@di-code/coding-agent 0.1.3 → 0.1.6

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 (147) hide show
  1. package/README.md +91 -30
  2. package/dist/cli.d.ts +15 -0
  3. package/dist/cli.d.ts.map +1 -1
  4. package/dist/cli.js +96 -17
  5. package/dist/cli.js.map +1 -1
  6. package/dist/core/clipboard-image.d.ts +3 -3
  7. package/dist/core/clipboard-image.d.ts.map +1 -1
  8. package/dist/core/clipboard-image.js +26 -13
  9. package/dist/core/clipboard-image.js.map +1 -1
  10. package/dist/core/context-builder.d.ts.map +1 -1
  11. package/dist/core/context-builder.js +6 -2
  12. package/dist/core/context-builder.js.map +1 -1
  13. package/dist/core/image-input.d.ts +1 -1
  14. package/dist/core/image-input.d.ts.map +1 -1
  15. package/dist/core/image-input.js +55 -10
  16. package/dist/core/image-input.js.map +1 -1
  17. package/dist/core/resources/loader.d.ts.map +1 -1
  18. package/dist/core/resources/loader.js +15 -42
  19. package/dist/core/resources/loader.js.map +1 -1
  20. package/dist/core/resources/types.d.ts +6 -9
  21. package/dist/core/resources/types.d.ts.map +1 -1
  22. package/dist/core/resources/types.js.map +1 -1
  23. package/dist/core/session/session-manager.d.ts +12 -1
  24. package/dist/core/session/session-manager.d.ts.map +1 -1
  25. package/dist/core/session/session-manager.js +66 -3
  26. package/dist/core/session/session-manager.js.map +1 -1
  27. package/dist/core/session/session-storage.d.ts.map +1 -1
  28. package/dist/core/session/session-storage.js +30 -15
  29. package/dist/core/session/session-storage.js.map +1 -1
  30. package/dist/core/session/types.d.ts +6 -1
  31. package/dist/core/session/types.d.ts.map +1 -1
  32. package/dist/core/session/types.js +1 -1
  33. package/dist/core/session/types.js.map +1 -1
  34. package/dist/core/session.d.ts +38 -3
  35. package/dist/core/session.d.ts.map +1 -1
  36. package/dist/core/session.js +167 -9
  37. package/dist/core/session.js.map +1 -1
  38. package/dist/core/system-prompt.js +2 -2
  39. package/dist/core/system-prompt.js.map +1 -1
  40. package/dist/core/tools/bash.d.ts +2 -2
  41. package/dist/core/tools/bash.d.ts.map +1 -1
  42. package/dist/core/tools/bash.js.map +1 -1
  43. package/dist/core/tools/edit-diff.d.ts +25 -0
  44. package/dist/core/tools/edit-diff.d.ts.map +1 -0
  45. package/dist/core/tools/edit-diff.js +136 -0
  46. package/dist/core/tools/edit-diff.js.map +1 -0
  47. package/dist/core/tools/edit.d.ts +13 -4
  48. package/dist/core/tools/edit.d.ts.map +1 -1
  49. package/dist/core/tools/edit.js +64 -30
  50. package/dist/core/tools/edit.js.map +1 -1
  51. package/dist/core/tools/file-search.d.ts +14 -0
  52. package/dist/core/tools/file-search.d.ts.map +1 -0
  53. package/dist/core/tools/file-search.js +99 -0
  54. package/dist/core/tools/file-search.js.map +1 -0
  55. package/dist/core/tools/glob.d.ts +11 -0
  56. package/dist/core/tools/glob.d.ts.map +1 -0
  57. package/dist/core/tools/glob.js +44 -0
  58. package/dist/core/tools/glob.js.map +1 -0
  59. package/dist/core/tools/grep.d.ts +13 -0
  60. package/dist/core/tools/grep.d.ts.map +1 -0
  61. package/dist/core/tools/grep.js +67 -0
  62. package/dist/core/tools/grep.js.map +1 -0
  63. package/dist/core/tools/load-skill.d.ts +10 -0
  64. package/dist/core/tools/load-skill.d.ts.map +1 -0
  65. package/dist/core/tools/load-skill.js +22 -0
  66. package/dist/core/tools/load-skill.js.map +1 -0
  67. package/dist/core/tools/path-boundary.d.ts +2 -0
  68. package/dist/core/tools/path-boundary.d.ts.map +1 -1
  69. package/dist/core/tools/path-boundary.js +4 -0
  70. package/dist/core/tools/path-boundary.js.map +1 -1
  71. package/dist/core/tools/read.d.ts +2 -2
  72. package/dist/core/tools/read.d.ts.map +1 -1
  73. package/dist/core/tools/read.js.map +1 -1
  74. package/dist/core/tools/write.d.ts +2 -2
  75. package/dist/core/tools/write.d.ts.map +1 -1
  76. package/dist/core/tools/write.js.map +1 -1
  77. package/dist/core/user-data.d.ts +3 -0
  78. package/dist/core/user-data.d.ts.map +1 -0
  79. package/dist/core/user-data.js +8 -0
  80. package/dist/core/user-data.js.map +1 -0
  81. package/dist/entry.js +22 -2
  82. package/dist/entry.js.map +1 -1
  83. package/dist/extensions/runtime.js +2 -2
  84. package/dist/extensions/runtime.js.map +1 -1
  85. package/dist/i18n.d.ts +5 -0
  86. package/dist/i18n.d.ts.map +1 -0
  87. package/dist/i18n.js +223 -0
  88. package/dist/i18n.js.map +1 -0
  89. package/dist/index.d.ts +3 -0
  90. package/dist/index.d.ts.map +1 -1
  91. package/dist/index.js +3 -0
  92. package/dist/index.js.map +1 -1
  93. package/dist/main.d.ts +20 -1
  94. package/dist/main.d.ts.map +1 -1
  95. package/dist/main.js +272 -17
  96. package/dist/main.js.map +1 -1
  97. package/dist/mcp/config.d.ts +33 -0
  98. package/dist/mcp/config.d.ts.map +1 -0
  99. package/dist/mcp/config.js +211 -0
  100. package/dist/mcp/config.js.map +1 -0
  101. package/dist/mcp/loader.d.ts +21 -0
  102. package/dist/mcp/loader.d.ts.map +1 -0
  103. package/dist/mcp/loader.js +60 -0
  104. package/dist/mcp/loader.js.map +1 -0
  105. package/dist/mcp/tool-adapter.d.ts +5 -0
  106. package/dist/mcp/tool-adapter.d.ts.map +1 -0
  107. package/dist/mcp/tool-adapter.js +149 -0
  108. package/dist/mcp/tool-adapter.js.map +1 -0
  109. package/dist/modes/interactive-components.d.ts +2 -0
  110. package/dist/modes/interactive-components.d.ts.map +1 -1
  111. package/dist/modes/interactive-components.js +55 -31
  112. package/dist/modes/interactive-components.js.map +1 -1
  113. package/dist/modes/interactive-diff.d.ts +8 -0
  114. package/dist/modes/interactive-diff.d.ts.map +1 -0
  115. package/dist/modes/interactive-diff.js +78 -0
  116. package/dist/modes/interactive-diff.js.map +1 -0
  117. package/dist/modes/interactive-layout.d.ts +4 -0
  118. package/dist/modes/interactive-layout.d.ts.map +1 -1
  119. package/dist/modes/interactive-layout.js +4 -0
  120. package/dist/modes/interactive-layout.js.map +1 -1
  121. package/dist/modes/interactive-state.d.ts +5 -0
  122. package/dist/modes/interactive-state.d.ts.map +1 -1
  123. package/dist/modes/interactive-state.js +65 -11
  124. package/dist/modes/interactive-state.js.map +1 -1
  125. package/dist/modes/interactive.d.ts +19 -0
  126. package/dist/modes/interactive.d.ts.map +1 -1
  127. package/dist/modes/interactive.js +351 -52
  128. package/dist/modes/interactive.js.map +1 -1
  129. package/dist/modes/tree-selector.d.ts +30 -0
  130. package/dist/modes/tree-selector.d.ts.map +1 -0
  131. package/dist/modes/tree-selector.js +205 -0
  132. package/dist/modes/tree-selector.js.map +1 -0
  133. package/dist/plugins/loader.d.ts +19 -1
  134. package/dist/plugins/loader.d.ts.map +1 -1
  135. package/dist/plugins/loader.js +21 -2
  136. package/dist/plugins/loader.js.map +1 -1
  137. package/dist/provider-onboarding.d.ts +8 -1
  138. package/dist/provider-onboarding.d.ts.map +1 -1
  139. package/dist/provider-onboarding.js +160 -40
  140. package/dist/provider-onboarding.js.map +1 -1
  141. package/dist/rpc-entry.js +1 -1
  142. package/dist/rpc-entry.js.map +1 -1
  143. package/dist/startup.d.ts +34 -3
  144. package/dist/startup.d.ts.map +1 -1
  145. package/dist/startup.js +407 -87
  146. package/dist/startup.js.map +1 -1
  147. package/package.json +7 -4
@@ -1,5 +1,7 @@
1
- import { Box, Markdown, Text, truncateToWidth, visibleWidth } from "@di-code/tui";
1
+ import { Markdown, SelectionPanel, Text, truncateToWidth, visibleWidth } from "@di-code/tui";
2
+ import { DEFAULT_LOCALE, translate } from "../i18n.js";
2
3
  import { highlightCode } from "../utils/syntax-highlight.js";
4
+ import { renderDiff } from "./interactive-diff.js";
3
5
  const RESET = "\x1b[0m";
4
6
  const BOLD = "\x1b[1m";
5
7
  const MAX_VISIBLE_TOOL_ITEMS = 6;
@@ -12,6 +14,7 @@ function paletteFor(theme) {
12
14
  dim: "\x1b[38;5;242m",
13
15
  error: "\x1b[38;5;160m",
14
16
  success: "\x1b[38;5;28m",
17
+ userBackground: "\x1b[48;2;239;246;255m",
15
18
  warning: "\x1b[38;5;130m",
16
19
  }
