# Word docs with AI

> How AI reads and changes a Word doc: the outline first, then one edit_word call that edits it directly.

Your AI reads a Word doc the way a person skims one: the outline first, then only the part it needs. It changes the doc in one call, and its edits apply directly, as they do in every other kind of doc.

## How it reads

`get` gives the outline: the title, version, pages and words, then each heading with its ID, page and the words in its section. A 200-page contract is about 2 KB. From there it reads only what the change needs:

| Read | What comes back |
|---|---|
| `blocks: ["h3"]` | A heading and its section, or any block |
| `from: "p40"` | On from a block, up to 8,000 words |
| `pages: "4-6"` | Those pages |
| `find: ["fees"]` | The blocks with those words, with page and a snippet |
| `suggestions: true` | The open suggestions: who, what and where |
| `since: 12` | What changed after version 12 |
| `asks: true` | What people asked the AI to do |

Each line starts with the block's ID (`h3`, `p14`, `t2`). A suggestion shows as `{++added++}[sg3]` or `{--deleted--}[sg3]`.

## How it changes

`edit_word` takes every change at once, by block ID, at the version it read: up to 500 ops, all or none. The answer has the new version, the new IDs and each changed block's new text.

| Op | Does |
|---|---|
| `replace` | Words in a block, or across the doc with `all: true` |
| `insert` | Markdown after or before a block |
| `set` | A block's style, alignment or list |
| `delete`, `move` | Blocks; a heading moves with its section |
| `table`, `cells` | A new table, or cells in one |
| `image`, `page_break` | A picture or a page break |
| `page`, `header`, `footer` | Page size and margins, and what repeats on each page |
| `accept`, `reject` | Its own suggestions |

The AI's edits apply directly. To review them first, set **⋯ → AI changes** to **Suggest**: its edits then show as suggestions with its name, and you accept or reject them. Moves, page setup, headers and footers always apply directly.

## Asks

Select text and ask the AI. `get` with `asks` lists what's waiting; the AI answers with `edit_word` and `answers`, which closes the ask.

## CLI

```sh
dockito get <doc>                                   # the outline
dockito get <doc> --find "notice period" --pages 4-6
dockito get <doc> --suggestions                     # open suggestions
dockito edit-word <doc> ops.json --base 12          # apply ops.json at v12
dockito edit-word <doc> ops.json --base 12 --dry-run
dockito get <doc> --asks                            # what people asked
```

## What to ask

- "Change the notice period to 45 days everywhere in the flat rental agreement."
- "Add a fees section after Scope, with a table of the three phases."
- "Tighten section 4 and accept your earlier suggestions there."
