@lysyi3m/sidecar 0.0.0-stage → 1.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +285 -2
- package/dist/bin/sidecar-dashboard.js +27 -0
- package/dist/bin/sidecar-mcp.js +35 -0
- package/dist/bin/sidecar.js +70 -0
- package/dist/src/adapters/claude-code.js +333 -0
- package/dist/src/adapters/claude-desktop.js +184 -0
- package/dist/src/adapters/codex.js +383 -0
- package/dist/src/adapters/index.js +38 -0
- package/dist/src/adapters/installed.js +25 -0
- package/dist/src/adapters/outcome.js +30 -0
- package/dist/src/adapters/registration.js +69 -0
- package/dist/src/adapters/types.js +1 -0
- package/dist/src/cases/events.js +9 -0
- package/dist/src/cases/items.js +120 -0
- package/dist/src/cases/lock.js +80 -0
- package/dist/src/cases/opinion.js +58 -0
- package/dist/src/cases/state.js +121 -0
- package/dist/src/cases/store.js +181 -0
- package/dist/src/cases/usage.js +36 -0
- package/dist/src/cli/deps.js +18 -0
- package/dist/src/cli/lines.js +11 -0
- package/dist/src/cli/list.js +44 -0
- package/dist/src/cli/setup.js +202 -0
- package/dist/src/cli/status.js +111 -0
- package/dist/src/cli/style.js +26 -0
- package/dist/src/cli/ui.js +170 -0
- package/dist/src/cli/uninstall.js +73 -0
- package/dist/src/config.js +108 -0
- package/dist/src/dashboard/cases.js +109 -0
- package/dist/src/dashboard/html.js +31 -0
- package/dist/src/dashboard/links.js +35 -0
- package/dist/src/dashboard/marks.js +16 -0
- package/dist/src/dashboard/pages.js +516 -0
- package/dist/src/dashboard/server.js +305 -0
- package/dist/src/dashboard/service.js +138 -0
- package/dist/src/dashboard/static/agents/NOTICE +32 -0
- package/dist/src/dashboard/static/agents/claude-code.svg +1 -0
- package/dist/src/dashboard/static/agents/claude-desktop.svg +1 -0
- package/dist/src/dashboard/static/agents/codex.svg +1 -0
- package/dist/src/dashboard/static/app.css +1121 -0
- package/dist/src/dashboard/static/app.js +256 -0
- package/dist/src/dashboard/static/times.js +44 -0
- package/dist/src/dashboard/view.js +25 -0
- package/dist/src/lib/agent-process.js +57 -0
- package/dist/src/lib/atomic-write.js +35 -0
- package/dist/src/lib/command.js +20 -0
- package/dist/src/lib/failpoint.js +14 -0
- package/dist/src/lib/git.js +14 -0
- package/dist/src/lib/json.js +2 -0
- package/dist/src/lib/paths.js +19 -0
- package/dist/src/lib/proc.js +80 -0
- package/dist/src/lib/version.js +43 -0
- package/dist/src/mcp/server.js +800 -0
- package/dist/src/mcp/stdio.js +31 -0
- package/dist/src/mcp/tools.js +180 -0
- package/dist/src/turns/dispatch.js +188 -0
- package/dist/src/turns/knobs.js +14 -0
- package/dist/src/turns/prompt.js +284 -0
- package/dist/src/turns/runner.js +283 -0
- package/package.json +44 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Emil Kashkevich
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,286 @@
|
|
|
1
|
-
#
|
|
1
|
+
# sidecar
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
sidecar lets a coding agent ask a second, read-only coding agent for an opinion during a task. It
|
|
4
|
+
runs locally, connects to the driver over MCP, and starts the second agent through the agent CLIs
|
|
5
|
+
you already have installed and logged in.
|
|
6
|
+
|
|
7
|
+
## Concepts
|
|
8
|
+
|
|
9
|
+
- The **driver** is the agent that does the work: it edits the workspace, asks, and decides.
|
|
10
|
+
- The **navigator** is the agent that advises. It reads the workspace on its own and cannot change
|
|
11
|
+
it.
|
|
12
|
+
- A **case** holds one problem: the driver's brief, its asks, the navigator's opinions and the
|
|
13
|
+
driver's decisions. It is an append-only log that outlives agent sessions.
|
|
14
|
+
- An **ask** is one question. The navigator answers it in one headless **turn**.
|
|
15
|
+
- Each opinion raises **points**. The driver records a **decision** on each point, and a point is
|
|
16
|
+
settled only when the navigator confirms that decision.
|
|
17
|
+
|
|
18
|
+
Typical asks: before the driver commits to an approach, when the same error comes back, and before
|
|
19
|
+
it calls non-trivial work done.
|
|
20
|
+
|
|
21
|
+
## Supported apps
|
|
22
|
+
|
|
23
|
+
| App | Driver | Navigator | Platforms |
|
|
24
|
+
| ------------------ | :----: | :-------: | ------------ |
|
|
25
|
+
| Claude Code (CLI) | ✓ | ✓ | Linux, macOS |
|
|
26
|
+
| Codex (CLI) | ✓ | ✓ | Linux, macOS |
|
|
27
|
+
| Claude desktop app | ✓ | — | macOS |
|
|
28
|
+
|
|
29
|
+
Any driver can consult any navigator, another app or its own. sidecar does not check versions. Its
|
|
30
|
+
behaviour was measured with Claude Code 2.1.300–2.1.317, codex-cli 0.154.0–0.166.0 and the Claude
|
|
31
|
+
desktop app 2.42304–4.4212; [docs/design.md](docs/design.md) lists the version behind each
|
|
32
|
+
measurement.
|
|
33
|
+
|
|
34
|
+
## How it works
|
|
35
|
+
|
|
36
|
+
```mermaid
|
|
37
|
+
flowchart LR
|
|
38
|
+
user(("You"))
|
|
39
|
+
driver["Driver<br/>Claude Code, Codex or<br/>the Claude desktop app"]
|
|
40
|
+
ws[/"Workspace"/]
|
|
41
|
+
nav["Navigator<br/>headless, read-only"]
|
|
42
|
+
|
|
43
|
+
subgraph sidecar
|
|
44
|
+
mcp["MCP server<br/>one per CLI session or desktop app"]
|
|
45
|
+
runner["Runner<br/>one per turn"]
|
|
46
|
+
store[("Case log<br/>~/.sidecar/cases")]
|
|
47
|
+
end
|
|
48
|
+
dash["Dashboard<br/>user service"]
|
|
49
|
+
|
|
50
|
+
user -- "prompt" --> driver
|
|
51
|
+
driver -- "open, ask, record, close" --> mcp
|
|
52
|
+
mcp -- "starts" --> runner
|
|
53
|
+
runner -- "one turn" --> nav
|
|
54
|
+
mcp <-- "events" --> store
|
|
55
|
+
runner -- "turn events" --> store
|
|
56
|
+
store --> dash
|
|
57
|
+
user -- "browser" --> dash
|
|
58
|
+
driver -- "edits" --> ws
|
|
59
|
+
nav -. "reads" .-> ws
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
One ask:
|
|
63
|
+
|
|
64
|
+
```mermaid
|
|
65
|
+
sequenceDiagram
|
|
66
|
+
participant D as Driver
|
|
67
|
+
participant S as sidecar
|
|
68
|
+
participant N as Navigator
|
|
69
|
+
D->>S: sidecar_ask(claim and path:line evidence)
|
|
70
|
+
S->>N: start or resume the navigator session: one headless turn
|
|
71
|
+
N-->>N: read the workspace
|
|
72
|
+
N->>S: opinion: verdict, points, limits, reviews
|
|
73
|
+
S->>D: opinion, or pending, busy, failed
|
|
74
|
+
D->>S: sidecar_record(a decision on each point)
|
|
75
|
+
Note over D,N: the next ask, or sidecar_review, shows the decisions to the navigator,<br/>which confirms, reopens or holds each point
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
- **On demand.** The navigator runs only while it answers. Between asks nothing runs.
|
|
79
|
+
- **Bounded.** Every wait has a limit. An ask returns `pending` after its budget (240 s, 45 s for
|
|
80
|
+
the Claude desktop app), and the driver keeps waiting with `sidecar_wait`. A turn ends after 15
|
|
81
|
+
minutes. If the navigator fails, the driver tells you and continues.
|
|
82
|
+
- **Independent of the driver's process.** A turn finishes and is recorded even if the driver or
|
|
83
|
+
its MCP server exits. A detached or closed case continues later with the navigator's context
|
|
84
|
+
intact.
|
|
85
|
+
|
|
86
|
+
The driver learns the protocol from the MCP server's instructions and tool descriptions. You need
|
|
87
|
+
no per-project configuration.
|
|
88
|
+
|
|
89
|
+
## Requirements
|
|
90
|
+
|
|
91
|
+
- Linux or macOS.
|
|
92
|
+
- Node 24.14 or later, with npm.
|
|
93
|
+
- At least one navigator CLI, installed, logged in and working headless: `claude -p` or
|
|
94
|
+
`codex exec`.
|
|
95
|
+
|
|
96
|
+
Each ask runs one turn of the navigator CLI on your own subscription, so it uses that quota.
|
|
97
|
+
|
|
98
|
+
## Installation
|
|
99
|
+
|
|
100
|
+
```sh
|
|
101
|
+
npm install --global @lysyi3m/sidecar
|
|
102
|
+
sidecar setup
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
If you use the Claude desktop app, quit it before `setup`: setup edits its config, and the app
|
|
106
|
+
rewrites that file while it runs.
|
|
107
|
+
|
|
108
|
+
`setup` finds the installed agents and asks:
|
|
109
|
+
|
|
110
|
+
- which agents and Claude profiles to register sidecar's MCP server with;
|
|
111
|
+
- the default model and effort for each navigator;
|
|
112
|
+
- how many rounds the navigator reviews a point before handing it over to you;
|
|
113
|
+
- where the dashboard is reachable from (this machine, your network or one address) and its port.
|
|
114
|
+
|
|
115
|
+
Nothing changes until you apply your answers. Setup then registers the server, saves your answers
|
|
116
|
+
and installs the dashboard as a user service.
|
|
117
|
+
|
|
118
|
+
Then allow sidecar's tools in each driver, or it asks before every call:
|
|
119
|
+
|
|
120
|
+
- **Claude Code:** add `"mcp__sidecar"` to `permissions.allow` in your Claude settings.
|
|
121
|
+
- **Codex:** setup sets `default_tools_approval_mode = "approve"` for sidecar's server.
|
|
122
|
+
- **Claude desktop app:** start the app again, then set sidecar's tools to "Always allow" under
|
|
123
|
+
Customize → Connectors → sidecar.
|
|
124
|
+
|
|
125
|
+
### What setup changes
|
|
126
|
+
|
|
127
|
+
| Where | What |
|
|
128
|
+
| -------------------------------------------------------------------------------------- | ------------------------------------------------------------------------ |
|
|
129
|
+
| `~/.claude.json`, and `.claude.json` in each selected Claude profile | The `sidecar` MCP server, through `claude mcp add`. |
|
|
130
|
+
| `$CODEX_HOME/config.toml` (default `~/.codex`) | The `sidecar` MCP server, through `codex mcp add`, and its auto-approve. |
|
|
131
|
+
| `~/Library/Application Support/Claude/claude_desktop_config.json` | `mcpServers.sidecar`. No other key changes. |
|
|
132
|
+
| `$XDG_CONFIG_HOME/systemd/user/sidecar-dashboard.service` (Linux; default `~/.config`) | The dashboard service. |
|
|
133
|
+
| `~/Library/LaunchAgents/dev.lysyi3m.sidecar.dashboard.plist` (macOS) | The dashboard service. |
|
|
134
|
+
| `~/.sidecar/config.json` | Your answers. Mode 0600: it can hold the dashboard token. |
|
|
135
|
+
|
|
136
|
+
Each registration runs the installed package with the Node that ran setup. After you change Node
|
|
137
|
+
versions, install sidecar again for the new Node, then run `sidecar setup --yes`: a global npm
|
|
138
|
+
install belongs to one Node.
|
|
139
|
+
|
|
140
|
+
## Usage
|
|
141
|
+
|
|
142
|
+
Ask the driver to use sidecar in your prompt:
|
|
143
|
+
|
|
144
|
+
```text
|
|
145
|
+
Find why the retry in src/sync.ts can send the same request twice, and fix it.
|
|
146
|
+
Use sidecar. Before you fix it, ask the navigator to challenge your cause chain with file:line
|
|
147
|
+
evidence. Record a decision on each point it raises. Close the case at the end.
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
When the case opens, you choose the navigator:
|
|
151
|
+
|
|
152
|
+
- Claude Code and Codex show a form, with another app than the driver preselected.
|
|
153
|
+
- The Claude desktop app has no forms, so the driver asks you in the chat.
|
|
154
|
+
- With only one navigator installed, there is nothing to choose.
|
|
155
|
+
|
|
156
|
+
The driver gives you the case's dashboard link. When the navigator is unavailable, for example
|
|
157
|
+
after a failed login, the driver says so and continues without the opinion.
|
|
158
|
+
|
|
159
|
+
**Workspace.** The navigator works in the driver's working directory, unless the driver passes
|
|
160
|
+
another `workspace`, such as the common parent of several repositories. The Claude desktop app
|
|
161
|
+
runs its server outside any project: in a chat, ask the driver to pass the project folder's
|
|
162
|
+
absolute path as the workspace. Without one, the navigator starts in an empty scratch directory.
|
|
163
|
+
|
|
164
|
+
**Later sessions.** Ask the driver to detach the case. In a new session, ask it to attach the case
|
|
165
|
+
by its id. A closed case reopens when it is attached: use that for the same work, such as a review
|
|
166
|
+
round on the same PR, and a new case for a new problem. `sidecar list` and the dashboard show
|
|
167
|
+
the ids.
|
|
168
|
+
|
|
169
|
+
## Dashboard
|
|
170
|
+
|
|
171
|
+
The dashboard runs as a user service at <http://127.0.0.1:47822/> by default. It shows every case,
|
|
172
|
+
and for each case the live timeline: asks, opinions, decisions, which points are settled, and what
|
|
173
|
+
each turn cost the navigator. A case page exports to one self-contained HTML file.
|
|
174
|
+
|
|
175
|
+
The dashboard is read-only and listens on loopback. To open it to your network, choose "my network"
|
|
176
|
+
or one address in setup: it then requires an access token, and `sidecar status` prints the links that carry
|
|
177
|
+
it. The traffic is plain HTTP, so use it only on a network you trust, or through a tunnel.
|
|
178
|
+
|
|
179
|
+
## Security model
|
|
180
|
+
|
|
181
|
+
- **Navigator: read-only for its built-in tools.** Every turn passes the adapter's full launch
|
|
182
|
+
policy; nothing carries over from an earlier turn.
|
|
183
|
+
- Codex runs in its read-only sandbox, which also denies its shell network access. Your
|
|
184
|
+
memories, developer instructions, hooks, plugins and apps stay off, and so does sidecar's own
|
|
185
|
+
MCP server.
|
|
186
|
+
- Claude Code runs with the Read, Grep and Glob tools and an allowlist of five read-only shell
|
|
187
|
+
commands (`cat`, `head`, `wc`, `ls`, `grep`), without your settings or auto memory.
|
|
188
|
+
- **Web lookups.** Both navigators can search and read the web, to check documentation, a
|
|
189
|
+
changelog or an API: Codex through its web search, Claude Code through `WebSearch` and
|
|
190
|
+
`WebFetch`. These tools write nothing. A fetched page can carry instructions aimed at the
|
|
191
|
+
navigator, which can skew an opinion, and a request can carry workspace content to a third party
|
|
192
|
+
in its URL.
|
|
193
|
+
- **Not covered.** A Codex navigator still loads your other MCP servers, which run outside its
|
|
194
|
+
sandbox and may offer write tools. Managed (enterprise) settings can widen either navigator's
|
|
195
|
+
permissions.
|
|
196
|
+
- **Dashboard.** Loopback only unless you choose otherwise; beyond loopback it requires a token.
|
|
197
|
+
|
|
198
|
+
[docs/design.md](docs/design.md) → Launch policy has the exact arguments and the probes behind
|
|
199
|
+
them.
|
|
200
|
+
|
|
201
|
+
## Commands
|
|
202
|
+
|
|
203
|
+
Run each command as `sidecar <command>`. `sidecar --version` prints the installed version.
|
|
204
|
+
|
|
205
|
+
| Command | Description |
|
|
206
|
+
| ----------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
207
|
+
| `setup [--yes]` | Set sidecar up, or repair a setup. `--yes` keeps your current answers and registrations; an effort the model no longer offers falls back to the CLI default. |
|
|
208
|
+
| `status` | Check agents, registrations, the dashboard and cases. Exits 1 on a problem. |
|
|
209
|
+
| `list [--state open\|closed]` | List cases. |
|
|
210
|
+
| `uninstall [--yes]` | Remove registrations, the dashboard service and the config. Keeps cases. |
|
|
211
|
+
|
|
212
|
+
## Files and ports
|
|
213
|
+
|
|
214
|
+
| Path | Contents |
|
|
215
|
+
| ------------------------------------ | -------------------------------------------------------------- |
|
|
216
|
+
| `~/.sidecar/config.json` | Navigator defaults, review budget, dashboard settings. |
|
|
217
|
+
| `~/.sidecar/cases/<id>/events.jsonl` | A case log. |
|
|
218
|
+
| `~/.sidecar/cases/<id>/scratch/` | The empty workspace of a case opened without one. |
|
|
219
|
+
| `~/.sidecar/schemas/` | The reply schemas passed to the Codex CLI. |
|
|
220
|
+
| `~/.sidecar/dashboard.log` | The dashboard's log on macOS. On Linux it goes to the journal. |
|
|
221
|
+
|
|
222
|
+
sidecar listens on two loopback ports: 47821 for the case store lock and 47822 for the dashboard.
|
|
223
|
+
Set `SIDECAR_HOME` to keep everything in another directory; setup registers that directory with
|
|
224
|
+
each agent. [docs/design.md](docs/design.md) → Configuration lists the other settings.
|
|
225
|
+
|
|
226
|
+
## Troubleshooting
|
|
227
|
+
|
|
228
|
+
Start with `sidecar status`. It names each problem and exits 1 when there is one.
|
|
229
|
+
|
|
230
|
+
- **A registration is stale** (another Node, a moved install, a missing `--driver`): run
|
|
231
|
+
`sidecar setup --yes`, then restart that agent's sessions.
|
|
232
|
+
- **"navigator unavailable: version-mismatch":** sidecar was upgraded while the agent session ran.
|
|
233
|
+
Restart the session.
|
|
234
|
+
- **The dashboard is down:** run setup again, or read its log: `journalctl --user -u
|
|
235
|
+
sidecar-dashboard` on Linux, `~/.sidecar/dashboard.log` on macOS.
|
|
236
|
+
- **"the Claude desktop app is running":** quit the app, then run setup or uninstall again.
|
|
237
|
+
- **"navigator unavailable":** the navigator CLI failed. The hint names the likely cause, such as
|
|
238
|
+
`auth` (log in to that CLI again) or `rate-limit`.
|
|
239
|
+
|
|
240
|
+
## Update
|
|
241
|
+
|
|
242
|
+
```sh
|
|
243
|
+
npm install --global @lysyi3m/sidecar@latest
|
|
244
|
+
sidecar setup --yes
|
|
245
|
+
```
|
|
246
|
+
|
|
247
|
+
Then restart your agent sessions: a running MCP server keeps the code it started with, and until
|
|
248
|
+
it restarts, its asks fail with `version-mismatch`. Setup restarts the dashboard.
|
|
249
|
+
|
|
250
|
+
[CHANGELOG.md](CHANGELOG.md) lists what each release changes.
|
|
251
|
+
|
|
252
|
+
## Uninstall
|
|
253
|
+
|
|
254
|
+
```sh
|
|
255
|
+
sidecar uninstall
|
|
256
|
+
npm uninstall --global @lysyi3m/sidecar
|
|
257
|
+
```
|
|
258
|
+
|
|
259
|
+
`sidecar uninstall` removes the MCP registrations, the dashboard service and
|
|
260
|
+
`~/.sidecar/config.json`. Your cases stay in `~/.sidecar`; delete the directory to remove them. Also
|
|
261
|
+
remove any permission entries you added for sidecar.
|
|
262
|
+
|
|
263
|
+
## Development
|
|
264
|
+
|
|
265
|
+
Run sidecar from a clone to work on it. `mise install` provides Node and pnpm from `.mise.toml`.
|
|
266
|
+
|
|
267
|
+
```sh
|
|
268
|
+
git clone https://github.com/lysyi3m/sidecar.git
|
|
269
|
+
cd sidecar
|
|
270
|
+
pnpm install
|
|
271
|
+
pnpm sidecar setup
|
|
272
|
+
```
|
|
273
|
+
|
|
274
|
+
`pnpm sidecar <command>` runs the clone's TypeScript sources directly. The install that ran setup
|
|
275
|
+
last is the one the agents and the dashboard use: `pnpm sidecar setup` registers the clone, and
|
|
276
|
+
`sidecar setup` the npm package.
|
|
277
|
+
|
|
278
|
+
[docs/design.md](docs/design.md) describes the invariants, the process model, the launch policies,
|
|
279
|
+
the storage, and the measured CLI behaviour sidecar relies on. [AGENTS.md](AGENTS.md) holds the
|
|
280
|
+
conventions for contributors, people and coding agents alike. CI runs `pnpm format:check`,
|
|
281
|
+
`pnpm lint`, `pnpm typecheck` and `pnpm test` on Linux and macOS.
|
|
282
|
+
|
|
283
|
+
## License
|
|
284
|
+
|
|
285
|
+
[MIT](LICENSE). The agent marks in `src/dashboard/static/agents/` are from LobeHub's icon set, under
|
|
286
|
+
their own MIT license: see the [NOTICE](src/dashboard/static/agents/NOTICE) there.
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
// The case dashboard, in the foreground. The dashboard service runs this path, so it stays stable.
|
|
2
|
+
//
|
|
3
|
+
// node bin/sidecar-dashboard.ts
|
|
4
|
+
import { Store } from "../src/cases/store.js";
|
|
5
|
+
import { loadConfig, sidecarHome } from "../src/config.js";
|
|
6
|
+
import { startDashboard } from "../src/dashboard/server.js";
|
|
7
|
+
import { watchVersion } from "../src/lib/version.js";
|
|
8
|
+
try {
|
|
9
|
+
const home = sidecarHome();
|
|
10
|
+
const config = loadConfig(home);
|
|
11
|
+
await startDashboard(new Store({ home, lockPort: config.lockPort }), {
|
|
12
|
+
port: config.dashboardPort,
|
|
13
|
+
host: config.dashboardHost,
|
|
14
|
+
...(config.dashboardToken ? { token: config.dashboardToken } : {}),
|
|
15
|
+
});
|
|
16
|
+
console.log(`sidecar dashboard on ${config.dashboardHost}:${config.dashboardPort}`);
|
|
17
|
+
// A failure exit: the service manager restarts the dashboard on the installed code.
|
|
18
|
+
watchVersion((reason) => {
|
|
19
|
+
console.error(`sidecar-dashboard: ${reason}; exiting for a restart`);
|
|
20
|
+
process.exit(1);
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
catch (err) {
|
|
24
|
+
// The service log gets one line, not a stack trace; the service manager restarts it.
|
|
25
|
+
console.error(`sidecar-dashboard: ${err.message}`);
|
|
26
|
+
process.exit(1);
|
|
27
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
// sidecar's stdio MCP server. Each agent session (Claude Code, Codex, ...) starts its own; an agent
|
|
2
|
+
// may also share one among its chats. This path is what `sidecar setup` registers, so it stays
|
|
3
|
+
// stable.
|
|
4
|
+
//
|
|
5
|
+
// node bin/sidecar-mcp.ts --driver <adapter id>
|
|
6
|
+
//
|
|
7
|
+
// --driver names the adapter of the agent that starts this server; setup writes it into each
|
|
8
|
+
// registration. It is an argument, not an environment variable, so it never reaches another
|
|
9
|
+
// server, a runner or a navigator.
|
|
10
|
+
import { parseArgs } from "node:util";
|
|
11
|
+
import { loadConfig, sidecarHome } from "../src/config.js";
|
|
12
|
+
import { dashboardBase } from "../src/dashboard/links.js";
|
|
13
|
+
import { SidecarServer } from "../src/mcp/server.js";
|
|
14
|
+
import { serveStdio } from "../src/mcp/stdio.js";
|
|
15
|
+
let server;
|
|
16
|
+
try {
|
|
17
|
+
const { values } = parseArgs({ options: { driver: { type: "string" } } });
|
|
18
|
+
if (values.driver === undefined)
|
|
19
|
+
throw new Error("--driver <adapter id> is missing; re-run `sidecar setup`");
|
|
20
|
+
const home = sidecarHome();
|
|
21
|
+
const config = loadConfig(home);
|
|
22
|
+
server = new SidecarServer({
|
|
23
|
+
store: { home, lockPort: config.lockPort },
|
|
24
|
+
workspace: process.cwd(),
|
|
25
|
+
driver: values.driver,
|
|
26
|
+
// A link only: the dashboard is its own service, not part of this process.
|
|
27
|
+
dashboardUrl: dashboardBase(config.dashboardPort, config.dashboardHost),
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
catch (err) {
|
|
31
|
+
// stdout carries only protocol messages; a bad launch says so on stderr and serves nothing.
|
|
32
|
+
process.stderr.write(`sidecar-mcp: ${err.message}\n`);
|
|
33
|
+
process.exit(1);
|
|
34
|
+
}
|
|
35
|
+
await serveStdio(server);
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// sidecar command line: see USAGE.
|
|
3
|
+
import { parseArgs } from "node:util";
|
|
4
|
+
import { CASE_STATUSES } from "../src/cases/state.js";
|
|
5
|
+
import { runList } from "../src/cli/list.js";
|
|
6
|
+
import { runSetup } from "../src/cli/setup.js";
|
|
7
|
+
import { runStatus } from "../src/cli/status.js";
|
|
8
|
+
import { acceptDefaults, clackUI } from "../src/cli/ui.js";
|
|
9
|
+
import { runUninstall } from "../src/cli/uninstall.js";
|
|
10
|
+
import { sidecarHome } from "../src/config.js";
|
|
11
|
+
import { SIDECAR_VERSION } from "../src/lib/version.js";
|
|
12
|
+
const USAGE = `usage:
|
|
13
|
+
sidecar setup [--yes]
|
|
14
|
+
sidecar status
|
|
15
|
+
sidecar uninstall [--yes]
|
|
16
|
+
sidecar list [--state ${CASE_STATUSES.join("|")}]
|
|
17
|
+
sidecar --version`;
|
|
18
|
+
/** Bad arguments: says what is wrong, prints usage and exits 2. */
|
|
19
|
+
function usage(problem) {
|
|
20
|
+
console.error(`sidecar: ${problem}\n${USAGE}`);
|
|
21
|
+
process.exit(2);
|
|
22
|
+
}
|
|
23
|
+
function parse() {
|
|
24
|
+
try {
|
|
25
|
+
return parseArgs({
|
|
26
|
+
allowPositionals: true,
|
|
27
|
+
options: {
|
|
28
|
+
state: { type: "string" },
|
|
29
|
+
version: { type: "boolean", short: "v" },
|
|
30
|
+
yes: { type: "boolean", short: "y" },
|
|
31
|
+
},
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
catch (err) {
|
|
35
|
+
return usage(err.message);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
const isStatus = (value) => CASE_STATUSES.includes(value);
|
|
39
|
+
const { positionals, values } = parse();
|
|
40
|
+
if (values.version) {
|
|
41
|
+
console.log(SIDECAR_VERSION);
|
|
42
|
+
process.exit(0);
|
|
43
|
+
}
|
|
44
|
+
const [command] = positionals;
|
|
45
|
+
const ui = values.yes ? acceptDefaults(clackUI()) : clackUI();
|
|
46
|
+
const home = sidecarHome();
|
|
47
|
+
// Any other failure, such as an invalid config, is one line on stderr, not a stack trace.
|
|
48
|
+
try {
|
|
49
|
+
switch (command) {
|
|
50
|
+
case "setup":
|
|
51
|
+
process.exit((await runSetup({ ui, home })) ? 0 : 1);
|
|
52
|
+
case "status":
|
|
53
|
+
process.exit((await runStatus({ ui, home })) ? 0 : 1);
|
|
54
|
+
case "uninstall":
|
|
55
|
+
process.exit((await runUninstall({ ui, home })) ? 0 : 1);
|
|
56
|
+
case "list": {
|
|
57
|
+
const { state } = values;
|
|
58
|
+
if (state !== undefined && !isStatus(state))
|
|
59
|
+
usage(`--state must be one of ${CASE_STATUSES.join(", ")}`);
|
|
60
|
+
await runList({ home, ...(state ? { state } : {}) });
|
|
61
|
+
break;
|
|
62
|
+
}
|
|
63
|
+
default:
|
|
64
|
+
usage(command ? `unknown command: ${command}` : "no command");
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
catch (err) {
|
|
68
|
+
console.error(`sidecar: ${err.message}`);
|
|
69
|
+
process.exit(1);
|
|
70
|
+
}
|