@caupulican/pi-adaptative 0.93.4 → 0.93.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (78) hide show
  1. package/CHANGELOG.md +37 -0
  2. package/dist/bundled-resources/skills/n-plus-2-architecture/SKILL.md +13 -0
  3. package/dist/core/agent-session.d.ts.map +1 -1
  4. package/dist/core/agent-session.js +5 -20
  5. package/dist/core/agent-session.js.map +1 -1
  6. package/dist/core/autonomy/envelope-enforcement.d.ts +3 -1
  7. package/dist/core/autonomy/envelope-enforcement.d.ts.map +1 -1
  8. package/dist/core/autonomy/envelope-enforcement.js +23 -12
  9. package/dist/core/autonomy/envelope-enforcement.js.map +1 -1
  10. package/dist/core/autonomy/gates.d.ts.map +1 -1
  11. package/dist/core/autonomy/gates.js +24 -26
  12. package/dist/core/autonomy/gates.js.map +1 -1
  13. package/dist/core/context-gc.d.ts.map +1 -1
  14. package/dist/core/context-gc.js +128 -3
  15. package/dist/core/context-gc.js.map +1 -1
  16. package/dist/core/session-shutdown.d.ts +9 -0
  17. package/dist/core/session-shutdown.d.ts.map +1 -0
  18. package/dist/core/session-shutdown.js +44 -0
  19. package/dist/core/session-shutdown.js.map +1 -0
  20. package/dist/core/settings-manager.js.map +1 -1
  21. package/dist/core/skill-vault.d.ts +24 -16
  22. package/dist/core/skill-vault.d.ts.map +1 -1
  23. package/dist/core/skill-vault.js +159 -82
  24. package/dist/core/skill-vault.js.map +1 -1
  25. package/dist/core/system-prompt.d.ts.map +1 -1
  26. package/dist/core/system-prompt.js +7 -18
  27. package/dist/core/system-prompt.js.map +1 -1
  28. package/dist/core/tools/bash.d.ts +3 -1
  29. package/dist/core/tools/bash.d.ts.map +1 -1
  30. package/dist/core/tools/bash.js +15 -7
  31. package/dist/core/tools/bash.js.map +1 -1
  32. package/dist/core/tools/edit.d.ts.map +1 -1
  33. package/dist/core/tools/edit.js +86 -33
  34. package/dist/core/tools/edit.js.map +1 -1
  35. package/dist/core/tools/file-mutation-intent.d.ts +16 -0
  36. package/dist/core/tools/file-mutation-intent.d.ts.map +1 -1
  37. package/dist/core/tools/file-mutation-intent.js +51 -2
  38. package/dist/core/tools/file-mutation-intent.js.map +1 -1
  39. package/dist/core/tools/persistent-process-coordinator.d.ts +8 -2
  40. package/dist/core/tools/persistent-process-coordinator.d.ts.map +1 -1
  41. package/dist/core/tools/persistent-process-coordinator.js +52 -4
  42. package/dist/core/tools/persistent-process-coordinator.js.map +1 -1
  43. package/dist/core/tools/shell-execution-session.d.ts +8 -1
  44. package/dist/core/tools/shell-execution-session.d.ts.map +1 -1
  45. package/dist/core/tools/shell-execution-session.js +54 -3
  46. package/dist/core/tools/shell-execution-session.js.map +1 -1
  47. package/dist/core/tools/shell-session.d.ts +5 -2
  48. package/dist/core/tools/shell-session.d.ts.map +1 -1
  49. package/dist/core/tools/shell-session.js +112 -17
  50. package/dist/core/tools/shell-session.js.map +1 -1
  51. package/dist/core/tools/skill.d.ts +2 -1
  52. package/dist/core/tools/skill.d.ts.map +1 -1
  53. package/dist/core/tools/skill.js +26 -12
  54. package/dist/core/tools/skill.js.map +1 -1
  55. package/dist/core/tools/windows-shell-engine.d.ts +1 -1
  56. package/dist/core/tools/windows-shell-engine.d.ts.map +1 -1
  57. package/dist/core/tools/windows-shell-engine.js +6 -2
  58. package/dist/core/tools/windows-shell-engine.js.map +1 -1
  59. package/dist/index.d.ts +1 -1
  60. package/dist/index.d.ts.map +1 -1
  61. package/dist/index.js +1 -1
  62. package/dist/index.js.map +1 -1
  63. package/dist/modes/interactive/components/settings-selector.js +2 -2
  64. package/dist/modes/interactive/components/settings-selector.js.map +1 -1
  65. package/dist/utils/shell.d.ts +3 -5
  66. package/dist/utils/shell.d.ts.map +1 -1
  67. package/dist/utils/shell.js +4 -7
  68. package/dist/utils/shell.js.map +1 -1
  69. package/docs/settings.md +7 -7
  70. package/examples/extensions/custom-provider-anthropic/package-lock.json +2 -2
  71. package/examples/extensions/custom-provider-anthropic/package.json +1 -1
  72. package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
  73. package/examples/extensions/sandbox/package-lock.json +2 -2
  74. package/examples/extensions/sandbox/package.json +1 -1
  75. package/examples/extensions/with-deps/package-lock.json +2 -2
  76. package/examples/extensions/with-deps/package.json +1 -1
  77. package/npm-shrinkwrap.json +12 -12
  78. package/package.json +4 -4
@@ -1 +1 @@
1
- {"version":3,"file":"system-prompt.js","sourceRoot":"","sources":["../../src/core/system-prompt.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC7C,OAAO,EAAE,uBAAuB,EAAE,uBAAuB,EAAE,MAAM,yBAAyB,CAAC;AAE3F,OAAO,EAAE,wCAAwC,EAA+B,MAAM,uBAAuB,CAAC;AAC9G,OAAO,EAAE,uBAAuB,EAAE,MAAM,gCAAgC,CAAC;AA0BzE,MAAM,gCAAgC,GACrC,sIAAsI,CAAC;AAExI,MAAM,yBAAyB,GAAG;;;;;;qLAMmJ,CAAC;AAEtL,MAAM,0BAA0B,GAAG;;;;;;;;;;IAU/B,gCAAgC;;;;;;;;;;;;;;kJAc8G,CAAC;AAEnJ,MAAM,+BAA+B,GAAG;;;;;;;;;IASpC,gCAAgC,EAAE,CAAC;AAEvC,MAAM,kCAAkC,GAAG;;;;;;;;IAQvC,gCAAgC,EAAE,CAAC;AAEvC,MAAM,+BAA+B,GAAG;;;;;;0FAMkD,CAAC;AAE3F,MAAM,kCAAkC,GAAG,GAAG,CAAC;AAC/C,MAAM,kCAAkC,GAAG,GAAG,CAAC;AAE/C,SAAS,iBAAiB,CAAC,KAAa,EAAE,QAAgB;IACzD,MAAM,UAAU,GAAG,KAAK,CAAC,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC;IACrD,IAAI,UAAU,CAAC,MAAM,IAAI,QAAQ;QAAE,OA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CAAC,CAAC,EAAE,CAAC;YACtC,GAAG,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;YAC5C,GAAG,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,WAAW,EAAE,iBAAiB,CAAC,WAAW,EAAE,kCAAkC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;SAC3G,CAAC,CACF,CAAC;QACF,KAAK,EAAE,CAAC;IACT,CAAC;IAED,IAAI,KAAK,KAAK,CAAC,EAAE,CAAC;QACjB,OAAO,EAAE,CAAC;IACX,CAAC;IAED,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACzB,CAAC","sourcesContent":["/**\n * System prompt construction and project context loading\n */\n\nimport { dirname } from \"node:path\";\nimport { getReadmePath } from \"../config.ts\";\nimport { getExtensionDescription, getExtensionDisplayName } from \"./extension-metadata.ts\";\nimport type { Extension } from \"./extensions/types.ts\";\nimport { enforceModelCapabilitySystemPromptBudget, type ModelCapabilityProfile } from \"./model-capability.ts\";\nimport { SKILL_VAULT_SYSTEM_RULE } from \"./provider-prompt-contracts.ts\";\nimport type { Skill } from \"./skills.ts\";\n\nexport interface BuildSystemPromptOptions {\n\t/** Capability profile that selects the stable prompt shape. Missing means full/legacy behavior. */\n\tmodelCapability?: Pick<ModelCapabilityProfile, \"class\" | \"contextWindow\" | \"reasonCode\" | \"systemPromptMaxChars\">;\n\t/** Custom system prompt (replaces default). */\n\tcustomPrompt?: string;\n\t/** Tools to include in the prompt. Defaults come from the shared active-tool surface. */\n\tselectedTools?: string[];\n\t/** Optional one-line tool snippets keyed by tool name. */\n\ttoolSnippets?: Record<string, string>;\n\t/** Additional guideline bullets appended to the default system prompt guidelines. */\n\tpromptGuidelines?: string[];\n\t/** Text to append to system prompt. */\n\tappendSystemPrompt?: string;\n\t/** Working directory. */\n\tcwd: string;\n\t/** Global instruction files (with content) plus on-demand project paths (path only). */\n\tcontextFiles?: Array<{ path: string; content?: string }>;\n\t/** Discovered skills remain host-side; retained for extension/API construction compatibility. */\n\tskills?: Skill[];\n\t/** Discovered extensions currently active. */\n\textensions?: Extension[];\n}\n\nconst MODEL_BLIND_CREDENTIAL_AUTHORITY =\n\t\"Active secret_store: host gate authorizes model-blind activation/migration from named accessible sources; no duplicate confirmation.\";\n\nconst ULTRA_TERSE_OUTPUT_POLICY = `\n\nULTRA-TERSE OUTPUT\n\n- Drop articles/filler/pleasantries/hedging; fragments valid. Strip conjunctions only when clear; each fact once.\n- Never drop not/never/no/only/except; never invent abbreviations or use causal arrows. Preserve numbers, units, code symbols, function/API names, commands, errors.\n- No self-reference/tool narration/tables/emoji/log dumps. Keep user language. Full grammar: security, irreversible actions, ambiguous order. Replies terse; artifacts normal prose.`;\n\nconst PI_ADAPTATIVE_CORE_SECTION = `\n\nOPERATING CONTRACT\n\n- Clear conversational outcome is goal; persist progress/evidence through compaction; finish or report blocker.\n- Hold scope; verify unknowns from primary sources; simplest proven design, one owner/path per invariant.\n- User outcome governs, method does not. Outcome risk: show evidence, test when practical, offer safest effective path, execute.\n- Work over 15 seconds: managed background run, event terminal, bounded handoff, owner notice; never poll.\n- Delegate independent work within host bounds; root integrates/verifies. Facts: memory, specialization: skills, behavior: source; discard noise.\n- Ask before broader scope, credential or authentication change/disclosure, destructive action, publication. Bound, source-label output; show paths.\n- ${MODEL_BLIND_CREDENTIAL_AUTHORITY}\n\nN+2 ARCHITECTURE\n\nLanguage-agnostic principles:\n1. Bounded flat arenas/pools/rings/chunks, batch recycle.\n2. Safe zero/default data/state, no hidden allocation, one activation owner.\n3. Validate trust boundary once; internal miss gets safe stub/default, external failure explicit.\n4. Stable IDs/indexes/buffers/batches; avoid pointer graphs/dispatch/fallback.\n5. Never concatenate growing prefixes, prepend, rescan consumed input, serialize unchanged history, rebuild incremental state; materialize once.\n\nEVIDENCE GATE\n\n- Map flow/lifetimes/boundaries/hot paths. Detect, verify, score, gate: baseline; deterministic positive/negative controls; lowest-owner fix; focused/proportionate checks.\n- Scanner/fuzzer/log/static/model finding stays candidate pending reproduction. Never weaken tests, claim success from skipped/incomplete probes.`;\n\nconst PI_ADAPTATIVE_LEAN_CORE_SECTION = `\n\nOPERATING CONTRACT\n\n- Complete current goal within scope, granted authority; keep progress, evidence concise.\n- Inspect relevant files, project instructions before mutation; make smallest coherent change, run focused checks.\n- Use active tools, exact schemas. On failure, read error, expected shape, correct call; never repeat unchanged failure.\n- Batch independent reads, order mutations; report real output, unresolved failures.\n- Ask before destructive actions, credential disclosure or provider authentication changes, publication, push/tag/release, material scope expansion.\n- ${MODEL_BLIND_CREDENTIAL_AUTHORITY}`;\n\nconst PI_ADAPTATIVE_MINIMAL_CORE_SECTION = `\n\nEXECUTION RULES\n\n- Work one scoped task. Inspect before editing, make small coherent change, run narrowest useful check.\n- Use listed tools, exact schemas. On failure, read error, expected shape, correct call; never repeat unchanged failure.\n- Batch independent reads, order mutations. Report actual results; never claim incomplete action.\n- Ask before destructive actions, credential disclosure or provider authentication changes, publication, push/tag/release, material scope change.\n- ${MODEL_BLIND_CREDENTIAL_AUTHORITY}`;\n\nconst PI_ADAPTATIVE_CHAT_CORE_SECTION = `\n\nCHAT RULES\n\n- Answer concisely from conversation; state uncertainty.\n- No execution tools are active. Do not claim to read files, run commands, or make changes.\n- Say when the request requires a tool-capable model or additional user-provided context.`;\n\nconst DEFERRED_CONTEXT_PATH_BUDGET_CHARS = 512;\nconst EXTENSION_DESCRIPTION_BUDGET_CHARS = 180;\n\nfunction compactPromptText(value: string, maxChars: number): string {\n\tconst normalized = value.replace(/\\s+/g, \" \").trim();\n\tif (normalized.length <= maxChars) return normalized;\n\tlet end = maxChars - 1;\n\tconst code = normalized.charCodeAt(end - 1);\n\tif (code >= 0xd800 && code <= 0xdbff) end--;\n\treturn `${normalized.slice(0, end)}…`;\n}\n\nfunction formatContextFilesForPrompt(\n\tcontextFiles: Array<{ path: string; content?: string }>,\n\toptions: { deferContents: boolean; canRead: boolean },\n): string {\n\tif (contextFiles.length === 0) {\n\t\treturn \"\";\n\t}\n\tconst injected = options.deferContents ? [] : contextFiles.filter((file) => file.content !== undefined);\n\tconst deferred = options.deferContents ? contextFiles : contextFiles.filter((file) => file.content === undefined);\n\tconst parts: string[] = [];\n\n\tif (injected.length > 0) {\n\t\tconst lines = [\"\\n\\nPROJECT-SPECIFIC INSTRUCTIONS (apply in listed order)\"];\n\t\tconst seen = new Set<string>();\n\t\tfor (const { path, content } of injected) {\n\t\t\tconst identity = `${path}\\0${content ?? \"\"}`;\n\t\t\tif (seen.has(identity)) continue;\n\t\t\tseen.add(identity);\n\t\t\tlines.push(`FILE ${JSON.stringify(path)} (${(content ?? \"\").length} chars)`);\n\t\t\tlines.push(content ?? \"\");\n\t\t\tlines.push(\"END FILE\");\n\t\t}\n\t\tparts.push(lines.join(\"\\n\"));\n\t}\n\n\tif (deferred.length > 0) {\n\t\tconst lines = [\n\t\t\t\"\\n\\nPROJECT RULE PATHS — contents not preloaded.\",\n\t\t\toptions.deferContents\n\t\t\t\t? options.canRead\n\t\t\t\t\t? \"Before editing, writing, or running a mutating command, read each relevant listed file completely before any mutation. Follow its instructions; if a file cannot fit, ask for a scoped instruction digest.\"\n\t\t\t\t\t: \"No read tool is active. Ask the user for the relevant project instructions before giving project-specific guidance.\"\n\t\t\t\t: options.canRead\n\t\t\t\t\t? \"Read a listed file completely before following it. Do not assume its contents.\"\n\t\t\t\t\t: \"No read tool is active. Ask the user for the relevant project instructions before giving project-specific guidance.\",\n\t\t];\n\t\tlet pathChars = 0;\n\t\tlet included = 0;\n\t\tfor (const { path } of deferred) {\n\t\t\tconst line = `- ${JSON.stringify(path)}`;\n\t\t\tif (pathChars + line.length > DEFERRED_CONTEXT_PATH_BUDGET_CHARS) break;\n\t\t\tlines.push(line);\n\t\t\tpathChars += line.length + 1;\n\t\t\tincluded++;\n\t\t}\n\t\tconst omitted = deferred.length - included;\n\t\tif (omitted > 0) {\n\t\t\tlines.push(`- omitted=${omitted}`);\n\t\t\tlines.push(\n\t\t\t\t\"Do not mutate until the omitted instruction paths are supplied or a more capable profile is used.\",\n\t\t\t);\n\t\t}\n\t\tparts.push(lines.join(\"\\n\"));\n\t}\n\n\treturn parts.join(\"\");\n}\n\nfunction appendPromptResources(\n\tprompt: string,\n\toptions: {\n\t\tappendSection: string;\n\t\tcontextFiles: Array<{ path: string; content?: string }>;\n\t\textensions: Extension[];\n\t\tvisibleTools: string[];\n\t\tfullPrompt: boolean;\n\t\thasRead: boolean;\n\t\tdate: string;\n\t\tpromptCwd: string;\n\t\tmodelCapability: BuildSystemPromptOptions[\"modelCapability\"];\n\t},\n): string {\n\tlet result = prompt;\n\tif (options.appendSection) result += options.appendSection;\n\tresult += formatContextFilesForPrompt(options.contextFiles, {\n\t\tdeferContents: !options.fullPrompt,\n\t\tcanRead: options.hasRead,\n\t});\n\t// Extension metadata is redundant with the active tool snippets on constrained profiles.\n\tif (options.fullPrompt && options.extensions.length > 0) {\n\t\tresult += formatExtensionsForPrompt(options.extensions, options.visibleTools);\n\t}\n\t// Day-granularity only; keep this tail stable across every call on the same calendar day.\n\tresult += `\\nCurrent date: ${options.date}`;\n\tresult += `\\nCurrent working directory: ${options.promptCwd}`;\n\t// Prompt resources can come from CRLF checkouts or user files. Canonicalize once at the final\n\t// assembly boundary so capability budgets and provider cache keys are host-independent.\n\tconst normalizedResult = result.replace(/\\r\\n?/g, \"\\n\");\n\treturn options.modelCapability\n\t\t? enforceModelCapabilitySystemPromptBudget(normalizedResult, options.modelCapability)\n\t\t: normalizedResult;\n}\n\n/**\n * Build the system prompt with tools, guidelines, and context.\n *\n * CACHE-STABILITY INVARIANT: providers treat the returned string as ONE prompt-cache block (a\n * single cache breakpoint covering the whole system prompt). The caller (SystemPromptBuilder /\n * AgentSession, see `_rebuildSystemPrompt` in agent-session.ts) rebuilds it only when the TOOL\n * SURFACE changes — never per turn. For a fixed `options` (fixed tool surface, cwd, context\n * files, extensions), two calls on the SAME CALENDAR DAY must return byte-identical\n * output, because `date` below is deliberately truncated to Y-M-D granularity. Do NOT widen it\n * to a timestamp (HH:MM:SS) or otherwise fold in any per-turn-volatile field (turn counters,\n * elapsed time, random ids, etc.) — that would cache-bust this entire block on EVERY turn instead\n * of once per calendar day, defeating provider prompt caching (cost + latency regression on every\n * request). Pinned by test/system-prompt-stability.test.ts.\n */\nexport function buildSystemPrompt(options: BuildSystemPromptOptions): string {\n\tconst {\n\t\tcustomPrompt,\n\t\tselectedTools,\n\t\ttoolSnippets,\n\t\tpromptGuidelines,\n\t\tappendSystemPrompt,\n\t\tcwd,\n\t\tcontextFiles: providedContextFiles,\n\t} = options;\n\tconst resolvedCwd = cwd;\n\tconst promptCwd = resolvedCwd.replace(/\\\\/g, \"/\");\n\n\t// Day-granularity only (see cache-stability invariant on buildSystemPrompt above): this must\n\t// stay stable across every call within a calendar day, not just within a single turn.\n\tconst now = new Date();\n\tconst year = now.getFullYear();\n\tconst month = String(now.getMonth() + 1).padStart(2, \"0\");\n\tconst day = String(now.getDate()).padStart(2, \"0\");\n\tconst date = `${year}-${month}-${day}`;\n\n\tconst appendSection = appendSystemPrompt ? `\\n\\n${appendSystemPrompt}` : \"\";\n\n\tconst contextFiles = providedContextFiles ?? [];\n\tconst capabilityClass = options.modelCapability?.class ?? \"full\";\n\tconst fullPrompt = capabilityClass === \"full\";\n\tconst leanPrompt = capabilityClass === \"lean\";\n\n\tconst activeTools = selectedTools || [\"read\", \"bash\", \"python\", \"edit\", \"write\"];\n\tconst visibleTools = activeTools.filter((name) => !!toolSnippets?.[name]);\n\tconst hasRead = activeTools.includes(\"read\");\n\tconst coreSection = fullPrompt\n\t\t? PI_ADAPTATIVE_CORE_SECTION\n\t\t: leanPrompt\n\t\t\t? PI_ADAPTATIVE_LEAN_CORE_SECTION\n\t\t\t: capabilityClass === \"minimal\"\n\t\t\t\t? PI_ADAPTATIVE_MINIMAL_CORE_SECTION\n\t\t\t\t: PI_ADAPTATIVE_CHAT_CORE_SECTION;\n\tconst skillVaultContract = activeTools.includes(\"skill\") ? `\\n\\n${SKILL_VAULT_SYSTEM_RULE}` : \"\";\n\tconst operatingContract = `${coreSection}${skillVaultContract}${ULTRA_TERSE_OUTPUT_POLICY}`;\n\n\tif (customPrompt) {\n\t\tlet prompt = customPrompt;\n\n\t\tprompt += operatingContract;\n\t\treturn appendPromptResources(prompt, {\n\t\t\tappendSection,\n\t\t\tcontextFiles,\n\t\t\textensions: options.extensions ?? [],\n\t\t\tvisibleTools,\n\t\t\tfullPrompt,\n\t\t\thasRead,\n\t\t\tdate,\n\t\t\tpromptCwd,\n\t\t\tmodelCapability: options.modelCapability,\n\t\t});\n\t}\n\n\tconst packageRoot = dirname(getReadmePath());\n\n\t// Build tools list based on selected tools.\n\t// A tool appears in Available tools only when the caller provides a one-line snippet.\n\tconst toolsList =\n\t\tvisibleTools.length > 0 ? visibleTools.map((name) => `- ${name}: ${toolSnippets![name]}`).join(\"\\n\") : \"(none)\";\n\n\t// Build guidelines based on which tools are actually available\n\tconst guidelinesList: string[] = [];\n\tconst guidelinesSet = new Set<string>();\n\tconst addGuideline = (guideline: string): void => {\n\t\tif (guidelinesSet.has(guideline)) {\n\t\t\treturn;\n\t\t}\n\t\tguidelinesSet.add(guideline);\n\t\tguidelinesList.push(guideline);\n\t};\n\n\tconst hasBash = activeTools.includes(\"bash\");\n\tconst hasPython = activeTools.includes(\"python\");\n\tconst hasGrep = activeTools.includes(\"grep\");\n\tconst hasFind = activeTools.includes(\"find\");\n\tconst hasLs = activeTools.includes(\"ls\");\n\tconst hasReadOnlyTools = hasRead || hasGrep || hasFind || hasLs;\n\n\t// File exploration guidelines\n\tif (!fullPrompt && !leanPrompt) {\n\t\tif (hasBash) addGuideline(\"Use bash for bounded shell commands\");\n\t\tif (hasReadOnlyTools) addGuideline(\"Batch independent reads; keep mutations and dependent calls ordered\");\n\t} else if (hasBash && !hasGrep && !hasFind && !hasLs) {\n\t\taddGuideline(\"Bash: ls, rg, find\");\n\t}\n\tif (fullPrompt || leanPrompt) {\n\t\tif (hasBash || hasGrep || hasFind) {\n\t\t\taddGuideline(\"rg/jq: scoped roots/filters, exhaustive output to file\");\n\t\t}\n\t\tif (hasPython) {\n\t\t\taddGuideline(\"Python: bounded scripts/data, source edits via read/edit/write\");\n\t\t}\n\t\tif (hasReadOnlyTools) {\n\t\t\taddGuideline(\"Batch independent reads; order dependent/mutating/stateful calls\");\n\t\t}\n\t}\n\n\tif (fullPrompt || leanPrompt) {\n\t\tfor (const guideline of promptGuidelines ?? []) {\n\t\t\tconst normalized = guideline.trim();\n\t\t\tif (normalized.length > 0) {\n\t\t\t\taddGuideline(normalized);\n\t\t\t}\n\t\t}\n\t}\n\n\tconst guidelines = guidelinesList.map((g) => `- ${g}`).join(\"\\n\");\n\tconst toolGuidelinesSection = guidelines.length > 0 ? `\\n\\nTOOL GUIDELINES\\n\\n${guidelines}` : \"\";\n\n\tconst introduction = fullPrompt\n\t\t? \"Pi-Adaptative: self-evolving assistant. Deliver goals within authority; preserve continuity, own integration.\"\n\t\t: leanPrompt\n\t\t\t? \"Pi-Adaptative bounded coding agent. Complete current goal with active surface; preserve handoff evidence.\"\n\t\t\t: capabilityClass === \"minimal\"\n\t\t\t\t? \"Pi-Adaptative focused coding executor. Complete one scoped task with active tools; report verified results.\"\n\t\t\t\t: \"Pi-Adaptative concise chat assistant. No execution tools active.\";\n\tconst toolSurfaceRule =\n\t\tfullPrompt || leanPrompt\n\t\t\t? \"Use active tool surface only; unlisted capabilities may exist.\"\n\t\t\t: \"Use only the active tool surface.\";\n\tlet prompt = `${introduction}\n\nAvailable tools:\n${toolsList}\n\n${toolSurfaceRule}${operatingContract}${toolGuidelinesSection}`;\n\n\tif (fullPrompt) {\n\t\tprompt += `\n\nPI DOCS: root=${packageRoot}. Relevant work only; read needed README.md, \\`docs/...\\`, \\`examples/...\\` fully, follow links.`;\n\t}\n\n\treturn appendPromptResources(prompt, {\n\t\tappendSection,\n\t\tcontextFiles,\n\t\textensions: options.extensions ?? [],\n\t\tvisibleTools,\n\t\tfullPrompt,\n\t\thasRead,\n\t\tdate,\n\t\tpromptCwd,\n\t\tmodelCapability: options.modelCapability,\n\t});\n}\n\nfunction formatExtensionsForPrompt(extensions: Extension[], visibleTools: string[]): string {\n\tif (extensions.length === 0) {\n\t\treturn \"\";\n\t}\n\n\tconst lines = [\"\\n\\nEXTENSIONS: name, path, tools, commands, description\"];\n\tlet added = 0;\n\n\tfor (const ext of extensions) {\n\t\tconst name = getExtensionDisplayName(ext.path);\n\t\tconst description = getExtensionDescription(ext.path);\n\n\t\tconst tools = Array.from(ext.tools.keys()).filter((t) => visibleTools.includes(t));\n\t\tconst commands = Array.from(ext.commands.keys());\n\n\t\t// Skip extension listing if it has no visible tools, commands, or description\n\t\tif (tools.length === 0 && commands.length === 0 && !description) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tlines.push(\n\t\t\tJSON.stringify({\n\t\t\t\tname,\n\t\t\t\tpath: ext.path,\n\t\t\t\t...(tools.length > 0 ? { tools } : {}),\n\t\t\t\t...(commands.length > 0 ? { commands } : {}),\n\t\t\t\t...(description ? { description: compactPromptText(description, EXTENSION_DESCRIPTION_BUDGET_CHARS) } : {}),\n\t\t\t}),\n\t\t);\n\t\tadded++;\n\t}\n\n\tif (added === 0) {\n\t\treturn \"\";\n\t}\n\n\treturn lines.join(\"\\n\");\n}\n"]}
1
+ {"version":3,"file":"system-prompt.js","sourceRoot":"","sources":["../../src/core/system-prompt.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC7C,OAAO,EAAE,uBAAuB,EAAE,uBAAuB,EAAE,MAAM,yBAAyB,CAAC;AAE3F,OAAO,EAAE,wCAAwC,EAA+B,MAAM,uBAAuB,CAAC;AAC9G,OAAO,EAAE,uBAAuB,EAAE,MAAM,gCAAgC,CAAC;AA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K,GAAG,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;QACnF,MAAM,QAAQ,GAAG,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAC;QAEjD,8EAA8E;QAC9E,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC;YACjE,SAAS;QACV,CAAC;QAED,KAAK,CAAC,IAAI,CACT,IAAI,CAAC,SAAS,CAAC;YACd,IAAI;YACJ,IAAI,EAAE,GAAG,CAAC,IAAI;YACd,GAAG,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;YACtC,GAAG,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;YAC5C,GAAG,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,WAAW,EAAE,iBAAiB,CAAC,WAAW,EAAE,kCAAkC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;SAC3G,CAAC,CACF,CAAC;QACF,KAAK,EAAE,CAAC;IACT,CAAC;IAED,IAAI,KAAK,KAAK,CAAC,EAAE,CAAC;QACjB,OAAO,EAAE,CAAC;IACX,CAAC;IAED,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACzB,CAAC","sourcesContent":["/**\n * System prompt construction and project context loading\n */\n\nimport { dirname } from \"node:path\";\nimport { getReadmePath } from \"../config.ts\";\nimport { getExtensionDescription, getExtensionDisplayName } from \"./extension-metadata.ts\";\nimport type { Extension } from \"./extensions/types.ts\";\nimport { enforceModelCapabilitySystemPromptBudget, type ModelCapabilityProfile } from \"./model-capability.ts\";\nimport { SKILL_VAULT_SYSTEM_RULE } from \"./provider-prompt-contracts.ts\";\nimport type { Skill } from \"./skills.ts\";\n\nexport interface BuildSystemPromptOptions {\n\t/** Capability profile that selects the stable prompt shape. Missing means full/legacy behavior. */\n\tmodelCapability?: Pick<ModelCapabilityProfile, \"class\" | \"contextWindow\" | \"reasonCode\" | \"systemPromptMaxChars\">;\n\t/** Custom system prompt (replaces default). */\n\tcustomPrompt?: string;\n\t/** Tools to include in the prompt. Defaults come from the shared active-tool surface. */\n\tselectedTools?: string[];\n\t/** Optional one-line tool snippets keyed by tool name. */\n\ttoolSnippets?: Record<string, string>;\n\t/** Additional guideline bullets appended to the default system prompt guidelines. */\n\tpromptGuidelines?: string[];\n\t/** Text to append to system prompt. */\n\tappendSystemPrompt?: string;\n\t/** Working directory. */\n\tcwd: string;\n\t/** Global instruction files (with content) plus on-demand project paths (path only). */\n\tcontextFiles?: Array<{ path: string; content?: string }>;\n\t/** Discovered skills remain host-side; retained for extension/API construction compatibility. */\n\tskills?: Skill[];\n\t/** Discovered extensions currently active. */\n\textensions?: Extension[];\n}\n\nconst MODEL_BLIND_CREDENTIAL_AUTHORITY =\n\t\"Active secret_store: host gate authorizes model-blind activation/migration from named accessible sources; no duplicate confirmation.\";\n\nconst ULTRA_TERSE_OUTPUT_POLICY = `\n\nULTRA-TERSE OUTPUT\n\n- Drop articles/filler/pleasantries/hedging; fragments valid. Strip conjunctions only when clear; each fact once.\n- Never drop not/never/no/only/except; never invent abbreviations or use causal arrows. Preserve numbers, units, code symbols, function/API names, commands, errors.\n- No self-reference/tool narration/tables/emoji/log dumps. Keep user language. Full grammar: security, irreversible actions, ambiguous order. Replies terse; artifacts normal prose.\n- Answer shape: status/ops turns terse; analysis/review/evaluation asks get complete structured answers; never restate harness protocol text or failure-record JSON to the user as an answer.`;\n\nconst PI_ADAPTATIVE_CORE_SECTION = `\n\nOPERATING CONTRACT\n\n- Clear conversational outcome is goal; persist progress/evidence through compaction; finish or report blocker.\n- Hold scope; verify unknowns from primary sources; simplest proven design, one owner/path per invariant.\n- User outcome governs, method does not. Outcome risk: show evidence, test when practical, offer safest effective path, execute.\n- Work over 15 seconds: managed background run, event terminal, bounded handoff, owner notice; never poll.\n- Delegate independent work within host bounds; root integrates/verifies. Facts: memory, specialization: skills, behavior: source; discard noise.\n- Implementation/verification work loads skill evidence-gated-tdd; architecture/performance design loads skill n-plus-2-architecture; their gates bind only while that work is active.\n- Explicit user instruction in current message overrides standing style (length/format/tone); security, untrusted-content, and authorization rules are never overridable.\n- Ask before broader scope, credential or authentication change/disclosure, destructive action, publication. Bound, source-label output; show paths.\n- ${MODEL_BLIND_CREDENTIAL_AUTHORITY}`;\n\nconst PI_ADAPTATIVE_LEAN_CORE_SECTION = `\n\nOPERATING CONTRACT\n\n- Complete current goal within scope, granted authority; keep progress, evidence concise.\n- Inspect relevant files and instructions before editing; make minimal coherent change, run focused checks.\n- Use active tools, exact schemas. On failure, read error, expected shape, correct call; never repeat unchanged failure.\n- Batch independent reads, order mutations; report real output, unresolved failures.\n- Ask before destructive actions, credential disclosure or provider authentication changes, publication, push/tag/release, scope expansion.\n- ${MODEL_BLIND_CREDENTIAL_AUTHORITY}`;\n\nconst PI_ADAPTATIVE_MINIMAL_CORE_SECTION = `\n\nEXECUTION RULES\n\n- Work one scoped task. Inspect before editing, make small coherent change, run narrowest useful check.\n- Use listed tools, exact schemas. On failure, read error, expected shape, correct call; never repeat unchanged failure.\n- Batch independent reads, order mutations. Report actual results; never claim incomplete action.\n- Ask before destructive actions, credential disclosure or provider authentication changes, publication, push/tag/release, material scope change.\n- ${MODEL_BLIND_CREDENTIAL_AUTHORITY}`;\n\nconst PI_ADAPTATIVE_CHAT_CORE_SECTION = `\n\nCHAT RULES\n\n- Answer concisely from conversation; state uncertainty.\n- No execution tools are active. Do not claim to read files, run commands, or make changes.\n- Say when the request requires a tool-capable model or additional user-provided context.`;\n\nconst DEFERRED_CONTEXT_PATH_BUDGET_CHARS = 512;\nconst EXTENSION_DESCRIPTION_BUDGET_CHARS = 180;\n\nfunction compactPromptText(value: string, maxChars: number): string {\n\tconst normalized = value.replace(/\\s+/g, \" \").trim();\n\tif (normalized.length <= maxChars) return normalized;\n\tlet end = maxChars - 1;\n\tconst code = normalized.charCodeAt(end - 1);\n\tif (code >= 0xd800 && code <= 0xdbff) end--;\n\treturn `${normalized.slice(0, end)}…`;\n}\n\nfunction formatContextFilesForPrompt(\n\tcontextFiles: Array<{ path: string; content?: string }>,\n\toptions: { deferContents: boolean; canRead: boolean },\n): string {\n\tif (contextFiles.length === 0) {\n\t\treturn \"\";\n\t}\n\tconst injected = options.deferContents ? [] : contextFiles.filter((file) => file.content !== undefined);\n\tconst deferred = options.deferContents ? contextFiles : contextFiles.filter((file) => file.content === undefined);\n\tconst parts: string[] = [];\n\n\tif (injected.length > 0) {\n\t\tconst lines = [\"\\n\\nPROJECT-SPECIFIC INSTRUCTIONS (apply in listed order)\"];\n\t\tconst seen = new Set<string>();\n\t\tfor (const { path, content } of injected) {\n\t\t\tconst identity = `${path}\\0${content ?? \"\"}`;\n\t\t\tif (seen.has(identity)) continue;\n\t\t\tseen.add(identity);\n\t\t\tlines.push(`FILE ${JSON.stringify(path)} (${(content ?? \"\").length} chars)`);\n\t\t\tlines.push(content ?? \"\");\n\t\t\tlines.push(\"END FILE\");\n\t\t}\n\t\tparts.push(lines.join(\"\\n\"));\n\t}\n\n\tif (deferred.length > 0) {\n\t\tconst lines = [\n\t\t\t\"\\n\\nPROJECT RULE PATHS — contents not preloaded.\",\n\t\t\toptions.deferContents\n\t\t\t\t? options.canRead\n\t\t\t\t\t? \"Before editing, writing, or running a mutating command, read each relevant listed file completely before any mutation. Follow its instructions; if a file cannot fit, ask for a scoped instruction digest.\"\n\t\t\t\t\t: \"No read tool is active. Ask the user for the relevant project instructions before giving project-specific guidance.\"\n\t\t\t\t: options.canRead\n\t\t\t\t\t? \"Read a listed file completely before following it. Do not assume its contents.\"\n\t\t\t\t\t: \"No read tool is active. Ask the user for the relevant project instructions before giving project-specific guidance.\",\n\t\t];\n\t\tlet pathChars = 0;\n\t\tlet included = 0;\n\t\tfor (const { path } of deferred) {\n\t\t\tconst line = `- ${JSON.stringify(path)}`;\n\t\t\tif (pathChars + line.length > DEFERRED_CONTEXT_PATH_BUDGET_CHARS) break;\n\t\t\tlines.push(line);\n\t\t\tpathChars += line.length + 1;\n\t\t\tincluded++;\n\t\t}\n\t\tconst omitted = deferred.length - included;\n\t\tif (omitted > 0) {\n\t\t\tlines.push(`- omitted=${omitted}`);\n\t\t\tlines.push(\n\t\t\t\t\"Do not mutate until the omitted instruction paths are supplied or a more capable profile is used.\",\n\t\t\t);\n\t\t}\n\t\tparts.push(lines.join(\"\\n\"));\n\t}\n\n\treturn parts.join(\"\");\n}\n\nfunction appendPromptResources(\n\tprompt: string,\n\toptions: {\n\t\tappendSection: string;\n\t\tcontextFiles: Array<{ path: string; content?: string }>;\n\t\textensions: Extension[];\n\t\tvisibleTools: string[];\n\t\tfullPrompt: boolean;\n\t\thasRead: boolean;\n\t\tdate: string;\n\t\tpromptCwd: string;\n\t\tmodelCapability: BuildSystemPromptOptions[\"modelCapability\"];\n\t},\n): string {\n\tlet result = prompt;\n\tif (options.appendSection) result += options.appendSection;\n\tresult += formatContextFilesForPrompt(options.contextFiles, {\n\t\tdeferContents: !options.fullPrompt,\n\t\tcanRead: options.hasRead,\n\t});\n\t// Extension metadata is redundant with the active tool snippets on constrained profiles.\n\tif (options.fullPrompt && options.extensions.length > 0) {\n\t\tresult += formatExtensionsForPrompt(options.extensions, options.visibleTools);\n\t}\n\t// Day-granularity only; keep this tail stable across every call on the same calendar day.\n\tresult += `\\nCurrent date: ${options.date}`;\n\tresult += `\\nCurrent working directory: ${options.promptCwd}`;\n\t// Prompt resources can come from CRLF checkouts or user files. Canonicalize once at the final\n\t// assembly boundary so capability budgets and provider cache keys are host-independent.\n\tconst normalizedResult = result.replace(/\\r\\n?/g, \"\\n\");\n\treturn options.modelCapability\n\t\t? enforceModelCapabilitySystemPromptBudget(normalizedResult, options.modelCapability)\n\t\t: normalizedResult;\n}\n\n/**\n * Build the system prompt with tools, guidelines, and context.\n *\n * CACHE-STABILITY INVARIANT: providers treat the returned string as ONE prompt-cache block (a\n * single cache breakpoint covering the whole system prompt). The caller (SystemPromptBuilder /\n * AgentSession, see `_rebuildSystemPrompt` in agent-session.ts) rebuilds it only when the TOOL\n * SURFACE changes — never per turn. For a fixed `options` (fixed tool surface, cwd, context\n * files, extensions), two calls on the SAME CALENDAR DAY must return byte-identical\n * output, because `date` below is deliberately truncated to Y-M-D granularity. Do NOT widen it\n * to a timestamp (HH:MM:SS) or otherwise fold in any per-turn-volatile field (turn counters,\n * elapsed time, random ids, etc.) — that would cache-bust this entire block on EVERY turn instead\n * of once per calendar day, defeating provider prompt caching (cost + latency regression on every\n * request). Pinned by test/system-prompt-stability.test.ts.\n */\nexport function buildSystemPrompt(options: BuildSystemPromptOptions): string {\n\tconst {\n\t\tcustomPrompt,\n\t\tselectedTools,\n\t\ttoolSnippets,\n\t\tpromptGuidelines,\n\t\tappendSystemPrompt,\n\t\tcwd,\n\t\tcontextFiles: providedContextFiles,\n\t} = options;\n\tconst resolvedCwd = cwd;\n\tconst promptCwd = resolvedCwd.replace(/\\\\/g, \"/\");\n\n\t// Day-granularity only (see cache-stability invariant on buildSystemPrompt above): this must\n\t// stay stable across every call within a calendar day, not just within a single turn.\n\tconst now = new Date();\n\tconst year = now.getFullYear();\n\tconst month = String(now.getMonth() + 1).padStart(2, \"0\");\n\tconst day = String(now.getDate()).padStart(2, \"0\");\n\tconst date = `${year}-${month}-${day}`;\n\n\tconst appendSection = appendSystemPrompt ? `\\n\\n${appendSystemPrompt}` : \"\";\n\n\tconst contextFiles = providedContextFiles ?? [];\n\tconst capabilityClass = options.modelCapability?.class ?? \"full\";\n\tconst fullPrompt = capabilityClass === \"full\";\n\tconst leanPrompt = capabilityClass === \"lean\";\n\n\tconst activeTools = selectedTools || [\"read\", \"bash\", \"python\", \"edit\", \"write\"];\n\tconst visibleTools = activeTools.filter((name) => !!toolSnippets?.[name]);\n\tconst hasRead = activeTools.includes(\"read\");\n\tconst coreSection = fullPrompt\n\t\t? PI_ADAPTATIVE_CORE_SECTION\n\t\t: leanPrompt\n\t\t\t? PI_ADAPTATIVE_LEAN_CORE_SECTION\n\t\t\t: capabilityClass === \"minimal\"\n\t\t\t\t? PI_ADAPTATIVE_MINIMAL_CORE_SECTION\n\t\t\t\t: PI_ADAPTATIVE_CHAT_CORE_SECTION;\n\tconst skillVaultContract = activeTools.includes(\"skill\") ? `\\n\\n${SKILL_VAULT_SYSTEM_RULE}` : \"\";\n\tconst operatingContract = `${coreSection}${skillVaultContract}${ULTRA_TERSE_OUTPUT_POLICY}`;\n\n\tif (customPrompt) {\n\t\tlet prompt = customPrompt;\n\n\t\tprompt += operatingContract;\n\t\treturn appendPromptResources(prompt, {\n\t\t\tappendSection,\n\t\t\tcontextFiles,\n\t\t\textensions: options.extensions ?? [],\n\t\t\tvisibleTools,\n\t\t\tfullPrompt,\n\t\t\thasRead,\n\t\t\tdate,\n\t\t\tpromptCwd,\n\t\t\tmodelCapability: options.modelCapability,\n\t\t});\n\t}\n\n\tconst packageRoot = dirname(getReadmePath());\n\n\t// Build tools list based on selected tools.\n\t// A tool appears in Available tools only when the caller provides a one-line snippet.\n\tconst toolsList =\n\t\tvisibleTools.length > 0 ? visibleTools.map((name) => `- ${name}: ${toolSnippets![name]}`).join(\"\\n\") : \"(none)\";\n\n\t// Build guidelines based on which tools are actually available\n\tconst guidelinesList: string[] = [];\n\tconst guidelinesSet = new Set<string>();\n\tconst addGuideline = (guideline: string): void => {\n\t\tif (guidelinesSet.has(guideline)) {\n\t\t\treturn;\n\t\t}\n\t\tguidelinesSet.add(guideline);\n\t\tguidelinesList.push(guideline);\n\t};\n\n\tconst hasBash = activeTools.includes(\"bash\");\n\tconst hasPython = activeTools.includes(\"python\");\n\tconst hasGrep = activeTools.includes(\"grep\");\n\tconst hasFind = activeTools.includes(\"find\");\n\tconst hasLs = activeTools.includes(\"ls\");\n\tconst hasReadOnlyTools = hasRead || hasGrep || hasFind || hasLs;\n\n\t// File exploration guidelines\n\tif (!fullPrompt && !leanPrompt) {\n\t\tif (hasBash) addGuideline(\"Use bash for bounded shell commands\");\n\t\tif (hasReadOnlyTools) addGuideline(\"Batch independent reads; keep mutations and dependent calls ordered\");\n\t} else if (hasBash && !hasGrep && !hasFind && !hasLs) {\n\t\taddGuideline(\"Bash: ls, rg, find\");\n\t}\n\tif (fullPrompt || leanPrompt) {\n\t\tif (hasBash || hasGrep || hasFind) {\n\t\t\taddGuideline(\"rg/jq: scoped roots/filters, exhaustive output to file\");\n\t\t}\n\t\tif (hasPython) {\n\t\t\taddGuideline(\"Python: bounded scripts/data, source edits via read/edit/write\");\n\t\t}\n\t\tif (hasReadOnlyTools) {\n\t\t\taddGuideline(\"Batch independent reads; order dependent/mutating/stateful calls\");\n\t\t}\n\t}\n\n\tif (fullPrompt || leanPrompt) {\n\t\tfor (const guideline of promptGuidelines ?? []) {\n\t\t\tconst normalized = guideline.trim();\n\t\t\tif (normalized.length > 0) {\n\t\t\t\taddGuideline(normalized);\n\t\t\t}\n\t\t}\n\t}\n\n\tconst guidelines = guidelinesList.map((g) => `- ${g}`).join(\"\\n\");\n\tconst toolGuidelinesSection = guidelines.length > 0 ? `\\n\\nTOOL GUIDELINES\\n\\n${guidelines}` : \"\";\n\n\tconst introduction = fullPrompt\n\t\t? \"Pi-Adaptative: self-evolving assistant. Deliver goals within authority; preserve continuity, own integration.\"\n\t\t: leanPrompt\n\t\t\t? \"Pi-Adaptative bounded coding agent. Complete current goal with active surface; preserve handoff evidence.\"\n\t\t\t: capabilityClass === \"minimal\"\n\t\t\t\t? \"Pi-Adaptative focused coding executor. Complete one scoped task with active tools; report verified results.\"\n\t\t\t\t: \"Pi-Adaptative concise chat assistant. No execution tools active.\";\n\tconst toolSurfaceRule =\n\t\tfullPrompt || leanPrompt\n\t\t\t? \"Use active tool surface only; unlisted capabilities may exist.\"\n\t\t\t: \"Use only the active tool surface.\";\n\tlet prompt = `${introduction}\n\nAvailable tools:\n${toolsList}\n\n${toolSurfaceRule}${operatingContract}${toolGuidelinesSection}`;\n\n\tif (fullPrompt) {\n\t\tprompt += `\n\nPI DOCS: root=${packageRoot}. Relevant work only; read needed README.md, \\`docs/...\\`, \\`examples/...\\` fully, follow links.`;\n\t}\n\n\treturn appendPromptResources(prompt, {\n\t\tappendSection,\n\t\tcontextFiles,\n\t\textensions: options.extensions ?? [],\n\t\tvisibleTools,\n\t\tfullPrompt,\n\t\thasRead,\n\t\tdate,\n\t\tpromptCwd,\n\t\tmodelCapability: options.modelCapability,\n\t});\n}\n\nfunction formatExtensionsForPrompt(extensions: Extension[], visibleTools: string[]): string {\n\tif (extensions.length === 0) {\n\t\treturn \"\";\n\t}\n\n\tconst lines = [\"\\n\\nEXTENSIONS: name, path, tools, commands, description\"];\n\tlet added = 0;\n\n\tfor (const ext of extensions) {\n\t\tconst name = getExtensionDisplayName(ext.path);\n\t\tconst description = getExtensionDescription(ext.path);\n\n\t\tconst tools = Array.from(ext.tools.keys()).filter((t) => visibleTools.includes(t));\n\t\tconst commands = Array.from(ext.commands.keys());\n\n\t\t// Skip extension listing if it has no visible tools, commands, or description\n\t\tif (tools.length === 0 && commands.length === 0 && !description) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tlines.push(\n\t\t\tJSON.stringify({\n\t\t\t\tname,\n\t\t\t\tpath: ext.path,\n\t\t\t\t...(tools.length > 0 ? { tools } : {}),\n\t\t\t\t...(commands.length > 0 ? { commands } : {}),\n\t\t\t\t...(description ? { description: compactPromptText(description, EXTENSION_DESCRIPTION_BUDGET_CHARS) } : {}),\n\t\t\t}),\n\t\t);\n\t\tadded++;\n\t}\n\n\tif (added === 0) {\n\t\treturn \"\";\n\t}\n\n\treturn lines.join(\"\\n\");\n}\n"]}
@@ -41,7 +41,8 @@ export interface BashOperations {
41
41
  * @param command The command to execute
42
42
  * @param cwd Working directory
43
43
  * @param options Execution options
44
- * @returns Promise resolving to exit code (null if killed)
44
+ * @returns Promise resolving to exit code (null if killed) plus, when the backend tracks it,
45
+ * the shell-reported working directory after the command ran
45
46
  */
46
47
  exec: (command: string, cwd: string, options: {
47
48
  onData: (data: Buffer) => void;
@@ -50,6 +51,7 @@ export interface BashOperations {
50
51
  env?: NodeJS.ProcessEnv;
51
52
  }) => Promise<{
52
53
  exitCode: number | null;
54
+ cwd?: string;
53
55
  }>;
54
56
  }
55
57
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"bash.d.ts","sourceRoot":"","sources":["../../../src/core/tools/bash.ts"],"names":[],"mappings":"AAIA,OAAO,EAIN,KAAK,gBAAgB,EACrB,MAAM,oCAAoC,CAAC;AAC5C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iCAAiC,CAAC;AAIjE,OAAO,EAAE,KAAK,MAAM,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAc5C,OAAO,KAAK,EAAE,cAAc,EAA2B,MAAM,wBAAwB,CAAC;AACtF,OAAO,EACN,KAAK,4BAA4B,EAIjC,MAAM,4BAA4B,CAAC;AAYpC,OAAO,EAGN,KAAK,4BAA4B,EACjC,MAAM,8BAA8B,CAAC;AAGtC,OAAO,EAAsC,KAAK,yBAAyB,EAAE,MAAM,2BAA2B,CAAC;AAK/G,qGAAqG;AACrG,eAAO,MAAM,+BAA+B,MAAM,CAAC;AACnD,eAAO,MAAM,2BAA2B,OAAO,CAAC;AAKhD,kGAAkG;AAClG,wBAAgB,2BAA2B,CAAC,EAAE,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,CAExE;AAED,mGAAmG;AACnG,wBAAgB,2BAA2B,CAAC,EAAE,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,CAExE;AAED,wBAAgB,4BAA4B,CAAC,OAAO,EAAE,MAAM,GAAG,S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AE,eAAe,GAAG,SAAS,CAAC,OAAO,UAAU,CAAC,CAEnG"}
@@ -423,8 +423,8 @@ function createShellToolDefinition(cwd, backendShell, contractPlatform, options)
423
423
  });
