Resolve bd.exe location from PATH and configuration fallback

Executable resolution contract.

Resolution order:
1) explicit configured executable path (request/config)
2) PATH scan for bd.exe, bd.cmd, bd.bat, bd

Failure behavior:
- Throw actionable guidance when missing, including install command:
  npm install -g @beads/bd
- Error message explicitly mentions explicit path when provided but invalid.

Verification:
- tests/lib/bd-path.test.ts validates config-first behavior, PATH lookup, and missing executable guidance.

Acceptance contract:
- Resolver is deterministic for config and PATH inputs.
- Missing executable guidance is actionable and user-readable.

Implemented src/lib/bd-path.ts executable resolution with config-first then PATH lookup (bd.exe/bd.cmd/bd.bat/bd), plus actionable setup guidance when missing. Added tests/lib/bd-path.test.ts for success/failure cases.

Executable resolution implemented with config/PATH fallback and actionable missing-bd guidance; tests added.


Implement mutation API for create/update/close/reopen/comment operations

Mutation API contract and mapping.

Supported operations:
- create, update, close, reopen, comment

Validation:
- Payload shape validation enforces required fields and basic constraints.
- update requires at least one mutable field.
- status values are constrained to board-supported statuses.

Command mapping:
- create -> bd create <title> [flags] --json
- update -> bd update <id> [flags] --json
- close  -> bd close <id> [-r reason] --json
- reopen -> bd reopen <id> [-r reason] --json
- comment -> bd comments add <id> <text> --json

Response shape:
- { ok, operation, command, error? }
- command field always includes normalized bridge result.

Verification:
- tests/lib/mutations.test.ts and tests/api/mutations-routes.test.ts
- Runtime smoke lifecycle executed across create/update/close/reopen/comment.

Acceptance contract:
- Every mutation route maps to bd.exe only.
- Invalid payloads return explicit bad_args responses.
- Reopen and comment operations are first-class and tested.

Implemented mutation validation/mapping/execution layer in src/lib/mutations.ts and App Router endpoints: /api/beads/create|update|close|reopen|comment. Added payload validation tests, route validation tests, and smoke-tested create/update/comment/close/reopen lifecycle via API.

Mutation API implemented for create/update/close/reopen/comment with payload validation, command mapping, normalized error shape, and verified smoke lifecycle via API.


Add optimistic updates with rollback and SSE reconciliation

Optimistic writeback behavior.

Frontend mutation strategy:
- Apply optimistic status update to local issue state.
- Mark issue as pending during command execution.
- On failure: rollback to previous issue snapshot and surface mutation error.
- On success: fetch authoritative issue list from /api/beads/read and replace local state.

Rationale:
- Preserves responsive UX without violating source-of-truth boundary.
- Reconciliation avoids stale local drift when external agents mutate files.

Verification:
- tests/lib/writeback.test.ts for transition planning and optimistic updater helpers.
- Runtime mutation smoke tests confirm end-to-end lifecycle.

Acceptance contract:
- Failed mutation restores prior local state.
- Successful mutation reconciles to authoritative read response.
- Pending state prevents repeated conflicting transitions.

Implemented optimistic status updates with rollback in Kanban page, per-issue pending state, and authoritative reconciliation via new GET /api/beads/read endpoint after successful mutations.

Optimistic board updates with rollback and authoritative post-mutation reconciliation via read route implemented and validated.


Implement drag-and-drop status transitions mapped to bd commands

Kanban drag-and-drop transition semantics.

Transition planner rules:
- Any -> closed: use close command.
- closed -> open: use reopen command.
- closed -> in_progress|blocked|deferred: reopen then update target status.
- open|in_progress|blocked|deferred between non-closed states: update status.

UI behavior:
- Drag start attaches issue id/status metadata.
- Drop lane executes planned mutation steps in order.
- Lane card pending state is shown while mutation is in flight.

Verification:
- tests/lib/writeback.test.ts transition planning cases.
- Runtime smoke checks for close/reopen/update transition chain.

Acceptance contract:
- DnD invokes valid bd command sequence for each source->target status.
- Invalid/no-op transitions do not emit unnecessary commands.
- Pending safeguards prevent duplicate conflicting moves.

Implemented lane drag-and-drop interactions in Kanban board, status transition planning (including closed -> reopen+update), and mapped transitions to bd mutation API routes with pending-state safeguards.

Kanban lane drag-and-drop transitions now map to bd-backed close/reopen/update mutations with transition planner tests and runtime smoke validation.