@polygraph/codex-plugin 0.4.30 → 0.4.32

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.
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "polygraph",
3
- "version": "0.4.30",
3
+ "version": "0.4.32",
4
4
  "description": "AI agent skills and subagents for Polygraph multi-repo coordination",
5
5
  "author": {
6
6
  "name": "Narwhal Technologies Inc",
@@ -69,7 +69,8 @@ This returns:
69
69
  - `name`: Repository name
70
70
  - `repository`: Full repo name (e.g., `org/repo`)
71
71
  - `provider`: VCS provider (e.g., `GITHUB`)
72
- - `description`: AI-generated description of what the repository does (may be null)
72
+
73
+ Candidate entries do not include repository descriptions. For natural-language discovery, pass the user's intent in `semanticQuery` so the service can apply semantic matching internally.
73
74
 
74
75
  ### Step 2: Select Relevant Repos
75
76
 
@@ -79,8 +80,8 @@ If `selectedRepoIds` or exact repo refs were provided by the main agent, use tho
79
80
 
80
81
  Otherwise, analyze the candidates using the `userContext` to determine which repos are relevant:
81
82
 
82
- 1. Read each repo's `description`
83
- 2. Match repo descriptions against the `userContext` to identify relevant repos
83
+ 1. Review each repo's `repository`, `name`, `provider`, and any relationship/filter metadata returned by the tool
84
+ 2. Match those fields and any requested filters against the `userContext` to identify relevant repos
84
85
  3. Select the repos that are relevant to the task
85
86
  4. When uncertain, include all candidates
86
87
  5. When the user described the task in natural language and the result is large, re-query with `semanticQuery` set to that description
@@ -129,16 +130,16 @@ Return a structured summary in this format:
129
130
 
130
131
  ### Repositories in this session
131
132
 
132
- | Repo | Repository ID | Description | Relationship |
133
- | --- | --- | --- | --- |
134
- | REPO_FULL_NAME | REPOSITORY_ID | DESCRIPTION | DIRECTION (distance: N) |
133
+ | Repo | Repository ID | Relationship |
134
+ | --- | --- | --- |
135
+ | REPO_FULL_NAME | REPOSITORY_ID | DIRECTION (distance: N) |
135
136
 
136
137
  ### All Candidates Discovered
137
138
  (Only include this section if `list_repos` was called)
138
139
 
139
- | Repo | Repository ID | Description | Selected |
140
- | --- | --- | --- | --- |
141
- | REPO_FULL_NAME | REPOSITORY_ID | DESCRIPTION | Yes/No |
140
+ | Repo | Repository ID | Selected |
141
+ | --- | --- | --- |
142
+ | REPO_FULL_NAME | REPOSITORY_ID | Yes/No |
142
143
  ```
143
144
 
144
145
  ## Important Notes
@@ -13,839 +13,6 @@ import {
13
13
  import { homedir } from "node:os";
14
14
  import { dirname, join, relative, resolve, sep } from "node:path";
15
15
  import { fileURLToPath } from "node:url";
16
-
17
- // node_modules/smol-toml/dist/error.js
18
- function getLineColFromPtr(string, ptr) {
19
- let lines = string.slice(0, ptr).split(/\r\n|\n|\r/g);
20
- return [lines.length, lines.pop().length + 1];
21
- }
22
- function makeCodeBlock(string, line, column) {
23
- let lines = string.split(/\r\n|\n|\r/g);
24
- let codeblock = "";
25
- let numberLen = (Math.log10(line + 1) | 0) + 1;
26
- for (let i = line - 1; i <= line + 1; i++) {
27
- let l = lines[i - 1];
28
- if (!l)
29
- continue;
30
- codeblock += i.toString().padEnd(numberLen, " ");
31
- codeblock += ": ";
32
- codeblock += l;
33
- codeblock += "\n";
34
- if (i === line) {
35
- codeblock += " ".repeat(numberLen + column + 2);
36
- codeblock += "^\n";
37
- }
38
- }
39
- return codeblock;
40
- }
41
- var TomlError = class extends Error {
42
- line;
43
- column;
44
- codeblock;
45
- constructor(message, options) {
46
- const [line, column] = getLineColFromPtr(options.toml, options.ptr);
47
- const codeblock = makeCodeBlock(options.toml, line, column);
48
- super(`Invalid TOML document: ${message}
49
-
50
- ${codeblock}`, options);
51
- this.line = line;
52
- this.column = column;
53
- this.codeblock = codeblock;
54
- }
55
- };
56
-
57
- // node_modules/smol-toml/dist/util.js
58
- function isEscaped(str, ptr) {
59
- let i = 0;
60
- while (str[ptr - ++i] === "\\")
61
- ;
62
- return --i && i % 2;
63
- }
64
- function indexOfNewline(str, start = 0, end = str.length) {
65
- let idx = str.indexOf("\n", start);
66
- if (str[idx - 1] === "\r")
67
- idx--;
68
- return idx <= end ? idx : -1;
69
- }
70
- function skipComment(str, ptr) {
71
- for (let i = ptr; i < str.length; i++) {
72
- let c = str[i];
73
- if (c === "\n")
74
- return i;
75
- if (c === "\r" && str[i + 1] === "\n")
76
- return i + 1;
77
- if (c < " " && c !== " " || c === "\x7F") {
78
- throw new TomlError("control characters are not allowed in comments", {
79
- toml: str,
80
- ptr
81
- });
82
- }
83
- }
84
- return str.length;
85
- }
86
- function skipVoid(str, ptr, banNewLines, banComments) {
87
- let c;
88
- while (1) {
89
- while ((c = str[ptr]) === " " || c === " " || !banNewLines && (c === "\n" || c === "\r" && str[ptr + 1] === "\n"))
90
- ptr++;
91
- if (banComments || c !== "#")
92
- break;
93
- ptr = skipComment(str, ptr);
94
- }
95
- return ptr;
96
- }
97
- function skipUntil(str, ptr, sep2, end, banNewLines = false) {
98
- if (!end) {
99
- ptr = indexOfNewline(str, ptr);
100
- return ptr < 0 ? str.length : ptr;
101
- }
102
- for (let i = ptr; i < str.length; i++) {
103
- let c = str[i];
104
- if (c === "#") {
105
- i = indexOfNewline(str, i);
106
- } else if (c === sep2) {
107
- return i + 1;
108
- } else if (c === end || banNewLines && (c === "\n" || c === "\r" && str[i + 1] === "\n")) {
109
- return i;
110
- }
111
- }
112
- throw new TomlError("cannot find end of structure", {
113
- toml: str,
114
- ptr
115
- });
116
- }
117
- function getStringEnd(str, seek) {
118
- let first = str[seek];
119
- let target = first === str[seek + 1] && str[seek + 1] === str[seek + 2] ? str.slice(seek, seek + 3) : first;
120
- seek += target.length - 1;
121
- do
122
- seek = str.indexOf(target, ++seek);
123
- while (seek > -1 && first !== "'" && isEscaped(str, seek));
124
- if (seek > -1) {
125
- seek += target.length;
126
- if (target.length > 1) {
127
- if (str[seek] === first)
128
- seek++;
129
- if (str[seek] === first)
130
- seek++;
131
- }
132
- }
133
- return seek;
134
- }
135
-
136
- // node_modules/smol-toml/dist/date.js
137
- var DATE_TIME_RE = /^(\d{4}-\d{2}-\d{2})?[T ]?(?:(\d{2}):\d{2}(?::\d{2}(?:\.\d+)?)?)?(Z|[-+]\d{2}:\d{2})?$/i;
138
- var TomlDate = class _TomlDate extends Date {
139
- #hasDate = false;
140
- #hasTime = false;
141
- #offset = null;
142
- constructor(date) {
143
- let hasDate = true;
144
- let hasTime = true;
145
- let offset = "Z";
146
- if (typeof date === "string") {
147
- let match = date.match(DATE_TIME_RE);
148
- if (match) {
149
- if (!match[1]) {
150
- hasDate = false;
151
- date = `0000-01-01T${date}`;
152
- }
153
- hasTime = !!match[2];
154
- hasTime && date[10] === " " && (date = date.replace(" ", "T"));
155
- if (match[2] && +match[2] > 23) {
156
- date = "";
157
- } else {
158
- offset = match[3] || null;
159
- date = date.toUpperCase();
160
- if (!offset && hasTime)
161
- date += "Z";
162
- }
163
- } else {
164
- date = "";
165
- }
166
- }
167
- super(date);
168
- if (!isNaN(this.getTime())) {
169
- this.#hasDate = hasDate;
170
- this.#hasTime = hasTime;
171
- this.#offset = offset;
172
- }
173
- }
174
- isDateTime() {
175
- return this.#hasDate && this.#hasTime;
176
- }
177
- isLocal() {
178
- return !this.#hasDate || !this.#hasTime || !this.#offset;
179
- }
180
- isDate() {
181
- return this.#hasDate && !this.#hasTime;
182
- }
183
- isTime() {
184
- return this.#hasTime && !this.#hasDate;
185
- }
186
- isValid() {
187
- return this.#hasDate || this.#hasTime;
188
- }
189
- toISOString() {
190
- let iso = super.toISOString();
191
- if (this.isDate())
192
- return iso.slice(0, 10);
193
- if (this.isTime())
194
- return iso.slice(11, 23);
195
- if (this.#offset === null)
196
- return iso.slice(0, -1);
197
- if (this.#offset === "Z")
198
- return iso;
199
- let offset = +this.#offset.slice(1, 3) * 60 + +this.#offset.slice(4, 6);
200
- offset = this.#offset[0] === "-" ? offset : -offset;
201
- let offsetDate = new Date(this.getTime() - offset * 6e4);
202
- return offsetDate.toISOString().slice(0, -1) + this.#offset;
203
- }
204
- static wrapAsOffsetDateTime(jsDate, offset = "Z") {
205
- let date = new _TomlDate(jsDate);
206
- date.#offset = offset;
207
- return date;
208
- }
209
- static wrapAsLocalDateTime(jsDate) {
210
- let date = new _TomlDate(jsDate);
211
- date.#offset = null;
212
- return date;
213
- }
214
- static wrapAsLocalDate(jsDate) {
215
- let date = new _TomlDate(jsDate);
216
- date.#hasTime = false;
217
- date.#offset = null;
218
- return date;
219
- }
220
- static wrapAsLocalTime(jsDate) {
221
- let date = new _TomlDate(jsDate);
222
- date.#hasDate = false;
223
- date.#offset = null;
224
- return date;
225
- }
226
- };
227
-
228
- // node_modules/smol-toml/dist/primitive.js
229
- var INT_REGEX = /^((0x[0-9a-fA-F](_?[0-9a-fA-F])*)|(([+-]|0[ob])?\d(_?\d)*))$/;
230
- var FLOAT_REGEX = /^[+-]?\d(_?\d)*(\.\d(_?\d)*)?([eE][+-]?\d(_?\d)*)?$/;
231
- var LEADING_ZERO = /^[+-]?0[0-9_]/;
232
- var ESCAPE_REGEX = /^[0-9a-f]{2,8}$/i;
233
- var ESC_MAP = {
234
- b: "\b",
235
- t: " ",
236
- n: "\n",
237
- f: "\f",
238
- r: "\r",
239
- e: "\x1B",
240
- '"': '"',
241
- "\\": "\\"
242
- };
243
- function parseString(str, ptr = 0, endPtr = str.length) {
244
- let isLiteral = str[ptr] === "'";
245
- let isMultiline = str[ptr++] === str[ptr] && str[ptr] === str[ptr + 1];
246
- if (isMultiline) {
247
- endPtr -= 2;
248
- if (str[ptr += 2] === "\r")
249
- ptr++;
250
- if (str[ptr] === "\n")
251
- ptr++;
252
- }
253
- let tmp = 0;
254
- let isEscape;
255
- let parsed = "";
256
- let sliceStart = ptr;
257
- while (ptr < endPtr - 1) {
258
- let c = str[ptr++];
259
- if (c === "\n" || c === "\r" && str[ptr] === "\n") {
260
- if (!isMultiline) {
261
- throw new TomlError("newlines are not allowed in strings", {
262
- toml: str,
263
- ptr: ptr - 1
264
- });
265
- }
266
- } else if (c < " " && c !== " " || c === "\x7F") {
267
- throw new TomlError("control characters are not allowed in strings", {
268
- toml: str,
269
- ptr: ptr - 1
270
- });
271
- }
272
- if (isEscape) {
273
- isEscape = false;
274
- if (c === "x" || c === "u" || c === "U") {
275
- let code = str.slice(ptr, ptr += c === "x" ? 2 : c === "u" ? 4 : 8);
276
- if (!ESCAPE_REGEX.test(code)) {
277
- throw new TomlError("invalid unicode escape", {
278
- toml: str,
279
- ptr: tmp
280
- });
281
- }
282
- try {
283
- parsed += String.fromCodePoint(parseInt(code, 16));
284
- } catch {
285
- throw new TomlError("invalid unicode escape", {
286
- toml: str,
287
- ptr: tmp
288
- });
289
- }
290
- } else if (isMultiline && (c === "\n" || c === " " || c === " " || c === "\r")) {
291
- ptr = skipVoid(str, ptr - 1, true);
292
- if (str[ptr] !== "\n" && str[ptr] !== "\r") {
293
- throw new TomlError("invalid escape: only line-ending whitespace may be escaped", {
294
- toml: str,
295
- ptr: tmp
296
- });
297
- }
298
- ptr = skipVoid(str, ptr);
299
- } else if (c in ESC_MAP) {
300
- parsed += ESC_MAP[c];
301
- } else {
302
- throw new TomlError("unrecognized escape sequence", {
303
- toml: str,
304
- ptr: tmp
305
- });
306
- }
307
- sliceStart = ptr;
308
- } else if (!isLiteral && c === "\\") {
309
- tmp = ptr - 1;
310
- isEscape = true;
311
- parsed += str.slice(sliceStart, tmp);
312
- }
313
- }
314
- return parsed + str.slice(sliceStart, endPtr - 1);
315
- }
316
- function parseValue(value, toml, ptr, integersAsBigInt) {
317
- if (value === "true")
318
- return true;
319
- if (value === "false")
320
- return false;
321
- if (value === "-inf")
322
- return -Infinity;
323
- if (value === "inf" || value === "+inf")
324
- return Infinity;
325
- if (value === "nan" || value === "+nan" || value === "-nan")
326
- return NaN;
327
- if (value === "-0")
328
- return integersAsBigInt ? 0n : 0;
329
- let isInt = INT_REGEX.test(value);
330
- if (isInt || FLOAT_REGEX.test(value)) {
331
- if (LEADING_ZERO.test(value)) {
332
- throw new TomlError("leading zeroes are not allowed", {
333
- toml,
334
- ptr
335
- });
336
- }
337
- value = value.replace(/_/g, "");
338
- let numeric = +value;
339
- if (isNaN(numeric)) {
340
- throw new TomlError("invalid number", {
341
- toml,
342
- ptr
343
- });
344
- }
345
- if (isInt) {
346
- if ((isInt = !Number.isSafeInteger(numeric)) && !integersAsBigInt) {
347
- throw new TomlError("integer value cannot be represented losslessly", {
348
- toml,
349
- ptr
350
- });
351
- }
352
- if (isInt || integersAsBigInt === true)
353
- numeric = BigInt(value);
354
- }
355
- return numeric;
356
- }
357
- const date = new TomlDate(value);
358
- if (!date.isValid()) {
359
- throw new TomlError("invalid value", {
360
- toml,
361
- ptr
362
- });
363
- }
364
- return date;
365
- }
366
-
367
- // node_modules/smol-toml/dist/extract.js
368
- function sliceAndTrimEndOf(str, startPtr, endPtr) {
369
- let value = str.slice(startPtr, endPtr);
370
- let commentIdx = value.indexOf("#");
371
- if (commentIdx > -1) {
372
- skipComment(str, commentIdx);
373
- value = value.slice(0, commentIdx);
374
- }
375
- return [value.trimEnd(), commentIdx];
376
- }
377
- function extractValue(str, ptr, end, depth, integersAsBigInt) {
378
- if (depth === 0) {
379
- throw new TomlError("document contains excessively nested structures. aborting.", {
380
- toml: str,
381
- ptr
382
- });
383
- }
384
- let c = str[ptr];
385
- if (c === "[" || c === "{") {
386
- let [value, endPtr2] = c === "[" ? parseArray(str, ptr, depth, integersAsBigInt) : parseInlineTable(str, ptr, depth, integersAsBigInt);
387
- if (end) {
388
- endPtr2 = skipVoid(str, endPtr2);
389
- if (str[endPtr2] === ",")
390
- endPtr2++;
391
- else if (str[endPtr2] !== end) {
392
- throw new TomlError("expected comma or end of structure", {
393
- toml: str,
394
- ptr: endPtr2
395
- });
396
- }
397
- }
398
- return [value, endPtr2];
399
- }
400
- let endPtr;
401
- if (c === '"' || c === "'") {
402
- endPtr = getStringEnd(str, ptr);
403
- let parsed = parseString(str, ptr, endPtr);
404
- if (end) {
405
- endPtr = skipVoid(str, endPtr);
406
- if (str[endPtr] && str[endPtr] !== "," && str[endPtr] !== end && str[endPtr] !== "\n" && str[endPtr] !== "\r") {
407
- throw new TomlError("unexpected character encountered", {
408
- toml: str,
409
- ptr: endPtr
410
- });
411
- }
412
- endPtr += +(str[endPtr] === ",");
413
- }
414
- return [parsed, endPtr];
415
- }
416
- endPtr = skipUntil(str, ptr, ",", end);
417
- let slice = sliceAndTrimEndOf(str, ptr, endPtr - +(str[endPtr - 1] === ","));
418
- if (!slice[0]) {
419
- throw new TomlError("incomplete key-value declaration: no value specified", {
420
- toml: str,
421
- ptr
422
- });
423
- }
424
- if (end && slice[1] > -1) {
425
- endPtr = skipVoid(str, ptr + slice[1]);
426
- endPtr += +(str[endPtr] === ",");
427
- }
428
- return [
429
- parseValue(slice[0], str, ptr, integersAsBigInt),
430
- endPtr
431
- ];
432
- }
433
-
434
- // node_modules/smol-toml/dist/struct.js
435
- var KEY_PART_RE = /^[a-zA-Z0-9-_]+[ \t]*$/;
436
- function parseKey(str, ptr, end = "=") {
437
- let dot = ptr - 1;
438
- let parsed = [];
439
- let endPtr = str.indexOf(end, ptr);
440
- if (endPtr < 0) {
441
- throw new TomlError("incomplete key-value: cannot find end of key", {
442
- toml: str,
443
- ptr
444
- });
445
- }
446
- do {
447
- let c = str[ptr = ++dot];
448
- if (c !== " " && c !== " ") {
449
- if (c === '"' || c === "'") {
450
- if (c === str[ptr + 1] && c === str[ptr + 2]) {
451
- throw new TomlError("multiline strings are not allowed in keys", {
452
- toml: str,
453
- ptr
454
- });
455
- }
456
- let eos = getStringEnd(str, ptr);
457
- if (eos < 0) {
458
- throw new TomlError("unfinished string encountered", {
459
- toml: str,
460
- ptr
461
- });
462
- }
463
- dot = str.indexOf(".", eos);
464
- let strEnd = str.slice(eos, dot < 0 || dot > endPtr ? endPtr : dot);
465
- let newLine = indexOfNewline(strEnd);
466
- if (newLine > -1) {
467
- throw new TomlError("newlines are not allowed in keys", {
468
- toml: str,
469
- ptr: ptr + dot + newLine
470
- });
471
- }
472
- if (strEnd.trimStart()) {
473
- throw new TomlError("found extra tokens after the string part", {
474
- toml: str,
475
- ptr: eos
476
- });
477
- }
478
- if (endPtr < eos) {
479
- endPtr = str.indexOf(end, eos);
480
- if (endPtr < 0) {
481
- throw new TomlError("incomplete key-value: cannot find end of key", {
482
- toml: str,
483
- ptr
484
- });
485
- }
486
- }
487
- parsed.push(parseString(str, ptr, eos));
488
- } else {
489
- dot = str.indexOf(".", ptr);
490
- let part = str.slice(ptr, dot < 0 || dot > endPtr ? endPtr : dot);
491
- if (!KEY_PART_RE.test(part)) {
492
- throw new TomlError("only letter, numbers, dashes and underscores are allowed in keys", {
493
- toml: str,
494
- ptr
495
- });
496
- }
497
- parsed.push(part.trimEnd());
498
- }
499
- }
500
- } while (dot + 1 && dot < endPtr);
501
- return [parsed, skipVoid(str, endPtr + 1, true, true)];
502
- }
503
- function parseInlineTable(str, ptr, depth, integersAsBigInt) {
504
- let res = {};
505
- let seen = /* @__PURE__ */ new Set();
506
- let c;
507
- ptr++;
508
- while ((c = str[ptr++]) !== "}" && c) {
509
- if (c === ",") {
510
- throw new TomlError("expected value, found comma", {
511
- toml: str,
512
- ptr: ptr - 1
513
- });
514
- } else if (c === "#")
515
- ptr = skipComment(str, ptr);
516
- else if (c !== " " && c !== " " && c !== "\n" && c !== "\r") {
517
- let k;
518
- let t = res;
519
- let hasOwn = false;
520
- let [key, keyEndPtr] = parseKey(str, ptr - 1);
521
- for (let i = 0; i < key.length; i++) {
522
- if (i)
523
- t = hasOwn ? t[k] : t[k] = {};
524
- k = key[i];
525
- if ((hasOwn = Object.hasOwn(t, k)) && (typeof t[k] !== "object" || seen.has(t[k]))) {
526
- throw new TomlError("trying to redefine an already defined value", {
527
- toml: str,
528
- ptr
529
- });
530
- }
531
- if (!hasOwn && k === "__proto__") {
532
- Object.defineProperty(t, k, { enumerable: true, configurable: true, writable: true });
533
- }
534
- }
535
- if (hasOwn) {
536
- throw new TomlError("trying to redefine an already defined value", {
537
- toml: str,
538
- ptr
539
- });
540
- }
541
- let [value, valueEndPtr] = extractValue(str, keyEndPtr, "}", depth - 1, integersAsBigInt);
542
- seen.add(value);
543
- t[k] = value;
544
- ptr = valueEndPtr;
545
- }
546
- }
547
- if (!c) {
548
- throw new TomlError("unfinished table encountered", {
549
- toml: str,
550
- ptr
551
- });
552
- }
553
- return [res, ptr];
554
- }
555
- function parseArray(str, ptr, depth, integersAsBigInt) {
556
- let res = [];
557
- let c;
558
- ptr++;
559
- while ((c = str[ptr++]) !== "]" && c) {
560
- if (c === ",") {
561
- throw new TomlError("expected value, found comma", {
562
- toml: str,
563
- ptr: ptr - 1
564
- });
565
- } else if (c === "#")
566
- ptr = skipComment(str, ptr);
567
- else if (c !== " " && c !== " " && c !== "\n" && c !== "\r") {
568
- let e = extractValue(str, ptr - 1, "]", depth - 1, integersAsBigInt);
569
- res.push(e[0]);
570
- ptr = e[1];
571
- }
572
- }
573
- if (!c) {
574
- throw new TomlError("unfinished array encountered", {
575
- toml: str,
576
- ptr
577
- });
578
- }
579
- return [res, ptr];
580
- }
581
-
582
- // node_modules/smol-toml/dist/parse.js
583
- function peekTable(key, table, meta, type) {
584
- let t = table;
585
- let m = meta;
586
- let k;
587
- let hasOwn = false;
588
- let state;
589
- for (let i = 0; i < key.length; i++) {
590
- if (i) {
591
- t = hasOwn ? t[k] : t[k] = {};
592
- m = (state = m[k]).c;
593
- if (type === 0 && (state.t === 1 || state.t === 2)) {
594
- return null;
595
- }
596
- if (state.t === 2) {
597
- let l = t.length - 1;
598
- t = t[l];
599
- m = m[l].c;
600
- }
601
- }
602
- k = key[i];
603
- if ((hasOwn = Object.hasOwn(t, k)) && m[k]?.t === 0 && m[k]?.d) {
604
- return null;
605
- }
606
- if (!hasOwn) {
607
- if (k === "__proto__") {
608
- Object.defineProperty(t, k, { enumerable: true, configurable: true, writable: true });
609
- Object.defineProperty(m, k, { enumerable: true, configurable: true, writable: true });
610
- }
611
- m[k] = {
612
- t: i < key.length - 1 && type === 2 ? 3 : type,
613
- d: false,
614
- i: 0,
615
- c: {}
616
- };
617
- }
618
- }
619
- state = m[k];
620
- if (state.t !== type && !(type === 1 && state.t === 3)) {
621
- return null;
622
- }
623
- if (type === 2) {
624
- if (!state.d) {
625
- state.d = true;
626
- t[k] = [];
627
- }
628
- t[k].push(t = {});
629
- state.c[state.i++] = state = { t: 1, d: false, i: 0, c: {} };
630
- }
631
- if (state.d) {
632
- return null;
633
- }
634
- state.d = true;
635
- if (type === 1) {
636
- t = hasOwn ? t[k] : t[k] = {};
637
- } else if (type === 0 && hasOwn) {
638
- return null;
639
- }
640
- return [k, t, state.c];
641
- }
642
- function parse(toml, { maxDepth = 1e3, integersAsBigInt } = {}) {
643
- let res = {};
644
- let meta = {};
645
- let tbl = res;
646
- let m = meta;
647
- for (let ptr = skipVoid(toml, 0); ptr < toml.length; ) {
648
- if (toml[ptr] === "[") {
649
- let isTableArray = toml[++ptr] === "[";
650
- let k = parseKey(toml, ptr += +isTableArray, "]");
651
- if (isTableArray) {
652
- if (toml[k[1] - 1] !== "]") {
653
- throw new TomlError("expected end of table declaration", {
654
- toml,
655
- ptr: k[1] - 1
656
- });
657
- }
658
- k[1]++;
659
- }
660
- let p = peekTable(
661
- k[0],
662
- res,
663
- meta,
664
- isTableArray ? 2 : 1
665
- /* Type.EXPLICIT */
666
- );
667
- if (!p) {
668
- throw new TomlError("trying to redefine an already defined table or value", {
669
- toml,
670
- ptr
671
- });
672
- }
673
- m = p[2];
674
- tbl = p[1];
675
- ptr = k[1];
676
- } else {
677
- let k = parseKey(toml, ptr);
678
- let p = peekTable(
679
- k[0],
680
- tbl,
681
- m,
682
- 0
683
- /* Type.DOTTED */
684
- );
685
- if (!p) {
686
- throw new TomlError("trying to redefine an already defined table or value", {
687
- toml,
688
- ptr
689
- });
690
- }
691
- let v = extractValue(toml, k[1], void 0, maxDepth, integersAsBigInt);
692
- p[1][p[0]] = v[0];
693
- ptr = v[1];
694
- }
695
- ptr = skipVoid(toml, ptr, true);
696
- if (toml[ptr] && toml[ptr] !== "\n" && toml[ptr] !== "\r") {
697
- throw new TomlError("each key-value declaration must be followed by an end-of-line", {
698
- toml,
699
- ptr
700
- });
701
- }
702
- ptr = skipVoid(toml, ptr);
703
- }
704
- return res;
705
- }
706
-
707
- // node_modules/smol-toml/dist/stringify.js
708
- var BARE_KEY = /^[a-z0-9-_]+$/i;
709
- function extendedTypeOf(obj) {
710
- let type = typeof obj;
711
- if (type === "object") {
712
- if (Array.isArray(obj))
713
- return "array";
714
- if (obj instanceof Date)
715
- return "date";
716
- }
717
- return type;
718
- }
719
- function isArrayOfTables(obj) {
720
- for (let i = 0; i < obj.length; i++) {
721
- if (extendedTypeOf(obj[i]) !== "object")
722
- return false;
723
- }
724
- return obj.length != 0;
725
- }
726
- function formatString(s) {
727
- return JSON.stringify(s).replace(/\x7f/g, "\\u007f");
728
- }
729
- function stringifyValue(val, type, depth, numberAsFloat) {
730
- if (depth === 0) {
731
- throw new Error("Could not stringify the object: maximum object depth exceeded");
732
- }
733
- if (type === "number") {
734
- if (isNaN(val))
735
- return "nan";
736
- if (val === Infinity)
737
- return "inf";
738
- if (val === -Infinity)
739
- return "-inf";
740
- if (numberAsFloat && Number.isInteger(val))
741
- return val.toFixed(1);
742
- return val.toString();
743
- }
744
- if (type === "bigint" || type === "boolean") {
745
- return val.toString();
746
- }
747
- if (type === "string") {
748
- return formatString(val);
749
- }
750
- if (type === "date") {
751
- if (isNaN(val.getTime())) {
752
- throw new TypeError("cannot serialize invalid date");
753
- }
754
- return val.toISOString();
755
- }
756
- if (type === "object") {
757
- return stringifyInlineTable(val, depth, numberAsFloat);
758
- }
759
- if (type === "array") {
760
- return stringifyArray(val, depth, numberAsFloat);
761
- }
762
- }
763
- function stringifyInlineTable(obj, depth, numberAsFloat) {
764
- let keys = Object.keys(obj);
765
- if (keys.length === 0)
766
- return "{}";
767
- let res = "{ ";
768
- for (let i = 0; i < keys.length; i++) {
769
- let k = keys[i];
770
- if (i)
771
- res += ", ";
772
- res += BARE_KEY.test(k) ? k : formatString(k);
773
- res += " = ";
774
- res += stringifyValue(obj[k], extendedTypeOf(obj[k]), depth - 1, numberAsFloat);
775
- }
776
- return res + " }";
777
- }
778
- function stringifyArray(array, depth, numberAsFloat) {
779
- if (array.length === 0)
780
- return "[]";
781
- let res = "[ ";
782
- for (let i = 0; i < array.length; i++) {
783
- if (i)
784
- res += ", ";
785
- if (array[i] === null || array[i] === void 0) {
786
- throw new TypeError("arrays cannot contain null or undefined values");
787
- }
788
- res += stringifyValue(array[i], extendedTypeOf(array[i]), depth - 1, numberAsFloat);
789
- }
790
- return res + " ]";
791
- }
792
- function stringifyArrayTable(array, key, depth, numberAsFloat) {
793
- if (depth === 0) {
794
- throw new Error("Could not stringify the object: maximum object depth exceeded");
795
- }
796
- let res = "";
797
- for (let i = 0; i < array.length; i++) {
798
- res += `${res && "\n"}[[${key}]]
799
- `;
800
- res += stringifyTable(0, array[i], key, depth, numberAsFloat);
801
- }
802
- return res;
803
- }
804
- function stringifyTable(tableKey, obj, prefix, depth, numberAsFloat) {
805
- if (depth === 0) {
806
- throw new Error("Could not stringify the object: maximum object depth exceeded");
807
- }
808
- let preamble = "";
809
- let tables = "";
810
- let keys = Object.keys(obj);
811
- for (let i = 0; i < keys.length; i++) {
812
- let k = keys[i];
813
- if (obj[k] !== null && obj[k] !== void 0) {
814
- let type = extendedTypeOf(obj[k]);
815
- if (type === "symbol" || type === "function") {
816
- throw new TypeError(`cannot serialize values of type '${type}'`);
817
- }
818
- let key = BARE_KEY.test(k) ? k : formatString(k);
819
- if (type === "array" && isArrayOfTables(obj[k])) {
820
- tables += (tables && "\n") + stringifyArrayTable(obj[k], prefix ? `${prefix}.${key}` : key, depth - 1, numberAsFloat);
821
- } else if (type === "object") {
822
- let tblKey = prefix ? `${prefix}.${key}` : key;
823
- tables += (tables && "\n") + stringifyTable(tblKey, obj[k], tblKey, depth - 1, numberAsFloat);
824
- } else {
825
- preamble += key;
826
- preamble += " = ";
827
- preamble += stringifyValue(obj[k], type, depth, numberAsFloat);
828
- preamble += "\n";
829
- }
830
- }
831
- }
832
- if (tableKey && (preamble || !tables))
833
- preamble = preamble ? `[${tableKey}]
834
- ${preamble}` : `[${tableKey}]`;
835
- return preamble && tables ? `${preamble}
836
- ${tables}` : preamble || tables;
837
- }
838
- function stringify(obj, { maxDepth = 1e3, numbersAsFloat = false } = {}) {
839
- if (extendedTypeOf(obj) !== "object") {
840
- throw new TypeError("stringify can only be called with an object");
841
- }
842
- let str = stringifyTable(0, obj, "", maxDepth, numbersAsFloat);
843
- if (str[str.length - 1] !== "\n")
844
- return str + "\n";
845
- return str;
846
- }
847
-
848
- // source/codex/lib/installer.mjs
849
16
  var PLUGIN_NAME = "polygraph";
850
17
  var PLUGIN_ID = "polygraph@polygraph-plugins";
851
18
  var MARKETPLACE_NAME = "polygraph-plugins";
@@ -861,22 +28,9 @@ function resolveCodexHome(env = process.env) {
861
28
  const userHome = env.HOME?.trim() || homedir();
862
29
  return join(resolve(expandHome(userHome, env)), ".codex");
863
30
  }
864
- function getConfigPath(codexHome) {
865
- return join(codexHome, "config.toml");
866
- }
867
31
  function getAgentsPath(codexHome) {
868
32
  return join(codexHome, "agents");
869
33
  }
870
- function getCacheRoot(codexHome, version) {
871
- const base = join(
872
- codexHome,
873
- "plugins",
874
- "cache",
875
- MARKETPLACE_NAME,
876
- PLUGIN_NAME
877
- );
878
- return version ? join(base, version) : base;
879
- }
880
34
  function resolveUserHome(env = process.env) {
881
35
  const userHome = env.HOME?.trim() || homedir();
882
36
  return resolve(expandHome(userHome, env));
@@ -917,23 +71,6 @@ function loadPackageMetadata(packageRoot) {
917
71
  version: packageJson.version
918
72
  };
919
73
  }
920
- function mirrorCodexPluginCache({ codexHome, packageRoot, packageJson, version }) {
921
- if (!existsSync(codexHome)) {
922
- return null;
923
- }
924
- const pluginCacheRoot = getCacheRoot(codexHome);
925
- if (existsSync(pluginCacheRoot)) {
926
- for (const entry of readdirSync(pluginCacheRoot)) {
927
- rmSync(join(pluginCacheRoot, entry), { recursive: true, force: true });
928
- }
929
- }
930
- const versionedCachePath = getCacheRoot(codexHome, version);
931
- mkdirSync(versionedCachePath, { recursive: true });
932
- for (const relativePath of getPackagePayloadPaths(packageRoot, packageJson)) {
933
- copyRelativeEntry(packageRoot, versionedCachePath, relativePath);
934
- }
935
- return versionedCachePath;
936
- }
937
74
  function installPlugin({
938
75
  packageRoot,
939
76
  env = process.env,
@@ -945,7 +82,6 @@ function installPlugin({
945
82
  const { packageJson, version } = loadPackageMetadata(packageRoot);
946
83
  const codexHome = resolveCodexHome(env);
947
84
  const userHome = resolveUserHome(env);
948
- const configPath = getConfigPath(codexHome);
949
85
  const agentsPath = getAgentsPath(codexHome);
950
86
  const marketplacePath = getMarketplacePath(userHome);
951
87
  const pluginPath = getPluginInstallPath(userHome);
@@ -980,19 +116,12 @@ function installPlugin({
980
116
  }
981
117
  copied = true;
982
118
  }
983
- const configChanged = enablePluginInConfig(configPath);
984
119
  const agentsChanged = installCodexAgents({ packageRoot, agentsPath });
985
120
  const marketplaceChanged = enablePluginInMarketplace({
986
121
  marketplacePath,
987
122
  pluginPath,
988
123
  userHome
989
124
  });
990
- const codexCachePath = mirrorCodexPluginCache({
991
- codexHome,
992
- packageRoot,
993
- packageJson,
994
- version
995
- });
996
125
  return {
997
126
  ok: true,
998
127
  action: "install",
@@ -1001,14 +130,11 @@ function installPlugin({
1001
130
  codexHome,
1002
131
  agentsPath,
1003
132
  pluginPath,
1004
- configPath,
1005
133
  marketplacePath,
1006
- codexCachePath,
1007
134
  copied,
1008
135
  overwritten: installAlreadyPresent && force,
1009
136
  pluginUpdated: installAlreadyPresent && versionMismatch && !force,
1010
137
  previousVersion,
1011
- configChanged,
1012
138
  agentsChanged,
1013
139
  marketplaceChanged
1014
140
  };
@@ -1020,22 +146,17 @@ function checkInstall({ packageRoot, env = process.env } = {}) {
1020
146
  }
1021
147
  const codexHome = resolveCodexHome(env);
1022
148
  const userHome = resolveUserHome(env);
1023
- const configPath = getConfigPath(codexHome);
1024
149
  const agentsPath = getAgentsPath(codexHome);
1025
150
  const marketplacePath = getMarketplacePath(userHome);
1026
151
  const pluginPath = getPluginInstallPath(userHome);
1027
152
  const pluginInstalled = isValidInstalledPluginDir(pluginPath);
1028
- const configEnabled = isPluginEnabled(configPath);
1029
153
  const agentsInstalled = packageRoot ? areCodexAgentsInstalled({ packageRoot, agentsPath }) : hasDefaultCodexAgents(agentsPath);
1030
154
  const marketplaceConfigured = isPluginConfiguredInMarketplace({
1031
155
  marketplacePath,
1032
156
  userHome,
1033
157
  pluginPath
1034
158
  });
1035
- const ok = pluginInstalled && configEnabled && agentsInstalled && marketplaceConfigured;
1036
- const codexHomeExists = existsSync(codexHome);
1037
- const codexCachePath = codexHomeExists && version ? getCacheRoot(codexHome, version) : null;
1038
- const codexCacheMirrored = codexCachePath !== null ? isCodexCacheCurrent({ cachePath: codexCachePath, pluginPath }) : null;
159
+ const ok = pluginInstalled && agentsInstalled && marketplaceConfigured;
1039
160
  return {
1040
161
  ok,
1041
162
  action: "check",
@@ -1043,43 +164,12 @@ function checkInstall({ packageRoot, env = process.env } = {}) {
1043
164
  codexHome,
1044
165
  agentsPath,
1045
166
  pluginPath,
1046
- configPath,
1047
167
  marketplacePath,
1048
- codexCachePath,
1049
168
  pluginInstalled,
1050
- configEnabled,
1051
169
  agentsInstalled,
1052
- marketplaceConfigured,
1053
- codexCacheMirrored
170
+ marketplaceConfigured
1054
171
  };
1055
172
  }
1056
- function enablePluginInConfig(configPath) {
1057
- const config = readTomlFile(configPath);
1058
- if (config.plugins !== void 0 && !isPlainObject(config.plugins)) {
1059
- throw new Error(
1060
- `Expected plugins table in ${configPath} to be a TOML table`
1061
- );
1062
- }
1063
- const plugins = config.plugins ?? {};
1064
- const pluginConfig = plugins[PLUGIN_ID];
1065
- if (pluginConfig !== void 0 && !isPlainObject(pluginConfig)) {
1066
- throw new Error(
1067
- `Expected plugins."${PLUGIN_ID}" in ${configPath} to be a TOML table`
1068
- );
1069
- }
1070
- const wasEnabled = pluginConfig?.enabled === true;
1071
- plugins[PLUGIN_ID] = { ...pluginConfig ?? {}, enabled: true };
1072
- config.plugins = plugins;
1073
- writeTomlFile(configPath, config);
1074
- return !wasEnabled;
1075
- }
1076
- function isPluginEnabled(configPath) {
1077
- if (!existsSync(configPath)) {
1078
- return false;
1079
- }
1080
- const config = readTomlFile(configPath);
1081
- return config.plugins?.[PLUGIN_ID]?.enabled === true;
1082
- }
1083
173
  function getPackagePayloadPaths(packageRoot, packageJson) {
1084
174
  const relativePaths = new Set(packageJson.files ?? []);
1085
175
  relativePaths.add("package.json");
@@ -1209,25 +299,6 @@ function isPluginConfiguredInMarketplace({
1209
299
  const configuredPath = resolve(userHome, pluginEntry.source.path);
1210
300
  return configuredPath === resolve(pluginPath);
1211
301
  }
1212
- function readTomlFile(path) {
1213
- if (!existsSync(path)) {
1214
- return {};
1215
- }
1216
- const raw = readFileSync(path, "utf8");
1217
- if (raw.trim() === "") {
1218
- return {};
1219
- }
1220
- const parsed = parse(raw);
1221
- if (!isPlainObject(parsed)) {
1222
- throw new Error(`Expected TOML document at ${path} to parse to an object`);
1223
- }
1224
- return parsed;
1225
- }
1226
- function writeTomlFile(path, value) {
1227
- mkdirSync(dirname(path), { recursive: true });
1228
- writeFileSync(path, `${stringify(value).trimEnd()}
1229
- `);
1230
- }
1231
302
  function readJsonFile(path, fallbackValue) {
1232
303
  if (!existsSync(path)) {
1233
304
  return fallbackValue;
@@ -1239,45 +310,6 @@ function writeJsonFile(path, value) {
1239
310
  writeFileSync(path, `${JSON.stringify(value, null, 2)}
1240
311
  `);
1241
312
  }
1242
- function isCodexCacheCurrent({ cachePath, pluginPath }) {
1243
- if (!existsSync(cachePath) || !existsSync(pluginPath)) {
1244
- return false;
1245
- }
1246
- return directoriesMatch(pluginPath, cachePath);
1247
- }
1248
- function directoriesMatch(aDir, bDir) {
1249
- if (!existsSync(aDir) || !existsSync(bDir)) {
1250
- return false;
1251
- }
1252
- const aEntries = readdirSync(aDir, { withFileTypes: true }).sort(
1253
- (x, y) => x.name < y.name ? -1 : x.name > y.name ? 1 : 0
1254
- );
1255
- const bEntries = readdirSync(bDir, { withFileTypes: true }).sort(
1256
- (x, y) => x.name < y.name ? -1 : x.name > y.name ? 1 : 0
1257
- );
1258
- if (aEntries.length !== bEntries.length) {
1259
- return false;
1260
- }
1261
- for (let i = 0; i < aEntries.length; i++) {
1262
- const a = aEntries[i];
1263
- const b = bEntries[i];
1264
- if (a.name !== b.name || a.isDirectory() !== b.isDirectory()) {
1265
- return false;
1266
- }
1267
- if (a.isDirectory()) {
1268
- if (!directoriesMatch(join(aDir, a.name), join(bDir, b.name))) {
1269
- return false;
1270
- }
1271
- } else {
1272
- const aContent = readFileSync(join(aDir, a.name));
1273
- const bContent = readFileSync(join(bDir, b.name));
1274
- if (!aContent.equals(bContent)) {
1275
- return false;
1276
- }
1277
- }
1278
- }
1279
- return true;
1280
- }
1281
313
  function isValidInstalledPluginDir(candidatePath) {
1282
314
  const pluginManifestPath = join(
1283
315
  candidatePath,
@@ -1326,7 +358,14 @@ function isPlainObject(value) {
1326
358
  var usage = `Usage:
1327
359
  npx @polygraph/codex-plugin
1328
360
  npx @polygraph/codex-plugin install [--force] [--json]
1329
- npx @polygraph/codex-plugin check [--json]`;
361
+ npx @polygraph/codex-plugin check [--json]
362
+
363
+ The install command materializes the plugin payload so that codex's official
364
+ plugin system can pick it up. After running install, run:
365
+
366
+ codex plugin add polygraph@polygraph-plugins
367
+
368
+ to have codex register and enable the plugin in its own config.`;
1330
369
  async function main() {
1331
370
  const args = process.argv.slice(2);
1332
371
  let command = "install";
@@ -1362,26 +401,24 @@ ${usage}`);
1362
401
  console.log(JSON.stringify(result, null, 2));
1363
402
  } else if (command === "check") {
1364
403
  if (result.ok) {
1365
- console.log(`Polygraph Codex plugin is enabled.`);
404
+ console.log(`Polygraph Codex plugin is materialized.`);
1366
405
  console.log(`Plugin path: ${result.pluginPath}`);
1367
406
  console.log(`Agents: ${result.agentsPath}`);
1368
- console.log(`Config: ${result.configPath}`);
1369
407
  console.log(`Marketplace: ${result.marketplacePath}`);
1370
408
  } else {
1371
409
  const pluginState = result.pluginInstalled ? "plugin files present" : "plugin files not present";
1372
- const configState = result.configEnabled ? "plugin enabled in config" : "plugin not enabled in config";
1373
410
  const agentsState = result.agentsInstalled ? "agents installed" : "agents not installed";
1374
411
  const marketplaceState = result.marketplaceConfigured ? "plugin present in marketplace" : "plugin not present in marketplace";
1375
412
  console.error(
1376
- `Polygraph Codex plugin check failed: ${pluginState}; ${configState}; ${agentsState}; ${marketplaceState}.`
413
+ `Polygraph Codex plugin check failed: ${pluginState}; ${agentsState}; ${marketplaceState}.`
1377
414
  );
1378
415
  }
1379
416
  } else {
1380
- console.log(`Installed Polygraph Codex plugin ${result.version}.`);
417
+ console.log(`Materialized Polygraph Codex plugin ${result.version}.`);
1381
418
  console.log(`Plugin path: ${result.pluginPath}`);
1382
419
  console.log(`Agents: ${result.agentsPath}`);
1383
- console.log(`Config: ${result.configPath}`);
1384
420
  console.log(`Marketplace: ${result.marketplacePath}`);
421
+ console.log(`Next step: codex plugin add ${result.plugin}`);
1385
422
  }
1386
423
  if (command === "check" && !result.ok) {
1387
424
  process.exitCode = 1;
@@ -1392,42 +429,3 @@ main().catch((error) => {
1392
429
  console.error(`polygraph-codex-plugin failed: ${message}`);
1393
430
  process.exitCode = 1;
1394
431
  });
1395
- /*! Bundled license information:
1396
-
1397
- smol-toml/dist/error.js:
1398
- smol-toml/dist/util.js:
1399
- smol-toml/dist/date.js:
1400
- smol-toml/dist/primitive.js:
1401
- smol-toml/dist/extract.js:
1402
- smol-toml/dist/struct.js:
1403
- smol-toml/dist/parse.js:
1404
- smol-toml/dist/stringify.js:
1405
- smol-toml/dist/index.js:
1406
- (*!
1407
- * Copyright (c) Squirrel Chat et al., All rights reserved.
1408
- * SPDX-License-Identifier: BSD-3-Clause
1409
- *
1410
- * Redistribution and use in source and binary forms, with or without
1411
- * modification, are permitted provided that the following conditions are met:
1412
- *
1413
- * 1. Redistributions of source code must retain the above copyright notice, this
1414
- * list of conditions and the following disclaimer.
1415
- * 2. Redistributions in binary form must reproduce the above copyright notice,
1416
- * this list of conditions and the following disclaimer in the
1417
- * documentation and/or other materials provided with the distribution.
1418
- * 3. Neither the name of the copyright holder nor the names of its contributors
1419
- * may be used to endorse or promote products derived from this software without
1420
- * specific prior written permission.
1421
- *
1422
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
1423
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
1424
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
1425
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
1426
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
1427
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
1428
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
1429
- * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
1430
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
1431
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
1432
- *)
1433
- */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@polygraph/codex-plugin",
3
- "version": "0.4.30",
3
+ "version": "0.4.32",
4
4
  "description": "AI agent skills and subagents for Polygraph multi-repo coordination",
5
5
  "license": "UNLICENSED",
6
6
  "private": false,
@@ -29,7 +29,7 @@ Polygraph functionality is available via both MCP tools and CLI commands. Use wh
29
29
 
30
30
  | MCP Tool | CLI Equivalent | Description |
31
31
  | --- | --- | --- |
32
- | `list_repos` | `polygraph repo list` | Discover candidate repositories. |
32
+ | `list_repos` | `polygraph repo list` | Discover candidate repositories. Candidate entries do not include repository descriptions; use `semanticQuery` for natural-language discovery. |
33
33
  | `start_session` | `polygraph session start --repo <ids>` | Initialize a Polygraph session with selected repositories |
34
34
  | `spawn_agent` | — | Start a new child task or send a follow-up to an active task in another repository. Input: `{ sessionId, repo, instruction, context? }`. Output: `{ taskId, message, status: 'delegated' }`. Follow-up routing is automatic: if the repo already has an active child task, the instruction is delivered to it as a follow-up message; otherwise a new child run starts. A repo has at most one active child at a time. A session resume or reconstruction is read-only context restoration; after resuming, do not use `spawn_agent` to continue changes unless the user explicitly asks for changes. |
35
35
  | `show_agent` | — | Poll flat per-child status for the session. Output: `{ children: PolygraphChildStatusItem[] }` where each item exposes `repositoryId`, `repoFullName`, `status`, `lastOutputLines`, `durationMs`, `instruction`, `agentType?`, `inputRequiredQuestion?`. `status` is an AcpRunStatus: `'created' \| 'in-progress' \| 'input-required' \| 'permission-required' \| 'completed' \| 'failed' \| 'cancelled'` (British double-L on `'cancelled'`). `inputRequiredQuestion` is populated only when `status === 'input-required'`. |
@@ -306,27 +306,9 @@ push_branch(
306
306
 
307
307
  ### Session Description Policy
308
308
 
309
- `description` is user-facing Polygraph session context.
309
+ `description` is user-facing Polygraph session context. It is required for `push_branch`, `create_pr`, and `associate_pr`, and is the primary input to `update_session` (`mark_pr_ready` does not take a description).
310
310
 
311
- `description` is required for `push_branch`, `create_pr`, and `associate_pr`, and is the primary input to `update_session` (which takes `title` and/or `description`). (`mark_pr_ready` does not take a description.) Use the canonical structured format:
312
-
313
- ```text
314
- Goal: <what the session is trying to accomplish>
315
-
316
- Current Progress: <what has been completed so far, including PR/session state when relevant>
317
-
318
- What Worked: <important decisions, approaches, or constraints that future agents should preserve>
319
-
320
- Next Steps: <clear next implementation steps>
321
- ```
322
-
323
- - Do not use a one-line feature summary for final handoff or PR creation in a multi-repo session.
324
- - Keep it concise but durable for a future resumed agent.
325
- - Prefer high-level state over file-by-file changelogs.
326
- - Mention unresolved decisions or risks when they matter.
327
- - In `Next Steps`, include only next implementation steps. Do not list routine operational steps such as pushing branches, watching CI, or marking PRs ready.
328
-
329
- > **Tip (optional):** The Polygraph UI renders fenced ` ```mermaid ` blocks in the session description as diagrams. If a small diagram would genuinely clarify the session state — for example, cross-repo relationships or a sequence of changes — you may include one. Plain text remains the norm; diagrams are never required.
311
+ **Whenever you write or update a session description, read [`reference/session-description.md`](reference/session-description.md) first.** That reference file holds the full policy: the canonical Markdown-heading template (`## Goal` / `## Current progress` / `## What worked` / `## Next steps`), the dual-audience guidance (humans in the web UI now, agents reconstructing history later), and the formatting building blocks the app renders (callouts, tables, mermaid, links, `link_reference`).
330
312
 
331
313
  ### 3. Create Draft PRs
332
314
 
@@ -636,15 +618,11 @@ get_ci_logs(
636
618
 
637
619
  ### Update Session Description
638
620
 
639
- Use this when the user asks to summarize progress, update the session description, capture the current state.
621
+ Use this when the user asks to summarize progress, update the session description, or capture the current state.
640
622
 
641
- Before writing:
642
- - Read the current session details.
643
- - Consider the current conversation, child-agent results, PRs, pushed branches, validation, and unresolved decisions.
644
- - If appending a new item, read the current/latest description first and write the full replacement description with the existing items plus the new item.
645
- - If updating or replacing the existing last item, write the resulting state directly.
623
+ Read [`reference/session-description.md`](reference/session-description.md) for the full update procedure (what to read before writing, how to append vs. replace) and the canonical Markdown-heading format. Then call `update_session` with the resulting summary as `description`.
646
624
 
647
- Write the description using the canonical structured format in the Session Description Policy. Then call `update_session` with the resulting summary as `description`.
625
+ Be liberal about updating the session description when you make changes that affect the scope of the session, how logic flows between repos, or anything else important for posterity. Avoid updating it for small implementation details that are not relevant outside of this session. An up-to-date session description matters for maintainability.
648
626
 
649
627
  ### Print Polygraph Session Details
650
628
 
@@ -0,0 +1,111 @@
1
+ # Session Description Reference
2
+
3
+ ## Session Description Policy
4
+
5
+ `description` is user-facing Polygraph session context.
6
+
7
+ `description` is required for `push_branch`, `create_pr`, and `associate_pr`, and is the primary input to `update_session` (which takes `title` and/or `description`). (`mark_pr_ready` does not take a description.) The Polygraph web app renders the description as Markdown, so use real Markdown headings — not flat `Label:` lines. Use the canonical structured format:
8
+
9
+ ```markdown
10
+ ## Goal
11
+
12
+ <what the session is trying to accomplish>
13
+
14
+ ## Current progress
15
+
16
+ <what has been completed so far, including PR/session state when relevant>
17
+
18
+ ## What worked
19
+
20
+ <important decisions, approaches, or constraints that future agents should preserve>
21
+
22
+ ## Next steps
23
+
24
+ <clear next implementation steps>
25
+ ```
26
+
27
+ - Do not use a one-line feature summary for final handoff or PR creation in a multi-repo session.
28
+ - Keep it concise but durable for a future resumed agent.
29
+ - Prefer high-level state over file-by-file changelogs.
30
+ - Mention unresolved decisions or risks when they matter.
31
+ - In `Next steps`, include only next implementation steps. Do not list routine operational steps such as pushing branches, watching CI, or marking PRs ready.
32
+
33
+ ## Dual audience: humans now, agents later
34
+
35
+ The description has two readers, and you must write for both:
36
+
37
+ 1. **Humans, in the web UI** — this is the primary surface. The app renders the description as Markdown for people scanning session state.
38
+ 2. **Agents, later** — the description is also read back by agents reconstructing session history (for example, on resume). They may not have the original working tree, branch, or local environment available.
39
+
40
+ Because of the second audience, write **durably**:
41
+
42
+ - Avoid ephemeral or local references (paths, ports, in-progress scratch state) that won't mean anything to a later reader.
43
+ - Don't assume the original working tree is available — describe *what* changed and *why* at a level that survives without the diff in front of you.
44
+ - Capture decisions and constraints, not just a snapshot of the current terminal.
45
+
46
+ ## Formatting building blocks
47
+
48
+ Plain text (headings + prose + lists) remains the norm. The blocks below are available when they genuinely add clarity — reach for them only when they earn their place.
49
+
50
+ ### Headings, emphasis, lists
51
+
52
+ Use the `##` headings from the canonical template. Use **bold**/*italic* for emphasis, and bullet or numbered lists for enumerations. Keep nesting shallow.
53
+
54
+ ### Callouts (GitHub alert syntax)
55
+
56
+ The app maps each callout to a status color, so pick the right type:
57
+
58
+ - `> [!WARNING]` / `> [!CAUTION]` — risky migrations, destructive operations, or **required manual steps** a reader must not miss.
59
+ - `> [!NOTE]` / `> [!IMPORTANT]` — context, rationale, or a key constraint worth highlighting.
60
+ - `> [!TIP]` — an optional helpful pointer.
61
+
62
+ ```markdown
63
+ > [!WARNING]
64
+ > The auth migration must run before deploying the API repo, or existing sessions are invalidated.
65
+ ```
66
+
67
+ ### Tables (GFM)
68
+
69
+ Use a GitHub-Flavored Markdown table only for genuinely tabular data. The polygraph UI already shows per-PR state so avoid that.
70
+
71
+ ```markdown
72
+ | Repo | Change Type |
73
+ | ----------- | ------------------ |
74
+ | org/api | api functionality |
75
+ | org/web | text-only |
76
+ ```
77
+
78
+ ### Mermaid diagrams
79
+
80
+ The app renders fenced ` ```mermaid ` blocks as diagrams. Use one only when it genuinely clarifies session state. Good uses:
81
+
82
+ - Control or data flow between logic pieces across repos or system components.
83
+ - A sequence of changes, or migration order.
84
+ - A state machine.
85
+
86
+ > [!IMPORTANT]
87
+ > Do NOT redraw the cross-repo dependency / repository graph. The app already renders the repo-relationship graph for every session, so a repo-relationship diagram in the description is redundant.
88
+
89
+ Plain text remains the norm; diagrams are optional and never required.
90
+
91
+ ### Code blocks and task lists
92
+
93
+ Use fenced code blocks for commands, signatures, or short snippets. Use task lists (`- [ ]` / `- [x]`) when tracking discrete remaining work items.
94
+
95
+ ### Links
96
+
97
+ - Prefer durable external URLs (e.g. GitHub PRs/issues, Linear tickets).
98
+ - Do NOT put local or dev links in the description: `localhost`, `127.0.0.1`, and `file://` URLs do not resolve in the UI and are useless to later readers.
99
+ - Do NOT put repo-relative file paths (`./foo.ts`, `../bar`) as links — they don't resolve in the UI.
100
+ - To attach supplementary references (PRs, issues, other Polygraph sessions, Linear tickets), use the `link_reference` tool instead of inline links. `link_reference` is **supplementary** to the description, not a replacement for it.
101
+
102
+ ## Updating the session description
103
+
104
+ Before writing:
105
+
106
+ - Read the current session details.
107
+ - Consider the current conversation, child-agent results, PRs, pushed branches, validation, and unresolved decisions.
108
+ - If appending a new item, read the current/latest description first and write the full replacement description with the existing items plus the new item.
109
+ - If updating or replacing the existing last item, write the resulting state directly.
110
+
111
+ Write the description using the canonical structured format above. Then call `update_session` or one of the other tools like `create_pr` that take a description as input.