jjack 开源工具简化 jj 用户的 GitHub PR 栈管理
jjack 是一个面向 jj 版本控制用户的 CLI 与 TypeScript 库,用于在 GitHub 上管理 PR 栈,其实现参考了 jj-spr 与 spr 的思路但已明显分化。作者坦言该工具完全由前沿模型 vibe-coding 生成、自己未阅读代码,但工具与 GitHub 测试模拟层已针对真实 GitHub 行为做了较充分验证。项目公开主要是为支撑其另一仓库 ah 的栈管理 GUI。
报道正文
本文目录5 个章节
jjack
jjack is a CLI and TypeScript library to help jj users manage PR stacks on GitHub.
It started as a very stripped-down TS port of @papertigers"s [native-stacks branch](https://github.com/papertigers/jj-spr/tree/native-stacks of jj-spr (which in turn comes from spr), but at this point it")s fairly different in implementation. See THIRD_PARTY_NOTICES.md for attribution and licenses.
Because jjack is built narrowly around how I want to work, I don't expect anyone else to want to use it, but you might take it as inspiration when building your own stack tool. This repo is public mostly because my other public repo ah depends on it for its stack management GUI, and I want anyone interested in that to be able to see all the pieces.
This was entirely vibe-coded with a variety of frontier models. I have not read any of the code and do not plan to. Despite that (or because of it), the tool and the GitHub test fake are pretty well-validated against actual GitHub behavior.
If you're looking for a stack tool to actually use yourself, you'll probably want one of these instead:
- jj-spr (original at jennings/jj-spr, native stacks at papertigers/jj-spr)
- jj-ryu
- jj-stack
See docs/comparison.md for details on how jjack differs from them.
The problem with stacks on GitHub
A big problem for jj users trying to use stacks on GitHub is that if you do things naively, every time you change a PR lower in the stack, whether by editing a commit or adding a new one, later PRs get rebased and force pushed. This results in a very poor reviewing experience in GitHub because the reviewer cannot easily tell what changed between pushes. The jj-spr approach is to treat what gets pushed to GitHub as a sort of generated projection of the "real" change you have in jj locally, taking what is intuitive for you and turning it into something entirely different that displays well on GitHub. In practice what that means is merge commits.
How jjack does it (which is also how jj-spr does it)
Say you have a stack of three PRs, A, B, and C, and the bottom one has three changes:
You make a change to A2 locally:
From git's point of view, everything from A2' on is brand new, so if you were to push the branches for A, B, and C directly, those are force pushes. What jj spr diff and jjack submit do here instead is maintain a second representation of the change that preserves all the existing commits, turning your change to A2 above into this:
U is an ordinary commit on top of A's branch that contains your edit. MB is a merge commit on B's branch with parents B1 and U. MC is a merge commit on C's branch with parents C1 and MB. Every commit that was already on GitHub is untouched, so each PR shows the update as new commits on top of what reviewers have already seen.
This is Git and GitHub's fault
The only reason all this is necessary is that Git doesn't have a good canonical spot to put the information necessary to make this work well, and GitHub does not know how to display stacks and the changes between them properly. They're stuck in a very tough spot because the vast majority of their users are not using jj, but their most savvy users want functionality like this.
We want interdiff!
Install
Requires Node 24 or later, jj, and git. It also needs gh unless you pass --token or set jjack.token. From a checkout of this repository:
npm install && npm run build && npm install --global .Configuration
jjack reads jj config and falls back to the jj-spr keys, so a repository already set up for jj-spr works without changes.
| Key | Falls back to | Default |
|---|---|---|
jjack.branchPrefix | spr.branchPrefix | none (required; e.g., yourname/) |
jjack.repository | spr.githubRepository | from the remote's URL (owner/repo) |
jjack.remote | spr.githubRemoteName | origin |
jjack.mainBranch | spr.githubMasterBranch | the remote's bookmark at jj's trunk(), or main |
jjack.requireApproval | spr.requireApproval | false |
jjack.token | spr.githubAuthToken | the output of gh auth token |
jjack.apiUrl | spr.githubApiUrl | https://api.github.com |
jj config set --repo jjack.branchPrefix yourname/--branch-prefix, --repository, and --token override these for a single run.
(注:更多技术实现细节与完整 API 文档请查阅原项目 README)