Skip to content

fix(cli): say patch, not draft, in user-facing copy - #110

Merged
allisonmahmood merged 2 commits into
mainfrom
t3code/implement-issue-ninety-two
Sep 2, 2026
Merged

allisonmahmood merged 2 commits into
mainfrom
t3code/implement-issue-ninety-two

Conversation

@allisonmahmood

Copy link
Copy Markdown
Owner

The CLI still called the thing it publishes a draft in its output, its --draft flag, its errors, the README, the agent skill and the cache's code names, while the wire and the Patches glossary say patch. Anyone reading the CLI next to the API saw two words for one thing.

Now the CLI says patch everywhere a user or agent reads it: Uploaded patch / Patch ID:, the update-only flag is --patch <patch-id>, and the skill, README and CONTEXT.md follow. The cache file moves from drafts.json to patches.json, and the identifiers around it are renamed. A leftover drafts.json is refused with a rename hint instead of being silently ignored, because ignoring it would make the next upload create a new patch at a new URL rather than update the old one. The stored pre-rename draftId key is still read, since that is wire history rather than vocabulary. The patchy skill's lock hash is refreshed by hand.

The wire contract is unchanged. The packed end-to-end script is updated only where it reads the CLI's output and cache file; its internal variable names rename when a port touches them.

Closes #92

Written by Claude Fable 5.1 in Claude Code.

Draft is retired; the CLI's word for the thing it publishes is patch.
Output labels, the update-only flag (--patch), error text, the skill,
the README and the cache's identifiers now say so. The cache file moves
to patches.json; a leftover drafts.json is refused with a rename hint
rather than silently forgotten.

Closes #92

Co-Authored-By: Claude Fable 5.1 <[email protected]>
@github-actions github-actions Bot added area:ci CI, shared testing infrastructure, development scripts and tooling area:cli Touches the cli area area:docs Touches the docs area size:m 100-500 changed lines labels Sep 2, 2026
@allisonmahmood

Copy link
Copy Markdown
Owner Author

Code review — PR 110 vs #92

Two-axis review of d038ec5 vs origin/main, plus the extra asks: issue #92's intent, the method, and whether this is the small model.


Standards

Hard violations: none.

Hit-every-surface for this rename: --draft → --patch, labels, errors, cache file, and skill copy land in packages/cli/README.md, skills/patchy/SKILL.md (onboarding/style refs, welcome-patch.html), packages/cli/CONTEXT.md (retired-copy note dropped), and patchy-dev-loop. skills-lock.json hash matches sha256(skills/patchy/SKILL.md). ADR-0004 does not name the flag; --json shape and the exit ladder are unchanged. Leftover drafts.json is refused with rename/delete (reverse state). Wire / docs/API.md / docs/product.md N/A.

Effect: No Effect service findings. State keeps order / tag / make / layer; new LocalError({ message }) matches existing CliError + ADR-0004.

Judgement (baseline smells):

  • Mysterious Name — scripts/packed-cli-e2e.mjs still names the parsed CLI id draftId after matching Patch ID::
const draftId = result.stdout.match(/^Patch ID: ([a-z0-9]{12})$/m)?.[1];
assert.ok(draftId, `missing draft ID in CLI output:\n${result.stdout}`);

(metadata.drafts / assertStoredDraft stay; ADR-0002/0003 keep table draft until the patches port.)

  • Duplicated Code — State.ts exists vs readDocument both wrap fs.exists with opposite fallbacks (false vs true):
