shortcutxl 0.2.12 → 0.2.13

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 (110) hide show
  1. package/README.md +26 -26
  2. package/agent-docs/README.md +397 -397
  3. package/agent-docs/docs/compaction.md +390 -390
  4. package/agent-docs/docs/custom-provider.md +580 -580
  5. package/agent-docs/docs/extensions.md +1971 -1971
  6. package/agent-docs/docs/packages.md +209 -209
  7. package/agent-docs/docs/rpc.md +1317 -1317
  8. package/agent-docs/docs/sdk.md +962 -962
  9. package/agent-docs/docs/session.md +412 -412
  10. package/agent-docs/docs/termux.md +127 -127
  11. package/agent-docs/docs/tui.md +887 -887
  12. package/agent-docs/examples/README.md +25 -25
  13. package/agent-docs/examples/extensions/README.md +205 -205
  14. package/agent-docs/examples/extensions/antigravity-image-gen.ts +447 -447
  15. package/agent-docs/examples/extensions/auto-commit-on-exit.ts +49 -49
  16. package/agent-docs/examples/extensions/bash-spawn-hook.ts +30 -30
  17. package/agent-docs/examples/extensions/bookmark.ts +50 -50
  18. package/agent-docs/examples/extensions/built-in-tool-renderer.ts +256 -256
  19. package/agent-docs/examples/extensions/claude-rules.ts +86 -86
  20. package/agent-docs/examples/extensions/commands.ts +75 -75
  21. package/agent-docs/examples/extensions/confirm-destructive.ts +59 -59
  22. package/agent-docs/examples/extensions/custom-compaction.ts +126 -126
  23. package/agent-docs/examples/extensions/custom-footer.ts +63 -63
  24. package/agent-docs/examples/extensions/custom-header.ts +73 -73
  25. package/agent-docs/examples/extensions/custom-provider-anthropic/index.ts +660 -660
  26. package/agent-docs/examples/extensions/custom-provider-gitlab-duo/index.ts +362 -362
  27. package/agent-docs/examples/extensions/custom-provider-gitlab-duo/test.ts +88 -88
  28. package/agent-docs/examples/extensions/custom-provider-qwen-cli/index.ts +349 -349
  29. package/agent-docs/examples/extensions/dirty-repo-guard.ts +56 -56
  30. package/agent-docs/examples/extensions/doom-overlay/doom-component.ts +133 -133
  31. package/agent-docs/examples/extensions/doom-overlay/doom-keys.ts +108 -108
  32. package/agent-docs/examples/extensions/doom-overlay/index.ts +74 -74
  33. package/agent-docs/examples/extensions/dynamic-resources/index.ts +15 -15
  34. package/agent-docs/examples/extensions/dynamic-tools.ts +77 -77
  35. package/agent-docs/examples/extensions/event-bus.ts +43 -43
  36. package/agent-docs/examples/extensions/file-trigger.ts +41 -41
  37. package/agent-docs/examples/extensions/git-checkpoint.ts +53 -53
  38. package/agent-docs/examples/extensions/handoff.ts +155 -155
  39. package/agent-docs/examples/extensions/hello.ts +25 -25
  40. package/agent-docs/examples/extensions/inline-bash.ts +94 -94
  41. package/agent-docs/examples/extensions/input-transform.ts +43 -43
  42. package/agent-docs/examples/extensions/interactive-shell.ts +209 -209
  43. package/agent-docs/examples/extensions/mac-system-theme.ts +47 -47
  44. package/agent-docs/examples/extensions/message-renderer.ts +59 -59
  45. package/agent-docs/examples/extensions/minimal-mode.ts +430 -430
  46. package/agent-docs/examples/extensions/modal-editor.ts +90 -90
  47. package/agent-docs/examples/extensions/model-status.ts +31 -31
  48. package/agent-docs/examples/extensions/notify.ts +55 -55
  49. package/agent-docs/examples/extensions/overlay-qa-tests.ts +936 -936
  50. package/agent-docs/examples/extensions/overlay-test.ts +159 -159
  51. package/agent-docs/examples/extensions/permission-gate.ts +37 -37
  52. package/agent-docs/examples/extensions/pirate.ts +47 -47
  53. package/agent-docs/examples/extensions/plan-mode/index.ts +363 -363
  54. package/agent-docs/examples/extensions/preset.ts +418 -418
  55. package/agent-docs/examples/extensions/protected-paths.ts +30 -30
  56. package/agent-docs/examples/extensions/qna.ts +122 -122
  57. package/agent-docs/examples/extensions/question.ts +278 -278
  58. package/agent-docs/examples/extensions/questionnaire.ts +440 -440
  59. package/agent-docs/examples/extensions/rainbow-editor.ts +90 -90
  60. package/agent-docs/examples/extensions/reload-runtime.ts +37 -37
  61. package/agent-docs/examples/extensions/rpc-demo.ts +124 -124
  62. package/agent-docs/examples/extensions/sandbox/index.ts +324 -324
  63. package/agent-docs/examples/extensions/send-user-message.ts +97 -97
  64. package/agent-docs/examples/extensions/session-name.ts +27 -27
  65. package/agent-docs/examples/extensions/shutdown-command.ts +69 -69
  66. package/agent-docs/examples/extensions/snake.ts +343 -343
  67. package/agent-docs/examples/extensions/space-invaders.ts +566 -566
  68. package/agent-docs/examples/extensions/ssh.ts +233 -233
  69. package/agent-docs/examples/extensions/status-line.ts +40 -40
  70. package/agent-docs/examples/extensions/subagent/agents.ts +130 -130
  71. package/agent-docs/examples/extensions/subagent/index.ts +1068 -1068
  72. package/agent-docs/examples/extensions/summarize.ts +206 -206
  73. package/agent-docs/examples/extensions/system-prompt-header.ts +17 -17
  74. package/agent-docs/examples/extensions/timed-confirm.ts +72 -72
  75. package/agent-docs/examples/extensions/titlebar-spinner.ts +58 -58
  76. package/agent-docs/examples/extensions/todo.ts +314 -314
  77. package/agent-docs/examples/extensions/tool-override.ts +146 -146
  78. package/agent-docs/examples/extensions/tools.ts +145 -145
  79. package/agent-docs/examples/extensions/trigger-compact.ts +40 -40
  80. package/agent-docs/examples/extensions/truncated-tool.ts +194 -194
  81. package/agent-docs/examples/extensions/widget-placement.ts +17 -17
  82. package/agent-docs/examples/extensions/with-deps/index.ts +37 -37
  83. package/agent-docs/examples/rpc-extension-ui.ts +654 -654
  84. package/agent-docs/examples/sdk/01-minimal.ts +22 -22
  85. package/agent-docs/examples/sdk/02-custom-model.ts +48 -48
  86. package/agent-docs/examples/sdk/03-custom-prompt.ts +55 -55
  87. package/agent-docs/examples/sdk/04-skills.ts +53 -53
  88. package/agent-docs/examples/sdk/05-tools.ts +56 -56
  89. package/agent-docs/examples/sdk/06-extensions.ts +88 -88
  90. package/agent-docs/examples/sdk/07-context-files.ts +40 -40
  91. package/agent-docs/examples/sdk/08-prompt-templates.ts +47 -47
  92. package/agent-docs/examples/sdk/09-api-keys-and-oauth.ts +48 -48
  93. package/agent-docs/examples/sdk/10-settings.ts +54 -54
  94. package/agent-docs/examples/sdk/11-sessions.ts +48 -48
  95. package/agent-docs/examples/sdk/12-full-control.ts +82 -82
  96. package/agent-docs/examples/sdk/README.md +144 -144
  97. package/agent-docs/xll-spec.md +110 -110
  98. package/dist/core/auth-storage.js +21 -2
  99. package/package.json +1 -1
  100. package/xll/ShortcutXL.xll +0 -0
  101. package/xll/modules/debug_render.py +272 -272
  102. package/xll/modules/gameboy.py +241 -241
  103. package/xll/modules/pong.py +188 -188
  104. package/xll/modules/shortcut_xl/_diff_highlight.py +176 -0
  105. package/xll/modules/shortcut_xl/_log.py +12 -12
  106. package/xll/modules/shortcut_xl/_registry.py +44 -44
  107. package/xll/modules/stocks.py +100 -100
  108. /package/skills/{com-advanced-api → COM-advanced-api}/SKILL.md +0 -0
  109. /package/skills/{com-advanced-api → COM-advanced-api}/excel-type-library.py +0 -0
  110. /package/skills/{com-advanced-api → COM-advanced-api}/office-type-library.py +0 -0
