Skip to content

Desktop app that records your on-screen work session and uses the GitHub Copilot SDK to reconstruct it as an intent + ordered steps, then builds a reusable Skill or Automation for Microsoft Autopilots like Scout, Microsoft Copilot Cowork, or Copilot Studio.

Add license-compliant distribution pipeline

Giorgio Ughini0ab8e2d2f99e
diff --git a/.github/workflows/non-windows.yml b/.github/workflows/non-windows.yml
index 34ad809..9119457 100644
--- a/.github/workflows/non-windows.yml
+++ b/.github/workflows/non-windows.yml
@@ -2,6 +2,8 @@ name: Non-Windows
on:
push:
+ branches:
+ - master
pull_request:
permissions:
@@ -26,7 +28,40 @@ jobs:
node-version: 24
cache: npm
+ - name: Validate source installer guardrails
+ run: |
+ bash -n install.sh
+ set +e
+ output="$(SKILL_RECORDER_COMMIT=master bash install.sh 2>&1)"
+ status=$?
+ set -e
+ if [ "$status" -eq 0 ]; then
+ echo "install.sh accepted a mutable source reference" >&2
+ exit 1
+ fi
+ printf '%s\n' "$output" | grep -q "full 40-character"
+
+ - name: Test commit-pinned source installation
+ env:
+ SKILL_RECORDER_COMMIT: ${{ github.event.pull_request.head.sha || github.sha }}
+ SKILL_RECORDER_INSTALL_ROOT: ${{ runner.temp }}/skill-recorder-source
+ SKILL_RECORDER_NO_LAUNCH: "1"
+ run: bash install.sh
+
- run: npm ci
+ - run: npm run compliance:licenses
+ - name: Verify platform license coverage
+ run: |
+ node --input-type=module -e "
+ import { existsSync, readFileSync } from 'node:fs';
+ const inventory = JSON.parse(readFileSync('.compliance/LICENSE-INVENTORY.json'));
+ const libvips = inventory.packages.find(({ name }) =>
+ name.startsWith('@img/sharp-libvips-'));
+ if (!libvips || libvips.licenseSource !== 'licenses/LGPL-3.0.txt')
+ throw new Error('Platform Sharp/libvips LGPL coverage is missing');
+ if (!existsSync('.compliance/licenses/LGPL-3.0.txt'))
+ throw new Error('Canonical LGPL-3.0 text is missing');
+ "
- name: Verify optional window provider
run: >-
node --input-type=module -e
diff --git a/.github/workflows/portable.yml b/.github/workflows/portable.yml
index bbb2533..79bf3de 100644
--- a/.github/workflows/portable.yml
+++ b/.github/workflows/portable.yml
@@ -7,7 +7,7 @@ name: Portable builds
# Runs ONLY when started by hand (workflow_dispatch) -- never on push or pull
# request -- so ordinary merges don't spend ~10-15 min packaging. The always-on
# Windows / Non-Windows workflows keep typechecking, testing, and (on Windows)
-# building on every push.
+# packaging on pull requests and master pushes.
#
# Unsigned by design: macOS arm64 carries only the automatic *ad-hoc* signature
# (mac.identity "-" in package.json) so it launches after a one-time Gatekeeper
@@ -40,11 +40,11 @@ jobs:
- os: macos-latest # Apple Silicon (arm64)
name: macOS-arm64
build_script: dist:portable:mac
- artifact_path: dist/*.zip
+ artifact_path: release/*.zip
- os: windows-latest # x64
name: Windows-x64
build_script: dist:portable:win
- artifact_path: dist/*.exe
+ artifact_path: release/*.exe
steps:
- uses: actions/checkout@v4
@@ -69,3 +69,11 @@ jobs:
name: skill-recorder-${{ matrix.name }}
path: ${{ matrix.artifact_path }}
if-no-files-found: error
+
+ - name: Upload compliance companion
+ uses: actions/upload-artifact@v4
+ with:
+ name: skill-recorder-${{ matrix.name }}-compliance
+ path: .compliance/**
+ include-hidden-files: true
+ if-no-files-found: error
diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml
index 76bccba..035c3a1 100644
--- a/.github/workflows/windows.yml
+++ b/.github/workflows/windows.yml
@@ -2,6 +2,8 @@ name: Windows
on:
push:
+ branches:
+ - master
pull_request:
permissions:
@@ -11,7 +13,7 @@ jobs:
native:
name: Windows ${{ matrix.arch }}
runs-on: ${{ matrix.runner }}
- timeout-minutes: 30
+ timeout-minutes: 60
strategy:
fail-fast: false
matrix:
@@ -25,6 +27,50 @@ jobs:
steps:
- uses: actions/checkout@v4
+
+ - name: Validate source installer guardrails
+ shell: pwsh
+ run: |
+ $tokens = $null
+ $parseErrors = $null
+ $path = (Resolve-Path "install.ps1").Path
+ [void][System.Management.Automation.Language.Parser]::ParseFile(
+ $path,
+ [ref]$tokens,
+ [ref]$parseErrors
+ )
+ if ($parseErrors.Count -ne 0) {
+ $parseErrors | ForEach-Object { Write-Error $_.Message }
+ throw "install.ps1 contains PowerShell syntax errors"
+ }
+ $beforeErrorPreference = $ErrorActionPreference
+ $beforeProgressPreference = $ProgressPreference
+ $env:SKILL_RECORDER_COMMIT = "master"
+ try {
+ & .\install.ps1
+ throw "install.ps1 accepted a mutable source reference"
+ } catch {
+ if ($_.Exception.Message -notmatch "full 40-character") {
+ throw
+ }
+ } finally {
+ Remove-Item Env:SKILL_RECORDER_COMMIT -ErrorAction SilentlyContinue
+ }
+ if (
+ $ErrorActionPreference -ne $beforeErrorPreference -or
+ $ProgressPreference -ne $beforeProgressPreference
+ ) {
+ throw "install.ps1 leaked preference changes into the caller"
+ }
+
+ - name: Test commit-pinned source installation
+ shell: pwsh
+ env:
+ SKILL_RECORDER_COMMIT: ${{ github.event.pull_request.head.sha || github.sha }}
+ SKILL_RECORDER_INSTALL_ROOT: ${{ runner.temp }}\skill-recorder-source
+ SKILL_RECORDER_NO_LAUNCH: "1"
+ run: .\install.ps1
+
- uses: actions/setup-node@v4
with:
node-version: 24
@@ -43,10 +89,14 @@ jobs:
throw "ffmpeg-static remains in the lockfile"
}
- - name: Test and build
- run: |
- npm test
- npm run build
+ - name: Generate license inventory
+ run: npm run compliance:licenses
+
+ - name: Run tests
+ run: npm test
+
+ - name: Build
+ run: npm run build
- name: Package native installer
run: npm run ${{ matrix.dist_script }}
diff --git a/.gitignore b/.gitignore
index ce6a580..22c9eed 100644
--- a/.gitignore
+++ b/.gitignore
@@ -2,6 +2,8 @@ node_modules
dist
dist-electron
release
+.compliance
+.compliance-cache
*.log
.DS_Store
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
new file mode 100644
index 0000000..a433da8
--- /dev/null
+++ b/CONTRIBUTING.md
@@ -0,0 +1,7 @@
+# Contributing
+
+By submitting a contribution to this repository, you certify that you have the
+right to provide it and agree that it is licensed under the repository's MIT
+License. Third-party material must retain its original license and attribution;
+do not add copied code, fonts, media, models, or binaries without documenting
+their provenance and redistribution terms.
diff --git a/INSTALL.md b/INSTALL.md
new file mode 100644
index 0000000..d359ce9
--- /dev/null
+++ b/INSTALL.md
@@ -0,0 +1,270 @@
+# Installing Skill Recorder from source
+
+Skill Recorder can run directly from an exact source revision on Windows, macOS,
+or Ubuntu. These methods do not download a prebuilt Skill Recorder application.
+Node.js, Electron, native dependencies, and the GitHub Copilot CLI are obtained
+directly from their publishers and assembled locally.
+
+The generated build is for local execution only. Do not redistribute the build,
+`node_modules`, or downloaded runtimes. Release binaries must use the
+repository's `npm run dist*` commands and include the complete generated
+compliance bundle.
+
+## Commit-pinned one-line installation
+
+Replace `<40-character-release-commit>` with the full 40-character commit SHA
+published for the release.
+
+### Windows 11 x64 or ARM64
+
+```powershell
+$commit="<40-character-release-commit>"; $env:SKILL_RECORDER_COMMIT=$commit; irm "https://raw.githubusercontent.com/adilei/skill-recorder/$commit/install.ps1" | iex
+```
+
+### macOS or Ubuntu
+
+```sh
+commit="<40-character-release-commit>"; curl -fsSL "https://raw.githubusercontent.com/adilei/skill-recorder/$commit/install.sh" | SKILL_RECORDER_COMMIT="$commit" bash
+```
+
+To launch in the background and retain rolling logs on macOS or Ubuntu:
+
+```sh
+commit="<40-character-release-commit>"; curl -fsSL "https://raw.githubusercontent.com/adilei/skill-recorder/$commit/install.sh" | SKILL_RECORDER_COMMIT="$commit" SKILL_RECORDER_DETACHED=1 bash
+```
+
+The commit appears twice deliberately: it pins both the script being executed
+and the source that the script builds. Never replace it with `master`, `main`, a
+branch name, or an unverified tag.
+
+The source installers:
+
+1. Require a full commit SHA and reject mutable references.
+2. Select the native x64 or ARM64 architecture and reject unsupported operating
+ systems. `install.sh` accepts macOS and Ubuntu only.
+3. Download an official portable Node.js 24 runtime from `nodejs.org` and verify
+ its archive against Node.js's `SHASUMS256.txt`. Windows additionally verifies
+ the OpenJS Foundation Authenticode signature.
+4. Download only the exact source commit from GitHub Codeload.
+5. Run `npm ci`, install Electron from its official release endpoint, and confirm
+ Electron's official checksum manifest matches the reviewed compliance policy.
+6. Run `npm run compliance:licenses` and fail if any installed platform package
+ lacks reviewed legal material.
+7. Build locally, retain repository/dependency licenses, and record hashes for
+ the installed Electron and Copilot executables.
+8. Create a Start Menu shortcut on Windows, a launcher on macOS, and a launcher
+ plus desktop entry on Ubuntu.
+
+No administrator access, global Node.js installation, or global Copilot CLI
+installation is required. GitHub Copilot authentication, entitlement, and
+network access are still required.
+
+Piping a downloaded script directly to a shell gives you no opportunity to
+inspect it first and may be disabled by enterprise policy. The inspect-first
+procedures below are preferred.
+
+Source installation is not a security-policy bypass. Gatekeeper, Smart App
+Control, application-control policy, or endpoint protection may still block
+downloaded or locally assembled components.
+
+## Inspect-first installation
+
+Compare the displayed script SHA-256 with the value published in the
+corresponding GitHub Release before executing it.
+
+### Windows
+
+```powershell
+$commit = "<40-character-release-commit>"
+$script = Join-Path $env:TEMP "skill-recorder-install-$commit.ps1"
+Invoke-WebRequest "https://raw.githubusercontent.com/adilei/skill-recorder/$commit/install.ps1" -OutFile $script -UseBasicParsing
+Get-FileHash $script -Algorithm SHA256
+Get-Content $script
+$env:SKILL_RECORDER_COMMIT = $commit
+& $script
+```
+
+### macOS
+
+```sh
+commit="<40-character-release-commit>"
+script="$(mktemp -t skill-recorder-install.XXXXXX)"
+curl -fsSL "https://raw.githubusercontent.com/adilei/skill-recorder/$commit/install.sh" -o "$script"
+shasum -a 256 "$script"
+cat "$script"
+SKILL_RECORDER_COMMIT="$commit" bash "$script"
+rm -f "$script"
+```
+
+### Ubuntu
+
+```sh
+commit="<40-character-release-commit>"
+script="$(mktemp --suffix=.sh)"
+curl -fsSL "https://raw.githubusercontent.com/adilei/skill-recorder/$commit/install.sh" -o "$script"
+sha256sum "$script"
+cat "$script"
+SKILL_RECORDER_COMMIT="$commit" bash "$script"
+rm -f "$script"
+```
+
+## Source-installer options and locations
+
+| Variable | Platforms | Meaning |
+| --- | --- | --- |
+| `SKILL_RECORDER_COMMIT` | all | Required full 40-character source commit |
+| `SKILL_RECORDER_INSTALL_ROOT` | all | Override the per-user source/runtime directory |
+| `SKILL_RECORDER_NO_LAUNCH=1` | all | Install and validate without launching |
+| `SKILL_RECORDER_DETACHED=1` | macOS, Ubuntu | Launch in the background with file logging |
+| `SKILL_RECORDER_LOG_KEEP` | macOS, Ubuntu | Number of detached launch logs to retain; default `5` |
+
+Default installation roots:
+
+- Windows: `%LOCALAPPDATA%\SkillRecorder`
+- macOS: `~/Library/Application Support/SkillRecorder`
+- Ubuntu: `${XDG_DATA_HOME:-~/.local/share}/SkillRecorder`
+
+Every revision is installed under `versions/<commit>`. The current launcher is
+updated only after the selected revision passes dependency, license, integrity,
+and build checks.
+
+## Manual developer setup
+
+Install native Node.js 24 from its official publisher. Download the exact commit
+archive rather than repository history.
+
+### Windows PowerShell
+
+```powershell
+$commit = "<40-character-release-commit>"
+$archive = Join-Path $env:TEMP "skill-recorder-$commit.zip"
+$parent = Join-Path $PWD "skill-recorder-source"
+Invoke-WebRequest "https://codeload.github.com/adilei/skill-recorder/zip/$commit" -OutFile $archive -UseBasicParsing
+Expand-Archive $archive $parent
+Set-Location (Join-Path $parent "skill-recorder-$commit")
+npm ci
+node node_modules\electron\install.js
+npm run compliance:licenses
+npm run build
+npm start
+```
+
+### macOS
+
+```sh
+commit="<40-character-release-commit>"
+archive="skill-recorder-$commit.tar.gz"
+source_dir="skill-recorder-$commit"
+curl -fsSL "https://codeload.github.com/adilei/skill-recorder/tar.gz/$commit" -o "$archive"
+mkdir "$source_dir"
+tar -xzf "$archive" --strip-components=1 -C "$source_dir"
+cd "$source_dir"
+npm ci
+node node_modules/electron/install.js
+npm run compliance:licenses
+npm run build
+npm start
+```
+
+### Ubuntu
+
+Install the basic archive/download tools if the machine does not already have
+them:
+
+```sh
+sudo apt-get update
+sudo apt-get install --yes ca-certificates curl tar
+```
+
+Then use the same pinned source process:
+
+```sh
+commit="<40-character-release-commit>"
+archive="skill-recorder-$commit.tar.gz"
+source_dir="skill-recorder-$commit"
+curl -fsSL "https://codeload.github.com/adilei/skill-recorder/tar.gz/$commit" -o "$archive"
+mkdir "$source_dir"
+tar -xzf "$archive" --strip-components=1 -C "$source_dir"
+cd "$source_dir"
+npm ci
+node node_modules/electron/install.js
+npm run compliance:licenses
+npm run build
+npm start
+```
+
+For hot-reload development, run `npm run dev` after `npm ci` and
+`npm run compliance:licenses`.
+
+The lockfile pins the dependency graph. Use `npm ci`, not `npm install`, and do
+not regenerate the lockfile during installation. Keep the entire checkout,
+`.compliance`, and dependency legal files.
+
+## Licensing boundary
+
+The source channels distribute this repository's MIT-licensed source. The
+user's package manager obtains Electron, Sharp/libvips, ONNX Runtime, the
+unmodified GitHub Copilot CLI, and other dependencies from their publishers.
+The local build is not a redistributable application package.
+
+Each platform's compliance check retains:
+
+- `LICENSE` and `THIRD-PARTY-NOTICES.md`;
+- complete license files installed with npm packages, including the Copilot CLI
+ license;
+- Electron and Chromium runtime notices;
+- canonical GPL, LGPL, and MPL texts under `.compliance/licenses`;
+- platform-specific Sharp/libvips and ONNX Runtime notices under `.compliance`;
+- an inventory with no unresolved dependency-license entries.
+
+Anyone redistributing a generated application must instead use the supported
+`npm run dist*` pipeline. It packages the exact notices, corresponding source,
+patches, hashes, and relinking instructions required by the bundled libraries.
+
+## Updating and uninstalling
+
+To update, rerun the source installer with the new release's full commit SHA.
+Test the new revision before deleting an older revision.
+
+### Windows uninstall
+
+```powershell
+Remove-Item "$([Environment]::GetFolderPath('Programs'))\Skill Recorder (Source).lnk" -Force
+Remove-Item "$env:LOCALAPPDATA\SkillRecorder" -Recurse -Force
+```
+
+### macOS uninstall
+
+```sh
+rm -rf "$HOME/Library/Application Support/SkillRecorder"
+```
+
+### Ubuntu uninstall
+
+```sh
+data_home="${XDG_DATA_HOME:-$HOME/.local/share}"
+rm -f "$data_home/applications/skill-recorder-source.desktop"
+rm -rf "$data_home/SkillRecorder"
+```
+
+These commands leave recorded-session/application data outside the source
+installation root intact.
+
+## Release maintainer checklist
+
+The complete repeatable process is documented in
+[`RELEASING.md`](RELEASING.md).
+
+1. Confirm all contributors and employers have authorized the MIT release.
+2. Build and test the exact release commit on every advertised native platform
+ and architecture.
+3. Confirm Windows, macOS, and Ubuntu CI produce a license inventory with no
+ unresolved entries.
+4. Publish the full commit SHA, never a branch name, in installation commands.
+5. Publish SHA-256 values for that commit's `install.ps1` and `install.sh`.
+6. Protect the release tag from movement or deletion.
+7. Test the one-line and inspect-first source paths on clean machines.
+8. Do not mirror or repackage Node.js, Electron, npm dependencies, or Copilot
+ binaries in the source-install channel.
+9. For any prebuilt release, use `npm run dist*` and publish the complete,
+ version-matched compliance materials.
diff --git a/LICENSE b/LICENSE
index 1f7ddd4..edaa48b 100644
--- a/LICENSE
+++ b/LICENSE
@@ -1,6 +1,6 @@
MIT License
-Copyright (c) 2026 Skill Recorder
+Copyright (c) 2026 Skill Recorder contributors
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
diff --git a/README.md b/README.md
index e5e042c..a45db88 100644
--- a/README.md
+++ b/README.md
@@ -35,40 +35,31 @@ form can teach the agent to submit *all* of them.
## Get started
-The quickest path: one command downloads Skill Recorder, sets it up, builds it, and
-launches it. It's **safe to re-run** — the same command updates your install to the latest
-version and only does work when something actually changed.
+**macOS / Ubuntu**
-**macOS / Linux**
-
-```bash
-curl -fsSL https://raw.githubusercontent.com/adilei/skill-recorder/master/install.sh | bash
-```
-
-To keep it running after you close the terminal (output goes to rolling logs in
-`~/.skill-recorder/logs`), add `SKILL_RECORDER_DETACHED=1` **after the pipe**:
-
-```bash
-curl -fsSL https://raw.githubusercontent.com/adilei/skill-recorder/master/install.sh | SKILL_RECORDER_DETACHED=1 bash
+```sh
+commit="<40-character-release-commit>"; curl -fsSL "https://raw.githubusercontent.com/adilei/skill-recorder/$commit/install.sh" | SKILL_RECORDER_COMMIT="$commit" bash
```
-**Windows** — paste into any terminal (Command Prompt *or* PowerShell)
+The release commit pins both the downloaded script and the source it builds. To keep the
+application running after the terminal closes, add `SKILL_RECORDER_DETACHED=1` after the
+pipe:
-```powershell
-powershell -c "irm https://raw.githubusercontent.com/adilei/skill-recorder/master/install.ps1 | iex"
+```sh
+commit="<40-character-release-commit>"; curl -fsSL "https://raw.githubusercontent.com/adilei/skill-recorder/$commit/install.sh" | SKILL_RECORDER_COMMIT="$commit" SKILL_RECORDER_DETACHED=1 bash
```
-To keep it running after you close the window, set `$env:SKILL_RECORDER_DETACHED=1`
-**inside the quotes**:
+**Windows**
-```powershell
-powershell -c "$env:SKILL_RECORDER_DETACHED=1; irm https://raw.githubusercontent.com/adilei/skill-recorder/master/install.ps1 | iex"
-```
+Use the commit-pinned source installer documented in [`INSTALL.md`](INSTALL.md). The
+published command must identify a full 40-character release commit. It downloads a
+verified portable Node.js 24 runtime, builds that exact source revision locally, preserves
+the required license materials, and creates a Start Menu shortcut without installing Node
+system-wide.
-No prerequisites to chase: if you don't already have **Node.js 22+**, the installer quietly
-downloads a private copy just for Skill Recorder (nothing is installed system-wide, no
-executables are built). You'll want the **GitHub Copilot CLI** signed in for the analysis
-step (see [Requirements](#requirements)). On first launch, macOS asks for **Screen Recording**
+Both paths install dependencies from their publishers and build Skill Recorder locally.
+The platform-specific Copilot CLI is installed with the application dependencies; a global
+CLI installation is not required. On first launch, macOS asks for **Screen Recording**
permission — grant it and you're ready to record.
> ⚠️ **Keep secrets out of your recordings.** Don't record, type, paste, or narrate
@@ -77,23 +68,20 @@ permission — grant it and you're ready to record.
> Details in [What gets captured](#what-gets-captured).
<details>
-<summary>Install options &amp; updating</summary>
+<summary>Source installer options &amp; updating</summary>
Set any of these environment variables when you run the command:
| Variable | Default | What it does |
| --- | --- | --- |
-| `SKILL_RECORDER_HOME` | `~/.skill-recorder` | where the app is installed |
-| `SKILL_RECORDER_REF` | `master` | branch, tag, or commit to install |
-| `SKILL_RECORDER_NO_RUN` | *(unset)* | set up without launching |
-| `SKILL_RECORDER_DETACHED` | *(unset)* | run detached (keeps running after the terminal closes) and write rolling logs to `<home>/logs` |
-| `SKILL_RECORDER_LOG_KEEP` | `5` | how many detached log files to keep |
-| `SKILL_RECORDER_NODE_VERSION` | `latest-v22.x` | Node version to fetch when none is installed |
-| `SKILL_RECORDER_NODE_MIRROR` | `https://nodejs.org/dist` | mirror for the Node download |
-
-Re-run the one-liner any time to update and relaunch. To relaunch without re-downloading,
-run `npm start` from the install directory. The installer uses `git` when available and
-falls back to a source tarball/zip download otherwise.
+| `SKILL_RECORDER_COMMIT` | *(required)* | exact 40-character source commit |
+| `SKILL_RECORDER_INSTALL_ROOT` | per-user platform path | source and portable runtime location |
+| `SKILL_RECORDER_NO_LAUNCH` | *(unset)* | set to `1` to install without launching |
+| `SKILL_RECORDER_DETACHED` | *(unset)* | macOS/Ubuntu background launch with rolling logs |
+| `SKILL_RECORDER_LOG_KEEP` | `5` | macOS/Ubuntu detached log retention |
+
+Re-run the platform command with a new release commit to update. Inspect-first,
+platform-specific relaunch, and uninstall instructions are in [`INSTALL.md`](INSTALL.md).
</details>
---
@@ -104,10 +92,10 @@ falls back to a source tarball/zip download otherwise.
- **macOS** (primary target). Windows 11 x64 and ARM64 are also supported — see
[`WINDOWS-VALIDATION.md`](WINDOWS-VALIDATION.md).
-- **Node.js 22+** — the one-liner auto-downloads a private copy if you don't already have
- it, so you only need to install this yourself if you skip the installer.
-- **GitHub Copilot CLI**, installed and signed in, with `copilot` on your `PATH`. It
- powers the analysis and the skill/automation builders.
+- **Node.js 24** for manual source development. Installers provide a private runtime when
+ needed.
+- A GitHub account with **Copilot access** and authentication. Dependency installation
+ includes the platform-specific Copilot CLI used by the SDK.
- No system media tools required — Chromium handles screen snapshots and narration audio
decoding. A system `ffmpeg` is only used to open recordings made by an older Skill
Recorder version that has no snapshot manifest.
@@ -147,12 +135,18 @@ The in-app "Records your screen and activity" panel spells out exactly what's co
model and uses the same `small` architecture, so runtime memory and transcription speed
are expected to remain effectively unchanged.
-## Run from source (development)
+## Install or develop from source
+
+See [`INSTALL.md`](INSTALL.md) for the commit-pinned Windows source installer,
+the inspect-first alternative, manual developer setup, updates, uninstallation,
+and the licensing boundary between local source builds and redistributable
+packages.
-Prefer to hack on the code instead of using the installer? Clone the repo and:
+For development after checking out an exact revision:
```bash
-npm install
+npm ci
+npm run compliance:licenses
npm run dev
```
@@ -166,12 +160,25 @@ Other useful scripts:
```bash
npm run typecheck # tsc --noEmit
npm run build # typecheck + production build (dist/ + dist-electron/)
-npm run dist # build a non-Windows distributable via electron-builder
+npm run dist # build a compliant non-Windows distributable in release/
npm run dist:win:x64 # requires native Windows x64
npm run dist:win:arm64 # requires native Windows ARM64
+npm run dist:portable:mac # compliant unsigned macOS ZIP
+npm run dist:portable:win # compliant unsigned Windows x64 portable executable
+npm run compliance:licenses # validate the installed dependency license inventory
npm start # run the last build with `electron .`
```
+Distributable builds download the exact corresponding-source archives and
+license materials required by bundled native libraries. They are packaged
+outside the ASAR under `resources/compliance/`; a release fails if any required
+notice, source archive, or relinking instruction is missing or differs from its
+reviewed SHA-256. Locally generated source builds must not be redistributed.
+
+Maintainers must follow [`RELEASING.md`](RELEASING.md) when changing versions,
+dependencies, assets, release notes, tags, source installers, or binary
+downloads.
+
## Evals
The variable part of the system — the Copilot **describer** and **builders** — has a
diff --git a/RELEASING.md b/RELEASING.md
new file mode 100644
index 0000000..807fed8
--- /dev/null
+++ b/RELEASING.md
@@ -0,0 +1,216 @@
+# Releasing Skill Recorder
+
+Skill Recorder uses semantic versions and two distinct release channels:
+
+1. **Source-only releases** are the default. GitHub publishes the tagged
+ repository source, and users build an exact commit locally with the
+ commit-pinned installers.
+2. **Binary releases** are optional. They must be built with the repository's
+ `npm run dist*` commands and accompanied by the complete, version-matched
+ compliance bundle.
+
+Never attach `dist/`, `dist-electron/`, `node_modules/`, or an application
+assembled by `install.ps1` or `install.sh` to a release.
+
+## 1. Prepare a release pull request
+
+Start from the latest `master` and choose the next semantic version:
+
+- patch (`0.1.1`) for compatible fixes;
+- minor (`0.2.0`) for compatible functionality;
+- major (`1.0.0`) for incompatible behavior after the project reaches 1.0.
+
+Update both `package.json` and `package-lock.json` without creating a tag:
+
+```sh
+npm version 0.2.0 --no-git-tag-version
+```
+
+Replace `0.2.0` with the chosen version. Summarize user-visible changes in the
+pull request. If dependencies or bundled assets changed, perform the review
+below before updating any compliance policy hash.
+
+### Dependency and asset review
+
+Run:
+
+```sh
+npm ci
+npm run compliance:licenses
+```
+
+Inspect:
+
+- `.compliance/LICENSE-INVENTORY.json`;
+- `.compliance/THIRD-PARTY-LICENSES.txt`;
+- `THIRD-PARTY-NOTICES.md`;
+- changes to `package-lock.json`;
+- every new or changed image, font, model, native library, executable, and
+ copied source file.
+
+The compliance scripts intentionally reject unreviewed component versions and
+materials. Do not fix such a failure by blindly replacing a version or hash.
+Review the new license, notices, redistribution terms, corresponding-source
+requirements, and upstream provenance first.
+
+| Change | Required review |
+| --- | --- |
+| GitHub Copilot SDK or CLI | Re-read that exact version's terms and notices; confirm unmodified bundling remains permitted; update the reviewed policy version. |
+| Electron or Chromium | Review the Electron archive and checksums, Chromium notices, FFmpeg revision/source/patches, and every supported platform hash. |
+| Sharp or sharp-libvips | Review package licenses, native dependency versions, build repositories, patches, source archives, and relinking instructions. |
+| ONNX Runtime | Review the exact release/development revision, license, notices, native packages, and source reference. |
+| New native or copyleft component | Add exact notices, canonical license text, complete corresponding source, build scripts/patches, and relinking instructions where required. |
+| Font, image, model, recording, or other asset | Record its provenance and written redistribution authorization; do not assume application code licenses cover assets. |
+
+If a new obligation cannot be met, do not merge or release the dependency.
+
+## 2. Validate the release candidate
+
+Run the existing checks:
+
+```sh
+npm test
+npm run build
+npm run typecheck:evals
+npm run compliance:licenses
+```
+
+For a binary candidate, also generate the full bundle:
+
+```sh
+npm run compliance:prepare
+```
+
+The pull request must pass:
+
+- Windows x64 and ARM64 license, test, build, package, and architecture checks;
+- macOS and Ubuntu license, test, and build checks;
+- commit-pinned source-installer checks on Windows, macOS, and Ubuntu.
+
+Resolve every compliance failure. Never disable or bypass a compliance check to
+publish a release.
+
+## 3. Merge and freeze the release commit
+
+Merge the release pull request into `master`, then wait for the workflows on
+the resulting `master` commit to pass. Record the exact commit:
+
+```sh
+git fetch origin master
+release_commit="$(git rev-parse origin/master)"
+printf '%s\n' "$release_commit"
+```
+
+The release tag and every installation command must identify this commit. Do
+not use a branch name or a mutable tag in an installer command.
+
+Create an annotated tag only after the commit passes:
+
+```sh
+version="v0.2.0"
+git tag -a "$version" "$release_commit" -m "Skill Recorder $version"
+git push origin "$version"
+```
+
+Do not move or reuse a published tag. Protect release tags in repository
+settings. If a release is defective, publish a new patch version.
+
+## 4. Calculate installer-script hashes
+
+Calculate hashes from the exact release commit's Git blobs, not working-tree
+files. This avoids stale checkouts and local line-ending conversion. Replace
+the final argument with the full 40-character release commit SHA. The command
+works in PowerShell, macOS, and Ubuntu:
+
+```sh
+node -e 'const {execFileSync}=require("node:child_process");const {createHash}=require("node:crypto");const commit=process.argv[1];if(!/^[0-9a-f]{40}$/i.test(commit))throw new Error("full release commit SHA required");for(const file of ["install.ps1","install.sh"]){const data=execFileSync("git",["cat-file","blob",commit+":"+file]);console.log(createHash("sha256").update(data).digest("hex")+" "+file)}' FULL_40_CHARACTER_RELEASE_COMMIT_SHA
+```
+
+Publish both hashes in the GitHub Release notes. A user following the
+inspect-first instructions in `INSTALL.md` must be able to compare the
+downloaded script with these values.
+
+## 5. Publish the source-only GitHub Release
+
+Source-only is the recommended release format. Do not attach installers or
+portable binaries. GitHub's automatically generated archives contain the
+tagged repository source but not `node_modules` or downloaded runtimes.
+
+Release notes must include:
+
+- version and full release commit SHA;
+- SHA-256 values for `install.ps1` and `install.sh`;
+- user-visible changes;
+- the commit-pinned Windows and macOS/Ubuntu commands from `INSTALL.md`;
+- a clear statement that the release is source-only;
+- important upgrade, security, or compatibility notes.
+
+After preparing a notes file:
+
+```sh
+gh release create "v0.2.0" \
+ --verify-tag \
+ --title "Skill Recorder v0.2.0" \
+ --notes-file release-notes.txt
+```
+
+Do not commit the temporary release-notes file.
+
+## 6. Optional binary release
+
+Binary publication is a separate decision. Build each artifact on its native
+operating system and architecture:
+
+```sh
+npm ci
+npm run dist
+npm run dist:win:x64
+npm run dist:win:arm64
+npm run dist:portable:mac
+npm run dist:portable:win
+```
+
+Run only the command applicable to that native machine. Outputs are written to
+`release/`. The build must complete the `afterPack` compliance gate.
+
+Before attaching a binary:
+
+1. Confirm it was built from the tagged commit with an unchanged lockfile.
+2. Verify its operating-system and CPU architecture.
+3. Confirm `resources/compliance/` contains exact notices, legal texts,
+ corresponding source, patches, hashes, and relinking instructions.
+4. Archive the generated `.compliance` directory as a separate companion asset.
+5. Attach the binary and its matching compliance archive to the same release.
+6. Publish SHA-256 values for every attached asset.
+7. Preserve the compliance archive for as long as the binary remains available.
+8. Disclose whether the binary is unsigned, ad-hoc signed, or Authenticode /
+ Developer ID signed.
+
+The manual **Portable builds** workflow produces unsigned preview artifacts and
+matching compliance artifacts. Download and verify them before deciding to
+publish them. An Actions artifact is not itself a GitHub Release.
+
+## 7. Post-release verification
+
+On clean supported machines:
+
+1. Download each installer script by the full release commit SHA.
+2. Compare its SHA-256 with the release notes.
+3. Run with `SKILL_RECORDER_NO_LAUNCH=1`.
+4. Confirm dependency installation and the platform license inventory succeed.
+5. Launch Skill Recorder and exercise recording, analysis, and skill creation.
+6. Confirm update and uninstall instructions in `INSTALL.md`.
+
+Check that the GitHub Release tag still resolves to the recorded commit and
+that all source archives, hashes, notes, and optional compliance assets remain
+available.
+
+## 8. Correcting a published release
+
+Never silently replace an asset or move a release tag.
+
+- For incorrect notes, edit the notes and document the correction.
+- For a defective script, dependency, compliance bundle, or binary, mark the
+ affected release as unsuitable and publish a new patch release.
+- If an asset creates a legal or security risk, remove the affected binary,
+ retain an audit record, and publish corrected materials under a new version.
diff --git a/THIRD-PARTY-NOTICES.md b/THIRD-PARTY-NOTICES.md
index fb1c7f1..d9262b5 100644
--- a/THIRD-PARTY-NOTICES.md
+++ b/THIRD-PARTY-NOTICES.md
@@ -3,13 +3,17 @@
Skill Recorder is licensed under the MIT License (see [`LICENSE`](./LICENSE)).
Packaged/distributed builds include third-party components that are covered by
-their own license terms. This file summarizes the notable ones. The complete
-license notices retained by Electron are distributed as `LICENSE.electron.txt`
-and `LICENSES.chromium.html`; package metadata and the source links below cover
-the other native runtime components.
+their own license terms. This file summarizes the notable ones. Every supported
+release command generates a complete, platform-specific compliance bundle under
+`resources/compliance/` containing full package license texts, native notices,
+copyleft license texts, corresponding source, and relinking instructions.
+Electron's exact notices are retained under `resources/compliance/electron/`;
+platforms that preserve Electron's root notice files carry those copies too.
The dependency tree is otherwise permissive (MIT, ISC, Apache-2.0, BSD,
BlueOak-1.0.0) and compatible with distributing this application under MIT.
+Those components remain under their own terms; the generated
+`THIRD-PARTY-LICENSES.txt` preserves their license and attribution text.
## Optional downloaded model
@@ -51,6 +55,8 @@ BlueOak-1.0.0) and compatible with distributing this application under MIT.
[`150.0.7871.114`](https://chromium.googlesource.com/chromium/src/+/150.0.7871.114),
and Chromium FFmpeg revision
[`ad41607c61898cf7150e0fb20fe4bbabd44922a3`](https://chromium.googlesource.com/chromium/third_party/ffmpeg/+/ad41607c61898cf7150e0fb20fe4bbabd44922a3).
+ The Electron source archive and its applied FFmpeg patch queue accompany each
+ release.
- Chromium records the WebM media, captures screen snapshots, and decodes
narration audio. Skill Recorder does **not** distribute `ffmpeg-static` or a
standalone FFmpeg executable.
@@ -69,14 +75,29 @@ BlueOak-1.0.0) and compatible with distributing this application under MIT.
and libvips
[`v8.17.3`](https://github.com/libvips/libvips/tree/v8.17.3). The unpacked
native module remains replaceable in the packaged application.
+- The native payload also contains libraries under MPL-2.0, MIT, BSD, ISC,
+ fontconfig, FreeType, libpng, libtiff, zlib, and related permissive terms.
+ The exact upstream table is distributed as
+ `resources/compliance/NATIVE-THIRD-PARTY-NOTICES.md`.
-### LGPL release materials
+### ONNX Runtime
-Before publishing an installer, its release must provide archives of the exact
-source revisions above, the applicable LGPL text, and any build/object material needed
-to relink modified LGPL components. These materials must be available beside
-the installer, or through a written offer valid for at least three years; do
-not rely only on third-party hosting remaining available.
+`onnxruntime-node`, `onnxruntime-web`, and `onnxruntime-common` are MIT. Their npm
+packages omit standalone license and third-party-notice files, so exact notices
+from each pinned source revision are included under
+`resources/compliance/onnxruntime/`.
+
+### Copyleft release materials
+
+Redistributable builds include the complete GPL-3.0, LGPL-2.1, LGPL-3.0, and
+MPL-2.0 texts. They also include source archives for Electron's FFmpeg revision,
+Sharp, libvips, every library embedded in the Sharp native payload, the
+applicable packaging repositories, and all externally applied build patches.
+`SOURCE-MANIFEST.json` records the origin, version, SHA-256, and purpose of every
+file. Every remote payload is checked against a reviewed SHA-256 before use;
+the FFmpeg archive is deterministically generated from its pinned Git commit.
+`RELINKING.md` identifies platform-specific unpacked shared-library locations
+and explains how to rebuild and replace them.
### Other native modules
- `get-windows` — MIT
@@ -86,12 +107,19 @@ not rely only on third-party hosting remaining available.
## Apache-2.0 components
Some dependencies (e.g. `sharp`) are Apache-2.0, which requires retaining their
-copyright, license, and any `NOTICE` file contents. These are preserved under
-`node_modules`.
+copyright, license, and any `NOTICE` file contents. The release process collects
+these from the exact installed dependency tree into
+`resources/compliance/THIRD-PARTY-LICENSES.txt` and fails if any package lacks
+reviewed license material.
## Generating a complete license manifest
-For a full, per-package license listing at release time:
+To validate installed package notices without downloading corresponding source:
```sh
-npx license-checker-rseidelsohn --production --files THIRD-PARTY-LICENSES
+npm run compliance:licenses
```
+
+All `npm run dist*` commands run the full `npm run compliance:prepare` process
+automatically. Electron Builder's `afterPack` hook refuses to create an
+installer if the bundle is incomplete or if a build output directory was
+recursively packaged.
diff --git a/install.ps1 b/install.ps1
index d1db88c..d6ef90f 100644
--- a/install.ps1
+++ b/install.ps1
@@ -1,241 +1,562 @@
+# SPDX-License-Identifier: MIT
+# Copyright (c) 2026 Skill Recorder contributors
+
<#
- Skill Recorder — download & run (Windows).
-
- Fetches Skill Recorder from source into a local directory, installs its
- dependencies, builds it, and launches it. A lightweight alternative to
- packaged installers (no .exe / .msi): it just runs the app from source.
-
- The script is idempotent — re-running it fast-forwards to the latest code and
- skips any step (dependency install, build) whose inputs haven't changed, so
- the same one-liner both installs and updates the app.
-
- Usage (one line, from any Windows terminal — cmd.exe or PowerShell):
- powershell -c "irm https://raw.githubusercontent.com/adilei/skill-recorder/master/install.ps1 | iex"
-
- Node.js is downloaded automatically when it's missing: an official,
- checksum-verified Node binary (win-x64 or win-arm64) is placed under the
- install directory and used just for this app — nothing is installed
- system-wide and no executables are built.
-
- Environment overrides:
- SKILL_RECORDER_HOME install directory (default: %USERPROFILE%\.skill-recorder)
- SKILL_RECORDER_REPO owner/repo (default: adilei/skill-recorder)
- SKILL_RECORDER_REF branch / tag / commit (default: master)
- SKILL_RECORDER_NO_RUN set to install & build only, without launching
- SKILL_RECORDER_DETACHED set to run the app detached (survives the window
- closing) and write rolling logs to <home>\logs
- SKILL_RECORDER_LOG_KEEP how many detached log files to keep (default: 5)
- SKILL_RECORDER_NODE_VERSION Node to fetch when missing (default: latest-v22.x)
- SKILL_RECORDER_NODE_MIRROR Node dist mirror (default: https://nodejs.org/dist)
+.SYNOPSIS
+Builds and installs Skill Recorder from an exact source commit.
+
+.DESCRIPTION
+This script does not download a prebuilt Skill Recorder application. It obtains
+an official portable Node.js 24 runtime, downloads the exact requested source
+commit from GitHub, installs lockfile-pinned dependencies from their publishers,
+validates license materials, builds locally, and creates a Start Menu shortcut.
#>
-$ErrorActionPreference = 'Stop'
-# Invoke-WebRequest is ~10x slower with the progress bar on Windows PowerShell 5.1.
-$ProgressPreference = 'SilentlyContinue'
+& {
+Set-StrictMode -Version Latest
+$ErrorActionPreference = "Stop"
+$ProgressPreference = "SilentlyContinue"
+$Commit = $env:SKILL_RECORDER_COMMIT
+$InstallRoot = $env:SKILL_RECORDER_INSTALL_ROOT
+$skipLaunch = $env:SKILL_RECORDER_NO_LAUNCH -eq "1"
+
+function Write-Step {
+ param([Parameter(Mandatory)][string]$Message)
+ Write-Host "[Skill Recorder] $Message"
+}
-$Repo = if ($env:SKILL_RECORDER_REPO) { $env:SKILL_RECORDER_REPO } else { 'adilei/skill-recorder' }
-$Ref = if ($env:SKILL_RECORDER_REF) { $env:SKILL_RECORDER_REF } else { 'master' }
-$InstallDir = if ($env:SKILL_RECORDER_HOME) { $env:SKILL_RECORDER_HOME } else { Join-Path $env:USERPROFILE '.skill-recorder' }
-$NodeMinMajor = 22
+function Invoke-Download {
+ param(
+ [Parameter(Mandatory)][string]$Uri,
+ [Parameter(Mandatory)][string]$Destination
+ )
-function Info($m) { Write-Host "==> $m" -ForegroundColor Cyan }
-function Have($c) { [bool](Get-Command $c -ErrorAction SilentlyContinue) }
+ $parsedUri = [Uri]$Uri
+ if ($parsedUri.Scheme -ne "https") {
+ throw "Refusing non-HTTPS download: $Uri"
+ }
-# Detect the Copilot CLI the same way the app's doctor does (it runs `where
-# copilot`). Get-Command alone misses an extensionless `copilot` launcher or a
-# Windows App Execution Alias that `where.exe` — and therefore the app — finds.
-function Test-CopilotAvailable {
- # 1. Bundled in node_modules (what the Electron app actually uses)
- $arch = if ([System.Runtime.InteropServices.RuntimeInformation]::OSArchitecture -eq 'Arm64') { 'arm64' } else { 'x64' }
- $bundled = Join-Path $InstallDir "node_modules\@github\copilot-win32-$arch\copilot.exe"
- if (Test-Path -LiteralPath $bundled) { return $true }
- # 2. GitHub Copilot desktop app
- $ghcpApp = Join-Path $env:LOCALAPPDATA 'Programs\GitHub Copilot\github.exe'
- if (Test-Path -LiteralPath $ghcpApp) { return $true }
- # 3. copilot on PATH (Get-Command or where.exe)
- if (Have 'copilot') { return $true }
- try { $null = & where.exe copilot 2>$null; return ($LASTEXITCODE -eq 0) } catch { return $false }
-}
+ $parameters = @{
+ Uri = $Uri
+ OutFile = $Destination
+ Headers = @{ "User-Agent" = "Skill-Recorder-Source-Installer" }
+ }
+ if ($PSVersionTable.PSVersion.Major -lt 6) {
+ $parameters.UseBasicParsing = $true
+ }
-# Abort if the most recent native command reported a non-zero exit code
-# (PowerShell does not treat native exit codes as terminating errors on its own).
-function Assert-Ok($what) {
- if ($LASTEXITCODE -ne 0) { throw "$what failed (exit $LASTEXITCODE)" }
+ $previousSecurityProtocol = [Net.ServicePointManager]::SecurityProtocol
+ try {
+ [Net.ServicePointManager]::SecurityProtocol =
+ $previousSecurityProtocol -bor [Net.SecurityProtocolType]::Tls12
+ Invoke-WebRequest @parameters
+ } finally {
+ [Net.ServicePointManager]::SecurityProtocol = $previousSecurityProtocol
+ }
+ if (-not (Test-Path -LiteralPath $Destination -PathType Leaf)) {
+ throw "Download did not create $Destination"
+ }
+ if ((Get-Item -LiteralPath $Destination).Length -eq 0) {
+ throw "Downloaded file is empty: $Uri"
+ }
}
-function FileSha($path) {
- if (Test-Path -LiteralPath $path) { (Get-FileHash -LiteralPath $path -Algorithm SHA256).Hash } else { '' }
-}
+function Assert-ZipArchive {
+ param([Parameter(Mandatory)][string]$Path)
-# True when a Node new enough to build & run the app is already on PATH.
-function Test-NodeAvailable {
- if (-not (Have 'node')) { return $false }
- try {
- # Parse "node -v" (e.g. v22.23.1); avoid passing a JS expression, because
- # Windows strips the embedded quotes from 'node -p "...".split()' arguments.
- $v = & node -v 2>$null
- if ($v -match '^v?(\d+)\.') { return ([int]$Matches[1] -ge $NodeMinMajor) }
- return $false
- } catch { return $false }
-}
-
-# Ensure a usable Node/npm is on PATH: prefer the system one, otherwise download
-# an official Node binary into "$InstallDir\.node" (once) and prepend it to PATH.
-function Initialize-NodeRuntime {
- if (Test-NodeAvailable) { Info "Using existing Node $(& node -v)."; return }
-
- $nodeDir = Join-Path $InstallDir '.node'
- if (Test-Path -LiteralPath (Join-Path $nodeDir 'node.exe')) {
- $env:Path = "$nodeDir;$env:Path"
- if (Test-NodeAvailable) { Info "Using bundled Node $(& node -v) (in $nodeDir)."; return }
- }
-
- # OSArchitecture reports the true OS arch even from an x64 process emulated on
- # ARM64, so ARM64 devices get the native win-arm64 build.
- $osArch = [System.Runtime.InteropServices.RuntimeInformation]::OSArchitecture.ToString()
- $arch = switch ($osArch) {
- 'X64' { 'x64' }
- 'Arm64' { 'arm64' }
- default { throw "Can't auto-download Node for Windows $osArch; install Node $NodeMinMajor+ manually." }
- }
-
- $channel = if ($env:SKILL_RECORDER_NODE_VERSION) { $env:SKILL_RECORDER_NODE_VERSION } else { "latest-v$NodeMinMajor.x" }
- if ($channel -notlike 'latest-*' -and $channel -notlike 'v*') { $channel = "v$channel" }
- $mirror = if ($env:SKILL_RECORDER_NODE_MIRROR) { $env:SKILL_RECORDER_NODE_MIRROR } else { 'https://nodejs.org/dist' }
- $base = "$mirror/$channel"
-
- Info "Node $NodeMinMajor+ not found — downloading a private copy for Skill Recorder…"
- $sums = (Invoke-WebRequest -UseBasicParsing -Uri "$base/SHASUMS256.txt").Content
- $line = ($sums -split "`n") | Where-Object { $_ -match "node-.*-win-$arch\.zip$" } | Select-Object -First 1
- if (-not $line) { throw "No Node win-$arch build found at $base." }
- $fields = ($line.Trim() -split '\s+')
- $want = $fields[0].ToLower(); $file = $fields[1]
-
- $tmp = Join-Path $env:TEMP ("sr-node-" + [guid]::NewGuid().ToString())
- New-Item -ItemType Directory -Force -Path $tmp | Out-Null
+ $stream = [IO.File]::OpenRead($Path)
try {
- $zip = Join-Path $tmp $file
- Info " downloading $file"
- Invoke-WebRequest -UseBasicParsing -Uri "$base/$file" -OutFile $zip
- $got = (Get-FileHash -LiteralPath $zip -Algorithm SHA256).Hash.ToLower()
- if ($got -ne $want) { throw "Checksum mismatch for $file (expected $want, got $got)." }
- Info " checksum verified"
-
- if (Test-Path -LiteralPath $nodeDir) { Remove-Item -Recurse -Force -LiteralPath $nodeDir }
- Expand-Archive -LiteralPath $zip -DestinationPath $tmp -Force
- $inner = Get-ChildItem -Directory -LiteralPath $tmp | Where-Object { $_.Name -like 'node-*' } | Select-Object -First 1
- Move-Item -LiteralPath $inner.FullName -Destination $nodeDir
+ $header = New-Object byte[] 4
+ if ($stream.Read($header, 0, $header.Length) -ne $header.Length) {
+ throw "Archive is too short: $Path"
+ }
+ if (
+ $header[0] -ne 0x50 -or
+ $header[1] -ne 0x4b -or
+ $header[2] -ne 0x03 -or
+ $header[3] -ne 0x04
+ ) {
+ throw "Downloaded file is not a ZIP archive: $Path"
+ }
} finally {
- Remove-Item -Recurse -Force -ErrorAction SilentlyContinue -LiteralPath $tmp
+ $stream.Dispose()
}
+}
+
+function Assert-TrustedSignature {
+ param(
+ [Parameter(Mandatory)][string]$Path,
+ [Parameter(Mandatory)][string]$PublisherPattern,
+ [Parameter(Mandatory)][string]$PublisherName
+ )
- $env:Path = "$nodeDir;$env:Path"
- if (-not (Test-NodeAvailable)) { throw "Downloaded Node is still unusable — please report this." }
- Info "Installed Node $(& node -v) into $nodeDir"
+ if (-not (Test-Path -LiteralPath $Path -PathType Leaf)) {
+ throw "Required executable is missing: $Path"
+ }
+
+ $signature = Get-AuthenticodeSignature -FilePath $Path
+ if ([string]$signature.Status -ne "Valid" -or $null -eq $signature.SignerCertificate) {
+ throw "$PublisherName signature is not valid for $Path (status: $($signature.Status))."
+ }
+ if ($signature.SignerCertificate.Subject -notmatch $PublisherPattern) {
+ throw "Unexpected signer for ${Path}: $($signature.SignerCertificate.Subject)"
+ }
}
-# --- prerequisites ---------------------------------------------------------
+function Assert-RequiredPaths {
+ param(
+ [Parameter(Mandatory)][string]$Root,
+ [Parameter(Mandatory)][string[]]$RelativePaths
+ )
+
+ foreach ($relativePath in $RelativePaths) {
+ $candidate = Join-Path $Root $relativePath
+ if (-not (Test-Path -LiteralPath $candidate)) {
+ throw "Required installation material is missing: $relativePath"
+ }
+ }
+}
+
+function Invoke-CheckedCommand {
+ param(
+ [Parameter(Mandatory)][string]$FilePath,
+ [Parameter(Mandatory)][string[]]$Arguments,
+ [Parameter(Mandatory)][string]$Description
+ )
-# --- fetch source ----------------------------------------------------------
-$versionToken = ''
-if (Have 'git') {
- if (-not (Test-Path -LiteralPath (Join-Path $InstallDir '.git'))) {
- if (Test-Path -LiteralPath $InstallDir) { Remove-Item -Recurse -Force -LiteralPath $InstallDir }
- New-Item -ItemType Directory -Force -Path $InstallDir | Out-Null
- & git -C $InstallDir init -q; Assert-Ok 'git init'
- & git -C $InstallDir remote add origin "https://github.com/$Repo.git"; Assert-Ok 'git remote add'
- } else {
- & git -C $InstallDir remote set-url origin "https://github.com/$Repo.git"; Assert-Ok 'git remote set-url'
+ & $FilePath @Arguments
+ if ($LASTEXITCODE -ne 0) {
+ throw "$Description failed with exit code $LASTEXITCODE."
}
- Info "Fetching $Repo ($Ref) into $InstallDir"
- & git -C $InstallDir fetch --depth 1 origin $Ref; Assert-Ok 'git fetch'
- & git -C $InstallDir reset --hard FETCH_HEAD; Assert-Ok 'git reset'
- $versionToken = (& git -C $InstallDir rev-parse HEAD).Trim(); Assert-Ok 'git rev-parse'
-} else {
- Write-Warning "'git' not found — downloading a source zip instead."
- New-Item -ItemType Directory -Force -Path $InstallDir | Out-Null
- $zip = Join-Path $env:TEMP ("skill-recorder-" + [guid]::NewGuid().ToString() + ".zip")
- $tmp = Join-Path $env:TEMP ("skill-recorder-" + [guid]::NewGuid().ToString())
- try {
- Info "Downloading $Repo ($Ref) into $InstallDir"
- Invoke-WebRequest -UseBasicParsing -Uri "https://codeload.github.com/$Repo/zip/$Ref" -OutFile $zip
- Expand-Archive -LiteralPath $zip -DestinationPath $tmp -Force
- $inner = Get-ChildItem -Directory -LiteralPath $tmp | Select-Object -First 1
- # Copy the source over the install dir; node_modules and dist/ are local-only
- # (not in the zip) and are excluded so they survive re-runs.
- robocopy $inner.FullName $InstallDir /E /XD node_modules dist dist-electron /NFL /NDL /NJH /NJS /NP | Out-Null
- if ($LASTEXITCODE -ge 8) { throw "robocopy failed (exit $LASTEXITCODE)" }
- $versionToken = (Get-FileHash -LiteralPath $zip -Algorithm SHA256).Hash
- } finally {
- Remove-Item -Recurse -Force -ErrorAction SilentlyContinue -LiteralPath $zip, $tmp
+}
+
+function Get-WindowsArchitecture {
+ $architecture = [Runtime.InteropServices.RuntimeInformation]::OSArchitecture.ToString().ToLowerInvariant()
+ if ($architecture -notin @("x64", "arm64")) {
+ throw "Skill Recorder supports Windows x64 and ARM64, not $architecture."
+ }
+ return $architecture
+}
+
+function Get-ElectronExecutable {
+ param([Parameter(Mandatory)][string]$SourceDirectory)
+
+ Assert-RequiredPaths -Root $SourceDirectory -RelativePaths @(
+ "node_modules\electron\package.json",
+ "node_modules\electron\checksums.json",
+ "node_modules\electron\dist\electron.exe",
+ "node_modules\electron\dist\version",
+ "node_modules\electron\dist\LICENSE",
+ "node_modules\electron\dist\LICENSES.chromium.html"
+ )
+
+ $package = Get-Content `
+ -LiteralPath (Join-Path $SourceDirectory "node_modules\electron\package.json") `
+ -Raw | ConvertFrom-Json
+ $distVersion = (
+ Get-Content -LiteralPath (Join-Path $SourceDirectory "node_modules\electron\dist\version") -Raw
+ ).Trim().TrimStart("v")
+ if ([string]$package.version -ne $distVersion) {
+ throw "Electron runtime version mismatch. Expected $($package.version), got $distVersion."
}
+
+ return Join-Path $SourceDirectory "node_modules\electron\dist\electron.exe"
}
-Set-Location -LiteralPath $InstallDir
+function Assert-ReviewedElectronDistribution {
+ param(
+ [Parameter(Mandatory)][string]$SourceDirectory,
+ [Parameter(Mandatory)][string]$Architecture
+ )
+
+ Assert-RequiredPaths -Root $SourceDirectory -RelativePaths @(
+ "node_modules\electron\package.json",
+ "node_modules\electron\checksums.json",
+ "third_party\compliance-policy.json"
+ )
+
+ $electronPackage = Get-Content `
+ -LiteralPath (Join-Path $SourceDirectory "node_modules\electron\package.json") `
+ -Raw | ConvertFrom-Json
+ $electronChecksums = Get-Content `
+ -LiteralPath (Join-Path $SourceDirectory "node_modules\electron\checksums.json") `
+ -Raw | ConvertFrom-Json
+ $policy = Get-Content `
+ -LiteralPath (Join-Path $SourceDirectory "third_party\compliance-policy.json") `
+ -Raw | ConvertFrom-Json
+
+ if ([string]$electronPackage.version -ne [string]$policy.electron.version) {
+ throw "Installed Electron version has not been reviewed by the compliance policy."
+ }
-# --- ensure a Node.js runtime (download one if the system has none) --------
-Initialize-NodeRuntime
+ $archiveName = "electron-v$($electronPackage.version)-win32-$Architecture.zip"
+ $manifestProperty = $electronChecksums.PSObject.Properties[$archiveName]
+ if ($null -eq $manifestProperty) {
+ throw "Electron's checksum manifest does not list $archiveName."
+ }
-# --- install dependencies (only when the lockfile changed) -----------------
-$depsStamp = Join-Path $InstallDir '.skill-recorder-deps.sha'
-$depsNow = FileSha 'package-lock.json'
-if (-not (Test-Path 'node_modules') -or ((Get-Content -LiteralPath $depsStamp -ErrorAction SilentlyContinue) -ne $depsNow)) {
- Info "Installing dependencies (npm install)…"
- & npm install --no-audit --no-fund; Assert-Ok 'npm install'
- Set-Content -LiteralPath $depsStamp -Value $depsNow
-} else {
- Info "Dependencies already up to date — skipping npm install."
+ $distributionKey = "win32-$Architecture"
+ $reviewedProperty = $policy.electron.distributions.PSObject.Properties[$distributionKey]
+ if ($null -eq $reviewedProperty) {
+ throw "The compliance policy does not review Electron for $distributionKey."
+ }
+
+ $manifestHash = ([string]$manifestProperty.Value).ToLowerInvariant()
+ $reviewedHash = ([string]$reviewedProperty.Value).ToLowerInvariant()
+ if ($manifestHash -ne $reviewedHash) {
+ throw "Electron's checksum manifest does not match the reviewed distribution hash."
+ }
}
-# --- check for Copilot CLI (bundled, desktop app, or PATH) -----------------
-if (-not (Test-CopilotAvailable)) {
- Write-Warning "No Copilot CLI found. Install GitHub Copilot (https://github.com/features/copilot) or ensure the bundled package installed correctly. The app will launch, but recording analysis needs it."
+function Get-NodeRuntime {
+ param(
+ [Parameter(Mandatory)][string]$Architecture,
+ [Parameter(Mandatory)][string]$RuntimeRoot,
+ [Parameter(Mandatory)][string]$StagingRoot
+ )
+
+ Write-Step "Resolving the latest Node.js 24 LTS release for Windows $Architecture."
+ $indexPath = Join-Path $StagingRoot "node-index.json"
+ Invoke-Download -Uri "https://nodejs.org/dist/index.json" -Destination $indexPath
+ $index = @(Get-Content -LiteralPath $indexPath -Raw | ConvertFrom-Json)
+ $fileKind = "win-$Architecture-zip"
+ $matches = @(
+ $index | Where-Object {
+ $_.version -match "^v24\.\d+\.\d+$" -and
+ [bool]$_.lts -and
+ $_.files -contains $fileKind
+ }
+ )
+ if ($matches.Count -eq 0) {
+ throw "Node.js did not publish a Node 24 archive for Windows $Architecture."
+ }
+
+ $version = [string]$matches[0].version
+ $archiveName = "node-$version-win-$Architecture.zip"
+ $runtimeDirectory = Join-Path $RuntimeRoot ([IO.Path]::GetFileNameWithoutExtension($archiveName))
+ $nodeExe = Join-Path $runtimeDirectory "node.exe"
+ $npmCmd = Join-Path $runtimeDirectory "npm.cmd"
+
+ if (-not (Test-Path -LiteralPath $runtimeDirectory -PathType Container)) {
+ Write-Step "Downloading $archiveName from nodejs.org."
+ $archivePath = Join-Path $StagingRoot $archiveName
+ $sumsPath = Join-Path $StagingRoot "SHASUMS256.txt"
+ $baseUri = "https://nodejs.org/dist/$version"
+ Invoke-Download -Uri "$baseUri/$archiveName" -Destination $archivePath
+ Invoke-Download -Uri "$baseUri/SHASUMS256.txt" -Destination $sumsPath
+ Assert-ZipArchive -Path $archivePath
+
+ $hashPattern = "(?m)^([0-9a-fA-F]{64})\s+" + [regex]::Escape($archiveName) + "\s*$"
+ $hashMatch = [regex]::Match((Get-Content -LiteralPath $sumsPath -Raw), $hashPattern)
+ if (-not $hashMatch.Success) {
+ throw "Official Node.js checksums do not list $archiveName."
+ }
+
+ $expectedHash = $hashMatch.Groups[1].Value.ToLowerInvariant()
+ $actualHash = (Get-FileHash -LiteralPath $archivePath -Algorithm SHA256).Hash.ToLowerInvariant()
+ if ($actualHash -ne $expectedHash) {
+ throw "Node.js archive SHA-256 mismatch. Expected $expectedHash, got $actualHash."
+ }
+
+ $expandedRoot = Join-Path $StagingRoot "node-expanded"
+ Expand-Archive -LiteralPath $archivePath -DestinationPath $expandedRoot
+ $expandedDirectory = Join-Path $expandedRoot ([IO.Path]::GetFileNameWithoutExtension($archiveName))
+ Assert-TrustedSignature `
+ -Path (Join-Path $expandedDirectory "node.exe") `
+ -PublisherPattern "OpenJS Foundation" `
+ -PublisherName "OpenJS Foundation"
+ Assert-RequiredPaths -Root $expandedDirectory -RelativePaths @("LICENSE", "npm.cmd")
+
+ New-Item -ItemType Directory -Path $RuntimeRoot -Force | Out-Null
+ Move-Item -LiteralPath $expandedDirectory -Destination $runtimeDirectory
+ }
+
+ Assert-TrustedSignature `
+ -Path $nodeExe `
+ -PublisherPattern "OpenJS Foundation" `
+ -PublisherName "OpenJS Foundation"
+ Assert-RequiredPaths -Root $runtimeDirectory -RelativePaths @("LICENSE", "npm.cmd")
+
+ $versionOutput = @(& $nodeExe --version)
+ $versionExitCode = $LASTEXITCODE
+ $reportedVersion = ($versionOutput -join "`n").Trim()
+ if ($versionExitCode -ne 0 -or $reportedVersion -ne $version) {
+ throw "Node.js runtime version mismatch. Expected $version, got $reportedVersion."
+ }
+ $architectureOutput = @(& $nodeExe -p "process.arch")
+ $architectureExitCode = $LASTEXITCODE
+ $reportedArchitecture = ($architectureOutput -join "`n").Trim()
+ if ($architectureExitCode -ne 0 -or $reportedArchitecture -ne $Architecture) {
+ throw "Node.js runtime architecture mismatch. Expected $Architecture, got $reportedArchitecture."
+ }
+
+ return [pscustomobject]@{
+ Version = $version
+ Root = $runtimeDirectory
+ Node = $nodeExe
+ Npm = $npmCmd
+ }
+}
+
+function New-SourceShortcut {
+ param(
+ [Parameter(Mandatory)][string]$SourceDirectory,
+ [Parameter(Mandatory)][string]$ElectronExecutable
+ )
+
+ $programs = [Environment]::GetFolderPath([Environment+SpecialFolder]::Programs)
+ if ([string]::IsNullOrWhiteSpace($programs)) {
+ throw "The current user does not have a Start Menu Programs directory."
+ }
+
+ $shortcutPath = Join-Path $programs "Skill Recorder (Source).lnk"
+ $shell = New-Object -ComObject WScript.Shell
+ $shortcut = $shell.CreateShortcut($shortcutPath)
+ $shortcut.TargetPath = $ElectronExecutable
+ $shortcut.Arguments = '"' + $SourceDirectory + '"'
+ $shortcut.WorkingDirectory = $SourceDirectory
+ $shortcut.IconLocation = "$ElectronExecutable,0"
+ $shortcut.Description = "Skill Recorder built locally from pinned source"
+ $shortcut.Save()
+ return $shortcutPath
+}
+
+if ([Environment]::OSVersion.Platform -ne [PlatformID]::Win32NT) {
+ throw "install.ps1 supports Windows only. Use the manual source instructions in INSTALL.md elsewhere."
+}
+if ($PSVersionTable.PSVersion -lt [version]"5.1") {
+ throw "PowerShell 5.1 or newer is required."
+}
+if ([string]::IsNullOrWhiteSpace($Commit) -or $Commit -notmatch "^[0-9a-fA-F]{40}$") {
+ throw "Set SKILL_RECORDER_COMMIT to the full 40-character release commit SHA."
+}
+
+$Commit = $Commit.ToLowerInvariant()
+$architecture = Get-WindowsArchitecture
+
+if ([string]::IsNullOrWhiteSpace($InstallRoot)) {
+ if ([string]::IsNullOrWhiteSpace($env:LOCALAPPDATA)) {
+ throw "LOCALAPPDATA is unavailable. Set SKILL_RECORDER_INSTALL_ROOT explicitly."
+ }
+ $InstallRoot = Join-Path $env:LOCALAPPDATA "SkillRecorder"
}
+$InstallRoot = [IO.Path]::GetFullPath($InstallRoot)
+
+$runtimeRoot = Join-Path $InstallRoot "runtime"
+$versionsRoot = Join-Path $InstallRoot "versions"
+$sourceDirectory = Join-Path $versionsRoot $Commit
+$metadataPath = Join-Path $sourceDirectory ".skill-recorder-install.json"
+$platformPackage = "@github\copilot-win32-$architecture"
+
+New-Item -ItemType Directory -Path $versionsRoot -Force | Out-Null
-# --- build (only when the source or dependencies changed) ------------------
-$buildStamp = Join-Path $InstallDir '.skill-recorder-build.sha'
-$buildNow = "${versionToken}:${depsNow}"
-if (-not (Test-Path 'dist-electron/main.js') -or -not (Test-Path 'dist/index.html') -or
- ((Get-Content -LiteralPath $buildStamp -ErrorAction SilentlyContinue) -ne $buildNow)) {
- Info "Building app (npm run build)…"
- & npm run build; Assert-Ok 'npm run build'
- Set-Content -LiteralPath $buildStamp -Value $buildNow
+if (Test-Path -LiteralPath $sourceDirectory -PathType Container) {
+ Write-Step "Using the existing installation for commit $Commit."
+ if (-not (Test-Path -LiteralPath $metadataPath -PathType Leaf)) {
+ throw "The existing source directory has no installation metadata: $sourceDirectory"
+ }
+
+ $metadata = Get-Content -LiteralPath $metadataPath -Raw | ConvertFrom-Json
+ if ([string]$metadata.commit -ne $Commit) {
+ throw "Existing installation metadata does not match commit $Commit."
+ }
+ $lockHash = (Get-FileHash -LiteralPath (Join-Path $sourceDirectory "package-lock.json") -Algorithm SHA256).Hash.ToLowerInvariant()
+ if ($lockHash -ne [string]$metadata.packageLockSha256) {
+ throw "The existing installation's package-lock.json has changed."
+ }
} else {
- Info "Build already up to date — skipping npm run build."
-}
-
-Info "Skill Recorder is installed in $InstallDir"
-Info "Re-run the same command any time to update & launch, or: cd `"$InstallDir`"; npm start"
-
-# --- launch ----------------------------------------------------------------
-if ($env:SKILL_RECORDER_NO_RUN) {
- Info "SKILL_RECORDER_NO_RUN set — not launching."
- return
-}
-
-Info "Launching Skill Recorder…"
-
-if ($env:SKILL_RECORDER_DETACHED) {
- # Detached: keep running after this window closes, and (since there's no
- # console to watch) capture output to a rolling, capped set of log files.
- $logDir = Join-Path $InstallDir 'logs'
- $keep = if ($env:SKILL_RECORDER_LOG_KEEP -match '^\d+$') { [int]$env:SKILL_RECORDER_LOG_KEEP } else { 5 }
- if ($keep -lt 1) { $keep = 1 }
- New-Item -ItemType Directory -Force -Path $logDir | Out-Null
- # Rotate by launch: keep the newest ($keep-1) logs so that, once we add the
- # one below, at most $keep remain.
- Get-ChildItem -LiteralPath $logDir -Filter 'skill-recorder-*.log' -ErrorAction SilentlyContinue |
- Sort-Object LastWriteTime -Descending | Select-Object -Skip ($keep - 1) |
- Remove-Item -Force -ErrorAction SilentlyContinue
- $logFile = Join-Path $logDir ("skill-recorder-" + (Get-Date -Format 'yyyyMMdd-HHmmss') + ".log")
- # Let cmd.exe own the redirection so stdout+stderr share one file; Start-Process
- # launches it independently so the app outlives this PowerShell session.
- $proc = Start-Process -FilePath $env:ComSpec `
- -ArgumentList "/c npm start > `"$logFile`" 2>&1" `
- -WorkingDirectory $InstallDir -WindowStyle Hidden -PassThru
- Info "Running in the background (PID $($proc.Id)). It will keep running after this window closes."
- Info "Logs: $logFile"
- return
-}
-
-& npm start; Assert-Ok 'npm start'
+ $stagingDirectory = Join-Path $InstallRoot (".staging-" + [guid]::NewGuid().ToString("N"))
+ New-Item -ItemType Directory -Path $stagingDirectory -Force | Out-Null
+
+ try {
+ $runtime = Get-NodeRuntime `
+ -Architecture $architecture `
+ -RuntimeRoot $runtimeRoot `
+ -StagingRoot $stagingDirectory
+
+ Write-Step "Downloading the exact source commit from GitHub."
+ $sourceArchive = Join-Path $stagingDirectory "skill-recorder-$Commit.zip"
+ Invoke-Download `
+ -Uri "https://codeload.github.com/adilei/skill-recorder/zip/$Commit" `
+ -Destination $sourceArchive
+ Assert-ZipArchive -Path $sourceArchive
+ $sourceArchiveHash = (Get-FileHash -LiteralPath $sourceArchive -Algorithm SHA256).Hash.ToLowerInvariant()
+
+ $sourceExtractRoot = Join-Path $stagingDirectory "source"
+ Expand-Archive -LiteralPath $sourceArchive -DestinationPath $sourceExtractRoot
+ $sourceCandidates = @(
+ Get-ChildItem -LiteralPath $sourceExtractRoot -Directory |
+ Where-Object { Test-Path -LiteralPath (Join-Path $_.FullName "package.json") -PathType Leaf }
+ )
+ if ($sourceCandidates.Count -ne 1) {
+ throw "Expected one Skill Recorder source directory, found $($sourceCandidates.Count)."
+ }
+ $expectedSourceDirectoryName = "skill-recorder-$Commit"
+ if ($sourceCandidates[0].Name -ne $expectedSourceDirectoryName) {
+ throw "GitHub source directory does not match commit $Commit."
+ }
+ $buildDirectory = $sourceCandidates[0].FullName
+
+ Assert-RequiredPaths -Root $buildDirectory -RelativePaths @(
+ "LICENSE",
+ "THIRD-PARTY-NOTICES.md",
+ "CONTRIBUTING.md",
+ "package.json",
+ "package-lock.json"
+ )
+
+ Write-Step "Installing lockfile-pinned dependencies from their publishers."
+ $environmentOverrides = [ordered]@{
+ PATH = "$($runtime.Root);$env:PATH"
+ NPM_CONFIG_REGISTRY = "https://registry.npmjs.org/"
+ NPM_CONFIG_REPLACE_REGISTRY_HOST = "never"
+ NPM_CONFIG_PLATFORM = "win32"
+ NPM_CONFIG_ARCH = $architecture
+ ELECTRON_MIRROR = "https://github.com/electron/electron/releases/download/"
+ NPM_CONFIG_ELECTRON_MIRROR = "https://github.com/electron/electron/releases/download/"
+ ELECTRON_INSTALL_PLATFORM = "win32"
+ ELECTRON_INSTALL_ARCH = $architecture
+ ELECTRON_USE_REMOTE_CHECKSUMS = $null
+ NPM_CONFIG_ELECTRON_USE_REMOTE_CHECKSUMS = $null
+ ELECTRON_OVERRIDE_DIST_PATH = $null
+ ELECTRON_CUSTOM_DIR = $null
+ ELECTRON_CUSTOM_FILENAME = $null
+ }
+ $originalEnvironment = @{}
+ foreach ($entry in $environmentOverrides.GetEnumerator()) {
+ $originalEnvironment[$entry.Key] = [Environment]::GetEnvironmentVariable(
+ $entry.Key,
+ [EnvironmentVariableTarget]::Process
+ )
+ [Environment]::SetEnvironmentVariable(
+ $entry.Key,
+ $entry.Value,
+ [EnvironmentVariableTarget]::Process
+ )
+ }
+
+ Push-Location $buildDirectory
+ try {
+ Invoke-CheckedCommand `
+ -FilePath $runtime.Npm `
+ -Arguments @("ci", "--no-audit", "--no-fund") `
+ -Description "npm ci"
+
+ Assert-ReviewedElectronDistribution `
+ -SourceDirectory $buildDirectory `
+ -Architecture $architecture
+
+ Write-Step "Downloading the checksummed Electron runtime from GitHub."
+ Invoke-CheckedCommand `
+ -FilePath $runtime.Node `
+ -Arguments @("node_modules\electron\install.js") `
+ -Description "Electron runtime download"
+
+ Write-Step "Validating dependency licenses and notices."
+ Invoke-CheckedCommand `
+ -FilePath $runtime.Npm `
+ -Arguments @("run", "compliance:licenses") `
+ -Description "license validation"
+
+ Write-Step "Building Skill Recorder locally."
+ Invoke-CheckedCommand `
+ -FilePath $runtime.Npm `
+ -Arguments @("run", "build") `
+ -Description "local source build"
+ } finally {
+ foreach ($entry in $originalEnvironment.GetEnumerator()) {
+ [Environment]::SetEnvironmentVariable(
+ $entry.Key,
+ $entry.Value,
+ [EnvironmentVariableTarget]::Process
+ )
+ }
+ Pop-Location
+ }
+
+ Assert-RequiredPaths -Root $buildDirectory -RelativePaths @(
+ ".compliance\COMPLIANCE-README.md",
+ ".compliance\THIRD-PARTY-LICENSES.txt",
+ ".compliance\onnxruntime",
+ "node_modules\@github\copilot\LICENSE.md",
+ "node_modules\$platformPackage\LICENSE.md",
+ "node_modules\electron\dist\LICENSE",
+ "node_modules\electron\dist\LICENSES.chromium.html",
+ "dist",
+ "dist-electron"
+ )
+
+ $buildElectron = Get-ElectronExecutable -SourceDirectory $buildDirectory
+ $buildCopilot = Join-Path $buildDirectory "node_modules\$platformPackage\copilot.exe"
+ Assert-TrustedSignature `
+ -Path $buildCopilot `
+ -PublisherPattern "GitHub, Inc\." `
+ -PublisherName "GitHub"
+
+ $metadata = [ordered]@{
+ schemaVersion = 1
+ distributionMode = "source-local-build"
+ commit = $Commit
+ sourceUrl = "https://github.com/adilei/skill-recorder/tree/$Commit"
+ sourceArchiveSha256 = $sourceArchiveHash
+ packageLockSha256 = (Get-FileHash -LiteralPath (Join-Path $buildDirectory "package-lock.json") -Algorithm SHA256).Hash.ToLowerInvariant()
+ electronExecutableSha256 = (Get-FileHash -LiteralPath $buildElectron -Algorithm SHA256).Hash.ToLowerInvariant()
+ nodeVersion = $runtime.Version
+ nodeRuntime = $runtime.Root
+ installedAt = (Get-Date).ToUniversalTime().ToString("o")
+ }
+ $metadata | ConvertTo-Json -Depth 4 |
+ Set-Content -LiteralPath (Join-Path $buildDirectory ".skill-recorder-install.json") -Encoding UTF8
+
+ if (Test-Path -LiteralPath $sourceDirectory) {
+ throw "Refusing to overwrite an existing source installation: $sourceDirectory"
+ }
+ Move-Item -LiteralPath $buildDirectory -Destination $sourceDirectory
+ } finally {
+ if (Test-Path -LiteralPath $stagingDirectory) {
+ Remove-Item -LiteralPath $stagingDirectory -Recurse -Force
+ }
+ }
+}
+
+Assert-RequiredPaths -Root $sourceDirectory -RelativePaths @(
+ "LICENSE",
+ "THIRD-PARTY-NOTICES.md",
+ ".compliance\COMPLIANCE-README.md",
+ ".compliance\THIRD-PARTY-LICENSES.txt",
+ "node_modules\@github\copilot\LICENSE.md",
+ "node_modules\$platformPackage\LICENSE.md",
+ "node_modules\electron\dist\LICENSE",
+ "node_modules\electron\dist\LICENSES.chromium.html",
+ "dist",
+ "dist-electron"
+)
+
+$electronExecutable = Get-ElectronExecutable -SourceDirectory $sourceDirectory
+$copilotExecutable = Join-Path $sourceDirectory "node_modules\$platformPackage\copilot.exe"
+$electronHash = (Get-FileHash -LiteralPath $electronExecutable -Algorithm SHA256).Hash.ToLowerInvariant()
+if ($electronHash -ne [string]$metadata.electronExecutableSha256) {
+ throw "The installed Electron executable has changed since its checksum-verified download."
+}
+Assert-TrustedSignature `
+ -Path $copilotExecutable `
+ -PublisherPattern "GitHub, Inc\." `
+ -PublisherName "GitHub"
+
+$shortcutPath = New-SourceShortcut `
+ -SourceDirectory $sourceDirectory `
+ -ElectronExecutable $electronExecutable
+
+Write-Step "Installed commit $Commit at $sourceDirectory"
+Write-Step "License materials remain in the source tree, dependency packages, and .compliance directory."
+Write-Step "Created Start Menu shortcut: $shortcutPath"
+Write-Warning "This locally generated build is for local execution only. Do not redistribute it."
+
+if (-not $skipLaunch) {
+ Write-Step "Launching Skill Recorder."
+ Start-Process `
+ -FilePath $electronExecutable `
+ -ArgumentList ('"{0}"' -f $sourceDirectory) `
+ -WorkingDirectory $sourceDirectory | Out-Null
+}
+}
diff --git a/install.sh b/install.sh
index 9435a3e..322404c 100755
--- a/install.sh
+++ b/install.sh
@@ -1,244 +1,438 @@
#!/usr/bin/env bash
+# SPDX-License-Identifier: MIT
+# Copyright (c) 2026 Skill Recorder contributors
#
-# Skill Recorder — download & run (macOS / Linux).
-#
-# Fetches Skill Recorder from source into a local directory, installs its
-# dependencies, builds it, and launches it. This is a lightweight alternative
-# to packaged installers (no .dmg / .exe): it just runs the app from source.
-#
-# The script is idempotent — re-running it fast-forwards to the latest code and
-# skips any step (dependency install, build) whose inputs haven't changed, so
-# the same one-liner both installs and updates the app.
-#
-# Usage:
-# curl -fsSL https://raw.githubusercontent.com/adilei/skill-recorder/master/install.sh | bash
-#
-# Node.js is the only heavy prerequisite, and you don't need it pre-installed:
-# if a suitable Node isn't already on your PATH, this script downloads an
-# official, checksum-verified Node.js binary into the install directory and uses
-# it just for this app. Nothing is installed system-wide and no executables are
-# built.
-#
-# Environment overrides:
-# SKILL_RECORDER_HOME install directory (default: ~/.skill-recorder)
-# SKILL_RECORDER_REPO owner/repo (default: adilei/skill-recorder)
-# SKILL_RECORDER_REF branch / tag / commit (default: master)
-# SKILL_RECORDER_NO_RUN set to install & build only, without launching
-# SKILL_RECORDER_DETACHED set to run the app detached (survives terminal
-# close) and write rolling logs to <home>/logs
-# SKILL_RECORDER_LOG_KEEP how many detached log files to keep (default: 5)
-# SKILL_RECORDER_NODE_VERSION Node to fetch when missing (default: latest-v22.x)
-# SKILL_RECORDER_NODE_MIRROR Node dist mirror (default: https://nodejs.org/dist)
-#
+# Builds Skill Recorder locally from an exact source commit on macOS or Ubuntu.
+# The script downloads no prebuilt Skill Recorder application.
+
set -euo pipefail
+umask 077
-REPO="${SKILL_RECORDER_REPO:-adilei/skill-recorder}"
-REF="${SKILL_RECORDER_REF:-master}"
-INSTALL_DIR="${SKILL_RECORDER_HOME:-$HOME/.skill-recorder}"
-NODE_MIN_MAJOR=22
+COMMIT="${SKILL_RECORDER_COMMIT:-}"
+INSTALL_ROOT="${SKILL_RECORDER_INSTALL_ROOT:-}"
+NO_LAUNCH="${SKILL_RECORDER_NO_LAUNCH:-}"
+DETACHED="${SKILL_RECORDER_DETACHED:-}"
+LOG_KEEP="${SKILL_RECORDER_LOG_KEEP:-5}"
-info() { printf '\033[1;34m==>\033[0m %s\n' "$*"; }
-warn() { printf '\033[1;33mwarning:\033[0m %s\n' "$*" >&2; }
-die() { printf '\033[1;31merror:\033[0m %s\n' "$*" >&2; exit 1; }
+info() { printf '[Skill Recorder] %s\n' "$*"; }
+warn() { printf '[Skill Recorder] WARNING: %s\n' "$*" >&2; }
+die() {
+ printf '[Skill Recorder] ERROR: %s\n' "$*" >&2
+ exit 1
+}
have() { command -v "$1" >/dev/null 2>&1; }
-# Detect a usable Copilot CLI the way the Electron app does. The app uses the
-# platform binary bundled in node_modules (installed by npm), so that is the
-# real signal — not a `copilot` on PATH. Fall back to the desktop app or PATH.
-copilot_available() {
- local plat arch
- case "$(uname -s)" in Darwin) plat="darwin" ;; *) plat="linux" ;; esac
- case "$(uname -m)" in arm64|aarch64) arch="arm64" ;; *) arch="x64" ;; esac
- [ -e "$INSTALL_DIR/node_modules/@github/copilot-$plat-$arch/copilot" ] && return 0
- [ -d "/Applications/GitHub Copilot.app" ] && return 0
- have copilot
-}
+if [[ ! "$COMMIT" =~ ^[0-9a-fA-F]{40}$ ]]; then
+ die "Set SKILL_RECORDER_COMMIT to the full 40-character release commit SHA."
+fi
+COMMIT="$(printf '%s' "$COMMIT" | tr 'A-F' 'a-f')"
+
+SYSTEM="$(uname -s)"
+MACHINE="$(uname -m)"
+case "$SYSTEM" in
+ Darwin)
+ PLATFORM="darwin"
+ DEFAULT_INSTALL_ROOT="$HOME/Library/Application Support/SkillRecorder"
+ ;;
+ Linux)
+ [ -r /etc/os-release ] || die "Ubuntu could not be identified from /etc/os-release."
+ OS_ID="$(sed -n 's/^ID=//p' /etc/os-release | head -n 1 | tr -d '"')"
+ [ "$OS_ID" = "ubuntu" ] || die "install.sh supports Ubuntu only; found ${OS_ID:-unknown}."
+ PLATFORM="linux"
+ DEFAULT_INSTALL_ROOT="${XDG_DATA_HOME:-$HOME/.local/share}/SkillRecorder"
+ ;;
+ *)
+ die "install.sh supports macOS and Ubuntu only; found $SYSTEM."
+ ;;
+esac
+
+case "$MACHINE" in
+ x86_64|amd64) ARCHITECTURE="x64" ;;
+ arm64|aarch64) ARCHITECTURE="arm64" ;;
+ *) die "Unsupported processor architecture: $MACHINE." ;;
+esac
+
+INSTALL_ROOT="${INSTALL_ROOT:-$DEFAULT_INSTALL_ROOT}"
+case "$INSTALL_ROOT" in
+ ""|"/"|"$HOME") die "Refusing unsafe installation root: $INSTALL_ROOT." ;;
+esac
+
+for command in curl tar; do
+ have "$command" || die "$command is required."
+done
+if ! have shasum && ! have sha256sum; then
+ die "shasum or sha256sum is required."
+fi
+
+mkdir -p "$INSTALL_ROOT"
+INSTALL_ROOT="$(cd "$INSTALL_ROOT" && pwd -P)"
+RUNTIME_ROOT="$INSTALL_ROOT/runtime"
+VERSIONS_ROOT="$INSTALL_ROOT/versions"
+mkdir -p "$RUNTIME_ROOT" "$VERSIONS_ROOT"
-sha256() { # print the sha256 of a file, or nothing if it doesn't exist
- [ -f "$1" ] || return 0
- if have shasum; then shasum -a 256 "$1" | awk '{print $1}'
- else sha256sum "$1" | awk '{print $1}'; fi
+WORK_DIR="$(mktemp -d "${TMPDIR:-/tmp}/skill-recorder-install.XXXXXX")"
+STAGING_DIR=""
+cleanup() {
+ if [ -n "$STAGING_DIR" ] && [ -d "$STAGING_DIR" ]; then
+ rm -rf -- "$STAGING_DIR"
+ fi
+ if [ -n "${WORK_DIR:-}" ] && [ -d "$WORK_DIR" ]; then
+ rm -rf -- "$WORK_DIR"
+ fi
}
+trap cleanup EXIT
+trap 'exit 130' HUP INT TERM
-# True when a Node new enough to build & run the app is already on PATH.
-node_ok() {
- have node || return 1
- # Parse "node -v" (e.g. v22.23.1) rather than a quoted JS expression, to stay
- # consistent with the Windows script and avoid any arg-quoting surprises.
- local ver maj
- ver="$(node -v 2>/dev/null)" || return 1
- maj="${ver#v}"; maj="${maj%%.*}"
- case "$maj" in ''|*[!0-9]*) return 1 ;; esac
- [ "$maj" -ge "$NODE_MIN_MAJOR" ]
+sha256_file() {
+ if have shasum; then
+ shasum -a 256 "$1" | awk '{print tolower($1)}'
+ else
+ sha256sum "$1" | awk '{print tolower($1)}'
+ fi
}
-# Echo "<os> <arch>" tokens matching Node's dist filenames, or die if unsupported.
-detect_node_platform() {
- local os arch
- case "$(uname -s)" in
- Darwin) os=darwin ;;
- Linux) os=linux ;;
- *) die "Can't auto-download Node for $(uname -s); install Node ${NODE_MIN_MAJOR}+ manually." ;;
+download() {
+ local uri="$1"
+ local destination="$2"
+ case "$uri" in
+ https://*) ;;
+ *) die "Refusing non-HTTPS download: $uri." ;;
esac
- case "$(uname -m)" in
- x86_64|amd64) arch=x64 ;;
- arm64|aarch64) arch=arm64 ;;
- *) die "Can't auto-download Node for $(uname -m); install Node ${NODE_MIN_MAJOR}+ manually." ;;
- esac
- printf '%s %s' "$os" "$arch"
+ curl --fail --location --silent --show-error "$uri" --output "$destination"
+ [ -s "$destination" ] || die "Download did not create a non-empty file: $uri."
+}
+
+checksum_from_manifest() {
+ local manifest="$1"
+ local file_name="$2"
+ awk -v name="$file_name" '$2 == name || $2 == "*" name { print tolower($1); exit }' "$manifest"
}
-# Ensure a usable Node/npm is on PATH: prefer the system one, otherwise download
-# an official binary into "$INSTALL_DIR/.node" (once) and prepend it to PATH.
-ensure_node() {
- if node_ok; then
- info "Using existing Node $(node -v)."
- return
+install_node_runtime() {
+ local channel="https://nodejs.org/dist/latest-v24.x"
+ local sums="$WORK_DIR/node-SHASUMS256.txt"
+ download "$channel/SHASUMS256.txt" "$sums"
+
+ local suffix="-${PLATFORM}-${ARCHITECTURE}.tar.gz"
+ local archive_name
+ archive_name="$(
+ awk -v suffix="$suffix" '
+ length($2) >= length(suffix) &&
+ substr($2, length($2) - length(suffix) + 1) == suffix {
+ print $2
+ exit
+ }
+ ' "$sums"
+ )"
+ [ -n "$archive_name" ] || die "Node.js 24 did not publish a $PLATFORM-$ARCHITECTURE archive."
+ case "$archive_name" in
+ node-v24.*-"$PLATFORM"-"$ARCHITECTURE".tar.gz) ;;
+ *) die "Unexpected Node.js archive name: $archive_name." ;;
+ esac
+
+ local expected_hash
+ expected_hash="$(checksum_from_manifest "$sums" "$archive_name")"
+ [ -n "$expected_hash" ] || die "Node.js checksums do not list $archive_name."
+
+ local archive_base="${archive_name%.tar.gz}"
+ RUNTIME_DIR="$RUNTIME_ROOT/$archive_base"
+ NODE="$RUNTIME_DIR/bin/node"
+ NPM="$RUNTIME_DIR/bin/npm"
+
+ if [ -x "$NODE" ] &&
+ [ -x "$NPM" ] &&
+ [ -f "$RUNTIME_DIR/LICENSE" ] &&
+ [ "$(cat "$RUNTIME_DIR/.archive-sha256" 2>/dev/null || true)" = "$expected_hash" ] &&
+ [ "$(cat "$RUNTIME_DIR/.node-sha256" 2>/dev/null || true)" = "$(sha256_file "$NODE")" ]; then
+ info "Using verified portable Node.js runtime $archive_base."
+ else
+ local archive="$WORK_DIR/$archive_name"
+ local extraction="$WORK_DIR/node-extraction"
+ info "Downloading official portable Node.js 24 runtime for $PLATFORM-$ARCHITECTURE."
+ download "$channel/$archive_name" "$archive"
+ local actual_hash
+ actual_hash="$(sha256_file "$archive")"
+ [ "$actual_hash" = "$expected_hash" ] ||
+ die "Node.js archive SHA-256 mismatch. Expected $expected_hash, got $actual_hash."
+
+ rm -rf -- "$RUNTIME_DIR"
+ mkdir -p "$extraction"
+ tar -xzf "$archive" -C "$extraction"
+ [ -d "$extraction/$archive_base" ] ||
+ die "Node.js archive did not contain the expected directory."
+ mv "$extraction/$archive_base" "$RUNTIME_DIR"
+ [ -x "$NODE" ] && [ -x "$NPM" ] && [ -f "$RUNTIME_DIR/LICENSE" ] ||
+ die "The extracted Node.js runtime is incomplete."
+ printf '%s\n' "$expected_hash" > "$RUNTIME_DIR/.archive-sha256"
+ sha256_file "$NODE" > "$RUNTIME_DIR/.node-sha256"
fi
- local node_dir="$INSTALL_DIR/.node"
- if [ -x "$node_dir/bin/node" ]; then
- PATH="$node_dir/bin:$PATH"; export PATH
- if node_ok; then
- info "Using bundled Node $(node -v) (in $node_dir)."
- return
- fi
+ PATH="$RUNTIME_DIR/bin:$PATH"
+ export PATH
+ local node_version node_platform node_architecture
+ node_version="$("$NODE" -p 'process.versions.node')"
+ node_platform="$("$NODE" -p 'process.platform')"
+ node_architecture="$("$NODE" -p 'process.arch')"
+ [ "${node_version%%.*}" = "24" ] || die "Expected Node.js 24, got $node_version."
+ [ "$node_platform" = "$PLATFORM" ] ||
+ die "Expected Node.js platform $PLATFORM, got $node_platform."
+ [ "$node_architecture" = "$ARCHITECTURE" ] ||
+ die "Expected Node.js architecture $ARCHITECTURE, got $node_architecture."
+}
+
+required_install_files() {
+ local source_directory="$1"
+ local copilot_package="@github/copilot-${PLATFORM}-${ARCHITECTURE}"
+ local files="
+LICENSE
+THIRD-PARTY-NOTICES.md
+third_party/compliance-policy.json
+node_modules/@github/copilot/LICENSE.md
+node_modules/$copilot_package/LICENSE.md
+node_modules/electron/dist/LICENSE
+node_modules/electron/dist/LICENSES.chromium.html
+.compliance/COMPLIANCE-README.md
+.compliance/THIRD-PARTY-LICENSES.txt
+.compliance/licenses/LGPL-3.0.txt
+dist/index.html
+dist-electron/main.js
+"
+ local relative
+ while IFS= read -r relative; do
+ [ -z "$relative" ] && continue
+ [ -e "$source_directory/$relative" ] ||
+ die "Installed source is missing required file: $relative."
+ done <<EOF
+$files
+EOF
+}
+
+electron_executable() {
+ local source_directory="$1"
+ if [ "$PLATFORM" = "darwin" ]; then
+ printf '%s\n' "$source_directory/node_modules/electron/dist/Electron.app/Contents/MacOS/Electron"
+ else
+ printf '%s\n' "$source_directory/node_modules/electron/dist/electron"
fi
+}
- have curl || die "curl is required to download Node.js."
- have tar || die "tar is required to unpack Node.js."
+copilot_executable() {
+ local source_directory="$1"
+ printf '%s\n' \
+ "$source_directory/node_modules/@github/copilot-${PLATFORM}-${ARCHITECTURE}/copilot"
+}
- local platform os arch
- platform="$(detect_node_platform)"; os="${platform% *}"; arch="${platform#* }"
+validate_existing_install() {
+ local source_directory="$1"
+ [ "$(cat "$source_directory/.skill-recorder-commit" 2>/dev/null || true)" = "$COMMIT" ] ||
+ die "Existing installation metadata does not match commit $COMMIT."
+ local lock_hash
+ lock_hash="$(sha256_file "$source_directory/package-lock.json")"
+ [ "$(cat "$source_directory/.skill-recorder-lock-sha256" 2>/dev/null || true)" = "$lock_hash" ] ||
+ die "The existing installation's package-lock.json has changed."
- local channel="${SKILL_RECORDER_NODE_VERSION:-latest-v${NODE_MIN_MAJOR}.x}"
- local mirror="${SKILL_RECORDER_NODE_MIRROR:-https://nodejs.org/dist}"
- case "$channel" in
- latest-*|v*) : ;; # already a dist subdirectory name
- *) channel="v$channel" ;;
- esac
- local base="$mirror/$channel"
-
- info "Node ${NODE_MIN_MAJOR}+ not found — downloading a private copy for Skill Recorder…"
- local sums; sums="$(curl -fsSL "$base/SHASUMS256.txt")" \
- || die "Couldn't fetch Node checksums from $base/SHASUMS256.txt"
- local file; file="$(printf '%s\n' "$sums" \
- | awk -v re="node-.*-${os}-${arch}\\.tar\\.gz$" '$2 ~ re {print $2; exit}')"
- [ -n "$file" ] || die "No Node ${os}-${arch} build found at $base."
- local want; want="$(printf '%s\n' "$sums" | awk -v f="$file" '$2==f {print $1; exit}')"
-
- local tmp; tmp="$(mktemp -d -t sr-node.XXXXXX)"
- trap 'rm -rf "$tmp"' RETURN
- info " downloading $file"
- curl -fSL --progress-bar "$base/$file" -o "$tmp/$file" || die "Download failed: $base/$file"
- local got; got="$(sha256 "$tmp/$file")"
- [ "$got" = "$want" ] || die "Checksum mismatch for $file (expected $want, got $got)."
- info " checksum verified"
-
- rm -rf "$node_dir"; mkdir -p "$node_dir"
- tar -xzf "$tmp/$file" -C "$node_dir" --strip-components=1
- PATH="$node_dir/bin:$PATH"; export PATH
- node_ok || die "Downloaded Node is still unusable — please report this."
- info "Installed Node $(node -v) into $node_dir"
+ local electron copilot
+ electron="$(electron_executable "$source_directory")"
+ copilot="$(copilot_executable "$source_directory")"
+ [ -x "$electron" ] || die "The installed Electron executable is missing."
+ [ -x "$copilot" ] || die "The installed GitHub Copilot CLI is missing."
+ [ "$(cat "$source_directory/.skill-recorder-electron-sha256")" = "$(sha256_file "$electron")" ] ||
+ die "The installed Electron executable has changed."
+ [ "$(cat "$source_directory/.skill-recorder-copilot-sha256")" = "$(sha256_file "$copilot")" ] ||
+ die "The installed GitHub Copilot CLI has changed."
+ required_install_files "$source_directory"
}
-# --- fetch source ----------------------------------------------------------
-version_token=""
-if have git; then
- if [ ! -d "$INSTALL_DIR/.git" ]; then
- rm -rf "$INSTALL_DIR"
- mkdir -p "$INSTALL_DIR"
- git -C "$INSTALL_DIR" init -q
- git -C "$INSTALL_DIR" remote add origin "https://github.com/$REPO.git"
- else
- git -C "$INSTALL_DIR" remote set-url origin "https://github.com/$REPO.git"
+build_source_install() {
+ local source_directory="$1"
+ local archive="$WORK_DIR/skill-recorder-$COMMIT.tar.gz"
+ info "Downloading Skill Recorder source commit $COMMIT."
+ download "https://codeload.github.com/adilei/skill-recorder/tar.gz/$COMMIT" "$archive"
+
+ local top_directory
+ top_directory="$(tar -tzf "$archive" | awk -F/ 'NR == 1 { first = $1 } END { print first }')"
+ [ "$top_directory" = "skill-recorder-$COMMIT" ] ||
+ die "GitHub source archive did not contain the expected commit directory."
+
+ STAGING_DIR="$VERSIONS_ROOT/.staging-$COMMIT-$$"
+ [ ! -e "$STAGING_DIR" ] || die "Staging directory already exists: $STAGING_DIR."
+ mkdir -p "$STAGING_DIR"
+ tar -xzf "$archive" --strip-components=1 -C "$STAGING_DIR"
+
+ cd "$STAGING_DIR"
+ export NPM_CONFIG_REGISTRY="https://registry.npmjs.org/"
+ export NPM_CONFIG_CACHE="$INSTALL_ROOT/npm-cache"
+ export ELECTRON_MIRROR="https://github.com/electron/electron/releases/download/"
+
+ info "Installing lockfile-pinned dependencies from their publishers."
+ "$NPM" ci --no-audit --no-fund
+
+ info "Installing the reviewed Electron runtime."
+ "$NODE" "node_modules/electron/install.js"
+
+ local policy_key="$PLATFORM-$ARCHITECTURE"
+ local electron_version reviewed_hash
+ electron_version="$(
+ "$NODE" -e \
+ "const p=require('./third_party/compliance-policy.json');process.stdout.write(p.electron.version)"
+ )"
+ reviewed_hash="$(
+ "$NODE" -e \
+ "const p=require('./third_party/compliance-policy.json');process.stdout.write(p.electron.distributions[process.argv[1]]||'')" \
+ "$policy_key"
+ )"
+ [ -n "$reviewed_hash" ] ||
+ die "No reviewed Electron distribution exists for $policy_key."
+
+ local electron_archive="electron-v${electron_version}-${PLATFORM}-${ARCHITECTURE}.zip"
+ local electron_sums="$WORK_DIR/electron-SHASUMS256.txt"
+ download \
+ "https://github.com/electron/electron/releases/download/v${electron_version}/SHASUMS256.txt" \
+ "$electron_sums"
+ local official_hash
+ official_hash="$(checksum_from_manifest "$electron_sums" "$electron_archive")"
+ [ -n "$official_hash" ] ||
+ die "Electron's checksum manifest does not list $electron_archive."
+ [ "$official_hash" = "$reviewed_hash" ] ||
+ die "Electron's official checksum differs from the reviewed compliance policy."
+ local bundled_hash
+ bundled_hash="$(
+ "$NODE" -e \
+ "const c=require('./node_modules/electron/checksums.json');process.stdout.write(c[process.argv[1]]||'')" \
+ "$electron_archive"
+ )"
+ [ "$bundled_hash" = "$reviewed_hash" ] ||
+ die "Electron's installed checksum manifest differs from the reviewed compliance policy."
+ [ "$(cat node_modules/electron/dist/version)" = "$electron_version" ] ||
+ die "The installed Electron runtime version is not $electron_version."
+
+ local copilot_package="@github/copilot-${PLATFORM}-${ARCHITECTURE}"
+ for required in \
+ LICENSE \
+ THIRD-PARTY-NOTICES.md \
+ third_party/compliance-policy.json \
+ node_modules/@github/copilot/LICENSE.md \
+ "node_modules/$copilot_package/LICENSE.md" \
+ node_modules/electron/dist/LICENSE \
+ node_modules/electron/dist/LICENSES.chromium.html; do
+ [ -f "$required" ] || die "Dependency installation is missing required legal file: $required."
+ done
+
+ local electron copilot
+ electron="$(electron_executable "$STAGING_DIR")"
+ copilot="$(copilot_executable "$STAGING_DIR")"
+ [ -x "$electron" ] || die "Electron did not install its native executable."
+ [ -x "$copilot" ] || die "GitHub Copilot CLI did not install its native executable."
+ if [ "$PLATFORM" = "linux" ] && have ldd; then
+ local missing_libraries
+ missing_libraries="$(ldd "$electron" | awk '/not found/ { print $1 }')"
+ [ -z "$missing_libraries" ] ||
+ die "Electron requires missing Ubuntu libraries: $missing_libraries"
fi
- info "Fetching $REPO ($REF) into $INSTALL_DIR"
- git -C "$INSTALL_DIR" fetch --depth 1 origin "$REF"
- git -C "$INSTALL_DIR" reset --hard FETCH_HEAD
- version_token="$(git -C "$INSTALL_DIR" rev-parse HEAD)"
-else
- warn "'git' not found — downloading a source tarball instead."
- have curl || die "Either 'git' or 'curl' is required to download Skill Recorder."
- have tar || die "'tar' is required to extract the source tarball."
- mkdir -p "$INSTALL_DIR"
- tarball="$(mktemp -t skill-recorder.XXXXXX)"
- trap 'rm -f "$tarball"' EXIT
- info "Downloading $REPO ($REF) into $INSTALL_DIR"
- curl -fsSL "https://codeload.github.com/$REPO/tar.gz/$REF" -o "$tarball"
- # --strip-components=1 drops the top "repo-ref/" directory; node_modules and
- # dist/ live only locally (they're not in the tarball) so they survive.
- tar -xzf "$tarball" --strip-components=1 -C "$INSTALL_DIR"
- version_token="$(sha256 "$tarball")"
- rm -f "$tarball"
- trap - EXIT
-fi
-cd "$INSTALL_DIR"
+ info "Generating and validating platform license materials."
+ "$NPM" run compliance:licenses
+ [ -f .compliance/licenses/LGPL-3.0.txt ] ||
+ die "The canonical LGPL-3.0 text was not generated."
+
+ info "Building Skill Recorder locally."
+ "$NPM" run build
+
+ printf '%s\n' "$COMMIT" > .skill-recorder-commit
+ sha256_file package-lock.json > .skill-recorder-lock-sha256
+ sha256_file "$electron" > .skill-recorder-electron-sha256
+ sha256_file "$copilot" > .skill-recorder-copilot-sha256
+
+ [ ! -e "$source_directory" ] ||
+ die "Installation directory appeared while building: $source_directory."
+ mv "$STAGING_DIR" "$source_directory"
+ STAGING_DIR=""
+}
-# --- ensure a Node.js runtime (download one if the system has none) --------
-ensure_node
+write_launcher() {
+ local source_directory="$1"
+ local electron="$2"
+ local launcher="$INSTALL_ROOT/skill-recorder-source"
+ local temporary="$INSTALL_ROOT/.skill-recorder-source.$$"
+ {
+ printf '%s\n' '#!/usr/bin/env bash' 'set -euo pipefail'
+ printf 'SOURCE_DIRECTORY=%q\n' "$source_directory"
+ printf 'ELECTRON_EXECUTABLE=%q\n' "$electron"
+ printf 'exec "$ELECTRON_EXECUTABLE" "$SOURCE_DIRECTORY" "$@"\n'
+ } > "$temporary"
+ chmod 755 "$temporary"
+ mv -f "$temporary" "$launcher"
+ LAUNCHER="$launcher"
-# --- install dependencies (only when the lockfile changed) -----------------
-deps_stamp="$INSTALL_DIR/.skill-recorder-deps.sha"
-deps_now="$(sha256 package-lock.json)"
-if [ ! -d node_modules ] || [ "$(cat "$deps_stamp" 2>/dev/null || true)" != "$deps_now" ]; then
- info "Installing dependencies (npm install)…"
- npm install --no-audit --no-fund
- printf '%s\n' "$deps_now" > "$deps_stamp"
+ if [ "$PLATFORM" = "linux" ]; then
+ local applications="${XDG_DATA_HOME:-$HOME/.local/share}/applications"
+ local desktop="$applications/skill-recorder-source.desktop"
+ local desktop_temporary="$applications/.skill-recorder-source.desktop.$$"
+ mkdir -p "$applications"
+ {
+ printf '%s\n' \
+ '[Desktop Entry]' \
+ 'Type=Application' \
+ 'Name=Skill Recorder (Source)' \
+ 'Comment=Skill Recorder built locally from pinned source'
+ printf 'Exec="%s"\n' "$launcher"
+ printf '%s\n' \
+ 'Icon=applications-development' \
+ 'Terminal=false' \
+ 'Categories=Development;'
+ } > "$desktop_temporary"
+ chmod 644 "$desktop_temporary"
+ mv -f "$desktop_temporary" "$desktop"
+ DESKTOP_ENTRY="$desktop"
+ fi
+}
+
+install_node_runtime
+
+SOURCE_DIR="$VERSIONS_ROOT/$COMMIT"
+if [ -d "$SOURCE_DIR" ]; then
+ info "Using the existing source installation for commit $COMMIT."
else
- info "Dependencies already up to date — skipping npm install."
+ build_source_install "$SOURCE_DIR"
fi
-# --- check for Copilot CLI (bundled, desktop app, or PATH) -----------------
-copilot_available || warn "No Copilot CLI found. Install GitHub Copilot \
-(https://github.com/features/copilot) or ensure the bundled package installed \
-correctly. The app will launch, but recording analysis needs it."
-
-# --- build (only when the source or dependencies changed) ------------------
-build_stamp="$INSTALL_DIR/.skill-recorder-build.sha"
-build_now="${version_token}:${deps_now}"
-if [ ! -f dist-electron/main.js ] || [ ! -f dist/index.html ] \
- || [ "$(cat "$build_stamp" 2>/dev/null || true)" != "$build_now" ]; then
- info "Building app (npm run build)…"
- npm run build
- printf '%s\n' "$build_now" > "$build_stamp"
-else
- info "Build already up to date — skipping npm run build."
+validate_existing_install "$SOURCE_DIR"
+ELECTRON_EXECUTABLE="$(electron_executable "$SOURCE_DIR")"
+write_launcher "$SOURCE_DIR" "$ELECTRON_EXECUTABLE"
+
+info "Installed commit $COMMIT at $SOURCE_DIR."
+info "License materials remain in the source tree, dependency packages, and .compliance directory."
+info "Launcher: $LAUNCHER"
+if [ -n "${DESKTOP_ENTRY:-}" ]; then
+ info "Ubuntu desktop entry: $DESKTOP_ENTRY"
fi
+warn "This locally generated build is for local execution only. Do not redistribute it."
-info "Skill Recorder is installed in $INSTALL_DIR"
-info "Re-run the same command any time to update & launch, or: (cd \"$INSTALL_DIR\" && npm start)"
+rm -rf -- "$WORK_DIR"
+WORK_DIR=""
-# --- launch ----------------------------------------------------------------
-if [ -n "${SKILL_RECORDER_NO_RUN:-}" ]; then
- info "SKILL_RECORDER_NO_RUN set — not launching."
+if [ "$NO_LAUNCH" = "1" ]; then
+ info "SKILL_RECORDER_NO_LAUNCH=1; not launching."
exit 0
fi
-info "Launching Skill Recorder…"
-
-if [ -n "${SKILL_RECORDER_DETACHED:-}" ]; then
- # Detached: keep running after this terminal closes, and (since there's no
- # terminal to watch) capture output to a rolling, capped set of log files.
- log_dir="$INSTALL_DIR/logs"
- keep="${SKILL_RECORDER_LOG_KEEP:-5}"
- case "$keep" in ''|*[!0-9]*) keep=5 ;; esac
- [ "$keep" -lt 1 ] && keep=1
- mkdir -p "$log_dir"
- # Rotate by launch: keep the newest (keep-1) logs so that, once we add the
- # one below, at most $keep remain. `ls -t` lists newest first; `tail` selects
- # the ones past the cap for deletion.
- { ls -1t "$log_dir"/skill-recorder-*.log 2>/dev/null || true; } | tail -n +"$keep" | while IFS= read -r old; do
- rm -f "$old"
+if [ -n "$DETACHED" ]; then
+ case "$LOG_KEEP" in
+ ""|*[!0-9]*) LOG_KEEP=5 ;;
+ esac
+ [ "$LOG_KEEP" -ge 1 ] || LOG_KEEP=1
+ LOG_DIR="$INSTALL_ROOT/logs"
+ mkdir -p "$LOG_DIR"
+ {
+ ls -1t "$LOG_DIR"/skill-recorder-*.log 2>/dev/null || true
+ } | tail -n +"$LOG_KEEP" | while IFS= read -r old_log; do
+ rm -f -- "$old_log"
done
- log_file="$log_dir/skill-recorder-$(date +%Y%m%d-%H%M%S).log"
- # </dev/null + nohup + disown fully detach from the (possibly piped) terminal.
- nohup npm start </dev/null >"$log_file" 2>&1 &
- disown 2>/dev/null || true
- info "Running in the background (PID $!). It will keep running after this terminal closes."
- info "Logs: $log_file"
+ LOG_FILE="$LOG_DIR/skill-recorder-$(date +%Y%m%d-%H%M%S).log"
+ nohup "$LAUNCHER" </dev/null >"$LOG_FILE" 2>&1 &
+ info "Running in the background as process $!. Logs: $LOG_FILE"
exit 0
fi
-exec npm start
+info "Launching Skill Recorder."
+exec "$LAUNCHER"
diff --git a/package-lock.json b/package-lock.json
index daba9f9..13ca6cf 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -25,6 +25,7 @@
"@types/react": "^19.2.14",
"@types/react-dom": "^19.2.3",
"@vitejs/plugin-react": "^6.0.2",
+ "adm-zip": "^0.5.18",
"electron": "^43.0.0",
"electron-builder": "^26.15.6",
"typescript": "^7.0.0",
diff --git a/package.json b/package.json
index 1dc78c6..75f4fc0 100644
--- a/package.json
+++ b/package.json
@@ -2,7 +2,7 @@
"name": "skill-recorder",
"version": "0.1.0",
"description": "Records a user's on-screen work session and derives a structured description for building AI-agent skills.",
- "author": "Skill Recorder",
+ "author": "Skill Recorder contributors",
"repository": "github:adilei/skill-recorder",
"license": "MIT",
"private": true,
@@ -14,15 +14,18 @@
"build": "tsc --noEmit && vite build",
"typecheck": "tsc --noEmit",
"typecheck:evals": "tsc --noEmit -p evals/tsconfig.json",
- "test": "node --experimental-transform-types --no-warnings --import ./evals/register.mjs --test common/audio.test.ts common/microphone.test.ts common/narration.test.ts electron/recording-controls-bounds.test.ts electron/recording-privacy.test.ts electron/recorder/controller.test.ts electron/frames/extractor.test.ts electron/narration/audio-analysis.test.ts electron/narration/analyze-gate.test.ts electron/narration/transcribe.test.ts electron/narration/whisper.test.ts electron/sessions.test.ts electron/debug-bundle.test.ts",
+ "test": "node --experimental-transform-types --no-warnings --import ./evals/register.mjs --test common/audio.test.ts common/microphone.test.ts common/narration.test.ts electron/recording-controls-bounds.test.ts electron/recording-privacy.test.ts electron/recorder/controller.test.ts electron/frames/extractor.test.ts electron/narration/audio-analysis.test.ts electron/narration/analyze-gate.test.ts electron/narration/transcribe.test.ts electron/narration/whisper.test.ts electron/sessions.test.ts electron/debug-bundle.test.ts scripts/compliance.test.mjs",
"eval": "node --experimental-transform-types --no-warnings --import ./evals/register.mjs evals/run.ts",
"eval:builder": "node --experimental-transform-types --no-warnings --import ./evals/register.mjs evals/builder/run.ts",
"eval:skill": "node --experimental-transform-types --no-warnings --import ./evals/register.mjs evals/skillbuilder/run.ts",
- "dist": "node scripts/assert-generic-dist-platform.mjs && vite build && electron-builder --publish never",
- "dist:win:x64": "node scripts/assert-native-windows-arch.mjs x64 && vite build && electron-builder --publish never --win nsis --x64",
- "dist:win:arm64": "node scripts/assert-native-windows-arch.mjs arm64 && vite build && electron-builder --publish never --win nsis --arm64",
- "dist:portable:mac": "vite build && electron-builder --publish never --mac zip",
- "dist:portable:win": "node scripts/assert-native-windows-arch.mjs x64 && vite build && electron-builder --publish never --win portable --x64",
+ "compliance:licenses": "node scripts/prepare-compliance.mjs --licenses-only",
+ "compliance:prepare": "node scripts/prepare-compliance.mjs",
+ "compliance:test": "node --test scripts/compliance.test.mjs",
+ "dist": "npm run compliance:prepare && node scripts/assert-generic-dist-platform.mjs && vite build && electron-builder --publish never",
+ "dist:win:x64": "npm run compliance:prepare && node scripts/assert-native-windows-arch.mjs x64 && vite build && electron-builder --config.npmRebuild=false --publish never --win nsis --x64",
+ "dist:win:arm64": "npm run compliance:prepare && node scripts/assert-native-windows-arch.mjs arm64 && vite build && electron-builder --config.npmRebuild=false --publish never --win nsis --arm64",
+ "dist:portable:mac": "npm run compliance:prepare && vite build && electron-builder --publish never --mac zip",
+ "dist:portable:win": "npm run compliance:prepare && node scripts/assert-native-windows-arch.mjs x64 && vite build && electron-builder --config.npmRebuild=false --publish never --win portable --x64",
"start": "electron ."
},
"dependencies": {
@@ -45,6 +48,7 @@
"@types/react": "^19.2.14",
"@types/react-dom": "^19.2.3",
"@vitejs/plugin-react": "^6.0.2",
+ "adm-zip": "^0.5.18",
"electron": "^43.0.0",
"electron-builder": "^26.15.6",
"typescript": "^7.0.0",
@@ -54,6 +58,11 @@
"build": {
"appId": "com.skillrecorder.app",
"productName": "Skill Recorder",
+ "directories": {
+ "output": "release"
+ },
+ "electronDist": ".compliance-cache/electron",
+ "afterPack": "scripts/verify-packaged-compliance.mjs",
"files": [
"dist/**",
"dist-electron/**",
@@ -61,6 +70,12 @@
"LICENSE",
"THIRD-PARTY-NOTICES.md"
],
+ "extraResources": [
+ {
+ "from": ".compliance",
+ "to": "compliance"
+ }
+ ],
"asarUnpack": [
"node_modules/get-windows/**",
"node_modules/sharp/**",
@@ -79,16 +94,6 @@
],
"identity": "-",
"hardenedRuntime": false,
- "extraResources": [
- {
- "from": "node_modules/electron/dist/LICENSE",
- "to": "LICENSE.electron.txt"
- },
- {
- "from": "node_modules/electron/dist/LICENSES.chromium.html",
- "to": "LICENSES.chromium.html"
- }
- ],
"category": "public.app-category.developer-tools",
"extendInfo": {
"NSMicrophoneUsageDescription": "Skill Recorder uses your microphone only while you turn on Narrate during a recording, to transcribe your spoken narration on this computer."
@@ -107,6 +112,12 @@
"target": "nsis",
"artifactName": "${productName}-${version}-windows-${arch}.${ext}"
},
+ "linux": {
+ "target": [
+ "AppImage"
+ ],
+ "category": "Development"
+ },
"compression": "normal",
"nsis": {
"oneClick": false,
diff --git a/scripts/compliance.mjs b/scripts/compliance.mjs
new file mode 100644
index 0000000..c0f2e50
--- /dev/null
+++ b/scripts/compliance.mjs
@@ -0,0 +1,1503 @@
+import { execFile } from "node:child_process";
+import { createHash } from "node:crypto";
+import {
+ createReadStream,
+ createWriteStream,
+ existsSync,
+ readdirSync,
+ readFileSync,
+ statSync,
+} from "node:fs";
+import {
+ copyFile,
+ mkdir,
+ open,
+ readFile,
+ rename,
+ rm,
+ writeFile,
+} from "node:fs/promises";
+import { createRequire } from "node:module";
+import path from "node:path";
+import { pipeline } from "node:stream/promises";
+import { Readable } from "node:stream";
+import { promisify } from "node:util";
+import { fileURLToPath } from "node:url";
+
+const moduleDir = path.dirname(fileURLToPath(import.meta.url));
+const require = createRequire(import.meta.url);
+const AdmZip = require("adm-zip");
+const execFileAsync = promisify(execFile);
+export const deterministicGitConfigArgs = [
+ "-c",
+ "core.autocrlf=false",
+ "-c",
+ "core.eol=lf",
+ "-c",
+ "core.attributesFile=",
+ "-c",
+ "tar.umask=0002",
+];
+export const repositoryRoot = path.resolve(moduleDir, "..");
+export const complianceOutput = path.join(repositoryRoot, ".compliance");
+
+const policyPath = path.join(repositoryRoot, "third_party", "compliance-policy.json");
+const gccLicenseMirrorRevision = "7da4eb256f169fdc6bf3849b247d81f2e9404eb3";
+const gccLicenseMirror =
+ `https://raw.githubusercontent.com/gcc-mirror/gcc/${gccLicenseMirrorRevision}`;
+const mozillaLicenseRevision = "6efbc1d7604a22fae6ba145d1c3637f0bec7b1e6";
+const mozillaLicense =
+ `https://raw.githubusercontent.com/mozilla/grcov/${mozillaLicenseRevision}`;
+const licenseFilePattern =
+ /^(?:(?:licen[cs]e|copying|notice|copyright)(?:[-._].*)?|third[-_. ]?party[-_. ]?notices?(?:[-._].*)?)$/i;
+const requiredComplianceFiles = [
+ "COMPLIANCE-README.md",
+ "LICENSE",
+ "LICENSE-INVENTORY.json",
+ "NATIVE-COMPONENTS.json",
+ "NATIVE-THIRD-PARTY-NOTICES.md",
+ "RELINKING.md",
+ "REMOTE-MATERIALS.json",
+ "SOURCE-MANIFEST.json",
+ "THIRD-PARTY-LICENSES.txt",
+ "THIRD-PARTY-NOTICES.md",
+];
+
+export const legalTextSpecs = [
+ {
+ id: "gpl-3.0",
+ fileName: "GPL-3.0.txt",
+ url: `${gccLicenseMirror}/COPYING3`,
+ marker: "GNU GENERAL PUBLIC LICENSE",
+ },
+ {
+ id: "lgpl-2.1",
+ fileName: "LGPL-2.1.txt",
+ url: `${gccLicenseMirror}/COPYING.LIB`,
+ marker: "GNU LESSER GENERAL PUBLIC LICENSE",
+ },
+ {
+ id: "lgpl-3.0",
+ fileName: "LGPL-3.0.txt",
+ url: `${gccLicenseMirror}/COPYING3.LIB`,
+ marker: "GNU LESSER GENERAL PUBLIC LICENSE",
+ },
+ {
+ id: "mpl-2.0",
+ fileName: "MPL-2.0.txt",
+ url: `${mozillaLicense}/LICENSE-MPL-2.0`,
+ marker: "Mozilla Public License Version 2.0",
+ },
+];
+
+const sourceBuilders = {
+ aom: (version) => ({
+ fileName: `libaom-${version}.tar.gz`,
+ url: `https://storage.googleapis.com/aom-releases/libaom-${version}.tar.gz`,
+ }),
+ archive: (version) => ({
+ fileName: `libarchive-${version}.tar.xz`,
+ url: `https://github.com/libarchive/libarchive/releases/download/v${version}/libarchive-${version}.tar.xz`,
+ }),
+ cairo: (version) => ({
+ fileName: `cairo-${version}.tar.xz`,
+ url: `https://cairographics.org/releases/cairo-${version}.tar.xz`,
+ }),
+ cgif: (version) => ({
+ fileName: `cgif-${version}.tar.gz`,
+ url: `https://github.com/dloebl/cgif/archive/refs/tags/v${version}.tar.gz`,
+ }),
+ exif: (version) => ({
+ fileName: `libexif-${version}.tar.xz`,
+ url: `https://github.com/libexif/libexif/releases/download/v${version}/libexif-${version}.tar.xz`,
+ }),
+ expat: (version) => ({
+ fileName: `expat-${version}.tar.xz`,
+ url:
+ `https://github.com/libexpat/libexpat/releases/download/` +
+ `R_${version.replaceAll(".", "_")}/expat-${version}.tar.xz`,
+ }),
+ ffi: (version) => ({
+ fileName: `libffi-${version}.tar.gz`,
+ url: `https://github.com/libffi/libffi/releases/download/v${version}/libffi-${version}.tar.gz`,
+ }),
+ fontconfig: (version) => ({
+ fileName: `fontconfig-${version}.tar.gz`,
+ url: `https://codeload.github.com/fontconfig/fontconfig/tar.gz/refs/tags/${version}`,
+ }),
+ freetype: (version) => ({
+ fileName: `freetype-${version}.tar.gz`,
+ url:
+ "https://github.com/freetype/freetype/archive/refs/tags/" +
+ `VER-${version.replaceAll(".", "-")}.tar.gz`,
+ }),
+ fribidi: (version) => ({
+ fileName: `fribidi-${version}.tar.xz`,
+ url: `https://github.com/fribidi/fribidi/releases/download/v${version}/fribidi-${version}.tar.xz`,
+ }),
+ glib: (version) => ({
+ fileName: `glib-${version}.tar.xz`,
+ url:
+ `https://download.gnome.org/sources/glib/${withoutPatch(version)}/` +
+ `glib-${version}.tar.xz`,
+ }),
+ harfbuzz: (version) => ({
+ fileName: `harfbuzz-${version}.tar.gz`,
+ url: `https://github.com/harfbuzz/harfbuzz/archive/refs/tags/${version}.tar.gz`,
+ }),
+ heif: (version) => ({
+ fileName: `libheif-${version}.tar.gz`,
+ url: `https://github.com/strukturag/libheif/releases/download/v${version}/libheif-${version}.tar.gz`,
+ }),
+ highway: (version) => ({
+ fileName: `highway-${version}.tar.gz`,
+ url: `https://github.com/google/highway/archive/refs/tags/${version}.tar.gz`,
+ }),
+ imagequant: (version) => ({
+ fileName: `libimagequant-${version}.tar.gz`,
+ url: `https://github.com/lovell/libimagequant/archive/refs/tags/v${version}.tar.gz`,
+ }),
+ lcms: (version) => ({
+ fileName: `lcms2-${version}.tar.gz`,
+ url: `https://github.com/mm2/Little-CMS/releases/download/lcms${version}/lcms2-${version}.tar.gz`,
+ }),
+ mozjpeg: (version) => ({
+ fileName: `mozjpeg-${version}.tar.gz`,
+ url: `https://github.com/mozilla/mozjpeg/archive/${version}.tar.gz`,
+ }),
+ pango: (version) => ({
+ fileName: `pango-${version}.tar.xz`,
+ url:
+ `https://download.gnome.org/sources/pango/${withoutPatch(version)}/` +
+ `pango-${version}.tar.xz`,
+ }),
+ pixman: (version) => ({
+ fileName: `pixman-${version}.tar.gz`,
+ url: `https://cairographics.org/releases/pixman-${version}.tar.gz`,
+ }),
+ png: (version) => ({
+ fileName: `libpng-${version}.tar.gz`,
+ url: `https://github.com/pnggroup/libpng/archive/refs/tags/v${version}.tar.gz`,
+ }),
+ "proxy-libintl": (version) => ({
+ fileName: `proxy-libintl-${version}.tar.gz`,
+ url: `https://github.com/frida/proxy-libintl/archive/${version}.tar.gz`,
+ }),
+ rsvg: (version) => ({
+ fileName: `librsvg-${version}.tar.xz`,
+ url:
+ `https://download.gnome.org/sources/librsvg/${withoutPatch(version)}/` +
+ `librsvg-${version}.tar.xz`,
+ }),
+ spng: (version) => ({
+ fileName: `libspng-${version}.tar.gz`,
+ url: `https://github.com/randy408/libspng/archive/refs/tags/v${version}.tar.gz`,
+ }),
+ tiff: (version) => ({
+ fileName: `libtiff-${version}.tar.gz`,
+ url: `https://download.osgeo.org/libtiff/tiff-${version}.tar.gz`,
+ }),
+ vips: (version) => ({
+ fileName: `vips-${version}.tar.xz`,
+ url: `https://github.com/libvips/libvips/releases/download/v${version}/vips-${version}.tar.xz`,
+ }),
+ webp: (version) => ({
+ fileName: `libwebp-${version}.tar.gz`,
+ url:
+ "https://storage.googleapis.com/downloads.webmproject.org/releases/webp/" +
+ `libwebp-${version}.tar.gz`,
+ }),
+ xml2: (version) => ({
+ fileName: `libxml2-${version}.tar.xz`,
+ url:
+ `https://download.gnome.org/sources/libxml2/${withoutPatch(version)}/` +
+ `libxml2-${version}.tar.xz`,
+ }),
+ "zlib-ng": (version) => ({
+ fileName: `zlib-ng-${version}.tar.gz`,
+ url: `https://github.com/zlib-ng/zlib-ng/archive/refs/tags/${version}.tar.gz`,
+ }),
+};
+
+export function isLicenseFileName(name) {
+ return licenseFilePattern.test(name);
+}
+
+export async function hasExpectedFileHeader(fileName, file) {
+ const handle = await open(file, "r");
+ try {
+ const buffer = Buffer.alloc(512);
+ const { bytesRead } = await handle.read(buffer, 0, buffer.length, 0);
+ const header = buffer.subarray(0, bytesRead);
+ const lowerText = header.toString("utf8").trimStart().toLowerCase();
+ if (lowerText.startsWith("<!doctype html") || lowerText.startsWith("<html")) {
+ return false;
+ }
+ if (fileName.endsWith(".tar.gz") || fileName.endsWith(".tgz")) {
+ return header[0] === 0x1f && header[1] === 0x8b;
+ }
+ if (fileName.endsWith(".tar.xz")) {
+ return header.subarray(0, 6).equals(Buffer.from([0xfd, 0x37, 0x7a, 0x58, 0x5a, 0x00]));
+ }
+ if (fileName.endsWith(".tar")) {
+ return header.subarray(257, 262).toString("ascii") === "ustar";
+ }
+ if (fileName.endsWith(".zip")) {
+ return header[0] === 0x50 && header[1] === 0x4b;
+ }
+ return bytesRead >= 100;
+ } finally {
+ await handle.close();
+ }
+}
+
+export function onnxRefForVersion(version, policy) {
+ const configured = policy.onnxruntime?.[version];
+ if (configured) return configured;
+ throw new Error(
+ `ONNX Runtime ${version} has not been reviewed. Add its exact source ref to ` +
+ "third_party/compliance-policy.json.",
+ );
+}
+
+export function reviewedMaterialHash(id, hashes, kind) {
+ const hash = hashes?.[id];
+ if (/^[a-f0-9]{64}$/.test(hash ?? "")) return hash;
+ throw new Error(
+ `${kind} ${id} has no reviewed SHA-256. Add it to third_party/compliance-policy.json.`,
+ );
+}
+
+export function findPackageLicenseFiles(root) {
+ const matches = [];
+ function visit(directory, relativeDirectory = "") {
+ for (const entry of readdirSync(directory, { withFileTypes: true })) {
+ const relative = relativeDirectory
+ ? `${relativeDirectory}/${entry.name}`
+ : entry.name;
+ if (entry.isDirectory()) {
+ if (entry.name === "node_modules" || entry.name === ".git") continue;
+ visit(path.join(directory, entry.name), relative);
+ } else if (entry.isFile() && isLicenseFileName(entry.name)) {
+ matches.push(relative);
+ }
+ }
+ }
+ visit(root);
+ return matches.sort((a, b) => a.localeCompare(b));
+}
+
+export function buildNativeSourceSpecs(
+ versions,
+ {
+ platform,
+ sharpVersion,
+ sharpLibvipsVersion,
+ electronVersion,
+ ffmpegRevision,
+ },
+) {
+ const specs = [];
+ for (const [name, builder] of Object.entries(sourceBuilders)) {
+ const version = versions[name];
+ if (!version) throw new Error(`Sharp native payload does not identify a ${name} version.`);
+ specs.push({
+ id: `sharp-native-${name}`,
+ version,
+ reason: "Source and license material for the Sharp/libvips native payload.",
+ ...builder(version),
+ });
+ }
+
+ specs.push(
+ {
+ id: "sharp",
+ version: sharpVersion,
+ fileName: `sharp-${sharpVersion}.tar.gz`,
+ url: `https://github.com/lovell/sharp/archive/refs/tags/v${sharpVersion}.tar.gz`,
+ reason: "Source for the Sharp native Node.js binding.",
+ },
+ {
+ id: "sharp-libvips-build",
+ version: sharpLibvipsVersion,
+ fileName: `sharp-libvips-${sharpLibvipsVersion}.tar.gz`,
+ url:
+ "https://github.com/lovell/sharp-libvips/archive/refs/tags/" +
+ `v${sharpLibvipsVersion}.tar.gz`,
+ reason: "Build scripts and packaging instructions for the libvips payload.",
+ },
+ {
+ id: "electron",
+ version: electronVersion,
+ fileName: `electron-${electronVersion}.tar.gz`,
+ url:
+ "https://github.com/electron/electron/archive/refs/tags/" +
+ `v${electronVersion}.tar.gz`,
+ reason: "Electron source, including its FFmpeg patch queue and build integration.",
+ },
+ {
+ id: "electron-ffmpeg",
+ version: ffmpegRevision,
+ fileName: `electron-ffmpeg-${ffmpegRevision}.tar`,
+ url:
+ "https://chromium.googlesource.com/chromium/third_party/ffmpeg/+/" +
+ ffmpegRevision,
+ gitRepository:
+ "https://chromium.googlesource.com/chromium/third_party/ffmpeg",
+ gitRevision: ffmpegRevision,
+ archivePrefix: `electron-ffmpeg-${ffmpegRevision}/`,
+ reason: "Corresponding source for Electron's dynamically loaded LGPL FFmpeg library.",
+ },
+ {
+ id: "electron-ffmpeg-patch-link-with-loader-path",
+ version: electronVersion,
+ fileName: "electron-ffmpeg-link-with-loader-path.patch",
+ url:
+ "https://raw.githubusercontent.com/electron/electron/" +
+ `v${electronVersion}/patches/ffmpeg/link_with_loader_path.patch`,
+ reason: "Patch Electron applies to its pinned FFmpeg source.",
+ },
+ );
+
+ if (platform === "win32") {
+ specs.push({
+ id: "libvips-windows-build",
+ version: versions.vips,
+ fileName: `build-win64-mxe-${versions.vips}.tar.gz`,
+ url:
+ "https://github.com/libvips/build-win64-mxe/archive/refs/tags/" +
+ `v${versions.vips}.tar.gz`,
+ reason: "Windows build scripts and patches for the libvips payload.",
+ });
+ }
+
+ specs.push(
+ {
+ id: "sharp-patch-glib-without-gregex",
+ version: "bdad5489a61c217850631571caf57f5db6ea8b2c",
+ fileName: "glib-without-gregex.patch",
+ url:
+ "https://gist.github.com/kleisauke/284d685efa00908da99ea6afbaaf39ae/raw/" +
+ "bdad5489a61c217850631571caf57f5db6ea8b2c/glib-without-gregex.patch",
+ reason: "Patch applied by the Sharp/libvips build.",
+ },
+ {
+ id: "sharp-patch-aom",
+ version: "6d2b7f71b98bfa28e372b1f2d85f137280bdb3de",
+ fileName: "aom-mxe-nasm.patch",
+ url:
+ "https://github.com/m-ab-s/aom/commit/" +
+ "6d2b7f71b98bfa28e372b1f2d85f137280bdb3de.patch",
+ reason: "Patch applied by the Sharp/libvips build.",
+ },
+ {
+ id: "sharp-patch-highway",
+ version: "ad48f2bf298bac247288c8399a5c0e9a40ed8246",
+ fileName: "highway-gcc-sve.patch",
+ url:
+ "https://github.com/google/highway/commit/" +
+ "ad48f2bf298bac247288c8399a5c0e9a40ed8246.patch",
+ reason: "Patch applied by the Sharp/libvips build.",
+ },
+ {
+ id: "sharp-patch-libvips-soversion",
+ version: "3988223c7dfa4d22745d9392034b0117abef1446",
+ fileName: "libvips-cpp-soversion.patch",
+ url:
+ "https://gist.githubusercontent.com/lovell/313a6901e9db1bf285f2a1f1180499e4/raw/" +
+ "3988223c7dfa4d22745d9392034b0117abef1446/libvips-cpp-soversion.patch",
+ reason: "Patch applied by the Sharp/libvips build.",
+ },
+ {
+ id: "sharp-patch-libvips-heif",
+ version: versions.vips,
+ fileName: "libvips-heifsave-disable-hbr-support.patch",
+ url:
+ "https://raw.githubusercontent.com/libvips/build-win64-mxe/" +
+ `v${versions.vips}/build/patches/vips-8-heifsave-disable-hbr-support.patch`,
+ reason: "Patch applied by the Sharp/libvips build.",
+ },
+ );
+
+ return specs.sort((a, b) => a.id.localeCompare(b.id));
+}
+
+export async function prepareCompliance({
+ rootDir = repositoryRoot,
+ outputDir = complianceOutput,
+ includeSources = true,
+ fetchImpl = globalThis.fetch,
+} = {}) {
+ if (typeof fetchImpl !== "function") throw new Error("A Fetch API implementation is required.");
+
+ const policy = readJson(path.join(rootDir, "third_party", "compliance-policy.json"));
+ const lock = readJson(path.join(rootDir, "package-lock.json"));
+ const packages = collectProductionPackages(rootDir, lock);
+ validateReviewedVersions(packages, lock, policy);
+ await removeStalePartialFiles(path.join(rootDir, ".compliance-cache"));
+
+ await rm(outputDir, { recursive: true, force: true });
+ await mkdir(outputDir, { recursive: true });
+
+ await Promise.all([
+ copyFile(path.join(rootDir, "LICENSE"), path.join(outputDir, "LICENSE")),
+ copyFile(
+ path.join(rootDir, "THIRD-PARTY-NOTICES.md"),
+ path.join(outputDir, "THIRD-PARTY-NOTICES.md"),
+ ),
+ ]);
+
+ const inventory = buildLicenseInventory(rootDir, packages, policy);
+ await writeFile(
+ path.join(outputDir, "THIRD-PARTY-LICENSES.txt"),
+ renderLicenseInventory(inventory, lock, rootDir),
+ "utf8",
+ );
+ await writeJson(path.join(outputDir, "LICENSE-INVENTORY.json"), {
+ schemaVersion: 1,
+ platform: process.platform,
+ architecture: process.arch,
+ packageLockSha256: sha256FileSync(path.join(rootDir, "package-lock.json")),
+ packages: inventory.map(({ text: _text, ...entry }) => entry),
+ unresolved: [],
+ });
+
+ const native = collectNativeComponents(packages);
+ await writeFile(
+ path.join(outputDir, "NATIVE-THIRD-PARTY-NOTICES.md"),
+ native.notices,
+ "utf8",
+ );
+ await writeJson(path.join(outputDir, "NATIVE-COMPONENTS.json"), {
+ schemaVersion: 1,
+ platform: process.platform,
+ architecture: process.arch,
+ packages: native.packages,
+ versions: native.versions,
+ });
+
+ const remoteMaterials = await prepareRemoteMaterials({
+ outputDir,
+ rootDir,
+ packages,
+ policy,
+ fetchImpl,
+ });
+ await writeJson(path.join(outputDir, "REMOTE-MATERIALS.json"), {
+ schemaVersion: 1,
+ materials: remoteMaterials,
+ });
+
+ const sourceManifest = includeSources
+ ? await prepareSources({
+ outputDir,
+ rootDir,
+ policy,
+ nativeVersions: native.versions,
+ fetchImpl,
+ })
+ : { schemaVersion: 1, mode: "licenses-only", sources: [] };
+ await writeJson(path.join(outputDir, "SOURCE-MANIFEST.json"), sourceManifest);
+ if (includeSources) {
+ await prepareElectronNotices({ outputDir, rootDir, policy, fetchImpl });
+ }
+
+ await writeFile(
+ path.join(outputDir, "RELINKING.md"),
+ renderRelinking(native, sourceManifest, policy, process.platform),
+ "utf8",
+ );
+ await writeFile(
+ path.join(outputDir, "COMPLIANCE-README.md"),
+ renderComplianceReadme(includeSources),
+ "utf8",
+ );
+
+ await verifyComplianceDirectory(outputDir, {
+ requireSources: includeSources,
+ requireElectronNotices: includeSources,
+ });
+ return {
+ packageCount: inventory.length,
+ sourceCount: sourceManifest.sources.length,
+ outputDir,
+ };
+}
+
+export async function verifyComplianceDirectory(
+ directory,
+ {
+ requireSources = true,
+ requireElectronNotices = false,
+ requireRemoteMaterials = true,
+ } = {},
+) {
+ const policy = readJson(policyPath);
+ for (const file of requiredComplianceFiles) {
+ const target = path.join(directory, file);
+ if (!existsSync(target) || !statSync(target).isFile()) {
+ throw new Error(`Compliance bundle is missing ${file}.`);
+ }
+ }
+
+ const inventory = readJson(path.join(directory, "LICENSE-INVENTORY.json"));
+ if (!Array.isArray(inventory.packages) || inventory.packages.length === 0) {
+ throw new Error("Compliance license inventory is empty.");
+ }
+ if (!Array.isArray(inventory.unresolved) || inventory.unresolved.length !== 0) {
+ throw new Error(`Compliance inventory has unresolved licenses: ${inventory.unresolved}`);
+ }
+
+ const licenseText = await readFile(
+ path.join(directory, "THIRD-PARTY-LICENSES.txt"),
+ "utf8",
+ );
+ if (licenseText.length < 1_000) {
+ throw new Error("Generated third-party license text is unexpectedly short.");
+ }
+
+ const remote = readJson(path.join(directory, "REMOTE-MATERIALS.json"));
+ if (requireRemoteMaterials) {
+ assertExactManifestIds(
+ remote.materials,
+ Object.keys(policy.remoteMaterials),
+ "remote materials",
+ );
+ }
+ for (const material of remote.materials ?? []) {
+ if (
+ requireRemoteMaterials &&
+ material.sha256 !==
+ reviewedMaterialHash(material.id, policy.remoteMaterials, "Remote material")
+ ) {
+ throw new Error(`Remote material ${material.id} does not match its reviewed SHA-256.`);
+ }
+ await verifyManifestFile(directory, material);
+ }
+
+ const sources = readJson(path.join(directory, "SOURCE-MANIFEST.json"));
+ if (requireSources && sources.mode !== "full") {
+ throw new Error("Release compliance requires full corresponding sources.");
+ }
+ if (requireSources && (!Array.isArray(sources.sources) || sources.sources.length < 30)) {
+ throw new Error("Corresponding-source manifest is incomplete.");
+ }
+ if (requireSources) {
+ const native = readJson(path.join(directory, "NATIVE-COMPONENTS.json"));
+ const expectedSources = buildNativeSourceSpecs(native.versions, {
+ platform: native.platform,
+ sharpVersion: policy.sharp,
+ sharpLibvipsVersion: policy.sharpLibvips.version,
+ electronVersion: policy.electron.version,
+ ffmpegRevision: policy.electron.ffmpegRevision,
+ });
+ assertExactManifestIds(
+ sources.sources,
+ expectedSources.map(({ id }) => id),
+ "corresponding sources",
+ );
+ }
+ for (const source of sources.sources ?? []) {
+ if (
+ requireSources &&
+ source.sha256 !==
+ reviewedMaterialHash(source.id, policy.sourceMaterials, "Source material")
+ ) {
+ throw new Error(`Source material ${source.id} does not match its reviewed SHA-256.`);
+ }
+ await verifyManifestFile(directory, source);
+ }
+
+ if (requireElectronNotices) {
+ const electron = readJson(path.join(directory, "ELECTRON-NOTICES.json"));
+ const distributionKey = `${electron.platform}-${electron.architecture}`;
+ const expectedDistributionHash = reviewedMaterialHash(
+ distributionKey,
+ policy.electron?.distributions,
+ "Electron distribution",
+ );
+ if (
+ electron.version !== policy.electron?.version ||
+ electron.archive?.sha256 !== expectedDistributionHash
+ ) {
+ throw new Error("Electron notice archive does not match the reviewed distribution.");
+ }
+ for (const notice of electron.notices ?? []) {
+ const noticeName = path.posix.basename(notice.file);
+ if (notice.sha256 !== policy.electron?.notices?.[noticeName]) {
+ throw new Error(`Electron notice ${noticeName} does not match its reviewed SHA-256.`);
+ }
+ await verifyManifestFile(directory, notice);
+ }
+ if (electron.notices?.length !== 2) {
+ throw new Error("Packaged compliance bundle must contain both Electron notices.");
+ }
+ }
+
+ return {
+ packageCount: inventory.packages.length,
+ sourceCount: sources.sources?.length ?? 0,
+ };
+}
+
+async function verifyManifestFile(directory, entry) {
+ const normalizedFile =
+ typeof entry.file === "string" ? entry.file.replaceAll("\\", "/") : entry.file;
+ if (
+ typeof normalizedFile !== "string" ||
+ path.isAbsolute(normalizedFile) ||
+ normalizedFile.split("/").includes("..")
+ ) {
+ throw new Error(`Compliance manifest contains unsafe path ${entry.file}.`);
+ }
+ const target = path.join(directory, ...normalizedFile.split("/"));
+ if (!existsSync(target) || !statSync(target).isFile()) {
+ throw new Error(`Compliance material is missing ${entry.file}.`);
+ }
+ const actual = await sha256File(target);
+ if (actual !== entry.sha256) {
+ throw new Error(
+ `Compliance material ${entry.file} has SHA-256 ${actual}, expected ${entry.sha256}.`,
+ );
+ }
+}
+
+function assertExactManifestIds(entries, expectedIds, label) {
+ const actual = [...new Set((entries ?? []).map(({ id }) => id))].sort();
+ const expected = [...new Set(expectedIds)].sort();
+ if (
+ (entries?.length ?? 0) !== actual.length ||
+ JSON.stringify(actual) !== JSON.stringify(expected)
+ ) {
+ throw new Error(
+ `Compliance ${label} differ from policy; expected ${expected.join(", ")}, ` +
+ `found ${actual.join(", ")}.`,
+ );
+ }
+}
+
+function collectProductionPackages(rootDir, lock) {
+ const packages = [];
+ for (const [lockPath, lockEntry] of Object.entries(lock.packages ?? {})) {
+ if (!lockPath || lockEntry.dev) continue;
+ const directory = path.join(rootDir, ...lockPath.split("/"));
+ const packageJsonPath = path.join(directory, "package.json");
+ if (!existsSync(packageJsonPath)) continue;
+ const metadata = readJson(packageJsonPath);
+ packages.push({
+ directory,
+ lockPath,
+ metadata,
+ name: metadata.name,
+ version: metadata.version ?? lockEntry.version,
+ license: normalizeLicense(metadata.license ?? lockEntry.license),
+ });
+ }
+ return packages.sort(
+ (a, b) =>
+ a.name.localeCompare(b.name) ||
+ a.version.localeCompare(b.version) ||
+ a.lockPath.localeCompare(b.lockPath),
+ );
+}
+
+function validateReviewedVersions(packages, lock, policy) {
+ assertInstalledVersion(packages, "@github/copilot-sdk", policy.copilotSdk);
+ assertReviewedCopilotCliVersions(lock, policy.copilotCli);
+ assertInstalledVersion(packages, "sharp", policy.sharp);
+
+ const electronVersion = lock.packages?.["node_modules/electron"]?.version;
+ if (electronVersion !== policy.electron.version) {
+ throw new Error(
+ `Electron ${electronVersion} has not been reviewed; expected ${policy.electron.version}.`,
+ );
+ }
+
+ const sharpLibvipsVersions = new Set(
+ Object.entries(lock.packages ?? {})
+ .filter(([lockPath]) => lockPath.startsWith("node_modules/@img/sharp-libvips-"))
+ .map(([, entry]) => entry.version),
+ );
+ if (
+ sharpLibvipsVersions.size !== 1 ||
+ !sharpLibvipsVersions.has(policy.sharpLibvips.version)
+ ) {
+ throw new Error(
+ `Sharp/libvips package versions have not been reviewed: ${[
+ ...sharpLibvipsVersions,
+ ].join(", ")}.`,
+ );
+ }
+
+ for (const pkg of packages.filter(({ name }) => name.startsWith("onnxruntime-"))) {
+ onnxRefForVersion(pkg.version, policy);
+ }
+}
+
+export function assertReviewedCopilotCliVersions(lock, expected) {
+ const versions = new Set(
+ Object.entries(lock.packages ?? {})
+ .filter(
+ ([lockPath]) =>
+ lockPath === "node_modules/@github/copilot" ||
+ /^node_modules\/@github\/copilot-(?:darwin|linux|linuxmusl|win32)-/.test(
+ lockPath,
+ ),
+ )
+ .map(([, entry]) => entry.version),
+ );
+ if (versions.size !== 1 || !versions.has(expected)) {
+ throw new Error(
+ `GitHub Copilot CLI versions have not been reviewed: ${
+ [...versions].join(", ") || "(missing)"
+ }; expected ${expected}.`,
+ );
+ }
+}
+
+function assertInstalledVersion(packages, name, expected) {
+ const versions = new Set(packages.filter((pkg) => pkg.name === name).map((pkg) => pkg.version));
+ if (versions.size !== 1 || !versions.has(expected)) {
+ throw new Error(
+ `${name} versions have not been reviewed: ${[...versions].join(", ") || "(missing)"}; ` +
+ `expected ${expected}.`,
+ );
+ }
+}
+
+function buildLicenseInventory(rootDir, packages, policy) {
+ return packages.map((pkg) => {
+ const files = findPackageLicenseFiles(pkg.directory);
+
+ if (files.length > 0) {
+ return {
+ name: pkg.name,
+ version: pkg.version,
+ license: pkg.license,
+ packagePath: pkg.lockPath,
+ licenseSource: files.join(", "),
+ text: files
+ .map(
+ (file) =>
+ `----- ${file} -----\n${readFileSync(
+ path.join(pkg.directory, ...file.split("/")),
+ "utf8",
+ ).trim()}`,
+ )
+ .join("\n\n"),
+ };
+ }
+
+ if (pkg.name === "@koromix/koffi-win32-arm64" || pkg.name === "@koromix/koffi-win32-x64") {
+ const parent = path.join(rootDir, "node_modules", "koffi", "LICENSE.txt");
+ if (!existsSync(parent)) throw new Error(`${pkg.name} requires the parent Koffi license.`);
+ return {
+ name: pkg.name,
+ version: pkg.version,
+ license: pkg.license,
+ packagePath: pkg.lockPath,
+ licenseSource: "koffi/LICENSE.txt",
+ text: readFileSync(parent, "utf8").trim(),
+ };
+ }
+
+ if (pkg.name === "@github/copilot-sdk") {
+ if (pkg.version !== policy.copilotSdk) {
+ throw new Error(`No reviewed Copilot SDK license override exists for ${pkg.version}.`);
+ }
+ return overrideEntry(
+ pkg,
+ path.join(rootDir, "third_party", "package-licenses", "github-copilot-sdk-MIT.txt"),
+ );
+ }
+
+ if (pkg.name.startsWith("@img/sharp-libvips-")) {
+ return reviewedSharpLibvipsLicenseEntry(pkg, policy);
+ }
+
+ if (pkg.name.startsWith("onnxruntime-")) {
+ onnxRefForVersion(pkg.version, policy);
+ return overrideEntry(
+ pkg,
+ path.join(rootDir, "third_party", "package-licenses", "onnxruntime-MIT.txt"),
+ );
+ }
+
+ if (pkg.license === "MIT") {
+ return metadataLicenseEntry(pkg, renderMitFallback(pkg));
+ }
+ if (pkg.license === "ISC") {
+ return metadataLicenseEntry(pkg, renderIscFallback(pkg));
+ }
+
+ throw new Error(
+ `${pkg.name}@${pkg.version} declares ${pkg.license} but has no license file or reviewed override.`,
+ );
+ });
+}
+
+export function reviewedSharpLibvipsLicenseEntry(pkg, policy) {
+ if (pkg.version !== policy.sharpLibvips.version) {
+ throw new Error(`No reviewed Sharp/libvips license override exists for ${pkg.version}.`);
+ }
+ if (pkg.license !== "LGPL-3.0-or-later") {
+ throw new Error(
+ `${pkg.name}@${pkg.version} has unexpected license metadata: ${pkg.license}.`,
+ );
+ }
+ return {
+ name: pkg.name,
+ version: pkg.version,
+ license: pkg.license,
+ packagePath: pkg.lockPath,
+ licenseSource: "licenses/LGPL-3.0.txt",
+ text: [
+ "This platform package contains the libvips runtime under LGPL-3.0-or-later.",
+ "The complete canonical LGPL-3.0 text accompanies the generated compliance",
+ "bundle at licenses/LGPL-3.0.txt. Native dependency notices and corresponding",
+ "source are identified separately in the same bundle.",
+ ].join("\n"),
+ };
+}
+
+function overrideEntry(pkg, file) {
+ if (!existsSync(file)) throw new Error(`Missing reviewed license override ${file}.`);
+ return {
+ name: pkg.name,
+ version: pkg.version,
+ license: pkg.license,
+ packagePath: pkg.lockPath,
+ licenseSource: path.relative(repositoryRoot, file).replaceAll("\\", "/"),
+ text: readFileSync(file, "utf8").trim(),
+ };
+}
+
+function metadataLicenseEntry(pkg, text) {
+ return {
+ name: pkg.name,
+ version: pkg.version,
+ license: pkg.license,
+ packagePath: pkg.lockPath,
+ licenseSource: "package.json declaration plus canonical SPDX text",
+ text,
+ };
+}
+
+function renderLicenseInventory(inventory, lock, rootDir) {
+ const packageLockHash = sha256FileSync(path.join(rootDir, "package-lock.json"));
+ const blocks = inventory.map(
+ (entry) =>
+ [
+ "=".repeat(80),
+ `${entry.name}@${entry.version}`,
+ `Declared license: ${entry.license}`,
+ `Installed path: ${entry.packagePath}`,
+ `License material: ${entry.licenseSource}`,
+ "-".repeat(80),
+ entry.text,
+ ].join("\n"),
+ );
+ return [
+ "SKILL RECORDER THIRD-PARTY LICENSES",
+ "",
+ "These terms apply to the identified third-party components, not to Skill",
+ "Recorder's own MIT-licensed code.",
+ "",
+ `Platform: ${process.platform}-${process.arch}`,
+ `package-lock.json SHA-256: ${packageLockHash}`,
+ `Lockfile version: ${lock.lockfileVersion}`,
+ "",
+ ...blocks,
+ "",
+ ].join("\n");
+}
+
+function collectNativeComponents(packages) {
+ const candidates = packages.filter(
+ ({ name, directory }) =>
+ name.startsWith("@img/sharp-") && existsSync(path.join(directory, "versions.json")),
+ );
+ if (candidates.length === 0) {
+ throw new Error("No installed Sharp native package exposes versions.json.");
+ }
+
+ const versionSets = candidates.map((pkg) => ({
+ pkg,
+ versions: readJson(path.join(pkg.directory, "versions.json")),
+ }));
+ const canonical = JSON.stringify(versionSets[0].versions);
+ for (const item of versionSets.slice(1)) {
+ if (JSON.stringify(item.versions) !== canonical) {
+ throw new Error("Installed Sharp native packages disagree about embedded library versions.");
+ }
+ }
+
+ const notices = [];
+ for (const { pkg } of versionSets) {
+ const readme = path.join(pkg.directory, "README.md");
+ if (!existsSync(readme)) {
+ throw new Error(`${pkg.name}@${pkg.version} is missing its native licensing README.`);
+ }
+ const text = readFileSync(readme, "utf8").trim();
+ if (!text.includes("third-party libraries") || !text.includes("LGPL")) {
+ throw new Error(`${pkg.name}@${pkg.version} has an unexpected native licensing README.`);
+ }
+ if (!notices.includes(text)) notices.push(text);
+ }
+
+ return {
+ packages: versionSets.map(({ pkg }) => ({ name: pkg.name, version: pkg.version })),
+ versions: versionSets[0].versions,
+ notices: [
+ "# Native Third-Party Notices",
+ "",
+ "The following upstream notices describe libraries embedded in the Sharp/libvips",
+ "native payload. Full source archives and license files accompany this application",
+ "under `sources/`; canonical copyleft license texts are under `licenses/`.",
+ "",
+ ...notices,
+ "",
+ ].join("\n"),
+ };
+}
+
+async function prepareRemoteMaterials({
+ outputDir,
+ rootDir,
+ packages,
+ policy,
+ fetchImpl,
+}) {
+ const specs = legalTextSpecs.map((spec) => ({
+ ...spec,
+ outputPath: `licenses/${spec.fileName}`,
+ }));
+
+ const onnxVersions = [
+ ...new Set(
+ packages
+ .filter(({ name }) => name.startsWith("onnxruntime-"))
+ .map(({ version }) => version),
+ ),
+ ].sort();
+ for (const version of onnxVersions) {
+ const ref = onnxRefForVersion(version, policy);
+ const safeVersion = version.replaceAll(/[^A-Za-z0-9._-]/g, "_");
+ specs.push(
+ {
+ id: `onnxruntime-${version}-license`,
+ fileName: `onnxruntime-${safeVersion}-LICENSE.txt`,
+ outputPath: `onnxruntime/onnxruntime-${safeVersion}-LICENSE.txt`,
+ url: `https://raw.githubusercontent.com/microsoft/onnxruntime/${ref}/LICENSE`,
+ marker: "MIT License",
+ },
+ {
+ id: `onnxruntime-${version}-notices`,
+ fileName: `onnxruntime-${safeVersion}-ThirdPartyNotices.txt`,
+ outputPath: `onnxruntime/onnxruntime-${safeVersion}-ThirdPartyNotices.txt`,
+ url:
+ `https://raw.githubusercontent.com/microsoft/onnxruntime/${ref}/` +
+ "ThirdPartyNotices.txt",
+ marker: "THIRD PARTY SOFTWARE NOTICES AND INFORMATION",
+ },
+ );
+ }
+
+ return mapLimit(specs, 4, async (spec) => {
+ const target = path.join(outputDir, ...spec.outputPath.split("/"));
+ await mkdir(path.dirname(target), { recursive: true });
+ const cache = path.join(rootDir, ".compliance-cache", "remote", spec.fileName);
+ await obtainFile(
+ {
+ ...spec,
+ expectedSha256: reviewedMaterialHash(
+ spec.id,
+ policy.remoteMaterials,
+ "Remote material",
+ ),
+ },
+ cache,
+ target,
+ fetchImpl,
+ );
+ const content = await readFile(target, "utf8");
+ if (!content.includes(spec.marker)) {
+ throw new Error(`${spec.id} does not contain expected marker "${spec.marker}".`);
+ }
+ return {
+ id: spec.id,
+ url: spec.url,
+ file: spec.outputPath,
+ sha256: await sha256File(target),
+ };
+ });
+}
+
+async function prepareSources({
+ outputDir,
+ rootDir,
+ policy,
+ nativeVersions,
+ fetchImpl,
+}) {
+ const specs = buildNativeSourceSpecs(nativeVersions, {
+ platform: process.platform,
+ sharpVersion: policy.sharp,
+ sharpLibvipsVersion: policy.sharpLibvips.version,
+ electronVersion: policy.electron.version,
+ ffmpegRevision: policy.electron.ffmpegRevision,
+ });
+ const sources = await mapLimit(specs, 4, async (spec) => {
+ const relative = `sources/${spec.fileName}`;
+ const target = path.join(outputDir, "sources", spec.fileName);
+ await mkdir(path.dirname(target), { recursive: true });
+ const cache = path.join(rootDir, ".compliance-cache", "sources", spec.fileName);
+ const reviewedSpec = {
+ ...spec,
+ expectedSha256: reviewedMaterialHash(
+ spec.id,
+ policy.sourceMaterials,
+ "Source material",
+ ),
+ };
+ if (spec.gitRepository) {
+ await obtainGitArchive(reviewedSpec, cache, rootDir);
+ await copyFile(cache, target);
+ } else {
+ await obtainFile(reviewedSpec, cache, target, fetchImpl);
+ }
+ return {
+ id: spec.id,
+ version: spec.version,
+ reason: spec.reason,
+ url: spec.url,
+ retrieval: spec.gitRepository ? "git-archive" : "download",
+ file: relative,
+ sha256: await sha256File(target),
+ bytes: statSync(target).size,
+ };
+ });
+ return { schemaVersion: 1, mode: "full", sources };
+}
+
+async function prepareElectronNotices({ outputDir, rootDir, policy, fetchImpl }) {
+ const distributionKey = `${process.platform}-${process.arch}`;
+ const expectedSha256 = reviewedMaterialHash(
+ distributionKey,
+ policy.electron.distributions,
+ "Electron distribution",
+ );
+ const fileName =
+ `electron-v${policy.electron.version}-${process.platform}-${process.arch}.zip`;
+ const url =
+ `https://github.com/electron/electron/releases/download/v${policy.electron.version}/` +
+ fileName;
+ const cache = path.join(rootDir, ".compliance-cache", "electron", fileName);
+ await obtainCachedFile(
+ {
+ id: `electron-distribution-${distributionKey}`,
+ fileName,
+ url,
+ expectedSha256,
+ },
+ cache,
+ fetchImpl,
+ );
+
+ const archive = new AdmZip(cache);
+ const noticeDirectory = path.join(outputDir, "electron");
+ await mkdir(noticeDirectory, { recursive: true });
+ const notices = [];
+ for (const [sourceName, targetName] of [
+ ["LICENSE", "LICENSE.electron.txt"],
+ ["LICENSES.chromium.html", "LICENSES.chromium.html"],
+ ]) {
+ const entry = archive.getEntry(sourceName);
+ if (!entry || entry.isDirectory) {
+ throw new Error(`Electron distribution is missing ${sourceName}.`);
+ }
+ const content = entry.getData();
+ if (content.length < 100) {
+ throw new Error(`Electron distribution notice ${sourceName} is unexpectedly short.`);
+ }
+ const target = path.join(noticeDirectory, targetName);
+ await writeFile(target, content);
+ const sha256 = await sha256File(target);
+ if (sha256 !== policy.electron.notices?.[targetName]) {
+ throw new Error(
+ `Electron distribution notice ${targetName} has SHA-256 ${sha256}, ` +
+ `expected ${policy.electron.notices?.[targetName] ?? "(unreviewed)"}.`,
+ );
+ }
+ notices.push({
+ id: `electron-${targetName}`,
+ file: `electron/${targetName}`,
+ sha256,
+ });
+ }
+ await writeJson(path.join(outputDir, "ELECTRON-NOTICES.json"), {
+ schemaVersion: 1,
+ version: policy.electron.version,
+ platform: process.platform,
+ architecture: process.arch,
+ archive: { fileName, url, sha256: expectedSha256 },
+ notices,
+ });
+}
+
+async function obtainFile(spec, cache, target, fetchImpl) {
+ await obtainCachedFile(spec, cache, fetchImpl);
+ await copyFile(cache, target);
+ if (statSync(target).size < 100) {
+ throw new Error(`Downloaded compliance material ${spec.id} is unexpectedly short.`);
+ }
+}
+
+async function obtainGitArchive(spec, cache, rootDir) {
+ await mkdir(path.dirname(cache), { recursive: true });
+ const cacheIsValid =
+ existsSync(cache) &&
+ statSync(cache).size >= 100 &&
+ (await hasExpectedFileHeader(spec.fileName, cache)) &&
+ (await sha256File(cache)) === spec.expectedSha256;
+ if (cacheIsValid) return;
+
+ await rm(cache, { force: true });
+ const repository = path.join(rootDir, ".compliance-cache", "git", spec.id);
+ const temporary = `${cache}.partial`;
+ await rm(repository, { recursive: true, force: true });
+ await rm(temporary, { force: true });
+ await mkdir(repository, { recursive: true });
+
+ await runGit(["init", "--quiet"], repository);
+ await runGit(
+ [
+ "fetch",
+ "--depth=1",
+ "--no-tags",
+ "--quiet",
+ spec.gitRepository,
+ spec.gitRevision,
+ ],
+ repository,
+ );
+ const resolvedRevision = await runGit(["rev-parse", "FETCH_HEAD"], repository);
+ if (resolvedRevision !== spec.gitRevision) {
+ throw new Error(
+ `Fetched ${spec.id} revision ${resolvedRevision}; expected ${spec.gitRevision}.`,
+ );
+ }
+
+ await runGit(
+ [
+ ...deterministicGitConfigArgs,
+ "archive",
+ "--format=tar",
+ `--prefix=${spec.archivePrefix}`,
+ `--output=${temporary}`,
+ "FETCH_HEAD",
+ ],
+ repository,
+ );
+ if (!(await hasExpectedFileHeader(spec.fileName, temporary))) {
+ await rm(temporary, { force: true });
+ throw new Error(`Generated source material ${spec.id} is not a valid tar archive.`);
+ }
+ const actualHash = await sha256File(temporary);
+ if (actualHash !== spec.expectedSha256) {
+ await rm(temporary, { force: true });
+ throw new Error(
+ `Generated source material ${spec.id} has SHA-256 ${actualHash}; ` +
+ `expected reviewed hash ${spec.expectedSha256}.`,
+ );
+ }
+ await rename(temporary, cache);
+}
+
+async function runGit(args, cwd) {
+ try {
+ const { stdout } = await execFileAsync("git", args, {
+ cwd,
+ windowsHide: true,
+ maxBuffer: 10 * 1024 * 1024,
+ });
+ return stdout.trim();
+ } catch (error) {
+ const detail = error.stderr?.trim() || error.message;
+ throw new Error(`Git command failed while preparing compliance sources: ${detail}`, {
+ cause: error,
+ });
+ }
+}
+
+async function obtainCachedFile(spec, cache, fetchImpl) {
+ await mkdir(path.dirname(cache), { recursive: true });
+ const cacheIsValid =
+ existsSync(cache) &&
+ statSync(cache).size >= 100 &&
+ (await hasExpectedFileHeader(spec.fileName, cache)) &&
+ (await sha256File(cache)) === spec.expectedSha256;
+ if (!cacheIsValid) {
+ await rm(cache, { force: true });
+ await downloadWithRetry(spec.url, cache, fetchImpl);
+ }
+ if (!(await hasExpectedFileHeader(spec.fileName, cache))) {
+ await rm(cache, { force: true });
+ throw new Error(`Downloaded compliance material ${spec.id} has invalid file content.`);
+ }
+ const actualHash = await sha256File(cache);
+ if (actualHash !== spec.expectedSha256) {
+ await rm(cache, { force: true });
+ throw new Error(
+ `Downloaded compliance material ${spec.id} has SHA-256 ${actualHash}; ` +
+ `expected reviewed hash ${spec.expectedSha256}.`,
+ );
+ }
+}
+
+async function downloadWithRetry(url, target, fetchImpl) {
+ const temporary = `${target}.partial`;
+ let lastError;
+ for (let attempt = 1; attempt <= 3; attempt += 1) {
+ await rm(temporary, { force: true });
+ try {
+ const response = await fetchImpl(url, {
+ redirect: "follow",
+ headers: {
+ accept: "application/octet-stream, text/plain;q=0.9, */*;q=0.8",
+ "user-agent":
+ "Mozilla/5.0 (compatible; SkillRecorderCompliance/1.0; " +
+ "+https://github.com/adilei/skill-recorder)",
+ },
+ });
+ if (!response.ok || !response.body) {
+ throw new Error(`HTTP ${response.status} ${response.statusText}`);
+ }
+ await pipeline(Readable.fromWeb(response.body), createWriteStream(temporary));
+ if (statSync(temporary).size < 100) throw new Error("response was unexpectedly short");
+ await rename(temporary, target);
+ return;
+ } catch (error) {
+ lastError = error;
+ if (attempt < 3) {
+ await new Promise((resolve) => setTimeout(resolve, attempt * 1_000));
+ }
+ }
+ }
+ throw new Error(`Failed to download ${url} after three attempts.`, { cause: lastError });
+}
+
+export function renderRelinking(native, sourceManifest, policy, platform = process.platform) {
+ const { versions } = native;
+ const nativePackageList = native.packages.map(({ name }) => name).join(", ");
+ const sourceFile = (id) => {
+ const source = sourceManifest.sources.find((entry) => entry.id === id);
+ if (!source && sourceManifest.mode === "full") {
+ throw new Error(`Relinking guide requires source material ${id}.`);
+ }
+ return source?.file ?? `sources/[${id} omitted from licenses-only bundle]`;
+ };
+ const hasWindowsBuildSource = sourceManifest.sources.some(
+ ({ id }) => id === "libvips-windows-build",
+ );
+ const nativeLocation =
+ platform === "darwin"
+ ? "Contents/Resources/app.asar.unpacked/node_modules/"
+ : "resources/app.asar.unpacked/node_modules/";
+ const ffmpegLocation =
+ platform === "darwin"
+ ? "Contents/Frameworks/Electron Framework.framework/Versions/A/Libraries/libffmpeg.dylib"
+ : platform === "win32"
+ ? "ffmpeg.dll beside the Skill Recorder executable"
+ : "libffmpeg.so beside the Skill Recorder executable";
+ const sharpBuildSource = sourceFile("sharp-libvips-build");
+ const electronSource = sourceFile("electron");
+ const ffmpegSource = sourceFile("electron-ffmpeg");
+ const ffmpegPatch = sourceFile("electron-ffmpeg-patch-link-with-loader-path");
+ const windowsBuildSource =
+ platform === "win32" ? sourceFile("libvips-windows-build") : undefined;
+ return [
+ "# Replacing and relinking native libraries",
+ "",
+ "Skill Recorder's own source is available under the MIT License at",
+ "https://github.com/adilei/skill-recorder. The native libraries listed in",
+ "`NATIVE-COMPONENTS.json` remain under their own licenses.",
+ "",
+ "The packaged application keeps Sharp, libvips, and related native modules outside",
+ `the ASAR archive under \`${nativeLocation}\`. Installed native packages:`,
+ `\`${nativePackageList}\`. Electron's FFmpeg library is at \`${ffmpegLocation}\`.`,
+ "You may replace these",
+ "files with ABI-compatible modified builds and reverse engineer the application to",
+ "the extent needed to debug those modifications.",
+ "",
+ "Exact upstream sources, packaging scripts, and build patches are included under",
+ "`sources/`. `SOURCE-MANIFEST.json` records their original URLs and SHA-256 hashes.",
+ hasWindowsBuildSource
+ ? `Use \`${sharpBuildSource}\` and \`${windowsBuildSource}\` to rebuild the libvips`
+ : `Use \`${sharpBuildSource}\` to rebuild the libvips`,
+ "payload, then replace the matching unpacked native libraries in an installed copy.",
+ "",
+ `For Electron FFmpeg, start from \`${ffmpegSource}\`, apply \`${ffmpegPatch}\`,`,
+ `and use the Electron build integration in \`${electronSource}\`. Replace the`,
+ `resulting ABI-compatible library at \`${ffmpegLocation}\`.`,
+ "",
+ "Important pinned versions:",
+ "",
+ `- Electron: ${policy.electron.version}`,
+ `- Electron FFmpeg revision: ${policy.electron.ffmpegRevision}`,
+ `- Sharp: ${policy.sharp}`,
+ `- Sharp/libvips packaging: ${policy.sharpLibvips.version}`,
+ `- libvips: ${versions.vips}`,
+ `- GLib: ${versions.glib}`,
+ `- Cairo: ${versions.cairo}`,
+ "",
+ sourceManifest.mode === "full"
+ ? "This distribution includes the corresponding-source materials."
+ : "This licenses-only bundle is not suitable for redistribution.",
+ "",
+ ].join("\n");
+}
+
+function renderComplianceReadme(includeSources) {
+ return [
+ "# License and source materials",
+ "",
+ "Keep this entire directory with every distributed copy of Skill Recorder.",
+ "",
+ "- `THIRD-PARTY-LICENSES.txt` contains per-package license and attribution text.",
+ "- `NATIVE-THIRD-PARTY-NOTICES.md` identifies libraries embedded in native payloads.",
+ "- `onnxruntime/` contains exact ONNX Runtime third-party notices.",
+ includeSources
+ ? "- `electron/` contains the exact Electron and Chromium notices from this build."
+ : "- Electron notices are added when a redistributable build is prepared.",
+ "- `licenses/` contains the complete GPL, LGPL, and MPL license texts.",
+ "- `RELINKING.md` explains replacement and relinking of native libraries.",
+ "- `SOURCE-MANIFEST.json` maps corresponding-source archives to their origins.",
+ "",
+ includeSources
+ ? "The `sources/` directory accompanies this redistributable build."
+ : "This development bundle omits sources and must not be redistributed.",
+ "",
+ ].join("\n");
+}
+
+function renderMitFallback(pkg) {
+ const owner = packageAuthor(pkg.metadata);
+ return [
+ `Available attribution from package metadata: ${owner}`,
+ "",
+ "MIT License",
+ "",
+ `Copyright (c) ${owner}`,
+ "",
+ "Permission is hereby granted, free of charge, to any person obtaining a copy",
+ 'of this software and associated documentation files (the "Software"), to deal',
+ "in the Software without restriction, including without limitation the rights",
+ "to use, copy, modify, merge, publish, distribute, sublicense, and/or sell",
+ "copies of the Software, and to permit persons to whom the Software is",
+ "furnished to do so, subject to the following conditions:",
+ "",
+ "The above copyright notice and this permission notice shall be included in all",
+ "copies or substantial portions of the Software.",
+ "",
+ 'THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR',
+ "IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,",
+ "FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE",
+ "AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER",
+ "LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,",
+ "OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE",
+ "SOFTWARE.",
+ ].join("\n");
+}
+
+function renderIscFallback(pkg) {
+ const owner = packageAuthor(pkg.metadata);
+ return [
+ `Available attribution from package metadata: ${owner}`,
+ "",
+ `Copyright (c) ${owner}`,
+ "",
+ "Permission to use, copy, modify, and/or distribute this software for any",
+ "purpose with or without fee is hereby granted, provided that the above",
+ "copyright notice and this permission notice appear in all copies.",
+ "",
+ 'THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH',
+ "REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY",
+ "AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,",
+ "INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM",
+ "LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR",
+ "OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR",
+ "PERFORMANCE OF THIS SOFTWARE.",
+ ].join("\n");
+}
+
+function packageAuthor(metadata) {
+ if (typeof metadata.author === "string" && metadata.author.trim()) {
+ return metadata.author.trim();
+ }
+ if (metadata.author?.name) return metadata.author.name;
+ if (metadata.maintainers?.length) {
+ return metadata.maintainers
+ .map((maintainer) => maintainer.name ?? maintainer.email)
+ .filter(Boolean)
+ .join(", ");
+ }
+ throw new Error(`${metadata.name}@${metadata.version} has no attribution metadata.`);
+}
+
+function normalizeLicense(license) {
+ if (typeof license === "string") return license;
+ if (license?.type) return license.type;
+ if (Array.isArray(license)) return license.map(normalizeLicense).join(" OR ");
+ return "(missing)";
+}
+
+function withoutPatch(version) {
+ return version.split(".").slice(0, -1).join(".");
+}
+
+function readJson(file) {
+ return JSON.parse(readFileSync(file, "utf8"));
+}
+
+async function writeJson(file, value) {
+ await writeFile(file, `${JSON.stringify(value, null, 2)}\n`, "utf8");
+}
+
+function sha256FileSync(file) {
+ const hash = createHash("sha256");
+ hash.update(readFileSync(file));
+ return hash.digest("hex");
+}
+
+export async function sha256File(file) {
+ const hash = createHash("sha256");
+ for await (const chunk of createReadStream(file)) hash.update(chunk);
+ return hash.digest("hex");
+}
+
+async function mapLimit(items, limit, worker) {
+ const results = new Array(items.length);
+ let next = 0;
+ async function run() {
+ while (next < items.length) {
+ const index = next;
+ next += 1;
+ results[index] = await worker(items[index], index);
+ }
+ }
+ await Promise.all(Array.from({ length: Math.min(limit, items.length) }, run));
+ return results;
+}
+
+async function removeStalePartialFiles(directory) {
+ if (!existsSync(directory)) return;
+ for (const entry of readdirSync(directory, { withFileTypes: true })) {
+ const target = path.join(directory, entry.name);
+ if (entry.isDirectory()) {
+ await removeStalePartialFiles(target);
+ } else if (entry.isFile() && entry.name.endsWith(".partial")) {
+ await rm(target, { force: true });
+ }
+ }
+}
diff --git a/scripts/compliance.test.mjs b/scripts/compliance.test.mjs
new file mode 100644
index 0000000..d702cc5
--- /dev/null
+++ b/scripts/compliance.test.mjs
@@ -0,0 +1,390 @@
+import assert from "node:assert/strict";
+import { mkdir, mkdtemp, rm, writeFile } from "node:fs/promises";
+import { readFile } from "node:fs/promises";
+import { tmpdir } from "node:os";
+import path from "node:path";
+import test from "node:test";
+import { fileURLToPath } from "node:url";
+
+import {
+ assertReviewedCopilotCliVersions,
+ buildNativeSourceSpecs,
+ deterministicGitConfigArgs,
+ findPackageLicenseFiles,
+ hasExpectedFileHeader,
+ isLicenseFileName,
+ legalTextSpecs,
+ onnxRefForVersion,
+ reviewedSharpLibvipsLicenseEntry,
+ reviewedMaterialHash,
+ renderRelinking,
+ verifyComplianceDirectory,
+} from "./compliance.mjs";
+
+const nativeVersions = {
+ aom: "3.13.1",
+ archive: "3.8.2",
+ cairo: "1.18.4",
+ cgif: "0.5.0",
+ exif: "0.6.25",
+ expat: "2.7.3",
+ ffi: "3.5.2",
+ fontconfig: "2.17.1",
+ freetype: "2.14.1",
+ fribidi: "1.0.16",
+ glib: "2.86.1",
+ harfbuzz: "12.1.0",
+ heif: "1.20.2",
+ highway: "1.3.0",
+ imagequant: "2.4.1",
+ lcms: "2.17",
+ mozjpeg: "0826579",
+ pango: "1.57.0",
+ pixman: "0.46.4",
+ png: "1.6.50",
+ "proxy-libintl": "0.5",
+ rsvg: "2.61.2",
+ spng: "0.7.4",
+ tiff: "4.7.1",
+ vips: "8.17.3",
+ webp: "1.6.0",
+ xml2: "2.15.1",
+ "zlib-ng": "2.2.5",
+};
+
+const repoRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "..");
+
+test("license filenames include common suffixed forms", () => {
+ assert.equal(isLicenseFileName("LICENSE"), true);
+ assert.equal(isLicenseFileName("LICENSE-MIT.txt"), true);
+ assert.equal(isLicenseFileName("NOTICE.md"), true);
+ assert.equal(isLicenseFileName("thirdpartynotices.txt"), true);
+ assert.equal(isLicenseFileName("README.md"), false);
+});
+
+test("canonical legal texts use immutable reviewed sources", () => {
+ for (const spec of legalTextSpecs) {
+ assert.match(
+ spec.url,
+ /^https:\/\/raw\.githubusercontent\.com\/[^/]+\/[^/]+\/[0-9a-f]{40}\//,
+ `${spec.id} must use an immutable source revision`,
+ );
+ }
+});
+
+test("nested package legal files are discovered", async () => {
+ const root = await mkdtemp(path.join(tmpdir(), "skill-recorder-licenses-"));
+ try {
+ await mkdir(path.join(root, "google"), { recursive: true });
+ await mkdir(path.join(root, "vendor", "node-api"), { recursive: true });
+ await writeFile(path.join(root, "LICENSE"), "root license");
+ await writeFile(path.join(root, "google", "LICENSE"), "vendored license");
+ await writeFile(
+ path.join(root, "vendor", "node-api", "thirdpartynotices.txt"),
+ "vendored notices",
+ );
+ assert.deepEqual(findPackageLicenseFiles(root), [
+ "google/LICENSE",
+ "LICENSE",
+ "vendor/node-api/thirdpartynotices.txt",
+ ]);
+ } finally {
+ await rm(root, { recursive: true, force: true });
+ }
+});
+
+test("native source manifest covers dependencies, build scripts, and patches", () => {
+ const sources = buildNativeSourceSpecs(nativeVersions, {
+ platform: "win32",
+ sharpVersion: "0.34.5",
+ sharpLibvipsVersion: "1.2.4",
+ electronVersion: "43.1.1",
+ ffmpegRevision: "ad41607c61898cf7150e0fb20fe4bbabd44922a3",
+ });
+
+ const ids = new Set(sources.map(({ id }) => id));
+ for (const dependency of Object.keys(nativeVersions)) {
+ assert(ids.has(`sharp-native-${dependency}`), `missing ${dependency}`);
+ }
+ for (const required of [
+ "sharp",
+ "sharp-libvips-build",
+ "libvips-windows-build",
+ "electron-ffmpeg",
+ "electron",
+ "electron-ffmpeg-patch-link-with-loader-path",
+ "sharp-patch-glib-without-gregex",
+ ]) {
+ assert(ids.has(required), `missing ${required}`);
+ }
+ const ffmpeg = sources.find(({ id }) => id === "electron-ffmpeg");
+ assert.equal(
+ ffmpeg.fileName,
+ "electron-ffmpeg-ad41607c61898cf7150e0fb20fe4bbabd44922a3.tar",
+ );
+ assert.equal(
+ ffmpeg.gitRepository,
+ "https://chromium.googlesource.com/chromium/third_party/ffmpeg",
+ );
+ assert.doesNotMatch(ffmpeg.url, /\+archive/);
+});
+
+test("git archives ignore host line-ending and global attribute settings", () => {
+ assert.deepEqual(deterministicGitConfigArgs, [
+ "-c",
+ "core.autocrlf=false",
+ "-c",
+ "core.eol=lf",
+ "-c",
+ "core.attributesFile=",
+ "-c",
+ "tar.umask=0002",
+ ]);
+});
+
+test("unreviewed ONNX versions fail closed", () => {
+ const policy = { onnxruntime: { "1.24.3": "v1.24.3" } };
+ assert.equal(onnxRefForVersion("1.24.3", policy), "v1.24.3");
+ assert.throws(
+ () => onnxRefForVersion("1.24.4", policy),
+ /has not been reviewed/,
+ );
+});
+
+test("unreviewed GitHub Copilot CLI versions fail closed", () => {
+ const reviewedLock = {
+ packages: {
+ "node_modules/@github/copilot": { version: "1.0.71" },
+ "node_modules/@github/copilot-win32-x64": { version: "1.0.71" },
+ },
+ };
+ assert.doesNotThrow(() =>
+ assertReviewedCopilotCliVersions(reviewedLock, "1.0.71"),
+ );
+
+ const changedLock = structuredClone(reviewedLock);
+ changedLock.packages["node_modules/@github/copilot-win32-x64"].version = "1.0.72";
+ assert.throws(
+ () => assertReviewedCopilotCliVersions(changedLock, "1.0.71"),
+ /have not been reviewed/,
+ );
+});
+
+test("platform Sharp/libvips packages use the reviewed LGPL text", () => {
+ const pkg = {
+ name: "@img/sharp-libvips-linux-x64",
+ version: "1.2.4",
+ license: "LGPL-3.0-or-later",
+ lockPath: "node_modules/@img/sharp-libvips-linux-x64",
+ };
+ const entry = reviewedSharpLibvipsLicenseEntry(pkg, {
+ sharpLibvips: { version: "1.2.4" },
+ });
+ assert.equal(entry.licenseSource, "licenses/LGPL-3.0.txt");
+ assert.throws(
+ () =>
+ reviewedSharpLibvipsLicenseEntry(
+ { ...pkg, version: "1.2.5" },
+ { sharpLibvips: { version: "1.2.4" } },
+ ),
+ /No reviewed Sharp\/libvips license override/,
+ );
+ assert.throws(
+ () =>
+ reviewedSharpLibvipsLicenseEntry(
+ { ...pkg, license: "UNKNOWN" },
+ { sharpLibvips: { version: "1.2.4" } },
+ ),
+ /unexpected license metadata/,
+ );
+});
+
+test("unreviewed source hashes fail closed", () => {
+ assert.equal(
+ reviewedMaterialHash("source", { source: "a".repeat(64) }, "Source material"),
+ "a".repeat(64),
+ );
+ assert.throws(
+ () => reviewedMaterialHash("missing", {}, "Source material"),
+ /has no reviewed SHA-256/,
+ );
+});
+
+test("relinking instructions use platform-specific native paths", () => {
+ const sources = [
+ "sharp-libvips-build",
+ "electron",
+ "electron-ffmpeg",
+ "electron-ffmpeg-patch-link-with-loader-path",
+ ].map((id) => ({ id, file: `sources/${id}.tar.gz` }));
+ const native = {
+ packages: [{ name: "@img/sharp-libvips-darwin-arm64" }],
+ versions: { vips: "8.17.3", glib: "2.86.1", cairo: "1.18.4" },
+ };
+ const policy = {
+ electron: { version: "43.1.1", ffmpegRevision: "abc" },
+ sharp: "0.34.5",
+ sharpLibvips: { version: "1.2.4" },
+ };
+ const mac = renderRelinking(native, { mode: "full", sources }, policy, "darwin");
+ assert.match(
+ mac,
+ /Contents\/Frameworks\/Electron Framework\.framework\/Versions\/A\/Libraries\/libffmpeg\.dylib/,
+ );
+ assert.doesNotMatch(mac, /build-win64-mxe/);
+
+ const linux = renderRelinking(native, { mode: "full", sources }, policy, "linux");
+ assert.match(linux, /libffmpeg\.so beside the Skill Recorder executable/);
+});
+
+test("archive validation rejects HTML challenge pages", async () => {
+ const root = await mkdtemp(path.join(tmpdir(), "skill-recorder-archive-"));
+ try {
+ const challenge = path.join(root, "source.tar.gz");
+ await writeFile(challenge, `<!doctype html>${"x".repeat(200)}`);
+ assert.equal(await hasExpectedFileHeader("source.tar.gz", challenge), false);
+
+ const gzip = path.join(root, "valid.tar.gz");
+ await writeFile(gzip, Buffer.concat([Buffer.from([0x1f, 0x8b]), Buffer.alloc(200)]));
+ assert.equal(await hasExpectedFileHeader("valid.tar.gz", gzip), true);
+
+ const tar = path.join(root, "valid.tar");
+ const tarHeader = Buffer.alloc(512);
+ tarHeader.write("ustar", 257, "ascii");
+ await writeFile(tar, tarHeader);
+ assert.equal(await hasExpectedFileHeader("valid.tar", tar), true);
+ } finally {
+ await rm(root, { recursive: true, force: true });
+ }
+});
+
+test("licenses-only bundles cannot pass release verification", async () => {
+ const root = await mkdtemp(path.join(tmpdir(), "skill-recorder-compliance-"));
+ try {
+ const files = [
+ "COMPLIANCE-README.md",
+ "LICENSE",
+ "NATIVE-COMPONENTS.json",
+ "NATIVE-THIRD-PARTY-NOTICES.md",
+ "RELINKING.md",
+ "THIRD-PARTY-NOTICES.md",
+ ];
+ await Promise.all(files.map((file) => writeFile(path.join(root, file), `${file}\n`)));
+ await writeFile(path.join(root, "THIRD-PARTY-LICENSES.txt"), "x".repeat(1_100));
+ await writeFile(
+ path.join(root, "LICENSE-INVENTORY.json"),
+ JSON.stringify({ packages: [{ name: "example" }], unresolved: [] }),
+ );
+ await writeFile(
+ path.join(root, "REMOTE-MATERIALS.json"),
+ JSON.stringify({ materials: [] }),
+ );
+ await writeFile(
+ path.join(root, "SOURCE-MANIFEST.json"),
+ JSON.stringify({ mode: "licenses-only", sources: [] }),
+ );
+
+ await verifyComplianceDirectory(root, {
+ requireSources: false,
+ requireRemoteMaterials: false,
+ });
+ await assert.rejects(
+ verifyComplianceDirectory(root, {
+ requireSources: true,
+ requireRemoteMaterials: false,
+ }),
+ /requires full corresponding sources/,
+ );
+ } finally {
+ await rm(root, { recursive: true, force: true });
+ }
+});
+
+test("source and release instructions remain compliance-preserving", async () => {
+ const [windowsInstaller, unixInstaller, instructions, readme, releasing] =
+ await Promise.all([
+ readFile(path.join(repoRoot, "install.ps1"), "utf8"),
+ readFile(path.join(repoRoot, "install.sh"), "utf8"),
+ readFile(path.join(repoRoot, "INSTALL.md"), "utf8"),
+ readFile(path.join(repoRoot, "README.md"), "utf8"),
+ readFile(path.join(repoRoot, "RELEASING.md"), "utf8"),
+ ]);
+
+ assert.match(windowsInstaller, /\^\[0-9a-fA-F\]\{40\}\$/);
+ assert.match(
+ windowsInstaller,
+ /https:\/\/codeload\.github\.com\/adilei\/skill-recorder\/zip\/\$Commit/,
+ );
+ assert.match(windowsInstaller, /https:\/\/nodejs\.org\/dist\/index\.json/);
+ assert.match(windowsInstaller, /NPM_CONFIG_REGISTRY = "https:\/\/registry\.npmjs\.org\/"/);
+ assert.match(
+ windowsInstaller,
+ /ELECTRON_MIRROR = "https:\/\/github\.com\/electron\/electron\/releases\/download\/"/,
+ );
+ assert.match(windowsInstaller, /SHASUMS256\.txt/);
+ assert.match(windowsInstaller, /Get-AuthenticodeSignature/);
+ assert.match(windowsInstaller, /OpenJS Foundation/);
+ assert.match(windowsInstaller, /GitHub, Inc\\\./);
+ assert.match(windowsInstaller, /@github\\copilot\\LICENSE\.md/);
+ assert.match(windowsInstaller, /@github\\copilot-win32-\$architecture/);
+ assert.match(windowsInstaller, /node_modules\\electron\\dist\\LICENSES\.chromium\.html/);
+ assert.match(windowsInstaller, /third_party\\compliance-policy\.json/);
+ assert.match(windowsInstaller, /Assert-ReviewedElectronDistribution/);
+ assert.match(windowsInstaller, /\$versionOutput = @\(& \$nodeExe --version\)/);
+ assert.doesNotMatch(
+ windowsInstaller,
+ /\(& \$nodeExe [^\r\n]+\| Select-Object -First 1\)/,
+ );
+ assert.match(windowsInstaller, /@?\("ci", "--no-audit", "--no-fund"\)/);
+ assert.match(windowsInstaller, /@?\("node_modules\\electron\\install\.js"\)/);
+ assert.match(windowsInstaller, /@?\("run", "compliance:licenses"\)/);
+ assert.match(windowsInstaller, /@?\("run", "build"\)/);
+ assert.doesNotMatch(
+ windowsInstaller,
+ /github\.com\/adilei\/skill-recorder\/releases\/download/i,
+ );
+ assert.doesNotMatch(windowsInstaller, /\/(?:master|main)\/install\.ps1/i);
+
+ assert.match(unixInstaller, /\^\[0-9a-fA-F\]\{40\}\$/);
+ assert.match(
+ unixInstaller,
+ /https:\/\/codeload\.github\.com\/adilei\/skill-recorder\/tar\.gz\/\$COMMIT/,
+ );
+ assert.match(unixInstaller, /https:\/\/nodejs\.org\/dist\/latest-v24\.x/);
+ assert.match(unixInstaller, /NPM_CONFIG_REGISTRY="https:\/\/registry\.npmjs\.org\/"/);
+ assert.match(
+ unixInstaller,
+ /ELECTRON_MIRROR="https:\/\/github\.com\/electron\/electron\/releases\/download\/"/,
+ );
+ assert.match(unixInstaller, /SHASUMS256\.txt/);
+ assert.match(unixInstaller, /"\$NPM" ci --no-audit --no-fund/);
+ assert.match(unixInstaller, /"\$NODE" "node_modules\/electron\/install\.js"/);
+ assert.match(unixInstaller, /"\$NPM" run compliance:licenses/);
+ assert.match(unixInstaller, /"\$NPM" run build/);
+ assert.match(unixInstaller, /\.compliance\/licenses\/LGPL-3\.0\.txt/);
+ assert.match(unixInstaller, /@github\/copilot-\$\{PLATFORM\}-\$\{ARCHITECTURE\}/);
+ assert.doesNotMatch(
+ unixInstaller,
+ /github\.com\/adilei\/skill-recorder\/releases\/download/i,
+ );
+ assert.doesNotMatch(unixInstaller, /\/(?:master|main)\/install\.sh/i);
+
+ assert.match(instructions, /generated build is for local execution only/i);
+ assert.match(instructions, /npm ci/);
+ assert.match(instructions, /full 40-character commit SHA/i);
+ assert.match(instructions, /macOS/);
+ assert.match(instructions, /Ubuntu/);
+ assert.match(instructions, /complete generated\s+compliance bundle/i);
+ assert.doesNotMatch(instructions, /raw\.githubusercontent\.com\/[^ \n]+\/(?:master|main)\//i);
+ assert.match(readme, /\[`INSTALL\.md`\]\(INSTALL\.md\)/);
+ assert.match(readme, /\[`RELEASING\.md`\]\(RELEASING\.md\)/);
+ assert.doesNotMatch(readme, /raw\.githubusercontent\.com\/[^ \n]+\/(?:master|main)\//i);
+ assert.match(releasing, /source-only releases.*are the default/i);
+ assert.match(releasing, /npm version 0\.2\.0 --no-git-tag-version/);
+ assert.match(releasing, /full release commit SHA/i);
+ assert.match(releasing, /git",\["cat-file","blob"/);
+ assert.match(releasing, /not working-tree\s+files/i);
+ assert.match(releasing, /SHA-256 values for `install\.ps1` and `install\.sh`/i);
+ assert.match(releasing, /complete, version-matched\s+compliance bundle/i);
+ assert.match(releasing, /Never silently replace an asset or move a release tag/i);
+});
diff --git a/scripts/prepare-compliance.mjs b/scripts/prepare-compliance.mjs
new file mode 100644
index 0000000..6ddfef5
--- /dev/null
+++ b/scripts/prepare-compliance.mjs
@@ -0,0 +1,9 @@
+import { prepareCompliance } from "./compliance.mjs";
+
+const licensesOnly = process.argv.includes("--licenses-only");
+const result = await prepareCompliance({ includeSources: !licensesOnly });
+
+console.log(
+ `Prepared ${result.packageCount} package licenses and ${result.sourceCount} source materials in ` +
+ result.outputDir,
+);
diff --git a/scripts/verify-packaged-compliance.mjs b/scripts/verify-packaged-compliance.mjs
new file mode 100644
index 0000000..69b0361
--- /dev/null
+++ b/scripts/verify-packaged-compliance.mjs
@@ -0,0 +1,75 @@
+import { existsSync } from "node:fs";
+import { copyFile, readFile } from "node:fs/promises";
+import { createRequire } from "node:module";
+import path from "node:path";
+
+import { sha256File, verifyComplianceDirectory } from "./compliance.mjs";
+
+const require = createRequire(import.meta.url);
+const { listPackage } = require("@electron/asar");
+
+export default async function verifyPackagedCompliance(context) {
+ const platform = context.electronPlatformName;
+ const productFilename = context.packager.appInfo.productFilename;
+ const resources =
+ platform === "darwin"
+ ? path.join(context.appOutDir, `${productFilename}.app`, "Contents", "Resources")
+ : path.join(context.appOutDir, "resources");
+
+ const compliance = path.join(resources, "compliance");
+ const electronNotices = path.join(compliance, "electron");
+ const noticeManifest = JSON.parse(
+ await readFile(path.join(compliance, "ELECTRON-NOTICES.json"), "utf8"),
+ );
+ for (const notice of ["LICENSE.electron.txt", "LICENSES.chromium.html"]) {
+ const source = [path.join(context.appOutDir, notice), path.join(resources, notice)].find(
+ existsSync,
+ );
+ const target = path.join(electronNotices, notice);
+ const expected = noticeManifest.notices.find(
+ ({ file }) => file === `electron/${notice}`,
+ )?.sha256;
+ if (!expected) throw new Error(`Compliance manifest is missing Electron notice ${notice}.`);
+ if (source) {
+ const sourceHash = await sha256File(source);
+ if (sourceHash !== expected) {
+ throw new Error(`Packaged Electron notice ${notice} differs from the reviewed archive.`);
+ }
+ await copyFile(source, target);
+ }
+ if (!existsSync(target) || (await sha256File(target)) !== expected) {
+ throw new Error(`Packaged application is missing verified Electron notice ${notice}.`);
+ }
+ }
+ await verifyComplianceDirectory(compliance, {
+ requireSources: true,
+ requireElectronNotices: true,
+ });
+
+ const asarPath = path.join(resources, "app.asar");
+ if (!existsSync(asarPath)) throw new Error(`Packaged application is missing ${asarPath}.`);
+
+ const entries = listPackage(asarPath).map((entry) =>
+ entry.replace(/^[\\/]+/, "").replaceAll("\\", "/").toLowerCase(),
+ );
+ for (const required of ["license", "third-party-notices.md"]) {
+ if (!entries.includes(required)) {
+ throw new Error(`Packaged ASAR is missing ${required}.`);
+ }
+ }
+
+ const nestedOutput = entries.find(
+ (entry) =>
+ entry.startsWith("release/") ||
+ /^dist\/(?:win(?:-[^/]+)?-unpacked|mac(?:-[^/]+)?|linux(?:-[^/]+)?-unpacked)\//.test(
+ entry,
+ ),
+ );
+ if (nestedOutput) {
+ throw new Error(`Packaged ASAR recursively contains build output: ${nestedOutput}.`);
+ }
+
+ console.log(
+ `Verified packaged compliance materials and non-recursive ASAR in ${context.appOutDir}.`,
+ );
+}
diff --git a/scripts/verify-windows-package.mjs b/scripts/verify-windows-package.mjs
index 6ab170c..5daf2d4 100644
--- a/scripts/verify-windows-package.mjs
+++ b/scripts/verify-windows-package.mjs
@@ -2,6 +2,8 @@ import { readdirSync, readFileSync, statSync } from "node:fs";
import { createRequire } from "node:module";
import path from "node:path";
+import { verifyComplianceDirectory } from "./compliance.mjs";
+
const require = createRequire(import.meta.url);
const { listPackage } = require("@electron/asar");
@@ -10,7 +12,7 @@ if (arch !== "x64" && arch !== "arm64") {
throw new Error("Usage: node scripts/verify-windows-package.mjs <x64|arm64>");
}
-const outputRoot = path.resolve("dist");
+const outputRoot = path.resolve("release");
const unpacked = readdirSync(outputRoot)
.map((name) => path.join(outputRoot, name))
.find(
@@ -95,6 +97,22 @@ for (const notice of ["third-party-notices.md", "license"]) {
throw new Error(`Packaged application is missing application notice ${notice}.`);
}
}
+
+await verifyComplianceDirectory(path.join(unpacked, "resources", "compliance"), {
+ requireSources: true,
+ requireElectronNotices: true,
+});
+
+const nestedOutput = asarEntries.find(
+ (entry) =>
+ entry.startsWith("release/") ||
+ /^dist\/(?:win(?:-[^/]+)?-unpacked|mac(?:-[^/]+)?|linux(?:-[^/]+)?-unpacked)\//.test(
+ entry,
+ ),
+);
+if (nestedOutput) {
+ throw new Error(`Packaged application recursively contains build output ${nestedOutput}.`);
+}
const forbiddenSourceRoots = ["common", "docs", "electron", "evals", "scripts", "src"];
for (const root of forbiddenSourceRoots) {
if (asarEntries.some((entry) => entry === root || entry.startsWith(`${root}/`))) {
@@ -103,7 +121,7 @@ for (const root of forbiddenSourceRoots) {
}
console.log(
- `Verified native ${arch} package, asar contents, license notices, and no standalone FFmpeg: ` +
+ `Verified native ${arch} package, compliance sources, notices, and no standalone FFmpeg: ` +
path.relative(process.cwd(), unpacked),
);
diff --git a/third_party/compliance-policy.json b/third_party/compliance-policy.json
new file mode 100644
index 0000000..379fde2
--- /dev/null
+++ b/third_party/compliance-policy.json
@@ -0,0 +1,83 @@
+{
+ "schemaVersion": 1,
+ "copilotCli": "1.0.71",
+ "copilotSdk": "1.0.7",
+ "electron": {
+ "version": "43.1.1",
+ "ffmpegRevision": "ad41607c61898cf7150e0fb20fe4bbabd44922a3",
+ "distributions": {
+ "darwin-arm64": "d6d0598d042ef4d146278d08d84deac9dde145eae31eb4f32ef46206d6bd6169",
+ "darwin-x64": "82789f6fbba543f9c170dd3a0f053278eeda9b4818d51aea5467c4e500e79d51",
+ "linux-arm64": "30ed0b3672dd71672f6496fa0ba0c770ac7f8c6d9b38f01f615a6923b1541311",
+ "linux-x64": "c1f479c52747caf1510e17500e1c8a556d0e40802837bd48c5647a84688a3880",
+ "win32-arm64": "41a8cbea7f356ede97b5222c6f2a6da501e3ae8936a0ed053ae5fa9202ccd912",
+ "win32-x64": "b4e9995cd3f65785eb8818276aa9020f3165ab11da41b3c762616d4a0ad8c7ad"
+ },
+ "notices": {
+ "LICENSE.electron.txt": "5154e165bd6c2cc0cfbcd8916498c7abab0497923bafcd5cb07673fe8480087d",
+ "LICENSES.chromium.html": "b911161e6594ec76b872498b423c54406168f2974e0d407a847f7de1e5ff94dd"
+ }
+ },
+ "sharp": "0.34.5",
+ "sharpLibvips": {
+ "version": "1.2.4"
+ },
+ "onnxruntime": {
+ "1.24.3": "v1.24.3",
+ "1.24.0-dev.20251116-b39e144322": "b39e144322",
+ "1.26.0-dev.20260416-b7804b056c": "b7804b056c"
+ },
+ "remoteMaterials": {
+ "gpl-3.0": "8ceb4b9ee5adedde47b31e975c1d90c73ad27b6b165a1dcd80c7c545eb65b903",
+ "lgpl-2.1": "a9bdde5616ecdd1e980b44f360600ee8783b1f99b8cc83a2beb163a0a390e861",
+ "lgpl-3.0": "a853c2ffec17057872340eee242ae4d96cbf2b520ae27d903e1b2fef1a5f9d1c",
+ "mpl-2.0": "1f256ecad192880510e84ad60474eab7589218784b9a50bc7ceee34c2b91f1d5",
+ "onnxruntime-1.24.0-dev.20251116-b39e144322-license": "2f07c72751aed99790b8a4869cf2311df85a860b22ded05fa22803587a48922c",
+ "onnxruntime-1.24.0-dev.20251116-b39e144322-notices": "e9e90971a8e75a9a8ac0c6412e29c1202d079998389915aa485f46c816c3b4cc",
+ "onnxruntime-1.24.3-license": "2f07c72751aed99790b8a4869cf2311df85a860b22ded05fa22803587a48922c",
+ "onnxruntime-1.24.3-notices": "0e07b95f3a8d6230037707c5c4a2b554d12c4cb67369669ac255635528ffcee2",
+ "onnxruntime-1.26.0-dev.20260416-b7804b056c-license": "2f07c72751aed99790b8a4869cf2311df85a860b22ded05fa22803587a48922c",
+ "onnxruntime-1.26.0-dev.20260416-b7804b056c-notices": "0e07b95f3a8d6230037707c5c4a2b554d12c4cb67369669ac255635528ffcee2"
+ },
+ "sourceMaterials": {
+ "electron": "9fa9a84bc0ee0aab5ec7f46de991dc55904e634fb566a75bb3f93599c861c46a",
+ "electron-ffmpeg": "e84618cc968bb2895ad494c86943c020b242a74f905fc412653c1068a37ea640",
+ "electron-ffmpeg-patch-link-with-loader-path": "849b0fbef990623b0caf187c75a3f31f53ed4390e5770196d47880056b53dc7e",
+ "libvips-windows-build": "241e9b486a14eb1a6b531591f703aeb7d3497c762fc209b2de6a3fdaa67ec8fb",
+ "sharp": "8b4d7e0149fee8d273b1b674ede7886bb7b7b172ebec0398d0b8dbaf816214d2",
+ "sharp-libvips-build": "d434fe577941e979438431ccbdf59ea86a5d559d6b218d6ec2a8ea466ad7c868",
+ "sharp-native-aom": "19e45a5a7192d690565229983dad900e76b513a02306c12053fb9a262cbeca7d",
+ "sharp-native-archive": "db0dee91561cbd957689036a3a71281efefd131d35d1d98ebbc32720e4da58e2",
+ "sharp-native-cairo": "445ed8208a6e4823de1226a74ca319d3600e83f6369f99b14265006599c32ccb",
+ "sharp-native-cgif": "d6cb312c7da2c6c9f310811aa3658120c0316ba130c48a012e7baf3698920fe9",
+ "sharp-native-exif": "62f74cf3bf673a6e24d2de68f6741643718541f83aca5947e76e3978c25dce83",
+ "sharp-native-expat": "71df8f40706a7bb0a80a5367079ea75d91da4f8c65c58ec59bcdfbf7decdab9f",
+ "sharp-native-ffi": "f3a3082a23b37c293a4fcd1053147b371f2ff91fa7ea1b2a52e335676bac82dc",
+ "sharp-native-fontconfig": "82e73b26adad651b236e5f5d4b3074daf8ff0910188808496326bd3449e5261d",
+ "sharp-native-freetype": "44bd69d1f0750603410cfd4f26f1c5523c5a3a087a2dfa8639b757dc7c6677be",
+ "sharp-native-fribidi": "1b1cde5b235d40479e91be2f0e88a309e3214c8ab470ec8a2744d82a5a9ea05c",
+ "sharp-native-glib": "119d1708ca022556d6d2989ee90ad1b82bd9c0d1667e066944a6d0020e2d5e57",
+ "sharp-native-harfbuzz": "0238bf7ada6b1fb92984f69f8b9cd66518af83cf24f7db1cfe60c772c42312d3",
+ "sharp-native-heif": "68ac9084243004e0ef3633f184eeae85d615fe7e4444373a0a21cebccae9d12a",
+ "sharp-native-highway": "07b3c1ba2c1096878a85a31a5b9b3757427af963b1141ca904db2f9f4afe0bc2",
+ "sharp-native-imagequant": "47d2a84b7b1052975c9d50a3d4e3cacbf57b43d84a4c3131210848ead9964dfb",
+ "sharp-native-lcms": "d11af569e42a1baa1650d20ad61d12e41af4fead4aa7964a01f93b08b53ab074",
+ "sharp-native-mozjpeg": "b680167bd5d9afebdd576a12f8c49d2c9066a3b92ef96a2b2c5f7829b8600fe5",
+ "sharp-native-pango": "890640c841dae77d3ae3d8fe8953784b930fa241b17423e6120c7bfdf8b891e7",
+ "sharp-native-pixman": "d09c44ebc3bd5bee7021c79f922fe8fb2fb57f7320f55e97ff9914d2346a591c",
+ "sharp-native-png": "71158e53cfdf2877bc99bcab33641d78df3f48e6e0daad030afe9cb8c031aa46",
+ "sharp-native-proxy-libintl": "f7a1cbd7579baaf575c66f9d99fb6295e9b0684a28b095967cfda17857595303",
+ "sharp-native-rsvg": "4644d83623dd61cc4479c2b3c372e1da2b281552ebc90035c8d1ac502eb1dc00",
+ "sharp-native-spng": "47ec02be6c0a6323044600a9221b049f63e1953faf816903e7383d4dc4234487",
+ "sharp-native-tiff": "f698d94f3103da8ca7438d84e0344e453fe0ba3b7486e04c5bf7a9a3fabe9b69",
+ "sharp-native-vips": "41e9a1439cd57dcc6d4435a085e2cfe181d9da1962fa84a484f09e8b536e4b77",
+ "sharp-native-webp": "e4ab7009bf0629fd11982d4c2aa83964cf244cffba7347ecd39019a9e38c4564",
+ "sharp-native-xml2": "c008bac08fd5c7b4a87f7b8a71f283fa581d80d80ff8d2efd3b26224c39bc54c",
+ "sharp-native-zlib-ng": "5b3b022489f3ced82384f06db1e13ba148cbce38c7941e424d6cb414416acd18",
+ "sharp-patch-aom": "9905702d2be0d790ca9a47752f2e6f84b37e085f43c58e1d2dd66896e9fd5694",
+ "sharp-patch-glib-without-gregex": "b1f2930a11292e529de137c7eb723850e0cc0969b1a2b0358196389312acd272",
+ "sharp-patch-highway": "6ce65c4a6e90a4293da81cd3e932e81fd7ac77f31058143241ca9b8dd085098c",
+ "sharp-patch-libvips-heif": "59a547c12915bc2670c37ff88200ebe74fe70aacce6e20b7069157a0d6a098c8",
+ "sharp-patch-libvips-soversion": "256b7d6f8c973bb53b20cff5171c7117d6b35d3aa4e72d22cb906f4fe1e2c890"
+ }
+}
diff --git a/third_party/package-licenses/github-copilot-sdk-MIT.txt b/third_party/package-licenses/github-copilot-sdk-MIT.txt
new file mode 100644
index 0000000..28a50fa
--- /dev/null
+++ b/third_party/package-licenses/github-copilot-sdk-MIT.txt
@@ -0,0 +1,21 @@
+MIT License
+
+Copyright GitHub, Inc.
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
diff --git a/third_party/package-licenses/onnxruntime-MIT.txt b/third_party/package-licenses/onnxruntime-MIT.txt
new file mode 100644
index 0000000..48bc6bb
--- /dev/null
+++ b/third_party/package-licenses/onnxruntime-MIT.txt
@@ -0,0 +1,21 @@
+MIT License
+
+Copyright (c) Microsoft Corporation
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.