@kolisachint/hoocode-agent 0.4.9 → 0.4.10
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 +2 -0
- package/dist/core/dispatch-evaluator.d.ts +31 -0
- package/dist/core/dispatch-evaluator.d.ts.map +1 -0
- package/dist/core/dispatch-evaluator.js +300 -0
- package/dist/core/dispatch-evaluator.js.map +1 -0
- package/dist/core/slash-commands.d.ts.map +1 -1
- package/dist/core/slash-commands.js +1 -0
- package/dist/core/slash-commands.js.map +1 -1
- package/dist/core/subagent-pool.d.ts +35 -0
- package/dist/core/subagent-pool.d.ts.map +1 -1
- package/dist/core/subagent-pool.js +147 -7
- package/dist/core/subagent-pool.js.map +1 -1
- package/dist/core/subagent.d.ts +9 -1
- package/dist/core/subagent.d.ts.map +1 -1
- package/dist/core/subagent.js +23 -2
- package/dist/core/subagent.js.map +1 -1
- package/dist/core/task-store.d.ts +9 -1
- package/dist/core/task-store.d.ts.map +1 -1
- package/dist/core/task-store.js +2 -0
- package/dist/core/task-store.js.map +1 -1
- package/dist/core/tools/subagent.d.ts +5 -1
- package/dist/core/tools/subagent.d.ts.map +1 -1
- package/dist/core/tools/subagent.js +49 -8
- package/dist/core/tools/subagent.js.map +1 -1
- package/dist/init-templates.generated.d.ts +1 -0
- package/dist/init-templates.generated.d.ts.map +1 -1
- package/dist/init-templates.generated.js +8 -0
- package/dist/init-templates.generated.js.map +1 -1
- package/dist/modes/interactive/components/assistant-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/assistant-message.js +2 -2
- package/dist/modes/interactive/components/assistant-message.js.map +1 -1
- package/dist/modes/interactive/components/bash-execution.d.ts.map +1 -1
- package/dist/modes/interactive/components/bash-execution.js +9 -14
- package/dist/modes/interactive/components/bash-execution.js.map +1 -1
- package/dist/modes/interactive/components/config-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/config-selector.js +1 -6
- package/dist/modes/interactive/components/config-selector.js.map +1 -1
- package/dist/modes/interactive/components/model-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/model-selector.js +1 -5
- package/dist/modes/interactive/components/model-selector.js.map +1 -1
- package/dist/modes/interactive/components/task-panel.d.ts +4 -2
- package/dist/modes/interactive/components/task-panel.d.ts.map +1 -1
- package/dist/modes/interactive/components/task-panel.js +69 -6
- package/dist/modes/interactive/components/task-panel.js.map +1 -1
- package/dist/modes/interactive/components/tool-execution.d.ts.map +1 -1
- package/dist/modes/interactive/components/tool-execution.js +12 -10
- package/dist/modes/interactive/components/tool-execution.js.map +1 -1
- package/dist/modes/interactive/interactive-mode.d.ts +1 -0
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode.js +59 -0
- package/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/dist/modes/interactive/theme/dark.json +5 -5
- package/dist/modes/interactive/theme/light.json +5 -5
- package/docs/routing.md +57 -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/doc.md +35 -0
- package/templates/agents/edit.md +37 -0
- package/templates/agents/explore.md +35 -0
- package/templates/agents/review.md +36 -0
- package/templates/agents/test.md +35 -0
- package/templates/subagent/doc.md +16 -0
package/dist/core/task-store.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"task-store.js","sourceRoot":"","sources":["../../src/core/task-store.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;
|
|
1
|
+
{"version":3,"file":"task-store.js","sourceRoot":"","sources":["../../src/core/task-store.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AA8BH,MAAM,SAAS;IACN,KAAK,GAAW,EAAE,CAAC;IACnB,MAAM,GAAG,CAAC,CAAC;IACF,SAAS,GAAG,IAAI,GAAG,EAAY,CAAC;IAEjD,M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AAED,uCAAuC;AACvC,MAAM,CAAC,MAAM,SAAS,GAAG,IAAI,SAAS,EAAE,CAAC","sourcesContent":["/**\n * Minimal in-process task store.\n *\n * Tracks short-lived tasks (e.g. subagent delegations) so the TUI task panel can\n * display active work. It is a process-level singleton because the tool that\n * creates tasks and the footer that renders them live in the same process and\n * there is no cross-process boundary to cross.\n */\n\nexport type TaskStatus = \"pending\" | \"in_progress\" | \"done\" | \"failed\";\n\nexport interface Task {\n\treadonly id: number;\n\ttitle: string;\n\tstatus: TaskStatus;\n\t/** Subagent mode when this task is owned by a subagent (e.g. \"explore\"). */\n\tsubagentMode?: string;\n\treadonly createdAt: number;\n\tupdatedAt: number;\n\t/** Token and cost usage attributed to this task (e.g. from a subagent session). */\n\tusage?: {\n\t\tinput: number;\n\t\toutput: number;\n\t\tcacheRead: number;\n\t\tcacheWrite: number;\n\t\tcost: number;\n\t};\n}\n\nexport interface CreateTaskOptions {\n\tsubagentMode?: string;\n}\n\nexport type TaskPatch = Partial<Pick<Task, \"title\" | \"status\" | \"subagentMode\" | \"usage\">>;\n\ntype Listener = () => void;\n\nclass TaskStore {\n\tprivate tasks: Task[] = [];\n\tprivate nextId = 1;\n\tprivate readonly listeners = new Set<Listener>();\n\n\tcreate(title: string, options: CreateTaskOptions = {}): Task {\n\t\tconst now = Date.now();\n\t\tconst task: Task = {\n\t\t\tid: this.nextId++,\n\t\t\ttitle: title.trim() || \"(untitled task)\",\n\t\t\tstatus: \"pending\",\n\t\t\tsubagentMode: options.subagentMode,\n\t\t\tcreatedAt: now,\n\t\t\tupdatedAt: now,\n\t\t};\n\t\tthis.tasks.push(task);\n\t\tthis.emit();\n\t\treturn task;\n\t}\n\n\tupdate(id: number, patch: TaskPatch): void {\n\t\tconst task = this.tasks.find((t) => t.id === id);\n\t\tif (!task) return;\n\t\tif (patch.title !== undefined) task.title = patch.title;\n\t\tif (patch.status !== undefined) task.status = patch.status;\n\t\tif (patch.subagentMode !== undefined) task.subagentMode = patch.subagentMode;\n\t\tif (patch.usage !== undefined) task.usage = patch.usage;\n\t\ttask.updatedAt = Date.now();\n\t\tthis.emit();\n\t}\n\n\tremove(id: number): void {\n\t\tconst idx = this.tasks.findIndex((t) => t.id === id);\n\t\tif (idx === -1) return;\n\t\tthis.tasks.splice(idx, 1);\n\t\tthis.emit();\n\t}\n\n\t/**\n\t * Remove all finished tasks (done or failed), keeping pending/in_progress ones.\n\t *\n\t * Called when the main agent moves on after a parallel subagent spawn: finished\n\t * tasks stay visible (with their final status) until that point, then retire.\n\t */\n\tretireFinished(): void {\n\t\tconst before = this.tasks.length;\n\t\tthis.tasks = this.tasks.filter((t) => t.status !== \"done\" && t.status !== \"failed\");\n\t\tif (this.tasks.length !== before) this.emit();\n\t}\n\n\tlist(): readonly Task[] {\n\t\treturn this.tasks;\n\t}\n\n\tsubscribe(listener: Listener): () => void {\n\t\tthis.listeners.add(listener);\n\t\treturn () => {\n\t\t\tthis.listeners.delete(listener);\n\t\t};\n\t}\n\n\t/** Clear all tasks. Intended for test isolation only. */\n\tclear(): void {\n\t\tthis.tasks = [];\n\t\tthis.nextId = 1;\n\t\tthis.emit();\n\t}\n\n\tprivate emit(): void {\n\t\tfor (const listener of this.listeners) {\n\t\t\tlistener();\n\t\t}\n\t}\n}\n\n/** Shared, process-wide task store. */\nexport const taskStore = new TaskStore();\n"]}
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
*/
|
|
9
9
|
/** System prompt appendix for the main session when subagent tooling is enabled.
|
|
10
10
|
* Instructs the parent agent on when and how to delegate effectively. */
|
|
11
|
-
export declare const SUBAGENT_MAIN_PROMPT = "You have access to the **subagent** tool. Use it to delegate self-contained tasks to isolated subagent loops that run with their own context and return only their final answer.\n\nAvailable subagent modes:\n- explore: read-only investigation (read, grep, find, ls, bash).\n- edit: make a focused code change (read, edit, write, grep, find, ls, bash).\n- test: run tests and report (read, bash, grep, find, ls).\n- fix: diagnose and fix a failure (read, edit, write, bash, grep, find, ls).\n- review: read-only code review (read, grep, find, ls, bash).\n\nWhen to delegate:\n1. The work is self-contained and you only need the final result, not intermediate steps.\n2. You want to investigate or edit something in parallel without losing your current context or reasoning chain.\n3. The task is a discrete unit (explore one module, run one test file, review one PR, fix one isolated bug).\n4. You need to run a long command or test suite and wait for its output without blocking your own reasoning.\n\nGuidelines:\n- Make every task specific and self-contained. The subagent cannot see this conversation.\n- Pass all necessary context (files, constraints, prior findings) via the `context` parameter.\n- Do NOT delegate tasks that require tight back-and-forth with your current reasoning.\n- Do NOT delegate edits to files you are actively reasoning about.\n- The subagent returns ONLY its final answer. Intermediate reasoning, tool calls, and output are hidden from you.";
|
|
11
|
+
export declare const SUBAGENT_MAIN_PROMPT = "You have access to the **subagent** tool. Use it to delegate self-contained tasks to isolated subagent loops that run with their own context and return only their final answer.\n\nAvailable subagent modes:\n- explore: read-only investigation (read, grep, find, ls, bash).\n- edit: make a focused code change (read, edit, write, grep, find, ls, bash).\n- test: run tests and report (read, bash, grep, find, ls).\n- fix: diagnose and fix a failure (read, edit, write, bash, grep, find, ls).\n- review: read-only code review (read, grep, find, ls, bash).\n- doc: write documentation, README, or comments (read, write, edit, grep, find, ls, bash).\n\nWhen to delegate:\n1. The work is self-contained and you only need the final result, not intermediate steps.\n2. You want to investigate or edit something in parallel without losing your current context or reasoning chain.\n3. The task is a discrete unit (explore one module, run one test file, review one PR, fix one isolated bug).\n4. You need to run a long command or test suite and wait for its output without blocking your own reasoning.\n\nGuidelines:\n- Make every task specific and self-contained. The subagent cannot see this conversation.\n- Pass all necessary context (files, constraints, prior findings) via the `context` parameter.\n- Do NOT delegate tasks that require tight back-and-forth with your current reasoning.\n- Do NOT delegate edits to files you are actively reasoning about.\n- The subagent returns ONLY its final answer. Intermediate reasoning, tool calls, and output are hidden from you.\n\nDispatch evaluator:\n- The dispatch evaluator determines if a subagent is needed. Do not spawn subagents directly unless the user explicitly requests it.\n- For simple single-file changes (<50 lines, read-only or trivial edit), handle them inline.\n- Use force=true to bypass evaluation when you are certain a subagent is required.";
|
|
12
12
|
import type { ToolDefinition } from "../extensions/types.js";
|
|
13
13
|
import { type SubagentMode } from "../subagent.js";
|
|
14
14
|
export interface SubagentToolDetails {
|
|
@@ -16,7 +16,11 @@ export interface SubagentToolDetails {
|
|
|
16
16
|
ok: boolean;
|
|
17
17
|
error?: string;
|
|
18
18
|
taskId: number;
|
|
19
|
+
/** True when the evaluator handled the task inline instead of delegating. */
|
|
20
|
+
inline?: boolean;
|
|
19
21
|
}
|
|
22
|
+
/** Quick check: should this task go to a subagent? */
|
|
23
|
+
export declare function isSubagentRecommended(task: string): boolean;
|
|
20
24
|
/** Create the subagent tool definition. Registered as a customTool when enabled. */
|
|
21
25
|
export declare function createSubagentToolDefinition(): ToolDefinition;
|
|
22
26
|
//# sourceMappingURL=subagent.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"subagent.d.ts","sourceRoot":"","sources":["../../../src/core/tools/subagent.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH;0EAC0E;AAC1E,eAAO,MAAM,oBAAoB,
|
|
1
|
+
{"version":3,"file":"subagent.d.ts","sourceRoot":"","sources":["../../../src/core/tools/subagent.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH;0EAC0E;AAC1E,eAAO,MAAM,oBAAoB,82DA0BkD,CAAC;AAKpF,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAE7D,OAAO,EAAe,KAAK,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAmChE,MAAM,WAAW,mBAAmB;IACnC,IAAI,EAAE,YAAY,CAAC;IACnB,EAAE,EAAE,OAAO,CAAC;IACZ,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,6EAA6E;IAC7E,MAAM,CAAC,EAAE,OAAO,CAAC;CACjB;AAQD,sDAAsD;AACtD,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAG3D;AAOD,oFAAoF;AACpF,wBAAgB,4BAA4B,IAAI,cAAc,CAuF7D","sourcesContent":["/**\n * Subagent tool: delegate a focused task to a fresh, isolated agent loop.\n *\n * The tool registers a task in the shared task store (visible in the task panel),\n * runs the subagent to completion, and returns ONLY the subagent's final\n * answer. It is an optional, opt-in tool (enabled via --subagent or the\n * `enableSubagent` setting); see buildSessionOptions in main.ts.\n */\n\n/** System prompt appendix for the main session when subagent tooling is enabled.\n * Instructs the parent agent on when and how to delegate effectively. */\nexport const SUBAGENT_MAIN_PROMPT = `You have access to the **subagent** tool. Use it to delegate self-contained tasks to isolated subagent loops that run with their own context and return only their final answer.\n\nAvailable subagent modes:\n- explore: read-only investigation (read, grep, find, ls, bash).\n- edit: make a focused code change (read, edit, write, grep, find, ls, bash).\n- test: run tests and report (read, bash, grep, find, ls).\n- fix: diagnose and fix a failure (read, edit, write, bash, grep, find, ls).\n- review: read-only code review (read, grep, find, ls, bash).\n- doc: write documentation, README, or comments (read, write, edit, grep, find, ls, bash).\n\nWhen to delegate:\n1. The work is self-contained and you only need the final result, not intermediate steps.\n2. You want to investigate or edit something in parallel without losing your current context or reasoning chain.\n3. The task is a discrete unit (explore one module, run one test file, review one PR, fix one isolated bug).\n4. You need to run a long command or test suite and wait for its output without blocking your own reasoning.\n\nGuidelines:\n- Make every task specific and self-contained. The subagent cannot see this conversation.\n- Pass all necessary context (files, constraints, prior findings) via the \\`context\\` parameter.\n- Do NOT delegate tasks that require tight back-and-forth with your current reasoning.\n- Do NOT delegate edits to files you are actively reasoning about.\n- The subagent returns ONLY its final answer. Intermediate reasoning, tool calls, and output are hidden from you.\n\nDispatch evaluator:\n- The dispatch evaluator determines if a subagent is needed. Do not spawn subagents directly unless the user explicitly requests it.\n- For simple single-file changes (<50 lines, read-only or trivial edit), handle them inline.\n- Use force=true to bypass evaluation when you are certain a subagent is required.`;\n\nimport { Text } from \"@kolisachint/hoocode-tui\";\nimport { type Static, Type } from \"typebox\";\nimport { type AgentType, DispatchEvaluator } from \"../dispatch-evaluator.js\";\nimport type { ToolDefinition } from \"../extensions/types.js\";\nimport { defineTool } from \"../extensions/types.js\";\nimport { runSubagent, type SubagentMode } from \"../subagent.js\";\nimport { taskStore } from \"../task-store.js\";\n\nconst subagentParams = Type.Object({\n\ttask: Type.String({\n\t\tdescription:\n\t\t\t\"The task to delegate. Make it specific and self-contained; the subagent cannot see this conversation.\",\n\t}),\n\tcontext: Type.String({\n\t\tdescription:\n\t\t\t'Context distilled from the conversation the subagent needs (files, constraints, prior findings). Pass \"\" if none.',\n\t}),\n\tmode: Type.Union(\n\t\t[\n\t\t\tType.Literal(\"explore\"),\n\t\t\tType.Literal(\"edit\"),\n\t\t\tType.Literal(\"test\"),\n\t\t\tType.Literal(\"fix\"),\n\t\t\tType.Literal(\"review\"),\n\t\t\tType.Literal(\"doc\"),\n\t\t],\n\t\t{\n\t\t\tdescription:\n\t\t\t\t\"explore: read-only investigation. edit: make a focused code change. test: run tests and report. fix: diagnose and fix a failure. review: read-only code review. doc: write documentation.\",\n\t\t},\n\t),\n\tforce: Type.Boolean({\n\t\tdescription:\n\t\t\t\"Bypass dispatch evaluation and spawn the subagent directly. Use when you are certain a subagent is required.\",\n\t\tdefault: false,\n\t}),\n});\n\ntype SubagentParams = Static<typeof subagentParams>;\n\nexport interface SubagentToolDetails {\n\tmode: SubagentMode;\n\tok: boolean;\n\terror?: string;\n\ttaskId: number;\n\t/** True when the evaluator handled the task inline instead of delegating. */\n\tinline?: boolean;\n}\n\n/** First line of the task, trimmed to a short summary for the task list/footer. */\nfunction summarize(task: string): string {\n\tconst firstLine = task.trim().split(\"\\n\")[0] ?? \"\";\n\treturn firstLine.length > 60 ? `${firstLine.slice(0, 57)}...` : firstLine || \"(task)\";\n}\n\n/** Quick check: should this task go to a subagent? */\nexport function isSubagentRecommended(task: string): boolean {\n\tconst evaluator = new DispatchEvaluator();\n\treturn evaluator.evaluate(task).should_delegate;\n}\n\n/** Map evaluator AgentType to SubagentMode (they are compatible strings). */\nfunction toSubagentMode(agentType: AgentType | null): SubagentMode {\n\treturn (agentType as SubagentMode) ?? \"explore\";\n}\n\n/** Create the subagent tool definition. Registered as a customTool when enabled. */\nexport function createSubagentToolDefinition(): ToolDefinition {\n\treturn defineTool<typeof subagentParams, SubagentToolDetails>({\n\t\tname: \"subagent\",\n\t\tlabel: \"Subagent\",\n\t\tdescription: [\n\t\t\t\"Delegate a focused task to a subagent that runs in a fresh, isolated context (it cannot see this conversation).\",\n\t\t\t\"Pass everything it needs via `context`. The subagent returns only its final answer.\",\n\t\t\t\"Modes: explore, edit, test, fix, review, doc.\",\n\t\t\t\"WHEN TO USE: (1) The work is self-contained and you do not need to see intermediate steps — only the final result.\",\n\t\t\t\"(2) You want to investigate or edit something in parallel without losing your current context or reasoning chain.\",\n\t\t\t\"(3) The task is a discrete unit (explore one module, run one test file, review one PR, fix one isolated bug, write docs).\",\n\t\t\t\"(4) You need to run a long command or test suite and wait for its output without blocking your own reasoning.\",\n\t\t\t\"Do NOT use for tasks that require tight back-and-forth with your current reasoning or that change files you are actively reasoning about.\",\n\t\t\t\"Use force=true to bypass dispatch evaluation when you are certain a subagent is required.\",\n\t\t].join(\" \"),\n\t\tpromptSnippet: \"delegate a self-contained task to an isolated subagent (modes: explore/edit/test/fix/review/doc)\",\n\t\tparameters: subagentParams,\n\n\t\tasync execute(_toolCallId, params: SubagentParams, signal, _onUpdate, ctx) {\n\t\t\tconst forcedMode = params.mode as SubagentMode;\n\n\t\t\t// Dispatch evaluation\n\t\t\tif (!params.force) {\n\t\t\t\tconst evaluator = new DispatchEvaluator();\n\t\t\t\tconst analysis = evaluator.evaluate(params.task);\n\t\t\t\tif (!analysis.should_delegate) {\n\t\t\t\t\treturn {\n\t\t\t\t\t\tcontent: [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\ttype: \"text\",\n\t\t\t\t\t\t\t\ttext: `Task is simple enough for inline handling. Reason: ${analysis.reason}. Use force=true for subagent override.`,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t],\n\t\t\t\t\t\tdetails: { mode: forcedMode, ok: true, taskId: 0, inline: true },\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst mode = params.force\n\t\t\t\t? forcedMode\n\t\t\t\t: toSubagentMode(new DispatchEvaluator().evaluate(params.task).agent_type);\n\t\t\tconst summary = summarize(params.task);\n\n\t\t\tconst task = taskStore.create(summary, { subagentMode: mode });\n\t\t\ttaskStore.update(task.id, { status: \"in_progress\" });\n\t\t\ttry {\n\t\t\t\tconst result = await runSubagent({\n\t\t\t\t\ttask: params.task,\n\t\t\t\t\tcontext: params.context,\n\t\t\t\t\tmode,\n\t\t\t\t\tcwd: ctx.cwd,\n\t\t\t\t\tmodel: ctx.model,\n\t\t\t\t\tmodelRegistry: ctx.modelRegistry,\n\t\t\t\t\tsignal: signal ?? ctx.signal,\n\t\t\t\t});\n\n\t\t\t\tif (!result.ok) {\n\t\t\t\t\t// Signal failure by throwing: the agent loop derives a tool's error\n\t\t\t\t\t// state from a thrown error, not from a returned flag.\n\t\t\t\t\ttaskStore.update(task.id, { status: \"failed\", usage: result.usage });\n\t\t\t\t\tthrow new Error(`Subagent (${mode}) failed: ${result.error ?? \"unknown error\"}`);\n\t\t\t\t}\n\n\t\t\t\t// Leave the task in the store with its final status. It stays visible in\n\t\t\t\t// the task panel until the main agent moves on (retireFinished is called\n\t\t\t\t// when the main agent starts its next turn).\n\t\t\t\ttaskStore.update(task.id, { status: \"done\", usage: result.usage });\n\t\t\t\treturn {\n\t\t\t\t\tcontent: [{ type: \"text\", text: result.answer || \"(subagent returned no output)\" }],\n\t\t\t\t\tdetails: { mode, ok: true, taskId: task.id },\n\t\t\t\t};\n\t\t\t} catch (error) {\n\t\t\t\ttaskStore.update(task.id, { status: \"failed\" });\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t},\n\n\t\trenderCall(args, theme) {\n\t\t\tconst mode = args.mode ?? \"explore\";\n\t\t\tconst preview = summarize(args.task ?? \"\");\n\t\t\tconst text =\n\t\t\t\ttheme.fg(\"toolTitle\", theme.bold(\"subagent \")) +\n\t\t\t\ttheme.fg(\"accent\", `[${mode}]`) +\n\t\t\t\ttheme.fg(\"dim\", ` ${preview}`);\n\t\t\treturn new Text(text, 0, 0);\n\t\t},\n\t});\n}\n"]}
|
|
@@ -16,6 +16,7 @@ Available subagent modes:
|
|
|
16
16
|
- test: run tests and report (read, bash, grep, find, ls).
|
|
17
17
|
- fix: diagnose and fix a failure (read, edit, write, bash, grep, find, ls).
|
|
18
18
|
- review: read-only code review (read, grep, find, ls, bash).
|
|
19
|
+
- doc: write documentation, README, or comments (read, write, edit, grep, find, ls, bash).
|
|
19
20
|
|
|
20
21
|
When to delegate:
|
|
21
22
|
1. The work is self-contained and you only need the final result, not intermediate steps.
|
|
@@ -28,9 +29,15 @@ Guidelines:
|
|
|
28
29
|
- Pass all necessary context (files, constraints, prior findings) via the \`context\` parameter.
|
|
29
30
|
- Do NOT delegate tasks that require tight back-and-forth with your current reasoning.
|
|
30
31
|
- Do NOT delegate edits to files you are actively reasoning about.
|
|
31
|
-
- The subagent returns ONLY its final answer. Intermediate reasoning, tool calls, and output are hidden from you
|
|
32
|
+
- The subagent returns ONLY its final answer. Intermediate reasoning, tool calls, and output are hidden from you.
|
|
33
|
+
|
|
34
|
+
Dispatch evaluator:
|
|
35
|
+
- The dispatch evaluator determines if a subagent is needed. Do not spawn subagents directly unless the user explicitly requests it.
|
|
36
|
+
- For simple single-file changes (<50 lines, read-only or trivial edit), handle them inline.
|
|
37
|
+
- Use force=true to bypass evaluation when you are certain a subagent is required.`;
|
|
32
38
|
import { Text } from "@kolisachint/hoocode-tui";
|
|
33
39
|
import { Type } from "typebox";
|
|
40
|
+
import { DispatchEvaluator } from "../dispatch-evaluator.js";
|
|
34
41
|
import { defineTool } from "../extensions/types.js";
|
|
35
42
|
import { runSubagent } from "../subagent.js";
|
|
36
43
|
import { taskStore } from "../task-store.js";
|
|
@@ -47,8 +54,13 @@ const subagentParams = Type.Object({
|
|
|
47
54
|
Type.Literal("test"),
|
|
48
55
|
Type.Literal("fix"),
|
|
49
56
|
Type.Literal("review"),
|
|
57
|
+
Type.Literal("doc"),
|
|
50
58
|
], {
|
|
51
|
-
description: "explore: read-only investigation. edit: make a focused code change. test: run tests and report. fix: diagnose and fix a failure. review: read-only code review.",
|
|
59
|
+
description: "explore: read-only investigation. edit: make a focused code change. test: run tests and report. fix: diagnose and fix a failure. review: read-only code review. doc: write documentation.",
|
|
60
|
+
}),
|
|
61
|
+
force: Type.Boolean({
|
|
62
|
+
description: "Bypass dispatch evaluation and spawn the subagent directly. Use when you are certain a subagent is required.",
|
|
63
|
+
default: false,
|
|
52
64
|
}),
|
|
53
65
|
});
|
|
54
66
|
/** First line of the task, trimmed to a short summary for the task list/footer. */
|
|
@@ -56,6 +68,15 @@ function summarize(task) {
|
|
|
56
68
|
const firstLine = task.trim().split("\n")[0] ?? "";
|
|
57
69
|
return firstLine.length > 60 ? `${firstLine.slice(0, 57)}...` : firstLine || "(task)";
|
|
58
70
|
}
|
|
71
|
+
/** Quick check: should this task go to a subagent? */
|
|
72
|
+
export function isSubagentRecommended(task) {
|
|
73
|
+
const evaluator = new DispatchEvaluator();
|
|
74
|
+
return evaluator.evaluate(task).should_delegate;
|
|
75
|
+
}
|
|
76
|
+
/** Map evaluator AgentType to SubagentMode (they are compatible strings). */
|
|
77
|
+
function toSubagentMode(agentType) {
|
|
78
|
+
return agentType ?? "explore";
|
|
79
|
+
}
|
|
59
80
|
/** Create the subagent tool definition. Registered as a customTool when enabled. */
|
|
60
81
|
export function createSubagentToolDefinition() {
|
|
61
82
|
return defineTool({
|
|
@@ -64,17 +85,37 @@ export function createSubagentToolDefinition() {
|
|
|
64
85
|
description: [
|
|
65
86
|
"Delegate a focused task to a subagent that runs in a fresh, isolated context (it cannot see this conversation).",
|
|
66
87
|
"Pass everything it needs via `context`. The subagent returns only its final answer.",
|
|
67
|
-
"Modes: explore, edit, test, fix, review.",
|
|
88
|
+
"Modes: explore, edit, test, fix, review, doc.",
|
|
68
89
|
"WHEN TO USE: (1) The work is self-contained and you do not need to see intermediate steps — only the final result.",
|
|
69
90
|
"(2) You want to investigate or edit something in parallel without losing your current context or reasoning chain.",
|
|
70
|
-
"(3) The task is a discrete unit (explore one module, run one test file, review one PR, fix one isolated bug).",
|
|
91
|
+
"(3) The task is a discrete unit (explore one module, run one test file, review one PR, fix one isolated bug, write docs).",
|
|
71
92
|
"(4) You need to run a long command or test suite and wait for its output without blocking your own reasoning.",
|
|
72
93
|
"Do NOT use for tasks that require tight back-and-forth with your current reasoning or that change files you are actively reasoning about.",
|
|
94
|
+
"Use force=true to bypass dispatch evaluation when you are certain a subagent is required.",
|
|
73
95
|
].join(" "),
|
|
74
|
-
promptSnippet: "delegate a self-contained task to an isolated subagent (modes: explore/edit/test/fix/review)",
|
|
96
|
+
promptSnippet: "delegate a self-contained task to an isolated subagent (modes: explore/edit/test/fix/review/doc)",
|
|
75
97
|
parameters: subagentParams,
|
|
76
98
|
async execute(_toolCallId, params, signal, _onUpdate, ctx) {
|
|
77
|
-
const
|
|
99
|
+
const forcedMode = params.mode;
|
|
100
|
+
// Dispatch evaluation
|
|
101
|
+
if (!params.force) {
|
|
102
|
+
const evaluator = new DispatchEvaluator();
|
|
103
|
+
const analysis = evaluator.evaluate(params.task);
|
|
104
|
+
if (!analysis.should_delegate) {
|
|
105
|
+
return {
|
|
106
|
+
content: [
|
|
107
|
+
{
|
|
108
|
+
type: "text",
|
|
109
|
+
text: `Task is simple enough for inline handling. Reason: ${analysis.reason}. Use force=true for subagent override.`,
|
|
110
|
+
},
|
|
111
|
+
],
|
|
112
|
+
details: { mode: forcedMode, ok: true, taskId: 0, inline: true },
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
const mode = params.force
|
|
117
|
+
? forcedMode
|
|
118
|
+
: toSubagentMode(new DispatchEvaluator().evaluate(params.task).agent_type);
|
|
78
119
|
const summary = summarize(params.task);
|
|
79
120
|
const task = taskStore.create(summary, { subagentMode: mode });
|
|
80
121
|
taskStore.update(task.id, { status: "in_progress" });
|
|
@@ -91,13 +132,13 @@ export function createSubagentToolDefinition() {
|
|
|
91
132
|
if (!result.ok) {
|
|
92
133
|
// Signal failure by throwing: the agent loop derives a tool's error
|
|
93
134
|
// state from a thrown error, not from a returned flag.
|
|
94
|
-
taskStore.update(task.id, { status: "failed" });
|
|
135
|
+
taskStore.update(task.id, { status: "failed", usage: result.usage });
|
|
95
136
|
throw new Error(`Subagent (${mode}) failed: ${result.error ?? "unknown error"}`);
|
|
96
137
|
}
|
|
97
138
|
// Leave the task in the store with its final status. It stays visible in
|
|
98
139
|
// the task panel until the main agent moves on (retireFinished is called
|
|
99
140
|
// when the main agent starts its next turn).
|
|
100
|
-
taskStore.update(task.id, { status: "done" });
|
|
141
|
+
taskStore.update(task.id, { status: "done", usage: result.usage });
|
|
101
142
|
return {
|
|
102
143
|
content: [{ type: "text", text: result.answer || "(subagent returned no output)" }],
|
|
103
144
|
details: { mode, ok: true, taskId: task.id },
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"subagent.js","sourceRoot":"","sources":["../../../src/core/tools/subagent.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH;0EAC0E;AAC1E,MAAM,CAAC,MAAM,oBAAoB,GAAG;;;;;;;;;;;;;;;;;;;;kHAoB8E,CAAC;AAEnH,OAAO,EAAE,IAAI,EAAE,MAAM,0BAA0B,CAAC;AAChD,OAAO,EAAe,IAAI,EAAE,MAAM,SAAS,CAAC;AAE5C,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACpD,OAAO,EAAE,WAAW,EAAqB,MAAM,gBAAgB,CAAC;AAChE,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAE7C,MAAM,cAAc,GAAG,IAAI,CAAC,MAAM,CAAC;IAClC,IAAI,EAAE,IAAI,CAAC,MAAM,CAAC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AE,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,EAAE;iBAC5C,CAAC;YACH,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBAChB,SAAS,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,CAAC;gBAChD,MAAM,KAAK,CAAC;YACb,CAAC;QAAA,CACD;QAED,UAAU,CAAC,IAAI,EAAE,KAAK,EAAE;YACvB,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,IAAI,SAAS,CAAC;YACpC,MAAM,OAAO,GAAG,SAAS,CAAC,IAAI,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC;YAC3C,MAAM,IAAI,GACT,KAAK,CAAC,EAAE,CAAC,WAAW,EAAE,KAAK,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;gBAC9C,KAAK,CAAC,EAAE,CAAC,QAAQ,EAAE,IAAI,IAAI,GAAG,CAAC;gBAC/B,KAAK,CAAC,EAAE,CAAC,KAAK,EAAE,IAAI,OAAO,EAAE,CAAC,CAAC;YAChC,OAAO,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;QAAA,CAC5B;KACD,CAAC,CAAC;AAAA,CACH","sourcesContent":["/**\n * Subagent tool: delegate a focused task to a fresh, isolated agent loop.\n *\n * The tool registers a task in the shared task store (visible in the task panel),\n * runs the subagent to completion, and returns ONLY the subagent's final\n * answer. It is an optional, opt-in tool (enabled via --subagent or the\n * `enableSubagent` setting); see buildSessionOptions in main.ts.\n */\n\n/** System prompt appendix for the main session when subagent tooling is enabled.\n * Instructs the parent agent on when and how to delegate effectively. */\nexport const SUBAGENT_MAIN_PROMPT = `You have access to the **subagent** tool. Use it to delegate self-contained tasks to isolated subagent loops that run with their own context and return only their final answer.\n\nAvailable subagent modes:\n- explore: read-only investigation (read, grep, find, ls, bash).\n- edit: make a focused code change (read, edit, write, grep, find, ls, bash).\n- test: run tests and report (read, bash, grep, find, ls).\n- fix: diagnose and fix a failure (read, edit, write, bash, grep, find, ls).\n- review: read-only code review (read, grep, find, ls, bash).\n\nWhen to delegate:\n1. The work is self-contained and you only need the final result, not intermediate steps.\n2. You want to investigate or edit something in parallel without losing your current context or reasoning chain.\n3. The task is a discrete unit (explore one module, run one test file, review one PR, fix one isolated bug).\n4. You need to run a long command or test suite and wait for its output without blocking your own reasoning.\n\nGuidelines:\n- Make every task specific and self-contained. The subagent cannot see this conversation.\n- Pass all necessary context (files, constraints, prior findings) via the \\`context\\` parameter.\n- Do NOT delegate tasks that require tight back-and-forth with your current reasoning.\n- Do NOT delegate edits to files you are actively reasoning about.\n- The subagent returns ONLY its final answer. Intermediate reasoning, tool calls, and output are hidden from you.`;\n\nimport { Text } from \"@kolisachint/hoocode-tui\";\nimport { type Static, Type } from \"typebox\";\nimport type { ToolDefinition } from \"../extensions/types.js\";\nimport { defineTool } from \"../extensions/types.js\";\nimport { runSubagent, type SubagentMode } from \"../subagent.js\";\nimport { taskStore } from \"../task-store.js\";\n\nconst subagentParams = Type.Object({\n\ttask: Type.String({\n\t\tdescription:\n\t\t\t\"The task to delegate. Make it specific and self-contained; the subagent cannot see this conversation.\",\n\t}),\n\tcontext: Type.String({\n\t\tdescription:\n\t\t\t'Context distilled from the conversation the subagent needs (files, constraints, prior findings). Pass \"\" if none.',\n\t}),\n\tmode: Type.Union(\n\t\t[\n\t\t\tType.Literal(\"explore\"),\n\t\t\tType.Literal(\"edit\"),\n\t\t\tType.Literal(\"test\"),\n\t\t\tType.Literal(\"fix\"),\n\t\t\tType.Literal(\"review\"),\n\t\t],\n\t\t{\n\t\t\tdescription:\n\t\t\t\t\"explore: read-only investigation. edit: make a focused code change. test: run tests and report. fix: diagnose and fix a failure. review: read-only code review.\",\n\t\t},\n\t),\n});\n\ntype SubagentParams = Static<typeof subagentParams>;\n\nexport interface SubagentToolDetails {\n\tmode: SubagentMode;\n\tok: boolean;\n\terror?: string;\n\ttaskId: number;\n}\n\n/** First line of the task, trimmed to a short summary for the task list/footer. */\nfunction summarize(task: string): string {\n\tconst firstLine = task.trim().split(\"\\n\")[0] ?? \"\";\n\treturn firstLine.length > 60 ? `${firstLine.slice(0, 57)}...` : firstLine || \"(task)\";\n}\n\n/** Create the subagent tool definition. Registered as a customTool when enabled. */\nexport function createSubagentToolDefinition(): ToolDefinition {\n\treturn defineTool<typeof subagentParams, SubagentToolDetails>({\n\t\tname: \"subagent\",\n\t\tlabel: \"Subagent\",\n\t\tdescription: [\n\t\t\t\"Delegate a focused task to a subagent that runs in a fresh, isolated context (it cannot see this conversation).\",\n\t\t\t\"Pass everything it needs via `context`. The subagent returns only its final answer.\",\n\t\t\t\"Modes: explore, edit, test, fix, review.\",\n\t\t\t\"WHEN TO USE: (1) The work is self-contained and you do not need to see intermediate steps — only the final result.\",\n\t\t\t\"(2) You want to investigate or edit something in parallel without losing your current context or reasoning chain.\",\n\t\t\t\"(3) The task is a discrete unit (explore one module, run one test file, review one PR, fix one isolated bug).\",\n\t\t\t\"(4) You need to run a long command or test suite and wait for its output without blocking your own reasoning.\",\n\t\t\t\"Do NOT use for tasks that require tight back-and-forth with your current reasoning or that change files you are actively reasoning about.\",\n\t\t].join(\" \"),\n\t\tpromptSnippet: \"delegate a self-contained task to an isolated subagent (modes: explore/edit/test/fix/review)\",\n\t\tparameters: subagentParams,\n\n\t\tasync execute(_toolCallId, params: SubagentParams, signal, _onUpdate, ctx) {\n\t\t\tconst mode = params.mode as SubagentMode;\n\t\t\tconst summary = summarize(params.task);\n\n\t\t\tconst task = taskStore.create(summary, { subagentMode: mode });\n\t\t\ttaskStore.update(task.id, { status: \"in_progress\" });\n\t\t\ttry {\n\t\t\t\tconst result = await runSubagent({\n\t\t\t\t\ttask: params.task,\n\t\t\t\t\tcontext: params.context,\n\t\t\t\t\tmode,\n\t\t\t\t\tcwd: ctx.cwd,\n\t\t\t\t\tmodel: ctx.model,\n\t\t\t\t\tmodelRegistry: ctx.modelRegistry,\n\t\t\t\t\tsignal: signal ?? ctx.signal,\n\t\t\t\t});\n\n\t\t\t\tif (!result.ok) {\n\t\t\t\t\t// Signal failure by throwing: the agent loop derives a tool's error\n\t\t\t\t\t// state from a thrown error, not from a returned flag.\n\t\t\t\t\ttaskStore.update(task.id, { status: \"failed\" });\n\t\t\t\t\tthrow new Error(`Subagent (${mode}) failed: ${result.error ?? \"unknown error\"}`);\n\t\t\t\t}\n\n\t\t\t\t// Leave the task in the store with its final status. It stays visible in\n\t\t\t\t// the task panel until the main agent moves on (retireFinished is called\n\t\t\t\t// when the main agent starts its next turn).\n\t\t\t\ttaskStore.update(task.id, { status: \"done\" });\n\t\t\t\treturn {\n\t\t\t\t\tcontent: [{ type: \"text\", text: result.answer || \"(subagent returned no output)\" }],\n\t\t\t\t\tdetails: { mode, ok: true, taskId: task.id },\n\t\t\t\t};\n\t\t\t} catch (error) {\n\t\t\t\ttaskStore.update(task.id, { status: \"failed\" });\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t},\n\n\t\trenderCall(args, theme) {\n\t\t\tconst mode = args.mode ?? \"explore\";\n\t\t\tconst preview = summarize(args.task ?? \"\");\n\t\t\tconst text =\n\t\t\t\ttheme.fg(\"toolTitle\", theme.bold(\"subagent \")) +\n\t\t\t\ttheme.fg(\"accent\", `[${mode}]`) +\n\t\t\t\ttheme.fg(\"dim\", ` ${preview}`);\n\t\t\treturn new Text(text, 0, 0);\n\t\t},\n\t});\n}\n"]}
|
|
1
|
+
{"version":3,"file":"subagent.js","sourceRoot":"","sources":["../../../src/core/tools/subagent.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH;0EAC0E;AAC1E,MAAM,CAAC,MAAM,oBAAoB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;mFA0B+C,CAAC;AAEpF,OAAO,EAAE,IAAI,EAAE,MAAM,0BAA0B,CAAC;AAChD,OAAO,EAAe,IAAI,EAAE,MAAM,SAAS,CAAC;AAC5C,OAAO,EAAkB,iBAAiB,EA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MAAM,CAAC,IAAI,CAAC,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC;gBACnE,OAAO;oBACN,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,IAAI,+BAA+B,EAAE,CAAC;oBACnF,OAAO,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,EAAE;iBAC5C,CAAC;YACH,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBAChB,SAAS,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,CAAC;gBAChD,MAAM,KAAK,CAAC;YACb,CAAC;QAAA,CACD;QAED,UAAU,CAAC,IAAI,EAAE,KAAK,EAAE;YACvB,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,IAAI,SAAS,CAAC;YACpC,MAAM,OAAO,GAAG,SAAS,CAAC,IAAI,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC;YAC3C,MAAM,IAAI,GACT,KAAK,CAAC,EAAE,CAAC,WAAW,EAAE,KAAK,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;gBAC9C,KAAK,CAAC,EAAE,CAAC,QAAQ,EAAE,IAAI,IAAI,GAAG,CAAC;gBAC/B,KAAK,CAAC,EAAE,CAAC,KAAK,EAAE,IAAI,OAAO,EAAE,CAAC,CAAC;YAChC,OAAO,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;QAAA,CAC5B;KACD,CAAC,CAAC;AAAA,CACH","sourcesContent":["/**\n * Subagent tool: delegate a focused task to a fresh, isolated agent loop.\n *\n * The tool registers a task in the shared task store (visible in the task panel),\n * runs the subagent to completion, and returns ONLY the subagent's final\n * answer. It is an optional, opt-in tool (enabled via --subagent or the\n * `enableSubagent` setting); see buildSessionOptions in main.ts.\n */\n\n/** System prompt appendix for the main session when subagent tooling is enabled.\n * Instructs the parent agent on when and how to delegate effectively. */\nexport const SUBAGENT_MAIN_PROMPT = `You have access to the **subagent** tool. Use it to delegate self-contained tasks to isolated subagent loops that run with their own context and return only their final answer.\n\nAvailable subagent modes:\n- explore: read-only investigation (read, grep, find, ls, bash).\n- edit: make a focused code change (read, edit, write, grep, find, ls, bash).\n- test: run tests and report (read, bash, grep, find, ls).\n- fix: diagnose and fix a failure (read, edit, write, bash, grep, find, ls).\n- review: read-only code review (read, grep, find, ls, bash).\n- doc: write documentation, README, or comments (read, write, edit, grep, find, ls, bash).\n\nWhen to delegate:\n1. The work is self-contained and you only need the final result, not intermediate steps.\n2. You want to investigate or edit something in parallel without losing your current context or reasoning chain.\n3. The task is a discrete unit (explore one module, run one test file, review one PR, fix one isolated bug).\n4. You need to run a long command or test suite and wait for its output without blocking your own reasoning.\n\nGuidelines:\n- Make every task specific and self-contained. The subagent cannot see this conversation.\n- Pass all necessary context (files, constraints, prior findings) via the \\`context\\` parameter.\n- Do NOT delegate tasks that require tight back-and-forth with your current reasoning.\n- Do NOT delegate edits to files you are actively reasoning about.\n- The subagent returns ONLY its final answer. Intermediate reasoning, tool calls, and output are hidden from you.\n\nDispatch evaluator:\n- The dispatch evaluator determines if a subagent is needed. Do not spawn subagents directly unless the user explicitly requests it.\n- For simple single-file changes (<50 lines, read-only or trivial edit), handle them inline.\n- Use force=true to bypass evaluation when you are certain a subagent is required.`;\n\nimport { Text } from \"@kolisachint/hoocode-tui\";\nimport { type Static, Type } from \"typebox\";\nimport { type AgentType, DispatchEvaluator } from \"../dispatch-evaluator.js\";\nimport type { ToolDefinition } from \"../extensions/types.js\";\nimport { defineTool } from \"../extensions/types.js\";\nimport { runSubagent, type SubagentMode } from \"../subagent.js\";\nimport { taskStore } from \"../task-store.js\";\n\nconst subagentParams = Type.Object({\n\ttask: Type.String({\n\t\tdescription:\n\t\t\t\"The task to delegate. Make it specific and self-contained; the subagent cannot see this conversation.\",\n\t}),\n\tcontext: Type.String({\n\t\tdescription:\n\t\t\t'Context distilled from the conversation the subagent needs (files, constraints, prior findings). Pass \"\" if none.',\n\t}),\n\tmode: Type.Union(\n\t\t[\n\t\t\tType.Literal(\"explore\"),\n\t\t\tType.Literal(\"edit\"),\n\t\t\tType.Literal(\"test\"),\n\t\t\tType.Literal(\"fix\"),\n\t\t\tType.Literal(\"review\"),\n\t\t\tType.Literal(\"doc\"),\n\t\t],\n\t\t{\n\t\t\tdescription:\n\t\t\t\t\"explore: read-only investigation. edit: make a focused code change. test: run tests and report. fix: diagnose and fix a failure. review: read-only code review. doc: write documentation.\",\n\t\t},\n\t),\n\tforce: Type.Boolean({\n\t\tdescription:\n\t\t\t\"Bypass dispatch evaluation and spawn the subagent directly. Use when you are certain a subagent is required.\",\n\t\tdefault: false,\n\t}),\n});\n\ntype SubagentParams = Static<typeof subagentParams>;\n\nexport interface SubagentToolDetails {\n\tmode: SubagentMode;\n\tok: boolean;\n\terror?: string;\n\ttaskId: number;\n\t/** True when the evaluator handled the task inline instead of delegating. */\n\tinline?: boolean;\n}\n\n/** First line of the task, trimmed to a short summary for the task list/footer. */\nfunction summarize(task: string): string {\n\tconst firstLine = task.trim().split(\"\\n\")[0] ?? \"\";\n\treturn firstLine.length > 60 ? `${firstLine.slice(0, 57)}...` : firstLine || \"(task)\";\n}\n\n/** Quick check: should this task go to a subagent? */\nexport function isSubagentRecommended(task: string): boolean {\n\tconst evaluator = new DispatchEvaluator();\n\treturn evaluator.evaluate(task).should_delegate;\n}\n\n/** Map evaluator AgentType to SubagentMode (they are compatible strings). */\nfunction toSubagentMode(agentType: AgentType | null): SubagentMode {\n\treturn (agentType as SubagentMode) ?? \"explore\";\n}\n\n/** Create the subagent tool definition. Registered as a customTool when enabled. */\nexport function createSubagentToolDefinition(): ToolDefinition {\n\treturn defineTool<typeof subagentParams, SubagentToolDetails>({\n\t\tname: \"subagent\",\n\t\tlabel: \"Subagent\",\n\t\tdescription: [\n\t\t\t\"Delegate a focused task to a subagent that runs in a fresh, isolated context (it cannot see this conversation).\",\n\t\t\t\"Pass everything it needs via `context`. The subagent returns only its final answer.\",\n\t\t\t\"Modes: explore, edit, test, fix, review, doc.\",\n\t\t\t\"WHEN TO USE: (1) The work is self-contained and you do not need to see intermediate steps — only the final result.\",\n\t\t\t\"(2) You want to investigate or edit something in parallel without losing your current context or reasoning chain.\",\n\t\t\t\"(3) The task is a discrete unit (explore one module, run one test file, review one PR, fix one isolated bug, write docs).\",\n\t\t\t\"(4) You need to run a long command or test suite and wait for its output without blocking your own reasoning.\",\n\t\t\t\"Do NOT use for tasks that require tight back-and-forth with your current reasoning or that change files you are actively reasoning about.\",\n\t\t\t\"Use force=true to bypass dispatch evaluation when you are certain a subagent is required.\",\n\t\t].join(\" \"),\n\t\tpromptSnippet: \"delegate a self-contained task to an isolated subagent (modes: explore/edit/test/fix/review/doc)\",\n\t\tparameters: subagentParams,\n\n\t\tasync execute(_toolCallId, params: SubagentParams, signal, _onUpdate, ctx) {\n\t\t\tconst forcedMode = params.mode as SubagentMode;\n\n\t\t\t// Dispatch evaluation\n\t\t\tif (!params.force) {\n\t\t\t\tconst evaluator = new DispatchEvaluator();\n\t\t\t\tconst analysis = evaluator.evaluate(params.task);\n\t\t\t\tif (!analysis.should_delegate) {\n\t\t\t\t\treturn {\n\t\t\t\t\t\tcontent: [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\ttype: \"text\",\n\t\t\t\t\t\t\t\ttext: `Task is simple enough for inline handling. Reason: ${analysis.reason}. Use force=true for subagent override.`,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t],\n\t\t\t\t\t\tdetails: { mode: forcedMode, ok: true, taskId: 0, inline: true },\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst mode = params.force\n\t\t\t\t? forcedMode\n\t\t\t\t: toSubagentMode(new DispatchEvaluator().evaluate(params.task).agent_type);\n\t\t\tconst summary = summarize(params.task);\n\n\t\t\tconst task = taskStore.create(summary, { subagentMode: mode });\n\t\t\ttaskStore.update(task.id, { status: \"in_progress\" });\n\t\t\ttry {\n\t\t\t\tconst result = await runSubagent({\n\t\t\t\t\ttask: params.task,\n\t\t\t\t\tcontext: params.context,\n\t\t\t\t\tmode,\n\t\t\t\t\tcwd: ctx.cwd,\n\t\t\t\t\tmodel: ctx.model,\n\t\t\t\t\tmodelRegistry: ctx.modelRegistry,\n\t\t\t\t\tsignal: signal ?? ctx.signal,\n\t\t\t\t});\n\n\t\t\t\tif (!result.ok) {\n\t\t\t\t\t// Signal failure by throwing: the agent loop derives a tool's error\n\t\t\t\t\t// state from a thrown error, not from a returned flag.\n\t\t\t\t\ttaskStore.update(task.id, { status: \"failed\", usage: result.usage });\n\t\t\t\t\tthrow new Error(`Subagent (${mode}) failed: ${result.error ?? \"unknown error\"}`);\n\t\t\t\t}\n\n\t\t\t\t// Leave the task in the store with its final status. It stays visible in\n\t\t\t\t// the task panel until the main agent moves on (retireFinished is called\n\t\t\t\t// when the main agent starts its next turn).\n\t\t\t\ttaskStore.update(task.id, { status: \"done\", usage: result.usage });\n\t\t\t\treturn {\n\t\t\t\t\tcontent: [{ type: \"text\", text: result.answer || \"(subagent returned no output)\" }],\n\t\t\t\t\tdetails: { mode, ok: true, taskId: task.id },\n\t\t\t\t};\n\t\t\t} catch (error) {\n\t\t\t\ttaskStore.update(task.id, { status: \"failed\" });\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t},\n\n\t\trenderCall(args, theme) {\n\t\t\tconst mode = args.mode ?? \"explore\";\n\t\t\tconst preview = summarize(args.task ?? \"\");\n\t\t\tconst text =\n\t\t\t\ttheme.fg(\"toolTitle\", theme.bold(\"subagent \")) +\n\t\t\t\ttheme.fg(\"accent\", `[${mode}]`) +\n\t\t\t\ttheme.fg(\"dim\", ` ${preview}`);\n\t\t\treturn new Text(text, 0, 0);\n\t\t},\n\t});\n}\n"]}
|
|
@@ -2,4 +2,5 @@ export declare const EMBEDDED_DEFAULT_CONFIG: string;
|
|
|
2
2
|
export declare const EMBEDDED_MODES: Record<string, string>;
|
|
3
3
|
export declare const EMBEDDED_PROFILES: Record<string, string>;
|
|
4
4
|
export declare const EMBEDDED_SUBAGENT_PROMPTS: Record<string, string>;
|
|
5
|
+
export declare const EMBEDDED_AGENT_PROMPTS: Record<string, string>;
|
|
5
6
|
//# sourceMappingURL=init-templates.generated.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"init-templates.generated.d.ts","sourceRoot":"","sources":["../src/init-templates.generated.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,uBAAuB,EAAE,MAC+Z,CAAC;AAEtc,eAAO,MAAM,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAKjD,CAAC;AAEF,eAAO,MAAM,iBAAiB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAM,CAAC;AAE5D,eAAO,MAAM,yBAAyB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAQ5D,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};\n"]}
|
|
1
|
+
{"version":3,"file":"init-templates.generated.d.ts","sourceRoot":"","sources":["../src/init-templates.generated.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,uBAAuB,EAAE,MAC+Z,CAAC;AAEtc,eAAO,MAAM,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAKjD,CAAC;AAEF,eAAO,MAAM,iBAAiB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAM,CAAC;AAE5D,eAAO,MAAM,yBAAyB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAS5D,CAAC;AAEF,eAAO,MAAM,sBAAsB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAQzD,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"]}
|
|
@@ -15,5 +15,13 @@ export const EMBEDDED_SUBAGENT_PROMPTS = {
|
|
|
15
15
|
fix: "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",
|
|
16
16
|
review: "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",
|
|
17
17
|
test: "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",
|
|
18
|
+
doc: "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",
|
|
19
|
+
};
|
|
20
|
+
export const EMBEDDED_AGENT_PROMPTS = {
|
|
21
|
+
explore: "---\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",
|
|
22
|
+
edit: "---\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",
|
|
23
|
+
test: "---\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",
|
|
24
|
+
review: "---\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",
|
|
25
|
+
doc: "---\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",
|
|
18
26
|
};
|
|
19
27
|
//# sourceMappingURL=init-templates.generated.js.map
|
|
@@ -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;CACnkD,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};\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,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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"assistant-message.d.ts","sourceRoot":"","sources":["../../../../src/modes/interactive/components/assistant-message.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,EAAE,SAAS,EAAY,KAAK,aAAa,EAAgB,MAAM,0BAA0B,CAAC;AAOjG;;GAEG;AACH,qBAAa,yBAA0B,SAAQ,SAAS;IACvD,OAAO,CAAC,gBAAgB,CAAY;IACpC,OAAO,CAAC,iBAAiB,CAAU;IACnC,OAAO,CAAC,aAAa,CAAgB;IACrC,OAAO,CAAC,mBAAmB,CAAS;IACpC,OAAO,CAAC,WAAW,CAAC,CAAmB;IACvC,OAAO,CAAC,YAAY,CAAS;IAE7B,YACC,OAAO,CAAC,EAAE,gBAAgB,EAC1B,iBAAiB,UAAQ,EACzB,aAAa,GAAE,aAAkC,EACjD,mBAAmB,SAAgB,EAenC;IAEQ,UAAU,IAAI,IAAI,CAK1B;IAED,oBAAoB,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI,CAKxC;IAED,sBAAsB,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAK1C;IAEQ,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,CASvC;IAED,aAAa,CAAC,OAAO,EAAE,gBAAgB,GAAG,IAAI,CAyE7C;CACD","sourcesContent":["import type { AssistantMessage } from \"@kolisachint/hoocode-ai\";\nimport { Container, Markdown, type MarkdownTheme, Spacer, Text } from \"@kolisachint/hoocode-tui\";\nimport { getMarkdownTheme, theme } from \"../theme/theme.js\";\n\nconst OSC133_ZONE_START = \"\\x1b]133;A\\x07\";\nconst OSC133_ZONE_END = \"\\x1b]133;B\\x07\";\nconst OSC133_ZONE_FINAL = \"\\x1b]133;C\\x07\";\n\n/**\n * Component that renders a complete assistant message\n */\nexport class AssistantMessageComponent extends Container {\n\tprivate contentContainer: Container;\n\tprivate hideThinkingBlock: boolean;\n\tprivate markdownTheme: MarkdownTheme;\n\tprivate hiddenThinkingLabel: string;\n\tprivate lastMessage?: AssistantMessage;\n\tprivate hasToolCalls = false;\n\n\tconstructor(\n\t\tmessage?: AssistantMessage,\n\t\thideThinkingBlock = false,\n\t\tmarkdownTheme: MarkdownTheme = getMarkdownTheme(),\n\t\thiddenThinkingLabel = \"Thinking...\",\n\t) {\n\t\tsuper();\n\n\t\tthis.hideThinkingBlock = hideThinkingBlock;\n\t\tthis.markdownTheme = markdownTheme;\n\t\tthis.hiddenThinkingLabel = hiddenThinkingLabel;\n\n\t\t// Container for text/thinking content\n\t\tthis.contentContainer = new Container();\n\t\tthis.addChild(this.contentContainer);\n\n\t\tif (message) {\n\t\t\tthis.updateContent(message);\n\t\t}\n\t}\n\n\toverride invalidate(): void {\n\t\tsuper.invalidate();\n\t\tif (this.lastMessage) {\n\t\t\tthis.updateContent(this.lastMessage);\n\t\t}\n\t}\n\n\tsetHideThinkingBlock(hide: boolean): void {\n\t\tthis.hideThinkingBlock = hide;\n\t\tif (this.lastMessage) {\n\t\t\tthis.updateContent(this.lastMessage);\n\t\t}\n\t}\n\n\tsetHiddenThinkingLabel(label: string): void {\n\t\tthis.hiddenThinkingLabel = label;\n\t\tif (this.lastMessage) {\n\t\t\tthis.updateContent(this.lastMessage);\n\t\t}\n\t}\n\n\toverride render(width: number): string[] {\n\t\tconst lines = super.render(width);\n\t\tif (this.hasToolCalls || lines.length === 0) {\n\t\t\treturn lines;\n\t\t}\n\n\t\tlines[0] = OSC133_ZONE_START + lines[0];\n\t\tlines[lines.length - 1] = OSC133_ZONE_END + OSC133_ZONE_FINAL + lines[lines.length - 1];\n\t\treturn lines;\n\t}\n\n\tupdateContent(message: AssistantMessage): void {\n\t\tthis.lastMessage = message;\n\n\t\t// Clear content container\n\t\tthis.contentContainer.clear();\n\n\t\tconst hasVisibleContent = message.content.some(\n\t\t\t(c) => (c.type === \"text\" && c.text.trim()) || (c.type === \"thinking\" && c.thinking.trim()),\n\t\t);\n\n\t\tif (hasVisibleContent) {\n\t\t\tthis.contentContainer.addChild(new Spacer(1));\n\t\t}\n\n\t\t// Render content in order\n\t\tfor (let i = 0; i < message.content.length; i++) {\n\t\t\tconst content = message.content[i];\n\t\t\tif (content.type === \"text\" && content.text.trim()) {\n\t\t\t\t// Assistant text messages with no background - trim the text\n\t\t\t\t// Set paddingY=0 to avoid extra spacing before tool executions\n\t\t\t\tthis.contentContainer.addChild(new Markdown(content.text.trim(), 1, 0, this.markdownTheme));\n\t\t\t} else if (content.type === \"thinking\" && content.thinking.trim()) {\n\t\t\t\t// Add spacing only when another visible assistant content block follows.\n\t\t\t\t// This avoids a superfluous blank line before separately-rendered tool execution blocks.\n\t\t\t\tconst hasVisibleContentAfter = message.content\n\t\t\t\t\t.slice(i + 1)\n\t\t\t\t\t.some((c) => (c.type === \"text\" && c.text.trim()) || (c.type === \"thinking\" && c.thinking.trim()));\n\n\t\t\t\tif (this.hideThinkingBlock) {\n\t\t\t\t\t// Show static thinking label when hidden\n\t\t\t\t\tthis.contentContainer.addChild(\n\t\t\t\t\t\tnew Text(theme.italic(theme.fg(\"thinkingText\", this.hiddenThinkingLabel)), 1, 0),\n\t\t\t\t\t);\n\t\t\t\t\tif (hasVisibleContentAfter) {\n\t\t\t\t\t\tthis.contentContainer.addChild(new Spacer(1));\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\t// Thinking traces in thinkingText color, italic\n\t\t\t\t\tthis.contentContainer.addChild(\n\t\t\t\t\t\tnew Markdown(content.thinking.trim()
|
|
1
|
+
{"version":3,"file":"assistant-message.d.ts","sourceRoot":"","sources":["../../../../src/modes/interactive/components/assistant-message.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,EAAE,SAAS,EAAY,KAAK,aAAa,EAAgB,MAAM,0BAA0B,CAAC;AAOjG;;GAEG;AACH,qBAAa,yBAA0B,SAAQ,SAAS;IACvD,OAAO,CAAC,gBAAgB,CAAY;IACpC,OAAO,CAAC,iBAAiB,CAAU;IACnC,OAAO,CAAC,aAAa,CAAgB;IACrC,OAAO,CAAC,mBAAmB,CAAS;IACpC,OAAO,CAAC,WAAW,CAAC,CAAmB;IACvC,OAAO,CAAC,YAAY,CAAS;IAE7B,YACC,OAAO,CAAC,EAAE,gBAAgB,EAC1B,iBAAiB,UAAQ,EACzB,aAAa,GAAE,aAAkC,EACjD,mBAAmB,SAAgB,EAenC;IAEQ,UAAU,IAAI,IAAI,CAK1B;IAED,oBAAoB,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI,CAKxC;IAED,sBAAsB,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAK1C;IAEQ,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,CASvC;IAED,aAAa,CAAC,OAAO,EAAE,gBAAgB,GAAG,IAAI,CAyE7C;CACD","sourcesContent":["import type { AssistantMessage } from \"@kolisachint/hoocode-ai\";\nimport { Container, Markdown, type MarkdownTheme, Spacer, Text } from \"@kolisachint/hoocode-tui\";\nimport { getMarkdownTheme, theme } from \"../theme/theme.js\";\n\nconst OSC133_ZONE_START = \"\\x1b]133;A\\x07\";\nconst OSC133_ZONE_END = \"\\x1b]133;B\\x07\";\nconst OSC133_ZONE_FINAL = \"\\x1b]133;C\\x07\";\n\n/**\n * Component that renders a complete assistant message\n */\nexport class AssistantMessageComponent extends Container {\n\tprivate contentContainer: Container;\n\tprivate hideThinkingBlock: boolean;\n\tprivate markdownTheme: MarkdownTheme;\n\tprivate hiddenThinkingLabel: string;\n\tprivate lastMessage?: AssistantMessage;\n\tprivate hasToolCalls = false;\n\n\tconstructor(\n\t\tmessage?: AssistantMessage,\n\t\thideThinkingBlock = false,\n\t\tmarkdownTheme: MarkdownTheme = getMarkdownTheme(),\n\t\thiddenThinkingLabel = \"Thinking...\",\n\t) {\n\t\tsuper();\n\n\t\tthis.hideThinkingBlock = hideThinkingBlock;\n\t\tthis.markdownTheme = markdownTheme;\n\t\tthis.hiddenThinkingLabel = hiddenThinkingLabel;\n\n\t\t// Container for text/thinking content\n\t\tthis.contentContainer = new Container();\n\t\tthis.addChild(this.contentContainer);\n\n\t\tif (message) {\n\t\t\tthis.updateContent(message);\n\t\t}\n\t}\n\n\toverride invalidate(): void {\n\t\tsuper.invalidate();\n\t\tif (this.lastMessage) {\n\t\t\tthis.updateContent(this.lastMessage);\n\t\t}\n\t}\n\n\tsetHideThinkingBlock(hide: boolean): void {\n\t\tthis.hideThinkingBlock = hide;\n\t\tif (this.lastMessage) {\n\t\t\tthis.updateContent(this.lastMessage);\n\t\t}\n\t}\n\n\tsetHiddenThinkingLabel(label: string): void {\n\t\tthis.hiddenThinkingLabel = label;\n\t\tif (this.lastMessage) {\n\t\t\tthis.updateContent(this.lastMessage);\n\t\t}\n\t}\n\n\toverride render(width: number): string[] {\n\t\tconst lines = super.render(width);\n\t\tif (this.hasToolCalls || lines.length === 0) {\n\t\t\treturn lines;\n\t\t}\n\n\t\tlines[0] = OSC133_ZONE_START + lines[0];\n\t\tlines[lines.length - 1] = OSC133_ZONE_END + OSC133_ZONE_FINAL + lines[lines.length - 1];\n\t\treturn lines;\n\t}\n\n\tupdateContent(message: AssistantMessage): void {\n\t\tthis.lastMessage = message;\n\n\t\t// Clear content container\n\t\tthis.contentContainer.clear();\n\n\t\tconst hasVisibleContent = message.content.some(\n\t\t\t(c) => (c.type === \"text\" && c.text.trim()) || (c.type === \"thinking\" && c.thinking.trim()),\n\t\t);\n\n\t\tif (hasVisibleContent) {\n\t\t\tthis.contentContainer.addChild(new Spacer(1));\n\t\t}\n\n\t\t// Render content in order\n\t\tfor (let i = 0; i < message.content.length; i++) {\n\t\t\tconst content = message.content[i];\n\t\t\tif (content.type === \"text\" && content.text.trim()) {\n\t\t\t\t// Assistant text messages with no background - trim the text\n\t\t\t\t// Set paddingY=0 to avoid extra spacing before tool executions\n\t\t\t\tthis.contentContainer.addChild(new Markdown(content.text.trim(), 1, 0, this.markdownTheme));\n\t\t\t} else if (content.type === \"thinking\" && content.thinking.trim()) {\n\t\t\t\t// Add spacing only when another visible assistant content block follows.\n\t\t\t\t// This avoids a superfluous blank line before separately-rendered tool execution blocks.\n\t\t\t\tconst hasVisibleContentAfter = message.content\n\t\t\t\t\t.slice(i + 1)\n\t\t\t\t\t.some((c) => (c.type === \"text\" && c.text.trim()) || (c.type === \"thinking\" && c.thinking.trim()));\n\n\t\t\t\tif (this.hideThinkingBlock) {\n\t\t\t\t\t// Show static thinking label when hidden\n\t\t\t\t\tthis.contentContainer.addChild(\n\t\t\t\t\t\tnew Text(theme.italic(theme.fg(\"thinkingText\", this.hiddenThinkingLabel)), 1, 0),\n\t\t\t\t\t);\n\t\t\t\t\tif (hasVisibleContentAfter) {\n\t\t\t\t\t\tthis.contentContainer.addChild(new Spacer(1));\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\t// Thinking traces in thinkingText color, italic, with ✻ prefix\n\t\t\t\t\tthis.contentContainer.addChild(\n\t\t\t\t\t\tnew Markdown(`✻ ${content.thinking.trim()}`, 1, 0, this.markdownTheme, {\n\t\t\t\t\t\t\tcolor: (text: string) => theme.fg(\"thinkingText\", text),\n\t\t\t\t\t\t\titalic: true,\n\t\t\t\t\t\t}),\n\t\t\t\t\t);\n\t\t\t\t\tif (hasVisibleContentAfter) {\n\t\t\t\t\t\tthis.contentContainer.addChild(new Spacer(1));\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// Check if aborted - show after partial content\n\t\t// But only if there are no tool calls (tool execution components will show the error)\n\t\tconst hasToolCalls = message.content.some((c) => c.type === \"toolCall\");\n\t\tthis.hasToolCalls = hasToolCalls;\n\t\tif (!hasToolCalls) {\n\t\t\tif (message.stopReason === \"aborted\") {\n\t\t\t\tconst abortMessage =\n\t\t\t\t\tmessage.errorMessage && message.errorMessage !== \"Request was aborted\"\n\t\t\t\t\t\t? message.errorMessage\n\t\t\t\t\t\t: \"Operation aborted\";\n\t\t\t\tif (hasVisibleContent) {\n\t\t\t\t\tthis.contentContainer.addChild(new Spacer(1));\n\t\t\t\t} else {\n\t\t\t\t\tthis.contentContainer.addChild(new Spacer(1));\n\t\t\t\t}\n\t\t\t\tthis.contentContainer.addChild(new Text(theme.fg(\"error\", abortMessage), 1, 0));\n\t\t\t} else if (message.stopReason === \"error\") {\n\t\t\t\tconst errorMsg = message.errorMessage || \"Unknown error\";\n\t\t\t\tthis.contentContainer.addChild(new Spacer(1));\n\t\t\t\tthis.contentContainer.addChild(new Text(theme.fg(\"error\", `Error: ${errorMsg}`), 1, 0));\n\t\t\t}\n\t\t}\n\t}\n}\n"]}
|
|
@@ -82,8 +82,8 @@ export class AssistantMessageComponent extends Container {
|
|
|
82
82
|
}
|
|
83
83
|
}
|
|
84
84
|
else {
|
|
85
|
-
// Thinking traces in thinkingText color, italic
|
|
86
|
-
this.contentContainer.addChild(new Markdown(content.thinking.trim()
|
|
85
|
+
// Thinking traces in thinkingText color, italic, with ✻ prefix
|
|
86
|
+
this.contentContainer.addChild(new Markdown(`✻ ${content.thinking.trim()}`, 1, 0, this.markdownTheme, {
|
|
87
87
|
color: (text) => theme.fg("thinkingText", text),
|
|
88
88
|
italic: true,
|
|
89
89
|
}));
|