Skip to content

Commit ff0b7d8

Browse files
committed
docs: align README and architecture with SHA-256 hashes and adapters
- Fix content_hash docs (was Bun.hash; use src/hash.ts SHA-256) - Layering table + CLI/agents + export list; packaging library row
1 parent 4943f36 commit ff0b7d8

4 files changed

Lines changed: 21 additions & 20 deletions

File tree

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ bun add @stainless-code/codemap
1818

1919
(`0.0.0` until the first npm release; use a git dependency or `bun link` until then.)
2020

21-
The package exposes a **`codemap`** binary, a **library** entry (`import` / `exports`), and ships compiled **`dist/`** — see [docs/packaging.md](docs/packaging.md).
21+
The package exposes a **`codemap`** binary, a **library** entry (`import` / `exports`), compiled **`dist/`**, and **`templates/agents`** for **`codemap agents init`** — see [docs/packaging.md](docs/packaging.md).
2222

2323
**Engines:** Node **≥20** and/or Bun **≥1.1** (see `package.json`).
2424

@@ -94,7 +94,7 @@ bun run check # build + format:check + lint + test + typecheck
9494
bun run fix # oxlint --fix, then oxfmt
9595
```
9696

97-
**Readability & DX:** Prefer clear names and small functions over cleverness. **Public API** surface (`createCodemap`, `Codemap`, config types, `runCodemapIndex`) should stay **documented with JSDoc** so consumers get good hovers and published `.d.ts` stay useful. **Layering** (`cli``application`parsers / SQLite): see [docs/architecture.md](docs/architecture.md). More for contributors: [.github/CONTRIBUTING.md](.github/CONTRIBUTING.md).
97+
**Readability & DX:** Prefer clear names and small functions over cleverness. **Public API** surface (`createCodemap`, `Codemap`, config types, `runCodemapIndex`, adapter exports) should stay **documented with JSDoc** so consumers get good hovers and published `.d.ts` stay useful. **Layering** (`cli``application``adapters` / parsers → SQLite): see [docs/architecture.md](docs/architecture.md). More for contributors: [.github/CONTRIBUTING.md](.github/CONTRIBUTING.md).
9898

9999
---
100100

docs/architecture.md

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ A local SQLite database (`.codemap.db`) indexes the project tree and stores stru
1515
| **`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`). |
18-
| **`runtime.ts` / `config.ts` / `db.ts` / …** | Infrastructure and parsing — unchanged responsibilities. |
18+
| **`adapters/`** | `LanguageAdapter` registry; built-ins call `parser.ts` / `css-parser.ts` / `markers.ts` from `parse-worker-core`. |
19+
| **`runtime.ts` / `config.ts` / `db.ts` / …** | Config, SQLite, resolver, workers. |
1920

2021
`index.ts` is the package entry: re-exports the public API and runs `cli.ts` only when executed as the main module (Node/Bun `codemap` binary).
2122

@@ -88,7 +89,7 @@ A local SQLite database (`.codemap.db`) indexes the project tree and stores stru
8889
| File | Purpose |
8990
| ----------------- | ------------------------------------------------------------------------------------------------ |
9091
| `index.ts` | Package entry — re-exports `api` / `config`, runs CLI when main |
91-
| `cli.ts` | CLI adapter — argv parsing, `query` / index commands |
92+
| `cli.ts` | CLI — argv parsing, `query`, `agents init`, `--files`, index modes |
9293
| `api.ts` | Programmatic API — `createCodemap`, `Codemap`, `runCodemapIndex` |
9394
| `application/` | Indexing use cases and engine (`run-index`, `index-engine`, types) |
9495
| `worker-pool.ts` | Parallel parse workers (Bun / Node) |
@@ -130,7 +131,7 @@ When specific file paths are passed via `--files`, the indexer skips git diff, g
130131

131132
## Programmatic usage
132133

133-
The npm package exports **`createCodemap`**, **`Codemap`** (`query`, `index`), **`runCodemapIndex`** (advanced), and config helpers — see **`src/api.ts`** and **`dist/index.d.mts`**. Typical flow:
134+
The npm package exports **`createCodemap`**, **`Codemap`** (`query`, `index`), **`runCodemapIndex`** (advanced), config helpers, **`CodemapDatabase`** (type), adapter types (`LanguageAdapter`, `getAdapterForExtension`, …), and **`ParsedFile`** — see **`src/api.ts`** / **`src/index.ts`** and **`dist/index.d.mts`**. Typical flow:
134135

135136
1. **`await createCodemap({ root, configFile?, config? })`** — loads `codemap.config.*`, calls **`initCodemap`** and **`configureResolver`**.
136137
2. **`await cm.index({ mode, files?, quiet? })`** — same pipeline as the CLI (incremental / full / targeted).
@@ -146,15 +147,15 @@ All tables use `STRICT` mode. Tables marked with `WITHOUT ROWID` store data dire
146147

147148
### `files` — Every indexed file (`STRICT`)
148149

149-
| Column | Type | Description |
150-
| ------------- | ------- | ------------------------------------- |
151-
| path | TEXT PK | Relative path from project root |
152-
| content_hash | TEXT | `Bun.hash` (wyhash) as base-36 string |
153-
| size | INTEGER | File size in bytes |
154-
| line_count | INTEGER | Total lines |
155-
| language | TEXT | `ts`, `tsx`, `css`, `md`, etc. |
156-
| last_modified | INTEGER | File mtime (epoch ms) |
157-
| indexed_at | INTEGER | When this row was written |
150+
| Column | Type | Description |
151+
| ------------- | ------- | ------------------------------------------------- |
152+
| path | TEXT PK | Relative path from project root |
153+
| content_hash | TEXT | SHA-256 hex (`src/hash.ts`, same on Node and Bun) |
154+
| size | INTEGER | File size in bytes |
155+
| line_count | INTEGER | Total lines |
156+
| language | TEXT | `ts`, `tsx`, `css`, `md`, etc. |
157+
| last_modified | INTEGER | File mtime (epoch ms) |
158+
| indexed_at | INTEGER | When this row was written |
158159

159160
### `symbols` — Functions, variables, classes, interfaces, type aliases, enums (`STRICT`)
160161

docs/benchmark.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ Each scenario runs both approaches back-to-back on the same machine, same data.
6262

6363
## Results
6464

65-
Example snapshot from `bun src/benchmark.ts` immediately after `bun src/index.ts --full` on **this repository** (small tree; many scenario result counts are zero — that is expected here). Numbers vary by machine and project shape. Settings: schema v2, `Bun.hash` content fingerprints, `db.query()` caching, covering/partial indexes, mmap, worker threads, deferred indexes, `batchInsert` helper.
65+
Example snapshot from `bun src/benchmark.ts` immediately after `bun src/index.ts --full` on **this repository** (small tree; many scenario result counts are zero — that is expected here). Numbers vary by machine and project shape. Settings: schema v2, SHA-256 content fingerprints (`src/hash.ts`), `db.query()` caching, covering/partial indexes, mmap, worker threads, deferred indexes, `batchInsert` helper.
6666

6767
| Scenario | Index Time | Results | Trad. Time | Results | Files Read | Bytes Read | Speedup |
6868
| --------------------------------------- | ---------- | ------- | ---------- | ------- | ---------- | ---------- | -------- |

docs/packaging.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@ How **@stainless-code/codemap** is built and consumed on npm.
1010

1111
## Entry points
1212

13-
| Surface | Location |
14-
| ------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
15-
| **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`. |
16-
| **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", "templates"]``src/` is not published; **`templates/agents`** supports `codemap agents init`. |
13+
| Surface | Location |
14+
| ------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
15+
| **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`. |
16+
| **Library** | `"exports"` / `"main"` / `"types"`**`./dist/index.mjs`** and **`./dist/index.d.mts`**`createCodemap`, `Codemap`, `defineConfig`, config types, `runCodemapIndex`, adapter helpers, etc. |
17+
| **Published files** | `package.json``"files": ["dist", "templates"]``src/` is not published; **`templates/agents`** supports `codemap agents init`. |
1818

1919
## Install
2020

0 commit comments

Comments
 (0)