@ashx-j/lunr 0.2.7 → 0.2.9

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.
Files changed (164) hide show
  1. package/dist/builtin-extensions/ashxj-spinners.d.ts +7 -0
  2. package/dist/builtin-extensions/ashxj-spinners.d.ts.map +1 -1
  3. package/dist/builtin-extensions/ashxj-spinners.js +40 -3
  4. package/dist/builtin-extensions/ashxj-spinners.js.map +1 -1
  5. package/dist/builtin-extensions/ashxj-tui.d.ts +4 -0
  6. package/dist/builtin-extensions/ashxj-tui.d.ts.map +1 -1
  7. package/dist/builtin-extensions/ashxj-tui.js +44 -0
  8. package/dist/builtin-extensions/ashxj-tui.js.map +1 -1
  9. package/dist/builtin-extensions/lunr-behavior.d.ts +2 -1
  10. package/dist/builtin-extensions/lunr-behavior.d.ts.map +1 -1
  11. package/dist/builtin-extensions/lunr-behavior.js +26 -14
  12. package/dist/builtin-extensions/lunr-behavior.js.map +1 -1
  13. package/dist/builtin-extensions/lunr-todos.d.ts +4 -7
  14. package/dist/builtin-extensions/lunr-todos.d.ts.map +1 -1
  15. package/dist/builtin-extensions/lunr-todos.js +18 -10
  16. package/dist/builtin-extensions/lunr-todos.js.map +1 -1
  17. package/dist/builtin-extensions/pi-subagents/src/agents/agent-management.d.ts.map +1 -1
  18. package/dist/builtin-extensions/pi-subagents/src/agents/agent-management.js +3 -3
  19. package/dist/builtin-extensions/pi-subagents/src/agents/agent-management.js.map +1 -1
  20. package/dist/builtin-extensions/pi-subagents/src/extension/control-notices.d.ts.map +1 -1
  21. package/dist/builtin-extensions/pi-subagents/src/extension/control-notices.js +2 -2
  22. package/dist/builtin-extensions/pi-subagents/src/extension/control-notices.js.map +1 -1
  23. package/dist/builtin-extensions/pi-subagents/src/extension/index.d.ts.map +1 -1
  24. package/dist/builtin-extensions/pi-subagents/src/extension/index.js +1 -7
  25. package/dist/builtin-extensions/pi-subagents/src/extension/index.js.map +1 -1
  26. package/dist/builtin-extensions/pi-subagents/src/extension/schemas.d.ts.map +1 -1
  27. package/dist/builtin-extensions/pi-subagents/src/extension/schemas.js +2 -2
  28. package/dist/builtin-extensions/pi-subagents/src/extension/schemas.js.map +1 -1
  29. package/dist/builtin-extensions/pi-subagents/src/extension/tool-description.d.ts +2 -2
  30. package/dist/builtin-extensions/pi-subagents/src/extension/tool-description.d.ts.map +1 -1
  31. package/dist/builtin-extensions/pi-subagents/src/extension/tool-description.js +3 -4
  32. package/dist/builtin-extensions/pi-subagents/src/extension/tool-description.js.map +1 -1
  33. package/dist/builtin-extensions/pi-subagents/src/runs/foreground/execution.d.ts.map +1 -1
  34. package/dist/builtin-extensions/pi-subagents/src/runs/foreground/execution.js +21 -0
  35. package/dist/builtin-extensions/pi-subagents/src/runs/foreground/execution.js.map +1 -1
  36. package/dist/builtin-extensions/pi-subagents/src/runs/foreground/subagent-executor.d.ts.map +1 -1
  37. package/dist/builtin-extensions/pi-subagents/src/runs/foreground/subagent-executor.js +6 -18
  38. package/dist/builtin-extensions/pi-subagents/src/runs/foreground/subagent-executor.js.map +1 -1
  39. package/dist/builtin-extensions/pi-subagents/src/runs/shared/model-fallback.d.ts.map +1 -1
  40. package/dist/builtin-extensions/pi-subagents/src/runs/shared/model-fallback.js +13 -5
  41. package/dist/builtin-extensions/pi-subagents/src/runs/shared/model-fallback.js.map +1 -1
  42. package/dist/builtin-extensions/pi-subagents/src/shared/lunr-child-context.d.ts +21 -0
  43. package/dist/builtin-extensions/pi-subagents/src/shared/lunr-child-context.d.ts.map +1 -0
  44. package/dist/builtin-extensions/pi-subagents/src/shared/lunr-child-context.js +22 -0
  45. package/dist/builtin-extensions/pi-subagents/src/shared/lunr-child-context.js.map +1 -0
  46. package/dist/builtin-extensions/pi-subagents/src/shared/types.d.ts +1 -0
  47. package/dist/builtin-extensions/pi-subagents/src/shared/types.d.ts.map +1 -1
  48. package/dist/builtin-extensions/pi-subagents/src/shared/types.js.map +1 -1
  49. package/dist/builtin-extensions/pi-subagents/src/slash/prompt-workflows.d.ts.map +1 -1
  50. package/dist/builtin-extensions/pi-subagents/src/slash/prompt-workflows.js +2 -1
  51. package/dist/builtin-extensions/pi-subagents/src/slash/prompt-workflows.js.map +1 -1
  52. package/dist/builtin-extensions/pi-subagents/src/slash/slash-commands.d.ts.map +1 -1
  53. package/dist/builtin-extensions/pi-subagents/src/slash/slash-commands.js +10 -18
  54. package/dist/builtin-extensions/pi-subagents/src/slash/slash-commands.js.map +1 -1
  55. package/dist/builtin-extensions/pi-subagents/src/tui/render.d.ts +3 -0
  56. package/dist/builtin-extensions/pi-subagents/src/tui/render.d.ts.map +1 -1
  57. package/dist/builtin-extensions/pi-subagents/src/tui/render.js +9 -11
  58. package/dist/builtin-extensions/pi-subagents/src/tui/render.js.map +1 -1
  59. package/dist/builtin-extensions/pi-web-access/render-search-error.d.ts.map +1 -1
  60. package/dist/builtin-extensions/pi-web-access/render-search-error.js +1 -1
  61. package/dist/builtin-extensions/pi-web-access/render-search-error.js.map +1 -1
  62. package/dist/catalog/models.json +1 -1
  63. package/dist/catalog/providers/github-copilot.json +1 -1
  64. package/dist/catalog/providers/google-vertex.json +1 -1
  65. package/dist/catalog/providers/google.json +1 -1
  66. package/dist/catalog/providers/nvidia.json +1 -1
  67. package/dist/catalog/providers/opencode-go.json +1 -1
  68. package/dist/catalog/providers/opencode.json +1 -1
  69. package/dist/catalog/providers/openrouter.json +1 -1
  70. package/dist/catalog/providers/vercel-ai-gateway.json +1 -1
  71. package/dist/catalog/publication.json +3 -3
  72. package/dist/cli/update-cli.d.ts +16 -0
  73. package/dist/cli/update-cli.d.ts.map +1 -0
  74. package/dist/cli/update-cli.js +83 -0
  75. package/dist/cli/update-cli.js.map +1 -0
  76. package/dist/cli.d.ts.map +1 -1
  77. package/dist/cli.js +6 -0
  78. package/dist/cli.js.map +1 -1
  79. package/dist/core/behavior-preset.d.ts +60 -0
  80. package/dist/core/behavior-preset.d.ts.map +1 -0
  81. package/dist/core/behavior-preset.js +257 -0
  82. package/dist/core/behavior-preset.js.map +1 -0
  83. package/dist/core/customize.d.ts +3 -0
  84. package/dist/core/customize.d.ts.map +1 -1
  85. package/dist/core/customize.js +9 -0
  86. package/dist/core/customize.js.map +1 -1
  87. package/dist/core/footer-data-provider.d.ts +12 -1
  88. package/dist/core/footer-data-provider.d.ts.map +1 -1
  89. package/dist/core/footer-data-provider.js +70 -5
  90. package/dist/core/footer-data-provider.js.map +1 -1
  91. package/dist/core/keybindings.d.ts +2 -2
  92. package/dist/core/keybindings.d.ts.map +1 -1
  93. package/dist/core/keybindings.js +1 -1
  94. package/dist/core/keybindings.js.map +1 -1
  95. package/dist/core/model-tiers.d.ts +9 -0
  96. package/dist/core/model-tiers.d.ts.map +1 -1
  97. package/dist/core/model-tiers.js +16 -0
  98. package/dist/core/model-tiers.js.map +1 -1
  99. package/dist/core/rollback.d.ts +1 -1
  100. package/dist/core/rollback.d.ts.map +1 -1
  101. package/dist/core/rollback.js +1 -1
  102. package/dist/core/rollback.js.map +1 -1
  103. package/dist/core/settings-manager.d.ts +23 -0
  104. package/dist/core/settings-manager.d.ts.map +1 -1
  105. package/dist/core/settings-manager.js +66 -0
  106. package/dist/core/settings-manager.js.map +1 -1
  107. package/dist/core/slash-commands.d.ts.map +1 -1
  108. package/dist/core/slash-commands.js +2 -1
  109. package/dist/core/slash-commands.js.map +1 -1
  110. package/dist/core/tools/bash.d.ts.map +1 -1
  111. package/dist/core/tools/bash.js +1 -3
  112. package/dist/core/tools/bash.js.map +1 -1
  113. package/dist/core/update-check.d.ts +32 -0
  114. package/dist/core/update-check.d.ts.map +1 -0
  115. package/dist/core/update-check.js +112 -0
  116. package/dist/core/update-check.js.map +1 -0
  117. package/dist/core/usage-service.d.ts +24 -1
  118. package/dist/core/usage-service.d.ts.map +1 -1
  119. package/dist/core/usage-service.js +91 -14
  120. package/dist/core/usage-service.js.map +1 -1
  121. package/dist/gateway/agent-bridge.d.ts.map +1 -1
  122. package/dist/gateway/agent-bridge.js +5 -1
  123. package/dist/gateway/agent-bridge.js.map +1 -1
  124. package/dist/gateway/cron.d.ts.map +1 -1
  125. package/dist/gateway/cron.js +5 -1
  126. package/dist/gateway/cron.js.map +1 -1
  127. package/dist/main.d.ts.map +1 -1
  128. package/dist/main.js +13 -1
  129. package/dist/main.js.map +1 -1
  130. package/dist/modes/interactive/components/assistant-message.d.ts +10 -1
  131. package/dist/modes/interactive/components/assistant-message.d.ts.map +1 -1
  132. package/dist/modes/interactive/components/assistant-message.js +154 -68
  133. package/dist/modes/interactive/components/assistant-message.js.map +1 -1
  134. package/dist/modes/interactive/components/settings-selector.d.ts +13 -0
  135. package/dist/modes/interactive/components/settings-selector.d.ts.map +1 -1
  136. package/dist/modes/interactive/components/settings-selector.js +157 -10
  137. package/dist/modes/interactive/components/settings-selector.js.map +1 -1
  138. package/dist/modes/interactive/components/thinking-summary.d.ts +4 -4
  139. package/dist/modes/interactive/components/thinking-summary.d.ts.map +1 -1
  140. package/dist/modes/interactive/components/thinking-summary.js +7 -5
  141. package/dist/modes/interactive/components/thinking-summary.js.map +1 -1
  142. package/dist/modes/interactive/components/thinking-tail.d.ts.map +1 -1
  143. package/dist/modes/interactive/components/thinking-tail.js +5 -3
  144. package/dist/modes/interactive/components/thinking-tail.js.map +1 -1
  145. package/dist/modes/interactive/components/tool-execution.d.ts +1 -0
  146. package/dist/modes/interactive/components/tool-execution.d.ts.map +1 -1
  147. package/dist/modes/interactive/components/tool-execution.js +9 -0
  148. package/dist/modes/interactive/components/tool-execution.js.map +1 -1
  149. package/dist/modes/interactive/interactive-mode.d.ts +6 -1
  150. package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
  151. package/dist/modes/interactive/interactive-mode.js +124 -43
  152. package/dist/modes/interactive/interactive-mode.js.map +1 -1
  153. package/docs/keybindings.md +1 -1
  154. package/docs/providers.md +2 -0
  155. package/examples/extensions/custom-provider-anthropic/package-lock.json +2 -2
  156. package/examples/extensions/custom-provider-anthropic/package.json +1 -1
  157. package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
  158. package/examples/extensions/gondolin/package-lock.json +2 -2
  159. package/examples/extensions/gondolin/package.json +1 -1
  160. package/examples/extensions/sandbox/package-lock.json +2 -2
  161. package/examples/extensions/sandbox/package.json +1 -1
  162. package/examples/extensions/with-deps/package-lock.json +2 -2
  163. package/examples/extensions/with-deps/package.json +1 -1
  164. package/package.json +4 -4
