Skip to content

Commit 4943f36

Browse files
committed
feat: language adapters, benchmark fixture, agents init; trim roadmap
- LanguageAdapter + builtin registry; ParsedFile in parsed-types; parse-worker dispatch - fixtures/minimal + CI benchmark job; docs/benchmark + packaging - codemap agents init + templates/agents (npm files); tests - docs/ROADMAP: forward-looking only; docs/README table blurb
1 parent 40f178a commit 4943f36

32 files changed

Lines changed: 894 additions & 110 deletions

.github/CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ Releases: **[@changesets/cli](https://github.com/changesets/changesets)** — ru
3535

3636
## Agent rules and skills (`.agents/`)
3737

38-
**Upstream** skill and rules in this repo (e.g. `codemap`) stay **generic** — placeholder SQL and triggers, no product-specific paths. Consumer projects should **copy or symlink**, then **edit their copy** for team aliases and queries. A future `codemap` CLI may scaffold these files; customization always belongs in the **consumer** repo.
38+
**Upstream** skill and rules in this repo (e.g. `codemap`) stay **generic** — placeholder SQL and triggers, no product-specific paths. Consumer projects can run **`codemap agents init`** (ships **`templates/agents`** on npm) or **copy/symlink** manually, then **edit their copy** for team aliases and queries. Customization always belongs in the **consumer** repo.
3939

4040
Rules live under **`.agents/rules/`**; skills under **`.agents/skills/<name>/SKILL.md`**. Symlink each into **`.cursor/`** (see [agents-first-convention.mdc](../.agents/rules/agents-first-convention.mdc)):
4141

.github/workflows/ci.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,3 +78,19 @@ jobs:
7878
# Bun is already used for build/tests above.
7979
- name: Node smoke (dist + better-sqlite3)
8080
run: node dist/index.mjs query "SELECT 1 as ok"
81+
82+
benchmark:
83+
name: 📊 Benchmark (fixture)
84+
runs-on: ubuntu-latest
85+
steps:
86+
- name: Checkout
87+
uses: actions/checkout@v4
88+
89+
- name: Setup
90+
uses: ./.github/actions/setup
91+
92+
- name: Index fixture and run benchmark
93+
run: |
94+
export CODEMAP_ROOT="$GITHUB_WORKSPACE/fixtures/minimal"
95+
bun run dev --full
96+
bun run benchmark

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,10 @@ codemap --config /path/to/codemap.config.json --full
4747

4848
# Re-index only given paths (relative to project root)
4949
codemap --files src/a.ts src/b.tsx
50+
51+
# Scaffold .agents/ rules and skills from bundled templates (see CONTRIBUTING)
52+
codemap agents init
53+
codemap agents init --force
5054
```
5155

5256
**Environment / flags:** `--root` overrides **`CODEMAP_ROOT`** / **`CODEMAP_TEST_BENCH`**, then **`process.cwd()`**. Using a separate app as a QA target: [docs/bench-repo.md](docs/bench-repo.md).

docs/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ Technical docs for **[@stainless-code/codemap](https://github.com/stainless-code
66
| -------------------------------------- | --------------------------------------------------------------------------------------- |
77
| [architecture.md](./architecture.md) | Schema, layering, CLI, programmatic API, parsers |
88
| [bench-repo.md](./bench-repo.md) | `CODEMAP_TEST_BENCH` / `.env` QA workflow |
9-
| [benchmark.md](./benchmark.md) | Benchmark script; fixtures (planned) |
9+
| [benchmark.md](./benchmark.md) | Benchmark script; [`fixtures/minimal/`](../fixtures/minimal/) |
1010
| [bun-reference.md](./bun-reference.md) | Upstream **`bun:sqlite`** doc links |
1111
| [extraction.md](./extraction.md) | Extraction history → layout in [architecture § Key Files](./architecture.md#key-files) |
1212
| [packaging.md](./packaging.md) | `dist/`, npm entry, Node vs Bun, [Changesets](https://github.com/changesets/changesets) |
13-
| [roadmap.md](./roadmap.md) | Planned work / backlog (not a `src/` inventory) |
13+
| [roadmap.md](./roadmap.md) | Forward-looking backlog (not a `src/` inventory) |
1414
| [why-codemap.md](./why-codemap.md) | Why index + SQL for agents |
1515

1616
**Conventions:** one topic per file; link with relative paths; no hardcoded symbol/file counts (use `codemap query` / `bun run dev query`); no source line numbers. **Contributors:** keep public API JSDoc useful; run `bun run check` — see [CONTRIBUTING](../.github/CONTRIBUTING.md).

docs/architecture.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ A local SQLite database (`.codemap.db`) indexes the project tree and stores stru
1212

1313
| Layer | Role |
1414
| -------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------- |
15-
| **`cli.ts`** | Parses argv (`--root`, `--config`, `query`, `--files`, `--full`), wires bootstrap → `runCodemapIndex` / `printQueryResult`. |
15+
| **`cli.ts`** | Parses argv (`--root`, `--config`, `query`, `agents init`, `--files`, `--full`), wires bootstrap → `runCodemapIndex` / `printQueryResult`. |
1616
| **`api.ts`** | Public programmatic surface: `createCodemap()`, `Codemap` (`query`, `index`), re-exports `runCodemapIndex` for advanced use. |
1717
| **`application/`** | Use cases: `run-index.ts` (incremental / full / targeted orchestration), `index-engine.ts` (collect files, git diff, `indexFiles`, workers via `worker-pool.ts`). |
1818
| **`runtime.ts` / `config.ts` / `db.ts` / …** | Infrastructure and parsing — unchanged responsibilities. |
@@ -79,6 +79,10 @@ A local SQLite database (`.codemap.db`) indexes the project tree and stores stru
7979
└──────────────┘
8080
```
8181

82+
### Language adapters
83+
84+
**`src/adapters/types.ts`** defines **`LanguageAdapter`**: `id`, `extensions`, and **`parse(ctx)`** returning structured rows for the SQLite schema. **`src/adapters/builtin.ts`** registers **TS/JS** (oxc), **CSS** (Lightning CSS), and **text** (markers + configured extensions). **`getAdapterForExtension(ext)`** selects the first matching adapter; unknown extensions fall back to **markers-only** text indexing. Future optional packages can add adapters once a registration API exists (see [roadmap.md](./roadmap.md)).
85+
8286
## Key Files
8387

8488
| File | Purpose |
@@ -95,6 +99,9 @@ A local SQLite database (`.codemap.db`) indexes the project tree and stores stru
9599
| `constants.ts` | Shared constants — e.g. `LANG_MAP` |
96100
| `markers.ts` | Shared marker extraction (`TODO`/`FIXME`/`HACK`/`NOTE`) — used by all parsers |
97101
| `parse-worker.ts` | Worker thread entry point — reads, parses, and extracts file data in parallel |
102+
| `adapters/` | `LanguageAdapter` types and built-in TS/CSS/text implementations |
103+
| `parsed-types.ts` | Shared `ParsedFile` shape for workers and adapters |
104+
| `agents-init.ts` | `codemap agents init` — copies `templates/agents``.agents/` |
98105
| `benchmark.ts` | Performance comparison script — see [benchmark.md](./benchmark.md) |
99106

100107
## CLI usage

docs/benchmark.md

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Compares two approaches to answering common code-discovery questions:
99

1010
The benchmark script lives at `src/benchmark.ts`.
1111

12-
**OSS note:** Scenario names and paths in the tables below came from **historical snapshots** of a large application. For reproducible numbers, we plan **fixture apps** under `fixtures/` — see [Fixtures (planned)](#fixtures-planned).
12+
**OSS note:** For **repeatable** numbers, use **`fixtures/minimal/`** ([Fixtures](#fixtures)) or index your own app with **`CODEMAP_ROOT`**. Tables below may still use historical labels; methodology is the same.
1313

1414
## Prerequisites
1515

@@ -126,25 +126,22 @@ The benchmark also measures the cost of keeping the index fresh (3 runs each, sa
126126
- **Full-text search** — the index doesn't store source code, so you still need grep/read for content-level queries (e.g. "find all usages of `console.log`")
127127
- **Questions about code logic** — the index captures structure (names, types, locations), not semantics (what the code does)
128128

129-
## Fixtures (planned)
129+
## Fixtures
130130

131-
### Problem
131+
### `fixtures/minimal/`
132132

133-
Historical benchmark scenarios used paths and labels tied to a **specific product tree**. In this OSS repo, those paths are **not canonical** — the [Results](#results) tables above are **illustrative** methodology from snapshots, not guaranteed reproducible numbers across machines.
133+
Small **private** package (not published) with intentional:
134134

135-
### Direction
135+
- `usePermissions`, `~/api/client` import, `components/shop/*`, `utils/date`, CSS variables, and a TODO marker.
136136

137-
Introduce **one or more small example / test apps** under this repo (e.g. `fixtures/minimal-react/`, `fixtures/monorepo-ts/`) that:
137+
**Local:**
138138

139-
- Include **stable, intentional** symbols, imports, CSS tokens, and markers.
140-
- Are indexed with a **pinned `codemap.config`** so `src/benchmark.ts` runs against a **known layout**, not whatever `cwd` happens to be.
141-
- Allow CI to run **deterministic** index + benchmark steps in isolation.
142-
143-
### Work items
139+
```bash
140+
export CODEMAP_ROOT="$(pwd)/fixtures/minimal"
141+
bun run dev --full
142+
bun run benchmark
143+
```
144144

145-
- [ ] Add `fixtures/<name>/` with minimal TS/React components, sample pages, and CSS/markers.
146-
- [ ] Point CI / docs at `CODEMAP_ROOT=$PWD/fixtures/<name>` (or `--root`) for benchmark runs.
147-
- [ ] Rename benchmark scenario titles to match fixture semantics (e.g. paths under `fixtures/...`) or neutral names (“scoped component subtree”).
148-
- [ ] Optionally vendor **two** fixtures (small vs medium) to show scale without depending on a private app.
145+
**CI:** the workflow **Benchmark (fixture)** runs the same steps with `CODEMAP_ROOT=$GITHUB_WORKSPACE/fixtures/minimal`.
149146

150-
Until fixtures exist, treat the [Results](#results) tables as **illustrative** methodology only.
147+
Scenario **titles** in `src/benchmark.ts` are still generic (historical names); **indexed row counts** on the fixture are stable for a given schema. A second, larger fixture is optional — see [roadmap.md](./ROADMAP.md).

docs/packaging.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ How **@stainless-code/codemap** is built and consumed on npm.
1414
| ------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
1515
| **CLI** | `package.json``"bin": { "codemap": "./dist/index.mjs" }` — same file as the library entry; **shebang** prepended at build time (tsdown `banner`) for `npx` / `node_modules/.bin`. |
1616
| **Library** | `"exports"` / `"main"` / `"types"`**`./dist/index.mjs`** and **`./dist/index.d.mts`**`createCodemap`, `Codemap`, `defineConfig`, config types, `runCodemapIndex`, etc. |
17-
| **Published files** | `package.json``"files": ["dist"]``src/` is not published. |
17+
| **Published files** | `package.json``"files": ["dist", "templates"]``src/` is not published; **`templates/agents`** supports `codemap agents init`. |
1818

1919
## Install
2020

docs/roadmap.md

Lines changed: 3 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,13 @@
11
# Roadmap
22

3-
Forward-looking plans only — **not** a mirror of `src/`. **Where things live:** `package.json`, `src/`, `.github/workflows/`; **design:** [README.md](./README.md) (index), [architecture.md](./architecture.md), [packaging.md](./packaging.md).
3+
Forward-looking plans only — **not** a mirror of `src/`. **Index:** [README.md](./README.md); **design:** [architecture.md](./architecture.md), [packaging.md](./packaging.md). **Shipped features** (adapters, fixtures, `codemap agents init`) live in `src/` and linked docs — not enumerated here.
44

55
---
66

77
## Next
88

9-
### Pluggable language adapters
10-
11-
**TypeScript/JavaScript**, **CSS**, and **text/markers** are implemented under **`src/`** (oxc, lightningcss, etc.). **Not** done: a stable **`LanguageAdapter`-style** boundary so more languages ship as add-ons:
12-
13-
```text
14-
LanguageAdapter
15-
id: string
16-
extensions: string[]
17-
parseFile(path, content, ctx): ParsedFileFragment
18-
```
19-
20-
- [ ] Define and document the internal adapter boundary (even if only one implementation ships in-repo at first).
21-
- [ ] Optional community packages (e.g. Tree-sitter-based) with a **peerDependency** on `@stainless-code/codemap`.
22-
23-
### Benchmarks & fixtures
24-
25-
- [ ] **Fixture tree(s)** under `fixtures/`[benchmark.md § Fixtures (planned)](./benchmark.md#fixtures-planned)
26-
- [ ] Point **`CODEMAP_ROOT`** / **`--root`** at a fixture in CI for **repeatable** benchmark numbers
27-
28-
### Agent tooling
29-
30-
- [ ] **`codemap`** subcommands or a small companion CLI to **generate/sync** agent files (Cursor rules, `AGENTS.md`, `.agents/skills/` stubs) — org layout TBD
31-
- [ ] Evaluate **[TanStack Intent](https://tanstack.com/intent/latest/docs/overview)** for versioned skills in `node_modules` (optional; generator remains fallback)
9+
- **Community language adapters** — optional packages (e.g. Tree-sitter) with a **peerDependency** on `@stainless-code/codemap` and a public **registration** API beyond built-ins in [`src/adapters/`](../src/adapters/).
10+
- **Agent tooling** — evaluate [TanStack Intent](https://tanstack.com/intent/latest/docs/overview) for versioned skills in `node_modules` (optional; **`codemap agents init`** remains the default).
3211

3312
---
3413

fixtures/minimal/README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Minimal benchmark fixture
2+
3+
Stable tree for **repeatable** `src/benchmark.ts` runs and CI.
4+
5+
- **Index from the codemap repo:** `CODEMAP_ROOT="$(pwd)/fixtures/minimal" bun run dev --full`
6+
- **Benchmark:** same `CODEMAP_ROOT`, then `bun run benchmark`
7+
8+
Includes intentional symbols (`usePermissions`), a `~/api/client` import, `components/shop/*`, `utils/date`, CSS variables, and a TODO marker.

fixtures/minimal/package.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"name": "codemap-fixture-minimal",
3+
"version": "0.0.0",
4+
"private": true,
5+
"description": "Small fixture for benchmarks and CI — not published."
6+
}

0 commit comments

Comments
 (0)