uiu
一个最小可跑的个人 IP agent 骨架。借鉴 Hermes Agent 的 SOUL/skills/memory 模式,但砍到只剩核心。
它能做什么
- 跟你多轮对话,记住上下文(同一会话内)。
- 自动调用 3 个内置工具:
shell_exec/read_file/write_file。 - 自动调用
workspace/skills/*/SKILL.md里声明的 skill。 - 你的"人设"写在
workspace/SOUL.md里——改它,agent 就变样。 - 长记忆写在
workspace/MEMORY.md——对话里/memory <note>一键追加。 - 完整 CLI:配置模型、添加 skill、加 channel(目前支持 Telegram)、更新代码。
- 可发布到 PyPI:
uiu publish一行构建 + 上传,全世界pip install uiu。
安装(发布后)
pip install uiu # 安装
uiu init # 首次初始化 workspace
uiu # 开聊
或者不装全局,直接跑:
pipx run uiu
发布到 PyPI(作者用)
- 注册 PyPI 账号
- 到 API tokens 建一个 token(scope 选 "Entire account")
- 把 token 存环境变量:
$env:PYPI_TOKEN = "pypi-xxxxx"
- 发布:
uiu publish # 正式发布到 PyPI uiu publish --test # 先发 TestPyPI 试水
- 验证:
pip install uiu uiu version
发布前记得把
pyproject.toml里的version升版本(每次发布必须比上次大)。 发布后 1-2 分钟生效。
安装(本地开发)
cd E:\Code\Personal\agent\my-agent
python -m venv .venv
.\.venv\Scripts\Activate.ps1
pip install -e .
快速上手
uiu init # 建 workspace
uiu config --api-key sk-xxx # 写 API key
uiu model --set-model deepseek-chat \ # 换模型(DeepSeek/Moonshot/Ollama 都行)
--set-base-url https://api.deepseek.com/v1
uiu show # 看当前配置
uiu # 进 TUI 开聊
完整 CLI 参考
默认行为
uiu # 不带参数 → 进 TUI REPL
init
第一次跑:创建 workspace/ + .env 模板 + 必要目录。
uiu init
show
打印当前生效的配置(model + channels + secrets 状态):
uiu show
model
查看 / 修改模型配置(写入 workspace/config.yaml):
uiu model
uiu model --set-model deepseek-chat
uiu model --set-base-url https://api.moonshot.cn/v1
uiu model --set-api-key-env MOONSHOT_API_KEY
uiu model --set-temperature 0.3
uiu model --set-max-tokens 8192
config
管理 secrets(写入 workspace/.env):
uiu config --api-key sk-xxx # 写到 model.api_key_env 那把 key
uiu config --set-secret TELEGRAM_BOT_TOKEN=... # 任意 key=value
uiu config --list # 列出所有 secret(默认打码)
uiu config --list --show-values # 明文列出
uiu config --unset-secret TELEGRAM_BOT_TOKEN
skills
管理 skill:
uiu skills list # 列出已加载 skill
uiu skills add my_skill # 按模板新建
uiu skills edit my_skill # 用 $EDITOR 打开
uiu skills path # 打印 skills 目录
channel
管理外部渠道。目前 adapter:telegram(用官方 Bot API 做 token 校验)。
uiu channel list
uiu channel add tg-main --type telegram # 会自动用 TELEGRAM_BOT_TOKEN
uiu channel add tg-main --type telegram --secret-env MY_TG_TOKEN
uiu channel add tg-main --type telegram -o polling=true -o timeout=30
uiu channel test tg-main # 调 getMe 验证 token
uiu channel disable tg-main # 临时关掉
uiu channel enable tg-main
uiu channel remove tg-main
接 Telegram 的真正 gateway(轮询消息、转给 agent)没实现,只有 token 校验。
后续如果要长期监听 Telegram 消息,需要在 channels.py 加 gateway 函数 + 一个 serve 命令。
update
uiu update self # git pull(如有 remote)+ 重装,幂等
uiu update self --no-pull # 只重装,不拉远程
uiu update skills # 同步默认 skills 到 workspace
更新流程(推荐): 改完代码 → git add -A && git commit -m "..." → uiu update self。
git 本身就是回滚手段(git log / git revert),update 永不碰你的 workspace 人设。
publish
uiu publish # 构建 + 上传到 PyPI(需要 PYPI_TOKEN)
uiu publish --test # 构建 + 上传到 TestPyPI 试水
version
uiu version
TUI 内置命令
在 TUI 内(uiu 不带参数):
| 命令 | 干嘛 |
|---|---|
/help |
帮助 |
/skills |
列出已加载的 skill |
/tools |
列出内置工具 |
/identity |
打印 IDENTITY.md |
/memory <内容> |
追加一行到 MEMORY.md |
/clear |
清空对话上下文 |
/quit /exit |
退出 |
怎么变成"你的 agent"
- 改 SOUL.md:写你的价值观、口头禅、不喜欢的东西。这是灵魂。
- 改 IDENTITY.md:给它起名、定位、调性。
- 填 USER.md:告诉它你是谁。
- 加 skill:
workspace/skills/<name>/SKILL.md- 简单 skill:声明
exec: <内置名>(如exec: echo),再用 ```tool_schema 块声明参数。 - 复杂 skill:在
src/uiu/skills_runtime.py里注册 Python 函数当 builtin。
- 简单 skill:声明
- 加 channel:
uiu channel add <name> --type telegram然后uiu config --set-secret TELEGRAM_BOT_TOKEN=<botfather 给你的 token>
配置存储
| 文件 | 内容 | 入 git? |
|---|---|---|
workspace/config.yaml |
模型参数、channel 列表、agent_name | ✅ |
workspace/.env |
API key / bot token 等秘密 | ❌ 加到 .gitignore |
workspace/SOUL.md 等 |
人设 / 记忆 / skill 定义 | ✅ |
秘密走 *.env,配置走 *.yaml——这样你可以把整个 workspace push 到 GitHub 不泄露 token。
目录结构
uiu/
├── pyproject.toml
├── README.md
├── .env.example
├── src/uiu/ # 代码(~1100 行)
│ ├── main.py # CLI 入口(argparse subparsers)
│ ├── commands.py # 8 个子命令实现
│ ├── config.py # config.yaml + .env 读写
│ ├── channels.py # channel adapter(Telegram getMe)
│ ├── workspace.py # SOUL/skills/memory 加载
│ ├── llm.py # OpenAI 兼容客户端
│ ├── tools.py # 3 个内置工具 + registry
│ ├── skills_runtime.py # skill 执行器
│ ├── agent.py # 对话 + 工具调用循环
│ ├── tui.py # Rich + prompt_toolkit
│ └── _default_skills/say_hello/ # update skills 同步的内容
│ └── SKILL.md
└── workspace/ # 你的 IP 在这里
├── config.yaml
├── .env
├── SOUL.md
├── IDENTITY.md
├── USER.md
├── MEMORY.md
└── skills/
├── _default/say_hello/ # update skills 之后会出现在这
└── echo/ # 你自己加的 skill
和 Hermes 的关系
Hermes Agent 全量 10000+ 文件、cli.py 单文件 1MB。本骨架是其"工作区模式"的精简:
- ✅ 保留了:SOUL/IDENTITY/USER/MEMORY 分层、SKILL.md 渐进披露、内置工具 + 插件工具并行、对话循环。
- ❌ 砍掉了:多平台 gateway、cron、subagent 派发、训练数据生成、ACP/MCP 协议、桌面应用、UI 前端。
需要哪块再补,不预加载。
验证
仓库自带 cli_smoke.py(22 个测试用例覆盖全部子命令,不需要真 LLM/网络):
.venv\Scripts\python.exe cli_smoke.py
# === 22/22 passed ===
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file uiu-0.1.0.tar.gz.
File metadata
- Download URL: uiu-0.1.0.tar.gz
- Upload date:
- Size: 24.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.12.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
29b9d7343ada209bb2ece8c56fa0cdbd971540a11194edf7ed3e8d180318adb3
|
|
| MD5 |
7b16d9ac59fc69f2e69efc9146cab6fc
|
|
| BLAKE2b-256 |
9abaa1163ddff7cff0f9178acb55f875f9dd3188be665b49001a292390085520
|
File details
Details for the file uiu-0.1.0-py3-none-any.whl.
File metadata
- Download URL: uiu-0.1.0-py3-none-any.whl
- Upload date:
- Size: 30.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.12.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4f3a3feb3ab737a07b89159c371d03f85b808f0312127a5df65df6329896dc3d
|
|
| MD5 |
604e3b9ed606cd527b7b963db6914864
|
|
| BLAKE2b-256 |
f286d440a9699fc6c08ce23fe7925924c35226a350e07fd4dbd3fb1554996d2b
|