Skip to content

feat: undo/redo system, action history, and LLM-agent CLI ergonomics - #84

Merged
e6qu merged 2 commits into
mainfrom
feat/undo-redo-json-cli-clean
Mar 15, 2026
Merged

feat: undo/redo system, action history, and LLM-agent CLI ergonomics#84
e6qu merged 2 commits into
mainfrom
feat/undo-redo-json-cli-clean

Conversation

@e6qu

@e6qu e6qu commented Mar 15, 2026

Copy link
Copy Markdown
Owner

Summary

  • Undo/redo system: Linear timeline with cursor model. All mutating commands (init, mode, veil, unveil, apply, restore, checkpoint, gc, clean) record pre/post state snapshots to .funveil/history/log.yaml. Undo restores pre-state (config + files from CAS), redo restores post-state. New action after undo discards future. 500-entry cap with auto-truncation.
  • Action history: fv history lists past/future actions with timestamps. fv history --show <id> shows config diffs and file size changes for a specific action.
  • --json global flag: Machine-readable JSON output via CommandResult enum with #[serde(tag = "command")]. Errors include error codes (E001-E034). Enables LLM agents to parse fv output programmatically.
  • --dry-run flag: Added to veil, unveil, and apply — previews what would change without modifying state.
  • --files flag on status: Per-file state reporting (veiled/unveiled, full/partial, ranges).
  • New commands: undo [--force], redo, history [--limit N] [--show <id>]

Files changed

File Changes
src/history.rs NewActionRecord, ActionState, FileSnapshot, ActionHistory with 18 unit tests
src/main.rs New commands, --json/--dry-run/--files flags, CommandResult enum, history integration, 15 new tests
src/error.rs HistoryEmpty, NothingToRedo, ActionNotUndoable variants + code() method
src/config.rs HISTORY_DIR constant, normalize_path() helper, history dir in ensure_data_dir()
src/lib.rs Register history module, new re-exports
Cargo.toml serde_json made unconditional dependency

Test plan

  • cargo test --all-features — all 1,724 tests pass (33 new)
  • cargo clippy --all-targets --all-features -- -D warnings — clean
  • Manual: fv init → fv veil src/ → fv history → fv undo → verify restored → fv redo → verify veiled again
  • Manual: fv veil src/ --json → valid JSON; fv veil src/ --dry-run → no state change
  • Manual: fv status --files --json → per-file detail as JSON
  • Manual: fv history show 2 → shows config diff and file size changes

Implement a linear-timeline undo/redo system with snapshot-based state
restoration, action history with config/file diffs, and machine-readable
CLI output for LLM agent consumption.

- Add history module with ActionRecord, ActionState, FileSnapshot structs
  and ActionHistory with load/save/push/undo/redo/past/future/get methods
- New commands: undo [--force], redo, history [--limit N] [--show <id>]
- Record pre/post state snapshots for all mutating commands
- Add --json global flag for structured JSON output via CommandResult enum
- Add --dry-run flag to veil, unveil, and apply commands
- Add --files flag to status for per-file state reporting
- Add error codes (E001-E034) for machine-parseable error responses
- Add normalize_path helper and HISTORY_DIR constant
- 500-entry history cap with automatic truncation and ID renumbering
@github-actions

github-actions Bot commented Mar 15, 2026

Copy link
Copy Markdown

🔒 Security Report

Check Status
cargo audit ✅ Pass
cargo deny ✅ Pass
pip-audit ✅ Pass

@github-actions

github-actions Bot commented Mar 15, 2026

Copy link
Copy Markdown

Coverage Report

Metric PR Base Delta
Statement 97.01% 97.36% -0.36% (regression)
Branch 89.09% 89.43% -0.33% (regression)
Per-file coverage (28 files)
File Statement Branch Lines
/home/runner/work/funveil/funveil/src/update.rs 84.4% 83.3% 92/109
/home/runner/work/funveil/funveil/src/parser/languages/markdown.rs 91.4% 73.3% 85/93
/home/runner/work/funveil/funveil/src/output.rs 93.8% 100.0% 45/48
/home/runner/work/funveil/funveil/src/parser/languages/typescript.rs 93.8% 80.0% 285/304
/home/runner/work/funveil/funveil/src/main.rs 94.0% 84.4% 1402/1492
/home/runner/work/funveil/funveil/src/parser/languages/xml.rs 94.2% 71.4% 49/52
/home/runner/work/funveil/funveil/src/parser/languages/css.rs 94.4% 80.0% 102/108
/home/runner/work/funveil/funveil/src/veil.rs 95.0% 92.1% 627/660
/home/runner/work/funveil/funveil/src/logging.rs 95.2% 75.0% 60/63
/home/runner/work/funveil/funveil/src/history.rs 95.5% 91.7% 85/89
/home/runner/work/funveil/funveil/src/parser/languages/go.rs 97.2% 80.3% 310/319
/home/runner/work/funveil/funveil/src/parser/languages/html.rs 97.3% 61.5% 109/112
/home/runner/work/funveil/funveil/src/parser/languages/zig.rs 97.5% 82.8% 274/281
/home/runner/work/funveil/funveil/src/checkpoint.rs 97.9% 93.5% 235/240
/home/runner/work/funveil/funveil/src/cas.rs 98.5% 92.6% 128/130
/home/runner/work/funveil/funveil/src/analysis/call_graph.rs 99.0% 82.5% 283/286
/home/runner/work/funveil/funveil/src/patch/manager.rs 99.1% 83.3% 347/350
/home/runner/work/funveil/funveil/src/patch/parser.rs 99.3% 93.6% 268/270
/home/runner/work/funveil/funveil/src/analysis/cache.rs 99.4% 94.4% 163/164
/home/runner/work/funveil/funveil/src/parser/tree_sitter_parser.rs 99.5% 93.8% 611/614
/home/runner/work/funveil/funveil/src/types.rs 99.6% 97.0% 272/273
/home/runner/work/funveil/funveil/src/analysis/entrypoints.rs 100.0% 97.3% 754/754
/home/runner/work/funveil/funveil/src/config.rs 100.0% 100.0% 295/295
/home/runner/work/funveil/funveil/src/error.rs 100.0% 0.0% 37/37
/home/runner/work/funveil/funveil/src/parser/mod.rs 100.0% 100.0% 167/167
/home/runner/work/funveil/funveil/src/perms.rs 100.0% 100.0% 35/35
/home/runner/work/funveil/funveil/src/strategies/header.rs 100.0% 94.4% 151/151
/home/runner/work/funveil/funveil/src/strategies/mod.rs 100.0% 0.0% 17/17

- Add 50+ tests covering undo/redo state restoration, history show
  config diffs, JSON output for all commands, dry-run modes, checkpoint
  history recording, error codes, restore_action_state, and more
- Statement coverage: 95.27% -> 97.01%, branch: 87.72% -> 89.03%
- Update CI: 97% statement floor, 87% branch floor, 1% relative
  tolerance with absolute floors enforced (prevents progressive erosion)
- Add PLAN.md: physical file removal, parser-based veiling, and
  progressive disclosure for context window optimization
@e6qu
e6qu merged commit b23659b into main Mar 15, 2026
14 checks passed
@e6qu
e6qu deleted the feat/undo-redo-json-cli-clean branch March 15, 2026 00:49
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