Repository navigation
feat(mcp): add pull_docs and push_docs tools for document mirroring and editing - #776
Conversation
There was a problem hiding this comment.
ℹ️ No critical issues — three minor suggestions inline, plus one design question about where the default mirror lives.
Reviewed changes
pull_docs/push_docstools (apps/mcp/src/tools/doc-mirror-tools.ts) — thin wrappers over the existingrunPull/runPush, sharing arunCommandhelper that collects CLI output; exit 0 is success, 2 is a non-error conflict, 1 and unreachable are tool errors.- Registration and routing (
apps/mcp/src/tools/index.ts) — both tools added togetAllTools()and routed throughDOC_MIRROR_TOOL_NAMES, after the filesystem document tools. - Tests —
doc-mirror-tools.test.tscovers the tool list, required arguments and result shaping for ok/conflict/failure/unreachable;index.test.tsadds a routing check. - Skills and reference docs — a new "Reading and editing docs as files" section, routing rows and tool-reference entries in
paca,paca-doandpaca-doc(CLI and agent forms), a README paragraph and a CHANGELOG entry, all steering agents to a temporary mirror outside the workspace. - Underlying CLI wiring checked —
runPullrefuses symlinks and writes only under the mirror root,runPushresolves a mirror throughfindMirrorandpushMirrorFilerefusespath/lock/forcefor pulled files, honoursdryRun, and reads with the caller'sprojectId. The mapping inrunCommandis faithful to those exit codes.
ℹ️ The default mirror folder lands inside the working tree
pull_docs defaults dir to .paca/docs, relative to the MCP server's working directory, which for an agent is the repository checkout. The skills tell the model to gitignore that folder first, but the fallback is only as good as the model remembering it, and git_commit with all: true runs git add -A, which would stage every mirrored document plus .paca-sync.json and .paca-base/ into the user's branch. The PR body already flags this as deliberately unchanged, so this is a question rather than a defect.
Technical details
# Default `dir` inside the checkout can be committed
## Affected sites
- `apps/mcp/src/tools/doc-mirror-tools.ts:11` — `dir` defaults to `.paca/docs` (same as the CLI).
- `apps/mcp/src/git/workspace.ts:696` — `git_commit` with `all: true` stages the whole work tree.
- `services/api/.../content/paca.agent.md` / `paca.md` — the instruction to gitignore the folder is a model step, not an enforced one.
## Required outcome
- Either the default mirror is guaranteed not to be commit-or-push-able (a per-project path under the system temp directory), or `pull_docs` refuses/warns when `dir` resolves inside a git work tree and is not already ignored by `.gitignore`/`.git/info/exclude`.
## Open questions for the human
- Is the CLI-compatible `.paca/docs` default worth keeping now that the caller is an autonomous agent rather than a person watching the output?
- If keeping it, should the tool report the exact `.gitignore` line (or check `git check-ignore`) instead of leaving it to the skill text?deepseek-v4.1-flash-1017 (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
✅ No new issues found. The three inline findings from the previous review are addressed, and the new routing test now exercises real routing.
Reviewed changes
pull_docsdescription — now sends the agent topush_docsrather than thenpx @paca-ai/paca-mcp pushshell command.push_docsconflict summary — no longer assumes the pull-mirror flow; it defers to the CLI guidance appended to the result and mapsforce/pullto those flags.- Document-mirror routing test —
doc-mirror-tools.jsis mocked and the test is parametrized overpull_docs/push_docs, assertinghandleDocMirrorToolreceives(name, {}, docClient)and the filesystem handler is not called, so it fails if routing is lost.
deepseek-v4.1-flash-1017 (free via Pullfrog for OSS) | 𝕏
…ore functionality
There was a problem hiding this comment.
Important
The new path confinement refuses the temp folder that the tool descriptions and the bundled skills tell agents to use, on macOS and Windows.
Reviewed changes
- Confined both tools' filesystem targets —
assertAllowedPathresolves the nearest existing ancestor withrealishand refuses apull_docsdirorpush_docsfileoutside the server's working directory,os.tmpdir()andPACA_MCP_FILE_ROOTS; tests cover absolute and..escapes. - Made
pull_docsignore its mirror — a pull that is not a tool error writes<dir>/.gitignorecontaining*, so the mirror files,.paca-sync.jsonand.paca-base/stay out of Git. - Tightened the conflict and result text — the pull conflict summary now says
forcediscards local edits,push_docsdocuments.paca/push.jsonand the confinement, andrunCommandreturns a typedToolResult. - Documented the confinement — README and CHANGELOG describe the allowed roots and the per-mirror ignore file.
deepseek-v4.1-flash-1017 (free via Pullfrog for OSS) | 𝕏
| const extra = (process.env.PACA_MCP_FILE_ROOTS ?? "") | ||
| .split(path.delimiter) | ||
| .filter(Boolean); | ||
| return [process.cwd(), os.tmpdir(), ...extra].map((r) => path.resolve(r)); |
There was a problem hiding this comment.
The allowlist is the server's cwd, os.tmpdir() and PACA_MCP_FILE_ROOTS, but the pull_docs description (line 101), the dir help (line 114) and every bundled skill tell agents to use dir: "/tmp/paca-docs". On macOS os.tmpdir() is normally $TMPDIR (/var/folders/.../T) while /tmp resolves to /private/tmp, and on Windows /tmp resolves under the current drive, so the documented call is refused as outside the allowed folders.
Technical details
# The documented temp folder is outside the allowlist on macOS and Windows
## Affected sites
- `apps/mcp/src/tools/doc-mirror-tools.ts:43` — roots are `process.cwd()`, `os.tmpdir()`, `PACA_MCP_FILE_ROOTS`.
- `apps/mcp/src/tools/doc-mirror-tools.ts:101` and `:114` — recommend `dir: "/tmp/paca-docs"`.
- `services/api/internal/platform/bundledskills/content/paca.md:74`, `paca.agent.md:93`, `paca-do.md:17`, `paca-do.agent.md:18`, `paca-doc.md:19` — same example.
## Required outcome
- Either admit the conventional POSIX temp root (`/tmp`, realpath-resolved) to `allowedRoots()`, or stop naming `/tmp/...` and point agents at a folder under the system temp directory; the refusal message should name the actual temp root so an agent can recover.
- The tool description, the `dir` help and the skill text must agree with the allowlist on macOS and Windows.… validation and mirror handling
There was a problem hiding this comment.
ℹ️ No critical issues — two minor suggestions inline.
Reviewed changes
- Admitted
/tmpon POSIX —allowedRoots()now adds/tmpon non-Windows platforms, so the folder the tool help and skills name is accepted on macOS, and the refusal message namesos.tmpdir(). - Scoped the mirror
.gitignore— a pull now writes<dir>/.gitignoreonly for a folder it creates or an existing mirror, and adirresolving to the server's working directory is refused before the pull runs. - Covered the new guards with tests — new cases for the working-directory refusal,
/tmpacceptance, and the untouched pre-existing folder.
deepseek-v4.1-flash-1017 (free via Pullfrog for OSS) | 𝕏
| ).rejects.toThrow(/working directory/); | ||
| }); | ||
|
|
||
| it("accepts /tmp as documented", async () => { |
There was a problem hiding this comment.
allowedRoots() excludes /tmp on win32, so this test fails on a Windows checkout while its name asserts the documented path works. Use os.tmpdir() for the platform-neutral check, or guard the /tmp case with it.skipIf(process.platform === "win32") and keep it as a POSIX-only test.
| failed: "Pull failed; nothing was changed.", | ||
| }, | ||
| ); | ||
| if (!res.isError && ownsFolder) await ignoreMirror(dir); |
There was a problem hiding this comment.
When dir already exists and is not yet a mirror, ownsFolder is false, so no .gitignore is written — even though the pull then writes .paca-sync.json and makes it a mirror (the next pull would add the file). Meanwhile the pull_docs description (line 127) and the dir help (line 140) promise the folder gets its own .gitignore, so an agent pulling into a pre-existing in-repo folder (e.g. dir: "docs") leaves mirror files that git_commit with all: true will stage. Say in the result when the folder was left alone so the caller can add it to .gitignore, or make the promise conditional.

