Skip to content

feat(cli): patchy on effect/unstable/cli with the agent contract #78

Closed

Description

@allisonmahmood

Problem

The CLI is commander with hand-rolled exit codes and its own HTTP calls. It moves to effect/unstable/cli on the derived HttpApiClient and promises the contract decided on CLI contract on Effect cli.

Do

  • Commands auth set, whoami, status, validate, upload (and delete if #41 has landed) as Commands; all HTTP through @patchy/api's client on NodeHttpClient.
  • Exit codes: one CliError union, each tag carrying kind: "local" | "rejected" | "unreachable"; one table kind → 1 | 2 | 3; 130 on interruption; nothing else. HTTP status → kind: 4xx rejected, 5xx / connect / timeout / unparseable unreachable.
  • --json global flag: success one stdout document in the api shape, stderr empty (upload warnings in warnings: []); failure { ok: false, error, kind } on stderr, stdout empty.
  • --api-url global flag feeding one Instance service: --api-url > .local/dev/env (walk up from cwd) > PATCHY_API_URL > ~/.patchy > default; exposes URL + source; status --json reports it and mutating commands print "target came from …".
  • Signals: Effect's mapping (SIGINT/SIGTERM → interrupt → 130, no 128+n); the hidden-token prompt's terminal restore as an acquireRelease finalizer.
  • Built-ins: Effect's defaults stay (--help, --version printing the bare version, --completions, --wizard, --log-level); defects render as one Unexpected error: <message> line, exit 1, stack only at --log-level debug. Starting point: packages/effect-slice/src/cli.ts on prototype/effect-slice (CliOutput.layer overrides).
  • Bundle: esbuild with the createRequire banner (packages/effect-slice/scripts/build-cli.mjs); skills/ still copied in.
  • e2e (scripts/packed-cli-e2e.mjs): keep asserting contract — exit codes per the ladder, one-line stderr, bare --version, token never in argv/output, --json shapes; move the 130/143 signal probes and process-group assertions to harness tests or drop them.
  • ADR CLI contract for agents in docs/adr/ (the ladder + the .local/dev/env precedence); move the Publishing glossary into packages/cli/CONTEXT.md (agents primary operator, developers secondary). Promote the language-service warnings to error for the package. Update packages/cli/README.md and skills/patchy/SKILL.md for the exit codes and --json.

Done when

The packed-CLI e2e passes on the ladder; pnpm dev then patchy upload in the worktree targets the local instance with no env set; commander is gone from the lockfile.

Decisions implemented

Spec §5; CLI contract on Effect cli; Local dev environment (precedence); vertical slice.


Filed from the Effect v4 port spec (#68) by the map task Write the port spec and file the build tickets.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:cliarea:docsready-for-agent

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions