@kurrent/kcap 1.3.0-beta.7 → 1.3.0-beta.9

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.
@@ -0,0 +1,324 @@
1
+ ---
2
+ name: connect-capacitor
3
+ description: >-
4
+ This skill should be used when the user asks to "connect Capacitor", "set up
5
+ Capacitor", "set up kcap", "install kcap", "log in to Capacitor", "reconnect
6
+ Capacitor", or pastes the npm package name @kurrent/kcap; and when a kcap tool
7
+ or skill fails because `kcap` is not installed or not signed in. Installs the
8
+ kcap CLI and signs it in. On a Muse Assistant VM it also registers Capacitor's
9
+ MCP servers as a custom connector, writes the `capacitor` skill and keeps the
10
+ sign-in warm with an hourly cron.
11
+ ---
12
+
13
+ # Connect Capacitor
14
+
15
+ Kurrent Capacitor records a team's coding-agent sessions and serves them back as
16
+ tools: search past sessions, team memory, analytics, work items, plans and
17
+ knowledge. `kcap` is its CLI. This skill installs `kcap` and signs it in; what
18
+ happens after that depends on the machine.
19
+
20
+ **Where am I?**
21
+
22
+ ```bash
23
+ [ "$HOME" = /home/hatch ] && [ -d "$HOME/workspace" ] && [ -d /opt/hatch-image/bin ] && echo muse-assistant
24
+ ```
25
+
26
+ - Prints `muse-assistant` → follow **Part B** (the Muse Assistant walkthrough).
27
+ - Prints nothing → follow **Part A** (any other machine), then stop.
28
+
29
+ Never print the contents of `~/.config/kcap/` — it holds the sign-in tokens.
30
+ Never start `kcap daemon` unless the user asks for hosted agents.
31
+
32
+ ## Part A — any other machine
33
+
34
+ 1. Check what is there: `command -v kcap && kcap whoami`. A `Server:` line
35
+ naming the workspace the user wants (or any, if they named none) plus
36
+ `Server: accepts this token` means nothing to do; say so and stop.
37
+ No `kcap` on PATH means step 2, then step 3; anything else, step 3.
38
+ 2. Install: requires Node.js 18+ (`node -v`). `npm install -g @kurrent/kcap`,
39
+ then `command -v kcap` must print a path (otherwise add `$(npm prefix -g)/bin`
40
+ to PATH in the shell profile — the hooks run `kcap` by name).
41
+ 3. Sign in: ask the user for their Capacitor server URL (for example
42
+ `https://acme.kcap.ai`) unless they gave it, then run `kcap setup --server-url <url>`.
43
+ With no browser on this machine add `--device`: it prints a URL and a short
44
+ code — **show both to the user** and ask them to approve on their own device;
45
+ the command finishes once they do. Let setup detect the installed coding
46
+ agents and install their hooks; that is what records sessions here.
47
+ 4. Confirm with `kcap status` (`Auth: … ✓ token valid`). Done.
48
+
49
+ ## Part B — Muse Assistant
50
+
51
+ ### What the user will see, and must do
52
+
53
+ First ask for the workspace address (for example `https://acme.kcap.ai`) if the
54
+ user has not given one. Never guess a tenant.
55
+
56
+ Then say this to the user, naming the workspace's own host:
57
+
58
+ > Connecting Capacitor needs a few approvals from you in this chat. Each time I
59
+ > first contact a new host, a card appears here with **Allow once / Always allow
60
+ > this site / Deny**. Please choose **Always allow this site** on each. The first
61
+ > two are your workspace (`<its host>`) and `phog.kurrent.io` (kcap's anonymous
62
+ > usage proxy); the sign-in then adds `api.workos.com` and `signin.kcap.ai`, or
63
+ > `github.com` for a GitHub workspace. After that I will show you a short code to
64
+ > approve on your own device.
65
+
66
+ Setup prints the exact hosts as it reaches each stage; relay them to the user.
67
+ I do not see the cards. If a command below fails with "cannot reach" or asks for
68
+ a card to be approved, the user has not approved that host yet: ask them to look
69
+ for the card, then run the **same command again** unchanged.
70
+
71
+ ### B1. Check what is already there
72
+
73
+ ```bash
74
+ KCAP=~/workspace/kcap/node_modules/.bin/kcap
75
+ [ -x "$KCAP" ] && "$KCAP" whoami
76
+ ```
77
+
78
+ B2 and B3 are done only when `whoami` prints a `Server:` line naming the
79
+ workspace the user asked for **and** a `Server: accepts this token` line —
80
+ the workspace itself checked the sign-in. Then continue at B4 and only create
81
+ what is missing. A different server, `could not verify` (on this VM, usually a
82
+ card not yet approved), `REJECTS this token`, or no sign-in at all means B3
83
+ still runs.
84
+
85
+ ### B2. Install under the persistent workspace
86
+
87
+ Only `~` survives a VM replacement; the global npm prefix is `/usr` and is
88
+ wiped, so never `npm install -g` here.
89
+ If `npm install` cannot reach `registry.npmjs.org`, that host needs its card
90
+ approved too.
91
+
92
+ ```bash
93
+ mkdir -p ~/workspace/kcap ~/workspace/capacitor
94
+ npm install --prefix ~/workspace/kcap @kurrent/kcap
95
+ ~/workspace/kcap/node_modules/.bin/kcap --version
96
+ ```
97
+
98
+ ### B3. Sign in by device code
99
+
100
+ The workspace address goes into a shell command, and the sign-in travels to it,
101
+ so check it first: it must be `https://` followed only by letters, digits, `.`
102
+ and `-`, with an optional `:port` and nothing after it. `http://` is acceptable
103
+ only for `localhost` or `127.0.0.1`. Refuse anything else — plain `http://` to
104
+ a remote host, quotes, spaces, `$`, `;` or a path — and ask the user for the
105
+ plain `https://` address.
106
+
107
+ Run setup in the background and read its output while it waits for the user:
108
+
109
+ ```bash
110
+ KCAP=~/workspace/kcap/node_modules/.bin/kcap
111
+ SERVER='<the checked workspace address>'
112
+ nohup "$KCAP" setup --server-url "$SERVER" --device --no-prompt --muse-assistant \
113
+ > ~/workspace/capacitor/setup.log 2>&1 &
114
+ sleep 8; cat ~/workspace/capacitor/setup.log
115
+ ```
116
+
117
+ `--muse-assistant` installs nothing into Codex or any other agent on this image
118
+ (Muse does not use them), makes every session this install records private by
119
+ default, lists the hosts above before its first request, and treats an
120
+ unreachable server as "not yet approved".
121
+
122
+ - The log first lists the hosts, and once the server answers, the sign-in
123
+ hosts. If it then says **Cannot reach server** and **not yet approved**, or
124
+ sign-in fails while a card is waiting: ask the user to approve it, then run
125
+ the same command again.
126
+ - If the user declined the code, or it expired before they entered it, the log
127
+ says **Login failed**: run the same command again, which starts a fresh
128
+ sign-in, and show the user the new URL and code.
129
+ - Once the server answers, the log shows a **verification URL and a code**.
130
+ **Show both to the user** and ask them to open the URL on their own device and
131
+ enter the code. Keep reading the log (`sleep 15; tail -20 …`) until it reaches
132
+ `Setup complete`.
133
+ - Confirm: `"$KCAP" status` → `Auth: <name> ✓ token valid`. Tokens live under
134
+ `~/.config/kcap/` and persist; never paste them into the chat.
135
+
136
+ If sign-in lapses later (`kcap status` reports an expired or missing token):
137
+ `"$KCAP" login --device`, show the URL and code again.
138
+
139
+ ### B4. Register Capacitor as a custom connector
140
+
141
+ Capacitor's tools are stdio MCP servers started by `kcap mcp <name>`. Register
142
+ them as one custom connector at `~/workspace/custom-connectors/custom.kcap/`.
143
+ The directory holds `connector.yaml`, `CONNECTOR.md`, and a stdio helper
144
+ `mcp_call.py` — write the helper yourself, the way other custom connectors on
145
+ this VM do: spawn the command with its args, speak JSON-RPC 2.0 over
146
+ newline-delimited stdin/stdout, send `initialize` (protocol version
147
+ `2024-11-05`, then `notifications/initialized`), then `tools/list` or
148
+ `tools/call`, with a 60-second timeout and the result printed as JSON.
149
+
150
+ `connector.yaml` — if another custom connector already exists here, copy its
151
+ field names; these are the servers, commands and args:
152
+
153
+ ```yaml
154
+ name: kcap
155
+ description: >-
156
+ Kurrent Capacitor: the team's recorded coding-agent sessions, team memory,
157
+ analytics, work items, plans and curated knowledge.
158
+ servers:
159
+ kcap-sessions:
160
+ transport: stdio
161
+ command: /home/hatch/workspace/kcap/node_modules/.bin/kcap
162
+ args: [mcp, sessions]
163
+ kcap-memory:
164
+ transport: stdio
165
+ command: /home/hatch/workspace/kcap/node_modules/.bin/kcap
166
+ args: [mcp, memory]
167
+ kcap-analytics:
168
+ transport: stdio
169
+ command: /home/hatch/workspace/kcap/node_modules/.bin/kcap
170
+ args: [mcp, analytics]
171
+ kcap-workitems:
172
+ transport: stdio
173
+ command: /home/hatch/workspace/kcap/node_modules/.bin/kcap
174
+ args: [mcp, workitems]
175
+ kcap-plans:
176
+ transport: stdio
177
+ command: /home/hatch/workspace/kcap/node_modules/.bin/kcap
178
+ args: [mcp, plans]
179
+ kcap-knowledge:
180
+ transport: stdio
181
+ command: /home/hatch/workspace/kcap/node_modules/.bin/kcap
182
+ args: [mcp, knowledge]
183
+ ```
184
+
185
+ `CONNECTOR.md`:
186
+
187
+ ```markdown
188
+ # kcap — Kurrent Capacitor
189
+
190
+ Six stdio MCP servers over the team's Capacitor workspace. Call a tool with
191
+ `python3 mcp_call.py <server> <tool> '<json-args>'`; list tools with
192
+ `python3 mcp_call.py <server> tools/list`.
193
+
194
+ | Server | Use it for |
195
+ |---|---|
196
+ | kcap-sessions | `search_sessions`, `list_repo_sessions`, `get_session_summary`, `list_turns`, `get_turn`, `get_session_transcript`, `list_repo_plans`, `get_declared_plans`, `get_session_evals` |
197
+ | kcap-memory | `search_memories`, `get_memory`, `save_memory`, `update_memory`, `rescope_memory`, `archive_memory` |
198
+ | kcap-analytics | `get_analytics_schema` once, then `query_analytics` (read-only SQL) |
199
+ | kcap-workitems | work items, breakdowns, loose ends, next work |
200
+ | kcap-plans | declared plan documents and tasks |
201
+ | kcap-knowledge | curated facts and skills |
202
+
203
+ This VM is not a git checkout: pass `"repo": "all"` to `search_sessions` and
204
+ `list_repo_sessions`, or they search nothing. Sign-in is `kcap`'s own
205
+ (`~/.config/kcap/`); if a call returns 401, run `kcap status` and follow the
206
+ capacitor skill's reconnect step.
207
+ ```
208
+
209
+ Verify with a real call (keyword queries, one to three terms):
210
+
211
+ ```bash
212
+ cd ~/workspace/custom-connectors/custom.kcap
213
+ python3 mcp_call.py kcap-sessions tools/list | head -c 600
214
+ python3 mcp_call.py kcap-sessions search_sessions '{"query":"setup","repo":"all"}' | head -c 1200
215
+ ```
216
+
217
+ A hit list with `hit_kind`, `session_id` and `title` fields means the connector
218
+ works.
219
+
220
+ ### B5. Write the `capacitor` skill
221
+
222
+ Create `~/workspace/skills/capacitor/SKILL.md` with this content:
223
+
224
+ ```markdown
225
+ ---
226
+ name: capacitor
227
+ description: >-
228
+ Use Kurrent Capacitor — the team's recorded coding-agent sessions, team
229
+ memory, analytics, work items, plans and curated knowledge — through the
230
+ `kcap` custom connector. Triggers: "what did my team work on", "what did we
231
+ do last week", "find the session where", "did we ever", "who worked on",
232
+ "recap session", "what's next", "team memory", "save this for the team",
233
+ "how much did we spend on agents", and any question about past coding work.
234
+ metadata:
235
+ includeInPrompt: true
236
+ ---
237
+
238
+ # Capacitor
239
+
240
+ Capacitor's tools are the `kcap` custom connector
241
+ (`~/workspace/custom-connectors/custom.kcap/`): `python3 mcp_call.py <server>
242
+ <tool> '<json>'`. Read `CONNECTOR.md` there for the servers and tools.
243
+
244
+ ## Operating rules
245
+
246
+ 1. **Keyword queries.** `search_sessions` takes one to three terms or an
247
+ identifier, not a sentence. "what did the team do on billing last week" →
248
+ `{"query":"billing","repo":"all"}` then narrow by date with
249
+ `list_repo_sessions` (`repo:"all"`, a period).
250
+ 2. **Always `"repo": "all"`** for `search_sessions` and `list_repo_sessions`.
251
+ This VM is not a git checkout, so the default repo scope is empty.
252
+ 3. **Check `hit_kind`.** `transcript` and `title` hits contain your terms;
253
+ `turn_prose` and `semantic` hits can be near neighbours that do not, so check
254
+ the snippet first. Open a session with `get_session_summary`, then drill in:
255
+ a `transcript` hit's `hit_event_index` (with its `agent_id`) goes to
256
+ `get_session_transcript`, a `turn_prose` hit's `hit_turn_index` to `get_turn`.
257
+ 4. **Analytics:** call `get_analytics_schema` once per conversation, then write
258
+ Postgres `SELECT`s for `query_analytics` with `"scope": "global"` — this VM
259
+ has no repository, so the default repo scope refuses the query. A rejection
260
+ names the reason — fix the SQL and retry.
261
+ 5. **Memory:** search before saving; save with an explicit `audience` and
262
+ `global: true`, since nothing here is scoped to a repository.
263
+ 6. **Never paste `~/.config/kcap/` or any token** into the chat or a file.
264
+ 7. **Never start `kcap daemon`**, run `kcap import`, or install hooks. This VM
265
+ records only the chats the user puts in scope through the
266
+ `capacitor-recording` skill: if the user asks to record their chats, copy
267
+ `~/workspace/kcap/node_modules/@kurrent/kcap/kcap/muse-assistant/capacitor-recording/SKILL.md`
268
+ to `~/workspace/skills/capacitor-recording/SKILL.md` and follow its
269
+ "Granting" section.
270
+ 8. **A 401 or "token" error:** run `~/workspace/kcap/node_modules/.bin/kcap
271
+ status`. If the sign-in has lapsed, tell the user to say "reconnect
272
+ Capacitor"; the connect-capacitor skill runs `kcap login --device` and shows
273
+ them the code.
274
+ 9. Cite what you found: session title, date, author, and the `session_id`, so
275
+ the user can open it in Capacitor.
276
+ ```
277
+
278
+ ### B6. Keep the sign-in warm: an hourly `kcap status` cron
279
+
280
+ Ask the user first: the cron runs every hour while they are away, uses the
281
+ Capacitor sign-in to refresh it, appends to `~/workspace/capacitor/cron.log`,
282
+ and survives a VM replacement. Create it only once they agree; without it the
283
+ sign-in can lapse on a VM left idle, and "reconnect Capacitor" restores it.
284
+
285
+ Create a cron (title `kcap-hourly-status`, every hour) whose instruction is:
286
+
287
+ > Run `~/workspace/kcap/node_modules/.bin/kcap status --no-update-check >> ~/workspace/capacitor/cron.log 2>&1`,
288
+ > then keep only the last 500 lines of that file. Do nothing else and do not
289
+ > wake the user — unless the output says the token is expired, missing or the
290
+ > server rejected it, in which case add one line to the chat: "Capacitor
291
+ > sign-in lapsed — say 'reconnect Capacitor' when you have a minute."
292
+
293
+ `kcap status` refreshes the token when it can, so the hourly run is what keeps a
294
+ long-idle VM signed in; `~/workspace/capacitor/cron.log` is where a lapse shows.
295
+ `--no-update-check` keeps it from contacting `registry.npmjs.org`, a host an
296
+ unattended run has no one to approve.
297
+
298
+ ### B7. Recording (only when the user asks for it)
299
+
300
+ Connecting records nothing. If the user asks to record their chats — now or later —
301
+ install the recording skill and follow it; never grant recording from this skill:
302
+
303
+ ```bash
304
+ mkdir -p ~/workspace/skills/capacitor-recording
305
+ cp ~/workspace/kcap/node_modules/@kurrent/kcap/kcap/muse-assistant/capacitor-recording/SKILL.md ~/workspace/skills/capacitor-recording/SKILL.md
306
+ ```
307
+
308
+ If that file does not exist, the installed kcap predates recording: run B2's
309
+ `npm install` again to update it, then copy.
310
+
311
+ Then follow `~/workspace/skills/capacitor-recording/SKILL.md` from its "Granting"
312
+ section: it reads the consent scope back to the user, runs
313
+ `kcap muse-assistant scope add` in that same turn, and installs the 15-minute cron.
314
+
315
+ ### B8. Tell the user
316
+
317
+ - Capacitor is connected: ask me things like "what did my team work on this
318
+ week", "find the session where we fixed X", or "save this for the team".
319
+ - Nothing on this VM is recorded until you ask: say "record my chats" and I
320
+ will read the exact scope back to you before anything is sent.
321
+ - Everything lives under your home — `~/workspace/kcap`, `~/.config/kcap`,
322
+ the connector, the skill and the cron (if you agreed to it) — so it survives
323
+ a VM replacement.
324
+ - If a tool ever says the sign-in lapsed, say "reconnect Capacitor".
@@ -53,8 +53,8 @@ A failure at a lower layer never re-opens the file for a higher one.
53
53
  is a boolean. Fail → not selectable; try the next candidate file, or close with no lookup if none
