Skip to content

refactor(ai-briefing): simplify generate build emit, parse and run code - #14532

Merged
kyle-sexton merged 1 commit into
mainfrom
work-resolve-issue/issue-14388-42595351213-1
Nov 9, 2026
Merged

kyle-sexton merged 1 commit into
mainfrom
work-resolve-issue/issue-14388-42595351213-1

Conversation

@melodic-automation-lanes

Copy link
Copy Markdown
Contributor

Closes #14388

Summary

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

Simplified five of the ten listed ai-briefing build files without changing what they output, print or export. emit-slides.js merges tierSlides' split and single-slide branches into one chunked map, sorts with the stable built-in toSorted in place of index tracking, appends tiers through one helper, and stamps news sections through one pushNews helper. parse-briefing.js shares one ISO-date regex and one year-month-day helper, flushes H2 sections through one closure, and runs both date fallbacks through one first-URL lookup. run.js builds its task list as one filtered array with one rule constant; brand-overlay.js and emit-slides-data.js lose a redundant fallback and a wrapped ternary. paths.js, provider-logos.js, schema.js, url-display.js and url-policy.js were reviewed and left as they are: they had nothing to simplify inside their own file, and moving code between files is out of scope.

Not verified

  • node --test suite for the build directory (parse-briefing, schema, window, cli-entry, brand-overlay and others) not executed: this lane runs no interpreter; left to the PR's CI
  • lint and build of the touched JS files not run here (no interpreter); left to the PR's CI
  • tidy-diff passes 4-5 (write-for-humans, ai-slop fix) skipped for the changelog fragment: its only line is the exact text the issue prescribes, so a rewrite would break that acceptance criterion
  • ci-status green on the PR is a CI check this run cannot observe

Fix

  • plugins/ai-briefing/skills/generate/output/build/lib/emit-slides.js: tierSlides builds chunks then maps them to slides with one title rule; sortItemsByDate uses stable toSorted; sortTiersByDate iterates one key list; the tier normalization uses an append helper; news slides are stamped and pushed…
  • plugins/ai-briefing/skills/generate/output/build/lib/parse-briefing.js: rest text built with map/join; shared ISO_DATE regex and ymdMatchToMs helper; firstUrlDate helper for both date fallback passes; flushBucket closure replaces three copies of the section flush; ??= for tier init
  • plugins/ai-briefing/skills/generate/output/build/run.js: RULE constant for the separator; task list as one array filtered by the skip flags
  • plugins/ai-briefing/skills/generate/output/build/lib/brand-overlay.js: dropped redundant ?? {} before object spread
  • plugins/ai-briefing/skills/generate/output/build/emit-slides-data.js: outPath ternary on one line
  • .changes/ai-briefing/work-resolve-issue-issue-14388-42595351213-1-68b61c67.md: patch fragment, ### Changed, "Internal simplification, no behavior change."

Verification

The runner ran each check from the base copy against 6a04425:

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

The run reports:

  • check-changelog-fragments: all 4 fragments valid (run before and after tidy)
  • check-changed-skills: CHECK-SKILL generate PASS, 0 errors, 3 pre-existing warnings (run before and after tidy)
  • check-affected: 12 passed, 7 skipped, 0 failed over 6 changed files (run before and after tidy)
  • fresh-context review subagent over the whole diff: no behavior difference found for any input the callers supply (checked chunk boundaries, sort order and stability, sorted key sets, slide key order, builder call order, run.js argv defaults)
  • tidy-diff over the 33 changed hunks: no edits needed in passes 1-3
  • The lane run: https://github.com/melodic-software/claude-code-plugins/actions/runs/42595351213

Left out: the items under Not verified.

Related

#14388

Lane-Activity: work-resolve-issue/resolve-issue
@melodic-automation-lanes

Copy link
Copy Markdown
Contributor Author

Unattended merge: native auto-merge leaves this pull request unarmed at head 6a04425c15cd43597d9282bebbeecb25f7041594. The lanes clear this reason on their own; the next scheduled run judges it again.

pr-merge's gate refuses its verifier verdict (verify:missing)

@github-actions

github-actions Bot commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

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

Security review: PR #14532 (head 6a04425)

I found no security issues. I read every hunk of all 6 changed files in .claude-lane/pr.diff.

What changed. The PR is a behavior-preserving refactor of the local deck-build pipeline under plugins/ai-briefing/skills/generate/output/build/, plus a changelog fragment that bumps the patch version.

  • emit-slides.js: the tier chunking, sorting (now toSorted), tier append and news-slide stamping are restructured.
  • parse-briefing.js: the ISO-date regex and the year-month-day helper are shared, there is one section-flush closure, and both date fallbacks use one first-URL lookup.
  • run.js: the task list is now one filtered array.
  • brand-overlay.js: the redundant ?? {} before the object spread is gone.
  • emit-slides-data.js: the outPath ternary is on one line.

