Skip to content
Open
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
73 changes: 73 additions & 0 deletions src/main/core/conversations/impl/agent-command.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { describe, expect, it } from 'vitest';
import type { AgentProviderId } from '@shared/agent-provider-registry';
import type { ProviderCustomConfig } from '@shared/app-settings';
import { providerConfigDefaults } from '@main/core/settings/schema';
import { buildAgentCommand } from './agent-command';
Expand Down Expand Up @@ -82,6 +83,78 @@ describe('buildAgentCommand', () => {
expect(result.args).toEqual(['--session', 'id', 'conv-1']);
});

it('puts default args before resume flags for CLIs with subcommands', () => {
const result = buildAgentCommand({
providerId: 'goose',
providerConfig: providerConfigDefaults.goose,
sessionId: 'conv-1',
isResuming: true,
});

expect(result.args).toEqual(['run', '-s', '--resume']);
});

it('does not pass Droid session id on fresh sessions', () => {
const result = buildAgentCommand({
providerId: 'droid',
providerConfig: providerConfigDefaults.droid,
initialPrompt: 'Fix the bug',
sessionId: 'conv-1',
});

expect(result.args).toEqual(['Fix the bug']);
});

it('passes Droid session id when resuming', () => {
const result = buildAgentCommand({
providerId: 'droid',
providerConfig: providerConfigDefaults.droid,
sessionId: 'conv-1',
isResuming: true,
});

expect(result.args).toEqual(['--session-id', 'conv-1']);
});
Comment on lines +86 to +117
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 No test coverage for six newly added resumeFlag providers

The PR adds resumeFlag to cursor-agent, opencode, copilot, augment, goose, and kimi, and changes vibe's initialPromptFlag to ''. Only goose and droid receive new tests. Without tests for the others, a typo in a flag value (e.g. --contunue) or an incorrect arg ordering would go unnoticed until runtime. Adding one test per affected provider for both the fresh-session and the resume path would provide the same confidence here as the droid and goose tests do.

Prompt To Fix With AI
This is a comment left during a code review.
Path: src/main/core/conversations/impl/agent-command.test.ts
Line: 85-116

Comment:
**No test coverage for six newly added `resumeFlag` providers**

The PR adds `resumeFlag` to cursor-agent, opencode, copilot, augment, goose, and kimi, and changes `vibe`'s `initialPromptFlag` to `''`. Only goose and droid receive new tests. Without tests for the others, a typo in a flag value (e.g. `--contunue`) or an incorrect arg ordering would go unnoticed until runtime. Adding one test per affected provider for both the fresh-session and the resume path would provide the same confidence here as the droid and goose tests do.

How can I resolve this? If you propose a fix, please make it concise.


it.each<{
providerId: AgentProviderId;
freshArgs: string[];
resumeArgs: string[];
}>([
{ providerId: 'cursor', freshArgs: ['Fix the bug'], resumeArgs: ['--resume'] },
{ providerId: 'opencode', freshArgs: [], resumeArgs: ['--continue'] },
{ providerId: 'copilot', freshArgs: ['Fix the bug'], resumeArgs: ['--resume'] },
{
providerId: 'auggie',
freshArgs: ['--allow-indexing', 'Fix the bug'],
resumeArgs: ['--allow-indexing', '--continue'],
},
{
providerId: 'goose',
freshArgs: ['run', '-s', '-t', 'Fix the bug'],
resumeArgs: ['run', '-s', '--resume'],
},
{ providerId: 'kimi', freshArgs: ['-c', 'Fix the bug'], resumeArgs: ['--continue'] },
{ providerId: 'mistral', freshArgs: ['Fix the bug'], resumeArgs: [] },
])('builds fresh and resume args for $providerId', ({ providerId, freshArgs, resumeArgs }) => {
const fresh = buildAgentCommand({
providerId,
providerConfig: providerConfigDefaults[providerId],
initialPrompt: 'Fix the bug',
sessionId: 'conv-1',
});

const resume = buildAgentCommand({
providerId,
providerConfig: providerConfigDefaults[providerId],
sessionId: 'conv-1',
isResuming: true,
});

expect(fresh.args).toEqual(freshArgs);
expect(resume.args).toEqual(resumeArgs);
});

