@renseiai/agentfactory-code-intelligence 0.8.4
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/LICENSE +21 -0
- package/dist/src/__tests__/types.test.d.ts +2 -0
- package/dist/src/__tests__/types.test.d.ts.map +1 -0
- package/dist/src/__tests__/types.test.js +187 -0
- package/dist/src/index.d.ts +26 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +29 -0
- package/dist/src/indexing/__tests__/indexing.test.d.ts +2 -0
- package/dist/src/indexing/__tests__/indexing.test.d.ts.map +1 -0
- package/dist/src/indexing/__tests__/indexing.test.js +193 -0
- package/dist/src/indexing/change-detector.d.ts +16 -0
- package/dist/src/indexing/change-detector.d.ts.map +1 -0
- package/dist/src/indexing/change-detector.js +38 -0
- package/dist/src/indexing/git-hash-provider.d.ts +11 -0
- package/dist/src/indexing/git-hash-provider.d.ts.map +1 -0
- package/dist/src/indexing/git-hash-provider.js +25 -0
- package/dist/src/indexing/incremental-indexer.d.ts +38 -0
- package/dist/src/indexing/incremental-indexer.d.ts.map +1 -0
- package/dist/src/indexing/incremental-indexer.js +122 -0
- package/dist/src/indexing/merkle-tree.d.ts +33 -0
- package/dist/src/indexing/merkle-tree.d.ts.map +1 -0
- package/dist/src/indexing/merkle-tree.js +107 -0
- package/dist/src/memory/__tests__/dedup.test.d.ts +2 -0
- package/dist/src/memory/__tests__/dedup.test.d.ts.map +1 -0
- package/dist/src/memory/__tests__/dedup.test.js +173 -0
- package/dist/src/memory/dedup-pipeline.d.ts +24 -0
- package/dist/src/memory/dedup-pipeline.d.ts.map +1 -0
- package/dist/src/memory/dedup-pipeline.js +73 -0
- package/dist/src/memory/memory-store.d.ts +22 -0
- package/dist/src/memory/memory-store.d.ts.map +1 -0
- package/dist/src/memory/memory-store.js +32 -0
- package/dist/src/memory/simhash.d.ts +16 -0
- package/dist/src/memory/simhash.d.ts.map +1 -0
- package/dist/src/memory/simhash.js +67 -0
- package/dist/src/memory/xxhash.d.ts +3 -0
- package/dist/src/memory/xxhash.d.ts.map +1 -0
- package/dist/src/memory/xxhash.js +13 -0
- package/dist/src/parser/__tests__/multi-language.test.d.ts +2 -0
- package/dist/src/parser/__tests__/multi-language.test.d.ts.map +1 -0
- package/dist/src/parser/__tests__/multi-language.test.js +350 -0
- package/dist/src/parser/__tests__/symbol-extractor.test.d.ts +2 -0
- package/dist/src/parser/__tests__/symbol-extractor.test.d.ts.map +1 -0
- package/dist/src/parser/__tests__/symbol-extractor.test.js +188 -0
- package/dist/src/parser/go-extractor.d.ts +8 -0
- package/dist/src/parser/go-extractor.d.ts.map +1 -0
- package/dist/src/parser/go-extractor.js +127 -0
- package/dist/src/parser/python-extractor.d.ts +8 -0
- package/dist/src/parser/python-extractor.d.ts.map +1 -0
- package/dist/src/parser/python-extractor.js +92 -0
- package/dist/src/parser/rust-extractor.d.ts +8 -0
- package/dist/src/parser/rust-extractor.d.ts.map +1 -0
- package/dist/src/parser/rust-extractor.js +168 -0
- package/dist/src/parser/symbol-extractor.d.ts +14 -0
- package/dist/src/parser/symbol-extractor.d.ts.map +1 -0
- package/dist/src/parser/symbol-extractor.js +47 -0
- package/dist/src/parser/typescript-extractor.d.ts +13 -0
- package/dist/src/parser/typescript-extractor.d.ts.map +1 -0
- package/dist/src/parser/typescript-extractor.js +229 -0
- package/dist/src/plugin/__tests__/plugin.test.d.ts +2 -0
- package/dist/src/plugin/__tests__/plugin.test.d.ts.map +1 -0
- package/dist/src/plugin/__tests__/plugin.test.js +48 -0
- package/dist/src/plugin/code-intelligence-plugin.d.ts +15 -0
- package/dist/src/plugin/code-intelligence-plugin.d.ts.map +1 -0
- package/dist/src/plugin/code-intelligence-plugin.js +102 -0
- package/dist/src/repo-map/__tests__/repo-map.test.d.ts +2 -0
- package/dist/src/repo-map/__tests__/repo-map.test.d.ts.map +1 -0
- package/dist/src/repo-map/__tests__/repo-map.test.js +186 -0
- package/dist/src/repo-map/dependency-graph.d.ts +30 -0
- package/dist/src/repo-map/dependency-graph.d.ts.map +1 -0
- package/dist/src/repo-map/dependency-graph.js +105 -0
- package/dist/src/repo-map/pagerank.d.ts +20 -0
- package/dist/src/repo-map/pagerank.d.ts.map +1 -0
- package/dist/src/repo-map/pagerank.js +68 -0
- package/dist/src/repo-map/repo-map-generator.d.ts +20 -0
- package/dist/src/repo-map/repo-map-generator.d.ts.map +1 -0
- package/dist/src/repo-map/repo-map-generator.js +66 -0
- package/dist/src/search/__tests__/search.test.d.ts +2 -0
- package/dist/src/search/__tests__/search.test.d.ts.map +1 -0
- package/dist/src/search/__tests__/search.test.js +191 -0
- package/dist/src/search/bm25.d.ts +24 -0
- package/dist/src/search/bm25.d.ts.map +1 -0
- package/dist/src/search/bm25.js +44 -0
- package/dist/src/search/inverted-index.d.ts +31 -0
- package/dist/src/search/inverted-index.d.ts.map +1 -0
- package/dist/src/search/inverted-index.js +72 -0
- package/dist/src/search/search-engine.d.ts +22 -0
- package/dist/src/search/search-engine.d.ts.map +1 -0
- package/dist/src/search/search-engine.js +76 -0
- package/dist/src/search/tokenizer.d.ts +11 -0
- package/dist/src/search/tokenizer.d.ts.map +1 -0
- package/dist/src/search/tokenizer.js +48 -0
- package/dist/src/types.d.ts +242 -0
- package/dist/src/types.d.ts.map +1 -0
- package/dist/src/types.js +96 -0
- package/package.json +74 -0
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { CodeSymbol, SearchQuery, SearchResult } from '../types.js';
|
|
2
|
+
import { type BM25Options } from './bm25.js';
|
|
3
|
+
/**
|
|
4
|
+
* High-level search engine combining BM25 ranking with filtering and exact match boosting.
|
|
5
|
+
*/
|
|
6
|
+
export declare class SearchEngine {
|
|
7
|
+
private index;
|
|
8
|
+
private bm25;
|
|
9
|
+
private symbols;
|
|
10
|
+
constructor(options?: BM25Options);
|
|
11
|
+
/** Build the search index from symbols. */
|
|
12
|
+
buildIndex(symbols: CodeSymbol[]): void;
|
|
13
|
+
/** Search for symbols matching a query. */
|
|
14
|
+
search(query: SearchQuery): SearchResult[];
|
|
15
|
+
/** Get index statistics. */
|
|
16
|
+
getStats(): {
|
|
17
|
+
totalSymbols: number;
|
|
18
|
+
totalTerms: number;
|
|
19
|
+
};
|
|
20
|
+
private matchPattern;
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=search-engine.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"search-engine.d.ts","sourceRoot":"","sources":["../../../src/search/search-engine.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAExE,OAAO,EAAQ,KAAK,WAAW,EAAE,MAAM,WAAW,CAAA;AAElD;;GAEG;AACH,qBAAa,YAAY;IACvB,OAAO,CAAC,KAAK,CAAsB;IACnC,OAAO,CAAC,IAAI,CAAM;IAClB,OAAO,CAAC,OAAO,CAAmB;gBAEtB,OAAO,CAAC,EAAE,WAAW;IAIjC,2CAA2C;IAC3C,UAAU,CAAC,OAAO,EAAE,UAAU,EAAE,GAAG,IAAI;IAKvC,2CAA2C;IAC3C,MAAM,CAAC,KAAK,EAAE,WAAW,GAAG,YAAY,EAAE;IAyC1C,4BAA4B;IAC5B,QAAQ,IAAI;QAAE,YAAY,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,MAAM,CAAA;KAAE;IAOxD,OAAO,CAAC,YAAY;CAcrB"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { InvertedIndex } from './inverted-index.js';
|
|
2
|
+
import { BM25 } from './bm25.js';
|
|
3
|
+
/**
|
|
4
|
+
* High-level search engine combining BM25 ranking with filtering and exact match boosting.
|
|
5
|
+
*/
|
|
6
|
+
export class SearchEngine {
|
|
7
|
+
index = new InvertedIndex();
|
|
8
|
+
bm25;
|
|
9
|
+
symbols = [];
|
|
10
|
+
constructor(options) {
|
|
11
|
+
this.bm25 = new BM25(options);
|
|
12
|
+
}
|
|
13
|
+
/** Build the search index from symbols. */
|
|
14
|
+
buildIndex(symbols) {
|
|
15
|
+
this.symbols = symbols;
|
|
16
|
+
this.index.build(symbols);
|
|
17
|
+
}
|
|
18
|
+
/** Search for symbols matching a query. */
|
|
19
|
+
search(query) {
|
|
20
|
+
const scored = this.bm25.score(query.query, this.index);
|
|
21
|
+
let results = [];
|
|
22
|
+
const queryLower = query.query.toLowerCase();
|
|
23
|
+
for (const { docId, score } of scored) {
|
|
24
|
+
const symbol = this.index.getDocument(docId);
|
|
25
|
+
if (!symbol)
|
|
26
|
+
continue;
|
|
27
|
+
// Apply filters
|
|
28
|
+
if (query.symbolKinds && !query.symbolKinds.includes(symbol.kind))
|
|
29
|
+
continue;
|
|
30
|
+
if (query.language && symbol.language !== query.language)
|
|
31
|
+
continue;
|
|
32
|
+
if (query.filePattern && !this.matchPattern(symbol.filePath, query.filePattern))
|
|
33
|
+
continue;
|
|
34
|
+
// Determine match type and boost exact matches
|
|
35
|
+
let matchType = 'bm25';
|
|
36
|
+
let finalScore = score;
|
|
37
|
+
if (symbol.name.toLowerCase() === queryLower) {
|
|
38
|
+
matchType = 'exact';
|
|
39
|
+
finalScore *= 3.0; // Boost exact name matches
|
|
40
|
+
}
|
|
41
|
+
else if (symbol.name.toLowerCase().includes(queryLower)) {
|
|
42
|
+
matchType = 'fuzzy';
|
|
43
|
+
finalScore *= 1.5; // Boost partial name matches
|
|
44
|
+
}
|
|
45
|
+
results.push({ symbol, score: finalScore, matchType });
|
|
46
|
+
}
|
|
47
|
+
// Sort by final score
|
|
48
|
+
results.sort((a, b) => b.score - a.score);
|
|
49
|
+
// Limit results
|
|
50
|
+
if (query.maxResults) {
|
|
51
|
+
results = results.slice(0, query.maxResults);
|
|
52
|
+
}
|
|
53
|
+
return results;
|
|
54
|
+
}
|
|
55
|
+
/** Get index statistics. */
|
|
56
|
+
getStats() {
|
|
57
|
+
return {
|
|
58
|
+
totalSymbols: this.index.getDocCount(),
|
|
59
|
+
totalTerms: this.index.getTerms().length,
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
matchPattern(filePath, pattern) {
|
|
63
|
+
// Simple glob matching: *.ts matches .ts files, src/** matches src/ prefix
|
|
64
|
+
if (pattern.startsWith('*')) {
|
|
65
|
+
return filePath.endsWith(pattern.slice(1));
|
|
66
|
+
}
|
|
67
|
+
if (pattern.endsWith('/**')) {
|
|
68
|
+
return filePath.startsWith(pattern.slice(0, -3));
|
|
69
|
+
}
|
|
70
|
+
if (pattern.endsWith('/*')) {
|
|
71
|
+
const dir = pattern.slice(0, -2);
|
|
72
|
+
return filePath.startsWith(dir) && !filePath.slice(dir.length + 1).includes('/');
|
|
73
|
+
}
|
|
74
|
+
return filePath.includes(pattern);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Code-aware tokenizer that splits on camelCase, snake_case, kebab-case.
|
|
3
|
+
* Preserves compound tokens while also indexing sub-tokens.
|
|
4
|
+
*/
|
|
5
|
+
export declare class CodeTokenizer {
|
|
6
|
+
/** Tokenize a code identifier or query string. */
|
|
7
|
+
tokenize(text: string): string[];
|
|
8
|
+
/** Split camelCase/PascalCase into parts. */
|
|
9
|
+
private splitCamelCase;
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=tokenizer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tokenizer.d.ts","sourceRoot":"","sources":["../../../src/search/tokenizer.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,qBAAa,aAAa;IACxB,kDAAkD;IAClD,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE;IAsChC,6CAA6C;IAC7C,OAAO,CAAC,cAAc;CAQvB"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Code-aware tokenizer that splits on camelCase, snake_case, kebab-case.
|
|
3
|
+
* Preserves compound tokens while also indexing sub-tokens.
|
|
4
|
+
*/
|
|
5
|
+
export class CodeTokenizer {
|
|
6
|
+
/** Tokenize a code identifier or query string. */
|
|
7
|
+
tokenize(text) {
|
|
8
|
+
const tokens = [];
|
|
9
|
+
// Split on whitespace and common delimiters, but preserve _ and - for compound tokens
|
|
10
|
+
const words = text.split(/[\s.,:;()\[\]{}<>=!&|+*/\\@#$%^~`'"]+/)
|
|
11
|
+
.filter(w => w.length > 0);
|
|
12
|
+
for (const word of words) {
|
|
13
|
+
// Add the full word as a token (lowered)
|
|
14
|
+
const lower = word.toLowerCase();
|
|
15
|
+
tokens.push(lower);
|
|
16
|
+
// Split camelCase / PascalCase
|
|
17
|
+
const camelParts = this.splitCamelCase(word);
|
|
18
|
+
if (camelParts.length > 1) {
|
|
19
|
+
for (const part of camelParts) {
|
|
20
|
+
const p = part.toLowerCase();
|
|
21
|
+
if (p.length >= 2 && p !== lower) {
|
|
22
|
+
tokens.push(p);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
// Split snake_case / kebab-case
|
|
27
|
+
const snakeParts = word.split(/[_-]/).filter(p => p.length > 0);
|
|
28
|
+
if (snakeParts.length > 1) {
|
|
29
|
+
for (const part of snakeParts) {
|
|
30
|
+
const p = part.toLowerCase();
|
|
31
|
+
if (p.length >= 2 && !tokens.includes(p)) {
|
|
32
|
+
tokens.push(p);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
return tokens;
|
|
38
|
+
}
|
|
39
|
+
/** Split camelCase/PascalCase into parts. */
|
|
40
|
+
splitCamelCase(word) {
|
|
41
|
+
// Insert boundary before uppercase letters
|
|
42
|
+
return word
|
|
43
|
+
.replace(/([a-z])([A-Z])/g, '$1\0$2')
|
|
44
|
+
.replace(/([A-Z]+)([A-Z][a-z])/g, '$1\0$2')
|
|
45
|
+
.split('\0')
|
|
46
|
+
.filter(p => p.length > 0);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
@@ -0,0 +1,242 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const SymbolKindSchema: z.ZodEnum<{
|
|
3
|
+
function: "function";
|
|
4
|
+
class: "class";
|
|
5
|
+
interface: "interface";
|
|
6
|
+
type: "type";
|
|
7
|
+
variable: "variable";
|
|
8
|
+
method: "method";
|
|
9
|
+
property: "property";
|
|
10
|
+
import: "import";
|
|
11
|
+
export: "export";
|
|
12
|
+
enum: "enum";
|
|
13
|
+
struct: "struct";
|
|
14
|
+
trait: "trait";
|
|
15
|
+
impl: "impl";
|
|
16
|
+
macro: "macro";
|
|
17
|
+
decorator: "decorator";
|
|
18
|
+
module: "module";
|
|
19
|
+
}>;
|
|
20
|
+
export type SymbolKind = z.infer<typeof SymbolKindSchema>;
|
|
21
|
+
export declare const CodeSymbolSchema: z.ZodObject<{
|
|
22
|
+
name: z.ZodString;
|
|
23
|
+
kind: z.ZodEnum<{
|
|
24
|
+
function: "function";
|
|
25
|
+
class: "class";
|
|
26
|
+
interface: "interface";
|
|
27
|
+
type: "type";
|
|
28
|
+
variable: "variable";
|
|
29
|
+
method: "method";
|
|
30
|
+
property: "property";
|
|
31
|
+
import: "import";
|
|
32
|
+
export: "export";
|
|
33
|
+
enum: "enum";
|
|
34
|
+
struct: "struct";
|
|
35
|
+
trait: "trait";
|
|
36
|
+
impl: "impl";
|
|
37
|
+
macro: "macro";
|
|
38
|
+
decorator: "decorator";
|
|
39
|
+
module: "module";
|
|
40
|
+
}>;
|
|
41
|
+
filePath: z.ZodString;
|
|
42
|
+
line: z.ZodNumber;
|
|
43
|
+
endLine: z.ZodOptional<z.ZodNumber>;
|
|
44
|
+
signature: z.ZodOptional<z.ZodString>;
|
|
45
|
+
documentation: z.ZodOptional<z.ZodString>;
|
|
46
|
+
exported: z.ZodDefault<z.ZodBoolean>;
|
|
47
|
+
parentName: z.ZodOptional<z.ZodString>;
|
|
48
|
+
language: z.ZodOptional<z.ZodString>;
|
|
49
|
+
}, z.core.$strip>;
|
|
50
|
+
export type CodeSymbol = z.infer<typeof CodeSymbolSchema>;
|
|
51
|
+
export declare const FileASTSchema: z.ZodObject<{
|
|
52
|
+
filePath: z.ZodString;
|
|
53
|
+
language: z.ZodString;
|
|
54
|
+
symbols: z.ZodArray<z.ZodObject<{
|
|
55
|
+
name: z.ZodString;
|
|
56
|
+
kind: z.ZodEnum<{
|
|
57
|
+
function: "function";
|
|
58
|
+
class: "class";
|
|
59
|
+
interface: "interface";
|
|
60
|
+
type: "type";
|
|
61
|
+
variable: "variable";
|
|
62
|
+
method: "method";
|
|
63
|
+
property: "property";
|
|
64
|
+
import: "import";
|
|
65
|
+
export: "export";
|
|
66
|
+
enum: "enum";
|
|
67
|
+
struct: "struct";
|
|
68
|
+
trait: "trait";
|
|
69
|
+
impl: "impl";
|
|
70
|
+
macro: "macro";
|
|
71
|
+
decorator: "decorator";
|
|
72
|
+
module: "module";
|
|
73
|
+
}>;
|
|
74
|
+
filePath: z.ZodString;
|
|
75
|
+
line: z.ZodNumber;
|
|
76
|
+
endLine: z.ZodOptional<z.ZodNumber>;
|
|
77
|
+
signature: z.ZodOptional<z.ZodString>;
|
|
78
|
+
documentation: z.ZodOptional<z.ZodString>;
|
|
79
|
+
exported: z.ZodDefault<z.ZodBoolean>;
|
|
80
|
+
parentName: z.ZodOptional<z.ZodString>;
|
|
81
|
+
language: z.ZodOptional<z.ZodString>;
|
|
82
|
+
}, z.core.$strip>>;
|
|
83
|
+
imports: z.ZodArray<z.ZodString>;
|
|
84
|
+
exports: z.ZodArray<z.ZodString>;
|
|
85
|
+
hash: z.ZodOptional<z.ZodString>;
|
|
86
|
+
}, z.core.$strip>;
|
|
87
|
+
export type FileAST = z.infer<typeof FileASTSchema>;
|
|
88
|
+
export declare const FileIndexSchema: z.ZodObject<{
|
|
89
|
+
filePath: z.ZodString;
|
|
90
|
+
gitHash: z.ZodString;
|
|
91
|
+
symbols: z.ZodArray<z.ZodObject<{
|
|
92
|
+
name: z.ZodString;
|
|
93
|
+
kind: z.ZodEnum<{
|
|
94
|
+
function: "function";
|
|
95
|
+
class: "class";
|
|
96
|
+
interface: "interface";
|
|
97
|
+
type: "type";
|
|
98
|
+
variable: "variable";
|
|
99
|
+
method: "method";
|
|
100
|
+
property: "property";
|
|
101
|
+
import: "import";
|
|
102
|
+
export: "export";
|
|
103
|
+
enum: "enum";
|
|
104
|
+
struct: "struct";
|
|
105
|
+
trait: "trait";
|
|
106
|
+
impl: "impl";
|
|
107
|
+
macro: "macro";
|
|
108
|
+
decorator: "decorator";
|
|
109
|
+
module: "module";
|
|
110
|
+
}>;
|
|
111
|
+
filePath: z.ZodString;
|
|
112
|
+
line: z.ZodNumber;
|
|
113
|
+
endLine: z.ZodOptional<z.ZodNumber>;
|
|
114
|
+
signature: z.ZodOptional<z.ZodString>;
|
|
115
|
+
documentation: z.ZodOptional<z.ZodString>;
|
|
116
|
+
exported: z.ZodDefault<z.ZodBoolean>;
|
|
117
|
+
parentName: z.ZodOptional<z.ZodString>;
|
|
118
|
+
language: z.ZodOptional<z.ZodString>;
|
|
119
|
+
}, z.core.$strip>>;
|
|
120
|
+
lastIndexed: z.ZodNumber;
|
|
121
|
+
}, z.core.$strip>;
|
|
122
|
+
export type FileIndex = z.infer<typeof FileIndexSchema>;
|
|
123
|
+
export declare const SearchQuerySchema: z.ZodObject<{
|
|
124
|
+
query: z.ZodString;
|
|
125
|
+
maxResults: z.ZodDefault<z.ZodNumber>;
|
|
126
|
+
filePattern: z.ZodOptional<z.ZodString>;
|
|
127
|
+
symbolKinds: z.ZodOptional<z.ZodArray<z.ZodEnum<{
|
|
128
|
+
function: "function";
|
|
129
|
+
class: "class";
|
|
130
|
+
interface: "interface";
|
|
131
|
+
type: "type";
|
|
132
|
+
variable: "variable";
|
|
133
|
+
method: "method";
|
|
134
|
+
property: "property";
|
|
135
|
+
import: "import";
|
|
136
|
+
export: "export";
|
|
137
|
+
enum: "enum";
|
|
138
|
+
struct: "struct";
|
|
139
|
+
trait: "trait";
|
|
140
|
+
impl: "impl";
|
|
141
|
+
macro: "macro";
|
|
142
|
+
decorator: "decorator";
|
|
143
|
+
module: "module";
|
|
144
|
+
}>>>;
|
|
145
|
+
language: z.ZodOptional<z.ZodString>;
|
|
146
|
+
}, z.core.$strip>;
|
|
147
|
+
export type SearchQuery = z.infer<typeof SearchQuerySchema>;
|
|
148
|
+
export declare const SearchResultSchema: z.ZodObject<{
|
|
149
|
+
symbol: z.ZodObject<{
|
|
150
|
+
name: z.ZodString;
|
|
151
|
+
kind: z.ZodEnum<{
|
|
152
|
+
function: "function";
|
|
153
|
+
class: "class";
|
|
154
|
+
interface: "interface";
|
|
155
|
+
type: "type";
|
|
156
|
+
variable: "variable";
|
|
157
|
+
method: "method";
|
|
158
|
+
property: "property";
|
|
159
|
+
import: "import";
|
|
160
|
+
export: "export";
|
|
161
|
+
enum: "enum";
|
|
162
|
+
struct: "struct";
|
|
163
|
+
trait: "trait";
|
|
164
|
+
impl: "impl";
|
|
165
|
+
macro: "macro";
|
|
166
|
+
decorator: "decorator";
|
|
167
|
+
module: "module";
|
|
168
|
+
}>;
|
|
169
|
+
filePath: z.ZodString;
|
|
170
|
+
line: z.ZodNumber;
|
|
171
|
+
endLine: z.ZodOptional<z.ZodNumber>;
|
|
172
|
+
signature: z.ZodOptional<z.ZodString>;
|
|
173
|
+
documentation: z.ZodOptional<z.ZodString>;
|
|
174
|
+
exported: z.ZodDefault<z.ZodBoolean>;
|
|
175
|
+
parentName: z.ZodOptional<z.ZodString>;
|
|
176
|
+
language: z.ZodOptional<z.ZodString>;
|
|
177
|
+
}, z.core.$strip>;
|
|
178
|
+
score: z.ZodNumber;
|
|
179
|
+
matchType: z.ZodEnum<{
|
|
180
|
+
exact: "exact";
|
|
181
|
+
fuzzy: "fuzzy";
|
|
182
|
+
bm25: "bm25";
|
|
183
|
+
}>;
|
|
184
|
+
}, z.core.$strip>;
|
|
185
|
+
export type SearchResult = z.infer<typeof SearchResultSchema>;
|
|
186
|
+
export declare const MemoryEntrySchema: z.ZodObject<{
|
|
187
|
+
id: z.ZodString;
|
|
188
|
+
content: z.ZodString;
|
|
189
|
+
xxhash: z.ZodString;
|
|
190
|
+
simhash: z.ZodBigInt;
|
|
191
|
+
createdAt: z.ZodNumber;
|
|
192
|
+
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
193
|
+
}, z.core.$strip>;
|
|
194
|
+
export type MemoryEntry = z.infer<typeof MemoryEntrySchema>;
|
|
195
|
+
export declare const DedupResultSchema: z.ZodObject<{
|
|
196
|
+
isDuplicate: z.ZodBoolean;
|
|
197
|
+
matchType: z.ZodEnum<{
|
|
198
|
+
exact: "exact";
|
|
199
|
+
near: "near";
|
|
200
|
+
none: "none";
|
|
201
|
+
}>;
|
|
202
|
+
existingId: z.ZodOptional<z.ZodString>;
|
|
203
|
+
hammingDistance: z.ZodOptional<z.ZodNumber>;
|
|
204
|
+
}, z.core.$strip>;
|
|
205
|
+
export type DedupResult = z.infer<typeof DedupResultSchema>;
|
|
206
|
+
export declare const IndexMetadataSchema: z.ZodObject<{
|
|
207
|
+
version: z.ZodNumber;
|
|
208
|
+
rootHash: z.ZodString;
|
|
209
|
+
totalFiles: z.ZodNumber;
|
|
210
|
+
totalSymbols: z.ZodNumber;
|
|
211
|
+
lastUpdated: z.ZodNumber;
|
|
212
|
+
languages: z.ZodArray<z.ZodString>;
|
|
213
|
+
}, z.core.$strip>;
|
|
214
|
+
export type IndexMetadata = z.infer<typeof IndexMetadataSchema>;
|
|
215
|
+
export declare const RepoMapEntrySchema: z.ZodObject<{
|
|
216
|
+
filePath: z.ZodString;
|
|
217
|
+
rank: z.ZodNumber;
|
|
218
|
+
symbols: z.ZodArray<z.ZodObject<{
|
|
219
|
+
name: z.ZodString;
|
|
220
|
+
kind: z.ZodEnum<{
|
|
221
|
+
function: "function";
|
|
222
|
+
class: "class";
|
|
223
|
+
interface: "interface";
|
|
224
|
+
type: "type";
|
|
225
|
+
variable: "variable";
|
|
226
|
+
method: "method";
|
|
227
|
+
property: "property";
|
|
228
|
+
import: "import";
|
|
229
|
+
export: "export";
|
|
230
|
+
enum: "enum";
|
|
231
|
+
struct: "struct";
|
|
232
|
+
trait: "trait";
|
|
233
|
+
impl: "impl";
|
|
234
|
+
macro: "macro";
|
|
235
|
+
decorator: "decorator";
|
|
236
|
+
module: "module";
|
|
237
|
+
}>;
|
|
238
|
+
line: z.ZodNumber;
|
|
239
|
+
}, z.core.$strip>>;
|
|
240
|
+
}, z.core.$strip>;
|
|
241
|
+
export type RepoMapEntry = z.infer<typeof RepoMapEntrySchema>;
|
|
242
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAIvB,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;;EAiB3B,CAAA;AACF,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAA;AAIzD,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAW3B,CAAA;AACF,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAA;AAIzD,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAOxB,CAAA;AACF,MAAM,MAAM,OAAO,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,aAAa,CAAC,CAAA;AAInD,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAK1B,CAAA;AACF,MAAM,MAAM,SAAS,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,eAAe,CAAC,CAAA;AAIvD,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;iBAM5B,CAAA;AACF,MAAM,MAAM,WAAW,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,iBAAiB,CAAC,CAAA;AAE3D,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAI7B,CAAA;AACF,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAA;AAI7D,eAAO,MAAM,iBAAiB;;;;;;;iBAO5B,CAAA;AACF,MAAM,MAAM,WAAW,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,iBAAiB,CAAC,CAAA;AAE3D,eAAO,MAAM,iBAAiB;;;;;;;;;iBAK5B,CAAA;AACF,MAAM,MAAM,WAAW,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,iBAAiB,CAAC,CAAA;AAI3D,eAAO,MAAM,mBAAmB;;;;;;;iBAO9B,CAAA;AACF,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAA;AAI/D,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;iBAQ7B,CAAA;AACF,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAA"}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
// ── Symbol Kinds ──────────────────────────────────────────────────────
|
|
3
|
+
export const SymbolKindSchema = z.enum([
|
|
4
|
+
'function',
|
|
5
|
+
'class',
|
|
6
|
+
'interface',
|
|
7
|
+
'type',
|
|
8
|
+
'variable',
|
|
9
|
+
'method',
|
|
10
|
+
'property',
|
|
11
|
+
'import',
|
|
12
|
+
'export',
|
|
13
|
+
'enum',
|
|
14
|
+
'struct',
|
|
15
|
+
'trait',
|
|
16
|
+
'impl',
|
|
17
|
+
'macro',
|
|
18
|
+
'decorator',
|
|
19
|
+
'module',
|
|
20
|
+
]);
|
|
21
|
+
// ── Code Symbol ───────────────────────────────────────────────────────
|
|
22
|
+
export const CodeSymbolSchema = z.object({
|
|
23
|
+
name: z.string().min(1),
|
|
24
|
+
kind: SymbolKindSchema,
|
|
25
|
+
filePath: z.string().min(1),
|
|
26
|
+
line: z.number().int().nonnegative(),
|
|
27
|
+
endLine: z.number().int().nonnegative().optional(),
|
|
28
|
+
signature: z.string().optional(),
|
|
29
|
+
documentation: z.string().optional(),
|
|
30
|
+
exported: z.boolean().default(false),
|
|
31
|
+
parentName: z.string().optional(),
|
|
32
|
+
language: z.string().optional(),
|
|
33
|
+
});
|
|
34
|
+
// ── File AST ──────────────────────────────────────────────────────────
|
|
35
|
+
export const FileASTSchema = z.object({
|
|
36
|
+
filePath: z.string().min(1),
|
|
37
|
+
language: z.string().min(1),
|
|
38
|
+
symbols: z.array(CodeSymbolSchema),
|
|
39
|
+
imports: z.array(z.string()),
|
|
40
|
+
exports: z.array(z.string()),
|
|
41
|
+
hash: z.string().optional(),
|
|
42
|
+
});
|
|
43
|
+
// ── File Index (Merkle tree node) ─────────────────────────────────────
|
|
44
|
+
export const FileIndexSchema = z.object({
|
|
45
|
+
filePath: z.string().min(1),
|
|
46
|
+
gitHash: z.string().min(1),
|
|
47
|
+
symbols: z.array(CodeSymbolSchema),
|
|
48
|
+
lastIndexed: z.number(),
|
|
49
|
+
});
|
|
50
|
+
// ── Search ────────────────────────────────────────────────────────────
|
|
51
|
+
export const SearchQuerySchema = z.object({
|
|
52
|
+
query: z.string().min(1),
|
|
53
|
+
maxResults: z.number().int().positive().default(20),
|
|
54
|
+
filePattern: z.string().optional(),
|
|
55
|
+
symbolKinds: z.array(SymbolKindSchema).optional(),
|
|
56
|
+
language: z.string().optional(),
|
|
57
|
+
});
|
|
58
|
+
export const SearchResultSchema = z.object({
|
|
59
|
+
symbol: CodeSymbolSchema,
|
|
60
|
+
score: z.number().nonnegative(),
|
|
61
|
+
matchType: z.enum(['exact', 'fuzzy', 'bm25']),
|
|
62
|
+
});
|
|
63
|
+
// ── Memory / Dedup ────────────────────────────────────────────────────
|
|
64
|
+
export const MemoryEntrySchema = z.object({
|
|
65
|
+
id: z.string().min(1),
|
|
66
|
+
content: z.string(),
|
|
67
|
+
xxhash: z.string(),
|
|
68
|
+
simhash: z.bigint(),
|
|
69
|
+
createdAt: z.number(),
|
|
70
|
+
metadata: z.record(z.string(), z.unknown()).optional(),
|
|
71
|
+
});
|
|
72
|
+
export const DedupResultSchema = z.object({
|
|
73
|
+
isDuplicate: z.boolean(),
|
|
74
|
+
matchType: z.enum(['exact', 'near', 'none']),
|
|
75
|
+
existingId: z.string().optional(),
|
|
76
|
+
hammingDistance: z.number().int().nonnegative().optional(),
|
|
77
|
+
});
|
|
78
|
+
// ── Index Metadata ────────────────────────────────────────────────────
|
|
79
|
+
export const IndexMetadataSchema = z.object({
|
|
80
|
+
version: z.number().int().positive(),
|
|
81
|
+
rootHash: z.string(),
|
|
82
|
+
totalFiles: z.number().int().nonnegative(),
|
|
83
|
+
totalSymbols: z.number().int().nonnegative(),
|
|
84
|
+
lastUpdated: z.number(),
|
|
85
|
+
languages: z.array(z.string()),
|
|
86
|
+
});
|
|
87
|
+
// ── Repo Map ──────────────────────────────────────────────────────────
|
|
88
|
+
export const RepoMapEntrySchema = z.object({
|
|
89
|
+
filePath: z.string().min(1),
|
|
90
|
+
rank: z.number().nonnegative(),
|
|
91
|
+
symbols: z.array(z.object({
|
|
92
|
+
name: z.string(),
|
|
93
|
+
kind: SymbolKindSchema,
|
|
94
|
+
line: z.number().int().nonnegative(),
|
|
95
|
+
})),
|
|
96
|
+
});
|
package/package.json
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@renseiai/agentfactory-code-intelligence",
|
|
3
|
+
"version": "0.8.4",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"description": "Code intelligence for AgentFactory — tree-sitter AST parsing, BM25 search, incremental indexing, memory deduplication",
|
|
6
|
+
"author": "Rensei AI (https://rensei.ai)",
|
|
7
|
+
"license": "MIT",
|
|
8
|
+
"engines": {
|
|
9
|
+
"node": ">=22.0.0"
|
|
10
|
+
},
|
|
11
|
+
"repository": {
|
|
12
|
+
"type": "git",
|
|
13
|
+
"url": "git+https://github.com/RenseiAI/agentfactory.git",
|
|
14
|
+
"directory": "packages/code-intelligence"
|
|
15
|
+
},
|
|
16
|
+
"homepage": "https://github.com/RenseiAI/agentfactory/tree/main/packages/code-intelligence",
|
|
17
|
+
"bugs": {
|
|
18
|
+
"url": "https://github.com/RenseiAI/agentfactory/issues"
|
|
19
|
+
},
|
|
20
|
+
"publishConfig": {
|
|
21
|
+
"access": "public"
|
|
22
|
+
},
|
|
23
|
+
"keywords": [
|
|
24
|
+
"code-intelligence",
|
|
25
|
+
"tree-sitter",
|
|
26
|
+
"bm25",
|
|
27
|
+
"search",
|
|
28
|
+
"agent",
|
|
29
|
+
"ast"
|
|
30
|
+
],
|
|
31
|
+
"main": "./dist/src/index.js",
|
|
32
|
+
"module": "./dist/src/index.js",
|
|
33
|
+
"types": "./dist/src/index.d.ts",
|
|
34
|
+
"exports": {
|
|
35
|
+
".": {
|
|
36
|
+
"types": "./dist/src/index.d.ts",
|
|
37
|
+
"import": "./dist/src/index.js",
|
|
38
|
+
"default": "./dist/src/index.js"
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
"files": [
|
|
42
|
+
"dist",
|
|
43
|
+
"README.md",
|
|
44
|
+
"LICENSE"
|
|
45
|
+
],
|
|
46
|
+
"dependencies": {
|
|
47
|
+
"xxhash-wasm": "^1.1.0"
|
|
48
|
+
},
|
|
49
|
+
"peerDependencies": {
|
|
50
|
+
"@anthropic-ai/claude-agent-sdk": "^0.2.7",
|
|
51
|
+
"zod": "^4.3.6"
|
|
52
|
+
},
|
|
53
|
+
"peerDependenciesMeta": {
|
|
54
|
+
"@anthropic-ai/claude-agent-sdk": {
|
|
55
|
+
"optional": true
|
|
56
|
+
},
|
|
57
|
+
"zod": {
|
|
58
|
+
"optional": true
|
|
59
|
+
}
|
|
60
|
+
},
|
|
61
|
+
"devDependencies": {
|
|
62
|
+
"@types/node": "^22.5.4",
|
|
63
|
+
"typescript": "^5.7.3",
|
|
64
|
+
"vitest": "^3.2.3"
|
|
65
|
+
},
|
|
66
|
+
"scripts": {
|
|
67
|
+
"build": "tsc",
|
|
68
|
+
"typecheck": "tsc --noEmit",
|
|
69
|
+
"test": "vitest run --passWithNoTests",
|
|
70
|
+
"test:watch": "vitest",
|
|
71
|
+
"clean": "rm -rf dist",
|
|
72
|
+
"prepublishOnly": "pnpm clean && pnpm build"
|
|
73
|
+
}
|
|
74
|
+
}
|