@draht/tools 2026.11.18 → 2026.11.19
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/CHANGELOG.md +32 -0
- package/README.md +26 -2
- package/bin/draht-kg.cjs +4782 -0
- package/bin/draht-tools.cjs +747 -47
- package/package.json +2 -2
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## [2026.11.19-1] - 2026-11-19
|
|
4
|
+
|
|
5
|
+
### Added
|
|
6
|
+
|
|
7
|
+
- run kg in the Go engine with output identical to the JavaScript engine
|
|
8
|
+
- align Go engine with CJS parity
|
|
9
|
+
- kg engine — graphify-parity symbol-level knowledge graph
|
|
10
|
+
- graphify parity for the living map — barrel exports, query recall, Insights view
|
|
11
|
+
- kg engine — graphify-parity symbol-level knowledge graph
|
|
12
|
+
- graphify parity for the living map — barrel exports, query recall, Insights view
|
|
13
|
+
|
|
14
|
+
### Fixed
|
|
15
|
+
|
|
16
|
+
- kg reads comparisons and pattern defaults in parameter lists correctly
|
|
17
|
+
- kg keeps calls in default values and reads parameter lists by binding
|
|
18
|
+
- kg no longer links shadowed names or type signatures as calls
|
|
19
|
+
- resolve kg workspace subpath imports through package exports
|
|
20
|
+
- keep star-barrel names whose re-export target stars them in
|
|
21
|
+
- keep kg declaration headers, type imports and wiki pages accurate
|
|
22
|
+
- resolve local export aliases before comparing star-export binding origins
|
|
23
|
+
- accept generic class headers, compare star origins by binding, bound wiki names
|
|
24
|
+
- address Greptile round-6 findings on kg parsing and star origins
|
|
25
|
+
- use lookbehind in kg call scans so nested calls are not consumed
|
|
26
|
+
- harden default-decl regex, retract stale star copies, isolate query test
|
|
27
|
+
- keep multiline function headers open and guard namespace-call receivers
|
|
28
|
+
- address Greptile review findings on kg engine and star expansion
|
|
29
|
+
- classify named default declarations as the default export
|
|
30
|
+
- address CodeRabbit re-review findings on export extraction
|
|
31
|
+
- address CodeRabbit review findings on knowledge-graph parity
|
|
32
|
+
- address Greptile P1 findings — expansion fixpoint, Go aliases, Rust impl methods
|
package/README.md
CHANGED
|
@@ -24,6 +24,10 @@ Run `draht-tools help` for the full list. Highlights:
|
|
|
24
24
|
| `graph-path <from> <to>` | Shortest import path between two files |
|
|
25
25
|
| `graph-hotspots` / `graph-clusters [--surprising]` | God-nodes / structural neighborhoods + surprising connections |
|
|
26
26
|
| `graph-hook install\|uninstall\|status` | Git post-commit hook that refreshes the map |
|
|
27
|
+
| `kg build` | **Symbol-level** knowledge graph (graphify-parity engine) → `graph.json` + `KG_REPORT.md` |
|
|
28
|
+
| `kg query "<question>"` | Files ranked for the question (text, symbol names, path), then a BFS/DFS subgraph from the best — graphify's `NODE`/`EDGE` output |
|
|
29
|
+
| `kg explain` / `kg path` / `kg affected` | Node dump · shortest path with relation arrows · reverse blast-radius |
|
|
30
|
+
| `kg export tree\|wiki\|graphml` | Collapsible module tree HTML / wiki articles / GraphML |
|
|
27
31
|
| `init` / `create-project` / `create-roadmap` / … | Planning scaffolding (see `help`) |
|
|
28
32
|
|
|
29
33
|
All `graph-*` commands are **read-only** (never mutate `MAP.json`), print concise text by default (`--json` for machine output), and degrade gracefully when no map exists (`run map-graph first`).
|
|
@@ -32,17 +36,37 @@ All `graph-*` commands are **read-only** (never mutate `MAP.json`), print concis
|
|
|
32
36
|
|
|
33
37
|
`map-graph` builds an interactive, graphify-style **knowledge graph** of your codebase — not just stats:
|
|
34
38
|
|
|
35
|
-
- **MAP.json** (schemaVersion
|
|
39
|
+
- **MAP.json** (schemaVersion 6) — entry points (CLI bins, HTTP routes, library main exports), sinks (FS / net / DB / stdout / exec calls), bounded contexts (packages), cross-package dataflow edges, symbol-resolved call edges, flows, per-module architectural layer (presentation / application / domain / infrastructure / support), exports and imports per file — **plus**: `symbols` (symbol-level nodes with line numbers), `clusters` (deterministic label-propagation neighborhoods) + per-module `cluster`, `hotspots` (god-nodes / most-depended-on / orchestrators / largest), `surprisingConnections` (bridge / cross-group / layer-violating edges), `rationaleIndex` (inline `NOTE`/`WHY`/`HACK`/`TODO`/`FIXME`/`SECURITY` notes), and `EXTRACTED` / `INFERRED` / `AMBIGUOUS` confidence on every edge. Barrel files are first-class: `export { X } from './y'`, multi-line export blocks, and `export * from './y'` (expanded from the resolved target, with `via` provenance) all populate the barrel's own `exports`/`symbols`, so a package's public API is visible on its `index.ts`. Only code-language files become `modules` — docs/config/lockfiles/images etc. are excluded from the module graph (to keep imports/clusters/hotspots free of non-code noise) but still show up in `stats.languages` and are still scanned for `rationaleIndex` notes. Read once and you know how the software actually works — or query it with the `graph-*` commands instead of grepping.
|
|
36
40
|
- **GRAPH_REPORT.md** — a deterministic, skimmable narrative: overview, key concepts (top clusters), god nodes, surprising connections, rationale highlights, and templated suggested questions. The one page to read first.
|
|
37
|
-
- **MAP.html** — an interactive viewer with
|
|
41
|
+
- **MAP.html** — an interactive viewer with four tabs:
|
|
38
42
|
- **Graph** — the interactive force-directed canvas graph: nodes colored by cluster and sized by degree, collapsed to one supernode per cluster by default; search, layer/cluster/edge-confidence filters, an inspector (file, symbols, importers, callers), and PNG/SVG export.
|
|
39
43
|
- **Architecture** — package containers in layer bands with cross-package dataflow arrows (thickness = import count); click a package for detail, double-click a group header to focus.
|
|
40
44
|
- **Flows** — entry points on top, sinks on bottom, intermediate modules ranked by depth. Pick an entry → trace which sinks it reaches and through which module.
|
|
45
|
+
- **Insights** — the graphify-style "read this first" panel: clusters table, god nodes / most-depended-on / orchestrators, surprising connections, and SECURITY/BUG/FIXME/HACK rationale highlights, all click-through to the inspector (keyboard: `i`).
|
|
41
46
|
|
|
42
47
|
`MAP.html` embeds the map data inline, so it works fully offline via `file://` — no server needed. Run `draht-tools map-serve` instead for a live-reloading dev view that pushes updates over SSE as you edit.
|
|
43
48
|
|
|
44
49
|
`map-graph` and `map-codebase` always map the **whole repository** from the git root, regardless of any `[dir]` argument — a directory argument only scopes the narrative analysis (`map-codebase`'s STACK/ARCHITECTURE/CONVENTIONS/CONCERNS docs), never the graph itself. The map regenerates on every code-file save (docs/asset saves are ignored by design) in `map-serve` mode (`fs.watch` + Server-Sent Events), and on every commit if you `graph-hook install`. The build is **deterministic** (git-committable) and writes are idempotent — a no-op rebuild produces zero diff. No need to write architecture docs by hand — the map is always current.
|
|
45
50
|
|
|
51
|
+
## Two engines, both deterministic (no LLM anywhere in indexing)
|
|
52
|
+
|
|
53
|
+
Both run in the prebuilt `draht-graph` Go binary when one is installed and in JavaScript otherwise (`DRAHT_GRAPH_ENGINE=go|js|auto`). For `kg` the two implementations are held byte-identical — `graph.json`, reports, exports and command output — by `go/internal/kg`'s parity test.
|
|
54
|
+
|
|
55
|
+
| | `map-graph` (living map) | `kg` (graphify-parity engine, `bin/draht-kg.cjs`) |
|
|
56
|
+
|---|---|---|
|
|
57
|
+
| Languages | any file the map recognizes; symbols and imports for the code languages it parses | TS/JS, Python, Go, Rust — declarations, imports and calls each resolved by the language's own rules (module tree, package scope, source roots) |
|
|
58
|
+
| Nodes | modules (files) with symbols as attributes | **symbols**: files, classes, `functions()`, `methods()`, types, constants, declarations nested in function bodies |
|
|
59
|
+
| Edges | import / re-export / external + call heuristics | graphify's relation set: `imports`, `imports_from`, `re_exports`, `dynamic_import`, `contains`, `defines`, `method`, `calls`, `indirect_call`, `inherits`, `implements`, `extends`, `instantiates` |
|
|
60
|
+
| Confidence | per-edge tag | tag **+ `confidence_score`** (EXTRACTED 1.0 · INFERRED 0.8 calls · AMBIGUOUS 0.2), graphify's rubric |
|
|
61
|
+
| IDs | file paths | graphify `ids.py` canonicalization (NFKC → `_` → casefold), e.g. `packages_router_src_router_modelrouter`; methods of one class whose names share an id (`close()` / `#close()`) get graphify's 6-hex suffix |
|
|
62
|
+
| Query | ranked search (`graph-query`) | **file-first ranking + subgraph traversal** (`kg query`): files scored by BM25 over their stored keywords, best symbol name and path → the top files' symbols lead the output → BFS/DFS from the best three with p99-degree hub guard → `NODE`/`EDGE` lines under a token budget |
|
|
63
|
+
| Output | MAP.json (schema v6) + MAP.html + GRAPH_REPORT.md | `graph.json` (node-link, loadable by graphify's own tooling) + KG_REPORT.md + GRAPH_TREE.html/wiki/GraphML |
|
|
64
|
+
|
|
65
|
+
Both engines are pure deterministic JS — the LLM is only involved in the *narrative* docs
|
|
66
|
+
(`map-codebase`'s STACK/ARCHITECTURE/…), never in indexing. A no-op rebuild over an existing
|
|
67
|
+
map leaves the file byte-identical (regression-tested; independent fresh builds differ only in
|
|
68
|
+
the `generatedAt`/`buildMs` stamps), so both graphs are safe to commit or regenerate from hooks.
|
|
69
|
+
|
|
46
70
|
## Querying the graph (instead of grepping)
|
|
47
71
|
|
|
48
72
|
The `graph-*` commands let agents (and you) orient without walking the tree:
|