Repository navigation
Description
Agent Brief
Type: Task
Summary: Move the main-module tail that seven video-digest CLI scripts repeat into one helper, plugins/knowledge/skills/video-digest/extraction/lib/run-main.js (part of restructuring pass #14622).
Current behavior:
Seven scripts under plugins/knowledge/skills/video-digest/extraction/ end in the same 10-line tail: if (isMainModule(import.meta.url)) { <cli>(process.argv).then((code) => { process.exitCode = code; }).catch((error) => { writeStderr(error instanceof Error ? error.message : String(error)); process.exitCode = 1; }); }. Only the CLI function differs:
harvesting/run-harvest.js:83-92,runHarvestClitranscript/run-transcript.js:153-162,runTranscriptCliwatch/caption-recheck.js:122-131,mainwatch/recover-watch-bootstrap.js:416-425,recoverWatchBootstrapCliwatch/run-resume.js:113-122,runResumeCliwatch/run-watch.js:598-607,runWatchCliwatching/run-watching-pipeline.js:66-75,runWatchingPipelineCli
In each, isMainModule appears only in its import line and the tail (run-harvest.js:14, run-transcript.js:24, caption-recheck.js:21, recover-watch-bootstrap.js:15, run-resume.js:10, run-watch.js:37, run-watching-pipeline.js:14); writeStderr has other uses in each (git grep -c writeStderr: 3 to 23 per file).
Desired behavior:
- New
extraction/lib/run-main.jsexportingrunMain(moduleUrl, cli), which runs the tail above forcliwhenisMainModule(moduleUrl)is true. It takes the caller'simport.meta.urlbecauseisMainModulemust judge the calling module (plugins/knowledge/vendor/video-digestion/shared/main-module.js:12-15). It importsisMainModuleandwriteStderrfrom@melodic/video-digestion/shared/*, as the callers do (run-harvest.js:14-15), and carries JSDoc types, since the package runs checkJs (extraction/tsconfig.json:9). - Each of the seven replaces its tail with
runMain(import.meta.url, <cli>);and replaces itsisMainModuleimport withimport { runMain } from "../lib/run-main.js";. ItswriteStderrimport stays. - No
run-main.test.jsis added. No repository check pairs a file underextraction/with a test:scripts/affected-tests-no-suite.txt:122-128records the whole tree as covered by thetest-nodelane, which runsplugins/knowledge/skills/video-digest/scripts/run-tests.shinstall,build(typecheck) andtestwhen a file under the package changes (scripts/node-subprojects.txt:10,scripts/plan-test-lanes.sh:54-55);extraction/vitest.config.ts:5sets no coverage gate;lib/watch-frame-index.jshas no suite (git ls-files); and noscripts/check-*.shnamesvideo-digest(git grep).
Files:
plugins/knowledge/skills/video-digest/extraction/lib/run-main.js(new)plugins/knowledge/skills/video-digest/extraction/harvesting/run-harvest.jsplugins/knowledge/skills/video-digest/extraction/transcript/run-transcript.jsplugins/knowledge/skills/video-digest/extraction/watch/caption-recheck.jsplugins/knowledge/skills/video-digest/extraction/watch/recover-watch-bootstrap.jsplugins/knowledge/skills/video-digest/extraction/watch/run-resume.jsplugins/knowledge/skills/video-digest/extraction/watch/run-watch.jsplugins/knowledge/skills/video-digest/extraction/watching/run-watching-pipeline.js- a new
patchfragment in.changes/knowledge/:### Changed, "Internal restructuring, no behavior change."
Key interfaces:
- Each script's exported functions, stdout, stderr text and exit codes: unchanged.
watch/run-watch-signal.test.js:17runsrun-watch.jsas a child process and checks its exit codes. - Two scripts keep their own tails:
harvesting/analyze-harvested-repos.js:123-132, becauseanalyze-harvested-repos.test.js:279-281reads its source and requiresprocess.exitCode = codein it, andwatch/watch-state.js:605-627, which has a usage branch exiting 2 (:614-616) and error text ending in\n(:623). - No test names
isMainModulefor these seven; the evals (skills/video-digest/evals/evals.json) name only script paths, which are unchanged.
Acceptance criteria:
- The main-module tail exists once, in
extraction/lib/run-main.js, and the seven scripts callrunMain. - Behavior is unchanged: the same outputs, exit codes and printed results for the same inputs.
- The diff edits only the listed files and the lines of a test that assert on them when the change breaks that assertion.
- The pull request stays within 400 changed lines and 15 hand-edited files.
-
plugins/knowledge/skills/video-digest/scripts/run-tests.sh allpasses, includingrun-transcript.test.js,caption-recheck.test.js,recover-watch-bootstrap.test.js,run-resume.test.jsand therun-watch*.test.jssuites. - ci-status is green.
Out of scope:
analyze-harvested-repos.js,watch-state.js, the other scripts' synchronous tails,vendor/video-digestion/, a new test file, other duplication, eval cases, fixtures, and skill and agent text.
Metadata
Metadata
Assignees
Labels
Type
Fields
Work status
Priority
Activity
melodic-automation-lanes commentedon Nov 12, 2026
{"v":1,"actor_id":337595936,"title_sha256":"4275b6ed7f660e77e824fee74c1814489a40883a94b88d7112c6747f89a29f76","body_sha256":"5c7d014f8004b86346c66ad0f87354d1a22ce649723006fc4c053f95fd9f9362"}
github-actions commentedon Nov 12, 2026