Watch
0
0
Fork
You've already forked hyperhive
0

subagent: default cwd to the work dir only when it exists

A spawn into a missing cwd fails with a bare ENOENT; a daemon newer than its
container's bind now inherits its own cwd again, as before the work-dir default.
This commit is contained in:
atlas 2026-10-15 23:02:58 +02:00 • committed by mara
commit 8c0a552792
5 changed files with 49 additions and 12 deletions

View file

@ -32,13 +32,21 @@ pub fn state_dir() -> PathBuf {
/// The agent's persistent work dir, a sibling of [`state_dir`]
/// (`/agents/<name>/work`). It has no `CLAUDE.md` above it, so a subagent
/// started here does not load the agent's own. This is the working
/// directory a subagent gets when `start` is given no `dir`.
/// started here does not load the agent's own.
#[must_use]
pub fn work_dir() -> PathBuf {
state_dir().with_file_name("work")
}
/// The working directory a subagent gets when `start` is given no `dir`:
/// [`work_dir`] when it exists, else `None` (the daemon's own cwd). The
/// directory only exists once the container has restarted with its bind, and
/// a spawn into a missing cwd fails with a bare ENOENT.
#[must_use]
pub fn default_cwd() -> Option<PathBuf> {
Some(work_dir()).filter(|p| p.is_dir())
}
/// Where this agent's named subagent role files live, one markdown file per
/// role under the agent's own [`state_dir`]. Per-agent rather than
/// hive-wide: the clauses a role carries came out of one agent's own prompt