File tree Expand file tree Collapse file tree
utils/agentic-cli-invocation Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -28,7 +28,10 @@ export const show_agentic_cli_output_channel = () => {
2828export const invoke_agentic_cli = async ( params : {
2929 workspace_provider : WorkspaceProvider
3030 extension_context : vscode . ExtensionContext
31- build_prompt : ( selected_root : string ) => Promise < string | 'back' | undefined >
31+ build_prompt : (
32+ selected_root : string ,
33+ temp_dir_path ?: string
34+ ) => Promise < string | 'back' | undefined >
3235 notification_title : string
3336 last_selected_workspace_state_key : string
3437 agent_state_key ?: string
@@ -527,7 +530,10 @@ export const invoke_agentic_cli = async (params: {
527530 }
528531 }
529532
530- const final_prompt = await params . build_prompt ( selected_root ! )
533+ const final_prompt = await params . build_prompt (
534+ selected_root ! ,
535+ temp_dir_path
536+ )
531537
532538 if ( final_prompt === 'back' ) {
533539 if ( roots . length === 1 || params . isolate_in_temp_dir ) {
Original file line number Diff line number Diff line change @@ -9,6 +9,9 @@ async function get_all_files(dir: string): Promise<string[]> {
99 const dirents = await fs . promises . readdir ( dir , { withFileTypes : true } )
1010 const files = await Promise . all (
1111 dirents . map ( async ( dirent ) => {
12+ if ( dirent . isDirectory ( ) && dirent . name === '.cwc' ) {
13+ return [ ]
14+ }
1215 const res = path . resolve ( dir , dirent . name )
1316 return dirent . isDirectory ( ) ? get_all_files ( res ) : res
1417 } )
Original file line number Diff line number Diff line change @@ -59,10 +59,11 @@ export const handle_invoke_agentic_cli = async (
5959 name
6060 } )
6161 } ,
62- build_prompt : async ( selected_root : string ) => {
62+ build_prompt : async ( selected_root : string , temp_dir_path ?: string ) => {
6363 return build_cli_prompt ( {
6464 prompt_view_provider,
65- selected_root
65+ selected_root,
66+ temp_dir_path
6667 } )
6768 }
6869 } )
Original file line number Diff line number Diff line change @@ -9,6 +9,7 @@ import { PromptBuilder } from '@/utils/prompt-builder'
99export const build_cli_prompt = async ( params : {
1010 prompt_view_provider : PromptViewProvider
1111 selected_root ?: string
12+ temp_dir_path ?: string
1213} ) : Promise < string > => {
1314 const { prompt_view_provider } = params
1415 let { selected_root } = params
@@ -29,7 +30,8 @@ export const build_cli_prompt = async (params: {
2930 extension_context : prompt_view_provider . extension_context ,
3031 workspace_provider : prompt_view_provider . workspace_provider ,
3132 image_as_paths : true ,
32- symbols_cache : prompt_view_provider . symbols_cache
33+ symbols_cache : prompt_view_provider . symbols_cache ,
34+ copy_images_to_dir : params . temp_dir_path
3335 } )
3436
3537 const processed_query = processed_instructions_array [ 0 ]
Original file line number Diff line number Diff line change 11import * as fs from 'fs'
2+ import * as path from 'path'
23import * as vscode from 'vscode'
34import { PersistentPromptStorage } from '../../persistent-prompt-storage'
45
@@ -7,6 +8,7 @@ export const replace_image_symbol = async (params: {
78 extension_context : vscode . ExtensionContext
89 remove ?: boolean
910 as_paths ?: boolean
11+ copy_images_to_dir ?: string
1012} ) : Promise < string [ ] > => {
1113 const storage = new PersistentPromptStorage ( params . extension_context , 'image' )
1214
@@ -34,8 +36,22 @@ export const replace_image_symbol = async (params: {
3436 if ( ! fs . existsSync ( png_path ) ) {
3537 return { success : false }
3638 }
39+ if ( params . copy_images_to_dir ) {
40+ const images_dir = path . join ( params . copy_images_to_dir , '.cwc' )
41+ if ( ! fs . existsSync ( images_dir ) ) {
42+ await fs . promises . mkdir ( images_dir , { recursive : true } )
43+ }
44+ const dest_path = path . join ( images_dir , path . basename ( png_path ) )
45+ await fs . promises . copyFile ( png_path , dest_path )
46+ return {
47+ path : path
48+ . relative ( params . copy_images_to_dir , dest_path )
49+ . replace ( / \\ / g, '/' ) ,
50+ success : true
51+ }
52+ }
3753 return {
38- path : png_path ,
54+ path : png_path . replace ( / \\ / g , '/' ) ,
3955 success : true
4056 }
4157 } else {
Original file line number Diff line number Diff line change @@ -20,6 +20,7 @@ export const replace_symbols = async (params: {
2020 remove_images ?: boolean
2121 image_as_paths ?: boolean
2222 symbols_cache ?: SymbolCacheManager
23+ copy_images_to_dir ?: string
2324} ) : Promise < {
2425 instructions : string [ ]
2526 skill_definitions : string
@@ -97,7 +98,8 @@ export const replace_symbols = async (params: {
9798 instructions : processed_instructions ,
9899 extension_context : params . extension_context ,
99100 remove : params . remove_images ,
100- as_paths : params . image_as_paths
101+ as_paths : params . image_as_paths ,
102+ copy_images_to_dir : params . copy_images_to_dir
101103 } )
102104 }
103105
You can’t perform that action at this time.
0 commit comments