feat(diff): cross-surface /diff with staged/all/session modes

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>
This commit is contained in:
teknium1
2026-07-26 14:25:28 -07:00
committed by Teknium
parent 88d45edca2
commit 0fa5e41c86
30 changed files with 1035 additions and 64 deletions
+5
View File
@@ -279,6 +279,11 @@ Future messages in this room will use that transcript until `/reset` or another
restored: "✅ Herstel na kontrolepunt {hash}: {reason}\n'n Voor-terugrol-momentopname is outomaties gestoor."
restore_failed: "❌ {error}"
diff:
not_enabled: "Kontrolepunte is nie geaktiveer nie, dus is daar geen sessie-basislyn nie.\nAktiveer in config.yaml:\n```\ncheckpoints:\n enabled: true\n```\nGewone /diff werk steeds — dit gebruik git direk."
no_changes: "Geen veranderinge nie."
failed: "{error}"
set_home:
save_failed: "Kon nie tuiste-kanaal stoor nie: {error}"
success: "✅ Tuiste-kanaal gestel op **{name}** (ID: {chat_id}).\nKron-take en kruisplatform-boodskappe sal hier afgelewer word."
+5
View File
@@ -299,6 +299,11 @@ gateway:
restored: "✅ استُعيد إلى نقطة التحقّق {hash}: {reason}\nحُفظت لقطة ما قبل التراجع تلقائيًا."
restore_failed: "❌ {error}"
diff:
not_enabled: "نقاط التحقق غير مفعّلة، لذا لا يوجد خط أساس للجلسة.\nفعّلها في config.yaml:\n```\ncheckpoints:\n enabled: true\n```\nلا يزال /diff العادي يعمل — فهو يستخدم git مباشرة."
no_changes: "لا توجد تغييرات."
failed: "{error}"
set_home:
save_failed: "فشل حفظ القناة الرئيسية: {error}"
success: "✅ ضُبطت القناة الرئيسية إلى **{name}** (المعرّف: {chat_id}).\nستُسلَّم مهام cron والرسائل عبر المنصّات هنا."
+5
View File
@@ -279,6 +279,11 @@ Future messages in this room will use that transcript until `/reset` or another
restored: "✅ Auf Checkpoint {hash} wiederhergestellt: {reason}\nEin Pre-Rollback-Snapshot wurde automatisch gespeichert."
restore_failed: "❌ {error}"
diff:
not_enabled: "Checkpoints sind nicht aktiviert, daher gibt es keine Sitzungs-Baseline.\nIn config.yaml aktivieren:\n```\ncheckpoints:\n enabled: true\n```\nEin einfaches /diff funktioniert weiterhin — es nutzt git direkt."
no_changes: "Keine Änderungen."
failed: "{error}"
set_home:
save_failed: "Home-Kanal konnte nicht gespeichert werden: {error}"
success: "✅ Home-Kanal auf **{name}** (ID: {chat_id}) gesetzt.\nCron-Jobs und plattformübergreifende Nachrichten werden hierher geliefert."
+5
View File
@@ -291,6 +291,11 @@ gateway:
restored: "✅ Restored to checkpoint {hash}: {reason}\nA pre-rollback snapshot was saved automatically."
restore_failed: "❌ {error}"
diff:
not_enabled: "Checkpoints are not enabled, so there's no session baseline.\nEnable in config.yaml:\n```\ncheckpoints:\n enabled: true\n```\nPlain /diff still works — it uses git directly."
no_changes: "No changes."
failed: "{error}"
set_home:
save_failed: "Failed to save home channel: {error}"
success: "✅ Home channel set to **{name}** (ID: {chat_id}).\nCron jobs and cross-platform messages will be delivered here."
+5
View File
@@ -276,6 +276,11 @@ gateway:
restored: "✅ Restaurado al checkpoint {hash}: {reason}\nSe guardó automáticamente un snapshot previo al rollback."
restore_failed: "❌ {error}"
diff:
not_enabled: "Los checkpoints no están activados, así que no hay línea base de sesión.\nActívalos en config.yaml:\n```\ncheckpoints:\n enabled: true\n```\nEl /diff normal sigue funcionando — usa git directamente."
no_changes: "Sin cambios."
failed: "{error}"
set_home:
save_failed: "No se pudo guardar el canal principal: {error}"
success: "✅ Canal principal establecido en **{name}** (ID: {chat_id}).\nLas tareas cron y los mensajes entre plataformas se entregarán aquí."
+5
View File
@@ -279,6 +279,11 @@ Future messages in this room will use that transcript until `/reset` or another
restored: "✅ Restauré au point de contrôle {hash} : {reason}\nUn instantané pré-rollback a été enregistré automatiquement."
restore_failed: "❌ {error}"
diff:
not_enabled: "Les points de contrôle ne sont pas activés, il n'y a donc pas de référence de session.\nActivez-les dans config.yaml :\n```\ncheckpoints:\n enabled: true\n```\nLe /diff simple fonctionne toujours — il utilise git directement."
no_changes: "Aucun changement."
failed: "{error}"
set_home:
save_failed: "Impossible d'enregistrer le canal principal : {error}"
success: "✅ Canal principal défini sur **{name}** (ID : {chat_id}).\nLes tâches cron et les messages multi-plateformes seront livrés ici."
+5
View File
@@ -283,6 +283,11 @@ Future messages in this room will use that transcript until `/reset` or another
restored: "✅ Aischurtha go seicphointe {hash}: {reason}\nSábháladh roghchóip réamh-rollback go huathoibríoch."
restore_failed: "❌ {error}"
diff:
not_enabled: "Níl seicphointí cumasaithe, mar sin níl aon bhonnlíne seisiúin ann.\nCumasaigh in config.yaml:\n```\ncheckpoints:\n enabled: true\n```\nOibríonn /diff simplí fós — úsáideann sé git go díreach."
no_changes: "Gan athruithe."
failed: "{error}"
set_home:
save_failed: "Theip ar shábháil chainéil bhaile: {error}"
success: "✅ Cainéal baile socraithe go **{name}** (ID: {chat_id}).\nSeachadfar tascanna cron agus teachtaireachtaí trasardáin anseo."
+5
View File
@@ -279,6 +279,11 @@ Future messages in this room will use that transcript until `/reset` or another
restored: "✅ Visszaállítva a(z) {hash} ellenőrzőpontra: {reason}\nA visszaállítás előtti pillanatkép automatikusan elmentve."
restore_failed: "❌ {error}"
diff:
not_enabled: "A checkpointok nincsenek engedélyezve, így nincs munkamenet-alapvonal.\nEngedélyezd a config.yaml-ban:\n```\ncheckpoints:\n enabled: true\n```\nA sima /diff továbbra is működik — közvetlenül a gitet használja."
no_changes: "Nincs változás."
failed: "{error}"
set_home:
save_failed: "Nem sikerült menteni a kezdőcsatornát: {error}"
success: "✅ Kezdőcsatorna beállítva: **{name}** (ID: {chat_id}).\nA cron-feladatok és a platformok közötti üzenetek ide érkeznek."
+5
View File
@@ -279,6 +279,11 @@ Future messages in this room will use that transcript until `/reset` or another
restored: "✅ Ripristinato al checkpoint {hash}: {reason}\nUno snapshot pre-rollback è stato salvato automaticamente."
restore_failed: "❌ {error}"
diff:
not_enabled: "I checkpoint non sono abilitati, quindi non esiste una baseline di sessione.\nAbilitali in config.yaml:\n```\ncheckpoints:\n enabled: true\n```\nIl /diff semplice funziona comunque — usa git direttamente."
no_changes: "Nessuna modifica."
failed: "{error}"
set_home:
save_failed: "Salvataggio del canale home non riuscito: {error}"
success: "✅ Canale home impostato su **{name}** (ID: {chat_id}).\nI cron job e i messaggi cross-platform verranno consegnati qui."
+5
View File
@@ -279,6 +279,11 @@ Future messages in this room will use that transcript until `/reset` or another
restored: "✅ チェックポイント {hash} に復元しました: {reason}\nロールバック前のスナップショットが自動的に保存されました。"
restore_failed: "❌ {error}"
diff:
not_enabled: "チェックポイントが有効になっていないため、セッションのベースラインがありません。\nconfig.yaml で有効にしてください:\n```\ncheckpoints:\n enabled: true\n```\n通常の /diff は引き続き使えます — git を直接使用します。"
no_changes: "変更はありません。"
failed: "{error}"
set_home:
save_failed: "ホームチャンネルを保存できませんでした: {error}"
success: "✅ ホームチャンネルを **{name}** (ID: {chat_id}) に設定しました。\nCron ジョブとプラットフォーム間メッセージはここに配信されます。"
+5
View File
@@ -279,6 +279,11 @@ Future messages in this room will use that transcript until `/reset` or another
restored: "✅ 체크포인트 {hash}(으)로 복원됨: {reason}\n롤백 전 스냅샷이 자동으로 저장되었습니다."
restore_failed: "❌ {error}"
diff:
not_enabled: "체크포인트가 활성화되지 않아 세션 기준선이 없습니다.\nconfig.yaml에서 활성화하세요:\n```\ncheckpoints:\n enabled: true\n```\n일반 /diff는 여전히 작동합니다 — git을 직접 사용합니다."
no_changes: "변경 사항이 없습니다."
failed: "{error}"
set_home:
save_failed: "홈 채널 저장에 실패했습니다: {error}"
success: "✅ 홈 채널이 **{name}**(ID: {chat_id})(으)로 설정되었습니다.\n크론 작업과 플랫폼 간 메시지가 여기로 전달됩니다."
+5
View File
@@ -279,6 +279,11 @@ Future messages in this room will use that transcript until `/reset` or another
restored: "✅ Restaurado para o checkpoint {hash}: {reason}\nFoi guardado automaticamente um snapshot anterior ao rollback."
restore_failed: "❌ {error}"
diff:
not_enabled: "Os checkpoints não estão ativados, então não há linha de base da sessão.\nAtive em config.yaml:\n```\ncheckpoints:\n enabled: true\n```\nO /diff simples continua funcionando — ele usa git diretamente."
no_changes: "Sem alterações."
failed: "{error}"
set_home:
save_failed: "Falha ao guardar o canal principal: {error}"
success: "✅ Canal principal definido como **{name}** (ID: {chat_id}).\nAs tarefas cron e mensagens entre plataformas serão entregues aqui."
+5
View File
@@ -279,6 +279,11 @@ Future messages in this room will use that transcript until `/reset` or another
restored: "✅ Восстановлено до контрольной точки {hash}: {reason}\nСнимок перед откатом сохранён автоматически."
restore_failed: "❌ {error}"
diff:
not_enabled: "Контрольные точки не включены, поэтому базовой линии сессии нет.\nВключите в config.yaml:\n```\ncheckpoints:\n enabled: true\n```\nОбычный /diff по-прежнему работает — он использует git напрямую."
no_changes: "Изменений нет."
failed: "{error}"
set_home:
save_failed: "Не удалось сохранить главный канал: {error}"
success: "✅ Главный канал установлен на **{name}** (ID: {chat_id}).\nCron-задачи и межплатформенные сообщения будут доставляться сюда."
+5
View File
@@ -279,6 +279,11 @@ Future messages in this room will use that transcript until `/reset` or another
restored: "✅ {hash} kontrol noktasına geri yüklendi: {reason}\nGeri alma öncesi anlık görüntü otomatik olarak kaydedildi."
restore_failed: "❌ {error}"
diff:
not_enabled: "Kontrol noktaları etkin değil, bu yüzden oturum temel çizgisi yok.\nconfig.yaml içinde etkinleştirin:\n```\ncheckpoints:\n enabled: true\n```\nDüz /diff yine de çalışır — doğrudan git kullanır."
no_changes: "Değişiklik yok."
failed: "{error}"
set_home:
save_failed: "Ana kanal kaydedilemedi: {error}"
success: "✅ Ana kanal **{name}** (ID: {chat_id}) olarak ayarlandı.\nCron işleri ve platformlar arası mesajlar buraya iletilecek."
+5
View File
@@ -279,6 +279,11 @@ Future messages in this room will use that transcript until `/reset` or another
restored: "✅ Відновлено до контрольної точки {hash}: {reason}\nЗнімок перед відкатом збережено автоматично."
restore_failed: "❌ {error}"
diff:
not_enabled: "Контрольні точки не ввімкнено, тому базової лінії сесії немає.\nУвімкніть у config.yaml:\n```\ncheckpoints:\n enabled: true\n```\nЗвичайний /diff все одно працює — він використовує git напряму."
no_changes: "Змін немає."
failed: "{error}"
set_home:
save_failed: "Не вдалося зберегти головний канал: {error}"
success: "✅ Головний канал встановлено на **{name}** (ID: {chat_id}).\nCron-завдання та міжплатформні повідомлення доставлятимуться сюди."
+5
View File
@@ -279,6 +279,11 @@ Future messages in this room will use that transcript until `/reset` or another
restored: "✅ 已還原至檢查點 {hash}:{reason}\n已自動儲存回復前的快照。"
restore_failed: "❌ {error}"
diff:
not_enabled: "檢查點未啟用,因此沒有工作階段基準線。\n在 config.yaml 中啟用:\n```\ncheckpoints:\n enabled: true\n```\n一般 /diff 仍然可用 — 它直接使用 git。"
no_changes: "沒有變更。"
failed: "{error}"
set_home:
save_failed: "無法儲存主頻道:{error}"
success: "✅ 主頻道已設定為 **{name}**(ID:{chat_id})。\n排程任務和跨平台訊息將傳送至此處。"
+5
View File
@@ -279,6 +279,11 @@ Future messages in this room will use that transcript until `/reset` or another
restored: "✅ 已恢复到检查点 {hash}:{reason}\n已自动保存回滚前的快照。"
restore_failed: "❌ {error}"
diff:
not_enabled: "检查点未启用,因此没有会话基线。\n在 config.yaml 中启用:\n```\ncheckpoints:\n enabled: true\n```\n普通 /diff 仍然可用 — 它直接使用 git。"
no_changes: "没有更改。"
failed: "{error}"
set_home:
save_failed: "无法保存主频道:{error}"
success: "✅ 主频道已设置为 **{name}**(ID:{chat_id})。\n定时任务和跨平台消息将发送到此处。"