@maxgfr/codeindex 2.10.0 → 2.11.1

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 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
@@ -1,5 +1,7 @@
1
1
  # codeindex
2
2
 
3
+ [![Site](https://img.shields.io/badge/site-maxgfr.github.io%2Fcodeindex-2a78d6)](https://maxgfr.github.io/codeindex/)
4
+
3
5
  Self-contained, deterministic **repo-indexing engine**: file walking, language
4
6
  detection, symbol/import extraction (tree-sitter AST with a regex fallback),
5
7
  import resolution, a typed cross-file link-graph, and graph analytics — shipped
@@ -75,6 +77,32 @@ codeindex callers --repo . # per-symbol caller index
75
77
  codeindex grep 'pattern' --repo .
76
78
  ```
77
79
 
80
+ ## Docker
81
+
82
+ `ghcr.io/maxgfr/codeindex` ships the same zero-dependency bundle (`engine.mjs`
83
+ + `cli.mjs` + the AST grammars) with nothing else inside — just `node` and the
84
+ files above, no `npm install`. Multi-arch (`linux/amd64`, `linux/arm64`),
85
+ built and pushed on release. Mount the repo to index at `/work`:
86
+
87
+ ```sh
88
+ docker run --rm -v "$PWD":/work ghcr.io/maxgfr/codeindex scan --repo /work
89
+ docker run --rm -v "$PWD":/work ghcr.io/maxgfr/codeindex index --repo /work --out /work/.codeindex
90
+ ```
91
+
92
+ Pin by digest in CI or anywhere reproducibility matters, rather than a
93
+ mutable tag:
94
+
95
+ ```sh
96
+ docker run --rm -v "$PWD":/work ghcr.io/maxgfr/codeindex@sha256:... scan --repo /work
97
+ ```
98
+
99
+ Runs as an MCP server over stdio the same way as the npm CLI (see
100
+ **Use as an MCP server** below) — add `-i` so `docker run` keeps stdin open:
101
+
102
+ ```sh
103
+ docker run -i --rm -v "$PWD":/work ghcr.io/maxgfr/codeindex mcp
104
+ ```
105
+
78
106
  ## Search
79
107
 
80
108
  `codeindex search "<query>" --repo .` ranks files with keyless BM25 over symbol
@@ -104,14 +132,38 @@ lexical, and `--semantic` without a model returns lexical results on **exit 0**
104
132
  resolved from `CODEINDEX_EMBED_DIR` or `<repo>/.codeindex/models/`.
105
133
 
106
134
  ```sh
107
- codeindex embed status --repo . # is a model active? (JSON)
135
+ codeindex embed status --repo . # effective mode + reachability (JSON)
108
136
  codeindex embed build --repo . --out .codeindex # write embeddings.bin
109
137
  codeindex search "http client retry" --repo . --semantic
110
138
  ```
111
139
 
112
140
  `codeindex index` also writes `embeddings.bin` next to `graph.json` when a model
113
141
  is present. Fusion reuses the engine's `rrf` helper (k=60); `SCHEMA_VERSION` is
114
- untouched (a dedicated `EMBED_VERSION` keys the sidecar). Full details:
142
+ untouched (a dedicated `EMBED_VERSION` keys the sidecar).
143
+
144
+ #### Three embedding modes (precedence: endpoint > static > none)
145
+
146
+ | mode | trigger | determinism |
147
+ |---|---|---|
148
+ | **none** | no model, no endpoint | — (pure lexical) |
149
+ | **static** | a `model.json` on disk | byte-deterministic (goldens) |
150
+ | **endpoint** | `CODEINDEX_EMBED_ENDPOINT` set | per **image digest** |
151
+
152
+ The **rich (endpoint) tier** points the engine at a local containerized
153
+ embedding server (all-MiniLM-L6-v2). The endpoint's float vectors flow through
154
+ the *same* L2 + int8-quantize + integer-ranking pipeline as the static tier.
155
+ Setting the env var is explicit intent, so it **wins over** a local model; an
156
+ unreachable endpoint degrades to lexical (exit 0), not to the static model.
157
+
158
+ ```sh
159
+ codeindex embed serve # print the docker run one-liner (or --run it)
160
+ docker run -d -p 8756:8756 ghcr.io/maxgfr/codeindex-embed:latest
161
+ # reproducible: pin the digest → ghcr.io/maxgfr/codeindex-embed@sha256:<digest>
162
+ CODEINDEX_EMBED_ENDPOINT=http://localhost:8756 \
163
+ codeindex search "auth token" --repo . --semantic
164
+ ```
165
+
166
+ Full details incl. the HTTP protocol (build your own server):
115
167
  [docs/SEMANTIC.md](./docs/SEMANTIC.md).
116
168
 
117
169
  ## Use as an MCP server
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@maxgfr/codeindex",
3
- "version": "2.10.0",
3
+ "version": "2.11.1",
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",
@@ -1,6 +1,6 @@
1
- declare const ENGINE_VERSION = "2.10.0";
1
+ declare const ENGINE_VERSION = "2.11.1";
2
2
  declare const SCHEMA_VERSION = 4;
3
- declare const EXTRACTOR_VERSION = 6;
3
+ declare const EXTRACTOR_VERSION = 8;
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 };