What I checked.

  • Subprocesses. run.js still runs fixed, in-repository script names through spawnSync(process.execPath, [...]) with no shell. Only the emit step gets the user's passthrough args, same as before. When the other tasks leave args undefined, step's default args = [] applies.
  • Output path. emit-slides-data.js handles --out as before (path.resolve(args.out), only the formatting changed). The operator supplies it locally, so it is not an untrusted input.
  • Brand overlay. brand-overlay.js still validates the overlay with overlaySchema.parse before spreading it. Logo keys still go through resolveLogo. Spreading undefined is a no-op, so nothing new can get in.
  • Date parsing. The parse-briefing.js regex is identical to the base regex (now hoisted into the ISO_DATE const). The malformed-URL try/catch around new URL in dateFromUrl is unchanged.
  • Scope. No workflow, manifest (plugin.json / marketplace.json), trust control, merge hold, token request or instruction surface is touched. None of the changed files matches a listed trusted path.

Embedded text. The PR context file holds no directive aimed at this lane.

Prior findings. This lane has not reviewed an earlier head (0 earlier heads, blocking only: no), so this was a full review.

Spend. None. The change starts no charge and spends no extra credits.

critical-findings: 0

@github-actions

github-actions Bot commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

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

Code review: PR #14532, simplify the ai-briefing generate build code (closes #14388)

I read every hunk in all 6 changed files. I also read the head versions of parse-briefing.js, run.js and the changed part of emit-slides.js, plus brand-overlay.js's overlay schema and the build's package.json engines. I checked each rewrite against the base code and found no change in behavior:

  • tierSlides: items.length <= cap always gives exactly one chunk, which uses baseTitle. Anything over the cap gives two or more chunks with the same part titles as before. The empty case still returns [] early.
  • sortItemsByDate: toSorted is stable and the build requires Node.js 24 or later (engines.node >=24), so it is available. The comparator (b.date == null) - (a.date == null) puts undated items first and keeps undated items in source order. Ties and the newest-first order match the old index-tracking sort.
  • sortTiersByDate: dropping if (!data) continue is safe, because normalized[key] ??= {} always stores an object. The sorted key sets are the same: high, med, low and _items, plus every raw key for dev-tools.
  • Tier normalization and pushNews: the routing order, the builders' call order, and the slide order and section stamps are unchanged. The new if (!s) continue covers the old if (patterns), if (pace) and if (breaking) guards.
  • parse-briefing.js:
    • item.urls is always an array (allLinks or the nested-URL merge), so dropping || [] is safe.
    • extractDate returns a number or null, so ??= gives the same final values.
    • ISO_DATE has no g flag, so match keeps no state between calls.
    • The ISO_DATE const is defined after extractDate, but nothing calls extractDate until the module has loaded.
    • flushBucket resets currentBucket and bucketChildren the same way the inlined copies did.
    • map().join("") matches the old concatenation, since every segment's value and url is a string.
  • brand-overlay.js: brand and theme are .optional(), and spreading undefined is a no-op.
  • run.js: tasks that omit args fall back to step's default []. The printed separators are the same.

I ran nothing: this lane has no interpreter. The PR's test-suite, lint and check-script results are the author's claims and I have not verified them.

Closing issue #14388, acceptance criteria

  • "The diff edits only the listed files … and changelog fragments": met. The 5 source files are on the issue's list, and the sixth file is a changelog fragment.
  • "within 400 changed lines and 15 hand-edited files": met (about 140 changed lines, 5 hand-edited files).
  • Fragment with ### Changed and "Internal simplification, no behavior change.": met. .changes/ai-briefing/…68b61c67.md has bump: patch and the exact line.
  • "ci-status is green": this lane cannot see CI.
  • Finding (advisory): "Behavior is unchanged: same outputs …". The code meets this, but no test could catch a regression in the most heavily rewritten logic. test/ has no test for emit-slides.js: nothing checks the tierSlides chunk titles, the sortItemsByDate ordering, or the news-section stamping. parse-briefing.test.js also never checks the URL and seenUrlDateMap date fallbacks that were moved into firstUrlDate. For example, a comparator that sorted undated items last, or a cap off by one, would still pass every existing test. The issue puts new tests out of scope for this chunk, so this is a gap to record as a follow-up, not a blocker.

No settled threads and no prior findings applied; this is the first review of this PR. No plugin manifest changed. No embedded instructions were found in the PR context. Nothing here can cost money, so there is no hold.

@kyle-sexton
kyle-sexton added this pull request to the merge queue Nov 9, 2026
Merged via the queue into main with commit 55f9807 Nov 9, 2026
50 checks passed
@kyle-sexton
kyle-sexton deleted the work-resolve-issue/issue-14388-42595351213-1 branch November 9, 2026 11:41
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 generate ai-briefing plugin code (2 of 3)

1 participant