work-rhythm 0.1.2 → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.agents/notes/AGENTS.md +1 -0
- package/.agents/notes/decisions/2026-12-01-agent-binding-asks-for-model-and-effort.md +29 -0
- package/.agents/notes/decisions/2026-12-01-scheduling-is-cli-only-and-needs-a-bound-agent.md +1 -0
- package/.agents/skills/work-rhythm/SKILL.md +20 -7
- package/README.md +1 -1
- package/collectors/local.env.example +7 -0
- package/docs/agents.md +27 -10
- package/docs/formats.md +4 -0
- package/package.json +1 -1
- package/scripts/cli.js +14 -4
- package/scripts/cmd/agent.js +151 -43
- package/scripts/cmd/check.js +9 -1
- package/scripts/cmd/collect.js +10 -1
- package/scripts/cmd/decisions.js +17 -6
- package/scripts/cmd/events.js +103 -0
- package/scripts/cmd/goals.js +16 -20
- package/scripts/cmd/init.js +7 -1
- package/scripts/cmd/listen.js +7 -2
- package/scripts/cmd/notify.js +9 -1
- package/scripts/cmd/pack.js +7 -1
- package/scripts/cmd/rhythm.js +7 -2
- package/scripts/cmd/selftest.js +7 -1
- package/scripts/cmd/sync.js +12 -1
- package/scripts/cmd/today.js +13 -1
- package/scripts/cmd/workdir.js +5 -2
- package/scripts/lib/agent.js +139 -25
- package/scripts/lib/bot.js +2 -1
- package/scripts/lib/rhythm.js +10 -2
- package/scripts/test/agent.test.js +132 -6
- package/scripts/test/events.test.js +89 -0
- package/scripts/test/harness.js +8 -0
- package/scripts/test/help.test.js +71 -0
- package/scripts/test/listen.test.js +8 -4
- package/scripts/test/rhythm.test.js +21 -0
- package/templates/AGENTS.md +1 -1
- package/templates/README.md +1 -0
package/.agents/notes/AGENTS.md
CHANGED
|
@@ -23,6 +23,7 @@
|
|
|
23
23
|
| 改录耗费任务的指令或填法 | [录耗费直接写入,只填空格子](decisions/2026-11-30-cost-entry-writes-into-empty-cells-directly.md) |
|
|
24
24
|
| 改推送(`scripts/lib/notify.js`、`scripts/lib/robot.js`)、`docs/channels.md`、`preferences.notify` 的取值,或想知道提醒为什么不直接用 yzj-cli 给自己发 | [推送走个人机器人](decisions/2026-11-30-push-via-personal-robot-webhook.md)、[消息渠道预置进 skill](decisions/2026-11-30-message-channels-are-preset-in-the-skill.md) |
|
|
25
25
|
| 验证一条推送有没有送到,或想把机器人会话加进订阅 | [刚发的消息搜不到](pitfalls/2026-11-30-message-search-lags-after-sending.md) |
|
|
26
|
+
| 改模型 / 思考强度的配置、`agent models`,或想知道 zcode 为什么配不了模型 | [绑定时问模型和思考强度](decisions/2026-12-01-agent-binding-asks-for-model-and-effort.md) |
|
|
26
27
|
| 改引导第 6 步、`work-rhythm agent`、预置的 agent(`scripts/lib/agent.js`),或想知道为什么不往运行时的调度器建任务 | "+NEW+" |
|
|
27
28
|
| 改值守(`scripts/lib/bot.js`、`scripts/lib/agent.js`),想换一个回复的 agent,或要改值守的权限默认值 | [值守用长连接收消息](decisions/2026-11-30-bot-inbound-uses-websocket-and-a-responder-command.md) |
|
|
28
29
|
| 改本地服务(`scripts/lib/rhythm.js`)、`tasks/*.md`、`profile` 的 `rhythm:` 一节,或想知道定时任务为什么不绑在运行时的调度器上 | [运转的中心挪到本机服务](decisions/2026-11-30-scheduling-moves-to-a-local-service.md) |
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# 给 work-rhythm 绑定 agent 时,模型和思考强度也要问用户、写进配置、调用时真的带上
|
|
2
|
+
|
|
3
|
+
Decided: 2026-12-01
|
|
4
|
+
|
|
5
|
+
## Problem
|
|
6
|
+
|
|
7
|
+
[定时任务只建在 CLI 上,先绑一个 agent](2026-12-01-scheduling-is-cli-only-and-needs-a-bound-agent.md)只解决了「用哪个 agent」,没管「用哪个模型、思考强度多少」:预置只管能跑起来,模型都是各家命令行自己的默认——zcode 的无界面默认是 opencode-go 的 minimax-m3.1-flash,不是用户在窗口里给会话选的;dsh 跟着桌面应用的默认(本机是 deepseek-v4.1-flash、max)。用户要求:配置 agent 的时候用什么模型要问,思考强度也要配上。
|
|
8
|
+
|
|
9
|
+
## Decision
|
|
10
|
+
|
|
11
|
+
- `collectors/local.env` 加两个键:`YZJ_BOT_MODEL`、`YZJ_BOT_EFFORT`(none / low / medium / high / max)。不写就用 agent 自己的默认。定时任务可以另配:profile 的 `rhythm.agent-model` / `rhythm.agent-effort`,不配就沿用这两个。
|
|
12
|
+
- `work-rhythm agent bind` 接受 `--model` / `--effort`;`agent model <模型>` / `agent effort <强度>`(`--clear` 清掉);`agent models <名字>` 列出能用的;`agent doctor` 校验模型在它的清单里、强度在词表里;`agent test` 请 agent 自报模型。
|
|
13
|
+
- 各家怎么带上:dsh 写进自动生成的覆盖文件(`agent-default-model` 的 `provider` / `model` / `reasoningEffort`,清单来自它配置里的 `llm-pi-ai`);qoder 加 `--model` / `--reasoning-effort`;claude 加 `--model` / `--effort`。
|
|
14
|
+
- **zcode 不支持**:ZCode 的命令行(0.18.0)没有指定模型和强度的参数(`--help` 里没有,bundle 里 `"--model"` 只属于它内置的别家命令),`/model` 只能在交互界面里切。给它写模型或强度会被 `agent bind` / `agent model` 拒绝并说明原因。
|
|
15
|
+
- 引导第 6 步绑定后**必须问**:列出模型清单、标出当前默认,问用哪个,再问强度(给建议:定时任务 medium / high,值守聊天 low / medium);绑的是 zcode 如实说配不了。
|
|
16
|
+
|
|
17
|
+
## Alternatives considered
|
|
18
|
+
|
|
19
|
+
**不问,用各家默认。** 被否:用户明确要求问;而且默认往往不是想要的(zcode 的默认是 flash 档)。
|
|
20
|
+
|
|
21
|
+
**给 zcode 想办法绕(改它的 provider 配置、走 app-server 协议)。** 推迟:改用户 ZCode 的配置文件越界,app-server 协议为一件事引一整套不值;等它的命令行支持参数。
|
|
22
|
+
|
|
23
|
+
**强度词表按各家原样透传(qoder 还有 xhigh)。** 被否:五个词够用、各家都能映射;qoder 认 `xhigh` 的话直接写进 local.env 也行,命令层不列。
|
|
24
|
+
|
|
25
|
+
## Consequences
|
|
26
|
+
|
|
27
|
+
- 真机验证:dsh 绑 `zai-coding-cn/glm-5.3-flash` + `low`,覆盖文件换了,agent 自报 glm-5.3-flash,4 秒。qoder / claude 的模型参数按官方文档写,没在真机跑过(本机没装)。
|
|
28
|
+
- DSH 的配置是 YAML,用 lib/config 的解析器读(先是按缩进手写解析,对不上它的缩进,列不出模型)。
|
|
29
|
+
- `agent test` 的默认问题改成请它自报模型,回答不再是自我介绍。
|
package/.agents/notes/decisions/2026-12-01-scheduling-is-cli-only-and-needs-a-bound-agent.md
CHANGED
|
@@ -29,3 +29,4 @@ Decided: 2026-12-01
|
|
|
29
29
|
- Qoder 和 Claude Code 两个预置按官方文档写,没在真机上跑过(本机没装);`work-rhythm agent test` 是装了之后一步验证的办法。
|
|
30
30
|
- 「认正在调的 agent」靠环境变量,各家公司随时可能改名;认不出来只是退回让用户选,不会出错。
|
|
31
31
|
- `check` 不再把「配了 YZJ_BOT_AGENT」当成「要开值守」;装了值守才核对值守。
|
|
32
|
+
- 同日后续:绑定之后还要问模型和思考强度(zcode 的命令行配不了)。见[绑定时问模型和思考强度](2026-12-01-agent-binding-asks-for-model-and-effort.md)。
|
|
@@ -42,6 +42,7 @@ when_to_use: "第一次进入工作目录、初始化还没做完(setup.status
|
|
|
42
42
|
| 接入某个 IM | `docs/im-adapters.md` |
|
|
43
43
|
| 开通提醒推送(消息渠道),或给别的 IM 新增一个渠道 | `docs/channels.md` |
|
|
44
44
|
| 执行或设置定时任务 | `docs/scheduled-tasks.md` |
|
|
45
|
+
| 列事件流(`work-rhythm events`) | `work-rhythm events --help`;格式见 `docs/formats.md` 的「事件流」 |
|
|
45
46
|
| 给 work-rhythm 绑定 agent(定时任务和值守用哪个),或本机哪个 agent 能用 | `docs/agents.md` |
|
|
46
47
|
| 了解用户 | `00-config/profile.yaml`、`00-config/sources.yaml`、`05-goals/` |
|
|
47
48
|
| 写或改脚本、配置、文档格式之前,或者刚踩了坑 | `.agents/notes/AGENTS.md`,按它的路由表看相关的踩坑笔记 |
|
|
@@ -55,6 +56,7 @@ when_to_use: "第一次进入工作目录、初始化还没做完(setup.status
|
|
|
55
56
|
| `setup.status` 不是 `done`,用户只是打招呼或说「开始」「帮我弄」 | 从「引导流程」的步骤 0 开始,再接着第一个没完成的步骤 |
|
|
56
57
|
| 「记一下……」「刚才开了个会……」 | 记一笔 |
|
|
57
58
|
| 「同步一下」「拉一下数据」 | 同步并提炼事件 |
|
|
59
|
+
| 「今天都发生了什么」「事件流有什么变化」「我最近在忙什么」「X 那件事怎么样了」「这个月会多不多」,或任何问工作目录里的事 | 看「看事件流、问目录里的事」 |
|
|
58
60
|
| 「今天怎么安排」「做个计划」「进展」「复盘」「整理下遗留」 | 手动执行定时任务 |
|
|
59
61
|
| 「看看我的工作规律」「我最近在忙什么」 | 总结工作规律 |
|
|
60
62
|
| 「定个目标」「我想长期盯着 X」 | 长期目标 · 新建 |
|
|
@@ -158,12 +160,14 @@ IM 是工作密度最高的信号,也决定了后面能不能自动化,所
|
|
|
158
160
|
|
|
159
161
|
定时任务全在 `work-rhythm rhythm` 这个本地服务上:到点采集、到点把任务交给 agent 跑、跑完经消息渠道推送、在本机起网页服务。它和会话无关,agent 不在自己运行时的调度器上建任务——那条路已经不走了。服务到点要一个 agent 来跑,机器人值守(「消息渠道」)也是它来答,所以先绑一个。细节见 `docs/agents.md`。
|
|
160
162
|
|
|
161
|
-
1. **看本机有什么**:跑 `work-rhythm agent --json`。它列出预置的四个(zcode、dsh、qoder、claude
|
|
162
|
-
2.
|
|
163
|
-
3.
|
|
164
|
-
4.
|
|
165
|
-
5.
|
|
166
|
-
6.
|
|
163
|
+
1. **看本机有什么**:跑 `work-rhythm agent --json`。它列出预置的四个(zcode、dsh、qoder、claude)各装没装、哪个能配模型,以及现在是不是有 agent 正在调这个 skill(按它给工具留的环境变量认)。
|
|
164
|
+
2. **定绑哪个**:默认就用正在调这个 skill 的 agent——用户正在用它,登录是现成的;它没装命令行、或用户想换,就把装了的列出来让他选。用 `work-rhythm agent bind <名字>` 写进 `collectors/local.env`(`YZJ_BOT_AGENT`)。一个都没装:如实说定时任务和机器人值守现在做不了,按 `docs/agents.md` 教他装一个,`schedule` 留空,原因记进 `setup.skipped`,下面的 3–8 不做。
|
|
165
|
+
3. **问模型和思考强度**(一定要问,不要替用户定):`work-rhythm agent models <名字>` 列出能用的,把清单给用户看,标清哪个是它当前的默认;问他用哪个模型,再问思考强度多少——`low` 快而省,`medium` 日常够用,`high` / `max` 想得深但慢、费 token;定时任务整理一天的事件建议 `medium` 或 `high`,机器人值守聊天建议 `low` 或 `medium`。用户说「随便」就用它当前的默认模型加 `medium`。定下来用 `work-rhythm agent bind <名字> --model <模型> --effort <强度>`(或 `agent model` / `agent effort`)写进 `collectors/local.env`。绑的是 zcode 时如实说:ZCode 的命令行没有指定模型和强度的参数,用的是它自己的默认(本机实测是 opencode-go 的 minimax-m3.1-flash),在意的话换 dsh / qoder。想给定时任务另配一套,写 profile 的 `rhythm.agent-model` / `rhythm.agent-effort`。
|
|
166
|
+
4. **试一句**:`work-rhythm agent test` 让它自报模型,把回答给用户看,确认模型对得上、登录没过期。
|
|
167
|
+
5. **定时间**:问上下班时间,按 `docs/scheduled-tasks.md` 的默认规则换算出时间点(上班前 10 分钟、午休开始、下班前 15 分钟),用户确认后写入 `schedule`;不要的任务在 `schedule` 里写空。介绍几个标准任务(每日工作计划、中午工作进展、晚间工作复盘、遗留待处理)和可选的每周工作规律,确认要开哪些。
|
|
168
|
+
6. **说明待决的事怎么走**:不做定时巡查。计划和复盘的推送里会提醒有几件等他定,到时候对任何一个能读到这个工作目录的 agent 说「有什么要我定」,就逐件来问。
|
|
169
|
+
7. **装服务**:`work-rhythm rhythm doctor` 查配置,`work-rhythm rhythm due` 给用户看今天什么时候跑什么;`work-rhythm rhythm run <任务id> --push` 试一遍,看推送和页面。征得同意后 `install`(macOS launchd 常驻)或者让用户自己 `start`。
|
|
170
|
+
8. 把 `setup.status` 改成 `done`,更新 `setup.updated`。
|
|
167
171
|
|
|
168
172
|
### 步骤 7:交代用法
|
|
169
173
|
|
|
@@ -184,9 +188,18 @@ IM 是工作密度最高的信号,也决定了后面能不能自动化,所
|
|
|
184
188
|
|
|
185
189
|
1. 跑 `work-rhythm sync [起始日期]` 同步所有已启用的源,或者只跑某一个:`work-rhythm sync <起始日期> <源id>`(数据落在 `01-inbox/<源id>/<今天>/`)。失败的源在今天文件「## 备注」里记一行(「12:30 同步:im-yzj 失败,未登录」),继续处理其他源。
|
|
186
190
|
2. 读 `01-inbox/` 里的输出,按各源在 `00-config/sources.yaml` 里的 `extract` 规则提炼事件。规则遵守 `docs/formats.md` 的「事件流」一节。
|
|
187
|
-
3. 合并进今天文件的「## 事件流」:替换同来源同时段的旧事件,保留 `口述`
|
|
191
|
+
3. 合并进今天文件的「## 事件流」:替换同来源同时段的旧事件,保留 `口述` 的行,按时间排序(合并后 `work-rhythm events --today` 能把它列出来,核对一眼)。
|
|
188
192
|
4. 汇报一行:新增多少条事件,哪些源失败。
|
|
189
193
|
|
|
194
|
+
## 看事件流、问目录里的事
|
|
195
|
+
|
|
196
|
+
用户问工作目录里的事——今天发生了什么、事件流有什么变化、最近在忙什么、某件事进展如何、会多不多、哪些事快搁置了——答案都在这个目录里,不要凭印象答:
|
|
197
|
+
|
|
198
|
+
1. **先取数**:`work-rhythm events --today`(或 `--days N`、`--from/--to`;`--type`、`--source`、`--project` 筛选;`--json` 给程序读)拿到事件流,它是每日文件「## 事件流」那张表 flatten 后的样子。再按问题读对应的记录:遗留 `03-carryover/CARRYOVER.md`,决定 `work-rhythm decisions list`,目标 `work-rhythm goals list` 和 `05-goals/`,规律画像 `04-patterns/WORK_RHYTHM.md`,我是谁 `00-config/profile.yaml`。事件流还停在早上,就先 `work-rhythm sync` 并提炼一遍(上一节)。
|
|
199
|
+
2. **答问题**:先结论,再依据(哪天几点、哪个来源),不展开细节。数字从取到的数据里数,不估。没有记录就说没有,不编。
|
|
200
|
+
3. **顺着变化做事**:事件流里有新东西时,想着下一步——新冒出来的工作项、告警,问要不要进遗留;搁置快满 5 个工作日的提醒一句;和长期目标有关的事件,记进展(`work-rhythm goals progress <id>`);日程变了,建议调今天的计划;有该我定的事,`work-rhythm decisions add … --choice 未答` 记下,再问我。记一笔、同步、更新每日文件这类只写工作目录的动作直接做;其余都是建议,先说再做。
|
|
201
|
+
4. 答完问一句:要不要据此做点什么。
|
|
202
|
+
|
|
190
203
|
## 接入一个数据源
|
|
191
204
|
|
|
192
205
|
用户说「把 XX 接进来」,或者在引导里点名了某个记录系统(工作项、日志、文档、工时、审批……)时,不管 `docs/sources.md` 的目录里有没有它,都按这个顺序:
|
package/README.md
CHANGED
|
@@ -31,7 +31,7 @@ ln -s "$(npm root -g)/work-rhythm/.agents/skills/work-rhythm" ~/.agents/skills/w
|
|
|
31
31
|
| 命令 | 做什么 |
|
|
32
32
|
|---|---|
|
|
33
33
|
| `init`、`workdir` | 新建工作目录;找到、登记、扫描工作目录 |
|
|
34
|
-
| `today`、`goals`、`decisions` |
|
|
34
|
+
| `today`、`goals`、`decisions`、`events` | 每日约定、长期目标、待决与决定的记录、事件流 |
|
|
35
35
|
| `sync`、`collect` | 跑内置或自己写的采集器,原始数据落 `01-inbox/` |
|
|
36
36
|
| `notify`、`listen` | 消息渠道:把提醒推给我;值守,收我在 IM 里说的话交给本地 agent |
|
|
37
37
|
| `agent` | 定时任务和机器人值守用哪个 agent:检测本机的、绑定、试一句([docs/agents.md](docs/agents.md)) |
|
|
@@ -42,6 +42,13 @@
|
|
|
42
42
|
# "qoder" Qoder CLI(要另装:curl -fsSL https://qoder.com/install | bash,装完 qoder login)。模型和登录跟着 Qoder CLI 自己的配置
|
|
43
43
|
# "claude" Claude Code 的命令行
|
|
44
44
|
# 一条自己的命令:我的消息作为最后一个参数传给它,回复打到标准输出,退出码 0 算成功。路径带空格的命令先写成一个脚本再写它的路径
|
|
45
|
+
# 用哪个模型、思考强度多少(引导时会问你;只有 dsh / qoder / claude 认,zcode 的命令行没有这两个参数,用它自己的默认):
|
|
46
|
+
# work-rhythm agent models <名字> 列出能用的
|
|
47
|
+
# work-rhythm agent model <模型> dsh 写「provider/模型id」或模型id,qoder / claude 写它们认的模型名;不写用 agent 自己的默认
|
|
48
|
+
# work-rhythm agent effort <强度> none / low / medium / high / max;不写用 agent 自己的默认
|
|
49
|
+
# 定时任务想另配一套,写 profile 的 rhythm.agent-model / rhythm.agent-effort
|
|
50
|
+
# YZJ_BOT_MODEL="opencode-go/deepseek-v4.1-flash"
|
|
51
|
+
# YZJ_BOT_EFFORT="medium"
|
|
45
52
|
# YZJ_BOT_AGENT_MODE 是权限:plan 只读(默认,能查能答能出计划,不改文件);edit 允许改工作目录,等于我在聊天里说什么它就做什么
|
|
46
53
|
# YZJ_BOT_TIMEOUT 每条消息最多等多少秒(默认 300);YZJ_BOT_REPLY_MAX 回复最多多少字(默认 2000,超出截断并注明)
|
|
47
54
|
# 消息一到机器人先回「收到,正在处理,稍等。」,YZJ_BOT_ACK=0 关掉。
|
package/docs/agents.md
CHANGED
|
@@ -3,10 +3,12 @@
|
|
|
3
3
|
定时任务全在 `work-rhythm rhythm` 这个本地服务上,agent 不在自己运行时的调度器上建任务。服务到点要把任务交给一个 agent 跑,机器人值守([channels.md](channels.md))也是它来答——所以要先给 work-rhythm 绑定一个 agent。没绑就没有定时任务(`rhythm` 拒绝起),也不支持机器人响应(`listen` 拒绝跑)。
|
|
4
4
|
|
|
5
5
|
```sh
|
|
6
|
-
work-rhythm agent # 本机装了哪些、现在是不是有 agent 正在调这个 skill
|
|
7
|
-
work-rhythm agent bind [名字|命令] # 绑定,写进 collectors/local.env 的 YZJ_BOT_AGENT
|
|
8
|
-
work-rhythm agent
|
|
9
|
-
work-rhythm agent
|
|
6
|
+
work-rhythm agent # 本机装了哪些、现在是不是有 agent 正在调这个 skill、现在绑的是哪个、模型和强度是多少
|
|
7
|
+
work-rhythm agent bind [名字|命令] # 绑定,写进 collectors/local.env 的 YZJ_BOT_AGENT;--model / --effort 一起写
|
|
8
|
+
work-rhythm agent models [名字] # 这个 agent 能用哪些模型
|
|
9
|
+
work-rhythm agent model <模型> # 只换模型;agent effort <强度> 只换思考强度(--clear 清掉)
|
|
10
|
+
work-rhythm agent test ["一句话"] # 让绑定的 agent 只读答一句(自报模型),看模型和凭据通不通
|
|
11
|
+
work-rhythm agent doctor # 绑定的 agent、模型、强度有没有问题
|
|
10
12
|
```
|
|
11
13
|
|
|
12
14
|
绑哪个:**现在正在调这个 skill 的那个 agent,它装了的话就用它**——用户正在用它,模型和登录都是现成的;它没装命令行、或者用户想换,就从装了的里面选;都由用户定。一个都没装,如实说定时任务和值守现在做不了,教他装一个(下表),`schedule` 留空,原因记进 `setup.skipped`。
|
|
@@ -15,10 +17,10 @@ work-rhythm agent doctor # 绑定的 agent 配置和依赖有没有
|
|
|
15
17
|
|
|
16
18
|
| 名字 | 是什么 | 怎么找到 | 模型和凭据跟谁走 | 实测 |
|
|
17
19
|
|---|---|---|---|---|
|
|
18
|
-
| `zcode` | ZCode 自带的命令行(桌面版里就有,不用另装) | PATH 上的 `zcode`,或 `/Applications/ZCode.app/Contents/Resources/glm/zcode.cjs`;`ZCODE_CLI` 可指定 | 它自己的默认选择,不是 ZCode
|
|
19
|
-
| `dsh` | DSH(DeepSeek Harness)桌面版的 headless 模式 | `~/.dsh-desktop/runtime/<版本>/dsh/` 下的入口,用它自带的 Node 跑;`DSH_HOME`、`DSH_NODE`、`DSH_CLI` 可指定 | DSH 桌面应用里配好的模型和凭据(值守自动生成一份只含模型配置、并打开凭据存储的覆盖文件带进去,密钥始终在 DSH
|
|
20
|
-
| `qoder` | Qoder CLI。装了 Qoder 的 IDE 不等于装了它:`curl -fsSL https://qoder.com/install \| bash`(或 `npm install -g @qoder-ai/qodercli`),装完 `qoder login` | PATH 上的 `qoder` / `qodercli`;`QODER_CLI` 可指定 | Qoder CLI 自己的配置(`~/.qoder
|
|
21
|
-
| `claude` | Claude Code 的命令行 | PATH 上的 `claude`;`CLAUDE_CLI` 可指定 | Claude Code
|
|
20
|
+
| `zcode` | ZCode 自带的命令行(桌面版里就有,不用另装) | PATH 上的 `zcode`,或 `/Applications/ZCode.app/Contents/Resources/glm/zcode.cjs`;`ZCODE_CLI` 可指定 | 它自己的默认选择,不是 ZCode 窗口里给会话选的模型;命令行没有指定模型和强度的参数,配不了 | 是 |
|
|
21
|
+
| `dsh` | DSH(DeepSeek Harness)桌面版的 headless 模式 | `~/.dsh-desktop/runtime/<版本>/dsh/` 下的入口,用它自带的 Node 跑;`DSH_HOME`、`DSH_NODE`、`DSH_CLI` 可指定 | DSH 桌面应用里配好的模型和凭据(值守自动生成一份只含模型配置、并打开凭据存储的覆盖文件带进去,密钥始终在 DSH 自己的存储里);模型和强度可用 `YZJ_BOT_MODEL` / `YZJ_BOT_EFFORT` 换,清单来自它的配置 | 是 |
|
|
22
|
+
| `qoder` | Qoder CLI。装了 Qoder 的 IDE 不等于装了它:`curl -fsSL https://qoder.com/install \| bash`(或 `npm install -g @qoder-ai/qodercli`),装完 `qoder login` | PATH 上的 `qoder` / `qodercli`;`QODER_CLI` 可指定 | Qoder CLI 自己的配置(`~/.qoder`);模型和强度可用 `YZJ_BOT_MODEL` / `YZJ_BOT_EFFORT` 换 | 按官方文档写的,没在真机上跑过 |
|
|
23
|
+
| `claude` | Claude Code 的命令行 | PATH 上的 `claude`;`CLAUDE_CLI` 可指定 | Claude Code 自己的登录;模型和强度可换 | 按公开的用法写的,没在真机上跑过 |
|
|
22
24
|
|
|
23
25
|
其余值当成一条自己的命令:按空白拆开(引号里的算一个参数),消息作为最后一个参数传给它,回复打到标准输出,退出码 0 算成功。不支持管道、重定向——要的话包一层脚本。
|
|
24
26
|
|
|
@@ -26,8 +28,23 @@ work-rhythm agent doctor # 绑定的 agent 配置和依赖有没有
|
|
|
26
28
|
|
|
27
29
|
- zcode:`zcode --cwd <工作目录> --mode <模式> [--resume <会话>] --no-color --json -p <这句话>`,回答在 JSON 的 `response`,会话在 `sessionId`。
|
|
28
30
|
- dsh:`<自带 node> --import <tsx> <入口> --profile headless --patch <覆盖文件> --permission-mode <模式> [--session-id <会话>] --json <这句话>`,`--json` 一行一个事件,回答在 `final`。
|
|
29
|
-
- qoder:`qoder --cwd <工作目录> --permission-mode <模式> [--resume <会话>] --output-format json --print <这句话>`,回答在 JSON 的 `result`,会话在 `session_id`。无界面模式下它不弹确认,要确认的操作一律被拒。
|
|
30
|
-
- claude:`claude --cwd <工作目录> --permission-mode <模式> [--resume <会话>] --output-format json -p <这句话>`。
|
|
31
|
+
- qoder:`qoder --cwd <工作目录> --permission-mode <模式> [--model <模型>] [--reasoning-effort <强度>] [--resume <会话>] --output-format json --print <这句话>`,回答在 JSON 的 `result`,会话在 `session_id`。无界面模式下它不弹确认,要确认的操作一律被拒。
|
|
32
|
+
- claude:`claude --cwd <工作目录> --permission-mode <模式> [--model <模型>] [--effort <强度>] [--resume <会话>] --output-format json -p <这句话>`。
|
|
33
|
+
|
|
34
|
+
## 模型和思考强度
|
|
35
|
+
|
|
36
|
+
引导第 6 步绑定 agent 时要问用户两件事:用哪个模型、思考强度多少。写在 `collectors/local.env`:
|
|
37
|
+
|
|
38
|
+
| 键 | 意思 | 怎么取值 |
|
|
39
|
+
|---|---|---|
|
|
40
|
+
| `YZJ_BOT_MODEL` | 模型。不写用 agent 自己的默认 | `work-rhythm agent models <名字>` 列出能用的;dsh 写 `provider/模型id`(如 `zai-coding-cn/glm-5.3-flash`)或只写模型id;qoder 写它认的档位或模型名(`auto` / `lite` / `performance` / 具体模型);claude 写 `opus` / `sonnet` / `haiku` 或全名 |
|
|
41
|
+
| `YZJ_BOT_EFFORT` | 思考强度。不写用 agent 自己的默认 | `none` / `low` / `medium` / `high` / `max`:`low` 快而省,`medium` 日常够用,`high` / `max` 想得深但慢、费 token |
|
|
42
|
+
|
|
43
|
+
改用 `work-rhythm agent model <模型>` / `agent effort <强度>`(`--clear` 清掉),或者绑的时候一起写 `agent bind <名字> --model … --effort …`;写完 `work-rhythm agent test` 让它自报模型核对。
|
|
44
|
+
|
|
45
|
+
各家怎么带上:dsh 写进自动生成的覆盖文件(`agent-default-model` 的 `provider` / `model` / `reasoningEffort`,2026-12-01 实测换模型生效);qoder 加 `--model` / `--reasoning-effort`(它还认 `xhigh`,我们没列,要的话直接写进 local.env);claude 加 `--model` / `--effort`。**zcode 不支持**:ZCode 的命令行(0.18.0)没有指定模型和强度的参数,`/model` 只能在交互界面里切,无界面跑用它自己的默认选择;给它写了 `YZJ_BOT_MODEL` 会在 `agent doctor` 里报出来,调用时也不生效。
|
|
46
|
+
|
|
47
|
+
定时任务可以用和值守不一样的一套:profile 的 `rhythm` 一节写 `agent-model` / `agent-effort`(可选项),不配就沿用上面两个。
|
|
31
48
|
|
|
32
49
|
## 权限
|
|
33
50
|
|
package/docs/formats.md
CHANGED
|
@@ -117,6 +117,10 @@
|
|
|
117
117
|
- 来源填订阅源的 id(见 [00-config/sources.yaml](../00-config/sources.yaml)),用户自己说的填 `口述`。
|
|
118
118
|
- 项目填简短标签,归不进去就留空。事件和某个长期目标相关时,项目列填目标的 id。
|
|
119
119
|
|
|
120
|
+
### agent 怎么读
|
|
121
|
+
|
|
122
|
+
`work-rhythm events` 把一段时间里的这张表列出来(`--days N`、`--from/--to`、`--type`、`--source`、`--project`、`--json`),按日期、时间排好;写完之后用它核对一眼。
|
|
123
|
+
|
|
120
124
|
### 合并
|
|
121
125
|
|
|
122
126
|
- 同一来源、同一类型、30 分钟内连续发生的活动合成一条;编码类放宽到 90 分钟。
|
package/package.json
CHANGED
package/scripts/cli.js
CHANGED
|
@@ -19,6 +19,7 @@ const COMMANDS = {
|
|
|
19
19
|
decisions: 'decisions add | answer | done | list | archive … 待决与决定的记录',
|
|
20
20
|
sync: 'sync [起始日期] [源 id …] 依次运行已启用的源,原始数据落 01-inbox/<源>/<今天>',
|
|
21
21
|
collect: 'collect <源id> <输出目录> [起始日期] 只跑一个采集器',
|
|
22
|
+
events: 'events [--days N] [--today] [--type …] [--json] 列出每日文件里的事件流:什么时候、做了什么、属于哪个项目',
|
|
22
23
|
notify: 'notify "<文字>" | - 把一段文字经消息渠道推给我本人,或从标准输入读',
|
|
23
24
|
check: 'check 改完脚本、配置或文档后跑一遍:语法、内链、预算、配置、密钥、笔记',
|
|
24
25
|
listen: 'listen probe|run|handle|handle-frame|reset|doctor|install|uninstall|status 值守:收我在 IM 里说的话,交给本地 agent 回复',
|
|
@@ -39,11 +40,14 @@ const usage = (name) => {
|
|
|
39
40
|
const lines = Object.entries(COMMANDS).map(([key, text]) => ` ${text}`);
|
|
40
41
|
return `work-rhythm ${VERSION} —— 个人工作目录的日常运转
|
|
41
42
|
用法: work-rhythm <子命令> [参数] [--workdir <目录>]
|
|
42
|
-
|
|
43
|
+
每个子命令的详细用法: work-rhythm <子命令> --help(写在子命令后面也行,任何位置都认)
|
|
44
|
+
在工作目录里运行就作用在那个目录上;不在时往上找带 00-config/profile.yaml 的目录,也可以用 --workdir 指定
|
|
45
|
+
退出码约定: 0 成功 · 2 用法不对 · 3 没配置好(含「不在工作目录里」)· 4 缺依赖 · 5 运行失败;
|
|
46
|
+
check 和各 doctor 用 1 表示「查出了问题」。子命令有别的约定时它的 --help 里会写
|
|
43
47
|
|
|
44
48
|
${lines.join('\n')}
|
|
45
49
|
--help [子命令] | --version
|
|
46
|
-
|
|
50
|
+
流程和规则在 work-rhythm skill(.agents/skills/work-rhythm/SKILL.md);消息渠道见 docs/channels.md,定时任务见 docs/scheduled-tasks.md,agent 见 docs/agents.md。`;
|
|
47
51
|
};
|
|
48
52
|
|
|
49
53
|
async function main(argv) {
|
|
@@ -77,6 +81,12 @@ async function main(argv) {
|
|
|
77
81
|
stderr.write(`work-rhythm: 不认识的子命令「${name}」\n\n${usage()}\n`);
|
|
78
82
|
return EXIT.USAGE;
|
|
79
83
|
}
|
|
84
|
+
// 「work-rhythm notify --help」这种:任何位置出现 --help / -h,或者第一个参数是 help,都只打用法、什么都不做。
|
|
85
|
+
// 必须在分发之前截住——不然 notify 会把「--help」当成要发的文字发出去,init 会建一个叫 --help 的目录
|
|
86
|
+
if (rest.includes('--help') || rest.includes('-h') || rest[0] === 'help') {
|
|
87
|
+
stdout.write(`${usage(name)}\n`);
|
|
88
|
+
return EXIT.OK;
|
|
89
|
+
}
|
|
80
90
|
// 作用在哪个目录:--workdir 指定的,或从当前目录往上找;站在这个包自己的仓库里就是仓库(只有 check 查它);最后看用户级的登记
|
|
81
91
|
const found = resolveRoot({ cwd: process.cwd(), option: rootOption, env: process.env, packageRoot: PACKAGE_ROOT });
|
|
82
92
|
const ctx = { root: found.root, rootSource: found.source, cwd: process.cwd(), stdin: process.stdin, stdout, stderr, env: process.env, packageRoot: PACKAGE_ROOT };
|
|
@@ -90,9 +100,9 @@ async function main(argv) {
|
|
|
90
100
|
try {
|
|
91
101
|
return await require(`./cmd/${name}`).run(rest, ctx);
|
|
92
102
|
} catch (error) {
|
|
93
|
-
//
|
|
103
|
+
// 用法不对、没配置好、缺依赖、没跑成:消息打给用户,按它带的退出码结束。用法错的顺带告诉它用法在哪
|
|
94
104
|
if (error instanceof Fail) {
|
|
95
|
-
stderr.write(`work-rhythm ${name}: ${error.message}\n`);
|
|
105
|
+
stderr.write(`work-rhythm ${name}: ${error.message}${error.code === EXIT.USAGE ? `\n(用法: work-rhythm ${name} --help)` : ''}\n`);
|
|
96
106
|
return error.code;
|
|
97
107
|
}
|
|
98
108
|
throw error;
|
package/scripts/cmd/agent.js
CHANGED
|
@@ -1,30 +1,48 @@
|
|
|
1
|
-
// work-rhythm agent:定时任务和机器人值守都要一个 agent
|
|
2
|
-
// 用法: work-rhythm agent
|
|
3
|
-
// work-rhythm agent
|
|
4
|
-
// work-rhythm agent
|
|
5
|
-
//
|
|
6
|
-
// work-rhythm agent
|
|
7
|
-
//
|
|
8
|
-
//
|
|
9
|
-
//
|
|
1
|
+
// work-rhythm agent:定时任务和机器人值守都要一个 agent 来跑,这里管「用哪个 agent、哪个模型、思考强度多少」。
|
|
2
|
+
// 用法: work-rhythm agent 看本机装了哪些、现在是不是有 agent 正在调这个 skill、现在绑的是哪个、模型和强度
|
|
3
|
+
// work-rhythm agent models [名字] 这个 agent 能用哪些模型(不给名字就是绑定的那个)
|
|
4
|
+
// work-rhythm agent bind <名字|命令> [--model <模型>] [--effort <强度>]
|
|
5
|
+
// 绑定,写进 collectors/local.env 的 YZJ_BOT_AGENT;模型和强度写了就一起写
|
|
6
|
+
// work-rhythm agent model <模型id> | agent model --clear 只换模型
|
|
7
|
+
// work-rhythm agent effort <强度> | agent effort --clear 只换思考强度
|
|
8
|
+
// work-rhythm agent test ["一句话"] 让绑定的 agent 答一句(自报模型),看模型和凭据通不通
|
|
9
|
+
// work-rhythm agent doctor 绑定的 agent、模型、强度有没有问题
|
|
10
|
+
// work-rhythm agent --json 打成 JSON,给 agent 读
|
|
11
|
+
// 预置:zcode、dsh、qoder、claude;其余值当成一条自己的命令。
|
|
12
|
+
// 「正在调这个 skill 的是哪个」看它给工具留的环境变量。模型和强度只有支持的预置才认(zcode 的命令行没有这两个参数)。
|
|
13
|
+
// 没绑 agent 就没有定时任务(rhythm 拒绝起)和机器人响应(listen 拒绝跑)。细节见 docs/agents.md
|
|
10
14
|
'use strict';
|
|
11
15
|
const fs = require('node:fs');
|
|
12
16
|
const path = require('node:path');
|
|
13
17
|
const { EXIT, Fail, UsageError } = require('../lib/run');
|
|
14
18
|
const { settings } = require('../lib/config');
|
|
15
|
-
const { PRESETS, PRESET_NAMES, invokingAgent, installedAgents, bindAgent, createAgent } = require('../lib/agent');
|
|
19
|
+
const { PRESETS, PRESET_NAMES, MODEL_SUPPORT, EFFORTS, invokingAgent, installedAgents, bindAgent, createAgent, listModels } = require('../lib/agent');
|
|
16
20
|
|
|
17
|
-
const USAGE =
|
|
18
|
-
|
|
21
|
+
const USAGE = `work-rhythm agent [子命令] —— 定时任务和机器人值守用哪个 agent、哪个模型、思考强度多少:检测本机的、绑定、试一句
|
|
22
|
+
|
|
23
|
+
用法: work-rhythm agent [子命令]
|
|
24
|
+
看本机装了哪些、现在是不是有 agent 正在调这个 skill、现在绑的是哪个、模型和强度是多少(--json 打成 JSON)
|
|
25
|
+
models [名字] 这个 agent 能用哪些模型(不给名字就是绑定的那个);dsh 读它的配置,qoder 问命令行,claude 给常见的别名
|
|
19
26
|
bind [名字|命令] 绑定,写进 collectors/local.env 的 YZJ_BOT_AGENT;不给名字就用正在调的这个,没有就装了的第一个
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
27
|
+
[--model <模型>] 一起写模型:dsh 写「provider/模型id」或模型id;qoder、claude 写它们认的模型名。不写不动原来的
|
|
28
|
+
[--effort <强度>] 一起写思考强度:none / low / medium / high / max。不写不动原来的
|
|
29
|
+
model <模型id> 只换模型;model --clear 清掉,用 agent 自己的默认
|
|
30
|
+
effort <强度> 只换思考强度(none / low / medium / high / max);effort --clear 清掉
|
|
31
|
+
test ["一句话"] 让绑定的 agent 答一句(默认请它自报模型),只读
|
|
32
|
+
doctor 绑定的 agent、模型、强度有没有问题
|
|
33
|
+
预置:${PRESET_NAMES.join('、')}。模型和强度只有 ${PRESET_NAMES.filter((n) => MODEL_SUPPORT[n].model).join('、')} 支持(zcode 的命令行没有这两个参数,用它自己的默认);
|
|
34
|
+
其余值当成一条自己的命令(消息作为最后一个参数,回复打到标准输出)。
|
|
35
|
+
定时任务可以另配模型和强度:profile 的 rhythm.agent-model / rhythm.agent-effort,不配就和这里一样。
|
|
36
|
+
退出码: 0;1 doctor 查出问题;2 用法不对;3 没绑或绑不上(本机找不到那个 agent、模型不在它的清单里、它不支持这个设置);5 test 没答上来。
|
|
37
|
+
各家怎么被调用、权限模式见 docs/agents.md。`;
|
|
23
38
|
|
|
24
39
|
function binding(root, env) {
|
|
25
|
-
|
|
40
|
+
const s = settings(root, env);
|
|
41
|
+
return { agent: (s.YZJ_BOT_AGENT || '').trim(), model: (s.YZJ_BOT_MODEL || '').trim(), effort: (s.YZJ_BOT_EFFORT || '').trim() };
|
|
26
42
|
}
|
|
27
43
|
|
|
44
|
+
const kindOf = (name) => (PRESET_NAMES.includes(name) ? name : name ? 'custom' : '');
|
|
45
|
+
|
|
28
46
|
// 建议绑哪个:正在调这个 skill 的那个(它装了的话);否则装了的第一个;都没有就空
|
|
29
47
|
function suggest(list) {
|
|
30
48
|
const invoking = list.find((a) => a.invoking && a.found);
|
|
@@ -33,6 +51,54 @@ function suggest(list) {
|
|
|
33
51
|
return first ? first.name : '';
|
|
34
52
|
}
|
|
35
53
|
|
|
54
|
+
// 模型和强度对这个 agent 意味着什么,一句话
|
|
55
|
+
function describeModel(kind, model, effort) {
|
|
56
|
+
if (kind === 'custom') return model || effort ? '自定义命令:模型和强度写在你的命令里,这里不传' : '';
|
|
57
|
+
const support = MODEL_SUPPORT[kind] || {};
|
|
58
|
+
const parts = [];
|
|
59
|
+
parts.push(model ? (support.model ? `模型 ${model}` : `写了模型 ${model},但 ${kind} 不支持,不生效`) : '模型用它自己的默认');
|
|
60
|
+
parts.push(effort ? (support.effort ? `思考强度 ${effort}` : `写了思考强度 ${effort},但 ${kind} 不支持,不生效`) : '思考强度用它自己的默认');
|
|
61
|
+
return parts.join(',');
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
// 把某个预置能用的模型列出来
|
|
65
|
+
function showModels(kind, env, stdout) {
|
|
66
|
+
const r = listModels(kind, env);
|
|
67
|
+
if (r.problem) throw new Fail(EXIT.NOT_CONFIGURED, r.problem);
|
|
68
|
+
if (r.text) {
|
|
69
|
+
stdout.write(r.text.endsWith('\n') ? r.text : `${r.text}\n`);
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
const current = r.current || {};
|
|
73
|
+
stdout.write(`${kind} 能用的模型:\n`);
|
|
74
|
+
for (const m of r.models) {
|
|
75
|
+
const marks = [];
|
|
76
|
+
if (current.model === m.id) marks.push('当前默认');
|
|
77
|
+
if (m.reasoning) marks.push('支持思考强度');
|
|
78
|
+
stdout.write(` ${(m.provider ? `${m.provider}/${m.id}` : m.id).padEnd(40)} ${m.name || ''}${marks.length ? ` ${marks.join(' · ')}` : ''}\n`);
|
|
79
|
+
}
|
|
80
|
+
if (current.effort) stdout.write(`当前默认的思考强度:${current.effort}\n`);
|
|
81
|
+
if (!r.models.length) stdout.write(' (没列出来:看它的文档或 --list-models)\n');
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
// bind 的参数:<名字> 可选(最多一个),--model X / --effort X 可选,顺序随意
|
|
85
|
+
function parseBind(params) {
|
|
86
|
+
const names = [];
|
|
87
|
+
const opts = {};
|
|
88
|
+
for (let i = 0; i < params.length; i += 1) {
|
|
89
|
+
const a = params[i];
|
|
90
|
+
if (a === '--model' || a === '--effort') {
|
|
91
|
+
const v = params[i + 1];
|
|
92
|
+
if (v === undefined || v.startsWith('--')) throw new UsageError(`${a} 后面要跟一个值\n${USAGE}`);
|
|
93
|
+
opts[a.slice(2)] = v;
|
|
94
|
+
i += 1;
|
|
95
|
+
} else if (a.startsWith('--')) throw new UsageError(`不认识的参数 ${a}\n${USAGE}`);
|
|
96
|
+
else names.push(a);
|
|
97
|
+
}
|
|
98
|
+
if (names.length > 1) throw new UsageError(USAGE);
|
|
99
|
+
return { name: names[0], opts };
|
|
100
|
+
}
|
|
101
|
+
|
|
36
102
|
module.exports = {
|
|
37
103
|
usage: USAGE,
|
|
38
104
|
async run(args, ctx) {
|
|
@@ -42,61 +108,107 @@ module.exports = {
|
|
|
42
108
|
const rest = args.filter((a) => a !== '--json');
|
|
43
109
|
const [verb, ...params] = rest;
|
|
44
110
|
const bound = binding(root, env);
|
|
111
|
+
const boundKind = kindOf(bound.agent);
|
|
45
112
|
|
|
46
113
|
switch (verb) {
|
|
47
114
|
case undefined: {
|
|
48
115
|
if (params.length) throw new UsageError(USAGE);
|
|
49
116
|
const invoking = invokingAgent(env);
|
|
50
117
|
const pick = suggest(list);
|
|
51
|
-
const
|
|
52
|
-
invoking,
|
|
53
|
-
invokingFound: invoking ? list.find((a) => a.name === invoking).found : false,
|
|
54
|
-
bound: presetKindOf(bound),
|
|
55
|
-
boundValue: bound,
|
|
56
|
-
suggest: pick,
|
|
57
|
-
agents: list.map((a) => ({ name: a.name, label: a.label, found: a.found, command: a.command, problem: a.problem || undefined, invoking: a.invoking })),
|
|
58
|
-
};
|
|
118
|
+
const support = boundKind && boundKind !== 'custom' ? MODEL_SUPPORT[boundKind] : null;
|
|
59
119
|
if (json) {
|
|
60
|
-
stdout.write(`${JSON.stringify(
|
|
120
|
+
stdout.write(`${JSON.stringify({
|
|
121
|
+
invoking,
|
|
122
|
+
invokingFound: invoking ? list.find((a) => a.name === invoking).found : false,
|
|
123
|
+
bound: boundKind,
|
|
124
|
+
boundValue: bound.agent,
|
|
125
|
+
model: bound.model,
|
|
126
|
+
effort: bound.effort,
|
|
127
|
+
modelSupported: support ? support.model : null,
|
|
128
|
+
effortSupported: support ? support.effort : null,
|
|
129
|
+
suggest: pick,
|
|
130
|
+
agents: list.map((a) => ({ name: a.name, label: a.label, found: a.found, command: a.command, problem: a.problem || undefined, invoking: a.invoking, modelSupported: MODEL_SUPPORT[a.name].model, effortSupported: MODEL_SUPPORT[a.name].effort })),
|
|
131
|
+
}, null, 1)}\n`);
|
|
61
132
|
return EXIT.OK;
|
|
62
133
|
}
|
|
63
134
|
stdout.write('本机的 agent:\n');
|
|
64
135
|
for (const a of list) {
|
|
65
136
|
const how = a.found ? a.command : `没装:${a.problem}`;
|
|
66
|
-
stdout.write(` ${a.name.padEnd(7)}${a.found ? '装了' : '没装'} ${a.label}${a.invoking ? ' ← 现在是它在调这个 skill' : ''}\n ${how}\n`);
|
|
137
|
+
stdout.write(` ${a.name.padEnd(7)}${a.found ? '装了' : '没装'} ${a.label}${a.invoking ? ' ← 现在是它在调这个 skill' : ''}\n ${how}\n 模型和思考强度:${MODEL_SUPPORT[a.name].model ? `能配,work-rhythm agent models ${a.name} 看能用哪些` : '不能配,用它自己的默认'}\n`);
|
|
67
138
|
}
|
|
68
139
|
stdout.write(`正在调这个 skill 的:${invoking || '认不出来(不是从 agent 的工具里跑的,或者它不留标记)'}\n`);
|
|
69
|
-
stdout.write(`现在绑定的:${bound || '没绑'}${
|
|
70
|
-
if (
|
|
140
|
+
stdout.write(`现在绑定的:${bound.agent || '没绑'}${boundKind === 'custom' ? '(一条自定义命令)' : ''}\n`);
|
|
141
|
+
if (bound.agent) {
|
|
142
|
+
const described = describeModel(boundKind, bound.model, bound.effort);
|
|
143
|
+
if (described) stdout.write(` ${described}\n`);
|
|
144
|
+
}
|
|
145
|
+
if (!bound.agent) stdout.write(`没绑 agent 就没有定时任务,也不支持机器人响应。${pick ? `建议:work-rhythm agent bind ${pick}` : '本机一个预置的 agent 都没装,先装一个(docs/agents.md)'}\n`);
|
|
71
146
|
return EXIT.OK;
|
|
72
147
|
}
|
|
73
|
-
case '
|
|
148
|
+
case 'models': {
|
|
74
149
|
if (params.length > 1) throw new UsageError(USAGE);
|
|
75
|
-
const
|
|
150
|
+
const kind = params[0] || boundKind;
|
|
151
|
+
if (!kind) throw new Fail(EXIT.NOT_CONFIGURED, '还没绑 agent:work-rhythm agent models <名字>,或先 work-rhythm agent bind');
|
|
152
|
+
if (kind === 'custom') throw new Fail(EXIT.NOT_CONFIGURED, '自定义命令的模型写在你自己的命令里,这里列不出来');
|
|
153
|
+
if (!MODEL_SUPPORT[kind].model) throw new Fail(EXIT.NOT_CONFIGURED, `${kind} 不支持指定模型(ZCode 的命令行没有这个参数):用它自己的默认,或者换 dsh / qoder / claude`);
|
|
154
|
+
showModels(kind, env, stdout);
|
|
155
|
+
return EXIT.OK;
|
|
156
|
+
}
|
|
157
|
+
case 'bind': {
|
|
158
|
+
const { name: given, opts } = parseBind(params);
|
|
159
|
+
const name = given || suggest(list);
|
|
76
160
|
if (!name) throw new Fail(EXIT.NOT_CONFIGURED, '本机没找到能用的 agent,也没指定要绑的命令:装一个预置的(docs/agents.md),或者 work-rhythm agent bind "<一条命令>"');
|
|
77
|
-
const r = bindAgent(root, env, name);
|
|
161
|
+
const r = bindAgent(root, env, name, { model: opts.model, effort: opts.effort });
|
|
78
162
|
if (r.problems) throw new Fail(EXIT.NOT_CONFIGURED, `绑不了 ${name}:${r.problems.join(';')}`);
|
|
79
|
-
|
|
80
|
-
|
|
163
|
+
const kind = kindOf(name);
|
|
164
|
+
const support = kind !== 'custom' ? MODEL_SUPPORT[kind] : null;
|
|
165
|
+
const after = binding(root, env);
|
|
166
|
+
stdout.write(`已绑定 ${name}${kind === 'custom' ? '(一条自定义命令)' : `(${PRESETS[kind].label})`},写进了 ${path.relative(root, r.file)} 的 YZJ_BOT_AGENT。\n`);
|
|
167
|
+
stdout.write(` ${describeModel(kind, after.model, after.effort)}\n`);
|
|
168
|
+
if (support && !after.model && !after.effort) {
|
|
169
|
+
stdout.write(` 模型和思考强度还没配:work-rhythm agent models ${name} 看能用哪些,work-rhythm agent model <模型> / agent effort <强度> 配上;不配就用它自己的默认。\n`);
|
|
170
|
+
}
|
|
171
|
+
stdout.write('下一步:work-rhythm agent test 让它答一句(会自报模型);定时任务用 work-rhythm rhythm doctor 查配置,机器人值守用 work-rhythm listen doctor。\n');
|
|
172
|
+
return EXIT.OK;
|
|
173
|
+
}
|
|
174
|
+
case 'model':
|
|
175
|
+
case 'effort': {
|
|
176
|
+
const isModel = verb === 'model';
|
|
177
|
+
let value;
|
|
178
|
+
if (params.length === 1 && params[0] === '--clear') value = '';
|
|
179
|
+
else if (params.length === 1 && !params[0].startsWith('--')) value = params[0];
|
|
180
|
+
else throw new UsageError(USAGE);
|
|
181
|
+
if (!isModel && value && !EFFORTS.includes(value)) throw new UsageError(`思考强度写的是「${value}」,只能是 ${EFFORTS.join(' / ')}`);
|
|
182
|
+
if (!bound.agent) throw new Fail(EXIT.NOT_CONFIGURED, '还没绑 agent:work-rhythm agent bind <名字>');
|
|
183
|
+
const support = boundKind !== 'custom' ? MODEL_SUPPORT[boundKind] : null;
|
|
184
|
+
const what = isModel ? '模型' : '思考强度';
|
|
185
|
+
if (value && support && !support[isModel ? 'model' : 'effort']) {
|
|
186
|
+
throw new Fail(EXIT.NOT_CONFIGURED, `${boundKind} 不支持指定${what}(${boundKind === 'zcode' ? 'ZCode 的命令行没有这个参数' : '见 docs/agents.md'}):换一个支持的 agent,或者不配、用它自己的默认`);
|
|
187
|
+
}
|
|
188
|
+
const r = bindAgent(root, env, bound.agent, isModel ? { model: value } : { effort: value });
|
|
189
|
+
if (r.problems) throw new Fail(EXIT.NOT_CONFIGURED, `写不了:${r.problems.join(';')}`);
|
|
190
|
+
const after = binding(root, env);
|
|
191
|
+
stdout.write(value ? `${what}已设为 ${value},写进了 ${path.relative(root, r.file)}。\n` : `${what}已清掉,用 ${boundKind} 自己的默认。\n`);
|
|
192
|
+
stdout.write(` ${describeModel(boundKind, after.model, after.effort)}\n下一步:work-rhythm agent test 让它答一句,看自报的模型对不对。\n`);
|
|
81
193
|
return EXIT.OK;
|
|
82
194
|
}
|
|
83
195
|
case 'test': {
|
|
84
196
|
if (params.length > 1) throw new UsageError(USAGE);
|
|
85
|
-
if (!bound) throw new Fail(EXIT.NOT_CONFIGURED, '还没绑 agent:work-rhythm agent detect 看本机有哪些,work-rhythm agent bind <名字> 绑定');
|
|
197
|
+
if (!bound.agent) throw new Fail(EXIT.NOT_CONFIGURED, '还没绑 agent:work-rhythm agent detect 看本机有哪些,work-rhythm agent bind <名字> 绑定');
|
|
86
198
|
const started = Date.now();
|
|
87
199
|
// 只读模式跑一句;会话落在 01-inbox/_agent/ 下,不碰值守和定时任务各自的专属会话
|
|
88
|
-
const agent = createAgent({ root, agent: bound, mode: 'plan', timeoutS: 180, env: settings(root, env), log: (event, fields) => stderr.write(`${event} ${fields}\n`) });
|
|
89
|
-
const r = agent.run(params[0] || '
|
|
200
|
+
const agent = createAgent({ root, agent: bound.agent, mode: 'plan', timeoutS: 180, env: settings(root, env), model: bound.model, effort: bound.effort, log: (event, fields) => stderr.write(`${event} ${fields}\n`) });
|
|
201
|
+
const r = agent.run(params[0] || '你好。请只用两句话回答:1)你是哪个模型?说模型名。2)1+1 等于几?', { stateDir: path.join(root, '01-inbox', '_agent') });
|
|
90
202
|
if (r.config) throw new Fail(EXIT.NOT_CONFIGURED, r.failed);
|
|
91
203
|
if (r.failed) throw new Fail(EXIT.FAILED, `没答上来:${r.failed}`);
|
|
92
|
-
stdout.write(`${r.reply.trim()}\n(${bound}
|
|
204
|
+
stdout.write(`${r.reply.trim()}\n(${bound.agent}${bound.model ? `,配置的模型 ${bound.model}` : ''}${bound.effort ? `,思考强度 ${bound.effort}` : ''};只读模式,用时 ${Math.round((Date.now() - started) / 1000)} 秒)\n`);
|
|
93
205
|
return EXIT.OK;
|
|
94
206
|
}
|
|
95
207
|
case 'doctor': {
|
|
96
208
|
if (params.length) throw new UsageError(USAGE);
|
|
97
|
-
const problems = createAgent({ root, agent: bound, env: settings(root, env) }).doctor();
|
|
209
|
+
const problems = createAgent({ root, agent: bound.agent, env: settings(root, env), model: bound.model, effort: bound.effort }).doctor();
|
|
98
210
|
if (problems.length) stdout.write(`${problems.join('\n')}\n`);
|
|
99
|
-
else stdout.write(`${bound}
|
|
211
|
+
else stdout.write(`${bound.agent} 没有问题${bound.model || bound.effort ? `(${describeModel(boundKind, bound.model, bound.effort)})` : ''}。\n`);
|
|
100
212
|
return problems.length ? 1 : EXIT.OK;
|
|
101
213
|
}
|
|
102
214
|
default:
|
|
@@ -104,7 +216,3 @@ module.exports = {
|
|
|
104
216
|
}
|
|
105
217
|
},
|
|
106
218
|
};
|
|
107
|
-
|
|
108
|
-
function presetKindOf(name) {
|
|
109
|
-
return PRESET_NAMES.includes(name) ? name : name ? 'custom' : '';
|
|
110
|
-
}
|
package/scripts/cmd/check.js
CHANGED
|
@@ -341,4 +341,12 @@ async function run(args, ctx) {
|
|
|
341
341
|
return bad ? 1 : EXIT.OK;
|
|
342
342
|
}
|
|
343
343
|
|
|
344
|
-
|
|
344
|
+
const USAGE = `work-rhythm check —— 改完配置或文档后跑一遍:脚本语法、文档内链、预算、配置自检、疑似密钥、笔记格式。只读,不改任何文件
|
|
345
|
+
|
|
346
|
+
用法:
|
|
347
|
+
work-rhythm check
|
|
348
|
+
在工作目录里是 6 项;站在这个包自己的仓库里是另一套 7 项(多了「模板」「仓库保持通用」,没有「配置自检」)。
|
|
349
|
+
每项的问题逐条打出来;疑似密钥只报位置、不打印内容。
|
|
350
|
+
退出码: 0 全部通过;1 有未通过的项;2 用法不对;3 不在工作目录里。`;
|
|
351
|
+
|
|
352
|
+
module.exports = { usage: USAGE, run, __test: { genericProblems, checkTemplates } };
|
package/scripts/cmd/collect.js
CHANGED
|
@@ -8,8 +8,17 @@ const { EXIT, UsageError } = require('../lib/run');
|
|
|
8
8
|
const { loadSources } = require('../lib/config');
|
|
9
9
|
const { resolveCollector, spawnCollector } = require('./sync');
|
|
10
10
|
|
|
11
|
+
const USAGE = `work-rhythm collect <源id> <输出目录> [起始日期] [采集器自己的参数…] —— 只跑一个采集器(任务里「取今日日程」「取告警」这种只要一个源的数据时用)
|
|
12
|
+
|
|
13
|
+
用法:
|
|
14
|
+
work-rhythm collect calendar-yzj 01-inbox/calendar-yzj/2026-12-01 2026-12-01
|
|
15
|
+
输出目录写成 01-inbox/<源id>/<日期>:和 im-yzj 共用采集器的源(如 ops-yzj)靠它认出自己该读哪个变量。
|
|
16
|
+
sources.yaml 里有的源按它登记的采集器跑;没有的,把 <源id> 当成内置采集器的 id。
|
|
17
|
+
起始日期默认今天;采集器自己的参数原样传给它(比如 im-yzj 的页数)。
|
|
18
|
+
退出码就是采集器的:0 成功;2 参数错;3 未配置;4 缺依赖;5 远端失败或结果不完整(这时不留上一次的旧文件)。`;
|
|
19
|
+
|
|
11
20
|
module.exports = {
|
|
12
|
-
usage:
|
|
21
|
+
usage: USAGE,
|
|
13
22
|
async run(args, ctx) {
|
|
14
23
|
const { root, env, packageRoot } = ctx;
|
|
15
24
|
const [id, out] = args;
|