Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ src-tauri/icons/Assets.xcassets/
static/oss-licenses.json
# Prerendered overlay route (vite build output, regenerated every build)
static/overlay.html
# SPA fallback page (vite build output). It names hashed files under static/_app/, so a
# committed copy is stale after any build and broken on a fresh clone.
static/index.html
# Generated by scripts/env/load.mjs when DEV_PORT != 8420
.tauri-dev-port.json

Expand Down
1 change: 1 addition & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
bun scripts/ensure-attribution.mjs
bun run check
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

All notable changes to Echophrase will be documented in this file.

## [Unreleased]

### Developers
- Committing a dependency change (`Cargo.lock`, `bun.lock`) now regenerates the third-party notices in the same commit, so the "Attribution is current" check no longer fails afterwards. It needs `cargo-about` at the version `ci.yml` pins.
- `static/index.html` is no longer tracked. It is build output, so it showed up as modified after every build.

## [v1.3.0] - 2026-12-02
<!-- discord: new seamless model updates, up to 1.9x faster than handy on short dictations on windows, hold-to-talk stops the instant you let go -->

Expand Down
2 changes: 1 addition & 1 deletion CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@ buttons). Add an entry whenever you work around a bug you do not own.
- When updating `env.yaml`, also update `env.yaml.template`
- Safetensors only for Candle models (no GGUF, no PyTorch .bin)
- All user-facing strings must be localized. When adding or changing any string, update all three of `src/lib/locales/en.json`, `src/lib/locales/zh-TW.json` and `src/lib/locales/zh-CN.json` (a vitest parity test fails on key drift). Use `t('key')` in templates and `translate('key')` in JS.
- **When adding a new Rust dependency** (`cargo add`), check its license against `src-tauri/about.toml`'s `accepted` allowlist (the copyleft guard - `cargo about generate` fails the build if a shipped crate's license isn't listed). If the license is already accepted (MIT, Apache-2.0, BSD, MIT-0, CC0-1.0, etc.), no action needed - attribution text itself is auto-generated from `Cargo.lock` (`bun run licenses:generate`), never hand-written. Any `Cargo.lock` change that alters a shipped crate's name, version or license (even a patch bump of a transitive crate) must commit the regenerated `ATTRIBUTION.md` / `src-tauri/licenses/THIRD-PARTY-NOTICES.txt` in the same PR, or the "Attribution is current" CI job fails. The generator also rebuilds the frontend (which rewrites the tracked `static/index.html` - restore it) and writes `licenses.generated.json` into a sibling `echophrase-www` checkout when one exists. If it's a new license not yet in the list, confirm it's permissive/notice-only (never add GPL/AGPL/LGPL) before adding it to `accepted`. New frontend (`bun add`) dependencies are covered automatically by `rollup-license-plugin` in `vite.config.js` - no manual step there either.
- **When adding a new Rust dependency** (`cargo add`), check its license against `src-tauri/about.toml`'s `accepted` allowlist (the copyleft guard - `cargo about generate` fails the build if a shipped crate's license isn't listed). If the license is already accepted (MIT, Apache-2.0, BSD, MIT-0, CC0-1.0, etc.), no action needed - attribution text itself is auto-generated from `Cargo.lock` (`bun run licenses:generate`), never hand-written. Any `Cargo.lock` change that alters a shipped crate's name, version or license (even a patch bump of a transitive crate) must commit the regenerated `ATTRIBUTION.md` / `src-tauri/licenses/THIRD-PARTY-NOTICES.txt` in the same PR, or the "Attribution is current" CI job fails. The pre-commit hook does this for you: `scripts/ensure-attribution.mjs` regenerates and stages both files whenever a commit stages `Cargo.lock`, `bun.lock`, `src-tauri/about.toml`, `src-tauri/about.hbs`, `vite.config.js` or the generator itself (about a minute; every other commit is unaffected). It needs `cargo-about` at the exact version `ci.yml` pins and refuses the commit otherwise - install it, do not skip the hook. Run by hand (`bun run licenses:generate`, the release flow), the generator also writes `licenses.generated.json` into a sibling `echophrase-www` checkout when one exists; the hook passes `--skip-www`, because the website lists what the last release ships. If it's a new license not yet in the list, confirm it's permissive/notice-only (never add GPL/AGPL/LGPL) before adding it to `accepted`. New frontend (`bun add`) dependencies are covered automatically by `rollup-license-plugin` in `vite.config.js` - no manual step there either.

### Backend Architecture Principles
- **Traits for swappable systems**: VAD, transcription, GPU providers use trait interfaces
Expand Down
3 changes: 3 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ are in [CLAUDE.md](CLAUDE.md), which is written for human contributors and AI co
```
8. **New dependencies** must be permissively licensed. Rust crates must match the
`accepted` list in `src-tauri/about.toml` (no GPL/AGPL/LGPL).
A commit that changes `Cargo.lock` or `bun.lock` regenerates the third-party notices
through the pre-commit hook (`scripts/ensure-attribution.mjs`), which needs
`cargo-about` at the version pinned in `.github/workflows/ci.yml`.

## Style

Expand Down
113 changes: 113 additions & 0 deletions scripts/ensure-attribution.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
#!/usr/bin/env node

// SPDX-FileCopyrightText: 2025-2026 Imperium42 LLC
//
// SPDX-License-Identifier: MPL-2.0

// Pre-commit guard for the "Attribution is current" CI job. Run from repo root
// (husky does): `bun scripts/ensure-attribution.mjs`.
//
// When the commit stages a file the third-party notices are generated from, this
// regenerates them (scripts/gen-attribution.mjs) and stages the result, so a
// dependency change and its attribution always land in the same commit. Any other
// commit exits immediately.
//
// The job failed on five PRs before this existed, every time because a lockfile
// change was committed without `bun run licenses:generate`.
//
// --force regenerate even when no input is staged
// SKIP_ATTRIBUTION=1 skip (CI will still fail a stale commit)

import { execFileSync } from "node:child_process";
import { readFileSync } from "node:fs";
import { dirname, resolve } from "node:path";
import { fileURLToPath } from "node:url";

const repoRoot = resolve(dirname(fileURLToPath(import.meta.url)), "..");

/** Files whose content decides what gen-attribution.mjs writes. */
const INPUTS = [
"Cargo.lock",
"bun.lock",
"src-tauri/about.toml",
"src-tauri/about.hbs",
"scripts/gen-attribution.mjs",
"vite.config.js", // npm license plugin config and overrides
];

/** The committed generator outputs that CI diffs. */
const OUTPUTS = ["ATTRIBUTION.md", "src-tauri/licenses/THIRD-PARTY-NOTICES.txt"];

function git(args) {
return execFileSync("git", args, { cwd: repoRoot, encoding: "utf8" });
}

function fail(message) {
console.error(`[attribution] ${message}`);
console.error(
"[attribution] To commit anyway, set SKIP_ATTRIBUTION=1 (the CI job will fail until the notices are regenerated).",
);
process.exit(1);
}

/** The cargo-about version CI pins; ci.yml is the single source of truth. */
function pinnedCargoAbout() {
const ci = readFileSync(resolve(repoRoot, ".github/workflows/ci.yml"), "utf8");
const match = ci.match(/tool:\s*cargo-about@(\d+\.\d+\.\d+)/);
if (!match) fail("could not read the pinned cargo-about version from .github/workflows/ci.yml");
return match[1];
}

function installedCargoAbout() {
try {
const out = execFileSync("cargo", ["about", "--version"], { cwd: repoRoot, encoding: "utf8" });
return out.match(/(\d+\.\d+\.\d+)/)?.[1] ?? null;
} catch {
return null;
}
}

function main() {
if (process.env.SKIP_ATTRIBUTION === "1") {
console.log("[attribution] SKIP_ATTRIBUTION=1 - not checking");
return;
}

const staged = git(["diff", "--cached", "--name-only"]).split("\n").filter(Boolean);
const touched = INPUTS.filter((file) => staged.includes(file));
if (touched.length === 0 && !process.argv.includes("--force")) return;

console.log(
`[attribution] ${touched.length ? `${touched.join(", ")} staged` : "--force"} - regenerating third-party notices...`,
);

// A different cargo-about version groups notices differently, so its output
// would fail CI just the same as a stale file.
const pinned = pinnedCargoAbout();
const installed = installedCargoAbout();
if (installed !== pinned) {
fail(
`cargo-about ${pinned} is required (found: ${installed ?? "none"}). ` +
`Install it with: cargo install cargo-about@${pinned} --locked --features cli`,
);
}

try {
execFileSync("bun", ["scripts/gen-attribution.mjs", "--skip-www"], {
cwd: repoRoot,
stdio: "inherit",
});
} catch {
fail("scripts/gen-attribution.mjs failed (see the output above); nothing was staged");
}

const changed = git(["status", "--porcelain", "--", ...OUTPUTS]).trim();
git(["add", "--", ...OUTPUTS]);
console.log(
changed
? "[attribution] notices changed and were added to this commit"
: "[attribution] notices already current",
);
}

main();
11 changes: 8 additions & 3 deletions scripts/gen-attribution.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,11 @@
* - ./ATTRIBUTION.md (repo-root artifact)
*
* Usage:
* node scripts/gen-attribution.mjs [--skip-npm-build]
* node scripts/gen-attribution.mjs [--skip-npm-build] [--skip-www]
* (--skip-npm-build reuses an existing static/oss-licenses.json for fast dev
* iteration; the release path always rebuilds for freshness.)
* iteration; the release path always rebuilds for freshness.
* --skip-www leaves the website checkout alone: the pre-commit hook passes it,
* because the site should list what the last RELEASE ships, not every commit.)
*/

import { execFileSync } from "node:child_process";
Expand All @@ -46,6 +48,7 @@ const noticesTxt = resolve(srcTauri, "licenses/THIRD-PARTY-NOTICES.txt");
const npmManifest = resolve(clientRoot, "static/oss-licenses.json");

const skipNpmBuild = process.argv.includes("--skip-npm-build");
const skipWww = process.argv.includes("--skip-www");

// Copyleft licenses that must never ship. The Rust side is already guarded by
// about.toml's `accepted` allowlist; this is the second gate for npm packages.
Expand Down Expand Up @@ -310,7 +313,9 @@ function main() {
console.log(`[attribution] wrote ${attributionMd}`);
// The website repo is a maintainer-only sibling checkout; public clones
// don't have it, so only ATTRIBUTION.md is required.
if (existsSync(dirname(wwwDataFile))) {
if (skipWww) {
console.log(`[attribution] skipped ${wwwDataFile} (--skip-www)`);
} else if (existsSync(dirname(wwwDataFile))) {
writeFileSync(wwwDataFile, JSON.stringify(out, null, 2) + "\n");
console.log(`[attribution] wrote ${wwwDataFile}`);
} else {
Expand Down
149 changes: 0 additions & 149 deletions static/index.html

This file was deleted.

Loading