@agentsignalnet/claude-plugin 0.2.97 → 0.2.98
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/.claude-plugin/plugin.json +1 -1
- package/package.json +1 -1
- package/scripts/responder.mjs +31 -2
package/package.json
CHANGED
package/scripts/responder.mjs
CHANGED
|
@@ -347,19 +347,48 @@ export function promptFor(message, mode) {
|
|
|
347
347
|
.join('\n');
|
|
348
348
|
}
|
|
349
349
|
|
|
350
|
+
/**
|
|
351
|
+
* THE PROMPT GOES ON STDIN, and the reason is a bug that made this script
|
|
352
|
+
* incapable of ever answering anything.
|
|
353
|
+
*
|
|
354
|
+
* It used to be the last element of argv, after `--allowed-tools`:
|
|
355
|
+
*
|
|
356
|
+
* '--allowed-tools', ...toolsFor(mode), promptFor(message, mode)
|
|
357
|
+
*
|
|
358
|
+
* `--allowed-tools` is VARIADIC. It ate the prompt as a fifth tool name, and
|
|
359
|
+
* claude exited 1 in under a second with "Input must be provided either
|
|
360
|
+
* through stdin or as a prompt argument when using --print". Every spawn since
|
|
361
|
+
* this file was written failed that way -- two of them on the author's own
|
|
362
|
+
* machine, visible in the ledger as `exit_code: 1` a second after the spawn.
|
|
363
|
+
* Nothing red, no reply sent, and a responder that looked like it was running.
|
|
364
|
+
*
|
|
365
|
+
* Joining the tools with commas does not fix it; the positional is still
|
|
366
|
+
* consumed. Putting the prompt BEFORE the flag does, and so does this.
|
|
367
|
+
*
|
|
368
|
+
* Stdin is chosen over reordering for two reasons. A flag added later cannot
|
|
369
|
+
* swallow it, which is exactly the failure being repaired. And the prompt
|
|
370
|
+
* carries the message's title and body -- on argv that is readable by anybody
|
|
371
|
+
* who can run `ps` on this machine, which is not a thing to do with somebody
|
|
372
|
+
* else's message.
|
|
373
|
+
*/
|
|
350
374
|
export function spawnResponder(message, config, cwd = process.cwd()) {
|
|
351
375
|
const args = [
|
|
352
376
|
'--print',
|
|
353
377
|
'--permission-mode', config.mode === 'act' ? 'acceptEdits' : 'dontAsk',
|
|
354
378
|
'--allowed-tools', ...toolsFor(config.mode),
|
|
355
|
-
promptFor(message, config.mode),
|
|
356
379
|
];
|
|
357
380
|
const child = spawn('claude', args, {
|
|
358
381
|
cwd,
|
|
359
382
|
env: { ...process.env, AGENTSIGNAL_FROM_RESPONDER: '1' },
|
|
360
|
-
stdio: ['
|
|
383
|
+
stdio: ['pipe', 'pipe', 'pipe'],
|
|
361
384
|
detached: false,
|
|
362
385
|
});
|
|
386
|
+
try {
|
|
387
|
+
child.stdin.end(promptFor(message, config.mode));
|
|
388
|
+
} catch {
|
|
389
|
+
// A child that died before stdin was writable is already an exit the
|
|
390
|
+
// caller will see; throwing here would lose that in a stack trace.
|
|
391
|
+
}
|
|
363
392
|
return child;
|
|
364
393
|
}
|
|
365
394
|
|