Commit 237db5c
feat(cli): CLI UX improvements (#84)
* docs: add CLI v2 features design (issue #81)
Design for k-neighbor exploration, colored output, and shell completions.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* docs: add CLI v2 implementation plan (issue #81)
10-task plan covering shell completions, colored output, and k-neighbor
graph exploration for the pred CLI tool.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* feat(cli): add shell completions command (bash/zsh/fish)
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* test(cli): add integration tests for shell completions
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* feat(cli): add owo-colors dependency and color helper functions
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* feat(cli): add aligned columns and color to pred list
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* feat(cli): add colors to pred show output
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* feat(cli): add colors to pred path output
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* feat(lib): add k_neighbors BFS method to ReductionGraph
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* feat(cli): add --hops and --direction flags to pred show for neighbor exploration
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* test(cli): add integration tests for k-neighbor exploration
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* chore: apply rustfmt formatting
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* fix: address PR review comments
- Remove unused `fmt_arrow_out()` dead code (Copilot review)
- Deduplicate `find_node_index()` by delegating to existing `lookup_node()`
- Extract table formatting into reusable `format_table()` helper in output.rs
- Remove `completions` command and `clap_complete` dependency (manual setup not useful)
- Update CLI documentation with new table output and k-neighbor exploration examples
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* feat(cli): re-add completions with auto-detection and eval setup
Shell argument is now optional — auto-detects from $SHELL env.
Setup is just one line: eval "$(pred completions)"
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* feat(cli): add problem name completion for shell tab-completion
Custom ProblemNameParser provides all registered problem names and
aliases as completion candidates while still accepting any string
(so MIS/UnitDiskGraph variant syntax works).
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* fix(cli): use left arrow for "Reduces from" and green for all arrows
Makes direction immediately clear: → for outgoing, ← for incoming.
Both arrows use green for visual consistency. Removes unused
fmt_incoming() function.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* fix(cli): add tab completion hint to pred --help
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* feat(cli): make --to optional when --via is given in pred reduce
The target problem is already in the path file, so --to is redundant.
Now: pred reduce problem.json --via path.json -o reduced.json
Either --to or --via must be provided; error if neither is given.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* feat(cli): unify solve output format for direct and bundle solving
Use consistent Problem/Solver/Solution/Evaluation format for both
direct problem solving and reduction bundle solving. Bundle solver
shows "via <target>" in solver description. Add hint about -o flag
for JSON output with intermediate results.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* fix(cli): print solve hint after output, not before
Move the -o hint eprintln to after emit_with_default_name so the hint
appears at the last line of terminal output.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* fix(cli): only show solve hint when stderr is a TTY
Suppress the "Hint: use -o to save full solution details as JSON."
message when stderr is piped, so scripts and non-interactive usage
are not cluttered with the hint. Interactive terminal users still
see it.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* feat(cli): show auto-reduction info in solve human output
When solving a non-ILP problem with the ILP solver, the human text
output now shows "Solver: ilp (via ILP)" to indicate that auto-reduction
occurred. Previously this information was only visible in JSON output.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* feat(cli): add global -q/--quiet flag to suppress stderr info
Add a -q/--quiet global flag that suppresses all informational messages
on stderr (hints, "Wrote..." messages, summary messages). Only errors
still go to stderr in quiet mode. This enables clean scripting usage.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* feat(cli): print JSON to stdout when create is used without -o
Previously `pred create MIS --edges 0-1,1-2` printed "Created
MaximumIndependentSet instance" but discarded the actual data. Now it
prints the problem JSON to stdout, consistent with how `reduce` works
and enabling piping to other commands.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* feat(cli): add fuzzy matching for unknown problem names
Add "Did you mean ...?" suggestions when a problem name is not
recognized, using Levenshtein edit distance. All "Unknown problem"
error sites now also suggest running `pred list`.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* feat(cli): add --random flag for random problem instance generation
Support random Erdos-Renyi graph generation for graph-based problems
via `pred create <PROBLEM> --random --num-vertices N [--edge-prob P] [--seed S]`.
Uses a simple LCG PRNG with no external dependencies. Supported for
MIS, MVC, MaxCut, MaxClique, MaximumMatching, MinimumDominatingSet,
SpinGlass, KColoring, and TravelingSalesman.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* feat(cli): add inspect, stdin support, --json reduce, export-graph consistency
Remaining changes from CLI UX improvement plan:
- P4: export-graph uses global -o flag instead of positional arg
- P7: accept - for stdin in solve, evaluate, reduce
- P2: human-readable reduce output by default, --json flag for raw JSON
- F1: new inspect command for problem/bundle introspection
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* feat: add cli-demo Makefile target for end-to-end CLI testing
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* chore: apply rustfmt formatting
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* feat(cli): refactor show --hops --direction into pred to / pred from commands
Split neighbor exploration out of `pred show` into dedicated subcommands:
- `pred to MIS --hops 2` for outgoing neighbors
- `pred from QUBO --hops 1` for incoming neighbors
Tree output now shows variant-level information (e.g., `MIS {graph=SimpleGraph, weight=i32}`)
instead of just problem names. The `pred show` command is simplified to only inspect
problem details (variants, fields, reductions).
Resolves H2 from the CLI UX improvements audit.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* feat(cli): add create Factoring and solve --timeout
- P8: Support `pred create Factoring --target 15 --bits-m 4 --bits-n 4`
with all three flags required (replaces unhelpful bail message)
- H3: Add `--timeout <seconds>` to `pred solve` using thread+channel
pattern (default 0 = no limit, process exits on timeout)
- Add 6 CLI tests for Factoring creation and timeout behavior
- Update cli-demo, docs, and audit file
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* refactor: unify name+variant formatting and move tree-building to core
- Add fmt_node() as single source of truth for "bold name + plain variant"
- Move neighbor tree BFS from CLI into ReductionGraph::k_neighbor_tree()
- Add NeighborTree type to core library
- Remove petgraph-exposing helpers (find_node_index, neighbor_indices, etc.)
- Remove petgraph dependency from CLI crate
- Fix path header not formatting names as bold
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* chore: remove completed CLI plan files
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* feat(cli): add global --json flag for JSON output to stdout
All commands now support --json to print JSON to stdout. Previously
only `create` (always JSON) and `reduce` (per-command --json) did.
- Add `--json` as a global CLI flag on OutputConfig
- Update emit_with_default_name to handle -o / --json / human-text
- Remove per-command --json from ReduceArgs (now global)
- Wire path and path --all through emit or --json branch
- Update docs and after_help
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>1 parent 6e36c4a commit 237db5c
35 files changed
Lines changed: 3196 additions & 377 deletions
File tree
- .claude
- docs/src
- examples
- problemreductions-cli
- src
- commands
- tests
- src
- models
- graph
- set
- specialized
- rules
- unit_tests
- models/graph
- rules
- tests/suites
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
| 30 | + | |
| 31 | + | |
30 | 32 | | |
31 | 33 | | |
32 | 34 | | |
| |||
48 | 50 | | |
49 | 51 | | |
50 | 52 | | |
| 53 | + | |
51 | 54 | | |
52 | 55 | | |
53 | 56 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| |||
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
| 28 | + | |
28 | 29 | | |
29 | 30 | | |
30 | 31 | | |
| |||
196 | 197 | | |
197 | 198 | | |
198 | 199 | | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
0 commit comments