mirror of
https://github.com/heygen-com/hyperframes.git
synced 2026-11-23 11:29:54 +00:00
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:
@@ -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);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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": {
|
||||
|
||||
@@ -9,7 +9,7 @@ description: HyperFrames CLI - scaffold, check frames, edit timelines, preview,
|
||||
|
||||
# HyperFrames CLI
|
||||
|
||||
Run `npx hyperframes <command>` 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 <exact-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 <command>` 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 <exact-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.
|
||||
|
||||
|
||||
@@ -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 "<SKILLS>/hyperframes/scripts/plugin-cli.mjs" --cli-version <exact-version> <command>` ([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@<version>…`) to the release that created the project. A job the person owns runs those, or installs once — `npm i hyperframes@<version>` then `node_modules/.bin/hyperframes <command>`, or `npm i -g hyperframes@<version>` then `hyperframes <command>` — 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@<version>…`) to the release that created the project. Their pipeline can run those, or install once — `npm i hyperframes@<version>` then `node_modules/.bin/hyperframes <command>`, or `npm i -g hyperframes@<version>` then `hyperframes <command>` — 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.
|
||||
|
||||
|
||||
@@ -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/
|
||||
|
||||
Reference in New Issue
Block a user