Skip to content

Agent-authoring: --scaffold, schema, render --redact fix + Claude Code skill#1

Merged
russ merged 4 commits into
mainfrom
feat/agent-integration
Jun 9, 2026
Merged

Agent-authoring: --scaffold, schema, render --redact fix + Claude Code skill#1
russ merged 4 commits into
mainfrom
feat/agent-integration

Conversation

@russ

@russ russ commented Jun 9, 2026

Copy link
Copy Markdown
Owner

Make PatchStory's core thesis — the AI-authored story is separate from the renderer — a first-class workflow, so any coding agent (not just the built-in anthropic adapter) can author the walkthrough. The agent reads the diff in repo context, so the narrative is better than a one-shot API call, and no API key is involved.

CLI primitives (836b4d9)

  • --scaffold on the source commands (diff/commits/file/github) emits the editable pr-walkthrough.json (the IR) instead of rendering a site — to a file (-o) or stdout. Implemented as a flag, symmetric with --single-file/--zip, so it reuses all source detection.
  • --emit-diff <file> (with --scaffold) also writes the exact resolved diff bytes, so the same input can be passed to render --diff with hunk line refs still aligned.
  • schema command prints the canonical WALKTHROUGH_JSON_SCHEMA for validation.
  • Fix render --redact — it was a no-op: redaction only ran inside buildWalkthrough (the source paths), never in renderCommand, which parses the --diff file itself. It now calls redactParsedDiff on the parsed diff, so secrets are masked in the embedded output and the "masked N lines" count is truthful.

Adds tests/cli.test.ts (spawns the built bundle; skips if unbuilt — CI builds first) covering schema output, scaffold validity + byte-identical --emit-diff, and the render --redact masking as a regression guard.

Claude Code skill (db8063b)

integrations/claude-code/ ships a ready-to-install skill that runs the flow: resolve source → patchstory scaffold --emit-diff → Claude authors the narrative → render --redact --single-file --open. The new primitives keep it thin (no re-implemented redaction, no scaffold hacks). The top-level README's "Author the story with your own AI agent" section documents the agent-agnostic recipe and links here.

Verification

npm run build && npm run typecheck && npm test — 23/23 green. Exercised end-to-end in both github and diff modes.

🤖 Generated with Claude Code

russ and others added 4 commits June 9, 2026 15:18
…ct fix

Make the "AI authors the story, renderer stays separate" thesis a first-class
CLI flow so any coding agent (not just the built-in anthropic adapter) can drive
patchstory:

- `--scaffold` on the source commands (diff/commits/file/github) emits the
  editable pr-walkthrough.json (the IR) instead of rendering a site. `--emit-diff`
  additionally writes the exact resolved diff bytes, so the same input can be
  passed to `render --diff` with hunk line refs still aligned.
- `schema` command prints the canonical WALKTHROUGH_JSON_SCHEMA for validation.
- Fix `render --redact`: it was a no-op, because redaction only ran inside
  buildWalkthrough (the source paths), never in renderCommand — which parses the
  --diff file itself. Now render calls redactParsedDiff on the parsed diff, so
  secrets are masked in the embedded output and the "masked N lines" count is
  truthful.

Adds tests/cli.test.ts covering schema output, scaffold validity + byte-identical
--emit-diff, and the render --redact masking (regression guard). Skips when the
bundle isn't built; CI builds before testing.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
A ready-to-install skill that drives patchstory with Claude authoring the
narrative (the JSON IR), built on the new CLI primitives so it stays thin:

- scripts/collect.sh resolves the source (branch's open PR, else branch-vs-base,
  or an explicit PR#/URL/range/branch) and runs a single `patchstory scaffold
  --emit-diff` to produce skel.json + the exact diff. No more re-implementing
  redaction or rendering a whole site just to get a skeleton.
- SKILL.md: the authoring rubric + the scaffold -> author -> render --redact
  --open flow. References `patchstory schema` as the contract.
- README.md: symlink/copy install, prerequisites (Linux/macOS, node/git/gh).

The top-level README's "Author the story with your own AI agent" section now
links here; the recipe is agent-agnostic, this is the turnkey reference impl.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Releases the agent-authoring CLI primitives (--scaffold/--emit-diff, schema,
and the render --redact fix) to npm. publish.yml publishes packages/cli on a
GitHub Release via OIDC; npm refuses to re-publish 0.1.2, so the bump is required.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Lets users install with the marketplace instead of a manual symlink:

    /plugin marketplace add russ/patchstory
    /plugin install patchstory@russ-patchstory

- .claude-plugin/marketplace.json (repo root) catalogs the plugin
  (source: ./integrations/claude-code/patchstory).
- integrations/claude-code/patchstory/.claude-plugin/plugin.json manifest.
- Move the skill into the plugin skill layout: skills/patchstory/{SKILL.md,
  scripts/collect.sh} (history preserved via git mv).
- SKILL.md resolves its helper via $CLAUDE_PLUGIN_ROOT with manual-install
  fallbacks, since CLAUDE_PLUGIN_ROOT isn't guaranteed for model-run Bash.
- READMEs document the plugin install (primary) and manual symlink.

Validated with `claude plugin validate .` (passed).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@russ russ merged commit a1fbdbd into main Jun 9, 2026
1 check passed
@russ russ deleted the feat/agent-integration branch June 9, 2026 22:38
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.

1 participant