work-rhythm 0.1.6 → 0.1.8
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 +3 -0
- package/.agents/notes/decisions/2026-11-30-bot-inbound-uses-websocket-and-a-responder-command.md +1 -0
- package/.agents/notes/decisions/2026-11-30-scheduling-moves-to-a-local-service.md +1 -0
- package/.agents/notes/decisions/2026-12-01-binding-carries-the-current-session.md +29 -0
- package/.agents/notes/decisions/2026-12-01-bot-lives-in-the-service-process.md +28 -0
- package/.agents/notes/pitfalls/2026-12-01-launchd-install-bakes-invoking-node.md +28 -0
- package/.agents/skills/work-rhythm/SKILL.md +1 -1
- package/collectors/local.env.example +6 -1
- package/docs/agents.md +10 -1
- package/docs/channels.md +5 -2
- package/docs/scheduled-tasks.md +1 -1
- package/package.json +1 -1
- package/scripts/cmd/agent.js +66 -5
- package/scripts/cmd/listen.js +48 -14
- package/scripts/cmd/rhythm.js +15 -2
- package/scripts/lib/agent.js +33 -3
- package/scripts/lib/bot.js +61 -7
- package/scripts/lib/config.js +22 -1
- package/scripts/lib/launchd.js +56 -3
- package/scripts/lib/rhythm.js +40 -3
- package/scripts/test/agent.test.js +66 -1
- package/scripts/test/harness.js +1 -0
- package/scripts/test/listen.test.js +97 -0
- package/scripts/test/rhythm.test.js +77 -0
- package/scripts/test/stubs.js +11 -1
package/scripts/test/stubs.js
CHANGED
|
@@ -122,10 +122,18 @@ const fs = require('node:fs');
|
|
|
122
122
|
const { spawnSync } = require('node:child_process');
|
|
123
123
|
const args = process.argv.slice(2);
|
|
124
124
|
fs.writeFileSync(process.env.STUB_DSH_ENV || '/dev/null', 'run_as_node=' + (process.env.ELECTRON_RUN_AS_NODE || '') + ' dsh_home=' + (process.env.DSH_HOME || '') + '\\n');
|
|
125
|
+
fs.writeFileSync((process.env.STUB_DSH_ARGS || '/dev/null') + '.cwd', process.cwd() + '\\n');
|
|
125
126
|
const r = spawnSync(process.execPath, [args[2], ...args.slice(3)], { stdio: 'inherit' });
|
|
126
127
|
process.exit(r.status === null ? 1 : r.status);
|
|
127
128
|
`;
|
|
128
129
|
|
|
130
|
+
// 假的 launchctl:把每次调用记进 STUB_LAUNCHCTL(一行一次),不真的动 launchd。print 在 STUB_LAUNCHCTL_RUNNING=1 时退出码 0(在跑),否则 1
|
|
131
|
+
const launchctl = `
|
|
132
|
+
const fs = require('node:fs');
|
|
133
|
+
fs.appendFileSync(process.env.STUB_LAUNCHCTL || '/dev/null', process.argv.slice(2).join(' ') + '\\n');
|
|
134
|
+
process.exit(process.argv[2] === 'print' && process.env.STUB_LAUNCHCTL_RUNNING !== '1' ? 1 : 0);
|
|
135
|
+
`;
|
|
136
|
+
|
|
129
137
|
// 假的 mdfind(Spotlight):记下查询串,按 STUB_MDFIND 列出路径。STUB_MDFIND=empty 时什么都不返回(目录没被索引的那种)
|
|
130
138
|
const mdfind = `
|
|
131
139
|
const fs = require('node:fs');
|
|
@@ -151,8 +159,10 @@ const args = process.argv.slice(2);
|
|
|
151
159
|
const patch = args[args.indexOf('--patch') + 1];
|
|
152
160
|
fs.writeFileSync(process.env.STUB_DSH_ARGS || '/dev/null', args.join(' ') + '\\n');
|
|
153
161
|
fs.writeFileSync((process.env.STUB_DSH_ARGS || '/dev/null') + '.patch', (fs.readFileSync(patch, 'utf8').match(/^- id: |^ disabled:/gm) || []).join('\\n') + '\\n');
|
|
162
|
+
// STUB_DSH_REJECT_SESSION 指的会话 id 出现在参数里就退出 1(接不上那个会话)
|
|
163
|
+
if (process.env.STUB_DSH_REJECT_SESSION && args.includes(process.env.STUB_DSH_REJECT_SESSION)) process.exit(1);
|
|
154
164
|
process.stdout.write(JSON.stringify({ type: 'session', sessionId: 'session_fake', cwd: 'x' }) + '\\n');
|
|
155
165
|
process.stdout.write(JSON.stringify({ type: 'final', sessionId: 'session_fake', reason: { kind: process.env.STUB_DSH_FINAL || 'completed' }, text: '回复:' + args[args.length - 1] }) + '\\n');
|
|
156
166
|
`;
|
|
157
167
|
|
|
158
|
-
module.exports = { yzjCli, linky, security, fakeAgent, fakeZcode, fakeQoder, fakeClaude, fakeDshNode, fakeDsh, mdfind, mdls };
|
|
168
|
+
module.exports = { yzjCli, linky, security, launchctl, fakeAgent, fakeZcode, fakeQoder, fakeClaude, fakeDshNode, fakeDsh, mdfind, mdls };
|