iosm-cli 0.2.2 → 0.2.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +33 -0
- package/README.md +32 -5
- package/dist/cli/args.d.ts +1 -1
- package/dist/cli/args.d.ts.map +1 -1
- package/dist/cli/args.js +1 -1
- package/dist/cli/args.js.map +1 -1
- package/dist/core/agent-profiles.d.ts +1 -1
- package/dist/core/agent-profiles.d.ts.map +1 -1
- package/dist/core/agent-profiles.js +9 -0
- package/dist/core/agent-profiles.js.map +1 -1
- package/dist/core/agent-session.d.ts +7 -0
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +58 -13
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/extensions/types.d.ts +1 -1
- package/dist/core/extensions/types.d.ts.map +1 -1
- package/dist/core/extensions/types.js.map +1 -1
- package/dist/core/orchestration-limits.d.ts +6 -0
- package/dist/core/orchestration-limits.d.ts.map +1 -0
- package/dist/core/orchestration-limits.js +6 -0
- package/dist/core/orchestration-limits.js.map +1 -0
- package/dist/core/sdk.d.ts +6 -1
- package/dist/core/sdk.d.ts.map +1 -1
- package/dist/core/sdk.js +96 -6
- package/dist/core/sdk.js.map +1 -1
- package/dist/core/subagents.d.ts.map +1 -1
- package/dist/core/subagents.js +21 -7
- package/dist/core/subagents.js.map +1 -1
- package/dist/core/tools/edit.d.ts +8 -4
- package/dist/core/tools/edit.d.ts.map +1 -1
- package/dist/core/tools/edit.js +18 -3
- package/dist/core/tools/edit.js.map +1 -1
- package/dist/core/tools/index.d.ts +9 -7
- package/dist/core/tools/index.d.ts.map +1 -1
- package/dist/core/tools/task.d.ts +10 -3
- package/dist/core/tools/task.d.ts.map +1 -1
- package/dist/core/tools/task.js +404 -149
- package/dist/core/tools/task.js.map +1 -1
- package/dist/core/tools/todo.d.ts +10 -10
- package/dist/core/tools/todo.d.ts.map +1 -1
- package/dist/core/tools/todo.js +135 -17
- package/dist/core/tools/todo.js.map +1 -1
- package/dist/modes/interactive/components/footer.d.ts +1 -1
- package/dist/modes/interactive/components/footer.d.ts.map +1 -1
- package/dist/modes/interactive/components/footer.js +8 -8
- package/dist/modes/interactive/components/footer.js.map +1 -1
- package/dist/modes/interactive/interactive-mode.d.ts +10 -0
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode.js +243 -15
- package/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/docs/cli-reference.md +4 -0
- package/docs/configuration.md +5 -1
- package/docs/interactive-mode.md +5 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"subagents.js","sourceRoot":"","sources":["../../src/core/subagents.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAC1E,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpD,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AA8C3D,MAAM,yBAAyB,GAAG,CAAC,CAAC,CAAC;AAErC,MAAM,iBAAiB,GAA+B;IACrD;QACC,IAAI,EAAE,kBAAkB;QACxB,WAAW,EAAE,mFAAmF;QAChG,UAAU,EAAE,+BAA+B;QAC3C,OAAO,EAAE,SAAS;QAClB,YAAY,EAAE;YACb,6BAA6B;YAC7B,EAAE;YACF,OAAO;YACP,gGAAgG;YAChG,EAAE;YACF,QAAQ;YACR,0CAA0C;YAC1C,qDAAqD;YACrD,sDAAsD;YACtD,EAAE;YACF,kBAAkB;YAClB,mCAAmC;YACnC,4BAA4B;YAC5B,6BAA6B;YAC7B,EAAE;YACF,2BAA2B;YAC3B,+CAA+C;YAC/C,eAAe;YACf,0BAA0B;YAC1B,EAAE;YACF,8FAA8F;SAC9F,CAAC,IAAI,CAAC,IAAI,CAAC;KACZ;IACD;QACC,IAAI,EA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xD,IAAI,WAAW,KAAK,CAAC;YAAE,OAAO,WAAW,CAAC;QAC1C,OAAO,KAAK,CAAC,cAAc,GAAG,IAAI,CAAC,cAAc,CAAC;IACnD,CAAC,CAAC,CAAC;IACH,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,SAAS,EAAE,WAAW,EAAE,CAAC;AACtD,CAAC","sourcesContent":["import { existsSync, readdirSync, readFileSync, statSync } from \"node:fs\";\nimport { basename, join, resolve } from \"node:path\";\nimport { parseFrontmatter } from \"../utils/frontmatter.js\";\nimport type { AgentProfileName } from \"./agent-profiles.js\";\n\nexport type CustomSubagentSourceScope = \"builtin\" | \"global\" | \"project\";\n\nexport interface CustomSubagentDefinition {\n\tname: string;\n\tdescription: string;\n\tsourcePath: string;\n\tprofile?: AgentProfileName;\n\ttools?: string[];\n\tdisallowedTools?: string[];\n\tsystemPrompt?: string;\n\tinstructions: string;\n\tcwd?: string;\n\tmodel?: string;\n\tbackground?: boolean;\n}\n\nexport interface CustomSubagentEntry extends CustomSubagentDefinition {\n\tsourceScope: CustomSubagentSourceScope;\n\tsourcePriority: number;\n\teffective: boolean;\n\toverriddenByPath?: string;\n}\n\nexport interface SubagentOverrideInfo {\n\tname: string;\n\twinnerPath: string;\n\twinnerScope: CustomSubagentSourceScope;\n\toverriddenPath: string;\n\toverriddenScope: CustomSubagentSourceScope;\n}\n\nexport interface SubagentDiagnostic {\n\tpath: string;\n\tmessage: string;\n}\n\nexport interface LoadCustomSubagentsResult {\n\tagents: CustomSubagentEntry[];\n\tallAgents: CustomSubagentEntry[];\n\toverrides: SubagentOverrideInfo[];\n\tdiagnostics: SubagentDiagnostic[];\n}\n\nconst BUILTIN_SUBAGENT_PRIORITY = -1;\n\nconst BUILTIN_SUBAGENTS: CustomSubagentDefinition[] = [\n\t{\n\t\tname: \"codebase_auditor\",\n\t\tdescription: \"Structured codebase audit for architecture, reliability, security, and test gaps.\",\n\t\tsourcePath: \"builtin://codebase_auditor.md\",\n\t\tprofile: \"explore\",\n\t\tinstructions: [\n\t\t\t\"You are a codebase auditor.\",\n\t\t\t\"\",\n\t\t\t\"Goal:\",\n\t\t\t\"- Produce an evidence-based audit of architecture, defect risks, and maintainability hotspots.\",\n\t\t\t\"\",\n\t\t\t\"Rules:\",\n\t\t\t\"- Read-only operation. Never edit files.\",\n\t\t\t\"- Make claims only with direct repository evidence.\",\n\t\t\t\"- Prioritize by user impact and likelihood (P0..P3).\",\n\t\t\t\"\",\n\t\t\t\"Required output:\",\n\t\t\t\"1) Findings (ordered by severity)\",\n\t\t\t\"2) Open questions/unknowns\",\n\t\t\t\"3) Recommended next actions\",\n\t\t\t\"\",\n\t\t\t\"For each finding include:\",\n\t\t\t\"- file path + line reference (when available)\",\n\t\t\t\"- risk/impact\",\n\t\t\t\"- concrete fix direction\",\n\t\t\t\"\",\n\t\t\t\"If no issues are found, explicitly state 'No findings' and list residual risks/testing gaps.\",\n\t\t].join(\"\\n\"),\n\t},\n\t{\n\t\tname: \"system_error_analyst\",\n\t\tdescription: \"Diagnoses system/runtime failures and produces root-cause + fix plan.\",\n\t\tsourcePath: \"builtin://system_error_analyst.md\",\n\t\tprofile: \"plan\",\n\t\tinstructions: [\n\t\t\t\"You are a system error analyst.\",\n\t\t\t\"\",\n\t\t\t\"Goal:\",\n\t\t\t\"- Triage failures, identify probable root cause, and propose a minimal, testable fix plan.\",\n\t\t\t\"\",\n\t\t\t\"Rules:\",\n\t\t\t\"- Do not modify files.\",\n\t\t\t\"- Use deterministic evidence (logs, stack traces, tests, configs).\",\n\t\t\t\"- Distinguish facts vs hypotheses explicitly.\",\n\t\t\t\"\",\n\t\t\t\"Required output:\",\n\t\t\t\"1) Incident summary\",\n\t\t\t\"2) Root-cause analysis (ranked hypotheses with evidence)\",\n\t\t\t\"3) Minimal patch plan\",\n\t\t\t\"4) Verification plan (commands + expected signals)\",\n\t\t\t\"5) Regression risks\",\n\t\t\t\"\",\n\t\t\t\"Escalation guidance:\",\n\t\t\t\"- If data is insufficient, request the minimum missing evidence instead of guessing.\",\n\t\t].join(\"\\n\"),\n\t},\n\t{\n\t\tname: \"iosm_change_executor\",\n\t\tdescription: \"Implements repository changes under IOSM methodology and keeps artifacts aligned.\",\n\t\tsourcePath: \"builtin://iosm_change_executor.md\",\n\t\tprofile: \"iosm\",\n\t\tinstructions: [\n\t\t\t\"You are an IOSM change executor.\",\n\t\t\t\"\",\n\t\t\t\"Goal:\",\n\t\t\t\"- Analyze, implement, and verify changes while preserving IOSM methodology and artifact consistency.\",\n\t\t\t\"\",\n\t\t\t\"Execution policy:\",\n\t\t\t\"- Inspect relevant code and .iosm artifacts before edits.\",\n\t\t\t\"- Make minimal, targeted changes with clear rationale.\",\n\t\t\t\"- Run focused verification after each meaningful change.\",\n\t\t\t\"- Keep IOSM artifacts in sync when behavior/metrics assumptions change.\",\n\t\t\t\"\",\n\t\t\t\"Required output:\",\n\t\t\t\"1) What changed and why\",\n\t\t\t\"2) Files changed\",\n\t\t\t\"3) Verification executed and results\",\n\t\t\t\"4) Remaining risks/assumptions\",\n\t\t\t\"\",\n\t\t\t\"Safety rules:\",\n\t\t\t\"- Do not introduce speculative changes.\",\n\t\t\t\"- If requirements are ambiguous, ask a concise clarification before risky edits.\",\n\t\t].join(\"\\n\"),\n\t},\n\t{\n\t\tname: \"iosm_postchange_verifier\",\n\t\tdescription: \"Post-change IOSM verifier for metric/artifact integrity and regression checks.\",\n\t\tsourcePath: \"builtin://iosm_postchange_verifier.md\",\n\t\tprofile: \"iosm_verifier\",\n\t\tinstructions: [\n\t\t\t\"You are an IOSM post-change verifier.\",\n\t\t\t\"\",\n\t\t\t\"Goal:\",\n\t\t\t\"- Validate that implemented changes are correctly reflected in IOSM metrics/artifacts.\",\n\t\t\t\"\",\n\t\t\t\"Rules:\",\n\t\t\t\"- Restrict edits to .iosm artifacts unless explicitly instructed otherwise.\",\n\t\t\t\"- Prefer deterministic checks and reproducible commands.\",\n\t\t\t\"- Report mismatches and exact remediation steps.\",\n\t\t\t\"\",\n\t\t\t\"Required output:\",\n\t\t\t\"1) Checks performed\",\n\t\t\t\"2) Pass/fail per check\",\n\t\t\t\"3) Artifact updates applied (if any)\",\n\t\t\t\"4) Remaining discrepancies and follow-ups\",\n\t\t].join(\"\\n\"),\n\t},\n\t{\n\t\tname: \"qa_test_engineer\",\n\t\tdescription: \"Writes tests, runs verification, and fixes regressions with evidence-driven workflow.\",\n\t\tsourcePath: \"builtin://qa_test_engineer.md\",\n\t\tprofile: \"full\",\n\t\tinstructions: [\n\t\t\t\"You are a QA test engineer and regression fixer.\",\n\t\t\t\"\",\n\t\t\t\"Goal:\",\n\t\t\t\"- Increase confidence by adding/updating tests, reproducing failures, and fixing root causes.\",\n\t\t\t\"\",\n\t\t\t\"Workflow:\",\n\t\t\t\"1) Reproduce failure (or define expected behavior if bug is not reproducible yet).\",\n\t\t\t\"2) Add/update focused tests that capture expected behavior.\",\n\t\t\t\"3) Run targeted tests first, then broader suite if needed.\",\n\t\t\t\"4) Implement minimal fix in production code.\",\n\t\t\t\"5) Re-run tests and report outcomes.\",\n\t\t\t\"\",\n\t\t\t\"Rules:\",\n\t\t\t\"- Never hide failures by removing assertions or disabling tests unless explicitly requested.\",\n\t\t\t\"- Prefer deterministic tests; avoid flaky timing assumptions.\",\n\t\t\t\"- Keep patch size minimal and localized.\",\n\t\t\t\"\",\n\t\t\t\"Required output:\",\n\t\t\t\"1) Root cause summary\",\n\t\t\t\"2) Tests added/updated\",\n\t\t\t\"3) Code fixes applied\",\n\t\t\t\"4) Commands executed + pass/fail results\",\n\t\t\t\"5) Residual risk\",\n\t\t].join(\"\\n\"),\n\t},\n\t{\n\t\tname: \"test_failure_triager\",\n\t\tdescription: \"Analyzes failing/flaky tests and proposes a ranked remediation plan.\",\n\t\tsourcePath: \"builtin://test_failure_triager.md\",\n\t\tprofile: \"plan\",\n\t\tinstructions: [\n\t\t\t\"You are a test-failure triage specialist.\",\n\t\t\t\"\",\n\t\t\t\"Goal:\",\n\t\t\t\"- Analyze failures quickly and produce a ranked, actionable remediation plan.\",\n\t\t\t\"\",\n\t\t\t\"Rules:\",\n\t\t\t\"- Read/analyze only; do not edit files.\",\n\t\t\t\"- Separate infra/environment issues from product-code defects.\",\n\t\t\t\"- Label confidence for each hypothesis.\",\n\t\t\t\"\",\n\t\t\t\"Required output:\",\n\t\t\t\"1) Failure classification (deterministic, flaky, environment, unknown)\",\n\t\t\t\"2) Ranked hypotheses with evidence\",\n\t\t\t\"3) Minimal next steps to verify each hypothesis\",\n\t\t\t\"4) Recommended owner/agent to execute fixes\",\n\t\t].join(\"\\n\"),\n\t},\n\t{\n\t\tname: \"meta_orchestrator\",\n\t\tdescription: \"Autonomous orchestration lead: audits, plans, and delegates parallel specialists safely.\",\n\t\tsourcePath: \"builtin://meta_orchestrator.md\",\n\t\tprofile: \"full\",\n\t\tinstructions: [\n\t\t\t\"You are the main orchestration agent for complex engineering tasks.\",\n\t\t\t\"\",\n\t\t\t\"Goal:\",\n\t\t\t\"- Drive tasks end-to-end with dynamic delegation: audit -> plan -> execution -> verification.\",\n\t\t\t\"\",\n\t\t\t\"Required operating phases:\",\n\t\t\t\"1) Recon: inspect repository context and constraints.\",\n\t\t\t\"2) Plan: split work into independent chunks and dependency chains.\",\n\t\t\t\"3) Delegate: emit specialist <delegate_task> blocks for chunks that benefit from parallel execution.\",\n\t\t\t\"4) Synthesize: provide integrated results, unresolved risks, and next actions.\",\n\t\t\t\"\",\n\t\t\t\"Delegation policy:\",\n\t\t\t\"- Decide number of delegates based on task complexity (usually 1-10).\",\n\t\t\t\"- Run independent read-heavy work in parallel by emitting multiple delegate blocks.\",\n\t\t\t\"- For write-capable delegates touching overlapping areas, provide lock_key to avoid edit collisions.\",\n\t\t\t\"- Use depends_on to enforce ordering for dependent steps (for example verification after implementation).\",\n\t\t\t\"- Use clear description values and focused prompts per delegate.\",\n\t\t\t\"\",\n\t\t\t\"Suggested specialist mapping:\",\n\t\t\t\"- architecture/recon -> profile=explore or plan\",\n\t\t\t\"- implementation -> profile=full or iosm\",\n\t\t\t\"- iosm artifact validation -> profile=iosm_verifier\",\n\t\t\t\"- test creation/fixes -> profile=full (or qa_test_engineer when referenced)\",\n\t\t\t\"\",\n\t\t\t\"Safety rules:\",\n\t\t\t\"- Avoid broad overlapping writes without lock separation.\",\n\t\t\t\"- If requirements are ambiguous and risky, ask for minimal clarification before destructive changes.\",\n\t\t\t\"- Keep all delegated prompts concrete and scoped to specific files/behaviors.\",\n\t\t\t\"\",\n\t\t\t\"Output requirements:\",\n\t\t\t\"- concise execution summary\",\n\t\t\t\"- delegated work breakdown\",\n\t\t\t\"- verification status\",\n\t\t\t\"- residual risks/assumptions\",\n\t\t].join(\"\\n\"),\n\t},\n];\n\nfunction trimWrappingChars(value: string): string {\n\tlet next = value.trim();\n\tnext = next.replace(/^@+/, \"\");\n\tnext = next.replace(/^[`\"'“”‘’]+/, \"\");\n\tnext = next.replace(/[`\"'“”‘’]+$/, \"\");\n\tnext = next.replace(/[),;:!?]+$/, \"\");\n\treturn next.trim();\n}\n\nfunction pushCandidate(set: Set<string>, value: string): void {\n\tconst trimmed = value.trim();\n\tif (!trimmed) return;\n\tset.add(trimmed);\n}\n\nexport function getSubagentLookupCandidates(reference: string): string[] {\n\tconst cleaned = trimWrappingChars(reference);\n\tif (!cleaned) return [];\n\tconst normalized = cleaned.replace(/\\\\/g, \"/\");\n\tconst lowerNormalized = normalized.toLowerCase();\n\tconst candidates = new Set<string>();\n\n\tpushCandidate(candidates, cleaned);\n\tpushCandidate(candidates, cleaned.replace(/\\.md$/i, \"\"));\n\tpushCandidate(candidates, normalized);\n\tpushCandidate(candidates, normalized.replace(/\\.md$/i, \"\"));\n\n\tconst pathMarkers = [\"/.iosm/agents/\", \".iosm/agents/\", \"/agents/\", \"agents/\"];\n\tfor (const marker of pathMarkers) {\n\t\tconst markerIndex = lowerNormalized.lastIndexOf(marker.toLowerCase());\n\t\tif (markerIndex === -1) continue;\n\t\tconst suffix = normalized.slice(markerIndex + marker.length);\n\t\tpushCandidate(candidates, suffix);\n\t\tpushCandidate(candidates, suffix.replace(/\\.md$/i, \"\"));\n\t}\n\n\tconst baseFromNormalized = normalized.split(\"/\").filter(Boolean).pop() ?? \"\";\n\tconst baseFromPath = basename(cleaned);\n\tpushCandidate(candidates, baseFromNormalized);\n\tpushCandidate(candidates, baseFromNormalized.replace(/\\.md$/i, \"\"));\n\tpushCandidate(candidates, baseFromPath);\n\tpushCandidate(candidates, baseFromPath.replace(/\\.md$/i, \"\"));\n\n\treturn Array.from(candidates);\n}\n\nexport function resolveCustomSubagentReference(\n\treference: string,\n\tagents: ReadonlyArray<Pick<CustomSubagentDefinition, \"name\" | \"sourcePath\">>,\n): string | undefined {\n\tif (agents.length === 0) return undefined;\n\tconst byName = new Map<string, string>();\n\tconst byNameLower = new Map<string, string>();\n\tconst bySourceBaseLower = new Map<string, string>();\n\n\tfor (const agent of agents) {\n\t\tbyName.set(agent.name, agent.name);\n\t\tbyNameLower.set(agent.name.toLowerCase(), agent.name);\n\n\t\tconst sourceBase = basename(agent.sourcePath);\n\t\tif (sourceBase) {\n\t\t\tconst sourceBaseLower = sourceBase.toLowerCase();\n\t\t\tif (!bySourceBaseLower.has(sourceBaseLower)) {\n\t\t\t\tbySourceBaseLower.set(sourceBaseLower, agent.name);\n\t\t\t}\n\t\t\tconst sourceBaseNoMdLower = sourceBase.replace(/\\.md$/i, \"\").toLowerCase();\n\t\t\tif (!bySourceBaseLower.has(sourceBaseNoMdLower)) {\n\t\t\t\tbySourceBaseLower.set(sourceBaseNoMdLower, agent.name);\n\t\t\t}\n\t\t}\n\t}\n\n\tfor (const candidate of getSubagentLookupCandidates(reference)) {\n\t\tconst exact = byName.get(candidate);\n\t\tif (exact) return exact;\n\n\t\tconst lower = candidate.toLowerCase();\n\t\tconst byLower = byNameLower.get(lower);\n\t\tif (byLower) return byLower;\n\t\tconst withoutMd = lower.replace(/\\.md$/i, \"\");\n\t\tconst byWithoutMd = byNameLower.get(withoutMd);\n\t\tif (byWithoutMd) return byWithoutMd;\n\n\t\tconst byBase = bySourceBaseLower.get(lower) ?? bySourceBaseLower.get(withoutMd);\n\t\tif (byBase) return byBase;\n\t}\n\n\treturn undefined;\n}\n\ntype ParsedFrontmatter = {\n\tname?: unknown;\n\tdescription?: unknown;\n\tprofile?: unknown;\n\ttools?: unknown;\n\tdisallowed_tools?: unknown;\n\tsystem_prompt?: unknown;\n\tcwd?: unknown;\n\tmodel?: unknown;\n\tbackground?: unknown;\n};\n\nfunction readMarkdownFilesRecursive(root: string): string[] {\n\tif (!existsSync(root)) return [];\n\tconst files: string[] = [];\n\tconst walk = (dir: string): void => {\n\t\tconst entries = readdirSync(dir, { withFileTypes: true }).sort((left, right) =>\n\t\t\tleft.name.localeCompare(right.name),\n\t\t);\n\t\tfor (const entry of entries) {\n\t\t\tconst full = join(dir, entry.name);\n\t\t\tif (entry.isDirectory()) {\n\t\t\t\twalk(full);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (entry.isFile() && entry.name.toLowerCase().endsWith(\".md\")) {\n\t\t\t\tfiles.push(full);\n\t\t\t}\n\t\t}\n\t};\n\twalk(root);\n\treturn files;\n}\n\nfunction asStringArray(value: unknown): string[] | undefined {\n\tif (Array.isArray(value)) {\n\t\tconst normalized = value.map((item) => String(item).trim()).filter(Boolean);\n\t\treturn normalized.length > 0 ? normalized : undefined;\n\t}\n\tif (typeof value === \"string\") {\n\t\tconst normalized = value\n\t\t\t.split(\",\")\n\t\t\t.map((item) => item.trim())\n\t\t\t.filter(Boolean);\n\t\treturn normalized.length > 0 ? normalized : undefined;\n\t}\n\treturn undefined;\n}\n\nfunction parseSubagentFile(filePath: string, cwd: string): { agent?: CustomSubagentDefinition; diagnostic?: SubagentDiagnostic } {\n\tlet content: string;\n\ttry {\n\t\tcontent = readFileSync(filePath, \"utf8\");\n\t} catch (error) {\n\t\treturn {\n\t\t\tdiagnostic: { path: filePath, message: `Failed to read file: ${error instanceof Error ? error.message : String(error)}` },\n\t\t};\n\t}\n\n\tconst { frontmatter, body } = parseFrontmatter<ParsedFrontmatter>(content);\n\tconst nameRaw = typeof frontmatter.name === \"string\" ? frontmatter.name.trim() : \"\";\n\tconst defaultName = filePath.split(\"/\").pop()?.replace(/\\.md$/i, \"\") ?? \"subagent\";\n\tconst name = (nameRaw || defaultName).trim();\n\tconst description = typeof frontmatter.description === \"string\" ? frontmatter.description.trim() : \"\";\n\tconst profile =\n\t\ttypeof frontmatter.profile === \"string\" && frontmatter.profile.trim().length > 0\n\t\t\t? (frontmatter.profile.trim() as AgentProfileName)\n\t\t\t: undefined;\n\tconst tools = asStringArray(frontmatter.tools);\n\tconst disallowedTools = asStringArray(frontmatter.disallowed_tools);\n\tconst systemPrompt =\n\t\ttypeof frontmatter.system_prompt === \"string\" && frontmatter.system_prompt.trim().length > 0\n\t\t\t? frontmatter.system_prompt.trim()\n\t\t\t: undefined;\n\tconst configuredCwd =\n\t\ttypeof frontmatter.cwd === \"string\" && frontmatter.cwd.trim().length > 0\n\t\t\t? resolve(cwd, frontmatter.cwd.trim())\n\t\t\t: undefined;\n\n\tif (configuredCwd) {\n\t\ttry {\n\t\t\tif (!existsSync(configuredCwd) || !statSync(configuredCwd).isDirectory()) {\n\t\t\t\treturn { diagnostic: { path: filePath, message: `Configured cwd is invalid: ${configuredCwd}` } };\n\t\t\t}\n\t\t} catch {\n\t\t\treturn { diagnostic: { path: filePath, message: `Configured cwd is invalid: ${configuredCwd}` } };\n\t\t}\n\t}\n\n\tconst instructions = body.trim();\n\tif (!instructions) {\n\t\treturn { diagnostic: { path: filePath, message: \"Subagent instructions are empty.\" } };\n\t}\n\n\treturn {\n\t\tagent: {\n\t\t\tname,\n\t\t\tdescription: description || `Custom subagent ${name}`,\n\t\t\tsourcePath: filePath,\n\t\t\tprofile,\n\t\t\ttools,\n\t\t\tdisallowedTools,\n\t\t\tsystemPrompt,\n\t\t\tinstructions,\n\t\t\tcwd: configuredCwd,\n\t\t\tmodel: typeof frontmatter.model === \"string\" ? frontmatter.model.trim() : undefined,\n\t\t\tbackground: frontmatter.background === true,\n\t\t},\n\t};\n}\n\nexport function loadCustomSubagents(options: { cwd: string; agentDir: string }): LoadCustomSubagentsResult {\n\tconst roots: Array<{ path: string; scope: CustomSubagentSourceScope; priority: number }> = [\n\t\t{ path: join(options.agentDir, \"agents\"), scope: \"global\", priority: 0 },\n\t\t{ path: join(options.cwd, \".iosm\", \"agents\"), scope: \"project\", priority: 1 },\n\t];\n\tconst diagnostics: SubagentDiagnostic[] = [];\n\tconst overrides: SubagentOverrideInfo[] = [];\n\tconst allAgents: CustomSubagentEntry[] = [];\n\tconst byName = new Map<string, CustomSubagentEntry>();\n\n\tconst registerEntry = (entry: CustomSubagentEntry): void => {\n\t\tconst existing = byName.get(entry.name);\n\t\tif (!existing) {\n\t\t\tentry.effective = true;\n\t\t\tbyName.set(entry.name, entry);\n\t\t\tallAgents.push(entry);\n\t\t\treturn;\n\t\t}\n\n\t\tconst shouldReplace =\n\t\t\tentry.sourcePriority > existing.sourcePriority ||\n\t\t\t(entry.sourcePriority === existing.sourcePriority &&\n\t\t\t\tentry.sourcePath.localeCompare(existing.sourcePath) > 0);\n\n\t\tif (entry.sourcePriority === existing.sourcePriority) {\n\t\t\tdiagnostics.push({\n\t\t\t\tpath: entry.sourcePath,\n\t\t\t\tmessage: `Duplicate agent \"${entry.name}\" in ${entry.sourceScope} scope; ${\n\t\t\t\t\tshouldReplace ? \"this file takes precedence\" : \"existing file keeps precedence\"\n\t\t\t\t}.`,\n\t\t\t});\n\t\t}\n\n\t\tif (shouldReplace) {\n\t\t\texisting.effective = false;\n\t\t\texisting.overriddenByPath = entry.sourcePath;\n\t\t\tentry.effective = true;\n\t\t\tbyName.set(entry.name, entry);\n\t\t\toverrides.push({\n\t\t\t\tname: entry.name,\n\t\t\t\twinnerPath: entry.sourcePath,\n\t\t\t\twinnerScope: entry.sourceScope,\n\t\t\t\toverriddenPath: existing.sourcePath,\n\t\t\t\toverriddenScope: existing.sourceScope,\n\t\t\t});\n\t\t} else {\n\t\t\tentry.overriddenByPath = existing.sourcePath;\n\t\t\toverrides.push({\n\t\t\t\tname: entry.name,\n\t\t\t\twinnerPath: existing.sourcePath,\n\t\t\t\twinnerScope: existing.sourceScope,\n\t\t\t\toverriddenPath: entry.sourcePath,\n\t\t\t\toverriddenScope: entry.sourceScope,\n\t\t\t});\n\t\t}\n\n\t\tallAgents.push(entry);\n\t};\n\n\tfor (const builtin of BUILTIN_SUBAGENTS) {\n\t\tregisterEntry({\n\t\t\t...builtin,\n\t\t\tsourceScope: \"builtin\",\n\t\t\tsourcePriority: BUILTIN_SUBAGENT_PRIORITY,\n\t\t\teffective: false,\n\t\t});\n\t}\n\n\tfor (const root of roots) {\n\t\tfor (const file of readMarkdownFilesRecursive(root.path)) {\n\t\t\tconst parsed = parseSubagentFile(file, options.cwd);\n\t\t\tif (parsed.diagnostic) {\n\t\t\t\tdiagnostics.push(parsed.diagnostic);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (!parsed.agent) continue;\n\t\t\tconst entry: CustomSubagentEntry = {\n\t\t\t\t...parsed.agent,\n\t\t\t\tsourceScope: root.scope,\n\t\t\t\tsourcePriority: root.priority,\n\t\t\t\teffective: false,\n\t\t\t};\n\t\t\tregisterEntry(entry);\n\t\t}\n\t}\n\n\tconst agents = Array.from(byName.values()).sort((left, right) => left.name.localeCompare(right.name));\n\tallAgents.sort((left, right) => {\n\t\tconst nameCompare = left.name.localeCompare(right.name);\n\t\tif (nameCompare !== 0) return nameCompare;\n\t\treturn right.sourcePriority - left.sourcePriority;\n\t});\n\treturn { agents, allAgents, overrides, diagnostics };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"subagents.js","sourceRoot":"","sources":["../../src/core/subagents.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAC1E,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,OAAO,EAAE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AAiB,CAAC,IAAI,EAAE,OAAO,CAAC,GAAG,CAAC,CAAC;YACpD,IAAI,MAAM,CAAC,UAAU,EAAE,CAAC;gBACvB,WAAW,CAAC,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;gBACpC,SAAS;YACV,CAAC;YACD,IAAI,CAAC,MAAM,CAAC,KAAK;gBAAE,SAAS;YAC5B,MAAM,KAAK,GAAwB;gBAClC,GAAG,MAAM,CAAC,KAAK;gBACf,WAAW,EAAE,IAAI,CAAC,KAAK;gBACvB,cAAc,EAAE,IAAI,CAAC,QAAQ;gBAC7B,SAAS,EAAE,KAAK;aAChB,CAAC;YACF,aAAa,CAAC,KAAK,CAAC,CAAC;QACtB,CAAC;IACF,CAAC;IAED,MAAM,MAAM,GAAG,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC;IACtG,SAAS,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE;QAC9B,MAAM,WAAW,GAAG,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QACxD,IAAI,WAAW,KAAK,CAAC;YAAE,OAAO,WAAW,CAAC;QAC1C,OAAO,KAAK,CAAC,cAAc,GAAG,IAAI,CAAC,cAAc,CAAC;IACnD,CAAC,CAAC,CAAC;IACH,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,SAAS,EAAE,WAAW,EAAE,CAAC;AACtD,CAAC","sourcesContent":["import { existsSync, readdirSync, readFileSync, statSync } from \"node:fs\";\nimport { basename, join, resolve } from \"node:path\";\nimport { parseFrontmatter } from \"../utils/frontmatter.js\";\nimport type { AgentProfileName } from \"./agent-profiles.js\";\n\nexport type CustomSubagentSourceScope = \"builtin\" | \"global\" | \"project\";\n\nexport interface CustomSubagentDefinition {\n\tname: string;\n\tdescription: string;\n\tsourcePath: string;\n\tprofile?: AgentProfileName;\n\ttools?: string[];\n\tdisallowedTools?: string[];\n\tsystemPrompt?: string;\n\tinstructions: string;\n\tcwd?: string;\n\tmodel?: string;\n\tbackground?: boolean;\n}\n\nexport interface CustomSubagentEntry extends CustomSubagentDefinition {\n\tsourceScope: CustomSubagentSourceScope;\n\tsourcePriority: number;\n\teffective: boolean;\n\toverriddenByPath?: string;\n}\n\nexport interface SubagentOverrideInfo {\n\tname: string;\n\twinnerPath: string;\n\twinnerScope: CustomSubagentSourceScope;\n\toverriddenPath: string;\n\toverriddenScope: CustomSubagentSourceScope;\n}\n\nexport interface SubagentDiagnostic {\n\tpath: string;\n\tmessage: string;\n}\n\nexport interface LoadCustomSubagentsResult {\n\tagents: CustomSubagentEntry[];\n\tallAgents: CustomSubagentEntry[];\n\toverrides: SubagentOverrideInfo[];\n\tdiagnostics: SubagentDiagnostic[];\n}\n\nconst BUILTIN_SUBAGENT_PRIORITY = -1;\n\nconst BUILTIN_SUBAGENTS: CustomSubagentDefinition[] = [\n\t{\n\t\tname: \"codebase_auditor\",\n\t\tdescription: \"Structured codebase audit for architecture, reliability, security, and test gaps.\",\n\t\tsourcePath: \"builtin://codebase_auditor.md\",\n\t\tprofile: \"explore\",\n\t\tinstructions: [\n\t\t\t\"You are a codebase auditor.\",\n\t\t\t\"\",\n\t\t\t\"Goal:\",\n\t\t\t\"- Produce an evidence-based audit of architecture, defect risks, and maintainability hotspots.\",\n\t\t\t\"\",\n\t\t\t\"Rules:\",\n\t\t\t\"- Read-only operation. Never edit files.\",\n\t\t\t\"- Make claims only with direct repository evidence.\",\n\t\t\t\"- Prioritize by user impact and likelihood (P0..P3).\",\n\t\t\t\"- If the assigned audit still spans multiple independent subsystems and delegation protocol is available, split it with nested delegates instead of producing one monolithic audit.\",\n\t\t\t\"\",\n\t\t\t\"Required output:\",\n\t\t\t\"1) Findings (ordered by severity)\",\n\t\t\t\"2) Open questions/unknowns\",\n\t\t\t\"3) Recommended next actions\",\n\t\t\t\"\",\n\t\t\t\"For each finding include:\",\n\t\t\t\"- file path + line reference (when available)\",\n\t\t\t\"- risk/impact\",\n\t\t\t\"- concrete fix direction\",\n\t\t\t\"\",\n\t\t\t\"If no issues are found, explicitly state 'No findings' and list residual risks/testing gaps.\",\n\t\t].join(\"\\n\"),\n\t},\n\t{\n\t\tname: \"system_error_analyst\",\n\t\tdescription: \"Diagnoses system/runtime failures and produces root-cause + fix plan.\",\n\t\tsourcePath: \"builtin://system_error_analyst.md\",\n\t\tprofile: \"plan\",\n\t\tinstructions: [\n\t\t\t\"You are a system error analyst.\",\n\t\t\t\"\",\n\t\t\t\"Goal:\",\n\t\t\t\"- Triage failures, identify probable root cause, and propose a minimal, testable fix plan.\",\n\t\t\t\"\",\n\t\t\t\"Rules:\",\n\t\t\t\"- Do not modify files.\",\n\t\t\t\"- Use deterministic evidence (logs, stack traces, tests, configs).\",\n\t\t\t\"- Distinguish facts vs hypotheses explicitly.\",\n\t\t\t\"\",\n\t\t\t\"Required output:\",\n\t\t\t\"1) Incident summary\",\n\t\t\t\"2) Root-cause analysis (ranked hypotheses with evidence)\",\n\t\t\t\"3) Minimal patch plan\",\n\t\t\t\"4) Verification plan (commands + expected signals)\",\n\t\t\t\"5) Regression risks\",\n\t\t\t\"\",\n\t\t\t\"Escalation guidance:\",\n\t\t\t\"- If data is insufficient, request the minimum missing evidence instead of guessing.\",\n\t\t].join(\"\\n\"),\n\t},\n\t{\n\t\tname: \"iosm_change_executor\",\n\t\tdescription: \"Implements repository changes under IOSM methodology and keeps artifacts aligned.\",\n\t\tsourcePath: \"builtin://iosm_change_executor.md\",\n\t\tprofile: \"iosm\",\n\t\tinstructions: [\n\t\t\t\"You are an IOSM change executor.\",\n\t\t\t\"\",\n\t\t\t\"Goal:\",\n\t\t\t\"- Analyze, implement, and verify changes while preserving IOSM methodology and artifact consistency.\",\n\t\t\t\"\",\n\t\t\t\"Execution policy:\",\n\t\t\t\"- Inspect relevant code and .iosm artifacts before edits.\",\n\t\t\t\"- Make minimal, targeted changes with clear rationale.\",\n\t\t\t\"- Run focused verification after each meaningful change.\",\n\t\t\t\"- Keep IOSM artifacts in sync when behavior/metrics assumptions change.\",\n\t\t\t\"\",\n\t\t\t\"Required output:\",\n\t\t\t\"1) What changed and why\",\n\t\t\t\"2) Files changed\",\n\t\t\t\"3) Verification executed and results\",\n\t\t\t\"4) Remaining risks/assumptions\",\n\t\t\t\"\",\n\t\t\t\"Safety rules:\",\n\t\t\t\"- Do not introduce speculative changes.\",\n\t\t\t\"- If requirements are ambiguous, ask a concise clarification before risky edits.\",\n\t\t].join(\"\\n\"),\n\t},\n\t{\n\t\tname: \"iosm_postchange_verifier\",\n\t\tdescription: \"Post-change IOSM verifier for metric/artifact integrity and regression checks.\",\n\t\tsourcePath: \"builtin://iosm_postchange_verifier.md\",\n\t\tprofile: \"iosm_verifier\",\n\t\tinstructions: [\n\t\t\t\"You are an IOSM post-change verifier.\",\n\t\t\t\"\",\n\t\t\t\"Goal:\",\n\t\t\t\"- Validate that implemented changes are correctly reflected in IOSM metrics/artifacts.\",\n\t\t\t\"\",\n\t\t\t\"Rules:\",\n\t\t\t\"- Restrict edits to .iosm artifacts unless explicitly instructed otherwise.\",\n\t\t\t\"- Prefer deterministic checks and reproducible commands.\",\n\t\t\t\"- Report mismatches and exact remediation steps.\",\n\t\t\t\"\",\n\t\t\t\"Required output:\",\n\t\t\t\"1) Checks performed\",\n\t\t\t\"2) Pass/fail per check\",\n\t\t\t\"3) Artifact updates applied (if any)\",\n\t\t\t\"4) Remaining discrepancies and follow-ups\",\n\t\t].join(\"\\n\"),\n\t},\n\t{\n\t\tname: \"qa_test_engineer\",\n\t\tdescription: \"Writes tests, runs verification, and fixes regressions with evidence-driven workflow.\",\n\t\tsourcePath: \"builtin://qa_test_engineer.md\",\n\t\tprofile: \"full\",\n\t\tinstructions: [\n\t\t\t\"You are a QA test engineer and regression fixer.\",\n\t\t\t\"\",\n\t\t\t\"Goal:\",\n\t\t\t\"- Increase confidence by adding/updating tests, reproducing failures, and fixing root causes.\",\n\t\t\t\"\",\n\t\t\t\"Workflow:\",\n\t\t\t\"1) Reproduce failure (or define expected behavior if bug is not reproducible yet).\",\n\t\t\t\"2) Add/update focused tests that capture expected behavior.\",\n\t\t\t\"3) Run targeted tests first, then broader suite if needed.\",\n\t\t\t\"4) Implement minimal fix in production code.\",\n\t\t\t\"5) Re-run tests and report outcomes.\",\n\t\t\t\"\",\n\t\t\t\"Rules:\",\n\t\t\t\"- Never hide failures by removing assertions or disabling tests unless explicitly requested.\",\n\t\t\t\"- Prefer deterministic tests; avoid flaky timing assumptions.\",\n\t\t\t\"- Keep patch size minimal and localized.\",\n\t\t\t\"\",\n\t\t\t\"Required output:\",\n\t\t\t\"1) Root cause summary\",\n\t\t\t\"2) Tests added/updated\",\n\t\t\t\"3) Code fixes applied\",\n\t\t\t\"4) Commands executed + pass/fail results\",\n\t\t\t\"5) Residual risk\",\n\t\t].join(\"\\n\"),\n\t},\n\t{\n\t\tname: \"test_failure_triager\",\n\t\tdescription: \"Analyzes failing/flaky tests and proposes a ranked remediation plan.\",\n\t\tsourcePath: \"builtin://test_failure_triager.md\",\n\t\tprofile: \"plan\",\n\t\tinstructions: [\n\t\t\t\"You are a test-failure triage specialist.\",\n\t\t\t\"\",\n\t\t\t\"Goal:\",\n\t\t\t\"- Analyze failures quickly and produce a ranked, actionable remediation plan.\",\n\t\t\t\"\",\n\t\t\t\"Rules:\",\n\t\t\t\"- Read/analyze only; do not edit files.\",\n\t\t\t\"- Separate infra/environment issues from product-code defects.\",\n\t\t\t\"- Label confidence for each hypothesis.\",\n\t\t\t\"\",\n\t\t\t\"Required output:\",\n\t\t\t\"1) Failure classification (deterministic, flaky, environment, unknown)\",\n\t\t\t\"2) Ranked hypotheses with evidence\",\n\t\t\t\"3) Minimal next steps to verify each hypothesis\",\n\t\t\t\"4) Recommended owner/agent to execute fixes\",\n\t\t].join(\"\\n\"),\n\t},\n\t{\n\t\tname: \"meta_orchestrator\",\n\t\tdescription: \"Autonomous orchestration lead: audits, plans, and delegates parallel specialists safely.\",\n\t\tsourcePath: \"builtin://meta_orchestrator.md\",\n\t\tprofile: \"meta\",\n\t\t\tinstructions: [\n\t\t\t\t\"You are the main orchestration agent for complex engineering tasks.\",\n\t\t\t\t\"\",\n\t\t\t\t\"Goal:\",\n\t\t\t\t\"- Drive tasks end-to-end with dynamic delegation: audit -> plan -> execution -> verification.\",\n\t\t\t\t\"- Act as the lead orchestrator, not as a substitute for the parent session runtime.\",\n\t\t\t\t\"\",\n\t\t\t\t\"Required operating phases:\",\n\t\t\t\t\"1) Recon: do bounded read-only inspection to identify repository context, constraints, and relevant files.\",\n\t\t\t\t\"2) Plan: split work into an explicit execution graph of tasks/delegates, including dependencies and lock domains where needed.\",\n\t\t\t\t\"3) Execute adaptively: trivial tasks may stay single-agent; medium/complex tasks should maximize safe parallelism via <delegate_task> and multiple focused workstreams.\",\n\t\t\t\t\"4) Verify: for any code or test changes, add/update tests and run targeted verification before closure.\",\n\t\t\t\t\"5) Synthesize: provide integrated results, unresolved risks, and next actions only after all launched delegates are resolved.\",\n\t\t\t\t\"\",\n\t\t\t\t\"Delegation policy:\",\n\t\t\t\t\"- Main emphasis in META orchestration is parallelism: use as many focused agents and delegates as the task can support safely, rather than defaulting to one broad worker.\",\n\t\t\t\t\"- Recon is only preparation; once you can name the workstreams, stop exploring and delegate.\",\n\t\t\t\t\"- For non-trivial work, assume multi-agent parallel fan-out is required unless you can justify why it is not useful.\",\n\t\t\t\t\"- Decide number of delegates based on task complexity (usually 1-10), and prefer higher fan-out when the work naturally splits.\",\n\t\t\t\t\"- For medium/complex work, target aggressive safe parallel fan-out (commonly >=3 delegates) when independent slices exist.\",\n\t\t\t\t\"- If the user asked for N parallel agents, match that fan-out when feasible or explain the exact blocker.\",\n\t\t\t\t\"- If a delegate owns a task that still contains multiple independent slices, that delegate should split again with nested delegates instead of executing everything alone.\",\n\t\t\t\t\"- Run independent read-heavy work in parallel by emitting multiple delegate blocks.\",\n\t\t\t\t\"- For write-capable delegates touching overlapping areas, provide lock_key to avoid edit collisions.\",\n\t\t\t\t\"- Use depends_on to enforce ordering for dependent steps (for example verification after implementation).\",\n\t\t\t\t\"- Use clear description values and focused prompts per delegate.\",\n\t\t\t\t\"- Do not keep doing direct implementation in the orchestrator after recon for non-trivial work; delegate first.\",\n\t\t\t\t\"- Do not collapse the whole implementation into one specialist delegate when multiple independent workstreams exist.\",\n\t\t\t\t\"- If you keep any non-trivial work single-agent or undelegated, include one line: DELEGATION_IMPOSSIBLE: <reason>.\",\n\t\t\t\"\",\n\t\t\t\"Suggested specialist mapping:\",\n\t\t\t\"- architecture/recon -> profile=explore or plan\",\n\t\t\t\"- implementation -> profile=meta or full or iosm\",\n\t\t\t\"- iosm artifact validation -> profile=iosm_verifier\",\n\t\t\t\"- test creation/fixes -> profile=full (or qa_test_engineer when referenced)\",\n\t\t\t\"\",\n\t\t\t\"Safety rules:\",\n\t\t\t\"- Avoid broad overlapping writes without lock separation.\",\n\t\t\t\"- If requirements are ambiguous and risky, ask for minimal clarification before destructive changes.\",\n\t\t\t\"- Keep all delegated prompts concrete and scoped to specific files/behaviors.\",\n\t\t\t\"- Do not claim completion while any launched delegate remains pending/running.\",\n\t\t\t\"- If no code changed and tests were skipped, include an explicit safety justification.\",\n\t\t\t\"\",\n\t\t\t\"Output requirements:\",\n\t\t\t\"- concise execution summary\",\n\t\t\t\"- delegated work breakdown\",\n\t\t\t\"- verification status\",\n\t\t\t\"- residual risks/assumptions\",\n\t\t].join(\"\\n\"),\n\t},\n];\n\nfunction trimWrappingChars(value: string): string {\n\tlet next = value.trim();\n\tnext = next.replace(/^@+/, \"\");\n\tnext = next.replace(/^[`\"'“”‘’]+/, \"\");\n\tnext = next.replace(/[`\"'“”‘’]+$/, \"\");\n\tnext = next.replace(/[),;:!?]+$/, \"\");\n\treturn next.trim();\n}\n\nfunction pushCandidate(set: Set<string>, value: string): void {\n\tconst trimmed = value.trim();\n\tif (!trimmed) return;\n\tset.add(trimmed);\n}\n\nexport function getSubagentLookupCandidates(reference: string): string[] {\n\tconst cleaned = trimWrappingChars(reference);\n\tif (!cleaned) return [];\n\tconst normalized = cleaned.replace(/\\\\/g, \"/\");\n\tconst lowerNormalized = normalized.toLowerCase();\n\tconst candidates = new Set<string>();\n\n\tpushCandidate(candidates, cleaned);\n\tpushCandidate(candidates, cleaned.replace(/\\.md$/i, \"\"));\n\tpushCandidate(candidates, normalized);\n\tpushCandidate(candidates, normalized.replace(/\\.md$/i, \"\"));\n\n\tconst pathMarkers = [\"/.iosm/agents/\", \".iosm/agents/\", \"/agents/\", \"agents/\"];\n\tfor (const marker of pathMarkers) {\n\t\tconst markerIndex = lowerNormalized.lastIndexOf(marker.toLowerCase());\n\t\tif (markerIndex === -1) continue;\n\t\tconst suffix = normalized.slice(markerIndex + marker.length);\n\t\tpushCandidate(candidates, suffix);\n\t\tpushCandidate(candidates, suffix.replace(/\\.md$/i, \"\"));\n\t}\n\n\tconst baseFromNormalized = normalized.split(\"/\").filter(Boolean).pop() ?? \"\";\n\tconst baseFromPath = basename(cleaned);\n\tpushCandidate(candidates, baseFromNormalized);\n\tpushCandidate(candidates, baseFromNormalized.replace(/\\.md$/i, \"\"));\n\tpushCandidate(candidates, baseFromPath);\n\tpushCandidate(candidates, baseFromPath.replace(/\\.md$/i, \"\"));\n\n\treturn Array.from(candidates);\n}\n\nexport function resolveCustomSubagentReference(\n\treference: string,\n\tagents: ReadonlyArray<Pick<CustomSubagentDefinition, \"name\" | \"sourcePath\">>,\n): string | undefined {\n\tif (agents.length === 0) return undefined;\n\tconst byName = new Map<string, string>();\n\tconst byNameLower = new Map<string, string>();\n\tconst bySourceBaseLower = new Map<string, string>();\n\n\tfor (const agent of agents) {\n\t\tbyName.set(agent.name, agent.name);\n\t\tbyNameLower.set(agent.name.toLowerCase(), agent.name);\n\n\t\tconst sourceBase = basename(agent.sourcePath);\n\t\tif (sourceBase) {\n\t\t\tconst sourceBaseLower = sourceBase.toLowerCase();\n\t\t\tif (!bySourceBaseLower.has(sourceBaseLower)) {\n\t\t\t\tbySourceBaseLower.set(sourceBaseLower, agent.name);\n\t\t\t}\n\t\t\tconst sourceBaseNoMdLower = sourceBase.replace(/\\.md$/i, \"\").toLowerCase();\n\t\t\tif (!bySourceBaseLower.has(sourceBaseNoMdLower)) {\n\t\t\t\tbySourceBaseLower.set(sourceBaseNoMdLower, agent.name);\n\t\t\t}\n\t\t}\n\t}\n\n\tfor (const candidate of getSubagentLookupCandidates(reference)) {\n\t\tconst exact = byName.get(candidate);\n\t\tif (exact) return exact;\n\n\t\tconst lower = candidate.toLowerCase();\n\t\tconst byLower = byNameLower.get(lower);\n\t\tif (byLower) return byLower;\n\t\tconst withoutMd = lower.replace(/\\.md$/i, \"\");\n\t\tconst byWithoutMd = byNameLower.get(withoutMd);\n\t\tif (byWithoutMd) return byWithoutMd;\n\n\t\tconst byBase = bySourceBaseLower.get(lower) ?? bySourceBaseLower.get(withoutMd);\n\t\tif (byBase) return byBase;\n\t}\n\n\treturn undefined;\n}\n\ntype ParsedFrontmatter = {\n\tname?: unknown;\n\tdescription?: unknown;\n\tprofile?: unknown;\n\ttools?: unknown;\n\tdisallowed_tools?: unknown;\n\tsystem_prompt?: unknown;\n\tcwd?: unknown;\n\tmodel?: unknown;\n\tbackground?: unknown;\n};\n\nfunction readMarkdownFilesRecursive(root: string): string[] {\n\tif (!existsSync(root)) return [];\n\tconst files: string[] = [];\n\tconst walk = (dir: string): void => {\n\t\tconst entries = readdirSync(dir, { withFileTypes: true }).sort((left, right) =>\n\t\t\tleft.name.localeCompare(right.name),\n\t\t);\n\t\tfor (const entry of entries) {\n\t\t\tconst full = join(dir, entry.name);\n\t\t\tif (entry.isDirectory()) {\n\t\t\t\twalk(full);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (entry.isFile() && entry.name.toLowerCase().endsWith(\".md\")) {\n\t\t\t\tfiles.push(full);\n\t\t\t}\n\t\t}\n\t};\n\twalk(root);\n\treturn files;\n}\n\nfunction asStringArray(value: unknown): string[] | undefined {\n\tif (Array.isArray(value)) {\n\t\tconst normalized = value.map((item) => String(item).trim()).filter(Boolean);\n\t\treturn normalized.length > 0 ? normalized : undefined;\n\t}\n\tif (typeof value === \"string\") {\n\t\tconst normalized = value\n\t\t\t.split(\",\")\n\t\t\t.map((item) => item.trim())\n\t\t\t.filter(Boolean);\n\t\treturn normalized.length > 0 ? normalized : undefined;\n\t}\n\treturn undefined;\n}\n\nfunction parseSubagentFile(filePath: string, cwd: string): { agent?: CustomSubagentDefinition; diagnostic?: SubagentDiagnostic } {\n\tlet content: string;\n\ttry {\n\t\tcontent = readFileSync(filePath, \"utf8\");\n\t} catch (error) {\n\t\treturn {\n\t\t\tdiagnostic: { path: filePath, message: `Failed to read file: ${error instanceof Error ? error.message : String(error)}` },\n\t\t};\n\t}\n\n\tconst { frontmatter, body } = parseFrontmatter<ParsedFrontmatter>(content);\n\tconst nameRaw = typeof frontmatter.name === \"string\" ? frontmatter.name.trim() : \"\";\n\tconst defaultName = filePath.split(\"/\").pop()?.replace(/\\.md$/i, \"\") ?? \"subagent\";\n\tconst name = (nameRaw || defaultName).trim();\n\tconst description = typeof frontmatter.description === \"string\" ? frontmatter.description.trim() : \"\";\n\tconst profile =\n\t\ttypeof frontmatter.profile === \"string\" && frontmatter.profile.trim().length > 0\n\t\t\t? (frontmatter.profile.trim() as AgentProfileName)\n\t\t\t: undefined;\n\tconst tools = asStringArray(frontmatter.tools);\n\tconst disallowedTools = asStringArray(frontmatter.disallowed_tools);\n\tconst systemPrompt =\n\t\ttypeof frontmatter.system_prompt === \"string\" && frontmatter.system_prompt.trim().length > 0\n\t\t\t? frontmatter.system_prompt.trim()\n\t\t\t: undefined;\n\tconst configuredCwd =\n\t\ttypeof frontmatter.cwd === \"string\" && frontmatter.cwd.trim().length > 0\n\t\t\t? resolve(cwd, frontmatter.cwd.trim())\n\t\t\t: undefined;\n\n\tif (configuredCwd) {\n\t\ttry {\n\t\t\tif (!existsSync(configuredCwd) || !statSync(configuredCwd).isDirectory()) {\n\t\t\t\treturn { diagnostic: { path: filePath, message: `Configured cwd is invalid: ${configuredCwd}` } };\n\t\t\t}\n\t\t} catch {\n\t\t\treturn { diagnostic: { path: filePath, message: `Configured cwd is invalid: ${configuredCwd}` } };\n\t\t}\n\t}\n\n\tconst instructions = body.trim();\n\tif (!instructions) {\n\t\treturn { diagnostic: { path: filePath, message: \"Subagent instructions are empty.\" } };\n\t}\n\n\treturn {\n\t\tagent: {\n\t\t\tname,\n\t\t\tdescription: description || `Custom subagent ${name}`,\n\t\t\tsourcePath: filePath,\n\t\t\tprofile,\n\t\t\ttools,\n\t\t\tdisallowedTools,\n\t\t\tsystemPrompt,\n\t\t\tinstructions,\n\t\t\tcwd: configuredCwd,\n\t\t\tmodel: typeof frontmatter.model === \"string\" ? frontmatter.model.trim() : undefined,\n\t\t\tbackground: frontmatter.background === true,\n\t\t},\n\t};\n}\n\nexport function loadCustomSubagents(options: { cwd: string; agentDir: string }): LoadCustomSubagentsResult {\n\tconst roots: Array<{ path: string; scope: CustomSubagentSourceScope; priority: number }> = [\n\t\t{ path: join(options.agentDir, \"agents\"), scope: \"global\", priority: 0 },\n\t\t{ path: join(options.cwd, \".iosm\", \"agents\"), scope: \"project\", priority: 1 },\n\t];\n\tconst diagnostics: SubagentDiagnostic[] = [];\n\tconst overrides: SubagentOverrideInfo[] = [];\n\tconst allAgents: CustomSubagentEntry[] = [];\n\tconst byName = new Map<string, CustomSubagentEntry>();\n\n\tconst registerEntry = (entry: CustomSubagentEntry): void => {\n\t\tconst existing = byName.get(entry.name);\n\t\tif (!existing) {\n\t\t\tentry.effective = true;\n\t\t\tbyName.set(entry.name, entry);\n\t\t\tallAgents.push(entry);\n\t\t\treturn;\n\t\t}\n\n\t\tconst shouldReplace =\n\t\t\tentry.sourcePriority > existing.sourcePriority ||\n\t\t\t(entry.sourcePriority === existing.sourcePriority &&\n\t\t\t\tentry.sourcePath.localeCompare(existing.sourcePath) > 0);\n\n\t\tif (entry.sourcePriority === existing.sourcePriority) {\n\t\t\tdiagnostics.push({\n\t\t\t\tpath: entry.sourcePath,\n\t\t\t\tmessage: `Duplicate agent \"${entry.name}\" in ${entry.sourceScope} scope; ${\n\t\t\t\t\tshouldReplace ? \"this file takes precedence\" : \"existing file keeps precedence\"\n\t\t\t\t}.`,\n\t\t\t});\n\t\t}\n\n\t\tif (shouldReplace) {\n\t\t\texisting.effective = false;\n\t\t\texisting.overriddenByPath = entry.sourcePath;\n\t\t\tentry.effective = true;\n\t\t\tbyName.set(entry.name, entry);\n\t\t\toverrides.push({\n\t\t\t\tname: entry.name,\n\t\t\t\twinnerPath: entry.sourcePath,\n\t\t\t\twinnerScope: entry.sourceScope,\n\t\t\t\toverriddenPath: existing.sourcePath,\n\t\t\t\toverriddenScope: existing.sourceScope,\n\t\t\t});\n\t\t} else {\n\t\t\tentry.overriddenByPath = existing.sourcePath;\n\t\t\toverrides.push({\n\t\t\t\tname: entry.name,\n\t\t\t\twinnerPath: existing.sourcePath,\n\t\t\t\twinnerScope: existing.sourceScope,\n\t\t\t\toverriddenPath: entry.sourcePath,\n\t\t\t\toverriddenScope: entry.sourceScope,\n\t\t\t});\n\t\t}\n\n\t\tallAgents.push(entry);\n\t};\n\n\tfor (const builtin of BUILTIN_SUBAGENTS) {\n\t\tregisterEntry({\n\t\t\t...builtin,\n\t\t\tsourceScope: \"builtin\",\n\t\t\tsourcePriority: BUILTIN_SUBAGENT_PRIORITY,\n\t\t\teffective: false,\n\t\t});\n\t}\n\n\tfor (const root of roots) {\n\t\tfor (const file of readMarkdownFilesRecursive(root.path)) {\n\t\t\tconst parsed = parseSubagentFile(file, options.cwd);\n\t\t\tif (parsed.diagnostic) {\n\t\t\t\tdiagnostics.push(parsed.diagnostic);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (!parsed.agent) continue;\n\t\t\tconst entry: CustomSubagentEntry = {\n\t\t\t\t...parsed.agent,\n\t\t\t\tsourceScope: root.scope,\n\t\t\t\tsourcePriority: root.priority,\n\t\t\t\teffective: false,\n\t\t\t};\n\t\t\tregisterEntry(entry);\n\t\t}\n\t}\n\n\tconst agents = Array.from(byName.values()).sort((left, right) => left.name.localeCompare(right.name));\n\tallAgents.sort((left, right) => {\n\t\tconst nameCompare = left.name.localeCompare(right.name);\n\t\tif (nameCompare !== 0) return nameCompare;\n\t\treturn right.sourcePriority - left.sourcePriority;\n\t});\n\treturn { agents, allAgents, overrides, diagnostics };\n}\n"]}
|
|
@@ -3,8 +3,10 @@ import { type Static } from "@sinclair/typebox";
|
|
|
3
3
|
import type { ToolPermissionGuard } from "./permissions.js";
|
|
4
4
|
declare const editSchema: import("@sinclair/typebox").TObject<{
|
|
5
5
|
path: import("@sinclair/typebox").TString;
|
|
6
|
-
oldText: import("@sinclair/typebox").TString
|
|
7
|
-
|
|
6
|
+
oldText: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
7
|
+
findText: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
8
|
+
newText: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
9
|
+
replaceText: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
8
10
|
}>;
|
|
9
11
|
export type EditToolInput = Static<typeof editSchema>;
|
|
10
12
|
export interface EditToolDetails {
|
|
@@ -35,8 +37,10 @@ export declare function createEditTool(cwd: string, options?: EditToolOptions):
|
|
|
35
37
|
/** Default edit tool using process.cwd() - for backwards compatibility */
|
|
36
38
|
export declare const editTool: AgentTool<import("@sinclair/typebox").TObject<{
|
|
37
39
|
path: import("@sinclair/typebox").TString;
|
|
38
|
-
oldText: import("@sinclair/typebox").TString
|
|
39
|
-
|
|
40
|
+
oldText: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
41
|
+
findText: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
42
|
+
newText: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
43
|
+
replaceText: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
40
44
|
}>, any>;
|
|
41
45
|
export {};
|
|
42
46
|
//# sourceMappingURL=edit.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"edit.d.ts","sourceRoot":"","sources":["../../../src/core/tools/edit.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAC;AAC7D,OAAO,EAAE,KAAK,MAAM,EAAQ,MAAM,mBAAmB,CAAC;AAatD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAE5D,QAAA,MAAM,UAAU
|
|
1
|
+
{"version":3,"file":"edit.d.ts","sourceRoot":"","sources":["../../../src/core/tools/edit.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAC;AAC7D,OAAO,EAAE,KAAK,MAAM,EAAQ,MAAM,mBAAmB,CAAC;AAatD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAE5D,QAAA,MAAM,UAAU;;;;;;EAMd,CAAC;AAEH,MAAM,MAAM,aAAa,GAAG,MAAM,CAAC,OAAO,UAAU,CAAC,CAAC;AAEtD,MAAM,WAAW,eAAe;IAC/B,uCAAuC;IACvC,IAAI,EAAE,MAAM,CAAC;IACb,8EAA8E;IAC9E,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED;;;GAGG;AACH,MAAM,WAAW,cAAc;IAC9B,qCAAqC;IACrC,QAAQ,EAAE,CAAC,YAAY,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;IACpD,8BAA8B;IAC9B,SAAS,EAAE,CAAC,YAAY,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACpE,4DAA4D;IAC5D,MAAM,EAAE,CAAC,YAAY,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CAChD;AAQD,MAAM,WAAW,eAAe;IAC/B,oEAAoE;IACpE,UAAU,CAAC,EAAE,cAAc,CAAC;IAC5B,wDAAwD;IACxD,eAAe,CAAC,EAAE,mBAAmB,CAAC;CACtC;AAqBD,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,eAAe,GAAG,SAAS,CAAC,OAAO,UAAU,CAAC,CAuLnG;AAED,0EAA0E;AAC1E,eAAO,MAAM,QAAQ;;;;;;QAAgC,CAAC"}
|
package/dist/core/tools/edit.js
CHANGED
|
@@ -5,14 +5,28 @@ import { detectLineEnding, fuzzyFindText, generateDiffString, normalizeForFuzzyM
|
|
|
5
5
|
import { resolveToCwd } from "./path-utils.js";
|
|
6
6
|
const editSchema = Type.Object({
|
|
7
7
|
path: Type.String({ description: "Path to the file to edit (relative or absolute)" }),
|
|
8
|
-
oldText: Type.String({ description: "Exact text to find and replace (must match exactly)" }),
|
|
9
|
-
|
|
8
|
+
oldText: Type.Optional(Type.String({ description: "Exact text to find and replace (must match exactly)" })),
|
|
9
|
+
findText: Type.Optional(Type.String({ description: "Legacy alias for oldText" })),
|
|
10
|
+
newText: Type.Optional(Type.String({ description: "New text to replace the old text with" })),
|
|
11
|
+
replaceText: Type.Optional(Type.String({ description: "Legacy alias for newText" })),
|
|
10
12
|
});
|
|
11
13
|
const defaultEditOperations = {
|
|
12
14
|
readFile: (path) => fsReadFile(path),
|
|
13
15
|
writeFile: (path, content) => fsWriteFile(path, content, "utf-8"),
|
|
14
16
|
access: (path) => fsAccess(path, constants.R_OK | constants.W_OK),
|
|
15
17
|
};
|
|
18
|
+
function normalizeEditPayload(input) {
|
|
19
|
+
const oldText = input.oldText ?? input.findText;
|
|
20
|
+
const newText = input.newText ?? input.replaceText;
|
|
21
|
+
if (typeof oldText !== "string" || typeof newText !== "string") {
|
|
22
|
+
throw new Error('Edit tool requires both oldText/findText and newText/replaceText.');
|
|
23
|
+
}
|
|
24
|
+
return {
|
|
25
|
+
path: input.path,
|
|
26
|
+
oldText,
|
|
27
|
+
newText,
|
|
28
|
+
};
|
|
29
|
+
}
|
|
16
30
|
export function createEditTool(cwd, options) {
|
|
17
31
|
const ops = options?.operations ?? defaultEditOperations;
|
|
18
32
|
const permissionGuard = options?.permissionGuard;
|
|
@@ -21,7 +35,8 @@ export function createEditTool(cwd, options) {
|
|
|
21
35
|
label: "edit",
|
|
22
36
|
description: "Edit a file by replacing exact text. The oldText must match exactly (including whitespace). Use this for precise, surgical edits.",
|
|
23
37
|
parameters: editSchema,
|
|
24
|
-
execute: async (_toolCallId,
|
|
38
|
+
execute: async (_toolCallId, input, signal) => {
|
|
39
|
+
const { path, oldText, newText } = normalizeEditPayload(input);
|
|
25
40
|
if (permissionGuard) {
|
|
26
41
|
const allowed = await permissionGuard({
|
|
27
42
|
toolName: "edit",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"edit.js","sourceRoot":"","sources":["../../../src/core/tools/edit.ts"],"names":[],"mappings":"AACA,OAAO,EAAe,IAAI,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,EAAE,SAAS,EAAE,MAAM,IAAI,CAAC;AAC/B,OAAO,EAAE,MAAM,IAAI,QAAQ,EAAE,QAAQ,IAAI,UAAU,EAAE,SAAS,IAAI,WAAW,EAAE,MAAM,aAAa,CAAC;AACnG,OAAO,EACN,gBAAgB,EAChB,aAAa,EACb,kBAAkB,EAClB,sBAAsB,EACtB,aAAa,EACb,kBAAkB,EAClB,QAAQ,GACR,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAG/C,MAAM,UAAU,GAAG,IAAI,CAAC,MAAM,CAAC;IAC9B,IAAI,EAAE,IAAI,CAAC,MAAM,CA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I,EAAE,iCAAiC,IAAI,GAAG;iCAC9C;6BACD;4BACD,OAAO,EAAE,EAAE,IAAI,EAAE,UAAU,CAAC,IAAI,EAAE,gBAAgB,EAAE,UAAU,CAAC,gBAAgB,EAAE;yBACjF,CAAC,CAAC;oBACJ,CAAC;oBAAC,OAAO,KAAU,EAAE,CAAC;wBACrB,yBAAyB;wBACzB,IAAI,MAAM,EAAE,CAAC;4BACZ,MAAM,CAAC,mBAAmB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;wBAC9C,CAAC;wBAED,IAAI,CAAC,OAAO,EAAE,CAAC;4BACd,MAAM,CAAC,KAAK,CAAC,CAAC;wBACf,CAAC;oBACF,CAAC;gBACF,CAAC,CAAC,EAAE,CAAC;YACN,CAAC,CAAC,CAAC;QACJ,CAAC;KACD,CAAC;AACH,CAAC;AAED,0EAA0E;AAC1E,MAAM,CAAC,MAAM,QAAQ,GAAG,cAAc,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC","sourcesContent":["import type { AgentTool } from \"@mariozechner/pi-agent-core\";\nimport { type Static, Type } from \"@sinclair/typebox\";\nimport { constants } from \"fs\";\nimport { access as fsAccess, readFile as fsReadFile, writeFile as fsWriteFile } from \"fs/promises\";\nimport {\n\tdetectLineEnding,\n\tfuzzyFindText,\n\tgenerateDiffString,\n\tnormalizeForFuzzyMatch,\n\tnormalizeToLF,\n\trestoreLineEndings,\n\tstripBom,\n} from \"./edit-diff.js\";\nimport { resolveToCwd } from \"./path-utils.js\";\nimport type { ToolPermissionGuard } from \"./permissions.js\";\n\nconst editSchema = Type.Object({\n\tpath: Type.String({ description: \"Path to the file to edit (relative or absolute)\" }),\n\toldText: Type.String({ description: \"Exact text to find and replace (must match exactly)\" }),\n\tnewText: Type.String({ description: \"New text to replace the old text with\" }),\n});\n\nexport type EditToolInput = Static<typeof editSchema>;\n\nexport interface EditToolDetails {\n\t/** Unified diff of the changes made */\n\tdiff: string;\n\t/** Line number of the first change in the new file (for editor navigation) */\n\tfirstChangedLine?: number;\n}\n\n/**\n * Pluggable operations for the edit tool.\n * Override these to delegate file editing to remote systems (e.g., SSH).\n */\nexport interface EditOperations {\n\t/** Read file contents as a Buffer */\n\treadFile: (absolutePath: string) => Promise<Buffer>;\n\t/** Write content to a file */\n\twriteFile: (absolutePath: string, content: string) => Promise<void>;\n\t/** Check if file is readable and writable (throw if not) */\n\taccess: (absolutePath: string) => Promise<void>;\n}\n\nconst defaultEditOperations: EditOperations = {\n\treadFile: (path) => fsReadFile(path),\n\twriteFile: (path, content) => fsWriteFile(path, content, \"utf-8\"),\n\taccess: (path) => fsAccess(path, constants.R_OK | constants.W_OK),\n};\n\nexport interface EditToolOptions {\n\t/** Custom operations for file editing. Default: local filesystem */\n\toperations?: EditOperations;\n\t/** Optional permission guard executed before editing */\n\tpermissionGuard?: ToolPermissionGuard;\n}\n\nexport function createEditTool(cwd: string, options?: EditToolOptions): AgentTool<typeof editSchema> {\n\tconst ops = options?.operations ?? defaultEditOperations;\n\tconst permissionGuard = options?.permissionGuard;\n\n\treturn {\n\t\tname: \"edit\",\n\t\tlabel: \"edit\",\n\t\tdescription:\n\t\t\t\"Edit a file by replacing exact text. The oldText must match exactly (including whitespace). Use this for precise, surgical edits.\",\n\t\tparameters: editSchema,\n\t\texecute: async (\n\t\t\t_toolCallId: string,\n\t\t\t{ path, oldText, newText }: { path: string; oldText: string; newText: string },\n\t\t\tsignal?: AbortSignal,\n\t\t) => {\n\t\t\tif (permissionGuard) {\n\t\t\t\tconst allowed = await permissionGuard({\n\t\t\t\t\ttoolName: \"edit\",\n\t\t\t\t\tcwd,\n\t\t\t\t\tinput: { path, oldTextLength: oldText.length, newTextLength: newText.length },\n\t\t\t\t\tsummary: path,\n\t\t\t\t});\n\t\t\t\tif (!allowed) {\n\t\t\t\t\tthrow new Error(\"Permission denied for edit operation.\");\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst absolutePath = resolveToCwd(path, cwd);\n\n\t\t\treturn new Promise<{\n\t\t\t\tcontent: Array<{ type: \"text\"; text: string }>;\n\t\t\t\tdetails: EditToolDetails | undefined;\n\t\t\t}>((resolve, reject) => {\n\t\t\t\t// Check if already aborted\n\t\t\t\tif (signal?.aborted) {\n\t\t\t\t\treject(new Error(\"Operation aborted\"));\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tlet aborted = false;\n\n\t\t\t\t// Set up abort handler\n\t\t\t\tconst onAbort = () => {\n\t\t\t\t\taborted = true;\n\t\t\t\t\treject(new Error(\"Operation aborted\"));\n\t\t\t\t};\n\n\t\t\t\tif (signal) {\n\t\t\t\t\tsignal.addEventListener(\"abort\", onAbort, { once: true });\n\t\t\t\t}\n\n\t\t\t\t// Perform the edit operation\n\t\t\t\t(async () => {\n\t\t\t\t\ttry {\n\t\t\t\t\t\t// Check if file exists\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\tawait ops.access(absolutePath);\n\t\t\t\t\t\t} catch {\n\t\t\t\t\t\t\tif (signal) {\n\t\t\t\t\t\t\t\tsignal.removeEventListener(\"abort\", onAbort);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\treject(new Error(`File not found: ${path}`));\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t// Check if aborted before reading\n\t\t\t\t\t\tif (aborted) {\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t// Read the file\n\t\t\t\t\t\tconst buffer = await ops.readFile(absolutePath);\n\t\t\t\t\t\tconst rawContent = buffer.toString(\"utf-8\");\n\n\t\t\t\t\t\t// Check if aborted after reading\n\t\t\t\t\t\tif (aborted) {\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t// Strip BOM before matching (LLM won't include invisible BOM in oldText)\n\t\t\t\t\t\tconst { bom, text: content } = stripBom(rawContent);\n\n\t\t\t\t\t\tconst originalEnding = detectLineEnding(content);\n\t\t\t\t\t\tconst normalizedContent = normalizeToLF(content);\n\t\t\t\t\t\tconst normalizedOldText = normalizeToLF(oldText);\n\t\t\t\t\t\tconst normalizedNewText = normalizeToLF(newText);\n\n\t\t\t\t\t\t// Find the old text using fuzzy matching (tries exact match first, then fuzzy)\n\t\t\t\t\t\tconst matchResult = fuzzyFindText(normalizedContent, normalizedOldText);\n\n\t\t\t\t\t\tif (!matchResult.found) {\n\t\t\t\t\t\t\tif (signal) {\n\t\t\t\t\t\t\t\tsignal.removeEventListener(\"abort\", onAbort);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\treject(\n\t\t\t\t\t\t\t\tnew Error(\n\t\t\t\t\t\t\t\t\t`Could not find the exact text in ${path}. The old text must match exactly including all whitespace and newlines.`,\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t// Count occurrences using fuzzy-normalized content for consistency\n\t\t\t\t\t\tconst fuzzyContent = normalizeForFuzzyMatch(normalizedContent);\n\t\t\t\t\t\tconst fuzzyOldText = normalizeForFuzzyMatch(normalizedOldText);\n\t\t\t\t\t\tconst occurrences = fuzzyContent.split(fuzzyOldText).length - 1;\n\n\t\t\t\t\t\tif (occurrences > 1) {\n\t\t\t\t\t\t\tif (signal) {\n\t\t\t\t\t\t\t\tsignal.removeEventListener(\"abort\", onAbort);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\treject(\n\t\t\t\t\t\t\t\tnew Error(\n\t\t\t\t\t\t\t\t\t`Found ${occurrences} occurrences of the text in ${path}. The text must be unique. Please provide more context to make it unique.`,\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t// Check if aborted before writing\n\t\t\t\t\t\tif (aborted) {\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t// Perform replacement using the matched text position\n\t\t\t\t\t\t// When fuzzy matching was used, contentForReplacement is the normalized version\n\t\t\t\t\t\tconst baseContent = matchResult.contentForReplacement;\n\t\t\t\t\t\tconst newContent =\n\t\t\t\t\t\t\tbaseContent.substring(0, matchResult.index) +\n\t\t\t\t\t\t\tnormalizedNewText +\n\t\t\t\t\t\t\tbaseContent.substring(matchResult.index + matchResult.matchLength);\n\n\t\t\t\t\t\t// Verify the replacement actually changed something\n\t\t\t\t\t\tif (baseContent === newContent) {\n\t\t\t\t\t\t\tif (signal) {\n\t\t\t\t\t\t\t\tsignal.removeEventListener(\"abort\", onAbort);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\treject(\n\t\t\t\t\t\t\t\tnew Error(\n\t\t\t\t\t\t\t\t\t`No changes made to ${path}. The replacement produced identical content. This might indicate an issue with special characters or the text not existing as expected.`,\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tconst finalContent = bom + restoreLineEndings(newContent, originalEnding);\n\t\t\t\t\t\tawait ops.writeFile(absolutePath, finalContent);\n\n\t\t\t\t\t\t// Check if aborted after writing\n\t\t\t\t\t\tif (aborted) {\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t// Clean up abort handler\n\t\t\t\t\t\tif (signal) {\n\t\t\t\t\t\t\tsignal.removeEventListener(\"abort\", onAbort);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tconst diffResult = generateDiffString(baseContent, newContent);\n\t\t\t\t\t\tresolve({\n\t\t\t\t\t\t\tcontent: [\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\ttype: \"text\",\n\t\t\t\t\t\t\t\t\ttext: `Successfully replaced text in ${path}.`,\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\tdetails: { diff: diffResult.diff, firstChangedLine: diffResult.firstChangedLine },\n\t\t\t\t\t\t});\n\t\t\t\t\t} catch (error: any) {\n\t\t\t\t\t\t// Clean up abort handler\n\t\t\t\t\t\tif (signal) {\n\t\t\t\t\t\t\tsignal.removeEventListener(\"abort\", onAbort);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif (!aborted) {\n\t\t\t\t\t\t\treject(error);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t})();\n\t\t\t});\n\t\t},\n\t};\n}\n\n/** Default edit tool using process.cwd() - for backwards compatibility */\nexport const editTool = createEditTool(process.cwd());\n"]}
|
|
1
|
+
{"version":3,"file":"edit.js","sourceRoot":"","sources":["../../../src/core/tools/edit.ts"],"names":[],"mappings":"AACA,OAAO,EAAe,IAAI,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,EAAE,SAAS,EAAE,MAAM,IAAI,CAAC;AAC/B,OAAO,EAAE,MAAM,IAAI,QAAQ,EAAE,QAAQ,IAAI,UAAU,EAAE,SAAS,IAAI,WAAW,EAAE,MAAM,aAAa,CAAC;AACnG,OAAO,EACN,gBAAgB,EAChB,aAAa,EACb,kBAAkB,EAClB,sBAAsB,EACtB,aAAa,EACb,kBAAkB,EAClB,QAAQ,GACR,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAG/C,MAAM,UAAU,GAAG,IAAI,CAAC,MAAM,CAAC;IAC9B,IAAI,EAAE,IAAI,CAAC,MAAM,CAAC,EAAE,WAAW,EAAE,iDAAiD,EAAE,CAAC;IACrF,OAAO,EAAE,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,WAAW,EAAE,qDAAqD,EAAE,CAAC,CAAC;IAC3G,QAAQ,EAAE,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,WAAW,EAAE,0BAA0B,EAAE,CAAC,CAAC;IACjF,OAAO,EAAE,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,WA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AC1E,MAAM,GAAG,CAAC,SAAS,CAAC,YAAY,EAAE,YAAY,CAAC,CAAC;wBAEhD,iCAAiC;wBACjC,IAAI,OAAO,EAAE,CAAC;4BACb,OAAO;wBACR,CAAC;wBAED,yBAAyB;wBACzB,IAAI,MAAM,EAAE,CAAC;4BACZ,MAAM,CAAC,mBAAmB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;wBAC9C,CAAC;wBAED,MAAM,UAAU,GAAG,kBAAkB,CAAC,WAAW,EAAE,UAAU,CAAC,CAAC;wBAC/D,OAAO,CAAC;4BACP,OAAO,EAAE;gCACR;oCACC,IAAI,EAAE,MAAM;oCACZ,IAAI,EAAE,iCAAiC,IAAI,GAAG;iCAC9C;6BACD;4BACD,OAAO,EAAE,EAAE,IAAI,EAAE,UAAU,CAAC,IAAI,EAAE,gBAAgB,EAAE,UAAU,CAAC,gBAAgB,EAAE;yBACjF,CAAC,CAAC;oBACJ,CAAC;oBAAC,OAAO,KAAU,EAAE,CAAC;wBACrB,yBAAyB;wBACzB,IAAI,MAAM,EAAE,CAAC;4BACZ,MAAM,CAAC,mBAAmB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;wBAC9C,CAAC;wBAED,IAAI,CAAC,OAAO,EAAE,CAAC;4BACd,MAAM,CAAC,KAAK,CAAC,CAAC;wBACf,CAAC;oBACF,CAAC;gBACF,CAAC,CAAC,EAAE,CAAC;YACN,CAAC,CAAC,CAAC;QACJ,CAAC;KACD,CAAC;AACH,CAAC;AAED,0EAA0E;AAC1E,MAAM,CAAC,MAAM,QAAQ,GAAG,cAAc,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC","sourcesContent":["import type { AgentTool } from \"@mariozechner/pi-agent-core\";\nimport { type Static, Type } from \"@sinclair/typebox\";\nimport { constants } from \"fs\";\nimport { access as fsAccess, readFile as fsReadFile, writeFile as fsWriteFile } from \"fs/promises\";\nimport {\n\tdetectLineEnding,\n\tfuzzyFindText,\n\tgenerateDiffString,\n\tnormalizeForFuzzyMatch,\n\tnormalizeToLF,\n\trestoreLineEndings,\n\tstripBom,\n} from \"./edit-diff.js\";\nimport { resolveToCwd } from \"./path-utils.js\";\nimport type { ToolPermissionGuard } from \"./permissions.js\";\n\nconst editSchema = Type.Object({\n\tpath: Type.String({ description: \"Path to the file to edit (relative or absolute)\" }),\n\toldText: Type.Optional(Type.String({ description: \"Exact text to find and replace (must match exactly)\" })),\n\tfindText: Type.Optional(Type.String({ description: \"Legacy alias for oldText\" })),\n\tnewText: Type.Optional(Type.String({ description: \"New text to replace the old text with\" })),\n\treplaceText: Type.Optional(Type.String({ description: \"Legacy alias for newText\" })),\n});\n\nexport type EditToolInput = Static<typeof editSchema>;\n\nexport interface EditToolDetails {\n\t/** Unified diff of the changes made */\n\tdiff: string;\n\t/** Line number of the first change in the new file (for editor navigation) */\n\tfirstChangedLine?: number;\n}\n\n/**\n * Pluggable operations for the edit tool.\n * Override these to delegate file editing to remote systems (e.g., SSH).\n */\nexport interface EditOperations {\n\t/** Read file contents as a Buffer */\n\treadFile: (absolutePath: string) => Promise<Buffer>;\n\t/** Write content to a file */\n\twriteFile: (absolutePath: string, content: string) => Promise<void>;\n\t/** Check if file is readable and writable (throw if not) */\n\taccess: (absolutePath: string) => Promise<void>;\n}\n\nconst defaultEditOperations: EditOperations = {\n\treadFile: (path) => fsReadFile(path),\n\twriteFile: (path, content) => fsWriteFile(path, content, \"utf-8\"),\n\taccess: (path) => fsAccess(path, constants.R_OK | constants.W_OK),\n};\n\nexport interface EditToolOptions {\n\t/** Custom operations for file editing. Default: local filesystem */\n\toperations?: EditOperations;\n\t/** Optional permission guard executed before editing */\n\tpermissionGuard?: ToolPermissionGuard;\n}\n\nfunction normalizeEditPayload(input: {\n\tpath: string;\n\toldText?: string;\n\tfindText?: string;\n\tnewText?: string;\n\treplaceText?: string;\n}): { path: string; oldText: string; newText: string } {\n\tconst oldText = input.oldText ?? input.findText;\n\tconst newText = input.newText ?? input.replaceText;\n\tif (typeof oldText !== \"string\" || typeof newText !== \"string\") {\n\t\tthrow new Error('Edit tool requires both oldText/findText and newText/replaceText.');\n\t}\n\treturn {\n\t\tpath: input.path,\n\t\toldText,\n\t\tnewText,\n\t};\n}\n\nexport function createEditTool(cwd: string, options?: EditToolOptions): AgentTool<typeof editSchema> {\n\tconst ops = options?.operations ?? defaultEditOperations;\n\tconst permissionGuard = options?.permissionGuard;\n\n\treturn {\n\t\tname: \"edit\",\n\t\tlabel: \"edit\",\n\t\tdescription:\n\t\t\t\"Edit a file by replacing exact text. The oldText must match exactly (including whitespace). Use this for precise, surgical edits.\",\n\t\tparameters: editSchema,\n\t\texecute: async (\n\t\t\t_toolCallId: string,\n\t\t\tinput: { path: string; oldText?: string; findText?: string; newText?: string; replaceText?: string },\n\t\t\tsignal?: AbortSignal,\n\t\t) => {\n\t\t\tconst { path, oldText, newText } = normalizeEditPayload(input);\n\t\t\tif (permissionGuard) {\n\t\t\t\tconst allowed = await permissionGuard({\n\t\t\t\t\ttoolName: \"edit\",\n\t\t\t\t\tcwd,\n\t\t\t\t\tinput: { path, oldTextLength: oldText.length, newTextLength: newText.length },\n\t\t\t\t\tsummary: path,\n\t\t\t\t});\n\t\t\t\tif (!allowed) {\n\t\t\t\t\tthrow new Error(\"Permission denied for edit operation.\");\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst absolutePath = resolveToCwd(path, cwd);\n\n\t\t\treturn new Promise<{\n\t\t\t\tcontent: Array<{ type: \"text\"; text: string }>;\n\t\t\t\tdetails: EditToolDetails | undefined;\n\t\t\t}>((resolve, reject) => {\n\t\t\t\t// Check if already aborted\n\t\t\t\tif (signal?.aborted) {\n\t\t\t\t\treject(new Error(\"Operation aborted\"));\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tlet aborted = false;\n\n\t\t\t\t// Set up abort handler\n\t\t\t\tconst onAbort = () => {\n\t\t\t\t\taborted = true;\n\t\t\t\t\treject(new Error(\"Operation aborted\"));\n\t\t\t\t};\n\n\t\t\t\tif (signal) {\n\t\t\t\t\tsignal.addEventListener(\"abort\", onAbort, { once: true });\n\t\t\t\t}\n\n\t\t\t\t// Perform the edit operation\n\t\t\t\t(async () => {\n\t\t\t\t\ttry {\n\t\t\t\t\t\t// Check if file exists\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\tawait ops.access(absolutePath);\n\t\t\t\t\t\t} catch {\n\t\t\t\t\t\t\tif (signal) {\n\t\t\t\t\t\t\t\tsignal.removeEventListener(\"abort\", onAbort);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\treject(new Error(`File not found: ${path}`));\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t// Check if aborted before reading\n\t\t\t\t\t\tif (aborted) {\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t// Read the file\n\t\t\t\t\t\tconst buffer = await ops.readFile(absolutePath);\n\t\t\t\t\t\tconst rawContent = buffer.toString(\"utf-8\");\n\n\t\t\t\t\t\t// Check if aborted after reading\n\t\t\t\t\t\tif (aborted) {\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t// Strip BOM before matching (LLM won't include invisible BOM in oldText)\n\t\t\t\t\t\tconst { bom, text: content } = stripBom(rawContent);\n\n\t\t\t\t\t\tconst originalEnding = detectLineEnding(content);\n\t\t\t\t\t\tconst normalizedContent = normalizeToLF(content);\n\t\t\t\t\t\tconst normalizedOldText = normalizeToLF(oldText);\n\t\t\t\t\t\tconst normalizedNewText = normalizeToLF(newText);\n\n\t\t\t\t\t\t// Find the old text using fuzzy matching (tries exact match first, then fuzzy)\n\t\t\t\t\t\tconst matchResult = fuzzyFindText(normalizedContent, normalizedOldText);\n\n\t\t\t\t\t\tif (!matchResult.found) {\n\t\t\t\t\t\t\tif (signal) {\n\t\t\t\t\t\t\t\tsignal.removeEventListener(\"abort\", onAbort);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\treject(\n\t\t\t\t\t\t\t\tnew Error(\n\t\t\t\t\t\t\t\t\t`Could not find the exact text in ${path}. The old text must match exactly including all whitespace and newlines.`,\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t// Count occurrences using fuzzy-normalized content for consistency\n\t\t\t\t\t\tconst fuzzyContent = normalizeForFuzzyMatch(normalizedContent);\n\t\t\t\t\t\tconst fuzzyOldText = normalizeForFuzzyMatch(normalizedOldText);\n\t\t\t\t\t\tconst occurrences = fuzzyContent.split(fuzzyOldText).length - 1;\n\n\t\t\t\t\t\tif (occurrences > 1) {\n\t\t\t\t\t\t\tif (signal) {\n\t\t\t\t\t\t\t\tsignal.removeEventListener(\"abort\", onAbort);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\treject(\n\t\t\t\t\t\t\t\tnew Error(\n\t\t\t\t\t\t\t\t\t`Found ${occurrences} occurrences of the text in ${path}. The text must be unique. Please provide more context to make it unique.`,\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t// Check if aborted before writing\n\t\t\t\t\t\tif (aborted) {\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t// Perform replacement using the matched text position\n\t\t\t\t\t\t// When fuzzy matching was used, contentForReplacement is the normalized version\n\t\t\t\t\t\tconst baseContent = matchResult.contentForReplacement;\n\t\t\t\t\t\tconst newContent =\n\t\t\t\t\t\t\tbaseContent.substring(0, matchResult.index) +\n\t\t\t\t\t\t\tnormalizedNewText +\n\t\t\t\t\t\t\tbaseContent.substring(matchResult.index + matchResult.matchLength);\n\n\t\t\t\t\t\t// Verify the replacement actually changed something\n\t\t\t\t\t\tif (baseContent === newContent) {\n\t\t\t\t\t\t\tif (signal) {\n\t\t\t\t\t\t\t\tsignal.removeEventListener(\"abort\", onAbort);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\treject(\n\t\t\t\t\t\t\t\tnew Error(\n\t\t\t\t\t\t\t\t\t`No changes made to ${path}. The replacement produced identical content. This might indicate an issue with special characters or the text not existing as expected.`,\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tconst finalContent = bom + restoreLineEndings(newContent, originalEnding);\n\t\t\t\t\t\tawait ops.writeFile(absolutePath, finalContent);\n\n\t\t\t\t\t\t// Check if aborted after writing\n\t\t\t\t\t\tif (aborted) {\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t// Clean up abort handler\n\t\t\t\t\t\tif (signal) {\n\t\t\t\t\t\t\tsignal.removeEventListener(\"abort\", onAbort);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tconst diffResult = generateDiffString(baseContent, newContent);\n\t\t\t\t\t\tresolve({\n\t\t\t\t\t\t\tcontent: [\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\ttype: \"text\",\n\t\t\t\t\t\t\t\t\ttext: `Successfully replaced text in ${path}.`,\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\tdetails: { diff: diffResult.diff, firstChangedLine: diffResult.firstChangedLine },\n\t\t\t\t\t\t});\n\t\t\t\t\t} catch (error: any) {\n\t\t\t\t\t\t// Clean up abort handler\n\t\t\t\t\t\tif (signal) {\n\t\t\t\t\t\t\tsignal.removeEventListener(\"abort\", onAbort);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif (!aborted) {\n\t\t\t\t\t\t\treject(error);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t})();\n\t\t\t});\n\t\t},\n\t};\n}\n\n/** Default edit tool using process.cwd() - for backwards compatibility */\nexport const editTool = createEditTool(process.cwd());\n"]}
|
|
@@ -41,8 +41,10 @@ export declare const allTools: {
|
|
|
41
41
|
}>, any>;
|
|
42
42
|
edit: AgentTool<import("@sinclair/typebox").TObject<{
|
|
43
43
|
path: import("@sinclair/typebox").TString;
|
|
44
|
-
oldText: import("@sinclair/typebox").TString
|
|
45
|
-
|
|
44
|
+
oldText: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
45
|
+
findText: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
46
|
+
newText: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
47
|
+
replaceText: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
46
48
|
}>, any>;
|
|
47
49
|
write: AgentTool<import("@sinclair/typebox").TObject<{
|
|
48
50
|
path: import("@sinclair/typebox").TString;
|
|
@@ -120,13 +122,13 @@ export declare const allTools: {
|
|
|
120
122
|
top_k: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TNumber>;
|
|
121
123
|
}>, any>;
|
|
122
124
|
todo_write: AgentTool<import("@sinclair/typebox").TObject<{
|
|
123
|
-
tasks: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TObject<{
|
|
124
|
-
id: import("@sinclair/typebox").TString
|
|
125
|
-
subject: import("@sinclair/typebox").TString
|
|
125
|
+
tasks: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TArray<import("@sinclair/typebox").TObject<{
|
|
126
|
+
id: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
127
|
+
subject: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
126
128
|
description: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
127
|
-
status: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TLiteral<"pending">, import("@sinclair/typebox").TLiteral<"in_progress">, import("@sinclair/typebox").TLiteral<"completed">, import("@sinclair/typebox").TLiteral<"deleted">]
|
|
129
|
+
status: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TLiteral<"pending">, import("@sinclair/typebox").TLiteral<"in_progress">, import("@sinclair/typebox").TLiteral<"completed">, import("@sinclair/typebox").TLiteral<"deleted">]>>;
|
|
128
130
|
activeForm: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
129
|
-
}>>;
|
|
131
|
+
}>>, import("@sinclair/typebox").TString]>>;
|
|
130
132
|
}>, any>;
|
|
131
133
|
todo_read: AgentTool<import("@sinclair/typebox").TObject<{}>, any>;
|
|
132
134
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/core/tools/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,iBAAiB,EACjB,KAAK,gBAAgB,EACrB,WAAW,GACX,MAAM,eAAe,CAAC;AACvB,OAAO,EACN,KAAK,cAAc,EACnB,KAAK,gBAAgB,EACrB,KAAK,aAAa,EAClB,KAAK,eAAe,EACpB,KAAK,aAAa,EAClB,KAAK,eAAe,EACpB,QAAQ,EACR,cAAc,GACd,MAAM,WAAW,CAAC;AACnB,OAAO,EACN,KAAK,cAAc,EACnB,SAAS,EACT,eAAe,GACf,MAAM,YAAY,CAAC;AACpB,OAAO,EACN,cAAc,EACd,KAAK,cAAc,EACnB,KAAK,eAAe,EACpB,KAAK,aAAa,EAClB,KAAK,eAAe,EACpB,QAAQ,GACR,MAAM,WAAW,CAAC;AACnB,OAAO,EACN,KAAK,sBAAsB,EAC3B,KAAK,oBAAoB,EACzB,KAAK,sBAAsB,EAC3B,qBAAqB,GACrB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EACN,YAAY,EACZ,KAAK,WAAW,EAChB,MAAM,GACN,MAAM,SAAS,CAAC;AACjB,OAAO,EACN,cAAc,EACd,KAAK,cAAc,EACnB,KAAK,eAAe,EACpB,KAAK,aAAa,EAClB,KAAK,eAAe,EACpB,QAAQ,GACR,MAAM,WAAW,CAAC;A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
|
|
44
45
|
tools: string[];
|
|
45
46
|
prompt: string;
|
|
46
47
|
cwd: string;
|
|
@@ -50,10 +51,12 @@ export type SubagentRunner = (options: {
|
|
|
50
51
|
onProgress?: (progress: TaskToolProgress) => void;
|
|
51
52
|
}) => Promise<string | SubagentRunResult>;
|
|
52
53
|
declare const taskSchema: import("@sinclair/typebox").TObject<{
|
|
53
|
-
description: import("@sinclair/typebox").TString
|
|
54
|
-
|
|
54
|
+
description: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
55
|
+
task: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
56
|
+
args: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
57
|
+
prompt: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
55
58
|
agent: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
56
|
-
profile: import("@sinclair/typebox").TString
|
|
59
|
+
profile: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
57
60
|
cwd: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
58
61
|
lock_key: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
59
62
|
run_id: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
@@ -101,6 +104,10 @@ export interface TaskToolOptions {
|
|
|
101
104
|
}>;
|
|
102
105
|
/** Returns pending live meta updates entered during an active run. */
|
|
103
106
|
getMetaMessages?: () => readonly string[];
|
|
107
|
+
/** Active profile of the host session that is invoking the task tool (static fallback). */
|
|
108
|
+
hostProfileName?: string;
|
|
109
|
+
/** Returns active profile of the host session dynamically (preferred over static fallback when provided). */
|
|
110
|
+
getHostProfileName?: () => string | undefined;
|
|
104
111
|
}
|
|
105
112
|
/**
|
|
106
113
|
* Create the Task tool using the factory pattern.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"task.d.ts","sourceRoot":"","sources":["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