Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@ Run from a Git checkout:
npx diffsplain
```

The command opens a local page and compares the checkout with its default
branch. It starts at port `2299` and uses the next free port when needed. You
The command opens a local page showing staged, unstaged, and untracked changes
against `HEAD`, the same as `--worktree`. It starts at port `2299` and uses the
next free port when needed. You
need Node.js 22.13 or newer and a signed-in Codex, Claude, Copilot, Cursor, or
OpenCode CLI. Set a default with `diffsplain config agent NAME`, or choose one
run with `--agent NAME`. If neither is set, an interactive terminal lists
Expand Down
8 changes: 4 additions & 4 deletions docs/content/cli.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@ sidebar:

## Current checkout

With no target, Diffsplain compares the current checkout with its default
branch. The result includes local commits plus staged, unstaged, and untracked
work.
With no target, Diffsplain shows staged, unstaged, and untracked changes
against `HEAD`, the same as `--worktree`. Already committed changes are excluded.

```sh
npx diffsplain
Expand Down Expand Up @@ -62,7 +61,8 @@ npx diffsplain \

## Worktree changes

Use `--worktree` to show only tracked and untracked changes against `HEAD`:
Use `--worktree` explicitly to select the default review of tracked and
untracked changes against `HEAD`:

```sh
npx diffsplain --worktree
Expand Down
3 changes: 1 addition & 2 deletions docs/content/data.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ See the [CLI guide](/cli/) for all review commands.

| Target | Comparison | Workspace changes | Network and cache | Refresh |
| --- | --- | --- | --- | --- |
| Current checkout (no target flag) | Default-branch merge base through the current checkout | Local commits, staged, unstaged, and untracked files | May query the remote to find its default branch; does not fetch | Local state every two seconds |
| `--worktree` | `HEAD` through the current worktree | Staged, unstaged, and untracked files; excludes prior commits | No Git network | Local state every two seconds |
| Current checkout (no target flag), or `--worktree` | `HEAD` through the current worktree | Staged, unstaged, and untracked files; excludes prior commits | No Git network | Local state every two seconds |
| `--base REF` | The resolved base commit through the current worktree | Later commits, staged, unstaged, and untracked files | No Git network | Local state every two seconds |
| `--base REF --head REF` | The two resolved commit trees | None | No Git network | Moved refs every two seconds |
| `--branch NAME` | Remote base/head merge base through the remote branch head | None | Fetches into the Diffsplain bare cache | Remote data every 30 seconds |
Expand Down
5 changes: 3 additions & 2 deletions docs/content/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@ service.
npx diffsplain
```

The command compares the current checkout with its default branch and opens a
local page. It starts at port `2299` and uses the next free port when needed.
The command opens a local page showing staged, unstaged, and untracked changes
against `HEAD`, the same as `--worktree`. It starts at port `2299` and uses the
next free port when needed.

For a pull request:

Expand Down
4 changes: 2 additions & 2 deletions scripts/cli-args.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ const hostOption = cliOptions['--host'];

export const helpText = `Usage: diffsplain [REPO] [options]

Show the current checkout against its default branch:
Show worktree changes against HEAD (default):
diffsplain

Commands:
Expand Down Expand Up @@ -390,7 +390,7 @@ export function parseCliArgs(
if (branch) commonArgs.push('--branch', branch);
if (worktree) commonArgs.push('--worktree');
if (!pullRequest && !branch && !worktree && !base && !head) {
commonArgs.push('--checkout');
commonArgs.push('--worktree');
}
if (base) commonArgs.push('--base', base);
if (head) commonArgs.push('--head', head);
Expand Down
22 changes: 20 additions & 2 deletions tests/cli-args.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,34 @@ test('leaves agent selection open when no agent is passed', () => {
assert.equal(parsed.portWasPassed, false);
assert.equal(parsed.host, 'localhost');
assert.equal(parsed.browserEnabled, true);
assert.deepEqual(parsed.feedArgs, ['--repo', cwd, '--checkout']);
assert.deepEqual(parsed.feedArgs, ['--repo', cwd, '--worktree']);
assert.deepEqual(parsed.agentArgs, [
'--repo',
cwd,
'--checkout',
'--worktree',
'--batch-size',
'12',
'--jobs',
'3',
]);
});

test('defaults to the same review as --worktree when no target is supplied', () => {
for (const args of [
[],
['--no-agent', '--no-browser'],
['--agent', 'claude'],
['--repo', '/another/repo'],
]) {
const context = { callerDirectory: cwd, pathExists: missing };
assert.deepEqual(
parseCliArgs(args, context),
parseCliArgs([...args, '--worktree'], context),
args.join(' '),
);
}
});

test('passes no-checkout-access only to agent notes', () => {
const parsed = parseCliArgs(['--no-checkout-access'], {
callerDirectory: cwd,
Expand Down Expand Up @@ -74,6 +90,8 @@ test('keeps repeated exclusion rules in encounter order for both builders', () =

test('forwards flag-shaped exclusion patterns as values for both builders', () => {
const parsed = parseCliArgs([
'--base',
'main',
'--exclude',
'private/**',
'--exclude=--help',
Expand Down
Loading