Skip to content

Commit 8b6d680

Browse files
committed
docs: update docs and remove old ccc-dev/ directory
- AGENTS.md: document fork-scripts/ workflow and per-fork structure - README.md: update developer script examples for fork:* format - Delete ccc-dev/: replaced by fork-scripts/ + ccc-fork/
1 parent c88e479 commit 8b6d680

15 files changed

Lines changed: 49 additions & 695 deletions

File tree

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
---
3+
4+
Generalize ccc-dev/ into multi-repo fork management tool

AGENTS.md

Lines changed: 30 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -18,32 +18,45 @@
1818
1919
## PR Workflow
2020
21-
1. **Routine Pre-PR Validation**: `pnpm check:full`, it wipes derived state and regenerates from scratch. If `ccc-dev/ccc/` has pending work, the wipe is skipped to prevent data loss — re-record or push CCC changes first for a clean validation
21+
1. **Routine Pre-PR Validation**: `pnpm check:full`, it wipes derived state and regenerates from scratch. If any fork clone has pending work, the wipe is skipped to prevent data loss — re-record or push fork changes first for a clean validation
2222
2. **Open a PR**: Run `pnpm changeset` to generate a changeset entry, then push the branch and present a clickable markdown link `[title](url)` where the URL is a GitHub compare URL (`quick_pull=1`). Base branch is `master`. Prefill "title" (concise, under 70 chars) and "body" (markdown with ## Why and ## Changes sections)
2323
3. **Fetch PR review comments**: Use the GitHub REST API via curl. Fetch all three comment types (issue comments, reviews, and inline comments). Categorize feedback by actionability (action required / informational), not by source (human / bot). Reviewers reply asynchronously — poll every minute until comments arrive
2424
25-
## CCC Local Development (ccc-dev/)
25+
## Fork Management (fork-scripts/ + *-fork/)
2626
27-
The `ccc-dev/` system uses a record/replay mechanism for deterministic builds of a local CCC fork:
27+
The `fork-scripts/` system uses a record/replay mechanism for deterministic builds of external repo forks. Each fork lives in a `<name>-fork/` directory with a `config.json` specifying upstream URL, fork URL, merge refs, and workspace config. Scripts in `fork-scripts/` are generic and accept the fork directory as their first argument.
2828
29-
- `ccc-dev/pins/` is **committed** to git (base SHAs, merge refs, conflict resolutions, local patches), regenerated by `pnpm ccc:record`
30-
- `ccc-dev/ccc/` is **not in git** — it is rebuilt from pins on `pnpm install`
31-
- The developer may have **pending work** in `ccc-dev/ccc/`. Run `pnpm ccc:status` (exit 0 = safe to wipe, exit 1 = has custom work) before any operation that would destroy it. `pnpm ccc:record`, `pnpm ccc:clean`, and `pnpm ccc:reset` already guard against this automatically
32-
- `.pnpmfile.cjs` silently rewrites all `@ckb-ccc/*` dependencies to `workspace:*` when `ccc-dev/ccc/` exists. Local CCC packages override published ones without any visible change in package.json files
33-
- `pnpm install` has a side effect: if `ccc-dev/pins/REFS` exists but `ccc-dev/ccc/` does not, it automatically runs `ccc-dev/replay.sh` to rebuild CCC from pins. This is intentional
34-
- `ccc-dev/patch.sh` rewrites CCC package exports to point at `.ts` source instead of `.d.ts`, then creates a deterministic git commit (fixed author/date) so record and replay produce the same `pins/HEAD` hash. This is why imports from `@ckb-ccc/*` resolve to TypeScript source files inside `node_modules` — it is not a bug
35-
- `ccc-dev/tsgo-filter.sh` is a bash wrapper around `tsgo` that filters out diagnostics originating from `ccc-dev/ccc/`. CCC source does not satisfy this repo's strict tsconfig (`verbatimModuleSyntax`, `noUncheckedIndexedAccess`, `noImplicitOverride`), so the wrapper suppresses those errors while still reporting errors in stack source
29+
### Per-fork directory structure
3630
37-
### Opening a CCC upstream PR
31+
Each `<name>-fork/` contains:
32+
- `config.json` — upstream URL, fork URL, refs to merge, cloneDir, workspace include/exclude
33+
- `pins/` — **committed** to git (manifest + counted resolutions + local patches), regenerated by `pnpm fork:record <name>-fork`
34+
- `pins/HEAD` — expected final SHA after full replay
35+
- `pins/manifest` — base SHA + merge refs (TSV, one per line)
36+
- `pins/res-N.resolution` — conflict resolution for merge step N (counted format: `--- path` file headers, `CONFLICT ours=N base=M theirs=K resolution=R` conflict headers followed by R resolution lines; parser is purely positional — reads counts and skips lines, never inspects content)
37+
- `pins/local-*.patch` — local development patches (applied after merges + patch.sh)
38+
- `<cloneDir>/` — **not in git** — rebuilt from pins on `pnpm install`
3839
39-
In `ccc-dev/ccc/`, branch off `origin/master` (or relevant branch), push to fork (`phroi/ccc`), open PR against `ckb-devrel/ccc`. Before pushing, run the CCC CI steps (`ccc-dev/ccc/.github/workflows/check.yaml`) with `CI=true`.
40+
### Key behaviors
4041
41-
Once the PR is open, replace the local patch with a merge ref:
42+
- The developer may have **pending work** in a fork clone. Run `pnpm fork:status <name>-fork` (exit 0 = safe to wipe, exit 1 = has custom work) before any operation that would destroy it. `fork:record`, `fork:clean`, and `fork:reset` already guard against this automatically
43+
- `.pnpmfile.cjs` scans all `*-fork/config.json` directories and silently rewrites matching dependencies to `workspace:*` when clones exist. Local fork packages override published ones without any visible change in package.json files
44+
- `pnpm install` has a side effect: if `<name>-fork/pins/manifest` exists but the clone does not, it automatically runs `fork-scripts/replay.sh` to rebuild from pins. This is intentional
45+
- `fork-scripts/patch.sh` rewrites fork package exports to point at `.ts` source instead of `.d.ts`, then creates a deterministic git commit (fixed author/date) so record and replay produce the same HEAD hash. This is why imports from fork packages resolve to TypeScript source files — it is not a bug
46+
- `fork-scripts/tsgo-filter.sh` is a bash wrapper around `tsgo` that filters out diagnostics originating from all `*-fork/` clone paths. Fork source may not satisfy this repo's strict tsconfig, so the wrapper suppresses those errors while still reporting errors in stack source
47+
- `pnpm fork:save <name>-fork [description]` captures local work as a patch in `pins/`. Patches survive re-records and replays
48+
- `pnpm fork:record` regenerates the fork workspace entries in `pnpm-workspace.yaml` (between `@generated` markers) from all `*-fork/config.json` files — manual edits to that section are overwritten on re-record
4249
43-
1. Delete the patch from `ccc-dev/pins/local/`
44-
2. Add the PR number to `ccc:record` in `package.json` — order PRs by target branch from upstream to downstream, so each group merges cleanly onto its base before the next layer begins
45-
3. Run `pnpm ccc:record`
46-
4. Run `pnpm check:full` to verify the merge ref reproduces what the local patch achieved
50+
### CCC upstream contributions
51+
52+
Work locally via `ccc-fork/` first. Only push to the fork (`phroi/ccc`) when changes are validated against the stack. Do not open PRs against `ckb-devrel/ccc` prematurely — keep changes on the fork until they are production-ready and the maintainer decides to upstream.
53+
54+
1. Develop and test in `ccc-fork/ccc/` on the `wip` branch
55+
2. When ready, use `pnpm fork:push ccc-fork` to cherry-pick commits onto a PR branch
56+
3. Push the PR branch to `phroi/ccc` for review
57+
4. Add the PR number to `refs` in `ccc-fork/config.json` — order PRs by target branch from upstream to downstream, so each group merges cleanly onto its base before the next layer begins
58+
5. Run `pnpm fork:record ccc-fork` and `pnpm check:full` to verify
59+
6. Only open an upstream PR against `ckb-devrel/ccc` when the maintainer explicitly decides to upstream
4760
4861
## Reference Repos
4962

README.md

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -54,17 +54,17 @@ graph TD;
5454
click F "https://github.com/ickb/stack/tree/master/packages/sdk" "Go to @ickb/sdk"
5555
```
5656

57-
## Develop CCC
57+
## Develop with Forks
5858

59-
When `ccc-dev/pins/REFS` is committed, `pnpm install` automatically sets up the CCC local development environment on first run (by replaying pinned merges via `ccc-dev/replay.sh`). No manual setup step is needed — just clone and install:
59+
When `<name>-fork/pins/manifest` is committed, `pnpm install` automatically sets up the local fork development environment on first run (by replaying pinned merges via `fork-scripts/replay.sh`). No manual setup step is needed — just clone and install:
6060

6161
```bash
6262
git clone git@github.com:ickb/stack.git && cd stack && pnpm install
6363
```
6464

65-
To redo the setup from scratch: `pnpm ccc:clean && pnpm install`.
65+
To redo the setup from scratch: `pnpm fork:clean-all && pnpm install`.
6666

67-
See [ccc-dev/README.md](ccc-dev/README.md) for recording new pins, developing CCC PRs, and the full workflow.
67+
See [ccc-fork/README.md](ccc-fork/README.md) for recording new pins, developing CCC PRs, and the full workflow.
6868

6969
## Reference
7070

@@ -81,15 +81,17 @@ This clones two repos into the project root (both are git-ignored and made read-
8181

8282
## Developer Scripts
8383

84-
| Command | Description |
85-
| ------------------- | ------------------------------------------------------------------------------------- |
86-
| `pnpm coworker` | Launch an interactive AI Coworker session (full autonomy, opus model). |
87-
| `pnpm coworker:ask` | One-shot AI query for scripting (sonnet model, stateless). Used by `pnpm ccc:record`. |
88-
| `pnpm ccc:status` | Check if CCC clone matches pinned state. Exit 0 = safe to wipe. |
89-
| `pnpm ccc:record` | Record CCC pins (clone, merge refs, build). Guarded against pending work. |
90-
| `pnpm ccc:clean` | Remove CCC clone, keep pins (guarded). Re-replay on next `pnpm install`. |
91-
| `pnpm ccc:reset` | Remove CCC clone and pins (guarded). Restores published CCC packages. |
92-
| `pnpm check:full` | Wipe derived state and validate from scratch. Skips wipe if CCC has pending work. |
84+
| Command | Description |
85+
| -------------------------------- | --------------------------------------------------------------------------------- |
86+
| `pnpm coworker` | Launch an interactive AI Coworker session (full autonomy, opus model). |
87+
| `pnpm coworker:ask` | One-shot AI query for scripting (sonnet model, stateless). Used by fork:record. |
88+
| `pnpm fork:status <name>-fork` | Check if fork clone matches pinned state. Exit 0 = safe to wipe. |
89+
| `pnpm fork:record <name>-fork` | Record fork pins (clone, merge refs, build). Guarded against pending work. |
90+
| `pnpm fork:save <name>-fork` | Capture local fork work as a patch in pins/ (survives re-records and replays). |
91+
| `pnpm fork:push <name>-fork` | Cherry-pick commits from wip branch onto a PR branch for pushing to the fork. |
92+
| `pnpm fork:clean <name>-fork` | Remove fork clone, keep pins (guarded). Re-replay on next `pnpm install`. |
93+
| `pnpm fork:reset <name>-fork` | Remove fork clone and pins (guarded). Restores published packages. |
94+
| `pnpm check:full` | Wipe derived state and validate from scratch. Skips wipe if forks have pending work.|
9395

9496
## Epoch Semantic Versioning
9597

ccc-dev/.gitignore

Lines changed: 0 additions & 1 deletion
This file was deleted.

ccc-dev/README.md

Lines changed: 0 additions & 128 deletions
This file was deleted.

ccc-dev/patch.sh

Lines changed: 0 additions & 35 deletions
This file was deleted.

ccc-dev/pins/HEAD

Lines changed: 0 additions & 1 deletion
This file was deleted.

ccc-dev/pins/REFS

Lines changed: 0 additions & 4 deletions
This file was deleted.

0 commit comments

Comments
 (0)