Files
hyperframes/packages/cli/bin/hyperframes.mjs
T
James RussoandClaude Opus 5.5 a8fe3a5b68 fix(skills): plugin launcher and media helpers run the pinned CLI, not a project copy (#7552)
* fix(skills): plugin launcher and media helpers run the pinned CLI, not a project copy

The plugin launcher now starts npx from the home folder, so the project's
node_modules, package.json bin and .npmrc cannot choose which CLI npm runs or
how it starts it. It names the project in HYPERFRAMES_PLUGIN_CWD and the CLI's
bin moves into that folder before anything else runs, then drops the variable
so nested runs keep the folder their caller gives them.

In --script mode the launcher hands itself over as HYPERFRAMES_CLI_ENTRY. The
media helpers (Kokoro voice, transcription, the resolve shim) run the CLI they
were handed, and stop with an actionable message when none was, instead of
resolving `npx hyperframes` from the project.

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

* fix(skills): keep the project name and require a home folder for npx

The CLI bin now sets PWD to the project folder after moving into it, because
npm's shell resets PWD to the folder npx started in and preview names the
project from PWD. The plugin launcher no longer falls back to the temp folder
when there is no home folder; it stops with an error instead, and only when it
is about to start npx.

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

* test(cli): type the bin test environment

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

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-11 11:28:10 +00:00

28 lines
1.2 KiB
JavaScript

#!/usr/bin/env node
import module from "node:module";
import { runtimeVersionError } from "../dist/runtimeVersion.js";
// The plugin launcher starts npx outside the project so npm cannot pick the CLI from it,
// and names the project here. Nested CLI runs keep the working folder their caller gives them.
const projectDir = process.env.HYPERFRAMES_PLUGIN_CWD;
delete process.env.HYPERFRAMES_PLUGIN_CWD;
if (projectDir) {
process.chdir(projectDir);
// npm's shell resets PWD to the folder npx started in; commands read the project name from it.
process.env.PWD = projectDir;
}
const error = runtimeVersionError(process.versions.node);
if (error) {
console.error(error);
process.exitCode = 1;
} else {
// Reuses V8 bytecode across runs (os.tmpdir()/node-compile-cache); Node 22.0 has no such API.
module.enableCompileCache?.();
if (process.env.HYPERFRAMES_HANG_REPORT) (await import("../dist/hangReport.js")).watchForHang();
const warm = process.argv[2] === "check" ? await import("../dist/warmCheckClient.js") : undefined;
if (warm?.warmCheckEligible()) process.once("exit", () => warm.startNextWarmCheck());
if (!(warm?.warmCheckEligible() && (await warm.runWarmCheck()))) await import("../dist/cli.js");
}