Skip to content

Commit 619d1d3

Browse files
committed
Use sequential numbered temporary directories for CLI isolation
- temporary directories created for interactive code editing with CLIs are using naming scheme: `cwc-cli-edit-[hash]`. becase using each requires permission from the user for interactive session, we'd like to replace hash with autoincremented number, with lowest not used by any concurrent invocation re-used for next interactive cli invocation. ├── apps │ └── editor │ └── src │ ├── commands │ │ ├── apply-from-terminal-command.ts │ │ ├── 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 │ │ │ ├── copilot.ts │ │ │ ├── cursor.ts │ │ │ ├── devin.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-apply-from.ts │ │ ├── handle-invoke-agentic-cli.ts │ │ ├── handle-patch-repair.ts │ │ └── handle-voice-input.ts │ └── prompt-view-provider.ts └── packages └── shared └── src └── types ├── prompt-types.ts └── terminal-interactivity.ts
1 parent a2787e1 commit 619d1d3

1 file changed

Lines changed: 15 additions & 4 deletions

File tree

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

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -372,10 +372,21 @@ export const invoke_agentic_cli = async (params: {
372372
>()
373373

374374
if (params.isolate_in_temp_dir) {
375-
const prefix = `cwc-cli-${params.cli_prompt_type || 'edit'}-`
376-
temp_dir_path = await fs.promises.mkdtemp(
377-
path.join(os.tmpdir(), prefix)
378-
)
375+
const base_prefix = `cwc-cli-${params.cli_prompt_type || 'edit'}`
376+
let i = 1
377+
while (true) {
378+
temp_dir_path = path.join(os.tmpdir(), `${base_prefix}-${i}`)
379+
try {
380+
await fs.promises.mkdir(temp_dir_path)
381+
break
382+
} catch (err: any) {
383+
if (err.code === 'EEXIST') {
384+
i++
385+
} else {
386+
throw err
387+
}
388+
}
389+
}
379390

380391
const files_array: string[] = []
381392

0 commit comments

Comments
 (0)