@hivehub/rulebook 4.0.0 → 4.1.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/.claude-plugin/plugin.json +1 -1
- package/README.md +34 -0
- package/dist/core/indexer/background-indexer.d.ts +27 -0
- package/dist/core/indexer/background-indexer.d.ts.map +1 -0
- package/dist/core/indexer/background-indexer.js +135 -0
- package/dist/core/indexer/background-indexer.js.map +1 -0
- package/dist/core/indexer/file-parser.d.ts +28 -0
- package/dist/core/indexer/file-parser.d.ts.map +1 -0
- package/dist/core/indexer/file-parser.js +171 -0
- package/dist/core/indexer/file-parser.js.map +1 -0
- package/dist/core/indexer/indexer-types.d.ts +35 -0
- package/dist/core/indexer/indexer-types.d.ts.map +1 -0
- package/dist/core/indexer/indexer-types.js +8 -0
- package/dist/core/indexer/indexer-types.js.map +1 -0
- package/dist/mcp/rulebook-server.d.ts.map +1 -1
- package/dist/mcp/rulebook-server.js +109 -7
- package/dist/mcp/rulebook-server.js.map +1 -1
- package/dist/memory/memory-manager.d.ts +4 -1
- package/dist/memory/memory-manager.d.ts.map +1 -1
- package/dist/memory/memory-manager.js +33 -4
- package/dist/memory/memory-manager.js.map +1 -1
- package/dist/memory/memory-search.d.ts +2 -2
- package/dist/memory/memory-search.d.ts.map +1 -1
- package/dist/memory/memory-search.js +19 -0
- package/dist/memory/memory-search.js.map +1 -1
- package/dist/memory/memory-store.d.ts +13 -0
- package/dist/memory/memory-store.d.ts.map +1 -1
- package/dist/memory/memory-store.js +88 -1
- package/dist/memory/memory-store.js.map +1 -1
- package/dist/memory/memory-types.d.ts +15 -0
- package/dist/memory/memory-types.d.ts.map +1 -1
- package/package.json +1 -1
- package/templates/commands/rulebook-task-archive.md +24 -0
- package/templates/core/RULEBOOK.md +42 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rulebook",
|
|
3
3
|
"description": "Standardize AI-generated projects with Ralph autonomous loop, persistent memory, and quality gates. Supports 28 languages, 17 frameworks, 13 MCP modules, and 20 services.",
|
|
4
|
-
"version": "4.
|
|
4
|
+
"version": "4.1.0",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "HiveLLM"
|
|
7
7
|
}
|
package/README.md
CHANGED
|
@@ -52,6 +52,13 @@ npx @hivehub/rulebook@latest update
|
|
|
52
52
|
|
|
53
53
|
See the full [CHANGELOG](CHANGELOG.md) for details.
|
|
54
54
|
|
|
55
|
+
### v4.1.0 — Background Indexer & Codebase Intelligence
|
|
56
|
+
|
|
57
|
+
- 🔍 **Background Indexer**: Autonomous daemon that continuously indexes your codebase into a searchable vector + graph database
|
|
58
|
+
- 🧠 **3 New MCP Tools**: `rulebook_codebase_search` (semantic code search), `rulebook_codebase_graph` (import/export relationships), `rulebook_indexer_status` (daemon status)
|
|
59
|
+
- 📋 **Deferred Items Protocol**: New mandatory directive ensuring deferred task items always get tracked as new Rulebook tasks before archiving
|
|
60
|
+
- 📚 **22 MCP Functions** total (was 19)
|
|
61
|
+
|
|
55
62
|
### v4.0.0 — AI-first DX & Ralph maturity
|
|
56
63
|
|
|
57
64
|
- 🚀 **Zero-prompt `init`**: auto-configures from detection, no questionnaires
|
|
@@ -187,6 +194,33 @@ Memory is enabled in `.rulebook`:
|
|
|
187
194
|
- 📦 **Publication Ready**: CI/CD pipelines for npm, crates.io, PyPI, Maven Central, and more
|
|
188
195
|
- 🔄 **Automatic Migration**: Existing projects automatically migrated to modular structure
|
|
189
196
|
|
|
197
|
+
## VSCode Extension
|
|
198
|
+
|
|
199
|
+
The **Rulebook Dashboard** extension brings full visibility into your AI-powered workflow directly inside VSCode.
|
|
200
|
+
|
|
201
|
+
```bash
|
|
202
|
+
# Install from .vsix (local)
|
|
203
|
+
code --install-extension vscode-extension/rulebook-dashboard-*.vsix
|
|
204
|
+
|
|
205
|
+
# Or build from source
|
|
206
|
+
cd vscode-extension && npm install && npm run compile
|
|
207
|
+
# Press F5 to launch Extension Development Host
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
| Tab | What it shows |
|
|
211
|
+
|-----|---------------|
|
|
212
|
+
| 🤖 **Agents** | All Claude agent team members with real-time status (active/idle), memory state, last activity |
|
|
213
|
+
| 📋 **Tasks** | Project tasks with progress bars, expandable details, Archive & Update via AI buttons |
|
|
214
|
+
| 🔄 **Ralph** | Autonomous loop status, current iteration, progress tracking |
|
|
215
|
+
| 🧠 **Memory** | Memory stats (count, DB size, types), full-text search, clear/reprocess |
|
|
216
|
+
| 🔍 **Indexer** | Background indexer status, files processed, queue size, reindex button |
|
|
217
|
+
|
|
218
|
+
**Multi-root workspace support** — scans all open workspace folders for `.claude/agents/`, `.rulebook/tasks/`, and more.
|
|
219
|
+
|
|
220
|
+
**Status Bar** — `📖 Rulebook` button (opens dashboard), indexer indicator, Ralph running state.
|
|
221
|
+
|
|
222
|
+
> See [`vscode-extension/README.md`](vscode-extension/README.md) for full documentation.
|
|
223
|
+
|
|
190
224
|
## What It Does
|
|
191
225
|
|
|
192
226
|
**For New Projects:**
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { MemoryManager } from '../../memory/memory-manager.js';
|
|
2
|
+
import type { IndexerConfig } from './indexer-types.js';
|
|
3
|
+
export declare class BackgroundIndexer {
|
|
4
|
+
private memoryManager;
|
|
5
|
+
private parser;
|
|
6
|
+
private config;
|
|
7
|
+
private projectRoot;
|
|
8
|
+
private isProcessing;
|
|
9
|
+
private processQueue;
|
|
10
|
+
private debounceTimer;
|
|
11
|
+
private watchControllers;
|
|
12
|
+
private processedCount;
|
|
13
|
+
private errorCount;
|
|
14
|
+
constructor(memoryManager: MemoryManager, projectRoot: string, config?: Partial<IndexerConfig>);
|
|
15
|
+
start(): void;
|
|
16
|
+
stop(): void;
|
|
17
|
+
getStatus(): {
|
|
18
|
+
queue: number;
|
|
19
|
+
processed: number;
|
|
20
|
+
errors: number;
|
|
21
|
+
isProcessing: boolean;
|
|
22
|
+
};
|
|
23
|
+
private isIgnored;
|
|
24
|
+
private handleFileChange;
|
|
25
|
+
private processNextBatch;
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=background-indexer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"background-indexer.d.ts","sourceRoot":"","sources":["../../../src/core/indexer/background-indexer.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAC;AAEpE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAExD,qBAAa,iBAAiB;IAC1B,OAAO,CAAC,aAAa,CAAgB;IACrC,OAAO,CAAC,MAAM,CAAa;IAC3B,OAAO,CAAC,MAAM,CAAgB;IAC9B,OAAO,CAAC,WAAW,CAAS;IAC5B,OAAO,CAAC,YAAY,CAAS;IAC7B,OAAO,CAAC,YAAY,CAA0B;IAC9C,OAAO,CAAC,aAAa,CAA+B;IACpD,OAAO,CAAC,gBAAgB,CAA0C;IAGlE,OAAO,CAAC,cAAc,CAAK;IAC3B,OAAO,CAAC,UAAU,CAAK;gBAEX,aAAa,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,GAAE,OAAO,CAAC,aAAa,CAAM;IAa3F,KAAK,IAAI,IAAI;IAsBb,IAAI,IAAI,IAAI;IAOZ,SAAS,IAAI;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAC;QAAC,YAAY,EAAE,OAAO,CAAA;KAAE;IAS/F,OAAO,CAAC,SAAS;IAmBjB,OAAO,CAAC,gBAAgB;YAeV,gBAAgB;CAkDjC"}
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import { existsSync, statSync, watch } from 'fs';
|
|
2
|
+
import { extname, join, resolve } from 'path';
|
|
3
|
+
import { CodeParser } from './file-parser.js';
|
|
4
|
+
export class BackgroundIndexer {
|
|
5
|
+
memoryManager;
|
|
6
|
+
parser;
|
|
7
|
+
config;
|
|
8
|
+
projectRoot;
|
|
9
|
+
isProcessing = false;
|
|
10
|
+
processQueue = new Set();
|
|
11
|
+
debounceTimer = null;
|
|
12
|
+
watchControllers = new Set();
|
|
13
|
+
// Stats
|
|
14
|
+
processedCount = 0;
|
|
15
|
+
errorCount = 0;
|
|
16
|
+
constructor(memoryManager, projectRoot, config = {}) {
|
|
17
|
+
this.memoryManager = memoryManager;
|
|
18
|
+
this.projectRoot = resolve(projectRoot);
|
|
19
|
+
this.parser = new CodeParser();
|
|
20
|
+
this.config = {
|
|
21
|
+
enabled: config.enabled ?? true,
|
|
22
|
+
watchPaths: config.watchPaths ?? ['.'],
|
|
23
|
+
ignorePatterns: config.ignorePatterns ?? ['node_modules', '.git', 'dist', 'build', '.rulebook', 'coverage'],
|
|
24
|
+
chunkSize: config.chunkSize ?? 1500,
|
|
25
|
+
debounceMs: config.debounceMs ?? 3000,
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
start() {
|
|
29
|
+
if (!this.config.enabled)
|
|
30
|
+
return;
|
|
31
|
+
console.log(`[BackgroundIndexer] Starting watcher on: ${this.projectRoot}`);
|
|
32
|
+
// Very naive watcher for V1 (Node.js native Recursive FS Watcher when available, otherwise basic)
|
|
33
|
+
// Production ready app should probably use `chokidar` here, but sticking to native limits deps
|
|
34
|
+
try {
|
|
35
|
+
const watcher = watch(this.projectRoot, { recursive: true }, (_, filename) => {
|
|
36
|
+
if (!filename)
|
|
37
|
+
return;
|
|
38
|
+
this.handleFileChange(filename);
|
|
39
|
+
});
|
|
40
|
+
watcher.on('error', (error) => {
|
|
41
|
+
console.error('[BackgroundIndexer] Watcher error:', error);
|
|
42
|
+
});
|
|
43
|
+
this.watchControllers.add(watcher);
|
|
44
|
+
}
|
|
45
|
+
catch (e) {
|
|
46
|
+
console.warn(`[BackgroundIndexer] Recursive FS watch failed. Falling back to targeted watching may be required. Error: ${e}`);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
stop() {
|
|
50
|
+
this.watchControllers.forEach(w => w.close());
|
|
51
|
+
this.watchControllers.clear();
|
|
52
|
+
if (this.debounceTimer)
|
|
53
|
+
clearTimeout(this.debounceTimer);
|
|
54
|
+
console.log('[BackgroundIndexer] Stopped');
|
|
55
|
+
}
|
|
56
|
+
getStatus() {
|
|
57
|
+
return {
|
|
58
|
+
queue: this.processQueue.size,
|
|
59
|
+
processed: this.processedCount,
|
|
60
|
+
errors: this.errorCount,
|
|
61
|
+
isProcessing: this.isProcessing
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
isIgnored(filePath) {
|
|
65
|
+
// Basic ignore check
|
|
66
|
+
const normalizedPath = filePath.replace(/\\/g, '/');
|
|
67
|
+
for (const pattern of this.config.ignorePatterns) {
|
|
68
|
+
if (normalizedPath.includes(`/${pattern}/`) || normalizedPath.startsWith(`${pattern}/`) || normalizedPath.includes(`\\${pattern}\\`)) {
|
|
69
|
+
return true;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
// Ignore non-code files or assets
|
|
73
|
+
const ext = extname(filePath).toLowerCase();
|
|
74
|
+
const ignoredExts = ['.png', '.jpg', '.jpeg', '.gif', '.svg', '.ico', '.mp3', '.mp4', '.sqlite', '.db', '.pdf'];
|
|
75
|
+
if (ignoredExts.includes(ext)) {
|
|
76
|
+
return true;
|
|
77
|
+
}
|
|
78
|
+
return false;
|
|
79
|
+
}
|
|
80
|
+
handleFileChange(filename) {
|
|
81
|
+
const fullPath = join(this.projectRoot, filename);
|
|
82
|
+
if (this.isIgnored(filename))
|
|
83
|
+
return;
|
|
84
|
+
this.processQueue.add(fullPath);
|
|
85
|
+
// Debounce the queue processor
|
|
86
|
+
if (this.debounceTimer)
|
|
87
|
+
clearTimeout(this.debounceTimer);
|
|
88
|
+
this.debounceTimer = setTimeout(() => {
|
|
89
|
+
this.processNextBatch();
|
|
90
|
+
}, this.config.debounceMs);
|
|
91
|
+
}
|
|
92
|
+
async processNextBatch() {
|
|
93
|
+
if (this.isProcessing || this.processQueue.size === 0)
|
|
94
|
+
return;
|
|
95
|
+
this.isProcessing = true;
|
|
96
|
+
const batch = Array.from(this.processQueue);
|
|
97
|
+
this.processQueue.clear();
|
|
98
|
+
console.log(`[BackgroundIndexer] Processing batch of ${batch.length} files...`);
|
|
99
|
+
for (const filePath of batch) {
|
|
100
|
+
try {
|
|
101
|
+
if (!existsSync(filePath)) {
|
|
102
|
+
// File was deleted
|
|
103
|
+
await this.memoryManager.deleteCodeNodesByFile(filePath);
|
|
104
|
+
continue;
|
|
105
|
+
}
|
|
106
|
+
const stats = statSync(filePath);
|
|
107
|
+
if (!stats.isFile())
|
|
108
|
+
continue;
|
|
109
|
+
// Parse
|
|
110
|
+
const { nodes, edges } = this.parser.parseFile(filePath);
|
|
111
|
+
// 1. Flush old Nodes/Edges for this file (Cascade handles Edges)
|
|
112
|
+
await this.memoryManager.deleteCodeNodesByFile(filePath);
|
|
113
|
+
// 2. Insert new Nodes
|
|
114
|
+
for (const node of nodes) {
|
|
115
|
+
await this.memoryManager.saveCodeNode(node);
|
|
116
|
+
}
|
|
117
|
+
// 3. Insert new Edges
|
|
118
|
+
for (const edge of edges) {
|
|
119
|
+
await this.memoryManager.saveCodeEdge(edge);
|
|
120
|
+
}
|
|
121
|
+
this.processedCount++;
|
|
122
|
+
}
|
|
123
|
+
catch (e) {
|
|
124
|
+
console.error(`[BackgroundIndexer] Error processing ${filePath}:`, e);
|
|
125
|
+
this.errorCount++;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
this.isProcessing = false;
|
|
129
|
+
// If more accumulated while processing, trigger again
|
|
130
|
+
if (this.processQueue.size > 0) {
|
|
131
|
+
this.handleFileChange('__trigger_batch__');
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
//# sourceMappingURL=background-indexer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"background-indexer.js","sourceRoot":"","sources":["../../../src/core/indexer/background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,CAAC,IAAI,CAAC,CAAC;gBAChD,CAAC;gBAED,IAAI,CAAC,cAAc,EAAE,CAAC;YAC1B,CAAC;YAAC,OAAO,CAAC,EAAE,CAAC;gBACT,OAAO,CAAC,KAAK,CAAC,wCAAwC,QAAQ,GAAG,EAAE,CAAC,CAAC,CAAC;gBACtE,IAAI,CAAC,UAAU,EAAE,CAAC;YACtB,CAAC;QACL,CAAC;QAED,IAAI,CAAC,YAAY,GAAG,KAAK,CAAC;QAE1B,sDAAsD;QACtD,IAAI,IAAI,CAAC,YAAY,CAAC,IAAI,GAAG,CAAC,EAAE,CAAC;YAC7B,IAAI,CAAC,gBAAgB,CAAC,mBAAmB,CAAC,CAAC;QAC/C,CAAC;IACL,CAAC;CACJ"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { CodeEdge, CodeNode } from './indexer-types.js';
|
|
2
|
+
export declare class CodeParser {
|
|
3
|
+
private readonly CHUNK_SIZE;
|
|
4
|
+
/**
|
|
5
|
+
* Main entry point to parse a file and generate Nodes and Edges
|
|
6
|
+
*/
|
|
7
|
+
parseFile(filePath: string): {
|
|
8
|
+
nodes: CodeNode[];
|
|
9
|
+
edges: CodeEdge[];
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* Generates a stable hash for a node's content
|
|
13
|
+
*/
|
|
14
|
+
generateHash(content: string): string;
|
|
15
|
+
/**
|
|
16
|
+
* Generates a deterministic ID based on the file path and element name
|
|
17
|
+
*/
|
|
18
|
+
private generateNodeId;
|
|
19
|
+
/**
|
|
20
|
+
* Regex-based parser for TypeScript/JavaScript (V1 Strategy)
|
|
21
|
+
* Future: Can be upgraded to use full AST (e.g. ts-morph / typescript compiler API)
|
|
22
|
+
*/
|
|
23
|
+
private parseTypeScript;
|
|
24
|
+
private parseMarkdown;
|
|
25
|
+
private parseNaive;
|
|
26
|
+
private createNode;
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=file-parser.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"file-parser.d.ts","sourceRoot":"","sources":["../../../src/core/indexer/file-parser.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAgB,MAAM,oBAAoB,CAAC;AAE3E,qBAAa,UAAU;IACnB,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAQ;IAEnC;;OAEG;IACI,SAAS,CAAC,QAAQ,EAAE,MAAM,GAAG;QAAE,KAAK,EAAE,QAAQ,EAAE,CAAC;QAAC,KAAK,EAAE,QAAQ,EAAE,CAAA;KAAE;IAyB5E;;OAEG;IACI,YAAY,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM;IAI5C;;OAEG;IACH,OAAO,CAAC,cAAc;IAItB;;;OAGG;IACH,OAAO,CAAC,eAAe;IAoEvB,OAAO,CAAC,aAAa;IAiCrB,OAAO,CAAC,UAAU;IAyBlB,OAAO,CAAC,UAAU;CAarB"}
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
import { createHash, randomUUID } from 'crypto';
|
|
2
|
+
import { readFileSync, statSync } from 'fs';
|
|
3
|
+
import { extname } from 'path';
|
|
4
|
+
export class CodeParser {
|
|
5
|
+
CHUNK_SIZE = 1500; // Character limit for basic chunking if AST not used
|
|
6
|
+
/**
|
|
7
|
+
* Main entry point to parse a file and generate Nodes and Edges
|
|
8
|
+
*/
|
|
9
|
+
parseFile(filePath) {
|
|
10
|
+
try {
|
|
11
|
+
const stats = statSync(filePath);
|
|
12
|
+
if (stats.size > 1024 * 1024) {
|
|
13
|
+
// Skip files > 1MB automatically to prevent OOM
|
|
14
|
+
return { nodes: [], edges: [] };
|
|
15
|
+
}
|
|
16
|
+
const content = readFileSync(filePath, 'utf-8');
|
|
17
|
+
const ext = extname(filePath).toLowerCase();
|
|
18
|
+
// Dispatch to specific language parsers or fallback to naive
|
|
19
|
+
if (['.ts', '.js', '.tsx', '.jsx'].includes(ext)) {
|
|
20
|
+
return this.parseTypeScript(filePath, content);
|
|
21
|
+
}
|
|
22
|
+
else if (ext === '.md') {
|
|
23
|
+
return this.parseMarkdown(filePath, content);
|
|
24
|
+
}
|
|
25
|
+
else {
|
|
26
|
+
return this.parseNaive(filePath, content);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
catch (e) {
|
|
30
|
+
console.error(`[Indexer] Failed to parse file ${filePath}:`, e);
|
|
31
|
+
return { nodes: [], edges: [] };
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Generates a stable hash for a node's content
|
|
36
|
+
*/
|
|
37
|
+
generateHash(content) {
|
|
38
|
+
return createHash('sha256').update(content).digest('hex');
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Generates a deterministic ID based on the file path and element name
|
|
42
|
+
*/
|
|
43
|
+
generateNodeId(filePath, elementPath) {
|
|
44
|
+
return createHash('md5').update(`${filePath}::${elementPath}`).digest('hex');
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Regex-based parser for TypeScript/JavaScript (V1 Strategy)
|
|
48
|
+
* Future: Can be upgraded to use full AST (e.g. ts-morph / typescript compiler API)
|
|
49
|
+
*/
|
|
50
|
+
parseTypeScript(filePath, content) {
|
|
51
|
+
const nodes = [];
|
|
52
|
+
const edges = [];
|
|
53
|
+
const lines = content.split('\n');
|
|
54
|
+
let currentChunk = '';
|
|
55
|
+
let startLine = 1;
|
|
56
|
+
const now = Date.now();
|
|
57
|
+
// 1. Create the base File Node
|
|
58
|
+
const fileNodeId = this.generateNodeId(filePath, 'file');
|
|
59
|
+
nodes.push({
|
|
60
|
+
id: fileNodeId,
|
|
61
|
+
type: 'file',
|
|
62
|
+
name: filePath.split(/[/\\]/).pop() || 'unknown',
|
|
63
|
+
filePath,
|
|
64
|
+
startLine: 1,
|
|
65
|
+
endLine: lines.length,
|
|
66
|
+
content,
|
|
67
|
+
hash: this.generateHash(content),
|
|
68
|
+
updatedAt: now,
|
|
69
|
+
});
|
|
70
|
+
// 2. Extract Imports to create Edges
|
|
71
|
+
// Simplistic regex for: import { X } from './Y' or import X from 'Y'
|
|
72
|
+
const importRegex = /import\s+.*?\s+from\s+['"]([^'"]+)['"]/g;
|
|
73
|
+
let match;
|
|
74
|
+
while ((match = importRegex.exec(content)) !== null) {
|
|
75
|
+
const targetModule = match[1];
|
|
76
|
+
edges.push({
|
|
77
|
+
id: randomUUID(),
|
|
78
|
+
sourceId: fileNodeId,
|
|
79
|
+
targetId: `__module__${targetModule}`, // We resolve this later in the manager to actual Node IDs if internal
|
|
80
|
+
type: 'imports',
|
|
81
|
+
weight: 1.0,
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
// 3. Naive Chunking for internal classes/functions (Regex based for v1)
|
|
85
|
+
// Looking for 'class X' or 'function Y' or 'const Z = ('
|
|
86
|
+
const classRegex = /export\s+class\s+([^ \n{]+)/;
|
|
87
|
+
const functionRegex = /export\s+(?:async\s+)?function\s+([^ \n(]+)/;
|
|
88
|
+
for (let i = 0; i < lines.length; i++) {
|
|
89
|
+
const line = lines[i];
|
|
90
|
+
let matchName = classRegex.exec(line)?.[1] || functionRegex.exec(line)?.[1];
|
|
91
|
+
if (matchName && currentChunk.length > 0) {
|
|
92
|
+
// Save previous chunk if exists before starting new semantic block
|
|
93
|
+
// (Simplified block separation)
|
|
94
|
+
}
|
|
95
|
+
currentChunk += line + '\n';
|
|
96
|
+
if (currentChunk.length >= this.CHUNK_SIZE) {
|
|
97
|
+
nodes.push(this.createNode(filePath, 'chunk', matchName || `chunk-${i}`, currentChunk, startLine, i + 1, now));
|
|
98
|
+
currentChunk = '';
|
|
99
|
+
startLine = i + 2;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
// Flush remaining
|
|
103
|
+
if (currentChunk.trim().length > 0) {
|
|
104
|
+
nodes.push(this.createNode(filePath, 'chunk', `chunk-end`, currentChunk, startLine, lines.length, now));
|
|
105
|
+
}
|
|
106
|
+
return { nodes, edges };
|
|
107
|
+
}
|
|
108
|
+
parseMarkdown(filePath, content) {
|
|
109
|
+
const nodes = [];
|
|
110
|
+
const lines = content.split('\n');
|
|
111
|
+
const now = Date.now();
|
|
112
|
+
let currentChunk = '';
|
|
113
|
+
let startLine = 1;
|
|
114
|
+
for (let i = 0; i < lines.length; i++) {
|
|
115
|
+
const line = lines[i];
|
|
116
|
+
if (line.startsWith('# ') || line.startsWith('## ')) {
|
|
117
|
+
if (currentChunk.trim().length > 0) {
|
|
118
|
+
nodes.push(this.createNode(filePath, 'unknown', `md-section-${startLine}`, currentChunk, startLine, i, now));
|
|
119
|
+
}
|
|
120
|
+
currentChunk = line + '\n';
|
|
121
|
+
startLine = i + 1;
|
|
122
|
+
}
|
|
123
|
+
else {
|
|
124
|
+
currentChunk += line + '\n';
|
|
125
|
+
}
|
|
126
|
+
if (currentChunk.length > this.CHUNK_SIZE * 2) {
|
|
127
|
+
nodes.push(this.createNode(filePath, 'unknown', `md-chunk-${startLine}`, currentChunk, startLine, i + 1, now));
|
|
128
|
+
currentChunk = '';
|
|
129
|
+
startLine = i + 2;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
if (currentChunk.trim().length > 0) {
|
|
133
|
+
nodes.push(this.createNode(filePath, 'unknown', `md-end`, currentChunk, startLine, lines.length, now));
|
|
134
|
+
}
|
|
135
|
+
return { nodes, edges: [] };
|
|
136
|
+
}
|
|
137
|
+
parseNaive(filePath, content) {
|
|
138
|
+
const nodes = [];
|
|
139
|
+
const lines = content.split('\n');
|
|
140
|
+
const now = Date.now();
|
|
141
|
+
// Just chunk it linearly
|
|
142
|
+
let currentChunk = '';
|
|
143
|
+
let startLine = 1;
|
|
144
|
+
for (let i = 0; i < lines.length; i++) {
|
|
145
|
+
currentChunk += lines[i] + '\n';
|
|
146
|
+
if (currentChunk.length >= this.CHUNK_SIZE) {
|
|
147
|
+
nodes.push(this.createNode(filePath, 'unknown', `chunk-${startLine}`, currentChunk, startLine, i + 1, now));
|
|
148
|
+
currentChunk = '';
|
|
149
|
+
startLine = i + 2;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
if (currentChunk.trim().length > 0) {
|
|
153
|
+
nodes.push(this.createNode(filePath, 'unknown', `chunk-end`, currentChunk, startLine, lines.length, now));
|
|
154
|
+
}
|
|
155
|
+
return { nodes, edges: [] };
|
|
156
|
+
}
|
|
157
|
+
createNode(filePath, type, name, content, startLine, endLine, now) {
|
|
158
|
+
return {
|
|
159
|
+
id: this.generateNodeId(filePath, `${startLine}-${endLine}`),
|
|
160
|
+
type: type,
|
|
161
|
+
name,
|
|
162
|
+
filePath,
|
|
163
|
+
startLine,
|
|
164
|
+
endLine,
|
|
165
|
+
content,
|
|
166
|
+
hash: this.generateHash(content),
|
|
167
|
+
updatedAt: now
|
|
168
|
+
};
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
//# sourceMappingURL=file-parser.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"file-parser.js","sourceRoot":"","sources":["../../../src/core/indexer/file-parser.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AAChD,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,IAAI,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAG/B,MAAM,OAAO,UAAU;IACF,UAAU,GAAG,IAAI,CAAC,CAAC,qDAAqD;IAEzF;;OAEG;IACI,SAAS,CAAC,QAAgB;QAC7B,IAAI,CAAC;YACD,MAAM,KAAK,GAAG,QAAQ,CAAC,QAAQ,CAAC,CAAC;YACjC,IAAI,KAAK,CAAC,IAAI,GAAG,IAAI,GAAG,IAAI,EAAE,CAAC;gBAC3B,gDAAgD;gBAChD,OAAO,EAAE,KAAK,EAAE,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC;YACpC,CAAC;YAED,MAAM,OAAO,GAAG,YAAY,CAAC,QAAQ,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,CAAC,CAAC,CAAC;QAC9G,CAAC;QAED,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC;IAChC,CAAC;IAEO,UAAU,CAAC,QAAgB,EAAE,IAAY,EAAE,IAAY,EAAE,OAAe,EAAE,SAAiB,EAAE,OAAe,EAAE,GAAW;QAC7H,OAAO;YACH,EAAE,EAAE,IAAI,CAAC,cAAc,CAAC,QAAQ,EAAE,GAAG,SAAS,IAAI,OAAO,EAAE,CAAC;YAC5D,IAAI,EAAE,IAAoB;YAC1B,IAAI;YACJ,QAAQ;YACR,SAAS;YACT,OAAO;YACP,OAAO;YACP,IAAI,EAAE,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC;YAChC,SAAS,EAAE,GAAG;SACjB,CAAC;IACN,CAAC;CACJ"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Indexer System Type Definitions
|
|
3
|
+
*
|
|
4
|
+
* Core types for the background indexer, representing files,
|
|
5
|
+
* code symbols (classes, functions), and their relationships (Graph).
|
|
6
|
+
*/
|
|
7
|
+
export type CodeNodeType = 'file' | 'class' | 'function' | 'interface' | 'variable' | 'unknown';
|
|
8
|
+
export interface CodeNode {
|
|
9
|
+
id: string;
|
|
10
|
+
type: CodeNodeType;
|
|
11
|
+
name: string;
|
|
12
|
+
filePath: string;
|
|
13
|
+
startLine: number;
|
|
14
|
+
endLine: number;
|
|
15
|
+
content: string;
|
|
16
|
+
summary?: string;
|
|
17
|
+
hash: string;
|
|
18
|
+
updatedAt: number;
|
|
19
|
+
}
|
|
20
|
+
export type CodeEdgeType = 'imports' | 'exports' | 'implements' | 'calls' | 'extends' | 'instantiates' | 'unknown';
|
|
21
|
+
export interface CodeEdge {
|
|
22
|
+
id: string;
|
|
23
|
+
sourceId: string;
|
|
24
|
+
targetId: string;
|
|
25
|
+
type: CodeEdgeType;
|
|
26
|
+
weight: number;
|
|
27
|
+
}
|
|
28
|
+
export interface IndexerConfig {
|
|
29
|
+
enabled: boolean;
|
|
30
|
+
watchPaths: string[];
|
|
31
|
+
ignorePatterns: string[];
|
|
32
|
+
chunkSize: number;
|
|
33
|
+
debounceMs: number;
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=indexer-types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"indexer-types.d.ts","sourceRoot":"","sources":["../../../src/core/indexer/indexer-types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,MAAM,YAAY,GAAG,MAAM,GAAG,OAAO,GAAG,UAAU,GAAG,WAAW,GAAG,UAAU,GAAG,SAAS,CAAC;AAEhG,MAAM,WAAW,QAAQ;IACvB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,YAAY,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,MAAM,YAAY,GAAG,SAAS,GAAG,SAAS,GAAG,YAAY,GAAG,OAAO,GAAG,SAAS,GAAG,cAAc,GAAG,SAAS,CAAC;AAEnH,MAAM,WAAW,QAAQ;IACvB,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,YAAY,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,aAAa;IAC5B,OAAO,EAAE,OAAO,CAAC;IACjB,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,cAAc,EAAE,MAAM,EAAE,CAAC;IACzB,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;CACpB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"indexer-types.js","sourceRoot":"","sources":["../../../src/core/indexer/indexer-types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rulebook-server.d.ts","sourceRoot":"","sources":["../../src/mcp/rulebook-server.ts"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"rulebook-server.d.ts","sourceRoot":"","sources":["../../src/mcp/rulebook-server.ts"],"names":[],"mappings":";AAcA,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAalE;AA2CD,wBAAsB,sBAAsB,IAAI,OAAO,CAAC,IAAI,CAAC,CA+/C5D"}
|