@kolisachint/hoocode-agent 0.4.61 → 0.4.63
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 +41 -0
- package/dist/cli/args.d.ts +5 -0
- package/dist/cli/args.d.ts.map +1 -1
- package/dist/cli/args.js +22 -0
- package/dist/cli/args.js.map +1 -1
- package/dist/core/agent-frontmatter.d.ts +22 -0
- package/dist/core/agent-frontmatter.d.ts.map +1 -1
- package/dist/core/agent-frontmatter.js +60 -0
- package/dist/core/agent-frontmatter.js.map +1 -1
- package/dist/core/agent-session.d.ts +3 -0
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +7 -1
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/dispatch-evaluator.d.ts +3 -2
- package/dist/core/dispatch-evaluator.d.ts.map +1 -1
- package/dist/core/dispatch-evaluator.js +9 -5
- package/dist/core/dispatch-evaluator.js.map +1 -1
- package/dist/core/sdk.d.ts +5 -0
- package/dist/core/sdk.d.ts.map +1 -1
- package/dist/core/sdk.js +1 -0
- package/dist/core/sdk.js.map +1 -1
- package/dist/core/settings-defaults.d.ts +2 -0
- package/dist/core/settings-defaults.d.ts.map +1 -1
- package/dist/core/settings-defaults.js +2 -0
- package/dist/core/settings-defaults.js.map +1 -1
- package/dist/core/settings-manager.d.ts +6 -0
- package/dist/core/settings-manager.d.ts.map +1 -1
- package/dist/core/settings-manager.js +10 -0
- package/dist/core/settings-manager.js.map +1 -1
- package/dist/core/subagent-depth.d.ts +67 -0
- package/dist/core/subagent-depth.d.ts.map +1 -0
- package/dist/core/subagent-depth.js +112 -0
- package/dist/core/subagent-depth.js.map +1 -0
- package/dist/core/subagent-pool-instance.d.ts.map +1 -1
- package/dist/core/subagent-pool-instance.js +11 -1
- package/dist/core/subagent-pool-instance.js.map +1 -1
- package/dist/core/subagent-pool.d.ts.map +1 -1
- package/dist/core/subagent-pool.js +47 -17
- package/dist/core/subagent-pool.js.map +1 -1
- package/dist/core/subagent-result.d.ts +31 -0
- package/dist/core/subagent-result.d.ts.map +1 -1
- package/dist/core/subagent-result.js +31 -0
- package/dist/core/subagent-result.js.map +1 -1
- package/dist/core/task-store.d.ts +11 -1
- package/dist/core/task-store.d.ts.map +1 -1
- package/dist/core/task-store.js +3 -0
- package/dist/core/task-store.js.map +1 -1
- package/dist/core/token-budget.d.ts.map +1 -1
- package/dist/core/token-budget.js +6 -9
- package/dist/core/token-budget.js.map +1 -1
- package/dist/core/tools/subagent.d.ts +8 -0
- package/dist/core/tools/subagent.d.ts.map +1 -1
- package/dist/core/tools/subagent.js +55 -2
- package/dist/core/tools/subagent.js.map +1 -1
- package/dist/init-templates.generated.d.ts.map +1 -1
- package/dist/init-templates.generated.js +3 -6
- package/dist/init-templates.generated.js.map +1 -1
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +31 -3
- package/dist/main.js.map +1 -1
- package/dist/modes/interactive/components/task-panel.d.ts +12 -7
- package/dist/modes/interactive/components/task-panel.d.ts.map +1 -1
- package/dist/modes/interactive/components/task-panel.js +90 -57
- package/dist/modes/interactive/components/task-panel.js.map +1 -1
- package/dist/modes/print-mode.d.ts.map +1 -1
- package/dist/modes/print-mode.js +8 -1
- package/dist/modes/print-mode.js.map +1 -1
- package/docs/routing.md +15 -10
- package/examples/agents/fork-reviewer.md +29 -0
- package/examples/agents/orchestrator.md +35 -0
- 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/explore.md +4 -5
- package/templates/agents/general-purpose.md +8 -7
- package/templates/agents/plan.md +39 -0
- package/templates/agents/doc.md +0 -37
- package/templates/agents/edit.md +0 -39
- package/templates/agents/review.md +0 -38
- package/templates/agents/test.md +0 -37
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"print-m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M,cAAc,EAAE,CAAC;QACvB,MAAM,cAAc,EAAE,CAAC;IACxB,CAAC;AAAA,CACD","sourcesContent":["/**\n * Print mode (single-shot): Send prompts, output result, exit.\n *\n * Used for:\n * - `hoocode -p \"prompt\"` - text output\n * - `hoocode --mode json \"prompt\"` - JSON event stream\n */\n\nimport type { AssistantMessage, ImageContent } from \"@kolisachint/hoocode-ai\";\nimport type { AgentSessionRuntime } from \"../core/agent-session-runtime.js\";\nimport { flushRawStdout, writeRawStdout } from \"../core/output-guard.js\";\nimport { buildSubagentResult, writeSubagentResult } from \"../core/subagent-result.js\";\nimport { killTrackedDetachedChildren } from \"../utils/shell.js\";\n\n/** Heartbeat cadence for spawned subagents (parent lifeguard stalls after 60s of silence). */\nconst SUBAGENT_HEARTBEAT_MS = 30000;\n\n/**\n * Options for print mode.\n */\nexport interface PrintModeOptions {\n\t/** Output mode: \"text\" for final response only, \"json\" for all events */\n\tmode: \"text\" | \"json\";\n\t/** Array of additional prompts to send after initialMessage */\n\tmessages?: string[];\n\t/** First message to send (may contain @file content) */\n\tinitialMessage?: string;\n\t/** Images to attach to the initial message */\n\tinitialImages?: ImageContent[];\n\t/** Internal: set when this process is a spawned subagent. Enables heartbeats and result.json. */\n\ttaskId?: string;\n\t/** Hard cap on assistant turns. Near the cap the agent is asked to wrap up; at the cap it is aborted. */\n\tmaxTurns?: number;\n}\n\n/**\n * Run in print (single-shot) mode.\n * Sends prompts to the agent and outputs the result.\n */\nexport async function runPrintMode(runtimeHost: AgentSessionRuntime, options: PrintModeOptions): Promise<number> {\n\tconst { mode, messages = [], initialMessage, initialImages, taskId, maxTurns } = options;\n\tlet exitCode = 0;\n\tlet session = runtimeHost.session;\n\tlet unsubscribe: (() => void) | undefined;\n\tlet disposed = false;\n\n\t// Spawned subagents (json mode + task id) emit a periodic heartbeat so the\n\t// parent lifeguard does not treat a long-thinking turn as a stall.\n\tconst isSubagent = mode === \"json\" && typeof taskId === \"string\" && taskId.length > 0;\n\tlet heartbeat: NodeJS.Timeout | undefined;\n\tif (isSubagent) {\n\t\t// Emit an immediate ping so a child that crashes during startup surfaces its\n\t\t// real error instead of stalling silently until the first delayed heartbeat.\n\t\twriteRawStdout(`${JSON.stringify({ ping: true })}\\n`);\n\t\theartbeat = setInterval(() => {\n\t\t\twriteRawStdout(`${JSON.stringify({ ping: true })}\\n`);\n\t\t}, SUBAGENT_HEARTBEAT_MS);\n\t\theartbeat.unref();\n\t}\n\t// Turn-limit enforcement for spawned subagents: ask the agent to wrap up near\n\t// the cap, then hard-stop at the cap so a runaway agent always terminates.\n\tlet reachedMaxTurns = false;\n\tlet turnLimitUnsub: (() => void) | undefined;\n\tconst signalCleanupHandlers: Array<() => void> = [];\n\n\tconst disposeRuntime = async (): Promise<void> => {\n\t\tif (disposed) return;\n\t\tdisposed = true;\n\t\tunsubscribe?.();\n\t\tawait runtimeHost.dispose();\n\t};\n\n\tconst registerSignalHandlers = (): void => {\n\t\tconst signals: NodeJS.Signals[] = [\"SIGTERM\"];\n\t\tif (process.platform !== \"win32\") {\n\t\t\tsignals.push(\"SIGHUP\");\n\t\t}\n\n\t\tfor (const signal of signals) {\n\t\t\tconst handler = () => {\n\t\t\t\tkillTrackedDetachedChildren();\n\t\t\t\tvoid disposeRuntime().finally(() => {\n\t\t\t\t\tprocess.exit(signal === \"SIGHUP\" ? 129 : 143);\n\t\t\t\t});\n\t\t\t};\n\t\t\tprocess.on(signal, handler);\n\t\t\tsignalCleanupHandlers.push(() => process.off(signal, handler));\n\t\t}\n\t};\n\n\tregisterSignalHandlers();\n\n\truntimeHost.setRebindSession(async () => {\n\t\tawait rebindSession();\n\t});\n\n\tconst rebindSession = async (): Promise<void> => {\n\t\tsession = runtimeHost.session;\n\t\tawait session.bindExtensions({\n\t\t\tcommandContextActions: {\n\t\t\t\twaitForIdle: () => session.agent.waitForIdle(),\n\t\t\t\tnewSession: async (newSessionOptions) => runtimeHost.newSession(newSessionOptions),\n\t\t\t\tfork: async (entryId, forkOptions) => {\n\t\t\t\t\tconst result = await runtimeHost.fork(entryId, forkOptions);\n\t\t\t\t\treturn { cancelled: result.cancelled };\n\t\t\t\t},\n\t\t\t\tnavigateTree: async (targetId, navigateOptions) => {\n\t\t\t\t\tconst result = await session.navigateTree(targetId, {\n\t\t\t\t\t\tsummarize: navigateOptions?.summarize,\n\t\t\t\t\t\tcustomInstructions: navigateOptions?.customInstructions,\n\t\t\t\t\t\treplaceInstructions: navigateOptions?.replaceInstructions,\n\t\t\t\t\t\tlabel: navigateOptions?.label,\n\t\t\t\t\t});\n\t\t\t\t\treturn { cancelled: result.cancelled };\n\t\t\t\t},\n\t\t\t\tswitchSession: async (sessionPath, switchOptions) => {\n\t\t\t\t\treturn runtimeHost.switchSession(sessionPath, switchOptions);\n\t\t\t\t},\n\t\t\t\treload: async () => {\n\t\t\t\t\tawait session.reload();\n\t\t\t\t},\n\t\t\t},\n\t\t\tonError: (err) => {\n\t\t\t\tconsole.error(`Extension error (${err.extensionPath}): ${err.error}`);\n\t\t\t},\n\t\t});\n\n\t\tunsubscribe?.();\n\t\tunsubscribe = session.subscribe((event) => {\n\t\t\tif (mode === \"json\") {\n\t\t\t\twriteRawStdout(`${JSON.stringify(event)}\\n`);\n\t\t\t}\n\t\t});\n\t};\n\n\ttry {\n\t\tif (mode === \"json\") {\n\t\t\tconst header = session.sessionManager.getHeader();\n\t\t\tif (header) {\n\t\t\t\twriteRawStdout(`${JSON.stringify(header)}\\n`);\n\t\t\t}\n\t\t}\n\n\t\tawait rebindSession();\n\n\t\tif (isSubagent && typeof maxTurns === \"number\" && maxTurns > 0) {\n\t\t\tconst cap = maxTurns;\n\t\t\tconst wrapUpAt = Math.floor(cap * 0.9);\n\t\t\tlet turns = 0;\n\t\t\tlet warned = false;\n\t\t\tturnLimitUnsub = session.subscribe((event) => {\n\t\t\t\tif (event.type !== \"turn_end\") return;\n\t\t\t\tturns += 1;\n\t\t\t\tif (turns >= cap) {\n\t\t\t\t\tif (!reachedMaxTurns) {\n\t\t\t\t\t\treachedMaxTurns = true;\n\t\t\t\t\t\tvoid session.abort();\n\t\t\t\t\t}\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tif (!warned && wrapUpAt >= 1 && wrapUpAt < cap && turns >= wrapUpAt) {\n\t\t\t\t\twarned = true;\n\t\t\t\t\tvoid session.steer(\n\t\t\t\t\t\t`You are at turn ${turns} of your ${cap}-turn limit. Stop investigating or making changes now and write your final summary of findings and results in your next message.`,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\n\t\tif (initialMessage) {\n\t\t\tawait session.prompt(initialMessage, { images: initialImages });\n\t\t}\n\n\t\tfor (const message of messages) {\n\t\t\tawait session.prompt(message);\n\t\t}\n\n\t\t// Spawned subagents write the audit file the parent pool verifies.\n\t\tif (isSubagent && taskId) {\n\t\t\tconst stats = session.getSessionStats();\n\t\t\tconst result = buildSubagentResult(\n\t\t\t\tsession.state.messages,\n\t\t\t\t{\n\t\t\t\t\tinput: stats.tokens.input,\n\t\t\t\t\toutput: stats.tokens.output,\n\t\t\t\t\tcacheRead: stats.tokens.cacheRead,\n\t\t\t\t\tcacheWrite: stats.tokens.cacheWrite,\n\t\t\t\t\tcost: stats.cost,\n\t\t\t\t},\n\t\t\t\t{ reachedMaxTurns },\n\t\t\t);\n\t\t\twriteSubagentResult(session.sessionManager.getCwd(), taskId, result);\n\t\t\tif (result.status === \"failed\") exitCode = 1;\n\t\t}\n\n\t\tif (mode === \"text\") {\n\t\t\tconst state = session.state;\n\t\t\tconst lastMessage = state.messages[state.messages.length - 1];\n\n\t\t\tif (lastMessage?.role === \"assistant\") {\n\t\t\t\tconst assistantMsg = lastMessage as AssistantMessage;\n\t\t\t\tif (assistantMsg.stopReason === \"error\" || assistantMsg.stopReason === \"aborted\") {\n\t\t\t\t\tconsole.error(assistantMsg.errorMessage || `Request ${assistantMsg.stopReason}`);\n\t\t\t\t\texitCode = 1;\n\t\t\t\t} else {\n\t\t\t\t\tfor (const content of assistantMsg.content) {\n\t\t\t\t\t\tif (content.type === \"text\") {\n\t\t\t\t\t\t\twriteRawStdout(`${content.text}\\n`);\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\n\t\treturn exitCode;\n\t} catch (error: unknown) {\n\t\tconsole.error(error instanceof Error ? error.message : String(error));\n\t\treturn 1;\n\t} finally {\n\t\tif (heartbeat) clearInterval(heartbeat);\n\t\tturnLimitUnsub?.();\n\t\tfor (const cleanup of signalCleanupHandlers) {\n\t\t\tcleanup();\n\t\t}\n\t\tawait disposeRuntime();\n\t\tawait flushRawStdout();\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"print-mode.js","sourceRoot":"","sources":["../../src/modes/print-mode.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AACzE,OAAO,EAAE,mBAAmB,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AACvG,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAClD,OAAO,EAAE,2BAA2B,EAAE,MAAM,mBAAmB,CAAC;AAEhE,8FAA8F;AAC9F,MAAM,qBAAqB,GAAG,KAAK,CAAC;AAoBpC;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY,CAAC,WAAgC,EAAE,OAAyB,EAAmB;IAChH,MAAM,EAAE,IAAI,EAAE,QAAQ,GAAG,EAAE,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,EAAE,QAAQ,EAAE,GAAG,OAAO,CAAC;IACzF,IAAI,QAAQ,GAAG,CAAC,CAAC;IACjB,IAAI,OAAO,GAAG,WAAW,CAAC,OAAO,CAAC;IAClC,IAAI,WAAqC,CAAC;IAC1C,IAAI,QAAQ,GAAG,KAAK,CAAC;IAErB,2EAA2E;IAC3E,mEAAmE;IACnE,MAAM,UAAU,GAAG,IAAI,KAAK,MAAM,I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AAC;gBACd,CAAC;qBAAM,CAAC;oBACP,KAAK,MAAM,OAAO,IAAI,YAAY,CAAC,OAAO,EAAE,CAAC;wBAC5C,IAAI,OAAO,CAAC,IAAI,KAAK,MAAM,EAAE,CAAC;4BAC7B,cAAc,CAAC,GAAG,OAAO,CAAC,IAAI,IAAI,CAAC,CAAC;wBACrC,CAAC;oBACF,CAAC;gBACF,CAAC;YACF,CAAC;QACF,CAAC;QAED,OAAO,QAAQ,CAAC;IACjB,CAAC;IAAC,OAAO,KAAc,EAAE,CAAC;QACzB,OAAO,CAAC,KAAK,CAAC,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;QACtE,OAAO,CAAC,CAAC;IACV,CAAC;YAAS,CAAC;QACV,IAAI,SAAS;YAAE,aAAa,CAAC,SAAS,CAAC,CAAC;QACxC,cAAc,EAAE,EAAE,CAAC;QACnB,KAAK,MAAM,OAAO,IAAI,qBAAqB,EAAE,CAAC;YAC7C,OAAO,EAAE,CAAC;QACX,CAAC;QACD,MAAM,cAAc,EAAE,CAAC;QACvB,MAAM,cAAc,EAAE,CAAC;IACxB,CAAC;AAAA,CACD","sourcesContent":["/**\n * Print mode (single-shot): Send prompts, output result, exit.\n *\n * Used for:\n * - `hoocode -p \"prompt\"` - text output\n * - `hoocode --mode json \"prompt\"` - JSON event stream\n */\n\nimport type { AssistantMessage, ImageContent } from \"@kolisachint/hoocode-ai\";\nimport type { AgentSessionRuntime } from \"../core/agent-session-runtime.js\";\nimport { flushRawStdout, writeRawStdout } from \"../core/output-guard.js\";\nimport { buildSubagentResult, buildTaskForest, writeSubagentResult } from \"../core/subagent-result.js\";\nimport { taskStore } from \"../core/task-store.js\";\nimport { killTrackedDetachedChildren } from \"../utils/shell.js\";\n\n/** Heartbeat cadence for spawned subagents (parent lifeguard stalls after 60s of silence). */\nconst SUBAGENT_HEARTBEAT_MS = 30000;\n\n/**\n * Options for print mode.\n */\nexport interface PrintModeOptions {\n\t/** Output mode: \"text\" for final response only, \"json\" for all events */\n\tmode: \"text\" | \"json\";\n\t/** Array of additional prompts to send after initialMessage */\n\tmessages?: string[];\n\t/** First message to send (may contain @file content) */\n\tinitialMessage?: string;\n\t/** Images to attach to the initial message */\n\tinitialImages?: ImageContent[];\n\t/** Internal: set when this process is a spawned subagent. Enables heartbeats and result.json. */\n\ttaskId?: string;\n\t/** Hard cap on assistant turns. Near the cap the agent is asked to wrap up; at the cap it is aborted. */\n\tmaxTurns?: number;\n}\n\n/**\n * Run in print (single-shot) mode.\n * Sends prompts to the agent and outputs the result.\n */\nexport async function runPrintMode(runtimeHost: AgentSessionRuntime, options: PrintModeOptions): Promise<number> {\n\tconst { mode, messages = [], initialMessage, initialImages, taskId, maxTurns } = options;\n\tlet exitCode = 0;\n\tlet session = runtimeHost.session;\n\tlet unsubscribe: (() => void) | undefined;\n\tlet disposed = false;\n\n\t// Spawned subagents (json mode + task id) emit a periodic heartbeat so the\n\t// parent lifeguard does not treat a long-thinking turn as a stall.\n\tconst isSubagent = mode === \"json\" && typeof taskId === \"string\" && taskId.length > 0;\n\tlet heartbeat: NodeJS.Timeout | undefined;\n\tif (isSubagent) {\n\t\t// Emit an immediate ping so a child that crashes during startup surfaces its\n\t\t// real error instead of stalling silently until the first delayed heartbeat.\n\t\twriteRawStdout(`${JSON.stringify({ ping: true })}\\n`);\n\t\theartbeat = setInterval(() => {\n\t\t\twriteRawStdout(`${JSON.stringify({ ping: true })}\\n`);\n\t\t}, SUBAGENT_HEARTBEAT_MS);\n\t\theartbeat.unref();\n\t}\n\t// Turn-limit enforcement for spawned subagents: ask the agent to wrap up near\n\t// the cap, then hard-stop at the cap so a runaway agent always terminates.\n\tlet reachedMaxTurns = false;\n\tlet turnLimitUnsub: (() => void) | undefined;\n\tconst signalCleanupHandlers: Array<() => void> = [];\n\n\tconst disposeRuntime = async (): Promise<void> => {\n\t\tif (disposed) return;\n\t\tdisposed = true;\n\t\tunsubscribe?.();\n\t\tawait runtimeHost.dispose();\n\t};\n\n\tconst registerSignalHandlers = (): void => {\n\t\tconst signals: NodeJS.Signals[] = [\"SIGTERM\"];\n\t\tif (process.platform !== \"win32\") {\n\t\t\tsignals.push(\"SIGHUP\");\n\t\t}\n\n\t\tfor (const signal of signals) {\n\t\t\tconst handler = () => {\n\t\t\t\tkillTrackedDetachedChildren();\n\t\t\t\tvoid disposeRuntime().finally(() => {\n\t\t\t\t\tprocess.exit(signal === \"SIGHUP\" ? 129 : 143);\n\t\t\t\t});\n\t\t\t};\n\t\t\tprocess.on(signal, handler);\n\t\t\tsignalCleanupHandlers.push(() => process.off(signal, handler));\n\t\t}\n\t};\n\n\tregisterSignalHandlers();\n\n\truntimeHost.setRebindSession(async () => {\n\t\tawait rebindSession();\n\t});\n\n\tconst rebindSession = async (): Promise<void> => {\n\t\tsession = runtimeHost.session;\n\t\tawait session.bindExtensions({\n\t\t\tcommandContextActions: {\n\t\t\t\twaitForIdle: () => session.agent.waitForIdle(),\n\t\t\t\tnewSession: async (newSessionOptions) => runtimeHost.newSession(newSessionOptions),\n\t\t\t\tfork: async (entryId, forkOptions) => {\n\t\t\t\t\tconst result = await runtimeHost.fork(entryId, forkOptions);\n\t\t\t\t\treturn { cancelled: result.cancelled };\n\t\t\t\t},\n\t\t\t\tnavigateTree: async (targetId, navigateOptions) => {\n\t\t\t\t\tconst result = await session.navigateTree(targetId, {\n\t\t\t\t\t\tsummarize: navigateOptions?.summarize,\n\t\t\t\t\t\tcustomInstructions: navigateOptions?.customInstructions,\n\t\t\t\t\t\treplaceInstructions: navigateOptions?.replaceInstructions,\n\t\t\t\t\t\tlabel: navigateOptions?.label,\n\t\t\t\t\t});\n\t\t\t\t\treturn { cancelled: result.cancelled };\n\t\t\t\t},\n\t\t\t\tswitchSession: async (sessionPath, switchOptions) => {\n\t\t\t\t\treturn runtimeHost.switchSession(sessionPath, switchOptions);\n\t\t\t\t},\n\t\t\t\treload: async () => {\n\t\t\t\t\tawait session.reload();\n\t\t\t\t},\n\t\t\t},\n\t\t\tonError: (err) => {\n\t\t\t\tconsole.error(`Extension error (${err.extensionPath}): ${err.error}`);\n\t\t\t},\n\t\t});\n\n\t\tunsubscribe?.();\n\t\tunsubscribe = session.subscribe((event) => {\n\t\t\tif (mode === \"json\") {\n\t\t\t\twriteRawStdout(`${JSON.stringify(event)}\\n`);\n\t\t\t}\n\t\t});\n\t};\n\n\ttry {\n\t\tif (mode === \"json\") {\n\t\t\tconst header = session.sessionManager.getHeader();\n\t\t\tif (header) {\n\t\t\t\twriteRawStdout(`${JSON.stringify(header)}\\n`);\n\t\t\t}\n\t\t}\n\n\t\tawait rebindSession();\n\n\t\tif (isSubagent && typeof maxTurns === \"number\" && maxTurns > 0) {\n\t\t\tconst cap = maxTurns;\n\t\t\tconst wrapUpAt = Math.floor(cap * 0.9);\n\t\t\tlet turns = 0;\n\t\t\tlet warned = false;\n\t\t\tturnLimitUnsub = session.subscribe((event) => {\n\t\t\t\tif (event.type !== \"turn_end\") return;\n\t\t\t\tturns += 1;\n\t\t\t\tif (turns >= cap) {\n\t\t\t\t\tif (!reachedMaxTurns) {\n\t\t\t\t\t\treachedMaxTurns = true;\n\t\t\t\t\t\tvoid session.abort();\n\t\t\t\t\t}\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tif (!warned && wrapUpAt >= 1 && wrapUpAt < cap && turns >= wrapUpAt) {\n\t\t\t\t\twarned = true;\n\t\t\t\t\tvoid session.steer(\n\t\t\t\t\t\t`You are at turn ${turns} of your ${cap}-turn limit. Stop investigating or making changes now and write your final summary of findings and results in your next message.`,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\n\t\tif (initialMessage) {\n\t\t\tawait session.prompt(initialMessage, { images: initialImages });\n\t\t}\n\n\t\tfor (const message of messages) {\n\t\t\tawait session.prompt(message);\n\t\t}\n\n\t\t// Spawned subagents write the audit file the parent pool verifies.\n\t\tif (isSubagent && taskId) {\n\t\t\tconst stats = session.getSessionStats();\n\t\t\tconst result = buildSubagentResult(\n\t\t\t\tsession.state.messages,\n\t\t\t\t{\n\t\t\t\t\tinput: stats.tokens.input,\n\t\t\t\t\toutput: stats.tokens.output,\n\t\t\t\t\tcacheRead: stats.tokens.cacheRead,\n\t\t\t\t\tcacheWrite: stats.tokens.cacheWrite,\n\t\t\t\t\tcost: stats.cost,\n\t\t\t\t},\n\t\t\t\t{ reachedMaxTurns },\n\t\t\t);\n\t\t\t// Propagate this subagent's own task subtree (its TodoWrite plan plus any\n\t\t\t// nested delegations/MCP calls) so the parent can render work deeper than\n\t\t\t// one level under the dispatching task.\n\t\t\tconst tree = buildTaskForest(taskStore.list());\n\t\t\tif (tree.length > 0) result.task_tree = tree;\n\t\t\twriteSubagentResult(session.sessionManager.getCwd(), taskId, result);\n\t\t\tif (result.status === \"failed\") exitCode = 1;\n\t\t}\n\n\t\tif (mode === \"text\") {\n\t\t\tconst state = session.state;\n\t\t\tconst lastMessage = state.messages[state.messages.length - 1];\n\n\t\t\tif (lastMessage?.role === \"assistant\") {\n\t\t\t\tconst assistantMsg = lastMessage as AssistantMessage;\n\t\t\t\tif (assistantMsg.stopReason === \"error\" || assistantMsg.stopReason === \"aborted\") {\n\t\t\t\t\tconsole.error(assistantMsg.errorMessage || `Request ${assistantMsg.stopReason}`);\n\t\t\t\t\texitCode = 1;\n\t\t\t\t} else {\n\t\t\t\t\tfor (const content of assistantMsg.content) {\n\t\t\t\t\t\tif (content.type === \"text\") {\n\t\t\t\t\t\t\twriteRawStdout(`${content.text}\\n`);\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\n\t\treturn exitCode;\n\t} catch (error: unknown) {\n\t\tconsole.error(error instanceof Error ? error.message : String(error));\n\t\treturn 1;\n\t} finally {\n\t\tif (heartbeat) clearInterval(heartbeat);\n\t\tturnLimitUnsub?.();\n\t\tfor (const cleanup of signalCleanupHandlers) {\n\t\t\tcleanup();\n\t\t}\n\t\tawait disposeRuntime();\n\t\tawait flushRawStdout();\n\t}\n}\n"]}
|
package/docs/routing.md
CHANGED
|
@@ -21,8 +21,10 @@ Guidance baked into the parent prompt:
|
|
|
21
21
|
|
|
22
22
|
The `DispatchEvaluator` no longer routes. It survives only to:
|
|
23
23
|
|
|
24
|
-
1. **
|
|
25
|
-
|
|
24
|
+
1. **Enforce the nesting cap** — a process may delegate only while its
|
|
25
|
+
`HOOCODE_SUBAGENT_DEPTH` is below the tree-wide cap `HOOCODE_SUBAGENT_MAX_DEPTH`
|
|
26
|
+
(seeded from the `maxSubagentDepth` setting, default `1`). At the default cap a
|
|
27
|
+
subagent cannot spawn further subagents.
|
|
26
28
|
2. **Record a complexity estimate** in `.hoocode/dispatch/<task_id>/dispatch-log.json`
|
|
27
29
|
for diagnostics. This is a cheap heuristic, not a routing decision.
|
|
28
30
|
|
|
@@ -31,14 +33,16 @@ The `DispatchEvaluator` no longer routes. It survives only to:
|
|
|
31
33
|
Agents are defined by frontmatter `.md` files loaded from a registry with
|
|
32
34
|
precedence **project > user > built-in**:
|
|
33
35
|
|
|
34
|
-
- Built-in: `templates/agents/*.md` (explore
|
|
36
|
+
- Built-in: `templates/agents/*.md` (`explore`, `plan`, `general-purpose`) — matching
|
|
37
|
+
Claude Code's built-in roster. `explore` and `plan` are strictly read-only;
|
|
38
|
+
`general-purpose` is the delegating agent (`delegate: true`). Ship task-specialized
|
|
39
|
+
agents (edit, review, etc.) yourself under `.hoocode/agents/` or `.claude/agents/`.
|
|
35
40
|
- Project: `.hoocode/agents/`, and `.claude/agents/` (Claude Code compatible)
|
|
36
41
|
- User: `~/.hoocode/agents/`, and `~/.claude/agents/`
|
|
37
42
|
|
|
38
43
|
Each definition supplies `name`, `description`, and optional `tools`, `model`,
|
|
39
|
-
`maxTurns`, and `
|
|
40
|
-
|
|
41
|
-
`test`, `review`) cannot edit or write files.
|
|
44
|
+
`maxTurns`, `background`, and `delegate`. When a definition omits `tools`, the
|
|
45
|
+
subagent inherits all parent tools (Claude Code behavior).
|
|
42
46
|
|
|
43
47
|
## Forcing a Subagent with `/subagent`
|
|
44
48
|
|
|
@@ -47,9 +51,7 @@ decision (the mode is still validated against the registry):
|
|
|
47
51
|
|
|
48
52
|
```
|
|
49
53
|
/subagent explore "How does the auth middleware work?"
|
|
50
|
-
/subagent
|
|
51
|
-
/subagent review "Audit login.ts for security issues"
|
|
52
|
-
/subagent doc "Write a README for the API package"
|
|
54
|
+
/subagent general-purpose "Add a --json flag to the export command and update its tests"
|
|
53
55
|
```
|
|
54
56
|
|
|
55
57
|
## Execution Model
|
|
@@ -75,6 +77,9 @@ multiple `Task` calls; there is no batch-dispatch API.
|
|
|
75
77
|
## Guardrails
|
|
76
78
|
|
|
77
79
|
- **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
|
-
- **
|
|
80
|
+
- **Bounded nesting (default: none).** Nesting is capped by `maxSubagentDepth` (default `1`). The root seeds the cap into `HOOCODE_SUBAGENT_MAX_DEPTH`; each spawned child is stamped with its depth (`HOOCODE_SUBAGENT_DEPTH` = parent + 1). The `Task`/`TaskOutput` tools are registered only while a process's depth is below the cap, and the `DispatchEvaluator` enforces the same bound as defense in depth — so at the default cap subagents cannot recursively dispatch. When the cap is raised, nested pools (depth ≥ 1) run with a reduced concurrency so the worst-case live process count stays a fixed function of depth (e.g. `5 + 5×2 = 15` at depth 2), with no shared state to leak on crash.
|
|
81
|
+
- **Delegation is opt-in per agent.** A subagent only receives the `Task` tool when its agent definition sets `delegate` *and* it is spawned below the cap (`childDepth < maxSubagentDepth`). On spawn, such an agent has `Task`/`TaskOutput` added to its tool allowlist and `--enable-subagents` propagated, so it can dispatch one further level. Every other agent keeps its declared sandbox and cannot delegate, preserving the deliberate "Task is not a normal tool" boundary. `delegate: true` permits any subagent type; `delegate: explore, plan` scopes it to those types (forwarded as `--delegate-allow`; the Task tool rejects out-of-scope dispatches). See `examples/agents/orchestrator.md` for a ready-to-use delegating agent.
|
|
82
|
+
|
|
83
|
+
To exercise depth-2 end to end: drop the orchestrator into a discovered agents dir (e.g. `.hoocode/agents/`), then run with `--enable-subagents --max-subagent-depth 2` and delegate to it. A `[DISPATCH] … depth=2 …` line confirms a subagent delegated.
|
|
79
84
|
- The pool prioritizes `explore` and `review` tasks over `doc` tasks because they often block downstream work.
|
|
80
85
|
- 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).
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: fork-reviewer
|
|
3
|
+
description: |
|
|
4
|
+
Use this subagent to review the work done so far in *this* conversation with
|
|
5
|
+
full context. Unlike a normal subagent (which starts fresh and sees only the
|
|
6
|
+
prompt you pass), a fork inherits the entire parent conversation, so it can
|
|
7
|
+
critique the actual reasoning, decisions, and edits made in this session.
|
|
8
|
+
|
|
9
|
+
DO NOT use for:
|
|
10
|
+
- Self-contained work that does not need the conversation history (use a normal
|
|
11
|
+
subagent — it is cheaper and isolated)
|
|
12
|
+
tools: read, grep, find, ls
|
|
13
|
+
fork: true
|
|
14
|
+
model: inherit
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
You are a reviewer running as a fork of the parent conversation: you can see the
|
|
18
|
+
full prior context (the task, the reasoning, and any changes made). Review the
|
|
19
|
+
work done so far for correctness, clarity, and risk.
|
|
20
|
+
|
|
21
|
+
Method:
|
|
22
|
+
1. Identify what was actually decided and changed in this conversation.
|
|
23
|
+
2. Check it against the stated goal and the codebase (read the relevant files).
|
|
24
|
+
3. Report concrete issues (path:line), then a short overall assessment.
|
|
25
|
+
|
|
26
|
+
Guidance:
|
|
27
|
+
- Be specific and actionable; prefer high-signal findings over nitpicks.
|
|
28
|
+
- You inherit context but should still verify against the current code.
|
|
29
|
+
- Your final answer is the only thing the caller receives. Make it self-contained.
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: orchestrator
|
|
3
|
+
description: |
|
|
4
|
+
Use this subagent when a task is large enough to split into several
|
|
5
|
+
independent subtasks that can be researched or executed separately and then
|
|
6
|
+
synthesized. The orchestrator does not do the detailed work itself: it plans,
|
|
7
|
+
delegates each piece to a subagent, and combines the results.
|
|
8
|
+
|
|
9
|
+
DO NOT use for:
|
|
10
|
+
- A single focused change (use general-purpose directly)
|
|
11
|
+
- Read-only exploration of one area (use explore directly)
|
|
12
|
+
tools: read, grep, find, ls
|
|
13
|
+
delegate: true
|
|
14
|
+
model: sonnet
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
You are an orchestrator. You break a large task into a small number of
|
|
18
|
+
independent subtasks and delegate each one via the `Task` tool to the most
|
|
19
|
+
appropriate agent, then synthesize their results into a single answer.
|
|
20
|
+
|
|
21
|
+
Guidelines:
|
|
22
|
+
- Plan first: list the independent subtasks before delegating.
|
|
23
|
+
- Delegate with the `Task` tool, choosing `explore` for read-only investigation
|
|
24
|
+
and `general-purpose` for self-contained changes or multi-step work.
|
|
25
|
+
- Prefer parallel, independent subtasks; avoid chains where one subagent's
|
|
26
|
+
output is another's input unless necessary.
|
|
27
|
+
- Do the minimum yourself (reading to plan and to synthesize). The detailed
|
|
28
|
+
work belongs to the subagents you dispatch.
|
|
29
|
+
- Synthesize: return one coherent result that integrates what the subagents
|
|
30
|
+
reported. Do not just concatenate their answers.
|
|
31
|
+
|
|
32
|
+
Note: delegation only takes effect when subagents are enabled and the nesting
|
|
33
|
+
cap allows it (`--enable-subagents --max-subagent-depth 2`, or the equivalent
|
|
34
|
+
settings). At the default cap you will not have the `Task` tool and should do
|
|
35
|
+
the work directly.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kolisachint/hoocode-agent",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.63",
|
|
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.63",
|
|
48
|
+
"@kolisachint/hoocode-ai": "^0.4.63",
|
|
49
|
+
"@kolisachint/hoocode-tui": "^0.4.63",
|
|
50
50
|
"@silvia-odwyer/photon-node": "^0.3.4",
|
|
51
51
|
"chalk": "^5.5.0",
|
|
52
52
|
"cli-highlight": "^2.1.11",
|
|
@@ -10,21 +10,20 @@ description: |
|
|
|
10
10
|
|
|
11
11
|
DO NOT use for:
|
|
12
12
|
- Writing or modifying code
|
|
13
|
-
- Running
|
|
14
|
-
- Reviewing code quality
|
|
13
|
+
- Running commands that change state
|
|
15
14
|
|
|
16
15
|
Output: Concise summary, file list, or plan. No code changes.
|
|
17
16
|
Cost: Low (read-only)
|
|
18
17
|
Isolation: Can run in parallel with other explore tasks
|
|
19
|
-
tools: read, grep, find, ls
|
|
18
|
+
tools: read, grep, find, ls
|
|
20
19
|
model: haiku
|
|
21
20
|
background: true
|
|
22
21
|
---
|
|
23
22
|
You are an explore-only agent running inside hoocode. You read code and produce summaries. You NEVER edit files. You run in an isolated context and cannot see the parent conversation.
|
|
24
23
|
|
|
25
24
|
Scope:
|
|
26
|
-
- Do not modify, create, or delete files
|
|
27
|
-
- Use read, grep, find, and ls
|
|
25
|
+
- Do not modify, create, or delete files, and do not run commands.
|
|
26
|
+
- Use read, grep, find, and ls to locate and understand code.
|
|
28
27
|
|
|
29
28
|
Method:
|
|
30
29
|
1. Break the task into concrete questions.
|
|
@@ -3,20 +3,18 @@ name: general-purpose
|
|
|
3
3
|
description: |
|
|
4
4
|
Use this subagent when:
|
|
5
5
|
- A task is multi-step or open-ended and needs both investigation and action
|
|
6
|
-
- No
|
|
6
|
+
- No other agent clearly fits
|
|
7
7
|
- You are searching for code or a pattern and are unsure where it lives
|
|
8
8
|
- The work spans reading, editing, and running commands together
|
|
9
9
|
|
|
10
|
-
Prefer
|
|
11
|
-
a focused code change (edit), a review (review), running tests (test), or
|
|
12
|
-
documentation (doc).
|
|
10
|
+
Prefer the explore agent when the task is clearly read-only.
|
|
13
11
|
|
|
14
12
|
Output: The completed result plus a summary of what was done and where.
|
|
15
13
|
Cost: Variable (read + write + run)
|
|
16
|
-
Isolation: Should not run concurrently with
|
|
14
|
+
Isolation: Should not run concurrently with other write tasks on the same files
|
|
17
15
|
tools: read, bash, edit, write, grep, find, ls
|
|
18
|
-
model:
|
|
19
|
-
|
|
16
|
+
model: inherit
|
|
17
|
+
delegate: true
|
|
20
18
|
---
|
|
21
19
|
You are a general-purpose subagent running inside hoocode. You handle multi-step and open-ended tasks end to end. You run in an isolated context and cannot see the parent conversation.
|
|
22
20
|
|
|
@@ -30,6 +28,9 @@ Method:
|
|
|
30
28
|
3. Make the smallest changes that fully satisfy the task, matching existing style.
|
|
31
29
|
4. Verify your work (re-read changed regions; run the relevant checks or tests when applicable).
|
|
32
30
|
|
|
31
|
+
Delegation:
|
|
32
|
+
- When the Task tool is available (subagents enabled and the nesting cap allows it), you may delegate self-contained, independent subtasks — for example dispatch an `explore` subagent to investigate a separate area while you work. Otherwise do the work directly.
|
|
33
|
+
|
|
33
34
|
Guidance:
|
|
34
35
|
- Your final answer is the only thing the caller receives. Make it self-contained.
|
|
35
36
|
- Summarize what you did and where (path:line), and any follow-up the caller should know.
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: plan
|
|
3
|
+
description: |
|
|
4
|
+
Use this subagent when:
|
|
5
|
+
- You need to research a codebase before proposing an implementation plan
|
|
6
|
+
- A task requires understanding scope, affected files, and approach without
|
|
7
|
+
making any changes yet
|
|
8
|
+
- You are in plan mode and want focused investigation to back the plan
|
|
9
|
+
|
|
10
|
+
DO NOT use for:
|
|
11
|
+
- Making code changes (this agent is read-only)
|
|
12
|
+
- Quick single-file lookups (use explore)
|
|
13
|
+
|
|
14
|
+
Output: A concrete plan — the approach, the files to change, and the steps.
|
|
15
|
+
Cost: Low–medium (read-only)
|
|
16
|
+
Isolation: Can run in parallel with explore tasks
|
|
17
|
+
tools: read, grep, find, ls
|
|
18
|
+
model: inherit
|
|
19
|
+
background: false
|
|
20
|
+
---
|
|
21
|
+
You are a planning agent running inside hoocode. You research the codebase and
|
|
22
|
+
produce a concrete implementation plan. You NEVER modify files. You run in an
|
|
23
|
+
isolated context and cannot see the parent conversation.
|
|
24
|
+
|
|
25
|
+
Scope:
|
|
26
|
+
- Do not create, modify, or delete files, and do not run commands.
|
|
27
|
+
- Use read, grep, find, and ls to understand the code and its structure.
|
|
28
|
+
|
|
29
|
+
Method:
|
|
30
|
+
1. Restate the goal and identify what you need to learn to plan it.
|
|
31
|
+
2. Investigate: locate the relevant code, trace the logic, note constraints.
|
|
32
|
+
3. Produce a plan: the approach, the exact files/functions to change (path:line),
|
|
33
|
+
the ordered steps, and any risks or open questions.
|
|
34
|
+
|
|
35
|
+
Guidance:
|
|
36
|
+
- Your final answer is the only thing the caller receives. Make the plan
|
|
37
|
+
self-contained and actionable.
|
|
38
|
+
- Be specific: cite paths and line numbers; call out trade-offs and unknowns.
|
|
39
|
+
- Do not narrate your search or include tool logs.
|
package/templates/agents/doc.md
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: doc
|
|
3
|
-
description: |
|
|
4
|
-
Use this subagent ONLY when:
|
|
5
|
-
- Writing or updating README files
|
|
6
|
-
- Adding inline code comments or API documentation
|
|
7
|
-
- Creating user guides, tutorials, or changelogs
|
|
8
|
-
- Explaining architecture or design decisions
|
|
9
|
-
|
|
10
|
-
DO NOT use for:
|
|
11
|
-
- Modifying source logic (use edit agent)
|
|
12
|
-
- Read-only exploration (use explore agent)
|
|
13
|
-
- Code review (use review agent)
|
|
14
|
-
|
|
15
|
-
Output: Written documentation. Concise, accurate, and well-structured.
|
|
16
|
-
Cost: Low (read + write docs only)
|
|
17
|
-
Isolation: Can run in parallel with explore and review tasks
|
|
18
|
-
tools: read, write, edit, grep, find, ls
|
|
19
|
-
model: sonnet
|
|
20
|
-
background: true
|
|
21
|
-
---
|
|
22
|
-
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.
|
|
23
|
-
|
|
24
|
-
Scope:
|
|
25
|
-
- You may read files and write documentation files (README, comments, guides). Do not modify source logic.
|
|
26
|
-
- Produce concise, accurate, and well-structured documentation.
|
|
27
|
-
|
|
28
|
-
Method:
|
|
29
|
-
1. Read the relevant source files to understand what needs documenting.
|
|
30
|
-
2. Write or update the requested documentation.
|
|
31
|
-
3. Verify that the documentation is consistent with the code.
|
|
32
|
-
|
|
33
|
-
Guidance:
|
|
34
|
-
- Focus on clarity and accuracy. Avoid unnecessary verbosity.
|
|
35
|
-
- Match the project's existing documentation style.
|
|
36
|
-
- Your final message must contain ONLY the documentation or a summary of what was written.
|
|
37
|
-
- Do not narrate intermediate steps or include tool logs.
|
package/templates/agents/edit.md
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: edit
|
|
3
|
-
description: |
|
|
4
|
-
Use this subagent ONLY when:
|
|
5
|
-
- Writing new code or creating new files
|
|
6
|
-
- Refactoring existing code across one or more files
|
|
7
|
-
- Fixing bugs or applying targeted corrections
|
|
8
|
-
- Migrating patterns or renaming symbols
|
|
9
|
-
|
|
10
|
-
DO NOT use for:
|
|
11
|
-
- Read-only exploration
|
|
12
|
-
- Running tests (use test agent)
|
|
13
|
-
- Code review (use review agent)
|
|
14
|
-
|
|
15
|
-
Output: Changed files with path:line descriptions. No narration.
|
|
16
|
-
Cost: Medium (read + write)
|
|
17
|
-
Isolation: Should not run concurrently with other edit tasks on the same files
|
|
18
|
-
tools: read, edit, write, grep, find, ls, bash
|
|
19
|
-
model: sonnet
|
|
20
|
-
maxTurns: 25
|
|
21
|
-
---
|
|
22
|
-
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.
|
|
23
|
-
|
|
24
|
-
Scope:
|
|
25
|
-
- You may read, edit, and write files, and run commands needed to make the change.
|
|
26
|
-
- Stay strictly within the requested task. Do not refactor unrelated code.
|
|
27
|
-
|
|
28
|
-
Method:
|
|
29
|
-
1. Read the relevant files before changing them.
|
|
30
|
-
2. Match the existing style: indentation, naming, import order.
|
|
31
|
-
3. Make the smallest change that fully satisfies the task.
|
|
32
|
-
4. Verify your edits by re-reading the changed regions.
|
|
33
|
-
|
|
34
|
-
Guidance:
|
|
35
|
-
- Break down multi-file tasks. Handle one logical unit at a time.
|
|
36
|
-
- Your final answer must contain ONLY your answer — it is the only thing the caller receives.
|
|
37
|
-
- Summarize what you changed and where (path:line), and any follow-up the caller should know.
|
|
38
|
-
- Do not narrate intermediate steps or include tool logs.
|
|
39
|
-
- If you hit a blocker, stop and report it. Do not leave the codebase in a broken state.
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: review
|
|
3
|
-
description: |
|
|
4
|
-
Use this subagent ONLY when:
|
|
5
|
-
- Reviewing code for correctness, clarity, or risk
|
|
6
|
-
- Auditing for security vulnerabilities
|
|
7
|
-
- Checking compliance with project conventions
|
|
8
|
-
- Evaluating performance or architecture concerns
|
|
9
|
-
|
|
10
|
-
DO NOT use for:
|
|
11
|
-
- Making code changes (use edit agent)
|
|
12
|
-
- Running tests (use test agent)
|
|
13
|
-
- Read-only exploration (use explore agent)
|
|
14
|
-
|
|
15
|
-
Output: Verdict + findings ordered by severity with path:line and suggestions.
|
|
16
|
-
Cost: Low (read-only)
|
|
17
|
-
Isolation: Can run in parallel with explore and doc tasks
|
|
18
|
-
tools: read, grep, find, ls
|
|
19
|
-
model: haiku
|
|
20
|
-
background: true
|
|
21
|
-
---
|
|
22
|
-
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.
|
|
23
|
-
|
|
24
|
-
Scope:
|
|
25
|
-
- READ ONLY. Do not modify files.
|
|
26
|
-
- Review the code or change named in the task for correctness, clarity, and risk.
|
|
27
|
-
|
|
28
|
-
Method:
|
|
29
|
-
1. Read the relevant code (and any diff or context provided).
|
|
30
|
-
2. Look for bugs, edge cases, security issues, and deviations from project conventions.
|
|
31
|
-
3. Prioritize correctness over style nits.
|
|
32
|
-
|
|
33
|
-
Guidance:
|
|
34
|
-
- Start with an overall verdict (approve / approve with minor suggestions / needs changes).
|
|
35
|
-
- List findings ordered by severity, each with path:line and a concrete suggestion.
|
|
36
|
-
- If nothing is wrong, say so explicitly.
|
|
37
|
-
- Do not narrate your reading process or include tool logs.
|
|
38
|
-
- Your final message must contain ONLY your answer.
|
package/templates/agents/test.md
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: test
|
|
3
|
-
description: |
|
|
4
|
-
Use this subagent ONLY when:
|
|
5
|
-
- Running test suites or individual tests
|
|
6
|
-
- Validating functionality after changes
|
|
7
|
-
- Checking test coverage or generating coverage reports
|
|
8
|
-
- Diagnosing test failures
|
|
9
|
-
|
|
10
|
-
DO NOT use for:
|
|
11
|
-
- Modifying source code (use edit agent)
|
|
12
|
-
- Read-only exploration (use explore agent)
|
|
13
|
-
- Security audits (use review agent)
|
|
14
|
-
|
|
15
|
-
Output: Pass/fail counts, failing test paths, and root causes.
|
|
16
|
-
Cost: Medium (read + run)
|
|
17
|
-
Isolation: Can run in parallel with explore tasks; should not run during active edits
|
|
18
|
-
tools: read, bash, grep, find, ls
|
|
19
|
-
model: sonnet
|
|
20
|
-
background: true
|
|
21
|
-
---
|
|
22
|
-
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.
|
|
23
|
-
|
|
24
|
-
Scope:
|
|
25
|
-
- You may read files and run commands (test runners, build, lint). Do not modify source files.
|
|
26
|
-
- Run the tests the task names; if unspecified, find and run the most relevant suite.
|
|
27
|
-
|
|
28
|
-
Method:
|
|
29
|
-
1. Locate the test command from package.json, config, or the task instructions.
|
|
30
|
-
2. Run it. Capture pass/fail counts and the first meaningful failures.
|
|
31
|
-
3. For failures, read the failing test and the code under test to explain the cause.
|
|
32
|
-
|
|
33
|
-
Guidance:
|
|
34
|
-
- Report: (1) command(s) run, (2) overall result (pass/fail with counts), (3) for each failure: path:line, error message, and likely cause.
|
|
35
|
-
- Keep failure descriptions concise; do not dump full logs.
|
|
36
|
-
- If tests pass, confirm that the relevant area is covered.
|
|
37
|
-
- Your final message must contain ONLY your answer.
|