stainless-code/codemap
GitHub: stainless-code/codemap
Codemap 为 JS/TS/CSS 代码库构建本地 SQLite 结构化索引,让 AI agents 和开发者通过单次 SQL 查询高效导航代码结构,大幅减少 token 消耗。
Stars: 8 | Forks: 0
# Codemap
**查询你的代码库。** Codemap 构建了一个结构化元数据(符号、imports、exports、组件、依赖项、CSS tokens、标记等)的**本地 SQLite 索引**,以便 **AI agents 和工具** 能够使用 **SQL** 回答“在哪里 / 是什么 / 是谁”的问题,而无需扫描整个文件树。
- 默认情况下**不是** grep 语义 —— 对于原始文本匹配,请使用 `ripgrep` / 你的 IDE。当你需要内容匹配,并希望在单个 SQL 中与 `symbols` / `coverage` / `markers` 进行 JOIN 时,Codemap 提供了可选的 **FTS5**(`--with-fts` / `fts5: true`)。
- 它是一种快速且节省 token 的方式,用于导航**结构**:定义、imports、依赖方向、组件以及其他提取出的事实。
**文档:** [docs/README.md](docs/README.md) 是核心中心(主题索引 + 单一来源规则)。主题:[架构](docs/architecture.md)、[agents](docs/agents.md)(`codemap agents init`)、[基准测试](docs/benchmark.md)、[黄金查询](docs/golden-queries.md)、[打包](docs/packaging.md)、[路线图](docs/roadmap.md)、[为什么选择 Codemap](docs/why-codemap.md)。**内置的规则/技能:** [`.agents/rules/`](.agents/rules/)、[`.agents/skills/codemap/SKILL.md`](.agents/skills/codemap/SKILL.md)。**消费者:** [.github/CONTRIBUTING.md](.github/CONTRIBUTING.md)。
## 你能得到什么
只需**一次 SQL 往返**即可回答结构化问题,而无需进行 3-5 次文件读取:
| 问题 | Grep / Read(目前) | Codemap |
| -------------------------------------------------- | ------------------------------------------------------------ | -------------------------------------------------------------------------------------- |
| 按确切名称查找符号 | Glob + Read + 手动过滤 | `SELECT name, file_path, line_start FROM symbols WHERE name = 'X'` |
| 谁导入了 `~/utils/date`? | Grep + 手动解析 `tsconfig` 别名 | `SELECT DISTINCT from_path FROM dependencies WHERE to_path LIKE '%utils/date%'` |
| 使用了 `useQuery` hook 的组件 | Grep `useQuery` + 过滤到组件文件 | `SELECT name, file_path FROM components WHERE hooks_used LIKE '%useQuery%'` |
| 按 import 扇出计算最重的文件 | 没有解析器是不切实际的 | `SELECT from_path, COUNT(*) AS n FROM dependencies GROUP BY from_path ORDER BY n DESC` |
| 所有 CSS keyframes / design tokens / 模块类 | Grep `@keyframes`, `--var-`, `.module.css` 然后进行消歧 | 对 `css_keyframes` / `css_variables` / `css_classes` 进行一次 `SELECT` |
| 已弃用的符号(`@deprecated` JSDoc) | Grep `@deprecated` + 交叉引用符号 | `SELECT name, kind FROM symbols WHERE doc_comment LIKE '%@deprecated%'` |
完整 schema 和方案目录:[docs/architecture.md § Schema](docs/architecture.md#schema) · [docs/why-codemap.md](docs/why-codemap.md) · `codemap query --recipes-json`。
## 安装
```
bun add @stainless-code/codemap
# or: npm install @stainless-code/codemap
```
**运行环境:** Node **`^20.19.0 || >=22.12.0`** 和/或 Bun **`>=1.0.0`** —— 参见 `package.json` 和 [docs/packaging.md](docs/packaging.md)。
## CLI
- **已安装的包:** `codemap`、`bunx @stainless-code/codemap` 或 `node node_modules/@stainless-code/codemap/dist/index.mjs`
- **本仓库(开发):** `bun src/index.ts`(参数相同)
### 日常命令
```
codemap # incremental index (run once per session)
codemap dead-code --json # outcome alias → query --recipe untested-and-dead
codemap query --json --recipe fan-out # recipe SQL by id (alias: -r)
codemap query --json "SELECT name, file_path FROM symbols WHERE name = 'foo'" # ad-hoc SQL
codemap --files src/a.ts src/b.tsx # targeted re-index after edits
codemap validate --json # detect stale / missing / unindexed / rejected files
codemap context --compact --for "refactor auth" # JSON envelope + intent-matched recipes
codemap ingest-coverage coverage/coverage-final.json --json # Istanbul / LCOV (auto-detected) → coverage table; joins with symbols
NODE_V8_COVERAGE=.cov bun test && codemap ingest-coverage .cov --runtime --json # V8 protocol (per-process dumps); local-only
codemap ingest-churn metrics/churn.json --json # precomputed file_churn → churn-complexity-hotspots (non-git / CI)
codemap query --json --recipe churn-complexity-hotspots # change-frequency × complexity (not the hotspots alias)
codemap agents init # scaffold .agents/ rules + skills
codemap agents init --mcp # PM-aware project MCP config (see docs/agents.md)
codemap apply rename-preview --params old=foo,new=bar --dry-run # preview recipe-driven edits (substrate executor)
```
**版本匹配的 agent 指导:** `codemap agents init` 会向 `.agents/` 写入**轻量级指针文件**(简短的 SKILL + rule)。完整内容由 **`codemap skill`** / **`codemap rule`**(CLI)和 **`codemap://skill`** / **`codemap://rule`**(MCP / HTTP)实时提供 —— 因此 `bun update @stainless-code/codemap` 会自动刷新 agents 看到的内容,无需重新初始化。参见 [docs/agents.md](docs/agents.md)。
### 完整参考
```
# Index project root (optional /config.{ts,js,json}; --state-dir overrides .codemap/)
codemap
# Version (also: codemap --version, codemap -V)
codemap version
# Full rebuild
codemap --full
# SQL against the index (after at least one index run). Bundled agent rules/skills use --json first; omit it for console.table in a terminal.
codemap query --json "SELECT name, file_path FROM symbols LIMIT 10"
# With --json: JSON array on success; {"error":"..."} on stdout for bad SQL, DB open, or query bootstrap (config/resolver)
codemap query "SELECT name, file_path FROM symbols LIMIT 10"
# Query is not row-capped — add LIMIT in SQL for large selects
# Bundled SQL (same as skill examples): fan-out rankings
codemap query --json --recipe fan-out
codemap query --json --recipe fan-out-sample
# Outcome aliases — thin wrappers over `query --recipe `; every query flag passes through.
# Capped at 5 to avoid alias-sprawl.
codemap dead-code --json # → query --recipe untested-and-dead
codemap deprecated --ci # → query --recipe deprecated-symbols --ci
codemap boundaries --format sarif > boundary-findings.sarif # → query --recipe boundary-violations --format sarif
codemap hotspots --json --group-by directory # → query --recipe fan-in (import hubs — not churn×complexity)
codemap coverage-gaps --json --summary # → query --recipe worst-covered-exports --json --summary
# Parametrised recipes validate params from .md frontmatter before SQL binding.
codemap query --json --recipe find-symbol-by-kind --params kind=function,name_pattern=%Query%
codemap query --recipe rename-preview --params old=usePermissions,new=useAccess,kind=function --format diff
# Architecture-boundary rules (declare in .codemap/config.ts):
# boundaries: [{ name: "ui-cant-touch-server", from_glob: "src/ui/**", to_glob: "src/server/**" }]
# Default action is "deny"; the table is reconciled from config on every index pass.
codemap query --recipe boundary-violations --format sarif > boundary-findings.sarif
# Counts only (skip the rows) — pairs well with --recipe for dashboards / agent context windows
codemap query --json --summary -r deprecated-symbols
# PR-scoped: filter result rows to those touching files changed since
codemap query --json --changed-since origin/main -r fan-out
codemap query --json --summary --changed-since HEAD~5 "SELECT file_path FROM symbols"
# Group rows by directory, CODEOWNERS owner, or workspace package
codemap query --json --summary --group-by directory -r fan-in
codemap query --json --group-by owner -r deprecated-symbols
codemap query --json --summary --group-by package "SELECT file_path FROM symbols"
# Snapshot a result, refactor, then diff (saved inside .codemap/index.db, no JSON files)
codemap query --save-baseline -r visibility-tags # save under name "visibility-tags"
codemap query --json --baseline -r visibility-tags # full diff: {baseline, current_row_count, added, removed}
codemap query --json --summary --baseline -r visibility-tags # counts only: {baseline, current_row_count, added: N, removed: N}
codemap query --save-baseline=pre-refactor "SELECT file_path FROM symbols" # ad-hoc SQL needs an explicit =
codemap query --baseline=pre-refactor "SELECT file_path FROM symbols"
codemap query --baselines # list saved baselines
codemap query --drop-baseline visibility-tags # delete
# --group-by is mutually exclusive with --save-baseline / --baseline (different output shapes)
# Diff per-delta baselines vs current — files / dependencies / deprecated drift in one envelope
codemap query --save-baseline=base-files "SELECT path FROM files"
codemap query --save-baseline=base-dependencies "SELECT from_path, to_path FROM dependencies"
codemap query --save-baseline=base-deprecated -r deprecated-symbols
codemap audit --baseline base # auto-resolves base-{files,dependencies,deprecated}
codemap audit --json --summary --baseline base # counts-only — useful for CI dashboards
codemap audit --files-baseline base-files # explicit per-delta — runs only the slots provided
codemap audit --baseline base --files-baseline hotfix-files # mixed — auto-resolve deps + deprecated; override files
codemap audit --baseline base --no-index # skip the auto-incremental-index prelude (frozen-DB CI)
codemap audit --base origin/main --json # ad-hoc — added[].attribution; --summary adds added_introduced/inherited
codemap audit --base origin/main --format sarif # emit SARIF 2.1.0 directly (Code Scanning); also: --ci alias
codemap audit --base origin/main --ci # CI shortcut: --format sarif + non-zero exit on additions
codemap audit --base v1.0.0 --files-baseline pre-release-files # mix --base with per-delta override
# --base materialises via `git archive | tar -x` to .codemap/audit-cache//, reindexes into
# a cached `.codemap/index.db` at that sha, then diffs. Cache hit on second run against same sha is sub-100ms. Requires git;
# non-git projects get a clean `codemap audit: --base requires a git repository.` error.
# Recipes that define per-row action templates append "actions" hints (kebab-case verb +
# description) in --json output; ad-hoc SQL never carries actions. Inspect via --recipes-json.
# --format — SARIF for GitHub
# Code Scanning; annotations for GH Actions ::notice lines; codeclimate for GitLab Code Quality;
# badge for issue-count summaries; mermaid/diff for graph and edit previews. All
# formatted outputs require a flat row list
# (no --summary / --group-by / baseline). SARIF / annotations / codeclimate / badge
# auto-detect file_path / path / to_path / from_path; rule.id is codemap.
# (or codemap.adhoc). codeclimate/badge skip aggregate-only rows. Mermaid
# requires {from, to, label?, kind?} rows and rejects unbounded inputs (>50 edges) with a
# scope-suggestion error — alias columns via SELECT col AS "from", col2 AS "to".
codemap query --recipe deprecated-symbols --format sarif > findings.sarif
codemap query --recipe deprecated-symbols --ci # CI shortcut: --format sarif + non-zero exit + quiet
codemap query --recipe deprecated-symbols --format annotations # one ::notice per row
# GitLab Code Quality artifact (locatable rows only; flat minor severity):
codemap query --recipe boundary-violations --format codeclimate > gl-code-quality-report.json
# Badge summary for README paste or CI (counts locatable rows only):
codemap query --recipe boundary-violations --format badge
codemap query --recipe boundary-violations --format badge --badge-style json | jq -e '.status == "pass"'
# Render any audit/SARIF output as a markdown PR-summary comment (for repos without
# Code Scanning / aggregate audit deltas / bot-context seeding):
codemap audit --base origin/main --json | codemap pr-comment - | gh pr comment -F -
codemap query --format mermaid 'SELECT from_path AS "from", to_path AS "to" FROM dependencies LIMIT 50'
codemap query --format diff 'SELECT "README.md" AS file_path, 1 AS line_start, "# Codemap" AS before_pattern, "# Codemap Preview" AS after_pattern'
codemap query --format diff-json 'SELECT "README.md" AS file_path, 1 AS line_start, "# Codemap" AS before_pattern, "# Codemap Preview" AS after_pattern' | jq '.summary'
# --with-fts — opt-in FTS5 virtual table populated at index time. Default OFF (preserves
# .codemap/index.db size); CLI flag wins over .codemap/config.ts `fts5` field. Toggle change
# auto-detects and forces a full rebuild so `source_fts` stays consistent.
codemap --with-fts --full
codemap query --recipe text-in-deprecated-functions # demonstrates FTS5 ⨯ symbols ⨯ coverage JOIN
# HTTP API — same tool taxonomy as `codemap mcp`, exposed over POST /tool/{name} for
# non-MCP consumers (CI scripts, curl, IDE plugins). Loopback default; --token required on non-loopback.
TOKEN=$(openssl rand -hex 32)
codemap serve --port 7878 --token "$TOKEN" & # --token required when --host is not loopback
curl -s -X POST http://127.0.0.1:7878/tool/query \
-H 'Content-Type: application/json' \
-H "Authorization: Bearer $TOKEN" \
-d '{"sql":"SELECT name, file_path FROM symbols LIMIT 5"}'
# Watch mode — long-running process; debounced reindex on file changes (default 250ms).
# `mcp` / `serve` boot the watcher in-process by default since 2026-05 — every tool
# reads a live index without per-request prelude:
codemap mcp # default-ON watcher
codemap serve --port 7878 # default-ON watcher
codemap watch --quiet # standalone (decoupled from a transport)
codemap mcp --no-watch # opt out for one-shot fire-and-forget calls
CODEMAP_WATCH=0 codemap mcp # env-var opt-out (mirrors --no-watch)
# List recipe catalog (bundled + project-local) as JSON, or print one recipe's SQL (no DB required)
codemap query --recipes-json
codemap query --print-sql fan-out
# `components-by-hooks` ranks by hook count without SQLite JSON1 (comma-based count on the stored JSON array).
# Project-local recipes — drop SQL files into `/recipes/` (default `.codemap/recipes/`) to make them discoverable across the team
# Bundled recipes live in templates/recipes/ in the npm package; project recipes win on id collision
# (shadowing is signalled via a `shadows: true` field in --recipes-json so agents notice the override)
mkdir -p .codemap/recipes # or: codemap --state-dir .cm --full && mkdir -p .cm/recipes
echo "SELECT path FROM files WHERE language IN ('ts', 'tsx') AND line_count > 500" \
> .codemap/recipes/big-ts-files.sql
codemap query --recipe big-ts-files # auto-discovered alongside bundled
# Targeted reads — precise lookup by symbol name without composing SQL
codemap show runQueryCmd # metadata: file:line + signature
codemap show foo --kind function --in src/cli # narrow ambiguous matches
codemap show --query 'kind:function name:Auth path:src/' # field-qualified discovery
codemap show --query 'kind:function name:foo' --print-sql # Moat-A SQL transparency
codemap snippet runQueryCmd # same lookup + source text from disk
codemap snippet --query 'kind:function name:run' --json # field-qualified + source body
codemap snippet foo --json # {matches: [{...metadata, source, stale, missing}]}
# Output envelope is always {matches, disambiguation?, warning?} — single match → {matches: [{...}]};
# multi-match adds disambiguation: {n, by_kind, files, hint} for agent-friendly narrowing;
# warning when FTS was requested but source_fts is empty (re-index with --with-fts or fts5: true).
# Impact analysis — symbol/file blast-radius walker (callers, callees, dependents, dependencies)
codemap impact handleQuery # both directions, depth 3, all compatible graphs
codemap impact dup --in src/a.ts --via calls # homonym symbol scoped to one defining file
codemap impact src/db.ts --direction up # what depends on db.ts (file-level, deps + imports)
codemap impact handleAudit --depth 1 --via calls # direct callers via the calls table only
codemap impact runWatchLoop --json --summary | jq '.summary.nodes' # CI-gate fan-in score
# Replaces hand-composed `WITH RECURSIVE` queries. Cycle-detected, depth-bounded
# (default 3, --depth 0 = unbounded), limit-capped (default 500). Result envelope:
# {target, matches: [...], summary: {nodes, terminated_by}, skipped_scope?}.
# Homonym symbols: unscoped unions per-defining-file graphs; --in scopes one file.
# Affected tests — reverse dependency walk from changed sources → test files to run
codemap affected --json # working-tree changes vs HEAD (git status + diff)
git diff --name-only origin/main | codemap affected --stdin --json
codemap affected src/lib/cache.ts --json # explicit changed paths
codemap affected --changed-since origin/main --json # committed delta + working tree vs ref
# Moat-A twin: `affected-tests` recipe. Output: [{test_path, impact_depth}] — CI composes the runner command.
# Apply — substrate-shaped fix executor (recipe SQL describes hunks; codemap validates + writes)
# Row contract (same as --format diff-json): {file_path, line_start, before_pattern, after_pattern}
# Preview first: codemap query --recipe rename-preview --params old=foo,new=bar --format diff-json
codemap apply rename-preview --params old=usePermissions,new=useAccess,kind=function --dry-run
codemap apply rename-preview --params old=usePermissions,new=useAccess,kind=function --yes # TTY prompts without --yes
# Homonym-safe: add define_in=src/path/to/definition.ts (scopes target; in_file only filters output rows)
# Alias: codemap rename helper worker --define-in src/path/to/definition.ts --dry-run
codemap apply migrate-import-source --params old_source=legacy,new_source=@app/core --dry-run
codemap apply stale-imports --params in_file=src/widget --dry-run # preview; writes need --force --yes
codemap apply migrate-jsx-prop --params old_name=data-id,new_name=data-testid,component_name=ProductCard --dry-run --force
# Agent/codemod rows (no recipe policy gates): echo '[{...}]' | codemap apply --rows - --yes
# External unified diff: codemap apply --diff-input /tmp/patch.diff --dry-run
# Fixpoint (recipe mode): codemap apply rename-preview --params old=a,new=b --until-empty --yes
# Optional git commit (recipe id required): codemap apply rename-preview --params old=a,new=b --yes --commit "chore: rename a→b"
# Bundled diff-shape recipes: rename-preview, migrate-import-source, replace-marker-kind, stale-imports, migrate-deprecated, deprecated-usages, migrate-jsx-prop, add-jsdoc-deprecated
# All-or-nothing: any conflict aborts before any file is written. MCP: apply, apply_rows, apply_diff_input (yes: true for writes).
# Live agent content (pointer protocol — full body served from installed package version)
codemap skill # full codemap SKILL markdown to stdout
codemap rule # full codemap rule markdown to stdout
# MCP server (Model Context Protocol) — for agent hosts (Claude Code, Cursor, Codex, generic MCP clients)
codemap mcp # JSON-RPC on stdio (21 tools; watcher default-ON)
# Tools (21): query, query_batch, query_recipe, audit, save_baseline,
# list_baselines, drop_baseline, context, validate, show, snippet, impact,
# affected, trace, explore, node, apply, apply_rows, apply_diff_input,
# ingest_coverage, ingest_churn
# CLI twins: query batch, trace, explore, node, file, schema, symbols, context --include-snippets, ingest-coverage, ingest-churn (same JSON as MCP/HTTP).
# query / query_recipe also accept baseline (same diff envelope as codemap query --baseline).
# Resources: codemap://schema, codemap://skill, codemap://rule, codemap://mcp-instructions (lazy-cached);
# codemap://recipes, codemap://recipes/{id} (live read-per-call — recency fields stay fresh);
# codemap://files/{path}, codemap://symbols/{name} (live read-per-call)
# Output shape verbatim from `--json` envelopes (no re-mapping). Snake_case throughout.
# Another project
codemap --root /path/to/repo --full
# Explicit config
codemap --config /path/to/config.json --full
# Override the state directory (default `.codemap/`):
codemap --state-dir .cm --full # or: CODEMAP_STATE_DIR=.cm codemap --full
codemap unlock # clear stale /index.lock after a crashed indexer
# Re-index only given paths (relative to project root)
codemap --files src/a.ts src/b.tsx
# Scaffold .agents/ from bundled templates — full matrix: docs/agents.md
codemap agents init
codemap agents init --force
codemap agents init --mcp # PM-aware project MCP config (see docs/agents.md)
codemap agents init --interactive # -i; IDE wiring + symlink vs copy
```
**环境 / 参数:** `--root` 会覆盖 **`CODEMAP_ROOT`** / **`CODEMAP_TEST_BENCH`**,然后是 **`process.cwd()`**;**`--state-dir`** 会覆盖 **`CODEMAP_STATE_DIR`**(默认为 `.codemap/`);**`CODEMAP_WATCH=0`** / **`CODEMAP_NO_WATCH=1`** 可选择退出 `mcp` / `serve` 中默认开启的监视器(与 `--no-watch` 相同);**`CODEMAP_FORCE_WATCH=1`** 会覆盖 WSL `/mnt/*` 的自动禁用。当监视器关闭时,请使用 **`codemap agents init --git-hooks`** 以便在 git 事件中进行后台同步。**`CODEMAP_MCP_TOOLS`** 会注册 MCP 工具的子集(逗号分隔的 snake_case 名称;参见 [agents.md § MCP 工具白名单](docs/agents.md#mcp-tool-allowlist))。**`CODEMAP_PARSE_TIMEOUT_MS`** —— 固定的单文件解析预算(毫秒);未设置时使用 10 秒 + 随文件大小缩放,上限为 30 秒。**`CODEMAP_WORKER_RECYCLE_EVERY`** —— 在处理 N 个文件后回收 worker 线程(默认为 **250**)。**`CODEMAP_PARSE_WORKERS`** —— worker 池大小(正整数,最大 32)。索引此 clone 之外的项目:[docs/benchmark.md § 索引另一个项目](docs/benchmark.md#indexing-another-project)。
**配置:** 可选的 **`/config.{ts,js,json}`**(默认为 `.codemap/config.*`;默认导出对象或异步工厂)。数据结构:[codemap.config.example.json](codemap.config.example.json)。运行时验证(**Zod**,严格键名)和 API 接口:[docs/architecture.md § 用户配置](docs/architecture.md#user-config)。当在此 repo 中进行开发时,你可以使用来自 `@stainless-code/codemap` 或 `./src/config` 的 `defineConfig`。如果你设置了 **`include`**,它将**完全替换**默认的 glob 列表。**自我修复文件 (D11):** `/.gitignore` 会在每次 codemap 启动时重写为规范格式;JSON 配置会修剪未知键名 + 修复键名排序偏移;TS/JS 配置仅进行验证。
## 编程 API (ESM)
```
import { createCodemap } from "@stainless-code/codemap";
const cm = await createCodemap({ root: "/path/to/repo" });
await cm.index({ mode: "incremental" });
await cm.index({ mode: "full" });
await cm.index({ mode: "files", files: ["src/a.ts"] });
await cm.index({ quiet: true });
const rows = cm.query("SELECT name FROM symbols LIMIT 5");
```
`createCodemap` 会配置进程全局运行时(`initCodemap`);每个进程仅支持**一个活动项目**。进阶用法:当你持有 `CodemapDatabase` 句柄时,可以使用 `runCodemapIndex`(库集成 —— 没有单独的公共 `openDb()` 导出;支持的使用路径请用 `createCodemap`)。**模块布局:** [docs/architecture.md § 分层](docs/architecture.md#layering)。
## 开发
工具:**Oxfmt**、**Oxlint**、**tsgo**(`@typescript/native-preview`)。
| 命令 | 用途 |
| ------------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `bun run dev` | 从源码运行 CLI(等同于 `bun src/index.ts`) |
| `bun run check` | 构建、格式化检查、lint、测试、类型检查、黄金查询 + agent-eval 测试集冒烟测试 —— 推送前运行 |
| `bun run fix` | 应用 lint 修复,然后格式化 |
| `bun run test` / `bun run typecheck` | 针对性检查 |
| `bun run test:golden` | 针对 `fixtures/minimal` 进行 SQL 快照回归测试(包含在 `check` 中) |
| `bun run test:agent-eval` | 针对 `fixtures/minimal` 进行 agent-eval 测试集冒烟测试 —— 探针 + 实时 MCP 处理程序(包含在 `check` 中;[docs/benchmark.md § Agent eval 测试集](docs/benchmark.md#agent-eval-harness)) |
| `bun run test:golden:external` | B 级:通过 `CODEMAP_*` / `--root` 指定本地树(不包含在默认的 `check` 中) |
| `bun run benchmark:query` | 比较 `console.table` 与 `--json` stdout 大小(需要本地 `.codemap/index.db`;[docs/benchmark.md § 查询 stdout](docs/benchmark.md#query-stdout-table-vs-json-benchmarkquery)) |
| `bun run qa:external` | 在 `CODEMAP_ROOT` / `CODEMAP_TEST_BENCH` 上进行索引 + 完整性检查 + 基准测试 |
```
bun install
bun run check # build + format:check + lint:ci + test + typecheck + test:golden + test:agent-eval
bun run fix # oxlint --fix, then oxfmt
```
**可读性与 DX:** 偏好清晰的命名和简短的函数;在公共导出上保留 **JSDoc**。[.github/CONTRIBUTING.md](.github/CONTRIBUTING.md) 包含了贡献者工作流程和约定。
## 基准测试
使用**真实**的项目路径(该 repo 必须存在于磁盘上)。参见 [docs/benchmark.md § 索引另一个项目](docs/benchmark.md#indexing-another-project)。
```
CODEMAP_ROOT=/absolute/path/to/indexed-repo bun src/benchmark.ts
```
可选的 **`CODEMAP_BENCHMARK_CONFIG`** 用于针对特定 repo 的场景:[docs/benchmark.md § 自定义场景](docs/benchmark.md#custom-scenarios-codemap_benchmark_config)。
要在现有索引上比较**查询**的 stdout 大小(`console.table` 与 **`--json`**),请参见 [docs/benchmark.md § 查询 stdout](docs/benchmark.md#query-stdout-table-vs-json-benchmarkquery)(**`bun run benchmark:query`**)。
## 组织
在 GitHub 上的 **[stainless-code](https://github.com/stainless-code)** 下开发。
## 许可证
MIT —— 参见 [LICENSE](LICENSE)。
标签:AI编程助手, MITM代理, SOC Prime, SQLite, 云安全监控, 代码索引, 开发工具, 自动化攻击, 静态分析