Files
hyperframes/scripts/check-core-skills.test.mjs
T
Michael WangandClaude Opus 5.5 a6e6717f2a feat(cli): checkout links name the CLI and the skill that sent them (#7177)
* feat(skills): every published skill reports its own run

`hyperframes events --skill=<name>` exists so a skill can say it ran, but
only reverse-any-video and figma asked the agent to call it, so the other
skills' use was invisible. Each of the nine published skills now opens with
a one-line usage beacon naming itself. The line says what it sends (the
skill's name only) and that the telemetry opt-out applies. The router's
`init` line also passes `--skill=hyperframes`, so renders of new projects
carry the skill.

check-core-skills fails a core skill that lacks its own beacon; each core
skill's size budget grows by 192 B for the line.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* feat(cli): checkout links name the CLI and the skill that sent them

Only `billing subscribe` marked its pricing link `from=cli`, and the
terminal's Press-Enter Pro checkout sent no return page, so a purchase made
from the terminal looked like one made on the site. Now:

- `pageUrl` adds `utm_source=cli` and `skill`: the one named, else the
  project's own `authoringSkill` from hyperframes.json.
- `billing` takes `--skill`. The terminal Pro checkout returns to the plans
  page marked `from=cli&skill=...`, and retries without the return page if
  the server does not allow it.
- Pricing links the server hands back (reverse's upgrade link, a refused
  media call's link) gain `from=cli` and the skill when they lack them.
- The Pro gates name their skill: reverse -> reverse-any-video, templates ->
  style-sampling, paid media calls -> media-use, in the CLI's printed fix and
  in those skills' billing commands.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(cli): report a refused checkout return page, and say where --skill goes

When the server refuses the terminal checkout's return page, the CLI still
sells Pro without it, but that purchase loses its CLI origin. A
cli_billing_checkout_return_refused event now makes that visible.

The --skill help said the skill is recorded with the purchase. It is sent
with the pricing link; the purchase itself does not store it yet.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-05 00:23:20 +00:00

105 lines
4.2 KiB
JavaScript

import test from "node:test";
import assert from "node:assert/strict";
import { mkdtempSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
import {
beaconProblems,
checkCoreSkills,
descriptionOf,
missingPaths,
registeredCommands,
unknownCommands,
} from "./check-core-skills.mjs";
test("the repo's core skills pass", () => {
assert.deepEqual(checkCoreSkills(), []);
});
test("the skills teach the direct sign-in, not the old key and executable rules", () => {
const read = (path) => readFileSync(new URL(`../skills/${path}`, import.meta.url), "utf8");
assert.doesNotMatch(read("reverse-any-video/references/people.md"), /Without a HeyGen key/);
assert.doesNotMatch(read("media-use/SKILL.md"), /HeyGen calls also need/);
const heygen = read("media-use/references/heygen.md");
assert.match(heygen, /~\/\.hyperframes\/credentials/);
assert.doesNotMatch(heygen, /~\/\.heygen\/credentials/);
});
test("the paid-plan cloud final keeps the composition fps and high quality", () => {
for (const path of ["hyperframes-cli/SKILL.md", "hyperframes-cli/references/cloud.md"]) {
const text = readFileSync(new URL(`../skills/${path}`, import.meta.url), "utf8");
assert.match(text, /`cloud render --fps <data-fps> --quality high -o [^`]+`/, path);
}
});
test("media-use lists Voice Turbo as free only on the Free plan, not for every sign-in", () => {
const text = readFileSync(new URL("../skills/media-use/SKILL.md", import.meta.url), "utf8");
assert.match(text, /\| Voice Turbo, Free plan: 3 min a month \| Voice Turbo on a paid plan/);
assert.doesNotMatch(text, /Voice Turbo \(signed in\)/);
});
test("reverse builds the project with init --video and asks for the run's total once", () => {
const read = (path) =>
readFileSync(new URL(`../skills/reverse-any-video/${path}`, import.meta.url), "utf8");
const start = read("references/start.md");
assert.match(
start,
/`npx hyperframes init <project> --video <video> --keep-original --skip-transcribe --skip-skills`/,
);
assert.match(
start,
/add up what each refused step\s+needs, and run `npx hyperframes billing (?:top-up|add-credits) --needed <total>(?: --skill reverse-any-video)?` once for that total/,
);
assert.doesNotMatch(read("SKILL.md"), /copy the video into the project/);
assert.match(read("SKILL.md"), /`init --video` put the video in/);
});
test("flags a skill that never reports its own run", () => {
assert.deepEqual(
beaconProblems("slideshow", "Run `npx hyperframes events --skill=slideshow` first."),
[],
);
assert.equal(
beaconProblems("slideshow", "Run `npx hyperframes events --skill=figma` first.").length,
1,
);
assert.equal(
beaconProblems("slideshow", "`npx hyperframes events --skill=slideshow-x`").length,
1,
);
});
test("reads the registered commands, quoted or not", () => {
const source = `const commandLoaders = {\n init: () => x,\n "catch-up": () => y,\n};`;
assert.deepEqual([...registeredCommands(source)], ["init", "catch-up"]);
});
test("flags a command the CLI does not register", () => {
const content = "Run `npx hyperframes check --json`, then `npx hyperframes frame 3`.";
assert.deepEqual(unknownCommands(content, new Set(["check"])), ["frame"]);
});
test("reads a one-line description", () => {
assert.equal(
descriptionOf("---\nname: x\ndescription: Does a thing.\n---\n# x"),
"Does a thing.",
);
});
test("flags a path the skill does not ship, and skips placeholders", () => {
const dir = mkdtempSync(join(tmpdir(), "core-skills-"));
mkdirSync(join(dir, "references"));
writeFileSync(join(dir, "references", "a.md"), "# a");
const content = "`references/a.md`, `references/b.md`, `references/routes/<workflow>.md`";
assert.deepEqual(missingPaths(content, dir), ["references/b.md"]);
});
test("style-sampling picks a voice from the HyperFrames account, never the separate heygen sign-in", () => {
const remix = readFileSync(
new URL("../skills/style-sampling/references/remix.md", import.meta.url),
"utf8",
);
assert.match(remix, /`npx hyperframes media-use voices`/);
assert.doesNotMatch(remix.replace(/never `heygen voice list`/, ""), /heygen voice list/);
});