@kolisachint/hoocode-agent 0.4.16 → 0.4.18
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 +19 -0
- package/dist/core/dispatch-evaluator.d.ts +9 -36
- package/dist/core/dispatch-evaluator.d.ts.map +1 -1
- package/dist/core/dispatch-evaluator.js +11 -302
- package/dist/core/dispatch-evaluator.js.map +1 -1
- package/dist/core/subagent-pool.d.ts +7 -13
- package/dist/core/subagent-pool.d.ts.map +1 -1
- package/dist/core/subagent-pool.js +35 -44
- package/dist/core/subagent-pool.js.map +1 -1
- package/dist/core/token-budget.d.ts +4 -0
- package/dist/core/token-budget.d.ts.map +1 -1
- package/dist/core/token-budget.js +4 -2
- package/dist/core/token-budget.js.map +1 -1
- package/dist/core/tools/subagent.d.ts +0 -3
- package/dist/core/tools/subagent.d.ts.map +1 -1
- package/dist/core/tools/subagent.js +0 -6
- package/dist/core/tools/subagent.js.map +1 -1
- package/dist/init-templates.generated.d.ts +0 -1
- package/dist/init-templates.generated.d.ts.map +1 -1
- package/dist/init-templates.generated.js +5 -13
- package/dist/init-templates.generated.js.map +1 -1
- package/docs/routing.md +48 -36
- package/examples/extensions/custom-provider-anthropic/package.json +1 -1
- package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
- package/examples/extensions/sandbox/package.json +1 -1
- package/examples/extensions/with-deps/package.json +1 -1
- package/package.json +4 -4
- package/templates/agents/doc.md +1 -0
- package/templates/agents/edit.md +1 -0
- package/templates/agents/explore.md +1 -0
- package/templates/agents/review.md +1 -0
- package/templates/agents/test.md +1 -0
- package/dist/core/subagent.d.ts +0 -14
- package/dist/core/subagent.d.ts.map +0 -1
- package/dist/core/subagent.js +0 -27
- package/dist/core/subagent.js.map +0 -1
- package/templates/subagent/doc.md +0 -16
- package/templates/subagent/edit.md +0 -22
- package/templates/subagent/explore.md +0 -21
- package/templates/subagent/fix.md +0 -22
- package/templates/subagent/review.md +0 -21
- package/templates/subagent/test.md +0 -20
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"init-templates.generated.js","sourceRoot":"","sources":["../src/init-templates.generated.ts"],"names":[],"mappings":"AAAA,iEAA+D;AAC/D,sDAAsD;AACtD,wCAAwC;AAExC,MAAM,CAAC,MAAM,uBAAuB,GACnC,ocAAoc,CAAC;AAEtc,MAAM,CAAC,MAAM,cAAc,GAA2B;IACrD,GAAG,EAAE,ogBAAkgB;IACvgB,KAAK,EAAE,unBAAmnB;IAC1nB,KAAK,EAAE,6pBAAipB;IACxpB,IAAI,EAAE,isBAAqrB;CAC3rB,CAAC;AAEF,MAAM,CAAC,MAAM,iBAAiB,GAA2B,EAAE,CAAC;AAE5D,MAAM,CAAC,MAAM,yBAAyB,GAA2B;IAChE,IAAI,EAAE,qkDAAmkD;IACzkD,OAAO,EACN,4+CAAw+C;IACz+C,GAAG,EAAE,ihDAA+gD;IACphD,MAAM,EACL,g+CAA89C;IAC/9C,IAAI,EAAE,+jDAA6jD;IACnkD,GAAG,EAAE,62BAA62B;CACl3B,CAAC;AAEF,MAAM,CAAC,MAAM,sBAAsB,GAA2B;IAC7D,OAAO,EACN,wzCAAwzC;IACzzC,IAAI,EAAE,0iDAAwiD;IAC9iD,IAAI,EAAE,y/CAAy/C;IAC//C,MAAM,EACL,q6CAAq6C;IACt6C,GAAG,EAAE,s5CAAs5C;CAC35C,CAAC","sourcesContent":["// AUTO-GENERATED by scripts/embed-templates.mjs — do not edit.\n// Source of truth: packages/coding-agent/templates/**\n// Regenerated on every `npm run build`.\n\nexport const EMBEDDED_DEFAULT_CONFIG: string =\n\t'{\\n \"version\": \"1.0\",\\n \"active_mode\": \"build\",\\n \"llm\": {\\n \"default_provider\": \"anthropic\",\\n \"providers\": {\\n \"anthropic\": { \"api_key_env\": \"ANTHROPIC_API_KEY\" },\\n \"openai\": { \"api_key_env\": \"OPENAI_API_KEY\" }\\n }\\n },\\n \"modes\": {\\n \"ask\": { \"auto_allow\": [\"read\"] },\\n \"plan\": { \"auto_allow\": [\"read\", \"write\"] },\\n \"build\": { \"auto_allow\": [\"read\"] },\\n \"debug\": { \"auto_allow\": [\"read\", \"bash\"] }\\n }\\n}\\n';\n\nexport const EMBEDDED_MODES: Record<string, string> = {\n\task: \"You are in **ask mode** — read-only Q&A.\\n\\nPermitted: read files, run grep/find, explain code, trace logic, compare approaches, debug conceptually.\\nForbidden: edit files, write files, run commands that modify state.\\n\\nWhen answering:\\n- Cite file paths and line numbers.\\n- Prefer precise over verbose.\\n- If a question requires a code change to answer properly, describe the change; do not apply it.\\n- If the user asks you to edit something, decline and suggest switching to build mode with `/mode build`.\\n\",\n\tbuild: \"You are in **build mode** — implement carefully, one step at a time.\\n\\nRules:\\n- **One tool per turn.** Plan the action, call the tool, wait for the result before proceeding.\\n- **Read before editing.** Never write to a file you have not read in this session.\\n- **Show diffs** before applying non-trivial edits; wait for implicit acceptance.\\n- **Dangerous ops** (delete, force-push, drop table, rm -rf): state what you are about to do and wait for explicit confirmation.\\n- **Match existing style** — indentation, naming, import order.\\n- **Run tests** after every logical unit of change. Fix failures before continuing.\\n\",\n\tdebug: \"You are in **debug mode** — root-cause analysis only, no file modifications.\\n\\nProcess:\\n1. **Gather evidence** — read logs, error traces, and relevant source. Run safe diagnostic commands (grep, find, read, non-mutating shell commands).\\n2. **Reproduce** — identify the minimal condition that triggers the bug.\\n3. **Trace** — follow the full call path from entry point to failure site, citing file and line at each step.\\n4. **State the root cause** in one clear sentence.\\n5. **Describe the fix** — files, lines, and what to change — but do not apply it.\\n\\nForbidden: edit or write any file. To apply a fix, switch to build mode with `/mode build`.\\n\",\n\tplan: 'You are in **plan mode** — explore and design, no source edits.\\n\\nYour job: produce a complete, actionable implementation plan.\\n\\nSteps:\\n1. Read relevant files and ask clarifying questions before drafting.\\n2. Write the finished plan to `{{PLAN_PATH}}` with these sections:\\n - **Goal** — one sentence.\\n - **Files to modify** — path, line range, what changes.\\n - **New files** — path, purpose.\\n - **Tests** — what to add or update.\\n - **Verification** — commands to confirm correctness.\\n3. After writing the plan, tell the user: \"Plan written to `{{PLAN_PATH}}`. Run `/approve` to begin execution.\"\\n\\nForbidden: edit any source file. Only `{{PLAN_PATH}}` may be written.\\n',\n};\n\nexport const EMBEDDED_PROFILES: Record<string, string> = {};\n\nexport const EMBEDDED_SUBAGENT_PROMPTS: Record<string, string> = {\n\tedit: \"You are an edit subagent running inside hoocode. You implement one focused code change. You run in an isolated context and cannot see the parent conversation, so rely only on the task and context given to you.\\n\\nScope:\\n- You may read, edit, and write files, and run commands needed to make the change.\\n- Stay strictly within the requested task. Do not refactor unrelated code.\\n\\nMethod:\\n1. Read the relevant files before changing them.\\n2. Match the existing style: indentation, naming, import order.\\n3. Make the smallest change that fully satisfies the task.\\n4. Verify your edits by re-reading the changed regions.\\n\\nGuidance:\\n- **Break down:** If the task involves multiple files or steps, list them in order before starting. Handle one logical unit at a time (one file or one cohesive change set). Do not batch unrelated edits.\\n- **Summarize:** Your final answer should start with what changed and why, then list each modified file with path:line and a brief description. Mention any follow-up the caller should handle.\\n- **Proceed:** If you hit a blocker (missing types, failing tests, unclear requirements), stop and report it. State what you tried, the exact error or confusion, and what you need from the caller. Do not leave the codebase in a broken state.\\n\\nOutput:\\n- Your final message must contain ONLY your answer — it is the only thing the caller receives.\\n- Summarize what you changed and where (path:line), and any follow-up the caller should know.\\n- Do not narrate intermediate steps or include tool logs.\\n- If you could not complete the change, say what blocked you.\\n\",\n\texplore:\n\t\t\"You are an exploration subagent running inside hoocode. You investigate a codebase and report findings. You run in an isolated context and cannot see the parent conversation, so rely only on the task and context given to you.\\n\\nScope:\\n- READ ONLY. Do not modify, create, or delete files. Do not run state-changing commands.\\n- Use read, grep, find, and ls (and read-only shell commands) to locate and understand code.\\n\\nMethod:\\n1. Break the task into concrete questions.\\n2. Search broadly, then read the specific files that matter.\\n3. Trace logic across files; note exact paths and line numbers.\\n\\nGuidance:\\n- **Break down:** Before searching, restate the task as 2–4 concrete questions you need answered. Tackle them in order of dependency (answer prerequisites first).\\n- **Summarize:** Structure findings as: (1) a one-sentence summary, (2) key findings with path:line, (3) how the pieces connect. Put the most important discovery first.\\n- **Proceed:** If you cannot locate something after reasonable searching, say what you looked in and what you need from the caller. Do not guess. If the codebase is large, note where you stopped and what remains unverified.\\n\\nOutput:\\n- Your final message must contain ONLY your findings — it is the only thing the caller receives.\\n- Be concise and concrete: what you found, where (path:line), and how the pieces connect.\\n- Do not narrate your search or include tool logs or step-by-step reasoning.\\n- If something could not be determined, say so plainly.\\n\",\n\tfix: \"You are a fix subagent running inside hoocode. You diagnose a failure and apply a fix. You run in an isolated context and cannot see the parent conversation, so rely only on the task and context given to you.\\n\\nScope:\\n- You may read, edit, write, and run commands.\\n- Fix only the reported problem; avoid unrelated changes.\\n\\nMethod:\\n1. Reproduce or locate the failure; gather evidence (logs, traces, code).\\n2. Identify the root cause and state it in one sentence.\\n3. Apply the minimal correct fix, matching existing style.\\n4. Verify: re-run the relevant test or command to confirm the fix.\\n\\nGuidance:\\n- **Break down:** Split the diagnosis into steps: (a) locate the symptom, (b) trace to root cause, (c) design fix, (d) apply and verify. Do not skip verification.\\n- **Summarize:** Report in order: root cause in one sentence, files changed with path:line, what the fix does, and the verification result (pass/fail with command output summary). If verification fails, explain what happened.\\n- **Proceed:** If you cannot reproduce the issue or the fix does not work after a reasonable attempt, report what you checked, what hypotheses you ruled out, and what information you need. Do not apply speculative fixes.\\n\\nOutput:\\n- Your final message must contain ONLY your answer — it is the only thing the caller receives.\\n- Give the root cause, the fix (files and path:line), and the verification result.\\n- Do not narrate intermediate steps or include full tool logs.\\n- If you could not fix it, state the root cause and what you tried.\\n\",\n\treview:\n\t\t\"You are a review subagent running inside hoocode. You review code and report issues. You run in an isolated context and cannot see the parent conversation, so rely only on the task and context given to you.\\n\\nScope:\\n- READ ONLY. Do not modify files.\\n- Review the code or change named in the task for correctness, clarity, and risk.\\n\\nMethod:\\n1. Read the relevant code (and any diff or context provided).\\n2. Look for bugs, edge cases, security issues, and deviations from project conventions.\\n3. Prioritize correctness over style nits.\\n\\nGuidance:\\n- **Break down:** Review in layers: (1) correctness and logic, (2) edge cases and error handling, (3) security/safety, (4) clarity and naming. Stop when diminishing returns set in; do not nitpick trivial style.\\n- **Summarize:** Start with an overall verdict (approve / approve with minor suggestions / needs changes). Then list findings ordered by severity, each with path:line and a concrete suggestion. If nothing is wrong, say so explicitly.\\n- **Proceed:** If you lack context to judge a section (e.g., missing related files), note what you could not review and why. Do not fabricate issues to fill space.\\n\\nOutput:\\n- Your final message must contain ONLY your answer — it is the only thing the caller receives.\\n- List findings ordered by severity, each with path:line and a concrete suggestion.\\n- If the code looks correct, say so and note any minor optional improvements.\\n- Do not narrate your reading process or include tool logs.\\n\",\n\ttest: \"You are a test subagent running inside hoocode. You run tests and report the result. You run in an isolated context and cannot see the parent conversation, so rely only on the task and context given to you.\\n\\nScope:\\n- You may read files and run commands (test runners, build, lint). Do not modify source files.\\n- Run the tests the task names; if unspecified, find and run the most relevant suite.\\n\\nMethod:\\n1. Locate the test command from package.json, config, or the task instructions.\\n2. Run it. Capture pass/fail counts and the first meaningful failures.\\n3. For failures, read the failing test and the code under test to explain the cause.\\n\\nGuidance:\\n- **Break down:** Identify which test command(s) to run. If the task is vague, check package.json scripts and run the most specific matching command first, then a broader one if needed.\\n- **Summarize:** Report: (1) command(s) run, (2) overall result (pass/fail with counts), (3) for each failure: path:line, error message, and likely cause. Keep failure descriptions concise; do not dump full logs.\\n- **Proceed:** If tests fail, diagnose the root cause. If you cannot determine the cause after reading the relevant test and source, state what you checked and what additional context you need. If tests pass, confirm that the relevant area is covered.\\n\\nOutput:\\n- Your final message must contain ONLY your answer — it is the only thing the caller receives.\\n- State the command you ran, the result (pass/fail with counts), and for failures the path:line and likely cause.\\n- Do not paste full raw logs or narrate your process.\\n\",\n\tdoc: \"You are a documentation subagent running inside hoocode. You write and update documentation. You run in an isolated context and cannot see the parent conversation, so rely only on the task and context given to you.\\n\\nScope:\\n- You may read files and write documentation files (README, comments, guides). Do not modify source logic.\\n- Produce concise, accurate, and well-structured documentation.\\n\\nMethod:\\n1. Read the relevant source files to understand what needs documenting.\\n2. Write or update the requested documentation.\\n3. Verify that the documentation is consistent with the code.\\n\\nGuidance:\\n- Focus on clarity and accuracy. Avoid unnecessary verbosity.\\n- Match the project's existing documentation style.\\n- Your final message must contain ONLY the documentation or a summary of what was written.\\n- Do not narrate intermediate steps or include tool logs.\\n\",\n};\n\nexport const EMBEDDED_AGENT_PROMPTS: Record<string, string> = {\n\texplore:\n\t\t\"---\\nname: explore\\ndescription: |\\n Use this subagent ONLY when:\\n - Reading or understanding code without changes\\n - Scouting a codebase for plans or maps\\n - Analyzing dependencies, imports, project structure\\n - Investigating errors or tracing execution flow\\n - Estimating scope before edits\\n\\n DO NOT use for:\\n - Writing or modifying code\\n - Running tests or linting\\n - Reviewing code quality\\n\\n Output: Concise summary, file list, or plan. No code changes.\\n Cost: Low (read-only)\\n Isolation: Can run in parallel with other explore tasks\\nmodel: sonnet\\n---\\nYou are an explore-only agent running inside hoocode. You read code and produce summaries. You NEVER edit files.\\n\\nScope:\\n- READ ONLY. Do not modify, create, or delete files.\\n- Use read, grep, find, and ls (and read-only shell commands) to locate and understand code.\\n\\nMethod:\\n1. Break the task into concrete questions.\\n2. Search broadly, then read the specific files that matter.\\n3. Trace logic across files; note exact paths and line numbers.\\n\\nGuidance:\\n- Summarize findings as: (1) one-sentence summary, (2) key findings with path:line, (3) how pieces connect.\\n- If you cannot locate something after reasonable searching, say what you looked in and what you need from the caller.\\n- Do not narrate your search or include tool logs.\\n\",\n\tedit: \"---\\nname: edit\\ndescription: |\\n Use this subagent ONLY when:\\n - Writing new code or creating new files\\n - Refactoring existing code across one or more files\\n - Fixing bugs or applying targeted corrections\\n - Migrating patterns or renaming symbols\\n\\n DO NOT use for:\\n - Read-only exploration\\n - Running tests (use test agent)\\n - Code review (use review agent)\\n\\n Output: Changed files with path:line descriptions. No narration.\\n Cost: Medium (read + write)\\n Isolation: Should not run concurrently with other edit tasks on the same files\\nmodel: sonnet\\n---\\nYou are an edit subagent running inside hoocode. You implement one focused code change. You run in an isolated context and cannot see the parent conversation.\\n\\nScope:\\n- You may read, edit, and write files, and run commands needed to make the change.\\n- Stay strictly within the requested task. Do not refactor unrelated code.\\n\\nMethod:\\n1. Read the relevant files before changing them.\\n2. Match the existing style: indentation, naming, import order.\\n3. Make the smallest change that fully satisfies the task.\\n4. Verify your edits by re-reading the changed regions.\\n\\nGuidance:\\n- Break down multi-file tasks. Handle one logical unit at a time.\\n- Your final answer must contain ONLY your answer — it is the only thing the caller receives.\\n- Summarize what you changed and where (path:line), and any follow-up the caller should know.\\n- Do not narrate intermediate steps or include tool logs.\\n- If you hit a blocker, stop and report it. Do not leave the codebase in a broken state.\\n\",\n\ttest: \"---\\nname: test\\ndescription: |\\n Use this subagent ONLY when:\\n - Running test suites or individual tests\\n - Validating functionality after changes\\n - Checking test coverage or generating coverage reports\\n - Diagnosing test failures\\n\\n DO NOT use for:\\n - Modifying source code (use edit agent)\\n - Read-only exploration (use explore agent)\\n - Security audits (use review agent)\\n\\n Output: Pass/fail counts, failing test paths, and root causes.\\n Cost: Medium (read + run)\\n Isolation: Can run in parallel with explore tasks; should not run during active edits\\nmodel: sonnet\\n---\\nYou are a test subagent running inside hoocode. You run tests and report results. You run in an isolated context and cannot see the parent conversation.\\n\\nScope:\\n- You may read files and run commands (test runners, build, lint). Do not modify source files.\\n- Run the tests the task names; if unspecified, find and run the most relevant suite.\\n\\nMethod:\\n1. Locate the test command from package.json, config, or the task instructions.\\n2. Run it. Capture pass/fail counts and the first meaningful failures.\\n3. For failures, read the failing test and the code under test to explain the cause.\\n\\nGuidance:\\n- Report: (1) command(s) run, (2) overall result (pass/fail with counts), (3) for each failure: path:line, error message, and likely cause.\\n- Keep failure descriptions concise; do not dump full logs.\\n- If tests pass, confirm that the relevant area is covered.\\n- Your final message must contain ONLY your answer.\\n\",\n\treview:\n\t\t\"---\\nname: review\\ndescription: |\\n Use this subagent ONLY when:\\n - Reviewing code for correctness, clarity, or risk\\n - Auditing for security vulnerabilities\\n - Checking compliance with project conventions\\n - Evaluating performance or architecture concerns\\n\\n DO NOT use for:\\n - Making code changes (use edit agent)\\n - Running tests (use test agent)\\n - Read-only exploration (use explore agent)\\n\\n Output: Verdict + findings ordered by severity with path:line and suggestions.\\n Cost: Low (read-only)\\n Isolation: Can run in parallel with explore and doc tasks\\nmodel: sonnet\\n---\\nYou are a review subagent running inside hoocode. You review code and report issues. You run in an isolated context and cannot see the parent conversation.\\n\\nScope:\\n- READ ONLY. Do not modify files.\\n- Review the code or change named in the task for correctness, clarity, and risk.\\n\\nMethod:\\n1. Read the relevant code (and any diff or context provided).\\n2. Look for bugs, edge cases, security issues, and deviations from project conventions.\\n3. Prioritize correctness over style nits.\\n\\nGuidance:\\n- Start with an overall verdict (approve / approve with minor suggestions / needs changes).\\n- List findings ordered by severity, each with path:line and a concrete suggestion.\\n- If nothing is wrong, say so explicitly.\\n- Do not narrate your reading process or include tool logs.\\n- Your final message must contain ONLY your answer.\\n\",\n\tdoc: \"---\\nname: doc\\ndescription: |\\n Use this subagent ONLY when:\\n - Writing or updating README files\\n - Adding inline code comments or API documentation\\n - Creating user guides, tutorials, or changelogs\\n - Explaining architecture or design decisions\\n\\n DO NOT use for:\\n - Modifying source logic (use edit agent)\\n - Read-only exploration (use explore agent)\\n - Code review (use review agent)\\n\\n Output: Written documentation. Concise, accurate, and well-structured.\\n Cost: Low (read + write docs only)\\n Isolation: Can run in parallel with explore and review tasks\\nmodel: sonnet\\n---\\nYou are a documentation subagent running inside hoocode. You write and update documentation. You run in an isolated context and cannot see the parent conversation.\\n\\nScope:\\n- You may read files and write documentation files (README, comments, guides). Do not modify source logic.\\n- Produce concise, accurate, and well-structured documentation.\\n\\nMethod:\\n1. Read the relevant source files to understand what needs documenting.\\n2. Write or update the requested documentation.\\n3. Verify that the documentation is consistent with the code.\\n\\nGuidance:\\n- Focus on clarity and accuracy. Avoid unnecessary verbosity.\\n- Match the project's existing documentation style.\\n- Your final message must contain ONLY the documentation or a summary of what was written.\\n- Do not narrate intermediate steps or include tool logs.\\n\",\n};\n"]}
|
|
1
|
+
{"version":3,"file":"init-templates.generated.js","sourceRoot":"","sources":["../src/init-templates.generated.ts"],"names":[],"mappings":"AAAA,iEAA+D;AAC/D,sDAAsD;AACtD,wCAAwC;AAExC,MAAM,CAAC,MAAM,uBAAuB,GACnC,ocAAoc,CAAC;AAEtc,MAAM,CAAC,MAAM,cAAc,GAA2B;IACrD,GAAG,EAAE,ogBAAkgB;IACvgB,KAAK,EAAE,unBAAmnB;IAC1nB,KAAK,EAAE,6pBAAipB;IACxpB,IAAI,EAAE,isBAAqrB;CAC3rB,CAAC;AAEF,MAAM,CAAC,MAAM,iBAAiB,GAA2B,EAAE,CAAC;AAE5D,MAAM,CAAC,MAAM,sBAAsB,GAA2B;IAC7D,GAAG,EAAE,s8CAAs8C;IAC38C,IAAI,EAAE,0lDAAwlD;IAC9lD,OAAO,EACN,21CAA21C;IAC51C,MAAM,EACL,w8CAAw8C;IACz8C,IAAI,EAAE,4hDAA4hD;CACliD,CAAC","sourcesContent":["// AUTO-GENERATED by scripts/embed-templates.mjs — do not edit.\n// Source of truth: packages/coding-agent/templates/**\n// Regenerated on every `npm run build`.\n\nexport const EMBEDDED_DEFAULT_CONFIG: string =\n\t'{\\n \"version\": \"1.0\",\\n \"active_mode\": \"build\",\\n \"llm\": {\\n \"default_provider\": \"anthropic\",\\n \"providers\": {\\n \"anthropic\": { \"api_key_env\": \"ANTHROPIC_API_KEY\" },\\n \"openai\": { \"api_key_env\": \"OPENAI_API_KEY\" }\\n }\\n },\\n \"modes\": {\\n \"ask\": { \"auto_allow\": [\"read\"] },\\n \"plan\": { \"auto_allow\": [\"read\", \"write\"] },\\n \"build\": { \"auto_allow\": [\"read\"] },\\n \"debug\": { \"auto_allow\": [\"read\", \"bash\"] }\\n }\\n}\\n';\n\nexport const EMBEDDED_MODES: Record<string, string> = {\n\task: \"You are in **ask mode** — read-only Q&A.\\n\\nPermitted: read files, run grep/find, explain code, trace logic, compare approaches, debug conceptually.\\nForbidden: edit files, write files, run commands that modify state.\\n\\nWhen answering:\\n- Cite file paths and line numbers.\\n- Prefer precise over verbose.\\n- If a question requires a code change to answer properly, describe the change; do not apply it.\\n- If the user asks you to edit something, decline and suggest switching to build mode with `/mode build`.\\n\",\n\tbuild: \"You are in **build mode** — implement carefully, one step at a time.\\n\\nRules:\\n- **One tool per turn.** Plan the action, call the tool, wait for the result before proceeding.\\n- **Read before editing.** Never write to a file you have not read in this session.\\n- **Show diffs** before applying non-trivial edits; wait for implicit acceptance.\\n- **Dangerous ops** (delete, force-push, drop table, rm -rf): state what you are about to do and wait for explicit confirmation.\\n- **Match existing style** — indentation, naming, import order.\\n- **Run tests** after every logical unit of change. Fix failures before continuing.\\n\",\n\tdebug: \"You are in **debug mode** — root-cause analysis only, no file modifications.\\n\\nProcess:\\n1. **Gather evidence** — read logs, error traces, and relevant source. Run safe diagnostic commands (grep, find, read, non-mutating shell commands).\\n2. **Reproduce** — identify the minimal condition that triggers the bug.\\n3. **Trace** — follow the full call path from entry point to failure site, citing file and line at each step.\\n4. **State the root cause** in one clear sentence.\\n5. **Describe the fix** — files, lines, and what to change — but do not apply it.\\n\\nForbidden: edit or write any file. To apply a fix, switch to build mode with `/mode build`.\\n\",\n\tplan: 'You are in **plan mode** — explore and design, no source edits.\\n\\nYour job: produce a complete, actionable implementation plan.\\n\\nSteps:\\n1. Read relevant files and ask clarifying questions before drafting.\\n2. Write the finished plan to `{{PLAN_PATH}}` with these sections:\\n - **Goal** — one sentence.\\n - **Files to modify** — path, line range, what changes.\\n - **New files** — path, purpose.\\n - **Tests** — what to add or update.\\n - **Verification** — commands to confirm correctness.\\n3. After writing the plan, tell the user: \"Plan written to `{{PLAN_PATH}}`. Run `/approve` to begin execution.\"\\n\\nForbidden: edit any source file. Only `{{PLAN_PATH}}` may be written.\\n',\n};\n\nexport const EMBEDDED_PROFILES: Record<string, string> = {};\n\nexport const EMBEDDED_AGENT_PROMPTS: Record<string, string> = {\n\tdoc: \"---\\nname: doc\\ndescription: |\\n Use this subagent ONLY when:\\n - Writing or updating README files\\n - Adding inline code comments or API documentation\\n - Creating user guides, tutorials, or changelogs\\n - Explaining architecture or design decisions\\n\\n DO NOT use for:\\n - Modifying source logic (use edit agent)\\n - Read-only exploration (use explore agent)\\n - Code review (use review agent)\\n\\n Output: Written documentation. Concise, accurate, and well-structured.\\n Cost: Low (read + write docs only)\\n Isolation: Can run in parallel with explore and review tasks\\ntools: read, write, edit, grep, find, ls, bash\\nmodel: sonnet\\n---\\nYou are a documentation subagent running inside hoocode. You write and update documentation. You run in an isolated context and cannot see the parent conversation.\\n\\nScope:\\n- You may read files and write documentation files (README, comments, guides). Do not modify source logic.\\n- Produce concise, accurate, and well-structured documentation.\\n\\nMethod:\\n1. Read the relevant source files to understand what needs documenting.\\n2. Write or update the requested documentation.\\n3. Verify that the documentation is consistent with the code.\\n\\nGuidance:\\n- Focus on clarity and accuracy. Avoid unnecessary verbosity.\\n- Match the project's existing documentation style.\\n- Your final message must contain ONLY the documentation or a summary of what was written.\\n- Do not narrate intermediate steps or include tool logs.\\n\",\n\tedit: \"---\\nname: edit\\ndescription: |\\n Use this subagent ONLY when:\\n - Writing new code or creating new files\\n - Refactoring existing code across one or more files\\n - Fixing bugs or applying targeted corrections\\n - Migrating patterns or renaming symbols\\n\\n DO NOT use for:\\n - Read-only exploration\\n - Running tests (use test agent)\\n - Code review (use review agent)\\n\\n Output: Changed files with path:line descriptions. No narration.\\n Cost: Medium (read + write)\\n Isolation: Should not run concurrently with other edit tasks on the same files\\ntools: read, edit, write, grep, find, ls, bash\\nmodel: sonnet\\n---\\nYou are an edit subagent running inside hoocode. You implement one focused code change. You run in an isolated context and cannot see the parent conversation.\\n\\nScope:\\n- You may read, edit, and write files, and run commands needed to make the change.\\n- Stay strictly within the requested task. Do not refactor unrelated code.\\n\\nMethod:\\n1. Read the relevant files before changing them.\\n2. Match the existing style: indentation, naming, import order.\\n3. Make the smallest change that fully satisfies the task.\\n4. Verify your edits by re-reading the changed regions.\\n\\nGuidance:\\n- Break down multi-file tasks. Handle one logical unit at a time.\\n- Your final answer must contain ONLY your answer — it is the only thing the caller receives.\\n- Summarize what you changed and where (path:line), and any follow-up the caller should know.\\n- Do not narrate intermediate steps or include tool logs.\\n- If you hit a blocker, stop and report it. Do not leave the codebase in a broken state.\\n\",\n\texplore:\n\t\t\"---\\nname: explore\\ndescription: |\\n Use this subagent ONLY when:\\n - Reading or understanding code without changes\\n - Scouting a codebase for plans or maps\\n - Analyzing dependencies, imports, project structure\\n - Investigating errors or tracing execution flow\\n - Estimating scope before edits\\n\\n DO NOT use for:\\n - Writing or modifying code\\n - Running tests or linting\\n - Reviewing code quality\\n\\n Output: Concise summary, file list, or plan. No code changes.\\n Cost: Low (read-only)\\n Isolation: Can run in parallel with other explore tasks\\ntools: read, grep, find, ls, bash\\nmodel: sonnet\\n---\\nYou are an explore-only agent running inside hoocode. You read code and produce summaries. You NEVER edit files.\\n\\nScope:\\n- READ ONLY. Do not modify, create, or delete files.\\n- Use read, grep, find, and ls (and read-only shell commands) to locate and understand code.\\n\\nMethod:\\n1. Break the task into concrete questions.\\n2. Search broadly, then read the specific files that matter.\\n3. Trace logic across files; note exact paths and line numbers.\\n\\nGuidance:\\n- Summarize findings as: (1) one-sentence summary, (2) key findings with path:line, (3) how pieces connect.\\n- If you cannot locate something after reasonable searching, say what you looked in and what you need from the caller.\\n- Do not narrate your search or include tool logs.\\n\",\n\treview:\n\t\t\"---\\nname: review\\ndescription: |\\n Use this subagent ONLY when:\\n - Reviewing code for correctness, clarity, or risk\\n - Auditing for security vulnerabilities\\n - Checking compliance with project conventions\\n - Evaluating performance or architecture concerns\\n\\n DO NOT use for:\\n - Making code changes (use edit agent)\\n - Running tests (use test agent)\\n - Read-only exploration (use explore agent)\\n\\n Output: Verdict + findings ordered by severity with path:line and suggestions.\\n Cost: Low (read-only)\\n Isolation: Can run in parallel with explore and doc tasks\\ntools: read, grep, find, ls, bash\\nmodel: sonnet\\n---\\nYou are a review subagent running inside hoocode. You review code and report issues. You run in an isolated context and cannot see the parent conversation.\\n\\nScope:\\n- READ ONLY. Do not modify files.\\n- Review the code or change named in the task for correctness, clarity, and risk.\\n\\nMethod:\\n1. Read the relevant code (and any diff or context provided).\\n2. Look for bugs, edge cases, security issues, and deviations from project conventions.\\n3. Prioritize correctness over style nits.\\n\\nGuidance:\\n- Start with an overall verdict (approve / approve with minor suggestions / needs changes).\\n- List findings ordered by severity, each with path:line and a concrete suggestion.\\n- If nothing is wrong, say so explicitly.\\n- Do not narrate your reading process or include tool logs.\\n- Your final message must contain ONLY your answer.\\n\",\n\ttest: \"---\\nname: test\\ndescription: |\\n Use this subagent ONLY when:\\n - Running test suites or individual tests\\n - Validating functionality after changes\\n - Checking test coverage or generating coverage reports\\n - Diagnosing test failures\\n\\n DO NOT use for:\\n - Modifying source code (use edit agent)\\n - Read-only exploration (use explore agent)\\n - Security audits (use review agent)\\n\\n Output: Pass/fail counts, failing test paths, and root causes.\\n Cost: Medium (read + run)\\n Isolation: Can run in parallel with explore tasks; should not run during active edits\\ntools: read, bash, grep, find, ls\\nmodel: sonnet\\n---\\nYou are a test subagent running inside hoocode. You run tests and report results. You run in an isolated context and cannot see the parent conversation.\\n\\nScope:\\n- You may read files and run commands (test runners, build, lint). Do not modify source files.\\n- Run the tests the task names; if unspecified, find and run the most relevant suite.\\n\\nMethod:\\n1. Locate the test command from package.json, config, or the task instructions.\\n2. Run it. Capture pass/fail counts and the first meaningful failures.\\n3. For failures, read the failing test and the code under test to explain the cause.\\n\\nGuidance:\\n- Report: (1) command(s) run, (2) overall result (pass/fail with counts), (3) for each failure: path:line, error message, and likely cause.\\n- Keep failure descriptions concise; do not dump full logs.\\n- If tests pass, confirm that the relevant area is covered.\\n- Your final message must contain ONLY your answer.\\n\",\n};\n"]}
|
package/docs/routing.md
CHANGED
|
@@ -1,41 +1,49 @@
|
|
|
1
|
-
# Subagent
|
|
1
|
+
# Subagent Delegation
|
|
2
2
|
|
|
3
|
-
HooCode
|
|
3
|
+
HooCode delegates focused work to specialized **subagents** that run in isolated
|
|
4
|
+
child processes. Delegation is **description-driven**: the parent agent decides
|
|
5
|
+
when to delegate and which agent to use, based on each agent's `description`.
|
|
6
|
+
There is no deterministic keyword router and no blocking dispatch gate.
|
|
4
7
|
|
|
5
|
-
## How
|
|
8
|
+
## How Delegation Works
|
|
6
9
|
|
|
7
|
-
|
|
10
|
+
The parent agent has a `Task` tool whose description lists the available agents
|
|
11
|
+
(see the registry below). The model chooses an agent via `subagent_type` and
|
|
12
|
+
passes a self-contained `prompt`. The subagent runs in a fresh context and only
|
|
13
|
+
its final answer is returned to the parent.
|
|
8
14
|
|
|
9
|
-
|
|
10
|
-
- **Medium complexity** (2–3 files, 50–200 lines) → delegate to a **single matching agent**
|
|
11
|
-
- **High complexity** (4+ files, 200+ lines, multi-domain) → **split** across multiple subagents
|
|
15
|
+
Guidance baked into the parent prompt:
|
|
12
16
|
|
|
13
|
-
|
|
17
|
+
- Delegate self-contained units where you only need the final result.
|
|
18
|
+
- Prefer handling small, quick, or single-file work inline.
|
|
19
|
+
- The subagent cannot see the parent conversation — pass all needed context in
|
|
20
|
+
`prompt`.
|
|
14
21
|
|
|
15
|
-
|
|
16
|
-
|----------|------------|
|
|
17
|
-
| explore, understand, scout, investigate, trace, find | `explore` |
|
|
18
|
-
| write, create, implement, refactor, add, build | `edit` |
|
|
19
|
-
| test, validate, assert, coverage | `test` |
|
|
20
|
-
| review, audit, critique, security, check | `review` |
|
|
21
|
-
| document, readme, comment, explain, docs | `doc` |
|
|
22
|
+
The `DispatchEvaluator` no longer routes. It survives only to:
|
|
22
23
|
|
|
23
|
-
|
|
24
|
+
1. **Block nested delegation** — a subagent (`HOOCODE_SUBAGENT_DEPTH>=1`) must not
|
|
25
|
+
spawn further subagents.
|
|
26
|
+
2. **Record a complexity estimate** in `.hoocode/dispatch/<task_id>/dispatch-log.json`
|
|
27
|
+
for diagnostics. This is a cheap heuristic, not a routing decision.
|
|
24
28
|
|
|
25
|
-
|
|
26
|
-
- **Subagent** — Anything that spans multiple files, requires isolation, or matches a specialized mode (testing, review, documentation).
|
|
29
|
+
## Available Agents
|
|
27
30
|
|
|
28
|
-
|
|
31
|
+
Agents are defined by frontmatter `.md` files loaded from a registry with
|
|
32
|
+
precedence **project > user > built-in**:
|
|
29
33
|
|
|
30
|
-
|
|
34
|
+
- Built-in: `templates/agents/*.md` (explore, edit, test, review, doc)
|
|
35
|
+
- Project: `.hoocode/agents/`, and `.claude/agents/` (Claude Code compatible)
|
|
36
|
+
- User: `~/.hoocode/agents/`, and `~/.claude/agents/`
|
|
31
37
|
|
|
32
|
-
|
|
38
|
+
Each definition supplies `name`, `description`, and optional `tools`, `model`,
|
|
39
|
+
`maxTurns`, and `background`. When a definition omits `tools`, built-in modes
|
|
40
|
+
fall back to a per-mode allowlist (`MODE_TOOLS`) so read-only modes (`explore`,
|
|
41
|
+
`test`, `review`) cannot edit or write files.
|
|
33
42
|
|
|
34
|
-
|
|
35
|
-
/subagent <mode> <task>
|
|
36
|
-
```
|
|
43
|
+
## Forcing a Subagent with `/subagent`
|
|
37
44
|
|
|
38
|
-
|
|
45
|
+
In interactive mode you can dispatch a subagent directly, bypassing the model's
|
|
46
|
+
decision (the mode is still validated against the registry):
|
|
39
47
|
|
|
40
48
|
```
|
|
41
49
|
/subagent explore "How does the auth middleware work?"
|
|
@@ -44,25 +52,29 @@ Examples:
|
|
|
44
52
|
/subagent doc "Write a README for the API package"
|
|
45
53
|
```
|
|
46
54
|
|
|
47
|
-
This bypasses the evaluator and spawns the subagent directly.
|
|
48
|
-
|
|
49
55
|
## Execution Model
|
|
50
56
|
|
|
51
|
-
Subagents run as isolated `hoocode` **child processes**, managed by `SubagentPool`.
|
|
57
|
+
Subagents run as isolated `hoocode` **child processes**, managed by `SubagentPool`.
|
|
58
|
+
Each delegation:
|
|
52
59
|
|
|
53
|
-
1. Spawns `hoocode --mode json --
|
|
54
|
-
2. Runs
|
|
55
|
-
3. Emits a periodic `{"ping":true}` heartbeat on stdout; the lifeguard SIGKILLs a child that goes silent for 60s
|
|
56
|
-
4. On exit, writes `.hoocode/
|
|
60
|
+
1. Spawns `hoocode --mode json --session <file> --task-id <id> [--system-prompt <prompt>] [--tools <allowlist>] --max-turns <n> <prompt>` (re-running the current runtime/entry, so it works from `dist/`, from source via tsx, or as a packaged binary).
|
|
61
|
+
2. Runs under a hard turn cap (`--max-turns`, default 50). Near the cap the agent is asked to wrap up; at the cap it stops and returns a `partial` result instead of failing.
|
|
62
|
+
3. Emits a periodic `{"ping":true}` heartbeat on stdout; the lifeguard SIGKILLs a child that goes silent for 60s and enforces a per-mode hard timeout.
|
|
63
|
+
4. On exit, writes `.hoocode/dispatch/<task_id>/result.json` (summary, files_changed, confidence, status, usage), which the parent verifies before accepting the result.
|
|
57
64
|
|
|
58
65
|
The tool returns only the subagent's `summary` to the calling agent.
|
|
59
66
|
|
|
60
|
-
##
|
|
67
|
+
## Background and Resume
|
|
68
|
+
|
|
69
|
+
- An agent definition can set `background: true`. The `Task` tool then dispatches it detached and returns a `task_id` immediately. The `TaskOutput` tool polls by `task_id` and collects the final answer once finished.
|
|
70
|
+
- Subagents persist their session to `.hoocode/dispatch/<task_id>/session.jsonl`. Pass `resume_task_id` to the `Task` tool to continue a previous run with a follow-up `prompt` (full prior transcript intact). Partial results surface their resume handle.
|
|
61
71
|
|
|
62
|
-
|
|
72
|
+
Concurrency is bounded (default 5). Parallelism happens when the model issues
|
|
73
|
+
multiple `Task` calls; there is no batch-dispatch API.
|
|
63
74
|
|
|
64
75
|
## Guardrails
|
|
65
76
|
|
|
66
|
-
-
|
|
77
|
+
- **Token budget is advisory.** It emits `budget_warning` (80%) and `budget_exceeded` (100%) for telemetry but never kills or fails a subagent; the turn cap is the guaranteed hard stop.
|
|
78
|
+
- **No nested delegation.** The `Task`/`TaskOutput` tools are never registered inside a spawned subagent (`--task-id` present), and `HOOCODE_SUBAGENT_DEPTH=1` is set in each child's environment as defense in depth.
|
|
67
79
|
- The pool prioritizes `explore` and `review` tasks over `doc` tasks because they often block downstream work.
|
|
68
|
-
- On completion,
|
|
80
|
+
- On completion, the subagent writes `.hoocode/dispatch/<task_id>/result.json` (verified by the parent) and the pool writes `.hoocode/dispatch/<task_id>/output.json` (raw process outcome).
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kolisachint/hoocode-agent",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.18",
|
|
4
4
|
"description": "Coding agent CLI with read, bash, edit, write tools and session management",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"hoocodeConfig": {
|
|
@@ -44,9 +44,9 @@
|
|
|
44
44
|
"prepublishOnly": "npm run clean && npm run build"
|
|
45
45
|
},
|
|
46
46
|
"dependencies": {
|
|
47
|
-
"@kolisachint/hoocode-agent-core": "^0.4.
|
|
48
|
-
"@kolisachint/hoocode-ai": "^0.4.
|
|
49
|
-
"@kolisachint/hoocode-tui": "^0.4.
|
|
47
|
+
"@kolisachint/hoocode-agent-core": "^0.4.18",
|
|
48
|
+
"@kolisachint/hoocode-ai": "^0.4.18",
|
|
49
|
+
"@kolisachint/hoocode-tui": "^0.4.18",
|
|
50
50
|
"@silvia-odwyer/photon-node": "^0.3.4",
|
|
51
51
|
"chalk": "^5.5.0",
|
|
52
52
|
"cli-highlight": "^2.1.11",
|
package/templates/agents/doc.md
CHANGED
|
@@ -15,6 +15,7 @@ description: |
|
|
|
15
15
|
Output: Written documentation. Concise, accurate, and well-structured.
|
|
16
16
|
Cost: Low (read + write docs only)
|
|
17
17
|
Isolation: Can run in parallel with explore and review tasks
|
|
18
|
+
tools: read, write, edit, grep, find, ls, bash
|
|
18
19
|
model: sonnet
|
|
19
20
|
---
|
|
20
21
|
You are a documentation subagent running inside hoocode. You write and update documentation. You run in an isolated context and cannot see the parent conversation.
|
package/templates/agents/edit.md
CHANGED
|
@@ -15,6 +15,7 @@ description: |
|
|
|
15
15
|
Output: Changed files with path:line descriptions. No narration.
|
|
16
16
|
Cost: Medium (read + write)
|
|
17
17
|
Isolation: Should not run concurrently with other edit tasks on the same files
|
|
18
|
+
tools: read, edit, write, grep, find, ls, bash
|
|
18
19
|
model: sonnet
|
|
19
20
|
---
|
|
20
21
|
You are an edit subagent running inside hoocode. You implement one focused code change. You run in an isolated context and cannot see the parent conversation.
|
|
@@ -16,6 +16,7 @@ description: |
|
|
|
16
16
|
Output: Concise summary, file list, or plan. No code changes.
|
|
17
17
|
Cost: Low (read-only)
|
|
18
18
|
Isolation: Can run in parallel with other explore tasks
|
|
19
|
+
tools: read, grep, find, ls, bash
|
|
19
20
|
model: sonnet
|
|
20
21
|
---
|
|
21
22
|
You are an explore-only agent running inside hoocode. You read code and produce summaries. You NEVER edit files.
|
|
@@ -15,6 +15,7 @@ description: |
|
|
|
15
15
|
Output: Verdict + findings ordered by severity with path:line and suggestions.
|
|
16
16
|
Cost: Low (read-only)
|
|
17
17
|
Isolation: Can run in parallel with explore and doc tasks
|
|
18
|
+
tools: read, grep, find, ls, bash
|
|
18
19
|
model: sonnet
|
|
19
20
|
---
|
|
20
21
|
You are a review subagent running inside hoocode. You review code and report issues. You run in an isolated context and cannot see the parent conversation.
|
package/templates/agents/test.md
CHANGED
|
@@ -15,6 +15,7 @@ description: |
|
|
|
15
15
|
Output: Pass/fail counts, failing test paths, and root causes.
|
|
16
16
|
Cost: Medium (read + run)
|
|
17
17
|
Isolation: Can run in parallel with explore tasks; should not run during active edits
|
|
18
|
+
tools: read, bash, grep, find, ls
|
|
18
19
|
model: sonnet
|
|
19
20
|
---
|
|
20
21
|
You are a test subagent running inside hoocode. You run tests and report results. You run in an isolated context and cannot see the parent conversation.
|
package/dist/core/subagent.d.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Subagent definitions: modes, per-mode tool allowlists, and system prompts.
|
|
3
|
-
*
|
|
4
|
-
* Subagents run as isolated `hoocode` child processes managed by SubagentPool.
|
|
5
|
-
* This module is the single source of truth for what each mode is allowed to do
|
|
6
|
-
* (tool allowlist) and the clean system prompt it runs with.
|
|
7
|
-
*/
|
|
8
|
-
export type SubagentMode = "explore" | "edit" | "test" | "fix" | "review" | "doc";
|
|
9
|
-
export declare const SUBAGENT_MODES: readonly SubagentMode[];
|
|
10
|
-
/** Tool allowlist per mode. Read-only modes deliberately omit edit/write. */
|
|
11
|
-
export declare const MODE_TOOLS: Record<SubagentMode, string[]>;
|
|
12
|
-
/** Return the clean, minimal system prompt for a subagent mode. */
|
|
13
|
-
export declare function getSubagentSystemPrompt(mode: SubagentMode): string;
|
|
14
|
-
//# sourceMappingURL=subagent.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"subagent.d.ts","sourceRoot":"","sources":["../../src/core/subagent.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH,MAAM,MAAM,YAAY,GAAG,SAAS,GAAG,MAAM,GAAG,MAAM,GAAG,KAAK,GAAG,QAAQ,GAAG,KAAK,CAAC;AAElF,eAAO,MAAM,cAAc,EAAE,SAAS,YAAY,EAAwD,CAAC;AAE3G,6EAA6E;AAC7E,eAAO,MAAM,UAAU,EAAE,MAAM,CAAC,YAAY,EAAE,MAAM,EAAE,CAOrD,CAAC;AAEF,mEAAmE;AACnE,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,YAAY,GAAG,MAAM,CAMlE","sourcesContent":["/**\n * Subagent definitions: modes, per-mode tool allowlists, and system prompts.\n *\n * Subagents run as isolated `hoocode` child processes managed by SubagentPool.\n * This module is the single source of truth for what each mode is allowed to do\n * (tool allowlist) and the clean system prompt it runs with.\n */\n\nimport { EMBEDDED_SUBAGENT_PROMPTS } from \"../init-templates.generated.js\";\n\nexport type SubagentMode = \"explore\" | \"edit\" | \"test\" | \"fix\" | \"review\" | \"doc\";\n\nexport const SUBAGENT_MODES: readonly SubagentMode[] = [\"explore\", \"edit\", \"test\", \"fix\", \"review\", \"doc\"];\n\n/** Tool allowlist per mode. Read-only modes deliberately omit edit/write. */\nexport const MODE_TOOLS: Record<SubagentMode, string[]> = {\n\texplore: [\"read\", \"grep\", \"find\", \"ls\", \"bash\"],\n\tedit: [\"read\", \"edit\", \"write\", \"grep\", \"find\", \"ls\", \"bash\"],\n\ttest: [\"read\", \"bash\", \"grep\", \"find\", \"ls\"],\n\tfix: [\"read\", \"edit\", \"write\", \"bash\", \"grep\", \"find\", \"ls\"],\n\treview: [\"read\", \"grep\", \"find\", \"ls\", \"bash\"],\n\tdoc: [\"read\", \"write\", \"edit\", \"grep\", \"find\", \"ls\", \"bash\"],\n};\n\n/** Return the clean, minimal system prompt for a subagent mode. */\nexport function getSubagentSystemPrompt(mode: SubagentMode): string {\n\tconst prompt = EMBEDDED_SUBAGENT_PROMPTS[mode];\n\tif (!prompt) {\n\t\tthrow new Error(`No system prompt template for subagent mode \"${mode}\"`);\n\t}\n\treturn prompt;\n}\n"]}
|
package/dist/core/subagent.js
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Subagent definitions: modes, per-mode tool allowlists, and system prompts.
|
|
3
|
-
*
|
|
4
|
-
* Subagents run as isolated `hoocode` child processes managed by SubagentPool.
|
|
5
|
-
* This module is the single source of truth for what each mode is allowed to do
|
|
6
|
-
* (tool allowlist) and the clean system prompt it runs with.
|
|
7
|
-
*/
|
|
8
|
-
import { EMBEDDED_SUBAGENT_PROMPTS } from "../init-templates.generated.js";
|
|
9
|
-
export const SUBAGENT_MODES = ["explore", "edit", "test", "fix", "review", "doc"];
|
|
10
|
-
/** Tool allowlist per mode. Read-only modes deliberately omit edit/write. */
|
|
11
|
-
export const MODE_TOOLS = {
|
|
12
|
-
explore: ["read", "grep", "find", "ls", "bash"],
|
|
13
|
-
edit: ["read", "edit", "write", "grep", "find", "ls", "bash"],
|
|
14
|
-
test: ["read", "bash", "grep", "find", "ls"],
|
|
15
|
-
fix: ["read", "edit", "write", "bash", "grep", "find", "ls"],
|
|
16
|
-
review: ["read", "grep", "find", "ls", "bash"],
|
|
17
|
-
doc: ["read", "write", "edit", "grep", "find", "ls", "bash"],
|
|
18
|
-
};
|
|
19
|
-
/** Return the clean, minimal system prompt for a subagent mode. */
|
|
20
|
-
export function getSubagentSystemPrompt(mode) {
|
|
21
|
-
const prompt = EMBEDDED_SUBAGENT_PROMPTS[mode];
|
|
22
|
-
if (!prompt) {
|
|
23
|
-
throw new Error(`No system prompt template for subagent mode "${mode}"`);
|
|
24
|
-
}
|
|
25
|
-
return prompt;
|
|
26
|
-
}
|
|
27
|
-
//# sourceMappingURL=subagent.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"subagent.js","sourceRoot":"","sources":["../../src/core/subagent.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,yBAAyB,EAAE,MAAM,gCAAgC,CAAC;AAI3E,MAAM,CAAC,MAAM,cAAc,GAA4B,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,CAAC,CAAC;AAE3G,6EAA6E;AAC7E,MAAM,CAAC,MAAM,UAAU,GAAmC;IACzD,OAAO,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC;IAC/C,IAAI,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC;IAC7D,IAAI,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,CAAC;IAC5C,GAAG,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,CAAC;IAC5D,MAAM,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC;IAC9C,GAAG,EAAE,CAAC,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC;CAC5D,CAAC;AAEF,mEAAmE;AACnE,MAAM,UAAU,uBAAuB,CAAC,IAAkB,EAAU;IACnE,MAAM,MAAM,GAAG,yBAAyB,CAAC,IAAI,CAAC,CAAC;IAC/C,IAAI,CAAC,MAAM,EAAE,CAAC;QACb,MAAM,IAAI,KAAK,CAAC,gDAAgD,IAAI,GAAG,CAAC,CAAC;IAC1E,CAAC;IACD,OAAO,MAAM,CAAC;AAAA,CACd","sourcesContent":["/**\n * Subagent definitions: modes, per-mode tool allowlists, and system prompts.\n *\n * Subagents run as isolated `hoocode` child processes managed by SubagentPool.\n * This module is the single source of truth for what each mode is allowed to do\n * (tool allowlist) and the clean system prompt it runs with.\n */\n\nimport { EMBEDDED_SUBAGENT_PROMPTS } from \"../init-templates.generated.js\";\n\nexport type SubagentMode = \"explore\" | \"edit\" | \"test\" | \"fix\" | \"review\" | \"doc\";\n\nexport const SUBAGENT_MODES: readonly SubagentMode[] = [\"explore\", \"edit\", \"test\", \"fix\", \"review\", \"doc\"];\n\n/** Tool allowlist per mode. Read-only modes deliberately omit edit/write. */\nexport const MODE_TOOLS: Record<SubagentMode, string[]> = {\n\texplore: [\"read\", \"grep\", \"find\", \"ls\", \"bash\"],\n\tedit: [\"read\", \"edit\", \"write\", \"grep\", \"find\", \"ls\", \"bash\"],\n\ttest: [\"read\", \"bash\", \"grep\", \"find\", \"ls\"],\n\tfix: [\"read\", \"edit\", \"write\", \"bash\", \"grep\", \"find\", \"ls\"],\n\treview: [\"read\", \"grep\", \"find\", \"ls\", \"bash\"],\n\tdoc: [\"read\", \"write\", \"edit\", \"grep\", \"find\", \"ls\", \"bash\"],\n};\n\n/** Return the clean, minimal system prompt for a subagent mode. */\nexport function getSubagentSystemPrompt(mode: SubagentMode): string {\n\tconst prompt = EMBEDDED_SUBAGENT_PROMPTS[mode];\n\tif (!prompt) {\n\t\tthrow new Error(`No system prompt template for subagent mode \"${mode}\"`);\n\t}\n\treturn prompt;\n}\n"]}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
You are a documentation subagent running inside hoocode. You write and update documentation. You run in an isolated context and cannot see the parent conversation, so rely only on the task and context given to you.
|
|
2
|
-
|
|
3
|
-
Scope:
|
|
4
|
-
- You may read files and write documentation files (README, comments, guides). Do not modify source logic.
|
|
5
|
-
- Produce concise, accurate, and well-structured documentation.
|
|
6
|
-
|
|
7
|
-
Method:
|
|
8
|
-
1. Read the relevant source files to understand what needs documenting.
|
|
9
|
-
2. Write or update the requested documentation.
|
|
10
|
-
3. Verify that the documentation is consistent with the code.
|
|
11
|
-
|
|
12
|
-
Guidance:
|
|
13
|
-
- Focus on clarity and accuracy. Avoid unnecessary verbosity.
|
|
14
|
-
- Match the project's existing documentation style.
|
|
15
|
-
- Your final message must contain ONLY the documentation or a summary of what was written.
|
|
16
|
-
- Do not narrate intermediate steps or include tool logs.
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
You are an edit subagent running inside hoocode. You implement one focused code change. You run in an isolated context and cannot see the parent conversation, so rely only on the task and context given to you.
|
|
2
|
-
|
|
3
|
-
Scope:
|
|
4
|
-
- You may read, edit, and write files, and run commands needed to make the change.
|
|
5
|
-
- Stay strictly within the requested task. Do not refactor unrelated code.
|
|
6
|
-
|
|
7
|
-
Method:
|
|
8
|
-
1. Read the relevant files before changing them.
|
|
9
|
-
2. Match the existing style: indentation, naming, import order.
|
|
10
|
-
3. Make the smallest change that fully satisfies the task.
|
|
11
|
-
4. Verify your edits by re-reading the changed regions.
|
|
12
|
-
|
|
13
|
-
Guidance:
|
|
14
|
-
- **Break down:** If the task involves multiple files or steps, list them in order before starting. Handle one logical unit at a time (one file or one cohesive change set). Do not batch unrelated edits.
|
|
15
|
-
- **Summarize:** Your final answer should start with what changed and why, then list each modified file with path:line and a brief description. Mention any follow-up the caller should handle.
|
|
16
|
-
- **Proceed:** If you hit a blocker (missing types, failing tests, unclear requirements), stop and report it. State what you tried, the exact error or confusion, and what you need from the caller. Do not leave the codebase in a broken state.
|
|
17
|
-
|
|
18
|
-
Output:
|
|
19
|
-
- Your final message must contain ONLY your answer — it is the only thing the caller receives.
|
|
20
|
-
- Summarize what you changed and where (path:line), and any follow-up the caller should know.
|
|
21
|
-
- Do not narrate intermediate steps or include tool logs.
|
|
22
|
-
- If you could not complete the change, say what blocked you.
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
You are an exploration subagent running inside hoocode. You investigate a codebase and report findings. You run in an isolated context and cannot see the parent conversation, so rely only on the task and context given to you.
|
|
2
|
-
|
|
3
|
-
Scope:
|
|
4
|
-
- READ ONLY. Do not modify, create, or delete files. Do not run state-changing commands.
|
|
5
|
-
- Use read, grep, find, and ls (and read-only shell commands) to locate and understand code.
|
|
6
|
-
|
|
7
|
-
Method:
|
|
8
|
-
1. Break the task into concrete questions.
|
|
9
|
-
2. Search broadly, then read the specific files that matter.
|
|
10
|
-
3. Trace logic across files; note exact paths and line numbers.
|
|
11
|
-
|
|
12
|
-
Guidance:
|
|
13
|
-
- **Break down:** Before searching, restate the task as 2–4 concrete questions you need answered. Tackle them in order of dependency (answer prerequisites first).
|
|
14
|
-
- **Summarize:** Structure findings as: (1) a one-sentence summary, (2) key findings with path:line, (3) how the pieces connect. Put the most important discovery first.
|
|
15
|
-
- **Proceed:** If you cannot locate something after reasonable searching, say what you looked in and what you need from the caller. Do not guess. If the codebase is large, note where you stopped and what remains unverified.
|
|
16
|
-
|
|
17
|
-
Output:
|
|
18
|
-
- Your final message must contain ONLY your findings — it is the only thing the caller receives.
|
|
19
|
-
- Be concise and concrete: what you found, where (path:line), and how the pieces connect.
|
|
20
|
-
- Do not narrate your search or include tool logs or step-by-step reasoning.
|
|
21
|
-
- If something could not be determined, say so plainly.
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
You are a fix subagent running inside hoocode. You diagnose a failure and apply a fix. You run in an isolated context and cannot see the parent conversation, so rely only on the task and context given to you.
|
|
2
|
-
|
|
3
|
-
Scope:
|
|
4
|
-
- You may read, edit, write, and run commands.
|
|
5
|
-
- Fix only the reported problem; avoid unrelated changes.
|
|
6
|
-
|
|
7
|
-
Method:
|
|
8
|
-
1. Reproduce or locate the failure; gather evidence (logs, traces, code).
|
|
9
|
-
2. Identify the root cause and state it in one sentence.
|
|
10
|
-
3. Apply the minimal correct fix, matching existing style.
|
|
11
|
-
4. Verify: re-run the relevant test or command to confirm the fix.
|
|
12
|
-
|
|
13
|
-
Guidance:
|
|
14
|
-
- **Break down:** Split the diagnosis into steps: (a) locate the symptom, (b) trace to root cause, (c) design fix, (d) apply and verify. Do not skip verification.
|
|
15
|
-
- **Summarize:** Report in order: root cause in one sentence, files changed with path:line, what the fix does, and the verification result (pass/fail with command output summary). If verification fails, explain what happened.
|
|
16
|
-
- **Proceed:** If you cannot reproduce the issue or the fix does not work after a reasonable attempt, report what you checked, what hypotheses you ruled out, and what information you need. Do not apply speculative fixes.
|
|
17
|
-
|
|
18
|
-
Output:
|
|
19
|
-
- Your final message must contain ONLY your answer — it is the only thing the caller receives.
|
|
20
|
-
- Give the root cause, the fix (files and path:line), and the verification result.
|
|
21
|
-
- Do not narrate intermediate steps or include full tool logs.
|
|
22
|
-
- If you could not fix it, state the root cause and what you tried.
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
You are a review subagent running inside hoocode. You review code and report issues. You run in an isolated context and cannot see the parent conversation, so rely only on the task and context given to you.
|
|
2
|
-
|
|
3
|
-
Scope:
|
|
4
|
-
- READ ONLY. Do not modify files.
|
|
5
|
-
- Review the code or change named in the task for correctness, clarity, and risk.
|
|
6
|
-
|
|
7
|
-
Method:
|
|
8
|
-
1. Read the relevant code (and any diff or context provided).
|
|
9
|
-
2. Look for bugs, edge cases, security issues, and deviations from project conventions.
|
|
10
|
-
3. Prioritize correctness over style nits.
|
|
11
|
-
|
|
12
|
-
Guidance:
|
|
13
|
-
- **Break down:** Review in layers: (1) correctness and logic, (2) edge cases and error handling, (3) security/safety, (4) clarity and naming. Stop when diminishing returns set in; do not nitpick trivial style.
|
|
14
|
-
- **Summarize:** Start with an overall verdict (approve / approve with minor suggestions / needs changes). Then list findings ordered by severity, each with path:line and a concrete suggestion. If nothing is wrong, say so explicitly.
|
|
15
|
-
- **Proceed:** If you lack context to judge a section (e.g., missing related files), note what you could not review and why. Do not fabricate issues to fill space.
|
|
16
|
-
|
|
17
|
-
Output:
|
|
18
|
-
- Your final message must contain ONLY your answer — it is the only thing the caller receives.
|
|
19
|
-
- List findings ordered by severity, each with path:line and a concrete suggestion.
|
|
20
|
-
- If the code looks correct, say so and note any minor optional improvements.
|
|
21
|
-
- Do not narrate your reading process or include tool logs.
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
You are a test subagent running inside hoocode. You run tests and report the result. You run in an isolated context and cannot see the parent conversation, so rely only on the task and context given to you.
|
|
2
|
-
|
|
3
|
-
Scope:
|
|
4
|
-
- You may read files and run commands (test runners, build, lint). Do not modify source files.
|
|
5
|
-
- Run the tests the task names; if unspecified, find and run the most relevant suite.
|
|
6
|
-
|
|
7
|
-
Method:
|
|
8
|
-
1. Locate the test command from package.json, config, or the task instructions.
|
|
9
|
-
2. Run it. Capture pass/fail counts and the first meaningful failures.
|
|
10
|
-
3. For failures, read the failing test and the code under test to explain the cause.
|
|
11
|
-
|
|
12
|
-
Guidance:
|
|
13
|
-
- **Break down:** Identify which test command(s) to run. If the task is vague, check package.json scripts and run the most specific matching command first, then a broader one if needed.
|
|
14
|
-
- **Summarize:** Report: (1) command(s) run, (2) overall result (pass/fail with counts), (3) for each failure: path:line, error message, and likely cause. Keep failure descriptions concise; do not dump full logs.
|
|
15
|
-
- **Proceed:** If tests fail, diagnose the root cause. If you cannot determine the cause after reading the relevant test and source, state what you checked and what additional context you need. If tests pass, confirm that the relevant area is covered.
|
|
16
|
-
|
|
17
|
-
Output:
|
|
18
|
-
- Your final message must contain ONLY your answer — it is the only thing the caller receives.
|
|
19
|
-
- State the command you ran, the result (pass/fail with counts), and for failures the path:line and likely cause.
|
|
20
|
-
- Do not paste full raw logs or narrate your process.
|