Skip to content

Commit 4aa3443

Browse files
authored
Merge pull request #666 from cluesmith/spir/0602-vscode-extension
[Spec 0602][Phase 1] Shared types, monorepo restructure, approved spec + plan
2 parents a799a80 + 73448fa commit 4aa3443

File tree

102 files changed

+5544
-1088
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

102 files changed

+5544
-1088
lines changed

.gitignore

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,15 @@ codev/maintain/.trash/
2424
node_modules/
2525
packages/codev/dist/
2626
packages/codev/skeleton/
27-
packages/codev-vscode/dist/
28-
packages/codev-vscode/out/
27+
packages/types/dist/
28+
packages/vscode/dist/
29+
packages/vscode/out/
2930
*.tsbuildinfo
3031
test-results/
3132

32-
# Dashboard sub-package
33-
packages/codev/dashboard/package-lock.json
33+
# Dashboard build output (copied into codev for publishing)
34+
packages/codev/dashboard-dist/
35+
packages/dashboard/dist/
3436

3537
# Checklister runtime state (per-project JSON files)
3638
codev/checklists/*.json

.vscode/launch.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@
66
"type": "extensionHost",
77
"request": "launch",
88
"args": [
9-
"--extensionDevelopmentPath=${workspaceFolder}/packages/codev-vscode"
9+
"--extensionDevelopmentPath=${workspaceFolder}/packages/vscode"
1010
],
1111
"outFiles": [
12-
"${workspaceFolder}/packages/codev-vscode/dist/**/*.js"
12+
"${workspaceFolder}/packages/vscode/dist/**/*.js"
1313
],
1414
"preLaunchTask": "build-extension"
1515
}

.vscode/settings.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
{
22
"files.exclude": {
3-
"packages/codev-vscode/out": true,
4-
"packages/codev-vscode/dist": true,
3+
"packages/vscode/out": true,
4+
"packages/vscode/dist": true,
55
"packages/codev/dist": true
66
},
77
"search.exclude": {
8-
"packages/codev-vscode/out": true,
9-
"packages/codev-vscode/dist": true,
8+
"packages/vscode/out": true,
9+
"packages/vscode/dist": true,
1010
"packages/codev/dist": true
1111
},
1212
"typescript.tsc.autoDetect": "off"

.vscode/tasks.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"label": "build-extension",
66
"type": "npm",
77
"script": "compile",
8-
"path": "packages/codev-vscode",
8+
"path": "packages/vscode",
99
"group": "build",
1010
"problemMatcher": "$esbuild-watch"
1111
}

codev/plans/0602-vscode-extension.md

Lines changed: 748 additions & 0 deletions
Large diffs are not rendered by default.

codev/specs/0602-vscode-extension.md

Lines changed: 51 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
1+
---
2+
approved: 2026-04-06
3+
validated: [gemini, codex, claude]
4+
---
5+
16
# Specification: VS Code Extension for Codev Agent Farm
27

38
## Metadata
49
- **ID**: 0602
5-
- **Status**: draft
10+
- **Status**: approved
611
- **Created**: 2026-03-11
12+
- **Approved**: 2026-04-06
713
- **Protocol**: SPIR
814
- **Related**: Spec 0066
915

@@ -111,13 +117,17 @@ Users can use the browser dashboard, the VS Code extension, or both simultaneous
111117

112118
### Technical Constraints
113119

120+
**Why native Pseudoterminal, not xterm.js in a Webview:**
121+
Tower's WebSocket speaks a binary protocol (`0x00`/`0x01` framing). xterm.js handles this natively — it's what the browser dashboard uses. An alternative approach would embed xterm.js in a VS Code Webview, avoiding any protocol translation. However, Webview terminals have significant UX issues: keyboard shortcuts (Ctrl+C, arrows, paste) require custom passthrough, they can't appear in VS Code's native terminal panel or editor groups, they don't respect VS Code theming or focus management, and they feel like a browser embedded in an IDE. A native `Pseudoterminal` avoids all of this at the cost of a small binary adapter (~50 lines) that translates between Tower's binary protocol and VS Code's string-based API. This is a one-time implementation cost for a permanently better UX.
122+
114123
**VS Code Pseudoterminal API:**
115-
- `Pseudoterminal.onDidWrite` expects UTF-8 strings, not binary — requires translation from the `0x01` data frames
116-
- `Pseudoterminal.handleInput` provides strings — must encode to binary `0x01` frames for Tower
124+
- `Pseudoterminal.onDidWrite` expects UTF-8 strings, not binary — requires a binary protocol adapter to translate from `0x01` data frames
125+
- `Pseudoterminal.handleInput` provides strings — adapter encodes to binary `0x01` frames for Tower
117126
- `Pseudoterminal.setDimensions` maps to `0x00` control frames for PTY resize
118127
- No native stdout capture — but irrelevant since Tower/shellper handle observation
119128

