Skip to content

Commit b366c53

Browse files
docs: PR workflow for protected main, packaging alignment, release notes (#1)
* docs: document PR-only workflow for protected main - CONTRIBUTING: branch from main, push branch, PR after CI green. - docs/README: link CI workflow in contributor conventions. * docs: align packaging/benchmark with docs/README conventions - packaging: tarball contents match package.json files (include CHANGELOG). - benchmark: point glob stack to Node vs Bun; avoid duplicating SQL in prose. - docs/README: index packaging row + conventions (no duplicate runtime table; benchmark exception). * ci(release): use npm run release for Changesets publish; document NPM_TOKEN - setup-node@22 before changesets/action so publish matches npx changeset publish. - Replace bun run release in the action: avoid exit 1 on no-op main pushes. - packaging.md: explain every main push, no-changeset path, NPM_TOKEN for real publishes. * ci(release): fact-check publish step; bun run release, honest docs Remove unverified Bun-vs-npm claims. Revert to bun run release without setup-node. Document troubleshooting (NPM_TOKEN, logs) instead of assumed root cause. * chore: consolidate docs, packaging releases; add patch changeset - docs README hub, packaging Changesets table, .changeset README pointer - clean / check-updates scripts; CONTRIBUTING updates - changeset: patch bump for @stainless-code/codemap
1 parent 1d01528 commit b366c53

9 files changed

Lines changed: 129 additions & 94 deletions

File tree

.changeset/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,7 @@ find the full documentation for it [in our repository](https://github.com/change
66

77
We have a quick list of common questions to get you started engaging with this project in
88
[our documentation](https://github.com/changesets/changesets/blob/main/docs/common-questions.md).
9+
10+
---
11+
12+
**This repo:** How versioning, **`NPM_TOKEN`**, and the GitHub workflow fit together for **`@stainless-code/codemap`** — see [docs/packaging.md § Releases](../docs/packaging.md#releases) (single place; don’t duplicate here).
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@stainless-code/codemap": patch
3+
---
4+
5+
Consolidate docs (index hub, packaging/Releases, benchmark vs external root), point `.changeset/README` at packaging, and add `clean` / `check-updates` npm scripts.

.github/CONTRIBUTING.md

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,28 @@ bun install # runs `prepare` → Husky git hooks
1212
bun run dev # same as `bun src/index.ts` — CLI from source
1313
bun test
1414
bun run check # format + lint + tests + typecheck + build
15+
bun run clean # remove untracked/ignored build artifacts (keeps `.env`, `.codemap.db*`)
16+
bun run check-updates # interactive dependency updates (`bun update -i --latest`)
1517
```
1618

19+
### `main` and pull requests
20+
21+
Branch **`main`** is **protected**: routine work does **not** push directly to `main`. Open a **pull request** and merge only after **[CI](workflows/ci.yml)** passes (format, lint, typecheck, test, build).
22+
23+
```bash
24+
git fetch origin && git checkout main && git pull
25+
git checkout -b your-branch-name
26+
# … commit …
27+
git push -u origin your-branch-name
28+
```
29+
30+
Then open a PR on GitHub into **`main`**.
31+
1732
### Readability & DX
1833

1934
- **Public API** — Anything exported from the package entry (`src/index.ts``src/api.ts`, `config.ts`, shared types) should have **JSDoc** that reads well in hovers and in published typings.
2035
- **Layers** — Keep boundaries clear: [architecture.md](../docs/architecture.md) (`cli``application` → infrastructure). Don’t let CLI concerns leak into parsers or the DB layer.
21-
- **Before you push**`bun run check` (or at least `bun run test` + `bun run typecheck` if you’re iterating).
36+
- **Before you open / update a PR**`bun run check` (or at least `bun run test` + `bun run typecheck` while iterating).
2237
- **Style** — Match Oxfmt/Oxlint; prefer **straight-line code** and extracted helpers over long nested blocks.
2338

2439
**Editor (VS Code):** [`.vscode/extensions.json`](../.vscode/extensions.json) lists recommended extensions (Bun, Oxc, TypeScript native preview, etc.). [`.vscode/settings.json`](../.vscode/settings.json) enables Oxc format on save and `tsgo`. Formatting and lint rules live in [`.oxfmtrc.json`](../.oxfmtrc.json) and [`.oxlintrc.json`](../.oxlintrc.json) (no framework-specific options beyond defaults).

.github/workflows/release.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,11 @@ jobs:
3131
- name: Install dependencies
3232
run: bun install --frozen-lockfile
3333

34-
# Opens/updates the Version PR; after merge, publishes to npm and creates GitHub Releases
35-
# (see https://github.com/changesets/action — createGithubReleases defaults to true).
34+
# Opens/updates the Version PR when `.changeset/*.md` exist. When there are none, the action
35+
# can still run `publish` (see changesets/action) so a just-merged Version PR can ship.
36+
# `changeset publish` should exit 0 when there is nothing new to publish. If this job fails,
37+
# read the step log: common causes are missing/invalid NPM_TOKEN, registry/network errors, or
38+
# a real publish failure — not assumed from the runner alone.
3639
- name: Create Release Pull Request or Publish to npm
3740
id: changesets
3841
uses: changesets/action@v1

bun.lock

Lines changed: 74 additions & 74 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/README.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@
22

33
Technical docs for **[@stainless-code/codemap](https://github.com/stainless-code/codemap)**. Quick start: [../README.md](../README.md).
44

5-
| File | Topic |
6-
| ------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
7-
| [architecture.md](./architecture.md) | Schema, layering, CLI, programmatic API, [**User config**](./architecture.md#user-config) (Zod), parsers, [Key Files](./architecture.md#key-files) |
8-
| [benchmark.md](./benchmark.md) | **[Indexing another project](./benchmark.md#indexing-another-project)** (`CODEMAP_*`, `.env`) · **[benchmark script](./benchmark.md#the-benchmark-script)** (`src/benchmark.ts`) · [`fixtures/minimal/`](../fixtures/minimal/) |
9-
| [packaging.md](./packaging.md) | `dist/`, npm **`files`**, **engines**, **[Node vs Bun](./packaging.md#node-vs-bun)**, **[Releases](./packaging.md#releases)** (Changesets) |
10-
| [roadmap.md](./roadmap.md) | Forward-looking backlog (not a `src/` inventory) |
11-
| [why-codemap.md](./why-codemap.md) | Why index + SQL for agents (speed, tokens, accuracy) |
5+
| File | Topic |
6+
| ------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
7+
| [architecture.md](./architecture.md) | Schema, layering, CLI, API, [**User config**](./architecture.md#user-config) (Zod), parsers, [Key Files](./architecture.md#key-files) |
8+
| [benchmark.md](./benchmark.md) | [**Indexing another project**](./benchmark.md#indexing-another-project) · [**Benchmark script**](./benchmark.md#the-benchmark-script) · [`fixtures/minimal/`](../fixtures/minimal/) |
9+
| [packaging.md](./packaging.md) | **`CHANGELOG.md` / `dist/` / `templates/`** on npm, **engines**, [**Node vs Bun**](./packaging.md#node-vs-bun), [**Releases**](./packaging.md#releases) (Changesets) |
10+
| [roadmap.md](./roadmap.md) | Forward-looking backlog (not a `src/` inventory) |
11+
| [why-codemap.md](./why-codemap.md) | Why index + SQL for agents (speed, tokens, accuracy) |
1212

13-
**Cross-cutting:** SQLite, workers, include globs, and **JSON config I/O** use Bun when available — **[packaging.md § Node vs Bun](./packaging.md#node-vs-bun)** (single table; don’t duplicate elsewhere). **Config shape / validation** (Zod, strict keys) lives only in **[architecture.md § User config](./architecture.md#user-config)**.
13+
**Cross-cutting:** Runtime splits (SQLite, workers, globs, JSON config I/O) — [packaging § Node vs Bun](./packaging.md#node-vs-bun) only (link it; don’t copy the table). **User config** shape/validation[architecture § User config](./architecture.md#user-config) only.
1414

15-
**Conventions:** one topic per file; relative links; no symbol/file counts or source line numbers (use `codemap query` / `bun run dev query` after indexing). **This repo:** `bun run dev``bun src/index.ts`; **`bun run build`** → tsdown → `dist/`. **Contributors:** `bun run check`, JSDoc on public API[.github/CONTRIBUTING.md](../.github/CONTRIBUTING.md).
15+
**Conventions:** One topic per file; relative links; avoid stale file/symbol counts in narrative docs (use `codemap query` / `bun run dev query` after indexing; methodology tables in [benchmark.md](./benchmark.md) are fine). **This repo:** `bun run dev``bun src/index.ts`; `bun run build` → tsdown → `dist/`; `bun run clean` / `bun run check-updates`[.github/CONTRIBUTING.md](../.github/CONTRIBUTING.md). **Contributors:** branch + PR into **`main`** ([CI](../.github/workflows/ci.yml)), `bun run check`, JSDoc on public API.

docs/benchmark.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ Use **`CODEMAP_ROOT`** instead of **`CODEMAP_TEST_BENCH`** if you prefer; behavi
4545
### Overview
4646

4747
1. **Indexed** — single SQL query against `.codemap.db`
48-
2. **Traditional** — glob (Bun **`Glob`** or **`fast-glob`** on Node, same as the indexer) → **`readFileSync`** → regex match (simulates what AI agent tools like Grep/Read/Glob do)
48+
2. **Traditional** — glob (same implementation as the indexer — [packaging.md § Node vs Bun](./packaging.md#node-vs-bun)) → **`readFileSync`** → regex match (simulates what AI agent tools like Grep/Read/Glob do)
4949

5050
**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.
5151

@@ -131,7 +131,7 @@ On a small repo, totals move with noise and thermal variance. On a large indexed
131131

132132
The script’s **reindex** section averages **3 internal runs** per mode; full-rebuild wall time varies with disk and CPU load.
133133

134-
The indexed CSS scenario uses `ORDER BY name LIMIT 50`see `benchmark.ts` for the exact queries.
134+
The indexed CSS scenario uses `ORDER BY name LIMIT 50`exact SQL for each scenario lives in **`src/benchmark.ts`** in this repo (not duplicated here; keep in sync when changing scenarios).
135135

136136
### Key takeaways
137137

docs/packaging.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ How **@stainless-code/codemap** is built and published. Hub: [README.md](./READM
99

1010
## Consuming locally
1111

12-
Tarballs contain **`dist/`** + **`templates/`** only. **`bun run pack`**, then point the consumer at **`file:…/stainless-code-codemap-*.tgz`**, or use **`file:/path/to/repo`** after build, or **`bun link`**. If **`better-sqlite3`** fails in the consumer, **`npm rebuild better-sqlite3`** (native addon must match that Node).
12+
Published tarballs match **`package.json` `files`**: **`CHANGELOG.md`**, **`dist/`**, **`templates/`** (no `src/`). **`bun run pack`**, then point the consumer at **`file:…/stainless-code-codemap-*.tgz`**, or use **`file:/path/to/repo`** after build, or **`bun link`**. If **`better-sqlite3`** fails in the consumer, **`npm rebuild better-sqlite3`** (native addon must match that Node).
1313

1414
**Engines** (`package.json`): **Node** `^20.19.0 || >=22.12.0` (matches **`oxc-parser`**; **`better-sqlite3`** is prebuilt for current Node majors only). **Bun** `>=1.0.0`. **Native bindings:** `better-sqlite3`, `lightningcss`, `oxc-parser`, `oxc-resolver` (NAPI); **`fast-glob`** and **`zod`** are JS-only. **`zod`** validates `codemap.config.*` at runtime (**`codemapUserConfigSchema`** in **`src/config.ts`**); see [architecture.md § User config](./architecture.md#user-config).
1515

@@ -30,7 +30,13 @@ Same schema and CLI; implementation differs by runtime. Details: [architecture.m
3030

3131
## Releases
3232

33-
[**Changesets**](https://github.com/changesets/changesets): **`bun run changeset`** → commit **`.changeset/`** → merge → [release workflow](../.github/workflows/release.yml) versions / publishes. **`bun run release`** runs **`changeset publish`** (CI uses it too). Needs **`NPM_TOKEN`** (and typically **`GITHUB_TOKEN`**) as repo secrets for publish and changelog links.
33+
Releases use [**Changesets**](https://github.com/changesets/changesets). Repo config: [`.changeset/config.json`](../.changeset/config.json) (`$schema` targets **`@changesets/config`** — resolved version in **`bun.lock`**). Upstream CLI docs: [`.changeset/README.md`](../.changeset/README.md).
34+
35+
| Step | What happens |
36+
| ---- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
37+
| 1 | **`bun run changeset`** — add a changeset file under **`.changeset/`**, commit, open PR to **`main`**. |
38+
| 2 | **Merge** — on every push to **`main`**, [`.github/workflows/release.yml`](../.github/workflows/release.yml) runs [`changesets/action@v1`](https://github.com/changesets/action): opens/updates the **Version packages** PR when pending changesets exist; **`publish: bun run release`** runs **`changeset publish`**; **`createGithubReleases: true`**. |
39+
| 3 | **Secrets****`GITHUB_TOKEN`** is provided by Actions. **`NPM_TOKEN`** (npm [automation token](https://docs.npmjs.com/creating-and-viewing-access-tokens)) must be a **repository secret** for publishes to npm. If the Release job fails, use the workflow log (missing token, registry error, etc.) — don’t assume the cause from the job name alone. |
3440

3541
## Related
3642

package.json

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@
4646
"build": "tsdown",
4747
"changeset": "changeset",
4848
"check": "bun run build && bun run --parallel format:check lint:ci test typecheck",
49+
"check-updates": "bun update -i --latest",
50+
"clean": "git clean -xdf -e .env -e .codemap.db -e .codemap.db-wal -e .codemap.db-shm",
4951
"dev": "bun src/index.ts",
5052
"fix": "bun run lint:fix && bun run format",
5153
"format": "oxfmt",
@@ -67,7 +69,7 @@
6769
"better-sqlite3": "^12.8.0",
6870
"fast-glob": "^3.3.3",
6971
"lightningcss": "^1.32.0",
70-
"oxc-parser": "^0.123.0",
72+
"oxc-parser": "^0.124.0",
7173
"oxc-resolver": "^11.19.1",
7274
"zod": "^4.3.6"
7375
},
@@ -77,11 +79,11 @@
7779
"@types/better-sqlite3": "^7.6.13",
7880
"@types/bun": "^1.3.11",
7981
"@types/node": "^25.5.2",
80-
"@typescript/native-preview": "^7.0.0-dev.20260406.1",
82+
"@typescript/native-preview": "^7.0.0-dev.20260407.1",
8183
"husky": "^9.1.7",
8284
"lint-staged": "^16.4.0",
83-
"oxfmt": "^0.43.0",
84-
"oxlint": "^1.58.0",
85+
"oxfmt": "^0.44.0",
86+
"oxlint": "^1.59.0",
8587
"tsdown": "^0.21.7",
8688
"typescript": "^6.0.2"
8789
},

0 commit comments

Comments
 (0)