From 70011f3c64f8548da7be73166da5cc80d75402fc Mon Sep 17 00:00:00 2001 From: Zhongwei Li Date: Sat, 29 Nov 2025 18:17:51 +0800 Subject: [PATCH] Initial commit --- .claude-plugin/plugin.json | 11 + README.md | 3 + SKILL.md | 288 +++++++++++++++++++++ plugin.lock.json | 61 +++++ references/commands.md | 462 ++++++++++++++++++++++++++++++++++ references/configuration.md | 470 +++++++++++++++++++++++++++++++++++ references/git-comparison.md | 380 ++++++++++++++++++++++++++++ references/revsets.md | 265 ++++++++++++++++++++ 8 files changed, 1940 insertions(+) create mode 100644 .claude-plugin/plugin.json create mode 100644 README.md create mode 100644 SKILL.md create mode 100644 plugin.lock.json create mode 100644 references/commands.md create mode 100644 references/configuration.md create mode 100644 references/git-comparison.md create mode 100644 references/revsets.md diff --git a/.claude-plugin/plugin.json b/.claude-plugin/plugin.json new file mode 100644 index 0000000..1955506 --- /dev/null +++ b/.claude-plugin/plugin.json @@ -0,0 +1,11 @@ +{ + "name": "jj", + "description": "Jujutsu (jj) version control system - a Git-compatible VCS with novel features. Use when working with jj repositories, managing stacked commits, needing automatic rebasing with first-class conflict handling, using revsets to select commits, or wanting enhanced Git workflows. Triggers on mentions of 'jj', 'jujutsu', change IDs, or operation log.", + "version": "1.0.0", + "author": { + "name": "Alberto Leal" + }, + "skills": [ + "./" + ] +} \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..1b307b2 --- /dev/null +++ b/README.md @@ -0,0 +1,3 @@ +# jj + +Jujutsu (jj) version control system - a Git-compatible VCS with novel features. Use when working with jj repositories, managing stacked commits, needing automatic rebasing with first-class conflict handling, using revsets to select commits, or wanting enhanced Git workflows. Triggers on mentions of 'jj', 'jujutsu', change IDs, or operation log. diff --git a/SKILL.md b/SKILL.md new file mode 100644 index 0000000..4b588d1 --- /dev/null +++ b/SKILL.md @@ -0,0 +1,288 @@ +--- +name: jj +description: Jujutsu (jj) version control system - a Git-compatible VCS with novel features. Use when working with jj repositories, managing stacked/dependent commits, needing automatic rebasing with first-class conflict handling, using revsets to select commits, or wanting enhanced Git workflows. Triggers on mentions of 'jj', 'jujutsu', change IDs, operation log, or jj-specific commands. +--- + +# Jujutsu (jj) Version Control System + +## Overview + +Jujutsu is a powerful Git-compatible version control system that combines ideas from Git, Mercurial, Darcs, and adds novel features. It uses Git repositories as a storage backend, making it fully interoperable with existing Git tooling. + +**Key differentiators from Git:** +- Working copy is automatically committed (no staging area) +- Conflicts can be committed and resolved later +- Automatic rebasing of descendants when commits change +- Operation log enables easy undo of any operation +- Revsets provide powerful commit selection +- Change IDs stay stable across rewrites (unlike commit hashes) + +## When to Use This Skill + +- User mentions "jj", "jujutsu", or "jujutsu vcs" +- Working with stacked/dependent commits +- Questions about change IDs vs commit IDs +- Revset queries for selecting commits +- Conflict resolution workflows in jj +- Git interoperability with jj +- Operation log, undo, or redo operations +- History rewriting (squash, split, rebase, diffedit) +- Bookmark management (jj's equivalent of branches) + +## Key Concepts + +### Working Copy as a Commit + +In jj, the working copy is always a commit. Changes are automatically snapshotted: + +```bash +# No need for 'git add' - changes are tracked automatically +jj status # Shows working copy state +jj diff # Shows changes in working copy commit +``` + +### Change ID vs Commit ID + +- **Change ID**: Stable identifier that persists across rewrites (e.g., `kntqzsqt`) +- **Commit ID**: Hash that changes when commit is rewritten (e.g., `5d39e19d`) + +Always prefer change IDs when referring to commits in commands. + +### No Staging Area + +Instead of staging, use these patterns: +- `jj split` - Split working copy into multiple commits +- `jj squash -i` - Interactively move changes to parent +- Direct editing with `jj diffedit` + +### First-Class Conflicts + +Conflicts are recorded in commits, not blocking operations: + +```bash +jj rebase -s X -d Y # Succeeds even with conflicts +jj log # Shows conflicted commits with × +jj new # Work on top of conflict +# Edit files to resolve, then: +jj squash # Move resolution into parent +``` + +### Operation Log + +Every operation is recorded and can be undone: + +```bash +jj op log # View operation history +jj undo # Undo last operation +jj op restore # Restore to specific operation +``` + +## Essential Commands + +| Command | Description | Git Equivalent | +|---------|-------------|----------------| +| `jj git clone ` | Clone a Git repository | `git clone` | +| `jj git init` | Initialize new repo | `git init` | +| `jj status` / `jj st` | Show working copy status | `git status` | +| `jj log` | Show commit history | `git log --graph` | +| `jj diff` | Show changes | `git diff` | +| `jj new` | Create new empty commit | - | +| `jj describe` / `jj desc` | Edit commit message | `git commit --amend` (msg only) | +| `jj edit ` | Edit existing commit | `git checkout` + amend | +| `jj squash` | Move changes to parent | `git commit --amend` | +| `jj split` | Split commit in two | `git add -p` + multiple commits | +| `jj rebase` | Move commits | `git rebase` | +| `jj bookmark` / `jj b` | Manage bookmarks | `git branch` | +| `jj git fetch` | Fetch from remote | `git fetch` | +| `jj git push` | Push to remote | `git push` | +| `jj undo` | Undo last operation | `git reflog` + reset | +| `jj file annotate` | Show line origins | `git blame` | + +## Common Workflows + +### Starting a New Change + +```bash +# Working copy changes are auto-committed +# When ready to start fresh work: +jj new # Create new commit on top +jj describe -m "message" # Set description +# Or combine: +jj new -m "Start feature X" +``` + +### Editing a Previous Commit + +```bash +# Option 1: Edit in place +jj edit # Make working copy edit that commit +# Make changes, they're auto-committed +jj new # Return to working on new changes + +# Option 2: Squash changes into parent +jj squash # Move all changes to parent +jj squash -i # Interactively select changes +jj squash # Move specific file +``` + +### Rebasing Commits + +```bash +# Rebase current branch onto main +jj rebase -d main + +# Rebase specific revision and descendants +jj rebase -s -d + +# Rebase only specific revisions (not descendants) +jj rebase -r -d + +# Insert commit between others +jj rebase -r X -A Y # Insert X after Y +jj rebase -r X -B Y # Insert X before Y +``` + +### Working with Bookmarks (Branches) + +```bash +jj bookmark list # List bookmarks +jj bookmark create # Create at current commit +jj bookmark set # Move bookmark to current commit +jj bookmark delete # Delete bookmark +jj bookmark track @ # Track remote bookmark +``` + +### Pushing Changes + +```bash +# Push specific bookmark +jj git push --bookmark + +# Push change by creating auto-named bookmark +jj git push --change + +# Push all bookmarks +jj git push --all +``` + +### Resolving Conflicts + +```bash +# After a rebase creates conflicts: +jj log # Find conflicted commit (marked with ×) +jj new # Create commit on top +# Edit files to resolve conflicts +jj squash # Move resolution into conflicted commit + +# Or use external merge tool: +jj resolve # Opens merge tool for each conflict +``` + +### Undoing Mistakes + +```bash +jj undo # Undo last operation +jj op log # View operation history +jj op restore # Restore to specific state + +# View repo at past operation +jj --at-op= log +``` + +## Revsets Quick Reference + +Revsets select commits using a functional language: + +| Expression | Description | +|------------|-------------| +| `@` | Working copy commit | +| `@-` | Parent of working copy | +| `x-` | Parents of x | +| `x+` | Children of x | +| `::x` | Ancestors of x (inclusive) | +| `x::` | Descendants of x (inclusive) | +| `x..y` | Ancestors of y not in ancestors of x | +| `x::y` | Commits between x and y (DAG path) | +| `bookmarks()` | All bookmark targets | +| `trunk()` | Main branch (main/master) | +| `mine()` | Commits by current user | +| `conflicts()` | Commits with conflicts | +| `description(text)` | Commits with matching description | + +**Examples:** +```bash +jj log -r '@::' # Working copy and descendants +jj log -r 'trunk()..@' # Commits between trunk and working copy +jj log -r 'mine() & ::@' # My commits in working copy ancestry +jj rebase -s 'roots(trunk()..@)' -d trunk() # Rebase branch onto trunk +``` + +## Git Interoperability + +### Colocated Repositories + +By default, `jj git clone` and `jj git init` create colocated repos where both `jj` and `git` commands work: + +```bash +jj git clone # Creates colocated repo (default) +jj git clone --no-colocate # Non-colocated (jj only) +``` + +### Using Git Commands + +In colocated repos, Git changes are auto-imported. For non-colocated: + +```bash +jj git import # Import changes from Git +jj git export # Export changes to Git +``` + +### Converting Existing Git Repo + +```bash +cd existing-git-repo +jj git init --colocate # Add jj to existing Git repo +``` + +## Configuration + +Edit config with `jj config edit --user`: + +```toml +[user] +name = "Your Name" +email = "your@email.com" + +[ui] +default-command = "log" # Run 'jj log' when no command given +diff-editor = ":builtin" # Or "meld", "kdiff3", etc. + +[revset-aliases] +'wip' = 'description(exact:"") & mine()' # Custom revset alias +``` + +## Advanced Topics + +For comprehensive documentation, see: +- [references/revsets.md](references/revsets.md) - Complete revset reference +- [references/commands.md](references/commands.md) - Full command reference +- [references/git-comparison.md](references/git-comparison.md) - Git to jj command mapping + +## Troubleshooting + +**"Working copy is dirty"** - Never happens in jj! Working copy is always a commit. + +**Conflicts after rebase** - Normal in jj. Conflicts are recorded, resolve when convenient. + +**Lost commits** - Use `jj op log` to find when commits existed, then `jj op restore`. + +**Divergent changes** - Same change ID, different commits. Usually from concurrent edits: +```bash +jj log # Shows divergent commits +jj abandon # Remove one version +``` + +**Immutable commit error** - Can't modify trunk/tagged commits by default: +```bash +jj --ignore-immutable # Override protection +``` diff --git a/plugin.lock.json b/plugin.lock.json new file mode 100644 index 0000000..c2a8741 --- /dev/null +++ b/plugin.lock.json @@ -0,0 +1,61 @@ +{ + "$schema": "internal://schemas/plugin.lock.v1.json", + "pluginId": "gh:dashed/claude-marketplace:plugins/jj", + "normalized": { + "repo": null, + "ref": "refs/tags/v20251128.0", + "commit": "442bff07c9748b53336d513522bcb1c8eed5cd81", + "treeHash": "5a660cc6f4f6a2eaf497f7cc2c241b894d6400e6de1025f5fdb352703ab96b6e", + "generatedAt": "2025-11-28T10:16:05.918215Z", + "toolVersion": "publish_plugins.py@0.2.0" + }, + "origin": { + "remote": "git@github.com:zhongweili/42plugin-data.git", + "branch": "master", + "commit": "aa1497ed0949fd50e99e70d6324a29c5b34f9390", + "repoRoot": "/Users/zhongweili/projects/openmind/42plugin-data" + }, + "manifest": { + "name": "jj", + "description": "Jujutsu (jj) version control system - a Git-compatible VCS with novel features. Use when working with jj repositories, managing stacked commits, needing automatic rebasing with first-class conflict handling, using revsets to select commits, or wanting enhanced Git workflows. Triggers on mentions of 'jj', 'jujutsu', change IDs, or operation log.", + "version": "1.0.0" + }, + "content": { + "files": [ + { + "path": "README.md", + "sha256": "30721e1c4de730eb2d90af34b5ea780f70d7b822e093c898d76301501adfae46" + }, + { + "path": "SKILL.md", + "sha256": "392a27c60874f13ae43e313608e55f27900eba8553fa033a7ef310094c4a5220" + }, + { + "path": "references/git-comparison.md", + "sha256": "6109e4338d8da91ac1ac526aead4ab8155ff9cdc1633afdc61087aadfe49e840" + }, + { + "path": "references/commands.md", + "sha256": "6d9b9e31586313fe80be07ee7f6720d8657cb39eeb2297137ae8eeae0d9391c1" + }, + { + "path": "references/configuration.md", + "sha256": "2f5d8566592a00d934d3486dc82112076960f77e8fcfebf62a09445d8ddcef75" + }, + { + "path": "references/revsets.md", + "sha256": "ae1d311521e7f31025e11dc6d3e2dbd2a3e6b70f9af5eebe3c975f80a77315c9" + }, + { + "path": ".claude-plugin/plugin.json", + "sha256": "9b7ee9cb24d7e4bd3cc615f3b7544404276eb4c0f3b79658c7d1a568d50bfb79" + } + ], + "dirSha256": "5a660cc6f4f6a2eaf497f7cc2c241b894d6400e6de1025f5fdb352703ab96b6e" + }, + "security": { + "scannedAt": null, + "scannerVersion": null, + "flags": [] + } +} \ No newline at end of file diff --git a/references/commands.md b/references/commands.md new file mode 100644 index 0000000..49f1b0c --- /dev/null +++ b/references/commands.md @@ -0,0 +1,462 @@ +# Commands Reference + +Complete reference for jj commands and their options. + +## Table of Contents + +- [Repository Setup](#repository-setup) +- [Status and History](#status-and-history) +- [Creating and Editing Commits](#creating-and-editing-commits) +- [History Rewriting](#history-rewriting) +- [Bookmarks (Branches)](#bookmarks-branches) +- [Git Operations](#git-operations) +- [Operation Log](#operation-log) +- [File Operations](#file-operations) +- [Workspaces](#workspaces) +- [Configuration](#configuration) + +## Repository Setup + +### `jj git clone` + +Clone a Git repository: + +```bash +jj git clone [destination] +jj git clone --colocate # Allow git commands (default) +jj git clone --no-colocate # jj-only repo +jj git clone --branch # Clone specific branch +jj git clone --depth # Shallow clone +``` + +### `jj git init` + +Initialize a new repository: + +```bash +jj git init # New colocated repo (default) +jj git init --no-colocate # New jj-only repo +jj git init --git-repo # Use existing git repo as backend +``` + +## Status and History + +### `jj status` (alias: `st`) + +Show working copy status: + +```bash +jj status +jj st [paths...] # Status for specific paths +``` + +### `jj log` + +Show commit history: + +```bash +jj log # Default: mutable commits +jj log -r # Specific revisions +jj log -r '::' # All commits +jj log -n 10 # Limit to 10 commits +jj log -p # Show patches +jj log -s # Summary (files changed) +jj log --stat # Show diffstat +jj log --no-graph # Flat list, no graph +jj log --reversed # Oldest first +jj log -T