@gonovus-ai/spec-flow-cli 0.6.2 → 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 (73) hide show
  1. package/README.md +48 -4
  2. package/dist/authentication-command-topology.js.map +1 -1
  3. package/dist/bin.js.map +1 -1
  4. package/dist/cli.js +879 -295
  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 +19 -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.d.ts +3 -0
  59. package/dist/work-item-delivery-commands.js +135 -0
  60. package/dist/work-item-delivery-commands.js.map +1 -0
  61. package/dist/work-item-exchange-file.js +22 -8
  62. package/dist/work-item-exchange-file.js.map +1 -1
  63. package/dist/work-item-query-commands.js +420 -14
  64. package/dist/work-item-query-commands.js.map +1 -1
  65. package/dist/work-item-resource-link-commands.js +105 -28
  66. package/dist/work-item-resource-link-commands.js.map +1 -1
  67. package/dist/work-item-thread-commands.d.ts +3 -0
  68. package/dist/work-item-thread-commands.js +101 -0
  69. package/dist/work-item-thread-commands.js.map +1 -0
  70. package/dist/work-item-watcher-commands.d.ts +20 -0
  71. package/dist/work-item-watcher-commands.js +93 -0
  72. package/dist/work-item-watcher-commands.js.map +1 -0
  73. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -2,25 +2,28 @@ 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";
20
20
  import { registerWorkItemAssetCommands } from "./work-item-asset-commands.js";
21
+ import { registerWorkItemDeliveryCommands } from "./work-item-delivery-commands.js";
21
22
  import { readWorkItemImportFile } from "./work-item-exchange-file.js";
22
23
  import { registerWorkItemQueryCommands } from "./work-item-query-commands.js";
23
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";
24
27
  export function formatResourceDiagnostic(message) {
25
28
  return `${JSON.stringify({ diagnostic: { level: "warning", message } })}\n`;
26
29
  }
@@ -48,7 +51,10 @@ const sourceReferenceInputSchema = z
48
51
  externalRevision: z.string().trim().min(1).max(200).optional(),
49
52
  section: z.string().trim().min(1).max(500).optional(),
50
53
  title: z.string().trim().min(1).max(300),
51
- url: z.url().max(2_000).refine((value) => {
54
+ url: z
55
+ .url()
56
+ .max(2_000)
57
+ .refine((value) => {
52
58
  const url = new URL(value);
53
59
  return ((url.protocol === "https:" || url.protocol === "http:") &&
54
60
  url.username.length === 0 &&
@@ -67,7 +73,11 @@ const findingReferenceSchema = z
67
73
  const findingTargetSchema = z
68
74
  .object({
69
75
  references: z.array(findingReferenceSchema).min(1).max(50),
70
- 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),
71
81
  })
72
82
  .strict();
73
83
  const findingEvidenceSchema = z.discriminatedUnion("kind", [
@@ -141,7 +151,9 @@ const findingCreateInputSchema = z
141
151
  export async function runCli(arguments_, dependencies) {
142
152
  let exitCode = 0;
143
153
  let outputMode = "full";
144
- 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
+ };
145
157
  const program = createProgram(dependencies);
146
158
  const run = async (request, options = {}) => {
147
159
  const selected = await selectSession(dependencies, options, program.getOptionValue("server"), program.getOptionValue("apiKeyId"));
@@ -158,27 +170,61 @@ export async function runCli(arguments_, dependencies) {
158
170
  }
159
171
  me = identity.data.user.id;
160
172
  }
161
- 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);
162
174
  if (!result.ok) {
163
175
  writeSkillError(dependencies, result.error);
164
176
  return skillErrorExitCode(result.error);
165
177
  }
166
178
  return writeResult(dependencies, () => options.project === undefined ? result.data : options.project(result.data));
167
179
  };
168
- registerUserApiKeyCommands(program, { dependencies, run, setExitCode: (value) => { exitCode = value; }, parseScopes: parseRoleStatements, parseLimit: parseSearchLimit });
169
- 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
+ });
170
196
  const authentication = addAuthenticationCommandTopology(program);
171
197
  program.hook("preAction", (_command, actionCommand) => {
172
198
  const names = [];
173
199
  for (let command = actionCommand; command.parent !== null; command = command.parent)
174
200
  names.unshift(command.name());
175
201
  const path = names.join(" ");
176
- outputMode = program.opts().output ?? (path === "work-item subtask link" ? "summary" : "full");
177
- 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))
178
216
  throw invalidArgument("Summary output is not supported for this command");
179
- 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)) {
180
224
  const assignee = actionCommand.getOptionValue("assignee");
181
- 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"))))
182
228
  throw invalidArgument("This command accepts User IDs only; me is supported by work-item create and assign");
183
229
  }
184
230
  const options = actionCommand.opts();
@@ -192,32 +238,36 @@ export async function runCli(arguments_, dependencies) {
192
238
  actionCommand.setOptionValue("workItemId", parseWorkItemId(options.workItemId));
193
239
  }
194
240
  });
195
- for (const command of [
196
- authentication.login,
197
- authentication.logout,
198
- authentication.status,
199
- ]) {
241
+ for (const command of [authentication.login, authentication.logout, authentication.status]) {
200
242
  command.action(() => {
201
243
  throw new CommanderError(2, "specflow.authenticationCommand", "Authentication commands use the human-facing CLI boundary");
202
244
  });
203
245
  }
204
246
  dependencies.registerAuthentication?.(program, authentication);
205
- 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 () => {
206
251
  exitCode = await run(async (client, _me, credentialKind) => {
207
252
  const result = await readIdentity(client);
208
- 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
+ };
209
259
  }, { rejectWorkspaceReadToken: true });
210
260
  });
211
261
  const workspace = program.command("workspace");
212
- workspace
213
- .command("list")
214
- .action(async () => {
215
- 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
+ });
216
266
  });
217
267
  workspace
218
268
  .command("create")
219
269
  .requiredOption("--name <name>")
220
- .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")
221
271
  .option("--spec-language <language>", "Workspace keyword language: zh-CN or en", (value) => z.enum(["zh-CN", "en"]).parse(value), "zh-CN")
222
272
  .action(async (options) => {
223
273
  if (hasWorkspaceReadToken(dependencies.environment)) {
@@ -226,23 +276,63 @@ export async function runCli(arguments_, dependencies) {
226
276
  }
227
277
  const idempotencyKey = randomUUID();
228
278
  exitCode = await run((client) => client.POST("/v1/workspaces", {
229
- 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
+ },
230
284
  params: { header: { "idempotency-key": idempotencyKey } },
231
- }), { 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
+ });
232
289
  });
233
- 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) => {
234
- 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 });
235
307
  });
236
308
  const workspaceSettings = workspace.command("settings");
237
- workspaceSettings.command("read").requiredOption("--workspace-id <workspaceId>").action(async (options) => {
238
- 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 } }));
239
314
  });
240
- 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) => {
241
322
  if (hasWorkspaceReadToken(dependencies.environment)) {
242
323
  exitCode = rejectTokenWrite(dependencies);
243
324
  return;
244
325
  }
245
- 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 });
246
336
  });
247
337
  const workspaceMember = workspace.command("member");
248
338
  workspaceMember
@@ -439,12 +529,8 @@ export async function runCli(arguments_, dependencies) {
439
529
  exitCode = await run((client) => client.GET("/v1/projects", {
440
530
  params: {
441
531
  query: {
442
- ...(options.status === undefined
443
- ? {}
444
- : { status: options.status }),
445
- ...(options.workspaceId === undefined
446
- ? {}
447
- : { workspaceId: options.workspaceId }),
532
+ ...(options.status === undefined ? {} : { status: options.status }),
533
+ ...(options.workspaceId === undefined ? {} : { workspaceId: options.workspaceId }),
448
534
  },
449
535
  },
450
536
  }), { rejectWorkspaceReadToken: true });
@@ -497,15 +583,19 @@ export async function runCli(arguments_, dependencies) {
497
583
  params: { path: { projectId: options.projectId } },
498
584
  }));
499
585
  });
