herdr-orchestra 5.7.0 → 5.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +38 -0
- package/README.md +25 -2
- package/VERSION +1 -1
- package/bin/__pycache__/orchcpython-314.pyc +0 -0
- package/bin/orch +416 -7
- package/install.sh +56 -2
- package/package.json +1 -1
- package/playbooks/plan.md +1 -0
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,44 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes. Versions follow [semantic versioning](https://semver.org).
|
|
4
4
|
|
|
5
|
+
## [5.8.0] - 2026-11-16
|
|
6
|
+
|
|
7
|
+
orch now tells you when a new version is out, and can keep itself up to date. It also fixes the `<repo>-wt` folder that stayed on disk after `orch finish`.
|
|
8
|
+
|
|
9
|
+
**Already installed? Run `npx herdr-orchestra@latest` once.** Versions before 5.8.0 cannot see new releases, so this one update is by hand. It asks the auto-update question, and after that updates come by themselves.
|
|
10
|
+
|
|
11
|
+
### Added
|
|
12
|
+
- **The installer asks once about auto-update, and the default is on.** `Keep herdr-orchestra up to date automatically? [Y/n]`. The answer is saved in `~/.local/share/herdr-orchestra/settings.json` and not asked again; an install that has no saved answer (every install older than 5.8.0) is asked too. With no keyboard it does not ask and turns it on. `--auto-update`, `--no-auto-update` and `ORCH_AUTO_UPDATE=1|0` answer it for scripts. Under `curl | bash` the question is read from the terminal.
|
|
13
|
+
- **`orch update [--check] [--version vX.Y.Z]`.** Installs the latest release with that release's own installer and prints the headline of each changelog entry. `--check` only looks. `--version` installs one exact version, which is also how you go back. A failed update leaves the old version active.
|
|
14
|
+
- **`orch config [auto-update on|off]`.** Shows or changes the setting, the installed version and the last check.
|
|
15
|
+
- **A new-version notice.** `herdr-orchestra 5.8.1 is out (you have 5.8.0). Run orch update.` at `orch lead plan`, `orch version` and `orch status`. orch asks GitHub at most once a day, waits 3 seconds at most, sends nothing about you or the project, and stays silent with no internet. `orch status` reads the last answer and never waits for the network. `ORCH_NO_UPDATE_CHECK=1` turns the check off.
|
|
16
|
+
- **Auto-update when a new plan starts.** With auto-update on, `orch lead plan` installs a newer release first and then runs the plan on it. It installs nothing while an event manager is running anywhere on this machine (each manager signs in under `~/.local/share/herdr-orchestra/active/`), for a major version, in a repo pinned with `.orch-version`, or from a git checkout. A failed update warns once, is logged to `update.log` and is tried again the next day. A run started on the old version finishes on the new one.
|
|
17
|
+
- The plan playbook tells the lead to pass the update lines on to the developer and never to run `orch update` itself.
|
|
18
|
+
- Installs now ship `CHANGELOG.md`, so `orch update` can say what is new.
|
|
19
|
+
|
|
20
|
+
### Fixed
|
|
21
|
+
- **`orch finish` leaves no `<repo>-wt` folder behind.** It removed each coder folder inside `../<repo>-wt` but never the `-wt` folder itself, so an empty one stayed after every worktree run. Now it goes too.
|
|
22
|
+
- **A coder folder is no longer kept for an agent's own files.** One untracked file, such as the `.claude/settings.local.json` that Claude Code writes when you approve a permission, made finish print `SKIP ... has uncommitted changes` and keep the whole folder, though all its work had landed. A folder that holds only agent or orch files (`.claude/`, `.codex/`, `.agents/`, `.opencode/`, `.gemini/`, `.hermes/`, `.amp/`, `.agy/`, `.orch-task/`) is now removed. A folder with real changes no milestone has is kept and named, with the command that deletes it.
|
|
23
|
+
- **Folders of coders no longer in the plan are removed.** A coder renamed or taken out of `Workers:` was forgotten by `orch sync`, so its folder stayed. Finish now cleans every coder folder under `<repo>-wt`, not only today's team.
|
|
24
|
+
- `orch lead ... | head` (and the other commands that work outside a repo) no longer print a traceback when the reader closes the pipe.
|
|
25
|
+
|
|
26
|
+
Folders are removed only by `orch finish`, which runs only when every milestone has landed. A stopped, crashed or unfinished run keeps its folders for `orch resume`, and quick runs make none.
|
|
27
|
+
|
|
28
|
+
### Tests
|
|
29
|
+
- Updates (sections 40 to 42, with a fake release on disk, no network): the installer question and its flags, `orch config`, `orch update` with `--check` and `--version`, one check a day, silence with no network, the notice, every case where auto-update holds back (a run going, a major version, a pinned repo, a checkout, a failed install), and a run started on the old version that finishes on the new one.
|
|
30
|
+
- Finish removes a coder folder holding only an agent settings file, the folder of a coder no longer in the plan, and the empty `-wt` folder; it keeps a folder with real changes and says how to delete it; and it refuses (keeping every folder) while a milestone is still open.
|
|
31
|
+
- No test asks the network for a version, waits for a keyboard, or writes into the developer's own install.
|
|
32
|
+
|
|
33
|
+
## [5.7.1] - 2026-11-16
|
|
34
|
+
|
|
35
|
+
A check that quick runs (5.6.0) and the stalled-run fixes (5.7.0) did not change how a real feature is planned. They did not: a plan with no `Mode:` line, or `Mode: full`, is planned and run as before (worktrees, reviewer, `Why separate:`, `Role:`, tier and estimate per milestone, and the same warnings). The check found one bug in quick runs.
|
|
36
|
+
|
|
37
|
+
### Fixed
|
|
38
|
+
- **`orch sync` refused a quick run after `orch fix`.** The follow-up milestone that `orch fix M1 "..."` adds was counted as a second planned milestone, so `orch sync` stopped with "`Mode: quick` is one milestone, and this plan has 2". Follow-ups from `orch fix` no longer count; a second milestone you plan by hand is still refused.
|
|
39
|
+
|
|
40
|
+
### Tests
|
|
41
|
+
- New tests lock in full feature planning: a three-milestone feature with no `Mode:` line stays full (worktrees, reviewer, review per milestone, role, tier, estimate and dependencies kept), none of the quick-run rules touch it (a migration or `package.json` is fine), `Why separate` and `Estimate` warnings still appear, `Mode: full` is the same as no line, an unknown `Mode` is refused, and the planning playbook keeps steps 3 to 10.
|
|
42
|
+
|
|
5
43
|
## [5.7.0] - 2026-11-15
|
|
6
44
|
|
|
7
45
|
Found in a real run (orch 5.4.0): a coder hit its usage limit, then the terminal closed and herdr restarted. The event manager had been started from a herdr pane, so it died too. For 2.5 hours `orch status` still said "M3 coding on rs-opencode-1" for a pane that no longer existed, and nobody was told. After that, `orch team up` opened an OpenCode pane that quit at once and left a plain shell, and the task was typed into that shell. `dispatch --to rs-agy-1` said "ok" for a worker with no pane. The developer's "no more Claude" was forgotten as soon as Claude's pane came back. Swapping a coder meant killing the event manager by hand, and a dead manager left no trace of why it died.
|
package/README.md
CHANGED
|
@@ -73,6 +73,29 @@ orch agents sync
|
|
|
73
73
|
|
|
74
74
|
It finds every installed agent (binary on `PATH`), copies the `orch-plan` / `orch-run` skills and slash commands into that agent's folders, and records them so `--uninstall` still removes exactly what was installed. `orch agents` prints a hint when a new agent is missing its skills.
|
|
75
75
|
|
|
76
|
+
## Updates
|
|
77
|
+
|
|
78
|
+
**Already installed (5.7 or older)? Run `npx herdr-orchestra@latest` once.** That install asks the question below, and from then on orch keeps itself up to date.
|
|
79
|
+
|
|
80
|
+
The installer asks once: `Keep herdr-orchestra up to date automatically? [Y/n]`. Enter means yes. The answer is saved for this machine (`~/.local/share/herdr-orchestra/settings.json`) and is not asked again. With no keyboard (CI, a script) it does not ask and turns it on; `--auto-update` / `--no-auto-update` or `ORCH_AUTO_UPDATE=1|0` answer it for a script.
|
|
81
|
+
|
|
82
|
+
```bash
|
|
83
|
+
orch update # install the latest release now and show what is new
|
|
84
|
+
orch update --check # only say whether a new version is out
|
|
85
|
+
orch update --version v5.8.0 # install that exact version (this is also how you go back)
|
|
86
|
+
orch config # auto-update on/off, the installed version, the last check
|
|
87
|
+
orch config auto-update off # or: on
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
- **The check.** At most once a day, at `orch lead plan` or `orch version`, orch asks GitHub for the latest release (3 seconds at most; nothing about you or your project is sent). With no internet it stays silent and asks again the next day. `ORCH_NO_UPDATE_CHECK=1` turns the check off.
|
|
91
|
+
- **Auto-update on.** When a new plan starts (`orch lead plan`) and a newer release is out, orch installs it first and the plan runs on the new version: `UPDATED herdr-orchestra 5.8.0 -> 5.8.1`, with what is new.
|
|
92
|
+
- **Never during a run.** While an event manager is running anywhere on this machine nothing is installed; it happens at the next plan with no run going. A run that was started on the old version finishes on the new one.
|
|
93
|
+
- **Not installed by itself:** a major version (5.x to 6.0: read its changelog, then `orch update`), a repo pinned with `.orch-version`, and a git checkout.
|
|
94
|
+
- **A failed update** keeps the version you have, prints one warning, writes the reason to `~/.local/share/herdr-orchestra/update.log` and tries again the next day.
|
|
95
|
+
- **Auto-update off.** `orch lead plan`, `orch status` and `orch version` show one line instead: `herdr-orchestra 5.8.1 is out (you have 5.8.0). Run orch update.`
|
|
96
|
+
|
|
97
|
+
The skills are thin wrappers that call `orch`, so an updated `orch` is new logic for every agent at once.
|
|
98
|
+
|
|
76
99
|
## Versions
|
|
77
100
|
|
|
78
101
|
Every release is a git tag (`v4.2.0`) with a GitHub Release that carries its own `install.sh`. Every installed version is kept side by side, so switching back is instant.
|
|
@@ -128,7 +151,7 @@ Version choice, first match wins: `--version` flag › `ORCH_VERSION` env › `.
|
|
|
128
151
|
|
|
129
152
|
You can also start the event manager yourself: `orch autopilot` in a spare terminal. It is the only driver of a run: while it runs, other `orch` commands that would change the run are refused (`orch status`, `orch report`, `orch approve` and the lead's `orch events` / `orch dispatch` / `orch answer` still work).
|
|
130
153
|
4. **If the lead is away** (its pane is closed, or it never reads its events): nothing is lost, the events wait in the queue. Ready work starts by itself after 15 minutes, you get a desktop notification, and `orch events --peek` shows what is open. With `Lead mode: off` in the plan header there is no lead in the run at all: `orch autopilot` dispatches by itself and stops (exit 3) when it needs you.
|
|
131
|
-
5. **When it's done:** read `.orchestrate/summary.md` and do its manual checklist. It holds only what needs your eyes or hands (how the UI looks and behaves, a real device); whatever a command or a look at the code can settle, the run and the lead have already checked and listed with the evidence. Want a change? Tell the lead (for example "the login button should be blue"). It runs `orch fix M1 "the login button should be blue"`: one small follow-up job goes straight to the coder who built M1, with the check and review as before, and no new plan. You can run `orch fix` yourself too. When you are happy, run `orch finish`. It re-runs the check (or reuses it when it already passed on exactly these files; `--recheck` runs it anyway), removes the worktrees, pushes `feature/<name>` and opens a PR into `main` (with `gh`, or prints the compare link).
|
|
154
|
+
5. **When it's done:** read `.orchestrate/summary.md` and do its manual checklist. It holds only what needs your eyes or hands (how the UI looks and behaves, a real device); whatever a command or a look at the code can settle, the run and the lead have already checked and listed with the evidence. Want a change? Tell the lead (for example "the login button should be blue"). It runs `orch fix M1 "the login button should be blue"`: one small follow-up job goes straight to the coder who built M1, with the check and review as before, and no new plan. You can run `orch fix` yourself too. When you are happy, run `orch finish`. It re-runs the check (or reuses it when it already passed on exactly these files; `--recheck` runs it anyway), removes the coders' worktrees and the `../<repo>-wt` folder (a coder folder with changes no milestone has is kept and named), pushes `feature/<name>` and opens a PR into `main` (with `gh`, or prints the compare link).
|
|
132
155
|
|
|
133
156
|
### Git: one branch per run, real commits, one PR
|
|
134
157
|
Planning touches no git at all. `orch start` creates the plan's `Branch:` (`feature/<slug>`) and that is the only branch a run makes: coders work on detached worktrees, and a milestone's work in progress (under review, parked, waiting for a fix) lives in hidden refs under `refs/orch/`, which `git branch` doesn't list and `git push` doesn't send. Each milestone lands as **one commit whose message says what changed** (the coder's `COMMIT:` line, e.g. `feat(api): add categories endpoint`, with a `Milestone: M2` trailer). `Commits: single` in the plan header squashes the run into one commit at finish.
|
|
@@ -300,7 +323,7 @@ Every status change is written to `.orchestrate/events.jsonl`, and `orch report
|
|
|
300
323
|
Optional plan header lines: `Lead mode: events | off` (default `events` when the plan has a `Lead:` line) · `Scope: warn | strict` · `Risk hold: on | off` · `Budget: 3h` (autopilot stops when its running time is used up) · `Estimate: 1h30m` (the lead's estimate for the feature) · `Setup inputs: <globs>` (which files mean "run setup again"; default: lockfiles and manifests). Per milestone: `Why separate` (why it is its own milestone; needed when the plan has more than one) · `Tier`, `Needs`, `Model why` (see [Models and tiers](#models-and-tiers)) · `Estimate: 40m` (dispatch to landed if nothing goes wrong) · `Parallel: allow` lets it run next to a milestone that shares its `Likely files`.
|
|
301
324
|
|
|
302
325
|
### Commands
|
|
303
|
-
`orch status` · `orch resume` · `orch report` · `orch approve Mn` · `orch models [show|check <id>]` · `orch events [--peek]` · `orch dispatch Mn... [--to <worker>] [--tier <tier>]` · `orch answer Mn "<answer>"` · `orch fix Mn "<change>" [--to <worker>]` · `orch doctor [kind]` · `orch ready` · `orch autopilot` · `orch lead plan|run|check|whoami` · `orch agents [launch <kind> [--model <id>]|sync|check]` · `orch handoff Mn` · `orch needs-fix Mn` · `orch set M3 pending` · `orch park M2 paused "why"` · `orch cooldown claude-1 60` · `orch bench claude-1 off|on` · `orch stop [--now]` · `orch doctor --crash` · `orch cleanup` · `orch finish [--no-push]` · `orch version` · `orch` (full help)
|
|
326
|
+
`orch status` · `orch resume` · `orch report` · `orch approve Mn` · `orch models [show|check <id>]` · `orch events [--peek]` · `orch dispatch Mn... [--to <worker>] [--tier <tier>]` · `orch answer Mn "<answer>"` · `orch fix Mn "<change>" [--to <worker>]` · `orch doctor [kind]` · `orch ready` · `orch autopilot` · `orch lead plan|run|check|whoami` · `orch agents [launch <kind> [--model <id>]|sync|check]` · `orch handoff Mn` · `orch needs-fix Mn` · `orch set M3 pending` · `orch park M2 paused "why"` · `orch cooldown claude-1 60` · `orch bench claude-1 off|on` · `orch stop [--now]` · `orch doctor --crash` · `orch cleanup` · `orch finish [--no-push]` · `orch version` · `orch update [--check] [--version vX.Y.Z]` · `orch config [auto-update on|off]` · `orch` (full help)
|
|
304
327
|
|
|
305
328
|
Tunables: `ORCH_CODER_BUDGET_MIN` (45) · `ORCH_REVIEW_BUDGET_MIN` (15) · `ORCH_CHECK_TIMEOUT_MIN` (30) · `ORCH_COOLDOWN_MIN` (60) · `ORCH_MAX_TASKS` (unset: no limit) · `ORCH_GONE_COOLDOWN_MIN` (10) · `ORCH_SEND_RETRY_S` (120) · `ORCH_HERDR_TIMEOUT_S` (30) · `ORCH_MAX_LOST` (4) · `ORCH_UNREACHABLE_MIN` (30) · `ORCH_CONFIRM_S` (30) · `ORCH_DOWN_MIN_S` (120: an event manager silent for longer was down, and that time is not counted) · `ORCH_RISK_MAX_LINES` (1500) · `ORCH_LEAD_WAIT_MIN` (15: ready work the lead hasn't dispatched starts by itself) · `ORCH_LEAD_CONFIRM_S` (30: a wake-up the lead did not pick up is sent again, doubling) · `ORCH_LEAD_REWAKE_S` (300) · `ORCH_LEAD_MAX_WAKES` (3) · `ORCH_LEAD_IDLE_MAX_MIN` (720: how long the event manager waits for an answer) · `ORCH_NO_AUTOSTART=1` (the lead's commands never start the event manager)
|
|
306
329
|
|
package/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
5.
|
|
1
|
+
5.8.0
|
|
Binary file
|
package/bin/orch
CHANGED
|
@@ -219,6 +219,7 @@ def take_lease():
|
|
|
219
219
|
f.flush()
|
|
220
220
|
os.environ["ORCH_DRIVER"], os.environ["ORCH_DRIVER_PID"] = token, str(os.getpid())
|
|
221
221
|
_LEASE = f
|
|
222
|
+
sign_in_manager()
|
|
222
223
|
|
|
223
224
|
|
|
224
225
|
def task(st, tid):
|
|
@@ -1204,8 +1205,14 @@ def cmd_sync(args):
|
|
|
1204
1205
|
if not quick_because:
|
|
1205
1206
|
errors.append("`Mode: quick` needs `Quick because: <what you found in the code that makes this small>` "
|
|
1206
1207
|
"— e.g. `Quick because: the column already exists, only the response changes`")
|
|
1207
|
-
|
|
1208
|
-
|
|
1208
|
+
# follow-ups added by `orch fix` after the quick milestone landed are not extra planned milestones
|
|
1209
|
+
try:
|
|
1210
|
+
fixes = {k for k, v in json.loads(STATE.read_text()).get("tasks", {}).items() if v.get("fix_of")}
|
|
1211
|
+
except (OSError, ValueError, AttributeError):
|
|
1212
|
+
fixes = set()
|
|
1213
|
+
planned = [tid for tid in enabled if tid not in fixes]
|
|
1214
|
+
if len(planned) > 1:
|
|
1215
|
+
errors.append(f"`Mode: quick` is one milestone, and this plan has {len(planned)} — put the small changes "
|
|
1209
1216
|
f"in one milestone (one acceptance criterion each), or use `Mode: full`")
|
|
1210
1217
|
if isolation == "worktree":
|
|
1211
1218
|
warns.append("`Mode: quick` with `Isolation: worktree`: one milestone needs no separate folder — "
|
|
@@ -2932,6 +2939,7 @@ def cmd_status(args):
|
|
|
2932
2939
|
elif not any(t["status"] in ACTIVE for t in st["tasks"].values()) and not any(
|
|
2933
2940
|
t["status"] == "pending" and deps_met(st, t) for t in st["tasks"].values()):
|
|
2934
2941
|
print("STUCK — nothing running and nothing ready; resolve paused/needs-answer/failed tasks with the developer")
|
|
2942
|
+
update_notice(network=False) # from the last daily check only: status never waits for the network
|
|
2935
2943
|
|
|
2936
2944
|
|
|
2937
2945
|
def remove_worktrees(st):
|
|
@@ -2946,6 +2954,41 @@ def remove_worktrees(st):
|
|
|
2946
2954
|
git("worktree", "prune", cwd=ROOT)
|
|
2947
2955
|
|
|
2948
2956
|
|
|
2957
|
+
# files agents and orch leave in a coder's folder that are not work: settings an agent saves when a permission
|
|
2958
|
+
# is approved, its local skills, orch's task files. `orch finish` removes a folder that holds only these.
|
|
2959
|
+
AGENT_LEFTOVERS = (".claude/", ".codex/", ".agents/", ".opencode/", ".gemini/", ".hermes/", ".amp/", ".agy/",
|
|
2960
|
+
".orchestrate/", f"{TASK_DIR}/")
|
|
2961
|
+
|
|
2962
|
+
|
|
2963
|
+
def finish_worktrees():
|
|
2964
|
+
"""orch finish (every milestone landed): remove every coder folder under <repo>-wt, the folders of coders no
|
|
2965
|
+
longer in the plan too, then the empty <repo>-wt folder. A folder that holds only agent or orch files goes;
|
|
2966
|
+
one with real changes no milestone has is kept and named, with the command that deletes it."""
|
|
2967
|
+
top = ROOT.parent / f"{ROOT.name}-wt"
|
|
2968
|
+
git("worktree", "prune", cwd=ROOT)
|
|
2969
|
+
if not top.is_dir():
|
|
2970
|
+
return
|
|
2971
|
+
listed = git("worktree", "list", "--porcelain", cwd=ROOT).stdout.splitlines()
|
|
2972
|
+
paths = [Path(x[len("worktree "):]) for x in listed if x.startswith("worktree ")]
|
|
2973
|
+
for p in sorted(x for x in paths if x.resolve().parent == top.resolve()):
|
|
2974
|
+
lines = git("status", "--porcelain", "--untracked-files=all", cwd=p).stdout.splitlines()
|
|
2975
|
+
real = [x[3:] for x in lines if not (x.startswith("?? ") and x[3:].startswith(AGENT_LEFTOVERS))]
|
|
2976
|
+
if real:
|
|
2977
|
+
print(f"KEPT {p}: changes no milestone has ({', '.join(real[:5])}{', ...' if len(real) > 5 else ''}) "
|
|
2978
|
+
f"— look, then delete it with `git worktree remove --force {p}`")
|
|
2979
|
+
continue
|
|
2980
|
+
git("worktree", "remove", "--force", str(p), cwd=ROOT)
|
|
2981
|
+
junk = sorted({x[3:].split("/", 1)[0] + "/" for x in lines})
|
|
2982
|
+
print(f"REMOVED {p}" + (f" (only agent files: {', '.join(junk)})" if junk else ""))
|
|
2983
|
+
git("worktree", "prune", cwd=ROOT)
|
|
2984
|
+
with contextlib.suppress(OSError):
|
|
2985
|
+
top.rmdir() # only when nothing is left in it
|
|
2986
|
+
if top.exists():
|
|
2987
|
+
print(f"KEPT {top}: still holds {', '.join(sorted(x.name for x in top.iterdir()))}")
|
|
2988
|
+
else:
|
|
2989
|
+
print(f"REMOVED {top}")
|
|
2990
|
+
|
|
2991
|
+
|
|
2949
2992
|
def cmd_cleanup(args):
|
|
2950
2993
|
st = load()
|
|
2951
2994
|
if st["isolation"] != "worktree":
|
|
@@ -2989,8 +3032,7 @@ def cmd_finish(args):
|
|
|
2989
3032
|
print(f"SQUASHED {len(subjects)} commits into one (Commits: single)")
|
|
2990
3033
|
refs = git("for-each-ref", "--format=%(refname)", f"{REF_NS}/{st['branch'].replace('/', '-')}/",
|
|
2991
3034
|
cwd=ROOT).stdout.split()
|
|
2992
|
-
|
|
2993
|
-
remove_worktrees(st)
|
|
3035
|
+
finish_worktrees() # every milestone landed: no coder folder is needed any more
|
|
2994
3036
|
rescued = [r for r in refs if "/rescue-" in r]
|
|
2995
3037
|
refs = [r for r in refs if r not in rescued]
|
|
2996
3038
|
for ref in refs:
|
|
@@ -5080,6 +5122,8 @@ UNLOCKED = {"autopilot", "poll", "events", "dispatch", "answer", "fix", "team",
|
|
|
5080
5122
|
|
|
5081
5123
|
USAGE = """usage: orch <command> [args]
|
|
5082
5124
|
version print the installed herdr-orchestra version
|
|
5125
|
+
update [--check] [--version vX.Y.Z] install the latest release (or that one) and show what is new
|
|
5126
|
+
config [auto-update on|off] this machine's settings: keep orch up to date by itself, or only be told
|
|
5083
5127
|
lead plan|run print the lead playbook (any agent can lead: "Run `orch lead plan` and follow it")
|
|
5084
5128
|
lead check preflight: is this agent in a Herdr pane / can it reach herdr?
|
|
5085
5129
|
lead whoami show the lead's own herdr pane and how to name it `lead`
|
|
@@ -5124,7 +5168,8 @@ USAGE = """usage: orch <command> [args]
|
|
|
5124
5168
|
set <Mn> <status> [reason] [--force] manual override: pending/paused/failed/skipped (others need --force)
|
|
5125
5169
|
approve <Mn> let a milestone held for risky changes land (works while autopilot runs)
|
|
5126
5170
|
cleanup remove clean worker worktrees
|
|
5127
|
-
finish [--no-push] [--recheck] final check (reused if it passed on these exact files),
|
|
5171
|
+
finish [--no-push] [--recheck] final check (reused if it passed on these exact files), remove the <repo>-wt
|
|
5172
|
+
coder folders, push, open a PR
|
|
5128
5173
|
write-task <Mn> generate TASKDIR/task.md from plan.md (+ reports of merged dependencies)
|
|
5129
5174
|
nudge <Mn> re-send the current prompt once to an agent that stopped early
|
|
5130
5175
|
autopilot the event manager: watches agents, checks, merges, wakes the lead; exits 0 ALL_DONE, 3 when it needs you
|
|
@@ -5175,6 +5220,8 @@ def cmd_lead(args):
|
|
|
5175
5220
|
sub = args[0] if args else ""
|
|
5176
5221
|
if sub in ("plan", "run"):
|
|
5177
5222
|
pb = asset(f"playbooks/{sub}.md") or die(f"playbooks/{sub}.md not found next to orch or in the install")
|
|
5223
|
+
if sub == "plan":
|
|
5224
|
+
auto_update_at_plan() # a new feature starts on the newest release (never during a run)
|
|
5178
5225
|
print(f"herdr-orchestra {installed_version()} — lead playbook: {sub}\n")
|
|
5179
5226
|
print(pb.read_text(), end="")
|
|
5180
5227
|
return
|
|
@@ -5623,15 +5670,377 @@ def installed_version():
|
|
|
5623
5670
|
return "unknown"
|
|
5624
5671
|
|
|
5625
5672
|
|
|
5673
|
+
# ---------------------------------------------------------------- updates: notice, `orch update`, auto-update
|
|
5674
|
+
UPDATE_REPO = os.environ.get("ORCH_REPO") or "arunnarangali/herdr-orchestra"
|
|
5675
|
+
UPDATE_CHECK_S = 24 * 3600 # ask for the latest release at most once a day
|
|
5676
|
+
UPDATE_NET_S = 3 # ...and never wait longer than this for the answer
|
|
5677
|
+
|
|
5678
|
+
|
|
5679
|
+
def share_dir():
|
|
5680
|
+
return Path(os.environ.get("ORCH_SHARE") or Path.home() / ".local/share/herdr-orchestra")
|
|
5681
|
+
|
|
5682
|
+
|
|
5683
|
+
def settings_load():
|
|
5684
|
+
try:
|
|
5685
|
+
data = json.loads((share_dir() / "settings.json").read_text())
|
|
5686
|
+
return data if isinstance(data, dict) else {}
|
|
5687
|
+
except (OSError, ValueError):
|
|
5688
|
+
return {}
|
|
5689
|
+
|
|
5690
|
+
|
|
5691
|
+
def settings_save(data):
|
|
5692
|
+
with contextlib.suppress(OSError):
|
|
5693
|
+
share_dir().mkdir(parents=True, exist_ok=True)
|
|
5694
|
+
tmp = share_dir() / "settings.json.tmp"
|
|
5695
|
+
tmp.write_text(json.dumps(data, indent=1))
|
|
5696
|
+
os.replace(tmp, share_dir() / "settings.json")
|
|
5697
|
+
|
|
5698
|
+
|
|
5699
|
+
def auto_update_on():
|
|
5700
|
+
env = os.environ.get("ORCH_AUTO_UPDATE", "").lower()
|
|
5701
|
+
if env in ("0", "off", "false", "no"):
|
|
5702
|
+
return False
|
|
5703
|
+
if env in ("1", "on", "true", "yes"):
|
|
5704
|
+
return True
|
|
5705
|
+
return settings_load().get("auto_update") is True
|
|
5706
|
+
|
|
5707
|
+
|
|
5708
|
+
def ver_tuple(v):
|
|
5709
|
+
m = re.match(r"v?(\d+)\.(\d+)\.(\d+)$", (v or "").strip())
|
|
5710
|
+
return tuple(int(x) for x in m.groups()) if m else None
|
|
5711
|
+
|
|
5712
|
+
|
|
5713
|
+
def release_install():
|
|
5714
|
+
"""True when this orch is an installed release (~/.local/share/herdr-orchestra/vX.Y.Z), not a git checkout or
|
|
5715
|
+
a -dev install: only a release looks for, and moves to, a newer release."""
|
|
5716
|
+
here = Path(__file__).resolve().parent.parent
|
|
5717
|
+
return here.parent == share_dir().resolve() and here.name == f"v{installed_version()}"
|
|
5718
|
+
|
|
5719
|
+
|
|
5720
|
+
def update_source():
|
|
5721
|
+
"""Tests: ORCH_UPDATE_SOURCE is a folder with `latest` (a tag) and one release tree per tag (<tag>/install.sh)."""
|
|
5722
|
+
src = os.environ.get("ORCH_UPDATE_SOURCE")
|
|
5723
|
+
return Path(src) if src else None
|
|
5724
|
+
|
|
5725
|
+
|
|
5726
|
+
def fetch_latest(thorough=False):
|
|
5727
|
+
"""The newest released version as 'X.Y.Z', or None when it can't be reached within UPDATE_NET_S. The daily
|
|
5728
|
+
check asks GitHub's API once; `orch update` (thorough) also tries the tag list when the API says no."""
|
|
5729
|
+
src = update_source()
|
|
5730
|
+
if src:
|
|
5731
|
+
try:
|
|
5732
|
+
tag = (src / "latest").read_text().strip()
|
|
5733
|
+
except OSError:
|
|
5734
|
+
return None
|
|
5735
|
+
return tag.lstrip("v") if ver_tuple(tag) else None
|
|
5736
|
+
import urllib.request
|
|
5737
|
+
try:
|
|
5738
|
+
req = urllib.request.Request(f"https://api.github.com/repos/{UPDATE_REPO}/releases/latest",
|
|
5739
|
+
headers={"Accept": "application/vnd.github+json", "User-Agent": "herdr-orchestra"})
|
|
5740
|
+
with urllib.request.urlopen(req, timeout=UPDATE_NET_S) as r:
|
|
5741
|
+
tag = json.loads(r.read().decode()).get("tag_name", "")
|
|
5742
|
+
if ver_tuple(tag):
|
|
5743
|
+
return tag.lstrip("v")
|
|
5744
|
+
except Exception:
|
|
5745
|
+
pass
|
|
5746
|
+
if not thorough:
|
|
5747
|
+
return None
|
|
5748
|
+
try:
|
|
5749
|
+
r = subprocess.run(["git", "ls-remote", "--tags", "--refs", f"https://github.com/{UPDATE_REPO}.git"],
|
|
5750
|
+
text=True, capture_output=True, timeout=20,
|
|
5751
|
+
env={**os.environ, "GIT_TERMINAL_PROMPT": "0"})
|
|
5752
|
+
tags = [t for t in (x.rsplit("/", 1)[-1] for x in r.stdout.split()) if ver_tuple(t)]
|
|
5753
|
+
return max(tags, key=ver_tuple).lstrip("v") if r.returncode == 0 and tags else None
|
|
5754
|
+
except (OSError, subprocess.TimeoutExpired):
|
|
5755
|
+
return None
|
|
5756
|
+
|
|
5757
|
+
|
|
5758
|
+
def latest_known(force=False):
|
|
5759
|
+
"""The newest release orch knows of. Asks the network at most once a day (always with force); with no answer
|
|
5760
|
+
it stays quiet and asks again a day later. ORCH_NO_UPDATE_CHECK=1: never asks."""
|
|
5761
|
+
if os.environ.get("ORCH_NO_UPDATE_CHECK") == "1":
|
|
5762
|
+
return None
|
|
5763
|
+
s = settings_load()
|
|
5764
|
+
if not force and now() - int(s.get("last_check") or 0) < UPDATE_CHECK_S:
|
|
5765
|
+
return s.get("latest_seen")
|
|
5766
|
+
latest = fetch_latest(thorough=force)
|
|
5767
|
+
s = settings_load()
|
|
5768
|
+
s["last_check"] = now()
|
|
5769
|
+
if latest:
|
|
5770
|
+
s["latest_seen"] = latest
|
|
5771
|
+
settings_save(s)
|
|
5772
|
+
return latest or (None if force else s.get("latest_seen"))
|
|
5773
|
+
|
|
5774
|
+
|
|
5775
|
+
def newer(latest):
|
|
5776
|
+
a, b = ver_tuple(latest), ver_tuple(installed_version())
|
|
5777
|
+
return bool(a and b and a > b)
|
|
5778
|
+
|
|
5779
|
+
|
|
5780
|
+
def update_notice(network=True):
|
|
5781
|
+
"""One line when a newer release is out (installed releases only). Never raises, never waits long."""
|
|
5782
|
+
try:
|
|
5783
|
+
if not release_install() or os.environ.get("ORCH_NO_UPDATE_CHECK") == "1":
|
|
5784
|
+
return
|
|
5785
|
+
latest = latest_known() if network else settings_load().get("latest_seen")
|
|
5786
|
+
if newer(latest):
|
|
5787
|
+
print(f"herdr-orchestra {latest} is out (you have {installed_version()}). Run `orch update`.")
|
|
5788
|
+
except Exception:
|
|
5789
|
+
pass
|
|
5790
|
+
|
|
5791
|
+
|
|
5792
|
+
def active_runs():
|
|
5793
|
+
"""Repos whose event manager is running on this machine right now (each manager signs in under active/)."""
|
|
5794
|
+
live = []
|
|
5795
|
+
d = share_dir() / "active"
|
|
5796
|
+
for f in (sorted(d.glob("*.json")) if d.is_dir() else []):
|
|
5797
|
+
try:
|
|
5798
|
+
root = json.loads(f.read_text()).get("root") or ""
|
|
5799
|
+
lock = Path(root) / ".orchestrate" / "driver.lock"
|
|
5800
|
+
held = False
|
|
5801
|
+
if root and lock.exists():
|
|
5802
|
+
with open(lock, "a") as fh:
|
|
5803
|
+
try:
|
|
5804
|
+
fcntl.flock(fh, fcntl.LOCK_SH | fcntl.LOCK_NB)
|
|
5805
|
+
fcntl.flock(fh, fcntl.LOCK_UN)
|
|
5806
|
+
except OSError:
|
|
5807
|
+
held = True
|
|
5808
|
+
if held:
|
|
5809
|
+
live.append(root)
|
|
5810
|
+
else:
|
|
5811
|
+
f.unlink(missing_ok=True) # that manager is gone
|
|
5812
|
+
except (OSError, ValueError):
|
|
5813
|
+
continue
|
|
5814
|
+
return live
|
|
5815
|
+
|
|
5816
|
+
|
|
5817
|
+
def sign_in_manager():
|
|
5818
|
+
"""The event manager tells the machine it is running, so no auto-update happens under a run."""
|
|
5819
|
+
with contextlib.suppress(OSError):
|
|
5820
|
+
d = share_dir() / "active"
|
|
5821
|
+
d.mkdir(parents=True, exist_ok=True)
|
|
5822
|
+
f = d / f"{os.getpid()}.json"
|
|
5823
|
+
f.write_text(json.dumps({"pid": os.getpid(), "root": str(ROOT), "started": now()}))
|
|
5824
|
+
import atexit
|
|
5825
|
+
atexit.register(lambda: f.unlink(missing_ok=True))
|
|
5826
|
+
|
|
5827
|
+
|
|
5828
|
+
def changelog_lines(version, limit=8):
|
|
5829
|
+
"""The headline of each changelog entry for a version, from the installed CHANGELOG.md."""
|
|
5830
|
+
p = share_dir() / "current" / "CHANGELOG.md"
|
|
5831
|
+
if not p.exists():
|
|
5832
|
+
return []
|
|
5833
|
+
out, on, tests = [], False, False
|
|
5834
|
+
for line in p.read_text(errors="replace").splitlines():
|
|
5835
|
+
if line.startswith("## "):
|
|
5836
|
+
if on:
|
|
5837
|
+
break
|
|
5838
|
+
on = line.startswith(f"## [{version}]")
|
|
5839
|
+
continue
|
|
5840
|
+
if line.startswith("### "):
|
|
5841
|
+
tests = line.strip().lower() == "### tests"
|
|
5842
|
+
continue
|
|
5843
|
+
if on and not tests and line.startswith("- "):
|
|
5844
|
+
m = re.match(r"- \*\*(.+?)\*\*", line)
|
|
5845
|
+
out.append((m.group(1) if m else line[2:]).rstrip(".")[:110])
|
|
5846
|
+
return out[:limit] + ([f"... ({len(out) - limit} more: CHANGELOG.md)"] if len(out) > limit else [])
|
|
5847
|
+
|
|
5848
|
+
|
|
5849
|
+
def update_log(msg):
|
|
5850
|
+
with contextlib.suppress(OSError):
|
|
5851
|
+
with open(share_dir() / "update.log", "a") as f:
|
|
5852
|
+
f.write(f"[{time.strftime('%Y-%m-%d %H:%M:%S')}] {msg}\n")
|
|
5853
|
+
|
|
5854
|
+
|
|
5855
|
+
def install_version(version, quiet=False):
|
|
5856
|
+
"""Install release `version` ('X.Y.Z') with that release's own install.sh. Returns (ok, message). The installer
|
|
5857
|
+
switches the `current` link only at its end, so a failed install leaves the old version active."""
|
|
5858
|
+
tag = f"v{version}"
|
|
5859
|
+
before = installed_version()
|
|
5860
|
+
env = {k: v for k, v in os.environ.items() if k not in ("ORCH_VERSION", "ORCH_AUTO_UPDATE")}
|
|
5861
|
+
env["ORCH_TTY"] = "/dev/null" # an update never stops to ask a question
|
|
5862
|
+
s = settings_load()
|
|
5863
|
+
if "auto_update" not in s: # ...so the installer's question is answered here, as it stands now
|
|
5864
|
+
s["auto_update"] = auto_update_on()
|
|
5865
|
+
settings_save(s)
|
|
5866
|
+
tmp = None
|
|
5867
|
+
try:
|
|
5868
|
+
src = update_source()
|
|
5869
|
+
if src:
|
|
5870
|
+
script = src / tag / "install.sh"
|
|
5871
|
+
if not script.exists():
|
|
5872
|
+
return False, f"version {tag} not found"
|
|
5873
|
+
cmd, env = ["bash", str(script), "--no-herdr-skill"], {**env, "ORCH_PACKAGE": "1"}
|
|
5874
|
+
else:
|
|
5875
|
+
if not shutil.which("curl"):
|
|
5876
|
+
return False, "curl is needed to download a release — or run: npx herdr-orchestra@latest"
|
|
5877
|
+
import urllib.request
|
|
5878
|
+
tmp = Path(tempfile.mkdtemp(prefix="orch-update-"))
|
|
5879
|
+
script = tmp / "install.sh"
|
|
5880
|
+
try:
|
|
5881
|
+
with urllib.request.urlopen(f"https://github.com/{UPDATE_REPO}/releases/download/{tag}/install.sh",
|
|
5882
|
+
timeout=30) as r:
|
|
5883
|
+
script.write_bytes(r.read())
|
|
5884
|
+
except Exception as e:
|
|
5885
|
+
return False, f"could not download {tag} ({e})"
|
|
5886
|
+
cmd = ["bash", str(script), "--version", tag, "--no-herdr-skill"]
|
|
5887
|
+
try:
|
|
5888
|
+
r = subprocess.run(cmd, text=True, capture_output=True, timeout=600, env=env, cwd=str(Path.home()),
|
|
5889
|
+
stdin=subprocess.DEVNULL)
|
|
5890
|
+
except (OSError, subprocess.TimeoutExpired) as e:
|
|
5891
|
+
return False, f"the installer did not finish ({e})"
|
|
5892
|
+
if r.returncode != 0:
|
|
5893
|
+
tail = " | ".join((r.stdout + r.stderr).strip().splitlines()[-3:])
|
|
5894
|
+
return False, f"the installer failed (exit {r.returncode}): {tail}"
|
|
5895
|
+
cur = share_dir() / "current" / "VERSION"
|
|
5896
|
+
got = cur.read_text().strip() if cur.exists() else "?"
|
|
5897
|
+
if got != version:
|
|
5898
|
+
return False, f"the installer ran but {got} is active, not {version}"
|
|
5899
|
+
if not quiet:
|
|
5900
|
+
print((r.stdout + r.stderr).strip())
|
|
5901
|
+
return True, f"herdr-orchestra {before} -> {version}"
|
|
5902
|
+
finally:
|
|
5903
|
+
if tmp:
|
|
5904
|
+
shutil.rmtree(tmp, ignore_errors=True)
|
|
5905
|
+
|
|
5906
|
+
|
|
5907
|
+
def cmd_update(args):
|
|
5908
|
+
"""orch update [--check] [--version vX.Y.Z] -> install the latest release (or that one) and say what is new."""
|
|
5909
|
+
want = None
|
|
5910
|
+
if "--version" in args:
|
|
5911
|
+
i = args.index("--version")
|
|
5912
|
+
want = args[i + 1] if len(args) > i + 1 else die("--version needs a value, e.g. --version v5.8.0")
|
|
5913
|
+
if not ver_tuple(want):
|
|
5914
|
+
die(f"{want!r} is not a version — use the form v5.8.0")
|
|
5915
|
+
want = want.lstrip("v")
|
|
5916
|
+
cur = installed_version()
|
|
5917
|
+
if not want:
|
|
5918
|
+
latest = latest_known(force=True)
|
|
5919
|
+
if not latest:
|
|
5920
|
+
die("could not reach GitHub to look for a new version" + (" (ORCH_NO_UPDATE_CHECK=1 is set)"
|
|
5921
|
+
if os.environ.get("ORCH_NO_UPDATE_CHECK") == "1" else "") + " — try again later, or run: "
|
|
5922
|
+
"npx herdr-orchestra@latest")
|
|
5923
|
+
if "--check" in args:
|
|
5924
|
+
print(f"herdr-orchestra {latest} is out (you have {cur}). Run `orch update`." if newer(latest)
|
|
5925
|
+
else f"herdr-orchestra {cur} is the latest version.")
|
|
5926
|
+
return
|
|
5927
|
+
if not newer(latest):
|
|
5928
|
+
print(f"herdr-orchestra {cur} is the latest version. Nothing to do.")
|
|
5929
|
+
return
|
|
5930
|
+
want = latest
|
|
5931
|
+
elif "--check" in args:
|
|
5932
|
+
die("--check looks for the latest version: leave out --version")
|
|
5933
|
+
live = active_runs()
|
|
5934
|
+
if live:
|
|
5935
|
+
print(f"NOTE a run is going ({', '.join(live)}). It keeps working, but its next steps use the new version.")
|
|
5936
|
+
ok, msg = install_version(want)
|
|
5937
|
+
if not ok:
|
|
5938
|
+
update_log(f"orch update {cur} -> {want} FAILED: {msg}")
|
|
5939
|
+
die(f"update failed, herdr-orchestra {cur} is still active: {msg}")
|
|
5940
|
+
update_log(f"orch update: {msg}")
|
|
5941
|
+
print(f"UPDATED {msg}")
|
|
5942
|
+
lines = changelog_lines(want)
|
|
5943
|
+
if lines:
|
|
5944
|
+
print(f"New in {want}:")
|
|
5945
|
+
for x in lines:
|
|
5946
|
+
print(f" - {x}")
|
|
5947
|
+
if ver_tuple(cur):
|
|
5948
|
+
print(f"Go back any time: orch update --version v{cur}")
|
|
5949
|
+
|
|
5950
|
+
|
|
5951
|
+
def cmd_config(args):
|
|
5952
|
+
"""orch config -> this machine's settings; orch config auto-update on|off."""
|
|
5953
|
+
if args[:1] == ["auto-update"] and args[1:2] and args[1].lower() in ("on", "off"):
|
|
5954
|
+
s = settings_load()
|
|
5955
|
+
s["auto_update"] = args[1].lower() == "on"
|
|
5956
|
+
settings_save(s)
|
|
5957
|
+
print(f"auto-update: {args[1].lower()}" + (" — orch installs new versions by itself when a new plan starts, "
|
|
5958
|
+
"never during a run" if s["auto_update"] else " — orch only tells you when a new version is out; "
|
|
5959
|
+
"update with `orch update`"))
|
|
5960
|
+
return
|
|
5961
|
+
if args:
|
|
5962
|
+
die("usage: orch config | orch config auto-update on|off")
|
|
5963
|
+
s = settings_load()
|
|
5964
|
+
env = os.environ.get("ORCH_AUTO_UPDATE")
|
|
5965
|
+
print(f"auto-update: {'on' if auto_update_on() else 'off'}"
|
|
5966
|
+
+ (f" (ORCH_AUTO_UPDATE={env} overrides the saved setting)" if env else "")
|
|
5967
|
+
+ ("" if "auto_update" in s or env else " (never asked: `orch config auto-update on` turns it on)"))
|
|
5968
|
+
print(f"installed: {installed_version()}" + ("" if release_install() else " (not a release install: no update checks)"))
|
|
5969
|
+
lc = int(s.get("last_check") or 0)
|
|
5970
|
+
print("last check: " + (time.strftime("%Y-%m-%d %H:%M", time.localtime(lc)) if lc else "never")
|
|
5971
|
+
+ (f", latest seen: {s['latest_seen']}" if s.get("latest_seen") else "")
|
|
5972
|
+
+ (" (ORCH_NO_UPDATE_CHECK=1: checks are off)" if os.environ.get("ORCH_NO_UPDATE_CHECK") == "1" else ""))
|
|
5973
|
+
print(f"settings file: {share_dir() / 'settings.json'}")
|
|
5974
|
+
|
|
5975
|
+
|
|
5976
|
+
def auto_update_at_plan():
|
|
5977
|
+
"""Start of a new plan (`orch lead plan`): with auto-update on, move to the newest release first and carry on
|
|
5978
|
+
as that version. Skipped (with one line saying why) during any run on this machine, for a major jump, in a repo
|
|
5979
|
+
pinned with .orch-version, and for a checkout. A failed update keeps the version that is here."""
|
|
5980
|
+
try:
|
|
5981
|
+
if os.environ.get("ORCH_UPDATED") == "1" or not release_install():
|
|
5982
|
+
return
|
|
5983
|
+
latest = latest_known()
|
|
5984
|
+
if not newer(latest):
|
|
5985
|
+
return
|
|
5986
|
+
cur = installed_version()
|
|
5987
|
+
note = f"herdr-orchestra {latest} is out (you have {cur})."
|
|
5988
|
+
if not auto_update_on():
|
|
5989
|
+
print(f"{note} Run `orch update`.\n")
|
|
5990
|
+
return
|
|
5991
|
+
if ver_tuple(latest)[0] > ver_tuple(cur)[0]:
|
|
5992
|
+
print(f"{note} It is a major version, so it is not installed by itself: read its changelog, then run "
|
|
5993
|
+
f"`orch update`.\n")
|
|
5994
|
+
return
|
|
5995
|
+
if Path(".orch-version").exists():
|
|
5996
|
+
print(f"{note} Not installed: this repo pins its version in .orch-version.\n")
|
|
5997
|
+
return
|
|
5998
|
+
if now() - int(settings_load().get("last_auto_fail") or 0) < UPDATE_CHECK_S:
|
|
5999
|
+
print(f"{note} Auto-update failed earlier today (see {share_dir() / 'update.log'}); it tries again "
|
|
6000
|
+
f"tomorrow, or run `orch update`.\n")
|
|
6001
|
+
return
|
|
6002
|
+
live = active_runs()
|
|
6003
|
+
if live:
|
|
6004
|
+
print(f"{note} Not installed now: a run is going ({', '.join(live)}). It installs when a plan starts "
|
|
6005
|
+
f"with no run going.\n")
|
|
6006
|
+
return
|
|
6007
|
+
ok, msg = install_version(latest, quiet=True)
|
|
6008
|
+
if not ok:
|
|
6009
|
+
update_log(f"auto-update {cur} -> {latest} FAILED: {msg}")
|
|
6010
|
+
print(f"WARN auto-update to {latest} failed, {cur} is still active: {msg} (it tries again tomorrow; "
|
|
6011
|
+
f"or run `orch update`)\n")
|
|
6012
|
+
s = settings_load()
|
|
6013
|
+
s["last_auto_fail"] = now() # one try a day, not one per plan
|
|
6014
|
+
settings_save(s)
|
|
6015
|
+
return
|
|
6016
|
+
update_log(f"auto-update: {msg}")
|
|
6017
|
+
print(f"UPDATED {msg} (auto-update; turn it off with `orch config auto-update off`)")
|
|
6018
|
+
for x in changelog_lines(latest, 5):
|
|
6019
|
+
print(f" - {x}")
|
|
6020
|
+
print()
|
|
6021
|
+
sys.stdout.flush()
|
|
6022
|
+
new = share_dir() / "current" / "bin" / "orch"
|
|
6023
|
+
os.environ["ORCH_UPDATED"] = "1"
|
|
6024
|
+
os.execv(sys.executable, [sys.executable, str(new), *sys.argv[1:]])
|
|
6025
|
+
except Exception as e: # an update problem never stops the plan
|
|
6026
|
+
update_log(f"auto-update error: {e!r}")
|
|
6027
|
+
|
|
6028
|
+
|
|
5626
6029
|
if __name__ == "__main__":
|
|
5627
6030
|
if len(sys.argv) >= 2 and sys.argv[1] in ("version", "--version", "-v"):
|
|
5628
6031
|
print(f"herdr-orchestra {installed_version()}")
|
|
6032
|
+
update_notice()
|
|
5629
6033
|
sys.exit(0)
|
|
5630
6034
|
NO_REPO_COMMANDS = {"lead": cmd_lead, "agents": cmd_agents, "doctor": cmd_doctor, "models": cmd_models,
|
|
5631
|
-
"team": cmd_team}
|
|
6035
|
+
"team": cmd_team, "update": cmd_update, "config": cmd_config}
|
|
5632
6036
|
if (len(sys.argv) >= 2 and sys.argv[1] in NO_REPO_COMMANDS # work outside a git repo
|
|
5633
6037
|
and sys.argv[2:3] != ["up"] and sys.argv[2:3] != ["--crash"]): # (`orch team up` reads the run's state)
|
|
5634
|
-
|
|
6038
|
+
try:
|
|
6039
|
+
NO_REPO_COMMANDS[sys.argv[1]](sys.argv[2:])
|
|
6040
|
+
sys.stdout.flush()
|
|
6041
|
+
except BrokenPipeError: # `orch config | head`: the reader has what it wanted
|
|
6042
|
+
with contextlib.suppress(OSError):
|
|
6043
|
+
os.dup2(os.open(os.devnull, os.O_WRONLY), sys.stdout.fileno())
|
|
5635
6044
|
sys.exit(0)
|
|
5636
6045
|
if len(sys.argv) < 2 or sys.argv[1] not in COMMANDS:
|
|
5637
6046
|
print(USAGE)
|
package/install.sh
CHANGED
|
@@ -23,7 +23,8 @@ BIN="$HOME/.local/bin"
|
|
|
23
23
|
SKILLS="$HOME/.agents/skills"
|
|
24
24
|
OC_CMDS=("$HOME/.config/opencode/commands" "$HOME/.config/opencode/command")
|
|
25
25
|
MANIFEST="$SHARE/manifest.txt" # files installed outside $SHARE, removed by --uninstall
|
|
26
|
-
|
|
26
|
+
SETTINGS="$SHARE/settings.json" # this machine's choices (auto-update); every installed version reads it
|
|
27
|
+
SHIP=(bin skills opencode-commands claude-commands playbooks agents.default.toml models.default.toml VERSION CHANGELOG.md)
|
|
27
28
|
|
|
28
29
|
say() { printf '\033[1;32m==>\033[0m %s\n' "$*"; }
|
|
29
30
|
warn() { printf '\033[1;33mwarn:\033[0m %s\n' "$*" >&2; }
|
|
@@ -39,11 +40,13 @@ Options:
|
|
|
39
40
|
--current show the installed version
|
|
40
41
|
--uninstall remove herdr-orchestra (keeps the herdr skill and your projects' .orchestrate/)
|
|
41
42
|
--no-herdr-skill don't install/refresh the official herdr skill via npx
|
|
43
|
+
--auto-update keep herdr-orchestra up to date automatically (no question asked)
|
|
44
|
+
--no-auto-update never update by itself (also: ORCH_AUTO_UPDATE=1 or 0)
|
|
42
45
|
-h, --help this help
|
|
43
46
|
EOF
|
|
44
47
|
}
|
|
45
48
|
|
|
46
|
-
VERSION_ARG="" ACTION="install" HERDR_SKILL=1
|
|
49
|
+
VERSION_ARG="" ACTION="install" HERDR_SKILL=1 AUTO_UPDATE="${ORCH_AUTO_UPDATE:-}"
|
|
47
50
|
while [[ $# -gt 0 ]]; do
|
|
48
51
|
case "$1" in
|
|
49
52
|
--version) VERSION_ARG="${2:?--version needs a value}"; shift 2;;
|
|
@@ -52,6 +55,8 @@ while [[ $# -gt 0 ]]; do
|
|
|
52
55
|
--current) ACTION="current"; shift;;
|
|
53
56
|
--uninstall) ACTION="uninstall"; shift;;
|
|
54
57
|
--no-herdr-skill) HERDR_SKILL=0; shift;;
|
|
58
|
+
--auto-update) AUTO_UPDATE=1; shift;;
|
|
59
|
+
--no-auto-update) AUTO_UPDATE=0; shift;;
|
|
55
60
|
-h|--help) usage; exit 0;;
|
|
56
61
|
*) die "unknown option: $1 (see --help)";;
|
|
57
62
|
esac
|
|
@@ -211,6 +216,54 @@ if [[ $HERDR_SKILL -eq 1 ]]; then
|
|
|
211
216
|
fi
|
|
212
217
|
fi
|
|
213
218
|
|
|
219
|
+
# ---------------------------------------------------------------- auto-update: asked once, the answer is kept
|
|
220
|
+
setting() { # setting get <key> | setting set <key> <true|false>
|
|
221
|
+
python3 - "$SETTINGS" "$@" <<'PYEOF'
|
|
222
|
+
import json, os, sys
|
|
223
|
+
path, op, key = sys.argv[1:4]
|
|
224
|
+
try:
|
|
225
|
+
data = json.load(open(path))
|
|
226
|
+
if not isinstance(data, dict):
|
|
227
|
+
data = {}
|
|
228
|
+
except (OSError, ValueError):
|
|
229
|
+
data = {}
|
|
230
|
+
if op == "get":
|
|
231
|
+
v = data.get(key)
|
|
232
|
+
print("" if v is None else ("1" if v else "0"))
|
|
233
|
+
else:
|
|
234
|
+
data[key] = sys.argv[4] == "true"
|
|
235
|
+
tmp = path + ".tmp"
|
|
236
|
+
with open(tmp, "w") as f:
|
|
237
|
+
json.dump(data, f, indent=1)
|
|
238
|
+
os.replace(tmp, path)
|
|
239
|
+
PYEOF
|
|
240
|
+
}
|
|
241
|
+
case "$AUTO_UPDATE" in
|
|
242
|
+
1|on|true|yes) setting set auto_update true;;
|
|
243
|
+
0|off|false|no) setting set auto_update false;;
|
|
244
|
+
*)
|
|
245
|
+
if [[ -z "$(setting get auto_update)" ]]; then # never answered on this machine (a new or an older install)
|
|
246
|
+
TTY="${ORCH_TTY:-}" # under `curl | bash` stdin is this script: ask the terminal
|
|
247
|
+
if [[ -z "$TTY" ]]; then
|
|
248
|
+
if [[ -t 0 ]]; then TTY=/dev/stdin; elif { : < /dev/tty; } 2>/dev/null; then TTY=/dev/tty; fi
|
|
249
|
+
fi
|
|
250
|
+
ans=""
|
|
251
|
+
if [[ -n "$TTY" ]]; then
|
|
252
|
+
{
|
|
253
|
+
printf '\033[1;32m==>\033[0m Keep herdr-orchestra up to date automatically? [Y/n]\n'
|
|
254
|
+
printf ' (orch installs new versions by itself, never during a run. Change it later: orch config auto-update off)\n > '
|
|
255
|
+
} >&2
|
|
256
|
+
IFS= read -r ans < "$TTY" 2>/dev/null || true
|
|
257
|
+
fi
|
|
258
|
+
case "$ans" in n|N|no|No|NO) setting set auto_update false;; *) setting set auto_update true;; esac
|
|
259
|
+
fi;;
|
|
260
|
+
esac
|
|
261
|
+
if [[ "$(setting get auto_update)" == 1 ]]; then
|
|
262
|
+
say "auto-update: on (turn it off with: orch config auto-update off)"
|
|
263
|
+
else
|
|
264
|
+
say "auto-update: off (turn it on with: orch config auto-update on; update by hand with: orch update)"
|
|
265
|
+
fi
|
|
266
|
+
|
|
214
267
|
case ":$PATH:" in *":$BIN:"*) ;; *) warn "$BIN is not on your PATH — add: export PATH=\"\$HOME/.local/bin:\$PATH\"";; esac
|
|
215
268
|
|
|
216
269
|
say "herdr-orchestra $VER is active"
|
|
@@ -220,6 +273,7 @@ cat <<'MSG'
|
|
|
220
273
|
Run orch autopilot (or ask the lead: /orch-run, or "Run `orch lead run` and follow it")
|
|
221
274
|
Agents orch agents New agent installed later? orch agents sync
|
|
222
275
|
Status orch status Version orch version
|
|
276
|
+
Update orch update Auto-update orch config auto-update on|off
|
|
223
277
|
|
|
224
278
|
Restart running agents (or start a new thread) so they pick up the new skills and commands.
|
|
225
279
|
MSG
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "herdr-orchestra",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.8.0",
|
|
4
4
|
"description": "Orchestrate AI coding agents (Claude Code, Codex, OpenCode, Amp) as one team in Herdr: a lead plans, coders build in parallel, a reviewer checks, you get one PR.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"bin": {
|
package/playbooks/plan.md
CHANGED
|
@@ -17,6 +17,7 @@ Feature request = the user's message that asked you to run this playbook.
|
|
|
17
17
|
**Small change? There is a quick path.** After research (step 2) you decide whether this is a **quick run** (step 2b) or the full process. A quick run is for any small, clear change: a UI tweak, a new field in an API response, a validation rule, a bug fix in one function, a config or docs change, or several of these together. It skips the parts of planning and running that only big features need. The developer can decide for you by starting the request with `quick:` (quick run), `quick review:` (quick run that keeps a reviewer) or `full:` (the full process).
|
|
18
18
|
|
|
19
19
|
## 1. Preflight (stop and report if any check fails)
|
|
20
|
+
- **Lines above this playbook about a version.** `UPDATED herdr-orchestra X -> Y`: orch updated itself before this plan; tell the developer in one line and carry on. `herdr-orchestra Y is out (you have X)`: tell the developer once, with the command it names (`orch update`), and carry on with the plan. Never run `orch update` yourself: it is the developer's call. A `WARN auto-update ... failed` line: pass it on and carry on.
|
|
20
21
|
- `orch lead check` prints `OK`. If it fails, show the user its message (it says how to fix it), then stop. Do not test `$HERDR_ENV` yourself: some agents (Hermes) run their shell tool outside the pane's environment, so it can be empty inside a real Herdr pane.
|
|
21
22
|
- Inside a git repo, and `git status --porcelain` is empty. If not, ask the user to commit or stash first.
|
|
22
23
|
- `mkdir -p .orchestrate`.
|