@kolisachint/hoocode-agent 0.5.41 → 0.5.43
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 +111 -0
- package/dist/core/builtin-skills.d.ts +11 -0
- package/dist/core/builtin-skills.d.ts.map +1 -1
- package/dist/core/builtin-skills.js +31 -0
- package/dist/core/builtin-skills.js.map +1 -1
- package/dist/core/canvas/scaffold.d.ts +1 -1
- package/dist/core/canvas/scaffold.d.ts.map +1 -1
- package/dist/core/canvas/scaffold.js +100 -5
- package/dist/core/canvas/scaffold.js.map +1 -1
- package/dist/core/settings-defaults.d.ts +1 -0
- package/dist/core/settings-defaults.d.ts.map +1 -1
- package/dist/core/settings-defaults.js +1 -0
- package/dist/core/settings-defaults.js.map +1 -1
- package/dist/core/settings-manager.d.ts +14 -0
- package/dist/core/settings-manager.d.ts.map +1 -1
- package/dist/core/settings-manager.js +15 -0
- package/dist/core/settings-manager.js.map +1 -1
- package/dist/core/settings-types.d.ts +3 -0
- package/dist/core/settings-types.d.ts.map +1 -1
- package/dist/core/settings-types.js.map +1 -1
- package/dist/core/tools/webtools-shared.d.ts +53 -2
- package/dist/core/tools/webtools-shared.d.ts.map +1 -1
- package/dist/core/tools/webtools-shared.js +43 -2
- package/dist/core/tools/webtools-shared.js.map +1 -1
- package/dist/extensions/core/canvas.d.ts.map +1 -1
- package/dist/extensions/core/canvas.js +2 -1
- package/dist/extensions/core/canvas.js.map +1 -1
- package/dist/init-templates.generated.d.ts.map +1 -1
- package/dist/init-templates.generated.js +4 -0
- package/dist/init-templates.generated.js.map +1 -1
- package/dist/modes/interactive/components/settings-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/settings-selector.js +11 -0
- package/dist/modes/interactive/components/settings-selector.js.map +1 -1
- package/dist/modes/interactive/interactive-mode.d.ts +6 -0
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode.js +16 -0
- package/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/dist/modes/interactive/websearch-warning.d.ts +35 -0
- package/dist/modes/interactive/websearch-warning.d.ts.map +1 -0
- package/dist/modes/interactive/websearch-warning.js +40 -0
- package/dist/modes/interactive/websearch-warning.js.map +1 -0
- package/docs/settings.md +52 -2
- 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/code-review.md +61 -0
- package/templates/agents/security-review.md +69 -0
- package/templates/skills/artifact-design/SKILL.md +191 -0
- package/templates/skills/canvas-design/SKILL.md +117 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"canvas.js","sourceRoot":"","sources":["../../../src/extensions/core/canvas.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAErD,0EAA0E;AAC1E,MAAM,KAAK,GAAG,cAAc,CAAC,UAAU,CAAC;AAExC,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AAEjE,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AACnH,OAAO,EAEN,aAAa,EAEb,cAAc,GACd,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,qBAAqB,EAAE,MAAM,2DAA2D,CAAC;AAClG,OAAO,EAAE,kBAAkB,EAAE,cAAc,EAAE,MAAM,wCAAwC,CAAC;AAE5F,OAAO,EAAE,2BAA2B,EAAE,MAAM,4BAA4B,CAAC;AACzE,OAAO,EAAE,cAAc,EAAE,MAAM,uDAAuD,CAAC;A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OAAO,GAAG,OAAO,CAAC;QACxB,OAAO,GAAG,SAAS,CAAC;QACpB,KAAK,OAAO,EAAE,OAAO,EAAE,CAAC;IAAA,CACxB,CAAC,CAAC;AAAA,CACH","sourcesContent":["/**\n * `/canvas` — the interactive surface for canvas extensions.\n *\n * Design: `docs/canvas-extensions-design.md` §11. Deliberately thin: every decision\n * lives in `core/canvas/session.ts`, which is testable without a terminal, so this\n * file only renders and supplies an `AbortSignal`.\n *\n * The signal is the point of the loader. `BorderedLoader` already gives Esc-to-cancel\n * and exposes an `AbortSignal`, and `registry.open` accepts one — so a person's Esc\n * reaches the abandon path (§11.6) and the extension is told to release the port it\n * may already have bound, rather than the spinner merely disappearing.\n *\n * `/new-canvas` is registered here rather than beside `/new-skill` and friends\n * because it is not a file-writing command any more: it opens what it scaffolds\n * and hands the agent a brief to build it, which needs this file's session and\n * `pi.sendUserMessage`. Its decisions live in `core/canvas/scaffold.ts`.\n *\n * The agent tools register on the first successful open and stay for the session:\n * `registerTool` has no counterpart to remove a tool. So a session that never opens a\n * canvas pays nothing for them, which is the case that matters (§11.5); after the\n * first open they cost ~235 tokens and answer honestly when nothing is open.\n */\n\nimport { homedir } from \"node:os\";\nimport { getAgentDir } from \"../../config.js\";\nimport { CATEGORY_GLYPH } from \"../../core/brand.js\";\n\n/** Canvas extensions are extensions, so they wear the extension glyph. */\nconst GLYPH = CATEGORY_GLYPH.extensions;\n\nimport { isCanvasRefusal } from \"../../core/canvas/lifecycle.js\";\nimport type { CanvasInstance } from \"../../core/canvas/registry.js\";\nimport { CANVAS_HOMES, canvasBuildBrief, parseCanvasRequest, scaffoldCanvas } from \"../../core/canvas/scaffold.js\";\nimport {\n\ttype CanvasOverview,\n\tCanvasSession,\n\ttype CanvasSessionOptions,\n\tparseCanvasRef,\n} from \"../../core/canvas/session.js\";\nimport { getWorkspacePlatforms } from \"../../core/extensions/plugins/formats/platform-targets.js\";\nimport { isWorkspaceTrusted, trustWorkspace } from \"../../core/extensions/plugins/trust.js\";\nimport type { ExtensionAPI, ExtensionCommandContext } from \"../../core/extensions/types.js\";\nimport { createCanvasToolDefinitions } from \"../../core/tools/canvas.js\";\nimport { BorderedLoader } from \"../../modes/interactive/components/bordered-loader.js\";\n\nconst SUBCOMMANDS = [\"list\", \"open\", \"close\", \"reload\", \"rename\", \"remove\"] as const;\n\n/** How an open attempt ended. `custom()` resolves with exactly one of these. */\ntype OpenOutcome =\n\t| { kind: \"opened\"; instance: CanvasInstance }\n\t| { kind: \"failed\"; message: string }\n\t| { kind: \"cancelled\" };\n\nfunction describeInstance(instance: CanvasInstance): string {\n\tconst title = instance.title ?? instance.canvasId;\n\treturn `${instance.instanceId} ${title}${instance.url ? ` ${instance.url}` : \"\"}`;\n}\n\nfunction renderOverview(overview: CanvasOverview): string {\n\tconst lines: string[] = [];\n\tif (!overview.availability.available) {\n\t\tlines.push(`Canvases are unavailable: ${overview.availability.reason}`, \"\");\n\t}\n\tif (overview.listings.length === 0) {\n\t\tlines.push(\n\t\t\t\"No canvas extensions found in .agents/extensions, .github/extensions, ~/.copilot/extensions,\",\n\t\t\t\"or any installed plugin. Create one with /new-canvas <what it should do>, or install one with /plugin.\",\n\t\t);\n\t\treturn lines.join(\"\\n\");\n\t}\n\tfor (const listing of overview.listings) {\n\t\tconst name = listing.canvasId ? `${listing.extensionId}:${listing.canvasId}` : listing.extensionId;\n\t\tconst label = listing.displayName ? ` ${listing.displayName}` : \"\";\n\t\tif (listing.withheld === \"untrusted-workspace\") {\n\t\t\tlines.push(`${GLYPH} ${name}${label} [withheld: untrusted workspace]`);\n\t\t\tcontinue;\n\t\t}\n\t\tlines.push(`${GLYPH} ${name}${label} (${listing.scope})`);\n\t\tfor (const instance of listing.open) {\n\t\t\tlines.push(` open ${describeInstance(instance)}`);\n\t\t\t// What a canvas can do is otherwise visible only to the model, through\n\t\t\t// `list_canvas_capabilities` — so the person driving the session could not\n\t\t\t// see the surface they were being asked about. Only for open instances,\n\t\t\t// because actions come from running the code (§5.1).\n\t\t\tconst actions = overview.actionsByInstance.get(instance.instanceId) ?? [];\n\t\t\tif (actions.length > 0) lines.push(` actions ${actions.join(\", \")}`);\n\t\t}\n\t}\n\tif (overview.withheldCount > 0) {\n\t\tlines.push(\n\t\t\t\"\",\n\t\t\t`${overview.withheldCount} extension(s) came with this repository and are withheld. Run /plugin trust to allow this directory to run code it ships.`,\n\t\t);\n\t}\n\treturn lines.join(\"\\n\");\n}\n\n/**\n * Test seams, and only that.\n *\n * `/new-canvas` opens what it writes, so driving it without a terminal needs a\n * runtime that does not depend on hoocode having been built, and a home\n * directory that is not the developer's. Everything else this file does is\n * decided in `core/canvas/`, where it is testable without any of this.\n */\nexport interface CanvasSetupOverrides {\n\thomeDir?: string;\n\tresolveRuntime?: CanvasSessionOptions[\"resolveRuntime\"];\n}\n\nexport function setupCanvas(pi: ExtensionAPI, overrides?: CanvasSetupOverrides): void {\n\tlet session: CanvasSession | undefined;\n\tlet toolsRegistered = false;\n\t/**\n\t * Points at the most recent command's UI.\n\t *\n\t * A canvas keeps talking after the command that opened it has returned — logs,\n\t * stray stdout, a leaked-port warning — so the callbacks cannot close over one\n\t * invocation's `ctx`.\n\t */\n\tlet notify: (message: string, type?: \"info\" | \"warning\" | \"error\") => void = () => {};\n\n\tconst ensureSession = (ctx: ExtensionCommandContext): CanvasSession => {\n\t\tnotify = (message, type) => ctx.ui.notify(message, type);\n\t\tsession ??= new CanvasSession({\n\t\t\tcwd: ctx.cwd,\n\t\t\thomeDir: overrides?.homeDir ?? homedir(),\n\t\t\tagentDir: getAgentDir(),\n\t\t\tresolveRuntime: overrides?.resolveRuntime,\n\t\t\t// A canvas's own diagnostics are the user's business: a stray stdout line means\n\t\t\t// its author reached for console.log, and a possible leaked port is worth saying.\n\t\t\tonLog: (id, message) => notify(`[canvas ${id}] ${message}`, \"info\"),\n\t\t\tonStray: (id, line) => notify(`[canvas ${id}] non-protocol stdout (use session.log): ${line}`, \"warning\"),\n\t\t\tonDiagnostic: (id, message) => notify(`[canvas ${id}] ${message}`, \"warning\"),\n\t\t});\n\t\treturn session;\n\t};\n\n\tconst registerToolsOnce = (canvas: CanvasSession): void => {\n\t\tif (toolsRegistered) return;\n\t\tconst registry = canvas.registryOrUndefined();\n\t\tif (!registry) return;\n\t\ttoolsRegistered = true;\n\t\tfor (const definition of createCanvasToolDefinitions(registry)) pi.registerTool(definition);\n\t};\n\n\t/**\n\t * Open a canvas behind a cancellable loader.\n\t *\n\t * Shared by `/canvas open` and `/new-canvas`, which want identical behaviour:\n\t * opening forks a process and binds a port, so it can be slow and must be\n\t * interruptible. The loader's signal is what makes Esc mean something — it\n\t * reaches the registry's abandon path, which tells the extension to release a\n\t * port it may already have bound. Outside a terminal (--print, RPC) there is\n\t * nothing to draw and nothing to press, so the open simply runs.\n\t */\n\tconst openWithLoader = async (\n\t\tcanvas: CanvasSession,\n\t\tref: { extensionId: string; canvasId?: string },\n\t\tctx: ExtensionCommandContext,\n\t): Promise<OpenOutcome | undefined> =>\n\t\tctx.hasUI\n\t\t\t? await ctx.ui.custom<OpenOutcome | undefined>((tui, theme, _keybindings, done) => {\n\t\t\t\t\tconst loader = new BorderedLoader(tui, theme, `Opening ${ref.extensionId}…`);\n\t\t\t\t\tloader.onAbort = () => done({ kind: \"cancelled\" });\n\t\t\t\t\tvoid canvas\n\t\t\t\t\t\t.open(ref, { signal: loader.signal })\n\t\t\t\t\t\t.then((instance) => done({ kind: \"opened\", instance }))\n\t\t\t\t\t\t// Cancelling races: the signal rejects the pending call at the same moment\n\t\t\t\t\t\t// onAbort fires, and whichever lands first resolves `custom`. Deciding from\n\t\t\t\t\t\t// the signal rather than from who won means a cancel always reads as a\n\t\t\t\t\t\t// cancel instead of surfacing as an error.\n\t\t\t\t\t\t.catch((error: unknown) =>\n\t\t\t\t\t\t\tdone(\n\t\t\t\t\t\t\t\tloader.signal.aborted\n\t\t\t\t\t\t\t\t\t? { kind: \"cancelled\" }\n\t\t\t\t\t\t\t\t\t: { kind: \"failed\", message: error instanceof Error ? error.message : String(error) },\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t);\n\t\t\t\t\treturn loader;\n\t\t\t\t})\n\t\t\t: await canvas\n\t\t\t\t\t.open(ref)\n\t\t\t\t\t.then((instance): OpenOutcome => ({ kind: \"opened\", instance }))\n\t\t\t\t\t.catch(\n\t\t\t\t\t\t(error: unknown): OpenOutcome => ({\n\t\t\t\t\t\t\tkind: \"failed\",\n\t\t\t\t\t\t\tmessage: error instanceof Error ? error.message : String(error),\n\t\t\t\t\t\t}),\n\t\t\t\t\t);\n\n\tpi.registerCommand(\"canvas\", {\n\t\tdescription:\n\t\t\t\"Work with canvas extensions. /canvas list | open <extension>[:<canvas>] | reload [extension] | close <instanceId> | rename <extension> <new-name> | remove <extension>\",\n\t\tgetArgumentCompletions: (prefix: string) =>\n\t\t\tSUBCOMMANDS.filter((name) => name.startsWith(prefix)).map((name) => ({ value: name, label: name })),\n\t\thandler: async (args: string, ctx: ExtensionCommandContext): Promise<void> => {\n\t\t\tconst trimmed = args.trim();\n\t\t\tconst canvas = ensureSession(ctx);\n\n\t\t\tif (trimmed.length === 0 || trimmed === \"list\") {\n\t\t\t\tctx.ui.notify(renderOverview(await canvas.list()), \"info\");\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (trimmed.startsWith(\"close\")) {\n\t\t\t\tconst instanceId = trimmed.slice(\"close\".length).trim();\n\t\t\t\tif (!instanceId) {\n\t\t\t\t\tctx.ui.notify(\"Usage: /canvas close <instanceId> (see /canvas list)\", \"warning\");\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tconst closed = await canvas.close(instanceId);\n\t\t\t\tif (!closed) ctx.ui.notify(`No open canvas instance \"${instanceId}\".`, \"warning\");\n\t\t\t\telse ctx.ui.notify(`Closed ${closed.canvasId} (${closed.instanceId}).`, \"info\");\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (trimmed.startsWith(\"reload\")) {\n\t\t\t\t// A reload re-forks the extension, so it can take as long as an open and is\n\t\t\t\t// worth being able to abandon — but unlike an open there is nothing to\n\t\t\t\t// abandon *to*: the registry keeps the old child serving until the new one\n\t\t\t\t// answers, so a cancel here just stops waiting.\n\t\t\t\tconst requested = trimmed.slice(\"reload\".length).trim();\n\t\t\t\tconst running = canvas.runningExtensionIds();\n\t\t\t\tconst extensionId = requested || (running.length === 1 ? running[0] : undefined);\n\t\t\t\tif (!extensionId) {\n\t\t\t\t\tctx.ui.notify(\n\t\t\t\t\t\trunning.length === 0\n\t\t\t\t\t\t\t? \"Nothing is open, so there is nothing to reload. Open a canvas first with /canvas open <extension>.\"\n\t\t\t\t\t\t\t: `Several extensions are open; name one: ${running.join(\", \")}.`,\n\t\t\t\t\t\t\"warning\",\n\t\t\t\t\t);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\ttry {\n\t\t\t\t\tconst result = await canvas.reload(extensionId);\n\t\t\t\t\tconst lines = [`Reloaded ${result.extensionId} from disk.`];\n\t\t\t\t\t// Same reason the tool reports it: an edit to `actions: [...]` is\n\t\t\t\t\t// otherwise invisible, and a typo there fails by the action simply\n\t\t\t\t\t// not being there.\n\t\t\t\t\tconst { added, removed, changed } = result.actions;\n\t\t\t\t\tif (added.length > 0) lines.push(` + ${added.join(\", \")}`);\n\t\t\t\t\tif (removed.length > 0) lines.push(` - ${removed.join(\", \")}`);\n\t\t\t\t\tif (changed.length > 0) lines.push(` ~ ${changed.join(\", \")} (description or schema)`);\n\t\t\t\t\tfor (const instance of result.reopened) {\n\t\t\t\t\t\t// The url is the point of saying anything: the extension binds a new\n\t\t\t\t\t\t// port and mints a new token on every open, so the tab the person has\n\t\t\t\t\t\t// in front of them is now pointing at a closed port.\n\t\t\t\t\t\tlines.push(` ${describeInstance(instance)}`);\n\t\t\t\t\t}\n\t\t\t\t\tif (result.reopened.length > 0) lines.push(\"\", \"Open the new url(s) — the previous tab is dead.\");\n\t\t\t\t\tfor (const drop of result.dropped) {\n\t\t\t\t\t\tlines.push(` ${drop.canvasId} (${drop.instanceId}) did not come back: ${drop.reason}`);\n\t\t\t\t\t}\n\t\t\t\t\tctx.ui.notify(lines.join(\"\\n\"), result.dropped.length > 0 ? \"warning\" : \"info\");\n\t\t\t\t} catch (error) {\n\t\t\t\t\t// The registry only swaps children once the new one is ready, so the\n\t\t\t\t\t// canvas the person is looking at survived this. Say so, or they will\n\t\t\t\t\t// think they just lost it.\n\t\t\t\t\tctx.ui.notify(\n\t\t\t\t\t\t`Reloading ${extensionId} failed, so it is still running the code it was started with: ` +\n\t\t\t\t\t\t\t`${error instanceof Error ? error.message : String(error)}`,\n\t\t\t\t\t\t\"error\",\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (trimmed.startsWith(\"rename\")) {\n\t\t\t\tconst [from, to, ...rest] = trimmed.slice(\"rename\".length).trim().split(/\\s+/).filter(Boolean);\n\t\t\t\tif (!from || !to || rest.length > 0) {\n\t\t\t\t\tctx.ui.notify(`Usage: /canvas rename <extension> <new-name> (see /canvas list)`, \"warning\");\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\t// Renaming closes whatever the extension had open, because the directory\n\t\t\t\t// is about to move out from under it. Say so before doing it, not after.\n\t\t\t\tconst wasOpen = canvas.instances().filter((instance) => instance.extensionId === from);\n\t\t\t\tconst result = await canvas.rename(from, to);\n\t\t\t\tif (isCanvasRefusal(result)) {\n\t\t\t\t\tctx.ui.notify(`/canvas rename: ${result.detail}`, \"warning\");\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tconst lines = [`Renamed ${result.from} → ${result.to}.`, ` ${result.dir}`];\n\t\t\t\tif (result.rewrites.length > 0) {\n\t\t\t\t\tlines.push(\"\", \"Rewrote in extension.mjs:\");\n\t\t\t\t\tfor (const rewrite of result.rewrites) lines.push(` line ${rewrite.line}: ${rewrite.after.trim()}`);\n\t\t\t\t}\n\t\t\t\tif (result.leftovers.length > 0) {\n\t\t\t\t\t// Prose is not identity, so it is reported rather than edited — a rename\n\t\t\t\t\t// that silently rewrote a description would be worse than one that\n\t\t\t\t\t// admits what it left.\n\t\t\t\t\tlines.push(\n\t\t\t\t\t\t\"\",\n\t\t\t\t\t\t`\"${result.from}\" still appears on line(s) ${result.leftovers.join(\", \")}; those look like prose, so they were left alone.`,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tif (wasOpen.length > 0) lines.push(\"\", `Closed ${wasOpen.length} open instance(s) to move the directory.`);\n\t\t\t\tlines.push(\"\", `Open it with /canvas open ${result.to}.`);\n\t\t\t\tctx.ui.notify(lines.join(\"\\n\"), \"info\");\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (trimmed.startsWith(\"remove\")) {\n\t\t\t\tconst target = trimmed.slice(\"remove\".length).trim();\n\t\t\t\tif (!target) {\n\t\t\t\t\tctx.ui.notify(\"Usage: /canvas remove <extension> (see /canvas list)\", \"warning\");\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tconst known = canvas.knownExtensionIds();\n\t\t\t\tif (!known.includes(target)) {\n\t\t\t\t\tctx.ui.notify(`No canvas extension \"${target}\" (found: ${known.join(\", \") || \"none\"}).`, \"warning\");\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\t// Deleting source is not undoable from here, so it is confirmed — and\n\t\t\t\t// outside a terminal there is nobody to ask, so it is refused rather than\n\t\t\t\t// assumed. `--print` and RPC should not be able to delete a directory\n\t\t\t\t// because a command happened to be piped in.\n\t\t\t\tif (!ctx.hasUI) {\n\t\t\t\t\tctx.ui.notify(\n\t\t\t\t\t\t`/canvas remove needs to ask before deleting ${target}, and there is no interactive surface here. Delete the directory yourself, or run this in a terminal.`,\n\t\t\t\t\t\t\"warning\",\n\t\t\t\t\t);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tconst confirmed = await ctx.ui.confirm(\n\t\t\t\t\t`Delete canvas \"${target}\"?`,\n\t\t\t\t\t\"This deletes the extension directory and everything in it. It is not undoable from here.\",\n\t\t\t\t);\n\t\t\t\tif (!confirmed) {\n\t\t\t\t\tctx.ui.notify(`Left ${target} alone.`, \"info\");\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tconst openCount = canvas.instances().filter((instance) => instance.extensionId === target).length;\n\t\t\t\tconst result = await canvas.remove(target);\n\t\t\t\tif (isCanvasRefusal(result)) {\n\t\t\t\t\tctx.ui.notify(`/canvas remove: ${result.detail}`, \"warning\");\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tctx.ui.notify(\n\t\t\t\t\t[\n\t\t\t\t\t\t`Removed ${result.id}.`,\n\t\t\t\t\t\t` ${result.dir}`,\n\t\t\t\t\t\topenCount > 0 ? `Closed ${openCount} open instance(s) first.` : \"\",\n\t\t\t\t\t]\n\t\t\t\t\t\t.filter((line) => line.length > 0)\n\t\t\t\t\t\t.join(\"\\n\"),\n\t\t\t\t\t\"info\",\n\t\t\t\t);\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (!trimmed.startsWith(\"open\")) {\n\t\t\t\tctx.ui.notify(`Unknown subcommand. Use ${SUBCOMMANDS.join(\", \")}.`, \"warning\");\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst ref = parseCanvasRef(trimmed.slice(\"open\".length));\n\t\t\tif (!ref) {\n\t\t\t\tctx.ui.notify(\"Usage: /canvas open <extension>[:<canvas>] (see /canvas list)\", \"warning\");\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst outcome = await openWithLoader(canvas, ref, ctx);\n\n\t\t\t// `custom` can also settle on its own when the overlay is dismissed, without\n\t\t\t// our `done` ever running — an escape that closes the surface leaves no\n\t\t\t// outcome. Treat that as the cancel it is rather than reading `.kind` off\n\t\t\t// undefined and failing silently.\n\t\t\tif (!outcome || outcome.kind === \"cancelled\") {\n\t\t\t\t// KNOWN ISSUE: this confirmation does not render when the cancel came from the\n\t\t\t\t// loader's own escape handling, though every effect of cancelling is correct\n\t\t\t\t// and verified (the open rejects, no instance is registered, and the extension\n\t\t\t\t// is told to close the instance it never finished opening). Ruled out: the\n\t\t\t\t// continuation does run and `ctx.ui.notify` works here — the failure path\n\t\t\t\t// through the same lines renders its error, and the canvas's own diagnostic\n\t\t\t\t// arrives moments later through this very function. Deferring a tick did not\n\t\t\t\t// help either. Left as an unexplained cosmetic gap rather than papered over\n\t\t\t\t// with a sleep; the loader disappearing is itself the signal.\n\t\t\t\tctx.ui.notify(\"Canvas open cancelled.\", \"info\");\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (outcome.kind === \"failed\") {\n\t\t\t\tctx.ui.notify(outcome.message, \"error\");\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tregisterToolsOnce(canvas);\n\t\t\tctx.ui.notify(\n\t\t\t\t[\n\t\t\t\t\t`Opened ${outcome.instance.canvasId} (${outcome.instance.instanceId}).`,\n\t\t\t\t\toutcome.instance.url ? `Open in a browser: ${outcome.instance.url}` : \"\",\n\t\t\t\t\t\"The agent can now read and drive it; close it with /canvas close <instanceId>.\",\n\t\t\t\t]\n\t\t\t\t\t.filter((line) => line.length > 0)\n\t\t\t\t\t.join(\"\\n\"),\n\t\t\t\t\"info\",\n\t\t\t);\n\t\t},\n\t});\n\n\t// ── /new-canvas <name> | <description> ────────────────────────────────────\n\t// Authoring, in Copilot's `/create-canvas` shape: describe what you want, the\n\t// agent writes it, and it is already open while it does. Design:\n\t// `docs/canvas-extensions-design.md` §9 Phase 3, §13.\n\t//\n\t// Unlike the other `/new-*` scaffolds this one needs no /reload: canvases are\n\t// discovered when /canvas runs, not loaded at session start.\n\n\tpi.registerCommand(\"new-canvas\", {\n\t\tdescription:\n\t\t\t\"Create a canvas extension. Usage: /new-canvas <what it should do> | /new-canvas <name> | /new-canvas <name>: <what it should do>\",\n\t\tgetArgumentCompletions: () => [],\n\t\thandler: async (args: string, ctx: ExtensionCommandContext): Promise<void> => {\n\t\t\tconst request = parseCanvasRequest(args);\n\t\t\tif (typeof request === \"string\") {\n\t\t\t\tctx.ui.notify(`/new-canvas: ${request}`, \"warning\");\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// `--platform claude` is dropped rather than redirected: Claude has no\n\t\t\t// canvas convention, and silently writing into someone else's marker\n\t\t\t// directory would put an extension where that vendor will never look.\n\t\t\tconst requested = getWorkspacePlatforms() ?? [\"agents\"];\n\t\t\tconst targets = requested.filter((platform) => CANVAS_HOMES[platform] !== undefined);\n\t\t\tif (targets.length === 0) {\n\t\t\t\tctx.ui.notify(\n\t\t\t\t\t`/new-canvas: no canvas home for platform \"${requested.join(\", \")}\". ` +\n\t\t\t\t\t\t\"Canvas extensions exist under .agents/extensions (agents) and .github/extensions (github) only.\",\n\t\t\t\t\t\"warning\",\n\t\t\t\t);\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst { created, skipped } = scaffoldCanvas(ctx.cwd, request.name, targets);\n\n\t\t\t// A canvas lands in the working tree, which is where the trust gate looks\n\t\t\t// (`core/canvas/trust.ts`) — so without this the canvas you just asked for\n\t\t\t// is withheld the moment you try to open it, and refused with \"came with\n\t\t\t// this repository\", which is not true of a file created seconds ago.\n\t\t\t//\n\t\t\t// Granting is the same call `/plugin install --scope project` makes, for\n\t\t\t// the same stated reason: a person typing this command in this directory\n\t\t\t// is the human act workspace trust asks for. It is deliberately wider than\n\t\t\t// this one canvas — it also lets plugins already committed here run their\n\t\t\t// hooks and MCP servers — so it is said out loud and pointed at its\n\t\t\t// reverse, never done silently.\n\t\t\tlet trustNote = \"\";\n\t\t\tif (created.length > 0 && !isWorkspaceTrusted(ctx.cwd, getAgentDir())) {\n\t\t\t\ttrustWorkspace(ctx.cwd, getAgentDir());\n\t\t\t\ttrustNote =\n\t\t\t\t\t`Trusted this workspace so the canvas can run. Plugins committed here may now run hooks ` +\n\t\t\t\t\t`and MCP servers too; \\`/plugin untrust\\` reverses it.`;\n\t\t\t}\n\n\t\t\tif (created.length === 0) {\n\t\t\t\tctx.ui.notify(\n\t\t\t\t\t[\n\t\t\t\t\t\t\"Nothing created — these already exist:\",\n\t\t\t\t\t\t...skipped.map((file) => ` ${file}`),\n\t\t\t\t\t\t\"\",\n\t\t\t\t\t\t`Open the existing one with /canvas open ${request.name}, or pick another name.`,\n\t\t\t\t\t].join(\"\\n\"),\n\t\t\t\t\t\"warning\",\n\t\t\t\t);\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// Open before saying anything. Copilot's `/create-canvas` puts the canvas\n\t\t\t// in front of the person and *then* builds it, and the order is the point:\n\t\t\t// a build brief that can name a live url and instance id is a different\n\t\t\t// instruction than one that cannot, and the person watches it change.\n\t\t\tconst canvas = ensureSession(ctx);\n\t\t\tconst outcome = await openWithLoader(canvas, { extensionId: request.name }, ctx);\n\t\t\tconst opened = outcome?.kind === \"opened\" ? outcome.instance : undefined;\n\t\t\tif (opened) registerToolsOnce(canvas);\n\n\t\t\tconst lines = [\"Canvas created:\", ...created.map((file) => ` ${file}`)];\n\t\t\tif (skipped.length > 0) lines.push(\"Skipped (already exist):\", ...skipped.map((file) => ` ${file}`));\n\t\t\tlines.push(\"\");\n\t\t\tif (opened) {\n\t\t\t\tlines.push(`Opened ${opened.canvasId} (${opened.instanceId}).`);\n\t\t\t\tif (opened.url) lines.push(`Open in a browser: ${opened.url}`);\n\t\t\t} else if (outcome?.kind === \"failed\") {\n\t\t\t\t// Not fatal: the file is written and discoverable, so say what broke and\n\t\t\t\t// leave them a way in rather than making it look like nothing happened.\n\t\t\t\tlines.push(\n\t\t\t\t\t`Created, but opening it failed: ${outcome.message}`,\n\t\t\t\t\t`Retry with /canvas open ${request.name}.`,\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\tlines.push(`Opening cancelled. Open it when you want with /canvas open ${request.name}.`);\n\t\t\t}\n\t\t\tif (trustNote) lines.push(\"\", trustNote);\n\n\t\t\tif (request.description) {\n\t\t\t\tlines.push(\n\t\t\t\t\t\"\",\n\t\t\t\t\t`Building it now from: \"${request.description}\"`,\n\t\t\t\t\t\"Steer it like any other turn, or interrupt to take over the file yourself.\",\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\tlines.push(\"\", `Edit ${created[0]} and run /canvas reload ${request.name} to see each change.`);\n\t\t\t}\n\t\t\tctx.ui.notify(lines.join(\"\\n\"), \"info\");\n\n\t\t\t// The half that makes this `/create-canvas` rather than a scaffold. Queued\n\t\t\t// as a follow-up so it lands on the next turn whether or not the agent is\n\t\t\t// mid-stream, and only when a description was given: `/new-canvas my-board`\n\t\t\t// still means \"give me the template\", and starting a build nobody asked for\n\t\t\t// would burn a turn and overwrite the file they meant to edit.\n\t\t\tif (request.description) {\n\t\t\t\tawait pi.sendUserMessage(\n\t\t\t\t\tcanvasBuildBrief(\n\t\t\t\t\t\trequest.name,\n\t\t\t\t\t\trequest.description,\n\t\t\t\t\t\tcreated[0] as string,\n\t\t\t\t\t\topened ? { instanceId: opened.instanceId, url: opened.url } : undefined,\n\t\t\t\t\t),\n\t\t\t\t\t{ deliverAs: \"followUp\" },\n\t\t\t\t);\n\t\t\t}\n\t\t},\n\t});\n\n\t// Teardown on shutdown (§6): a browser tab gives no close signal, so without this\n\t// every child and loopback port outlives the session. `session_shutdown` is where\n\t// loop.ts stops its scheduler, and it is synchronous, so the dispose is fired and\n\t// not awaited.\n\tpi.on(\"session_shutdown\", () => {\n\t\tconst closing = session;\n\t\tsession = undefined;\n\t\tvoid closing?.dispose();\n\t});\n}\n"]}
|
|
1
|
+
{"version":3,"file":"canvas.js","sourceRoot":"","sources":["../../../src/extensions/core/canvas.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AAErE,0EAA0E;AAC1E,MAAM,KAAK,GAA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AC,eAAe,CACvB,gBAAgB,CACf,OAAO,CAAC,IAAI,EACZ,OAAO,CAAC,WAAW,EACnB,OAAO,CAAC,CAAC,CAAW,EACpB,MAAM,CAAC,CAAC,CAAC,EAAE,UAAU,EAAE,MAAM,CAAC,UAAU,EAAE,GAAG,EAAE,MAAM,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,SAAS,EACvE,qBAAqB,EAAE,CACvB,EACD,EAAE,SAAS,EAAE,UAAU,EAAE,CACzB,CAAC;YACH,CAAC;QAAA,CACD;KACD,CAAC,CAAC;IAEH,mFAAkF;IAClF,kFAAkF;IAClF,kFAAkF;IAClF,eAAe;IACf,EAAE,CAAC,EAAE,CAAC,kBAAkB,EAAE,GAAG,EAAE,CAAC;QAC/B,MAAM,OAAO,GAAG,OAAO,CAAC;QACxB,OAAO,GAAG,SAAS,CAAC;QACpB,KAAK,OAAO,EAAE,OAAO,EAAE,CAAC;IAAA,CACxB,CAAC,CAAC;AAAA,CACH","sourcesContent":["/**\n * `/canvas` — the interactive surface for canvas extensions.\n *\n * Design: `docs/canvas-extensions-design.md` §11. Deliberately thin: every decision\n * lives in `core/canvas/session.ts`, which is testable without a terminal, so this\n * file only renders and supplies an `AbortSignal`.\n *\n * The signal is the point of the loader. `BorderedLoader` already gives Esc-to-cancel\n * and exposes an `AbortSignal`, and `registry.open` accepts one — so a person's Esc\n * reaches the abandon path (§11.6) and the extension is told to release the port it\n * may already have bound, rather than the spinner merely disappearing.\n *\n * `/new-canvas` is registered here rather than beside `/new-skill` and friends\n * because it is not a file-writing command any more: it opens what it scaffolds\n * and hands the agent a brief to build it, which needs this file's session and\n * `pi.sendUserMessage`. Its decisions live in `core/canvas/scaffold.ts`.\n *\n * The agent tools register on the first successful open and stay for the session:\n * `registerTool` has no counterpart to remove a tool. So a session that never opens a\n * canvas pays nothing for them, which is the case that matters (§11.5); after the\n * first open they cost ~235 tokens and answer honestly when nothing is open.\n */\n\nimport { homedir } from \"node:os\";\nimport { getAgentDir } from \"../../config.js\";\nimport { CATEGORY_GLYPH } from \"../../core/brand.js\";\nimport { canvasDesignGuidePath } from \"../../core/builtin-skills.js\";\n\n/** Canvas extensions are extensions, so they wear the extension glyph. */\nconst GLYPH = CATEGORY_GLYPH.extensions;\n\nimport { isCanvasRefusal } from \"../../core/canvas/lifecycle.js\";\nimport type { CanvasInstance } from \"../../core/canvas/registry.js\";\nimport { CANVAS_HOMES, canvasBuildBrief, parseCanvasRequest, scaffoldCanvas } from \"../../core/canvas/scaffold.js\";\nimport {\n\ttype CanvasOverview,\n\tCanvasSession,\n\ttype CanvasSessionOptions,\n\tparseCanvasRef,\n} from \"../../core/canvas/session.js\";\nimport { getWorkspacePlatforms } from \"../../core/extensions/plugins/formats/platform-targets.js\";\nimport { isWorkspaceTrusted, trustWorkspace } from \"../../core/extensions/plugins/trust.js\";\nimport type { ExtensionAPI, ExtensionCommandContext } from \"../../core/extensions/types.js\";\nimport { createCanvasToolDefinitions } from \"../../core/tools/canvas.js\";\nimport { BorderedLoader } from \"../../modes/interactive/components/bordered-loader.js\";\n\nconst SUBCOMMANDS = [\"list\", \"open\", \"close\", \"reload\", \"rename\", \"remove\"] as const;\n\n/** How an open attempt ended. `custom()` resolves with exactly one of these. */\ntype OpenOutcome =\n\t| { kind: \"opened\"; instance: CanvasInstance }\n\t| { kind: \"failed\"; message: string }\n\t| { kind: \"cancelled\" };\n\nfunction describeInstance(instance: CanvasInstance): string {\n\tconst title = instance.title ?? instance.canvasId;\n\treturn `${instance.instanceId} ${title}${instance.url ? ` ${instance.url}` : \"\"}`;\n}\n\nfunction renderOverview(overview: CanvasOverview): string {\n\tconst lines: string[] = [];\n\tif (!overview.availability.available) {\n\t\tlines.push(`Canvases are unavailable: ${overview.availability.reason}`, \"\");\n\t}\n\tif (overview.listings.length === 0) {\n\t\tlines.push(\n\t\t\t\"No canvas extensions found in .agents/extensions, .github/extensions, ~/.copilot/extensions,\",\n\t\t\t\"or any installed plugin. Create one with /new-canvas <what it should do>, or install one with /plugin.\",\n\t\t);\n\t\treturn lines.join(\"\\n\");\n\t}\n\tfor (const listing of overview.listings) {\n\t\tconst name = listing.canvasId ? `${listing.extensionId}:${listing.canvasId}` : listing.extensionId;\n\t\tconst label = listing.displayName ? ` ${listing.displayName}` : \"\";\n\t\tif (listing.withheld === \"untrusted-workspace\") {\n\t\t\tlines.push(`${GLYPH} ${name}${label} [withheld: untrusted workspace]`);\n\t\t\tcontinue;\n\t\t}\n\t\tlines.push(`${GLYPH} ${name}${label} (${listing.scope})`);\n\t\tfor (const instance of listing.open) {\n\t\t\tlines.push(` open ${describeInstance(instance)}`);\n\t\t\t// What a canvas can do is otherwise visible only to the model, through\n\t\t\t// `list_canvas_capabilities` — so the person driving the session could not\n\t\t\t// see the surface they were being asked about. Only for open instances,\n\t\t\t// because actions come from running the code (§5.1).\n\t\t\tconst actions = overview.actionsByInstance.get(instance.instanceId) ?? [];\n\t\t\tif (actions.length > 0) lines.push(` actions ${actions.join(\", \")}`);\n\t\t}\n\t}\n\tif (overview.withheldCount > 0) {\n\t\tlines.push(\n\t\t\t\"\",\n\t\t\t`${overview.withheldCount} extension(s) came with this repository and are withheld. Run /plugin trust to allow this directory to run code it ships.`,\n\t\t);\n\t}\n\treturn lines.join(\"\\n\");\n}\n\n/**\n * Test seams, and only that.\n *\n * `/new-canvas` opens what it writes, so driving it without a terminal needs a\n * runtime that does not depend on hoocode having been built, and a home\n * directory that is not the developer's. Everything else this file does is\n * decided in `core/canvas/`, where it is testable without any of this.\n */\nexport interface CanvasSetupOverrides {\n\thomeDir?: string;\n\tresolveRuntime?: CanvasSessionOptions[\"resolveRuntime\"];\n}\n\nexport function setupCanvas(pi: ExtensionAPI, overrides?: CanvasSetupOverrides): void {\n\tlet session: CanvasSession | undefined;\n\tlet toolsRegistered = false;\n\t/**\n\t * Points at the most recent command's UI.\n\t *\n\t * A canvas keeps talking after the command that opened it has returned — logs,\n\t * stray stdout, a leaked-port warning — so the callbacks cannot close over one\n\t * invocation's `ctx`.\n\t */\n\tlet notify: (message: string, type?: \"info\" | \"warning\" | \"error\") => void = () => {};\n\n\tconst ensureSession = (ctx: ExtensionCommandContext): CanvasSession => {\n\t\tnotify = (message, type) => ctx.ui.notify(message, type);\n\t\tsession ??= new CanvasSession({\n\t\t\tcwd: ctx.cwd,\n\t\t\thomeDir: overrides?.homeDir ?? homedir(),\n\t\t\tagentDir: getAgentDir(),\n\t\t\tresolveRuntime: overrides?.resolveRuntime,\n\t\t\t// A canvas's own diagnostics are the user's business: a stray stdout line means\n\t\t\t// its author reached for console.log, and a possible leaked port is worth saying.\n\t\t\tonLog: (id, message) => notify(`[canvas ${id}] ${message}`, \"info\"),\n\t\t\tonStray: (id, line) => notify(`[canvas ${id}] non-protocol stdout (use session.log): ${line}`, \"warning\"),\n\t\t\tonDiagnostic: (id, message) => notify(`[canvas ${id}] ${message}`, \"warning\"),\n\t\t});\n\t\treturn session;\n\t};\n\n\tconst registerToolsOnce = (canvas: CanvasSession): void => {\n\t\tif (toolsRegistered) return;\n\t\tconst registry = canvas.registryOrUndefined();\n\t\tif (!registry) return;\n\t\ttoolsRegistered = true;\n\t\tfor (const definition of createCanvasToolDefinitions(registry)) pi.registerTool(definition);\n\t};\n\n\t/**\n\t * Open a canvas behind a cancellable loader.\n\t *\n\t * Shared by `/canvas open` and `/new-canvas`, which want identical behaviour:\n\t * opening forks a process and binds a port, so it can be slow and must be\n\t * interruptible. The loader's signal is what makes Esc mean something — it\n\t * reaches the registry's abandon path, which tells the extension to release a\n\t * port it may already have bound. Outside a terminal (--print, RPC) there is\n\t * nothing to draw and nothing to press, so the open simply runs.\n\t */\n\tconst openWithLoader = async (\n\t\tcanvas: CanvasSession,\n\t\tref: { extensionId: string; canvasId?: string },\n\t\tctx: ExtensionCommandContext,\n\t): Promise<OpenOutcome | undefined> =>\n\t\tctx.hasUI\n\t\t\t? await ctx.ui.custom<OpenOutcome | undefined>((tui, theme, _keybindings, done) => {\n\t\t\t\t\tconst loader = new BorderedLoader(tui, theme, `Opening ${ref.extensionId}…`);\n\t\t\t\t\tloader.onAbort = () => done({ kind: \"cancelled\" });\n\t\t\t\t\tvoid canvas\n\t\t\t\t\t\t.open(ref, { signal: loader.signal })\n\t\t\t\t\t\t.then((instance) => done({ kind: \"opened\", instance }))\n\t\t\t\t\t\t// Cancelling races: the signal rejects the pending call at the same moment\n\t\t\t\t\t\t// onAbort fires, and whichever lands first resolves `custom`. Deciding from\n\t\t\t\t\t\t// the signal rather than from who won means a cancel always reads as a\n\t\t\t\t\t\t// cancel instead of surfacing as an error.\n\t\t\t\t\t\t.catch((error: unknown) =>\n\t\t\t\t\t\t\tdone(\n\t\t\t\t\t\t\t\tloader.signal.aborted\n\t\t\t\t\t\t\t\t\t? { kind: \"cancelled\" }\n\t\t\t\t\t\t\t\t\t: { kind: \"failed\", message: error instanceof Error ? error.message : String(error) },\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t);\n\t\t\t\t\treturn loader;\n\t\t\t\t})\n\t\t\t: await canvas\n\t\t\t\t\t.open(ref)\n\t\t\t\t\t.then((instance): OpenOutcome => ({ kind: \"opened\", instance }))\n\t\t\t\t\t.catch(\n\t\t\t\t\t\t(error: unknown): OpenOutcome => ({\n\t\t\t\t\t\t\tkind: \"failed\",\n\t\t\t\t\t\t\tmessage: error instanceof Error ? error.message : String(error),\n\t\t\t\t\t\t}),\n\t\t\t\t\t);\n\n\tpi.registerCommand(\"canvas\", {\n\t\tdescription:\n\t\t\t\"Work with canvas extensions. /canvas list | open <extension>[:<canvas>] | reload [extension] | close <instanceId> | rename <extension> <new-name> | remove <extension>\",\n\t\tgetArgumentCompletions: (prefix: string) =>\n\t\t\tSUBCOMMANDS.filter((name) => name.startsWith(prefix)).map((name) => ({ value: name, label: name })),\n\t\thandler: async (args: string, ctx: ExtensionCommandContext): Promise<void> => {\n\t\t\tconst trimmed = args.trim();\n\t\t\tconst canvas = ensureSession(ctx);\n\n\t\t\tif (trimmed.length === 0 || trimmed === \"list\") {\n\t\t\t\tctx.ui.notify(renderOverview(await canvas.list()), \"info\");\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (trimmed.startsWith(\"close\")) {\n\t\t\t\tconst instanceId = trimmed.slice(\"close\".length).trim();\n\t\t\t\tif (!instanceId) {\n\t\t\t\t\tctx.ui.notify(\"Usage: /canvas close <instanceId> (see /canvas list)\", \"warning\");\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tconst closed = await canvas.close(instanceId);\n\t\t\t\tif (!closed) ctx.ui.notify(`No open canvas instance \"${instanceId}\".`, \"warning\");\n\t\t\t\telse ctx.ui.notify(`Closed ${closed.canvasId} (${closed.instanceId}).`, \"info\");\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (trimmed.startsWith(\"reload\")) {\n\t\t\t\t// A reload re-forks the extension, so it can take as long as an open and is\n\t\t\t\t// worth being able to abandon — but unlike an open there is nothing to\n\t\t\t\t// abandon *to*: the registry keeps the old child serving until the new one\n\t\t\t\t// answers, so a cancel here just stops waiting.\n\t\t\t\tconst requested = trimmed.slice(\"reload\".length).trim();\n\t\t\t\tconst running = canvas.runningExtensionIds();\n\t\t\t\tconst extensionId = requested || (running.length === 1 ? running[0] : undefined);\n\t\t\t\tif (!extensionId) {\n\t\t\t\t\tctx.ui.notify(\n\t\t\t\t\t\trunning.length === 0\n\t\t\t\t\t\t\t? \"Nothing is open, so there is nothing to reload. Open a canvas first with /canvas open <extension>.\"\n\t\t\t\t\t\t\t: `Several extensions are open; name one: ${running.join(\", \")}.`,\n\t\t\t\t\t\t\"warning\",\n\t\t\t\t\t);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\ttry {\n\t\t\t\t\tconst result = await canvas.reload(extensionId);\n\t\t\t\t\tconst lines = [`Reloaded ${result.extensionId} from disk.`];\n\t\t\t\t\t// Same reason the tool reports it: an edit to `actions: [...]` is\n\t\t\t\t\t// otherwise invisible, and a typo there fails by the action simply\n\t\t\t\t\t// not being there.\n\t\t\t\t\tconst { added, removed, changed } = result.actions;\n\t\t\t\t\tif (added.length > 0) lines.push(` + ${added.join(\", \")}`);\n\t\t\t\t\tif (removed.length > 0) lines.push(` - ${removed.join(\", \")}`);\n\t\t\t\t\tif (changed.length > 0) lines.push(` ~ ${changed.join(\", \")} (description or schema)`);\n\t\t\t\t\tfor (const instance of result.reopened) {\n\t\t\t\t\t\t// The url is the point of saying anything: the extension binds a new\n\t\t\t\t\t\t// port and mints a new token on every open, so the tab the person has\n\t\t\t\t\t\t// in front of them is now pointing at a closed port.\n\t\t\t\t\t\tlines.push(` ${describeInstance(instance)}`);\n\t\t\t\t\t}\n\t\t\t\t\tif (result.reopened.length > 0) lines.push(\"\", \"Open the new url(s) — the previous tab is dead.\");\n\t\t\t\t\tfor (const drop of result.dropped) {\n\t\t\t\t\t\tlines.push(` ${drop.canvasId} (${drop.instanceId}) did not come back: ${drop.reason}`);\n\t\t\t\t\t}\n\t\t\t\t\tctx.ui.notify(lines.join(\"\\n\"), result.dropped.length > 0 ? \"warning\" : \"info\");\n\t\t\t\t} catch (error) {\n\t\t\t\t\t// The registry only swaps children once the new one is ready, so the\n\t\t\t\t\t// canvas the person is looking at survived this. Say so, or they will\n\t\t\t\t\t// think they just lost it.\n\t\t\t\t\tctx.ui.notify(\n\t\t\t\t\t\t`Reloading ${extensionId} failed, so it is still running the code it was started with: ` +\n\t\t\t\t\t\t\t`${error instanceof Error ? error.message : String(error)}`,\n\t\t\t\t\t\t\"error\",\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (trimmed.startsWith(\"rename\")) {\n\t\t\t\tconst [from, to, ...rest] = trimmed.slice(\"rename\".length).trim().split(/\\s+/).filter(Boolean);\n\t\t\t\tif (!from || !to || rest.length > 0) {\n\t\t\t\t\tctx.ui.notify(`Usage: /canvas rename <extension> <new-name> (see /canvas list)`, \"warning\");\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\t// Renaming closes whatever the extension had open, because the directory\n\t\t\t\t// is about to move out from under it. Say so before doing it, not after.\n\t\t\t\tconst wasOpen = canvas.instances().filter((instance) => instance.extensionId === from);\n\t\t\t\tconst result = await canvas.rename(from, to);\n\t\t\t\tif (isCanvasRefusal(result)) {\n\t\t\t\t\tctx.ui.notify(`/canvas rename: ${result.detail}`, \"warning\");\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tconst lines = [`Renamed ${result.from} → ${result.to}.`, ` ${result.dir}`];\n\t\t\t\tif (result.rewrites.length > 0) {\n\t\t\t\t\tlines.push(\"\", \"Rewrote in extension.mjs:\");\n\t\t\t\t\tfor (const rewrite of result.rewrites) lines.push(` line ${rewrite.line}: ${rewrite.after.trim()}`);\n\t\t\t\t}\n\t\t\t\tif (result.leftovers.length > 0) {\n\t\t\t\t\t// Prose is not identity, so it is reported rather than edited — a rename\n\t\t\t\t\t// that silently rewrote a description would be worse than one that\n\t\t\t\t\t// admits what it left.\n\t\t\t\t\tlines.push(\n\t\t\t\t\t\t\"\",\n\t\t\t\t\t\t`\"${result.from}\" still appears on line(s) ${result.leftovers.join(\", \")}; those look like prose, so they were left alone.`,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tif (wasOpen.length > 0) lines.push(\"\", `Closed ${wasOpen.length} open instance(s) to move the directory.`);\n\t\t\t\tlines.push(\"\", `Open it with /canvas open ${result.to}.`);\n\t\t\t\tctx.ui.notify(lines.join(\"\\n\"), \"info\");\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (trimmed.startsWith(\"remove\")) {\n\t\t\t\tconst target = trimmed.slice(\"remove\".length).trim();\n\t\t\t\tif (!target) {\n\t\t\t\t\tctx.ui.notify(\"Usage: /canvas remove <extension> (see /canvas list)\", \"warning\");\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tconst known = canvas.knownExtensionIds();\n\t\t\t\tif (!known.includes(target)) {\n\t\t\t\t\tctx.ui.notify(`No canvas extension \"${target}\" (found: ${known.join(\", \") || \"none\"}).`, \"warning\");\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\t// Deleting source is not undoable from here, so it is confirmed — and\n\t\t\t\t// outside a terminal there is nobody to ask, so it is refused rather than\n\t\t\t\t// assumed. `--print` and RPC should not be able to delete a directory\n\t\t\t\t// because a command happened to be piped in.\n\t\t\t\tif (!ctx.hasUI) {\n\t\t\t\t\tctx.ui.notify(\n\t\t\t\t\t\t`/canvas remove needs to ask before deleting ${target}, and there is no interactive surface here. Delete the directory yourself, or run this in a terminal.`,\n\t\t\t\t\t\t\"warning\",\n\t\t\t\t\t);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tconst confirmed = await ctx.ui.confirm(\n\t\t\t\t\t`Delete canvas \"${target}\"?`,\n\t\t\t\t\t\"This deletes the extension directory and everything in it. It is not undoable from here.\",\n\t\t\t\t);\n\t\t\t\tif (!confirmed) {\n\t\t\t\t\tctx.ui.notify(`Left ${target} alone.`, \"info\");\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tconst openCount = canvas.instances().filter((instance) => instance.extensionId === target).length;\n\t\t\t\tconst result = await canvas.remove(target);\n\t\t\t\tif (isCanvasRefusal(result)) {\n\t\t\t\t\tctx.ui.notify(`/canvas remove: ${result.detail}`, \"warning\");\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tctx.ui.notify(\n\t\t\t\t\t[\n\t\t\t\t\t\t`Removed ${result.id}.`,\n\t\t\t\t\t\t` ${result.dir}`,\n\t\t\t\t\t\topenCount > 0 ? `Closed ${openCount} open instance(s) first.` : \"\",\n\t\t\t\t\t]\n\t\t\t\t\t\t.filter((line) => line.length > 0)\n\t\t\t\t\t\t.join(\"\\n\"),\n\t\t\t\t\t\"info\",\n\t\t\t\t);\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (!trimmed.startsWith(\"open\")) {\n\t\t\t\tctx.ui.notify(`Unknown subcommand. Use ${SUBCOMMANDS.join(\", \")}.`, \"warning\");\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst ref = parseCanvasRef(trimmed.slice(\"open\".length));\n\t\t\tif (!ref) {\n\t\t\t\tctx.ui.notify(\"Usage: /canvas open <extension>[:<canvas>] (see /canvas list)\", \"warning\");\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst outcome = await openWithLoader(canvas, ref, ctx);\n\n\t\t\t// `custom` can also settle on its own when the overlay is dismissed, without\n\t\t\t// our `done` ever running — an escape that closes the surface leaves no\n\t\t\t// outcome. Treat that as the cancel it is rather than reading `.kind` off\n\t\t\t// undefined and failing silently.\n\t\t\tif (!outcome || outcome.kind === \"cancelled\") {\n\t\t\t\t// KNOWN ISSUE: this confirmation does not render when the cancel came from the\n\t\t\t\t// loader's own escape handling, though every effect of cancelling is correct\n\t\t\t\t// and verified (the open rejects, no instance is registered, and the extension\n\t\t\t\t// is told to close the instance it never finished opening). Ruled out: the\n\t\t\t\t// continuation does run and `ctx.ui.notify` works here — the failure path\n\t\t\t\t// through the same lines renders its error, and the canvas's own diagnostic\n\t\t\t\t// arrives moments later through this very function. Deferring a tick did not\n\t\t\t\t// help either. Left as an unexplained cosmetic gap rather than papered over\n\t\t\t\t// with a sleep; the loader disappearing is itself the signal.\n\t\t\t\tctx.ui.notify(\"Canvas open cancelled.\", \"info\");\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (outcome.kind === \"failed\") {\n\t\t\t\tctx.ui.notify(outcome.message, \"error\");\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tregisterToolsOnce(canvas);\n\t\t\tctx.ui.notify(\n\t\t\t\t[\n\t\t\t\t\t`Opened ${outcome.instance.canvasId} (${outcome.instance.instanceId}).`,\n\t\t\t\t\toutcome.instance.url ? `Open in a browser: ${outcome.instance.url}` : \"\",\n\t\t\t\t\t\"The agent can now read and drive it; close it with /canvas close <instanceId>.\",\n\t\t\t\t]\n\t\t\t\t\t.filter((line) => line.length > 0)\n\t\t\t\t\t.join(\"\\n\"),\n\t\t\t\t\"info\",\n\t\t\t);\n\t\t},\n\t});\n\n\t// ── /new-canvas <name> | <description> ────────────────────────────────────\n\t// Authoring, in Copilot's `/create-canvas` shape: describe what you want, the\n\t// agent writes it, and it is already open while it does. Design:\n\t// `docs/canvas-extensions-design.md` §9 Phase 3, §13.\n\t//\n\t// Unlike the other `/new-*` scaffolds this one needs no /reload: canvases are\n\t// discovered when /canvas runs, not loaded at session start.\n\n\tpi.registerCommand(\"new-canvas\", {\n\t\tdescription:\n\t\t\t\"Create a canvas extension. Usage: /new-canvas <what it should do> | /new-canvas <name> | /new-canvas <name>: <what it should do>\",\n\t\tgetArgumentCompletions: () => [],\n\t\thandler: async (args: string, ctx: ExtensionCommandContext): Promise<void> => {\n\t\t\tconst request = parseCanvasRequest(args);\n\t\t\tif (typeof request === \"string\") {\n\t\t\t\tctx.ui.notify(`/new-canvas: ${request}`, \"warning\");\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// `--platform claude` is dropped rather than redirected: Claude has no\n\t\t\t// canvas convention, and silently writing into someone else's marker\n\t\t\t// directory would put an extension where that vendor will never look.\n\t\t\tconst requested = getWorkspacePlatforms() ?? [\"agents\"];\n\t\t\tconst targets = requested.filter((platform) => CANVAS_HOMES[platform] !== undefined);\n\t\t\tif (targets.length === 0) {\n\t\t\t\tctx.ui.notify(\n\t\t\t\t\t`/new-canvas: no canvas home for platform \"${requested.join(\", \")}\". ` +\n\t\t\t\t\t\t\"Canvas extensions exist under .agents/extensions (agents) and .github/extensions (github) only.\",\n\t\t\t\t\t\"warning\",\n\t\t\t\t);\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst { created, skipped } = scaffoldCanvas(ctx.cwd, request.name, targets);\n\n\t\t\t// A canvas lands in the working tree, which is where the trust gate looks\n\t\t\t// (`core/canvas/trust.ts`) — so without this the canvas you just asked for\n\t\t\t// is withheld the moment you try to open it, and refused with \"came with\n\t\t\t// this repository\", which is not true of a file created seconds ago.\n\t\t\t//\n\t\t\t// Granting is the same call `/plugin install --scope project` makes, for\n\t\t\t// the same stated reason: a person typing this command in this directory\n\t\t\t// is the human act workspace trust asks for. It is deliberately wider than\n\t\t\t// this one canvas — it also lets plugins already committed here run their\n\t\t\t// hooks and MCP servers — so it is said out loud and pointed at its\n\t\t\t// reverse, never done silently.\n\t\t\tlet trustNote = \"\";\n\t\t\tif (created.length > 0 && !isWorkspaceTrusted(ctx.cwd, getAgentDir())) {\n\t\t\t\ttrustWorkspace(ctx.cwd, getAgentDir());\n\t\t\t\ttrustNote =\n\t\t\t\t\t`Trusted this workspace so the canvas can run. Plugins committed here may now run hooks ` +\n\t\t\t\t\t`and MCP servers too; \\`/plugin untrust\\` reverses it.`;\n\t\t\t}\n\n\t\t\tif (created.length === 0) {\n\t\t\t\tctx.ui.notify(\n\t\t\t\t\t[\n\t\t\t\t\t\t\"Nothing created — these already exist:\",\n\t\t\t\t\t\t...skipped.map((file) => ` ${file}`),\n\t\t\t\t\t\t\"\",\n\t\t\t\t\t\t`Open the existing one with /canvas open ${request.name}, or pick another name.`,\n\t\t\t\t\t].join(\"\\n\"),\n\t\t\t\t\t\"warning\",\n\t\t\t\t);\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// Open before saying anything. Copilot's `/create-canvas` puts the canvas\n\t\t\t// in front of the person and *then* builds it, and the order is the point:\n\t\t\t// a build brief that can name a live url and instance id is a different\n\t\t\t// instruction than one that cannot, and the person watches it change.\n\t\t\tconst canvas = ensureSession(ctx);\n\t\t\tconst outcome = await openWithLoader(canvas, { extensionId: request.name }, ctx);\n\t\t\tconst opened = outcome?.kind === \"opened\" ? outcome.instance : undefined;\n\t\t\tif (opened) registerToolsOnce(canvas);\n\n\t\t\tconst lines = [\"Canvas created:\", ...created.map((file) => ` ${file}`)];\n\t\t\tif (skipped.length > 0) lines.push(\"Skipped (already exist):\", ...skipped.map((file) => ` ${file}`));\n\t\t\tlines.push(\"\");\n\t\t\tif (opened) {\n\t\t\t\tlines.push(`Opened ${opened.canvasId} (${opened.instanceId}).`);\n\t\t\t\tif (opened.url) lines.push(`Open in a browser: ${opened.url}`);\n\t\t\t} else if (outcome?.kind === \"failed\") {\n\t\t\t\t// Not fatal: the file is written and discoverable, so say what broke and\n\t\t\t\t// leave them a way in rather than making it look like nothing happened.\n\t\t\t\tlines.push(\n\t\t\t\t\t`Created, but opening it failed: ${outcome.message}`,\n\t\t\t\t\t`Retry with /canvas open ${request.name}.`,\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\tlines.push(`Opening cancelled. Open it when you want with /canvas open ${request.name}.`);\n\t\t\t}\n\t\t\tif (trustNote) lines.push(\"\", trustNote);\n\n\t\t\tif (request.description) {\n\t\t\t\tlines.push(\n\t\t\t\t\t\"\",\n\t\t\t\t\t`Building it now from: \"${request.description}\"`,\n\t\t\t\t\t\"Steer it like any other turn, or interrupt to take over the file yourself.\",\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\tlines.push(\"\", `Edit ${created[0]} and run /canvas reload ${request.name} to see each change.`);\n\t\t\t}\n\t\t\tctx.ui.notify(lines.join(\"\\n\"), \"info\");\n\n\t\t\t// The half that makes this `/create-canvas` rather than a scaffold. Queued\n\t\t\t// as a follow-up so it lands on the next turn whether or not the agent is\n\t\t\t// mid-stream, and only when a description was given: `/new-canvas my-board`\n\t\t\t// still means \"give me the template\", and starting a build nobody asked for\n\t\t\t// would burn a turn and overwrite the file they meant to edit.\n\t\t\tif (request.description) {\n\t\t\t\tawait pi.sendUserMessage(\n\t\t\t\t\tcanvasBuildBrief(\n\t\t\t\t\t\trequest.name,\n\t\t\t\t\t\trequest.description,\n\t\t\t\t\t\tcreated[0] as string,\n\t\t\t\t\t\topened ? { instanceId: opened.instanceId, url: opened.url } : undefined,\n\t\t\t\t\t\tcanvasDesignGuidePath(),\n\t\t\t\t\t),\n\t\t\t\t\t{ deliverAs: \"followUp\" },\n\t\t\t\t);\n\t\t\t}\n\t\t},\n\t});\n\n\t// Teardown on shutdown (§6): a browser tab gives no close signal, so without this\n\t// every child and loopback port outlives the session. `session_shutdown` is where\n\t// loop.ts stops its scheduler, and it is synchronous, so the dispose is fired and\n\t// not awaited.\n\tpi.on(\"session_shutdown\", () => {\n\t\tconst closing = session;\n\t\tsession = undefined;\n\t\tvoid closing?.dispose();\n\t});\n}\n"]}
|
|
@@ -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,sBAAsB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAMzD,CAAC;AAEF,eAAO,MAAM,gBAAgB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAanD,CAAC;AAEF,sFAAsF;AACtF,eAAO,MAAM,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAGlD,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\\n `/grill` to stress-test it, then `/approve` to execute it step by step or\\n `/goal` to work toward it autonomously.\" Recommend `/grill` first whenever the\\n plan carries real risk — it surfaces weak assumptions before any code changes.\\n\\nForbidden: edit any source file. Only `{{PLAN_PATH}}` may be written.\\n',\n};\n\nexport const EMBEDDED_PROFILES: Record<string, string> = {};\n\nexport const EMBEDDED_AGENT_PROMPTS: Record<string, string> = {\n\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 commands that change state\\n\\n Output: Concise summary, file list, or plan. No code changes.\\n Cost: Low (read-only)\\n Isolation: Can run in parallel with other explore tasks\\ntools: read, grep, find, ls\\nmodel: fast\\nbackground: true\\n---\\nYou are an explore-only agent running inside hoocode. You read code and produce summaries. You NEVER edit files. You run in an isolated context and cannot see the parent conversation.\\n\\nScope:\\n- Do not modify, create, or delete files, and do not run commands.\\n- Use read, grep, find, and ls 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\t\"general-purpose\":\n\t\t\"---\\nname: general-purpose\\ndescription: |\\n Use this subagent when:\\n - A task is multi-step or open-ended and needs both investigation and action\\n - No other agent clearly fits\\n - You are searching for code or a pattern and are unsure where it lives\\n - The work spans reading, editing, and running commands together\\n\\n Prefer the explore agent when the task is clearly read-only.\\n\\n Output: The completed result plus a summary of what was done and where.\\n Cost: Variable (read + write + run)\\n Isolation: Should not run concurrently with other write tasks on the same files\\ntools: read, bash, edit, write, grep, find, ls\\nmodel: standard\\ndelegate: true\\n---\\nYou are a general-purpose subagent running inside hoocode. You handle multi-step and open-ended tasks end to end. You run in an isolated context and cannot see the parent conversation.\\n\\nScope:\\n- You may read, search, edit, and write files, and run commands needed to complete the task.\\n- Stay within the requested task. Do not refactor or change unrelated code.\\n\\nMethod:\\n1. Break the task into concrete steps.\\n2. Investigate before acting: read the relevant files and trace the logic.\\n3. Make the smallest changes that fully satisfy the task, matching existing style.\\n4. Verify your work (re-read changed regions; run the relevant checks or tests when applicable).\\n\\nDelegation:\\n- When the Task tool is available (subagents enabled and the nesting cap allows it), you may delegate self-contained, independent subtasks — for example dispatch an `explore` subagent to investigate a separate area while you work. Otherwise do the work directly.\\n\\nGuidance:\\n- Your final answer is the only thing the caller receives. Make it self-contained.\\n- Summarize what you did 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\tplan: \"---\\nname: plan\\ndescription: |\\n Use this subagent when:\\n - You need to research a codebase before proposing an implementation plan\\n - A task requires understanding scope, affected files, and approach without\\n making any changes yet\\n - You are in plan mode and want focused investigation to back the plan\\n\\n DO NOT use for:\\n - Making code changes (this agent is read-only)\\n - Quick single-file lookups (use explore)\\n\\n Output: A concrete plan — the approach, the files to change, and the steps.\\n Cost: Low–medium (read-only)\\n Isolation: Can run in parallel with explore tasks\\ntools: read, grep, find, ls\\nmodel: standard\\nbackground: true\\n---\\nYou are a planning agent running inside hoocode. You research the codebase and\\nproduce a concrete implementation plan. You NEVER modify files. You run in an\\nisolated context and cannot see the parent conversation.\\n\\nScope:\\n- Do not create, modify, or delete files, and do not run commands.\\n- Use read, grep, find, and ls to understand the code and its structure.\\n\\nMethod:\\n1. Restate the goal and identify what you need to learn to plan it.\\n2. Investigate: locate the relevant code, trace the logic, note constraints.\\n3. Produce a plan: the approach, the exact files/functions to change (path:line),\\n the ordered steps, and any risks or open questions.\\n\\nGuidance:\\n- Your final answer is the only thing the caller receives. Make the plan\\n self-contained and actionable.\\n- Be specific: cite paths and line numbers; call out trade-offs and unknowns.\\n- Do not narrate your search or include tool logs.\\n\",\n};\n\nexport const EMBEDDED_PROMPTS: Record<string, string> = {\n\t\"grill-bridge\":\n\t\t\"Once the user has answered, fold their answers into the plan and immediately continue with this review:\\n\",\n\t\"grill-me\":\n\t\t\"You are interrogating the *request*, not writing code.\\n\\nRe-read the plan below and find where it rests on assumptions nobody confirmed: ambiguous requirements, unstated constraints, decisions you made silently because the request did not specify them, and places where a different reasonable reading of the request would produce a materially different plan.\\n\\nPut the most consequential of those to the user with the ask_options tool. Ask only what would actually change the plan — settle anything you can from the codebase or from convention yourself. Prefer two to four sharp questions over an exhaustive list, and mark a recommended option wherever you have a genuine preference.\\n\\nDo not edit files and do not revise the plan yet.\\n\",\n\t\"grill-plan\":\n\t\t\"You are attacking the plan below, not executing it.\\n\\nReview it as a skeptical reviewer would:\\n- Which steps rest on assumptions you have not verified in the codebase? Read the relevant files and verify them now.\\n- Where could this fail silently — wrong-but-plausible behaviour rather than a loud error?\\n- What does the goal require that the plan does not cover? What does the plan cover that the goal does not need?\\n- Does the verification section prove the goal is met, or only that the code runs?\\n\\nReport what you find. Where a weakness is real, revise the plan file and state what changed. Where the plan holds up, say so plainly rather than inventing criticism. Do not implement anything.\\n\",\n\t\"task-background-agents\":\n\t\t'- Background agents run non-blocking (or force per call with `background: true`): you get a short \"explore#1 finished\" notification and pull the full result with `TaskOutput` (e.g. `TaskOutput(\"explore#1\")`); `TaskOutput(list: true)` shows what\\'s running.\\n- After dispatching, don\\'t idle — keep doing independent work (read/edit unrelated files, draft, dispatch more); barrier with `TaskOutput(wait: true)` (a named task, or all outstanding when no id) only when you genuinely can\\'t proceed.\\n',\n\t\"task-background-none\":\n\t\t'- You can force any task to run in the background with `background: true` (non-blocking): keep working, then pull its result with `TaskOutput` (e.g. `TaskOutput(\"explore#1\")`) or block on it with `TaskOutput(wait: true)`.\\n',\n\t\"task-main\":\n\t\t\"You have access to the **Task** tool. Use it to delegate self-contained tasks to specialized subagents that run in their own isolated context and return only their final answer. Pick an agent by name from the <available_agents> list in this prompt and pass it as `subagent_type`.\\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\\nModel tier (optional `complexity`): set `fast` for quick reads/lookups, `standard` for multi-file edits, `capable` for deep architecture work. It maps to a model from `settings.modelCategories`. Omit it to use the agent's default; an agent that pins its own model ignores `complexity`.\\n\\nGuidelines:\\n- Choose the agent whose description best matches the task.\\n- Make every task specific and self-contained. The subagent cannot see this conversation; pass all necessary context (files, constraints, prior findings) in `prompt`.\\n- Do NOT delegate tasks that require tight back-and-forth with your current reasoning, or edits to files you are actively reasoning about.\\n- The subagent returns ONLY its final answer. Its intermediate reasoning, tool calls, and output are hidden from you.\\n- Delegate proactively when work is self-contained or parallelizable: multi-step investigation, read-only exploration (use `explore`), research before changes (use `plan`), drafting a standalone file/section, or running a long command/test suite. Dispatch independent subtasks in the same turn. Handle only trivial single-step edits or tightly interactive back-and-forth inline.\\n{{BACKGROUND_GUIDANCE}}\\n- When working through a TodoWrite plan, mark the plan item in_progress BEFORE dispatching subagents for it: each dispatch is attributed to the current in_progress item in the user's task panel, so dispatching first (or with several items in_progress) leaves the run unattributed.\\n- To continue a previous subagent (for example one that returned partial results), call Task again with `resume_task_id` set to its task_id; it resumes with its full prior transcript and `prompt` is your follow-up.\\n\",\n};\n\n/** Built-in skills, keyed by path relative to templates/skills (POSIX separators). */\nexport const EMBEDDED_SKILLS: Record<string, string> = {\n\t\"plugin-authoring/SKILL.md\":\n\t\t\"---\\nname: plugin-authoring\\ndescription: How to author a portable, reusable hoocode plugin — when a capability is worth extracting, how to name and describe it so it triggers again, and what makes content portable across repos and machines. Use before calling ProposePlugin or UpdatePlugin, or when deciding whether a recipe you just completed is worth keeping.\\nallowed-tools: read, write, edit, grep, find, ls\\n---\\n\\n# Authoring a plugin\\n\\nThis is the craft half of the plugin tools. `ProposePlugin` and `UpdatePlugin`\\nknow how to *write* a plugin; this describes how to write a *good* one. Read it\\nbefore authoring, not after.\\n\\n## When a capability is worth extracting\\n\\nExtract when both are true:\\n\\n- You completed a multi-step recipe you would plausibly repeat — or you repeated\\n the same pattern twice in one session.\\n- `SearchPlugins` found nothing that already covers it.\\n\\nDo not extract a one-off. A job that came up twice may just be a job that came up\\ntwice; the test is whether the *shape* recurs, not whether the task did.\\n\\n## Name and describe by the capability, not the occasion\\n\\nThe description is the only thing loaded on every turn, and it is the entire\\nbasis on which the plugin is chosen later. Write it for the next situation, not\\nfor the one that prompted it.\\n\\n- Bad: `fix-flaky-auth-test` — names the incident. It will never trigger again.\\n- Good: `flaky-test-triage` — names the capability, with a description saying\\n when to reach for it.\\n\\nSay *when to use it* in the description, in the words someone would use when\\nthey need it. A description that only says what the plugin is will not trigger.\\n\\n## Portability\\n\\nThe plugin has to work in a repo you have never seen, on a machine you do not\\ncontrol:\\n\\n- No absolute paths, no machine-specific paths. Prefer relative paths and\\n runtime discovery.\\n- No embedded secrets, tokens, or environment-specific values.\\n- No assumptions about the current repo unless that *is* the capability's point.\\n- State prerequisites in the body rather than assuming them.\\n\\nThe layout is the session's target platform. You never choose it.\\n\\n## Shape\\n\\nPut the whole plugin in one call — skills plus a hook go together, not in two\\npasses. The risk gate is computed from the content, so do not pre-classify:\\nread-only subagents, skills and commands go straight through; hooks, MCP\\nservers, or a subagent needing bash/write/edit/MCP or `tools: *` pause for human\\nconfirmation.\\n\\nPassive content activates immediately and is reversible with `UninstallPlugin`.\\nAnnounce what you created and why.\\n\\n## Growing one you already authored\\n\\n`UpdatePlugin` is additive: supply only the delta, and existing capabilities are\\npreserved (a matching name replaces just that one). It cannot remove anything —\\nthat is `RemovePluginCapability`.\\n\\nHooks are the exception to \\\"additive is safe\\\". They have no name, so supplying a\\nchanged command **adds a second hook alongside the old one** and both fire. To\\nchange a hook, remove the old one first, then add the new one.\\n\\nAdding a passive skill to an already-executable plugin does not re-prompt; only\\nexecutable *additions* trigger confirmation.\\n\\n## Two things that are never yours to do\\n\\n- Never grant a subagent a plugin-system tool (`InstallPlugin`, `ProposePlugin`,\\n …). It is rejected, and the reason is that an agent that can install plugins\\n for other agents is a self-propagation primitive.\\n- Never publish to a marketplace autonomously. Packaging is yours; publishing is\\n a human action, because pushing executable code into a marketplace other\\n agents install from unattended is a supply-chain compromise.\\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,sBAAsB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAUzD,CAAC;AAEF,eAAO,MAAM,gBAAgB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAanD,CAAC;AAEF,sFAAsF;AACtF,eAAO,MAAM,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAOlD,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\\n `/grill` to stress-test it, then `/approve` to execute it step by step or\\n `/goal` to work toward it autonomously.\" Recommend `/grill` first whenever the\\n plan carries real risk — it surfaces weak assumptions before any code changes.\\n\\nForbidden: edit any source file. Only `{{PLAN_PATH}}` may be written.\\n',\n};\n\nexport const EMBEDDED_PROFILES: Record<string, string> = {};\n\nexport const EMBEDDED_AGENT_PROMPTS: Record<string, string> = {\n\t\"code-review\":\n\t\t\"---\\nname: code-review\\ndescription: |\\n Use this subagent when:\\n - Reviewing a diff, branch, or files for defects before merge\\n - The user asks for a review, a second pass, or what they missed\\n - Findings are wanted without spending parent context on every changed file\\n\\n DO NOT use for:\\n - Applying the fixes (this agent reports; the parent decides)\\n - Hunting for security vulnerabilities specifically (use security-review)\\n\\n Output: Ranked findings, each with path:line, the defect, and how it fails.\\n Cost: Medium (reads the full diff and surrounding code)\\n Isolation: Read-only; can run in parallel with other review tasks\\ntools: read, bash, grep, find, ls\\nmodel: capable\\nbackground: true\\n---\\nYou are a code-review agent running inside hoocode. You find defects in changed\\ncode and report them. You never edit files. You run in an isolated context and\\ncannot see the parent conversation, so state findings in full rather than\\nreferring back to a discussion you cannot read.\\n\\nScope:\\n- Do not create, modify, or delete files.\\n- Use bash for read-only git commands (`git diff`, `git log`, `git show`) to\\n establish what changed. Do not commit, push, stash, or check out.\\n- Review what the caller named. If they named nothing, review the working tree\\n diff, then the branch against its base.\\n\\nMethod:\\n1. Establish the diff. Read every changed hunk before forming an opinion.\\n2. Read enough surrounding code to know whether a hunk is actually wrong. A\\n line that looks suspicious in isolation is usually fine in context.\\n3. For each candidate finding, construct the concrete failure: the input or\\n state that triggers it, and the wrong output or crash that results. If you\\n cannot construct one, it is not a finding.\\n4. Rank what survives by severity.\\n\\nWhat counts as a finding:\\n- Correctness: logic that produces a wrong result, a crash, unhandled errors,\\n off-by-one, wrong operator, a case the code does not cover.\\n- Contract violations: a caller that does not match the callee's expectations,\\n a type narrowed incorrectly, an invariant the change breaks.\\n- Reuse: the change hand-rolls something the codebase already provides.\\n- Efficiency: work repeated in a loop that belongs outside it, an avoidable\\n quadratic, a re-read of something already in memory.\\n\\nWhat does not:\\n- Style, formatting, or naming the linter does not flag.\\n- Restating what the code does without saying what is wrong with it.\\n- Speculative hardening for inputs the code cannot receive.\\n\\nGuidance:\\n- Verify before reporting. A confident wrong finding costs the caller more than\\n a missed one, because they have to read the code to disprove it.\\n- Report as a ranked list: `path:line`, one sentence naming the defect, then the\\n failure case. No preamble, no summary of the change, no tool logs.\\n- If nothing survives verification, say so plainly. An empty review is a\\n legitimate result.\\n\",\n\texplore:\n\t\t\"---\\nname: explore\\ndescription: |\\n Use this subagent ONLY when:\\n - Reading or understanding code without changes\\n - Scouting a codebase for plans or maps\\n - Analyzing dependencies, imports, project structure\\n - Investigating errors or tracing execution flow\\n - Estimating scope before edits\\n\\n DO NOT use for:\\n - Writing or modifying code\\n - Running commands that change state\\n\\n Output: Concise summary, file list, or plan. No code changes.\\n Cost: Low (read-only)\\n Isolation: Can run in parallel with other explore tasks\\ntools: read, grep, find, ls\\nmodel: fast\\nbackground: true\\n---\\nYou are an explore-only agent running inside hoocode. You read code and produce summaries. You NEVER edit files. You run in an isolated context and cannot see the parent conversation.\\n\\nScope:\\n- Do not modify, create, or delete files, and do not run commands.\\n- Use read, grep, find, and ls 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\t\"general-purpose\":\n\t\t\"---\\nname: general-purpose\\ndescription: |\\n Use this subagent when:\\n - A task is multi-step or open-ended and needs both investigation and action\\n - No other agent clearly fits\\n - You are searching for code or a pattern and are unsure where it lives\\n - The work spans reading, editing, and running commands together\\n\\n Prefer the explore agent when the task is clearly read-only.\\n\\n Output: The completed result plus a summary of what was done and where.\\n Cost: Variable (read + write + run)\\n Isolation: Should not run concurrently with other write tasks on the same files\\ntools: read, bash, edit, write, grep, find, ls\\nmodel: standard\\ndelegate: true\\n---\\nYou are a general-purpose subagent running inside hoocode. You handle multi-step and open-ended tasks end to end. You run in an isolated context and cannot see the parent conversation.\\n\\nScope:\\n- You may read, search, edit, and write files, and run commands needed to complete the task.\\n- Stay within the requested task. Do not refactor or change unrelated code.\\n\\nMethod:\\n1. Break the task into concrete steps.\\n2. Investigate before acting: read the relevant files and trace the logic.\\n3. Make the smallest changes that fully satisfy the task, matching existing style.\\n4. Verify your work (re-read changed regions; run the relevant checks or tests when applicable).\\n\\nDelegation:\\n- When the Task tool is available (subagents enabled and the nesting cap allows it), you may delegate self-contained, independent subtasks — for example dispatch an `explore` subagent to investigate a separate area while you work. Otherwise do the work directly.\\n\\nGuidance:\\n- Your final answer is the only thing the caller receives. Make it self-contained.\\n- Summarize what you did 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\tplan: \"---\\nname: plan\\ndescription: |\\n Use this subagent when:\\n - You need to research a codebase before proposing an implementation plan\\n - A task requires understanding scope, affected files, and approach without\\n making any changes yet\\n - You are in plan mode and want focused investigation to back the plan\\n\\n DO NOT use for:\\n - Making code changes (this agent is read-only)\\n - Quick single-file lookups (use explore)\\n\\n Output: A concrete plan — the approach, the files to change, and the steps.\\n Cost: Low–medium (read-only)\\n Isolation: Can run in parallel with explore tasks\\ntools: read, grep, find, ls\\nmodel: standard\\nbackground: true\\n---\\nYou are a planning agent running inside hoocode. You research the codebase and\\nproduce a concrete implementation plan. You NEVER modify files. You run in an\\nisolated context and cannot see the parent conversation.\\n\\nScope:\\n- Do not create, modify, or delete files, and do not run commands.\\n- Use read, grep, find, and ls to understand the code and its structure.\\n\\nMethod:\\n1. Restate the goal and identify what you need to learn to plan it.\\n2. Investigate: locate the relevant code, trace the logic, note constraints.\\n3. Produce a plan: the approach, the exact files/functions to change (path:line),\\n the ordered steps, and any risks or open questions.\\n\\nGuidance:\\n- Your final answer is the only thing the caller receives. Make the plan\\n self-contained and actionable.\\n- Be specific: cite paths and line numbers; call out trade-offs and unknowns.\\n- Do not narrate your search or include tool logs.\\n\",\n\t\"security-review\":\n\t\t\"---\\nname: security-review\\ndescription: |\\n Use this subagent when:\\n - Reviewing changes for vulnerabilities before merge or release\\n - The change touches auth, input parsing, paths, subprocesses, or secrets\\n - The user asks for a security review or audit of pending work\\n\\n DO NOT use for:\\n - General correctness and quality review (use code-review)\\n - Applying the fixes (this agent reports; the parent decides)\\n\\n Output: Findings ranked by severity, each with path:line, the attack, and the\\n fix.\\n Cost: Medium (reads the diff and traces untrusted input)\\n Isolation: Read-only; can run in parallel with other review tasks\\ntools: read, bash, grep, find, ls\\nmodel: capable\\nbackground: true\\n---\\nYou are a security-review agent running inside hoocode. You find vulnerabilities\\nin changed code and report them. You never edit files. You run in an isolated\\ncontext and cannot see the parent conversation, so state findings in full rather\\nthan referring back to a discussion you cannot read.\\n\\nScope:\\n- Do not create, modify, or delete files.\\n- Use bash for read-only git commands (`git diff`, `git log`, `git show`) to\\n establish what changed. Do not commit, push, stash, or check out.\\n- Review what the caller named. If they named nothing, review the working tree\\n diff, then the branch against its base.\\n\\nMethod:\\n1. Establish the diff, then identify every point where the change accepts input\\n it does not control: arguments, environment, files, network responses, tool\\n output, model output.\\n2. Trace each one to where it is used. A vulnerability is a path from untrusted\\n input to a dangerous operation, so follow the path rather than pattern\\n matching on the operation.\\n3. For each candidate, construct the attack: what an attacker supplies, what\\n they gain. If you cannot construct one, it is not a finding.\\n4. Rank what survives by severity, worst first.\\n\\nWhere to look hardest:\\n- Command execution: shell strings built from input, argument arrays that can be\\n injected, a path that reaches an interpreter.\\n- Path handling: traversal via `..` or absolute paths, symlinks, writes outside\\n an intended root.\\n- Secrets: credentials logged, embedded in errors, written to disk, sent to a\\n provider that does not need them.\\n- Deserialization and parsing: untrusted JSON, YAML, or archives fed to a parser\\n that can execute or allocate unboundedly.\\n- Authorization: a check that can be bypassed, a permission gate the change\\n routes around, a default that fails open.\\n- Injection into generated content: HTML, SQL, or prompt text assembled from\\n input without escaping.\\n\\nWhat does not count:\\n- A theoretical issue in code the change did not touch and does not reach.\\n- Missing hardening with no reachable attack path.\\n- Dependency advisories the change neither introduces nor exercises.\\n\\nGuidance:\\n- Verify reachability before reporting. An unreachable finding wastes the\\n caller's time and erodes trust in the review.\\n- Report as a severity-ranked list: `path:line`, the attack in one or two\\n sentences, then the fix. No preamble, no tool logs.\\n- Where a fix has a safer and a more convenient form, name the safer one.\\n- If nothing survives verification, say so plainly.\\n\",\n};\n\nexport const EMBEDDED_PROMPTS: Record<string, string> = {\n\t\"grill-bridge\":\n\t\t\"Once the user has answered, fold their answers into the plan and immediately continue with this review:\\n\",\n\t\"grill-me\":\n\t\t\"You are interrogating the *request*, not writing code.\\n\\nRe-read the plan below and find where it rests on assumptions nobody confirmed: ambiguous requirements, unstated constraints, decisions you made silently because the request did not specify them, and places where a different reasonable reading of the request would produce a materially different plan.\\n\\nPut the most consequential of those to the user with the ask_options tool. Ask only what would actually change the plan — settle anything you can from the codebase or from convention yourself. Prefer two to four sharp questions over an exhaustive list, and mark a recommended option wherever you have a genuine preference.\\n\\nDo not edit files and do not revise the plan yet.\\n\",\n\t\"grill-plan\":\n\t\t\"You are attacking the plan below, not executing it.\\n\\nReview it as a skeptical reviewer would:\\n- Which steps rest on assumptions you have not verified in the codebase? Read the relevant files and verify them now.\\n- Where could this fail silently — wrong-but-plausible behaviour rather than a loud error?\\n- What does the goal require that the plan does not cover? What does the plan cover that the goal does not need?\\n- Does the verification section prove the goal is met, or only that the code runs?\\n\\nReport what you find. Where a weakness is real, revise the plan file and state what changed. Where the plan holds up, say so plainly rather than inventing criticism. Do not implement anything.\\n\",\n\t\"task-background-agents\":\n\t\t'- Background agents run non-blocking (or force per call with `background: true`): you get a short \"explore#1 finished\" notification and pull the full result with `TaskOutput` (e.g. `TaskOutput(\"explore#1\")`); `TaskOutput(list: true)` shows what\\'s running.\\n- After dispatching, don\\'t idle — keep doing independent work (read/edit unrelated files, draft, dispatch more); barrier with `TaskOutput(wait: true)` (a named task, or all outstanding when no id) only when you genuinely can\\'t proceed.\\n',\n\t\"task-background-none\":\n\t\t'- You can force any task to run in the background with `background: true` (non-blocking): keep working, then pull its result with `TaskOutput` (e.g. `TaskOutput(\"explore#1\")`) or block on it with `TaskOutput(wait: true)`.\\n',\n\t\"task-main\":\n\t\t\"You have access to the **Task** tool. Use it to delegate self-contained tasks to specialized subagents that run in their own isolated context and return only their final answer. Pick an agent by name from the <available_agents> list in this prompt and pass it as `subagent_type`.\\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\\nModel tier (optional `complexity`): set `fast` for quick reads/lookups, `standard` for multi-file edits, `capable` for deep architecture work. It maps to a model from `settings.modelCategories`. Omit it to use the agent's default; an agent that pins its own model ignores `complexity`.\\n\\nGuidelines:\\n- Choose the agent whose description best matches the task.\\n- Make every task specific and self-contained. The subagent cannot see this conversation; pass all necessary context (files, constraints, prior findings) in `prompt`.\\n- Do NOT delegate tasks that require tight back-and-forth with your current reasoning, or edits to files you are actively reasoning about.\\n- The subagent returns ONLY its final answer. Its intermediate reasoning, tool calls, and output are hidden from you.\\n- Delegate proactively when work is self-contained or parallelizable: multi-step investigation, read-only exploration (use `explore`), research before changes (use `plan`), drafting a standalone file/section, or running a long command/test suite. Dispatch independent subtasks in the same turn. Handle only trivial single-step edits or tightly interactive back-and-forth inline.\\n{{BACKGROUND_GUIDANCE}}\\n- When working through a TodoWrite plan, mark the plan item in_progress BEFORE dispatching subagents for it: each dispatch is attributed to the current in_progress item in the user's task panel, so dispatching first (or with several items in_progress) leaves the run unattributed.\\n- To continue a previous subagent (for example one that returned partial results), call Task again with `resume_task_id` set to its task_id; it resumes with its full prior transcript and `prompt` is your follow-up.\\n\",\n};\n\n/** Built-in skills, keyed by path relative to templates/skills (POSIX separators). */\nexport const EMBEDDED_SKILLS: Record<string, string> = {\n\t\"artifact-design/SKILL.md\":\n\t\t\"---\\nname: artifact-design\\ndescription: Build a self-contained HTML visual written to disk — page, report, dashboard, mockup, diagram, or poster. Load before the first line of markup or CSS whenever something has to look right, or a redesign is asked for. Not for app code the project's own design system already governs.\\nallowed-tools: read, write, edit, grep, find, ls\\n---\\n\\n# Designing a visual\\n\\nhoocode writes visuals as one self-contained `.html` file on disk. There is no\\nhost, no CSP, and no gallery: fonts and libraries may come from a CDN or from\\nlocal files, and the page is yours to lay out however the subject demands. The\\nconstraint that remains is the only one that ever mattered — it has to be good.\\n\\nNot for a canvas extension. A canvas serves a live page from its own loopback\\nserver, under constraints that contradict half of this file, and `/new-canvas`\\npoints at `../canvas-design/SKILL.md` for it.\\n\\n## First, read the request\\n\\nDecide the treatment, not whether to design. Every visual gets real typographic\\nhierarchy, considered spacing, and a deliberate palette. What varies is how far\\npast that you go.\\n\\n- **Utilitarian** — a report, a plan, a status page, a diagram. Most requests.\\n Make it clean and well-composed. Skip the oversized hero. Keep flourishes few.\\n- **Editorial** — a landing page, a poster, something the user will show other\\n people. Take a real point of view and one deliberate risk.\\n\\nWhen unsure, build the well-composed version. A restrained page is never wrong;\\nan over-designed one sometimes is.\\n\\n## Honor what already exists\\n\\nLook before you invent. If the repo has a design system — a tokens file, a\\ntheme, CSS variables, an existing stylesheet, a brand section in a project\\ncontext file — use it. Precedence is always:\\n\\n1. What the user asked for, in their words\\n2. The project's existing system\\n3. Your own choices\\n\\nYour choices fill gaps. They never override the first two.\\n\\n## Write the plan before the markup\\n\\nThis is the part that does the work. Before any code, write down:\\n\\n- **Color** — 4 to 6 named hex values. Name them by role (`ink`, `ground`,\\n `accent`, `muted`), not by hue.\\n- **Type** — at least two faces with distinct jobs: one with character for\\n display, one comfortable for body text, and a third for data or captions if\\n the content needs it. Name the fallback stack for each.\\n- **Layout** — the structural idea in one or two sentences.\\n\\nThen build from the plan and derive every color and type decision from it. A\\npage assembled without a plan reads as assembled without a plan.\\n\\n## Fundamentals\\n\\n**Ground it in the subject.** One concrete subject, one audience, one job for\\nthe page. Distinctive choices come from the subject's own world — its materials,\\nits vocabulary, how people in it actually talk. Use real content throughout.\\nNever lorem, never placeholder rows.\\n\\n**Type carries the page,** including when the page is not about type. Keep\\nrunning text near 65 characters wide. Set a scale and stay on it. Give headings\\n`text-wrap: balance`, give body text line-height room, give uppercase labels a\\nlittle letter-spacing. Always declare a real fallback stack — a silent fallback\\nis the most common way a good design ships looking wrong.\\n\\n**Pick the neutrals.** A pure mid-grey reads as unconsidered. Bias the greys\\nslightly toward the accent hue and they read as chosen. Pure white and near-black\\nare fine grounds when the subject wants them; the point is that you decided.\\n\\n**Let layout do the spacing.** Flex or grid with `gap`, not per-element margins\\nthat collapse or double unpredictably. Wide content — tables, code blocks,\\ndiagrams — gets its own `overflow-x: auto` container so the page body never\\nscrolls sideways. Use `font-variant-numeric: tabular-nums` wherever digits line\\nup in a column.\\n\\n**Design both themes.** A local page sees only `prefers-color-scheme`, so this\\nis simpler here than on a hosted target: define the complete palette as custom\\nproperties on `:root`, redefine only those properties inside\\n`@media (prefers-color-scheme: dark)`, and style every component through the\\nproperties. Never give a color its only definition inside the media block — that\\nis how a page ends up rendering one theme's text on the other theme's ground.\\nSet an explicit `background` on `body`. Give the second theme the same attention\\nas the first rather than inverting it mechanically; check that the accent still\\nworks on both grounds. A page that deliberately commits to one visual world may\\nstay single-theme, but then paint every color explicitly so it holds either way.\\n\\n**Structure should encode something true.** Numbered markers, eyebrows,\\ndividers, and section labels are information, not decoration. Number things only\\nwhen the order actually matters to the reader.\\n\\n**When it is a UI, not a document,** the craft shifts from typography to\\ninformation design. A dashboard is scanned, not read. Put the summary above the\\ndetail. Encode state in form as well as in number — a pill, a chip, a severity\\nstripe — so what needs attention is visible at a glance. Semantic color (good,\\nwarning, critical) is a separate system from your accent and does not count as\\nusing it. Anything interactive should look interactive.\\n\\n## Avoid the generated look\\n\\nMachine-generated design keeps landing on the same handful of looks. When the\\nuser has specified a direction, follow it exactly, including if it is one of\\nthese. When nothing is specified, do not spend the freedom here:\\n\\n- Warm cream ground, serif display face, terracotta accent\\n- Near-black ground with a single acid-green or vermilion pop\\n- Hairline rules and dense columns imitating a broadsheet\\n- Purple-to-blue gradient hero on white\\n- Inter or Space Grotesk chosen as the safe default\\n- Emoji as section markers\\n- Everything centered\\n- Uniform large corner radii on every surface\\n- A colored accent rail down the side of every card\\n\\n## Words are design material\\n\\nWrite from the reader's side of the screen. Name things the way they would name\\nthem, not the way the system is built. Active voice. A control says exactly what\\nit does, and the confirmation matches it. Errors say what went wrong and what to\\ndo about it. Specific beats clever.\\n\\nGive the page a real `<title>` — a short, specific noun phrase, not a category\\nlabel and not a name with an explainer bolted on after a dash.\\n\\n## Libraries, and why the answer is usually none\\n\\nA hosted page and a file on disk fail differently, and that decides this. A\\nhosted page is always viewed online, so a CDN dependency is free. A file gets\\nmoved, attached to mail, and opened on a laptop in a tunnel — and there a\\nruntime dependency does not degrade, it collapses. Tailwind from a CDN with no\\nnetwork is an unstyled document. React from a CDN with no network is a blank\\none.\\n\\nSo the default is no runtime dependency at all. Write plain CSS; modern CSS has\\ncustom properties, grid, `clamp()`, and container queries, and a page that needs\\na utility framework to be laid out usually needs a clearer layout instead.\\n\\nThere is no build step here and nothing bundles this file, so a framework that\\nexpects one — Vite, a JSX pipeline, anything importing bare module specifiers —\\nis not an option regardless.\\n\\nWhen a library genuinely earns its place, and that is mostly charting or syntax\\nhighlighting rather than layout:\\n\\n- Inline it into the file if its licence permits, and the page stays whole.\\n- Otherwise pin an exact version, give the feature a readable fallback for when\\n the script does not load, and tell the user the page needs network.\\n\\nWebfonts are the one dependency that degrades gracefully, because a real\\nfallback stack keeps the page readable when the link fails. Use one, and always\\ndeclare the stack.\\n\\n## Build cleanly\\n\\n- Watch selector specificity. Type-level and element-level selectors fighting\\n over the same padding is how spacing silently comes undone.\\n- Close every non-void element and double-quote every attribute.\\n- Give keyboard focus a visible state.\\n- Respect `prefers-reduced-motion`.\\n- For generative or decorative graphics, reach for Canvas or WebGL rather than\\n hand-authoring long SVG path data.\\n- Before finishing, scan the stylesheet for any color declared only inside a\\n media query.\\n\\n## Delivering it\\n\\nWrite one self-contained `.html` file. Inline the page's own CSS and JS; embed\\nsmall assets as data URIs so the file survives being moved or sent to someone.\\n\\nPut it where the user would expect it — alongside the data it visualizes, or in\\nthe directory they named. Then give them the path as a markdown link with a\\n`file://` URL:\\n\\n```\\n[tokens.html](file:///abs/path/to/tokens.html)\\n```\\n\\nhoocode's markdown renderer turns that into an OSC 8 hyperlink wherever the\\nterminal supports one, so it is clickable in kitty, iTerm2, WezTerm and others,\\nand still readable as plain text everywhere else. Offer to open it rather than\\nopening it unasked.\\n\\nCanvas is not a viewer for this. `/canvas` hosts canvas extensions — a directory\\nwith an `extension.mjs` speaking the canvas JSON-RPC protocol — and `/canvas\\nopen` takes an extension id, not a file path. A page you can hand someone is a\\nfile; reach for `/new-canvas` only when the user wants a live surface the agent\\ncan call typed actions on, which is a different and larger job than a visual.\\n\",\n\t\"canvas-design/SKILL.md\":\n\t\t\"---\\nname: canvas-design\\ndescription: How to make a canvas extension's page good — layout, styling, live state, and the dependency and token constraints the surface imposes. Read when building or editing a canvas; the /new-canvas brief points here.\\ndisable-model-invocation: true\\nallowed-tools: read, write, edit, grep, find, ls\\n---\\n\\n# Designing a canvas\\n\\nA canvas is not a document. It is a small application: a page served over\\nloopback that a person operates while you drive the same state through typed\\nactions. Both of you are live on it at once, and that is the whole design\\nproblem.\\n\\nRead `../artifact-design/SKILL.md` for the fundamentals — treatment, the\\ncolor/type/layout plan you write before any markup, neutrals, spacing, the\\ngenerated-look list. All of it applies. This file covers only what is different\\nbecause the surface is a canvas, and where the two disagree, this file wins.\\n\\n## What the catalog already tells you\\n\\nOf the 23 extensions in GitHub's canvas catalog, 22 import nothing but\\n`@github/copilot-sdk` and `node:` builtins. The single exception ships a README\\ntelling the user to `npm install` by hand. Zero dependencies is not a\\nrestriction someone imposed on you; it is what working canvases actually do.\\n\\nThe flagship, `pr-artifact-explorer`, is a rich **read** surface the agent\\nnavigates — its shared state is a cache and a route, and neither party co-edits\\ncontent. It sidesteps concurrent editing entirely. Treat that as evidence about\\nwhat is easy and what is not: a canvas that shows state well is worth far more\\nthan one that lets both parties type into the same field.\\n\\n## The page lives inside a template string\\n\\nThe HTML is a JavaScript template literal in `extension.mjs`, not a file. Two\\nconsequences worth planning around rather than discovering:\\n\\n- Every backtick and `${` in your CSS or markup needs escaping. A `grid-template`\\n value or a JS snippet with a template literal inside it will break the outer\\n string. Prefer plain quotes and avoid nesting template literals.\\n- There is no stylesheet to open in an editor. Keep the CSS in one clearly\\n delimited chunk near the top of the served string so it stays findable, rather\\n than scattering inline `style=` attributes.\\n\\nIf the page grows past a screenful of markup, serve it from a separate file in\\nthe extension directory and read it at request time. The extension is already an\\nHTTP server; it can serve its own assets. That is the escape hatch from string\\nescaping, and it does not violate the no-dependency rule.\\n\\n## No dependencies, and no build\\n\\n`package.json` and `node_modules` are forbidden in the extension directory, so\\nthere is nothing to install and nothing to bundle. Write plain CSS and plain\\nDOM. Modern CSS has custom properties, grid, and `clamp()`; a canvas that needs\\na utility framework needs a clearer layout instead.\\n\\nDo not reach for a CDN either. The page is served from `127.0.0.1`, so it works\\nwith no network — a CDN script throws that away and turns an offline-capable\\nlocal tool into a broken one.\\n\\n## You own the theme completely\\n\\nThe canvas protocol carries no theme, no palette, and no styling hook. Nothing\\nis inherited. A page that sets no colors gets browser defaults, which is why the\\nscaffold's placeholder looks like nothing.\\n\\nSo define the full palette as custom properties on `:root`, redefine them under\\n`@media (prefers-color-scheme: dark)`, and style everything through them. Set an\\nexplicit `background` on `body`. This is the same discipline as any page, with\\none simplification: there is no host stamping `data-theme`, so two states is the\\nwhole problem.\\n\\n## Design for two operators\\n\\nThe person changes state through the page. You change the same state through\\n`invoke_canvas_action`. The page has to be honest about that:\\n\\n- **Render from server state, not from what the user just clicked.** After an\\n action mutates state, the page must be able to show the new truth. Poll on a\\n short interval, or push with SSE — both are a few lines with no dependency.\\n- **Make agent-reachable state visible.** If an action can add a note, the notes\\n should be on screen. State only you can see is state the person cannot trust.\\n- **Do not build co-editing.** Concurrent edits to one field is the hard problem\\n the reference canvas declined to solve. Prefer append, toggle, and select over\\n a shared text buffer.\\n- **Show that something changed.** When state moves underneath the person, a\\n brief highlight on the changed row beats a silent re-render.\\n\\n## Actions are tool schemas, so they cost\\n\\nEvery action becomes an agent-callable tool while the instance is open, and its\\nname, description, and `inputSchema` are re-sent on every request for as long as\\nit stays open. Declare the actions the canvas actually needs and give each a\\ntight schema — not one per button.\\n\\nAction results land in the model's context too. Return a summary and a count,\\nnot the whole collection; where a list is genuinely useful, slice it and set a\\nflag saying you did. Measure with `hoocode --print-token-surface` while a canvas\\nis open.\\n\\n## Reload replaces the URL\\n\\nReloading forks a new process and hands back a **new** URL; the tab the person\\nhad open dies with the old one. Two design consequences:\\n\\n- Keep meaningful state on the server side of the canvas, not in the page. A\\n scroll position is fine to lose; a half-filled form is not.\\n- Give the person the new URL every time you reload, and say the old tab is\\n dead. A page that silently stopped updating looks like a bug you caused.\\n\\n## Before you call it done\\n\\n- Open it and look, rather than reasoning about the markup.\\n- Check both color schemes.\\n- Resize narrow — a canvas is often a side window, not a full screen.\\n- Invoke each action and confirm the page reflects it without a manual refresh.\\n- Confirm the page still renders with the network off.\\n\",\n\t\"plugin-authoring/SKILL.md\":\n\t\t\"---\\nname: plugin-authoring\\ndescription: How to author a portable, reusable hoocode plugin — when a capability is worth extracting, how to name and describe it so it triggers again, and what makes content portable across repos and machines. Use before calling ProposePlugin or UpdatePlugin, or when deciding whether a recipe you just completed is worth keeping.\\nallowed-tools: read, write, edit, grep, find, ls\\n---\\n\\n# Authoring a plugin\\n\\nThis is the craft half of the plugin tools. `ProposePlugin` and `UpdatePlugin`\\nknow how to *write* a plugin; this describes how to write a *good* one. Read it\\nbefore authoring, not after.\\n\\n## When a capability is worth extracting\\n\\nExtract when both are true:\\n\\n- You completed a multi-step recipe you would plausibly repeat — or you repeated\\n the same pattern twice in one session.\\n- `SearchPlugins` found nothing that already covers it.\\n\\nDo not extract a one-off. A job that came up twice may just be a job that came up\\ntwice; the test is whether the *shape* recurs, not whether the task did.\\n\\n## Name and describe by the capability, not the occasion\\n\\nThe description is the only thing loaded on every turn, and it is the entire\\nbasis on which the plugin is chosen later. Write it for the next situation, not\\nfor the one that prompted it.\\n\\n- Bad: `fix-flaky-auth-test` — names the incident. It will never trigger again.\\n- Good: `flaky-test-triage` — names the capability, with a description saying\\n when to reach for it.\\n\\nSay *when to use it* in the description, in the words someone would use when\\nthey need it. A description that only says what the plugin is will not trigger.\\n\\n## Portability\\n\\nThe plugin has to work in a repo you have never seen, on a machine you do not\\ncontrol:\\n\\n- No absolute paths, no machine-specific paths. Prefer relative paths and\\n runtime discovery.\\n- No embedded secrets, tokens, or environment-specific values.\\n- No assumptions about the current repo unless that *is* the capability's point.\\n- State prerequisites in the body rather than assuming them.\\n\\nThe layout is the session's target platform. You never choose it.\\n\\n## Shape\\n\\nPut the whole plugin in one call — skills plus a hook go together, not in two\\npasses. The risk gate is computed from the content, so do not pre-classify:\\nread-only subagents, skills and commands go straight through; hooks, MCP\\nservers, or a subagent needing bash/write/edit/MCP or `tools: *` pause for human\\nconfirmation.\\n\\nPassive content activates immediately and is reversible with `UninstallPlugin`.\\nAnnounce what you created and why.\\n\\n## Growing one you already authored\\n\\n`UpdatePlugin` is additive: supply only the delta, and existing capabilities are\\npreserved (a matching name replaces just that one). It cannot remove anything —\\nthat is `RemovePluginCapability`.\\n\\nHooks are the exception to \\\"additive is safe\\\". They have no name, so supplying a\\nchanged command **adds a second hook alongside the old one** and both fire. To\\nchange a hook, remove the old one first, then add the new one.\\n\\nAdding a passive skill to an already-executable plugin does not re-prompt; only\\nexecutable *additions* trigger confirmation.\\n\\n## Two things that are never yours to do\\n\\n- Never grant a subagent a plugin-system tool (`InstallPlugin`, `ProposePlugin`,\\n …). It is rejected, and the reason is that an agent that can install plugins\\n for other agents is a self-propagation primitive.\\n- Never publish to a marketplace autonomously. Packaging is yours; publishing is\\n a human action, because pushing executable code into a marketplace other\\n agents install from unattended is a supply-chain compromise.\\n\",\n};\n"]}
|
|
@@ -10,9 +10,11 @@ export const EMBEDDED_MODES = {
|
|
|
10
10
|
};
|
|
11
11
|
export const EMBEDDED_PROFILES = {};
|
|
12
12
|
export const EMBEDDED_AGENT_PROMPTS = {
|
|
13
|
+
"code-review": "---\nname: code-review\ndescription: |\n Use this subagent when:\n - Reviewing a diff, branch, or files for defects before merge\n - The user asks for a review, a second pass, or what they missed\n - Findings are wanted without spending parent context on every changed file\n\n DO NOT use for:\n - Applying the fixes (this agent reports; the parent decides)\n - Hunting for security vulnerabilities specifically (use security-review)\n\n Output: Ranked findings, each with path:line, the defect, and how it fails.\n Cost: Medium (reads the full diff and surrounding code)\n Isolation: Read-only; can run in parallel with other review tasks\ntools: read, bash, grep, find, ls\nmodel: capable\nbackground: true\n---\nYou are a code-review agent running inside hoocode. You find defects in changed\ncode and report them. You never edit files. You run in an isolated context and\ncannot see the parent conversation, so state findings in full rather than\nreferring back to a discussion you cannot read.\n\nScope:\n- Do not create, modify, or delete files.\n- Use bash for read-only git commands (`git diff`, `git log`, `git show`) to\n establish what changed. Do not commit, push, stash, or check out.\n- Review what the caller named. If they named nothing, review the working tree\n diff, then the branch against its base.\n\nMethod:\n1. Establish the diff. Read every changed hunk before forming an opinion.\n2. Read enough surrounding code to know whether a hunk is actually wrong. A\n line that looks suspicious in isolation is usually fine in context.\n3. For each candidate finding, construct the concrete failure: the input or\n state that triggers it, and the wrong output or crash that results. If you\n cannot construct one, it is not a finding.\n4. Rank what survives by severity.\n\nWhat counts as a finding:\n- Correctness: logic that produces a wrong result, a crash, unhandled errors,\n off-by-one, wrong operator, a case the code does not cover.\n- Contract violations: a caller that does not match the callee's expectations,\n a type narrowed incorrectly, an invariant the change breaks.\n- Reuse: the change hand-rolls something the codebase already provides.\n- Efficiency: work repeated in a loop that belongs outside it, an avoidable\n quadratic, a re-read of something already in memory.\n\nWhat does not:\n- Style, formatting, or naming the linter does not flag.\n- Restating what the code does without saying what is wrong with it.\n- Speculative hardening for inputs the code cannot receive.\n\nGuidance:\n- Verify before reporting. A confident wrong finding costs the caller more than\n a missed one, because they have to read the code to disprove it.\n- Report as a ranked list: `path:line`, one sentence naming the defect, then the\n failure case. No preamble, no summary of the change, no tool logs.\n- If nothing survives verification, say so plainly. An empty review is a\n legitimate result.\n",
|
|
13
14
|
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 commands that change state\n\n Output: Concise summary, file list, or plan. No code changes.\n Cost: Low (read-only)\n Isolation: Can run in parallel with other explore tasks\ntools: read, grep, find, ls\nmodel: fast\nbackground: true\n---\nYou are an explore-only agent running inside hoocode. You read code and produce summaries. You NEVER edit files. You run in an isolated context and cannot see the parent conversation.\n\nScope:\n- Do not modify, create, or delete files, and do not run commands.\n- Use read, grep, find, and ls 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",
|
|
14
15
|
"general-purpose": "---\nname: general-purpose\ndescription: |\n Use this subagent when:\n - A task is multi-step or open-ended and needs both investigation and action\n - No other agent clearly fits\n - You are searching for code or a pattern and are unsure where it lives\n - The work spans reading, editing, and running commands together\n\n Prefer the explore agent when the task is clearly read-only.\n\n Output: The completed result plus a summary of what was done and where.\n Cost: Variable (read + write + run)\n Isolation: Should not run concurrently with other write tasks on the same files\ntools: read, bash, edit, write, grep, find, ls\nmodel: standard\ndelegate: true\n---\nYou are a general-purpose subagent running inside hoocode. You handle multi-step and open-ended tasks end to end. You run in an isolated context and cannot see the parent conversation.\n\nScope:\n- You may read, search, edit, and write files, and run commands needed to complete the task.\n- Stay within the requested task. Do not refactor or change unrelated code.\n\nMethod:\n1. Break the task into concrete steps.\n2. Investigate before acting: read the relevant files and trace the logic.\n3. Make the smallest changes that fully satisfy the task, matching existing style.\n4. Verify your work (re-read changed regions; run the relevant checks or tests when applicable).\n\nDelegation:\n- When the Task tool is available (subagents enabled and the nesting cap allows it), you may delegate self-contained, independent subtasks — for example dispatch an `explore` subagent to investigate a separate area while you work. Otherwise do the work directly.\n\nGuidance:\n- Your final answer is the only thing the caller receives. Make it self-contained.\n- Summarize what you did 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",
|
|
15
16
|
plan: "---\nname: plan\ndescription: |\n Use this subagent when:\n - You need to research a codebase before proposing an implementation plan\n - A task requires understanding scope, affected files, and approach without\n making any changes yet\n - You are in plan mode and want focused investigation to back the plan\n\n DO NOT use for:\n - Making code changes (this agent is read-only)\n - Quick single-file lookups (use explore)\n\n Output: A concrete plan — the approach, the files to change, and the steps.\n Cost: Low–medium (read-only)\n Isolation: Can run in parallel with explore tasks\ntools: read, grep, find, ls\nmodel: standard\nbackground: true\n---\nYou are a planning agent running inside hoocode. You research the codebase and\nproduce a concrete implementation plan. You NEVER modify files. You run in an\nisolated context and cannot see the parent conversation.\n\nScope:\n- Do not create, modify, or delete files, and do not run commands.\n- Use read, grep, find, and ls to understand the code and its structure.\n\nMethod:\n1. Restate the goal and identify what you need to learn to plan it.\n2. Investigate: locate the relevant code, trace the logic, note constraints.\n3. Produce a plan: the approach, the exact files/functions to change (path:line),\n the ordered steps, and any risks or open questions.\n\nGuidance:\n- Your final answer is the only thing the caller receives. Make the plan\n self-contained and actionable.\n- Be specific: cite paths and line numbers; call out trade-offs and unknowns.\n- Do not narrate your search or include tool logs.\n",
|
|
17
|
+
"security-review": "---\nname: security-review\ndescription: |\n Use this subagent when:\n - Reviewing changes for vulnerabilities before merge or release\n - The change touches auth, input parsing, paths, subprocesses, or secrets\n - The user asks for a security review or audit of pending work\n\n DO NOT use for:\n - General correctness and quality review (use code-review)\n - Applying the fixes (this agent reports; the parent decides)\n\n Output: Findings ranked by severity, each with path:line, the attack, and the\n fix.\n Cost: Medium (reads the diff and traces untrusted input)\n Isolation: Read-only; can run in parallel with other review tasks\ntools: read, bash, grep, find, ls\nmodel: capable\nbackground: true\n---\nYou are a security-review agent running inside hoocode. You find vulnerabilities\nin changed code and report them. You never edit files. You run in an isolated\ncontext and cannot see the parent conversation, so state findings in full rather\nthan referring back to a discussion you cannot read.\n\nScope:\n- Do not create, modify, or delete files.\n- Use bash for read-only git commands (`git diff`, `git log`, `git show`) to\n establish what changed. Do not commit, push, stash, or check out.\n- Review what the caller named. If they named nothing, review the working tree\n diff, then the branch against its base.\n\nMethod:\n1. Establish the diff, then identify every point where the change accepts input\n it does not control: arguments, environment, files, network responses, tool\n output, model output.\n2. Trace each one to where it is used. A vulnerability is a path from untrusted\n input to a dangerous operation, so follow the path rather than pattern\n matching on the operation.\n3. For each candidate, construct the attack: what an attacker supplies, what\n they gain. If you cannot construct one, it is not a finding.\n4. Rank what survives by severity, worst first.\n\nWhere to look hardest:\n- Command execution: shell strings built from input, argument arrays that can be\n injected, a path that reaches an interpreter.\n- Path handling: traversal via `..` or absolute paths, symlinks, writes outside\n an intended root.\n- Secrets: credentials logged, embedded in errors, written to disk, sent to a\n provider that does not need them.\n- Deserialization and parsing: untrusted JSON, YAML, or archives fed to a parser\n that can execute or allocate unboundedly.\n- Authorization: a check that can be bypassed, a permission gate the change\n routes around, a default that fails open.\n- Injection into generated content: HTML, SQL, or prompt text assembled from\n input without escaping.\n\nWhat does not count:\n- A theoretical issue in code the change did not touch and does not reach.\n- Missing hardening with no reachable attack path.\n- Dependency advisories the change neither introduces nor exercises.\n\nGuidance:\n- Verify reachability before reporting. An unreachable finding wastes the\n caller's time and erodes trust in the review.\n- Report as a severity-ranked list: `path:line`, the attack in one or two\n sentences, then the fix. No preamble, no tool logs.\n- Where a fix has a safer and a more convenient form, name the safer one.\n- If nothing survives verification, say so plainly.\n",
|
|
16
18
|
};
|
|
17
19
|
export const EMBEDDED_PROMPTS = {
|
|
18
20
|
"grill-bridge": "Once the user has answered, fold their answers into the plan and immediately continue with this review:\n",
|
|
@@ -24,6 +26,8 @@ export const EMBEDDED_PROMPTS = {
|
|
|
24
26
|
};
|
|
25
27
|
/** Built-in skills, keyed by path relative to templates/skills (POSIX separators). */
|
|
26
28
|
export const EMBEDDED_SKILLS = {
|
|
29
|
+
"artifact-design/SKILL.md": "---\nname: artifact-design\ndescription: Build a self-contained HTML visual written to disk — page, report, dashboard, mockup, diagram, or poster. Load before the first line of markup or CSS whenever something has to look right, or a redesign is asked for. Not for app code the project's own design system already governs.\nallowed-tools: read, write, edit, grep, find, ls\n---\n\n# Designing a visual\n\nhoocode writes visuals as one self-contained `.html` file on disk. There is no\nhost, no CSP, and no gallery: fonts and libraries may come from a CDN or from\nlocal files, and the page is yours to lay out however the subject demands. The\nconstraint that remains is the only one that ever mattered — it has to be good.\n\nNot for a canvas extension. A canvas serves a live page from its own loopback\nserver, under constraints that contradict half of this file, and `/new-canvas`\npoints at `../canvas-design/SKILL.md` for it.\n\n## First, read the request\n\nDecide the treatment, not whether to design. Every visual gets real typographic\nhierarchy, considered spacing, and a deliberate palette. What varies is how far\npast that you go.\n\n- **Utilitarian** — a report, a plan, a status page, a diagram. Most requests.\n Make it clean and well-composed. Skip the oversized hero. Keep flourishes few.\n- **Editorial** — a landing page, a poster, something the user will show other\n people. Take a real point of view and one deliberate risk.\n\nWhen unsure, build the well-composed version. A restrained page is never wrong;\nan over-designed one sometimes is.\n\n## Honor what already exists\n\nLook before you invent. If the repo has a design system — a tokens file, a\ntheme, CSS variables, an existing stylesheet, a brand section in a project\ncontext file — use it. Precedence is always:\n\n1. What the user asked for, in their words\n2. The project's existing system\n3. Your own choices\n\nYour choices fill gaps. They never override the first two.\n\n## Write the plan before the markup\n\nThis is the part that does the work. Before any code, write down:\n\n- **Color** — 4 to 6 named hex values. Name them by role (`ink`, `ground`,\n `accent`, `muted`), not by hue.\n- **Type** — at least two faces with distinct jobs: one with character for\n display, one comfortable for body text, and a third for data or captions if\n the content needs it. Name the fallback stack for each.\n- **Layout** — the structural idea in one or two sentences.\n\nThen build from the plan and derive every color and type decision from it. A\npage assembled without a plan reads as assembled without a plan.\n\n## Fundamentals\n\n**Ground it in the subject.** One concrete subject, one audience, one job for\nthe page. Distinctive choices come from the subject's own world — its materials,\nits vocabulary, how people in it actually talk. Use real content throughout.\nNever lorem, never placeholder rows.\n\n**Type carries the page,** including when the page is not about type. Keep\nrunning text near 65 characters wide. Set a scale and stay on it. Give headings\n`text-wrap: balance`, give body text line-height room, give uppercase labels a\nlittle letter-spacing. Always declare a real fallback stack — a silent fallback\nis the most common way a good design ships looking wrong.\n\n**Pick the neutrals.** A pure mid-grey reads as unconsidered. Bias the greys\nslightly toward the accent hue and they read as chosen. Pure white and near-black\nare fine grounds when the subject wants them; the point is that you decided.\n\n**Let layout do the spacing.** Flex or grid with `gap`, not per-element margins\nthat collapse or double unpredictably. Wide content — tables, code blocks,\ndiagrams — gets its own `overflow-x: auto` container so the page body never\nscrolls sideways. Use `font-variant-numeric: tabular-nums` wherever digits line\nup in a column.\n\n**Design both themes.** A local page sees only `prefers-color-scheme`, so this\nis simpler here than on a hosted target: define the complete palette as custom\nproperties on `:root`, redefine only those properties inside\n`@media (prefers-color-scheme: dark)`, and style every component through the\nproperties. Never give a color its only definition inside the media block — that\nis how a page ends up rendering one theme's text on the other theme's ground.\nSet an explicit `background` on `body`. Give the second theme the same attention\nas the first rather than inverting it mechanically; check that the accent still\nworks on both grounds. A page that deliberately commits to one visual world may\nstay single-theme, but then paint every color explicitly so it holds either way.\n\n**Structure should encode something true.** Numbered markers, eyebrows,\ndividers, and section labels are information, not decoration. Number things only\nwhen the order actually matters to the reader.\n\n**When it is a UI, not a document,** the craft shifts from typography to\ninformation design. A dashboard is scanned, not read. Put the summary above the\ndetail. Encode state in form as well as in number — a pill, a chip, a severity\nstripe — so what needs attention is visible at a glance. Semantic color (good,\nwarning, critical) is a separate system from your accent and does not count as\nusing it. Anything interactive should look interactive.\n\n## Avoid the generated look\n\nMachine-generated design keeps landing on the same handful of looks. When the\nuser has specified a direction, follow it exactly, including if it is one of\nthese. When nothing is specified, do not spend the freedom here:\n\n- Warm cream ground, serif display face, terracotta accent\n- Near-black ground with a single acid-green or vermilion pop\n- Hairline rules and dense columns imitating a broadsheet\n- Purple-to-blue gradient hero on white\n- Inter or Space Grotesk chosen as the safe default\n- Emoji as section markers\n- Everything centered\n- Uniform large corner radii on every surface\n- A colored accent rail down the side of every card\n\n## Words are design material\n\nWrite from the reader's side of the screen. Name things the way they would name\nthem, not the way the system is built. Active voice. A control says exactly what\nit does, and the confirmation matches it. Errors say what went wrong and what to\ndo about it. Specific beats clever.\n\nGive the page a real `<title>` — a short, specific noun phrase, not a category\nlabel and not a name with an explainer bolted on after a dash.\n\n## Libraries, and why the answer is usually none\n\nA hosted page and a file on disk fail differently, and that decides this. A\nhosted page is always viewed online, so a CDN dependency is free. A file gets\nmoved, attached to mail, and opened on a laptop in a tunnel — and there a\nruntime dependency does not degrade, it collapses. Tailwind from a CDN with no\nnetwork is an unstyled document. React from a CDN with no network is a blank\none.\n\nSo the default is no runtime dependency at all. Write plain CSS; modern CSS has\ncustom properties, grid, `clamp()`, and container queries, and a page that needs\na utility framework to be laid out usually needs a clearer layout instead.\n\nThere is no build step here and nothing bundles this file, so a framework that\nexpects one — Vite, a JSX pipeline, anything importing bare module specifiers —\nis not an option regardless.\n\nWhen a library genuinely earns its place, and that is mostly charting or syntax\nhighlighting rather than layout:\n\n- Inline it into the file if its licence permits, and the page stays whole.\n- Otherwise pin an exact version, give the feature a readable fallback for when\n the script does not load, and tell the user the page needs network.\n\nWebfonts are the one dependency that degrades gracefully, because a real\nfallback stack keeps the page readable when the link fails. Use one, and always\ndeclare the stack.\n\n## Build cleanly\n\n- Watch selector specificity. Type-level and element-level selectors fighting\n over the same padding is how spacing silently comes undone.\n- Close every non-void element and double-quote every attribute.\n- Give keyboard focus a visible state.\n- Respect `prefers-reduced-motion`.\n- For generative or decorative graphics, reach for Canvas or WebGL rather than\n hand-authoring long SVG path data.\n- Before finishing, scan the stylesheet for any color declared only inside a\n media query.\n\n## Delivering it\n\nWrite one self-contained `.html` file. Inline the page's own CSS and JS; embed\nsmall assets as data URIs so the file survives being moved or sent to someone.\n\nPut it where the user would expect it — alongside the data it visualizes, or in\nthe directory they named. Then give them the path as a markdown link with a\n`file://` URL:\n\n```\n[tokens.html](file:///abs/path/to/tokens.html)\n```\n\nhoocode's markdown renderer turns that into an OSC 8 hyperlink wherever the\nterminal supports one, so it is clickable in kitty, iTerm2, WezTerm and others,\nand still readable as plain text everywhere else. Offer to open it rather than\nopening it unasked.\n\nCanvas is not a viewer for this. `/canvas` hosts canvas extensions — a directory\nwith an `extension.mjs` speaking the canvas JSON-RPC protocol — and `/canvas\nopen` takes an extension id, not a file path. A page you can hand someone is a\nfile; reach for `/new-canvas` only when the user wants a live surface the agent\ncan call typed actions on, which is a different and larger job than a visual.\n",
|
|
30
|
+
"canvas-design/SKILL.md": "---\nname: canvas-design\ndescription: How to make a canvas extension's page good — layout, styling, live state, and the dependency and token constraints the surface imposes. Read when building or editing a canvas; the /new-canvas brief points here.\ndisable-model-invocation: true\nallowed-tools: read, write, edit, grep, find, ls\n---\n\n# Designing a canvas\n\nA canvas is not a document. It is a small application: a page served over\nloopback that a person operates while you drive the same state through typed\nactions. Both of you are live on it at once, and that is the whole design\nproblem.\n\nRead `../artifact-design/SKILL.md` for the fundamentals — treatment, the\ncolor/type/layout plan you write before any markup, neutrals, spacing, the\ngenerated-look list. All of it applies. This file covers only what is different\nbecause the surface is a canvas, and where the two disagree, this file wins.\n\n## What the catalog already tells you\n\nOf the 23 extensions in GitHub's canvas catalog, 22 import nothing but\n`@github/copilot-sdk` and `node:` builtins. The single exception ships a README\ntelling the user to `npm install` by hand. Zero dependencies is not a\nrestriction someone imposed on you; it is what working canvases actually do.\n\nThe flagship, `pr-artifact-explorer`, is a rich **read** surface the agent\nnavigates — its shared state is a cache and a route, and neither party co-edits\ncontent. It sidesteps concurrent editing entirely. Treat that as evidence about\nwhat is easy and what is not: a canvas that shows state well is worth far more\nthan one that lets both parties type into the same field.\n\n## The page lives inside a template string\n\nThe HTML is a JavaScript template literal in `extension.mjs`, not a file. Two\nconsequences worth planning around rather than discovering:\n\n- Every backtick and `${` in your CSS or markup needs escaping. A `grid-template`\n value or a JS snippet with a template literal inside it will break the outer\n string. Prefer plain quotes and avoid nesting template literals.\n- There is no stylesheet to open in an editor. Keep the CSS in one clearly\n delimited chunk near the top of the served string so it stays findable, rather\n than scattering inline `style=` attributes.\n\nIf the page grows past a screenful of markup, serve it from a separate file in\nthe extension directory and read it at request time. The extension is already an\nHTTP server; it can serve its own assets. That is the escape hatch from string\nescaping, and it does not violate the no-dependency rule.\n\n## No dependencies, and no build\n\n`package.json` and `node_modules` are forbidden in the extension directory, so\nthere is nothing to install and nothing to bundle. Write plain CSS and plain\nDOM. Modern CSS has custom properties, grid, and `clamp()`; a canvas that needs\na utility framework needs a clearer layout instead.\n\nDo not reach for a CDN either. The page is served from `127.0.0.1`, so it works\nwith no network — a CDN script throws that away and turns an offline-capable\nlocal tool into a broken one.\n\n## You own the theme completely\n\nThe canvas protocol carries no theme, no palette, and no styling hook. Nothing\nis inherited. A page that sets no colors gets browser defaults, which is why the\nscaffold's placeholder looks like nothing.\n\nSo define the full palette as custom properties on `:root`, redefine them under\n`@media (prefers-color-scheme: dark)`, and style everything through them. Set an\nexplicit `background` on `body`. This is the same discipline as any page, with\none simplification: there is no host stamping `data-theme`, so two states is the\nwhole problem.\n\n## Design for two operators\n\nThe person changes state through the page. You change the same state through\n`invoke_canvas_action`. The page has to be honest about that:\n\n- **Render from server state, not from what the user just clicked.** After an\n action mutates state, the page must be able to show the new truth. Poll on a\n short interval, or push with SSE — both are a few lines with no dependency.\n- **Make agent-reachable state visible.** If an action can add a note, the notes\n should be on screen. State only you can see is state the person cannot trust.\n- **Do not build co-editing.** Concurrent edits to one field is the hard problem\n the reference canvas declined to solve. Prefer append, toggle, and select over\n a shared text buffer.\n- **Show that something changed.** When state moves underneath the person, a\n brief highlight on the changed row beats a silent re-render.\n\n## Actions are tool schemas, so they cost\n\nEvery action becomes an agent-callable tool while the instance is open, and its\nname, description, and `inputSchema` are re-sent on every request for as long as\nit stays open. Declare the actions the canvas actually needs and give each a\ntight schema — not one per button.\n\nAction results land in the model's context too. Return a summary and a count,\nnot the whole collection; where a list is genuinely useful, slice it and set a\nflag saying you did. Measure with `hoocode --print-token-surface` while a canvas\nis open.\n\n## Reload replaces the URL\n\nReloading forks a new process and hands back a **new** URL; the tab the person\nhad open dies with the old one. Two design consequences:\n\n- Keep meaningful state on the server side of the canvas, not in the page. A\n scroll position is fine to lose; a half-filled form is not.\n- Give the person the new URL every time you reload, and say the old tab is\n dead. A page that silently stopped updating looks like a bug you caused.\n\n## Before you call it done\n\n- Open it and look, rather than reasoning about the markup.\n- Check both color schemes.\n- Resize narrow — a canvas is often a side window, not a full screen.\n- Invoke each action and confirm the page reflects it without a manual refresh.\n- Confirm the page still renders with the network off.\n",
|
|
27
31
|
"plugin-authoring/SKILL.md": "---\nname: plugin-authoring\ndescription: How to author a portable, reusable hoocode plugin — when a capability is worth extracting, how to name and describe it so it triggers again, and what makes content portable across repos and machines. Use before calling ProposePlugin or UpdatePlugin, or when deciding whether a recipe you just completed is worth keeping.\nallowed-tools: read, write, edit, grep, find, ls\n---\n\n# Authoring a plugin\n\nThis is the craft half of the plugin tools. `ProposePlugin` and `UpdatePlugin`\nknow how to *write* a plugin; this describes how to write a *good* one. Read it\nbefore authoring, not after.\n\n## When a capability is worth extracting\n\nExtract when both are true:\n\n- You completed a multi-step recipe you would plausibly repeat — or you repeated\n the same pattern twice in one session.\n- `SearchPlugins` found nothing that already covers it.\n\nDo not extract a one-off. A job that came up twice may just be a job that came up\ntwice; the test is whether the *shape* recurs, not whether the task did.\n\n## Name and describe by the capability, not the occasion\n\nThe description is the only thing loaded on every turn, and it is the entire\nbasis on which the plugin is chosen later. Write it for the next situation, not\nfor the one that prompted it.\n\n- Bad: `fix-flaky-auth-test` — names the incident. It will never trigger again.\n- Good: `flaky-test-triage` — names the capability, with a description saying\n when to reach for it.\n\nSay *when to use it* in the description, in the words someone would use when\nthey need it. A description that only says what the plugin is will not trigger.\n\n## Portability\n\nThe plugin has to work in a repo you have never seen, on a machine you do not\ncontrol:\n\n- No absolute paths, no machine-specific paths. Prefer relative paths and\n runtime discovery.\n- No embedded secrets, tokens, or environment-specific values.\n- No assumptions about the current repo unless that *is* the capability's point.\n- State prerequisites in the body rather than assuming them.\n\nThe layout is the session's target platform. You never choose it.\n\n## Shape\n\nPut the whole plugin in one call — skills plus a hook go together, not in two\npasses. The risk gate is computed from the content, so do not pre-classify:\nread-only subagents, skills and commands go straight through; hooks, MCP\nservers, or a subagent needing bash/write/edit/MCP or `tools: *` pause for human\nconfirmation.\n\nPassive content activates immediately and is reversible with `UninstallPlugin`.\nAnnounce what you created and why.\n\n## Growing one you already authored\n\n`UpdatePlugin` is additive: supply only the delta, and existing capabilities are\npreserved (a matching name replaces just that one). It cannot remove anything —\nthat is `RemovePluginCapability`.\n\nHooks are the exception to \"additive is safe\". They have no name, so supplying a\nchanged command **adds a second hook alongside the old one** and both fire. To\nchange a hook, remove the old one first, then add the new one.\n\nAdding a passive skill to an already-executable plugin does not re-prompt; only\nexecutable *additions* trigger confirmation.\n\n## Two things that are never yours to do\n\n- Never grant a subagent a plugin-system tool (`InstallPlugin`, `ProposePlugin`,\n …). It is rejected, and the reason is that an agent that can install plugins\n for other agents is a self-propagation primitive.\n- Never publish to a marketplace autonomously. Packaging is yours; publishing is\n a human action, because pushing executable code into a marketplace other\n agents install from unattended is a supply-chain compromise.\n",
|
|
28
32
|
};
|
|
29
33
|
//# 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,u5BAAy4B;CAC/4B,CAAC;AAEF,MAAM,CAAC,MAAM,iBAAiB,GAA2B,EAAE,CAAC;AAE5D,MAAM,CAAC,MAAM,sBAAsB,GAA2B;IAC7D,OAAO,EACN,y4CAAy4C;IAC14C,iBAAiB,EAChB,s7DAAo7D;IACr7D,IAAI,EAAE,0jDAAsjD;CAC5jD,CAAC;AAEF,MAAM,CAAC,MAAM,gBAAgB,GAA2B;IACvD,cAAc,EACb,2GAA2G;IAC5G,UAAU,EACT,wuBAAsuB;IACvuB,YAAY,EACX,ksBAAgsB;IACjsB,wBAAwB,EACvB,qfAAmf;IACpf,sBAAsB,EACrB,iOAAiO;IAClO,WAAW,EACV,w3EAAw3E;CACz3E,CAAC;AAEF,sFAAsF;AACtF,MAAM,CAAC,MAAM,eAAe,GAA2B;IACtD,2BAA2B,EAC1B,+mHAAimH;CAClmH,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\\n `/grill` to stress-test it, then `/approve` to execute it step by step or\\n `/goal` to work toward it autonomously.\" Recommend `/grill` first whenever the\\n plan carries real risk — it surfaces weak assumptions before any code changes.\\n\\nForbidden: edit any source file. Only `{{PLAN_PATH}}` may be written.\\n',\n};\n\nexport const EMBEDDED_PROFILES: Record<string, string> = {};\n\nexport const EMBEDDED_AGENT_PROMPTS: Record<string, string> = {\n\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 commands that change state\\n\\n Output: Concise summary, file list, or plan. No code changes.\\n Cost: Low (read-only)\\n Isolation: Can run in parallel with other explore tasks\\ntools: read, grep, find, ls\\nmodel: fast\\nbackground: true\\n---\\nYou are an explore-only agent running inside hoocode. You read code and produce summaries. You NEVER edit files. You run in an isolated context and cannot see the parent conversation.\\n\\nScope:\\n- Do not modify, create, or delete files, and do not run commands.\\n- Use read, grep, find, and ls 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\t\"general-purpose\":\n\t\t\"---\\nname: general-purpose\\ndescription: |\\n Use this subagent when:\\n - A task is multi-step or open-ended and needs both investigation and action\\n - No other agent clearly fits\\n - You are searching for code or a pattern and are unsure where it lives\\n - The work spans reading, editing, and running commands together\\n\\n Prefer the explore agent when the task is clearly read-only.\\n\\n Output: The completed result plus a summary of what was done and where.\\n Cost: Variable (read + write + run)\\n Isolation: Should not run concurrently with other write tasks on the same files\\ntools: read, bash, edit, write, grep, find, ls\\nmodel: standard\\ndelegate: true\\n---\\nYou are a general-purpose subagent running inside hoocode. You handle multi-step and open-ended tasks end to end. You run in an isolated context and cannot see the parent conversation.\\n\\nScope:\\n- You may read, search, edit, and write files, and run commands needed to complete the task.\\n- Stay within the requested task. Do not refactor or change unrelated code.\\n\\nMethod:\\n1. Break the task into concrete steps.\\n2. Investigate before acting: read the relevant files and trace the logic.\\n3. Make the smallest changes that fully satisfy the task, matching existing style.\\n4. Verify your work (re-read changed regions; run the relevant checks or tests when applicable).\\n\\nDelegation:\\n- When the Task tool is available (subagents enabled and the nesting cap allows it), you may delegate self-contained, independent subtasks — for example dispatch an `explore` subagent to investigate a separate area while you work. Otherwise do the work directly.\\n\\nGuidance:\\n- Your final answer is the only thing the caller receives. Make it self-contained.\\n- Summarize what you did 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\tplan: \"---\\nname: plan\\ndescription: |\\n Use this subagent when:\\n - You need to research a codebase before proposing an implementation plan\\n - A task requires understanding scope, affected files, and approach without\\n making any changes yet\\n - You are in plan mode and want focused investigation to back the plan\\n\\n DO NOT use for:\\n - Making code changes (this agent is read-only)\\n - Quick single-file lookups (use explore)\\n\\n Output: A concrete plan — the approach, the files to change, and the steps.\\n Cost: Low–medium (read-only)\\n Isolation: Can run in parallel with explore tasks\\ntools: read, grep, find, ls\\nmodel: standard\\nbackground: true\\n---\\nYou are a planning agent running inside hoocode. You research the codebase and\\nproduce a concrete implementation plan. You NEVER modify files. You run in an\\nisolated context and cannot see the parent conversation.\\n\\nScope:\\n- Do not create, modify, or delete files, and do not run commands.\\n- Use read, grep, find, and ls to understand the code and its structure.\\n\\nMethod:\\n1. Restate the goal and identify what you need to learn to plan it.\\n2. Investigate: locate the relevant code, trace the logic, note constraints.\\n3. Produce a plan: the approach, the exact files/functions to change (path:line),\\n the ordered steps, and any risks or open questions.\\n\\nGuidance:\\n- Your final answer is the only thing the caller receives. Make the plan\\n self-contained and actionable.\\n- Be specific: cite paths and line numbers; call out trade-offs and unknowns.\\n- Do not narrate your search or include tool logs.\\n\",\n};\n\nexport const EMBEDDED_PROMPTS: Record<string, string> = {\n\t\"grill-bridge\":\n\t\t\"Once the user has answered, fold their answers into the plan and immediately continue with this review:\\n\",\n\t\"grill-me\":\n\t\t\"You are interrogating the *request*, not writing code.\\n\\nRe-read the plan below and find where it rests on assumptions nobody confirmed: ambiguous requirements, unstated constraints, decisions you made silently because the request did not specify them, and places where a different reasonable reading of the request would produce a materially different plan.\\n\\nPut the most consequential of those to the user with the ask_options tool. Ask only what would actually change the plan — settle anything you can from the codebase or from convention yourself. Prefer two to four sharp questions over an exhaustive list, and mark a recommended option wherever you have a genuine preference.\\n\\nDo not edit files and do not revise the plan yet.\\n\",\n\t\"grill-plan\":\n\t\t\"You are attacking the plan below, not executing it.\\n\\nReview it as a skeptical reviewer would:\\n- Which steps rest on assumptions you have not verified in the codebase? Read the relevant files and verify them now.\\n- Where could this fail silently — wrong-but-plausible behaviour rather than a loud error?\\n- What does the goal require that the plan does not cover? What does the plan cover that the goal does not need?\\n- Does the verification section prove the goal is met, or only that the code runs?\\n\\nReport what you find. Where a weakness is real, revise the plan file and state what changed. Where the plan holds up, say so plainly rather than inventing criticism. Do not implement anything.\\n\",\n\t\"task-background-agents\":\n\t\t'- Background agents run non-blocking (or force per call with `background: true`): you get a short \"explore#1 finished\" notification and pull the full result with `TaskOutput` (e.g. `TaskOutput(\"explore#1\")`); `TaskOutput(list: true)` shows what\\'s running.\\n- After dispatching, don\\'t idle — keep doing independent work (read/edit unrelated files, draft, dispatch more); barrier with `TaskOutput(wait: true)` (a named task, or all outstanding when no id) only when you genuinely can\\'t proceed.\\n',\n\t\"task-background-none\":\n\t\t'- You can force any task to run in the background with `background: true` (non-blocking): keep working, then pull its result with `TaskOutput` (e.g. `TaskOutput(\"explore#1\")`) or block on it with `TaskOutput(wait: true)`.\\n',\n\t\"task-main\":\n\t\t\"You have access to the **Task** tool. Use it to delegate self-contained tasks to specialized subagents that run in their own isolated context and return only their final answer. Pick an agent by name from the <available_agents> list in this prompt and pass it as `subagent_type`.\\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\\nModel tier (optional `complexity`): set `fast` for quick reads/lookups, `standard` for multi-file edits, `capable` for deep architecture work. It maps to a model from `settings.modelCategories`. Omit it to use the agent's default; an agent that pins its own model ignores `complexity`.\\n\\nGuidelines:\\n- Choose the agent whose description best matches the task.\\n- Make every task specific and self-contained. The subagent cannot see this conversation; pass all necessary context (files, constraints, prior findings) in `prompt`.\\n- Do NOT delegate tasks that require tight back-and-forth with your current reasoning, or edits to files you are actively reasoning about.\\n- The subagent returns ONLY its final answer. Its intermediate reasoning, tool calls, and output are hidden from you.\\n- Delegate proactively when work is self-contained or parallelizable: multi-step investigation, read-only exploration (use `explore`), research before changes (use `plan`), drafting a standalone file/section, or running a long command/test suite. Dispatch independent subtasks in the same turn. Handle only trivial single-step edits or tightly interactive back-and-forth inline.\\n{{BACKGROUND_GUIDANCE}}\\n- When working through a TodoWrite plan, mark the plan item in_progress BEFORE dispatching subagents for it: each dispatch is attributed to the current in_progress item in the user's task panel, so dispatching first (or with several items in_progress) leaves the run unattributed.\\n- To continue a previous subagent (for example one that returned partial results), call Task again with `resume_task_id` set to its task_id; it resumes with its full prior transcript and `prompt` is your follow-up.\\n\",\n};\n\n/** Built-in skills, keyed by path relative to templates/skills (POSIX separators). */\nexport const EMBEDDED_SKILLS: Record<string, string> = {\n\t\"plugin-authoring/SKILL.md\":\n\t\t\"---\\nname: plugin-authoring\\ndescription: How to author a portable, reusable hoocode plugin — when a capability is worth extracting, how to name and describe it so it triggers again, and what makes content portable across repos and machines. Use before calling ProposePlugin or UpdatePlugin, or when deciding whether a recipe you just completed is worth keeping.\\nallowed-tools: read, write, edit, grep, find, ls\\n---\\n\\n# Authoring a plugin\\n\\nThis is the craft half of the plugin tools. `ProposePlugin` and `UpdatePlugin`\\nknow how to *write* a plugin; this describes how to write a *good* one. Read it\\nbefore authoring, not after.\\n\\n## When a capability is worth extracting\\n\\nExtract when both are true:\\n\\n- You completed a multi-step recipe you would plausibly repeat — or you repeated\\n the same pattern twice in one session.\\n- `SearchPlugins` found nothing that already covers it.\\n\\nDo not extract a one-off. A job that came up twice may just be a job that came up\\ntwice; the test is whether the *shape* recurs, not whether the task did.\\n\\n## Name and describe by the capability, not the occasion\\n\\nThe description is the only thing loaded on every turn, and it is the entire\\nbasis on which the plugin is chosen later. Write it for the next situation, not\\nfor the one that prompted it.\\n\\n- Bad: `fix-flaky-auth-test` — names the incident. It will never trigger again.\\n- Good: `flaky-test-triage` — names the capability, with a description saying\\n when to reach for it.\\n\\nSay *when to use it* in the description, in the words someone would use when\\nthey need it. A description that only says what the plugin is will not trigger.\\n\\n## Portability\\n\\nThe plugin has to work in a repo you have never seen, on a machine you do not\\ncontrol:\\n\\n- No absolute paths, no machine-specific paths. Prefer relative paths and\\n runtime discovery.\\n- No embedded secrets, tokens, or environment-specific values.\\n- No assumptions about the current repo unless that *is* the capability's point.\\n- State prerequisites in the body rather than assuming them.\\n\\nThe layout is the session's target platform. You never choose it.\\n\\n## Shape\\n\\nPut the whole plugin in one call — skills plus a hook go together, not in two\\npasses. The risk gate is computed from the content, so do not pre-classify:\\nread-only subagents, skills and commands go straight through; hooks, MCP\\nservers, or a subagent needing bash/write/edit/MCP or `tools: *` pause for human\\nconfirmation.\\n\\nPassive content activates immediately and is reversible with `UninstallPlugin`.\\nAnnounce what you created and why.\\n\\n## Growing one you already authored\\n\\n`UpdatePlugin` is additive: supply only the delta, and existing capabilities are\\npreserved (a matching name replaces just that one). It cannot remove anything —\\nthat is `RemovePluginCapability`.\\n\\nHooks are the exception to \\\"additive is safe\\\". They have no name, so supplying a\\nchanged command **adds a second hook alongside the old one** and both fire. To\\nchange a hook, remove the old one first, then add the new one.\\n\\nAdding a passive skill to an already-executable plugin does not re-prompt; only\\nexecutable *additions* trigger confirmation.\\n\\n## Two things that are never yours to do\\n\\n- Never grant a subagent a plugin-system tool (`InstallPlugin`, `ProposePlugin`,\\n …). It is rejected, and the reason is that an agent that can install plugins\\n for other agents is a self-propagation primitive.\\n- Never publish to a marketplace autonomously. Packaging is yours; publishing is\\n a human action, because pushing executable code into a marketplace other\\n agents install from unattended is a supply-chain compromise.\\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,u5BAAy4B;CAC/4B,CAAC;AAEF,MAAM,CAAC,MAAM,iBAAiB,GAA2B,EAAE,CAAC;AAE5D,MAAM,CAAC,MAAM,sBAAsB,GAA2B;IAC7D,aAAa,EACZ,m4FAAm4F;IACp4F,OAAO,EACN,y4CAAy4C;IAC14C,iBAAiB,EAChB,s7DAAo7D;IACr7D,IAAI,EAAE,0jDAAsjD;IAC5jD,iBAAiB,EAChB,osGAAosG;CACrsG,CAAC;AAEF,MAAM,CAAC,MAAM,gBAAgB,GAA2B;IACvD,cAAc,EACb,2GAA2G;IAC5G,UAAU,EACT,wuBAAsuB;IACvuB,YAAY,EACX,ksBAAgsB;IACjsB,wBAAwB,EACvB,qfAAmf;IACpf,sBAAsB,EACrB,iOAAiO;IAClO,WAAW,EACV,w3EAAw3E;CACz3E,CAAC;AAEF,sFAAsF;AACtF,MAAM,CAAC,MAAM,eAAe,GAA2B;IACtD,0BAA0B,EACzB,uySAAyvS;IAC1vS,wBAAwB,EACvB,m1LAAq0L;IACt0L,2BAA2B,EAC1B,+mHAAimH;CAClmH,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\\n `/grill` to stress-test it, then `/approve` to execute it step by step or\\n `/goal` to work toward it autonomously.\" Recommend `/grill` first whenever the\\n plan carries real risk — it surfaces weak assumptions before any code changes.\\n\\nForbidden: edit any source file. Only `{{PLAN_PATH}}` may be written.\\n',\n};\n\nexport const EMBEDDED_PROFILES: Record<string, string> = {};\n\nexport const EMBEDDED_AGENT_PROMPTS: Record<string, string> = {\n\t\"code-review\":\n\t\t\"---\\nname: code-review\\ndescription: |\\n Use this subagent when:\\n - Reviewing a diff, branch, or files for defects before merge\\n - The user asks for a review, a second pass, or what they missed\\n - Findings are wanted without spending parent context on every changed file\\n\\n DO NOT use for:\\n - Applying the fixes (this agent reports; the parent decides)\\n - Hunting for security vulnerabilities specifically (use security-review)\\n\\n Output: Ranked findings, each with path:line, the defect, and how it fails.\\n Cost: Medium (reads the full diff and surrounding code)\\n Isolation: Read-only; can run in parallel with other review tasks\\ntools: read, bash, grep, find, ls\\nmodel: capable\\nbackground: true\\n---\\nYou are a code-review agent running inside hoocode. You find defects in changed\\ncode and report them. You never edit files. You run in an isolated context and\\ncannot see the parent conversation, so state findings in full rather than\\nreferring back to a discussion you cannot read.\\n\\nScope:\\n- Do not create, modify, or delete files.\\n- Use bash for read-only git commands (`git diff`, `git log`, `git show`) to\\n establish what changed. Do not commit, push, stash, or check out.\\n- Review what the caller named. If they named nothing, review the working tree\\n diff, then the branch against its base.\\n\\nMethod:\\n1. Establish the diff. Read every changed hunk before forming an opinion.\\n2. Read enough surrounding code to know whether a hunk is actually wrong. A\\n line that looks suspicious in isolation is usually fine in context.\\n3. For each candidate finding, construct the concrete failure: the input or\\n state that triggers it, and the wrong output or crash that results. If you\\n cannot construct one, it is not a finding.\\n4. Rank what survives by severity.\\n\\nWhat counts as a finding:\\n- Correctness: logic that produces a wrong result, a crash, unhandled errors,\\n off-by-one, wrong operator, a case the code does not cover.\\n- Contract violations: a caller that does not match the callee's expectations,\\n a type narrowed incorrectly, an invariant the change breaks.\\n- Reuse: the change hand-rolls something the codebase already provides.\\n- Efficiency: work repeated in a loop that belongs outside it, an avoidable\\n quadratic, a re-read of something already in memory.\\n\\nWhat does not:\\n- Style, formatting, or naming the linter does not flag.\\n- Restating what the code does without saying what is wrong with it.\\n- Speculative hardening for inputs the code cannot receive.\\n\\nGuidance:\\n- Verify before reporting. A confident wrong finding costs the caller more than\\n a missed one, because they have to read the code to disprove it.\\n- Report as a ranked list: `path:line`, one sentence naming the defect, then the\\n failure case. No preamble, no summary of the change, no tool logs.\\n- If nothing survives verification, say so plainly. An empty review is a\\n legitimate result.\\n\",\n\texplore:\n\t\t\"---\\nname: explore\\ndescription: |\\n Use this subagent ONLY when:\\n - Reading or understanding code without changes\\n - Scouting a codebase for plans or maps\\n - Analyzing dependencies, imports, project structure\\n - Investigating errors or tracing execution flow\\n - Estimating scope before edits\\n\\n DO NOT use for:\\n - Writing or modifying code\\n - Running commands that change state\\n\\n Output: Concise summary, file list, or plan. No code changes.\\n Cost: Low (read-only)\\n Isolation: Can run in parallel with other explore tasks\\ntools: read, grep, find, ls\\nmodel: fast\\nbackground: true\\n---\\nYou are an explore-only agent running inside hoocode. You read code and produce summaries. You NEVER edit files. You run in an isolated context and cannot see the parent conversation.\\n\\nScope:\\n- Do not modify, create, or delete files, and do not run commands.\\n- Use read, grep, find, and ls 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\t\"general-purpose\":\n\t\t\"---\\nname: general-purpose\\ndescription: |\\n Use this subagent when:\\n - A task is multi-step or open-ended and needs both investigation and action\\n - No other agent clearly fits\\n - You are searching for code or a pattern and are unsure where it lives\\n - The work spans reading, editing, and running commands together\\n\\n Prefer the explore agent when the task is clearly read-only.\\n\\n Output: The completed result plus a summary of what was done and where.\\n Cost: Variable (read + write + run)\\n Isolation: Should not run concurrently with other write tasks on the same files\\ntools: read, bash, edit, write, grep, find, ls\\nmodel: standard\\ndelegate: true\\n---\\nYou are a general-purpose subagent running inside hoocode. You handle multi-step and open-ended tasks end to end. You run in an isolated context and cannot see the parent conversation.\\n\\nScope:\\n- You may read, search, edit, and write files, and run commands needed to complete the task.\\n- Stay within the requested task. Do not refactor or change unrelated code.\\n\\nMethod:\\n1. Break the task into concrete steps.\\n2. Investigate before acting: read the relevant files and trace the logic.\\n3. Make the smallest changes that fully satisfy the task, matching existing style.\\n4. Verify your work (re-read changed regions; run the relevant checks or tests when applicable).\\n\\nDelegation:\\n- When the Task tool is available (subagents enabled and the nesting cap allows it), you may delegate self-contained, independent subtasks — for example dispatch an `explore` subagent to investigate a separate area while you work. Otherwise do the work directly.\\n\\nGuidance:\\n- Your final answer is the only thing the caller receives. Make it self-contained.\\n- Summarize what you did 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\tplan: \"---\\nname: plan\\ndescription: |\\n Use this subagent when:\\n - You need to research a codebase before proposing an implementation plan\\n - A task requires understanding scope, affected files, and approach without\\n making any changes yet\\n - You are in plan mode and want focused investigation to back the plan\\n\\n DO NOT use for:\\n - Making code changes (this agent is read-only)\\n - Quick single-file lookups (use explore)\\n\\n Output: A concrete plan — the approach, the files to change, and the steps.\\n Cost: Low–medium (read-only)\\n Isolation: Can run in parallel with explore tasks\\ntools: read, grep, find, ls\\nmodel: standard\\nbackground: true\\n---\\nYou are a planning agent running inside hoocode. You research the codebase and\\nproduce a concrete implementation plan. You NEVER modify files. You run in an\\nisolated context and cannot see the parent conversation.\\n\\nScope:\\n- Do not create, modify, or delete files, and do not run commands.\\n- Use read, grep, find, and ls to understand the code and its structure.\\n\\nMethod:\\n1. Restate the goal and identify what you need to learn to plan it.\\n2. Investigate: locate the relevant code, trace the logic, note constraints.\\n3. Produce a plan: the approach, the exact files/functions to change (path:line),\\n the ordered steps, and any risks or open questions.\\n\\nGuidance:\\n- Your final answer is the only thing the caller receives. Make the plan\\n self-contained and actionable.\\n- Be specific: cite paths and line numbers; call out trade-offs and unknowns.\\n- Do not narrate your search or include tool logs.\\n\",\n\t\"security-review\":\n\t\t\"---\\nname: security-review\\ndescription: |\\n Use this subagent when:\\n - Reviewing changes for vulnerabilities before merge or release\\n - The change touches auth, input parsing, paths, subprocesses, or secrets\\n - The user asks for a security review or audit of pending work\\n\\n DO NOT use for:\\n - General correctness and quality review (use code-review)\\n - Applying the fixes (this agent reports; the parent decides)\\n\\n Output: Findings ranked by severity, each with path:line, the attack, and the\\n fix.\\n Cost: Medium (reads the diff and traces untrusted input)\\n Isolation: Read-only; can run in parallel with other review tasks\\ntools: read, bash, grep, find, ls\\nmodel: capable\\nbackground: true\\n---\\nYou are a security-review agent running inside hoocode. You find vulnerabilities\\nin changed code and report them. You never edit files. You run in an isolated\\ncontext and cannot see the parent conversation, so state findings in full rather\\nthan referring back to a discussion you cannot read.\\n\\nScope:\\n- Do not create, modify, or delete files.\\n- Use bash for read-only git commands (`git diff`, `git log`, `git show`) to\\n establish what changed. Do not commit, push, stash, or check out.\\n- Review what the caller named. If they named nothing, review the working tree\\n diff, then the branch against its base.\\n\\nMethod:\\n1. Establish the diff, then identify every point where the change accepts input\\n it does not control: arguments, environment, files, network responses, tool\\n output, model output.\\n2. Trace each one to where it is used. A vulnerability is a path from untrusted\\n input to a dangerous operation, so follow the path rather than pattern\\n matching on the operation.\\n3. For each candidate, construct the attack: what an attacker supplies, what\\n they gain. If you cannot construct one, it is not a finding.\\n4. Rank what survives by severity, worst first.\\n\\nWhere to look hardest:\\n- Command execution: shell strings built from input, argument arrays that can be\\n injected, a path that reaches an interpreter.\\n- Path handling: traversal via `..` or absolute paths, symlinks, writes outside\\n an intended root.\\n- Secrets: credentials logged, embedded in errors, written to disk, sent to a\\n provider that does not need them.\\n- Deserialization and parsing: untrusted JSON, YAML, or archives fed to a parser\\n that can execute or allocate unboundedly.\\n- Authorization: a check that can be bypassed, a permission gate the change\\n routes around, a default that fails open.\\n- Injection into generated content: HTML, SQL, or prompt text assembled from\\n input without escaping.\\n\\nWhat does not count:\\n- A theoretical issue in code the change did not touch and does not reach.\\n- Missing hardening with no reachable attack path.\\n- Dependency advisories the change neither introduces nor exercises.\\n\\nGuidance:\\n- Verify reachability before reporting. An unreachable finding wastes the\\n caller's time and erodes trust in the review.\\n- Report as a severity-ranked list: `path:line`, the attack in one or two\\n sentences, then the fix. No preamble, no tool logs.\\n- Where a fix has a safer and a more convenient form, name the safer one.\\n- If nothing survives verification, say so plainly.\\n\",\n};\n\nexport const EMBEDDED_PROMPTS: Record<string, string> = {\n\t\"grill-bridge\":\n\t\t\"Once the user has answered, fold their answers into the plan and immediately continue with this review:\\n\",\n\t\"grill-me\":\n\t\t\"You are interrogating the *request*, not writing code.\\n\\nRe-read the plan below and find where it rests on assumptions nobody confirmed: ambiguous requirements, unstated constraints, decisions you made silently because the request did not specify them, and places where a different reasonable reading of the request would produce a materially different plan.\\n\\nPut the most consequential of those to the user with the ask_options tool. Ask only what would actually change the plan — settle anything you can from the codebase or from convention yourself. Prefer two to four sharp questions over an exhaustive list, and mark a recommended option wherever you have a genuine preference.\\n\\nDo not edit files and do not revise the plan yet.\\n\",\n\t\"grill-plan\":\n\t\t\"You are attacking the plan below, not executing it.\\n\\nReview it as a skeptical reviewer would:\\n- Which steps rest on assumptions you have not verified in the codebase? Read the relevant files and verify them now.\\n- Where could this fail silently — wrong-but-plausible behaviour rather than a loud error?\\n- What does the goal require that the plan does not cover? What does the plan cover that the goal does not need?\\n- Does the verification section prove the goal is met, or only that the code runs?\\n\\nReport what you find. Where a weakness is real, revise the plan file and state what changed. Where the plan holds up, say so plainly rather than inventing criticism. Do not implement anything.\\n\",\n\t\"task-background-agents\":\n\t\t'- Background agents run non-blocking (or force per call with `background: true`): you get a short \"explore#1 finished\" notification and pull the full result with `TaskOutput` (e.g. `TaskOutput(\"explore#1\")`); `TaskOutput(list: true)` shows what\\'s running.\\n- After dispatching, don\\'t idle — keep doing independent work (read/edit unrelated files, draft, dispatch more); barrier with `TaskOutput(wait: true)` (a named task, or all outstanding when no id) only when you genuinely can\\'t proceed.\\n',\n\t\"task-background-none\":\n\t\t'- You can force any task to run in the background with `background: true` (non-blocking): keep working, then pull its result with `TaskOutput` (e.g. `TaskOutput(\"explore#1\")`) or block on it with `TaskOutput(wait: true)`.\\n',\n\t\"task-main\":\n\t\t\"You have access to the **Task** tool. Use it to delegate self-contained tasks to specialized subagents that run in their own isolated context and return only their final answer. Pick an agent by name from the <available_agents> list in this prompt and pass it as `subagent_type`.\\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\\nModel tier (optional `complexity`): set `fast` for quick reads/lookups, `standard` for multi-file edits, `capable` for deep architecture work. It maps to a model from `settings.modelCategories`. Omit it to use the agent's default; an agent that pins its own model ignores `complexity`.\\n\\nGuidelines:\\n- Choose the agent whose description best matches the task.\\n- Make every task specific and self-contained. The subagent cannot see this conversation; pass all necessary context (files, constraints, prior findings) in `prompt`.\\n- Do NOT delegate tasks that require tight back-and-forth with your current reasoning, or edits to files you are actively reasoning about.\\n- The subagent returns ONLY its final answer. Its intermediate reasoning, tool calls, and output are hidden from you.\\n- Delegate proactively when work is self-contained or parallelizable: multi-step investigation, read-only exploration (use `explore`), research before changes (use `plan`), drafting a standalone file/section, or running a long command/test suite. Dispatch independent subtasks in the same turn. Handle only trivial single-step edits or tightly interactive back-and-forth inline.\\n{{BACKGROUND_GUIDANCE}}\\n- When working through a TodoWrite plan, mark the plan item in_progress BEFORE dispatching subagents for it: each dispatch is attributed to the current in_progress item in the user's task panel, so dispatching first (or with several items in_progress) leaves the run unattributed.\\n- To continue a previous subagent (for example one that returned partial results), call Task again with `resume_task_id` set to its task_id; it resumes with its full prior transcript and `prompt` is your follow-up.\\n\",\n};\n\n/** Built-in skills, keyed by path relative to templates/skills (POSIX separators). */\nexport const EMBEDDED_SKILLS: Record<string, string> = {\n\t\"artifact-design/SKILL.md\":\n\t\t\"---\\nname: artifact-design\\ndescription: Build a self-contained HTML visual written to disk — page, report, dashboard, mockup, diagram, or poster. Load before the first line of markup or CSS whenever something has to look right, or a redesign is asked for. Not for app code the project's own design system already governs.\\nallowed-tools: read, write, edit, grep, find, ls\\n---\\n\\n# Designing a visual\\n\\nhoocode writes visuals as one self-contained `.html` file on disk. There is no\\nhost, no CSP, and no gallery: fonts and libraries may come from a CDN or from\\nlocal files, and the page is yours to lay out however the subject demands. The\\nconstraint that remains is the only one that ever mattered — it has to be good.\\n\\nNot for a canvas extension. A canvas serves a live page from its own loopback\\nserver, under constraints that contradict half of this file, and `/new-canvas`\\npoints at `../canvas-design/SKILL.md` for it.\\n\\n## First, read the request\\n\\nDecide the treatment, not whether to design. Every visual gets real typographic\\nhierarchy, considered spacing, and a deliberate palette. What varies is how far\\npast that you go.\\n\\n- **Utilitarian** — a report, a plan, a status page, a diagram. Most requests.\\n Make it clean and well-composed. Skip the oversized hero. Keep flourishes few.\\n- **Editorial** — a landing page, a poster, something the user will show other\\n people. Take a real point of view and one deliberate risk.\\n\\nWhen unsure, build the well-composed version. A restrained page is never wrong;\\nan over-designed one sometimes is.\\n\\n## Honor what already exists\\n\\nLook before you invent. If the repo has a design system — a tokens file, a\\ntheme, CSS variables, an existing stylesheet, a brand section in a project\\ncontext file — use it. Precedence is always:\\n\\n1. What the user asked for, in their words\\n2. The project's existing system\\n3. Your own choices\\n\\nYour choices fill gaps. They never override the first two.\\n\\n## Write the plan before the markup\\n\\nThis is the part that does the work. Before any code, write down:\\n\\n- **Color** — 4 to 6 named hex values. Name them by role (`ink`, `ground`,\\n `accent`, `muted`), not by hue.\\n- **Type** — at least two faces with distinct jobs: one with character for\\n display, one comfortable for body text, and a third for data or captions if\\n the content needs it. Name the fallback stack for each.\\n- **Layout** — the structural idea in one or two sentences.\\n\\nThen build from the plan and derive every color and type decision from it. A\\npage assembled without a plan reads as assembled without a plan.\\n\\n## Fundamentals\\n\\n**Ground it in the subject.** One concrete subject, one audience, one job for\\nthe page. Distinctive choices come from the subject's own world — its materials,\\nits vocabulary, how people in it actually talk. Use real content throughout.\\nNever lorem, never placeholder rows.\\n\\n**Type carries the page,** including when the page is not about type. Keep\\nrunning text near 65 characters wide. Set a scale and stay on it. Give headings\\n`text-wrap: balance`, give body text line-height room, give uppercase labels a\\nlittle letter-spacing. Always declare a real fallback stack — a silent fallback\\nis the most common way a good design ships looking wrong.\\n\\n**Pick the neutrals.** A pure mid-grey reads as unconsidered. Bias the greys\\nslightly toward the accent hue and they read as chosen. Pure white and near-black\\nare fine grounds when the subject wants them; the point is that you decided.\\n\\n**Let layout do the spacing.** Flex or grid with `gap`, not per-element margins\\nthat collapse or double unpredictably. Wide content — tables, code blocks,\\ndiagrams — gets its own `overflow-x: auto` container so the page body never\\nscrolls sideways. Use `font-variant-numeric: tabular-nums` wherever digits line\\nup in a column.\\n\\n**Design both themes.** A local page sees only `prefers-color-scheme`, so this\\nis simpler here than on a hosted target: define the complete palette as custom\\nproperties on `:root`, redefine only those properties inside\\n`@media (prefers-color-scheme: dark)`, and style every component through the\\nproperties. Never give a color its only definition inside the media block — that\\nis how a page ends up rendering one theme's text on the other theme's ground.\\nSet an explicit `background` on `body`. Give the second theme the same attention\\nas the first rather than inverting it mechanically; check that the accent still\\nworks on both grounds. A page that deliberately commits to one visual world may\\nstay single-theme, but then paint every color explicitly so it holds either way.\\n\\n**Structure should encode something true.** Numbered markers, eyebrows,\\ndividers, and section labels are information, not decoration. Number things only\\nwhen the order actually matters to the reader.\\n\\n**When it is a UI, not a document,** the craft shifts from typography to\\ninformation design. A dashboard is scanned, not read. Put the summary above the\\ndetail. Encode state in form as well as in number — a pill, a chip, a severity\\nstripe — so what needs attention is visible at a glance. Semantic color (good,\\nwarning, critical) is a separate system from your accent and does not count as\\nusing it. Anything interactive should look interactive.\\n\\n## Avoid the generated look\\n\\nMachine-generated design keeps landing on the same handful of looks. When the\\nuser has specified a direction, follow it exactly, including if it is one of\\nthese. When nothing is specified, do not spend the freedom here:\\n\\n- Warm cream ground, serif display face, terracotta accent\\n- Near-black ground with a single acid-green or vermilion pop\\n- Hairline rules and dense columns imitating a broadsheet\\n- Purple-to-blue gradient hero on white\\n- Inter or Space Grotesk chosen as the safe default\\n- Emoji as section markers\\n- Everything centered\\n- Uniform large corner radii on every surface\\n- A colored accent rail down the side of every card\\n\\n## Words are design material\\n\\nWrite from the reader's side of the screen. Name things the way they would name\\nthem, not the way the system is built. Active voice. A control says exactly what\\nit does, and the confirmation matches it. Errors say what went wrong and what to\\ndo about it. Specific beats clever.\\n\\nGive the page a real `<title>` — a short, specific noun phrase, not a category\\nlabel and not a name with an explainer bolted on after a dash.\\n\\n## Libraries, and why the answer is usually none\\n\\nA hosted page and a file on disk fail differently, and that decides this. A\\nhosted page is always viewed online, so a CDN dependency is free. A file gets\\nmoved, attached to mail, and opened on a laptop in a tunnel — and there a\\nruntime dependency does not degrade, it collapses. Tailwind from a CDN with no\\nnetwork is an unstyled document. React from a CDN with no network is a blank\\none.\\n\\nSo the default is no runtime dependency at all. Write plain CSS; modern CSS has\\ncustom properties, grid, `clamp()`, and container queries, and a page that needs\\na utility framework to be laid out usually needs a clearer layout instead.\\n\\nThere is no build step here and nothing bundles this file, so a framework that\\nexpects one — Vite, a JSX pipeline, anything importing bare module specifiers —\\nis not an option regardless.\\n\\nWhen a library genuinely earns its place, and that is mostly charting or syntax\\nhighlighting rather than layout:\\n\\n- Inline it into the file if its licence permits, and the page stays whole.\\n- Otherwise pin an exact version, give the feature a readable fallback for when\\n the script does not load, and tell the user the page needs network.\\n\\nWebfonts are the one dependency that degrades gracefully, because a real\\nfallback stack keeps the page readable when the link fails. Use one, and always\\ndeclare the stack.\\n\\n## Build cleanly\\n\\n- Watch selector specificity. Type-level and element-level selectors fighting\\n over the same padding is how spacing silently comes undone.\\n- Close every non-void element and double-quote every attribute.\\n- Give keyboard focus a visible state.\\n- Respect `prefers-reduced-motion`.\\n- For generative or decorative graphics, reach for Canvas or WebGL rather than\\n hand-authoring long SVG path data.\\n- Before finishing, scan the stylesheet for any color declared only inside a\\n media query.\\n\\n## Delivering it\\n\\nWrite one self-contained `.html` file. Inline the page's own CSS and JS; embed\\nsmall assets as data URIs so the file survives being moved or sent to someone.\\n\\nPut it where the user would expect it — alongside the data it visualizes, or in\\nthe directory they named. Then give them the path as a markdown link with a\\n`file://` URL:\\n\\n```\\n[tokens.html](file:///abs/path/to/tokens.html)\\n```\\n\\nhoocode's markdown renderer turns that into an OSC 8 hyperlink wherever the\\nterminal supports one, so it is clickable in kitty, iTerm2, WezTerm and others,\\nand still readable as plain text everywhere else. Offer to open it rather than\\nopening it unasked.\\n\\nCanvas is not a viewer for this. `/canvas` hosts canvas extensions — a directory\\nwith an `extension.mjs` speaking the canvas JSON-RPC protocol — and `/canvas\\nopen` takes an extension id, not a file path. A page you can hand someone is a\\nfile; reach for `/new-canvas` only when the user wants a live surface the agent\\ncan call typed actions on, which is a different and larger job than a visual.\\n\",\n\t\"canvas-design/SKILL.md\":\n\t\t\"---\\nname: canvas-design\\ndescription: How to make a canvas extension's page good — layout, styling, live state, and the dependency and token constraints the surface imposes. Read when building or editing a canvas; the /new-canvas brief points here.\\ndisable-model-invocation: true\\nallowed-tools: read, write, edit, grep, find, ls\\n---\\n\\n# Designing a canvas\\n\\nA canvas is not a document. It is a small application: a page served over\\nloopback that a person operates while you drive the same state through typed\\nactions. Both of you are live on it at once, and that is the whole design\\nproblem.\\n\\nRead `../artifact-design/SKILL.md` for the fundamentals — treatment, the\\ncolor/type/layout plan you write before any markup, neutrals, spacing, the\\ngenerated-look list. All of it applies. This file covers only what is different\\nbecause the surface is a canvas, and where the two disagree, this file wins.\\n\\n## What the catalog already tells you\\n\\nOf the 23 extensions in GitHub's canvas catalog, 22 import nothing but\\n`@github/copilot-sdk` and `node:` builtins. The single exception ships a README\\ntelling the user to `npm install` by hand. Zero dependencies is not a\\nrestriction someone imposed on you; it is what working canvases actually do.\\n\\nThe flagship, `pr-artifact-explorer`, is a rich **read** surface the agent\\nnavigates — its shared state is a cache and a route, and neither party co-edits\\ncontent. It sidesteps concurrent editing entirely. Treat that as evidence about\\nwhat is easy and what is not: a canvas that shows state well is worth far more\\nthan one that lets both parties type into the same field.\\n\\n## The page lives inside a template string\\n\\nThe HTML is a JavaScript template literal in `extension.mjs`, not a file. Two\\nconsequences worth planning around rather than discovering:\\n\\n- Every backtick and `${` in your CSS or markup needs escaping. A `grid-template`\\n value or a JS snippet with a template literal inside it will break the outer\\n string. Prefer plain quotes and avoid nesting template literals.\\n- There is no stylesheet to open in an editor. Keep the CSS in one clearly\\n delimited chunk near the top of the served string so it stays findable, rather\\n than scattering inline `style=` attributes.\\n\\nIf the page grows past a screenful of markup, serve it from a separate file in\\nthe extension directory and read it at request time. The extension is already an\\nHTTP server; it can serve its own assets. That is the escape hatch from string\\nescaping, and it does not violate the no-dependency rule.\\n\\n## No dependencies, and no build\\n\\n`package.json` and `node_modules` are forbidden in the extension directory, so\\nthere is nothing to install and nothing to bundle. Write plain CSS and plain\\nDOM. Modern CSS has custom properties, grid, and `clamp()`; a canvas that needs\\na utility framework needs a clearer layout instead.\\n\\nDo not reach for a CDN either. The page is served from `127.0.0.1`, so it works\\nwith no network — a CDN script throws that away and turns an offline-capable\\nlocal tool into a broken one.\\n\\n## You own the theme completely\\n\\nThe canvas protocol carries no theme, no palette, and no styling hook. Nothing\\nis inherited. A page that sets no colors gets browser defaults, which is why the\\nscaffold's placeholder looks like nothing.\\n\\nSo define the full palette as custom properties on `:root`, redefine them under\\n`@media (prefers-color-scheme: dark)`, and style everything through them. Set an\\nexplicit `background` on `body`. This is the same discipline as any page, with\\none simplification: there is no host stamping `data-theme`, so two states is the\\nwhole problem.\\n\\n## Design for two operators\\n\\nThe person changes state through the page. You change the same state through\\n`invoke_canvas_action`. The page has to be honest about that:\\n\\n- **Render from server state, not from what the user just clicked.** After an\\n action mutates state, the page must be able to show the new truth. Poll on a\\n short interval, or push with SSE — both are a few lines with no dependency.\\n- **Make agent-reachable state visible.** If an action can add a note, the notes\\n should be on screen. State only you can see is state the person cannot trust.\\n- **Do not build co-editing.** Concurrent edits to one field is the hard problem\\n the reference canvas declined to solve. Prefer append, toggle, and select over\\n a shared text buffer.\\n- **Show that something changed.** When state moves underneath the person, a\\n brief highlight on the changed row beats a silent re-render.\\n\\n## Actions are tool schemas, so they cost\\n\\nEvery action becomes an agent-callable tool while the instance is open, and its\\nname, description, and `inputSchema` are re-sent on every request for as long as\\nit stays open. Declare the actions the canvas actually needs and give each a\\ntight schema — not one per button.\\n\\nAction results land in the model's context too. Return a summary and a count,\\nnot the whole collection; where a list is genuinely useful, slice it and set a\\nflag saying you did. Measure with `hoocode --print-token-surface` while a canvas\\nis open.\\n\\n## Reload replaces the URL\\n\\nReloading forks a new process and hands back a **new** URL; the tab the person\\nhad open dies with the old one. Two design consequences:\\n\\n- Keep meaningful state on the server side of the canvas, not in the page. A\\n scroll position is fine to lose; a half-filled form is not.\\n- Give the person the new URL every time you reload, and say the old tab is\\n dead. A page that silently stopped updating looks like a bug you caused.\\n\\n## Before you call it done\\n\\n- Open it and look, rather than reasoning about the markup.\\n- Check both color schemes.\\n- Resize narrow — a canvas is often a side window, not a full screen.\\n- Invoke each action and confirm the page reflects it without a manual refresh.\\n- Confirm the page still renders with the network off.\\n\",\n\t\"plugin-authoring/SKILL.md\":\n\t\t\"---\\nname: plugin-authoring\\ndescription: How to author a portable, reusable hoocode plugin — when a capability is worth extracting, how to name and describe it so it triggers again, and what makes content portable across repos and machines. Use before calling ProposePlugin or UpdatePlugin, or when deciding whether a recipe you just completed is worth keeping.\\nallowed-tools: read, write, edit, grep, find, ls\\n---\\n\\n# Authoring a plugin\\n\\nThis is the craft half of the plugin tools. `ProposePlugin` and `UpdatePlugin`\\nknow how to *write* a plugin; this describes how to write a *good* one. Read it\\nbefore authoring, not after.\\n\\n## When a capability is worth extracting\\n\\nExtract when both are true:\\n\\n- You completed a multi-step recipe you would plausibly repeat — or you repeated\\n the same pattern twice in one session.\\n- `SearchPlugins` found nothing that already covers it.\\n\\nDo not extract a one-off. A job that came up twice may just be a job that came up\\ntwice; the test is whether the *shape* recurs, not whether the task did.\\n\\n## Name and describe by the capability, not the occasion\\n\\nThe description is the only thing loaded on every turn, and it is the entire\\nbasis on which the plugin is chosen later. Write it for the next situation, not\\nfor the one that prompted it.\\n\\n- Bad: `fix-flaky-auth-test` — names the incident. It will never trigger again.\\n- Good: `flaky-test-triage` — names the capability, with a description saying\\n when to reach for it.\\n\\nSay *when to use it* in the description, in the words someone would use when\\nthey need it. A description that only says what the plugin is will not trigger.\\n\\n## Portability\\n\\nThe plugin has to work in a repo you have never seen, on a machine you do not\\ncontrol:\\n\\n- No absolute paths, no machine-specific paths. Prefer relative paths and\\n runtime discovery.\\n- No embedded secrets, tokens, or environment-specific values.\\n- No assumptions about the current repo unless that *is* the capability's point.\\n- State prerequisites in the body rather than assuming them.\\n\\nThe layout is the session's target platform. You never choose it.\\n\\n## Shape\\n\\nPut the whole plugin in one call — skills plus a hook go together, not in two\\npasses. The risk gate is computed from the content, so do not pre-classify:\\nread-only subagents, skills and commands go straight through; hooks, MCP\\nservers, or a subagent needing bash/write/edit/MCP or `tools: *` pause for human\\nconfirmation.\\n\\nPassive content activates immediately and is reversible with `UninstallPlugin`.\\nAnnounce what you created and why.\\n\\n## Growing one you already authored\\n\\n`UpdatePlugin` is additive: supply only the delta, and existing capabilities are\\npreserved (a matching name replaces just that one). It cannot remove anything —\\nthat is `RemovePluginCapability`.\\n\\nHooks are the exception to \\\"additive is safe\\\". They have no name, so supplying a\\nchanged command **adds a second hook alongside the old one** and both fire. To\\nchange a hook, remove the old one first, then add the new one.\\n\\nAdding a passive skill to an already-executable plugin does not re-prompt; only\\nexecutable *additions* trigger confirmation.\\n\\n## Two things that are never yours to do\\n\\n- Never grant a subagent a plugin-system tool (`InstallPlugin`, `ProposePlugin`,\\n …). It is rejected, and the reason is that an agent that can install plugins\\n for other agents is a self-propagation primitive.\\n- Never publish to a marketplace autonomously. Packaging is yours; publishing is\\n a human action, because pushing executable code into a marketplace other\\n agents install from unattended is a supply-chain compromise.\\n\",\n};\n"]}
|