feat: orch up starts issue sessions in existing worktrees
orch up MANIFEST reads an issue manifest (a path, or NAME in manifest_dir, default <config>/manifests, set in <config>/config.toml) and starts one detached session per listed worktree, across repos. Each worktree brings its own machine, profile and .hx/task.md; the task text now reaches the agent. Sessions live in <state>/issues.db; orch issues shows them grouped by issue. Also: liveness checks use kill(pid, 0) instead of /proc (broken on macOS), the same branch name in two repos no longer counts as the same place, and the merge queue column ticket is renamed to issue (migrated on open). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
440b19180e
commit
20f88d88df
16 files changed
+791
-65
No files matched your search
+47
-3
@@ -6,6 +6,7 @@ mod db;
|
||||
mod detail;
|
||||
mod goal;
|
||||
mod init;
|
||||
mod issue;
|
||||
mod junit;
|
||||
mod lock;
|
||||
mod machine;
|
||||
@@ -143,6 +144,13 @@ enum Cmd {
|
||||
#[arg(long, default_value = "default")]
|
||||
profile: String,
|
||||
},
|
||||
/// Start one detached session per worktree of an issue manifest (a file, or NAME in `manifest_dir`).
|
||||
Up { manifest: String },
|
||||
/// The TUI on the sessions `orch up` started, grouped by issue.
|
||||
Issues,
|
||||
/// Run one session of the issues database (started by `orch up`, not by hand).
|
||||
#[command(hide = true)]
|
||||
Launch { id: String },
|
||||
/// hx extension that enforces a run's tool allowlist (started by hx, not by hand).
|
||||
#[command(hide = true)]
|
||||
Guard { policy: PathBuf },
|
||||
@@ -194,10 +202,47 @@ fn code(ok: bool) -> std::process::ExitCode {
|
||||
|
||||
fn main() -> Result<std::process::ExitCode> {
|
||||
let Some(cmd) = Cli::parse().cmd else {
|
||||
tui::run()?;
|
||||
tui::run(false)?;
|
||||
return Ok(code(true));
|
||||
};
|
||||
match cmd {
|
||||
Cmd::Issues => {
|
||||
tui::run(true)?;
|
||||
Ok(code(true))
|
||||
}
|
||||
Cmd::Up { manifest } => {
|
||||
for o in issue::up(&manifest)? {
|
||||
println!("{} {}: {}", o.session, o.name, o.what);
|
||||
}
|
||||
println!("watch them with: orch issues");
|
||||
Ok(code(true))
|
||||
}
|
||||
Cmd::Launch { id } => match issue::launch(&id) {
|
||||
Ok(status) => {
|
||||
println!("{id} -> {status}");
|
||||
Ok(code(status == "merged" || status == "done"))
|
||||
}
|
||||
Err(e) => {
|
||||
// the TUI shows why; without this the session would sit there as queued
|
||||
if let Ok(db) = db::Db::open(&issue::db_path())
|
||||
&& db.session(&id).ok().flatten().is_some_and(|s| {
|
||||
!matches!(
|
||||
s.status.as_str(),
|
||||
"done" | "merged" | "failed" | "escalated" | "aborted"
|
||||
)
|
||||
})
|
||||
{
|
||||
let _ = db.set_session(&id, "", "failed");
|
||||
let _ = db.set_pid(&id, None);
|
||||
let _ = db.emit(
|
||||
&id,
|
||||
"end",
|
||||
serde_json::json!({"status": "failed", "reason": format!("{e:#}")}),
|
||||
);
|
||||
}
|
||||
Err(e)
|
||||
}
|
||||
},
|
||||
Cmd::Init { repo, force } => {
|
||||
let written = init::run(&repo, &config_dir(), force)?;
|
||||
for p in &written {
|
||||
@@ -284,8 +329,7 @@ fn main() -> Result<std::process::ExitCode> {
|
||||
);
|
||||
anyhow::ensure!(
|
||||
s.pid
|
||||
.is_none_or(|p| !Path::new(&format!("/proc/{p}")).exists()
|
||||
|| p == std::process::id()),
|
||||
.is_none_or(|p| !state::pid_alive(p) || p == std::process::id()),
|
||||
"session {id} is still running (pid {})",
|
||||
s.pid.unwrap_or(0)
|
||||
);
|
||||
|
||||
Reference in new issue
Block a user