From bf944ddf3a0e8600ae6ad648fd8e9d8a2274bea1 Mon Sep 17 00:00:00 2001 From: Sebastian Gieseler Date: Fri, 6 Nov 2026 15:29:05 +0100 Subject: [PATCH 1/2] feat: lane start, stop and reset take the lane of the worktree they run in In a lane's worktree `devstack up` found the lane by itself, while `devstack lane stop` refused without a name. Without one, start, stop and reset now take the lane whose worktree the command runs in, by the daemon's list (start brings the daemon up first, as up does). In the main working tree or outside a worktree they ask for the name as before. Closes #476 Co-Authored-By: Claude Opus 5.5 --- CHANGELOG.md | 10 +++++++++ crates/devstack/src/client.rs | 27 ++++++++++++++++++++--- crates/devstack/src/dispatch/lane.rs | 21 +++++++++++++++--- crates/devstack/src/main.rs | 33 +++++++++++++++++++++++----- docs/stack-file.md | 3 ++- skills/devstack/SKILL.md | 2 +- 6 files changed, 82 insertions(+), 14 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 746f0e8a..cb2944e8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,16 @@ and listed with their assets on the ### Added +- **`devstack lane start`, `stop` and `reset` take the lane of the worktree + they run in.** In a lane's worktree, `devstack up` found the lane by + itself, while `devstack lane stop` refused without its name, and an agent + finishing its work had to work out the name first. Without a name, the + three now take the lane whose worktree the command runs in (from any + folder of it). In the main working tree, or outside a worktree, they ask + for the name as before. + +### Added + - **`devstack init` sets `PYTHONUTF8 = "1"` for Python apps.** On Windows a native Python process opens text files in the ANSI code page (cp1252) unless the code passes `encoding=`, while the same code in a container diff --git a/crates/devstack/src/client.rs b/crates/devstack/src/client.rs index 587cb18b..a12643d0 100644 --- a/crates/devstack/src/client.rs +++ b/crates/devstack/src/client.rs @@ -2184,9 +2184,13 @@ pub fn lane_start( /// daemon's list; `None` in the main working tree, or without a daemon. pub fn worktree_lane(stack_file: &Path) -> Option { let c = Client::probe(&state_dir(stack_file).ok()?).ok().flatten()?; - let wt = worktree()?; - let lanes: Vec = serde_json::from_str(&c.get("/v1/lanes").ok()?).ok()?; - let me = devstack_proc::long_path(&wt.path); + lane_at(&c, &worktree()?.path).ok() +} + +/// The name of the lane whose worktree is `path`, by the daemon's list. +fn lane_at(c: &Client, path: &Path) -> Result { + let lanes: Vec = serde_json::from_str(&c.get("/v1/lanes")?)?; + let me = devstack_proc::long_path(path); lanes .iter() .find(|l| { @@ -2195,6 +2199,23 @@ pub fn worktree_lane(stack_file: &Path) -> Option { .is_some_and(|p| same_dir(&devstack_proc::long_path(Path::new(p)), &me)) }) .and_then(|l| l["name"].as_str().map(str::to_string)) + .ok_or_else(|| anyhow!("the daemon knows no lane at {}", path.display())) +} + +/// The lane of the worktree the CLI runs in, for `devstack lane` without a +/// name (#476): an error in the main working tree or outside a worktree. +/// With `start`, the daemon is started to ask it, as `up` does. +pub fn lane_here(stack_file: &Path, start: bool) -> Result { + let state = state_dir(stack_file)?; + let Some(wt) = worktree() else { + bail!("this is not a lane's worktree"); + }; + let c = if start { + ensure_daemon(&daemon_file(stack_file), &state)? + } else { + need(&state)? + }; + lane_at(&c, &wt.path) } /// In the worktree of a lane on a node, for `status`: what `prepare` makes, diff --git a/crates/devstack/src/dispatch/lane.rs b/crates/devstack/src/dispatch/lane.rs index 9e0f5b64..7d46e99f 100644 --- a/crates/devstack/src/dispatch/lane.rs +++ b/crates/devstack/src/dispatch/lane.rs @@ -12,9 +12,12 @@ pub(crate) fn run(file: &Path, action: LaneAction) -> Result<()> { on, profile, run, - } => client::lane_start(file, &name, on.as_deref(), profile.as_deref(), run), - LaneAction::Stop { name } => client::lane_stop(file, &name), - LaneAction::Reset { name } => client::lane_reset(file, &name), + } => { + let name = named(file, name, "start", true)?; + client::lane_start(file, &name, on.as_deref(), profile.as_deref(), run) + } + LaneAction::Stop { name } => client::lane_stop(file, &named(file, name, "stop", false)?), + LaneAction::Reset { name } => client::lane_reset(file, &named(file, name, "reset", false)?), LaneAction::Prune { older_than, dry_run, @@ -23,3 +26,15 @@ pub(crate) fn run(file: &Path, action: LaneAction) -> Result<()> { LaneAction::Share { name, with } => client::lane_share(file, &name, &with), } } + +/// The lane named, or without a name the lane of the worktree the command +/// runs in, as `devstack up` there finds it (#476). `start` brings the +/// daemon up to ask it; the others need it running anyway. +fn named(file: &Path, name: Option, action: &str, start: bool) -> Result { + match name { + Some(n) => Ok(n), + None => client::lane_here(file, start).map_err(|e| { + anyhow::anyhow!("{e}; name it: `devstack lane {action} ` (`devstack lane list`)") + }), + } +} diff --git a/crates/devstack/src/main.rs b/crates/devstack/src/main.rs index 14d8e506..2211d36b 100644 --- a/crates/devstack/src/main.rs +++ b/crates/devstack/src/main.rs @@ -553,9 +553,10 @@ enum LaneAction { List, /// Start a lane (its name or branch, see `lane list`) from anywhere in /// the repository, as `devstack up` in its worktree does: its own ports - /// and containers, beside the main tree. + /// and containers, beside the main tree. Without a name: the lane of + /// the worktree it runs in. Start { - name: String, + name: Option, /// Run it on this node of the pool (its name or member id), or /// `pool` to let the coordinator choose (ADR-0025). #[arg(long, value_name = "NODE")] @@ -570,12 +571,13 @@ enum LaneAction { }, /// Stop a lane: its services stop and it is no longer started (its /// builds stay). The worktree is git's: devstack never creates or removes - /// one. - Stop { name: String }, + /// one. Without a name: the lane of the worktree it runs in. + Stop { name: Option }, /// Throw a stopped lane's data away (ADR-0038): its containers and /// volumes here and on the nodes it ran on. Its next start is a fresh - /// one, seeded again; its worktree and builds stay. - Reset { name: String }, + /// one, seeded again; its worktree and builds stay. Without a name: the + /// lane of the worktree it runs in. + Reset { name: Option }, /// Remove what this repository's lanes leave behind: on this machine /// the containers and volumes of lanes whose worktree is gone, on the /// pool's nodes this machine's kept lanes of this repository that are @@ -1276,6 +1278,25 @@ mod tests { #[test] fn lane_pool_and_node_subcommands() { + // In a lane's worktree the name may be left out (#476). + for action in ["start", "stop", "reset"] { + let cli = parse(&["lane", action]); + assert!( + matches!( + cli.cmd, + Cmd::Lane { + action: LaneAction::Start { name: None, .. } + | LaneAction::Stop { name: None } + | LaneAction::Reset { name: None } + } + ), + "{action}" + ); + } + assert!(matches!( + parse(&["lane", "stop", "feature"]).cmd, + Cmd::Lane { action: LaneAction::Stop { name: Some(n) } } if n == "feature" + )); assert!(matches!( parse(&["lane", "move", "feature", "--to", "local"]).cmd, Cmd::Lane { action: LaneAction::Move { name, to } } if name == "feature" && to == "local" diff --git a/docs/stack-file.md b/docs/stack-file.md index 15fb2edb..1c48e61b 100644 --- a/docs/stack-file.md +++ b/docs/stack-file.md @@ -882,7 +882,8 @@ stop the lane first: see `prepare`). Ignored files are not in the snapshot: `devstack lane stop ` stops a lane (its builds stay, the worktree too); `devstack lane reset ` throws a stopped lane's data away (its containers and volumes, here and on the nodes it ran on), so it starts - fresh; `devstack lane prune [--older-than 7d] [--dry-run]` removes what + fresh. In a lane's worktree, `start`, `stop` and `reset` take that lane + without a name; `devstack lane prune [--older-than 7d] [--dry-run]` removes what lanes whose worktree is gone left behind, here and on the pool's nodes (ADR-0038); with `--older-than`, also entries of the store of `prepare` that no copy used for as long (ADR-0062). diff --git a/skills/devstack/SKILL.md b/skills/devstack/SKILL.md index aab808b5..fde19a89 100644 --- a/skills/devstack/SKILL.md +++ b/skills/devstack/SKILL.md @@ -58,7 +58,7 @@ Run from anywhere in the repository: without `-f`, devstack looks for `devstack. | `devstack up` refuses: "the stack `` … runs on " | another repository's stack on this machine runs on the same ports. Nothing started. Ask the user, then `devstack up --shift auto` (MCP `up` with `shift: "auto"`): this stack runs on its ports + 1000 (2000, ...) on this machine, services, containers and links alike, its data unchanged, and keeps the shift until `devstack up --shift none`. Ports written into app config outside devstack's placeholders do not move. A stopped stack on the same ports only warns while they are free. `devstack status` shows `shifted +1000` | | `devstack up` refuses: "the containers of the stack `` … hold , though its daemon does not run" | Docker started that stack's containers again (their restart policy) while its daemon stayed down. Nothing started. Ask the user, then `devstack down` in that stack's repository: its containers go, its volumes and data stay. Or shift this stack as above. "another program holds ": find it with `Get-NetTCPConnection -LocalPort

