Skip to content

refactor(scripts): simplify validate-plugin-contracts.mjs and validate-plugins.sh - #14531

Merged
melodic-automation-lanes[bot] merged 1 commit into
mainfrom
work-resolve-issue/issue-14369-42595269158-1
Nov 9, 2026
Merged

melodic-automation-lanes[bot] merged 1 commit into
mainfrom
work-resolve-issue/issue-14369-42595269158-1

Conversation

@melodic-automation-lanes

@melodic-automation-lanes melodic-automation-lanes Bot commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

Closes #14369

Summary

Opened by the work-resolve-issue lane. The run's own summary:

Took repeated code in validate-plugin-contracts.mjs out into small shared helpers. warn() matches fail(); frontmatterOf() and afterFrontmatter() replace six inline copies of the frontmatter regex and the body slice. The plugin.json manifest filter now runs once into pluginManifests, used by three loops. marketplace.json is parsed once into catalogEntries instead of three times, and pluginPathParts() is reused where one copy of its expression was inlined. validate-plugins.sh gets a usage() function in place of two copies of the usage message. Each check still runs in the same order, so failures, warnings, exit codes and flags are unchanged. A fresh-context review of the diff found no behavior difference.

Not verified

  • scripts/validate-plugin-contracts.test.sh and scripts/validate-plugins.test.sh were not run: this lane runs no interpreter, so they are left to the PR's CI
  • tidy skipped: the change is under scripts/, a shared path the tidy cutoffs exclude
  • no changelog fragment: the change touches only repository scripts, not a plugin

