@kolisachint/hoocode-agent 0.5.29 → 0.5.30
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 +24 -0
- package/dist/core/light.d.ts +9 -0
- package/dist/core/light.d.ts.map +1 -1
- package/dist/core/light.js +12 -4
- package/dist/core/light.js.map +1 -1
- package/dist/modes/interactive/components/settings-selector.d.ts +20 -0
- package/dist/modes/interactive/components/settings-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/settings-selector.js +105 -35
- package/dist/modes/interactive/components/settings-selector.js.map +1 -1
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode.js +21 -1
- package/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/docs/settings.md +21 -0
- package/docs/usage.md +3 -3
- 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/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,29 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [0.5.30] - 2026-08-23
|
|
4
|
+
|
|
5
|
+
### Added
|
|
6
|
+
|
|
7
|
+
- `/settings` prices what it is about to cost you. A line under the pane reports
|
|
8
|
+
the fixed per-turn surface — system prompt plus active tool schemas, the text
|
|
9
|
+
re-sent on every request — and each tool carries its own schema price beside
|
|
10
|
+
its switch, including the tools that are off, where the price is what turning
|
|
11
|
+
one back on will cost. The numbers are the same measurement
|
|
12
|
+
`--print-token-surface` prints, re-measured after every change, so a toggle
|
|
13
|
+
that moves the surface shows what it moved.
|
|
14
|
+
|
|
15
|
+
- The `light` preset is editable from `/settings`. It was the one low-token
|
|
16
|
+
control with no home in the pane, which is backwards for the setting whose
|
|
17
|
+
entire purpose is the token budget. It reads at startup, so it applies on the
|
|
18
|
+
next session.
|
|
19
|
+
|
|
20
|
+
- `/settings` grouping: a **Context** category now holds auto-compact, context
|
|
21
|
+
GC and the light preset. Those three decide the token budget and were in three
|
|
22
|
+
different places — auto-compact alone at the top level, context GC filed under
|
|
23
|
+
tool settings, light nowhere. Tool output display joins the truncation caps it
|
|
24
|
+
belongs with under one **Tool output** row, and every top-level row now opens
|
|
25
|
+
something rather than cycling in place.
|
|
26
|
+
|
|
3
27
|
## [0.5.29] - 2026-08-23
|
|
4
28
|
|
|
5
29
|
### Added
|
package/dist/core/light.d.ts
CHANGED
|
@@ -47,6 +47,15 @@ export interface PromptSurface {
|
|
|
47
47
|
tokens: number;
|
|
48
48
|
}>;
|
|
49
49
|
}
|
|
50
|
+
/**
|
|
51
|
+
* What one tool costs on every request: its serialized `{name, description,
|
|
52
|
+
* parameters}`, the three fields a provider re-sends each turn.
|
|
53
|
+
*
|
|
54
|
+
* Exported because the surface is worth showing for a tool that is *off* too —
|
|
55
|
+
* `/settings` prices each toggle with it, and a disabled tool has no entry in a
|
|
56
|
+
* measured surface precisely because it currently costs nothing.
|
|
57
|
+
*/
|
|
58
|
+
export declare function measureToolSchemaTokens(tool: ToolInfo): number;
|
|
50
59
|
/**
|
|
51
60
|
* Measure the fixed per-turn surface a session sends on every request: the
|
|
52
61
|
* assembled system prompt plus the serialized schemas (name, description,
|
package/dist/core/light.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"light.d.ts","sourceRoot":"","sources":["../../src/core/light.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iCAAiC,CAAC;AAEjE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAGtD,8CAA8C;AAC9C,eAAO,MAAM,gBAAgB,4CAA6C,CAAC;AAE3E;;;;GAIG;AACH,eAAO,MAAM,mBAAmB,2MAEP,CAAC;AAE1B;;;;;GAKG;AACH,e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AAC,CAgDvE;AAED,6DAA6D;AAC7D,MAAM,WAAW,aAAa;IAC7B,uDAAuD;IACvD,kBAAkB,EAAE,MAAM,CAAC;IAC3B,kEAAkE;IAClE,gBAAgB,EAAE,MAAM,CAAC;IACzB,6CAA6C;IAC7C,WAAW,EAAE,MAAM,CAAC;IACpB,4DAA4D;IAC5D,KAAK,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CAC/C;AAOD;;;;;;;GAOG;AACH,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,QAAQ,GAAG,MAAM,CAI9D;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE;IAC7C,YAAY,EAAE,MAAM,CAAC;IACrB,kBAAkB,IAAI,MAAM,EAAE,CAAC;IAC/B,WAAW,IAAI,QAAQ,EAAE,CAAC;CAC1B,GAAG,aAAa,CAchB","sourcesContent":["/**\n * Light mode — a minimal, low-token preset for small/local models.\n *\n * The preset restricts the session to the four core tools (read, write, edit,\n * bash) with shortened descriptions and undocumented parameter schemas,\n * replaces the default system prompt with a terse one, and disables\n * subagents, TodoWrite, skills, context files, and the mode-prompt appendix.\n * The goal is the smallest possible fixed per-turn surface (system prompt +\n * serialized tool schemas) so weak tool-callers waste no context on harness\n * boilerplate. bash subsumes grep/find/ls: search happens via the shell.\n */\n\nimport type { AgentTool } from \"@kolisachint/hoocode-agent-core\";\nimport { Type } from \"typebox\";\nimport type { ToolInfo } from \"./extensions/types.js\";\nimport { createBashTool, createEditTool, createReadTool, createWriteTool } from \"./tools/index.js\";\n\n/** The only tools a light session exposes. */\nexport const LIGHT_TOOL_NAMES = [\"read\", \"write\", \"edit\", \"bash\"] as const;\n\n/**\n * Terse replacement for the default system prompt. buildSystemPrompt appends\n * the current date and working directory; nothing else rides along because\n * light mode also disables skills, context files, and the mode appendix.\n */\nexport const LIGHT_SYSTEM_PROMPT = `You are a coding agent. Use the tools to read, edit, and write files and run shell commands.\nSearch with bash (grep/find/ls). Prefer edit for changes; write for new files.\nBe concise. No preamble.`;\n\n/**\n * Environment flag signaling light mode to code that cannot see CLI flags or\n * settings — notably the hoo-core modes extension, which reads it to skip the\n * `<!-- hoo-core: mode= -->` system-prompt appendix. Same pattern as\n * WARM_SUBAGENTS_ENV / SUBAGENT_MAX_DEPTH_ENV.\n */\nexport const LIGHT_MODE_ENV = \"HOOCODE_LIGHT\";\n\n/** Whether light mode was signaled through the environment. */\nexport function isLightModeEnv(): boolean {\n\treturn process.env[LIGHT_MODE_ENV] === \"1\";\n}\n\n// Light parameter schemas: same shapes the real tools accept, minus the\n// per-property descriptions (that is where most schema tokens live).\nconst lightReadSchema = Type.Object({\n\tpath: Type.String(),\n\toffset: Type.Optional(Type.Number()),\n\tlimit: Type.Optional(Type.Number()),\n});\n\nconst lightWriteSchema = Type.Object({\n\tpath: Type.String(),\n\tcontent: Type.String(),\n});\n\n// Flat single-replacement shape instead of the full edits[] batch schema. The\n// execute shim below converts it to the batch form the real edit tool expects.\nconst lightEditSchema = Type.Object({\n\tpath: Type.String(),\n\toldText: Type.String(),\n\tnewText: Type.String(),\n});\n\nconst lightBashSchema = Type.Object({\n\tcommand: Type.String(),\n\ttimeout: Type.Optional(Type.Number()),\n});\n\n/**\n * Build the four light tools for `baseToolsOverride`: the real tool\n * implementations wearing short descriptions and stripped parameter schemas.\n */\nexport function createLightTools(cwd: string): Record<string, AgentTool> {\n\tconst read = createReadTool(cwd);\n\tconst write = createWriteTool(cwd);\n\tconst edit = createEditTool(cwd);\n\tconst bash = createBashTool(cwd);\n\n\tconst lightRead: AgentTool<typeof lightReadSchema> = {\n\t\t...read,\n\t\tdescription: \"Read a file. args: path, offset?, limit?\",\n\t\tparameters: lightReadSchema,\n\t};\n\n\tconst lightWrite: AgentTool<typeof lightWriteSchema> = {\n\t\t...write,\n\t\tdescription: \"Write file (overwrites). args: path, content\",\n\t\tparameters: lightWriteSchema,\n\t};\n\n\t// The real edit tool validates against its edits[] schema after\n\t// prepareArguments runs, so the flat light shape must skip the original\n\t// prepareArguments (validation sees the raw flat args against the flat\n\t// schema) and convert to the batch form at execute time instead.\n\tconst lightEdit: AgentTool<typeof lightEditSchema> = {\n\t\t...edit,\n\t\tdescription: \"Replace exact text. args: path, oldText, newText\",\n\t\tparameters: lightEditSchema,\n\t\tprepareArguments: undefined,\n\t\texecute: (toolCallId, params, signal, onUpdate) =>\n\t\t\tedit.execute(\n\t\t\t\ttoolCallId,\n\t\t\t\t{ path: params.path, edits: [{ oldText: params.oldText, newText: params.newText }] },\n\t\t\t\tsignal,\n\t\t\t\tonUpdate,\n\t\t\t),\n\t};\n\n\tconst lightBash: AgentTool<typeof lightBashSchema> = {\n\t\t...bash,\n\t\tdescription: \"Run a shell command. args: command, timeout?\",\n\t\tparameters: lightBashSchema,\n\t};\n\n\treturn {\n\t\tread: lightRead as AgentTool,\n\t\twrite: lightWrite as AgentTool,\n\t\tedit: lightEdit as AgentTool,\n\t\tbash: lightBash as AgentTool,\n\t};\n}\n\n/** Token breakdown of a session's fixed per-turn surface. */\nexport interface PromptSurface {\n\t/** Estimated tokens in the assembled system prompt. */\n\tsystemPromptTokens: number;\n\t/** Estimated tokens across the serialized active tool schemas. */\n\ttoolSchemaTokens: number;\n\t/** systemPromptTokens + toolSchemaTokens. */\n\ttotalTokens: number;\n\t/** Per-tool breakdown of the serialized schema estimate. */\n\ttools: Array<{ name: string; tokens: number }>;\n}\n\n/** Same conservative chars/4 heuristic the agent harness uses for context estimates. */\nfunction estimateStringTokens(text: string): number {\n\treturn Math.ceil(text.length / 4);\n}\n\n/**\n * What one tool costs on every request: its serialized `{name, description,\n * parameters}`, the three fields a provider re-sends each turn.\n *\n * Exported because the surface is worth showing for a tool that is *off* too —\n * `/settings` prices each toggle with it, and a disabled tool has no entry in a\n * measured surface precisely because it currently costs nothing.\n */\nexport function measureToolSchemaTokens(tool: ToolInfo): number {\n\treturn estimateStringTokens(\n\t\tJSON.stringify({ name: tool.name, description: tool.description, parameters: tool.parameters }),\n\t);\n}\n\n/**\n * Measure the fixed per-turn surface a session sends on every request: the\n * assembled system prompt plus the serialized schemas (name, description,\n * parameters) of the active tools. Providers add their own envelope on top,\n * so treat the result as a floor estimate.\n */\nexport function measurePromptSurface(session: {\n\tsystemPrompt: string;\n\tgetActiveToolNames(): string[];\n\tgetAllTools(): ToolInfo[];\n}): PromptSurface {\n\tconst activeNames = new Set(session.getActiveToolNames());\n\tconst tools = session\n\t\t.getAllTools()\n\t\t.filter((tool) => activeNames.has(tool.name))\n\t\t.map((tool) => ({ name: tool.name, tokens: measureToolSchemaTokens(tool) }));\n\tconst systemPromptTokens = estimateStringTokens(session.systemPrompt);\n\tconst toolSchemaTokens = tools.reduce((sum, tool) => sum + tool.tokens, 0);\n\treturn {\n\t\tsystemPromptTokens,\n\t\ttoolSchemaTokens,\n\t\ttotalTokens: systemPromptTokens + toolSchemaTokens,\n\t\ttools,\n\t};\n}\n"]}
|
package/dist/core/light.js
CHANGED
|
@@ -100,6 +100,17 @@ export function createLightTools(cwd) {
|
|
|
100
100
|
function estimateStringTokens(text) {
|
|
101
101
|
return Math.ceil(text.length / 4);
|
|
102
102
|
}
|
|
103
|
+
/**
|
|
104
|
+
* What one tool costs on every request: its serialized `{name, description,
|
|
105
|
+
* parameters}`, the three fields a provider re-sends each turn.
|
|
106
|
+
*
|
|
107
|
+
* Exported because the surface is worth showing for a tool that is *off* too —
|
|
108
|
+
* `/settings` prices each toggle with it, and a disabled tool has no entry in a
|
|
109
|
+
* measured surface precisely because it currently costs nothing.
|
|
110
|
+
*/
|
|
111
|
+
export function measureToolSchemaTokens(tool) {
|
|
112
|
+
return estimateStringTokens(JSON.stringify({ name: tool.name, description: tool.description, parameters: tool.parameters }));
|
|
113
|
+
}
|
|
103
114
|
/**
|
|
104
115
|
* Measure the fixed per-turn surface a session sends on every request: the
|
|
105
116
|
* assembled system prompt plus the serialized schemas (name, description,
|
|
@@ -111,10 +122,7 @@ export function measurePromptSurface(session) {
|
|
|
111
122
|
const tools = session
|
|
112
123
|
.getAllTools()
|
|
113
124
|
.filter((tool) => activeNames.has(tool.name))
|
|
114
|
-
.map((tool) => ({
|
|
115
|
-
name: tool.name,
|
|
116
|
-
tokens: estimateStringTokens(JSON.stringify({ name: tool.name, description: tool.description, parameters: tool.parameters })),
|
|
117
|
-
}));
|
|
125
|
+
.map((tool) => ({ name: tool.name, tokens: measureToolSchemaTokens(tool) }));
|
|
118
126
|
const systemPromptTokens = estimateStringTokens(session.systemPrompt);
|
|
119
127
|
const toolSchemaTokens = tools.reduce((sum, tool) => sum + tool.tokens, 0);
|
|
120
128
|
return {
|
package/dist/core/light.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"light.js","sourceRoot":"","sources":["../../src/core/light.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAGH,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAE/B,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAEnG,8CAA8C;AAC9C,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,CAAU,CAAC;AAE3E;;;;GAIG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG;;yBAEV,CAAC;AAE1B;;;;;GAKG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,eAAe,CAAC;AAE9C,+DAA+D;AAC/D,MAAM,UAAU,cAAc,GAAY;IACzC,OAAO,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC,KAAK,GAAG,CAAC;AAAA,CAC3C;AAED,wEAAwE;AACxE,qEAAqE;AACrE,MAAM,eAAe,GAAG,IAAI,CAAC,MAAM,CAAC;IACnC,IAAI,EAAE,IAAI,CAAC,MAAM,EAAE;IACnB,MAAM,EAAE,IAAI,CAAC,QAAQ,CAAC,I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,IAAI,CAAC,SAAS,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,WAAW,EAAE,IAAI,CAAC,WAAW,EAAE,UAAU,EAAE,IAAI,CAAC,UAAU,EAAE,CAAC,CAC/F;KACD,CAAC,CAAC,CAAC;IACL,MAAM,kBAAkB,GAAG,oBAAoB,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;IACtE,MAAM,gBAAgB,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,IAAI,EAAE,EAAE,CAAC,GAAG,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;IAC3E,OAAO;QACN,kBAAkB;QAClB,gBAAgB;QAChB,WAAW,EAAE,kBAAkB,GAAG,gBAAgB;QAClD,KAAK;KACL,CAAC;AAAA,CACF","sourcesContent":["/**\n * Light mode — a minimal, low-token preset for small/local models.\n *\n * The preset restricts the session to the four core tools (read, write, edit,\n * bash) with shortened descriptions and undocumented parameter schemas,\n * replaces the default system prompt with a terse one, and disables\n * subagents, TodoWrite, skills, context files, and the mode-prompt appendix.\n * The goal is the smallest possible fixed per-turn surface (system prompt +\n * serialized tool schemas) so weak tool-callers waste no context on harness\n * boilerplate. bash subsumes grep/find/ls: search happens via the shell.\n */\n\nimport type { AgentTool } from \"@kolisachint/hoocode-agent-core\";\nimport { Type } from \"typebox\";\nimport type { ToolInfo } from \"./extensions/types.js\";\nimport { createBashTool, createEditTool, createReadTool, createWriteTool } from \"./tools/index.js\";\n\n/** The only tools a light session exposes. */\nexport const LIGHT_TOOL_NAMES = [\"read\", \"write\", \"edit\", \"bash\"] as const;\n\n/**\n * Terse replacement for the default system prompt. buildSystemPrompt appends\n * the current date and working directory; nothing else rides along because\n * light mode also disables skills, context files, and the mode appendix.\n */\nexport const LIGHT_SYSTEM_PROMPT = `You are a coding agent. Use the tools to read, edit, and write files and run shell commands.\nSearch with bash (grep/find/ls). Prefer edit for changes; write for new files.\nBe concise. No preamble.`;\n\n/**\n * Environment flag signaling light mode to code that cannot see CLI flags or\n * settings — notably the hoo-core modes extension, which reads it to skip the\n * `<!-- hoo-core: mode= -->` system-prompt appendix. Same pattern as\n * WARM_SUBAGENTS_ENV / SUBAGENT_MAX_DEPTH_ENV.\n */\nexport const LIGHT_MODE_ENV = \"HOOCODE_LIGHT\";\n\n/** Whether light mode was signaled through the environment. */\nexport function isLightModeEnv(): boolean {\n\treturn process.env[LIGHT_MODE_ENV] === \"1\";\n}\n\n// Light parameter schemas: same shapes the real tools accept, minus the\n// per-property descriptions (that is where most schema tokens live).\nconst lightReadSchema = Type.Object({\n\tpath: Type.String(),\n\toffset: Type.Optional(Type.Number()),\n\tlimit: Type.Optional(Type.Number()),\n});\n\nconst lightWriteSchema = Type.Object({\n\tpath: Type.String(),\n\tcontent: Type.String(),\n});\n\n// Flat single-replacement shape instead of the full edits[] batch schema. The\n// execute shim below converts it to the batch form the real edit tool expects.\nconst lightEditSchema = Type.Object({\n\tpath: Type.String(),\n\toldText: Type.String(),\n\tnewText: Type.String(),\n});\n\nconst lightBashSchema = Type.Object({\n\tcommand: Type.String(),\n\ttimeout: Type.Optional(Type.Number()),\n});\n\n/**\n * Build the four light tools for `baseToolsOverride`: the real tool\n * implementations wearing short descriptions and stripped parameter schemas.\n */\nexport function createLightTools(cwd: string): Record<string, AgentTool> {\n\tconst read = createReadTool(cwd);\n\tconst write = createWriteTool(cwd);\n\tconst edit = createEditTool(cwd);\n\tconst bash = createBashTool(cwd);\n\n\tconst lightRead: AgentTool<typeof lightReadSchema> = {\n\t\t...read,\n\t\tdescription: \"Read a file. args: path, offset?, limit?\",\n\t\tparameters: lightReadSchema,\n\t};\n\n\tconst lightWrite: AgentTool<typeof lightWriteSchema> = {\n\t\t...write,\n\t\tdescription: \"Write file (overwrites). args: path, content\",\n\t\tparameters: lightWriteSchema,\n\t};\n\n\t// The real edit tool validates against its edits[] schema after\n\t// prepareArguments runs, so the flat light shape must skip the original\n\t// prepareArguments (validation sees the raw flat args against the flat\n\t// schema) and convert to the batch form at execute time instead.\n\tconst lightEdit: AgentTool<typeof lightEditSchema> = {\n\t\t...edit,\n\t\tdescription: \"Replace exact text. args: path, oldText, newText\",\n\t\tparameters: lightEditSchema,\n\t\tprepareArguments: undefined,\n\t\texecute: (toolCallId, params, signal, onUpdate) =>\n\t\t\tedit.execute(\n\t\t\t\ttoolCallId,\n\t\t\t\t{ path: params.path, edits: [{ oldText: params.oldText, newText: params.newText }] },\n\t\t\t\tsignal,\n\t\t\t\tonUpdate,\n\t\t\t),\n\t};\n\n\tconst lightBash: AgentTool<typeof lightBashSchema> = {\n\t\t...bash,\n\t\tdescription: \"Run a shell command. args: command, timeout?\",\n\t\tparameters: lightBashSchema,\n\t};\n\n\treturn {\n\t\tread: lightRead as AgentTool,\n\t\twrite: lightWrite as AgentTool,\n\t\tedit: lightEdit as AgentTool,\n\t\tbash: lightBash as AgentTool,\n\t};\n}\n\n/** Token breakdown of a session's fixed per-turn surface. */\nexport interface PromptSurface {\n\t/** Estimated tokens in the assembled system prompt. */\n\tsystemPromptTokens: number;\n\t/** Estimated tokens across the serialized active tool schemas. */\n\ttoolSchemaTokens: number;\n\t/** systemPromptTokens + toolSchemaTokens. */\n\ttotalTokens: number;\n\t/** Per-tool breakdown of the serialized schema estimate. */\n\ttools: Array<{ name: string; tokens: number }>;\n}\n\n/** Same conservative chars/4 heuristic the agent harness uses for context estimates. */\nfunction estimateStringTokens(text: string): number {\n\treturn Math.ceil(text.length / 4);\n}\n\n/**\n * Measure the fixed per-turn surface a session sends on every request: the\n * assembled system prompt plus the serialized schemas (name, description,\n * parameters) of the active tools. Providers add their own envelope on top,\n * so treat the result as a floor estimate.\n */\nexport function measurePromptSurface(session: {\n\tsystemPrompt: string;\n\tgetActiveToolNames(): string[];\n\tgetAllTools(): ToolInfo[];\n}): PromptSurface {\n\tconst activeNames = new Set(session.getActiveToolNames());\n\tconst tools = session\n\t\t.getAllTools()\n\t\t.filter((tool) => activeNames.has(tool.name))\n\t\t.map((tool) => ({\n\t\t\tname: tool.name,\n\t\t\ttokens: estimateStringTokens(\n\t\t\t\tJSON.stringify({ name: tool.name, description: tool.description, parameters: tool.parameters }),\n\t\t\t),\n\t\t}));\n\tconst systemPromptTokens = estimateStringTokens(session.systemPrompt);\n\tconst toolSchemaTokens = tools.reduce((sum, tool) => sum + tool.tokens, 0);\n\treturn {\n\t\tsystemPromptTokens,\n\t\ttoolSchemaTokens,\n\t\ttotalTokens: systemPromptTokens + toolSchemaTokens,\n\t\ttools,\n\t};\n}\n"]}
|
|
1
|
+
{"version":3,"file":"light.js","sourceRoot":"","sources":["../../src/core/light.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAGH,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAE/B,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAEnG,8CAA8C;AAC9C,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,CAAU,CAAC;AAE3E;;;;GAIG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG;;yBAEV,CAAC;AAE1B;;;;;GAKG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,eAAe,CAAC;AAE9C,+DAA+D;AAC/D,MAAM,UAAU,cAAc,GAAY;IACzC,OAAO,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC,KAAK,GAAG,CAAC;AAAA,CAC3C;AAED,wEAAwE;AACxE,qEAAqE;AACrE,MAAM,eAAe,GAAG,IAAI,CAAC,MAAM,CAAC;IACnC,IAAI,EAAE,IAAI,CAAC,MAAM,EAAE;IACnB,MAAM,EAAE,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC;IACpC,KAAK,EAAE,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC;CACnC,CAAC,CAAC;AAEH,MAA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,CAAC;SAC5C,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,uBAAuB,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC;IAC9E,MAAM,kBAAkB,GAAG,oBAAoB,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;IACtE,MAAM,gBAAgB,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,IAAI,EAAE,EAAE,CAAC,GAAG,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;IAC3E,OAAO;QACN,kBAAkB;QAClB,gBAAgB;QAChB,WAAW,EAAE,kBAAkB,GAAG,gBAAgB;QAClD,KAAK;KACL,CAAC;AAAA,CACF","sourcesContent":["/**\n * Light mode — a minimal, low-token preset for small/local models.\n *\n * The preset restricts the session to the four core tools (read, write, edit,\n * bash) with shortened descriptions and undocumented parameter schemas,\n * replaces the default system prompt with a terse one, and disables\n * subagents, TodoWrite, skills, context files, and the mode-prompt appendix.\n * The goal is the smallest possible fixed per-turn surface (system prompt +\n * serialized tool schemas) so weak tool-callers waste no context on harness\n * boilerplate. bash subsumes grep/find/ls: search happens via the shell.\n */\n\nimport type { AgentTool } from \"@kolisachint/hoocode-agent-core\";\nimport { Type } from \"typebox\";\nimport type { ToolInfo } from \"./extensions/types.js\";\nimport { createBashTool, createEditTool, createReadTool, createWriteTool } from \"./tools/index.js\";\n\n/** The only tools a light session exposes. */\nexport const LIGHT_TOOL_NAMES = [\"read\", \"write\", \"edit\", \"bash\"] as const;\n\n/**\n * Terse replacement for the default system prompt. buildSystemPrompt appends\n * the current date and working directory; nothing else rides along because\n * light mode also disables skills, context files, and the mode appendix.\n */\nexport const LIGHT_SYSTEM_PROMPT = `You are a coding agent. Use the tools to read, edit, and write files and run shell commands.\nSearch with bash (grep/find/ls). Prefer edit for changes; write for new files.\nBe concise. No preamble.`;\n\n/**\n * Environment flag signaling light mode to code that cannot see CLI flags or\n * settings — notably the hoo-core modes extension, which reads it to skip the\n * `<!-- hoo-core: mode= -->` system-prompt appendix. Same pattern as\n * WARM_SUBAGENTS_ENV / SUBAGENT_MAX_DEPTH_ENV.\n */\nexport const LIGHT_MODE_ENV = \"HOOCODE_LIGHT\";\n\n/** Whether light mode was signaled through the environment. */\nexport function isLightModeEnv(): boolean {\n\treturn process.env[LIGHT_MODE_ENV] === \"1\";\n}\n\n// Light parameter schemas: same shapes the real tools accept, minus the\n// per-property descriptions (that is where most schema tokens live).\nconst lightReadSchema = Type.Object({\n\tpath: Type.String(),\n\toffset: Type.Optional(Type.Number()),\n\tlimit: Type.Optional(Type.Number()),\n});\n\nconst lightWriteSchema = Type.Object({\n\tpath: Type.String(),\n\tcontent: Type.String(),\n});\n\n// Flat single-replacement shape instead of the full edits[] batch schema. The\n// execute shim below converts it to the batch form the real edit tool expects.\nconst lightEditSchema = Type.Object({\n\tpath: Type.String(),\n\toldText: Type.String(),\n\tnewText: Type.String(),\n});\n\nconst lightBashSchema = Type.Object({\n\tcommand: Type.String(),\n\ttimeout: Type.Optional(Type.Number()),\n});\n\n/**\n * Build the four light tools for `baseToolsOverride`: the real tool\n * implementations wearing short descriptions and stripped parameter schemas.\n */\nexport function createLightTools(cwd: string): Record<string, AgentTool> {\n\tconst read = createReadTool(cwd);\n\tconst write = createWriteTool(cwd);\n\tconst edit = createEditTool(cwd);\n\tconst bash = createBashTool(cwd);\n\n\tconst lightRead: AgentTool<typeof lightReadSchema> = {\n\t\t...read,\n\t\tdescription: \"Read a file. args: path, offset?, limit?\",\n\t\tparameters: lightReadSchema,\n\t};\n\n\tconst lightWrite: AgentTool<typeof lightWriteSchema> = {\n\t\t...write,\n\t\tdescription: \"Write file (overwrites). args: path, content\",\n\t\tparameters: lightWriteSchema,\n\t};\n\n\t// The real edit tool validates against its edits[] schema after\n\t// prepareArguments runs, so the flat light shape must skip the original\n\t// prepareArguments (validation sees the raw flat args against the flat\n\t// schema) and convert to the batch form at execute time instead.\n\tconst lightEdit: AgentTool<typeof lightEditSchema> = {\n\t\t...edit,\n\t\tdescription: \"Replace exact text. args: path, oldText, newText\",\n\t\tparameters: lightEditSchema,\n\t\tprepareArguments: undefined,\n\t\texecute: (toolCallId, params, signal, onUpdate) =>\n\t\t\tedit.execute(\n\t\t\t\ttoolCallId,\n\t\t\t\t{ path: params.path, edits: [{ oldText: params.oldText, newText: params.newText }] },\n\t\t\t\tsignal,\n\t\t\t\tonUpdate,\n\t\t\t),\n\t};\n\n\tconst lightBash: AgentTool<typeof lightBashSchema> = {\n\t\t...bash,\n\t\tdescription: \"Run a shell command. args: command, timeout?\",\n\t\tparameters: lightBashSchema,\n\t};\n\n\treturn {\n\t\tread: lightRead as AgentTool,\n\t\twrite: lightWrite as AgentTool,\n\t\tedit: lightEdit as AgentTool,\n\t\tbash: lightBash as AgentTool,\n\t};\n}\n\n/** Token breakdown of a session's fixed per-turn surface. */\nexport interface PromptSurface {\n\t/** Estimated tokens in the assembled system prompt. */\n\tsystemPromptTokens: number;\n\t/** Estimated tokens across the serialized active tool schemas. */\n\ttoolSchemaTokens: number;\n\t/** systemPromptTokens + toolSchemaTokens. */\n\ttotalTokens: number;\n\t/** Per-tool breakdown of the serialized schema estimate. */\n\ttools: Array<{ name: string; tokens: number }>;\n}\n\n/** Same conservative chars/4 heuristic the agent harness uses for context estimates. */\nfunction estimateStringTokens(text: string): number {\n\treturn Math.ceil(text.length / 4);\n}\n\n/**\n * What one tool costs on every request: its serialized `{name, description,\n * parameters}`, the three fields a provider re-sends each turn.\n *\n * Exported because the surface is worth showing for a tool that is *off* too —\n * `/settings` prices each toggle with it, and a disabled tool has no entry in a\n * measured surface precisely because it currently costs nothing.\n */\nexport function measureToolSchemaTokens(tool: ToolInfo): number {\n\treturn estimateStringTokens(\n\t\tJSON.stringify({ name: tool.name, description: tool.description, parameters: tool.parameters }),\n\t);\n}\n\n/**\n * Measure the fixed per-turn surface a session sends on every request: the\n * assembled system prompt plus the serialized schemas (name, description,\n * parameters) of the active tools. Providers add their own envelope on top,\n * so treat the result as a floor estimate.\n */\nexport function measurePromptSurface(session: {\n\tsystemPrompt: string;\n\tgetActiveToolNames(): string[];\n\tgetAllTools(): ToolInfo[];\n}): PromptSurface {\n\tconst activeNames = new Set(session.getActiveToolNames());\n\tconst tools = session\n\t\t.getAllTools()\n\t\t.filter((tool) => activeNames.has(tool.name))\n\t\t.map((tool) => ({ name: tool.name, tokens: measureToolSchemaTokens(tool) }));\n\tconst systemPromptTokens = estimateStringTokens(session.systemPrompt);\n\tconst toolSchemaTokens = tools.reduce((sum, tool) => sum + tool.tokens, 0);\n\treturn {\n\t\tsystemPromptTokens,\n\t\ttoolSchemaTokens,\n\t\ttotalTokens: systemPromptTokens + toolSchemaTokens,\n\t\ttools,\n\t};\n}\n"]}
|
|
@@ -2,12 +2,20 @@ import type { ThinkingLevel } from "@kolisachint/hoocode-agent-core";
|
|
|
2
2
|
import type { Transport } from "@kolisachint/hoocode-ai";
|
|
3
3
|
import { Container, SettingsList } from "@kolisachint/hoocode-tui";
|
|
4
4
|
import type { MarketplacePlatform } from "../../../core/extensions/plugins/formats/types.js";
|
|
5
|
+
import type { PromptSurface } from "../../../core/light.js";
|
|
5
6
|
import type { LearnSettingKey, WarningSettings } from "../../../core/settings-manager.js";
|
|
6
7
|
interface ToolToggleInfo {
|
|
7
8
|
/** Tool name (e.g. "read", "bash"). */
|
|
8
9
|
name: string;
|
|
9
10
|
/** Whether the tool is currently enabled (not in the persisted disabled set). */
|
|
10
11
|
enabled: boolean;
|
|
12
|
+
/**
|
|
13
|
+
* What this tool's serialized schema costs on every request. Priced whether or
|
|
14
|
+
* not it is on: for a tool that is off, this is what turning it on will cost.
|
|
15
|
+
* Undefined for a tool that was disabled before launch, whose schema this
|
|
16
|
+
* session never built.
|
|
17
|
+
*/
|
|
18
|
+
tokens?: number;
|
|
11
19
|
}
|
|
12
20
|
interface FlagInfo {
|
|
13
21
|
/** Flag name (without the leading --). */
|
|
@@ -39,6 +47,7 @@ export interface SettingsConfig {
|
|
|
39
47
|
autoResizeImages: boolean;
|
|
40
48
|
blockImages: boolean;
|
|
41
49
|
enableSkillCommands: boolean;
|
|
50
|
+
light: boolean;
|
|
42
51
|
pluginInstallScope: "user" | "project";
|
|
43
52
|
enablePluginTools: boolean;
|
|
44
53
|
/**
|
|
@@ -71,6 +80,12 @@ export interface SettingsConfig {
|
|
|
71
80
|
voiceSilenceMs: number;
|
|
72
81
|
webtoolsTimeoutSecs: number;
|
|
73
82
|
learn: Record<LearnSettingKey, number>;
|
|
83
|
+
/**
|
|
84
|
+
* Re-measure the fixed per-turn surface (system prompt + active tool schemas).
|
|
85
|
+
* Called on open and after every change, so a toggle that costs tokens shows
|
|
86
|
+
* what it cost. Omitted by callers that have no session to measure.
|
|
87
|
+
*/
|
|
88
|
+
measureTokenSurface?: () => PromptSurface;
|
|
74
89
|
}
|
|
75
90
|
export interface SettingsCallbacks {
|
|
76
91
|
onAutoCompactChange: (enabled: boolean) => void;
|
|
@@ -86,6 +101,7 @@ export interface SettingsCallbacks {
|
|
|
86
101
|
onAutoResizeImagesChange: (enabled: boolean) => void;
|
|
87
102
|
onBlockImagesChange: (blocked: boolean) => void;
|
|
88
103
|
onEnableSkillCommandsChange: (enabled: boolean) => void;
|
|
104
|
+
onLightChange: (enabled: boolean) => void;
|
|
89
105
|
onPluginInstallScopeChange: (scope: "user" | "project") => void;
|
|
90
106
|
onEnablePluginToolsChange: (enabled: boolean) => void;
|
|
91
107
|
onPlatformChange: (platforms: MarketplacePlatform[]) => void;
|
|
@@ -118,7 +134,11 @@ export interface SettingsCallbacks {
|
|
|
118
134
|
*/
|
|
119
135
|
export declare class SettingsSelectorComponent extends Container {
|
|
120
136
|
private settingsList;
|
|
137
|
+
private surfaceLine?;
|
|
138
|
+
private measureTokenSurface?;
|
|
121
139
|
constructor(config: SettingsConfig, callbacks: SettingsCallbacks);
|
|
140
|
+
/** Re-price the pane after a change that may have altered what each turn sends. */
|
|
141
|
+
private refreshTokenSurface;
|
|
122
142
|
getSettingsList(): SettingsList;
|
|
123
143
|
}
|
|
124
144
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"settings-selector.d.ts","sourceRoot":"","sources":["../../../../src/modes/interactive/components/settings-selector.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC;AACrE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AACzD,OAAO,EACN,SAAS,EAOT,YAAY,EAGZ,MAAM,0BAA0B,CAAC;AAClC,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,mDAAmD,CAAC;AAC7F,OAAO,KAAK,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,mCAAmC,CAAC;AAmB1F,UAAU,cAAc;IACvB,uCAAuC;IACvC,IAAI,EAAE,MAAM,CAAC;IACb,iFAAiF;IACjF,OAAO,EAAE,OAAO,CAAC;CACjB;AAED,UAAU,QAAQ;IACjB,0CAA0C;IAC1C,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,IAAI,EAAE,SAAS,GAAG,QAAQ,CAAC;IAC3B,+BAA+B;IAC/B,KAAK,EAAE,OAAO,GAAG,MAAM,CAAC;CACxB;AAED,UAAU,aAAa;IACtB,kDAAkD;IAClD,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;IACpB,wEAAwE;IACxE,OAAO,EAAE,OAAO,CAAC;CACjB;AAED,MAAM,WAAW,cAAc;IAC9B,WAAW,EAAE,OAAO,CAAC;IACrB,KAAK,EAAE,cAAc,EAAE,CAAC;IACxB,UAAU,EAAE,aAAa,EAAE,CAAC;IAC5B,KAAK,EAAE,QAAQ,EAAE,CAAC;IAClB,iBAAiB,EAAE,WAAW,GAAG,MAAM,GAAG,UAAU,CAAC;IACr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AE,OAAO,KAAK,IAAI,CAAC;IACzD,gBAAgB,EAAE,CAAC,QAAQ,EAAE,eAAe,KAAK,IAAI,CAAC;IACtD,sBAAsB,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;IAC7C,2BAA2B,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IACpD,oBAAoB,EAAE,CAAC,GAAG,EAAE,eAAe,EAAE,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACpE,QAAQ,EAAE,MAAM,IAAI,CAAC;CACrB;AA6iBD;;GAEG;AACH,qBAAa,yBAA0B,SAAQ,SAAS;IACvD,OAAO,CAAC,YAAY,CAAe;IAEnC,YAAY,MAAM,EAAE,cAAc,EAAE,SAAS,EAAE,iBAAiB,EAulB/D;IAED,eAAe,IAAI,YAAY,CAE9B;CACD","sourcesContent":["import type { ThinkingLevel } from \"@kolisachint/hoocode-agent-core\";\nimport type { Transport } from \"@kolisachint/hoocode-ai\";\nimport {\n\tContainer,\n\tgetCapabilities,\n\tInput,\n\ttype SelectItem,\n\tSelectList,\n\ttype SelectListLayoutOptions,\n\ttype SettingItem,\n\tSettingsList,\n\tSpacer,\n\tText,\n} from \"@kolisachint/hoocode-tui\";\nimport type { MarketplacePlatform } from \"../../../core/extensions/plugins/formats/types.js\";\nimport type { LearnSettingKey, WarningSettings } from \"../../../core/settings-manager.js\";\nimport { getSelectListTheme, getSettingsListTheme, getThemeDescription, theme } from \"../theme/theme.js\";\nimport { DynamicBorder } from \"./dynamic-border.js\";\nimport { keyDisplayText } from \"./keybinding-hints.js\";\n\nconst SETTINGS_SUBMENU_SELECT_LIST_LAYOUT: SelectListLayoutOptions = {\n\tminPrimaryColumnWidth: 12,\n\tmaxPrimaryColumnWidth: 32,\n};\n\nconst THINKING_DESCRIPTIONS: Record<ThinkingLevel, string> = {\n\toff: \"No reasoning\",\n\tminimal: \"Very brief reasoning (~1k tokens)\",\n\tlow: \"Light reasoning (~2k tokens)\",\n\tmedium: \"Moderate reasoning (~8k tokens)\",\n\thigh: \"Deep reasoning (~16k tokens)\",\n\txhigh: \"Maximum reasoning (~32k tokens)\",\n};\n\ninterface ToolToggleInfo {\n\t/** Tool name (e.g. \"read\", \"bash\"). */\n\tname: string;\n\t/** Whether the tool is currently enabled (not in the persisted disabled set). */\n\tenabled: boolean;\n}\n\ninterface FlagInfo {\n\t/** Flag name (without the leading --). */\n\tname: string;\n\tdescription?: string;\n\ttype: \"boolean\" | \"string\";\n\t/** Current effective value. */\n\tvalue: boolean | string;\n}\n\ninterface ToolGroupInfo {\n\t/** Group identifier (e.g. \"web\", \"embsearch\"). */\n\tid: string;\n\tlabel: string;\n\tdescription: string;\n\t/** Whether the group is currently enabled (its tools are available). */\n\tenabled: boolean;\n}\n\nexport interface SettingsConfig {\n\tautoCompact: boolean;\n\ttools: ToolToggleInfo[];\n\ttoolGroups: ToolGroupInfo[];\n\tflags: FlagInfo[];\n\ttoolOutputDisplay: \"collapsed\" | \"peek\" | \"standard\";\n\ttoolOutputMaxBytes: number;\n\ttoolOutputMaxLines: number;\n\tcontextGc: boolean;\n\tshowImages: boolean;\n\timageWidthCells: number;\n\tautoResizeImages: boolean;\n\tblockImages: boolean;\n\tenableSkillCommands: boolean;\n\tpluginInstallScope: \"user\" | \"project\";\n\tenablePluginTools: boolean;\n\t/**\n\t * settings.json keys the project file sets. A pane row writes user scope, so\n\t * anything listed here wins again on the next session however the row is set.\n\t */\n\tprojectPinnedSettings: string[];\n\t/** Platform layouts in force this session (empty = unset, per-consumer defaults apply). */\n\tplatform: MarketplacePlatform[];\n\tsteeringMode: \"all\" | \"one-at-a-time\";\n\tfollowUpMode: \"all\" | \"one-at-a-time\";\n\ttransport: Transport;\n\tthinkingLevel: ThinkingLevel;\n\tavailableThinkingLevels: ThinkingLevel[];\n\tcurrentTheme: string;\n\tavailableThemes: string[];\n\thideThinkingBlock: boolean;\n\tcollapseChangelog: boolean;\n\tenableInstallTelemetry: boolean;\n\tdoubleEscapeAction: \"fork\" | \"tree\" | \"none\";\n\ttreeFilterMode: \"default\" | \"no-tools\" | \"user-only\" | \"labeled-only\" | \"all\";\n\tshowHardwareCursor: boolean;\n\teditorBorder: \"rule\" | \"box\";\n\teditorPaddingX: number;\n\tautocompleteMaxVisible: number;\n\tquietStartup: boolean;\n\tclearOnShrink: boolean;\n\tshowTerminalProgress: boolean;\n\twarnings: WarningSettings;\n\tvoiceSilenceMs: number;\n\twebtoolsTimeoutSecs: number;\n\tlearn: Record<LearnSettingKey, number>;\n}\n\nexport interface SettingsCallbacks {\n\tonAutoCompactChange: (enabled: boolean) => void;\n\tonToolEnabledChange: (name: string, enabled: boolean) => void;\n\tonToolGroupChange: (id: string, enabled: boolean) => void;\n\tonToolOutputDisplayChange: (level: \"collapsed\" | \"peek\" | \"standard\") => void;\n\tonToolOutputMaxBytesChange: (bytes: number) => void;\n\tonToolOutputMaxLinesChange: (lines: number) => void;\n\tonContextGcChange: (enabled: boolean) => void;\n\tonFlagChange: (name: string, value: boolean | string) => void;\n\tonShowImagesChange: (enabled: boolean) => void;\n\tonImageWidthCellsChange: (width: number) => void;\n\tonAutoResizeImagesChange: (enabled: boolean) => void;\n\tonBlockImagesChange: (blocked: boolean) => void;\n\tonEnableSkillCommandsChange: (enabled: boolean) => void;\n\tonPluginInstallScopeChange: (scope: \"user\" | \"project\") => void;\n\tonEnablePluginToolsChange: (enabled: boolean) => void;\n\tonPlatformChange: (platforms: MarketplacePlatform[]) => void;\n\tonSteeringModeChange: (mode: \"all\" | \"one-at-a-time\") => void;\n\tonFollowUpModeChange: (mode: \"all\" | \"one-at-a-time\") => void;\n\tonTransportChange: (transport: Transport) => void;\n\tonThinkingLevelChange: (level: ThinkingLevel) => void;\n\tonThemeChange: (theme: string) => void;\n\tonThemePreview?: (theme: string) => void;\n\tonHideThinkingBlockChange: (hidden: boolean) => void;\n\tonCollapseChangelogChange: (collapsed: boolean) => void;\n\tonEnableInstallTelemetryChange: (enabled: boolean) => void;\n\tonDoubleEscapeActionChange: (action: \"fork\" | \"tree\" | \"none\") => void;\n\tonTreeFilterModeChange: (mode: \"default\" | \"no-tools\" | \"user-only\" | \"labeled-only\" | \"all\") => void;\n\tonShowHardwareCursorChange: (enabled: boolean) => void;\n\tonEditorBorderChange: (border: \"rule\" | \"box\") => void;\n\tonEditorPaddingXChange: (padding: number) => void;\n\tonAutocompleteMaxVisibleChange: (maxVisible: number) => void;\n\tonQuietStartupChange: (enabled: boolean) => void;\n\tonClearOnShrinkChange: (enabled: boolean) => void;\n\tonShowTerminalProgressChange: (enabled: boolean) => void;\n\tonWarningsChange: (warnings: WarningSettings) => void;\n\tonVoiceSilenceMsChange: (ms: number) => void;\n\tonWebtoolsTimeoutSecsChange: (secs: number) => void;\n\tonLearnSettingChange: (key: LearnSettingKey, value: number) => void;\n\tonCancel: () => void;\n}\n\n/**\n * The `/learn` thresholds as pane rows: the presets to cycle through, and what\n * each one buys. Kept as a table because all five are the same shape — a\n * positive integer with a handful of sensible values — and the pane, the change\n * handler and the category row all read from it rather than repeating the list.\n */\nconst LEARN_SETTINGS: ReadonlyArray<{\n\tkey: LearnSettingKey;\n\tlabel: string;\n\tdescription: string;\n\tpresets: number[];\n}> = [\n\t{\n\t\tkey: \"learnMaxSessions\",\n\t\tlabel: \"Sessions scanned\",\n\t\tdescription: \"How many recent sessions in this directory /learn mines. Raise it on a repo you touch rarely.\",\n\t\tpresets: [10, 20, 30, 50, 100],\n\t},\n\t{\n\t\tkey: \"learnMaxAgeDays\",\n\t\tlabel: \"Session age limit\",\n\t\tdescription: \"Ignore sessions older than this many days. A pattern that stopped is not a rule.\",\n\t\tpresets: [7, 14, 30, 60, 90, 180],\n\t},\n\t{\n\t\tkey: \"learnMinRepeats\",\n\t\tlabel: \"Directive repeats\",\n\t\tdescription:\n\t\t\t\"Times a directive must recur before it is proposed. The signal/noise dial: raise it for fewer, better-evidenced proposals.\",\n\t\tpresets: [2, 3, 4, 5],\n\t},\n\t{\n\t\tkey: \"learnMinRequestRepeats\",\n\t\tlabel: \"Workflow repeats\",\n\t\tdescription: \"Non-overlapping repeats a tool sequence needs before it is proposed as a skill.\",\n\t\tpresets: [2, 3, 4, 5, 6],\n\t},\n\t{\n\t\tkey: \"learnMaxProposals\",\n\t\tlabel: \"Max proposals\",\n\t\tdescription: \"Cap on each list in the digest. Every proposal costs the model context.\",\n\t\tpresets: [3, 5, 8, 12, 20],\n\t},\n];\n\nconst LEARN_KEYS: ReadonlySet<string> = new Set(LEARN_SETTINGS.map((setting) => setting.key));\n\n/**\n * Preset list for a numeric row, guaranteed to contain the value in force.\n *\n * Without this a value set by hand in settings.json — say 45 days — is absent\n * from the cycle, so the first keypress silently snaps it to the first preset,\n * discarding a deliberate choice the pane never showed as unusual. Every numeric\n * cycle row goes through this for that reason.\n */\nfunction presetValues(presets: number[], current: number): string[] {\n\tconst all = presets.includes(current) ? presets : [...presets, current].sort((a, b) => a - b);\n\treturn all.map(String);\n}\n\n/**\n * A submenu component for selecting from a list of options.\n */\nclass WarningSettingsSubmenu extends Container {\n\tprivate settingsList: SettingsList;\n\tprivate state: WarningSettings;\n\n\tconstructor(warnings: WarningSettings, onChange: (warnings: WarningSettings) => void, onCancel: () => void) {\n\t\tsuper();\n\n\t\tthis.state = { ...warnings };\n\n\t\tconst items: SettingItem[] = [\n\t\t\t{\n\t\t\t\tid: \"anthropic-extra-usage\",\n\t\t\t\tlabel: \"Anthropic extra usage\",\n\t\t\t\tdescription: \"Warn when Anthropic subscription auth may use paid extra usage\",\n\t\t\t\tcurrentValue: (this.state.anthropicExtraUsage ?? true) ? \"true\" : \"false\",\n\t\t\t\tvalues: [\"true\", \"false\"],\n\t\t\t},\n\t\t];\n\n\t\tthis.settingsList = new SettingsList(\n\t\t\titems,\n\t\t\tMath.min(items.length, 10),\n\t\t\tgetSettingsListTheme(),\n\t\t\t(id, newValue) => {\n\t\t\t\tswitch (id) {\n\t\t\t\t\tcase \"anthropic-extra-usage\":\n\t\t\t\t\t\tthis.state = { ...this.state, anthropicExtraUsage: newValue === \"true\" };\n\t\t\t\t\t\tonChange({ ...this.state });\n\t\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t},\n\t\t\tonCancel,\n\t\t);\n\n\t\tthis.addChild(this.settingsList);\n\t}\n\n\thandleInput(data: string): void {\n\t\tthis.settingsList.handleInput(data);\n\t}\n}\n\n/**\n * The artifact platform targets, in the order the pane shows them. Each row is an\n * independent on/off toggle because `--platform` (and the `platform` setting it\n * mirrors) takes a list: emitting for two platforms at once is a supported shape.\n * The tokens here are the canonical ones — the CLI aliases (`copilot`, `gh`,\n * `native`) fold into these before anything reads them.\n */\nconst PLATFORM_ROWS: ReadonlyArray<{\n\tplatform: MarketplacePlatform;\n\tlabel: string;\n\tdescription: string;\n}> = [\n\t{\n\t\tplatform: \"claude\",\n\t\tlabel: \"claude\",\n\t\tdescription:\n\t\t\t\"Claude Code layout: .claude/ scaffolds, and authored plugins drop into ~/.claude/skills/<id>/. The default when nothing is set.\",\n\t},\n\t{\n\t\tplatform: \"github\",\n\t\tlabel: \"github (copilot, gh)\",\n\t\tdescription:\n\t\t\t\"Copilot layout: .github/ scaffolds, and authored plugins are produced under ~/.agents/publish/github/<id>/.\",\n\t},\n\t{\n\t\tplatform: \"agents\",\n\t\tlabel: \"agents (native)\",\n\t\tdescription:\n\t\t\t\"Cross-vendor .agents/ layout. Scaffolds only - a plugin belongs to no marketplace in this layout, so plugin authoring ignores it.\",\n\t},\n];\n\n/** Row value for the platform setting: the selection, or the fallback when it is empty. */\nfunction platformSummary(platforms: readonly MarketplacePlatform[]): string {\n\treturn platforms.length > 0 ? platforms.join(\", \") : \"default (claude)\";\n}\n\n/**\n * Submenu for the session's artifact platform targets (the `platform` setting,\n * same knob as `--platform`).\n *\n * A list rather than a cycle: the setting is a list, and the three tokens are not\n * mutually exclusive. Turning everything off is legal and means \"unset\" — the\n * per-consumer defaults come back (claude for plugins, .hoocode/ for scaffolds).\n */\nclass PlatformSubmenu extends Container {\n\tprivate settingsList: SettingsList;\n\tprivate selected: Set<MarketplacePlatform>;\n\n\tconstructor(\n\t\tplatforms: readonly MarketplacePlatform[],\n\t\tonChange: (platforms: MarketplacePlatform[]) => void,\n\t\tonDone: (summary: string) => void,\n\t) {\n\t\tsuper();\n\n\t\tthis.selected = new Set(platforms);\n\n\t\tconst items: SettingItem[] = PLATFORM_ROWS.map(({ platform, label, description }) => ({\n\t\t\tid: platform,\n\t\t\tlabel,\n\t\t\tdescription,\n\t\t\tcurrentValue: this.selected.has(platform) ? \"on\" : \"off\",\n\t\t\tvalues: [\"on\", \"off\"],\n\t\t}));\n\n\t\tthis.settingsList = new SettingsList(\n\t\t\titems,\n\t\t\tMath.min(items.length, 10),\n\t\t\tgetSettingsListTheme(),\n\t\t\t(id, newValue) => {\n\t\t\t\tconst platform = id as MarketplacePlatform;\n\t\t\t\tif (newValue === \"on\") this.selected.add(platform);\n\t\t\t\telse this.selected.delete(platform);\n\t\t\t\tonChange(this.ordered());\n\t\t\t},\n\t\t\t() => onDone(platformSummary(this.ordered())),\n\t\t);\n\n\t\tthis.addChild(this.settingsList);\n\t}\n\n\t/** Selection in the pane's order, so the persisted list does not depend on click order. */\n\tprivate ordered(): MarketplacePlatform[] {\n\t\treturn PLATFORM_ROWS.map((row) => row.platform).filter((platform) => this.selected.has(platform));\n\t}\n\n\thandleInput(data: string): void {\n\t\tthis.settingsList.handleInput(data);\n\t}\n}\n\n/**\n * Submenu for tool availability. The first rows are group switches (web,\n * semantic search) that decide whether a group's tools\n * exist at all — this is the same master switch that governs, e.g., the\n * webfetch/websearch tools. Below them are per-tool on/off toggles for the\n * tools that are currently available.\n *\n * Group switches change tool availability and apply on the next session;\n * per-tool toggles apply live and persist. A minimum core (read/bash/edit/\n * write) is guarded so the agent can never be left with no way to act.\n */\nclass ToolsSubmenu extends Container {\n\tprivate settingsList: SettingsList;\n\tprivate enabled: Map<string, boolean>;\n\tprivate static readonly CORE = new Set([\"read\", \"bash\", \"edit\", \"write\"]);\n\tprivate static readonly GROUP_PREFIX = \"group:\";\n\n\tconstructor(\n\t\ttools: ToolToggleInfo[],\n\t\tgroups: ToolGroupInfo[],\n\t\tonChange: (name: string, enabled: boolean) => void,\n\t\tonGroupChange: (id: string, enabled: boolean) => void,\n\t\tonCancel: () => void,\n\t) {\n\t\tsuper();\n\n\t\tthis.enabled = new Map(tools.map((t) => [t.name, t.enabled]));\n\n\t\tconst groupItems: SettingItem[] = groups.map((group) => ({\n\t\t\tid: `${ToolsSubmenu.GROUP_PREFIX}${group.id}`,\n\t\t\tlabel: `[group] ${group.label}`,\n\t\t\tdescription: `${group.description} Governs whether these tools exist; applies on the next session.`,\n\t\t\tcurrentValue: group.enabled ? \"on\" : \"off\",\n\t\t\tvalues: [\"on\", \"off\"],\n\t\t}));\n\n\t\tconst toolItems: SettingItem[] = tools.map((tool) => ({\n\t\t\tid: tool.name,\n\t\t\tlabel: tool.name,\n\t\t\tdescription: ToolsSubmenu.CORE.has(tool.name)\n\t\t\t\t? \"Core tool. Disabling leaves the agent unable to perform this action in every session.\"\n\t\t\t\t: \"Disable to remove this tool from the agent this session and every future session.\",\n\t\t\tcurrentValue: tool.enabled ? \"on\" : \"off\",\n\t\t\tvalues: [\"on\", \"off\"],\n\t\t}));\n\n\t\tconst items = [...groupItems, ...toolItems];\n\n\t\tthis.settingsList = new SettingsList(\n\t\t\titems,\n\t\t\tMath.min(items.length, 12),\n\t\t\tgetSettingsListTheme(),\n\t\t\t(id, newValue) => {\n\t\t\t\tconst wantEnabled = newValue === \"on\";\n\t\t\t\tif (id.startsWith(ToolsSubmenu.GROUP_PREFIX)) {\n\t\t\t\t\tonGroupChange(id.slice(ToolsSubmenu.GROUP_PREFIX.length), wantEnabled);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\t// Guard: never let the last core tool be turned off.\n\t\t\t\tif (!wantEnabled && ToolsSubmenu.CORE.has(id)) {\n\t\t\t\t\tconst remainingCore = [...ToolsSubmenu.CORE].filter((n) => n !== id && this.enabled.get(n));\n\t\t\t\t\tif (remainingCore.length === 0) {\n\t\t\t\t\t\tthis.settingsList.updateValue(id, \"on\");\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tthis.enabled.set(id, wantEnabled);\n\t\t\t\tonChange(id, wantEnabled);\n\t\t\t},\n\t\t\tonCancel,\n\t\t\t{ enableSearch: true },\n\t\t);\n\n\t\tthis.addChild(this.settingsList);\n\t}\n\n\thandleInput(data: string): void {\n\t\tthis.settingsList.handleInput(data);\n\t}\n}\n\n/** Byte-cap presets shown as human labels; mapped back to raw byte counts. */\nconst TOOL_OUTPUT_BYTE_PRESETS: ReadonlyArray<[label: string, bytes: number]> = [\n\t[\"8 KB\", 8 * 1024],\n\t[\"16 KB\", 16 * 1024],\n\t[\"32 KB\", 32 * 1024],\n\t[\"64 KB\", 64 * 1024],\n\t[\"128 KB\", 128 * 1024],\n];\n\nfunction bytesToLabel(bytes: number): string {\n\tconst match = TOOL_OUTPUT_BYTE_PRESETS.find(([, b]) => b === bytes);\n\treturn match ? match[0] : `${Math.round(bytes / 1024)} KB`;\n}\n\n/** Byte-cap labels to cycle through, including a hand-set cap that matches no preset. */\nfunction byteLabels(current: number): string[] {\n\tconst all: Array<[string, number]> = TOOL_OUTPUT_BYTE_PRESETS.some(([, bytes]) => bytes === current)\n\t\t? [...TOOL_OUTPUT_BYTE_PRESETS]\n\t\t: [...TOOL_OUTPUT_BYTE_PRESETS, [bytesToLabel(current), current]];\n\treturn all.sort((a, b) => a[1] - b[1]).map(([label]) => label);\n}\n\ninterface ToolSettingsConfig {\n\ttoolOutputMaxBytes: number;\n\ttoolOutputMaxLines: number;\n\tcontextGc: boolean;\n}\n\ninterface ToolSettingsCallbacks {\n\tonToolOutputMaxBytesChange: (bytes: number) => void;\n\tonToolOutputMaxLinesChange: (lines: number) => void;\n\tonContextGcChange: (enabled: boolean) => void;\n}\n\n/**\n * Submenu for per-tool runtime settings. These feed the tool runtime the next\n * time it is built (next session / rebuild), so changes apply to future tool\n * calls rather than retroactively.\n */\nclass ToolSettingsSubmenu extends Container {\n\tprivate settingsList: SettingsList;\n\n\tconstructor(config: ToolSettingsConfig, callbacks: ToolSettingsCallbacks, onCancel: () => void) {\n\t\tsuper();\n\n\t\tconst items: SettingItem[] = [\n\t\t\t{\n\t\t\t\tid: \"output-max-bytes\",\n\t\t\t\tlabel: \"Output max bytes\",\n\t\t\t\tdescription: \"Byte cap on a single read/bash result before truncation. Applies to future tool calls.\",\n\t\t\t\tcurrentValue: bytesToLabel(config.toolOutputMaxBytes),\n\t\t\t\tvalues: byteLabels(config.toolOutputMaxBytes),\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: \"output-max-lines\",\n\t\t\t\tlabel: \"Output max lines\",\n\t\t\t\tdescription: \"Line cap on a single read/bash result before truncation. Applies to future tool calls.\",\n\t\t\t\tcurrentValue: String(config.toolOutputMaxLines),\n\t\t\t\tvalues: presetValues([200, 400, 800, 1600, 3200], config.toolOutputMaxLines),\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: \"context-gc\",\n\t\t\t\tlabel: \"Context GC\",\n\t\t\t\tdescription: \"Stub superseded read results (files later edited/re-read) out of the outgoing context.\",\n\t\t\t\tcurrentValue: config.contextGc ? \"true\" : \"false\",\n\t\t\t\tvalues: [\"true\", \"false\"],\n\t\t\t},\n\t\t];\n\n\t\tthis.settingsList = new SettingsList(\n\t\t\titems,\n\t\t\tMath.min(items.length, 10),\n\t\t\tgetSettingsListTheme(),\n\t\t\t(id, newValue) => {\n\t\t\t\tswitch (id) {\n\t\t\t\t\tcase \"output-max-bytes\": {\n\t\t\t\t\t\tconst preset = TOOL_OUTPUT_BYTE_PRESETS.find(([label]) => label === newValue);\n\t\t\t\t\t\t// A hand-set cap has no preset entry; its label is \"<n> KB\" by\n\t\t\t\t\t\t// construction, so read the number back out of it.\n\t\t\t\t\t\tconst bytes = preset ? preset[1] : Math.round(parseFloat(newValue) * 1024);\n\t\t\t\t\t\tif (Number.isFinite(bytes) && bytes > 0) callbacks.onToolOutputMaxBytesChange(bytes);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\tcase \"output-max-lines\":\n\t\t\t\t\t\tcallbacks.onToolOutputMaxLinesChange(parseInt(newValue, 10));\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"context-gc\":\n\t\t\t\t\t\tcallbacks.onContextGcChange(newValue === \"true\");\n\t\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t},\n\t\t\tonCancel,\n\t\t);\n\n\t\tthis.addChild(this.settingsList);\n\t}\n\n\thandleInput(data: string): void {\n\t\tthis.settingsList.handleInput(data);\n\t}\n}\n\n/** Single-line text editor for a string flag value. */\nclass FlagStringEditSubmenu extends Container {\n\tprivate input: Input;\n\n\tconstructor(flagName: string, currentValue: string, done: (value?: string) => void) {\n\t\tsuper();\n\n\t\tthis.addChild(new Text(theme.bold(theme.fg(\"accent\", `Flag: --${flagName}`)), 0, 0));\n\t\tthis.addChild(new Spacer(1));\n\t\tthis.addChild(new Text(theme.fg(\"muted\", \"Enter a value · Enter to save · Esc to cancel\"), 0, 0));\n\t\tthis.addChild(new Spacer(1));\n\n\t\tthis.input = new Input();\n\t\tthis.input.setValue(currentValue);\n\t\tthis.input.onSubmit = (value: string) => done(value);\n\t\tthis.input.onEscape = () => done();\n\t\tthis.addChild(this.input);\n\t}\n\n\thandleInput(data: string): void {\n\t\tthis.input.handleInput(data);\n\t}\n}\n\n/**\n * Submenu listing extension-registered flags. Boolean flags toggle on/off;\n * string flags open a text editor. Changes persist to settings.json and are\n * applied live best-effort — extensions that read a flag only at load time\n * pick up the new value on the next launch.\n */\nclass FlagsSubmenu extends Container {\n\tprivate settingsList: SettingsList;\n\n\tconstructor(flags: FlagInfo[], onChange: (name: string, value: boolean | string) => void, onCancel: () => void) {\n\t\tsuper();\n\n\t\tconst items: SettingItem[] = flags.map((flag) => {\n\t\t\tconst baseDescription = flag.description ?? \"Extension-registered flag.\";\n\t\t\tconst description = `${baseDescription} Persists across sessions; some flags need a restart to fully apply.`;\n\t\t\tif (flag.type === \"boolean\") {\n\t\t\t\treturn {\n\t\t\t\t\tid: flag.name,\n\t\t\t\t\tlabel: flag.name,\n\t\t\t\t\tdescription,\n\t\t\t\t\tcurrentValue: flag.value ? \"on\" : \"off\",\n\t\t\t\t\tvalues: [\"on\", \"off\"],\n\t\t\t\t};\n\t\t\t}\n\t\t\treturn {\n\t\t\t\tid: flag.name,\n\t\t\t\tlabel: flag.name,\n\t\t\t\tdescription,\n\t\t\t\tcurrentValue: String(flag.value ?? \"\"),\n\t\t\t\tsubmenu: (currentValue, done) => new FlagStringEditSubmenu(flag.name, currentValue, done),\n\t\t\t};\n\t\t});\n\n\t\tconst typeByName = new Map(flags.map((f) => [f.name, f.type]));\n\n\t\tthis.settingsList = new SettingsList(\n\t\t\titems,\n\t\t\tMath.min(items.length, 12),\n\t\t\tgetSettingsListTheme(),\n\t\t\t(id, newValue) => {\n\t\t\t\tif (typeByName.get(id) === \"boolean\") {\n\t\t\t\t\tonChange(id, newValue === \"on\");\n\t\t\t\t} else {\n\t\t\t\t\tonChange(id, newValue);\n\t\t\t\t}\n\t\t\t},\n\t\t\tonCancel,\n\t\t\t{ enableSearch: true },\n\t\t);\n\n\t\tthis.addChild(this.settingsList);\n\t}\n\n\thandleInput(data: string): void {\n\t\tthis.settingsList.handleInput(data);\n\t}\n}\n\n/**\n * Generic submenu holding a subset of leaf settings under a category label.\n * Shares the parent's change handler so cycle rows behave exactly as they did\n * when flat; nested submenu rows (theme, thinking, warnings) keep their own\n * factories.\n */\nclass CategorySubmenu extends Container {\n\tprivate settingsList: SettingsList;\n\n\tconstructor(items: SettingItem[], onChange: (id: string, newValue: string) => void, onCancel: () => void) {\n\t\tsuper();\n\t\tthis.settingsList = new SettingsList(\n\t\t\titems,\n\t\t\tMath.min(items.length, 10),\n\t\t\tgetSettingsListTheme(),\n\t\t\tonChange,\n\t\t\tonCancel,\n\t\t\t{\n\t\t\t\tenableSearch: true,\n\t\t\t},\n\t\t);\n\t\tthis.addChild(this.settingsList);\n\t}\n\n\thandleInput(data: string): void {\n\t\tthis.settingsList.handleInput(data);\n\t}\n}\n\nclass SelectSubmenu extends Container {\n\tprivate selectList: SelectList;\n\n\tconstructor(\n\t\ttitle: string,\n\t\tdescription: string,\n\t\toptions: SelectItem[],\n\t\tcurrentValue: string,\n\t\tonSelect: (value: string) => void,\n\t\tonCancel: () => void,\n\t\tonSelectionChange?: (value: string) => void,\n\t) {\n\t\tsuper();\n\n\t\t// Title\n\t\tthis.addChild(new Text(theme.bold(theme.fg(\"accent\", title)), 0, 0));\n\n\t\t// Description\n\t\tif (description) {\n\t\t\tthis.addChild(new Spacer(1));\n\t\t\tthis.addChild(new Text(theme.fg(\"muted\", description), 0, 0));\n\t\t}\n\n\t\t// Spacer\n\t\tthis.addChild(new Spacer(1));\n\n\t\t// Select list\n\t\tthis.selectList = new SelectList(\n\t\t\toptions,\n\t\t\tMath.min(options.length, 10),\n\t\t\tgetSelectListTheme(),\n\t\t\tSETTINGS_SUBMENU_SELECT_LIST_LAYOUT,\n\t\t);\n\n\t\t// Pre-select current value\n\t\tconst currentIndex = options.findIndex((o) => o.value === currentValue);\n\t\tif (currentIndex !== -1) {\n\t\t\tthis.selectList.setSelectedIndex(currentIndex);\n\t\t}\n\n\t\tthis.selectList.onSelect = (item) => {\n\t\t\tonSelect(item.value);\n\t\t};\n\n\t\tthis.selectList.onCancel = onCancel;\n\n\t\tif (onSelectionChange) {\n\t\t\tthis.selectList.onSelectionChange = (item) => {\n\t\t\t\tonSelectionChange(item.value);\n\t\t\t};\n\t\t}\n\n\t\tthis.addChild(this.selectList);\n\n\t\t// Hint\n\t\tthis.addChild(new Spacer(1));\n\t\tthis.addChild(new Text(theme.fg(\"dim\", \" Enter to select · Esc to go back\"), 0, 0));\n\t}\n\n\thandleInput(data: string): void {\n\t\tthis.selectList.handleInput(data);\n\t}\n}\n\n/**\n * Main settings selector component.\n */\nexport class SettingsSelectorComponent extends Container {\n\tprivate settingsList: SettingsList;\n\n\tconstructor(config: SettingsConfig, callbacks: SettingsCallbacks) {\n\t\tsuper();\n\n\t\tconst supportsImages = getCapabilities().images;\n\t\tconst followUpKey = keyDisplayText(\"app.message.followUp\");\n\t\tlet currentWarnings = { ...config.warnings };\n\n\t\t// A row writes the user settings file; a key the project file also sets is\n\t\t// merged over it on the next session, so say so rather than letting the row\n\t\t// look like it took.\n\t\tconst projectPinned = new Set(config.projectPinnedSettings);\n\t\tconst pinnedNote = (key: string): string =>\n\t\t\tprojectPinned.has(key)\n\t\t\t\t? ` This repo's .hoocode/settings.json sets ${key}, which overrides this row from the next session on.`\n\t\t\t\t: \"\";\n\n\t\tconst toolsOn = config.tools.filter((t) => t.enabled).length;\n\t\tconst toolsOff = config.tools.length - toolsOn;\n\n\t\tconst items: SettingItem[] = [\n\t\t\t{\n\t\t\t\tid: \"autocompact\",\n\t\t\t\tlabel: \"Auto-compact\",\n\t\t\t\tdescription: \"Automatically compact context when it gets too large\",\n\t\t\t\tcurrentValue: config.autoCompact ? \"true\" : \"false\",\n\t\t\t\tvalues: [\"true\", \"false\"],\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: \"steering-mode\",\n\t\t\t\tlabel: \"Steering mode\",\n\t\t\t\tdescription:\n\t\t\t\t\t\"Enter while streaming queues steering messages. 'one-at-a-time': deliver one, wait for response. 'all': deliver all at once.\",\n\t\t\t\tcurrentValue: config.steeringMode,\n\t\t\t\tvalues: [\"one-at-a-time\", \"all\"],\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: \"follow-up-mode\",\n\t\t\t\tlabel: \"Follow-up mode\",\n\t\t\t\tdescription: `${followUpKey} queues follow-up messages until agent stops. 'one-at-a-time': deliver one, wait for response. 'all': deliver all at once.`,\n\t\t\t\tcurrentValue: config.followUpMode,\n\t\t\t\tvalues: [\"one-at-a-time\", \"all\"],\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: \"transport\",\n\t\t\t\tlabel: \"Transport\",\n\t\t\t\tdescription: \"Preferred transport for providers that support multiple transports\",\n\t\t\t\tcurrentValue: config.transport,\n\t\t\t\tvalues: [\"sse\", \"websocket\", \"websocket-cached\", \"auto\"],\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: \"hide-thinking\",\n\t\t\t\tlabel: \"Hide thinking\",\n\t\t\t\tdescription: \"Hide thinking blocks in assistant responses\",\n\t\t\t\tcurrentValue: config.hideThinkingBlock ? \"true\" : \"false\",\n\t\t\t\tvalues: [\"true\", \"false\"],\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: \"collapse-changelog\",\n\t\t\t\tlabel: \"Collapse changelog\",\n\t\t\t\tdescription: \"Show condensed changelog after updates\",\n\t\t\t\tcurrentValue: config.collapseChangelog ? \"true\" : \"false\",\n\t\t\t\tvalues: [\"true\", \"false\"],\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: \"quiet-startup\",\n\t\t\t\tlabel: \"Quiet startup\",\n\t\t\t\tdescription: \"Disable verbose printing at startup\",\n\t\t\t\tcurrentValue: config.quietStartup ? \"true\" : \"false\",\n\t\t\t\tvalues: [\"true\", \"false\"],\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: \"install-telemetry\",\n\t\t\t\tlabel: \"Install telemetry\",\n\t\t\t\tdescription: \"Send an anonymous version/update ping after changelog-detected updates\",\n\t\t\t\tcurrentValue: config.enableInstallTelemetry ? \"true\" : \"false\",\n\t\t\t\tvalues: [\"true\", \"false\"],\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: \"double-escape-action\",\n\t\t\t\tlabel: \"Double-escape action\",\n\t\t\t\tdescription: \"Action when pressing Escape twice with empty editor\",\n\t\t\t\tcurrentValue: config.doubleEscapeAction,\n\t\t\t\tvalues: [\"tree\", \"fork\", \"none\"],\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: \"tree-filter-mode\",\n\t\t\t\tlabel: \"Tree filter mode\",\n\t\t\t\tdescription: \"Default filter when opening /tree\",\n\t\t\t\tcurrentValue: config.treeFilterMode,\n\t\t\t\tvalues: [\"default\", \"no-tools\", \"user-only\", \"labeled-only\", \"all\"],\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: \"warnings\",\n\t\t\t\tlabel: \"Warnings\",\n\t\t\t\tdescription: \"Enable or disable individual warnings\",\n\t\t\t\tcurrentValue: \"configure\",\n\t\t\t\tsubmenu: (_currentValue, done) =>\n\t\t\t\t\tnew WarningSettingsSubmenu(\n\t\t\t\t\t\tcurrentWarnings,\n\t\t\t\t\t\t(warnings) => {\n\t\t\t\t\t\t\tcurrentWarnings = warnings;\n\t\t\t\t\t\t\tcallbacks.onWarningsChange(warnings);\n\t\t\t\t\t\t},\n\t\t\t\t\t\t() => done(),\n\t\t\t\t\t),\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: \"thinking\",\n\t\t\t\tlabel: \"Thinking level\",\n\t\t\t\tdescription: \"Reasoning depth for thinking-capable models\",\n\t\t\t\tcurrentValue: config.thinkingLevel,\n\t\t\t\tsubmenu: (currentValue, done) =>\n\t\t\t\t\tnew SelectSubmenu(\n\t\t\t\t\t\t\"Thinking Level\",\n\t\t\t\t\t\t\"Select reasoning depth for thinking-capable models\",\n\t\t\t\t\t\tconfig.availableThinkingLevels.map((level) => ({\n\t\t\t\t\t\t\tvalue: level,\n\t\t\t\t\t\t\tlabel: level,\n\t\t\t\t\t\t\tdescription: THINKING_DESCRIPTIONS[level],\n\t\t\t\t\t\t})),\n\t\t\t\t\t\tcurrentValue,\n\t\t\t\t\t\t(value) => {\n\t\t\t\t\t\t\tcallbacks.onThinkingLevelChange(value as ThinkingLevel);\n\t\t\t\t\t\t\tdone(value);\n\t\t\t\t\t\t},\n\t\t\t\t\t\t() => done(),\n\t\t\t\t\t),\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: \"theme\",\n\t\t\t\tlabel: \"Theme\",\n\t\t\t\tdescription: \"Color theme for the interface\",\n\t\t\t\tcurrentValue: config.currentTheme,\n\t\t\t\tsubmenu: (currentValue, done) =>\n\t\t\t\t\tnew SelectSubmenu(\n\t\t\t\t\t\t\"Theme\",\n\t\t\t\t\t\t\"Select color theme\",\n\t\t\t\t\t\tconfig.availableThemes.map((t) => ({\n\t\t\t\t\t\t\tvalue: t,\n\t\t\t\t\t\t\tlabel: t,\n\t\t\t\t\t\t\tdescription: getThemeDescription(t),\n\t\t\t\t\t\t})),\n\t\t\t\t\t\tcurrentValue,\n\t\t\t\t\t\t(value) => {\n\t\t\t\t\t\t\tcallbacks.onThemeChange(value);\n\t\t\t\t\t\t\tdone(value);\n\t\t\t\t\t\t},\n\t\t\t\t\t\t() => {\n\t\t\t\t\t\t\t// Restore original theme on cancel\n\t\t\t\t\t\t\tcallbacks.onThemePreview?.(currentValue);\n\t\t\t\t\t\t\tdone();\n\t\t\t\t\t\t},\n\t\t\t\t\t\t(value) => {\n\t\t\t\t\t\t\t// Preview theme on selection change\n\t\t\t\t\t\t\tcallbacks.onThemePreview?.(value);\n\t\t\t\t\t\t},\n\t\t\t\t\t),\n\t\t\t},\n\t\t];\n\n\t\t// Only show image toggle if terminal supports it\n\t\tif (supportsImages) {\n\t\t\t// Insert after autocompact\n\t\t\titems.splice(1, 0, {\n\t\t\t\tid: \"show-images\",\n\t\t\t\tlabel: \"Show images\",\n\t\t\t\tdescription: \"Render images inline in terminal\",\n\t\t\t\tcurrentValue: config.showImages ? \"true\" : \"false\",\n\t\t\t\tvalues: [\"true\", \"false\"],\n\t\t\t});\n\t\t\titems.splice(2, 0, {\n\t\t\t\tid: \"image-width-cells\",\n\t\t\t\tlabel: \"Image width\",\n\t\t\t\tdescription: \"Preferred inline image width in terminal cells\",\n\t\t\t\tcurrentValue: String(config.imageWidthCells),\n\t\t\t\tvalues: presetValues([60, 80, 120], config.imageWidthCells),\n\t\t\t});\n\t\t}\n\n\t\t// Image auto-resize toggle (always available, affects both attached and read images)\n\t\titems.splice(supportsImages ? 3 : 1, 0, {\n\t\t\tid: \"auto-resize-images\",\n\t\t\tlabel: \"Auto-resize images\",\n\t\t\tdescription: \"Resize large images to 2000x2000 max for better model compatibility\",\n\t\t\tcurrentValue: config.autoResizeImages ? \"true\" : \"false\",\n\t\t\tvalues: [\"true\", \"false\"],\n\t\t});\n\n\t\t// Block images toggle (always available, insert after auto-resize-images)\n\t\tconst autoResizeIndex = items.findIndex((item) => item.id === \"auto-resize-images\");\n\t\titems.splice(autoResizeIndex + 1, 0, {\n\t\t\tid: \"block-images\",\n\t\t\tlabel: \"Block images\",\n\t\t\tdescription: \"Prevent images from being sent to LLM providers\",\n\t\t\tcurrentValue: config.blockImages ? \"true\" : \"false\",\n\t\t\tvalues: [\"true\", \"false\"],\n\t\t});\n\n\t\t// Skill commands toggle (insert after block-images)\n\t\tconst blockImagesIndex = items.findIndex((item) => item.id === \"block-images\");\n\t\titems.splice(blockImagesIndex + 1, 0, {\n\t\t\tid: \"skill-commands\",\n\t\t\tlabel: \"Skill commands\",\n\t\t\tdescription: \"Register skills as /skill:name commands\",\n\t\t\tcurrentValue: config.enableSkillCommands ? \"true\" : \"false\",\n\t\t\tvalues: [\"true\", \"false\"],\n\t\t});\n\n\t\t// The autonomous plugin system's master switch (insert after skill-commands).\n\t\t// One flag for the lifecycle tools and the reuse nudge, so both flip together.\n\t\tconst skillCommandsIdx = items.findIndex((item) => item.id === \"skill-commands\");\n\t\titems.splice(skillCommandsIdx + 1, 0, {\n\t\t\tid: \"plugin-tools\",\n\t\t\tlabel: \"Plugin system\",\n\t\t\tdescription: `Autonomous plugin system: the lifecycle tools (SearchPlugins, InstallPlugin, ...), ProposePlugin, and the plugin-reuse nudge. Tools arrive on the next session; the nudge follows at once.${pinnedNote(\"enablePluginTools\")}`,\n\t\t\tcurrentValue: config.enablePluginTools ? \"true\" : \"false\",\n\t\t\tvalues: [\"true\", \"false\"],\n\t\t});\n\n\t\t// Plugin install scope (insert after the master switch). Governs the\n\t\t// autonomous InstallPlugin only — /plugin install asks per install.\n\t\tconst pluginToolsIdx = items.findIndex((item) => item.id === \"plugin-tools\");\n\t\titems.splice(pluginToolsIdx + 1, 0, {\n\t\t\tid: \"plugin-install-scope\",\n\t\t\tlabel: \"Plugin install scope\",\n\t\t\tdescription: \"Where autonomous plugin installs go: user (~/.agents) or project (this repo, shared)\",\n\t\t\tcurrentValue: config.pluginInstallScope,\n\t\t\tvalues: [\"user\", \"project\"],\n\t\t});\n\n\t\t// Artifact platform targets (insert after plugin-install-scope). Set once and\n\t\t// it holds for every later session: it is the `platform` setting, which\n\t\t// `--platform` overrides for a single run.\n\t\tconst pluginScopeIdx = items.findIndex((item) => item.id === \"plugin-install-scope\");\n\t\tlet currentPlatforms = [...config.platform];\n\t\titems.splice(pluginScopeIdx + 1, 0, {\n\t\t\tid: \"platform\",\n\t\t\tlabel: \"Platform\",\n\t\t\tdescription: `Vendor layout(s) hoocode writes artifacts in: authored plugins and the /new-skill //new-agent //new-command scaffolds.${pinnedNote(\"platform\")}`,\n\t\t\tcurrentValue: platformSummary(currentPlatforms),\n\t\t\tsubmenu: (_currentValue, done) =>\n\t\t\t\tnew PlatformSubmenu(\n\t\t\t\t\tcurrentPlatforms,\n\t\t\t\t\t(platforms) => {\n\t\t\t\t\t\tcurrentPlatforms = platforms;\n\t\t\t\t\t\tcallbacks.onPlatformChange(platforms);\n\t\t\t\t\t},\n\t\t\t\t\t(summary) => done(summary),\n\t\t\t\t),\n\t\t});\n\n\t\t// Hardware cursor toggle (insert after the platform row)\n\t\tconst platformIndex = items.findIndex((item) => item.id === \"platform\");\n\t\titems.splice(platformIndex + 1, 0, {\n\t\t\tid: \"show-hardware-cursor\",\n\t\t\tlabel: \"Show hardware cursor\",\n\t\t\tdescription: \"Show the terminal cursor while still positioning it for IME support\",\n\t\t\tcurrentValue: config.showHardwareCursor ? \"true\" : \"false\",\n\t\t\tvalues: [\"true\", \"false\"],\n\t\t});\n\n\t\t// Editor border toggle (insert after show-hardware-cursor)\n\t\tconst hardwareCursorIndex = items.findIndex((item) => item.id === \"show-hardware-cursor\");\n\t\titems.splice(hardwareCursorIndex + 1, 0, {\n\t\t\tid: \"editor-border\",\n\t\t\tlabel: \"Editor border\",\n\t\t\tdescription: \"Box draws side borders, rule draws horizontal lines only\",\n\t\t\tcurrentValue: config.editorBorder,\n\t\t\tvalues: [\"box\", \"rule\"],\n\t\t});\n\n\t\t// Editor padding toggle (insert after editor-border)\n\t\tconst editorBorderIndex = items.findIndex((item) => item.id === \"editor-border\");\n\t\titems.splice(editorBorderIndex + 1, 0, {\n\t\t\tid: \"editor-padding\",\n\t\t\tlabel: \"Editor padding\",\n\t\t\tdescription: \"Horizontal padding for input editor (0-3)\",\n\t\t\tcurrentValue: String(config.editorPaddingX),\n\t\t\tvalues: [\"0\", \"1\", \"2\", \"3\"],\n\t\t});\n\n\t\t// Autocomplete max visible toggle (insert after editor-padding)\n\t\tconst editorPaddingIndex = items.findIndex((item) => item.id === \"editor-padding\");\n\t\titems.splice(editorPaddingIndex + 1, 0, {\n\t\t\tid: \"autocomplete-max-visible\",\n\t\t\tlabel: \"Autocomplete max items\",\n\t\t\tdescription: \"Max visible items in autocomplete dropdown (3-20)\",\n\t\t\tcurrentValue: String(config.autocompleteMaxVisible),\n\t\t\tvalues: presetValues([3, 5, 7, 10, 15, 20], config.autocompleteMaxVisible),\n\t\t});\n\n\t\t// Clear on shrink toggle (insert after autocomplete-max-visible)\n\t\tconst autocompleteIndex = items.findIndex((item) => item.id === \"autocomplete-max-visible\");\n\t\titems.splice(autocompleteIndex + 1, 0, {\n\t\t\tid: \"clear-on-shrink\",\n\t\t\tlabel: \"Clear on shrink\",\n\t\t\tdescription: \"Clear empty rows when content shrinks (may cause flicker)\",\n\t\t\tcurrentValue: config.clearOnShrink ? \"true\" : \"false\",\n\t\t\tvalues: [\"true\", \"false\"],\n\t\t});\n\n\t\t// Terminal progress toggle (insert after clear-on-shrink)\n\t\tconst clearOnShrinkIndex = items.findIndex((item) => item.id === \"clear-on-shrink\");\n\t\titems.splice(clearOnShrinkIndex + 1, 0, {\n\t\t\tid: \"terminal-progress\",\n\t\t\tlabel: \"Terminal progress\",\n\t\t\tdescription: \"Show OSC 9;4 progress indicators in the terminal tab bar\",\n\t\t\tcurrentValue: config.showTerminalProgress ? \"true\" : \"false\",\n\t\t\tvalues: [\"true\", \"false\"],\n\t\t});\n\n\t\t// Voice silence window (insert after terminal-progress)\n\t\tconst terminalProgressIndex = items.findIndex((item) => item.id === \"terminal-progress\");\n\t\titems.splice(terminalProgressIndex + 1, 0, {\n\t\t\tid: \"voice-silence-ms\",\n\t\t\tlabel: \"Voice silence window\",\n\t\t\tdescription: \"Trailing-silence (ms) before voice capture auto-stops (300-10000). Env: VOICETOOLS_SILENCE_MS.\",\n\t\t\tcurrentValue: String(config.voiceSilenceMs),\n\t\t\tvalues: presetValues([300, 500, 800, 1200, 2000, 3000, 5000, 8000, 10000], config.voiceSilenceMs),\n\t\t});\n\n\t\t// Webtools request timeout (insert after voice-silence-ms)\n\t\tconst voiceSilenceIndex = items.findIndex((item) => item.id === \"voice-silence-ms\");\n\t\titems.splice(voiceSilenceIndex + 1, 0, {\n\t\t\tid: \"webtools-timeout-secs\",\n\t\t\tlabel: \"Web tools timeout\",\n\t\t\tdescription: \"Per-request timeout (secs) for webfetch/websearch (1-120). Env: HOOCODE_WEBTOOLS_TIMEOUT.\",\n\t\t\tcurrentValue: String(config.webtoolsTimeoutSecs),\n\t\t\tvalues: presetValues([5, 10, 15, 30, 60, 120], config.webtoolsTimeoutSecs),\n\t\t});\n\n\t\t// The /learn thresholds, appended as leaf rows and gathered into their own\n\t\t// category below. They are written to the user settings.json, which /learn\n\t\t// re-reads on every invocation, so a change here applies to the next run.\n\t\tconst webtoolsIndex = items.findIndex((item) => item.id === \"webtools-timeout-secs\");\n\t\titems.splice(\n\t\t\twebtoolsIndex + 1,\n\t\t\t0,\n\t\t\t...LEARN_SETTINGS.map(({ key, label, description, presets }) => ({\n\t\t\t\tid: key,\n\t\t\t\tlabel,\n\t\t\t\tdescription,\n\t\t\t\tcurrentValue: String(config.learn[key]),\n\t\t\t\tvalues: presetValues(presets, config.learn[key]),\n\t\t\t})),\n\t\t);\n\n\t\t// Keep the tool/flag controls together as one block near the top, inserted\n\t\t// after the image/terminal splices above so they aren't leapfrogged.\n\t\tconst toolFlagGroup: SettingItem[] = [\n\t\t\t{\n\t\t\t\tid: \"tools\",\n\t\t\t\tlabel: \"Tools\",\n\t\t\t\tdescription:\n\t\t\t\t\t\"Enable/disable tools and tool groups (web, semantic search). Changes persist across sessions.\",\n\t\t\t\tcurrentValue: toolsOff > 0 ? `${toolsOn} on · ${toolsOff} off` : `${toolsOn} on`,\n\t\t\t\tsubmenu: (_currentValue, done) =>\n\t\t\t\t\tnew ToolsSubmenu(\n\t\t\t\t\t\tconfig.tools,\n\t\t\t\t\t\tconfig.toolGroups,\n\t\t\t\t\t\t(name, enabled) => callbacks.onToolEnabledChange(name, enabled),\n\t\t\t\t\t\t(id, enabled) => callbacks.onToolGroupChange(id, enabled),\n\t\t\t\t\t\t() => done(),\n\t\t\t\t\t),\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: \"tool-output-display\",\n\t\t\t\tlabel: \"Tool output display\",\n\t\t\t\tdescription:\n\t\t\t\t\t\"How tool results render. 'standard': shown (expandable). 'collapsed': hidden. 'peek': hidden with a ▸ reveal caret (press the expand key to reveal).\",\n\t\t\t\tcurrentValue: config.toolOutputDisplay,\n\t\t\t\tvalues: [\"standard\", \"collapsed\", \"peek\"],\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: \"tool-settings\",\n\t\t\t\tlabel: \"Tool settings\",\n\t\t\t\tdescription: \"Per-tool runtime settings: output truncation caps and context garbage collection.\",\n\t\t\t\tcurrentValue: \"configure\",\n\t\t\t\tsubmenu: (_currentValue, done) =>\n\t\t\t\t\tnew ToolSettingsSubmenu(\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\ttoolOutputMaxBytes: config.toolOutputMaxBytes,\n\t\t\t\t\t\t\ttoolOutputMaxLines: config.toolOutputMaxLines,\n\t\t\t\t\t\t\tcontextGc: config.contextGc,\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tonToolOutputMaxBytesChange: callbacks.onToolOutputMaxBytesChange,\n\t\t\t\t\t\t\tonToolOutputMaxLinesChange: callbacks.onToolOutputMaxLinesChange,\n\t\t\t\t\t\t\tonContextGcChange: callbacks.onContextGcChange,\n\t\t\t\t\t\t},\n\t\t\t\t\t\t() => done(),\n\t\t\t\t\t),\n\t\t\t},\n\t\t];\n\t\tif (config.flags.length > 0) {\n\t\t\ttoolFlagGroup.push({\n\t\t\t\tid: \"flags\",\n\t\t\t\tlabel: \"Flags\",\n\t\t\t\tdescription: \"Set flags registered by extensions. Changes persist across sessions.\",\n\t\t\t\tcurrentValue: `${config.flags.length} flag${config.flags.length === 1 ? \"\" : \"s\"}`,\n\t\t\t\tsubmenu: (_currentValue, done) =>\n\t\t\t\t\tnew FlagsSubmenu(\n\t\t\t\t\t\tconfig.flags,\n\t\t\t\t\t\t(name, value) => callbacks.onFlagChange(name, value),\n\t\t\t\t\t\t() => done(),\n\t\t\t\t\t),\n\t\t\t});\n\t\t}\n\t\t// Add borders\n\t\tthis.addChild(new DynamicBorder());\n\n\t\t// Shared change handler for every leaf (cycle) setting; used by the\n\t\t// top-level list and each category submenu.\n\t\tconst applyChange = (id: string, newValue: string): void => {\n\t\t\tswitch (id) {\n\t\t\t\tcase \"autocompact\":\n\t\t\t\t\tcallbacks.onAutoCompactChange(newValue === \"true\");\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"tool-output-display\":\n\t\t\t\t\tcallbacks.onToolOutputDisplayChange(newValue as \"collapsed\" | \"peek\" | \"standard\");\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"show-images\":\n\t\t\t\t\tcallbacks.onShowImagesChange(newValue === \"true\");\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"image-width-cells\":\n\t\t\t\t\tcallbacks.onImageWidthCellsChange(parseInt(newValue, 10));\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"auto-resize-images\":\n\t\t\t\t\tcallbacks.onAutoResizeImagesChange(newValue === \"true\");\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"block-images\":\n\t\t\t\t\tcallbacks.onBlockImagesChange(newValue === \"true\");\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"skill-commands\":\n\t\t\t\t\tcallbacks.onEnableSkillCommandsChange(newValue === \"true\");\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"plugin-tools\":\n\t\t\t\t\tcallbacks.onEnablePluginToolsChange(newValue === \"true\");\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"plugin-install-scope\":\n\t\t\t\t\tcallbacks.onPluginInstallScopeChange(newValue as \"user\" | \"project\");\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"platform\":\n\t\t\t\t\t// Display only. Each toggle inside the submenu already applied itself;\n\t\t\t\t\t// closing it hands back the summary purely to refresh this row's value.\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"steering-mode\":\n\t\t\t\t\tcallbacks.onSteeringModeChange(newValue as \"all\" | \"one-at-a-time\");\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"follow-up-mode\":\n\t\t\t\t\tcallbacks.onFollowUpModeChange(newValue as \"all\" | \"one-at-a-time\");\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"transport\":\n\t\t\t\t\tcallbacks.onTransportChange(newValue as Transport);\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"hide-thinking\":\n\t\t\t\t\tcallbacks.onHideThinkingBlockChange(newValue === \"true\");\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"collapse-changelog\":\n\t\t\t\t\tcallbacks.onCollapseChangelogChange(newValue === \"true\");\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"quiet-startup\":\n\t\t\t\t\tcallbacks.onQuietStartupChange(newValue === \"true\");\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"install-telemetry\":\n\t\t\t\t\tcallbacks.onEnableInstallTelemetryChange(newValue === \"true\");\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"double-escape-action\":\n\t\t\t\t\tcallbacks.onDoubleEscapeActionChange(newValue as \"fork\" | \"tree\" | \"none\");\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"tree-filter-mode\":\n\t\t\t\t\tcallbacks.onTreeFilterModeChange(\n\t\t\t\t\t\tnewValue as \"default\" | \"no-tools\" | \"user-only\" | \"labeled-only\" | \"all\",\n\t\t\t\t\t);\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"show-hardware-cursor\":\n\t\t\t\t\tcallbacks.onShowHardwareCursorChange(newValue === \"true\");\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"editor-border\":\n\t\t\t\t\tcallbacks.onEditorBorderChange(newValue as \"rule\" | \"box\");\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"editor-padding\":\n\t\t\t\t\tcallbacks.onEditorPaddingXChange(parseInt(newValue, 10));\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"autocomplete-max-visible\":\n\t\t\t\t\tcallbacks.onAutocompleteMaxVisibleChange(parseInt(newValue, 10));\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"clear-on-shrink\":\n\t\t\t\t\tcallbacks.onClearOnShrinkChange(newValue === \"true\");\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"terminal-progress\":\n\t\t\t\t\tcallbacks.onShowTerminalProgressChange(newValue === \"true\");\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"voice-silence-ms\":\n\t\t\t\t\tcallbacks.onVoiceSilenceMsChange(parseInt(newValue, 10));\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"webtools-timeout-secs\":\n\t\t\t\t\tcallbacks.onWebtoolsTimeoutSecsChange(parseInt(newValue, 10));\n\t\t\t\t\tbreak;\n\t\t\t\tdefault:\n\t\t\t\t\t// The /learn rows are keyed by their settings.json name, so they need\n\t\t\t\t\t// no case of their own — the id is the key to write.\n\t\t\t\t\tif (LEARN_KEYS.has(id)) callbacks.onLearnSettingChange(id as LearnSettingKey, parseInt(newValue, 10));\n\t\t\t\t\tbreak;\n\t\t\t}\n\t\t};\n\n\t\t// Partition the flat leaf settings into named category submenus so the\n\t\t// top level stays short. `items` holds autocompact + every leaf setting.\n\t\tconst byId = new Map(items.map((item) => [item.id, item] as const));\n\t\tconst pick = (ids: string[]): SettingItem[] =>\n\t\t\tids.map((id) => byId.get(id)).filter((item): item is SettingItem => item !== undefined);\n\t\tconst categoryRow = (id: string, label: string, description: string, ids: string[]): SettingItem => {\n\t\t\tconst members = pick(ids);\n\t\t\treturn {\n\t\t\t\tid,\n\t\t\t\tlabel,\n\t\t\t\tdescription,\n\t\t\t\tcurrentValue: `${members.length} setting${members.length === 1 ? \"\" : \"s\"}`,\n\t\t\t\t// Categories shortened the top level but also hid every setting from\n\t\t\t\t// its search: searching \"theme\" matched no category label. The member\n\t\t\t\t// labels ride along as search text so the query lands on the category\n\t\t\t\t// that holds the setting.\n\t\t\t\tkeywords: members.map((member) => member.label).join(\" \"),\n\t\t\t\tsubmenu: (_currentValue, done) => new CategorySubmenu(members, applyChange, () => done()),\n\t\t\t};\n\t\t};\n\n\t\tconst topItems: SettingItem[] = [\n\t\t\t...(byId.has(\"autocompact\") ? [byId.get(\"autocompact\")!] : []),\n\t\t\t...toolFlagGroup,\n\t\t\tcategoryRow(\n\t\t\t\t\"cat-behavior\",\n\t\t\t\t\"Behavior\",\n\t\t\t\t\"Agent and session behavior: steering, follow-up, thinking, escape, tree filter, transport.\",\n\t\t\t\t[\"steering-mode\", \"follow-up-mode\", \"thinking\", \"double-escape-action\", \"tree-filter-mode\", \"transport\"],\n\t\t\t),\n\t\t\tcategoryRow(\n\t\t\t\t\"cat-interface\",\n\t\t\t\t\"Interface\",\n\t\t\t\t\"Appearance and editor: theme, thinking visibility, cursor, border, padding, autocomplete, terminal.\",\n\t\t\t\t[\n\t\t\t\t\t\"theme\",\n\t\t\t\t\t\"hide-thinking\",\n\t\t\t\t\t\"show-hardware-cursor\",\n\t\t\t\t\t\"editor-border\",\n\t\t\t\t\t\"editor-padding\",\n\t\t\t\t\t\"autocomplete-max-visible\",\n\t\t\t\t\t\"clear-on-shrink\",\n\t\t\t\t\t\"terminal-progress\",\n\t\t\t\t],\n\t\t\t),\n\t\t\t// Artifact production. `plugin-install-scope` had no category and was\n\t\t\t// therefore unreachable from the pane despite having a live callback.\n\t\t\tcategoryRow(\n\t\t\t\t\"cat-plugins\",\n\t\t\t\t\"Plugins\",\n\t\t\t\t\"The autonomous plugin system's master switch, the vendor layout hoocode writes, and where autonomous installs land.\",\n\t\t\t\t[\"plugin-tools\", \"platform\", \"plugin-install-scope\"],\n\t\t\t),\n\t\t\tcategoryRow(\"cat-images\", \"Images\", \"Inline image rendering and resizing.\", [\n\t\t\t\t\"show-images\",\n\t\t\t\t\"image-width-cells\",\n\t\t\t\t\"auto-resize-images\",\n\t\t\t\t\"block-images\",\n\t\t\t]),\n\t\t\t// Top level rather than folded into Advanced: these are the thresholds\n\t\t\t// that decide whether /learn finds anything, and burying them is what\n\t\t\t// made them undiscoverable in the first place.\n\t\t\tcategoryRow(\n\t\t\t\t\"cat-learn\",\n\t\t\t\t\"Learning\",\n\t\t\t\t\"Thresholds /learn mines sessions with: how far back to look, and how often something must repeat.\",\n\t\t\t\tLEARN_SETTINGS.map((setting) => setting.key),\n\t\t\t),\n\t\t\tcategoryRow(\"cat-advanced\", \"Advanced\", \"Startup, telemetry, skills, warnings, voice, and web tools.\", [\n\t\t\t\t\"quiet-startup\",\n\t\t\t\t\"collapse-changelog\",\n\t\t\t\t\"install-telemetry\",\n\t\t\t\t\"skill-commands\",\n\t\t\t\t\"warnings\",\n\t\t\t\t\"voice-silence-ms\",\n\t\t\t\t\"webtools-timeout-secs\",\n\t\t\t]),\n\t\t];\n\n\t\tthis.settingsList = new SettingsList(\n\t\t\ttopItems,\n\t\t\tMath.min(topItems.length, 10),\n\t\t\tgetSettingsListTheme(),\n\t\t\tapplyChange,\n\t\t\tcallbacks.onCancel,\n\t\t\t{\n\t\t\t\tenableSearch: true,\n\t\t\t},\n\t\t);\n\n\t\tthis.addChild(this.settingsList);\n\t\tthis.addChild(new DynamicBorder());\n\t}\n\n\tgetSettingsList(): SettingsList {\n\t\treturn this.settingsList;\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"settings-selector.d.ts","sourceRoot":"","sources":["../../../../src/modes/interactive/components/settings-selector.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC;AACrE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AACzD,OAAO,EACN,SAAS,EAOT,YAAY,EAGZ,MAAM,0BAA0B,CAAC;AAClC,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,mDAAmD,CAAC;AAC7F,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAC5D,OAAO,KAAK,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,mCAAmC,CAAC;AAmB1F,UAAU,cAAc;IACvB,uCAAuC;IACvC,IAAI,EAAE,MAAM,CAAC;IACb,iFAAiF;IACjF,OAAO,EAAE,OAAO,CAAC;IACjB;;;;;OAKG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,UAAU,QAAQ;IACjB,0CAA0C;IAC1C,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,IAAI,EAAE,SAAS,GAAG,QAAQ,CAAC;IAC3B,+BAA+B;IAC/B,KAAK,EAAE,OAAO,GAAG,MAAM,CAAC;CACxB;AAED,UAAU,aAAa;IACtB,kDAAkD;IAClD,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;IACpB,wEAAwE;IACxE,OAAO,EAAE,OAAO,CAAC;CACjB;AAED,MAAM,WAAW,cAAc;IAC9B,WAAW,EAAE,OAAO,CA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E,MAAM,GAAG,KAAK,KAAK,IAAI,CAAC;IACvD,sBAAsB,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;IAClD,8BAA8B,EAAE,CAAC,UAAU,EAAE,MAAM,KAAK,IAAI,CAAC;IAC7D,oBAAoB,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI,CAAC;IACjD,qBAAqB,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI,CAAC;IAClD,4BAA4B,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI,CAAC;IACzD,gBAAgB,EAAE,CAAC,QAAQ,EAAE,eAAe,KAAK,IAAI,CAAC;IACtD,sBAAsB,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;IAC7C,2BAA2B,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IACpD,oBAAoB,EAAE,CAAC,GAAG,EAAE,eAAe,EAAE,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACpE,QAAQ,EAAE,MAAM,IAAI,CAAC;CACrB;AAklBD;;GAEG;AACH,qBAAa,yBAA0B,SAAQ,SAAS;IACvD,OAAO,CAAC,YAAY,CAAe;IACnC,OAAO,CAAC,WAAW,CAAC,CAAO;IAC3B,OAAO,CAAC,mBAAmB,CAAC,CAAsB;IAElD,YAAY,MAAM,EAAE,cAAc,EAAE,SAAS,EAAE,iBAAiB,EA8nB/D;IAED,mFAAmF;IACnF,OAAO,CAAC,mBAAmB;IAK3B,eAAe,IAAI,YAAY,CAE9B;CACD","sourcesContent":["import type { ThinkingLevel } from \"@kolisachint/hoocode-agent-core\";\nimport type { Transport } from \"@kolisachint/hoocode-ai\";\nimport {\n\tContainer,\n\tgetCapabilities,\n\tInput,\n\ttype SelectItem,\n\tSelectList,\n\ttype SelectListLayoutOptions,\n\ttype SettingItem,\n\tSettingsList,\n\tSpacer,\n\tText,\n} from \"@kolisachint/hoocode-tui\";\nimport type { MarketplacePlatform } from \"../../../core/extensions/plugins/formats/types.js\";\nimport type { PromptSurface } from \"../../../core/light.js\";\nimport type { LearnSettingKey, WarningSettings } from \"../../../core/settings-manager.js\";\nimport { getSelectListTheme, getSettingsListTheme, getThemeDescription, theme } from \"../theme/theme.js\";\nimport { DynamicBorder } from \"./dynamic-border.js\";\nimport { keyDisplayText } from \"./keybinding-hints.js\";\n\nconst SETTINGS_SUBMENU_SELECT_LIST_LAYOUT: SelectListLayoutOptions = {\n\tminPrimaryColumnWidth: 12,\n\tmaxPrimaryColumnWidth: 32,\n};\n\nconst THINKING_DESCRIPTIONS: Record<ThinkingLevel, string> = {\n\toff: \"No reasoning\",\n\tminimal: \"Very brief reasoning (~1k tokens)\",\n\tlow: \"Light reasoning (~2k tokens)\",\n\tmedium: \"Moderate reasoning (~8k tokens)\",\n\thigh: \"Deep reasoning (~16k tokens)\",\n\txhigh: \"Maximum reasoning (~32k tokens)\",\n};\n\ninterface ToolToggleInfo {\n\t/** Tool name (e.g. \"read\", \"bash\"). */\n\tname: string;\n\t/** Whether the tool is currently enabled (not in the persisted disabled set). */\n\tenabled: boolean;\n\t/**\n\t * What this tool's serialized schema costs on every request. Priced whether or\n\t * not it is on: for a tool that is off, this is what turning it on will cost.\n\t * Undefined for a tool that was disabled before launch, whose schema this\n\t * session never built.\n\t */\n\ttokens?: number;\n}\n\ninterface FlagInfo {\n\t/** Flag name (without the leading --). */\n\tname: string;\n\tdescription?: string;\n\ttype: \"boolean\" | \"string\";\n\t/** Current effective value. */\n\tvalue: boolean | string;\n}\n\ninterface ToolGroupInfo {\n\t/** Group identifier (e.g. \"web\", \"embsearch\"). */\n\tid: string;\n\tlabel: string;\n\tdescription: string;\n\t/** Whether the group is currently enabled (its tools are available). */\n\tenabled: boolean;\n}\n\nexport interface SettingsConfig {\n\tautoCompact: boolean;\n\ttools: ToolToggleInfo[];\n\ttoolGroups: ToolGroupInfo[];\n\tflags: FlagInfo[];\n\ttoolOutputDisplay: \"collapsed\" | \"peek\" | \"standard\";\n\ttoolOutputMaxBytes: number;\n\ttoolOutputMaxLines: number;\n\tcontextGc: boolean;\n\tshowImages: boolean;\n\timageWidthCells: number;\n\tautoResizeImages: boolean;\n\tblockImages: boolean;\n\tenableSkillCommands: boolean;\n\tlight: boolean;\n\tpluginInstallScope: \"user\" | \"project\";\n\tenablePluginTools: boolean;\n\t/**\n\t * settings.json keys the project file sets. A pane row writes user scope, so\n\t * anything listed here wins again on the next session however the row is set.\n\t */\n\tprojectPinnedSettings: string[];\n\t/** Platform layouts in force this session (empty = unset, per-consumer defaults apply). */\n\tplatform: MarketplacePlatform[];\n\tsteeringMode: \"all\" | \"one-at-a-time\";\n\tfollowUpMode: \"all\" | \"one-at-a-time\";\n\ttransport: Transport;\n\tthinkingLevel: ThinkingLevel;\n\tavailableThinkingLevels: ThinkingLevel[];\n\tcurrentTheme: string;\n\tavailableThemes: string[];\n\thideThinkingBlock: boolean;\n\tcollapseChangelog: boolean;\n\tenableInstallTelemetry: boolean;\n\tdoubleEscapeAction: \"fork\" | \"tree\" | \"none\";\n\ttreeFilterMode: \"default\" | \"no-tools\" | \"user-only\" | \"labeled-only\" | \"all\";\n\tshowHardwareCursor: boolean;\n\teditorBorder: \"rule\" | \"box\";\n\teditorPaddingX: number;\n\tautocompleteMaxVisible: number;\n\tquietStartup: boolean;\n\tclearOnShrink: boolean;\n\tshowTerminalProgress: boolean;\n\twarnings: WarningSettings;\n\tvoiceSilenceMs: number;\n\twebtoolsTimeoutSecs: number;\n\tlearn: Record<LearnSettingKey, number>;\n\t/**\n\t * Re-measure the fixed per-turn surface (system prompt + active tool schemas).\n\t * Called on open and after every change, so a toggle that costs tokens shows\n\t * what it cost. Omitted by callers that have no session to measure.\n\t */\n\tmeasureTokenSurface?: () => PromptSurface;\n}\n\nexport interface SettingsCallbacks {\n\tonAutoCompactChange: (enabled: boolean) => void;\n\tonToolEnabledChange: (name: string, enabled: boolean) => void;\n\tonToolGroupChange: (id: string, enabled: boolean) => void;\n\tonToolOutputDisplayChange: (level: \"collapsed\" | \"peek\" | \"standard\") => void;\n\tonToolOutputMaxBytesChange: (bytes: number) => void;\n\tonToolOutputMaxLinesChange: (lines: number) => void;\n\tonContextGcChange: (enabled: boolean) => void;\n\tonFlagChange: (name: string, value: boolean | string) => void;\n\tonShowImagesChange: (enabled: boolean) => void;\n\tonImageWidthCellsChange: (width: number) => void;\n\tonAutoResizeImagesChange: (enabled: boolean) => void;\n\tonBlockImagesChange: (blocked: boolean) => void;\n\tonEnableSkillCommandsChange: (enabled: boolean) => void;\n\tonLightChange: (enabled: boolean) => void;\n\tonPluginInstallScopeChange: (scope: \"user\" | \"project\") => void;\n\tonEnablePluginToolsChange: (enabled: boolean) => void;\n\tonPlatformChange: (platforms: MarketplacePlatform[]) => void;\n\tonSteeringModeChange: (mode: \"all\" | \"one-at-a-time\") => void;\n\tonFollowUpModeChange: (mode: \"all\" | \"one-at-a-time\") => void;\n\tonTransportChange: (transport: Transport) => void;\n\tonThinkingLevelChange: (level: ThinkingLevel) => void;\n\tonThemeChange: (theme: string) => void;\n\tonThemePreview?: (theme: string) => void;\n\tonHideThinkingBlockChange: (hidden: boolean) => void;\n\tonCollapseChangelogChange: (collapsed: boolean) => void;\n\tonEnableInstallTelemetryChange: (enabled: boolean) => void;\n\tonDoubleEscapeActionChange: (action: \"fork\" | \"tree\" | \"none\") => void;\n\tonTreeFilterModeChange: (mode: \"default\" | \"no-tools\" | \"user-only\" | \"labeled-only\" | \"all\") => void;\n\tonShowHardwareCursorChange: (enabled: boolean) => void;\n\tonEditorBorderChange: (border: \"rule\" | \"box\") => void;\n\tonEditorPaddingXChange: (padding: number) => void;\n\tonAutocompleteMaxVisibleChange: (maxVisible: number) => void;\n\tonQuietStartupChange: (enabled: boolean) => void;\n\tonClearOnShrinkChange: (enabled: boolean) => void;\n\tonShowTerminalProgressChange: (enabled: boolean) => void;\n\tonWarningsChange: (warnings: WarningSettings) => void;\n\tonVoiceSilenceMsChange: (ms: number) => void;\n\tonWebtoolsTimeoutSecsChange: (secs: number) => void;\n\tonLearnSettingChange: (key: LearnSettingKey, value: number) => void;\n\tonCancel: () => void;\n}\n\n/**\n * The `/learn` thresholds as pane rows: the presets to cycle through, and what\n * each one buys. Kept as a table because all five are the same shape — a\n * positive integer with a handful of sensible values — and the pane, the change\n * handler and the category row all read from it rather than repeating the list.\n */\nconst LEARN_SETTINGS: ReadonlyArray<{\n\tkey: LearnSettingKey;\n\tlabel: string;\n\tdescription: string;\n\tpresets: number[];\n}> = [\n\t{\n\t\tkey: \"learnMaxSessions\",\n\t\tlabel: \"Sessions scanned\",\n\t\tdescription: \"How many recent sessions in this directory /learn mines. Raise it on a repo you touch rarely.\",\n\t\tpresets: [10, 20, 30, 50, 100],\n\t},\n\t{\n\t\tkey: \"learnMaxAgeDays\",\n\t\tlabel: \"Session age limit\",\n\t\tdescription: \"Ignore sessions older than this many days. A pattern that stopped is not a rule.\",\n\t\tpresets: [7, 14, 30, 60, 90, 180],\n\t},\n\t{\n\t\tkey: \"learnMinRepeats\",\n\t\tlabel: \"Directive repeats\",\n\t\tdescription:\n\t\t\t\"Times a directive must recur before it is proposed. The signal/noise dial: raise it for fewer, better-evidenced proposals.\",\n\t\tpresets: [2, 3, 4, 5],\n\t},\n\t{\n\t\tkey: \"learnMinRequestRepeats\",\n\t\tlabel: \"Workflow repeats\",\n\t\tdescription: \"Non-overlapping repeats a tool sequence needs before it is proposed as a skill.\",\n\t\tpresets: [2, 3, 4, 5, 6],\n\t},\n\t{\n\t\tkey: \"learnMaxProposals\",\n\t\tlabel: \"Max proposals\",\n\t\tdescription: \"Cap on each list in the digest. Every proposal costs the model context.\",\n\t\tpresets: [3, 5, 8, 12, 20],\n\t},\n];\n\nconst LEARN_KEYS: ReadonlySet<string> = new Set(LEARN_SETTINGS.map((setting) => setting.key));\n\n/**\n * Preset list for a numeric row, guaranteed to contain the value in force.\n *\n * Without this a value set by hand in settings.json — say 45 days — is absent\n * from the cycle, so the first keypress silently snaps it to the first preset,\n * discarding a deliberate choice the pane never showed as unusual. Every numeric\n * cycle row goes through this for that reason.\n */\nfunction presetValues(presets: number[], current: number): string[] {\n\tconst all = presets.includes(current) ? presets : [...presets, current].sort((a, b) => a - b);\n\treturn all.map(String);\n}\n\n/**\n * A submenu component for selecting from a list of options.\n */\nclass WarningSettingsSubmenu extends Container {\n\tprivate settingsList: SettingsList;\n\tprivate state: WarningSettings;\n\n\tconstructor(warnings: WarningSettings, onChange: (warnings: WarningSettings) => void, onCancel: () => void) {\n\t\tsuper();\n\n\t\tthis.state = { ...warnings };\n\n\t\tconst items: SettingItem[] = [\n\t\t\t{\n\t\t\t\tid: \"anthropic-extra-usage\",\n\t\t\t\tlabel: \"Anthropic extra usage\",\n\t\t\t\tdescription: \"Warn when Anthropic subscription auth may use paid extra usage\",\n\t\t\t\tcurrentValue: (this.state.anthropicExtraUsage ?? true) ? \"true\" : \"false\",\n\t\t\t\tvalues: [\"true\", \"false\"],\n\t\t\t},\n\t\t];\n\n\t\tthis.settingsList = new SettingsList(\n\t\t\titems,\n\t\t\tMath.min(items.length, 10),\n\t\t\tgetSettingsListTheme(),\n\t\t\t(id, newValue) => {\n\t\t\t\tswitch (id) {\n\t\t\t\t\tcase \"anthropic-extra-usage\":\n\t\t\t\t\t\tthis.state = { ...this.state, anthropicExtraUsage: newValue === \"true\" };\n\t\t\t\t\t\tonChange({ ...this.state });\n\t\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t},\n\t\t\tonCancel,\n\t\t);\n\n\t\tthis.addChild(this.settingsList);\n\t}\n\n\thandleInput(data: string): void {\n\t\tthis.settingsList.handleInput(data);\n\t}\n}\n\n/**\n * The artifact platform targets, in the order the pane shows them. Each row is an\n * independent on/off toggle because `--platform` (and the `platform` setting it\n * mirrors) takes a list: emitting for two platforms at once is a supported shape.\n * The tokens here are the canonical ones — the CLI aliases (`copilot`, `gh`,\n * `native`) fold into these before anything reads them.\n */\nconst PLATFORM_ROWS: ReadonlyArray<{\n\tplatform: MarketplacePlatform;\n\tlabel: string;\n\tdescription: string;\n}> = [\n\t{\n\t\tplatform: \"claude\",\n\t\tlabel: \"claude\",\n\t\tdescription:\n\t\t\t\"Claude Code layout: .claude/ scaffolds, and authored plugins drop into ~/.claude/skills/<id>/. The default when nothing is set.\",\n\t},\n\t{\n\t\tplatform: \"github\",\n\t\tlabel: \"github (copilot, gh)\",\n\t\tdescription:\n\t\t\t\"Copilot layout: .github/ scaffolds, and authored plugins are produced under ~/.agents/publish/github/<id>/.\",\n\t},\n\t{\n\t\tplatform: \"agents\",\n\t\tlabel: \"agents (native)\",\n\t\tdescription:\n\t\t\t\"Cross-vendor .agents/ layout. Scaffolds only - a plugin belongs to no marketplace in this layout, so plugin authoring ignores it.\",\n\t},\n];\n\n/** Row value for the platform setting: the selection, or the fallback when it is empty. */\nfunction platformSummary(platforms: readonly MarketplacePlatform[]): string {\n\treturn platforms.length > 0 ? platforms.join(\", \") : \"default (claude)\";\n}\n\n/**\n * Submenu for the session's artifact platform targets (the `platform` setting,\n * same knob as `--platform`).\n *\n * A list rather than a cycle: the setting is a list, and the three tokens are not\n * mutually exclusive. Turning everything off is legal and means \"unset\" — the\n * per-consumer defaults come back (claude for plugins, .hoocode/ for scaffolds).\n */\nclass PlatformSubmenu extends Container {\n\tprivate settingsList: SettingsList;\n\tprivate selected: Set<MarketplacePlatform>;\n\n\tconstructor(\n\t\tplatforms: readonly MarketplacePlatform[],\n\t\tonChange: (platforms: MarketplacePlatform[]) => void,\n\t\tonDone: (summary: string) => void,\n\t) {\n\t\tsuper();\n\n\t\tthis.selected = new Set(platforms);\n\n\t\tconst items: SettingItem[] = PLATFORM_ROWS.map(({ platform, label, description }) => ({\n\t\t\tid: platform,\n\t\t\tlabel,\n\t\t\tdescription,\n\t\t\tcurrentValue: this.selected.has(platform) ? \"on\" : \"off\",\n\t\t\tvalues: [\"on\", \"off\"],\n\t\t}));\n\n\t\tthis.settingsList = new SettingsList(\n\t\t\titems,\n\t\t\tMath.min(items.length, 10),\n\t\t\tgetSettingsListTheme(),\n\t\t\t(id, newValue) => {\n\t\t\t\tconst platform = id as MarketplacePlatform;\n\t\t\t\tif (newValue === \"on\") this.selected.add(platform);\n\t\t\t\telse this.selected.delete(platform);\n\t\t\t\tonChange(this.ordered());\n\t\t\t},\n\t\t\t() => onDone(platformSummary(this.ordered())),\n\t\t);\n\n\t\tthis.addChild(this.settingsList);\n\t}\n\n\t/** Selection in the pane's order, so the persisted list does not depend on click order. */\n\tprivate ordered(): MarketplacePlatform[] {\n\t\treturn PLATFORM_ROWS.map((row) => row.platform).filter((platform) => this.selected.has(platform));\n\t}\n\n\thandleInput(data: string): void {\n\t\tthis.settingsList.handleInput(data);\n\t}\n}\n\n/**\n * Submenu for tool availability. The first rows are group switches (web,\n * semantic search) that decide whether a group's tools\n * exist at all — this is the same master switch that governs, e.g., the\n * webfetch/websearch tools. Below them are per-tool on/off toggles for the\n * tools that are currently available.\n *\n * Group switches change tool availability and apply on the next session;\n * per-tool toggles apply live and persist. A minimum core (read/bash/edit/\n * write) is guarded so the agent can never be left with no way to act.\n */\nclass ToolsSubmenu extends Container {\n\tprivate settingsList: SettingsList;\n\tprivate enabled: Map<string, boolean>;\n\tprivate static readonly CORE = new Set([\"read\", \"bash\", \"edit\", \"write\"]);\n\tprivate static readonly GROUP_PREFIX = \"group:\";\n\n\tconstructor(\n\t\ttools: ToolToggleInfo[],\n\t\tgroups: ToolGroupInfo[],\n\t\tonChange: (name: string, enabled: boolean) => void,\n\t\tonGroupChange: (id: string, enabled: boolean) => void,\n\t\tonCancel: () => void,\n\t) {\n\t\tsuper();\n\n\t\tthis.enabled = new Map(tools.map((t) => [t.name, t.enabled]));\n\n\t\tconst groupItems: SettingItem[] = groups.map((group) => ({\n\t\t\tid: `${ToolsSubmenu.GROUP_PREFIX}${group.id}`,\n\t\t\tlabel: `[group] ${group.label}`,\n\t\t\tdescription: `${group.description} Governs whether these tools exist; applies on the next session.`,\n\t\t\tcurrentValue: group.enabled ? \"on\" : \"off\",\n\t\t\tvalues: [\"on\", \"off\"],\n\t\t}));\n\n\t\tconst toolItems: SettingItem[] = tools.map((tool) => ({\n\t\t\tid: tool.name,\n\t\t\tlabel: tool.name,\n\t\t\tdescription: ToolsSubmenu.CORE.has(tool.name)\n\t\t\t\t? \"Core tool. Disabling leaves the agent unable to perform this action in every session.\"\n\t\t\t\t: \"Disable to remove this tool from the agent this session and every future session.\",\n\t\t\tcurrentValue: tool.enabled ? \"on\" : \"off\",\n\t\t\t// What the schema costs on every request, whether the tool is on or off:\n\t\t\t// off, it is the price of turning it back on. This is the number that\n\t\t\t// makes a tool worth disabling, so it belongs beside the switch.\n\t\t\tvalueSuffix: tool.tokens !== undefined ? `${tokenCount(tool.tokens)} tok/turn` : undefined,\n\t\t\tvalues: [\"on\", \"off\"],\n\t\t}));\n\n\t\tconst items = [...groupItems, ...toolItems];\n\n\t\tthis.settingsList = new SettingsList(\n\t\t\titems,\n\t\t\tMath.min(items.length, 12),\n\t\t\tgetSettingsListTheme(),\n\t\t\t(id, newValue) => {\n\t\t\t\tconst wantEnabled = newValue === \"on\";\n\t\t\t\tif (id.startsWith(ToolsSubmenu.GROUP_PREFIX)) {\n\t\t\t\t\tonGroupChange(id.slice(ToolsSubmenu.GROUP_PREFIX.length), wantEnabled);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\t// Guard: never let the last core tool be turned off.\n\t\t\t\tif (!wantEnabled && ToolsSubmenu.CORE.has(id)) {\n\t\t\t\t\tconst remainingCore = [...ToolsSubmenu.CORE].filter((n) => n !== id && this.enabled.get(n));\n\t\t\t\t\tif (remainingCore.length === 0) {\n\t\t\t\t\t\tthis.settingsList.updateValue(id, \"on\");\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tthis.enabled.set(id, wantEnabled);\n\t\t\t\tonChange(id, wantEnabled);\n\t\t\t},\n\t\t\tonCancel,\n\t\t\t{ enableSearch: true },\n\t\t);\n\n\t\tthis.addChild(this.settingsList);\n\t}\n\n\thandleInput(data: string): void {\n\t\tthis.settingsList.handleInput(data);\n\t}\n}\n\n/** Byte-cap presets shown as human labels; mapped back to raw byte counts. */\nconst TOOL_OUTPUT_BYTE_PRESETS: ReadonlyArray<[label: string, bytes: number]> = [\n\t[\"8 KB\", 8 * 1024],\n\t[\"16 KB\", 16 * 1024],\n\t[\"32 KB\", 32 * 1024],\n\t[\"64 KB\", 64 * 1024],\n\t[\"128 KB\", 128 * 1024],\n];\n\nfunction bytesToLabel(bytes: number): string {\n\tconst match = TOOL_OUTPUT_BYTE_PRESETS.find(([, b]) => b === bytes);\n\treturn match ? match[0] : `${Math.round(bytes / 1024)} KB`;\n}\n\n/** Byte-cap labels to cycle through, including a hand-set cap that matches no preset. */\nfunction byteLabels(current: number): string[] {\n\tconst all: Array<[string, number]> = TOOL_OUTPUT_BYTE_PRESETS.some(([, bytes]) => bytes === current)\n\t\t? [...TOOL_OUTPUT_BYTE_PRESETS]\n\t\t: [...TOOL_OUTPUT_BYTE_PRESETS, [bytesToLabel(current), current]];\n\treturn all.sort((a, b) => a[1] - b[1]).map(([label]) => label);\n}\n\ninterface ToolSettingsConfig {\n\ttoolOutputDisplay: \"collapsed\" | \"peek\" | \"standard\";\n\ttoolOutputMaxBytes: number;\n\ttoolOutputMaxLines: number;\n}\n\ninterface ToolSettingsCallbacks {\n\tonToolOutputDisplayChange: (level: \"collapsed\" | \"peek\" | \"standard\") => void;\n\tonToolOutputMaxBytesChange: (bytes: number) => void;\n\tonToolOutputMaxLinesChange: (lines: number) => void;\n}\n\n/**\n * Submenu for what a tool result looks like: how much of it is rendered, and\n * where it is truncated. The display level applies to the transcript at once;\n * the caps feed the tool runtime, so they bind on future tool calls.\n *\n * Context GC is deliberately not here. It is not about a tool's output but about\n * what stays in the outgoing context, which is the Context category's subject.\n */\nclass ToolSettingsSubmenu extends Container {\n\tprivate settingsList: SettingsList;\n\n\tconstructor(config: ToolSettingsConfig, callbacks: ToolSettingsCallbacks, onCancel: () => void) {\n\t\tsuper();\n\n\t\tconst items: SettingItem[] = [\n\t\t\t{\n\t\t\t\tid: \"tool-output-display\",\n\t\t\t\tlabel: \"Display\",\n\t\t\t\tdescription:\n\t\t\t\t\t\"How tool results render. 'standard': shown (expandable). 'collapsed': hidden. 'peek': hidden with a ▸ reveal caret (press the expand key to reveal).\",\n\t\t\t\tcurrentValue: config.toolOutputDisplay,\n\t\t\t\tvalues: [\"standard\", \"collapsed\", \"peek\"],\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: \"output-max-bytes\",\n\t\t\t\tlabel: \"Max bytes\",\n\t\t\t\tdescription: \"Byte cap on a single read/bash result before truncation. Applies to future tool calls.\",\n\t\t\t\tcurrentValue: bytesToLabel(config.toolOutputMaxBytes),\n\t\t\t\tvalues: byteLabels(config.toolOutputMaxBytes),\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: \"output-max-lines\",\n\t\t\t\tlabel: \"Max lines\",\n\t\t\t\tdescription: \"Line cap on a single read/bash result before truncation. Applies to future tool calls.\",\n\t\t\t\tcurrentValue: String(config.toolOutputMaxLines),\n\t\t\t\tvalues: presetValues([200, 400, 800, 1600, 3200], config.toolOutputMaxLines),\n\t\t\t},\n\t\t];\n\n\t\tthis.settingsList = new SettingsList(\n\t\t\titems,\n\t\t\tMath.min(items.length, 10),\n\t\t\tgetSettingsListTheme(),\n\t\t\t(id, newValue) => {\n\t\t\t\tswitch (id) {\n\t\t\t\t\tcase \"tool-output-display\":\n\t\t\t\t\t\tcallbacks.onToolOutputDisplayChange(newValue as \"collapsed\" | \"peek\" | \"standard\");\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"output-max-bytes\": {\n\t\t\t\t\t\tconst preset = TOOL_OUTPUT_BYTE_PRESETS.find(([label]) => label === newValue);\n\t\t\t\t\t\t// A hand-set cap has no preset entry; its label is \"<n> KB\" by\n\t\t\t\t\t\t// construction, so read the number back out of it.\n\t\t\t\t\t\tconst bytes = preset ? preset[1] : Math.round(parseFloat(newValue) * 1024);\n\t\t\t\t\t\tif (Number.isFinite(bytes) && bytes > 0) callbacks.onToolOutputMaxBytesChange(bytes);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\tcase \"output-max-lines\":\n\t\t\t\t\t\tcallbacks.onToolOutputMaxLinesChange(parseInt(newValue, 10));\n\t\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t},\n\t\t\tonCancel,\n\t\t);\n\n\t\tthis.addChild(this.settingsList);\n\t}\n\n\thandleInput(data: string): void {\n\t\tthis.settingsList.handleInput(data);\n\t}\n}\n\n/** Single-line text editor for a string flag value. */\nclass FlagStringEditSubmenu extends Container {\n\tprivate input: Input;\n\n\tconstructor(flagName: string, currentValue: string, done: (value?: string) => void) {\n\t\tsuper();\n\n\t\tthis.addChild(new Text(theme.bold(theme.fg(\"accent\", `Flag: --${flagName}`)), 0, 0));\n\t\tthis.addChild(new Spacer(1));\n\t\tthis.addChild(new Text(theme.fg(\"muted\", \"Enter a value · Enter to save · Esc to cancel\"), 0, 0));\n\t\tthis.addChild(new Spacer(1));\n\n\t\tthis.input = new Input();\n\t\tthis.input.setValue(currentValue);\n\t\tthis.input.onSubmit = (value: string) => done(value);\n\t\tthis.input.onEscape = () => done();\n\t\tthis.addChild(this.input);\n\t}\n\n\thandleInput(data: string): void {\n\t\tthis.input.handleInput(data);\n\t}\n}\n\n/**\n * Submenu listing extension-registered flags. Boolean flags toggle on/off;\n * string flags open a text editor. Changes persist to settings.json and are\n * applied live best-effort — extensions that read a flag only at load time\n * pick up the new value on the next launch.\n */\nclass FlagsSubmenu extends Container {\n\tprivate settingsList: SettingsList;\n\n\tconstructor(flags: FlagInfo[], onChange: (name: string, value: boolean | string) => void, onCancel: () => void) {\n\t\tsuper();\n\n\t\tconst items: SettingItem[] = flags.map((flag) => {\n\t\t\tconst baseDescription = flag.description ?? \"Extension-registered flag.\";\n\t\t\tconst description = `${baseDescription} Persists across sessions; some flags need a restart to fully apply.`;\n\t\t\tif (flag.type === \"boolean\") {\n\t\t\t\treturn {\n\t\t\t\t\tid: flag.name,\n\t\t\t\t\tlabel: flag.name,\n\t\t\t\t\tdescription,\n\t\t\t\t\tcurrentValue: flag.value ? \"on\" : \"off\",\n\t\t\t\t\tvalues: [\"on\", \"off\"],\n\t\t\t\t};\n\t\t\t}\n\t\t\treturn {\n\t\t\t\tid: flag.name,\n\t\t\t\tlabel: flag.name,\n\t\t\t\tdescription,\n\t\t\t\tcurrentValue: String(flag.value ?? \"\"),\n\t\t\t\tsubmenu: (currentValue, done) => new FlagStringEditSubmenu(flag.name, currentValue, done),\n\t\t\t};\n\t\t});\n\n\t\tconst typeByName = new Map(flags.map((f) => [f.name, f.type]));\n\n\t\tthis.settingsList = new SettingsList(\n\t\t\titems,\n\t\t\tMath.min(items.length, 12),\n\t\t\tgetSettingsListTheme(),\n\t\t\t(id, newValue) => {\n\t\t\t\tif (typeByName.get(id) === \"boolean\") {\n\t\t\t\t\tonChange(id, newValue === \"on\");\n\t\t\t\t} else {\n\t\t\t\t\tonChange(id, newValue);\n\t\t\t\t}\n\t\t\t},\n\t\t\tonCancel,\n\t\t\t{ enableSearch: true },\n\t\t);\n\n\t\tthis.addChild(this.settingsList);\n\t}\n\n\thandleInput(data: string): void {\n\t\tthis.settingsList.handleInput(data);\n\t}\n}\n\n/**\n * Generic submenu holding a subset of leaf settings under a category label.\n * Shares the parent's change handler so cycle rows behave exactly as they did\n * when flat; nested submenu rows (theme, thinking, warnings) keep their own\n * factories.\n */\nclass CategorySubmenu extends Container {\n\tprivate settingsList: SettingsList;\n\n\tconstructor(items: SettingItem[], onChange: (id: string, newValue: string) => void, onCancel: () => void) {\n\t\tsuper();\n\t\tthis.settingsList = new SettingsList(\n\t\t\titems,\n\t\t\tMath.min(items.length, 10),\n\t\t\tgetSettingsListTheme(),\n\t\t\tonChange,\n\t\t\tonCancel,\n\t\t\t{\n\t\t\t\tenableSearch: true,\n\t\t\t},\n\t\t);\n\t\tthis.addChild(this.settingsList);\n\t}\n\n\thandleInput(data: string): void {\n\t\tthis.settingsList.handleInput(data);\n\t}\n}\n\nclass SelectSubmenu extends Container {\n\tprivate selectList: SelectList;\n\n\tconstructor(\n\t\ttitle: string,\n\t\tdescription: string,\n\t\toptions: SelectItem[],\n\t\tcurrentValue: string,\n\t\tonSelect: (value: string) => void,\n\t\tonCancel: () => void,\n\t\tonSelectionChange?: (value: string) => void,\n\t) {\n\t\tsuper();\n\n\t\t// Title\n\t\tthis.addChild(new Text(theme.bold(theme.fg(\"accent\", title)), 0, 0));\n\n\t\t// Description\n\t\tif (description) {\n\t\t\tthis.addChild(new Spacer(1));\n\t\t\tthis.addChild(new Text(theme.fg(\"muted\", description), 0, 0));\n\t\t}\n\n\t\t// Spacer\n\t\tthis.addChild(new Spacer(1));\n\n\t\t// Select list\n\t\tthis.selectList = new SelectList(\n\t\t\toptions,\n\t\t\tMath.min(options.length, 10),\n\t\t\tgetSelectListTheme(),\n\t\t\tSETTINGS_SUBMENU_SELECT_LIST_LAYOUT,\n\t\t);\n\n\t\t// Pre-select current value\n\t\tconst currentIndex = options.findIndex((o) => o.value === currentValue);\n\t\tif (currentIndex !== -1) {\n\t\t\tthis.selectList.setSelectedIndex(currentIndex);\n\t\t}\n\n\t\tthis.selectList.onSelect = (item) => {\n\t\t\tonSelect(item.value);\n\t\t};\n\n\t\tthis.selectList.onCancel = onCancel;\n\n\t\tif (onSelectionChange) {\n\t\t\tthis.selectList.onSelectionChange = (item) => {\n\t\t\t\tonSelectionChange(item.value);\n\t\t\t};\n\t\t}\n\n\t\tthis.addChild(this.selectList);\n\n\t\t// Hint\n\t\tthis.addChild(new Spacer(1));\n\t\tthis.addChild(new Text(theme.fg(\"dim\", \" Enter to select · Esc to go back\"), 0, 0));\n\t}\n\n\thandleInput(data: string): void {\n\t\tthis.selectList.handleInput(data);\n\t}\n}\n\n/**\n * Token counts, grouped and exact.\n *\n * `formatTokens` (2.7k) exists for the fixed-width chrome, where a count must\n * never grow the box it sits in. This pane is the opposite case: the point of\n * showing a number here is to compare it with another one, and \"2.7k\" hides the\n * difference between the tool that costs 2,710 and the one that costs 2,749.\n */\nfunction tokenCount(tokens: number): string {\n\treturn tokens.toString().replace(/\\B(?=(\\d{3})+(?!\\d))/g, \",\");\n}\n\n/**\n * The fixed per-turn cost, as one line under the pane.\n *\n * Every byte of system prompt and active tool schema is re-sent on every\n * request, and the pane is where that number is decided - so the pane is where\n * it should be visible. It reports the *live* session: a tool toggle applies at\n * once and moves it, while a setting that only takes effect next session (a tool\n * group, the light preset) leaves it alone until then.\n */\nfunction formatSurfaceLine(surface: PromptSurface): string {\n\tconst tools = `${surface.tools.length} tool${surface.tools.length === 1 ? \"\" : \"s\"}`;\n\treturn (\n\t\t` Per-turn surface: ${tokenCount(surface.totalTokens)} tokens ` +\n\t\t`${theme.fg(\"dim\", `(${tokenCount(surface.systemPromptTokens)} system prompt + ${tokenCount(surface.toolSchemaTokens)} schemas, ${tools})`)}`\n\t);\n}\n\n/**\n * Main settings selector component.\n */\nexport class SettingsSelectorComponent extends Container {\n\tprivate settingsList: SettingsList;\n\tprivate surfaceLine?: Text;\n\tprivate measureTokenSurface?: () => PromptSurface;\n\n\tconstructor(config: SettingsConfig, callbacks: SettingsCallbacks) {\n\t\tsuper();\n\n\t\tthis.measureTokenSurface = config.measureTokenSurface;\n\n\t\tconst supportsImages = getCapabilities().images;\n\t\tconst followUpKey = keyDisplayText(\"app.message.followUp\");\n\t\tlet currentWarnings = { ...config.warnings };\n\n\t\t// A row writes the user settings file; a key the project file also sets is\n\t\t// merged over it on the next session, so say so rather than letting the row\n\t\t// look like it took.\n\t\tconst projectPinned = new Set(config.projectPinnedSettings);\n\t\tconst pinnedNote = (key: string): string =>\n\t\t\tprojectPinned.has(key)\n\t\t\t\t? ` This repo's .hoocode/settings.json sets ${key}, which overrides this row from the next session on.`\n\t\t\t\t: \"\";\n\n\t\tconst initialSurface = config.measureTokenSurface?.();\n\n\t\tconst toolsOn = config.tools.filter((t) => t.enabled).length;\n\t\tconst toolsOff = config.tools.length - toolsOn;\n\n\t\tconst items: SettingItem[] = [\n\t\t\t{\n\t\t\t\tid: \"autocompact\",\n\t\t\t\tlabel: \"Auto-compact\",\n\t\t\t\tdescription: \"Automatically compact context when it gets too large\",\n\t\t\t\tcurrentValue: config.autoCompact ? \"true\" : \"false\",\n\t\t\t\tvalues: [\"true\", \"false\"],\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: \"steering-mode\",\n\t\t\t\tlabel: \"Steering mode\",\n\t\t\t\tdescription:\n\t\t\t\t\t\"Enter while streaming queues steering messages. 'one-at-a-time': deliver one, wait for response. 'all': deliver all at once.\",\n\t\t\t\tcurrentValue: config.steeringMode,\n\t\t\t\tvalues: [\"one-at-a-time\", \"all\"],\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: \"follow-up-mode\",\n\t\t\t\tlabel: \"Follow-up mode\",\n\t\t\t\tdescription: `${followUpKey} queues follow-up messages until agent stops. 'one-at-a-time': deliver one, wait for response. 'all': deliver all at once.`,\n\t\t\t\tcurrentValue: config.followUpMode,\n\t\t\t\tvalues: [\"one-at-a-time\", \"all\"],\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: \"transport\",\n\t\t\t\tlabel: \"Transport\",\n\t\t\t\tdescription: \"Preferred transport for providers that support multiple transports\",\n\t\t\t\tcurrentValue: config.transport,\n\t\t\t\tvalues: [\"sse\", \"websocket\", \"websocket-cached\", \"auto\"],\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: \"hide-thinking\",\n\t\t\t\tlabel: \"Hide thinking\",\n\t\t\t\tdescription: \"Hide thinking blocks in assistant responses\",\n\t\t\t\tcurrentValue: config.hideThinkingBlock ? \"true\" : \"false\",\n\t\t\t\tvalues: [\"true\", \"false\"],\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: \"collapse-changelog\",\n\t\t\t\tlabel: \"Collapse changelog\",\n\t\t\t\tdescription: \"Show condensed changelog after updates\",\n\t\t\t\tcurrentValue: config.collapseChangelog ? \"true\" : \"false\",\n\t\t\t\tvalues: [\"true\", \"false\"],\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: \"quiet-startup\",\n\t\t\t\tlabel: \"Quiet startup\",\n\t\t\t\tdescription: \"Disable verbose printing at startup\",\n\t\t\t\tcurrentValue: config.quietStartup ? \"true\" : \"false\",\n\t\t\t\tvalues: [\"true\", \"false\"],\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: \"install-telemetry\",\n\t\t\t\tlabel: \"Install telemetry\",\n\t\t\t\tdescription: \"Send an anonymous version/update ping after changelog-detected updates\",\n\t\t\t\tcurrentValue: config.enableInstallTelemetry ? \"true\" : \"false\",\n\t\t\t\tvalues: [\"true\", \"false\"],\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: \"double-escape-action\",\n\t\t\t\tlabel: \"Double-escape action\",\n\t\t\t\tdescription: \"Action when pressing Escape twice with empty editor\",\n\t\t\t\tcurrentValue: config.doubleEscapeAction,\n\t\t\t\tvalues: [\"tree\", \"fork\", \"none\"],\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: \"tree-filter-mode\",\n\t\t\t\tlabel: \"Tree filter mode\",\n\t\t\t\tdescription: \"Default filter when opening /tree\",\n\t\t\t\tcurrentValue: config.treeFilterMode,\n\t\t\t\tvalues: [\"default\", \"no-tools\", \"user-only\", \"labeled-only\", \"all\"],\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: \"warnings\",\n\t\t\t\tlabel: \"Warnings\",\n\t\t\t\tdescription: \"Enable or disable individual warnings\",\n\t\t\t\tcurrentValue: \"configure\",\n\t\t\t\tsubmenu: (_currentValue, done) =>\n\t\t\t\t\tnew WarningSettingsSubmenu(\n\t\t\t\t\t\tcurrentWarnings,\n\t\t\t\t\t\t(warnings) => {\n\t\t\t\t\t\t\tcurrentWarnings = warnings;\n\t\t\t\t\t\t\tcallbacks.onWarningsChange(warnings);\n\t\t\t\t\t\t},\n\t\t\t\t\t\t() => done(),\n\t\t\t\t\t),\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: \"thinking\",\n\t\t\t\tlabel: \"Thinking level\",\n\t\t\t\tdescription: \"Reasoning depth for thinking-capable models\",\n\t\t\t\tcurrentValue: config.thinkingLevel,\n\t\t\t\tsubmenu: (currentValue, done) =>\n\t\t\t\t\tnew SelectSubmenu(\n\t\t\t\t\t\t\"Thinking Level\",\n\t\t\t\t\t\t\"Select reasoning depth for thinking-capable models\",\n\t\t\t\t\t\tconfig.availableThinkingLevels.map((level) => ({\n\t\t\t\t\t\t\tvalue: level,\n\t\t\t\t\t\t\tlabel: level,\n\t\t\t\t\t\t\tdescription: THINKING_DESCRIPTIONS[level],\n\t\t\t\t\t\t})),\n\t\t\t\t\t\tcurrentValue,\n\t\t\t\t\t\t(value) => {\n\t\t\t\t\t\t\tcallbacks.onThinkingLevelChange(value as ThinkingLevel);\n\t\t\t\t\t\t\tdone(value);\n\t\t\t\t\t\t},\n\t\t\t\t\t\t() => done(),\n\t\t\t\t\t),\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: \"theme\",\n\t\t\t\tlabel: \"Theme\",\n\t\t\t\tdescription: \"Color theme for the interface\",\n\t\t\t\tcurrentValue: config.currentTheme,\n\t\t\t\tsubmenu: (currentValue, done) =>\n\t\t\t\t\tnew SelectSubmenu(\n\t\t\t\t\t\t\"Theme\",\n\t\t\t\t\t\t\"Select color theme\",\n\t\t\t\t\t\tconfig.availableThemes.map((t) => ({\n\t\t\t\t\t\t\tvalue: t,\n\t\t\t\t\t\t\tlabel: t,\n\t\t\t\t\t\t\tdescription: getThemeDescription(t),\n\t\t\t\t\t\t})),\n\t\t\t\t\t\tcurrentValue,\n\t\t\t\t\t\t(value) => {\n\t\t\t\t\t\t\tcallbacks.onThemeChange(value);\n\t\t\t\t\t\t\tdone(value);\n\t\t\t\t\t\t},\n\t\t\t\t\t\t() => {\n\t\t\t\t\t\t\t// Restore original theme on cancel\n\t\t\t\t\t\t\tcallbacks.onThemePreview?.(currentValue);\n\t\t\t\t\t\t\tdone();\n\t\t\t\t\t\t},\n\t\t\t\t\t\t(value) => {\n\t\t\t\t\t\t\t// Preview theme on selection change\n\t\t\t\t\t\t\tcallbacks.onThemePreview?.(value);\n\t\t\t\t\t\t},\n\t\t\t\t\t),\n\t\t\t},\n\t\t];\n\n\t\t// Only show image toggle if terminal supports it\n\t\tif (supportsImages) {\n\t\t\t// Insert after autocompact\n\t\t\titems.splice(1, 0, {\n\t\t\t\tid: \"show-images\",\n\t\t\t\tlabel: \"Show images\",\n\t\t\t\tdescription: \"Render images inline in terminal\",\n\t\t\t\tcurrentValue: config.showImages ? \"true\" : \"false\",\n\t\t\t\tvalues: [\"true\", \"false\"],\n\t\t\t});\n\t\t\titems.splice(2, 0, {\n\t\t\t\tid: \"image-width-cells\",\n\t\t\t\tlabel: \"Image width\",\n\t\t\t\tdescription: \"Preferred inline image width in terminal cells\",\n\t\t\t\tcurrentValue: String(config.imageWidthCells),\n\t\t\t\tvalues: presetValues([60, 80, 120], config.imageWidthCells),\n\t\t\t});\n\t\t}\n\n\t\t// Image auto-resize toggle (always available, affects both attached and read images)\n\t\titems.splice(supportsImages ? 3 : 1, 0, {\n\t\t\tid: \"auto-resize-images\",\n\t\t\tlabel: \"Auto-resize images\",\n\t\t\tdescription: \"Resize large images to 2000x2000 max for better model compatibility\",\n\t\t\tcurrentValue: config.autoResizeImages ? \"true\" : \"false\",\n\t\t\tvalues: [\"true\", \"false\"],\n\t\t});\n\n\t\t// Block images toggle (always available, insert after auto-resize-images)\n\t\tconst autoResizeIndex = items.findIndex((item) => item.id === \"auto-resize-images\");\n\t\titems.splice(autoResizeIndex + 1, 0, {\n\t\t\tid: \"block-images\",\n\t\t\tlabel: \"Block images\",\n\t\t\tdescription: \"Prevent images from being sent to LLM providers\",\n\t\t\tcurrentValue: config.blockImages ? \"true\" : \"false\",\n\t\t\tvalues: [\"true\", \"false\"],\n\t\t});\n\n\t\t// Context GC (insert after block-images), a leaf the Context category picks up.\n\t\titems.splice(items.findIndex((item) => item.id === \"block-images\") + 1, 0, {\n\t\t\tid: \"context-gc\",\n\t\t\tlabel: \"Context GC\",\n\t\t\tdescription: \"Stub superseded read results (files later edited or re-read) out of the outgoing context.\",\n\t\t\tcurrentValue: config.contextGc ? \"true\" : \"false\",\n\t\t\tvalues: [\"true\", \"false\"],\n\t\t});\n\n\t\t// The light preset (insert after context GC). Read at startup to pick the\n\t\t// tool set and the system prompt, so it lands on the next session.\n\t\tconst blockImagesIdx = items.findIndex((item) => item.id === \"context-gc\");\n\t\titems.splice(blockImagesIdx + 1, 0, {\n\t\t\tid: \"light\",\n\t\t\tlabel: \"Light preset\",\n\t\t\tdescription:\n\t\t\t\t\"Low-token preset for small or local models: read/write/edit/bash only with stripped schemas, a terse system prompt, and no subagents/TodoWrite/skills/context files. Applies on the next session.\",\n\t\t\tcurrentValue: config.light ? \"true\" : \"false\",\n\t\t\tvalues: [\"true\", \"false\"],\n\t\t});\n\n\t\t// Skill commands toggle (insert after the light preset)\n\t\tconst blockImagesIndex = items.findIndex((item) => item.id === \"light\");\n\t\titems.splice(blockImagesIndex + 1, 0, {\n\t\t\tid: \"skill-commands\",\n\t\t\tlabel: \"Skill commands\",\n\t\t\tdescription: \"Register skills as /skill:name commands\",\n\t\t\tcurrentValue: config.enableSkillCommands ? \"true\" : \"false\",\n\t\t\tvalues: [\"true\", \"false\"],\n\t\t});\n\n\t\t// The autonomous plugin system's master switch (insert after skill-commands).\n\t\t// One flag for the lifecycle tools and the reuse nudge, so both flip together.\n\t\tconst skillCommandsIdx = items.findIndex((item) => item.id === \"skill-commands\");\n\t\titems.splice(skillCommandsIdx + 1, 0, {\n\t\t\tid: \"plugin-tools\",\n\t\t\tlabel: \"Plugin system\",\n\t\t\tdescription: `Autonomous plugin system: the lifecycle tools (SearchPlugins, InstallPlugin, ...), ProposePlugin, and the plugin-reuse nudge. Tools arrive on the next session; the nudge follows at once.${pinnedNote(\"enablePluginTools\")}`,\n\t\t\tcurrentValue: config.enablePluginTools ? \"true\" : \"false\",\n\t\t\tvalues: [\"true\", \"false\"],\n\t\t});\n\n\t\t// Plugin install scope (insert after the master switch). Governs the\n\t\t// autonomous InstallPlugin only — /plugin install asks per install.\n\t\tconst pluginToolsIdx = items.findIndex((item) => item.id === \"plugin-tools\");\n\t\titems.splice(pluginToolsIdx + 1, 0, {\n\t\t\tid: \"plugin-install-scope\",\n\t\t\tlabel: \"Plugin install scope\",\n\t\t\tdescription: \"Where autonomous plugin installs go: user (~/.agents) or project (this repo, shared)\",\n\t\t\tcurrentValue: config.pluginInstallScope,\n\t\t\tvalues: [\"user\", \"project\"],\n\t\t});\n\n\t\t// Artifact platform targets (insert after plugin-install-scope). Set once and\n\t\t// it holds for every later session: it is the `platform` setting, which\n\t\t// `--platform` overrides for a single run.\n\t\tconst pluginScopeIdx = items.findIndex((item) => item.id === \"plugin-install-scope\");\n\t\tlet currentPlatforms = [...config.platform];\n\t\titems.splice(pluginScopeIdx + 1, 0, {\n\t\t\tid: \"platform\",\n\t\t\tlabel: \"Platform\",\n\t\t\tdescription: `Vendor layout(s) hoocode writes artifacts in: authored plugins and the /new-skill //new-agent //new-command scaffolds.${pinnedNote(\"platform\")}`,\n\t\t\tcurrentValue: platformSummary(currentPlatforms),\n\t\t\tsubmenu: (_currentValue, done) =>\n\t\t\t\tnew PlatformSubmenu(\n\t\t\t\t\tcurrentPlatforms,\n\t\t\t\t\t(platforms) => {\n\t\t\t\t\t\tcurrentPlatforms = platforms;\n\t\t\t\t\t\tcallbacks.onPlatformChange(platforms);\n\t\t\t\t\t},\n\t\t\t\t\t(summary) => done(summary),\n\t\t\t\t),\n\t\t});\n\n\t\t// Hardware cursor toggle (insert after the platform row)\n\t\tconst platformIndex = items.findIndex((item) => item.id === \"platform\");\n\t\titems.splice(platformIndex + 1, 0, {\n\t\t\tid: \"show-hardware-cursor\",\n\t\t\tlabel: \"Show hardware cursor\",\n\t\t\tdescription: \"Show the terminal cursor while still positioning it for IME support\",\n\t\t\tcurrentValue: config.showHardwareCursor ? \"true\" : \"false\",\n\t\t\tvalues: [\"true\", \"false\"],\n\t\t});\n\n\t\t// Editor border toggle (insert after show-hardware-cursor)\n\t\tconst hardwareCursorIndex = items.findIndex((item) => item.id === \"show-hardware-cursor\");\n\t\titems.splice(hardwareCursorIndex + 1, 0, {\n\t\t\tid: \"editor-border\",\n\t\t\tlabel: \"Editor border\",\n\t\t\tdescription: \"Box draws side borders, rule draws horizontal lines only\",\n\t\t\tcurrentValue: config.editorBorder,\n\t\t\tvalues: [\"box\", \"rule\"],\n\t\t});\n\n\t\t// Editor padding toggle (insert after editor-border)\n\t\tconst editorBorderIndex = items.findIndex((item) => item.id === \"editor-border\");\n\t\titems.splice(editorBorderIndex + 1, 0, {\n\t\t\tid: \"editor-padding\",\n\t\t\tlabel: \"Editor padding\",\n\t\t\tdescription: \"Horizontal padding for input editor (0-3)\",\n\t\t\tcurrentValue: String(config.editorPaddingX),\n\t\t\tvalues: [\"0\", \"1\", \"2\", \"3\"],\n\t\t});\n\n\t\t// Autocomplete max visible toggle (insert after editor-padding)\n\t\tconst editorPaddingIndex = items.findIndex((item) => item.id === \"editor-padding\");\n\t\titems.splice(editorPaddingIndex + 1, 0, {\n\t\t\tid: \"autocomplete-max-visible\",\n\t\t\tlabel: \"Autocomplete max items\",\n\t\t\tdescription: \"Max visible items in autocomplete dropdown (3-20)\",\n\t\t\tcurrentValue: String(config.autocompleteMaxVisible),\n\t\t\tvalues: presetValues([3, 5, 7, 10, 15, 20], config.autocompleteMaxVisible),\n\t\t});\n\n\t\t// Clear on shrink toggle (insert after autocomplete-max-visible)\n\t\tconst autocompleteIndex = items.findIndex((item) => item.id === \"autocomplete-max-visible\");\n\t\titems.splice(autocompleteIndex + 1, 0, {\n\t\t\tid: \"clear-on-shrink\",\n\t\t\tlabel: \"Clear on shrink\",\n\t\t\tdescription: \"Clear empty rows when content shrinks (may cause flicker)\",\n\t\t\tcurrentValue: config.clearOnShrink ? \"true\" : \"false\",\n\t\t\tvalues: [\"true\", \"false\"],\n\t\t});\n\n\t\t// Terminal progress toggle (insert after clear-on-shrink)\n\t\tconst clearOnShrinkIndex = items.findIndex((item) => item.id === \"clear-on-shrink\");\n\t\titems.splice(clearOnShrinkIndex + 1, 0, {\n\t\t\tid: \"terminal-progress\",\n\t\t\tlabel: \"Terminal progress\",\n\t\t\tdescription: \"Show OSC 9;4 progress indicators in the terminal tab bar\",\n\t\t\tcurrentValue: config.showTerminalProgress ? \"true\" : \"false\",\n\t\t\tvalues: [\"true\", \"false\"],\n\t\t});\n\n\t\t// Voice silence window (insert after terminal-progress)\n\t\tconst terminalProgressIndex = items.findIndex((item) => item.id === \"terminal-progress\");\n\t\titems.splice(terminalProgressIndex + 1, 0, {\n\t\t\tid: \"voice-silence-ms\",\n\t\t\tlabel: \"Voice silence window\",\n\t\t\tdescription: \"Trailing-silence (ms) before voice capture auto-stops (300-10000). Env: VOICETOOLS_SILENCE_MS.\",\n\t\t\tcurrentValue: String(config.voiceSilenceMs),\n\t\t\tvalues: presetValues([300, 500, 800, 1200, 2000, 3000, 5000, 8000, 10000], config.voiceSilenceMs),\n\t\t});\n\n\t\t// Webtools request timeout (insert after voice-silence-ms)\n\t\tconst voiceSilenceIndex = items.findIndex((item) => item.id === \"voice-silence-ms\");\n\t\titems.splice(voiceSilenceIndex + 1, 0, {\n\t\t\tid: \"webtools-timeout-secs\",\n\t\t\tlabel: \"Web tools timeout\",\n\t\t\tdescription: \"Per-request timeout (secs) for webfetch/websearch (1-120). Env: HOOCODE_WEBTOOLS_TIMEOUT.\",\n\t\t\tcurrentValue: String(config.webtoolsTimeoutSecs),\n\t\t\tvalues: presetValues([5, 10, 15, 30, 60, 120], config.webtoolsTimeoutSecs),\n\t\t});\n\n\t\t// The /learn thresholds, appended as leaf rows and gathered into their own\n\t\t// category below. They are written to the user settings.json, which /learn\n\t\t// re-reads on every invocation, so a change here applies to the next run.\n\t\tconst webtoolsIndex = items.findIndex((item) => item.id === \"webtools-timeout-secs\");\n\t\titems.splice(\n\t\t\twebtoolsIndex + 1,\n\t\t\t0,\n\t\t\t...LEARN_SETTINGS.map(({ key, label, description, presets }) => ({\n\t\t\t\tid: key,\n\t\t\t\tlabel,\n\t\t\t\tdescription,\n\t\t\t\tcurrentValue: String(config.learn[key]),\n\t\t\t\tvalues: presetValues(presets, config.learn[key]),\n\t\t\t})),\n\t\t);\n\n\t\t// Keep the tool/flag controls together as one block near the top, inserted\n\t\t// after the image/terminal splices above so they aren't leapfrogged.\n\t\tconst toolFlagGroup: SettingItem[] = [\n\t\t\t{\n\t\t\t\tid: \"tools\",\n\t\t\t\tlabel: \"Tools\",\n\t\t\t\tdescription:\n\t\t\t\t\t\"Enable/disable tools and tool groups (web, semantic search), each priced by what its schema costs per turn. Changes persist across sessions.\",\n\t\t\t\tcurrentValue: toolsOff > 0 ? `${toolsOn} on · ${toolsOff} off` : `${toolsOn} on`,\n\t\t\t\tvalueSuffix: initialSurface ? `${tokenCount(initialSurface.toolSchemaTokens)} tok/turn` : undefined,\n\t\t\t\tsubmenu: (_currentValue, done) =>\n\t\t\t\t\tnew ToolsSubmenu(\n\t\t\t\t\t\tconfig.tools,\n\t\t\t\t\t\tconfig.toolGroups,\n\t\t\t\t\t\t(name, enabled) => {\n\t\t\t\t\t\t\tcallbacks.onToolEnabledChange(name, enabled);\n\t\t\t\t\t\t\t// Applied live by the host, so the surface below is already stale.\n\t\t\t\t\t\t\tthis.refreshTokenSurface();\n\t\t\t\t\t\t},\n\t\t\t\t\t\t(id, enabled) => callbacks.onToolGroupChange(id, enabled),\n\t\t\t\t\t\t() => done(),\n\t\t\t\t\t),\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: \"tool-output\",\n\t\t\t\tlabel: \"Tool output\",\n\t\t\t\tdescription: \"How much of a tool result is rendered, and where it is truncated.\",\n\t\t\t\tcurrentValue: config.toolOutputDisplay,\n\t\t\t\tsubmenu: (_currentValue, done) =>\n\t\t\t\t\tnew ToolSettingsSubmenu(\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\ttoolOutputDisplay: config.toolOutputDisplay,\n\t\t\t\t\t\t\ttoolOutputMaxBytes: config.toolOutputMaxBytes,\n\t\t\t\t\t\t\ttoolOutputMaxLines: config.toolOutputMaxLines,\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tonToolOutputDisplayChange: callbacks.onToolOutputDisplayChange,\n\t\t\t\t\t\t\tonToolOutputMaxBytesChange: callbacks.onToolOutputMaxBytesChange,\n\t\t\t\t\t\t\tonToolOutputMaxLinesChange: callbacks.onToolOutputMaxLinesChange,\n\t\t\t\t\t\t},\n\t\t\t\t\t\t() => done(),\n\t\t\t\t\t),\n\t\t\t},\n\t\t];\n\t\tif (config.flags.length > 0) {\n\t\t\ttoolFlagGroup.push({\n\t\t\t\tid: \"flags\",\n\t\t\t\tlabel: \"Flags\",\n\t\t\t\tdescription: \"Set flags registered by extensions. Changes persist across sessions.\",\n\t\t\t\tcurrentValue: `${config.flags.length} flag${config.flags.length === 1 ? \"\" : \"s\"}`,\n\t\t\t\tsubmenu: (_currentValue, done) =>\n\t\t\t\t\tnew FlagsSubmenu(\n\t\t\t\t\t\tconfig.flags,\n\t\t\t\t\t\t(name, value) => callbacks.onFlagChange(name, value),\n\t\t\t\t\t\t() => done(),\n\t\t\t\t\t),\n\t\t\t});\n\t\t}\n\t\t// Add borders\n\t\tthis.addChild(new DynamicBorder());\n\n\t\t// Shared change handler for every leaf (cycle) setting; used by the\n\t\t// top-level list and each category submenu.\n\t\tconst applyChange = (id: string, newValue: string): void => {\n\t\t\tswitch (id) {\n\t\t\t\tcase \"autocompact\":\n\t\t\t\t\tcallbacks.onAutoCompactChange(newValue === \"true\");\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"show-images\":\n\t\t\t\t\tcallbacks.onShowImagesChange(newValue === \"true\");\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"image-width-cells\":\n\t\t\t\t\tcallbacks.onImageWidthCellsChange(parseInt(newValue, 10));\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"auto-resize-images\":\n\t\t\t\t\tcallbacks.onAutoResizeImagesChange(newValue === \"true\");\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"block-images\":\n\t\t\t\t\tcallbacks.onBlockImagesChange(newValue === \"true\");\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"skill-commands\":\n\t\t\t\t\tcallbacks.onEnableSkillCommandsChange(newValue === \"true\");\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"light\":\n\t\t\t\t\tcallbacks.onLightChange(newValue === \"true\");\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"plugin-tools\":\n\t\t\t\t\tcallbacks.onEnablePluginToolsChange(newValue === \"true\");\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"plugin-install-scope\":\n\t\t\t\t\tcallbacks.onPluginInstallScopeChange(newValue as \"user\" | \"project\");\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"platform\":\n\t\t\t\t\t// Display only. Each toggle inside the submenu already applied itself;\n\t\t\t\t\t// closing it hands back the summary purely to refresh this row's value.\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"steering-mode\":\n\t\t\t\t\tcallbacks.onSteeringModeChange(newValue as \"all\" | \"one-at-a-time\");\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"follow-up-mode\":\n\t\t\t\t\tcallbacks.onFollowUpModeChange(newValue as \"all\" | \"one-at-a-time\");\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"transport\":\n\t\t\t\t\tcallbacks.onTransportChange(newValue as Transport);\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"hide-thinking\":\n\t\t\t\t\tcallbacks.onHideThinkingBlockChange(newValue === \"true\");\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"collapse-changelog\":\n\t\t\t\t\tcallbacks.onCollapseChangelogChange(newValue === \"true\");\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"quiet-startup\":\n\t\t\t\t\tcallbacks.onQuietStartupChange(newValue === \"true\");\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"install-telemetry\":\n\t\t\t\t\tcallbacks.onEnableInstallTelemetryChange(newValue === \"true\");\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"double-escape-action\":\n\t\t\t\t\tcallbacks.onDoubleEscapeActionChange(newValue as \"fork\" | \"tree\" | \"none\");\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"tree-filter-mode\":\n\t\t\t\t\tcallbacks.onTreeFilterModeChange(\n\t\t\t\t\t\tnewValue as \"default\" | \"no-tools\" | \"user-only\" | \"labeled-only\" | \"all\",\n\t\t\t\t\t);\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"show-hardware-cursor\":\n\t\t\t\t\tcallbacks.onShowHardwareCursorChange(newValue === \"true\");\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"editor-border\":\n\t\t\t\t\tcallbacks.onEditorBorderChange(newValue as \"rule\" | \"box\");\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"editor-padding\":\n\t\t\t\t\tcallbacks.onEditorPaddingXChange(parseInt(newValue, 10));\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"autocomplete-max-visible\":\n\t\t\t\t\tcallbacks.onAutocompleteMaxVisibleChange(parseInt(newValue, 10));\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"clear-on-shrink\":\n\t\t\t\t\tcallbacks.onClearOnShrinkChange(newValue === \"true\");\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"terminal-progress\":\n\t\t\t\t\tcallbacks.onShowTerminalProgressChange(newValue === \"true\");\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"voice-silence-ms\":\n\t\t\t\t\tcallbacks.onVoiceSilenceMsChange(parseInt(newValue, 10));\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"webtools-timeout-secs\":\n\t\t\t\t\tcallbacks.onWebtoolsTimeoutSecsChange(parseInt(newValue, 10));\n\t\t\t\t\tbreak;\n\t\t\t\tdefault:\n\t\t\t\t\t// The /learn rows are keyed by their settings.json name, so they need\n\t\t\t\t\t// no case of their own — the id is the key to write.\n\t\t\t\t\tif (LEARN_KEYS.has(id)) callbacks.onLearnSettingChange(id as LearnSettingKey, parseInt(newValue, 10));\n\t\t\t\t\tbreak;\n\t\t\t}\n\t\t\t// Most rows leave the per-turn surface alone; the ones that do not (a tool\n\t\t\t// toggle, anything that rebuilds the system prompt) move it immediately.\n\t\t\t// Re-measuring after every change is cheaper than knowing which is which.\n\t\t\tthis.refreshTokenSurface();\n\t\t};\n\n\t\t// Partition the flat leaf settings into named category submenus so the\n\t\t// top level stays short. `items` holds autocompact + every leaf setting.\n\t\tconst byId = new Map(items.map((item) => [item.id, item] as const));\n\t\tconst pick = (ids: string[]): SettingItem[] =>\n\t\t\tids.map((id) => byId.get(id)).filter((item): item is SettingItem => item !== undefined);\n\t\tconst categoryRow = (id: string, label: string, description: string, ids: string[]): SettingItem => {\n\t\t\tconst members = pick(ids);\n\t\t\treturn {\n\t\t\t\tid,\n\t\t\t\tlabel,\n\t\t\t\tdescription,\n\t\t\t\tcurrentValue: `${members.length} setting${members.length === 1 ? \"\" : \"s\"}`,\n\t\t\t\t// Categories shortened the top level but also hid every setting from\n\t\t\t\t// its search: searching \"theme\" matched no category label. The member\n\t\t\t\t// labels ride along as search text so the query lands on the category\n\t\t\t\t// that holds the setting.\n\t\t\t\tkeywords: members.map((member) => member.label).join(\" \"),\n\t\t\t\tsubmenu: (_currentValue, done) => new CategorySubmenu(members, applyChange, () => done()),\n\t\t\t};\n\t\t};\n\n\t\tconst topItems: SettingItem[] = [\n\t\t\t...toolFlagGroup,\n\t\t\t// What the model is sent, and how much of it. Auto-compact used to sit\n\t\t\t// alone at the top level and context GC was filed under tool settings,\n\t\t\t// which left the three settings that decide the token budget in three\n\t\t\t// different places - with the light preset in none of them.\n\t\t\tcategoryRow(\n\t\t\t\t\"cat-context\",\n\t\t\t\t\"Context\",\n\t\t\t\t\"What the model is sent and how much of it: compaction, superseded reads, and the low-token preset.\",\n\t\t\t\t[\"autocompact\", \"context-gc\", \"light\"],\n\t\t\t),\n\t\t\tcategoryRow(\n\t\t\t\t\"cat-behavior\",\n\t\t\t\t\"Behavior\",\n\t\t\t\t\"Agent and session behavior: steering, follow-up, thinking, escape, tree filter, transport.\",\n\t\t\t\t[\"steering-mode\", \"follow-up-mode\", \"thinking\", \"double-escape-action\", \"tree-filter-mode\", \"transport\"],\n\t\t\t),\n\t\t\tcategoryRow(\n\t\t\t\t\"cat-interface\",\n\t\t\t\t\"Interface\",\n\t\t\t\t\"Appearance and editor: theme, thinking visibility, cursor, border, padding, autocomplete, terminal.\",\n\t\t\t\t[\n\t\t\t\t\t\"theme\",\n\t\t\t\t\t\"hide-thinking\",\n\t\t\t\t\t\"show-hardware-cursor\",\n\t\t\t\t\t\"editor-border\",\n\t\t\t\t\t\"editor-padding\",\n\t\t\t\t\t\"autocomplete-max-visible\",\n\t\t\t\t\t\"clear-on-shrink\",\n\t\t\t\t\t\"terminal-progress\",\n\t\t\t\t],\n\t\t\t),\n\t\t\t// Artifact production. `plugin-install-scope` had no category and was\n\t\t\t// therefore unreachable from the pane despite having a live callback.\n\t\t\tcategoryRow(\n\t\t\t\t\"cat-plugins\",\n\t\t\t\t\"Plugins\",\n\t\t\t\t\"The autonomous plugin system's master switch, the vendor layout hoocode writes, and where autonomous installs land.\",\n\t\t\t\t[\"plugin-tools\", \"platform\", \"plugin-install-scope\"],\n\t\t\t),\n\t\t\tcategoryRow(\"cat-images\", \"Images\", \"Inline image rendering and resizing.\", [\n\t\t\t\t\"show-images\",\n\t\t\t\t\"image-width-cells\",\n\t\t\t\t\"auto-resize-images\",\n\t\t\t\t\"block-images\",\n\t\t\t]),\n\t\t\t// Top level rather than folded into Advanced: these are the thresholds\n\t\t\t// that decide whether /learn finds anything, and burying them is what\n\t\t\t// made them undiscoverable in the first place.\n\t\t\tcategoryRow(\n\t\t\t\t\"cat-learn\",\n\t\t\t\t\"Learning\",\n\t\t\t\t\"Thresholds /learn mines sessions with: how far back to look, and how often something must repeat.\",\n\t\t\t\tLEARN_SETTINGS.map((setting) => setting.key),\n\t\t\t),\n\t\t\tcategoryRow(\"cat-advanced\", \"Advanced\", \"Startup, telemetry, skills, warnings, voice, and web tools.\", [\n\t\t\t\t\"quiet-startup\",\n\t\t\t\t\"collapse-changelog\",\n\t\t\t\t\"install-telemetry\",\n\t\t\t\t\"skill-commands\",\n\t\t\t\t\"warnings\",\n\t\t\t\t\"voice-silence-ms\",\n\t\t\t\t\"webtools-timeout-secs\",\n\t\t\t]),\n\t\t];\n\n\t\tthis.settingsList = new SettingsList(\n\t\t\ttopItems,\n\t\t\tMath.min(topItems.length, 10),\n\t\t\tgetSettingsListTheme(),\n\t\t\tapplyChange,\n\t\t\tcallbacks.onCancel,\n\t\t\t{\n\t\t\t\tenableSearch: true,\n\t\t\t},\n\t\t);\n\n\t\tthis.addChild(this.settingsList);\n\t\tif (initialSurface) {\n\t\t\tthis.surfaceLine = new Text(formatSurfaceLine(initialSurface), 0, 0);\n\t\t\tthis.addChild(this.surfaceLine);\n\t\t}\n\t\tthis.addChild(new DynamicBorder());\n\t}\n\n\t/** Re-price the pane after a change that may have altered what each turn sends. */\n\tprivate refreshTokenSurface(): void {\n\t\tif (!this.surfaceLine || !this.measureTokenSurface) return;\n\t\tthis.surfaceLine.setText(formatSurfaceLine(this.measureTokenSurface()));\n\t}\n\n\tgetSettingsList(): SettingsList {\n\t\treturn this.settingsList;\n\t}\n}\n"]}
|