@wundr.io/cli 1.0.11 → 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.
- package/bin/wundr.js +8 -4
- package/package.json +23 -23
- package/src/ai/ai-service.ts +16 -17
- package/src/ai/claude-client.ts +16 -16
- package/src/ai/conversation-manager.ts +29 -29
- package/src/cli.ts +4 -4
- package/src/commands/ai.ts +246 -78
- package/src/commands/alignment.ts +74 -74
- package/src/commands/analyze-optimized.ts +111 -78
- package/src/commands/analyze.ts +14 -14
- package/src/commands/batch.ts +179 -42
- package/src/commands/chat.ts +37 -30
- package/src/commands/claude-init.ts +41 -45
- package/src/commands/claude-setup.ts +204 -119
- package/src/commands/computer-setup.ts +85 -43
- package/src/commands/create-command.ts +4 -4
- package/src/commands/create.ts +27 -27
- package/src/commands/dashboard.ts +24 -24
- package/src/commands/govern.ts +25 -25
- package/src/commands/governance.ts +34 -34
- package/src/commands/guardian.ts +56 -56
- package/src/commands/init.ts +25 -22
- package/src/commands/orchestrator.ts +68 -41
- package/src/commands/performance-optimizer.ts +34 -35
- package/src/commands/plugins.ts +27 -27
- package/src/commands/project-update.ts +175 -72
- package/src/commands/rag.ts +185 -78
- package/src/commands/session.ts +35 -35
- package/src/commands/setup.ts +40 -344
- package/src/commands/test-init.ts +3 -3
- package/src/commands/test.ts +4 -4
- package/src/commands/watch.ts +28 -29
- package/src/commands/worktree.ts +49 -49
- package/src/context/context-manager.ts +10 -10
- package/src/context/session-manager.ts +41 -41
- package/src/framework/command-interface.ts +520 -0
- package/src/framework/command-registry.ts +942 -0
- package/src/framework/completion-exporter.ts +383 -0
- package/src/framework/debug-logger.ts +519 -0
- package/src/framework/error-handler.ts +867 -0
- package/src/framework/help-generator.ts +540 -0
- package/src/framework/index.ts +169 -0
- package/src/framework/interactive-repl.ts +703 -0
- package/src/framework/output-formatter.ts +834 -0
- package/src/framework/progress-manager.ts +539 -0
- package/src/index.ts +4 -4
- package/src/interactive/interactive-mode.ts +16 -16
- package/src/lib/conflict-resolution.ts +799 -9
- package/src/lib/merge-strategy.ts +529 -7
- package/src/lib/safety-mechanisms.ts +422 -18
- package/src/lib/state-detection.ts +1015 -13
- package/src/nlp/command-mapper.ts +29 -29
- package/src/nlp/command-parser.ts +17 -17
- package/src/nlp/intent-classifier.ts +7 -7
- package/src/nlp/intent-parser.ts +54 -52
- package/src/plugins/plugin-manager.ts +61 -39
- package/src/tests/computer-setup-integration.test.ts +46 -15
- package/src/types/modules.d.ts +424 -1
- package/src/utils/backup-rollback-manager.ts +11 -8
- package/src/utils/config-manager.ts +3 -3
- package/src/utils/error-handler.ts +2 -2
- package/src/utils/logger.ts +22 -22
- package/templates/batch/ci-cd.yaml +7 -7
- package/test-suites/api/health.spec.ts +20 -23
- package/test-suites/helpers/test-config.ts +14 -13
- package/test-suites/ui/accessibility.spec.ts +27 -22
- package/test-suites/ui/smoke.spec.ts +26 -21
- package/LICENSE +0 -21
- package/dist/ai/ai-service.d.ts +0 -152
- package/dist/ai/ai-service.d.ts.map +0 -1
- package/dist/ai/ai-service.js +0 -430
- package/dist/ai/ai-service.js.map +0 -1
- package/dist/ai/claude-client.d.ts +0 -130
- package/dist/ai/claude-client.d.ts.map +0 -1
- package/dist/ai/claude-client.js +0 -340
- package/dist/ai/claude-client.js.map +0 -1
- package/dist/ai/conversation-manager.d.ts +0 -164
- package/dist/ai/conversation-manager.d.ts.map +0 -1
- package/dist/ai/conversation-manager.js +0 -614
- package/dist/ai/conversation-manager.js.map +0 -1
- package/dist/ai/index.d.ts +0 -5
- package/dist/ai/index.d.ts.map +0 -1
- package/dist/ai/index.js +0 -8
- package/dist/ai/index.js.map +0 -1
- package/dist/cli.d.ts +0 -36
- package/dist/cli.d.ts.map +0 -1
- package/dist/cli.js +0 -192
- package/dist/cli.js.map +0 -1
- package/dist/commands/ai.d.ts +0 -89
- package/dist/commands/ai.d.ts.map +0 -1
- package/dist/commands/ai.js +0 -799
- package/dist/commands/ai.js.map +0 -1
- package/dist/commands/alignment.d.ts +0 -78
- package/dist/commands/alignment.d.ts.map +0 -1
- package/dist/commands/alignment.js +0 -817
- package/dist/commands/alignment.js.map +0 -1
- package/dist/commands/analyze-optimized.d.ts +0 -14
- package/dist/commands/analyze-optimized.d.ts.map +0 -1
- package/dist/commands/analyze-optimized.js +0 -600
- package/dist/commands/analyze-optimized.js.map +0 -1
- package/dist/commands/analyze.d.ts +0 -65
- package/dist/commands/analyze.d.ts.map +0 -1
- package/dist/commands/analyze.js +0 -435
- package/dist/commands/analyze.js.map +0 -1
- package/dist/commands/batch.d.ts +0 -71
- package/dist/commands/batch.d.ts.map +0 -1
- package/dist/commands/batch.js +0 -738
- package/dist/commands/batch.js.map +0 -1
- package/dist/commands/chat.d.ts +0 -71
- package/dist/commands/chat.d.ts.map +0 -1
- package/dist/commands/chat.js +0 -674
- package/dist/commands/chat.js.map +0 -1
- package/dist/commands/claude-init.d.ts +0 -28
- package/dist/commands/claude-init.d.ts.map +0 -1
- package/dist/commands/claude-init.js +0 -591
- package/dist/commands/claude-init.js.map +0 -1
- package/dist/commands/claude-setup.d.ts +0 -119
- package/dist/commands/claude-setup.d.ts.map +0 -1
- package/dist/commands/claude-setup.js +0 -1073
- package/dist/commands/claude-setup.js.map +0 -1
- package/dist/commands/computer-setup-commands.d.ts +0 -53
- package/dist/commands/computer-setup-commands.d.ts.map +0 -1
- package/dist/commands/computer-setup-commands.js +0 -705
- package/dist/commands/computer-setup-commands.js.map +0 -1
- package/dist/commands/computer-setup.d.ts +0 -7
- package/dist/commands/computer-setup.d.ts.map +0 -1
- package/dist/commands/computer-setup.js +0 -849
- package/dist/commands/computer-setup.js.map +0 -1
- package/dist/commands/create-command.d.ts +0 -7
- package/dist/commands/create-command.d.ts.map +0 -1
- package/dist/commands/create-command.js +0 -158
- package/dist/commands/create-command.js.map +0 -1
- package/dist/commands/create.d.ts +0 -74
- package/dist/commands/create.d.ts.map +0 -1
- package/dist/commands/create.js +0 -556
- package/dist/commands/create.js.map +0 -1
- package/dist/commands/dashboard.d.ts +0 -91
- package/dist/commands/dashboard.d.ts.map +0 -1
- package/dist/commands/dashboard.js +0 -538
- package/dist/commands/dashboard.js.map +0 -1
- package/dist/commands/govern.d.ts +0 -70
- package/dist/commands/govern.d.ts.map +0 -1
- package/dist/commands/govern.js +0 -481
- package/dist/commands/govern.js.map +0 -1
- package/dist/commands/governance.d.ts +0 -17
- package/dist/commands/governance.d.ts.map +0 -1
- package/dist/commands/governance.js +0 -703
- package/dist/commands/governance.js.map +0 -1
- package/dist/commands/guardian.d.ts +0 -20
- package/dist/commands/guardian.d.ts.map +0 -1
- package/dist/commands/guardian.js +0 -597
- package/dist/commands/guardian.js.map +0 -1
- package/dist/commands/init.d.ts +0 -59
- package/dist/commands/init.d.ts.map +0 -1
- package/dist/commands/init.js +0 -650
- package/dist/commands/init.js.map +0 -1
- package/dist/commands/orchestrator.d.ts +0 -7
- package/dist/commands/orchestrator.d.ts.map +0 -1
- package/dist/commands/orchestrator.js +0 -571
- package/dist/commands/orchestrator.js.map +0 -1
- package/dist/commands/performance-optimizer.d.ts +0 -30
- package/dist/commands/performance-optimizer.d.ts.map +0 -1
- package/dist/commands/performance-optimizer.js +0 -650
- package/dist/commands/performance-optimizer.js.map +0 -1
- package/dist/commands/plugins.d.ts +0 -87
- package/dist/commands/plugins.d.ts.map +0 -1
- package/dist/commands/plugins.js +0 -685
- package/dist/commands/plugins.js.map +0 -1
- package/dist/commands/rag.d.ts +0 -7
- package/dist/commands/rag.d.ts.map +0 -1
- package/dist/commands/rag.js +0 -748
- package/dist/commands/rag.js.map +0 -1
- package/dist/commands/session.d.ts +0 -41
- package/dist/commands/session.d.ts.map +0 -1
- package/dist/commands/session.js +0 -441
- package/dist/commands/session.js.map +0 -1
- package/dist/commands/setup.d.ts +0 -29
- package/dist/commands/setup.d.ts.map +0 -1
- package/dist/commands/setup.js +0 -397
- package/dist/commands/setup.js.map +0 -1
- package/dist/commands/test-init.d.ts +0 -9
- package/dist/commands/test-init.d.ts.map +0 -1
- package/dist/commands/test-init.js +0 -222
- package/dist/commands/test-init.js.map +0 -1
- package/dist/commands/test.d.ts +0 -25
- package/dist/commands/test.d.ts.map +0 -1
- package/dist/commands/test.js +0 -217
- package/dist/commands/test.js.map +0 -1
- package/dist/commands/vp.d.ts +0 -7
- package/dist/commands/vp.d.ts.map +0 -1
- package/dist/commands/vp.js +0 -571
- package/dist/commands/vp.js.map +0 -1
- package/dist/commands/watch.d.ts +0 -76
- package/dist/commands/watch.d.ts.map +0 -1
- package/dist/commands/watch.js +0 -613
- package/dist/commands/watch.js.map +0 -1
- package/dist/commands/worktree.d.ts +0 -63
- package/dist/commands/worktree.d.ts.map +0 -1
- package/dist/commands/worktree.js +0 -774
- package/dist/commands/worktree.js.map +0 -1
- package/dist/context/context-manager.d.ts +0 -155
- package/dist/context/context-manager.d.ts.map +0 -1
- package/dist/context/context-manager.js +0 -383
- package/dist/context/context-manager.js.map +0 -1
- package/dist/context/index.d.ts +0 -3
- package/dist/context/index.d.ts.map +0 -1
- package/dist/context/index.js +0 -6
- package/dist/context/index.js.map +0 -1
- package/dist/context/session-manager.d.ts +0 -207
- package/dist/context/session-manager.d.ts.map +0 -1
- package/dist/context/session-manager.js +0 -686
- package/dist/context/session-manager.js.map +0 -1
- package/dist/index.d.ts +0 -8
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -51
- package/dist/index.js.map +0 -1
- package/dist/interactive/interactive-mode.d.ts +0 -76
- package/dist/interactive/interactive-mode.d.ts.map +0 -1
- package/dist/interactive/interactive-mode.js +0 -732
- package/dist/interactive/interactive-mode.js.map +0 -1
- package/dist/nlp/command-mapper.d.ts +0 -174
- package/dist/nlp/command-mapper.d.ts.map +0 -1
- package/dist/nlp/command-mapper.js +0 -624
- package/dist/nlp/command-mapper.js.map +0 -1
- package/dist/nlp/command-parser.d.ts +0 -106
- package/dist/nlp/command-parser.d.ts.map +0 -1
- package/dist/nlp/command-parser.js +0 -417
- package/dist/nlp/command-parser.js.map +0 -1
- package/dist/nlp/index.d.ts +0 -5
- package/dist/nlp/index.d.ts.map +0 -1
- package/dist/nlp/index.js +0 -8
- package/dist/nlp/index.js.map +0 -1
- package/dist/nlp/intent-classifier.d.ts +0 -59
- package/dist/nlp/intent-classifier.d.ts.map +0 -1
- package/dist/nlp/intent-classifier.js +0 -384
- package/dist/nlp/intent-classifier.js.map +0 -1
- package/dist/nlp/intent-parser.d.ts +0 -152
- package/dist/nlp/intent-parser.d.ts.map +0 -1
- package/dist/nlp/intent-parser.js +0 -744
- package/dist/nlp/intent-parser.js.map +0 -1
- package/dist/plugins/plugin-manager.d.ts +0 -120
- package/dist/plugins/plugin-manager.d.ts.map +0 -1
- package/dist/plugins/plugin-manager.js +0 -595
- package/dist/plugins/plugin-manager.js.map +0 -1
- package/dist/types/index.d.ts +0 -224
- package/dist/types/index.d.ts.map +0 -1
- package/dist/types/index.js +0 -3
- package/dist/types/index.js.map +0 -1
- package/dist/utils/backup-rollback-manager.d.ts +0 -72
- package/dist/utils/backup-rollback-manager.d.ts.map +0 -1
- package/dist/utils/backup-rollback-manager.js +0 -289
- package/dist/utils/backup-rollback-manager.js.map +0 -1
- package/dist/utils/claude-config-installer.d.ts +0 -98
- package/dist/utils/claude-config-installer.d.ts.map +0 -1
- package/dist/utils/claude-config-installer.js +0 -678
- package/dist/utils/claude-config-installer.js.map +0 -1
- package/dist/utils/config-manager.d.ts +0 -73
- package/dist/utils/config-manager.d.ts.map +0 -1
- package/dist/utils/config-manager.js +0 -339
- package/dist/utils/config-manager.js.map +0 -1
- package/dist/utils/error-handler.d.ts +0 -46
- package/dist/utils/error-handler.d.ts.map +0 -1
- package/dist/utils/error-handler.js +0 -169
- package/dist/utils/error-handler.js.map +0 -1
- package/dist/utils/logger.d.ts +0 -25
- package/dist/utils/logger.d.ts.map +0 -1
- package/dist/utils/logger.js +0 -105
- package/dist/utils/logger.js.map +0 -1
- package/src/commands/computer-setup-commands.ts +0 -872
package/src/commands/rag.ts
CHANGED
|
@@ -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(
|
|
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(
|
|
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(
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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(
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
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(
|
|
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(
|
|
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
|
-
|
|
386
|
-
|
|
387
|
-
|
|
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
|
-
|
|
408
|
-
|
|
409
|
-
|
|
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(
|
|
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: {
|
|
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(
|
|
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(
|
|
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(
|
|
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 (
|
|
500
|
+
if (
|
|
501
|
+
stat.isDirectory() &&
|
|
502
|
+
!entry.startsWith('.') &&
|
|
503
|
+
entry !== 'node_modules'
|
|
504
|
+
) {
|
|
469
505
|
countFiles(fullPath);
|
|
470
|
-
} else if (
|
|
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(
|
|
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(
|
|
540
|
+
console.log(
|
|
541
|
+
chalk.green(` [OK] ${storeName}: Synced ${fileCount} files`)
|
|
542
|
+
);
|
|
498
543
|
}
|
|
499
544
|
synced++;
|
|
500
545
|
} catch (error) {
|
|
501
|
-
console.log(
|
|
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(
|
|
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(
|
|
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: {
|
|
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 =>
|
|
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(
|
|
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(
|
|
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(
|
|
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: {
|
|
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 =>
|
|
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(
|
|
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(
|
|
724
|
+
console.error(
|
|
725
|
+
chalk.red(error instanceof Error ? error.message : String(error))
|
|
726
|
+
);
|
|
654
727
|
}
|
|
655
728
|
}
|
|
656
729
|
|
|
657
|
-
async function createStore(
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
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'), {
|
|
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(
|
|
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(
|
|
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: {
|
|
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<
|
|
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(
|
|
962
|
+
console.error(
|
|
963
|
+
chalk.red(error instanceof Error ? error.message : String(error))
|
|
964
|
+
);
|
|
862
965
|
}
|
|
863
966
|
}
|
|
864
967
|
|
|
865
|
-
async function deleteStore(
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
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(
|
|
1003
|
+
console.error(
|
|
1004
|
+
chalk.red(error instanceof Error ? error.message : String(error))
|
|
1005
|
+
);
|
|
899
1006
|
}
|
|
900
1007
|
}
|
|
901
1008
|
|