luna-agents 2.0.1
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/.claude-plugin/LICENSE +21 -0
- package/.claude-plugin/README.md +285 -0
- package/.claude-plugin/claude-plugin.json +106 -0
- package/.claude-plugin/index.js +318 -0
- package/.claude-plugin/lib/api-client.js +504 -0
- package/.claude-plugin/lib/rag-utils.js +442 -0
- package/.claude-plugin/package.json +418 -0
- package/LICENSE +21 -0
- package/README.md +350 -0
- package/agents/json/design-architect.json +57 -0
- package/agents/json/luna-auth.json +71 -0
- package/agents/json/luna-brand.json +66 -0
- package/agents/json/luna-cloudflare.json +261 -0
- package/agents/json/luna-code-review.json +63 -0
- package/agents/json/luna-deployment.json +68 -0
- package/agents/json/luna-documentation.json +85 -0
- package/agents/json/luna-hig.json +128 -0
- package/agents/json/luna-layout-designer.json +178 -0
- package/agents/json/luna-monitoring-observability.json +64 -0
- package/agents/json/luna-post-launch-review.json +68 -0
- package/agents/json/luna-requirements-analyzer.json +53 -0
- package/agents/json/luna-task-executor.json +63 -0
- package/agents/json/luna-task-planner.json +62 -0
- package/agents/json/luna-testing-validation.json +66 -0
- package/agents/luna-365-security.md +96 -0
- package/agents/luna-analytics.md +318 -0
- package/agents/luna-api-generator.md +654 -0
- package/agents/luna-auth.md +396 -0
- package/agents/luna-brand.md +248 -0
- package/agents/luna-cloudflare.md +728 -0
- package/agents/luna-code-review.md +487 -0
- package/agents/luna-database.md +453 -0
- package/agents/luna-deployment.md +202 -0
- package/agents/luna-design-architect.md +353 -0
- package/agents/luna-docker.md +615 -0
- package/agents/luna-documentation.md +177 -0
- package/agents/luna-full-test.md +910 -0
- package/agents/luna-glm-vision.md +211 -0
- package/agents/luna-hig.md +430 -0
- package/agents/luna-lemonsqueezy.md +441 -0
- package/agents/luna-monitoring-observability.md +199 -0
- package/agents/luna-openai-app.md +499 -0
- package/agents/luna-post-launch-review.md +191 -0
- package/agents/luna-rag-enhanced.md +1619 -0
- package/agents/luna-rag.md +1733 -0
- package/agents/luna-requirements-analyzer.md +189 -0
- package/agents/luna-run.md +620 -0
- package/agents/luna-seo.md +338 -0
- package/agents/luna-task-executor.md +371 -0
- package/agents/luna-task-planner.md +275 -0
- package/agents/luna-testing-validation.md +681 -0
- package/agents/luna-ui-fix.md +591 -0
- package/agents/luna-ui-test.md +600 -0
- package/agents/luna-user-guide.md +409 -0
- package/agents/site-auditor.md +83 -0
- package/commands/3d-mesh.md +12 -0
- package/commands/3d.md +12 -0
- package/commands/agent-boost.md +13 -0
- package/commands/ai-index.md +16 -0
- package/commands/api.md +12 -0
- package/commands/assert.md +17 -0
- package/commands/audience.md +12 -0
- package/commands/auth.md +17 -0
- package/commands/autopilot.md +12 -0
- package/commands/boost-finsavvy.md +10 -0
- package/commands/boost-org.md +10 -0
- package/commands/boost-project.md +12 -0
- package/commands/brand.md +17 -0
- package/commands/browser-test.md +18 -0
- package/commands/cf.md +26 -0
- package/commands/cfg.md +33 -0
- package/commands/chain.md +12 -0
- package/commands/challenge.md +13 -0
- package/commands/clone.md +12 -0
- package/commands/cmds.md +243 -0
- package/commands/collab.md +12 -0
- package/commands/compete.md +12 -0
- package/commands/config-rules.md +21 -0
- package/commands/connect-infra.md +10 -0
- package/commands/context-pack.md +13 -0
- package/commands/curb.md +12 -0
- package/commands/des.md +38 -0
- package/commands/devto.md +20 -0
- package/commands/dock.md +26 -0
- package/commands/docs.md +33 -0
- package/commands/e2e-flow.md +18 -0
- package/commands/email-routing.md +10 -0
- package/commands/feature.md +12 -0
- package/commands/figma.md +12 -0
- package/commands/fix.md +12 -0
- package/commands/flaky.md +12 -0
- package/commands/flow-record.md +12 -0
- package/commands/gamify.md +12 -0
- package/commands/ghost.md +12 -0
- package/commands/git-insights.md +12 -0
- package/commands/go-viral.md +16 -0
- package/commands/go.md +42 -0
- package/commands/graph-rag.md +13 -0
- package/commands/guard.md +12 -0
- package/commands/heal.md +17 -0
- package/commands/heygen.md +12 -0
- package/commands/hig.md +33 -0
- package/commands/idea.md +12 -0
- package/commands/imagine.md +12 -0
- package/commands/inbox.md +12 -0
- package/commands/lam.md +12 -0
- package/commands/landing.md +12 -0
- package/commands/launch.md +12 -0
- package/commands/learn.md +12 -0
- package/commands/leverage.md +12 -0
- package/commands/ll-365-secure.md +179 -0
- package/commands/ll-3d-mesh.md +94 -0
- package/commands/ll-3d.md +123 -0
- package/commands/ll-a11y-scan.md +143 -0
- package/commands/ll-a11y.md +71 -0
- package/commands/ll-agent-boost.md +92 -0
- package/commands/ll-agent-chain.md +104 -0
- package/commands/ll-ai-index.md +120 -0
- package/commands/ll-api-client.md +77 -0
- package/commands/ll-api.md +99 -0
- package/commands/ll-assert.md +73 -0
- package/commands/ll-audience.md +308 -0
- package/commands/ll-auth.md +145 -0
- package/commands/ll-autopilot.md +113 -0
- package/commands/ll-boost-finsavvy.md +106 -0
- package/commands/ll-boost-org.md +161 -0
- package/commands/ll-boost-project.md +118 -0
- package/commands/ll-brand.md +150 -0
- package/commands/ll-browser-test.md +203 -0
- package/commands/ll-challenge.md +124 -0
- package/commands/ll-changelog.md +80 -0
- package/commands/ll-ci.md +78 -0
- package/commands/ll-claude-instructions.md +80 -0
- package/commands/ll-clone.md +82 -0
- package/commands/ll-cloudflare.md +580 -0
- package/commands/ll-codemap.md +78 -0
- package/commands/ll-collab.md +87 -0
- package/commands/ll-compete.md +67 -0
- package/commands/ll-config-rules.md +255 -0
- package/commands/ll-config.md +434 -0
- package/commands/ll-connect-infra.md +123 -0
- package/commands/ll-context-pack.md +100 -0
- package/commands/ll-curb.md +164 -0
- package/commands/ll-debug.md +76 -0
- package/commands/ll-deploy.md +101 -0
- package/commands/ll-deps.md +70 -0
- package/commands/ll-design.md +86 -0
- package/commands/ll-devto-publish.md +172 -0
- package/commands/ll-dockerize.md +273 -0
- package/commands/ll-docs.md +123 -0
- package/commands/ll-e2e-flow.md +132 -0
- package/commands/ll-e2e-test.md +231 -0
- package/commands/ll-email-routing.md +130 -0
- package/commands/ll-env.md +70 -0
- package/commands/ll-execute.md +98 -0
- package/commands/ll-feature.md +80 -0
- package/commands/ll-figma.md +82 -0
- package/commands/ll-fix.md +76 -0
- package/commands/ll-flaky.md +151 -0
- package/commands/ll-flow-record.md +180 -0
- package/commands/ll-flowdocs.md +83 -0
- package/commands/ll-gamify.md +131 -0
- package/commands/ll-gemma4.md +84 -0
- package/commands/ll-ghost.md +79 -0
- package/commands/ll-git-insights.md +152 -0
- package/commands/ll-go-viral.md +171 -0
- package/commands/ll-graph-rag.md +113 -0
- package/commands/ll-guard.md +92 -0
- package/commands/ll-heal.md +135 -0
- package/commands/ll-heygen.md +203 -0
- package/commands/ll-hig.md +578 -0
- package/commands/ll-hld.md +84 -0
- package/commands/ll-i18n.md +74 -0
- package/commands/ll-idea.md +101 -0
- package/commands/ll-imagine.md +72 -0
- package/commands/ll-inbox.md +116 -0
- package/commands/ll-lam.md +93 -0
- package/commands/ll-landing.md +171 -0
- package/commands/ll-launch.md +100 -0
- package/commands/ll-learn.md +87 -0
- package/commands/ll-leverage.md +137 -0
- package/commands/ll-local-llm.md +131 -0
- package/commands/ll-ls-products.md +160 -0
- package/commands/ll-marketplace.md +130 -0
- package/commands/ll-mcp-publish.md +104 -0
- package/commands/ll-migrate.md +68 -0
- package/commands/ll-mock.md +79 -0
- package/commands/ll-money.md +87 -0
- package/commands/ll-monitor.md +120 -0
- package/commands/ll-morph.md +117 -0
- package/commands/ll-multi-agent.md +170 -0
- package/commands/ll-native.md +93 -0
- package/commands/ll-nexa.md +79 -0
- package/commands/ll-onboarding.md +84 -0
- package/commands/ll-openhands.md +78 -0
- package/commands/ll-organic-promote.md +260 -0
- package/commands/ll-parallel.md +74 -0
- package/commands/ll-payments.md +83 -0
- package/commands/ll-perf-trace.md +147 -0
- package/commands/ll-perf.md +65 -0
- package/commands/ll-persona.md +280 -0
- package/commands/ll-pipe.md +296 -0
- package/commands/ll-plan-impl.js +570 -0
- package/commands/ll-plan-v2.md +297 -0
- package/commands/ll-plan.md +87 -0
- package/commands/ll-postlaunch.md +109 -0
- package/commands/ll-pr.md +84 -0
- package/commands/ll-present.md +110 -0
- package/commands/ll-product-map.md +152 -0
- package/commands/ll-promote.md +352 -0
- package/commands/ll-publish.md +124 -0
- package/commands/ll-pulse.md +96 -0
- package/commands/ll-rag-guided.md +345 -0
- package/commands/ll-rag-upgrade.md +504 -0
- package/commands/ll-rag.md +343 -0
- package/commands/ll-record.md +114 -0
- package/commands/ll-refactor.md +71 -0
- package/commands/ll-requirements.md +71 -0
- package/commands/ll-review.md +92 -0
- package/commands/ll-rollback.md +66 -0
- package/commands/ll-routemap.md +79 -0
- package/commands/ll-rules.md +90 -0
- package/commands/ll-shortcuts.md +229 -0
- package/commands/ll-sing.md +99 -0
- package/commands/ll-site-audit.md +228 -0
- package/commands/ll-smart-route.md +92 -0
- package/commands/ll-smart-search.md +58 -0
- package/commands/ll-storybook.md +86 -0
- package/commands/ll-swarm.md +101 -0
- package/commands/ll-test.md +97 -0
- package/commands/ll-time-machine.md +72 -0
- package/commands/ll-ui-convert.md +433 -0
- package/commands/ll-video.md +108 -0
- package/commands/ll-vision-pipeline.md +247 -0
- package/commands/ll-vision.md +74 -0
- package/commands/ll-visual-diff.md +118 -0
- package/commands/ll-visual-qa.md +204 -0
- package/commands/ll-visual-regression.md +96 -0
- package/commands/ll-voice.md +138 -0
- package/commands/ll-watch.md +65 -0
- package/commands/ll-workflow.md +108 -0
- package/commands/ll-zen.md +98 -0
- package/commands/local-llm.md +12 -0
- package/commands/marketplace.md +13 -0
- package/commands/mcp-publish.md +16 -0
- package/commands/migrate.md +12 -0
- package/commands/money.md +12 -0
- package/commands/morph.md +12 -0
- package/commands/multi-agent.md +12 -0
- package/commands/native.md +12 -0
- package/commands/nexa.md +12 -0
- package/commands/oh.md +12 -0
- package/commands/organic-promote.md +16 -0
- package/commands/perf-trace.md +12 -0
- package/commands/perf.md +12 -0
- package/commands/persona.md +12 -0
- package/commands/pipe.md +21 -0
- package/commands/plan.md +38 -0
- package/commands/pr.md +12 -0
- package/commands/present.md +12 -0
- package/commands/product-map.md +13 -0
- package/commands/promote.md +16 -0
- package/commands/publish.md +12 -0
- package/commands/pulse.md +12 -0
- package/commands/q.md +35 -0
- package/commands/record.md +12 -0
- package/commands/refactor.md +12 -0
- package/commands/req.md +40 -0
- package/commands/retro.md +33 -0
- package/commands/rev.md +39 -0
- package/commands/rules.md +19 -0
- package/commands/search.md +12 -0
- package/commands/sec.md +34 -0
- package/commands/ship.md +39 -0
- package/commands/sing.md +12 -0
- package/commands/site-audit.md +12 -0
- package/commands/smart-route.md +13 -0
- package/commands/swarm.md +12 -0
- package/commands/test.md +39 -0
- package/commands/time-machine.md +12 -0
- package/commands/ui.md +33 -0
- package/commands/video.md +12 -0
- package/commands/vision.md +12 -0
- package/commands/voice.md +12 -0
- package/commands/vr.md +18 -0
- package/commands/watch.md +39 -0
- package/commands/workflow.md +19 -0
- package/commands/zen.md +12 -0
- package/package.json +76 -0
- package/setup.sh +382 -0
|
@@ -0,0 +1,442 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* RAG Utilities for Luna Agents Plugin
|
|
3
|
+
*
|
|
4
|
+
* Provides convenient methods for repository indexing, semantic search,
|
|
5
|
+
* and context-aware AI interactions using the enhanced RAG system.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
const fs = require('fs');
|
|
9
|
+
const path = require('path');
|
|
10
|
+
|
|
11
|
+
class RAGUtils {
|
|
12
|
+
constructor(apiClient) {
|
|
13
|
+
this.apiClient = apiClient;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Automatically detect and index the current project repository
|
|
18
|
+
*/
|
|
19
|
+
async indexCurrentProject(options = {}) {
|
|
20
|
+
try {
|
|
21
|
+
const currentDir = process.cwd();
|
|
22
|
+
console.log(`š Analyzing project directory: ${currentDir}`);
|
|
23
|
+
|
|
24
|
+
// Detect repository type and structure
|
|
25
|
+
const projectInfo = this.analyzeProjectStructure(currentDir);
|
|
26
|
+
|
|
27
|
+
console.log(`š Project type: ${projectInfo.type}`);
|
|
28
|
+
console.log(`š Found ${projectInfo.fileCount} files in ${projectInfo.dirCount} directories`);
|
|
29
|
+
|
|
30
|
+
// Configure indexing options based on project type
|
|
31
|
+
const indexOptions = this.configureIndexingOptions(projectInfo, options);
|
|
32
|
+
|
|
33
|
+
console.log('š Starting repository indexing...');
|
|
34
|
+
const result = await this.apiClient.indexRepository(currentDir, indexOptions);
|
|
35
|
+
|
|
36
|
+
if (result.errors && result.errors.length > 0) {
|
|
37
|
+
console.warn(`ā ļø ${result.errors.length} files had indexing errors`);
|
|
38
|
+
console.log(' First few errors:', result.errors.slice(0, 3));
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
console.log(`ā
Successfully indexed ${result.indexedFiles} files`);
|
|
42
|
+
console.log(`š Skipped ${result.skippedFiles} files`);
|
|
43
|
+
console.log(`š Processing took ${(result.scanTime / 1000).toFixed(2)} seconds`);
|
|
44
|
+
|
|
45
|
+
return {
|
|
46
|
+
success: true,
|
|
47
|
+
...result,
|
|
48
|
+
projectInfo
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
} catch (error) {
|
|
52
|
+
console.error('ā Failed to index current project:', error.message);
|
|
53
|
+
throw error;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Analyze project structure to determine optimal indexing strategy
|
|
59
|
+
*/
|
|
60
|
+
analyzeProjectStructure(projectPath) {
|
|
61
|
+
const stats = {
|
|
62
|
+
type: 'unknown',
|
|
63
|
+
fileCount: 0,
|
|
64
|
+
dirCount: 0,
|
|
65
|
+
languages: new Set(),
|
|
66
|
+
frameworks: new Set(),
|
|
67
|
+
hasTests: false,
|
|
68
|
+
hasDocs: false,
|
|
69
|
+
configFiles: []
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
// Scan directory structure
|
|
73
|
+
this.scanDirectory(projectPath, stats, 0, 5); // Limit depth for performance
|
|
74
|
+
|
|
75
|
+
// Determine project type
|
|
76
|
+
if (stats.frameworks.has('react') || stats.frameworks.has('next')) {
|
|
77
|
+
stats.type = 'react';
|
|
78
|
+
} else if (stats.frameworks.has('vue')) {
|
|
79
|
+
stats.type = 'vue';
|
|
80
|
+
} else if (stats.frameworks.has('angular')) {
|
|
81
|
+
stats.type = 'angular';
|
|
82
|
+
} else if (stats.frameworks.has('express')) {
|
|
83
|
+
stats.type = 'express';
|
|
84
|
+
} else if (stats.languages.has('python')) {
|
|
85
|
+
stats.type = 'python';
|
|
86
|
+
} else if (stats.languages.has('go')) {
|
|
87
|
+
stats.type = 'go';
|
|
88
|
+
} else if (stats.languages.has('rust')) {
|
|
89
|
+
stats.type = 'rust';
|
|
90
|
+
} else if (stats.languages.has('java')) {
|
|
91
|
+
stats.type = 'java';
|
|
92
|
+
} else if (stats.languages.has('typescript') || stats.languages.has('javascript')) {
|
|
93
|
+
stats.type = 'javascript';
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
return stats;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Recursively scan directory (with depth limit)
|
|
101
|
+
*/
|
|
102
|
+
scanDirectory(dirPath, stats, depth = 0, maxDepth = 3) {
|
|
103
|
+
if (depth > maxDepth) return;
|
|
104
|
+
|
|
105
|
+
try {
|
|
106
|
+
const entries = fs.readdirSync(dirPath, { withFileTypes: true });
|
|
107
|
+
|
|
108
|
+
for (const entry of entries) {
|
|
109
|
+
if (entry.isDirectory()) {
|
|
110
|
+
stats.dirCount++;
|
|
111
|
+
|
|
112
|
+
// Skip certain directories
|
|
113
|
+
if (this.shouldSkipDirectory(entry.name)) {
|
|
114
|
+
continue;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
this.scanDirectory(path.join(dirPath, entry.name), stats, depth + 1, maxDepth);
|
|
118
|
+
} else if (entry.isFile()) {
|
|
119
|
+
stats.fileCount++;
|
|
120
|
+
this.analyzeFile(path.join(dirPath, entry.name), stats);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
} catch (error) {
|
|
124
|
+
// Skip directories we can't read
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* Analyze individual file for project insights
|
|
130
|
+
*/
|
|
131
|
+
analyzeFile(filePath, stats) {
|
|
132
|
+
const ext = path.extname(filePath).toLowerCase();
|
|
133
|
+
const fileName = path.basename(filePath).toLowerCase();
|
|
134
|
+
|
|
135
|
+
// Track languages
|
|
136
|
+
const languageMap = {
|
|
137
|
+
'.js': 'javascript',
|
|
138
|
+
'.jsx': 'javascript',
|
|
139
|
+
'.ts': 'typescript',
|
|
140
|
+
'.tsx': 'typescript',
|
|
141
|
+
'.py': 'python',
|
|
142
|
+
'.go': 'go',
|
|
143
|
+
'.rs': 'rust',
|
|
144
|
+
'.java': 'java',
|
|
145
|
+
'.cpp': 'cpp',
|
|
146
|
+
'.c': 'c',
|
|
147
|
+
'.cs': 'csharp',
|
|
148
|
+
'.php': 'php',
|
|
149
|
+
'.rb': 'ruby'
|
|
150
|
+
};
|
|
151
|
+
|
|
152
|
+
if (languageMap[ext]) {
|
|
153
|
+
stats.languages.add(languageMap[ext]);
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
// Track frameworks
|
|
157
|
+
if (fileName === 'package.json') {
|
|
158
|
+
try {
|
|
159
|
+
const packageJson = JSON.parse(fs.readFileSync(filePath, 'utf8'));
|
|
160
|
+
const deps = { ...packageJson.dependencies, ...packageJson.devDependencies };
|
|
161
|
+
|
|
162
|
+
if (deps.react) stats.frameworks.add('react');
|
|
163
|
+
if (deps.next) stats.frameworks.add('next');
|
|
164
|
+
if (deps.vue) stats.frameworks.add('vue');
|
|
165
|
+
if (deps.angular) stats.frameworks.add('angular');
|
|
166
|
+
if (deps.express) stats.frameworks.add('express');
|
|
167
|
+
if (deps.gatsby) stats.frameworks.add('gatsby');
|
|
168
|
+
} catch (error) {
|
|
169
|
+
// Ignore parse errors
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
// Check for tests and docs
|
|
174
|
+
if (fileName.includes('test') || fileName.includes('spec')) {
|
|
175
|
+
stats.hasTests = true;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
if (fileName === 'readme.md' || fileName.endsWith('.md')) {
|
|
179
|
+
stats.hasDocs = true;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
// Track config files
|
|
183
|
+
const configFiles = ['tsconfig.json', 'webpack.config.js', 'vite.config.js', 'dockerfile', '.gitignore'];
|
|
184
|
+
if (configFiles.includes(fileName)) {
|
|
185
|
+
stats.configFiles.push(fileName);
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
/**
|
|
190
|
+
* Check if directory should be skipped during scanning
|
|
191
|
+
*/
|
|
192
|
+
shouldSkipDirectory(dirName) {
|
|
193
|
+
const skipDirs = [
|
|
194
|
+
'node_modules',
|
|
195
|
+
'.git',
|
|
196
|
+
'dist',
|
|
197
|
+
'build',
|
|
198
|
+
'coverage',
|
|
199
|
+
'.next',
|
|
200
|
+
'.nuxt',
|
|
201
|
+
'target',
|
|
202
|
+
'bin',
|
|
203
|
+
'obj',
|
|
204
|
+
'.vscode',
|
|
205
|
+
'.idea',
|
|
206
|
+
'__pycache__'
|
|
207
|
+
];
|
|
208
|
+
|
|
209
|
+
return skipDirs.includes(dirName) || dirName.startsWith('.');
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
/**
|
|
213
|
+
* Configure indexing options based on project analysis
|
|
214
|
+
*/
|
|
215
|
+
configureIndexingOptions(projectInfo, userOptions = {}) {
|
|
216
|
+
const baseOptions = {
|
|
217
|
+
filePatterns: [
|
|
218
|
+
'**/*.ts',
|
|
219
|
+
'**/*.tsx',
|
|
220
|
+
'**/*.js',
|
|
221
|
+
'**/*.jsx',
|
|
222
|
+
'**/*.py',
|
|
223
|
+
'**/*.go',
|
|
224
|
+
'**/*.rs',
|
|
225
|
+
'**/*.java',
|
|
226
|
+
'**/*.cpp',
|
|
227
|
+
'**/*.c',
|
|
228
|
+
'**/*.cs',
|
|
229
|
+
'**/*.php',
|
|
230
|
+
'**/*.rb',
|
|
231
|
+
'**/*.swift',
|
|
232
|
+
'**/*.kt',
|
|
233
|
+
'**/*.md',
|
|
234
|
+
'**/*.txt',
|
|
235
|
+
'**/*.json',
|
|
236
|
+
'**/*.yaml',
|
|
237
|
+
'**/*.yml',
|
|
238
|
+
'**/*.toml',
|
|
239
|
+
'**/*.xml',
|
|
240
|
+
'**/*.sql',
|
|
241
|
+
'**/*.sh',
|
|
242
|
+
'**/*.dockerfile',
|
|
243
|
+
'**/README*',
|
|
244
|
+
'**/CHANGELOG*',
|
|
245
|
+
'**/LICENSE*'
|
|
246
|
+
],
|
|
247
|
+
excludePatterns: [
|
|
248
|
+
'**/node_modules/**',
|
|
249
|
+
'**/dist/**',
|
|
250
|
+
'**/build/**',
|
|
251
|
+
'**/.git/**',
|
|
252
|
+
'**/.next/**',
|
|
253
|
+
'**/.nuxt/**',
|
|
254
|
+
'**/coverage/**',
|
|
255
|
+
'**/vendor/**',
|
|
256
|
+
'**/target/**',
|
|
257
|
+
'**/bin/**',
|
|
258
|
+
'**/obj/**',
|
|
259
|
+
'**/*.log',
|
|
260
|
+
'**/*.tmp',
|
|
261
|
+
'**/.DS_Store',
|
|
262
|
+
'**/Thumbs.db',
|
|
263
|
+
'**/*.min.js',
|
|
264
|
+
'**/*.min.css',
|
|
265
|
+
'**/*.map',
|
|
266
|
+
'**/*.lock'
|
|
267
|
+
],
|
|
268
|
+
extractGitMetadata: true,
|
|
269
|
+
followSymlinks: false
|
|
270
|
+
};
|
|
271
|
+
|
|
272
|
+
// Customize based on project type
|
|
273
|
+
switch (projectInfo.type) {
|
|
274
|
+
case 'react':
|
|
275
|
+
case 'next':
|
|
276
|
+
baseOptions.filePatterns.push('**/*.css', '**/*.scss', '**/*.less');
|
|
277
|
+
break;
|
|
278
|
+
case 'python':
|
|
279
|
+
baseOptions.filePatterns.push('**/*.pyx', '**/*.pyi');
|
|
280
|
+
baseOptions.excludePatterns.push('**/__pycache__/**');
|
|
281
|
+
break;
|
|
282
|
+
case 'go':
|
|
283
|
+
baseOptions.excludePatterns.push('**/vendor/**');
|
|
284
|
+
break;
|
|
285
|
+
case 'rust':
|
|
286
|
+
baseOptions.excludePatterns.push('**/target/**');
|
|
287
|
+
break;
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
// Add project-specific patterns
|
|
291
|
+
if (projectInfo.hasTests) {
|
|
292
|
+
baseOptions.filePatterns.push('**/*test*', '**/*spec*');
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
if (projectInfo.hasDocs) {
|
|
296
|
+
baseOptions.filePatterns.push('**/*.md', '**/*.rst');
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
return {
|
|
300
|
+
...baseOptions,
|
|
301
|
+
...userOptions,
|
|
302
|
+
metadata: {
|
|
303
|
+
...baseOptions.metadata,
|
|
304
|
+
...userOptions.metadata,
|
|
305
|
+
projectType: projectInfo.type,
|
|
306
|
+
languages: Array.from(projectInfo.languages),
|
|
307
|
+
frameworks: Array.from(projectInfo.frameworks),
|
|
308
|
+
analysisTimestamp: new Date().toISOString()
|
|
309
|
+
}
|
|
310
|
+
};
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
/**
|
|
314
|
+
* Perform semantic search with context
|
|
315
|
+
*/
|
|
316
|
+
async searchWithEnhancement(query, options = {}) {
|
|
317
|
+
try {
|
|
318
|
+
console.log(`š Searching for: "${query}"`);
|
|
319
|
+
|
|
320
|
+
const result = await this.apiClient.queryRAG(query, {
|
|
321
|
+
maxResults: options.maxResults || 5,
|
|
322
|
+
temperature: options.temperature || 0.7,
|
|
323
|
+
includeContext: true,
|
|
324
|
+
includeSources: true,
|
|
325
|
+
filters: options.filters || {}
|
|
326
|
+
});
|
|
327
|
+
|
|
328
|
+
console.log(`š Generated response (${result.answer?.length || 0} chars)`);
|
|
329
|
+
console.log(`š Found ${result.sources?.length || 0} relevant sources`);
|
|
330
|
+
|
|
331
|
+
if (result.sources && result.sources.length > 0) {
|
|
332
|
+
console.log('\nš Top sources:');
|
|
333
|
+
result.sources.slice(0, 3).forEach((source, index) => {
|
|
334
|
+
console.log(` ${index + 1}. ${source.title || source.id} (score: ${(source.relevanceScore || 0).toFixed(3)})`);
|
|
335
|
+
});
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
return result;
|
|
339
|
+
|
|
340
|
+
} catch (error) {
|
|
341
|
+
console.error('ā Search failed:', error.message);
|
|
342
|
+
throw error;
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
/**
|
|
347
|
+
* Get RAG system status and statistics
|
|
348
|
+
*/
|
|
349
|
+
async getSystemStatus() {
|
|
350
|
+
try {
|
|
351
|
+
const [status, stats] = await Promise.all([
|
|
352
|
+
this.apiClient.getRAGStatus(),
|
|
353
|
+
this.apiClient.getRAGStatistics()
|
|
354
|
+
]);
|
|
355
|
+
|
|
356
|
+
console.log('š RAG System Status:');
|
|
357
|
+
console.log(` Status: ${status.status}`);
|
|
358
|
+
console.log(` Message: ${status.message}`);
|
|
359
|
+
|
|
360
|
+
if (status.statistics) {
|
|
361
|
+
console.log('š Statistics:');
|
|
362
|
+
console.log(` Documents: ${status.statistics.totalDocuments || 'N/A'}`);
|
|
363
|
+
console.log(` Queries: ${status.statistics.totalQueries || 'N/A'}`);
|
|
364
|
+
console.log(` Avg Response Time: ${status.statistics.averageResponseTime || 'N/A'}ms`);
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
return { status, stats };
|
|
368
|
+
|
|
369
|
+
} catch (error) {
|
|
370
|
+
console.error('ā Failed to get RAG status:', error.message);
|
|
371
|
+
throw error;
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
/**
|
|
376
|
+
* Interactive repository indexing with user confirmation
|
|
377
|
+
*/
|
|
378
|
+
async interactiveIndexing() {
|
|
379
|
+
try {
|
|
380
|
+
const currentDir = process.cwd();
|
|
381
|
+
console.log(`š Current directory: ${currentDir}`);
|
|
382
|
+
|
|
383
|
+
// Quick analysis
|
|
384
|
+
const projectInfo = this.analyzeProjectStructure(currentDir);
|
|
385
|
+
|
|
386
|
+
console.log('\nš Project Analysis:');
|
|
387
|
+
console.log(` Type: ${projectInfo.type}`);
|
|
388
|
+
console.log(` Files: ${projectInfo.fileCount}`);
|
|
389
|
+
console.log(` Languages: ${Array.from(projectInfo.languages).join(', ')}`);
|
|
390
|
+
console.log(` Frameworks: ${Array.from(projectInfo.frameworks).join(', ')}`);
|
|
391
|
+
|
|
392
|
+
// Check if already indexed
|
|
393
|
+
try {
|
|
394
|
+
const ragStatus = await this.getSystemStatus();
|
|
395
|
+
if (ragStatus.status.status === 'active' && ragStatus.status.statistics?.totalDocuments > 0) {
|
|
396
|
+
console.log('\nš” This project appears to already be indexed.');
|
|
397
|
+
console.log(` Found ${ragStatus.status.statistics.totalDocuments} documents in the system.`);
|
|
398
|
+
|
|
399
|
+
// In a real implementation, you'd ask for user confirmation here
|
|
400
|
+
console.log('š Re-indexing with updated configuration...');
|
|
401
|
+
}
|
|
402
|
+
} catch (error) {
|
|
403
|
+
console.log('š Fresh indexing (no existing index found)');
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
// Perform indexing
|
|
407
|
+
const result = await this.indexCurrentProject();
|
|
408
|
+
|
|
409
|
+
console.log('\nā
Indexing completed successfully!');
|
|
410
|
+
console.log(`š Processed ${result.indexedFiles} files`);
|
|
411
|
+
console.log(`š Took ${(result.scanTime / 1000).toFixed(2)} seconds`);
|
|
412
|
+
|
|
413
|
+
return result;
|
|
414
|
+
|
|
415
|
+
} catch (error) {
|
|
416
|
+
console.error('ā Interactive indexing failed:', error.message);
|
|
417
|
+
throw error;
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
/**
|
|
422
|
+
* Create a smart query based on current context
|
|
423
|
+
*/
|
|
424
|
+
async contextualQuery(intent, options = {}) {
|
|
425
|
+
const contextQueries = {
|
|
426
|
+
'overview': 'What is this project about and what are its main components?',
|
|
427
|
+
'architecture': 'What is the architecture and design patterns used in this project?',
|
|
428
|
+
'apis': 'What are the main API endpoints and their purposes?',
|
|
429
|
+
'database': 'What is the database schema and data model?',
|
|
430
|
+
'testing': 'What testing strategies and frameworks are used?',
|
|
431
|
+
'deployment': 'How is this project deployed and what are the deployment configurations?',
|
|
432
|
+
'security': 'What security measures and authentication mechanisms are implemented?',
|
|
433
|
+
'performance': 'What are the performance considerations and optimizations?',
|
|
434
|
+
'recent-changes': 'What are the most recent changes and updates to the codebase?'
|
|
435
|
+
};
|
|
436
|
+
|
|
437
|
+
const query = contextQueries[intent] || intent;
|
|
438
|
+
return this.searchWithEnhancement(query, options);
|
|
439
|
+
}
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
module.exports = RAGUtils;
|