@remnic/coding-graph 9.3.759
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 +130 -0
- package/dist/chunk-5I2DBHOQ.js +1042 -0
- package/dist/chunk-5I2DBHOQ.js.map +1 -0
- package/dist/chunk-CPYJACC5.js +1838 -0
- package/dist/chunk-CPYJACC5.js.map +1 -0
- package/dist/chunk-ZVCMIM4T.js +216 -0
- package/dist/chunk-ZVCMIM4T.js.map +1 -0
- package/dist/cypher/query-parser.d.ts +253 -0
- package/dist/cypher/query-parser.js +17 -0
- package/dist/cypher/query-parser.js.map +1 -0
- package/dist/graph-schema.d.ts +84 -0
- package/dist/graph-schema.js +17 -0
- package/dist/graph-schema.js.map +1 -0
- package/dist/graph-store.d.ts +938 -0
- package/dist/graph-store.js +16 -0
- package/dist/graph-store.js.map +1 -0
- package/dist/index.d.ts +1953 -0
- package/dist/index.js +3509 -0
- package/dist/index.js.map +1 -0
- package/grammars/tree-sitter-bash.wasm +0 -0
- package/grammars/tree-sitter-c.wasm +0 -0
- package/grammars/tree-sitter-c_sharp.wasm +0 -0
- package/grammars/tree-sitter-cpp.wasm +0 -0
- package/grammars/tree-sitter-go.wasm +0 -0
- package/grammars/tree-sitter-java.wasm +0 -0
- package/grammars/tree-sitter-javascript.wasm +0 -0
- package/grammars/tree-sitter-kotlin.wasm +0 -0
- package/grammars/tree-sitter-php.wasm +0 -0
- package/grammars/tree-sitter-python.wasm +0 -0
- package/grammars/tree-sitter-ruby.wasm +0 -0
- package/grammars/tree-sitter-rust.wasm +0 -0
- package/grammars/tree-sitter-swift.wasm +0 -0
- package/grammars/tree-sitter-tsx.wasm +0 -0
- package/grammars/tree-sitter-typescript.wasm +0 -0
- package/package.json +79 -0
- package/src/co-change.test.ts +175 -0
- package/src/co-change.ts +167 -0
- package/src/cypher/query-parser.test.ts +1107 -0
- package/src/cypher/query-parser.ts +1692 -0
- package/src/detect-changes.test.ts +533 -0
- package/src/detect-changes.ts +367 -0
- package/src/engine/emit.ts +556 -0
- package/src/engine/engine.test.ts +1417 -0
- package/src/engine/engine.ts +182 -0
- package/src/engine/extractors.ts +486 -0
- package/src/engine/fixtures.ts +364 -0
- package/src/engine/language-sniff.ts +56 -0
- package/src/engine/parser-backend.ts +206 -0
- package/src/engine/utf16-offsets.ts +68 -0
- package/src/git-invoker.test.ts +116 -0
- package/src/git-invoker.ts +426 -0
- package/src/graph-schema.test.ts +541 -0
- package/src/graph-schema.ts +383 -0
- package/src/graph-store-pr2.test.ts +1879 -0
- package/src/graph-store.test.ts +1420 -0
- package/src/graph-store.ts +3489 -0
- package/src/index-status.test.ts +303 -0
- package/src/index-status.ts +135 -0
- package/src/index.ts +384 -0
- package/src/lsp/byte-position.ts +173 -0
- package/src/lsp/characterization.test.ts +174 -0
- package/src/lsp/client.test.ts +275 -0
- package/src/lsp/client.ts +484 -0
- package/src/lsp/config.ts +219 -0
- package/src/lsp/degradation.ts +86 -0
- package/src/lsp/fixtures/fake-server.mjs +198 -0
- package/src/lsp/framing.test.ts +180 -0
- package/src/lsp/framing.ts +177 -0
- package/src/lsp/resolution.test.ts +497 -0
- package/src/lsp/resolution.ts +483 -0
- package/src/lsp/status.ts +140 -0
- package/src/lsp/types.ts +167 -0
- package/src/reindex.test.ts +1038 -0
- package/src/reindex.ts +908 -0
- package/src/row-types.ts +45 -0
- package/src/semantic/canonical-text.test.ts +150 -0
- package/src/semantic/canonical-text.ts +219 -0
- package/src/semantic/config.ts +235 -0
- package/src/semantic/index.ts +78 -0
- package/src/semantic/minhash.test.ts +197 -0
- package/src/semantic/minhash.ts +261 -0
- package/src/semantic/semantic-query.ts +173 -0
- package/src/semantic/semantic.test.ts +1315 -0
- package/src/semantic/similarity.ts +268 -0
- package/src/semantic/types.ts +145 -0
- package/src/semantic/vectors.ts +235 -0
package/README.md
ADDED
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
# @remnic/coding-graph
|
|
2
|
+
|
|
3
|
+
À-la-carte optional companion of `@remnic/core` that ships the codebase-graph
|
|
4
|
+
engine: web-tree-sitter grammars, per-language symbol extractors, and the
|
|
5
|
+
neutral `FileIR` intermediate representation that the graph store consumes.
|
|
6
|
+
|
|
7
|
+
> Part of #1548 (Track B, Phase 1). Package and core wiring for PR1 (#1551
|
|
8
|
+
> step 1 + step 2). The real backend lands in PR2 (#1551 step 3+).
|
|
9
|
+
|
|
10
|
+
## Install
|
|
11
|
+
|
|
12
|
+
```bash
|
|
13
|
+
npm install @remnic/coding-graph
|
|
14
|
+
# or
|
|
15
|
+
pnpm add @remnic/coding-graph
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## Status (PR1)
|
|
19
|
+
|
|
20
|
+
This package's public surface is **scaffolded only**:
|
|
21
|
+
|
|
22
|
+
- `ENGINE_VERSION = "0.1.0-pr1"` constant
|
|
23
|
+
- `TIER_1_LANGUAGES` (15 languages)
|
|
24
|
+
- `CodingGraphError` tagged error class (`code: "not_implemented" | "module_load_failed"`)
|
|
25
|
+
- `CodingGraphEngine` interface — the full PR2 contract, no implementation
|
|
26
|
+
- `createCodingGraphEngine()` — throws `CodingGraphError("not_implemented", …)`
|
|
27
|
+
|
|
28
|
+
Calling `createCodingGraphEngine()` *always* throws a tagged error. There
|
|
29
|
+
is no silent stub and there is no half-working fallback. The runtime
|
|
30
|
+
contract is observable today; PR2 fills the implementation.
|
|
31
|
+
|
|
32
|
+
`web-tree-sitter` is declared as the parser engine; grammar `.wasm` assets
|
|
33
|
+
will ship in PR2 via the `grammars/` directory listed in the package's
|
|
34
|
+
`files` manifest.
|
|
35
|
+
|
|
36
|
+
## How `@remnic/core` loads this
|
|
37
|
+
|
|
38
|
+
`@remnic/core` does not import `@remnic/coding-graph` directly. It uses a
|
|
39
|
+
computed-specifier dynamic import:
|
|
40
|
+
|
|
41
|
+
```ts
|
|
42
|
+
import type { CodingGraphEngine, ... } from "@remnic/coding-graph"; // types only
|
|
43
|
+
|
|
44
|
+
const SPECIFIER = "@remnic/" + "coding-graph";
|
|
45
|
+
// await import(SPECIFIER) — see
|
|
46
|
+
// packages/remnic-core/src/coding/optional-coding-graph.ts
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
When the optional package is absent the loader throws a user-facing hint:
|
|
50
|
+
|
|
51
|
+
```
|
|
52
|
+
The `@remnic/coding-graph` engine is optional and not installed in this environment.
|
|
53
|
+
|
|
54
|
+
Install it alongside @remnic/core to enable codebase-graph features:
|
|
55
|
+
npm install @remnic/coding-graph
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
## Standards reference
|
|
59
|
+
|
|
60
|
+
- CLAUDE.md rule 57 (à-la-carte) and AGENTS.md rule 44 (computed-specifier dynamic import)
|
|
61
|
+
- `web-tree-sitter` chosen to avoid the native-binding pain called out in
|
|
62
|
+
#1518 / #1538 — see #1548 for the full design rationale
|
|
63
|
+
|
|
64
|
+
## Semantic layer (#1556)
|
|
65
|
+
|
|
66
|
+
The optional semantic layer adds symbol embeddings, `SIMILAR_TO` near-clone
|
|
67
|
+
edges, and `semantic_query` (natural-language retrieval over the symbol graph).
|
|
68
|
+
|
|
69
|
+
### Privacy posture
|
|
70
|
+
|
|
71
|
+
**Default configuration sends nothing anywhere.** The semantic layer is OFF by
|
|
72
|
+
default (`SemanticConfig.enabled = false`). When off, zero embedding provider
|
|
73
|
+
calls are made and zero rows are written to the `symbol_vectors` table — the
|
|
74
|
+
gate-off test (`semantic.test.ts: gate-off`) asserts this end to end.
|
|
75
|
+
|
|
76
|
+
When `enabled = true`:
|
|
77
|
+
- With **no embedding provider** configured: the feature degrades gracefully.
|
|
78
|
+
`SIMILAR_TO` edges are still produced via local, deterministic MinHash/LSH
|
|
79
|
+
(pure TypeScript, no network). `semantic_query` returns a tagged
|
|
80
|
+
`{ ok: false, code: "provider_unavailable" }` — never an empty result
|
|
81
|
+
masquerading as "no matches".
|
|
82
|
+
- With a **remote embedding provider** configured (e.g. OpenAI or an
|
|
83
|
+
OpenAI-compatible endpoint via the host embedding provider registry):
|
|
84
|
+
symbol text (canonical form: kind + qualified name + signature + body
|
|
85
|
+
excerpt) leaves the machine to be embedded. This is the same path
|
|
86
|
+
@remnic/core's `EmbeddingFallback` uses for conversation embeddings —
|
|
87
|
+
no new network stack is introduced.
|
|
88
|
+
|
|
89
|
+
The canonical text that is embedded is the canonical text that is hashed for
|
|
90
|
+
the cache (rule 23): `signature + doc comment + first N tokens of body`,
|
|
91
|
+
whitespace- and punctuation-normalized so formatting variants hash
|
|
92
|
+
identically. Cached vectors are reused on re-index when the content hash is
|
|
93
|
+
unchanged (rule 37).
|
|
94
|
+
|
|
95
|
+
### API surface
|
|
96
|
+
|
|
97
|
+
```typescript
|
|
98
|
+
import {
|
|
99
|
+
resolveSemanticConfig,
|
|
100
|
+
indexSymbolVectors,
|
|
101
|
+
computeSimilarTo,
|
|
102
|
+
similarEdgesToEdgeIR,
|
|
103
|
+
semanticQuery,
|
|
104
|
+
} from "@remnic/coding-graph";
|
|
105
|
+
|
|
106
|
+
const config = resolveSemanticConfig({ enabled: true });
|
|
107
|
+
|
|
108
|
+
// Index: embed symbols, cache by canonical-text hash
|
|
109
|
+
const indexResult = await indexSymbolVectors({ store, provider, repoRoot, config });
|
|
110
|
+
|
|
111
|
+
// SIMILAR_TO: MinHash/LSH candidates → cosine confirmation.
|
|
112
|
+
// repoRoot (or prebuilt bodies) is required so the pipeline hashes real
|
|
113
|
+
// symbol bodies, not qualified names.
|
|
114
|
+
// Compute-first-then-swap: computeSimilarTo is pure (it reads nodes +
|
|
115
|
+
// vectors but never mutates edges), so compute the candidate set BEFORE
|
|
116
|
+
// touching the table. Only on success do we clear + upsert — this
|
|
117
|
+
// preserves the existing SIMILAR_TO edges if the recompute fails (e.g. a
|
|
118
|
+
// closed store or a missing repoRoot), instead of leaving the graph with
|
|
119
|
+
// zero semantic edges. The clear is still required because upsertEdges
|
|
120
|
+
// does not delete absent rows — without it, two symbols that stop being
|
|
121
|
+
// similar would keep a stale edge (replace-not-append).
|
|
122
|
+
const similar = computeSimilarTo({ store, provider, repoRoot, config });
|
|
123
|
+
if (similar.ok) {
|
|
124
|
+
await store.clearSemanticSimilarToEdges();
|
|
125
|
+
await store.upsertEdges(similarEdgesToEdgeIR(similar.edges));
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
// semantic_query: embed query → top-k → hydrate with graph context
|
|
129
|
+
const query = await semanticQuery({ store, provider, repoRoot, config, query: "payment processing" });
|
|
130
|
+
```
|