Commit Graph

3 Commits

Author SHA1 Message Date
Maciej Lisiewski
d76cce4f11 ci: apply all automatic linter fixes available 2026-10-08 17:22:54 +02:00
teknium1
c56c0a61c4 fix(update): launches racing an interrupted-pull restore take turns and never advise reset --hard
Follow-up to #120339 from its independent re-review.

- Single-flight: the restore runs under an OS lock on <git dir>/hermes-update-pull.claim
  (flock on POSIX, msvcrt.locking on Windows; owner pid written for humans). The kernel drops
  the lock with its owner, so a dead launch's claim is broken without a check-then-unlink race.
  A launch that loses waits up to 10 s, then re-checks: if the marker is gone the tree changed
  under it and it returns True (relaunch) instead of importing a half-restored tree; if the
  holder is still busy it prints a neutral note and never touches the tree.
- index.lock is removed only by the claim holder and only when no live process has it open
  (/proc on Linux; Windows refuses the unlink of an open file; elsewhere the claim is the guard).
- The failure message no longer prints `git reset --hard <pre>`: that wipes the uncommitted
  edits the restore keeps. It names git's error and says the next launch retries.
- HEAD already moved is checked before merge/rebase state, so a git killed after committing its
  merge but before deleting MERGE_HEAD spends the marker instead of pinning it forever.
- MERGE_HEAD == the marker's target (the updater's own merge, killed mid-conflict): print
  `git -C <root> merge --abort`, then relaunch, once per launch (plus the stash name if any).
- `hermes-agent` (agent.legacy_cli:main) now repairs at the top of agent/legacy_cli.py, before
  argparse and run_agent; the entry-point spy test covers it.
- Directories git created for added files are removed bottom-up when empty; a dir pre has, or one
  holding an untracked file, is kept.
2026-09-23 18:26:45 -07:00
teknium1
2fb564d2df fix(cli): move the hermes-agent argv layer into agent/legacy_cli
Follow-up to the salvaged wrapper: the argument layer now lives in a topical
sibling (agent/legacy_cli.py) instead of growing the run_agent facade, and
`python run_agent.py` (the installer's PATH launcher for hermes-agent) routes
through the same parser instead of fire, so `--version` and a bare invocation
no longer run the demo turn there either.

- --help/-h/--version use argparse's own exit path; options carry help text
- the runner is injected (`run=`) so `python run_agent.py` does not import
  run_agent a second time
- tests trimmed to two invariants that resolve the console-script target
  from pyproject exactly like pip's wrapper (red on main, green here)
- docs: hermes-agent section in the CLI reference
2026-09-23 10:40:39 -07:00