Skip to content

Commit b7643d0

Browse files
committed
Refactor agentic CLI invocation to use execution mode and refine temporary directory handling
- A clearer name for agent_args_type would have been something like execution_mode: 'headless' | 'interactive-terminal'. - when not copying selected files, the temp folder should have clearer name (without hash suffix), e.g. "cwc-cli" └── apps └── editor └── src ├── commands │ ├── code-at-cursor-command │ │ └── utils │ │ └── perform-code-at-cursor.ts │ └── generate-commit-message-commands │ └── actions │ └── run-generate-action.ts ├── features │ ├── agentic-search │ │ └── agentic-search.ts │ └── search-files │ └── search-modes │ └── perform-intelligent-search-mode.ts ├── utils │ └── agentic-cli-invocation │ ├── agents │ │ ├── antigravity.ts │ │ ├── claude.ts │ │ ├── codex.ts │ │ ├── cursor.ts │ │ ├── grok.ts │ │ ├── index.ts │ │ └── opencode.ts │ ├── index.ts │ ├── invoke-agentic-cli.ts │ ├── types.ts │ └── utils │ ├── check-command-exists.ts │ ├── format-duration.ts │ ├── generate-diff-markdown.ts │ └── get-progress-dots.ts └── views └── prompt └── backend └── message-handlers ├── handle-invoke-agentic-cli.ts ├── handle-patch-repair.ts └── handle-voice-input.ts
1 parent e6151e9 commit b7643d0

8 files changed

Lines changed: 21 additions & 16 deletions

File tree

‎apps/editor/src/commands/code-at-cursor-command/utils/perform-code-at-cursor.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -399,7 +399,7 @@ export const perform_code_at_cursor = async (params: {
399399
},
400400
show_back_button: true,
401401
isolate_in_temp_dir: true,
402-
agent_args_type: 'isolated-dir'
402+
execution_mode: 'headless'
403403
})
404404

405405
if (invoke_cli_result === 'back') {

‎apps/editor/src/commands/generate-commit-message-commands/actions/run-generate-action.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -491,7 +491,7 @@ export const run_generate_action = async (params: {
491491
},
492492
show_back_button: true,
493493
isolate_in_temp_dir: true,
494-
agent_args_type: 'isolated-dir'
494+
execution_mode: 'headless'
495495
})
496496

497497
if (invoke_cli_result === 'back') {

‎apps/editor/src/constants/instructions.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ export const voice_input_output_formatting =
7070

7171
export const cli_edit_ask_requirements = {
7272
preloaded_context:
73-
'All available files for the [task](#task) were shown in [files](#files). Reading any other files is FORBIDDEN.',
73+
'All necessary files for the [task](#task) were preloaded to [files](#files). Reading any other files is FORBIDDEN.',
7474
disable_tool_calling:
7575
'Calling tools, including shell commands (e.g. grep, glob, ls, git, etc.) is FORBIDDEN.',
7676
exception_read_images:

‎apps/editor/src/features/search-files/search-modes/perform-intelligent-search-mode.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -446,7 +446,7 @@ export const perform_intelligent_search_mode = async (params: {
446446
},
447447
show_back_button: true,
448448
isolate_in_temp_dir: true,
449-
agent_args_type: 'isolated-dir'
449+
execution_mode: 'headless'
450450
})
451451

452452
if (invoke_cli_result === 'back') {

‎apps/editor/src/utils/agentic-cli-invocation/invoke-agentic-cli.ts‎

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ export const invoke_agentic_cli = async (params: {
3434
copy_selected_files?: boolean
3535
run_in_terminal?: boolean
3636
generate_diff_for_temp_dir?: boolean
37-
agent_args_type?: 'isolated-dir' | 'integrated-terminal'
37+
execution_mode?: 'headless' | 'interactive-terminal'
3838
cli_configuration_name?: string
3939
use_quick_pick?: boolean
4040
}): Promise<
@@ -308,9 +308,14 @@ export const invoke_agentic_cli = async (params: {
308308
>()
309309

310310
if (params.isolate_in_temp_dir) {
311-
temp_dir_path = await fs.promises.mkdtemp(
312-
path.join(os.tmpdir(), 'cwc-cli-')
313-
)
311+
if (params.copy_selected_files) {
312+
temp_dir_path = await fs.promises.mkdtemp(
313+
path.join(os.tmpdir(), 'cwc-cli-')
314+
)
315+
} else {
316+
temp_dir_path = path.join(os.tmpdir(), 'cwc-cli')
317+
await fs.promises.mkdir(temp_dir_path, { recursive: true })
318+
}
314319

315320
if (params.copy_selected_files) {
316321
const selected_files = params.workspace_provider.get_selected_files()
@@ -476,7 +481,7 @@ export const invoke_agentic_cli = async (params: {
476481

477482
if (params.run_in_terminal) {
478483
const base_args =
479-
params.agent_args_type === 'integrated-terminal'
484+
params.execution_mode === 'interactive-terminal'
480485
? agent_info.get_integrated_terminal_args
481486
? agent_info.get_integrated_terminal_args({ cwd: selected_root })
482487
: []
@@ -514,7 +519,7 @@ export const invoke_agentic_cli = async (params: {
514519
terminal.sendText(command)
515520

516521
if (
517-
params.agent_args_type === 'integrated-terminal' &&
522+
params.execution_mode === 'interactive-terminal' &&
518523
agent_info.get_post_integrated_terminal_args
519524
) {
520525
const post_args = agent_info.get_post_integrated_terminal_args()
@@ -553,7 +558,7 @@ export const invoke_agentic_cli = async (params: {
553558
}
554559

555560
const base_args =
556-
params.agent_args_type === 'integrated-terminal'
561+
params.execution_mode === 'interactive-terminal'
557562
? agent_info.get_integrated_terminal_args
558563
? agent_info.get_integrated_terminal_args({
559564
cwd: selected_root

‎apps/editor/src/views/prompt/backend/message-handlers/handle-invoke-agentic-cli.ts‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,11 @@ export const handle_invoke_agentic_cli = async (
5252
last_selected_workspace_state_key:
5353
LAST_SELECTED_WORKSPACE_IN_AGENTIC_CLI_STATE_KEY,
5454
isolate_in_temp_dir: true,
55-
copy_selected_files: true,
55+
copy_selected_files: prompt_type == 'edit-files',
5656
run_in_terminal: prompt_type == 'ask-about-files',
5757
generate_diff_for_temp_dir: prompt_type == 'edit-files',
58-
agent_args_type:
59-
prompt_type == 'edit-files' ? 'isolated-dir' : 'integrated-terminal',
58+
execution_mode:
59+
prompt_type == 'edit-files' ? 'headless' : 'interactive-terminal',
6060
cli_configuration_name: message.cli_configuration_name,
6161
use_quick_pick: message.use_quick_pick,
6262
on_agent_selected: (name: string) => {

‎apps/editor/src/views/prompt/backend/message-handlers/handle-patch-repair.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ export const handle_patch_repair = async (params: {
294294
},
295295
show_back_button: true,
296296
isolate_in_temp_dir: true,
297-
agent_args_type: 'isolated-dir'
297+
execution_mode: 'headless'
298298
})
299299

300300
if (invoke_cli_result === 'back') {

‎apps/editor/src/views/prompt/backend/message-handlers/handle-voice-input.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ const stop_recording = async (prompt_view_provider: PromptViewProvider) => {
252252
},
253253
show_back_button: true,
254254
isolate_in_temp_dir: true,
255-
agent_args_type: 'isolated-dir'
255+
execution_mode: 'headless'
256256
})
257257

258258
if (invoke_cli_result === 'back') {

0 commit comments

Comments
 (0)