Skip to content

Commit d60e906

Browse files
committed
Add a command line option to specify the mode to run in
1 parent 0d09431 commit d60e906

File tree

3 files changed

+40
-25
lines changed

3 files changed

+40
-25
lines changed

apps/cli/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ In non-interactive mode:
8080
| `-k, --api-key <key>` | API key for the LLM provider | From env var |
8181
| `-p, --provider <provider>` | API provider (anthropic, openai, openrouter, etc.) | `anthropic` |
8282
| `-m, --model <model>` | Model to use | Provider default |
83+
| `-M, --mode <mode>` | Mode to start in (code, architect, ask, debug, etc.) | Default mode |
8384

8485
## Environment Variables
8586

apps/cli/src/extension-host.ts

Lines changed: 36 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ export interface ExtensionHostOptions {
3030
apiKey?: string
3131
apiProvider?: string
3232
model?: string
33+
mode?: string
3334
}
3435

3536
interface ExtensionModule {
@@ -493,38 +494,48 @@ export class ExtensionHost extends EventEmitter {
493494
// In interactive mode (default), we'll prompt the user for each action
494495
if (this.options.nonInteractive) {
495496
this.log("Non-interactive mode: enabling auto-approval settings...")
497+
const settings: Record<string, unknown> = {
498+
autoApprovalEnabled: true,
499+
alwaysAllowReadOnly: true,
500+
alwaysAllowReadOnlyOutsideWorkspace: true,
501+
alwaysAllowWrite: true,
502+
alwaysAllowWriteOutsideWorkspace: true,
503+
alwaysAllowWriteProtected: false, // Keep protected files safe.
504+
alwaysAllowBrowser: true,
505+
alwaysAllowMcp: true,
506+
alwaysAllowModeSwitch: true,
507+
alwaysAllowSubtasks: true,
508+
alwaysAllowExecute: true,
509+
alwaysAllowFollowupQuestions: true,
510+
// Enable reasoning/thinking tokens for models that support it.
511+
enableReasoningEffort: true,
512+
reasoningEffort: "medium",
513+
// Allow all commands with wildcard (required for command auto-approval).
514+
allowedCommands: ["*"],
515+
}
516+
// Include mode if specified
517+
if (this.options.mode) {
518+
settings.mode = this.options.mode
519+
}
496520
this.sendToExtension({
497521
type: "updateSettings",
498-
updatedSettings: {
499-
autoApprovalEnabled: true,
500-
alwaysAllowReadOnly: true,
501-
alwaysAllowReadOnlyOutsideWorkspace: true,
502-
alwaysAllowWrite: true,
503-
alwaysAllowWriteOutsideWorkspace: true,
504-
alwaysAllowWriteProtected: false, // Keep protected files safe.
505-
alwaysAllowBrowser: true,
506-
alwaysAllowMcp: true,
507-
alwaysAllowModeSwitch: true,
508-
alwaysAllowSubtasks: true,
509-
alwaysAllowExecute: true,
510-
alwaysAllowFollowupQuestions: true,
511-
// Enable reasoning/thinking tokens for models that support it.
512-
enableReasoningEffort: true,
513-
reasoningEffort: "medium",
514-
// Allow all commands with wildcard (required for command auto-approval).
515-
allowedCommands: ["*"],
516-
},
522+
updatedSettings: settings,
517523
})
518524
} else {
519525
this.log("Interactive mode: user will be prompted for approvals...")
526+
const settings: Record<string, unknown> = {
527+
autoApprovalEnabled: false,
528+
// Enable reasoning/thinking tokens for models that support it
529+
enableReasoningEffort: true,
530+
reasoningEffort: "medium",
531+
}
532+
// Include mode if specified
533+
if (this.options.mode) {
534+
settings.mode = this.options.mode
535+
}
520536
this.sendToExtension({
521537
type: "updateSettings",
522-
updatedSettings: {
523-
autoApprovalEnabled: false,
524-
// Enable reasoning/thinking tokens for models that support it
525-
enableReasoningEffort: true,
526-
reasoningEffort: "medium",
527-
},
538+
updatedSettings: settings,
528539
})
529540
}
530541

apps/cli/src/index.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ program
3030
.option("-k, --api-key <key>", "API key for the LLM provider (defaults to ANTHROPIC_API_KEY env var)")
3131
.option("-p, --provider <provider>", "API provider (anthropic, openai, openrouter, etc.)", "anthropic")
3232
.option("-m, --model <model>", "Model to use")
33+
.option("-M, --mode <mode>", "Mode to start in (code, architect, ask, debug, etc.)")
3334
.action(
3435
async (
3536
prompt: string,
@@ -43,6 +44,7 @@ program
4344
apiKey?: string
4445
provider: string
4546
model?: string
47+
mode?: string
4648
},
4749
) => {
4850
// Set up quiet mode - suppress VSCode shim logs
@@ -92,6 +94,7 @@ program
9294
apiKey,
9395
apiProvider: options.provider,
9496
model: options.model,
97+
mode: options.mode,
9598
})
9699

97100
// Handle SIGINT (Ctrl+C)

0 commit comments

Comments
 (0)