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.
This commit is contained in:
Michael Wang
2026-11-21 00:11:12 +00:00
committed by GitHub
parent 9e3fb696c0
commit b2c18a45c6
6 changed files with 69 additions and 5 deletions
+38 -1
View File
@@ -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 "<SKILLS>/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);
}
});
+24
View File
@@ -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();