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(release): assemble embedded packages from ownership graph

kashorina80beb4ddadb
diff --git a/bin/hypit.mjs b/bin/hypit.mjs
index 8e165407..8670aef7 100755
--- a/bin/hypit.mjs
+++ b/bin/hypit.mjs
@@ -1,9 +1,9 @@
#!/usr/bin/env node
+import { register } from "tsx/esm/api";
import { readFileSync, realpathSync } from "node:fs";
import { dirname, resolve, sep } from "node:path";
import { fileURLToPath, pathToFileURL } from "node:url";
-import { spawnSync } from "node:child_process";
if (process.argv.length === 3 && ["--version", "-v"].includes(process.argv[2])) {
const manifest = JSON.parse(readFileSync(new URL("../package.json", import.meta.url), "utf8"));
@@ -19,22 +19,22 @@ process.emitWarning = function hypitWarning(warning, ...args) {
};
// Bootstrap and package activation must agree on the physical Distribution root. Windows short
-// paths can survive Node's ordinary resolution. Enter the TypeScript host only from the physical
-// path so its loader and every later package import share one file identity.
+// paths can survive Node's ordinary resolution while package lookup expands them through libuv.
const distributionRoot = realpathSync.native(resolve(dirname(fileURLToPath(import.meta.url)), ".."));
-const args = process.argv.slice(2);
-const canonicalLauncher = resolve(distributionRoot, "bin", "hypit.mjs");
-if (fileURLToPath(import.meta.url) !== canonicalLauncher) {
- const child = spawnSync(process.execPath, [...process.execArgv, canonicalLauncher, ...args], {
- stdio: "inherit",
- windowsHide: true,
- });
- if (child.error !== undefined) throw child.error;
- process.exit(child.status ?? 1);
-}
const distributionUrl = pathToFileURL(distributionRoot + sep);
-const { runHypit } = await import(new URL("bin/run.mjs", distributionUrl).href);
-await runHypit(args, {
- distributionRoot,
- launcher: canonicalLauncher,
+register();
+const { installDistributionPackageResolution } =
+ await import(new URL("packages/loader/src/node/distribution-resolution.ts", distributionUrl).href);
+installDistributionPackageResolution([distributionRoot]);
+const args = process.argv.slice(2);
+const { runInstalledCliApplication, runNodeCli } = await import(new URL("packages/cli/src/index.ts", distributionUrl).href);
+const { createVideoDistribution } = await import("@hypit/video");
+const videoDistribution = createVideoDistribution({
+ packageRoot: distributionRoot,
+ launcher: fileURLToPath(import.meta.url),
});
+await runNodeCli(args, async (argv, io) => await runInstalledCliApplication(argv, io, {
+ distribution: videoDistribution,
+ distributionRoot,
+ launcher: fileURLToPath(import.meta.url),
+}));
diff --git a/bin/run.mjs b/bin/run.mjs
deleted file mode 100644
index 07425651..00000000
--- a/bin/run.mjs
+++ /dev/null
@@ -1,24 +0,0 @@
-import { register } from "tsx/esm/api";
-import { sep } from "node:path";
-import { pathToFileURL } from "node:url";
-
-/** Enter the TypeScript application after the plain-JavaScript launcher has canonicalized itself. */
-export async function runHypit(args, { distributionRoot, launcher }) {
- register();
- const distributionUrl = pathToFileURL(distributionRoot + sep);
- const { installDistributionPackageResolution } =
- await import(new URL("packages/loader/src/node/distribution-resolution.ts", distributionUrl).href);
- installDistributionPackageResolution([distributionRoot]);
- const { runInstalledCliApplication, runNodeCli } =
- await import(new URL("packages/cli/src/index.ts", distributionUrl).href);
- const { createVideoDistribution } = await import("@hypit/video");
- const videoDistribution = createVideoDistribution({
- packageRoot: distributionRoot,
- launcher,
- });
- await runNodeCli(args, async (argv, io) => await runInstalledCliApplication(argv, io, {
- distribution: videoDistribution,
- distributionRoot,
- launcher,
- }));
-}
diff --git a/package.json b/package.json
index 4ada663d..010abd3f 100644
--- a/package.json
+++ b/package.json
@@ -252,9 +252,6 @@
"files": [
"bin",
"dist/public/**/*.d.ts",
- "packages/{blob,result,caption,cli,compiler,producer,composition,kernel,executor,author,endpoint,atomic-file,generation,facet,html-program,markup,media,narrative,narrative-caption,narrative-temporal,loader,project,protocol,region-evidence,run,runtime,source,spatial,speech-evidence,recipe,temporal,text,timeline,admission,workspace}/src/**/*",
- "packages/{blob,result,caption,cli,compiler,producer,composition,kernel,executor,author,endpoint,atomic-file,generation,facet,html-program,markup,media,narrative,narrative-caption,narrative-temporal,loader,project,protocol,region-evidence,run,runtime,source,spatial,speech-evidence,recipe,temporal,text,timeline,admission,workspace}/package.json",
- "packages/{blob,result,caption,cli,compiler,producer,composition,kernel,executor,author,endpoint,atomic-file,generation,facet,html-program,markup,media,narrative,narrative-caption,narrative-temporal,loader,project,protocol,region-evidence,run,runtime,source,spatial,speech-evidence,recipe,temporal,text,timeline,admission,workspace}/README.md",
"docs/public/hypit-logo-dark.svg",
"docs/public/hypit-logo-light.svg",
"examples/minimal-author-package/README.md",
diff --git a/scripts/distribution-ownership.mjs b/scripts/distribution-ownership.mjs
index 8b55c8de..e021c5ae 100644
--- a/scripts/distribution-ownership.mjs
+++ b/scripts/distribution-ownership.mjs
@@ -41,7 +41,7 @@ export async function distributionEmbeddedPackageDirectories(repositoryRoot) {
const paths = [
...globSync("packages/*/package.json", { cwd: repositoryRoot }),
...globSync("services/*/package.json", { cwd: repositoryRoot }),
- ].sort();
+ ].map((path) => path.replaceAll("\\", "/")).sort();
const packages = await Promise.all(paths.map(async (path) => ({
path,
manifest: await manifest(repositoryRoot, path),
diff --git a/scripts/pack-distribution.mjs b/scripts/pack-distribution.mjs
index e92319be..32410cff 100644
--- a/scripts/pack-distribution.mjs
+++ b/scripts/pack-distribution.mjs
@@ -1,5 +1,5 @@
import { execFileSync } from "node:child_process";
-import { copyFile, mkdir, mkdtemp, readFile, rm, writeFile } from "node:fs/promises";
+import { copyFile, cp, mkdir, mkdtemp, readFile, rm, writeFile } from "node:fs/promises";
import { tmpdir } from "node:os";
import { dirname, resolve } from "node:path";
import { fileURLToPath } from "node:url";
@@ -41,15 +41,6 @@ async function releaseDependencyVersion(owner, name, declared) {
npm(["run", "build:public-types"], root);
const [inventory] = JSON.parse(npm(["pack", "--dry-run", "--ignore-scripts", "--json"], root, true));
const embeddedPackageDirectories = await distributionEmbeddedPackageDirectories(root);
-const inventoriedPackageDirectories = new Set(inventory.files.flatMap(({ path }) => {
- const match = /^packages\/([^/]+)\//u.exec(path);
- return match === null ? [] : [match[1]];
-}));
-for (const directory of embeddedPackageDirectories) {
- if (!inventoriedPackageDirectories.has(directory)) {
- throw new Error(`Embedded Distribution package @hypit/${directory} has no npm files`);
- }
-}
let readme = await readFile(resolve(root, "README.md"), "utf8");
const examples = readme.indexOf("## Examples\n");
const next = readme.indexOf("## Use the Hypit skill\n", examples);
@@ -77,9 +68,25 @@ try {
await mkdir(dirname(target), { recursive: true });
await copyFile(resolve(root, path), target);
}
+ for (const directory of [...embeddedPackageDirectories].sort()) {
+ const source = resolve(root, "packages", directory);
+ const target = resolve(stage, "packages", directory);
+ await mkdir(target, { recursive: true });
+ await cp(resolve(source, "src"), resolve(target, "src"), { recursive: true });
+ await copyFile(resolve(source, "package.json"), resolve(target, "package.json"));
+ await copyFile(resolve(source, "README.md"), resolve(target, "README.md"));
+ }
await writeFile(resolve(stage, "README.md"), readme);
const stagedManifestPath = resolve(stage, "package.json");
const stagedManifest = JSON.parse(await readFile(stagedManifestPath, "utf8"));
+ stagedManifest.files = [
+ ...(stagedManifest.files ?? []).filter((path) => !path.startsWith("packages/")),
+ ...[...embeddedPackageDirectories].sort().flatMap((directory) => [
+ `packages/${directory}/src/**/*`,
+ `packages/${directory}/package.json`,
+ `packages/${directory}/README.md`,
+ ]),
+ ];
const independentDefaults = Object.entries(stagedManifest.dependencies ?? {})
.filter(([, version]) => typeof version === "string" && version.startsWith("workspace:"))
.map(([name]) => name);
@@ -102,6 +109,14 @@ try {
}
await mkdir(output, { recursive: true });
const packed = npm(["pack", "--ignore-scripts", "--pack-destination", output, "--json"], stage, true);
+ const [packedInventory] = JSON.parse(packed);
+ const packedPaths = new Set(packedInventory.files.map(({ path }) => path));
+ for (const directory of embeddedPackageDirectories) {
+ if (!packedPaths.has(`packages/${directory}/package.json`)
+ || ![...packedPaths].some((path) => path.startsWith(`packages/${directory}/src/`))) {
+ throw new Error(`Embedded Distribution package @hypit/${directory} is incomplete in the npm tarball`);
+ }
+ }
await writeFile(resolve(output, "README.md"), readme);
console.log(packed);
} finally {