54
54
  remain.
55
55
 
56
- **Layer B** (may its ids drive data): `cohort` ∈ {exact, partial_exact, unknown}; `background` ∈
57
- {not_needed, running, exited_zero, failed}; `foreground_certainty` ∈ {complete, incomplete};
56
+ **Layer B** (may its ids drive data): `cohort` ∈ {exact, partial_exact, unknown}; `scope` ∈ {all,
57
+ repos} (absent reads as `all`); `background` ∈ {not_needed, running, exited_zero, failed}; `foreground_certainty` ∈ {complete, incomplete};
58
58
  `handoff_suppressed` is null or one of import_failed, no_new_sessions, nothing_landed,
59
59
  analytics_not_in_plan, skill_not_installed, no_agent_detected (older setups write
60
60
  `analytics_not_in_plan`); every entry of `session_ids` and
@@ -76,8 +76,10 @@ If `handoff_offered` is false, branch on `handoff_suppressed` and CLOSE:
76
76
  - `no_new_sessions` → "nothing to watch — that import found no new sessions".
77
77
  - `nothing_landed` → "the sessions that import selected were skipped at import time"; point at
78
78
  `kcap import --all` for per-session reasons; no retry.
79
- - `import_failed` → "that import did not get running"; name `kcap import --all --yes` and the
80
- `background_log` when displayable.
79
+ - `import_failed` → "that import did not get running"; name `kcap import --all --yes` when the
80
+ file's `scope` is `all`; when it is `repos`, say to run `kcap setup` again and choose the same
81
+ repositories at the same Only me / Shared levels (plain `kcap import` would not keep those levels); and the `background_log`
82
+ when displayable.
81
83
  - `analytics_not_in_plan` / `skill_not_installed` / `no_agent_detected` → the import ran and you
