Skip to content

Commit ebd4c34

Browse files
feat(cli): codemap validate / context / --performance, four new query recipes, friendlier no-DB error (#23)
* chore(deps): bump runtime and dev dependencies Routine bumps caught by lockfile drift; no functional changes. * docs: anti-pitch, scenario-keyed token table, capability table, daily commands - why-codemap.md: add "What Codemap is not" section (anti-pitch — preempts "is this an LSP / agent / smart tool?" reading); replace narrative token-savings text with scenario-keyed rows (single lookup → 50-turn session) backed by a methodology footnote pointing at bun run benchmark:query - README.md: add "What you get" Grep/Read vs Codemap capability table near the top; add a "Daily commands" stripe and a "version-matched Agent Skill" packaging line in the CLI section - docs/research/competitive-scan-2026-04.md: capture the audit of fallow, AZidan/codemap, and JordanCoin/codemap that drove the messaging changes - .agents/lessons.md: add bump-policy lesson (patch by default for 0.x; reserve minor for schema-breaking changes; strict SemVer post-1.0) * chore(lint): tighten oxlint baseline; ignore fixtures Add the import plugin and 11 stricter rules: prefer-const, type-import hoisting (consistent-type-specifier-style: prefer-top-level), interface preference for object types, no-confusing-non-null-assertion, no-unnecessary-{boolean-literal-compare,template-expression,type-assertion}, prefer-{includes,nullish-coalescing,optional-chain}, and unicorn/switch-case-braces. Add fixtures/ to ignorePatterns so hand-crafted parser test corpora are never auto-mutated (prevents golden churn — discovered when an auto-fix on fixtures/minimal/src/consumer.ts split a mixed import and broke the imports-consumer-alias / files-hashes / index-summary scenarios). Source-side auto-fixes from these rules ship with the feature commits that follow. * feat(query): four new recipes, -r short alias, cleaner --help Recipes (all parameterless SQL on the existing schema): - deprecated-symbols — symbols whose JSDoc contains @deprecated; lets agents flag callers of soon-to-be-removed APIs - visibility-tags — symbols tagged @internal / @Private / @Alpha / @beta - files-hashes — every indexed file with content_hash; powers the forthcoming `codemap validate` CLI - barrel-files — top files by export count (public-API hubs) CLI: - -r is now a short alias for --recipe (e.g. `codemap query -r fan-out`) - --help is reorganized: sectioned flags, dynamic recipe-id padding, examples for both --recipe and -r forms Fixtures: - @deprecated and @internal JSDoc added to fixtures/minimal/src/utils/date.ts to give the new recipes real rows to assert on - 4 new golden scenarios + index-summary refresh (symbols 8 → 9) * feat(cli): codemap validate, codemap context, --performance, friendlier no-DB error; JSDoc the public type surface CLI commands and flags - codemap validate [--json] [paths...] — diffs disk SHA-256 against files.content_hash; statuses: stale | missing | unindexed; exits 1 on any drift (git-status semantics) so agents can branch on $? - codemap context [--compact] [--for "<intent>"] — stable JSON envelope (project metadata, top hubs, recent markers, recipe catalog). --for runs lightweight intent classification (refactor / debug / test / feature / explore / other) and returns matched recipe ids plus a hint - codemap --performance — per-phase breakdown (collect / parse / insert / index_create) plus top-10 slowest files by parse time during full rebuild; surfaces pathological inputs - Friendlier no-.codemap.db error — `no such table: <X>` rewrites to an actionable hint pointing at `codemap` / `codemap --full`, on both the JSON and human paths - bootstrap.ts whitelists the new subcommands and flag Public type surface (visible in dist/index.d.mts via the existing index re-exports) - New IndexPerformanceReport; IndexRunStats.performance? field - Per-field JSDoc on IndexResult, IndexRunStats, IndexPerformanceReport, IndexTableStats (snake_case key note), ResolvedCodemapConfig - Interface-level JSDoc on every db.ts row interface (FileRow, SymbolRow, ImportRow, ExportRow, ComponentRow, DependencyRow, MarkerRow, CssVariableRow, CssClassRow, CssKeyframeRow, CallRow, TypeMemberRow) with cross-links to docs/architecture.md § Schema as the single source - Per-field JSDoc on ParsedFile (clarifies error vs parseError, category semantics, CSS-only fields, cssImportSources main-thread conversion) - @param/@returns on getAdapterForExtension Implementation plumbing - ParsedFile gains optional parseMs?, populated by parse-worker-core.ts - RunIndexOptions.performance threads through index-engine.ts and run-index.ts - index-engine.ts times collect / parse / insert / createIndexes phases when the flag is on; bottom-of-summary block prints the breakdown plus the slowest_files list Auto-fixes from the new lint baseline - import type hoisting (consistent-type-specifier-style: prefer-top-level) - type X = {...} → interface X {...} for object shapes (ValidateRow, ValidateOpts, ContextEnvelope, ContextOpts) - switch case braces in src/parser.ts (12 keyword-mapping cases) and src/agents-init.ts Tests - 9 new tests for cmd-validate (parse + computeValidateRows: stale, missing, unindexed, dedup, sort) - 14 new tests for cmd-context (parse + classifyIntent: 6 categories + fallback) - 2 new cases on cmd-query for -r Changeset entered as patch (matches 0.x precedent for additive changes; schema unchanged). * fix(cli): address PR #23 review — recent_markers misnomer, validate TOCTOU, --compact, --for guard, README Adopts the 7 valid items from CodeRabbit review. A1 — `recent_markers` was alphabetical-first-20, not recency-ordered (the markers table has no timestamp column). Rename to `sample_markers` with a JSDoc note pointing at the proper time-ordered query (join `files.last_modified`). A2 — `cmd-validate.ts` had a TOCTOU between existsSync and readFileSync. Replace with a single guarded read; also drops one syscall in the common path (open instead of stat + open). N2 — Rename `performance` local in cmd-index.ts to `reportPerformance` to avoid shadowing the global `performance` API. N4 — Route the `files-hashes` golden through the bundled recipe (was inline SQL); now exercises the recipe SQL itself and prevents drift. Snapshot refreshed. N5 — Add `validate` and `context` to the README "Daily commands" stripe; they were the headline additions in this PR but weren't on the showcase. N7 — `--for ""` was accepted as a valid intent and silently classified as "other". Reject empty-string values with the same error as missing. N8 — `--compact` now actually compacts: `JSON.stringify` is called without indent in compact mode (was unconditional 2-space pretty-print). Tests: +1 case for `--for ""` rejection. 19/19 goldens green, 24/24 cmd-context + cmd-validate tests pass. * feat(db): tighten NOT NULL on every Row-interface non-nullable column; bump SCHEMA_VERSION 2 → 3 Closes review item N1: until now FileRow declared `size`, `line_count`, `language`, `last_modified`, `indexed_at` as non-nullable in TypeScript, but the SQLite schema only required `path` and `content_hash` to be NOT NULL — so a row read back via `query<FileRow>(...)` could legally surface null for any of those columns. The same gap applied to 8 other tables (symbols, imports, exports, components, markers, css_variables, css_classes, css_keyframes, type_members). This commit aligns the SQL invariants with the existing TypeScript types: add NOT NULL to every column whose Row-interface type is non-nullable. The DEFAULT 0 columns gain NOT NULL too so the constraint is enforced even when the writer omits the column. `calls` and `dependencies` were already fully constrained — no change. `SCHEMA_VERSION` bumps 2 → 3. The existing `createSchema()` version- mismatch detector picks up the bump on first open and triggers a full rebuild — verified locally (meta.schema_version = "3" after one run). Changeset bumped to minor per .agents/lessons.md (schema-breaking changes that force a .codemap.db rebuild are minor, even pre-1.0). * docs: tighten JSDoc comments on public types Concise rewrite of the JSDocs added in the previous commits. Keeps the non-obvious facts (FK cascade, JSON-encoded fields, recipe pointers, related-table cross-references, total_ms vs collect_ms gotcha, snake_case key convention on IndexTableStats) and drops the boilerplate: - 12 row interfaces in db.ts: collapse the per-table architecture.md links (single source already lives in docs/architecture.md § Schema). Keep the high-signal hints (FK behavior on FileRow, JSDoc-tag recipes on SymbolRow, dependencies cross-link on ImportRow, JSON shape on ComponentRow.hooks_used, scope semantics on CssVariableRow, is_module/`.module.css` rule on CssClassRow, dedup keying on CallRow, null type semantics on TypeMemberRow). - ParsedFile: drop redundant per-field one-liners that just restated the field name; keep error/parseError distinction, category meaning, CSS-only grouping, cssImportSources main-thread conversion. - SCHEMA_VERSION: drop the v3-specific @remarks paragraph (that belongs in the changelog/changeset, not in code that lives forever). - ResolvedCodemapConfig: tighten interface doc; per-field one-liners unchanged. - getAdapterForExtension: collapse multi-paragraph JSDoc to one sentence retaining the leading-dot rule and the markers-only fallback. application/types.ts left as-is — already balanced, and the verbose parts there encode invariants worth keeping (snake_case keys, total_ms != wall_time). * fix(cli): trim --for whitespace, normalize POSIX separators in validate Two follow-ups from PR #23 review: C1 — `cmd-context.ts:98-109` — `--for " "` (whitespace-only) was slipping past the `v === ""` guard added in 0fafbff and silently being classified as "other" with `intent.input = " "`. Reject anything that trims to empty, and store the trimmed value so leading/trailing spaces in quoted intents don't leak into the envelope. +2 tests (whitespace-only rejection, trim-around-content). C2 — `cmd-validate.ts:142-145` — Cross-platform bug. The `files.path` column always stores POSIX paths (tinyglobby and Bun.Glob normalize on Windows; git diff emits POSIX universally), but `path.relative()` on Windows returns backslash-separated paths. So `codemap validate C:\proj\src\foo.ts` would build a `src\foo.ts` lookup key that fails to match `src/foo.ts` in the index, falsely reporting a tracked file as `unindexed`. Mirror the same `replace(/\\/g, "/")` normalization already in `lint-staged.config.js:12,21`. No new test — the helper is private and the `sep === "/"` short-circuit makes it a no-op on macOS / Linux. * docs: migrate competitive scan into roadmap, why-codemap, and the docs index Following docs/README.md conventions ("one topic per file", no flag duplication, single-source-of-truth): roadmap.md - Drop `--performance` from backlog (shipped in PR #23). - Add 4 backlog entries that the scan flagged as still open: MCP server, HTTP API (`codemap serve`), recipes-as-content registry + project-local recipes, targeted-read CLI (`codemap show <symbol>`), cross-agent handoff artifact (speculative). - Expand "Non-goals (v1)" with the explicit list inherited from the scan's PASS table — static analysis (fallow's class), visualization (skyline), daemon, deep intent classification beyond `codemap context`. Roadmap is now the canonical home for these. why-codemap.md - Add "Codemap vs alternatives" comparison (Codemap / fallow / Aider RepoMap / LSP) — durable positioning material from the scan's side-by-side. Frames the four tools as solving different problems rather than competing for one slot. docs/research/competitive-scan-2026-04.md - Slim from 210 lines (full ranked adopt/watch/pass list, messaging lessons, next steps) to 87 lines of durable narrative: dated context, sources, positioning recap, raw side-by-side, "what shipped" appendix linking to canonical homes, "what moved to roadmap" pointer, two open questions still open, citations. - Replaces sections that are now duplicates of canonical docs. docs/README.md - Add a `research/` row to the topic index pointing at the new folder convention (dated snapshot notes that link back to canonical homes). - Add "Non-goals (v1)" row to the Single Source of Truth table — roadmap.md is canonical, why-codemap.md carries the consumer-facing framing, research/ notes link here and never re-list. * docs(governance): adopt rules + lifecycle from PaySpace analytics docs; add glossary, plans/ folder, and an enforcement rule Lifts the high-signal subset of the analytics docs governance pattern: - Rules for Agents (numbered, normative — cite by number in PR review) - Document Lifecycle (4 doc types: Reference / Roadmap / Plan / Research) - Existence test for whether a doc earns its place - Top-level cap rule - Closing rules for research notes (codifies what we did manually for competitive-scan-2026-04.md) docs/README.md - Restructure into File Ownership → Rules for Agents → Single Source of Truth → Document Lifecycle → Naming Conventions → Conventions. - Move existing "Conventions" prose to the bottom as a stylistic addendum to the rules above. - Add 9 numbered rules (one source of truth, ship-flow, plans, table freshness, relative paths, no inventory counts, no line-numbers, research closing, glossary updates). - Add Document Lifecycle section with 4 doc types, the existence test, closing-research rules, and the top-level cap. - Add `glossary.md`, `plans/`, `research/` rows to File Ownership. - Add "Domain term definitions" + "Non-goals" rows to Single Source of Truth (canonical = glossary.md / roadmap.md, others link). docs/glossary.md (new) - ~70 entries covering schema/parser/recipe/agent terminology. - Disambiguates pairs that look similar: FileRow vs `files` table, recipe vs query, schema vs DDL, hub vs barrel-file, fan-in vs fan-out, parser vs adapter, plan vs research, rule vs skill. - Links recipe + table entries back to architecture.md schema sections for deep details (Rule 1 — one source of truth). docs/plans/.gitkeep (new) - Empty folder so the convention is in place for the first plan that lands. Don't add the `-plan` suffix per the naming convention. .agents/rules/docs-governance.md + .cursor/rules/docs-governance.mdc (new) - alwaysApply rule pointing at docs/README.md as canonical source. - Carries the 9-rule quick checklist + the existence test + top-level cap so agents see them at session start without reading the full docs/README.md every time. - Symlinked into .cursor/rules/ per the agents-first-convention rule. No source code touched; 185/185 tests still pass; goldens all green. * docs: dogfood the new docs/README.md governance Audited every doc against the 9 numbered rules in the new docs/README.md. Three violations found and fixed; the rest pass. Rule 2 — When a backlog item ships, document it in its canonical home - architecture.md § CLI usage gains four new implementation-note paragraphs: * Validate wiring (cmd-validate.ts, computeValidateRows pure function, POSIX path normalization, exit-1 git-status semantics). * Context wiring (buildContextEnvelope composing existing recipes, classifyIntent regex routing, --compact behavior). * Performance wiring (RunIndexOptions.performance, parseMs on ParsedFile, IndexPerformanceReport assembly, total_ms gotcha). * Friendlier no-DB error rewriting in enrichQueryError + the new -r alias on --recipe (folded into existing Query wiring paragraph). Rule 4 — Keep ownership tables current - Key Files `cli/` row updated to mention `validate` / `context` modes alongside `query` / `agents init` / index modes. Rule 6 — No inventory counts in narrative - golden-queries.md said "15 scenarios" — now 19 after this PR's additions. Replaced with a qualitative descriptor + a `codemap query` example so the doc never goes stale on count again. Rules 1, 3, 5, 7, 8, 9 all pass — no duplicated prose, no unintended plans, no absolute paths to in-tree files, no line-number references (except Rule 7's own example), competitive scan already closed, every new term from this PR is in glossary.md.
1 parent 56bb673 commit ebd4c34

49 files changed

Lines changed: 2261 additions & 301 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.agents/lessons.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,5 @@ Persistent log of corrections and insights from past sessions. Agents **must** c
77
Each entry is a single bullet: `- **<topic>** — <lesson>`. Newest entries at the bottom.
88

99
## Lessons
10+
11+
- **changesets bump policy (pre-v1)** — while in `0.x`, default to **patch** for everything (additive features, fixes, docs, internal refactors); reserve **minor** for schema-breaking changes that force a `.codemap.db` rebuild (matches 0.2.0 precedent: new tables/columns/`SCHEMA_VERSION` bump). Strict SemVer kicks in only after `1.0.0`. Don't propose `minor` just because new CLI commands or public types were added.

.agents/rules/docs-governance.md

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
---
2+
description: Always follow the docs governance in docs/README.md when touching files under docs/. Specifically: cite Rules by number, update File Ownership and Single Source of Truth tables when adding/removing docs, fold new content into existing files unless it passes the Existence Test.
3+
alwaysApply: true
4+
---
5+
6+
# Docs Governance
7+
8+
`docs/README.md` is the source of truth for how the docs folder is organized and edited. Read it first whenever you touch anything under `docs/`.
9+
10+
## Quick checklist
11+
12+
When you change a doc, these checks must pass before the PR ships:
13+
14+
- **Rule 1 — One source of truth.** No prose duplicated across files. Cross-reference by relative path instead.
15+
- **Rule 2 — Shipped items leave the roadmap.** When a backlog item lands, move its description to its canonical home (architecture / why-codemap / README) and remove it from `roadmap.md`.
16+
- **Rule 3 — Plans get their own file.** Don't embed plans in `roadmap.md`. Create `docs/plans/<feature-name>.md` and link from the roadmap entry.
17+
- **Rule 4 — Tables stay current.** When you add or delete a doc, update the **File Ownership** and **Single Source of Truth** tables in `docs/README.md` in the same PR.
18+
- **Rule 5 — Relative cross-references.** `[architecture.md § Section](./architecture.md#section)` — never absolute paths or repo URLs for in-tree docs.
19+
- **Rule 6 — No inventory counts in narrative.** Don't hardcode counts of files / symbols / recipes. Use qualitative descriptors or a `codemap query` example. Decision values (cache TTLs, `SCHEMA_VERSION`) are fine.
20+
- **Rule 7 — No line-number references.** Cite by function name, section heading, or `codemap query` lookup. Methodology tables in `benchmark.md` are exempt.
21+
- **Rule 8 — Close research notes.** When a `research/` scan's adopt items ship, slim it to a "What shipped" appendix linking to canonical homes. Rejected items keep a `Status: Rejected (date) — <reason>` header.
22+
- **Rule 9 — New term ⇒ glossary.** Every PR that introduces a new domain noun (table name, recipe id, parser name, schema column) updates `docs/glossary.md` in the same PR. Disambiguations (e.g. `FileRow` TS shape vs `files` SQLite table) take priority.
23+
24+
## Document Lifecycle (full text in `docs/README.md`)
25+
26+
Four doc types: **Reference** (lives forever), **Roadmap** (single file, items move in/out), **Plan** (created on commit, deleted on ship), **Research** (created for evaluations, closed per § Closing research).
27+
28+
Backlogs / frameworks / decisions don't get their own file — they fold into one of the four.
29+
30+
### Existence test (apply on every doc-touching PR)
31+
32+
A file earns its place if it meets at least one of:
33+
34+
1. Source code or another doc cites it (grep finds the path).
35+
2. It documents durable policy or framework unavailable elsewhere.
36+
3. It tracks open work.
37+
4. It carries unique historical context that `git log` + `architecture.md` cannot reconstruct.
38+
39+
If none → fold any salvageable content into roadmap / architecture / glossary, fix cross-refs, **delete the file**.
40+
41+
### Top-level cap
42+
43+
Adding a new top-level doc requires:
44+
45+
1. The topic doesn't fit any existing root-level doc.
46+
2. The new file passes the existence test on day one.
47+
3. **File Ownership** table in `docs/README.md` updated in the same PR.
48+
49+
When in doubt, default to absorbing into the closest existing root-level file.
50+
51+
## Why this exists
52+
53+
- Avoids the slow rot that hits any docs folder where any contributor (human or agent) can drop a new top-level file at any time.
54+
- Gives reviewers cite-able rule numbers ("violates Rule 4") instead of vague "this should go elsewhere" feedback.
55+
- Keeps `git log` legible by making doc files have predictable lifecycles.
56+
57+
## Reference
58+
59+
- [`docs/README.md`](../../docs/README.md) — full text of all rules, the lifecycle, and the existence test.
60+
- Adapted from PaySpace `analytics/docs/README.md` governance pattern.
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
---
2+
"@stainless-code/codemap": minor
3+
---
4+
5+
Agent-friendly CLI surface plus a schema v3 bump that tightens `NOT NULL` invariants. Existing `.codemap.db` files auto-rebuild on first open.
6+
7+
- **New: `codemap validate [--json] [paths...]`** — diffs the on-disk SHA-256 of indexed files against `files.content_hash` and prints stale / missing / unindexed rows. Lets agents skip re-reads they don't need; exits `1` on any drift (git-status semantics)
8+
- **New: `codemap context [--compact] [--for "<intent>"]`** — emits a stable JSON envelope (project metadata, top hubs, recent markers, recipe catalog) for any agent or editor that wants the index in one cheap shot. `--for` runs lightweight intent classification (refactor / debug / test / feature / explore / other) and returns matched recipe ids plus a hint
9+
- **New: `codemap --performance`** flag — prints a per-phase timing breakdown (collect / parse / insert / index_create) and the top-10 slowest files by parse time during full rebuilds, for triaging giant or pathological inputs
10+
- **New: `-r` short alias for `codemap query --recipe`** + cleaner organized `codemap query --help` (sectioned flags, dynamic recipe-id padding, examples for both forms)
11+
- **New recipes**: `deprecated-symbols` (`@deprecated` JSDoc tag scan), `visibility-tags` (`@internal` / `@private` / `@alpha` / `@beta`), `files-hashes` (powers `validate`), `barrel-files` (top files by export count)
12+
- **Friendlier no-`.codemap.db` error**: `no such table: <X>` now rewrites to an actionable hint pointing at `codemap` / `codemap --full`, on both the JSON and human paths
13+
- **Public type surface**: new `IndexPerformanceReport`; `IndexRunStats.performance?` field; per-field JSDoc coverage on `IndexResult`, `IndexRunStats`, `ResolvedCodemapConfig`, all `db.ts` row interfaces (`FileRow`, `SymbolRow`, `ImportRow`, `ExportRow`, `ComponentRow`, `DependencyRow`, `MarkerRow`, `CssVariableRow`, `CssClassRow`, `CssKeyframeRow`, `CallRow`, `TypeMemberRow`), and `ParsedFile`
14+
- **Documentation**: README now leads with a "What you get" Grep/Read vs Codemap capability table and a "Daily commands" stripe; `docs/why-codemap.md` adds a "What Codemap is **not**" anti-pitch section and a scenario-keyed token-savings table (single lookup → 50-turn session) replacing the earlier hand-wave
15+
- **Stricter lint baseline**: enabled `prefer-const`, `consistent-type-specifier-style`, `consistent-type-definitions`, `no-confusing-non-null-assertion`, `no-unnecessary-{boolean-literal-compare,template-expression,type-assertion}`, `prefer-{includes,nullish-coalescing,optional-chain}`, and `unicorn/switch-case-braces`
16+
- **Schema v3 — tighter `NOT NULL` invariants**: every column whose `Row`-interface type was non-nullable is now `NOT NULL` in the SQLite DDL (`files.size`/`line_count`/`language`/`last_modified`/`indexed_at`, `symbols.line_start`/`line_end`/`signature`/`is_exported`/`is_default_export`, `imports.specifiers`/`is_type_only`/`line_number`, `exports.kind`/`is_default`, `components.hooks_used`/`is_default_export`, `markers.line_number`/`content`, `css_variables.scope`/`line_number`, `css_classes.is_module`/`line_number`, `css_keyframes.line_number`, `type_members.is_optional`/`is_readonly`). Existing v2 databases auto-rebuild via `createSchema()`'s version-mismatch detector — no manual action needed

.cursor/rules/docs-governance.mdc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../.agents/rules/docs-governance.md

.oxlintrc.json

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,25 @@
11
{
22
"$schema": "./node_modules/oxlint/configuration_schema.json",
3-
"ignorePatterns": [".output", "node_modules", "dist", "coverage", "bun.lock"],
4-
"plugins": ["eslint", "typescript", "unicorn", "oxc"]
3+
"ignorePatterns": [
4+
".output",
5+
"bun.lock",
6+
"coverage",
7+
"dist",
8+
"fixtures",
9+
"node_modules"
10+
],
11+
"plugins": ["eslint", "typescript", "unicorn", "oxc", "import"],
12+
"rules": {
13+
"eslint/prefer-const": "error",
14+
"import/consistent-type-specifier-style": ["error", "prefer-top-level"],
15+
"typescript/consistent-type-definitions": ["error", "interface"],
16+
"typescript/no-confusing-non-null-assertion": "error",
17+
"typescript/no-unnecessary-boolean-literal-compare": "error",
18+
"typescript/no-unnecessary-template-expression": "error",
19+
"typescript/no-unnecessary-type-assertion": "error",
20+
"typescript/prefer-includes": "error",
21+
"typescript/prefer-nullish-coalescing": "error",
22+
"typescript/prefer-optional-chain": "error",
23+
"unicorn/switch-case-braces": "error"
24+
}
525
}

README.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,23 @@
99

1010
---
1111

12+
## What you get
13+
14+
Structural questions answered in **one SQL round-trip** instead of 3–5 file reads:
15+
16+
| Question | Grep / Read (today) | Codemap |
17+
| -------------------------------------------------- | ------------------------------------------------------------ | -------------------------------------------------------------------------------------- |
18+
| Find a symbol by exact name | Glob + Read + filter by hand | `SELECT name, file_path, line_start FROM symbols WHERE name = 'X'` |
19+
| Who imports `~/utils/date`? | Grep + resolve `tsconfig` aliases manually | `SELECT DISTINCT from_path FROM dependencies WHERE to_path LIKE '%utils/date%'` |
20+
| Components using the `useQuery` hook | Grep `useQuery` + filter to component files | `SELECT name, file_path FROM components WHERE hooks_used LIKE '%useQuery%'` |
21+
| Heaviest files by import fan-out | Impractical without a parser | `SELECT from_path, COUNT(*) AS n FROM dependencies GROUP BY from_path ORDER BY n DESC` |
22+
| All CSS keyframes / design tokens / module classes | Grep `@keyframes`, `--var-`, `.module.css` then disambiguate | One `SELECT` against `css_keyframes` / `css_variables` / `css_classes` |
23+
| Deprecated symbols (`@deprecated` JSDoc) | Grep `@deprecated` + cross-reference symbol | `SELECT name, kind FROM symbols WHERE doc_comment LIKE '%@deprecated%'` |
24+
25+
Full schema and recipe catalog: [docs/architecture.md § Schema](docs/architecture.md#schema) · [docs/why-codemap.md](docs/why-codemap.md) · `codemap query --recipes-json`.
26+
27+
---
28+
1229
## Install
1330

1431
```bash
@@ -25,6 +42,22 @@ bun add @stainless-code/codemap
2542
- **Installed package:** `codemap`, `bunx @stainless-code/codemap`, or `node node_modules/@stainless-code/codemap/dist/index.mjs`
2643
- **This repo (dev):** `bun src/index.ts` (same flags)
2744

45+
### Daily commands
46+
47+
```bash
48+
codemap # incremental index (run once per session)
49+
codemap query --json --recipe fan-out # bundled SQL via recipe id (alias: -r)
50+
codemap query --json "SELECT name, file_path FROM symbols WHERE name = 'foo'" # ad-hoc SQL
51+
codemap --files src/a.ts src/b.tsx # targeted re-index after edits
52+
codemap validate --json # detect stale / missing / unindexed files
53+
codemap context --compact --for "refactor auth" # JSON envelope + intent-matched recipes
54+
codemap agents init # scaffold .agents/ rules + skills
55+
```
56+
57+
**Version-matched agent guidance:** the published npm package ships **`templates/agents/`** (rules + skills) keyed to that version, so `codemap agents init` writes guidance that matches the CLI you installed. See [docs/agents.md](docs/agents.md).
58+
59+
### Full reference
60+
2861
```bash
2962
# Index project root (optional codemap.config.ts / codemap.config.json)
3063
codemap

0 commit comments

Comments
 (0)