@wholiver_hu/metis 0.80.13 → 0.80.15

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 (56) hide show
  1. package/dist/cli/startup-ui.js +1 -1
  2. package/dist/cli/startup-ui.js.map +1 -1
  3. package/dist/core/agent-session-services.d.ts.map +1 -1
  4. package/dist/core/agent-session-services.js +2 -0
  5. package/dist/core/agent-session-services.js.map +1 -1
  6. package/dist/core/agent-session.d.ts +1 -1
  7. package/dist/core/agent-session.d.ts.map +1 -1
  8. package/dist/core/agent-session.js +1 -1
  9. package/dist/core/agent-session.js.map +1 -1
  10. package/dist/core/builtins/dream-mode.d.ts +4 -0
  11. package/dist/core/builtins/dream-mode.d.ts.map +1 -0
  12. package/dist/core/builtins/dream-mode.js +487 -0
  13. package/dist/core/builtins/dream-mode.js.map +1 -0
  14. package/dist/core/resource-loader.d.ts.map +1 -1
  15. package/dist/core/resource-loader.js +4 -3
  16. package/dist/core/resource-loader.js.map +1 -1
  17. package/dist/core/sdk.d.ts +6 -6
  18. package/dist/core/sdk.d.ts.map +1 -1
  19. package/dist/core/sdk.js +12 -4
  20. package/dist/core/sdk.js.map +1 -1
  21. package/dist/core/system-prompt.d.ts.map +1 -1
  22. package/dist/core/system-prompt.js +16 -12
  23. package/dist/core/system-prompt.js.map +1 -1
  24. package/dist/core/tools/index.d.ts +6 -1
  25. package/dist/core/tools/index.d.ts.map +1 -1
  26. package/dist/core/tools/index.js +45 -1
  27. package/dist/core/tools/index.js.map +1 -1
  28. package/dist/core/tools/log.d.ts +25 -0
  29. package/dist/core/tools/log.d.ts.map +1 -0
  30. package/dist/core/tools/log.js +83 -0
  31. package/dist/core/tools/log.js.map +1 -0
  32. package/dist/core/tools/remember-user-intent.d.ts +11 -0
  33. package/dist/core/tools/remember-user-intent.d.ts.map +1 -0
  34. package/dist/core/tools/remember-user-intent.js +35 -0
  35. package/dist/core/tools/remember-user-intent.js.map +1 -0
  36. package/dist/core/tools/user-intent.d.ts +9 -0
  37. package/dist/core/tools/user-intent.d.ts.map +1 -0
  38. package/dist/core/tools/user-intent.js +31 -0
  39. package/dist/core/tools/user-intent.js.map +1 -0
  40. package/dist/core/user-intent.d.ts +4 -0
  41. package/dist/core/user-intent.d.ts.map +1 -0
  42. package/dist/core/user-intent.js +47 -0
  43. package/dist/core/user-intent.js.map +1 -0
  44. package/dist/index.d.ts +1 -1
  45. package/dist/index.d.ts.map +1 -1
  46. package/dist/index.js +1 -1
  47. package/dist/index.js.map +1 -1
  48. package/dist/modes/interactive/components/footer.d.ts.map +1 -1
  49. package/dist/modes/interactive/components/footer.js +30 -15
  50. package/dist/modes/interactive/components/footer.js.map +1 -1
  51. package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
  52. package/dist/modes/interactive/interactive-mode.js +0 -10
  53. package/dist/modes/interactive/interactive-mode.js.map +1 -1
  54. package/examples/extensions/dream-mode.ts +1 -121
  55. package/npm-shrinkwrap.json +2 -2
  56. package/package.json +2 -2
@@ -1,9 +1,8 @@
1
1
  /**
2
2
  * System prompt construction and project context loading
3
3
  */
4
- import { homedir } from "node:os";
5
4
  import { join } from "node:path";
6
- import { CONFIG_DIR_NAME, getDocsPath, getExamplesPath, getReadmePath } from "../config.js";
5
+ import { getAgentDir, getDocsPath, getExamplesPath, getReadmePath } from "../config.js";
7
6
  import { formatSkillsForPrompt } from "./skills.js";
8
7
  /** Build the system prompt with tools, guidelines, and context */