@@ -1,256 +1,256 @@
1
- /**
2
- * Built-in Tool Renderer Example - Custom rendering for built-in tools
3
- *
4
- * Demonstrates how to override the rendering of built-in tools (read, bash,
5
- * edit, write) without changing their behavior. Each tool is re-registered
6
- * with the same name, delegating execution to the original implementation
7
- * while providing compact custom renderCall/renderResult functions.
8
- *
9
- * This is useful for users who prefer more concise tool output, or who want
10
- * to highlight specific information (e.g., showing only the diff stats for
11
- * edit, or just the exit code for bash).
12
- *
13
- * How it works:
14
- * - registerTool() with the same name as a built-in replaces it entirely
15
- * - We create instances of the original tools via createReadTool(), etc.
16
- * and delegate execute() to them
17
- * - renderCall() controls what's shown when the tool is invoked
18
- * - renderResult() controls what's shown after execution completes
19
- * - The `expanded` flag in renderResult indicates whether the user has
20
- * toggled the tool output open (via ctrl+e or clicking)
21
- *
22
- * Usage:
23
- * shortcut -e ./built-in-tool-renderer.ts
24
- */
25
-
26
- import type {
27
- BashToolDetails,
28
- EditToolDetails,
29
- ExtensionAPI,
30
- ReadToolDetails
31
- } from 'shortcutxl';
32
- import {
33
- createBashTool,
34
- createEditTool,
35
- createReadTool,
36
- createWriteTool,
37
- Text
38
- } from 'shortcutxl';
39
-
40
- export default function (shortcut: ExtensionAPI) {
41
- const cwd = process.cwd();
42
-
43
- // --- Read tool: show path and line count ---
44
- const originalRead = createReadTool(cwd);
45
- shortcut.registerTool({
46
- name: 'read',
47
- label: 'read',
48
- description: originalRead.description,
49
- parameters: originalRead.parameters,
50
-
51
- async execute(toolCallId, params, signal, onUpdate) {
52
- return originalRead.execute(toolCallId, params, signal, onUpdate);
53
- },
54
-
55
- renderCall(args, theme) {
56
- let text = theme.fg('toolTitle', theme.bold('read '));
57
- text += theme.fg('accent', args.path);
58
- if (args.offset || args.limit) {
59
- const parts: string[] = [];
60
- if (args.offset) parts.push(`offset=${args.offset}`);
61
- if (args.limit) parts.push(`limit=${args.limit}`);
62
- text += theme.fg('dim', ` (${parts.join(', ')})`);
63
- }
64
- return new Text(text, 0, 0);
65
- },
66
-
67
- renderResult(result, { expanded, isPartial }, theme) {
68
- if (isPartial) return new Text(theme.fg('warning', 'Reading...'), 0, 0);
69
-
70
- const details = result.details as ReadToolDetails | undefined;
71
- const content = result.content[0];
72
-
73
- if (content?.type === 'image') {
74
- return new Text(theme.fg('success', 'Image loaded'), 0, 0);
75
- }
76
-
77
- if (content?.type !== 'text') {
78
- return new Text(theme.fg('error', 'No content'), 0, 0);
79
- }
80
-
81
- const lineCount = content.text.split('\n').length;
82
- let text = theme.fg('success', `${lineCount} lines`);
83
-
84
- if (details?.truncation?.truncated) {
85
- text += theme.fg('warning', ` (truncated from ${details.truncation.totalLines})`);
86
- }
87
-
88
- if (expanded) {
89
- const lines = content.text.split('\n').slice(0, 15);
90
- for (const line of lines) {
91
- text += `\n${theme.fg('dim', line)}`;
92
- }
93
- if (lineCount > 15) {
94
- text += `\n${theme.fg('muted', `... ${lineCount - 15} more lines`)}`;
95
- }
96
- }
97
-
98
- return new Text(text, 0, 0);
99
- }
100
- });
101
-
102
- // --- Bash tool: show command and exit code ---
103
- const originalBash = createBashTool(cwd);
104
- shortcut.registerTool({
105
- name: 'bash',
106
- label: 'bash',
107
- description: originalBash.description,
108
- parameters: originalBash.parameters,
109
-
110
- async execute(toolCallId, params, signal, onUpdate) {
111
- return originalBash.execute(toolCallId, params, signal, onUpdate);
112
- },
113
-
114
- renderCall(args, theme) {
115
- let text = theme.fg('toolTitle', theme.bold('$ '));
116
- const cmd = args.command.length > 80 ? `${args.command.slice(0, 77)}...` : args.command;
117
- text += theme.fg('accent', cmd);
118
- if (args.timeout) {
119
- text += theme.fg('dim', ` (timeout: ${args.timeout}s)`);
120
- }
121
- return new Text(text, 0, 0);
122
- },
123
-
124
- renderResult(result, { expanded, isPartial }, theme) {
125
- if (isPartial) return new Text(theme.fg('warning', 'Running...'), 0, 0);
126
-
127
- const details = result.details as BashToolDetails | undefined;
128
- const content = result.content[0];
129
- const output = content?.type === 'text' ? content.text : '';
130
-
131
- const exitMatch = output.match(/exit code: (\d+)/);
132
- const exitCode = exitMatch ? parseInt(exitMatch[1], 10) : null;
133
- const lineCount = output.split('\n').filter((l) => l.trim()).length;
134
-
135
- let text = '';
136
- if (exitCode === 0 || exitCode === null) {
137
- text += theme.fg('success', 'done');
138
- } else {
139
- text += theme.fg('error', `exit ${exitCode}`);
140
- }
141
- text += theme.fg('dim', ` (${lineCount} lines)`);
142
-
143
- if (details?.truncation?.truncated) {
144
- text += theme.fg('warning', ' [truncated]');
145
- }
146
-
147
- if (expanded) {
148
- const lines = output.split('\n').slice(0, 20);
149
- for (const line of lines) {
150
- text += `\n${theme.fg('dim', line)}`;
151
- }
152
- if (output.split('\n').length > 20) {
153
- text += `\n${theme.fg('muted', '... more output')}`;
154
- }
155
- }
156
-
157
- return new Text(text, 0, 0);
158
- }
159
- });
160
-
161
- // --- Edit tool: show path and diff stats ---
162
- const originalEdit = createEditTool(cwd);
163
- shortcut.registerTool({
164
- name: 'edit',
165
- label: 'edit',
166
- description: originalEdit.description,
167
- parameters: originalEdit.parameters,
168
-
169
- async execute(toolCallId, params, signal, onUpdate) {
170
- return originalEdit.execute(toolCallId, params, signal, onUpdate);
171
- },
172
-
173
- renderCall(args, theme) {
174
- let text = theme.fg('toolTitle', theme.bold('edit '));
175
- text += theme.fg('accent', args.path);
176
- return new Text(text, 0, 0);
177
- },
178
-
179
- renderResult(result, { expanded, isPartial }, theme) {
180
- if (isPartial) return new Text(theme.fg('warning', 'Editing...'), 0, 0);
181
-
182
- const details = result.details as EditToolDetails | undefined;
183
- const content = result.content[0];
184
-
185
- if (content?.type === 'text' && content.text.startsWith('Error')) {
186
- return new Text(theme.fg('error', content.text.split('\n')[0]), 0, 0);
187
- }
188
-
189
- if (!details?.diff) {
190
- return new Text(theme.fg('success', 'Applied'), 0, 0);
191
- }
192
-
193
- // Count additions and removals from the diff
194
- const diffLines = details.diff.split('\n');
195
- let additions = 0;
196
- let removals = 0;
197
- for (const line of diffLines) {
198
- if (line.startsWith('+') && !line.startsWith('+++')) additions++;
199
- if (line.startsWith('-') && !line.startsWith('---')) removals++;
200
- }
201
-
202
- let text = theme.fg('success', `+${additions}`);
203
- text += theme.fg('dim', ' / ');
204
- text += theme.fg('error', `-${removals}`);
205
-
206
- if (expanded) {
207
- for (const line of diffLines.slice(0, 30)) {
208
- if (line.startsWith('+') && !line.startsWith('+++')) {
209
- text += `\n${theme.fg('success', line)}`;
210
- } else if (line.startsWith('-') && !line.startsWith('---')) {
211
- text += `\n${theme.fg('error', line)}`;
212
- } else {
213
- text += `\n${theme.fg('dim', line)}`;
214
- }
215
- }
216
- if (diffLines.length > 30) {
217
- text += `\n${theme.fg('muted', `... ${diffLines.length - 30} more diff lines`)}`;
218
- }
219
- }
220
-
221
- return new Text(text, 0, 0);
222
- }
223
- });
224
-
225
- // --- Write tool: show path and size ---
226
- const originalWrite = createWriteTool(cwd);
227
- shortcut.registerTool({
228
- name: 'write',
229
- label: 'write',
230
- description: originalWrite.description,
231
- parameters: originalWrite.parameters,
232
-
233
- async execute(toolCallId, params, signal, onUpdate) {
234
- return originalWrite.execute(toolCallId, params, signal, onUpdate);
235
- },
236
-
237
- renderCall(args, theme) {
238
- let text = theme.fg('toolTitle', theme.bold('write '));
239
- text += theme.fg('accent', args.path);
240
- const lineCount = args.content.split('\n').length;
241
- text += theme.fg('dim', ` (${lineCount} lines)`);
242
- return new Text(text, 0, 0);
243
- },
244
-
245
- renderResult(result, { isPartial }, theme) {
246
- if (isPartial) return new Text(theme.fg('warning', 'Writing...'), 0, 0);
247
-
248
- const content = result.content[0];
249
- if (content?.type === 'text' && content.text.startsWith('Error')) {
250
- return new Text(theme.fg('error', content.text.split('\n')[0]), 0, 0);
251
- }
252
-
253
- return new Text(theme.fg('success', 'Written'), 0, 0);
254
- }
255
- });
256
- }
1
+ /**
2
+ * Built-in Tool Renderer Example - Custom rendering for built-in tools
3
+ *
4
+ * Demonstrates how to override the rendering of built-in tools (read, bash,
5
+ * edit, write) without changing their behavior. Each tool is re-registered
6
+ * with the same name, delegating execution to the original implementation
7
+ * while providing compact custom renderCall/renderResult functions.
8
+ *
9
+ * This is useful for users who prefer more concise tool output, or who want
10
+ * to highlight specific information (e.g., showing only the diff stats for
11
+ * edit, or just the exit code for bash).
12
+ *
13
+ * How it works:
14
+ * - registerTool() with the same name as a built-in replaces it entirely
15
+ * - We create instances of the original tools via createReadTool(), etc.
16
+ * and delegate execute() to them
17
+ * - renderCall() controls what's shown when the tool is invoked
18
+ * - renderResult() controls what's shown after execution completes
19
+ * - The `expanded` flag in renderResult indicates whether the user has
20
+ * toggled the tool output open (via ctrl+e or clicking)
21
+ *
22
+ * Usage:
23
+ * shortcut -e ./built-in-tool-renderer.ts
24
+ */
25
+
26
+ import type {
27
+ BashToolDetails,
28
+ EditToolDetails,
29
+ ExtensionAPI,
30
+ ReadToolDetails
31
+ } from 'shortcutxl';
32
+ import {
33
+ createBashTool,
34
+ createEditTool,
35
+ createReadTool,
36
+ createWriteTool,
37
+ Text
38
+ } from 'shortcutxl';
39
+
40
+ export default function (shortcut: ExtensionAPI) {
41
+ const cwd = process.cwd();
42
+
43
+ // --- Read tool: show path and line count ---
44
+ const originalRead = createReadTool(cwd);
45
+ shortcut.registerTool({
46
+ name: 'read',
47
+ label: 'read',
48
+ description: originalRead.description,
49
+ parameters: originalRead.parameters,
50
+
51
+ async execute(toolCallId, params, signal, onUpdate) {
52
+ return originalRead.execute(toolCallId, params, signal, onUpdate);
53
+ },
54
+
55
+ renderCall(args, theme) {
56
+ let text = theme.fg('toolTitle', theme.bold('read '));
57
+ text += theme.fg('accent', args.path);
58
+ if (args.offset || args.limit) {
59
+ const parts: string[] = [];
60
+ if (args.offset) parts.push(`offset=${args.offset}`);
61
+ if (args.limit) parts.push(`limit=${args.limit}`);
62
+ text += theme.fg('dim', ` (${parts.join(', ')})`);
63
+ }
64
+ return new Text(text, 0, 0);
65
+ },
66
+
67
+ renderResult(result, { expanded, isPartial }, theme) {
68
+ if (isPartial) return new Text(theme.fg('warning', 'Reading...'), 0, 0);
69
+
70
+ const details = result.details as ReadToolDetails | undefined;
71
+ const content = result.content[0];
72
+
73
+ if (content?.type === 'image') {
74
+ return new Text(theme.fg('success', 'Image loaded'), 0, 0);
75
+ }
76
+
77
+ if (content?.type !== 'text') {
78
+ return new Text(theme.fg('error', 'No content'), 0, 0);
79
+ }
80
+
81
+ const lineCount = content.text.split('\n').length;
82
+ let text = theme.fg('success', `${lineCount} lines`);
83
+
84
+ if (details?.truncation?.truncated) {
85
+ text += theme.fg('warning', ` (truncated from ${details.truncation.totalLines})`);
86
+ }
87
+
88
+ if (expanded) {
89
+ const lines = content.text.split('\n').slice(0, 15);
90
+ for (const line of lines) {
91
+ text += `\n${theme.fg('dim', line)}`;
92
+ }
93
+ if (lineCount > 15) {
94
+ text += `\n${theme.fg('muted', `... ${lineCount - 15} more lines`)}`;
95
+ }
96
+ }
97
+
98
+ return new Text(text, 0, 0);
99
+ }
100
+ });
101
+
102
+ // --- Bash tool: show command and exit code ---
103
+ const originalBash = createBashTool(cwd);
104
+ shortcut.registerTool({
105
+ name: 'bash',
106
+ label: 'bash',
107
+ description: originalBash.description,
108
+ parameters: originalBash.parameters,
109
+
110
+ async execute(toolCallId, params, signal, onUpdate) {
111
+ return originalBash.execute(toolCallId, params, signal, onUpdate);
112
+ },
113
+
114
+ renderCall(args, theme) {
115
+ let text = theme.fg('toolTitle', theme.bold('$ '));
116
+ const cmd = args.command.length > 80 ? `${args.command.slice(0, 77)}...` : args.command;
117
+ text += theme.fg('accent', cmd);
118
+ if (args.timeout) {
119
+ text += theme.fg('dim', ` (timeout: ${args.timeout}s)`);
120
+ }
121
+ return new Text(text, 0, 0);
122
+ },
123
+
124
+ renderResult(result, { expanded, isPartial }, theme) {
125
+ if (isPartial) return new Text(theme.fg('warning', 'Running...'), 0, 0);
126
+
127
+ const details = result.details as BashToolDetails | undefined;
128
+ const content = result.content[0];
129
+ const output = content?.type === 'text' ? content.text : '';
130
+
131
+ const exitMatch = output.match(/exit code: (\d+)/);
132
+ const exitCode = exitMatch ? parseInt(exitMatch[1], 10) : null;
133
+ const lineCount = output.split('\n').filter((l) => l.trim()).length;
134
+
135
+ let text = '';
136
+ if (exitCode === 0 || exitCode === null) {
137
+ text += theme.fg('success', 'done');
138
+ } else {
139
+ text += theme.fg('error', `exit ${exitCode}`);
140
+ }
141
+ text += theme.fg('dim', ` (${lineCount} lines)`);
142
+
143
+ if (details?.truncation?.truncated) {
144
+ text += theme.fg('warning', ' [truncated]');
145
+ }
146
+
147
+ if (expanded) {
148
+ const lines = output.split('\n').slice(0, 20);
149
+ for (const line of lines) {
150
+ text += `\n${theme.fg('dim', line)}`;
151
+ }
152
+ if (output.split('\n').length > 20) {
153
+ text += `\n${theme.fg('muted', '... more output')}`;
154
+ }
155
+ }
156
+
157
+ return new Text(text, 0, 0);
158
+ }
159
+ });
160
+
161
+ // --- Edit tool: show path and diff stats ---
162
+ const originalEdit = createEditTool(cwd);
163
+ shortcut.registerTool({
164
+ name: 'edit',
165
+ label: 'edit',
166
+ description: originalEdit.description,
167
+ parameters: originalEdit.parameters,
168
+
169
+ async execute(toolCallId, params, signal, onUpdate) {
170
+ return originalEdit.execute(toolCallId, params, signal, onUpdate);
171
+ },
172
+
173
+ renderCall(args, theme) {
174
+ let text = theme.fg('toolTitle', theme.bold('edit '));
175
+ text += theme.fg('accent', args.path);
176
+ return new Text(text, 0, 0);
177
+ },
178
+
179
+ renderResult(result, { expanded, isPartial }, theme) {
180
+ if (isPartial) return new Text(theme.fg('warning', 'Editing...'), 0, 0);
181
+
182
+ const details = result.details as EditToolDetails | undefined;
183
+ const content = result.content[0];
184
+
185
+ if (content?.type === 'text' && content.text.startsWith('Error')) {
186
+ return new Text(theme.fg('error', content.text.split('\n')[0]), 0, 0);
187
+ }
188
+
189
+ if (!details?.diff) {
190
+ return new Text(theme.fg('success', 'Applied'), 0, 0);
191
+ }
192
+
193
+ // Count additions and removals from the diff
194
+ const diffLines = details.diff.split('\n');
195
+ let additions = 0;
196
+ let removals = 0;
197
+ for (const line of diffLines) {
198
+ if (line.startsWith('+') && !line.startsWith('+++')) additions++;
199
+ if (line.startsWith('-') && !line.startsWith('---')) removals++;
200
+ }
201
+
202
+ let text = theme.fg('success', `+${additions}`);
203
+ text += theme.fg('dim', ' / ');
204
+ text += theme.fg('error', `-${removals}`);
205
+
206
+ if (expanded) {
207
+ for (const line of diffLines.slice(0, 30)) {
208
+ if (line.startsWith('+') && !line.startsWith('+++')) {
209
+ text += `\n${theme.fg('success', line)}`;
210
+ } else if (line.startsWith('-') && !line.startsWith('---')) {
211
+ text += `\n${theme.fg('error', line)}`;
212
+ } else {
213
+ text += `\n${theme.fg('dim', line)}`;
214
+ }
215
+ }
216
+ if (diffLines.length > 30) {
217
+ text += `\n${theme.fg('muted', `... ${diffLines.length - 30} more diff lines`)}`;
218
+ }
219
+ }
220
+
221
+ return new Text(text, 0, 0);
222
+ }
223
+ });
224
+
225
+ // --- Write tool: show path and size ---
226
+ const originalWrite = createWriteTool(cwd);
227
+ shortcut.registerTool({
228
+ name: 'write',
229
+ label: 'write',
230
+ description: originalWrite.description,
231
+ parameters: originalWrite.parameters,
232
+
233
+ async execute(toolCallId, params, signal, onUpdate) {
234
+ return originalWrite.execute(toolCallId, params, signal, onUpdate);
235
+ },
236
+
237
+ renderCall(args, theme) {
238
+ let text = theme.fg('toolTitle', theme.bold('write '));
239
+ text += theme.fg('accent', args.path);
240
+ const lineCount = args.content.split('\n').length;
241
+ text += theme.fg('dim', ` (${lineCount} lines)`);
242
+ return new Text(text, 0, 0);
243
+ },
244
+
245
+ renderResult(result, { isPartial }, theme) {
246
+ if (isPartial) return new Text(theme.fg('warning', 'Writing...'), 0, 0);
247
+
248
+ const content = result.content[0];
249
+ if (content?.type === 'text' && content.text.startsWith('Error')) {
250
+ return new Text(theme.fg('error', content.text.split('\n')[0]), 0, 0);
251
+ }
252
+
253
+ return new Text(theme.fg('success', 'Written'), 0, 0);
254
+ }
255
+ });
256
+ }