@maxgfr/codeindex 2.10.0 → 2.11.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/LICENSE +21 -0
- package/README.md +52 -2
- package/package.json +1 -1
- package/scripts/engine.d.mts +18 -3
- package/scripts/engine.mjs +248 -95
- package/src/embed/encode.ts +26 -16
- package/src/embed/endpoint.ts +110 -21
- package/src/embed/index.ts +30 -14
- package/src/embed/search.ts +9 -3
- package/src/engine-cli.ts +99 -22
- package/src/engine.ts +17 -5
- package/src/extract/code.ts +15 -3
- package/src/mcp.ts +31 -17
- package/src/types.ts +6 -3
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 maxgfr
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -75,6 +75,32 @@ codeindex callers --repo . # per-symbol caller index
|
|
|
75
75
|
codeindex grep 'pattern' --repo .
|
|
76
76
|
```
|
|
77
77
|
|
|
78
|
+
## Docker
|
|
79
|
+
|
|
80
|
+
`ghcr.io/maxgfr/codeindex` ships the same zero-dependency bundle (`engine.mjs`
|
|
81
|
+
+ `cli.mjs` + the AST grammars) with nothing else inside — just `node` and the
|
|
82
|
+
files above, no `npm install`. Multi-arch (`linux/amd64`, `linux/arm64`),
|
|
83
|
+
built and pushed on release. Mount the repo to index at `/work`:
|
|
84
|
+
|
|
85
|
+
```sh
|
|
86
|
+
docker run --rm -v "$PWD":/work ghcr.io/maxgfr/codeindex scan --repo /work
|
|
87
|
+
docker run --rm -v "$PWD":/work ghcr.io/maxgfr/codeindex index --repo /work --out /work/.codeindex
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
Pin by digest in CI or anywhere reproducibility matters, rather than a
|
|
91
|
+
mutable tag:
|
|
92
|
+
|
|
93
|
+
```sh
|
|
94
|
+
docker run --rm -v "$PWD":/work ghcr.io/maxgfr/codeindex@sha256:... scan --repo /work
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
Runs as an MCP server over stdio the same way as the npm CLI (see
|
|
98
|
+
**Use as an MCP server** below) — add `-i` so `docker run` keeps stdin open:
|
|
99
|
+
|
|
100
|
+
```sh
|
|
101
|
+
docker run -i --rm -v "$PWD":/work ghcr.io/maxgfr/codeindex mcp
|
|
102
|
+
```
|
|
103
|
+
|
|
78
104
|
## Search
|
|
79
105
|
|
|
80
106
|
`codeindex search "<query>" --repo .` ranks files with keyless BM25 over symbol
|
|
@@ -104,14 +130,38 @@ lexical, and `--semantic` without a model returns lexical results on **exit 0**
|
|
|
104
130
|
resolved from `CODEINDEX_EMBED_DIR` or `<repo>/.codeindex/models/`.
|
|
105
131
|
|
|
106
132
|
```sh
|
|
107
|
-
codeindex embed status --repo . #
|
|
133
|
+
codeindex embed status --repo . # effective mode + reachability (JSON)
|
|
108
134
|
codeindex embed build --repo . --out .codeindex # write embeddings.bin
|
|
109
135
|
codeindex search "http client retry" --repo . --semantic
|
|
110
136
|
```
|
|
111
137
|
|
|
112
138
|
`codeindex index` also writes `embeddings.bin` next to `graph.json` when a model
|
|
113
139
|
is present. Fusion reuses the engine's `rrf` helper (k=60); `SCHEMA_VERSION` is
|
|
114
|
-
untouched (a dedicated `EMBED_VERSION` keys the sidecar).
|
|
140
|
+
untouched (a dedicated `EMBED_VERSION` keys the sidecar).
|
|
141
|
+
|
|
142
|
+
#### Three embedding modes (precedence: endpoint > static > none)
|
|
143
|
+
|
|
144
|
+
| mode | trigger | determinism |
|
|
145
|
+
|---|---|---|
|
|
146
|
+
| **none** | no model, no endpoint | — (pure lexical) |
|
|
147
|
+
| **static** | a `model.json` on disk | byte-deterministic (goldens) |
|
|
148
|
+
| **endpoint** | `CODEINDEX_EMBED_ENDPOINT` set | per **image digest** |
|
|
149
|
+
|
|
150
|
+
The **rich (endpoint) tier** points the engine at a local containerized
|
|
151
|
+
embedding server (all-MiniLM-L6-v2). The endpoint's float vectors flow through
|
|
152
|
+
the *same* L2 + int8-quantize + integer-ranking pipeline as the static tier.
|
|
153
|
+
Setting the env var is explicit intent, so it **wins over** a local model; an
|
|
154
|
+
unreachable endpoint degrades to lexical (exit 0), not to the static model.
|
|
155
|
+
|
|
156
|
+
```sh
|
|
157
|
+
codeindex embed serve # print the docker run one-liner (or --run it)
|
|
158
|
+
docker run -d -p 8756:8756 ghcr.io/maxgfr/codeindex-embed:latest
|
|
159
|
+
# reproducible: pin the digest → ghcr.io/maxgfr/codeindex-embed@sha256:<digest>
|
|
160
|
+
CODEINDEX_EMBED_ENDPOINT=http://localhost:8756 \
|
|
161
|
+
codeindex search "auth token" --repo . --semantic
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
Full details incl. the HTTP protocol (build your own server):
|
|
115
165
|
[docs/SEMANTIC.md](./docs/SEMANTIC.md).
|
|
116
166
|
|
|
117
167
|
## Use as an MCP server
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@maxgfr/codeindex",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.11.0",
|
|
4
4
|
"description": "Self-contained, deterministic repo-indexing engine: walk + language detection + symbol/import extraction (tree-sitter AST with regex fallback) + import resolution + typed cross-file link-graph + analytics. Ships as a single zero-dependency engine.mjs that consumer tools vendor.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"packageManager": "pnpm@10.33.0",
|
package/scripts/engine.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
declare const ENGINE_VERSION = "2.
|
|
1
|
+
declare const ENGINE_VERSION = "2.11.0";
|
|
2
2
|
declare const SCHEMA_VERSION = 4;
|
|
3
|
-
declare const EXTRACTOR_VERSION =
|
|
3
|
+
declare const EXTRACTOR_VERSION = 7;
|
|
4
4
|
type FileKind = "code" | "doc" | "config" | "asset" | "other";
|
|
5
5
|
type EdgeKind = "contains" | "doc-link" | "import" | "call" | "use" | "mention";
|
|
6
6
|
type Tier = 0 | 1 | 2;
|
|
@@ -518,6 +518,7 @@ declare function basicTokenize(text: string): string[];
|
|
|
518
518
|
declare function wordpiece(word: string, model: StaticEmbedModel): number[];
|
|
519
519
|
declare function tokenize(text: string, model: StaticEmbedModel): number[];
|
|
520
520
|
declare function roundHalfToEven(x: number): number;
|
|
521
|
+
declare function quantize(vec: ArrayLike<number>): Int8Array;
|
|
521
522
|
declare function encode(model: StaticEmbedModel, text: string): Int8Array;
|
|
522
523
|
declare function intDot(a: Int8Array, b: Int8Array): number;
|
|
523
524
|
|
|
@@ -533,12 +534,20 @@ interface EmbeddingIndex {
|
|
|
533
534
|
dim: number;
|
|
534
535
|
records: EmbeddingRecord[];
|
|
535
536
|
}
|
|
537
|
+
interface EmbeddingUnit {
|
|
538
|
+
file: string;
|
|
539
|
+
symbol?: string;
|
|
540
|
+
line?: number;
|
|
541
|
+
text: string;
|
|
542
|
+
}
|
|
543
|
+
declare function embeddingUnits(scan: RepoScan): EmbeddingUnit[];
|
|
536
544
|
declare function buildEmbeddingIndex(scan: RepoScan, model: StaticEmbedModel): EmbeddingIndex;
|
|
537
545
|
declare function serializeEmbeddings(index: EmbeddingIndex): Uint8Array;
|
|
538
546
|
declare function deserializeEmbeddings(bytes: Uint8Array): EmbeddingIndex;
|
|
539
547
|
|
|
540
548
|
interface SemanticSearchOptions extends SearchOptions {
|
|
541
549
|
model?: StaticEmbedModel;
|
|
550
|
+
queryVec?: Int8Array;
|
|
542
551
|
rrfK?: number;
|
|
543
552
|
}
|
|
544
553
|
interface SemanticSearchResult extends SearchResult {
|
|
@@ -550,9 +559,15 @@ interface EmbedEndpointOptions {
|
|
|
550
559
|
url?: string;
|
|
551
560
|
timeoutMs?: number;
|
|
552
561
|
headers?: Record<string, string>;
|
|
562
|
+
batchSize?: number;
|
|
553
563
|
}
|
|
554
564
|
declare function resolveEmbedEndpoint(opts?: EmbedEndpointOptions): string | undefined;
|
|
565
|
+
declare function embedEndpointUrl(base: string): string;
|
|
566
|
+
declare function healthzUrl(base: string): string;
|
|
555
567
|
declare function embedViaEndpoint(texts: string[], opts?: EmbedEndpointOptions): Promise<number[][]>;
|
|
568
|
+
declare function probeEndpoint(base: string, opts?: EmbedEndpointOptions): Promise<boolean>;
|
|
569
|
+
declare function encodeQueryViaEndpoint(query: string, opts?: EmbedEndpointOptions): Promise<Int8Array>;
|
|
570
|
+
declare function buildEndpointIndex(scan: RepoScan, opts?: EmbedEndpointOptions): Promise<EmbeddingIndex>;
|
|
556
571
|
|
|
557
572
|
type RuleSeverity = "error" | "warn";
|
|
558
573
|
interface ForbiddenEdgeRule {
|
|
@@ -678,4 +693,4 @@ declare function rrf<T>(lists: T[][], keyOf: (item: T) => string, k?: number): M
|
|
|
678
693
|
|
|
679
694
|
declare function runCli(argv: string[]): Promise<void>;
|
|
680
695
|
|
|
681
|
-
export { type ArchRule, type BuildIndexOptions, type BuiltinRule, type CallerEntry, type CallerIndex, type CallerIndexOptions, type CallerSite, type ChangeCoupling, type CodeInfo, type CodeSymbol, type CouplingOptions, DEFAULT_MAX_FILES, type DeadSymbol, type DiffFile, type DiffSpec, EMBED_VERSION, ENGINE_VERSION, EXTRACTOR_VERSION, type Edge, type EdgeKind, type EditResult, type EmbedEndpointOptions, type EmbeddingIndex, type EmbeddingRecord, type FileCategory, type FileKind, type FileNode, type FileRecord, type FindSymbolOptions, type ForbiddenEdgeRule, type Graph, type GrepOptions, type Hotspot, type Hunk, type IgnoreRule, type IndexArtifacts, MARKDOWN_EXT, type MarkdownInfo, type MermaidOptions, type ModuleInfo, type ModuleNode, type RawRef, type RenderScipOptions, type RepoMapOptions, type RepoScan, type Resolution, type ResolveContext, type RiskHotspot, type RuleSeverity, type RuleViolation, SCHEMA_VERSION, type ScanOptions, type SearchHit, type SearchOptions, type SearchResult, type SemanticSearchOptions, type SemanticSearchResult, type ShResult, type StaticEmbedModel, type SurpriseEdge, type SymbolComplexity, type SymbolIndex, type SymbolMatch, type SymbolReferences, type TestMap, type Tier, type WalkOptions, type WalkResult, type WalkedFile, type WorkspaceInfo, type WorkspaceKind, type WorkspacePackage, allGrammarKeys, applyCentrality, basicTokenize, betweennessOf, buildCallerIndex, buildEmbeddingIndex, buildGraph, buildIndexArtifacts, buildModules, buildResolveContext, buildSymbolIndex, byKey, byStr, categorize, changeCoupling, changedSince, checkRules, classify, clip, clipInline, communityOf, compileGlobs, complexityOfSource, computeImportPairs, computeSurprises, computeSymbolRefs, computeTestMap, deleteMemory, deserializeEmbeddings, detectCommunities, detectWorkspaces, diffFiles, diffHunks, embedViaEndpoint, enclosingSymbol, encode, ensureGrammars, escapeRegExp, extToLang, extractAst, extractCode, extractMarkdown, extractSymbols, findDeadCode, findReferences, findSymbol, foldText, gitChurn, grammarKeyForExt, grammarReady, grepRepo, hasEmbedModel, have, headCommit, insertAfterSymbol, insertBeforeSymbol, intDot, isCode, isDoc, isGitWorktree, isIgnored, isSurprising, isTestFile, isTestPath, keywords, languageOf, listMemories, loadEmbedModel, pagerankOf, parseGitignore, parseRules, rankHotspots, rankedKeywords, readMemory, readText, renderGraphJson, renderMermaid, renderRepoMap, renderScip, renderSymbolsJson, replaceSymbolBody, resolveBaseRef, resolveCallEdges, resolveDocLink, resolveEmbedEndpoint, resolveEmbedModelDir, resolveEmbedPullUrl, resolveImport, resolveUniqueSymbol, riskHotspots, roundHalfToEven, rrf, runCli, runMcpServer, scanRepo, searchIndex, searchSemantic, serializeEmbeddings, sh, sha1, shortHash, slugify, subtokens, symbolComplexity, symbolsOverview, testsForModule, tierForPath, tokenize, uniqueSymbolDefs, untestedModules, untrackedFiles, walk, wordpiece, writeMemory };
|
|
696
|
+
export { type ArchRule, type BuildIndexOptions, type BuiltinRule, type CallerEntry, type CallerIndex, type CallerIndexOptions, type CallerSite, type ChangeCoupling, type CodeInfo, type CodeSymbol, type CouplingOptions, DEFAULT_MAX_FILES, type DeadSymbol, type DiffFile, type DiffSpec, EMBED_VERSION, ENGINE_VERSION, EXTRACTOR_VERSION, type Edge, type EdgeKind, type EditResult, type EmbedEndpointOptions, type EmbeddingIndex, type EmbeddingRecord, type EmbeddingUnit, type FileCategory, type FileKind, type FileNode, type FileRecord, type FindSymbolOptions, type ForbiddenEdgeRule, type Graph, type GrepOptions, type Hotspot, type Hunk, type IgnoreRule, type IndexArtifacts, MARKDOWN_EXT, type MarkdownInfo, type MermaidOptions, type ModuleInfo, type ModuleNode, type RawRef, type RenderScipOptions, type RepoMapOptions, type RepoScan, type Resolution, type ResolveContext, type RiskHotspot, type RuleSeverity, type RuleViolation, SCHEMA_VERSION, type ScanOptions, type SearchHit, type SearchOptions, type SearchResult, type SemanticSearchOptions, type SemanticSearchResult, type ShResult, type StaticEmbedModel, type SurpriseEdge, type SymbolComplexity, type SymbolIndex, type SymbolMatch, type SymbolReferences, type TestMap, type Tier, type WalkOptions, type WalkResult, type WalkedFile, type WorkspaceInfo, type WorkspaceKind, type WorkspacePackage, allGrammarKeys, applyCentrality, basicTokenize, betweennessOf, buildCallerIndex, buildEmbeddingIndex, buildEndpointIndex, buildGraph, buildIndexArtifacts, buildModules, buildResolveContext, buildSymbolIndex, byKey, byStr, categorize, changeCoupling, changedSince, checkRules, classify, clip, clipInline, communityOf, compileGlobs, complexityOfSource, computeImportPairs, computeSurprises, computeSymbolRefs, computeTestMap, deleteMemory, deserializeEmbeddings, detectCommunities, detectWorkspaces, diffFiles, diffHunks, embedEndpointUrl, embedViaEndpoint, embeddingUnits, enclosingSymbol, encode, encodeQueryViaEndpoint, ensureGrammars, escapeRegExp, extToLang, extractAst, extractCode, extractMarkdown, extractSymbols, findDeadCode, findReferences, findSymbol, foldText, gitChurn, grammarKeyForExt, grammarReady, grepRepo, hasEmbedModel, have, headCommit, healthzUrl, insertAfterSymbol, insertBeforeSymbol, intDot, isCode, isDoc, isGitWorktree, isIgnored, isSurprising, isTestFile, isTestPath, keywords, languageOf, listMemories, loadEmbedModel, pagerankOf, parseGitignore, parseRules, probeEndpoint, quantize, rankHotspots, rankedKeywords, readMemory, readText, renderGraphJson, renderMermaid, renderRepoMap, renderScip, renderSymbolsJson, replaceSymbolBody, resolveBaseRef, resolveCallEdges, resolveDocLink, resolveEmbedEndpoint, resolveEmbedModelDir, resolveEmbedPullUrl, resolveImport, resolveUniqueSymbol, riskHotspots, roundHalfToEven, rrf, runCli, runMcpServer, scanRepo, searchIndex, searchSemantic, serializeEmbeddings, sh, sha1, shortHash, slugify, subtokens, symbolComplexity, symbolsOverview, testsForModule, tierForPath, tokenize, uniqueSymbolDefs, untestedModules, untrackedFiles, walk, wordpiece, writeMemory };
|