@@ -15,9 +15,9 @@ export class AssistantMessageComponent extends Container {
15
15
  // lunr: collapsible reasoning — when true, a completed thinking run renders as
16
16
  // "✻ Thought for Xs" + its first sentence instead of the full block.
17
17
  thinkingCollapse;
18
- // lunr: ctrl+o expansion when true, collapsed thinking runs render in full
19
- // (wired into the global app.tools.expand toggle via the Expandable interface).
18
+ // lunr: per-run expand. `expanded` still means "all runs" for setExpanded().
20
19
  expanded = false;
20
+ expandedRuns = new Set();
21
21
  // lunr: live per-run timings from interactive-mode; undefined = history message
22
22
  // (always treated as final, rendered without durations).
23
23
  thinkingTimings;
@@ -27,6 +27,7 @@ export class AssistantMessageComponent extends Container {
27
27
  hiddenThinkingLabel;
28
28
  outputPad;
29
29
  lastMessage;
30
+ thinkingSource;
30
31
  hasToolCalls = false;
31
32
  // lunr: gutter rail — prefix rendered lines with a dim │; the last line uses ╰
32
33
  // when this component closes the turn (no tool calls follow).
@@ -49,30 +50,69 @@ export class AssistantMessageComponent extends Container {
49
50
  invalidate() {
50
51
  super.invalidate();
51
52
  if (this.lastMessage) {
52
- this.updateContent(this.lastMessage);
53
+ this.updateContent(this.lastMessage, this.thinkingSourceOptions());
53
54
  }
54
55
  }
55
56
  setHideThinkingBlock(hide) {
56
57
  this.hideThinkingBlock = hide;
57
58
  if (this.lastMessage) {
58
- this.updateContent(this.lastMessage);
59
+ this.updateContent(this.lastMessage, this.thinkingSourceOptions());
59
60
  }
60
61
  }
61
62
  // lunr: collapsible reasoning toggles (live; re-render like setHideThinkingBlock).
62
63
  setThinkingCollapse(collapse) {
63
64
  this.thinkingCollapse = collapse;
64
65
  if (this.lastMessage) {
65
- this.updateContent(this.lastMessage);
66
+ this.updateContent(this.lastMessage, this.thinkingSourceOptions());
66
67
  }
67
68
  }
68
- // lunr: ctrl+o expansion Expandable interface hook; expanded collapsed thinking
69
- // runs render as full Markdown blocks again.
69
+ // lunr: Expandable hook; true expands every thinking run, false collapses all.
70
70
  setExpanded(expanded) {
71
71
  this.expanded = expanded;
72
+ if (!expanded)
73
+ this.expandedRuns.clear();
72
74
  if (this.lastMessage) {
73
- this.updateContent(this.lastMessage);
75
+ this.updateContent(this.lastMessage, this.thinkingSourceOptions());
74
76
  }
75
77
  }
78
+ isRunExpanded(runIndex) {
79
+ return this.expanded || this.expandedRuns.has(runIndex);
80
+ }
81
+ toggleThinkingRun(runIndex) {
82
+ if (this.expanded) {
83
+ this.expanded = false;
84
+ this.expandedRuns.clear();
85
+ const count = this.lastMessage ? collectThinkingRuns(this.lastMessage.content).length : 0;
86
+ for (let i = 0; i < count; i++) {
87
+ if (i !== runIndex)
88
+ this.expandedRuns.add(i);
89
+ }
90
+ }
91
+ else if (this.expandedRuns.has(runIndex)) {
92
+ this.expandedRuns.delete(runIndex);
93
+ }
94
+ else {
95
+ this.expandedRuns.add(runIndex);
96
+ }
97
+ if (this.lastMessage) {
98
+ this.updateContent(this.lastMessage, this.thinkingSourceOptions());
99
+ }
100
+ }
101
+ handleClick(localY, width) {
102
+ const contentWidth = this.gutterRail ? Math.max(1, width - 2) : width;
103
+ let y = 0;
104
+ for (const child of this.contentContainer.children) {
105
+ const h = child.render(contentWidth).length;
106
+ if (localY >= y && localY < y + h) {
107
+ if (typeof child.handleClick === "function") {
108
+ return child.handleClick(localY - y, contentWidth);
109
+ }
110
+ return false;
111
+ }
112
+ y += h;
113
+ }
114
+ return false;
115
+ }
76
116
  setThinkingTimings(timings) {
77
117
  this.thinkingTimings = timings;
78
118
  }
@@ -83,13 +123,13 @@ export class AssistantMessageComponent extends Container {
83
123
  setHiddenThinkingLabel(label) {
84
124
  this.hiddenThinkingLabel = label;
85
125
  if (this.lastMessage) {
86
- this.updateContent(this.lastMessage);
126
+ this.updateContent(this.lastMessage, this.thinkingSourceOptions());
87
127
  }
88
128
  }
89
129
  setOutputPad(padding) {
90
130
  this.outputPad = padding;
91
131
  if (this.lastMessage) {
92
- this.updateContent(this.lastMessage);
132
+ this.updateContent(this.lastMessage, this.thinkingSourceOptions());
93
133
  }
94
134
  }
95
135
  render(width) {
@@ -120,17 +160,25 @@ export class AssistantMessageComponent extends Container {
120
160
  }
121
161
  return lines;
122
162
  }
123
- updateContent(message) {
163
+ thinkingSourceOptions() {
164
+ return this.thinkingSource ? { thinkingSource: this.thinkingSource } : undefined;
165
+ }
166
+ updateContent(message, options) {
124
167
  this.lastMessage = message;
168
+ this.thinkingSource = options?.thinkingSource;
125
169
  // Clear content container
126
170
  this.contentContainer.clear();
127
- const hasVisibleContent = message.content.some((c) => (c.type === "text" && c.text.trim()) || (c.type === "thinking" && c.thinking.trim()));
171
+ const sourceMessage = this.thinkingSource ?? message;
172
+ const sourceThinkingRuns = collectThinkingRuns(sourceMessage.content);
173
+ const hasVisibleContent = message.content.some((c) => (c.type === "text" && c.text.trim()) || (c.type === "thinking" && c.thinking.trim())) ||
174
+ (!this.hideThinkingBlock && sourceThinkingRuns.some((run) => run.length > 0));
128
175
  if (hasVisibleContent) {
129
176
  this.contentContainer.addChild(new Spacer(1));
130
177
  }
131
178
  // Render content in order
132
179
  let isFirstTextBlock = true;
133
180
  let thinkingRunIndex = -1;
181
+ let renderedThinking = false;
134
182
  for (let i = 0; i < message.content.length; i++) {
135
183
  const content = message.content[i];
136
184
  if (content.type === "text" && content.text.trim()) {
@@ -149,7 +197,7 @@ export class AssistantMessageComponent extends Container {
149
197
  }
150
198
  else if (content.type === "thinking") {
151
199
  thinkingRunIndex++;
152
- const thinkingBlocks = [];
200
+ const displayBlocks = [];
153
201
  for (; i < message.content.length; i++) {
154
202
  const thinkingContent = message.content[i];
155
203
  if (thinkingContent.type !== "thinking") {
@@ -157,66 +205,23 @@ export class AssistantMessageComponent extends Container {
157
205
  }
158
206
  const thinking = thinkingContent.thinking.trim();
159
207
  if (thinking) {
160
- thinkingBlocks.push(thinking);
208
+ displayBlocks.push(thinking);
161
209
  }
162
210
  }
163
211
  i--;
164
- if (thinkingBlocks.length === 0) {
212
+ const thinkingBlocks = sourceThinkingRuns[thinkingRunIndex] ?? displayBlocks;
213
+ if (thinkingBlocks.length === 0 || this.hideThinkingBlock) {
165
214
  continue;
166
215
  }
167
- // Add spacing only when another visible assistant content block follows.
168
- // This avoids a superfluous blank line before separately-rendered tool execution blocks.
169
- const hasVisibleContentAfter = message.content
170
- .slice(i + 1)
171
- .some((c) => (c.type === "text" && c.text.trim()) || (c.type === "thinking" && c.thinking.trim()));
172
- if (this.hideThinkingBlock) {
173
- // lunr: thinking blocks are hidden — render nothing (the "Thinking..." label is
174
- // removed; an alternative hidden indicator will be designed separately).
175
- }
176
- else {
177
- // lunr: a run is complete when a block follows it, its timing closed, or no
178
- // timings are attached (history). Incomplete = still streaming.
179
- const runComplete = isThinkingRunComplete(i < message.content.length - 1, this.thinkingTimings?.[thinkingRunIndex], this.thinkingTimings !== undefined);
180
- if (this.thinkingCollapse && !this.expanded && runComplete) {
181
- // lunr: collapsible reasoning — a completed run collapses to
182
- // "✻ Thought for Xs" (duration only from live timings) + its first sentence.
183
- const timing = this.thinkingTimings?.[thinkingRunIndex];
184
- const label = timing?.end !== undefined
185
- ? `✻ Thought for ${formatThoughtDuration(timing.end - timing.start)}`
186
- : "✻ Thought";
187
- this.contentContainer.addChild(new Text(theme.fg("thinkingText", theme.italic(label)), this.outputPad, 0));
188
- const snippet = thinkingSnippet(thinkingBlocks.join("\n\n"));
189
- if (snippet) {
190
- this.contentContainer.addChild(new Text(theme.fg("thinkingText", theme.italic(snippet)), this.outputPad + 2, 0));
191
- }
192
- if (hasVisibleContentAfter) {
193
- this.contentContainer.addChild(new Spacer(1));
194
- }
195
- }
196
- else if (!runComplete && !this.expanded) {
197
- // lunr: rolling window — a still-streaming run shows only its last
198
- // THINKING_TAIL_LINES rendered lines; older lines disappear as new
199
- // ones stream in. ctrl+o expand (or completion) renders in full.
200
- this.contentContainer.addChild(new ThinkingTailComponent(thinkingBlocks.join("\n\n"), this.outputPad, 0, this.markdownTheme, {
201
- color: (text) => theme.fg("thinkingText", text),
202
- italic: true,
203
- }));
204
- if (hasVisibleContentAfter) {
205
- this.contentContainer.addChild(new Spacer(1));
206
- }
207
- }
208
- else {
209
- // Render each run of thinking blocks as one Markdown section.
210
- this.contentContainer.addChild(new Markdown(thinkingBlocks.join("\n\n"), this.outputPad, 0, this.markdownTheme, {
211
- color: (text) => theme.fg("thinkingText", text),
212
- italic: true,
213
- }));
214
- // lunr: only add the spacer when thinking is visible (avoids stray blank line when hidden).
215
- if (hasVisibleContentAfter) {
216
- this.contentContainer.addChild(new Spacer(1));
217
- }
218
- }
219
- }
216
+ renderedThinking = true;
217
+ this.renderThinkingRun(thinkingRunIndex, thinkingBlocks, message, i);
218
+ }
219
+ }
220
+ if (!this.hideThinkingBlock && !renderedThinking && sourceThinkingRuns.length > 0) {
221
+ thinkingRunIndex = 0;
222
+ const thinkingBlocks = sourceThinkingRuns[0] ?? [];
223
+ if (thinkingBlocks.length > 0) {
224
+ this.renderThinkingRun(thinkingRunIndex, thinkingBlocks, message, -1);
220
225
  }
221
226
  }
222
227
  // Check if incomplete/failed - show after partial content.
@@ -243,5 +248,86 @@ export class AssistantMessageComponent extends Container {
243
248
  }
244
249
  }
245
250
  }
251
+ renderThinkingRun(thinkingRunIndex, thinkingBlocks, displayMessage, displayIndex) {
252
+ const hasVisibleContentAfter = displayIndex >= 0
253
+ ? displayMessage.content
254
+ .slice(displayIndex + 1)
255
+ .some((c) => (c.type === "text" && c.text.trim()) || (c.type === "thinking" && c.thinking.trim()))
256
+ : displayMessage.content.some((c) => c.type === "text" && c.text.trim());
257
+ const runComplete = isThinkingRunComplete(false, this.thinkingTimings?.[thinkingRunIndex], this.thinkingTimings !== undefined);
258
+ const wrap = (inner) => {
259
+ this.contentContainer.addChild(new ThinkingRunBlock(this, thinkingRunIndex, inner));
260
+ };
261
+ if (this.thinkingCollapse && !this.isRunExpanded(thinkingRunIndex) && runComplete) {
262
+ const timing = this.thinkingTimings?.[thinkingRunIndex];
263
+ const label = timing?.end !== undefined
264
+ ? `✻ Thought for ${formatThoughtDuration(timing.end - timing.start)}`
265
+ : "✻ Thought";
266
+ const block = new Container();
267
+ block.addChild(new Text(theme.fg("thinkingText", theme.italic(label)), this.outputPad, 0));
268
+ const snippet = thinkingSnippet(thinkingBlocks.join("\n\n"));
269
+ if (snippet) {
270
+ block.addChild(new Text(theme.fg("thinkingText", theme.italic(snippet)), this.outputPad + 2, 0));
271
+ }
272
+ wrap(block);
273
+ if (hasVisibleContentAfter) {
274
+ this.contentContainer.addChild(new Spacer(1));
275
+ }
276
+ return;
277
+ }
278
+ if (!runComplete && !this.isRunExpanded(thinkingRunIndex)) {
279
+ wrap(new ThinkingTailComponent(thinkingBlocks.join("\n\n"), this.outputPad, 0, this.markdownTheme, {
280
+ color: (text) => theme.fg("thinkingText", text),
281
+ italic: true,
282
+ }));
283
+ if (hasVisibleContentAfter) {
284
+ this.contentContainer.addChild(new Spacer(1));
285
+ }
286
+ return;
287
+ }
288
+ wrap(new Markdown(thinkingBlocks.join("\n\n"), this.outputPad, 0, this.markdownTheme, {
289
+ color: (text) => theme.fg("thinkingText", text),
290
+ italic: true,
291
+ }));
292
+ if (hasVisibleContentAfter) {
293
+ this.contentContainer.addChild(new Spacer(1));
294
+ }
295
+ }
296
+ }
297
+ class ThinkingRunBlock extends Container {
298
+ owner;
299
+ runIndex;
300
+ constructor(owner, runIndex, inner) {
301
+ super();
302
+ this.owner = owner;
303
+ this.runIndex = runIndex;
304
+ this.addChild(inner);
305
+ }
306
+ handleClick(_localY, _width) {
307
+ this.owner.toggleThinkingRun(this.runIndex);
308
+ return true;
309
+ }
310
+ }
311
+ function collectThinkingRuns(content) {
312
+ const runs = [];
313
+ for (let i = 0; i < content.length; i++) {
314
+ const block = content[i];
315
+ if (block.type !== "thinking")
316
+ continue;
317
+ const blocks = [];
318
+ for (; i < content.length; i++) {
319
+ const thinkingContent = content[i];
320
+ if (thinkingContent.type !== "thinking") {
321
+ i--;
322
+ break;
323
+ }
324
+ const thinking = thinkingContent.thinking.trim();
325
+ if (thinking)
326
+ blocks.push(thinking);
327
+ }
328
+ if (blocks.length > 0)
329
+ runs.push(blocks);
330
+ }
331
+ return runs;
246
332
  }
247
333
  //# sourceMappingURL=assistant-message.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"assistant-message.js","sourceRoot":"","sources":["../../../../src/modes/interactive/components/assistant-message.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAsB,MAAM,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAC;AAC/F,OAAO,EAAE,gBAAgB,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,EACN,qBAAqB,EACrB,qBAAqB,EAErB,eAAe,GACf,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAE3D,MAAM,iBAAiB,GAAG,gBAAgB,CAAC;AAC3C,MAAM,eAAe,GAAG,gBAAgB,CAAC;AACzC,MAAM,iBAAiB,GAAG,gBAAgB,CAAC;AAE3C;;GAEG;AACH,MAAM,OAAO,yBAA0B,SAAQ,SAAS;IACvD,UAAU,GAAG,IAAI,CAAC;IACV,gBAAgB,CAAY;IAC5B,iBAAiB,CAAU;IACnC,iFAA+E;IAC/E,uEAAqE;IAC7D,gBAAgB,CAAU;IAClC,+EAA6E;IAC7E,gFAAgF;IACxE,QAAQ,GAAG,KAAK,CAAC;IACzB,gFAAgF;IAChF,yDAAyD;IACjD,eAAe,CAAuB;IACtC,aAAa,CAAgB;IACrC,wGAAwG;IACxG,qFAAqF;IAC7E,mBAAmB,CAAS;IAC5B,SAAS,CAAS;IA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,CAAC,CAAC;YAC9F,CAAC;iBAAM,IAAI,OAAO,CAAC,UAAU,KAAK,OAAO,EAAE,CAAC;gBAC3C,MAAM,QAAQ,GAAG,OAAO,CAAC,YAAY,IAAI,eAAe,CAAC;gBACzD,IAAI,CAAC,gBAAgB,CAAC,QAAQ,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;gBAC9C,IAAI,CAAC,gBAAgB,CAAC,QAAQ,CAAC,IAAI,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,OAAO,EAAE,UAAU,QAAQ,EAAE,CAAC,EAAE,IAAI,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC,CAAC;YACtG,CAAC;QACF,CAAC;IAAA,CACD;CACD","sourcesContent":["import type { AssistantMessage } from \"@ashx-j/lunr-ai\";\nimport { Container, Markdown, type MarkdownTheme, Spacer, Text } from \"@ashx-j/lunr-tui\";\nimport { getMarkdownTheme, theme } from \"../theme/theme.ts\";\nimport {\n\tformatThoughtDuration,\n\tisThinkingRunComplete,\n\ttype ThinkingRunTiming,\n\tthinkingSnippet,\n} from \"./thinking-summary.ts\";\nimport { ThinkingTailComponent } from \"./thinking-tail.ts\";\n\nconst OSC133_ZONE_START = \"\\x1b]133;A\\x07\";\nconst OSC133_ZONE_END = \"\\x1b]133;B\\x07\";\nconst OSC133_ZONE_FINAL = \"\\x1b]133;C\\x07\";\n\n/**\n * Component that renders a complete assistant message\n */\nexport class AssistantMessageComponent extends Container {\n\tselectable = true;\n\tprivate contentContainer: Container;\n\tprivate hideThinkingBlock: boolean;\n\t// lunr: collapsible reasoning — when true, a completed thinking run renders as\n\t// \"✻ Thought for Xs\" + its first sentence instead of the full block.\n\tprivate thinkingCollapse: boolean;\n\t// lunr: ctrl+o expansion — when true, collapsed thinking runs render in full\n\t// (wired into the global app.tools.expand toggle via the Expandable interface).\n\tprivate expanded = false;\n\t// lunr: live per-run timings from interactive-mode; undefined = history message\n\t// (always treated as final, rendered without durations).\n\tprivate thinkingTimings?: ThinkingRunTiming[];\n\tprivate markdownTheme: MarkdownTheme;\n\t// lunr: kept for the deferred alternative hidden-thinking indicator (Phase 8 removed the label render).\n\t// biome-ignore lint/correctness/noUnusedPrivateClassMembers: retained for future use\n\tprivate hiddenThinkingLabel: string;\n\tprivate outputPad: number;\n\tprivate lastMessage?: AssistantMessage;\n\tprivate hasToolCalls = false;\n\t// lunr: gutter rail — prefix rendered lines with a dim │; the last line uses ╰\n\t// when this component closes the turn (no tool calls follow).\n\tprivate gutterRail: boolean;\n\n\tconstructor(\n\t\tmessage?: AssistantMessage,\n\t\thideThinkingBlock = false,\n\t\tmarkdownTheme: MarkdownTheme = getMarkdownTheme(),\n\t\thiddenThinkingLabel = \"Thinking...\",\n\t\toutputPad = 1,\n\t\tgutterRail = false,\n\t\tthinkingCollapse = false,\n\t) {\n\t\tsuper();\n\n\t\tthis.hideThinkingBlock = hideThinkingBlock;\n\t\tthis.thinkingCollapse = thinkingCollapse;\n\t\tthis.markdownTheme = markdownTheme;\n\t\tthis.hiddenThinkingLabel = hiddenThinkingLabel;\n\t\tthis.outputPad = outputPad;\n\t\tthis.gutterRail = gutterRail;\n\n\t\t// Container for text/thinking content\n\t\tthis.contentContainer = new Container();\n\t\tthis.addChild(this.contentContainer);\n\n\t\tif (message) {\n\t\t\tthis.updateContent(message);\n\t\t}\n\t}\n\n\toverride invalidate(): void {\n\t\tsuper.invalidate();\n\t\tif (this.lastMessage) {\n\t\t\tthis.updateContent(this.lastMessage);\n\t\t}\n\t}\n\n\tsetHideThinkingBlock(hide: boolean): void {\n\t\tthis.hideThinkingBlock = hide;\n\t\tif (this.lastMessage) {\n\t\t\tthis.updateContent(this.lastMessage);\n\t\t}\n\t}\n\n\t// lunr: collapsible reasoning toggles (live; re-render like setHideThinkingBlock).\n\tsetThinkingCollapse(collapse: boolean): void {\n\t\tthis.thinkingCollapse = collapse;\n\t\tif (this.lastMessage) {\n\t\t\tthis.updateContent(this.lastMessage);\n\t\t}\n\t}\n\n\t// lunr: ctrl+o expansion — Expandable interface hook; expanded collapsed thinking\n\t// runs render as full Markdown blocks again.\n\tsetExpanded(expanded: boolean): void {\n\t\tthis.expanded = expanded;\n\t\tif (this.lastMessage) {\n\t\t\tthis.updateContent(this.lastMessage);\n\t\t}\n\t}\n\n\tsetThinkingTimings(timings: ThinkingRunTiming[] | undefined): void {\n\t\tthis.thinkingTimings = timings;\n\t}\n\n\t// lunr: gutter rail toggle (live; applied on next render).\n\tsetGutterRail(enabled: boolean): void {\n\t\tthis.gutterRail = enabled;\n\t}\n\n\tsetHiddenThinkingLabel(label: string): void {\n\t\tthis.hiddenThinkingLabel = label;\n\t\tif (this.lastMessage) {\n\t\t\tthis.updateContent(this.lastMessage);\n\t\t}\n\t}\n\n\tsetOutputPad(padding: number): void {\n\t\tthis.outputPad = padding;\n\t\tif (this.lastMessage) {\n\t\t\tthis.updateContent(this.lastMessage);\n\t\t}\n\t}\n\n\toverride render(width: number): string[] {\n\t\t// lunr: gutter rail — render content at width-2 and prefix each line with a\n\t\t// dim │; the last line uses ╰ when this assistant message closes the turn\n\t\t// (no tool calls follow). When tool calls are present the rail stays open (│)\n\t\t// because tool-execution components render their own borders below.\n\t\tconst railEnabled = this.gutterRail;\n\t\tconst contentWidth = railEnabled ? Math.max(1, width - 2) : width;\n\t\tconst lines = super.render(contentWidth);\n\t\tif (this.hasToolCalls || lines.length === 0) {\n\t\t\tif (railEnabled && lines.length > 0) {\n\t\t\t\tconst rail = theme.fg(\"dim\", \"│ \");\n\t\t\t\tfor (let i = 0; i < lines.length; i++) {\n\t\t\t\t\tlines[i] = rail + lines[i];\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn lines;\n\t\t}\n\n\t\tlines[0] = OSC133_ZONE_START + lines[0];\n\t\tlines[lines.length - 1] = OSC133_ZONE_END + OSC133_ZONE_FINAL + lines[lines.length - 1];\n\n\t\tif (railEnabled) {\n\t\t\tconst rail = theme.fg(\"dim\", \"│ \");\n\t\t\tconst close = theme.fg(\"dim\", \"╰ \");\n\t\t\tfor (let i = 0; i < lines.length; i++) {\n\t\t\t\tlines[i] = (i === lines.length - 1 ? close : rail) + lines[i];\n\t\t\t}\n\t\t}\n\t\treturn lines;\n\t}\n\n\tupdateContent(message: AssistantMessage): void {\n\t\tthis.lastMessage = message;\n\n\t\t// Clear content container\n\t\tthis.contentContainer.clear();\n\n\t\tconst hasVisibleContent = message.content.some(\n\t\t\t(c) => (c.type === \"text\" && c.text.trim()) || (c.type === \"thinking\" && c.thinking.trim()),\n\t\t);\n\n\t\tif (hasVisibleContent) {\n\t\t\tthis.contentContainer.addChild(new Spacer(1));\n\t\t}\n\n\t\t// Render content in order\n\t\tlet isFirstTextBlock = true;\n\t\tlet thinkingRunIndex = -1;\n\t\tfor (let i = 0; i < message.content.length; i++) {\n\t\t\tconst content = message.content[i];\n\t\t\tif (content.type === \"text\" && content.text.trim()) {\n\t\t\t\t// Assistant text messages with no background - trim the text\n\t\t\t\t// Set paddingY=0 to avoid extra spacing before tool executions\n\t\t\t\t// lunr: leading ● marks the first text block (never thinking blocks). It rides\n\t\t\t\t// the defaultTextStyle below, so it renders bright white like the body.\n\t\t\t\tconst trimmed = content.text.trim();\n\t\t\t\tconst text = isFirstTextBlock ? `● ${trimmed}` : trimmed;\n\t\t\t\tisFirstTextBlock = false;\n\t\t\t\t// lunr: theme-polish — assistant message body renders bright white via the\n\t\t\t\t// shared userMessageText token (same knob as user messages).\n\t\t\t\tthis.contentContainer.addChild(\n\t\t\t\t\tnew Markdown(text, this.outputPad, 0, this.markdownTheme, {\n\t\t\t\t\t\tcolor: (body: string) => theme.fg(\"userMessageText\", body),\n\t\t\t\t\t}),\n\t\t\t\t);\n\t\t\t} else if (content.type === \"thinking\") {\n\t\t\t\tthinkingRunIndex++;\n\t\t\t\tconst thinkingBlocks: string[] = [];\n\t\t\t\tfor (; i < message.content.length; i++) {\n\t\t\t\t\tconst thinkingContent = message.content[i];\n\t\t\t\t\tif (thinkingContent.type !== \"thinking\") {\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\tconst thinking = thinkingContent.thinking.trim();\n\t\t\t\t\tif (thinking) {\n\t\t\t\t\t\tthinkingBlocks.push(thinking);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\ti--;\n\n\t\t\t\tif (thinkingBlocks.length === 0) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\t// Add spacing only when another visible assistant content block follows.\n\t\t\t\t// This avoids a superfluous blank line before separately-rendered tool execution blocks.\n\t\t\t\tconst hasVisibleContentAfter = message.content\n\t\t\t\t\t.slice(i + 1)\n\t\t\t\t\t.some((c) => (c.type === \"text\" && c.text.trim()) || (c.type === \"thinking\" && c.thinking.trim()));\n\n\t\t\t\tif (this.hideThinkingBlock) {\n\t\t\t\t\t// lunr: thinking blocks are hidden — render nothing (the \"Thinking...\" label is\n\t\t\t\t\t// removed; an alternative hidden indicator will be designed separately).\n\t\t\t\t} else {\n\t\t\t\t\t// lunr: a run is complete when a block follows it, its timing closed, or no\n\t\t\t\t\t// timings are attached (history). Incomplete = still streaming.\n\t\t\t\t\tconst runComplete = isThinkingRunComplete(\n\t\t\t\t\t\ti < message.content.length - 1,\n\t\t\t\t\t\tthis.thinkingTimings?.[thinkingRunIndex],\n\t\t\t\t\t\tthis.thinkingTimings !== undefined,\n\t\t\t\t\t);\n\t\t\t\t\tif (this.thinkingCollapse && !this.expanded && runComplete) {\n\t\t\t\t\t\t// lunr: collapsible reasoning — a completed run collapses to\n\t\t\t\t\t\t// \"✻ Thought for Xs\" (duration only from live timings) + its first sentence.\n\t\t\t\t\t\tconst timing = this.thinkingTimings?.[thinkingRunIndex];\n\t\t\t\t\t\tconst label =\n\t\t\t\t\t\t\ttiming?.end !== undefined\n\t\t\t\t\t\t\t\t? `✻ Thought for ${formatThoughtDuration(timing.end - timing.start)}`\n\t\t\t\t\t\t\t\t: \"✻ Thought\";\n\t\t\t\t\t\tthis.contentContainer.addChild(\n\t\t\t\t\t\t\tnew Text(theme.fg(\"thinkingText\", theme.italic(label)), this.outputPad, 0),\n\t\t\t\t\t\t);\n\t\t\t\t\t\tconst snippet = thinkingSnippet(thinkingBlocks.join(\"\\n\\n\"));\n\t\t\t\t\t\tif (snippet) {\n\t\t\t\t\t\t\tthis.contentContainer.addChild(\n\t\t\t\t\t\t\t\tnew Text(theme.fg(\"thinkingText\", theme.italic(snippet)), this.outputPad + 2, 0),\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (hasVisibleContentAfter) {\n\t\t\t\t\t\t\tthis.contentContainer.addChild(new Spacer(1));\n\t\t\t\t\t\t}\n\t\t\t\t\t} else if (!runComplete && !this.expanded) {\n\t\t\t\t\t\t// lunr: rolling window — a still-streaming run shows only its last\n\t\t\t\t\t\t// THINKING_TAIL_LINES rendered lines; older lines disappear as new\n\t\t\t\t\t\t// ones stream in. ctrl+o expand (or completion) renders in full.\n\t\t\t\t\t\tthis.contentContainer.addChild(\n\t\t\t\t\t\t\tnew ThinkingTailComponent(thinkingBlocks.join(\"\\n\\n\"), this.outputPad, 0, this.markdownTheme, {\n\t\t\t\t\t\t\t\tcolor: (text: string) => theme.fg(\"thinkingText\", text),\n\t\t\t\t\t\t\t\titalic: true,\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t);\n\t\t\t\t\t\tif (hasVisibleContentAfter) {\n\t\t\t\t\t\t\tthis.contentContainer.addChild(new Spacer(1));\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\t// Render each run of thinking blocks as one Markdown section.\n\t\t\t\t\t\tthis.contentContainer.addChild(\n\t\t\t\t\t\t\tnew Markdown(thinkingBlocks.join(\"\\n\\n\"), this.outputPad, 0, this.markdownTheme, {\n\t\t\t\t\t\t\t\tcolor: (text: string) => theme.fg(\"thinkingText\", text),\n\t\t\t\t\t\t\t\titalic: true,\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t);\n\t\t\t\t\t\t// lunr: only add the spacer when thinking is visible (avoids stray blank line when hidden).\n\t\t\t\t\t\tif (hasVisibleContentAfter) {\n\t\t\t\t\t\t\tthis.contentContainer.addChild(new Spacer(1));\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// Check if incomplete/failed - show after partial content.\n\t\t// For aborted/error tool calls, tool execution components show the error.\n\t\t// Length stops can happen before a tool call is complete, so surface them here too.\n\t\tconst hasToolCalls = message.content.some((c) => c.type === \"toolCall\");\n\t\tthis.hasToolCalls = hasToolCalls;\n\t\tif (message.stopReason === \"length\") {\n\t\t\tthis.contentContainer.addChild(new Spacer(1));\n\t\t\tthis.contentContainer.addChild(\n\t\t\t\tnew Text(\n\t\t\t\t\ttheme.fg(\n\t\t\t\t\t\t\"error\",\n\t\t\t\t\t\t\"Error: Model stopped because it reached the maximum output token limit. The response may be incomplete.\",\n\t\t\t\t\t),\n\t\t\t\t\tthis.outputPad,\n\t\t\t\t\t0,\n\t\t\t\t),\n\t\t\t);\n\t\t} else if (!hasToolCalls) {\n\t\t\tif (message.stopReason === \"aborted\") {\n\t\t\t\tconst abortMessage =\n\t\t\t\t\tmessage.errorMessage && message.errorMessage !== \"Request was aborted\"\n\t\t\t\t\t\t? message.errorMessage\n\t\t\t\t\t\t: \"Operation aborted\";\n\t\t\t\tthis.contentContainer.addChild(new Spacer(1));\n\t\t\t\tthis.contentContainer.addChild(new Text(theme.fg(\"error\", abortMessage), this.outputPad, 0));\n\t\t\t} else if (message.stopReason === \"error\") {\n\t\t\t\tconst errorMsg = message.errorMessage || \"Unknown error\";\n\t\t\t\tthis.contentContainer.addChild(new Spacer(1));\n\t\t\t\tthis.contentContainer.addChild(new Text(theme.fg(\"error\", `Error: ${errorMsg}`), this.outputPad, 0));\n\t\t\t}\n\t\t}\n\t}\n}\n"]}
1
+ {"version":3,"file":"assistant-message.js","sourceRoot":"","sources":["../../../../src/modes/interactive/components/assistant-message.ts"],"names":[],"mappings":"AAC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,IAAI,CAAC,KAAK,CAAC,iBAAiB,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAC5C,OAAO,IAAI,CAAC;IAAA,CACZ;CACD;AAED,SAAS,mBAAmB,CAAC,OAAoC,EAAc;IAC9E,MAAM,IAAI,GAAe,EAAE,CAAC;IAC5B,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACzC,MAAM,KAAK,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;QACzB,IAAI,KAAK,CAAC,IAAI,KAAK,UAAU;YAAE,SAAS;QACxC,MAAM,MAAM,GAAa,EAAE,CAAC;QAC5B,OAAO,CAAC,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;YAChC,MAAM,eAAe,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;YACnC,IAAI,eAAe,CAAC,IAAI,KAAK,UAAU,EAAE,CAAC;gBACzC,CAAC,EAAE,CAAC;gBACJ,MAAM;YACP,CAAC;YACD,MAAM,QAAQ,GAAG,eAAe,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC;YACjD,IAAI,QAAQ;gBAAE,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QACrC,CAAC;QACD,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC;YAAE,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAC1C,CAAC;IACD,OAAO,IAAI,CAAC;AAAA,CACZ","sourcesContent":["import type { AssistantMessage } from \"@ashx-j/lunr-ai\";\nimport { type Component, Container, Markdown, type MarkdownTheme, Spacer, Text } from \"@ashx-j/lunr-tui\";\nimport { getMarkdownTheme, theme } from \"../theme/theme.ts\";\nimport {\n\tformatThoughtDuration,\n\tisThinkingRunComplete,\n\ttype ThinkingRunTiming,\n\tthinkingSnippet,\n} from \"./thinking-summary.ts\";\nimport { ThinkingTailComponent } from \"./thinking-tail.ts\";\n\nconst OSC133_ZONE_START = \"\\x1b]133;A\\x07\";\nconst OSC133_ZONE_END = \"\\x1b]133;B\\x07\";\nconst OSC133_ZONE_FINAL = \"\\x1b]133;C\\x07\";\n\n/**\n * Component that renders a complete assistant message\n */\nexport class AssistantMessageComponent extends Container {\n\tselectable = true;\n\tprivate contentContainer: Container;\n\tprivate hideThinkingBlock: boolean;\n\t// lunr: collapsible reasoning — when true, a completed thinking run renders as\n\t// \"✻ Thought for Xs\" + its first sentence instead of the full block.\n\tprivate thinkingCollapse: boolean;\n\t// lunr: per-run expand. `expanded` still means \"all runs\" for setExpanded().\n\tprivate expanded = false;\n\tprivate expandedRuns = new Set<number>();\n\t// lunr: live per-run timings from interactive-mode; undefined = history message\n\t// (always treated as final, rendered without durations).\n\tprivate thinkingTimings?: ThinkingRunTiming[];\n\tprivate markdownTheme: MarkdownTheme;\n\t// lunr: kept for the deferred alternative hidden-thinking indicator (Phase 8 removed the label render).\n\t// biome-ignore lint/correctness/noUnusedPrivateClassMembers: retained for future use\n\tprivate hiddenThinkingLabel: string;\n\tprivate outputPad: number;\n\tprivate lastMessage?: AssistantMessage;\n\tprivate thinkingSource?: AssistantMessage;\n\tprivate hasToolCalls = false;\n\t// lunr: gutter rail — prefix rendered lines with a dim │; the last line uses ╰\n\t// when this component closes the turn (no tool calls follow).\n\tprivate gutterRail: boolean;\n\n\tconstructor(\n\t\tmessage?: AssistantMessage,\n\t\thideThinkingBlock = false,\n\t\tmarkdownTheme: MarkdownTheme = getMarkdownTheme(),\n\t\thiddenThinkingLabel = \"Thinking...\",\n\t\toutputPad = 1,\n\t\tgutterRail = false,\n\t\tthinkingCollapse = false,\n\t) {\n\t\tsuper();\n\n\t\tthis.hideThinkingBlock = hideThinkingBlock;\n\t\tthis.thinkingCollapse = thinkingCollapse;\n\t\tthis.markdownTheme = markdownTheme;\n\t\tthis.hiddenThinkingLabel = hiddenThinkingLabel;\n\t\tthis.outputPad = outputPad;\n\t\tthis.gutterRail = gutterRail;\n\n\t\t// Container for text/thinking content\n\t\tthis.contentContainer = new Container();\n\t\tthis.addChild(this.contentContainer);\n\n\t\tif (message) {\n\t\t\tthis.updateContent(message);\n\t\t}\n\t}\n\n\toverride invalidate(): void {\n\t\tsuper.invalidate();\n\t\tif (this.lastMessage) {\n\t\t\tthis.updateContent(this.lastMessage, this.thinkingSourceOptions());\n\t\t}\n\t}\n\n\tsetHideThinkingBlock(hide: boolean): void {\n\t\tthis.hideThinkingBlock = hide;\n\t\tif (this.lastMessage) {\n\t\t\tthis.updateContent(this.lastMessage, this.thinkingSourceOptions());\n\t\t}\n\t}\n\n\t// lunr: collapsible reasoning toggles (live; re-render like setHideThinkingBlock).\n\tsetThinkingCollapse(collapse: boolean): void {\n\t\tthis.thinkingCollapse = collapse;\n\t\tif (this.lastMessage) {\n\t\t\tthis.updateContent(this.lastMessage, this.thinkingSourceOptions());\n\t\t}\n\t}\n\n\t// lunr: Expandable hook; true expands every thinking run, false collapses all.\n\tsetExpanded(expanded: boolean): void {\n\t\tthis.expanded = expanded;\n\t\tif (!expanded) this.expandedRuns.clear();\n\t\tif (this.lastMessage) {\n\t\t\tthis.updateContent(this.lastMessage, this.thinkingSourceOptions());\n\t\t}\n\t}\n\n\tprivate isRunExpanded(runIndex: number): boolean {\n\t\treturn this.expanded || this.expandedRuns.has(runIndex);\n\t}\n\n\ttoggleThinkingRun(runIndex: number): void {\n\t\tif (this.expanded) {\n\t\t\tthis.expanded = false;\n\t\t\tthis.expandedRuns.clear();\n\t\t\tconst count = this.lastMessage ? collectThinkingRuns(this.lastMessage.content).length : 0;\n\t\t\tfor (let i = 0; i < count; i++) {\n\t\t\t\tif (i !== runIndex) this.expandedRuns.add(i);\n\t\t\t}\n\t\t} else if (this.expandedRuns.has(runIndex)) {\n\t\t\tthis.expandedRuns.delete(runIndex);\n\t\t} else {\n\t\t\tthis.expandedRuns.add(runIndex);\n\t\t}\n\t\tif (this.lastMessage) {\n\t\t\tthis.updateContent(this.lastMessage, this.thinkingSourceOptions());\n\t\t}\n\t}\n\n\thandleClick(localY: number, width: number): boolean {\n\t\tconst contentWidth = this.gutterRail ? Math.max(1, width - 2) : width;\n\t\tlet y = 0;\n\t\tfor (const child of this.contentContainer.children) {\n\t\t\tconst h = child.render(contentWidth).length;\n\t\t\tif (localY >= y && localY < y + h) {\n\t\t\t\tif (typeof child.handleClick === \"function\") {\n\t\t\t\t\treturn child.handleClick(localY - y, contentWidth);\n\t\t\t\t}\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\ty += h;\n\t\t}\n\t\treturn false;\n\t}\n\n\tsetThinkingTimings(timings: ThinkingRunTiming[] | undefined): void {\n\t\tthis.thinkingTimings = timings;\n\t}\n\n\t// lunr: gutter rail toggle (live; applied on next render).\n\tsetGutterRail(enabled: boolean): void {\n\t\tthis.gutterRail = enabled;\n\t}\n\n\tsetHiddenThinkingLabel(label: string): void {\n\t\tthis.hiddenThinkingLabel = label;\n\t\tif (this.lastMessage) {\n\t\t\tthis.updateContent(this.lastMessage, this.thinkingSourceOptions());\n\t\t}\n\t}\n\n\tsetOutputPad(padding: number): void {\n\t\tthis.outputPad = padding;\n\t\tif (this.lastMessage) {\n\t\t\tthis.updateContent(this.lastMessage, this.thinkingSourceOptions());\n\t\t}\n\t}\n\n\toverride render(width: number): string[] {\n\t\t// lunr: gutter rail — render content at width-2 and prefix each line with a\n\t\t// dim │; the last line uses ╰ when this assistant message closes the turn\n\t\t// (no tool calls follow). When tool calls are present the rail stays open (│)\n\t\t// because tool-execution components render their own borders below.\n\t\tconst railEnabled = this.gutterRail;\n\t\tconst contentWidth = railEnabled ? Math.max(1, width - 2) : width;\n\t\tconst lines = super.render(contentWidth);\n\t\tif (this.hasToolCalls || lines.length === 0) {\n\t\t\tif (railEnabled && lines.length > 0) {\n\t\t\t\tconst rail = theme.fg(\"dim\", \"│ \");\n\t\t\t\tfor (let i = 0; i < lines.length; i++) {\n\t\t\t\t\tlines[i] = rail + lines[i];\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn lines;\n\t\t}\n\n\t\tlines[0] = OSC133_ZONE_START + lines[0];\n\t\tlines[lines.length - 1] = OSC133_ZONE_END + OSC133_ZONE_FINAL + lines[lines.length - 1];\n\n\t\tif (railEnabled) {\n\t\t\tconst rail = theme.fg(\"dim\", \"│ \");\n\t\t\tconst close = theme.fg(\"dim\", \"╰ \");\n\t\t\tfor (let i = 0; i < lines.length; i++) {\n\t\t\t\tlines[i] = (i === lines.length - 1 ? close : rail) + lines[i];\n\t\t\t}\n\t\t}\n\t\treturn lines;\n\t}\n\n\tprivate thinkingSourceOptions(): { thinkingSource?: AssistantMessage } | undefined {\n\t\treturn this.thinkingSource ? { thinkingSource: this.thinkingSource } : undefined;\n\t}\n\n\tupdateContent(message: AssistantMessage, options?: { thinkingSource?: AssistantMessage }): void {\n\t\tthis.lastMessage = message;\n\t\tthis.thinkingSource = options?.thinkingSource;\n\n\t\t// Clear content container\n\t\tthis.contentContainer.clear();\n\n\t\tconst sourceMessage = this.thinkingSource ?? message;\n\t\tconst sourceThinkingRuns = collectThinkingRuns(sourceMessage.content);\n\t\tconst hasVisibleContent =\n\t\t\tmessage.content.some(\n\t\t\t\t(c) => (c.type === \"text\" && c.text.trim()) || (c.type === \"thinking\" && c.thinking.trim()),\n\t\t\t) ||\n\t\t\t(!this.hideThinkingBlock && sourceThinkingRuns.some((run) => run.length > 0));\n\n\t\tif (hasVisibleContent) {\n\t\t\tthis.contentContainer.addChild(new Spacer(1));\n\t\t}\n\n\t\t// Render content in order\n\t\tlet isFirstTextBlock = true;\n\t\tlet thinkingRunIndex = -1;\n\t\tlet renderedThinking = false;\n\t\tfor (let i = 0; i < message.content.length; i++) {\n\t\t\tconst content = message.content[i];\n\t\t\tif (content.type === \"text\" && content.text.trim()) {\n\t\t\t\t// Assistant text messages with no background - trim the text\n\t\t\t\t// Set paddingY=0 to avoid extra spacing before tool executions\n\t\t\t\t// lunr: leading ● marks the first text block (never thinking blocks). It rides\n\t\t\t\t// the defaultTextStyle below, so it renders bright white like the body.\n\t\t\t\tconst trimmed = content.text.trim();\n\t\t\t\tconst text = isFirstTextBlock ? `● ${trimmed}` : trimmed;\n\t\t\t\tisFirstTextBlock = false;\n\t\t\t\t// lunr: theme-polish — assistant message body renders bright white via the\n\t\t\t\t// shared userMessageText token (same knob as user messages).\n\t\t\t\tthis.contentContainer.addChild(\n\t\t\t\t\tnew Markdown(text, this.outputPad, 0, this.markdownTheme, {\n\t\t\t\t\t\tcolor: (body: string) => theme.fg(\"userMessageText\", body),\n\t\t\t\t\t}),\n\t\t\t\t);\n\t\t\t} else if (content.type === \"thinking\") {\n\t\t\t\tthinkingRunIndex++;\n\t\t\t\tconst displayBlocks: string[] = [];\n\t\t\t\tfor (; i < message.content.length; i++) {\n\t\t\t\t\tconst thinkingContent = message.content[i];\n\t\t\t\t\tif (thinkingContent.type !== \"thinking\") {\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\tconst thinking = thinkingContent.thinking.trim();\n\t\t\t\t\tif (thinking) {\n\t\t\t\t\t\tdisplayBlocks.push(thinking);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\ti--;\n\n\t\t\t\tconst thinkingBlocks = sourceThinkingRuns[thinkingRunIndex] ?? displayBlocks;\n\t\t\t\tif (thinkingBlocks.length === 0 || this.hideThinkingBlock) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\trenderedThinking = true;\n\t\t\t\tthis.renderThinkingRun(thinkingRunIndex, thinkingBlocks, message, i);\n\t\t\t}\n\t\t}\n\n\t\tif (!this.hideThinkingBlock && !renderedThinking && sourceThinkingRuns.length > 0) {\n\t\t\tthinkingRunIndex = 0;\n\t\t\tconst thinkingBlocks = sourceThinkingRuns[0] ?? [];\n\t\t\tif (thinkingBlocks.length > 0) {\n\t\t\t\tthis.renderThinkingRun(thinkingRunIndex, thinkingBlocks, message, -1);\n\t\t\t}\n\t\t}\n\n\t\t// Check if incomplete/failed - show after partial content.\n\t\t// For aborted/error tool calls, tool execution components show the error.\n\t\t// Length stops can happen before a tool call is complete, so surface them here too.\n\t\tconst hasToolCalls = message.content.some((c) => c.type === \"toolCall\");\n\t\tthis.hasToolCalls = hasToolCalls;\n\t\tif (message.stopReason === \"length\") {\n\t\t\tthis.contentContainer.addChild(new Spacer(1));\n\t\t\tthis.contentContainer.addChild(\n\t\t\t\tnew Text(\n\t\t\t\t\ttheme.fg(\n\t\t\t\t\t\t\"error\",\n\t\t\t\t\t\t\"Error: Model stopped because it reached the maximum output token limit. The response may be incomplete.\",\n\t\t\t\t\t),\n\t\t\t\t\tthis.outputPad,\n\t\t\t\t\t0,\n\t\t\t\t),\n\t\t\t);\n\t\t} else if (!hasToolCalls) {\n\t\t\tif (message.stopReason === \"aborted\") {\n\t\t\t\tconst abortMessage =\n\t\t\t\t\tmessage.errorMessage && message.errorMessage !== \"Request was aborted\"\n\t\t\t\t\t\t? message.errorMessage\n\t\t\t\t\t\t: \"Operation aborted\";\n\t\t\t\tthis.contentContainer.addChild(new Spacer(1));\n\t\t\t\tthis.contentContainer.addChild(new Text(theme.fg(\"error\", abortMessage), this.outputPad, 0));\n\t\t\t} else if (message.stopReason === \"error\") {\n\t\t\t\tconst errorMsg = message.errorMessage || \"Unknown error\";\n\t\t\t\tthis.contentContainer.addChild(new Spacer(1));\n\t\t\t\tthis.contentContainer.addChild(new Text(theme.fg(\"error\", `Error: ${errorMsg}`), this.outputPad, 0));\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate renderThinkingRun(\n\t\tthinkingRunIndex: number,\n\t\tthinkingBlocks: string[],\n\t\tdisplayMessage: AssistantMessage,\n\t\tdisplayIndex: number,\n\t): void {\n\t\tconst hasVisibleContentAfter =\n\t\t\tdisplayIndex >= 0\n\t\t\t\t? displayMessage.content\n\t\t\t\t\t\t.slice(displayIndex + 1)\n\t\t\t\t\t\t.some((c) => (c.type === \"text\" && c.text.trim()) || (c.type === \"thinking\" && c.thinking.trim()))\n\t\t\t\t: displayMessage.content.some((c) => c.type === \"text\" && c.text.trim());\n\n\t\tconst runComplete = isThinkingRunComplete(\n\t\t\tfalse,\n\t\t\tthis.thinkingTimings?.[thinkingRunIndex],\n\t\t\tthis.thinkingTimings !== undefined,\n\t\t);\n\t\tconst wrap = (inner: Component): void => {\n\t\t\tthis.contentContainer.addChild(new ThinkingRunBlock(this, thinkingRunIndex, inner));\n\t\t};\n\t\tif (this.thinkingCollapse && !this.isRunExpanded(thinkingRunIndex) && runComplete) {\n\t\t\tconst timing = this.thinkingTimings?.[thinkingRunIndex];\n\t\t\tconst label =\n\t\t\t\ttiming?.end !== undefined\n\t\t\t\t\t? `✻ Thought for ${formatThoughtDuration(timing.end - timing.start)}`\n\t\t\t\t\t: \"✻ Thought\";\n\t\t\tconst block = new Container();\n\t\t\tblock.addChild(new Text(theme.fg(\"thinkingText\", theme.italic(label)), this.outputPad, 0));\n\t\t\tconst snippet = thinkingSnippet(thinkingBlocks.join(\"\\n\\n\"));\n\t\t\tif (snippet) {\n\t\t\t\tblock.addChild(new Text(theme.fg(\"thinkingText\", theme.italic(snippet)), this.outputPad + 2, 0));\n\t\t\t}\n\t\t\twrap(block);\n\t\t\tif (hasVisibleContentAfter) {\n\t\t\t\tthis.contentContainer.addChild(new Spacer(1));\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\t\tif (!runComplete && !this.isRunExpanded(thinkingRunIndex)) {\n\t\t\twrap(\n\t\t\t\tnew ThinkingTailComponent(thinkingBlocks.join(\"\\n\\n\"), this.outputPad, 0, this.markdownTheme, {\n\t\t\t\t\tcolor: (text: string) => theme.fg(\"thinkingText\", text),\n\t\t\t\t\titalic: true,\n\t\t\t\t}),\n\t\t\t);\n\t\t\tif (hasVisibleContentAfter) {\n\t\t\t\tthis.contentContainer.addChild(new Spacer(1));\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\t\twrap(\n\t\t\tnew Markdown(thinkingBlocks.join(\"\\n\\n\"), this.outputPad, 0, this.markdownTheme, {\n\t\t\t\tcolor: (text: string) => theme.fg(\"thinkingText\", text),\n\t\t\t\titalic: true,\n\t\t\t}),\n\t\t);\n\t\tif (hasVisibleContentAfter) {\n\t\t\tthis.contentContainer.addChild(new Spacer(1));\n\t\t}\n\t}\n}\n\nclass ThinkingRunBlock extends Container {\n\tprivate readonly owner: AssistantMessageComponent;\n\tprivate readonly runIndex: number;\n\n\tconstructor(owner: AssistantMessageComponent, runIndex: number, inner: Component) {\n\t\tsuper();\n\t\tthis.owner = owner;\n\t\tthis.runIndex = runIndex;\n\t\tthis.addChild(inner);\n\t}\n\n\thandleClick(_localY: number, _width: number): boolean {\n\t\tthis.owner.toggleThinkingRun(this.runIndex);\n\t\treturn true;\n\t}\n}\n\nfunction collectThinkingRuns(content: AssistantMessage[\"content\"]): string[][] {\n\tconst runs: string[][] = [];\n\tfor (let i = 0; i < content.length; i++) {\n\t\tconst block = content[i];\n\t\tif (block.type !== \"thinking\") continue;\n\t\tconst blocks: string[] = [];\n\t\tfor (; i < content.length; i++) {\n\t\t\tconst thinkingContent = content[i];\n\t\t\tif (thinkingContent.type !== \"thinking\") {\n\t\t\t\ti--;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tconst thinking = thinkingContent.thinking.trim();\n\t\t\tif (thinking) blocks.push(thinking);\n\t\t}\n\t\tif (blocks.length > 0) runs.push(blocks);\n\t}\n\treturn runs;\n}\n"]}
@@ -1,6 +1,7 @@
1
1
  import type { ThinkingLevel } from "@ashx-j/lunr-agent";
2
2
  import type { Transport } from "@ashx-j/lunr-ai";
3
3
  import { type Component, Container, SettingsList } from "@ashx-j/lunr-tui";
4
+ import { type BehaviorPreset } from "../../../core/behavior-preset.ts";
4
5
  import type { SearchCuratorSetting } from "../../../core/search-curator.ts";
5
6
  import type { DefaultPermissionMode, DefaultProjectTrust, ModelTierName, ModelTiersSettings, RollbackCapture, RollbackScope } from "../../../core/settings-manager.ts";
6
7
  import { type TerminalTheme } from "../theme/theme.ts";
@@ -39,6 +40,7 @@ export interface SettingsConfig {
39
40
  showTerminalProgress: boolean;
40
41
  modelTiers: ModelTiersSettings;
41
42
  memoryCharCap: number;
43
+ behaviorPreset: BehaviorPreset;
42
44
  /** undefined when pi-web-access is not loaded (curator bridge absent). */
43
45
  searchCurator: SearchCuratorSetting | undefined;
44
46
  gutterRail: boolean;
@@ -48,6 +50,10 @@ export interface SettingsConfig {
48
50
  footerContext: boolean;
49
51
  footerTokens: boolean;
50
52
  footerStatuses: boolean;
53
+ footerGit: boolean;
54
+ footerPlan: boolean;
55
+ footerPlanBar: boolean;
56
+ planUsageWindow: "5h" | "weekly";
51
57
  defaultPermissionMode: DefaultPermissionMode;
52
58
  rollbackEnabled: boolean;
53
59
  rollbackTurns: number;
@@ -88,7 +94,10 @@ export interface SettingsCallbacks {
88
94
  onShowTerminalProgressChange: (enabled: boolean) => void;
89
95
  onModelTiersEnabledChange: (enabled: boolean) => void;
90
96
  onModelTierModelChange: (tier: ModelTierName, model: string) => void;
97
+ onModelTierThinkingChange: (tier: ModelTierName, level: ThinkingLevel | undefined) => void;
98
+ getTierThinkingLevels: (tier: ModelTierName) => ThinkingLevel[];
91
99
  onMemoryCharCapChange: (cap: number) => void;
100
+ onBehaviorPresetChange: (preset: BehaviorPreset) => void;
92
101
  onSearchCuratorChange: (setting: SearchCuratorSetting) => void;
93
102
  onGutterRailChange: (enabled: boolean) => void;
94
103
  onPromptSymbolChange: (enabled: boolean) => void;
@@ -97,6 +106,10 @@ export interface SettingsCallbacks {
97
106
  onFooterContextChange: (enabled: boolean) => void;
98
107
  onFooterTokensChange: (enabled: boolean) => void;
99
108
  onFooterStatusesChange: (enabled: boolean) => void;
109
+ onFooterGitChange: (enabled: boolean) => void;
110
+ onFooterPlanChange: (enabled: boolean) => void;
111
+ onFooterPlanBarChange: (enabled: boolean) => void;
112
+ onPlanUsageWindowChange: (window: "5h" | "weekly") => void;
100
113
  onDefaultPermissionModeChange: (mode: DefaultPermissionMode) => void;
101
114
  onRollbackEnabledChange: (enabled: boolean) => void;
102
115
  onRollbackTurnsChange: (turns: number) => void;