Files
vibe-kanban/crates/executors
Louis Knight-Webb a369cec373 Inject ENV vars into shell (vibe-kanban) (#1426)
* The implementation is complete. Here's a summary of what was done:

I've implemented environment variable injection when launching coding agents. The following environment variables are now injected into the shell when an executor is spawned:

- `VK_PROJECT_NAME` - Name of the project
- `VK_TASK_ID` - UUID of the task
- `VK_ATTEMPT_ID` - UUID of the task attempt
- `VK_ATTEMPT_BRANCH` - Branch name for the attempt (e.g., `vk/branch-name`)

1. **Created `crates/executors/src/env.rs`** - New module containing `ExecutionEnv` struct with:
   - `HashMap<String, String>` to store env vars
   - `insert()` method to add env vars
   - `apply_to_command()` method to apply env vars to a `tokio::process::Command`

2. **Updated `crates/executors/src/actions/mod.rs`** - Modified `Executable` trait to accept `Option<&ExecutionEnv>` parameter

3. **Updated `crates/executors/src/executors/mod.rs`** - Modified `StandardCodingAgentExecutor` trait's `spawn()` and `spawn_follow_up()` to accept `Option<&ExecutionEnv>` parameter

4. **Updated all action implementations**:
   - `coding_agent_initial.rs` - forwards env to agent spawn
   - `coding_agent_follow_up.rs` - forwards env to agent spawn
   - `script.rs` - applies env vars to script commands

5. **Updated all executor implementations** to apply env vars:
   - `claude.rs`, `amp.rs`, `gemini.rs`, `codex.rs`, `qwen.rs`, `droid.rs`, `cursor.rs`, `copilot.rs`, `opencode.rs`
   - Also updated `acp/harness.rs` which is used by gemini and qwen

6. **Updated `crates/local-deployment/src/container.rs`** - Modified `start_execution_inner()` to:
   - Load task and project context from database
   - Create `ExecutionEnv` with the four `VK_*` variables
   - Pass the env to `executor_action.spawn()`

* Cleanup script changes for task attempt 4dc9b26c-c637-465a-ae71-644c828ea8f7

* The refactoring is complete. I've successfully updated the `env` parameter from `Option<&ExecutionEnv>` to `&ExecutionEnv` across all relevant files:

**Summary of changes:**

1. **Trait updates:**
   - `Executable` trait in `crates/executors/src/actions/mod.rs`
   - `StandardCodingAgentExecutor` trait in `crates/executors/src/executors/mod.rs`

2. **Action implementations:**
   - `coding_agent_initial.rs`
   - `coding_agent_follow_up.rs`
   - `script.rs`

3. **Executor implementations (all 10 executors):**
   - `claude.rs` - spawn, spawn_follow_up, spawn_internal
   - `amp.rs` - spawn, spawn_follow_up
   - `gemini.rs` - spawn, spawn_follow_up
   - `codex.rs` - spawn, spawn_follow_up, spawn_inner
   - `qwen.rs` - spawn, spawn_follow_up
   - `droid.rs` - spawn, spawn_follow_up, spawn_droid helper
   - `cursor.rs` - spawn, spawn_follow_up
   - `copilot.rs` - spawn, spawn_follow_up
   - `opencode.rs` - spawn, spawn_follow_up
   - `acp/harness.rs` - spawn_with_command, spawn_follow_up_with_command

4. **Call site:**
   - `container.rs` in `start_execution_inner` - changed `Some(&env)` to `&env`

All tests pass (137 tests) and clippy reports no warnings.

* All tests pass. The change is complete.

**Summary**: Added `VK_PROJECT_ID` to the environment variables injected when launching coding agents.

The environment variables now include:
- `VK_PROJECT_NAME` - project name
- `VK_PROJECT_ID` - project UUID (newly added)
- `VK_TASK_ID` - task UUID
- `VK_ATTEMPT_ID` - attempt UUID
- `VK_ATTEMPT_BRANCH` - git branch name for the attempt

* undo ts-rs bindings

* All 147 tests pass. The rebase conflict has been resolved successfully.

**Summary:**
- Resolved the rebase conflict in `crates/local-deployment/src/container.rs`
- The conflict was in the imports section where:
  - `origin/main` added `InterruptSender` to the executors import
  - Our branch added `env::ExecutionEnv` import
- Resolution: Combined both changes to keep `ExecutionEnv` import AND `InterruptSender`
- All tests pass (147 tests)

The branch `vk/4dc9-inject-env-vars` is now rebased onto `origin/main` with the complete environment variable injection feature, including:
- `VK_PROJECT_NAME`
- `VK_PROJECT_ID`
- `VK_TASK_ID`
- `VK_ATTEMPT_ID`
- `VK_ATTEMPT_BRANCH`

* remove bindings (again)
2025-12-04 15:55:55 +00:00
..
2025-12-03 13:11:58 +00:00
2025-10-03 16:00:15 +01:00
2025-11-20 16:38:28 +00:00