diff --git a/.changeset/curious-bears-zip.md b/.changeset/curious-bears-zip.md index 3a1c41de7..d4b298725 100644 --- a/.changeset/curious-bears-zip.md +++ b/.changeset/curious-bears-zip.md @@ -2,4 +2,4 @@ type: Changed pr: 3554 --- -**Project-Root Resolution Module unifies CJS and SDK `findProjectRoot` callers** — the previously-duplicated 67-line CJS and 94-line SDK implementations at `bin/lib/core.cjs:74-140` and `sdk/src/query/helpers.ts:497-590` are replaced by a single shared Module (`sdk/src/project-root/index.ts`) emitted to a CJS mirror via the existing generator pattern. The four-heuristic resolution logic (own `.planning/` guard #1362, parent `sub_repos`, legacy `multiRepo: true`, `.git` ancestor fallback) is byte-identical across runtimes, enforced by a CI freshness check. Two pre-existing CJS↔SDK drift deltas canonicalized to the SDK behavior: walk-up is now bounded by `FIND_PROJECT_ROOT_MAX_DEPTH = 10` (previously unbounded on CJS), and `.planning/config.json` is read via raw `readFileSync` (previously `platformReadSync` on CJS — functionally equivalent since the surrounding `try/catch` swallowed both fail-modes). Closes #3553. +**Project-Root Resolution Module unifies CJS and SDK `findProjectRoot` callers** — the previously-duplicated 67-line CJS and 94-line SDK implementations at `bin/lib/core.cjs:74-140` and `sdk/src/query/helpers.ts:497-590` are replaced by a single shared Module (`sdk/src/project-root/index.ts`) emitted to a CJS mirror via the existing generator pattern. The four-heuristic resolution logic (own `.planning/` guard #1362, parent `sub_repos`, legacy `multiRepo: true`, `.git` ancestor fallback) is byte-identical across runtimes, enforced by a CI freshness check. Two pre-existing CJS↔SDK drift deltas canonicalized to the SDK behavior: walk-up is now bounded by `FIND_PROJECT_ROOT_MAX_DEPTH = 10` (previously unbounded on CJS), and `.planning/config.json` is read via raw `readFileSync` (previously `platformReadSync` on CJS — functionally equivalent since the surrounding `try/catch` swallowed both fail-modes). Closes #3553. (`#3554`) diff --git a/CONTEXT.md b/CONTEXT.md index a2874d9cd..7d60be149 100644 --- a/CONTEXT.md +++ b/CONTEXT.md @@ -62,7 +62,7 @@ Module owning `.planning` path resolution, active workstream pointer policy (`se Shared CJS/SDK Module owning workstream directory discovery, per-workstream state projection, phase/plan/summary counting, roadmap-declared phase count, active marker projection, and active-workstream collision inputs. Command handlers render list/status/progress outputs from this inventory instead of rescanning `.planning/workstreams/*` directly. Source of truth for the pure projection is `sdk/src/workstream-inventory/builder.ts` (a Builder Module emitted to `get-shit-done/bin/lib/workstream-inventory-builder.generated.cjs` via the generator pattern); per-side Reader Adapters (`bin/lib/workstream-inventory.cjs` sync, `sdk/src/query/workstream-inventory.ts` async-ready) collect filesystem inputs and delegate projection to the Builder. ### Project-Root Resolution Module -Shared CJS/SDK Module owning project-root resolution from any starting directory. Walks the ancestor chain (bounded by `FIND_PROJECT_ROOT_MAX_DEPTH = 10`) applying four heuristics in order: (0) own `.planning/` guard (#1362), (1) parent `.planning/config.json` `sub_repos` traversal, (2) legacy `multiRepo: true` boolean + ancestor `.git`, (3) `.git` heuristic with parent `.planning/`. Returns `startDir` when no ancestor qualifies. Sync `node:fs` I/O. Source of truth: `sdk/src/project-root/index.ts`; CJS callers consume the generator-emitted `get-shit-done/bin/lib/project-root.generated.cjs` via thin re-exports at `bin/lib/core.cjs` and `sdk/src/query/helpers.ts`. +Shared CJS/SDK Module owning project-root resolution from any starting directory. Walks the ancestor chain (bounded by `FIND_PROJECT_ROOT_MAX_DEPTH = 10`) applying four heuristics in order: (0) own `.planning/` guard (#1362), (1) parent `.planning/config.json` `sub_repos` traversal, (2) legacy `multiRepo: true` boolean + ancestor `.git`, (3) `.git` heuristic with parent `.planning/`. Returns `startDir` when no ancestor qualifies. Sync `node:fs` I/O. Source of truth: `sdk/src/project-root/index.ts`; CJS callers consume the generator-emitted `get-shit-done/bin/lib/project-root.generated.cjs` via thin re-exports at `get-shit-done/bin/lib/core.cjs` and `sdk/src/query/helpers.ts`. ### Planning Path Projection Module SDK query Module owning projection from project/workstream context to concrete `.planning` paths. Policy precedence is `explicit workstream > env workstream > env project > root`. Invalid workspace context is a validation error at this seam rather than a silent fallback. diff --git a/docs/INVENTORY.md b/docs/INVENTORY.md index fc8428091..30195d4fb 100644 --- a/docs/INVENTORY.md +++ b/docs/INVENTORY.md @@ -402,8 +402,8 @@ Full listing: `get-shit-done/bin/lib/*.cjs`. | `phase.cjs` | Phase directory operations, decimal numbering, plan indexing | | `phases-command-router.cjs` | Thin CJS subcommand router adapter for `gsd-tools phases` | | `plan-scan.cjs` | Canonical phase-plan scanner — shared helper for detecting plan and summary files in flat and nested layouts (k014); consumed by state, roadmap, init, and workstream inventory paths | -| `project-root.generated.cjs` | GENERATED — CJS artifact emitted from `sdk/src/project-root/index.ts` via `sdk/scripts/gen-project-root.mjs`; resolves a project root from a starting directory using four heuristics (own `.planning/` guard, `sub_repos` config, `multiRepo` flag, `.git` heuristic); do not edit directly | | `planning-workspace.cjs` | Planning path/workstream seam (`planningDir`, `planningPaths`, active-workstream routing, `.planning/.lock` orchestration) | +| `project-root.generated.cjs` | GENERATED — CJS artifact emitted from `sdk/src/project-root/index.ts` via `sdk/scripts/gen-project-root.mjs`; resolves a project root from a starting directory using four heuristics (own `.planning/` guard, `sub_repos` config, `multiRepo` flag, `.git` heuristic); do not edit directly | | `profile-output.cjs` | Profile rendering, USER-PROFILE.md and dev-preferences.md generation | | `profile-pipeline.cjs` | User behavioral profiling data pipeline, session file scanning | | `review-reviewer-selection.cjs` | Reviewer selection/normalization helpers for `/gsd-review` default reviewer policy and precedence |