82
84
  can follow it now: continue as if offered, watching the file's cohort as usual (sections 4–5).
83
85
 
@@ -87,12 +89,19 @@ If the selected file's `cohort` is `unknown`, skip this check and go straight to
87
89
  is no cohort to look up either way, and the mismatch remediation below would be misleading when
88
90
  watching was never possible.
89
91
 
90
- Otherwise, run `kcap whoami` and compare its server URL to `server_url`: lowercase scheme and host,
91
- drop a default port (80 for http, 443 for https only), trim a trailing slash, compare the path
92
- as-is. Match → continue to section 5. Mismatch or `whoami` failure → make **NO** eval lookup.
93
- CLOSE with the file's links and this remediation: start your agent from a shell where `kcap whoami`
94
- reports `<server_url>` — set `KCAP_PROFILE=<profile>`, unset `KCAP_URL`, and set `KCAP_CONFIG_DIR`
95
- if kcap uses a custom config directory — then prompt again.
92
+ Otherwise, in this order — any CLOSE here makes **NO** eval lookup:
93
+
94
+ 1. If `get_connection` is not among your `kcap-sessions` tools, this kcap is older than the skill:
95
+ say to update kcap and restart the agent, then CLOSE. `kcap whoami` is no substitute — it runs
96
+ in another process and cannot say which server the agent's MCP server reads.
97
+ 2. Run `kcap whoami`. If it fails because kcap is not logged in, say to run `kcap login`, then CLOSE.
98
+ 3. Call `get_connection` and compare its `server_url` to the file's — lowercase scheme and host,
99
+ drop a default port (80 for http, 443 for https only), trim a trailing slash, compare the path
100
+ as-is — and its `profile` to the file's `profile`, exactly. Both match → continue to section 5.
101
+ Either differs → CLOSE with the file's links and this remediation: start your agent from a
102
+ shell with `KCAP_PROFILE=<profile>`, `KCAP_URL` unset, and `KCAP_CONFIG_DIR` set if kcap uses a
103
+ custom config directory — restarting the agent, since its kcap-sessions server only reads those
104
+ when it starts — then prompt again.
96
105
 
97
106
  ## 5. Watch the cohort
98
107