@wundr.io/cli 1.0.10 → 1.0.12

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 (269) hide show
  1. package/bin/wundr.js +8 -4
  2. package/package.json +23 -23
  3. package/src/ai/ai-service.ts +16 -17
  4. package/src/ai/claude-client.ts +16 -16
  5. package/src/ai/conversation-manager.ts +29 -29
  6. package/src/cli.ts +4 -4
  7. package/src/commands/ai.ts +246 -78
  8. package/src/commands/alignment.ts +74 -74
  9. package/src/commands/analyze-optimized.ts +111 -78
  10. package/src/commands/analyze.ts +14 -14
  11. package/src/commands/batch.ts +179 -42
  12. package/src/commands/chat.ts +37 -30
  13. package/src/commands/claude-init.ts +41 -45
  14. package/src/commands/claude-setup.ts +204 -119
  15. package/src/commands/computer-setup.ts +85 -43
  16. package/src/commands/create-command.ts +4 -4
  17. package/src/commands/create.ts +27 -27
  18. package/src/commands/dashboard.ts +24 -24
  19. package/src/commands/govern.ts +25 -25
  20. package/src/commands/governance.ts +34 -34
  21. package/src/commands/guardian.ts +56 -56
  22. package/src/commands/init.ts +25 -22
  23. package/src/commands/orchestrator.ts +68 -41
  24. package/src/commands/performance-optimizer.ts +34 -35
  25. package/src/commands/plugins.ts +27 -27
  26. package/src/commands/project-update.ts +175 -72
  27. package/src/commands/rag.ts +185 -78
  28. package/src/commands/session.ts +35 -35
  29. package/src/commands/setup.ts +40 -344
  30. package/src/commands/test-init.ts +3 -3
  31. package/src/commands/test.ts +4 -4
  32. package/src/commands/watch.ts +28 -29
  33. package/src/commands/worktree.ts +49 -49
  34. package/src/context/context-manager.ts +10 -10
  35. package/src/context/session-manager.ts +41 -41
  36. package/src/framework/command-interface.ts +520 -0
  37. package/src/framework/command-registry.ts +942 -0
  38. package/src/framework/completion-exporter.ts +383 -0
  39. package/src/framework/debug-logger.ts +519 -0
  40. package/src/framework/error-handler.ts +867 -0
  41. package/src/framework/help-generator.ts +540 -0
  42. package/src/framework/index.ts +169 -0
  43. package/src/framework/interactive-repl.ts +703 -0
  44. package/src/framework/output-formatter.ts +834 -0
  45. package/src/framework/progress-manager.ts +539 -0
  46. package/src/index.ts +4 -4
  47. package/src/interactive/interactive-mode.ts +16 -16
  48. package/src/lib/conflict-resolution.ts +799 -9
  49. package/src/lib/merge-strategy.ts +529 -7
  50. package/src/lib/safety-mechanisms.ts +422 -18
  51. package/src/lib/state-detection.ts +1015 -13
  52. package/src/nlp/command-mapper.ts +29 -29
  53. package/src/nlp/command-parser.ts +17 -17
  54. package/src/nlp/intent-classifier.ts +7 -7
  55. package/src/nlp/intent-parser.ts +54 -52
  56. package/src/plugins/plugin-manager.ts +61 -39
  57. package/src/tests/computer-setup-integration.test.ts +46 -15
  58. package/src/types/modules.d.ts +424 -1
  59. package/src/utils/backup-rollback-manager.ts +11 -8
  60. package/src/utils/config-manager.ts +3 -3
  61. package/src/utils/error-handler.ts +2 -2
  62. package/src/utils/logger.ts +22 -22
  63. package/templates/batch/ci-cd.yaml +7 -7
  64. package/test-suites/api/health.spec.ts +20 -23
  65. package/test-suites/helpers/test-config.ts +14 -13
  66. package/test-suites/ui/accessibility.spec.ts +27 -22
  67. package/test-suites/ui/smoke.spec.ts +26 -21
  68. package/LICENSE +0 -21
  69. package/dist/ai/ai-service.d.ts +0 -152
  70. package/dist/ai/ai-service.d.ts.map +0 -1
  71. package/dist/ai/ai-service.js +0 -430
  72. package/dist/ai/ai-service.js.map +0 -1
  73. package/dist/ai/claude-client.d.ts +0 -130
  74. package/dist/ai/claude-client.d.ts.map +0 -1
  75. package/dist/ai/claude-client.js +0 -340
  76. package/dist/ai/claude-client.js.map +0 -1
  77. package/dist/ai/conversation-manager.d.ts +0 -164
  78. package/dist/ai/conversation-manager.d.ts.map +0 -1
  79. package/dist/ai/conversation-manager.js +0 -614
  80. package/dist/ai/conversation-manager.js.map +0 -1
  81. package/dist/ai/index.d.ts +0 -5
  82. package/dist/ai/index.d.ts.map +0 -1
  83. package/dist/ai/index.js +0 -8
  84. package/dist/ai/index.js.map +0 -1
  85. package/dist/cli.d.ts +0 -36
  86. package/dist/cli.d.ts.map +0 -1
  87. package/dist/cli.js +0 -192
  88. package/dist/cli.js.map +0 -1
  89. package/dist/commands/ai.d.ts +0 -89
  90. package/dist/commands/ai.d.ts.map +0 -1
  91. package/dist/commands/ai.js +0 -799
  92. package/dist/commands/ai.js.map +0 -1
  93. package/dist/commands/alignment.d.ts +0 -78
  94. package/dist/commands/alignment.d.ts.map +0 -1
  95. package/dist/commands/alignment.js +0 -817
  96. package/dist/commands/alignment.js.map +0 -1
  97. package/dist/commands/analyze-optimized.d.ts +0 -14
  98. package/dist/commands/analyze-optimized.d.ts.map +0 -1
  99. package/dist/commands/analyze-optimized.js +0 -600
  100. package/dist/commands/analyze-optimized.js.map +0 -1
  101. package/dist/commands/analyze.d.ts +0 -65
  102. package/dist/commands/analyze.d.ts.map +0 -1
  103. package/dist/commands/analyze.js +0 -435
  104. package/dist/commands/analyze.js.map +0 -1
  105. package/dist/commands/batch.d.ts +0 -71
  106. package/dist/commands/batch.d.ts.map +0 -1
  107. package/dist/commands/batch.js +0 -738
  108. package/dist/commands/batch.js.map +0 -1
  109. package/dist/commands/chat.d.ts +0 -71
  110. package/dist/commands/chat.d.ts.map +0 -1
  111. package/dist/commands/chat.js +0 -674
  112. package/dist/commands/chat.js.map +0 -1
  113. package/dist/commands/claude-init.d.ts +0 -28
  114. package/dist/commands/claude-init.d.ts.map +0 -1
  115. package/dist/commands/claude-init.js +0 -591
  116. package/dist/commands/claude-init.js.map +0 -1
  117. package/dist/commands/claude-setup.d.ts +0 -119
  118. package/dist/commands/claude-setup.d.ts.map +0 -1
  119. package/dist/commands/claude-setup.js +0 -1073
  120. package/dist/commands/claude-setup.js.map +0 -1
  121. package/dist/commands/computer-setup-commands.d.ts +0 -53
  122. package/dist/commands/computer-setup-commands.d.ts.map +0 -1
  123. package/dist/commands/computer-setup-commands.js +0 -705
  124. package/dist/commands/computer-setup-commands.js.map +0 -1
  125. package/dist/commands/computer-setup.d.ts +0 -7
  126. package/dist/commands/computer-setup.d.ts.map +0 -1
  127. package/dist/commands/computer-setup.js +0 -849
  128. package/dist/commands/computer-setup.js.map +0 -1
  129. package/dist/commands/create-command.d.ts +0 -7
  130. package/dist/commands/create-command.d.ts.map +0 -1
  131. package/dist/commands/create-command.js +0 -158
  132. package/dist/commands/create-command.js.map +0 -1
  133. package/dist/commands/create.d.ts +0 -74
  134. package/dist/commands/create.d.ts.map +0 -1
  135. package/dist/commands/create.js +0 -556
  136. package/dist/commands/create.js.map +0 -1
  137. package/dist/commands/dashboard.d.ts +0 -91
  138. package/dist/commands/dashboard.d.ts.map +0 -1
  139. package/dist/commands/dashboard.js +0 -538
  140. package/dist/commands/dashboard.js.map +0 -1
  141. package/dist/commands/govern.d.ts +0 -70
  142. package/dist/commands/govern.d.ts.map +0 -1
  143. package/dist/commands/govern.js +0 -481
  144. package/dist/commands/govern.js.map +0 -1
  145. package/dist/commands/governance.d.ts +0 -17
  146. package/dist/commands/governance.d.ts.map +0 -1
  147. package/dist/commands/governance.js +0 -703
  148. package/dist/commands/governance.js.map +0 -1
  149. package/dist/commands/guardian.d.ts +0 -20
  150. package/dist/commands/guardian.d.ts.map +0 -1
  151. package/dist/commands/guardian.js +0 -597
  152. package/dist/commands/guardian.js.map +0 -1
  153. package/dist/commands/init.d.ts +0 -59
  154. package/dist/commands/init.d.ts.map +0 -1
  155. package/dist/commands/init.js +0 -650
  156. package/dist/commands/init.js.map +0 -1
  157. package/dist/commands/orchestrator.d.ts +0 -7
  158. package/dist/commands/orchestrator.d.ts.map +0 -1
  159. package/dist/commands/orchestrator.js +0 -571
  160. package/dist/commands/orchestrator.js.map +0 -1
  161. package/dist/commands/performance-optimizer.d.ts +0 -30
  162. package/dist/commands/performance-optimizer.d.ts.map +0 -1
  163. package/dist/commands/performance-optimizer.js +0 -650
  164. package/dist/commands/performance-optimizer.js.map +0 -1
  165. package/dist/commands/plugins.d.ts +0 -87
  166. package/dist/commands/plugins.d.ts.map +0 -1
  167. package/dist/commands/plugins.js +0 -685
  168. package/dist/commands/plugins.js.map +0 -1
  169. package/dist/commands/rag.d.ts +0 -7
  170. package/dist/commands/rag.d.ts.map +0 -1
  171. package/dist/commands/rag.js +0 -748
  172. package/dist/commands/rag.js.map +0 -1
  173. package/dist/commands/session.d.ts +0 -41
  174. package/dist/commands/session.d.ts.map +0 -1
  175. package/dist/commands/session.js +0 -441
  176. package/dist/commands/session.js.map +0 -1
  177. package/dist/commands/setup.d.ts +0 -29
  178. package/dist/commands/setup.d.ts.map +0 -1
  179. package/dist/commands/setup.js +0 -397
  180. package/dist/commands/setup.js.map +0 -1
  181. package/dist/commands/test-init.d.ts +0 -9
  182. package/dist/commands/test-init.d.ts.map +0 -1
  183. package/dist/commands/test-init.js +0 -222
  184. package/dist/commands/test-init.js.map +0 -1
  185. package/dist/commands/test.d.ts +0 -25
  186. package/dist/commands/test.d.ts.map +0 -1
  187. package/dist/commands/test.js +0 -217
  188. package/dist/commands/test.js.map +0 -1
  189. package/dist/commands/vp.d.ts +0 -7
  190. package/dist/commands/vp.d.ts.map +0 -1
  191. package/dist/commands/vp.js +0 -571
  192. package/dist/commands/vp.js.map +0 -1
  193. package/dist/commands/watch.d.ts +0 -76
  194. package/dist/commands/watch.d.ts.map +0 -1
  195. package/dist/commands/watch.js +0 -613
  196. package/dist/commands/watch.js.map +0 -1
  197. package/dist/commands/worktree.d.ts +0 -63
  198. package/dist/commands/worktree.d.ts.map +0 -1
  199. package/dist/commands/worktree.js +0 -774
  200. package/dist/commands/worktree.js.map +0 -1
  201. package/dist/context/context-manager.d.ts +0 -155
  202. package/dist/context/context-manager.d.ts.map +0 -1
  203. package/dist/context/context-manager.js +0 -383
  204. package/dist/context/context-manager.js.map +0 -1
  205. package/dist/context/index.d.ts +0 -3
  206. package/dist/context/index.d.ts.map +0 -1
  207. package/dist/context/index.js +0 -6
  208. package/dist/context/index.js.map +0 -1
  209. package/dist/context/session-manager.d.ts +0 -207
  210. package/dist/context/session-manager.d.ts.map +0 -1
  211. package/dist/context/session-manager.js +0 -686
  212. package/dist/context/session-manager.js.map +0 -1
  213. package/dist/index.d.ts +0 -8
  214. package/dist/index.d.ts.map +0 -1
  215. package/dist/index.js +0 -51
  216. package/dist/index.js.map +0 -1
  217. package/dist/interactive/interactive-mode.d.ts +0 -76
  218. package/dist/interactive/interactive-mode.d.ts.map +0 -1
  219. package/dist/interactive/interactive-mode.js +0 -732
  220. package/dist/interactive/interactive-mode.js.map +0 -1
  221. package/dist/nlp/command-mapper.d.ts +0 -174
  222. package/dist/nlp/command-mapper.d.ts.map +0 -1
  223. package/dist/nlp/command-mapper.js +0 -624
  224. package/dist/nlp/command-mapper.js.map +0 -1
  225. package/dist/nlp/command-parser.d.ts +0 -106
  226. package/dist/nlp/command-parser.d.ts.map +0 -1
  227. package/dist/nlp/command-parser.js +0 -417
  228. package/dist/nlp/command-parser.js.map +0 -1
  229. package/dist/nlp/index.d.ts +0 -5
  230. package/dist/nlp/index.d.ts.map +0 -1
  231. package/dist/nlp/index.js +0 -8
  232. package/dist/nlp/index.js.map +0 -1
  233. package/dist/nlp/intent-classifier.d.ts +0 -59
  234. package/dist/nlp/intent-classifier.d.ts.map +0 -1
  235. package/dist/nlp/intent-classifier.js +0 -384
  236. package/dist/nlp/intent-classifier.js.map +0 -1
  237. package/dist/nlp/intent-parser.d.ts +0 -152
  238. package/dist/nlp/intent-parser.d.ts.map +0 -1
  239. package/dist/nlp/intent-parser.js +0 -744
  240. package/dist/nlp/intent-parser.js.map +0 -1
  241. package/dist/plugins/plugin-manager.d.ts +0 -120
  242. package/dist/plugins/plugin-manager.d.ts.map +0 -1
  243. package/dist/plugins/plugin-manager.js +0 -595
  244. package/dist/plugins/plugin-manager.js.map +0 -1
  245. package/dist/types/index.d.ts +0 -224
  246. package/dist/types/index.d.ts.map +0 -1
  247. package/dist/types/index.js +0 -3
  248. package/dist/types/index.js.map +0 -1
  249. package/dist/utils/backup-rollback-manager.d.ts +0 -72
  250. package/dist/utils/backup-rollback-manager.d.ts.map +0 -1
  251. package/dist/utils/backup-rollback-manager.js +0 -289
  252. package/dist/utils/backup-rollback-manager.js.map +0 -1
  253. package/dist/utils/claude-config-installer.d.ts +0 -98
  254. package/dist/utils/claude-config-installer.d.ts.map +0 -1
  255. package/dist/utils/claude-config-installer.js +0 -678
  256. package/dist/utils/claude-config-installer.js.map +0 -1
  257. package/dist/utils/config-manager.d.ts +0 -73
  258. package/dist/utils/config-manager.d.ts.map +0 -1
  259. package/dist/utils/config-manager.js +0 -339
  260. package/dist/utils/config-manager.js.map +0 -1
  261. package/dist/utils/error-handler.d.ts +0 -46
  262. package/dist/utils/error-handler.d.ts.map +0 -1
  263. package/dist/utils/error-handler.js +0 -169
  264. package/dist/utils/error-handler.js.map +0 -1
  265. package/dist/utils/logger.d.ts +0 -25
  266. package/dist/utils/logger.d.ts.map +0 -1
  267. package/dist/utils/logger.js +0 -105
  268. package/dist/utils/logger.js.map +0 -1
  269. package/src/commands/computer-setup-commands.ts +0 -872
