Split comments into separate commits. When you add code and comments together, use this with jj split to commit the code changes first while leaving comment-only changes in your working copy. This lets you stage, squash, and manipulate documentation separately from logic changes.
No installation needed! Run directly from JSR with Deno:
# Add to your jj config (~/.config/jj/config.toml)
[merge-tools.split-comments]
program = "deno"
edit-args = [
"run",
"--allow-read=/tmp",
"--allow-write=/tmp",
"--allow-env=JJ_SPLIT_LOG",
"jsr:@farnoy/jj-comment-splitter",
"$left",
"$right"
]Then use it:
jj split --tool split-commentsRunning jj split --tool split-comments creates one commit with non-comment changes and leaves comment-only changes in your working copy.
Supports // and # style comments.
The tool needs:
--allow-read=/tmp- jj creates temporary directories in /tmp for the split operation--allow-write=/tmp- To write the filtered changes back--allow-env=JJ_SPLIT_LOG- To read the optionalJJ_SPLIT_LOGenvironment variable for verbose output
Set JJ_SPLIT_LOG=1 to see detailed output:
JJ_SPLIT_LOG=1 jj split --tool split-commentsClone the repository and run with Deno:
git clone https://github.com/farnoy/code-comment-splitter.git
cd code-comment-splitter
# Run directly
deno task start <leftDir> <rightDir>
# Or with full permissions
deno run --allow-read --allow-write --allow-env src/cli/jj-merge-tool.ts <leftDir> <rightDir>deno task test # Run tests
deno task check # Type check
deno task dev # Watch modeTo use your local version instead of GitHub:
[merge-tools.split-comments]
program = "deno"
edit-args = [
"run",
"--allow-read=/tmp",
"--allow-write=/tmp",
"--allow-env=JJ_SPLIT_LOG",
"/absolute/path/to/src/cli/jj-merge-tool.ts",
"$left",
"$right"
]code-comment-splitter/
├── src/
│ ├── cli/jj-merge-tool.ts # CLI entry point
│ ├── lib/splitNonComment.ts # Core logic (LCS-based diff algorithm)
│ └── __tests__/splitNonComment.test.ts
└── deno.json
ISC