@sjawhar/pi-legion-envoy 1.6.0 → 1.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/envoy.js CHANGED
@@ -29662,6 +29662,7 @@ var DispatchEventSchema = object({
29662
29662
  });
29663
29663
  var IssueEventPayloadSchema = object({
29664
29664
  title: string2().optional(),
29665
+ labels: array(string2()).optional(),
29665
29666
  status: string2().optional(),
29666
29667
  rank: string2().optional(),
29667
29668
  route: string2().nullish()
@@ -29837,7 +29838,8 @@ var dispatchToolSpecs = [
29837
29838
  parent: z.string().describe("Optional parent issue.").optional(),
29838
29839
  external: z.string().describe("Optional external issue reference.").optional(),
29839
29840
  force: z.boolean().describe("Create even though POSSIBLE_DUPLICATE listed similar issues; pass it only after reading them.").optional(),
29840
- spec: z.string().describe(`Optional initial primary-document markdown. ${SPEC_WRITING_GUIDANCE}`).optional()
29841
+ spec: z.string().describe(`Optional initial primary-document markdown. ${SPEC_WRITING_GUIDANCE}`).optional(),
29842
+ labels: z.array(z.string({ min: 1, max: 40 }), { max: 20 }).describe("Optional initial labels, at most 20 labels of up to 40 characters.").optional()
29841
29843
  })
29842
29844
  },
29843
29845
  {
@@ -29846,7 +29848,7 @@ var dispatchToolSpecs = [
29846
29848
  arguments: (z) => ({
29847
29849
  issue: z.string().describe(ISSUE_REFERENCE).optional(),
29848
29850
  project: z.string().describe("Project key owning the document.").optional(),
29849
- artifact: z.string().describe("Project document slug or id.").optional(),
29851
+ artifact: z.string().describe("Project document artifact id, slug, or filename.").optional(),
29850
29852
  ref: z.string().describe("Optional dispatch:// issue or document reference.").optional(),
29851
29853
  question: z.string({ max: 800 }).describe("Decision question, at most 800 characters."),
29852
29854
  options: z.array(z.object({
@@ -29899,7 +29901,7 @@ var dispatchToolSpecs = [
29899
29901
  arguments: (z) => ({
29900
29902
  issue: z.string().describe(ISSUE_REFERENCE).optional(),
29901
29903
  project: z.string().describe("Project key owning the document.").optional(),
29902
- artifact: z.string().describe("Artifact slug or id required when quote is given.").optional(),
29904
+ artifact: z.string().describe("Project document artifact id, slug, or filename required when quote is given.").optional(),
29903
29905
  ref: z.string().describe("Optional dispatch:// issue or document reference.").optional(),
29904
29906
  quote: z.string().describe("Optional exact quoted document text.").optional(),
29905
29907
  occurrence: z.number({ int: true, min: 0 }).describe("Optional zero-based occurrence of quote.").optional(),
@@ -29915,7 +29917,7 @@ var dispatchToolSpecs = [
29915
29917
  arguments: (z) => ({
29916
29918
  issue: z.string().describe(ISSUE_REFERENCE).optional(),
29917
29919
  project: z.string().describe("Project key owning the document.").optional(),
29918
- artifact: z.string().describe("Artifact slug or id containing the quoted text; optional when ref names it.").optional(),
29920
+ artifact: z.string().describe("Project document artifact id, slug, or filename containing the quoted text; optional when ref names it.").optional(),
29919
29921
  ref: z.string().describe("Optional dispatch:// issue or document reference.").optional(),
29920
29922
  quote: z.string().describe("Exact document text to replace."),
29921
29923
  replace_with: z.string().describe("Replacement text."),
@@ -29939,7 +29941,7 @@ var dispatchToolSpecs = [
29939
29941
  arguments: (z) => ({
29940
29942
  issue: z.string().describe(ISSUE_REFERENCE).optional(),
29941
29943
  project: z.string().describe("Project key owning the document.").optional(),
29942
- artifact: z.string().describe("Artifact slug or id for the document; optional when ref names it.").optional(),
29944
+ artifact: z.string().describe("Project document artifact id, slug, or filename; optional when ref names it.").optional(),
29943
29945
  ref: z.string().describe("Optional dispatch:// issue or document reference.").optional(),
29944
29946
  ops: z.array(z.object({
29945
29947
  op: z.enum(DOC_EDIT_OPS).describe("Edit operation."),
@@ -29960,7 +29962,7 @@ var dispatchToolSpecs = [
29960
29962
  arguments: (z) => ({
29961
29963
  issue: z.string().describe(ISSUE_REFERENCE).optional(),
29962
29964
  project: z.string().describe("Project key owning the document.").optional(),
29963
- artifact: z.string().describe("Optional artifact slug or id; primary document by default for an issue.").optional(),
29965
+ artifact: z.string().describe("Optional project document artifact id, slug, or filename; primary document by default for an issue.").optional(),
29964
29966
  version: z.number({ int: true, min: 1 }).describe("Optional version number.").optional(),
29965
29967
  ref: z.string().describe("Optional dispatch:// document reference.").optional()
29966
29968
  }),
@@ -29972,7 +29974,7 @@ var dispatchToolSpecs = [
29972
29974
  arguments: (z) => ({
29973
29975
  issue: z.string().describe(ISSUE_REFERENCE).optional(),
29974
29976
  project: z.string().describe("Project key owning the document.").optional(),
29975
- artifact: z.string().describe("Artifact slug or id; primary document by default for an issue.").optional()
29977
+ artifact: z.string().describe("Project document artifact id, slug, or filename; primary document by default for an issue.").optional()
29976
29978
  }),
29977
29979
  validation: documentOwnerValidation(true)
29978
29980
  },
@@ -30001,7 +30003,7 @@ var dispatchToolSpecs = [
30001
30003
  arguments: (z) => ({
30002
30004
  issue: z.string().describe(ISSUE_REFERENCE).optional(),
30003
30005
  project: z.string().describe("Project key owning the document.").optional(),
30004
- artifact: z.string().describe("Project document slug or id.").optional(),
30006
+ artifact: z.string().describe("Project document artifact id, slug, or filename.").optional(),
30005
30007
  ref: z.string().describe("Optional dispatch:// issue or document reference.").optional()
30006
30008
  }),
30007
30009
  validation: documentOwnerValidation(true)
@@ -31892,7 +31894,7 @@ async function resolveOwnerArguments(tool, args, cwd, env, exec) {
31892
31894
  return { args, ref: null, owner: null };
31893
31895
  const refArgument = args.ref;
31894
31896
  const ref = typeof refArgument === "string" ? parseDispatchRef(refArgument) ?? (() => {
31895
- throw new Error("ref must be a valid dispatch:// reference such as dispatch://KEY-1, " + "dispatch://KEY-1/ask/<uuid>, dispatch://KEY-1/comment/<uuid>, " + "dispatch://KEY-1/message/<uuid>, dispatch://KEY-1/artifact/<slug>, or " + "dispatch://PROJECT/artifact/<slug>");
31897
+ throw new Error("ref must be a valid dispatch:// reference such as dispatch://KEY-1, " + "dispatch://KEY-1/ask/<uuid>, dispatch://KEY-1/comment/<uuid>, " + "dispatch://KEY-1/message/<uuid>, dispatch://KEY-1/artifact/<slug>, or " + "dispatch://PROJECT/artifact/<document-ref> (an artifact id, slug, or filename)");
31896
31898
  })() : null;
31897
31899
  const issueArgument = args.issue;
31898
31900
  const projectArgument = args.project;
@@ -31973,14 +31975,16 @@ async function resolveArtifact(client, owner, artifactReference) {
31973
31975
  if (!(error instanceof DispatchServiceError) || error.status !== 404)
31974
31976
  throw error;
31975
31977
  const artifacts = await client.listProjectArtifacts(owner.project, true);
31976
- const matches = artifacts.filter((candidate) => candidate.name === artifactReference);
31977
- if (matches.length > 1) {
31978
- throw new Error(`artifact name ${artifactReference} is ambiguous in project ${owner.project}; ` + `${matches.length} documents share it \u2014 use its slug instead`);
31979
- }
31980
- const artifact = matches[0];
31981
- if (!artifact)
31978
+ const artifact = artifacts.find((candidate) => candidate.id === artifactReference) ?? artifacts.find((candidate) => candidate.slug === artifactReference);
31979
+ if (artifact)
31980
+ return { owner, artifact };
31981
+ const names = artifacts.filter((candidate) => candidate.name === artifactReference);
31982
+ if (names.length > 1) {
31983
+ throw new Error(`artifact name ${artifactReference} is ambiguous in project ${owner.project}; ` + `${names.length} documents share it \u2014 use its slug instead`);
31984
+ }
31985
+ if (names[0] === undefined)
31982
31986
  throw error;
31983
- return { owner, artifact };
31987
+ return { owner, artifact: names[0] };
31984
31988
  }
31985
31989
  }
31986
31990
  const issue = await client.getIssue(owner.issue);
@@ -32031,6 +32035,7 @@ function issueSummary(issue, events, references) {
32031
32035
  `Title: ${issue.title}`,
32032
32036
  `Key: ${issue.key}`,
32033
32037
  `Status: ${issue.status}`,
32038
+ `Labels: ${issue.labels.length === 0 ? "none" : issue.labels.join(", ")}`,
32034
32039
  `Route: ${issue.route ?? "none"}`,
32035
32040
  ...specApproval === undefined ? [] : [`Spec ${specApproval.replace(/^Approval/, "approval")}`],
32036
32041
  "Open asks:",
@@ -32163,6 +32168,7 @@ async function executeDispatchTool(input) {
32163
32168
  const external = optionalString(args, "external");
32164
32169
  const force = optionalBoolean(args, "force");
32165
32170
  const spec = optionalString(args, "spec");
32171
+ const labels = args.labels;
32166
32172
  try {
32167
32173
  const created = await client.issue({
32168
32174
  project,
@@ -32171,6 +32177,7 @@ async function executeDispatchTool(input) {
32171
32177
  ...external === undefined ? {} : { external },
32172
32178
  ...force === undefined ? {} : { force },
32173
32179
  ...spec === undefined ? {} : { spec },
32180
+ ...Array.isArray(labels) ? { labels } : {},
32174
32181
  actor
32175
32182
  });
32176
32183
  return {
package/dist/legion.js CHANGED
@@ -29661,6 +29661,7 @@ var DispatchEventSchema = object({
29661
29661
  });
29662
29662
  var IssueEventPayloadSchema = object({
29663
29663
  title: string2().optional(),
29664
+ labels: array(string2()).optional(),
29664
29665
  status: string2().optional(),
29665
29666
  rank: string2().optional(),
29666
29667
  route: string2().nullish()
@@ -29836,7 +29837,8 @@ var dispatchToolSpecs = [
29836
29837
  parent: z.string().describe("Optional parent issue.").optional(),
29837
29838
  external: z.string().describe("Optional external issue reference.").optional(),
29838
29839
  force: z.boolean().describe("Create even though POSSIBLE_DUPLICATE listed similar issues; pass it only after reading them.").optional(),
29839
- spec: z.string().describe(`Optional initial primary-document markdown. ${SPEC_WRITING_GUIDANCE}`).optional()
29840
+ spec: z.string().describe(`Optional initial primary-document markdown. ${SPEC_WRITING_GUIDANCE}`).optional(),
29841
+ labels: z.array(z.string({ min: 1, max: 40 }), { max: 20 }).describe("Optional initial labels, at most 20 labels of up to 40 characters.").optional()
29840
29842
  })
29841
29843
  },
29842
29844
  {
@@ -29845,7 +29847,7 @@ var dispatchToolSpecs = [
29845
29847
  arguments: (z) => ({
29846
29848
  issue: z.string().describe(ISSUE_REFERENCE).optional(),
29847
29849
  project: z.string().describe("Project key owning the document.").optional(),
29848
- artifact: z.string().describe("Project document slug or id.").optional(),
29850
+ artifact: z.string().describe("Project document artifact id, slug, or filename.").optional(),
29849
29851
  ref: z.string().describe("Optional dispatch:// issue or document reference.").optional(),
29850
29852
  question: z.string({ max: 800 }).describe("Decision question, at most 800 characters."),
29851
29853
  options: z.array(z.object({
@@ -29898,7 +29900,7 @@ var dispatchToolSpecs = [
29898
29900
  arguments: (z) => ({
29899
29901
  issue: z.string().describe(ISSUE_REFERENCE).optional(),
29900
29902
  project: z.string().describe("Project key owning the document.").optional(),
29901
- artifact: z.string().describe("Artifact slug or id required when quote is given.").optional(),
29903
+ artifact: z.string().describe("Project document artifact id, slug, or filename required when quote is given.").optional(),
29902
29904
  ref: z.string().describe("Optional dispatch:// issue or document reference.").optional(),
29903
29905
  quote: z.string().describe("Optional exact quoted document text.").optional(),
29904
29906
  occurrence: z.number({ int: true, min: 0 }).describe("Optional zero-based occurrence of quote.").optional(),
@@ -29914,7 +29916,7 @@ var dispatchToolSpecs = [
29914
29916
  arguments: (z) => ({
29915
29917
  issue: z.string().describe(ISSUE_REFERENCE).optional(),
29916
29918
  project: z.string().describe("Project key owning the document.").optional(),
29917
- artifact: z.string().describe("Artifact slug or id containing the quoted text; optional when ref names it.").optional(),
29919
+ artifact: z.string().describe("Project document artifact id, slug, or filename containing the quoted text; optional when ref names it.").optional(),
29918
29920
  ref: z.string().describe("Optional dispatch:// issue or document reference.").optional(),
29919
29921
  quote: z.string().describe("Exact document text to replace."),
29920
29922
  replace_with: z.string().describe("Replacement text."),
@@ -29938,7 +29940,7 @@ var dispatchToolSpecs = [
29938
29940
  arguments: (z) => ({
29939
29941
  issue: z.string().describe(ISSUE_REFERENCE).optional(),
29940
29942
  project: z.string().describe("Project key owning the document.").optional(),
29941
- artifact: z.string().describe("Artifact slug or id for the document; optional when ref names it.").optional(),
29943
+ artifact: z.string().describe("Project document artifact id, slug, or filename; optional when ref names it.").optional(),
29942
29944
  ref: z.string().describe("Optional dispatch:// issue or document reference.").optional(),
29943
29945
  ops: z.array(z.object({
29944
29946
  op: z.enum(DOC_EDIT_OPS).describe("Edit operation."),
@@ -29959,7 +29961,7 @@ var dispatchToolSpecs = [
29959
29961
  arguments: (z) => ({
29960
29962
  issue: z.string().describe(ISSUE_REFERENCE).optional(),
29961
29963
  project: z.string().describe("Project key owning the document.").optional(),
29962
- artifact: z.string().describe("Optional artifact slug or id; primary document by default for an issue.").optional(),
29964
+ artifact: z.string().describe("Optional project document artifact id, slug, or filename; primary document by default for an issue.").optional(),
29963
29965
  version: z.number({ int: true, min: 1 }).describe("Optional version number.").optional(),
29964
29966
  ref: z.string().describe("Optional dispatch:// document reference.").optional()
29965
29967
  }),
@@ -29971,7 +29973,7 @@ var dispatchToolSpecs = [
29971
29973
  arguments: (z) => ({
29972
29974
  issue: z.string().describe(ISSUE_REFERENCE).optional(),
29973
29975
  project: z.string().describe("Project key owning the document.").optional(),
29974
- artifact: z.string().describe("Artifact slug or id; primary document by default for an issue.").optional()
29976
+ artifact: z.string().describe("Project document artifact id, slug, or filename; primary document by default for an issue.").optional()
29975
29977
  }),
29976
29978
  validation: documentOwnerValidation(true)
29977
29979
  },
@@ -30000,7 +30002,7 @@ var dispatchToolSpecs = [
30000
30002
  arguments: (z) => ({
30001
30003
  issue: z.string().describe(ISSUE_REFERENCE).optional(),
30002
30004
  project: z.string().describe("Project key owning the document.").optional(),
30003
- artifact: z.string().describe("Project document slug or id.").optional(),
30005
+ artifact: z.string().describe("Project document artifact id, slug, or filename.").optional(),
30004
30006
  ref: z.string().describe("Optional dispatch:// issue or document reference.").optional()
30005
30007
  }),
30006
30008
  validation: documentOwnerValidation(true)
@@ -32318,7 +32320,7 @@ async function resolveOwnerArguments(tool, args, cwd, env, exec) {
32318
32320
  return { args, ref: null, owner: null };
32319
32321
  const refArgument = args.ref;
32320
32322
  const ref = typeof refArgument === "string" ? parseDispatchRef(refArgument) ?? (() => {
32321
- throw new Error("ref must be a valid dispatch:// reference such as dispatch://KEY-1, " + "dispatch://KEY-1/ask/<uuid>, dispatch://KEY-1/comment/<uuid>, " + "dispatch://KEY-1/message/<uuid>, dispatch://KEY-1/artifact/<slug>, or " + "dispatch://PROJECT/artifact/<slug>");
32323
+ throw new Error("ref must be a valid dispatch:// reference such as dispatch://KEY-1, " + "dispatch://KEY-1/ask/<uuid>, dispatch://KEY-1/comment/<uuid>, " + "dispatch://KEY-1/message/<uuid>, dispatch://KEY-1/artifact/<slug>, or " + "dispatch://PROJECT/artifact/<document-ref> (an artifact id, slug, or filename)");
32322
32324
  })() : null;
32323
32325
  const issueArgument = args.issue;
32324
32326
  const projectArgument = args.project;
@@ -32399,14 +32401,16 @@ async function resolveArtifact(client, owner, artifactReference) {
32399
32401
  if (!(error instanceof DispatchServiceError) || error.status !== 404)
32400
32402
  throw error;
32401
32403
  const artifacts = await client.listProjectArtifacts(owner.project, true);
32402
- const matches = artifacts.filter((candidate) => candidate.name === artifactReference);
32403
- if (matches.length > 1) {
32404
- throw new Error(`artifact name ${artifactReference} is ambiguous in project ${owner.project}; ` + `${matches.length} documents share it \u2014 use its slug instead`);
32405
- }
32406
- const artifact = matches[0];
32407
- if (!artifact)
32404
+ const artifact = artifacts.find((candidate) => candidate.id === artifactReference) ?? artifacts.find((candidate) => candidate.slug === artifactReference);
32405
+ if (artifact)
32406
+ return { owner, artifact };
32407
+ const names = artifacts.filter((candidate) => candidate.name === artifactReference);
32408
+ if (names.length > 1) {
32409
+ throw new Error(`artifact name ${artifactReference} is ambiguous in project ${owner.project}; ` + `${names.length} documents share it \u2014 use its slug instead`);
32410
+ }
32411
+ if (names[0] === undefined)
32408
32412
  throw error;
32409
- return { owner, artifact };
32413
+ return { owner, artifact: names[0] };
32410
32414
  }
32411
32415
  }
32412
32416
  const issue = await client.getIssue(owner.issue);
@@ -32457,6 +32461,7 @@ function issueSummary(issue, events, references) {
32457
32461
  `Title: ${issue.title}`,
32458
32462
  `Key: ${issue.key}`,
32459
32463
  `Status: ${issue.status}`,
32464
+ `Labels: ${issue.labels.length === 0 ? "none" : issue.labels.join(", ")}`,
32460
32465
  `Route: ${issue.route ?? "none"}`,
32461
32466
  ...specApproval === undefined ? [] : [`Spec ${specApproval.replace(/^Approval/, "approval")}`],
32462
32467
  "Open asks:",
@@ -32589,6 +32594,7 @@ async function executeDispatchTool(input) {
32589
32594
  const external = optionalString(args, "external");
32590
32595
  const force = optionalBoolean(args, "force");
32591
32596
  const spec = optionalString(args, "spec");
32597
+ const labels = args.labels;
32592
32598
  try {
32593
32599
  const created = await client.issue({
32594
32600
  project,
@@ -32597,6 +32603,7 @@ async function executeDispatchTool(input) {
32597
32603
  ...external === undefined ? {} : { external },
32598
32604
  ...force === undefined ? {} : { force },
32599
32605
  ...spec === undefined ? {} : { spec },
32606
+ ...Array.isArray(labels) ? { labels } : {},
32600
32607
  actor
32601
32608
  });
32602
32609
  return {
@@ -76,10 +76,11 @@ Issue reads include `rank`, the server-owned ordering key used by project boards
76
76
 
77
77
  Architects create newly tracked child work with:
78
78
  ```ts
79
- dispatch_issue({ project, title, parent?, external?, spec?, force? })
79
+ dispatch_issue({ project, title, parent?, external?, spec?, force?, labels?: string[] })
80
80
  ```
81
- It returns `details` `{ issue, topic }`. Use `dispatch_issue` only to create an issue; never use it to park a question. When `spec` is
82
- supplied, follow [Writing a spec](#writing-a-spec).
81
+ `labels` are optional initial labels: Dispatch trims them, preserves their case, and removes case-insensitive duplicates. It returns
82
+ `details` `{ issue, topic }`. Use `dispatch_issue` only to create an issue; never use it to park a question. When `spec` is supplied,
83
+ follow [Writing a spec](#writing-a-spec).
83
84
 
84
85
  ## Search first
85
86
 
@@ -188,7 +189,7 @@ Read the current document before changing it:
188
189
  dispatch_doc_read({ issue?, project?, artifact?, version?, ref? })
189
190
  ```
190
191
  It returns live or versioned markdown with open marks. `issue` with an omitted `artifact` reads the issue specification; a project needs
191
- `artifact`; and a `dispatch://PROJECT/artifact/<slug>` ref supplies both. Then write with:
192
+ `artifact`; and a `dispatch://PROJECT/artifact/<document-ref>` ref supplies both, where `document-ref` is the id, slug, or filename.
192
193
 
193
194
  ```ts
194
195
  dispatch_doc_edit({ issue?, project?, artifact, ops, summary? })
@@ -266,7 +267,8 @@ Exactly one of `issue` and `project` is required. A project upload creates an un
266
267
  Exactly one of `path` and `content` is required. It returns issue or project-document owner details plus `artifact`, `version`, and its
267
268
  write `topic`. Uploading the same `name` creates its next version — so uploading `spec.md` **replaces the issue's own specification**
268
269
  with your text. Never do that: the spec is edited in place with `dispatch_doc_edit` (see [The Spec](#the-spec)). Address an existing
269
- artifact by the slug shown in the upload result or by its filename; the slug also arrives on `artifact.created` events.
270
+ artifact by the slug shown in the upload result or by its filename, and a project document by its artifact id, slug, or filename; the
271
+ slug also arrives on `artifact.created` events.
270
272
 
271
273
  ## Messages
272
274
 
@@ -315,9 +317,9 @@ dispatch://KEY/artifact/<slug>[@vN]
315
317
  dispatch://KEY/ask/<id>
316
318
  dispatch://KEY/comment/<id>
317
319
  dispatch://KEY/message/<id>
318
- dispatch://PROJECT/artifact/<slug>[@vN]
319
- dispatch://PROJECT/artifact/<slug>/ask/<id>
320
- dispatch://PROJECT/artifact/<slug>/comment/<id>
320
+ dispatch://PROJECT/artifact/<document-ref>[@vN]
321
+ dispatch://PROJECT/artifact/<document-ref>/ask/<id>
322
+ dispatch://PROJECT/artifact/<document-ref>/comment/<id>
321
323
  ```
322
324
 
323
325
  A bare UUID or `KEY#seq` is not a reference; the `dispatch://` form is what Dispatch links and records.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sjawhar/pi-legion-envoy",
3
- "version": "1.6.0",
3
+ "version": "1.7.0",
4
4
  "type": "module",
5
5
  "omp": {
6
6
  "extensions": [