Skip to content

Commit 41e5376

Browse files
authored
Merge pull request #5987 from Hmbown/pr/vscode-send-path
fix(vscode): make the extension's send path work, and close the security holes
2 parents 705b385 + dc6d8d5 commit 41e5376

23 files changed

Lines changed: 3704 additions & 371 deletions

.github/workflows/ci.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,31 @@ jobs:
252252
# platform backends, and the MCP stdio protocol. No GUI input runs.
253253
run: (cd crates/tui/plugins/computer-use && npm test)
254254

255+
vscode-extension:
256+
name: VS Code extension
257+
timeout-minutes: 15
258+
runs-on: ubuntu-latest
259+
defaults:
260+
run:
261+
working-directory: extensions/vscode
262+
steps:
263+
- uses: actions/checkout@v7
264+
- uses: actions/setup-node@v7
265+
with:
266+
# The extension targets VS Code >=1.90, whose extension host is
267+
# Node 20, and its @types/node pin is ^20. Build and test on the
268+
# runtime the extension actually ships against.
269+
node-version: 20
270+
- name: Install extension dependencies
271+
run: npm ci
272+
- name: Run VS Code extension suites
273+
# extensions/vscode ships node --test suites (api, markdown, sse) that
274+
# NO workflow ran: release.yml only reads package.json for a version
275+
# string, so the whole client compiled and shipped without its tests or
276+
# `tsc` ever running in CI. `npm test` compiles first (tsc -p ./), so
277+
# this is the type-check gate for the extension too.
278+
run: npm test
279+
255280
safety-gate:
256281
name: Safety gate
257282
needs: changes

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ codewhale-inference/
2222
!.env.example
2323
node_modules/
2424
.vscode/
25+
# The extension ships its own dev-loop config (F5 Extension Development Host).
26+
# Without this negation the bare `.vscode/` above swallows it silently.
27+
!/extensions/vscode/.vscode/
2528
.idea/
2629
*.swp
2730
*.swo
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{
2+
"version": "0.2.0",
3+
"configurations": [
4+
{
5+
"name": "Run Extension",
6+
"type": "extensionHost",
7+
"request": "launch",
8+
"args": ["--extensionDevelopmentPath=${workspaceFolder}"],
9+
"outFiles": ["${workspaceFolder}/out/**/*.js"],
10+
"preLaunchTask": "watch"
11+
},
12+
{
13+
"name": "Extension Tests",
14+
"type": "node",
15+
"request": "launch",
16+
"runtimeArgs": ["--test", "out/test"],
17+
"cwd": "${workspaceFolder}",
18+
"outFiles": ["${workspaceFolder}/out/**/*.js"],
19+
"console": "integratedTerminal",
20+
"internalConsoleOptions": "neverOpen",
21+
"preLaunchTask": "compile"
22+
}
23+
]
24+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{
2+
"version": "2.0.0",
3+
"tasks": [
4+
{
5+
"label": "watch",
6+
"detail": "tsc -p ./ --watch — background compile for the Run Extension launch config",
7+
"type": "shell",
8+
"command": "npx tsc -p ./ --watch",
9+
"options": { "cwd": "${workspaceFolder}" },
10+
"isBackground": true,
11+
"problemMatcher": "$tsc-watch",
12+
"presentation": { "reveal": "never", "panel": "dedicated" },
13+
"group": { "kind": "build", "isDefault": true }
14+
},
15+
{
16+
"label": "compile",
17+
"detail": "tsc -p ./ — one-shot build into out/",
18+
"type": "shell",
19+
"command": "npx tsc -p ./",
20+
"options": { "cwd": "${workspaceFolder}" },
21+
"problemMatcher": "$tsc",
22+
"presentation": { "reveal": "silent", "panel": "dedicated" },
23+
"group": "build"
24+
}
25+
]
26+
}

extensions/vscode/.vscodeignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
src/**
2+
node_modules/**
3+
out/test/**
4+
*.vsix
5+
tsconfig.json
6+
package-lock.json

extensions/vscode/README.md

Lines changed: 54 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,68 @@
11
# CodeWhale for VS Code
22

3-
Official Codewhale extension scaffold for local development.
3+
Official Codewhale extension: an agentic chat sidebar over the local Engine
4+
Runtime API, with editor context, streaming turns, approvals, and terminal
5+
parity.
46

5-
This first slice is intentionally small:
7+
## What it does
68

7-
- open Codewhale in an integrated terminal
8-
- start `codewhale serve --http` in a visible terminal
9-
- check a local runtime through `/health` and `/v1/runtime/info`
10-
- show connection state in the status bar
11-
- show a read-only Agent View with recent runtime thread summaries from
12-
`/v1/threads/summary`
13-
- show recent read-only restore points from `/v1/snapshots`
14-
- refresh the read-only Agent View automatically so branch/workspace metadata
15-
catches up while agents are working
9+
**Chat sidebar** (primary view):
1610

17-
It does not expose the full chat webview, VS Code Agent View chat/editor
18-
integration, inline edit application, marketplace publish workflow, or
19-
retry/undo/snapshot GUI endpoints yet.
11+
- create, switch, and resume Codewhale threads; every thread stays available
12+
from the terminal and the embedded browser client
13+
- stream turns live over the runtime's replayable SSE contract
14+
(`GET /v1/threads/{id}/events?since_seq=…`) with automatic reconnection
15+
- attach editor context as chips before sending: current selection,
16+
active file, or Problems-panel diagnostics
17+
- resolve tool approvals (allow / deny / remember) and clarification
18+
questions inline, hydrated from the thread-detail snapshot so a reload
19+
never strands pending work
20+
- steer a running turn or stop it
21+
- render agent replies as a safe Markdown subset; every code block gets
22+
Copy and Insert-at-cursor actions
23+
- open changed files from `file_change` items when the runtime includes a path
2024

21-
## Local Use
25+
**Runtime view** (secondary): connection state, recent thread summaries,
26+
restore points, and the original terminal launch helpers.
27+
28+
**Connection**: the extension attaches to `codewhale serve --http` on
29+
`127.0.0.1:7878` by default, starts it in a visible terminal on request, and
30+
never runs its own agent engine — the runtime is the single turn/event owner.
31+
32+
## Security posture
33+
34+
- Runtime bearer tokens are stored in VS Code SecretStorage via
35+
**CodeWhale: Set Runtime Token**; the legacy `codewhale.runtimeToken`
36+
setting still works and is migrated into secret storage on first use.
37+
- The webview renders with a strict CSP (`default-src 'none'`), and all
38+
model output is HTML-escaped before any Markdown transform runs; links
39+
must be http(s).
40+
- The chat webview script is a static string — no runtime data is
41+
interpolated into it.
42+
43+
## Local use
2244

2345
```bash
2446
npm install
25-
npm run compile
26-
npm run package
27-
code --install-extension codewhale-vscode-0.9.11.vsix
47+
npm test # compile + unit tests
48+
npm run package # -> codewhale-vscode-<version>.vsix
49+
code --install-extension codewhale-vscode-<version>.vsix
2850
```
2951

30-
Configure `codewhale.commandPath`, `codewhale.runtimeHost`,
31-
`codewhale.runtimePort`, `codewhale.runtimeToken`, and
32-
`codewhale.agentViewRefreshIntervalSeconds` from VS Code settings.
33-
Set the refresh interval to `0` to disable automatic read-only refreshes.
52+
Settings: `codewhale.commandPath`, `codewhale.runtimeHost`,
53+
`codewhale.runtimePort`, `codewhale.agentViewRefreshIntervalSeconds`
54+
(`0` disables automatic refresh). Commands: **CodeWhale: Ask Codewhale**
55+
(`ctrl+alt+c` from the editor, also on the editor context menu),
56+
**CodeWhale: New Chat**, **CodeWhale: Set Runtime Token**,
57+
**CodeWhale: Start Local Runtime**.
3458

3559
Keep the runtime on `127.0.0.1` unless you deliberately front it with trusted
3660
local networking controls.
61+
62+
## Not yet built
63+
64+
VS Code-native diff/merge review of agent file changes (blocked on the
65+
runtime publishing a Files/Changes contract), provider/model switching from
66+
the composer, retry/undo/restore buttons, and account sign-in surface. The
67+
runtime's embedded browser client (`codewhale web`) remains the full-feature
68+
fallback for those flows.
Lines changed: 10 additions & 8 deletions
Loading

extensions/vscode/media/icon.png

-23 KB
Loading

0 commit comments

Comments
 (0)