@bastani/atomic 0.9.5-alpha.6 → 0.9.5-alpha.8
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 +35 -2
- package/dist/builtin/cursor/package.json +2 -2
- package/dist/builtin/intercom/CHANGELOG.md +17 -0
- package/dist/builtin/intercom/README.md +27 -21
- package/dist/builtin/intercom/broker/broker.ts +3 -6
- package/dist/builtin/intercom/broker/paths.ts +42 -5
- package/dist/builtin/intercom/broker/spawn.ts +78 -10
- package/dist/builtin/intercom/config.ts +6 -3
- package/dist/builtin/intercom/contact-supervisor-tool.ts +6 -4
- package/dist/builtin/intercom/index-heavy.ts +1 -1
- package/dist/builtin/intercom/index.ts +162 -130
- package/dist/builtin/intercom/intercom-tool.ts +9 -3
- package/dist/builtin/intercom/package.json +10 -1
- package/dist/builtin/intercom/result-renderers.ts +1 -1
- package/dist/builtin/intercom/ui/compose.ts +2 -2
- package/dist/builtin/intercom/ui/inline-message.ts +2 -2
- package/dist/builtin/intercom/ui/session-list.ts +2 -2
- package/dist/builtin/mcp/package.json +1 -1
- package/dist/builtin/subagents/CHANGELOG.md +6 -0
- package/dist/builtin/subagents/package.json +1 -1
- package/dist/builtin/subagents/src/tui/render-event-formatting.ts +15 -48
- package/dist/builtin/subagents/src/tui/render-layout.ts +9 -0
- package/dist/builtin/subagents/src/tui/render-widget-graph.ts +27 -25
- package/dist/builtin/subagents/src/tui/render-widget.ts +46 -69
- package/dist/builtin/subagents/src/tui/render.ts +1 -1
- package/dist/builtin/web-access/package.json +1 -1
- package/dist/builtin/workflows/CHANGELOG.md +11 -0
- package/dist/builtin/workflows/README.md +3 -1
- package/dist/builtin/workflows/builtin/goal-artifacts.ts +3 -1
- package/dist/builtin/workflows/builtin/goal-prompts.ts +23 -2
- package/dist/builtin/workflows/builtin/goal-reducer.ts +21 -0
- package/dist/builtin/workflows/builtin/goal-review.ts +60 -6
- package/dist/builtin/workflows/builtin/goal-runner.ts +32 -21
- package/dist/builtin/workflows/builtin/goal-types.ts +7 -1
- package/dist/builtin/workflows/builtin/ralph-core.ts +52 -4
- package/dist/builtin/workflows/builtin/ralph-review-gate.ts +10 -3
- package/dist/builtin/workflows/builtin/ralph-reviewer-prompt.ts +23 -2
- package/dist/builtin/workflows/builtin/ralph-runner.ts +38 -16
- package/dist/builtin/workflows/builtin/review-convergence.ts +111 -0
- package/dist/builtin/workflows/package.json +1 -1
- package/dist/builtin/workflows/skills/create-spec/SKILL.md +2 -0
- package/dist/builtin/workflows/src/durable/child-primitive.ts +12 -8
- package/dist/builtin/workflows/src/durable/dbos-backend.ts +47 -2
- package/dist/builtin/workflows/src/durable/dbos-envelope.ts +28 -0
- package/dist/builtin/workflows/src/durable/stage-primitive.ts +165 -27
- package/dist/builtin/workflows/src/durable/types.ts +14 -1
- package/dist/builtin/workflows/src/engine/run.ts +12 -13
- package/dist/builtin/workflows/src/extension/workflow-prompts.ts +2 -0
- package/dist/builtin/workflows/src/runs/foreground/executor-continuation.ts +13 -3
- package/dist/builtin/workflows/src/runs/foreground/executor-stage-factory.ts +1 -1
- package/dist/builtin/workflows/src/runs/foreground/stage-runner-controller.ts +18 -19
- package/dist/builtin/workflows/src/runs/foreground/stage-runner-unresolved-overflow.ts +38 -0
- package/dist/builtin/workflows/src/shared/persistence-restore-helpers.ts +18 -1
- package/dist/builtin/workflows/src/shared/persistence-restore.ts +23 -5
- package/dist/builtin/workflows/src/shared/persistence-session-entries.ts +4 -0
- package/dist/bun/internal-intercom-broker.d.ts +6 -0
- package/dist/bun/internal-intercom-broker.d.ts.map +1 -0
- package/dist/bun/internal-intercom-broker.js +39 -0
- package/dist/bun/internal-intercom-broker.js.map +1 -0
- package/dist/bun/split-loader.d.ts +2 -0
- package/dist/bun/split-loader.d.ts.map +1 -0
- package/dist/bun/split-loader.js +50 -0
- package/dist/bun/split-loader.js.map +1 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +6 -4
- package/dist/config.js.map +1 -1
- package/dist/core/agent-session-auto-compaction.d.ts +7 -7
- package/dist/core/agent-session-auto-compaction.d.ts.map +1 -1
- package/dist/core/agent-session-auto-compaction.js +62 -16
- package/dist/core/agent-session-auto-compaction.js.map +1 -1
- package/dist/core/agent-session-events.d.ts.map +1 -1
- package/dist/core/agent-session-events.js +3 -1
- package/dist/core/agent-session-events.js.map +1 -1
- package/dist/core/agent-session-extension-bindings.d.ts.map +1 -1
- package/dist/core/agent-session-extension-bindings.js +1 -1
- package/dist/core/agent-session-extension-bindings.js.map +1 -1
- package/dist/core/agent-session-methods.d.ts +10 -4
- package/dist/core/agent-session-methods.d.ts.map +1 -1
- package/dist/core/agent-session-methods.js.map +1 -1
- package/dist/core/agent-session-models.d.ts +2 -2
- package/dist/core/agent-session-models.d.ts.map +1 -1
- package/dist/core/agent-session-models.js.map +1 -1
- package/dist/core/agent-session-prompt.d.ts.map +1 -1
- package/dist/core/agent-session-prompt.js +1 -0
- package/dist/core/agent-session-prompt.js.map +1 -1
- package/dist/core/agent-session-retry.d.ts +2 -0
- package/dist/core/agent-session-retry.d.ts.map +1 -1
- package/dist/core/agent-session-retry.js +152 -4
- package/dist/core/agent-session-retry.js.map +1 -1
- package/dist/core/agent-session-services.d.ts +1 -0
- package/dist/core/agent-session-services.d.ts.map +1 -1
- package/dist/core/agent-session-services.js +1 -0
- package/dist/core/agent-session-services.js.map +1 -1
- package/dist/core/agent-session-types.d.ts +15 -1
- package/dist/core/agent-session-types.d.ts.map +1 -1
- package/dist/core/agent-session-types.js.map +1 -1
- package/dist/core/agent-session.d.ts +4 -0
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +4 -0
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/builtin-packages.d.ts.map +1 -1
- package/dist/core/builtin-packages.js +8 -4
- package/dist/core/builtin-packages.js.map +1 -1
- package/dist/core/compaction/context-compaction-runner.d.ts.map +1 -1
- package/dist/core/compaction/context-compaction-runner.js +36 -20
- package/dist/core/compaction/context-compaction-runner.js.map +1 -1
- package/dist/core/copilot-anthropic-sse-repair.d.ts +23 -0
- package/dist/core/copilot-anthropic-sse-repair.d.ts.map +1 -0
- package/dist/core/copilot-anthropic-sse-repair.js +340 -0
- package/dist/core/copilot-anthropic-sse-repair.js.map +1 -0
- package/dist/core/copilot-gemini-reasoning.d.ts +16 -8
- package/dist/core/copilot-gemini-reasoning.d.ts.map +1 -1
- package/dist/core/copilot-gemini-reasoning.js +27 -22
- package/dist/core/copilot-gemini-reasoning.js.map +1 -1
- package/dist/core/copilot-hosts.d.ts +12 -0
- package/dist/core/copilot-hosts.d.ts.map +1 -0
- package/dist/core/copilot-hosts.js +33 -0
- package/dist/core/copilot-hosts.js.map +1 -0
- package/dist/core/copilot-model-catalog.d.ts.map +1 -1
- package/dist/core/copilot-model-catalog.js +3 -2
- package/dist/core/copilot-model-catalog.js.map +1 -1
- package/dist/core/extensions/agent-events.d.ts +1 -1
- package/dist/core/extensions/agent-events.d.ts.map +1 -1
- package/dist/core/extensions/agent-events.js.map +1 -1
- package/dist/core/extensions/loader-virtual-modules.d.ts.map +1 -1
- package/dist/core/extensions/loader-virtual-modules.js +8 -3
- package/dist/core/extensions/loader-virtual-modules.js.map +1 -1
- package/dist/core/http-dispatcher.d.ts.map +1 -1
- package/dist/core/http-dispatcher.js +5 -5
- package/dist/core/http-dispatcher.js.map +1 -1
- package/dist/core/openai-responses-payload-sanitizer.d.ts +6 -0
- package/dist/core/openai-responses-payload-sanitizer.d.ts.map +1 -0
- package/dist/core/openai-responses-payload-sanitizer.js +59 -0
- package/dist/core/openai-responses-payload-sanitizer.js.map +1 -0
- package/dist/core/package-manager-auto-resources.d.ts +2 -2
- package/dist/core/package-manager-auto-resources.d.ts.map +1 -1
- package/dist/core/package-manager-auto-resources.js +32 -52
- package/dist/core/package-manager-auto-resources.js.map +1 -1
- package/dist/core/package-manager-resolver.d.ts.map +1 -1
- package/dist/core/package-manager-resolver.js +23 -14
- package/dist/core/package-manager-resolver.js.map +1 -1
- package/dist/core/package-manager-resource-collector.d.ts +3 -3
- package/dist/core/package-manager-resource-collector.d.ts.map +1 -1
- package/dist/core/package-manager-resource-collector.js +76 -73
- package/dist/core/package-manager-resource-collector.js.map +1 -1
- package/dist/core/package-manager-resource-files.d.ts +9 -8
- package/dist/core/package-manager-resource-files.d.ts.map +1 -1
- package/dist/core/package-manager-resource-files.js +92 -81
- package/dist/core/package-manager-resource-files.js.map +1 -1
- package/dist/core/prompt-templates-async.d.ts +3 -0
- package/dist/core/prompt-templates-async.d.ts.map +1 -0
- package/dist/core/prompt-templates-async.js +118 -0
- package/dist/core/prompt-templates-async.js.map +1 -0
- package/dist/core/provider-context-usage.d.ts +11 -0
- package/dist/core/provider-context-usage.d.ts.map +1 -0
- package/dist/core/provider-context-usage.js +58 -0
- package/dist/core/provider-context-usage.js.map +1 -0
- package/dist/core/resource-loader-assets.d.ts +3 -3
- package/dist/core/resource-loader-assets.d.ts.map +1 -1
- package/dist/core/resource-loader-assets.js +66 -83
- package/dist/core/resource-loader-assets.js.map +1 -1
- package/dist/core/resource-loader-core.d.ts +1 -1
- package/dist/core/resource-loader-core.d.ts.map +1 -1
- package/dist/core/resource-loader-core.js +5 -5
- package/dist/core/resource-loader-core.js.map +1 -1
- package/dist/core/resource-loader-reload.d.ts.map +1 -1
- package/dist/core/resource-loader-reload.js +43 -7
- package/dist/core/resource-loader-reload.js.map +1 -1
- package/dist/core/resource-loader-types.d.ts +7 -1
- package/dist/core/resource-loader-types.d.ts.map +1 -1
- package/dist/core/resource-loader-types.js.map +1 -1
- package/dist/core/sdk-types.d.ts +2 -0
- package/dist/core/sdk-types.d.ts.map +1 -1
- package/dist/core/sdk-types.js.map +1 -1
- package/dist/core/sdk.d.ts.map +1 -1
- package/dist/core/sdk.js +7 -4
- package/dist/core/sdk.js.map +1 -1
- package/dist/core/settings-manager-basic-accessors.d.ts +1 -0
- package/dist/core/settings-manager-basic-accessors.d.ts.map +1 -1
- package/dist/core/settings-manager-basic-accessors.js +6 -0
- package/dist/core/settings-manager-basic-accessors.js.map +1 -1
- package/dist/core/settings-types.d.ts +1 -0
- package/dist/core/settings-types.d.ts.map +1 -1
- package/dist/core/settings-types.js.map +1 -1
- package/dist/core/skills-async.d.ts +3 -0
- package/dist/core/skills-async.d.ts.map +1 -0
- package/dist/core/skills-async.js +269 -0
- package/dist/core/skills-async.js.map +1 -0
- package/dist/index-extensions.d.ts +1 -1
- package/dist/index-extensions.d.ts.map +1 -1
- package/dist/index-extensions.js.map +1 -1
- package/dist/main-deferred-startup.d.ts +14 -0
- package/dist/main-deferred-startup.d.ts.map +1 -1
- package/dist/main-deferred-startup.js +23 -0
- package/dist/main-deferred-startup.js.map +1 -1
- package/dist/main-early-input.d.ts +41 -0
- package/dist/main-early-input.d.ts.map +1 -0
- package/dist/main-early-input.js +147 -0
- package/dist/main-early-input.js.map +1 -0
- package/dist/main.d.ts +0 -6
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +23 -17
- package/dist/main.js.map +1 -1
- package/dist/modes/interactive/components/chat-session-host-events.d.ts.map +1 -1
- package/dist/modes/interactive/components/chat-session-host-events.js +15 -0
- package/dist/modes/interactive/components/chat-session-host-events.js.map +1 -1
- package/dist/modes/interactive/interactive-agent-events.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-agent-events.js +34 -1
- package/dist/modes/interactive/interactive-agent-events.js.map +1 -1
- package/dist/modes/interactive/interactive-deferred-startup.d.ts +6 -0
- package/dist/modes/interactive/interactive-deferred-startup.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-deferred-startup.js +27 -13
- package/dist/modes/interactive/interactive-deferred-startup.js.map +1 -1
- package/dist/modes/interactive/interactive-editor-actions.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-editor-actions.js +13 -13
- package/dist/modes/interactive/interactive-editor-actions.js.map +1 -1
- package/dist/modes/interactive/interactive-extension-runtime.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-extension-runtime.js +16 -0
- package/dist/modes/interactive/interactive-extension-runtime.js.map +1 -1
- package/dist/modes/interactive/interactive-input-handling.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-input-handling.js +324 -178
- package/dist/modes/interactive/interactive-input-handling.js.map +1 -1
- package/dist/modes/interactive/interactive-mode-base.d.ts +14 -0
- package/dist/modes/interactive/interactive-mode-base.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode-base.js +41 -0
- package/dist/modes/interactive/interactive-mode-base.js.map +1 -1
- package/dist/modes/interactive/interactive-mode-surface.d.ts +22 -6
- package/dist/modes/interactive/interactive-mode-surface.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode-surface.js.map +1 -1
- package/dist/modes/interactive/interactive-mode-types.d.ts +3 -0
- package/dist/modes/interactive/interactive-mode-types.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode-types.js.map +1 -1
- package/dist/modes/interactive/interactive-model-routing.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-model-routing.js +3 -3
- package/dist/modes/interactive/interactive-model-routing.js.map +1 -1
- package/dist/modes/interactive/interactive-onboarding.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-onboarding.js +1 -0
- package/dist/modes/interactive/interactive-onboarding.js.map +1 -1
- package/dist/modes/interactive/interactive-process-lifecycle.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-process-lifecycle.js +43 -6
- package/dist/modes/interactive/interactive-process-lifecycle.js.map +1 -1
- package/dist/modes/interactive/interactive-render-chat.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-render-chat.js +78 -9
- package/dist/modes/interactive/interactive-render-chat.js.map +1 -1
- package/dist/modes/interactive/interactive-resource-disclosure.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-resource-disclosure.js +3 -2
- package/dist/modes/interactive/interactive-resource-disclosure.js.map +1 -1
- package/dist/modes/interactive/interactive-resource-rendering.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-resource-rendering.js +10 -8
- package/dist/modes/interactive/interactive-resource-rendering.js.map +1 -1
- package/dist/modes/interactive/interactive-session-runtime.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-session-runtime.js +1 -1
- package/dist/modes/interactive/interactive-session-runtime.js.map +1 -1
- package/dist/modes/interactive/interactive-startup.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-startup.js +65 -53
- package/dist/modes/interactive/interactive-startup.js.map +1 -1
- package/dist/modes/interactive/theme/theme-loading.d.ts +1 -0
- package/dist/modes/interactive/theme/theme-loading.d.ts.map +1 -1
- package/dist/modes/interactive/theme/theme-loading.js +3 -0
- package/dist/modes/interactive/theme/theme-loading.js.map +1 -1
- package/dist/modes/interactive/theme/theme.d.ts +1 -1
- package/dist/modes/interactive/theme/theme.d.ts.map +1 -1
- package/dist/modes/interactive/theme/theme.js +1 -1
- package/dist/modes/interactive/theme/theme.js.map +1 -1
- package/dist/utils/module-require.d.ts +11 -0
- package/dist/utils/module-require.d.ts.map +1 -1
- package/dist/utils/module-require.js +14 -1
- package/dist/utils/module-require.js.map +1 -1
- package/dist/utils/split-launcher.d.ts +38 -0
- package/dist/utils/split-launcher.d.ts.map +1 -0
- package/dist/utils/split-launcher.js +63 -0
- package/dist/utils/split-launcher.js.map +1 -0
- package/docs/compaction.md +7 -0
- package/docs/json.md +3 -1
- package/docs/keybindings.md +2 -2
- package/docs/providers.md +2 -1
- package/docs/rpc.md +3 -1
- package/docs/settings.md +28 -2
- package/docs/terminal-setup.md +4 -0
- package/docs/usage.md +3 -3
- package/docs/workflows.md +13 -3
- package/npm-shrinkwrap.json +513 -23
- package/package.json +5 -4
|
@@ -1,7 +1,18 @@
|
|
|
1
1
|
import { InteractiveModeBase } from "./interactive-mode-base.js";
|
|
2
2
|
import { chalk, killTrackedDetachedChildren } from "./interactive-mode-deps.js";
|
|
3
3
|
import { formatResumeCommand, isDeadTerminalError } from "./interactive-mode-helpers.js";
|
|
4
|
+
const SHUTDOWN_INPUT_DRAIN_MAX_MS = 250;
|
|
5
|
+
const SHUTDOWN_INPUT_DRAIN_IDLE_MS = 50;
|
|
4
6
|
InteractiveModeBase.prototype.handleCtrlC = function () {
|
|
7
|
+
// When the agent is doing work, Ctrl+C interrupts it (matching Escape and
|
|
8
|
+
// common CLI muscle memory) instead of clearing/exiting the editor. Only
|
|
9
|
+
// fall back to the clear / double-press-exit behavior when idle.
|
|
10
|
+
if (this.interruptActiveOperation()) {
|
|
11
|
+
// Reset the double-press window so a follow-up Ctrl+C after the abort
|
|
12
|
+
// does not immediately exit.
|
|
13
|
+
this.lastSigintTime = 0;
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
5
16
|
const now = Date.now();
|
|
6
17
|
if (now - this.lastSigintTime < 500) {
|
|
7
18
|
void this.shutdown();
|
|
@@ -11,6 +22,27 @@ InteractiveModeBase.prototype.handleCtrlC = function () {
|
|
|
11
22
|
this.lastSigintTime = now;
|
|
12
23
|
}
|
|
13
24
|
};
|
|
25
|
+
InteractiveModeBase.prototype.interruptActiveOperation = function () {
|
|
26
|
+
// Mirror the Escape interrupt paths so Ctrl+C aborts whichever operation is
|
|
27
|
+
// currently running. Returns true when something was aborted.
|
|
28
|
+
if (this.session.isStreaming) {
|
|
29
|
+
this.restoreQueuedMessagesToEditor({ abort: true });
|
|
30
|
+
return true;
|
|
31
|
+
}
|
|
32
|
+
if (this.session.isBashRunning) {
|
|
33
|
+
this.session.abortBash();
|
|
34
|
+
return true;
|
|
35
|
+
}
|
|
36
|
+
if (this.session.isCompacting) {
|
|
37
|
+
this.session.abortCompaction();
|
|
38
|
+
return true;
|
|
39
|
+
}
|
|
40
|
+
if (this.session.isRetrying) {
|
|
41
|
+
this.session.abortRetry();
|
|
42
|
+
return true;
|
|
43
|
+
}
|
|
44
|
+
return false;
|
|
45
|
+
};
|
|
14
46
|
InteractiveModeBase.prototype.handleCtrlD = function () {
|
|
15
47
|
// Only called when editor is empty (enforced by CustomEditor)
|
|
16
48
|
void this.shutdown();
|
|
@@ -25,16 +57,16 @@ InteractiveModeBase.prototype.shutdown = async function (options) {
|
|
|
25
57
|
if (options?.fromSignal) {
|
|
26
58
|
await this.runtimeHost.dispose();
|
|
27
59
|
this.themeController.disableAutoSync();
|
|
28
|
-
// Drain any in-flight Kitty key release events before stopping.
|
|
29
|
-
//
|
|
30
|
-
await this.ui.terminal.drainInput(
|
|
60
|
+
// Drain any in-flight Kitty key release events briefly before stopping.
|
|
61
|
+
// Keep this bounded so Ctrl+C exits do not feel stalled on Windows.
|
|
62
|
+
await this.ui.terminal.drainInput(SHUTDOWN_INPUT_DRAIN_MAX_MS, SHUTDOWN_INPUT_DRAIN_IDLE_MS);
|
|
31
63
|
this.stop();
|
|
32
64
|
process.exit(0);
|
|
33
65
|
}
|
|
34
|
-
// Drain any in-flight Kitty key release events before stopping.
|
|
35
|
-
//
|
|
66
|
+
// Drain any in-flight Kitty key release events briefly before stopping.
|
|
67
|
+
// Keep this bounded so Ctrl+C exits do not feel stalled on Windows.
|
|
36
68
|
this.themeController.disableAutoSync();
|
|
37
|
-
await this.ui.terminal.drainInput(
|
|
69
|
+
await this.ui.terminal.drainInput(SHUTDOWN_INPUT_DRAIN_MAX_MS, SHUTDOWN_INPUT_DRAIN_IDLE_MS);
|
|
38
70
|
this.stop();
|
|
39
71
|
await this.runtimeHost.dispose();
|
|
40
72
|
const resumeCommand = formatResumeCommand(this.sessionManager);
|
|
@@ -91,6 +123,11 @@ InteractiveModeBase.prototype.registerSignalHandlers = function () {
|
|
|
91
123
|
process.prependListener(signal, handler);
|
|
92
124
|
this.signalCleanupHandlers.push(() => process.off(signal, handler));
|
|
93
125
|
}
|
|
126
|
+
const sigintHandler = () => {
|
|
127
|
+
this.handleCtrlC();
|
|
128
|
+
};
|
|
129
|
+
process.prependListener("SIGINT", sigintHandler);
|
|
130
|
+
this.signalCleanupHandlers.push(() => process.off("SIGINT", sigintHandler));
|
|
94
131
|
const terminalErrorHandler = (error) => {
|
|
95
132
|
if (isDeadTerminalError(error)) {
|
|
96
133
|
this.emergencyTerminalExit();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interactive-process-lifecycle.js","sourceRoot":"","sources":["../../../src/modes/interactive/interactive-process-lifecycle.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AACjE,OAAO,EAAE,KAAK,EAAE,2BAA2B,EAAE,MAAM,4BAA4B,CAAC;AAChF,OAAO,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AAEzF,mBAAmB,CAAC,SAAS,CAAC,WAAW,GAAG;IACxC,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;IACvB,IAAI,GAAG,GAAG,IAAI,CAAC,cAAc,GAAG,GAAG,EAAE,CAAC;QACpC,KAAK,IAAI,CAAC,QAAQ,EAAE,CAAC;IACvB,CAAC;SAAM,CAAC;QACN,IAAI,CAAC,WAAW,EAAE,CAAC;QACnB,IAAI,CAAC,cAAc,GAAG,GAAG,CAAC;IAC5B,CAAC;AACH,CAAC,CAAC;AAEJ,mBAAmB,CAAC,SAAS,CAAC,WAAW,GAAG;IACxC,8DAA8D;IAC9D,KAAK,IAAI,CAAC,QAAQ,EAAE,CAAC;AACvB,CAAC,CAAC;AAEJ,mBAAmB,CAAC,SAAS,CAAC,QAAQ,GAAG,KAAK,WAAqC,OAAkC;IACjH,IAAI,IAAI,CAAC,cAAc;QAAE,OAAO;IAChC,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC;IAC3B,wEAAwE;IACxE,wEAAwE;IACxE,qEAAqE;IAErE,IAAI,OAAO,EAAE,UAAU,EAAE,CAAC;QACxB,MAAM,IAAI,CAAC,WAAW,CAAC,OAAO,EAAE,CAAC;QACjC,IAAI,CAAC,eAAe,CAAC,eAAe,EAAE,CAAC;QACvC,gEAAgE;QAChE,iFAAiF;QACjF,MAAM,IAAI,CAAC,EAAE,CAAC,QAAQ,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;QACxC,IAAI,CAAC,IAAI,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;SAAM,CAAC;QACN,IAAI,CAAC,UAAU,CACb,YAAY,QAAQ,kBAAkB,QAAQ,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,YAAY,CAC1E,CAAC;IACJ,CAAC;AACH,CAAC,CAAC","sourcesContent":["import { InteractiveModeBase } from \"./interactive-mode-base.ts\";\nimport { chalk, killTrackedDetachedChildren } from \"./interactive-mode-deps.ts\";\nimport { formatResumeCommand, isDeadTerminalError } from \"./interactive-mode-helpers.ts\";\n\nInteractiveModeBase.prototype.handleCtrlC = function(this: InteractiveModeBase): void {\n const now = Date.now();\n if (now - this.lastSigintTime < 500) {\n void this.shutdown();\n } else {\n this.clearEditor();\n this.lastSigintTime = now;\n }\n };\n\nInteractiveModeBase.prototype.handleCtrlD = function(this: InteractiveModeBase): void {\n // Only called when editor is empty (enforced by CustomEditor)\n void this.shutdown();\n };\n\nInteractiveModeBase.prototype.shutdown = async function(this: InteractiveModeBase, options?: { fromSignal?: boolean }): Promise<void> {\n if (this.isShuttingDown) return;\n this.isShuttingDown = true;\n // Keep signal handlers registered until terminal cleanup has completed.\n // `signal-exit` checks the listener list during the same SIGTERM/SIGHUP\n // dispatch and re-sends the signal if only its own listeners remain.\n\n if (options?.fromSignal) {\n await this.runtimeHost.dispose();\n this.themeController.disableAutoSync();\n // Drain any in-flight Kitty key release events before stopping.\n // This prevents escape sequences from leaking to the parent shell over slow SSH.\n await this.ui.terminal.drainInput(1000);\n this.stop();\n process.exit(0);\n }\n\n // Drain any in-flight Kitty key release events before stopping.\n // This prevents escape sequences from leaking to the parent shell over slow SSH.\n this.themeController.disableAutoSync();\n await this.ui.terminal.drainInput(1000);\n\n this.stop();\n await this.runtimeHost.dispose();\n const resumeCommand = formatResumeCommand(this.sessionManager);\n if (resumeCommand) {\n process.stdout.write(`${chalk.dim(\"To resume this session:\")} ${resumeCommand}\\n`);\n }\n process.exit(0);\n };\n\nInteractiveModeBase.prototype.emergencyTerminalExit = function(this: InteractiveModeBase): never {\n this.isShuttingDown = true;\n this.unregisterSignalHandlers();\n killTrackedDetachedChildren();\n // The terminal is gone. Do not run normal shutdown because TUI and\n // extension cleanup can write restore sequences and re-trigger EIO.\n process.exit(129);\n };\n\nInteractiveModeBase.prototype.uncaughtCrash = function(this: InteractiveModeBase, error: Error): never {\n if (this.isShuttingDown) {\n process.exit(1);\n }\n this.isShuttingDown = true;\n try {\n this.unregisterSignalHandlers();\n } catch {}\n try {\n killTrackedDetachedChildren();\n } catch {}\n try {\n this.ui.stop();\n } catch {}\n console.error(\"pi exiting due to uncaughtException:\");\n console.error(error);\n process.exit(1);\n };\n\nInteractiveModeBase.prototype.checkShutdownRequested = async function(this: InteractiveModeBase): Promise<void> {\n if (!this.shutdownRequested) return;\n await this.shutdown();\n };\n\nInteractiveModeBase.prototype.registerSignalHandlers = function(this: InteractiveModeBase): void {\n this.unregisterSignalHandlers();\n\n const signals: NodeJS.Signals[] = [\"SIGTERM\"];\n if (process.platform !== \"win32\") {\n signals.push(\"SIGHUP\");\n }\n\n for (const signal of signals) {\n const handler = () => {\n killTrackedDetachedChildren();\n void this.shutdown({ fromSignal: true });\n };\n process.prependListener(signal, handler);\n this.signalCleanupHandlers.push(() => process.off(signal, handler));\n }\n\n const terminalErrorHandler = (error: Error) => {\n if (isDeadTerminalError(error)) {\n this.emergencyTerminalExit();\n }\n throw error;\n };\n process.stdout.on(\"error\", terminalErrorHandler);\n process.stderr.on(\"error\", terminalErrorHandler);\n this.signalCleanupHandlers.push(() =>\n process.stdout.off(\"error\", terminalErrorHandler),\n );\n this.signalCleanupHandlers.push(() =>\n process.stderr.off(\"error\", terminalErrorHandler),\n );\n\n // Restore the terminal before the process dies on any uncaught throw.\n // Without this, an unhandled exception from extension code (or anywhere\n // in pi) leaves the terminal in raw mode with no cursor.\n const uncaughtExceptionHandler = (error: Error) =>\n this.uncaughtCrash(error);\n process.prependListener(\"uncaughtException\", uncaughtExceptionHandler);\n this.signalCleanupHandlers.push(() =>\n process.off(\"uncaughtException\", uncaughtExceptionHandler),\n );\n };\n\nInteractiveModeBase.prototype.unregisterSignalHandlers = function(this: InteractiveModeBase): void {\n for (const cleanup of this.signalCleanupHandlers) {\n cleanup();\n }\n this.signalCleanupHandlers = [];\n };\n\nInteractiveModeBase.prototype.handleCtrlZ = function(this: InteractiveModeBase): void {\n if (process.platform === \"win32\") {\n this.showStatus(\"Suspend to background is not supported on Windows\");\n return;\n }\n\n // Keep the event loop alive while suspended. Without this, stopping the TUI\n // can leave Node with no ref'ed handles, causing the process to exit on fg\n // before the SIGCONT handler gets a chance to restore the terminal.\n const suspendKeepAlive = setInterval(() => {}, 2 ** 30);\n\n // Ignore SIGINT while suspended so Ctrl+C in the terminal does not\n // kill the backgrounded process. The handler is removed on resume.\n const ignoreSigint = () => {};\n process.on(\"SIGINT\", ignoreSigint);\n\n // Set up handler to restore TUI when resumed\n process.once(\"SIGCONT\", () => {\n clearInterval(suspendKeepAlive);\n process.removeListener(\"SIGINT\", ignoreSigint);\n this.ui.start();\n this.ui.requestRender(true);\n });\n\n try {\n // Stop the TUI (restore terminal to normal mode)\n this.ui.stop();\n\n // Send SIGTSTP to process group (pid=0 means all processes in group)\n process.kill(0, \"SIGTSTP\");\n } catch (error) {\n clearInterval(suspendKeepAlive);\n process.removeListener(\"SIGINT\", ignoreSigint);\n throw error;\n }\n };\n\nInteractiveModeBase.prototype.handleFollowUp = async function(this: InteractiveModeBase): Promise<void> {\n const text = (\n this.editor.getExpandedText?.() ?? this.editor.getText()\n ).trim();\n if (!text) return;\n\n // Queue input during compaction (extension commands execute immediately)\n if (this.session.isCompacting) {\n if (this.isExtensionCommand(text)) {\n this.editor.addToHistory?.(text);\n this.editor.setText(\"\");\n await this.session.prompt(text);\n } else {\n this.queueCompactionMessage(text, \"followUp\");\n }\n return;\n }\n\n // Alt+Enter queues a follow-up message (waits until agent finishes)\n // This handles extension commands (execute immediately), prompt template expansion, and queueing\n if (this.session.isStreaming) {\n this.editor.addToHistory?.(text);\n this.editor.setText(\"\");\n await this.session.prompt(text, { streamingBehavior: \"followUp\" });\n this.updatePendingMessagesDisplay();\n this.ui.requestRender();\n }\n // If not streaming, Alt+Enter acts like regular Enter (trigger onSubmit)\n else if (this.editor.onSubmit) {\n this.editor.setText(\"\");\n this.editor.onSubmit(text);\n }\n };\n\nInteractiveModeBase.prototype.handleDequeue = function(this: InteractiveModeBase): void {\n const restored = this.restoreQueuedMessagesToEditor();\n if (restored === 0) {\n this.showStatus(\"No queued messages to restore\");\n } else {\n this.showStatus(\n `Restored ${restored} queued message${restored > 1 ? \"s\" : \"\"} to editor`,\n );\n }\n };\n"]}
|
|
1
|
+
{"version":3,"file":"interactive-process-lifecycle.js","sourceRoot":"","sources":["../../../src/modes/interactive/interactive-process-lifecycle.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AACjE,OAAO,EAAE,KAAK,EAAE,2BAA2B,EAAE,MAAM,4BAA4B,CAAC;AAChF,OAAO,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AAEzF,MAAM,2BAA2B,GAAG,GAAG,CAAC;AACxC,MAAM,4BAA4B,GAAG,EAAE,CAAC;AAExC,mBAAmB,CAAC,SAAS,CAAC,WAAW,GAAG;IACxC,0EAA0E;IAC1E,yEAAyE;IACzE,iEAAiE;IACjE,IAAI,IAAI,CAAC,wBAAwB,EAAE,EAAE,CAAC;QACpC,sEAAsE;QACtE,6BAA6B;QAC7B,IAAI,CAAC,cAAc,GAAG,CAAC,CAAC;QACxB,OAAO;IACT,CAAC;IACD,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;IACvB,IAAI,GAAG,GAAG,IAAI,CAAC,cAAc,GAAG,GAAG,EAAE,CAAC;QACpC,KAAK,IAAI,CAAC,QAAQ,EAAE,CAAC;IACvB,CAAC;SAAM,CAAC;QACN,IAAI,CAAC,WAAW,EAAE,CAAC;QACnB,IAAI,C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;IACD,yEAAyE;SACpE,IAAI,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC;QAC9B,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;QACxB,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;IAC7B,CAAC;AACH,CAAC,CAAC;AAEJ,mBAAmB,CAAC,SAAS,CAAC,aAAa,GAAG;IAC1C,MAAM,QAAQ,GAAG,IAAI,CAAC,6BAA6B,EAAE,CAAC;IACtD,IAAI,QAAQ,KAAK,CAAC,EAAE,CAAC;QACnB,IAAI,CAAC,UAAU,CAAC,+BAA+B,CAAC,CAAC;IACnD,CAAC;SAAM,CAAC;QACN,IAAI,CAAC,UAAU,CACb,YAAY,QAAQ,kBAAkB,QAAQ,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,YAAY,CAC1E,CAAC;IACJ,CAAC;AACH,CAAC,CAAC","sourcesContent":["import { InteractiveModeBase } from \"./interactive-mode-base.ts\";\nimport { chalk, killTrackedDetachedChildren } from \"./interactive-mode-deps.ts\";\nimport { formatResumeCommand, isDeadTerminalError } from \"./interactive-mode-helpers.ts\";\n\nconst SHUTDOWN_INPUT_DRAIN_MAX_MS = 250;\nconst SHUTDOWN_INPUT_DRAIN_IDLE_MS = 50;\n\nInteractiveModeBase.prototype.handleCtrlC = function(this: InteractiveModeBase): void {\n // When the agent is doing work, Ctrl+C interrupts it (matching Escape and\n // common CLI muscle memory) instead of clearing/exiting the editor. Only\n // fall back to the clear / double-press-exit behavior when idle.\n if (this.interruptActiveOperation()) {\n // Reset the double-press window so a follow-up Ctrl+C after the abort\n // does not immediately exit.\n this.lastSigintTime = 0;\n return;\n }\n const now = Date.now();\n if (now - this.lastSigintTime < 500) {\n void this.shutdown();\n } else {\n this.clearEditor();\n this.lastSigintTime = now;\n }\n };\n\nInteractiveModeBase.prototype.interruptActiveOperation = function(this: InteractiveModeBase): boolean {\n // Mirror the Escape interrupt paths so Ctrl+C aborts whichever operation is\n // currently running. Returns true when something was aborted.\n if (this.session.isStreaming) {\n this.restoreQueuedMessagesToEditor({ abort: true });\n return true;\n }\n if (this.session.isBashRunning) {\n this.session.abortBash();\n return true;\n }\n if (this.session.isCompacting) {\n this.session.abortCompaction();\n return true;\n }\n if (this.session.isRetrying) {\n this.session.abortRetry();\n return true;\n }\n return false;\n };\n\nInteractiveModeBase.prototype.handleCtrlD = function(this: InteractiveModeBase): void {\n // Only called when editor is empty (enforced by CustomEditor)\n void this.shutdown();\n };\n\nInteractiveModeBase.prototype.shutdown = async function(this: InteractiveModeBase, options?: { fromSignal?: boolean }): Promise<void> {\n if (this.isShuttingDown) return;\n this.isShuttingDown = true;\n // Keep signal handlers registered until terminal cleanup has completed.\n // `signal-exit` checks the listener list during the same SIGTERM/SIGHUP\n // dispatch and re-sends the signal if only its own listeners remain.\n\n if (options?.fromSignal) {\n await this.runtimeHost.dispose();\n this.themeController.disableAutoSync();\n // Drain any in-flight Kitty key release events briefly before stopping.\n // Keep this bounded so Ctrl+C exits do not feel stalled on Windows.\n await this.ui.terminal.drainInput(SHUTDOWN_INPUT_DRAIN_MAX_MS, SHUTDOWN_INPUT_DRAIN_IDLE_MS);\n this.stop();\n process.exit(0);\n }\n\n // Drain any in-flight Kitty key release events briefly before stopping.\n // Keep this bounded so Ctrl+C exits do not feel stalled on Windows.\n this.themeController.disableAutoSync();\n await this.ui.terminal.drainInput(SHUTDOWN_INPUT_DRAIN_MAX_MS, SHUTDOWN_INPUT_DRAIN_IDLE_MS);\n\n this.stop();\n await this.runtimeHost.dispose();\n const resumeCommand = formatResumeCommand(this.sessionManager);\n if (resumeCommand) {\n process.stdout.write(`${chalk.dim(\"To resume this session:\")} ${resumeCommand}\\n`);\n }\n process.exit(0);\n };\n\nInteractiveModeBase.prototype.emergencyTerminalExit = function(this: InteractiveModeBase): never {\n this.isShuttingDown = true;\n this.unregisterSignalHandlers();\n killTrackedDetachedChildren();\n // The terminal is gone. Do not run normal shutdown because TUI and\n // extension cleanup can write restore sequences and re-trigger EIO.\n process.exit(129);\n };\n\nInteractiveModeBase.prototype.uncaughtCrash = function(this: InteractiveModeBase, error: Error): never {\n if (this.isShuttingDown) {\n process.exit(1);\n }\n this.isShuttingDown = true;\n try {\n this.unregisterSignalHandlers();\n } catch {}\n try {\n killTrackedDetachedChildren();\n } catch {}\n try {\n this.ui.stop();\n } catch {}\n console.error(\"pi exiting due to uncaughtException:\");\n console.error(error);\n process.exit(1);\n };\n\nInteractiveModeBase.prototype.checkShutdownRequested = async function(this: InteractiveModeBase): Promise<void> {\n if (!this.shutdownRequested) return;\n await this.shutdown();\n };\n\nInteractiveModeBase.prototype.registerSignalHandlers = function(this: InteractiveModeBase): void {\n this.unregisterSignalHandlers();\n\n const signals: NodeJS.Signals[] = [\"SIGTERM\"];\n if (process.platform !== \"win32\") {\n signals.push(\"SIGHUP\");\n }\n\n for (const signal of signals) {\n const handler = () => {\n killTrackedDetachedChildren();\n void this.shutdown({ fromSignal: true });\n };\n process.prependListener(signal, handler);\n this.signalCleanupHandlers.push(() => process.off(signal, handler));\n }\n\n const sigintHandler = () => {\n this.handleCtrlC();\n };\n process.prependListener(\"SIGINT\", sigintHandler);\n this.signalCleanupHandlers.push(() => process.off(\"SIGINT\", sigintHandler));\n\n const terminalErrorHandler = (error: Error) => {\n if (isDeadTerminalError(error)) {\n this.emergencyTerminalExit();\n }\n throw error;\n };\n process.stdout.on(\"error\", terminalErrorHandler);\n process.stderr.on(\"error\", terminalErrorHandler);\n this.signalCleanupHandlers.push(() =>\n process.stdout.off(\"error\", terminalErrorHandler),\n );\n this.signalCleanupHandlers.push(() =>\n process.stderr.off(\"error\", terminalErrorHandler),\n );\n\n // Restore the terminal before the process dies on any uncaught throw.\n // Without this, an unhandled exception from extension code (or anywhere\n // in pi) leaves the terminal in raw mode with no cursor.\n const uncaughtExceptionHandler = (error: Error) =>\n this.uncaughtCrash(error);\n process.prependListener(\"uncaughtException\", uncaughtExceptionHandler);\n this.signalCleanupHandlers.push(() =>\n process.off(\"uncaughtException\", uncaughtExceptionHandler),\n );\n };\n\nInteractiveModeBase.prototype.unregisterSignalHandlers = function(this: InteractiveModeBase): void {\n for (const cleanup of this.signalCleanupHandlers) {\n cleanup();\n }\n this.signalCleanupHandlers = [];\n };\n\nInteractiveModeBase.prototype.handleCtrlZ = function(this: InteractiveModeBase): void {\n if (process.platform === \"win32\") {\n this.showStatus(\"Suspend to background is not supported on Windows\");\n return;\n }\n\n // Keep the event loop alive while suspended. Without this, stopping the TUI\n // can leave Node with no ref'ed handles, causing the process to exit on fg\n // before the SIGCONT handler gets a chance to restore the terminal.\n const suspendKeepAlive = setInterval(() => {}, 2 ** 30);\n\n // Ignore SIGINT while suspended so Ctrl+C in the terminal does not\n // kill the backgrounded process. The handler is removed on resume.\n const ignoreSigint = () => {};\n process.on(\"SIGINT\", ignoreSigint);\n\n // Set up handler to restore TUI when resumed\n process.once(\"SIGCONT\", () => {\n clearInterval(suspendKeepAlive);\n process.removeListener(\"SIGINT\", ignoreSigint);\n this.ui.start();\n this.ui.requestRender(true);\n });\n\n try {\n // Stop the TUI (restore terminal to normal mode)\n this.ui.stop();\n\n // Send SIGTSTP to process group (pid=0 means all processes in group)\n process.kill(0, \"SIGTSTP\");\n } catch (error) {\n clearInterval(suspendKeepAlive);\n process.removeListener(\"SIGINT\", ignoreSigint);\n throw error;\n }\n };\n\nInteractiveModeBase.prototype.handleFollowUp = async function(this: InteractiveModeBase): Promise<void> {\n const text = (\n this.editor.getExpandedText?.() ?? this.editor.getText()\n ).trim();\n if (!text) return;\n\n // Queue input during compaction (extension commands execute immediately)\n if (this.session.isCompacting) {\n if (this.isExtensionCommand(text)) {\n this.editor.addToHistory?.(text);\n this.editor.setText(\"\");\n await this.session.prompt(text);\n } else {\n this.queueCompactionMessage(text, \"followUp\");\n }\n return;\n }\n\n // Alt+Enter queues a follow-up message (waits until agent finishes)\n // This handles extension commands (execute immediately), prompt template expansion, and queueing\n if (this.session.isStreaming) {\n this.editor.addToHistory?.(text);\n this.editor.setText(\"\");\n await this.session.prompt(text, { streamingBehavior: \"followUp\" });\n this.updatePendingMessagesDisplay();\n this.ui.requestRender();\n }\n // If not streaming, Alt+Enter acts like regular Enter (trigger onSubmit)\n else if (this.editor.onSubmit) {\n this.editor.setText(\"\");\n this.editor.onSubmit(text);\n }\n };\n\nInteractiveModeBase.prototype.handleDequeue = function(this: InteractiveModeBase): void {\n const restored = this.restoreQueuedMessagesToEditor();\n if (restored === 0) {\n this.showStatus(\"No queued messages to restore\");\n } else {\n this.showStatus(\n `Restored ${restored} queued message${restored > 1 ? \"s\" : \"\"} to editor`,\n );\n }\n };\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interactive-render-chat.d.ts","sourceRoot":"","sources":["../../../src/modes/interactive/interactive-render-chat.ts"],"names":[],"mappings":"","sourcesContent":["import { InteractiveModeBase } from \"./interactive-mode-base.ts\";\nimport { type AgentMessage, type Component, type ContextCompactionResult, type SessionContext, type TruncationResult, type ChatMessageEntry, type ChatMessageRenderOptions, Spacer, Text, parseSkillBlock, AssistantMessageComponent, BashExecutionComponent, BranchSummaryMessageComponent, chatEntriesFromAgentMessages, renderChatMessageEntry, addChatTranscriptEntry, ContextCompactionSummaryMessageComponent, CustomMessageComponent, SkillInvocationMessageComponent, ToolExecutionComponent, UserMessageComponent, theme } from \"./interactive-mode-deps.ts\";\n\nInteractiveModeBase.prototype.showStatus = function(this: InteractiveModeBase, message: string): void {\n const children = this.chatContainer.children;\n const last =\n children.length > 0 ? children[children.length - 1] : undefined;\n const secondLast =\n children.length > 1 ? children[children.length - 2] : undefined;\n\n if (\n last &&\n secondLast &&\n last === this.lastStatusText &&\n secondLast === this.lastStatusSpacer\n ) {\n this.lastStatusText.setText(theme.fg(\"dim\", message));\n this.ui.requestRender();\n return;\n }\n\n const spacer = new Spacer(1);\n const text = new Text(theme.fg(\"dim\", message), 1, 0);\n this.chatContainer.addChild(spacer);\n this.chatContainer.addChild(text);\n this.lastStatusSpacer = spacer;\n this.lastStatusText = text;\n this.ui.requestRender();\n };\n\nInteractiveModeBase.prototype.chatMessageRenderOptions = function(this: InteractiveModeBase): ChatMessageRenderOptions {\n return {\n ui: this.ui,\n cwd: this.sessionManager.getCwd(),\n markdownTheme: this.getMarkdownThemeWithSettings(),\n hideThinkingBlock: this.hideThinkingBlock,\n hiddenThinkingLabel: this.hiddenThinkingLabel,\n toolOutputExpanded: this.toolOutputExpanded,\n showImages: this.settingsManager.getShowImages(),\n imageWidthCells: this.settingsManager.getImageWidthCells(),\n outputPad: this.outputPad,\n getToolDefinition: (toolName) => this.getRegisteredToolDefinition(toolName),\n getCustomMessageRenderer: (customType) =>\n this.session.extensionRunner.getMessageRenderer(customType),\n };\n };\n\nInteractiveModeBase.prototype.addRenderedChatEntry = function(this: InteractiveModeBase, entry: ChatMessageEntry): Component {\n const component = renderChatMessageEntry(entry, this.chatMessageRenderOptions());\n addChatTranscriptEntry(this.chatContainer, component, entry.role);\n return component;\n };\n\nInteractiveModeBase.prototype.addContextCompactionSummaryToChat = function(this: InteractiveModeBase, result: ContextCompactionResult): void {\n this.chatContainer.addChild(new Spacer(1));\n const component = new ContextCompactionSummaryMessageComponent(\n result,\n this.getMarkdownThemeWithSettings(),\n );\n component.setExpanded(this.toolOutputExpanded);\n this.chatContainer.addChild(component);\n };\n\nInteractiveModeBase.prototype.addMessageToChat = function(this: InteractiveModeBase, message: AgentMessage, options?: { populateHistory?: boolean }): void {\n switch (message.role) {\n case \"bashExecution\": {\n const component = new BashExecutionComponent(\n message.command,\n this.ui,\n message.excludeFromContext,\n );\n if (message.output) {\n component.appendOutput(message.output);\n }\n component.setComplete(\n message.exitCode,\n message.cancelled,\n message.truncated\n ? ({ truncated: true } as TruncationResult)\n : undefined,\n message.fullOutputPath,\n );\n this.chatContainer.addChild(component);\n break;\n }\n case \"custom\": {\n if (message.display) {\n const renderer = this.session.extensionRunner.getMessageRenderer(\n message.customType,\n );\n const component = new CustomMessageComponent(\n message,\n renderer,\n this.getMarkdownThemeWithSettings(),\n );\n component.setExpanded(this.toolOutputExpanded);\n this.chatContainer.addChild(component);\n }\n break;\n }\n case \"branchSummary\": {\n this.chatContainer.addChild(new Spacer(1));\n const component = new BranchSummaryMessageComponent(\n message,\n this.getMarkdownThemeWithSettings(),\n );\n component.setExpanded(this.toolOutputExpanded);\n this.chatContainer.addChild(component);\n break;\n }\n case \"user\": {\n const textContent = this.getUserMessageText(message);\n if (textContent) {\n if (this.chatContainer.children.length > 0) {\n this.chatContainer.addChild(new Spacer(1));\n }\n const skillBlock = parseSkillBlock(textContent);\n if (skillBlock) {\n // Render skill block (collapsible)\n const component = new SkillInvocationMessageComponent(\n skillBlock,\n this.getMarkdownThemeWithSettings(),\n );\n component.setExpanded(this.toolOutputExpanded);\n this.chatContainer.addChild(component);\n // Render user message separately if present\n if (skillBlock.userMessage) {\n const userComponent = new UserMessageComponent(\n skillBlock.userMessage,\n this.getMarkdownThemeWithSettings(),\n this.outputPad,\n );\n this.chatContainer.addChild(userComponent);\n }\n } else {\n const userComponent = new UserMessageComponent(\n textContent,\n this.getMarkdownThemeWithSettings(),\n this.outputPad,\n );\n this.chatContainer.addChild(userComponent);\n }\n if (options?.populateHistory) {\n this.editor.addToHistory?.(textContent);\n }\n }\n break;\n }\n case \"assistant\": {\n const assistantComponent = new AssistantMessageComponent(\n message,\n this.hideThinkingBlock,\n this.getMarkdownThemeWithSettings(),\n this.hiddenThinkingLabel,\n this.outputPad,\n );\n this.chatContainer.addChild(assistantComponent);\n break;\n }\n case \"toolResult\": {\n // Tool results are rendered inline with tool calls, handled separately\n break;\n }\n default:\n break;\n }\n };\n\nInteractiveModeBase.prototype.renderSessionContext = function(this: InteractiveModeBase, sessionContext: SessionContext, options: { updateFooter?: boolean; populateHistory?: boolean } = {}): void {\n this.pendingTools.clear();\n\n if (options.updateFooter) {\n this.footer.invalidate();\n this.updateEditorBorderColor();\n }\n\n const entries = chatEntriesFromAgentMessages(sessionContext.messages);\n for (const entry of entries) {\n const component = this.addRenderedChatEntry(entry);\n if (\n entry.kind === \"tool\" &&\n entry.isPartial !== false &&\n component instanceof ToolExecutionComponent\n ) {\n this.pendingTools.set(entry.toolCallId, component);\n }\n if (options.populateHistory && entry.kind === \"user\") {\n this.editor.addToHistory?.(entry.text);\n }\n }\n\n this.ui.requestRender();\n };\n\nInteractiveModeBase.prototype.renderInitialMessages = function(this: InteractiveModeBase): void {\n // Get aligned messages and entries from session context\n const context = this.sessionManager.buildSessionContext();\n this.renderSessionContext(context, {\n updateFooter: true,\n populateHistory: true,\n });\n\n // Show compaction info if session was compacted\n const allEntries = this.sessionManager.getEntries();\n const compactionCount = allEntries.filter(\n (e) => e.type === \"compaction\",\n ).length;\n if (compactionCount > 0) {\n const times =\n compactionCount === 1 ? \"1 time\" : `${compactionCount} times`;\n this.showStatus(`Session compacted ${times}`);\n }\n };\n\nInteractiveModeBase.prototype.getUserInput = async function(this: InteractiveModeBase): Promise<string> {\n const queuedInput = this.pendingUserInputs.shift();\n if (queuedInput !== undefined) {\n return queuedInput;\n }\n\n return new Promise((resolve) => {\n this.onInputCallback = (text: string) => {\n this.onInputCallback = undefined;\n resolve(text);\n };\n });\n };\n\nInteractiveModeBase.prototype.rebuildChatFromMessages = function(this: InteractiveModeBase): void {\n this.chatContainer.clear();\n const context = this.sessionManager.buildSessionContext();\n this.renderSessionContext(context);\n };\n"]}
|
|
1
|
+
{"version":3,"file":"interactive-render-chat.d.ts","sourceRoot":"","sources":["../../../src/modes/interactive/interactive-render-chat.ts"],"names":[],"mappings":"","sourcesContent":["import { InteractiveModeBase } from \"./interactive-mode-base.ts\";\nimport { type AgentMessage, type Component, type ContextCompactionResult, type SessionContext, type TruncationResult, type ChatMessageEntry, type ChatMessageRenderOptions, Spacer, Text, parseSkillBlock, AssistantMessageComponent, BashExecutionComponent, BranchSummaryMessageComponent, chatEntriesFromAgentMessages, renderChatMessageEntry, addChatTranscriptEntry, ContextCompactionSummaryMessageComponent, CustomMessageComponent, SkillInvocationMessageComponent, ToolExecutionComponent, UserMessageComponent, theme } from \"./interactive-mode-deps.ts\";\nimport { yieldToEventLoop } from \"../../utils/event-loop.ts\";\n\nInteractiveModeBase.prototype.showStatus = function(this: InteractiveModeBase, message: string): void {\n const children = this.chatContainer.children;\n const last =\n children.length > 0 ? children[children.length - 1] : undefined;\n const secondLast =\n children.length > 1 ? children[children.length - 2] : undefined;\n\n if (\n last &&\n secondLast &&\n last === this.lastStatusText &&\n secondLast === this.lastStatusSpacer\n ) {\n this.lastStatusText.setText(theme.fg(\"dim\", message));\n this.ui.requestRender();\n return;\n }\n\n const spacer = new Spacer(1);\n const text = new Text(theme.fg(\"dim\", message), 1, 0);\n this.chatContainer.addChild(spacer);\n this.chatContainer.addChild(text);\n this.lastStatusSpacer = spacer;\n this.lastStatusText = text;\n this.ui.requestRender();\n };\n\nInteractiveModeBase.prototype.renderDeferredUserInput = function(this: InteractiveModeBase, text: string): void {\n this.deferredRenderedUserInputs.push(text);\n const startIndex = this.chatContainer.children.length;\n this.addMessageToChat({ role: \"user\", content: text } as AgentMessage);\n const renderedComponents = this.chatContainer.children.slice(startIndex);\n const trackedComponents = this.deferredRenderedUserInputComponents.get(text) ?? [];\n trackedComponents.push(renderedComponents);\n this.deferredRenderedUserInputComponents.set(text, trackedComponents);\n this.updatePendingMessagesDisplay();\n this.ui.requestRender();\n };\n\nInteractiveModeBase.prototype.consumeDeferredRenderedUserInput = function(this: InteractiveModeBase, text: string): boolean {\n const index = this.deferredRenderedUserInputs.indexOf(text);\n if (index === -1) return false;\n this.deferredRenderedUserInputs.splice(index, 1);\n const trackedComponents = this.deferredRenderedUserInputComponents.get(text);\n trackedComponents?.shift();\n if (trackedComponents && trackedComponents.length === 0) {\n this.deferredRenderedUserInputComponents.delete(text);\n }\n return true;\n };\n\nInteractiveModeBase.prototype.discardDeferredRenderedUserInput = function(this: InteractiveModeBase, text: string): void {\n const index = this.deferredRenderedUserInputs.indexOf(text);\n if (index !== -1) this.deferredRenderedUserInputs.splice(index, 1);\n const trackedComponents = this.deferredRenderedUserInputComponents.get(text);\n const componentsToRemove = trackedComponents?.shift();\n if (trackedComponents && trackedComponents.length === 0) {\n this.deferredRenderedUserInputComponents.delete(text);\n }\n if (!componentsToRemove) return;\n for (const component of componentsToRemove) {\n this.chatContainer.removeChild(component);\n }\n this.updatePendingMessagesDisplay();\n this.ui.requestRender();\n };\n\nInteractiveModeBase.prototype.chatMessageRenderOptions = function(this: InteractiveModeBase): ChatMessageRenderOptions {\n return {\n ui: this.ui,\n cwd: this.sessionManager.getCwd(),\n markdownTheme: this.getMarkdownThemeWithSettings(),\n hideThinkingBlock: this.hideThinkingBlock,\n hiddenThinkingLabel: this.hiddenThinkingLabel,\n toolOutputExpanded: this.toolOutputExpanded,\n showImages: this.settingsManager.getShowImages(),\n imageWidthCells: this.settingsManager.getImageWidthCells(),\n outputPad: this.outputPad,\n getToolDefinition: (toolName) => this.getRegisteredToolDefinition(toolName),\n getCustomMessageRenderer: (customType) =>\n this.session.extensionRunner.getMessageRenderer(customType),\n };\n };\n\nInteractiveModeBase.prototype.addRenderedChatEntry = function(this: InteractiveModeBase, entry: ChatMessageEntry): Component {\n const component = renderChatMessageEntry(entry, this.chatMessageRenderOptions());\n addChatTranscriptEntry(this.chatContainer, component, entry.role);\n return component;\n };\n\nInteractiveModeBase.prototype.addContextCompactionSummaryToChat = function(this: InteractiveModeBase, result: ContextCompactionResult): void {\n this.chatContainer.addChild(new Spacer(1));\n const component = new ContextCompactionSummaryMessageComponent(\n result,\n this.getMarkdownThemeWithSettings(),\n );\n component.setExpanded(this.toolOutputExpanded);\n this.chatContainer.addChild(component);\n };\n\nInteractiveModeBase.prototype.addMessageToChat = function(this: InteractiveModeBase, message: AgentMessage, options?: { populateHistory?: boolean }): void {\n switch (message.role) {\n case \"bashExecution\": {\n const component = new BashExecutionComponent(\n message.command,\n this.ui,\n message.excludeFromContext,\n );\n if (message.output) {\n component.appendOutput(message.output);\n }\n component.setComplete(\n message.exitCode,\n message.cancelled,\n message.truncated\n ? ({ truncated: true } as TruncationResult)\n : undefined,\n message.fullOutputPath,\n );\n this.chatContainer.addChild(component);\n break;\n }\n case \"custom\": {\n if (message.display) {\n const renderer = this.session.extensionRunner.getMessageRenderer(\n message.customType,\n );\n const component = new CustomMessageComponent(\n message,\n renderer,\n this.getMarkdownThemeWithSettings(),\n );\n component.setExpanded(this.toolOutputExpanded);\n this.chatContainer.addChild(component);\n }\n break;\n }\n case \"branchSummary\": {\n this.chatContainer.addChild(new Spacer(1));\n const component = new BranchSummaryMessageComponent(\n message,\n this.getMarkdownThemeWithSettings(),\n );\n component.setExpanded(this.toolOutputExpanded);\n this.chatContainer.addChild(component);\n break;\n }\n case \"user\": {\n const textContent = this.getUserMessageText(message);\n if (textContent) {\n if (this.chatContainer.children.length > 0) {\n this.chatContainer.addChild(new Spacer(1));\n }\n const skillBlock = parseSkillBlock(textContent);\n if (skillBlock) {\n // Render skill block (collapsible)\n const component = new SkillInvocationMessageComponent(\n skillBlock,\n this.getMarkdownThemeWithSettings(),\n );\n component.setExpanded(this.toolOutputExpanded);\n this.chatContainer.addChild(component);\n // Render user message separately if present\n if (skillBlock.userMessage) {\n const userComponent = new UserMessageComponent(\n skillBlock.userMessage,\n this.getMarkdownThemeWithSettings(),\n this.outputPad,\n );\n this.chatContainer.addChild(userComponent);\n }\n } else {\n const userComponent = new UserMessageComponent(\n textContent,\n this.getMarkdownThemeWithSettings(),\n this.outputPad,\n );\n this.chatContainer.addChild(userComponent);\n }\n if (options?.populateHistory) {\n this.editor.addToHistory?.(textContent);\n }\n }\n break;\n }\n case \"assistant\": {\n const assistantComponent = new AssistantMessageComponent(\n message,\n this.hideThinkingBlock,\n this.getMarkdownThemeWithSettings(),\n this.hiddenThinkingLabel,\n this.outputPad,\n );\n this.chatContainer.addChild(assistantComponent);\n break;\n }\n case \"toolResult\": {\n // Tool results are rendered inline with tool calls, handled separately\n break;\n }\n default:\n break;\n }\n };\n\nInteractiveModeBase.prototype.renderSessionContext = function(this: InteractiveModeBase, sessionContext: SessionContext, options: { updateFooter?: boolean; populateHistory?: boolean } = {}): void {\n this.pendingTools.clear();\n const pendingDeferredInputs = [...this.deferredRenderedUserInputs];\n this.deferredRenderedUserInputs = [];\n this.deferredRenderedUserInputComponents.clear();\n\n if (options.updateFooter) {\n this.footer.invalidate();\n this.updateEditorBorderColor();\n }\n\n const entries = chatEntriesFromAgentMessages(sessionContext.messages);\n for (const entry of entries) {\n const component = this.addRenderedChatEntry(entry);\n if (\n entry.kind === \"tool\" &&\n entry.isPartial !== false &&\n component instanceof ToolExecutionComponent\n ) {\n this.pendingTools.set(entry.toolCallId, component);\n }\n if (options.populateHistory && entry.kind === \"user\") {\n this.editor.addToHistory?.(entry.text);\n }\n }\n\n for (const input of pendingDeferredInputs) {\n this.renderDeferredUserInput(input);\n }\n\n this.ui.requestRender();\n };\n\nInteractiveModeBase.prototype.attachStartupNoticesContainer = function(this: InteractiveModeBase, options: { resetDetached?: boolean } = {}): void {\n const isAttached = this.chatContainer.children.includes(this.startupNoticesContainer);\n if (isAttached) return;\n if (options.resetDetached) {\n this.startupNoticesContainer.clear();\n }\n this.chatContainer.addChild(this.startupNoticesContainer);\n };\n\nInteractiveModeBase.prototype.renderInitialMessages = function(this: InteractiveModeBase): void {\n this.attachStartupNoticesContainer({ resetDetached: true });\n // Get aligned messages and entries from session context\n const context = this.sessionManager.buildSessionContext();\n this.renderSessionContext(context, {\n updateFooter: true,\n populateHistory: true,\n });\n\n // Show compaction info if session was compacted\n const allEntries = this.sessionManager.getEntries();\n const compactionCount = allEntries.filter(\n (e) => e.type === \"compaction\",\n ).length;\n if (compactionCount > 0) {\n const times =\n compactionCount === 1 ? \"1 time\" : `${compactionCount} times`;\n this.showStatus(`Session compacted ${times}`);\n }\n };\n\nInteractiveModeBase.prototype.getUserInput = async function(this: InteractiveModeBase): Promise<string> {\n for (let attempt = 0; !this.startupCookedInputRecovered && attempt < 10; attempt += 1) {\n await yieldToEventLoop();\n if (this.recoverCookedStartupInput?.()) break;\n }\n while (true) {\n const queuedInput = this.pendingUserInputs.shift();\n if (queuedInput !== undefined) {\n return queuedInput;\n }\n\n if (this.startupReplayActiveInput) {\n await this.drainStartupReplayCommands();\n continue;\n }\n\n return new Promise((resolve) => {\n this.onInputCallback = (text: string) => {\n this.onInputCallback = undefined;\n resolve(text);\n };\n });\n }\n };\n\nInteractiveModeBase.prototype.rebuildChatFromMessages = function(this: InteractiveModeBase): void {\n this.chatContainer.clear();\n this.attachStartupNoticesContainer();\n const context = this.sessionManager.buildSessionContext();\n this.renderSessionContext(context);\n };\n"]}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { InteractiveModeBase } from "./interactive-mode-base.js";
|
|
2
2
|
import { Spacer, Text, parseSkillBlock, AssistantMessageComponent, BashExecutionComponent, BranchSummaryMessageComponent, chatEntriesFromAgentMessages, renderChatMessageEntry, addChatTranscriptEntry, ContextCompactionSummaryMessageComponent, CustomMessageComponent, SkillInvocationMessageComponent, ToolExecutionComponent, UserMessageComponent, theme } from "./interactive-mode-deps.js";
|
|
3
|
+
import { yieldToEventLoop } from "../../utils/event-loop.js";
|
|
3
4
|
InteractiveModeBase.prototype.showStatus = function (message) {
|
|
4
5
|
const children = this.chatContainer.children;
|
|
5
6
|
const last = children.length > 0 ? children[children.length - 1] : undefined;
|
|
@@ -20,6 +21,46 @@ InteractiveModeBase.prototype.showStatus = function (message) {
|
|
|
20
21
|
this.lastStatusText = text;
|
|
21
22
|
this.ui.requestRender();
|
|
22
23
|
};
|
|
24
|
+
InteractiveModeBase.prototype.renderDeferredUserInput = function (text) {
|
|
25
|
+
this.deferredRenderedUserInputs.push(text);
|
|
26
|
+
const startIndex = this.chatContainer.children.length;
|
|
27
|
+
this.addMessageToChat({ role: "user", content: text });
|
|
28
|
+
const renderedComponents = this.chatContainer.children.slice(startIndex);
|
|
29
|
+
const trackedComponents = this.deferredRenderedUserInputComponents.get(text) ?? [];
|
|
30
|
+
trackedComponents.push(renderedComponents);
|
|
31
|
+
this.deferredRenderedUserInputComponents.set(text, trackedComponents);
|
|
32
|
+
this.updatePendingMessagesDisplay();
|
|
33
|
+
this.ui.requestRender();
|
|
34
|
+
};
|
|
35
|
+
InteractiveModeBase.prototype.consumeDeferredRenderedUserInput = function (text) {
|
|
36
|
+
const index = this.deferredRenderedUserInputs.indexOf(text);
|
|
37
|
+
if (index === -1)
|
|
38
|
+
return false;
|
|
39
|
+
this.deferredRenderedUserInputs.splice(index, 1);
|
|
40
|
+
const trackedComponents = this.deferredRenderedUserInputComponents.get(text);
|
|
41
|
+
trackedComponents?.shift();
|
|
42
|
+
if (trackedComponents && trackedComponents.length === 0) {
|
|
43
|
+
this.deferredRenderedUserInputComponents.delete(text);
|
|
44
|
+
}
|
|
45
|
+
return true;
|
|
46
|
+
};
|
|
47
|
+
InteractiveModeBase.prototype.discardDeferredRenderedUserInput = function (text) {
|
|
48
|
+
const index = this.deferredRenderedUserInputs.indexOf(text);
|
|
49
|
+
if (index !== -1)
|
|
50
|
+
this.deferredRenderedUserInputs.splice(index, 1);
|
|
51
|
+
const trackedComponents = this.deferredRenderedUserInputComponents.get(text);
|
|
52
|
+
const componentsToRemove = trackedComponents?.shift();
|
|
53
|
+
if (trackedComponents && trackedComponents.length === 0) {
|
|
54
|
+
this.deferredRenderedUserInputComponents.delete(text);
|
|
55
|
+
}
|
|
56
|
+
if (!componentsToRemove)
|
|
57
|
+
return;
|
|
58
|
+
for (const component of componentsToRemove) {
|
|
59
|
+
this.chatContainer.removeChild(component);
|
|
60
|
+
}
|
|
61
|
+
this.updatePendingMessagesDisplay();
|
|
62
|
+
this.ui.requestRender();
|
|
63
|
+
};
|
|
23
64
|
InteractiveModeBase.prototype.chatMessageRenderOptions = function () {
|
|
24
65
|
return {
|
|
25
66
|
ui: this.ui,
|
|
@@ -118,6 +159,9 @@ InteractiveModeBase.prototype.addMessageToChat = function (message, options) {
|
|
|
118
159
|
};
|
|
119
160
|
InteractiveModeBase.prototype.renderSessionContext = function (sessionContext, options = {}) {
|
|
120
161
|
this.pendingTools.clear();
|
|
162
|
+
const pendingDeferredInputs = [...this.deferredRenderedUserInputs];
|
|
163
|
+
this.deferredRenderedUserInputs = [];
|
|
164
|
+
this.deferredRenderedUserInputComponents.clear();
|
|
121
165
|
if (options.updateFooter) {
|
|
122
166
|
this.footer.invalidate();
|
|
123
167
|
this.updateEditorBorderColor();
|
|
@@ -134,9 +178,22 @@ InteractiveModeBase.prototype.renderSessionContext = function (sessionContext, o
|
|
|
134
178
|
this.editor.addToHistory?.(entry.text);
|
|
135
179
|
}
|
|
136
180
|
}
|
|
181
|
+
for (const input of pendingDeferredInputs) {
|
|
182
|
+
this.renderDeferredUserInput(input);
|
|
183
|
+
}
|
|
137
184
|
this.ui.requestRender();
|
|
138
185
|
};
|
|
186
|
+
InteractiveModeBase.prototype.attachStartupNoticesContainer = function (options = {}) {
|
|
187
|
+
const isAttached = this.chatContainer.children.includes(this.startupNoticesContainer);
|
|
188
|
+
if (isAttached)
|
|
189
|
+
return;
|
|
190
|
+
if (options.resetDetached) {
|
|
191
|
+
this.startupNoticesContainer.clear();
|
|
192
|
+
}
|
|
193
|
+
this.chatContainer.addChild(this.startupNoticesContainer);
|
|
194
|
+
};
|
|
139
195
|
InteractiveModeBase.prototype.renderInitialMessages = function () {
|
|
196
|
+
this.attachStartupNoticesContainer({ resetDetached: true });
|
|
140
197
|
// Get aligned messages and entries from session context
|
|
141
198
|
const context = this.sessionManager.buildSessionContext();
|
|
142
199
|
this.renderSessionContext(context, {
|
|
@@ -152,19 +209,31 @@ InteractiveModeBase.prototype.renderInitialMessages = function () {
|
|
|
152
209
|
}
|
|
153
210
|
};
|
|
154
211
|
InteractiveModeBase.prototype.getUserInput = async function () {
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
212
|
+
for (let attempt = 0; !this.startupCookedInputRecovered && attempt < 10; attempt += 1) {
|
|
213
|
+
await yieldToEventLoop();
|
|
214
|
+
if (this.recoverCookedStartupInput?.())
|
|
215
|
+
break;
|
|
216
|
+
}
|
|
217
|
+
while (true) {
|
|
218
|
+
const queuedInput = this.pendingUserInputs.shift();
|
|
219
|
+
if (queuedInput !== undefined) {
|
|
220
|
+
return queuedInput;
|
|
221
|
+
}
|
|
222
|
+
if (this.startupReplayActiveInput) {
|
|
223
|
+
await this.drainStartupReplayCommands();
|
|
224
|
+
continue;
|
|
225
|
+
}
|
|
226
|
+
return new Promise((resolve) => {
|
|
227
|
+
this.onInputCallback = (text) => {
|
|
228
|
+
this.onInputCallback = undefined;
|
|
229
|
+
resolve(text);
|
|
230
|
+
};
|
|
231
|
+
});
|
|
158
232
|
}
|
|
159
|
-
return new Promise((resolve) => {
|
|
160
|
-
this.onInputCallback = (text) => {
|
|
161
|
-
this.onInputCallback = undefined;
|
|
162
|
-
resolve(text);
|
|
163
|
-
};
|
|
164
|
-
});
|
|
165
233
|
};
|
|
166
234
|
InteractiveModeBase.prototype.rebuildChatFromMessages = function () {
|
|
167
235
|
this.chatContainer.clear();
|
|
236
|
+
this.attachStartupNoticesContainer();
|
|
168
237
|
const context = this.sessionManager.buildSessionContext();
|
|
169
238
|
this.renderSessionContext(context);
|
|
170
239
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interactive-render-chat.js","sourceRoot":"","sources":["../../../src/modes/interactive/interactive-render-chat.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AACjE,OAAO,EAAqK,MAAM,EAAE,IAAI,EAAE,eAAe,EAAE,yBAAyB,EAAE,sBAAsB,EAAE,6BAA6B,EAAE,4BAA4B,EAAE,sBAAsB,EAAE,sBAAsB,EAAE,wCAAwC,EAAE,sBAAsB,EAAE,+BAA+B,EAAE,sBAAsB,EAAE,oBAAoB,EAAE,KAAK,EAAE,MAAM,4BAA4B,CAAC;AAEtiB,mBAAmB,CAAC,SA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,iBAAiB,CAAC,KAAK,EAAE,CAAC;IACnD,IAAI,WAAW,KAAK,SAAS,EAAE,CAAC;QAC9B,OAAO,WAAW,CAAC;IACrB,CAAC;IAED,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;QAC7B,IAAI,CAAC,eAAe,GAAG,CAAC,IAAY,EAAE,EAAE;YACtC,IAAI,CAAC,eAAe,GAAG,SAAS,CAAC;YACjC,OAAO,CAAC,IAAI,CAAC,CAAC;QAChB,CAAC,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC,CAAC;AAEJ,mBAAmB,CAAC,SAAS,CAAC,uBAAuB,GAAG;IACpD,IAAI,CAAC,aAAa,CAAC,KAAK,EAAE,CAAC;IAC3B,MAAM,OAAO,GAAG,IAAI,CAAC,cAAc,CAAC,mBAAmB,EAAE,CAAC;IAC1D,IAAI,CAAC,oBAAoB,CAAC,OAAO,CAAC,CAAC;AACrC,CAAC,CAAC","sourcesContent":["import { InteractiveModeBase } from \"./interactive-mode-base.ts\";\nimport { type AgentMessage, type Component, type ContextCompactionResult, type SessionContext, type TruncationResult, type ChatMessageEntry, type ChatMessageRenderOptions, Spacer, Text, parseSkillBlock, AssistantMessageComponent, BashExecutionComponent, BranchSummaryMessageComponent, chatEntriesFromAgentMessages, renderChatMessageEntry, addChatTranscriptEntry, ContextCompactionSummaryMessageComponent, CustomMessageComponent, SkillInvocationMessageComponent, ToolExecutionComponent, UserMessageComponent, theme } from \"./interactive-mode-deps.ts\";\n\nInteractiveModeBase.prototype.showStatus = function(this: InteractiveModeBase, message: string): void {\n const children = this.chatContainer.children;\n const last =\n children.length > 0 ? children[children.length - 1] : undefined;\n const secondLast =\n children.length > 1 ? children[children.length - 2] : undefined;\n\n if (\n last &&\n secondLast &&\n last === this.lastStatusText &&\n secondLast === this.lastStatusSpacer\n ) {\n this.lastStatusText.setText(theme.fg(\"dim\", message));\n this.ui.requestRender();\n return;\n }\n\n const spacer = new Spacer(1);\n const text = new Text(theme.fg(\"dim\", message), 1, 0);\n this.chatContainer.addChild(spacer);\n this.chatContainer.addChild(text);\n this.lastStatusSpacer = spacer;\n this.lastStatusText = text;\n this.ui.requestRender();\n };\n\nInteractiveModeBase.prototype.chatMessageRenderOptions = function(this: InteractiveModeBase): ChatMessageRenderOptions {\n return {\n ui: this.ui,\n cwd: this.sessionManager.getCwd(),\n markdownTheme: this.getMarkdownThemeWithSettings(),\n hideThinkingBlock: this.hideThinkingBlock,\n hiddenThinkingLabel: this.hiddenThinkingLabel,\n toolOutputExpanded: this.toolOutputExpanded,\n showImages: this.settingsManager.getShowImages(),\n imageWidthCells: this.settingsManager.getImageWidthCells(),\n outputPad: this.outputPad,\n getToolDefinition: (toolName) => this.getRegisteredToolDefinition(toolName),\n getCustomMessageRenderer: (customType) =>\n this.session.extensionRunner.getMessageRenderer(customType),\n };\n };\n\nInteractiveModeBase.prototype.addRenderedChatEntry = function(this: InteractiveModeBase, entry: ChatMessageEntry): Component {\n const component = renderChatMessageEntry(entry, this.chatMessageRenderOptions());\n addChatTranscriptEntry(this.chatContainer, component, entry.role);\n return component;\n };\n\nInteractiveModeBase.prototype.addContextCompactionSummaryToChat = function(this: InteractiveModeBase, result: ContextCompactionResult): void {\n this.chatContainer.addChild(new Spacer(1));\n const component = new ContextCompactionSummaryMessageComponent(\n result,\n this.getMarkdownThemeWithSettings(),\n );\n component.setExpanded(this.toolOutputExpanded);\n this.chatContainer.addChild(component);\n };\n\nInteractiveModeBase.prototype.addMessageToChat = function(this: InteractiveModeBase, message: AgentMessage, options?: { populateHistory?: boolean }): void {\n switch (message.role) {\n case \"bashExecution\": {\n const component = new BashExecutionComponent(\n message.command,\n this.ui,\n message.excludeFromContext,\n );\n if (message.output) {\n component.appendOutput(message.output);\n }\n component.setComplete(\n message.exitCode,\n message.cancelled,\n message.truncated\n ? ({ truncated: true } as TruncationResult)\n : undefined,\n message.fullOutputPath,\n );\n this.chatContainer.addChild(component);\n break;\n }\n case \"custom\": {\n if (message.display) {\n const renderer = this.session.extensionRunner.getMessageRenderer(\n message.customType,\n );\n const component = new CustomMessageComponent(\n message,\n renderer,\n this.getMarkdownThemeWithSettings(),\n );\n component.setExpanded(this.toolOutputExpanded);\n this.chatContainer.addChild(component);\n }\n break;\n }\n case \"branchSummary\": {\n this.chatContainer.addChild(new Spacer(1));\n const component = new BranchSummaryMessageComponent(\n message,\n this.getMarkdownThemeWithSettings(),\n );\n component.setExpanded(this.toolOutputExpanded);\n this.chatContainer.addChild(component);\n break;\n }\n case \"user\": {\n const textContent = this.getUserMessageText(message);\n if (textContent) {\n if (this.chatContainer.children.length > 0) {\n this.chatContainer.addChild(new Spacer(1));\n }\n const skillBlock = parseSkillBlock(textContent);\n if (skillBlock) {\n // Render skill block (collapsible)\n const component = new SkillInvocationMessageComponent(\n skillBlock,\n this.getMarkdownThemeWithSettings(),\n );\n component.setExpanded(this.toolOutputExpanded);\n this.chatContainer.addChild(component);\n // Render user message separately if present\n if (skillBlock.userMessage) {\n const userComponent = new UserMessageComponent(\n skillBlock.userMessage,\n this.getMarkdownThemeWithSettings(),\n this.outputPad,\n );\n this.chatContainer.addChild(userComponent);\n }\n } else {\n const userComponent = new UserMessageComponent(\n textContent,\n this.getMarkdownThemeWithSettings(),\n this.outputPad,\n );\n this.chatContainer.addChild(userComponent);\n }\n if (options?.populateHistory) {\n this.editor.addToHistory?.(textContent);\n }\n }\n break;\n }\n case \"assistant\": {\n const assistantComponent = new AssistantMessageComponent(\n message,\n this.hideThinkingBlock,\n this.getMarkdownThemeWithSettings(),\n this.hiddenThinkingLabel,\n this.outputPad,\n );\n this.chatContainer.addChild(assistantComponent);\n break;\n }\n case \"toolResult\": {\n // Tool results are rendered inline with tool calls, handled separately\n break;\n }\n default:\n break;\n }\n };\n\nInteractiveModeBase.prototype.renderSessionContext = function(this: InteractiveModeBase, sessionContext: SessionContext, options: { updateFooter?: boolean; populateHistory?: boolean } = {}): void {\n this.pendingTools.clear();\n\n if (options.updateFooter) {\n this.footer.invalidate();\n this.updateEditorBorderColor();\n }\n\n const entries = chatEntriesFromAgentMessages(sessionContext.messages);\n for (const entry of entries) {\n const component = this.addRenderedChatEntry(entry);\n if (\n entry.kind === \"tool\" &&\n entry.isPartial !== false &&\n component instanceof ToolExecutionComponent\n ) {\n this.pendingTools.set(entry.toolCallId, component);\n }\n if (options.populateHistory && entry.kind === \"user\") {\n this.editor.addToHistory?.(entry.text);\n }\n }\n\n this.ui.requestRender();\n };\n\nInteractiveModeBase.prototype.renderInitialMessages = function(this: InteractiveModeBase): void {\n // Get aligned messages and entries from session context\n const context = this.sessionManager.buildSessionContext();\n this.renderSessionContext(context, {\n updateFooter: true,\n populateHistory: true,\n });\n\n // Show compaction info if session was compacted\n const allEntries = this.sessionManager.getEntries();\n const compactionCount = allEntries.filter(\n (e) => e.type === \"compaction\",\n ).length;\n if (compactionCount > 0) {\n const times =\n compactionCount === 1 ? \"1 time\" : `${compactionCount} times`;\n this.showStatus(`Session compacted ${times}`);\n }\n };\n\nInteractiveModeBase.prototype.getUserInput = async function(this: InteractiveModeBase): Promise<string> {\n const queuedInput = this.pendingUserInputs.shift();\n if (queuedInput !== undefined) {\n return queuedInput;\n }\n\n return new Promise((resolve) => {\n this.onInputCallback = (text: string) => {\n this.onInputCallback = undefined;\n resolve(text);\n };\n });\n };\n\nInteractiveModeBase.prototype.rebuildChatFromMessages = function(this: InteractiveModeBase): void {\n this.chatContainer.clear();\n const context = this.sessionManager.buildSessionContext();\n this.renderSessionContext(context);\n };\n"]}
|
|
1
|
+
{"version":3,"file":"interactive-render-chat.js","sourceRoot":"","sources":["../../../src/modes/interactive/interactive-render-chat.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AACjE,OAAO,EAAqK,MAAM,EAAE,IAAI,EAAE,eAAe,EAAE,yBAAyB,EAAE,sBAAsB,EAAE,6BAA6B,EAAE,4BAA4B,EAAE,sBAAsB,EAAE,sBAAsB,EAAE,wCAAwC,E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AC;gBACjC,OAAO,CAAC,IAAI,CAAC,CAAC;YAChB,CAAC,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC;AACH,CAAC,CAAC;AAEJ,mBAAmB,CAAC,SAAS,CAAC,uBAAuB,GAAG;IACpD,IAAI,CAAC,aAAa,CAAC,KAAK,EAAE,CAAC;IAC3B,IAAI,CAAC,6BAA6B,EAAE,CAAC;IACrC,MAAM,OAAO,GAAG,IAAI,CAAC,cAAc,CAAC,mBAAmB,EAAE,CAAC;IAC1D,IAAI,CAAC,oBAAoB,CAAC,OAAO,CAAC,CAAC;AACrC,CAAC,CAAC","sourcesContent":["import { InteractiveModeBase } from \"./interactive-mode-base.ts\";\nimport { type AgentMessage, type Component, type ContextCompactionResult, type SessionContext, type TruncationResult, type ChatMessageEntry, type ChatMessageRenderOptions, Spacer, Text, parseSkillBlock, AssistantMessageComponent, BashExecutionComponent, BranchSummaryMessageComponent, chatEntriesFromAgentMessages, renderChatMessageEntry, addChatTranscriptEntry, ContextCompactionSummaryMessageComponent, CustomMessageComponent, SkillInvocationMessageComponent, ToolExecutionComponent, UserMessageComponent, theme } from \"./interactive-mode-deps.ts\";\nimport { yieldToEventLoop } from \"../../utils/event-loop.ts\";\n\nInteractiveModeBase.prototype.showStatus = function(this: InteractiveModeBase, message: string): void {\n const children = this.chatContainer.children;\n const last =\n children.length > 0 ? children[children.length - 1] : undefined;\n const secondLast =\n children.length > 1 ? children[children.length - 2] : undefined;\n\n if (\n last &&\n secondLast &&\n last === this.lastStatusText &&\n secondLast === this.lastStatusSpacer\n ) {\n this.lastStatusText.setText(theme.fg(\"dim\", message));\n this.ui.requestRender();\n return;\n }\n\n const spacer = new Spacer(1);\n const text = new Text(theme.fg(\"dim\", message), 1, 0);\n this.chatContainer.addChild(spacer);\n this.chatContainer.addChild(text);\n this.lastStatusSpacer = spacer;\n this.lastStatusText = text;\n this.ui.requestRender();\n };\n\nInteractiveModeBase.prototype.renderDeferredUserInput = function(this: InteractiveModeBase, text: string): void {\n this.deferredRenderedUserInputs.push(text);\n const startIndex = this.chatContainer.children.length;\n this.addMessageToChat({ role: \"user\", content: text } as AgentMessage);\n const renderedComponents = this.chatContainer.children.slice(startIndex);\n const trackedComponents = this.deferredRenderedUserInputComponents.get(text) ?? [];\n trackedComponents.push(renderedComponents);\n this.deferredRenderedUserInputComponents.set(text, trackedComponents);\n this.updatePendingMessagesDisplay();\n this.ui.requestRender();\n };\n\nInteractiveModeBase.prototype.consumeDeferredRenderedUserInput = function(this: InteractiveModeBase, text: string): boolean {\n const index = this.deferredRenderedUserInputs.indexOf(text);\n if (index === -1) return false;\n this.deferredRenderedUserInputs.splice(index, 1);\n const trackedComponents = this.deferredRenderedUserInputComponents.get(text);\n trackedComponents?.shift();\n if (trackedComponents && trackedComponents.length === 0) {\n this.deferredRenderedUserInputComponents.delete(text);\n }\n return true;\n };\n\nInteractiveModeBase.prototype.discardDeferredRenderedUserInput = function(this: InteractiveModeBase, text: string): void {\n const index = this.deferredRenderedUserInputs.indexOf(text);\n if (index !== -1) this.deferredRenderedUserInputs.splice(index, 1);\n const trackedComponents = this.deferredRenderedUserInputComponents.get(text);\n const componentsToRemove = trackedComponents?.shift();\n if (trackedComponents && trackedComponents.length === 0) {\n this.deferredRenderedUserInputComponents.delete(text);\n }\n if (!componentsToRemove) return;\n for (const component of componentsToRemove) {\n this.chatContainer.removeChild(component);\n }\n this.updatePendingMessagesDisplay();\n this.ui.requestRender();\n };\n\nInteractiveModeBase.prototype.chatMessageRenderOptions = function(this: InteractiveModeBase): ChatMessageRenderOptions {\n return {\n ui: this.ui,\n cwd: this.sessionManager.getCwd(),\n markdownTheme: this.getMarkdownThemeWithSettings(),\n hideThinkingBlock: this.hideThinkingBlock,\n hiddenThinkingLabel: this.hiddenThinkingLabel,\n toolOutputExpanded: this.toolOutputExpanded,\n showImages: this.settingsManager.getShowImages(),\n imageWidthCells: this.settingsManager.getImageWidthCells(),\n outputPad: this.outputPad,\n getToolDefinition: (toolName) => this.getRegisteredToolDefinition(toolName),\n getCustomMessageRenderer: (customType) =>\n this.session.extensionRunner.getMessageRenderer(customType),\n };\n };\n\nInteractiveModeBase.prototype.addRenderedChatEntry = function(this: InteractiveModeBase, entry: ChatMessageEntry): Component {\n const component = renderChatMessageEntry(entry, this.chatMessageRenderOptions());\n addChatTranscriptEntry(this.chatContainer, component, entry.role);\n return component;\n };\n\nInteractiveModeBase.prototype.addContextCompactionSummaryToChat = function(this: InteractiveModeBase, result: ContextCompactionResult): void {\n this.chatContainer.addChild(new Spacer(1));\n const component = new ContextCompactionSummaryMessageComponent(\n result,\n this.getMarkdownThemeWithSettings(),\n );\n component.setExpanded(this.toolOutputExpanded);\n this.chatContainer.addChild(component);\n };\n\nInteractiveModeBase.prototype.addMessageToChat = function(this: InteractiveModeBase, message: AgentMessage, options?: { populateHistory?: boolean }): void {\n switch (message.role) {\n case \"bashExecution\": {\n const component = new BashExecutionComponent(\n message.command,\n this.ui,\n message.excludeFromContext,\n );\n if (message.output) {\n component.appendOutput(message.output);\n }\n component.setComplete(\n message.exitCode,\n message.cancelled,\n message.truncated\n ? ({ truncated: true } as TruncationResult)\n : undefined,\n message.fullOutputPath,\n );\n this.chatContainer.addChild(component);\n break;\n }\n case \"custom\": {\n if (message.display) {\n const renderer = this.session.extensionRunner.getMessageRenderer(\n message.customType,\n );\n const component = new CustomMessageComponent(\n message,\n renderer,\n this.getMarkdownThemeWithSettings(),\n );\n component.setExpanded(this.toolOutputExpanded);\n this.chatContainer.addChild(component);\n }\n break;\n }\n case \"branchSummary\": {\n this.chatContainer.addChild(new Spacer(1));\n const component = new BranchSummaryMessageComponent(\n message,\n this.getMarkdownThemeWithSettings(),\n );\n component.setExpanded(this.toolOutputExpanded);\n this.chatContainer.addChild(component);\n break;\n }\n case \"user\": {\n const textContent = this.getUserMessageText(message);\n if (textContent) {\n if (this.chatContainer.children.length > 0) {\n this.chatContainer.addChild(new Spacer(1));\n }\n const skillBlock = parseSkillBlock(textContent);\n if (skillBlock) {\n // Render skill block (collapsible)\n const component = new SkillInvocationMessageComponent(\n skillBlock,\n this.getMarkdownThemeWithSettings(),\n );\n component.setExpanded(this.toolOutputExpanded);\n this.chatContainer.addChild(component);\n // Render user message separately if present\n if (skillBlock.userMessage) {\n const userComponent = new UserMessageComponent(\n skillBlock.userMessage,\n this.getMarkdownThemeWithSettings(),\n this.outputPad,\n );\n this.chatContainer.addChild(userComponent);\n }\n } else {\n const userComponent = new UserMessageComponent(\n textContent,\n this.getMarkdownThemeWithSettings(),\n this.outputPad,\n );\n this.chatContainer.addChild(userComponent);\n }\n if (options?.populateHistory) {\n this.editor.addToHistory?.(textContent);\n }\n }\n break;\n }\n case \"assistant\": {\n const assistantComponent = new AssistantMessageComponent(\n message,\n this.hideThinkingBlock,\n this.getMarkdownThemeWithSettings(),\n this.hiddenThinkingLabel,\n this.outputPad,\n );\n this.chatContainer.addChild(assistantComponent);\n break;\n }\n case \"toolResult\": {\n // Tool results are rendered inline with tool calls, handled separately\n break;\n }\n default:\n break;\n }\n };\n\nInteractiveModeBase.prototype.renderSessionContext = function(this: InteractiveModeBase, sessionContext: SessionContext, options: { updateFooter?: boolean; populateHistory?: boolean } = {}): void {\n this.pendingTools.clear();\n const pendingDeferredInputs = [...this.deferredRenderedUserInputs];\n this.deferredRenderedUserInputs = [];\n this.deferredRenderedUserInputComponents.clear();\n\n if (options.updateFooter) {\n this.footer.invalidate();\n this.updateEditorBorderColor();\n }\n\n const entries = chatEntriesFromAgentMessages(sessionContext.messages);\n for (const entry of entries) {\n const component = this.addRenderedChatEntry(entry);\n if (\n entry.kind === \"tool\" &&\n entry.isPartial !== false &&\n component instanceof ToolExecutionComponent\n ) {\n this.pendingTools.set(entry.toolCallId, component);\n }\n if (options.populateHistory && entry.kind === \"user\") {\n this.editor.addToHistory?.(entry.text);\n }\n }\n\n for (const input of pendingDeferredInputs) {\n this.renderDeferredUserInput(input);\n }\n\n this.ui.requestRender();\n };\n\nInteractiveModeBase.prototype.attachStartupNoticesContainer = function(this: InteractiveModeBase, options: { resetDetached?: boolean } = {}): void {\n const isAttached = this.chatContainer.children.includes(this.startupNoticesContainer);\n if (isAttached) return;\n if (options.resetDetached) {\n this.startupNoticesContainer.clear();\n }\n this.chatContainer.addChild(this.startupNoticesContainer);\n };\n\nInteractiveModeBase.prototype.renderInitialMessages = function(this: InteractiveModeBase): void {\n this.attachStartupNoticesContainer({ resetDetached: true });\n // Get aligned messages and entries from session context\n const context = this.sessionManager.buildSessionContext();\n this.renderSessionContext(context, {\n updateFooter: true,\n populateHistory: true,\n });\n\n // Show compaction info if session was compacted\n const allEntries = this.sessionManager.getEntries();\n const compactionCount = allEntries.filter(\n (e) => e.type === \"compaction\",\n ).length;\n if (compactionCount > 0) {\n const times =\n compactionCount === 1 ? \"1 time\" : `${compactionCount} times`;\n this.showStatus(`Session compacted ${times}`);\n }\n };\n\nInteractiveModeBase.prototype.getUserInput = async function(this: InteractiveModeBase): Promise<string> {\n for (let attempt = 0; !this.startupCookedInputRecovered && attempt < 10; attempt += 1) {\n await yieldToEventLoop();\n if (this.recoverCookedStartupInput?.()) break;\n }\n while (true) {\n const queuedInput = this.pendingUserInputs.shift();\n if (queuedInput !== undefined) {\n return queuedInput;\n }\n\n if (this.startupReplayActiveInput) {\n await this.drainStartupReplayCommands();\n continue;\n }\n\n return new Promise((resolve) => {\n this.onInputCallback = (text: string) => {\n this.onInputCallback = undefined;\n resolve(text);\n };\n });\n }\n };\n\nInteractiveModeBase.prototype.rebuildChatFromMessages = function(this: InteractiveModeBase): void {\n this.chatContainer.clear();\n this.attachStartupNoticesContainer();\n const context = this.sessionManager.buildSessionContext();\n this.renderSessionContext(context);\n };\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interactive-resource-disclosure.d.ts","sourceRoot":"","sources":["../../../src/modes/interactive/interactive-resource-disclosure.ts"],"names":[],"mappings":"","sourcesContent":["import { InteractiveModeBase } from \"./interactive-mode-base.ts\";\nimport { type ResourceDiagnostic, type SourceInfo, Spacer, theme } from \"./interactive-mode-deps.ts\";\nimport { ExpandableText } from \"./interactive-mode-helpers.ts\";\n\nInteractiveModeBase.prototype.formatDiagnostics = function(this: InteractiveModeBase, diagnostics: readonly ResourceDiagnostic[], sourceInfos: Map<string, SourceInfo>): string {\n const lines: string[] = [];\n\n // Group collision diagnostics by name\n const collisions = new Map<string, ResourceDiagnostic[]>();\n const otherDiagnostics: ResourceDiagnostic[] = [];\n\n for (const d of diagnostics) {\n if (d.type === \"collision\" && d.collision) {\n const list = collisions.get(d.collision.name) ?? [];\n list.push(d);\n collisions.set(d.collision.name, list);\n } else {\n otherDiagnostics.push(d);\n }\n }\n\n // Format collision diagnostics grouped by name\n for (const [name, collisionList] of collisions) {\n const first = collisionList[0]?.collision;\n if (!first) continue;\n lines.push(theme.fg(\"warning\", ` \"${name}\" collision:`));\n lines.push(\n theme.fg(\n \"dim\",\n ` ${theme.fg(\"success\", \"✓\")} ${this.formatPathWithSource(first.winnerPath, this.findSourceInfoForPath(first.winnerPath, sourceInfos))}`,\n ),\n );\n for (const d of collisionList) {\n if (d.collision) {\n lines.push(\n theme.fg(\n \"dim\",\n ` ${theme.fg(\"warning\", \"✗\")} ${this.formatPathWithSource(d.collision.loserPath, this.findSourceInfoForPath(d.collision.loserPath, sourceInfos))} (skipped)`,\n ),\n );\n }\n }\n }\n\n for (const d of otherDiagnostics) {\n if (d.path) {\n const formattedPath = this.formatPathWithSource(\n d.path,\n this.findSourceInfoForPath(d.path, sourceInfos),\n );\n lines.push(\n theme.fg(\n d.type === \"error\" ? \"error\" : \"warning\",\n ` ${formattedPath}`,\n ),\n );\n lines.push(\n theme.fg(\n d.type === \"error\" ? \"error\" : \"warning\",\n ` ${d.message}`,\n ),\n );\n } else {\n lines.push(\n theme.fg(d.type === \"error\" ? \"error\" : \"warning\", ` ${d.message}`),\n );\n }\n }\n\n return lines.join(\"\\n\");\n };\n\nInteractiveModeBase.prototype.getResourceDiagnosticsTotal = function(this: InteractiveModeBase, values: ResourceDiagnostic[][]): number {\n return values.reduce((total, diagnostics) => total + diagnostics.length, 0);\n };\n\nInteractiveModeBase.prototype.formatResourceCount = function(this: InteractiveModeBase, count: number, singular: string, plural = `${singular}s`): string | undefined {\n if (count <= 0) {\n return undefined;\n }\n return `${count} ${count === 1 ? singular : plural}`;\n };\n\nInteractiveModeBase.prototype.addResourceDisclosure = function(this: InteractiveModeBase, options: {\n contextFiles: ReadonlyArray<{ path: string }>;\n skills: ReadonlyArray<{ filePath: string; name: string }>;\n prompts: ReadonlyArray<{ filePath: string; name: string }>;\n templates: ReadonlyArray<{ filePath: string; name: string }>;\n extensions: ReadonlyArray<{ path: string; sourceInfo?: SourceInfo }>;\n themes: ReadonlyArray<{ name?: string; sourcePath?: string }>;\n diagnosticsTotal: number;\n expandedBody: string;\n }): void {\n const contextLabels = options.contextFiles.map((contextFile) =>\n this.formatContextPath(contextFile.path),\n );\n const promptCount = options.prompts.length + options.templates.length;\n const summaryParts = [\n contextLabels.length > 0 ? contextLabels.join(\", \") : \"context ready\",\n this.formatResourceCount(options.skills.length, \"skill\"),\n this.formatResourceCount(promptCount, \"prompt\"),\n this.formatResourceCount(options.extensions.length, \"extension\"),\n this.formatResourceCount(options.themes.length, \"theme\"),\n this.formatResourceCount(options.diagnosticsTotal, \"issue\"),\n ].filter((part): part is string => part !== undefined && part.length > 0);\n\n const collapsed = `${theme.bold(theme.fg(\"muted\", \"RESOURCES\"))} ${theme.fg(\"muted\", summaryParts.join(\" · \"))}`;\n\n const ok = theme.fg(\"success\", \"✓\");\n const pending = theme.fg(\"dim\", \"○\");\n const sep = theme.fg(\"dim\", \" · \");\n const label = (value: string) => theme.bold(theme.fg(\"text\", value.padEnd(10)));\n const mutedList = (values: string[], maxItems = 4) => {\n if (values.length === 0) {\n return theme.fg(\"dim\", \"none\");\n }\n const shown = values.slice(0, maxItems).join(\", \");\n const suffix = values.length > maxItems ? `, +${values.length - maxItems}` : \"\";\n return theme.fg(\"dim\", `${shown}${suffix}`);\n };\n\n const extensionLabels = this.getCompactExtensionLabels([...options.extensions]);\n const themeLabels = options.themes.map((loadedTheme) =>\n loadedTheme.name ??\n (loadedTheme.sourcePath\n ? this.getCompactPathLabel(loadedTheme.sourcePath, undefined)\n : \"theme\"),\n );\n const expandedSummary = [\n `${ok} ${label(\"Ready\")} ${contextLabels.length > 0 ? contextLabels.join(\", \") : \"context loaded\"}`,\n `${ok} ${label(\"Skills\")} ${options.skills.length} available${sep}${mutedList(options.skills.map((skill) => skill.name))}`,\n `${ok} ${label(\"Prompts\")} ${promptCount} available${sep}${mutedList([\n ...options.templates.map((template) => `/${template.name}`),\n ...options.prompts.map((prompt) => prompt.name),\n ])}`,\n `${ok} ${label(\"Extensions\")} ${options.extensions.length} available${sep}${mutedList(extensionLabels)}`,\n ];\n\n if (themeLabels.length > 0) {\n expandedSummary.push(\n `${ok} ${label(\"Themes\")} ${themeLabels.length} loaded${sep}${mutedList(themeLabels)}`,\n );\n }\n if (options.diagnosticsTotal > 0) {\n expandedSummary.push(\n `${pending} ${label(\"Issues\")} ${options.diagnosticsTotal} noted${sep}${theme.fg(\"dim\", \"details below\")}`,\n );\n }\n\n const expanded = `${collapsed}\\n${expandedSummary.join(\"\\n\")}${\n options.expandedBody.length > 0 ? `\\n\\n${options.expandedBody}` : \"\"\n }`;\n\n this.chatContainer.addChild(\n new ExpandableText(\n () => collapsed,\n () => expanded,\n this.getStartupExpansionState(),\n 0,\n 0,\n ),\n );\n
|
|
1
|
+
{"version":3,"file":"interactive-resource-disclosure.d.ts","sourceRoot":"","sources":["../../../src/modes/interactive/interactive-resource-disclosure.ts"],"names":[],"mappings":"","sourcesContent":["import { InteractiveModeBase } from \"./interactive-mode-base.ts\";\nimport { type Container, type ResourceDiagnostic, type SourceInfo, Spacer, theme } from \"./interactive-mode-deps.ts\";\nimport { ExpandableText } from \"./interactive-mode-helpers.ts\";\n\nInteractiveModeBase.prototype.formatDiagnostics = function(this: InteractiveModeBase, diagnostics: readonly ResourceDiagnostic[], sourceInfos: Map<string, SourceInfo>): string {\n const lines: string[] = [];\n\n // Group collision diagnostics by name\n const collisions = new Map<string, ResourceDiagnostic[]>();\n const otherDiagnostics: ResourceDiagnostic[] = [];\n\n for (const d of diagnostics) {\n if (d.type === \"collision\" && d.collision) {\n const list = collisions.get(d.collision.name) ?? [];\n list.push(d);\n collisions.set(d.collision.name, list);\n } else {\n otherDiagnostics.push(d);\n }\n }\n\n // Format collision diagnostics grouped by name\n for (const [name, collisionList] of collisions) {\n const first = collisionList[0]?.collision;\n if (!first) continue;\n lines.push(theme.fg(\"warning\", ` \"${name}\" collision:`));\n lines.push(\n theme.fg(\n \"dim\",\n ` ${theme.fg(\"success\", \"✓\")} ${this.formatPathWithSource(first.winnerPath, this.findSourceInfoForPath(first.winnerPath, sourceInfos))}`,\n ),\n );\n for (const d of collisionList) {\n if (d.collision) {\n lines.push(\n theme.fg(\n \"dim\",\n ` ${theme.fg(\"warning\", \"✗\")} ${this.formatPathWithSource(d.collision.loserPath, this.findSourceInfoForPath(d.collision.loserPath, sourceInfos))} (skipped)`,\n ),\n );\n }\n }\n }\n\n for (const d of otherDiagnostics) {\n if (d.path) {\n const formattedPath = this.formatPathWithSource(\n d.path,\n this.findSourceInfoForPath(d.path, sourceInfos),\n );\n lines.push(\n theme.fg(\n d.type === \"error\" ? \"error\" : \"warning\",\n ` ${formattedPath}`,\n ),\n );\n lines.push(\n theme.fg(\n d.type === \"error\" ? \"error\" : \"warning\",\n ` ${d.message}`,\n ),\n );\n } else {\n lines.push(\n theme.fg(d.type === \"error\" ? \"error\" : \"warning\", ` ${d.message}`),\n );\n }\n }\n\n return lines.join(\"\\n\");\n };\n\nInteractiveModeBase.prototype.getResourceDiagnosticsTotal = function(this: InteractiveModeBase, values: ResourceDiagnostic[][]): number {\n return values.reduce((total, diagnostics) => total + diagnostics.length, 0);\n };\n\nInteractiveModeBase.prototype.formatResourceCount = function(this: InteractiveModeBase, count: number, singular: string, plural = `${singular}s`): string | undefined {\n if (count <= 0) {\n return undefined;\n }\n return `${count} ${count === 1 ? singular : plural}`;\n };\n\nInteractiveModeBase.prototype.addResourceDisclosure = function(this: InteractiveModeBase, options: {\n contextFiles: ReadonlyArray<{ path: string }>;\n skills: ReadonlyArray<{ filePath: string; name: string }>;\n prompts: ReadonlyArray<{ filePath: string; name: string }>;\n templates: ReadonlyArray<{ filePath: string; name: string }>;\n extensions: ReadonlyArray<{ path: string; sourceInfo?: SourceInfo }>;\n themes: ReadonlyArray<{ name?: string; sourcePath?: string }>;\n diagnosticsTotal: number;\n expandedBody: string;\n targetContainer?: Container;\n }): void {\n const contextLabels = options.contextFiles.map((contextFile) =>\n this.formatContextPath(contextFile.path),\n );\n const promptCount = options.prompts.length + options.templates.length;\n const summaryParts = [\n contextLabels.length > 0 ? contextLabels.join(\", \") : \"context ready\",\n this.formatResourceCount(options.skills.length, \"skill\"),\n this.formatResourceCount(promptCount, \"prompt\"),\n this.formatResourceCount(options.extensions.length, \"extension\"),\n this.formatResourceCount(options.themes.length, \"theme\"),\n this.formatResourceCount(options.diagnosticsTotal, \"issue\"),\n ].filter((part): part is string => part !== undefined && part.length > 0);\n\n const collapsed = `${theme.bold(theme.fg(\"muted\", \"RESOURCES\"))} ${theme.fg(\"muted\", summaryParts.join(\" · \"))}`;\n\n const ok = theme.fg(\"success\", \"✓\");\n const pending = theme.fg(\"dim\", \"○\");\n const sep = theme.fg(\"dim\", \" · \");\n const label = (value: string) => theme.bold(theme.fg(\"text\", value.padEnd(10)));\n const mutedList = (values: string[], maxItems = 4) => {\n if (values.length === 0) {\n return theme.fg(\"dim\", \"none\");\n }\n const shown = values.slice(0, maxItems).join(\", \");\n const suffix = values.length > maxItems ? `, +${values.length - maxItems}` : \"\";\n return theme.fg(\"dim\", `${shown}${suffix}`);\n };\n\n const extensionLabels = this.getCompactExtensionLabels([...options.extensions]);\n const themeLabels = options.themes.map((loadedTheme) =>\n loadedTheme.name ??\n (loadedTheme.sourcePath\n ? this.getCompactPathLabel(loadedTheme.sourcePath, undefined)\n : \"theme\"),\n );\n const expandedSummary = [\n `${ok} ${label(\"Ready\")} ${contextLabels.length > 0 ? contextLabels.join(\", \") : \"context loaded\"}`,\n `${ok} ${label(\"Skills\")} ${options.skills.length} available${sep}${mutedList(options.skills.map((skill) => skill.name))}`,\n `${ok} ${label(\"Prompts\")} ${promptCount} available${sep}${mutedList([\n ...options.templates.map((template) => `/${template.name}`),\n ...options.prompts.map((prompt) => prompt.name),\n ])}`,\n `${ok} ${label(\"Extensions\")} ${options.extensions.length} available${sep}${mutedList(extensionLabels)}`,\n ];\n\n if (themeLabels.length > 0) {\n expandedSummary.push(\n `${ok} ${label(\"Themes\")} ${themeLabels.length} loaded${sep}${mutedList(themeLabels)}`,\n );\n }\n if (options.diagnosticsTotal > 0) {\n expandedSummary.push(\n `${pending} ${label(\"Issues\")} ${options.diagnosticsTotal} noted${sep}${theme.fg(\"dim\", \"details below\")}`,\n );\n }\n\n const expanded = `${collapsed}\\n${expandedSummary.join(\"\\n\")}${\n options.expandedBody.length > 0 ? `\\n\\n${options.expandedBody}` : \"\"\n }`;\n\n const targetContainer = options.targetContainer ?? this.chatContainer;\n targetContainer.addChild(\n new ExpandableText(\n () => collapsed,\n () => expanded,\n this.getStartupExpansionState(),\n 0,\n 0,\n ),\n );\n targetContainer.addChild(new Spacer(1));\n };\n"]}
|
|
@@ -95,7 +95,8 @@ InteractiveModeBase.prototype.addResourceDisclosure = function (options) {
|
|
|
95
95
|
expandedSummary.push(`${pending} ${label("Issues")} ${options.diagnosticsTotal} noted${sep}${theme.fg("dim", "details below")}`);
|
|
96
96
|
}
|
|
97
97
|
const expanded = `${collapsed}\n${expandedSummary.join("\n")}${options.expandedBody.length > 0 ? `\n\n${options.expandedBody}` : ""}`;
|
|
98
|
-
|
|
99
|
-
|
|
98
|
+
const targetContainer = options.targetContainer ?? this.chatContainer;
|
|
99
|
+
targetContainer.addChild(new ExpandableText(() => collapsed, () => expanded, this.getStartupExpansionState(), 0, 0));
|
|
100
|
+
targetContainer.addChild(new Spacer(1));
|
|
100
101
|
};
|
|
101
102
|
//# sourceMappingURL=interactive-resource-disclosure.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interactive-resource-disclosure.js","sourceRoot":"","sources":["../../../src/modes/interactive/interactive-resource-disclosure.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AACjE,OAAO,EAA4C,MAAM,EAAE,KAAK,EAAE,MAAM,4BAA4B,CAAC;AACrG,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAE/D,mBAAmB,CAAC,SAAS,CAAC,iBAAiB,GAAG,UAAoC,WAA0C,EAAE,WAAoC;IAClK,MAAM,KAAK,GAAa,EAAE,CAAC;IAE3B,sCAAsC;IACtC,MAAM,UAAU,GAAG,IAAI,GAAG,EAAgC,CAAC;IAC3D,MAAM,gBAAgB,GAAyB,EAAE,CAAC;IAElD,KAAK,MAAM,CAAC,IAAI,WAAW,EAAE,CAAC;QAC5B,IAAI,CAAC,CAAC,IAAI,KAAK,WAAW,IAAI,CAAC,CAAC,SAAS,EAAE,CAAC;YAC1C,MAAM,IAAI,GAAG,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC;YACpD,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;YACb,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,SAAS,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;QACzC,CAAC;aAAM,CAAC;YACN,gBAAgB,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAC3B,CAAC;IACH,CAAC;IAED,+CAA+C;IAC/C,KAAK,MAAM,CAAC,IAAI,EAAE,aAAa,CAAC,IAAI,UAAU,EAAE,CAAC;QAC/C,MAAM,KAAK,GAAG,aAAa,CAAC,CAAC,CAAC,EAAE,SAAS,CAAC;QAC1C,IAA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GAC1D,OAAO,CAAC,YAAY,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,OAAO,OAAO,CAAC,YAAY,EAAE,CAAC,CAAC,CAAC,EACpE,EAAE,CAAC;IAEH,IAAI,CAAC,aAAa,CAAC,QAAQ,CACzB,IAAI,cAAc,CAChB,GAAG,EAAE,CAAC,SAAS,EACf,GAAG,EAAE,CAAC,QAAQ,EACd,IAAI,CAAC,wBAAwB,EAAE,EAC/B,CAAC,EACD,CAAC,CACF,CACF,CAAC;IACF,IAAI,CAAC,aAAa,CAAC,QAAQ,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;AAC7C,CAAC,CAAC","sourcesContent":["import { InteractiveModeBase } from \"./interactive-mode-base.ts\";\nimport { type ResourceDiagnostic, type SourceInfo, Spacer, theme } from \"./interactive-mode-deps.ts\";\nimport { ExpandableText } from \"./interactive-mode-helpers.ts\";\n\nInteractiveModeBase.prototype.formatDiagnostics = function(this: InteractiveModeBase, diagnostics: readonly ResourceDiagnostic[], sourceInfos: Map<string, SourceInfo>): string {\n const lines: string[] = [];\n\n // Group collision diagnostics by name\n const collisions = new Map<string, ResourceDiagnostic[]>();\n const otherDiagnostics: ResourceDiagnostic[] = [];\n\n for (const d of diagnostics) {\n if (d.type === \"collision\" && d.collision) {\n const list = collisions.get(d.collision.name) ?? [];\n list.push(d);\n collisions.set(d.collision.name, list);\n } else {\n otherDiagnostics.push(d);\n }\n }\n\n // Format collision diagnostics grouped by name\n for (const [name, collisionList] of collisions) {\n const first = collisionList[0]?.collision;\n if (!first) continue;\n lines.push(theme.fg(\"warning\", ` \"${name}\" collision:`));\n lines.push(\n theme.fg(\n \"dim\",\n ` ${theme.fg(\"success\", \"✓\")} ${this.formatPathWithSource(first.winnerPath, this.findSourceInfoForPath(first.winnerPath, sourceInfos))}`,\n ),\n );\n for (const d of collisionList) {\n if (d.collision) {\n lines.push(\n theme.fg(\n \"dim\",\n ` ${theme.fg(\"warning\", \"✗\")} ${this.formatPathWithSource(d.collision.loserPath, this.findSourceInfoForPath(d.collision.loserPath, sourceInfos))} (skipped)`,\n ),\n );\n }\n }\n }\n\n for (const d of otherDiagnostics) {\n if (d.path) {\n const formattedPath = this.formatPathWithSource(\n d.path,\n this.findSourceInfoForPath(d.path, sourceInfos),\n );\n lines.push(\n theme.fg(\n d.type === \"error\" ? \"error\" : \"warning\",\n ` ${formattedPath}`,\n ),\n );\n lines.push(\n theme.fg(\n d.type === \"error\" ? \"error\" : \"warning\",\n ` ${d.message}`,\n ),\n );\n } else {\n lines.push(\n theme.fg(d.type === \"error\" ? \"error\" : \"warning\", ` ${d.message}`),\n );\n }\n }\n\n return lines.join(\"\\n\");\n };\n\nInteractiveModeBase.prototype.getResourceDiagnosticsTotal = function(this: InteractiveModeBase, values: ResourceDiagnostic[][]): number {\n return values.reduce((total, diagnostics) => total + diagnostics.length, 0);\n };\n\nInteractiveModeBase.prototype.formatResourceCount = function(this: InteractiveModeBase, count: number, singular: string, plural = `${singular}s`): string | undefined {\n if (count <= 0) {\n return undefined;\n }\n return `${count} ${count === 1 ? singular : plural}`;\n };\n\nInteractiveModeBase.prototype.addResourceDisclosure = function(this: InteractiveModeBase, options: {\n contextFiles: ReadonlyArray<{ path: string }>;\n skills: ReadonlyArray<{ filePath: string; name: string }>;\n prompts: ReadonlyArray<{ filePath: string; name: string }>;\n templates: ReadonlyArray<{ filePath: string; name: string }>;\n extensions: ReadonlyArray<{ path: string; sourceInfo?: SourceInfo }>;\n themes: ReadonlyArray<{ name?: string; sourcePath?: string }>;\n diagnosticsTotal: number;\n expandedBody: string;\n }): void {\n const contextLabels = options.contextFiles.map((contextFile) =>\n this.formatContextPath(contextFile.path),\n );\n const promptCount = options.prompts.length + options.templates.length;\n const summaryParts = [\n contextLabels.length > 0 ? contextLabels.join(\", \") : \"context ready\",\n this.formatResourceCount(options.skills.length, \"skill\"),\n this.formatResourceCount(promptCount, \"prompt\"),\n this.formatResourceCount(options.extensions.length, \"extension\"),\n this.formatResourceCount(options.themes.length, \"theme\"),\n this.formatResourceCount(options.diagnosticsTotal, \"issue\"),\n ].filter((part): part is string => part !== undefined && part.length > 0);\n\n const collapsed = `${theme.bold(theme.fg(\"muted\", \"RESOURCES\"))} ${theme.fg(\"muted\", summaryParts.join(\" · \"))}`;\n\n const ok = theme.fg(\"success\", \"✓\");\n const pending = theme.fg(\"dim\", \"○\");\n const sep = theme.fg(\"dim\", \" · \");\n const label = (value: string) => theme.bold(theme.fg(\"text\", value.padEnd(10)));\n const mutedList = (values: string[], maxItems = 4) => {\n if (values.length === 0) {\n return theme.fg(\"dim\", \"none\");\n }\n const shown = values.slice(0, maxItems).join(\", \");\n const suffix = values.length > maxItems ? `, +${values.length - maxItems}` : \"\";\n return theme.fg(\"dim\", `${shown}${suffix}`);\n };\n\n const extensionLabels = this.getCompactExtensionLabels([...options.extensions]);\n const themeLabels = options.themes.map((loadedTheme) =>\n loadedTheme.name ??\n (loadedTheme.sourcePath\n ? this.getCompactPathLabel(loadedTheme.sourcePath, undefined)\n : \"theme\"),\n );\n const expandedSummary = [\n `${ok} ${label(\"Ready\")} ${contextLabels.length > 0 ? contextLabels.join(\", \") : \"context loaded\"}`,\n `${ok} ${label(\"Skills\")} ${options.skills.length} available${sep}${mutedList(options.skills.map((skill) => skill.name))}`,\n `${ok} ${label(\"Prompts\")} ${promptCount} available${sep}${mutedList([\n ...options.templates.map((template) => `/${template.name}`),\n ...options.prompts.map((prompt) => prompt.name),\n ])}`,\n `${ok} ${label(\"Extensions\")} ${options.extensions.length} available${sep}${mutedList(extensionLabels)}`,\n ];\n\n if (themeLabels.length > 0) {\n expandedSummary.push(\n `${ok} ${label(\"Themes\")} ${themeLabels.length} loaded${sep}${mutedList(themeLabels)}`,\n );\n }\n if (options.diagnosticsTotal > 0) {\n expandedSummary.push(\n `${pending} ${label(\"Issues\")} ${options.diagnosticsTotal} noted${sep}${theme.fg(\"dim\", \"details below\")}`,\n );\n }\n\n const expanded = `${collapsed}\\n${expandedSummary.join(\"\\n\")}${\n options.expandedBody.length > 0 ? `\\n\\n${options.expandedBody}` : \"\"\n }`;\n\n this.chatContainer.addChild(\n new ExpandableText(\n () => collapsed,\n () => expanded,\n this.getStartupExpansionState(),\n 0,\n 0,\n ),\n );\n this.chatContainer.addChild(new Spacer(1));\n };\n"]}
|
|
1
|
+
{"version":3,"file":"interactive-resource-disclosure.js","sourceRoot":"","sources":["../../../src/modes/interactive/interactive-resource-disclosure.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AACjE,OAAO,EAA4D,MAAM,EAAE,KAAK,EAAE,MAAM,4BAA4B,CAAC;AACrH,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAE/D,mBAAmB,CAAC,SAAS,CAAC,iBAAiB,GAAG,UAAoC,WAA0C,EAAE,WAAoC;IAClK,MAAM,KAAK,GAAa,EAAE,CAAC;IAE3B,sCAAsC;IACtC,MAAM,UAAU,GAAG,IAAI,GAAG,EAAgC,CAAC;IAC3D,MAAM,gBAAgB,GAAyB,EAAE,CAAC;IAElD,KAAK,MAAM,CAAC,IAAI,WAAW,EAAE,CAAC;QAC5B,IAAI,CAAC,CAAC,IAAI,KAAK,WAAW,IAAI,CAAC,CAAC,SAAS,EAAE,CAAC;YAC1C,MAAM,IAAI,GAAG,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC;YACpD,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;YACb,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,SAAS,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;QACzC,CAAC;aAAM,CAAC;YACN,gBAAgB,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAC3B,CAAC;IACH,CAAC;IAED,+CAA+C;IAC/C,KAAK,MAAM,CAAC,IAAI,EAAE,aAAa,CAAC,IAAI,UAAU,EAAE,CAA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AC;IAED,MAAM,QAAQ,GAAG,GAAG,SAAS,KAAK,eAAe,CAAC,IAAI,CAAC,IAAI,CAAC,GAC1D,OAAO,CAAC,YAAY,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,OAAO,OAAO,CAAC,YAAY,EAAE,CAAC,CAAC,CAAC,EACpE,EAAE,CAAC;IAEH,MAAM,eAAe,GAAG,OAAO,CAAC,eAAe,IAAI,IAAI,CAAC,aAAa,CAAC;IACtE,eAAe,CAAC,QAAQ,CACtB,IAAI,cAAc,CAChB,GAAG,EAAE,CAAC,SAAS,EACf,GAAG,EAAE,CAAC,QAAQ,EACd,IAAI,CAAC,wBAAwB,EAAE,EAC/B,CAAC,EACD,CAAC,CACF,CACF,CAAC;IACF,eAAe,CAAC,QAAQ,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;AAC1C,CAAC,CAAC","sourcesContent":["import { InteractiveModeBase } from \"./interactive-mode-base.ts\";\nimport { type Container, type ResourceDiagnostic, type SourceInfo, Spacer, theme } from \"./interactive-mode-deps.ts\";\nimport { ExpandableText } from \"./interactive-mode-helpers.ts\";\n\nInteractiveModeBase.prototype.formatDiagnostics = function(this: InteractiveModeBase, diagnostics: readonly ResourceDiagnostic[], sourceInfos: Map<string, SourceInfo>): string {\n const lines: string[] = [];\n\n // Group collision diagnostics by name\n const collisions = new Map<string, ResourceDiagnostic[]>();\n const otherDiagnostics: ResourceDiagnostic[] = [];\n\n for (const d of diagnostics) {\n if (d.type === \"collision\" && d.collision) {\n const list = collisions.get(d.collision.name) ?? [];\n list.push(d);\n collisions.set(d.collision.name, list);\n } else {\n otherDiagnostics.push(d);\n }\n }\n\n // Format collision diagnostics grouped by name\n for (const [name, collisionList] of collisions) {\n const first = collisionList[0]?.collision;\n if (!first) continue;\n lines.push(theme.fg(\"warning\", ` \"${name}\" collision:`));\n lines.push(\n theme.fg(\n \"dim\",\n ` ${theme.fg(\"success\", \"✓\")} ${this.formatPathWithSource(first.winnerPath, this.findSourceInfoForPath(first.winnerPath, sourceInfos))}`,\n ),\n );\n for (const d of collisionList) {\n if (d.collision) {\n lines.push(\n theme.fg(\n \"dim\",\n ` ${theme.fg(\"warning\", \"✗\")} ${this.formatPathWithSource(d.collision.loserPath, this.findSourceInfoForPath(d.collision.loserPath, sourceInfos))} (skipped)`,\n ),\n );\n }\n }\n }\n\n for (const d of otherDiagnostics) {\n if (d.path) {\n const formattedPath = this.formatPathWithSource(\n d.path,\n this.findSourceInfoForPath(d.path, sourceInfos),\n );\n lines.push(\n theme.fg(\n d.type === \"error\" ? \"error\" : \"warning\",\n ` ${formattedPath}`,\n ),\n );\n lines.push(\n theme.fg(\n d.type === \"error\" ? \"error\" : \"warning\",\n ` ${d.message}`,\n ),\n );\n } else {\n lines.push(\n theme.fg(d.type === \"error\" ? \"error\" : \"warning\", ` ${d.message}`),\n );\n }\n }\n\n return lines.join(\"\\n\");\n };\n\nInteractiveModeBase.prototype.getResourceDiagnosticsTotal = function(this: InteractiveModeBase, values: ResourceDiagnostic[][]): number {\n return values.reduce((total, diagnostics) => total + diagnostics.length, 0);\n };\n\nInteractiveModeBase.prototype.formatResourceCount = function(this: InteractiveModeBase, count: number, singular: string, plural = `${singular}s`): string | undefined {\n if (count <= 0) {\n return undefined;\n }\n return `${count} ${count === 1 ? singular : plural}`;\n };\n\nInteractiveModeBase.prototype.addResourceDisclosure = function(this: InteractiveModeBase, options: {\n contextFiles: ReadonlyArray<{ path: string }>;\n skills: ReadonlyArray<{ filePath: string; name: string }>;\n prompts: ReadonlyArray<{ filePath: string; name: string }>;\n templates: ReadonlyArray<{ filePath: string; name: string }>;\n extensions: ReadonlyArray<{ path: string; sourceInfo?: SourceInfo }>;\n themes: ReadonlyArray<{ name?: string; sourcePath?: string }>;\n diagnosticsTotal: number;\n expandedBody: string;\n targetContainer?: Container;\n }): void {\n const contextLabels = options.contextFiles.map((contextFile) =>\n this.formatContextPath(contextFile.path),\n );\n const promptCount = options.prompts.length + options.templates.length;\n const summaryParts = [\n contextLabels.length > 0 ? contextLabels.join(\", \") : \"context ready\",\n this.formatResourceCount(options.skills.length, \"skill\"),\n this.formatResourceCount(promptCount, \"prompt\"),\n this.formatResourceCount(options.extensions.length, \"extension\"),\n this.formatResourceCount(options.themes.length, \"theme\"),\n this.formatResourceCount(options.diagnosticsTotal, \"issue\"),\n ].filter((part): part is string => part !== undefined && part.length > 0);\n\n const collapsed = `${theme.bold(theme.fg(\"muted\", \"RESOURCES\"))} ${theme.fg(\"muted\", summaryParts.join(\" · \"))}`;\n\n const ok = theme.fg(\"success\", \"✓\");\n const pending = theme.fg(\"dim\", \"○\");\n const sep = theme.fg(\"dim\", \" · \");\n const label = (value: string) => theme.bold(theme.fg(\"text\", value.padEnd(10)));\n const mutedList = (values: string[], maxItems = 4) => {\n if (values.length === 0) {\n return theme.fg(\"dim\", \"none\");\n }\n const shown = values.slice(0, maxItems).join(\", \");\n const suffix = values.length > maxItems ? `, +${values.length - maxItems}` : \"\";\n return theme.fg(\"dim\", `${shown}${suffix}`);\n };\n\n const extensionLabels = this.getCompactExtensionLabels([...options.extensions]);\n const themeLabels = options.themes.map((loadedTheme) =>\n loadedTheme.name ??\n (loadedTheme.sourcePath\n ? this.getCompactPathLabel(loadedTheme.sourcePath, undefined)\n : \"theme\"),\n );\n const expandedSummary = [\n `${ok} ${label(\"Ready\")} ${contextLabels.length > 0 ? contextLabels.join(\", \") : \"context loaded\"}`,\n `${ok} ${label(\"Skills\")} ${options.skills.length} available${sep}${mutedList(options.skills.map((skill) => skill.name))}`,\n `${ok} ${label(\"Prompts\")} ${promptCount} available${sep}${mutedList([\n ...options.templates.map((template) => `/${template.name}`),\n ...options.prompts.map((prompt) => prompt.name),\n ])}`,\n `${ok} ${label(\"Extensions\")} ${options.extensions.length} available${sep}${mutedList(extensionLabels)}`,\n ];\n\n if (themeLabels.length > 0) {\n expandedSummary.push(\n `${ok} ${label(\"Themes\")} ${themeLabels.length} loaded${sep}${mutedList(themeLabels)}`,\n );\n }\n if (options.diagnosticsTotal > 0) {\n expandedSummary.push(\n `${pending} ${label(\"Issues\")} ${options.diagnosticsTotal} noted${sep}${theme.fg(\"dim\", \"details below\")}`,\n );\n }\n\n const expanded = `${collapsed}\\n${expandedSummary.join(\"\\n\")}${\n options.expandedBody.length > 0 ? `\\n\\n${options.expandedBody}` : \"\"\n }`;\n\n const targetContainer = options.targetContainer ?? this.chatContainer;\n targetContainer.addChild(\n new ExpandableText(\n () => collapsed,\n () => expanded,\n this.getStartupExpansionState(),\n 0,\n 0,\n ),\n );\n targetContainer.addChild(new Spacer(1));\n };\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interactive-resource-rendering.d.ts","sourceRoot":"","sources":["../../../src/modes/interactive/interactive-resource-rendering.ts"],"names":[],"mappings":"","sourcesContent":["import { InteractiveModeBase } from \"./interactive-mode-base.ts\";\nimport { type ResourceDiagnostic, type SourceInfo, Spacer, Text, theme } from \"./interactive-mode-deps.ts\";\n\nInteractiveModeBase.prototype.showLoadedResources = function(this: InteractiveModeBase, options?: {\n extensions?: Array<{ path: string; sourceInfo?: SourceInfo }>;\n force?: boolean;\n showDiagnosticsWhenQuiet?: boolean;\n }): void {\n const showListing =\n options?.force ||\n this.options.verbose ||\n !this.settingsManager.getQuietStartup();\n const showDiagnostics =\n showListing || options?.showDiagnosticsWhenQuiet === true;\n if (!showListing && !showDiagnostics) {\n return;\n }\n\n const skillsResult = this.session.resourceLoader.getSkills();\n const promptsResult = this.session.resourceLoader.getPrompts();\n const themesResult = this.session.resourceLoader.getThemes();\n const extensions =\n options?.extensions ??\n this.session.resourceLoader\n .getExtensions()\n .extensions.map((extension) => ({\n path: extension.path,\n sourceInfo: extension.sourceInfo,\n }));\n const sourceInfos = new Map<string, SourceInfo>();\n for (const extension of extensions) {\n if (extension.sourceInfo) {\n sourceInfos.set(extension.path, extension.sourceInfo);\n }\n }\n for (const skill of skillsResult.skills) {\n if (skill.sourceInfo) {\n sourceInfos.set(skill.filePath, skill.sourceInfo);\n }\n }\n for (const prompt of promptsResult.prompts) {\n if (prompt.sourceInfo) {\n sourceInfos.set(prompt.filePath, prompt.sourceInfo);\n }\n }\n for (const loadedTheme of themesResult.themes) {\n if (loadedTheme.sourcePath && loadedTheme.sourceInfo) {\n sourceInfos.set(loadedTheme.sourcePath, loadedTheme.sourceInfo);\n }\n }\n\n if (showListing) {\n const contextFiles =\n this.session.resourceLoader.getAgentsFiles().agentsFiles;\n const templates = this.session.promptTemplates;\n const customThemes = themesResult.themes.filter((t) => t.sourcePath);\n\n const expandedSections: string[] = [];\n if (contextFiles.length > 0) {\n expandedSections.push(\n `${theme.bold(theme.fg(\"muted\", \"CONTEXT\"))}\\n${contextFiles\n .map((contextFile) => theme.fg(\"dim\", ` ${this.formatDisplayPath(contextFile.path)}`))\n .join(\"\\n\")}`,\n );\n }\n\n const skills = skillsResult.skills;\n if (skills.length > 0) {\n const groups = this.buildScopeGroups(\n skills.map((skill) => ({\n path: skill.filePath,\n sourceInfo: skill.sourceInfo,\n })),\n );\n expandedSections.push(\n `${theme.bold(theme.fg(\"muted\", \"SKILLS\"))}\\n${this.formatScopeGroups(groups, {\n formatPath: (item) => this.formatDisplayPath(item.path),\n formatPackagePath: (item) =>\n this.getShortPath(item.path, item.sourceInfo),\n })}`,\n );\n }\n\n if (templates.length > 0) {\n const groups = this.buildScopeGroups(\n templates.map((template) => ({\n path: template.filePath,\n sourceInfo: template.sourceInfo,\n })),\n );\n const templateByPath = new Map(templates.map((t) => [t.filePath, t]));\n expandedSections.push(\n `${theme.bold(theme.fg(\"muted\", \"PROMPTS\"))}\\n${this.formatScopeGroups(groups, {\n formatPath: (item) => {\n const template = templateByPath.get(item.path);\n return template\n ? `/${template.name}`\n : this.formatDisplayPath(item.path);\n },\n formatPackagePath: (item) => {\n const template = templateByPath.get(item.path);\n return template\n ? `/${template.name}`\n : this.formatDisplayPath(item.path);\n },\n })}`,\n );\n }\n\n const prompts = promptsResult.prompts;\n if (prompts.length > 0) {\n const groups = this.buildScopeGroups(\n prompts.map((prompt) => ({\n path: prompt.filePath,\n sourceInfo: prompt.sourceInfo,\n })),\n );\n const promptByPath = new Map(prompts.map((prompt) => [prompt.filePath, prompt]));\n expandedSections.push(\n `${theme.bold(theme.fg(\"muted\", \"PROMPTS\"))}\\n${this.formatScopeGroups(groups, {\n formatPath: (item) => promptByPath.get(item.path)?.name ?? this.formatDisplayPath(item.path),\n formatPackagePath: (item) => promptByPath.get(item.path)?.name ?? this.formatDisplayPath(item.path),\n })}`,\n );\n }\n\n if (extensions.length > 0) {\n const groups = this.buildScopeGroups(extensions);\n expandedSections.push(\n `${theme.bold(theme.fg(\"muted\", \"EXTENSIONS\"))}\\n${this.formatScopeGroups(groups, {\n formatPath: (item) => this.formatExtensionDisplayPath(item.path),\n formatPackagePath: (item) =>\n this.formatExtensionDisplayPath(\n this.getShortPath(item.path, item.sourceInfo),\n ),\n })}`,\n );\n }\n\n if (customThemes.length > 0) {\n const groups = this.buildScopeGroups(\n customThemes.map((loadedTheme) => ({\n path: loadedTheme.sourcePath!,\n sourceInfo: loadedTheme.sourceInfo,\n })),\n );\n expandedSections.push(\n `${theme.bold(theme.fg(\"muted\", \"THEMES\"))}\\n${this.formatScopeGroups(groups, {\n formatPath: (item) => this.formatDisplayPath(item.path),\n formatPackagePath: (item) =>\n this.getShortPath(item.path, item.sourceInfo),\n })}`,\n );\n }\n\n const extensionDiagnostics: ResourceDiagnostic[] = [];\n const extensionErrors =\n this.session.resourceLoader.getExtensions().errors;\n for (const error of extensionErrors) {\n extensionDiagnostics.push({\n type: \"error\",\n message: error.error,\n path: error.path,\n });\n }\n extensionDiagnostics.push(\n ...this.session.extensionRunner.getCommandDiagnostics(),\n ...this.getBuiltInCommandConflictDiagnostics(\n this.session.extensionRunner,\n ),\n ...this.session.extensionRunner.getShortcutDiagnostics(),\n );\n\n this.addResourceDisclosure({\n contextFiles,\n skills,\n prompts,\n templates,\n extensions,\n themes: customThemes,\n diagnosticsTotal: this.getResourceDiagnosticsTotal([\n skillsResult.diagnostics,\n promptsResult.diagnostics,\n extensionDiagnostics,\n themesResult.diagnostics,\n ]),\n expandedBody: this.options.verbose ? expandedSections.join(\"\\n\\n\") : \"\",\n });\n }\n\n if (showDiagnostics) {\n const skillDiagnostics = skillsResult.diagnostics;\n if (skillDiagnostics.length > 0) {\n const warningLines = this.formatDiagnostics(\n skillDiagnostics,\n sourceInfos,\n );\n this.chatContainer.addChild(\n new Text(\n `${theme.fg(\"warning\", \"[Skill conflicts]\")}\\n${warningLines}`,\n 0,\n 0,\n ),\n );\n this.chatContainer.addChild(new Spacer(1));\n }\n\n const promptDiagnostics = promptsResult.diagnostics;\n if (promptDiagnostics.length > 0) {\n const warningLines = this.formatDiagnostics(\n promptDiagnostics,\n sourceInfos,\n );\n this.chatContainer.addChild(\n new Text(\n `${theme.fg(\"warning\", \"[Prompt conflicts]\")}\\n${warningLines}`,\n 0,\n 0,\n ),\n );\n this.chatContainer.addChild(new Spacer(1));\n }\n\n const extensionDiagnostics: ResourceDiagnostic[] = [];\n const extensionErrors =\n this.session.resourceLoader.getExtensions().errors;\n if (extensionErrors.length > 0) {\n for (const error of extensionErrors) {\n extensionDiagnostics.push({\n type: \"error\",\n message: error.error,\n path: error.path,\n });\n }\n }\n\n const commandDiagnostics =\n this.session.extensionRunner.getCommandDiagnostics();\n extensionDiagnostics.push(...commandDiagnostics);\n extensionDiagnostics.push(\n ...this.getBuiltInCommandConflictDiagnostics(\n this.session.extensionRunner,\n ),\n );\n\n const shortcutDiagnostics =\n this.session.extensionRunner.getShortcutDiagnostics();\n extensionDiagnostics.push(...shortcutDiagnostics);\n\n if (extensionDiagnostics.length > 0) {\n const warningLines = this.formatDiagnostics(\n extensionDiagnostics,\n sourceInfos,\n );\n this.chatContainer.addChild(\n new Text(\n `${theme.fg(\"warning\", \"[Extension issues]\")}\\n${warningLines}`,\n 0,\n 0,\n ),\n );\n this.chatContainer.addChild(new Spacer(1));\n }\n\n const themeDiagnostics = themesResult.diagnostics;\n if (themeDiagnostics.length > 0) {\n const warningLines = this.formatDiagnostics(\n themeDiagnostics,\n sourceInfos,\n );\n this.chatContainer.addChild(\n new Text(\n `${theme.fg(\"warning\", \"[Theme conflicts]\")}\\n${warningLines}`,\n 0,\n 0,\n ),\n );\n this.chatContainer.addChild(new Spacer(1));\n }\n }\n };\n"]}
|
|
1
|
+
{"version":3,"file":"interactive-resource-rendering.d.ts","sourceRoot":"","sources":["../../../src/modes/interactive/interactive-resource-rendering.ts"],"names":[],"mappings":"","sourcesContent":["import { InteractiveModeBase } from \"./interactive-mode-base.ts\";\nimport { type Container, type ResourceDiagnostic, type SourceInfo, Spacer, Text, theme } from \"./interactive-mode-deps.ts\";\n\nInteractiveModeBase.prototype.showLoadedResources = function(this: InteractiveModeBase, options?: {\n extensions?: Array<{ path: string; sourceInfo?: SourceInfo }>;\n force?: boolean;\n showDiagnosticsWhenQuiet?: boolean;\n targetContainer?: Container;\n }): void {\n const targetContainer = options?.targetContainer ?? this.chatContainer;\n const showListing =\n options?.force ||\n this.options.verbose ||\n !this.settingsManager.getQuietStartup();\n const showDiagnostics =\n showListing || options?.showDiagnosticsWhenQuiet === true;\n if (!showListing && !showDiagnostics) {\n return;\n }\n\n const skillsResult = this.session.resourceLoader.getSkills();\n const promptsResult = this.session.resourceLoader.getPrompts();\n const themesResult = this.session.resourceLoader.getThemes();\n const extensions =\n options?.extensions ??\n this.session.resourceLoader\n .getExtensions()\n .extensions.map((extension) => ({\n path: extension.path,\n sourceInfo: extension.sourceInfo,\n }));\n const sourceInfos = new Map<string, SourceInfo>();\n for (const extension of extensions) {\n if (extension.sourceInfo) {\n sourceInfos.set(extension.path, extension.sourceInfo);\n }\n }\n for (const skill of skillsResult.skills) {\n if (skill.sourceInfo) {\n sourceInfos.set(skill.filePath, skill.sourceInfo);\n }\n }\n for (const prompt of promptsResult.prompts) {\n if (prompt.sourceInfo) {\n sourceInfos.set(prompt.filePath, prompt.sourceInfo);\n }\n }\n for (const loadedTheme of themesResult.themes) {\n if (loadedTheme.sourcePath && loadedTheme.sourceInfo) {\n sourceInfos.set(loadedTheme.sourcePath, loadedTheme.sourceInfo);\n }\n }\n\n if (showListing) {\n const contextFiles =\n this.session.resourceLoader.getAgentsFiles().agentsFiles;\n const templates = this.session.promptTemplates;\n const customThemes = themesResult.themes.filter((t) => t.sourcePath);\n\n const expandedSections: string[] = [];\n if (contextFiles.length > 0) {\n expandedSections.push(\n `${theme.bold(theme.fg(\"muted\", \"CONTEXT\"))}\\n${contextFiles\n .map((contextFile) => theme.fg(\"dim\", ` ${this.formatDisplayPath(contextFile.path)}`))\n .join(\"\\n\")}`,\n );\n }\n\n const skills = skillsResult.skills;\n if (skills.length > 0) {\n const groups = this.buildScopeGroups(\n skills.map((skill) => ({\n path: skill.filePath,\n sourceInfo: skill.sourceInfo,\n })),\n );\n expandedSections.push(\n `${theme.bold(theme.fg(\"muted\", \"SKILLS\"))}\\n${this.formatScopeGroups(groups, {\n formatPath: (item) => this.formatDisplayPath(item.path),\n formatPackagePath: (item) =>\n this.getShortPath(item.path, item.sourceInfo),\n })}`,\n );\n }\n\n if (templates.length > 0) {\n const groups = this.buildScopeGroups(\n templates.map((template) => ({\n path: template.filePath,\n sourceInfo: template.sourceInfo,\n })),\n );\n const templateByPath = new Map(templates.map((t) => [t.filePath, t]));\n expandedSections.push(\n `${theme.bold(theme.fg(\"muted\", \"PROMPTS\"))}\\n${this.formatScopeGroups(groups, {\n formatPath: (item) => {\n const template = templateByPath.get(item.path);\n return template\n ? `/${template.name}`\n : this.formatDisplayPath(item.path);\n },\n formatPackagePath: (item) => {\n const template = templateByPath.get(item.path);\n return template\n ? `/${template.name}`\n : this.formatDisplayPath(item.path);\n },\n })}`,\n );\n }\n\n const prompts = promptsResult.prompts;\n if (prompts.length > 0) {\n const groups = this.buildScopeGroups(\n prompts.map((prompt) => ({\n path: prompt.filePath,\n sourceInfo: prompt.sourceInfo,\n })),\n );\n const promptByPath = new Map(prompts.map((prompt) => [prompt.filePath, prompt]));\n expandedSections.push(\n `${theme.bold(theme.fg(\"muted\", \"PROMPTS\"))}\\n${this.formatScopeGroups(groups, {\n formatPath: (item) => promptByPath.get(item.path)?.name ?? this.formatDisplayPath(item.path),\n formatPackagePath: (item) => promptByPath.get(item.path)?.name ?? this.formatDisplayPath(item.path),\n })}`,\n );\n }\n\n if (extensions.length > 0) {\n const groups = this.buildScopeGroups(extensions);\n expandedSections.push(\n `${theme.bold(theme.fg(\"muted\", \"EXTENSIONS\"))}\\n${this.formatScopeGroups(groups, {\n formatPath: (item) => this.formatExtensionDisplayPath(item.path),\n formatPackagePath: (item) =>\n this.formatExtensionDisplayPath(\n this.getShortPath(item.path, item.sourceInfo),\n ),\n })}`,\n );\n }\n\n if (customThemes.length > 0) {\n const groups = this.buildScopeGroups(\n customThemes.map((loadedTheme) => ({\n path: loadedTheme.sourcePath!,\n sourceInfo: loadedTheme.sourceInfo,\n })),\n );\n expandedSections.push(\n `${theme.bold(theme.fg(\"muted\", \"THEMES\"))}\\n${this.formatScopeGroups(groups, {\n formatPath: (item) => this.formatDisplayPath(item.path),\n formatPackagePath: (item) =>\n this.getShortPath(item.path, item.sourceInfo),\n })}`,\n );\n }\n\n const extensionDiagnostics: ResourceDiagnostic[] = [];\n const extensionErrors =\n this.session.resourceLoader.getExtensions().errors;\n for (const error of extensionErrors) {\n extensionDiagnostics.push({\n type: \"error\",\n message: error.error,\n path: error.path,\n });\n }\n extensionDiagnostics.push(\n ...this.session.extensionRunner.getCommandDiagnostics(),\n ...this.getBuiltInCommandConflictDiagnostics(\n this.session.extensionRunner,\n ),\n ...this.session.extensionRunner.getShortcutDiagnostics(),\n );\n\n this.addResourceDisclosure({\n contextFiles,\n skills,\n prompts,\n templates,\n extensions,\n themes: customThemes,\n diagnosticsTotal: this.getResourceDiagnosticsTotal([\n skillsResult.diagnostics,\n promptsResult.diagnostics,\n extensionDiagnostics,\n themesResult.diagnostics,\n ]),\n expandedBody: this.options.verbose ? expandedSections.join(\"\\n\\n\") : \"\",\n targetContainer,\n });\n }\n\n if (showDiagnostics) {\n const skillDiagnostics = skillsResult.diagnostics;\n if (skillDiagnostics.length > 0) {\n const warningLines = this.formatDiagnostics(\n skillDiagnostics,\n sourceInfos,\n );\n targetContainer.addChild(\n new Text(\n `${theme.fg(\"warning\", \"[Skill conflicts]\")}\\n${warningLines}`,\n 0,\n 0,\n ),\n );\n targetContainer.addChild(new Spacer(1));\n }\n\n const promptDiagnostics = promptsResult.diagnostics;\n if (promptDiagnostics.length > 0) {\n const warningLines = this.formatDiagnostics(\n promptDiagnostics,\n sourceInfos,\n );\n targetContainer.addChild(\n new Text(\n `${theme.fg(\"warning\", \"[Prompt conflicts]\")}\\n${warningLines}`,\n 0,\n 0,\n ),\n );\n targetContainer.addChild(new Spacer(1));\n }\n\n const extensionDiagnostics: ResourceDiagnostic[] = [];\n const extensionErrors =\n this.session.resourceLoader.getExtensions().errors;\n if (extensionErrors.length > 0) {\n for (const error of extensionErrors) {\n extensionDiagnostics.push({\n type: \"error\",\n message: error.error,\n path: error.path,\n });\n }\n }\n\n const commandDiagnostics =\n this.session.extensionRunner.getCommandDiagnostics();\n extensionDiagnostics.push(...commandDiagnostics);\n extensionDiagnostics.push(\n ...this.getBuiltInCommandConflictDiagnostics(\n this.session.extensionRunner,\n ),\n );\n\n const shortcutDiagnostics =\n this.session.extensionRunner.getShortcutDiagnostics();\n extensionDiagnostics.push(...shortcutDiagnostics);\n\n if (extensionDiagnostics.length > 0) {\n const warningLines = this.formatDiagnostics(\n extensionDiagnostics,\n sourceInfos,\n );\n targetContainer.addChild(\n new Text(\n `${theme.fg(\"warning\", \"[Extension issues]\")}\\n${warningLines}`,\n 0,\n 0,\n ),\n );\n targetContainer.addChild(new Spacer(1));\n }\n\n const themeDiagnostics = themesResult.diagnostics;\n if (themeDiagnostics.length > 0) {\n const warningLines = this.formatDiagnostics(\n themeDiagnostics,\n sourceInfos,\n );\n targetContainer.addChild(\n new Text(\n `${theme.fg(\"warning\", \"[Theme conflicts]\")}\\n${warningLines}`,\n 0,\n 0,\n ),\n );\n targetContainer.addChild(new Spacer(1));\n }\n }\n };\n"]}
|