@gonovus-ai/spec-flow-cli 0.6.3 → 0.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.
Files changed (72) hide show
  1. package/README.md +10 -0
  2. package/dist/authentication-command-topology.js.map +1 -1
  3. package/dist/bin.js.map +1 -1
  4. package/dist/cli.js +848 -286
  5. package/dist/cli.js.map +1 -1
  6. package/dist/client-identity.d.ts +1 -1
  7. package/dist/client-identity.js +3 -1
  8. package/dist/client-identity.js.map +1 -1
  9. package/dist/commands/work-item-output.d.ts +15 -5
  10. package/dist/commands/work-item-output.js +47 -9
  11. package/dist/commands/work-item-output.js.map +1 -1
  12. package/dist/credential-store.js +6 -7
  13. package/dist/credential-store.js.map +1 -1
  14. package/dist/custom-field-color-commands.js +13 -3
  15. package/dist/custom-field-color-commands.js.map +1 -1
  16. package/dist/default-api-origin.js.map +1 -1
  17. package/dist/github-account-commands.js +116 -20
  18. package/dist/github-account-commands.js.map +1 -1
  19. package/dist/github-connection-commands.js +284 -36
  20. package/dist/github-connection-commands.js.map +1 -1
  21. package/dist/github-import-commands.js +41 -11
  22. package/dist/github-import-commands.js.map +1 -1
  23. package/dist/http-origin.js +1 -1
  24. package/dist/http-origin.js.map +1 -1
  25. package/dist/index.d.ts +1 -1
  26. package/dist/index.js +103 -35
  27. package/dist/index.js.map +1 -1
  28. package/dist/input/text-source.js +8 -2
  29. package/dist/input/text-source.js.map +1 -1
  30. package/dist/node-version.js.map +1 -1
  31. package/dist/product-map-commands.js +220 -37
  32. package/dist/product-map-commands.js.map +1 -1
  33. package/dist/program.js +5 -2
  34. package/dist/program.js.map +1 -1
  35. package/dist/project-administration-commands.js +36 -8
  36. package/dist/project-administration-commands.js.map +1 -1
  37. package/dist/runtime/errors.js +21 -3
  38. package/dist/runtime/errors.js.map +1 -1
  39. package/dist/runtime/execute.js +16 -2
  40. package/dist/runtime/execute.js.map +1 -1
  41. package/dist/runtime/identity.d.ts +8 -80
  42. package/dist/runtime/identity.js +21 -4
  43. package/dist/runtime/identity.js.map +1 -1
  44. package/dist/runtime/output.js +6 -1
  45. package/dist/runtime/output.js.map +1 -1
  46. package/dist/runtime/session.js +44 -11
  47. package/dist/runtime/session.js.map +1 -1
  48. package/dist/screen-image-commands.js +66 -14
  49. package/dist/screen-image-commands.js.map +1 -1
  50. package/dist/spec-discussion-commands.js +87 -24
  51. package/dist/spec-discussion-commands.js.map +1 -1
  52. package/dist/spec-owner-commands.js +22 -7
  53. package/dist/spec-owner-commands.js.map +1 -1
  54. package/dist/user-api-key-commands.js +92 -20
  55. package/dist/user-api-key-commands.js.map +1 -1
  56. package/dist/work-item-asset-commands.js +23 -6
  57. package/dist/work-item-asset-commands.js.map +1 -1
  58. package/dist/work-item-delivery-commands.js +97 -31
  59. package/dist/work-item-delivery-commands.js.map +1 -1
  60. package/dist/work-item-exchange-file.js +22 -8
  61. package/dist/work-item-exchange-file.js.map +1 -1
  62. package/dist/work-item-query-commands.js +403 -35
  63. package/dist/work-item-query-commands.js.map +1 -1
  64. package/dist/work-item-resource-link-commands.js +105 -28
  65. package/dist/work-item-resource-link-commands.js.map +1 -1
  66. package/dist/work-item-thread-commands.d.ts +3 -0
  67. package/dist/work-item-thread-commands.js +101 -0
  68. package/dist/work-item-thread-commands.js.map +1 -0
  69. package/dist/work-item-watcher-commands.d.ts +20 -0
  70. package/dist/work-item-watcher-commands.js +93 -0
  71. package/dist/work-item-watcher-commands.js.map +1 -0
  72. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -2,18 +2,18 @@ import { CommanderError, InvalidArgumentError } from "commander";
2
2
  import { randomUUID } from "node:crypto";
3
3
  import { z } from "zod";
4
4
  import { addAuthenticationCommandTopology } from "./authentication-command-topology.js";
5
- import { itemOutput, itemListOutput, relationListOutput, relationReceiptOutput } from "./commands/work-item-output.js";
6
- import { registerCustomFieldColorCommands, parseOptionColors } from "./custom-field-color-commands.js";
5
+ import { itemOutput, itemListOutput, relationListOutput, relationReceiptOutput, } from "./commands/work-item-output.js";
6
+ import { registerCustomFieldColorCommands, parseOptionColors, } from "./custom-field-color-commands.js";
7
7
  import { registerGitHubAccountCommands } from "./github-account-commands.js";
8
8
  import { readDescription, singleDescriptionSource } from "./input/text-source.js";
9
9
  import { registerProductMapCommands } from "./product-map-commands.js";
10
10
  import { createProgram } from "./program.js";
11
11
  import { registerProjectAdministrationCommands } from "./project-administration-commands.js";
12
12
  import { writeSkillError, skillErrorExitCode } from "./runtime/errors.js";
13
- import { execute } from "./runtime/execute.js";
13
+ import { execute, } from "./runtime/execute.js";
14
14
  import { readIdentity } from "./runtime/identity.js";
15
15
  import { writeResult } from "./runtime/output.js";
16
- import { selectSession, hasWorkspaceReadToken, rejectWorkspaceReadTokenOperation } from "./runtime/session.js";
16
+ import { selectSession, hasWorkspaceReadToken, rejectWorkspaceReadTokenOperation, } from "./runtime/session.js";
17
17
  import { registerSpecDiscussionCommands } from "./spec-discussion-commands.js";
18
18
  import { registerSpecOwnerCommands } from "./spec-owner-commands.js";
19
19
  import { registerUserApiKeyCommands } from "./user-api-key-commands.js";
@@ -22,6 +22,8 @@ import { registerWorkItemDeliveryCommands } from "./work-item-delivery-commands.
22
22
  import { readWorkItemImportFile } from "./work-item-exchange-file.js";
23
23
  import { registerWorkItemQueryCommands } from "./work-item-query-commands.js";
24
24
  import { registerWorkItemResourceLinkCommands } from "./work-item-resource-link-commands.js";
25
+ import { registerWorkItemThreadCommands } from "./work-item-thread-commands.js";
26
+ import { registerWorkItemWatcherCommands } from "./work-item-watcher-commands.js";
25
27
  export function formatResourceDiagnostic(message) {
26
28
  return `${JSON.stringify({ diagnostic: { level: "warning", message } })}\n`;
27
29
  }
@@ -49,7 +51,10 @@ const sourceReferenceInputSchema = z
49
51
  externalRevision: z.string().trim().min(1).max(200).optional(),
50
52
  section: z.string().trim().min(1).max(500).optional(),
51
53
  title: z.string().trim().min(1).max(300),
