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

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
174 changes: 174 additions & 0 deletions .github/workflows/npm-package-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,174 @@
name: npm-package-release

on:
push:
tags:
- 'v[0-9]*'
pull_request:
branches: [main]
workflow_dispatch:

permissions:
contents: read

jobs:
clean-install:
name: npm clean install / ${{ matrix.os }}
runs-on: ${{ matrix.os }}
timeout-minutes: 25
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v4
with:
version: 12
- uses: actions/setup-node@v4
with:
node-version: '24'
cache: pnpm
- run: pnpm install --frozen-lockfile --ignore-scripts
- name: Compile and test npm tarball, gateway, MCP, and local Admin UI
run: pnpm run test:package
- run: pnpm run test:portable
- run: pnpm run test:portable:server
- run: pnpm run test:cli
- run: pnpm run test:extensions
- name: Linux policy and integration acceptance
if: runner.os == 'Linux'
run: pnpm run test:policy && pnpm run test:integration && pnpm run test:sources
shell: bash

full-tests:
name: npm release full regression / Linux
runs-on: ubuntu-latest
timeout-minutes: 25
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v4
with:
version: 12
- uses: actions/setup-node@v4
with:
node-version: '24'
cache: pnpm
- run: pnpm install --frozen-lockfile --ignore-scripts
- name: Install workstation-specific test prerequisites
# Full suite tests real chezmoi target resolution and fish syntax.
# CI-only tools; no npm runtime dependency or modified assertions.
shell: bash
run: |
set -euo pipefail
sudo apt-get update -qq
sudo apt-get install -y --no-install-recommends fish
# Ubuntu's runner apt repositories do not provide chezmoi.
# Fetch one immutable upstream release and verify its published digest.
curl --fail --location --silent --show-error --retry 2 \
https://github.com/twpayne/chezmoi/releases/download/v2.74.1/chezmoi_2.74.1_linux_amd64.tar.gz \
-o "$RUNNER_TEMP/chezmoi.tar.gz"
printf '%s %s\n' \
ae01c66b1a6dbf563667c63fbbd9986b3cfa3c98dd266ddee732f63e8af2e9d1 \
"$RUNNER_TEMP/chezmoi.tar.gz" | sha256sum --check
tar -xzf "$RUNNER_TEMP/chezmoi.tar.gz" -C "$RUNNER_TEMP" chezmoi
chmod 755 "$RUNNER_TEMP/chezmoi"
echo "$RUNNER_TEMP" >> "$GITHUB_PATH"
"$RUNNER_TEMP/chezmoi" --version
fish --version
- run: pnpm run build
- name: Full existing regression suite
run: pnpm run test:all
- name: Native tool schema inventory
run: node scripts/sync-tool-counts.mjs --check-manifest profiles/native-tool-counts.json

tarball:
name: Verified npm tarball
needs: [clean-install, full-tests]
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: pnpm/action-setup@v4
with:
version: 12
- uses: actions/setup-node@v4
with:
node-version: '24'
cache: pnpm
- run: pnpm install --frozen-lockfile --ignore-scripts
- name: Verify release tag and protected main ancestry
if: startsWith(github.ref, 'refs/tags/')
shell: bash
run: |
node -e 'const p=require("./package.json");if(process.env.GITHUB_REF_NAME!=="v"+p.version){throw Error("Tag and package.json version mismatch")}'
git fetch origin main
git merge-base --is-ancestor HEAD origin/main
- name: Generate prebuilt package
run: npm pack
- name: Record tarball SHA-256
shell: bash
run: sha256sum bridge-dev-*.tgz
- uses: actions/upload-artifact@v4
with:
name: npm-tarball
path: bridge-dev-*.tgz
if-no-files-found: error
retention-days: 14

publish:
name: npm trusted publish (explicit opt-in only)
needs: tarball
# Existing npm package: trusted publisher registered in npm settings.
# Avoid setup-node registry-url here: an empty _authToken can suppress OIDC.
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') && vars.NPM_PUBLISH_ENABLED == 'true' && vars.NPM_TRUSTED_PUBLISH_READY == 'true' && vars.NPM_BOOTSTRAP_ENABLED != 'true'
runs-on: ubuntu-latest
environment: npm-release
timeout-minutes: 10
permissions:
contents: read
id-token: write
steps:
- uses: actions/setup-node@v4
with:
node-version: '24'
- uses: actions/download-artifact@v4
with:
name: npm-tarball
- name: Require npm trusted-publishing CLI version
shell: bash
run: |
node -e 'const [a,b,c]=require("child_process").execFileSync("npm",["--version"],{encoding:"utf8"}).trim().split(".").map(Number);if(a<11||(a===11&&(b<5||(b===5&&c<1))))throw Error("npm 11.5.1+ required for OIDC publishing")'
- name: Publish verified tarball using OIDC with provenance
shell: bash
run: npm publish ./bridge-dev-*.tgz --access public --provenance

bootstrap-publish:
name: npm first release (explicit one-time credential opt-in)
needs: tarball
# npm requires the package to exist before a trusted publisher can be
# registered. Only the initial release uses a reviewed temporary npm token.
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') && vars.NPM_PUBLISH_ENABLED == 'true' && vars.NPM_BOOTSTRAP_ENABLED == 'true' && vars.NPM_TRUSTED_PUBLISH_READY != 'true'
runs-on: ubuntu-latest
environment: npm-release
timeout-minutes: 10
permissions:
contents: read
id-token: write
steps:
- uses: actions/setup-node@v4
with:
node-version: '24'
registry-url: 'https://registry.npmjs.org'
- uses: actions/download-artifact@v4
with:
name: npm-tarball
- name: First package publication with provenance
shell: bash
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
run: |
test -n "$NODE_AUTH_TOKEN" || { echo "Missing NPM_TOKEN secret for one-time initial publication" >&2; exit 1; }
npm publish ./bridge-dev-*.tgz --access public --provenance
2 changes: 2 additions & 0 deletions .github/workflows/portable-platforms.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ jobs:
- run: pnpm run test:portable:server
- run: pnpm run test:trial
- run: pnpm run test:cli
- name: Packed npm installation (isolated prefix)
run: pnpm run test:package
- run: node scripts/test-install-portable.mjs
- run: pnpm run test:extensions
sources:
Expand Down
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,22 @@ Requires **Node.js 22+ and npm**. No Git checkout, global TypeScript or pnpm
installation is required. The standard portable install needs no administrator
permissions, background service, or host-root controller.

**npm package (after its first verified registry release):**

```sh
npm install -g bridge-dev
bridge-dev setup
bridge-dev start
```

The tarball contains the prebuilt CLI, gateway and Admin UI; no Git checkout,
TypeScript toolchain or postinstall script is needed on the consumer machine.
Until publication, the same tarball is validated with `pnpm run test:package`.
An npm installation does not enable a service or grant root access. Existing
managed Linux installations keep their verified GitHub updater and signed lease
workflow. [Package details](docs/INSTALL.md#npm-package) ·
[Release procedure](docs/RELEASING.md).

**Linux / macOS / Termux**

```sh
Expand Down
47 changes: 47 additions & 0 deletions docs/INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,53 @@ modes and update requirements.



## npm package

BridgeDev is packaged as a precompiled npm CLI: its tarball contains `dist/`,
`public/ui/`, reviewed portable profiles, required runtime scripts, and the
license and installation documentation. npm installs the production Node.js
dependencies automatically. No TypeScript build, pnpm, Git checkout, service or
root controller is required on the consumer machine.

After a registry release is explicitly published, the installation is:

~~~sh
npm install -g bridge-dev
bridge-dev setup
bridge-dev start
~~~

**Publication is a separate operator action.** Until the registry package is
published, create and inspect a local tarball instead:

~~~sh
pnpm install --frozen-lockfile --ignore-scripts
npm run test:package
npm pack
# In a disposable prefix, inspect and install the generated .tgz before use.
~~~

`npm run test:package` builds and checks the tarball in a temporary local
installation, verifies CLI/help and portable setup, and rejects excluded files.
The global npm command must not replace the launcher for an existing managed
BridgeDev installation. Its signed host-controller lease, systemd cutover and
rollback remain governed by the [separate managed update procedure](PERSISTENT_SERVICE.md).
For an **explicit initial** Linux service setup from an npm-installed CLI,
`bridge-dev service install --start` stages the *GitHub CI-verified release*
corresponding to the npm package's `vX.Y.Z` tag; it does not seed the unverified
npm files into an operator-privileged service. This advanced operation requires
the `gh` CLI authenticated for the release-artifact API, an already-published
tag and green main-branch CI. It does not create YOLO authorization or Funnel
exposure. Existing managed installations use their own operator CLI for
verified service updates; a standalone npm CLI only reports npm update guidance.

`bridge-dev --version` reports the packaged version. `bridge-dev doctor`
identifies the installation source. For npm installs, `bridge-dev update --check`
reports the manual update command `npm install -g bridge-dev@latest` and does
not invoke GitHub deployment or npm itself; the managed Linux updater is
unchanged. A standalone npm gateway must never inherit a different, managed
gateway's operator-signed YOLO authorization. See [release instructions](RELEASING.md).

## One-command portable installation

Requirements: **Node.js 22+ and npm**. The shell installer also needs `curl` and `tar`. Windows PowerShell requires `Invoke-WebRequest` and `Expand-Archive`.
Expand Down
102 changes: 102 additions & 0 deletions docs/RELEASING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
# BridgeDev npm release procedure

The npm tarball is a precompiled JavaScript CLI and gateway, not a system installer.
Node.js >=22 is required on the consumer machine. It includes the Admin UI,
reviewed metadata profiles, and the lease verification / service acceptance
helpers needed by the code. npm resolves the five production JavaScript packages;
there are no required native Node addons, postinstall scripts, persistent
services, host-root grants, credential copies, or automatically started servers.

## Package name and ownership

The intended public name is `bridge-dev` (version 2.0.0 is the current source
baseline). On 2026-11-17, `npm view bridge-dev` returned E404, **not proof of
permanent name reservation**. Before first publication, independently check
`npm view bridge-dev` from the operator's terminal, then register/login to
[npmjs.com](https://www.npmjs.com/). If another account owns the name, use
`@kmanisk/bridge-dev` with `--access public`, update `package.json`,
all hardcoded npm commands and package tests, and inspect the changed tarball.
Never publish an unreviewed third-party package under the intended name.

## Local preflight (no publication)

From a clean feature branch:

```sh
pnpm install --frozen-lockfile --ignore-scripts
pnpm run test:package
pnpm test
pnpm run test:policy
pnpm run test:portable
pnpm run test:cli
pnpm run test:extensions
pnpm run test:integration
pnpm run test:all
node scripts/sync-tool-counts.mjs --check-manifest profiles/native-tool-counts.json
git diff --check
npm pack --dry-run
```

The packaged test creates a disposable npm installation with its own HOME,
configuration, workspace, ports and tokens; it starts an isolated gateway,
checks an authenticated MCP session and local Admin UI, and removes fixtures.
It must not attach to a running managed service or inherit its signed YOLO
lease. Inspect the tarball file list and source diff before approving a release.

## npm publishing (operator-only setup)

1. Create or sign in to npm, enable account-level two-factor authentication,
configure recovery factors and confirm the package name is available.
2. Configure a protected GitHub Actions environment named `npm-release`,
with a required operator reviewer before publishing.
3. **First publication:** npm requires a package to exist before its trusted
publisher can be configured. Create a short-lived npm publication token
with appropriate publish privileges and save it as a GitHub Actions
repository secret `NPM_TOKEN`. For a one-time, independently approved
release, set repository variables `NPM_BOOTSTRAP_ENABLED=true` and
`NPM_PUBLISH_ENABLED=true`; leave `NPM_TRUSTED_PUBLISH_READY` unset.
The tag workflow then publishes its *verified tarball* using that token
with provenance from CI, not from the developer's laptop.
4. Immediately after the first release, **revoke the bootstrap token** and
set `NPM_BOOTSTRAP_ENABLED=false`. In the npm package's Trusted Publisher
settings, register GitHub Actions owner `kmanisk`, repository `bridge-dev`,
workflow filename `npm-package-release.yml`, allowing release
publication. Set `NPM_TRUSTED_PUBLISH_READY=true` only after validating
the link. Keep `NPM_PUBLISH_ENABLED=false` until the next release
is independently approved.
5. Subsequent releases use **tokenless GitHub OIDC** with `id-token: write`,
Node.js 24, npm CLI 11.5.1+, and provenance. The OIDC job deliberately
avoids a `setup-node` `registry-url` option because an empty .npmrc
auth token may suppress the trusted-publisher exchange. Do not install
an npm token for these releases.
6. Review the version bump in `package.json` and `pnpm-lock.yaml` as
applicable; merge via the protected `main` pull request and CI.
Confirm the exact merged main commit and package version locally.
Create a signed or annotated `vX.Y.Z` tag on that exact commit and push
it **only after explicit publication approval**. This document does
not authorize creating a tag or publishing automatically.
7. The tag workflow runs Linux, Windows and macOS clean-install tests,
full Linux regression, a tag/version and main ancestry check, and
uploads the verified .tgz artifact. Publishing occurs only if
`NPM_PUBLISH_ENABLED=true` *and* the corresponding one-time bootstrap
or trusted-publisher flag is set. Manual `workflow_dispatch` only verifies.
8. From a fresh terminal inspect `npm view bridge-dev version dist.integrity`
and provenance, then `npm install -g bridge-dev`,
`bridge-dev --version`, `bridge-dev doctor` and an explicit portable
gateway smoke test. Never paste private credentials into logs.

## Upgrade, recovery and rollback

- npm installation: `npm install -g bridge-dev@latest` executed manually as
the owner; no background updates. For a known good version use
`npm install -g bridge-dev@X.Y.Z`.
- A verified managed Linux service is **not** upgraded by npm. It uses
`bridge-dev update`, its GitHub CI artifact, shadow tests, controlled
systemd cutover, preserved operator-signed lease and rollback.
- GitHub-source portable installer: rerun the reviewed `install.sh` or
`install.ps1`; its previous built app is retained separately.
- npm versions are immutable: do **not** overwrite a published version.
For an incorrect release, use `npm deprecate bridge-dev@X.Y.Z
"Reason; use X.Y.Z+1"` and publish a new patch version through a new,
reviewed tag. Follow npm policy for rare unpublish emergencies.
- Never update a running production gateway merely to test npm packaging.
23 changes: 23 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,35 @@
},
"author": "kmanisk (based on MIT-licensed chatgpt-local-coder by hoangcoderr)",
"type": "module",
"engines": {
"node": ">=22"
},
"files": [
"dist/",
"public/ui/",
"profiles/",
"scripts/lease-activation.mjs",
"scripts/lease-activation.d.mts",
"scripts/deploy-acceptance/",
"scripts/shadow-release-acceptance.mjs",
"scripts/policygate-operator.mjs",
"platform/windows-provider-cleanup.ps1",
"docs/INSTALL.md",
"docs/RELEASING.md",
"docs/POLICY_GATEWAY.md",
"docs/PERSISTENT_SERVICE.md",
"docs/HOST_CONTROLLER.md",
"docs/MCP_INTEGRATIONS.md",
"docs/ADMIN_AUTH.md"
],
"main": "dist/index.js",
"bin": {
"bridge-dev": "dist/cli.js"
},
"scripts": {
"build": "tsc",
"prepack": "npm run build",
"test:package": "npm run build && node scripts/test-install-source.mjs && node scripts/test-npm-package.mjs",
"test": "tsc && node scripts/isolated-tests.mjs scripts/test-patch.mjs scripts/test-tools.mjs scripts/test-checkpoints.mjs scripts/test-mcp-upstream.mjs scripts/test-mcp-oauth.mjs scripts/test-activity-log.mjs scripts/test-project-memory.mjs scripts/test-tool-profile.mjs scripts/test-shell-persist.mjs scripts/test-phase1-safe-edit.mjs scripts/test-phase2-chezmoi.mjs scripts/test-system-enhancements.mjs scripts/test-policy-gateway.mjs",
"test:all": "node scripts/run-all-tests.mjs",
"test:integration": "tsc && node scripts/isolated-tests.mjs scripts/test-mcp-bridge-integration.mjs scripts/test-extension-interfaces.mjs scripts/test-managed-session-http.mjs scripts/test-output-schemas.mjs scripts/test-deploy-acceptance.mjs",
Expand Down
Loading
Loading