@leanandmean/coding-agent 0.74.1-scramjet.19 → 0.74.1-scramjet.20
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.
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +2 -0
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/system-prompt.d.ts +2 -0
- package/dist/core/system-prompt.d.ts.map +1 -1
- package/dist/core/system-prompt.js +5 -2
- package/dist/core/system-prompt.js.map +1 -1
- package/docs/extensions.md +3 -2
- package/docs/sdk.md +1 -1
- package/package.json +65 -65
|
@@ -23,6 +23,8 @@ export interface BuildSystemPromptOptions {
|
|
|
23
23
|
}>;
|
|
24
24
|
/** Pre-loaded skills. */
|
|
25
25
|
skills?: Skill[];
|
|
26
|
+
/** Current session file path, omitted when sessions are disabled. */
|
|
27
|
+
sessionFile?: string;
|
|
26
28
|
}
|
|
27
29
|
/**
|
|
28
30
|
* Build the system prompt as ordered sections.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"system-prompt.d.ts","sourceRoot":"","sources":["../../src/core/system-prompt.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAuB,KAAK,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAEhF,OAAO,EAAyB,KAAK,KAAK,EAAE,MAAM,aAAa,CAAC;AAEhE,MAAM,WAAW,wBAAwB;IACxC,+CAA+C;IAC/C,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,qEAAqE;IACrE,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;IACzB,0DAA0D;IAC1D,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACtC,qFAAqF;IACrF,gBAAgB,CAAC,EAAE,MAAM,EAAE,CAAC;IAC5B,uCAAuC;IACvC,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,yBAAyB;IACzB,GAAG,EAAE,MAAM,CAAC;IACZ,gCAAgC;IAChC,YAAY,CAAC,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACxD,yBAAyB;IACzB,MAAM,CAAC,EAAE,KAAK,EAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"system-prompt.d.ts","sourceRoot":"","sources":["../../src/core/system-prompt.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAuB,KAAK,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAEhF,OAAO,EAAyB,KAAK,KAAK,EAAE,MAAM,aAAa,CAAC;AAEhE,MAAM,WAAW,wBAAwB;IACxC,+CAA+C;IAC/C,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,qEAAqE;IACrE,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;IACzB,0DAA0D;IAC1D,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACtC,qFAAqF;IACrF,gBAAgB,CAAC,EAAE,MAAM,EAAE,CAAC;IAC5B,uCAAuC;IACvC,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,yBAAyB;IACzB,GAAG,EAAE,MAAM,CAAC;IACZ,gCAAgC;IAChC,YAAY,CAAC,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACxD,yBAAyB;IACzB,MAAM,CAAC,EAAE,KAAK,EAAE,CAAC;IAEjB,qEAAqE;IACrE,WAAW,CAAC,EAAE,MAAM,CAAC;CACrB;AAED;;;;;;;GAOG;AACH,wBAAgB,yBAAyB,CAAC,OAAO,EAAE,wBAAwB,GAAG,mBAAmB,EAAE,CAyDlG;AAED,kEAAkE;AAClE,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,wBAAwB,GAAG,MAAM,CAE3E","sourcesContent":["/**\n * System prompt construction and project context loading\n */\n\nimport { flattenSystemPrompt, type SystemPromptSection } from \"@leanandmean/ai\";\nimport { getDocsPath, getExamplesPath, getReadmePath } from \"../config.js\";\nimport { formatSkillsForPrompt, type Skill } from \"./skills.js\";\n\nexport interface BuildSystemPromptOptions {\n\t/** Custom system prompt (replaces default). */\n\tcustomPrompt?: string;\n\t/** Tools to include in prompt. Default: [read, bash, edit, write] */\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/** Pre-loaded context files. */\n\tcontextFiles?: Array<{ path: string; content: string }>;\n\t/** Pre-loaded skills. */\n\tskills?: Skill[];\n\t// SCRAMJET-DIVERGENCE: expose session file path as volatile environment fact (issue 348)\n\t/** Current session file path, omitted when sessions are disabled. */\n\tsessionFile?: string;\n}\n\n/**\n * Build the system prompt as ordered sections.\n *\n * Each section's `text` carries its own leading separator, so flattening the\n * sections with an empty-string join reproduces the single-string prompt\n * byte-for-byte. The volatile date/cwd tail is the last section and is marked\n * `cacheRetention: \"none\"` so providers can exclude it from cached prefixes.\n */\nexport function buildSystemPromptSections(options: BuildSystemPromptOptions): SystemPromptSection[] {\n\tconst {\n\t\tcustomPrompt,\n\t\tselectedTools,\n\t\tappendSystemPrompt,\n\t\tcwd,\n\t\tcontextFiles: providedContextFiles,\n\t\tskills: providedSkills,\n\t} = options;\n\tconst promptCwd = cwd.replace(/\\\\/g, \"/\");\n\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 sections: SystemPromptSection[] = [];\n\n\tsections.push({ id: \"core\", text: customPrompt || buildDefaultCorePrompt(options) });\n\n\tif (appendSystemPrompt) {\n\t\tsections.push({ id: \"append\", text: `\\n\\n${appendSystemPrompt}` });\n\t}\n\n\tconst contextFiles = providedContextFiles ?? [];\n\tif (contextFiles.length > 0) {\n\t\tlet text = \"\\n\\n# Project Context\\n\\n\";\n\t\ttext += \"Project-specific instructions and guidelines:\\n\\n\";\n\t\tfor (const { path: filePath, content } of contextFiles) {\n\t\t\ttext += `## ${filePath}\\n\\n${content}\\n\\n`;\n\t\t}\n\t\tsections.push({ id: \"context-files\", text });\n\t}\n\n\t// Skills section (only if read tool is available)\n\tconst skills = providedSkills ?? [];\n\tconst hasRead = !selectedTools || selectedTools.includes(\"read\");\n\tif (hasRead && skills.length > 0) {\n\t\tconst text = formatSkillsForPrompt(skills);\n\t\tif (text) {\n\t\t\tsections.push({ id: \"skills\", text });\n\t\t}\n\t}\n\n\t// SCRAMJET-DIVERGENCE: include session journal path alongside date/cwd (issue 348)\n\tconst sessionJournalLine = options.sessionFile\n\t\t? `\\nCurrent session journal: ${options.sessionFile.replace(/\\\\/g, \"/\")}`\n\t\t: \"\";\n\n\tsections.push({\n\t\tid: \"volatile\",\n\t\ttext: `\\nCurrent date: ${date}\\nCurrent working directory: ${promptCwd}${sessionJournalLine}`,\n\t\tcacheRetention: \"none\",\n\t});\n\n\treturn sections;\n}\n\n/** Build the system prompt with tools, guidelines, and context */\nexport function buildSystemPrompt(options: BuildSystemPromptOptions): string {\n\treturn flattenSystemPrompt(buildSystemPromptSections(options));\n}\n\n// SCRAMJET-DIVERGENCE: rebrand product identity in system prompt (Pi -> Scramjet)\n/** Build the default core prompt: identity, tools list, guidelines, doc paths. */\nfunction buildDefaultCorePrompt(options: BuildSystemPromptOptions): string {\n\tconst { selectedTools, toolSnippets, promptGuidelines } = options;\n\n\t// Get absolute paths to documentation and examples\n\tconst readmePath = getReadmePath();\n\tconst docsPath = getDocsPath();\n\tconst examplesPath = getExamplesPath();\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 tools = selectedTools || [\"read\", \"bash\", \"edit\", \"write\"];\n\tconst visibleTools = tools.filter((name) => !!toolSnippets?.[name]);\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 = tools.includes(\"bash\");\n\tconst hasGrep = tools.includes(\"grep\");\n\tconst hasFind = tools.includes(\"find\");\n\tconst hasLs = tools.includes(\"ls\");\n\n\t// File exploration guidelines\n\tif (hasBash && !hasGrep && !hasFind && !hasLs) {\n\t\taddGuideline(\"Use bash for file operations like ls, rg, find\");\n\t} else if (hasBash && (hasGrep || hasFind || hasLs)) {\n\t\taddGuideline(\"Prefer grep/find/ls tools over bash for file exploration (faster, respects .gitignore)\");\n\t}\n\n\tfor (const guideline of promptGuidelines ?? []) {\n\t\tconst normalized = guideline.trim();\n\t\tif (normalized.length > 0) {\n\t\t\taddGuideline(normalized);\n\t\t}\n\t}\n\n\t// Always include these\n\taddGuideline(\"Be concise in your responses\");\n\taddGuideline(\"Show file paths clearly when working with files\");\n\n\tconst guidelines = guidelinesList.map((g) => `- ${g}`).join(\"\\n\");\n\n\treturn `You are an expert coding assistant operating inside scramjet, a coding agent harness. You help users by reading files, executing commands, editing code, and writing new files.\n\nAvailable tools:\n${toolsList}\n\nIn addition to the tools above, you may have access to other custom tools depending on the project.\n\nGuidelines:\n${guidelines}\n\nScramjet documentation (read only when the user asks about scramjet itself, its SDK, extensions, themes, skills, or TUI):\n- Main documentation: ${readmePath}\n- Additional docs: ${docsPath}\n- Examples: ${examplesPath} (extensions, custom tools, SDK)\n- When asked about: extensions (docs/extensions.md, examples/extensions/), themes (docs/themes.md), skills (docs/skills.md), prompt templates (docs/prompt-templates.md), TUI components (docs/tui.md), keybindings (docs/keybindings.md), SDK integrations (docs/sdk.md), custom providers (docs/custom-provider.md), adding models (docs/models.md), scramjet packages (docs/packages.md)\n- When working on scramjet topics, read the docs and examples, and follow .md cross-references before implementing\n- Always read scramjet .md files completely and follow links to related docs (e.g., tui.md for TUI API details)`;\n}\n"]}
|
|
@@ -43,10 +43,13 @@ export function buildSystemPromptSections(options) {
|
|
|
43
43
|
sections.push({ id: "skills", text });
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
|
-
//
|
|
46
|
+
// SCRAMJET-DIVERGENCE: include session journal path alongside date/cwd (issue 348)
|
|
47
|
+
const sessionJournalLine = options.sessionFile
|
|
48
|
+
? `\nCurrent session journal: ${options.sessionFile.replace(/\\/g, "/")}`
|
|
49
|
+
: "";
|
|
47
50
|
sections.push({
|
|
48
51
|
id: "volatile",
|
|
49
|
-
text: `\nCurrent date: ${date}\nCurrent working directory: ${promptCwd}`,
|
|
52
|
+
text: `\nCurrent date: ${date}\nCurrent working directory: ${promptCwd}${sessionJournalLine}`,
|
|
50
53
|
cacheRetention: "none",
|
|
51
54
|
});
|
|
52
55
|
return sections;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"system-prompt.js","sourceRoot":"","sources":["../../src/core/system-prompt.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,mBAAmB,EAA4B,MAAM,iBAAiB,CAAC;AAChF,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC3E,OAAO,EAAE,qBAAqB,EAAc,MAAM,aAAa,CAAC;AAqBhE;;;;;;;GAOG;AACH,MAAM,UAAU,yBAAyB,CAAC,OAAiC,EAAyB;IACnG,MAAM,EACL,YAAY,EACZ,aAAa,EACb,kBAAkB,EAClB,GAAG,EACH,YAAY,EAAE,oBAAoB,EAClC,MAA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,CAAC,wFAAwF,CAAC,CAAC;IACxG,CAAC;IAED,KAAK,MAAM,SAAS,IAAI,gBAAgB,IAAI,EAAE,EAAE,CAAC;QAChD,MAAM,UAAU,GAAG,SAAS,CAAC,IAAI,EAAE,CAAC;QACpC,IAAI,UAAU,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAC3B,YAAY,CAAC,UAAU,CAAC,CAAC;QAC1B,CAAC;IACF,CAAC;IAED,uBAAuB;IACvB,YAAY,CAAC,8BAA8B,CAAC,CAAC;IAC7C,YAAY,CAAC,iDAAiD,CAAC,CAAC;IAEhE,MAAM,UAAU,GAAG,cAAc,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAElE,OAAO;;;EAGN,SAAS;;;;;EAKT,UAAU;;;wBAGY,UAAU;qBACb,QAAQ;cACf,YAAY;;;gHAGsF,CAAC;AAAA,CAChH","sourcesContent":["/**\n * System prompt construction and project context loading\n */\n\nimport { flattenSystemPrompt, type SystemPromptSection } from \"@leanandmean/ai\";\nimport { getDocsPath, getExamplesPath, getReadmePath } from \"../config.js\";\nimport { formatSkillsForPrompt, type Skill } from \"./skills.js\";\n\nexport interface BuildSystemPromptOptions {\n\t/** Custom system prompt (replaces default). */\n\tcustomPrompt?: string;\n\t/** Tools to include in prompt. Default: [read, bash, edit, write] */\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/** Pre-loaded context files. */\n\tcontextFiles?: Array<{ path: string; content: string }>;\n\t/** Pre-loaded skills. */\n\tskills?: Skill[];\n}\n\n/**\n * Build the system prompt as ordered sections.\n *\n * Each section's `text` carries its own leading separator, so flattening the\n * sections with an empty-string join reproduces the single-string prompt\n * byte-for-byte. The volatile date/cwd tail is the last section and is marked\n * `cacheRetention: \"none\"` so providers can exclude it from cached prefixes.\n */\nexport function buildSystemPromptSections(options: BuildSystemPromptOptions): SystemPromptSection[] {\n\tconst {\n\t\tcustomPrompt,\n\t\tselectedTools,\n\t\tappendSystemPrompt,\n\t\tcwd,\n\t\tcontextFiles: providedContextFiles,\n\t\tskills: providedSkills,\n\t} = options;\n\tconst promptCwd = cwd.replace(/\\\\/g, \"/\");\n\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 sections: SystemPromptSection[] = [];\n\n\tsections.push({ id: \"core\", text: customPrompt || buildDefaultCorePrompt(options) });\n\n\tif (appendSystemPrompt) {\n\t\tsections.push({ id: \"append\", text: `\\n\\n${appendSystemPrompt}` });\n\t}\n\n\tconst contextFiles = providedContextFiles ?? [];\n\tif (contextFiles.length > 0) {\n\t\tlet text = \"\\n\\n# Project Context\\n\\n\";\n\t\ttext += \"Project-specific instructions and guidelines:\\n\\n\";\n\t\tfor (const { path: filePath, content } of contextFiles) {\n\t\t\ttext += `## ${filePath}\\n\\n${content}\\n\\n`;\n\t\t}\n\t\tsections.push({ id: \"context-files\", text });\n\t}\n\n\t// Skills section (only if read tool is available)\n\tconst skills = providedSkills ?? [];\n\tconst hasRead = !selectedTools || selectedTools.includes(\"read\");\n\tif (hasRead && skills.length > 0) {\n\t\tconst text = formatSkillsForPrompt(skills);\n\t\tif (text) {\n\t\t\tsections.push({ id: \"skills\", text });\n\t\t}\n\t}\n\n\t// Date and working directory last, excluded from cached prefixes\n\tsections.push({\n\t\tid: \"volatile\",\n\t\ttext: `\\nCurrent date: ${date}\\nCurrent working directory: ${promptCwd}`,\n\t\tcacheRetention: \"none\",\n\t});\n\n\treturn sections;\n}\n\n/** Build the system prompt with tools, guidelines, and context */\nexport function buildSystemPrompt(options: BuildSystemPromptOptions): string {\n\treturn flattenSystemPrompt(buildSystemPromptSections(options));\n}\n\n// SCRAMJET-DIVERGENCE: rebrand product identity in system prompt (Pi -> Scramjet)\n/** Build the default core prompt: identity, tools list, guidelines, doc paths. */\nfunction buildDefaultCorePrompt(options: BuildSystemPromptOptions): string {\n\tconst { selectedTools, toolSnippets, promptGuidelines } = options;\n\n\t// Get absolute paths to documentation and examples\n\tconst readmePath = getReadmePath();\n\tconst docsPath = getDocsPath();\n\tconst examplesPath = getExamplesPath();\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 tools = selectedTools || [\"read\", \"bash\", \"edit\", \"write\"];\n\tconst visibleTools = tools.filter((name) => !!toolSnippets?.[name]);\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 = tools.includes(\"bash\");\n\tconst hasGrep = tools.includes(\"grep\");\n\tconst hasFind = tools.includes(\"find\");\n\tconst hasLs = tools.includes(\"ls\");\n\n\t// File exploration guidelines\n\tif (hasBash && !hasGrep && !hasFind && !hasLs) {\n\t\taddGuideline(\"Use bash for file operations like ls, rg, find\");\n\t} else if (hasBash && (hasGrep || hasFind || hasLs)) {\n\t\taddGuideline(\"Prefer grep/find/ls tools over bash for file exploration (faster, respects .gitignore)\");\n\t}\n\n\tfor (const guideline of promptGuidelines ?? []) {\n\t\tconst normalized = guideline.trim();\n\t\tif (normalized.length > 0) {\n\t\t\taddGuideline(normalized);\n\t\t}\n\t}\n\n\t// Always include these\n\taddGuideline(\"Be concise in your responses\");\n\taddGuideline(\"Show file paths clearly when working with files\");\n\n\tconst guidelines = guidelinesList.map((g) => `- ${g}`).join(\"\\n\");\n\n\treturn `You are an expert coding assistant operating inside scramjet, a coding agent harness. You help users by reading files, executing commands, editing code, and writing new files.\n\nAvailable tools:\n${toolsList}\n\nIn addition to the tools above, you may have access to other custom tools depending on the project.\n\nGuidelines:\n${guidelines}\n\nScramjet documentation (read only when the user asks about scramjet itself, its SDK, extensions, themes, skills, or TUI):\n- Main documentation: ${readmePath}\n- Additional docs: ${docsPath}\n- Examples: ${examplesPath} (extensions, custom tools, SDK)\n- When asked about: extensions (docs/extensions.md, examples/extensions/), themes (docs/themes.md), skills (docs/skills.md), prompt templates (docs/prompt-templates.md), TUI components (docs/tui.md), keybindings (docs/keybindings.md), SDK integrations (docs/sdk.md), custom providers (docs/custom-provider.md), adding models (docs/models.md), scramjet packages (docs/packages.md)\n- When working on scramjet topics, read the docs and examples, and follow .md cross-references before implementing\n- Always read scramjet .md files completely and follow links to related docs (e.g., tui.md for TUI API details)`;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"system-prompt.js","sourceRoot":"","sources":["../../src/core/system-prompt.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,mBAAmB,EAA4B,MAAM,iBAAiB,CAAC;AAChF,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC3E,OAAO,EAAE,qBAAqB,EAAc,MAAM,aAAa,CAAC;AAwBhE;;;;;;;GAOG;AACH,MAAM,UAAU,yBAAyB,CAAC,OAAiC,EAAyB;IACnG,MAAM,EACL,YAAY,EACZ,aAAa,EACb,kBAAkB,EAClB,GAAG,EACH,YAAY,EAAE,oBAAoB,EAClC,MAAM,EAAE,cAAc,GACtB,GAAG,OAAO,CAAC;IACZ,MAAM,SAAS,GAAG,GAAG,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC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AO,IAAI,CAAC,OAAO,IAAI,OAAO,IAAI,KAAK,CAAC,EAAE,CAAC;QACrD,YAAY,CAAC,wFAAwF,CAAC,CAAC;IACxG,CAAC;IAED,KAAK,MAAM,SAAS,IAAI,gBAAgB,IAAI,EAAE,EAAE,CAAC;QAChD,MAAM,UAAU,GAAG,SAAS,CAAC,IAAI,EAAE,CAAC;QACpC,IAAI,UAAU,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAC3B,YAAY,CAAC,UAAU,CAAC,CAAC;QAC1B,CAAC;IACF,CAAC;IAED,uBAAuB;IACvB,YAAY,CAAC,8BAA8B,CAAC,CAAC;IAC7C,YAAY,CAAC,iDAAiD,CAAC,CAAC;IAEhE,MAAM,UAAU,GAAG,cAAc,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAElE,OAAO;;;EAGN,SAAS;;;;;EAKT,UAAU;;;wBAGY,UAAU;qBACb,QAAQ;cACf,YAAY;;;gHAGsF,CAAC;AAAA,CAChH","sourcesContent":["/**\n * System prompt construction and project context loading\n */\n\nimport { flattenSystemPrompt, type SystemPromptSection } from \"@leanandmean/ai\";\nimport { getDocsPath, getExamplesPath, getReadmePath } from \"../config.js\";\nimport { formatSkillsForPrompt, type Skill } from \"./skills.js\";\n\nexport interface BuildSystemPromptOptions {\n\t/** Custom system prompt (replaces default). */\n\tcustomPrompt?: string;\n\t/** Tools to include in prompt. Default: [read, bash, edit, write] */\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/** Pre-loaded context files. */\n\tcontextFiles?: Array<{ path: string; content: string }>;\n\t/** Pre-loaded skills. */\n\tskills?: Skill[];\n\t// SCRAMJET-DIVERGENCE: expose session file path as volatile environment fact (issue 348)\n\t/** Current session file path, omitted when sessions are disabled. */\n\tsessionFile?: string;\n}\n\n/**\n * Build the system prompt as ordered sections.\n *\n * Each section's `text` carries its own leading separator, so flattening the\n * sections with an empty-string join reproduces the single-string prompt\n * byte-for-byte. The volatile date/cwd tail is the last section and is marked\n * `cacheRetention: \"none\"` so providers can exclude it from cached prefixes.\n */\nexport function buildSystemPromptSections(options: BuildSystemPromptOptions): SystemPromptSection[] {\n\tconst {\n\t\tcustomPrompt,\n\t\tselectedTools,\n\t\tappendSystemPrompt,\n\t\tcwd,\n\t\tcontextFiles: providedContextFiles,\n\t\tskills: providedSkills,\n\t} = options;\n\tconst promptCwd = cwd.replace(/\\\\/g, \"/\");\n\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 sections: SystemPromptSection[] = [];\n\n\tsections.push({ id: \"core\", text: customPrompt || buildDefaultCorePrompt(options) });\n\n\tif (appendSystemPrompt) {\n\t\tsections.push({ id: \"append\", text: `\\n\\n${appendSystemPrompt}` });\n\t}\n\n\tconst contextFiles = providedContextFiles ?? [];\n\tif (contextFiles.length > 0) {\n\t\tlet text = \"\\n\\n# Project Context\\n\\n\";\n\t\ttext += \"Project-specific instructions and guidelines:\\n\\n\";\n\t\tfor (const { path: filePath, content } of contextFiles) {\n\t\t\ttext += `## ${filePath}\\n\\n${content}\\n\\n`;\n\t\t}\n\t\tsections.push({ id: \"context-files\", text });\n\t}\n\n\t// Skills section (only if read tool is available)\n\tconst skills = providedSkills ?? [];\n\tconst hasRead = !selectedTools || selectedTools.includes(\"read\");\n\tif (hasRead && skills.length > 0) {\n\t\tconst text = formatSkillsForPrompt(skills);\n\t\tif (text) {\n\t\t\tsections.push({ id: \"skills\", text });\n\t\t}\n\t}\n\n\t// SCRAMJET-DIVERGENCE: include session journal path alongside date/cwd (issue 348)\n\tconst sessionJournalLine = options.sessionFile\n\t\t? `\\nCurrent session journal: ${options.sessionFile.replace(/\\\\/g, \"/\")}`\n\t\t: \"\";\n\n\tsections.push({\n\t\tid: \"volatile\",\n\t\ttext: `\\nCurrent date: ${date}\\nCurrent working directory: ${promptCwd}${sessionJournalLine}`,\n\t\tcacheRetention: \"none\",\n\t});\n\n\treturn sections;\n}\n\n/** Build the system prompt with tools, guidelines, and context */\nexport function buildSystemPrompt(options: BuildSystemPromptOptions): string {\n\treturn flattenSystemPrompt(buildSystemPromptSections(options));\n}\n\n// SCRAMJET-DIVERGENCE: rebrand product identity in system prompt (Pi -> Scramjet)\n/** Build the default core prompt: identity, tools list, guidelines, doc paths. */\nfunction buildDefaultCorePrompt(options: BuildSystemPromptOptions): string {\n\tconst { selectedTools, toolSnippets, promptGuidelines } = options;\n\n\t// Get absolute paths to documentation and examples\n\tconst readmePath = getReadmePath();\n\tconst docsPath = getDocsPath();\n\tconst examplesPath = getExamplesPath();\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 tools = selectedTools || [\"read\", \"bash\", \"edit\", \"write\"];\n\tconst visibleTools = tools.filter((name) => !!toolSnippets?.[name]);\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 = tools.includes(\"bash\");\n\tconst hasGrep = tools.includes(\"grep\");\n\tconst hasFind = tools.includes(\"find\");\n\tconst hasLs = tools.includes(\"ls\");\n\n\t// File exploration guidelines\n\tif (hasBash && !hasGrep && !hasFind && !hasLs) {\n\t\taddGuideline(\"Use bash for file operations like ls, rg, find\");\n\t} else if (hasBash && (hasGrep || hasFind || hasLs)) {\n\t\taddGuideline(\"Prefer grep/find/ls tools over bash for file exploration (faster, respects .gitignore)\");\n\t}\n\n\tfor (const guideline of promptGuidelines ?? []) {\n\t\tconst normalized = guideline.trim();\n\t\tif (normalized.length > 0) {\n\t\t\taddGuideline(normalized);\n\t\t}\n\t}\n\n\t// Always include these\n\taddGuideline(\"Be concise in your responses\");\n\taddGuideline(\"Show file paths clearly when working with files\");\n\n\tconst guidelines = guidelinesList.map((g) => `- ${g}`).join(\"\\n\");\n\n\treturn `You are an expert coding assistant operating inside scramjet, a coding agent harness. You help users by reading files, executing commands, editing code, and writing new files.\n\nAvailable tools:\n${toolsList}\n\nIn addition to the tools above, you may have access to other custom tools depending on the project.\n\nGuidelines:\n${guidelines}\n\nScramjet documentation (read only when the user asks about scramjet itself, its SDK, extensions, themes, skills, or TUI):\n- Main documentation: ${readmePath}\n- Additional docs: ${docsPath}\n- Examples: ${examplesPath} (extensions, custom tools, SDK)\n- When asked about: extensions (docs/extensions.md, examples/extensions/), themes (docs/themes.md), skills (docs/skills.md), prompt templates (docs/prompt-templates.md), TUI components (docs/tui.md), keybindings (docs/keybindings.md), SDK integrations (docs/sdk.md), custom providers (docs/custom-provider.md), adding models (docs/models.md), scramjet packages (docs/packages.md)\n- When working on scramjet topics, read the docs and examples, and follow .md cross-references before implementing\n- Always read scramjet .md files completely and follow links to related docs (e.g., tui.md for TUI API details)`;\n}\n"]}
|
package/docs/extensions.md
CHANGED
|
@@ -477,7 +477,7 @@ pi.on("before_agent_start", async (event, ctx) => {
|
|
|
477
477
|
// (includes changes from earlier before_agent_start handlers)
|
|
478
478
|
// event.systemPromptSections - read-only view of the base system prompt
|
|
479
479
|
// sections for this turn, before extension contributions; the volatile
|
|
480
|
-
// environment tail (current date/cwd) is the section with
|
|
480
|
+
// environment tail (current date/cwd/session journal) is the section with
|
|
481
481
|
// cacheRetention: "none"
|
|
482
482
|
// event.systemPromptOptions - structured options used to build the system prompt
|
|
483
483
|
// .customPrompt - any custom system prompt (from --system-prompt, SYSTEM.md, or custom templates)
|
|
@@ -486,6 +486,7 @@ pi.on("before_agent_start", async (event, ctx) => {
|
|
|
486
486
|
// .promptGuidelines - custom guideline bullets
|
|
487
487
|
// .appendSystemPrompt - text from --append-system-prompt flags
|
|
488
488
|
// .cwd - working directory
|
|
489
|
+
// .sessionFile - current session file path (undefined when sessions are disabled)
|
|
489
490
|
// .contextFiles - AGENTS.md files and other loaded context files
|
|
490
491
|
// .skills - loaded skills
|
|
491
492
|
|
|
@@ -510,7 +511,7 @@ Inside `before_agent_start`, `event.systemPrompt` and `ctx.getSystemPrompt()` bo
|
|
|
510
511
|
|
|
511
512
|
##### System prompt sections
|
|
512
513
|
|
|
513
|
-
Scramjet assembles the system prompt as ordered sections (`SystemPromptSection { id, text, cacheRetention?: "none" }` from `@leanandmean/ai`; ids are informational, and `"none"` is the only per-section retention — request-level retention applies otherwise) so providers can cache the stable prefix independently of the volatile tail. The last base section holds the current date
|
|
514
|
+
Scramjet assembles the system prompt as ordered sections (`SystemPromptSection { id, text, cacheRetention?: "none" }` from `@leanandmean/ai`; ids are informational, and `"none"` is the only per-section retention — request-level retention applies otherwise) so providers can cache the stable prefix independently of the volatile tail. The last base section holds the current date, working directory, and session journal path and is marked `cacheRetention: "none"`; on Anthropic, everything before it is folded into a single cached system block and the volatile tail trails uncached.
|
|
514
515
|
|
|
515
516
|
Returning `systemPromptSection` contributes a section for the current turn without replacing Scramjet's prompt assembly:
|
|
516
517
|
|
package/docs/sdk.md
CHANGED
|
@@ -420,7 +420,7 @@ If no model is provided:
|
|
|
420
420
|
|
|
421
421
|
`cacheRetention` controls prompt-cache retention on providers that support it (Anthropic: `long` -> 1h cache TTL where the model supports it, `short` -> the default 5m TTL, `none` -> no caching). Precedence: the `cacheRetention` option (or the `--cache-retention` CLI flag), then the `PI_CACHE_RETENTION` environment variable, then the built-in default `long`. Short-lived sessions such as subagents should pass `short` since a 1h cache write costs more than a 5m one and rarely pays off for a single run.
|
|
422
422
|
|
|
423
|
-
Scramjet builds the system prompt as ordered sections and isolates the volatile environment tail (current date, working directory) into a final uncached section. On Anthropic, the stable sections are folded into a single system block carrying the cache breakpoint, so the cached prefix survives across turns even though the tail varies between sessions. Extensions can contribute stable sections via `before_agent_start` — see [extensions.md](extensions.md#system-prompt-sections).
|
|
423
|
+
Scramjet builds the system prompt as ordered sections and isolates the volatile environment tail (current date, working directory, session journal path) into a final uncached section. On Anthropic, the stable sections are folded into a single system block carrying the cache breakpoint, so the cached prefix survives across turns even though the tail varies between sessions. Extensions can contribute stable sections via `before_agent_start` — see [extensions.md](extensions.md#system-prompt-sections).
|
|
424
424
|
|
|
425
425
|
> Before sectioned system prompts landed, the effective default was `short` (the env var could only upgrade it to `long`). Sessions created through the SDK or CLI now default to `long`; set `PI_CACHE_RETENTION=short` or pass `cacheRetention: "short"` to restore the old behavior.
|
|
426
426
|
|
package/package.json
CHANGED
|
@@ -1,67 +1,67 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
2
|
+
"name": "@leanandmean/coding-agent",
|
|
3
|
+
"version": "0.74.1-scramjet.20",
|
|
4
|
+
"publishConfig": {
|
|
5
|
+
"access": "public"
|
|
6
|
+
},
|
|
7
|
+
"description": "Coding agent CLI with read, bash, edit, write tools and session management",
|
|
8
|
+
"license": "Apache-2.0",
|
|
9
|
+
"type": "module",
|
|
10
|
+
"piConfig": {
|
|
11
|
+
"name": "scramjet",
|
|
12
|
+
"configDir": ".scramjet"
|
|
13
|
+
},
|
|
14
|
+
"main": "./dist/index.js",
|
|
15
|
+
"types": "./dist/index.d.ts",
|
|
16
|
+
"exports": {
|
|
17
|
+
".": {
|
|
18
|
+
"types": "./dist/index.d.ts",
|
|
19
|
+
"import": "./dist/index.js"
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
"files": [
|
|
23
|
+
"dist",
|
|
24
|
+
"docs",
|
|
25
|
+
"examples",
|
|
26
|
+
"CHANGELOG.md"
|
|
27
|
+
],
|
|
28
|
+
"scripts": {
|
|
29
|
+
"clean": "shx rm -rf dist",
|
|
30
|
+
"dev": "tsgo -p tsconfig.build.json --watch --preserveWatchOutput",
|
|
31
|
+
"build": "tsgo -p tsconfig.build.json && shx chmod +x dist/cli.js && npm run copy-assets",
|
|
32
|
+
"copy-assets": "shx mkdir -p dist/modes/interactive/theme && shx cp src/modes/interactive/theme/*.json dist/modes/interactive/theme/ && shx mkdir -p dist/modes/interactive/assets && shx cp src/modes/interactive/assets/*.png dist/modes/interactive/assets/ && shx mkdir -p dist/core/export-html/vendor && shx cp src/core/export-html/template.html src/core/export-html/template.css src/core/export-html/template.js dist/core/export-html/ && shx cp src/core/export-html/vendor/*.js dist/core/export-html/vendor/",
|
|
33
|
+
"test": "vitest --run --passWithNoTests"
|
|
34
|
+
},
|
|
35
|
+
"dependencies": {
|
|
36
|
+
"@leanandmean/agent": "0.74.1-scramjet.10",
|
|
37
|
+
"@leanandmean/ai": "0.74.1-scramjet.8",
|
|
38
|
+
"@leanandmean/tui": "0.74.1-scramjet.8",
|
|
39
|
+
"@silvia-odwyer/photon-node": "^0.3.4",
|
|
40
|
+
"chalk": "^5.5.0",
|
|
41
|
+
"dictionary-en": "^4.0.0",
|
|
42
|
+
"diff": "^8.0.2",
|
|
43
|
+
"glob": "^13.0.1",
|
|
44
|
+
"highlight.js": "^10.7.3",
|
|
45
|
+
"hosted-git-info": "^9.0.2",
|
|
46
|
+
"ignore": "^7.0.5",
|
|
47
|
+
"jiti": "^2.7.0",
|
|
48
|
+
"minimatch": "^10.2.3",
|
|
49
|
+
"nspell": "^2.1.5",
|
|
50
|
+
"proper-lockfile": "^4.1.2",
|
|
51
|
+
"typebox": "^1.1.24",
|
|
52
|
+
"undici": "^7.19.1",
|
|
53
|
+
"yaml": "^2.8.2"
|
|
54
|
+
},
|
|
55
|
+
"optionalDependencies": {
|
|
56
|
+
"@mariozechner/clipboard": "^0.3.6"
|
|
57
|
+
},
|
|
58
|
+
"devDependencies": {
|
|
59
|
+
"@types/diff": "^7.0.2",
|
|
60
|
+
"@types/hosted-git-info": "^3.0.5",
|
|
61
|
+
"@types/ms": "^2.1.0",
|
|
62
|
+
"@types/proper-lockfile": "^4.1.4"
|
|
63
|
+
},
|
|
64
|
+
"engines": {
|
|
65
|
+
"node": ">=20.6.0"
|
|
66
|
+
}
|
|
67
67
|
}
|