Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -923,7 +923,7 @@ export async function dispatch(args: string[]): Promise<void> {
}
}

const stream = config.agent.stream;
const stream = args.includes('--id') ? config.agent.stream : false;
const agent = getAgentCommand({ agentName, stream });

const cmd = new Deno.Command(agent.cmd, {
Expand Down Expand Up @@ -990,9 +990,9 @@ export async function dispatch(args: string[]): Promise<void> {
Deno.exit(status.code);
}
} else {
const result = await child.output();
if (!result.success) {
Deno.exit(result.code);
const status = await child.status;
if (!status.success) {
Deno.exit(status.code);
}
}
}
Expand Down
35 changes: 35 additions & 0 deletions cli_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,41 @@ describe('dispatch', () => {
assertSpyCalls(exitStub, 0);
});

it('uses inherited stdout when dispatching without --id', async () => {
using _ = stubFiles({
'config.json': {
channels: { telegram: { token: 'mock-token' } },
allowedUsers: [],
agent: { name: 'claude', stream: true },
},
});

using cmdStub = stub(
Deno,
'Command',
() => fakeCommand(),
);
using exitStub = stubDenoExit();

await dispatch(['whats', 'up']);

assertSpyCall(cmdStub, 0, {
args: ['claude', {
args: [
'--add-dir',
DATA_DIR,
'-p',
],
cwd: Deno.cwd(),
stdin: 'piped',
stdout: 'inherit',
stderr: 'inherit',
}],
});

assertSpyCalls(exitStub, 0);
});

it('reads prompt from file with --id', async () => {
using _ = stubFiles({
'config.json': {
Expand Down
Loading