refactor: route repo-root resolution through shared helper (57 files)#86
Merged
Conversation
Sweep follow-up to #84. 57 modules each baked an identical `const REPO_ROOT = process.env.CUE_REPO_ROOT ?? SOUL_REPO_ROOT ?? resolve(<import.meta>)` plus derived `const SKILLS_ROOT/PROFILES_DIR/...` off it. Replace each with the shared lazy repoRoot() from src/lib/repo-root.ts (added in #84). Behavior-preserving: repoRoot() returns the same value the bake would, and its fallback is the canonical repo root regardless of caller location. Derived consts become join(repoRoot(), ...) — eager, same as before; the #84 hot modules remain fully lazy. Net -72 LOC (kills 57 duplicated env-reads → one source of truth). Three files already declared a local `repoRoot` (different identifier); the import is aliased to cueRepoRoot there. score.ts's REPO_ROOT was dead code and is dropped. Excluded: status.ts + skill-dependencies.ts (fleet is editing them), launch.ts (inline reads, fleet-touched), dashboard-server.ts (env-free by design). typecheck + biome lint clean; full suite 1360 pass, 0 fail.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Mechanical sweep following #84. 57 modules each duplicated the same baked
const REPO_ROOT = process.env.CUE_REPO_ROOT ?? SOUL_REPO_ROOT ?? resolve(<import.meta>)plus derived consts. Each now imports the shared lazyrepoRoot()fromsrc/lib/repo-root.ts(added in #84). Net −72 LOC — kills 57 copies of the env-read in favor of one source of truth.Transform (codemod, then verified)
REPO_ROOT→repoRoot()(derived consts becomejoin(repoRoot(), …)— same eager eval timing as before, zero behavior change).node:path/node:urlimports.repoRoot(different identifier) → import aliased tocueRepoRootthere (profile-linter.ts,skill-quality.ts,profile-generator.ts).score.ts: itsREPO_ROOTwas dead code — removed entirely.Correctness (why it's safe)
repoRoot()'s fallback is anchored torepo-root.ts's own location → always the canonical repo root, independent of caller depth. Verified equivalent even for the depth-1src/index.ts(oldresolve(HERE,"..")fromsrc/= repo root; new = repo root)./\bREPO_ROOT\b/g— independent review confirmed zero string/comment contamination.Excluded (intentional)
status.ts+skill-dependencies.ts(fleet actively editing — avoids conflicts),launch.ts(inline reads, fleet-touched),dashboard-server.ts(env-free, location-locked by design). ~15 other non-matching-pattern files remain for a future pass.Verification
typecheck exit 0 · biome lint exit 0 (10 pre-existing warnings, 0 errors) · full suite 1360 pass / 0 fail. Independent review: DONE, no CRITICAL/HIGH, no blockers.