From b2c18a45c635bf2894575d221aea5a6c1dbe7cbe Mon Sep 17 00:00:00 2001 From: Michael Wang Date: Sat, 21 Nov 2026 00:11:12 +0000 Subject: [PATCH] fix(skills): agents run the CLI through the launcher, never a project's scripts (#8326) The hyperframes-cli skill told a job with no TTY to pin the release with the project's pinned npm run scripts. Agent shells rarely have a TTY, so a project from someone else could choose what the agent runs through its package.json scripts, .npmrc or node_modules. The skill core now offers only the launcher with an exact version from the person or from --cli-version latest --version. The unattended reference keeps project scripts and project installs for a person's own pipelines on projects they wrote. The Remotion eval flow is scoped to the fixtures the skill ships. A new skill lint check fails when a shipped SKILL.md documents npm run, an npm install of the CLI, or node_modules/.bin/hyperframes. --- scripts/lint-skills.test.mjs | 39 ++++++++++++++++++- scripts/lint-skills.ts | 24 ++++++++++++ skills-manifest.json | 4 +- skills/hyperframes-cli/SKILL.md | 2 +- .../hyperframes-cli/references/unattended.md | 3 +- .../references/eval.md | 2 + 6 files changed, 69 insertions(+), 5 deletions(-) diff --git a/scripts/lint-skills.test.mjs b/scripts/lint-skills.test.mjs index 195f73d0d5..5aed038199 100644 --- a/scripts/lint-skills.test.mjs +++ b/scripts/lint-skills.test.mjs @@ -8,13 +8,14 @@ import test from "node:test"; import assert from "node:assert/strict"; -import { mkdtempSync, mkdirSync, writeFileSync } from "node:fs"; +import { mkdtempSync, mkdirSync, readdirSync, readFileSync, writeFileSync } from "node:fs"; import { tmpdir } from "node:os"; import { join } from "node:path"; import { headingSlugs, lintDocRefs, lintFrontmatter, + lintProjectCliRoutes, lintRegistryItemRefs, lintRelativeScriptRuns, lintVersionedCliRuns, @@ -414,3 +415,39 @@ test("versioned CLI examples use the installed launcher", () => { [], ); }); + +test("project CLI routes: a project's scripts or a CLI installed into it are flagged", () => { + for (const text of [ + "or the project's pinned `npm run` scripts", + "run `npm run render` in the project", + "`npm i hyperframes@0.9.0` then run it", + "`npm install --save-dev hyperframes`", + "then `node_modules/.bin/hyperframes render`", + ]) { + assert.equal(lintProjectCliRoutes(`intro\n${text}\n`)[0]?.line, 2, text); + } +}); + +test("project CLI routes: the launcher and plain prose pass", () => { + const ok = [ + 'node "/hyperframes/scripts/plugin-cli.mjs" --cli-version 1.2.3 render', + "never a project's own scripts or wrapper unless the person names that command", + "`npx skills add heygen-com/hyperframes`", + ].join("\n"); + assert.deepEqual(lintProjectCliRoutes(ok), []); +}); + +test("project CLI routes: no shipped SKILL.md offers a route through a project's files", () => { + const skillsDir = join(import.meta.dirname, "..", "skills"); + for (const entry of readdirSync(skillsDir, { withFileTypes: true })) { + if (!entry.isDirectory()) continue; + const path = join(skillsDir, entry.name, "SKILL.md"); + let content; + try { + content = readFileSync(path, "utf-8"); + } catch { + continue; + } + assert.deepEqual(lintProjectCliRoutes(content), [], path); + } +}); diff --git a/scripts/lint-skills.ts b/scripts/lint-skills.ts index 0b5eb0ced5..9c3e88a25e 100644 --- a/scripts/lint-skills.ts +++ b/scripts/lint-skills.ts @@ -582,6 +582,27 @@ export function lintVersionedCliRuns(content: string): LineViolation[] { ); } +/** A project's own scripts or a CLI installed into it: routes that let a received project pick what an agent runs. */ +const PROJECT_CLI_ROUTE = + /\bnpm\s+run\b|\bnpm\s+(?:i|install)\b[^\n]*\bhyperframes\b|node_modules\/\.bin\/hyperframes/; + +/** A skill core documents only the launcher, so an agent reading it alone finds no route through a project's files. */ +export function lintProjectCliRoutes(content: string): LineViolation[] { + return content + .split("\n") + .flatMap((text, index) => + PROJECT_CLI_ROUTE.test(text) + ? [ + violation( + index + 1, + "Offer only the launcher here. A project's own scripts and a CLI installed into it belong in a reference, for the person's own pipelines.", + text, + ), + ] + : [], + ); +} + function collectMarkdownFiles(dir: string): string[] { return readdirSync(dir, { withFileTypes: true, recursive: true }) .filter((entry) => entry.isFile() && entry.name.endsWith(".md")) @@ -643,6 +664,9 @@ function main(): void { for (const file of files) { report(relative(process.cwd(), file), lintFile(file)); + if (file.startsWith(join(REPO_ROOT, "skills") + sep)) { + report(relative(process.cwd(), file), lintProjectCliRoutes(readFileSync(file, "utf-8"))); + } } const knownItems = registryItemNames(); diff --git a/skills-manifest.json b/skills-manifest.json index c9279fb22d..42d25ab935 100644 --- a/skills-manifest.json +++ b/skills-manifest.json @@ -10,7 +10,7 @@ "files": 81 }, "hyperframes-cli": { - "hash": "3e3f9c549e0df1b7", + "hash": "132e56038dbd2365", "files": 14 }, "hyperframes-registry": { @@ -22,7 +22,7 @@ "files": 131 }, "remotion-to-hyperframes": { - "hash": "27f757cb659e1aaa", + "hash": "52ec1ac28a9251ae", "files": 76 }, "reverse-any-video": { diff --git a/skills/hyperframes-cli/SKILL.md b/skills/hyperframes-cli/SKILL.md index 2a57f9d14f..e3b8ab3e12 100644 --- a/skills/hyperframes-cli/SKILL.md +++ b/skills/hyperframes-cli/SKILL.md @@ -9,7 +9,7 @@ description: HyperFrames CLI - scaffold, check frames, edit timelines, preview, # HyperFrames CLI -Run `npx hyperframes ` as above, never a project's own scripts or wrapper unless the person names that command. A job with no TTY pins the release (`--cli-version `, or the project's pinned `npm run` scripts), never a floating install (`references/unattended.md`). It needs Node.js 22+ and FFmpeg. Every command has `--help`; most take `--json`, and a failure prints `✗ …`, a `Fix:` line and exits non-zero. +Run `npx hyperframes ` as above, never a project's own scripts or wrapper unless the person names that command. A job with no TTY pins the release with the launcher's `--cli-version `, taking the version from the person or from `--cli-version latest --version`, never from the project's files and never a floating install (`references/unattended.md`). It needs Node.js 22+ and FFmpeg. Every command has `--help`; most take `--json`, and a failure prints `✗ …`, a `Fix:` line and exits non-zero. A `--json` result may carry `_meta.updateNotice`: a newer HyperFrames release is out. Pass it to the person once per conversation, in your own words, at a natural pause; updating is theirs to decide. diff --git a/skills/hyperframes-cli/references/unattended.md b/skills/hyperframes-cli/references/unattended.md index 908990f633..34ed7059e0 100644 --- a/skills/hyperframes-cli/references/unattended.md +++ b/skills/hyperframes-cli/references/unattended.md @@ -12,7 +12,8 @@ With no version, `npx` asks the registry for the latest release on every run and ## Pin the release - From a skill, run the CLI through the launcher with an exact release: `node "/hyperframes/scripts/plugin-cli.mjs" --cli-version ` ([rules](../../hyperframes/references/plugin-installation.md)). Take the version from the person or from `--cli-version latest --version`, never from the project's own files. -- A scaffolded project (`hyperframes init`) ships `npm run dev|check|render|publish`, each pinned (`npx …hyperframes@…`) to the release that created the project. A job the person owns runs those, or installs once — `npm i hyperframes@` then `node_modules/.bin/hyperframes `, or `npm i -g hyperframes@` then `hyperframes ` — and skips the fetch and the cache race altogether. +- An agent keeps using the launcher, which refuses releases below its floor and starts npm in the home folder. It does not run a project's `npm run` scripts, install the CLI into the project, or use a release the project's files name, unless the person asks for that command by name. A project from someone else is never run through its own scripts, pins, `.npmrc` or `node_modules`. +- A person's own pipeline, on a project they wrote, may skip the launcher. A scaffolded project (`hyperframes init`) ships `npm run dev|check|render|publish`, each pinned (`npx …hyperframes@…`) to the release that created the project. Their pipeline can run those, or install once — `npm i hyperframes@` then `node_modules/.bin/hyperframes `, or `npm i -g hyperframes@` then `hyperframes ` — and skip the fetch and the cache race altogether. That is the person's setup, not a route for an agent. Interactive sessions float on purpose: `update` moves an `npx` user to the latest release, and the reverse-any-video skill moves to `--cli-version latest` when the installed CLI is behind. That is a person's call at a terminal. An unattended job pins. diff --git a/skills/remotion-to-hyperframes/references/eval.md b/skills/remotion-to-hyperframes/references/eval.md index 2466de1563..4b0afed7ee 100644 --- a/skills/remotion-to-hyperframes/references/eval.md +++ b/skills/remotion-to-hyperframes/references/eval.md @@ -17,6 +17,8 @@ Run them in this order: **lint → render → diff → (if fail) read the sheet* ## Per-fixture flow +This flow is for the fixtures this skill ships. Do not run `npm install` or a project's scripts in a Remotion project someone else wrote; ask the person for its baseline render instead. + ```bash # 1. Lint the source — blockers mean stop python3 ../../scripts/lint_source.py ./remotion-src/src/