indusagi-coding-agent 0.1.23 → 0.1.24

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 (213) hide show
  1. package/CHANGELOG.md +65 -0
  2. package/README.md +2 -0
  3. package/dist/cli/args.d.ts +117 -1
  4. package/dist/cli/args.d.ts.map +1 -1
  5. package/dist/cli/args.js +221 -52
  6. package/dist/cli/args.js.map +1 -1
  7. package/dist/cli/config-selector.d.ts +58 -2
  8. package/dist/cli/config-selector.d.ts.map +1 -1
  9. package/dist/cli/config-selector.js +130 -12
  10. package/dist/cli/config-selector.js.map +1 -1
  11. package/dist/cli/file-processor.d.ts +70 -2
  12. package/dist/cli/file-processor.d.ts.map +1 -1
  13. package/dist/cli/file-processor.js +240 -15
  14. package/dist/cli/file-processor.js.map +1 -1
  15. package/dist/cli/list-models.d.ts +63 -3
  16. package/dist/cli/list-models.d.ts.map +1 -1
  17. package/dist/cli/list-models.js +202 -27
  18. package/dist/cli/list-models.js.map +1 -1
  19. package/dist/cli/login-handler.d.ts +82 -8
  20. package/dist/cli/login-handler.d.ts.map +1 -1
  21. package/dist/cli/login-handler.js +410 -77
  22. package/dist/cli/login-handler.js.map +1 -1
  23. package/dist/cli/session-picker.d.ts +74 -2
  24. package/dist/cli/session-picker.d.ts.map +1 -1
  25. package/dist/cli/session-picker.js +236 -12
  26. package/dist/cli/session-picker.js.map +1 -1
  27. package/dist/core/agent-session.d.ts +214 -9
  28. package/dist/core/agent-session.d.ts.map +1 -1
  29. package/dist/core/agent-session.js +214 -9
  30. package/dist/core/agent-session.js.map +1 -1
  31. package/dist/core/bash-executor.d.ts +302 -12
  32. package/dist/core/bash-executor.d.ts.map +1 -1
  33. package/dist/core/bash-executor.js +302 -12
  34. package/dist/core/bash-executor.js.map +1 -1
  35. package/dist/core/diagnostics.d.ts +191 -0
  36. package/dist/core/diagnostics.d.ts.map +1 -1
  37. package/dist/core/diagnostics.js +142 -0
  38. package/dist/core/diagnostics.js.map +1 -1
  39. package/dist/core/event-bus.d.ts +146 -0
  40. package/dist/core/event-bus.d.ts.map +1 -1
  41. package/dist/core/event-bus.js +93 -0
  42. package/dist/core/event-bus.js.map +1 -1
  43. package/dist/core/export-html/ansi-to-html.d.ts +4 -0
  44. package/dist/core/export-html/ansi-to-html.d.ts.map +1 -1
  45. package/dist/core/export-html/ansi-to-html.js +4 -0
  46. package/dist/core/export-html/ansi-to-html.js.map +1 -1
  47. package/dist/core/export-html/index.d.ts +128 -0
  48. package/dist/core/export-html/index.d.ts.map +1 -1
  49. package/dist/core/export-html/index.js +128 -0
  50. package/dist/core/export-html/index.js.map +1 -1
  51. package/dist/core/export-html/tool-renderer.d.ts +4 -0
  52. package/dist/core/export-html/tool-renderer.d.ts.map +1 -1
  53. package/dist/core/export-html/tool-renderer.js +4 -0
  54. package/dist/core/export-html/tool-renderer.js.map +1 -1
  55. package/dist/core/keybindings.d.ts +142 -0
  56. package/dist/core/keybindings.d.ts.map +1 -1
  57. package/dist/core/keybindings.js +142 -0
  58. package/dist/core/keybindings.js.map +1 -1
  59. package/dist/core/model-registry.d.ts +98 -1
  60. package/dist/core/model-registry.d.ts.map +1 -1
  61. package/dist/core/model-registry.js +98 -1
  62. package/dist/core/model-registry.js.map +1 -1
  63. package/dist/core/model-resolver.d.ts +99 -1
  64. package/dist/core/model-resolver.d.ts.map +1 -1
  65. package/dist/core/model-resolver.js +99 -1
  66. package/dist/core/model-resolver.js.map +1 -1
  67. package/dist/core/prompt-templates.js.map +1 -1
  68. package/dist/core/session-manager.d.ts +127 -0
  69. package/dist/core/session-manager.d.ts.map +1 -1
  70. package/dist/core/session-manager.js +125 -0
  71. package/dist/core/session-manager.js.map +1 -1
  72. package/dist/core/skills.js.map +1 -1
  73. package/dist/core/subagents.js.map +1 -1
  74. package/dist/core/tools/bash.d.ts +391 -11
  75. package/dist/core/tools/bash.d.ts.map +1 -1
  76. package/dist/core/tools/bash.js +269 -2
  77. package/dist/core/tools/bash.js.map +1 -1
  78. package/dist/core/tools/edit.d.ts +284 -6
  79. package/dist/core/tools/edit.d.ts.map +1 -1
  80. package/dist/core/tools/edit.js +238 -0
  81. package/dist/core/tools/edit.js.map +1 -1
  82. package/dist/core/tools/find.d.ts +169 -5
  83. package/dist/core/tools/find.d.ts.map +1 -1
  84. package/dist/core/tools/find.js +136 -0
  85. package/dist/core/tools/find.js.map +1 -1
  86. package/dist/core/tools/grep.d.ts +285 -5
  87. package/dist/core/tools/grep.d.ts.map +1 -1
  88. package/dist/core/tools/grep.js +247 -0
  89. package/dist/core/tools/grep.js.map +1 -1
  90. package/dist/core/tools/ls.d.ts +6 -0
  91. package/dist/core/tools/ls.d.ts.map +1 -1
  92. package/dist/core/tools/ls.js +6 -0
  93. package/dist/core/tools/ls.js.map +1 -1
  94. package/dist/core/tools/read.d.ts +308 -7
  95. package/dist/core/tools/read.d.ts.map +1 -1
  96. package/dist/core/tools/read.js +231 -0
  97. package/dist/core/tools/read.js.map +1 -1
  98. package/dist/core/tools/webfetch.d.ts +118 -3
  99. package/dist/core/tools/webfetch.d.ts.map +1 -1
  100. package/dist/core/tools/webfetch.js +118 -3
  101. package/dist/core/tools/webfetch.js.map +1 -1
  102. package/dist/core/tools/websearch.d.ts +130 -3
  103. package/dist/core/tools/websearch.d.ts.map +1 -1
  104. package/dist/core/tools/websearch.js +130 -3
  105. package/dist/core/tools/websearch.js.map +1 -1
  106. package/dist/core/tools/write.d.ts +251 -5
  107. package/dist/core/tools/write.d.ts.map +1 -1
  108. package/dist/core/tools/write.js +210 -0
  109. package/dist/core/tools/write.js.map +1 -1
  110. package/dist/modes/interactive/components/assistant-message.d.ts +164 -1
  111. package/dist/modes/interactive/components/assistant-message.d.ts.map +1 -1
  112. package/dist/modes/interactive/components/assistant-message.js +164 -1
  113. package/dist/modes/interactive/components/assistant-message.js.map +1 -1
  114. package/dist/modes/interactive/components/bash-execution.d.ts +297 -1
  115. package/dist/modes/interactive/components/bash-execution.d.ts.map +1 -1
  116. package/dist/modes/interactive/components/bash-execution.js +297 -1
  117. package/dist/modes/interactive/components/bash-execution.js.map +1 -1
  118. package/dist/modes/interactive/components/tool-execution.d.ts.map +1 -1
  119. package/dist/modes/interactive/components/tool-execution.js +251 -1
  120. package/dist/modes/interactive/components/tool-execution.js.map +1 -1
  121. package/dist/modes/interactive/components/user-message.d.ts +186 -1
  122. package/dist/modes/interactive/components/user-message.d.ts.map +1 -1
  123. package/dist/modes/interactive/components/user-message.js +186 -1
  124. package/dist/modes/interactive/components/user-message.js.map +1 -1
  125. package/dist/modes/interactive/interactive-mode.d.ts +1567 -13
  126. package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
  127. package/dist/modes/interactive/interactive-mode.js +1567 -13
  128. package/dist/modes/interactive/interactive-mode.js.map +1 -1
  129. package/dist/modes/interactive/theme/theme.d.ts +422 -0
  130. package/dist/modes/interactive/theme/theme.d.ts.map +1 -1
  131. package/dist/modes/interactive/theme/theme.js +422 -0
  132. package/dist/modes/interactive/theme/theme.js.map +1 -1
  133. package/dist/modes/print-mode.d.ts +538 -5
  134. package/dist/modes/print-mode.d.ts.map +1 -1
  135. package/dist/modes/print-mode.js +538 -5
  136. package/dist/modes/print-mode.js.map +1 -1
  137. package/dist/modes/rpc/rpc-client.d.ts +921 -8
  138. package/dist/modes/rpc/rpc-client.d.ts.map +1 -1
  139. package/dist/modes/rpc/rpc-client.js +921 -8
  140. package/dist/modes/rpc/rpc-client.js.map +1 -1
  141. package/dist/modes/rpc/rpc-mode.d.ts +802 -9
  142. package/dist/modes/rpc/rpc-mode.d.ts.map +1 -1
  143. package/dist/modes/rpc/rpc-mode.js +802 -9
  144. package/dist/modes/rpc/rpc-mode.js.map +1 -1
  145. package/dist/modes/rpc/rpc-types.d.ts +356 -3
  146. package/dist/modes/rpc/rpc-types.d.ts.map +1 -1
  147. package/dist/modes/rpc/rpc-types.js +356 -3
  148. package/dist/modes/rpc/rpc-types.js.map +1 -1
  149. package/dist/modes/shared.d.ts +386 -0
  150. package/dist/modes/shared.d.ts.map +1 -0
  151. package/dist/modes/shared.js +543 -0
  152. package/dist/modes/shared.js.map +1 -0
  153. package/dist/utils/array.d.ts +389 -0
  154. package/dist/utils/array.d.ts.map +1 -0
  155. package/dist/utils/array.js +585 -0
  156. package/dist/utils/array.js.map +1 -0
  157. package/dist/utils/color-formatter.d.ts +318 -0
  158. package/dist/utils/color-formatter.d.ts.map +1 -0
  159. package/dist/utils/color-formatter.js +442 -0
  160. package/dist/utils/color-formatter.js.map +1 -0
  161. package/dist/utils/data-transformer.d.ts +326 -0
  162. package/dist/utils/data-transformer.d.ts.map +1 -0
  163. package/dist/utils/data-transformer.js +512 -0
  164. package/dist/utils/data-transformer.js.map +1 -0
  165. package/dist/utils/date-formatter.d.ts +281 -0
  166. package/dist/utils/date-formatter.d.ts.map +1 -0
  167. package/dist/utils/date-formatter.js +503 -0
  168. package/dist/utils/date-formatter.js.map +1 -0
  169. package/dist/utils/error-handler.d.ts +541 -0
  170. package/dist/utils/error-handler.d.ts.map +1 -0
  171. package/dist/utils/error-handler.js +726 -0
  172. package/dist/utils/error-handler.js.map +1 -0
  173. package/dist/utils/file-operations.d.ts +297 -0
  174. package/dist/utils/file-operations.d.ts.map +1 -0
  175. package/dist/utils/file-operations.js +505 -0
  176. package/dist/utils/file-operations.js.map +1 -0
  177. package/dist/utils/frontmatter.d.ts +268 -6
  178. package/dist/utils/frontmatter.d.ts.map +1 -1
  179. package/dist/utils/frontmatter.js +500 -21
  180. package/dist/utils/frontmatter.js.map +1 -1
  181. package/dist/utils/json-formatter.d.ts +259 -0
  182. package/dist/utils/json-formatter.d.ts.map +1 -0
  183. package/dist/utils/json-formatter.js +517 -0
  184. package/dist/utils/json-formatter.js.map +1 -0
  185. package/dist/utils/logger.d.ts +176 -0
  186. package/dist/utils/logger.d.ts.map +1 -0
  187. package/dist/utils/logger.js +346 -0
  188. package/dist/utils/logger.js.map +1 -0
  189. package/dist/utils/markdown-formatter.d.ts +211 -0
  190. package/dist/utils/markdown-formatter.d.ts.map +1 -0
  191. package/dist/utils/markdown-formatter.js +482 -0
  192. package/dist/utils/markdown-formatter.js.map +1 -0
  193. package/dist/utils/path-validator.d.ts +603 -0
  194. package/dist/utils/path-validator.d.ts.map +1 -0
  195. package/dist/utils/path-validator.js +870 -0
  196. package/dist/utils/path-validator.js.map +1 -0
  197. package/dist/utils/string-formatter.d.ts +609 -0
  198. package/dist/utils/string-formatter.d.ts.map +1 -0
  199. package/dist/utils/string-formatter.js +806 -0
  200. package/dist/utils/string-formatter.js.map +1 -0
  201. package/dist/utils/type-guards.d.ts +629 -0
  202. package/dist/utils/type-guards.d.ts.map +1 -0
  203. package/dist/utils/type-guards.js +662 -0
  204. package/dist/utils/type-guards.js.map +1 -0
  205. package/docs/COMPLETE-GUIDE.md +300 -0
  206. package/docs/MODES-ARCHITECTURE.md +565 -0
  207. package/docs/PRINT-MODE-GUIDE.md +456 -0
  208. package/docs/RPC-GUIDE.md +705 -0
  209. package/docs/UTILS-IMPLEMENTATION-SUMMARY.md +647 -0
  210. package/docs/UTILS-MODULE-OVERVIEW.md +1480 -0
  211. package/docs/UTILS-QA-CHECKLIST.md +1061 -0
  212. package/docs/UTILS-USAGE-GUIDE.md +1419 -0
  213. package/package.json +1 -1
@@ -1,5 +1,301 @@
1
1
  /**
2
- * Component for displaying bash command execution with streaming output.
2
+ * ============================================================================
3
+ * BASH EXECUTION COMPONENT - REAL-TIME BASH OUTPUT RENDERER
4
+ * ============================================================================
5
+ *
6
+ * PURPOSE:
7
+ * ============================================================================
8
+ * Renders live bash command execution in the interactive chat interface.
9
+ * This component displays:
10
+ *
11
+ * - Command invocation with dynamic border styling
12
+ * - Real-time streaming output (appended as chunks arrive)
13
+ * - Loading animation while command runs
14
+ * - Exit code and cancellation status
15
+ * - Expandable output (collapsed preview vs full output)
16
+ * - Truncation warnings (context limits, path to full output)
17
+ * - Visual line truncation with width-aware caching
18
+ *
19
+ * DESIGN:
20
+ * BashExecutionComponent is distinct from ToolExecutionComponent because:
21
+ * 1. Streaming: Output arrives chunk-by-chunk (append, not replace)
22
+ * 2. State: Maintains outputLines array during execution
23
+ * 3. Loading: Shows spinner while running
24
+ * 4. Borders: Dynamic borders with color based on context exclusion
25
+ * 5. Visual wrapping: Line-based truncation respects terminal width
26
+ *
27
+ * DIFFERENCES FROM TOOL EXECUTION:
28
+ * - Tool execution: Shows full tool state (args + result at once)
29
+ * - Bash execution: Shows streaming output with real-time updates
30
+ * - Tool has result.content structure, bash has outputLines array
31
+ * - Bash shows loader during execution, tool shows pending background
32
+ *
33
+ * DATA FLOW:
34
+ * ============================================================================
35
+ * Bash Execution Pipeline:
36
+ * User types: !! command text
37
+ * ↓
38
+ * InteractiveMode.handleBashCommand() captures input
39
+ * ↓
40
+ * session.bash() starts async bash execution
41
+ * ↓
42
+ * BashExecutionComponent created
43
+ * ↓
44
+ * While running, agent streams stdout via session.on('bash_output')
45
+ * ↓
46
+ * component.appendOutput(chunk) called repeatedly
47
+ * ↓
48
+ * updateDisplay() called, adds new lines to content
49
+ * ↓
50
+ * TUI invalidate() and requestRender()
51
+ * ↓
52
+ * Terminal shows streaming output with loading spinner
53
+ * ↓
54
+ * Agent emits bash_complete event
55
+ * ↓
56
+ * component.setComplete(exitCode, cancelled, truncation, fullPath)
57
+ * ↓
58
+ * Loader stops, exit code/status displayed
59
+ * ↓
60
+ * TUI displays final output
61
+ *
62
+ * Component State Lifecycle:
63
+ * 1. Constructor:
64
+ * - Initialize with command string
65
+ * - Create bordered container structure
66
+ * - Add command header with styling
67
+ * - Show loader with "Running..." text
68
+ * 2. appendOutput() calls (while running):
69
+ * - Strip ANSI codes and normalize line endings
70
+ * - Split on newlines and append to outputLines
71
+ * - Call updateDisplay() to refresh
72
+ * - TUI invalidate() → render shows new content
73
+ * 3. setComplete() call (when done):
74
+ * - Store exit code and status (error/cancelled/complete)
75
+ * - Stop loader animation
76
+ * - Call updateDisplay() final time
77
+ * - Display exit code or cancellation message
78
+ * 4. invalidate() call (on theme change):
79
+ * - Re-render with new colors
80
+ * - Keep outputLines unchanged
81
+ * - Re-apply truncation and styling
82
+ *
83
+ * RENDERING PIPELINE:
84
+ * ============================================================================
85
+ * Layout Structure (ASCII):
86
+ * ┌─────────────────────────────────────────────┐
87
+ * │ [Spacer 1 line] │ ← Top margin
88
+ * ├─────────────────────────────────────────────┤
89
+ * │ ┌ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ┐ │ ← DynamicBorder
90
+ * │ $ command text │ ← Command header
91
+ * │ │ ← (or content)
92
+ * │ [spinner] Running... (C-c to cancel) │ ← Loader (if running)
93
+ * │ │
94
+ * │ output line 1 │ ← Output lines
95
+ * │ output line 2 │
96
+ * │ output line 3 │
97
+ * │ ... (5 more lines, to expand) │ ← Truncation hint (collapsed)
98
+ * │ │
99
+ * │ (exit 0) or (cancelled) or (exit 1) │ ← Status (if complete)
100
+ * │ └ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ┘ │ ← DynamicBorder
101
+ * └─────────────────────────────────────────────┘
102
+ *
103
+ * Rendering Rules:
104
+ * 1. Top spacer: Always present
105
+ * 2. Top border: DynamicBorder with colorKey (bashMode or dim)
106
+ * 3. ContentContainer:
107
+ * - Command header: "$ command" (bold, colored)
108
+ * - Output lines (if available):
109
+ * a. If expanded: Show all outputLines
110
+ * b. If collapsed: Show last PREVIEW_LINES with visual truncation
111
+ * - Loader: Only if status="running"
112
+ * - Status: Only if status!="running" (complete/error/cancelled)
113
+ * 4. Bottom border: Same style as top border
114
+ *
115
+ * Output Line Handling:
116
+ * - Raw output: Received with ANSI codes
117
+ * - Strip ANSI: stripAnsi() removes color codes (preserve structure)
118
+ * - Normalize newlines: \r\n → \n, \r → \n
119
+ * - Split/append: newLines split on \n, append to outputLines
120
+ * - Styling: Apply theme.fg("muted", line) to each line
121
+ * - Wrapping: Visual line truncation handles width changes
122
+ *
123
+ * Preview Truncation (collapsed state):
124
+ * - PREVIEW_LINES = 20 (max logical lines to show when collapsed)
125
+ * - hiddenLineCount = availableLines.length - previewLogicalLines.length
126
+ * - Visual truncation: truncateToVisualLines() respects terminal width
127
+ * - Shown: "... N more lines" hint with expand key hint
128
+ *
129
+ * Context Truncation (for LLM):
130
+ * - DEFAULT_MAX_LINES = 500
131
+ * - DEFAULT_MAX_BYTES = 50KB
132
+ * - Applied BEFORE preview truncation
133
+ * - Only tail of output kept (prevents explosion of context)
134
+ * - Warning message shows truncation occurred
135
+ *
136
+ * STYLING/FORMATTING:
137
+ * ============================================================================
138
+ * Color Scheme:
139
+ * - Command: theme.fg("bashMode", "$ command") [colored, bold]
140
+ * - Border: colorKey function (bashMode or dim)
141
+ * - Output: theme.fg("muted", line) [neutral/gray]
142
+ * - Error status: theme.fg("error", "(exit 1)") [red]
143
+ * - Cancelled: theme.fg("warning", "(cancelled)") [yellow]
144
+ * - Truncation: theme.fg("warning", "[Truncated...]") [yellow]
145
+ * - Hints: keyHint("expandTools", "...") [key binding text]
146
+ *
147
+ * Loader Styling:
148
+ * - Spinner: Animated loader component
149
+ * - Spinner color: theme.fg(colorKey, spinner)
150
+ * - Text: theme.fg("muted", "Running...")
151
+ * - Key hint: editorKey("selectCancel") + " to cancel"
152
+ *
153
+ * Border Styling:
154
+ * - DynamicBorder: Fills terminal width with box characters
155
+ * - Color: colorKey function (respects excludeFromContext flag)
156
+ * - excludeFromContext: Command prefixed with !! (dim border)
157
+ * - Normal: bashMode color (highlighted border)
158
+ *
159
+ * Component Nesting:
160
+ * - BashExecutionComponent (Container)
161
+ * ├── Spacer(1) ← Top margin
162
+ * ├── DynamicBorder ← Top border
163
+ * ├── contentContainer (Container)
164
+ * │ ├── Text: "$ command" header
165
+ * │ ├── Text or dynamic component: Output lines
166
+ * │ ├── Loader ← If running
167
+ * │ └── Text: Status message ← If complete
168
+ * └── DynamicBorder ← Bottom border
169
+ *
170
+ * EXAMPLES:
171
+ * ============================================================================
172
+ *
173
+ * Example 1: Simple Command (Running)
174
+ * ────────────────────────────────────
175
+ * Command: "ls -la"
176
+ * Rendered:
177
+ * <blank>
178
+ * ┌─────────────────────────────────────────┐
179
+ * $ ls -la
180
+ * [spinner] Running... (C-c to cancel)
181
+ * └─────────────────────────────────────────┘
182
+ *
183
+ * Example 2: Simple Command (Complete)
184
+ * ──────────────────────────────────────
185
+ * Command: "echo hello" completed successfully
186
+ * Rendered:
187
+ * <blank>
188
+ * ┌─────────────────────────────────────────┐
189
+ * $ echo hello
190
+ *
191
+ * hello
192
+ * └─────────────────────────────────────────┘
193
+ *
194
+ * Example 3: Large Output (Collapsed)
195
+ * ────────────────────────────────────
196
+ * Command: "find ." with 1000 results, collapsed
197
+ * Rendered:
198
+ * <blank>
199
+ * ┌─────────────────────────────────────────┐
200
+ * $ find .
201
+ *
202
+ * ... 980 more lines (to expand)
203
+ * ./src/index.ts
204
+ * ./src/main.ts
205
+ * ./dist/index.js
206
+ * (exit 0)
207
+ * └─────────────────────────────────────────┘
208
+ *
209
+ * Example 4: Error Exit Code
210
+ * ──────────────────────────
211
+ * Command: "rm /nonexistent" failed
212
+ * Rendered:
213
+ * <blank>
214
+ * ┌─────────────────────────────────────────┐
215
+ * $ rm /nonexistent
216
+ *
217
+ * Cannot remove: No such file or directory
218
+ * (exit 1)
219
+ * └─────────────────────────────────────────┘
220
+ *
221
+ * Example 5: Cancelled Command
222
+ * ──────────────────────────────
223
+ * User pressed Ctrl-C during execution
224
+ * Rendered:
225
+ * <blank>
226
+ * ┌─────────────────────────────────────────┐
227
+ * $ long_running_command
228
+ *
229
+ * Processing...
230
+ * ... 10 more lines (to expand)
231
+ * (cancelled)
232
+ * └─────────────────────────────────────────┘
233
+ *
234
+ * INTEGRATION:
235
+ * ============================================================================
236
+ * TUI Integration:
237
+ * - Extends Container (indusagi/tui base component)
238
+ * - Uses Text, Spacer, Loader, DynamicBorder components
239
+ * - Theme system: theme.fg(), theme.bold()
240
+ * - Loader component: Animated spinner from indusagi/tui
241
+ * - Terminal access: this.ui.terminal.columns for width
242
+ *
243
+ * Session Integration:
244
+ * - Created by InteractiveMode when !! command entered
245
+ * - Updates come from AgentSession.on('bash_output')
246
+ * - Completion from AgentSession.on('bash_complete')
247
+ * - Stored in chatContainer like other messages
248
+ * - Output exported via getOutput() for BashExecutionMessage
249
+ *
250
+ * Theme Integration:
251
+ * - bashMode color: Border and command header color
252
+ * - dim color: Used if excludeFromContext=true
253
+ * - muted color: Output lines rendered in muted color
254
+ * - invalidate(): Re-renders with new theme
255
+ * - Colors apply dynamically at render time
256
+ *
257
+ * Real-time Updates:
258
+ * - appendOutput(): Non-blocking append to array
259
+ * - updateDisplay(): Rebuilds contentContainer
260
+ * - TUI calls render() after requestRender()
261
+ * - Suitable for high-frequency updates (many lines/sec)
262
+ *
263
+ * Performance Notes:
264
+ * - outputLines stored as string array (efficient append)
265
+ * - Visual truncation cached (recomputed on width change)
266
+ * - Loader is simple spinner (minimal overhead)
267
+ * - PREVIEW_LINES limits rendered lines when collapsed
268
+ * - DEFAULT_MAX_LINES prevents context explosion (500 lines cap)
269
+ *
270
+ * API:
271
+ * ============================================================================
272
+ * Constructor(command, ui, excludeFromContext):
273
+ * - command: String to display in header (can be long)
274
+ * - ui: TUI instance for requestRender() and terminal access
275
+ * - excludeFromContext: Boolean, true if !! prefixed (dim border)
276
+ *
277
+ * setExpanded(expanded):
278
+ * - expanded: Boolean, toggle between full/preview output
279
+ * - Updates display immediately
280
+ *
281
+ * appendOutput(chunk):
282
+ * - chunk: String of output to append (can be partial line)
283
+ * - Strips ANSI, normalizes newlines, appends to outputLines
284
+ * - Calls updateDisplay() and requestRender()
285
+ *
286
+ * setComplete(exitCode, cancelled, truncationResult, fullOutputPath):
287
+ * - exitCode: Number or undefined (exit code from bash)
288
+ * - cancelled: Boolean, true if user cancelled
289
+ * - truncationResult: Optional truncation info for context limits
290
+ * - fullOutputPath: Path to file with full output (if truncated)
291
+ * - Stops loader, sets status, calls updateDisplay()
292
+ *
293
+ * getOutput():
294
+ * - Returns: String of all output lines joined with newlines
295
+ * - Used for creating BashExecutionMessage
296
+ *
297
+ * getCommand():
298
+ * - Returns: String of the command that was executed
3
299
  */
