Skip to main content

Edit content in any format, faithfully

Goal: edit the text inside a file without touching its structure (a Word document, a JSON catalog, a Markdown guide, or any other format kapi reads). The result is the same file (same keys, same styles, same inline codes) with only the prose changed. You (or your assistant) do the rewriting; kapi parses the format, enforces a faithful round-trip, and writes the result back. kapi sends no content to a model for the rewrite, and you need no project, provider or credential.

Walkthrough videoPending recording

A short walkthrough inspecting a file's blocks, previewing an edit as a diff, applying it in place, and verifying the result with a check, showing how only the leaf text changes while the format round-trips.

View scene script ↗
  1. Read the blocks. Open the file in your project: Blocks lists each text block as the engine reads it; Preview shows the rendered document with the source ↔ target toggle.
  2. Edit a block in place. In Preview, click a block and choose Edit. Formatting and placeholders stay as chips you type around, and saving writes the file through its format, leaving every other byte as it was.
  3. Edit translated text in Review. For target-language blocks you can also edit in the Review queue, then approve; the write goes through the same round-trip.
  4. Rewrite many blocks at once with apply. Drive the inspect → apply loop from the CLI tab or a connected assistant. Then reopen Preview to see that headings, styles and inline codes are intact, and click Run on everything on the project's Overview to confirm the gate.

What refuses an edit​

apply writes a change set only when every operation in it holds. When one is refused, nothing in the change set is written, the refused operation names why, and the others report not_applied:

  • stale: the block's revision differs from the if_match you sent; it changed since you read it. The result carries the current revision and text to rebase on.
  • guard: an edited text that drops, invents, duplicates, or unbalances an <x id="…"/> token, or flat text in place of a block holding a plural or select. Edit one branch of a plural with the path that inspect lists under structures.
  • not_found: the reference names no document or block, or a find matches nothing; the block may have been removed or renamed since you read it.
  • unsupported: the block takes no edit, such as a Markdown code block, which inspect lists with no ops.

A refusal exits with code 3, distinct from an operational error: read the affected blocks again and resend with fresh revisions. A change set that does not decode exits 2 before anything is read. Resending a change set that landed writes nothing: the revisions it names have moved, so it is refused as stale with each block's current text. An operation whose revision still holds and whose text the block already has reports unchanged. The same change set can carry a term or a content memory pair (Create content) or a review decision (The kapi loop), applied after the content; kapi apply --schema prints every operation.

What "faithfully" means​

Only the extracted prose changes; everything outside it (.docx character styles and table borders, JSON keys and non-string values, Markdown headings and fences) is reproduced byte for byte. So you can edit binary office formats (.docx, .pptx) safely; kapi formats marks such formats faithful in its Edit column.

In a project​

In a kapi project, kapi inspect and kapi check run against the recipe's declared content with no file argument. inspect names each document by its project-relative path and lists each translation among a block's editions, and kapi apply resolves those references in the same project.

Next​

  • Checks: rule families, profiles, scoring, and the gate exit codes.
  • Create content: the author → parse → check loop and the mixed change-set.
  • Feed content to your AI: the same anchored blocks as an ingestion stream.