Files
vibe-kanban/AGENTS.md
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

2.8 KiB

Repository Guidelines

Project Structure & Module Organization

  • crates/: Rust workspace crates — server (API + bins), db (SQLx models/migrations), executors, services, utils, deployment, local-deployment, remote.
  • frontend/: React + TypeScript app (Vite, Tailwind). Source in frontend/src.
  • frontend/src/components/dialogs: Dialog components for the frontend.
  • remote-frontend/: Remote deployment frontend.
  • shared/: Generated TypeScript types (shared/types.ts). Do not edit directly.
  • assets/, dev_assets_seed/, dev_assets/: Packaged and local dev assets.
  • npx-cli/: Files published to the npm CLI package.
  • scripts/: Dev helpers (ports, DB preparation).
  • docs/: Documentation files.

Managing Shared Types Between Rust and TypeScript

ts-rs allows you to derive TypeScript types from Rust structs/enums. By annotating your Rust types with #[derive(TS)] and related macros, ts-rs will generate .ts declaration files for those types. When making changes to the types, you can regenerate them using pnpm run generate-types Do not manually edit shared/types.ts, instead edit crates/server/src/bin/generate_types.rs

Build, Test, and Development Commands

  • Install: pnpm i
  • Run dev (frontend + backend with ports auto-assigned): pnpm run dev
  • Backend (watch): pnpm run backend:dev:watch
  • Frontend (dev): pnpm run frontend:dev
  • Type checks: pnpm run check (frontend) and pnpm run backend:check (Rust cargo check)
  • Rust tests: cargo test --workspace
  • Generate TS types from Rust: pnpm run generate-types (or generate-types:check in CI)
  • Prepare SQLx (offline): pnpm run prepare-db
  • Prepare SQLx (remote package, postgres): pnpm run remote:prepare-db
  • Local NPX build: pnpm run build:npx then pnpm pack in npx-cli/

Automated QA

  • When testing changes by runnign the application, you should prefer pnpm run dev:qa over pnpm run dev, which starts the application in a dedicated mode that is optimised for QA testing

Coding Style & Naming Conventions

  • Rust: rustfmt enforced (rustfmt.toml); group imports by crate; snake_case modules, PascalCase types.
  • TypeScript/React: ESLint + Prettier (2 spaces, single quotes, 80 cols). PascalCase components, camelCase vars/functions, kebab-case file names where practical.
  • Keep functions small, add Debug/Serialize/Deserialize where useful.

Testing Guidelines

  • Rust: prefer unit tests alongside code (#[cfg(test)]), run cargo test --workspace. Add tests for new logic and edge cases.
  • Frontend: ensure pnpm run check and pnpm run lint pass. If adding runtime logic, include lightweight tests (e.g., Vitest) in the same directory.

Security & Config Tips

  • Use .env for local overrides; never commit secrets. Key envs: FRONTEND_PORT, BACKEND_PORT, HOST
  • Dev ports and assets are managed by scripts/setup-dev-environment.js.