Skip to content

fix(ci-inference): read nested package-manager calls like top-level ones - #198

Closed
FredApps wants to merge 4 commits into
DiffCI:mainfrom
FredApps:fix/ci-inference-nested-pm-verbs
Closed

FredApps wants to merge 4 commits into
DiffCI:mainfrom
FredApps:fix/ci-inference-nested-pm-verbs

Conversation

@FredApps

@FredApps FredApps commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #197

Changed behavior

resolveScript now finds each npm run, yarn or pnpm call in a script body and reads it up to the next shell separator with packageManagerCommand, the same grammar infer.ts uses for top-level steps:

  • install verbs (install, i, add, ci, …) and a bare yarn are installs, not script references;
  • builtins (why, exec, dlx, …) are not script references;
  • flags are skipped, so pnpm -r build and npm run -s build reference build.

A missing nested script is still UNRESOLVED.

Validation

Unsupported cases

  • yarn <bin> (for example yarn tsc) is still read as a script reference and is unresolved when no such script exists. Top-level steps behave the same way.
  • Bare npm test / npm start inside a script are still not followed, as before.
  • This touches the same loop as fix(ci-inference): only an ancestor script makes a cycle #188 (diamond scripts), so whichever lands second needs a small main merge.

Includes #188. Both change the nested-script loop in resolveScript, and this PR already carried #188's fix (each nested call gets new Set(seen)). This branch merges #188 in, which adds its diamond test, so #188 and this PR merge in either order, or this PR alone (GitHub then marks #188 as merged).

resolveScript shared one seen set across sibling branches, so a script
reached twice (ci runs build and test, test runs build) was reported as a
cycle and the step was left not executable. Each nested call now gets its
own copy of its ancestors.

Fixes DiffCI#187

Signed-off-by: FredApps <[email protected]>
resolveScript found nested scripts with a regex that took the word after a
bare yarn or pnpm as a script name, so yarn install, pnpm add, yarn why and
flags such as -r or -s became missing scripts. Each nested call is now read
with packageManagerCommand, the grammar the top-level step already uses.

Fixes DiffCI#197

Signed-off-by: FredApps <[email protected]>
…verbs

Each nested resolveScript call now gets a copy of its ancestors, as in DiffCI#188.
A script reached twice through different branches is not a cycle. Without
this copy, merging this branch after DiffCI#188 would bring that bug back.

Signed-off-by: FredApps <[email protected]>

@FredApps FredApps left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cross-review (Yandere-san). Head 166d94b (includes my follow-up).

Checked: nestedScriptNames uses packageManagerCommand, so yarn install, pnpm add, builtins and flags (-r, -s, npm run -s) are not treated as script names. The original three tests fail on main and pass here.

This loop is the same one #188 changes. On 374b04a, #188's diamond test still failed (script cycle through build). I pushed 166d94b: each nested call now gets new Set(seen), plus a diamond test, so this branch no longer undoes #188 if it merges second. tests/ci-inference/*.test.ts pass locally after that (80). Hosted CI is re-running on 166d94b.

Nothing further open.

@FredApps

Copy link
Copy Markdown
Contributor Author

CI follow-up: 166d94b is green (12 success, change-impact neutral on the fork).

…n either order

Both change the nested-script loop in resolveScript; this PR already carried DiffCI#188's fix (each nested call gets new Set(seen)). Merging DiffCI#188 in adds its diamond test and lets GitHub merge DiffCI#188 and this PR in either order, or this PR alone.

Signed-off-by: FredApps <[email protected]>
@FredApps
FredApps marked this pull request as ready for review November 18, 2026 01:15
@adityankale190895

Copy link
Copy Markdown
Member

Thanks for this one. #188 is now in main as a squash commit, so GitHub no longer sees that this branch already contains it, and it reports a conflict in src/ci-inference/resolve.ts.

Could you merge main into this branch? Keeping this branch's version of resolve.ts resolves it; after that the diff against main is just this PR's change. We tested this PR together with the rest of the CI-inference batch, and it passed, so I'll merge it as soon as CI is green.

For later PRs that include other PRs (for example #258 with #232, #248, #250 and #254), I'll merge the combined PR by itself so this doesn't happen again.

adityankale190895 pushed a commit that referenced this pull request Nov 18, 2026
…nes (#198)

yarn install, pnpm install and flags before a script name inside a
package.json script were read as nested script names and left the
command unresolved. Nested calls now go through the same parser as
top-level ones. Fixes #197.

Signed-off-by: FredApps <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
@adityankale190895

Copy link
Copy Markdown
Member

Merged to main as 5b293ce (squashed, authorship kept). I resolved the conflict with #188 by taking your nestedScriptNames loop, and dropped the diamond test from script-pm-verbs because main already has it in script-diamond.test.ts. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CI inference: yarn install, pnpm install and flags inside a package.json script are read as script names

2 participants