首页/ AI 技能 / @skilllib/skill-2014279393441427458
Skill站外收录 @skilllib/skill-2014279393441427458

vcs-detect

自动识别当前项目使用的版本控制系统,准确区分 Jujutsu 和 Git 环境,并在共存场景下优先采用 Jujutsu 操作,确保后续所有版本控制命令与实际底层系统匹配,避免因工具错配导致的执行失败。

0.0 (0) 632 次安装 原作者 编程导航
收录于 2026-01-22
开发运维 AI 技能

Skills.MD

# VCS Detection Skill Detect the version control system in use before running any VCS commands. ## Why This Matters - jj (Jujutsu) and git have different CLIs and workflows - Running `git` commands in a jj repo (or vice versa) causes errors - Some repos use jj with git colocated (both `.jj/` and `.git/` exist) ## Detection Logic Both `jj root` and `git rev-parse --show-toplevel` walk up the filesystem to find repo root. **Priority order:** 1. `jj root` succeeds → jj (handles colocated too) 2. `git rev-parse` succeeds → git 3. Both fail → no VCS ## Detection Command ```bash if jj root &>/dev/null; then echo "jj" elif git rev-parse --show-toplevel &>/dev/null; then echo "git" else echo "none" fi ``` ## Command Mappings | Operation | git | jj | |-----------|-----|-----| | Status | `git status` | `jj status` | | Log | `git log` | `jj log` | | Diff | `git diff` | `jj diff` | | Commit | `git commit` | `jj commit` / `jj describe` | | Branch list | `git branch` | `jj branch list` | | New branch | `git checkout -b <name>` | `jj branch create <name>` | | Push | `git push` | `jj git push` | | Pull/Fetch | `git pull` / `git fetch` | `jj git fetch` | | Rebase | `git rebase` | `jj rebase` | ## Usage Before any VCS operation: 1. Run detection command 2. Use appropriate CLI based on result 3. If `none`, warn user directory is not version controlled ## Example Integration ``` User: Show me the git log Agent: [Runs detection] -> Result: jj Agent: [Runs `jj log` instead of `git log`] ``` ## Colocated Repos When both `.jj/` and `.git/` exist, the repo is "colocated": - jj manages the working copy - git is available for compatibility (GitHub, etc.) - **Always prefer jj commands** in colocated repos

评论 0

还没有评论,来抢沙发。