@@ -4,28 +4,28 @@ import { join } from "node:path";
44 import { tildePath } from "../cli/output.ts";
55
66 function tryReadFile(p: string): string | null {
7- if (!existsSync(p)) return null;
8- try {
9- return readFileSync(p, "utf-8");
10- } catch {
11- return null;
12- }
7+ if (!existsSync(p)) return null;
8+ try {
9+ return readFileSync(p, "utf-8");
10+ } catch {
11+ return null;
12+ }
1313 }
1414
1515 function loadGlobalContextFile(homeDir: string): string | null {
16- const globalDir = join(homeDir, ".agents");
17- return (
18- tryReadFile(join(globalDir, "AGENTS.md")) ??
19- tryReadFile(join(globalDir, "CLAUDE.md"))
20- );
16+ const globalDir = join(homeDir, ".agents");
17+ return (
18+ tryReadFile(join(globalDir, "AGENTS.md")) ??
19+ tryReadFile(join(globalDir, "CLAUDE.md"))
20+ );
2121 }
2222
2323 export function loadLocalContextFile(cwd: string): string | null {
24- return (
25- tryReadFile(join(cwd, ".agents", "AGENTS.md")) ??
26- tryReadFile(join(cwd, "CLAUDE.md")) ??
27- tryReadFile(join(cwd, "AGENTS.md"))
28- );
24+ return (
25+ tryReadFile(join(cwd, ".agents", "AGENTS.md")) ??
26+ tryReadFile(join(cwd, "CLAUDE.md")) ??
27+ tryReadFile(join(cwd, "AGENTS.md"))
28+ );
2929 }
3030
3131 const AUTONOMY = `
@@ -73,18 +73,18 @@ const FINAL_MESSAGE = `
7373 const SUBAGENT_DELEGATION = `You are running as a subagent. Complete the task you have been given directly using your tools. Do not spawn further subagents unless the subtask is unambiguously separable and self-contained.`;
7474
7575 export function buildSystemPrompt(
76- cwd: string,
77- extraSystemPrompt?: string,
78- isSubagent?: boolean,
79- /** Override home directory — used in tests to isolate global context loading. */
80- homeDir?: string,
76+ cwd: string,
77+ extraSystemPrompt?: string,
78+ isSubagent?: boolean,
79+ /** Override home directory — used in tests to isolate global context loading. */
80+ homeDir?: string,
8181 ): string {
82- const globalContext = loadGlobalContextFile(homeDir ?? homedir());
83- const localContext = loadLocalContextFile(cwd);
84- const cwdDisplay = tildePath(cwd);
85- const now = new Date().toLocaleString(undefined, { hour12: false });
82+ const globalContext = loadGlobalContextFile(homeDir ?? homedir());
83+ const localContext = loadLocalContextFile(cwd);
84+ const cwdDisplay = tildePath(cwd);
85+ const now = new Date().toLocaleString(undefined, { hour12: false });
8686
87- let prompt = `You are mini-coder, a small and fast CLI coding agent.
87+ let prompt = `You are mini-coder, a small and fast CLI coding agent.
8888 You have access to tools to read files, search code, make edits, run shell commands, and spawn subagents.
8989
9090 Current working directory: ${cwdDisplay}
@@ -100,29 +100,29 @@ Guidelines:
100100 # Tool output format
101101 \`read\` and \`grep\` prefix every line with \`line:hash|\` (e.g. \`11:a3| code here\`). This prefix is metadata — never include it in file content you write. Use the \`line:hash\` values as anchors for \`replace\` and \`insert\`.`;
102102
103- prompt += AUTONOMY;
104- prompt += SAFETY;
105- prompt += WORKSPACE_GUARDRAILS;
106- prompt += STATUS_UPDATES;
107- prompt += FINAL_MESSAGE;
108-
109- if (globalContext || localContext) {
110- prompt += "\n\n# Project context";
111- if (globalContext) {
112- prompt += `\n\n${globalContext}`;
113- }
114- if (localContext) {
115- prompt += `\n\n${localContext}`;
116- }
117- }
118-
119- if (isSubagent) {
120- prompt += `\n\n${SUBAGENT_DELEGATION}`;
121- }
122-
123- if (extraSystemPrompt) {
124- prompt += `\n\n${extraSystemPrompt}`;
125- }
126-
127- return prompt;
103+ prompt += AUTONOMY;
104+ prompt += SAFETY;
105+ prompt += WORKSPACE_GUARDRAILS;
106+ prompt += STATUS_UPDATES;
107+ prompt += FINAL_MESSAGE;
108+
109+ if (globalContext || localContext) {
110+ prompt += "\n\n# Project context";
111+ if (globalContext) {
112+ prompt += `\n\n${globalContext}`;
113+ }
114+ if (localContext) {
115+ prompt += `\n\n${localContext}`;
116+ }
117+ }
118+
119+ if (isSubagent) {
120+ prompt += `\n\n${SUBAGENT_DELEGATION}`;
121+ }
122+
123+ if (extraSystemPrompt) {
124+ prompt += `\n\n${extraSystemPrompt}`;
125+ }
126+
127+ return prompt;
128128 }