export declare const platformSelfUpdatingDocsMdxTemplate = "---\ntitle: \"Agent Sync\"\ndescription: \"Agent Sync links documentation pages to the code they describe and rewrites them when that code changes, keeping your docs self-updating.\"\ndate: \"2026-07-24\"\nupdated: \"2026-08-01\"\ncategory: \"Editing\"\ncategoryOrder: 1\norder: 2\nsection: \"Platform\"\n---\n# Agent Sync\n\nDocumentation goes stale because code moves and nobody notices. **Agent Sync** closes that gap: every page can be linked to the source files it documents, pinned to the exact commit it was written from. When those files change, the page is flagged as **drifted** - and the agent can rewrite it for you.\n\nYou'll find it under **Agent Sync** in the project sidebar.\n\n## The four views\n\n| View | What it's for |\n| --------- | ----------------------------------------------------------------------------- |\n| **Agent** | Ask questions about your code, or ask the agent to write and update pages |\n| **Map** | Each page beside the sources it came from, with its sync state |\n| **Table** | The same information as a dense, sortable list |\n| **Drift** | The queue of pages whose sources have changed |\n\nA badge on the sidebar link counts the pages currently waiting for attention.\n\n## Asking the agent for docs\n\nThe **Agent** view is a chat. Choose a **source repository** and a **scope** - the whole repo, a folder, or a single file - then either ask a question or ask for a change.\n\n**Questions are answered in the chat.** Ask what a module does, which pages cover a feature, or whether a guide still matches the code, and the agent reads the source and replies without touching your documentation:\n\n> Which pages would break if we renamed the refresh-token endpoint?\n\n**Asking for a change starts a run.** The agent researches the code, plans the pages, and writes them:\n\n> Document the auth module - cover sessions, refresh tokens and the error codes.\n\n> Update the buttons page so it matches the current component.\n\nReplies are threaded, so a follow-up builds on what came before - and agreeing to something the agent suggested is enough to start the work, without repeating yourself:\n\n> Now do the same for the CLI.\n\nA turn that changes documentation shows the steps the agent took, the pages it changed, the sources it read, and what the run cost. You can switch between conversations, rename them, or start a fresh one.\n\nA run commits itself only when every page it wrote is set to auto-update and untouched by hand. Anything else is staged alongside your own edits and waits, and you can settle it from the conversation or from the project's [Publish](/platform/publishing) modal - either way, the other side is kept in step.\n\n\n An empty result is a valid answer. If the docs already describe the code accurately, the agent will say so rather than rewriting pages for the sake of it.\n\n\n## Linking pages to sources\n\nA page needs at least one source link before drift can be detected. There are three ways to create them:\n\n\n \n Every page the agent produces records the files it was derived from. Sites created by [Import from GitHub](/platform/import-from-github) arrive fully linked.\n \n \n **Auto-link code** scans your existing pages, proposes matching files from every source repository, and lets you approve the links in one batch. It's a good way to bootstrap a hand-written site.\n \n \n Open an MDX page in the editor, select **Source links** in the toolbar, then choose a repository and match one file, a folder, or a path pattern. Hand-written pages can be tracked this way without ever having been generated.\n \n\n\n## Auto-link existing pages\n\nUse **Auto-link code** in the Agent Sync header when you already have documentation but it is not connected to its source code yet.\n\n\n \n Select **Auto-link code**. Doccupine reads the committed Markdown and MDX pages in your docs repository that do not have source links yet, then compares them with file paths from all your source repositories. Pending editor changes are not included until they are published.\n \n \n Suggestions are grouped by page. A strong match means the page names or references the file, so it starts selected. A weaker name match is left unselected for you to confirm. You can change any checkbox, and existing source links are never replaced.\n \n \n Select **Link selected (N)**. Each approved file is recorded against the page and pinned to the repository's current commit. The page appears as **In sync** in the Map and Table views; Auto-link does not rewrite, commit, or publish the documentation.\n \n\n\nThe normal scan is deterministic and uses no AI credit. **AI auto-select** is optional: it asks the configured AI model to refine the offered matches, uses AI credit, and only changes which checkboxes are selected. You still review the result and select **Link selected (N)** to save it.\n\n\n Auto-link skips pages that already have at least one source link. To add another file, folder, or pattern to one of those pages, open the page's **Source links** panel in the editor and link it manually.\n\n\nIf the scan finds an OpenAPI specification and your `doccupine.json` does not configure one yet, it also offers **Add to doccupine.json (N)**. This stages the configuration and, when needed, a copy of the specification as pending changes. Review and publish those changes through the normal publishing flow.\n\n## How drift is detected\n\nDoccupine watches your source repositories two ways:\n\n- **Push webhook** - instant, and used whenever Doccupine can install a hook on the repository. Your project's own repository always has one.\n- **Background check** - every 30 minutes, for repositories you don't administer.\n\nThe Source repositories manager shows which one each repo is using, as an **Instant** or **~30 min** badge.\n\n## Review or publish automatically\n\nWhen a linked source changes, what happens next depends on the page:\n\n| Page setting | On drift |\n| -------------------------------- | ---------------------------------------------------------------- |\n| Default | Flagged for review - you trigger the update |\n| **Auto-update** on | The agent rewrites the page and publishes it |\n| Edited by a human | **Always** flagged for review, whatever else is set |\n\nEach row on the Map and Table views has an **Auto-update this page when its source changes** toggle, so you can let routine reference pages look after themselves while a carefully worded overview page always waits for you.\n\nThe same settings decide what happens to a run you started yourself from the Agent view - auto-update is not only about drift. What differs is that a run writes one change set and commits or stages it as a unit: if any page in it resolves to review, the whole set waits. Publishing half a coherent change and leaving the rest behind would be worse than waiting for you.\n\nFor anything in review, **Review update** opens the change set - the same diff view as [publishing](/platform/publishing) - and **Update from source** asks the agent to regenerate that one page on demand.\n\n\n Your edits are never overwritten. Doccupine compares the page's content against what the agent last wrote, so a page you've touched by hand is detected and routed to review - even if auto-update is on. Reformatting, line-ending changes, and blank-line churn don't count as edits.\n\n\n## Source repositories\n\nYour project's own repository is always a source, so a repo that holds both code and docs needs no setup at all.\n\nFor a multi-repo setup, add the other repositories from Agent Sync:\n\n\n \n Select **Source repositories** in the Agent Sync header. Your project's repository appears first with a **Default** badge and cannot be removed.\n \n \n Project owners and editors can select **Add repository**, then search the GitHub repositories they own, collaborate on, or can access through an organization. If GitHub is not connected yet, select **Connect GitHub**, finish authorization, then reopen the manager.\n \n \n Selecting a repository adds it immediately. **Instant** means Doccupine installed a push webhook; **~30 min** means it will check for source changes on a schedule instead. Both modes support the agent, manual source links, Auto-link code, and drift tracking.\n \n\n\nOnce connected, the repository appears in the Agent view's **Source repository** selector and anywhere you create a source link.\n\n\n Removing a repository never deletes your documentation pages. If pages still link to it, Doccupine tells you how many are affected and asks again before removing those source links. The pages remain, but they stop tracking changes from that repository.\n\n\n## Notifications\n\nDoccupine emails the project owner when pages are ready to review, and when pages have been updated and published. You're notified once per project when pages first drift - a later change to the same page won't email you again until you've dealt with it.\n\n## What it costs\n\nAgent runs spend whatever the project's [AI setting](/platform/ai-assistant) points at - the AI credit included with your plan, or your own provider key. Doccupine keeps that spend predictable either way:\n\n- Automatic regeneration only ever happens for pages you've explicitly set to auto-update. A page waiting for review costs nothing when its source changes.\n- Drift that changes no lines - a merge or a rename that leaves the tracked file's content alone - never triggers a run.\n- Every run has a ceiling on pages, and a ceiling on spend: a built-in one on included credit, or the limit you set on your own key.\n- Only one run happens at a time per project.\n\nIf AI is switched off for the project, Agent Sync keeps tracking drift but the agent cannot run, and the page says so.\n\n## In the editor\n\nYou don't have to leave the editor to use any of this. The toolbar has a source status button showing whether the open page is in sync, drifted, or unlinked - and why it would need review - and the side panel lets you ask the agent for a block of MDX to drop straight in at your cursor.";