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.
@@ -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 };