@popoverinstall/cli 0.9.0 → 0.9.1
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/CHANGELOG.md +12 -0
- package/dist/vaults.d.ts +1 -102
- package/dist/vaults.d.ts.map +1 -1
- package/dist/vaults.js +15 -294
- package/dist/vaults.js.map +1 -1
- package/package.json +47 -47
- package/plugin/.claude-plugin/plugin.json +19 -19
- package/plugin/mcp/index.mjs +765 -585
- package/plugin/skills/popover/SKILL.md +205 -175
package/plugin/mcp/index.mjs
CHANGED
|
@@ -1,585 +1,765 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
// Popover MCP server — lets an agent see and ask its teammates' agents.
|
|
3
|
-
//
|
|
4
|
-
// Implemented directly against the JSON-RPC stdio protocol rather than the MCP SDK. The
|
|
5
|
-
// plugin is distributed through a marketplace and installed into a cache directory where
|
|
6
|
-
// dependency installation is conditional and can fail; a server with zero dependencies
|
|
7
|
-
// simply cannot fail that way. The protocol surface we need is small — initialize,
|
|
8
|
-
// tools/list, tools/call — so the SDK buys us little here.
|
|
9
|
-
//
|
|
10
|
-
// All real work happens in the daemon. This process is a thin bridge to it.
|
|
11
|
-
|
|
12
|
-
import { readFileSync } from "node:fs";
|
|
13
|
-
import { callerSessionId, request } from "../scripts/_ipc.mjs";
|
|
14
|
-
|
|
15
|
-
const PROTOCOL_VERSION = "2025-06-18";
|
|
16
|
-
|
|
17
|
-
// Read from the plugin manifest, which Claude Code copies into its cache alongside this
|
|
18
|
-
// file — so the relative path survives the severing copy that breaks everything else.
|
|
19
|
-
const SERVER_INFO = {
|
|
20
|
-
name: "popover",
|
|
21
|
-
version: JSON.parse(
|
|
22
|
-
readFileSync(new URL("../.claude-plugin/plugin.json", import.meta.url), "utf8"),
|
|
23
|
-
).version,
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
const TOOLS = [
|
|
28
|
-
{
|
|
29
|
-
name: "team_list",
|
|
30
|
-
description:
|
|
31
|
-
"List your teammates' currently-active Claude Code agents in THIS repo: who owns " +
|
|
32
|
-
"each one, what it is doing right now, and its short handle (e.g. B1). Only agents " +
|
|
33
|
-
"working in the same repository as you are visible — agents your teammates are " +
|
|
34
|
-
"running in other repos are not listed and cannot be asked. Use this before " +
|
|
35
|
-
"team_ask to find out which agent to ask. Read-only.",
|
|
36
|
-
inputSchema: { type: "object", properties: {}, additionalProperties: false },
|
|
37
|
-
annotations: { readOnlyHint: true, openWorldHint: true, title: "List team agents" },
|
|
38
|
-
},
|
|
39
|
-
{
|
|
40
|
-
name: "team_ask",
|
|
41
|
-
description:
|
|
42
|
-
"Ask a teammate's Claude Code agent a question and wait for the answer. A " +
|
|
43
|
-
"read-only copy of that agent answers from its full accumulated context; the " +
|
|
44
|
-
"teammate's live session is never interrupted or modified. Use this when a " +
|
|
45
|
-
"teammate's agent already knows something that would take you a long time to " +
|
|
46
|
-
"work out — why a decision was made, what they already ruled out, how a service " +
|
|
47
|
-
"they own behaves. Only agents working in the same repository as you can be asked. " +
|
|
48
|
-
"Answering costs the teammate tokens and takes up to ~90s, so ask one well-formed " +
|
|
49
|
-
"question rather than several exploratory ones.",
|
|
50
|
-
inputSchema: {
|
|
51
|
-
type: "object",
|
|
52
|
-
properties: {
|
|
53
|
-
target: {
|
|
54
|
-
type: "string",
|
|
55
|
-
description:
|
|
56
|
-
"Which agent to ask: a handle from team_list such as 'B1', or a teammate's " +
|
|
57
|
-
"name, or a repo name.",
|
|
58
|
-
},
|
|
59
|
-
question: {
|
|
60
|
-
type: "string",
|
|
61
|
-
description:
|
|
62
|
-
"A self-contained question. The answering agent has none of your " +
|
|
63
|
-
"conversation's context, so expand pronouns and vague references.",
|
|
64
|
-
},
|
|
65
|
-
timeout_seconds: {
|
|
66
|
-
type: "number",
|
|
67
|
-
description: "How long to wait for an answer. Default 90, max 300.",
|
|
68
|
-
minimum: 5,
|
|
69
|
-
maximum: 300,
|
|
70
|
-
},
|
|
71
|
-
},
|
|
72
|
-
required: ["target", "question"],
|
|
73
|
-
additionalProperties: false,
|
|
74
|
-
},
|
|
75
|
-
annotations: { readOnlyHint: true, openWorldHint: true, title: "Ask a teammate's agent" },
|
|
76
|
-
},
|
|
77
|
-
{
|
|
78
|
-
name: "team_tell",
|
|
79
|
-
description:
|
|
80
|
-
"Send a short heads-up to a teammate's agent working in this repo. Unlike team_ask " +
|
|
81
|
-
"there is no answer: the message is delivered into that agent's context before its " +
|
|
82
|
-
"next prompt, and nothing comes back. Use it for facts about shared state that would " +
|
|
83
|
-
"otherwise cause a collision — \"the migration is applied on prod\", \"I am rewriting " +
|
|
84
|
-
"globals.css, leave it alone\". Do not use it to give another agent instructions or " +
|
|
85
|
-
"assign it work: the receiving agent is told to treat your message as information " +
|
|
86
|
-
"from outside its conversation, not as a directive, and its user is notified that you " +
|
|
87
|
-
"sent it. Only agents in the same repository can be told, and you are limited to 10 " +
|
|
88
|
-
"messages an hour to any one agent.",
|
|
89
|
-
inputSchema: {
|
|
90
|
-
type: "object",
|
|
91
|
-
properties: {
|
|
92
|
-
target: {
|
|
93
|
-
type: "string",
|
|
94
|
-
description:
|
|
95
|
-
"Which agent to tell: a handle from team_list such as 'B1', or a teammate's " +
|
|
96
|
-
"name, or a repo name.",
|
|
97
|
-
},
|
|
98
|
-
message: {
|
|
99
|
-
type: "string",
|
|
100
|
-
description:
|
|
101
|
-
"The heads-up, in one or two sentences. It arrives with no context of its own, " +
|
|
102
|
-
"so name the thing you are talking about rather than referring to it.",
|
|
103
|
-
},
|
|
104
|
-
},
|
|
105
|
-
required: ["target", "message"],
|
|
106
|
-
additionalProperties: false,
|
|
107
|
-
},
|
|
108
|
-
// Not read-only: this writes into someone else's context and notifies a person.
|
|
109
|
-
annotations: { readOnlyHint: false, openWorldHint: true, title: "Tell a teammate's agent" },
|
|
110
|
-
},
|
|
111
|
-
{
|
|
112
|
-
name: "vault_search",
|
|
113
|
-
description:
|
|
114
|
-
"Search your team's vaults. A vault is a conversation somebody on your team froze " +
|
|
115
|
-
"deliberately and published: it does not expire, it is not a live session, and its " +
|
|
116
|
-
"author does not have to be online — or still at the company — for you to use it. " +
|
|
117
|
-
"This searches the index only. It is free, it runs no model, it resumes nothing, and " +
|
|
118
|
-
"it costs neither you nor anybody else a token, so use it freely. Each result carries " +
|
|
119
|
-
"the questions that vault says it can answer, when it was frozen, who froze it, and " +
|
|
120
|
-
"how much of the code it discussed has changed since — a vault whose files nobody has " +
|
|
121
|
-
"touched is current however old it is, and one whose files have churned is suspect " +
|
|
122
|
-
"even if it is recent. Unlike team_list this is not limited to agents in your repo or " +
|
|
123
|
-
"to people who are working right now: every vault on every team you belong to is " +
|
|
124
|
-
"searchable. ALWAYS call this before vault_ask, and read what comes back: asking is " +
|
|
125
|
-
"the expensive half and this is how you spend it on the right vault.",
|
|
126
|
-
inputSchema: {
|
|
127
|
-
type: "object",
|
|
128
|
-
properties: {
|
|
129
|
-
query: {
|
|
130
|
-
type: "string",
|
|
131
|
-
description:
|
|
132
|
-
"What you want to know, phrased as a question. Vaults are indexed by the " +
|
|
133
|
-
"questions they can answer rather than by a summary, so a question matches far " +
|
|
134
|
-
"better than keywords do. Omit it to list the most recently frozen vaults.",
|
|
135
|
-
},
|
|
136
|
-
repo: {
|
|
137
|
-
type: "string",
|
|
138
|
-
description:
|
|
139
|
-
"Narrow to one repo label. Display-level filtering only — vaults are visible " +
|
|
140
|
-
"across every repo your team works in, so leave this off unless the user asked " +
|
|
141
|
-
"for one repo specifically.",
|
|
142
|
-
},
|
|
143
|
-
limit: {
|
|
144
|
-
type: "number",
|
|
145
|
-
description: "How many to return. Default 20, max 50.",
|
|
146
|
-
minimum: 1,
|
|
147
|
-
maximum: 50,
|
|
148
|
-
},
|
|
149
|
-
},
|
|
150
|
-
additionalProperties: false,
|
|
151
|
-
},
|
|
152
|
-
annotations: { readOnlyHint: true, openWorldHint: true, title: "Search team vaults" },
|
|
153
|
-
},
|
|
154
|
-
{
|
|
155
|
-
name: "vault_ask",
|
|
156
|
-
description:
|
|
157
|
-
"Ask one vault one question and wait for the answer. **This costs a full context " +
|
|
158
|
-
"load and real money** — the frozen conversation is resumed in its entirety on THIS " +
|
|
159
|
-
"machine, on your user's account, at roughly $0.50 and up to 90 seconds per call. " +
|
|
160
|
-
"Call vault_search first and ask the one vault that fits; never fan out across " +
|
|
161
|
-
"several to see which answers best, and never call this on a vault you have not seen " +
|
|
162
|
-
"in a search result. The vault answers from its frozen context and has no tools at " +
|
|
163
|
-
"all: it cannot read a file, run a command, or look at the repository as it stands " +
|
|
164
|
-
"today, which is deliberate — it is authoritative about what was decided and why, and " +
|
|
165
|
-
"explicitly unreliable about what the code currently looks like. Report what comes " +
|
|
166
|
-
"back as the vault's claim, attributed and dated, never as a bare fact merged into " +
|
|
167
|
-
"your own reasoning: a vault can hold a hypothesis the team later disproved. Nothing " +
|
|
168
|
-
"you do here reaches the vault's author, changes the vault, or costs them anything.",
|
|
169
|
-
inputSchema: {
|
|
170
|
-
type: "object",
|
|
171
|
-
properties: {
|
|
172
|
-
vault_id: {
|
|
173
|
-
type: "string",
|
|
174
|
-
description: "The `id` of a vault from a vault_search result. Never guess one.",
|
|
175
|
-
},
|
|
176
|
-
question: {
|
|
177
|
-
type: "string",
|
|
178
|
-
description:
|
|
179
|
-
"A self-contained question. The vault has none of your conversation and has " +
|
|
180
|
-
"been frozen for weeks or months, so expand every pronoun, name files by path, " +
|
|
181
|
-
"and ask about decisions and reasoning rather than about the current code.",
|
|
182
|
-
},
|
|
183
|
-
timeout_seconds: {
|
|
184
|
-
type: "number",
|
|
185
|
-
description: "How long to wait for an answer. Default 90, max 300.",
|
|
186
|
-
minimum: 5,
|
|
187
|
-
maximum: 300,
|
|
188
|
-
},
|
|
189
|
-
},
|
|
190
|
-
required: ["vault_id", "question"],
|
|
191
|
-
additionalProperties: false,
|
|
192
|
-
},
|
|
193
|
-
// Read-only: it resumes a copy and writes nothing back. It is not free, which the
|
|
194
|
-
// description says at length, because an annotation cannot say "and it costs money".
|
|
195
|
-
annotations: { readOnlyHint: true, openWorldHint: true, title: "Ask a team vault" },
|
|
196
|
-
},
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
const
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
:
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
if (
|
|
286
|
-
if (
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
);
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
return
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
const
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
);
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
if (
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
}
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
return
|
|
436
|
-
}
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
return
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
}
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
}
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
const
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
}
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
})
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// Popover MCP server — lets an agent see and ask its teammates' agents.
|
|
3
|
+
//
|
|
4
|
+
// Implemented directly against the JSON-RPC stdio protocol rather than the MCP SDK. The
|
|
5
|
+
// plugin is distributed through a marketplace and installed into a cache directory where
|
|
6
|
+
// dependency installation is conditional and can fail; a server with zero dependencies
|
|
7
|
+
// simply cannot fail that way. The protocol surface we need is small — initialize,
|
|
8
|
+
// tools/list, tools/call — so the SDK buys us little here.
|
|
9
|
+
//
|
|
10
|
+
// All real work happens in the daemon. This process is a thin bridge to it.
|
|
11
|
+
|
|
12
|
+
import { readFileSync } from "node:fs";
|
|
13
|
+
import { callerSessionId, request } from "../scripts/_ipc.mjs";
|
|
14
|
+
|
|
15
|
+
const PROTOCOL_VERSION = "2025-06-18";
|
|
16
|
+
|
|
17
|
+
// Read from the plugin manifest, which Claude Code copies into its cache alongside this
|
|
18
|
+
// file — so the relative path survives the severing copy that breaks everything else.
|
|
19
|
+
const SERVER_INFO = {
|
|
20
|
+
name: "popover",
|
|
21
|
+
version: JSON.parse(
|
|
22
|
+
readFileSync(new URL("../.claude-plugin/plugin.json", import.meta.url), "utf8"),
|
|
23
|
+
).version,
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
const TOOLS = [
|
|
28
|
+
{
|
|
29
|
+
name: "team_list",
|
|
30
|
+
description:
|
|
31
|
+
"List your teammates' currently-active Claude Code agents in THIS repo: who owns " +
|
|
32
|
+
"each one, what it is doing right now, and its short handle (e.g. B1). Only agents " +
|
|
33
|
+
"working in the same repository as you are visible — agents your teammates are " +
|
|
34
|
+
"running in other repos are not listed and cannot be asked. Use this before " +
|
|
35
|
+
"team_ask to find out which agent to ask. Read-only.",
|
|
36
|
+
inputSchema: { type: "object", properties: {}, additionalProperties: false },
|
|
37
|
+
annotations: { readOnlyHint: true, openWorldHint: true, title: "List team agents" },
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
name: "team_ask",
|
|
41
|
+
description:
|
|
42
|
+
"Ask a teammate's Claude Code agent a question and wait for the answer. A " +
|
|
43
|
+
"read-only copy of that agent answers from its full accumulated context; the " +
|
|
44
|
+
"teammate's live session is never interrupted or modified. Use this when a " +
|
|
45
|
+
"teammate's agent already knows something that would take you a long time to " +
|
|
46
|
+
"work out — why a decision was made, what they already ruled out, how a service " +
|
|
47
|
+
"they own behaves. Only agents working in the same repository as you can be asked. " +
|
|
48
|
+
"Answering costs the teammate tokens and takes up to ~90s, so ask one well-formed " +
|
|
49
|
+
"question rather than several exploratory ones.",
|
|
50
|
+
inputSchema: {
|
|
51
|
+
type: "object",
|
|
52
|
+
properties: {
|
|
53
|
+
target: {
|
|
54
|
+
type: "string",
|
|
55
|
+
description:
|
|
56
|
+
"Which agent to ask: a handle from team_list such as 'B1', or a teammate's " +
|
|
57
|
+
"name, or a repo name.",
|
|
58
|
+
},
|
|
59
|
+
question: {
|
|
60
|
+
type: "string",
|
|
61
|
+
description:
|
|
62
|
+
"A self-contained question. The answering agent has none of your " +
|
|
63
|
+
"conversation's context, so expand pronouns and vague references.",
|
|
64
|
+
},
|
|
65
|
+
timeout_seconds: {
|
|
66
|
+
type: "number",
|
|
67
|
+
description: "How long to wait for an answer. Default 90, max 300.",
|
|
68
|
+
minimum: 5,
|
|
69
|
+
maximum: 300,
|
|
70
|
+
},
|
|
71
|
+
},
|
|
72
|
+
required: ["target", "question"],
|
|
73
|
+
additionalProperties: false,
|
|
74
|
+
},
|
|
75
|
+
annotations: { readOnlyHint: true, openWorldHint: true, title: "Ask a teammate's agent" },
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
name: "team_tell",
|
|
79
|
+
description:
|
|
80
|
+
"Send a short heads-up to a teammate's agent working in this repo. Unlike team_ask " +
|
|
81
|
+
"there is no answer: the message is delivered into that agent's context before its " +
|
|
82
|
+
"next prompt, and nothing comes back. Use it for facts about shared state that would " +
|
|
83
|
+
"otherwise cause a collision — \"the migration is applied on prod\", \"I am rewriting " +
|
|
84
|
+
"globals.css, leave it alone\". Do not use it to give another agent instructions or " +
|
|
85
|
+
"assign it work: the receiving agent is told to treat your message as information " +
|
|
86
|
+
"from outside its conversation, not as a directive, and its user is notified that you " +
|
|
87
|
+
"sent it. Only agents in the same repository can be told, and you are limited to 10 " +
|
|
88
|
+
"messages an hour to any one agent.",
|
|
89
|
+
inputSchema: {
|
|
90
|
+
type: "object",
|
|
91
|
+
properties: {
|
|
92
|
+
target: {
|
|
93
|
+
type: "string",
|
|
94
|
+
description:
|
|
95
|
+
"Which agent to tell: a handle from team_list such as 'B1', or a teammate's " +
|
|
96
|
+
"name, or a repo name.",
|
|
97
|
+
},
|
|
98
|
+
message: {
|
|
99
|
+
type: "string",
|
|
100
|
+
description:
|
|
101
|
+
"The heads-up, in one or two sentences. It arrives with no context of its own, " +
|
|
102
|
+
"so name the thing you are talking about rather than referring to it.",
|
|
103
|
+
},
|
|
104
|
+
},
|
|
105
|
+
required: ["target", "message"],
|
|
106
|
+
additionalProperties: false,
|
|
107
|
+
},
|
|
108
|
+
// Not read-only: this writes into someone else's context and notifies a person.
|
|
109
|
+
annotations: { readOnlyHint: false, openWorldHint: true, title: "Tell a teammate's agent" },
|
|
110
|
+
},
|
|
111
|
+
{
|
|
112
|
+
name: "vault_search",
|
|
113
|
+
description:
|
|
114
|
+
"Search your team's vaults. A vault is a conversation somebody on your team froze " +
|
|
115
|
+
"deliberately and published: it does not expire, it is not a live session, and its " +
|
|
116
|
+
"author does not have to be online — or still at the company — for you to use it. " +
|
|
117
|
+
"This searches the index only. It is free, it runs no model, it resumes nothing, and " +
|
|
118
|
+
"it costs neither you nor anybody else a token, so use it freely. Each result carries " +
|
|
119
|
+
"the questions that vault says it can answer, when it was frozen, who froze it, and " +
|
|
120
|
+
"how much of the code it discussed has changed since — a vault whose files nobody has " +
|
|
121
|
+
"touched is current however old it is, and one whose files have churned is suspect " +
|
|
122
|
+
"even if it is recent. Unlike team_list this is not limited to agents in your repo or " +
|
|
123
|
+
"to people who are working right now: every vault on every team you belong to is " +
|
|
124
|
+
"searchable. ALWAYS call this before vault_ask, and read what comes back: asking is " +
|
|
125
|
+
"the expensive half and this is how you spend it on the right vault.",
|
|
126
|
+
inputSchema: {
|
|
127
|
+
type: "object",
|
|
128
|
+
properties: {
|
|
129
|
+
query: {
|
|
130
|
+
type: "string",
|
|
131
|
+
description:
|
|
132
|
+
"What you want to know, phrased as a question. Vaults are indexed by the " +
|
|
133
|
+
"questions they can answer rather than by a summary, so a question matches far " +
|
|
134
|
+
"better than keywords do. Omit it to list the most recently frozen vaults.",
|
|
135
|
+
},
|
|
136
|
+
repo: {
|
|
137
|
+
type: "string",
|
|
138
|
+
description:
|
|
139
|
+
"Narrow to one repo label. Display-level filtering only — vaults are visible " +
|
|
140
|
+
"across every repo your team works in, so leave this off unless the user asked " +
|
|
141
|
+
"for one repo specifically.",
|
|
142
|
+
},
|
|
143
|
+
limit: {
|
|
144
|
+
type: "number",
|
|
145
|
+
description: "How many to return. Default 20, max 50.",
|
|
146
|
+
minimum: 1,
|
|
147
|
+
maximum: 50,
|
|
148
|
+
},
|
|
149
|
+
},
|
|
150
|
+
additionalProperties: false,
|
|
151
|
+
},
|
|
152
|
+
annotations: { readOnlyHint: true, openWorldHint: true, title: "Search team vaults" },
|
|
153
|
+
},
|
|
154
|
+
{
|
|
155
|
+
name: "vault_ask",
|
|
156
|
+
description:
|
|
157
|
+
"Ask one vault one question and wait for the answer. **This costs a full context " +
|
|
158
|
+
"load and real money** — the frozen conversation is resumed in its entirety on THIS " +
|
|
159
|
+
"machine, on your user's account, at roughly $0.50 and up to 90 seconds per call. " +
|
|
160
|
+
"Call vault_search first and ask the one vault that fits; never fan out across " +
|
|
161
|
+
"several to see which answers best, and never call this on a vault you have not seen " +
|
|
162
|
+
"in a search result. The vault answers from its frozen context and has no tools at " +
|
|
163
|
+
"all: it cannot read a file, run a command, or look at the repository as it stands " +
|
|
164
|
+
"today, which is deliberate — it is authoritative about what was decided and why, and " +
|
|
165
|
+
"explicitly unreliable about what the code currently looks like. Report what comes " +
|
|
166
|
+
"back as the vault's claim, attributed and dated, never as a bare fact merged into " +
|
|
167
|
+
"your own reasoning: a vault can hold a hypothesis the team later disproved. Nothing " +
|
|
168
|
+
"you do here reaches the vault's author, changes the vault, or costs them anything.",
|
|
169
|
+
inputSchema: {
|
|
170
|
+
type: "object",
|
|
171
|
+
properties: {
|
|
172
|
+
vault_id: {
|
|
173
|
+
type: "string",
|
|
174
|
+
description: "The `id` of a vault from a vault_search result. Never guess one.",
|
|
175
|
+
},
|
|
176
|
+
question: {
|
|
177
|
+
type: "string",
|
|
178
|
+
description:
|
|
179
|
+
"A self-contained question. The vault has none of your conversation and has " +
|
|
180
|
+
"been frozen for weeks or months, so expand every pronoun, name files by path, " +
|
|
181
|
+
"and ask about decisions and reasoning rather than about the current code.",
|
|
182
|
+
},
|
|
183
|
+
timeout_seconds: {
|
|
184
|
+
type: "number",
|
|
185
|
+
description: "How long to wait for an answer. Default 90, max 300.",
|
|
186
|
+
minimum: 5,
|
|
187
|
+
maximum: 300,
|
|
188
|
+
},
|
|
189
|
+
},
|
|
190
|
+
required: ["vault_id", "question"],
|
|
191
|
+
additionalProperties: false,
|
|
192
|
+
},
|
|
193
|
+
// Read-only: it resumes a copy and writes nothing back. It is not free, which the
|
|
194
|
+
// description says at length, because an annotation cannot say "and it costs money".
|
|
195
|
+
annotations: { readOnlyHint: true, openWorldHint: true, title: "Ask a team vault" },
|
|
196
|
+
},
|
|
197
|
+
{
|
|
198
|
+
name: "vault_create",
|
|
199
|
+
description:
|
|
200
|
+
"Publish this conversation to your team's vault. This writes: it uploads the whole " +
|
|
201
|
+
"conversation — every message, and the contents of every file read into it — where " +
|
|
202
|
+
"everyone on the team can search it and ask it, permanently. It does not expire, it " +
|
|
203
|
+
"cannot be edited afterwards, and it is not sent to one named person: it goes to the " +
|
|
204
|
+
"team. **A vault is readable by the popover service.** That is the one way it differs " +
|
|
205
|
+
"from /popover:fork, which is end-to-end encrypted and which the service cannot read; " +
|
|
206
|
+
"do not describe a vault as if it made the same promise, and say so plainly if you " +
|
|
207
|
+
"tell the user you have vaulted something. You may call this on your own judgement " +
|
|
208
|
+
"rather than waiting to be asked — the moment worth vaulting is usually one the user " +
|
|
209
|
+
"is too deep in the work to notice, and a conversation nobody vaults is deleted when " +
|
|
210
|
+
"the session ends. But judge it as a real disclosure and not as a cheap call: vault a " +
|
|
211
|
+
"conversation that worked something out the team will want and the repository will " +
|
|
212
|
+
"not record — a decision and the reasons behind it, an approach that was tried and " +
|
|
213
|
+
"rejected, an investigation into why something is the way it is. Do not vault routine " +
|
|
214
|
+
"work, and do not vault the same session twice.",
|
|
215
|
+
inputSchema: {
|
|
216
|
+
type: "object",
|
|
217
|
+
properties: {
|
|
218
|
+
title: {
|
|
219
|
+
type: "string",
|
|
220
|
+
description:
|
|
221
|
+
"A short human label, 3 to 120 characters. It is what a teammate reads on a card " +
|
|
222
|
+
"in a grid, so name the subject rather than the activity: 'Why the repo key does " +
|
|
223
|
+
"not gate vaults', not 'vault work'.",
|
|
224
|
+
},
|
|
225
|
+
answers: {
|
|
226
|
+
type: "array",
|
|
227
|
+
items: { type: "string" },
|
|
228
|
+
description:
|
|
229
|
+
"Questions this conversation can answer — NOT a summary of what happened. This " +
|
|
230
|
+
"is the retrieval surface: the query that finds this vault later will itself be " +
|
|
231
|
+
"a question, and matching a question against a summary retrieves badly where " +
|
|
232
|
+
"question against question does not. Write each one the way a teammate would " +
|
|
233
|
+
"type it months from now, in full: 'Why did we reject the repo key as a vault " +
|
|
234
|
+
"credential?', not 'discussed encryption'. Three to six is right; each is 8 to " +
|
|
235
|
+
"200 characters and there can be at most 12. This is the field that decides " +
|
|
236
|
+
"whether the vault is ever found again, and it cannot be edited afterwards.",
|
|
237
|
+
minItems: 1,
|
|
238
|
+
maxItems: 12,
|
|
239
|
+
},
|
|
240
|
+
name: {
|
|
241
|
+
type: "string",
|
|
242
|
+
description:
|
|
243
|
+
"Optional slug, lowercase letters, digits and hyphens. It appears in URLs and in " +
|
|
244
|
+
"the command teammates type. Derived from the title when omitted, which is " +
|
|
245
|
+
"usually right — pass one only when the title makes an awkward slug or when a " +
|
|
246
|
+
"name collision has been reported.",
|
|
247
|
+
},
|
|
248
|
+
},
|
|
249
|
+
required: ["title", "answers"],
|
|
250
|
+
additionalProperties: false,
|
|
251
|
+
},
|
|
252
|
+
// Not read-only, and the only vault tool that is not. This publishes a conversation to a
|
|
253
|
+
// whole team, permanently, and there is no edit and no undo — `archive` retires a vault
|
|
254
|
+
// without erasing the record that it was made.
|
|
255
|
+
annotations: {
|
|
256
|
+
readOnlyHint: false,
|
|
257
|
+
openWorldHint: true,
|
|
258
|
+
title: "Publish this conversation to the team",
|
|
259
|
+
},
|
|
260
|
+
},
|
|
261
|
+
];
|
|
262
|
+
|
|
263
|
+
// ---------------------------------------------------------------------------
|
|
264
|
+
// Tool implementations
|
|
265
|
+
// ---------------------------------------------------------------------------
|
|
266
|
+
|
|
267
|
+
async function callTeamList() {
|
|
268
|
+
// Sent so the daemon can mark which line is this agent's own, and so it can scope the
|
|
269
|
+
// roster to the repo this session is working in. Absent outside a session, in which case
|
|
270
|
+
// the roster comes back unmarked rather than failing.
|
|
271
|
+
const reply = await request(
|
|
272
|
+
{
|
|
273
|
+
t: "roster",
|
|
274
|
+
id: rpcId(),
|
|
275
|
+
refresh: true,
|
|
276
|
+
...(callerSessionId() ? { fromSessionId: callerSessionId() } : {}),
|
|
277
|
+
// Fallback for the narrow window where the daemon has not seen this session yet. The
|
|
278
|
+
// session is authoritative when known; this is only ever consulted when it is not.
|
|
279
|
+
cwd: process.cwd(),
|
|
280
|
+
},
|
|
281
|
+
{ timeoutMs: 15000 },
|
|
282
|
+
);
|
|
283
|
+
|
|
284
|
+
if (!reply) return errorText(daemonDownMessage());
|
|
285
|
+
if (reply.t === "error") return errorText(explain(reply));
|
|
286
|
+
if (reply.t !== "roster.ok") return errorText("The popover daemon returned an unexpected response.");
|
|
287
|
+
|
|
288
|
+
if (!reply.entries || reply.entries.length === 0) {
|
|
289
|
+
// The daemon's own text, because only it knows whether the answer is "nobody on your
|
|
290
|
+
// team is working" or "nobody is working in this repo" — and those lead a model to say
|
|
291
|
+
// very different things.
|
|
292
|
+
return text(
|
|
293
|
+
reply.rendered ||
|
|
294
|
+
"No teammates currently have active Claude Code sessions. Nobody is available to ask right now.",
|
|
295
|
+
);
|
|
296
|
+
}
|
|
297
|
+
// Returned as text rather than structuredContent on purpose: setting
|
|
298
|
+
// structuredContent suppresses text blocks, and the rendered table is both easier for
|
|
299
|
+
// the model to read and directly presentable to the user.
|
|
300
|
+
return text(reply.rendered);
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
async function callTeamAsk(args) {
|
|
304
|
+
const target = typeof args?.target === "string" ? args.target.trim() : "";
|
|
305
|
+
const question = typeof args?.question === "string" ? args.question.trim() : "";
|
|
306
|
+
|
|
307
|
+
if (!target) return errorText("`target` is required — call team_list to see the options.");
|
|
308
|
+
if (!question) return errorText("`question` is required.");
|
|
309
|
+
|
|
310
|
+
const timeoutSeconds = clamp(Number(args?.timeout_seconds) || 90, 5, 300);
|
|
311
|
+
|
|
312
|
+
const reply = await request(
|
|
313
|
+
{
|
|
314
|
+
t: "ask",
|
|
315
|
+
id: rpcId(),
|
|
316
|
+
req: {
|
|
317
|
+
target,
|
|
318
|
+
question,
|
|
319
|
+
timeoutSeconds,
|
|
320
|
+
// Lets the audit log show that an agent asked, not a human, and scopes the target
|
|
321
|
+
// to this session's repo.
|
|
322
|
+
...(callerSessionId() ? { fromSessionId: callerSessionId() } : {}),
|
|
323
|
+
},
|
|
324
|
+
cwd: process.cwd(),
|
|
325
|
+
},
|
|
326
|
+
// Outlast the daemon's own wait so its specific error wins over a generic timeout.
|
|
327
|
+
{ timeoutMs: timeoutSeconds * 1000 + 15000 },
|
|
328
|
+
);
|
|
329
|
+
|
|
330
|
+
if (!reply) return errorText(daemonDownMessage());
|
|
331
|
+
if (reply.t === "error") return errorText(explain(reply));
|
|
332
|
+
if (reply.t !== "ask.ok") return errorText("The popover daemon returned an unexpected response.");
|
|
333
|
+
|
|
334
|
+
const { answer } = reply;
|
|
335
|
+
const by = answer.answeredBy;
|
|
336
|
+
const attribution = by ? `${by.handle} (${by.ownerName}, ${by.repo})` : "a teammate's agent";
|
|
337
|
+
const cost =
|
|
338
|
+
answer.costUsd != null && answer.durationMs != null
|
|
339
|
+
? `\n\n_(answered in ${(answer.durationMs / 1000).toFixed(1)}s, cost $${answer.costUsd.toFixed(3)} on their account)_`
|
|
340
|
+
: "";
|
|
341
|
+
|
|
342
|
+
return text(`Answer from ${attribution}:\n\n${answer.answer}${cost}`);
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
async function callTeamTell(args) {
|
|
346
|
+
const target = typeof args?.target === "string" ? args.target.trim() : "";
|
|
347
|
+
const message = typeof args?.message === "string" ? args.message.trim() : "";
|
|
348
|
+
|
|
349
|
+
if (!target) return errorText("`target` is required — call team_list to see the options.");
|
|
350
|
+
if (!message) return errorText("`message` is required.");
|
|
351
|
+
|
|
352
|
+
const reply = await request(
|
|
353
|
+
{
|
|
354
|
+
t: "tell",
|
|
355
|
+
id: rpcId(),
|
|
356
|
+
req: {
|
|
357
|
+
target,
|
|
358
|
+
message,
|
|
359
|
+
...(callerSessionId() ? { fromSessionId: callerSessionId() } : {}),
|
|
360
|
+
},
|
|
361
|
+
cwd: process.cwd(),
|
|
362
|
+
},
|
|
363
|
+
{ timeoutMs: 15000 },
|
|
364
|
+
);
|
|
365
|
+
|
|
366
|
+
if (!reply) return errorText(daemonDownMessage());
|
|
367
|
+
if (reply.t === "error") return errorText(explain(reply));
|
|
368
|
+
if (reply.t !== "tell.ok") return errorText("The popover daemon returned an unexpected response.");
|
|
369
|
+
|
|
370
|
+
// Says delivered-to, never read-by: a sender is deliberately told nothing about what
|
|
371
|
+
// happened to their message afterwards.
|
|
372
|
+
return text(
|
|
373
|
+
`Sent to ${reply.handle} (${reply.ownerName}). It will reach that agent before its next ` +
|
|
374
|
+
`prompt; there is no reply.`,
|
|
375
|
+
);
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
// ---------------------------------------------------------------------------
|
|
379
|
+
// Vaults — the cheap half and the costly half, deliberately two tools
|
|
380
|
+
// ---------------------------------------------------------------------------
|
|
381
|
+
|
|
382
|
+
async function callVaultSearch(args) {
|
|
383
|
+
const query = typeof args?.query === "string" ? args.query.trim() : "";
|
|
384
|
+
const repo = typeof args?.repo === "string" ? args.repo.trim() : "";
|
|
385
|
+
const limit = clamp(Number(args?.limit) || 20, 1, 50);
|
|
386
|
+
|
|
387
|
+
const reply = await request(
|
|
388
|
+
{
|
|
389
|
+
t: "vaults",
|
|
390
|
+
id: rpcId(),
|
|
391
|
+
req: {
|
|
392
|
+
limit,
|
|
393
|
+
...(query ? { query } : {}),
|
|
394
|
+
...(repo ? { repo } : {}),
|
|
395
|
+
},
|
|
396
|
+
// Not a filter. The daemon uses it to diff each vault's files against the tree in front
|
|
397
|
+
// of you, which is what the staleness figure in each result is.
|
|
398
|
+
cwd: process.cwd(),
|
|
399
|
+
},
|
|
400
|
+
{ timeoutMs: 20000 },
|
|
401
|
+
);
|
|
402
|
+
|
|
403
|
+
if (!reply) return errorText(daemonDownMessage());
|
|
404
|
+
if (reply.t === "error") return errorText(explain(reply));
|
|
405
|
+
if (reply.t !== "vaults.ok") return errorText("The popover daemon returned an unexpected response.");
|
|
406
|
+
|
|
407
|
+
const vaults = reply.vaults ?? [];
|
|
408
|
+
if (vaults.length === 0) {
|
|
409
|
+
return text(
|
|
410
|
+
query
|
|
411
|
+
? `No vault on your teams answers anything like "${query}". Nothing was spent looking. ` +
|
|
412
|
+
"Do not call vault_ask — there is no vault to ask."
|
|
413
|
+
: "Your teams have not published any vaults yet.",
|
|
414
|
+
);
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
const lines = vaults.map((vault, index) => {
|
|
418
|
+
const facts = [
|
|
419
|
+
vault.authorLabel,
|
|
420
|
+
`frozen ${friendlyDate(vault.frozenAt)}`,
|
|
421
|
+
vault.repoLabel ? `repo ${vault.repoLabel}` : null,
|
|
422
|
+
vault.noteCount > 0 ? `${vault.noteCount} note${vault.noteCount === 1 ? "" : "s"}` : null,
|
|
423
|
+
describeStaleness(vault.staleness),
|
|
424
|
+
].filter(Boolean);
|
|
425
|
+
|
|
426
|
+
const answers = (vault.answers ?? []).map((a) => ` - ${a}`).join("\n");
|
|
427
|
+
return (
|
|
428
|
+
`${index + 1}. ${vault.title} (${vault.name})\n` +
|
|
429
|
+
` id: ${vault.id}\n` +
|
|
430
|
+
` ${facts.join(" · ")}\n` +
|
|
431
|
+
(answers ? ` Says it can answer:\n${answers}\n` : "")
|
|
432
|
+
);
|
|
433
|
+
});
|
|
434
|
+
|
|
435
|
+
return text(
|
|
436
|
+
`${vaults.length} vault${vaults.length === 1 ? "" : "s"} on your teams:\n\n` +
|
|
437
|
+
lines.join("\n") +
|
|
438
|
+
"\nThis search cost nothing. Asking one of these costs a full context load and real " +
|
|
439
|
+
"money on your user's account, so pick the single best fit — or none, if none of them " +
|
|
440
|
+
"claims to answer the question.",
|
|
441
|
+
);
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
async function callVaultAsk(args) {
|
|
445
|
+
const vaultId = typeof args?.vault_id === "string" ? args.vault_id.trim() : "";
|
|
446
|
+
const question = typeof args?.question === "string" ? args.question.trim() : "";
|
|
447
|
+
|
|
448
|
+
if (!vaultId) return errorText("`vault_id` is required — call vault_search to find one.");
|
|
449
|
+
if (!question) return errorText("`question` is required.");
|
|
450
|
+
|
|
451
|
+
const timeoutSeconds = clamp(Number(args?.timeout_seconds) || 90, 5, 300);
|
|
452
|
+
|
|
453
|
+
const reply = await request(
|
|
454
|
+
{
|
|
455
|
+
t: "vaultAsk",
|
|
456
|
+
id: rpcId(),
|
|
457
|
+
req: {
|
|
458
|
+
vaultId,
|
|
459
|
+
question,
|
|
460
|
+
timeoutSeconds,
|
|
461
|
+
// Carries the per-session budget. Without it the daemon cannot tell one agent asking
|
|
462
|
+
// six vaults from six agents asking one each.
|
|
463
|
+
...(callerSessionId() ? { fromSessionId: callerSessionId() } : {}),
|
|
464
|
+
},
|
|
465
|
+
cwd: process.cwd(),
|
|
466
|
+
},
|
|
467
|
+
// Outlast the daemon's own wait so its specific error wins over a generic timeout.
|
|
468
|
+
{ timeoutMs: timeoutSeconds * 1000 + 15000 },
|
|
469
|
+
);
|
|
470
|
+
|
|
471
|
+
if (!reply) return errorText(daemonDownMessage());
|
|
472
|
+
if (reply.t === "error") return errorText(explain(reply));
|
|
473
|
+
if (reply.t !== "vaultAsk.ok") return errorText("The popover daemon returned an unexpected response.");
|
|
474
|
+
|
|
475
|
+
const { answer } = reply;
|
|
476
|
+
// Attribution first, and not optional. A human reading a vault's answer supplies the
|
|
477
|
+
// skepticism unprompted; a model will not unless the format forces it, and a vault can hold
|
|
478
|
+
// a hypothesis the team later disproved.
|
|
479
|
+
const at = answer.gitSha ? ` at commit ${answer.gitSha}` : "";
|
|
480
|
+
const cost =
|
|
481
|
+
answer.costUsd != null && answer.durationMs != null
|
|
482
|
+
? ` Answered in ${(answer.durationMs / 1000).toFixed(1)}s, cost $${answer.costUsd.toFixed(3)} on your own account.`
|
|
483
|
+
: "";
|
|
484
|
+
|
|
485
|
+
return text(
|
|
486
|
+
`The "${answer.title}" vault, frozen ${friendlyDate(answer.frozenAt)}${at}, says:\n\n` +
|
|
487
|
+
`${answer.answer}\n\n` +
|
|
488
|
+
`_(That is a frozen conversation, not the current code. Treat it as authoritative ` +
|
|
489
|
+
`about what was decided and why, and check anything it says about how the repository ` +
|
|
490
|
+
`looks today. Attribute it to the vault when you pass it on.${cost})_`,
|
|
491
|
+
);
|
|
492
|
+
}
|
|
493
|
+
|
|
494
|
+
/**
|
|
495
|
+
* Publish this conversation. The one tool here that writes something permanent.
|
|
496
|
+
*
|
|
497
|
+
* ## Why this is an IPC verb and not `popover vault create`
|
|
498
|
+
*
|
|
499
|
+
* The pipeline it drives is the CLI's, tested and unchanged — find the transcript, settle it,
|
|
500
|
+
* sanitize, collect touched paths, upload. The obvious implementation is therefore to spawn
|
|
501
|
+
* `popover vault create --json` and relay what it prints. It is not what happens, and the
|
|
502
|
+
* reason is Windows.
|
|
503
|
+
*
|
|
504
|
+
* `popover` on Windows is a `.cmd` shim, and Node refuses to spawn a `.cmd` without a shell.
|
|
505
|
+
* With `shell: true` the arguments are pasted into a `cmd.exe` command line, where `&`, `|`,
|
|
506
|
+
* `^` and `>` are operators — and every argument here is written by a model: a title, a list
|
|
507
|
+
* of questions, a slug. That is untrusted-input-into-a-shell, on the machine this is being
|
|
508
|
+
* built on, to save a wire format. The escape hatches are worse than the problem: locating the
|
|
509
|
+
* CLI's real `.js` inside the shim is guesswork about npm's layout, and hand-quoting for
|
|
510
|
+
* `cmd.exe` is a thing to get wrong quietly.
|
|
511
|
+
*
|
|
512
|
+
* So it goes over the pipe the other four tools already use. The daemon needs nothing new to
|
|
513
|
+
* be reachable, holds the device token already, and already POSTs to the vault routes; the
|
|
514
|
+
* shared decisions — `planVault`, `collectToolPaths`, `packBody` — moved into
|
|
515
|
+
* @popoverinstall/shared so the terminal and the daemon build byte-identical payloads. No
|
|
516
|
+
* child process, nothing to quote, and the same code path on every platform.
|
|
517
|
+
*/
|
|
518
|
+
async function callVaultCreate(args) {
|
|
519
|
+
const title = typeof args?.title === "string" ? args.title.trim() : "";
|
|
520
|
+
const name = typeof args?.name === "string" ? args.name.trim() : "";
|
|
521
|
+
const answers = Array.isArray(args?.answers)
|
|
522
|
+
? args.answers.filter((a) => typeof a === "string" && a.trim()).map((a) => a.trim())
|
|
523
|
+
: [];
|
|
524
|
+
|
|
525
|
+
if (!title) return errorText("`title` is required — a vault needs a short human label.");
|
|
526
|
+
if (answers.length === 0) {
|
|
527
|
+
return errorText(
|
|
528
|
+
"`answers` is required, and it holds questions this conversation can answer rather " +
|
|
529
|
+
"than a summary of it. A vault with no questions is one nobody will ever find.",
|
|
530
|
+
);
|
|
531
|
+
}
|
|
532
|
+
|
|
533
|
+
// Never from the model. The session being frozen is the one this process belongs to, and a
|
|
534
|
+
// caller that could name any session could publish a conversation it was never part of.
|
|
535
|
+
const sessionId = callerSessionId();
|
|
536
|
+
if (!sessionId) {
|
|
537
|
+
return errorText(
|
|
538
|
+
"There is no Claude Code session here to vault. This tool freezes the conversation it " +
|
|
539
|
+
"is running inside, and outside a session there is nothing to freeze.",
|
|
540
|
+
);
|
|
541
|
+
}
|
|
542
|
+
|
|
543
|
+
const reply = await request(
|
|
544
|
+
{
|
|
545
|
+
t: "vaultCreate",
|
|
546
|
+
id: rpcId(),
|
|
547
|
+
req: { sessionId, title, answers, ...(name ? { name } : {}) },
|
|
548
|
+
// Where git runs: it decides the recorded commit and the uncommitted half of the
|
|
549
|
+
// touched-path list. Not a filter, and never a permission.
|
|
550
|
+
cwd: process.cwd(),
|
|
551
|
+
},
|
|
552
|
+
// Generous: the daemon waits for the transcript to stop moving, runs git, and then
|
|
553
|
+
// uploads a whole gzipped conversation, which is megabytes rather than bytes.
|
|
554
|
+
{ timeoutMs: 60000 },
|
|
555
|
+
);
|
|
556
|
+
|
|
557
|
+
// Not `daemonDownMessage()`. Silence here has a second cause the other tools do not have:
|
|
558
|
+
// a daemon older than this plugin does not know the verb, and drops a request its schema
|
|
559
|
+
// refuses without answering it. Telling somebody to start a daemon that is already running
|
|
560
|
+
// sends them after the wrong problem, so both possibilities are named and neither is
|
|
561
|
+
// asserted. Nothing was published either way — the upload is the last thing that happens.
|
|
562
|
+
if (!reply) {
|
|
563
|
+
return errorText(
|
|
564
|
+
"The popover daemon did not answer, so nothing was published. Either it is not " +
|
|
565
|
+
"running on this machine, or it is older than this plugin and does not know how to " +
|
|
566
|
+
"publish a vault. Run `popover doctor` to find out which, and `popover update` if it " +
|
|
567
|
+
"is the second.",
|
|
568
|
+
);
|
|
569
|
+
}
|
|
570
|
+
if (reply.t === "error") return errorText(explain(reply));
|
|
571
|
+
if (reply.t !== "vaultCreate.ok") {
|
|
572
|
+
return errorText("The popover daemon returned an unexpected response.");
|
|
573
|
+
}
|
|
574
|
+
|
|
575
|
+
const vault = reply.vault;
|
|
576
|
+
const answered = (vault.answers ?? []).map((a) => ` - ${a}`).join("\n");
|
|
577
|
+
const sha = vault.gitSha ? ` at commit ${vault.gitSha.slice(0, 7)}` : "";
|
|
578
|
+
|
|
579
|
+
return text(
|
|
580
|
+
`Published "${vault.title}" to your team as \`${vault.name}\`.\n\n` +
|
|
581
|
+
`${vault.entryCount} messages, frozen at the last completed turn ` +
|
|
582
|
+
`(${friendlyDate(vault.frozenAt)}${sha}). Nothing said from here is in it.\n\n` +
|
|
583
|
+
`It says it can answer:\n${answered}\n\n` +
|
|
584
|
+
`Anyone on the team can ask it, on their own machine and at their own cost:\n` +
|
|
585
|
+
` popover vault ask ${vault.name} "…"\n\n` +
|
|
586
|
+
// Said every time, in the same register the CLI's confirmation uses. Anyone who has
|
|
587
|
+
// internalized /popover:fork being end-to-end will assume this is too, and it is not.
|
|
588
|
+
`Tell the user you did this, and tell them plainly that a vault is readable by the ` +
|
|
589
|
+
`popover service — a fork is end-to-end and this is not. It does not expire and cannot ` +
|
|
590
|
+
`be edited; \`popover vault archive ${vault.name}\` retires it without erasing the ` +
|
|
591
|
+
`record that it was made.`,
|
|
592
|
+
);
|
|
593
|
+
}
|
|
594
|
+
|
|
595
|
+
/** ISO timestamp to something a person reads, without pulling in a formatter. */
|
|
596
|
+
function friendlyDate(iso) {
|
|
597
|
+
const at = new Date(iso);
|
|
598
|
+
if (Number.isNaN(at.getTime())) return iso;
|
|
599
|
+
const months = "Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec".split(" ");
|
|
600
|
+
return `${at.getUTCDate()} ${months[at.getUTCMonth()]} ${at.getUTCFullYear()}`;
|
|
601
|
+
}
|
|
602
|
+
|
|
603
|
+
/**
|
|
604
|
+
* The staleness figure in words.
|
|
605
|
+
*
|
|
606
|
+
* Absent when the daemon had no working tree to diff against, or the vault recorded no paths.
|
|
607
|
+
* Silence is correct there: "0% changed" and "we could not check" are different claims, and
|
|
608
|
+
* only one of them is evidence that the vault is still current.
|
|
609
|
+
*/
|
|
610
|
+
function describeStaleness(staleness) {
|
|
611
|
+
if (typeof staleness !== "number") return null;
|
|
612
|
+
if (staleness === 0) return "none of its files have changed since";
|
|
613
|
+
return `${Math.round(staleness * 100)}% of its files have changed since`;
|
|
614
|
+
}
|
|
615
|
+
|
|
616
|
+
/**
|
|
617
|
+
* The daemon's own words for a failure, plus whatever it said to do about it.
|
|
618
|
+
*
|
|
619
|
+
* `hints` arrives on refusals that have an answer — a title too short, a name already taken,
|
|
620
|
+
* a conversation over the size limit — and is relayed verbatim rather than summarised. Those
|
|
621
|
+
* sentences are the difference between a second attempt that works and one that fails
|
|
622
|
+
* identically, and they are written where the constraint is, which is not here.
|
|
623
|
+
*/
|
|
624
|
+
function explain(errorReply) {
|
|
625
|
+
const hints = Array.isArray(errorReply.hints) ? errorReply.hints.filter(Boolean) : [];
|
|
626
|
+
const said = describe(errorReply);
|
|
627
|
+
return hints.length ? `${said}\n\n${hints.join("\n")}` : said;
|
|
628
|
+
}
|
|
629
|
+
|
|
630
|
+
function describe(errorReply) {
|
|
631
|
+
switch (errorReply.code) {
|
|
632
|
+
// The daemon knows whether credentials are missing or merely unusable; relaying its
|
|
633
|
+
// message avoids telling an already signed-in user to sign in again.
|
|
634
|
+
case "not_authenticated":
|
|
635
|
+
case "target_offline":
|
|
636
|
+
case "unknown_target":
|
|
637
|
+
case "timeout":
|
|
638
|
+
case "fork_failed":
|
|
639
|
+
case "bad_request":
|
|
640
|
+
return errorReply.message;
|
|
641
|
+
// A vault that is gone is gone: they are never edited and never expire, so this means the
|
|
642
|
+
// id was wrong or it has been archived. Retrying it, or trying a neighbouring id, cannot
|
|
643
|
+
// help — searching again can.
|
|
644
|
+
case "vault_not_found":
|
|
645
|
+
return `${errorReply.message} Call vault_search again rather than trying another id.`;
|
|
646
|
+
case "cloud_unreachable":
|
|
647
|
+
return `Could not reach the popover backend: ${errorReply.message}`;
|
|
648
|
+
default:
|
|
649
|
+
return errorReply.message || "The request failed.";
|
|
650
|
+
}
|
|
651
|
+
}
|
|
652
|
+
|
|
653
|
+
function daemonDownMessage() {
|
|
654
|
+
return (
|
|
655
|
+
"The popover daemon is not running on this machine, so teammate agents are not " +
|
|
656
|
+
"reachable. Start it with `popover daemon start`, or run `popover doctor` to diagnose."
|
|
657
|
+
);
|
|
658
|
+
}
|
|
659
|
+
|
|
660
|
+
// ---------------------------------------------------------------------------
|
|
661
|
+
// JSON-RPC plumbing
|
|
662
|
+
// ---------------------------------------------------------------------------
|
|
663
|
+
|
|
664
|
+
function text(value) {
|
|
665
|
+
return { content: [{ type: "text", text: value }] };
|
|
666
|
+
}
|
|
667
|
+
|
|
668
|
+
function errorText(message) {
|
|
669
|
+
// isError tells the model the call failed while still handing it a readable reason,
|
|
670
|
+
// which is far more useful than a transport-level error.
|
|
671
|
+
return { content: [{ type: "text", text: message }], isError: true };
|
|
672
|
+
}
|
|
673
|
+
|
|
674
|
+
function clamp(n, lo, hi) {
|
|
675
|
+
return Number.isFinite(n) ? Math.min(hi, Math.max(lo, n)) : lo;
|
|
676
|
+
}
|
|
677
|
+
|
|
678
|
+
let counter = 0;
|
|
679
|
+
function rpcId() {
|
|
680
|
+
counter += 1;
|
|
681
|
+
return `mcp-${process.pid}-${counter}`;
|
|
682
|
+
}
|
|
683
|
+
|
|
684
|
+
function send(message) {
|
|
685
|
+
process.stdout.write(`${JSON.stringify(message)}\n`);
|
|
686
|
+
}
|
|
687
|
+
|
|
688
|
+
function reply(id, result) {
|
|
689
|
+
send({ jsonrpc: "2.0", id, result });
|
|
690
|
+
}
|
|
691
|
+
|
|
692
|
+
function replyError(id, code, message) {
|
|
693
|
+
send({ jsonrpc: "2.0", id, error: { code, message } });
|
|
694
|
+
}
|
|
695
|
+
|
|
696
|
+
async function handle(message) {
|
|
697
|
+
const { id, method, params } = message;
|
|
698
|
+
|
|
699
|
+
// Notifications have no id and must never be answered.
|
|
700
|
+
const isNotification = id === undefined || id === null;
|
|
701
|
+
|
|
702
|
+
switch (method) {
|
|
703
|
+
case "initialize":
|
|
704
|
+
return reply(id, {
|
|
705
|
+
protocolVersion: PROTOCOL_VERSION,
|
|
706
|
+
capabilities: { tools: {} },
|
|
707
|
+
serverInfo: SERVER_INFO,
|
|
708
|
+
});
|
|
709
|
+
|
|
710
|
+
case "notifications/initialized":
|
|
711
|
+
case "notifications/cancelled":
|
|
712
|
+
return;
|
|
713
|
+
|
|
714
|
+
case "ping":
|
|
715
|
+
return reply(id, {});
|
|
716
|
+
|
|
717
|
+
case "tools/list":
|
|
718
|
+
return reply(id, { tools: TOOLS });
|
|
719
|
+
|
|
720
|
+
case "tools/call": {
|
|
721
|
+
const name = params?.name;
|
|
722
|
+
try {
|
|
723
|
+
if (name === "team_list") return reply(id, await callTeamList());
|
|
724
|
+
if (name === "team_ask") return reply(id, await callTeamAsk(params?.arguments ?? {}));
|
|
725
|
+
if (name === "team_tell") return reply(id, await callTeamTell(params?.arguments ?? {}));
|
|
726
|
+
if (name === "vault_search") return reply(id, await callVaultSearch(params?.arguments ?? {}));
|
|
727
|
+
if (name === "vault_ask") return reply(id, await callVaultAsk(params?.arguments ?? {}));
|
|
728
|
+
if (name === "vault_create") return reply(id, await callVaultCreate(params?.arguments ?? {}));
|
|
729
|
+
return replyError(id, -32602, `Unknown tool: ${name}`);
|
|
730
|
+
} catch (err) {
|
|
731
|
+
// A thrown handler must not kill the server; report it as a failed tool call.
|
|
732
|
+
return reply(id, errorText(`popover failed: ${err?.message ?? String(err)}`));
|
|
733
|
+
}
|
|
734
|
+
}
|
|
735
|
+
|
|
736
|
+
default:
|
|
737
|
+
if (!isNotification) replyError(id, -32601, `Method not found: ${method}`);
|
|
738
|
+
return;
|
|
739
|
+
}
|
|
740
|
+
}
|
|
741
|
+
|
|
742
|
+
let buffer = "";
|
|
743
|
+
process.stdin.setEncoding("utf8");
|
|
744
|
+
process.stdin.on("data", (chunk) => {
|
|
745
|
+
buffer += chunk;
|
|
746
|
+
let idx = buffer.indexOf("\n");
|
|
747
|
+
while (idx !== -1) {
|
|
748
|
+
const line = buffer.slice(0, idx).trim();
|
|
749
|
+
buffer = buffer.slice(idx + 1);
|
|
750
|
+
if (line) {
|
|
751
|
+
let message;
|
|
752
|
+
try {
|
|
753
|
+
message = JSON.parse(line);
|
|
754
|
+
} catch {
|
|
755
|
+
idx = buffer.indexOf("\n");
|
|
756
|
+
continue;
|
|
757
|
+
}
|
|
758
|
+
void handle(message);
|
|
759
|
+
}
|
|
760
|
+
idx = buffer.indexOf("\n");
|
|
761
|
+
}
|
|
762
|
+
});
|
|
763
|
+
|
|
764
|
+
process.stdin.on("end", () => process.exit(0));
|
|
765
|
+
process.on("uncaughtException", () => {});
|