Repository navigation
feat(mocactl): one-line install via release asset and curl | sh - #473
Conversation
ingpaolodettori-dev
left a comment
There was a problem hiding this comment.
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'); |
There was a problem hiding this comment.
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.)
There was a problem hiding this comment.
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]); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Done in ca17a30: the clipboard probe test now has an explicit 30_000 timeout.
| branches: [main] | ||
|
|
||
| permissions: | ||
| contents: write |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 uploadsmocactl.mjsand.sha256as themocactl-assetartifact.publish(contents: write): downloads that artifact and runs onlygh, 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.
| 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" || |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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]>
34caa3c to
52b26a9
Compare
ingpaolodettori-dev
left a comment
There was a problem hiding this comment.
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'andCONTINUOUS_INTEGRATION: 'false'(ca17a30), andcheckpasses on this head. - clipboard test timeout: an explicit
30_000(ca17a30). - release workflow token exposure: done properly (52b26a9). The workflow default is
contents: read,buildchecks out withpersist-credentials: falseand hands off through a pinnedupload-artifact/download-artifact(both SHAs match their v7.0.1/v8.0.2 tags), andpublishholdscontents: writebut runs onlygh. The singulargit/reflookup 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.
…#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]>
Summary
Anyone pointed at a MOCA server can now install
mocactlwith one line and run it by name. There is no clone, nopnpm installand noalias:docs/specs/2026-10-08-mocactl-installer-design.md(registry entry MU1.2)How it works
What's in it
packages/mocactlmocactl --version(also-V) prints a release tag,edge-<sha>, ordev, and reads no config and makes no network call first.build.mjsuses esbuild to bundle the client and every runtime dependency into onedist/mocactl.mjsof about 5 MB, with a node shebang and the version baked in.createRequirebanner is needed: without it,--helpworks but the TUI crashes at startup onDynamic require of "assert"(from Ink'ssignal-exit).pnpm --filter @moca/mocactl buildruns it. The tsx path from a checkout (bin/mocactl.mjs) is unchanged.test/bundle.test.tsbuilds the bundle and runs it from a temp dir with nonode_modulesin reach. It checks:--versionand--help;"type": "commonjs"package.json, with a control case showing an extensionless copy prints nothing.scripts/install-mocactl.sh, a POSIX sh installer built forcurl | sh, followingdeploy/compose/install.shMOCACTL_VERSION(latestby default,edge, orvX.Y.Z),MOCACTL_INSTALL_DIR(~/.local/binby default) andMOCACTL_BASE_URL.curl --proto '=https', so redirects can't downgrade to http either.sha256sum, orshasumon stock macOS.PATH, it prints the line to add.scripts/tests/install-mocactl.test.shmockscurlandnodeon a narrowed PATH and covers 10 cases, including:mocactlthat prints no version.make test-deploy, and the shellcheck CI job now coversscripts/..github/workflows/mocactl-release.ymlrelease: publishedand onpushtomain. 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 handsmocactl.mjsand its.sha256topublishas a workflow artifact.publish(contents: write): runs onlygh, with no checkout and no pnpm. It attaches the asset to the release, or moves themocactl-edgetag through the git refs API and updates the prerelease.Docs
MOCACTL_VERSION=edge, since that cluster is built frommain.CLAUDE.mdare updated.After merge
mocactl.mjsand can't be backfilled, because its source has nobuild.mjs. Until a release is published after this merge, the defaultlatestchannel 404s, and the error tells the user to tryMOCACTL_VERSION=edge.maincreatesmocactl-edge. Not verified yet: whether a tag ruleset blocks the workflow's force-push of themocactl-edgetag withGITHUB_TOKEN.Testing
CI=true make test,make typecheckandmake lint: green.CI=trueis how GitHub Actions runs them, and Ink renders differently under CI.dashas/bin/sh(Ubuntu's).actionlintandshellcheck -S warningare clean.--filter '@moca/mocactl...') builds and passes the bundle test from agit archivecopy with no pi-fork.Deferred (minor, from review)
--clobbercan briefly 404 the edge asset mid-update. The installer's hint says to re-run.EXITtrap, leaving a temp dir behind.~/.bashrcrather than~/.bash_profile./prints the PATH hint even when it's already onPATH.Assisted-By: Claude (Anthropic AI) [email protected]
🤖 Generated with Claude Code