mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-05-18 04:41:56 +00:00
fix(kanban): restore HERMES_KANBAN_BOARD after scoped slash override
This commit is contained in:
parent
2b3bf17dfa
commit
641e40c4bd
2 changed files with 30 additions and 1 deletions
|
|
@ -652,6 +652,16 @@ def kanban_command(args: argparse.Namespace) -> int:
|
|||
# keeps the patch small and inherits the exact same resolution the
|
||||
# dispatcher uses for workers — consistency is a feature here.
|
||||
board_override = getattr(args, "board", None)
|
||||
prev_board_env = os.environ.get("HERMES_KANBAN_BOARD")
|
||||
restore_board_env = False
|
||||
|
||||
def _restore_board_env() -> None:
|
||||
if not restore_board_env:
|
||||
return
|
||||
if prev_board_env is None:
|
||||
os.environ.pop("HERMES_KANBAN_BOARD", None)
|
||||
else:
|
||||
os.environ["HERMES_KANBAN_BOARD"] = prev_board_env
|
||||
if board_override:
|
||||
try:
|
||||
normed = kb._normalize_board_slug(board_override)
|
||||
|
|
@ -671,12 +681,16 @@ def kanban_command(args: argparse.Namespace) -> int:
|
|||
)
|
||||
return 1
|
||||
os.environ["HERMES_KANBAN_BOARD"] = normed
|
||||
restore_board_env = True
|
||||
|
||||
# Boards management doesn't touch the DB at all — dispatch early so
|
||||
# fresh installs that haven't initialized any DB can still use
|
||||
# `hermes kanban boards create …`.
|
||||
if action == "boards":
|
||||
return _dispatch_boards(args)
|
||||
try:
|
||||
return _dispatch_boards(args)
|
||||
finally:
|
||||
_restore_board_env()
|
||||
|
||||
# Auto-initialize the DB before dispatching any subcommand. init_db
|
||||
# is idempotent, so running it every invocation is cheap (one
|
||||
|
|
@ -689,6 +703,7 @@ def kanban_command(args: argparse.Namespace) -> int:
|
|||
kb.init_db()
|
||||
except Exception as exc:
|
||||
print(f"kanban: could not initialize database: {exc}", file=sys.stderr)
|
||||
_restore_board_env()
|
||||
return 1
|
||||
|
||||
handlers = {
|
||||
|
|
@ -730,12 +745,16 @@ def kanban_command(args: argparse.Namespace) -> int:
|
|||
handler = handlers.get(action)
|
||||
if not handler:
|
||||
print(f"kanban: unknown action {action!r}", file=sys.stderr)
|
||||
_restore_board_env()
|
||||
return 2
|
||||
try:
|
||||
return int(handler(args) or 0)
|
||||
except (ValueError, RuntimeError) as exc:
|
||||
print(f"kanban: {exc}", file=sys.stderr)
|
||||
_restore_board_env()
|
||||
return 1
|
||||
finally:
|
||||
_restore_board_env()
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue