Skip to content

refactor(cli): Unify turn-range flags across compact and print#804

Merged
JeanMertz merged 1 commit into
mainfrom
jp-compact-flags
Jun 29, 2026
Merged

refactor(cli): Unify turn-range flags across compact and print#804
JeanMertz merged 1 commit into
mainfrom
jp-compact-flags

Conversation

@JeanMertz

Copy link
Copy Markdown
Collaborator

Both jp conversation compact and jp conversation print now share the same --from/--to/--last/--turn selectors via a new TurnRange type in cmd::turn_range. Previously each command had its own parallel implementations of these flags with inconsistent semantics.

All absolute turn positions on the user-facing side are now 1-based: --turn 1 and --from 1 address the first turn, --to -1 addresses the last. The config @N form for keep_first/keep_last is likewise 1-based. Internally, RangeBound::Absolute and Turn::index() remain 0-based; the translation happens once at the CLI resolution boundary in cmd::turn_range.

Timeline output (jp conversation compact --dry-run) now displays 1-based turn numbers ("Compacted turns 2..=8" rather than "1..=7").

A new architecture document (docs/architecture/indexing-conventions.md) fixes the 1-based/0-based convention so future flags, config keys, and display values have a single rule to follow. The RFD-064 document is updated with a note pointing to the new convention.

BREAKING CHANGE: Absolute turn positions in --from, --to, and --turn are now 1-based

Any script or config using a numeric absolute turn index (--from 3, --to 7, --turn 2, or the @N config form) must increment the value by one to preserve the previous behaviour. Count-based flags (--last N, --keep-first N, --keep-last N) and from-end offsets (--from -N) are unaffected.

Both `jp conversation compact` and `jp conversation print` now share the
same `--from`/`--to`/`--last`/`--turn` selectors via a new `TurnRange`
type in `cmd::turn_range`. Previously each command had its own parallel
implementations of these flags with inconsistent semantics.

All absolute turn positions on the user-facing side are now **1-based**:
`--turn 1` and `--from 1` address the first turn, `--to -1` addresses
the last. The config `@N` form for `keep_first`/`keep_last` is likewise
1-based. Internally, `RangeBound::Absolute` and `Turn::index()` remain
0-based; the translation happens once at the CLI resolution boundary in
`cmd::turn_range`.

Timeline output (`jp conversation compact --dry-run`) now displays
1-based turn numbers ("Compacted turns 2..=8" rather than "1..=7").

A new architecture document (`docs/architecture/indexing-conventions.md`)
fixes the 1-based/0-based convention so future flags, config keys, and
display values have a single rule to follow. The RFD-064 document is
updated with a note pointing to the new convention.

BREAKING CHANGE: Absolute turn positions in `--from`, `--to`, and `--turn`
are now 1-based

Any script or config using a numeric absolute turn index (`--from 3`,
`--to 7`, `--turn 2`, or the `@N` config form) must increment the value
by one to preserve the previous behaviour. Count-based flags (`--last N`,
`--keep-first N`, `--keep-last N`) and from-end offsets (`--from -N`) are
unaffected.

Signed-off-by: Jean Mertz <git@jeanmertz.com>
@JeanMertz JeanMertz merged commit 1128203 into main Jun 29, 2026
16 checks passed
@JeanMertz JeanMertz deleted the jp-compact-flags branch June 29, 2026 13:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant