Skip to content

feat(mocactl): one-line install via release asset and curl | sh - #473

Merged
pdettori merged 10 commits into
rossoctl:mainfrom
pdettori:feat/mocactl-installer
Oct 9, 2026
Merged

pdettori merged 10 commits into
rossoctl:mainfrom
pdettori:feat/mocactl-installer

Conversation

@pdettori

@pdettori pdettori commented Oct 9, 2026 •

Copy link
Copy Markdown
Member

Summary

Anyone pointed at a MOCA server can now install mocactl with one line and run it by name. There is no clone, no pnpm install and no alias:

curl -fsSL https://raw.githubusercontent.com/rossoctl/moca/main/scripts/install-mocactl.sh | sh
export SH_CONTROL_PLANE_URL=https://moca.example.com
mocactl
  • Spec: docs/specs/2026-10-08-mocactl-installer-design.md (registry entry MU1.2)

How it works

push to main ──► mocactl-release.yml ──► build + test the bundle ──► mocactl-edge prerelease (never "Latest")
release published ──────────────────────────────────────────────────► mocactl.mjs + mocactl.mjs.sha256 on the release
curl | sh ──► check Node ≥ 22 ──► download from latest | edge | vX.Y.Z ──► verify SHA-256
          ──► ~/.local/bin/mocactl.mjs, with mocactl → mocactl.mjs (a relative symlink, swapped in by atomic rename)

What's in it