@@ -67,8 +67,8 @@ function getTimestamp(): string {
67
67
 
68
68
  function formatBytes(bytes: number): string {
69
69
  if (bytes === 0) {
70
- return '0 Bytes';
71
- }
70
+ return '0 Bytes';
71
+ }
72
72
  const k = 1024;
73
73
  const sizes = ['Bytes', 'KB', 'MB', 'GB'];
74
74
  const i = Math.floor(Math.log(bytes) / Math.log(k));
@@ -77,8 +77,8 @@ return '0 Bytes';
77
77
 
78
78
  function getDirSize(dirPath: string): number {
79
79
  if (!existsSync(dirPath)) {
80
- return 0;
81
- }
80
+ return 0;
81
+ }
82
82
 
83
83
  let totalSize = 0;
84
84
  try {
@@ -208,7 +208,9 @@ async function getStoreMetadata(storePath: string): Promise<StoreMetadata> {
208
208
  let lastPrune: string | null = null;
209
209
  if (existsSync(pruneMetadataPath)) {
210
210
  try {
211
- const pruneData = JSON.parse(await fs.readFile(pruneMetadataPath, 'utf-8'));
211
+ const pruneData = JSON.parse(
212
+ await fs.readFile(pruneMetadataPath, 'utf-8')
213
+ );
212
214
  lastPrune = pruneData.lastPrune || null;
213
215
  } catch {
214
216
  // Ignore parse errors
@@ -218,7 +220,9 @@ async function getStoreMetadata(storePath: string): Promise<StoreMetadata> {
218
220
  let lastIndex: string | null = null;
219
221
  if (existsSync(indexMetadataPath)) {
220
222
  try {
221
- const indexData = JSON.parse(await fs.readFile(indexMetadataPath, 'utf-8'));
223
+ const indexData = JSON.parse(
224
+ await fs.readFile(indexMetadataPath, 'utf-8')
225
+ );
222
226
  lastIndex = indexData.lastIndex || null;
223
227
  } catch {
224
228
  // Ignore parse errors
@@ -240,7 +244,9 @@ async function getStoreMetadata(storePath: string): Promise<StoreMetadata> {
240
244
  // Create RAG command
241
245
  export function createRAGCommand(): Command {
242
246
  const command = new Command('rag')
243
- .description('Manage RAG (Retrieval-Augmented Generation) stores for AI-powered code understanding')
247
+ .description(
248
+ 'Manage RAG (Retrieval-Augmented Generation) stores for AI-powered code understanding'
249
+ )
244
250
  .addHelpText(
245
251
  'after',
246
252
  chalk.gray(`
@@ -251,7 +257,7 @@ Examples:
251
257
  ${chalk.green('wundr rag reindex')} Re-index stores
252
258
  ${chalk.green('wundr rag create myproject')} Create a new project-specific store
253
259
  ${chalk.green('wundr rag setup')} Run initial RAG infrastructure setup
254
- `),
260
+ `)
255
261
  );
256
262
 
257
263
  // Status command (default)
@@ -259,7 +265,7 @@ Examples:
259
265
  .command('status', { isDefault: true })
260
266
  .description('Show RAG store status and statistics')
261
267
  .option('--json', 'Output as JSON')
262
- .action(async (options) => {
268
+ .action(async options => {
263
269
  await showStatus(options);
264
270
  });
265
271
 
@@ -269,7 +275,7 @@ Examples:
269
275
  .description('Sync all RAG stores with their source directories')
270
276
  .option('--store <name>', 'Only sync specific store')
271
277
  .option('--dry-run', 'Show what would be synced without making changes')
272
- .action(async (options) => {
278
+ .action(async options => {
273
279
  await syncStores(options);
274
280
  });
275
281
 
@@ -279,7 +285,7 @@ Examples:
279
285
  .description('Remove deleted files from RAG stores')
280
286
  .option('--store <name>', 'Only prune specific store')
281
287
  .option('--dry-run', 'Show what would be pruned without making changes')
282
- .action(async (options) => {
288
+ .action(async options => {
283
289
  await pruneStores(options);
284
290
  });
285
291
 
@@ -289,7 +295,7 @@ Examples:
289
295
  .description('Re-index RAG stores with updated configurations')
290
296
  .option('--store <name>', 'Only reindex specific store')
291
297
  .option('--force', 'Force complete reindex')
292
- .action(async (options) => {
298
+ .action(async options => {
293
299
  await reindexStores(options);
294
300
  });
295
301
 
@@ -309,7 +315,7 @@ Examples:
309
315
  .command('setup')
310
316
  .description('Run initial RAG infrastructure setup')
311
317
  .option('--skip-api-key', 'Skip GEMINI_API_KEY configuration')
312
- .action(async (options) => {
318
+ .action(async options => {
313
319
  await runSetup(options);
314
320
  });
315
321
 
@@ -320,7 +326,7 @@ Examples:
320
326
  .option('--get <key>', 'Get configuration value')
321
327
  .option('--set <key=value>', 'Set configuration value')
322
328
  .option('--reset', 'Reset to default configuration')
323
- .action(async (options) => {
329
+ .action(async options => {
324
330
  await manageConfig(options);
325
331
  });
326
332
 
@@ -357,13 +363,19 @@ async function showStatus(options: { json?: boolean }): Promise<void> {
357
363
  spinner.stop();
358
364
 
359
365
  if (options.json) {
360
- console.log(JSON.stringify({
361
- timestamp: getTimestamp(),
362
- stores: storeMetadata,
363
- totalEmbeddings,
364
- totalDiskUsage: formatBytes(totalSize),
365
- configPath: CONFIG_FILE,
366
- }, null, 2));
366
+ console.log(
367
+ JSON.stringify(
368
+ {
369
+ timestamp: getTimestamp(),
370
+ stores: storeMetadata,
371
+ totalEmbeddings,
372
+ totalDiskUsage: formatBytes(totalSize),
373
+ configPath: CONFIG_FILE,
374
+ },
375
+ null,
376
+ 2
377
+ )
378
+ );
367
379
  return;
368
380
  }
369
381
 
@@ -371,21 +383,28 @@ async function showStatus(options: { json?: boolean }): Promise<void> {
371
383
  console.log(chalk.gray('='.repeat(70)));
372
384
  console.log(chalk.white('Config:'), chalk.gray(CONFIG_FILE));
373
385
  console.log(chalk.white('Total Embeddings:'), chalk.green(totalEmbeddings));
374
- console.log(chalk.white('Disk Usage:'), chalk.green(formatBytes(totalSize)));
386
+ console.log(
387
+ chalk.white('Disk Usage:'),
388
+ chalk.green(formatBytes(totalSize))
389
+ );
375
390
  console.log(chalk.gray('-'.repeat(70)));
376
391
 
377
392
  if (storeMetadata.length === 0) {
378
- console.log(chalk.yellow('\nNo RAG stores found. Run "wundr rag setup" to get started.\n'));
393
+ console.log(
394
+ chalk.yellow(
395
+ '\nNo RAG stores found. Run "wundr rag setup" to get started.\n'
396
+ )
397
+ );
379
398
  return;
380
399
  }
381
400
 
382
401
  console.log(
383
402
  chalk.cyan(
384
403
  padRight('Store', 25) +
385
- padRight('Embeddings', 12) +
386
- padRight('Last Sync', 18) +
387
- padRight('Status', 15),
388
- ),
404
+ padRight('Embeddings', 12) +
405
+ padRight('Last Sync', 18) +
406
+ padRight('Status', 15)
407
+ )
389
408
  );
390
409
  console.log(chalk.gray('-'.repeat(70)));
391
410
 
@@ -396,17 +415,17 @@ async function showStatus(options: { json?: boolean }): Promise<void> {
396
415
 
397
416
  let statusColor = chalk.yellow;
398
417
  if (store.status === 'ready') {
399
- statusColor = chalk.green;
400
- }
418
+ statusColor = chalk.green;
419
+ }
401
420
  if (store.status === 'error') {
402
- statusColor = chalk.red;
403
- }
421
+ statusColor = chalk.red;
422
+ }
404
423
 
405
424
  console.log(
406
425
  padRight(store.name, 25) +
407
- padRight(String(store.embeddingCount), 12) +
408
- padRight(lastSync, 18) +
409
- statusColor(padRight(store.status, 15)),
426
+ padRight(String(store.embeddingCount), 12) +
427
+ padRight(lastSync, 18) +
428
+ statusColor(padRight(store.status, 15))
410
429
  );
411
430
  }
412
431
 
@@ -414,11 +433,16 @@ statusColor = chalk.red;
414
433
  console.log('');
415
434
  } catch (error) {
416
435
  spinner.fail('Failed to load RAG status');
417
- console.error(chalk.red(error instanceof Error ? error.message : String(error)));
436
+ console.error(
437
+ chalk.red(error instanceof Error ? error.message : String(error))
438
+ );
418
439
  }
419
440
  }
420
441
 
421
- async function syncStores(options: { store?: string; dryRun?: boolean }): Promise<void> {
442
+ async function syncStores(options: {
443
+ store?: string;
444
+ dryRun?: boolean;
445
+ }): Promise<void> {
422
446
  const spinner = ora('Syncing RAG stores...').start();
423
447
 
424
448
  try {
@@ -436,7 +460,11 @@ async function syncStores(options: { store?: string; dryRun?: boolean }): Promis
436
460
  continue;
437
461
  }
438
462
 
439
- const sourceMetadataPath = path.join(storePath, 'metadata', 'source.json');
463
+ const sourceMetadataPath = path.join(
464
+ storePath,
465
+ 'metadata',
466
+ 'source.json'
467
+ );
440
468
 
441
469
  if (!existsSync(sourceMetadataPath)) {
442
470
  console.log(chalk.yellow(` [SKIP] ${storeName}: No source metadata`));
@@ -445,11 +473,15 @@ async function syncStores(options: { store?: string; dryRun?: boolean }): Promis
445
473
  }
446
474
 
447
475
  try {
448
- const sourceMetadata = JSON.parse(await fs.readFile(sourceMetadataPath, 'utf-8'));
476
+ const sourceMetadata = JSON.parse(
477
+ await fs.readFile(sourceMetadataPath, 'utf-8')
478
+ );
449
479
  const sourceDir = sourceMetadata.sourceDir;
450
480
 
451
481
  if (!sourceDir || !existsSync(sourceDir)) {
452
- console.log(chalk.yellow(` [SKIP] ${storeName}: Source directory not found`));
482
+ console.log(
483
+ chalk.yellow(` [SKIP] ${storeName}: Source directory not found`)
484
+ );
453
485
  skipped++;
454
486
  continue;
455
487
  }
@@ -458,16 +490,23 @@ async function syncStores(options: { store?: string; dryRun?: boolean }): Promis
458
490
  let fileCount = 0;
459
491
  const countFiles = (dir: string): void => {
460
492
  if (!existsSync(dir)) {
461
- return;
462
- }
493
+ return;
494
+ }
463
495
  try {
464
496
  const entries = readdirSync(dir);
465
497
  for (const entry of entries) {
466
498
  const fullPath = path.join(dir, entry);
467
499
  const stat = statSync(fullPath);
468
- if (stat.isDirectory() && !entry.startsWith('.') && entry !== 'node_modules') {
500
+ if (
501
+ stat.isDirectory() &&
502
+ !entry.startsWith('.') &&
503
+ entry !== 'node_modules'
504
+ ) {
469
505
  countFiles(fullPath);
470
- } else if (stat.isFile() && /\.(ts|js|tsx|jsx|md|json)$/.test(entry)) {
506
+ } else if (
507
+ stat.isFile() &&
508
+ /\.(ts|js|tsx|jsx|md|json)$/.test(entry)
509
+ ) {
471
510
  fileCount++;
472
511
  }
473
512
  }
@@ -478,7 +517,11 @@ return;
478
517
  countFiles(sourceDir);
479
518
 
480
519
  if (options.dryRun) {
481
- console.log(chalk.blue(` [DRY-RUN] ${storeName}: Would sync ${fileCount} files`));
520
+ console.log(
521
+ chalk.blue(
522
+ ` [DRY-RUN] ${storeName}: Would sync ${fileCount} files`
523
+ )
524
+ );
482
525
  } else {
483
526
  // Update sync metadata
484
527
  const syncMetadata = {
@@ -491,26 +534,39 @@ return;
491
534
  await fs.mkdir(path.join(storePath, 'metadata'), { recursive: true });
492
535
  await fs.writeFile(
493
536
  path.join(storePath, 'metadata', 'sync.json'),
494
- JSON.stringify(syncMetadata, null, 2),
537
+ JSON.stringify(syncMetadata, null, 2)
495
538
  );
496
539
 
497
- console.log(chalk.green(` [OK] ${storeName}: Synced ${fileCount} files`));
540
+ console.log(
541
+ chalk.green(` [OK] ${storeName}: Synced ${fileCount} files`)
542
+ );
498
543
  }
499
544
  synced++;
500
545
  } catch (error) {
501
- console.log(chalk.red(` [ERROR] ${storeName}: ${error instanceof Error ? error.message : String(error)}`));
546
+ console.log(
547
+ chalk.red(
548
+ ` [ERROR] ${storeName}: ${error instanceof Error ? error.message : String(error)}`
549
+ )
550
+ );
502
551
  }
503
552
  }
504
553
 
505
554
  console.log(chalk.gray('\n' + '-'.repeat(50)));
506
- console.log(chalk.green(`Sync complete: ${synced} synced, ${skipped} skipped\n`));
555
+ console.log(
556
+ chalk.green(`Sync complete: ${synced} synced, ${skipped} skipped\n`)
557
+ );
507
558
  } catch (error) {
508
559
  spinner.fail('Failed to sync stores');
509
- console.error(chalk.red(error instanceof Error ? error.message : String(error)));
560
+ console.error(
561
+ chalk.red(error instanceof Error ? error.message : String(error))
562
+ );
510
563
  }
511
564
  }
512
565
 
513
- async function pruneStores(options: { store?: string; dryRun?: boolean }): Promise<void> {
566
+ async function pruneStores(options: {
567
+ store?: string;
568
+ dryRun?: boolean;
569
+ }): Promise<void> {
514
570
  const spinner = ora('Pruning RAG stores...').start();
515
571
 
516
572
  try {
@@ -532,13 +588,17 @@ async function pruneStores(options: { store?: string; dryRun?: boolean }): Promi
532
588
 
533
589
  if (existsSync(embeddingsDir)) {
534
590
  try {
535
- const embeddingFiles = readdirSync(embeddingsDir).filter(f => f.endsWith('.json'));
591
+ const embeddingFiles = readdirSync(embeddingsDir).filter(f =>
592
+ f.endsWith('.json')
593
+ );
536
594
 
537
595
  for (const file of embeddingFiles) {
538
596
  const embeddingPath = path.join(embeddingsDir, file);
539
597
 
540
598
  try {
541
- const embeddingData = JSON.parse(await fs.readFile(embeddingPath, 'utf-8'));
599
+ const embeddingData = JSON.parse(
600
+ await fs.readFile(embeddingPath, 'utf-8')
601
+ );
542
602
  const originalPath = embeddingData.originalPath;
543
603
 
544
604
  if (originalPath && !existsSync(originalPath)) {
@@ -569,7 +629,7 @@ async function pruneStores(options: { store?: string; dryRun?: boolean }): Promi
569
629
  await fs.mkdir(path.join(storePath, 'metadata'), { recursive: true });
570
630
  await fs.writeFile(
571
631
  path.join(storePath, 'metadata', 'prune.json'),
572
- JSON.stringify(pruneMetadata, null, 2),
632
+ JSON.stringify(pruneMetadata, null, 2)
573
633
  );
574
634
  }
575
635
 
@@ -578,14 +638,21 @@ async function pruneStores(options: { store?: string; dryRun?: boolean }): Promi
578
638
  }
579
639
 
580
640
  console.log(chalk.gray('\n' + '-'.repeat(50)));
581
- console.log(chalk.green(`Prune complete: ${totalPruned} entries removed\n`));
641
+ console.log(
642
+ chalk.green(`Prune complete: ${totalPruned} entries removed\n`)
643
+ );
582
644
  } catch (error) {
583
645
  spinner.fail('Failed to prune stores');
584
- console.error(chalk.red(error instanceof Error ? error.message : String(error)));
646
+ console.error(
647
+ chalk.red(error instanceof Error ? error.message : String(error))
648
+ );
585
649
  }
586
650
  }
587
651
 
588
- async function reindexStores(options: { store?: string; force?: boolean }): Promise<void> {
652
+ async function reindexStores(options: {
653
+ store?: string;
654
+ force?: boolean;
655
+ }): Promise<void> {
589
656
  const spinner = ora('Re-indexing RAG stores...').start();
590
657
 
591
658
  try {
@@ -609,7 +676,9 @@ async function reindexStores(options: { store?: string; force?: boolean }): Prom
609
676
  let embeddingCount = 0;
610
677
  if (existsSync(embeddingsDir)) {
611
678
  try {
612
- const files = readdirSync(embeddingsDir).filter(f => f.endsWith('.json'));
679
+ const files = readdirSync(embeddingsDir).filter(f =>
680
+ f.endsWith('.json')
681
+ );
613
682
  embeddingCount = files.length;
614
683
  } catch {
615
684
  // Ignore permission errors
@@ -640,21 +709,28 @@ async function reindexStores(options: { store?: string; force?: boolean }): Prom
640
709
  await fs.mkdir(path.join(storePath, 'metadata'), { recursive: true });
641
710
  await fs.writeFile(
642
711
  path.join(storePath, 'metadata', 'index.json'),
643
- JSON.stringify(indexMetadata, null, 2),
712
+ JSON.stringify(indexMetadata, null, 2)
644
713
  );
645
714
 
646
- console.log(chalk.green(` [OK] ${storeName}: Indexed ${embeddingCount} entries`));
715
+ console.log(
716
+ chalk.green(` [OK] ${storeName}: Indexed ${embeddingCount} entries`)
717
+ );
647
718
  }
648
719
 
649
720
  console.log(chalk.gray('\n' + '-'.repeat(50)));
650
721
  console.log(chalk.green('Re-index complete\n'));
651
722
  } catch (error) {
652
723
  spinner.fail('Failed to reindex stores');
653
- console.error(chalk.red(error instanceof Error ? error.message : String(error)));
724
+ console.error(
725
+ chalk.red(error instanceof Error ? error.message : String(error))
726
+ );
654
727
  }
655
728
  }
656
729
 
657
- async function createStore(name: string, options: { source?: string; global?: boolean }): Promise<void> {
730
+ async function createStore(
731
+ name: string,
732
+ options: { source?: string; global?: boolean }
733
+ ): Promise<void> {
658
734
  const spinner = ora(`Creating RAG store: ${name}...`).start();
659
735
 
660
736
  try {
@@ -706,7 +782,7 @@ async function createStore(name: string, options: { source?: string; global?: bo
706
782
 
707
783
  await fs.writeFile(
708
784
  path.join(baseDir, 'metadata', 'source.json'),
709
- JSON.stringify(sourceMetadata, null, 2),
785
+ JSON.stringify(sourceMetadata, null, 2)
710
786
  );
711
787
 
712
788
  spinner.succeed(`RAG store created: ${name}`);
@@ -715,13 +791,17 @@ async function createStore(name: string, options: { source?: string; global?: bo
715
791
  console.log(chalk.green('\nRun "wundr rag sync" to sync the store.\n'));
716
792
  } catch (error) {
717
793
  spinner.fail('Failed to create store');
718
- console.error(chalk.red(error instanceof Error ? error.message : String(error)));
794
+ console.error(
795
+ chalk.red(error instanceof Error ? error.message : String(error))
796
+ );
719
797
  }
720
798
  }
721
799
 
722
800
  async function runSetup(options: { skipApiKey?: boolean }): Promise<void> {
723
801
  console.log(chalk.cyan('\nRAG Infrastructure Setup\n'));
724
- console.log(chalk.gray('This will set up the RAG infrastructure for Wundr.\n'));
802
+ console.log(
803
+ chalk.gray('This will set up the RAG infrastructure for Wundr.\n')
804
+ );
725
805
 
726
806
  const spinner = ora('Checking prerequisites...').start();
727
807
 
@@ -751,14 +831,22 @@ async function runSetup(options: { skipApiKey?: boolean }): Promise<void> {
751
831
  if (!options.skipApiKey) {
752
832
  spinner.stop();
753
833
  console.log(chalk.yellow('\nGEMINI_API_KEY Configuration'));
754
- console.log(chalk.gray('Get your API key from: https://makersuite.google.com/app/apikey\n'));
834
+ console.log(
835
+ chalk.gray(
836
+ 'Get your API key from: https://makersuite.google.com/app/apikey\n'
837
+ )
838
+ );
755
839
 
756
840
  if (process.env.GEMINI_API_KEY) {
757
- console.log(chalk.green('GEMINI_API_KEY is already set in environment.\n'));
841
+ console.log(
842
+ chalk.green('GEMINI_API_KEY is already set in environment.\n')
843
+ );
758
844
  } else {
759
845
  console.log(chalk.yellow('GEMINI_API_KEY is not set.'));
760
846
  console.log(chalk.gray('Add the following to your shell profile:'));
761
- console.log(chalk.white(' export GEMINI_API_KEY="your-api-key-here"\n'));
847
+ console.log(
848
+ chalk.white(' export GEMINI_API_KEY="your-api-key-here"\n')
849
+ );
762
850
  }
763
851
  }
764
852
 
@@ -766,7 +854,9 @@ async function runSetup(options: { skipApiKey?: boolean }): Promise<void> {
766
854
  spinner.start('Creating RAG store directories...');
767
855
 
768
856
  await fs.mkdir(RAG_GLOBAL_DIR, { recursive: true });
769
- await fs.mkdir(path.join(RAG_GLOBAL_DIR, 'embeddings'), { recursive: true });
857
+ await fs.mkdir(path.join(RAG_GLOBAL_DIR, 'embeddings'), {
858
+ recursive: true,
859
+ });
770
860
  await fs.mkdir(path.join(RAG_GLOBAL_DIR, 'indexes'), { recursive: true });
771
861
  await fs.mkdir(path.join(RAG_GLOBAL_DIR, 'metadata'), { recursive: true });
772
862
  await fs.mkdir(path.join(RAG_GLOBAL_DIR, 'cache'), { recursive: true });
@@ -788,16 +878,24 @@ async function runSetup(options: { skipApiKey?: boolean }): Promise<void> {
788
878
  console.log(chalk.green('\nRAG infrastructure setup complete!\n'));
789
879
  console.log(chalk.gray('Next steps:'));
790
880
  console.log(chalk.white(' 1. Set GEMINI_API_KEY if not already set'));
791
- console.log(chalk.white(' 2. Run "wundr rag create <name>" to create a store'));
881
+ console.log(
882
+ chalk.white(' 2. Run "wundr rag create <name>" to create a store')
883
+ );
792
884
  console.log(chalk.white(' 3. Run "wundr rag sync" to sync your stores'));
793
885
  console.log(chalk.white(' 4. Run "wundr rag status" to check status\n'));
794
886
  } catch (error) {
795
887
  spinner.fail('Setup failed');
796
- console.error(chalk.red(error instanceof Error ? error.message : String(error)));
888
+ console.error(
889
+ chalk.red(error instanceof Error ? error.message : String(error))
890
+ );
797
891
  }
798
892
  }
799
893
 
800
- async function manageConfig(options: { get?: string; set?: string; reset?: boolean }): Promise<void> {
894
+ async function manageConfig(options: {
895
+ get?: string;
896
+ set?: string;
897
+ reset?: boolean;
898
+ }): Promise<void> {
801
899
  try {
802
900
  if (options.reset) {
803
901
  const config = getDefaultConfig();
@@ -828,7 +926,10 @@ async function manageConfig(options: { get?: string; set?: string; reset?: boole
828
926
  }
829
927
 
830
928
  const keys = keyPath.split('.');
831
- let obj: Record<string, unknown> = config as unknown as Record<string, unknown>;
929
+ let obj: Record<string, unknown> = config as unknown as Record<
930
+ string,
931
+ unknown
932
+ >;
832
933
  for (let i = 0; i < keys.length - 1; i++) {
833
934
  const key = keys[i];
834
935
  if (key) {
@@ -858,14 +959,18 @@ async function manageConfig(options: { get?: string; set?: string; reset?: boole
858
959
  console.log(chalk.cyan('\nRAG Configuration\n'));
859
960
  console.log(JSON.stringify(config, null, 2));
860
961
  } catch (error) {
861
- console.error(chalk.red(error instanceof Error ? error.message : String(error)));
962
+ console.error(
963
+ chalk.red(error instanceof Error ? error.message : String(error))
964
+ );
862
965
  }
863
966
  }
864
967
 
865
- async function deleteStore(name: string, options: { force?: boolean }): Promise<void> {
866
- const storePath = name === 'global'
867
- ? RAG_GLOBAL_DIR
868
- : path.join(RAG_PROJECT_DIR, name);
968
+ async function deleteStore(
969
+ name: string,
970
+ options: { force?: boolean }
971
+ ): Promise<void> {
972
+ const storePath =
973
+ name === 'global' ? RAG_GLOBAL_DIR : path.join(RAG_PROJECT_DIR, name);
869
974
 
870
975
  if (!existsSync(storePath)) {
871
976
  console.log(chalk.red(`Store not found: ${name}`));
@@ -895,7 +1000,9 @@ async function deleteStore(name: string, options: { force?: boolean }): Promise<
895
1000
  spinner.succeed(`Store deleted: ${name}`);
896
1001
  } catch (error) {
897
1002
  spinner.fail('Failed to delete store');
898
- console.error(chalk.red(error instanceof Error ? error.message : String(error)));
1003
+ console.error(
1004
+ chalk.red(error instanceof Error ? error.message : String(error))
1005
+ );
899
1006
  }
900
1007
  }
901
1008