6.5 KiB
6.5 KiB
Tasks: folder-reorg-by-domain
Change ID: folder-reorg-by-domain Scope: Monorepo-wide structural change
1. Pre-flight
- Confirm clean working tree (
git statusreports nothing) and no in-flight worktrees with uncommitted work (git worktree listthengit statusin each). - Confirm all currently-published packages on Verdaccio have green pre-publish gates (snapshot the list —
bun scripts/list-published.tsif available, otherwise grepnpmjs.fq.io). - Tag the pre-migration state:
git tag pre-folder-reorg.
2. Assignment manifest
- Create
scripts/folder-reorg/assignment.yml— machine-readable copy of the plugin → package table fromproposal.md. Format:<plugin-name>: [<pkg1>, <pkg2>, ...]. - Add a sanity check: every package referenced in
assignment.ymlexists either on disk in genesis OR inMIGRATION.md(future) OR in the universe spec (future). Fail fast if any package is unaccounted for. - Add a uniqueness check: every package appears in exactly one plugin.
3. Migration script
- Write
scripts/folder-reorg/migrate-folders.ts:- Reads
assignment.yml. - For each package currently on disk under
universal/<domain>/<pkg>/, runsgit mv universal/<domain>/<pkg>/ packages/<plugin>/<pkg>/. - Skips packages listed in
assignment.ymlbut not yet on disk (future packages from MIGRATION.md / universe spec). - Logs every move; outputs a summary.
- Reads
- Dry-run mode (
--dry-run) prints planned moves without executing.
4. Execute migration
- Run
bun scripts/folder-reorg/migrate-folders.ts --dry-run. Review output. - Run
bun scripts/folder-reorg/migrate-folders.ts. Single commit:chore(structure): move all packages to domain-first layout. - Verify
packages/contains exactly the plugin folders fromproposal.md. - Verify legacy folders (
universal/, etc.) are empty or removed.
5. Workspace + tooling updates
- Root
package.json—workspacesglob: ensurepackages/*/*covers the new layout. Remove any tier-specific globs. - Root
tsconfig.json— regeneratepathsmapping if it's not glob-based. turbo.json— no change expected (uses workspace inheritance); verify by runningbunx turbo run build --dry-run.- Run nuclear clean install:
rm -rf node_modules bun.lockb && find . -type d -name "node_modules" -exec rm -rf {} + && bun install --force. - Run full lint+typecheck+test sweep:
bunx turbo lint typecheck test. All packages must stay green — folder move should be transparent to package contents.
6. Documentation updates
CLAUDE.md— replace everyuniversal/<domain>/<pkg>path reference withpackages/<plugin>/<pkg>. Update the Packages section to describe the new layout. Update Quick Commands examples.openspec/AGENTS.md— replace everyuniversal/<domain>/<pkg>andpackages/universal/<pkg>path reference. Update file-size, banned-pattern, and missing-.mdscan commands.openspec/project.md— update if it references folder layout.- In-flight OpenSpec changes (
enterprise-*) — update only theTarget path:line in eachproposal.mdif the change is not yet archived. Already-archived changes stay frozen.
7. Delete FOLDERS.yml
git rm FOLDERS.yml.- Add a one-line note to
CLAUDE.mdPackages section: "Folder layout is domain-first; seeMANIFEST.mdfor the per-tier overlay view."
8. Retire @suaveplan/overview
git rm -r packages/data/overview/(it has been reassigned to foundation but is being retired — confirm by re-readingproposal.mdand removing it from the foundation row inassignment.ymlbefore running the migration script).- Unpublish from Verdaccio:
bun scripts/unpublish.ts --package @suaveplan/overview(or manualnpm unpublish @suaveplan/overview --registry https://npmjs.fq.io --force). - Search the rest of genesis for any
import ... from '@suaveplan/overview'or"@suaveplan/overview"dependency entries; remove them. Expected: zero matches (the package was a leaf with no in-repo consumers). - Remove the
enterprise-overviewOpenSpec archive line from any index if one exists.
9. MANIFEST.md generator
- Write
scripts/generate-manifest.ts:- Walks
packages/<plugin>/<pkg>/package.jsonfor every package. - Emits
MANIFEST.mdat repo root with sections:- Plugins — table of
plugin | package count | total deps. - Packages — table of
npm name | plugin | tier (inferred) | version | dep count. - Tier overlay — packages grouped by inferred tier (universal / browser / react / r3f / server / python). Inference rules:
pythonifpackage.jsonhas"python"field or path containspython-.r3fifpeerDependenciescontains@react-three/fiber.reactelse ifpeerDependenciescontainsreact.browserelse ifpackage.jsonhas"browser"field orenginesexcludes node.serverelse ifbinis set OR depends onbun:sqlite/node:fs/ similar.universalotherwise.
- Dependency graph — DOT block listing
<pkgA> -> <pkgB>for every workspace dep edge.
- Plugins — table of
--checkmode regenerates in-memory and diffs against on-diskMANIFEST.md; exits non-zero on diff.
- Walks
- Co-locate
scripts/generate-manifest.mddocumentation per genesis docs rules. - First-time generation:
bun scripts/generate-manifest.ts > MANIFEST.md. Commit.
10. CI gate
- Add
bun scripts/generate-manifest.ts --checkas a CI step in the root pipeline. - Add the same as a
pre-commithook entry (optional — if hooks are configured).
11. Verify
bunx turbo lint typecheck test— all green.bunx turbo test:coverage --filter=@suaveplan/*— every package still at 100%.bunx turbo build— every package still builds.bun scripts/generate-manifest.ts --check— clean.git status— only intentional changes (folder moves, doc updates, MANIFEST.md, removed FOLDERS.yml, removed overview package).- Spot-check three packages from different plugins (e.g.
packages/core/error/,packages/gaming-engine/ecs/,packages/drive/drive-webrtc/) —package.jsonvalid,vitest.config.tsresolves, tests pass.
12. OpenSpec archival
- Fold
specs/monorepo-structure/spec.md(this change's spec delta) intoopenspec/specs/monorepo-structure/spec.md. - Move
openspec/changes/folder-reorg-by-domain/→openspec/archive/2026-04-25-folder-reorg-by-domain/.