Read the repo-root build path, and stop overstating what a flip forbids

Two findings from Greptile on #579, both about the same key seen from
different roots.

`appendBuildPathDirective` searched projectRoot and cwd but never repoRoot,
while `checkBuildPathUnset` reads both. In a monorepo that committed the
preference once at the root, the two disagreed in the worst direction: the
staleness finding stayed silent because a value existed, and the directive
never named it, so nothing on screen explained why the recorded default was
not being honored. Roots are now ordered nearest first, workspace over repo
root, with regression tests for both the fallback and the override.

The ANSWER line for a flipped path said "never write it to settings". The
page indeed never writes it, but the sentence read as a rule and applied
itself to new-work's one-time offer, which exists for exactly the case a flip
creates: a project with no recorded default, asked once after the round
closes. It now states what the page does and names the exception.

The same report's first issue also named context.mjs, and that part does not
hold: its directive is emitted only when a value is already recorded, which is
precisely when session-only is the correct instruction. Left as is.

Written with AI assistance (Claude Code).

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Paul Bakaus
2026-08-13 22:20:19 -04:00
co-authored by Claude Opus 5
parent 65de2d294b
commit c0e7f2d778
3 changed files with 43 additions and 2 deletions
+8 -1
View File
@@ -1299,8 +1299,15 @@ function readBuildPathAt(root) {
return value ? { value, source } : null;
}
// Roots in precedence order, nearest first: the active workspace decides, and
// the repo root is the fallback a monorepo commits once for every app in it.
// `checkBuildPathUnset` already reads both, so leaving repoRoot out here made
// the two disagree: the finding stayed silent because a value existed while the
// directive never named it, which is the one combination nobody can debug.
function appendBuildPathDirective(parts, ctx) {
const roots = [...new Set([ctx?.projectRoot, process.cwd()].filter(Boolean).map((root) => path.resolve(root)))];
const roots = [...new Set(
[ctx?.projectRoot, process.cwd(), ctx?.repoRoot].filter(Boolean).map((root) => path.resolve(root)),
)];
for (const root of roots) {
const found = readBuildPathAt(root);
if (!found) continue;