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.

refactor: remove hidden validation side paths

kashorin4c6af5860f25
diff --git a/.gitignore b/.gitignore
index 1ffb63bf..88abfffa 100644
--- a/.gitignore
+++ b/.gitignore
@@ -67,7 +67,3 @@ examples/**/.svml/
# Reverse-engineering scratch projects live outside the repository too
/projects/*
-!/projects/hypihub-provider-smoke/
-!/projects/hypihub-provider-smoke/**
-/projects/hypihub-provider-smoke/.hypit/
-/projects/hypihub-provider-smoke/.DS_Store
diff --git a/bin/hypit-preview-check.mjs b/bin/hypit-preview-check.mjs
deleted file mode 100644
index edf5a084..00000000
--- a/bin/hypit-preview-check.mjs
+++ /dev/null
@@ -1,17 +0,0 @@
-#!/usr/bin/env node
-import { register } from "tsx/esm/api";
-import { dirname, resolve } from "node:path";
-import { fileURLToPath } from "node:url";
-
-const distributionRoot = resolve(dirname(fileURLToPath(import.meta.url)), "..");
-process.env.HYPIT_DISTRIBUTION_ROOT ??= distributionRoot;
-process.env.INIT_CWD ??= process.cwd();
-register();
-const {
- installDistributionPackageResolution,
- installExternalPackageResolution,
-} = await import("../packages/package-loader-node/src/distribution-resolution.ts");
-installDistributionPackageResolution([distributionRoot]);
-const { hypitHostPackageRoot } = await import("../packages/runtime-host-node/src/index.ts");
-installExternalPackageResolution([hypitHostPackageRoot()]);
-await import("../packages/studio/preview-check.ts");
diff --git a/package.json b/package.json
index 938f0911..4e091605 100644
--- a/package.json
+++ b/package.json
@@ -6,8 +6,7 @@
"type": "module",
"bin": {
"hypit": "./bin/hypit.mjs",
- "hypit-studio": "./bin/hypit-studio.mjs",
- "hypit-preview-check": "./bin/hypit-preview-check.mjs"
+ "hypit-studio": "./bin/hypit-studio.mjs"
},
"packageManager": "[email protected]",
"files": [
@@ -38,7 +37,6 @@
],
"scripts": {
"check": "tsc -p tsconfig.json --noEmit",
- "lockfile:refresh": "node test/lockfile-refresh.mjs",
"docs:dev": "vitepress dev docs",
"docs:build": "vitepress build docs",
"docs:preview": "vitepress preview docs",
diff --git a/packages/cli/src/main.ts b/packages/cli/src/main.ts
index 3da3e360..98005268 100644
--- a/packages/cli/src/main.ts
+++ b/packages/cli/src/main.ts
@@ -7,7 +7,6 @@ import { orderedBuildId } from "@hypit/protocol";
import { parseSourceHeader } from "@hypit/source";
import { unreachedGenerations } from "./reachability.js";
-import { typecheckProjectPackages } from "./package-typecheck.js";
import { checkRunFile, collectRunFrontends, loadRunFile } from "./run-file.js";
import type { CliDistribution } from "./distribution.js";
import type {
@@ -268,12 +267,6 @@ export async function runCli(
throw new Error(`${args.command} requires a self-described Run Source; check Author Sources independently`);
}
if (args.command === "check") {
- // A project's own packages decide their element field names in TypeScript, and nothing authored
- // carries them, so this is the only place before a Build that can read them.
- const packageDiagnostics = typecheckProjectPackages(sourcePackageRoot, distribution.packageRoot);
- if (packageDiagnostics.length > 0) {
- throw new Error(`this project's own author packages do not typecheck:\n${packageDiagnostics.join("\n")}`);
- }
if (runMode) {
const loaded = await checkRunFile({
workspace,
diff --git a/packages/cli/src/package-typecheck.ts b/packages/cli/src/package-typecheck.ts
deleted file mode 100644
index 79e9dba8..00000000
--- a/packages/cli/src/package-typecheck.ts
+++ /dev/null
@@ -1,88 +0,0 @@
-import { existsSync, readdirSync, readFileSync } from "node:fs";
-import { createRequire } from "node:module";
-import { resolve } from "node:path";
-
-/**
- * Typecheck the author packages a project owns.
- *
- * A project-local package builds its picture in TypeScript: its Producer returns a list of elements,
- * and the field names on those elements are fixed by the Composition Types it imports. Nothing
- * authored carries them, so `check` has no Record to validate — the object does not exist until the
- * Producer runs, which is at Build.
- *
- * The compiler decides them without running anything. A media element's artifact field is `artifact`,
- * and writing `source` instead is `TS2353: 'source' does not exist in type 'VisualMediaElement'` —
- * available in a second, and otherwise first seen as a Build failure blaming a field the author never
- * typed.
- *
- * That check never ran on a project because the CLI loads TypeScript through tsx, which strips types
- * without reading them, and the tree's own `tsconfig.json` covers the packages it ships rather than
- * the ones a project writes.
- *
- * The options come from the Distribution's own `tsconfig.json`, so a project package is held to
- * exactly the standard the packages it imports are held to, and there is one place to change it.
- */
-export function typecheckProjectPackages(
- projectRoot: string,
- distributionRoot: string | undefined,
-): readonly string[] {
- if (distributionRoot === undefined) return [];
- const root = resolve(projectRoot);
- const distribution = resolve(distributionRoot);
- // A Distribution checking itself is `pnpm check`, over a different and much larger file set.
- if (root === distribution) return [];
- if (!existsSync(resolve(root, "packages"))) return [];
-
- const require = createRequire(resolve(distribution, "package.json"));
- let ts: typeof import("typescript");
- // A Distribution that ships no compiler cannot do this, and saying nothing is better than refusing
- // a project over the toolchain it was handed.
- try { ts = require("typescript") as typeof import("typescript"); } catch { return []; }
-
- // Where the compiler finds the packages a project imports. Hypit resolves `@hypit/x` by its own
- // walk to `<root>/packages/x`, and nothing links it into `node_modules`, so Node resolution — which
- // is what TypeScript follows — reaches none of them from a project. The Distribution says where
- // each one is in its own `package.json`, so the mapping is read rather than guessed.
- const paths: Record<string, string[]> = {};
- for (const entry of readdirSync(resolve(distribution, "packages"), { withFileTypes: true })) {
- if (!entry.isDirectory()) continue;
- const home = resolve(distribution, "packages", entry.name);
- const manifest = resolve(home, "package.json");
- if (!existsSync(manifest)) continue;
- const declared = JSON.parse(readFileSync(manifest, "utf8")) as {
- name?: string;
- exports?: string | Record<string, unknown>;
- };
- if (declared.name === undefined) continue;
- const root_ = typeof declared.exports === "string" ? declared.exports : declared.exports?.["."];
- if (typeof root_ === "string") paths[declared.name] = [resolve(home, root_)];
- // A deep import such as `@hypit/studio/src/domain.js` names a file inside the package.
- paths[`${declared.name}/*`] = [resolve(home, "*")];
- }
-
- const shipped = resolve(distribution, "tsconfig.json");
- const declared = existsSync(shipped)
- ? (ts.readConfigFile(shipped, ts.sys.readFile).config as { compilerOptions?: Record<string, unknown> }).compilerOptions
- : undefined;
- const parsed = ts.parseJsonConfigFileContent({
- compilerOptions: {
- ...(declared ?? { target: "ES2023", module: "NodeNext", moduleResolution: "NodeNext", strict: true }),
- // A project is read, never emitted, and its own layout decides nothing here.
- noEmit: true, declaration: false, sourceMap: false, composite: false, rootDir: undefined,
- skipLibCheck: true,
- baseUrl: root,
- paths,
- typeRoots: [resolve(distribution, "node_modules/@types")],
- },
- include: ["packages/*/src/**/*.ts"],
- }, ts.sys, root);
- if (parsed.fileNames.length === 0) return [];
-
- const host = {
- getCanonicalFileName: (name: string): string => name,
- getCurrentDirectory: (): string => root,
- getNewLine: (): string => "\n",
- };
- return ts.getPreEmitDiagnostics(ts.createProgram(parsed.fileNames, parsed.options))
- .map((item) => ts.formatDiagnostic(item, host).trimEnd());
-}
diff --git a/packages/studio/package.json b/packages/studio/package.json
index e8ac2142..5bbf46dc 100644
--- a/packages/studio/package.json
+++ b/packages/studio/package.json
@@ -5,7 +5,6 @@
"type": "module",
"exports": {
"./start": "./start.ts",
- "./preview-check": "./preview-check.ts",
"./src/*": "./src/*"
},
"dependencies": {
diff --git a/packages/studio/preview-check.ts b/packages/studio/preview-check.ts
deleted file mode 100644
index d95de0f0..00000000
--- a/packages/studio/preview-check.ts
+++ /dev/null
@@ -1,119 +0,0 @@
-#!/usr/bin/env node
-import { existsSync } from "node:fs";
-import { dirname, join, resolve } from "node:path";
-
-import { videoCliDistribution } from "@hypit/video-cli";
-
-import { openStudioBuildLibrary } from "./src/build-library.js";
-import { loadStudioCompanionRegistry } from "./src/companion-profile.js";
-import { loadStudioDomain } from "./src/domain.js";
-import { loadStudioRun } from "./src/run.js";
-import { readStudioSession } from "./src/session.js";
-import { inspectStudioRun } from "./src/studio-preflight.js";
-
-/**
- * Where a Source's imports resolve from: the nearest directory at or above it holding a
- * `package.json`. This is the walk `hypit check` makes, and it is why a project is given a
- * `package.json` of its own — a project's `packages/local-*` are installed against the project, so a
- * root taken from anywhere else resolves none of them.
- *
- * The Run's own directory is not that root whenever the Run sits in a subdirectory, which is how one
- * command resolved a project's packages and this one did not.
- */
-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;
- }
-}
-
-const flags = new Map<string, string>();
-const operands: string[] = [];
-for (let index = 2; index < process.argv.length; index += 1) {
- const token = process.argv[index]!;
- if (!token.startsWith("--")) { operands.push(token); continue; }
- const [name, inline] = token.slice(2).split(/=(.*)/su);
- const value = inline ?? process.argv[++index];
- if (value === undefined) { process.stderr.write(`--${name} needs a value\n`); process.exit(2); }
- flags.set(name!, value);
-}
-
-const runArgument = operands[0];
-if (runArgument === undefined) {
- process.stderr.write("usage: hypit-preview-check <build.svrun> [<hypit.runtime.json>]"
- + " [--workspace <dir>] [--package-root <dir>]\n");
- process.exitCode = 2;
-} else {
- const invokedFrom = process.cwd();
- const runPath = resolve(invokedFrom, runArgument);
- const runtimeArgument = operands[1];
- const runtimePath = runtimeArgument === undefined ? undefined : resolve(invokedFrom, runtimeArgument);
- const workspaceFlag = flags.get("workspace");
- const packageRootFlag = flags.get("package-root");
- const workspaceRoot = workspaceFlag === undefined ? dirname(runPath) : resolve(invokedFrom, workspaceFlag);
- const packageRoot = packageRootFlag === undefined
- ? nearestPackageRoot(dirname(runPath)) ?? workspaceRoot
- : resolve(invokedFrom, packageRootFlag);
- const distributionPackageRoot = videoCliDistribution.packageRoot;
- if (distributionPackageRoot === undefined) throw new Error("active Hypit Distribution has no package root");
-
- const registry = await loadStudioCompanionRegistry({ workspaceRoot, packageRoot, distributionPackageRoot });
- const domain = await loadStudioDomain({ run: runPath, workspaceRoot, packageRoot });
- const buildLibrary = await openStudioBuildLibrary(runtimePath, packageRoot, workspaceRoot, distributionPackageRoot);
- const awaitingPrefix = "the Studio projection closure requires unresolved capabilities:";
-
- let session: Awaited<ReturnType<typeof readStudioSession>> | undefined;
- let refusal: string | undefined;
- let awaiting: string[] | undefined;
- try {
- const run = await loadStudioRun({
- run: runPath,
- domain,
- registry,
- ...(buildLibrary === undefined ? {} : { buildLibrary }),
- });
- inspectStudioRun(registry, run.source, run);
- session = await readStudioSession({
- domain,
- registry,
- run,
- workspaceRoot,
- revision: 0,
- });
- } catch (error) {
- const issues = (error as { readonly issues?: unknown }).issues;
- if (Array.isArray(issues)
- && issues.every((issue): issue is string => typeof issue === "string" && issue.startsWith(awaitingPrefix))) {
- awaiting = issues.flatMap((issue) => issue.slice(awaitingPrefix.length).split(",").map((item) => item.trim()));
- } else {
- refusal = error instanceof Error ? error.message : String(error);
- }
- } finally {
- await buildLibrary?.close();
- }
-
- if (refusal !== undefined) {
- process.stdout.write(`${JSON.stringify({ refused: refusal }, null, 2)}\n`);
- process.exitCode = 1;
- } else if (awaiting !== undefined) {
- const noun = awaiting.length === 1 ? "capability" : "capabilities";
- process.stdout.write(`preview-check: the graph is sound, waiting on ${awaiting.length} ${noun}.\n`);
- for (const capability of awaiting) process.stdout.write(` - ${capability}\n`);
- } else if (session !== undefined) {
- const problems: Array<Record<string, unknown>> = [];
- for (const track of session.snapshot.tracks) {
- const { status, errors, output } = track.provenance;
- if (errors.length > 0) problems.push({ track: track.label, errors });
- else if (status === "unresolved") problems.push({ track: track.label, unresolved: output });
- }
- if (problems.length === 0) {
- process.stdout.write(`preview-check: every Track resolved (${session.snapshot.tracks.length}).\n`);
- } else {
- for (const item of problems) process.stdout.write(`${JSON.stringify(item, null, 2)}\n`);
- process.exitCode = 1;
- }
- }
-}
diff --git a/test/lockfile-refresh.mjs b/test/lockfile-refresh.mjs
deleted file mode 100644
index c33117de..00000000
--- a/test/lockfile-refresh.mjs
+++ /dev/null
@@ -1,42 +0,0 @@
-#!/usr/bin/env node
-/**
- * Write a lockfile the repository can commit.
- *
- * `pnpm-workspace.yaml` globs `projects/*​/packages/*` so that a project-local author package is one
- * pnpm links — the authoring guide's convention depends on it. `.gitignore` excludes `projects/`,
- * because a project is working material. Both are right, and together they mean a local install
- * writes importers a clone will not have into a file the clone installs from.
- *
- * So the lockfile is written with that directory set aside, and put back afterwards. Dependencies
- * declared inside `packages/` resolve identically either way; only the importers differ.
- *
- * Run this after changing package dependencies to keep the committed lockfile reproducible.
- */
-import { rename } from "node:fs/promises";
-import { existsSync } from "node:fs";
-import { spawnSync } from "node:child_process";
-import { fileURLToPath } from "node:url";
-
-const root = fileURLToPath(new URL("../", import.meta.url));
-const projects = fileURLToPath(new URL("../projects", import.meta.url));
-const aside = fileURLToPath(new URL("../.projects-aside-for-lockfile", import.meta.url));
-
-const moved = existsSync(projects);
-if (moved) {
- if (existsSync(aside)) {
- console.error(`${aside} already exists; a previous refresh did not finish. Move it back by hand.`);
- process.exit(2);
- }
- await rename(projects, aside);
-}
-try {
- const install = spawnSync("pnpm", ["install", "--lockfile-only"], {
- cwd: root, stdio: "inherit", shell: process.platform === "win32", windowsHide: true,
- });
- if (install.status !== 0) process.exitCode = install.status ?? 1;
-} finally {
- if (moved) await rename(aside, projects);
-}
-console.log(moved
- ? "lockfile written with projects/ set aside; it is back where it was."
- : "lockfile written.");