Skip to content

armgit / hypit

Public Imported from GitHub
0

Clone any viral video with AI agents. Not just a script, the whole workflow: swap the face, the words, the B-roll, ship 100 variants in one command, and get your 100M views.

fix(cli): isolate runtime context by command

kashorin40ff5fc9d59f
diff --git a/packages/cli/README.md b/packages/cli/README.md
index d3586cb2..af23a83e 100644
--- a/packages/cli/README.md
+++ b/packages/cli/README.md
@@ -21,6 +21,6 @@ browsing/export lives under `commands/results.ts`; Runtime,
credential, package and deployment operations live under `commands/environment.ts`; active Build
observation is read-only code in `observation.ts`; and human rendering is separate from the explicit
machine-view union. `main.ts` resolves project and selected Runtime context separately from parsed
-syntax, then dispatches these command groups. Result
-commands cannot silently construct a Runtime, and the generic CLI cannot silently choose a physical
-Result Store or a Provider-specific login flow.
+syntax, then dispatches these command groups. Result commands do not consult or construct a Runtime,
+and the generic CLI cannot silently choose a physical Result Store or a Provider-specific login
+flow.
diff --git a/packages/cli/src/arguments.ts b/packages/cli/src/arguments.ts
index db11c85a..555c174a 100644
--- a/packages/cli/src/arguments.ts
+++ b/packages/cli/src/arguments.ts
@@ -152,7 +152,7 @@ export function parseCommand(argv: readonly string[]): CliCommand {
if (options.presentation.jsonl === true && !options.watch) {
throw new Error("--jsonl applies only to activity --watch");
}
- if (options.watch && options.presentation.json && options.presentation.jsonl !== true) {
+ if (options.watch && options.seenOptions.includes("--json")) {
throw new Error("activity --watch is a stream; use --jsonl instead of --json");
}
return {
@@ -545,7 +545,7 @@ function optionalRuntime(options: RawOptions): RuntimeOption {
}
function runtimeOption(profile: string | undefined): RuntimeOption {
- return profile === undefined ? {} : { runtimeProfile: profile };
+ return { runtimeProfile: profile };
}
function optionalPackageRoot(options: RawOptions): { readonly packageRoot?: string } {
diff --git a/packages/cli/src/command.ts b/packages/cli/src/command.ts
index 0be1dc3d..59cd3ae3 100644
--- a/packages/cli/src/command.ts
+++ b/packages/cli/src/command.ts
@@ -5,7 +5,7 @@ type CommandBase = {
};
export type RuntimeOption = {
- readonly runtimeProfile?: string;
+ readonly runtimeProfile: string | undefined;
};
export type ProjectOption = {
diff --git a/packages/cli/src/main.ts b/packages/cli/src/main.ts
index 76f9700a..c5a440dc 100644
--- a/packages/cli/src/main.ts
+++ b/packages/cli/src/main.ts
@@ -16,7 +16,7 @@ import type {
import { writeCliHelp, writeCliOutput } from "./output.js";
import type { CliIo, CliMachineView } from "./output.js";
import { parseCommand } from "./arguments.js";
-import type { CliCommand } from "./command.js";
+import type { CliCommand, RuntimeOption } from "./command.js";
import { assertPreflight, createCatalogDescriptor, preflightPlan } from "./build-planning.js";
import { observeBuild } from "./observation.js";
import { isProjectResultCommand, runProjectResultCommand } from "./commands/results.js";
@@ -52,8 +52,8 @@ function commandPackageRoot(command: CliCommand): string | undefined {
return "packageRoot" in command ? command.packageRoot : undefined;
}
-function commandRuntimeProfile(command: CliCommand): string | undefined {
- return "runtimeProfile" in command ? command.runtimeProfile : undefined;
+function acceptsRuntimeContext(command: CliCommand): command is CliCommand & RuntimeOption {
+ return "runtimeProfile" in command;
}
export async function runCli(
@@ -143,10 +143,10 @@ export async function runCli(
return;
}
- let runtimeProfile = commandRuntimeProfile(args);
+ let runtimeProfile = acceptsRuntimeContext(args) ? args.runtimeProfile : undefined;
const runtimeWasExplicit = runtimeProfile !== undefined;
let runtimeNeedsHint = runtimeWasExplicit;
- if (runtimeProfile === undefined) {
+ if (acceptsRuntimeContext(args) && runtimeProfile === undefined) {
const sourceScoped = args.command === "check" || args.command === "plan" || args.command === "build";
const start = commandWorkspaceRoot(args)
?? (sourceScoped ? dirname(resolve(args.source)) : process.cwd());
diff --git a/packages/cli/test/build-results.test.ts b/packages/cli/test/build-results.test.ts
index 8dc35626..fcdcd639 100644
--- a/packages/cli/test/build-results.test.ts
+++ b/packages/cli/test/build-results.test.ts
@@ -75,6 +75,7 @@ test("builds, history, inspect and get read project Build Results without openin
const root = await mkdtemp(join(tmpdir(), "hypit-cli-results-"));
try {
await fixture(root);
+ await writeFile(join(root, ".hypit", "runtime"), "missing-runtime.json\n", "utf8");
const builds = await jsonCommand(["builds"], root) as {
readonly builds: readonly {
readonly id: string;
diff --git a/packages/cli/test/control-commands.test.ts b/packages/cli/test/control-commands.test.ts
index eecb3652..65f3630a 100644
--- a/packages/cli/test/control-commands.test.ts
+++ b/packages/cli/test/control-commands.test.ts
@@ -304,6 +304,12 @@ test("command options fail closed instead of being silently ignored", async () =
], io, distribution),
/--runtime cannot be repeated/u,
);
+ await assert.rejects(
+ async () => await runCli([
+ "activity", "--runtime", "/tmp/runtime.json", "--watch", "--json", "--jsonl",
+ ], io, distribution),
+ /use --jsonl instead of --json/u,
+ );
await assert.rejects(
async () => await runCli([
"doctor", "/tmp/runtime.json", "--workspace", "/tmp",