52
- url: z.url().max(2_000).refine((value) => {
54
+ url: z
55
+ .url()
56
+ .max(2_000)
57
+ .refine((value) => {
53
58
  const url = new URL(value);
54
59
  return ((url.protocol === "https:" || url.protocol === "http:") &&
55
60
  url.username.length === 0 &&
@@ -68,7 +73,11 @@ const findingReferenceSchema = z
68
73
  const findingTargetSchema = z
69
74
  .object({
70
75
  references: z.array(findingReferenceSchema).min(1).max(50),
71
- specId: z.string().trim().toUpperCase().regex(/^[A-Z]{2,10}-S[1-9]\d*$/u),
76
+ specId: z
77
+ .string()
78
+ .trim()
79
+ .toUpperCase()
80
+ .regex(/^[A-Z]{2,10}-S[1-9]\d*$/u),
72
81
  })
73
82
  .strict();
74
83
  const findingEvidenceSchema = z.discriminatedUnion("kind", [
@@ -142,7 +151,9 @@ const findingCreateInputSchema = z
142
151
  export async function runCli(arguments_, dependencies) {
143
152
  let exitCode = 0;
144
153
  let outputMode = "full";
145
- const warnMissingUrl = () => { dependencies.stderr(formatResourceDiagnostic("This server version does not support Work Item URLs; upgrade the server. The business operation succeeded.")); };
154
+ const warnMissingUrl = () => {
155
+ dependencies.stderr(formatResourceDiagnostic("This server version does not support Work Item URLs; upgrade the server. The business operation succeeded."));
156
+ };
146
157
  const program = createProgram(dependencies);
147
158
  const run = async (request, options = {}) => {
148
159
  const selected = await selectSession(dependencies, options, program.getOptionValue("server"), program.getOptionValue("apiKeyId"));
@@ -159,27 +170,61 @@ export async function runCli(arguments_, dependencies) {
159
170
  }
160
171
  me = identity.data.user.id;
161
172
  }
162
- const result = await execute(client => request(client, me, selected.credentialKind), selected.client, options);
173
+ const result = await execute((client) => request(client, me, selected.credentialKind), selected.client, options);
163
174
  if (!result.ok) {
164
175
  writeSkillError(dependencies, result.error);
165
176
  return skillErrorExitCode(result.error);
166
177
  }
167
178
  return writeResult(dependencies, () => options.project === undefined ? result.data : options.project(result.data));
168
179
  };
169
- registerUserApiKeyCommands(program, { dependencies, run, setExitCode: (value) => { exitCode = value; }, parseScopes: parseRoleStatements, parseLimit: parseSearchLimit });
170
- registerGitHubAccountCommands(program, { dependencies, run, setExitCode: (value) => { exitCode = value; } });
180
+ registerUserApiKeyCommands(program, {
181
+ dependencies,
182
+ run,
183
+ setExitCode: (value) => {
184
+ exitCode = value;
185
+ },
186
+ parseScopes: parseRoleStatements,
187
+ parseLimit: parseSearchLimit,
188
+ });
189
+ registerGitHubAccountCommands(program, {
190
+ dependencies,
191
+ run,
192
+ setExitCode: (value) => {
193
+ exitCode = value;
194
+ },
195
+ });
171
196
  const authentication = addAuthenticationCommandTopology(program);
172
197
  program.hook("preAction", (_command, actionCommand) => {
173
198
  const names = [];
174
199
  for (let command = actionCommand; command.parent !== null; command = command.parent)
175
200
  names.unshift(command.name());
176
201
  const path = names.join(" ");
177
- outputMode = program.opts().output ?? (path === "work-item subtask link" ? "summary" : "full");
178
- if (outputMode === "summary" && !["work-item create", "work-item read", "work-item update", "work-item assign", "work-item list", "work-item relation create", "work-item relation list", "work-item subtask link"].includes(path))
202
+ outputMode =
203
+ program.opts().output ??
204
+ (path === "work-item subtask link" ? "summary" : "full");
205
+ if (outputMode === "summary" &&
206
+ ![
207
+ "work-item create",
208
+ "work-item read",
209
+ "work-item update",
210
+ "work-item assign",
211
+ "work-item list",
212
+ "work-item relation create",
213
+ "work-item relation list",
214
+ "work-item subtask link",
215
+ ].includes(path))
179
216
  throw invalidArgument("Summary output is not supported for this command");
180
- if (!["work-item create", "work-item assign"].includes(path)) {
217
+ if (![
218
+ "work-item create",
219
+ "work-item assign",
220
+ "work-item list",
221
+ "work-item board",
222
+ "work-item export",
223
+ ].includes(path)) {
181
224
  const assignee = actionCommand.getOptionValue("assignee");
182
- if (assignee === "me" || (Array.isArray(assignee) && assignee.some(value => typeof value === "string" && value.split(",").includes("me"))))
225
+ if (assignee === "me" ||
226
+ (Array.isArray(assignee) &&
227
+ assignee.some((value) => typeof value === "string" && value.split(",").includes("me"))))
183
228
  throw invalidArgument("This command accepts User IDs only; me is supported by work-item create and assign");
184
229
  }
185
230
  const options = actionCommand.opts();
@@ -193,32 +238,36 @@ export async function runCli(arguments_, dependencies) {
193
238
  actionCommand.setOptionValue("workItemId", parseWorkItemId(options.workItemId));
194
239
  }
195
240
  });
196
- for (const command of [
197
- authentication.login,
198
- authentication.logout,
199
- authentication.status,
200
- ]) {
241
+ for (const command of [authentication.login, authentication.logout, authentication.status]) {
201
242
  command.action(() => {
202
243
  throw new CommanderError(2, "specflow.authenticationCommand", "Authentication commands use the human-facing CLI boundary");
203
244
  });
204
245
  }
205
246
  dependencies.registerAuthentication?.(program, authentication);
206
- authentication.status.parent?.command("whoami").description("Read the current User ID and selected credential kind").action(async () => {
247
+ authentication.status.parent
248
+ ?.command("whoami")
249
+ .description("Read the current User ID and selected credential kind")
250
+ .action(async () => {
207
251
  exitCode = await run(async (client, _me, credentialKind) => {
208
252
  const result = await readIdentity(client);
209
- return { ...result, ...(result.data === undefined ? {} : { data: { user: { id: result.data.user.id }, credentialKind } }) };
253
+ return {
254
+ ...result,
255
+ ...(result.data === undefined
256
+ ? {}
257
+ : { data: { user: { id: result.data.user.id }, credentialKind } }),
258
+ };
210
259
  }, { rejectWorkspaceReadToken: true });
211
260
  });
212
261
  const workspace = program.command("workspace");
213
- workspace
214
- .command("list")
215
- .action(async () => {
216
- exitCode = await run((client) => client.GET("/v1/workspaces"), { rejectWorkspaceReadToken: true });
262
+ workspace.command("list").action(async () => {
263
+ exitCode = await run((client) => client.GET("/v1/workspaces"), {
264
+ rejectWorkspaceReadToken: true,
265
+ });
217
266
  });
218
267
  workspace
219
268
  .command("create")
220
269
  .requiredOption("--name <name>")
221
- .requiredOption("--prefix <prefix>", "Immutable Workspace number prefix, 2 to 10 uppercase letters")
270
+ .option("--prefix <prefix>", "Immutable Workspace number prefix, 2 to 10 uppercase letters")
222
271
  .option("--spec-language <language>", "Workspace keyword language: zh-CN or en", (value) => z.enum(["zh-CN", "en"]).parse(value), "zh-CN")
223
272
  .action(async (options) => {
224
273
  if (hasWorkspaceReadToken(dependencies.environment)) {
@@ -227,23 +276,63 @@ export async function runCli(arguments_, dependencies) {
227
276
  }
228
277
  const idempotencyKey = randomUUID();
229
278
  exitCode = await run((client) => client.POST("/v1/workspaces", {
230
- body: { name: options.name, prefix: options.prefix, specLanguage: options.specLanguage },
279
+ body: {
280
+ name: options.name,
281
+ prefix: options.prefix,
282
+ specLanguage: options.specLanguage,
283
+ },
231
284
  params: { header: { "idempotency-key": idempotencyKey } },
232
- }), { retryTransportOnce: true, ambiguousOutcomeMessage: "Workspace creation outcome is unknown; run workspace list before trying a new command identity" });
285
+ }), {
286
+ retryTransportOnce: true,
287
+ ambiguousOutcomeMessage: "Workspace creation outcome is unknown; run workspace list before trying a new command identity",
288
+ });
233
289
  });
234
- workspace.command("rename").requiredOption("--workspace-id <workspaceId>").requiredOption("--name <name>").requiredOption("--expected-version <version>", "Observed Workspace settings version", parseOpaqueVersion).requiredOption("--idempotency-key <key>").action(async (options) => {
235
- exitCode = await run(client => client.PATCH("/v1/workspaces/{workspaceId}/settings", { params: { path: { workspaceId: options.workspaceId }, header: { "idempotency-key": options.idempotencyKey, "if-match": options.expectedVersion } }, body: { name: options.name } }), { retryTransportOnce: true });
290
+ workspace
291
+ .command("rename")
292
+ .requiredOption("--workspace-id <workspaceId>")
293
+ .requiredOption("--name <name>")
294
+ .requiredOption("--expected-version <version>", "Observed Workspace settings version", parseOpaqueVersion)
295
+ .requiredOption("--idempotency-key <key>")
296
+ .action(async (options) => {
297
+ exitCode = await run((client) => client.PATCH("/v1/workspaces/{workspaceId}/settings", {
298
+ params: {
299
+ path: { workspaceId: options.workspaceId },
300
+ header: {
301
+ "idempotency-key": options.idempotencyKey,
302
+ "if-match": options.expectedVersion,
303
+ },
304
+ },
305
+ body: { name: options.name },
306
+ }), { retryTransportOnce: true });
236
307
  });
237
308
  const workspaceSettings = workspace.command("settings");
238
- workspaceSettings.command("read").requiredOption("--workspace-id <workspaceId>").action(async (options) => {
239
- exitCode = await run(client => client.GET("/v1/workspaces/{workspaceId}/settings", { params: { path: options } }));
309
+ workspaceSettings
310
+ .command("read")
311
+ .requiredOption("--workspace-id <workspaceId>")
312
+ .action(async (options) => {
313
+ exitCode = await run((client) => client.GET("/v1/workspaces/{workspaceId}/settings", { params: { path: options } }));
240
314
  });
241
- workspaceSettings.command("update").requiredOption("--workspace-id <workspaceId>").requiredOption("--spec-language <language>", "Workspace keyword language", (value) => z.enum(["zh-CN", "en"]).parse(value)).requiredOption("--expected-version <version>", "Observed Workspace settings version", parseOpaqueVersion).requiredOption("--idempotency-key <key>").action(async (options) => {
315
+ workspaceSettings
316
+ .command("update")
317
+ .requiredOption("--workspace-id <workspaceId>")
318
+ .requiredOption("--spec-language <language>", "Workspace keyword language", (value) => z.enum(["zh-CN", "en"]).parse(value))
319
+ .requiredOption("--expected-version <version>", "Observed Workspace settings version", parseOpaqueVersion)
320
+ .requiredOption("--idempotency-key <key>")
321
+ .action(async (options) => {
242
322
  if (hasWorkspaceReadToken(dependencies.environment)) {
243
323
  exitCode = rejectTokenWrite(dependencies);
244
324
  return;
245
325
  }
246
- exitCode = await run(client => client.PATCH("/v1/workspaces/{workspaceId}/settings", { params: { path: { workspaceId: options.workspaceId }, header: { "idempotency-key": options.idempotencyKey, "if-match": options.expectedVersion } }, body: { specLanguage: options.specLanguage } }), { retryTransportOnce: true });
326
+ exitCode = await run((client) => client.PATCH("/v1/workspaces/{workspaceId}/settings", {
327
+ params: {
328
+ path: { workspaceId: options.workspaceId },
329
+ header: {
330
+ "idempotency-key": options.idempotencyKey,
331
+ "if-match": options.expectedVersion,
332
+ },
333
+ },
334
+ body: { specLanguage: options.specLanguage },
335
+ }), { retryTransportOnce: true });
247
336
  });
248
337
  const workspaceMember = workspace.command("member");
249
338
  workspaceMember
@@ -440,12 +529,8 @@ export async function runCli(arguments_, dependencies) {
440
529
  exitCode = await run((client) => client.GET("/v1/projects", {
441
530
  params: {
442
531
  query: {
443
- ...(options.status === undefined
444
- ? {}
445
- : { status: options.status }),
446
- ...(options.workspaceId === undefined
447
- ? {}
448
- : { workspaceId: options.workspaceId }),
532
+ ...(options.status === undefined ? {} : { status: options.status }),
533
+ ...(options.workspaceId === undefined ? {} : { workspaceId: options.workspaceId }),
449
534
  },
450
535
  },
451
536
  }), { rejectWorkspaceReadToken: true });
@@ -498,15 +583,19 @@ export async function runCli(arguments_, dependencies) {
498
583
  params: { path: { projectId: options.projectId } },
499
584
  }));
500
585
  });
501
- const sharing = project.command("sharing").description("Manage anonymous task-only Project sharing");
502
- sharing.command("read")
586
+ const sharing = project
587
+ .command("sharing")
588
+ .description("Manage anonymous task-only Project sharing");
589
+ sharing
590
+ .command("read")
503
591
  .requiredOption("--project-id <projectId>")
504
592
  .action(async (options) => {
505
593
  exitCode = await run((client) => client.GET("/v1/projects/{projectId}/sharing", {
506
594
  params: { path: { projectId: options.projectId } },
507
595
  }), { rejectWorkspaceReadToken: true });
508
596
  });
509
- sharing.command("set")
597
+ sharing
598
+ .command("set")
510
599
  .requiredOption("--project-id <projectId>")
511
600
  .requiredOption("--public <boolean>", "true or false", (value) => {
512
601
  if (value !== "true" && value !== "false")
@@ -526,12 +615,39 @@ export async function runCli(arguments_, dependencies) {
526
615
  }
527
616
  exitCode = await run((client) => client.PUT("/v1/projects/{projectId}/sharing", {
528
617
  body: { isPublic: options.public },
529
- params: { path: { projectId: options.projectId }, header: { "if-match": options.expectedVersion, "idempotency-key": options.idempotencyKey } },
530
- }), { rejectWorkspaceReadToken: true, retryTransportOnce: true, ambiguousOutcomeMessage: "Sharing outcome is unknown; reread project sharing and retry the same command key and intent" });
618
+ params: {
619
+ path: { projectId: options.projectId },
620
+ header: {
621
+ "if-match": options.expectedVersion,
622
+ "idempotency-key": options.idempotencyKey,
623
+ },
624
+ },
625
+ }), {
626
+ rejectWorkspaceReadToken: true,
627
+ retryTransportOnce: true,
628
+ ambiguousOutcomeMessage: "Sharing outcome is unknown; reread project sharing and retry the same command key and intent",
629
+ });
531
630
  });
532
631
  const spec = program.command("spec");
533
- spec.command("list").requiredOption("--workspace-id <workspaceId>").option("--project-id <projectId>").option("--query <query>").option("--limit <limit>", "Maximum results", parseSearchLimit, 50).option("--cursor <cursor>").action(async (options) => {
534
- exitCode = await run(client => client.GET("/v1/workspaces/{workspaceId}/spec-directory", { params: { path: { workspaceId: options.workspaceId }, query: { ...(options.projectId === undefined ? {} : { projectId: options.projectId }), ...(options.query === undefined ? {} : { query: options.query }), limit: options.limit, ...(options.cursor === undefined ? {} : { cursor: options.cursor }) } } }), { rejectWorkspaceReadToken: true });
632
+ spec
633
+ .command("list")
634
+ .requiredOption("--workspace-id <workspaceId>")
635
+ .option("--project-id <projectId>")
636
+ .option("--query <query>")
637
+ .option("--limit <limit>", "Maximum results", parseSearchLimit, 50)
638
+ .option("--cursor <cursor>")
639
+ .action(async (options) => {
640
+ exitCode = await run((client) => client.GET("/v1/workspaces/{workspaceId}/spec-directory", {
641
+ params: {
642
+ path: { workspaceId: options.workspaceId },
643
+ query: {
644
+ ...(options.projectId === undefined ? {} : { projectId: options.projectId }),
645
+ ...(options.query === undefined ? {} : { query: options.query }),
646
+ limit: options.limit,
647
+ ...(options.cursor === undefined ? {} : { cursor: options.cursor }),
648
+ },
649
+ },
650
+ }), { rejectWorkspaceReadToken: true });
535
651
  });
536
652
  spec
537
653
  .command("read")
@@ -547,7 +663,9 @@ export async function runCli(arguments_, dependencies) {
547
663
  .requiredOption("--workspace-id <workspaceId>")
548
664
  .requiredOption("--spec-id <specId>")
549
665
  .action(async (options) => {
550
- exitCode = await run((client) => client.GET("/v1/workspaces/{workspaceId}/specs/{specId}/changelog", { params: { path: options } }), { rejectWorkspaceReadToken: true });
666
+ exitCode = await run((client) => client.GET("/v1/workspaces/{workspaceId}/specs/{specId}/changelog", {
667
+ params: { path: options },
668
+ }), { rejectWorkspaceReadToken: true });
551
669
  });
552
670
  spec
553
671
  .command("search")
@@ -560,9 +678,7 @@ export async function runCli(arguments_, dependencies) {
560
678
  params: {
561
679
  path: { workspaceId: options.workspaceId },
562
680
  query: {
563
- ...(options.cursor === undefined
564
- ? {}
565
- : { cursor: options.cursor }),
681
+ ...(options.cursor === undefined ? {} : { cursor: options.cursor }),
566
682
  limit: options.limit,
567
683
  query: options.query,
568
684
  },
@@ -574,7 +690,9 @@ export async function runCli(arguments_, dependencies) {
574
690
  .requiredOption("--workspace-id <workspaceId>")
575
691
  .requiredOption("--spec-id <specId>")
576
692
  .action(async (options) => {
577
- exitCode = await run((client) => client.GET(hasWorkspaceReadToken(dependencies.environment) ? "/v1/workspaces/{workspaceId}/published/specs/{specId}/current-revision" : "/v1/workspaces/{workspaceId}/specs/{specId}/current-revision", { params: { path: options } }));
693
+ exitCode = await run((client) => client.GET(hasWorkspaceReadToken(dependencies.environment)
694
+ ? "/v1/workspaces/{workspaceId}/published/specs/{specId}/current-revision"
695
+ : "/v1/workspaces/{workspaceId}/specs/{specId}/current-revision", { params: { path: options } }));
578
696
  });
579
697
  spec
580
698
  .command("revision")
@@ -582,7 +700,9 @@ export async function runCli(arguments_, dependencies) {
582
700
  .requiredOption("--spec-id <specId>")
583
701
  .requiredOption("--revision-id <revisionId>")
584
702
  .action(async (options) => {
585
- exitCode = await run((client) => client.GET(hasWorkspaceReadToken(dependencies.environment) ? "/v1/workspaces/{workspaceId}/published/specs/{specId}/revisions/{revisionId}" : "/v1/workspaces/{workspaceId}/specs/{specId}/revisions/{revisionId}", { params: { path: options } }));
703
+ exitCode = await run((client) => client.GET(hasWorkspaceReadToken(dependencies.environment)
704
+ ? "/v1/workspaces/{workspaceId}/published/specs/{specId}/revisions/{revisionId}"
705
+ : "/v1/workspaces/{workspaceId}/specs/{specId}/revisions/{revisionId}", { params: { path: options } }));
586
706
  });
587
707
  spec
588
708
  .command("edit")
@@ -688,8 +808,7 @@ export async function runCli(arguments_, dependencies) {
688
808
  exitCode = rejectTokenWrite(dependencies);
689
809
  return;
690
810
  }
691
- if (options.capabilityId === undefined &&
692
- options.sourceReferences === undefined) {
811
+ if (options.capabilityId === undefined && options.sourceReferences === undefined) {
693
812
  throw invalidArgument("Spec update requires Metadata to change");
694
813
  }
695
814
  const sourceReferences = options.sourceReferences === undefined
@@ -700,9 +819,7 @@ export async function runCli(arguments_, dependencies) {
700
819
  ...(options.capabilityId === undefined
701
820
  ? {}
702
821
  : { capabilityId: options.capabilityId === "none" ? null : options.capabilityId }),
703
- ...(sourceReferences === undefined
704
- ? {}
705
- : { sourceReferences }),
822
+ ...(sourceReferences === undefined ? {} : { sourceReferences }),
706
823
  },
707
824
  params: {
708
825
  header: { "if-match": options.expectedVersion },
@@ -746,12 +863,10 @@ export async function runCli(arguments_, dependencies) {
746
863
  exitCode = rejectTokenWrite(dependencies);
747
864
  return;
748
865
  }
749
- if (options.state === "Unavailable" &&
750
- options.unavailabilityReason === undefined) {
866
+ if (options.state === "Unavailable" && options.unavailabilityReason === undefined) {
751
867
  throw invalidArgument("Unavailable requires --unavailability-reason");
752
868
  }
753
- if (options.state === "Ready" &&
754
- options.unavailabilityReason !== undefined) {
869
+ if (options.state === "Ready" && options.unavailabilityReason !== undefined) {
755
870
  throw invalidArgument("Ready does not accept --unavailability-reason");
756
871
  }
757
872
  exitCode = await run((client) => client.PATCH("/v1/workspaces/{workspaceId}/specs/{specId}/state", {
@@ -812,7 +927,9 @@ export async function runCli(arguments_, dependencies) {
812
927
  .requiredOption("--workspace-id <workspaceId>")
813
928
  .requiredOption("--revision-id <revisionId>")
814
929
  .action(async (options) => {
815
- exitCode = await run((client) => client.GET(hasWorkspaceReadToken(dependencies.environment) ? "/v1/workspaces/{workspaceId}/published/glossary/revisions/{revisionId}" : "/v1/workspaces/{workspaceId}/glossary/revisions/{revisionId}", { params: { path: options } }));
930
+ exitCode = await run((client) => client.GET(hasWorkspaceReadToken(dependencies.environment)
931
+ ? "/v1/workspaces/{workspaceId}/published/glossary/revisions/{revisionId}"
932
+ : "/v1/workspaces/{workspaceId}/glossary/revisions/{revisionId}", { params: { path: options } }));
816
933
  });
817
934
  workspaceGlossary
818
935
  .command("read")
@@ -909,8 +1026,13 @@ export async function runCli(arguments_, dependencies) {
909
1026
  retryTransportOnce: true,
910
1027
  });
911
1028
  });
912
- workspace.command("context").requiredOption("--workspace-id <workspaceId>").action(async (options) => {
913
- exitCode = await run((client) => client.GET("/v1/workspaces/{workspaceId}/knowledge-context", { params: { path: { workspaceId: options.workspaceId } } }), { rejectWorkspaceReadToken: true });
1029
+ workspace
1030
+ .command("context")
1031
+ .requiredOption("--workspace-id <workspaceId>")
1032
+ .action(async (options) => {
1033
+ exitCode = await run((client) => client.GET("/v1/workspaces/{workspaceId}/knowledge-context", {
1034
+ params: { path: { workspaceId: options.workspaceId } },
1035
+ }), { rejectWorkspaceReadToken: true });
914
1036
  });
915
1037
  const proposal = program.command("proposal");
916
1038
  proposal
@@ -992,9 +1114,7 @@ export async function runCli(arguments_, dependencies) {
992
1114
  query: {
993
1115
  ...(options.specId === undefined ? {} : { specId: options.specId }),
994
1116
  ...(options.status === undefined ? {} : { status: options.status }),
995
- ...(options.targetKind === undefined
996
- ? {}
997
- : { targetKind: options.targetKind }),
1117
+ ...(options.targetKind === undefined ? {} : { targetKind: options.targetKind }),
998
1118
  },
999
1119
  },
1000
1120
  }));
@@ -1147,9 +1267,27 @@ export async function runCli(arguments_, dependencies) {
1147
1267
  .option("--limit <limit>", "Maximum results", parseSearchLimit, 20)
1148
1268
  .option("--cursor <cursor>")
1149
1269
  .action(async (options) => {
1150
- exitCode = await run(client => options.specId === undefined
1151
- ? client.GET("/v1/workspaces/{workspaceId}/findings", { params: { path: { workspaceId: options.workspaceId }, query: { limit: options.limit, ...(options.cursor === undefined ? {} : { cursor: options.cursor }), ...(options.status === undefined ? {} : { status: options.status }) } } })
1152
- : client.GET("/v1/workspaces/{workspaceId}/specs/{specId}/findings", { params: { path: { workspaceId: options.workspaceId, specId: options.specId }, query: { limit: options.limit, ...(options.cursor === undefined ? {} : { cursor: options.cursor }), ...(options.status === undefined ? {} : { status: options.status }) } } }), { rejectWorkspaceReadToken: true });
1270
+ exitCode = await run((client) => options.specId === undefined
1271
+ ? client.GET("/v1/workspaces/{workspaceId}/findings", {
1272
+ params: {
1273
+ path: { workspaceId: options.workspaceId },
1274
+ query: {
1275
+ limit: options.limit,
1276
+ ...(options.cursor === undefined ? {} : { cursor: options.cursor }),
1277
+ ...(options.status === undefined ? {} : { status: options.status }),
1278
+ },
1279
+ },
1280
+ })
1281
+ : client.GET("/v1/workspaces/{workspaceId}/specs/{specId}/findings", {
1282
+ params: {
1283
+ path: { workspaceId: options.workspaceId, specId: options.specId },
1284
+ query: {
1285
+ limit: options.limit,
1286
+ ...(options.cursor === undefined ? {} : { cursor: options.cursor }),
1287
+ ...(options.status === undefined ? {} : { status: options.status }),
1288
+ },
1289
+ },
1290
+ }), { rejectWorkspaceReadToken: true });
1153
1291
  });
1154
1292
  workspaceFinding
1155
1293
  .command("read")
@@ -1213,36 +1351,112 @@ export async function runCli(arguments_, dependencies) {
1213
1351
  });
1214
1352
  });
1215
1353
  }
1216
- workspaceFinding.command("handler").requiredOption("--workspace-id <workspaceId>").requiredOption("--finding-id <findingId>").option("--user-id <userId>", "Workspace member; omit to clear the handler").requiredOption("--expected-version <expectedVersion>", "Opaque version", parseOpaqueVersion).requiredOption("--idempotency-key <key>").action(async (options) => {
1217
- exitCode = await run(client => client.PATCH("/v1/workspaces/{workspaceId}/findings/{findingId}/handler", { body: { handlerUserId: options.userId ?? null }, params: { path: options, header: { "idempotency-key": options.idempotencyKey, "if-match": options.expectedVersion } } }), { rejectWorkspaceReadToken: true });
1354
+ workspaceFinding
1355
+ .command("handler")
1356
+ .requiredOption("--workspace-id <workspaceId>")
1357
+ .requiredOption("--finding-id <findingId>")
1358
+ .option("--user-id <userId>", "Workspace member; omit to clear the handler")
1359
+ .requiredOption("--expected-version <expectedVersion>", "Opaque version", parseOpaqueVersion)
1360
+ .requiredOption("--idempotency-key <key>")
1361
+ .action(async (options) => {
1362
+ exitCode = await run((client) => client.PATCH("/v1/workspaces/{workspaceId}/findings/{findingId}/handler", {
1363
+ body: { handlerUserId: options.userId ?? null },
1364
+ params: {
1365
+ path: options,
1366
+ header: {
1367
+ "idempotency-key": options.idempotencyKey,
1368
+ "if-match": options.expectedVersion,
1369
+ },
1370
+ },
1371
+ }), { rejectWorkspaceReadToken: true });
1218
1372
  });
1219
- workspaceFinding.command("follow-up").requiredOption("--workspace-id <workspaceId>").requiredOption("--finding-id <findingId>").requiredOption("--project-id <projectId>").requiredOption("--idempotency-key <key>").action(async (options) => {
1220
- exitCode = await run(client => client.POST("/v1/workspaces/{workspaceId}/findings/{findingId}/work-item", { body: { projectId: options.projectId }, params: { path: { workspaceId: options.workspaceId, findingId: options.findingId }, header: { "idempotency-key": options.idempotencyKey } } }), { rejectWorkspaceReadToken: true });
1373
+ workspaceFinding
1374
+ .command("follow-up")
1375
+ .requiredOption("--workspace-id <workspaceId>")
1376
+ .requiredOption("--finding-id <findingId>")
1377
+ .requiredOption("--project-id <projectId>")
1378
+ .requiredOption("--idempotency-key <key>")
1379
+ .action(async (options) => {
1380
+ exitCode = await run((client) => client.POST("/v1/workspaces/{workspaceId}/findings/{findingId}/work-item", {
1381
+ body: { projectId: options.projectId },
1382
+ params: {
1383
+ path: { workspaceId: options.workspaceId, findingId: options.findingId },
1384
+ header: { "idempotency-key": options.idempotencyKey },
1385
+ },
1386
+ }), { rejectWorkspaceReadToken: true });
1221
1387
  });
1222
- workspaceFinding.command("discussion").requiredOption("--workspace-id <workspaceId>").requiredOption("--finding-id <findingId>").action(async (options) => {
1223
- exitCode = await run(client => client.GET("/v1/workspaces/{workspaceId}/findings/{findingId}/discussion", { params: { path: options } }), { rejectWorkspaceReadToken: true });
1388
+ workspaceFinding
1389
+ .command("discussion")
1390
+ .requiredOption("--workspace-id <workspaceId>")
1391
+ .requiredOption("--finding-id <findingId>")
1392
+ .action(async (options) => {
1393
+ exitCode = await run((client) => client.GET("/v1/workspaces/{workspaceId}/findings/{findingId}/discussion", {
1394
+ params: { path: options },
1395
+ }), { rejectWorkspaceReadToken: true });
1224
1396
  });
1225
- workspaceFinding.command("comment").requiredOption("--workspace-id <workspaceId>").requiredOption("--finding-id <findingId>").requiredOption("--body <body>").option("--parent-id <parentId>").requiredOption("--idempotency-key <key>").action(async (options) => {
1226
- exitCode = await run(client => client.POST("/v1/workspaces/{workspaceId}/findings/{findingId}/discussion", { body: { body: options.body, parentId: options.parentId ?? null }, params: { path: options, header: { "idempotency-key": options.idempotencyKey } } }), { rejectWorkspaceReadToken: true });
1397
+ workspaceFinding
1398
+ .command("comment")
1399
+ .requiredOption("--workspace-id <workspaceId>")
1400
+ .requiredOption("--finding-id <findingId>")
1401
+ .requiredOption("--body <body>")
1402
+ .option("--parent-id <parentId>")
1403
+ .requiredOption("--idempotency-key <key>")
1404
+ .action(async (options) => {
1405
+ exitCode = await run((client) => client.POST("/v1/workspaces/{workspaceId}/findings/{findingId}/discussion", {
1406
+ body: { body: options.body, parentId: options.parentId ?? null },
1407
+ params: { path: options, header: { "idempotency-key": options.idempotencyKey } },
1408
+ }), { rejectWorkspaceReadToken: true });
1227
1409
  });
1228
1410
  const workspaceReview = workspace.command("review");
1229
- workspaceReview.command("request").requiredOption("--workspace-id <workspaceId>").requiredOption("--spec-id <specId>").option("--idempotency-key <key>").action(async (options) => {
1230
- exitCode = await run(client => client.POST("/v1/workspaces/{workspaceId}/specs/{specId}/reviews", { params: { path: options, header: { "idempotency-key": options.idempotencyKey ?? randomUUID() } } }), { rejectWorkspaceReadToken: true });
1411
+ workspaceReview
1412
+ .command("request")
1413
+ .requiredOption("--workspace-id <workspaceId>")
1414
+ .requiredOption("--spec-id <specId>")
1415
+ .option("--idempotency-key <key>")
1416
+ .action(async (options) => {
1417
+ exitCode = await run((client) => client.POST("/v1/workspaces/{workspaceId}/specs/{specId}/reviews", {
1418
+ params: {
1419
+ path: options,
1420
+ header: { "idempotency-key": options.idempotencyKey ?? randomUUID() },
1421
+ },
1422
+ }), { rejectWorkspaceReadToken: true });
1231
1423
  });
1232
- workspaceReview.command("history").requiredOption("--workspace-id <workspaceId>").action(async (options) => {
1233
- exitCode = await run(client => client.GET("/v1/workspaces/{workspaceId}/reviews", { params: { path: options } }), { rejectWorkspaceReadToken: true });
1424
+ workspaceReview
1425
+ .command("history")
1426
+ .requiredOption("--workspace-id <workspaceId>")
1427
+ .action(async (options) => {
1428
+ exitCode = await run((client) => client.GET("/v1/workspaces/{workspaceId}/reviews", { params: { path: options } }), { rejectWorkspaceReadToken: true });
1234
1429
  });
1235
- workspaceReview.command("read").requiredOption("--workspace-id <workspaceId>").requiredOption("--review-id <reviewId>").action(async (options) => {
1236
- exitCode = await run(client => client.GET("/v1/workspaces/{workspaceId}/reviews/{reviewId}", { params: { path: options } }), { rejectWorkspaceReadToken: true });
1430
+ workspaceReview
1431
+ .command("read")
1432
+ .requiredOption("--workspace-id <workspaceId>")
1433
+ .requiredOption("--review-id <reviewId>")
1434
+ .action(async (options) => {
1435
+ exitCode = await run((client) => client.GET("/v1/workspaces/{workspaceId}/reviews/{reviewId}", {
1436
+ params: { path: options },
1437
+ }), { rejectWorkspaceReadToken: true });
1237
1438
  });
1238
- workspaceReview.command("plan").requiredOption("--workspace-id <workspaceId>").action(async (options) => {
1239
- exitCode = await run(client => client.GET("/v1/workspaces/{workspaceId}/review-schedule", { params: { path: options } }), { rejectWorkspaceReadToken: true });
1439
+ workspaceReview
1440
+ .command("plan")
1441
+ .requiredOption("--workspace-id <workspaceId>")
1442
+ .action(async (options) => {
1443
+ exitCode = await run((client) => client.GET("/v1/workspaces/{workspaceId}/review-schedule", { params: { path: options } }), { rejectWorkspaceReadToken: true });
1240
1444
  });
1241
- workspaceReview.command("configure").requiredOption("--workspace-id <workspaceId>").requiredOption("--expected-version <expectedVersion>", "Opaque version", parseOpaqueVersion).requiredOption("--input <input>", "Review plan JSON").action(async (options) => {
1445
+ workspaceReview
1446
+ .command("configure")
1447
+ .requiredOption("--workspace-id <workspaceId>")
1448
+ .requiredOption("--expected-version <expectedVersion>", "Opaque version", parseOpaqueVersion)
1449
+ .requiredOption("--input <input>", "Review plan JSON")
1450
+ .action(async (options) => {
1242
1451
  const body = reviewPlanInputSchema.parse(JSON.parse(options.input));
1243
- exitCode = await run(client => client.PUT("/v1/workspaces/{workspaceId}/review-schedule", { body, params: { path: options, header: { "if-match": options.expectedVersion } } }), { rejectWorkspaceReadToken: true });
1452
+ exitCode = await run((client) => client.PUT("/v1/workspaces/{workspaceId}/review-schedule", {
1453
+ body,
1454
+ params: { path: options, header: { "if-match": options.expectedVersion } },
1455
+ }), { rejectWorkspaceReadToken: true });
1244
1456
  });
1245
- const notification = program.command("notification").description("Read and manage your personal task notifications");
1457
+ const notification = program
1458
+ .command("notification")
1459
+ .description("Read and manage your personal task notifications");
1246
1460
  notification.command("list").action(async () => {
1247
1461
  if (hasWorkspaceReadToken(dependencies.environment)) {
1248
1462
  exitCode = rejectWorkspaceReadTokenOperation(dependencies);
@@ -1250,14 +1464,18 @@ export async function runCli(arguments_, dependencies) {
1250
1464
  }
1251
1465
  exitCode = await run((client) => client.GET("/v1/notifications"));
1252
1466
  });
1253
- notification.command("create")
1467
+ notification
1468
+ .command("create")
1254
1469
  .option("--title <title>")
1255
1470
  .option("--message <message>")
1256
1471
  .option("--type <type>", "Notification type", "info")
1257
1472
  .option("--event-data <json>", "JSON object for presentation", parseNotificationEventData)
1258
1473
  .option("--related-entity-id <id>", "Public task ID or Workspace ID")
1259
- .option("--related-entity-type <type>", "task or workspace", (value) => { if (value !== "task" && value !== "workspace")
1260
- throw invalidArgument("Notification target must be task or workspace"); return value; })
1474
+ .option("--related-entity-type <type>", "task or workspace", (value) => {
1475
+ if (value !== "task" && value !== "workspace")
1476
+ throw invalidArgument("Notification target must be task or workspace");
1477
+ return value;
1478
+ })
1261
1479
  .requiredOption("--idempotency-key <key>", "Reuse the same command key and inputs when retrying", parseNotificationUuid)
1262
1480
  .action(async (options) => {
1263
1481
  if (hasWorkspaceReadToken(dependencies.environment)) {
@@ -1266,9 +1484,27 @@ export async function runCli(arguments_, dependencies) {
1266
1484
  }
1267
1485
  if ((options.relatedEntityId === undefined) !== (options.relatedEntityType === undefined))
1268
1486
  throw invalidArgument("Notification target identity and type must be provided together");
1269
- exitCode = await run((client) => client.POST("/v1/notifications", { body: { type: options.type, ...(options.title === undefined ? {} : { title: options.title }), ...(options.message === undefined ? {} : { message: options.message }), ...(options.eventData === undefined ? {} : { eventData: options.eventData }), ...(options.relatedEntityId === undefined ? {} : { relatedEntityId: options.relatedEntityId }), ...(options.relatedEntityType === undefined ? {} : { relatedEntityType: options.relatedEntityType }) }, params: { header: { "idempotency-key": options.idempotencyKey } } }), { retryTransportOnce: true, ambiguousOutcomeMessage: "Notification creation outcome is unknown; retry with the same inputs and command key" });
1487
+ exitCode = await run((client) => client.POST("/v1/notifications", {
1488
+ body: {
1489
+ type: options.type,
1490
+ ...(options.title === undefined ? {} : { title: options.title }),
1491
+ ...(options.message === undefined ? {} : { message: options.message }),
1492
+ ...(options.eventData === undefined ? {} : { eventData: options.eventData }),
1493
+ ...(options.relatedEntityId === undefined
1494
+ ? {}
1495
+ : { relatedEntityId: options.relatedEntityId }),
1496
+ ...(options.relatedEntityType === undefined
1497
+ ? {}
1498
+ : { relatedEntityType: options.relatedEntityType }),
1499
+ },
1500
+ params: { header: { "idempotency-key": options.idempotencyKey } },
1501
+ }), {
1502
+ retryTransportOnce: true,
1503
+ ambiguousOutcomeMessage: "Notification creation outcome is unknown; retry with the same inputs and command key",
1504
+ });
1270
1505
  });
1271
- notification.command("read")
1506
+ notification
1507
+ .command("read")
1272
1508
  .requiredOption("--notification-id <id>", "Notification UUID returned by the list", parseNotificationUuid)
1273
1509
  .requiredOption("--idempotency-key <key>", "Reuse the same key when retrying", parseNotificationUuid)
1274
1510
  .action(async (options) => {
@@ -1276,17 +1512,32 @@ export async function runCli(arguments_, dependencies) {
1276
1512
  exitCode = rejectWorkspaceReadTokenOperation(dependencies);
1277
1513
  return;
1278
1514
  }
1279
- exitCode = await run((client) => client.PATCH("/v1/notifications/{notificationId}/read", { params: { path: { notificationId: options.notificationId }, header: { "idempotency-key": options.idempotencyKey } } }), { retryTransportOnce: true, ambiguousOutcomeMessage: "Notification read outcome is unknown; retry with the same notification and command key" });
1515
+ exitCode = await run((client) => client.PATCH("/v1/notifications/{notificationId}/read", {
1516
+ params: {
1517
+ path: { notificationId: options.notificationId },
1518
+ header: { "idempotency-key": options.idempotencyKey },
1519
+ },
1520
+ }), {
1521
+ retryTransportOnce: true,
1522
+ ambiguousOutcomeMessage: "Notification read outcome is unknown; retry with the same notification and command key",
1523
+ });
1280
1524
  });
1281
1525
  for (const action of ["read-all", "clear"]) {
1282
- notification.command(action).requiredOption("--idempotency-key <key>", "Reuse the same key to avoid changing notifications that arrived after the first command", parseNotificationUuid)
1526
+ notification
1527
+ .command(action)
1528
+ .requiredOption("--idempotency-key <key>", "Reuse the same key to avoid changing notifications that arrived after the first command", parseNotificationUuid)
1283
1529
  .action(async (options) => {
1284
1530
  if (hasWorkspaceReadToken(dependencies.environment)) {
1285
1531
  exitCode = rejectWorkspaceReadTokenOperation(dependencies);
1286
1532
  return;
1287
1533
  }
1288
1534
  const params = { header: { "idempotency-key": options.idempotencyKey } };
1289
- exitCode = await run((client) => action === "read-all" ? client.PATCH("/v1/notifications/read", { params }) : client.DELETE("/v1/notifications", { params }), { retryTransportOnce: true, ambiguousOutcomeMessage: "Notification bulk command outcome is unknown; retry with the same command key" });
1535
+ exitCode = await run((client) => action === "read-all"
1536
+ ? client.PATCH("/v1/notifications/read", { params })
1537
+ : client.DELETE("/v1/notifications", { params }), {
1538
+ retryTransportOnce: true,
1539
+ ambiguousOutcomeMessage: "Notification bulk command outcome is unknown; retry with the same command key",
1540
+ });
1290
1541
  });
1291
1542
  }
1292
1543
  const notificationPreferences = notification.command("preferences");
@@ -1297,7 +1548,8 @@ export async function runCli(arguments_, dependencies) {
1297
1548
  }
1298
1549
  exitCode = await run((client) => client.GET("/v1/notification-preferences"));
1299
1550
  });
1300
- notificationPreferences.command("update")
1551
+ notificationPreferences
1552
+ .command("update")
1301
1553
  .requiredOption("--expected-version <version>", "Opaque preference version returned by get")
1302
1554
  .requiredOption("--preferences <json>", "JSON category settings; omitted settings remain unchanged", parseNotificationPreferences)
1303
1555
  .requiredOption("--idempotency-key <key>", "Reuse the same key and settings when retrying", parseNotificationUuid)
@@ -1306,50 +1558,129 @@ export async function runCli(arguments_, dependencies) {
1306
1558
  exitCode = rejectWorkspaceReadTokenOperation(dependencies);
1307
1559
  return;
1308
1560
  }
1309
- exitCode = await run((client) => client.PATCH("/v1/notification-preferences", { body: options.preferences, params: { header: { "idempotency-key": options.idempotencyKey, "if-match": options.expectedVersion } } }), { retryTransportOnce: true, ambiguousOutcomeMessage: "Notification preference outcome is unknown; retry with the same settings and command key" });
1561
+ exitCode = await run((client) => client.PATCH("/v1/notification-preferences", {
1562
+ body: options.preferences,
1563
+ params: {
1564
+ header: {
1565
+ "idempotency-key": options.idempotencyKey,
1566
+ "if-match": options.expectedVersion,
1567
+ },
1568
+ },
1569
+ }), {
1570
+ retryTransportOnce: true,
1571
+ ambiguousOutcomeMessage: "Notification preference outcome is unknown; retry with the same settings and command key",
1572
+ });
1310
1573
  });
1311
1574
  const workItem = program.command("work-item");
1312
- registerWorkItemAssetCommands(workItem, { dependencies, run, setExitCode: (value) => { exitCode = value; }, rejectWrite: () => rejectTokenWrite(dependencies) });
1313
- const resourceRuntime = { run, setExitCode: (value) => { exitCode = value; }, parseOpaqueVersion, parseLimit: parseSearchLimit };
1575
+ registerWorkItemAssetCommands(workItem, {
1576
+ dependencies,
1577
+ run,
1578
+ setExitCode: (value) => {
1579
+ exitCode = value;
1580
+ },
1581
+ rejectWrite: () => rejectTokenWrite(dependencies),
1582
+ });
1583
+ const resourceRuntime = {
1584
+ run,
1585
+ setExitCode: (value) => {
1586
+ exitCode = value;
1587
+ },
1588
+ parseOpaqueVersion,
1589
+ parseLimit: parseSearchLimit,
1590
+ };
1314
1591
  registerSpecOwnerCommands(spec, resourceRuntime);
1315
1592
  registerSpecDiscussionCommands(spec, resourceRuntime);
1316
1593
  registerProjectAdministrationCommands(project, workspace, resourceRuntime);
1317
- program.command("search-global").description("Search all currently accessible objects; preserves server totals and cursor")
1594
+ program
1595
+ .command("search-global")
1596
+ .description("Search all currently accessible objects; preserves server totals and cursor")
1318
1597
  .requiredOption("--query <query>")
1319
1598
  .option("--types <types>", "Comma-separated kinds: project,work-item,capability,spec,glossary,screen,journey,user")
1320
1599
  .option("--limit <limit>", "Server page size (1–100)", resourceRuntime.parseLimit, 20)
1321
1600
  .option("--cursor <cursor>")
1322
1601
  .action(async (options) => {
1323
- resourceRuntime.setExitCode(await resourceRuntime.run(client => client.GET("/v1/search", {
1324
- params: { query: { query: options.query, limit: options.limit, ...(options.cursor === undefined ? {} : { cursor: options.cursor }), ...(options.types === undefined ? {} : { types: options.types }) } },
1602
+ resourceRuntime.setExitCode(await resourceRuntime.run((client) => client.GET("/v1/search", {
1603
+ params: {
1604
+ query: {
1605
+ query: options.query,
1606
+ limit: options.limit,
1607
+ ...(options.cursor === undefined ? {} : { cursor: options.cursor }),
1608
+ ...(options.types === undefined ? {} : { types: options.types }),
1609
+ },
1610
+ },
1325
1611
  }), { rejectWorkspaceReadToken: true }));
1326
1612
  });
1327
1613
  registerWorkItemQueryCommands(workItem, workspace, resourceRuntime);
1328
1614
  registerWorkItemDeliveryCommands(workItem, project, resourceRuntime);
1329
- registerProductMapCommands(program, { dependencies, run, setExitCode: value => { exitCode = value; }, canWrite: () => !hasWorkspaceReadToken(dependencies.environment), rejectWrite: () => rejectTokenWrite(dependencies), parseOpaqueVersion });
1330
- registerWorkItemResourceLinkCommands(workItem, spec, { run, setExitCode: (value) => { exitCode = value; }, canWrite: () => !hasWorkspaceReadToken(dependencies.environment), rejectWrite: () => rejectTokenWrite(dependencies), parseOpaqueVersion, parseLimit: parseSearchLimit });
1331
- const workItemComment = workItem.command("comment").description("Read and manage authored task comments");
1332
- workItemComment.command("list")
1615
+ registerProductMapCommands(program, {
1616
+ dependencies,
1617
+ run,
1618
+ setExitCode: (value) => {
1619
+ exitCode = value;
1620
+ },
1621
+ canWrite: () => !hasWorkspaceReadToken(dependencies.environment),
1622
+ rejectWrite: () => rejectTokenWrite(dependencies),
1623
+ parseOpaqueVersion,
1624
+ });
1625
+ registerWorkItemResourceLinkCommands(workItem, spec, {
1626
+ run,
1627
+ setExitCode: (value) => {
1628
+ exitCode = value;
1629
+ },
1630
+ canWrite: () => !hasWorkspaceReadToken(dependencies.environment),
1631
+ rejectWrite: () => rejectTokenWrite(dependencies),
1632
+ parseOpaqueVersion,
1633
+ parseLimit: parseSearchLimit,
1634
+ });
1635
+ registerWorkItemWatcherCommands(workItem, {
1636
+ run,
1637
+ setExitCode: (value) => {
1638
+ exitCode = value;
1639
+ },
1640
+ canWrite: () => !hasWorkspaceReadToken(dependencies.environment),
1641
+ rejectWrite: () => rejectTokenWrite(dependencies),
1642
+ });
1643
+ registerWorkItemThreadCommands(workItem, resourceRuntime);
1644
+ const workItemComment = workItem
1645
+ .command("comment")
1646
+ .description("Read and manage authored task comments");
1647
+ workItemComment
1648
+ .command("list")
1333
1649
  .requiredOption("--project-id <projectId>")
1334
1650
  .requiredOption("--work-item-id <workItemId>")
1335
1651
  .option("--limit <limit>", "Maximum results, 1 through 100", parseSearchLimit, 50)
1336
1652
  .option("--cursor <cursor>", "Opaque cursor returned by the previous page")
1337
1653
  .action(async (options) => {
1338
1654
  exitCode = await run((client) => client.GET("/v1/projects/{projectId}/work-items/{workItemId}/comments", {
1339
- params: { path: { projectId: options.projectId, workItemId: options.workItemId }, query: { limit: options.limit, ...(options.cursor === undefined ? {} : { cursor: options.cursor }) } },
1655
+ params: {
1656
+ path: { projectId: options.projectId, workItemId: options.workItemId },
1657
+ query: {
1658
+ limit: options.limit,
1659
+ ...(options.cursor === undefined ? {} : { cursor: options.cursor }),
1660
+ },
1661
+ },
1340
1662
  }));
1341
1663
  });
1342
- workItem.command("discussion").description("Read comments and immutable activity newest first")
1664
+ workItem
1665
+ .command("discussion")
1666
+ .description("Read comments and immutable activity newest first")
1343
1667
  .requiredOption("--project-id <projectId>")
1344
1668
  .requiredOption("--work-item-id <workItemId>")
1345
1669
  .option("--limit <limit>", "Maximum results, 1 through 100", parseSearchLimit, 50)
1346
1670
  .option("--cursor <cursor>", "Opaque cursor returned by the previous page")
1347
1671
  .action(async (options) => {
1348
1672
  exitCode = await run((client) => client.GET("/v1/projects/{projectId}/work-items/{workItemId}/discussion", {
1349
- params: { path: { projectId: options.projectId, workItemId: options.workItemId }, query: { limit: options.limit, ...(options.cursor === undefined ? {} : { cursor: options.cursor }) } },
1673
+ params: {
1674
+ path: { projectId: options.projectId, workItemId: options.workItemId },
1675
+ query: {
1676
+ limit: options.limit,
1677
+ ...(options.cursor === undefined ? {} : { cursor: options.cursor }),
1678
+ },
1679
+ },
1350
1680
  }));
1351
1681
  });
1352
- workItemComment.command("create")
1682
+ workItemComment
1683
+ .command("create")
1353
1684
  .requiredOption("--project-id <projectId>")
1354
1685
  .requiredOption("--work-item-id <workItemId>")
1355
1686
  .requiredOption("--content <markdown>", "Markdown comment body, up to 20000 characters", parseCommentContent)
@@ -1361,10 +1692,17 @@ export async function runCli(arguments_, dependencies) {
1361
1692
  }
1362
1693
  exitCode = await run((client) => client.POST("/v1/projects/{projectId}/work-items/{workItemId}/comments", {
1363
1694
  body: { content: options.content },
1364
- params: { path: { projectId: options.projectId, workItemId: options.workItemId }, header: { "idempotency-key": options.idempotencyKey } },
1365
- }), { retryTransportOnce: true, ambiguousOutcomeMessage: "Comment creation outcome is unknown; retry with the same inputs and command key" });
1695
+ params: {
1696
+ path: { projectId: options.projectId, workItemId: options.workItemId },
1697
+ header: { "idempotency-key": options.idempotencyKey },
1698
+ },
1699
+ }), {
1700
+ retryTransportOnce: true,
1701
+ ambiguousOutcomeMessage: "Comment creation outcome is unknown; retry with the same inputs and command key",
1702
+ });
1366
1703
  });
1367
- workItemComment.command("update")
1704
+ workItemComment
1705
+ .command("update")
1368
1706
  .requiredOption("--project-id <projectId>")
1369
1707
  .requiredOption("--work-item-id <workItemId>")
1370
1708
  .requiredOption("--comment-id <commentId>", "Identifier returned by comments", parseCommentId)
@@ -1378,11 +1716,24 @@ export async function runCli(arguments_, dependencies) {
1378
1716
  }
1379
1717
  exitCode = await run((client) => client.PATCH("/v1/projects/{projectId}/work-items/{workItemId}/comments/{commentId}", {
1380
1718
  body: { content: options.content },
1381
- params: { path: { projectId: options.projectId, workItemId: options.workItemId, commentId: options.commentId },
1382
- header: { "idempotency-key": options.idempotencyKey, "if-match": options.expectedVersion } },
1383
- }), { retryTransportOnce: true, ambiguousOutcomeMessage: "Comment edit outcome is unknown; reread the comment or retry the same inputs and command key" });
1719
+ params: {
1720
+ path: {
1721
+ projectId: options.projectId,
1722
+ workItemId: options.workItemId,
1723
+ commentId: options.commentId,
1724
+ },
1725
+ header: {
1726
+ "idempotency-key": options.idempotencyKey,
1727
+ "if-match": options.expectedVersion,
1728
+ },
1729
+ },
1730
+ }), {
1731
+ retryTransportOnce: true,
1732
+ ambiguousOutcomeMessage: "Comment edit outcome is unknown; reread the comment or retry the same inputs and command key",
1733
+ });
1384
1734
  });
1385
- workItemComment.command("delete")
1735
+ workItemComment
1736
+ .command("delete")
1386
1737
  .requiredOption("--project-id <projectId>")
1387
1738
  .requiredOption("--work-item-id <workItemId>")
1388
1739
  .requiredOption("--comment-id <commentId>", "Identifier returned by comments", parseCommentId)
@@ -1394,41 +1745,93 @@ export async function runCli(arguments_, dependencies) {
1394
1745
  return;
1395
1746
  }
1396
1747
  exitCode = await run((client) => client.DELETE("/v1/projects/{projectId}/work-items/{workItemId}/comments/{commentId}", {
1397
- params: { path: { projectId: options.projectId, workItemId: options.workItemId, commentId: options.commentId },
1398
- header: { "idempotency-key": options.idempotencyKey, "if-match": options.expectedVersion } },
1399
- }), { retryTransportOnce: true, ambiguousOutcomeMessage: "Comment deletion outcome is unknown; reread the comment or retry the same inputs and command key" });
1748
+ params: {
1749
+ path: {
1750
+ projectId: options.projectId,
1751
+ workItemId: options.workItemId,
1752
+ commentId: options.commentId,
1753
+ },
1754
+ header: {
1755
+ "idempotency-key": options.idempotencyKey,
1756
+ "if-match": options.expectedVersion,
1757
+ },
1758
+ },
1759
+ }), {
1760
+ retryTransportOnce: true,
1761
+ ambiguousOutcomeMessage: "Comment deletion outcome is unknown; reread the comment or retry the same inputs and command key",
1762
+ });
1400
1763
  });
1401
- const workItemRelation = workItem.command("relation").description("Manage subtask, blocking and related task links");
1402
- workItemRelation.command("list")
1764
+ const workItemRelation = workItem
1765
+ .command("relation")
1766
+ .description("Manage subtask, blocking and related task links");
1767
+ workItemRelation
1768
+ .command("list")
1403
1769
  .requiredOption("--project-id <projectId>")
1404
1770
  .requiredOption("--work-item-id <workItemId>")
1405
1771
  .action(async (options) => {
1406
- exitCode = await run((client) => client.GET("/v1/projects/{projectId}/work-items/{workItemId}/relations", { params: { path: options } }), { project: data => relationListOutput(data, outputMode, warnMissingUrl) });
1772
+ exitCode = await run((client) => client.GET("/v1/projects/{projectId}/work-items/{workItemId}/relations", {
1773
+ params: { path: options },
1774
+ }), { project: (data) => relationListOutput(data, outputMode, warnMissingUrl) });
1407
1775
  });
1408
- workItemRelation.command("create")
1776
+ workItemRelation
1777
+ .command("create")
1409
1778
  .addHelpText("after", "\nExample: specflow work-item relation create --project-id PROJECT --work-item-id GON-78 --target-project-id PROJECT --target-work-item-id GON-79 --type subtask --idempotency-key KEY\n")
1410
1779
  .requiredOption("--project-id <projectId>")
1411
1780
  .requiredOption("--work-item-id <workItemId>")
1412
1781
  .requiredOption("--target-project-id <projectId>", "Target task's current Project", parseProjectId)
1413
1782
  .requiredOption("--target-work-item-id <workItemId>", "Target task's public identity", parseWorkItemId)
1414
- .requiredOption("--type <type>", "subtask (source=parent, target=child), blocks or related", (value) => {
1415
- const result = z.enum(["subtask", "blocks", "related"]).safeParse(value);
1783
+ .option("--type <type>", "subtask (source=parent, target=child), blocks, related or duplicate", (value) => {
1784
+ const result = z.enum(["subtask", "blocks", "related", "duplicate"]).safeParse(value);
1416
1785
  if (!result.success)
1417
- throw invalidArgument("Relation type must be subtask, blocks or related");
1786
+ throw invalidArgument("Relation type must be subtask, blocks, related or duplicate");
1418
1787
  return result.data;
1419
1788
  })
1789
+ .option("--direction <direction>", "Direction from the current task: related, subtask, parent, blocks or blocked-by", (value) => {
1790
+ const result = z
1791
+ .enum(["related", "subtask", "parent", "blocks", "blocked-by"])
1792
+ .safeParse(value);
1793
+ if (!result.success)
1794
+ throw invalidArgument("Invalid relation direction");
1795
+ return result.data;
1796
+ })
1797
+ .option("--replace-parent", "Replace the existing parent when linking a subtask")
1420
1798
  .requiredOption("--idempotency-key <key>", "Reuse the same key and inputs when retrying", parseRelationCommandKey)
1421
1799
  .action(async (options) => {
1422
1800
  if (hasWorkspaceReadToken(dependencies.environment)) {
1423
1801
  exitCode = rejectTokenWrite(dependencies);
1424
1802
  return;
1425
1803
  }
1804
+ if (options.direction === undefined && options.type === undefined)
1805
+ throw invalidArgument("Provide --type or --direction");
1806
+ const relationBody = options.direction === undefined
1807
+ ? options.type === undefined
1808
+ ? (() => {
1809
+ throw invalidArgument("Provide --type or --direction");
1810
+ })()
1811
+ : { relationType: options.type }
1812
+ : { direction: options.direction };
1426
1813
  exitCode = await run((client) => client.POST("/v1/projects/{projectId}/work-items/{workItemId}/relations", {
1427
- body: { targetProjectId: options.targetProjectId, targetWorkItemId: options.targetWorkItemId, relationType: options.type },
1428
- params: { path: { projectId: options.projectId, workItemId: options.workItemId }, header: { "idempotency-key": options.idempotencyKey } },
1429
- }), { project: data => relationReceiptOutput(data, outputMode, warnMissingUrl), retryTransportOnce: true, ambiguousOutcomeMessage: "Relation creation outcome is unknown; retry with the same inputs and command key" });
1814
+ body: {
1815
+ targetProjectId: options.targetProjectId,
1816
+ targetWorkItemId: options.targetWorkItemId,
1817
+ ...relationBody,
1818
+ ...(options.replaceParent === undefined
1819
+ ? {}
1820
+ : { replaceParent: options.replaceParent }),
1821
+ },
1822
+ params: {
1823
+ path: { projectId: options.projectId, workItemId: options.workItemId },
1824
+ header: { "idempotency-key": options.idempotencyKey },
1825
+ },
1826
+ }), {
1827
+ project: (data) => relationReceiptOutput(data, outputMode, warnMissingUrl),
1828
+ retryTransportOnce: true,
1829
+ ambiguousOutcomeMessage: "Relation creation outcome is unknown; retry with the same inputs and command key",
1830
+ });
1430
1831
  });
1431
- workItem.command("subtask").command("link")
1832
+ workItem
1833
+ .command("subtask")
1834
+ .command("link")
1432
1835
  .description("Link parent (source) to child (target), including across Projects")
1433
1836
  .requiredOption("--project-id <projectId>", "Parent Project")
1434
1837
  .requiredOption("--parent <workItemId>", "Parent public Work Item ID", parseWorkItemId)
@@ -1440,12 +1843,24 @@ export async function runCli(arguments_, dependencies) {
1440
1843
  exitCode = rejectTokenWrite(dependencies);
1441
1844
  return;
1442
1845
  }
1443
- exitCode = await run(client => client.POST("/v1/projects/{projectId}/work-items/{workItemId}/relations", {
1444
- body: { relationType: "subtask", targetProjectId: options.childProjectId ?? options.projectId, targetWorkItemId: options.child },
1445
- params: { path: { projectId: options.projectId, workItemId: options.parent }, header: { "idempotency-key": options.idempotencyKey } },
1446
- }), { retryTransportOnce: true, project: data => relationReceiptOutput(data, outputMode, warnMissingUrl), ambiguousOutcomeMessage: "Relation creation outcome is unknown; retry with the same inputs and command key" });
1846
+ exitCode = await run((client) => client.POST("/v1/projects/{projectId}/work-items/{workItemId}/relations", {
1847
+ body: {
1848
+ relationType: "subtask",
1849
+ targetProjectId: options.childProjectId ?? options.projectId,
1850
+ targetWorkItemId: options.child,
1851
+ },
1852
+ params: {
1853
+ path: { projectId: options.projectId, workItemId: options.parent },
1854
+ header: { "idempotency-key": options.idempotencyKey },
1855
+ },
1856
+ }), {
1857
+ retryTransportOnce: true,
1858
+ project: (data) => relationReceiptOutput(data, outputMode, warnMissingUrl),
1859
+ ambiguousOutcomeMessage: "Relation creation outcome is unknown; retry with the same inputs and command key",
1860
+ });
1447
1861
  });
1448
- workItemRelation.command("delete")
1862
+ workItemRelation
1863
+ .command("delete")
1449
1864
  .requiredOption("--project-id <projectId>")
1450
1865
  .requiredOption("--work-item-id <workItemId>")
1451
1866
  .requiredOption("--peer-project-id <projectId>", "Other endpoint's current Project", parseProjectId)
@@ -1462,9 +1877,83 @@ export async function runCli(arguments_, dependencies) {
1462
1877
  return;
1463
1878
  }
1464
1879
  exitCode = await run((client) => client.DELETE("/v1/projects/{projectId}/work-items/{workItemId}/relations/{relationId}", {
1465
- params: { path: { projectId: options.projectId, workItemId: options.workItemId, relationId: options.relationId },
1466
- query: { peerProjectId: options.peerProjectId }, header: { "idempotency-key": options.idempotencyKey, "if-match": options.expectedVersion } },
1467
- }), { retryTransportOnce: true, ambiguousOutcomeMessage: "Relation removal outcome is unknown; retry with the same inputs and command key" });
1880
+ params: {
1881
+ path: {
1882
+ projectId: options.projectId,
1883
+ workItemId: options.workItemId,
1884
+ relationId: options.relationId,
1885
+ },
1886
+ query: { peerProjectId: options.peerProjectId },
1887
+ header: {
1888
+ "idempotency-key": options.idempotencyKey,
1889
+ "if-match": options.expectedVersion,
1890
+ },
1891
+ },
1892
+ }), {
1893
+ retryTransportOnce: true,
1894
+ ambiguousOutcomeMessage: "Relation removal outcome is unknown; retry with the same inputs and command key",
1895
+ });
1896
+ });
1897
+ workItemRelation
1898
+ .command("duplicate")
1899
+ .description("Mark or cancel a duplicate Work Item mark")
1900
+ .command("mark")
1901
+ .requiredOption("--project-id <projectId>")
1902
+ .requiredOption("--work-item-id <workItemId>")
1903
+ .requiredOption("--target-project-id <projectId>", "Project containing the retained task")
1904
+ .requiredOption("--target-work-item-id <workItemId>", "Retained task public identity", parseWorkItemId)
1905
+ .requiredOption("--expected-version <expectedVersion>", "Current task version", parseOpaqueVersion)
1906
+ .requiredOption("--idempotency-key <key>", "Reuse the same key and inputs when retrying", parseRelationCommandKey)
1907
+ .action(async (options) => {
1908
+ if (hasWorkspaceReadToken(dependencies.environment)) {
1909
+ exitCode = rejectTokenWrite(dependencies);
1910
+ return;
1911
+ }
1912
+ const expectedVersion = Number(options.expectedVersion);
1913
+ if (!Number.isInteger(expectedVersion) || expectedVersion < 1)
1914
+ throw invalidArgument("Expected version must be a positive integer");
1915
+ exitCode = await run((client) => client.POST("/v1/projects/{projectId}/work-items/{workItemId}/relations/duplicate", {
1916
+ body: {
1917
+ targetProjectId: options.targetProjectId,
1918
+ targetWorkItemId: options.targetWorkItemId,
1919
+ expectedVersion,
1920
+ },
1921
+ params: {
1922
+ path: { projectId: options.projectId, workItemId: options.workItemId },
1923
+ header: { "idempotency-key": options.idempotencyKey },
1924
+ },
1925
+ }), {
1926
+ project: (data) => itemOutput(data, outputMode, warnMissingUrl),
1927
+ retryTransportOnce: true,
1928
+ ambiguousOutcomeMessage: "Duplicate mark outcome is unknown; retry with the same inputs and command key",
1929
+ });
1930
+ });
1931
+ workItemRelation
1932
+ .command("duplicate-cancel")
1933
+ .description("Cancel a duplicate Work Item mark")
1934
+ .requiredOption("--project-id <projectId>")
1935
+ .requiredOption("--work-item-id <workItemId>")
1936
+ .requiredOption("--expected-version <expectedVersion>", "Current task version", parseOpaqueVersion)
1937
+ .requiredOption("--idempotency-key <key>", "Reuse the same key and inputs when retrying", parseRelationCommandKey)
1938
+ .action(async (options) => {
1939
+ if (hasWorkspaceReadToken(dependencies.environment)) {
1940
+ exitCode = rejectTokenWrite(dependencies);
1941
+ return;
1942
+ }
1943
+ const expectedVersion = Number(options.expectedVersion);
1944
+ if (!Number.isInteger(expectedVersion) || expectedVersion < 1)
1945
+ throw invalidArgument("Expected version must be a positive integer");
1946
+ exitCode = await run((client) => client.DELETE("/v1/projects/{projectId}/work-items/{workItemId}/relations/duplicate", {
1947
+ params: {
1948
+ path: { projectId: options.projectId, workItemId: options.workItemId },
1949
+ query: { expectedVersion },
1950
+ header: { "idempotency-key": options.idempotencyKey },
1951
+ },
1952
+ }), {
1953
+ project: (data) => itemOutput(data, outputMode, warnMissingUrl),
1954
+ retryTransportOnce: true,
1955
+ ambiguousOutcomeMessage: "Duplicate cancellation outcome is unknown; retry with the same inputs and command key",
1956
+ });
1468
1957
  });
1469
1958
  workItemCompletedFlag(workItemSelectionFlags(workItem.command("list")))
1470
1959
  .requiredOption("--project-id <projectId>")
@@ -1483,16 +1972,12 @@ export async function runCli(arguments_, dependencies) {
1483
1972
  query: {
1484
1973
  ...workItemSelectionQuery(options),
1485
1974
  ...(options.completed === undefined ? {} : { completed: options.completed }),
1486
- ...(options.cursor === undefined
1487
- ? {}
1488
- : { cursor: options.cursor }),
1489
- ...(options.groupBy === undefined
1490
- ? {}
1491
- : { groupBy: options.groupBy }),
1975
+ ...(options.cursor === undefined ? {} : { cursor: options.cursor }),
1976
+ ...(options.groupBy === undefined ? {} : { groupBy: options.groupBy }),
1492
1977
  limit: options.limit,
1493
1978
  },
1494
1979
  },
1495
- }), { project: data => itemListOutput(data, outputMode, warnMissingUrl) });
1980
+ }), { project: (data) => itemListOutput(data, outputMode, warnMissingUrl) });
1496
1981
  });
1497
1982
  workItem
1498
1983
  .command("read")
@@ -1501,7 +1986,7 @@ export async function runCli(arguments_, dependencies) {
1501
1986
  .action(async (options) => {
1502
1987
  exitCode = await run((client) => client.GET("/v1/projects/{projectId}/work-items/{workItemId}", {
1503
1988
  params: { path: options },
1504
- }), { project: data => itemOutput(data, outputMode, warnMissingUrl) });
1989
+ }), { project: (data) => itemOutput(data, outputMode, warnMissingUrl) });
1505
1990
  });
1506
1991
  workItem
1507
1992
  .command("assignees")
@@ -1524,40 +2009,67 @@ export async function runCli(arguments_, dependencies) {
1524
2009
  .option("--start-date <startDate>", "ISO 8601 date", parseWorkItemDate)
1525
2010
  .option("--due-date <dueDate>", "ISO 8601 date", parseWorkItemDate)
1526
2011
  .option("--status <status>", "Workflow Column slug or virtual status to create the Work Item in")
2012
+ .option("--relation-direction <direction>", "Create one relation atomically: related, subtask, parent, blocks or blocked-by", (value) => {
2013
+ const result = z
2014
+ .enum(["related", "subtask", "parent", "blocks", "blocked-by"])
2015
+ .safeParse(value);
2016
+ if (!result.success)
2017
+ throw invalidArgument("Invalid relation direction");
2018
+ return result.data;
2019
+ })
2020
+ .option("--relation-target-project-id <projectId>", "Project containing the related task")
2021
+ .option("--relation-target-work-item-id <workItemId>", "Public identity of the related task", parseWorkItemId)
2022
+ .option("--replace-parent", "Replace an existing parent when creating a subtask relation")
2023
+ .option("--initial-watcher-ids <json>", "Initial watcher User IDs as a JSON array; [] explicitly mutes the creator", (value) => parseStringArray(value, "initial-watcher-ids"))
1527
2024
  .action(async (options) => {
1528
2025
  const description = (await readDescription(options)) ?? undefined;
1529
2026
  if (hasWorkspaceReadToken(dependencies.environment)) {
1530
2027
  exitCode = rejectTokenWrite(dependencies);
1531
2028
  return;
1532
2029
  }
2030
+ const relationFlags = [
2031
+ options.relationDirection,
2032
+ options.relationTargetProjectId,
2033
+ options.relationTargetWorkItemId,
2034
+ ];
2035
+ if (relationFlags.some((value) => value !== undefined) &&
2036
+ relationFlags.some((value) => value === undefined))
2037
+ throw invalidArgument("Atomic relation creation requires --relation-direction, --relation-target-project-id and --relation-target-work-item-id together");
2038
+ const relation = options.relationDirection === undefined
2039
+ ? undefined
2040
+ : options.relationTargetProjectId === undefined ||
2041
+ options.relationTargetWorkItemId === undefined
2042
+ ? (() => {
2043
+ throw invalidArgument("Atomic relation creation requires a relation target");
2044
+ })()
2045
+ : {
2046
+ direction: options.relationDirection,
2047
+ targetProjectId: options.relationTargetProjectId,
2048
+ targetWorkItemId: options.relationTargetWorkItemId,
2049
+ ...(options.replaceParent === undefined
2050
+ ? {}
2051
+ : { replaceParent: options.replaceParent }),
2052
+ };
1533
2053
  const customFields = options.customField.map(parseCustomFieldAssignment);
1534
2054
  const idempotencyKey = randomUUID();
1535
2055
  exitCode = await run((client, me) => client.POST("/v1/projects/{projectId}/work-items", {
1536
2056
  body: {
1537
- ...(options.assignee === undefined
1538
- ? {}
1539
- : { assigneeId: me ?? options.assignee }),
2057
+ ...(options.assignee === undefined ? {} : { assigneeId: me ?? options.assignee }),
1540
2058
  ...(options.customField.length === 0
1541
2059
  ? {}
1542
2060
  : {
1543
2061
  customFields,
1544
2062
  }),
1545
- ...(description === undefined
1546
- ? {}
1547
- : { description }),
2063
+ ...(description === undefined ? {} : { description }),
1548
2064
  ...(options.label.length === 0 ? {} : { labelIds: [...new Set(options.label)] }),
1549
- ...(options.dueDate === undefined
1550
- ? {}
1551
- : { dueDate: options.dueDate }),
1552
- ...(options.priority === undefined
1553
- ? {}
1554
- : { priority: options.priority }),
1555
- ...(options.startDate === undefined
1556
- ? {}
1557
- : { startDate: options.startDate }),
1558
- ...(options.status === undefined
2065
+ ...(options.initialWatcherIds === undefined
1559
2066
  ? {}
1560
- : { status: options.status }),
2067
+ : { initialWatcherIds: options.initialWatcherIds }),
2068
+ ...(options.dueDate === undefined ? {} : { dueDate: options.dueDate }),
2069
+ ...(options.priority === undefined ? {} : { priority: options.priority }),
2070
+ ...(options.startDate === undefined ? {} : { startDate: options.startDate }),
2071
+ ...(options.status === undefined ? {} : { status: options.status }),
2072
+ ...(relation === undefined ? {} : { relation }),
1561
2073
  title: options.title,
1562
2074
  },
1563
2075
  params: {
@@ -1566,7 +2078,7 @@ export async function runCli(arguments_, dependencies) {
1566
2078
  },
1567
2079
  }), {
1568
2080
  resolveMe: options.assignee === "me",
1569
- project: data => itemOutput(data, outputMode, warnMissingUrl),
2081
+ project: (data) => itemOutput(data, outputMode, warnMissingUrl),
1570
2082
  ambiguousOutcomeMessage: "Work Item creation outcome is unknown; list Work Items before retrying",
1571
2083
  retryTransportOnce: true,
1572
2084
  });
@@ -1625,12 +2137,8 @@ export async function runCli(arguments_, dependencies) {
1625
2137
  : options.startDate === undefined
1626
2138
  ? {}
1627
2139
  : { startDate: options.startDate }),
1628
- ...(options.priority === undefined
1629
- ? {}
1630
- : { priority: options.priority }),
1631
- ...(options.title === undefined
1632
- ? {}
1633
- : { title: options.title }),
2140
+ ...(options.priority === undefined ? {} : { priority: options.priority }),
2141
+ ...(options.title === undefined ? {} : { title: options.title }),
1634
2142
  },
1635
2143
  params: {
1636
2144
  header: {
@@ -1643,7 +2151,7 @@ export async function runCli(arguments_, dependencies) {
1643
2151
  },
1644
2152
  },
1645
2153
  }), {
1646
- project: data => itemOutput(data, outputMode, warnMissingUrl),
2154
+ project: (data) => itemOutput(data, outputMode, warnMissingUrl),
1647
2155
  ambiguousOutcomeMessage: "Work Item update outcome is unknown; read the Work Item before retrying",
1648
2156
  retryTransportOnce: true,
1649
2157
  });
@@ -1683,7 +2191,7 @@ export async function runCli(arguments_, dependencies) {
1683
2191
  },
1684
2192
  }), {
1685
2193
  resolveMe: options.assignee === "me",
1686
- project: data => itemOutput(data, outputMode, warnMissingUrl),
2194
+ project: (data) => itemOutput(data, outputMode, warnMissingUrl),
1687
2195
  ambiguousOutcomeMessage: "Work Item assignment outcome is unknown; read the Work Item before retrying",
1688
2196
  retryTransportOnce: true,
1689
2197
  });
@@ -1721,7 +2229,10 @@ export async function runCli(arguments_, dependencies) {
1721
2229
  exitCode = await run((client) => client.GET("/v1/projects/{projectId}/work-item-board", {
1722
2230
  params: {
1723
2231
  path: { projectId: options.projectId },
1724
- query: { ...workItemSelectionQuery(options), ...(options.completed === undefined ? {} : { completed: options.completed }) },
2232
+ query: {
2233
+ ...workItemSelectionQuery(options),
2234
+ ...(options.completed === undefined ? {} : { completed: options.completed }),
2235
+ },
1725
2236
  },
1726
2237
  }));
1727
2238
  });
@@ -1779,17 +2290,14 @@ export async function runCli(arguments_, dependencies) {
1779
2290
  ? {}
1780
2291
  : { dueDate: options.dueDate }
1781
2292
  : {}),
1782
- ...((options.action === "addLabel" ||
1783
- options.action === "removeLabel") &&
2293
+ ...((options.action === "addLabel" || options.action === "removeLabel") &&
1784
2294
  options.labelId !== undefined
1785
2295
  ? { labelId: options.labelId }
1786
2296
  : {}),
1787
- ...(options.action === "updatePriority" &&
1788
- options.priority !== undefined
2297
+ ...(options.action === "updatePriority" && options.priority !== undefined
1789
2298
  ? { priority: options.priority }
1790
2299
  : {}),
1791
- ...(options.action === "updateStatus" &&
1792
- options.status !== undefined
2300
+ ...(options.action === "updateStatus" && options.status !== undefined
1793
2301
  ? { status: options.status }
1794
2302
  : {}),
1795
2303
  workItems: options.target.map((target) => ({
@@ -1826,7 +2334,8 @@ export async function runCli(arguments_, dependencies) {
1826
2334
  if (body === null) {
1827
2335
  writeSkillError(dependencies, {
1828
2336
  message: "The import file must be valid task JSON within 1 MiB and 1000 tasks",
1829
- reason: "Invalid Operation", retryable: false,
2337
+ reason: "Invalid Operation",
2338
+ retryable: false,
1830
2339
  });
1831
2340
  exitCode = 2;
1832
2341
  return;
@@ -1834,7 +2343,11 @@ export async function runCli(arguments_, dependencies) {
1834
2343
  let failed = 0;
1835
2344
  exitCode = await run(async (client) => {
1836
2345
  const result = await client.POST("/v1/projects/{projectId}/work-items/import", {
1837
- body, params: { header: { "idempotency-key": key }, path: { projectId: options.projectId } },
2346
+ body,
2347
+ params: {
2348
+ header: { "idempotency-key": key },
2349
+ path: { projectId: options.projectId },
2350
+ },
1838
2351
  });
1839
2352
  if (result.data !== undefined) {
1840
2353
  failed = result.data.results.failed;
@@ -1847,7 +2360,8 @@ export async function runCli(arguments_, dependencies) {
1847
2360
  if (exitCode === 0 && failed > 0) {
1848
2361
  writeSkillError(dependencies, {
1849
2362
  message: "Some tasks were refused; inspect the per-row results and import only corrected failed rows with a new key",
1850
- reason: "Invalid Operation", retryable: false,
2363
+ reason: "Invalid Operation",
2364
+ retryable: false,
1851
2365
  });
1852
2366
  exitCode = 2;
1853
2367
  }
@@ -1857,7 +2371,10 @@ export async function runCli(arguments_, dependencies) {
1857
2371
  .requiredOption("--project-id <projectId>")
1858
2372
  .action(async (options) => {
1859
2373
  exitCode = await run((client) => client.GET("/v1/projects/{projectId}/work-items/export", {
1860
- params: { path: { projectId: options.projectId }, query: workItemSelectionQuery(options) },
2374
+ params: {
2375
+ path: { projectId: options.projectId },
2376
+ query: workItemSelectionQuery(options),
2377
+ },
1861
2378
  }));
1862
2379
  });
1863
2380
  workItem
@@ -1877,7 +2394,9 @@ export async function runCli(arguments_, dependencies) {
1877
2394
  exitCode = await run((client) => client.POST("/v1/projects/{projectId}/work-items/{workItemId}/transfer", {
1878
2395
  body: {
1879
2396
  destinationProjectId: options.destinationProjectId,
1880
- ...(options.destinationStatus === undefined ? {} : { destinationStatus: options.destinationStatus }),
2397
+ ...(options.destinationStatus === undefined
2398
+ ? {}
2399
+ : { destinationStatus: options.destinationStatus }),
1881
2400
  },
1882
2401
  params: {
1883
2402
  header: { "idempotency-key": idempotencyKey, "if-match": options.expectedVersion },
@@ -1903,9 +2422,7 @@ export async function runCli(arguments_, dependencies) {
1903
2422
  const idempotencyKey = randomUUID();
1904
2423
  exitCode = await run((client) => client.POST("/v1/projects/{projectId}/work-items/{workItemId}/move", {
1905
2424
  body: {
1906
- ...(options.position === undefined
1907
- ? {}
1908
- : { position: options.position }),
2425
+ ...(options.position === undefined ? {} : { position: options.position }),
1909
2426
  status: options.status,
1910
2427
  },
1911
2428
  params: {
@@ -1924,7 +2441,8 @@ export async function runCli(arguments_, dependencies) {
1924
2441
  });
1925
2442
  });
1926
2443
  for (const action of ["archive", "unarchive"]) {
1927
- workItem.command(action)
2444
+ workItem
2445
+ .command(action)
1928
2446
  .requiredOption("--project-id <projectId>")
1929
2447
  .requiredOption("--work-item-id <workItemId>")
1930
2448
  .requiredOption("--expected-version <expectedVersion>", "Opaque version returned by SpecFlow", parseOpaqueVersion)
@@ -1934,10 +2452,20 @@ export async function runCli(arguments_, dependencies) {
1934
2452
  return;
1935
2453
  }
1936
2454
  const idempotencyKey = randomUUID();
1937
- exitCode = await run((client) => client.POST(action === "archive" ? "/v1/projects/{projectId}/work-items/{workItemId}/archive" : "/v1/projects/{projectId}/work-items/{workItemId}/unarchive", {
1938
- params: { path: { projectId: options.projectId, workItemId: options.workItemId },
1939
- header: { "if-match": options.expectedVersion, "idempotency-key": idempotencyKey } },
1940
- }), { retryTransportOnce: true, ambiguousOutcomeMessage: "Work Item archive outcome is unknown; read the Work Item before retrying" });
2455
+ exitCode = await run((client) => client.POST(action === "archive"
2456
+ ? "/v1/projects/{projectId}/work-items/{workItemId}/archive"
2457
+ : "/v1/projects/{projectId}/work-items/{workItemId}/unarchive", {
2458
+ params: {
2459
+ path: { projectId: options.projectId, workItemId: options.workItemId },
2460
+ header: {
2461
+ "if-match": options.expectedVersion,
2462
+ "idempotency-key": idempotencyKey,
2463
+ },
2464
+ },
2465
+ }), {
2466
+ retryTransportOnce: true,
2467
+ ambiguousOutcomeMessage: "Work Item archive outcome is unknown; read the Work Item before retrying",
2468
+ });
1941
2469
  });
1942
2470
  }
1943
2471
  workItem
@@ -1953,7 +2481,9 @@ export async function runCli(arguments_, dependencies) {
1953
2481
  }
1954
2482
  const idempotencyKey = randomUUID();
1955
2483
  exitCode = await run(async (client) => {
1956
- const board = await client.GET("/v1/projects/{projectId}/work-item-board", { params: { path: { projectId: options.projectId } } });
2484
+ const board = await client.GET("/v1/projects/{projectId}/work-item-board", {
2485
+ params: { path: { projectId: options.projectId } },
2486
+ });
1957
2487
  if (!board.response.ok) {
1958
2488
  return board;
1959
2489
  }
@@ -2009,7 +2539,9 @@ export async function runCli(arguments_, dependencies) {
2009
2539
  .requiredOption("--project-id <projectId>")
2010
2540
  .requiredOption("--label-id <labelId>")
2011
2541
  .action(async (options) => {
2012
- exitCode = await run((client) => client.GET("/v1/projects/{projectId}/work-item-labels/{labelId}", { params: { path: options } }));
2542
+ exitCode = await run((client) => client.GET("/v1/projects/{projectId}/work-item-labels/{labelId}", {
2543
+ params: { path: options },
2544
+ }));
2013
2545
  });
2014
2546
  workItemLabel
2015
2547
  .command("create")
@@ -2027,9 +2559,7 @@ export async function runCli(arguments_, dependencies) {
2027
2559
  body: {
2028
2560
  color: options.color,
2029
2561
  name: options.name,
2030
- ...(options.workItemId === undefined
2031
- ? {}
2032
- : { workItemId: options.workItemId }),
2562
+ ...(options.workItemId === undefined ? {} : { workItemId: options.workItemId }),
2033
2563
  },
2034
2564
  params: {
2035
2565
  header: { "idempotency-key": idempotencyKey },
@@ -2058,9 +2588,7 @@ export async function runCli(arguments_, dependencies) {
2058
2588
  const idempotencyKey = randomUUID();
2059
2589
  exitCode = await run((client) => client.PATCH("/v1/projects/{projectId}/work-item-labels/{labelId}", {
2060
2590
  body: {
2061
- ...(options.color === undefined
2062
- ? {}
2063
- : { color: options.color }),
2591
+ ...(options.color === undefined ? {} : { color: options.color }),
2064
2592
  ...(options.name === undefined ? {} : { name: options.name }),
2065
2593
  },
2066
2594
  params: {
@@ -2203,7 +2731,7 @@ export async function runCli(arguments_, dependencies) {
2203
2731
  .command("create")
2204
2732
  .requiredOption("--project-id <projectId>")
2205
2733
  .requiredOption("--name <name>")
2206
- .requiredOption("--type <type>", "text, number, date, dropdown, or boolean", parseWorkItemCustomFieldType)
2734
+ .requiredOption("--type <type>", "text, number, date, dropdown, multi-select, or boolean", parseWorkItemCustomFieldType)
2207
2735
  .option("--option <option>", "Dropdown option; repeat for every choice", collectOption, [])
2208
2736
  .option("--default-value <defaultValue>")
2209
2737
  .option("--required", "Reject Work Items that leave the field blank")
@@ -2216,17 +2744,11 @@ export async function runCli(arguments_, dependencies) {
2216
2744
  const idempotencyKey = randomUUID();
2217
2745
  exitCode = await run((client) => client.POST("/v1/projects/{projectId}/work-item-custom-fields", {
2218
2746
  body: {
2219
- ...(options.defaultValue === undefined
2220
- ? {}
2221
- : { defaultValue: options.defaultValue }),
2747
+ ...(options.defaultValue === undefined ? {} : { defaultValue: options.defaultValue }),
2222
2748
  name: options.name,
2223
2749
  ...(options.optionColors === undefined ? {} : { optionColors: options.optionColors }),
2224
- ...(options.option.length === 0
2225
- ? {}
2226
- : { options: options.option }),
2227
- ...(options.required === undefined
2228
- ? {}
2229
- : { required: options.required }),
2750
+ ...(options.option.length === 0 ? {} : { options: options.option }),
2751
+ ...(options.required === undefined ? {} : { required: options.required }),
2230
2752
  type: options.type,
2231
2753
  },
2232
2754
  params: {
@@ -2269,7 +2791,7 @@ export async function runCli(arguments_, dependencies) {
2269
2791
  workItemCustomField
2270
2792
  .command("reorder")
2271
2793
  .requiredOption("--project-id <projectId>")
2272
- .requiredOption("--order <order>", "Comma-separated id@version pairs in display order — version is the integer inside the field's opaque \"N\" version")
2794
+ .requiredOption("--order <order>", 'Comma-separated id@version pairs in display order — version is the integer inside the field\'s opaque "N" version')
2273
2795
  .action(async (options) => {
2274
2796
  if (hasWorkspaceReadToken(dependencies.environment)) {
2275
2797
  exitCode = rejectTokenWrite(dependencies);
@@ -2310,7 +2832,9 @@ export async function runCli(arguments_, dependencies) {
2310
2832
  .command("filter-values")
2311
2833
  .requiredOption("--project-id <projectId>")
2312
2834
  .action(async (options) => {
2313
- exitCode = await run((client) => client.GET("/v1/projects/{projectId}/work-item-custom-field-filter-values", { params: { path: options } }));
2835
+ exitCode = await run((client) => client.GET("/v1/projects/{projectId}/work-item-custom-field-filter-values", {
2836
+ params: { path: options },
2837
+ }));
2314
2838
  });
2315
2839
  workItemCustomField
2316
2840
  .command("set")
@@ -2368,12 +2892,8 @@ export async function runCli(arguments_, dependencies) {
2368
2892
  const idempotencyKey = randomUUID();
2369
2893
  exitCode = await run((client) => client.POST("/v1/projects/{projectId}/workflow-columns", {
2370
2894
  body: {
2371
- ...(options.color === undefined
2372
- ? {}
2373
- : { color: options.color }),
2374
- ...(options.category === undefined
2375
- ? {}
2376
- : { category: options.category }),
2895
+ ...(options.color === undefined ? {} : { color: options.color }),
2896
+ ...(options.category === undefined ? {} : { category: options.category }),
2377
2897
  ...(options.icon === undefined ? {} : { icon: options.icon }),
2378
2898
  name: options.name,
2379
2899
  },
@@ -2430,9 +2950,7 @@ export async function runCli(arguments_, dependencies) {
2430
2950
  ? {}
2431
2951
  : { icon: options.icon }),
2432
2952
  ...(options.category === undefined ? {} : { category: options.category }),
2433
- ...(options.name === undefined
2434
- ? {}
2435
- : { name: options.name }),
2953
+ ...(options.name === undefined ? {} : { name: options.name }),
2436
2954
  },
2437
2955
  params: {
2438
2956
  header: {
@@ -2479,7 +2997,7 @@ export async function runCli(arguments_, dependencies) {
2479
2997
  workflowColumn
2480
2998
  .command("reorder")
2481
2999
  .requiredOption("--project-id <projectId>")
2482
- .requiredOption("--order <order>", "Comma-separated slug@version pairs in board order — version is the integer inside the column's opaque \"N\" version")
3000
+ .requiredOption("--order <order>", 'Comma-separated slug@version pairs in board order — version is the integer inside the column\'s opaque "N" version')
2483
3001
  .action(async (options) => {
2484
3002
  if (hasWorkspaceReadToken(dependencies.environment)) {
2485
3003
  exitCode = rejectTokenWrite(dependencies);
@@ -2542,7 +3060,9 @@ export async function runCli(arguments_, dependencies) {
2542
3060
  exitCode = rejectTokenWrite(dependencies);
2543
3061
  return;
2544
3062
  }
2545
- exitCode = await run(async (client) => withSuccessData(await client.DELETE("/v1/workspaces/{workspaceId}/read-tokens/{tokenId}", { params: { path: options } }), { revoked: { tokenId: options.tokenId } }), {
3063
+ exitCode = await run(async (client) => withSuccessData(await client.DELETE("/v1/workspaces/{workspaceId}/read-tokens/{tokenId}", {
3064
+ params: { path: options },
3065
+ }), { revoked: { tokenId: options.tokenId } }), {
2546
3066
  ambiguousOutcomeMessage: "Workspace read-only Token revocation outcome is unknown; list tokens before retrying",
2547
3067
  retryTransportOnce: true,
2548
3068
  });
@@ -2557,7 +3077,10 @@ export async function runCli(arguments_, dependencies) {
2557
3077
  return cause.exitCode;
2558
3078
  }
2559
3079
  writeSkillError(dependencies, {
2560
- message: cause.message.replace(/'[^']*'/gu, (quoted) => /^'--?[a-z][a-z-]*(?: [<[][^>\]]+[>\]])?'$/u.test(quoted) ? quoted : "'<redacted>'").replace(/[\r\n]/gu, " ").slice(0, 500),
3080
+ message: cause.message
3081
+ .replace(/'[^']*'/gu, (quoted) => /^'--?[a-z][a-z-]*(?: [<[][^>\]]+[>\]])?'$/u.test(quoted) ? quoted : "'<redacted>'")
3082
+ .replace(/[\r\n]/gu, " ")
3083
+ .slice(0, 500),
2561
3084
  code: "INVALID_CLI_INPUT",
2562
3085
  reason: "Invalid Operation",
2563
3086
  retryable: false,
@@ -2630,7 +3153,15 @@ function parseWorkItemId(value) {
2630
3153
  throw invalidArgument("Work Item ID must be a Project ID followed by a positive number");
2631
3154
  }
2632
3155
  const workflowCategories = ["backlog", "unstarted", "started", "completed", "canceled"];
2633
- const workflowIcons = ["backlog", "todo", "in-progress", "in-review", "done", "canceled", "duplicate"];
3156
+ const workflowIcons = [
3157
+ "backlog",
3158
+ "todo",
3159
+ "in-progress",
3160
+ "in-review",
3161
+ "done",
3162
+ "canceled",
3163
+ "duplicate",
3164
+ ];
2634
3165
  function parseWorkflowCategory(value) {
2635
3166
  if (workflowCategories.includes(value))
2636
3167
  return value;
@@ -2641,13 +3172,7 @@ function parseWorkflowIcon(value) {
2641
3172
  return value;
2642
3173
  throw invalidArgument("Workflow icon must be backlog, todo, in-progress, in-review, done, canceled or duplicate");
2643
3174
  }
2644
- const workItemPriorities = [
2645
- "no-priority",
2646
- "low",
2647
- "medium",
2648
- "high",
2649
- "urgent",
2650
- ];
3175
+ const workItemPriorities = ["no-priority", "low", "medium", "high", "urgent"];
2651
3176
  function parseWorkItemPriority(value) {
2652
3177
  const normalized = value.trim().toLowerCase();
2653
3178
  if (workItemPriorities.includes(normalized)) {
@@ -2656,18 +3181,17 @@ function parseWorkItemPriority(value) {
2656
3181
  throw invalidArgument("Work Item priority must be no-priority, low, medium, high, or urgent");
2657
3182
  }
2658
3183
  function parseWorkItemDate(value) {
2659
- if (z.iso.date().safeParse(value).success ||
2660
- z.iso.datetime().safeParse(value).success) {
3184
+ if (z.iso.date().safeParse(value).success || z.iso.datetime().safeParse(value).success) {
2661
3185
  return value;
2662
3186
  }
2663
3187
  throw invalidArgument("Work Item dates must be an ISO 8601 date or date-time");
2664
3188
  }
2665
- const workItemDueDateFilters = [
2666
- "dueThisWeek",
2667
- "dueNextWeek",
2668
- "noDueDate",
2669
- ];
3189
+ const workItemDueDateFilters = ["dueThisWeek", "dueNextWeek", "noDueDate"];
2670
3190
  const workItemQuerySortFields = [
3191
+ "status",
3192
+ "startDate",
3193
+ "updatedAt",
3194
+ "assignee",
2671
3195
  "createdAt",
2672
3196
  "dueDate",
2673
3197
  "number",
@@ -2706,34 +3230,29 @@ function workItemSelectionQuery(options) {
2706
3230
  customFields[fieldId] = [...(customFields[fieldId] ?? []), value];
2707
3231
  }
2708
3232
  return {
2709
- ...(options.assignee.length === 0
3233
+ ...(options.creator === undefined || options.creator.length === 0
2710
3234
  ? {}
2711
- : { assignee: options.assignee.join(",") }),
3235
+ : { creator: options.creator.join(",") }),
3236
+ ...Object.fromEntries(["operators", "created", "updated", "relations", "specs", "pullRequests"].flatMap((key) => (options[key] === undefined ? [] : [[key, options[key]]]))),
3237
+ ...(options.assignee.length === 0 ? {} : { assignee: options.assignee.join(",") }),
3238
+ ...(options.watcher.length === 0 ? {} : { watcher: options.watcher.join(",") }),
2712
3239
  ...(Object.keys(customFields).length === 0
2713
3240
  ? {}
2714
3241
  : { customFields: JSON.stringify(customFields) }),
2715
3242
  ...(options.due.length === 0 ? {} : { due: options.due.join(",") }),
2716
3243
  ...(options.dueAfter === undefined ? {} : { dueAfter: options.dueAfter }),
2717
- ...(options.dueBefore === undefined
2718
- ? {}
2719
- : { dueBefore: options.dueBefore }),
3244
+ ...(options.dueBefore === undefined ? {} : { dueBefore: options.dueBefore }),
2720
3245
  ...(options.label.length === 0 ? {} : { label: options.label.join(",") }),
2721
- ...(options.priority.length === 0
3246
+ ...(options.priority.length === 0 ? {} : { priority: options.priority.join(",") }),
3247
+ ...(options.repositoryConnectionId === undefined
2722
3248
  ? {}
2723
- : { priority: options.priority.join(",") }),
2724
- ...(options.repositoryConnectionId === undefined ? {} : { repositoryConnectionId: options.repositoryConnectionId }),
3249
+ : { repositoryConnectionId: options.repositoryConnectionId }),
2725
3250
  ...(options.search === undefined ? {} : { search: options.search }),
2726
3251
  ...(options.sort === undefined ? {} : { sortBy: options.sort }),
2727
3252
  ...(options.order === undefined ? {} : { sortOrder: options.order }),
2728
- ...(options.startAfter === undefined
2729
- ? {}
2730
- : { startAfter: options.startAfter }),
2731
- ...(options.startBefore === undefined
2732
- ? {}
2733
- : { startBefore: options.startBefore }),
2734
- ...(options.status.length === 0
2735
- ? {}
2736
- : { status: options.status.join(",") }),
3253
+ ...(options.startAfter === undefined ? {} : { startAfter: options.startAfter }),
3254
+ ...(options.startBefore === undefined ? {} : { startBefore: options.startBefore }),
3255
+ ...(options.status.length === 0 ? {} : { status: options.status.join(",") }),
2737
3256
  };
2738
3257
  }
2739
3258
  /** List and board only: which completed Work Items to keep. */
@@ -2750,7 +3269,15 @@ function workItemCompletedFlag(command) {
2750
3269
  */
2751
3270
  function workItemSelectionFlags(command) {
2752
3271
  return command
2753
- .option("--assignee <assignee>", "Filter by assignee User ID only (me is not supported), or unassigned for items with none; repeat for several", collectOption, [])
3272
+ .option("--creator <id>", "Creator User ID or me; repeat for several", collectOption, [])
3273
+ .option("--operators <json>", "Category -> include|exclude; custom fields use customField:<id>")
3274
+ .option("--created <filter>", "today|pastWeek|past2Weeks|pastMonth|past3Months or YYYY-MM-DD (UTC inclusive)")
3275
+ .option("--updated <filter>", "Same time choices as --created")
3276
+ .option("--relations <csv>", "blocked,blocking,hasParent,hasChildren,related")
3277
+ .option("--specs <csv>", "Linked Spec IDs, or none")
3278
+ .option("--pull-requests <csv>", "none,draft,open,merged,closed; synchronized state only")
3279
+ .option("--assignee <assignee>", "Filter by assignee User ID, me, or unassigned; repeat for several", collectOption, [])
3280
+ .option("--watcher <userId>", "Filter by watcher User ID or me; repeat for several", collectOption, [])
2754
3281
  .option("--custom-field <fieldId=value>", "Filter by Custom Field value; repeat to OR values or combine fields", collectOption, [])
2755
3282
  .option("--due <filter>", "Filter by due bucket: dueThisWeek, dueNextWeek, or noDueDate; repeat for several", (value, previous) => [
2756
3283
  ...previous,
@@ -2759,10 +3286,7 @@ function workItemSelectionFlags(command) {
2759
3286
  .option("--due-after <date>", "Filter due on/after", parseWorkItemDate)
2760
3287
  .option("--due-before <date>", "Filter due on/before", parseWorkItemDate)
2761
3288
  .option("--label <labelId>", "Filter by Work Item Label ID; repeat for several", collectOption, [])
2762
- .option("--priority <priority>", "Filter by priority; repeat for several", (value, previous) => [
2763
- ...previous,
2764
- parseWorkItemPriority(value),
2765
- ], [])
3289
+ .option("--priority <priority>", "Filter by priority; repeat for several", (value, previous) => [...previous, parseWorkItemPriority(value)], [])
2766
3290
  .option("--repository-connection-id <id>", "Filter by an explicit GitHub repository connection")
2767
3291
  .option("--search <search>", "Filter by title search text")
2768
3292
  .option("--sort <field>", "Sort by field", parseWorkItemSortField)
@@ -2795,20 +3319,21 @@ function parseWorkItemBulkTarget(value, previous) {
2795
3319
  throw invalidArgument(`Bulk target "${value}" must be a WORK-ITEM-ID@version pair`);
2796
3320
  }
2797
3321
  const numericVersion = Number(version);
2798
- if (!Number.isSafeInteger(numericVersion) ||
2799
- numericVersion > 2_147_483_647) {
3322
+ if (!Number.isSafeInteger(numericVersion) || numericVersion > 2_147_483_647) {
2800
3323
  throw invalidArgument(`Bulk target "${value}" has a version outside the supported range`);
2801
3324
  }
2802
3325
  return [
2803
3326
  ...previous,
2804
- { expectedVersion: `"${version}"`, id: id.trim().toUpperCase(), ...(projectId === undefined ? {} : { projectId }) },
3327
+ {
3328
+ expectedVersion: `"${version}"`,
3329
+ id: id.trim().toUpperCase(),
3330
+ ...(projectId === undefined ? {} : { projectId }),
3331
+ },
2805
3332
  ];
2806
3333
  }
2807
3334
  function parseBoardPosition(value) {
2808
3335
  const position = Number(value);
2809
- if (!Number.isInteger(position) ||
2810
- position < 0 ||
2811
- position > 2_147_483_646) {
3336
+ if (!Number.isInteger(position) || position < 0 || position > 2_147_483_646) {
2812
3337
  throw invalidArgument("Board position must be a nonnegative integer within the supported range");
2813
3338
  }
2814
3339
  return position;
@@ -2847,6 +3372,7 @@ const workItemCustomFieldTypes = [
2847
3372
  "text",
2848
3373
  "number",
2849
3374
  "date",
3375
+ "multi-select",
2850
3376
  "dropdown",
2851
3377
  "boolean",
2852
3378
  ];
@@ -2855,7 +3381,7 @@ function parseWorkItemCustomFieldType(value) {
2855
3381
  if (workItemCustomFieldTypes.includes(normalized)) {
2856
3382
  return normalized;
2857
3383
  }
2858
- throw invalidArgument("Custom Field type must be text, number, date, dropdown, or boolean");
3384
+ throw invalidArgument("Custom Field type must be text, number, date, dropdown, multi-select, or boolean");
2859
3385
  }
2860
3386
  function collectOption(value, previous) {
2861
3387
  return [...previous, value];
@@ -2978,9 +3504,7 @@ function parseStringArray(value, label) {
2978
3504
  }
2979
3505
  function toAgentProvenance(options) {
2980
3506
  return {
2981
- ...(options.agentRevision === undefined
2982
- ? {}
2983
- : { agentRevision: options.agentRevision }),
3507
+ ...(options.agentRevision === undefined ? {} : { agentRevision: options.agentRevision }),
2984
3508
  ...(options.agentModel === undefined ? {} : { model: options.agentModel }),
2985
3509
  sourceReferenceIds: options.sourceReferenceIds === undefined
2986
3510
  ? []
@@ -3028,9 +3552,7 @@ function parseFindingInput(value) {
3028
3552
  return finding.data;
3029
3553
  }
3030
3554
  function withSuccessData(result, data) {
3031
- return result.response.ok && result.data === undefined
3032
- ? { ...result, data }
3033
- : result;
3555
+ return result.response.ok && result.data === undefined ? { ...result, data } : result;
3034
3556
  }
3035
3557
  /**
3036
3558
  * Whether a `work-item-label delete` payload is the still-running cascade —
@@ -3043,10 +3565,8 @@ function isWorkItemLabelDeletionPending(data) {
3043
3565
  const label = data.workItemLabel;
3044
3566
  return (typeof label === "object" &&
3045
3567
  label !== null &&
3046
- label.deletionStartedAt !==
3047
- null &&
3048
- label.deletionStartedAt !==
3049
- undefined);
3568
+ label.deletionStartedAt !== null &&
3569
+ label.deletionStartedAt !== undefined);
3050
3570
  }
3051
3571
  function rejectTokenWrite(dependencies) {
3052
3572
  if (hasWorkspaceReadToken(dependencies.environment)) {
@@ -3065,7 +3585,13 @@ function rejectTokenWrite(dependencies) {
3065
3585
  return 2;
3066
3586
  }
3067
3587
  function parseCommentContent(value) {
3068
- const result = z.string().trim().min(1).max(20_000).refine((content) => !content.includes("\0")).safeParse(value);
3588
+ const result = z
3589
+ .string()
3590
+ .trim()
3591
+ .min(1)
3592
+ .max(20_000)
3593
+ .refine((content) => !content.includes("\0"))
3594
+ .safeParse(value);
3069
3595
  if (!result.success)
3070
3596
  throw invalidArgument("Comment content must contain 1 through 20000 characters without null characters");
3071
3597
  return result.data;
@@ -3106,11 +3632,47 @@ function parseNotificationPreferences(value) {
3106
3632
  catch {
3107
3633
  throw invalidArgument("Notification preferences must be a JSON object");
3108
3634
  }
3109
- const result = z.object({ taskAssignmentEnabled: z.boolean().optional(), taskCommentEnabled: z.boolean().optional(), taskStatusChangeEnabled: z.boolean().optional(), dueDateReminderEnabled: z.boolean().optional(), dueDateReminderMinutes: z.number().int().min(5).max(43200).optional() }).strict().safeParse(parsed);
3635
+ const result = z
3636
+ .object({
3637
+ taskAssignmentEnabled: z.boolean().optional(),
3638
+ taskCommentEnabled: z.boolean().optional(),
3639
+ taskStatusChangeEnabled: z.boolean().optional(),
3640
+ dueDateReminderEnabled: z.boolean().optional(),
3641
+ dueDateReminderMinutes: z.number().int().min(5).max(43200).optional(),
3642
+ })
3643
+ .strict()
3644
+ .safeParse(parsed);
3110
3645
  if (!result.success)
3111
3646
  throw invalidArgument("Notification preferences contain unsupported settings or invalid values");
3112
3647
  const data = result.data;
3113
- return { ...(data.taskAssignmentEnabled === undefined ? {} : { taskAssignmentEnabled: data.taskAssignmentEnabled }), ...(data.taskCommentEnabled === undefined ? {} : { taskCommentEnabled: data.taskCommentEnabled }), ...(data.taskStatusChangeEnabled === undefined ? {} : { taskStatusChangeEnabled: data.taskStatusChangeEnabled }), ...(data.dueDateReminderEnabled === undefined ? {} : { dueDateReminderEnabled: data.dueDateReminderEnabled }), ...(data.dueDateReminderMinutes === undefined ? {} : { dueDateReminderMinutes: data.dueDateReminderMinutes }) };
3648
+ return {
3649
+ ...(data.taskAssignmentEnabled === undefined
3650
+ ? {}
3651
+ : { taskAssignmentEnabled: data.taskAssignmentEnabled }),
3652
+ ...(data.taskCommentEnabled === undefined
3653
+ ? {}
3654
+ : { taskCommentEnabled: data.taskCommentEnabled }),
3655
+ ...(data.taskStatusChangeEnabled === undefined
3656
+ ? {}
3657
+ : { taskStatusChangeEnabled: data.taskStatusChangeEnabled }),
3658
+ ...(data.dueDateReminderEnabled === undefined
3659
+ ? {}
3660
+ : { dueDateReminderEnabled: data.dueDateReminderEnabled }),
3661
+ ...(data.dueDateReminderMinutes === undefined
3662
+ ? {}
3663
+ : { dueDateReminderMinutes: data.dueDateReminderMinutes }),
3664
+ };
3114
3665
  }
3115
- const reviewPlanInputSchema = z.discriminatedUnion("cadence", [z.object({ cadence: z.literal("Disabled") }).strict(), z.object({ cadence: z.literal("Daily"), timeOfDay: z.string(), timeZone: z.string() }).strict(), z.object({ cadence: z.literal("Weekly"), dayOfWeek: z.number().int().min(1).max(7), timeOfDay: z.string(), timeZone: z.string() }).strict()]);
3666
+ const reviewPlanInputSchema = z.discriminatedUnion("cadence", [
3667
+ z.object({ cadence: z.literal("Disabled") }).strict(),
3668
+ z.object({ cadence: z.literal("Daily"), timeOfDay: z.string(), timeZone: z.string() }).strict(),
3669
+ z
3670
+ .object({
3671
+ cadence: z.literal("Weekly"),
3672
+ dayOfWeek: z.number().int().min(1).max(7),
3673
+ timeOfDay: z.string(),
3674
+ timeZone: z.string(),
3675
+ })
3676
+ .strict(),
3677
+ ]);
3116
3678
  //# sourceMappingURL=cli.js.map