17
20
  : {
@@ -20,12 +23,16 @@ function paletteFor(theme) {
20
23
  dim: "\x1b[38;5;245m",
21
24
  error: "\x1b[38;5;210m",
22
25
  success: "\x1b[38;5;114m",
26
+ userBackground: "\x1b[48;2;31;39;50m",
23
27
  warning: "\x1b[38;5;222m",
24
28
  };
25
29
  }
26
30
  function paint(color, text, bold = false) {
27
31
  return `${color}${bold ? BOLD : ""}${text}${RESET}`;
28
32
  }
33
+ function paintBackground(background, text) {
34
+ return `${background}${text}${RESET}`;
35
+ }
29
36
  function markdownThemeFor(colors) {
30
37
  return {
31
38
  heading: (text) => paint(colors.assistant, text, true),
@@ -58,14 +65,14 @@ function alignEnds(left, right, width) {
58
65
  function activityLabel(state) {
59
66
  const colors = paletteFor(state.theme);
60
67
  if (state.error)
61
- return { text: "ERROR", color: colors.error };
68
+ return { text: translate(state.locale ?? DEFAULT_LOCALE, "error"), color: colors.error };
62
69
  if (state.compacting)
63
- return { text: "COMPACTING", color: colors.warning };
70
+ return { text: translate(state.locale ?? DEFAULT_LOCALE, "compacting"), color: colors.warning };
64
71
  if (state.retrying)
65
- return { text: "RETRYING", color: colors.warning };
72
+ return { text: translate(state.locale ?? DEFAULT_LOCALE, "retrying"), color: colors.warning };
66
73
  if (state.busy)
67
- return { text: "WORKING", color: colors.accent };
68
- return { text: "READY", color: colors.success };
74
+ return { text: translate(state.locale ?? DEFAULT_LOCALE, "working"), color: colors.accent };
75
+ return { text: translate(state.locale ?? DEFAULT_LOCALE, "ready"), color: colors.success };
69
76
  }
70
77
  export class InteractiveHeader {
71
78
  readState;
@@ -99,20 +106,28 @@ export class InteractiveChat {
99
106
  if (index > 0)
100
107
  lines.push(" ");
101
108
  if (message.role === "file_change") {
102
- lines.push(...renderLine(paint(colors.dim, `${message.kind === "edit" ? "Edited" : "Wrote"} ${message.path}`, true), width));
103
- for (const line of message.removed)
104
- lines.push(...renderLine(paint(colors.error, `- ${line}`), width));
105
- for (const line of message.added)
106
- lines.push(...renderLine(paint(colors.success, `+ ${line}`), width));
109
+ lines.push(...renderLine(paint(colors.dim, `${translate(state.locale ?? DEFAULT_LOCALE, message.kind === "edit" ? "edited" : "wrote")} ${message.path}`, true), width));
110
+ if (message.diff) {
111
+ for (const line of renderDiff(message.diff, colors))
112
+ lines.push(...renderLine(line, width));
113
+ }
114
+ else {
115
+ for (const line of message.removed)
116
+ lines.push(...renderLine(paint(colors.error, `- ${line}`), width));
117
+ for (const line of message.added)
118
+ lines.push(...renderLine(paint(colors.success, `+ ${line}`), width));
119
+ }
107
120
  }
108
121
  else if (message.role === "user") {
109
- lines.push(...new Box(new Text(message.text, 0, 0), { border: "single", padding: 1, title: "You" }).render(width));
122
+ lines.push(...new Text(message.text, 2, 1).render(width).map((line) => paintBackground(colors.userBackground, line)));
110
123
  }
111
124
  else {
112
- lines.push(...renderLine(paint(colors.assistant, "Assistant", true), width));
113
125
  lines.push(...new Markdown(message.text, { paddingX: 2, theme: markdownTheme }).render(width));
114
126
  }
115
127
  }
128
+ const hasProcess = state.processItems.length > 0 || (state.busy && !state.streamingText);
129
+ if (hasProcess && lines.length > 0)
130
+ lines.push(" ");
116
131
  const toolCount = state.processItems.filter((item) => item.type === "tool").length;
117
132
  const hiddenToolItems = Math.max(0, toolCount - MAX_VISIBLE_TOOL_ITEMS);
118
133
  let skippedToolItems = 0;
@@ -122,12 +137,12 @@ export class InteractiveChat {
122
137
  continue;
123
138
  }
124
139
  if (item.type === "tool" && skippedToolItems === hiddenToolItems && hiddenToolItems > 0) {
125
- lines.push(...renderLine(` ${paint(colors.dim, `${hiddenToolItems} earlier tool updates`)}`, width));
140
+ lines.push(...renderLine(` ${paint(colors.dim, translate(state.locale ?? DEFAULT_LOCALE, "earlierToolUpdates", String(hiddenToolItems)))}`, width));
126
141
  skippedToolItems += 1;
127
142
  }
128
143
  if (item.type === "thinking") {
129
144
  const frame = SPINNER_FRAMES[state.spinnerFrame % SPINNER_FRAMES.length] ?? SPINNER_FRAMES[0];
130
- lines.push(...renderLine(` ${paint(colors.accent, `${frame} Thinking`)}`, width));
145
+ lines.push(...renderLine(` ${paint(colors.accent, `${frame} ${translate(state.locale ?? DEFAULT_LOCALE, "thinking")}`)}`, width));
131
146
  continue;
132
147
  }
133
148
  const marker = item.status === "running" ? ">" : item.status === "error" ? "!" : "+";
@@ -135,30 +150,31 @@ export class InteractiveChat {
135
150
  const color = item.status === "error" ? colors.error : item.status === "done" ? colors.success : colors.warning;
136
151
  lines.push(...renderLine(` ${paint(color, marker)} ${paint(colors.dim, command)}`, width));
137
152
  }
138
- if (state.busy && !state.processItems.some((item) => item.type === "thinking")) {
153
+ if (state.busy && !state.streamingText && !state.processItems.some((item) => item.type === "thinking")) {
139
154
  const frame = SPINNER_FRAMES[state.spinnerFrame % SPINNER_FRAMES.length] ?? SPINNER_FRAMES[0];
140
- lines.push(...renderLine(` ${paint(colors.accent, `${frame} Thinking`)}`, width));
155
+ lines.push(...renderLine(` ${paint(colors.accent, `${frame} ${translate(state.locale ?? DEFAULT_LOCALE, "thinking")}`)}`, width));
141
156
  }
157
+ if (hasProcess)
158
+ lines.push(" ");
142
159
  if (state.streamingText) {
143
- if (lines.length > 0)
160
+ if (lines.length > 0 && lines.at(-1) !== " ")
144
161
  lines.push(" ");
145
- lines.push(...renderLine(paint(colors.assistant, "Assistant", true), width));
146
162
  lines.push(...new Markdown(state.streamingText, { paddingX: 2, theme: markdownTheme }).render(width));
147
163
  }
148
164
  const hasActivity = state.status || state.queue.length > 0 || state.error;
149
165
  if (hasActivity) {
150
166
  if (lines.length > 0)
151
167
  lines.push(" ");
152
- lines.push(...renderLine(paint(colors.dim, "Activity", true), width));
168
+ lines.push(...renderLine(paint(colors.dim, translate(state.locale ?? DEFAULT_LOCALE, "activity"), true), width));
153
169
  if (state.status)
154
170
  lines.push(...renderLine(` ${paint(colors.dim, state.status)}`, width));
155
171
  if (state.queue.length > 0) {
156
- lines.push(...renderLine(` ${paint(colors.dim, `Queue (${state.queue.length})`)}`, width));
172
+ lines.push(...renderLine(` ${paint(colors.dim, translate(state.locale ?? DEFAULT_LOCALE, "queue", String(state.queue.length)))}`, width));
157
173
  for (const prompt of state.queue)
158
174
  lines.push(...new Text(` ${prompt}`).render(width));
159
175
  }
160
176
  if (state.error)
161
- lines.push(...new Text(` ${paint(colors.error, `Error: ${state.error}`, true)}`).render(width));
177
+ lines.push(...new Text(` ${paint(colors.error, `${translate(state.locale ?? DEFAULT_LOCALE, "errorPrefix")}: ${state.error}`, true)}`).render(width));
162
178
  }
163
179
  const rendered = lines.flatMap((line) => new Text(line).render(width));
164
180
  return rendered.length > 0 ? rendered : [""];
@@ -173,7 +189,10 @@ export class InteractiveComposer {
173
189
  render(width) {
174
190
  const state = this.readState();
175
191
  const colors = paletteFor(state.theme);
176
- const copy = width >= 56 ? "/ commands Tab complete" : "/ commands";
192
+ const locale = state.locale ?? DEFAULT_LOCALE;
193
+ const copy = width >= 56
194
+ ? `/ ${translate(locale, "commands")} Tab ${translate(locale, "complete")}`
195
+ : `/ ${translate(locale, "commands")}`;
177
196
  return renderLine(paint(colors.dim, copy), width);
178
197
  }
179
198
  }
@@ -188,13 +207,13 @@ export class InteractiveFooter {
188
207
  const colors = paletteFor(state.theme);
189
208
  const activity = activityLabel(state);
190
209
  const left = paint(activity.color, `* ${activity.text}`, true);
191
- const context = paint(colors.dim, `${state.messageItems.length} messages ctx ${formatTokenCount(state.usage.estimatedContextTokens)}/${formatTokenCount(state.usage.contextWindow)} total ${formatTokenCount(state.usage.totalTokens)} tok`);
210
+ const context = paint(colors.dim, `${translate(state.locale ?? DEFAULT_LOCALE, "messages", String(state.messageItems.length))} ${translate(state.locale ?? DEFAULT_LOCALE, "context")} ${formatTokenCount(state.usage.estimatedContextTokens)}/${formatTokenCount(state.usage.contextWindow)} ${translate(state.locale ?? DEFAULT_LOCALE, "total")} ${formatTokenCount(state.usage.totalTokens)} ${translate(state.locale ?? DEFAULT_LOCALE, "tokens")}`);
192
211
  const right = paint(colors.dim, `${state.model} ${state.theme}`);
193
212
  const status = width >= 60 ? alignEnds(`${left} ${context}`, right, width) : `${left} ${right}`;
194
213
  const pasteImageShortcut = state.pasteImageShortcut ?? (process.platform === "win32" ? "Alt+V" : "Ctrl+V");
195
214
  const hints = width >= 60
196
- ? `Enter send ${pasteImageShortcut} paste image Esc cancel Ctrl+O model`
197
- : `Enter send ${pasteImageShortcut} image`;
215
+ ? `Enter ${translate(state.locale ?? DEFAULT_LOCALE, "send")} ${pasteImageShortcut} ${translate(state.locale ?? DEFAULT_LOCALE, "pasteImage")} Shift+Tab ${translate(state.locale ?? DEFAULT_LOCALE, "thinkingShortcut")} Esc ${translate(state.locale ?? DEFAULT_LOCALE, "cancel")} Ctrl+O ${translate(state.locale ?? DEFAULT_LOCALE, "model")}`
216
+ : `Enter ${translate(state.locale ?? DEFAULT_LOCALE, "send")} ${pasteImageShortcut} ${translate(state.locale ?? DEFAULT_LOCALE, "imageShortcut")}`;
198
217
  return [...renderLine(status, width), ...renderLine(paint(colors.dim, hints), width)];
199
218
  }
200
219
  }
@@ -213,11 +232,16 @@ export class AutocompleteMenu {
213
232
  invalidate() { }
214
233
  render(width) {
215
234
  const state = this.readState();
216
- return state.items.slice(0, 6).flatMap((item, index) => {
217
- const prefix = index === state.index ? "> " : " ";
218
- const description = item.description ? ` - ${item.description}` : "";
219
- return new Text(`${prefix}${item.label}${description}`).render(width);
220
- });
235
+ const maxVisible = 6;
236
+ const start = Math.min(Math.max(0, state.index - Math.floor(maxVisible / 2)), Math.max(0, state.items.length - maxVisible));
237
+ const items = state.items.slice(start, start + maxVisible);
238
+ return new SelectionPanel({
239
+ title: "Suggestions",
240
+ rows: items.map((item) => `${item.label}${item.description ? ` - ${item.description}` : ""}`),
241
+ selectedIndex: state.index - start,
242
+ position: state.index + 1,
243
+ total: state.items.length,
244
+ }).render(width);
221
245
  }
222
246
  }
223
247
  //# sourceMappingURL=interactive-components.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"interactive-components.js","sourceRoot":"","sources":["../../src/modes/interactive-components.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,IAAI,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAClF,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAkB7D,MAAM,KAAK,GAAG,SAAS,CAAC;AACxB,MAAM,IAAI,GAAG,SAAS,CAAC;AACvB,MAAM,sBAAsB,GAAG,CAAC,CAAC;AACjC,MAAM,cAAc,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,IAAI,CAAU,CAAC;AAEtD,SAAS,UAAU,CAAC,KAAoC;IACvD,OAAO,KAAK,KAAK,OAAO;QACvB,CAAC,CAAC;YACA,MAAM,EAAE,eAAe;YACvB,SAAS,EAAE,eAAe;YAC1B,GAAG,EAAE,gBAAgB;YACrB,KAAK,EAAE,gBAAgB;YACvB,OAAO,EAAE,eAAe;YACxB,OAAO,EAAE,gBAAgB;SACzB;QACF,CAAC,CAAC;YACA,MAAM,EAAE,eAAe;YACvB,SAAS,EAAE,eAAe;YAC1B,GAAG,EAAE,gBAAgB;YACrB,KAAK,EAAE,gBAAgB;YACvB,OAAO,EAAE,gBAAgB;YACzB,OAAO,EAAE,gBAAgB;SACzB,CAAC;AACL,CAAC;AAED,SAAS,KAAK,CAAC,KAAa,EAAE,IAAY,EAAE,IAAI,GAAG,KAAK;IACvD,OAAO,GAAG,KAAK,GAAG,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,GAAG,IAAI,GAAG,KAAK,EAAE,CAAC;AACrD,CAAC;AAED,SAAS,gBAAgB,CAAC,MAAe;IACxC,OAAO;QACN,OAAO,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,KAAK,CAAC,MAAM,CAAC,SAAS,EAAE,IAAI,EAAE,IAAI,CAAC;QACtD,IAAI,EAAE,CAAC,IAAI,EA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OD,MAAM,OAAO,gBAAgB;IACX,SAAS,CAA8B;IAExD,YAAY,SAAsC;QACjD,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;IAC5B,CAAC;IAED,UAAU,KAAU,CAAC;IAErB,MAAM,CAAC,KAAa;QACnB,MAAM,KAAK,GAAG,IAAI,CAAC,SAAS,EAAE,CAAC;QAC/B,OAAO,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE;YACtD,MAAM,MAAM,GAAG,KAAK,KAAK,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC;YACnD,MAAM,WAAW,GAAG,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,MAAM,IAAI,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;YACrE,OAAO,IAAI,IAAI,CAAC,GAAG,MAAM,GAAG,IAAI,CAAC,KAAK,GAAG,WAAW,EAAE,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QACvE,CAAC,CAAC,CAAC;IACJ,CAAC;CACD","sourcesContent":["import type { AutocompleteItem, Component, MarkdownTheme } from \"@di-code/tui\";\nimport { Box, Markdown, Text, truncateToWidth, visibleWidth } from \"@di-code/tui\";\nimport { highlightCode } from \"../utils/syntax-highlight.ts\";\nimport type { InteractiveState } from \"./interactive-state.ts\";\n\nexport interface InteractiveViewState extends InteractiveState {\n\treadonly model: string;\n\treadonly theme: \"dark\" | \"light\";\n\treadonly pasteImageShortcut?: string;\n}\n\ninterface Palette {\n\treadonly accent: string;\n\treadonly assistant: string;\n\treadonly dim: string;\n\treadonly error: string;\n\treadonly success: string;\n\treadonly warning: string;\n}\n\nconst RESET = \"\\x1b[0m\";\nconst BOLD = \"\\x1b[1m\";\nconst MAX_VISIBLE_TOOL_ITEMS = 6;\nconst SPINNER_FRAMES = [\"|\", \"/\", \"-\", \"\\\\\"] as const;\n\nfunction paletteFor(theme: InteractiveViewState[\"theme\"]): Palette {\n\treturn theme === \"light\"\n\t\t? {\n\t\t\t\taccent: \"\\x1b[38;5;25m\",\n\t\t\t\tassistant: \"\\x1b[38;5;30m\",\n\t\t\t\tdim: \"\\x1b[38;5;242m\",\n\t\t\t\terror: \"\\x1b[38;5;160m\",\n\t\t\t\tsuccess: \"\\x1b[38;5;28m\",\n\t\t\t\twarning: \"\\x1b[38;5;130m\",\n\t\t\t}\n\t\t: {\n\t\t\t\taccent: \"\\x1b[38;5;45m\",\n\t\t\t\tassistant: \"\\x1b[38;5;80m\",\n\t\t\t\tdim: \"\\x1b[38;5;245m\",\n\t\t\t\terror: \"\\x1b[38;5;210m\",\n\t\t\t\tsuccess: \"\\x1b[38;5;114m\",\n\t\t\t\twarning: \"\\x1b[38;5;222m\",\n\t\t\t};\n}\n\nfunction paint(color: string, text: string, bold = false): string {\n\treturn `${color}${bold ? BOLD : \"\"}${text}${RESET}`;\n}\n\nfunction markdownThemeFor(colors: Palette): MarkdownTheme {\n\treturn {\n\t\theading: (text) => paint(colors.assistant, text, true),\n\t\tlink: (text) => paint(colors.accent, text),\n\t\tlinkUrl: (text) => paint(colors.dim, text),\n\t\tcode: (text) => paint(colors.warning, text),\n\t\tcodeBlock: (text) => paint(colors.assistant, text),\n\t\tcodeBlockBorder: (text) => paint(colors.dim, text),\n\t\tquote: (text) => paint(colors.dim, text),\n\t\tquoteBorder: (text) => paint(colors.dim, text),\n\t\thr: (text) => paint(colors.dim, text),\n\t\tlistBullet: (text) => paint(colors.accent, text),\n\t\tbold: (text) => paint(colors.assistant, text, true),\n\t\titalic: (text) => `\\x1b[3m${text}${RESET}`,\n\t\tstrikethrough: (text) => `\\x1b[9m${text}${RESET}`,\n\t\tunderline: (text) => `\\x1b[4m${text}${RESET}`,\n\t\thighlightCode: (code, language) =>\n\t\t\t(language ? highlightCode(code, language) : undefined) ??\n\t\t\tcode.split(\"\\n\").map((line) => paint(colors.assistant, line)),\n\t};\n}\n\nfunction renderLine(text: string, width: number): string[] {\n\treturn new Text(truncateToWidth(text, width, \"\")).render(width);\n}\n\nfunction alignEnds(left: string, right: string, width: number): string {\n\tconst gap = 3;\n\tif (visibleWidth(left) + visibleWidth(right) + gap > width) return truncateToWidth(left, width, \"\");\n\treturn `${left}${\" \".repeat(width - visibleWidth(left) - visibleWidth(right))}${right}`;\n}\n\nfunction activityLabel(state: InteractiveViewState): { readonly text: string; readonly color: string } {\n\tconst colors = paletteFor(state.theme);\n\tif (state.error) return { text: \"ERROR\", color: colors.error };\n\tif (state.compacting) return { text: \"COMPACTING\", color: colors.warning };\n\tif (state.retrying) return { text: \"RETRYING\", color: colors.warning };\n\tif (state.busy) return { text: \"WORKING\", color: colors.accent };\n\treturn { text: \"READY\", color: colors.success };\n}\n\nexport class InteractiveHeader implements Component {\n\tprivate readonly readState: () => InteractiveViewState;\n\n\tconstructor(readState: () => InteractiveViewState) {\n\t\tthis.readState = readState;\n\t}\n\n\tinvalidate(): void {}\n\n\trender(width: number): string[] {\n\t\tconst state = this.readState();\n\t\tconst colors = paletteFor(state.theme);\n\t\tconst brand = paint(colors.accent, \"DI-CODE / INTERACTIVE\", true);\n\t\tconst model = paint(colors.dim, `MODEL ${state.model}`);\n\t\tconst title =\n\t\t\twidth >= 56\n\t\t\t\t? alignEnds(brand, model, width)\n\t\t\t\t: `${paint(colors.accent, \"DI-CODE\", true)} ${paint(colors.dim, state.model)}`;\n\t\treturn [...renderLine(title, width), ...renderLine(paint(colors.dim, \"-\".repeat(Math.max(0, width))), width)];\n\t}\n}\n\nexport class InteractiveChat implements Component {\n\tprivate readonly readState: () => InteractiveViewState;\n\n\tconstructor(readState: () => InteractiveViewState) {\n\t\tthis.readState = readState;\n\t}\n\n\tinvalidate(): void {}\n\n\trender(width: number): string[] {\n\t\tconst state = this.readState();\n\t\tconst lines: string[] = [];\n\t\tconst colors = paletteFor(state.theme);\n\t\tconst markdownTheme = markdownThemeFor(colors);\n\t\tfor (const [index, message] of state.messageItems.entries()) {\n\t\t\tif (index > 0) lines.push(\" \");\n\t\t\tif (message.role === \"file_change\") {\n\t\t\t\tlines.push(\n\t\t\t\t\t...renderLine(\n\t\t\t\t\t\tpaint(colors.dim, `${message.kind === \"edit\" ? \"Edited\" : \"Wrote\"} ${message.path}`, true),\n\t\t\t\t\t\twidth,\n\t\t\t\t\t),\n\t\t\t\t);\n\t\t\t\tfor (const line of message.removed) lines.push(...renderLine(paint(colors.error, `- ${line}`), width));\n\t\t\t\tfor (const line of message.added) lines.push(...renderLine(paint(colors.success, `+ ${line}`), width));\n\t\t\t} else if (message.role === \"user\") {\n\t\t\t\tlines.push(\n\t\t\t\t\t...new Box(new Text(message.text, 0, 0), { border: \"single\", padding: 1, title: \"You\" }).render(width),\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\tlines.push(...renderLine(paint(colors.assistant, \"Assistant\", true), width));\n\t\t\t\tlines.push(...new Markdown(message.text, { paddingX: 2, theme: markdownTheme }).render(width));\n\t\t\t}\n\t\t}\n\t\tconst toolCount = state.processItems.filter((item) => item.type === \"tool\").length;\n\t\tconst hiddenToolItems = Math.max(0, toolCount - MAX_VISIBLE_TOOL_ITEMS);\n\t\tlet skippedToolItems = 0;\n\t\tfor (const item of state.processItems) {\n\t\t\tif (item.type === \"tool\" && skippedToolItems < hiddenToolItems) {\n\t\t\t\tskippedToolItems += 1;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (item.type === \"tool\" && skippedToolItems === hiddenToolItems && hiddenToolItems > 0) {\n\t\t\t\tlines.push(...renderLine(` ${paint(colors.dim, `${hiddenToolItems} earlier tool updates`)}`, width));\n\t\t\t\tskippedToolItems += 1;\n\t\t\t}\n\t\t\tif (item.type === \"thinking\") {\n\t\t\t\tconst frame = SPINNER_FRAMES[state.spinnerFrame % SPINNER_FRAMES.length] ?? SPINNER_FRAMES[0];\n\t\t\t\tlines.push(...renderLine(` ${paint(colors.accent, `${frame} Thinking`)}`, width));\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tconst marker = item.status === \"running\" ? \">\" : item.status === \"error\" ? \"!\" : \"+\";\n\t\t\tconst command = truncateToWidth(item.command, Math.max(1, width - 6), \"...\");\n\t\t\tconst color = item.status === \"error\" ? colors.error : item.status === \"done\" ? colors.success : colors.warning;\n\t\t\tlines.push(...renderLine(` ${paint(color, marker)} ${paint(colors.dim, command)}`, width));\n\t\t}\n\t\tif (state.busy && !state.processItems.some((item) => item.type === \"thinking\")) {\n\t\t\tconst frame = SPINNER_FRAMES[state.spinnerFrame % SPINNER_FRAMES.length] ?? SPINNER_FRAMES[0];\n\t\t\tlines.push(...renderLine(` ${paint(colors.accent, `${frame} Thinking`)}`, width));\n\t\t}\n\t\tif (state.streamingText) {\n\t\t\tif (lines.length > 0) lines.push(\" \");\n\t\t\tlines.push(...renderLine(paint(colors.assistant, \"Assistant\", true), width));\n\t\t\tlines.push(...new Markdown(state.streamingText, { paddingX: 2, theme: markdownTheme }).render(width));\n\t\t}\n\t\tconst hasActivity = state.status || state.queue.length > 0 || state.error;\n\t\tif (hasActivity) {\n\t\t\tif (lines.length > 0) lines.push(\" \");\n\t\t\tlines.push(...renderLine(paint(colors.dim, \"Activity\", true), width));\n\t\t\tif (state.status) lines.push(...renderLine(` ${paint(colors.dim, state.status)}`, width));\n\t\t\tif (state.queue.length > 0) {\n\t\t\t\tlines.push(...renderLine(` ${paint(colors.dim, `Queue (${state.queue.length})`)}`, width));\n\t\t\t\tfor (const prompt of state.queue) lines.push(...new Text(` ${prompt}`).render(width));\n\t\t\t}\n\t\t\tif (state.error)\n\t\t\t\tlines.push(...new Text(` ${paint(colors.error, `Error: ${state.error}`, true)}`).render(width));\n\t\t}\n\t\tconst rendered = lines.flatMap((line) => new Text(line).render(width));\n\t\treturn rendered.length > 0 ? rendered : [\"\"];\n\t}\n}\n\nexport class InteractiveComposer implements Component {\n\tprivate readonly readState: () => InteractiveViewState;\n\n\tconstructor(readState: () => InteractiveViewState) {\n\t\tthis.readState = readState;\n\t}\n\n\tinvalidate(): void {}\n\n\trender(width: number): string[] {\n\t\tconst state = this.readState();\n\t\tconst colors = paletteFor(state.theme);\n\t\tconst copy = width >= 56 ? \"/ commands Tab complete\" : \"/ commands\";\n\t\treturn renderLine(paint(colors.dim, copy), width);\n\t}\n}\n\nexport class InteractiveFooter implements Component {\n\tprivate readonly readState: () => InteractiveViewState;\n\n\tconstructor(readState: () => InteractiveViewState) {\n\t\tthis.readState = readState;\n\t}\n\n\tinvalidate(): void {}\n\n\trender(width: number): string[] {\n\t\tconst state = this.readState();\n\t\tconst colors = paletteFor(state.theme);\n\t\tconst activity = activityLabel(state);\n\t\tconst left = paint(activity.color, `* ${activity.text}`, true);\n\t\tconst context = paint(\n\t\t\tcolors.dim,\n\t\t\t`${state.messageItems.length} messages ctx ${formatTokenCount(state.usage.estimatedContextTokens)}/${formatTokenCount(state.usage.contextWindow)} total ${formatTokenCount(state.usage.totalTokens)} tok`,\n\t\t);\n\t\tconst right = paint(colors.dim, `${state.model} ${state.theme}`);\n\t\tconst status = width >= 60 ? alignEnds(`${left} ${context}`, right, width) : `${left} ${right}`;\n\t\tconst pasteImageShortcut = state.pasteImageShortcut ?? (process.platform === \"win32\" ? \"Alt+V\" : \"Ctrl+V\");\n\t\tconst hints =\n\t\t\twidth >= 60\n\t\t\t\t? `Enter send ${pasteImageShortcut} paste image Esc cancel Ctrl+O model`\n\t\t\t\t: `Enter send ${pasteImageShortcut} image`;\n\t\treturn [...renderLine(status, width), ...renderLine(paint(colors.dim, hints), width)];\n\t}\n}\n\nfunction formatTokenCount(value: number): string {\n\tif (value >= 1_000_000) return `${(value / 1_000_000).toFixed(1)}m`;\n\tif (value >= 1_000) return `${(value / 1_000).toFixed(1)}k`;\n\treturn String(value);\n}\n\nexport interface AutocompleteMenuState {\n\treadonly items: readonly AutocompleteItem[];\n\treadonly index: number;\n}\n\nexport class AutocompleteMenu implements Component {\n\tprivate readonly readState: () => AutocompleteMenuState;\n\n\tconstructor(readState: () => AutocompleteMenuState) {\n\t\tthis.readState = readState;\n\t}\n\n\tinvalidate(): void {}\n\n\trender(width: number): string[] {\n\t\tconst state = this.readState();\n\t\treturn state.items.slice(0, 6).flatMap((item, index) => {\n\t\t\tconst prefix = index === state.index ? \"> \" : \" \";\n\t\t\tconst description = item.description ? ` - ${item.description}` : \"\";\n\t\t\treturn new Text(`${prefix}${item.label}${description}`).render(width);\n\t\t});\n\t}\n}\n"]}
1
+ {"version":3,"file":"interactive-components.js","sourceRoot":"","sources":["../../src/modes/interactive-components.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,cAAc,EAAE,IAAI,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC7F,OAAO,EAAE,cAAc,EAAe,SAAS,EAAE,MAAM,YAAY,CAAC;AACpE,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAC7D,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAoBnD,MAAM,KAAK,GAAG,SAAS,CAAC;AACxB,MAAM,IAAI,GAAG,SAAS,CAAC;AACvB,MAAM,sBAAsB,GAAG,CAAC,CAAC;AACjC,MAAM,cAAc,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,IAAI,CAAU,CAAC;AAEtD,SAAS,UAAU,CAAC,KAAoC;IACvD,OAAO,KAAK,KAAK,OAAO;QACvB,CAAC,CAAC;YACA,MAAM,EAAE,eAAe;YACvB,SAAS,EAAE,eAAe;YAC1B,GAAG,EAAE,gBAAgB;YACrB,KAAK,EAAE,gBAAgB;YACvB,OAAO,EAAE,eAAe;YACxB,cAAc,EAAE,wBAAwB;YACxC,OAAO,EAAE,gBAAgB;SACzB;QACF,CAAC,CAAC;YACA,MAAM,EAAE,eAAe;YACvB,SAAS,EAAE,eAAe;YAC1B,GAAG,EAAE,gBAAgB;YACrB,KAAK,EAAE,gBAAgB;YACvB,OAAO,EAAE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from \"@di-code/tui\";\nimport { Markdown, SelectionPanel, Text, truncateToWidth, visibleWidth } from \"@di-code/tui\";\nimport { DEFAULT_LOCALE, type Locale, translate } from \"../i18n.ts\";\nimport { highlightCode } from \"../utils/syntax-highlight.ts\";\nimport { renderDiff } from \"./interactive-diff.ts\";\nimport type { InteractiveState } from \"./interactive-state.ts\";\n\nexport interface InteractiveViewState extends InteractiveState {\n\treadonly model: string;\n\treadonly theme: \"dark\" | \"light\";\n\treadonly locale?: Locale;\n\treadonly pasteImageShortcut?: string;\n}\n\ninterface Palette {\n\treadonly accent: string;\n\treadonly assistant: string;\n\treadonly dim: string;\n\treadonly error: string;\n\treadonly success: string;\n\treadonly userBackground: string;\n\treadonly warning: string;\n}\n\nconst RESET = \"\\x1b[0m\";\nconst BOLD = \"\\x1b[1m\";\nconst MAX_VISIBLE_TOOL_ITEMS = 6;\nconst SPINNER_FRAMES = [\"|\", \"/\", \"-\", \"\\\\\"] as const;\n\nfunction paletteFor(theme: InteractiveViewState[\"theme\"]): Palette {\n\treturn theme === \"light\"\n\t\t? {\n\t\t\t\taccent: \"\\x1b[38;5;25m\",\n\t\t\t\tassistant: \"\\x1b[38;5;30m\",\n\t\t\t\tdim: \"\\x1b[38;5;242m\",\n\t\t\t\terror: \"\\x1b[38;5;160m\",\n\t\t\t\tsuccess: \"\\x1b[38;5;28m\",\n\t\t\t\tuserBackground: \"\\x1b[48;2;239;246;255m\",\n\t\t\t\twarning: \"\\x1b[38;5;130m\",\n\t\t\t}\n\t\t: {\n\t\t\t\taccent: \"\\x1b[38;5;45m\",\n\t\t\t\tassistant: \"\\x1b[38;5;80m\",\n\t\t\t\tdim: \"\\x1b[38;5;245m\",\n\t\t\t\terror: \"\\x1b[38;5;210m\",\n\t\t\t\tsuccess: \"\\x1b[38;5;114m\",\n\t\t\t\tuserBackground: \"\\x1b[48;2;31;39;50m\",\n\t\t\t\twarning: \"\\x1b[38;5;222m\",\n\t\t\t};\n}\n\nfunction paint(color: string, text: string, bold = false): string {\n\treturn `${color}${bold ? BOLD : \"\"}${text}${RESET}`;\n}\n\nfunction paintBackground(background: string, text: string): string {\n\treturn `${background}${text}${RESET}`;\n}\n\nfunction markdownThemeFor(colors: Palette): MarkdownTheme {\n\treturn {\n\t\theading: (text) => paint(colors.assistant, text, true),\n\t\tlink: (text) => paint(colors.accent, text),\n\t\tlinkUrl: (text) => paint(colors.dim, text),\n\t\tcode: (text) => paint(colors.warning, text),\n\t\tcodeBlock: (text) => paint(colors.assistant, text),\n\t\tcodeBlockBorder: (text) => paint(colors.dim, text),\n\t\tquote: (text) => paint(colors.dim, text),\n\t\tquoteBorder: (text) => paint(colors.dim, text),\n\t\thr: (text) => paint(colors.dim, text),\n\t\tlistBullet: (text) => paint(colors.accent, text),\n\t\tbold: (text) => paint(colors.assistant, text, true),\n\t\titalic: (text) => `\\x1b[3m${text}${RESET}`,\n\t\tstrikethrough: (text) => `\\x1b[9m${text}${RESET}`,\n\t\tunderline: (text) => `\\x1b[4m${text}${RESET}`,\n\t\thighlightCode: (code, language) =>\n\t\t\t(language ? highlightCode(code, language) : undefined) ??\n\t\t\tcode.split(\"\\n\").map((line) => paint(colors.assistant, line)),\n\t};\n}\n\nfunction renderLine(text: string, width: number): string[] {\n\treturn new Text(truncateToWidth(text, width, \"\")).render(width);\n}\n\nfunction alignEnds(left: string, right: string, width: number): string {\n\tconst gap = 3;\n\tif (visibleWidth(left) + visibleWidth(right) + gap > width) return truncateToWidth(left, width, \"\");\n\treturn `${left}${\" \".repeat(width - visibleWidth(left) - visibleWidth(right))}${right}`;\n}\n\nfunction activityLabel(state: InteractiveViewState): { readonly text: string; readonly color: string } {\n\tconst colors = paletteFor(state.theme);\n\tif (state.error) return { text: translate(state.locale ?? DEFAULT_LOCALE, \"error\"), color: colors.error };\n\tif (state.compacting) return { text: translate(state.locale ?? DEFAULT_LOCALE, \"compacting\"), color: colors.warning };\n\tif (state.retrying) return { text: translate(state.locale ?? DEFAULT_LOCALE, \"retrying\"), color: colors.warning };\n\tif (state.busy) return { text: translate(state.locale ?? DEFAULT_LOCALE, \"working\"), color: colors.accent };\n\treturn { text: translate(state.locale ?? DEFAULT_LOCALE, \"ready\"), color: colors.success };\n}\n\nexport class InteractiveHeader implements Component {\n\tprivate readonly readState: () => InteractiveViewState;\n\n\tconstructor(readState: () => InteractiveViewState) {\n\t\tthis.readState = readState;\n\t}\n\n\tinvalidate(): void {}\n\n\trender(width: number): string[] {\n\t\tconst state = this.readState();\n\t\tconst colors = paletteFor(state.theme);\n\t\tconst brand = paint(colors.accent, \"DI-CODE / INTERACTIVE\", true);\n\t\tconst model = paint(colors.dim, `MODEL ${state.model}`);\n\t\tconst title =\n\t\t\twidth >= 56\n\t\t\t\t? alignEnds(brand, model, width)\n\t\t\t\t: `${paint(colors.accent, \"DI-CODE\", true)} ${paint(colors.dim, state.model)}`;\n\t\treturn [...renderLine(title, width), ...renderLine(paint(colors.dim, \"-\".repeat(Math.max(0, width))), width)];\n\t}\n}\n\nexport class InteractiveChat implements Component {\n\tprivate readonly readState: () => InteractiveViewState;\n\n\tconstructor(readState: () => InteractiveViewState) {\n\t\tthis.readState = readState;\n\t}\n\n\tinvalidate(): void {}\n\n\trender(width: number): string[] {\n\t\tconst state = this.readState();\n\t\tconst lines: string[] = [];\n\t\tconst colors = paletteFor(state.theme);\n\t\tconst markdownTheme = markdownThemeFor(colors);\n\t\tfor (const [index, message] of state.messageItems.entries()) {\n\t\t\tif (index > 0) lines.push(\" \");\n\t\t\tif (message.role === \"file_change\") {\n\t\t\t\tlines.push(\n\t\t\t\t\t...renderLine(\n\t\t\t\t\t\tpaint(\n\t\t\t\t\t\t\tcolors.dim,\n\t\t\t\t\t\t\t`${translate(state.locale ?? DEFAULT_LOCALE, message.kind === \"edit\" ? \"edited\" : \"wrote\")} ${message.path}`,\n\t\t\t\t\t\t\ttrue,\n\t\t\t\t\t\t),\n\t\t\t\t\t\twidth,\n\t\t\t\t\t),\n\t\t\t\t);\n\t\t\t\tif (message.diff) {\n\t\t\t\t\tfor (const line of renderDiff(message.diff, colors)) lines.push(...renderLine(line, width));\n\t\t\t\t} else {\n\t\t\t\t\tfor (const line of message.removed) lines.push(...renderLine(paint(colors.error, `- ${line}`), width));\n\t\t\t\t\tfor (const line of message.added) lines.push(...renderLine(paint(colors.success, `+ ${line}`), width));\n\t\t\t\t}\n\t\t\t} else if (message.role === \"user\") {\n\t\t\t\tlines.push(\n\t\t\t\t\t...new Text(message.text, 2, 1).render(width).map((line) => paintBackground(colors.userBackground, line)),\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\tlines.push(...new Markdown(message.text, { paddingX: 2, theme: markdownTheme }).render(width));\n\t\t\t}\n\t\t}\n\t\tconst hasProcess = state.processItems.length > 0 || (state.busy && !state.streamingText);\n\t\tif (hasProcess && lines.length > 0) lines.push(\" \");\n\t\tconst toolCount = state.processItems.filter((item) => item.type === \"tool\").length;\n\t\tconst hiddenToolItems = Math.max(0, toolCount - MAX_VISIBLE_TOOL_ITEMS);\n\t\tlet skippedToolItems = 0;\n\t\tfor (const item of state.processItems) {\n\t\t\tif (item.type === \"tool\" && skippedToolItems < hiddenToolItems) {\n\t\t\t\tskippedToolItems += 1;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (item.type === \"tool\" && skippedToolItems === hiddenToolItems && hiddenToolItems > 0) {\n\t\t\t\tlines.push(\n\t\t\t\t\t...renderLine(\n\t\t\t\t\t\t` ${paint(colors.dim, translate(state.locale ?? DEFAULT_LOCALE, \"earlierToolUpdates\", String(hiddenToolItems)))}`,\n\t\t\t\t\t\twidth,\n\t\t\t\t\t),\n\t\t\t\t);\n\t\t\t\tskippedToolItems += 1;\n\t\t\t}\n\t\t\tif (item.type === \"thinking\") {\n\t\t\t\tconst frame = SPINNER_FRAMES[state.spinnerFrame % SPINNER_FRAMES.length] ?? SPINNER_FRAMES[0];\n\t\t\t\tlines.push(\n\t\t\t\t\t...renderLine(\n\t\t\t\t\t\t` ${paint(colors.accent, `${frame} ${translate(state.locale ?? DEFAULT_LOCALE, \"thinking\")}`)}`,\n\t\t\t\t\t\twidth,\n\t\t\t\t\t),\n\t\t\t\t);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tconst marker = item.status === \"running\" ? \">\" : item.status === \"error\" ? \"!\" : \"+\";\n\t\t\tconst command = truncateToWidth(item.command, Math.max(1, width - 6), \"...\");\n\t\t\tconst color = item.status === \"error\" ? colors.error : item.status === \"done\" ? colors.success : colors.warning;\n\t\t\tlines.push(...renderLine(` ${paint(color, marker)} ${paint(colors.dim, command)}`, width));\n\t\t}\n\t\tif (state.busy && !state.streamingText && !state.processItems.some((item) => item.type === \"thinking\")) {\n\t\t\tconst frame = SPINNER_FRAMES[state.spinnerFrame % SPINNER_FRAMES.length] ?? SPINNER_FRAMES[0];\n\t\t\tlines.push(\n\t\t\t\t...renderLine(\n\t\t\t\t\t` ${paint(colors.accent, `${frame} ${translate(state.locale ?? DEFAULT_LOCALE, \"thinking\")}`)}`,\n\t\t\t\t\twidth,\n\t\t\t\t),\n\t\t\t);\n\t\t}\n\t\tif (hasProcess) lines.push(\" \");\n\t\tif (state.streamingText) {\n\t\t\tif (lines.length > 0 && lines.at(-1) !== \" \") lines.push(\" \");\n\t\t\tlines.push(...new Markdown(state.streamingText, { paddingX: 2, theme: markdownTheme }).render(width));\n\t\t}\n\t\tconst hasActivity = state.status || state.queue.length > 0 || state.error;\n\t\tif (hasActivity) {\n\t\t\tif (lines.length > 0) lines.push(\" \");\n\t\t\tlines.push(...renderLine(paint(colors.dim, translate(state.locale ?? DEFAULT_LOCALE, \"activity\"), true), width));\n\t\t\tif (state.status) lines.push(...renderLine(` ${paint(colors.dim, state.status)}`, width));\n\t\t\tif (state.queue.length > 0) {\n\t\t\t\tlines.push(\n\t\t\t\t\t...renderLine(\n\t\t\t\t\t\t` ${paint(colors.dim, translate(state.locale ?? DEFAULT_LOCALE, \"queue\", String(state.queue.length)))}`,\n\t\t\t\t\t\twidth,\n\t\t\t\t\t),\n\t\t\t\t);\n\t\t\t\tfor (const prompt of state.queue) lines.push(...new Text(` ${prompt}`).render(width));\n\t\t\t}\n\t\t\tif (state.error)\n\t\t\t\tlines.push(\n\t\t\t\t\t...new Text(\n\t\t\t\t\t\t` ${paint(colors.error, `${translate(state.locale ?? DEFAULT_LOCALE, \"errorPrefix\")}: ${state.error}`, true)}`,\n\t\t\t\t\t).render(width),\n\t\t\t\t);\n\t\t}\n\t\tconst rendered = lines.flatMap((line) => new Text(line).render(width));\n\t\treturn rendered.length > 0 ? rendered : [\"\"];\n\t}\n}\n\nexport class InteractiveComposer implements Component {\n\tprivate readonly readState: () => InteractiveViewState;\n\n\tconstructor(readState: () => InteractiveViewState) {\n\t\tthis.readState = readState;\n\t}\n\n\tinvalidate(): void {}\n\n\trender(width: number): string[] {\n\t\tconst state = this.readState();\n\t\tconst colors = paletteFor(state.theme);\n\t\tconst locale = state.locale ?? DEFAULT_LOCALE;\n\t\tconst copy =\n\t\t\twidth >= 56\n\t\t\t\t? `/ ${translate(locale, \"commands\")} Tab ${translate(locale, \"complete\")}`\n\t\t\t\t: `/ ${translate(locale, \"commands\")}`;\n\t\treturn renderLine(paint(colors.dim, copy), width);\n\t}\n}\n\nexport class InteractiveFooter implements Component {\n\tprivate readonly readState: () => InteractiveViewState;\n\n\tconstructor(readState: () => InteractiveViewState) {\n\t\tthis.readState = readState;\n\t}\n\n\tinvalidate(): void {}\n\n\trender(width: number): string[] {\n\t\tconst state = this.readState();\n\t\tconst colors = paletteFor(state.theme);\n\t\tconst activity = activityLabel(state);\n\t\tconst left = paint(activity.color, `* ${activity.text}`, true);\n\t\tconst context = paint(\n\t\t\tcolors.dim,\n\t\t\t`${translate(state.locale ?? DEFAULT_LOCALE, \"messages\", String(state.messageItems.length))} ${translate(state.locale ?? DEFAULT_LOCALE, \"context\")} ${formatTokenCount(state.usage.estimatedContextTokens)}/${formatTokenCount(state.usage.contextWindow)} ${translate(state.locale ?? DEFAULT_LOCALE, \"total\")} ${formatTokenCount(state.usage.totalTokens)} ${translate(state.locale ?? DEFAULT_LOCALE, \"tokens\")}`,\n\t\t);\n\t\tconst right = paint(colors.dim, `${state.model} ${state.theme}`);\n\t\tconst status = width >= 60 ? alignEnds(`${left} ${context}`, right, width) : `${left} ${right}`;\n\t\tconst pasteImageShortcut = state.pasteImageShortcut ?? (process.platform === \"win32\" ? \"Alt+V\" : \"Ctrl+V\");\n\t\tconst hints =\n\t\t\twidth >= 60\n\t\t\t\t? `Enter ${translate(state.locale ?? DEFAULT_LOCALE, \"send\")} ${pasteImageShortcut} ${translate(state.locale ?? DEFAULT_LOCALE, \"pasteImage\")} Shift+Tab ${translate(state.locale ?? DEFAULT_LOCALE, \"thinkingShortcut\")} Esc ${translate(state.locale ?? DEFAULT_LOCALE, \"cancel\")} Ctrl+O ${translate(state.locale ?? DEFAULT_LOCALE, \"model\")}`\n\t\t\t\t: `Enter ${translate(state.locale ?? DEFAULT_LOCALE, \"send\")} ${pasteImageShortcut} ${translate(state.locale ?? DEFAULT_LOCALE, \"imageShortcut\")}`;\n\t\treturn [...renderLine(status, width), ...renderLine(paint(colors.dim, hints), width)];\n\t}\n}\n\nfunction formatTokenCount(value: number): string {\n\tif (value >= 1_000_000) return `${(value / 1_000_000).toFixed(1)}m`;\n\tif (value >= 1_000) return `${(value / 1_000).toFixed(1)}k`;\n\treturn String(value);\n}\n\nexport interface AutocompleteMenuState {\n\treadonly items: readonly AutocompleteItem[];\n\treadonly index: number;\n}\n\nexport class AutocompleteMenu implements Component {\n\tprivate readonly readState: () => AutocompleteMenuState;\n\n\tconstructor(readState: () => AutocompleteMenuState) {\n\t\tthis.readState = readState;\n\t}\n\n\tinvalidate(): void {}\n\n\trender(width: number): string[] {\n\t\tconst state = this.readState();\n\t\tconst maxVisible = 6;\n\t\tconst start = Math.min(\n\t\t\tMath.max(0, state.index - Math.floor(maxVisible / 2)),\n\t\t\tMath.max(0, state.items.length - maxVisible),\n\t\t);\n\t\tconst items = state.items.slice(start, start + maxVisible);\n\t\treturn new SelectionPanel({\n\t\t\ttitle: \"Suggestions\",\n\t\t\trows: items.map((item) => `${item.label}${item.description ? ` - ${item.description}` : \"\"}`),\n\t\t\tselectedIndex: state.index - start,\n\t\t\tposition: state.index + 1,\n\t\t\ttotal: state.items.length,\n\t\t}).render(width);\n\t}\n}\n"]}
@@ -0,0 +1,8 @@
1
+ export interface DiffColors {
2
+ readonly dim: string;
3
+ readonly error: string;
4
+ readonly success: string;
5
+ }
6
+ /** 将 edit-diff 的行号格式转换成 Pi 风格的 ANSI 着色行。 */
7
+ export declare function renderDiff(diffText: string, colors: DiffColors): string[];
8
+ //# sourceMappingURL=interactive-diff.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"interactive-diff.d.ts","sourceRoot":"","sources":["../../src/modes/interactive-diff.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,UAAU;IAC1B,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;CACzB;AAiCD,4CAA4C;AAC5C,wBAAgB,UAAU,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,GAAG,MAAM,EAAE,CA0CzE"}
@@ -0,0 +1,78 @@
1
+ import * as Diff from "diff";
2
+ const RESET = "\x1b[0m";
3
+ const INVERSE = "\x1b[7m";
4
+ function paint(color, text, inverse = false) {
5
+ return `${color}${inverse ? INVERSE : ""}${text}${RESET}`;
6
+ }
7
+ function parseLine(line) {
8
+ const match = line.match(/^([+-\s])(\s*\d*)\s(.*)$/);
9
+ return match ? { prefix: match[1], lineNumber: match[2], content: match[3] } : undefined;
10
+ }
11
+ function renderWordChange(oldContent, newContent) {
12
+ const parts = Diff.diffWords(oldContent, newContent);
13
+ let oldLine = "";
14
+ let newLine = "";
15
+ for (const part of parts) {
16
+ if (part.removed)
17
+ oldLine += paint("", part.value, true);
18
+ else if (part.added)
19
+ newLine += paint("", part.value, true);
20
+ else {
21
+ oldLine += part.value;
22
+ newLine += part.value;
23
+ }
24
+ }
25
+ return { oldLine, newLine };
26
+ }
27
+ function replaceTabs(text) {
28
+ return text.replaceAll("\t", " ");
29
+ }
30
+ /** 将 edit-diff 的行号格式转换成 Pi 风格的 ANSI 着色行。 */
31
+ export function renderDiff(diffText, colors) {
32
+ const source = diffText.split("\n");
33
+ const result = [];
34
+ let index = 0;
35
+ while (index < source.length) {
36
+ const current = parseLine(source[index]);
37
+ if (!current) {
38
+ result.push(paint(colors.dim, source[index]));
39
+ index += 1;
40
+ continue;
41
+ }
42
+ if (current.prefix !== "-") {
43
+ const color = current.prefix === "+" ? colors.success : colors.dim;
44
+ result.push(paint(color, `${current.prefix}${current.lineNumber} ${replaceTabs(current.content)}`));
45
+ index += 1;
46
+ continue;
47
+ }
48
+ const removed = [];
49
+ while (index < source.length) {
50
+ const line = parseLine(source[index]);
51
+ if (!line || line.prefix !== "-")
52
+ break;
53
+ removed.push({ lineNumber: line.lineNumber, content: line.content });
54
+ index += 1;
55
+ }
56
+ const added = [];
57
+ while (index < source.length) {
58
+ const line = parseLine(source[index]);
59
+ if (!line || line.prefix !== "+")
60
+ break;
61
+ added.push({ lineNumber: line.lineNumber, content: line.content });
62
+ index += 1;
63
+ }
64
+ if (removed.length === 1 && added.length === 1) {
65
+ const changed = renderWordChange(replaceTabs(removed[0].content), replaceTabs(added[0].content));
66
+ result.push(paint(colors.error, `-${removed[0].lineNumber} ${changed.oldLine}`));
67
+ result.push(paint(colors.success, `+${added[0].lineNumber} ${changed.newLine}`));
68
+ }
69
+ else {
70
+ for (const line of removed)
71
+ result.push(paint(colors.error, `-${line.lineNumber} ${replaceTabs(line.content)}`));
72
+ for (const line of added)
73
+ result.push(paint(colors.success, `+${line.lineNumber} ${replaceTabs(line.content)}`));
74
+ }
75
+ }
76
+ return result;
77
+ }
78
+ //# sourceMappingURL=interactive-diff.js.map
@@ -0,0 +1 @@
1
+ {"version":3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C,CAAC,UAAU,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC;QAClF,CAAC;aAAM,CAAC;YACP,KAAK,MAAM,IAAI,IAAI,OAAO;gBAAE,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,EAAE,IAAI,IAAI,CAAC,UAAU,IAAI,WAAW,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,CAAC;YACjH,KAAK,MAAM,IAAI,IAAI,KAAK;gBAAE,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,OAAO,EAAE,IAAI,IAAI,CAAC,UAAU,IAAI,WAAW,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,CAAC;QAClH,CAAC;IACF,CAAC;IACD,OAAO,MAAM,CAAC;AACf,CAAC","sourcesContent":["import * as Diff from \"diff\";\n\nexport interface DiffColors {\n\treadonly dim: string;\n\treadonly error: string;\n\treadonly success: string;\n}\n\nconst RESET = \"\\x1b[0m\";\nconst INVERSE = \"\\x1b[7m\";\n\nfunction paint(color: string, text: string, inverse = false): string {\n\treturn `${color}${inverse ? INVERSE : \"\"}${text}${RESET}`;\n}\n\nfunction parseLine(line: string): { prefix: string; lineNumber: string; content: string } | undefined {\n\tconst match = line.match(/^([+-\\s])(\\s*\\d*)\\s(.*)$/);\n\treturn match ? { prefix: match[1], lineNumber: match[2], content: match[3] } : undefined;\n}\n\nfunction renderWordChange(oldContent: string, newContent: string): { oldLine: string; newLine: string } {\n\tconst parts = Diff.diffWords(oldContent, newContent);\n\tlet oldLine = \"\";\n\tlet newLine = \"\";\n\tfor (const part of parts) {\n\t\tif (part.removed) oldLine += paint(\"\", part.value, true);\n\t\telse if (part.added) newLine += paint(\"\", part.value, true);\n\t\telse {\n\t\t\toldLine += part.value;\n\t\t\tnewLine += part.value;\n\t\t}\n\t}\n\treturn { oldLine, newLine };\n}\n\nfunction replaceTabs(text: string): string {\n\treturn text.replaceAll(\"\\t\", \" \");\n}\n\n/** 将 edit-diff 的行号格式转换成 Pi 风格的 ANSI 着色行。 */\nexport function renderDiff(diffText: string, colors: DiffColors): string[] {\n\tconst source = diffText.split(\"\\n\");\n\tconst result: string[] = [];\n\tlet index = 0;\n\twhile (index < source.length) {\n\t\tconst current = parseLine(source[index]);\n\t\tif (!current) {\n\t\t\tresult.push(paint(colors.dim, source[index]));\n\t\t\tindex += 1;\n\t\t\tcontinue;\n\t\t}\n\t\tif (current.prefix !== \"-\") {\n\t\t\tconst color = current.prefix === \"+\" ? colors.success : colors.dim;\n\t\t\tresult.push(paint(color, `${current.prefix}${current.lineNumber} ${replaceTabs(current.content)}`));\n\t\t\tindex += 1;\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst removed: Array<{ lineNumber: string; content: string }> = [];\n\t\twhile (index < source.length) {\n\t\t\tconst line = parseLine(source[index]);\n\t\t\tif (!line || line.prefix !== \"-\") break;\n\t\t\tremoved.push({ lineNumber: line.lineNumber, content: line.content });\n\t\t\tindex += 1;\n\t\t}\n\t\tconst added: Array<{ lineNumber: string; content: string }> = [];\n\t\twhile (index < source.length) {\n\t\t\tconst line = parseLine(source[index]);\n\t\t\tif (!line || line.prefix !== \"+\") break;\n\t\t\tadded.push({ lineNumber: line.lineNumber, content: line.content });\n\t\t\tindex += 1;\n\t\t}\n\t\tif (removed.length === 1 && added.length === 1) {\n\t\t\tconst changed = renderWordChange(replaceTabs(removed[0].content), replaceTabs(added[0].content));\n\t\t\tresult.push(paint(colors.error, `-${removed[0].lineNumber} ${changed.oldLine}`));\n\t\t\tresult.push(paint(colors.success, `+${added[0].lineNumber} ${changed.newLine}`));\n\t\t} else {\n\t\t\tfor (const line of removed) result.push(paint(colors.error, `-${line.lineNumber} ${replaceTabs(line.content)}`));\n\t\t\tfor (const line of added) result.push(paint(colors.success, `+${line.lineNumber} ${replaceTabs(line.content)}`));\n\t\t}\n\t}\n\treturn result;\n}\n"]}
@@ -15,6 +15,10 @@ export declare class InteractiveLayout implements Component {
15
15
  constructor(options: InteractiveLayoutOptions);
16
16
  invalidate(): void;
17
17
  renderTranscript(width: number): string[];
18
+ getEditorBounds(width: number): {
19
+ readonly start: number;
20
+ readonly end: number;
21
+ };
18
22
  render(width: number): string[];
19
23
  private renderEditor;
20
24
  }
@@ -1 +1 @@
1
- {"version":3,"file":"interactive-layout.d.ts","sourceRoot":"","sources":["../../src/modes/interactive-layout.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,SAAS,EAAiC,MAAM,cAAc,CAAC;AAE7E,MAAM,WAAW,wBAAwB;IACxC,QAAQ,CAAC,MAAM,EAAE,SAAS,CAAC;IAC3B,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC;IACzB,QAAQ,CAAC,QAAQ,EAAE,SAAS,CAAC;IAC7B,QAAQ,CAAC,MAAM,EAAE,SAAS,CAAC;IAC3B,QAAQ,CAAC,MAAM,EAAE,SAAS,CAAC;CAC3B;AAED,qBAAa,iBAAkB,YAAW,SAAS;IAClD,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAY;IACnC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAY;IACjC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAY;IACrC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAY;IACnC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAY;gBACvB,OAAO,EAAE,wBAAwB;IAQ7C,UAAU,IAAI,IAAI;IAQlB,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE;IAIzC,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE;IAU/B,OAAO,CAAC,YAAY;CAapB"}
1
+ {"version":3,"file":"interactive-layout.d.ts","sourceRoot":"","sources":["../../src/modes/interactive-layout.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,SAAS,EAAiC,MAAM,cAAc,CAAC;AAE7E,MAAM,WAAW,wBAAwB;IACxC,QAAQ,CAAC,MAAM,EAAE,SAAS,CAAC;IAC3B,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC;IACzB,QAAQ,CAAC,QAAQ,EAAE,SAAS,CAAC;IAC7B,QAAQ,CAAC,MAAM,EAAE,SAAS,CAAC;IAC3B,QAAQ,CAAC,MAAM,EAAE,SAAS,CAAC;CAC3B;AAED,qBAAa,iBAAkB,YAAW,SAAS;IAClD,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAY;IACnC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAY;IACjC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAY;IACrC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAY;IACnC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAY;gBACvB,OAAO,EAAE,wBAAwB;IAQ7C,UAAU,IAAI,IAAI;IAQlB,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE;IAIzC,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG;QAAE,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAA;KAAE;IAMhF,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE;IAU/B,OAAO,CAAC,YAAY;CAapB"}
@@ -22,6 +22,10 @@ export class InteractiveLayout {
22
22
  renderTranscript(width) {
23
23
  return [...this.header.render(width), ...this.chat.render(width), ...this.footer.render(width)];
24
24
  }
25
+ getEditorBounds(width) {
26
+ const start = this.header.render(width).length + this.chat.render(width).length + this.composer.render(width).length;
27
+ return { start, end: start + this.renderEditor(width).length };
28
+ }
25
29
  render(width) {
26
30
  return [
27
31
  ...this.header.render(width),
@@ -1 +1 @@
1
- {"version":3,"file":"interactive-layout.js","sourceRoot":"","sources":["../../src/modes/interactive-layout.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,eAAe,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAU7E,MAAM,OAAO,iBAAiB;IACZ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C;SAC5B,CAAC;IACH,CAAC;IAEO,YAAY,CAAC,KAAa;QACjC,IAAI,KAAK,IAAI,CAAC;YAAE,OAAO,EAAE,CAAC;QAC1B,IAAI,KAAK,GAAG,CAAC;YAAE,OAAO,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,eAAe,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC,CAAC,CAAC;QAChG,MAAM,UAAU,GAAG,KAAK,GAAG,CAAC,CAAC;QAC7B,MAAM,KAAK,GAAG,WAAW,CAAC;QAC1B,MAAM,GAAG,GAAG,IAAI,KAAK,GAAG,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,UAAU,GAAG,YAAY,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC;QACrF,MAAM,OAAO,GAAG,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE;YAC3D,MAAM,OAAO,GAAG,eAAe,CAAC,IAAI,EAAE,UAAU,EAAE,EAAE,EAAE,IAAI,CAAC,CAAC;YAC5D,OAAO,IAAI,OAAO,GAAG,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,UAAU,GAAG,YAAY,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC;QACrF,CAAC,CAAC,CAAC;QACH,MAAM,MAAM,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,UAAU,CAAC,GAAG,CAAC;QAC7C,OAAO,CAAC,GAAG,EAAE,GAAG,OAAO,EAAE,MAAM,CAAC,CAAC;IAClC,CAAC;CACD","sourcesContent":["import { type Component, truncateToWidth, visibleWidth } from \"@di-code/tui\";\n\nexport interface InteractiveLayoutOptions {\n\treadonly header: Component;\n\treadonly chat: Component;\n\treadonly composer: Component;\n\treadonly editor: Component;\n\treadonly footer: Component;\n}\n\nexport class InteractiveLayout implements Component {\n\tprivate readonly header: Component;\n\tprivate readonly chat: Component;\n\tprivate readonly composer: Component;\n\tprivate readonly editor: Component;\n\tprivate readonly footer: Component;\n\tconstructor(options: InteractiveLayoutOptions) {\n\t\tthis.header = options.header;\n\t\tthis.chat = options.chat;\n\t\tthis.composer = options.composer;\n\t\tthis.editor = options.editor;\n\t\tthis.footer = options.footer;\n\t}\n\n\tinvalidate(): void {\n\t\tthis.header.invalidate();\n\t\tthis.chat.invalidate();\n\t\tthis.composer.invalidate();\n\t\tthis.editor.invalidate();\n\t\tthis.footer.invalidate();\n\t}\n\n\trenderTranscript(width: number): string[] {\n\t\treturn [...this.header.render(width), ...this.chat.render(width), ...this.footer.render(width)];\n\t}\n\n\trender(width: number): string[] {\n\t\treturn [\n\t\t\t...this.header.render(width),\n\t\t\t...this.chat.render(width),\n\t\t\t...this.composer.render(width),\n\t\t\t...this.renderEditor(width),\n\t\t\t...this.footer.render(width),\n\t\t];\n\t}\n\n\tprivate renderEditor(width: number): string[] {\n\t\tif (width <= 0) return [];\n\t\tif (width < 3) return this.editor.render(width).map((line) => truncateToWidth(line, width, \"\"));\n\t\tconst innerWidth = width - 2;\n\t\tconst title = \" Compose \";\n\t\tconst top = `┌${title}${\"─\".repeat(Math.max(0, innerWidth - visibleWidth(title)))}┐`;\n\t\tconst content = this.editor.render(innerWidth).map((line) => {\n\t\t\tconst clipped = truncateToWidth(line, innerWidth, \"\", true);\n\t\t\treturn `│${clipped}${\" \".repeat(Math.max(0, innerWidth - visibleWidth(clipped)))}│`;\n\t\t});\n\t\tconst bottom = `└${\"─\".repeat(innerWidth)}┘`;\n\t\treturn [top, ...content, bottom];\n\t}\n}\n"]}
1
+ {"version":3,"file":"interactive-layout.js","sourceRoot":"","sources":["../../src/modes/interactive-layout.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,eAAe,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAU7E,MAAM,O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C,EAAE,UAAU,GAAG,YAAY,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC;QACrF,CAAC,CAAC,CAAC;QACH,MAAM,MAAM,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,UAAU,CAAC,GAAG,CAAC;QAC7C,OAAO,CAAC,GAAG,EAAE,GAAG,OAAO,EAAE,MAAM,CAAC,CAAC;IAClC,CAAC;CACD","sourcesContent":["import { type Component, truncateToWidth, visibleWidth } from \"@di-code/tui\";\n\nexport interface InteractiveLayoutOptions {\n\treadonly header: Component;\n\treadonly chat: Component;\n\treadonly composer: Component;\n\treadonly editor: Component;\n\treadonly footer: Component;\n}\n\nexport class InteractiveLayout implements Component {\n\tprivate readonly header: Component;\n\tprivate readonly chat: Component;\n\tprivate readonly composer: Component;\n\tprivate readonly editor: Component;\n\tprivate readonly footer: Component;\n\tconstructor(options: InteractiveLayoutOptions) {\n\t\tthis.header = options.header;\n\t\tthis.chat = options.chat;\n\t\tthis.composer = options.composer;\n\t\tthis.editor = options.editor;\n\t\tthis.footer = options.footer;\n\t}\n\n\tinvalidate(): void {\n\t\tthis.header.invalidate();\n\t\tthis.chat.invalidate();\n\t\tthis.composer.invalidate();\n\t\tthis.editor.invalidate();\n\t\tthis.footer.invalidate();\n\t}\n\n\trenderTranscript(width: number): string[] {\n\t\treturn [...this.header.render(width), ...this.chat.render(width), ...this.footer.render(width)];\n\t}\n\n\tgetEditorBounds(width: number): { readonly start: number; readonly end: number } {\n\t\tconst start =\n\t\t\tthis.header.render(width).length + this.chat.render(width).length + this.composer.render(width).length;\n\t\treturn { start, end: start + this.renderEditor(width).length };\n\t}\n\n\trender(width: number): string[] {\n\t\treturn [\n\t\t\t...this.header.render(width),\n\t\t\t...this.chat.render(width),\n\t\t\t...this.composer.render(width),\n\t\t\t...this.renderEditor(width),\n\t\t\t...this.footer.render(width),\n\t\t];\n\t}\n\n\tprivate renderEditor(width: number): string[] {\n\t\tif (width <= 0) return [];\n\t\tif (width < 3) return this.editor.render(width).map((line) => truncateToWidth(line, width, \"\"));\n\t\tconst innerWidth = width - 2;\n\t\tconst title = \" Compose \";\n\t\tconst top = `┌${title}${\"─\".repeat(Math.max(0, innerWidth - visibleWidth(title)))}┐`;\n\t\tconst content = this.editor.render(innerWidth).map((line) => {\n\t\t\tconst clipped = truncateToWidth(line, innerWidth, \"\", true);\n\t\t\treturn `│${clipped}${\" \".repeat(Math.max(0, innerWidth - visibleWidth(clipped)))}│`;\n\t\t});\n\t\tconst bottom = `└${\"─\".repeat(innerWidth)}┘`;\n\t\treturn [top, ...content, bottom];\n\t}\n}\n"]}
@@ -10,6 +10,8 @@ export type InteractiveMessage = {
10
10
  readonly kind: "edit" | "write";
11
11
  readonly removed: readonly string[];
12
12
  readonly added: readonly string[];
13
+ readonly diff?: string;
14
+ readonly firstChangedLine?: number;
13
15
  };
14
16
  export type InteractiveProcessItem = {
15
17
  readonly type: "thinking";
@@ -49,6 +51,8 @@ export declare class InteractiveProjection {
49
51
  private status;
50
52
  private compacting;
51
53
  private retrying;
54
+ private previewRoot;
55
+ private previewChange;
52
56
  private usage;
53
57
  get state(): InteractiveState;
54
58
  setError(message: string | undefined): void;
@@ -58,6 +62,7 @@ export declare class InteractiveProjection {
58
62
  setCompacting(value: boolean): void;
59
63
  setRetrying(value: boolean): void;
60
64
  setUsage(usage: SessionUsage): void;
65
+ configureFilePreview(root: string, onChange: () => void): void;
61
66
  advanceSpinner(): boolean;
62
67
  clearTransientProcess(): void;
63
68
  replaceTranscript(messages: readonly Message[]): void;
@@ -1 +1 @@
1
- {"version":3,"file":"interactive-state.d.ts","sourceRoot":"","sources":["../../src/modes/interactive-state.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,KAAK,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAE1E,MAAM,MAAM,kBAAkB,GAC3B;IAAE,QAAQ,CAAC,IAAI,EAAE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