500
- const sharing = project.command("sharing").description("Manage anonymous task-only Project sharing");
501
- sharing.command("read")
586
+ const sharing = project
587
+ .command("sharing")
588
+ .description("Manage anonymous task-only Project sharing");
589
+ sharing
590
+ .command("read")
502
591
  .requiredOption("--project-id <projectId>")
503
592
  .action(async (options) => {
504
593
  exitCode = await run((client) => client.GET("/v1/projects/{projectId}/sharing", {
505
594
  params: { path: { projectId: options.projectId } },
506
595
  }), { rejectWorkspaceReadToken: true });
507
596
  });
508
- sharing.command("set")
597
+ sharing
598
+ .command("set")
509
599
  .requiredOption("--project-id <projectId>")
510
600
  .requiredOption("--public <boolean>", "true or false", (value) => {
511
601
  if (value !== "true" && value !== "false")
@@ -525,12 +615,39 @@ export async function runCli(arguments_, dependencies) {
525
615
  }
526
616
  exitCode = await run((client) => client.PUT("/v1/projects/{projectId}/sharing", {
527
617
  body: { isPublic: options.public },
528
- params: { path: { projectId: options.projectId }, header: { "if-match": options.expectedVersion, "idempotency-key": options.idempotencyKey } },
529
- }), { 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
+ });
530
630
  });
531
631
  const spec = program.command("spec");
532
- 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) => {
533
- 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 });
534
651
  });
535
652
  spec
536
653
  .command("read")
@@ -546,7 +663,9 @@ export async function runCli(arguments_, dependencies) {
546
663
  .requiredOption("--workspace-id <workspaceId>")
547
664
  .requiredOption("--spec-id <specId>")
548
665
  .action(async (options) => {
549
- 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 });
550
669
  });
551
670
  spec
552
671
  .command("search")
@@ -559,9 +678,7 @@ export async function runCli(arguments_, dependencies) {
559
678
  params: {
560
679
  path: { workspaceId: options.workspaceId },
561
680
  query: {
562
- ...(options.cursor === undefined
563
- ? {}
564
- : { cursor: options.cursor }),
681
+ ...(options.cursor === undefined ? {} : { cursor: options.cursor }),
565
682
  limit: options.limit,
566
683
  query: options.query,
567
684
  },
@@ -573,7 +690,9 @@ export async function runCli(arguments_, dependencies) {
573
690
  .requiredOption("--workspace-id <workspaceId>")
574
691
  .requiredOption("--spec-id <specId>")
575
692
  .action(async (options) => {
576
- 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 } }));
577
696
  });
578
697
  spec
579
698
  .command("revision")
@@ -581,7 +700,9 @@ export async function runCli(arguments_, dependencies) {
581
700
  .requiredOption("--spec-id <specId>")
582
701
  .requiredOption("--revision-id <revisionId>")
583
702
  .action(async (options) => {
584
- 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 } }));
585
706
  });
586
707
  spec
587
708
  .command("edit")
@@ -687,8 +808,7 @@ export async function runCli(arguments_, dependencies) {
687
808
  exitCode = rejectTokenWrite(dependencies);
688
809
  return;
689
810
  }
690
- if (options.capabilityId === undefined &&
691
- options.sourceReferences === undefined) {
811
+ if (options.capabilityId === undefined && options.sourceReferences === undefined) {
692
812
  throw invalidArgument("Spec update requires Metadata to change");
693
813
  }
694
814
  const sourceReferences = options.sourceReferences === undefined
@@ -699,9 +819,7 @@ export async function runCli(arguments_, dependencies) {
699
819
  ...(options.capabilityId === undefined
700
820
  ? {}
701
821
  : { capabilityId: options.capabilityId === "none" ? null : options.capabilityId }),
702
- ...(sourceReferences === undefined
703
- ? {}
704
- : { sourceReferences }),
822
+ ...(sourceReferences === undefined ? {} : { sourceReferences }),
705
823
  },
706
824
  params: {
707
825
  header: { "if-match": options.expectedVersion },
@@ -745,12 +863,10 @@ export async function runCli(arguments_, dependencies) {
745
863
  exitCode = rejectTokenWrite(dependencies);
746
864
  return;
747
865
  }
748
- if (options.state === "Unavailable" &&
749
- options.unavailabilityReason === undefined) {
866
+ if (options.state === "Unavailable" && options.unavailabilityReason === undefined) {
750
867
  throw invalidArgument("Unavailable requires --unavailability-reason");
751
868
  }
752
- if (options.state === "Ready" &&
753
- options.unavailabilityReason !== undefined) {
869
+ if (options.state === "Ready" && options.unavailabilityReason !== undefined) {
754
870
  throw invalidArgument("Ready does not accept --unavailability-reason");
755
871
  }
756
872
  exitCode = await run((client) => client.PATCH("/v1/workspaces/{workspaceId}/specs/{specId}/state", {
@@ -811,7 +927,9 @@ export async function runCli(arguments_, dependencies) {
811
927
  .requiredOption("--workspace-id <workspaceId>")
812
928
  .requiredOption("--revision-id <revisionId>")
813
929
  .action(async (options) => {
814
- 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 } }));
815
933
  });
816
934
  workspaceGlossary
817
935
  .command("read")
@@ -908,8 +1026,13 @@ export async function runCli(arguments_, dependencies) {
908
1026
  retryTransportOnce: true,
909
1027
  });
910
1028
  });
911
- workspace.command("context").requiredOption("--workspace-id <workspaceId>").action(async (options) => {
912
- 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 });
913
1036
  });
914
1037
  const proposal = program.command("proposal");
915
1038
  proposal
@@ -991,9 +1114,7 @@ export async function runCli(arguments_, dependencies) {
991
1114
  query: {
992
1115
  ...(options.specId === undefined ? {} : { specId: options.specId }),
993
1116
  ...(options.status === undefined ? {} : { status: options.status }),
994
- ...(options.targetKind === undefined
995
- ? {}
996
- : { targetKind: options.targetKind }),
1117
+ ...(options.targetKind === undefined ? {} : { targetKind: options.targetKind }),
997
1118
  },
998
1119
  },
999
1120
  }));
@@ -1146,9 +1267,27 @@ export async function runCli(arguments_, dependencies) {
1146
1267
  .option("--limit <limit>", "Maximum results", parseSearchLimit, 20)
1147
1268
  .option("--cursor <cursor>")
1148
1269
  .action(async (options) => {
1149
- exitCode = await run(client => options.specId === undefined
1150
- ? 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 }) } } })
1151
- : 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 });
1152
1291
  });
1153
1292
  workspaceFinding
1154
1293
  .command("read")
@@ -1212,36 +1351,112 @@ export async function runCli(arguments_, dependencies) {
1212
1351
  });
1213
1352
  });
1214
1353
  }
1215
- 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) => {
1216
- 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 });
1217
1372
  });
1218
- workspaceFinding.command("follow-up").requiredOption("--workspace-id <workspaceId>").requiredOption("--finding-id <findingId>").requiredOption("--project-id <projectId>").requiredOption("--idempotency-key <key>").action(async (options) => {
1219
- 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 });
1220
1387
  });
1221
- workspaceFinding.command("discussion").requiredOption("--workspace-id <workspaceId>").requiredOption("--finding-id <findingId>").action(async (options) => {
1222
- 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 });
1223
1396
  });
1224
- 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) => {
1225
- 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 });
1226
1409
  });
1227
1410
  const workspaceReview = workspace.command("review");
1228
- workspaceReview.command("request").requiredOption("--workspace-id <workspaceId>").requiredOption("--spec-id <specId>").option("--idempotency-key <key>").action(async (options) => {
1229
- 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 });
1230
1423
  });
1231
- workspaceReview.command("history").requiredOption("--workspace-id <workspaceId>").action(async (options) => {
1232
- 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 });
1233
1429
  });
1234
- workspaceReview.command("read").requiredOption("--workspace-id <workspaceId>").requiredOption("--review-id <reviewId>").action(async (options) => {
1235
- 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 });
1236
1438
  });