120-
**WebSocket Binary Protocol Translation:**
129+
**Binary Protocol Adapter:**
130+
Translates between Tower's binary WebSocket protocol and VS Code's string-based Pseudoterminal API:
121131
- Incoming `0x01` frames: strip first byte, decode `Uint8Array` → UTF-8 string via `TextDecoder('utf-8', { stream: true })` (streaming mode required to handle multi-byte Unicode split across frames), fire to `onDidWrite`
122132
- Outgoing input: encode string → `Uint8Array`, prepend `0x01`, send over WebSocket
123133
- Control frames (`0x00`): handle resize, ping/pong, sequence numbers for replay
@@ -293,7 +303,7 @@ This mirrors the browser dashboard exactly: architect on the left, builders on t
293303
- Terminal scrollback is preserved via shellper — no data loss
294304

295305
**Escape sequence buffering:**
296-
WebSocket frames can split ANSI escape sequences mid-sequence (e.g., CSI, OSC, DCS). Writing a partial escape to `onDidWrite` corrupts terminal state (production Bugfix #630). The Pseudoterminal adapter must buffer incomplete trailing sequences and prepend them to the next frame — same logic as `dashboard/src/lib/escapeBuffer.ts`. This should be extracted into `@cluesmith/codev-api-client` as a shared utility.
306+
WebSocket frames can split ANSI escape sequences mid-sequence (e.g., CSI, OSC, DCS). Writing a partial escape to `onDidWrite` corrupts terminal state (production Bugfix #630). The Pseudoterminal adapter must buffer incomplete trailing sequences and prepend them to the next frame — same logic as `dashboard/src/lib/escapeBuffer.ts`. This should be extracted into `@cluesmith/codev-shared` as a shared utility.
297307

298308
**Resize deferral during replay:**
299309
On reconnect, the ring buffer replays potentially large scrollback. Sending a resize control frame (`0x00` with `type: 'resize'`) while replay data is being written causes garbled rendering (production Bugfix #625). The adapter must queue resize events and flush them only after the replay write completes.
@@ -491,7 +501,7 @@ Single Webview panel embedding the existing Recharts analytics page:
491501
Extract shared code to avoid triple-duplicating types and API client logic across server, dashboard, and extension. **Phased approach** — do not block V1 on extracting everything.
492502

493503
**Phase 1 (before V1)**: Extract `@cluesmith/codev-types` only. Low risk, high value.
494-
**Phase 2 (after V1 ships)**: Extract `@cluesmith/codev-api-client` once patterns stabilize across two real consumers (dashboard + extension).
504+
**Phase 2 (after V1 ships)**: Extract `@cluesmith/codev-shared` once patterns stabilize across two real consumers (dashboard + extension).
495505

496506
**Monorepo prerequisite**: Add a root `package.json` with `"workspaces": ["packages/*"]` before extracting. Currently no workspace manager exists. Without this, `file:` dependencies will break `vsce` packaging.
497507

@@ -506,9 +516,9 @@ Zero-dependency package with shared TypeScript interfaces currently duplicated b
506516

507517
Without this package, the extension becomes a third independent copy of these types, making protocol drift inevitable.
508518

509-
### `@cluesmith/codev-api-client` (Recommended, Phase 2 — after V1)
519+
### `@cluesmith/codev-shared` (Recommended, Phase 2 — after V1)
510520

511-
Environment-agnostic Tower API client shared between dashboard and extension:
521+
Shared runtime utilities and API client logic used by dashboard and extension:
512522

513523
- REST client with authenticated fetch (local-key header)
514524
- SSE client with reconnection logic and heartbeat handling
@@ -546,11 +556,13 @@ Environment-agnostic Tower API client shared between dashboard and extension:
546556

547557
## Default Keyboard Shortcuts
548558

559+
Chord bindings using `Cmd+K` (macOS) / `Ctrl+K` (Windows/Linux) as prefix — no conflicts with built-in VS Code shortcuts:
560+
549561
| Shortcut | Command |
550562
|----------|---------|
551-
| `Ctrl+Shift+A` / `Cmd+Shift+A` | Codev: Open Architect Terminal |
552-
| `Ctrl+Shift+M` / `Cmd+Shift+M` | Codev: Send Message |
553-
| `Ctrl+Shift+G` / `Cmd+Shift+G` | Codev: Approve Gate |
563+
| `Cmd+K, A` / `Ctrl+K, A` | Codev: Open Architect Terminal |
564+
| `Cmd+K, D` / `Ctrl+K, D` | Codev: Send Message |
565+
| `Cmd+K, G` / `Ctrl+K, G` | Codev: Approve Gate |
554566

555567
Additional commands available via Command Palette but without default keybindings to avoid conflicts.
556568

@@ -692,7 +704,7 @@ All errors surface through a consistent pattern:
692704
## Dependencies
693705
- **External Services**: None (localhost only)
694706
- **Internal Systems**: Tower server (existing), shellper (existing), all existing REST/WebSocket/SSE APIs
695-
- **Internal Packages (new)**: `@cluesmith/codev-types` (shared interfaces), `@cluesmith/codev-api-client` (shared Tower client)
707+
- **Internal Packages (new)**: `@cluesmith/codev-types` (shared interfaces), `@cluesmith/codev-shared` (shared runtime utilities + API client, post-V1)
696708
- **Libraries/Frameworks**: VS Code Extension API, `ws` (WebSocket client), `eventsource` (SSE client), React + Vite (analytics + team Webviews)
697709
- **Build**: `@vscode/vsce` for packaging and Marketplace publishing
698710

@@ -796,6 +808,28 @@ All findings incorporated into the relevant sections above.
796808
- [ ] Stakeholder Sign-off
797809
- [x] Expert AI Consultation Complete
798810

811+
## Extension Touch Points
812+
813+
Summary of all VS Code surfaces the extension introduces:
814+
815+
| Surface | What |
816+
|---------|------|
817+
| **Activity Bar** | Codev icon — opens the unified sidebar |
818+
| **Sidebar** | 7 collapsible TreeView sections (Needs Attention, Builders, PRs, Backlog, Recently Closed, Team, Status) |
819+
| **Editor Area (left group)** | Architect terminal (1 tab) |
820+
| **Editor Area (right group)** | Builder terminal tabs + shell tabs (N tabs) |
821+
| **Status Bar** | Builder count + blocked gate count, click to approve |
822+
| **Command Palette** | 15+ commands prefixed with `Codev:` |
823+
| **Keyboard Shortcuts** | 3 chord bindings (`Cmd+K, A/M/G`) |
824+
| **Context Menus** | Right-click actions on sidebar items |
825+
| **File Decorations** | Colored background + gutter icon on `REVIEW(...)` lines |
826+
| **Snippets** | `rev` + Tab inserts review comment |
827+
| **URI Handler** | `vscode://codev/open?file=...&line=...` for `afx open` |
828+
| **Terminal Link Provider** | Clickable file paths in terminal output |
829+
| **Settings** | 7 settings under `codev.*` in Settings UI |
830+
| **Output Channel** | `Codev` channel in Output panel for diagnostics |
831+
| **Webview Panel** (post-V1) | Analytics dashboard (Recharts) |
832+
799833
## Notes
800834

801835
**Why a new spec instead of amending 0066:**
@@ -929,13 +963,14 @@ This extension is additive. The browser dashboard continues to work. Both UIs co
929963
- Click the "+" gutter button → type a `REVIEW(@architect)` comment
930964
- Comment is written directly into the file
931965

932-
**VS Code:**
966+
**VS Code (V1):**
933967
- Open the file normally in your editor
934-
- Click the native "+" gutter icon (same as GitHub PR inline comments)
935-
- Type your review comment → it inserts `// REVIEW(@architect): text` into the file
968+
- Type `rev` + Tab → inserts `// REVIEW(@architect): ` with cursor positioned to type
969+
- Or `Cmd+Shift+P` → "Codev: Add Review Comment" → inserts at current line
970+
- Existing review comments highlighted with colored background + gutter icon
936971
- Same file format — interoperable with the browser dashboard
937972

938-
**Key difference:** Uses VS Code's native Comments API instead of a custom web UI. Feels like doing a PR review inline.
973+
**Key difference:** V1 uses snippet/command + visual decorations. Post-V1 adds the full Comments API with native gutter "+" buttons and threading.
939974

940975
### Team & Analytics
941976

0 commit comments

Comments
 (0)