Skip to content

Run the video-digest async CLIs through one main-module helper #15623

Description

@kyle-sexton

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, runHarvestCli
  • transcript/run-transcript.js:153-162, runTranscriptCli
  • watch/caption-recheck.js:122-131, main
  • watch/recover-watch-bootstrap.js:416-425, recoverWatchBootstrapCli
  • watch/run-resume.js:113-122, runResumeCli
  • watch/run-watch.js:598-607, runWatchCli
  • watching/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.js exporting runMain(moduleUrl, cli), which runs the tail above for cli when isMainModule(moduleUrl) is true. It takes the caller's import.meta.url because isMainModule must judge the calling module (plugins/knowledge/vendor/video-digestion/shared/main-module.js:12-15). It imports isMainModule and writeStderr from @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 its isMainModule import with import { runMain } from "../lib/run-main.js";. Its writeStderr import stays.
  • No run-main.test.js is added. No repository check pairs a file under extraction/ with a test: scripts/affected-tests-no-suite.txt:122-128 records the whole tree as covered by the test-node lane, which runs plugins/knowledge/skills/video-digest/scripts/run-tests.sh install, build (typecheck) and test when a file under the package changes (scripts/node-subprojects.txt:10, scripts/plan-test-lanes.sh:54-55); extraction/vitest.config.ts:5 sets no coverage gate; lib/watch-frame-index.js has no suite (git ls-files); and no scripts/check-*.sh names video-digest (git grep).

Files:

  • plugins/knowledge/skills/video-digest/extraction/lib/run-main.js (new)
  • plugins/knowledge/skills/video-digest/extraction/harvesting/run-harvest.js
  • plugins/knowledge/skills/video-digest/extraction/transcript/run-transcript.js
  • plugins/knowledge/skills/video-digest/extraction/watch/caption-recheck.js
  • plugins/knowledge/skills/video-digest/extraction/watch/recover-watch-bootstrap.js
  • plugins/knowledge/skills/video-digest/extraction/watch/run-resume.js
  • plugins/knowledge/skills/video-digest/extraction/watch/run-watch.js
  • plugins/knowledge/skills/video-digest/extraction/watching/run-watching-pipeline.js
  • a new patch fragment 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:17 runs run-watch.js as a child process and checks its exit codes.
  • Two scripts keep their own tails: harvesting/analyze-harvested-repos.js:123-132, because analyze-harvested-repos.test.js:279-281 reads its source and requires process.exitCode = code in it, and watch/watch-state.js:605-627, which has a usage branch exiting 2 (:614-616) and error text ending in \n (:623).
  • No test names isMainModule for 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 call runMain.
  • 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 all passes, including run-transcript.test.js, caption-recheck.test.js, recover-watch-bootstrap.test.js, run-resume.test.js and the run-watch*.test.js suites.
  • 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.

Activity

  1. added
    status: ready
    on Nov 12, 2026
  2. added theissue type on Nov 12, 2026
  3. removed
    status: ready
    on Nov 12, 2026
  4. melodic-automation-lanes commented on Nov 12, 2026

    @melodic-automation-lanes
    Contributor

    {"v":1,"actor_id":337595936,"title_sha256":"4275b6ed7f660e77e824fee74c1814489a40883a94b88d7112c6747f89a29f76","body_sha256":"5c7d014f8004b86346c66ad0f87354d1a22ce649723006fc4c053f95fd9f9362"}

  5. github-actions commented on Nov 12, 2026

    @github-actions
    Contributor
    No description provided.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Fields

    Work status

    needs-triage

    Priority

    low

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions