Skip to content

add hg + jj support to skill helper scripts#116

Merged
umputun merged 12 commits intoumputun:masterfrom
paskal:skill-scripts-hg-jj
Apr 17, 2026
Merged

add hg + jj support to skill helper scripts#116
umputun merged 12 commits intoumputun:masterfrom
paskal:skill-scripts-hg-jj

Conversation

@paskal
Copy link
Copy Markdown
Contributor

@paskal paskal commented Apr 17, 2026

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.sh refactored to dispatch by VCS. Top-level probe matches app/diff/vcs.go precedence (jj → git → hg → unknown) with command -v guards. Git logic moved into detect_git() verbatim; detect_hg() and detect_jj() added alongside.
  • apply_decision_logic no-commits branch short-circuits before is_main/has_uncommitted — prevents fresh hg repos with untracked files from misrouting into the main+uncommitted arm. --all-files fallback stays git-only (binary's --all-files is 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 for is_main (anonymous feature changes descending from main would otherwise misfire with a nearest-ancestor-bookmark check). Falls back to needs_ask=true when no main/master bookmark resolves.
  • read-latest-history.sh resolves repo root via jj → git → hg → pwd with symmetric command -v guards.
  • SKILL.md, references/usage.md, README.md, and CLAUDE.md updated to VCS-neutral wording.
  • Scripts mirrored into plugins/codex/skills/revdiff/scripts/ (byte-identical bodies; codex # source: header preserved).

Behaviour changes

  • No-VCS case: previously emitted suggested_ref=--all-files / needs_ask=false via the failed git rev-parse HEAD fallthrough. Now emits empty / needs_ask=true. The old output would have failed at the launcher anyway — the new behaviour is correct.
  • Git repos: runtime output byte-identical to master (verified via baseline diff).

Out of scope

  • --all-files remains hg-unsupported in the binary (app/diff/directory.go supports git + jj via NewGitDirectoryReader / NewJjDirectoryReader). Separate issue.
  • app/history/history.go still captures git diffs only (gitDiff shells out to git). History files in hg/jj repos will have an empty diff section. Flagged as a follow-up.

Verified

  • shellcheck clean on all four scripts; shfmt -d clean (pre-existing double-space in read-latest-history.sh header comment unchanged).
  • Cross-tree bodies byte-identical between .claude-plugin/skills/revdiff/scripts/ and plugins/codex/skills/revdiff/scripts/.
  • Git matrix: all 6 rows match pre-refactor baseline.
  • hg matrix: all 5 rows pass (including no-commits short-circuit with untracked files).
  • jj matrix: static review only — jj not installed on the dev machine. The command -v jj probe guards runtime.

paskal added 10 commits April 17, 2026 02:20
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)
@paskal paskal requested a review from umputun as a code owner April 17, 2026 02:23
Copilot AI review requested due to automatic review settings April 17, 2026 02:23
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.sh to auto-detect VCS (jj → git → hg), run VCS-specific detection, then apply shared decision logic.
  • Updates read-latest-history.sh to resolve repo root via jj → git → hg before falling back to pwd.
  • 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.

Comment thread plugins/codex/skills/revdiff/SKILL.md Outdated
Comment thread README.md Outdated
Comment thread .claude-plugin/skills/revdiff/scripts/detect-ref.sh Outdated
Comment thread plugins/codex/skills/revdiff/scripts/detect-ref.sh Outdated
Comment thread README.md Outdated
Comment thread .claude-plugin/skills/revdiff/references/usage.md Outdated
Comment thread plugins/codex/skills/revdiff/references/usage.md Outdated
Comment thread .claude-plugin/skills/revdiff/SKILL.md Outdated
Copy link
Copy Markdown
Owner

@umputun umputun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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-filesneeds_ask=true) is correct.

couple small things before merge:

  1. 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 the commit: 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).

  2. README --all-files wording is wrong in two more places. jj is supported via NewJjDirectoryReader (wired in app/renderer_setup.go:100-101):

    • README.md:306 — "Browse all git-tracked files, not just diffs (git only)"
    • README.md:485 — "--all-files requires a git repository (uses git ls-files for file discovery)"

    same VCS-neutral rewording should apply here.

  3. top-level git probe missing command -v git guard. .claude-plugin/skills/revdiff/scripts/detect-ref.sh:174 (and the codex mirror at line 175) runs git rev-parse --is-inside-work-tree without the command -v guard 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
@umputun
Copy link
Copy Markdown
Owner

umputun commented Apr 17, 2026

thx, items 1 and 3 look good. one small leftover — README.md still has the "git only" wording for --all-files in two other spots (separate from the line 29 fix):

  • line 306 (flags table): Browse all git-tracked files, not just diffs (git only)
  • line 485 ("All-Files Mode" section): --all-files requires a git repository (uses git ls-files for file discovery)

pls apply the same VCS-neutral rewording there.

@paskal
Copy link
Copy Markdown
Contributor Author

paskal commented Apr 17, 2026

done in 2885254:

  • line 306 (flags table): Browse all tracked files, not just diffs (git or jj)
  • line 485 (All-Files Mode section): reworded to mention git ls-files or jj file list and explicitly noted hg is not supported

Copy link
Copy Markdown
Owner

@umputun umputun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thx, all addressed. lgtm

@umputun umputun merged commit 802babf into umputun:master Apr 17, 2026
4 checks passed
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.sh to 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.sh to 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.

Comment thread README.md
- 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
@paskal paskal deleted the skill-scripts-hg-jj branch April 17, 2026 03:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants