Skip to content

refactor(knowledge): simplify course-digest extraction adapters and CLIs (1 of 3) - #15219

Merged
melodic-automation-lanes[bot] merged 1 commit into
mainfrom
work-resolve-issue/issue-14597-42929575836-1
Nov 11, 2026
Merged

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

Conversation

@melodic-automation-lanes

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

Copy link
Copy Markdown
Contributor

Closes #14597

Summary

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

Simplified five of the nine listed course-digest extraction files with no behavior change. discover-resources.js now uses the existing lib/player-presence.js hasPlayerElement helper in place of an identical inline page.evaluate. The other edits drop single-use locals, collapse needless async wrappers around timed() callbacks, destructure in place, fold three JSON-LD date copies into one loop, and drop a redundant trim before parseInt. adapter-contract.js, auth-session.js, registry.js and classify-frames.js were reviewed and left unchanged: they had no cleanup that was both behavior-preserving and in scope. For example, pngs.map(basename) would pass the index as basename's suffix argument and throw. Cross-file dedup, such as the shared navigate-then-check-player auth sequence, is left to the sub-epic's restructuring pass, as the issue scopes it.

Not verified

  • vitest suites for plugins/knowledge (cli-entry.test.js, cli-browser-artifacts.test.js, adapters/*.test.js): this lane cannot run a test runner, so they are left to the PR's CI
  • Build and lint (biome) of the touched JS files were not run here: the lane allows no node or biome invocation. Left to the PR's CI
  • ci-status green: a PR CI check, left to the PR's CI
  • Tidy passes 4 and 5 (write-for-humans, ai-slop fix) skipped on the changelog fragment: its text is fixed word for word by the issue's acceptance criterion. Code passes 1-3 ran with no further edits; the one comment added in the change (analyze-code-repo.js parseInt rationale) was triaged class C…

Fix

  • plugins/knowledge/skills/course-digest/extraction/adapters/dometrain.js: buildLessonUrl inlines its single-use local; applyJsonLdMetadata copies the three date keys in one loop (same key order); authenticate uses if/else with one return and inlines the hasPlayer local, keeping the eager config…
  • plugins/knowledge/skills/course-digest/extraction/adapters/teachable.js: detectResources and prepareLessonPage pass expression-bodied callbacks to timed() (throws still land inside timed's try); extractResources destructures articleLinks/textContent in place (same returned key order); authenticate…
  • plugins/knowledge/skills/course-digest/extraction/analyze-code-repo.js: checkRepoSize drops a second stdout.trim() before parseInt (parseInt skips surrounding whitespace) and reflows two calls onto one line each
  • plugins/knowledge/skills/course-digest/extraction/build-course-json.js: scrapeCurriculumInBrowser inlines the heading, fullText and title locals and builds the duration with destructuring plus a ternary instead of a let/if block; the function still references only its own locals and parameters, so…
  • plugins/knowledge/skills/course-digest/extraction/discover-resources.js: auth check reuses hasPlayerElement from ./lib/player-presence.js (same evaluate source and catch-to-false); discoveryCtx literal on one line and checked read by destructuring
  • .changes/knowledge/work-resolve-issue-issue-14597-42929575836-1-20b43e6b.md: new patch fragment for knowledge with '### Changed' and 'Internal simplification, no behavior change.'

Verification

The runner ran each check from the base copy against 1a78c85:

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

The run reports:

  • check-changelog-fragments: all 17 fragments valid (run before and after tidy/review fixes)
  • check-changed-skills: course-digest PASS, 0 errors, 4 pre-existing warnings about SKILL.md size and gotchas, none in touched files
  • check-affected: 12 passed, 7 skipped, over 6 changed files
  • Fresh-context review subagent over the whole diff: no HIGH findings. One LOW finding (dometrain authenticate read authEnvPrefix after navigation instead of before) was fixed by restoring the early read. Two LOW theoretical findings were left: a different TypeError message if scrapeTextAttachments…
  • Read cli-browser-artifacts.test.js stub rules: the 'querySelector(sel)' and 'instructorFragment' source-substring matches still hold for hasPlayerElement and scrapeCurriculumInBrowser
  • Diff size: 5 code files plus 1 fragment, about 130 changed lines, inside the issue's 400-line / 15-file limit
  • The lane run: https://github.com/melodic-software/claude-code-plugins/actions/runs/42929575836

Left out: the items under Not verified.

Related

#14597

Merge-Risk: max=HIGH demote=true head=1a78c85b50739e3e73f0148709014681c91f4f1d rubric=8.4.0 rater=claude-opus-5-5 checker=claude-opus-5-5

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

Copy link
Copy Markdown
Contributor

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

Security review: PR #15219 (complete, 6 of 6 files read)

I found no security issues in this pull request.

This is a behavior-preserving refactor of the knowledge plugin's course-digest extraction scripts, plus a patch changelog fragment. None of the changed files is on a trusted path, a trust control, a plugin manifest or an instruction surface. What I checked:

  • discover-resources.js: the inline auth check page.evaluate((sel) => !!document.querySelector(sel), videoSelector).catch(() => false) now goes through hasPlayerElement. That helper runs the same evaluate with the same catch-to-false (lib/player-presence.js#L22-L24). Failing to detect a player still means "not authenticated", so the check still fails closed.
  • dometrain.js authenticate: the early return became if/else. Both paths still return { baseUrl }, and loginOrPromptManual still runs only when no player is found. envPrefix is still read before navigation, so credential handling is unchanged.
  • teachable.js: the timed() callbacks are now expression-bodied. A rejection still settles inside timed, and the auth gate is unchanged.
  • analyze-code-repo.js: spawnSync("gh", [...]) still passes its arguments as an array with no shell, so there is no new injection surface. Dropping .trim() before parseInt doesn't change the parsed value, and the empty-output guard above it is unchanged.
  • build-course-json.js: these are in-browser scraping simplifications with the same output. Scraped values are only stored as data.
  • Changelog fragment: text only.

There is no embedded instruction text in the PR context. Prior findings: none (0 earlier heads reviewed). This was not a blocking-only review.

critical-findings: 0

@github-actions

Copy link
Copy Markdown
Contributor

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

Code review: no findings. I read every hunk of all 6 changed files.

Each change keeps the old behavior. I checked these against the code at head:

  • discover-resources.js: the new hasPlayerElement call matches the inline code it replaces. lib/player-presence.js:23 runs the same page.evaluate((sel) => !!document.querySelector(sel), selector) and also returns false when the page check fails.
  • teachable.js, timed() callbacks: detectResources and prepareLessonPage now pass plain callbacks instead of async wrappers. That is safe because timed (vendor/video-digestion/shared/result.js:55-63) runs await fn() inside its try. An error thrown at once, such as resolveSubtitleLanguage reading a missing platformCfg, still turns into the same fail(...) result.
  • teachable.js, extractResources: unpacking articleLinks and textContent in place is safe, because scrapeTextAttachments always returns an object with both keys. The returned keys keep their order.
  • dometrain.js: authenticate now uses if/else with a single return { baseUrl }, which gives the same result on both paths. envPrefix is still read before the page loads. The JSON-LD date loop copies the three keys in the same order with the same truthiness check.
  • build-course-json.js: duration is still "" when there is no time match; the ternary keeps the old guard. The function runs in the browser through page.evaluate, and it still uses only its own variables and parameters.
  • analyze-code-repo.js: dropping the extra trim() is safe. parseInt skips leading whitespace and stops at the trailing newline, and the empty-output check before it still trims.

Closing issue #14597, acceptance criteria:

  • Behavior unchanged; no exported names, flags or files renamed: met, per the checks above.
  • Diff edits only the listed files plus fragments: met. All 5 code files are on the issue's list.
  • Within 400 lines and 15 files: met (about 130 lines, 5 code files).
  • Fragment body is ### Changed plus "Internal simplification, no behavior change.": met, with bump: patch.
  • ci-status green: left to CI; I did not check it.

The PR's verification results (the vitest suites, biome, the changelog and skill checks) are the author's claims. I did not run them.

No plugin manifest changed, so there are no manifest lines. No paid usage is involved. The PR context contained no embedded instructions aimed at this review.

@melodic-automation-lanes

Copy link
Copy Markdown
Contributor Author

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

@melodic-automation-lanes

Copy link
Copy Markdown
Contributor Author

Verification evidence for 1a78c85

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-15219-1a78c85b50739e3e73f0148709014681c91f4f1d, expires on 2026-12-11.

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 11, 2026
Merged via the queue into main with commit 95d353c Nov 11, 2026
63 checks passed
@melodic-automation-lanes
melodic-automation-lanes Bot deleted the work-resolve-issue/issue-14597-42929575836-1 branch November 11, 2026 01:27
@melodic-automation-lanes

Copy link
Copy Markdown
Contributor Author

The post-merge check verified merge commit 95d353c9350c7fb09b426b921990115c0b6dffa2; 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 course-digest knowledge plugin code (1 of 3)

0 participants