Fix

  • scripts/validate-plugin-contracts.mjs: added warn(), frontmatterOf() and afterFrontmatter() helpers and moved the warnings array next to failures; added the pluginManifests list (used by the default-component-path, option-naming and claude.ai-sync loops) and catalogEntries (one marketplace.json…
  • scripts/validate-plugins.sh: one usage() function replaces the two copies of the usage message and exit 2

Verification

The runner ran each check from the base copy against ac8a44d:

  • scripts/check-changelog-fragments.sh --check: passed
  • scripts/check-changed-skills.sh --merge-base: passed

The run reports:

Left out: the items under Not verified.

Related

#14369

Merge-Risk: max=MEDIUM demote=false head=ac8a44dd940a1e7db0944a759908350f460887b9 rubric=8.1.3 rater=claude-opus-5-5 checker=claude-opus-5-5

Lane-Activity: work-resolve-issue/resolve-issue
@github-actions

github-actions Bot commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

claude-review reviewed ac8a44dd940a1e7db0944a759908350f460887b9: read 2 of 2 changed file(s); 0 finding(s), 0 as inline comments.

I found no correctness or maintainability problems. This is a full review of both changed files, scripts/validate-plugin-contracts.mjs and scripts/validate-plugins.sh, read hunk by hunk against the code they touch at head.

Behavior-equivalence checks (done by reading the code; I ran nothing):

  • warnings now sits at module top. Under the old placement (around line 1288), any earlier read would have thrown a TDZ error. The only other uses are line 1465 and the print at line 1606, so output order and content are unchanged.
  • warn(path, msg) builds the same ${relative(root, path)}: ${msg} string as the inline warnings.push calls it replaces. optionWarn keeps its (${OPTION_NAMING_DOC}) suffix.
  • frontmatterOf() uses the same regex and returns undefined where the old code had null or undefined.
    • The agent skills: loop (body === undefined → continue) and the preload target check (!== undefined) keep their old branch logic.
    • The ?? "" call sites and the SKILL.md === undefined check are unchanged.
  • afterFrontmatter() is the same slice(indexOf("---", 3) + 3) expression.
  • pluginManifests is the same filter over pluginFiles, which is never mutated, so the three manifest loops visit the same files in the same order.
  • catalogEntries parses marketplace.json once, at the spot the first parse ran before, so a parse error still throws at the same point. No loop mutates the shared entries.
    • The displayName check (?? []) and the core-entry check (!== null) keep their old existsSync gating.
  • pluginPathParts(path) is exactly relative(pluginRoot, path).split(sep) (line 113).
  • githubTest resolves to the same path.
  • usage() in validate-plugins.sh runs in the main shell, not a subshell, so exit 2 still ends the script. The message text and stderr target are unchanged, and the cases in scripts/validate-plugins.test.sh lines 24–26 still match.

Closing issue #14369, acceptance criteria:

  • "Behavior is unchanged…": met, per the checks above. The existing suites scripts/validate-plugin-contracts.test.sh and scripts/validate-plugins.test.sh cover the warning text, usage errors and frontmatter paths. The PR says it did not run them and leaves them to CI.
  • "The diff edits only the listed files…": met. Only the two listed files change.
  • "within 400 changed lines and 15 hand-edited files": met. Two files, well under 400 lines.
  • "ci-status is green": can't be checked from this lane. It rests on CI, and the PR's verification lines are the author's claims, not checked here.

Paved paths and path-scoped rules: nothing applied. Neither changed file is a plugin manifest, so there are no manifest lines.

@github-actions

github-actions Bot commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

claude-security-review reviewed ac8a44dd940a1e7db0944a759908350f460887b9: read 2 of 2 changed file(s); 0 finding(s), 0 as inline comments.

Security review: PR #14531

I found no security issues.

Scope: I read every hunk of both changed files, scripts/validate-plugin-contracts.mjs and scripts/validate-plugins.sh. Neither file matches a trusted-path glob. Neither is a trust control from the skill's list: not the trusted-trigger check, the token broker, the kill switch, a merge hold, or another action under .github/actions/. The diff changes no plugin manifest and no standing instruction.

What I checked: whether the refactor weakens a check the validator enforces, in particular the marketplace source pin requirement, the ban on displayName in plugin entries, the rule that core sets defaultEnabled: false, and the setup-skill and agent skills: checks.

  • Frontmatter helpers. frontmatterOf() uses the same regex as the inline copies it replaces. Callers that used ?? "" still do. The agent loop's if (!frontmatter) continue became if (body === undefined) continue. Both skip the same files, because a successful match always has a string capture.
  • Body slice. afterFrontmatter() is the same content.slice(content.indexOf("---", 3) + 3) expression.
  • Path parts. pluginPathParts(path) is relative(pluginRoot, path).split(sep) (
    function pluginPathParts(path) {
    return relative(pluginRoot, path).split(sep);
    }
    ), the exact expression it replaces.
  • Manifest list. pluginManifests uses the same endsWith(sep + ".claude-plugin" + sep + "plugin.json") filter as the three loops it now feeds.
  • Marketplace parse. catalogEntries is parsed at the same point in the script as the original first parse. It is null only when marketplace.json is missing, so the pin check, the displayName check and the core defaultEnabled check still run under the same conditions. Parsing once does not change what is checked.
  • Warnings. The warnings array is now declared earlier, and warn() produces the same message format. That affects only warning output, never failures or the exit code.
  • validate-plugins.sh. usage() prints the same message and exits 2 on both paths. The plugin-name validation for --only (^[A-Za-z0-9._-]+$ plus a directory check) is unchanged.

The PR description contains no text directed at this review lane.

Prior findings: none. This was a full review, not blocking only.

critical-findings: 0

@melodic-automation-lanes

Copy link
Copy Markdown
Contributor Author

The unattended merge path armed native auto-merge at head ac8a44dd940a1e7db0944a759908350f460887b9, the head its arming checks judged.

@melodic-automation-lanes

Copy link
Copy Markdown
Contributor Author

Verification evidence for ac8a44d

The verifier passed this head. The capture artifact holds the capture summary, which says whether the capture ran, and any screenshot or video that passed the mask check; this comment uploads no file.

Capture artifact: pr-capture-14531-ac8a44dd940a1e7db0944a759908350f460887b9, expires on 2026-12-09.

One comment per pull request, updated in place for each new head.

@melodic-automation-lanes
melodic-automation-lanes Bot added this pull request to the merge queue Nov 9, 2026
Merged via the queue into main with commit 3edf1ef Nov 9, 2026
64 checks passed
@melodic-automation-lanes
melodic-automation-lanes Bot deleted the work-resolve-issue/issue-14369-42595269158-1 branch November 9, 2026 10:28
@melodic-automation-lanes

Copy link
Copy Markdown
Contributor Author

The post-merge check verified merge commit 3edf1efe928630ddf8c01406519abce1af7c5733; later checks count it verified from this comment.

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.

Simplify the validate-plugin-contracts.mjs and validate-plugins.sh repository scripts

0 participants