Skip to content

Implement the local-first woj CLI - #53

Merged
JacobLinCool merged 1 commit into
mainfrom
a-issue-42-woj-cli
Aug 20, 2026
Merged

Implement the local-first woj CLI#53
JacobLinCool merged 1 commit into
mainfrom
a-issue-42-woj-cli

Conversation

@JacobLinCool

Copy link
Copy Markdown
Member

Closes #42.

What

Adds @wasm-oj/cli — one woj executable covering the Student and Organizer journeys with the same product boundaries as the web application.

  • Local boundary (init, build, run, test, bench, watch, judge, toolchain, config, cache, doctor): uses only bytes already on the machine. --offline rejects every network-capable command before dispatch.
  • Remote boundary (auth, problem, submit, submission, contest, performance, organizer …): browser-approved PKCE device login; the bearer lives only in the OS credential store (@napi-rs/keyring), with no plaintext file fallback.
  • Stable exit codes 0–7 as a public contract, plus --json for machine-readable output.
  • Retires the wasm-oj-collection bin; woj organizer collection … replaces it, and .github/actions/woj now invokes it via @wasm-oj/cli.

Server side

  • migrations/core/0018_cli_auth.sql — device-authorization flows and access tokens. D1 stores only the S256 challenge and the token hash; a flow can mint at most one token.
  • Bearer transport added to session resolution, and explicitly fenced out of every browser-only privileged mutation (organizer applications, admin review, release activation, profile, submission visibility, invite-code rotation, account erasure, GitHub App install). worker/browser-mutation-boundary.test.ts locks that boundary in.
  • Same-origin Turnstile approval page so woj submit can retry the identical request after the short-lived allowance is granted.

Java toolchain parity

Rebased onto main after #51 landed the Java WASI toolchain. Carried it through the CLI surface:

  • CLI_TOOLCHAIN_DESCRIPTORS now mirrors all six public toolchain packages (woj toolchain list/info/fetch/verify java-teavm work).
  • WORKSPACE_PACKAGE_PATTERN externalizes @wasm-oj/toolchain-java during library builds.
  • Corrected stale "five toolchain packages" counts in docs/releasing.md and docs/versioning.md.

Java stays toolchain-only here: BuiltinLanguage, problem starter templates, and allowedProfiles do not carry java, so it is deliberately not a woj init/woj problem pull workspace language yet.

Verification

  • pnpm run ci:verify — 178 test files, 883 tests passing
  • pnpm run library:verify — 13 packed packages, including @wasm-oj/cli, in a clean NodeNext consumer
  • docs:verify, licenses:verify, contract:verify, package-manager:verify, github:verify — all pass
  • Manual smoke: woj --version, woj --help, woj toolchain list (java present), woj init, offline fence, unknown-command and missing-runtime exit codes

Note

parseCli consumes -- while extracting global options, so the leaf-level -- handling never sees it. No current command needs -- (program args use repeatable --arg), so this is latent rather than a live defect.

https://claude.ai/code/session_01PHk8gF2Y12sSzyTGaFUi68

Add @wasm-oj/cli, the single `woj` executable for Students and Organizers.
Local commands (init/build/run/test/bench/watch/judge/toolchain/config/
cache/doctor) never touch the network; remote commands authorize through a
browser-approved PKCE device flow and keep the bearer only in the OS
credential store. Retire the `wasm-oj-collection` bin in favour of
`woj organizer collection`.

Server side adds the CLI login flow tables and endpoints, a bearer transport
that is fenced out of every browser-only privileged mutation, and a
same-origin Turnstile approval page the CLI can retry against.

Carry the Java WASI toolchain into the CLI catalog so `woj toolchain` mirrors
the six toolchain packages the platform now ships.

Claude-Session: https://claude.ai/code/session_01PHk8gF2Y12sSzyTGaFUi68
@JacobLinCool
JacobLinCool merged commit 10b97a5 into main Aug 20, 2026
1 check passed
@JacobLinCool
JacobLinCool deleted the a-issue-42-woj-cli branch August 20, 2026 14:28
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.

[Feature] Define the local-first woj CLI and role-based workflows

1 participant