@renseiai/agentfactory-code-intelligence 0.8.4 → 0.8.8
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/README.md +131 -0
- package/package.json +3 -4
package/README.md
ADDED
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
# @renseiai/agentfactory-code-intelligence
|
|
2
|
+
|
|
3
|
+
Code intelligence for AgentFactory agents — regex-based symbol extraction, BM25 search, incremental Merkle-tree indexing, PageRank repo maps, and memory deduplication.
|
|
4
|
+
|
|
5
|
+
Part of the [AgentFactory](https://github.com/renseiai/agentfactory) monorepo.
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install @renseiai/agentfactory-code-intelligence
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Features
|
|
14
|
+
|
|
15
|
+
| Module | What it does |
|
|
16
|
+
|--------|-------------|
|
|
17
|
+
| **Parser** | Extracts symbols (functions, classes, types, interfaces) from TypeScript, Python, Go, and Rust using regex-based extractors |
|
|
18
|
+
| **Search** | BM25-ranked code search with code-aware tokenization (camelCase splitting, stop-word removal) and exact/fuzzy match boosting |
|
|
19
|
+
| **Indexing** | Merkle-tree change detection with git-compatible hashing — only re-indexes files that changed |
|
|
20
|
+
| **Repo Map** | Builds a dependency graph from imports, ranks files by PageRank, and outputs an LLM-friendly repository map |
|
|
21
|
+
| **Memory** | Two-tier deduplication: xxHash64 for exact matches, SimHash for near-duplicates with configurable Hamming distance |
|
|
22
|
+
|
|
23
|
+
## Usage
|
|
24
|
+
|
|
25
|
+
### Symbol extraction
|
|
26
|
+
|
|
27
|
+
```typescript
|
|
28
|
+
import { SymbolExtractor } from '@renseiai/agentfactory-code-intelligence'
|
|
29
|
+
|
|
30
|
+
const extractor = new SymbolExtractor()
|
|
31
|
+
const ast = extractor.extractFromSource(sourceCode, 'src/index.ts')
|
|
32
|
+
|
|
33
|
+
for (const symbol of ast.symbols) {
|
|
34
|
+
console.log(`${symbol.kind}: ${symbol.name} (line ${symbol.line})`)
|
|
35
|
+
}
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
### Code search
|
|
39
|
+
|
|
40
|
+
```typescript
|
|
41
|
+
import { SearchEngine, SymbolExtractor } from '@renseiai/agentfactory-code-intelligence'
|
|
42
|
+
|
|
43
|
+
const extractor = new SymbolExtractor()
|
|
44
|
+
const engine = new SearchEngine()
|
|
45
|
+
|
|
46
|
+
// Extract symbols from your files, then build the index
|
|
47
|
+
const symbols = files.flatMap(f => extractor.extractFromSource(f.content, f.path).symbols)
|
|
48
|
+
engine.buildIndex(symbols)
|
|
49
|
+
|
|
50
|
+
const results = engine.search({ query: 'handleRequest', maxResults: 10 })
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
### Incremental indexing
|
|
54
|
+
|
|
55
|
+
```typescript
|
|
56
|
+
import { IncrementalIndexer, SymbolExtractor } from '@renseiai/agentfactory-code-intelligence'
|
|
57
|
+
|
|
58
|
+
const indexer = new IncrementalIndexer(new SymbolExtractor())
|
|
59
|
+
|
|
60
|
+
// Load previous index (if any)
|
|
61
|
+
await indexer.load(process.cwd())
|
|
62
|
+
|
|
63
|
+
// Index files — only changed files are re-processed
|
|
64
|
+
const files = new Map([['src/app.ts', sourceCode]])
|
|
65
|
+
const { changes, indexed, metadata } = await indexer.index(files)
|
|
66
|
+
|
|
67
|
+
console.log(`${changes.added.length} added, ${changes.modified.length} modified`)
|
|
68
|
+
|
|
69
|
+
// Persist for next run
|
|
70
|
+
await indexer.save(process.cwd())
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
### Repository map
|
|
74
|
+
|
|
75
|
+
```typescript
|
|
76
|
+
import { SymbolExtractor, RepoMapGenerator } from '@renseiai/agentfactory-code-intelligence'
|
|
77
|
+
|
|
78
|
+
const extractor = new SymbolExtractor()
|
|
79
|
+
const generator = new RepoMapGenerator()
|
|
80
|
+
|
|
81
|
+
const asts = files.map(f => extractor.extractFromSource(f.content, f.path))
|
|
82
|
+
const entries = generator.generate(asts, { maxFiles: 30 })
|
|
83
|
+
|
|
84
|
+
console.log(generator.format(entries))
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
### Memory deduplication
|
|
88
|
+
|
|
89
|
+
```typescript
|
|
90
|
+
import { DedupPipeline, InMemoryStore } from '@renseiai/agentfactory-code-intelligence'
|
|
91
|
+
|
|
92
|
+
const pipeline = new DedupPipeline(new InMemoryStore())
|
|
93
|
+
|
|
94
|
+
// Store content
|
|
95
|
+
await pipeline.storeContent('entry-1', 'some code block...')
|
|
96
|
+
|
|
97
|
+
// Check for duplicates
|
|
98
|
+
const result = await pipeline.check('some code block...')
|
|
99
|
+
// → { isDuplicate: true, matchType: 'exact', existingId: 'entry-1' }
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
## Agent tool plugin
|
|
103
|
+
|
|
104
|
+
When used with AgentFactory's Claude provider, the package registers four in-process MCP tools:
|
|
105
|
+
|
|
106
|
+
| Tool | Description |
|
|
107
|
+
|------|-------------|
|
|
108
|
+
| `af_code_search_symbols` | Search symbols by name with kind/language/file filtering |
|
|
109
|
+
| `af_code_get_repo_map` | PageRank-ranked repo map of the most important files |
|
|
110
|
+
| `af_code_search_code` | BM25 code search with code-aware tokenization |
|
|
111
|
+
| `af_code_check_duplicate` | xxHash64 exact + SimHash near-duplicate detection |
|
|
112
|
+
|
|
113
|
+
```typescript
|
|
114
|
+
import { codeIntelligencePlugin } from '@renseiai/agentfactory-code-intelligence'
|
|
115
|
+
|
|
116
|
+
// Register with orchestrator
|
|
117
|
+
const orchestrator = createOrchestrator({
|
|
118
|
+
toolPlugins: [codeIntelligencePlugin],
|
|
119
|
+
})
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
## Supported languages
|
|
123
|
+
|
|
124
|
+
- TypeScript / JavaScript
|
|
125
|
+
- Python
|
|
126
|
+
- Go
|
|
127
|
+
- Rust
|
|
128
|
+
|
|
129
|
+
## License
|
|
130
|
+
|
|
131
|
+
MIT
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@renseiai/agentfactory-code-intelligence",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.8",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Code intelligence for AgentFactory — tree-sitter AST parsing, BM25 search, incremental indexing, memory deduplication",
|
|
6
6
|
"author": "Rensei AI (https://rensei.ai)",
|
|
@@ -68,7 +68,6 @@
|
|
|
68
68
|
"typecheck": "tsc --noEmit",
|
|
69
69
|
"test": "vitest run --passWithNoTests",
|
|
70
70
|
"test:watch": "vitest",
|
|
71
|
-
"clean": "rm -rf dist"
|
|
72
|
-
"prepublishOnly": "pnpm clean && pnpm build"
|
|
71
|
+
"clean": "rm -rf dist"
|
|
73
72
|
}
|
|
74
|
-
}
|
|
73
|
+
}
|