packages/mocactl

  • mocactl --version (also -V) prints a release tag, edge-<sha>, or dev, and reads no config and makes no network call first.
  • build.mjs uses esbuild to bundle the client and every runtime dependency into one dist/mocactl.mjs of about 5 MB, with a node shebang and the version baked in.
    • A createRequire banner is needed: without it, --help works but the TUI crashes at startup on Dynamic require of "assert" (from Ink's signal-exit).
    • pnpm --filter @moca/mocactl build runs it. The tsx path from a checkout (bin/mocactl.mjs) is unchanged.
  • test/bundle.test.ts builds the bundle and runs it from a temp dir with no node_modules in reach. It checks:
    • --version and --help;
    • the TUI under a pseudo-terminal;
    • that a missing clipboard tool gives a rejected copy, not a crash;
    • the installed symlink layout under a "type": "commonjs" package.json, with a control case showing an extensionless copy prints nothing.

scripts/install-mocactl.sh, a POSIX sh installer built for curl | sh, following deploy/compose/install.sh

  • Settings: MOCACTL_VERSION (latest by default, edge, or vX.Y.Z), MOCACTL_INSTALL_DIR (~/.local/bin by default) and MOCACTL_BASE_URL.
  • The tag allowlist runs before any URL is built, and every fetch is curl --proto '=https', so redirects can't downgrade to http either.
  • Uses sha256sum, or shasum on stock macOS.
  • A failed or corrupt download leaves no files behind.
  • It never edits rc files. If the install dir isn't on PATH, it prints the line to add.
  • scripts/tests/install-mocactl.test.sh mocks curl and node on a narrowed PATH and covers 10 cases, including:
    • a 404 or a checksum mismatch;
    • Node too old, unreadable or missing;
    • shasum only;
    • an install dir containing a space;
    • a re-run upgrade;
    • a mocactl that prints no version.
  • The installer test is wired into make test-deploy, and the shellcheck CI job now covers scripts/.

.github/workflows/mocactl-release.yml

  • Triggers on release: published and on push to main. Actions are SHA-pinned, and it does not check out pi-fork.
  • build (contents: read, persist-credentials: false): install, build, the bundle test and an outside-the-workspace smoke check. It hands mocactl.mjs and its .sha256 to publish as a workflow artifact.
  • publish (contents: write): runs only gh, with no checkout and no pnpm. It attaches the asset to the release, or moves the mocactl-edge tag through the git refs API and updates the prerelease.

Docs

  • The mocactl README and QUICKSTART §4 lead with the one-liner. QUICKSTART uses MOCACTL_VERSION=edge, since that cluster is built from main.
  • The compose installer's closing message points at the one-liner.
  • The spec registry and CLAUDE.md are updated.

After merge

  • Cut a release. The current latest release, v0.5.1, has no mocactl.mjs and can't be backfilled, because its source has no build.mjs. Until a release is published after this merge, the default latest channel 404s, and the error tells the user to try MOCACTL_VERSION=edge.
  • The first push to main creates mocactl-edge. Not verified yet: whether a tag ruleset blocks the workflow's force-push of the mocactl-edge tag with GITHUB_TOKEN.

Testing

  • CI=true make test, make typecheck and make lint: green. CI=true is how GitHub Actions runs them, and Ink renders differently under CI.
  • The installer suite also passes with dash as /bin/sh (Ubuntu's).
  • actionlint and shellcheck -S warning are clean.
  • A frozen, filtered install (--filter '@moca/mocactl...') builds and passes the bundle test from a git archive copy with no pi-fork.

Deferred (minor, from review)

  • --clobber can briefly 404 the edge asset mid-update. The installer's hint says to re-run.
  • Ctrl-C under dash may skip the EXIT trap, leaving a temp dir behind.
  • For bash on macOS, the PATH hint names ~/.bashrc rather than ~/.bash_profile.
  • An install dir given with a trailing / prints the PATH hint even when it's already on PATH.

Assisted-By: Claude (Anthropic AI) [email protected]

🤖 Generated with Claude Code

@pdettori pdettori added the ready-for-ai-review Request automated AI code review from clawgenti label Oct 9, 2026

@ingpaolodettori-dev ingpaolodettori-dev left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Summary

This is a well-built one-line installer. The POSIX sh script validates the tag allowlist before it builds any URL, verifies the checksum, cleans up its temp dir, renames atomically and never touches rc files. The release workflow is SHA-pinned and has no pull_request trigger, and both are well tested. One blocker: the required check job is red on this head. Its Test step fails, while every other PR on the same base (4482def) is green. The cause is almost certainly the new PTY test in bundle.test.ts. GitHub Actions sets CI=true, and in that mode Ink 8 renders non-interactively and writes no frame until unmount. The test SIGKILLs the TUI first, so stdout never contains Log in with GitHub. It passes locally because CI is unset there. mocactl-release.yml runs the same test, so as written it would also fail every edge publish. Details are inline. Everything else is non-blocking.

Author: pdettori (MEMBER — maintainer)
Areas reviewed: Shell (installer + test), CI/GitHub Actions (new release workflow, shellcheck scope), TypeScript (build.mjs, --version, bundle/cli tests), Makefile, Docs/spec
Agent/IDE config (.claude/.vscode): none (root CLAUDE.md gets a one-line layout entry only)
Commits: 7 commits, all signed-off: yes
CI status: failing: check (Test step, caused by this PR; see the inline comment). trivy-scan is also red, but feat/mocactl-interrupted-turn-note shows the same failure on an unrelated head, so it looks like a new advisory against an existing dependency rather than this diff. Everything else passes, including deploy-scripts (the new installer test) and shellcheck (now covering scripts/).

Nit (title): the PR title is about 80 characters, over the 72-character advisory limit.

timeout: 15_000,
});
expect(r.stdout).not.toContain('Dynamic require');
expect(r.stdout).toContain('Log in with GitHub');

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

must-fix: this is almost certainly why check (pnpm -r test) is red on this head. GitHub Actions exports CI=true and cleanEnv() passes it through. Ink 8 decides interactive = !isInCi && stdout.isTTY (ink/build/ink.js, via is-in-ci), so even under the pty Ink runs non-interactively. In that mode it defers every frame and writes only lastOutput on unmount. The python driver SIGKILLs the process before any unmount, so out never contains Log in with GitHub. Locally CI is unset, so the test passes. mocactl-release.yml runs this same test file before uploading, so as written every edge and release publish would fail there too.

Suggested fix: drop the CI markers from this child's env only. is-in-ci reads CI and CONTINUOUS_INTEGRATION, and '0'/'false' count as unset:

env: cleanEnv({
  SH_CONTROL_PLANE_URL: 'http://127.0.0.1:9',
  XDG_CONFIG_HOME: join(dir, 'config'),
  TERM: 'xterm-256color',
  // Ink treats CI as non-interactive and prints nothing until unmount; this child is killed first.
  CI: 'false',
  CONTINUOUS_INTEGRATION: 'false',
}),

