@simpletoolsindiaorg/engi-mcp 1.0.0
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/CHANGELOG.md +34 -0
- package/LICENSE +21 -0
- package/README.md +592 -0
- package/dist/bin.d.ts +3 -0
- package/dist/bin.d.ts.map +1 -0
- package/dist/bin.js +6 -0
- package/dist/bin.js.map +1 -0
- package/dist/capabilities/analysis/analysis.d.ts +223 -0
- package/dist/capabilities/analysis/analysis.d.ts.map +1 -0
- package/dist/capabilities/analysis/analysis.js +202 -0
- package/dist/capabilities/analysis/analysis.js.map +1 -0
- package/dist/capabilities/analysis/index.d.ts +2 -0
- package/dist/capabilities/analysis/index.d.ts.map +1 -0
- package/dist/capabilities/analysis/index.js +19 -0
- package/dist/capabilities/analysis/index.js.map +1 -0
- package/dist/capabilities/documentation/documentation.d.ts +107 -0
- package/dist/capabilities/documentation/documentation.d.ts.map +1 -0
- package/dist/capabilities/documentation/documentation.js +112 -0
- package/dist/capabilities/documentation/documentation.js.map +1 -0
- package/dist/capabilities/documentation/index.d.ts +2 -0
- package/dist/capabilities/documentation/index.d.ts.map +1 -0
- package/dist/capabilities/documentation/index.js +19 -0
- package/dist/capabilities/documentation/index.js.map +1 -0
- package/dist/capabilities/execution/execution.d.ts +96 -0
- package/dist/capabilities/execution/execution.d.ts.map +1 -0
- package/dist/capabilities/execution/execution.js +175 -0
- package/dist/capabilities/execution/execution.js.map +1 -0
- package/dist/capabilities/execution/index.d.ts +2 -0
- package/dist/capabilities/execution/index.d.ts.map +1 -0
- package/dist/capabilities/execution/index.js +19 -0
- package/dist/capabilities/execution/index.js.map +1 -0
- package/dist/capabilities/memory/index.d.ts +2 -0
- package/dist/capabilities/memory/index.d.ts.map +1 -0
- package/dist/capabilities/memory/index.js +19 -0
- package/dist/capabilities/memory/index.js.map +1 -0
- package/dist/capabilities/memory/memory.d.ts +227 -0
- package/dist/capabilities/memory/memory.d.ts.map +1 -0
- package/dist/capabilities/memory/memory.js +106 -0
- package/dist/capabilities/memory/memory.js.map +1 -0
- package/dist/capabilities/planning/index.d.ts +2 -0
- package/dist/capabilities/planning/index.d.ts.map +1 -0
- package/dist/capabilities/planning/index.js +19 -0
- package/dist/capabilities/planning/index.js.map +1 -0
- package/dist/capabilities/planning/planning.d.ts +131 -0
- package/dist/capabilities/planning/planning.d.ts.map +1 -0
- package/dist/capabilities/planning/planning.js +179 -0
- package/dist/capabilities/planning/planning.js.map +1 -0
- package/dist/core/index.d.ts +2 -0
- package/dist/core/index.d.ts.map +1 -0
- package/dist/core/index.js +19 -0
- package/dist/core/index.js.map +1 -0
- package/dist/core/indexer/index.d.ts +2 -0
- package/dist/core/indexer/index.d.ts.map +1 -0
- package/dist/core/indexer/index.js +9 -0
- package/dist/core/indexer/index.js.map +1 -0
- package/dist/core/indexer/indexer.d.ts +35 -0
- package/dist/core/indexer/indexer.d.ts.map +1 -0
- package/dist/core/indexer/indexer.js +377 -0
- package/dist/core/indexer/indexer.js.map +1 -0
- package/dist/core/retrieval/index.d.ts +2 -0
- package/dist/core/retrieval/index.d.ts.map +1 -0
- package/dist/core/retrieval/index.js +8 -0
- package/dist/core/retrieval/index.js.map +1 -0
- package/dist/core/retrieval/retriever.d.ts +28 -0
- package/dist/core/retrieval/retriever.d.ts.map +1 -0
- package/dist/core/retrieval/retriever.js +258 -0
- package/dist/core/retrieval/retriever.js.map +1 -0
- package/dist/core/summarizer/index.d.ts +2 -0
- package/dist/core/summarizer/index.d.ts.map +1 -0
- package/dist/core/summarizer/index.js +8 -0
- package/dist/core/summarizer/index.js.map +1 -0
- package/dist/core/summarizer/summarizer.d.ts +33 -0
- package/dist/core/summarizer/summarizer.d.ts.map +1 -0
- package/dist/core/summarizer/summarizer.js +341 -0
- package/dist/core/summarizer/summarizer.js.map +1 -0
- package/dist/core/types.d.ts +224 -0
- package/dist/core/types.d.ts.map +1 -0
- package/dist/core/types.js +4 -0
- package/dist/core/types.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +127 -0
- package/dist/index.js.map +1 -0
- package/dist/memory/index.d.ts +2 -0
- package/dist/memory/index.d.ts.map +1 -0
- package/dist/memory/index.js +9 -0
- package/dist/memory/index.js.map +1 -0
- package/dist/memory/memory.d.ts +59 -0
- package/dist/memory/memory.d.ts.map +1 -0
- package/dist/memory/memory.js +212 -0
- package/dist/memory/memory.js.map +1 -0
- package/dist/resources/index.d.ts +3 -0
- package/dist/resources/index.d.ts.map +1 -0
- package/dist/resources/index.js +16 -0
- package/dist/resources/index.js.map +1 -0
- package/dist/resources/resources.d.ts +86 -0
- package/dist/resources/resources.d.ts.map +1 -0
- package/dist/resources/resources.js +285 -0
- package/dist/resources/resources.js.map +1 -0
- package/dist/utils/formatter.d.ts +26 -0
- package/dist/utils/formatter.d.ts.map +1 -0
- package/dist/utils/formatter.js +56 -0
- package/dist/utils/formatter.js.map +1 -0
- package/dist/utils/index.d.ts +7 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +17 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/logger.d.ts +21 -0
- package/dist/utils/logger.d.ts.map +1 -0
- package/dist/utils/logger.js +44 -0
- package/dist/utils/logger.js.map +1 -0
- package/dist/utils/token-counter.d.ts +24 -0
- package/dist/utils/token-counter.d.ts.map +1 -0
- package/dist/utils/token-counter.js +49 -0
- package/dist/utils/token-counter.js.map +1 -0
- package/package.json +70 -0
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.planningTools = void 0;
|
|
4
|
+
exports.implementationPlan = implementationPlan;
|
|
5
|
+
exports.pocPlan = pocPlan;
|
|
6
|
+
// Planning Capability Tools
|
|
7
|
+
const zod_1 = require("zod");
|
|
8
|
+
// ============================================================================
|
|
9
|
+
// Implementation Plan
|
|
10
|
+
// ============================================================================
|
|
11
|
+
const ImplementationPlanSchema = zod_1.z.object({
|
|
12
|
+
task: zod_1.z.string().describe('Feature or fix description'),
|
|
13
|
+
taskType: zod_1.z.enum(['feature', 'bug']).describe('Type of task'),
|
|
14
|
+
scope: zod_1.z.array(zod_1.z.string()).describe('Files in scope'),
|
|
15
|
+
existingPatterns: zod_1.z.array(zod_1.z.string()).optional().describe('Existing patterns to follow')
|
|
16
|
+
});
|
|
17
|
+
async function implementationPlan(params, verbosity = 'minimal') {
|
|
18
|
+
const { task, taskType, scope, existingPatterns = [] } = params;
|
|
19
|
+
const steps = [];
|
|
20
|
+
const editTargets = [];
|
|
21
|
+
const requiredTests = [];
|
|
22
|
+
const requiredDocs = [];
|
|
23
|
+
const riskNotes = [];
|
|
24
|
+
// Analyze scope and generate plan steps
|
|
25
|
+
for (let i = 0; i < scope.length; i++) {
|
|
26
|
+
const file = scope[i];
|
|
27
|
+
if (taskType === 'feature') {
|
|
28
|
+
steps.push({
|
|
29
|
+
order: i + 1,
|
|
30
|
+
description: `Implement in ${file}`,
|
|
31
|
+
file,
|
|
32
|
+
action: 'modify'
|
|
33
|
+
});
|
|
34
|
+
editTargets.push({
|
|
35
|
+
file,
|
|
36
|
+
description: `Add new functionality for: ${task}`
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
// Bug fix
|
|
41
|
+
steps.push({
|
|
42
|
+
order: i + 1,
|
|
43
|
+
description: `Fix bug in ${file}`,
|
|
44
|
+
file,
|
|
45
|
+
action: 'modify'
|
|
46
|
+
});
|
|
47
|
+
editTargets.push({
|
|
48
|
+
file,
|
|
49
|
+
description: `Address the bug: ${task}`
|
|
50
|
+
});
|
|
51
|
+
riskNotes.push(`Potential regression risk in ${file}`);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
// Add test creation step
|
|
55
|
+
steps.push({
|
|
56
|
+
order: steps.length + 1,
|
|
57
|
+
description: 'Create or update tests',
|
|
58
|
+
file: scope[0] || 'test file',
|
|
59
|
+
action: 'create',
|
|
60
|
+
dependencies: steps.map(s => s.file)
|
|
61
|
+
});
|
|
62
|
+
requiredTests.push(`${scope[0] || 'source'}.test.ts`);
|
|
63
|
+
// Add documentation step
|
|
64
|
+
if (taskType === 'feature') {
|
|
65
|
+
steps.push({
|
|
66
|
+
order: steps.length + 1,
|
|
67
|
+
description: 'Update documentation',
|
|
68
|
+
file: 'docs',
|
|
69
|
+
action: 'modify'
|
|
70
|
+
});
|
|
71
|
+
requiredDocs.push('README.md');
|
|
72
|
+
}
|
|
73
|
+
return {
|
|
74
|
+
steps,
|
|
75
|
+
editTargets,
|
|
76
|
+
requiredTests,
|
|
77
|
+
requiredDocs,
|
|
78
|
+
riskNotes,
|
|
79
|
+
handle: `plan_${Date.now()}`
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
// ============================================================================
|
|
83
|
+
// POC Plan
|
|
84
|
+
// ============================================================================
|
|
85
|
+
const POCPlanSchema = zod_1.z.object({
|
|
86
|
+
goal: zod_1.z.string().describe('POC goal description'),
|
|
87
|
+
constraints: zod_1.z.array(zod_1.z.string()).optional().describe('Known constraints or limitations'),
|
|
88
|
+
existingCode: zod_1.z.array(zod_1.z.string()).optional().describe('Existing code to leverage')
|
|
89
|
+
});
|
|
90
|
+
async function pocPlan(params, verbosity = 'minimal') {
|
|
91
|
+
const { goal, constraints = [], existingCode = [] } = params;
|
|
92
|
+
// Generate minimal architecture based on goal
|
|
93
|
+
let minimalArchitecture = 'Simple Node.js module';
|
|
94
|
+
const filesToCreate = [];
|
|
95
|
+
const shortcutsAllowed = [];
|
|
96
|
+
const excludedScope = [];
|
|
97
|
+
// Analyze goal and determine scope
|
|
98
|
+
const goalLower = goal.toLowerCase();
|
|
99
|
+
if (goalLower.includes('api') || goalLower.includes('endpoint')) {
|
|
100
|
+
minimalArchitecture = 'Simple Express/ HTTP handler with minimal routing';
|
|
101
|
+
filesToCreate.push('src/poc/handler.ts');
|
|
102
|
+
shortcutsAllowed.push('Use in-memory storage');
|
|
103
|
+
shortcutsAllowed.push('Skip authentication');
|
|
104
|
+
excludedScope.push('Database integration');
|
|
105
|
+
excludedScope.push('Complex validation');
|
|
106
|
+
}
|
|
107
|
+
else if (goalLower.includes('database') || goalLower.includes('storage')) {
|
|
108
|
+
minimalArchitecture = 'In-memory or file-based storage';
|
|
109
|
+
filesToCreate.push('src/poc/storage.ts');
|
|
110
|
+
shortcutsAllowed.push('Skip connection pooling');
|
|
111
|
+
excludedScope.push('Production database');
|
|
112
|
+
}
|
|
113
|
+
else if (goalLower.includes('ui') || goalLower.includes('interface')) {
|
|
114
|
+
minimalArchitecture = 'Minimal UI component';
|
|
115
|
+
filesToCreate.push('src/poc/Component.tsx');
|
|
116
|
+
shortcutsAllowed.push('Skip styling');
|
|
117
|
+
shortcutsAllowed.push('Use mock data');
|
|
118
|
+
}
|
|
119
|
+
else {
|
|
120
|
+
minimalArchitecture = 'Simple module with core logic';
|
|
121
|
+
filesToCreate.push('src/poc/index.ts');
|
|
122
|
+
shortcutsAllowed.push('Skip error handling');
|
|
123
|
+
shortcutsAllowed.push('Skip logging');
|
|
124
|
+
}
|
|
125
|
+
// Add constraint-based exclusions
|
|
126
|
+
for (const constraint of constraints) {
|
|
127
|
+
const constraintLower = constraint.toLowerCase();
|
|
128
|
+
if (constraintLower.includes('no auth')) {
|
|
129
|
+
excludedScope.push('Authentication');
|
|
130
|
+
}
|
|
131
|
+
if (constraintLower.includes('simple')) {
|
|
132
|
+
excludedScope.push('Advanced features');
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
const mockStrategy = 'Use hardcoded test data and in-memory implementations';
|
|
136
|
+
return {
|
|
137
|
+
goal,
|
|
138
|
+
minimalArchitecture,
|
|
139
|
+
filesToCreate,
|
|
140
|
+
shortcutsAllowed,
|
|
141
|
+
excludedScope,
|
|
142
|
+
mockStrategy,
|
|
143
|
+
handle: `poc_${Date.now()}`
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
exports.planningTools = {
|
|
147
|
+
implementation_plan: {
|
|
148
|
+
name: 'implementation_plan',
|
|
149
|
+
description: 'Build implementation plan for new feature or fix',
|
|
150
|
+
inputSchema: {
|
|
151
|
+
type: 'object',
|
|
152
|
+
properties: {
|
|
153
|
+
task: { type: 'string', description: 'Feature or fix description' },
|
|
154
|
+
taskType: { type: 'string', enum: ['feature', 'bug'], description: 'Type of task' },
|
|
155
|
+
scope: { type: 'array', items: { type: 'string' }, description: 'Files in scope' },
|
|
156
|
+
existingPatterns: { type: 'array', items: { type: 'string' }, description: 'Existing patterns to follow' }
|
|
157
|
+
},
|
|
158
|
+
required: ['task', 'taskType', 'scope']
|
|
159
|
+
},
|
|
160
|
+
handler: implementationPlan,
|
|
161
|
+
schema: ImplementationPlanSchema
|
|
162
|
+
},
|
|
163
|
+
poc_plan: {
|
|
164
|
+
name: 'poc_plan',
|
|
165
|
+
description: 'Define minimum viable POC implementation',
|
|
166
|
+
inputSchema: {
|
|
167
|
+
type: 'object',
|
|
168
|
+
properties: {
|
|
169
|
+
goal: { type: 'string', description: 'POC goal description' },
|
|
170
|
+
constraints: { type: 'array', items: { type: 'string' }, description: 'Known constraints' },
|
|
171
|
+
existingCode: { type: 'array', items: { type: 'string' }, description: 'Existing code to leverage' }
|
|
172
|
+
},
|
|
173
|
+
required: ['goal']
|
|
174
|
+
},
|
|
175
|
+
handler: pocPlan,
|
|
176
|
+
schema: POCPlanSchema
|
|
177
|
+
}
|
|
178
|
+
};
|
|
179
|
+
//# sourceMappingURL=planning.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"planning.js","sourceRoot":"","sources":["../../../src/capabilities/planning/planning.ts"],"names":[],"mappings":";;;AAuBA,gDA0EC;AAcD,0BA0DC;AAzKD,4BAA4B;AAC5B,6BAAwB;AASxB,+EAA+E;AAC/E,sBAAsB;AACtB,+EAA+E;AAE/E,MAAM,wBAAwB,GAAG,OAAC,CAAC,MAAM,CAAC;IACxC,IAAI,EAAE,OAAC,CAAC,MAA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;gBAC3F,YAAY,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE,WAAW,EAAE,2BAA2B,EAAE;aACrG;YACD,QAAQ,EAAE,CAAC,MAAM,CAAC;SACnB;QACD,OAAO,EAAE,OAAO;QAChB,MAAM,EAAE,aAAa;KACtB;CACF,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":"AACA,cAAc,YAAY,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
// Core module exports
|
|
18
|
+
__exportStar(require("./types.js"), exports);
|
|
19
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,sBAAsB;AACtB,6CAA2B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/core/indexer/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.indexRepository = exports.getIndexer = exports.RepoIndexer = void 0;
|
|
4
|
+
// Indexer module exports
|
|
5
|
+
var indexer_js_1 = require("./indexer.js");
|
|
6
|
+
Object.defineProperty(exports, "RepoIndexer", { enumerable: true, get: function () { return indexer_js_1.RepoIndexer; } });
|
|
7
|
+
Object.defineProperty(exports, "getIndexer", { enumerable: true, get: function () { return indexer_js_1.getIndexer; } });
|
|
8
|
+
Object.defineProperty(exports, "indexRepository", { enumerable: true, get: function () { return indexer_js_1.indexRepository; } });
|
|
9
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/core/indexer/index.ts"],"names":[],"mappings":";;;AAAA,yBAAyB;AACzB,2CAAwE;AAA/D,yGAAA,WAAW,OAAA;AAAE,wGAAA,UAAU,OAAA;AAAE,6GAAA,eAAe,OAAA"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { RepositoryIndex } from '../types.js';
|
|
2
|
+
export declare class RepoIndexer {
|
|
3
|
+
private index;
|
|
4
|
+
/**
|
|
5
|
+
* Index a repository directory
|
|
6
|
+
*/
|
|
7
|
+
indexRepository(rootPath: string): Promise<RepositoryIndex>;
|
|
8
|
+
/**
|
|
9
|
+
* Get current index
|
|
10
|
+
*/
|
|
11
|
+
getIndex(): RepositoryIndex | null;
|
|
12
|
+
/**
|
|
13
|
+
* Scan directory for files
|
|
14
|
+
*/
|
|
15
|
+
private scanDirectory;
|
|
16
|
+
/**
|
|
17
|
+
* Extract exports and imports from a file (simple regex-based)
|
|
18
|
+
*/
|
|
19
|
+
private extractExportsImports;
|
|
20
|
+
/**
|
|
21
|
+
* Extract symbols from a file
|
|
22
|
+
*/
|
|
23
|
+
private extractSymbols;
|
|
24
|
+
/**
|
|
25
|
+
* Create test entry
|
|
26
|
+
*/
|
|
27
|
+
private createTestEntry;
|
|
28
|
+
/**
|
|
29
|
+
* Create documentation entry
|
|
30
|
+
*/
|
|
31
|
+
private createDocEntry;
|
|
32
|
+
}
|
|
33
|
+
export declare function getIndexer(): RepoIndexer;
|
|
34
|
+
export declare function indexRepository(rootPath: string): Promise<RepositoryIndex>;
|
|
35
|
+
//# sourceMappingURL=indexer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"indexer.d.ts","sourceRoot":"","sources":["../../../src/core/indexer/indexer.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,eAAe,EAMhB,MAAM,aAAa,CAAC;AA8BrB,qBAAa,WAAW;IACtB,OAAO,CAAC,KAAK,CAAgC;IAE7C;;OAEG;IACG,eAAe,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC;IAgGjE;;OAEG;IACH,QAAQ,IAAI,eAAe,GAAG,IAAI;IAIlC;;OAEG;IACH,OAAO,CAAC,aAAa;IA2BrB;;OAEG;IACH,OAAO,CAAC,qBAAqB;IA6D7B;;OAEG;IACH,OAAO,CAAC,cAAc;IAoEtB;;OAEG;IACH,OAAO,CAAC,eAAe;IA4BvB;;OAEG;IACH,OAAO,CAAC,cAAc;CAgBvB;AAKD,wBAAgB,UAAU,IAAI,WAAW,CAKxC;AAED,wBAAsB,eAAe,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC,CAGhF"}
|
|
@@ -0,0 +1,377 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.RepoIndexer = void 0;
|
|
37
|
+
exports.getIndexer = getIndexer;
|
|
38
|
+
exports.indexRepository = indexRepository;
|
|
39
|
+
// Repo Indexer - Lightweight indexing for code repositories
|
|
40
|
+
const fs = __importStar(require("fs"));
|
|
41
|
+
const path = __importStar(require("path"));
|
|
42
|
+
// Supported file extensions and their languages
|
|
43
|
+
const EXTENSION_LANGUAGE_MAP = {
|
|
44
|
+
'.ts': 'typescript',
|
|
45
|
+
'.tsx': 'typescript',
|
|
46
|
+
'.js': 'javascript',
|
|
47
|
+
'.jsx': 'javascript',
|
|
48
|
+
'.py': 'python',
|
|
49
|
+
'.java': 'java',
|
|
50
|
+
'.go': 'go',
|
|
51
|
+
'.rs': 'rust',
|
|
52
|
+
'.rb': 'ruby',
|
|
53
|
+
'.php': 'php',
|
|
54
|
+
'.cs': 'csharp',
|
|
55
|
+
'.cpp': 'cpp',
|
|
56
|
+
'.c': 'c',
|
|
57
|
+
'.swift': 'swift',
|
|
58
|
+
'.kt': 'kotlin',
|
|
59
|
+
'.scala': 'scala'
|
|
60
|
+
};
|
|
61
|
+
const TEST_PATTERNS = [
|
|
62
|
+
'test', 'spec', '__tests__', 'tests', '.test.', '.spec.'
|
|
63
|
+
];
|
|
64
|
+
const DOC_PATTERNS = [
|
|
65
|
+
'readme', 'changelog', 'contributing', 'license', 'api', 'guide', 'docs'
|
|
66
|
+
];
|
|
67
|
+
class RepoIndexer {
|
|
68
|
+
index = null;
|
|
69
|
+
/**
|
|
70
|
+
* Index a repository directory
|
|
71
|
+
*/
|
|
72
|
+
async indexRepository(rootPath) {
|
|
73
|
+
const files = new Map();
|
|
74
|
+
const symbols = new Map();
|
|
75
|
+
const imports = [];
|
|
76
|
+
const tests = [];
|
|
77
|
+
const docs = [];
|
|
78
|
+
// Check if path exists
|
|
79
|
+
if (!fs.existsSync(rootPath)) {
|
|
80
|
+
throw new Error(`Path does not exist: ${rootPath}`);
|
|
81
|
+
}
|
|
82
|
+
// Recursively scan for files
|
|
83
|
+
const allFiles = this.scanDirectory(rootPath, rootPath);
|
|
84
|
+
for (const filePath of allFiles) {
|
|
85
|
+
const stats = fs.statSync(filePath);
|
|
86
|
+
if (!stats.isFile())
|
|
87
|
+
continue;
|
|
88
|
+
const relativePath = path.relative(rootPath, filePath);
|
|
89
|
+
const ext = path.extname(filePath).toLowerCase();
|
|
90
|
+
const language = EXTENSION_LANGUAGE_MAP[ext] || 'unknown';
|
|
91
|
+
// Determine file type
|
|
92
|
+
let type = 'other';
|
|
93
|
+
const baseName = path.basename(filePath).toLowerCase();
|
|
94
|
+
if (TEST_PATTERNS.some(p => baseName.includes(p))) {
|
|
95
|
+
type = 'test';
|
|
96
|
+
}
|
|
97
|
+
else if (['.json', '.yaml', '.yml', '.toml', '.ini', '.conf'].includes(ext)) {
|
|
98
|
+
type = 'config';
|
|
99
|
+
}
|
|
100
|
+
else if (DOC_PATTERNS.some(p => baseName.includes(p)) || ['.md', '.rst', '.adoc'].includes(ext)) {
|
|
101
|
+
type = 'doc';
|
|
102
|
+
}
|
|
103
|
+
else if (['.ts', '.tsx', '.js', '.jsx', '.py', '.java', '.go', '.rs'].includes(ext)) {
|
|
104
|
+
type = 'source';
|
|
105
|
+
}
|
|
106
|
+
// Extract exports and imports
|
|
107
|
+
const { exports: fileExports, imports: fileImports } = this.extractExportsImports(filePath, language);
|
|
108
|
+
// Create file entry
|
|
109
|
+
const fileEntry = {
|
|
110
|
+
path: relativePath,
|
|
111
|
+
name: path.basename(filePath, ext),
|
|
112
|
+
extension: ext,
|
|
113
|
+
type,
|
|
114
|
+
language,
|
|
115
|
+
size: stats.size,
|
|
116
|
+
lastModified: stats.mtimeMs,
|
|
117
|
+
exports: fileExports,
|
|
118
|
+
imports: fileImports
|
|
119
|
+
};
|
|
120
|
+
files.set(relativePath, fileEntry);
|
|
121
|
+
// Add imports to edge list
|
|
122
|
+
for (const imp of fileImports) {
|
|
123
|
+
imports.push({
|
|
124
|
+
from: relativePath,
|
|
125
|
+
to: imp,
|
|
126
|
+
types: ['import']
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
// Extract symbols for source files
|
|
130
|
+
if (type === 'source' || type === 'test') {
|
|
131
|
+
const fileSymbols = this.extractSymbols(filePath, language);
|
|
132
|
+
symbols.set(relativePath, fileSymbols);
|
|
133
|
+
}
|
|
134
|
+
// Add to test index
|
|
135
|
+
if (type === 'test') {
|
|
136
|
+
const testEntry = this.createTestEntry(filePath, relativePath, symbols);
|
|
137
|
+
if (testEntry)
|
|
138
|
+
tests.push(testEntry);
|
|
139
|
+
}
|
|
140
|
+
// Add to doc index
|
|
141
|
+
if (type === 'doc') {
|
|
142
|
+
const docEntry = this.createDocEntry(filePath, relativePath);
|
|
143
|
+
if (docEntry)
|
|
144
|
+
docs.push(docEntry);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
this.index = {
|
|
148
|
+
files,
|
|
149
|
+
symbols,
|
|
150
|
+
imports,
|
|
151
|
+
tests,
|
|
152
|
+
docs,
|
|
153
|
+
rootPath,
|
|
154
|
+
lastIndexed: Date.now()
|
|
155
|
+
};
|
|
156
|
+
return this.index;
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* Get current index
|
|
160
|
+
*/
|
|
161
|
+
getIndex() {
|
|
162
|
+
return this.index;
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* Scan directory for files
|
|
166
|
+
*/
|
|
167
|
+
scanDirectory(dirPath, rootPath) {
|
|
168
|
+
const results = [];
|
|
169
|
+
const ignoreDirs = ['node_modules', '.git', 'dist', 'build', 'coverage', '.venv', 'vendor', '__pycache__'];
|
|
170
|
+
try {
|
|
171
|
+
const entries = fs.readdirSync(dirPath);
|
|
172
|
+
for (const entry of entries) {
|
|
173
|
+
if (ignoreDirs.includes(entry))
|
|
174
|
+
continue;
|
|
175
|
+
if (entry.startsWith('.'))
|
|
176
|
+
continue;
|
|
177
|
+
const fullPath = path.join(dirPath, entry);
|
|
178
|
+
const stats = fs.statSync(fullPath);
|
|
179
|
+
if (stats.isDirectory()) {
|
|
180
|
+
results.push(...this.scanDirectory(fullPath, rootPath));
|
|
181
|
+
}
|
|
182
|
+
else {
|
|
183
|
+
results.push(fullPath);
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
catch {
|
|
188
|
+
// Ignore permission errors
|
|
189
|
+
}
|
|
190
|
+
return results;
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* Extract exports and imports from a file (simple regex-based)
|
|
194
|
+
*/
|
|
195
|
+
extractExportsImports(filePath, language) {
|
|
196
|
+
const exports = [];
|
|
197
|
+
const imports = [];
|
|
198
|
+
try {
|
|
199
|
+
const content = fs.readFileSync(filePath, 'utf-8');
|
|
200
|
+
if (language === 'typescript' || language === 'javascript') {
|
|
201
|
+
// Extract named exports: export const/function/class...
|
|
202
|
+
const exportRegex = /export\s+(?:const|function|class|interface|type|let|var)\s+(\w+)/g;
|
|
203
|
+
let match;
|
|
204
|
+
while ((match = exportRegex.exec(content)) !== null) {
|
|
205
|
+
exports.push(match[1]);
|
|
206
|
+
}
|
|
207
|
+
// Extract default exports
|
|
208
|
+
const defaultExportRegex = /export\s+default\s+(\w+)/g;
|
|
209
|
+
while ((match = defaultExportRegex.exec(content)) !== null) {
|
|
210
|
+
exports.push(match[1]);
|
|
211
|
+
}
|
|
212
|
+
// Extract named exports: export { ... }
|
|
213
|
+
const namedExportRegex = /export\s*\{\s*([^}]+)\s*\}/g;
|
|
214
|
+
while ((match = namedExportRegex.exec(content)) !== null) {
|
|
215
|
+
const exported = match[1].split(',').map(s => s.trim()).filter(s => s);
|
|
216
|
+
exports.push(...exported);
|
|
217
|
+
}
|
|
218
|
+
// Extract imports: import ... from '...'
|
|
219
|
+
const importRegex = /import\s+(?:\{\s*([^}]+)\s*\}|\*\s+as\s+\w+|\w+)\s+from\s+['"]([^'"]+)['"]/g;
|
|
220
|
+
while ((match = importRegex.exec(content)) !== null) {
|
|
221
|
+
imports.push(match[2]);
|
|
222
|
+
}
|
|
223
|
+
// Extract require: const ... = require('...')
|
|
224
|
+
const requireRegex = /require\s*\(\s*['"]([^'"]+)['"]\s*\)/g;
|
|
225
|
+
while ((match = requireRegex.exec(content)) !== null) {
|
|
226
|
+
imports.push(match[1]);
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
else if (language === 'python') {
|
|
230
|
+
// Extract Python exports
|
|
231
|
+
const pyExportRegex = /(?:^|\n)\s*(?:def|class)\s+(\w+)/gm;
|
|
232
|
+
let match;
|
|
233
|
+
while ((match = pyExportRegex.exec(content)) !== null) {
|
|
234
|
+
exports.push(match[1]);
|
|
235
|
+
}
|
|
236
|
+
// Extract imports
|
|
237
|
+
const pyImportRegex = /(?:^|\n)\s*import\s+([^\n]+)|(?:^|\n)\s*from\s+([^\n]+)\s+import/gm;
|
|
238
|
+
while ((match = pyImportRegex.exec(content)) !== null) {
|
|
239
|
+
imports.push(match[1] || match[2]);
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
// Add more languages as needed
|
|
243
|
+
}
|
|
244
|
+
catch {
|
|
245
|
+
// Ignore read errors
|
|
246
|
+
}
|
|
247
|
+
return { exports, imports };
|
|
248
|
+
}
|
|
249
|
+
/**
|
|
250
|
+
* Extract symbols from a file
|
|
251
|
+
*/
|
|
252
|
+
extractSymbols(filePath, language) {
|
|
253
|
+
const symbols = [];
|
|
254
|
+
try {
|
|
255
|
+
const content = fs.readFileSync(filePath, 'utf-8');
|
|
256
|
+
const lines = content.split('\n');
|
|
257
|
+
if (language === 'typescript' || language === 'javascript') {
|
|
258
|
+
// Find functions
|
|
259
|
+
const funcRegex = /(?:export\s+)?(?:async\s+)?function\s+(\w+)/g;
|
|
260
|
+
let match;
|
|
261
|
+
while ((match = funcRegex.exec(content)) !== null) {
|
|
262
|
+
const line = content.substring(0, match.index).split('\n').length - 1;
|
|
263
|
+
symbols.push({
|
|
264
|
+
name: match[1],
|
|
265
|
+
type: 'function',
|
|
266
|
+
file: filePath,
|
|
267
|
+
line,
|
|
268
|
+
exported: content.substring(match.index - 20, match.index).includes('export')
|
|
269
|
+
});
|
|
270
|
+
}
|
|
271
|
+
// Find classes
|
|
272
|
+
const classRegex = /(?:export\s+)?class\s+(\w+)/g;
|
|
273
|
+
while ((match = classRegex.exec(content)) !== null) {
|
|
274
|
+
const line = content.substring(0, match.index).split('\n').length - 1;
|
|
275
|
+
symbols.push({
|
|
276
|
+
name: match[1],
|
|
277
|
+
type: 'class',
|
|
278
|
+
file: filePath,
|
|
279
|
+
line,
|
|
280
|
+
exported: content.substring(match.index - 20, match.index).includes('export')
|
|
281
|
+
});
|
|
282
|
+
}
|
|
283
|
+
// Find interfaces
|
|
284
|
+
const interfaceRegex = /(?:export\s+)?interface\s+(\w+)/g;
|
|
285
|
+
while ((match = interfaceRegex.exec(content)) !== null) {
|
|
286
|
+
const line = content.substring(0, match.index).split('\n').length - 1;
|
|
287
|
+
symbols.push({
|
|
288
|
+
name: match[1],
|
|
289
|
+
type: 'interface',
|
|
290
|
+
file: filePath,
|
|
291
|
+
line,
|
|
292
|
+
exported: content.substring(match.index - 20, match.index).includes('export')
|
|
293
|
+
});
|
|
294
|
+
}
|
|
295
|
+
// Find const/let/var declarations
|
|
296
|
+
const constRegex = /(?:export\s+)?(?:const|let|var)\s+(\w+)\s*=/g;
|
|
297
|
+
while ((match = constRegex.exec(content)) !== null) {
|
|
298
|
+
const line = content.substring(0, match.index).split('\n').length - 1;
|
|
299
|
+
symbols.push({
|
|
300
|
+
name: match[1],
|
|
301
|
+
type: 'constant',
|
|
302
|
+
file: filePath,
|
|
303
|
+
line,
|
|
304
|
+
exported: content.substring(match.index - 20, match.index).includes('export')
|
|
305
|
+
});
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
catch {
|
|
310
|
+
// Ignore errors
|
|
311
|
+
}
|
|
312
|
+
return symbols;
|
|
313
|
+
}
|
|
314
|
+
/**
|
|
315
|
+
* Create test entry
|
|
316
|
+
*/
|
|
317
|
+
createTestEntry(filePath, relativePath, symbols) {
|
|
318
|
+
const name = path.basename(filePath);
|
|
319
|
+
// Determine test type
|
|
320
|
+
let type = 'unit';
|
|
321
|
+
if (name.includes('integration'))
|
|
322
|
+
type = 'integration';
|
|
323
|
+
else if (name.includes('e2e') || name.includes('end-to-end'))
|
|
324
|
+
type = 'e2e';
|
|
325
|
+
// Try to find target file
|
|
326
|
+
let targetFile;
|
|
327
|
+
const targetSymbols = [];
|
|
328
|
+
// Look for matching source file
|
|
329
|
+
const baseName = name
|
|
330
|
+
.replace(/\.test\.(js|ts|jsx|tsx)$/, '')
|
|
331
|
+
.replace(/\.spec\.(js|ts|jsx|tsx)$/, '')
|
|
332
|
+
.replace(/^test-/, '')
|
|
333
|
+
.replace(/^spec-/, '');
|
|
334
|
+
return {
|
|
335
|
+
path: relativePath,
|
|
336
|
+
name,
|
|
337
|
+
type,
|
|
338
|
+
targetFile,
|
|
339
|
+
targetSymbols
|
|
340
|
+
};
|
|
341
|
+
}
|
|
342
|
+
/**
|
|
343
|
+
* Create documentation entry
|
|
344
|
+
*/
|
|
345
|
+
createDocEntry(filePath, relativePath) {
|
|
346
|
+
const name = path.basename(filePath).toLowerCase();
|
|
347
|
+
let type = 'other';
|
|
348
|
+
if (name.startsWith('readme'))
|
|
349
|
+
type = 'readme';
|
|
350
|
+
else if (name.includes('changelog') || name.includes('history'))
|
|
351
|
+
type = 'changelog';
|
|
352
|
+
else if (name.includes('api'))
|
|
353
|
+
type = 'api';
|
|
354
|
+
else if (name.includes('guide') || name.includes('docs'))
|
|
355
|
+
type = 'guide';
|
|
356
|
+
return {
|
|
357
|
+
path: relativePath,
|
|
358
|
+
name: path.basename(filePath),
|
|
359
|
+
type,
|
|
360
|
+
sections: [] // Could extract sections from markdown
|
|
361
|
+
};
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
exports.RepoIndexer = RepoIndexer;
|
|
365
|
+
// Singleton instance
|
|
366
|
+
let indexerInstance = null;
|
|
367
|
+
function getIndexer() {
|
|
368
|
+
if (!indexerInstance) {
|
|
369
|
+
indexerInstance = new RepoIndexer();
|
|
370
|
+
}
|
|
371
|
+
return indexerInstance;
|
|
372
|
+
}
|
|
373
|
+
async function indexRepository(rootPath) {
|
|
374
|
+
const indexer = getIndexer();
|
|
375
|
+
return indexer.indexRepository(rootPath);
|
|
376
|
+
}
|
|
377
|
+
//# sourceMappingURL=indexer.js.map
|