` (Windows) or `lsof -nP -iTCP:

-sTCP:LISTEN` | | `devstack up` in a `git worktree` | starts that worktree's **lane** (every worktree is one) in the main tree's daemon: its own builds, ports moved by +100 (+200, ...), its own containers (a Compose project per lane, ports moved alike; the deprecated `shared` services come from the main tree), no background workers (`--workers` turns them on; `--force` skips the memory check). Every command in the worktree then acts on the lane (`devstack lane list` shows all) | -| `git worktree add -b ` | a new worktree is a lane at once, not started (devstack never creates or removes worktrees; use git or your tool); tell the user its dashboard page (`devstack ui --link` in it). A lane runs from a copy of its worktree, so removing the worktree stops the lane and takes its state along. `devstack lane stop ` stops a lane and keeps the worktree. **When the lane links directories into its worktree** (`devstack lane list`: `linked`, from `prepare.link`), run `devstack lane stop ` before `git worktree remove`: on Windows Git follows the junction and empties the lane's copy, or leaves the worktree behind with the junction in it; the stop removes the links. Without links the remove works while the lane runs | +| `git worktree add -b ` | a new worktree is a lane at once, not started (devstack never creates or removes worktrees; use git or your tool); tell the user its dashboard page (`devstack ui --link` in it). A lane runs from a copy of its worktree, so removing the worktree stops the lane and takes its state along. `devstack lane stop ` stops a lane and keeps the worktree; in the lane's own worktree `devstack lane stop` (likewise `lane start`, `lane reset`) needs no name. **When the lane links directories into its worktree** (`devstack lane list`: `linked`, from `prepare.link`), run `devstack lane stop ` before `git worktree remove`: on Windows Git follows the junction and empties the lane's copy, or leaves the worktree behind with the junction in it; the stop removes the links. Without links the remove works while the lane runs | | a directory in a worktree that `prepare` links (`node_modules`, see `devstack lane list`: `linked`) | it is **the lane's copy**, not the worktree's own: on Windows a junction, which looks like a folder. Do not reinstall, delete or clean it there (`npm ci`, `rm -rf`, `git clean -x`, an IDE's "delete node_modules"): that empties what the lane runs from (for a lane on a node, its copy from the store), and a running dev server then fails. To install your own, ask the user, then stop the lane (`devstack lane stop ` removes the link) or remove only the link (`cmd /c rmdir