(I couldn't read the Actions job log from my side, so please confirm against the log. Running CI=true pnpm --filter @moca/mocactl exec vitest run test/bundle.test.ts locally should reproduce it.)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Confirmed and fixed in ca17a30. CI=true pnpm --filter @moca/mocactl exec vitest run test/bundle.test.ts reproduced the failure locally: only the PTY test fails. I checked is-in-ci: it treats CI and CONTINUOUS_INTEGRATION as unset only when they're '0' or 'false'. So the PTY child now gets CI: 'false' and CONTINUOUS_INTEGRATION: 'false', with a comment explaining why. Results: the file passes with and without CI=true, and the whole suite passes under CI=true make test. I couldn't read the Actions job log either; it only shows the Test step of check failing.


it('turns a missing clipboard tool into a rejected copy, not a crash', () => {
const probe = join(dir, 'clipboard-probe.mjs');
build(['--entry', 'test/fixtures/clipboard-probe.ts', '--outfile', probe]);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

nit: this it spawns a full esbuild run but keeps vitest's default 5 s timeout. The beforeAll build gets 60 s and the PTY test gets 20 s. Under pnpm -r test on a shared runner a cold esbuild start can get close to 5 s. An explicit timeout, say 30_000, would keep it from flaking.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Done in ca17a30: the clipboard probe test now has an explicit 30_000 timeout.

Comment thread .github/workflows/mocactl-release.yml Outdated
branches: [main]

permissions:
contents: write

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

suggestion: I know the split is listed under Deferred, but the exposure is broader than the asset itself. Right now contents: write (plus the token actions/checkout persists in .git/config) is live through pnpm install and the vitest run. So a compromised dependency's lifecycle script or test-time code could push branches and tags or edit releases, on top of tampering with the bundle. The cheap mitigation is a build job with contents: read that installs, builds, tests and uploads mocactl.mjs + .sha256 with actions/upload-artifact. A small publish job with contents: write then downloads it and runs the gh release … / tag steps without ever running pnpm. If you keep one job for now, persist-credentials: false on checkout limits the window. The tag move can then use gh api -X PATCH repos/${{ github.repository }}/git/refs/tags/mocactl-edge -f sha=$GITHUB_SHA -F force=true. That's not blocking, but since this asset is what curl | sh users run, I'd do it soon after merge.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Done in 52b26a9 rather than deferring it. The workflow token is now contents: read, and the work is split into two jobs:

  • build (read-only, persist-credentials: false): install, build, the bundle test and the smoke check. It uploads mocactl.mjs and .sha256 as the mocactl-asset artifact.
  • publish (contents: write): downloads that artifact and runs only gh, with no checkout and no pnpm.

The edge tag now moves through the refs API, as you suggested. One catch: the existence check uses the exact git/ref/tags/mocactl-edge endpoint, because the plural git/refs/tags/<x> also returns 200 (an array) for a prefix match. I checked that read-only against v0.5. Spec §5 is updated to match.

Comment thread scripts/install-mocactl.sh Outdated
trap 'rm -rf "$WORK_DIR"' EXIT
log "downloading mocactl ($MOCACTL_VERSION) from $url"
for file in mocactl.mjs mocactl.mjs.sha256; do
curl -fsSL -o "$WORK_DIR/$file" "$url/$file" ||

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

nit: -L follows redirects to any protocol. The GitHub releases/download URL always redirects (to objects.githubusercontent.com / release-assets…), so consider --proto-redir '=https' (or --proto '=https' if http mirrors aren't a goal). That way a redirect can never downgrade the asset or checksum fetch to plain http. The mocked curl in the test ignores unknown flags, so the test is unaffected.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Done in 7ad50d8: every fetch is now curl -fsSL --proto '=https'. Plain http mirrors aren't a goal, and --proto also bounds redirects, since --proto-redir can't re-enable a protocol that --proto denies. Real curl refuses http://… with Protocol "http" disabled. The test now enforces this: the mock curl fails any fetch without --proto '=https', so every case checks it. I watched it fail before the change.

A bundled mocactl.mjs release asset (per release, plus a rolling
mocactl-edge prerelease from main) and a POSIX curl | sh installer that
verifies the checksum and installs to ~/.local/bin.

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Paolo Dettori <[email protected]>
A release tag, edge-<sha>, or dev from a checkout. It is read before any
config or network, so a user can always say what they are running.

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Paolo Dettori <[email protected]>
esbuild bundles mocactl and every runtime dependency into one file with
a node shebang and the version baked in: the asset the installer ships.
A createRequire banner keeps Ink's CommonJS dependencies working; the
test runs the bundled TUI under a pty because only that path needs it.

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Paolo Dettori <[email protected]>
curl -fsSL .../scripts/install-mocactl.sh | sh installs the latest
release's mocactl.mjs (MOCACTL_VERSION=edge for main, or a tag) to
~/.local/bin/mocactl after checking its SHA-256. POSIX sh; needs Node 22.

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Paolo Dettori <[email protected]>
…ease

Each published release gets mocactl.mjs and its .sha256; every push to
main rebuilds the mocactl-edge prerelease (never Latest), which
MOCACTL_VERSION=edge installs. The bundle is tested before upload.

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Paolo Dettori <[email protected]>
README and QUICKSTART lead with install-mocactl.sh; the checkout path
stays for contributors. The compose installer points at it too.

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Paolo Dettori <[email protected]>
An extensionless copy of the ESM bundle loads as CommonJS on Node
22.0-22.6 or under a "type": "commonjs" package.json, and prints
nothing. Keep the .mjs name and symlink mocactl to it; fail the install
when --version prints nothing; hint MOCACTL_VERSION=edge, not latest,
when the latest release has no asset.

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Paolo Dettori <[email protected]>
GitHub Actions sets CI=true, and Ink then renders non-interactively,
writing no frame until unmount; the pty driver kills the TUI first, so
the test failed only in CI. Give this child CI=false. Also give the
clipboard probe's esbuild run an explicit 30 s timeout.

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Paolo Dettori <[email protected]>
curl -L follows redirects to any protocol, and GitHub's download URLs
always redirect. --proto '=https' bounds the first request and every
redirect, so neither the bundle nor its checksum can arrive over http.

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Paolo Dettori <[email protected]>
… gh (review)

contents: write was live through pnpm install and the vitest run, so a
compromised dependency's install script or test code could push tags or
edit releases. Build, test and checksum now run with a read-only token
and no persisted credentials, and hand the asset to a publish job that
holds contents: write but runs nothing but gh. The edge tag moves
through the git refs API, since publish has no checkout.

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Paolo Dettori <[email protected]>
@pdettori
pdettori force-pushed the feat/mocactl-installer branch from 34caa3c to 52b26a9 Compare October 9, 2026 13:14
@pdettori pdettori changed the title feat(mocactl): one-line install — bundled release asset and curl | sh installer feat(mocactl): one-line install via release asset and curl | sh Oct 9, 2026

@ingpaolodettori-dev ingpaolodettori-dev left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Follow-up review at 52b26a9. All items from the previous round are fixed. I verified each one against the code:

  • must-fix (PTY test under CI): the child now runs with CI: 'false' and CONTINUOUS_INTEGRATION: 'false' (ca17a30), and check passes on this head.
  • clipboard test timeout: an explicit 30_000 (ca17a30).
  • release workflow token exposure: done properly (52b26a9). The workflow default is contents: read, build checks out with persist-credentials: false and hands off through a pinned upload-artifact/download-artifact (both SHAs match their v7.0.1/v8.0.2 tags), and publish holds contents: write but runs only gh. The singular git/ref lookup for the edge tag is a good catch.
  • http downgrade: curl --proto '=https' (7ad50d8), enforced by the mock in every test case.

The rebase onto 0555d7f is clean (range-diff: commits 1–7 unchanged). All 14 checks are green, including the previously red trivy-scan.

One thing to watch after merge: the split mocactl-release.yml has no PR trigger, so its first real run is the push to main, which also creates the mocactl-edge tag and prerelease for the first time.

@pdettori
pdettori merged commit 2da423e into rossoctl:main Oct 9, 2026
14 checks passed
@pdettori
pdettori deleted the feat/mocactl-installer branch October 9, 2026 13:29
pdettori added a commit to pdettori/moca that referenced this pull request Oct 9, 2026
…#473)

Resolve server.ts in main's favour for the workload lifecycle — every
/workloads route and any run naming a workloadId now answers 501
workloads_unavailable (rossoctl#455) — keeping this branch's error-code changes on
top. The spec follows: the /v1/runs 404 loses workload_not_found, the 501
gains workloads_unavailable, and the sandboxPoolSelector note drops the
workload-resolver clause. routes.ts workload summaries note the 501.

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Paolo Dettori <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-for-ai-review Request automated AI code review from clawgenti

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants