Skip to content

feat(npm): ship the rewrite as @aoagents/ao via optional-deps#252

Open
harshitsinghbhandari wants to merge 3 commits into
mainfrom
session/aa-107
Open

feat(npm): ship the rewrite as @aoagents/ao via optional-deps#252
harshitsinghbhandari wants to merge 3 commits into
mainfrom
session/aa-107

Conversation

@harshitsinghbhandari

Copy link
Copy Markdown
Collaborator

What

Builds the npm packaging machinery so the rewrite ships as @aoagents/ao@0.10.0 and ao runs the Go daemon. Implements the locked design from discussions #229 / #231: the optionalDependencies (esbuild/swc) pattern.

  • ao launcher shim (npm/bin/ao.js): resolves the installed @aoagents/ao-<os>-<arch> sub-package, locates its prebuilt daemon, and execs it, forwarding argv/stdio/exit code/signals. CLI verbs talk to the daemon over loopback exactly as today. Clear message + exit 1 when no matching platform package is installed (unsupported host, or --omit=optional).
  • Per-platform sub-packages: one tiny package per target carrying the right binary + os/cpu fields. npm installs only the host match. No postinstall, no install-time network call.
  • Main package @aoagents/ao@0.10.0: bin, optionalDependencies for all sub-packages, and repository/homepage/bugs repointed at aoagents/ReverbCode (legacy pointed at the old upstream).
  • Single source of truth npm/targets.mjs for the matrix (darwin arm64+x64, linux x64+arm64, win32 x64+arm64); scripts/check.mjs enforces that the committed optionalDependencies stay in lockstep.
  • Build tooling: build.mjs (cross-compile, CGO disabled / pure-Go SQLite → builds every target from one host, stamps version via ldflags + assembles sub-packages), pack.mjs (tarballs), collect-release.mjs (flattened binaries + SHA256SUMS for Releases).
  • Release CI (.github/workflows/release.yml, on a v* tag): cross-compile every target, publish binaries to the GitHub Release, build the npm sub-packages from those binaries, verify with npm publish --dry-run.
  • Publish CI (.github/workflows/npm-publish.yml): manual workflow_dispatch, dry-run by default. A real publish requires dry_run=false and an NPM_TOKEN secret — neither wired by default, so publishing stays a deliberate human action. Sub-packages publish before the main package so its optionalDependencies resolve.

Scope

Only the Go daemon (~20 MB) ships via npm. The Electron app is fetched from GitHub Releases during migration and is out of scope here.

Verification (local)

  • ✅ All 6 targets cross-compile cleanly (node npm/scripts/build.mjs).
  • npm pack main + host sub-package; installed both tarballs into a temp global prefix; ao version execs the host Go daemon and reports 0.10.0.
  • ✅ Daemon lifecycle through the installed ao: startstatus (ready) → stop.
  • ✅ Missing-platform path: removing the sub-package yields the clear error + exit 1.
  • npm publish --dry-run succeeds for main + sub-packages.
  • cd backend && go build ./... (no Go source changed).

🤖 Generated with Claude Code

harshitsinghbhandari and others added 2 commits June 16, 2026 17:27
Package the Go daemon as the @aoagents/ao npm package (v0.10.0) using the
esbuild/swc optionalDependencies pattern: one tiny per-platform sub-package
(@aoagents/ao-<os>-<arch>) carries the prebuilt daemon plus os/cpu fields, and
npm installs only the host match.

- bin/ao.js launcher shim resolves the installed platform sub-package, execs
  its daemon, and forwards argv/stdio/exit code/signals. CLI verbs talk to the
  daemon over loopback as before. Clear error + exit 1 when no platform package
  is installed.
- targets.mjs is the single source of truth for the platform matrix (darwin
  arm64+x64, linux x64+arm64, win32 x64+arm64); check.mjs enforces that the
  committed optionalDependencies stay in lockstep.
- build.mjs cross-compiles (CGO disabled, pure-Go SQLite) and assembles every
  sub-package; pack.mjs produces tarballs; collect-release.mjs flattens binaries
  + SHA256SUMS for GitHub Releases.
- repository/homepage/bugs repointed at aoagents/ReverbCode.
- release.yml (on v* tag): cross-compile all targets, publish binaries to the
  GitHub Release, build npm sub-packages, verify with npm publish --dry-run.
- npm-publish.yml: manual, dry-run by default; a real publish requires
  dry_run=false AND an NPM_TOKEN secret (neither wired by default).

The Electron app is fetched from GitHub Releases during migration and is out of
scope here. Verified locally: full-matrix cross-compile, npm pack, temp-prefix
global install, and the host ao execing the Go daemon through start/status/stop.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your free trial has ended. If you'd like to continue receiving code reviews, you can add a payment method here.

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your free trial has ended. If you'd like to continue receiving code reviews, you can add a payment method here.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your free trial has ended. If you'd like to continue receiving code reviews, you can add a payment method here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant