The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(cli): say "uncommitted changes" when keeping a dirty worktree on exit
kshitijk4poorcf15cd318661
diff --git a/cli.py b/cli.pyindex d720266f390..bc5feb3b954 100644--- a/cli.py+++ b/cli.py@@ -587,7 +587,13 @@ def _cleanup_worktree(info: Dict[str, str] = None) -> None:if not Path(wt_path).exists():return- if _worktree_has_unpushed_commits(wt_path, timeout=10) or _worktree_is_dirty(wt_path, timeout=10):+ if _worktree_is_dirty(wt_path, timeout=10):+ # Uncommitted work: say so, and don't hint at `remove --force`, which would destroy it.+ _cprint(f"\n\033[33m{_t('cli.worktree.uncommitted_keeping', path=wt_path)}\033[0m")+ _active_worktree = None+ return++ if _worktree_has_unpushed_commits(wt_path, timeout=10):if _repo_is_shallow(repo_root):# Shallow boundary makes the unpushed verdict unreliable; the startup pruner reaps later._cprint(f"\n\033[33m{_t('cli.worktree.shallow_clone_keeping', path=wt_path)}\033[0m")diff --git a/locales/af.yaml b/locales/af.yamlindex 8e4e060ef73..bc585ed2b57 100644--- a/locales/af.yaml+++ b/locales/af.yaml@@ -3286,6 +3286,7 @@ cli:shallow_clone_keeping: "⚠ Vlak kloon — kan nie stootstatus verifieer nie, word behou: {path}"next_session_deepens: "Die volgende `hermes -w`-sessie verdiep die kloon en snoei saamgevoegde werkbome outomaties."unpushed_keeping: "⚠ Werkboom het ongestootte commits, word behou: {path}"+ uncommitted_keeping: "⚠ Werkboom het ongecommitte veranderinge, word behou: {path}"clean_up_manually: "Om met die hand op te ruim: git worktree remove --force {path}"cleaned_up: "✓ Werkboom opgeruim: {path}"display:diff --git a/locales/ar.yaml b/locales/ar.yamlindex 10664ca2d37..830b57d4f0f 100644--- a/locales/ar.yaml+++ b/locales/ar.yaml@@ -3286,6 +3286,7 @@ cli:shallow_clone_keeping: "⚠ استنساخ سطحي — لا يمكن التحقق من حالة الدفع، سيُحتفظ به: {path}"next_session_deepens: "جلسة `hermes -w` التالية تعمّق الاستنساخ وتحذف worktrees المدمجة تلقائيًا."unpushed_keeping: "⚠ يحتوي worktree على إيداعات غير مدفوعة، سيُحتفظ به: {path}"+ uncommitted_keeping: "⚠ يحتوي worktree على تغييرات غير مودعة، سيُحتفظ به: {path}"clean_up_manually: "للتنظيف يدويًا: git worktree remove --force {path}"cleaned_up: "✓ تم تنظيف worktree: {path}"display:diff --git a/locales/de.yaml b/locales/de.yamlindex 41c5c88e0c7..b481d18cbf4 100644--- a/locales/de.yaml+++ b/locales/de.yaml@@ -3286,6 +3286,7 @@ cli:shallow_clone_keeping: "⚠ Flacher Klon — Push-Status kann nicht geprüft werden, wird behalten: {path}"next_session_deepens: "Die nächste `hermes -w`-Sitzung vertieft den Klon und entfernt gemergte Worktrees automatisch."unpushed_keeping: "⚠ Worktree hat nicht gepushte Commits, wird behalten: {path}"+ uncommitted_keeping: "⚠ Worktree hat nicht committete Änderungen, wird behalten: {path}"clean_up_manually: "Manuell aufräumen mit: git worktree remove --force {path}"cleaned_up: "✓ Worktree aufgeräumt: {path}"display:diff --git a/locales/en.yaml b/locales/en.yamlindex e4f844ca2b3..032b7d4acd0 100644--- a/locales/en.yaml+++ b/locales/en.yaml@@ -3387,6 +3387,7 @@ cli:shallow_clone_keeping: "⚠ Shallow clone — cannot verify push state, keeping: {path}"next_session_deepens: "The next `hermes -w` session deepens the clone and prunes merged worktrees automatically."unpushed_keeping: "⚠ Worktree has unpushed commits, keeping: {path}"+ uncommitted_keeping: "⚠ Worktree has uncommitted changes, keeping: {path}"clean_up_manually: "To clean up manually: git worktree remove --force {path}"cleaned_up: "✓ Worktree cleaned up: {path}"diff --git a/locales/es.yaml b/locales/es.yamlindex 71b3090d1fe..60a9b7bbf33 100644--- a/locales/es.yaml+++ b/locales/es.yaml@@ -3286,6 +3286,7 @@ cli:shallow_clone_keeping: "⚠ Clon superficial — no se puede verificar el estado del push, se conserva: {path}"next_session_deepens: "La próxima sesión `hermes -w` profundiza el clon y elimina automáticamente los worktrees fusionados."unpushed_keeping: "⚠ El worktree tiene commits sin push, se conserva: {path}"+ uncommitted_keeping: "⚠ El worktree tiene cambios sin commit, se conserva: {path}"clean_up_manually: "Para limpiar manualmente: git worktree remove --force {path}"cleaned_up: "✓ Worktree limpiado: {path}"display:diff --git a/locales/fr.yaml b/locales/fr.yamlindex a2be5edae4a..88b2308916c 100644--- a/locales/fr.yaml+++ b/locales/fr.yaml@@ -3603,6 +3603,7 @@ cli:shallow_clone_keeping: "⚠ Clone superficiel — impossible de vérifier l'état du push, conservé : {path}"next_session_deepens: "La prochaine session `hermes -w` approfondira le clone et supprimera automatiquement les worktrees fusionnés."unpushed_keeping: "⚠ Le worktree a des commits non poussés, conservé : {path}"+ uncommitted_keeping: "⚠ Le worktree a des modifications non commitées, conservé : {path}"clean_up_manually: "Pour nettoyer manuellement : git worktree remove --force {path}"cleaned_up: "✓ Worktree nettoyé : {path}"display:diff --git a/locales/ga.yaml b/locales/ga.yamlindex acba431fe90..c461efe2e7e 100644--- a/locales/ga.yaml+++ b/locales/ga.yaml@@ -3286,6 +3286,7 @@ cli:shallow_clone_keeping: "⚠ Clón éadomhain — ní féidir staid an bhrú a fhíorú, á choinneáil: {path}"next_session_deepens: "Déanann an chéad seisiún `hermes -w` eile an clón a dhoimhniú agus bearrann sé worktrees cumaiscthe go huathoibríoch."unpushed_keeping: "⚠ Tá tiomantais gan bhrú sa worktree, á choinneáil: {path}"+ uncommitted_keeping: "⚠ Tá athruithe gan tiomantas sa worktree, á choinneáil: {path}"clean_up_manually: "Chun glanadh de láimh: git worktree remove --force {path}"cleaned_up: "✓ Worktree glanta: {path}"display:diff --git a/locales/hu.yaml b/locales/hu.yamlindex 0898dc80ad8..c5da94731b5 100644--- a/locales/hu.yaml+++ b/locales/hu.yaml@@ -3303,6 +3303,7 @@ cli:shallow_clone_keeping: "⚠ Sekély klón — a push állapota nem ellenőrizhető, megtartva: {path}"next_session_deepens: "A következő `hermes -w` munkamenet mélyíti a klónt, és automatikusan eltávolítja a beolvasztott worktree-ket."unpushed_keeping: "⚠ A worktree-ben feltöltetlen commitok vannak, megtartva: {path}"+ uncommitted_keeping: "⚠ A worktree-ben nem commitolt változások vannak, megtartva: {path}"clean_up_manually: "Kézi takarításhoz: git worktree remove --force {path}"cleaned_up: "✓ Worktree eltakarítva: {path}"display:diff --git a/locales/it.yaml b/locales/it.yamlindex cdf4a547daf..ca6ea5aca48 100644--- a/locales/it.yaml+++ b/locales/it.yaml@@ -3286,6 +3286,7 @@ cli:shallow_clone_keeping: "⚠ Clone shallow — impossibile verificare lo stato del push, mantengo: {path}"next_session_deepens: "La prossima sessione `hermes -w` approfondisce il clone ed elimina automaticamente i worktree già uniti."unpushed_keeping: "⚠ Il worktree ha commit non inviati, mantengo: {path}"+ uncommitted_keeping: "⚠ Il worktree ha modifiche non committate, mantengo: {path}"clean_up_manually: "Per pulire manualmente: git worktree remove --force {path}"cleaned_up: "✓ Worktree pulito: {path}"display:diff --git a/locales/ja.yaml b/locales/ja.yamlindex 75ffd117497..80c9f28404a 100644--- a/locales/ja.yaml+++ b/locales/ja.yaml@@ -3286,6 +3286,7 @@ cli:shallow_clone_keeping: "⚠ シャロークローン — プッシュ状態を確認できないため保持します: {path}"next_session_deepens: "次回の `hermes -w` セッションでクローンを深化し、マージ済みのワークツリーを自動的に削除します。"unpushed_keeping: "⚠ ワークツリーに未プッシュのコミットがあるため保持します: {path}"+ uncommitted_keeping: "⚠ ワークツリーに未コミットの変更があるため保持します: {path}"clean_up_manually: "手動でクリーンアップするには: git worktree remove --force {path}"cleaned_up: "✓ ワークツリーをクリーンアップしました: {path}"display:diff --git a/locales/ko.yaml b/locales/ko.yamlindex b478312d397..90bcda75282 100644--- a/locales/ko.yaml+++ b/locales/ko.yaml@@ -3286,6 +3286,7 @@ cli:shallow_clone_keeping: "⚠ 얕은 클론 — 푸시 상태를 확인할 수 없어 유지해요: {path}"next_session_deepens: "다음 `hermes -w` 세션에서 클론을 깊게 만들고 병합된 워크트리를 자동으로 정리해요."unpushed_keeping: "⚠ 워크트리에 푸시되지 않은 커밋이 있어 유지해요: {path}"+ uncommitted_keeping: "⚠ 워크트리에 커밋되지 않은 변경 사항이 있어 유지해요: {path}"clean_up_manually: "직접 정리하려면: git worktree remove --force {path}"cleaned_up: "✓ 워크트리를 정리했어요: {path}"display:diff --git a/locales/pt.yaml b/locales/pt.yamlindex 5c03205f047..604b0aef611 100644--- a/locales/pt.yaml+++ b/locales/pt.yaml@@ -3286,6 +3286,7 @@ cli:shallow_clone_keeping: "⚠ Clone superficial — não é possível verificar o estado de push; mantendo: {path}"next_session_deepens: "A próxima sessão `hermes -w` aprofunda o clone e remove worktrees já mescladas automaticamente."unpushed_keeping: "⚠ A worktree tem commits não enviados (push); mantendo: {path}"+ uncommitted_keeping: "⚠ A worktree tem alterações não commitadas; mantendo: {path}"clean_up_manually: "Para limpar manualmente: git worktree remove --force {path}"cleaned_up: "✓ Worktree limpa: {path}"display:diff --git a/locales/ru.yaml b/locales/ru.yamlindex b8594c9cdb8..b9594b8f845 100644--- a/locales/ru.yaml+++ b/locales/ru.yaml@@ -3286,6 +3286,7 @@ cli:shallow_clone_keeping: "⚠ Неглубокий клон (shallow) — не могу проверить состояние push, оставляю: {path}"next_session_deepens: "Следующий сеанс `hermes -w` углубит клон и автоматически удалит слитые worktree."unpushed_keeping: "⚠ В worktree есть неотправленные коммиты, оставляю: {path}"+ uncommitted_keeping: "⚠ В worktree есть незакоммиченные изменения, оставляю: {path}"clean_up_manually: "Чтобы очистить вручную: git worktree remove --force {path}"cleaned_up: "✓ Worktree очищен: {path}"display:diff --git a/locales/tr.yaml b/locales/tr.yamlindex 3fc72fc9f9e..1cd00ba50e5 100644--- a/locales/tr.yaml+++ b/locales/tr.yaml@@ -3286,6 +3286,7 @@ cli:shallow_clone_keeping: "⚠ Sığ klon — push durumu doğrulanamıyor, korunuyor: {path}"next_session_deepens: "Bir sonraki `hermes -w` oturumu klonu derinleştirir ve birleştirilmiş worktree'leri otomatik olarak temizler."unpushed_keeping: "⚠ Worktree'de push edilmemiş commit'ler var, korunuyor: {path}"+ uncommitted_keeping: "⚠ Worktree'de commit edilmemiş değişiklikler var, korunuyor: {path}"clean_up_manually: "Elle temizlemek için: git worktree remove --force {path}"cleaned_up: "✓ Worktree temizlendi: {path}"display:diff --git a/locales/uk.yaml b/locales/uk.yamlindex 9b6a1802784..976e4a1c9f6 100644--- a/locales/uk.yaml+++ b/locales/uk.yaml@@ -3286,6 +3286,7 @@ cli:shallow_clone_keeping: "⚠ Неглибокий клон — неможливо перевірити стан push, залишаємо: {path}"next_session_deepens: "Наступний сеанс `hermes -w` поглибить клон і автоматично видалить злиті робочі дерева."unpushed_keeping: "⚠ У робочому дереві є невідправлені коміти, залишаємо: {path}"+ uncommitted_keeping: "⚠ У робочому дереві є незафіксовані зміни, залишаємо: {path}"clean_up_manually: "Щоб очистити вручну: git worktree remove --force {path}"cleaned_up: "✓ Робоче дерево очищено: {path}"display:diff --git a/locales/zh-hant.yaml b/locales/zh-hant.yamlindex 03348021beb..732ef48c31e 100644--- a/locales/zh-hant.yaml+++ b/locales/zh-hant.yaml@@ -3286,6 +3286,7 @@ cli:shallow_clone_keeping: "⚠ 淺層複製 — 無法確認推送狀態,保留:{path}"next_session_deepens: "下一次 `hermes -w` 工作階段會加深複製並自動清理已合併的工作樹。"unpushed_keeping: "⚠ 工作樹有未推送的提交,保留:{path}"+ uncommitted_keeping: "⚠ 工作樹有未提交的變更,保留:{path}"clean_up_manually: "手動清理方式:git worktree remove --force {path}"cleaned_up: "✓ 工作樹已清理:{path}"display:diff --git a/locales/zh.yaml b/locales/zh.yamlindex 62ab2279c26..e86cdc9339e 100644--- a/locales/zh.yaml+++ b/locales/zh.yaml@@ -3286,6 +3286,7 @@ cli:shallow_clone_keeping: "⚠ 浅克隆 — 无法验证推送状态,保留:{path}"next_session_deepens: "下一次 `hermes -w` 会话会自动加深克隆并清理已合并的工作树。"unpushed_keeping: "⚠ 工作树有未推送的提交,保留:{path}"+ uncommitted_keeping: "⚠ 工作树有未提交的更改,保留:{path}"clean_up_manually: "手动清理:git worktree remove --force {path}"cleaned_up: "✓ 工作树已清理:{path}"display:diff --git a/tests/hermes_cli/test_worktree.py b/tests/hermes_cli/test_worktree.pyindex 124012683f9..18ad157a0ec 100644--- a/tests/hermes_cli/test_worktree.py+++ b/tests/hermes_cli/test_worktree.py@@ -73,7 +73,7 @@ def git_repo_no_remote(tmp_path):# ----------------------------------------------------------------------------def test_exit_cleanup_preserves_dirty_worktree(git_repo, monkeypatch):+def test_exit_cleanup_preserves_dirty_worktree(git_repo, monkeypatch, capsys):"""Exit cleanup must preserve local changes for manual recovery."""import cli@@ -85,6 +85,8 @@ def test_exit_cleanup_preserves_dirty_worktree(git_repo, monkeypatch):)(worktree / "untracked.txt").write_text("recover me\n")monkeypatch.setattr(cli, "release_lsp_clients", lambda path: None)+ printed = []+ monkeypatch.setattr(cli, "_cprint", printed.append)cli._cleanup_worktree({"path": str(worktree),@@ -94,6 +96,9 @@ def test_exit_cleanup_preserves_dirty_worktree(git_repo, monkeypatch):assert worktree.exists()assert (worktree / "untracked.txt").read_text() == "recover me\n"+ out = "".join(printed) + capsys.readouterr().out+ assert "uncommitted changes" in out+ assert "--force" not in out