4
300
  import { Container, Loader, Spacer, Text } from "indusagi/tui";
5
301
  import stripAnsi from "strip-ansi";
@@ -1 +1 @@
1
- {"version":3,"file":"bash-execution.js","sourceRoot":"","sources":["../../../../src/modes/interactive/components/bash-execution.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAY,MAAM,cAAc,CAAC;AACzE,OAAO,SAAS,MAAM,YAAY,CAAC;AACnC,OAAO,EACN,iBAAiB,EACjB,iBAAiB,EAEjB,YAAY,GACZ,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAE7D,yEAAyE;AACzE,MAAM,aAAa,GAAG,EAAE,CAAC;AAEzB,MAAM,OAAO,sBAAuB,SAAQ,SAAS;IAYpD,YAAY,OAAe,EAAE,EAAO,EAAE,kBAAkB,GAAG,KAAK;QAC/D,KAAK,EAAE,CAAC;QAXD,gBAAW,GAAa,EAAE,CAAC;QAC3B,WAAM,GAAmD,SAAS,CAAC;QACnE,aAAQ,GAAuB,SAAS,CAAC;QAIzC,aAAQ,GAAG,KAAK,CAAC;QAMxB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC;QAEb,gEAAgE;QAChE,MAAM,QAAQ,GAAG,kBAAkB,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,UAAU,CAAC;QACzD,MAAM,WAAW,GAAG,CAAC,G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C;IACrB,CAAC;CACD"}
@@ -1 +1 @@
1
- {"version":3,"file":"tool-execution.d.ts","sourceRoot":"","sources":["../../../../src/modes/interactive/components/tool-execution.ts"],"names":[],"mappings":"AACA,OAAO,EAEN,SAAS,EAOT,KAAK,GAAG,EAER,MAAM,cAAc,CAAC;AAEtB,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mCAAmC,CAAC;AAiCxE,MAAM,WAAW,oBAAoB;IACpC,UAAU,CAAC,EAAE,OAAO,CAAC;CACrB;AAED;;GAEG;AACH,qBAAa,sBAAuB,SAAQ,SAAS;IACpD,OAAO,CAAC,UAAU,CAAM;IACxB,OAAO,CAAC,WAAW,CAAO;IAC1B,OAAO,CAAC,eAAe,CAAe;IACtC,OAAO,CAAC,YAAY,CAAgB;IACpC,OAAO,CAAC,QAAQ,CAAS;IACzB,OAAO,CAAC,IAAI,CAAM;IAClB,OAAO,CAAC,QAAQ,CAAS;IACzB,OAAO,CAAC,UAAU,CAAU;IAC5B,OAAO,CAAC,SAAS,CAAQ;IACzB,OAAO,CAAC,cAAc,CAAC,CAAiB;IACxC,OAAO,CAAC,EAAE,CAAM;IAChB,OAAO,CAAC,GAAG,CAAS;IACpB,OAAO,CAAC,MAAM,CAAC,CAIb;IAEF,OAAO,CAAC,eAAe,CAAC,CAAiC;IACzD,OAAO,CAAC,eAAe,CAAC,CAAS;IAEjC,OAAO,CAAC,eAAe,CAA8D;gBAGpF,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,GAAG,EACT,OAAO,EAAE,oBAAoB,YAAK,EAClC,cAAc,EAAE,cAAc,GAAG,SAAS,EAC1C,EAAE,EAAE,GAAG,EACP,GAAG,GAAE,MAAsB;IA2B5B;;;;OAIG;IACH,OAAO,CAAC,wBAAwB;IAMhC,UAAU,CAAC,IAAI,EAAE,GAAG,GAAG,IAAI;IAK3B;;;OAGG;IACH,eAAe,IAAI,IAAI;IAIvB;;;OAGG;IACH,OAAO,CAAC,oBAAoB;IA6B5B,YAAY,CACX,MAAM,EAAE;QACP,OAAO,EAAE,KAAK,CAAC;YAAE,IAAI,EAAE,MAAM,CAAC;YAAC,IAAI,CAAC,EAAE,MAAM,CAAC;YAAC,IAAI,CAAC,EAAE,MAAM,CAAC;YAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;SAAE,CAAC,CAAC;QAClF,OAAO,CAAC,EAAE,GAAG,CAAC;QACd,OAAO,EAAE,OAAO,CAAC;KACjB,EACD,SAAS,UAAQ,GACf,IAAI;IAQP;;;OAGG;IACH,OAAO,CAAC,0BAA0B;IA2BlC,WAAW,CAAC,QAAQ,EAAE,OAAO,GAAG,IAAI;IAKpC,aAAa,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI;IAKzB,UAAU,IAAI,IAAI;IAK3B,OAAO,CAAC,aAAa;IA+GrB;;OAEG;IACH,OAAO,CAAC,iBAAiB;IAiFzB,OAAO,CAAC,aAAa;IA2BrB,OAAO,CAAC,mBAAmB;CA6a3B"}
1
+ {"version":3,"file":"tool-execution.d.ts","sourceRoot":"","sources":["../../../../src/modes/interactive/components/tool-execution.ts"],"names":[],"mappings":"AACA,OAAO,EAEN,SAAS,EAOT,KAAK,GAAG,EAER,MAAM,cAAc,CAAC;AAEtB,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mCAAmC,CAAC;AA2RxE,MAAM,WAAW,oBAAoB;IACpC,UAAU,CAAC,EAAE,OAAO,CAAC;CACrB;AAED;;GAEG;AACH,qBAAa,sBAAuB,SAAQ,SAAS;IACpD,OAAO,CAAC,UAAU,CAAM;IACxB,OAAO,CAAC,WAAW,CAAO;IAC1B,OAAO,CAAC,eAAe,CAAe;IACtC,OAAO,CAAC,YAAY,CAAgB;IACpC,OAAO,CAAC,QAAQ,CAAS;IACzB,OAAO,CAAC,IAAI,CAAM;IAClB,OAAO,CAAC,QAAQ,CAAS;IACzB,OAAO,CAAC,UAAU,CAAU;IAC5B,OAAO,CAAC,SAAS,CAAQ;IACzB,OAAO,CAAC,cAAc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view line limit for bash when not expanded
14
14
  const BASH_PREVIEW_LINES = 5;
15
15
  /**
16
- * Convert absolute path to tilde notation if it's in home directory
16
+ * ============================================================================
17
+ * TOOL EXECUTION COMPONENT - COMPREHENSIVE RENDERING MODULE
18
+ * ============================================================================
19
+ *
20
+ * PURPOSE:
21
+ * ============================================================================
22
+ * Renders tool call invocations and their results in the interactive chat
23
+ * interface. This component is the primary display system for all tool
24
+ * execution in the agent, supporting:
25
+ *
26
+ * - Built-in tools (read, write, edit, bash, ls, find, grep, task, todos)
27
+ * - Custom tools with extension renderers
28
+ * - Real-time result streaming and updates
29
+ * - Expandable/collapsible output (respects toolOutputExpanded setting)
30
+ * - Syntax highlighting (code blocks, diffs, file paths)
31
+ * - Image rendering (with format conversion for compatibility)
32
+ * - Error states and partial results
33
+ * - Truncation warnings (context limit, output limit)
34
+ *
35
+ * TOOL-SPECIFIC RENDERING:
36
+ * Each tool has specialized rendering logic:
37
+ * - read: File contents with line numbers, highlighting
38
+ * - write: File creation preview, error display
39
+ * - edit: Visual diff (added/removed lines), line numbers
40
+ * - bash: Command + output with visual line truncation
41
+ * - ls/find/grep: Formatted output with entry limits
42
+ * - task: Metadata (subagent, duration, tool count)
43
+ * - todos: Status icons, priority coloring, completion count
44
+ *
45
+ * DATA FLOW:
46
+ * ============================================================================
47
+ * Tool Execution Pipeline:
48
+ * Assistant message with tool call content
49
+ * ↓
50
+ * InteractiveMode.renderSessionContext() encounters tool call
51
+ * ↓
52
+ * ToolExecutionComponent created with tool name + args
53
+ * ↓
54
+ * updateDisplay() renders pending state (no result yet)
55
+ * ↓
56
+ * Tool executes in background (on agent server)
57
+ * ↓
58
+ * AgentSession emits tool_output event
59
+ * ↓
60
+ * InteractiveMode.subscribeToAgent() receives tool_output
61
+ * ↓
62
+ * component.updateResult() called with result content
63
+ * ↓
64
+ * updateDisplay() re-renders with result + background color
65
+ * ↓
66
+ * TUI invalidate() and requestRender()
67
+ * ↓
68
+ * Terminal displays complete tool execution
69
+ *
70
+ * Streaming Tool Output:
71
+ * Some tools (bash, read, find) stream output:
72
+ * 1. tool_output event arrives with isPartial=true
73
+ * 2. updateResult() called, still showing pending background
74
+ * 3. Later, tool_output event with isPartial=false (complete)
75
+ * 4. updateDisplay() shows final result + success/error background
76
+ *
77
+ * Async Operations:
78
+ * - Edit diff computation: async computeEditDiff() with caching
79
+ * - Image format conversion: async convertToPng() for Kitty protocol
80
+ * - Both update display when complete via ui.requestRender()
81
+ *
82
+ * RENDERING PIPELINE:
83
+ * ============================================================================
84
+ * Component Structure (ASCII):
85
+ * ┌───────────────────────────────────────────────────────────┐
86
+ * │ [Spacer 1 line] │ ← Top margin
87
+ * ├───────────────────────────────────────────────────────────┤
88
+ * │ PENDING STATE (while tool executing) │
89
+ * │ ████████████████████████████████████████████████████████ │ ← toolPendingBg
90
+ * │ █ read /path/to/file.ts:10-20 █
91
+ * │ █ (Executing...) █
92
+ * │ ████████████████████████████████████████████████████████ │
93
+ * ├───────────────────────────────────────────────────────────┤
94
+ * │ COMPLETE STATE (after result arrives) │
95
+ * │ ████████████████████████████████████████████████████████ │ ← toolSuccessBg or toolErrorBg
96
+ * │ █ read /path/to/file.ts:10-20 │
97
+ * │ █ │
98
+ * │ █ 10 | import { foo } from 'bar'; │
99
+ * │ █ 11 | const x = foo(); │
100
+ * │ █ 12 | export { x }; │
101
+ * │ █ ... (5 more lines, to expand) │
102
+ * │ ████████████████████████████████████████████████████████ │
103
+ * ├───────────────────────────────────────────────────────────┤
104
+ * │ [Image 1: 640×480 pixels] │ ← Images (optional)
105
+ * ├───────────────────────────────────────────────────────────┤
106
+ * │ [Image 2: 800×600 pixels] │
107
+ * └───────────────────────────────────────────────────────────┘
108
+ *
109
+ * Background Color State Machine:
110
+ * 1. Initial: toolPendingBg (dark, neutral color)
111
+ * 2. Streaming: toolPendingBg (stays same while partial=true)
112
+ * 3. Success: toolSuccessBg (green tint, indicates success)
113
+ * 4. Error: toolErrorBg (red tint, indicates failure)
114
+ * 5. Partial: toolPendingBg (still running, don't show final color)
115
+ *
116
+ * Rendering Decision Tree:
117
+ * Tool in allTools? (built-in)
118
+ * ├─ Yes + tool=bash → Box with visual truncation
119
+ * ├─ Yes + tool=edit → Text with diff rendering
120
+ * ├─ Yes + tool=read → Text with syntax highlighting
121
+ * ├─ Yes + others → Text with formatted output
122
+ * └─ No → Check for custom renderer
123
+ * Custom tool with renderCall?
124
+ * ├─ Yes → Use custom renderCall component
125
+ * └─ No → Show tool name
126
+ * Custom tool with renderResult?
127
+ * ├─ Yes → Use custom renderResult component
128
+ * └─ No → Show formatted text output
129
+ *
130
+ * STYLING/FORMATTING:
131
+ * ============================================================================
132
+ * Background Colors:
133
+ * - Pending: theme.bg("toolPendingBg", text) [neutral gray]
134
+ * - Success: theme.bg("toolSuccessBg", text) [subtle green]
135
+ * - Error: theme.bg("toolErrorBg", text) [subtle red]
136
+ * - Colors apply to entire tool execution box
137
+ *
138
+ * Text Colors (within background):
139
+ * - Tool name: theme.fg("toolTitle", theme.bold(name))
140
+ * - File path: theme.fg("accent", path)
141
+ * - Line numbers: theme.fg("warning", ":10-20")
142
+ * - Output: theme.fg("toolOutput", output)
143
+ * - Error text: theme.fg("error", message)
144
+ * - Warning: theme.fg("warning", "[Truncated...]")
145
+ * - Muted: theme.fg("muted", "... (5 more lines,")
146
+ *
147
+ * Code Highlighting:
148
+ * - getLanguageFromPath(): Detect language from file extension
149
+ * - highlightCode(): ANSI syntax highlighting via highlight.js
150
+ * - Tabs replaced with 3 spaces for consistent rendering
151
+ * - Applied to read, write, and custom tool outputs
152
+ *
153
+ * Diff Rendering (edit tool):
154
+ * - renderDiff(): Specialized diff component
155
+ * - Shows added/removed lines with colors
156
+ * - Line numbers with context
157
+ * - File path with first changed line number
158
+ *
159
+ * Layout Spacing:
160
+ * - paddingY=1, paddingX=1 for Box/Text components
161
+ * - Spacer(1) above tool execution
162
+ * - Spacer(1) between tool and images
163
+ * - Blank lines in output for readability
164
+ *
165
+ * EXAMPLES:
166
+ * ============================================================================
167
+ *
168
+ * Example 1: Read Tool - File Contents
169
+ * ─────────────────────────────────────
170
+ * Input: read file="/src/main.ts" limit=5
171
+ * Rendered:
172
+ * ┌──────────────────────────────────┐
173
+ * │ read ~/src/main.ts:1-5 │
174
+ * │ │
175
+ * │ 1 | import { foo } from 'bar'; │
176
+ * │ 2 | const x = 42; │
177
+ * │ 3 | export { x }; │
178
+ * │ ... (27 more lines, to expand) │
179
+ * └──────────────────────────────────┘
180
+ *
181
+ * Example 2: Edit Tool - Visual Diff
182
+ * ──────────────────────────────────
183
+ * Input: edit path="/src/main.ts" oldText="const x = 1;" newText="const x = 42;"
184
+ * Rendered:
185
+ * ┌──────────────────────────────────────┐
186
+ * │ edit ~/src/main.ts:10 │
187
+ * │ │
188
+ * │ 10 - const x = 1; │
189
+ * │ 10 + const x = 42; │
190
+ * └──────────────────────────────────────┘
191
+ *
192
+ * Example 3: Bash Tool - Command Output
193
+ * ────────────────────────────────────
194
+ * Input: bash command="ls -la" timeout=5
195
+ * Rendered (collapsed):
196
+ * ┌──────────────────────────────────────┐
197
+ * │ $ ls -la (timeout 5s) │
198
+ * │ │
199
+ * │ total 128 │
200
+ * │ drwxr-xr-x 5 user wheel 160 │
201
+ * │ -rw-r--r-- 1 user wheel 1234 │
202
+ * │ ... (7 more lines, to expand) │
203
+ * └──────────────────────────────────────┘
204
+ *
205
+ * Example 4: Error Result
206
+ * ──────────────────────
207
+ * Tool fails, returns error
208
+ * Rendered:
209
+ * ┌──────────────────────────────────────┐ ← toolErrorBg (red tint)
210
+ * │ read ~/nonexistent/file.txt │
211
+ * │ │
212
+ * │ Error: ENOENT: no such file or dir │
213
+ * └──────────────────────────────────────┘
214
+ *
215
+ * Example 5: Tool with Images
216
+ * ───────────────────────────
217
+ * Bash tool that outputs PNG image
218
+ * Rendered:
219
+ * ┌──────────────────────────────────────┐
220
+ * │ $ generate_chart.sh │
221
+ * │ │
222
+ * │ Chart generated successfully │
223
+ * └──────────────────────────────────────┘
224
+ * [Image: 640×480 pixels, PNG]
225
+ *
226
+ * INTEGRATION:
227
+ * ============================================================================
228
+ * TUI Integration:
229
+ * - Extends Container (indusagi/tui base component)
230
+ * - Uses Box, Text, Image, Spacer components
231
+ * - Theme system: theme.fg(), theme.bg()
232
+ * - Automatic text wrapping to terminal width
233
+ * - Image rendering via indusagi/tui Image component
234
+ *
235
+ * Session Integration:
236
+ * - Created in InteractiveMode.renderSessionContext()
237
+ * - Updates come from AgentSession.on('tool_output')
238
+ * - Stored in chatContainer with tool calls
239
+ * - pendingTools map tracks incomplete tools
240
+ * - Expandable via toolOutputExpanded setting
241
+ *
242
+ * Extension Integration:
243
+ * - Supports custom renderCall() and renderResult()
244
+ * - Custom tools can provide their own renderers
245
+ * - Falls back to built-in rendering if no custom renderer
246
+ * - Passes theme object to custom renderers
247
+ *
248
+ * Image Integration:
249
+ * - Terminal capability detection via getCapabilities()
250
+ * - Kitty protocol requires PNG (auto-converts JPEG/GIF/WebP)
251
+ * - Image fallback for terminals without image support
252
+ * - Respects showImages setting
253
+ * - Image dimensions cached after first render
254
+ *
255
+ * Diff Integration:
256
+ * - computeEditDiff() runs async before tool execution
257
+ * - Preview diff shown while tool running (cached)
258
+ * - Final diff from tool result overrides preview (post-execution)
259
+ * - Handles race conditions (file modified between preview/execution)
260
+ *
261
+ * Performance Considerations:
262
+ * - Bash visual line truncation: Width-aware caching
263
+ * - Image conversion: Lazy async (doesn't block rendering)
264
+ * - Diff computation: Async with result override (non-blocking)
265
+ * - Tool output formatting: Cached in formatToolExecution()
266
+ * - Suitable for 50+ tools in conversation without lag
17
267
  */
18
268
  function shortenPath(path) {
19
269
  const home = os.homedir();