# Prompt Studio

The reference host turns a support-summary template into an editable draft. A reviewer can inspect the unified diff, ask for a deterministic evaluation and publish the exact bytes tied to an approved preview. The CLI and reference console share the HTTP service. Same-process MCP tools receive a scoped command handler.

## Run a review

Start `uv run ancrel-prompt-studio serve` from `packages/backend/python`. Run `uv run ancrel-prompt-studio draft open` to open a draft, then use `prompt synthesize_candidate` with its bundle. The initial template fails six next-action checks. A revised draft can pass all twelve cases. The CLI exposes the complete workflow through `ancrel-prompt-studio skill`.

## Adapt a new studio

| Adapter | Responsibility |
| - | - |
| Ontology | Normalize files, validate references, hash material and produce a reviewable diff. |
| Evidence and evaluator | Freeze cases and candidate digests, report verdict, trust and coverage. |
| Domain verbs | Describe and authorize tools for inspecting and modifying a candidate. |
| Commit and policy | Verify the external pre-image, authorize evidence and atomically replace the target. |

## Runtime profile

The default host runs a fenced SQLite task worker and stores accepted revisions, command receipts and release approvals in a local kernel database. The evaluator processes a pinned artifact in a bounded subprocess. Restart with the same workspace to resume questions or reconcile a file write interrupted before its database commit.

Inspect `release status PREVIEW` after a restart. A reconciled release retains its original approval. A held conflict preserves the third-party target for review. The reference console follows the durable task cursor across disconnects. The example README lists storage paths, the loopback actor convention and enforceable sandbox limits.

## Wire contract

[Schema](https://ancrel.prts.dev/v/0.3.0/schemas/cli-envelope.v1.json) · [Example](https://ancrel.prts.dev/v/0.3.0/examples/be.rsi-studio-template/walkthrough.sh)

```sh
sh examples/be.rsi-studio-template/walkthrough.sh
```

```sh
#!/bin/sh
# Run against a fresh local host. Every mutation travels through its HTTP client.
set -eu
cli() { ancrel-prompt-studio "$@" --json; }
draft=$(cli draft open)
draft_id=$(printf '%s\n' "$draft" | jq -er '.data.draft_id')
base=$(printf '%s\n' "$draft" | jq -er '.data.base_revision')
payload=$(printf '%s\n' "$draft" | jq -c '{bundle:.data.bundle}')
candidate=$(cli prompt synthesize_candidate --body "$payload" | jq -ec '.data')
cli draft patch "$draft_id" --base-revision "$base" --expected-draft-revision 1 --body "$candidate" >/dev/null
cli draft diff "$draft_id" | jq -r '.data.diff'
code=0
waiting=$(cli eval run --draft-id "$draft_id" --ask) || code=$?
test "$code" -eq 1
printf '%s\n' "$waiting" | jq -e '.error.code == "WAITING_INPUT"' >/dev/null
question=$(printf '%s\n' "$waiting" | jq -er '.data.intervention_id')
target=$(printf '%s\n' "$waiting" | jq -er '.data.target_revision')
result=$(cli intervention respond "$question" --target-revision "$target" --response continue --actor reviewer)
printf '%s\n' "$result" | jq -e '.data.evaluation | .verdict == "passed" and .unique_case_count == 12' >/dev/null
eval_id=$(printf '%s\n' "$result" | jq -er '.data.evaluation.eval_run_id')
task_id=$(printf '%s\n' "$result" | jq -er '.receipt.task_id')
cli task events "$task_id" --follow
preview=$(cli release preview --draft-id "$draft_id" --eval-run-id "$eval_id")
preview_id=$(printf '%s\n' "$preview" | jq -er '.data.preview_id')
cli release publish --preview-id "$preview_id" --actor reviewer --reason 'Reviewed twelve synthetic summaries'
```