1237
- workspaceReview.command("plan").requiredOption("--workspace-id <workspaceId>").action(async (options) => {
1238
- 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 });
1239
1444
  });
1240
- 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) => {
1241
1451
  const body = reviewPlanInputSchema.parse(JSON.parse(options.input));
1242
- 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 });
1243
1456
  });
1244
- 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");
1245
1460
  notification.command("list").action(async () => {
1246
1461
  if (hasWorkspaceReadToken(dependencies.environment)) {
1247
1462
  exitCode = rejectWorkspaceReadTokenOperation(dependencies);
@@ -1249,14 +1464,18 @@ export async function runCli(arguments_, dependencies) {
1249
1464
  }
1250
1465
  exitCode = await run((client) => client.GET("/v1/notifications"));
1251
1466
  });
1252
- notification.command("create")
1467
+ notification
1468
+ .command("create")
1253
1469
  .option("--title <title>")
1254
1470
  .option("--message <message>")
1255
1471
  .option("--type <type>", "Notification type", "info")
1256
1472
  .option("--event-data <json>", "JSON object for presentation", parseNotificationEventData)
1257
1473
  .option("--related-entity-id <id>", "Public task ID or Workspace ID")
1258
- .option("--related-entity-type <type>", "task or workspace", (value) => { if (value !== "task" && value !== "workspace")
1259
- 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
+ })
1260
1479
  .requiredOption("--idempotency-key <key>", "Reuse the same command key and inputs when retrying", parseNotificationUuid)
1261
1480
  .action(async (options) => {
1262
1481
  if (hasWorkspaceReadToken(dependencies.environment)) {
@@ -1265,9 +1484,27 @@ export async function runCli(arguments_, dependencies) {
1265
1484
  }
1266
1485
  if ((options.relatedEntityId === undefined) !== (options.relatedEntityType === undefined))
1267
1486
  throw invalidArgument("Notification target identity and type must be provided together");
1268
- 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
+ });
1269
1505
  });
1270
- notification.command("read")
1506
+ notification
1507
+ .command("read")
1271
1508
  .requiredOption("--notification-id <id>", "Notification UUID returned by the list", parseNotificationUuid)
1272
1509
  .requiredOption("--idempotency-key <key>", "Reuse the same key when retrying", parseNotificationUuid)
1273
1510
  .action(async (options) => {
@@ -1275,17 +1512,32 @@ export async function runCli(arguments_, dependencies) {
1275
1512
  exitCode = rejectWorkspaceReadTokenOperation(dependencies);
1276
1513
  return;
1277
1514
  }
1278
- 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
+ });
1279
1524
  });
1280
1525
  for (const action of ["read-all", "clear"]) {
1281
- 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)
1282
1529
  .action(async (options) => {
1283
1530
  if (hasWorkspaceReadToken(dependencies.environment)) {
1284
1531
  exitCode = rejectWorkspaceReadTokenOperation(dependencies);
1285
1532
  return;
1286
1533
  }
1287
1534
  const params = { header: { "idempotency-key": options.idempotencyKey } };
1288
- 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
+ });
1289
1541
  });
1290
1542
  }
1291
1543
  const notificationPreferences = notification.command("preferences");
@@ -1296,7 +1548,8 @@ export async function runCli(arguments_, dependencies) {
1296
1548
  }
1297
1549
  exitCode = await run((client) => client.GET("/v1/notification-preferences"));
1298
1550
  });
1299
- notificationPreferences.command("update")
1551
+ notificationPreferences
1552
+ .command("update")
1300
1553
  .requiredOption("--expected-version <version>", "Opaque preference version returned by get")
1301
1554
  .requiredOption("--preferences <json>", "JSON category settings; omitted settings remain unchanged", parseNotificationPreferences)
1302
1555
  .requiredOption("--idempotency-key <key>", "Reuse the same key and settings when retrying", parseNotificationUuid)
@@ -1305,49 +1558,129 @@ export async function runCli(arguments_, dependencies) {
1305
1558
  exitCode = rejectWorkspaceReadTokenOperation(dependencies);
1306
1559
  return;
1307
1560
  }
1308
- 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
+ });
1309
1573
  });
1310
1574
  const workItem = program.command("work-item");
1311
- registerWorkItemAssetCommands(workItem, { dependencies, run, setExitCode: (value) => { exitCode = value; }, rejectWrite: () => rejectTokenWrite(dependencies) });
1312
- 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
+ };
1313
1591
  registerSpecOwnerCommands(spec, resourceRuntime);
1314
1592
  registerSpecDiscussionCommands(spec, resourceRuntime);
1315
1593
  registerProjectAdministrationCommands(project, workspace, resourceRuntime);
1316
- 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")
1317
1597
  .requiredOption("--query <query>")
1318
1598
  .option("--types <types>", "Comma-separated kinds: project,work-item,capability,spec,glossary,screen,journey,user")
1319
1599
  .option("--limit <limit>", "Server page size (1–100)", resourceRuntime.parseLimit, 20)
1320
1600
  .option("--cursor <cursor>")
1321
1601
  .action(async (options) => {
1322
- resourceRuntime.setExitCode(await resourceRuntime.run(client => client.GET("/v1/search", {
1323
- 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
+ },
1324
1611
  }), { rejectWorkspaceReadToken: true }));
1325
1612
  });
1326
1613
  registerWorkItemQueryCommands(workItem, workspace, resourceRuntime);
1327
- registerProductMapCommands(program, { dependencies, run, setExitCode: value => { exitCode = value; }, canWrite: () => !hasWorkspaceReadToken(dependencies.environment), rejectWrite: () => rejectTokenWrite(dependencies), parseOpaqueVersion });
1328
- registerWorkItemResourceLinkCommands(workItem, spec, { run, setExitCode: (value) => { exitCode = value; }, canWrite: () => !hasWorkspaceReadToken(dependencies.environment), rejectWrite: () => rejectTokenWrite(dependencies), parseOpaqueVersion, parseLimit: parseSearchLimit });
1329
- const workItemComment = workItem.command("comment").description("Read and manage authored task comments");
1330
- workItemComment.command("list")
1614
+ registerWorkItemDeliveryCommands(workItem, project, resourceRuntime);
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")
1331
1649
  .requiredOption("--project-id <projectId>")
1332
1650
  .requiredOption("--work-item-id <workItemId>")
1333
1651
  .option("--limit <limit>", "Maximum results, 1 through 100", parseSearchLimit, 50)
1334
1652
  .option("--cursor <cursor>", "Opaque cursor returned by the previous page")
1335
1653
  .action(async (options) => {
1336
1654
  exitCode = await run((client) => client.GET("/v1/projects/{projectId}/work-items/{workItemId}/comments", {
1337
- 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
+ },
1338
1662
  }));
1339
1663
  });
1340
- 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")
1341
1667
  .requiredOption("--project-id <projectId>")
1342
1668
  .requiredOption("--work-item-id <workItemId>")
1343
1669
  .option("--limit <limit>", "Maximum results, 1 through 100", parseSearchLimit, 50)
1344
1670
  .option("--cursor <cursor>", "Opaque cursor returned by the previous page")
1345
1671
  .action(async (options) => {
1346
1672
  exitCode = await run((client) => client.GET("/v1/projects/{projectId}/work-items/{workItemId}/discussion", {
1347
- 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
+ },
1348
1680
  }));
1349
1681
  });
1350
- workItemComment.command("create")
1682
+ workItemComment
1683
+ .command("create")
1351
1684
  .requiredOption("--project-id <projectId>")
1352
1685
  .requiredOption("--work-item-id <workItemId>")
1353
1686
  .requiredOption("--content <markdown>", "Markdown comment body, up to 20000 characters", parseCommentContent)
@@ -1359,10 +1692,17 @@ export async function runCli(arguments_, dependencies) {
1359
1692
  }
1360
1693
  exitCode = await run((client) => client.POST("/v1/projects/{projectId}/work-items/{workItemId}/comments", {
1361
1694
  body: { content: options.content },
1362
- params: { path: { projectId: options.projectId, workItemId: options.workItemId }, header: { "idempotency-key": options.idempotencyKey } },
1363
- }), { 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
+ });
1364
1703
  });
