@sjawhar/claude-envoy 6.24.0 → 6.25.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.
@@ -2,5 +2,5 @@
2
2
  "name": "claude-envoy",
3
3
  "description": "Put Envoy events into the Claude Code session's own conversation and expose Envoy MCP tools.",
4
4
  "mcpServers": "./.mcp.json",
5
- "version": "6.24.0"
5
+ "version": "6.25.1"
6
6
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "claude-envoy",
3
- "version": "6.24.0",
3
+ "version": "6.25.1",
4
4
  "description": "Put Envoy events into the Claude Code session's own conversation and expose Envoy MCP tools.",
5
5
  "mcpServers": {}
6
6
  }
@@ -14211,6 +14211,29 @@ function pathKeepsBytesOf(name) {
14211
14211
  return extension === undefined || !MARKDOWN_EXTENSION.test(extension);
14212
14212
  }
14213
14213
  var artifactOwner = documentOwnerValidation(false);
14214
+ var SPEC_FORM_ROOT_RULE = "root walks every issue under that root: name no issue, project, artifact, version or ref with it.";
14215
+ var SPEC_FORM_VERSION_RULE = "A version number belongs to one document, and an issue has several: with version, name the document with artifact (--artifact).";
14216
+ var SPEC_FORM_DOCUMENT_ARGUMENTS = ["issue", "project", "artifact", "version", "ref"];
14217
+ var specFormDocumentOwner = documentOwnerValidation(true);
14218
+ function specFormRefusal(value) {
14219
+ const input = value;
14220
+ if (input["root"] !== undefined) {
14221
+ return SPEC_FORM_DOCUMENT_ARGUMENTS.every((name) => input[name] === undefined) ? undefined : SPEC_FORM_ROOT_RULE;
14222
+ }
14223
+ return brokenParts([
14224
+ [specFormDocumentOwner.check(value), specFormDocumentOwner.message],
14225
+ [
14226
+ input["version"] === undefined || typeof input["artifact"] === "string",
14227
+ SPEC_FORM_VERSION_RULE
14228
+ ]
14229
+ ]);
14230
+ }
14231
+ var SPEC_FORM_RULE = `${specFormDocumentOwner.message} ${SPEC_FORM_VERSION_RULE} ${SPEC_FORM_ROOT_RULE}`;
14232
+ var specFormValidation = {
14233
+ check: (value) => specFormRefusal(value) === undefined,
14234
+ message: SPEC_FORM_RULE,
14235
+ refusal: (value) => specFormRefusal(value) ?? SPEC_FORM_RULE
14236
+ };
14214
14237
  function artifactProblem(value) {
14215
14238
  const input = value;
14216
14239
  const extension = typeof input.path === "string" || typeof input.name !== "string" ? undefined : NAME_EXTENSION.exec(input.name.trim())?.[1];
@@ -15019,6 +15042,20 @@ var dispatchToolSpecs = [
15019
15042
  }),
15020
15043
  validation: documentOwnerValidation(true)
15021
15044
  },
15045
+ {
15046
+ name: "dispatch_spec_form",
15047
+ example: { issue: "DSP-1" },
15048
+ description: "Read the form of a document's texts of The Spec, as an approval request would judge them. " + "It lists each statement, check, component purpose and term that breaks the form, with its rule. " + "It writes nothing. " + "It says whether the document is under a root of The Spec, and how many texts it read. " + "With root, it lists each issue under that root and the form of each document that the root covers.",
15049
+ arguments: (z) => ({
15050
+ issue: z.string().describe(ISSUE_REFERENCE).optional(),
15051
+ project: z.string().describe("Project key owning the document.").optional(),
15052
+ artifact: z.string().describe("Optional document artifact id, slug, or filename. Without it, the command reads the latest settled version of the spec and of the Verification document of the issue.").optional(),
15053
+ version: z.number({ int: true, min: 1 }).describe("Optional version number of the document that artifact or ref names: a version belongs to one document, so a version with an issue and no artifact is refused. Without it, the command reads the latest settled version, which an approval request would name.").optional(),
15054
+ root: z.string().describe("An issue key. The command lists each issue under that root, with the form of the spec and the Verification document of each issue. Name no other argument with it.").optional(),
15055
+ ref: z.string().describe("Optional dispatch:// document reference.").optional()
15056
+ }),
15057
+ validation: specFormValidation
15058
+ },
15022
15059
  {
15023
15060
  name: "dispatch_request_approval",
15024
15061
  example: { issue: "DSP-1", summary: "A live sync replaces the nightly export." },
@@ -16320,7 +16357,134 @@ function claimTakeableAt(liveness, lastSeen = undefined) {
16320
16357
  }
16321
16358
  return new Date(seen + ISSUE_CLAIM_UNRESPONSIVE_GRACE_MS).toISOString();
16322
16359
  }
