commit 7df36e3dda7a1a04f02636f1a69718158dcc8209 Author: Zhongwei Li Date: Sat Nov 29 18:50:36 2025 +0800 Initial commit diff --git a/.claude-plugin/plugin.json b/.claude-plugin/plugin.json new file mode 100644 index 0000000..ed08361 --- /dev/null +++ b/.claude-plugin/plugin.json @@ -0,0 +1,12 @@ +{ + "name": "jj", + "description": "Jujutsu (jj) version control commands", + "version": "2025-10-12", + "author": { + "name": "Jeff Hui", + "email": "jeff@jeffhui.net" + }, + "commands": [ + "./commands" + ] +} \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..d84a1c1 --- /dev/null +++ b/README.md @@ -0,0 +1,3 @@ +# jj + +Jujutsu (jj) version control commands diff --git a/commands/commit.md b/commands/commit.md new file mode 100644 index 0000000..3fd5125 --- /dev/null +++ b/commands/commit.md @@ -0,0 +1,47 @@ +# Commit Changes + +You are tasked with creating jj commits for the changes made during this session. + +## Process: + +1. **Think about what changed:** + - Review the conversation history and understand what was accomplished + - Run `jj status` to see current changes + - Run `jj diff` to understand the modifications + - Consider whether changes should be one commit or multiple logical commits + +2. **Plan your commit(s):** + - Identify which files belong together + - Draft clear, descriptive commit messages + - Use imperative mood in commit messages + - Focus on why the changes were made, not just what + +3. **Present your plan to the user:** + - List the files you plan to include for each commit + - Show the commit message(s) you'll use + - Ask: "I plan to create [N] commit(s) with these changes. Shall I proceed?" + +4. **Execute upon confirmation:** + - Use `jj describe` to set the commit message for the current working copy + - Use `jj split` if multiple logical commits are needed + - Show the result with `jj log -n [number]` + +## Important: +- **NEVER add co-author information or Claude attribution** +- Commits should be authored solely by the user +- Do not include any "Generated with Claude" messages +- Do not add "Co-Authored-By" lines +- Write commit messages as if the user wrote them + +## Jujutsu-specific notes: +- Jujutsu automatically tracks all changes in the working copy +- Use `jj describe` to set the commit message +- Use `jj split` to split changes into multiple commits if needed +- Use `jj squash` to combine commits if necessary +- The working copy revision is automatically updated + +## Remember: +- You have the full context of what was done in this session +- Group related changes together +- Keep commits focused and atomic when possible +- The user trusts your judgment - they asked you to commit diff --git a/commands/create_prs.md b/commands/create_prs.md new file mode 100644 index 0000000..b6bac72 --- /dev/null +++ b/commands/create_prs.md @@ -0,0 +1,91 @@ +# Create Pull Requests from Stack + +You are tasked with creating pull requests for all changes in the current jj tree. + +## Process: + +1. **Ask about PR configuration:** + - Ask the user: "Should all PRs be based on the main branch, or should each PR be based on its direct parent branch?" + - Ask the user: "Should the PRs be created as drafts or published immediately?" + - Wait for user responses before proceeding + +2. **Understand the current state:** + - Run `jj log` to visualize the current commit tree + - Identify which commits need PRs + - Understand the branch structure and relationships + +3. **Push branches to origin:** + - Run `jj git push --allow-new` to push all branches + - Parse the output to identify which branches were pushed + - Track the branch names and their corresponding commits + +4. **Create PRs for each new branch:** + - For each new branch that was pushed: + - Determine the commit range for changes (use `jj log` and `jj diff`) + - Generate a clear, descriptive PR title based on the commit message(s) + - Create a PR body that describes the changes: + - Summarize what changed and why + - Include relevant context about the implementation + - Do NOT include Claude attribution or co-author information + - Determine the base branch: + - If user chose "main branch": use main (or master) + - If user chose "parent branch": use the direct parent commit's branch + - Create the PR: + - If user chose "drafts": Run `gh pr create --draft -H --base --head --title "" --body "<body>"` + - If user chose "published": Run `gh pr create -H <bookmark-name> --base <base-branch> --head <branch-name> --title "<title>" --body "<body>"` + - Store the PR URL and branch name for later use + +5. **Build the stack information:** + - Determine the order of PRs from closest to main to furthest + - For each PR, identify its position in the stack + +6. **Update all PR descriptions with stack links:** + - For each PR created: + - Build the stack section showing all PRs in order + - Mark the current PR with `<-- This PR` + - Use `gh pr edit <PR-URL> --body "<updated-body>"` to add the stack section + - Stack format: + ```md + Stack: + - https://github.com/<org>/<project>/pull/<id> + - https://github.com/<org>/<project>/pull/<id2> <-- This PR + - https://github.com/<org>/<project>/pull/<id3> + ``` + +7. **Generate summary:** + - Create a summary table showing: + - Bookmark/branch name + - Corresponding PR URL + - Base branch + - Present this to the user + +## Important: + +- **NEVER add co-author information or Claude attribution** +- PRs should be authored solely by the user +- Do not include any "Generated with Claude" messages +- Do not add "Co-Authored-By" lines +- Write PR descriptions in the user's voice + +## Jujutsu and GitHub CLI notes: + +- `jj git push --allow-new` will push all branches and output which ones are new +- Use `jj log -r 'bookmarks()'` to see all bookmarks +- Use `jj diff -r <revision>` to see changes for a specific commit +- Use `gh pr create` to create PRs programmatically +- Use `gh pr edit` to update PR descriptions after creation +- Use `gh pr list --json url,number,headRefName` to query existing PRs if needed + +## Error handling: + +- If push fails, report the error and stop +- If PR creation fails for a branch, report it but continue with other branches +- If PR description update fails, report it but continue with other PRs +- At the end, report any errors encountered + +## Remember: + +- The stack visualization helps reviewers understand dependencies +- PRs based on parent branches create a more granular review process +- PRs based on main are simpler but may have larger diffs +- Each PR should stand alone in its description despite being part of a stack diff --git a/commands/rebase.md b/commands/rebase.md new file mode 100644 index 0000000..9de3487 --- /dev/null +++ b/commands/rebase.md @@ -0,0 +1,60 @@ +# Rebase Current Changeset + +You are tasked with rebasing the current changeset onto the primary branch. + +## Process: + +1. **Determine the primary branch:** + - Run `jj log -r 'bookmarks()' --no-graph` to list all bookmarks + - Check if `main` or `master` exists in the bookmark list + - If `main` exists, use it as the primary branch + - If `main` doesn't exist but `master` does, use `master` as the primary branch + - If neither exists, ask the user: "What is the name of your primary branch?" + - Wait for the user's response before proceeding + +2. **Pull latest changes:** + - Run `jj git fetch` to fetch the latest changes from the remote + - This ensures we're rebasing onto the latest version of the primary branch + +3. **Identify the changeset to rebase:** + - Run `jj log -r 'mine() & ::@'` to see the current changeset and its ancestors + - The current changeset is marked with `@` in the log + - Identify the changeset ID of the current working copy (the one with `@`) + +4. **Rebase the changeset:** + - Run `jj rebase -s <changeset-id> -d <primary-branch>` + - Where `<changeset-id>` is the ID of the current working copy + - Where `<primary-branch>` is the primary branch determined in step 1 + - This rebases the current changeset and all its descendants onto the primary branch + +5. **Show the result:** + - Run `jj log` to display the updated commit tree + - Confirm to the user that the rebase was successful + +## Important: + +- **DO NOT rebase changesets that are part of bookmarks you plan to delete** +- Only rebase the current changeset chain, not other branches +- If there are conflicts during rebase, report them to the user and stop +- Use `jj git fetch` instead of `jj git pull` to avoid automatic merging + +## Jujutsu-specific notes: + +- `jj rebase -s <source> -d <destination>` rebases the source changeset and all its descendants +- The `-s` flag specifies the source changeset to rebase +- The `-d` flag specifies the destination to rebase onto +- Jujutsu handles rebasing automatically, updating the working copy +- Use changeset IDs or revision expressions (like `@` for current working copy) + +## Error handling: + +- If `jj git fetch` fails, report the error and stop +- If the primary branch doesn't exist locally, report this and ask the user to verify +- If rebase fails due to conflicts, report the conflicts and provide guidance +- If the user is not on a changeset that can be rebased, explain why + +## Remember: + +- Rebasing updates the working copy to be based on the latest primary branch +- This is useful before creating pull requests or pushing changes +- The user trusts your judgment to identify the correct changeset to rebase diff --git a/plugin.lock.json b/plugin.lock.json new file mode 100644 index 0000000..975be1e --- /dev/null +++ b/plugin.lock.json @@ -0,0 +1,53 @@ +{ + "$schema": "internal://schemas/plugin.lock.v1.json", + "pluginId": "gh:jeffh/claude-plugins:jj", + "normalized": { + "repo": null, + "ref": "refs/tags/v20251128.0", + "commit": "166f6c2a1b03b1c5117ee27051d76191ab63d8ba", + "treeHash": "d12fb95330cd27d4ec912a83868e3af00198f008293d1602d2df659daa5c1b0a", + "generatedAt": "2025-11-28T10:18:01.221332Z", + "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 commands", + "version": "2025-10-12" + }, + "content": { + "files": [ + { + "path": "README.md", + "sha256": "28ab613cc18f5c0ec5db1f0bf8568c8142515b37b944589adc5e2e0868c079eb" + }, + { + "path": ".claude-plugin/plugin.json", + "sha256": "04c9d23ffa78b56e2f491c3cc00f4a50cc807cf7f6fd8c70c7134aff8612efec" + }, + { + "path": "commands/rebase.md", + "sha256": "dd01e387f5e95bb61fecec51dd5c3f09bd851c220f8144a2436491f26315f5d0" + }, + { + "path": "commands/commit.md", + "sha256": "a9691c72900c508b392bd1200bdc0946f21767d7d0da3a93944dee4e2ff6e6c3" + }, + { + "path": "commands/create_prs.md", + "sha256": "6032cd4f3787c5ecd6b4afafbacdd8bdd30022f305090bb6b1631efce46dedd1" + } + ], + "dirSha256": "d12fb95330cd27d4ec912a83868e3af00198f008293d1602d2df659daa5c1b0a" + }, + "security": { + "scannedAt": null, + "scannerVersion": null, + "flags": [] + } +} \ No newline at end of file