Files
vibe-kanban/crates/services/Cargo.toml
Louis Knight-Webb 7de87e9b3a Add QA mode for automated testing with mock executor and hardcoded repos (Vibe Kanban) (#1940)
* The QA mode implementation is complete. Here's a summary of what was implemented:

## Summary

I've successfully implemented the QA mode feature for the vibe-kanban application. Here's what was created/modified:

### New Files
1. **`crates/services/src/services/qa_repos.rs`** - QA repos module that:
   - Defines two hardcoded QA repo URLs (`internal-qa-1` and `internal-qa-2`)
   - Clones repos to a persistent temp directory on first access using `git2`
   - Returns `DirectoryEntry` compatible with existing API

2. **`crates/executors/src/executors/qa_mock.rs`** - Mock executor that:
   - Implements `StandardCodingAgentExecutor` trait
   - Performs random file operations (create, delete, modify)
   - Streams 10 mock log entries in ClaudeJson format over 10 seconds
   - Reuses Claude's log processor for normalization

### Modified Files
1. **Cargo.toml files** - Added `qa-mode` feature flags to:
   - `crates/executors/Cargo.toml`
   - `crates/services/Cargo.toml`
   - `crates/server/Cargo.toml`

2. **`crates/executors/src/executors/mod.rs`** - Added:
   - Conditional `qa_mock` module export
   - `QaMock` variant to `CodingAgent` enum
   - Updated `capabilities()` match arm

3. **`crates/executors/src/mcp_config.rs`** - Added `QaMock` handling

4. **`crates/services/src/services/filesystem.rs`** - Override `list_git_repos` and `list_common_git_repos` in QA mode

5. **`crates/services/src/services/container.rs`** - Override `normalize_logs` executor lookup in QA mode

6. **`crates/executors/src/actions/coding_agent_initial.rs`** - Override spawn in QA mode

7. **`crates/executors/src/actions/coding_agent_follow_up.rs`** - Override spawn in QA mode

8. **`vibe-kanban/package.json`** - Added QA build scripts:
   - `backend:dev:qa`
   - `backend:dev:watch:qa`
   - `dev:qa`

### Usage
```bash
# Run backend in QA mode
cargo run --features qa-mode

# Or with pnpm
pnpm run dev:qa
```

When QA mode is enabled:
- `GitPanelCreate` will show only `internal-qa-1` and `internal-qa-2` as recent repos
- Starting any task will perform mock file operations and stream 10 logs over 10 seconds
- Logs follow the ClaudeJson format for compatibility with the existing log processor

* Cleanup script changes for workspace 15499061-ec87-4c1c-81b9-994e84d0e75b

* The TLS error fix is complete. I've replaced the `git2::Repository::clone` call with the `git` CLI approach in `qa_repos.rs`:

**Changes made:**
- Updated `clone_qa_repos_if_needed` function to use `Command::new("git")` with `["clone", "--depth", "1", url, path]` arguments instead of `git2::Repository::clone`
- Added `--depth 1` for shallow cloning (faster)
- Updated error handling to capture stderr output from the git command

The fix uses the git CLI which has reliable TLS support, avoiding the TLS configuration issues that git2 can have on some systems. This matches patterns used elsewhere in the codebase (e.g., `crates/remote/src/github_app/service.rs`).

You can now run `pnpm run backend:dev:qa` or `pnpm run dev:qa` and the QA repos should clone successfully.

* Cleanup script changes for workspace 15499061-ec87-4c1c-81b9-994e84d0e75b

* Done! I've made the mock logs strongly typed by:

1. **Added imports** for `ClaudeJson`, `ClaudeMessage`, `ClaudeContentItem`, and `ClaudeToolData` from the Claude executor

2. **Replaced `generate_mock_logs()`** to use strongly-typed structs:
   - Each log entry is now a proper `ClaudeJson` enum variant
   - Uses `ClaudeMessage` with proper fields (`id`, `message_type`, `role`, `model`, `content`, `stop_reason`)
   - Uses `ClaudeContentItem` variants (`Thinking`, `ToolUse`, `ToolResult`, `Text`)
   - Uses `ClaudeToolData` variants (`Read`, `Write`, `Bash`)
   - Serializes to JSON using `serde_json::to_string()` for correct escaping

3. **Updated tests** to verify the logs deserialize back to `ClaudeJson` types

This ensures:
- All fields match what `ClaudeLogProcessor::process_logs()` expects
- No manual JSON escaping needed (serde handles it)
- Compile-time type checking prevents malformed logs
- Session IDs are consistent across all entries

* Cleanup script changes for workspace 15499061-ec87-4c1c-81b9-994e84d0e75b

* Done! I've fixed the log display issue by replacing the shell echo approach with a temp file approach:

**Changes made to `crates/executors/src/executors/qa_mock.rs`:**

1. **Write logs to a temp file** instead of embedding them in a shell script:
   - Creates a temp file at `$TMPDIR/qa_mock_logs_{uuid}.jsonl`
   - Writes all logs as newline-delimited JSON

2. **Use `IFS= read -r` to read the file** - this preserves exact content:
   - `IFS=` prevents word splitting
   - `-r` prevents backslash interpretation
   - `echo "$line"` outputs the exact line content

3. **Clean up the temp file** after reading with `rm -f`

**Benefits:**
- No shell escaping needed - file contents are read verbatim
- Each line is output exactly as serialized by serde_json
- Avoids issues with single quotes, backslashes, and escape sequences
- Temp file is automatically cleaned up after use

This should fix the issue where logs were appearing as raw JSON or with corrupted content due to shell escaping issues.

* fix formatting

* Build succeeds. I've applied the same fix to the two remaining locations that had newlines in their content:

1. **Line 234** - README tool result: Changed `\n\n` to `\\n\\n`
2. **Line 302** - Bash tool result: Changed `\n` to `\\n`

This matches the pattern the user established in the assistant final message (line 318) where `\\n` is used instead of `\n` to ensure newlines are properly preserved through the serialization and display pipeline.

* Cleanup script changes for workspace 15499061-ec87-4c1c-81b9-994e84d0e75b

* simplify scripts

* update agents.md
2026-01-11 15:39:07 +00:00

60 lines
1.5 KiB
TOML

[package]
name = "services"
version = "0.0.148"
edition = "2024"
[features]
default = []
cloud = []
qa-mode = ["executors/qa-mode"]
[dependencies]
utils = { path = "../utils" }
executors = { path = "../executors" }
db = { path = "../db" }
remote = { path = "../remote" }
tokio = { workspace = true }
tokio-util = { version = "0.7", features = ["io"] }
axum = { workspace = true }
serde = { workspace = true }
serde_json = { workspace = true }
url = "2.5"
anyhow = { workspace = true }
tracing = { workspace = true }
sqlx = { version = "0.8.6", features = ["runtime-tokio", "tls-rustls-aws-lc-rs", "sqlite", "sqlite-preupdate-hook", "chrono", "uuid"] }
chrono = { version = "0.4", features = ["serde"] }
uuid = { version = "1.0", features = ["v4", "serde"] }
ts-rs = { workspace = true }
dirs = "5.0"
git2 = { workspace = true }
tempfile = "3.21"
async-trait = { workspace = true }
enum_dispatch = "0.3.13"
rust-embed = "8.2"
ignore = "0.4"
regex = "1.11.1"
notify-rust = "4.11"
os_info = "3.12.0"
reqwest = { workspace = true }
futures-util = "0.3"
json-patch = "2.0"
backon = "1.5.1"
base64 = "0.22"
thiserror = { workspace = true }
futures = "0.3.31"
tokio-stream = "0.1.17"
strum_macros = "0.27.2"
strum = "0.27.2"
notify = "8.2.0"
notify-debouncer-full = "0.5.0"
dunce = "1.0"
dashmap = "6.1"
once_cell = "1.20"
sha2 = "0.10"
fst = "0.4"
secrecy = "0.10.3"
moka = { version = "0.12", features = ["future"] }
[target.'cfg(target_os = "macos")'.dependencies]
security-framework = "2"