Repository navigation
ci: harden the doc extractors, and give skill discovery one predicate #548
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 5 commits
89c054a
31635ca
c806443
115ebfe
c67cac9
2de2c84
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -952,8 +952,25 @@ function dryRunRecipe(src) { | |
| const blocks = []; | ||
| let current = null; | ||
| for (let i = 0; i < lines.length; i++) { | ||
| if (masked[i]) (current ??= []).push(lines[i]); | ||
| else if (current) { | ||
| if (masked[i]) { | ||
| (current ??= []).push(lines[i]); | ||
| // fenceMask marks DELIMITER lines true, so two fences butted together | ||
| // with no prose between them form one contiguous masked run — and a | ||
| // merged block let an example fence's `for` loop stand in for the | ||
| // recipe's (or mask an omission in it). A bare closing delimiter | ||
| // followed immediately by an opening one is the seam between fences; | ||
| // split there. CommonMark says a closing fence has no info string, | ||
| // which is what distinguishes the pair. | ||
| if ( | ||
| /^\s{0,3}(?:`{3,}|~{3,})\s*$/.test(lines[i]) && | ||
| current.length > 1 && | ||
| masked[i + 1] && | ||
| /^\s{0,3}(?:`{3,}|~{3,})\S*/.test(lines[i + 1] ?? '') | ||
|
|
||
| ) { | ||
| blocks.push(current.join('\n')); | ||
| current = null; | ||
| } | ||
| } else if (current) { | ||
| blocks.push(current.join('\n')); | ||
| current = null; | ||
| } | ||
|
|
@@ -972,13 +989,40 @@ function dryRunRecipe(src) { | |
| * `echo "bestax-mcp is released separately"` satisfies it just as well, which | ||
| * is the same failure one step further out. | ||
| */ | ||
| function recipeTargets(block) { | ||
| export function recipeTargets(block) { | ||
| const commands = block | ||
| .split('\n') | ||
| .map(l => l.replace(/#.*$/, '')) | ||
| .join('\n'); | ||
| const loop = commands.match(/\bfor\s+\w+\s+in\s+([^;\n]+)/); | ||
| return loop ? loop[1] : commands; | ||
| .join('\n') | ||
| // A backslash continuation is one shell word-list across lines. Without | ||
| // the join, `for pkg in a b \\<newline> c d` counted only the first | ||
| // line's names and falsely reported the wrapped-onto ones missing. | ||
| .replace(/\\\n\s*/g, ' '); | ||
| // The loop that RUNS the release is the one whose word list counts. | ||
| // First-only missed a legitimate second release loop; union-of-all was the | ||
| // opposite failure — a preliminary loop over every package (an echo, an | ||
| // owner check) covered an omission in the loop that actually invokes the | ||
| // dry run. Segments are for…done spans; only those whose body mentions the | ||
| // release command contribute, falling back to all loops when none does, so | ||
| // a recipe driving the run through a variable stays a presence check | ||
| // rather than a false red. | ||
| const segments = [ | ||
| ...commands.matchAll(/\bfor\s+\w+\s+in\s+([^;\n]+)[\s\S]*?\bdone\b/g), | ||
| ]; | ||
| if (!segments.length) return commands; | ||
| // A mention has to look like an INVOCATION: a preliminary loop that merely | ||
| // echoes the command name (a progress banner, a dry-run preview) must not | ||
| // be classified alongside the loop that runs it (#548 review). | ||
| const invokes = seg => | ||
| seg | ||
| .split('\n') | ||
| .some( | ||
| l => | ||
| /\bsemantic-release\b/.test(l) && | ||
| !/^\s*(?:echo|printf)\b/.test(l.trim()) | ||
| ); | ||
| const release = segments.filter(m => invokes(m[0])); | ||
| return (release.length ? release : segments).map(m => m[1]).join(' '); | ||
|
coderabbitai[bot] marked this conversation as resolved.
Resolved
|
||
| } | ||
|
|
||
| /** | ||
|
|
@@ -1004,10 +1048,31 @@ function packagesBullet(src) { | |
| // section's own sentence anchoring the search, so the list still passed | ||
| // while the section it belongs to was gone. Requiring a heading also makes | ||
| // anchor..limit a real section rather than an arbitrary span. | ||
| const anchor = lines.findIndex( | ||
| (l, i) => | ||
| !masked[i] && /^\s{0,3}#{1,6}\s/.test(l) && /trusted[- ]publish/i.test(l) | ||
| ); | ||
| // Of the headings that mention trusted publishing, anchor on the one whose | ||
| // section actually CONTAINS the bullet. First-match anchoring meant a new | ||
| // earlier heading (a changelog note, a blog-ish aside) captured the search | ||
| // and produced a false "no \`- Packages:\` line" while the real section was | ||
| // intact. A heading with no bullet in its span still anchors when it is the | ||
| // only candidate, so "section exists but lost its list" stays a violation. | ||
| const candidates = []; | ||
| for (let i = 0; i < lines.length; i++) { | ||
| if ( | ||
| !masked[i] && | ||
| /^\s{0,3}#{1,6}\s/.test(lines[i]) && | ||
| /trusted[- ]publish/i.test(lines[i]) | ||
| ) { | ||
| candidates.push(i); | ||
| } | ||
| } | ||
| const owns = idx => { | ||
| for (let i = idx + 1; i < lines.length; i++) { | ||
| if (!masked[i] && /^\s{0,3}#{1,6}\s/.test(lines[i])) return false; | ||
| if (!masked[i] && lines[i].trimStart().startsWith('- Packages:')) | ||
| return true; | ||
| } | ||
| return false; | ||
| }; | ||
| const anchor = candidates.find(owns) ?? candidates[0] ?? -1; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win Keep lower-level headings inside the trusted-publishing section.
Stop only at a heading with the same or higher level than the candidate heading. Apply the same boundary rule to the later 🤖 Prompt for AI Agents |
||
| // No OIDC section means no trusted-publisher list, which is the violation. | ||
| // Falling back to line 0 restored the file-wide search this extractor exists | ||
| // to prevent: an unrelated "- Packages:" bullet elsewhere then satisfied the | ||
|
|
@@ -1037,7 +1102,11 @@ function packagesBullet(src) { | |
| // named there could then cover an omission in this list. | ||
| let end = limit; | ||
| for (let i = start + 1; i < limit; i++) { | ||
| if (!lines[i].trim() || /^\s*[-*]\s/.test(lines[i])) { | ||
| // A masked line ends the bullet too: a fenced example butted directly | ||
| // under the list (no blank line) was swept into the bullet text, and a | ||
| // package named in the example then covered an omission in the list — | ||
| // the fail-open whose cost this check itself documents. | ||
| if (!lines[i].trim() || /^\s*[-*]\s/.test(lines[i]) || masked[i]) { | ||
| end = i; | ||
| break; | ||
| } | ||
|
|
@@ -1223,6 +1292,14 @@ export async function publishablePackages(root = REPO) { | |
| let pkg; | ||
| try { | ||
| pkg = JSON.parse(await readFile(join(root, dir, 'package.json'), 'utf8')); | ||
| // JSON.parse succeeds on `null`, `42`, `"x"`, `[]` — shapes a truncated | ||
| // write really produces. `null` dereferenced below threw a TypeError | ||
| // past the runner's loop; an ARRAY passes typeof and instead vanishes | ||
| // silently (no name, so it never joins the package list) — the same | ||
| // outcome by a quieter road. Both are unreadable manifests. | ||
| if (!pkg || typeof pkg !== 'object' || Array.isArray(pkg)) { | ||
| throw new Error('not an object'); | ||
| } | ||
| } catch { | ||
| unreadable.push(dir); | ||
| continue; | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.