vscode-cowriting-plugin
Non-shippable proof-of-concept (Feature #2 of Epic #1): a standalone VS Code
extension that drives @cline/sdk
— validating Approach A (own coauthoring extension on the Cline SDK, no fork).
What it does
Registers one command, Cowriting: Show Cline SDK Info, which loads
@cline/sdk and shows the SDK build version plus the agent's builtin tool
catalog (a pure, key-free SDK call) in a notification and the
"Cowriting (Cline SDK)" output channel.
Features shipped so far: F2 region-anchored threads (Feature #4), F3 live human/Claude attribution (Feature #6).
Architecture
- CommonJS extension bundled with esbuild (
src/extension.ts→out/extension.cjs). @cline/sdkis ESM-only (Node ≥22) and usescreateRequire(import.meta.url), so it is not bundled — it is shipped innode_modulesand loaded at runtime via dynamicimport()from the vscode-freesrc/cline.ts.
Run it (F5)
npm installnpm run build- Press F5 (or Run → "Run Extension") to launch the Extension Development Host.
It opens the committed
sandbox/playground as its workspace (not the repo itself — VS Code won't open one folder in two windows, #8); start withsandbox/playground.md. - In the new window: Cmd/Ctrl+Shift+P → "Cowriting: Show Cline SDK Info".
F2 — Region-anchored threads (Feature #4)
Attach durable, region-anchored discussion threads to any document. Threads
render in the native VS Code Comments gutter and persist as git-native
sidecars under .threads/<doc-path>.json (plain, diffable JSON — no server).
- Create: select text → run "Cowriting: Add Coauthoring Thread on Selection" (or the Comments gutter "+").
- Reply / Resolve: use the native Comments reply box and the thread's Resolve/Reopen actions.
- Survives edits, reload, and external change (
git pull): a hybrid anchor (durable content fingerprint + live offset tracking) re-resolves the thread. If the anchored text can't be confidently re-found, the thread is shown as orphaned at its last-known line — never silently moved.
Design: vscode-cowriting-plugin-content/specs/coauthoring-inner-loop.md. No live
@cline/sdk turn and no credentials are involved in F2.
F3 — Live human/Claude attribution (Feature #6)
As you and Claude coauthor, every span in the buffer carries an author: human edits render with a subtle left border, Claude-authored spans with a background tint. Text that predates tracking stays plain — the honest record. Edits that touch a boundary (split, merge, partial overwrite) are handled char-precisely.
Attribution is persisted git-natively in the same .threads/ sidecars
(attributions[], sharing the same anchors fingerprints as F2 threads). On
reload, fingerprints re-resolve spans against the current document; spans that
can't be confidently re-found are orphaned (status-bar count + "Cowriting
Attribution" output channel) rather than silently moved or discarded.
Commands
Cowriting: Ask Claude to Edit Selection— select text → enter an instruction → a live@cline/sdkturn runs on the built-inclaude-codeprovider (rides your local Claude Code Pro/Max login; the extension stores no credentials). The replacement lands in the buffer as a Claude-attributed span.Cowriting: Toggle Attribution— show/hide attribution decorations.cowriting.applyAgentEdit(palette-hidden) — the single machine-edit ingress seam. Tests drive this directly so CI requires no LLM.
Design: vscode-cowriting-plugin-content/specs/coauthoring-attribution.md.
Develop
npm run watch— rebuild on change.npx vitest run— unit suite (SDK driver, schema, store, anchorer, thread mutations, attribution split/merge).npm run test:e2e—@vscode/test-electronhost E2E (create → reply → resolve → persist → reload → re-anchor → orphan; drivescowriting.applyAgentEditdirectly — no LLM required).npm run smoke:live— scripted live-turn smoke test for F3; requires Claude Code installed and signed in. Seedocs/MANUAL-SMOKE-F3.md.npm run typecheck— type-check without emit.