18 lines · 1.9 KBRaw
| 1 | /** The ref protocol section of an AGENTS.md: what an agent must do to work on `repo`, a repository on `origin`. */ |
| 2 | export function agentsSection(input: { readonly origin: string; readonly repo: string; readonly branch: string }): string { |
| 3 | return `## ref protocol |
| 4 | |
| 5 | This repository lives on refs at ${input.origin}/${input.repo}. Agents work on it over the ref protocol. The full rules are in ${input.origin}/llms.txt. |
| 6 | |
| 7 | - At the start of every session, call \`refs_connect\` with \`${input.repo}\`. With the refs CLI, the session connects by itself. If you don't have the refs tools, read ${input.origin}/llms.txt and set them up. |
| 8 | - Leave this clone's git configuration alone. refs gives git push access when you take a branch. |
| 9 | - Work on one branch at a time, never \`${input.branch}\`. Take a pull request or a branch with \`refs_take\`, or push a new branch to claim it. Push with \`git push origin HEAD:<branch>\`. |
| 10 | - When you make a choice that the owner of the work would want to make themselves, record it in a \`decision\` block at the end of the commit message. Most commits have none. The test and the format are in ${input.origin}/llms.txt. |
| 11 | - Never force-push. If a push is rejected, run \`git pull --rebase\` and push again. |
| 12 | - Act on each "[refs] Updates" message when it arrives. Without the refs hooks, call \`refs_events\` before every push. |
| 13 | - When the work is pushed, open its pull request with \`refs_open_pull\`. To see its merge state, the review threads that are not resolved, and the logs of failed CI jobs, call \`refs_view_pull\`. |
| 14 | - Answer mentions and report on your work with \`refs_reply\`. After you push a fix for a review thread, give that commit in \`addressed_in\`. Only a person resolves a thread or merges. |
| 15 | - With the refs CLI in your shell, \`refs pr checks\`, \`refs run view <id> --log-failed\` and \`refs task list\` give the same data. Add \`--json\` to parse it. |
| 16 | - Call \`refs_release\` when the work is done. Call \`refs_end\` only to go offline. |
| 17 | `; |
| 18 | } |