if (!(yield* fs.exists(file).pipe(Effect.orElseSucceed(() => true)))) {
const exists = (file: string) => fs.exists(file).pipe(Effect.orElseSucceed(() => false));
if (!(yield* exists(patchesPath)) && (yield* exists(retiredPatchesPath))) {

An exists fault on drafts.json treats it as absent and can skip the refuse path.


Spec

(a) Missing or partial

Spec: “Rename in every user-facing string.” examples/plan.html still talks about CLI publishing as drafts: “Draft viewer URLs…”, “create drafts and update drafts… cached draft unless --new”, table header “Draft URL”. Outside the CLI package, but it is user-facing copy that describes the CLI.

Listed CLI surfaces are done: messages (Uploaded patch / Patch ID:), --patch, errors, README, onboarding, welcome-patch.html, CONTEXT.md, skill (except the Postplan credit line), cache file patches.json.

Spec / Allison: “the cache's identifiers” vs “the code renames when the port touches it.” scripts/packed-cli-e2e.mjs still uses draftId, assertStoredDraft, metadata.drafts. Parse paths for CLI stdout / patches.json were updated; internals were not. Intentional, not a miss.

Stored draftId still read. Wire untouched (no packages/api / handler edits).

(b) Scope creep

--draft → --patch is in-scope: a user-facing flag is a user-facing string. Hard drop, no alias (unlike --anonymous in the same command). Breaking for agents; the spec asked for it.

Not in the issue: leftover drafts.json is refused with a rename hint instead of being read or auto-renamed. Issue only asked to rename cache identifiers. Small extra, fail-closed like the existing legacy-format path.

Not in the issue: skill Good-fits “stakeholder-facing drafts” → “stakeholder-facing updates”.

(c) Implemented but wrong

Spec: “the CLI's word for the thing it publishes is patch.” “Stakeholder-facing drafts” is ordinary English for preliminary docs, not that noun. “Updates” changes the skill’s advertised fit rather than replacing the product word.


Intent vs #92

After #16/#91, draft is no longer the unit. Agents drive the CLI, so they must see one word — patch — in messages, flags, skill, README, and cache names. The wire already says patch and stays put. Internal code still living on unported server/table names is not this ticket: “the code renames when the port touches it.”

That is what landed. --draft → --patch is the right call: the flag is the agent’s word for the unit. Hard drop (no alias, unlike --anonymous) is sharp, but “draft is retired” plus the updated skill is the contract. drafts.json → patches.json with refuse-closed leftover is the product-right door: silent ignore would mint a new URL; auto-migrate would contradict the house “we do not migrate old state files” rule. Keeping StoredPatch.draftId read-compat is wire history, not vocabulary. Leaving packed-e2e internals (assertStoredDraft, metadata.drafts) is correct per Allison; the local parseUpload field still named draftId is sloppy, not a product miss. welcome-draft.html → welcome-patch.html is right. “Stakeholder-facing drafts” → “updates” is the one English over-eager rename.

Verdict: this closes #92 honestly.


Method

Verdict: acceptable. Rename-in-place was the right scope. No redesign. Dual-file reads or a migrator would have been extra machinery for a same-shape rename.

StoredPatch with optional patchId/draftId is pre-existing, not added here — correct to keep. What this PR adds is one extra exists pair and a LocalError when drafts.json is still sitting there and patches.json is not. Silent ignore would mint a new URL; they correctly refused that.

The weaker choices:

  1. Cache filename. For a filename change of an identical document, fs.rename on first read is the smaller method: same remembered URLs, no agent action, no cacheMoved string/README paragraph. Applying the credential fail-closed policy here is ceremony, not a migration layer. Refuse-closed is still correct; it is just not the smallest method for a rename.
  2. --draft with no alias. Same command already keeps --anonymous as a no-op so old invocations keep working. --json success is the wire shape (patchId) so --json agents are fine; text-mode and --draft agents break (usage dump, exit 1). A hidden --draft alias mapping to --patch is the method this CLI already knows and did not use. Hard cut is simpler; the alias would have been the agent-native result.
  3. Both files present is !patches.json && drafts.json only. If both exist, drafts.json is ignored. This CLI cannot create that state itself; still untested, and the error copy says “the old file is still here” without refusing whenever it is.

Tests are focused, not slop: draftId piggybacked on the existing unavailable-target case; one new leftover-drafts.json test (no network, exact stderr, exit 1).


YAGNI / beautiful code

Verdict: mostly simple, with three blemishes.

The port is a straight substitution: --draft → --patch, drafts.json → patches.json, user copy to the product noun. Same command shape, same fail-closed cache, no new types or layers. That is the right size. Dual-key StoredPatch was already on main. cacheMoved is just the error string. No speculative generality.

Blemishes:

  1. The comment on retiredPatchesPath narrates the rename (“before patch replaced draft”). The invariant is enough: leftover drafts.json is the cache.
  2. parseUpload now matches Patch ID: but still returns draftId and asserts "missing draft ID". Server metadata.drafts is a different port; this local name is this one.
  3. Skill “stakeholder-facing drafts” → “updates” is English, not the product noun.

Summary

  • Standards: 0 hard violations, 2 judgement calls. Worst: exists failing open can skip the drafts.json refuse path and recreate the new-URL hazard the check exists to prevent.
  • Spec: 3 findings (1 partial surface, 2 small extras / one wrong English rename). Worst: examples/plan.html still describes CLI publishing as drafts, against “every user-facing string.”

Does not fail the PR. The vocabulary rename is the right size and closes #92. The three things worth a pass if you touch it again: restore “stakeholder-facing drafts” (or say “pages”), rename parseUpload’s local draftId, and either auto-rename drafts.json on first read or refuse it whenever it exists — not only when patches.json is absent.

Review follow-ups: the old cache file is refused on sight rather than only
when patches.json is absent, and a faulting exists() fails closed. The
packed e2e script's parsed id is a patchId, the skill's plain-English
"stakeholder-facing drafts" is restored, and the example page's copy about
the CLI says patch.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
@allisonmahmood

Copy link
Copy Markdown
Owner Author

Review follow-up, verified against the source, in the second commit.

Fixed

  • exists failing open on drafts.json. Real. The check now refuses a leftover drafts.json whenever it exists, with exists() faults failing closed like readDocument does. That also answers the both-files-present gap: there is no longer a second condition, and the test writes both files to prove it.
  • parseUpload returning draftId after matching Patch ID:. Real. The parsed id and its consumers in scripts/packed-cli-e2e.mjs are patchId now; the server-metadata names (metadata.drafts, assertStoredDraft) stay on the unported table names.
  • "stakeholder-facing drafts" → "updates". Agreed it was over-eager; that line is plain English, not the product noun. Restored, lock hash refreshed.
  • examples/plan.html still describing CLI publishing as drafts. Agreed it is user-facing copy about the CLI. The five lines now say patch.
  • Comment narrating the rename. Tightened to the invariant.

Kept as is

  • Refuse-closed rather than auto-renaming drafts.json. An fs.rename needs a guard for the case where patches.json already exists, and then a policy for which file wins, which is more machinery than one error string. Refusing on sight matches how the CLI already treats retired state files, and the message names the one-line fix.
  • --draft dropped with no alias. --anonymous is kept as a no-op because it changed behavior, not vocabulary. A hidden --draft alias would keep the retired word alive in the surface the issue exists to clean; --json consumers are unaffected and the skill teaches --patch.

Lint, typecheck, the CLI suite and the packed end-to-end script pass locally on the new commit.

Written by Claude Fable 5.1 in Claude Code.

@allisonmahmood
allisonmahmood merged commit 2854acf into main Sep 2, 2026
6 checks passed
@allisonmahmood
allisonmahmood deleted the t3code/implement-issue-ninety-two branch September 2, 2026 13:54
allisonmahmood added a commit that referenced this pull request Sep 2, 2026
- delete speaks patch: `--patch <patch-id>`, "Deleted patch", patches.json
- neither-target and both-target are separate local errors
- keyless message says publishing key, per the CLI glossary
- vitest proves forgetPatch drops every file pointing at the patch
- packed e2e delete step does its own upload instead of relying on script order
- skill and README examples name delete where they listed whoami/upload

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:ci CI, shared testing infrastructure, development scripts and tooling area:cli Touches the cli area area:docs Touches the docs area size:m 100-500 changed lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

cli: say patch, not draft, in user-facing copy

1 participant