{"version":3,"file":"system-prompt.test.d.ts","sourceRoot":"","sources":["../../src/core/system-prompt.test.ts"],"names":[],"mappings":"","sourcesContent":["import { describe, expect, it } from \"vitest\";\nimport { buildSystemPrompt } from \"./system-prompt.ts\";\nimport type { AgentPersona } from \"./agents.ts\";\nimport type { Skill } from \"./skills.ts\";\n\ndescribe(\"buildSystemPrompt\", () => {\n\tit(\"includes the generic delegation-routing threshold in the default prompt\", () => {\n\t\tconst prompt = buildSystemPrompt({ cwd: \"/tmp/project\" });\n\n\t\texpect(prompt).toMatch(/When a delegation\\/subagent tool is available/i);\n\t\texpect(prompt).toMatch(/keep tiny targeted reads and simple answers local/i);\n\t\texpect(prompt).toMatch(/broad local investigation, external research, and mutation\\/implementation work/i);\n\t\texpect(prompt).toMatch(/capable delegated agent/i);\n\t\texpect(prompt).toMatch(/inspecting the delegation catalog\\/list before selecting/i);\n\t\texpect(prompt).toMatch(/parent remains the decision-maker and normally the sole writer/i);\n\t\texpect(prompt).toMatch(/Guidelines:/);\n\t\texpect(prompt).toContain(\"Current working directory: /tmp/project\");\n\t});\n\n\tit(\"keeps the default tool snippets, skills, and agents XML read-gated\", () => {\n\t\tconst skill: Skill = {\n\t\t\tname: \"test-skill\",\n\t\t\tdescription: \"Test skill description\",\n\t\t\tfilePath: \"/tmp/skills/test-skill/SKILL.md\",\n\t\t\tbaseDir: \"/tmp/skills/test-skill\",\n\t\t\tsourceInfo: { type: \"file\", path: \"/tmp/skills/test-skill/SKILL.md\" } as never,\n\t\t\tdisableModelInvocation: false,\n\t\t};\n\t\tconst agent: AgentPersona = {\n\t\t\tname: \"test-agent\",\n\t\t\tdescription: \"Test agent description\",\n\t\t\tfilePath: \"/tmp/agents/test-agent.md\",\n\t\t\tbaseDir: \"/tmp/agents\",\n\t\t\tsourceInfo: { type: \"file\", path: \"/tmp/agents/test-agent.md\" } as never,\n\t\t\tfrontmatter: {} as never,\n\t\t};\n\n\t\tconst withoutRead = buildSystemPrompt({\n\t\t\tcwd: \"/tmp/project\",\n\t\t\tselectedTools: [\"bash\"],\n\t\t\tskills: [skill],\n\t\t\tagents: [agent],\n\t\t});\n\t\texpect(withoutRead).not.toContain(\"<available_skills>\");\n\t\texpect(withoutRead).not.toContain(\"<available_agents>\");\n\t\texpect(withoutRead).toContain(\"Current working directory: /tmp/project\");\n\n\t\tconst withRead = buildSystemPrompt({\n\t\t\tcwd: \"/tmp/project\",\n\t\t\tselectedTools: [\"read\", \"bash\"],\n\t\t\tskills: [skill],\n\t\t\tagents: [agent],\n\t\t});\n\t\texpect(withRead).toContain(\"<available_skills>\");\n\t\texpect(withRead).toContain(\"<available_agents>\");\n\t\texpect(withRead).toContain(\"test-skill\");\n\t\texpect(withRead).toContain(\"test-agent\");\n\t});\n\n\tit(\"appends active promptGuidelines to a custom system prompt unchanged\", () => {\n\t\tconst prompt = buildSystemPrompt({\n\t\t\tcwd: \"/tmp/project\",\n\t\t\tcustomPrompt: \"You are my custom assistant.\",\n\t\t\tpromptGuidelines: ['Before executing, call { action: \"list\" }.'],\n\t\t});\n\n\t\texpect(prompt).toContain(\"You are my custom assistant.\");\n\t\texpect(prompt).toContain(\"Active tool guidelines:\");\n\t\texpect(prompt).toContain('- Before executing, call { action: \"list\" }.');\n\t\texpect(prompt).toContain(\"Current working directory: /tmp/project\");\n\t});\n\n\tit(\"deduplicates and trims active promptGuidelines in custom prompts\", () => {\n\t\tconst prompt = buildSystemPrompt({\n\t\t\tcwd: \"/tmp/project\",\n\t\t\tcustomPrompt: \"Custom.\",\n\t\t\tpromptGuidelines: [\"  Same guideline  \", \"Same guideline\", \"\", \"   \"],\n\t\t});\n\n\t\texpect(prompt).toContain(\"Active tool guidelines:\");\n\t\texpect(prompt.match(/- Same guideline/g)).toHaveLength(1);\n\t});\n\n\tit(\"does not add an empty guideline section when no promptGuidelines are supplied\", () => {\n\t\tconst prompt = buildSystemPrompt({ cwd: \"/tmp/project\", customPrompt: \"Custom text.\" });\n\n\t\texpect(prompt).toContain(\"Custom text.\");\n\t\texpect(prompt).not.toContain(\"Active tool guidelines:\");\n\t\texpect(prompt).toContain(\"Current working directory: /tmp/project\");\n\t});\n\n\tit(\"renders active promptGuidelines in custom prompts without requiring read\", () => {\n\t\tconst prompt = buildSystemPrompt({\n\t\t\tcwd: \"/tmp/project\",\n\t\t\tcustomPrompt: \"Custom.\",\n\t\t\tselectedTools: [\"bash\"],\n\t\t\tpromptGuidelines: [\"Mandatory active-tool guidance.\"],\n\t\t});\n\n\t\texpect(prompt).toContain(\"- Mandatory active-tool guidance.\");\n\t\texpect(prompt).not.toContain(\"<available_agents>\");\n\t});\n});\n"]}