work-rhythm 0.2.21 → 0.2.22

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.
Files changed (68) hide show
  1. package/.agents/notes/AGENTS.md +10 -3
  2. package/.agents/notes/decisions/2026-11-30-bot-inbound-uses-websocket-and-a-responder-command.md +1 -0
  3. package/.agents/notes/decisions/2026-11-30-skill-ships-with-its-template-in-a-zip.md +1 -0
  4. package/.agents/notes/decisions/2026-12-01-agent-binding-asks-for-model-and-effort.md +1 -0
  5. package/.agents/notes/decisions/2026-12-01-interjections-batch-into-one-answer-and-interrupt-reruns.md +1 -0
  6. package/.agents/notes/decisions/2026-12-01-router-and-worker-pass-content-in-handoff-docs.md +1 -0
  7. package/.agents/notes/decisions/2026-12-01-router-runs-on-a-flash-model-with-low-effort.md +1 -0
  8. package/.agents/notes/decisions/2026-12-03-codex-cli-joins-as-a-preset-verified-against-its-own-binary.md +45 -0
  9. package/.agents/notes/decisions/2026-12-03-fewer-scheduled-tasks-silent-refine-no-question-cards.md +1 -0
  10. package/.agents/notes/decisions/2026-12-03-playbook-distills-handoffs-into-ws-tool-and-skill-know-how.md +43 -0
  11. package/.agents/notes/decisions/2026-12-03-related-work-comes-back-as-one-reply.md +49 -0
  12. package/.agents/notes/decisions/2026-12-03-roster-of-worker-groups-router-picks-the-group.md +33 -0
  13. package/.agents/notes/decisions/2026-12-03-router-model-and-effort-are-configurable.md +28 -0
  14. package/.agents/notes/decisions/2026-12-03-router-only-direct-mode-removed.md +27 -0
  15. package/.agents/notes/decisions/2026-12-03-unattended-runs-decide-on-their-own.md +32 -0
  16. package/.agents/notes/decisions/2026-12-03-update-upgrades-package-and-refreshes-shipped-files.md +30 -0
  17. package/.agents/notes/decisions/2026-12-03-workers-leave-a-status-trail-that-joins-the-receipt.md +31 -0
  18. package/.agents/notes/pitfalls/2026-12-01-replace-string-dollar-quote-expands.md +2 -0
  19. package/.agents/notes/pitfalls/2026-12-03-judging-a-symlink-by-realpath-ignores-parent-links.md +18 -0
  20. package/.agents/skills/work-rhythm/SKILL.md +20 -16
  21. package/README.md +13 -10
  22. package/collectors/local.env.example +31 -36
  23. package/docs/agents.md +61 -60
  24. package/docs/channels.md +15 -19
  25. package/docs/formats.md +27 -0
  26. package/docs/router-worker.md +60 -41
  27. package/docs/scheduled-tasks.md +9 -9
  28. package/package.json +1 -1
  29. package/scripts/cli.js +9 -5
  30. package/scripts/cmd/agent.js +348 -235
  31. package/scripts/cmd/check.js +14 -7
  32. package/scripts/cmd/listen.js +33 -32
  33. package/scripts/cmd/pack.js +6 -6
  34. package/scripts/cmd/rhythm.js +13 -10
  35. package/scripts/cmd/trigger.js +23 -14
  36. package/scripts/cmd/update.js +92 -0
  37. package/scripts/lib/agent.js +235 -142
  38. package/scripts/lib/agents.js +179 -0
  39. package/scripts/lib/bot.js +44 -263
  40. package/scripts/lib/engine.js +327 -110
  41. package/scripts/lib/handoff.js +54 -8
  42. package/scripts/lib/markdown.js +19 -0
  43. package/scripts/lib/playbook.js +123 -0
  44. package/scripts/lib/rhythm.js +405 -170
  45. package/scripts/lib/router.js +45 -29
  46. package/scripts/lib/template.js +3 -3
  47. package/scripts/lib/update.js +279 -0
  48. package/scripts/lib/worker.js +11 -5
  49. package/scripts/test/agent.test.js +410 -257
  50. package/scripts/test/check.test.js +17 -6
  51. package/scripts/test/harness.js +5 -2
  52. package/scripts/test/listen.test.js +190 -158
  53. package/scripts/test/playbook.test.js +106 -0
  54. package/scripts/test/rhythm.test.js +164 -54
  55. package/scripts/test/roster.test.js +155 -0
  56. package/scripts/test/router-helper.js +17 -2
  57. package/scripts/test/router.test.js +468 -194
  58. package/scripts/test/stubs.js +51 -4
  59. package/scripts/test/timeout.test.js +160 -59
  60. package/scripts/test/update.test.js +384 -0
  61. package/tasks/daily-persona.md +30 -11
  62. package/tasks/daily-plan.md +2 -1
  63. package/tasks/noon-checkin.md +2 -1
  64. package/templates/00-config/profile.example.yaml +9 -6
  65. package/templates/04-patterns/PERSONA.md +4 -1
  66. package/templates/04-patterns/PLAYBOOK.md +13 -0
  67. package/templates/AGENTS.md +6 -2
  68. package/templates/README.md +10 -9
