@raindrop-ai/wizard 0.0.1 → 0.0.2

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 (71) hide show
  1. package/dist/src/docs/claude-agent-sdk.mdx +382 -0
  2. package/dist/src/docs/{typescript.md → typescript.mdx} +8 -4
  3. package/dist/src/docs/vercel-ai-sdk.mdx +769 -0
  4. package/dist/src/lib/agent-interface.d.ts +4 -3
  5. package/dist/src/lib/agent-interface.js +290 -197
  6. package/dist/src/lib/agent-interface.js.map +1 -1
  7. package/dist/src/lib/constants.d.ts +1 -0
  8. package/dist/src/lib/constants.js +1 -0
  9. package/dist/src/lib/constants.js.map +1 -1
  10. package/dist/src/lib/handlers.d.ts +16 -8
  11. package/dist/src/lib/handlers.js +232 -118
  12. package/dist/src/lib/handlers.js.map +1 -1
  13. package/dist/src/lib/integration-testing.d.ts +5 -5
  14. package/dist/src/lib/integration-testing.js +28 -12
  15. package/dist/src/lib/integration-testing.js.map +1 -1
  16. package/dist/src/lib/mcp.d.ts +1 -1
  17. package/dist/src/lib/mcp.js +88 -49
  18. package/dist/src/lib/mcp.js.map +1 -1
  19. package/dist/src/lib/sdk-messages.d.ts +8 -1
  20. package/dist/src/lib/sdk-messages.js +83 -27
  21. package/dist/src/lib/sdk-messages.js.map +1 -1
  22. package/dist/src/lib/wizard.js +16 -20
  23. package/dist/src/lib/wizard.js.map +1 -1
  24. package/dist/src/ui/App.d.ts +5 -4
  25. package/dist/src/ui/App.js +12 -12
  26. package/dist/src/ui/App.js.map +1 -1
  27. package/dist/src/ui/components/ClarifyingQuestionsPrompt.js +4 -2
  28. package/dist/src/ui/components/ClarifyingQuestionsPrompt.js.map +1 -1
  29. package/dist/src/ui/components/ContinuePrompt.d.ts +3 -2
  30. package/dist/src/ui/components/ContinuePrompt.js +4 -4
  31. package/dist/src/ui/components/ContinuePrompt.js.map +1 -1
  32. package/dist/src/ui/components/DiffDisplay.js +16 -6
  33. package/dist/src/ui/components/DiffDisplay.js.map +1 -1
  34. package/dist/src/ui/components/FeedbackSelectPrompt.js +6 -3
  35. package/dist/src/ui/components/FeedbackSelectPrompt.js.map +1 -1
  36. package/dist/src/ui/components/HistoryItemDisplay.d.ts +5 -3
  37. package/dist/src/ui/components/HistoryItemDisplay.js +10 -9
  38. package/dist/src/ui/components/HistoryItemDisplay.js.map +1 -1
  39. package/dist/src/ui/components/Logo.js +19 -34
  40. package/dist/src/ui/components/Logo.js.map +1 -1
  41. package/dist/src/ui/components/OrgInfoBox.d.ts +2 -1
  42. package/dist/src/ui/components/OrgInfoBox.js +2 -4
  43. package/dist/src/ui/components/OrgInfoBox.js.map +1 -1
  44. package/dist/src/ui/components/PersistentTextInput.js +13 -11
  45. package/dist/src/ui/components/PersistentTextInput.js.map +1 -1
  46. package/dist/src/ui/components/PromptContainer.js +4 -8
  47. package/dist/src/ui/components/PromptContainer.js.map +1 -1
  48. package/dist/src/ui/components/ToolApprovalPrompt.js +4 -4
  49. package/dist/src/ui/components/ToolApprovalPrompt.js.map +1 -1
  50. package/dist/src/ui/components/WriteKeyDisplay.d.ts +1 -1
  51. package/dist/src/ui/components/WriteKeyDisplay.js +1 -1
  52. package/dist/src/ui/components/WriteKeyDisplay.js.map +1 -1
  53. package/dist/src/ui/contexts/WizardContext.d.ts +13 -5
  54. package/dist/src/ui/contexts/WizardContext.js +60 -20
  55. package/dist/src/ui/contexts/WizardContext.js.map +1 -1
  56. package/dist/src/ui/render.js +49 -5
  57. package/dist/src/ui/render.js.map +1 -1
  58. package/dist/src/ui/types.d.ts +4 -2
  59. package/dist/src/ui/types.js.map +1 -1
  60. package/dist/src/utils/oauth.js +0 -4
  61. package/dist/src/utils/oauth.js.map +1 -1
  62. package/dist/src/utils/session.d.ts +1 -0
  63. package/dist/src/utils/session.js +40 -1
  64. package/dist/src/utils/session.js.map +1 -1
  65. package/dist/src/utils/ui.d.ts +7 -2
  66. package/dist/src/utils/ui.js +9 -2
  67. package/dist/src/utils/ui.js.map +1 -1
  68. package/package.json +2 -1
  69. package/dist/src/docs/vercel-ai-sdk.md +0 -304
  70. /package/dist/src/docs/{browser.md → browser.mdx} +0 -0
  71. /package/dist/src/docs/{python.md → python.mdx} +0 -0