1365
- workItemComment.command("update")
1704
+ workItemComment
1705
+ .command("update")
1366
1706
  .requiredOption("--project-id <projectId>")
1367
1707
  .requiredOption("--work-item-id <workItemId>")
1368
1708
  .requiredOption("--comment-id <commentId>", "Identifier returned by comments", parseCommentId)
@@ -1376,11 +1716,24 @@ export async function runCli(arguments_, dependencies) {
1376
1716
  }
1377
1717
  exitCode = await run((client) => client.PATCH("/v1/projects/{projectId}/work-items/{workItemId}/comments/{commentId}", {
1378
1718
  body: { content: options.content },
1379
- params: { path: { projectId: options.projectId, workItemId: options.workItemId, commentId: options.commentId },
1380
- header: { "idempotency-key": options.idempotencyKey, "if-match": options.expectedVersion } },
1381
- }), { 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
+ });
1382
1734
  });
1383
- workItemComment.command("delete")
1735
+ workItemComment
1736
+ .command("delete")
1384
1737
  .requiredOption("--project-id <projectId>")
1385
1738
  .requiredOption("--work-item-id <workItemId>")
1386
1739
  .requiredOption("--comment-id <commentId>", "Identifier returned by comments", parseCommentId)
@@ -1392,41 +1745,93 @@ export async function runCli(arguments_, dependencies) {
1392
1745
  return;
1393
1746
  }
1394
1747
  exitCode = await run((client) => client.DELETE("/v1/projects/{projectId}/work-items/{workItemId}/comments/{commentId}", {
1395
- params: { path: { projectId: options.projectId, workItemId: options.workItemId, commentId: options.commentId },
1396
- header: { "idempotency-key": options.idempotencyKey, "if-match": options.expectedVersion } },
1397
- }), { 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
+ });
1398
1763
  });
1399
- const workItemRelation = workItem.command("relation").description("Manage subtask, blocking and related task links");
1400
- workItemRelation.command("list")
1764
+ const workItemRelation = workItem
1765
+ .command("relation")
1766
+ .description("Manage subtask, blocking and related task links");
1767
+ workItemRelation
1768
+ .command("list")
1401
1769
  .requiredOption("--project-id <projectId>")
1402
1770
  .requiredOption("--work-item-id <workItemId>")
1403
1771
  .action(async (options) => {
1404
- 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) });
1405
1775
  });
1406
- workItemRelation.command("create")
1776
+ workItemRelation
1777
+ .command("create")
1407
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")
1408
1779
  .requiredOption("--project-id <projectId>")
1409
1780
  .requiredOption("--work-item-id <workItemId>")
1410
1781
  .requiredOption("--target-project-id <projectId>", "Target task's current Project", parseProjectId)
1411
1782
  .requiredOption("--target-work-item-id <workItemId>", "Target task's public identity", parseWorkItemId)
1412
- .requiredOption("--type <type>", "subtask (source=parent, target=child), blocks or related", (value) => {
1413
- 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);
1785
+ if (!result.success)
1786
+ throw invalidArgument("Relation type must be subtask, blocks, related or duplicate");
1787
+ return result.data;
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);
1414
1793
  if (!result.success)
1415
- throw invalidArgument("Relation type must be subtask, blocks or related");
1794
+ throw invalidArgument("Invalid relation direction");
1416
1795
  return result.data;
1417
1796
  })
1797
+ .option("--replace-parent", "Replace the existing parent when linking a subtask")
1418
1798
  .requiredOption("--idempotency-key <key>", "Reuse the same key and inputs when retrying", parseRelationCommandKey)
1419
1799
  .action(async (options) => {
1420
1800
  if (hasWorkspaceReadToken(dependencies.environment)) {
1421
1801
  exitCode = rejectTokenWrite(dependencies);
1422
1802
  return;
1423
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 };
1424
1813
  exitCode = await run((client) => client.POST("/v1/projects/{projectId}/work-items/{workItemId}/relations", {
1425
- body: { targetProjectId: options.targetProjectId, targetWorkItemId: options.targetWorkItemId, relationType: options.type },
1426
- params: { path: { projectId: options.projectId, workItemId: options.workItemId }, header: { "idempotency-key": options.idempotencyKey } },
1427
- }), { 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
+ });
1428
1831
  });
1429
- workItem.command("subtask").command("link")
1832
+ workItem
1833
+ .command("subtask")
1834
+ .command("link")
1430
1835
  .description("Link parent (source) to child (target), including across Projects")
1431
1836
  .requiredOption("--project-id <projectId>", "Parent Project")
1432
1837
  .requiredOption("--parent <workItemId>", "Parent public Work Item ID", parseWorkItemId)
@@ -1438,12 +1843,24 @@ export async function runCli(arguments_, dependencies) {
1438
1843
  exitCode = rejectTokenWrite(dependencies);
1439
1844
  return;
1440
1845
  }
1441
- exitCode = await run(client => client.POST("/v1/projects/{projectId}/work-items/{workItemId}/relations", {
1442
- body: { relationType: "subtask", targetProjectId: options.childProjectId ?? options.projectId, targetWorkItemId: options.child },
1443
- params: { path: { projectId: options.projectId, workItemId: options.parent }, header: { "idempotency-key": options.idempotencyKey } },
1444
- }), { 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
+ });
1445
1861
  });
1446
- workItemRelation.command("delete")
1862
+ workItemRelation
1863
+ .command("delete")
1447
1864
  .requiredOption("--project-id <projectId>")
1448
1865
  .requiredOption("--work-item-id <workItemId>")
1449
1866
  .requiredOption("--peer-project-id <projectId>", "Other endpoint's current Project", parseProjectId)
@@ -1460,9 +1877,83 @@ export async function runCli(arguments_, dependencies) {
1460
1877
  return;
1461
1878
  }
1462
1879
  exitCode = await run((client) => client.DELETE("/v1/projects/{projectId}/work-items/{workItemId}/relations/{relationId}", {
1463
- params: { path: { projectId: options.projectId, workItemId: options.workItemId, relationId: options.relationId },
1464
- query: { peerProjectId: options.peerProjectId }, header: { "idempotency-key": options.idempotencyKey, "if-match": options.expectedVersion } },
1465
- }), { 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
+ });
1466
1957
  });
1467
1958
  workItemCompletedFlag(workItemSelectionFlags(workItem.command("list")))
1468
1959
  .requiredOption("--project-id <projectId>")
@@ -1481,16 +1972,12 @@ export async function runCli(arguments_, dependencies) {
1481
1972
  query: {
1482
1973
  ...workItemSelectionQuery(options),
1483
1974
  ...(options.completed === undefined ? {} : { completed: options.completed }),
1484
- ...(options.cursor === undefined
1485
- ? {}
1486
- : { cursor: options.cursor }),
1487
- ...(options.groupBy === undefined
1488
- ? {}
1489
- : { groupBy: options.groupBy }),
1975
+ ...(options.cursor === undefined ? {} : { cursor: options.cursor }),
1976
+ ...(options.groupBy === undefined ? {} : { groupBy: options.groupBy }),
1490
1977
  limit: options.limit,
1491
1978
  },
1492
1979
  },
1493
- }), { project: data => itemListOutput(data, outputMode, warnMissingUrl) });
1980
+ }), { project: (data) => itemListOutput(data, outputMode, warnMissingUrl) });
1494
1981
  });
1495
1982
  workItem
1496
1983
  .command("read")
@@ -1499,7 +1986,7 @@ export async function runCli(arguments_, dependencies) {
1499
1986
  .action(async (options) => {
1500
1987
  exitCode = await run((client) => client.GET("/v1/projects/{projectId}/work-items/{workItemId}", {
1501
1988
  params: { path: options },
1502
- }), { project: data => itemOutput(data, outputMode, warnMissingUrl) });
1989
+ }), { project: (data) => itemOutput(data, outputMode, warnMissingUrl) });
1503
1990
  });
1504
1991
  workItem