424
424
  }
425
425
  const contractDescription = routesWindowsContract
426
- ? "Execute Pi's stable Bash-like command contract in a persistent per-agent shell session (current directory and environment variables persist across calls, including across the PowerShell and Python engine tiers). On Windows, a deterministic router converts simple commands directly to PowerShell and routes word-list and arithmetic for loops, break/continue, portable builtins such as printf, pipelines, redirection, expansion, chaining, and state-mutating commands (cd/export/unset) through a bundled Python engine that implements the supported Bash grammar; named unsupported constructs (job control, process substitution, heredocs, nested shells, and similar) fail closed instead of being guessed."
427
- : "Execute a Bash command in a persistent per-agent shell session: the current directory and environment variables persist across calls, and a timed-out or aborted command resets the session.";
426
+ ? "Execute Pi's stable Bash-like command contract in a persistent per-agent shell session (starts at the project working directory; current directory and environment variables persist across calls, including across the PowerShell and Python engine tiers; a failed command reports its effective cwd on a final `cwd:` line). On Windows, a deterministic router converts simple commands directly to PowerShell and routes word-list and arithmetic for loops, break/continue, portable builtins such as printf, pipelines, redirection, expansion, chaining, and state-mutating commands (cd/export/unset) through a bundled Python engine that implements the supported Bash grammar; named unsupported constructs (job control, process substitution, heredocs, nested shells, and similar) fail closed instead of being guessed."
427
+ : "Execute a Bash command in a persistent per-agent shell session that starts at the project working directory: `cd` and environment variables persist across calls, a failed command reports its effective cwd on a final `cwd:` line, and a timed-out or aborted command resets the session.";
428
428
  return {
429
429
  name: toolName,
430
430
  label: toolName,
@@ -435,11 +435,10 @@ function createShellToolDefinition(cwd, backendShell, contractPlatform, options)
435
435
  promptGuidelines: routesWindowsContract
436
436
  ? [
437
437
  "On Windows, use Bash-like commands; never write PowerShell/ask owner to choose shell.",
438
- "Supports for, break/continue, printf, pipes/redirection, variable/command/glob expansion, chaining, cd/export/unset.",
439
- "Arithmetic outside for, job control, process substitution, heredocs, nested shells fail closed.",
438
+ "Supports for, break/continue, printf, pipes/redirection, expansions, chaining; unhandled syntax fails closed.",
440
439
  "cd/export/unset state persists across bash calls and PowerShell/Python tiers.",
441
440
  "File commands use literal paths; verify targets before recursive rm/cp/mv.",
442
- `Bash timeout values are seconds, not milliseconds; omit timeout to use the ${DEFAULT_COMMAND_TIMEOUT_SECONDS}s default.`,
441
+ `Bash timeout values are seconds; omit to use the ${DEFAULT_COMMAND_TIMEOUT_SECONDS}s default.`,
443
442
  `Search narrowly: root/filters, prefer grep/find. Broad scans fail; unavoidable scan: broadSearch="${BROAD_SEARCH_OUTPUT_ROUTE}", then inspect narrowly.`,
444
443
  ]
445
444
  : [
@@ -675,7 +674,8 @@ function createShellToolDefinition(cwd, backendShell, contractPlatform, options)
675
674
  const snapshot = await finishOutput();
676
675
  if (res.exitCode !== 0) {
677
676
  const { text: rawOutputText } = formatOutput(snapshot);
678
- throw new Error(appendStatus(rawOutputText, `Command exited with code ${res.exitCode}`));
677
+ // executeFilteredGit runs at the host cwd by construction.
678
+ throw new Error(appendStatus(rawOutputText, `Command exited with code ${res.exitCode}\ncwd: ${cwd}`));
679
679
  }
680
680
  const details = snapshot.truncation.truncated
681
681
  ? {
@@ -717,6 +717,7 @@ function createShellToolDefinition(cwd, backendShell, contractPlatform, options)
717
717
  spawnContext.env = mergeEffectiveEnv(getOrCreateWindowsShellState(sessionKey), spawnContext.env);
718
718
  }
719
719
  let exitCode;
720
+ let sessionCwd;
720
721
  try {
721
722
  // Shell commands cannot statically declare which files they mutate, so the
722
723
  // actual execution takes the coarse exclusive barrier: it waits for
@@ -728,6 +729,7 @@ function createShellToolDefinition(cwd, backendShell, contractPlatform, options)
728
729
  env: spawnContext.env,
729
730
  }));
730
731
  exitCode = result.exitCode;
732
+ sessionCwd = result.cwd;
731
733
  }
732
734
  catch (err) {
733
735
  const snapshot = await finishOutput();
@@ -765,7 +767,13 @@ function createShellToolDefinition(cwd, backendShell, contractPlatform, options)
765
767
  details,
766
768
  };
767
769
  }
768
- throw new Error(appendStatus(outputText, `Command exited with code ${exitCode}`));
770
+ // The true directory the command ran in: the session-reported $PWD on POSIX,
771
+ // the state-tracked effective cwd on the Windows contract (the runner protocol
772
+ // does not report one), or the host-requested cwd for per-command backends.
773
+ const reportedCwd = routesWindowsContract
774
+ ? resolveEffectiveCwd(getOrCreateWindowsShellState(sessionKey), cwd)
775
+ : (sessionCwd ?? spawnContext.cwd);
776
+ throw new Error(appendStatus(outputText, `Command exited with code ${exitCode}\ncwd: ${reportedCwd}`));
769
777
  }
770
778
  return { content: [{ type: "text", text: outputText }], details };
771
779
  }