Repository navigation
feat(cli): patchy on effect/unstable/cli with the agent contract - #89
Conversation
|
Two-axis review of PR 89 vs merge-base Commits: StandardsSkip: namespace imports, hoisted Hard (documented)
Effect.catchIf(isCliError, (error) => fail(error.message, error.kind)),Fix:
const fields = { message: Schema.String, cause: Schema.optionalKey(Schema.Defect()) };
Effect.catchIf(
(error) => error.message !== credentialErrors.legacy,
() => Effect.succeed({ hosts: {} as Record<string, unknown> })Fix: a structured
const local = Layer.provideMerge(Instance.layer(process.cwd()), State.layer);Fix: resolve cwd from
Judgment (baseline smells)
SpecIntent vs checklist. The three product intents mostly land: agents can branch 1/2/3; (a) Missing or partial
(b) Scope creepNo new commands. Port carries existing product ( (c) Implemented but wrong
MethodVerdict: mostly right. The cut matches the contract (who acts → kind → exit), the ticket’s one Instance service, and the prototype gotchas.
YAGNI / beautyMostly beautiful — services where there are two consumers, Git as a module, wire encodes at the top, extra machinery is almost all existing contract (tokens, Keep: Cut / simplify if you touch this again:
Tests (contract coverage)Pinned well: bare Gaps vs #78 / ADR-0004 (not a demand for more smoke tests):
Deleting the PTY/readline tests was correct. Summary: Standards 5 hard + 3 judgement (worst: |
|
Review triage — fixed in 26be75c on this branch (lint, typecheck, format, Addressed
Dismissed, with reasons
Not adding an Ready to merge once #88 lands. |
|
CI: lint, both test matrices, cli-smoke, dependency-review and label pass. The |
551b732 to
3fe4e98
Compare
26be75c to
c8c81ab
Compare
3fe4e98 to
6d917e2
Compare
The CLI was commander with hand-rolled exit codes and its own fetch calls,
so an agent could not tell its own mistake from the instance's refusal from
a network that was down.
It now runs on effect/unstable/cli over the client derived from @patchy/api.
One CliError union carries a kind (local, rejected, unreachable) and one
table maps it to exit 1, 2 or 3; 130 is Effect's interruption; a defect is
one 'Unexpected error:' line. --json and --api-url are global flags; a
failure under --json is { ok: false, error, kind } on stderr. One Instance
service resolves the target: --api-url, then the worktree's .local/dev/env
(with its seeded token), then PATCHY_API_URL, then the saved config, then
the default. The hidden prompt is Effect's, so the terminal restore is a
scope finalizer. The bundle carries Effect with the createRequire banner and
commander leaves the lockfile. The language-service rules are errors for
the package, and the packed-CLI e2e asserts the ladder and the --json shapes.
…ead it The exit-code ladder, --json, the --api-url precedence with the dev env, and the signal mapping as one ADR; README, skill, onboarding table and the Publishing glossary updated to match.
Catch the whole CliError channel with Effect.catch; refuse the retired credentials file by its shape instead of matching an error message; take the working directory from the entrypoint as a Cwd service; carry tokens as Redacted from the environment, the dev env and the store; share the environment-token chain between whoami/upload and status; let Ctrl-C or EOF in the hidden prompt interrupt (exit 130) instead of exit 1; drop the unused Git metadata export; add the SIGINT-exits-130 contract test.
c8c81ab to
51c2e09
Compare
Problem
The CLI was commander with hand-rolled exit codes and its own
fetchcalls. Everything exited 1, so an agent could not tell its own mistake from the instance's refusal from a network that was down without parsing prose, and a worktree with a runningpnpm devstill needed the environment set to publish to it.Solution
patchynow runs oneffect/unstable/cliover the client derived from@patchy/api, and promises the contract from #60 (recorded as ADR-0004):CliErrorunion, each tag carrying akind(local|rejected|unreachable), one table to 1 / 2 / 3; 130 is Effect's interruption; a defect is oneUnexpected error:line (stack at--log-level debug). Nothing else.--jsonand--api-urlare global flags. Success is one stdout document in the wire shape; failure is{ ok: false, error, kind }on stderr with stdout empty.Instanceservice resolves the target:--api-url>.local/dev/env(walked up from cwd, with the tokenpnpm devseeded) >PATCHY_API_URL> saved config > default.status --jsonreports the source anduploadprints "target came from …".pnpm devthenpatchy uploadin the worktree publishes with nothing set.Prompt.password, so the terminal restore is a scope finalizer and the readline/raw-mode choreography and its PTY tests are gone.createRequirebanner, commander leaves the lockfile, the language-service rules are errors for the package.Instanceand a subprocess contract suite (ladder, streams,--jsonshapes, token never in output, fail-closed state files). The packed-CLI e2e now asserts the exact rungs and the--jsondocuments; its signal probes stay as harness tests.Deviations from the ticket, named: a parse error still prints usage on stdout before the one stderr line (Effect renders help inside
Command.run); under--jsonthe mint announcement is the one thing on stderr besides a failure, so the agent can still relay it; the 404-on-update hint keys on the wire'sPatch not found.sentence because refusals reach the client as plain structs without a status; user-facing--draft/ "Draft ID" copy is kept since the skill and e2e read it.Stacked on #88 (
feat/server-httpapi).Closes #78
Built by Claude Fable 5 via Claude Code.