16360
+ // ../contracts/src/dashboard-pages.json
16361
+ var dashboard_pages_default = {
16362
+ about: "Generated from the dashboard's route table by packages/dispatch/web/src/features/refs/dashboard-pages-file.ts; do not edit.",
16363
+ tabs: [
16364
+ {
16365
+ page: "verification",
16366
+ reference: "verification"
16367
+ },
16368
+ {
16369
+ page: "plan",
16370
+ reference: "plan"
16371
+ },
16372
+ {
16373
+ page: "steps",
16374
+ reference: "steps"
16375
+ },
16376
+ {
16377
+ page: "conversation",
16378
+ reference: "log"
16379
+ },
16380
+ {
16381
+ page: "children",
16382
+ reference: "children"
16383
+ },
16384
+ {
16385
+ page: "artifacts",
16386
+ reference: "artifacts"
16387
+ },
16388
+ {
16389
+ page: "activity",
16390
+ reference: "activity"
16391
+ },
16392
+ {
16393
+ page: "collaborators",
16394
+ reference: "collaborators"
16395
+ }
16396
+ ],
16397
+ document_segments: [
16398
+ "artifacts",
16399
+ "artifact"
16400
+ ],
16401
+ document_pages: {
16402
+ primary: [
16403
+ "/issues/{key}",
16404
+ "/issues/{key}/spec",
16405
+ "/issues/{key}/artifacts/{slug}",
16406
+ "/issues/{key}/artifact/{slug}"
16407
+ ],
16408
+ verification: [
16409
+ "/issues/{key}/verification",
16410
+ "/issues/{key}/artifacts/{slug}",
16411
+ "/issues/{key}/artifact/{slug}"
16412
+ ],
16413
+ plan: [
16414
+ "/issues/{key}/plan",
16415
+ "/issues/{key}/artifacts/{slug}",
16416
+ "/issues/{key}/artifact/{slug}"
16417
+ ],
16418
+ decisions: [
16419
+ "/issues/{key}/decisions",
16420
+ "/issues/{key}/artifacts/{slug}",
16421
+ "/issues/{key}/artifact/{slug}"
16422
+ ],
16423
+ issue: [
16424
+ "/issues/{key}/artifacts/{slug}",
16425
+ "/issues/{key}/artifact/{slug}"
16426
+ ],
16427
+ project: [
16428
+ "/projects/{project}/documents/{slug}"
16429
+ ],
16430
+ agent: [
16431
+ "/agents/{session}/artifacts/{slug}"
16432
+ ]
16433
+ },
16434
+ references: [
16435
+ {
16436
+ href: "/issues/CORE-1/verification",
16437
+ ref: "dispatch://CORE-1/verification"
16438
+ },
16439
+ {
16440
+ href: "/issues/CORE-1/plan",
16441
+ ref: "dispatch://CORE-1/plan"
16442
+ },
16443
+ {
16444
+ href: "/issues/CORE-1/steps",
16445
+ ref: "dispatch://CORE-1/steps"
16446
+ },
16447
+ {
16448
+ href: "/issues/CORE-1/conversation",
16449
+ ref: "dispatch://CORE-1/log"
16450
+ },
16451
+ {
16452
+ href: "/issues/CORE-1/children",
16453
+ ref: "dispatch://CORE-1/children"
16454
+ },
16455
+ {
16456
+ href: "/issues/CORE-1/artifacts",
16457
+ ref: "dispatch://CORE-1/artifacts"
16458
+ },
16459
+ {
16460
+ href: "/issues/CORE-1/activity",
16461
+ ref: "dispatch://CORE-1/activity"
16462
+ },
16463
+ {
16464
+ href: "/issues/CORE-1/collaborators",
16465
+ ref: "dispatch://CORE-1/collaborators"
16466
+ },
16467
+ {
16468
+ href: "/issues/CORE-1/artifacts/notes-md",
16469
+ ref: "dispatch://CORE-1/artifact/notes-md"
16470
+ },
16471
+ {
16472
+ href: "/issues/CORE-1/artifacts/notes-md?v=2",
16473
+ ref: "dispatch://CORE-1/artifact/notes-md@v2"
16474
+ },
16475
+ {
16476
+ href: "/issues/CORE-1/artifact/notes-md",
16477
+ ref: "dispatch://CORE-1/artifact/notes-md"
16478
+ },
16479
+ {
16480
+ href: "/issues/CORE-1/artifact/notes-md?v=2",
16481
+ ref: "dispatch://CORE-1/artifact/notes-md@v2"
16482
+ }
16483
+ ]
16484
+ };
16485
+
16323
16486
  // ../contracts/src/dispatch-href.ts
16487
+ var DISPATCH_DASHBOARD_PAGES = dashboard_pages_default;
16324
16488
  function hasControlCharacter(value) {
16325
16489
  return /\p{Cc}/u.test(value);
16326
16490
  }
@@ -16349,6 +16513,102 @@ function itemFromSearch(search) {
16349
16513
  }
16350
16514
  return ask === null ? { id, kind: "comment" } : { id, kind: "ask" };
16351
16515
  }
16516
+ var DISPATCH_HREF_REFERENCES = [
16517
+ ...DISPATCH_DASHBOARD_PAGES.references,
16518
+ { href: "/issues/CORE-1", ref: "dispatch://CORE-1" },
16519
+ { href: "/issues/CORE-1/spec", ref: "dispatch://CORE-1/spec" },
16520
+ {
16521
+ href: "/issues/CORE-1/decisions",
16522
+ ref: "dispatch://CORE-1/artifact/decisions-md"
16523
+ },
16524
+ {
16525
+ href: "/issues/CORE-1/decisions#b-ship-it",
16526
+ ref: "dispatch://CORE-1/artifact/decisions-md"
16527
+ },
16528
+ {
16529
+ href: "/issues/CORE-1/comments/11111111-1111-4111-8111-111111111111",
16530
+ ref: "dispatch://CORE-1/comment/11111111-1111-4111-8111-111111111111"
16531
+ },
16532
+ {
16533
+ href: "/issues/CORE-1/asks/22222222-2222-4222-8222-222222222222",
16534
+ ref: "dispatch://CORE-1/ask/22222222-2222-4222-8222-222222222222"
16535
+ },
16536
+ {
16537
+ href: "/issues/CORE-1/messages/33333333-3333-4333-8333-333333333333",
16538
+ ref: "dispatch://CORE-1/message/33333333-3333-4333-8333-333333333333"
16539
+ },
16540
+ {
16541
+ href: "/issues/CORE-1/spec?comment=44444444-4444-4444-8444-444444444444",
16542
+ ref: "dispatch://CORE-1/comment/44444444-4444-4444-8444-444444444444"
16543
+ },
16544
+ {
16545
+ href: "/issues/CORE-1/artifacts/notes-md?comment=55555555-5555-4555-8555-555555555555",
16546
+ ref: "dispatch://CORE-1/comment/55555555-5555-4555-8555-555555555555"
16547
+ },
16548
+ {
16549
+ href: "/issues/CORE-1/spec?ask=66666666-6666-4666-8666-666666666666",
16550
+ ref: "dispatch://CORE-1/ask/66666666-6666-4666-8666-666666666666"
16551
+ },
16552
+ {
16553
+ href: "/issues/CORE-1/artifacts/notes-md?ask=77777777-7777-4777-8777-777777777777",
16554
+ ref: "dispatch://CORE-1/ask/77777777-7777-4777-8777-777777777777"
16555
+ },
16556
+ {
16557
+ href: "/projects/CORE/documents/handbook-md",
16558
+ ref: "dispatch://CORE/artifact/handbook-md"
16559
+ },
16560
+ {
16561
+ href: "/projects/CORE/documents/handbook-md?comment=88888888-8888-4888-8888-888888888888",
16562
+ ref: "dispatch://CORE/artifact/handbook-md/comment/88888888-8888-4888-8888-888888888888"
16563
+ },
16564
+ {
16565
+ href: "/projects/CORE/documents/handbook-md?ask=99999999-9999-4999-8999-999999999999",
16566
+ ref: "dispatch://CORE/artifact/handbook-md/ask/99999999-9999-4999-8999-999999999999"
16567
+ },
16568
+ { href: "/issues/CORE-1/spec#b-ship-it", ref: "dispatch://CORE-1/spec#b-ship-it" },
16569
+ {
16570
+ href: "/issues/CORE-1/artifacts/notes-md#b-ship-it",
16571
+ ref: "dispatch://CORE-1/artifact/notes-md#b-ship-it"
16572
+ },
16573
+ {
16574
+ href: "/projects/CORE/documents/handbook-md#b-ship-it",
16575
+ ref: "dispatch://CORE/artifact/handbook-md#b-ship-it"
16576
+ },
16577
+ {
16578
+ href: "/issues/CORE-1/comments/11111111-1111-4111-8111-111111111111#b-b2",
16579
+ ref: "dispatch://CORE-1/comment/11111111-1111-4111-8111-111111111111#b-b2"
16580
+ },
16581
+ {
16582
+ href: "/issues/CORE-1/messages/33333333-3333-4333-8333-333333333333#b-b2",
16583
+ ref: "dispatch://CORE-1/message/33333333-3333-4333-8333-333333333333#b-b2"
16584
+ },
16585
+ {
16586
+ href: "/issues/CORE-1/asks/22222222-2222-4222-8222-222222222222#b-b3",
16587
+ ref: "dispatch://CORE-1/ask/22222222-2222-4222-8222-222222222222#b-b3"
16588
+ },
16589
+ {
16590
+ href: "/projects/CORE/documents/handbook-md?comment=88888888-8888-4888-8888-888888888888#b-b2",
16591
+ ref: "dispatch://CORE/artifact/handbook-md/comment/88888888-8888-4888-8888-888888888888"
16592
+ },
16593
+ {
16594
+ href: "/projects/CORE/documents/handbook-md?ask=99999999-9999-4999-8999-999999999999#b-b2",
16595
+ ref: "dispatch://CORE/artifact/handbook-md/ask/99999999-9999-4999-8999-999999999999"
16596
+ },
16597
+ {
16598
+ href: "/issues/CORE-1/spec#b-d%C3%A9cision%3A1",
16599
+ ref: "dispatch://CORE-1/spec#b-d%C3%A9cision%3A1"
16600
+ },
16601
+ { href: "/issues/CORE-1/spec#top", ref: "dispatch://CORE-1/spec" },
16602
+ { href: "/issues/CORE-1/spec?v=2#b-ship-it", ref: "dispatch://CORE-1/artifact/spec@v2" },
16603
+ {
16604
+ href: "/issues/CORE-1/artifacts/notes-md?v=2#b-ship-it",
16605
+ ref: "dispatch://CORE-1/artifact/notes-md@v2"
16606
+ },
16607
+ {
16608
+ href: "/projects/CORE/documents/handbook-md?version=3#b-ship-it",
16609
+ ref: "dispatch://CORE/artifact/handbook-md@v3"
16610
+ }
16611
+ ];
16352
16612
 
16353
16613
  // ../contracts/src/dispatch-block-ref.ts
16354
16614
  var encoder = new TextEncoder;
@@ -23364,6 +23624,9 @@ class DispatchClient {
23364
23624
  async docRead(id, version, read = {}) {
23365
23625
  return version === undefined ? this.#read(["api", "v1", "artifacts", id, "text"], undefined, read) : this.#read(["api", "v1", "artifacts", id, "versions", String(version)], undefined, read);
23366
23626
  }
23627
+ async specForm(id, version) {
23628
+ return this.#json("GET", ["api", "v1", "artifacts", id, "spec-form"], undefined, version === undefined ? undefined : { version });
23629
+ }
23367
23630
  async docReadWithBlocks(id, read = {}) {
23368
23631
  return this.#read(["api", "v1", "artifacts", id, "text"], { blocks: true }, read);
23369
23632
  }
@@ -24045,6 +24308,11 @@ ${issueReference}`;
24045
24308
  }
24046
24309
 
24047
24310
  // ../envoy-client/src/dispatch-commands/links.ts
24311
+ var issueTabReferences = new Map([
24312
+ ...DISPATCH_DASHBOARD_PAGES.tabs.map(({ page, reference }) => [page, reference]),
24313
+ ["log", "log"]
24314
+ ]);
24315
+ var issuePagePattern = new RegExp(`^/issues/([A-Z][A-Z0-9]{1,9}-[1-9][0-9]*)(?:/(spec|decisions|${[...issueTabReferences.keys()].join("|")})|/(?:${DISPATCH_DASHBOARD_PAGES.document_segments.join("|")})/([^/]+)|/asks/([^/]+)|/comments/([^/]+)|/messages/([^/]+))?/?$`);
24048
24316
  function dispatchRefFromUrl(value, serverUrl) {
24049
24317
  let url;
24050
24318
  let origin;
@@ -24064,7 +24332,7 @@ function dispatchRefFromUrl(value, serverUrl) {
24064
24332
  const id = url.hash.startsWith("#b-") ? decodeBlockId(url.hash.slice(3)) : undefined;
24065
24333
  return id === undefined || versionName !== undefined && url.searchParams.get(versionName) ? "" : `#b-${encodeBlockId(id)}`;
24066
24334
  };
24067
- const issuePage = url.pathname.match(/^\/issues\/([A-Z][A-Z0-9]{1,9}-[1-9][0-9]*)(?:\/(spec|log|conversation|activity|children|decisions)|\/artifacts\/([^/]+)|\/asks\/([^/]+)|\/comments\/([^/]+)|\/messages\/([^/]+))?\/?$/);
24335
+ const issuePage = url.pathname.match(issuePagePattern);
24068
24336
  if (issuePage) {
24069
24337
  const [, key = "", page, artifact, ask, comment, message] = issuePage;
24070
24338
  const version = versionOf("v");
@@ -24082,7 +24350,7 @@ function dispatchRefFromUrl(value, serverUrl) {
24082
24350
  if (page === "decisions")
24083
24351
  return `dispatch://${key}/artifact/decisions-md`;
24084
24352
  if (page !== undefined)
24085
- return `dispatch://${key}/${page === "conversation" ? "log" : page}`;
24353
+ return `dispatch://${key}/${issueTabReferences.get(page) ?? page}`;
24086
24354
  if (artifact !== undefined) {
24087
24355
  const slug = decodeURIComponent(artifact);
24088
24356
  return `dispatch://${key}/artifact/${slug}${version}${blockOf("v")}`;
@@ -24490,6 +24758,8 @@ async function resolveOrigin(env, exec, cwd) {
24490
24758
  }
24491
24759
 
24492
24760
  // ../envoy-client/src/dispatch-owner.ts
24761
+ var issueViewReferences = DISPATCH_DASHBOARD_PAGES.tabs.map(({ reference }) => reference).filter((reference) => !["log", "activity", "children"].includes(reference));
24762
+ var issueReferencePattern = new RegExp(`^dispatch://([A-Z][A-Z0-9]{1,9}-[1-9][0-9]*)(?:/(spec)|/(log|activity)|/(children)|/(comments)|/(${issueViewReferences.join("|")})|/artifact/([^/@]+)(?:@v(\\d+))?|/ask/([^/]+)|/comment/([^/]+)|/message/([^/]+))?$`);
24493
24763
  function documentLabel(project, slug) {
24494
24764
  return `${project}/${slug}`;
24495
24765
  }
@@ -24582,10 +24852,10 @@ function parseDispatchRef(ref) {
24582
24852
  artifact
24583
24853
  };
24584
24854
  }
24585
- const issueReference = ref.match(/^dispatch:\/\/([A-Z][A-Z0-9]{1,9}-[1-9][0-9]*)(?:\/(spec)|\/(log|activity)|\/(children)|\/(comments)|\/artifact\/([^/@]+)(?:@v(\d+))?|\/ask\/([^/]+)|\/comment\/([^/]+)|\/message\/([^/]+))?$/);
24855
+ const issueReference = ref.match(issueReferencePattern);
24586
24856
  if (!issueReference)
24587
24857
  return null;
24588
- const [, issue, spec, log, children, comments, artifact, version, ask, comment, message] = issueReference;
24858
+ const [, issue, spec, log, children, comments, tab, artifact, version, ask, comment, message] = issueReference;
24589
24859
  if (!issue || version !== undefined && Number(version) < 1)
24590
24860
  return null;
24591
24861
  const owner = { kind: "issue", issue };
@@ -24597,6 +24867,8 @@ function parseDispatchRef(ref) {
24597
24867
  return { owner, kind: "children", id: children };
24598
24868
  if (comments)
24599
24869
  return { owner, kind: "comments", id: comments };
24870
+ if (tab)
24871
+ return { owner, kind: "tab", id: tab };
24600
24872
  if (artifact) {
24601
24873
  return {
24602
24874
  owner,
@@ -27853,18 +28125,18 @@ function itemReplyTo(args, field) {
27853
28125
  return block === undefined ? { id: replyTo } : { id: block.item.id, block: block.block };
27854
28126
  }
27855
28127
  function innerRefProblem(tool, ref, refText) {
27856
- if (ref.kind !== "ask" && ref.kind !== "comment" && ref.kind !== "message" && ref.kind !== "log" && ref.kind !== "children" && ref.kind !== "comments" && ref.kind !== "block") {
28128
+ if (ref.kind !== "ask" && ref.kind !== "comment" && ref.kind !== "message" && ref.kind !== "log" && ref.kind !== "children" && ref.kind !== "comments" && ref.kind !== "tab" && ref.kind !== "block") {
27857
28129
  return;
27858
28130
  }
27859
28131
  if (tool === "dispatch_read" || tool === "dispatch_ask")
27860
28132
  return;
27861
28133
  const owner = refOwnerName(ref);
27862
28134
  const itemKind = ref.item?.kind ?? ref.kind;
27863
- const documentArgument = ref.kind === "block" && ref.item === undefined && tool !== "dispatch_comment" ? ` and artifact ${ref.id}` : tool === "dispatch_suggest" ? " and artifact <the document's slug>" : "";
28135
+ const documentArgument = ref.kind === "block" && ref.item === undefined && tool !== "dispatch_comment" ? ` and artifact ${ref.id}` : tool === "dispatch_suggest" || ref.kind === "tab" && tool !== "dispatch_comment" ? " and artifact <the document's slug>" : "";
27864
28136
  const ownerArguments = ref.owner.kind === "issue" ? `issue ${ref.owner.issue}${documentArgument}` : `project ${ref.owner.project} and artifact ${ref.artifact}`;
27865
28137
  const partRef = ref.pin === undefined ? refText : refText.slice(0, -`@v${ref.pin}`.length);
27866
28138
  const fix = tool === "dispatch_comment" && itemKind === "ask" ? `reply under it with reply_to_ask ${ref.item === undefined ? ref.id : partRef} and ${ownerArguments}` : tool === "dispatch_comment" && itemKind === "comment" ? `reply in its thread with reply_to ${ref.id} and ${ownerArguments}` : `read it with dispatch read, or name ${owner} with ${ownerArguments}`;
27867
- const item = ref.kind === "ask" ? "an ask" : ref.kind === "log" ? "the event log" : ref.kind === "children" ? "the children" : ref.kind === "comments" ? "the comments" : ref.kind === "block" ? `block ${ref.block}${ref.item === undefined ? "" : ` of ${article(ref.item.kind)}`}` : `a ${ref.kind}`;
28139
+ const item = ref.kind === "ask" ? "an ask" : ref.kind === "log" ? "the event log" : ref.kind === "children" ? "the children" : ref.kind === "comments" ? "the comments" : ref.kind === "tab" ? `the ${ref.id} tab` : ref.kind === "block" ? `block ${ref.block}${ref.item === undefined ? "" : ` of ${article(ref.item.kind)}`}` : `a ${ref.kind}`;
27868
28140
  return `ref ${refText} names ${item} on ${owner}; dispatch ${commandName(tool)} would act on ${owner} and drop the ${ref.kind}: ${fix}`;
27869
28141
  }
27870
28142
  var documentItemPattern = /^dispatch:\/\/([A-Z][A-Z0-9]{1,9}-[1-9][0-9]*)\/artifact\/[^/@]+(?:@v\d+)?\/(ask|comment)\/([^/]+)$/;
@@ -28225,6 +28497,9 @@ async function resolveOwnerArguments(tool, input, cwd, env, exec, dashboardUrls,
28225
28497
  if (tool === "dispatch_result" && typeof retract === "string") {
28226
28498
  return { args, ref, owner: null };
28227
28499
  }
28500
+ if (tool === "dispatch_spec_form" && typeof args["root"] === "string") {
28501
+ return { args, ref, owner: null };
28502
+ }
28228
28503
  const legionIssue = env.LEGION_ISSUE;
28229
28504
  if (!legionIssue) {
28230
28505
  problems.push(ownerRequiredProblem);
@@ -32113,6 +32388,162 @@ async function refuseRemovingOpenDecisionBlocks(client, tool, resolved, ops) {
32113
32388
  `));
32114
32389
  }
32115
32390
 
32391
+ // ../envoy-client/src/dispatch-commands/spec-form.ts
32392
+ function counted(count, noun) {
32393
+ return `${count} ${noun}${count === 1 ? "" : "s"}`;
32394
+ }
32395
+ function textCounts(texts) {
32396
+ const of = (kind) => texts?.[kind] ?? 0;
32397
+ return `${counted(of("statement"), "statement")}, ${counted(of("claim"), "claim")}, ${counted(of("purpose"), "purpose")} and ${counted(of("definition"), "definition")}`;
32398
+ }
32399
+ function readLine2(texts, name, version) {
32400
+ const read = Object.values(texts ?? {}).reduce((sum, count) => sum + count, 0);
32401
+ return read === 0 ? `Dispatch found no text of The Spec in ${name} version ${version}, so it decided nothing about its form.` : `Dispatch read the form of ${textCounts(texts)}: no text breaks it.`;
32402
+ }
32403
+ function unreadLines(unread) {
32404
+ return (unread ?? []).map(({ line }) => line);
32405
+ }
32406
+ function approvalFormLines(result, name) {
32407
+ const form = result.spec_form;
32408
+ return form === undefined ? [] : [readLine2(form.texts, name, result.version), ...unreadLines(form.unread)];
32409
+ }
32410
+ function scopeLine(form) {
32411
+ switch (form.scope) {
32412
+ case "no_root":
32413
+ return "This server names no root of The Spec, so Dispatch refuses no approval request for its form.";
32414
+ case "outside":
32415
+ return `${form.name} is not under a root of The Spec, so Dispatch refuses no approval request of it for its form.`;
32416
+ case "not_spec":
32417
+ return `${form.name} is not the spec or the Verification document of its issue, so Dispatch refuses no approval request of it for its form.`;
32418
+ case "root":
32419
+ return `${form.name} belongs to a root of The Spec, so Dispatch refuses no approval request of it for its form.`;
32420
+ default:
32421
+ return `${form.name} has the scope ${form.scope}, so Dispatch refuses no approval request of it for its form.`;
32422
+ }
32423
+ }
32424
+ function documentLines(form) {
32425
+ const listed = form.finding_lines ?? [];
32426
+ const read = readLine2(form.texts, form.name, form.version);
32427
+ const unread = unreadLines(form.unread);
32428
+ if (!form.in_scope) {
32429
+ return form.findings_total === 0 ? [scopeLine(form), read, ...unread] : [scopeLine(form), "The findings below are for you to read.", ...listed, ...unread];
32430
+ }
32431
+ return form.findings_total === 0 ? [read, ...unread] : [...listed, ...unread];
32432
+ }
32433
+ function noVersionLine(name) {
32434
+ return `${name} has no version yet, so Dispatch read no text in it.`;
32435
+ }
32436
+ function playsSpecOrVerification(artifact) {
32437
+ if (artifact.kind !== "doc" || typeof artifact.issue_key !== "string")
32438
+ return false;
32439
+ return artifact.primary || artifact.role === "verification" || (artifact.role ?? "") === "" && artifact.slug === "verification-md";
32440
+ }
32441
+ async function latestForm(client, artifact) {
32442
+ try {
32443
+ return await client.specForm(artifact.id);
32444
+ } catch (error) {
32445
+ if (dispatchAnswered(error, 409) && error.code === "NO_VERSION")
32446
+ return;
32447
+ throw refusalWithCode(error);
32448
+ }
32449
+ }
32450
+ async function coveredForms(client, artifacts) {
32451
+ return Promise.all(artifacts.filter(playsSpecOrVerification).map(async (artifact) => ({ artifact, form: await latestForm(client, artifact) })));
32452
+ }
32453
+ async function issueForms(client, issue) {
32454
+ const read = await coveredForms(client, (await client.getIssue(issue)).artifacts ?? []);
32455
+ const lines = read.flatMap(({ artifact, form }) => form === undefined ? [noVersionLine(artifact.name)] : [`${form.name} version ${form.version}:`, ...documentLines(form)]);
32456
+ return {
32457
+ text: read.length === 0 ? `${issue} has no spec and no Verification document, so Dispatch read no document.` : lines.join(`
32458
+ `),
32459
+ details: {
32460
+ issue,
32461
+ documents: read.flatMap(({ form }) => form === undefined ? [] : [
32462
+ {
32463
+ artifact: form.artifact_id,
32464
+ version: form.version,
32465
+ scope: form.scope,
32466
+ refuses_approval: form.refuses_approval,
32467
+ findings_total: form.findings_total
32468
+ }
32469
+ ])
32470
+ }
32471
+ };
32472
+ }
32473
+ async function rootForms(client, root) {
32474
+ const rootKey = (await client.getIssue(root)).key;
32475
+ const lines = [];
32476
+ const seen = new Set([rootKey]);
32477
+ let documents = 0;
32478
+ let findings = 0;
32479
+ const walk = async (parent, depth) => {
32480
+ const indent = " ".repeat(depth);
32481
+ for (const child of await client.listAllIssues({ parent })) {
32482
+ if (seen.has(child.key))
32483
+ continue;
32484
+ seen.add(child.key);
32485
+ const read = await coveredForms(client, await client.listIssueArtifacts(child.key));
32486
+ const totals = {};
32487
+ let issueFindings = 0;
32488
+ const documentRows = read.map(({ artifact, form }) => {
32489
+ if (form === undefined)
32490
+ return `${indent} ${noVersionLine(artifact.name)}`;
32491
+ documents += 1;
32492
+ issueFindings += form.findings_total;
32493
+ for (const [kind, count] of Object.entries(form.texts ?? {})) {
32494
+ totals[kind] = (totals[kind] ?? 0) + count;
32495
+ }
32496
+ return `${indent} ${form.name} version ${form.version} (scope ${form.scope}): ${textCounts(form.texts)}, with ${counted(form.findings_total, "finding")}.`;
32497
+ });
32498
+ findings += issueFindings;
32499
+ const issueLine = `${indent}${child.key} [${child.status}] ${child.title}`;
32500
+ lines.push(read.length === 0 ? `${issueLine}: no spec and no Verification document.` : `${issueLine}: ${textCounts(totals)}, with ${counted(issueFindings, "finding")}.`, ...documentRows);
32501
+ await walk(child.key, depth + 1);
32502
+ }
32503
+ };
32504
+ await walk(rootKey, 0);
32505
+ const issues = seen.size - 1;
32506
+ return {
32507
+ text: issues === 0 ? `Dispatch found no issue under ${rootKey}, so it read no document.` : [
32508
+ ...lines,
32509
+ `Dispatch read ${counted(issues, "issue")} and ${counted(documents, "document")} under ${rootKey}.`
32510
+ ].join(`
32511
+ `),
32512
+ details: { root: rootKey, issues, documents, findings }
32513
+ };
32514
+ }
32515
+ async function specFormCommand(context) {
32516
+ const { args, client, ownerArguments, documentOwner, resolveDocument } = context;
32517
+ const root = optionalString(args, "root");
32518
+ if (root !== undefined)
32519
+ return rootForms(client, root);
32520
+ const artifactReference = optionalString(args, "artifact") ?? (ownerArguments.ref?.kind === "spec" || ownerArguments.ref?.kind === "artifact" ? ownerArguments.ref.id : undefined);
32521
+ const owner = documentOwner();
32522
+ if (artifactReference === undefined && owner.kind === "issue") {
32523
+ return issueForms(client, owner.issue);
32524
+ }
32525
+ const resolved = await resolveDocument(owner, artifactReference);
32526
+ const version = optionalNumber(args, "version") ?? ownerArguments.ref?.version;
32527
+ let form;
32528
+ try {
32529
+ form = await client.specForm(resolved.artifact.id, version);
32530
+ } catch (error) {
32531
+ throw refusalWithCode(error);
32532
+ }
32533
+ return {
32534
+ text: documentLines(form).join(`
32535
+ `),
32536
+ details: {
32537
+ ...resolved.owner.kind === "project" ? { project: resolved.owner.project } : { issue: resolved.issue?.key },
32538
+ artifact: form.artifact_id,
32539
+ version: form.version,
32540
+ scope: form.scope,
32541
+ refuses_approval: form.refuses_approval,
32542
+ findings_total: form.findings_total
32543
+ }
32544
+ };
32545
+ }
32546
+
32116
32547
  // ../envoy-client/src/dispatch-commands/stored-text.ts
32117
32548
  import { resolve as resolvePath2 } from "path";
32118
32549
 
@@ -32888,18 +33319,19 @@ async function requestApprovalCommand(context) {
32888
33319
  actor,
32889
33320
  summary: stringArg(args, "summary"),
32890
33321
  ...includeVerification ? { include_verification: true } : {}
32891
- });
33322
+ }).catch((error) => Promise.reject(refusalWithCode(error)));
32892
33323
  const gaps = result.coverage ?? [];
32893
33324
  const coverageLines = result.coverage_unread ? [
32894
33325
  `Coverage of ${resolved.artifact.name}: unread. Dispatch could not read what the spec's requirements lack, so no line here says there is no gap; the request is recorded either way. Read the coverage again with dispatch read --issue, and mark each requirement the spec states with a requirement block and write a check that serves it, in the issue's Verification document, before the work starts.`
32895
33326
  ] : gaps.length === 0 ? [] : [
32896
33327
  `Coverage of ${resolved.artifact.name}: ${gaps.map((gap) => `${gap}.`).join(" ")} Mark each requirement the spec states with a requirement block and write a check that serves it, in the issue's Verification document, before the work starts.`
32897
33328
  ];
33329
+ const trailing = [...approvalFormLines(result, resolved.artifact.name), ...coverageLines];
32898
33330
  if (result.ask === null) {
32899
33331
  return {
32900
33332
  text: [
32901
33333
  `${resolved.artifact.name} (document id ${resolved.artifact.id}) is already approved at version ${result.version} by ${result.approval.by?.id ?? "unknown"}; no new request was opened. A change outside the decision blocks after approval makes it stale, so request again only for such a version, once the human has agreed to every point in it, with a --summary naming what changed since version ${result.version}; the human's own answer to a decision block carries the approval when that answer is the whole change.`,
32902
- ...coverageLines
33334
+ ...trailing
32903
33335
  ].join(`
32904
33336
  `),
32905
33337
  details: {
@@ -32915,7 +33347,7 @@ async function requestApprovalCommand(context) {
32915
33347
  return {
32916
33348
  text: [
32917
33349
  `${outcome}${waitsOn === undefined ? "" : ` It waits on ${waitsOn}.`} The human's Inbox asks: ${JSON.stringify(result.ask.question)}. The answer arrives as artifact.approved or artifact.changes_requested. An edit before the answer moves this request to the new version and leaves it waiting on you, and a change outside the decision blocks after approval makes the approval stale: either way, request again for the new version once the human has agreed to every point in it, which hands this request back or opens a new one, with a --summary naming what changed since the earlier approval. The human's own answer to a decision block carries the approval when that answer is the whole change since the approved version, and answers an open request Approve in their name: request nothing then.`,
32918
- ...coverageLines
33350
+ ...trailing
32919
33351
  ].join(`
32920
33352
  `),
32921
33353
  details: { ...details, artifact: resolved.artifact.id, version: result.version }
@@ -34380,6 +34812,7 @@ var dispatchCommands = {
34380
34812
  dispatch_send_to_agent: acting(sendToAgentCommand),
34381
34813
  dispatch_doc_edit: acting(docEditCommand),
34382
34814
  dispatch_doc_read: reading(docReadCommand),
34815
+ dispatch_spec_form: acting(specFormCommand),
34383
34816
  dispatch_request_approval: acting(requestApprovalCommand),
34384
34817
  dispatch_plan_approve: acting(planApproveCommand),
34385
34818
  dispatch_review: acting(reviewCommand),