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.

ci: execute the installed npm package through render and export

kashorina94ebe463563
diff --git a/.github/workflows/npm-package.yml b/.github/workflows/npm-package.yml
new file mode 100644
index 00000000..f10c74e2
--- /dev/null
+++ b/.github/workflows/npm-package.yml
@@ -0,0 +1,58 @@
+name: npm package execution
+
+on:
+ pull_request:
+ paths-ignore:
+ - "docs/**"
+ - "skills/**"
+ - "design/**"
+ workflow_dispatch:
+ workflow_call:
+ outputs:
+ version:
+ description: Version of the installed and executed tarball
+ value: ${{ jobs.package.outputs.version }}
+
+permissions:
+ contents: read
+
+concurrency:
+ group: npm-package-${{ github.workflow }}-${{ github.ref }}
+ cancel-in-progress: true
+
+jobs:
+ package:
+ runs-on: ubuntu-latest
+ timeout-minutes: 25
+ outputs:
+ version: ${{ steps.version.outputs.version }}
+ steps:
+ - uses: actions/checkout@v4
+ with:
+ persist-credentials: false
+ - uses: pnpm/action-setup@v4
+ - uses: actions/setup-node@v4
+ with:
+ node-version: 24
+ cache: pnpm
+ - run: pnpm install --frozen-lockfile
+ - name: Prepare the local media toolchain
+ run: |
+ sudo apt-get update
+ sudo apt-get install -y ffmpeg
+ - name: Read the package version
+ id: version
+ run: node --input-type=module -e 'import { readFileSync, appendFileSync } from "node:fs"; const { version } = JSON.parse(readFileSync("package.json", "utf8")); appendFileSync(process.env.GITHUB_OUTPUT, `version=${version}\n`);'
+ - name: Build the npm package and README
+ run: npm run pack:distribution
+ - name: Install, render and export outside the checkout
+ env:
+ VERSION: ${{ steps.version.outputs.version }}
+ run: npm run check:distribution -- "$PWD/dist/release/hypit-hypit-$VERSION.tgz"
+ - uses: actions/upload-artifact@v4
+ with:
+ name: npm-package
+ path: |
+ dist/release/*.tgz
+ dist/release/README.md
+ if-no-files-found: error
diff --git a/.github/workflows/publish-npm.yml b/.github/workflows/publish-npm.yml
index f9254541..6453b4ea 100644
--- a/.github/workflows/publish-npm.yml
+++ b/.github/workflows/publish-npm.yml
@@ -69,54 +69,7 @@ jobs:
package:
needs: [version, checks]
- runs-on: ubuntu-latest
- outputs:
- version: ${{ needs.version.outputs.version }}
- steps:
- - uses: actions/checkout@v4
- with:
- ref: ${{ github.sha }}
- persist-credentials: false
- - uses: pnpm/action-setup@v4
- - uses: actions/setup-node@v4
- with:
- node-version: 24
- - run: pnpm install --frozen-lockfile
- - name: Build the npm package and README
- run: npm run pack:distribution
- - name: Check the packaged CLI
- env:
- VERSION: ${{ needs.version.outputs.version }}
- run: |
- npm install --prefix "$RUNNER_TEMP/hypit-install" "$PWD/dist/release/hypit-hypit-$VERSION.tgz" --no-audit --no-fund
- hypit="$RUNNER_TEMP/hypit-install/node_modules/.bin/hypit"
- "$hypit" --version
- "$hypit" studio --help
- # An authored font resolves through the machine package root. The packaged layout ships
- # no node_modules beside its sources, so this reaches that root the way an installation
- # does; running it outside the checkout keeps the workspace links from answering.
- mkdir -p "$RUNNER_TEMP/hypit-source"
- printf '%s\n' \
- '<?svml using="@hypit/markup@1"?>' \
- '<svml>' \
- ' <import as="fonts" from="@hypit/fonts-open@1"/>' \
- ' <fonts:Stack id="body-font" family="inter" weight="400" style="normal"/>' \
- '</svml>' > "$RUNNER_TEMP/hypit-source/font.svml"
- cd "$RUNNER_TEMP/hypit-source"
- "$hypit" packages install @fontsource-variable/[email protected]
- "$hypit" check font.svml
- - uses: actions/upload-artifact@v4
- with:
- name: npm-package
- path: |
- dist/release/*.tgz
- dist/release/README.md
- if-no-files-found: error
- - name: Record the release inputs
- env:
- VERSION: ${{ needs.version.outputs.version }}
- run: |
- echo "Prepared @hypit/hypit@$VERSION from $GITHUB_SHA. Download npm-package to inspect the tarball and README." >> "$GITHUB_STEP_SUMMARY"
+ uses: ./.github/workflows/npm-package.yml
publish:
if: github.event_name == 'release' || inputs.publish
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index e3c70eb2..02e3835b 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -57,6 +57,14 @@ Run `npm run pack:distribution` to build public types and write the release tarb
`dist/release/`. This stages npm's selected files in a temporary directory and adapts the English
README for the npm page: public image URLs, both GIFs, and a link to the full video examples.
The repository READMEs remain unchanged. `dist/release/README.md` shows the packaged text.
+
+With FFmpeg and FFprobe available, run
+`npm run check:distribution -- dist/release/hypit-hypit-<version>.tgz` to install that tarball outside
+the checkout, build its chat example component, prepare its font and local renderer, render and export
+the video, and decode the result. It uses a separate Hypit state directory, stops its Runtime Worker,
+and retains the temporary project on failure. The `npm package execution` workflow runs this on PRs
+and is reused by publication; publication uploads the same tarball that was installed and executed.
+
For a formal release, use the existing GitHub Release workflow. Commit the next stable npm version
in `package.json` to `main`. Open
**Releases → Draft a new release**, choose that commit with tag `v<version>` (for example `v0.1.8`),
diff --git a/CONTRIBUTING.zh-CN.md b/CONTRIBUTING.zh-CN.md
index 740bc45d..d43de113 100644
--- a/CONTRIBUTING.zh-CN.md
+++ b/CONTRIBUTING.zh-CN.md
@@ -50,6 +50,14 @@ pnpm test # 包与服务适配器测试
脚本在临时目录中使用 npm 选定的文件,从英文 README 生成 npm 页面版本:使用公开图片地址,
保留两个 GIF,并将完整视频示例改为链接。仓库的两份 README 保持原样。
`dist/release/README.md` 可用于检查打包后的文案。
+
+准备好 FFmpeg 和 FFprobe 后,运行
+`npm run check:distribution -- dist/release/hypit-hypit-<version>.tgz`。它在仓库外安装该包,
+编译包内的聊天示例组件,准备字体和本地渲染器,渲染、导出并解码视频。检查使用独立的
+Hypit 状态目录,结束时停止自己的 Runtime Worker,失败时保留临时项目。
+`npm package execution` 工作流在 PR 上执行这项检查,发布流程复用它;发布的就是已经
+安装并执行过的同一份 tarball。
+
正式发布请走现有的 GitHub Release 工作流。把下一个稳定 npm 版本写入 `package.json` 并提交到
`main`。打开 **Releases → Draft a new release**,选择该提交,打上标签 `v<version>`(例如
`v0.1.8`),写好发布说明后发布 Release。带标签的提交必须包含此工作流。
diff --git a/package.json b/package.json
index 3330a47f..c6b58a66 100644
--- a/package.json
+++ b/package.json
@@ -168,6 +168,7 @@
],
"scripts": {
"pack:distribution": "node scripts/pack-distribution.mjs",
+ "check:distribution": "node scripts/check-distribution.mjs",
"build:public-types": "node scripts/build-public-types.mjs",
"check": "tsc -p tsconfig.json --noEmit",
"docs:dev": "vitepress dev docs",
diff --git a/scripts/check-distribution.mjs b/scripts/check-distribution.mjs
new file mode 100644
index 00000000..c294868b
--- /dev/null
+++ b/scripts/check-distribution.mjs
@@ -0,0 +1,94 @@
+import assert from "node:assert/strict";
+import { spawn } from "node:child_process";
+import { cp, mkdir, mkdtemp, readFile, rm, writeFile } from "node:fs/promises";
+import { tmpdir } from "node:os";
+import { join, resolve } from "node:path";
+
+// Execute the installed package as a user would, without workspace module links or host state.
+const npmCli = process.env.npm_execpath;
+if (!npmCli?.endsWith("npm-cli.js") || process.argv.length !== 3) {
+ throw new Error("Use npm run check:distribution -- /path/to/hypit-hypit-<version>.tgz");
+}
+const tarball = resolve(process.argv[2]);
+const root = await mkdtemp(join(tmpdir(), "hypit-distribution-"));
+const project = join(root, "project");
+await mkdir(project);
+const env = { ...process.env, HYPIT_STATE_HOME: join(root, "state") };
+// A caller's checkout resolver must not select sources outside this installation.
+delete env.HYPIT_DISTRIBUTION_ROOT;
+delete env.HYPIT_CLI_LAUNCHER;
+delete env.NODE_PATH;
+delete env.NODE_OPTIONS;
+
+function run(command, args, capture = false) {
+ console.log(`> ${command} ${args.join(" ")}`);
+ return new Promise((resolveRun, reject) => {
+ const child = spawn(command, args, { cwd: project, env, windowsHide: true,
+ stdio: ["ignore", capture ? "pipe" : "inherit", "inherit"] });
+ let stdout = "";
+ child.stdout?.setEncoding("utf8").on("data", (text) => { stdout += text; });
+ child.once("error", reject);
+ child.once("close", (code, signal) => {
+ if (code === 0) resolveRun(stdout);
+ else reject(new Error(`${command} ${args[0]} failed (${signal ?? code})${stdout ? `\n${stdout}` : ""}`));
+ });
+ });
+}
+const npm = (...args) => run(process.execPath, [npmCli, ...args]);
+const distribution = join(project, "node_modules", "@hypit", "hypit");
+const hypit = (args, capture = false) => run(process.execPath, [join(distribution, "bin", "hypit.mjs"), ...args], capture);
+const scope = ["--workspace", project, "--runtime", join(project, "hypit.runtime.json")];
+let runtimeStarted = false;
+let passed = false;
+try {
+ await writeFile(join(project, "package.json"), JSON.stringify({ name: "distribution-example", private: true, type: "module" }));
+ await npm("install", tarball, "--no-audit", "--no-fund");
+ await hypit(["--version"]);
+ await hypit(["studio", "--help"]);
+
+ const example = join(distribution, "examples", "semantic-composition");
+ for (const name of ["chat.svml", "chat.svrun", "chat.svs", "hypit.runtime.json"]) {
+ await cp(join(example, name), join(project, name));
+ }
+ const component = join(project, "packages", "chat-scene");
+ await cp(join(example, "packages", "chat-scene"), component, { recursive: true });
+ const installed = JSON.parse(await readFile(join(distribution, "package.json"), "utf8"));
+ const componentPackage = JSON.parse(await readFile(join(component, "package.json"), "utf8"));
+ componentPackage.devDependencies["@hypit/hypit"] = installed.version;
+ await writeFile(join(component, "package.json"), JSON.stringify(componentPackage, null, 2));
+ const projectPackage = JSON.parse(await readFile(join(project, "package.json"), "utf8"));
+ projectPackage.workspaces = ["packages/chat-scene"];
+ await writeFile(join(project, "package.json"), JSON.stringify(projectPackage, null, 2));
+ await npm("install", "--no-audit", "--no-fund");
+ await npm("run", "build", "--workspace", "@example/chat-scene");
+
+ const profilePath = join(project, "hypit.runtime.json");
+ const profile = JSON.parse(await readFile(profilePath, "utf8"));
+ profile.endpoints["hyperframes.local"].config.browserGpu = "software";
+ await writeFile(profilePath, JSON.stringify(profile, null, 2));
+ await hypit(["packages", "install", "@fontsource-variable/[email protected]"]);
+ await hypit(["check", "chat.svml", "--workspace", project]);
+ runtimeStarted = true;
+ await hypit(["runtime", "up", ...scope]);
+ const result = JSON.parse(await hypit(["build", "chat.svrun", ...scope, "--follow", "--max-wait-ms", "180000", "--json"], true));
+ assert.equal(result.build.work.outcome, "complete", JSON.stringify(result));
+ const output = join(project, "chat.mp4");
+ await hypit(["get", result.build.id, "--workspace", project, "--output", "final.video", "--to", output]);
+ const probe = JSON.parse(await run("ffprobe", ["-v", "error", "-show_streams", "-of", "json", output], true));
+ const video = probe.streams.find((stream) => stream.codec_type === "video");
+ assert.ok(video, "the exported file must contain video");
+ assert.equal(video.width, 540);
+ assert.equal(video.height, 960);
+ assert.equal(video.avg_frame_rate, "30/1");
+ assert.equal(Number(video.nb_frames), 240);
+ await run("ffmpeg", ["-v", "error", "-xerror", "-i", output, "-f", "null", "-"]);
+ passed = true;
+ console.log(`Installed @hypit/hypit@${installed.version}: component build, font, render and export passed.`);
+} finally {
+ if (runtimeStarted) {
+ try { await hypit(["runtime", "down", ...scope]); }
+ catch (error) { passed = false; console.error(error); process.exitCode = 1; }
+ }
+ if (passed) await rm(root, { recursive: true, force: true });
+ else console.error(`Distribution execution files retained at ${root}`);
+}