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: resolve a project's packages from the project, and declare the shapes gpt-image makes

rpone482459cc14b8
diff --git a/packages/gpt-image/src/index.ts b/packages/gpt-image/src/index.ts
index 5dff94f9..0400c69c 100644
--- a/packages/gpt-image/src/index.ts
+++ b/packages/gpt-image/src/index.ts
@@ -21,8 +21,10 @@ export const gptImage2Ports: GenerationPortTable = sealGenerationPortTable({
name: "aspectRatio",
value: {
kind: "enum",
- values: ["auto", "1:1", "3:2", "2:3", "4:3", "3:4", "5:4", "4:5",
- "16:9", "9:16", "2:1", "1:2", "3:1", "1:3", "21:9", "9:21"],
+ // What the model produces. The wider shapes an image API will name in general — 2:1, 3:1,
+ // 21:9 and their inverses — this one refuses, and the refusal arrives from the Provider
+ // after the request was made rather than from validation before it.
+ values: ["auto", "1:1", "3:2", "2:3", "4:3", "3:4", "5:4", "4:5", "16:9", "9:16"],
},
minItems: 1,
maxItems: 1,
@@ -77,8 +79,7 @@ const gptImageAttributes: readonly SurfaceAttributeVocabulary[] = [
kind: "literal",
required: true,
summary: "The shape of the generated picture.",
- values: ["auto", "1:1", "3:2", "2:3", "4:3", "3:4", "5:4", "4:5",
- "16:9", "9:16", "2:1", "1:2", "3:1", "1:3", "21:9", "9:21"],
+ values: ["auto", "1:1", "3:2", "2:3", "4:3", "3:4", "5:4", "4:5", "16:9", "9:16"],
},
{
name: "resolution",
diff --git a/packages/reference-video-tools/src/authoring.ts b/packages/reference-video-tools/src/authoring.ts
index af4591ff..4472e06f 100644
--- a/packages/reference-video-tools/src/authoring.ts
+++ b/packages/reference-video-tools/src/authoring.ts
@@ -132,6 +132,25 @@ function repositoryRoot(): string {
return found;
}
+/**
+ * Where installed packages are resolved from, found the way `hypit check` finds it: the nearest
+ * directory at or above the project that holds a `package.json`.
+ *
+ * A project's own `packages/local-*` are installed against the project, so a root taken from
+ * anywhere else resolves none of them. This is the same walk `packages/cli/src/main.ts` performs,
+ * and the reason a project is given a `package.json` of its own — without one the walk passes
+ * through it and lands on the tree.
+ */
+function nearestPackageRoot(start: string): string | undefined {
+ let directory = resolve(start);
+ while (true) {
+ if (existsSync(join(directory, "package.json"))) return directory;
+ const parent = dirname(directory);
+ if (parent === directory) return undefined;
+ directory = parent;
+ }
+}
+
/** Where a relative path on the command line is measured from. */
export function invokedFrom(): string {
return process.env.INIT_CWD ?? process.cwd();
@@ -750,8 +769,11 @@ export async function renderElement(input: RenderElementInput): Promise<Record<s
const element = input.element;
const cwd = invokedFrom();
const runPath = resolve(cwd, input.run);
- const packageRoot = repositoryRoot();
const projectRoot = dirname(runPath);
+ // Where installed packages are found, which is not where the Hypit tree is. A project carries its
+ // own `packages/local-*`, so the search starts at the project and walks up the way the CLI's does —
+ // resolving against the tree instead would miss every package the project installed for itself.
+ const packageRoot = nearestPackageRoot(projectRoot) ?? repositoryRoot();
const outPath = resolve(cwd, input.out);
const runSource = await readFile(runPath, "utf8").catch(() => undefined);
@@ -1057,7 +1079,9 @@ export async function renderElement(input: RenderElementInput): Promise<Record<s
const frames = join(compareRoot, "frames");
await rm(frames, { recursive: true, force: true });
await mkdir(frames, { recursive: true });
- const hyperframesCli = createRequire(join(packageRoot, "packages/provider-hyperframes-local/package.json"))
+ // The runtime ships with the tree, not with the project. Resolving it against the package root
+ // finds nothing whenever those two differ, which is every project that installs packages of its own.
+ const hyperframesCli = createRequire(join(repositoryRoot(), "packages/provider-hyperframes-local/package.json"))
.resolve("hyperframes/bin/hyperframes.mjs");
const drawn = spawnSync(process.execPath, [
hyperframesCli, "render", stage,