@@ -11,10 +11,7 @@ const INTERNAL_TOOLS = new Set([
11
11
  'AskUserQuestion',
12
12
  'TodoWrite',
13
13
  'mcp__raindrop-wizard__CompleteIntegration',
14
- 'mcp__raindrop-wizard__LoadPythonDocumentation',
15
- 'mcp__raindrop-wizard__LoadTypeScriptDocumentation',
16
- 'mcp__raindrop-wizard__LoadVercelAiSdkDocumentation',
17
- 'mcp__raindrop-wizard__LoadBrowserDocumentation',
14
+ 'mcp__raindrop-wizard__LoadDocumentation',
18
15
  'mcp__raindrop-wizard__InitializeSession',
19
16
  'EnterPlanMode',
20
17
  'ExitPlanMode',
@@ -129,11 +126,40 @@ export function extractResultSummary(toolName, resultContent, input) {
129
126
  return undefined;
130
127
  }
131
128
  }
129
+ /**
130
+ * Build a contextual spinner message based on the completed tool call.
131
+ */
132
+ function getToolSpinnerMessage(toolName, input) {
133
+ switch (toolName) {
134
+ case 'Grep':
135
+ return `Analysing results`;
136
+ case 'Read':
137
+ return `Analysing`;
138
+ case 'Bash':
139
+ return `Analysing output`;
140
+ case 'Edit':
141
+ case 'Write':
142
+ return `Working`;
143
+ case 'Glob':
144
+ return `Browsing files`;
145
+ case 'WebSearch':
146
+ return `Searching the web`;
147
+ case 'WebFetch':
148
+ return `Fetching documentation`;
149
+ case 'EnterPlanMode':
150
+ return `Planning`;
151
+ default:
152
+ if (toolName.startsWith('mcp__raindrop-wizard__Load')) {
153
+ return `Loading Raindrop documentation`;
154
+ }
155
+ return `Working`;
156
+ }
157
+ }
132
158
  /**
133
159
  * Process SDK messages and provide user feedback.
134
160
  * Handles assistant text, tool use, tool results, and system messages.
135
161
  */
136
- export function processSDKMessage(message, options, collectedText, pendingToolCalls, isInterrupting) {
162
+ export function processSDKMessage(message, options, collectedText, pendingToolCalls, isInterrupting, context) {
137
163
  logToFile(`SDK Message: ${message.type}`, JSON.stringify(message, null, 2));
138
164
  if (options.debug) {
139
165
  debug(`SDK Message type: ${message.type}`);
@@ -151,6 +177,10 @@ export function processSDKMessage(message, options, collectedText, pendingToolCa
151
177
  type: 'agent-message',
152
178
  text: block.text,
153
179
  });
180
+ // Reset spinner after assistant responds — "Analysing" after "Perfect!" looks wrong
181
+ if (context?.updateSpinner) {
182
+ context.updateSpinner(context.baseSpinnerMessage);
183
+ }
154
184
  }
155
185
  // Handle tool_use blocks - store pending, don't add to history yet
156
186
  if (block.type === 'tool_use') {
@@ -162,13 +192,27 @@ export function processSDKMessage(message, options, collectedText, pendingToolCa
162
192
  if (INTERNAL_TOOLS.has(toolName)) {
163
193
  continue;
164
194
  }
165
- // Store pending tool call to complete when result arrives
195
+ // Show tool as executing immediately (pretooluse)
196
+ const historyItemId = ui.addItem({
197
+ type: 'tool-call',
198
+ text: toolName,
199
+ toolCall: {
200
+ toolName,
201
+ status: 'executing',
202
+ input: toolInput,
203
+ description: typeof toolInput.description === 'string'
204
+ ? toolInput.description
205
+ : undefined,
206
+ },
207
+ });
208
+ // Store pending tool call with history ID so we can update it on completion
166
209
  pendingToolCalls.set(toolUseId, {
167
210
  toolName,
168
211
  input: toolInput,
169
212
  description: typeof toolInput.description === 'string'
170
213
  ? toolInput.description
171
214
  : undefined,
215
+ historyItemId,
172
216
  });
173
217
  }
174
218
  }
@@ -194,31 +238,43 @@ export function processSDKMessage(message, options, collectedText, pendingToolCa
194
238
  pendingToolCalls.delete(toolUseId);
195
239
  // Extract diff content and file name for Edit/Write tools
196
240
  const { diffContent, fileName } = extractEditWriteInfo(pendingCall.toolName, pendingCall.input);
197
- // Skip displaying Write tool calls for plan files
198
- const isPlanWrite = pendingCall.toolName === 'Write' &&
199
- fileName &&
200
- fileName.includes('plans/');
201
- if (isPlanWrite) {
202
- // Don't add plan writes to history
241
+ // Skip displaying tool calls for plan files
242
+ if (fileName && fileName.includes('plans/')) {
203
243
  continue;
204
244
  }
205
245
  // Extract result summary based on tool type
206
246
  const resultSummary = extractResultSummary(pendingCall.toolName, resultContent, pendingCall.input);
207
- // Add completed tool call to history
208
- ui.addItem({
209
- type: 'tool-call',
210
- text: pendingCall.toolName,
211
- toolCall: {
212
- toolName: pendingCall.toolName,
213
- status: isError ? 'error' : 'success',
214
- input: pendingCall.input,
215
- description: pendingCall.description,
216
- result: resultSummary,
217
- error: isError ? String(resultContent) : undefined,
218
- diffContent,
219
- fileName,
220
- },
221
- });
247
+ // Update the existing 'executing' history item with the final result (posttooluse)
248
+ const completedToolCall = {
249
+ toolName: pendingCall.toolName,
250
+ status: (isError ? 'error' : 'success'),
251
+ input: pendingCall.input,
252
+ description: pendingCall.description,
253
+ result: resultSummary,
254
+ error: isError
255
+ ? `Error: ${String(resultContent).replace(/<\/?tool_use_error>/g, '').trim()}`
256
+ : undefined,
257
+ diffContent,
258
+ fileName,
259
+ };
260
+ if (pendingCall.historyItemId !== undefined) {
261
+ ui.updateItem(pendingCall.historyItemId, {
262
+ type: 'tool-call',
263
+ text: pendingCall.toolName,
264
+ toolCall: completedToolCall,
265
+ });
266
+ }
267
+ else {
268
+ ui.addItem({
269
+ type: 'tool-call',
270
+ text: pendingCall.toolName,
271
+ toolCall: completedToolCall,
272
+ });
273
+ }
274
+ // Update spinner with contextual message after tool completes (skip errors)
275
+ if (!isError && context?.updateSpinner) {
276
+ context.updateSpinner(getToolSpinnerMessage(pendingCall.toolName, pendingCall.input));
277
+ }
222
278
  }
223
279
  if (isError && options.debug) {
224
280
  debug(`Tool error: ${resultContent}`);
@@ -1 +1 @@
1
- {"version":3,"file":"sdk-messages.js","sourceRoot":"","sources":["../../../src/lib/sdk-messages.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAChC,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAGrD,OAAO,EAAE,mBAAmB,EAAE,M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,OAAO,KAAK,MAAM,EAAE,CAAC;gBAC/B,SAAS,CAAC,2BAA2B,EAAE;oBACrC,KAAK,EAAE,OAAO,CAAC,KAAK;oBACpB,KAAK,EAAE,OAAO,CAAC,KAAK,EAAE,MAAM;iBAC7B,CAAC,CAAC;YACL,CAAC;YACD,MAAM;QACR,CAAC;QAED;YACE,wCAAwC;YACxC,IAAI,OAAO,CAAC,KAAK,EAAE,CAAC;gBAClB,KAAK,CAAC,2BAA2B,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC;YACnD,CAAC;YACD,MAAM;IACV,CAAC;AACH,CAAC","sourcesContent":["/**\n * SDK message processing utilities\n * Handles parsing and displaying SDK messages from the Claude agent\n */\n\nimport ui from '../utils/ui.js';\nimport { debug, logToFile } from '../utils/debug.js';\nimport type { PendingToolCall } from './handlers.js';\nimport type { WizardOptions } from '../utils/types.js';\nimport { createTwoFilesPatch } from 'diff';\n\n// Using `any` because typed imports from ESM modules require import attributes\n// syntax which prettier cannot parse.\ntype SDKMessage = any;\n\n/** Internal SDK tools that should not be stored/displayed */\nconst INTERNAL_TOOLS = new Set([\n 'Task',\n 'AskUserQuestion',\n 'TodoWrite',\n 'mcp__raindrop-wizard__CompleteIntegration',\n 'mcp__raindrop-wizard__LoadPythonDocumentation',\n 'mcp__raindrop-wizard__LoadTypeScriptDocumentation',\n 'mcp__raindrop-wizard__LoadVercelAiSdkDocumentation',\n 'mcp__raindrop-wizard__LoadBrowserDocumentation',\n 'mcp__raindrop-wizard__InitializeSession',\n 'EnterPlanMode',\n 'ExitPlanMode',\n]);\n\n/**\n * Generate a unified diff for Edit tool inputs (old_string -> new_string)\n */\nfunction generateEditDiff(\n filePath: string,\n oldString: string,\n newString: string,\n): string {\n return createTwoFilesPatch(\n filePath,\n filePath,\n oldString,\n newString,\n '', // old header\n '', // new header\n { context: 3 }, // context lines\n );\n}\n\n/**\n * Extract summary for Edit tool (line changes)\n */\nfunction extractEditSummary(input: Record<string, unknown>): string {\n const oldString =\n typeof input.old_string === 'string' ? input.old_string : '';\n const newString =\n typeof input.new_string === 'string' ? input.new_string : '';\n\n const oldLines = oldString ? oldString.split('\\n').length : 0;\n const newLines = newString ? newString.split('\\n').length : 0;\n\n const added = Math.max(0, newLines - oldLines);\n const removed = Math.max(0, oldLines - newLines);\n\n // Handle the case where lines are replaced (same count but different content)\n if (added === 0 && removed === 0 && oldString !== newString) {\n return `Updated ${oldLines} line${oldLines === 1 ? '' : 's'}`;\n }\n\n const parts: string[] = [];\n if (added > 0) parts.push(`Added ${added} line${added === 1 ? '' : 's'}`);\n if (removed > 0)\n parts.push(`removed ${removed} line${removed === 1 ? '' : 's'}`);\n\n return parts.length > 0 ? parts.join(', ') : 'No changes';\n}\n\n/**\n * Extract summary for Write tool (lines written)\n */\nfunction extractWriteSummary(input: Record<string, unknown>): string {\n const content = typeof input.content === 'string' ? input.content : '';\n const lines = content ? content.split('\\n').length : 0;\n const fileName =\n typeof input.path === 'string' ? input.path.split('/').pop() : 'file';\n return `Wrote ${lines} line${lines === 1 ? '' : 's'} to ${fileName}`;\n}\n\n/**\n * Generate diff content and file name for Edit/Write tools\n */\nfunction extractEditWriteInfo(\n toolName: string,\n input: Record<string, unknown>,\n): { diffContent?: string; fileName?: string } {\n const fileName =\n typeof input.file_path === 'string'\n ? input.file_path\n : typeof input.path === 'string'\n ? input.path\n : undefined;\n\n if (toolName === 'Edit' && fileName) {\n const oldString =\n typeof input.old_string === 'string' ? input.old_string : '';\n const newString =\n typeof input.new_string === 'string' ? input.new_string : '';\n const diffContent = generateEditDiff(fileName, oldString, newString);\n return { diffContent, fileName };\n }\n\n if (toolName === 'Write' && fileName) {\n const content = typeof input.content === 'string' ? input.content : '';\n const diffContent = generateEditDiff(fileName, '', content);\n return { diffContent, fileName };\n }\n\n return {};\n}\n\n/**\n * Extract result summary from tool result content\n */\nexport function extractResultSummary(\n toolName: string,\n resultContent: unknown,\n input?: Record<string, unknown>,\n): string | undefined {\n // Handle string content\n const content =\n typeof resultContent === 'string'\n ? resultContent\n : Array.isArray(resultContent)\n ? resultContent.map((c: any) => c.text || '').join('\\n')\n : '';\n\n if (!content) return undefined;\n\n switch (toolName) {\n case 'Glob': {\n // Count non-empty lines (each line is a file path)\n const lines = content\n .trim()\n .split('\\n')\n .filter((l: string) => l.trim());\n return `Found ${lines.length} files`;\n }\n case 'Read': {\n // Count lines in the file content\n const lineCount = content.split('\\n').length;\n return `Read ${lineCount} lines`;\n }\n case 'Grep': {\n // Count match lines\n const lines = content\n .trim()\n .split('\\n')\n .filter((l: string) => l.trim());\n return `Found ${lines.length} matches`;\n }\n case 'Edit': {\n if (input) {\n return extractEditSummary(input);\n }\n return undefined;\n }\n case 'Write': {\n if (input) {\n return extractWriteSummary(input);\n }\n return undefined;\n }\n default:\n return undefined;\n }\n}\n\n/**\n * Process SDK messages and provide user feedback.\n * Handles assistant text, tool use, tool results, and system messages.\n */\nexport function processSDKMessage(\n message: SDKMessage,\n options: WizardOptions,\n collectedText: string[],\n pendingToolCalls: Map<string, PendingToolCall>,\n isInterrupting: boolean,\n): void {\n logToFile(`SDK Message: ${message.type}`, JSON.stringify(message, null, 2));\n\n if (options.debug) {\n debug(`SDK Message type: ${message.type}`);\n }\n\n switch (message.type) {\n case 'assistant': {\n // Extract text content from assistant messages\n const content = message.message?.content;\n if (Array.isArray(content)) {\n for (const block of content) {\n if (block.type === 'text' && typeof block.text === 'string') {\n collectedText.push(block.text);\n\n // Add agent message to history for visibility\n ui.addItem({\n type: 'agent-message',\n text: block.text,\n });\n }\n // Handle tool_use blocks - store pending, don't add to history yet\n if (block.type === 'tool_use') {\n const toolName = block.name || 'Unknown tool';\n const toolInput = block.input || {};\n const toolUseId = block.id;\n logToFile(\n `Tool use requested: ${toolName} (id: ${toolUseId})`,\n toolInput,\n );\n\n // Skip storing/displaying internal SDK tools\n if (INTERNAL_TOOLS.has(toolName)) {\n continue;\n }\n\n // Store pending tool call to complete when result arrives\n pendingToolCalls.set(toolUseId, {\n toolName,\n input: toolInput,\n description:\n typeof toolInput.description === 'string'\n ? toolInput.description\n : undefined,\n });\n }\n }\n }\n break;\n }\n\n case 'user': {\n // Tool results come as 'user' messages with tool_result content\n const content = message.message?.content;\n if (Array.isArray(content)) {\n for (const block of content) {\n if (block.type === 'tool_result') {\n const toolUseId = block.tool_use_id;\n const isError = block.is_error === true;\n const resultContent = block.content;\n\n logToFile(`Tool result for ${toolUseId}:`, {\n isError,\n content: resultContent,\n });\n\n // Look up the pending tool call\n const pendingCall = pendingToolCalls.get(toolUseId);\n if (pendingCall) {\n pendingToolCalls.delete(toolUseId);\n\n // Extract diff content and file name for Edit/Write tools\n const { diffContent, fileName } = extractEditWriteInfo(\n pendingCall.toolName,\n pendingCall.input,\n );\n\n // Skip displaying Write tool calls for plan files\n const isPlanWrite =\n pendingCall.toolName === 'Write' &&\n fileName &&\n fileName.includes('plans/');\n\n if (isPlanWrite) {\n // Don't add plan writes to history\n continue;\n }\n\n // Extract result summary based on tool type\n const resultSummary = extractResultSummary(\n pendingCall.toolName,\n resultContent,\n pendingCall.input,\n );\n\n // Add completed tool call to history\n ui.addItem({\n type: 'tool-call',\n text: pendingCall.toolName,\n toolCall: {\n toolName: pendingCall.toolName,\n status: isError ? 'error' : 'success',\n input: pendingCall.input,\n description: pendingCall.description,\n result: resultSummary,\n error: isError ? String(resultContent) : undefined,\n diffContent,\n fileName,\n },\n });\n }\n\n if (isError && options.debug) {\n debug(`Tool error: ${resultContent}`);\n }\n }\n }\n }\n break;\n }\n\n case 'result': {\n if (message.subtype === 'success') {\n logToFile('Agent completed successfully');\n if (typeof message.result === 'string') {\n collectedText.push(message.result);\n // Note: We intentionally don't display the result message here.\n // The SDK's result.result field contains the same text as the last\n // assistant message, which we already render above. Displaying both\n // would cause duplicate output in the UI.\n }\n } else {\n // Error result - suppress if it's an interrupt-related error\n logToFile('Agent error result:', message.subtype);\n if (message.errors && !isInterrupting) {\n for (const err of message.errors) {\n // Check if error is interrupt-related\n const errStr = String(err);\n const isInterruptError =\n errStr.includes('aborted') ||\n errStr.includes('interrupted') ||\n errStr.includes('403');\n if (!isInterruptError) {\n ui.addItem({ type: 'error', text: `Error: ${err}` });\n }\n logToFile('ERROR:', err);\n }\n }\n }\n break;\n }\n\n case 'system': {\n if (message.subtype === 'init') {\n logToFile('Agent session initialized', {\n model: message.model,\n tools: message.tools?.length,\n });\n }\n break;\n }\n\n default:\n // Log other message types for debugging\n if (options.debug) {\n debug(`Unhandled message type: ${message.type}`);\n }\n break;\n }\n}\n"]}
1
+ {"version":3,"file":"sdk-messages.js","sourceRoot":"","sources":["../../../src/lib/sdk-messages.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAChC,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAGrD,OAAO,EAAE,mBAAmB,EAAE,MAAM,MAAM,CAAC;AAM3C,6DAA6D;AAC7D,MAAM,cAAc,GAAG,IAAI,GAAG,CAAC;IAC7B,MAAM;IACN,iBAAiB;IACjB,WAAW;IACX,2CAA2C;IAC3C,yCAAyC;IACzC,yCAAyC;IACzC,eAAe;IACf,cAAc;CACf,CAAC,CAAC;AAEH;;GAEG;AACH,SAAS,gBAAgB,CACvB,QAAgB,EAChB,SAAiB,EACjB,SAAiB;IAEjB,OAAO,mBAAmB,CACxB,QAAQ,EACR,QAAQ,EACR,SAAS,EACT,SAAS,EACT,EAAE,EAAE,aAAa;IACjB,EAAE,EAAE,aAAa;IACjB,EAAE,OAAO,EAAE,CAAC,EAAE,CACf,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,SAAS,kBAAkB,CAAC,KAA8B;IACxD,MAAM,SAAS,GACb,OAAO,KAAK,CAAC,UAAU,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE,CAAC;IAC/D,MAAM,SAAS,GACb,OAAO,KAAK,CAAC,UAAU,KAAK,QAAQ,CAAC,CAAC,C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CAAC;YACD,MAAM;IACV,CAAC;AACH,CAAC","sourcesContent":["/**\n * SDK message processing utilities\n * Handles parsing and displaying SDK messages from the Claude agent\n */\n\nimport ui from '../utils/ui.js';\nimport { debug, logToFile } from '../utils/debug.js';\nimport type { PendingToolCall } from './handlers.js';\nimport type { WizardOptions } from '../utils/types.js';\nimport { createTwoFilesPatch } from 'diff';\n\n// Using `any` because typed imports from ESM modules require import attributes\n// syntax which prettier cannot parse.\ntype SDKMessage = any;\n\n/** Internal SDK tools that should not be stored/displayed */\nconst INTERNAL_TOOLS = new Set([\n 'Task',\n 'AskUserQuestion',\n 'TodoWrite',\n 'mcp__raindrop-wizard__CompleteIntegration',\n 'mcp__raindrop-wizard__LoadDocumentation',\n 'mcp__raindrop-wizard__InitializeSession',\n 'EnterPlanMode',\n 'ExitPlanMode',\n]);\n\n/**\n * Generate a unified diff for Edit tool inputs (old_string -> new_string)\n */\nfunction generateEditDiff(\n filePath: string,\n oldString: string,\n newString: string,\n): string {\n return createTwoFilesPatch(\n filePath,\n filePath,\n oldString,\n newString,\n '', // old header\n '', // new header\n { context: 3 }, // context lines\n );\n}\n\n/**\n * Extract summary for Edit tool (line changes)\n */\nfunction extractEditSummary(input: Record<string, unknown>): string {\n const oldString =\n typeof input.old_string === 'string' ? input.old_string : '';\n const newString =\n typeof input.new_string === 'string' ? input.new_string : '';\n\n const oldLines = oldString ? oldString.split('\\n').length : 0;\n const newLines = newString ? newString.split('\\n').length : 0;\n\n const added = Math.max(0, newLines - oldLines);\n const removed = Math.max(0, oldLines - newLines);\n\n // Handle the case where lines are replaced (same count but different content)\n if (added === 0 && removed === 0 && oldString !== newString) {\n return `Updated ${oldLines} line${oldLines === 1 ? '' : 's'}`;\n }\n\n const parts: string[] = [];\n if (added > 0) parts.push(`Added ${added} line${added === 1 ? '' : 's'}`);\n if (removed > 0)\n parts.push(`removed ${removed} line${removed === 1 ? '' : 's'}`);\n\n return parts.length > 0 ? parts.join(', ') : 'No changes';\n}\n\n/**\n * Extract summary for Write tool (lines written)\n */\nfunction extractWriteSummary(input: Record<string, unknown>): string {\n const content = typeof input.content === 'string' ? input.content : '';\n const lines = content ? content.split('\\n').length : 0;\n const fileName =\n typeof input.path === 'string' ? input.path.split('/').pop() : 'file';\n return `Wrote ${lines} line${lines === 1 ? '' : 's'} to ${fileName}`;\n}\n\n/**\n * Generate diff content and file name for Edit/Write tools\n */\nfunction extractEditWriteInfo(\n toolName: string,\n input: Record<string, unknown>,\n): { diffContent?: string; fileName?: string } {\n const fileName =\n typeof input.file_path === 'string'\n ? input.file_path\n : typeof input.path === 'string'\n ? input.path\n : undefined;\n\n if (toolName === 'Edit' && fileName) {\n const oldString =\n typeof input.old_string === 'string' ? input.old_string : '';\n const newString =\n typeof input.new_string === 'string' ? input.new_string : '';\n const diffContent = generateEditDiff(fileName, oldString, newString);\n return { diffContent, fileName };\n }\n\n if (toolName === 'Write' && fileName) {\n const content = typeof input.content === 'string' ? input.content : '';\n const diffContent = generateEditDiff(fileName, '', content);\n return { diffContent, fileName };\n }\n\n return {};\n}\n\n/**\n * Extract result summary from tool result content\n */\nexport function extractResultSummary(\n toolName: string,\n resultContent: unknown,\n input?: Record<string, unknown>,\n): string | undefined {\n // Handle string content\n const content =\n typeof resultContent === 'string'\n ? resultContent\n : Array.isArray(resultContent)\n ? resultContent.map((c: any) => c.text || '').join('\\n')\n : '';\n\n if (!content) return undefined;\n\n switch (toolName) {\n case 'Glob': {\n // Count non-empty lines (each line is a file path)\n const lines = content\n .trim()\n .split('\\n')\n .filter((l: string) => l.trim());\n return `Found ${lines.length} files`;\n }\n case 'Read': {\n // Count lines in the file content\n const lineCount = content.split('\\n').length;\n return `Read ${lineCount} lines`;\n }\n case 'Grep': {\n // Count match lines\n const lines = content\n .trim()\n .split('\\n')\n .filter((l: string) => l.trim());\n return `Found ${lines.length} matches`;\n }\n case 'Edit': {\n if (input) {\n return extractEditSummary(input);\n }\n return undefined;\n }\n case 'Write': {\n if (input) {\n return extractWriteSummary(input);\n }\n return undefined;\n }\n default:\n return undefined;\n }\n}\n\n/**\n * Build a contextual spinner message based on the completed tool call.\n */\nfunction getToolSpinnerMessage(\n toolName: string,\n input: Record<string, unknown>,\n): string {\n switch (toolName) {\n case 'Grep':\n return `Analysing results`;\n case 'Read':\n return `Analysing`;\n case 'Bash':\n return `Analysing output`;\n case 'Edit':\n case 'Write':\n return `Working`;\n case 'Glob':\n return `Browsing files`;\n case 'WebSearch':\n return `Searching the web`;\n case 'WebFetch':\n return `Fetching documentation`;\n case 'EnterPlanMode':\n return `Planning`;\n default:\n if (toolName.startsWith('mcp__raindrop-wizard__Load')) {\n return `Loading Raindrop documentation`;\n }\n return `Working`;\n }\n}\n\n/**\n * Context passed into processSDKMessage for spinner updates.\n */\nexport interface SDKMessageContext {\n updateSpinner: (msg: string) => void;\n baseSpinnerMessage: string;\n}\n\n/**\n * Process SDK messages and provide user feedback.\n * Handles assistant text, tool use, tool results, and system messages.\n */\nexport function processSDKMessage(\n message: SDKMessage,\n options: WizardOptions,\n collectedText: string[],\n pendingToolCalls: Map<string, PendingToolCall>,\n isInterrupting: boolean,\n context?: SDKMessageContext,\n): void {\n logToFile(`SDK Message: ${message.type}`, JSON.stringify(message, null, 2));\n\n if (options.debug) {\n debug(`SDK Message type: ${message.type}`);\n }\n\n switch (message.type) {\n case 'assistant': {\n // Extract text content from assistant messages\n const content = message.message?.content;\n if (Array.isArray(content)) {\n for (const block of content) {\n if (block.type === 'text' && typeof block.text === 'string') {\n collectedText.push(block.text);\n\n // Add agent message to history for visibility\n ui.addItem({\n type: 'agent-message',\n text: block.text,\n });\n\n // Reset spinner after assistant responds — \"Analysing\" after \"Perfect!\" looks wrong\n if (context?.updateSpinner) {\n context.updateSpinner(context.baseSpinnerMessage);\n }\n }\n // Handle tool_use blocks - store pending, don't add to history yet\n if (block.type === 'tool_use') {\n const toolName = block.name || 'Unknown tool';\n const toolInput = block.input || {};\n const toolUseId = block.id;\n logToFile(\n `Tool use requested: ${toolName} (id: ${toolUseId})`,\n toolInput,\n );\n\n // Skip storing/displaying internal SDK tools\n if (INTERNAL_TOOLS.has(toolName)) {\n continue;\n }\n\n // Show tool as executing immediately (pretooluse)\n const historyItemId = ui.addItem({\n type: 'tool-call',\n text: toolName,\n toolCall: {\n toolName,\n status: 'executing',\n input: toolInput,\n description:\n typeof toolInput.description === 'string'\n ? toolInput.description\n : undefined,\n },\n });\n\n // Store pending tool call with history ID so we can update it on completion\n pendingToolCalls.set(toolUseId, {\n toolName,\n input: toolInput,\n description:\n typeof toolInput.description === 'string'\n ? toolInput.description\n : undefined,\n historyItemId,\n });\n }\n }\n }\n break;\n }\n\n case 'user': {\n // Tool results come as 'user' messages with tool_result content\n const content = message.message?.content;\n if (Array.isArray(content)) {\n for (const block of content) {\n if (block.type === 'tool_result') {\n const toolUseId = block.tool_use_id;\n const isError = block.is_error === true;\n const resultContent = block.content;\n\n logToFile(`Tool result for ${toolUseId}:`, {\n isError,\n content: resultContent,\n });\n\n // Look up the pending tool call\n const pendingCall = pendingToolCalls.get(toolUseId);\n if (pendingCall) {\n pendingToolCalls.delete(toolUseId);\n\n // Extract diff content and file name for Edit/Write tools\n const { diffContent, fileName } = extractEditWriteInfo(\n pendingCall.toolName,\n pendingCall.input,\n );\n\n // Skip displaying tool calls for plan files\n if (fileName && fileName.includes('plans/')) {\n continue;\n }\n\n // Extract result summary based on tool type\n const resultSummary = extractResultSummary(\n pendingCall.toolName,\n resultContent,\n pendingCall.input,\n );\n\n // Update the existing 'executing' history item with the final result (posttooluse)\n const completedToolCall = {\n toolName: pendingCall.toolName,\n status: (isError ? 'error' : 'success') as 'error' | 'success',\n input: pendingCall.input,\n description: pendingCall.description,\n result: resultSummary,\n error: isError\n ? `Error: ${String(resultContent).replace(/<\\/?tool_use_error>/g, '').trim()}`\n : undefined,\n diffContent,\n fileName,\n };\n if (pendingCall.historyItemId !== undefined) {\n ui.updateItem(pendingCall.historyItemId, {\n type: 'tool-call',\n text: pendingCall.toolName,\n toolCall: completedToolCall,\n });\n } else {\n ui.addItem({\n type: 'tool-call',\n text: pendingCall.toolName,\n toolCall: completedToolCall,\n });\n }\n\n // Update spinner with contextual message after tool completes (skip errors)\n if (!isError && context?.updateSpinner) {\n context.updateSpinner(\n getToolSpinnerMessage(pendingCall.toolName, pendingCall.input),\n );\n }\n }\n\n if (isError && options.debug) {\n debug(`Tool error: ${resultContent}`);\n }\n }\n }\n }\n break;\n }\n\n case 'result': {\n if (message.subtype === 'success') {\n logToFile('Agent completed successfully');\n if (typeof message.result === 'string') {\n collectedText.push(message.result);\n // Note: We intentionally don't display the result message here.\n // The SDK's result.result field contains the same text as the last\n // assistant message, which we already render above. Displaying both\n // would cause duplicate output in the UI.\n }\n } else {\n // Error result - suppress if it's an interrupt-related error\n logToFile('Agent error result:', message.subtype);\n if (message.errors && !isInterrupting) {\n for (const err of message.errors) {\n // Check if error is interrupt-related\n const errStr = String(err);\n const isInterruptError =\n errStr.includes('aborted') ||\n errStr.includes('interrupted') ||\n errStr.includes('403');\n if (!isInterruptError) {\n ui.addItem({ type: 'error', text: `Error: ${err}` });\n }\n logToFile('ERROR:', err);\n }\n }\n }\n break;\n }\n\n case 'system': {\n if (message.subtype === 'init') {\n logToFile('Agent session initialized', {\n model: message.model,\n tools: message.tools?.length,\n });\n }\n break;\n }\n\n default:\n // Log other message types for debugging\n if (options.debug) {\n debug(`Unhandled message type: ${message.type}`);\n }\n break;\n }\n}\n"]}
@@ -92,27 +92,23 @@ export async function runWizard(options) {
92
92
  const agent = initializeAgent({
93
93
  workingDirectory: options.installDir,
94
94
  }, options);
95
- let prompt = 'begin';
96
- let resume = undefined;
97
- let shouldContinue = true;
98
- while (shouldContinue) {
99
- const agentResult = await runAgentLoop(agent, prompt, options, {
100
- spinnerMessage: SPINNER_MESSAGE,
101
- successMessage: 'Raindrop integration complete',
102
- resume,
103
- accessToken: token.token,
104
- orgId: token.orgId.toString(),
95
+ const agentResult = await runAgentLoop(agent, `Your WIZARD SESSION ID is ${options.sessionId}. Begin the integration.`, options, {
96
+ spinnerMessage: SPINNER_MESSAGE,
97
+ successMessage: 'Raindrop integration complete',
98
+ accessToken: token.token,
99
+ orgId: token.orgId.toString(),
100
+ onCompleteIntegration: async () => {
101
+ // Ensure persistent input is stopped before testing phase
102
+ ui.stopPersistentInput();
103
+ return testIntegration(options, writeKey, token.token, token.orgId.toString());
104
+ },
105
+ });
106
+ if (!agentResult.completed) {
107
+ ui.addItem({
108
+ type: 'warning',
109
+ text: 'Integration session ended before confirmation. You can rerun the wizard to continue.',
105
110
  });
106
- // Ensure persistent input is stopped before testing phase
107
- ui.stopPersistentInput();
108
- const result = await testIntegration(options, writeKey, token.token);
109
- if (result.shouldRetry && result.feedbackPrompt) {
110
- prompt = result.feedbackPrompt;
111
- resume = agentResult.sessionId;
112
- }
113
- else {
114
- shouldContinue = false;
115
- }
111
+ return;
116
112
  }
117
113
  // Build outro message
118
114
  const nextSteps = [
@@ -1 +1 @@
1
- {"version":3,"file":"wizard.js","sourceRoot":"","sources":["../../../src/lib/wizard.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,EACL,iBAAiB,EACjB,iCAAiC,GAClC,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAEnD,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAChC,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACrE,OAAO,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACrE,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAE3D,0DAA0D;AAC1D,MAAM,KAAK,GAAG,KAAY,CAAC;AAE3B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,OAAO,CAAC,CAAC;IAElB,MAAM,YAAY,GAAG,GAAG,KAAK,CAAC,KAAK,CAAC,kCAAkC,CAAC;;EAEvE,KAAK,CAAC,MAAM,CAAC,aAAa,CAAC;EAC3B,SAAS,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC;;cAEnC,KAAK,CAAC,IAAI,CAAC,8BAA8B,CAAC;EACtD,KAAK,CAAC,GAAG,CACT,iHAAiH,CAClH,EAAE,CAAC;IAEF,EAAE,CAAC,OAAO,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,YAAY,EAAE,CAAC,CAAC;AACtD,CAAC","sourcesContent":["import Chalk from 'chalk';\nimport clipboardy from 'clipboardy';\nimport {\n askForWizardLogin,\n confirmContinueIfNoOrDirtyGitRepo,\n} from '../utils/clack-utils.js';\nimport { enableDebugLogs } from '../utils/debug.js';\nimport { saveWriteKeyToEnv } from '../utils/environment.js';\nimport { getOrgWriteKey } from '../utils/oauth.js';\nimport type { WizardOptions } from '../utils/types.js';\nimport ui from '../utils/ui.js';\nimport { initializeAgent, runAgentLoop } from './agent-interface.js';\nimport { ANTHROPIC_BASE_URL, SPINNER_MESSAGE } from './constants.js';\nimport { testIntegration } from './integration-testing.js';\n\n// chalk v2 types don't work well with ESM default imports\nconst chalk = Chalk as any;\n\n/**\n * Unified wizard powered by the universal agent runner.\n * The agent will detect the integration type and load appropriate documentation.\n */\nexport async function runWizard(options: WizardOptions): Promise<void> {\n if (options.debug) {\n enableDebugLogs();\n }\n\n // Check if the current directory is a git repository and has uncommitted or untracked changes; prompt the user to continue if so.\n await confirmContinueIfNoOrDirtyGitRepo(options);\n\n const token = await askForWizardLogin();\n\n // Set the wizard JWT in process.env for the SDK\n process.env.ANTHROPIC_AUTH_TOKEN = token.token;\n\n const writeKeySpinner = ui.spinner();\n writeKeySpinner.start('Retrieving your Raindrop write key...');\n\n let writeKey: string;\n try {\n const result = await getOrgWriteKey(token.token);\n writeKey = result.writeKey;\n } catch (error) {\n writeKeySpinner.stop('Failed to retrieve write key');\n ui.addItem({\n type: 'error',\n text: `Error: ${error instanceof Error ? error.message : String(error)}`,\n });\n throw error;\n }\n\n writeKeySpinner.stop();\n\n // Show org info and write key in a beautiful box\n ui.addItem({\n type: 'org-info',\n text: 'Organization info',\n orgName: token.orgName,\n writeKey,\n });\n\n // Prompt user for what to do with the write key\n const writeKeyAction = await ui.feedbackSelect({\n message: `What would you like to do with your ${chalk.cyan(\n 'RAINDROP_WRITE_KEY',\n )}?`,\n options: [\n { value: 'add-env', label: 'Add to .env' },\n { value: 'copy', label: 'Copy to clipboard' },\n { value: 'continue', label: 'Continue' },\n ],\n skipHistory: true,\n });\n\n // Determine the label for the history item based on action taken\n let writeKeyLabel: string | undefined;\n\n if (writeKeyAction.type === 'option') {\n if (writeKeyAction.value === 'add-env') {\n try {\n await saveWriteKeyToEnv(writeKey, options.installDir);\n writeKeyLabel = 'saved to .env';\n } catch (error) {\n ui.addItem({\n type: 'error',\n text: `Failed to add write key to .env: ${\n error instanceof Error ? error.message : String(error)\n }`,\n });\n }\n } else if (writeKeyAction.value === 'copy') {\n try {\n await clipboardy.write(`RAINDROP_WRITE_KEY=${writeKey}`);\n writeKeyLabel = 'copied to clipboard';\n } catch (error) {\n ui.addItem({\n type: 'error',\n text: `Failed to copy to clipboard: ${\n error instanceof Error ? error.message : String(error)\n }`,\n });\n }\n }\n // For 'continue', writeKeyLabel remains undefined\n }\n\n process.env.ANTHROPIC_BASE_URL = ANTHROPIC_BASE_URL;\n process.env.ANTHROPIC_AUTH_TOKEN = token.token;\n process.env.ANTHROPIC_CUSTOM_HEADERS = `x-wizard-session: ${options.sessionId}`;\n\n // Initialize agent\n const agent = initializeAgent(\n {\n workingDirectory: options.installDir,\n },\n options,\n );\n\n let prompt = 'begin';\n let resume: string | undefined = undefined;\n let shouldContinue = true;\n\n while (shouldContinue) {\n const agentResult = await runAgentLoop(agent, prompt, options, {\n spinnerMessage: SPINNER_MESSAGE,\n successMessage: 'Raindrop integration complete',\n resume,\n accessToken: token.token,\n orgId: token.orgId.toString(),\n });\n\n // Ensure persistent input is stopped before testing phase\n ui.stopPersistentInput();\n\n const result = await testIntegration(options, writeKey, token.token);\n\n if (result.shouldRetry && result.feedbackPrompt) {\n prompt = result.feedbackPrompt;\n resume = agentResult.sessionId;\n } else {\n shouldContinue = false;\n }\n }\n\n // Build outro message\n const nextSteps = [\n 'Configure your API key in environment variables for deployment',\n 'Start using Raindrop in your application',\n ].filter(Boolean);\n\n const outroMessage = `${chalk.white('Raindrop successfully integrated')}\n\n${chalk.yellow('Next steps:')}\n${nextSteps.map((step) => `• ${step}`).join('\\n')}\n\nLearn more: ${chalk.cyan('https://www.raindrop.ai/docs')}\n${chalk.dim(\n 'Note: The Raindrop wizard uses an LLM agent to analyze and modify your project. Please review the changes made.',\n)}`;\n\n ui.addItem({ type: 'success', text: outroMessage });\n}\n"]}
1
+ {"version":3,"file":"wizard.js","sourceRoot":"","sources":["../../../src/lib/wizard.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,EACL,iBAAiB,EACjB,iCAAiC,GAClC,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAEnD,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAChC,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACrE,OAAO,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACrE,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAE3D,0DAA0D;AAC1D,MA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CAAC;;EAEvE,KAAK,CAAC,MAAM,CAAC,aAAa,CAAC;EAC3B,SAAS,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC;;cAEnC,KAAK,CAAC,IAAI,CAAC,8BAA8B,CAAC;EACtD,KAAK,CAAC,GAAG,CACT,iHAAiH,CAClH,EAAE,CAAC;IAEF,EAAE,CAAC,OAAO,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,YAAY,EAAE,CAAC,CAAC;AACtD,CAAC","sourcesContent":["import Chalk from 'chalk';\nimport clipboardy from 'clipboardy';\nimport {\n askForWizardLogin,\n confirmContinueIfNoOrDirtyGitRepo,\n} from '../utils/clack-utils.js';\nimport { enableDebugLogs } from '../utils/debug.js';\nimport { saveWriteKeyToEnv } from '../utils/environment.js';\nimport { getOrgWriteKey } from '../utils/oauth.js';\nimport type { WizardOptions } from '../utils/types.js';\nimport ui from '../utils/ui.js';\nimport { initializeAgent, runAgentLoop } from './agent-interface.js';\nimport { ANTHROPIC_BASE_URL, SPINNER_MESSAGE } from './constants.js';\nimport { testIntegration } from './integration-testing.js';\n\n// chalk v2 types don't work well with ESM default imports\nconst chalk = Chalk as any;\n\n/**\n * Unified wizard powered by the universal agent runner.\n * The agent will detect the integration type and load appropriate documentation.\n */\nexport async function runWizard(options: WizardOptions): Promise<void> {\n if (options.debug) {\n enableDebugLogs();\n }\n\n // Check if the current directory is a git repository and has uncommitted or untracked changes; prompt the user to continue if so.\n await confirmContinueIfNoOrDirtyGitRepo(options);\n\n const token = await askForWizardLogin();\n\n // Set the wizard JWT in process.env for the SDK\n process.env.ANTHROPIC_AUTH_TOKEN = token.token;\n\n const writeKeySpinner = ui.spinner();\n writeKeySpinner.start('Retrieving your Raindrop write key...');\n\n let writeKey: string;\n try {\n const result = await getOrgWriteKey(token.token);\n writeKey = result.writeKey;\n } catch (error) {\n writeKeySpinner.stop('Failed to retrieve write key');\n ui.addItem({\n type: 'error',\n text: `Error: ${error instanceof Error ? error.message : String(error)}`,\n });\n throw error;\n }\n\n writeKeySpinner.stop();\n\n // Show org info and write key in a beautiful box\n ui.addItem({\n type: 'org-info',\n text: 'Organization info',\n orgName: token.orgName,\n writeKey,\n });\n\n // Prompt user for what to do with the write key\n const writeKeyAction = await ui.feedbackSelect({\n message: `What would you like to do with your ${chalk.cyan(\n 'RAINDROP_WRITE_KEY',\n )}?`,\n options: [\n { value: 'add-env', label: 'Add to .env' },\n { value: 'copy', label: 'Copy to clipboard' },\n { value: 'continue', label: 'Continue' },\n ],\n skipHistory: true,\n });\n\n // Determine the label for the history item based on action taken\n let writeKeyLabel: string | undefined;\n\n if (writeKeyAction.type === 'option') {\n if (writeKeyAction.value === 'add-env') {\n try {\n await saveWriteKeyToEnv(writeKey, options.installDir);\n writeKeyLabel = 'saved to .env';\n } catch (error) {\n ui.addItem({\n type: 'error',\n text: `Failed to add write key to .env: ${\n error instanceof Error ? error.message : String(error)\n }`,\n });\n }\n } else if (writeKeyAction.value === 'copy') {\n try {\n await clipboardy.write(`RAINDROP_WRITE_KEY=${writeKey}`);\n writeKeyLabel = 'copied to clipboard';\n } catch (error) {\n ui.addItem({\n type: 'error',\n text: `Failed to copy to clipboard: ${\n error instanceof Error ? error.message : String(error)\n }`,\n });\n }\n }\n // For 'continue', writeKeyLabel remains undefined\n }\n\n process.env.ANTHROPIC_BASE_URL = ANTHROPIC_BASE_URL;\n process.env.ANTHROPIC_AUTH_TOKEN = token.token;\n process.env.ANTHROPIC_CUSTOM_HEADERS = `x-wizard-session: ${options.sessionId}`;\n\n // Initialize agent\n const agent = initializeAgent(\n {\n workingDirectory: options.installDir,\n },\n options,\n );\n\n const agentResult = await runAgentLoop(\n agent,\n `Your WIZARD SESSION ID is ${options.sessionId}. Begin the integration.`,\n options,\n {\n spinnerMessage: SPINNER_MESSAGE,\n successMessage: 'Raindrop integration complete',\n accessToken: token.token,\n orgId: token.orgId.toString(),\n onCompleteIntegration: async () => {\n // Ensure persistent input is stopped before testing phase\n ui.stopPersistentInput();\n return testIntegration(options, writeKey, token.token, token.orgId.toString());\n },\n },\n );\n\n if (!agentResult.completed) {\n ui.addItem({\n type: 'warning',\n text: 'Integration session ended before confirmation. You can rerun the wizard to continue.',\n });\n return;\n }\n\n // Build outro message\n const nextSteps = [\n 'Configure your API key in environment variables for deployment',\n 'Start using Raindrop in your application',\n ].filter(Boolean);\n\n const outroMessage = `${chalk.white('Raindrop successfully integrated')}\n\n${chalk.yellow('Next steps:')}\n${nextSteps.map((step) => `• ${step}`).join('\\n')}\n\nLearn more: ${chalk.cyan('https://www.raindrop.ai/docs')}\n${chalk.dim(\n 'Note: The Raindrop wizard uses an LLM agent to analyze and modify your project. Please review the changes made.',\n)}`;\n\n ui.addItem({ type: 'success', text: outroMessage });\n}\n"]}
@@ -1,11 +1,12 @@
1
1
  /**
2
2
  * Main unified Ink app component.
3
- * Uses the Static + pending items pattern for efficient rendering.
3
+ * Uses a history + pending items rendering pattern.
4
4
  *
5
5
  * Architecture:
6
- * - <Static> renders completed history items once and "freezes" them
7
- * - activeSpinner renders above the pending item when agent is working
8
- * - pendingItem re-renders frequently during active prompts
6
+ * - history renders completed items (memoized to avoid unnecessary repaints)
7
+ * - activeSpinner shows a static indicator only re-renders when the message
8
+ * string changes (updated from agent-interface.ts at ~1Hz, not via Ink timer)
9
+ * - pendingItem re-renders during active prompts
9
10
  */
10
11
  import React from 'react';
11
12
  /**
@@ -1,27 +1,27 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  /**
3
3
  * Main unified Ink app component.
4
- * Uses the Static + pending items pattern for efficient rendering.
4
+ * Uses a history + pending items rendering pattern.
5
5
  *
6
6
  * Architecture:
7
- * - <Static> renders completed history items once and "freezes" them
8
- * - activeSpinner renders above the pending item when agent is working
9
- * - pendingItem re-renders frequently during active prompts
7
+ * - history renders completed items (memoized to avoid unnecessary repaints)
8
+ * - activeSpinner shows a static indicator only re-renders when the message
9
+ * string changes (updated from agent-interface.ts at ~1Hz, not via Ink timer)
10
+ * - pendingItem re-renders during active prompts
10
11
  */
12
+ import { Box, Text } from 'ink';
11
13
  import { useMemo } from 'react';
12
- import { Box, Static, Text } from 'ink';
13
- import InkSpinner from 'ink-spinner';
14
- import { useWizardState } from './contexts/WizardContext.js';
15
- import { HistoryItemDisplay } from './components/HistoryItemDisplay.js';
14
+ import HistoryItemDisplay from './components/HistoryItemDisplay.js';
16
15
  import { PendingPrompt } from './components/PendingPrompt.js';
16
+ import { useWizardState } from './contexts/WizardContext.js';
17
17
  /**
18
18
  * Main wizard app component
19
19
  */
20
20
  export function WizardApp() {
21
- const { history, pendingItem, activeSpinner } = useWizardState();
22
- // Memoize history items to prevent unnecessary re-renders
23
- const historyItems = useMemo(() => history.map((item) => (_jsx(Box, { marginBottom: 1, children: _jsx(HistoryItemDisplay, { item: item }) }, item.id))), [history]);
24
- return (_jsxs(Box, { flexDirection: "column", children: [_jsx(Static, { items: historyItems, children: (item) => item }), activeSpinner && (_jsxs(Box, { marginBottom: 1, children: [_jsx(Text, { color: "cyan", children: _jsx(InkSpinner, { type: "dots" }) }), _jsxs(Text, { children: [" ", activeSpinner] })] })), pendingItem && _jsx(PendingPrompt, { item: pendingItem }, pendingItem.type)] }));
21
+ const { history, pendingItem, activeSpinner, terminalSize } = useWizardState();
22
+ // Memoize history items to avoid rebuilding nodes when only pending UI changes
23
+ const historyItems = useMemo(() => history.map((item) => (_jsx(Box, { marginBottom: 1, children: _jsx(HistoryItemDisplay, { item: item, terminalWidth: terminalSize.width }) }, item.id))), [history, terminalSize.width]);
24
+ return (_jsxs(Box, { flexDirection: "column", width: terminalSize.width, children: [historyItems, activeSpinner && (_jsxs(Box, { marginBottom: 1, width: terminalSize.width, children: [_jsx(Text, { color: "cyan", children: "\u25C6" }), _jsx(Box, { width: Math.max(1, terminalSize.width - 2), children: _jsxs(Text, { wrap: "truncate-end", children: [" ", activeSpinner] }) })] })), pendingItem && (_jsx(PendingPrompt, { item: pendingItem }, pendingItem.type))] }));
25
25
  }
26
26
  export default WizardApp;
27
27
  //# sourceMappingURL=App.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"App.js","sourceRoot":"","sources":["../../../src/ui/App.tsx"],"names":[],"mappings":";AAAA;;;;;;;;GAQG;AAEH,OAAc,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AACvC,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,KAAK,CAAC;AACxC,OAAO,UAAU,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAC7D,OAAO,EAAE,kBAAkB,EAAE,MAAM,oCAAoC,CAAC;AACxE,OAAO,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAG9D;;GAEG;AACH,MAAM,UAAU,SAAS;IACvB,MAAM,EAAE,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,GAAG,cAAc,EAAE,CAAC;IAEjE,0DAA0D;IAC1D,MAAM,YAAY,GAAG,OAAO,CAC1B,GAAG,EAAE,CACH,OAAO,CAAC,GAAG,CAAC,CAAC,IAAiB,EAAE,EAAE,CAAC,CACjC,KAAC,GAAG,IAAe,YAAY,EAAE,CAAC,YAChC,KAAC,kBAAkB,IAAC,IAAI,EAAE,IAAI,GAAI,IAD1B,IAAI,CAAC,EAAE,CAEX,CACP,CAAC,EACJ,CAAC,OAAO,CAAC,CACV,CAAC;IAEF,OAAO,CACL,MAAC,GAAG,IAAC,aAAa,EAAC,QAAQ,aAEzB,KAAC,MAAM,IAAC,KAAK,EAAE,YAAY,YAAG,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,GAAU,EAGrD,aAAa,IAAI,CAChB,MAAC,GAAG,IAAC,YAAY,EAAE,CAAC,aAClB,KAAC,IAAI,IAAC,KAAK,EAAC,MAAM,YAChB,KAAC,UAAU,IAAC,IAAI,EAAC,MAAM,GAAG,GACrB,EACP,MAAC,IAAI,oBAAG,aAAa,IAAQ,IACzB,CACP,EAGA,WAAW,IAAI,KAAC,aAAa,IAAwB,IAAI,EAAE,WAAW,IAAnC,WAAW,CAAC,IAAI,CAAuB,IACvE,CACP,CAAC;AACJ,CAAC;AAED,eAAe,SAAS,CAAC","sourcesContent":["/**\n * Main unified Ink app component.\n * Uses the Static + pending items pattern for efficient rendering.\n *\n * Architecture:\n * - <Static> renders completed history items once and \"freezes\" them\n * - activeSpinner renders above the pending item when agent is working\n * - pendingItem re-renders frequently during active prompts\n */\n\nimport React, { useMemo } from 'react';\nimport { Box, Static, Text } from 'ink';\nimport InkSpinner from 'ink-spinner';\nimport { useWizardState } from './contexts/WizardContext.js';\nimport { HistoryItemDisplay } from './components/HistoryItemDisplay.js';\nimport { PendingPrompt } from './components/PendingPrompt.js';\nimport type { HistoryItem } from './contexts/WizardContext.js';\n\n/**\n * Main wizard app component\n */\nexport function WizardApp(): React.ReactElement {\n const { history, pendingItem, activeSpinner } = useWizardState();\n\n // Memoize history items to prevent unnecessary re-renders\n const historyItems = useMemo(\n () =>\n history.map((item: HistoryItem) => (\n <Box key={item.id} marginBottom={1}>\n <HistoryItemDisplay item={item} />\n </Box>\n )),\n [history],\n );\n\n return (\n <Box flexDirection=\"column\">\n {/* Static section: completed items rendered once */}\n <Static items={historyItems}>{(item) => item}</Static>\n\n {/* Spinner: shown above pending item when active */}\n {activeSpinner && (\n <Box marginBottom={1}>\n <Text color=\"cyan\">\n <InkSpinner type=\"dots\" />\n </Text>\n <Text> {activeSpinner}</Text>\n </Box>\n )}\n\n {/* Pending section: actively updating content */}\n {pendingItem && <PendingPrompt key={pendingItem.type} item={pendingItem} />}\n </Box>\n );\n}\n\nexport default WizardApp;\n"]}
1
+ {"version":3,"file":"App.js","sourceRoot":"","sources":["../../../src/ui/App.tsx"],"names":[],"mappings":";AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,KAAK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P,CAAC;AACJ,CAAC;AAED,eAAe,SAAS,CAAC","sourcesContent":["/**\n * Main unified Ink app component.\n * Uses a history + pending items rendering pattern.\n *\n * Architecture:\n * - history renders completed items (memoized to avoid unnecessary repaints)\n * - activeSpinner shows a static indicator — only re-renders when the message\n * string changes (updated from agent-interface.ts at ~1Hz, not via Ink timer)\n * - pendingItem re-renders during active prompts\n */\n\nimport { Box, Text } from 'ink';\nimport React, { useMemo } from 'react';\nimport HistoryItemDisplay from './components/HistoryItemDisplay.js';\nimport { PendingPrompt } from './components/PendingPrompt.js';\nimport type { HistoryItem } from './contexts/WizardContext.js';\nimport { useWizardState } from './contexts/WizardContext.js';\n\n/**\n * Main wizard app component\n */\nexport function WizardApp(): React.ReactElement {\n const { history, pendingItem, activeSpinner, terminalSize } =\n useWizardState();\n\n // Memoize history items to avoid rebuilding nodes when only pending UI changes\n const historyItems = useMemo(\n () =>\n history.map((item: HistoryItem) => (\n <Box key={item.id} marginBottom={1}>\n <HistoryItemDisplay item={item} terminalWidth={terminalSize.width} />\n </Box>\n )),\n [history, terminalSize.width],\n );\n\n return (\n <Box flexDirection=\"column\" width={terminalSize.width}>\n {/* History section */}\n {historyItems}\n\n {/* Spinner: static indicator, only re-renders when message string changes.\n Elapsed time is appended to the message from agent-interface.ts at ~1Hz. */}\n {activeSpinner && (\n <Box marginBottom={1} width={terminalSize.width}>\n <Text color=\"cyan\">◆</Text>\n <Box width={Math.max(1, terminalSize.width - 2)}>\n <Text wrap=\"truncate-end\"> {activeSpinner}</Text>\n </Box>\n </Box>\n )}\n\n {/* Pending section: actively updating content */}\n {pendingItem && (\n <PendingPrompt key={pendingItem.type} item={pendingItem} />\n )}\n </Box>\n );\n}\n\nexport default WizardApp;\n"]}
@@ -46,7 +46,7 @@ export function ClarifyingQuestionsPrompt({ props, }) {
46
46
  const { questions } = props;
47
47
  const { state, actions } = useWizard();
48
48
  const { resolvePending, addItem } = actions;
49
- const { agentState } = state;
49
+ const { agentState, terminalSize } = state;
50
50
  // Track current question index
51
51
  const [currentQuestionIndex, setCurrentQuestionIndex] = useState(0);
52
52
  // Track answers for each question
@@ -328,7 +328,9 @@ export function ClarifyingQuestionsPrompt({ props, }) {
328
328
  ? '[✓] '
329
329
  : '[ ] '
330
330
  : '';
331
- return (_jsxs(Box, { children: [_jsxs(Text, { color: isHighlighted ? 'cyan' : undefined, children: [indicator, displayNumber, ". ", checkbox] }), isTypingMode || customText ? (_jsx(TextInput, { value: customText, onChange: setCustomText, onSubmit: handleCustomTextSubmit, focus: isTypingMode, placeholder: "" })) : (_jsx(Text, { color: isHighlighted ? 'cyan' : undefined, children: item.label }))] }, item.value));
331
+ const optionNumber = `${displayNumber}. `;
332
+ const inputWidth = Math.max(1, terminalSize.width - indicator.length - optionNumber.length - checkbox.length);
333
+ return (_jsxs(Box, { width: terminalSize.width, children: [_jsxs(Text, { color: isHighlighted ? 'cyan' : undefined, children: [indicator, optionNumber, checkbox] }), isTypingMode || customText ? (_jsx(Box, { width: inputWidth, children: _jsx(TextInput, { value: customText, onChange: setCustomText, onSubmit: handleCustomTextSubmit, focus: isTypingMode, placeholder: "" }) })) : (_jsx(Box, { width: inputWidth, children: _jsx(Text, { color: isHighlighted ? 'cyan' : undefined, wrap: "truncate-end", children: item.label }) }))] }, item.value));
332
334
  }
333
335
  // Submit option
334
336
  if (isSubmitOption) {