feat(diff): /diff — review everything Hermes changed this session - #53527
feat(diff): /diff — review everything Hermes changed this session#53527Harshkamdar67 wants to merge 1 commit into
Conversation
d354516 to
9cd9019
Compare
Adds a /diff slash command that shows the cumulative git diff from the
earliest retained checkpoint (the pre-edit baseline) to the current
working tree, i.e. "what has Hermes changed here?" in one view.
Complements /rollback diff <N> (single-checkpoint preview) without
duplicating it, and reuses the existing checkpoint shadow-store engine via
a new CheckpointManager.session_diff() helper.
Wired into all three surfaces that already expose checkpoints:
- CLI: /diff [--stat] (hermes_cli/cli_commands_mixin.py + cli.py dispatch)
- Gateway: /diff [--stat] (gateway/slash_commands.py + run.py dispatch,
en.yaml strings; other locales fall back to English)
- TUI: diff.session JSON-RPC method (tui_gateway/server.py)
Tests: session_diff unit tests, CLI handler tests, gateway E2E tests
(real git + checkpoint store), and TUI RPC tests. ruff + windows-footguns
clean.
9cd9019 to
64ee9a6
Compare
Competing |
tonydwb
left a comment
There was a problem hiding this comment.
Code Review Summary
Verdict: Approved
New /diff command that shows the cumulative diff from the earliest retained checkpoint to the current working tree. Complements /rollback diff <N> (single-checkpoint preview).
Looks Good
- Clean implementation across CLI, gateway, and slash_commands
--statflag for summary-only output- Diff truncation at 60 lines with helpful message
- Gateway version properly loads checkpoint config from config.yaml
- Integration with existing
CheckpointManager.session_diff() - Localized strings used for user-facing messages
14 files touched, all related to the same feature. Well-scoped.
Reviewed by Hermes Agent
|
Thanks for pursuing the checkpoint-backed variant and for covering the CLI, gateway, and backend RPC paths. Problems
Suggested changes
This is an automated hermes-sweeper review. |
Widen the cherry-picked /diff base (#4839 by @SHL0MS) into one cross-surface implementation, folding in the review feedback and the best ideas from the two sibling PRs (#22703, #53527): - tools/working_diff.py: shared git collection layer — unstaged (default), staged, and all (vs HEAD) modes; untracked files folded in via `git diff --no-index` so new files appear as additions (Codex /diff parity); shlex-split arguments preserve quoted paths. - CLI: handler moved to hermes_cli/cli_commands_mixin.py per the current god-file decomposition (dispatch stays in cli.py), renders through the rich console with a 400-line terminal-flood guard. - Gateway: _handle_diff_command in gateway/slash_commands.py + dispatch in gateway/run.py; fenced ```diff output truncated to 60 lines / 3000 chars before the platform senders apply their own per-platform message clamps (tool-progress-style layered truncation). Localized strings in all 17 locale catalogs. - /diff session (from #53527): cumulative checkpoint-baseline diff of everything Hermes changed, via new CheckpointManager.session_diff(); docstring records the retained-baseline approximation caveat from review. Works on both surfaces; degrades with an actionable message when checkpoints are off. - Slack: /diff routed via /hermes diff (50-slash cap; keeps telegram-parity test green and /version native). - Registry: cross-surface CommandDef with staged|all|session subcommands; docs: slash-commands reference (CLI + gateway tables + both-surfaces list) and hermes-agent skill reference. - Tests: tests/tools/test_working_diff.py (real git repos), tests/hermes_cli/test_diff_command.py (real git + stubbed checkpoint manager), tests/gateway/test_diff_command.py (end-to-end handler, real checkpoint store), TestSessionDiff in tests/tools/test_checkpoint_manager.py. Salvaged from the /diff PR cluster #4839 + #22703 + #53527. Co-authored-by: Ninso112 <ninso112@proton.me> Co-authored-by: Harshkamdar67 <harshkamdar67@gmail.com>
Widen the cherry-picked /diff base (#4839 by @SHL0MS) into one cross-surface implementation, folding in the review feedback and the best ideas from the two sibling PRs (#22703, #53527): - tools/working_diff.py: shared git collection layer — unstaged (default), staged, and all (vs HEAD) modes; untracked files folded in via `git diff --no-index` so new files appear as additions (Codex /diff parity); shlex-split arguments preserve quoted paths. - CLI: handler moved to hermes_cli/cli_commands_mixin.py per the current god-file decomposition (dispatch stays in cli.py), renders through the rich console with a 400-line terminal-flood guard. - Gateway: _handle_diff_command in gateway/slash_commands.py + dispatch in gateway/run.py; fenced ```diff output truncated to 60 lines / 3000 chars before the platform senders apply their own per-platform message clamps (tool-progress-style layered truncation). Localized strings in all 17 locale catalogs. - /diff session (from #53527): cumulative checkpoint-baseline diff of everything Hermes changed, via new CheckpointManager.session_diff(); docstring records the retained-baseline approximation caveat from review. Works on both surfaces; degrades with an actionable message when checkpoints are off. - Slack: /diff routed via /hermes diff (50-slash cap; keeps telegram-parity test green and /version native). - Registry: cross-surface CommandDef with staged|all|session subcommands; docs: slash-commands reference (CLI + gateway tables + both-surfaces list) and hermes-agent skill reference. - Tests: tests/tools/test_working_diff.py (real git repos), tests/hermes_cli/test_diff_command.py (real git + stubbed checkpoint manager), tests/gateway/test_diff_command.py (end-to-end handler, real checkpoint store), TestSessionDiff in tests/tools/test_checkpoint_manager.py. Salvaged from the /diff PR cluster #4839 + #22703 + #53527. Co-authored-by: Ninso112 <ninso112@proton.me> Co-authored-by: Harshkamdar67 <harshkamdar67@gmail.com>
Widen the cherry-picked /diff base (#4839 by @SHL0MS) into one cross-surface implementation, folding in the review feedback and the best ideas from the two sibling PRs (#22703, #53527): - tools/working_diff.py: shared git collection layer — unstaged (default), staged, and all (vs HEAD) modes; untracked files folded in via `git diff --no-index` so new files appear as additions (Codex /diff parity); shlex-split arguments preserve quoted paths. - CLI: handler moved to hermes_cli/cli_commands_mixin.py per the current god-file decomposition (dispatch stays in cli.py), renders through the rich console with a 400-line terminal-flood guard. - Gateway: _handle_diff_command in gateway/slash_commands.py + dispatch in gateway/run.py; fenced ```diff output truncated to 60 lines / 3000 chars before the platform senders apply their own per-platform message clamps (tool-progress-style layered truncation). Localized strings in all 17 locale catalogs. - /diff session (from #53527): cumulative checkpoint-baseline diff of everything Hermes changed, via new CheckpointManager.session_diff(); docstring records the retained-baseline approximation caveat from review. Works on both surfaces; degrades with an actionable message when checkpoints are off. - Slack: /diff routed via /hermes diff (50-slash cap; keeps telegram-parity test green and /version native). - Registry: cross-surface CommandDef with staged|all|session subcommands; docs: slash-commands reference (CLI + gateway tables + both-surfaces list) and hermes-agent skill reference. - Tests: tests/tools/test_working_diff.py (real git repos), tests/hermes_cli/test_diff_command.py (real git + stubbed checkpoint manager), tests/gateway/test_diff_command.py (end-to-end handler, real checkpoint store), TestSessionDiff in tests/tools/test_checkpoint_manager.py. Salvaged from the /diff PR cluster #4839 + #22703 + #53527. Co-authored-by: Ninso112 <ninso112@proton.me> Co-authored-by: Harshkamdar67 <harshkamdar67@gmail.com>
Widen the cherry-picked /diff base (#4839 by @SHL0MS) into one cross-surface implementation, folding in the review feedback and the best ideas from the two sibling PRs (#22703, #53527): - tools/working_diff.py: shared git collection layer — unstaged (default), staged, and all (vs HEAD) modes; untracked files folded in via `git diff --no-index` so new files appear as additions (Codex /diff parity); shlex-split arguments preserve quoted paths. - CLI: handler moved to hermes_cli/cli_commands_mixin.py per the current god-file decomposition (dispatch stays in cli.py), renders through the rich console with a 400-line terminal-flood guard. - Gateway: _handle_diff_command in gateway/slash_commands.py + dispatch in gateway/run.py; fenced ```diff output truncated to 60 lines / 3000 chars before the platform senders apply their own per-platform message clamps (tool-progress-style layered truncation). Localized strings in all 17 locale catalogs. - /diff session (from #53527): cumulative checkpoint-baseline diff of everything Hermes changed, via new CheckpointManager.session_diff(); docstring records the retained-baseline approximation caveat from review. Works on both surfaces; degrades with an actionable message when checkpoints are off. - Slack: /diff routed via /hermes diff (50-slash cap; keeps telegram-parity test green and /version native). - Registry: cross-surface CommandDef with staged|all|session subcommands; docs: slash-commands reference (CLI + gateway tables + both-surfaces list) and hermes-agent skill reference. - Tests: tests/tools/test_working_diff.py (real git repos), tests/hermes_cli/test_diff_command.py (real git + stubbed checkpoint manager), tests/gateway/test_diff_command.py (end-to-end handler, real checkpoint store), TestSessionDiff in tests/tools/test_checkpoint_manager.py. Salvaged from the /diff PR cluster #4839 + #22703 + #53527. Co-authored-by: Ninso112 <ninso112@proton.me> Co-authored-by: Harshkamdar67 <harshkamdar67@gmail.com>
|
The session-scoped diff mode from this PR landed via #72240 (now merged) — /diff session shows only files Hermes touched this session, credited in the unifying PR. Thanks! |
Widen the cherry-picked /diff base (NousResearch#4839 by @SHL0MS) into one cross-surface implementation, folding in the review feedback and the best ideas from the two sibling PRs (NousResearch#22703, NousResearch#53527): - tools/working_diff.py: shared git collection layer — unstaged (default), staged, and all (vs HEAD) modes; untracked files folded in via `git diff --no-index` so new files appear as additions (Codex /diff parity); shlex-split arguments preserve quoted paths. - CLI: handler moved to hermes_cli/cli_commands_mixin.py per the current god-file decomposition (dispatch stays in cli.py), renders through the rich console with a 400-line terminal-flood guard. - Gateway: _handle_diff_command in gateway/slash_commands.py + dispatch in gateway/run.py; fenced ```diff output truncated to 60 lines / 3000 chars before the platform senders apply their own per-platform message clamps (tool-progress-style layered truncation). Localized strings in all 17 locale catalogs. - /diff session (from NousResearch#53527): cumulative checkpoint-baseline diff of everything Hermes changed, via new CheckpointManager.session_diff(); docstring records the retained-baseline approximation caveat from review. Works on both surfaces; degrades with an actionable message when checkpoints are off. - Slack: /diff routed via /hermes diff (50-slash cap; keeps telegram-parity test green and /version native). - Registry: cross-surface CommandDef with staged|all|session subcommands; docs: slash-commands reference (CLI + gateway tables + both-surfaces list) and hermes-agent skill reference. - Tests: tests/tools/test_working_diff.py (real git repos), tests/hermes_cli/test_diff_command.py (real git + stubbed checkpoint manager), tests/gateway/test_diff_command.py (end-to-end handler, real checkpoint store), TestSessionDiff in tests/tools/test_checkpoint_manager.py. Salvaged from the /diff PR cluster NousResearch#4839 + NousResearch#22703 + NousResearch#53527. Co-authored-by: Ninso112 <ninso112@proton.me> Co-authored-by: Harshkamdar67 <harshkamdar67@gmail.com>
What does this PR do?
Adds a
/diffcommand that shows everything Hermes changed in the working directory this session - the cumulative diff from the earliest retained checkpoint (the pre-edit baseline) to the current working tree. It answers "what did you actually change?" before committing, in one view.This is the checkpoint/session-scoped approach requested in #4865 (approach #2 - "diff against checkpoint 0 (session start)", and the issue's Update note: "aggregate existing per-edit checkpoint diffs into a session-level summary").
Relationship to existing
/diffPRs (#4839, #22703)I found two open
/diffPRs while checking for duplicates. Both are thin wrappers aroundgit diffin the cwd, and neither addresses what #4865 actually asks for:git diff/git diff --cachedIf maintainers prefer one of the raw-git approaches, I'm happy to close this - but it's the only one of the three that solves the "what did the agent change this session" UX in #4865, and it works in non-git project directories where the others don't.
Related Issue
Fixes #4865
Type of Change
Changes Made
tools/checkpoint_manager.py- newCheckpointManager.session_diff()that diffs the earliest retained checkpoint against the working tree (reuses the existing.diff()staging machinery; returns{success, stat, diff, empty}).hermes_cli/commands.py- register/diff [--stat]inCOMMAND_REGISTRY.hermes_cli/cli_commands_mixin.py+cli.py- CLI handler_handle_diff_commandand dispatch.gateway/slash_commands.py+gateway/run.py+locales/en.yaml- gateway handler and dispatch (other locales fall back to English viat()).tui_gateway/server.py-diff.sessionJSON-RPC method (counterpart torollback.diff).website/docs/reference/slash-commands.md, agentSKILL.mdcommand list.How to Test
hermes --checkpoints/difffor the cumulative diff of all its edits this session;/diff --statfor the summary only.Automated:
pytest tests/tools/test_checkpoint_manager.py::TestSessionDiff -q(session_diff unit tests)pytest tests/hermes_cli/test_diff_command.py -q(CLI handler)pytest tests/gateway/test_diff_command.py -q(gateway E2E - real git + checkpoint store)pytest tests/test_tui_gateway_server.py -k diff_session -q(TUI RPC)Checklist
Code
/diffname, materially different approach)Documentation & Housekeeping
docs/, SKILL.md command list)checkpointsconfig) -cli-config.yaml.exampleN/Ascripts/check-windows-footguns.pyclean