@di-code/coding-agent 0.1.0 → 0.1.2
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/README.md +224 -0
- package/dist/cli.d.ts +11 -0
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +59 -0
- package/dist/cli.js.map +1 -1
- package/dist/core/resources/index.d.ts +3 -0
- package/dist/core/resources/index.d.ts.map +1 -0
- package/dist/core/resources/index.js +2 -0
- package/dist/core/resources/index.js.map +1 -0
- package/dist/core/resources/loader.d.ts +8 -0
- package/dist/core/resources/loader.d.ts.map +1 -0
- package/dist/core/resources/loader.js +174 -0
- package/dist/core/resources/loader.js.map +1 -0
- package/dist/core/resources/skills.d.ts +10 -0
- package/dist/core/resources/skills.d.ts.map +1 -0
- package/dist/core/resources/skills.js +167 -0
- package/dist/core/resources/skills.js.map +1 -0
- package/dist/core/resources/types.d.ts +41 -0
- package/dist/core/resources/types.d.ts.map +1 -0
- package/dist/core/resources/types.js +2 -0
- package/dist/core/resources/types.js.map +1 -0
- package/dist/core/session.d.ts +7 -0
- package/dist/core/session.d.ts.map +1 -1
- package/dist/core/session.js +23 -3
- package/dist/core/session.js.map +1 -1
- package/dist/core/skill-command.d.ts +3 -0
- package/dist/core/skill-command.d.ts.map +1 -0
- package/dist/core/skill-command.js +34 -0
- package/dist/core/skill-command.js.map +1 -0
- package/dist/core/system-prompt.d.ts +6 -0
- package/dist/core/system-prompt.d.ts.map +1 -0
- package/dist/core/system-prompt.js +57 -0
- package/dist/core/system-prompt.js.map +1 -0
- package/dist/extensions/runtime.d.ts +7 -4
- package/dist/extensions/runtime.d.ts.map +1 -1
- package/dist/extensions/runtime.js +45 -10
- package/dist/extensions/runtime.js.map +1 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -1
- package/dist/main.d.ts +1 -0
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +85 -2
- package/dist/main.js.map +1 -1
- package/dist/modes/interactive-components.d.ts.map +1 -1
- package/dist/modes/interactive-components.js +4 -0
- package/dist/modes/interactive-components.js.map +1 -1
- package/dist/modes/interactive-state.js +1 -1
- package/dist/modes/interactive-state.js.map +1 -1
- package/dist/modes/interactive.d.ts +4 -0
- package/dist/modes/interactive.d.ts.map +1 -1
- package/dist/modes/interactive.js +26 -5
- package/dist/modes/interactive.js.map +1 -1
- package/dist/plugins/index.d.ts +5 -0
- package/dist/plugins/index.d.ts.map +1 -0
- package/dist/plugins/index.js +5 -0
- package/dist/plugins/index.js.map +1 -0
- package/dist/plugins/loader.d.ts +18 -0
- package/dist/plugins/loader.d.ts.map +1 -0
- package/dist/plugins/loader.js +92 -0
- package/dist/plugins/loader.js.map +1 -0
- package/dist/plugins/manager.d.ts +23 -0
- package/dist/plugins/manager.d.ts.map +1 -0
- package/dist/plugins/manager.js +152 -0
- package/dist/plugins/manager.js.map +1 -0
- package/dist/plugins/manifest.d.ts +7 -0
- package/dist/plugins/manifest.d.ts.map +1 -0
- package/dist/plugins/manifest.js +116 -0
- package/dist/plugins/manifest.js.map +1 -0
- package/dist/plugins/types.d.ts +41 -0
- package/dist/plugins/types.d.ts.map +1 -0
- package/dist/plugins/types.js +2 -0
- package/dist/plugins/types.js.map +1 -0
- package/dist/provider-onboarding.d.ts.map +1 -1
- package/dist/provider-onboarding.js +13 -1
- package/dist/provider-onboarding.js.map +1 -1
- package/dist/startup.d.ts.map +1 -1
- package/dist/startup.js +37 -15
- package/dist/startup.js.map +1 -1
- package/package.json +24 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interactive-components.js","sourceRoot":"","sources":["../../src/modes/interactive-components.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAiB7E,MAAM,KAAK,GAAG,SAAS,CAAC;AACxB,MAAM,IAAI,GAAG,SAAS,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,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;YACrE,OAAO,IAAI,IAAI,CAAC,GAAG,MAAM,GAAG,IAAI,CAAC,KAAK,GAAG,WAAW,EAAE,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QACvE,CAAC,CAAC,CAAC;IACJ,CAAC;CACD","sourcesContent":["import type { AutocompleteItem, Component } from \"@di-code/tui\";\nimport { Markdown, Text, truncateToWidth, visibleWidth } from \"@di-code/tui\";\nimport type { InteractiveState } from \"./interactive-state.ts\";\n\nexport interface InteractiveViewState extends InteractiveState {\n\treadonly model: string;\n\treadonly theme: \"dark\" | \"light\";\n}\n\ninterface Palette {\n\treadonly accent: string;\n\treadonly assistant: string;\n\treadonly dim: string;\n\treadonly error: string;\n\treadonly success: string;\n\treadonly warning: string;\n}\n\nconst RESET = \"\\x1b[0m\";\nconst BOLD = \"\\x1b[1m\";\nconst MAX_VISIBLE_TOOL_ITEMS = 6;\nconst SPINNER_FRAMES = [\"|\", \"/\", \"-\", \"\\\\\"] as const;\n\nfunction paletteFor(theme: InteractiveViewState[\"theme\"]): Palette {\n\treturn theme === \"light\"\n\t\t? {\n\t\t\t\taccent: \"\\x1b[38;5;25m\",\n\t\t\t\tassistant: \"\\x1b[38;5;30m\",\n\t\t\t\tdim: \"\\x1b[38;5;242m\",\n\t\t\t\terror: \"\\x1b[38;5;160m\",\n\t\t\t\tsuccess: \"\\x1b[38;5;28m\",\n\t\t\t\twarning: \"\\x1b[38;5;130m\",\n\t\t\t}\n\t\t: {\n\t\t\t\taccent: \"\\x1b[38;5;45m\",\n\t\t\t\tassistant: \"\\x1b[38;5;80m\",\n\t\t\t\tdim: \"\\x1b[38;5;245m\",\n\t\t\t\terror: \"\\x1b[38;5;210m\",\n\t\t\t\tsuccess: \"\\x1b[38;5;114m\",\n\t\t\t\twarning: \"\\x1b[38;5;222m\",\n\t\t\t};\n}\n\nfunction paint(color: string, text: string, bold = false): string {\n\treturn `${color}${bold ? BOLD : \"\"}${text}${RESET}`;\n}\n\nfunction renderLine(text: string, width: number): string[] {\n\treturn new Text(truncateToWidth(text, width, \"\")).render(width);\n}\n\nfunction alignEnds(left: string, right: string, width: number): string {\n\tconst gap = 3;\n\tif (visibleWidth(left) + visibleWidth(right) + gap > width) return truncateToWidth(left, width, \"\");\n\treturn `${left}${\" \".repeat(width - visibleWidth(left) - visibleWidth(right))}${right}`;\n}\n\nfunction activityLabel(state: InteractiveViewState): { readonly text: string; readonly color: string } {\n\tconst colors = paletteFor(state.theme);\n\tif (state.error) return { text: \"ERROR\", color: colors.error };\n\tif (state.compacting) return { text: \"COMPACTING\", color: colors.warning };\n\tif (state.retrying) return { text: \"RETRYING\", color: colors.warning };\n\tif (state.busy) return { text: \"WORKING\", color: colors.accent };\n\treturn { text: \"READY\", color: colors.success };\n}\n\nexport class InteractiveHeader implements Component {\n\tprivate readonly readState: () => InteractiveViewState;\n\n\tconstructor(readState: () => InteractiveViewState) {\n\t\tthis.readState = readState;\n\t}\n\n\tinvalidate(): void {}\n\n\trender(width: number): string[] {\n\t\tconst state = this.readState();\n\t\tconst colors = paletteFor(state.theme);\n\t\tconst brand = paint(colors.accent, \"DI-CODE / INTERACTIVE\", true);\n\t\tconst model = paint(colors.dim, `MODEL ${state.model}`);\n\t\tconst title =\n\t\t\twidth >= 56\n\t\t\t\t? alignEnds(brand, model, width)\n\t\t\t\t: `${paint(colors.accent, \"DI-CODE\", true)} ${paint(colors.dim, state.model)}`;\n\t\treturn [...renderLine(title, width), ...renderLine(paint(colors.dim, \"-\".repeat(Math.max(0, width))), width)];\n\t}\n}\n\nexport class InteractiveChat implements Component {\n\tprivate readonly readState: () => InteractiveViewState;\n\n\tconstructor(readState: () => InteractiveViewState) {\n\t\tthis.readState = readState;\n\t}\n\n\tinvalidate(): void {}\n\n\trender(width: number): string[] {\n\t\tconst state = this.readState();\n\t\tconst lines: string[] = [];\n\t\tconst colors = paletteFor(state.theme);\n\t\tfor (const [index, message] of state.messageItems.entries()) {\n\t\t\tif (index > 0) lines.push(\" \");\n\t\t\tif (message.role === \"user\") {\n\t\t\t\tlines.push(...renderLine(` ${paint(colors.accent, \"You\", true)}`, width));\n\t\t\t\tlines.push(...new Text(` ${message.text}`).render(width));\n\t\t\t} else {\n\t\t\t\tlines.push(...renderLine(` ${paint(colors.assistant, \"Assistant\", true)}`, width));\n\t\t\t\tlines.push(...new Markdown(message.text, { paddingX: 4 }).render(width));\n\t\t\t}\n\t\t}\n\t\tconst toolCount = state.processItems.filter((item) => item.type === \"tool\").length;\n\t\tconst hiddenToolItems = Math.max(0, toolCount - MAX_VISIBLE_TOOL_ITEMS);\n\t\tlet skippedToolItems = 0;\n\t\tfor (const item of state.processItems) {\n\t\t\tif (item.type === \"tool\" && skippedToolItems < hiddenToolItems) {\n\t\t\t\tskippedToolItems += 1;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (item.type === \"tool\" && skippedToolItems === hiddenToolItems && hiddenToolItems > 0) {\n\t\t\t\tlines.push(...renderLine(` ${paint(colors.dim, `${hiddenToolItems} earlier tool updates`)}`, width));\n\t\t\t\tskippedToolItems += 1;\n\t\t\t}\n\t\t\tif (item.type === \"thinking\") {\n\t\t\t\tconst frame = SPINNER_FRAMES[state.spinnerFrame % SPINNER_FRAMES.length] ?? SPINNER_FRAMES[0];\n\t\t\t\tlines.push(...renderLine(` ${paint(colors.accent, `${frame} Thinking`)}`, width));\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tconst marker = item.status === \"running\" ? \">\" : item.status === \"error\" ? \"!\" : \"+\";\n\t\t\tconst command = truncateToWidth(item.command, Math.max(1, width - 6), \"...\");\n\t\t\tconst color = item.status === \"error\" ? colors.error : item.status === \"done\" ? colors.success : colors.warning;\n\t\t\tlines.push(...renderLine(` ${paint(color, marker)} ${paint(colors.dim, command)}`, width));\n\t\t}\n\t\tif (state.streamingText) {\n\t\t\tif (lines.length > 0) lines.push(\" \");\n\t\t\tlines.push(...renderLine(` ${paint(colors.assistant, \"Assistant\", true)}`, width));\n\t\t\tlines.push(...new Markdown(state.streamingText, { paddingX: 4 }).render(width));\n\t\t}\n\t\tconst hasActivity = state.status || state.queue.length > 0 || state.error;\n\t\tif (hasActivity) {\n\t\t\tif (lines.length > 0) lines.push(\" \");\n\t\t\tlines.push(...renderLine(` ${paint(colors.dim, \"ACTIVITY\", true)}`, width));\n\t\t\tif (state.status) lines.push(...renderLine(` ${paint(colors.dim, state.status)}`, width));\n\t\t\tif (state.queue.length > 0) {\n\t\t\t\tlines.push(...renderLine(` ${paint(colors.dim, `Queue (${state.queue.length})`)}`, width));\n\t\t\t\tfor (const prompt of state.queue) lines.push(...new Text(` ${prompt}`).render(width));\n\t\t\t}\n\t\t\tif (state.error)\n\t\t\t\tlines.push(...new Text(` ${paint(colors.error, `Error: ${state.error}`, true)}`).render(width));\n\t\t}\n\t\tconst rendered = lines.flatMap((line) => new Text(line).render(width));\n\t\treturn rendered.length > 0 ? rendered : [\"\"];\n\t}\n}\n\nexport class InteractiveComposer implements Component {\n\tprivate readonly readState: () => InteractiveViewState;\n\n\tconstructor(readState: () => InteractiveViewState) {\n\t\tthis.readState = readState;\n\t}\n\n\tinvalidate(): void {}\n\n\trender(width: number): string[] {\n\t\tconst state = this.readState();\n\t\tconst colors = paletteFor(state.theme);\n\t\tconst copy = width >= 56 ? \"COMPOSE / commands Tab complete\" : \"COMPOSE / commands\";\n\t\treturn [\n\t\t\t...renderLine(paint(colors.dim, \"-\".repeat(Math.max(0, width))), width),\n\t\t\t...renderLine(paint(colors.dim, copy), width),\n\t\t];\n\t}\n}\n\nexport class InteractiveFooter implements Component {\n\tprivate readonly readState: () => InteractiveViewState;\n\n\tconstructor(readState: () => InteractiveViewState) {\n\t\tthis.readState = readState;\n\t}\n\n\tinvalidate(): void {}\n\n\trender(width: number): string[] {\n\t\tconst state = this.readState();\n\t\tconst colors = paletteFor(state.theme);\n\t\tconst activity = activityLabel(state);\n\t\tconst left = paint(activity.color, `* ${activity.text}`, true);\n\t\tconst context = paint(\n\t\t\tcolors.dim,\n\t\t\t`${state.messageItems.length} messages ctx ${formatTokenCount(state.usage.estimatedContextTokens)}/${formatTokenCount(state.usage.contextWindow)} total ${formatTokenCount(state.usage.totalTokens)} tok`,\n\t\t);\n\t\tconst right = paint(colors.dim, `${state.model} ${state.theme}`);\n\t\tconst status = width >= 60 ? alignEnds(`${left} ${context}`, right, width) : `${left} ${right}`;\n\t\tconst hints = width >= 60 ? \"Enter send Esc cancel Ctrl+O model Ctrl+L session\" : \"Enter send Ctrl+O model\";\n\t\treturn [\n\t\t\t...renderLine(paint(colors.dim, \"-\".repeat(Math.max(0, width))), width),\n\t\t\t...renderLine(status, width),\n\t\t\t...renderLine(paint(colors.dim, hints), width),\n\t\t];\n\t}\n}\n\nfunction formatTokenCount(value: number): string {\n\tif (value >= 1_000_000) return `${(value / 1_000_000).toFixed(1)}m`;\n\tif (value >= 1_000) return `${(value / 1_000).toFixed(1)}k`;\n\treturn String(value);\n}\n\nexport interface AutocompleteMenuState {\n\treadonly items: readonly AutocompleteItem[];\n\treadonly index: number;\n}\n\nexport class AutocompleteMenu implements Component {\n\tprivate readonly readState: () => AutocompleteMenuState;\n\n\tconstructor(readState: () => AutocompleteMenuState) {\n\t\tthis.readState = readState;\n\t}\n\n\tinvalidate(): void {}\n\n\trender(width: number): string[] {\n\t\tconst state = this.readState();\n\t\treturn state.items.slice(0, 6).flatMap((item, index) => {\n\t\t\tconst prefix = index === state.index ? \"> \" : \" \";\n\t\t\tconst description = item.description ? ` - ${item.description}` : \"\";\n\t\t\treturn new Text(`${prefix}${item.label}${description}`).render(width);\n\t\t});\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"interactive-components.js","sourceRoot":"","sources":["../../src/modes/interactive-components.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAiB7E,MAAM,KAAK,GAAG,SAAS,CA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Y,SAAsC;QACjD,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;IAC5B,CAAC;IAED,UAAU,KAAU,CAAC;IAErB,MAAM,CAAC,KAAa;QACnB,MAAM,KAAK,GAAG,IAAI,CAAC,SAAS,EAAE,CAAC;QAC/B,OAAO,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE;YACtD,MAAM,MAAM,GAAG,KAAK,KAAK,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC;YACnD,MAAM,WAAW,GAAG,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,MAAM,IAAI,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;YACrE,OAAO,IAAI,IAAI,CAAC,GAAG,MAAM,GAAG,IAAI,CAAC,KAAK,GAAG,WAAW,EAAE,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QACvE,CAAC,CAAC,CAAC;IACJ,CAAC;CACD","sourcesContent":["import type { AutocompleteItem, Component } from \"@di-code/tui\";\nimport { Markdown, Text, truncateToWidth, visibleWidth } from \"@di-code/tui\";\nimport type { InteractiveState } from \"./interactive-state.ts\";\n\nexport interface InteractiveViewState extends InteractiveState {\n\treadonly model: string;\n\treadonly theme: \"dark\" | \"light\";\n}\n\ninterface Palette {\n\treadonly accent: string;\n\treadonly assistant: string;\n\treadonly dim: string;\n\treadonly error: string;\n\treadonly success: string;\n\treadonly warning: string;\n}\n\nconst RESET = \"\\x1b[0m\";\nconst BOLD = \"\\x1b[1m\";\nconst MAX_VISIBLE_TOOL_ITEMS = 6;\nconst SPINNER_FRAMES = [\"|\", \"/\", \"-\", \"\\\\\"] as const;\n\nfunction paletteFor(theme: InteractiveViewState[\"theme\"]): Palette {\n\treturn theme === \"light\"\n\t\t? {\n\t\t\t\taccent: \"\\x1b[38;5;25m\",\n\t\t\t\tassistant: \"\\x1b[38;5;30m\",\n\t\t\t\tdim: \"\\x1b[38;5;242m\",\n\t\t\t\terror: \"\\x1b[38;5;160m\",\n\t\t\t\tsuccess: \"\\x1b[38;5;28m\",\n\t\t\t\twarning: \"\\x1b[38;5;130m\",\n\t\t\t}\n\t\t: {\n\t\t\t\taccent: \"\\x1b[38;5;45m\",\n\t\t\t\tassistant: \"\\x1b[38;5;80m\",\n\t\t\t\tdim: \"\\x1b[38;5;245m\",\n\t\t\t\terror: \"\\x1b[38;5;210m\",\n\t\t\t\tsuccess: \"\\x1b[38;5;114m\",\n\t\t\t\twarning: \"\\x1b[38;5;222m\",\n\t\t\t};\n}\n\nfunction paint(color: string, text: string, bold = false): string {\n\treturn `${color}${bold ? BOLD : \"\"}${text}${RESET}`;\n}\n\nfunction renderLine(text: string, width: number): string[] {\n\treturn new Text(truncateToWidth(text, width, \"\")).render(width);\n}\n\nfunction alignEnds(left: string, right: string, width: number): string {\n\tconst gap = 3;\n\tif (visibleWidth(left) + visibleWidth(right) + gap > width) return truncateToWidth(left, width, \"\");\n\treturn `${left}${\" \".repeat(width - visibleWidth(left) - visibleWidth(right))}${right}`;\n}\n\nfunction activityLabel(state: InteractiveViewState): { readonly text: string; readonly color: string } {\n\tconst colors = paletteFor(state.theme);\n\tif (state.error) return { text: \"ERROR\", color: colors.error };\n\tif (state.compacting) return { text: \"COMPACTING\", color: colors.warning };\n\tif (state.retrying) return { text: \"RETRYING\", color: colors.warning };\n\tif (state.busy) return { text: \"WORKING\", color: colors.accent };\n\treturn { text: \"READY\", color: colors.success };\n}\n\nexport class InteractiveHeader implements Component {\n\tprivate readonly readState: () => InteractiveViewState;\n\n\tconstructor(readState: () => InteractiveViewState) {\n\t\tthis.readState = readState;\n\t}\n\n\tinvalidate(): void {}\n\n\trender(width: number): string[] {\n\t\tconst state = this.readState();\n\t\tconst colors = paletteFor(state.theme);\n\t\tconst brand = paint(colors.accent, \"DI-CODE / INTERACTIVE\", true);\n\t\tconst model = paint(colors.dim, `MODEL ${state.model}`);\n\t\tconst title =\n\t\t\twidth >= 56\n\t\t\t\t? alignEnds(brand, model, width)\n\t\t\t\t: `${paint(colors.accent, \"DI-CODE\", true)} ${paint(colors.dim, state.model)}`;\n\t\treturn [...renderLine(title, width), ...renderLine(paint(colors.dim, \"-\".repeat(Math.max(0, width))), width)];\n\t}\n}\n\nexport class InteractiveChat implements Component {\n\tprivate readonly readState: () => InteractiveViewState;\n\n\tconstructor(readState: () => InteractiveViewState) {\n\t\tthis.readState = readState;\n\t}\n\n\tinvalidate(): void {}\n\n\trender(width: number): string[] {\n\t\tconst state = this.readState();\n\t\tconst lines: string[] = [];\n\t\tconst colors = paletteFor(state.theme);\n\t\tfor (const [index, message] of state.messageItems.entries()) {\n\t\t\tif (index > 0) lines.push(\" \");\n\t\t\tif (message.role === \"user\") {\n\t\t\t\tlines.push(...renderLine(` ${paint(colors.accent, \"You\", true)}`, width));\n\t\t\t\tlines.push(...new Text(` ${message.text}`).render(width));\n\t\t\t} else {\n\t\t\t\tlines.push(...renderLine(` ${paint(colors.assistant, \"Assistant\", true)}`, width));\n\t\t\t\tlines.push(...new Markdown(message.text, { paddingX: 4 }).render(width));\n\t\t\t}\n\t\t}\n\t\tconst toolCount = state.processItems.filter((item) => item.type === \"tool\").length;\n\t\tconst hiddenToolItems = Math.max(0, toolCount - MAX_VISIBLE_TOOL_ITEMS);\n\t\tlet skippedToolItems = 0;\n\t\tfor (const item of state.processItems) {\n\t\t\tif (item.type === \"tool\" && skippedToolItems < hiddenToolItems) {\n\t\t\t\tskippedToolItems += 1;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (item.type === \"tool\" && skippedToolItems === hiddenToolItems && hiddenToolItems > 0) {\n\t\t\t\tlines.push(...renderLine(` ${paint(colors.dim, `${hiddenToolItems} earlier tool updates`)}`, width));\n\t\t\t\tskippedToolItems += 1;\n\t\t\t}\n\t\t\tif (item.type === \"thinking\") {\n\t\t\t\tconst frame = SPINNER_FRAMES[state.spinnerFrame % SPINNER_FRAMES.length] ?? SPINNER_FRAMES[0];\n\t\t\t\tlines.push(...renderLine(` ${paint(colors.accent, `${frame} Thinking`)}`, width));\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tconst marker = item.status === \"running\" ? \">\" : item.status === \"error\" ? \"!\" : \"+\";\n\t\t\tconst command = truncateToWidth(item.command, Math.max(1, width - 6), \"...\");\n\t\t\tconst color = item.status === \"error\" ? colors.error : item.status === \"done\" ? colors.success : colors.warning;\n\t\t\tlines.push(...renderLine(` ${paint(color, marker)} ${paint(colors.dim, command)}`, width));\n\t\t}\n\t\tif (state.busy && !state.processItems.some((item) => item.type === \"thinking\")) {\n\t\t\tconst frame = SPINNER_FRAMES[state.spinnerFrame % SPINNER_FRAMES.length] ?? SPINNER_FRAMES[0];\n\t\t\tlines.push(...renderLine(` ${paint(colors.accent, `${frame} Thinking`)}`, width));\n\t\t}\n\t\tif (state.streamingText) {\n\t\t\tif (lines.length > 0) lines.push(\" \");\n\t\t\tlines.push(...renderLine(` ${paint(colors.assistant, \"Assistant\", true)}`, width));\n\t\t\tlines.push(...new Markdown(state.streamingText, { paddingX: 4 }).render(width));\n\t\t}\n\t\tconst hasActivity = state.status || state.queue.length > 0 || state.error;\n\t\tif (hasActivity) {\n\t\t\tif (lines.length > 0) lines.push(\" \");\n\t\t\tlines.push(...renderLine(` ${paint(colors.dim, \"ACTIVITY\", true)}`, width));\n\t\t\tif (state.status) lines.push(...renderLine(` ${paint(colors.dim, state.status)}`, width));\n\t\t\tif (state.queue.length > 0) {\n\t\t\t\tlines.push(...renderLine(` ${paint(colors.dim, `Queue (${state.queue.length})`)}`, width));\n\t\t\t\tfor (const prompt of state.queue) lines.push(...new Text(` ${prompt}`).render(width));\n\t\t\t}\n\t\t\tif (state.error)\n\t\t\t\tlines.push(...new Text(` ${paint(colors.error, `Error: ${state.error}`, true)}`).render(width));\n\t\t}\n\t\tconst rendered = lines.flatMap((line) => new Text(line).render(width));\n\t\treturn rendered.length > 0 ? rendered : [\"\"];\n\t}\n}\n\nexport class InteractiveComposer implements Component {\n\tprivate readonly readState: () => InteractiveViewState;\n\n\tconstructor(readState: () => InteractiveViewState) {\n\t\tthis.readState = readState;\n\t}\n\n\tinvalidate(): void {}\n\n\trender(width: number): string[] {\n\t\tconst state = this.readState();\n\t\tconst colors = paletteFor(state.theme);\n\t\tconst copy = width >= 56 ? \"COMPOSE / commands Tab complete\" : \"COMPOSE / commands\";\n\t\treturn [\n\t\t\t...renderLine(paint(colors.dim, \"-\".repeat(Math.max(0, width))), width),\n\t\t\t...renderLine(paint(colors.dim, copy), width),\n\t\t];\n\t}\n}\n\nexport class InteractiveFooter implements Component {\n\tprivate readonly readState: () => InteractiveViewState;\n\n\tconstructor(readState: () => InteractiveViewState) {\n\t\tthis.readState = readState;\n\t}\n\n\tinvalidate(): void {}\n\n\trender(width: number): string[] {\n\t\tconst state = this.readState();\n\t\tconst colors = paletteFor(state.theme);\n\t\tconst activity = activityLabel(state);\n\t\tconst left = paint(activity.color, `* ${activity.text}`, true);\n\t\tconst context = paint(\n\t\t\tcolors.dim,\n\t\t\t`${state.messageItems.length} messages ctx ${formatTokenCount(state.usage.estimatedContextTokens)}/${formatTokenCount(state.usage.contextWindow)} total ${formatTokenCount(state.usage.totalTokens)} tok`,\n\t\t);\n\t\tconst right = paint(colors.dim, `${state.model} ${state.theme}`);\n\t\tconst status = width >= 60 ? alignEnds(`${left} ${context}`, right, width) : `${left} ${right}`;\n\t\tconst hints = width >= 60 ? \"Enter send Esc cancel Ctrl+O model Ctrl+L session\" : \"Enter send Ctrl+O model\";\n\t\treturn [\n\t\t\t...renderLine(paint(colors.dim, \"-\".repeat(Math.max(0, width))), width),\n\t\t\t...renderLine(status, width),\n\t\t\t...renderLine(paint(colors.dim, hints), width),\n\t\t];\n\t}\n}\n\nfunction formatTokenCount(value: number): string {\n\tif (value >= 1_000_000) return `${(value / 1_000_000).toFixed(1)}m`;\n\tif (value >= 1_000) return `${(value / 1_000).toFixed(1)}k`;\n\treturn String(value);\n}\n\nexport interface AutocompleteMenuState {\n\treadonly items: readonly AutocompleteItem[];\n\treadonly index: number;\n}\n\nexport class AutocompleteMenu implements Component {\n\tprivate readonly readState: () => AutocompleteMenuState;\n\n\tconstructor(readState: () => AutocompleteMenuState) {\n\t\tthis.readState = readState;\n\t}\n\n\tinvalidate(): void {}\n\n\trender(width: number): string[] {\n\t\tconst state = this.readState();\n\t\treturn state.items.slice(0, 6).flatMap((item, index) => {\n\t\t\tconst prefix = index === state.index ? \"> \" : \" \";\n\t\t\tconst description = item.description ? ` - ${item.description}` : \"\";\n\t\t\treturn new Text(`${prefix}${item.label}${description}`).render(width);\n\t\t});\n\t}\n}\n"]}
|
|
@@ -74,7 +74,7 @@ export class InteractiveProjection {
|
|
|
74
74
|
this.usage = structuredClone(usage);
|
|
75
75
|
}
|
|
76
76
|
advanceSpinner() {
|
|
77
|
-
if (!this.busy
|
|
77
|
+
if (!this.busy)
|
|
78
78
|
return false;
|
|
79
79
|
this.spinnerFrame = (this.spinnerFrame + 1) % 4;
|
|
80
80
|
return true;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interactive-state.js","sourceRoot":"","sources":["../../src/modes/interactive-state.ts"],"names":[],"mappings":"AAiCA,SAAS,MAAM,CAAC,OAAgB;IAE/B,OAAO,OAAO,CAAC,OAAO;SACpB,MAAM,CAAC,CAAC,OAAO,EAAwB,EAAE,CAAC,OAAO,CAAC,IAAI,KAAK,MAAM,CAAC;SAClE,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC;SAC9B,IAAI,CAAC,EAAE,CAAC,CAAC;AACZ,CAAC;AAED,MAAM,OAAO,qBAAqB;IAChB,QAAQ,GAAa,EAAE,CAAC;IACxB,YAAY,GAAyB,EAAE,CAAC;IACxC,YAAY,GAA6B,EAAE,CAAC;IAC5C,UAAU,GAAG,IAAI,GAAG,EAAkB,CAA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,YAAY,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,CAAC,CAAC;QACrD,CAAC;QACD,IAAI,OAAO,CAAC,UAAU,KAAK,OAAO,IAAI,OAAO,CAAC,UAAU,KAAK,SAAS;YAAE,IAAI,CAAC,KAAK,GAAG,OAAO,CAAC,YAAY,CAAC;QAC1G,IAAI,CAAC,aAAa,GAAG,EAAE,CAAC;IACzB,CAAC;CACD;AAED,SAAS,iBAAiB,CAAC,QAAgB,EAAE,cAAuC;IACnF,MAAM,UAAU,GAAG,IAAI,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC;IAClD,OAAO,UAAU,KAAK,IAAI,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,GAAG,QAAQ,IAAI,UAAU,EAAE,CAAC;AACrE,CAAC","sourcesContent":["import type { Message } from \"@di-code/ai\";\nimport type { AgentSessionEvent, SessionUsage } from \"../core/session.ts\";\n\nexport interface InteractiveMessage {\n\treadonly role: \"user\" | \"assistant\";\n\treadonly text: string;\n}\n\nexport type InteractiveProcessItem =\n\t| { readonly type: \"thinking\"; readonly id: \"thinking\" }\n\t| {\n\t\t\treadonly type: \"tool\";\n\t\t\treadonly id: string;\n\t\t\treadonly command: string;\n\t\t\treadonly status: \"running\" | \"done\" | \"error\";\n\t };\n\nexport interface InteractiveState {\n\treadonly messages: readonly string[];\n\treadonly messageItems: readonly InteractiveMessage[];\n\treadonly processItems: readonly InteractiveProcessItem[];\n\treadonly spinnerFrame: number;\n\treadonly streamingText: string;\n\treadonly toolStatus: readonly string[];\n\treadonly busy: boolean;\n\treadonly error?: string;\n\treadonly queue: readonly string[];\n\treadonly status?: string;\n\treadonly compacting: boolean;\n\treadonly retrying: boolean;\n\treadonly usage: SessionUsage;\n}\n\nfunction textOf(message: Message): string {\n\ttype TextBlock = Extract<Message[\"content\"][number], { type: \"text\" }>;\n\treturn message.content\n\t\t.filter((content): content is TextBlock => content.type === \"text\")\n\t\t.map((content) => content.text)\n\t\t.join(\"\");\n}\n\nexport class InteractiveProjection {\n\tprivate readonly messages: string[] = [];\n\tprivate readonly messageItems: InteractiveMessage[] = [];\n\tprivate readonly processItems: InteractiveProcessItem[] = [];\n\tprivate readonly toolStatus = new Map<string, string>();\n\tprivate spinnerFrame = 0;\n\tprivate streamingText = \"\";\n\tprivate busy = false;\n\tprivate error: string | undefined;\n\tprivate queue: string[] = [];\n\tprivate status: string | undefined;\n\tprivate compacting = false;\n\tprivate retrying = false;\n\tprivate usage: SessionUsage = {\n\t\trequestCount: 0,\n\t\tinputTokens: 0,\n\t\toutputTokens: 0,\n\t\tcacheReadTokens: 0,\n\t\tcacheWriteTokens: 0,\n\t\ttotalTokens: 0,\n\t\tcost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, total: 0 },\n\t\testimatedContextTokens: 0,\n\t\tcontextWindow: 0,\n\t\treserveTokens: 0,\n\t\ttriggerTokens: 0,\n\t};\n\n\tget state(): InteractiveState {\n\t\treturn {\n\t\t\tmessages: [...this.messages],\n\t\t\tmessageItems: this.messageItems.map((message) => ({ ...message })),\n\t\t\tprocessItems: this.processItems.map((item) => ({ ...item })),\n\t\t\tspinnerFrame: this.spinnerFrame,\n\t\t\tstreamingText: this.streamingText,\n\t\t\ttoolStatus: [...this.toolStatus.values()],\n\t\t\tbusy: this.busy,\n\t\t\terror: this.error,\n\t\t\tqueue: [...this.queue],\n\t\t\tstatus: this.status,\n\t\t\tcompacting: this.compacting,\n\t\t\tretrying: this.retrying,\n\t\t\tusage: { ...this.usage, cost: { ...this.usage.cost } },\n\t\t};\n\t}\n\n\tsetError(message: string | undefined): void {\n\t\tthis.error = message;\n\t}\n\n\tclearVisibleMessages(): void {\n\t\tthis.messages.length = 0;\n\t\tthis.messageItems.length = 0;\n\t\tthis.streamingText = \"\";\n\t\tthis.processItems.length = 0;\n\t\tthis.toolStatus.clear();\n\t\tthis.error = undefined;\n\t}\n\n\tsetQueue(queue: readonly string[]): void {\n\t\tthis.queue = [...queue];\n\t}\n\n\tsetStatus(status: string | undefined): void {\n\t\tthis.status = status;\n\t}\n\n\tsetCompacting(value: boolean): void {\n\t\tthis.compacting = value;\n\t}\n\n\tsetRetrying(value: boolean): void {\n\t\tthis.retrying = value;\n\t}\n\n\tsetUsage(usage: SessionUsage): void {\n\t\tthis.usage = structuredClone(usage);\n\t}\n\n\tadvanceSpinner(): boolean {\n\t\tif (!this.busy || !this.processItems.some((item) => item.type === \"thinking\")) return false;\n\t\tthis.spinnerFrame = (this.spinnerFrame + 1) % 4;\n\t\treturn true;\n\t}\n\n\tclearTransientProcess(): void {\n\t\tthis.processItems.length = 0;\n\t\tthis.toolStatus.clear();\n\t\tthis.spinnerFrame = 0;\n\t}\n\n\treplaceTranscript(messages: readonly Message[]): void {\n\t\tthis.messages.length = 0;\n\t\tthis.messageItems.length = 0;\n\t\tthis.processItems.length = 0;\n\t\tthis.toolStatus.clear();\n\t\tthis.spinnerFrame = 0;\n\t\tthis.streamingText = \"\";\n\t\tthis.busy = false;\n\t\tthis.error = undefined;\n\t\tfor (const message of messages) this.appendCompletedMessage(message);\n\t}\n\n\tapply(event: AgentSessionEvent): void {\n\t\tswitch (event.type) {\n\t\t\tcase \"agent_start\":\n\t\t\t\tthis.busy = true;\n\t\t\t\tthis.error = undefined;\n\t\t\t\tthis.retrying = false;\n\t\t\t\tthis.processItems.length = 0;\n\t\t\t\tthis.processItems.push({ type: \"thinking\", id: \"thinking\" });\n\t\t\t\tthis.toolStatus.clear();\n\t\t\t\tthis.spinnerFrame = 0;\n\t\t\t\treturn;\n\t\t\tcase \"compaction_start\":\n\t\t\t\tthis.compacting = true;\n\t\t\t\treturn;\n\t\t\tcase \"compaction_end\":\n\t\t\t\tthis.compacting = false;\n\t\t\t\tif (!event.success) this.error = event.errorMessage;\n\t\t\t\treturn;\n\t\t\tcase \"usage_update\":\n\t\t\t\tthis.setUsage(event.usage);\n\t\t\t\treturn;\n\t\t\tcase \"message_start\":\n\t\t\t\tif (event.message.role === \"assistant\") this.streamingText = \"\";\n\t\t\t\treturn;\n\t\t\tcase \"message_update\":\n\t\t\t\tif (event.event.type === \"text_delta\") {\n\t\t\t\t\tthis.removeThinking();\n\t\t\t\t\tthis.streamingText += event.event.delta;\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\tcase \"tool_execution_start\":\n\t\t\t\tthis.removeThinking();\n\t\t\t\tthis.processItems.push({\n\t\t\t\t\ttype: \"tool\",\n\t\t\t\t\tid: event.toolCallId,\n\t\t\t\t\tcommand: formatToolCommand(event.toolName, event.arguments),\n\t\t\t\t\tstatus: \"running\",\n\t\t\t\t});\n\t\t\t\tthis.toolStatus.set(event.toolCallId, `${event.toolName}: running`);\n\t\t\t\treturn;\n\t\t\tcase \"tool_execution_end\":\n\t\t\t\tthis.updateToolStatus(event.toolCallId, event.result.isError ? \"error\" : \"done\");\n\t\t\t\tthis.toolStatus.set(event.toolCallId, `${event.toolName}: ${event.result.isError ? \"error\" : \"done\"}`);\n\t\t\t\treturn;\n\t\t\tcase \"message_end\":\n\t\t\t\tthis.appendCompletedMessage(event.message);\n\t\t\t\treturn;\n\t\t\tcase \"agent_end\":\n\t\t\t\tthis.busy = false;\n\t\t\t\tthis.retrying = false;\n\t\t\t\tthis.processItems.length = 0;\n\t\t\t\tthis.toolStatus.clear();\n\t\t\t\tthis.spinnerFrame = 0;\n\t\t\t\treturn;\n\t\t\tcase \"turn_start\":\n\t\t\t\tif (this.busy && !this.processItems.some((item) => item.type === \"thinking\")) {\n\t\t\t\t\tthis.processItems.push({ type: \"thinking\", id: \"thinking\" });\n\t\t\t\t\tthis.spinnerFrame = 0;\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\tcase \"turn_end\":\n\t\t\t\treturn;\n\t\t}\n\t}\n\n\tprivate removeThinking(): void {\n\t\tconst index = this.processItems.findIndex((item) => item.type === \"thinking\");\n\t\tif (index >= 0) this.processItems.splice(index, 1);\n\t}\n\n\tprivate updateToolStatus(id: string, status: \"done\" | \"error\"): void {\n\t\tconst index = this.processItems.findIndex((item) => item.type === \"tool\" && item.id === id);\n\t\tconst item = this.processItems[index];\n\t\tif (index < 0 || item?.type !== \"tool\") return;\n\t\tthis.processItems[index] = { ...item, status };\n\t}\n\n\tprivate appendCompletedMessage(message: Message): void {\n\t\tif (message.role === \"tool_result\") return;\n\t\tconst text = textOf(message);\n\t\tif (message.role === \"user\") {\n\t\t\tif (text.length > 0) {\n\t\t\t\tthis.messages.push(text);\n\t\t\t\tthis.messageItems.push({ role: \"user\", text });\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\t\tif (text.length > 0 && message.stopReason !== \"tool_use\") {\n\t\t\tthis.messages.push(text);\n\t\t\tthis.messageItems.push({ role: \"assistant\", text });\n\t\t}\n\t\tif (message.stopReason === \"error\" || message.stopReason === \"aborted\") this.error = message.errorMessage;\n\t\tthis.streamingText = \"\";\n\t}\n}\n\nfunction formatToolCommand(toolName: string, argumentsValue: Record<string, unknown>): string {\n\tconst serialized = JSON.stringify(argumentsValue);\n\treturn serialized === \"{}\" ? toolName : `${toolName} ${serialized}`;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"interactive-state.js","sourceRoot":"","sources":["../../src/modes/interactive-state.ts"],"names":[],"mappings":"AAiCA,SAAS,MAAM,CAAC,OAAgB;IAE/B,OAAO,OAAO,CAAC,OAAO;SACpB,MAAM,CAAC,CAAC,OAAO,EAAwB,EAAE,CAAC,OAAO,CAAC,IAAI,KAAK,MAAM,CAAC;SAClE,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC;SAC9B,IAAI,CAAC,EAAE,CAAC,CAAC;AACZ,CAAC;AAED,MAAM,OAAO,qBAAqB;IAChB,QAAQ,GAAa,EAAE,CAAC;IACxB,YAAY,GAAyB,EAAE,CAAC;IACxC,YAAY,GAA6B,EAAE,CAAC;IAC5C,UAAU,GAAG,IAAI,GAAG,EAAkB,CAAC;IAChD,YAAY,GAAG,CAAC,CAAC;IAC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,UAAU,KAAK,SAAS;YAAE,IAAI,CAAC,KAAK,GAAG,OAAO,CAAC,YAAY,CAAC;QAC1G,IAAI,CAAC,aAAa,GAAG,EAAE,CAAC;IACzB,CAAC;CACD;AAED,SAAS,iBAAiB,CAAC,QAAgB,EAAE,cAAuC;IACnF,MAAM,UAAU,GAAG,IAAI,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC;IAClD,OAAO,UAAU,KAAK,IAAI,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,GAAG,QAAQ,IAAI,UAAU,EAAE,CAAC;AACrE,CAAC","sourcesContent":["import type { Message } from \"@di-code/ai\";\nimport type { AgentSessionEvent, SessionUsage } from \"../core/session.ts\";\n\nexport interface InteractiveMessage {\n\treadonly role: \"user\" | \"assistant\";\n\treadonly text: string;\n}\n\nexport type InteractiveProcessItem =\n\t| { readonly type: \"thinking\"; readonly id: \"thinking\" }\n\t| {\n\t\t\treadonly type: \"tool\";\n\t\t\treadonly id: string;\n\t\t\treadonly command: string;\n\t\t\treadonly status: \"running\" | \"done\" | \"error\";\n\t };\n\nexport interface InteractiveState {\n\treadonly messages: readonly string[];\n\treadonly messageItems: readonly InteractiveMessage[];\n\treadonly processItems: readonly InteractiveProcessItem[];\n\treadonly spinnerFrame: number;\n\treadonly streamingText: string;\n\treadonly toolStatus: readonly string[];\n\treadonly busy: boolean;\n\treadonly error?: string;\n\treadonly queue: readonly string[];\n\treadonly status?: string;\n\treadonly compacting: boolean;\n\treadonly retrying: boolean;\n\treadonly usage: SessionUsage;\n}\n\nfunction textOf(message: Message): string {\n\ttype TextBlock = Extract<Message[\"content\"][number], { type: \"text\" }>;\n\treturn message.content\n\t\t.filter((content): content is TextBlock => content.type === \"text\")\n\t\t.map((content) => content.text)\n\t\t.join(\"\");\n}\n\nexport class InteractiveProjection {\n\tprivate readonly messages: string[] = [];\n\tprivate readonly messageItems: InteractiveMessage[] = [];\n\tprivate readonly processItems: InteractiveProcessItem[] = [];\n\tprivate readonly toolStatus = new Map<string, string>();\n\tprivate spinnerFrame = 0;\n\tprivate streamingText = \"\";\n\tprivate busy = false;\n\tprivate error: string | undefined;\n\tprivate queue: string[] = [];\n\tprivate status: string | undefined;\n\tprivate compacting = false;\n\tprivate retrying = false;\n\tprivate usage: SessionUsage = {\n\t\trequestCount: 0,\n\t\tinputTokens: 0,\n\t\toutputTokens: 0,\n\t\tcacheReadTokens: 0,\n\t\tcacheWriteTokens: 0,\n\t\ttotalTokens: 0,\n\t\tcost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, total: 0 },\n\t\testimatedContextTokens: 0,\n\t\tcontextWindow: 0,\n\t\treserveTokens: 0,\n\t\ttriggerTokens: 0,\n\t};\n\n\tget state(): InteractiveState {\n\t\treturn {\n\t\t\tmessages: [...this.messages],\n\t\t\tmessageItems: this.messageItems.map((message) => ({ ...message })),\n\t\t\tprocessItems: this.processItems.map((item) => ({ ...item })),\n\t\t\tspinnerFrame: this.spinnerFrame,\n\t\t\tstreamingText: this.streamingText,\n\t\t\ttoolStatus: [...this.toolStatus.values()],\n\t\t\tbusy: this.busy,\n\t\t\terror: this.error,\n\t\t\tqueue: [...this.queue],\n\t\t\tstatus: this.status,\n\t\t\tcompacting: this.compacting,\n\t\t\tretrying: this.retrying,\n\t\t\tusage: { ...this.usage, cost: { ...this.usage.cost } },\n\t\t};\n\t}\n\n\tsetError(message: string | undefined): void {\n\t\tthis.error = message;\n\t}\n\n\tclearVisibleMessages(): void {\n\t\tthis.messages.length = 0;\n\t\tthis.messageItems.length = 0;\n\t\tthis.streamingText = \"\";\n\t\tthis.processItems.length = 0;\n\t\tthis.toolStatus.clear();\n\t\tthis.error = undefined;\n\t}\n\n\tsetQueue(queue: readonly string[]): void {\n\t\tthis.queue = [...queue];\n\t}\n\n\tsetStatus(status: string | undefined): void {\n\t\tthis.status = status;\n\t}\n\n\tsetCompacting(value: boolean): void {\n\t\tthis.compacting = value;\n\t}\n\n\tsetRetrying(value: boolean): void {\n\t\tthis.retrying = value;\n\t}\n\n\tsetUsage(usage: SessionUsage): void {\n\t\tthis.usage = structuredClone(usage);\n\t}\n\n\tadvanceSpinner(): boolean {\n\t\tif (!this.busy) return false;\n\t\tthis.spinnerFrame = (this.spinnerFrame + 1) % 4;\n\t\treturn true;\n\t}\n\n\tclearTransientProcess(): void {\n\t\tthis.processItems.length = 0;\n\t\tthis.toolStatus.clear();\n\t\tthis.spinnerFrame = 0;\n\t}\n\n\treplaceTranscript(messages: readonly Message[]): void {\n\t\tthis.messages.length = 0;\n\t\tthis.messageItems.length = 0;\n\t\tthis.processItems.length = 0;\n\t\tthis.toolStatus.clear();\n\t\tthis.spinnerFrame = 0;\n\t\tthis.streamingText = \"\";\n\t\tthis.busy = false;\n\t\tthis.error = undefined;\n\t\tfor (const message of messages) this.appendCompletedMessage(message);\n\t}\n\n\tapply(event: AgentSessionEvent): void {\n\t\tswitch (event.type) {\n\t\t\tcase \"agent_start\":\n\t\t\t\tthis.busy = true;\n\t\t\t\tthis.error = undefined;\n\t\t\t\tthis.retrying = false;\n\t\t\t\tthis.processItems.length = 0;\n\t\t\t\tthis.processItems.push({ type: \"thinking\", id: \"thinking\" });\n\t\t\t\tthis.toolStatus.clear();\n\t\t\t\tthis.spinnerFrame = 0;\n\t\t\t\treturn;\n\t\t\tcase \"compaction_start\":\n\t\t\t\tthis.compacting = true;\n\t\t\t\treturn;\n\t\t\tcase \"compaction_end\":\n\t\t\t\tthis.compacting = false;\n\t\t\t\tif (!event.success) this.error = event.errorMessage;\n\t\t\t\treturn;\n\t\t\tcase \"usage_update\":\n\t\t\t\tthis.setUsage(event.usage);\n\t\t\t\treturn;\n\t\t\tcase \"message_start\":\n\t\t\t\tif (event.message.role === \"assistant\") this.streamingText = \"\";\n\t\t\t\treturn;\n\t\t\tcase \"message_update\":\n\t\t\t\tif (event.event.type === \"text_delta\") {\n\t\t\t\t\tthis.removeThinking();\n\t\t\t\t\tthis.streamingText += event.event.delta;\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\tcase \"tool_execution_start\":\n\t\t\t\tthis.removeThinking();\n\t\t\t\tthis.processItems.push({\n\t\t\t\t\ttype: \"tool\",\n\t\t\t\t\tid: event.toolCallId,\n\t\t\t\t\tcommand: formatToolCommand(event.toolName, event.arguments),\n\t\t\t\t\tstatus: \"running\",\n\t\t\t\t});\n\t\t\t\tthis.toolStatus.set(event.toolCallId, `${event.toolName}: running`);\n\t\t\t\treturn;\n\t\t\tcase \"tool_execution_end\":\n\t\t\t\tthis.updateToolStatus(event.toolCallId, event.result.isError ? \"error\" : \"done\");\n\t\t\t\tthis.toolStatus.set(event.toolCallId, `${event.toolName}: ${event.result.isError ? \"error\" : \"done\"}`);\n\t\t\t\treturn;\n\t\t\tcase \"message_end\":\n\t\t\t\tthis.appendCompletedMessage(event.message);\n\t\t\t\treturn;\n\t\t\tcase \"agent_end\":\n\t\t\t\tthis.busy = false;\n\t\t\t\tthis.retrying = false;\n\t\t\t\tthis.processItems.length = 0;\n\t\t\t\tthis.toolStatus.clear();\n\t\t\t\tthis.spinnerFrame = 0;\n\t\t\t\treturn;\n\t\t\tcase \"turn_start\":\n\t\t\t\tif (this.busy && !this.processItems.some((item) => item.type === \"thinking\")) {\n\t\t\t\t\tthis.processItems.push({ type: \"thinking\", id: \"thinking\" });\n\t\t\t\t\tthis.spinnerFrame = 0;\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\tcase \"turn_end\":\n\t\t\t\treturn;\n\t\t}\n\t}\n\n\tprivate removeThinking(): void {\n\t\tconst index = this.processItems.findIndex((item) => item.type === \"thinking\");\n\t\tif (index >= 0) this.processItems.splice(index, 1);\n\t}\n\n\tprivate updateToolStatus(id: string, status: \"done\" | \"error\"): void {\n\t\tconst index = this.processItems.findIndex((item) => item.type === \"tool\" && item.id === id);\n\t\tconst item = this.processItems[index];\n\t\tif (index < 0 || item?.type !== \"tool\") return;\n\t\tthis.processItems[index] = { ...item, status };\n\t}\n\n\tprivate appendCompletedMessage(message: Message): void {\n\t\tif (message.role === \"tool_result\") return;\n\t\tconst text = textOf(message);\n\t\tif (message.role === \"user\") {\n\t\t\tif (text.length > 0) {\n\t\t\t\tthis.messages.push(text);\n\t\t\t\tthis.messageItems.push({ role: \"user\", text });\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\t\tif (text.length > 0 && message.stopReason !== \"tool_use\") {\n\t\t\tthis.messages.push(text);\n\t\t\tthis.messageItems.push({ role: \"assistant\", text });\n\t\t}\n\t\tif (message.stopReason === \"error\" || message.stopReason === \"aborted\") this.error = message.errorMessage;\n\t\tthis.streamingText = \"\";\n\t}\n}\n\nfunction formatToolCommand(toolName: string, argumentsValue: Record<string, unknown>): string {\n\tconst serialized = JSON.stringify(argumentsValue);\n\treturn serialized === \"{}\" ? toolName : `${toolName} ${serialized}`;\n}\n"]}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { type TUI } from "@di-code/tui";
|
|
2
2
|
import type { AgentSession, AgentSessionEvent } from "../core/session.ts";
|
|
3
|
+
import type { ExtensionHost } from "../extensions/runtime.ts";
|
|
3
4
|
export type { AgentSessionEvent };
|
|
4
5
|
export type { InteractiveMessage, InteractiveProcessItem, InteractiveState } from "./interactive-state.ts";
|
|
5
6
|
export { InteractiveProjection } from "./interactive-state.ts";
|
|
@@ -8,6 +9,7 @@ export interface InteractiveModeOptions {
|
|
|
8
9
|
readonly tui: TUI;
|
|
9
10
|
readonly onExit?: () => void;
|
|
10
11
|
readonly sessions?: readonly InteractiveSessionChoice[];
|
|
12
|
+
readonly extensionHost?: ExtensionHost;
|
|
11
13
|
}
|
|
12
14
|
export interface InteractiveSessionChoice {
|
|
13
15
|
readonly id: string;
|
|
@@ -22,6 +24,7 @@ export declare class InteractiveMode {
|
|
|
22
24
|
private session;
|
|
23
25
|
private readonly tui;
|
|
24
26
|
private readonly sessionChoices;
|
|
27
|
+
private readonly extensionHost?;
|
|
25
28
|
private unsubscribeSession?;
|
|
26
29
|
private sessionSwitching;
|
|
27
30
|
private promptInFlight;
|
|
@@ -35,6 +38,7 @@ export declare class InteractiveMode {
|
|
|
35
38
|
private overlay?;
|
|
36
39
|
private autocompleteOverlay?;
|
|
37
40
|
private spinnerTimer?;
|
|
41
|
+
private shutdownEmitted;
|
|
38
42
|
constructor(options: InteractiveModeOptions);
|
|
39
43
|
start(initialPrompt?: string): void;
|
|
40
44
|
stop(): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interactive.d.ts","sourceRoot":"","sources":["../../src/modes/interactive.ts"],"names":[],"mappings":"AAAA,OAAO,EAON,KAAK,GAAG,EACR,MAAM,cAAc,CAAC;AACtB,OAAO,KAAK,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"interactive.d.ts","sourceRoot":"","sources":["../../src/modes/interactive.ts"],"names":[],"mappings":"AAAA,OAAO,EAON,KAAK,GAAG,EACR,MAAM,cAAc,CAAC;AACtB,OAAO,KAAK,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAC1E,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAY9D,YAAY,EAAE,iBAAiB,EAAE,CAAC;AAClC,YAAY,EAAE,kBAAkB,EAAE,sBAAsB,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC3G,OAAO,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AAE/D,MAAM,WAAW,sBAAsB;IACtC,QAAQ,CAAC,OAAO,EAAE,YAAY,CAAC;IAC/B,QAAQ,CAAC,GAAG,EAAE,GAAG,CAAC;IAClB,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC;IAC7B,QAAQ,CAAC,QAAQ,CAAC,EAAE,SAAS,wBAAwB,EAAE,CAAC;IACxD,QAAQ,CAAC,aAAa,CAAC,EAAE,aAAa,CAAC;CACvC;AAED,MAAM,WAAW,wBAAwB;IACxC,QAAQ,CAAC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BzB,OAAO,CAAC,mBAAmB;IA6B3B,OAAO,CAAC,oBAAoB;IA+B5B,OAAO,CAAC,WAAW;IAYnB,OAAO,CAAC,YAAY;IAKpB,OAAO,CAAC,yBAAyB;IAoBjC,OAAO,CAAC,wBAAwB;IAKhC,OAAO,CAAC,OAAO;IAKf,OAAO,CAAC,iBAAiB;IAQzB,OAAO,CAAC,gBAAgB;IAKxB,OAAO,CAAC,kBAAkB;YASZ,aAAa;YA4Bb,MAAM;IAgDpB,OAAO,CAAC,kBAAkB;IAiD1B,OAAO,CAAC,WAAW;YAKL,mBAAmB;CAmBjC"}
|
|
@@ -10,6 +10,7 @@ export class InteractiveMode {
|
|
|
10
10
|
session;
|
|
11
11
|
tui;
|
|
12
12
|
sessionChoices;
|
|
13
|
+
extensionHost;
|
|
13
14
|
unsubscribeSession;
|
|
14
15
|
sessionSwitching = false;
|
|
15
16
|
promptInFlight = false;
|
|
@@ -23,11 +24,13 @@ export class InteractiveMode {
|
|
|
23
24
|
overlay;
|
|
24
25
|
autocompleteOverlay;
|
|
25
26
|
spinnerTimer;
|
|
27
|
+
shutdownEmitted = false;
|
|
26
28
|
constructor(options) {
|
|
27
29
|
this.session = options.session;
|
|
28
30
|
this.tui = options.tui;
|
|
29
31
|
this.onExit = options.onExit;
|
|
30
32
|
this.sessionChoices = [...(options.sessions ?? [])];
|
|
33
|
+
this.extensionHost = options.extensionHost;
|
|
31
34
|
const commands = [
|
|
32
35
|
{ name: "help", description: "Show interactive commands" },
|
|
33
36
|
{ name: "clear", description: "Clear visible messages" },
|
|
@@ -39,9 +42,10 @@ export class InteractiveMode {
|
|
|
39
42
|
{ name: "usage", description: "Show token and cost usage" },
|
|
40
43
|
{ name: "retry", description: "Retry the last failed prompt" },
|
|
41
44
|
];
|
|
45
|
+
const allCommands = [...commands, ...(this.extensionHost?.listCommands() ?? [])];
|
|
42
46
|
const autocomplete = {
|
|
43
|
-
getSuggestions: (context, autocompleteOptions) => new CombinedAutocompleteProvider(
|
|
44
|
-
applyCompletion: (context, item, prefix) => new CombinedAutocompleteProvider(
|
|
47
|
+
getSuggestions: (context, autocompleteOptions) => new CombinedAutocompleteProvider(allCommands, this.session.allowedRoot).getSuggestions(context, autocompleteOptions),
|
|
48
|
+
applyCompletion: (context, item, prefix) => new CombinedAutocompleteProvider(allCommands, this.session.allowedRoot).applyCompletion(context, item, prefix),
|
|
45
49
|
};
|
|
46
50
|
this.editor = new Editor({
|
|
47
51
|
maxHeight: 3,
|
|
@@ -71,6 +75,8 @@ export class InteractiveMode {
|
|
|
71
75
|
if (this.started)
|
|
72
76
|
throw new Error("Interactive mode is already started");
|
|
73
77
|
this.started = true;
|
|
78
|
+
this.shutdownEmitted = false;
|
|
79
|
+
void this.extensionHost?.emit({ type: "session_start", cwd: this.session.allowedRoot });
|
|
74
80
|
this.projection.replaceTranscript(this.session.transcript);
|
|
75
81
|
this.projection.setUsage(this.session.usage);
|
|
76
82
|
this.subscribeToSession();
|
|
@@ -100,6 +106,10 @@ export class InteractiveMode {
|
|
|
100
106
|
this.unsubscribeSession?.();
|
|
101
107
|
this.unsubscribeSession = undefined;
|
|
102
108
|
this.tui.stop({ finalLines: this.root.renderTranscript(this.tui.columns) });
|
|
109
|
+
if (!this.shutdownEmitted) {
|
|
110
|
+
this.shutdownEmitted = true;
|
|
111
|
+
void this.extensionHost?.emit({ type: "session_shutdown", reason: "user" });
|
|
112
|
+
}
|
|
103
113
|
}
|
|
104
114
|
exit() {
|
|
105
115
|
this.stop();
|
|
@@ -369,7 +379,10 @@ export class InteractiveMode {
|
|
|
369
379
|
}
|
|
370
380
|
}
|
|
371
381
|
handleSlashCommand(input) {
|
|
372
|
-
const
|
|
382
|
+
const trimmed = input.slice(1).trim();
|
|
383
|
+
const [rawCommand = "", ...argParts] = trimmed.split(/\s+/);
|
|
384
|
+
const command = rawCommand.toLowerCase();
|
|
385
|
+
const args = argParts.join(" ");
|
|
373
386
|
switch (command) {
|
|
374
387
|
case "help":
|
|
375
388
|
this.projection.setStatus("commands: /clear /model /session /theme /settings /compact /usage /retry");
|
|
@@ -402,8 +415,16 @@ export class InteractiveMode {
|
|
|
402
415
|
else
|
|
403
416
|
this.projection.setStatus("nothing to retry");
|
|
404
417
|
break;
|
|
405
|
-
default:
|
|
406
|
-
this.
|
|
418
|
+
default: {
|
|
419
|
+
if (this.extensionHost?.listCommands().some((entry) => entry.name === command)) {
|
|
420
|
+
void this.extensionHost.runCommand(command, args).catch((cause) => {
|
|
421
|
+
this.projection.setError(cause instanceof Error ? cause.message : String(cause));
|
|
422
|
+
this.refresh();
|
|
423
|
+
});
|
|
424
|
+
break;
|
|
425
|
+
}
|
|
426
|
+
this.projection.setError(`Unknown command: /${command}`);
|
|
427
|
+
}
|
|
407
428
|
}
|
|
408
429
|
this.refresh();
|
|
409
430
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interactive.js","sourceRoot":"","sources":["../../src/modes/interactive.ts"],"names":[],"mappings":"AAAA,OAAO,EAEN,4BAA4B,EAC5B,MAAM,EAEN,UAAU,EACV,YAAY,GAEZ,MAAM,cAAc,CAAC;AAEtB,OAAO,EACN,gBAAgB,EAChB,eAAe,EACf,mBAAmB,EACnB,iBAAiB,EACjB,iBAAiB,GAEjB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AAI/D,OAAO,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AAgB/D,MAAM,OAAO,eAAe;IACV,UAAU,GAAG,IAAI,qBAAqB,EAAE,CAAC;IACzC,IAAI,CAAoB;IACxB,MAAM,CAAS;IACxB,OAAO,CAAe;IACb,GAAG,CAAM;IACT,cAAc,CAAsC;IAC7D,kBAAkB,CAAc;IAChC,gBAAgB,GAAG,KAAK,CAAC;IACzB,cAAc,GAAG,KAAK,CAAC;IACvB,kBAAkB,GAAG,KAAK,CAAC;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AAI,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC;YAC7B,IAAI,CAAC,UAAU,CAAC,SAAS,CAAC,4BAA4B,CAAC,CAAC;QACzD,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YAChB,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;QAClF,CAAC;gBAAS,CAAC;YACV,IAAI,CAAC,kBAAkB,GAAG,KAAK,CAAC;YAChC,IAAI,CAAC,OAAO,EAAE,CAAC;QAChB,CAAC;IACF,CAAC;CACD","sourcesContent":["import {\n\ttype AutocompleteProvider,\n\tCombinedAutocompleteProvider,\n\tEditor,\n\ttype OverlayHandle,\n\tSelectList,\n\tSettingsList,\n\ttype TUI,\n} from \"@di-code/tui\";\nimport type { AgentSession, AgentSessionEvent } from \"../core/session.ts\";\nimport {\n\tAutocompleteMenu,\n\tInteractiveChat,\n\tInteractiveComposer,\n\tInteractiveFooter,\n\tInteractiveHeader,\n\ttype InteractiveViewState,\n} from \"./interactive-components.ts\";\nimport { InteractiveLayout } from \"./interactive-layout.ts\";\nimport { InteractiveProjection } from \"./interactive-state.ts\";\n\nexport type { AgentSessionEvent };\nexport type { InteractiveMessage, InteractiveProcessItem, InteractiveState } from \"./interactive-state.ts\";\nexport { InteractiveProjection } from \"./interactive-state.ts\";\n\nexport interface InteractiveModeOptions {\n\treadonly session: AgentSession;\n\treadonly tui: TUI;\n\treadonly onExit?: () => void;\n\treadonly sessions?: readonly InteractiveSessionChoice[];\n}\n\nexport interface InteractiveSessionChoice {\n\treadonly id: string;\n\treadonly label: string;\n\treadonly description?: string;\n\topen(): AgentSession | Promise<AgentSession>;\n}\n\nexport class InteractiveMode {\n\tprivate readonly projection = new InteractiveProjection();\n\tprivate readonly root: InteractiveLayout;\n\tprivate readonly editor: Editor;\n\tprivate session: AgentSession;\n\tprivate readonly tui: TUI;\n\tprivate readonly sessionChoices: readonly InteractiveSessionChoice[];\n\tprivate unsubscribeSession?: () => void;\n\tprivate sessionSwitching = false;\n\tprivate promptInFlight = false;\n\tprivate compactionInFlight = false;\n\tprivate activeAbort?: AbortController;\n\tprivate started = false;\n\tprivate lastFailedPrompt?: string;\n\tprivate queuedPrompts: string[] = [];\n\tprivate readonly onExit?: () => void;\n\tprivate theme: \"dark\" | \"light\" = \"dark\";\n\tprivate overlay?: OverlayHandle;\n\tprivate autocompleteOverlay?: OverlayHandle;\n\tprivate spinnerTimer?: ReturnType<typeof setInterval>;\n\n\tconstructor(options: InteractiveModeOptions) {\n\t\tthis.session = options.session;\n\t\tthis.tui = options.tui;\n\t\tthis.onExit = options.onExit;\n\t\tthis.sessionChoices = [...(options.sessions ?? [])];\n\t\tconst commands = [\n\t\t\t{ name: \"help\", description: \"Show interactive commands\" },\n\t\t\t{ name: \"clear\", description: \"Clear visible messages\" },\n\t\t\t{ name: \"model\", description: \"Open the model selector\" },\n\t\t\t{ name: \"session\", description: \"Open the session selector\" },\n\t\t\t{ name: \"theme\", description: \"Open the theme selector\" },\n\t\t\t{ name: \"settings\", description: \"Open the settings selector\" },\n\t\t\t{ name: \"compact\", description: \"Compact the persisted context now\" },\n\t\t\t{ name: \"usage\", description: \"Show token and cost usage\" },\n\t\t\t{ name: \"retry\", description: \"Retry the last failed prompt\" },\n\t\t] as const;\n\t\tconst autocomplete: AutocompleteProvider = {\n\t\t\tgetSuggestions: (context, autocompleteOptions) =>\n\t\t\t\tnew CombinedAutocompleteProvider(commands, this.session.allowedRoot).getSuggestions(\n\t\t\t\t\tcontext,\n\t\t\t\t\tautocompleteOptions,\n\t\t\t\t),\n\t\t\tapplyCompletion: (context, item, prefix) =>\n\t\t\t\tnew CombinedAutocompleteProvider(commands, this.session.allowedRoot).applyCompletion(context, item, prefix),\n\t\t};\n\t\tthis.editor = new Editor({\n\t\t\tmaxHeight: 3,\n\t\t\tautocomplete,\n\t\t});\n\t\tthis.editor.onSubmit = (text) => void this.submit(text);\n\t\tthis.editor.onEscape = () => this.activeAbort?.abort();\n\t\tthis.editor.onCommand = (data) => this.handleCommand(data);\n\t\tthis.editor.onInterrupt = () => this.exit();\n\t\tthis.editor.onAutocompleteChange = () => this.updateAutocompleteOverlay();\n\t\tconst readViewState = (): InteractiveViewState => ({\n\t\t\t...this.projection.state,\n\t\t\tmodel: this.session.modelId,\n\t\t\ttheme: this.theme,\n\t\t});\n\t\tthis.root = new InteractiveLayout({\n\t\t\theader: new InteractiveHeader(readViewState),\n\t\t\tchat: new InteractiveChat(readViewState),\n\t\t\tcomposer: new InteractiveComposer(readViewState),\n\t\t\teditor: this.editor,\n\t\t\tfooter: new InteractiveFooter(readViewState),\n\t\t});\n\t\tthis.tui.addChild(this.root);\n\t\tthis.tui.setFocus(this.editor);\n\t}\n\n\tstart(initialPrompt?: string): void {\n\t\tif (this.started) throw new Error(\"Interactive mode is already started\");\n\t\tthis.started = true;\n\t\tthis.projection.replaceTranscript(this.session.transcript);\n\t\tthis.projection.setUsage(this.session.usage);\n\t\tthis.subscribeToSession();\n\t\ttry {\n\t\t\tthis.tui.start();\n\t\t} catch (cause) {\n\t\t\tthis.started = false;\n\t\t\tthis.unsubscribeSession?.();\n\t\t\tthis.unsubscribeSession = undefined;\n\t\t\tthrow cause;\n\t\t}\n\t\tthis.startSpinnerTimer();\n\t\tif (initialPrompt?.trim()) void this.submit(initialPrompt);\n\t}\n\n\tstop(): void {\n\t\tif (!this.started && !this.unsubscribeSession) return;\n\t\tthis.started = false;\n\t\tthis.activeAbort?.abort();\n\t\tthis.activeAbort = undefined;\n\t\tthis.stopSpinnerTimer();\n\t\tthis.projection.clearTransientProcess();\n\t\tthis.closeOverlay();\n\t\tthis.closeAutocompleteOverlay();\n\t\tthis.unsubscribeSession?.();\n\t\tthis.unsubscribeSession = undefined;\n\t\tthis.tui.stop({ finalLines: this.root.renderTranscript(this.tui.columns) });\n\t}\n\n\tprivate exit(): void {\n\t\tthis.stop();\n\t\tthis.onExit?.();\n\t}\n\n\tprivate handleCommand(data: string): boolean {\n\t\tif (data === \"\\x14\") {\n\t\t\tthis.openThemeSelector();\n\t\t\treturn true;\n\t\t}\n\t\tif (data === \"\\x13\") {\n\t\t\tthis.openSettingsSelector();\n\t\t\treturn true;\n\t\t}\n\t\tif (data === \"\\x0f\") {\n\t\t\tthis.openModelSelector();\n\t\t\treturn true;\n\t\t}\n\t\tif (data === \"\\x0c\") {\n\t\t\tthis.openSessionSelector();\n\t\t\treturn true;\n\t\t}\n\t\tif (data === \"\\x12\" && this.lastFailedPrompt && !this.promptInFlight) {\n\t\t\tvoid this.submit(this.lastFailedPrompt, true);\n\t\t\treturn true;\n\t\t}\n\t\treturn false;\n\t}\n\n\tprivate openThemeSelector(): void {\n\t\tconst list = new SelectList([\n\t\t\t{ value: \"dark\", label: \"Dark\", description: \"Dark terminal theme\" },\n\t\t\t{ value: \"light\", label: \"Light\", description: \"Light terminal theme\" },\n\t\t]);\n\t\tlist.onSelect = (item) => {\n\t\t\tthis.theme = item.value === \"light\" ? \"light\" : \"dark\";\n\t\t\tthis.projection.setStatus(`theme=${this.theme}`);\n\t\t\tthis.closeOverlay();\n\t\t\tthis.refresh();\n\t\t};\n\t\tlist.onCancel = () => this.closeOverlay();\n\t\tthis.showOverlay(list);\n\t}\n\n\tprivate openModelSelector(): void {\n\t\tconst list = new SelectList(\n\t\t\tthis.session.availableModels.map((model) => ({\n\t\t\t\tvalue: model.id,\n\t\t\t\tlabel: model.name,\n\t\t\t\tdescription: `${model.provider} / ${model.id} / context ${model.contextWindow}`,\n\t\t\t})),\n\t\t);\n\t\tlist.onSelect = (item) => {\n\t\t\ttry {\n\t\t\t\tthis.session.setModel(item.value);\n\t\t\t\tthis.projection.setStatus(`model=${item.value}`);\n\t\t\t\tthis.closeOverlay();\n\t\t\t\tthis.refresh();\n\t\t\t} catch (cause) {\n\t\t\t\tthis.projection.setError(cause instanceof Error ? cause.message : String(cause));\n\t\t\t}\n\t\t};\n\t\tlist.onCancel = () => this.closeOverlay();\n\t\tthis.showOverlay(list);\n\t}\n\n\tprivate openSessionSelector(): void {\n\t\tconst list = new SelectList([\n\t\t\t{\n\t\t\t\tvalue: \"__current__\",\n\t\t\t\tlabel: \"Current session\",\n\t\t\t\tdescription: this.session.sessionFile ?? \"In-memory session\",\n\t\t\t},\n\t\t\t...this.sessionChoices.map((choice) => ({\n\t\t\t\tvalue: choice.id,\n\t\t\t\tlabel: choice.label,\n\t\t\t\t...(choice.description ? { description: choice.description } : {}),\n\t\t\t})),\n\t\t]);\n\t\tlist.onSelect = (item) => {\n\t\t\tif (item.value === \"__current__\") {\n\t\t\t\tthis.projection.setStatus(\"session=current\");\n\t\t\t\tthis.closeOverlay();\n\t\t\t\tthis.refresh();\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst choice = this.sessionChoices.find((candidate) => candidate.id === item.value);\n\t\t\tif (!choice) return;\n\t\t\tthis.closeOverlay();\n\t\t\tvoid this.switchSession(choice);\n\t\t};\n\t\tlist.onCancel = () => this.closeOverlay();\n\t\tthis.showOverlay(list);\n\t}\n\n\tprivate openSettingsSelector(): void {\n\t\tconst list = new SettingsList([\n\t\t\t{\n\t\t\t\tid: \"compaction\",\n\t\t\t\tlabel: \"Context compaction\",\n\t\t\t\tcurrentValue: this.session.compactionEnabled ? \"on\" : \"off\",\n\t\t\t\tvalues: [\"on\", \"off\"],\n\t\t\t\tdescription: \"Summarize older persisted context before the model limit is reached.\",\n\t\t\t},\n\t\t]);\n\t\tlist.onChange = (id, value) => {\n\t\t\tif (id !== \"compaction\") return;\n\t\t\ttry {\n\t\t\t\tconst enabled = this.session.setCompactionEnabled(value === \"on\");\n\t\t\t\tlist.updateValue(id, enabled ? \"on\" : \"off\");\n\t\t\t\tthis.projection.setStatus(\n\t\t\t\t\tenabled === (value === \"on\")\n\t\t\t\t\t\t? `compaction=${enabled ? \"on\" : \"off\"}`\n\t\t\t\t\t\t: \"compaction unavailable without a persisted session\",\n\t\t\t\t);\n\t\t\t} catch (cause) {\n\t\t\t\tlist.updateValue(id, this.session.compactionEnabled ? \"on\" : \"off\");\n\t\t\t\tthis.projection.setError(cause instanceof Error ? cause.message : String(cause));\n\t\t\t\tthis.closeOverlay();\n\t\t\t}\n\t\t\tthis.refresh();\n\t\t};\n\t\tlist.onCancel = () => this.closeOverlay();\n\t\tthis.showOverlay(list);\n\t}\n\n\tprivate showOverlay(component: SelectList | SettingsList): void {\n\t\tthis.editor.cancelAutocomplete();\n\t\tthis.closeAutocompleteOverlay();\n\t\tthis.closeOverlay();\n\t\tthis.overlay = this.tui.showOverlay(component, {\n\t\t\twidth: \"70%\",\n\t\t\tmaxHeight: \"60%\",\n\t\t\tanchor: \"center\",\n\t\t\tmargin: 1,\n\t\t});\n\t}\n\n\tprivate closeOverlay(): void {\n\t\tthis.overlay?.hide();\n\t\tthis.overlay = undefined;\n\t}\n\n\tprivate updateAutocompleteOverlay(): void {\n\t\tthis.closeAutocompleteOverlay();\n\t\tif (!this.editor.isShowingAutocomplete()) {\n\t\t\tthis.refresh();\n\t\t\treturn;\n\t\t}\n\t\tconst menu = new AutocompleteMenu(() => ({\n\t\t\titems: this.editor.getAutocompleteItems(),\n\t\t\tindex: this.editor.getAutocompleteIndex(),\n\t\t}));\n\t\tthis.autocompleteOverlay = this.tui.showOverlay(menu, {\n\t\t\twidth: \"55%\",\n\t\t\tmaxHeight: 8,\n\t\t\tanchor: \"bottom-left\",\n\t\t\tmargin: 1,\n\t\t\tnonCapturing: true,\n\t\t});\n\t\tthis.refresh();\n\t}\n\n\tprivate closeAutocompleteOverlay(): void {\n\t\tthis.autocompleteOverlay?.hide();\n\t\tthis.autocompleteOverlay = undefined;\n\t}\n\n\tprivate refresh(): void {\n\t\tthis.root.invalidate();\n\t\tthis.tui.requestRender();\n\t}\n\n\tprivate startSpinnerTimer(): void {\n\t\tthis.stopSpinnerTimer();\n\t\tthis.spinnerTimer = setInterval(() => {\n\t\t\tif (this.projection.advanceSpinner()) this.refresh();\n\t\t}, 120);\n\t\tthis.spinnerTimer.unref?.();\n\t}\n\n\tprivate stopSpinnerTimer(): void {\n\t\tif (this.spinnerTimer) clearInterval(this.spinnerTimer);\n\t\tthis.spinnerTimer = undefined;\n\t}\n\n\tprivate subscribeToSession(): void {\n\t\tthis.unsubscribeSession?.();\n\t\tthis.unsubscribeSession = this.session.subscribeSession((event) => {\n\t\t\tif (!this.started) return;\n\t\t\tthis.projection.apply(event);\n\t\t\tthis.refresh();\n\t\t});\n\t}\n\n\tprivate async switchSession(choice: InteractiveSessionChoice): Promise<void> {\n\t\tif (this.promptInFlight || this.sessionSwitching) {\n\t\t\tthis.projection.setError(\"Cannot switch sessions while a prompt is running.\");\n\t\t\tthis.refresh();\n\t\t\treturn;\n\t\t}\n\t\tthis.sessionSwitching = true;\n\t\tthis.projection.setStatus(`opening session=${choice.id}`);\n\t\tthis.refresh();\n\t\ttry {\n\t\t\tconst next = await choice.open();\n\t\t\tif (!this.started) return;\n\t\t\tthis.unsubscribeSession?.();\n\t\t\tthis.session = next;\n\t\t\tthis.queuedPrompts = [];\n\t\t\tthis.projection.setQueue([]);\n\t\t\tthis.projection.replaceTranscript(next.transcript);\n\t\t\tthis.projection.setUsage(next.usage);\n\t\t\tthis.projection.setStatus(`session=${choice.id}`);\n\t\t\tthis.subscribeToSession();\n\t\t} catch (cause) {\n\t\t\tthis.projection.setError(cause instanceof Error ? cause.message : String(cause));\n\t\t} finally {\n\t\t\tthis.sessionSwitching = false;\n\t\t}\n\t\tthis.refresh();\n\t}\n\n\tprivate async submit(text: string, retry = false): Promise<void> {\n\t\tconst prompt = text.trim();\n\t\tif (prompt.length === 0 || !this.started) return;\n\t\tif (prompt.startsWith(\"/\")) {\n\t\t\tthis.editor.setValue(\"\");\n\t\t\tthis.handleSlashCommand(prompt);\n\t\t\treturn;\n\t\t}\n\t\tif (this.sessionSwitching) {\n\t\t\tthis.projection.setError(\"A session is opening; wait before submitting a prompt.\");\n\t\t\tthis.refresh();\n\t\t\treturn;\n\t\t}\n\t\tif (this.compactionInFlight) {\n\t\t\tthis.projection.setError(\"A compaction is running; wait before submitting a prompt.\");\n\t\t\tthis.refresh();\n\t\t\treturn;\n\t\t}\n\t\tif (this.promptInFlight) {\n\t\t\tthis.queuedPrompts.push(prompt);\n\t\t\tthis.projection.setQueue(this.queuedPrompts);\n\t\t\tthis.root.invalidate();\n\t\t\tthis.tui.requestRender();\n\t\t\treturn;\n\t\t}\n\t\tthis.promptInFlight = true;\n\t\tthis.activeAbort = new AbortController();\n\t\tthis.projection.setRetrying(retry);\n\t\tthis.editor.setValue(\"\");\n\t\ttry {\n\t\t\tconst result = await this.session.prompt(prompt, this.activeAbort.signal);\n\t\t\tif (result.stopReason === \"error\" || result.stopReason === \"aborted\") this.lastFailedPrompt = prompt;\n\t\t\telse this.lastFailedPrompt = undefined;\n\t\t} catch (cause) {\n\t\t\tthis.lastFailedPrompt = prompt;\n\t\t\tthis.projection.setError(cause instanceof Error ? cause.message : String(cause));\n\t\t} finally {\n\t\t\tthis.promptInFlight = false;\n\t\t\tthis.activeAbort = undefined;\n\t\t\tthis.projection.setRetrying(false);\n\t\t\tconst next = this.queuedPrompts.shift();\n\t\t\tthis.projection.setQueue(this.queuedPrompts);\n\t\t\tthis.root.invalidate();\n\t\t\tthis.tui.requestRender();\n\t\t\tif (next && this.started) void this.submit(next);\n\t\t}\n\t}\n\n\tprivate handleSlashCommand(input: string): void {\n\t\tconst command = input.slice(1).trim().split(/\\s+/, 1)[0]?.toLowerCase();\n\t\tswitch (command) {\n\t\t\tcase \"help\":\n\t\t\t\tthis.projection.setStatus(\"commands: /clear /model /session /theme /settings /compact /usage /retry\");\n\t\t\t\tbreak;\n\t\t\tcase \"clear\":\n\t\t\t\tthis.projection.clearVisibleMessages();\n\t\t\t\tthis.projection.setStatus(\"visible messages cleared\");\n\t\t\t\tbreak;\n\t\t\tcase \"model\":\n\t\t\t\tthis.openModelSelector();\n\t\t\t\treturn;\n\t\t\tcase \"session\":\n\t\t\t\tthis.openSessionSelector();\n\t\t\t\treturn;\n\t\t\tcase \"theme\":\n\t\t\t\tthis.openThemeSelector();\n\t\t\t\treturn;\n\t\t\tcase \"settings\":\n\t\t\t\tthis.openSettingsSelector();\n\t\t\t\treturn;\n\t\t\tcase \"compact\":\n\t\t\t\tvoid this.runManualCompaction();\n\t\t\t\treturn;\n\t\t\tcase \"usage\":\n\t\t\t\tthis.projection.setStatus(this.formatUsage());\n\t\t\t\tbreak;\n\t\t\tcase \"retry\":\n\t\t\t\tif (this.lastFailedPrompt && !this.promptInFlight) void this.submit(this.lastFailedPrompt, true);\n\t\t\t\telse this.projection.setStatus(\"nothing to retry\");\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tthis.projection.setError(`Unknown command: /${command ?? \"\"}`);\n\t\t}\n\t\tthis.refresh();\n\t}\n\n\tprivate formatUsage(): string {\n\t\tconst usage = this.session.usage;\n\t\treturn `usage: requests=${usage.requestCount} input=${usage.inputTokens} output=${usage.outputTokens} total=${usage.totalTokens} cost=$${usage.cost.total.toFixed(4)} context=${usage.estimatedContextTokens}/${usage.contextWindow}`;\n\t}\n\n\tprivate async runManualCompaction(): Promise<void> {\n\t\tif (this.promptInFlight || this.compactionInFlight) {\n\t\t\tthis.projection.setError(\"Cannot compact while a prompt is running.\");\n\t\t\tthis.refresh();\n\t\t\treturn;\n\t\t}\n\t\tthis.compactionInFlight = true;\n\t\tthis.projection.setStatus(\"starting manual compaction\");\n\t\tthis.refresh();\n\t\ttry {\n\t\t\tawait this.session.compact();\n\t\t\tthis.projection.setStatus(\"manual compaction complete\");\n\t\t} catch (cause) {\n\t\t\tthis.projection.setError(cause instanceof Error ? cause.message : String(cause));\n\t\t} finally {\n\t\t\tthis.compactionInFlight = false;\n\t\t\tthis.refresh();\n\t\t}\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"interactive.js","sourceRoot":"","sources":["../../src/modes/interactive.ts"],"names":[],"mappings":"AAA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\tSettingsList,\n\ttype TUI,\n} from \"@di-code/tui\";\nimport type { AgentSession, AgentSessionEvent } from \"../core/session.ts\";\nimport type { ExtensionHost } from \"../extensions/runtime.ts\";\nimport {\n\tAutocompleteMenu,\n\tInteractiveChat,\n\tInteractiveComposer,\n\tInteractiveFooter,\n\tInteractiveHeader,\n\ttype InteractiveViewState,\n} from \"./interactive-components.ts\";\nimport { InteractiveLayout } from \"./interactive-layout.ts\";\nimport { InteractiveProjection } from \"./interactive-state.ts\";\n\nexport type { AgentSessionEvent };\nexport type { InteractiveMessage, InteractiveProcessItem, InteractiveState } from \"./interactive-state.ts\";\nexport { InteractiveProjection } from \"./interactive-state.ts\";\n\nexport interface InteractiveModeOptions {\n\treadonly session: AgentSession;\n\treadonly tui: TUI;\n\treadonly onExit?: () => void;\n\treadonly sessions?: readonly InteractiveSessionChoice[];\n\treadonly extensionHost?: ExtensionHost;\n}\n\nexport interface InteractiveSessionChoice {\n\treadonly id: string;\n\treadonly label: string;\n\treadonly description?: string;\n\topen(): AgentSession | Promise<AgentSession>;\n}\n\nexport class InteractiveMode {\n\tprivate readonly projection = new InteractiveProjection();\n\tprivate readonly root: InteractiveLayout;\n\tprivate readonly editor: Editor;\n\tprivate session: AgentSession;\n\tprivate readonly tui: TUI;\n\tprivate readonly sessionChoices: readonly InteractiveSessionChoice[];\n\tprivate readonly extensionHost?: ExtensionHost;\n\tprivate unsubscribeSession?: () => void;\n\tprivate sessionSwitching = false;\n\tprivate promptInFlight = false;\n\tprivate compactionInFlight = false;\n\tprivate activeAbort?: AbortController;\n\tprivate started = false;\n\tprivate lastFailedPrompt?: string;\n\tprivate queuedPrompts: string[] = [];\n\tprivate readonly onExit?: () => void;\n\tprivate theme: \"dark\" | \"light\" = \"dark\";\n\tprivate overlay?: OverlayHandle;\n\tprivate autocompleteOverlay?: OverlayHandle;\n\tprivate spinnerTimer?: ReturnType<typeof setInterval>;\n\tprivate shutdownEmitted = false;\n\n\tconstructor(options: InteractiveModeOptions) {\n\t\tthis.session = options.session;\n\t\tthis.tui = options.tui;\n\t\tthis.onExit = options.onExit;\n\t\tthis.sessionChoices = [...(options.sessions ?? [])];\n\t\tthis.extensionHost = options.extensionHost;\n\t\tconst commands = [\n\t\t\t{ name: \"help\", description: \"Show interactive commands\" },\n\t\t\t{ name: \"clear\", description: \"Clear visible messages\" },\n\t\t\t{ name: \"model\", description: \"Open the model selector\" },\n\t\t\t{ name: \"session\", description: \"Open the session selector\" },\n\t\t\t{ name: \"theme\", description: \"Open the theme selector\" },\n\t\t\t{ name: \"settings\", description: \"Open the settings selector\" },\n\t\t\t{ name: \"compact\", description: \"Compact the persisted context now\" },\n\t\t\t{ name: \"usage\", description: \"Show token and cost usage\" },\n\t\t\t{ name: \"retry\", description: \"Retry the last failed prompt\" },\n\t\t] as const;\n\t\tconst allCommands = [...commands, ...(this.extensionHost?.listCommands() ?? [])];\n\t\tconst autocomplete: AutocompleteProvider = {\n\t\t\tgetSuggestions: (context, autocompleteOptions) =>\n\t\t\t\tnew CombinedAutocompleteProvider(allCommands, this.session.allowedRoot).getSuggestions(\n\t\t\t\t\tcontext,\n\t\t\t\t\tautocompleteOptions,\n\t\t\t\t),\n\t\t\tapplyCompletion: (context, item, prefix) =>\n\t\t\t\tnew CombinedAutocompleteProvider(allCommands, this.session.allowedRoot).applyCompletion(context, item, prefix),\n\t\t};\n\t\tthis.editor = new Editor({\n\t\t\tmaxHeight: 3,\n\t\t\tautocomplete,\n\t\t});\n\t\tthis.editor.onSubmit = (text) => void this.submit(text);\n\t\tthis.editor.onEscape = () => this.activeAbort?.abort();\n\t\tthis.editor.onCommand = (data) => this.handleCommand(data);\n\t\tthis.editor.onInterrupt = () => this.exit();\n\t\tthis.editor.onAutocompleteChange = () => this.updateAutocompleteOverlay();\n\t\tconst readViewState = (): InteractiveViewState => ({\n\t\t\t...this.projection.state,\n\t\t\tmodel: this.session.modelId,\n\t\t\ttheme: this.theme,\n\t\t});\n\t\tthis.root = new InteractiveLayout({\n\t\t\theader: new InteractiveHeader(readViewState),\n\t\t\tchat: new InteractiveChat(readViewState),\n\t\t\tcomposer: new InteractiveComposer(readViewState),\n\t\t\teditor: this.editor,\n\t\t\tfooter: new InteractiveFooter(readViewState),\n\t\t});\n\t\tthis.tui.addChild(this.root);\n\t\tthis.tui.setFocus(this.editor);\n\t}\n\n\tstart(initialPrompt?: string): void {\n\t\tif (this.started) throw new Error(\"Interactive mode is already started\");\n\t\tthis.started = true;\n\t\tthis.shutdownEmitted = false;\n\t\tvoid this.extensionHost?.emit({ type: \"session_start\", cwd: this.session.allowedRoot });\n\t\tthis.projection.replaceTranscript(this.session.transcript);\n\t\tthis.projection.setUsage(this.session.usage);\n\t\tthis.subscribeToSession();\n\t\ttry {\n\t\t\tthis.tui.start();\n\t\t} catch (cause) {\n\t\t\tthis.started = false;\n\t\t\tthis.unsubscribeSession?.();\n\t\t\tthis.unsubscribeSession = undefined;\n\t\t\tthrow cause;\n\t\t}\n\t\tthis.startSpinnerTimer();\n\t\tif (initialPrompt?.trim()) void this.submit(initialPrompt);\n\t}\n\n\tstop(): void {\n\t\tif (!this.started && !this.unsubscribeSession) return;\n\t\tthis.started = false;\n\t\tthis.activeAbort?.abort();\n\t\tthis.activeAbort = undefined;\n\t\tthis.stopSpinnerTimer();\n\t\tthis.projection.clearTransientProcess();\n\t\tthis.closeOverlay();\n\t\tthis.closeAutocompleteOverlay();\n\t\tthis.unsubscribeSession?.();\n\t\tthis.unsubscribeSession = undefined;\n\t\tthis.tui.stop({ finalLines: this.root.renderTranscript(this.tui.columns) });\n\t\tif (!this.shutdownEmitted) {\n\t\t\tthis.shutdownEmitted = true;\n\t\t\tvoid this.extensionHost?.emit({ type: \"session_shutdown\", reason: \"user\" });\n\t\t}\n\t}\n\n\tprivate exit(): void {\n\t\tthis.stop();\n\t\tthis.onExit?.();\n\t}\n\n\tprivate handleCommand(data: string): boolean {\n\t\tif (data === \"\\x14\") {\n\t\t\tthis.openThemeSelector();\n\t\t\treturn true;\n\t\t}\n\t\tif (data === \"\\x13\") {\n\t\t\tthis.openSettingsSelector();\n\t\t\treturn true;\n\t\t}\n\t\tif (data === \"\\x0f\") {\n\t\t\tthis.openModelSelector();\n\t\t\treturn true;\n\t\t}\n\t\tif (data === \"\\x0c\") {\n\t\t\tthis.openSessionSelector();\n\t\t\treturn true;\n\t\t}\n\t\tif (data === \"\\x12\" && this.lastFailedPrompt && !this.promptInFlight) {\n\t\t\tvoid this.submit(this.lastFailedPrompt, true);\n\t\t\treturn true;\n\t\t}\n\t\treturn false;\n\t}\n\n\tprivate openThemeSelector(): void {\n\t\tconst list = new SelectList([\n\t\t\t{ value: \"dark\", label: \"Dark\", description: \"Dark terminal theme\" },\n\t\t\t{ value: \"light\", label: \"Light\", description: \"Light terminal theme\" },\n\t\t]);\n\t\tlist.onSelect = (item) => {\n\t\t\tthis.theme = item.value === \"light\" ? \"light\" : \"dark\";\n\t\t\tthis.projection.setStatus(`theme=${this.theme}`);\n\t\t\tthis.closeOverlay();\n\t\t\tthis.refresh();\n\t\t};\n\t\tlist.onCancel = () => this.closeOverlay();\n\t\tthis.showOverlay(list);\n\t}\n\n\tprivate openModelSelector(): void {\n\t\tconst list = new SelectList(\n\t\t\tthis.session.availableModels.map((model) => ({\n\t\t\t\tvalue: model.id,\n\t\t\t\tlabel: model.name,\n\t\t\t\tdescription: `${model.provider} / ${model.id} / context ${model.contextWindow}`,\n\t\t\t})),\n\t\t);\n\t\tlist.onSelect = (item) => {\n\t\t\ttry {\n\t\t\t\tthis.session.setModel(item.value);\n\t\t\t\tthis.projection.setStatus(`model=${item.value}`);\n\t\t\t\tthis.closeOverlay();\n\t\t\t\tthis.refresh();\n\t\t\t} catch (cause) {\n\t\t\t\tthis.projection.setError(cause instanceof Error ? cause.message : String(cause));\n\t\t\t}\n\t\t};\n\t\tlist.onCancel = () => this.closeOverlay();\n\t\tthis.showOverlay(list);\n\t}\n\n\tprivate openSessionSelector(): void {\n\t\tconst list = new SelectList([\n\t\t\t{\n\t\t\t\tvalue: \"__current__\",\n\t\t\t\tlabel: \"Current session\",\n\t\t\t\tdescription: this.session.sessionFile ?? \"In-memory session\",\n\t\t\t},\n\t\t\t...this.sessionChoices.map((choice) => ({\n\t\t\t\tvalue: choice.id,\n\t\t\t\tlabel: choice.label,\n\t\t\t\t...(choice.description ? { description: choice.description } : {}),\n\t\t\t})),\n\t\t]);\n\t\tlist.onSelect = (item) => {\n\t\t\tif (item.value === \"__current__\") {\n\t\t\t\tthis.projection.setStatus(\"session=current\");\n\t\t\t\tthis.closeOverlay();\n\t\t\t\tthis.refresh();\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst choice = this.sessionChoices.find((candidate) => candidate.id === item.value);\n\t\t\tif (!choice) return;\n\t\t\tthis.closeOverlay();\n\t\t\tvoid this.switchSession(choice);\n\t\t};\n\t\tlist.onCancel = () => this.closeOverlay();\n\t\tthis.showOverlay(list);\n\t}\n\n\tprivate openSettingsSelector(): void {\n\t\tconst list = new SettingsList([\n\t\t\t{\n\t\t\t\tid: \"compaction\",\n\t\t\t\tlabel: \"Context compaction\",\n\t\t\t\tcurrentValue: this.session.compactionEnabled ? \"on\" : \"off\",\n\t\t\t\tvalues: [\"on\", \"off\"],\n\t\t\t\tdescription: \"Summarize older persisted context before the model limit is reached.\",\n\t\t\t},\n\t\t]);\n\t\tlist.onChange = (id, value) => {\n\t\t\tif (id !== \"compaction\") return;\n\t\t\ttry {\n\t\t\t\tconst enabled = this.session.setCompactionEnabled(value === \"on\");\n\t\t\t\tlist.updateValue(id, enabled ? \"on\" : \"off\");\n\t\t\t\tthis.projection.setStatus(\n\t\t\t\t\tenabled === (value === \"on\")\n\t\t\t\t\t\t? `compaction=${enabled ? \"on\" : \"off\"}`\n\t\t\t\t\t\t: \"compaction unavailable without a persisted session\",\n\t\t\t\t);\n\t\t\t} catch (cause) {\n\t\t\t\tlist.updateValue(id, this.session.compactionEnabled ? \"on\" : \"off\");\n\t\t\t\tthis.projection.setError(cause instanceof Error ? cause.message : String(cause));\n\t\t\t\tthis.closeOverlay();\n\t\t\t}\n\t\t\tthis.refresh();\n\t\t};\n\t\tlist.onCancel = () => this.closeOverlay();\n\t\tthis.showOverlay(list);\n\t}\n\n\tprivate showOverlay(component: SelectList | SettingsList): void {\n\t\tthis.editor.cancelAutocomplete();\n\t\tthis.closeAutocompleteOverlay();\n\t\tthis.closeOverlay();\n\t\tthis.overlay = this.tui.showOverlay(component, {\n\t\t\twidth: \"70%\",\n\t\t\tmaxHeight: \"60%\",\n\t\t\tanchor: \"center\",\n\t\t\tmargin: 1,\n\t\t});\n\t}\n\n\tprivate closeOverlay(): void {\n\t\tthis.overlay?.hide();\n\t\tthis.overlay = undefined;\n\t}\n\n\tprivate updateAutocompleteOverlay(): void {\n\t\tthis.closeAutocompleteOverlay();\n\t\tif (!this.editor.isShowingAutocomplete()) {\n\t\t\tthis.refresh();\n\t\t\treturn;\n\t\t}\n\t\tconst menu = new AutocompleteMenu(() => ({\n\t\t\titems: this.editor.getAutocompleteItems(),\n\t\t\tindex: this.editor.getAutocompleteIndex(),\n\t\t}));\n\t\tthis.autocompleteOverlay = this.tui.showOverlay(menu, {\n\t\t\twidth: \"55%\",\n\t\t\tmaxHeight: 8,\n\t\t\tanchor: \"bottom-left\",\n\t\t\tmargin: 1,\n\t\t\tnonCapturing: true,\n\t\t});\n\t\tthis.refresh();\n\t}\n\n\tprivate closeAutocompleteOverlay(): void {\n\t\tthis.autocompleteOverlay?.hide();\n\t\tthis.autocompleteOverlay = undefined;\n\t}\n\n\tprivate refresh(): void {\n\t\tthis.root.invalidate();\n\t\tthis.tui.requestRender();\n\t}\n\n\tprivate startSpinnerTimer(): void {\n\t\tthis.stopSpinnerTimer();\n\t\tthis.spinnerTimer = setInterval(() => {\n\t\t\tif (this.projection.advanceSpinner()) this.refresh();\n\t\t}, 120);\n\t\tthis.spinnerTimer.unref?.();\n\t}\n\n\tprivate stopSpinnerTimer(): void {\n\t\tif (this.spinnerTimer) clearInterval(this.spinnerTimer);\n\t\tthis.spinnerTimer = undefined;\n\t}\n\n\tprivate subscribeToSession(): void {\n\t\tthis.unsubscribeSession?.();\n\t\tthis.unsubscribeSession = this.session.subscribeSession((event) => {\n\t\t\tif (!this.started) return;\n\t\t\tthis.projection.apply(event);\n\t\t\tthis.refresh();\n\t\t});\n\t}\n\n\tprivate async switchSession(choice: InteractiveSessionChoice): Promise<void> {\n\t\tif (this.promptInFlight || this.sessionSwitching) {\n\t\t\tthis.projection.setError(\"Cannot switch sessions while a prompt is running.\");\n\t\t\tthis.refresh();\n\t\t\treturn;\n\t\t}\n\t\tthis.sessionSwitching = true;\n\t\tthis.projection.setStatus(`opening session=${choice.id}`);\n\t\tthis.refresh();\n\t\ttry {\n\t\t\tconst next = await choice.open();\n\t\t\tif (!this.started) return;\n\t\t\tthis.unsubscribeSession?.();\n\t\t\tthis.session = next;\n\t\t\tthis.queuedPrompts = [];\n\t\t\tthis.projection.setQueue([]);\n\t\t\tthis.projection.replaceTranscript(next.transcript);\n\t\t\tthis.projection.setUsage(next.usage);\n\t\t\tthis.projection.setStatus(`session=${choice.id}`);\n\t\t\tthis.subscribeToSession();\n\t\t} catch (cause) {\n\t\t\tthis.projection.setError(cause instanceof Error ? cause.message : String(cause));\n\t\t} finally {\n\t\t\tthis.sessionSwitching = false;\n\t\t}\n\t\tthis.refresh();\n\t}\n\n\tprivate async submit(text: string, retry = false): Promise<void> {\n\t\tconst prompt = text.trim();\n\t\tif (prompt.length === 0 || !this.started) return;\n\t\tif (prompt.startsWith(\"/\")) {\n\t\t\tthis.editor.setValue(\"\");\n\t\t\tthis.handleSlashCommand(prompt);\n\t\t\treturn;\n\t\t}\n\t\tif (this.sessionSwitching) {\n\t\t\tthis.projection.setError(\"A session is opening; wait before submitting a prompt.\");\n\t\t\tthis.refresh();\n\t\t\treturn;\n\t\t}\n\t\tif (this.compactionInFlight) {\n\t\t\tthis.projection.setError(\"A compaction is running; wait before submitting a prompt.\");\n\t\t\tthis.refresh();\n\t\t\treturn;\n\t\t}\n\t\tif (this.promptInFlight) {\n\t\t\tthis.queuedPrompts.push(prompt);\n\t\t\tthis.projection.setQueue(this.queuedPrompts);\n\t\t\tthis.root.invalidate();\n\t\t\tthis.tui.requestRender();\n\t\t\treturn;\n\t\t}\n\t\tthis.promptInFlight = true;\n\t\tthis.activeAbort = new AbortController();\n\t\tthis.projection.setRetrying(retry);\n\t\tthis.editor.setValue(\"\");\n\t\ttry {\n\t\t\tconst result = await this.session.prompt(prompt, this.activeAbort.signal);\n\t\t\tif (result.stopReason === \"error\" || result.stopReason === \"aborted\") this.lastFailedPrompt = prompt;\n\t\t\telse this.lastFailedPrompt = undefined;\n\t\t} catch (cause) {\n\t\t\tthis.lastFailedPrompt = prompt;\n\t\t\tthis.projection.setError(cause instanceof Error ? cause.message : String(cause));\n\t\t} finally {\n\t\t\tthis.promptInFlight = false;\n\t\t\tthis.activeAbort = undefined;\n\t\t\tthis.projection.setRetrying(false);\n\t\t\tconst next = this.queuedPrompts.shift();\n\t\t\tthis.projection.setQueue(this.queuedPrompts);\n\t\t\tthis.root.invalidate();\n\t\t\tthis.tui.requestRender();\n\t\t\tif (next && this.started) void this.submit(next);\n\t\t}\n\t}\n\n\tprivate handleSlashCommand(input: string): void {\n\t\tconst trimmed = input.slice(1).trim();\n\t\tconst [rawCommand = \"\", ...argParts] = trimmed.split(/\\s+/);\n\t\tconst command = rawCommand.toLowerCase();\n\t\tconst args = argParts.join(\" \");\n\t\tswitch (command) {\n\t\t\tcase \"help\":\n\t\t\t\tthis.projection.setStatus(\"commands: /clear /model /session /theme /settings /compact /usage /retry\");\n\t\t\t\tbreak;\n\t\t\tcase \"clear\":\n\t\t\t\tthis.projection.clearVisibleMessages();\n\t\t\t\tthis.projection.setStatus(\"visible messages cleared\");\n\t\t\t\tbreak;\n\t\t\tcase \"model\":\n\t\t\t\tthis.openModelSelector();\n\t\t\t\treturn;\n\t\t\tcase \"session\":\n\t\t\t\tthis.openSessionSelector();\n\t\t\t\treturn;\n\t\t\tcase \"theme\":\n\t\t\t\tthis.openThemeSelector();\n\t\t\t\treturn;\n\t\t\tcase \"settings\":\n\t\t\t\tthis.openSettingsSelector();\n\t\t\t\treturn;\n\t\t\tcase \"compact\":\n\t\t\t\tvoid this.runManualCompaction();\n\t\t\t\treturn;\n\t\t\tcase \"usage\":\n\t\t\t\tthis.projection.setStatus(this.formatUsage());\n\t\t\t\tbreak;\n\t\t\tcase \"retry\":\n\t\t\t\tif (this.lastFailedPrompt && !this.promptInFlight) void this.submit(this.lastFailedPrompt, true);\n\t\t\t\telse this.projection.setStatus(\"nothing to retry\");\n\t\t\t\tbreak;\n\t\t\tdefault: {\n\t\t\t\tif (this.extensionHost?.listCommands().some((entry) => entry.name === command)) {\n\t\t\t\t\tvoid this.extensionHost.runCommand(command, args).catch((cause) => {\n\t\t\t\t\t\tthis.projection.setError(cause instanceof Error ? cause.message : String(cause));\n\t\t\t\t\t\tthis.refresh();\n\t\t\t\t\t});\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tthis.projection.setError(`Unknown command: /${command}`);\n\t\t\t}\n\t\t}\n\t\tthis.refresh();\n\t}\n\n\tprivate formatUsage(): string {\n\t\tconst usage = this.session.usage;\n\t\treturn `usage: requests=${usage.requestCount} input=${usage.inputTokens} output=${usage.outputTokens} total=${usage.totalTokens} cost=$${usage.cost.total.toFixed(4)} context=${usage.estimatedContextTokens}/${usage.contextWindow}`;\n\t}\n\n\tprivate async runManualCompaction(): Promise<void> {\n\t\tif (this.promptInFlight || this.compactionInFlight) {\n\t\t\tthis.projection.setError(\"Cannot compact while a prompt is running.\");\n\t\t\tthis.refresh();\n\t\t\treturn;\n\t\t}\n\t\tthis.compactionInFlight = true;\n\t\tthis.projection.setStatus(\"starting manual compaction\");\n\t\tthis.refresh();\n\t\ttry {\n\t\t\tawait this.session.compact();\n\t\t\tthis.projection.setStatus(\"manual compaction complete\");\n\t\t} catch (cause) {\n\t\t\tthis.projection.setError(cause instanceof Error ? cause.message : String(cause));\n\t\t} finally {\n\t\t\tthis.compactionInFlight = false;\n\t\t\tthis.refresh();\n\t\t}\n\t}\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/plugins/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,YAAY,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/plugins/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,YAAY,CAAC","sourcesContent":["export * from \"./loader.ts\";\nexport * from \"./manager.ts\";\nexport * from \"./manifest.ts\";\nexport * from \"./types.ts\";\n"]}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { type ExtensionHost } from "../extensions/runtime.ts";
|
|
2
|
+
import type { ProjectTrustManager } from "../extensions/trust.ts";
|
|
3
|
+
import type { DiscoveredPlugin, PluginDiagnostic } from "./types.ts";
|
|
4
|
+
export interface PluginLoadOptions {
|
|
5
|
+
readonly cwd: string;
|
|
6
|
+
readonly agentDir?: string;
|
|
7
|
+
readonly projectTrusted?: boolean;
|
|
8
|
+
readonly trustManager?: ProjectTrustManager;
|
|
9
|
+
readonly mode?: "interactive" | "print" | "json";
|
|
10
|
+
readonly explicitPaths?: readonly string[];
|
|
11
|
+
}
|
|
12
|
+
export interface PluginLoadResult {
|
|
13
|
+
readonly host: ExtensionHost;
|
|
14
|
+
readonly loaded: readonly DiscoveredPlugin[];
|
|
15
|
+
readonly diagnostics: readonly PluginDiagnostic[];
|
|
16
|
+
}
|
|
17
|
+
export declare function loadPlugins(options: PluginLoadOptions): Promise<PluginLoadResult>;
|
|
18
|
+
//# sourceMappingURL=loader.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loader.d.ts","sourceRoot":"","sources":["../../src/plugins/loader.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,aAAa,EAAkB,MAAM,0BAA0B,CAAC;AAC9E,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAIlE,OAAO,KAAK,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAErE,MAAM,WAAW,iBAAiB;IACjC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,cAAc,CAAC,EAAE,OAAO,CAAC;IAClC,QAAQ,CAAC,YAAY,CAAC,EAAE,mBAAmB,CAAC;IAC5C,QAAQ,CAAC,IAAI,CAAC,EAAE,aAAa,GAAG,OAAO,GAAG,MAAM,CAAC;IACjD,QAAQ,CAAC,aAAa,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;CAC3C;AAED,MAAM,WAAW,gBAAgB;IAChC,QAAQ,CAAC,IAAI,EAAE,aAAa,CAAC;IAC7B,QAAQ,CAAC,MAAM,EAAE,SAAS,gBAAgB,EAAE,CAAC;IAC7C,QAAQ,CAAC,WAAW,EAAE,SAAS,gBAAgB,EAAE,CAAC;CAClD;AA0BD,wBAAsB,WAAW,CAAC,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAyDvF"}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { existsSync } from "node:fs";
|
|
2
|
+
import { readdir, readFile } from "node:fs/promises";
|
|
3
|
+
import { join, resolve } from "node:path";
|
|
4
|
+
import { createJiti } from "jiti";
|
|
5
|
+
import { loadExtensions } from "../extensions/runtime.js";
|
|
6
|
+
import { PluginManager } from "./manager.js";
|
|
7
|
+
import { readPackagePluginManifest, readPluginManifest, resolvePluginEntry } from "./manifest.js";
|
|
8
|
+
async function isPluginPackage(root) {
|
|
9
|
+
try {
|
|
10
|
+
const parsed = JSON.parse(await readFile(join(root, "package.json"), "utf8"));
|
|
11
|
+
return typeof parsed === "object" && parsed !== null && "diCode" in parsed;
|
|
12
|
+
}
|
|
13
|
+
catch {
|
|
14
|
+
return false;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
async function discoverPluginRoots(cwd, agentDir, trusted) {
|
|
18
|
+
const roots = [...(trusted ? [join(cwd, ".di-code", "plugins")] : []), join(agentDir, "plugins", "installed")];
|
|
19
|
+
const result = [];
|
|
20
|
+
for (const root of roots) {
|
|
21
|
+
if (!existsSync(root))
|
|
22
|
+
continue;
|
|
23
|
+
for (const entry of await readdir(root, { withFileTypes: true })) {
|
|
24
|
+
if (!entry.isDirectory())
|
|
25
|
+
continue;
|
|
26
|
+
const pluginRoot = join(root, entry.name);
|
|
27
|
+
if (existsSync(join(pluginRoot, "plugin.json")) || (await isPluginPackage(pluginRoot)))
|
|
28
|
+
result.push(resolve(pluginRoot));
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
return result.sort((a, b) => a.localeCompare(b));
|
|
32
|
+
}
|
|
33
|
+
export async function loadPlugins(options) {
|
|
34
|
+
const cwd = resolve(options.cwd);
|
|
35
|
+
const agentDir = resolve(options.agentDir ?? join(cwd, ".di-code"));
|
|
36
|
+
const trusted = options.projectTrusted ?? (options.trustManager ? (await options.trustManager.get(cwd)) === true : false);
|
|
37
|
+
const extensionResult = await loadExtensions({
|
|
38
|
+
cwd,
|
|
39
|
+
projectTrusted: trusted,
|
|
40
|
+
trustManager: options.trustManager,
|
|
41
|
+
mode: options.mode,
|
|
42
|
+
paths: options.explicitPaths,
|
|
43
|
+
});
|
|
44
|
+
const diagnostics = extensionResult.diagnostics.map((diagnostic) => ({
|
|
45
|
+
sourcePath: diagnostic.path,
|
|
46
|
+
stage: diagnostic.stage,
|
|
47
|
+
severity: "error",
|
|
48
|
+
message: diagnostic.message,
|
|
49
|
+
}));
|
|
50
|
+
const enabledGlobal = new Set((await new PluginManager({ agentDir }).list()).filter((plugin) => plugin.enabled).map((plugin) => plugin.id));
|
|
51
|
+
const pluginRoots = await discoverPluginRoots(cwd, agentDir, trusted);
|
|
52
|
+
const loaded = [];
|
|
53
|
+
const jiti = createJiti(import.meta.url, { moduleCache: false });
|
|
54
|
+
for (const root of pluginRoots) {
|
|
55
|
+
const manifestPath = join(root, "plugin.json");
|
|
56
|
+
let manifest;
|
|
57
|
+
try {
|
|
58
|
+
manifest = await readPluginManifest(manifestPath).catch(async () => readPackagePluginManifest(root));
|
|
59
|
+
}
|
|
60
|
+
catch (cause) {
|
|
61
|
+
diagnostics.push({
|
|
62
|
+
sourcePath: manifestPath,
|
|
63
|
+
stage: "manifest",
|
|
64
|
+
severity: "error",
|
|
65
|
+
message: cause instanceof Error ? cause.message : String(cause),
|
|
66
|
+
});
|
|
67
|
+
continue;
|
|
68
|
+
}
|
|
69
|
+
const projectLocal = root.startsWith(resolve(cwd, ".di-code", "plugins"));
|
|
70
|
+
if (!projectLocal && !enabledGlobal.has(manifest.id))
|
|
71
|
+
continue;
|
|
72
|
+
try {
|
|
73
|
+
const entry = await resolvePluginEntry(root, manifest.entry);
|
|
74
|
+
const module = await jiti.import(entry);
|
|
75
|
+
if (typeof module.default !== "function")
|
|
76
|
+
throw new Error("plugin entry must export a default factory function");
|
|
77
|
+
await extensionResult.host.registerExtension(entry, module.default, manifest.id);
|
|
78
|
+
loaded.push({ manifest, root, sourcePath: manifestPath, projectLocal });
|
|
79
|
+
}
|
|
80
|
+
catch (cause) {
|
|
81
|
+
diagnostics.push({
|
|
82
|
+
pluginId: manifest.id,
|
|
83
|
+
sourcePath: manifestPath,
|
|
84
|
+
stage: "import",
|
|
85
|
+
severity: "error",
|
|
86
|
+
message: cause instanceof Error ? cause.message : String(cause),
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
return { host: extensionResult.host, loaded, diagnostics };
|
|
91
|
+
}
|
|
92
|
+
//# sourceMappingURL=loader.js.map
|