You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/architecture.md
+10-7Lines changed: 10 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -129,7 +129,7 @@ A local SQLite database (`.codemap.db`) indexes the project tree and stores stru
129
129
130
130
### `--files` (targeted reindex)
131
131
132
-
When specific file paths are passed via `--files`, the indexer skips git diff, git status, and the full filesystem glob scan. It reads the set of already-indexed paths from the database (for import resolution), then only processes the listed files. Files that no longer exist on disk are automatically removed from the index via `ON DELETE CASCADE`.
132
+
When specific file paths are passed via `--files`, the indexer skips git diff, git status, and the full filesystem glob scan. It reads the set of already-indexed paths from the database (for import resolution), then only processes the listed files. Files with non-standard extensions (e.g. custom `include` globs) are accepted and indexed as text; a warning is printed but they are not skipped. Files that no longer exist on disk are automatically removed from the index via `ON DELETE CASCADE`.
133
133
134
134
## Programmatic usage
135
135
@@ -208,7 +208,7 @@ All tables use `STRICT` mode. Tables marked with `WITHOUT ROWID` store data dire
208
208
| is_default | INTEGER | 1 if default export |
209
209
| re_export_source | TEXT | Source module if re-exported |
@@ -286,7 +286,7 @@ Uses the Rust-based `oxc-parser` via NAPI bindings to parse TypeScript/TSX/JS/JS
286
286
-**Symbols**: Functions, arrow functions, classes, interfaces, type aliases, enums — with reconstructed signatures
287
287
-**Imports**: All `import` statements with specifiers, source paths, and type-only flags
288
288
-**Exports**: Named exports, default exports, re-exports
289
-
-**Components**: React components detected via PascalCase name + JSX return. Extracts props type and hooks used
289
+
-**Components**: React components detected via PascalCase name + (JSX return**or** hook usage). A PascalCase function in `.tsx`/`.jsx` that neither returns JSX nor calls hooks is indexed only as a symbol, not a component. Extracts props type and hooks used
290
290
-**Markers**: `TODO`, `FIXME`, `HACK`, `NOTE` comments with line numbers
291
291
292
292
### CSS — `css-parser.ts` (`lightningcss`)
@@ -327,9 +327,10 @@ The indexer uses git to detect changes since the last indexed commit:
327
327
328
328
1.**Stores `last_indexed_commit`** (HEAD SHA) in the `meta` table after each run
329
329
2. On next run, computes `git diff --name-only <last_commit>..HEAD` + `git status --porcelain`
330
-
3. Only re-indexes changed files (SHA-256 content comparison), using DB-sourced `indexedPaths` for import resolution (skips full `collectFiles()` glob scan)
331
-
4. Deleted files are removed via `ON DELETE CASCADE` — deleting from `files` cascades to all related tables
332
-
5. Falls back to full rebuild if commit history is incompatible (e.g. force push, branch switch)
330
+
3. Filters changed files to those with a known extension **or** already present in the `files` table (so custom-extension files indexed during `--full` are re-indexed on subsequent incremental runs)
331
+
4. Only re-indexes changed files (SHA-256 content comparison), using DB-sourced `indexedPaths` for import resolution (skips full `collectFiles()` glob scan)
332
+
5. Deleted files are removed via `ON DELETE CASCADE` — deleting from `files` cascades to all related tables
333
+
6. Falls back to full rebuild if commit history is incompatible (e.g. force push, branch switch)
333
334
334
335
## File Artifacts
335
336
@@ -436,7 +437,7 @@ Until the first release, Codemap keeps **`SCHEMA_VERSION` at 1**; pull `--full`
436
437
437
438
### `bun:sqlite` API
438
439
439
-
All DDL and PRAGMA statements use `Database.run()`. The `sqlite-db.ts` wrapper abstracts both Bun (`bun:sqlite`) and Node (`better-sqlite3`). On Bun, `Database.query()` caches compiled statements; on Node, `better-sqlite3` re-prepares on each call via the wrapper's `run()`method. Read queries use the wrapper's `.query().all()` or `.get()`. Bulk inserts use the generic `batchInsert<T>()` helper with multi-row `INSERT ... VALUES (...),(...),(...)` in batches of 100, pre-computed placeholders, and zero-copy index-bounds iteration.
440
+
All DDL and PRAGMA statements use `Database.run()`. The `sqlite-db.ts` wrapper abstracts both Bun (`bun:sqlite`) and Node (`better-sqlite3`). On Bun, `Database.query()` caches compiled statements internally. On Node, the wrapper maintains a `Map<string, Statement>` cache so repeated `run()`and `query()` calls with the same SQL reuse a single prepared statement. Read queries use the wrapper's `.query().all()` or `.get()`. Bulk inserts use the generic `batchInsert<T>()` helper with multi-row `INSERT ... VALUES (...),(...),(...)` in batches of 100, pre-computed placeholders, and zero-copy index-bounds iteration.
440
441
441
442
### PRAGMAs (set on every `openDb()`)
442
443
@@ -457,6 +458,8 @@ All DDL and PRAGMA statements use `Database.run()`. The `sqlite-db.ts` wrapper a
457
458
|`analysis_limit`|`400`| Caps rows sampled by `optimize` to keep it fast |
Read-only query paths (`printQueryResult`, `queryRows`) call `closeDb` with `{ readonly: true }`, which skips both PRAGMAs to avoid write contention under concurrent `codemap query` processes.
462
+
460
463
### WITHOUT ROWID tables
461
464
462
465
Tables with a TEXT PRIMARY KEY and no auto-increment benefit from `WITHOUT ROWID` — the data is stored directly in the primary key B-tree instead of a separate rowid B-tree, eliminating a lookup indirection:
-**CSS**: variables (`--color-brand`, `--spacing-md`), class selectors (`.container`, `.primary` in a `.module.css`), `@keyframes fadeIn`, `@import` edge
214
+
-**Markers**: `TODO` (in `notes.md`) + `FIXME` (in `consumer.ts`)
0 commit comments