` on Windows, without `/s`; `rm ` elsewhere, no trailing slash), then install. devstack prepares a copy emptied this way again (a notice says so), but the lane's dev server fails until then | | `devstack lane start [--on ]` | start a lane from the main tree (or anywhere in the repository), as `devstack up` in its worktree does; `status` in the main tree lists the lanes in one line. **To run another branch or commit beside the main stack** (an end-to-end run against a given commit, a review): `git worktree add `, `devstack lane start ` (its ports are the main ports plus its offset, `devstack lane list`), test against those, `devstack lane stop `, `git worktree remove `. A commit without a stack file of its own runs with the main tree's. **For an acceptance run** use the stack file's profile if it has one (`status` lists none; `[profiles]` in the file): `devstack lane start --profile

--run` starts the lane as the profile says (a build instead of a dev server, workers, fresh data, the suite's env) and runs its suite command. A worktree another tool or script created is a lane too: starting it gives its own ports, containers and database without building a separate environment | | `devstack lane reset ` / `devstack lane prune [--older-than 7d] [--dry-run]` | throw a stopped lane's data away (it starts fresh, seeded again); remove what lanes whose worktree is gone left behind, here and on the pool's nodes. A lane on a node keeps its data there between starts. Ask the user before either: data goes | From efd8e043ee7cac4875b662ae8ae1fbb8c369338a Mon Sep 17 00:00:00 2001 From: Sebastian Gieseler Date: Fri, 6 Nov 2026 15:32:13 +0100 Subject: [PATCH 2/2] feat(mcp): lane_stop without a lane stops the lane of this worktree Co-Authored-By: Claude Opus 5.5 --- CHANGELOG.md | 5 +++-- crates/devstack/src/mcp.rs | 13 ++++++++++--- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index cb2944e8..d13af361 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,8 +16,9 @@ and listed with their assets on the itself, while `devstack lane stop` refused without its name, and an agent finishing its work had to work out the name first. Without a name, the three now take the lane whose worktree the command runs in (from any - folder of it). In the main working tree, or outside a worktree, they ask - for the name as before. + folder of it), and so does the MCP tool `lane_stop` without `lane`. In + the main working tree, or outside a worktree, they ask for the name as + before. ### Added diff --git a/crates/devstack/src/mcp.rs b/crates/devstack/src/mcp.rs index 3e917634..fdc3ee6e 100644 --- a/crates/devstack/src/mcp.rs +++ b/crates/devstack/src/mcp.rs @@ -576,9 +576,9 @@ pub fn tools() -> Vec { "lane_stop", "Stop a started lane: its services stop, its builds and containers' data stay; `lane_start` starts it again. Not the lane serving the main ports (`promote_lane` main first). POST /v1/lanes/{lane}/stop.", json!({ - "lane": { "type": "string", "description": "The lane's name (see `lanes`)" }, + "lane": { "type": "string", "description": "The lane's name (see `lanes`). Without it: the lane of the worktree this server runs in" }, }), - &["lane"], + &[], false, ), tool( @@ -973,7 +973,14 @@ fn call(name: &str, args: &Value, file: &Path) -> Result { } } "lane_stop" => { - let lane = name_arg(args, "lane")?; + // Without a name, the lane of this worktree, as the CLI (#476). + let here; + let lane = if args.get("lane").is_some_and(|l| !l.is_null()) { + name_arg(args, "lane")? + } else { + here = client::lane_here(file, false)?; + here.as_str() + }; let c = client::main_client(file)?; let (status, text) = c.call_raw("POST", &format!("/v1/lanes/{lane}/stop"), None)?; if status >= 400 {