Repository navigation
feat(mcp): add pull and push commands for documents - #769
Conversation
There was a problem hiding this comment.
Important
push can silently overwrite another file's managed document: the default document path keeps only the basename, so two plan.md files in different folders resolve to the same Plans/plan, and the second file's first push carries no If-Match.
Reviewed changes
Read the full diff (18 files, 9 commits) and checked the client calls against the Go handlers and contract docs already on master. In short: the pull mirror (change feed, name sanitization, symlink refusal, per-mirror lock, rollback), the push managed-copy writer (source metadata, If-Match conflict handling with diff, --lock/--dry-run), the CLI dispatch and exit codes, the getChanges/batchGet client additions, and the README/CHANGELOG with seven new test files.
deepseek-v4.1-flash-1017 (free via Pullfrog for OSS) | 𝕏
…ts temporary name
There was a problem hiding this comment.
Important
The new shared-document guard in push compares document paths as raw strings, but the server resolves them case-insensitively and trims segments, so Plans/plan and Plans/Plan are one document — the second file still overwrites the first's without an If-Match. There is also a smaller gap in the new interrupted-pull state.
Reviewed changes
Reviewed the 17 commits since the last Pullfrog review (3f46afc), which close the three earlier findings.
- Added a shared-document guard to
push: a path another file already records is refused, and an entry whose file was moved away is taken over with its ETag and base copy. - Wrote an interim pull state before any file is moved into place or written, with
reservedandpending_sha256recovery fields so a killed pull is finished by the next one. - Gave sibling folders whose names share one key (case, Unicode form, characters mapped to
_) their own mirror directories, remembered in the state's newdirs. - Moved a revived kept file with its document instead of writing over it.
- Restricted rollback's state restore to the case where every created file is gone and every moved file is back under its temporary name.
- Added crash tests that stop a pull at every rename and at chosen content writes, plus new pull, push and mirror-path cases and the matching README/state documentation.
deepseek-v4.1-flash-1017 (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
ℹ️ No critical issues — both findings from the last review are fixed and covered by tests; one small wording fix inline.
Reviewed changes
Reviewed the 3 commits since the prior Pullfrog review (0560073); both open findings are addressed.
- Added
docPathKey(segments trimmed, empty segments dropped, case-folded) and used it for the unchanged shortcut, the owner lookup andIf-Match, collecting every entry that claims the document rather than the first. - After a write, refused to record a document id another entry already records, which covers both the few characters JavaScript and Postgres lowercase differently and a document moved in Paca.
- Replaced the single
pending_sha256with a list settled at the start of every pull bysettlePending: only the hash the file on disk actually holds survives, and the interim state appends the hash being written instead of replacing it. - Added tests for case, space and double-slash path variants, several stale owners, the document-id guard, and repeated interrupted pulls including a local edit and a deleted document, plus the matching README and state documentation.
deepseek-v4.1-flash-1017 (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
Reviewed the single commit since the prior Pullfrog review (5a8d53a), which closes the last open finding.
- Pointed the
pushtwin-document error at--forcewhen telling the user to re-push the other file, since this write already bumped the document's ETag and a plain re-push would end in a 412.--forcebypasses both the unchanged short-circuit andIf-Match, so the suggested command does restore the other file's content.
deepseek-v4.1-flash-1017 (free via Pullfrog for OSS) | 𝕏
pikann
left a comment
There was a problem hiding this comment.
LGTM! Thank you for the contribution! 🚀

Summary
Part of #747 (docs pull / push / content check for coding agents). Adds two commands to
@paca-ai/paca-mcpthat use the API from #751, #753, #754 and #759. Onlyapps/mcpchanges; nothing in the MCP tools changes.They read the same environment as the server (
PACA_API_KEY,PACA_API_URL,PACA_PROJECT_ID). Without a command the binary starts the MCP server as before.pull: mirror documents to Markdown files--forceoverwrites it.push: write a repository file to a documentPlans/<name>, orSpecifications/<name>for a file under aspecsfolder;--pathsets another) as a managed copy that records repository, file path and commit.If-Matchwith the ETag of the last push.--forceoverwrites.--lockmakes the document read-only in Paca for everything but a push from the same repository.--path. Paths are compared the way the server resolves them (segments trimmed, empty ones dropped, case ignored). When that other file no longer exists (agit mv, including a case-only one), the moved file takes over the entry and its ETag.Exit codes: 0 done, 1 error, 2 conflict, 3 server unreachable (nothing recorded). The README has a new section, "Command line:
pullandpush", with the full rules.Safety rules in
pull--dir. Unsafe characters in titles become_; names that clash (compared without case and Unicode normalisation) get~<first 8 characters of the id>; Windows reserved names get a_prefix.--dirthatpulldid not write is never overwritten.pullrefuses to run when the mirror contains a symlink..paca-pull.lock; a lock left by a process that is gone is taken over).~<first 8 characters of the id>for the later one); a directory keeps its name across pulls.Decisions, listed so they can be challenged
source.repositoryisowner/namefrom theoriginremote, with the folder name as fallback. The lock compares this string exactly, so a bare repository name would let two forks' pushes collide.--forceremoves it..paca/push.json), so an entry made against another project or server is ignored.[Unreleased].Known gaps
PACA_API_URL) is reported as "this Paca server is too old for pull/push".pullmakes one extra request per managed document to record that it is managed.batchGetis added to the document client here; the partial-edit tools that follow in [Feature] Docs: efficient pull/push/content-check for coding agents (change feed, ETags, upsert by path, partial reads) #747 need the same method and will reuse it.Type of Change
Testing
apps/mcp:tscclean;lintreports 4 warnings, all in files this PR does not touch;vitest918 of 918 (42 files). New test files:cli/pull.test.ts,cli/pull-interrupt.test.ts,cli/pull-kill-every-rename.test.ts,cli/pull-rollback.test.ts,cli/push.test.ts,cli/mirror-paths.test.ts,cli/dispatch.test.ts,cli/diff.test.ts,cli/git-source.test.ts,api/doc-client-changes.test.ts.masterwith fix(api): accept a document ETag with a compression suffix in If-Match #759):created Plans/planunchangedupdated Plans/plan. The recorded ETag carried the gateway's-gzipsuffix and was accepted asIf-Match.push --force:updatedpull:1 updated;pullagain:up to date--dry-run),--pathsends it to its own document, and a moved file takes over its entry (the document'ssource.pathfollows).masteralso covered a folder rename (file moved without a download), a delete,--lockwith a push from another repository (refused, names the owning repository) and--dry-run.Checklist
apps/mcp/README.mdandapps/mcp/CHANGELOG.md.