mirror of
https://github.com/heygen-com/hyperframes.git
synced 2026-08-31 02:41:44 +00:00
* feat(cli): search the catalog by meaning, in three named tiers Browsing the registry means matching names and tags, which fails whenever the author's wording differs from yours. "make the pace feel faster" finds nothing when the move is described as "velocity-driven blur". This ranks by meaning instead. Three tiers, and the command always says which one answered: words shared vocabulary, free, offline, no account on-device bge-small, free, offline, one opt-in download hosted Gemini, free for signed-in HeyGen users The tier is stated because a quietly worse answer looks exactly like a good one. --json carries it as a token alongside dropped, shown, total and top_score, so an agent reads provenance as data rather than matching English that is written to be reworded. Two consents, asked once each, and never conflated. Sending a query is a privacy question, so the prompt says the query is sent. Downloading a model is a disk and bandwidth question, so that prompt talks about size. Neither fires without a terminal: an unattended run sends nothing and downloads nothing unless a flag records that a person agreed. The catalog is derived from registry-item.json rather than from a separate document, so the set that is ranked and the set that can be installed are the same object by construction. Only the on-device vectors are committed; the hosted vectors are nine megabytes and belong on the server. top_score is reported and never acted on. A "nothing matched" threshold looked clean on long briefs and collapsed on the short queries people type: "a logo appears" scores 0.6181 and keyboard mash scores 0.6417, so any cut that catches the noise rejects the real query. The measurement is in the evals directory rather than in this branch. Not covered here. The published recall figures were measured against a separate hand-written document, not against registry text, so they should not be quoted for this catalog until re-measured. The offline tier needs a normal install: a single-file build cannot load the native ONNX runtime, which the command now reports instead of silently degrading. And the drop-detection path has never been observed firing outside its author's tests. * fix(cli): make this branch pass the repo's own gates Three things `bun run lint` and `fallow audit --base origin/main` rejected. CI runs both, so none of this branch would have gone green. Found by running them, not by reading the diff. process.exit in catalog.ts, twice: an invalid --type and a cancelled picker. check:cli-process-ownership reserves that for cli.ts, and the rule is not cosmetic — process.exit tears the process down where it stands, so anything cli.ts has queued to run on the way out is dropped. finishCommand throws a CliResultSignal that cli.ts turns into the exit code, which is what init.ts already does for a cancelled prompt. Three exports with no consumers. normalize keeps its body and loses its export; localEmbedder is the only caller. modelsDirectory goes entirely, having no caller inside its file or out. The WordPieceConfig re-export goes, and with it the import it existed to forward: the type is exported from wordpiece.ts, where its consumers already take it from. Complexity. prepareOnDeviceTier is lifted out of run(), which took run from 64 cyclomatic and CRAP 948 to 54 and 684. That block is one decision — can the offline tier run, and if not, why not — and its only product is a list of warnings, so it reads and tests as a unit, which it could not do inline. The rest is suppressed rather than refactored, each with its reason on the line above. Finishing run() means extracting its three output paths, and that is a refactor of a command this branch already changes for other reasons: a separate initiative, not something to absorb here. Every suppression says what shape the function has and why; a bare marker on a function nobody can justify is how a threshold stops meaning anything. Verified: `bun run lint` exits 0, fallow reports no issues across 27 changed files, and 2540 CLI tests pass. * feat(cli): ship the local search tiers only, drop the hosted one Search now has two tiers, both local: shared-vocabulary word matching, and the opt-in on-device model. The hosted tier, which sent the query to a HeyGen endpoint and ranked it with a hosted model, is removed. This is a scope decision, not a defect. The endpoint works and its own change is reviewed and green; it is simply not what we want to ship first. Landing local only means the feature has no backend dependency, no auth requirement, and nothing leaves the machine unless someone opts into downloading a model. Gone: registry/smartSearch.ts and its test, the --smart and --no-smart flags, the outcome plumbing through the command, the remote branch of applySearch, the remote tier, and the hosted-only JSON fields (ranking, catalog_version, top_score). Also the smartSearchEnabled consent field in telemetry config, which was the persisted storage behind the hosted consent and would otherwise have been left as dead configuration surface. Kept exactly as they were: both local tiers, the --on-device and --yes flags, the download consent prompt, and the runtime check that happens before the download rather than after it. The --json envelope still reports query, tier, tier_detail, shown, total, dropped, warnings and results, so an agent can still tell which tier answered and why. tierToken now distinguishes on-device from words. Verified: lint exits 0, fallow reports no issues, 2522 CLI tests pass, and the command was exercised directly. A query answers on the on-device tier where the model is installed and falls back to word matching where it is not, reporting that fallback in warnings rather than silently. An unknown --type still exits 1 with a readable message, and --smart is now rejected as an unknown flag. * fix(cli): count only moves this registry cannot install as dropped The dropped count was computed against the list left after the user's own --type and --tag filters, so every move the user excluded was reported as one the registry is missing. Filtering made the number go up: the same query reported 277 unfiltered and 302 with --type block. The count exists so a caller can tell "nothing matched your words" apart from "the ranker suggested things this project cannot install". Conflating it with user filtering destroys exactly that signal, and worse, genuine index skew and a self-inflicted filter printed a byte-identical line with opposite remedies -- one means refresh the shelf, the other means drop a flag, and refreshing does nothing. Now counted against the registry rather than the filtered view. The manifest is already fetched whole and narrowed in memory, so keeping the unnarrowed name set costs no extra request, and item loading still runs only on the filtered subset. Verified against ground truth rather than by eye: the vector artifact holds 411 names, the registry holds 168 installable items, and 134 of those names exist in both, so 277 are genuinely uninstallable. The count now reads 277 unfiltered, 277 under --type block, 277 under --type component and 277 under --tag, and the skew it reports is real -- the artifact predates dropping the UI primitives and still ranks moves that are no longer on the shelf. Reported by Vance Ingalls, who also noted this closes an item the status doc listed as unverified. Two earlier sweeps could not make the count fire because neither combined a filter with a query. Tests pin the three cases: a genuinely absent name counts, a filter-excluded name does not, and a fully installable ranking reports zero. * fix(cli): tell the user when meaning search cannot see the catalog The on-device index was fetched once and never revalidated: the only freshness check was two existsSync calls. A move added after that fetch was invisible to meaning search permanently, not down-ranked but absent from the candidate set. The registry manifest on the same command carries a 24h TTL, so the two halves of one feature disagreed about staleness. The dropped count reported over-coverage only, names the index has that the registry lacks. Under-coverage was never computed, so the harmless direction was instrumented and the costly one was silent. Reproduced with an index truncated to 120 of 168 moves: dropped read 0, perfect health, while 48 moves were unreachable. Counts under-coverage from the name list the artifact already carries, so no extra request. Warns only when non-zero, and names the remedy. The remedy had to be made true: --on-device could not refresh a stale index because hasLocalVectors short-circuited the fetch. That flag now refetches when the index is absent or no longer covering. Two defects the reproduction surfaced. A failed refresh reported the tier unavailable while the old vectors were still on disk and still ranking. And the fetch wrote its two files one at a time, so failing between them paired a new name list with an old matrix, a hard load error rather than stale data. It now writes both or neither, which matters more once refresh runs on staleness. top_score returns, scoped to the on-device tier and set to the score of the best result actually shown rather than the ranking head, which can describe a row the caller never received. Also: scripts/ is now typechecked. It never was, which is how a build script that crashes after the paid embedding call, and two scripts whose imports do not resolve at all, went unnoticed. 43 errors fixed, no suppressions. And the docs stop describing a --smart hosted tier that was deleted, an item that does not exist, and a registry refresh that cannot fix a stale vector index. * ci: fail when the search index stops covering the registry The catalog vector artifact is regenerated by hand. Nothing in CI, in package.json or in a hook rebuilds it, because embedding needs the 32 MB model. So adding a registry item silently makes it invisible to meaning search until someone remembers to regenerate. The failure is asymmetric, which is what makes it easy to miss. Removing an item is self-healing: the ranker still scores the dead vector, then filters the name before display, so a user is never offered something they cannot install. Adding one is not: the item is absent from the candidate set entirely, not ranked low. Comparing the two name lists needs neither the model nor a network call, so the gate runs in seconds. CI checks rather than fixes, for the same reason it cannot regenerate. Scoped to blocks and components. Examples are starter projects a user scaffolds, never something catalog ranks, and the artifact carries no vector for them, so demanding one would keep this gate permanently red and it would be ignored within a week. Verified in both directions rather than assumed: adding an unindexed item exits 1 and names it, restoring the registry exits 0. * fix(catalog): rebuild the search index from the registry build-local-vectors.ts read registry/catalog-artifact/catalog.json, a file no script in this repo writes and which is not committed, so the documented regeneration command failed on a missing path. That is why the index could drift from the registry with nothing to run to fix it. It now reads registry/blocks/* and registry/components/* through catalogFromRegistry, the existing helper that already produced the right shape but had no caller. Rebuilding reproduces the shipped 168 rows byte for byte. A lefthook catalog-index command regenerates and re-stages both artifact files whenever a staged registry-item.json changes, mirroring the skills-manifest pattern, so adding or removing an item keeps the index in sync without anyone remembering to. Verified end to end: staging a new item took the artifact 168 to 169 rows and staged it in 0.80s. * fix(cli): refuse a half-downloaded vector cache The two artifact files have to agree on how many rows there are, and until now nothing checked that before writing them. A truncated or wrong-model response landed in the cache and only failed at load, on every later search, until someone cleared it by hand. The pair is now checked first and refused as a unit, and the cache is created 0o700 with 0o600 files rather than inheriting the umask of a directory the caller may have pointed anywhere. Also lifts the capture setup the two preview generators had drifted into sharing into scripts/preview-capture.ts, and splits the vector builders batching and packing out of main. Both were findings the audit attributed to this branch. * fix(cli): keep the catalog vitest run with the tests it runs Restacking took the base package.json wholesale, which dropped the vitest dependency and the scripts/catalog run this PR adds. Both belong here rather than under it. * fix(cli): stop the declined model download from happening anyway Answering no to the on-device download offer recorded no and warned, then carried on. The guard below it is localModelConsent() !== false, which the decline had just made false, so it was skipped rather than taken: control reached recordLocalModelConsent(true), overwrote the answer with yes, and fetched the 32 MB model the user had refused. Next run it never asked again. No test could catch it. The stub pinned localModelStatus to ready, so the prompt never fired, and recordLocalModelConsent was a no-op that recorded nothing. Two tests now cover the offer, and they need three things the old stubs did not model: the run has to look like a terminal, because off one the command treats --on-device as the consent and never asks; the ONNX probe has to answer true, or an accepted offer returns at the runtime guard before it can download; and the status has to follow the recorded answer, or the second offer later in the run fires as well. Removing the return makes the decline test fail. * fix(catalog): let someone without the model still add a component The pre-commit hook rebuilds the search index, and rebuilding needs the 32 MB embedding model. An outside contributor adding a registry item does not have it, so their commit died inside the ONNX loader on an ENOENT naming a path they never set, and the CI gate then told them to run the command that had just crashed. The model is an opt-in for search, not a build dependency, so nobody is charged for it to contribute. The builder checks first and explains itself, exiting 3 for cannot as distinct from 1 for failed. The hook treats 3 as skip and lets the commit through. The gate now names both paths: regenerate if you have the model, leave it if you do not and a maintainer will. Verified both ways: with no model the builder explains and the hook exits 0; with the model it still regenerates byte-identically. * docs: say that anyone can add a registry item, and stop hand-editing a generated file Two defects, one of them the reason 64 stale entries survived in registry.json. The checklist told contributors to add their item to registry/registry.json. That file is generated from the item directories, so an entry added by hand survives until the next regeneration and then vanishes, and one left behind for a directory that no longer exists is worse: hyperframes add resolves the name and then fails on missing files. Both CONTRIBUTING.md and the agent-facing skill reference now run the generator instead. Nothing said contribution was maintainer-only, but nothing said it was not either, and two steps do need assets an outside contributor has no reason to install. Those are now named in a table with what happens if you do not have them, matching how the preview image was already handled. The search index is the new one: the model behind it is a 32 MB opt-in for search, not a build dependency. * fix(cli): harden on-device catalog search * fix(cli): refresh stale catalog vectors * test: create catalog vector temp dirs securely
231 lines
11 KiB
Markdown
231 lines
11 KiB
Markdown
# Contributing to Hyperframes
|
|
|
|
Thanks for your interest in contributing to Hyperframes! This guide will help you get started.
|
|
|
|
## Getting Started
|
|
|
|
1. Fork the repository
|
|
2. Clone your fork: `git clone https://github.com/YOUR_USERNAME/hyperframes.git`
|
|
3. Install dependencies: `bun install`
|
|
4. Create a branch: `git checkout -b my-feature`
|
|
|
|
## Development
|
|
|
|
```bash
|
|
bun install # Install all dependencies
|
|
bun run dev # Run the studio (composition editor)
|
|
bun run build # Build all packages
|
|
bun run --filter '*' typecheck # Type-check all packages
|
|
bun run lint # Lint all packages
|
|
bun run format:check # Check formatting
|
|
```
|
|
|
|
### Running Tests
|
|
|
|
```bash
|
|
bun run --filter @hyperframes/core test # Core unit tests (vitest)
|
|
bun run --filter @hyperframes/engine test # Engine unit tests (vitest)
|
|
bun run --filter @hyperframes/core test:hyperframe-runtime-ci # Runtime contract tests
|
|
```
|
|
|
|
### Linting & Formatting
|
|
|
|
```bash
|
|
bun run lint # Run oxlint
|
|
bun run lint:fix # Run oxlint with auto-fix
|
|
bun run format # Format all files with oxfmt
|
|
bun run format:check # Check formatting without writing
|
|
```
|
|
|
|
Git hooks (via [lefthook](https://github.com/evilmartians/lefthook)) run automatically after `bun install` and enforce linting + formatting on staged files before each commit.
|
|
|
|
#### Type-safety conventions
|
|
|
|
We aim for honest types — code that lies to the compiler eventually lies to users. The underlying convention is:
|
|
|
|
- **Avoid `any`.** Use `unknown` and narrow it where possible.
|
|
- **Avoid `as T` type assertions.** They suppress type-checker warnings without telling the compiler anything new. Prefer:
|
|
- Type guards (`function isFoo(x): x is Foo`)
|
|
- `instanceof` / `typeof` narrowing
|
|
- Centralized narrowing helpers (e.g. `resolveIframe`)
|
|
- Properly-typed interfaces at the source
|
|
- **Acceptable `as` use, with a comment explaining why:**
|
|
- `as const` — literal narrowing; always safe
|
|
- `as unknown as T` — explicit double-cast at hard type-system boundaries (e.g. parsing untrusted JSON, FFI/postMessage). Pair with a one-line justification.
|
|
- **Avoid `!` non-null assertions** outside of post-`if`-checked code paths. Use `??` defaults or guard clauses instead.
|
|
|
|
If you must add a cast, add a comment:
|
|
|
|
```ts
|
|
// `postMessage` data is `unknown`; the runtime guarantees this shape.
|
|
const event = data as unknown as RuntimeEvent;
|
|
```
|
|
|
|
## Adding Registry Items (Blocks & Components)
|
|
|
|
The registry at `registry/` contains reusable items installable via `hyperframes add <name>`. Each item lives in its own directory under `registry/blocks/` or `registry/components/`.
|
|
|
|
### Directory structure
|
|
|
|
```
|
|
registry/blocks/<name>/
|
|
registry-item.json # Manifest (name, type, description, tags, files)
|
|
<name>.html # The composition HTML
|
|
|
|
registry/components/<name>/
|
|
registry-item.json # Manifest (no dimensions/duration for components)
|
|
<name>.html # The snippet HTML to paste into a composition
|
|
demo.html # Required — standalone demo showing the effect
|
|
```
|
|
|
|
### The `demo.html` convention
|
|
|
|
Every **component** must ship a companion `demo.html`. This file:
|
|
|
|
1. Is a complete, standalone HTML document (with `<!doctype html>`, GSAP CDN, etc.)
|
|
2. Shows the component effect applied to representative content
|
|
3. Registers a GSAP timeline on `window.__timelines` so it can be previewed in the Studio and rendered by the CI preview pipeline
|
|
4. Uses `data-composition-id="<name>-demo"` to avoid ID collisions
|
|
|
|
Blocks don't need `demo.html` — they are already standalone compositions.
|
|
|
|
### Checklist for new items
|
|
|
|
**Anyone can add an item.** Nothing here needs commit access, and the two steps
|
|
that do need something a contributor may not have are handled by a maintainer
|
|
before merge, listed at the end.
|
|
|
|
1. Create `registry/<blocks|components>/<name>/registry-item.json` following the [schema](packages/core/schemas/registry-item.json)
|
|
2. For components: include a `demo.html`
|
|
3. Run `npx hyperframes lint` and `npx hyperframes validate` on your HTML
|
|
4. Test the install flow: `hyperframes add <name> --dir /tmp/test-project`
|
|
5. Regenerate the manifest: `npx tsx scripts/generate-registry-items.ts`
|
|
|
|
`registry/registry.json` is generated from the item directories, so edit it with
|
|
that script rather than by hand. An entry added by hand survives until the next
|
|
regeneration and then disappears; entries left behind for directories that no
|
|
longer exist are worse, because `hyperframes add <name>` resolves the name and
|
|
then fails on missing files.
|
|
|
|
### What a maintainer finishes for you
|
|
|
|
Two things need assets an outside contributor is not expected to install. Open
|
|
the pull request without them and say so; neither blocks review.
|
|
|
|
| Thing | If you have it | If you do not |
|
|
| ----------------------------------------------- | --------------------------------------------------------- | ----------------------------------------------------------------------- |
|
|
| The search index (`registry/catalog-artifact/`) | The pre-commit hook rebuilds and stages it | The hook skips, CI names the gap, a maintainer regenerates before merge |
|
|
| The catalog preview image | Internal contributors run `scripts/upload-docs-images.sh` | Attach the preview MP4 to the PR instead |
|
|
|
|
The search index needs a 32 MB embedding model, which is an opt-in for catalog
|
|
search rather than a build dependency. Until it is regenerated your item is
|
|
findable by word search and not by meaning, which is the same state as any item
|
|
published since a user last refreshed their copy.
|
|
|
|
### Auto-generated docs
|
|
|
|
When you add a new block or component, its documentation page is generated automatically — you don't need to write MDX by hand.
|
|
|
|
Run the codegen script after adding items:
|
|
|
|
```bash
|
|
npx tsx scripts/generate-catalog-pages.ts
|
|
```
|
|
|
|
This produces:
|
|
|
|
- `docs/catalog/blocks/<name>.mdx` — per-block detail page
|
|
- `docs/catalog/components/<name>.mdx` — per-component detail page
|
|
- `docs/public/catalog-index.json` — flat manifest for the catalog grid page
|
|
- Updates `docs/docs.json` navigation with the new pages
|
|
|
|
The script wipes `docs/catalog/` before regenerating, so deleted items are automatically cleaned up.
|
|
|
|
## Pull Requests
|
|
|
|
- Use [conventional commit](https://www.conventionalcommits.org/) format for **all commits** (e.g., `feat: add timeline export`, `fix: resolve seek overflow`). Enforced by a git hook.
|
|
- CI must pass before merge (build, typecheck, tests, semantic PR title)
|
|
- PRs require at least 1 approval
|
|
|
|
## Packages
|
|
|
|
| Package | Description |
|
|
| ----------------------- | ------------------------------------------- |
|
|
| `@hyperframes/core` | Types, HTML generation, runtime, linter |
|
|
| `@hyperframes/engine` | Seekable page-to-video capture engine |
|
|
| `@hyperframes/producer` | Full rendering pipeline (capture + encode) |
|
|
| `@hyperframes/studio` | Composition editor UI |
|
|
| `hyperframes` | CLI for creating, previewing, and rendering |
|
|
|
|
## Releasing (Maintainers)
|
|
|
|
All packages use **fixed versioning** — every release bumps all packages to the same version.
|
|
|
|
### Stable releases
|
|
|
|
```bash
|
|
bun run release:prepare 0.2.0 # drafts changelog if needed, then creates the release commit/tag after review
|
|
git push origin main # push the release commit
|
|
git push origin v0.2.0 # push the tag → triggers the publish workflow
|
|
```
|
|
|
|
> Push the **specific tag**, not `git push --tags` — the latter pushes every local tag and the whole push is rejected if any one already exists on the remote.
|
|
|
|
The `release:prepare` script drafts missing release notes on the first run and stops for manual review. After the generated TODO summary is rewritten, rerun the same command; it delegates to `set-version`, which creates a `chore: release v<version>` commit and a `v<version>` git tag. Pushing the tag triggers CI to publish all packages to npm and create a GitHub Release.
|
|
|
|
`set-version` also refuses to tag if a **higher** semver tag already exists (a stale higher tag would hijack tag-sorting installers like `npx skills`). Delete the stray tag (`git tag -d <tag> && git push origin :refs/tags/<tag>`) or, only if intentional, pass `--skip-monotonicity-check`.
|
|
|
|
### Pre-releases (alpha / beta / rc)
|
|
|
|
Use a pre-release suffix to publish to a named npm dist-tag instead of `latest`:
|
|
|
|
```bash
|
|
bun run set-version 0.2.0-alpha.1 # first alpha
|
|
git push origin v0.2.0-alpha.1 # publishes to npm with --tag alpha
|
|
|
|
bun run set-version 0.2.0-alpha.2 # iterate
|
|
bun run set-version 0.2.0-beta.1 # promote to beta (--tag beta)
|
|
bun run set-version 0.2.0-rc.1 # release candidate (--tag rc)
|
|
bun run set-version 0.2.0 # final stable release (--tag latest)
|
|
```
|
|
|
|
Consumers install pre-releases with `npm install @hyperframes/core@alpha` (or `@beta`, `@rc`). The `latest` tag is never touched by pre-releases, so `npm install @hyperframes/core` always gets the last stable version.
|
|
|
|
Pre-releases also create GitHub Releases marked as **pre-release**.
|
|
|
|
### Options
|
|
|
|
If you need to bump versions without committing (e.g., for a release PR), pass `--no-tag`:
|
|
|
|
```bash
|
|
bun run set-version 0.2.0 --no-tag # updates package.json files only
|
|
```
|
|
|
|
## Reporting Issues
|
|
|
|
- Use [GitHub Issues](https://github.com/heygen-com/hyperframes/issues) for bug reports and feature requests
|
|
- Search existing issues before creating a new one
|
|
- Include reproduction steps for bugs
|
|
|
|
## AI-Assisted Contributions
|
|
|
|
We welcome contributions that use AI tools (GitHub Copilot, Claude, ChatGPT, etc.). If you used AI to help write a PR, there is no need to disclose it — we review all code on its merits. However:
|
|
|
|
- You are responsible for the correctness of any code you submit, regardless of how it was generated.
|
|
- AI-generated tests must actually test meaningful behavior, not just assert truthy values.
|
|
- Do not submit AI-generated code you don't understand. If you can't explain what a change does during review, it will be rejected.
|
|
|
|
## Governance
|
|
|
|
Hyperframes uses a **BDFL (Benevolent Dictator for Life)** governance model. The core maintainers at HeyGen have final say on the project's direction, API design, and what gets merged. This keeps the project focused and moving fast.
|
|
|
|
Community input is valued and encouraged — open issues, propose RFCs, and discuss in PRs. But final decisions rest with the maintainers.
|
|
|
|
## Code of Conduct
|
|
|
|
This project follows the [Contributor Covenant Code of Conduct](CODE_OF_CONDUCT.md). By participating, you are expected to uphold this code.
|
|
|
|
## License
|
|
|
|
By contributing, you agree that your contributions will be licensed under the project's license. See [LICENSE](LICENSE) for details.
|