Skip to content

feat(tools/vcs): implement the source-control (VCS) abstraction - #610

Merged
potiuk merged 1 commit into
mainfrom
feat/vcs-abstraction
Jun 29, 2026
Merged

potiuk merged 1 commit into
mainfrom
feat/vcs-abstraction

Conversation

@potiuk

@potiuk potiuk commented Jun 29, 2026

Copy link
Copy Markdown
Member

Summary

Extracts the source-control (VCS) capability — whose contract landed in
#609 (tools/github/source-control.md) —
into a runnable, tested, backend-dispatching tool: tools/vcs/
(magpie-vcs). A non-Git VCS now plugs in at one place (a backend class)
instead of editing every git-using skill.

The abstraction

  • VCSBackend — abstract interface with exactly the operations from the
    capability's What the skills require table: status/is_clean,
    current_branch, diff, log, create_branch, switch, stage,
    commit, fetch, push, reset_worktree.
  • GitBackend — complete Git binding (the default; GitHub's native VCS).
  • MercurialBackend / SubversionBackend — real detection (so
    magpie-vcs detect reports the working copy's VCS) but operations raise an
    actionable VCSError naming the bridge issue (feat(tools/mercurial): Mercurial (Hg) version-control support for the local dev-loop #601 / feat(tools/subversion): Apache Subversion (SVN) support — ASF svn.apache.org / dist.apache.org #602). SVN carries
    distributed = False. A bridge lands by replacing the stub base with a
    concrete subclass — dispatch, the CLI, and every skill calling magpie-vcs
    pick it up unchanged.
  • Backend detection is innermost-wins; override via --backend /
    $MAGPIE_VCS.
  • Hardened against inherited GIT_* env so a skill invoking it from inside a
    git hook resolves the repo from --cwd, not a stray GIT_DIR.
uv run --project tools/vcs magpie-vcs -C <upstream> diff --base main
uv run --project tools/vcs magpie-vcs -C <upstream> log --grep ISSUE-123
uv run --project tools/vcs magpie-vcs -C <upstream> detect

Write operations stay gated on explicit user confirmation in the calling
skill
— the tool adds no prompt of its own.

Registration & wiring

  • uv workspace member (pyproject.toml) + regenerated uv.lock
  • Capability to tool map row in docs/labels-and-capabilities.md
    (capability:setup) — capability-sync validator passes
  • Back-reference from tools/github/source-control.md → the implementation
  • README with capability declaration + usage

Validation

All hooks green via prek run:

  • ruff / ruff-format / mypy clean
  • 19 tests (Git ops against a temp repo, detection/override, inherited-
    GIT_* regression, stub-backend errors, CLI exit codes)
  • doctoc / markdownlint / lychee / check-placeholders / check-workspace-members
  • skill-and-tool-validate (skills, tools, capability sync)
  • workspace-pytest passes via prek run --all-files

Note: a plain git commit (not --no-verify) trips workspace-pytest
because git exports GIT_DIR/GIT_INDEX_FILE into hook subprocesses,
which breaks any test that shells out to git in a temp repo — it hits the
pre-existing agent-isolation tests too (they pass 54/54 standalone). This
PR's tests are hardened against it; the hook passes outside the commit
context. The prek-doesn't-scrub-GIT_* wrinkle is pre-existing and worth
a separate issue.

Follow-ups

The non-Git backends are deliberate extension points for the VCS bridge
issues: #601 (Mercurial), #602 (Subversion), #603 (Jujutsu), #604 (Fossil),
#605 (Perforce).


Generated-by: Claude Code (Opus 4.8), reviewed by the submitter before opening.

Extract the source-control capability contract (added in #609,
tools/github/source-control.md) into a runnable, backend-dispatching
tool so a non-Git VCS plugs in at one place instead of in every skill.

- tools/vcs/: stdlib-only `magpie-vcs` CLI. Abstract VCSBackend
  interface mirroring the capability's operation set (status, branch,
  stage, commit, diff, log, fetch, push, reset-worktree), a complete
  GitBackend, backend detection (innermost-wins) and override via
  --backend / MAGPIE_VCS.
- Mercurial and Subversion are detected extension points: detection is
  real (so `magpie-vcs detect` reports the working copy's VCS), but the
  operations raise an actionable error naming the bridge issue (#601,
  #602). A bridge lands by replacing the stub base with a concrete
  backend; dispatch, the CLI, and every skill calling magpie-vcs pick
  it up unchanged.
- 18 tests (git ops against a temp repo, detection/override, stub
  errors, CLI exit codes); ruff + mypy clean.
- Register the tool: uv workspace member + lockfile, capability-to-tool
  map row, and a back-reference from source-control.md to the
  implementation.

Generated-by: Claude Code (Opus 4.8)
@potiuk
potiuk merged commit 8f6e795 into main Jun 29, 2026
28 checks passed
@potiuk
potiuk deleted the feat/vcs-abstraction branch June 29, 2026 01:03
@potiuk potiuk added contract:change-request Tool capability: proposed-change review + merge gate (PR / MR / Gerrit change) contract:source-control Tool capability: branch / commit / diff / push (VCS) contract:tracker Tool capability: issue / board / label backend labels Sep 25, 2026
@potiuk potiuk added contract:people family:ci .github workflows, prek, validators family:docs Docs, MISSION.md, READMEs family:tools tools/* labels Nov 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

contract:change-request Tool capability: proposed-change review + merge gate (PR / MR / Gerrit change) contract:people contract:source-control Tool capability: branch / commit / diff / push (VCS) contract:tracker Tool capability: issue / board / label backend family:ci .github workflows, prek, validators family:docs Docs, MISSION.md, READMEs family:tools tools/*

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant