@draht/tools 2026.6.11
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 +59 -0
- package/bin/draht-tools.cjs +4875 -0
- package/package.json +39 -0
package/README.md
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
# @draht/tools
|
|
2
|
+
|
|
3
|
+
Canonical CLI for the Draht **Get Shit Done** methodology.
|
|
4
|
+
|
|
5
|
+
This package is the single source of truth for the `draht-tools` binary used by:
|
|
6
|
+
- [`draht-claude`](../draht-claude) — Claude Code plugin
|
|
7
|
+
- [`@draht/coding-agent`](../coding-agent) — Coding agent CLI
|
|
8
|
+
|
|
9
|
+
Both consumer packages copy `bin/draht-tools.cjs` into their own `bin/` during build / publish so the resulting npm tarballs remain self-contained.
|
|
10
|
+
|
|
11
|
+
## Commands
|
|
12
|
+
|
|
13
|
+
Run `draht-tools help` for the full list. Highlights:
|
|
14
|
+
|
|
15
|
+
| Command | What it does |
|
|
16
|
+
|---|---|
|
|
17
|
+
| `map-codebase [dir]` | Generate `.planning/codebase/*.md` from the current repo |
|
|
18
|
+
| `map-graph [dir] [--quiet]` | Generate `.planning/codebase/MAP.json` + `MAP.html` + `GRAPH_REPORT.md` — the **living map** (`--quiet` = JSON + report only, for hooks) |
|
|
19
|
+
| `map-serve [port]` | HTTP server with live reload — open the map in a browser and watch it update as you code |
|
|
20
|
+
| `graph-context <file…>` | Where a file sits: package, layer, cluster, importers/imports, sinks, rationale |
|
|
21
|
+
| `graph-impact <file…>` | Blast radius: reverse-dependents, entry points reached, downstream sinks, boundary warnings |
|
|
22
|
+
| `graph-query <term…>` | Ranked symbol + doc search — replaces `grep` for "find the X" |
|
|
23
|
+
| `graph-callers` / `graph-callees <file>` | Who calls / what it calls (N hops via `--depth`) |
|
|
24
|
+
| `graph-path <from> <to>` | Shortest import path between two files |
|
|
25
|
+
| `graph-hotspots` / `graph-clusters [--surprising]` | God-nodes / structural neighborhoods + surprising connections |
|
|
26
|
+
| `graph-hook install\|uninstall\|status` | Git post-commit hook that refreshes the map |
|
|
27
|
+
| `init` / `create-project` / `create-roadmap` / … | Planning scaffolding (see `help`) |
|
|
28
|
+
|
|
29
|
+
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`).
|
|
30
|
+
|
|
31
|
+
## Living architecture map
|
|
32
|
+
|
|
33
|
+
`map-graph` builds an interactive, graphify-style **knowledge graph** of your codebase — not just stats:
|
|
34
|
+
|
|
35
|
+
- **MAP.json** (schemaVersion 4) — 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. Read once and you know how the software actually works — or query it with the `graph-*` commands instead of grepping.
|
|
36
|
+
- **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** — four layered views:
|
|
38
|
+
- **System** — packages as containers in horizontal layer bands; cross-package dataflow drawn as arrows (thickness = import count).
|
|
39
|
+
- **Modules** — every file inside its package container; click a package or sink to highlight its subgraph.
|
|
40
|
+
- **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.
|
|
41
|
+
- **Insights** — modules colored by cluster, god-nodes enlarged, surprising connections drawn as hot edges. Hover any node for detail.
|
|
42
|
+
|
|
43
|
+
The map regenerates on every file save 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.
|
|
44
|
+
|
|
45
|
+
## Querying the graph (instead of grepping)
|
|
46
|
+
|
|
47
|
+
The `graph-*` commands let agents (and you) orient without walking the tree:
|
|
48
|
+
|
|
49
|
+
```sh
|
|
50
|
+
draht-tools graph-context src/auth/session.ts # package · layer · cluster · callers · sinks
|
|
51
|
+
draht-tools graph-impact src/auth/session.ts # what breaks if I change this
|
|
52
|
+
draht-tools graph-query auth storage # find the symbol/concept (ranked, no grep)
|
|
53
|
+
draht-tools graph-path a.ts b.ts # how does A reach B
|
|
54
|
+
draht-tools graph-clusters --surprising # neighborhoods + anomalous edges
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
## Architecture
|
|
58
|
+
|
|
59
|
+
Self-contained CommonJS, zero runtime dependencies, Node ≥20. Loads only `node:fs`, `node:path`, `node:child_process`, `node:http`.
|