1505
1992
  .command("assignees")
@@ -1522,40 +2009,67 @@ export async function runCli(arguments_, dependencies) {
1522
2009
  .option("--start-date <startDate>", "ISO 8601 date", parseWorkItemDate)
1523
2010
  .option("--due-date <dueDate>", "ISO 8601 date", parseWorkItemDate)
1524
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"))
1525
2024
  .action(async (options) => {
1526
2025
  const description = (await readDescription(options)) ?? undefined;
1527
2026
  if (hasWorkspaceReadToken(dependencies.environment)) {
1528
2027
  exitCode = rejectTokenWrite(dependencies);
1529
2028
  return;
1530
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
+ };
1531
2053
  const customFields = options.customField.map(parseCustomFieldAssignment);
1532
2054
  const idempotencyKey = randomUUID();
1533
2055
  exitCode = await run((client, me) => client.POST("/v1/projects/{projectId}/work-items", {
1534
2056
  body: {
1535
- ...(options.assignee === undefined
1536
- ? {}
1537
- : { assigneeId: me ?? options.assignee }),
2057
+ ...(options.assignee === undefined ? {} : { assigneeId: me ?? options.assignee }),
1538
2058
  ...(options.customField.length === 0
1539
2059
  ? {}
1540
2060
  : {
1541
2061
  customFields,
1542
2062
  }),
1543
- ...(description === undefined
1544
- ? {}
1545
- : { description }),
2063
+ ...(description === undefined ? {} : { description }),
1546
2064
  ...(options.label.length === 0 ? {} : { labelIds: [...new Set(options.label)] }),
1547
- ...(options.dueDate === undefined
1548
- ? {}
1549
- : { dueDate: options.dueDate }),
1550
- ...(options.priority === undefined
2065
+ ...(options.initialWatcherIds === undefined
1551
2066
  ? {}
1552
- : { priority: options.priority }),
1553
- ...(options.startDate === undefined
1554
- ? {}
1555
- : { startDate: options.startDate }),
1556
- ...(options.status === undefined
1557
- ? {}
1558
- : { 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 }),
1559
2073
  title: options.title,
1560
2074
  },
1561
2075
  params: {
@@ -1564,7 +2078,7 @@ export async function runCli(arguments_, dependencies) {
1564
2078
  },
1565
2079
  }), {
1566
2080
  resolveMe: options.assignee === "me",
1567
- project: data => itemOutput(data, outputMode, warnMissingUrl),
2081
+ project: (data) => itemOutput(data, outputMode, warnMissingUrl),
1568
2082
  ambiguousOutcomeMessage: "Work Item creation outcome is unknown; list Work Items before retrying",
1569
2083
  retryTransportOnce: true,
1570
2084
  });
@@ -1623,12 +2137,8 @@ export async function runCli(arguments_, dependencies) {
1623
2137
  : options.startDate === undefined
1624
2138
  ? {}
1625
2139
  : { startDate: options.startDate }),
1626
- ...(options.priority === undefined
1627
- ? {}
1628
- : { priority: options.priority }),
1629
- ...(options.title === undefined
1630
- ? {}
1631
- : { title: options.title }),
2140
+ ...(options.priority === undefined ? {} : { priority: options.priority }),
2141
+ ...(options.title === undefined ? {} : { title: options.title }),
1632
2142
  },
1633
2143
  params: {
1634
2144
  header: {
@@ -1641,7 +2151,7 @@ export async function runCli(arguments_, dependencies) {
1641
2151
  },
1642
2152
  },
1643
2153
  }), {
1644
- project: data => itemOutput(data, outputMode, warnMissingUrl),
2154
+ project: (data) => itemOutput(data, outputMode, warnMissingUrl),
1645
2155
  ambiguousOutcomeMessage: "Work Item update outcome is unknown; read the Work Item before retrying",
1646
2156
  retryTransportOnce: true,
1647
2157
  });
@@ -1681,7 +2191,7 @@ export async function runCli(arguments_, dependencies) {
1681
2191
  },
1682
2192
  }), {
1683
2193
  resolveMe: options.assignee === "me",
1684
- project: data => itemOutput(data, outputMode, warnMissingUrl),
2194
+ project: (data) => itemOutput(data, outputMode, warnMissingUrl),
1685
2195
  ambiguousOutcomeMessage: "Work Item assignment outcome is unknown; read the Work Item before retrying",
1686
2196
  retryTransportOnce: true,
1687
2197
  });
@@ -1719,7 +2229,10 @@ export async function runCli(arguments_, dependencies) {
1719
2229
  exitCode = await run((client) => client.GET("/v1/projects/{projectId}/work-item-board", {
1720
2230
  params: {
1721
2231
  path: { projectId: options.projectId },
1722
- query: { ...workItemSelectionQuery(options), ...(options.completed === undefined ? {} : { completed: options.completed }) },
2232
+ query: {
2233
+ ...workItemSelectionQuery(options),
2234
+ ...(options.completed === undefined ? {} : { completed: options.completed }),
2235
+ },
1723
2236
  },
1724
2237
  }));
1725
2238
  });
@@ -1777,17 +2290,14 @@ export async function runCli(arguments_, dependencies) {
1777
2290
  ? {}
1778
2291
  : { dueDate: options.dueDate }
1779
2292
  : {}),
