add hg + jj support to skill helper scripts#116
Conversation
plan for adding mercurial and jujutsu support to the claude code skill helper scripts (detect-ref.sh, read-latest-history.sh). binary already supports all three vcs since v0.16; this brings the skill layer in sync.
Mark verification complete and archive plan under docs/plans/completed/.
Consolidated from three review-fix commits: - address iter 1 quality/simplification/documentation findings - correct jj is_main semantic and harden git guard (iter 2 critical) - tighten local scoping and drop redundant default resets (smells)
There was a problem hiding this comment.
Pull request overview
Adds Mercurial (hg) and Jujutsu (jj) support to the revdiff skill helper scripts used by the Claude Code and Codex skill bundles, aligning VCS probing precedence with the Go binary and updating user-facing documentation to be VCS-neutral.
Changes:
- Refactors
detect-ref.shto auto-detect VCS (jj → git → hg), run VCS-specific detection, then apply shared decision logic. - Updates
read-latest-history.shto resolve repo root via jj → git → hg before falling back topwd. - Updates skill/docs wording from git-only to VCS-neutral and mirrors the script updates into the Codex plugin tree.
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
.claude-plugin/skills/revdiff/scripts/detect-ref.sh |
Adds VCS dispatch + hg/jj detection while preserving git output format. |
.claude-plugin/skills/revdiff/scripts/read-latest-history.sh |
Resolves repo root for history lookup using jj/git/hg probing. |
.claude-plugin/skills/revdiff/references/usage.md |
Updates usage prose to VCS-neutral wording. |
.claude-plugin/skills/revdiff/SKILL.md |
Updates skill description/flow text to mention git/hg/jj repos. |
plugins/codex/skills/revdiff/scripts/detect-ref.sh |
Mirrors the updated detect-ref script (Codex copy). |
plugins/codex/skills/revdiff/scripts/read-latest-history.sh |
Mirrors the updated history script (Codex copy). |
plugins/codex/skills/revdiff/references/usage.md |
Mirrors VCS-neutral wording in Codex reference docs. |
plugins/codex/skills/revdiff/SKILL.md |
Mirrors VCS-neutral wording in Codex skill doc. |
README.md |
Updates repo-wide docs to VCS-neutral wording for --only/history sections. |
CLAUDE.md |
Documents the new multi-VCS script behavior and precedence. |
docs/plans/completed/20260417-hg-jj-skill-scripts.md |
Adds an implementation plan/record for the change. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
umputun
left a comment
There was a problem hiding this comment.
lgtm overall. verified git runtime byte-identical on 9 scenarios (clean main, feature branch, uncommitted, staged-only, master-with-dirty, fresh repo, fresh+untracked, detached HEAD, non-git dir). the one intentional change (non-git dir: --all-files → needs_ask=true) is correct.
couple small things before merge:
-
history docs overstate content for hg/jj.
app/history/history.go:150-161(gitCommitHash) and the diff block (gitDiff) are git-only — for hg/jj thecommit:line is omitted and the diff section is empty. this PR touches the docs but doesn't qualify these lines:.claude-plugin/skills/revdiff/SKILL.md:36,plugins/codex/skills/revdiff/SKILL.md:49— "header (path, refs, commit hash)".claude-plugin/skills/revdiff/references/usage.md:194,plugins/codex/skills/revdiff/references/usage.md:194— "Header with path, VCS refs, and commit hash"README.md:562— "Header with path, VCS refs, and commit hash"
pls reword to smth like "git commit hash when available" and similarly note the diff block is git-only (or mention it as a known limitation).
-
README
--all-fileswording is wrong in two more places. jj is supported viaNewJjDirectoryReader(wired inapp/renderer_setup.go:100-101):README.md:306— "Browse all git-tracked files, not just diffs (git only)"README.md:485— "--all-filesrequires a git repository (usesgit ls-filesfor file discovery)"
same VCS-neutral rewording should apply here.
-
top-level git probe missing
command -v gitguard..claude-plugin/skills/revdiff/scripts/detect-ref.sh:174(and the codex mirror at line 175) runsgit rev-parse --is-inside-work-treewithout thecommand -vguard that jj (L172) and hg (L176) have. stderr is already suppressed so there's no noise issue, but parity is nice — one-line fix.
plan file + test matrix is great, thx for documenting the no-commits/untracked edge case.
- clarify commit-hash wording — history's `commit:` line is git-only (`app/history/history.go:gitCommitHash`); hg/jj histories don't carry one - README `--all-files` bullet now mentions git+jj backing (jj support via `NewJjDirectoryReader` in `app/diff/directory.go`) - add `command -v git` guard to detect-ref.sh VCS probe for symmetry with jj/hg guards — avoids `command not found` noise in hg/jj-only environments
|
thx, items 1 and 3 look good. one small leftover —
pls apply the same VCS-neutral rewording there. |
|
done in 2885254:
|
There was a problem hiding this comment.
Pull request overview
This PR updates the Claude/Codex revdiff skill helper scripts and docs to support hg and jj repos (in addition to git), aligning VCS detection precedence with the Go implementation (DetectVCS: jj → git → hg) so the skill can reliably suggest refs and locate history directories across VCS types.
Changes:
- Refactors
detect-ref.shto probe jj/git/hg and populate a consistent set of fields, with shared decision logic and git output kept byte-identical. - Updates
read-latest-history.shto resolve the repo history subdirectory via jj/git/hg root detection. - Revises skill/docs wording to be VCS-neutral and mirrors the script changes into the Codex plugin tree.
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| .claude-plugin/skills/revdiff/scripts/detect-ref.sh | Adds VCS dispatch (jj/git/hg) and shared decision logic for ref suggestion. |
| .claude-plugin/skills/revdiff/scripts/read-latest-history.sh | Resolves repo root via jj → git → hg to find the correct history subdir. |
| .claude-plugin/skills/revdiff/references/usage.md | Updates VCS-neutral wording in examples and context-only/history descriptions. |
| .claude-plugin/skills/revdiff/SKILL.md | Updates skill description/triggers and history explanation to cover git/hg/jj. |
| plugins/codex/skills/revdiff/scripts/detect-ref.sh | Mirrors the updated detect-ref script body into the Codex plugin tree. |
| plugins/codex/skills/revdiff/scripts/read-latest-history.sh | Mirrors the updated read-latest-history script body into the Codex plugin tree. |
| plugins/codex/skills/revdiff/references/usage.md | Mirrors VCS-neutral doc wording updates into the Codex plugin tree. |
| plugins/codex/skills/revdiff/SKILL.md | Mirrors skill metadata/wording updates into the Codex plugin tree. |
| README.md | Updates repo-level documentation to reflect multi-VCS support (incl. --all-files git/jj). |
| CLAUDE.md | Documents the new multi-VCS dispatch behavior for the helper scripts. |
| docs/plans/completed/20260417-hg-jj-skill-scripts.md | Adds an implementation plan/archive describing approach, testing matrix, and constraints. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| - Header with path, git refs, and commit hash | ||
| - Header with path, refs, and (git only) a short commit hash | ||
| - Full annotation output (same format as stdout) | ||
| - Raw git diff for annotated files only |
| - Header with path, git refs, and commit hash | ||
| - Header with path, refs, and (git only) a short commit hash | ||
| - Full annotation output (same format as stdout) | ||
| - Raw git diff for annotated files only |
| - Header with path, git refs, and commit hash | ||
| - Header with path, refs, and (git only) a short commit hash | ||
| - Full annotation output (same format as stdout) | ||
| - Raw git diff for annotated files only |
Summary
The revdiff binary supports git, hg, and jj (since v0.16), but the Claude Code / Codex skill's helper scripts (
detect-ref.sh,read-latest-history.sh) are git-only. In hg-only or jj-only repos the skill falls through with empty fields and can't suggest a ref or resolve the history directory name.This PR adds hg and jj paths to both scripts, keeps the git runtime output byte-identical, and mirrors the changes into the codex plugin tree.
Changes
detect-ref.shrefactored to dispatch by VCS. Top-level probe matchesapp/diff/vcs.goprecedence (jj → git → hg → unknown) withcommand -vguards. Git logic moved intodetect_git()verbatim;detect_hg()anddetect_jj()added alongside.apply_decision_logicno-commits branch short-circuits beforeis_main/has_uncommitted— prevents fresh hg repos with untracked files from misrouting into the main+uncommitted arm.--all-filesfallback stays git-only (binary's--all-filesis git+jj but jj's@always exists, so the branch is unreachable for jj; hg is genuinely unsupported).detect_jj()compares@-change_id to the main bookmark's change_id foris_main(anonymous feature changes descending from main would otherwise misfire with a nearest-ancestor-bookmark check). Falls back toneeds_ask=truewhen nomain/masterbookmark resolves.read-latest-history.shresolves repo root via jj → git → hg → pwd with symmetriccommand -vguards.plugins/codex/skills/revdiff/scripts/(byte-identical bodies; codex# source:header preserved).Behaviour changes
suggested_ref=--all-files/needs_ask=falsevia the failedgit rev-parse HEADfallthrough. Now emits empty /needs_ask=true. The old output would have failed at the launcher anyway — the new behaviour is correct.Out of scope
--all-filesremains hg-unsupported in the binary (app/diff/directory.gosupports git + jj viaNewGitDirectoryReader/NewJjDirectoryReader). Separate issue.app/history/history.gostill captures git diffs only (gitDiffshells out togit). History files in hg/jj repos will have an empty diff section. Flagged as a follow-up.Verified
shellcheckclean on all four scripts;shfmt -dclean (pre-existing double-space inread-latest-history.shheader comment unchanged)..claude-plugin/skills/revdiff/scripts/andplugins/codex/skills/revdiff/scripts/.command -v jjprobe guards runtime.