Problem
Asked to "pull docs", an agent had no tool for it.
pullandpushexist only as command-line commands of@paca-ai/paca-mcp, so the agent saw onlylist_docs/read_docand read the documents one by one into the conversation, saving nothing locally. Nothing in the skills pointed it at the commands either.Changes
MCP tools (
apps/mcp)pull_docs(projectId,dir,force) runs the existingpull: mirrors every document to<dir>/<folder>/<title>.md. A file edited locally is merged with changes made in Paca.push_docs(projectId,file,path,note,task,lock,force,dryRun) runs the existingpush: a file from a pull mirror goes back to its document as an edit of only the blocks it changes; any other file is written topathas a managed copy.runPull/runPushthrough one runner that collects the command's output. A conflict (exit 2) is a normal result that says topull_docs, resolve, and push again; a real failure or an unreachable server is a tool error.mergeanddiffare internal helpers of those two commands, not commands, so they get no tools.push_docsrecords state perPACA_API_URL(defaulthttp://localhost:8080), as the command line does.Bundled skills (
services/api/.../bundledskills/content:paca,paca-doc,paca-do, each in CLI and agent form)dir: "/tmp/paca-docs"). If they pull inside the workspace (the default.paca/docs), they must add the folder to.gitignorefirst so the mirror is never committed.read_doc/write_docremain the default for a single document.Not changed
The default
diris still.paca/docs, inside the workspace, so an agent that omitsdirpulls there. A default under the system temp folder would need a per-project path so mirrors of different projects do not mix.Testing
apps/mcp: full vitest suite passes (1296 tests), including new tests for both tools and a routing check; biome clean on the changed files.services/api:go test ./internal/platform/bundledskills/passes.tsc -bcould not writebuild/(root-owned by Docker);tsc --noEmit -p .shows no errors besides the write errors.The MCP server and the API need redeploying before agents see the new tools and skill text.