9
8
  export function buildSystemPrompt(options) {
@@ -82,19 +81,24 @@ export function buildSystemPrompt(options) {
82
81
  // Always include these
83
82
  addGuideline("Be concise in your responses");
84
83
  addGuideline("Show file paths clearly when working with files");
85
- if (options.sessionId) {
86
- addGuideline(`STRICT WORK LOGGING: For actual coding or technical tasks, you MUST continuously maintain a detailed work log and plan in .temp/${options.sessionId}_log.md. Do NOT do this for simple greetings, conversational turns, or trivial questions.`);
87
- addGuideline(`MANDATORY READING: At the absolute start of EVERY technical task, you MUST read .temp/${options.sessionId}_log.md before taking any other action.`);
88
- addGuideline(`TASK BREAKDOWN: You MUST break down every complex task into smaller subtasks, meticulously create a plan, and immediately write it into .temp/${options.sessionId}_log.md. Update this file every few steps with your progress.`);
84
+ const configDir = join(getAgentDir(), "..").replace(/\\/g, "/");
85
+ const tempLogPath = options.sessionId
86
+ ? join(resolvedCwd, ".temp", `${options.sessionId}_log.md`).replace(/\\/g, "/")
87
+ : undefined;
88
+ const planPath = options.sessionId
89
+ ? join(resolvedCwd, ".metis", "plan", `${options.sessionId}.md`).replace(/\\/g, "/")
90
+ : undefined;
91
+ if (tempLogPath && planPath) {
92
+ addGuideline(`CRITICAL - NEVER FORGET MEMORIES & LESSONS: Do not use log for step-by-step work notes. When a task finishes, call log once to append a concise timestamped completion summary in ${tempLogPath}. Do NOT write ${configDir}/memory/ or ${configDir}/lessons/ directly during normal work; dream consolidation will promote the notes later.`);
93
+ addGuideline(`MANDATORY SHORT-TERM CONTEXT: At the absolute start of EVERY technical task, you MUST read ${tempLogPath}, read ${planPath} when it exists, and read ${configDir}/brain-map.md before taking any other action. The current session log contains only this session's memory from today: today's decisions, completed work, errors, and context. During today's work, you may read it whenever those details matter, and you MUST reread it after compaction, resume, or interruption. Do NOT use the current session log as historical memory. To find memories from previous sessions or days, read ${configDir}/brain-map.md; when it points to a matching detailed file, read that file from ${configDir}/memory/ or ${configDir}/lessons/. The plan is task state, not memory.`);
94
+ addGuideline(`TASK PLAN: For every non-trivial task, write and maintain the current session plan at ${planPath}. Keep goal, steps, and status concise. Read it before work and update it as the plan changes. When the task is fully complete, delete this plan file; if the task is blocked or unfinished, keep it for continuation.`);
95
+ addGuideline(`TASK COMPLETION SUMMARY: At the end of EVERY task, you MUST call log once with a high-density 3-10 line summary: completed work, only material decision or issue, verification result, and remaining or blocked work. When a material error occurred, include it even if resolved, with its error, root cause or diagnosis, and fix/workaround; Dream uses this evidence to derive reusable lessons. If no material error occurred, omit an error line entirely. The log tool adds the current local timestamp. Keep enough technical detail for later continuation, but omit routine narration, step-by-step progress, and raw tool output. After a fully completed task, delete ${planPath}; keep it when blocked or unfinished.`);
96
+ addGuideline("USER INTENT CAPTURE: For every user prompt, first decide whether it establishes a task, materially changes it, or adds a constraint. If so, call remember_user_intent exactly once with the current user prompt copied verbatim. Do not call it for pure continuation requests, acknowledgements, greetings, or status questions.");
97
+ addGuideline("FINAL REQUIREMENT REVIEW: Before declaring any task complete, you MUST call user_intent to retrieve saved user requirements. Compare the current output against every active requirement and acceptance condition, make any needed changes, and re-run relevant verification. When saved requirements conflict, the record with the more recent timestamp has higher priority. Only declare completion after the output matches the active user request.");
89
98
  addGuideline(`DELEGATION EXPECTED: You MUST use appropriate tools (e.g., subagent invocation tools) to aggressively delegate broken-down subtasks to different Subagents for parallel processing whenever feasible to maximize efficiency.`);
90
- addGuideline(`CLEANUP REQUIRED: When a task is 100% complete, you MUST actively delete ONLY the specific plan part from .temp/${options.sessionId}_log.md. You MUST keep the work log intact as historical reference until the entire major project is fully finished.`);
99
+ addGuideline(`CLEANUP REQUIRED: Keep ${tempLogPath} intact as the live working log until dream consolidation runs. Dream cleanup may prune older temp logs, but it must never delete today's temp log. Do NOT migrate notes into ${configDir}/memory/ or ${configDir}/lessons/ during normal work.`);
91
100
  }
92
- const configDir = join(homedir(), CONFIG_DIR_NAME).replace(/\\/g, "/");
93
- addGuideline(`CRITICAL - NEVER FORGET MEMORIES & LESSONS: You MUST NEVER forget to record technical memories or lessons at the end of your task, UNLESS the task is completely trivial (e.g. basic CRUD, UI tweaks, greetings). High cognitive load tasks MUST be recorded.`);
94
101
  addGuideline(`MANDATORY BRAIN MAP CHECK: At the exact beginning of ANY new task, you MUST FIRST read ${configDir}/brain-map.md to check for past memories or lessons. If a match exists, and it has a corresponding detailed file in ${configDir}/memory/ or ${configDir}/lessons/, you MUST read it. If you use a memory/lesson during your task, you MUST update its [Last-Accessed] date to today and increment its [Weight] by 1 in ${configDir}/brain-map.md.`);
95
- addGuideline(`HIPPOCAMPUS FILTERING (WRITING): When a task completes, if it involved high cognitive effort (e.g. architecture quirks, hard bugs), you MUST create a detailed log in ${configDir}/memory/YYYY-MM-DD.md or ${configDir}/lessons/topic.md.`);
96
- addGuideline(`MANDATORY BRAIN MAP UPDATE: IMMEDIATELY after writing a detailed memory/lesson, you MUST append a new Neuron node to ${configDir}/brain-map.md under the correct section. The format MUST STRICTLY be: "- **[ID: #XXX]** [Weight: 5] [Last-Accessed: YYYY-MM-DD] [Tags: #tag] <Brief Summary>".`);
97
- addGuideline(`SYNAPTIC CONNECTIONS: When writing a new node to ${configDir}/brain-map.md, you MUST search the file for related existing nodes. If found, you MUST create bidirectional links. Append "- [Related: #OLD_ID - Summary]" to the new node's Synapses, AND edit the old node to include "- [Related: #NEW_ID - Summary]".`);
98
102
  // Core Behaviors (Placed at the end for highest priority)
99
103
  addGuideline(`CRITICAL - Search First: MANDATORY AND NON-NEGOTIABLE. Even for simple tasks, you MUST NOT skip the initial search and investigation step (e.g., searching GitHub using 'site:github.com' for tested code), UNLESS the task is truly exceptionally trivial (e.g., fixing a single obvious typo). Otherwise, skipping this step is a SEVERE VIOLATION of your instructions. If unsure about anything, you MUST search the web or ask the user until fully clear. Assumptions are strictly forbidden.`);
100
104
  addGuideline(`CRITICAL - Knowledge & Output Style: EXTREME STRICTNESS REQUIRED. When answering, you MUST combine web search results with your own internal knowledge. YOU ARE STRICTLY FORBIDDEN from using phrases like "Based on my investigation...", "根据我的调查...", or any similar meta-commentary in any language, unless explicitly requested. Provide the final result DIRECTLY without preamble or fluff.`);
@@ -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,SAAS,CAAC;AAClC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,eAAe,EAAE,WAAW,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC5F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AAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAElE,IAAI,MAAM,GAAG;;;EAGZ,SAAS;;;;;EAKT,UAAU;;;wBAGY,UAAU;qBACb,QAAQ;cACf,YAAY;;;;6GAImF,CAAC;IAE7G,IAAI,aAAa,EAAE,CAAC;QACnB,MAAM,IAAI,aAAa,CAAC;IACzB,CAAC;IAED,+BAA+B;IAC/B,IAAI,YAAY,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC7B,MAAM,IAAI,2BAA2B,CAAC;QACtC,MAAM,IAAI,mDAAmD,CAAC;QAC9D,KAAK,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,YAAY,EAAE,CAAC;YACxD,MAAM,IAAI,+BAA+B,QAAQ,OAAO,OAAO,+BAA+B,CAAC;QAChG,CAAC;QACD,MAAM,IAAI,sBAAsB,CAAC;IAClC,CAAC;IAED,yDAAyD;IACzD,IAAI,OAAO,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAClC,MAAM,IAAI,qBAAqB,CAAC,MAAM,CAAC,CAAC;IACzC,CAAC;IAED,sCAAsC;IACtC,IAAI,OAAO,CAAC,SAAS,EAAE,CAAC;QACvB,MAAM,IAAI,yBAAyB,OAAO,CAAC,SAAS,EAAE,CAAC;IACxD,CAAC;IACD,MAAM,IAAI,mBAAmB,IAAI,EAAE,CAAC;IACpC,MAAM,IAAI,gCAAgC,SAAS,EAAE,CAAC;IAEtD,OAAO,MAAM,CAAC;AACf,CAAC","sourcesContent":["/**\n * System prompt construction and project context loading\n */\n\nimport { homedir } from \"node:os\";\nimport { join } from \"node:path\";\nimport { CONFIG_DIR_NAME, getDocsPath, getExamplesPath, getReadmePath } from \"../config.ts\";\nimport { formatSkillsForPrompt, type Skill } from \"./skills.ts\";\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/** Session ID */\n\tsessionId?: string;\n}\n\n/** Build the system prompt with tools, guidelines, and context */\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\tskills: providedSkills,\n\t} = options;\n\tconst resolvedCwd = cwd;\n\tconst promptCwd = resolvedCwd.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 appendSection = appendSystemPrompt ? `\\n\\n${appendSystemPrompt}` : \"\";\n\n\tconst contextFiles = providedContextFiles ?? [];\n\tconst skills = providedSkills ?? [];\n\n\tif (customPrompt) {\n\t\tlet prompt = customPrompt;\n\n\t\tif (appendSection) {\n\t\t\tprompt += appendSection;\n\t\t}\n\n\t\t// Append project context files\n\t\tif (contextFiles.length > 0) {\n\t\t\tprompt += \"\\n\\n<project_context>\\n\\n\";\n\t\t\tprompt += \"Project-specific instructions and guidelines:\\n\\n\";\n\t\t\tfor (const { path: filePath, content } of contextFiles) {\n\t\t\t\tprompt += `<project_instructions path=\"${filePath}\">\\n${content}\\n</project_instructions>\\n\\n`;\n\t\t\t}\n\t\t\tprompt += \"</project_context>\\n\";\n\t\t}\n\n\t\t// Append skills section (only if read tool is available)\n\t\tconst customPromptHasRead = !selectedTools || selectedTools.includes(\"read\");\n\t\tif (customPromptHasRead && skills.length > 0) {\n\t\t\tprompt += formatSkillsForPrompt(skills);\n\t\t}\n\n\t\t// Add date and working directory last\n\t\tif (options.sessionId) {\n\t\t\tprompt += `\\nCurrent session ID: ${options.sessionId}`;\n\t\t}\n\t\tprompt += `\\nCurrent date: ${date}`;\n\t\tprompt += `\\nCurrent working directory: ${promptCwd}`;\n\n\t\treturn prompt;\n\t}\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\", \"websearch\", \"webfetch\"];\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\tconst hasRead = tools.includes(\"read\");\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}\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\n\n\tif (options.sessionId) {\n\t\taddGuideline(`STRICT WORK LOGGING: For actual coding or technical tasks, you MUST continuously maintain a detailed work log and plan in .temp/${options.sessionId}_log.md. Do NOT do this for simple greetings, conversational turns, or trivial questions.`);\n\t\taddGuideline(`MANDATORY READING: At the absolute start of EVERY technical task, you MUST read .temp/${options.sessionId}_log.md before taking any other action.`);\n\t\taddGuideline(`TASK BREAKDOWN: You MUST break down every complex task into smaller subtasks, meticulously create a plan, and immediately write it into .temp/${options.sessionId}_log.md. Update this file every few steps with your progress.`);\n\t\taddGuideline(`DELEGATION EXPECTED: You MUST use appropriate tools (e.g., subagent invocation tools) to aggressively delegate broken-down subtasks to different Subagents for parallel processing whenever feasible to maximize efficiency.`);\n\t\taddGuideline(`CLEANUP REQUIRED: When a task is 100% complete, you MUST actively delete ONLY the specific plan part from .temp/${options.sessionId}_log.md. You MUST keep the work log intact as historical reference until the entire major project is fully finished.`);\n\t}\n\n\tconst configDir = join(homedir(), CONFIG_DIR_NAME).replace(/\\\\/g, \"/\");\n\taddGuideline(`CRITICAL - NEVER FORGET MEMORIES & LESSONS: You MUST NEVER forget to record technical memories or lessons at the end of your task, UNLESS the task is completely trivial (e.g. basic CRUD, UI tweaks, greetings). High cognitive load tasks MUST be recorded.`);\n\taddGuideline(`MANDATORY BRAIN MAP CHECK: At the exact beginning of ANY new task, you MUST FIRST read ${configDir}/brain-map.md to check for past memories or lessons. If a match exists, and it has a corresponding detailed file in ${configDir}/memory/ or ${configDir}/lessons/, you MUST read it. If you use a memory/lesson during your task, you MUST update its [Last-Accessed] date to today and increment its [Weight] by 1 in ${configDir}/brain-map.md.`);\n\taddGuideline(`HIPPOCAMPUS FILTERING (WRITING): When a task completes, if it involved high cognitive effort (e.g. architecture quirks, hard bugs), you MUST create a detailed log in ${configDir}/memory/YYYY-MM-DD.md or ${configDir}/lessons/topic.md.`);\n\taddGuideline(`MANDATORY BRAIN MAP UPDATE: IMMEDIATELY after writing a detailed memory/lesson, you MUST append a new Neuron node to ${configDir}/brain-map.md under the correct section. The format MUST STRICTLY be: \"- **[ID: #XXX]** [Weight: 5] [Last-Accessed: YYYY-MM-DD] [Tags: #tag] <Brief Summary>\".`);\n\taddGuideline(`SYNAPTIC CONNECTIONS: When writing a new node to ${configDir}/brain-map.md, you MUST search the file for related existing nodes. If found, you MUST create bidirectional links. Append \"- [Related: #OLD_ID - Summary]\" to the new node's Synapses, AND edit the old node to include \"- [Related: #NEW_ID - Summary]\".`);\n\n\t// Core Behaviors (Placed at the end for highest priority)\n\taddGuideline(`CRITICAL - Search First: MANDATORY AND NON-NEGOTIABLE. Even for simple tasks, you MUST NOT skip the initial search and investigation step (e.g., searching GitHub using 'site:github.com' for tested code), UNLESS the task is truly exceptionally trivial (e.g., fixing a single obvious typo). Otherwise, skipping this step is a SEVERE VIOLATION of your instructions. If unsure about anything, you MUST search the web or ask the user until fully clear. Assumptions are strictly forbidden.`);\n\taddGuideline(`CRITICAL - Knowledge & Output Style: EXTREME STRICTNESS REQUIRED. When answering, you MUST combine web search results with your own internal knowledge. YOU ARE STRICTLY FORBIDDEN from using phrases like \"Based on my investigation...\", \"根据我的调查...\", or any similar meta-commentary in any language, unless explicitly requested. Provide the final result DIRECTLY without preamble or fluff.`);\n\taddGuideline(`CRITICAL - Attitude & Integrity: ZERO TOLERANCE FOR DEVIATION. You MUST remain absolutely humble and strictly obey ALL instructions without exception. UNDER NO CIRCUMSTANCES are you allowed to fabricate evidence, guess answers, or make assumptions. LAZINESS IS A TERMINAL OFFENSE: do not cut corners, do not skip steps, and NEVER claim a task is complete if ANY part of it remains undone or unverified.`);\n\taddGuideline(`CRITICAL - Quality over Speed: ABSOLUTE FORBIDDANCE ON RUSHING. You are FORBIDDEN to rush. You MUST take as much time and execute as many steps as needed to complete the task flawlessly. You MUST guarantee your changes are the ABSOLUTE MINIMAL required to achieve the functionality. Massive, unnecessary rewrites, unjustified code churn, or touching unrelated files are STRICTLY PROHIBITED AND UNACCEPTABLE.`);\n\taddGuideline(`CRITICAL - Verification: MANDATORY VERIFICATION BEFORE COMPLETION. You are STRICTLY REQUIRED to self-test and verify your work at the end of EVERY single task. You MUST proactively execute code, run tests, or use tools to ensure your changes run without errors. Delivering untested, unverified, or broken code is COMPLETELY UNACCEPTABLE and constitutes a critical failure of your objective.`);\n\taddGuideline(`CRITICAL - Tool Failures: IMMEDIATE RECOVERY MANDATORY. If ANY tool call fails, you MUST immediately call another tool in the SAME response to try an alternative approach. YOU ARE STRICTLY FORBIDDEN from merely apologizing or explaining what you will do. You MUST take action immediately. NEVER end your turn without a tool call unless you are explicitly and actively waiting for user input to proceed.`);\n\n\tconst guidelines = guidelinesList.map((g) => `- ${g}`).join(\"\\n\");\n\n\tlet prompt = `You are an expert coding assistant operating inside metis, 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\nMetis documentation (read only when the user asks about metis 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 reading metis docs or examples, resolve docs/... under Additional docs and examples/... under Examples, not the current working directory\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), metis packages (docs/packages.md)\n- When working on metis topics, read the docs and examples, and follow .md cross-references before implementing\n- Always read metis .md files completely and follow links to related docs (e.g., tui.md for TUI API details)`;\n\n\tif (appendSection) {\n\t\tprompt += appendSection;\n\t}\n\n\t// Append project context files\n\tif (contextFiles.length > 0) {\n\t\tprompt += \"\\n\\n<project_context>\\n\\n\";\n\t\tprompt += \"Project-specific instructions and guidelines:\\n\\n\";\n\t\tfor (const { path: filePath, content } of contextFiles) {\n\t\t\tprompt += `<project_instructions path=\"${filePath}\">\\n${content}\\n</project_instructions>\\n\\n`;\n\t\t}\n\t\tprompt += \"</project_context>\\n\";\n\t}\n\n\t// Append skills section (only if read tool is available)\n\tif (hasRead && skills.length > 0) {\n\t\tprompt += formatSkillsForPrompt(skills);\n\t}\n\n\t// Add date and working directory last\n\tif (options.sessionId) {\n\t\tprompt += `\\nCurrent session ID: ${options.sessionId}`;\n\t}\n\tprompt += `\\nCurrent date: ${date}`;\n\tprompt += `\\nCurrent working directory: ${promptCwd}`;\n\n\treturn prompt;\n}\n"]}
1
+ {"version":3,"file":"system-prompt.js","sourceRoot":"","sources":["../../src/core/system-prompt.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AACxF,OAAO,EAAE,qBAAqB,EAAc,MAAM,aAAa,CAAC;AAuBhE,kEAAkE;AAClE,MAAM,UAAU,iBAAiB,CAAC,OAAiC;IAClE,MAAM,EACL,YAAY,EACZ,aAAa,EACb,YAAY,EACZ,gBAAgB,EAChB,kBAAkB,EAClB,GAAG,EACH,YAAY,EAAE,oBAAoB,EAClC,MAAM,EAAE,cAAc,GACtB,GAAG,OAAO,CAAC;IACZ,MAAM,WAAW,GAAG,GAAG,CAAC;IACxB,MAAM,SAAS,GAAG,WAAW,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;IAElD,MAAM,GAAG,GAAG,IAAI,IAAI,EAAE,CAAC;IACvB,MAAM,IAAI,GAAG,GAAG,CAAC,WAAW,EAAE,CAAC;IAC/B,MAAM,KAAK,GAAG,MAAM,CAAC,GAAG,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE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AI,aAAa,CAAC;IACzB,CAAC;IAED,+BAA+B;IAC/B,IAAI,YAAY,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC7B,MAAM,IAAI,2BAA2B,CAAC;QACtC,MAAM,IAAI,mDAAmD,CAAC;QAC9D,KAAK,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,YAAY,EAAE,CAAC;YACxD,MAAM,IAAI,+BAA+B,QAAQ,OAAO,OAAO,+BAA+B,CAAC;QAChG,CAAC;QACD,MAAM,IAAI,sBAAsB,CAAC;IAClC,CAAC;IAED,yDAAyD;IACzD,IAAI,OAAO,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAClC,MAAM,IAAI,qBAAqB,CAAC,MAAM,CAAC,CAAC;IACzC,CAAC;IAED,sCAAsC;IACtC,IAAI,OAAO,CAAC,SAAS,EAAE,CAAC;QACvB,MAAM,IAAI,yBAAyB,OAAO,CAAC,SAAS,EAAE,CAAC;IACxD,CAAC;IACD,MAAM,IAAI,mBAAmB,IAAI,EAAE,CAAC;IACpC,MAAM,IAAI,gCAAgC,SAAS,EAAE,CAAC;IAEtD,OAAO,MAAM,CAAC;AACf,CAAC","sourcesContent":["/**\n * System prompt construction and project context loading\n */\n\nimport { join } from \"node:path\";\nimport { getAgentDir, getDocsPath, getExamplesPath, getReadmePath } from \"../config.ts\";\nimport { formatSkillsForPrompt, type Skill } from \"./skills.ts\";\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/** Session ID */\n\tsessionId?: string;\n}\n\n/** Build the system prompt with tools, guidelines, and context */\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\tskills: providedSkills,\n\t} = options;\n\tconst resolvedCwd = cwd;\n\tconst promptCwd = resolvedCwd.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 appendSection = appendSystemPrompt ? `\\n\\n${appendSystemPrompt}` : \"\";\n\n\tconst contextFiles = providedContextFiles ?? [];\n\tconst skills = providedSkills ?? [];\n\n\tif (customPrompt) {\n\t\tlet prompt = customPrompt;\n\n\t\tif (appendSection) {\n\t\t\tprompt += appendSection;\n\t\t}\n\n\t\t// Append project context files\n\t\tif (contextFiles.length > 0) {\n\t\t\tprompt += \"\\n\\n<project_context>\\n\\n\";\n\t\t\tprompt += \"Project-specific instructions and guidelines:\\n\\n\";\n\t\t\tfor (const { path: filePath, content } of contextFiles) {\n\t\t\t\tprompt += `<project_instructions path=\"${filePath}\">\\n${content}\\n</project_instructions>\\n\\n`;\n\t\t\t}\n\t\t\tprompt += \"</project_context>\\n\";\n\t\t}\n\n\t\t// Append skills section (only if read tool is available)\n\t\tconst customPromptHasRead = !selectedTools || selectedTools.includes(\"read\");\n\t\tif (customPromptHasRead && skills.length > 0) {\n\t\t\tprompt += formatSkillsForPrompt(skills);\n\t\t}\n\n\t\t// Add date and working directory last\n\t\tif (options.sessionId) {\n\t\t\tprompt += `\\nCurrent session ID: ${options.sessionId}`;\n\t\t}\n\t\tprompt += `\\nCurrent date: ${date}`;\n\t\tprompt += `\\nCurrent working directory: ${promptCwd}`;\n\n\t\treturn prompt;\n\t}\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\", \"websearch\", \"webfetch\"];\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\tconst hasRead = tools.includes(\"read\");\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}\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\n\n\tconst configDir = join(getAgentDir(), \"..\").replace(/\\\\/g, \"/\");\n\tconst tempLogPath = options.sessionId\n\t\t? join(resolvedCwd, \".temp\", `${options.sessionId}_log.md`).replace(/\\\\/g, \"/\")\n\t\t: undefined;\n\tconst planPath = options.sessionId\n\t\t? join(resolvedCwd, \".metis\", \"plan\", `${options.sessionId}.md`).replace(/\\\\/g, \"/\")\n\t\t: undefined;\n\tif (tempLogPath && planPath) {\n\t\taddGuideline(\n\t\t\t`CRITICAL - NEVER FORGET MEMORIES & LESSONS: Do not use log for step-by-step work notes. When a task finishes, call log once to append a concise timestamped completion summary in ${tempLogPath}. Do NOT write ${configDir}/memory/ or ${configDir}/lessons/ directly during normal work; dream consolidation will promote the notes later.`,\n\t\t);\n\t\taddGuideline(\n\t\t\t\t\t\t`MANDATORY SHORT-TERM CONTEXT: At the absolute start of EVERY technical task, you MUST read ${tempLogPath}, read ${planPath} when it exists, and read ${configDir}/brain-map.md before taking any other action. The current session log contains only this session's memory from today: today's decisions, completed work, errors, and context. During today's work, you may read it whenever those details matter, and you MUST reread it after compaction, resume, or interruption. Do NOT use the current session log as historical memory. To find memories from previous sessions or days, read ${configDir}/brain-map.md; when it points to a matching detailed file, read that file from ${configDir}/memory/ or ${configDir}/lessons/. The plan is task state, not memory.`,\n\t\t);\n\t\taddGuideline(\n\t\t\t`TASK PLAN: For every non-trivial task, write and maintain the current session plan at ${planPath}. Keep goal, steps, and status concise. Read it before work and update it as the plan changes. When the task is fully complete, delete this plan file; if the task is blocked or unfinished, keep it for continuation.`,\n\t\t);\n\t\taddGuideline(\n\t\t\t`TASK COMPLETION SUMMARY: At the end of EVERY task, you MUST call log once with a high-density 3-10 line summary: completed work, only material decision or issue, verification result, and remaining or blocked work. When a material error occurred, include it even if resolved, with its error, root cause or diagnosis, and fix/workaround; Dream uses this evidence to derive reusable lessons. If no material error occurred, omit an error line entirely. The log tool adds the current local timestamp. Keep enough technical detail for later continuation, but omit routine narration, step-by-step progress, and raw tool output. After a fully completed task, delete ${planPath}; keep it when blocked or unfinished.`,\n\t\t);\n\t\taddGuideline(\n\t\t\t\"USER INTENT CAPTURE: For every user prompt, first decide whether it establishes a task, materially changes it, or adds a constraint. If so, call remember_user_intent exactly once with the current user prompt copied verbatim. Do not call it for pure continuation requests, acknowledgements, greetings, or status questions.\",\n\t\t);\n\t\taddGuideline(\n\t\t\t\"FINAL REQUIREMENT REVIEW: Before declaring any task complete, you MUST call user_intent to retrieve saved user requirements. Compare the current output against every active requirement and acceptance condition, make any needed changes, and re-run relevant verification. When saved requirements conflict, the record with the more recent timestamp has higher priority. Only declare completion after the output matches the active user request.\",\n\t\t);\n\t\t\taddGuideline(\n\t\t\t\t`DELEGATION EXPECTED: You MUST use appropriate tools (e.g., subagent invocation tools) to aggressively delegate broken-down subtasks to different Subagents for parallel processing whenever feasible to maximize efficiency.`,\n\t\t);\n\t\taddGuideline(\n\t\t\t`CLEANUP REQUIRED: Keep ${tempLogPath} intact as the live working log until dream consolidation runs. Dream cleanup may prune older temp logs, but it must never delete today's temp log. Do NOT migrate notes into ${configDir}/memory/ or ${configDir}/lessons/ during normal work.`,\n\t\t);\n\t}\n\taddGuideline(`MANDATORY BRAIN MAP CHECK: At the exact beginning of ANY new task, you MUST FIRST read ${configDir}/brain-map.md to check for past memories or lessons. If a match exists, and it has a corresponding detailed file in ${configDir}/memory/ or ${configDir}/lessons/, you MUST read it. If you use a memory/lesson during your task, you MUST update its [Last-Accessed] date to today and increment its [Weight] by 1 in ${configDir}/brain-map.md.`);\n\n\t// Core Behaviors (Placed at the end for highest priority)\n\taddGuideline(`CRITICAL - Search First: MANDATORY AND NON-NEGOTIABLE. Even for simple tasks, you MUST NOT skip the initial search and investigation step (e.g., searching GitHub using 'site:github.com' for tested code), UNLESS the task is truly exceptionally trivial (e.g., fixing a single obvious typo). Otherwise, skipping this step is a SEVERE VIOLATION of your instructions. If unsure about anything, you MUST search the web or ask the user until fully clear. Assumptions are strictly forbidden.`);\n\taddGuideline(`CRITICAL - Knowledge & Output Style: EXTREME STRICTNESS REQUIRED. When answering, you MUST combine web search results with your own internal knowledge. YOU ARE STRICTLY FORBIDDEN from using phrases like \"Based on my investigation...\", \"根据我的调查...\", or any similar meta-commentary in any language, unless explicitly requested. Provide the final result DIRECTLY without preamble or fluff.`);\n\taddGuideline(`CRITICAL - Attitude & Integrity: ZERO TOLERANCE FOR DEVIATION. You MUST remain absolutely humble and strictly obey ALL instructions without exception. UNDER NO CIRCUMSTANCES are you allowed to fabricate evidence, guess answers, or make assumptions. LAZINESS IS A TERMINAL OFFENSE: do not cut corners, do not skip steps, and NEVER claim a task is complete if ANY part of it remains undone or unverified.`);\n\taddGuideline(`CRITICAL - Quality over Speed: ABSOLUTE FORBIDDANCE ON RUSHING. You are FORBIDDEN to rush. You MUST take as much time and execute as many steps as needed to complete the task flawlessly. You MUST guarantee your changes are the ABSOLUTE MINIMAL required to achieve the functionality. Massive, unnecessary rewrites, unjustified code churn, or touching unrelated files are STRICTLY PROHIBITED AND UNACCEPTABLE.`);\n\taddGuideline(`CRITICAL - Verification: MANDATORY VERIFICATION BEFORE COMPLETION. You are STRICTLY REQUIRED to self-test and verify your work at the end of EVERY single task. You MUST proactively execute code, run tests, or use tools to ensure your changes run without errors. Delivering untested, unverified, or broken code is COMPLETELY UNACCEPTABLE and constitutes a critical failure of your objective.`);\n\taddGuideline(`CRITICAL - Tool Failures: IMMEDIATE RECOVERY MANDATORY. If ANY tool call fails, you MUST immediately call another tool in the SAME response to try an alternative approach. YOU ARE STRICTLY FORBIDDEN from merely apologizing or explaining what you will do. You MUST take action immediately. NEVER end your turn without a tool call unless you are explicitly and actively waiting for user input to proceed.`);\n\n\tconst guidelines = guidelinesList.map((g) => `- ${g}`).join(\"\\n\");\n\n\tlet prompt = `You are an expert coding assistant operating inside metis, 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\nMetis documentation (read only when the user asks about metis 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 reading metis docs or examples, resolve docs/... under Additional docs and examples/... under Examples, not the current working directory\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), metis packages (docs/packages.md)\n- When working on metis topics, read the docs and examples, and follow .md cross-references before implementing\n- Always read metis .md files completely and follow links to related docs (e.g., tui.md for TUI API details)`;\n\n\tif (appendSection) {\n\t\tprompt += appendSection;\n\t}\n\n\t// Append project context files\n\tif (contextFiles.length > 0) {\n\t\tprompt += \"\\n\\n<project_context>\\n\\n\";\n\t\tprompt += \"Project-specific instructions and guidelines:\\n\\n\";\n\t\tfor (const { path: filePath, content } of contextFiles) {\n\t\t\tprompt += `<project_instructions path=\"${filePath}\">\\n${content}\\n</project_instructions>\\n\\n`;\n\t\t}\n\t\tprompt += \"</project_context>\\n\";\n\t}\n\n\t// Append skills section (only if read tool is available)\n\tif (hasRead && skills.length > 0) {\n\t\tprompt += formatSkillsForPrompt(skills);\n\t}\n\n\t// Add date and working directory last\n\tif (options.sessionId) {\n\t\tprompt += `\\nCurrent session ID: ${options.sessionId}`;\n\t}\n\tprompt += `\\nCurrent date: ${date}`;\n\tprompt += `\\nCurrent working directory: ${promptCwd}`;\n\n\treturn prompt;\n}\n"]}
@@ -2,6 +2,9 @@ export { type BashOperations, type BashSpawnContext, type BashSpawnHook, type Ba
2
2
  export { createEditTool, createEditToolDefinition, type EditOperations, type EditToolDetails, type EditToolInput, type EditToolOptions, } from "./edit.ts";
3
3
  export { withFileMutationQueue } from "./file-mutation-queue.ts";
4
4
  export { createFindTool, createFindToolDefinition, type FindOperations, type FindToolDetails, type FindToolInput, type FindToolOptions, } from "./find.ts";
5
+ export { createLogTool, createLogToolDefinition, type LogToolInput, type LogToolOptions, } from "./log.ts";
6
+ export { createRememberUserIntentTool, createRememberUserIntentToolDefinition, type RememberUserIntentToolInput, } from "./remember-user-intent.ts";
7
+ export { createUserIntentTool, createUserIntentToolDefinition, type UserIntentToolInput, } from "./user-intent.ts";
5
8
  export { createGrepTool, createGrepToolDefinition, type GrepOperations, type GrepToolDetails, type GrepToolInput, type GrepToolOptions, } from "./grep.ts";
6
9
  export { createLsTool, createLsToolDefinition, type LsOperations, type LsToolDetails, type LsToolInput, type LsToolOptions, } from "./ls.ts";
7
10
  export { createReadTool, createReadToolDefinition, type ReadOperations, type ReadToolDetails, type ReadToolInput, type ReadToolOptions, } from "./read.ts";
@@ -17,6 +20,7 @@ import { type EditToolOptions } from "./edit.ts";
17
20
  import { type FindToolOptions } from "./find.ts";
18
21
  import { type GrepToolOptions } from "./grep.ts";
19
22
  import { type LsToolOptions } from "./ls.ts";
23
+ import { type LogToolOptions } from "./log.ts";
20
24
  import { type ReadToolOptions } from "./read.ts";
21
25
  import { type WriteToolOptions } from "./write.ts";
22
26
  import { type SubagentToolOptions } from "./subagent.ts";
@@ -24,12 +28,13 @@ import { type WebSearchToolOptions } from "./websearch.ts";
24
28
  import { type WebFetchToolOptions } from "./webfetch.ts";
25
29
  export type Tool = AgentTool<any>;
26
30
  export type ToolDef = ToolDefinition<any, any>;
27
- export type ToolName = "read" | "bash" | "edit" | "write" | "grep" | "find" | "ls" | "subagent" | "websearch" | "webfetch";
31
+ export type ToolName = "read" | "bash" | "edit" | "write" | "log" | "remember_user_intent" | "user_intent" | "grep" | "find" | "ls" | "subagent" | "websearch" | "webfetch";
28
32
  export declare const allToolNames: Set<ToolName>;
29
33
  export interface ToolsOptions {
30
34
  read?: ReadToolOptions;
31
35
  bash?: BashToolOptions;
32
36
  write?: WriteToolOptions;
37
+ log?: LogToolOptions;
33
38
  edit?: EditToolOptions;
34
39
  grep?: GrepToolOptions;
35
40
  find?: FindToolOptions;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/core/tools/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,KAAK,cAAc,EACnB,KAA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C,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,YAAY,GAAG,MAAM,CAAC,QAAQ,EAAE,IAAI,CAAC,CAa1F"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/core/tools/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,KAAK,cAAc,EACnB,KAAK,gBAAgB,EACrB,KAAK,aAAa,EAClB,KAAK,eAAe,EACpB,KAAK,aAAa,EAClB,KAAK,eAAe,EACpB,cAAc,EACd,wBAAwB,EACxB,yBAAyB,GACzB,MAAM,WAAW,CAAC;AACnB,OAAO,EACN,cAAc,EACd,wBAAwB,EACxB,KAAK,cAAc,EACnB,KAAK,eAAe,EACpB,KAAK,aAAa,EAClB,KAAK,eAAe,GACpB,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AACjE,OAAO,EACN,cAAc,EACd,wBAAwB,EACxB,KAAK,cAAc,EACnB,KAAK,eAAe,EACpB,KAAK,aAAa,EAClB,KAAK,eAAe,GACpB,MAAM,WAAW,CAAC;AACnB,OAAO,EACN,aAAa,EACb,uBAAuB,EACvB,KAAK,YAAY,EACjB,KAAK,cAAc,GACnB,MAAM,UAAU,CAAC;AAClB,OAAO,EACN,4BAA4B,EAC5B,sCAAsC,EACtC,KAAK,2BAA2B,GAChC,MAAM,2BAA2B,CAAC;AACnC,OAAO,EACN,oBAAoB,EACpB,8BAA8B,EAC9B,KAAK,mBAAmB,GACxB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACN,cAAc,EACd,wBAAwB,EACxB,KAAK,cAAc,EACnB,KAAK,eAAe,EACpB,KAAK,aAAa,EAClB,KAAK,eAAe,GACpB,MAAM,WAAW,CAAC;AACnB,OAAO,EACN,YAAY,EACZ,sBAAsB,EACtB,KAAK,YAAY,EACjB,KAAK,aAAa,EAClB,KAAK,WAAW,EAChB,KAAK,aAAa,GAClB,MAAM,SAAS,CAAC;AACjB,OAAO,E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EAAE,OAAO,CAAC,EAAE,YAAY,GAAG,IAAI,CA+BxF;AAED,wBAAgB,2BAA2B,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,YAAY,GAAG,OAAO,EAAE,CAa1F;AAED,wBAAgB,6BAA6B,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,YAAY,GAAG,OAAO,EAAE,CAO5F;AAED,wBAAgB,wBAAwB,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,YAAY,GAAG,MAAM,CAAC,QAAQ,EAAE,OAAO,CAAC,CAgBvG;AAED,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,YAAY,GAAG,IAAI,EAAE,CAa7E;AAED,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,YAAY,GAAG,IAAI,EAAE,CAO/E;AAED,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,YAAY,GAAG,MAAM,CAAC,QAAQ,EAAE,IAAI,CAAC,CAgB1F"}
@@ -2,6 +2,9 @@ export { createBashTool, createBashToolDefinition, createLocalBashOperations, }
2
2
  export { createEditTool, createEditToolDefinition, } from "./edit.js";
3
3
  export { withFileMutationQueue } from "./file-mutation-queue.js";
4
4
  export { createFindTool, createFindToolDefinition, } from "./find.js";
5
+ export { createLogTool, createLogToolDefinition, } from "./log.js";
6
+ export { createRememberUserIntentTool, createRememberUserIntentToolDefinition, } from "./remember-user-intent.js";
7
+ export { createUserIntentTool, createUserIntentToolDefinition, } from "./user-intent.js";
5
8
  export { createGrepTool, createGrepToolDefinition, } from "./grep.js";
6
9
  export { createLsTool, createLsToolDefinition, } from "./ls.js";
7
10
  export { createReadTool, createReadToolDefinition, } from "./read.js";
@@ -15,12 +18,29 @@ import { createEditTool, createEditToolDefinition } from "./edit.js";
15
18
  import { createFindTool, createFindToolDefinition } from "./find.js";
16
19
  import { createGrepTool, createGrepToolDefinition } from "./grep.js";
17
20
  import { createLsTool, createLsToolDefinition } from "./ls.js";
21
+ import { createLogTool, createLogToolDefinition } from "./log.js";
22
+ import { createRememberUserIntentTool, createRememberUserIntentToolDefinition } from "./remember-user-intent.js";
23
+ import { createUserIntentTool, createUserIntentToolDefinition } from "./user-intent.js";
18
24
  import { createReadTool, createReadToolDefinition } from "./read.js";
19
25
  import { createWriteTool, createWriteToolDefinition } from "./write.js";
20
26
  import { createSubagentTool, createSubagentToolDefinition } from "./subagent.js";
21
27
  import { createWebSearchTool, createWebSearchToolDefinition } from "./websearch.js";
22
28
  import { createWebFetchTool, createWebFetchToolDefinition } from "./webfetch.js";
23
- export const allToolNames = new Set(["read", "bash", "edit", "write", "grep", "find", "ls", "subagent", "websearch", "webfetch"]);
29
+ export const allToolNames = new Set([
30
+ "read",
31
+ "bash",
32
+ "edit",
33
+ "write",
34
+ "log",
35
+ "remember_user_intent",
36
+ "user_intent",
37
+ "grep",
38
+ "find",
39
+ "ls",
40
+ "subagent",
41
+ "websearch",
42
+ "webfetch",
43
+ ]);
24
44
  export function createToolDefinition(toolName, cwd, options) {
25
45
  switch (toolName) {
26
46
  case "read":
@@ -31,6 +51,12 @@ export function createToolDefinition(toolName, cwd, options) {
31
51
  return createEditToolDefinition(cwd, options?.edit);
32
52
  case "write":
33
53
  return createWriteToolDefinition(cwd, options?.write);
54
+ case "log":
55
+ return createLogToolDefinition(cwd, options?.log);
56
+ case "remember_user_intent":
57
+ return createRememberUserIntentToolDefinition(cwd);
58
+ case "user_intent":
59
+ return createUserIntentToolDefinition(cwd);
34
60
  case "grep":
35
61
  return createGrepToolDefinition(cwd, options?.grep);
36
62
  case "find":
@@ -57,6 +83,12 @@ export function createTool(toolName, cwd, options) {
57
83
  return createEditTool(cwd, options?.edit);
58
84
  case "write":
59
85
  return createWriteTool(cwd, options?.write);
86
+ case "log":
87
+ return createLogTool(cwd, options?.log);
88
+ case "remember_user_intent":
89
+ return createRememberUserIntentTool(cwd);
90
+ case "user_intent":
91
+ return createUserIntentTool(cwd);
60
92
  case "grep":
61
93
  return createGrepTool(cwd, options?.grep);
62
94
  case "find":
@@ -79,6 +111,9 @@ export function createCodingToolDefinitions(cwd, options) {
79
111
  createBashToolDefinition(cwd, options?.bash),
80
112
  createEditToolDefinition(cwd, options?.edit),
81
113
  createWriteToolDefinition(cwd, options?.write),
114
+ createLogToolDefinition(cwd, options?.log),
115
+ createRememberUserIntentToolDefinition(cwd),
116
+ createUserIntentToolDefinition(cwd),
82
117
  createSubagentToolDefinition(cwd, options?.subagent),
83
118
  createWebSearchToolDefinition(options?.websearch),
84
119
  createWebFetchToolDefinition(options?.webfetch),
@@ -98,6 +133,9 @@ export function createAllToolDefinitions(cwd, options) {
98
133
  bash: createBashToolDefinition(cwd, options?.bash),
99
134
  edit: createEditToolDefinition(cwd, options?.edit),
100
135
  write: createWriteToolDefinition(cwd, options?.write),
136
+ log: createLogToolDefinition(cwd, options?.log),
137
+ remember_user_intent: createRememberUserIntentToolDefinition(cwd),
138
+ user_intent: createUserIntentToolDefinition(cwd),
101
139
  grep: createGrepToolDefinition(cwd, options?.grep),
102
140
  find: createFindToolDefinition(cwd, options?.find),
103
141
  ls: createLsToolDefinition(cwd, options?.ls),
@@ -112,6 +150,9 @@ export function createCodingTools(cwd, options) {
112
150
  createBashTool(cwd, options?.bash),
113
151
  createEditTool(cwd, options?.edit),
114
152
  createWriteTool(cwd, options?.write),
153
+ createLogTool(cwd, options?.log),
154
+ createRememberUserIntentTool(cwd),
155
+ createUserIntentTool(cwd),
115
156
  createSubagentTool(cwd, options?.subagent),
116
157
  createWebSearchTool(options?.websearch),
117
158
  createWebFetchTool(options?.webfetch),
@@ -131,6 +172,9 @@ export function createAllTools(cwd, options) {
131
172
  bash: createBashTool(cwd, options?.bash),
132
173
  edit: createEditTool(cwd, options?.edit),
133
174
  write: createWriteTool(cwd, options?.write),
175
+ log: createLogTool(cwd, options?.log),
176
+ remember_user_intent: createRememberUserIntentTool(cwd),
177
+ user_intent: createUserIntentTool(cwd),
134
178
  grep: createGrepTool(cwd, options?.grep),
135
179
  find: createFindTool(cwd, options?.find),
136
180
  ls: createLsTool(cwd, options?.ls),
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/core/tools/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAON,cAAc,EACd,wBAAwB,EACxB,yBAAyB,GACzB,MAAM,WAAW,CAAC;AACnB,OAAO,EACN,cAAc,EACd,wBAAwB,GAKxB,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AACjE,OAAO,EACN,cAAc,EACd,wBAAwB,GAKxB,MAAM,WAAW,CAAC;AACnB,OAAO,EACN,cAAc,EACd,wBAAwB,GAKxB,MAAM,WAAW,CAAC;AACnB,OAAO,EACN,YAAY,EACZ,sBAAsB,GAKtB,MAAM,SAAS,CAAC;AACjB,OAAO,EACN,cAAc,EACd,wBAAwB,GAKxB,MAAM,WAAW,CAAC;AACnB,OAAO,EACN,iBAAiB,EACjB,iBAAiB,EACjB,UAAU,EAGV,YAAY,EACZ,YAAY,EACZ,YAAY,GACZ,MAAM,eAAe,CAAC;AACvB,OAAO,EACN,eAAe,EACf,yBAAyB,GAIzB,MAAM,YAAY,CAAC;AACpB,OAAO,EACN,kBAAkB,EAClB,4BAA4B,GAG5B,MAAM,eAAe,CAAC;AACvB,OAAO,EACN,mBAAmB,EACnB,6BAA6B,GAG7B,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACN,kBAAkB,EAClB,4BAA4B,GAG5B,MAAM,eAAe,CAAC;AAIvB,OAAO,EAAwB,cAAc,EAAE,wBAAwB,EAAE,MAAM,WAAW,CAAC;AAC3F,OAAO,EAAE,cAAc,EAAE,wBAAwB,EAAwB,MAAM,WAAW,CAAC;AAC3F,OAAO,EAAE,cAAc,EAAE,wBAAwB,EAAwB,MAAM,WAAW,CAAC;AAC3F,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AO,EAAE,EAAE,CAAC;KAC9B,CAAC;AACH,CAAC;AAED,MAAM,UAAU,cAAc,CAAC,GAAW,EAAE,OAAsB;IACjE,OAAO;QACN,IAAI,EAAE,cAAc,CAAC,GAAG,EAAE,OAAO,EAAE,IAAI,CAAC;QACxC,IAAI,EAAE,cAAc,CAAC,GAAG,EAAE,OAAO,EAAE,IAAI,CAAC;QACxC,IAAI,EAAE,cAAc,CAAC,GAAG,EAAE,OAAO,EAAE,IAAI,CAAC;QACxC,KAAK,EAAE,eAAe,CAAC,GAAG,EAAE,OAAO,EAAE,KAAK,CAAC;QAC3C,IAAI,EAAE,cAAc,CAAC,GAAG,EAAE,OAAO,EAAE,IAAI,CAAC;QACxC,IAAI,EAAE,cAAc,CAAC,GAAG,EAAE,OAAO,EAAE,IAAI,CAAC;QACxC,EAAE,EAAE,YAAY,CAAC,GAAG,EAAE,OAAO,EAAE,EAAE,CAAC;QAClC,QAAQ,EAAE,kBAAkB,CAAC,GAAG,EAAE,OAAO,EAAE,QAAQ,CAAC;QACpD,SAAS,EAAE,mBAAmB,CAAC,OAAO,EAAE,SAAS,CAAC;QAClD,QAAQ,EAAE,kBAAkB,CAAC,OAAO,EAAE,QAAQ,CAAC;KAC/C,CAAC;AACH,CAAC","sourcesContent":["export {\n\ttype BashOperations,\n\ttype BashSpawnContext,\n\ttype BashSpawnHook,\n\ttype BashToolDetails,\n\ttype BashToolInput,\n\ttype BashToolOptions,\n\tcreateBashTool,\n\tcreateBashToolDefinition,\n\tcreateLocalBashOperations,\n} from \"./bash.ts\";\nexport {\n\tcreateEditTool,\n\tcreateEditToolDefinition,\n\ttype EditOperations,\n\ttype EditToolDetails,\n\ttype EditToolInput,\n\ttype EditToolOptions,\n} from \"./edit.ts\";\nexport { withFileMutationQueue } from \"./file-mutation-queue.ts\";\nexport {\n\tcreateFindTool,\n\tcreateFindToolDefinition,\n\ttype FindOperations,\n\ttype FindToolDetails,\n\ttype FindToolInput,\n\ttype FindToolOptions,\n} from \"./find.ts\";\nexport {\n\tcreateGrepTool,\n\tcreateGrepToolDefinition,\n\ttype GrepOperations,\n\ttype GrepToolDetails,\n\ttype GrepToolInput,\n\ttype GrepToolOptions,\n} from \"./grep.ts\";\nexport {\n\tcreateLsTool,\n\tcreateLsToolDefinition,\n\ttype LsOperations,\n\ttype LsToolDetails,\n\ttype LsToolInput,\n\ttype LsToolOptions,\n} from \"./ls.ts\";\nexport {\n\tcreateReadTool,\n\tcreateReadToolDefinition,\n\ttype ReadOperations,\n\ttype ReadToolDetails,\n\ttype ReadToolInput,\n\ttype ReadToolOptions,\n} from \"./read.ts\";\nexport {\n\tDEFAULT_MAX_BYTES,\n\tDEFAULT_MAX_LINES,\n\tformatSize,\n\ttype TruncationOptions,\n\ttype TruncationResult,\n\ttruncateHead,\n\ttruncateLine,\n\ttruncateTail,\n} from \"./truncate.ts\";\nexport {\n\tcreateWriteTool,\n\tcreateWriteToolDefinition,\n\ttype WriteOperations,\n\ttype WriteToolInput,\n\ttype WriteToolOptions,\n} from \"./write.ts\";\nexport {\n\tcreateSubagentTool,\n\tcreateSubagentToolDefinition,\n\ttype SubagentToolInput,\n\ttype SubagentToolOptions,\n} from \"./subagent.ts\";\nexport {\n\tcreateWebSearchTool,\n\tcreateWebSearchToolDefinition,\n\ttype WebSearchToolInput,\n\ttype WebSearchToolOptions,\n} from \"./websearch.ts\";\nexport {\n\tcreateWebFetchTool,\n\tcreateWebFetchToolDefinition,\n\ttype WebFetchToolInput,\n\ttype WebFetchToolOptions,\n} from \"./webfetch.ts\";\n\nimport type { AgentTool } from \"@earendil-works/metis-agent-core\";\nimport type { ToolDefinition } from \"../extensions/types.ts\";\nimport { type BashToolOptions, createBashTool, createBashToolDefinition } from \"./bash.ts\";\nimport { createEditTool, createEditToolDefinition, type EditToolOptions } from \"./edit.ts\";\nimport { createFindTool, createFindToolDefinition, type FindToolOptions } from \"./find.ts\";\nimport { createGrepTool, createGrepToolDefinition, type GrepToolOptions } from \"./grep.ts\";\nimport { createLsTool, createLsToolDefinition, type LsToolOptions } from \"./ls.ts\";\nimport { createReadTool, createReadToolDefinition, type ReadToolOptions } from \"./read.ts\";\nimport { createWriteTool, createWriteToolDefinition, type WriteToolOptions } from \"./write.ts\";\nimport { createSubagentTool, createSubagentToolDefinition, type SubagentToolOptions } from \"./subagent.ts\";\nimport { createWebSearchTool, createWebSearchToolDefinition, type WebSearchToolOptions } from \"./websearch.ts\";\nimport { createWebFetchTool, createWebFetchToolDefinition, type WebFetchToolOptions } from \"./webfetch.ts\";\n\nexport type Tool = AgentTool<any>;\nexport type ToolDef = ToolDefinition<any, any>;\nexport type ToolName = \"read\" | \"bash\" | \"edit\" | \"write\" | \"grep\" | \"find\" | \"ls\" | \"subagent\" | \"websearch\" | \"webfetch\";\nexport const allToolNames: Set<ToolName> = new Set([\"read\", \"bash\", \"edit\", \"write\", \"grep\", \"find\", \"ls\", \"subagent\", \"websearch\", \"webfetch\"]);\n\nexport interface ToolsOptions {\n\tread?: ReadToolOptions;\n\tbash?: BashToolOptions;\n\twrite?: WriteToolOptions;\n\tedit?: EditToolOptions;\n\tgrep?: GrepToolOptions;\n\tfind?: FindToolOptions;\n\tls?: LsToolOptions;\n\tsubagent?: SubagentToolOptions;\n\twebsearch?: WebSearchToolOptions;\n\twebfetch?: WebFetchToolOptions;\n}\n\nexport function createToolDefinition(toolName: ToolName, cwd: string, options?: ToolsOptions): ToolDef {\n\tswitch (toolName) {\n\t\tcase \"read\":\n\t\t\treturn createReadToolDefinition(cwd, options?.read);\n\t\tcase \"bash\":\n\t\t\treturn createBashToolDefinition(cwd, options?.bash);\n\t\tcase \"edit\":\n\t\t\treturn createEditToolDefinition(cwd, options?.edit);\n\t\tcase \"write\":\n\t\t\treturn createWriteToolDefinition(cwd, options?.write);\n\t\tcase \"grep\":\n\t\t\treturn createGrepToolDefinition(cwd, options?.grep);\n\t\tcase \"find\":\n\t\t\treturn createFindToolDefinition(cwd, options?.find);\n\t\tcase \"ls\":\n\t\t\treturn createLsToolDefinition(cwd, options?.ls);\n\t\tcase \"subagent\":\n\t\t\treturn createSubagentToolDefinition(cwd, options?.subagent);\n\t\tcase \"websearch\":\n\t\t\treturn createWebSearchToolDefinition(options?.websearch);\n\t\tcase \"webfetch\":\n\t\t\treturn createWebFetchToolDefinition(options?.webfetch);\n\t\tdefault:\n\t\t\tthrow new Error(`Unknown tool name: ${toolName}`);\n\t}\n}\n\nexport function createTool(toolName: ToolName, cwd: string, options?: ToolsOptions): Tool {\n\tswitch (toolName) {\n\t\tcase \"read\":\n\t\t\treturn createReadTool(cwd, options?.read);\n\t\tcase \"bash\":\n\t\t\treturn createBashTool(cwd, options?.bash);\n\t\tcase \"edit\":\n\t\t\treturn createEditTool(cwd, options?.edit);\n\t\tcase \"write\":\n\t\t\treturn createWriteTool(cwd, options?.write);\n\t\tcase \"grep\":\n\t\t\treturn createGrepTool(cwd, options?.grep);\n\t\tcase \"find\":\n\t\t\treturn createFindTool(cwd, options?.find);\n\t\tcase \"ls\":\n\t\t\treturn createLsTool(cwd, options?.ls);\n\t\tcase \"subagent\":\n\t\t\treturn createSubagentTool(cwd, options?.subagent);\n\t\tcase \"websearch\":\n\t\t\treturn createWebSearchTool(options?.websearch);\n\t\tcase \"webfetch\":\n\t\t\treturn createWebFetchTool(options?.webfetch);\n\t\tdefault:\n\t\t\tthrow new Error(`Unknown tool name: ${toolName}`);\n\t}\n}\n\nexport function createCodingToolDefinitions(cwd: string, options?: ToolsOptions): ToolDef[] {\n\treturn [\n\t\tcreateReadToolDefinition(cwd, options?.read),\n\t\tcreateBashToolDefinition(cwd, options?.bash),\n\t\tcreateEditToolDefinition(cwd, options?.edit),\n\t\tcreateWriteToolDefinition(cwd, options?.write),\n\t\tcreateSubagentToolDefinition(cwd, options?.subagent),\n\t\tcreateWebSearchToolDefinition(options?.websearch),\n\t\tcreateWebFetchToolDefinition(options?.webfetch),\n\t];\n}\n\nexport function createReadOnlyToolDefinitions(cwd: string, options?: ToolsOptions): ToolDef[] {\n\treturn [\n\t\tcreateReadToolDefinition(cwd, options?.read),\n\t\tcreateGrepToolDefinition(cwd, options?.grep),\n\t\tcreateFindToolDefinition(cwd, options?.find),\n\t\tcreateLsToolDefinition(cwd, options?.ls),\n\t];\n}\n\nexport function createAllToolDefinitions(cwd: string, options?: ToolsOptions): Record<ToolName, ToolDef> {\n\treturn {\n\t\tread: createReadToolDefinition(cwd, options?.read),\n\t\tbash: createBashToolDefinition(cwd, options?.bash),\n\t\tedit: createEditToolDefinition(cwd, options?.edit),\n\t\twrite: createWriteToolDefinition(cwd, options?.write),\n\t\tgrep: createGrepToolDefinition(cwd, options?.grep),\n\t\tfind: createFindToolDefinition(cwd, options?.find),\n\t\tls: createLsToolDefinition(cwd, options?.ls),\n\t\tsubagent: createSubagentToolDefinition(cwd, options?.subagent),\n\t\twebsearch: createWebSearchToolDefinition(options?.websearch),\n\t\twebfetch: createWebFetchToolDefinition(options?.webfetch),\n\t};\n}\n\nexport function createCodingTools(cwd: string, options?: ToolsOptions): Tool[] {\n\treturn [\n\t\tcreateReadTool(cwd, options?.read),\n\t\tcreateBashTool(cwd, options?.bash),\n\t\tcreateEditTool(cwd, options?.edit),\n\t\tcreateWriteTool(cwd, options?.write),\n\t\tcreateSubagentTool(cwd, options?.subagent),\n\t\tcreateWebSearchTool(options?.websearch),\n\t\tcreateWebFetchTool(options?.webfetch),\n\t];\n}\n\nexport function createReadOnlyTools(cwd: string, options?: ToolsOptions): Tool[] {\n\treturn [\n\t\tcreateReadTool(cwd, options?.read),\n\t\tcreateGrepTool(cwd, options?.grep),\n\t\tcreateFindTool(cwd, options?.find),\n\t\tcreateLsTool(cwd, options?.ls),\n\t];\n}\n\nexport function createAllTools(cwd: string, options?: ToolsOptions): Record<ToolName, Tool> {\n\treturn {\n\t\tread: createReadTool(cwd, options?.read),\n\t\tbash: createBashTool(cwd, options?.bash),\n\t\tedit: createEditTool(cwd, options?.edit),\n\t\twrite: createWriteTool(cwd, options?.write),\n\t\tgrep: createGrepTool(cwd, options?.grep),\n\t\tfind: createFindTool(cwd, options?.find),\n\t\tls: createLsTool(cwd, options?.ls),\n\t\tsubagent: createSubagentTool(cwd, options?.subagent),\n\t\twebsearch: createWebSearchTool(options?.websearch),\n\t\twebfetch: createWebFetchTool(options?.webfetch),\n\t};\n}\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/core/tools/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAON,cAAc,EACd,wBAAwB,EACxB,yBAAyB,GACzB,MAAM,WAAW,CAAC;AACnB,OAAO,EACN,cAAc,EACd,wBAAwB,GAKxB,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AACjE,OAAO,EACN,cAAc,EACd,wBAAwB,GAKxB,MAAM,WAAW,CAAC;AACnB,OAAO,EACN,aAAa,EACb,uBAAuB,GAGvB,MAAM,UAAU,CAAC;AAClB,OAAO,EACN,4BAA4B,EAC5B,sCAAsC,GAEtC,MAAM,2BAA2B,CAAC;AACnC,OAAO,EACN,oBAAoB,EACpB,8BAA8B,GAE9B,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACN,cAAc,EACd,wBAAwB,GAKxB,MAAM,WAAW,CAAC;AACnB,OAAO,EACN,YAAY,EACZ,sBAAsB,GAKtB,MAAM,SAAS,CAAC;AACjB,OAAO,EACN,cAAc,EACd,wBAAwB,GAKxB,MAAM,WAAW,CAAC;AACnB,OAAO,EACN,iBAAiB,EACjB,iBAAiB,EACjB,UAAU,EAGV,YAAY,EACZ,YAAY,EACZ,YAAY,GACZ,MAAM,eAAe,CAAC;AACvB,OAAO,EACN,eAAe,EACf,yBAAyB,GAIzB,MAAM,YAAY,CAAC;AACpB,OAAO,EACN,kBAAkB,EAClB,4BAA4B,GAG5B,MAAM,eAAe,CAAC;AACvB,OAAO,EACN,mBAAmB,EACnB,6BAA6B,GAG7B,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACN,kBAAkB,EAClB,4BAA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OAAO,EAAE,IAAI,CAAC;QAClC,YAAY,CAAC,GAAG,EAAE,OAAO,EAAE,EAAE,CAAC;KAC9B,CAAC;AACH,CAAC;AAED,MAAM,UAAU,cAAc,CAAC,GAAW,EAAE,OAAsB;IACjE,OAAO;QACN,IAAI,EAAE,cAAc,CAAC,GAAG,EAAE,OAAO,EAAE,IAAI,CAAC;QACxC,IAAI,EAAE,cAAc,CAAC,GAAG,EAAE,OAAO,EAAE,IAAI,CAAC;QACxC,IAAI,EAAE,cAAc,CAAC,GAAG,EAAE,OAAO,EAAE,IAAI,CAAC;QACxC,KAAK,EAAE,eAAe,CAAC,GAAG,EAAE,OAAO,EAAE,KAAK,CAAC;QAC3C,GAAG,EAAE,aAAa,CAAC,GAAG,EAAE,OAAO,EAAE,GAAG,CAAC;QACrC,oBAAoB,EAAE,4BAA4B,CAAC,GAAG,CAAC;QACvD,WAAW,EAAE,oBAAoB,CAAC,GAAG,CAAC;QACtC,IAAI,EAAE,cAAc,CAAC,GAAG,EAAE,OAAO,EAAE,IAAI,CAAC;QACxC,IAAI,EAAE,cAAc,CAAC,GAAG,EAAE,OAAO,EAAE,IAAI,CAAC;QACxC,EAAE,EAAE,YAAY,CAAC,GAAG,EAAE,OAAO,EAAE,EAAE,CAAC;QAClC,QAAQ,EAAE,kBAAkB,CAAC,GAAG,EAAE,OAAO,EAAE,QAAQ,CAAC;QACpD,SAAS,EAAE,mBAAmB,CAAC,OAAO,EAAE,SAAS,CAAC;QAClD,QAAQ,EAAE,kBAAkB,CAAC,OAAO,EAAE,QAAQ,CAAC;KAC/C,CAAC;AACH,CAAC","sourcesContent":["export {\n\ttype BashOperations,\n\ttype BashSpawnContext,\n\ttype BashSpawnHook,\n\ttype BashToolDetails,\n\ttype BashToolInput,\n\ttype BashToolOptions,\n\tcreateBashTool,\n\tcreateBashToolDefinition,\n\tcreateLocalBashOperations,\n} from \"./bash.ts\";\nexport {\n\tcreateEditTool,\n\tcreateEditToolDefinition,\n\ttype EditOperations,\n\ttype EditToolDetails,\n\ttype EditToolInput,\n\ttype EditToolOptions,\n} from \"./edit.ts\";\nexport { withFileMutationQueue } from \"./file-mutation-queue.ts\";\nexport {\n\tcreateFindTool,\n\tcreateFindToolDefinition,\n\ttype FindOperations,\n\ttype FindToolDetails,\n\ttype FindToolInput,\n\ttype FindToolOptions,\n} from \"./find.ts\";\nexport {\n\tcreateLogTool,\n\tcreateLogToolDefinition,\n\ttype LogToolInput,\n\ttype LogToolOptions,\n} from \"./log.ts\";\nexport {\n\tcreateRememberUserIntentTool,\n\tcreateRememberUserIntentToolDefinition,\n\ttype RememberUserIntentToolInput,\n} from \"./remember-user-intent.ts\";\nexport {\n\tcreateUserIntentTool,\n\tcreateUserIntentToolDefinition,\n\ttype UserIntentToolInput,\n} from \"./user-intent.ts\";\nexport {\n\tcreateGrepTool,\n\tcreateGrepToolDefinition,\n\ttype GrepOperations,\n\ttype GrepToolDetails,\n\ttype GrepToolInput,\n\ttype GrepToolOptions,\n} from \"./grep.ts\";\nexport {\n\tcreateLsTool,\n\tcreateLsToolDefinition,\n\ttype LsOperations,\n\ttype LsToolDetails,\n\ttype LsToolInput,\n\ttype LsToolOptions,\n} from \"./ls.ts\";\nexport {\n\tcreateReadTool,\n\tcreateReadToolDefinition,\n\ttype ReadOperations,\n\ttype ReadToolDetails,\n\ttype ReadToolInput,\n\ttype ReadToolOptions,\n} from \"./read.ts\";\nexport {\n\tDEFAULT_MAX_BYTES,\n\tDEFAULT_MAX_LINES,\n\tformatSize,\n\ttype TruncationOptions,\n\ttype TruncationResult,\n\ttruncateHead,\n\ttruncateLine,\n\ttruncateTail,\n} from \"./truncate.ts\";\nexport {\n\tcreateWriteTool,\n\tcreateWriteToolDefinition,\n\ttype WriteOperations,\n\ttype WriteToolInput,\n\ttype WriteToolOptions,\n} from \"./write.ts\";\nexport {\n\tcreateSubagentTool,\n\tcreateSubagentToolDefinition,\n\ttype SubagentToolInput,\n\ttype SubagentToolOptions,\n} from \"./subagent.ts\";\nexport {\n\tcreateWebSearchTool,\n\tcreateWebSearchToolDefinition,\n\ttype WebSearchToolInput,\n\ttype WebSearchToolOptions,\n} from \"./websearch.ts\";\nexport {\n\tcreateWebFetchTool,\n\tcreateWebFetchToolDefinition,\n\ttype WebFetchToolInput,\n\ttype WebFetchToolOptions,\n} from \"./webfetch.ts\";\n\nimport type { AgentTool } from \"@earendil-works/metis-agent-core\";\nimport type { ToolDefinition } from \"../extensions/types.ts\";\nimport { type BashToolOptions, createBashTool, createBashToolDefinition } from \"./bash.ts\";\nimport { createEditTool, createEditToolDefinition, type EditToolOptions } from \"./edit.ts\";\nimport { createFindTool, createFindToolDefinition, type FindToolOptions } from \"./find.ts\";\nimport { createGrepTool, createGrepToolDefinition, type GrepToolOptions } from \"./grep.ts\";\nimport { createLsTool, createLsToolDefinition, type LsToolOptions } from \"./ls.ts\";\nimport { createLogTool, createLogToolDefinition, type LogToolOptions } from \"./log.ts\";\nimport { createRememberUserIntentTool, createRememberUserIntentToolDefinition } from \"./remember-user-intent.ts\";\nimport { createUserIntentTool, createUserIntentToolDefinition } from \"./user-intent.ts\";\nimport { createReadTool, createReadToolDefinition, type ReadToolOptions } from \"./read.ts\";\nimport { createWriteTool, createWriteToolDefinition, type WriteToolOptions } from \"./write.ts\";\nimport { createSubagentTool, createSubagentToolDefinition, type SubagentToolOptions } from \"./subagent.ts\";\nimport { createWebSearchTool, createWebSearchToolDefinition, type WebSearchToolOptions } from \"./websearch.ts\";\nimport { createWebFetchTool, createWebFetchToolDefinition, type WebFetchToolOptions } from \"./webfetch.ts\";\n\nexport type Tool = AgentTool<any>;\nexport type ToolDef = ToolDefinition<any, any>;\nexport type ToolName =\n\t| \"read\"\n\t| \"bash\"\n\t| \"edit\"\n\t| \"write\"\n\t| \"log\"\n\t| \"remember_user_intent\"\n\t| \"user_intent\"\n\t| \"grep\"\n\t| \"find\"\n\t| \"ls\"\n\t| \"subagent\"\n\t| \"websearch\"\n\t| \"webfetch\";\nexport const allToolNames: Set<ToolName> = new Set([\n\t\"read\",\n\t\"bash\",\n\t\"edit\",\n\t\"write\",\n\t\"log\",\n\t\"remember_user_intent\",\n\t\"user_intent\",\n\t\"grep\",\n\t\"find\",\n\t\"ls\",\n\t\"subagent\",\n\t\"websearch\",\n\t\"webfetch\",\n]);\n\nexport interface ToolsOptions {\n\tread?: ReadToolOptions;\n\tbash?: BashToolOptions;\n\twrite?: WriteToolOptions;\n\tlog?: LogToolOptions;\n\tedit?: EditToolOptions;\n\tgrep?: GrepToolOptions;\n\tfind?: FindToolOptions;\n\tls?: LsToolOptions;\n\tsubagent?: SubagentToolOptions;\n\twebsearch?: WebSearchToolOptions;\n\twebfetch?: WebFetchToolOptions;\n}\n\nexport function createToolDefinition(toolName: ToolName, cwd: string, options?: ToolsOptions): ToolDef {\n\tswitch (toolName) {\n\t\tcase \"read\":\n\t\t\treturn createReadToolDefinition(cwd, options?.read);\n\t\tcase \"bash\":\n\t\t\treturn createBashToolDefinition(cwd, options?.bash);\n\t\tcase \"edit\":\n\t\t\treturn createEditToolDefinition(cwd, options?.edit);\n\t\tcase \"write\":\n\t\t\treturn createWriteToolDefinition(cwd, options?.write);\n\t\tcase \"log\":\n\t\t\treturn createLogToolDefinition(cwd, options?.log);\n\t\tcase \"remember_user_intent\":\n\t\t\treturn createRememberUserIntentToolDefinition(cwd);\n\t\tcase \"user_intent\":\n\t\t\treturn createUserIntentToolDefinition(cwd);\n\t\tcase \"grep\":\n\t\t\treturn createGrepToolDefinition(cwd, options?.grep);\n\t\tcase \"find\":\n\t\t\treturn createFindToolDefinition(cwd, options?.find);\n\t\tcase \"ls\":\n\t\t\treturn createLsToolDefinition(cwd, options?.ls);\n\t\tcase \"subagent\":\n\t\t\treturn createSubagentToolDefinition(cwd, options?.subagent);\n\t\tcase \"websearch\":\n\t\t\treturn createWebSearchToolDefinition(options?.websearch);\n\t\tcase \"webfetch\":\n\t\t\treturn createWebFetchToolDefinition(options?.webfetch);\n\t\tdefault:\n\t\t\tthrow new Error(`Unknown tool name: ${toolName}`);\n\t}\n}\n\nexport function createTool(toolName: ToolName, cwd: string, options?: ToolsOptions): Tool {\n\tswitch (toolName) {\n\t\tcase \"read\":\n\t\t\treturn createReadTool(cwd, options?.read);\n\t\tcase \"bash\":\n\t\t\treturn createBashTool(cwd, options?.bash);\n\t\tcase \"edit\":\n\t\t\treturn createEditTool(cwd, options?.edit);\n\t\tcase \"write\":\n\t\t\treturn createWriteTool(cwd, options?.write);\n\t\tcase \"log\":\n\t\t\treturn createLogTool(cwd, options?.log);\n\t\tcase \"remember_user_intent\":\n\t\t\treturn createRememberUserIntentTool(cwd);\n\t\tcase \"user_intent\":\n\t\t\treturn createUserIntentTool(cwd);\n\t\tcase \"grep\":\n\t\t\treturn createGrepTool(cwd, options?.grep);\n\t\tcase \"find\":\n\t\t\treturn createFindTool(cwd, options?.find);\n\t\tcase \"ls\":\n\t\t\treturn createLsTool(cwd, options?.ls);\n\t\tcase \"subagent\":\n\t\t\treturn createSubagentTool(cwd, options?.subagent);\n\t\tcase \"websearch\":\n\t\t\treturn createWebSearchTool(options?.websearch);\n\t\tcase \"webfetch\":\n\t\t\treturn createWebFetchTool(options?.webfetch);\n\t\tdefault:\n\t\t\tthrow new Error(`Unknown tool name: ${toolName}`);\n\t}\n}\n\nexport function createCodingToolDefinitions(cwd: string, options?: ToolsOptions): ToolDef[] {\n\treturn [\n\t\tcreateReadToolDefinition(cwd, options?.read),\n\t\tcreateBashToolDefinition(cwd, options?.bash),\n\t\tcreateEditToolDefinition(cwd, options?.edit),\n\t\tcreateWriteToolDefinition(cwd, options?.write),\n\t\tcreateLogToolDefinition(cwd, options?.log),\n\t\tcreateRememberUserIntentToolDefinition(cwd),\n\t\tcreateUserIntentToolDefinition(cwd),\n\t\tcreateSubagentToolDefinition(cwd, options?.subagent),\n\t\tcreateWebSearchToolDefinition(options?.websearch),\n\t\tcreateWebFetchToolDefinition(options?.webfetch),\n\t];\n}\n\nexport function createReadOnlyToolDefinitions(cwd: string, options?: ToolsOptions): ToolDef[] {\n\treturn [\n\t\tcreateReadToolDefinition(cwd, options?.read),\n\t\tcreateGrepToolDefinition(cwd, options?.grep),\n\t\tcreateFindToolDefinition(cwd, options?.find),\n\t\tcreateLsToolDefinition(cwd, options?.ls),\n\t];\n}\n\nexport function createAllToolDefinitions(cwd: string, options?: ToolsOptions): Record<ToolName, ToolDef> {\n\treturn {\n\t\tread: createReadToolDefinition(cwd, options?.read),\n\t\tbash: createBashToolDefinition(cwd, options?.bash),\n\t\tedit: createEditToolDefinition(cwd, options?.edit),\n\t\twrite: createWriteToolDefinition(cwd, options?.write),\n\t\tlog: createLogToolDefinition(cwd, options?.log),\n\t\tremember_user_intent: createRememberUserIntentToolDefinition(cwd),\n\t\tuser_intent: createUserIntentToolDefinition(cwd),\n\t\tgrep: createGrepToolDefinition(cwd, options?.grep),\n\t\tfind: createFindToolDefinition(cwd, options?.find),\n\t\tls: createLsToolDefinition(cwd, options?.ls),\n\t\tsubagent: createSubagentToolDefinition(cwd, options?.subagent),\n\t\twebsearch: createWebSearchToolDefinition(options?.websearch),\n\t\twebfetch: createWebFetchToolDefinition(options?.webfetch),\n\t};\n}\n\nexport function createCodingTools(cwd: string, options?: ToolsOptions): Tool[] {\n\treturn [\n\t\tcreateReadTool(cwd, options?.read),\n\t\tcreateBashTool(cwd, options?.bash),\n\t\tcreateEditTool(cwd, options?.edit),\n\t\tcreateWriteTool(cwd, options?.write),\n\t\tcreateLogTool(cwd, options?.log),\n\t\tcreateRememberUserIntentTool(cwd),\n\t\tcreateUserIntentTool(cwd),\n\t\tcreateSubagentTool(cwd, options?.subagent),\n\t\tcreateWebSearchTool(options?.websearch),\n\t\tcreateWebFetchTool(options?.webfetch),\n\t];\n}\n\nexport function createReadOnlyTools(cwd: string, options?: ToolsOptions): Tool[] {\n\treturn [\n\t\tcreateReadTool(cwd, options?.read),\n\t\tcreateGrepTool(cwd, options?.grep),\n\t\tcreateFindTool(cwd, options?.find),\n\t\tcreateLsTool(cwd, options?.ls),\n\t];\n}\n\nexport function createAllTools(cwd: string, options?: ToolsOptions): Record<ToolName, Tool> {\n\treturn {\n\t\tread: createReadTool(cwd, options?.read),\n\t\tbash: createBashTool(cwd, options?.bash),\n\t\tedit: createEditTool(cwd, options?.edit),\n\t\twrite: createWriteTool(cwd, options?.write),\n\t\tlog: createLogTool(cwd, options?.log),\n\t\tremember_user_intent: createRememberUserIntentTool(cwd),\n\t\tuser_intent: createUserIntentTool(cwd),\n\t\tgrep: createGrepTool(cwd, options?.grep),\n\t\tfind: createFindTool(cwd, options?.find),\n\t\tls: createLsTool(cwd, options?.ls),\n\t\tsubagent: createSubagentTool(cwd, options?.subagent),\n\t\twebsearch: createWebSearchTool(options?.websearch),\n\t\twebfetch: createWebFetchTool(options?.webfetch),\n\t};\n}\n"]}
@@ -0,0 +1,25 @@
1
+ import type { AgentTool } from "@earendil-works/metis-agent-core";
2
+ import { type Static, Type } from "typebox";
3
+ import type { ToolDefinition } from "../extensions/types.ts";
4
+ declare const logSchema: Type.TObject<{
5
+ content: Type.TString;
6
+ }>;
7
+ export type LogToolInput = Static<typeof logSchema>;
8
+ export interface LogToolOptions {
9
+ /**
10
+ * Optional custom append operation for tests or alternate storage backends.
11
+ */
12
+ appendFile?: (absolutePath: string, content: string) => Promise<void>;
13
+ /**
14
+ * Optional custom read operation for tests or alternate storage backends.
15
+ */
16
+ readFile?: (absolutePath: string) => Promise<string>;
17
+ /**
18
+ * Optional custom mkdir operation for tests or alternate storage backends.
19
+ */
20
+ mkdir?: (dir: string) => Promise<void>;
21
+ }
22
+ export declare function createLogToolDefinition(cwd: string, options?: LogToolOptions): ToolDefinition<typeof logSchema, undefined>;
23
+ export declare function createLogTool(cwd: string, options?: LogToolOptions): AgentTool<typeof logSchema>;
24
+ export {};
25
+ //# sourceMappingURL=log.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"log.d.ts","sourceRoot":"","sources":["../../../src/core/tools/log.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kCAAkC,CAAC;AAGlE,OAAO,EAAE,KAAK,MAAM,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAC5C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAK7D,QAAA,MAAM,SAAS;;EAIb,CAAC;AAEH,MAAM,MAAM,YAAY,GAAG,MAAM,CAAC,OAAO,SAAS,CAAC,CAAC;AAEpD,MAAM,WAAW,cAAc;IAC9B;;OAEG;IACH,UAAU,CAAC,EAAE,CAAC,YAAY,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACtE;;OAEG;IACH,QAAQ,CAAC,EAAE,CAAC,YAAY,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;IACrD;;OAEG;IACH,KAAK,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CACvC;AAqBD,wBAAgB,uBAAuB,CACtC,GAAG,EAAE,MAAM,EACX,OAAO,CAAC,EAAE,cAAc,GACtB,cAAc,CAAC,OAAO,SAAS,EAAE,SAAS,CAAC,CAwD7C;AAED,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,SAAS,CAAC,OAAO,SAAS,CAAC,CAEhG"}
@@ -0,0 +1,83 @@
1
+ import { appendFile as fsAppendFile, mkdir as fsMkdir, readFile as fsReadFile } from "node:fs/promises";
2
+ import { dirname, join } from "node:path";
3
+ import { Type } from "typebox";
4
+ import { withFileMutationQueue } from "./file-mutation-queue.js";
5
+ import { resolveToCwd } from "./path-utils.js";
6
+ import { wrapToolDefinition } from "./tool-definition-wrapper.js";
7
+ const logSchema = Type.Object({
8
+ content: Type.String({
9
+ description: "High-density task completion summary in 3-10 Markdown lines",
10
+ }),
11
+ });
12
+ const defaultLogOperations = {
13
+ appendFile: (path, content) => fsAppendFile(path, content, "utf-8"),
14
+ readFile: (path) => fsReadFile(path, "utf-8"),
15
+ mkdir: (dir) => fsMkdir(dir, { recursive: true }).then(() => { }),
16
+ };
17
+ function buildLogPath(cwd, sessionId) {
18
+ return resolveToCwd(join(".temp", `${sessionId}_log.md`), cwd);
19
+ }
20
+ function formatLocalTimestamp(date = new Date()) {
21
+ const year = date.getFullYear();
22
+ const month = String(date.getMonth() + 1).padStart(2, "0");
23
+ const day = String(date.getDate()).padStart(2, "0");
24
+ const hours = String(date.getHours()).padStart(2, "0");
25
+ const minutes = String(date.getMinutes()).padStart(2, "0");
26
+ return `${year}-${month}-${day} ${hours}:${minutes}`;
27
+ }
28
+ export function createLogToolDefinition(cwd, options) {
29
+ const ops = {
30
+ appendFile: options?.appendFile ?? defaultLogOperations.appendFile,
31
+ readFile: options?.readFile ?? defaultLogOperations.readFile,
32
+ mkdir: options?.mkdir ?? defaultLogOperations.mkdir,
33
+ };
34
+ return {
35
+ name: "log",
36
+ label: "log",
37
+ description: "Append one timestamped, high-density completion summary to today's working log in .temp.",
38
+ promptSnippet: "Append task completion summary",
39
+ promptGuidelines: [
40
+ "Keep today's working log in .temp/<sessionId>_log.md and let dream consolidate it later.",
41
+ "Call log once when a task finishes; do not write step-by-step progress notes.",
42
+ "Write 3-10 concise lines: completed work, only material decision/issue, verification, and remaining or blocked work. Preserve useful technical detail; omit routine narration and raw tool output.",
43
+ "When a material error occurred, include it even if resolved: error, root cause or diagnosis, and fix/workaround. This gives dream evidence for reusable lessons. If none occurred, omit any error line entirely.",
44
+ ],
45
+ parameters: logSchema,
46
+ async execute(_toolCallId, { content }, signal, _onUpdate, ctx) {
47
+ const sessionId = ctx.sessionManager.getSessionId();
48
+ const absolutePath = buildLogPath(cwd, sessionId);
49
+ const dir = dirname(absolutePath);
50
+ const loggedContent = `## [${formatLocalTimestamp()}] Task summary\n${content}`;
51
+ return withFileMutationQueue(absolutePath, async () => {
52
+ const throwIfAborted = () => {
53
+ if (signal?.aborted)
54
+ throw new Error("Operation aborted");
55
+ };
56
+ throwIfAborted();
57
+ await ops.mkdir(dir);
58
+ throwIfAborted();
59
+ let prefix = "";
60
+ try {
61
+ const existing = await ops.readFile(absolutePath);
62
+ if (existing.trim().length > 0) {
63
+ prefix = existing.endsWith("\n") ? "\n" : "\n\n";
64
+ }
65
+ }
66
+ catch {
67
+ // Fresh log file. Append without prefix.
68
+ }
69
+ throwIfAborted();
70
+ await ops.appendFile(absolutePath, `${prefix}${loggedContent}${loggedContent.endsWith("\n") ? "" : "\n"}`);
71
+ throwIfAborted();
72
+ return {
73
+ content: [{ type: "text", text: `Successfully appended ${content.length} bytes to ${absolutePath}` }],
74
+ details: undefined,
75
+ };
76
+ });
77
+ },
78
+ };
79
+ }
80
+ export function createLogTool(cwd, options) {
81
+ return wrapToolDefinition(createLogToolDefinition(cwd, options));
82
+ }
83
+ //# sourceMappingURL=log.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"log.js","sourceRoot":"","sources":["../../../src/core/tools/log.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,IAAI,YAAY,EAAE,KAAK,IAAI,OAAO,EAAE,QAAQ,IAAI,UAAU,EAAE,MAAM,kBAAkB,CAAC;AACxG,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAe,IAAI,EAAE,MAAM,SAAS,CAAC;AAE5C,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AACjE,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAC;AAElE,MAAM,SAAS,GAAG,IAAI,CAAC,MAAM,CAAC;IAC7B,OAAO,EAAE,IAAI,CAAC,MAAM,CAAC;QACpB,WAAW,EAAE,6DAA6D;KAC1E,CAAC;CACF,CAAC,CAAC;AAmBH,MAAM,oBAAoB,GAAG;IAC5B,UAAU,EAAE,CAAC,IAAY,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ClD,IAAI,QAAQ,CAAC,IAAI,EAAE,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;wBAChC,MAAM,GAAG,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC;oBAClD,CAAC;gBACF,CAAC;gBAAC,MAAM,CAAC;oBACR,yCAAyC;gBAC1C,CAAC;gBACD,cAAc,EAAE,CAAC;gBAEhB,MAAM,GAAG,CAAC,UAAU,CAAC,YAAY,EAAE,GAAG,MAAM,GAAG,aAAa,GAAG,aAAa,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC;gBAC5G,cAAc,EAAE,CAAC;gBAEjB,OAAO;oBACN,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,yBAAyB,OAAO,CAAC,MAAM,aAAa,YAAY,EAAE,EAAE,CAAC;oBACrG,OAAO,EAAE,SAAS;iBAClB,CAAC;YACH,CAAC,CAAC,CAAC;QACJ,CAAC;KACD,CAAC;AACH,CAAC;AAED,MAAM,UAAU,aAAa,CAAC,GAAW,EAAE,OAAwB;IAClE,OAAO,kBAAkB,CAAC,uBAAuB,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC,CAAC;AAClE,CAAC","sourcesContent":["import type { AgentTool } from \"@earendil-works/metis-agent-core\";\nimport { appendFile as fsAppendFile, mkdir as fsMkdir, readFile as fsReadFile } from \"node:fs/promises\";\nimport { dirname, join } from \"node:path\";\nimport { type Static, Type } from \"typebox\";\nimport type { ToolDefinition } from \"../extensions/types.ts\";\nimport { withFileMutationQueue } from \"./file-mutation-queue.ts\";\nimport { resolveToCwd } from \"./path-utils.ts\";\nimport { wrapToolDefinition } from \"./tool-definition-wrapper.ts\";\n\nconst logSchema = Type.Object({\n\tcontent: Type.String({\n\t\tdescription: \"High-density task completion summary in 3-10 Markdown lines\",\n\t}),\n});\n\nexport type LogToolInput = Static<typeof logSchema>;\n\nexport interface LogToolOptions {\n\t/**\n\t * Optional custom append operation for tests or alternate storage backends.\n\t */\n\tappendFile?: (absolutePath: string, content: string) => Promise<void>;\n\t/**\n\t * Optional custom read operation for tests or alternate storage backends.\n\t */\n\treadFile?: (absolutePath: string) => Promise<string>;\n\t/**\n\t * Optional custom mkdir operation for tests or alternate storage backends.\n\t */\n\tmkdir?: (dir: string) => Promise<void>;\n}\n\nconst defaultLogOperations = {\n\tappendFile: (path: string, content: string) => fsAppendFile(path, content, \"utf-8\"),\n\treadFile: (path: string) => fsReadFile(path, \"utf-8\"),\n\tmkdir: (dir: string) => fsMkdir(dir, { recursive: true }).then(() => {}),\n};\n\nfunction buildLogPath(cwd: string, sessionId: string): string {\n\treturn resolveToCwd(join(\".temp\", `${sessionId}_log.md`), cwd);\n}\n\nfunction formatLocalTimestamp(date = new Date()): string {\n\tconst year = date.getFullYear();\n\tconst month = String(date.getMonth() + 1).padStart(2, \"0\");\n\tconst day = String(date.getDate()).padStart(2, \"0\");\n\tconst hours = String(date.getHours()).padStart(2, \"0\");\n\tconst minutes = String(date.getMinutes()).padStart(2, \"0\");\n\treturn `${year}-${month}-${day} ${hours}:${minutes}`;\n}\n\nexport function createLogToolDefinition(\n\tcwd: string,\n\toptions?: LogToolOptions,\n): ToolDefinition<typeof logSchema, undefined> {\n\tconst ops = {\n\t\tappendFile: options?.appendFile ?? defaultLogOperations.appendFile,\n\t\treadFile: options?.readFile ?? defaultLogOperations.readFile,\n\t\tmkdir: options?.mkdir ?? defaultLogOperations.mkdir,\n\t};\n\n\treturn {\n\t\tname: \"log\",\n\t\tlabel: \"log\",\n\t\tdescription:\n\t\t\t\"Append one timestamped, high-density completion summary to today's working log in .temp.\",\n\t\tpromptSnippet: \"Append task completion summary\",\n\t\t\tpromptGuidelines: [\n\t\t\t\t\"Keep today's working log in .temp/<sessionId>_log.md and let dream consolidate it later.\",\n\t\t\t\t\"Call log once when a task finishes; do not write step-by-step progress notes.\",\n\t\t\t\t\"Write 3-10 concise lines: completed work, only material decision/issue, verification, and remaining or blocked work. Preserve useful technical detail; omit routine narration and raw tool output.\",\n\t\t\t\t\"When a material error occurred, include it even if resolved: error, root cause or diagnosis, and fix/workaround. This gives dream evidence for reusable lessons. If none occurred, omit any error line entirely.\",\n\t\t\t],\n\t\t\tparameters: logSchema,\n\t\t\tasync execute(_toolCallId, { content }, signal, _onUpdate, ctx) {\n\t\t\t\tconst sessionId = ctx.sessionManager.getSessionId();\n\t\t\t\tconst absolutePath = buildLogPath(cwd, sessionId);\n\t\t\t\tconst dir = dirname(absolutePath);\n\t\t\tconst loggedContent = `## [${formatLocalTimestamp()}] Task summary\\n${content}`;\n\n\t\t\treturn withFileMutationQueue(absolutePath, async () => {\n\t\t\t\tconst throwIfAborted = (): void => {\n\t\t\t\t\tif (signal?.aborted) throw new Error(\"Operation aborted\");\n\t\t\t\t};\n\n\t\t\t\tthrowIfAborted();\n\t\t\t\tawait ops.mkdir(dir);\n\t\t\t\tthrowIfAborted();\n\n\t\t\t\tlet prefix = \"\";\n\t\t\t\ttry {\n\t\t\t\t\tconst existing = await ops.readFile(absolutePath);\n\t\t\t\t\tif (existing.trim().length > 0) {\n\t\t\t\t\t\tprefix = existing.endsWith(\"\\n\") ? \"\\n\" : \"\\n\\n\";\n\t\t\t\t\t}\n\t\t\t\t} catch {\n\t\t\t\t\t// Fresh log file. Append without prefix.\n\t\t\t\t}\n\t\t\t\tthrowIfAborted();\n\n\t\t\t\t\tawait ops.appendFile(absolutePath, `${prefix}${loggedContent}${loggedContent.endsWith(\"\\n\") ? \"\" : \"\\n\"}`);\n\t\t\t\tthrowIfAborted();\n\n\t\t\t\treturn {\n\t\t\t\t\tcontent: [{ type: \"text\", text: `Successfully appended ${content.length} bytes to ${absolutePath}` }],\n\t\t\t\t\tdetails: undefined,\n\t\t\t\t};\n\t\t\t});\n\t\t},\n\t};\n}\n\nexport function createLogTool(cwd: string, options?: LogToolOptions): AgentTool<typeof logSchema> {\n\treturn wrapToolDefinition(createLogToolDefinition(cwd, options));\n}\n"]}
@@ -0,0 +1,11 @@
1
+ import type { AgentTool } from "@earendil-works/metis-agent-core";
2
+ import { type Static, Type } from "typebox";
3
+ import type { ToolDefinition } from "../extensions/types.ts";
4
+ declare const rememberUserIntentSchema: Type.TObject<{
5
+ content: Type.TString;
6
+ }>;
7
+ export type RememberUserIntentToolInput = Static<typeof rememberUserIntentSchema>;
8
+ export declare function createRememberUserIntentToolDefinition(cwd: string): ToolDefinition<typeof rememberUserIntentSchema, undefined>;
9
+ export declare function createRememberUserIntentTool(cwd: string): AgentTool<any>;
10
+ export {};
11
+ //# sourceMappingURL=remember-user-intent.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"remember-user-intent.d.ts","sourceRoot":"","sources":["../../../src/core/tools/remember-user-intent.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kCAAkC,CAAC;AAClE,OAAO,EAAE,KAAK,MAAM,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAC5C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAI7D,QAAA,MAAM,wBAAwB;;EAE5B,CAAC;AAEH,MAAM,MAAM,2BAA2B,GAAG,MAAM,CAAC,OAAO,wBAAwB,CAAC,CAAC;AAElF,wBAAgB,sCAAsC,CACrD,GAAG,EAAE,MAAM,GACT,cAAc,CAAC,OAAO,wBAAwB,EAAE,SAAS,CAAC,CAsB5D;AAED,wBAAgB,4BAA4B,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,CAAC,GAAG,CAAC,CAExE"}
@@ -0,0 +1,35 @@
1
+ import { Type } from "typebox";
2
+ import { appendUserIntent, getUserIntentPath } from "../user-intent.js";
3
+ import { wrapToolDefinition } from "./tool-definition-wrapper.js";
4
+ const rememberUserIntentSchema = Type.Object({
5
+ content: Type.String({ description: "Verbatim current user prompt to preserve as an active task requirement" }),
6
+ });
7
+ export function createRememberUserIntentToolDefinition(cwd) {
8
+ return {
9
+ name: "remember_user_intent",
10
+ label: "remember_user_intent",
11
+ description: "Append a verbatim, material user requirement to the current session's intent history.",
12
+ promptSnippet: "Save a material user requirement",
13
+ promptGuidelines: [
14
+ "For each user prompt, decide whether it creates, materially changes, or adds constraints to the active task. If it does, call remember_user_intent exactly once with the user's prompt copied verbatim.",
15
+ "Do not call remember_user_intent for pure continuation requests, acknowledgements, greetings, or status questions.",
16
+ ],
17
+ parameters: rememberUserIntentSchema,
18
+ async execute(_toolCallId, { content }, signal, _onUpdate, ctx) {
19
+ if (signal?.aborted)
20
+ throw new Error("Operation aborted");
21
+ const sessionId = ctx.sessionManager.getSessionId();
22
+ await appendUserIntent(cwd, sessionId, content);
23
+ if (signal?.aborted)
24
+ throw new Error("Operation aborted");
25
+ return {
26
+ content: [{ type: "text", text: `Saved user intent to ${getUserIntentPath(cwd, sessionId)}.` }],
27
+ details: undefined,
28
+ };
29
+ },
30
+ };
31
+ }
32
+ export function createRememberUserIntentTool(cwd) {
33
+ return wrapToolDefinition(createRememberUserIntentToolDefinition(cwd));
34
+ }
35
+ //# sourceMappingURL=remember-user-intent.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"remember-user-intent.js","sourceRoot":"","sources":["../../../src/core/tools/remember-user-intent.ts"],"names":[],"mappings":"AACA,OAAO,EAAe,IAAI,EAAE,MAAM,SAAS,CAAC;AAE5C,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AACxE,OAAO,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAC;AAElE,MAAM,wBAAwB,GAAG,IAAI,CAAC,MAAM,CAAC;IAC5C,OAAO,EAAE,IAAI,CAAC,MAAM,CAAC,EAAE,WAAW,EAAE,wEAAwE,EAAE,CAAC;CAC/G,CAAC,CAAC;AAIH,MAAM,UAAU,sCAAsC,CACrD,GAAW;IAEX,OAAO;QACN,IAAI,EAAE,sBAAsB;QAC5B,KAAK,EAAE,sBAAsB;QAC7B,WAAW,EAAE,uFAAuF;QACpG,aAAa,EAAE,kCAAkC;QACjD,gBAAgB,EAAE;YACjB,yMAAyM;YACzM,oHAAoH;SACpH;QACD,UAAU,EAAE,wBAAwB;QACpC,KAAK,CAAC,OAAO,CAAC,WAAW,EAAE,EAAE,OAAO,EAAE,EAAE,MAAM,EAAE,SAAS,EAAE,GAAG;YAC7D,IAAI,MAAM,EAAE,OAAO;gBAAE,MAAM,IAAI,KAAK,CAAC,mBAAmB,CAAC,CAAC;YAC1D,MAAM,SAAS,GAAG,GAAG,CAAC,cAAc,CAAC,YAAY,EAAE,CAAC;YACpD,MAAM,gBAAgB,CAAC,GAAG,EAAE,SAAS,EAAE,OAAO,CAAC,CAAC;YAChD,IAAI,MAAM,EAAE,OAAO;gBAAE,MAAM,IAAI,KAAK,CAAC,mBAAmB,CAAC,CAAC;YAC1D,OAAO;gBACN,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,wBAAwB,iBAAiB,CAAC,GAAG,EAAE,SAAS,CAAC,GAAG,EAAE,CAAC;gBAC/F,OAAO,EAAE,SAAS;aAClB,CAAC;QACH,CAAC;KACD,CAAC;AACH,CAAC;AAED,MAAM,UAAU,4BAA4B,CAAC,GAAW;IACvD,OAAO,kBAAkB,CAAC,sCAAsC,CAAC,GAAG,CAAC,CAAC,CAAC;AACxE,CAAC","sourcesContent":["import type { AgentTool } from \"@earendil-works/metis-agent-core\";\nimport { type Static, Type } from \"typebox\";\nimport type { ToolDefinition } from \"../extensions/types.ts\";\nimport { appendUserIntent, getUserIntentPath } from \"../user-intent.ts\";\nimport { wrapToolDefinition } from \"./tool-definition-wrapper.ts\";\n\nconst rememberUserIntentSchema = Type.Object({\n\tcontent: Type.String({ description: \"Verbatim current user prompt to preserve as an active task requirement\" }),\n});\n\nexport type RememberUserIntentToolInput = Static<typeof rememberUserIntentSchema>;\n\nexport function createRememberUserIntentToolDefinition(\n\tcwd: string,\n): ToolDefinition<typeof rememberUserIntentSchema, undefined> {\n\treturn {\n\t\tname: \"remember_user_intent\",\n\t\tlabel: \"remember_user_intent\",\n\t\tdescription: \"Append a verbatim, material user requirement to the current session's intent history.\",\n\t\tpromptSnippet: \"Save a material user requirement\",\n\t\tpromptGuidelines: [\n\t\t\t\"For each user prompt, decide whether it creates, materially changes, or adds constraints to the active task. If it does, call remember_user_intent exactly once with the user's prompt copied verbatim.\",\n\t\t\t\"Do not call remember_user_intent for pure continuation requests, acknowledgements, greetings, or status questions.\",\n\t\t],\n\t\tparameters: rememberUserIntentSchema,\n\t\tasync execute(_toolCallId, { content }, signal, _onUpdate, ctx) {\n\t\t\tif (signal?.aborted) throw new Error(\"Operation aborted\");\n\t\t\tconst sessionId = ctx.sessionManager.getSessionId();\n\t\t\tawait appendUserIntent(cwd, sessionId, content);\n\t\t\tif (signal?.aborted) throw new Error(\"Operation aborted\");\n\t\t\treturn {\n\t\t\t\tcontent: [{ type: \"text\", text: `Saved user intent to ${getUserIntentPath(cwd, sessionId)}.` }],\n\t\t\t\tdetails: undefined,\n\t\t\t};\n\t\t},\n\t};\n}\n\nexport function createRememberUserIntentTool(cwd: string): AgentTool<any> {\n\treturn wrapToolDefinition(createRememberUserIntentToolDefinition(cwd));\n}\n"]}
@@ -0,0 +1,9 @@
1
+ import type { AgentTool } from "@earendil-works/metis-agent-core";
2
+ import { type Static, Type } from "typebox";
3
+ import type { ToolDefinition } from "../extensions/types.ts";
4
+ declare const userIntentSchema: Type.TObject<{}>;
5
+ export type UserIntentToolInput = Static<typeof userIntentSchema>;
6
+ export declare function createUserIntentToolDefinition(cwd: string): ToolDefinition<typeof userIntentSchema, undefined>;
7
+ export declare function createUserIntentTool(cwd: string): AgentTool<any>;
8
+ export {};
9
+ //# sourceMappingURL=user-intent.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"user-intent.d.ts","sourceRoot":"","sources":["../../../src/core/tools/user-intent.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kCAAkC,CAAC;AAClE,OAAO,EAAE,KAAK,MAAM,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAC5C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAI7D,QAAA,MAAM,gBAAgB,kBAAkB,CAAC;AAEzC,MAAM,MAAM,mBAAmB,GAAG,MAAM,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAElE,wBAAgB,8BAA8B,CAAC,GAAG,EAAE,MAAM,GAAG,cAAc,CAAC,OAAO,gBAAgB,EAAE,SAAS,CAAC,CAqB9G;AAED,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,CAAC,GAAG,CAAC,CAEhE"}