Skip to content

feat(diff): /diff — review everything Hermes changed this session - #53527

Closed
Harshkamdar67 wants to merge 1 commit into
NousResearch:mainfrom
Harshkamdar67:feat/diff-session-changes
Closed

feat(diff): /diff — review everything Hermes changed this session#53527
Harshkamdar67 wants to merge 1 commit into
NousResearch:mainfrom
Harshkamdar67:feat/diff-session-changes

Conversation

@Harshkamdar67

@Harshkamdar67 Harshkamdar67 commented Jun 27, 2026

Copy link
Copy Markdown
Contributor

What does this PR do?

Adds a /diff command 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 /diff PRs (#4839, #22703)

I found two open /diff PRs while checking for duplicates. Both are thin wrappers around git diff in the cwd, and neither addresses what #4865 actually asks for:

#4839 / #22703 This PR
Mechanism raw git diff / git diff --cached diff vs the earliest checkpoint (session baseline)
Requires the project to be a git repo Yes - bails with "Not a git repository" No - uses Hermes's checkpoint shadow store
Scoped to what Hermes changed No - shows all your working-tree edits too Yes - only changes since the session's first checkpoint
Surfaces CLI only CLI + messaging gateway + TUI

If 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

  • New feature (non-breaking change that adds functionality)

Changes Made

  • tools/checkpoint_manager.py - new CheckpointManager.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] in COMMAND_REGISTRY.
  • hermes_cli/cli_commands_mixin.py + cli.py - CLI handler _handle_diff_command and dispatch.
  • gateway/slash_commands.py + gateway/run.py + locales/en.yaml - gateway handler and dispatch (other locales fall back to English via t()).
  • tui_gateway/server.py - diff.session JSON-RPC method (counterpart to rollback.diff).
  • Docs: website/docs/reference/slash-commands.md, agent SKILL.md command list.

How to Test

  1. Run with checkpoints on: hermes --checkpoints
  2. Ask Hermes to edit a couple of files.
  3. Run /diff for the cumulative diff of all its edits this session; /diff --stat for the summary only.
  4. Works even if the project directory is not a git repo.

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

  • I've read the Contributing Guide
  • My commit messages follow Conventional Commits
  • I searched for existing PRs to make sure this isn't a duplicate (see "Relationship to existing PRs" above - same /diff name, materially different approach)
  • My PR contains only changes related to this feature
  • I've added tests for my changes
  • I've tested on my platform: Windows 11

Documentation & Housekeeping

  • I've updated relevant documentation (docs/, SKILL.md command list)
  • No new config keys (reuses the existing checkpoints config) - cli-config.yaml.example N/A
  • Cross-platform: pure git/subprocess via the existing checkpoint engine; ruff + scripts/check-windows-footguns.py clean

@Harshkamdar67
Harshkamdar67 force-pushed the feat/diff-session-changes branch from d354516 to 9cd9019 Compare June 27, 2026 09:21
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.
@Harshkamdar67
Harshkamdar67 force-pushed the feat/diff-session-changes branch from 9cd9019 to 64ee9a6 Compare June 27, 2026 09:25
@alt-glitch alt-glitch added type/feature New feature or request P3 Low — cosmetic, nice to have comp/cli CLI entry point, hermes_cli/, setup wizard comp/gateway Gateway runner, session dispatch, delivery comp/tui Terminal UI (ui-tui/ + tui_gateway/) labels Jun 27, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

This was generated by AI during triage.

Competing /diff implementation alongside open #4839 and #22703 (both raw git diff wrappers that require a git repo). This PR instead diffs against the session-start checkpoint via the checkpoint shadow store (Fixes #4865 approach #2) and works in non-git directories. Flagging the three-PR cluster so a maintainer can pick the mechanism.

@tonydwb tonydwb left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
  • --stat flag 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

@teknium1

Copy link
Copy Markdown
Contributor

Thanks for pursuing the checkpoint-backed variant and for covering the CLI, gateway, and backend RPC paths.

Problems

  • tools/checkpoint_manager.py's proposed session_diff() selects the oldest retained item from list_checkpoints(). On current main, that list is a persistent per-project ref (tools/checkpoint_manager.py:690-729) and pruning rewrites it independently of sessions (tools/checkpoint_manager.py:1053-1118). It therefore cannot guarantee a current-session baseline: it may include prior-session changes or lose the real session-start state.
  • The proposed diff.session RPC is not wired into the TUI. This PR changes no ui-tui/src files. Current ui-tui/src/app/createSlashHandler.ts:40-148 routes unregistered commands to slash.exec, and that worker creates a separate HermesCLI (tui_gateway/slash_worker.py:155-168) instead of invoking the live-session RPC.

Suggested changes

  • Track a baseline explicitly by live session and working directory, then add regressions for consecutive sessions and retention pruning.
  • Add a native TUI /diff route that calls diff.session, plus an end-to-end slash-handler test.

This is an automated hermes-sweeper review.

@teknium1 teknium1 added sweeper:risk-compatibility Sweeper risk: may break existing users, config, migrations, defaults, or upgrades sweeper:blast-contained Sweeper blast radius: contained — one narrow path / opt-in / few users area/sessions Session lifecycle, resume, persistence, history labels Jul 15, 2026
teknium1 added a commit that referenced this pull request Jul 26, 2026
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>
teknium1 added a commit that referenced this pull request Jul 27, 2026
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>
teknium1 added a commit that referenced this pull request Jul 27, 2026
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>
teknium1 added a commit that referenced this pull request Jul 27, 2026
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>
@teknium1

Copy link
Copy Markdown
Contributor

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!

@teknium1 teknium1 closed this Jul 27, 2026
randlee pushed a commit to randlee/hermes-agent that referenced this pull request Aug 11, 2026
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/sessions Session lifecycle, resume, persistence, history comp/cli CLI entry point, hermes_cli/, setup wizard comp/gateway Gateway runner, session dispatch, delivery comp/tui Terminal UI (ui-tui/ + tui_gateway/) P3 Low — cosmetic, nice to have sweeper:blast-contained Sweeper blast radius: contained — one narrow path / opt-in / few users sweeper:risk-compatibility Sweeper risk: may break existing users, config, migrations, defaults, or upgrades type/feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[UX] No /diff command to see what the agent changed this session

4 participants