@@ -182,27 +182,38 @@ test('check:没装 security 时报出来', (t) => {
182
182
  assert.match(r.stdout, /消息渠道 yzj-robot 需要 security,本机没有/);
183
183
  });
184
184
 
185
- test('check:只绑了 agent 跑定时任务、没装值守,不报值守的事;schedule 有任务没绑 agent 才报', (t) => {
185
+ test('check:只绑了 agent 跑定时任务、没装值守,不报值守的事;schedule 有任务却没绑好 agent 才报(local.env 的老写法和名册都认)', (t) => {
186
186
  const s = setup(t);
187
+ const roster = `${s.box.work}/00-config/agents.json`;
187
188
  s.localEnv('YZJ_BOT_AGENT="dsh"\n');
188
189
  const r = s.check({ ...s.stubs });
189
190
  assert.equal(r.code, 0, r.out);
190
191
  assert.ok(!r.out.includes('值守'), r.out);
191
- // 引导做完(status: done)、把绑定的那行去掉:schedule 里有任务(模板的默认时间)却没绑 agent,就报;引导没走到第 6 步时不报
192
+ // 名册:路由和执行者分开绑,local.env 里不用再写。引导做完(status: done)之后才查它配得对不对
193
+ s.localEnv('');
192
194
  write(`${s.box.work}/00-config/profile.yaml`, read(`${s.box.work}/00-config/profile.yaml`).replace('status: new', 'status: done'));
193
- s.localEnv('# YZJ_BOT_AGENT="dsh"\n');
195
+ write(roster, JSON.stringify({ router: { agent: 'dsh', model: '', effort: '' }, workers: [{ id: 'w1', agent: 'zcode', model: '', effort: '', count: 1 }] }));
196
+ const named = s.check({ ...s.stubs, ZCODE_CLI: '/nonexistent/zcode' });
197
+ assert.equal(named.code, 1, named.out);
198
+ assert.match(named.stdout, /执行者 w1(zcode):[^\n]*\/nonexistent\/zcode/);
199
+ assert.equal(s.check({ ...s.stubs }).code, 0, s.check({ ...s.stubs }).out);
200
+ // 名册里只有路由、没有执行者:一样是没绑好
201
+ write(roster, JSON.stringify({ router: { agent: 'dsh', model: '', effort: '' }, workers: [] }));
202
+ assert.match(s.check({ ...s.stubs }).stdout, /schedule 里有任务([^)]*)却没绑好 agent,到点一个也跑不了/);
203
+ // 引导做完(status: done)、名册和 local.env 都没绑:schedule 里有任务(模板的默认时间)就报
204
+ fs.rmSync(roster);
194
205
  const r2 = s.check({ ...s.stubs });
195
206
  assert.equal(r2.code, 1, r2.out);
196
- assert.match(r2.stdout, /schedule 里有任务(daily-plan、evening-review、daily-persona)却没绑 agent,到点一个也跑不了:work-rhythm agent bind <zcode\|dsh\|qoder\|claude\|kimi>/);
207
+ assert.match(r2.stdout, /schedule 里有任务(daily-plan、evening-review、daily-persona)却没绑好 agent,到点一个也跑不了:work-rhythm agent bind <qoder\|dsh\|zcode\|claude\|codex\|kimi>(路由和执行者都绑上)/);
197
208
  });
198
209
 
199
- test('check:值守装了之后,配的命令找不到时报出来', (t) => {
210
+ test('check:值守装了之后,配的命令找不到时报出来(路由和执行者各报一条)', (t) => {
200
211
  const s = setup(t);
201
212
  s.setNotify('yzj-robot');
202
213
  s.localEnv('YZJ_BOT_AGENT="/nonexistent/agent x"\nYZJ_MY_OPEN_ID="me-0001"\n');
203
214
  const r = s.check({ ...s.botInstalled(), STUB_KEYCHAIN: 'ok' });
204
215
  assert.equal(r.code, 1);
205
- assert.match(r.stdout, /YZJ_BOT_AGENT 的命令找不到: \/nonexistent\/agent/);
216
+ assert.match(r.stdout, /路由(\/nonexistent\/agent x):自定义命令找不到: \/nonexistent\/agent\n执行者 w1(\/nonexistent\/agent x):自定义命令找不到: \/nonexistent\/agent/);
206
217
  assert.ok(!r.stdout.includes('值守属于 yzj-robot 渠道'));
207
218
  });
208
219
 
@@ -16,8 +16,8 @@ const BIN = path.join(PACKAGE_ROOT, 'scripts', 'work-rhythm.js');
16
16
  const T = '\t';
17
17
 
18
18
  // 这些变量是各命令的配置,本机环境里如果碰巧有,会让用例的结果跟着变。跑命令时一律不带
19
- // CLAUDE、QODER 也抹掉:调用这个测试的 agent 会留自己的标记(ZCODE_*、CLAUDE_CODE_*、DSH_SESSION_ID),用例不能被它带偏
20
- const STRIP = /^(YZJ_|GIT_ACTIVITY_|FILE_ACTIVITY_|DSH_|STUB_|ZCODE_|WORK_RHYTHM_|DECISIONS_TODAY|LINKY_TYPES|CLAUDE|QODER|KIMI_)/;
19
+ // CLAUDE、QODER 也抹掉:调用这个测试的 agent 会留自己的标记(ZCODE_*、CLAUDE_CODE_*、DSH_SESSION_ID、CODEX_*),用例不能被它带偏
20
+ const STRIP = /^(YZJ_|GIT_ACTIVITY_|FILE_ACTIVITY_|DSH_|STUB_|ZCODE_|WORK_RHYTHM_|DECISIONS_TODAY|LINKY_TYPES|CLAUDE|QODER|KIMI_|CODEX_)/;
21
21
  const { writeWorkdir } = require('../lib/template');
22
22
 
23
23
  // 用户级登记指向一个不存在的文件:用例不能被本机登记的工作目录带偏
@@ -164,10 +164,13 @@ function makeSandbox(t) {
164
164
  STUB_DSH_ENV: file('dsh.env'),
165
165
  STUB_KIMI_ARGS: file('kimi.args'),
166
166
  STUB_KIMI_ENV: file('kimi.env'),
167
+ STUB_CODEX_ARGS: file('codex.args'),
168
+ STUB_CODEX_ALL: file('codex.all'),
167
169
  STUB_ROUTER_CALLS: file('router.calls'),
168
170
  STUB_ROUTER_REPLY: file('router.reply'),
169
171
  STUB_HELPER: helper,
170
172
  KIMI_CLI: path.join(bin, 'fake-kimi'),
173
+ CODEX_CLI: path.join(bin, 'fake-codex'),
171
174
  STUB_APPROVAL_NEW_MS: String(Date.UTC(2026, 10, 27, 10, 0, 0)),
172
175
  STUB_APPROVAL_OLD_MS: String(Date.UTC(2026, 10, 16, 5, 30, 0)),
173
176
  DSH_HOME: path.join(root, 'dsh-home'),