@@ -87,16 +87,99 @@ ${isJinaAvailable() ? `
8787 - Arguments: {searchTerm: string}
8888` : '' }
8989
90+
91+
92+ Your capabilities include:
93+
94+ 1. File System Access:
95+ - Full access to read and edit files
96+ - All paths should be relative to current directory
97+ - Use './' or '.' for current directory references
98+ - Use relative paths for subdirectories
99+
100+ 2. Command Execution:
101+ - Can execute shell commands in the current environment
102+ - Ensure commands are compatible with the system
103+ - Can navigate and manipulate the file system
104+
105+ 3. Memory Management:
106+ - Access to system memory via /root/memory.json
107+ - Can add, retrieve, and clear memories
108+ - Use memory for context persistence
109+
110+ 4. Clipboard Access:
111+ - Can read content from the system clipboard
112+ ${ isJinaAvailable ( ) ? `
113+ 5. Jina API Integration:
114+ - Can read and parse content from a URL
115+ - Can search content using Jina Search API
116+ - Can search with grounding using Jina Grounding API
117+ ` : '' }
118+
90119Before taking any action, follow these steps:
91120
92121
93122Some tips:
94123- For any non file operations, use the BASH_TOOL
95124- If you need to locate the file, use BASH_TOOL to find the file path
96- - EDITOR_TOOL works best when you have the exact file path to work with
125+ - EDITOR_TOOL works best when you have the exact file path to work with.
97126- Best way to write or update a file is to use EDITOR_TOOL.
98127- If an information is needed to be stored for future reference, use MEMORY_TOOLS.
128+ - If you need to read content from a URL, search online use JINA_TOOLS.
129+ `
130+
131+ export const SYSTEM_PROMPT_TEMPLATE = `
132+ You are a versatile assistant with full system access.
133+ You are currently operating in \${Deno.cwd()} directory.
134+
135+ You have access to following tools and capabilities:
136+
137+ - BASH_TOOL:
138+ - Name: "bash"
139+ - Description: Execute shell commands
140+ - Arguments:
141+ - command: string (required) - The shell command to execute
142+ - restart: boolean (optional) - Restart shell session if true
143+ - Example: {command: "ls -la", restart: false}
144+
145+ - EDITOR_TOOL:
146+ - Name: "str_replace_editor"
147+ - Description: File manipulation operations
148+ - Commands:
149+ - view:
150+ - path: string (required)
151+ - create:
152+ -path: string (required)
153+ - file_text: string (required)
154+ - str_replace:
155+ - path: string (required)
156+ - old_str: string (required)
157+ - new_str: string (required)
158+ - insert:
159+ - path: string (required)
160+ - insert_line: number (required)
161+ - new_str: string (required)
162+ - MEMORY_TOOLS:
163+ - Name: "add_memory"
164+ - Arguments: {content: string}
165+ - Name: "get_memories"
166+ - Arguments: none
167+ - Name: "clear_memories"
168+ - Arguments: none
169+ - CLIPBOARD_TOOLS:
170+ - Name: "read_clipboard"
171+ - Arguments: none
172+ \${isJinaAvailable() ? \`
173+ - JINA_TOOLS:
174+ - Name: "readPage"
175+ - Arguments: {url: string}
176+ - Name: "search"
177+ - Arguments: {searchTerm: string}
178+ - Name: "searchGrounding"
179+ - Arguments: {searchTerm: string}
180+ \` : ''}
99181
182+ \${additionalTools}
100183
101184Your capabilities include:
102185
@@ -118,17 +201,26 @@ Your capabilities include:
118201
1192024. Clipboard Access:
120203 - Can read content from the system clipboard
121- ${ isJinaAvailable ( ) ? `
204+ \ ${isJinaAvailable() ? \ `
1222055. Jina API Integration:
123206 - Can read and parse content from a URL
124207 - Can search content using Jina Search API
125208 - Can search with grounding using Jina Grounding API
126- ` : '' }
209+ \ ` : ''}
127210
128- Always present your solution in this order:
129- 1. Understanding of the request
130- 2. Step-by-step plan
131- 3. Detailed execution of each step`
211+ Before taking any action, follow these steps:
212+
213+ Some tips:
214+ - For any non file operations, use the BASH_TOOL
215+ - If you need to locate the file, use BASH_TOOL to find the file path
216+ - EDITOR_TOOL works best when you have the exact file path to work with.
217+ - Best way to write or update a file is to use EDITOR_TOOL.
218+ - If an information is needed to be stored for future reference, use MEMORY_TOOLS.
219+ - If you need to read content from a URL, search online use JINA_TOOLS.
220+
221+ \${userContext}
222+ \${additionalInstructions ?? ''}
223+ `
132224
133225export const API_CONFIG = {
134226 MODEL : "claude-3-5-sonnet-20241022" ,
@@ -230,18 +322,41 @@ export const JINA_TOOLS: Anthropic.Beta.BetaTool[] = [
230322 } ,
231323]
232324
233- // Remove ALL_TOOLS export and definition
325+ interface SchemaProperty {
326+ type : string
327+ description ?: string
328+ }
234329
235- export function getSystemContext ( basePrompt : string ) : string {
330+ export function getSystemContext (
331+ additionalTools : Anthropic . Beta . Messages . BetaTool [ ] = [ ] ,
332+ additionalInstructions ?: string
333+ ) : string {
236334 const settings = loadUserSettings ( )
237- const customCommandsContext = settings . customCommands . length > 0
238- ? "\nAvailable Commands:\n" + settings . customCommands
239- . map ( cmd => `- ${ cmd . name } : ${ cmd . description } ${ cmd . helpCommand ? `\n Help: ${ cmd . helpCommand } ` : ''
240- } ${ cmd . helpText ? `\n Flags: ${ cmd . helpText } ` : ''
241- } `) . join ( '\n' )
242- : ''
243-
244- return `${ basePrompt }
335+
336+ const toolsString = additionalTools . map ( tool => {
337+ const schema = tool . input_schema as {
338+ type : string
339+ properties : Record < string , SchemaProperty >
340+ required ?: string [ ]
341+ }
342+ return `
343+ - ${ tool . name . toUpperCase ( ) } :
344+ - Name: "${ tool . name } "
345+ - Description: ${ tool . description }
346+ - Arguments: ${ Object . entries ( schema . properties )
347+ . map ( ( [ name , prop ] ) => `
348+ - ${ name } : ${ prop . type } ${ schema . required ?. includes ( name ) ? ' (required)' : '' } - ${ prop . description || '' } ` )
349+ . join ( '' ) }
350+ `
351+ } ) . join ( '\n' )
352+
353+ const userContext = `
245354User Context:
246- - Name: ${ settings . userName } ${ customCommandsContext } `
355+ - Name: ${ settings . userName }
356+ `
357+
358+ return SYSTEM_PROMPT_TEMPLATE
359+ . replace ( '${additionalTools}' , toolsString )
360+ . replace ( '${userContext}' , userContext )
361+ . replace ( '${additionalInstructions ?? \'\'}' , additionalInstructions ?? '' )
247362}
0 commit comments