@draht/tools

中文文档
2026.11.5发布于 2026/11/06MITCommonJS零依赖近 30 天下载 2607

Draht Tools — Get Shit Done CLI (canonical source shared by draht-claude and @draht/coding-agent).

原始使用文档
文档目录4 节
  1. Commands
  2. Living architecture map
  3. Querying the graph (instead of grepping)
  4. Architecture

@draht/tools

Canonical CLI for the Draht Get Shit Done methodology.

This package is the single source of truth for the draht-tools binary used by:

Both consumer packages copy bin/draht-tools.cjs into their own bin/ during build / publish so the resulting npm tarballs remain self-contained.

Commands

Run draht-tools help for the full list. Highlights:

CommandWhat it does
map-codebase [dir]Generate .planning/codebase/*.md from the current repo
map-graph [dir] [--quiet]Generate .planning/codebase/MAP.json + MAP.html + GRAPH_REPORT.md — the living map (--quiet = JSON + report only, for hooks)
map-serve [port]HTTP server with live reload — open the map in a browser and watch it update as you code
graph-context <file…>Where a file sits: package, layer, cluster, importers/imports, sinks, rationale
graph-impact <file…>Blast radius: reverse-dependents, entry points reached, downstream sinks, boundary warnings
graph-query <term…>Ranked symbol + doc search — replaces grep for "find the X"
graph-callers / graph-callees <file>Who calls / what it calls (N hops via --depth)
graph-path <from> <to>Shortest import path between two files
graph-hotspots / graph-clusters [--surprising]God-nodes / structural neighborhoods + surprising connections
graph-hook install|uninstall|statusGit post-commit hook that refreshes the map
init / create-project / create-roadmap / …Planning scaffolding (see help)

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).

Living architecture map

map-graph builds an interactive, graphify-style knowledge graph of your codebase — not just stats:

  • MAP.json (schemaVersion 5) — 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. 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.

  • 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.

  • MAP.html — an interactive viewer with three tabs:

    • 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.
    • 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.
    • 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.

    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.

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.

Querying the graph (instead of grepping)

The graph-* commands let agents (and you) orient without walking the tree:

draht-tools graph-context src/auth/session.ts   # package · layer · cluster · callers · sinks
draht-tools graph-impact  src/auth/session.ts   # what breaks if I change this
draht-tools graph-query   auth storage          # find the symbol/concept (ranked, no grep)
draht-tools graph-path    a.ts b.ts             # how does A reach B
draht-tools graph-clusters --surprising         # neighborhoods + anomalous edges

Architecture

Self-contained CommonJS, zero runtime dependencies, Node ≥20. Loads only node:fs, node:path, node:child_process, node:http.

版本与发布记录

@draht/tools 共发布 29 个版本,首次发布于 2026/06/11;过去 12 个月发布了 29 个版本。

版本发布日期距今
2026.11.5latest2026/11/067 天前
2026.11.5-12026/11/058 天前
2026.10.312026/11/0112 天前
2026.10.31-12026/10/3113 天前
2026.10.232026/10/2420 天前
2026.10.23-12026/10/2321 天前

关于 @draht/tools 的常见问题

@draht/tools 是什么?

Draht Tools — Get Shit Done CLI (canonical source shared by draht-claude and @draht/coding-agent).

如何安装 @draht/tools?

在项目目录运行 npm install @draht/tools,或使用 pnpm add / yarn add / bun add。它还提供命令行工具 draht-tools,可以用 npx draht-tools 直接运行。

@draht/tools 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/draht__tools 是否存在。

@draht/tools 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

@draht/tools 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js ^22.23.4 || ^24.22.1 || ^26.12.1。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@draht/tools 可以商用吗?

@draht/tools 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@draht/tools 的下载量有多少?

根据 npm 官方下载统计,@draht/tools 在 2026/10/13 – 2026/11/11 这 30 天内被下载 2,607 次,日均约 87 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@draht/tools 还在维护吗?

最新版本 2026.11.5 发布于 2026/11/06(7 天前);至今共发布 29 个版本,其中过去 12 个月发布了 29 个;首次发布于 2026/06/11。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。