refactor(cli): Unify turn-range flags across compact and print#804
Merged
Conversation
7a78841 to
7a71587
Compare
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>
1d1ba9b to
1b116f2
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Both
jp conversation compactandjp conversation printnow share the same--from/--to/--last/--turnselectors via a newTurnRangetype incmd::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 1and--from 1address the first turn,--to -1addresses the last. The config@Nform forkeep_first/keep_lastis likewise 1-based. Internally,RangeBound::AbsoluteandTurn::index()remain 0-based; the translation happens once at the CLI resolution boundary incmd::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--turnare now 1-basedAny script or config using a numeric absolute turn index (
--from 3,--to 7,--turn 2, or the@Nconfig 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.