MCPcopy
hub / github.com/Doorman11991/smallcode / buildSystemPrompt

Function buildSystemPrompt

bin/model_client.js:248–297  ·  view source on GitHub ↗
(ctx)

Source from the content-addressed store, hash-verified

246// ─── Helpers ─────────────────────────────────────────────────────────────────
247
248function buildSystemPrompt(ctx) {
249 const { config, conversationHistory, currentTaskType } = ctx;
250 const memCtx = getMemoryContext(ctx);
251 const skillCtx = getSkillContext(ctx);
252 const pluginCtx = getPluginPrompts(ctx);
253
254 let prompt = `You are SmallCode, a coding assistant that operates in the user's project directory.
255
256You have tools to read, write, and edit files, run shell commands, and search code.
257You also have project memory and compound tools that do multiple operations in one call.
258You have a CODE GRAPH indexed for this project — use it for understanding questions.
259
260IMPORTANT — Code Graph (use these FIRST for understanding/analysis questions):
261- list_projects: Lists ALL projects in the workspace with stats. Use FIRST when asked "what projects are here".
262- graph_search: Search for a specific symbol/function/class in the graph.
263- explain_symbol: Get full explanation of a function/class.
264- memory_load: Load relevant project memory.
265
266IMPORTANT — Environment:
267- OS: ${process.platform === 'win32' ? 'Windows (cmd.exe shell)' : process.platform === 'darwin' ? 'macOS (zsh)' : 'Linux (bash)'}
268${process.platform === 'win32' ? '- Use "dir" not "ls", "type" not "cat", "del" not "rm"\n- Do NOT use bash-specific commands (touch, export, chmod)' : ''}
269
270Rules:
271- PREFER compound tools to reduce back-and-forth.
272- Use "patch" for edits. Do NOT rewrite whole files.
273- Be concise — show what you did, not lengthy explanations.
274- If a tool fails, explain what went wrong. Do NOT output a greeting.
275- Create files with write_file directly. Do NOT run mkdir first.`;
276
277 if (currentTaskType === 'backend') {
278 prompt += `\n\nBONESCRIPT MODE — For Node.js/TypeScript backends, use BoneScript.`;
279 }
280
281 // Web research tools — only advertise them when web browsing is enabled.
282 // Smaller models trust the prose tool description over the raw `tools`
283 // array and will refuse research tasks ("my tools are for code files...")
284 // unless the prompt explicitly says the web tools exist (issue #58).
285 if (String(process.env.SMALLCODE_WEB_BROWSE).toLowerCase() === 'true') {
286 prompt += `
287
288WEB RESEARCH — you have live internet access:
289- web_search: focused query -> relevant results with URLs.
290- web_fetch: one URL -> that page's readable text.
291Use these whenever asked to research, look up, or find current information. Report a short summary with source URL(s); do NOT write scripts to fetch the web.`;
292 }
293
294 prompt += `\nWorking directory: ${process.cwd()}`;
295 prompt += memCtx + skillCtx + pluginCtx;
296 return prompt;
297}
298
299function getMemoryContext(ctx) {
300 try {

Callers 2

web_prompt.test.jsFile · 0.85
chatCompletionFunction · 0.85

Calls 3

getMemoryContextFunction · 0.70
getSkillContextFunction · 0.70
getPluginPromptsFunction · 0.70

Tested by

no test coverage detected