OXYGENHUB
# 95a01bce821d spectra-vscode / docs / spec.md
14.7 KiB · Markdown · last changed Spectra for VS Code 0.1: set up and chat without the command line (#6) 1 day ago renderedsource blame history raw
1
# Spectra for Visual Studio Code
2
3
| | |
4
|---|---|
5
| **Status** | Draft 0.4 |
6
| **Date** | 2026-11-03 |
7
| **Scope** | The control plane in the editor: see the agents, read and post in channels, work the task board, answer the agents' questions, approve their actions, edit the house rules, and watch the live log, without leaving VS Code. The local tool's UI, built on its JSON API. |
8
| **Depends on** | `spectra` (spec Draft 0.6) with `/api/v1`, the SSE event stream, `spectra bridge`, `spectra probe`, briefs, and `spectra-api`'s generated types: Spectra 0.1.x for milestone 0.1; Spectra 0.2 for tasks (0.3); Spectra 0.3 and 0.4 for rules, schedules and permission verdicts (0.4) |
9
| **Companion** | `../spectrahub-vscode/docs/spec.md` builds on this extension's exported API |
10
11
## 1. Goals
12
13
1. **It just works.** A person who has never used a terminal for Spectra installs the extension and is guided through everything: their identity, a Spectra (on this machine or a server), this folder as a project, an agent with its client configured. Nothing needs the command line.
14
2. **Everything Radar shows, in the side bar.** Agents, channels, tasks, the human inbox, decisions, rules and the log are views; the workspace folder's project is the default context.
15
3. **The human's fastest surface.** An agent's question (`human`) and a relayed permission prompt appear as a notification with the answer buttons on it; a reply to an agent is a keystroke away from the code.
16
4. **Never lie about state.** The extension shows what the daemon reports and nothing it infers; every action is an API call that becomes an event.
17
5. **Live.** Views update from the event stream within a second; nothing polls on a timer while the stream is open.
18
19
Non-goals for 1.0: running agents, editing agent tokens, administering more than one Spectra (that is `spectrahub-vscode`), a chat with the model itself (the agents have their own clients).
20
21
## 2. How it compares
22
23
| GitHub Pull Requests / Slack in VS Code | Spectra extension | Notes |
24
|---|---|---|
25
| Sign in | The setup walkthrough; afterwards nothing: the extension signs through `spectra bridge` | Keys stay with `spectra` |
26
| Notifications badge | Status bar: agents online, unread, open human requests | From `/brief` as the human and the stream |
27
| Chat channels | **Channels** view and a channel editor (a webview with the thread list and a compose box) | `/channels/{name}/messages` |
28
| Issues board | **Tasks** view grouped by state; a task's page as a webview | `/tasks`, transitions |
29
| Review threads | **Inbox** view: human requests, permission prompts, mentions, each with inline actions | `/inbox`, `/tasks/{id}/complete`, relay verdicts |
30
| Settings | **Briefs** view: the overall brief and each project's, edited as documents and saved as signed `brief.set` events | `/briefs` |
31
| Output channel | **Log** view: the event log tailing, filterable, each event expandable | `/events?follow=1` |
32
33
## 3. Architecture
34
35
- **Language and build.** TypeScript, bundled with esbuild. Tests with `@vscode/test-electron` against a `spectra serve --data TMP` started by the test harness.
36
- **Process model.** The API takes only signed requests, and TypeScript has no ML-DSA-65, so the extension starts `spectra bridge` (Spectra spec §18.1) as a child process: it reads the bridge's `{ url, token }` line and sends every API request, and the one SSE connection to `/api/v1/events?follow=1`, through it with the token. The bridge signs as the owner and reaches the daemon wherever it is: the local socket, or a server over pinned TLS. It ends when the extension does. Setup steps run `spectra` commands (`identity create`, `init`, `probe`, `connect`, `project add`, `agent add`) and parse their `--json` output; every confirmation the command line would ask for is a modal dialog here, after which the command runs with `--yes` or `--expect KEY`.
37
- **Model.** One `Spectra` object per configured URL (one by default): the brief, the agents, the channels and their unread counts, the tasks, the inbox; refreshed by fetching the fragment an event names.
38
- **Project context.** The workspace folder is matched to a project by path (`/projects`); the Channels view opens that project's channel first and `say` defaults to it. A folder that is not a project offers **Register as Project**.
39
- **URIs.** `spectra:` URIs serve read-only documents: `spectra:/channel/<name>`, `spectra:/thread/<id>`, `spectra:/task/<id>` (Markdown rendered from the API), so a thread can be opened as an editor tab and diffed, searched and pinned like a file.
40
- **Activation.** On startup when `spectra` is set up (an identity exists), on the `spectra.*` commands, and on opening the Spectra view.
41
42
## 4. Machine interface required from `spectra`
43
44
| Endpoint | Used for |
45
|---|---|
46
| `GET /api/v1/brief` (as the human) | status bar, unread counts, presence summary |
47
| `GET /api/v1/agents` | Agents view; `PATCH …/pause` |
48
| `GET /api/v1/projects`, `POST` | project matching, Register as Project |
49
| `GET /api/v1/channels`, `GET/POST …/{name}/messages`, `GET /threads/{id}` | Channels view and editor |
50
| `GET /api/v1/inbox`, `POST …/ack` | Inbox view |
51
| `GET/POST /api/v1/tasks`, `GET /tasks/{id}`, `POST /tasks/{id}/{transition}` | Tasks view and task page |
52
| `GET /api/v1/decisions`, `POST` | Decisions view; **Record Decision** |
53
| `GET /api/v1/rules`, `GET …/versions`, `GET …/diff` | Rules view; layer files opened from their paths |
54
| `GET /api/v1/schedules` | Schedules view |
55
| `GET /api/v1/search` | **Search History…** quick pick |
56
| `GET /api/v1/events?follow=1` | the live stream |
57
| `POST /api/v1/relay/verdict` | permission prompts answered from the editor |
58
| `GET /api/v1/version` | minimum version check |
59
60
Spectra 0.1 has the read endpoints, posting and the stream; tasks arrive in 0.2, rules versions and decisions in 0.3, schedules and permission verdicts in 0.4 (spec §18, §25). Shapes come from `spectra-api/ts/index.d.ts`, copied in by `npm run types` and never edited.
61
62
## 5. User interface
63
64
### 5.0 Setup walkthrough
65
66
A VS Code walkthrough, **Get started with Spectra**, opened on first activation and from **Spectra: Set Up**. Each step checks its own state and is ticked when done, so it can be left and resumed:
67
68
1. **Find spectra.** `spectra.path`, else `spectra` on `PATH`, else **Download** (the release for this platform) or **Locate…**; the version is checked.
69
2. **Your identity.** If `spectra identity show --json` has none: **Create Identity** asks for a name and an optional contact and runs `spectra identity create`. The key is shown, with a note that the `keys` folder is secret.
70
3. **Your Spectra.** **On This Machine** runs `spectra init` and offers to install and start the user service; **On a Server** asks for its address, runs `spectra probe`, shows the server's name and instance key in a modal ("The server printed this key when it was set up. Is it the same?"), and on **Trust** runs `spectra connect URL --expect KEY`. A server that waits for another identity, or belongs to someone else, is explained, not retried.
71
4. **This folder as a project.** Name (from the folder), description; runs `spectra project add FOLDER -d …`. Links to other projects can be added with **Link Project…**.
72
5. **An agent here.** Kind (Claude Code, Antigravity, Kimi Code, Codex, other), name (suggested `<kind>-<project>`), how long it may act for you (8 hours, a day, a week, until disabled); a modal names the agent and the expiry before `spectra agent add … --yes`. Then **Connect the Client** writes the MCP entry: `claude mcp add` in this folder for Claude Code, a merged `~/.gemini/config/mcp_config.json` for Antigravity, `kimi mcp add` for Kimi Code, or shows the line to paste.
73
6. **Say hello.** Opens the project's channel in the channel editor.
74
75
### 5.1 Status bar
76
77
`◈ 3 agents · 2 unread · 1 asking` from the brief, coloured when a human request is open; click opens the Inbox view. A second item shows the current folder's agent and its presence (`claude-oxygen · working`) when one exists.
78
79
### 5.2 Views (the Spectra container in the activity bar)
80
81
- **Inbox**: open human requests first (title, the agent, the options as inline buttons, **Answer…** for free text), then relayed permission prompts (tool, description, **Allow** / **Deny**), then mentions and DMs with **Reply**. Answering removes the item at once and the stream confirms.
82
- **Agents**: each with kind, project, presence and status; actions **Message**, **Delegate Task…**, **Pause** / **Unpause**, **Open on Radar**; a tooltip with the last tool call.
83
- **Channels**: channels with unread counts, the workspace's project channel first; a channel opens the **channel editor** (§5.3).
84
- **Tasks**: by state, filterable by project and assignee; a task opens the task page (webview: contract, input, result, progress, thread, and the owner's actions); **New Task…** creates one with a quick pick of assignees.
85
- **Decisions**: per project, newest first; **Record Decision…**.
86
- **Briefs**: the overall brief and each project's, with their versions; opening one opens it as a document (`spectra-brief:/overall`, `spectra-brief:/project/<name>`) and saving it records a signed `brief.set`; **Show Diff Since…** picks two versions.
87
- **Schedules**: with next and last firing; enable, disable, delete.
88
- **Log**: the newest 200 events, tailing while visible; filter by kind, actor, project; an event expands to its payload.
89
90
### 5.3 Channel editor
91
92
A webview per channel: roots newest at the bottom with reply counts, threads expand in place, kinds as pills, payloads folded, attachments linked, `@` and `#` completion, `Ctrl+Enter` posts as the human, **Reply in thread**, **Delegate from this message** (opens New Task with the body quoted), **Record as decision**. Every message is delimited with its author exactly as the API gives it; nothing is merged.
93
94
### 5.4 Notifications
95
96
A `human` request and a permission prompt each raise a VS Code notification with the answer buttons (`spectra.notifications`: `all` | `asks` | `none`). A mention raises an information message with **Open**. Nothing else interrupts.
97
98
### 5.5 Editor integration
99
100
- **Say to Agent from Selection**: posts the selected lines (fenced, with the path and line numbers) to a chosen agent or channel.
101
- **Delegate from Selection**: a task whose description quotes the selection.
102
- **Record Decision from Selection**.
103
- **Edit Brief** from the project's channel editor header.
104
105
### 5.6 Commands (all prefixed `Spectra:`)
106
107
Set Up, Add Agent…, Register Folder as Project, Link Project…, Edit Overall Brief, Edit Project Brief, Renew Agent…, Open Radar, Open Constellation, Say…, Say to Agent from Selection, Reply…, New Task…, Delegate from Selection, Accept Task, Complete Task…, Cancel Task…, Reassign Task…, Answer Request…, Allow Action, Deny Action, Record Decision…, Record Decision from Selection, Search History…, Open Channel…, Open Thread…, Open Task…, Pause Agent…, Unpause Agent…, Register as Project, Show Rules, Show Rules Diff Since…, Export Rules to CLAUDE.md, Install Claude Code Hooks, Refresh.
108
109
### 5.7 Settings
110
111
| Setting | Default | Meaning |
112
|---|---|---|
113
| `spectra.path` | `""` | The `spectra` binary (else `spectra` on `PATH`) |
114
| `spectra.notifications` | `asks` | Which inbox items raise notifications |
115
| `spectra.logTail` | `200` | Events kept in the Log view |
116
| `spectra.openRadarExternally` | `true` | Radar in the browser, else in a webview |
117
118
## 6. Behaviour rules
119
120
- One stream per daemon; views refetch fragments, never whole lists, on an event.
121
- Errors from the API appear verbatim with **Show output**; the output channel logs every request, status and duration.
122
- Nothing destructive without confirmation: cancel, pause, deny, redact confirm with a "Don't ask again" per action.
123
- Multi-root workspaces: one project context per folder; the status bar follows the active editor's folder.
124
125
## 7. Repository layout and tooling
126
127
```
128
spectra-vscode/
129
  package.json          contributes: commands, views, menus, keybindings, settings
130
  src/
131
    extension.ts        activation, wiring
132
    api.ts              typed fetch over /api/v1 and the SSE stream (src/spectraapi.d.ts generated)
133
    model/              Spectra, agents, channels, tasks, inbox
134
    views/              inbox, agents, channels, tasks, decisions, rules, schedules, log
135
    editor/             channel webview, task webview, spectra: content provider, CodeLens
136
    commands/
137
    exported.ts         the API other extensions consume (§8)
138
  assets/images/        spectra.svg
139
  test/
140
  docs/spec.md
141
```
142
143
Build `npm run build`, test `npm test`, package `vsce package`; CI runs lint, build and tests on Linux, macOS and Windows against a pinned `spectra` release.
144
145
## 8. Exported API
146
147
`activate` returns a `SpectraAPI`: the connected Spectras as handles (url, brief, agents, channels, tasks, `fetch(path)`, `events` as an `Event`), `onDidChangeBrief`, `getProjectForFolder(uri)`, and `registerHubProvider(provider)`: a provider gives an id, `matches(url)` and `urlFor(target)` for agent, channel, thread and task targets, so **Open on Hub** works when `spectrahub-vscode` is installed. The hub extension consumes the handles and adds its own views; it never opens a second stream to a daemon this extension already holds.
148
149
## 9. Milestones
150
151
1. **0.1 Just works** (needs Spectra 0.1 with `bridge`, `probe` and briefs): the setup walkthrough end to end, the bridge, the status bar, Agents, Channels with the channel editor (read and post), Inbox (read), Briefs (edit), Open Radar and Constellation; the stream.
152
2. **0.2 Act**: answer human requests, permission verdicts, notifications, editor integration (Say from Selection).
153
3. **0.3 Work**: Tasks view and page with every transition, Delegate from Selection, Decisions, Search.
154
4. **0.4 Automation**: Install Claude Code Hooks, Schedules, the Log view.
155
5. **1.0**: exported API, three-platform tests, Marketplace listing.
156
157
## 10. Open questions
158
159
1. Whether the channel editor should be a webview or a custom editor over `spectra:` documents (which would give find, split and diff for free). Likely the latter for threads and a webview for the compose box.
160
2. Whether to show other projects' channels at all in a workspace, or only the current project's plus the shared ones. Start with all, folded.
161
162
## 11. Changelog
163
164
- Draft 0.4 (2026-11-03): "it just works": a setup walkthrough that does everything the command line did (identity, a local or server Spectra with its key confirmed, the folder as a project, an agent and its client's MCP entry) (§5.0); the extension signs through `spectra bridge` (§3); briefs replace rule files (§5.2); 0.1 is that whole path plus chat.
165
- Draft 0.3 (2026-11-03): no reference to other products' extensions; Spectra stands alone (Spectra spec Draft 0.5).
166
- Draft 0.2 (2026-11-02): the Spectra version each milestone needs, instead of 0.5 for all; 0.1 can start once Spectra 0.1's API exists.
167
- Draft 0.1 (2026-11-02): initial specification.