it('appends extra args', () => {
const result = buildAgentCommand({
providerId: 'claude',
Expand Down
8 changes: 6 additions & 2 deletions src/main/core/conversations/impl/agent-command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,12 +109,17 @@ export function buildAgentCommand({
const providerDef = getProvider(providerId);
const [command, ...args] = parseCliPrefix(providerConfig?.cli, providerId);

args.push(...(providerConfig?.defaultArgs ?? []));

const shouldPassSessionId =
providerConfig?.sessionIdFlag && (!providerConfig.sessionIdOnResumeOnly || isResuming);

if (isResuming && providerConfig?.resumeFlag) {
args.push(...parseArgField(providerConfig.resumeFlag));
if (providerConfig.sessionIdFlag) {
args.push(sessionId);
}
} else if (providerConfig?.sessionIdFlag) {
} else if (shouldPassSessionId) {
args.push(...parseArgField(providerConfig.sessionIdFlag), sessionId);
}

Expand All @@ -126,7 +131,6 @@ export function buildAgentCommand({
args.push(...parseArgField(providerConfig?.initialPromptFlag), initialPrompt);
}

args.push(...(providerConfig?.defaultArgs ?? []));
args.push(...parseArgField(providerConfig?.extraArgs));

return { command, args };
Expand Down
2 changes: 2 additions & 0 deletions src/main/core/settings/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ export const providerCustomConfigEntrySchema = z.object({
autoApproveFlag: z.string().optional(),
initialPromptFlag: z.string().optional(),
sessionIdFlag: z.string().optional(),
sessionIdOnResumeOnly: z.boolean().optional(),
extraArgs: z.string().optional(),
env: z.record(z.string(), z.string()).optional(),
});
Expand All @@ -94,6 +95,7 @@ export const providerConfigDefaults = Object.fromEntries(
...(p.initialPromptFlag !== undefined ? { initialPromptFlag: p.initialPromptFlag } : {}),
...(p.defaultArgs ? { defaultArgs: p.defaultArgs } : {}),
...(p.sessionIdFlag ? { sessionIdFlag: p.sessionIdFlag } : {}),
...(p.sessionIdOnResumeOnly ? { sessionIdOnResumeOnly: p.sessionIdOnResumeOnly } : {}),
},
])
);
Expand Down
12 changes: 10 additions & 2 deletions src/shared/agent-provider-registry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ export type AgentProviderDefinition = {
* e.g. '--session-id' for Claude Code.
*/
sessionIdFlag?: string;
sessionIdOnResumeOnly?: boolean;
defaultArgs?: string[];
planActivateCommand?: string;
autoStartCommand?: string;
Expand Down Expand Up @@ -137,6 +138,7 @@ export const AGENT_PROVIDERS: AgentProviderDefinition[] = [
cli: 'cursor-agent',
autoApproveFlag: '-f',
initialPromptFlag: '',
resumeFlag: '--resume',
icon: 'cursor.svg',
alt: 'Cursor CLI',
terminalOnly: true,
Expand Down Expand Up @@ -185,7 +187,8 @@ export const AGENT_PROVIDERS: AgentProviderDefinition[] = [
versionArgs: ['--version'],
cli: 'droid',
initialPromptFlag: '',
resumeFlag: '-r',
sessionIdFlag: '--session-id',
sessionIdOnResumeOnly: true,
icon: 'droid.svg',
alt: 'Factory Droid',
terminalOnly: true,
Expand Down Expand Up @@ -219,6 +222,7 @@ export const AGENT_PROVIDERS: AgentProviderDefinition[] = [
cli: 'opencode',
initialPromptFlag: '',
useKeystrokeInjection: true,
resumeFlag: '--continue',
icon: 'opencode.png',
alt: 'OpenCode CLI',
invertInDark: true,
Expand Down Expand Up @@ -254,6 +258,7 @@ export const AGENT_PROVIDERS: AgentProviderDefinition[] = [
versionArgs: ['--version'],
cli: 'copilot',
autoApproveFlag: '--allow-all-tools',
resumeFlag: '--resume',
icon: 'gh-copilot.svg',
alt: 'GitHub Copilot CLI',
terminalOnly: true,
Expand Down Expand Up @@ -284,6 +289,7 @@ export const AGENT_PROVIDERS: AgentProviderDefinition[] = [
versionArgs: ['--version'],
cli: 'auggie',
initialPromptFlag: '',
resumeFlag: '--continue',
// otherwise user is prompted each time before prompt is passed
defaultArgs: ['--allow-indexing'],
icon: 'Auggie.svg',
Expand All @@ -303,6 +309,7 @@ export const AGENT_PROVIDERS: AgentProviderDefinition[] = [
// run subcommand with -s for interactive mode after initial prompt
defaultArgs: ['run', '-s'],
initialPromptFlag: '-t',
resumeFlag: '--resume',
icon: 'goose.png',
alt: 'Goose CLI',
terminalOnly: true,
Expand All @@ -319,6 +326,7 @@ export const AGENT_PROVIDERS: AgentProviderDefinition[] = [
cli: 'kimi',
autoApproveFlag: '--yolo',
initialPromptFlag: '-c',
resumeFlag: '--continue',
icon: 'kimi.png',
alt: 'Kimi CLI',
terminalOnly: true,
Expand Down Expand Up @@ -429,7 +437,7 @@ export const AGENT_PROVIDERS: AgentProviderDefinition[] = [
versionArgs: ['-h'],
cli: 'vibe',
autoApproveFlag: '--auto-approve',
initialPromptFlag: '--prompt',
initialPromptFlag: '',
icon: 'mistral.png',
alt: 'Mistral Vibe CLI',
terminalOnly: true,
Expand Down
Loading