1780
- ...((options.action === "addLabel" ||
1781
- options.action === "removeLabel") &&
2293
+ ...((options.action === "addLabel" || options.action === "removeLabel") &&
1782
2294
  options.labelId !== undefined
1783
2295
  ? { labelId: options.labelId }
1784
2296
  : {}),
1785
- ...(options.action === "updatePriority" &&
1786
- options.priority !== undefined
2297
+ ...(options.action === "updatePriority" && options.priority !== undefined
1787
2298
  ? { priority: options.priority }
1788
2299
  : {}),
1789
- ...(options.action === "updateStatus" &&
1790
- options.status !== undefined
2300
+ ...(options.action === "updateStatus" && options.status !== undefined
1791
2301
  ? { status: options.status }
1792
2302
  : {}),
1793
2303
  workItems: options.target.map((target) => ({
@@ -1824,7 +2334,8 @@ export async function runCli(arguments_, dependencies) {
1824
2334
  if (body === null) {
1825
2335
  writeSkillError(dependencies, {
1826
2336
  message: "The import file must be valid task JSON within 1 MiB and 1000 tasks",
1827
- reason: "Invalid Operation", retryable: false,
2337
+ reason: "Invalid Operation",
2338
+ retryable: false,
1828
2339
  });
1829
2340
  exitCode = 2;
1830
2341
  return;
@@ -1832,7 +2343,11 @@ export async function runCli(arguments_, dependencies) {
1832
2343
  let failed = 0;
1833
2344
  exitCode = await run(async (client) => {
1834
2345
  const result = await client.POST("/v1/projects/{projectId}/work-items/import", {
1835
- 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
+ },
1836
2351
  });
1837
2352
  if (result.data !== undefined) {
1838
2353
  failed = result.data.results.failed;
@@ -1845,7 +2360,8 @@ export async function runCli(arguments_, dependencies) {
1845
2360
  if (exitCode === 0 && failed > 0) {
1846
2361
  writeSkillError(dependencies, {
1847
2362
  message: "Some tasks were refused; inspect the per-row results and import only corrected failed rows with a new key",
1848
- reason: "Invalid Operation", retryable: false,
2363
+ reason: "Invalid Operation",
2364
+ retryable: false,
1849
2365
  });
1850
2366
  exitCode = 2;
1851
2367
  }
@@ -1855,7 +2371,10 @@ export async function runCli(arguments_, dependencies) {
1855
2371
  .requiredOption("--project-id <projectId>")
1856
2372
  .action(async (options) => {
1857
2373
  exitCode = await run((client) => client.GET("/v1/projects/{projectId}/work-items/export", {
1858
- params: { path: { projectId: options.projectId }, query: workItemSelectionQuery(options) },
2374
+ params: {
2375
+ path: { projectId: options.projectId },
2376
+ query: workItemSelectionQuery(options),
2377
+ },
1859
2378
  }));
1860
2379
  });
1861
2380
  workItem
@@ -1875,7 +2394,9 @@ export async function runCli(arguments_, dependencies) {
1875
2394
  exitCode = await run((client) => client.POST("/v1/projects/{projectId}/work-items/{workItemId}/transfer", {
1876
2395
  body: {
1877
2396
  destinationProjectId: options.destinationProjectId,
1878
- ...(options.destinationStatus === undefined ? {} : { destinationStatus: options.destinationStatus }),
2397
+ ...(options.destinationStatus === undefined
2398
+ ? {}
2399
+ : { destinationStatus: options.destinationStatus }),
1879
2400
  },
1880
2401
  params: {
1881
2402
  header: { "idempotency-key": idempotencyKey, "if-match": options.expectedVersion },
@@ -1901,9 +2422,7 @@ export async function runCli(arguments_, dependencies) {
1901
2422
  const idempotencyKey = randomUUID();
1902
2423
  exitCode = await run((client) => client.POST("/v1/projects/{projectId}/work-items/{workItemId}/move", {
1903
2424
  body: {
1904
- ...(options.position === undefined
1905
- ? {}
1906
- : { position: options.position }),
2425
+ ...(options.position === undefined ? {} : { position: options.position }),
1907
2426
  status: options.status,
1908
2427
  },
1909
2428
  params: {
@@ -1921,6 +2440,34 @@ export async function runCli(arguments_, dependencies) {
1921
2440
  retryTransportOnce: true,
1922
2441
  });
1923
2442
  });
2443
+ for (const action of ["archive", "unarchive"]) {
2444
+ workItem
2445
+ .command(action)
2446
+ .requiredOption("--project-id <projectId>")
2447
+ .requiredOption("--work-item-id <workItemId>")
2448
+ .requiredOption("--expected-version <expectedVersion>", "Opaque version returned by SpecFlow", parseOpaqueVersion)
2449
+ .action(async (options) => {
2450
+ if (hasWorkspaceReadToken(dependencies.environment)) {
2451
+ exitCode = rejectTokenWrite(dependencies);
2452
+ return;
2453
+ }
2454
+ const idempotencyKey = randomUUID();
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
+ });
2469
+ });
2470
+ }
1924
2471
  workItem
1925
2472
  .command("complete")
1926
2473
  .requiredOption("--project-id <projectId>")
@@ -1934,11 +2481,13 @@ export async function runCli(arguments_, dependencies) {
1934
2481
  }
1935
2482
  const idempotencyKey = randomUUID();
1936
2483
  exitCode = await run(async (client) => {
1937
- 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
+ });
1938
2487
  if (!board.response.ok) {
1939
2488
  return board;
1940
2489
  }
1941
- const finalColumn = board.data?.workflowColumns.find((column) => column.isFinal);
2490
+ const finalColumn = board.data?.workflowColumns.find((column) => column.category === "completed");
1942
2491
  if (finalColumn === undefined) {
1943
2492
  return {
1944
2493
  error: {
@@ -1990,7 +2539,9 @@ export async function runCli(arguments_, dependencies) {
1990
2539
  .requiredOption("--project-id <projectId>")
1991
2540
  .requiredOption("--label-id <labelId>")
1992
2541
  .action(async (options) => {
1993
- 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
+ }));
1994
2545
  });
1995
2546
  workItemLabel
1996
2547
  .command("create")
@@ -2008,9 +2559,7 @@ export async function runCli(arguments_, dependencies) {
2008
2559
  body: {
2009
2560
  color: options.color,
2010
2561
  name: options.name,
2011
- ...(options.workItemId === undefined
2012
- ? {}
2013
- : { workItemId: options.workItemId }),
2562
+ ...(options.workItemId === undefined ? {} : { workItemId: options.workItemId }),
2014
2563
  },
2015
2564
  params: {
2016
2565
  header: { "idempotency-key": idempotencyKey },
@@ -2039,9 +2588,7 @@ export async function runCli(arguments_, dependencies) {
2039
2588
  const idempotencyKey = randomUUID();
2040
2589
  exitCode = await run((client) => client.PATCH("/v1/projects/{projectId}/work-item-labels/{labelId}", {
2041
2590
  body: {
2042
- ...(options.color === undefined
2043
- ? {}
2044
- : { color: options.color }),
2591
+ ...(options.color === undefined ? {} : { color: options.color }),
2045
2592
  ...(options.name === undefined ? {} : { name: options.name }),
2046
2593
  },
2047
2594
  params: {
@@ -2184,7 +2731,7 @@ export async function runCli(arguments_, dependencies) {
2184
2731
  .command("create")
2185
2732
  .requiredOption("--project-id <projectId>")
2186
2733
  .requiredOption("--name <name>")
2187
- .requiredOption("--type <type>", "text, number, date, dropdown, or boolean", parseWorkItemCustomFieldType)
2734
+ .requiredOption("--type <type>", "text, number, date, dropdown, multi-select, or boolean", parseWorkItemCustomFieldType)
2188
2735
  .option("--option <option>", "Dropdown option; repeat for every choice", collectOption, [])
2189
2736
  .option("--default-value <defaultValue>")
2190
2737
  .option("--required", "Reject Work Items that leave the field blank")
@@ -2197,17 +2744,11 @@ export async function runCli(arguments_, dependencies) {
2197
2744
  const idempotencyKey = randomUUID();
2198
2745
  exitCode = await run((client) => client.POST("/v1/projects/{projectId}/work-item-custom-fields", {
2199
2746
  body: {
2200
- ...(options.defaultValue === undefined
2201
- ? {}
2202
- : { defaultValue: options.defaultValue }),
2747
+ ...(options.defaultValue === undefined ? {} : { defaultValue: options.defaultValue }),
2203
2748
  name: options.name,
2204
2749
  ...(options.optionColors === undefined ? {} : { optionColors: options.optionColors }),
2205
- ...(options.option.length === 0
2206
- ? {}
2207
- : { options: options.option }),
2208
- ...(options.required === undefined
2209
- ? {}
2210
- : { required: options.required }),
2750
+ ...(options.option.length === 0 ? {} : { options: options.option }),
2751
+ ...(options.required === undefined ? {} : { required: options.required }),
2211
2752
  type: options.type,
2212
2753
  },
2213
2754
  params: {
@@ -2250,7 +2791,7 @@ export async function runCli(arguments_, dependencies) {
2250
2791
  workItemCustomField
2251
2792
  .command("reorder")
2252
2793
  .requiredOption("--project-id <projectId>")
2253
- .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')
2254
2795
  .action(async (options) => {
2255
2796
  if (hasWorkspaceReadToken(dependencies.environment)) {
2256
2797
  exitCode = rejectTokenWrite(dependencies);
@@ -2291,7 +2832,9 @@ export async function runCli(arguments_, dependencies) {
2291
2832
  .command("filter-values")
2292
2833
  .requiredOption("--project-id <projectId>")
2293
2834
  .action(async (options) => {
2294
- 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
+ }));
2295
2838
  });
2296
2839
  workItemCustomField
2297
2840
  .command("set")
@@ -2338,9 +2881,9 @@ export async function runCli(arguments_, dependencies) {
2338
2881
  .command("create")
2339
2882
  .requiredOption("--project-id <projectId>")
2340
2883
  .requiredOption("--name <name>")
2341
- .option("--icon <icon>", "Column icon name")
2884
+ .option("--icon <icon>", "Workflow icon", parseWorkflowIcon)
2342
2885
  .option("--color <color>", "Column color")
2343
- .option("--final", "Mark the column as an explicit completion lane")
2886
+ .option("--category <category>", "Lifecycle category", parseWorkflowCategory)
2344
2887
  .action(async (options) => {
2345
2888
  if (hasWorkspaceReadToken(dependencies.environment)) {
2346
2889
  exitCode = rejectTokenWrite(dependencies);
@@ -2349,12 +2892,8 @@ export async function runCli(arguments_, dependencies) {
2349
2892
  const idempotencyKey = randomUUID();
2350
2893
  exitCode = await run((client) => client.POST("/v1/projects/{projectId}/workflow-columns", {
2351
2894
  body: {
2352
- ...(options.color === undefined
2353
- ? {}
2354
- : { color: options.color }),
2355
- ...(options.final === undefined
2356
- ? {}
2357
- : { isFinal: options.final }),
2895
+ ...(options.color === undefined ? {} : { color: options.color }),
2896
+ ...(options.category === undefined ? {} : { category: options.category }),
2358
2897
  ...(options.icon === undefined ? {} : { icon: options.icon }),
2359
2898
  name: options.name,
2360
2899
  },
@@ -2373,12 +2912,11 @@ export async function runCli(arguments_, dependencies) {
2373
2912
  .requiredOption("--column-slug <columnSlug>")
2374
2913
  .requiredOption("--expected-version <expectedVersion>", "Opaque version returned by SpecFlow", parseOpaqueVersion)
2375
2914
  .option("--name <name>")
2376
- .option("--icon <icon>", "Column icon name")
2915
+ .option("--icon <icon>", "Workflow icon", parseWorkflowIcon)
2377
2916
  .option("--color <color>", "Column color")
2378
2917
  .option("--clear-icon", "Remove the column icon")
2379
2918
  .option("--clear-color", "Remove the column color")
2380
- .option("--final", "Mark the column as an explicit completion lane")
2381
- .option("--not-final", "Remove the column's completion marker")
2919
+ .option("--category <category>", "Lifecycle category", parseWorkflowCategory)
2382
2920
  .action(async (options) => {
2383
2921
  if (hasWorkspaceReadToken(dependencies.environment)) {
2384
2922
  exitCode = rejectTokenWrite(dependencies);
@@ -2389,8 +2927,7 @@ export async function runCli(arguments_, dependencies) {
2389
2927
  options.clearIcon !== true &&
2390
2928
  options.color === undefined &&
2391
2929
  options.clearColor !== true &&
2392
- options.final !== true &&
2393
- options.notFinal !== true) {
2930
+ options.category === undefined) {
2394
2931
  throw invalidArgument("Workflow Column update requires a field change");
2395
2932
  }
2396
2933
  if (options.clearIcon === true && options.icon !== undefined) {
@@ -2399,9 +2936,6 @@ export async function runCli(arguments_, dependencies) {
2399
2936
  if (options.clearColor === true && options.color !== undefined) {
2400
2937
  throw invalidArgument("Workflow Column update cannot set and clear the color together");
2401
2938
  }
2402
- if (options.final === true && options.notFinal === true) {
2403
- throw invalidArgument("Workflow Column update cannot set and clear the final marker together");
2404
- }
2405
2939
  const idempotencyKey = randomUUID();
2406
2940
  exitCode = await run((client) => client.PATCH("/v1/projects/{projectId}/workflow-columns/{columnSlug}", {
2407
2941
  body: {
@@ -2415,14 +2949,8 @@ export async function runCli(arguments_, dependencies) {
2415
2949
  : options.icon === undefined
2416
2950
  ? {}
2417
2951
  : { icon: options.icon }),
2418
- ...(options.final === true
2419
- ? { isFinal: true }
2420
- : options.notFinal === true
2421
- ? { isFinal: false }
2422
- : {}),
2423
- ...(options.name === undefined
2424
- ? {}
2425
- : { name: options.name }),
2952
+ ...(options.category === undefined ? {} : { category: options.category }),
2953
+ ...(options.name === undefined ? {} : { name: options.name }),
2426
2954
  },
2427
2955
  params: {
2428
2956
  header: {
@@ -2469,7 +2997,7 @@ export async function runCli(arguments_, dependencies) {
2469
2997
  workflowColumn
2470
2998
  .command("reorder")
2471
2999
  .requiredOption("--project-id <projectId>")
2472
- .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')
2473
3001
  .action(async (options) => {
2474
3002
  if (hasWorkspaceReadToken(dependencies.environment)) {
2475
3003
  exitCode = rejectTokenWrite(dependencies);
@@ -2532,7 +3060,9 @@ export async function runCli(arguments_, dependencies) {
2532
3060
  exitCode = rejectTokenWrite(dependencies);
2533
3061
  return;
2534
3062
  }
2535
- 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 } }), {
2536
3066
  ambiguousOutcomeMessage: "Workspace read-only Token revocation outcome is unknown; list tokens before retrying",
2537
3067
  retryTransportOnce: true,
2538
3068
  });
@@ -2547,7 +3077,10 @@ export async function runCli(arguments_, dependencies) {
2547
3077
  return cause.exitCode;
2548
3078
  }
2549
3079
  writeSkillError(dependencies, {
2550
- 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),
2551
3084
  code: "INVALID_CLI_INPUT",
2552
3085
  reason: "Invalid Operation",
2553
3086
  retryable: false,
@@ -2619,13 +3152,27 @@ function parseWorkItemId(value) {
2619
3152
  }
2620
3153
  throw invalidArgument("Work Item ID must be a Project ID followed by a positive number");
2621
3154
  }
2622
- const workItemPriorities = [
2623
- "no-priority",
2624
- "low",
2625
- "medium",
2626
- "high",
2627
- "urgent",
3155
+ const workflowCategories = ["backlog", "unstarted", "started", "completed", "canceled"];
3156
+ const workflowIcons = [
3157
+ "backlog",
3158
+ "todo",
3159
+ "in-progress",
3160
+ "in-review",
3161
+ "done",
3162
+ "canceled",
3163
+ "duplicate",
2628
3164
  ];
3165
+ function parseWorkflowCategory(value) {
3166
+ if (workflowCategories.includes(value))
3167
+ return value;
3168
+ throw invalidArgument("Workflow category must be backlog, unstarted, started, completed or canceled");
3169
+ }
3170
+ function parseWorkflowIcon(value) {
3171
+ if (workflowIcons.includes(value))
3172
+ return value;
3173
+ throw invalidArgument("Workflow icon must be backlog, todo, in-progress, in-review, done, canceled or duplicate");
3174
+ }
3175
+ const workItemPriorities = ["no-priority", "low", "medium", "high", "urgent"];
2629
3176
  function parseWorkItemPriority(value) {
2630
3177
  const normalized = value.trim().toLowerCase();
2631
3178
  if (workItemPriorities.includes(normalized)) {
@@ -2634,18 +3181,17 @@ function parseWorkItemPriority(value) {
2634
3181
  throw invalidArgument("Work Item priority must be no-priority, low, medium, high, or urgent");
2635
3182
  }
2636
3183
  function parseWorkItemDate(value) {
2637
- if (z.iso.date().safeParse(value).success ||
2638
- z.iso.datetime().safeParse(value).success) {
3184
+ if (z.iso.date().safeParse(value).success || z.iso.datetime().safeParse(value).success) {
2639
3185
  return value;
2640
3186
  }
2641
3187
  throw invalidArgument("Work Item dates must be an ISO 8601 date or date-time");
2642
3188
  }
2643
- const workItemDueDateFilters = [
2644
- "dueThisWeek",
2645
- "dueNextWeek",
2646
- "noDueDate",
2647
- ];
3189
+ const workItemDueDateFilters = ["dueThisWeek", "dueNextWeek", "noDueDate"];
2648
3190
  const workItemQuerySortFields = [
3191
+ "status",
3192
+ "startDate",
3193
+ "updatedAt",
3194
+ "assignee",
2649
3195
  "createdAt",
2650
3196
  "dueDate",
2651
3197
  "number",
@@ -2684,34 +3230,29 @@ function workItemSelectionQuery(options) {
2684
3230
  customFields[fieldId] = [...(customFields[fieldId] ?? []), value];
2685
3231
  }
2686
3232
  return {
2687
- ...(options.assignee.length === 0
3233
+ ...(options.creator === undefined || options.creator.length === 0
2688
3234
  ? {}
2689
- : { 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(",") }),
2690
3239
  ...(Object.keys(customFields).length === 0
2691
3240
  ? {}
2692
3241
  : { customFields: JSON.stringify(customFields) }),
2693
3242
  ...(options.due.length === 0 ? {} : { due: options.due.join(",") }),
2694
3243
  ...(options.dueAfter === undefined ? {} : { dueAfter: options.dueAfter }),
2695
- ...(options.dueBefore === undefined
2696
- ? {}
2697
- : { dueBefore: options.dueBefore }),
3244
+ ...(options.dueBefore === undefined ? {} : { dueBefore: options.dueBefore }),
2698
3245
  ...(options.label.length === 0 ? {} : { label: options.label.join(",") }),
2699
- ...(options.priority.length === 0
3246
+ ...(options.priority.length === 0 ? {} : { priority: options.priority.join(",") }),
3247
+ ...(options.repositoryConnectionId === undefined
2700
3248
  ? {}
2701
- : { priority: options.priority.join(",") }),
2702
- ...(options.repositoryConnectionId === undefined ? {} : { repositoryConnectionId: options.repositoryConnectionId }),
3249
+ : { repositoryConnectionId: options.repositoryConnectionId }),
2703
3250
  ...(options.search === undefined ? {} : { search: options.search }),
2704
3251
  ...(options.sort === undefined ? {} : { sortBy: options.sort }),
2705
3252
  ...(options.order === undefined ? {} : { sortOrder: options.order }),
2706
- ...(options.startAfter === undefined
2707
- ? {}
2708
- : { startAfter: options.startAfter }),
2709
- ...(options.startBefore === undefined
2710
- ? {}
2711
- : { startBefore: options.startBefore }),
2712
- ...(options.status.length === 0
2713
- ? {}
2714
- : { 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(",") }),
2715
3256
  };
2716
3257
  }
2717
3258
  /** List and board only: which completed Work Items to keep. */
@@ -2728,7 +3269,15 @@ function workItemCompletedFlag(command) {
2728
3269
  */
2729
3270
  function workItemSelectionFlags(command) {
2730
3271
  return command
2731
- .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, [])
2732
3281
  .option("--custom-field <fieldId=value>", "Filter by Custom Field value; repeat to OR values or combine fields", collectOption, [])
2733
3282
  .option("--due <filter>", "Filter by due bucket: dueThisWeek, dueNextWeek, or noDueDate; repeat for several", (value, previous) => [
2734
3283
  ...previous,
@@ -2737,10 +3286,7 @@ function workItemSelectionFlags(command) {
2737
3286
  .option("--due-after <date>", "Filter due on/after", parseWorkItemDate)
2738
3287
  .option("--due-before <date>", "Filter due on/before", parseWorkItemDate)
2739
3288
  .option("--label <labelId>", "Filter by Work Item Label ID; repeat for several", collectOption, [])
2740
- .option("--priority <priority>", "Filter by priority; repeat for several", (value, previous) => [
2741
- ...previous,
2742
- parseWorkItemPriority(value),
2743
- ], [])
3289
+ .option("--priority <priority>", "Filter by priority; repeat for several", (value, previous) => [...previous, parseWorkItemPriority(value)], [])
2744
3290
  .option("--repository-connection-id <id>", "Filter by an explicit GitHub repository connection")
2745
3291
  .option("--search <search>", "Filter by title search text")
2746
3292
  .option("--sort <field>", "Sort by field", parseWorkItemSortField)
@@ -2773,20 +3319,21 @@ function parseWorkItemBulkTarget(value, previous) {
2773
3319
  throw invalidArgument(`Bulk target "${value}" must be a WORK-ITEM-ID@version pair`);
2774
3320
  }
2775
3321
  const numericVersion = Number(version);
2776
- if (!Number.isSafeInteger(numericVersion) ||
2777
- numericVersion > 2_147_483_647) {
3322
+ if (!Number.isSafeInteger(numericVersion) || numericVersion > 2_147_483_647) {
2778
3323
  throw invalidArgument(`Bulk target "${value}" has a version outside the supported range`);
2779
3324
  }
2780
3325
  return [
2781
3326
  ...previous,
2782
- { expectedVersion: `"${version}"`, id: id.trim().toUpperCase(), ...(projectId === undefined ? {} : { projectId }) },
3327
+ {
3328
+ expectedVersion: `"${version}"`,
3329
+ id: id.trim().toUpperCase(),
3330
+ ...(projectId === undefined ? {} : { projectId }),
3331
+ },
2783
3332
  ];
2784
3333
  }
2785
3334
  function parseBoardPosition(value) {
2786
3335
  const position = Number(value);
2787
- if (!Number.isInteger(position) ||
2788
- position < 0 ||
2789
- position > 2_147_483_646) {
3336
+ if (!Number.isInteger(position) || position < 0 || position > 2_147_483_646) {
2790
3337
  throw invalidArgument("Board position must be a nonnegative integer within the supported range");
2791
3338
  }
2792
3339
  return position;
@@ -2825,6 +3372,7 @@ const workItemCustomFieldTypes = [
2825
3372
  "text",
2826
3373
  "number",
2827
3374
  "date",
3375
+ "multi-select",
2828
3376
  "dropdown",
2829
3377
  "boolean",
2830
3378
  ];
@@ -2833,7 +3381,7 @@ function parseWorkItemCustomFieldType(value) {
2833
3381
  if (workItemCustomFieldTypes.includes(normalized)) {
2834
3382
  return normalized;
2835
3383
  }
2836
- 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");
2837
3385
  }
2838
3386
  function collectOption(value, previous) {
2839
3387
  return [...previous, value];
@@ -2956,9 +3504,7 @@ function parseStringArray(value, label) {
2956
3504
  }
2957
3505
  function toAgentProvenance(options) {
2958
3506
  return {
2959
- ...(options.agentRevision === undefined
2960
- ? {}
2961
- : { agentRevision: options.agentRevision }),
3507
+ ...(options.agentRevision === undefined ? {} : { agentRevision: options.agentRevision }),
2962
3508
  ...(options.agentModel === undefined ? {} : { model: options.agentModel }),
2963
3509
  sourceReferenceIds: options.sourceReferenceIds === undefined
2964
3510
  ? []
@@ -3006,9 +3552,7 @@ function parseFindingInput(value) {
3006
3552
  return finding.data;
3007
3553
  }
3008
3554
  function withSuccessData(result, data) {
3009
- return result.response.ok && result.data === undefined
3010
- ? { ...result, data }
3011
- : result;
3555
+ return result.response.ok && result.data === undefined ? { ...result, data } : result;
3012
3556
  }
3013
3557
  /**
3014
3558
  * Whether a `work-item-label delete` payload is the still-running cascade —
@@ -3021,10 +3565,8 @@ function isWorkItemLabelDeletionPending(data) {
3021
3565
  const label = data.workItemLabel;
3022
3566
  return (typeof label === "object" &&
3023
3567
  label !== null &&
3024
- label.deletionStartedAt !==
3025
- null &&
3026
- label.deletionStartedAt !==
3027
- undefined);
3568
+ label.deletionStartedAt !== null &&
3569
+ label.deletionStartedAt !== undefined);
3028
3570
  }
3029
3571
  function rejectTokenWrite(dependencies) {
3030
3572
  if (hasWorkspaceReadToken(dependencies.environment)) {
@@ -3043,7 +3585,13 @@ function rejectTokenWrite(dependencies) {
3043
3585
  return 2;
3044
3586
  }
3045
3587
  function parseCommentContent(value) {
3046
- 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);
3047
3595
  if (!result.success)
3048
3596
  throw invalidArgument("Comment content must contain 1 through 20000 characters without null characters");
3049
3597
  return result.data;
@@ -3084,11 +3632,47 @@ function parseNotificationPreferences(value) {
3084
3632
  catch {
3085
3633
  throw invalidArgument("Notification preferences must be a JSON object");
3086
3634
  }
3087
- 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);
3088
3645
  if (!result.success)
3089
3646
  throw invalidArgument("Notification preferences contain unsupported settings or invalid values");
3090
3647
  const data = result.data;
3091
- 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
+ };
3092
3665
  }
3093
- 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
+ ]);
3094
3678
  //# sourceMappingURL=cli.js.map