@kolisachint/hoocode-agent 0.5.24 → 0.5.25
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 +70 -0
- package/dist/core/brand.d.ts +1 -0
- package/dist/core/brand.d.ts.map +1 -1
- package/dist/core/brand.js +1 -0
- package/dist/core/brand.js.map +1 -1
- package/dist/core/canvas/discovery.d.ts +11 -3
- package/dist/core/canvas/discovery.d.ts.map +1 -1
- package/dist/core/canvas/discovery.js +18 -3
- package/dist/core/canvas/discovery.js.map +1 -1
- package/dist/core/canvas/plugin-canvases.d.ts +30 -0
- package/dist/core/canvas/plugin-canvases.d.ts.map +1 -0
- package/dist/core/canvas/plugin-canvases.js +51 -0
- package/dist/core/canvas/plugin-canvases.js.map +1 -0
- package/dist/core/canvas/session.d.ts +7 -0
- package/dist/core/canvas/session.d.ts.map +1 -1
- package/dist/core/canvas/session.js +8 -1
- package/dist/core/canvas/session.js.map +1 -1
- package/dist/core/canvas/trust.d.ts +4 -5
- package/dist/core/canvas/trust.d.ts.map +1 -1
- package/dist/core/canvas/trust.js +23 -8
- package/dist/core/canvas/trust.js.map +1 -1
- package/dist/core/extensions/plugins/formats/copilot.d.ts +10 -0
- package/dist/core/extensions/plugins/formats/copilot.d.ts.map +1 -1
- package/dist/core/extensions/plugins/formats/copilot.js +36 -4
- package/dist/core/extensions/plugins/formats/copilot.js.map +1 -1
- package/dist/core/extensions/plugins/formats/jsonManifest.d.ts.map +1 -1
- package/dist/core/extensions/plugins/formats/jsonManifest.js +15 -2
- package/dist/core/extensions/plugins/formats/jsonManifest.js.map +1 -1
- package/dist/core/extensions/plugins/formats/shared.d.ts +30 -2
- package/dist/core/extensions/plugins/formats/shared.d.ts.map +1 -1
- package/dist/core/extensions/plugins/formats/shared.js +72 -0
- package/dist/core/extensions/plugins/formats/shared.js.map +1 -1
- package/dist/core/extensions/plugins/install.d.ts +31 -0
- package/dist/core/extensions/plugins/install.d.ts.map +1 -1
- package/dist/core/extensions/plugins/install.js +102 -12
- package/dist/core/extensions/plugins/install.js.map +1 -1
- package/dist/core/extensions/plugins/listing.d.ts.map +1 -1
- package/dist/core/extensions/plugins/listing.js +1 -0
- package/dist/core/extensions/plugins/listing.js.map +1 -1
- package/dist/core/extensions/plugins/manifest.d.ts +18 -0
- package/dist/core/extensions/plugins/manifest.d.ts.map +1 -1
- package/dist/core/extensions/plugins/manifest.js.map +1 -1
- package/dist/core/extensions/plugins/packaging.d.ts.map +1 -1
- package/dist/core/extensions/plugins/packaging.js +1 -0
- package/dist/core/extensions/plugins/packaging.js.map +1 -1
- package/dist/extensions/core/canvas.d.ts.map +1 -1
- package/dist/extensions/core/canvas.js +1 -1
- package/dist/extensions/core/canvas.js.map +1 -1
- package/dist/extensions/core/marketplace.d.ts.map +1 -1
- package/dist/extensions/core/marketplace.js +28 -1
- package/dist/extensions/core/marketplace.js.map +1 -1
- package/dist/extensions/core/scaffold.d.ts +1 -1
- package/dist/extensions/core/scaffold.d.ts.map +1 -1
- package/dist/extensions/core/scaffold.js +185 -1
- package/dist/extensions/core/scaffold.js.map +1 -1
- package/dist/modes/interactive/interactive-mode.d.ts +11 -0
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode.js +40 -0
- package/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/dist/modes/interactive/resource-display.d.ts +11 -0
- package/dist/modes/interactive/resource-display.d.ts.map +1 -1
- package/dist/modes/interactive/resource-display.js +20 -1
- package/dist/modes/interactive/resource-display.js.map +1 -1
- 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
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scaffold.js","sourceRoot":"","sources":["../../../src/extensions/core/scaffold.ts"],"names":[],"mappings":"AAA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,WAAW,EAAE,GAAG,IAAI,KAAK,CAAC,CAAC;YAEpD,IAAI,UAAU,CAAC,WAAW,CAAC,EAAE,CAAC;gBAC7B,GAAG,CAAC,EAAE,CAAC,MAAM,CAAC,iBAAiB,WAAW,iBAAiB,EAAE,SAAS,CAAC,CAAC;gBACxE,OAAO;YACR,CAAC;YAED,SAAS,CAAC,WAAW,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;YAC5C,aAAa,CACZ,WAAW,EACX;gBACC,KAAK;gBACL,SAAS,IAAI,EAAE;gBACf,gBAAgB;gBAChB,0BAA0B,IAAI,2BAA2B;gBACzD,aAAa,IAAI,SAAS;gBAC1B,uBAAuB;gBACvB,KAAK;gBACL,YAAY,IAAI,0CAA0C;gBAC1D,EAAE;gBACF,8DAA8D;gBAC9D,wCAAwC;gBACxC,sCAAsC;gBACtC,MAAM,GAAG,WAAW,GAAG,8BAA8B;gBACrD,EAAE;aACF,CAAC,IAAI,CAAC,IAAI,CAAC,EACZ,MAAM,CACN,CAAC;YAEF,GAAG,CAAC,EAAE,CAAC,MAAM,CACZ,oBAAoB,IAAI,CAAC,UAAU,EAAE,UAAU,EAAE,GAAG,IAAI,KAAK,CAAC,mDAAmD,EACjH,MAAM,CACN,CAAC;QAAA,CACF;KACD,CAAC,CAAC;AAAA,CACH","sourcesContent":["/**\n * Scaffold commands — /new-skill, /new-agent, and /new-command.\n *\n * Without `--platform`, each creates a ready-to-edit resource file\n * under `.hoocode/` (hoocode's private surface), picked up on the next /reload.\n *\n * With `--platform` (or the `platform` setting), the scaffold\n * instead lands in each target platform's *workspace* conventions via the\n * format registry's per-adapter {@link WorkspaceLayout} — e.g.\n * `--platform copilot` writes `.github/skills/<name>/SKILL.md`,\n * `.github/agents/<name>.agent.md`, and `.github/prompts/<name>.prompt.md`,\n * while `claude` writes `.claude/skills|agents|commands/`. hoocode reads all\n * of these back, so the scaffold is live after /reload either way.\n */\n\nimport { existsSync, mkdirSync, writeFileSync } from \"node:fs\";\nimport { dirname, join } from \"node:path\";\nimport { getFormatByPlatform } from \"../../core/extensions/plugins/formats/index.js\";\nimport { getWorkspacePlatforms } from \"../../core/extensions/plugins/formats/platform-targets.js\";\nimport type { EmittedFile, MarketplacePlatform, WorkspaceLayout } from \"../../core/extensions/plugins/formats/types.js\";\nimport type { ExtensionAPI, ExtensionCommandContext } from \"../../core/extensions/types.js\";\n\n/** Validates a resource name: lowercase a-z, 0-9, hyphens, no leading/trailing/double hyphens. */\nfunction validateResourceName(name: string): string | null {\n\tif (!name) return \"name is required\";\n\tif (!/^[a-z0-9-]+$/.test(name)) return \"name must be lowercase a-z, 0-9, and hyphens only\";\n\tif (name.startsWith(\"-\") || name.endsWith(\"-\")) return \"name must not start or end with a hyphen\";\n\tif (name.includes(\"--\")) return \"name must not contain consecutive hyphens\";\n\treturn null;\n}\n\n/**\n * Write one scaffolded artifact into every `--platform` target's\n * workspace layout. Existing files are never clobbered — they are reported and\n * skipped. Returns true when the platform-targeted path handled the command.\n */\nfunction scaffoldForPlatforms(\n\tctx: ExtensionCommandContext,\n\tcommand: string,\n\tplatforms: MarketplacePlatform[],\n\temit: (workspace: WorkspaceLayout) => EmittedFile,\n): void {\n\tconst created: string[] = [];\n\tconst skipped: string[] = [];\n\tfor (const platform of platforms) {\n\t\tconst adapter = getFormatByPlatform(platform);\n\t\tif (!adapter) continue;\n\t\tconst file = emit(adapter.workspace);\n\t\tconst abs = join(ctx.cwd, file.path);\n\t\tif (existsSync(abs)) {\n\t\t\tskipped.push(file.path);\n\t\t\tcontinue;\n\t\t}\n\t\tmkdirSync(dirname(abs), { recursive: true });\n\t\twriteFileSync(abs, file.content, \"utf8\");\n\t\tcreated.push(file.path);\n\t}\n\n\tconst lines: string[] = [];\n\tif (created.length > 0) {\n\t\tlines.push(`Created (${platforms.join(\", \")}):`, ...created.map((f) => ` ${f}`));\n\t\tlines.push(\"Edit the file(s), then run /reload to activate.\");\n\t}\n\tif (skipped.length > 0) {\n\t\tlines.push(`Skipped (already exist):`, ...skipped.map((f) => ` ${f}`));\n\t}\n\tif (lines.length === 0) {\n\t\tlines.push(`/${command}: no writable platform targets resolved`);\n\t}\n\tctx.ui.notify(lines.join(\"\\n\"), created.length > 0 ? \"info\" : \"warning\");\n}\n\nconst SKILL_BODY_TEMPLATE = (name: string) =>\n\t[\n\t\t`# ${name}`,\n\t\t\"\",\n\t\t\"TODO: write the skill instructions here.\",\n\t\t\"\",\n\t\t\"When relative paths appear below, they are resolved from this file's directory.\",\n\t\t\"\",\n\t].join(\"\\n\");\n\nconst AGENT_BODY_TEMPLATE = (name: string) =>\n\t[\n\t\t`You are a ${name} subagent.`,\n\t\t\"You run in an isolated context and cannot see the parent conversation.\",\n\t\t\"\",\n\t\t\"TODO: write the system prompt here.\",\n\t\t\"\",\n\t\t\"Your final message must contain ONLY your answer — it is the only output\",\n\t\t\"the caller receives. Do not include intermediate reasoning or tool logs.\",\n\t\t\"\",\n\t].join(\"\\n\");\n\nconst COMMAND_BODY_TEMPLATE = (name: string) =>\n\t[\n\t\t`Run the /${name} command with arguments: **$ARGUMENTS**.`,\n\t\t\"\",\n\t\t\"TODO: write the instructions here. Placeholders you can use:\",\n\t\t\"- $1, $2, ... for positional arguments\",\n\t\t\"- $@ or $ARGUMENTS for all arguments\",\n\t\t\"\",\n\t].join(\"\\n\");\n\nexport function setupScaffold(pi: ExtensionAPI): void {\n\t// ── /new-skill <name> ─────────────────────────────────────────────────────\n\t// Creates a SKILL.md with valid Agent Skills frontmatter — under .hoocode/ by\n\t// default, or under each --platform target's skills directory.\n\n\tpi.registerCommand(\"new-skill\", {\n\t\tdescription: \"Scaffold a new skill. Usage: /new-skill <name>\",\n\t\tgetArgumentCompletions: () => [],\n\t\thandler: async (args: string, ctx: ExtensionCommandContext): Promise<void> => {\n\t\t\tconst name = args.trim();\n\t\t\tconst error = validateResourceName(name);\n\t\t\tif (error) {\n\t\t\t\tctx.ui.notify(`/new-skill: ${error}. Usage: /new-skill <name>`, \"warning\");\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst platforms = getWorkspacePlatforms();\n\t\t\tif (platforms) {\n\t\t\t\tscaffoldForPlatforms(ctx, \"new-skill\", platforms, (ws) =>\n\t\t\t\t\tws.emitSkill({\n\t\t\t\t\t\tname,\n\t\t\t\t\t\tdescription:\n\t\t\t\t\t\t\t\"TODO: describe when to use this skill — the agent reads this to decide whether to load it.\",\n\t\t\t\t\t\tbody: SKILL_BODY_TEMPLATE(name),\n\t\t\t\t\t}),\n\t\t\t\t);\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst skillDir = join(ctx.cwd, \".hoocode\", \"skills\", name);\n\t\t\tconst skillFile = join(skillDir, \"SKILL.md\");\n\n\t\t\tif (existsSync(skillFile)) {\n\t\t\t\tctx.ui.notify(`/new-skill: ${skillFile} already exists`, \"warning\");\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tmkdirSync(skillDir, { recursive: true });\n\t\t\twriteFileSync(\n\t\t\t\tskillFile,\n\t\t\t\t[\n\t\t\t\t\t\"---\",\n\t\t\t\t\t`name: ${name}`,\n\t\t\t\t\t\"description: |\",\n\t\t\t\t\t\" TODO: describe when to use this skill — one clear sentence per bullet.\",\n\t\t\t\t\t\" The model reads this to decide whether to load the skill.\",\n\t\t\t\t\t\"allowed-tools: read, bash\",\n\t\t\t\t\t\"---\",\n\t\t\t\t\t\"\",\n\t\t\t\t\tSKILL_BODY_TEMPLATE(name),\n\t\t\t\t].join(\"\\n\"),\n\t\t\t\t\"utf8\",\n\t\t\t);\n\n\t\t\tctx.ui.notify(\n\t\t\t\t`Skill created: ${join(\".hoocode\", \"skills\", name, \"SKILL.md\")}\\nEdit the file, then run /reload to activate it.`,\n\t\t\t\t\"info\",\n\t\t\t);\n\t\t},\n\t});\n\n\t// ── /new-agent <name> ─────────────────────────────────────────────────────\n\t// Creates a subagent definition — .hoocode/agents/<name>.md by default, or\n\t// each platform's convention (.claude/agents/<name>.md,\n\t// .github/agents/<name>.agent.md with a YAML-list tools grant, ...).\n\n\tpi.registerCommand(\"new-agent\", {\n\t\tdescription: \"Scaffold a new subagent. Usage: /new-agent <name>\",\n\t\tgetArgumentCompletions: () => [],\n\t\thandler: async (args: string, ctx: ExtensionCommandContext): Promise<void> => {\n\t\t\tconst name = args.trim();\n\t\t\tconst error = validateResourceName(name);\n\t\t\tif (error) {\n\t\t\t\tctx.ui.notify(`/new-agent: ${error}. Usage: /new-agent <name>`, \"warning\");\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst platforms = getWorkspacePlatforms();\n\t\t\tif (platforms) {\n\t\t\t\tscaffoldForPlatforms(ctx, \"new-agent\", platforms, (ws) =>\n\t\t\t\t\tws.emitAgent({\n\t\t\t\t\t\tname,\n\t\t\t\t\t\tdescription: \"TODO: describe the task(s) to delegate to this agent.\",\n\t\t\t\t\t\ttools: \"read, bash\",\n\t\t\t\t\t\tbody: AGENT_BODY_TEMPLATE(name),\n\t\t\t\t\t}),\n\t\t\t\t);\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst agentsDir = join(ctx.cwd, \".hoocode\", \"agents\");\n\t\t\tconst agentFile = join(agentsDir, `${name}.md`);\n\n\t\t\tif (existsSync(agentFile)) {\n\t\t\t\tctx.ui.notify(`/new-agent: ${agentFile} already exists`, \"warning\");\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tmkdirSync(agentsDir, { recursive: true });\n\t\t\twriteFileSync(\n\t\t\t\tagentFile,\n\t\t\t\t[\n\t\t\t\t\t\"---\",\n\t\t\t\t\t`name: ${name}`,\n\t\t\t\t\t\"description: |\",\n\t\t\t\t\t\" Use this subagent ONLY when:\",\n\t\t\t\t\t\" - TODO: describe the task(s) to delegate here\",\n\t\t\t\t\t\"\",\n\t\t\t\t\t\" DO NOT use for:\",\n\t\t\t\t\t\" - TODO: describe what this agent should NOT handle\",\n\t\t\t\t\t\"tools: read, bash\",\n\t\t\t\t\t\"model: sonnet\",\n\t\t\t\t\t\"---\",\n\t\t\t\t\t`You are a ${name} subagent running inside hoocode.`,\n\t\t\t\t\t\"You run in an isolated context and cannot see the parent conversation.\",\n\t\t\t\t\t\"\",\n\t\t\t\t\t\"TODO: write the system prompt here.\",\n\t\t\t\t\t\"\",\n\t\t\t\t\t\"Your final message must contain ONLY your answer — it is the only output\",\n\t\t\t\t\t\"the caller receives. Do not include intermediate reasoning or tool logs.\",\n\t\t\t\t\t\"\",\n\t\t\t\t].join(\"\\n\"),\n\t\t\t\t\"utf8\",\n\t\t\t);\n\n\t\t\tctx.ui.notify(\n\t\t\t\t`Agent created: ${join(\".hoocode\", \"agents\", `${name}.md`)}\\nEdit the file, then run /reload to activate it.`,\n\t\t\t\t\"info\",\n\t\t\t);\n\t\t},\n\t});\n\n\t// ── /new-command <name> ───────────────────────────────────────────────────\n\t// Creates a slash-command prompt template — .hoocode/commands/<name>.md by\n\t// default, or each platform's convention (.claude/commands/<name>.md,\n\t// .github/prompts/<name>.prompt.md, ...).\n\n\tpi.registerCommand(\"new-command\", {\n\t\tdescription: \"Scaffold a new slash command. Usage: /new-command <name>\",\n\t\tgetArgumentCompletions: () => [],\n\t\thandler: async (args: string, ctx: ExtensionCommandContext): Promise<void> => {\n\t\t\tconst name = args.trim();\n\t\t\tconst error = validateResourceName(name);\n\t\t\tif (error) {\n\t\t\t\tctx.ui.notify(`/new-command: ${error}. Usage: /new-command <name>`, \"warning\");\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst platforms = getWorkspacePlatforms();\n\t\t\tif (platforms) {\n\t\t\t\tscaffoldForPlatforms(ctx, \"new-command\", platforms, (ws) =>\n\t\t\t\t\tws.emitCommand({\n\t\t\t\t\t\tname,\n\t\t\t\t\t\tdescription: `TODO: describe what /${name} does and when to use it.`,\n\t\t\t\t\t\tbody: COMMAND_BODY_TEMPLATE(name),\n\t\t\t\t\t}),\n\t\t\t\t);\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst commandsDir = join(ctx.cwd, \".hoocode\", \"commands\");\n\t\t\tconst commandFile = join(commandsDir, `${name}.md`);\n\n\t\t\tif (existsSync(commandFile)) {\n\t\t\t\tctx.ui.notify(`/new-command: ${commandFile} already exists`, \"warning\");\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tmkdirSync(commandsDir, { recursive: true });\n\t\t\twriteFileSync(\n\t\t\t\tcommandFile,\n\t\t\t\t[\n\t\t\t\t\t\"---\",\n\t\t\t\t\t`name: ${name}`,\n\t\t\t\t\t\"description: |\",\n\t\t\t\t\t` TODO: describe what /${name} does and when to use it.`,\n\t\t\t\t\t` Usage: /${name} <args>`,\n\t\t\t\t\t\"argument-hint: <args>\",\n\t\t\t\t\t\"---\",\n\t\t\t\t\t`Run the /${name} command with arguments: **$ARGUMENTS**.`,\n\t\t\t\t\t\"\",\n\t\t\t\t\t\"TODO: write the instructions here. Placeholders you can use:\",\n\t\t\t\t\t\"- $1, $2, ... for positional arguments\",\n\t\t\t\t\t\"- $@ or $ARGUMENTS for all arguments\",\n\t\t\t\t\t`- $${\"{\"}@:N} / $${\"{\"}@:N:L} for bash-style slices`,\n\t\t\t\t\t\"\",\n\t\t\t\t].join(\"\\n\"),\n\t\t\t\t\"utf8\",\n\t\t\t);\n\n\t\t\tctx.ui.notify(\n\t\t\t\t`Command created: ${join(\".hoocode\", \"commands\", `${name}.md`)}\\nEdit the file, then run /reload to activate it.`,\n\t\t\t\t\"info\",\n\t\t\t);\n\t\t},\n\t});\n}\n"]}
|
|
1
|
+
{"version":3,"file":"scaffold.js","sourceRoot":"","sources":["../../../src/extensions/core/scaffold.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAC/D,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EAAE,iBAAiB,EA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IAAI,SAAS;oBAAE,KAAK,CAAC,IAAI,CAAC,EAAE,EAAE,SAAS,CAAC,CAAC;YAC1C,CAAC;YACD,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;gBACxB,KAAK,CAAC,IAAI,CAAC,0BAA0B,EAAE,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,CAAC;YAC/E,CAAC;YACD,GAAG,CAAC,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;QAAA,CACzE;KACD,CAAC,CAAC;AAAA,CACH","sourcesContent":["/**\n * Scaffold commands — /new-skill, /new-agent, /new-command, and /new-canvas.\n *\n * Without `--platform`, each creates a ready-to-edit resource file\n * under `.hoocode/` (hoocode's private surface), picked up on the next /reload.\n *\n * With `--platform` (or the `platform` setting), the scaffold\n * instead lands in each target platform's *workspace* conventions via the\n * format registry's per-adapter {@link WorkspaceLayout} — e.g.\n * `--platform copilot` writes `.github/skills/<name>/SKILL.md`,\n * `.github/agents/<name>.agent.md`, and `.github/prompts/<name>.prompt.md`,\n * while `claude` writes `.claude/skills|agents|commands/`. hoocode reads all\n * of these back, so the scaffold is live after /reload either way.\n */\n\nimport { existsSync, mkdirSync, writeFileSync } from \"node:fs\";\nimport { dirname, join } from \"node:path\";\nimport { getAgentDir } from \"../../config.js\";\nimport { CANVAS_ENTRY_FILE } from \"../../core/canvas/discovery.js\";\nimport { getFormatByPlatform } from \"../../core/extensions/plugins/formats/index.js\";\nimport { getWorkspacePlatforms } from \"../../core/extensions/plugins/formats/platform-targets.js\";\nimport type { EmittedFile, MarketplacePlatform, WorkspaceLayout } from \"../../core/extensions/plugins/formats/types.js\";\nimport { isWorkspaceTrusted, trustWorkspace } from \"../../core/extensions/plugins/trust.js\";\nimport type { ExtensionAPI, ExtensionCommandContext } from \"../../core/extensions/types.js\";\n\n/** Validates a resource name: lowercase a-z, 0-9, hyphens, no leading/trailing/double hyphens. */\nfunction validateResourceName(name: string): string | null {\n\tif (!name) return \"name is required\";\n\tif (!/^[a-z0-9-]+$/.test(name)) return \"name must be lowercase a-z, 0-9, and hyphens only\";\n\tif (name.startsWith(\"-\") || name.endsWith(\"-\")) return \"name must not start or end with a hyphen\";\n\tif (name.includes(\"--\")) return \"name must not contain consecutive hyphens\";\n\treturn null;\n}\n\n/**\n * Write one scaffolded artifact into every `--platform` target's\n * workspace layout. Existing files are never clobbered — they are reported and\n * skipped. Returns true when the platform-targeted path handled the command.\n */\nfunction scaffoldForPlatforms(\n\tctx: ExtensionCommandContext,\n\tcommand: string,\n\tplatforms: MarketplacePlatform[],\n\temit: (workspace: WorkspaceLayout) => EmittedFile,\n): void {\n\tconst created: string[] = [];\n\tconst skipped: string[] = [];\n\tfor (const platform of platforms) {\n\t\tconst adapter = getFormatByPlatform(platform);\n\t\tif (!adapter) continue;\n\t\tconst file = emit(adapter.workspace);\n\t\tconst abs = join(ctx.cwd, file.path);\n\t\tif (existsSync(abs)) {\n\t\t\tskipped.push(file.path);\n\t\t\tcontinue;\n\t\t}\n\t\tmkdirSync(dirname(abs), { recursive: true });\n\t\twriteFileSync(abs, file.content, \"utf8\");\n\t\tcreated.push(file.path);\n\t}\n\n\tconst lines: string[] = [];\n\tif (created.length > 0) {\n\t\tlines.push(`Created (${platforms.join(\", \")}):`, ...created.map((f) => ` ${f}`));\n\t\tlines.push(\"Edit the file(s), then run /reload to activate.\");\n\t}\n\tif (skipped.length > 0) {\n\t\tlines.push(`Skipped (already exist):`, ...skipped.map((f) => ` ${f}`));\n\t}\n\tif (lines.length === 0) {\n\t\tlines.push(`/${command}: no writable platform targets resolved`);\n\t}\n\tctx.ui.notify(lines.join(\"\\n\"), created.length > 0 ? \"info\" : \"warning\");\n}\n\nconst SKILL_BODY_TEMPLATE = (name: string) =>\n\t[\n\t\t`# ${name}`,\n\t\t\"\",\n\t\t\"TODO: write the skill instructions here.\",\n\t\t\"\",\n\t\t\"When relative paths appear below, they are resolved from this file's directory.\",\n\t\t\"\",\n\t].join(\"\\n\");\n\nconst AGENT_BODY_TEMPLATE = (name: string) =>\n\t[\n\t\t`You are a ${name} subagent.`,\n\t\t\"You run in an isolated context and cannot see the parent conversation.\",\n\t\t\"\",\n\t\t\"TODO: write the system prompt here.\",\n\t\t\"\",\n\t\t\"Your final message must contain ONLY your answer — it is the only output\",\n\t\t\"the caller receives. Do not include intermediate reasoning or tool logs.\",\n\t\t\"\",\n\t].join(\"\\n\");\n\nconst COMMAND_BODY_TEMPLATE = (name: string) =>\n\t[\n\t\t`Run the /${name} command with arguments: **$ARGUMENTS**.`,\n\t\t\"\",\n\t\t\"TODO: write the instructions here. Placeholders you can use:\",\n\t\t\"- $1, $2, ... for positional arguments\",\n\t\t\"- $@ or $ARGUMENTS for all arguments\",\n\t\t\"\",\n\t].join(\"\\n\");\n\n/**\n * A working single-canvas extension.\n *\n * Deliberately complete rather than a stub: a canvas has no passive half — its\n * name, its actions and its UI all come from running its code — so a scaffold\n * that does not run teaches nothing and cannot be checked with `/canvas open`.\n * This one opens, serves a page, answers an action, and closes cleanly, which is\n * the whole contract; everything past that is the author's.\n *\n * Shaped like the catalog extensions hoocode already hosts: the only import is\n * `@github/copilot-sdk/extension` (host-resolved — never installed, see\n * `docs/canvas-extensions-design.md` §4.1) plus `node:` builtins, and the UI is\n * served from an ephemeral loopback port behind a per-instance token so nothing\n * else on the machine can read it.\n */\nconst CANVAS_ENTRY_TEMPLATE = (name: string): string => `\\\n// ${name} — a canvas extension. Run it with: /canvas open ${name}\n//\n// The \"@github/copilot-sdk/extension\" import is resolved by the host at fork\n// time. Do not install it, and do not add a node_modules here.\nimport { createCanvas, CanvasError, joinSession } from \"@github/copilot-sdk/extension\";\nimport { randomBytes } from \"node:crypto\";\nimport { createServer } from \"node:http\";\n\n/** Per-instance state. A canvas can be opened more than once at a time. */\nconst instances = new Map();\n\nconst session = await joinSession({\n\tcanvases: [\n\t\tcreateCanvas({\n\t\t\tid: \"${name}\",\n\t\t\tdisplayName: \"${name}\",\n\t\t\tdescription: \"TODO: one sentence — the agent reads this to decide whether to open it.\",\n\t\t\tactions: [\n\t\t\t\t{\n\t\t\t\t\tname: \"add_note\",\n\t\t\t\t\tdescription: \"TODO: describe what the agent can do to this canvas.\",\n\t\t\t\t\tinputSchema: {\n\t\t\t\t\t\ttype: \"object\",\n\t\t\t\t\t\tproperties: { text: { type: \"string\" } },\n\t\t\t\t\t\trequired: [\"text\"],\n\t\t\t\t\t},\n\t\t\t\t\thandler: (ctx) => {\n\t\t\t\t\t\tconst entry = instances.get(ctx.instanceId);\n\t\t\t\t\t\t// CanvasError carries a code the host shows verbatim; a bare\n\t\t\t\t\t\t// throw arrives as an opaque internal error instead.\n\t\t\t\t\t\tif (!entry) throw new CanvasError(\"no_instance\", \\`Instance \"\\${ctx.instanceId}\" is not open.\\`);\n\t\t\t\t\t\tentry.notes.push(ctx.input.text);\n\t\t\t\t\t\treturn { notes: entry.notes.length };\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t],\n\t\t\topen: async (ctx) => {\n\t\t\t\tconst token = randomBytes(32).toString(\"base64url\");\n\t\t\t\tconst notes = [];\n\t\t\t\tconst server = createServer((req, res) => {\n\t\t\t\t\tconst url = new URL(req.url ?? \"/\", \"http://127.0.0.1\");\n\t\t\t\t\tif (url.searchParams.get(\"token\") !== token) {\n\t\t\t\t\t\tres.writeHead(403, { \"Content-Type\": \"text/plain\" });\n\t\t\t\t\t\tres.end(\"forbidden\");\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\tres.writeHead(200, { \"Content-Type\": \"text/html; charset=utf-8\" });\n\t\t\t\t\tres.end(\n\t\t\t\t\t\t\\`<!doctype html><meta charset=\"utf-8\"><title>${name}</title>\\` +\n\t\t\t\t\t\t\t\\`<p>\\${notes.length} note(s). TODO: build the UI.\\`,\n\t\t\t\t\t);\n\t\t\t\t});\n\t\t\t\t// Port 0 on 127.0.0.1: an ephemeral port, reachable only from this machine.\n\t\t\t\tawait new Promise((resolve) => server.listen(0, \"127.0.0.1\", resolve));\n\t\t\t\tconst { port } = server.address();\n\t\t\t\tinstances.set(ctx.instanceId, { server, notes });\n\t\t\t\treturn {\n\t\t\t\t\turl: \\`http://127.0.0.1:\\${port}/?token=\\${token}\\`,\n\t\t\t\t\ttitle: \"${name}\",\n\t\t\t\t};\n\t\t\t},\n\t\t\tonClose: async (ctx) => {\n\t\t\t\tconst entry = instances.get(ctx.instanceId);\n\t\t\t\t// Called for an abandoned open too, so the instance may be unknown.\n\t\t\t\tif (!entry) return;\n\t\t\t\tinstances.delete(ctx.instanceId);\n\t\t\t\tawait new Promise((resolve) => entry.server.close(resolve));\n\t\t\t},\n\t\t}),\n\t],\n});\n\n// stdout is the protocol channel. Use session.log, never console.log.\nawait session.log(\"${name} ready\");\n`;\n\n/**\n * Where a canvas extension lives, per platform.\n *\n * This does not go through {@link WorkspaceLayout} like the other scaffolds, and\n * the reason is that a canvas has no Claude convention to emit into: the surface\n * exists in Copilot and in hoocode's own `.agents/` tree and nowhere else. A\n * layout method returning nothing for one adapter would be a worse lie than\n * naming the two real homes here — these are exactly the roots\n * `core/canvas/discovery.ts` searches, which is what makes a scaffold live on\n * the next /canvas.\n */\nconst CANVAS_HOMES: Partial<Record<MarketplacePlatform, string[]>> = {\n\tagents: [\".agents\", \"extensions\"],\n\tgithub: [\".github\", \"extensions\"],\n};\n\nexport function setupScaffold(pi: ExtensionAPI): void {\n\t// ── /new-skill <name> ─────────────────────────────────────────────────────\n\t// Creates a SKILL.md with valid Agent Skills frontmatter — under .hoocode/ by\n\t// default, or under each --platform target's skills directory.\n\n\tpi.registerCommand(\"new-skill\", {\n\t\tdescription: \"Scaffold a new skill. Usage: /new-skill <name>\",\n\t\tgetArgumentCompletions: () => [],\n\t\thandler: async (args: string, ctx: ExtensionCommandContext): Promise<void> => {\n\t\t\tconst name = args.trim();\n\t\t\tconst error = validateResourceName(name);\n\t\t\tif (error) {\n\t\t\t\tctx.ui.notify(`/new-skill: ${error}. Usage: /new-skill <name>`, \"warning\");\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst platforms = getWorkspacePlatforms();\n\t\t\tif (platforms) {\n\t\t\t\tscaffoldForPlatforms(ctx, \"new-skill\", platforms, (ws) =>\n\t\t\t\t\tws.emitSkill({\n\t\t\t\t\t\tname,\n\t\t\t\t\t\tdescription:\n\t\t\t\t\t\t\t\"TODO: describe when to use this skill — the agent reads this to decide whether to load it.\",\n\t\t\t\t\t\tbody: SKILL_BODY_TEMPLATE(name),\n\t\t\t\t\t}),\n\t\t\t\t);\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst skillDir = join(ctx.cwd, \".hoocode\", \"skills\", name);\n\t\t\tconst skillFile = join(skillDir, \"SKILL.md\");\n\n\t\t\tif (existsSync(skillFile)) {\n\t\t\t\tctx.ui.notify(`/new-skill: ${skillFile} already exists`, \"warning\");\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tmkdirSync(skillDir, { recursive: true });\n\t\t\twriteFileSync(\n\t\t\t\tskillFile,\n\t\t\t\t[\n\t\t\t\t\t\"---\",\n\t\t\t\t\t`name: ${name}`,\n\t\t\t\t\t\"description: |\",\n\t\t\t\t\t\" TODO: describe when to use this skill — one clear sentence per bullet.\",\n\t\t\t\t\t\" The model reads this to decide whether to load the skill.\",\n\t\t\t\t\t\"allowed-tools: read, bash\",\n\t\t\t\t\t\"---\",\n\t\t\t\t\t\"\",\n\t\t\t\t\tSKILL_BODY_TEMPLATE(name),\n\t\t\t\t].join(\"\\n\"),\n\t\t\t\t\"utf8\",\n\t\t\t);\n\n\t\t\tctx.ui.notify(\n\t\t\t\t`Skill created: ${join(\".hoocode\", \"skills\", name, \"SKILL.md\")}\\nEdit the file, then run /reload to activate it.`,\n\t\t\t\t\"info\",\n\t\t\t);\n\t\t},\n\t});\n\n\t// ── /new-agent <name> ─────────────────────────────────────────────────────\n\t// Creates a subagent definition — .hoocode/agents/<name>.md by default, or\n\t// each platform's convention (.claude/agents/<name>.md,\n\t// .github/agents/<name>.agent.md with a YAML-list tools grant, ...).\n\n\tpi.registerCommand(\"new-agent\", {\n\t\tdescription: \"Scaffold a new subagent. Usage: /new-agent <name>\",\n\t\tgetArgumentCompletions: () => [],\n\t\thandler: async (args: string, ctx: ExtensionCommandContext): Promise<void> => {\n\t\t\tconst name = args.trim();\n\t\t\tconst error = validateResourceName(name);\n\t\t\tif (error) {\n\t\t\t\tctx.ui.notify(`/new-agent: ${error}. Usage: /new-agent <name>`, \"warning\");\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst platforms = getWorkspacePlatforms();\n\t\t\tif (platforms) {\n\t\t\t\tscaffoldForPlatforms(ctx, \"new-agent\", platforms, (ws) =>\n\t\t\t\t\tws.emitAgent({\n\t\t\t\t\t\tname,\n\t\t\t\t\t\tdescription: \"TODO: describe the task(s) to delegate to this agent.\",\n\t\t\t\t\t\ttools: \"read, bash\",\n\t\t\t\t\t\tbody: AGENT_BODY_TEMPLATE(name),\n\t\t\t\t\t}),\n\t\t\t\t);\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst agentsDir = join(ctx.cwd, \".hoocode\", \"agents\");\n\t\t\tconst agentFile = join(agentsDir, `${name}.md`);\n\n\t\t\tif (existsSync(agentFile)) {\n\t\t\t\tctx.ui.notify(`/new-agent: ${agentFile} already exists`, \"warning\");\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tmkdirSync(agentsDir, { recursive: true });\n\t\t\twriteFileSync(\n\t\t\t\tagentFile,\n\t\t\t\t[\n\t\t\t\t\t\"---\",\n\t\t\t\t\t`name: ${name}`,\n\t\t\t\t\t\"description: |\",\n\t\t\t\t\t\" Use this subagent ONLY when:\",\n\t\t\t\t\t\" - TODO: describe the task(s) to delegate here\",\n\t\t\t\t\t\"\",\n\t\t\t\t\t\" DO NOT use for:\",\n\t\t\t\t\t\" - TODO: describe what this agent should NOT handle\",\n\t\t\t\t\t\"tools: read, bash\",\n\t\t\t\t\t\"model: sonnet\",\n\t\t\t\t\t\"---\",\n\t\t\t\t\t`You are a ${name} subagent running inside hoocode.`,\n\t\t\t\t\t\"You run in an isolated context and cannot see the parent conversation.\",\n\t\t\t\t\t\"\",\n\t\t\t\t\t\"TODO: write the system prompt here.\",\n\t\t\t\t\t\"\",\n\t\t\t\t\t\"Your final message must contain ONLY your answer — it is the only output\",\n\t\t\t\t\t\"the caller receives. Do not include intermediate reasoning or tool logs.\",\n\t\t\t\t\t\"\",\n\t\t\t\t].join(\"\\n\"),\n\t\t\t\t\"utf8\",\n\t\t\t);\n\n\t\t\tctx.ui.notify(\n\t\t\t\t`Agent created: ${join(\".hoocode\", \"agents\", `${name}.md`)}\\nEdit the file, then run /reload to activate it.`,\n\t\t\t\t\"info\",\n\t\t\t);\n\t\t},\n\t});\n\n\t// ── /new-command <name> ───────────────────────────────────────────────────\n\t// Creates a slash-command prompt template — .hoocode/commands/<name>.md by\n\t// default, or each platform's convention (.claude/commands/<name>.md,\n\t// .github/prompts/<name>.prompt.md, ...).\n\n\tpi.registerCommand(\"new-command\", {\n\t\tdescription: \"Scaffold a new slash command. Usage: /new-command <name>\",\n\t\tgetArgumentCompletions: () => [],\n\t\thandler: async (args: string, ctx: ExtensionCommandContext): Promise<void> => {\n\t\t\tconst name = args.trim();\n\t\t\tconst error = validateResourceName(name);\n\t\t\tif (error) {\n\t\t\t\tctx.ui.notify(`/new-command: ${error}. Usage: /new-command <name>`, \"warning\");\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst platforms = getWorkspacePlatforms();\n\t\t\tif (platforms) {\n\t\t\t\tscaffoldForPlatforms(ctx, \"new-command\", platforms, (ws) =>\n\t\t\t\t\tws.emitCommand({\n\t\t\t\t\t\tname,\n\t\t\t\t\t\tdescription: `TODO: describe what /${name} does and when to use it.`,\n\t\t\t\t\t\tbody: COMMAND_BODY_TEMPLATE(name),\n\t\t\t\t\t}),\n\t\t\t\t);\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst commandsDir = join(ctx.cwd, \".hoocode\", \"commands\");\n\t\t\tconst commandFile = join(commandsDir, `${name}.md`);\n\n\t\t\tif (existsSync(commandFile)) {\n\t\t\t\tctx.ui.notify(`/new-command: ${commandFile} already exists`, \"warning\");\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tmkdirSync(commandsDir, { recursive: true });\n\t\t\twriteFileSync(\n\t\t\t\tcommandFile,\n\t\t\t\t[\n\t\t\t\t\t\"---\",\n\t\t\t\t\t`name: ${name}`,\n\t\t\t\t\t\"description: |\",\n\t\t\t\t\t` TODO: describe what /${name} does and when to use it.`,\n\t\t\t\t\t` Usage: /${name} <args>`,\n\t\t\t\t\t\"argument-hint: <args>\",\n\t\t\t\t\t\"---\",\n\t\t\t\t\t`Run the /${name} command with arguments: **$ARGUMENTS**.`,\n\t\t\t\t\t\"\",\n\t\t\t\t\t\"TODO: write the instructions here. Placeholders you can use:\",\n\t\t\t\t\t\"- $1, $2, ... for positional arguments\",\n\t\t\t\t\t\"- $@ or $ARGUMENTS for all arguments\",\n\t\t\t\t\t`- $${\"{\"}@:N} / $${\"{\"}@:N:L} for bash-style slices`,\n\t\t\t\t\t\"\",\n\t\t\t\t].join(\"\\n\"),\n\t\t\t\t\"utf8\",\n\t\t\t);\n\n\t\t\tctx.ui.notify(\n\t\t\t\t`Command created: ${join(\".hoocode\", \"commands\", `${name}.md`)}\\nEdit the file, then run /reload to activate it.`,\n\t\t\t\t\"info\",\n\t\t\t);\n\t\t},\n\t});\n\n\t// ── /new-canvas <name> ────────────────────────────────────────────────────\n\t// Creates a canvas extension — .agents/extensions/<name>/extension.mjs by\n\t// default, or .github/extensions/<name>/ with --platform github (Copilot's\n\t// project scope). Design: docs/canvas-extensions-design.md §9, Phase 3.\n\t//\n\t// Unlike the other scaffolds this one needs no /reload: canvases are\n\t// discovered when /canvas runs, not loaded at session start, so the new\n\t// extension is openable immediately.\n\n\tpi.registerCommand(\"new-canvas\", {\n\t\tdescription: \"Scaffold a new canvas extension. Usage: /new-canvas <name>\",\n\t\tgetArgumentCompletions: () => [],\n\t\thandler: async (args: string, ctx: ExtensionCommandContext): Promise<void> => {\n\t\t\tconst name = args.trim();\n\t\t\tconst error = validateResourceName(name);\n\t\t\tif (error) {\n\t\t\t\tctx.ui.notify(`/new-canvas: ${error}. Usage: /new-canvas <name>`, \"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: string[] = [];\n\t\t\tconst skipped: string[] = [];\n\t\t\tfor (const platform of targets) {\n\t\t\t\tconst home = CANVAS_HOMES[platform];\n\t\t\t\tif (!home) continue;\n\t\t\t\tconst relative = join(...home, name, CANVAS_ENTRY_FILE);\n\t\t\t\tconst absolute = join(ctx.cwd, relative);\n\t\t\t\tif (existsSync(absolute)) {\n\t\t\t\t\tskipped.push(relative);\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tmkdirSync(dirname(absolute), { recursive: true });\n\t\t\t\twriteFileSync(absolute, CANVAS_ENTRY_TEMPLATE(name), \"utf8\");\n\t\t\t\tcreated.push(relative);\n\t\t\t}\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\tconst lines: string[] = [];\n\t\t\tif (created.length > 0) {\n\t\t\t\tlines.push(\"Canvas created:\", ...created.map((file) => ` ${file}`));\n\t\t\t\tlines.push(\"\", `Open it now with /canvas open ${name} — no /reload needed.`);\n\t\t\t\tif (trustNote) lines.push(\"\", trustNote);\n\t\t\t}\n\t\t\tif (skipped.length > 0) {\n\t\t\t\tlines.push(\"Skipped (already exist):\", ...skipped.map((file) => ` ${file}`));\n\t\t\t}\n\t\t\tctx.ui.notify(lines.join(\"\\n\"), created.length > 0 ? \"info\" : \"warning\");\n\t\t},\n\t});\n}\n"]}
|
|
@@ -139,6 +139,17 @@ export declare class InteractiveMode {
|
|
|
139
139
|
private applyRuntimeSettings;
|
|
140
140
|
private rebindCurrentSession;
|
|
141
141
|
private handleFatalRuntimeError;
|
|
142
|
+
/**
|
|
143
|
+
* Reset the transcript to whatever the (possibly just-swapped) session holds.
|
|
144
|
+
*
|
|
145
|
+
* Every caller — /new, /resume, /fork — reaches here *after* the runtime has
|
|
146
|
+
* rebound extensions, and rebinding is what renders the loaded-resource
|
|
147
|
+
* listing. Clearing the chat therefore wiped the listing a moment after it was
|
|
148
|
+
* drawn, which is why /reload showed skills, agents and plugins and starting a
|
|
149
|
+
* new session showed nothing. Re-rendering it here is what makes the surface
|
|
150
|
+
* common: one call site, so a session change of any kind reports the same
|
|
151
|
+
* capabilities /reload does.
|
|
152
|
+
*/
|
|
142
153
|
private renderCurrentSessionState;
|
|
143
154
|
/**
|
|
144
155
|
* Bound the view layer's memory: freeze finished tool blocks once more than
|