@wholiver_hu/metis 0.80.16 → 0.80.17

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.
@@ -1 +1 @@
1
- {"version":3,"file":"system-prompt.d.ts","sourceRoot":"","sources":["../../src/core/system-prompt.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,OAAO,EAAyB,KAAK,KAAK,EAAE,MAAM,aAAa,CAAC;AAEhE,MAAM,WAAW,wBAAwB;IACxC,+CAA+C;IAC/C,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,qEAAqE;IACrE,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;IACzB,0DAA0D;IAC1D,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACtC,qFAAqF;IACrF,gBAAgB,CAAC,EAAE,MAAM,EAAE,CAAC;IAC5B,uCAAuC;IACvC,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,yBAAyB;IACzB,GAAG,EAAE,MAAM,CAAC;IACZ,gCAAgC;IAChC,YAAY,CAAC,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACxD,yBAAyB;IACzB,MAAM,CAAC,EAAE,KAAK,EAAE,CAAC;IACjB,iBAAiB;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,kEAAkE;AAClE,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,wBAAwB,GAAG,MAAM,CAqM3E"}
1
+ {"version":3,"file":"system-prompt.d.ts","sourceRoot":"","sources":["../../src/core/system-prompt.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,OAAO,EAAyB,KAAK,KAAK,EAAE,MAAM,aAAa,CAAC;AAEhE,MAAM,WAAW,wBAAwB;IACxC,+CAA+C;IAC/C,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,qEAAqE;IACrE,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;IACzB,0DAA0D;IAC1D,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACtC,qFAAqF;IACrF,gBAAgB,CAAC,EAAE,MAAM,EAAE,CAAC;IAC5B,uCAAuC;IACvC,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,yBAAyB;IACzB,GAAG,EAAE,MAAM,CAAC;IACZ,gCAAgC;IAChC,YAAY,CAAC,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACxD,yBAAyB;IACzB,MAAM,CAAC,EAAE,KAAK,EAAE,CAAC;IACjB,iBAAiB;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,kEAAkE;AAClE,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,wBAAwB,GAAG,MAAM,CAwM3E"}
@@ -91,7 +91,8 @@ export function buildSystemPrompt(options) {
91
91
  if (tempLogPath && planPath) {
92
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
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.`);
94
+ addGuideline(`TASK PLAN: For every non-trivial task, create and maintain the current session plan at ${planPath} before substantive work. Use this concise Markdown structure: # Task Plan (user goal and explicit acceptance criteria); ## Scope & Constraints (scope, non-goals, user constraints, known risks); ## Steps (each item is [pending|in_progress|completed|blocked] action — expected result — verification method; only one item may be in_progress); ## Verification (planned tests, build, manual checks, or release validation); ## Risks & Blockers (blockers, dependencies, unverified risks, and next step). Update the plan immediately when requirements, scope, approach, status, verification strategy, or blockers change. Keep it actionable: do NOT write a work diary, raw tool output, or unrelated completed exploration. 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(`TESTING ERROR LOGGING: When testing, build, runtime, or verification reveals a material error, diagnose or resolve it, then call log immediately before resuming substantive work; record it even when resolved. Every error entry MUST include: phase or test, symptom and reproduction, impact, root cause or diagnosis, fix or workaround, post-fix verification result, and residual risk. Misfiled artifacts or incorrect paths, mistakes requiring implementation rework, and tool, dependency, or environment failures are material errors. Do NOT log expected negative-test failures or no-impact informational messages. This immediate error entry is separate from the single required task-completion summary.`);
95
96
  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
97
  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
98
  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.");
@@ -1 +1 @@
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,GAAG,CAAC,CAAC;IAC1D,MAAM,GAAG,GAAG,MAAM,CAAC,GAAG,CAAC,OAAO,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;IACnD,MAAM,IAAI,GAAG,GAAG,IAAI,IAAI,KAAK,IAAI,GAAG,EAAE,CAAC;IAEvC,MAAM,aAAa,GAAG,kBAAkB,CAAC,CAAC,CAAC,OAAO,kBAAkB,EAAE,CAAC,CAAC,CA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,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 - User Prompt Fidelity: Before declaring work complete, compare the output against every requirement, constraint, acceptance condition, and later clarification in the user's prompt. Do NOT omit, reinterpret, weaken, substitute, or expand any requirement without explicit authorization. If requirements conflict or cannot be satisfied, explain the concrete conflict and request a decision; never present a partial or alternative result as complete.`);\n\taddGuideline(`CRITICAL - Verification: MANDATORY VERIFICATION BEFORE COMPLETION. For every implementation, fix, configuration, data, or release change, create and execute a risk-based test matrix. Cover every applicable dimension: build, type/static checks, lint, and existing automated tests; functional and acceptance paths; boundary, empty, invalid, and error inputs; regressions and backward compatibility; integration, API/schema/dependency/configuration contracts, and end-to-end workflows; persistence, migrations, transactions, caching, idempotency, concurrency, race conditions, and recovery; timeouts, retries, cancellation, fallbacks, fault recovery, and resource cleanup; authentication, authorization, input validation, sensitive data, error handling, and audit logging; latency, throughput, resource use, load, stress, and endurance; UI usability, keyboard access, accessibility, responsive behavior, localization, and platform/browser compatibility; and build artifacts, deployment configuration, feature flags, monitoring, alerts, canary rollout, and rollback. During testing, use web research when useful to consult authoritative documentation, dependency release notes, security advisories, known issues, and testing practices; turn relevant findings into concrete test cases, never use search as a substitute for testing. State each inapplicable or blocked dimension, its reason, remaining risk, and needed follow-up. Never run unsafe production tests merely to claim coverage. Report executed tests, results, coverage, unverified risks, and the final user-requirements check. 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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AO,+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, create and maintain the current session plan at ${planPath} before substantive work. Use this concise Markdown structure: # Task Plan (user goal and explicit acceptance criteria); ## Scope & Constraints (scope, non-goals, user constraints, known risks); ## Steps (each item is [pending|in_progress|completed|blocked] action — expected result — verification method; only one item may be in_progress); ## Verification (planned tests, build, manual checks, or release validation); ## Risks & Blockers (blockers, dependencies, unverified risks, and next step). Update the plan immediately when requirements, scope, approach, status, verification strategy, or blockers change. Keep it actionable: do NOT write a work diary, raw tool output, or unrelated completed exploration. 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`TESTING ERROR LOGGING: When testing, build, runtime, or verification reveals a material error, diagnose or resolve it, then call log immediately before resuming substantive work; record it even when resolved. Every error entry MUST include: phase or test, symptom and reproduction, impact, root cause or diagnosis, fix or workaround, post-fix verification result, and residual risk. Misfiled artifacts or incorrect paths, mistakes requiring implementation rework, and tool, dependency, or environment failures are material errors. Do NOT log expected negative-test failures or no-impact informational messages. This immediate error entry is separate from the single required task-completion summary.`,\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 - User Prompt Fidelity: Before declaring work complete, compare the output against every requirement, constraint, acceptance condition, and later clarification in the user's prompt. Do NOT omit, reinterpret, weaken, substitute, or expand any requirement without explicit authorization. If requirements conflict or cannot be satisfied, explain the concrete conflict and request a decision; never present a partial or alternative result as complete.`);\n\taddGuideline(`CRITICAL - Verification: MANDATORY VERIFICATION BEFORE COMPLETION. For every implementation, fix, configuration, data, or release change, create and execute a risk-based test matrix. Cover every applicable dimension: build, type/static checks, lint, and existing automated tests; functional and acceptance paths; boundary, empty, invalid, and error inputs; regressions and backward compatibility; integration, API/schema/dependency/configuration contracts, and end-to-end workflows; persistence, migrations, transactions, caching, idempotency, concurrency, race conditions, and recovery; timeouts, retries, cancellation, fallbacks, fault recovery, and resource cleanup; authentication, authorization, input validation, sensitive data, error handling, and audit logging; latency, throughput, resource use, load, stress, and endurance; UI usability, keyboard access, accessibility, responsive behavior, localization, and platform/browser compatibility; and build artifacts, deployment configuration, feature flags, monitoring, alerts, canary rollout, and rollback. During testing, use web research when useful to consult authoritative documentation, dependency release notes, security advisories, known issues, and testing practices; turn relevant findings into concrete test cases, never use search as a substitute for testing. State each inapplicable or blocked dimension, its reason, remaining risk, and needed follow-up. Never run unsafe production tests merely to claim coverage. Report executed tests, results, coverage, unverified risks, and the final user-requirements check. 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,12 +1,12 @@
1
1
  {
2
2
  "name": "@wholiver_hu/metis",
3
- "version": "0.80.16",
3
+ "version": "0.80.17",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "@wholiver_hu/metis",
9
- "version": "0.80.16",
9
+ "version": "0.80.17",
10
10
  "bundleDependencies": [
11
11
  "@earendil-works/metis-agent-core",
12
12
  "@earendil-works/metis-ai",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wholiver_hu/metis",
3
- "version": "0.80.16",
3
+ "version": "0.80.17",
4
4
  "description": "Metis coding agent CLI with read, bash, edit, write tools and session management",
5
5
  "type": "module",
6
6
  "metisConfig": {