jiradc-cli 1.0.20 → 2.0.0-ga26d641.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/README.md +13 -6
  2. package/dist/index.js +519 -263
  3. package/package.json +6 -5
package/README.md CHANGED
@@ -37,14 +37,17 @@ All commands output JSON. Add `--pretty` to pretty-print.
37
37
  | `jiradc issue assign <key> <user>` | Assign issue (user can be a username, `me`, or `none` to unassign) |
38
38
  | `jiradc issue transition <key>` | Transition issue to a new status (`--to` accepts ID or status name, `--comment` to add a note) |
39
39
  | `jiradc issue transitions <key>` | List available transitions |
40
- | `jiradc issue comment <key>` | Add a comment |
41
- | `jiradc issue comment-edit <key> <commentId>` | Edit a comment |
40
+ | `jiradc issue comment add <key>` | Add a comment (`--body`) |
41
+ | `jiradc issue comment edit <key>` | Edit a comment (`--id`, `--body`) |
42
+ | `jiradc issue comment delete <key>` | Delete a comment (`--id`) |
42
43
  | `jiradc issue link <key> <targetKey>` | Link two issues (`--type` link type name) |
43
44
  | `jiradc issue unlink <linkId>` | Remove a link |
44
45
  | `jiradc issue link-types` | List available link types |
45
46
  | `jiradc issue link-epic <keys...>` | Link one or more issues to an epic (`--epic <epicKey>`) |
46
- | `jiradc issue worklog <key>` | Add a work log entry |
47
- | `jiradc issue get-worklog <key>` | Get work log entries |
47
+ | `jiradc issue worklog add <key>` | Add a work log entry (`--time`, `--comment`, `--started`) |
48
+ | `jiradc issue worklog list <key>` | Get work log entries |
49
+ | `jiradc issue worklog edit <key>` | Update a work log entry (`--id`, `--time`, `--comment`, `--started`, `--adjust-estimate`, `--new-estimate`) |
50
+ | `jiradc issue worklog delete <key>` | Delete a work log entry (`--id`, `--adjust-estimate`, `--new-estimate`, `--increase-by`) |
48
51
  | `jiradc issue changelog <key>` | Get issue changelog |
49
52
  | `jiradc issue batch-changelog` | Get changelog for multiple issues (`--keys`) |
50
53
  | `jiradc issue clone <key>` | Clone an issue with subtasks |
@@ -93,6 +96,7 @@ All commands output JSON. Add `--pretty` to pretty-print.
93
96
  | `jiradc sprint issues <boardId> <sprintId>` | Get issues in a sprint |
94
97
  | `jiradc sprint create <boardId>` | Create a sprint |
95
98
  | `jiradc sprint update <sprintId>` | Update a sprint |
99
+ | `jiradc sprint delete <sprintId>` | Delete a sprint (returns its issues to the backlog) |
96
100
 
97
101
  ### field
98
102
 
@@ -151,13 +155,16 @@ jiradc issue update AI-123 --fix-versions 1.0,2.0
151
155
  jiradc issue link-epic AI-456 AI-457 AI-458 --epic AI-100
152
156
 
153
157
  # Add a comment
154
- jiradc issue comment AI-123 --body "Fixed in commit abc123"
158
+ jiradc issue comment add AI-123 --body "Fixed in commit abc123"
159
+
160
+ # Delete a comment
161
+ jiradc issue comment delete AI-123 --id 12345
155
162
 
156
163
  # Link two issues
157
164
  jiradc issue link AI-123 AI-456 --type "blocks"
158
165
 
159
166
  # Log work
160
- jiradc issue worklog AI-123 --time "2h 30m" --comment "Code review"
167
+ jiradc issue worklog add AI-123 --time "2h 30m" --comment "Code review"
161
168
 
162
169
  # List active sprints
163
170
  jiradc sprint list 42 --state active
package/dist/index.js CHANGED
@@ -1,16 +1,25 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- // src/index.ts
4
- import { readFileSync } from "fs";
5
- import { dirname, join as join4 } from "path";
6
- import { fileURLToPath } from "url";
7
- import { styleText } from "util";
8
- import { Command as Command8 } from "commander";
3
+ // ../../cli-utils/dist/cache.js
4
+ import { readFileSync, writeFileSync, mkdirSync, statSync } from "fs";
5
+ import { homedir } from "os";
6
+ import { join } from "path";
9
7
 
10
- // src/commands/board/issues.ts
11
- import { Argument } from "commander";
8
+ // ../../cli-utils/dist/bootstrap.js
9
+ import { readFileSync as readFileSync2 } from "fs";
10
+ import { dirname, join as join2 } from "path";
11
+ import { fileURLToPath } from "url";
12
+ function readPackageVersion(importMetaUrl) {
13
+ try {
14
+ const here = dirname(fileURLToPath(importMetaUrl));
15
+ const pkg = JSON.parse(readFileSync2(join2(here, "..", "package.json"), "utf-8"));
16
+ return pkg.version ?? "0.0.0";
17
+ } catch {
18
+ return "0.0.0";
19
+ }
20
+ }
12
21
 
13
- // src/utils/cli.ts
22
+ // ../../cli-utils/dist/validators.js
14
23
  import { InvalidArgumentError } from "commander";
15
24
  function intInRange(min, max) {
16
25
  return (raw) => {
@@ -39,6 +48,236 @@ function positiveInt(raw) {
39
48
  return n;
40
49
  }
41
50
 
51
+ // ../../cli-utils/dist/registry.js
52
+ var SUB_ENTITY_ID_NUMERIC = {
53
+ comment: true,
54
+ worklog: true,
55
+ attachment: true,
56
+ request: true,
57
+ type: true,
58
+ employee: true,
59
+ message: false,
60
+ membership: false
61
+ };
62
+
63
+ // ../../cli-utils/dist/builders.js
64
+ function defineOption(cmd, flags, description, parser, mandatory) {
65
+ if (mandatory) {
66
+ return parser ? cmd.requiredOption(flags, description, parser) : cmd.requiredOption(flags, description);
67
+ }
68
+ return parser ? cmd.option(flags, description, parser) : cmd.option(flags, description);
69
+ }
70
+ function subjectArg(cmd, name, opts = {}) {
71
+ const inner = opts.variadic ? `${name}...` : name;
72
+ const token = opts.optional ? `[${inner}]` : `<${inner}>`;
73
+ return opts.parser ? cmd.argument(token, opts.description ?? "", opts.parser) : cmd.argument(token, opts.description ?? "");
74
+ }
75
+ function subEntityOption(cmd, entity, opts = {}) {
76
+ const numeric = opts.numeric ?? SUB_ENTITY_ID_NUMERIC[entity] ?? true;
77
+ const description = `${entity.charAt(0).toUpperCase()}${entity.slice(1)} id`;
78
+ return defineOption(cmd, `--${entity}-id <id>`, description, numeric ? positiveInt : void 0, opts.mandatory);
79
+ }
80
+ function bodyOption(cmd, opts = {}) {
81
+ return defineOption(cmd, "--body <text>", "Prose body content", void 0, opts.mandatory);
82
+ }
83
+
84
+ // ../../cli-utils/dist/errors.js
85
+ import { CommanderError } from "commander";
86
+ var EXIT = {
87
+ SUCCESS: 0,
88
+ GENERIC: 1,
89
+ USAGE: 2,
90
+ NOT_FOUND: 3,
91
+ FORBIDDEN: 4,
92
+ CONFLICT: 5,
93
+ AUTH: 6
94
+ };
95
+ var TYPE_EXIT = {
96
+ usage: EXIT.USAGE,
97
+ not_found: EXIT.NOT_FOUND,
98
+ forbidden: EXIT.FORBIDDEN,
99
+ conflict: EXIT.CONFLICT,
100
+ auth: EXIT.AUTH,
101
+ rate_limited: EXIT.GENERIC,
102
+ server: EXIT.GENERIC,
103
+ network: EXIT.GENERIC,
104
+ unknown: EXIT.GENERIC
105
+ };
106
+ var NETWORK_CODES = ["ENOTFOUND", "ECONNREFUSED", "ECONNRESET", "ETIMEDOUT"];
107
+ function httpStatus(err) {
108
+ const e = err;
109
+ return e?.response?.status ?? e?.statusCode;
110
+ }
111
+ function responseDetail(err) {
112
+ const e = err;
113
+ const data = e?.response?.data;
114
+ if (data && typeof data === "object")
115
+ return data;
116
+ const body = e?.body;
117
+ if (typeof body === "string") {
118
+ try {
119
+ const parsed = JSON.parse(body);
120
+ return parsed.error ?? parsed;
121
+ } catch {
122
+ return void 0;
123
+ }
124
+ }
125
+ if (body && typeof body === "object") {
126
+ return body.error ?? body;
127
+ }
128
+ return void 0;
129
+ }
130
+ function errorCode(err) {
131
+ return err?.code;
132
+ }
133
+ function normalize(err, opts) {
134
+ const message = err instanceof Error ? err.message : String(err);
135
+ if (err instanceof CommanderError) {
136
+ return {
137
+ type: "usage",
138
+ message: message || "Invalid command usage",
139
+ recovery: "Check the command syntax and flags; run the command with --help.",
140
+ retryable: false
141
+ };
142
+ }
143
+ const status = httpStatus(err);
144
+ const detail = responseDetail(err);
145
+ if (status !== void 0) {
146
+ switch (status) {
147
+ case 400:
148
+ return {
149
+ type: "usage",
150
+ status,
151
+ message: "Bad request (HTTP 400)",
152
+ recovery: "Check parameter values (ids, keys, query syntax) against the API.",
153
+ retryable: false,
154
+ detail
155
+ };
156
+ case 401:
157
+ return {
158
+ type: "auth",
159
+ status,
160
+ message: "Authentication failed (HTTP 401)",
161
+ recovery: opts.authRecovery,
162
+ retryable: false
163
+ };
164
+ case 403:
165
+ return {
166
+ type: "forbidden",
167
+ status,
168
+ message: "Forbidden (HTTP 403)",
169
+ recovery: `Your ${opts.service} account lacks permission for this operation; check token scope and resource permissions.`,
170
+ retryable: false,
171
+ detail
172
+ };
173
+ case 404:
174
+ return {
175
+ type: "not_found",
176
+ status,
177
+ message: "Not found (HTTP 404)",
178
+ recovery: "Verify the id/key exists and that you have access to it.",
179
+ retryable: false,
180
+ detail
181
+ };
182
+ case 409:
183
+ return {
184
+ type: "conflict",
185
+ status,
186
+ message: "Conflict (HTTP 409)",
187
+ recovery: "The resource changed or already exists; re-fetch current state and retry.",
188
+ retryable: false,
189
+ detail
190
+ };
191
+ case 429:
192
+ return {
193
+ type: "rate_limited",
194
+ status,
195
+ message: "Rate limited (HTTP 429)",
196
+ recovery: "Wait and retry the request.",
197
+ retryable: true
198
+ };
199
+ }
200
+ if (status >= 500) {
201
+ return {
202
+ type: "server",
203
+ status,
204
+ message: `Server error (HTTP ${status})`,
205
+ recovery: `${opts.service} returned an internal error; retry shortly.`,
206
+ retryable: true,
207
+ detail
208
+ };
209
+ }
210
+ return {
211
+ type: "unknown",
212
+ status,
213
+ message: `${opts.service} error (HTTP ${status}): ${message}`,
214
+ recovery: "Inspect the detail field for the API response.",
215
+ retryable: false,
216
+ detail
217
+ };
218
+ }
219
+ const code = errorCode(err);
220
+ if (code && NETWORK_CODES.includes(code) || NETWORK_CODES.some((c) => message.includes(c))) {
221
+ return {
222
+ type: "network",
223
+ message: `Cannot connect to ${opts.service}: ${message}`,
224
+ recovery: opts.networkRecovery ?? "Verify the *_URL is correct, the server is reachable, and you are on the VPN if required.",
225
+ retryable: true
226
+ };
227
+ }
228
+ return { type: "unknown", message, recovery: "Unexpected error; inspect the message.", retryable: false };
229
+ }
230
+ function classifyError(err, opts) {
231
+ const base = normalize(err, opts);
232
+ const n = opts.adapt ? opts.adapt(base, err) : base;
233
+ return {
234
+ envelope: {
235
+ error: {
236
+ type: n.type,
237
+ message: n.message,
238
+ recovery: n.recovery,
239
+ retryable: n.retryable,
240
+ ...n.detail !== void 0 ? { detail: n.detail } : {}
241
+ }
242
+ },
243
+ exitCode: TYPE_EXIT[n.type]
244
+ };
245
+ }
246
+ function createErrorHandler(opts) {
247
+ return (err) => {
248
+ const { envelope, exitCode } = classifyError(err, opts);
249
+ process.stderr.write(`${JSON.stringify(envelope)}
250
+ `);
251
+ return process.exit(exitCode);
252
+ };
253
+ }
254
+ function isCleanCommanderExit(err) {
255
+ return err instanceof CommanderError && (err.exitCode === 0 || err.code === "commander.helpDisplayed" || err.code === "commander.help" || err.code === "commander.version");
256
+ }
257
+ function routeErrors(cmd) {
258
+ cmd.exitOverride();
259
+ cmd.configureOutput({ writeErr: () => void 0 });
260
+ cmd.commands.forEach(routeErrors);
261
+ }
262
+ async function runCli(program, opts) {
263
+ routeErrors(program);
264
+ try {
265
+ await program.parseAsync();
266
+ } catch (err) {
267
+ if (isCleanCommanderExit(err)) {
268
+ process.exit(err.exitCode ?? 0);
269
+ }
270
+ createErrorHandler(opts)(err);
271
+ }
272
+ }
273
+
274
+ // src/program.ts
275
+ import { styleText } from "util";
276
+ import { Command as Command11 } from "commander";
277
+
278
+ // src/commands/board/issues.ts
279
+ import { Argument } from "commander";
280
+
42
281
  // src/utils/client.ts
43
282
  import { JiraClient } from "jira-data-center-client";
44
283
 
@@ -89,68 +328,6 @@ function output(data) {
89
328
  process.stdout.write(`${JSON.stringify(data, null, prettyPrint ? 2 : void 0)}
90
329
  `);
91
330
  }
92
- function handleError(err) {
93
- const message = err instanceof Error ? err.message : String(err);
94
- const axiosStatus = err?.response?.status;
95
- if (axiosStatus === 400) {
96
- const responseData = err?.response?.data;
97
- const jiraErrors = responseData && typeof responseData === "object" ? responseData : void 0;
98
- process.stderr.write(
99
- `${JSON.stringify({
100
- error: `Bad request (HTTP 400)`,
101
- detail: jiraErrors ?? message,
102
- hint: "Check that all parameters are valid (JQL syntax, field names, project keys, etc.)."
103
- })}
104
- `
105
- );
106
- } else if (axiosStatus === 401) {
107
- process.stderr.write(
108
- `${JSON.stringify({
109
- error: "Authentication failed (HTTP 401)",
110
- ...getCredentialInfo()
111
- })}
112
- `
113
- );
114
- } else if (axiosStatus === 403) {
115
- const responseData = err?.response?.data;
116
- process.stderr.write(
117
- `${JSON.stringify({
118
- error: "Forbidden (HTTP 403)",
119
- detail: responseData && typeof responseData === "object" ? responseData : message,
120
- hint: "Your account does not have permission for this operation. Check project permissions and token scope."
121
- })}
122
- `
123
- );
124
- } else if (message.includes("ENOTFOUND") || message.includes("ECONNREFUSED") || message.includes("ECONNRESET")) {
125
- process.stderr.write(
126
- `${JSON.stringify({
127
- error: `Cannot connect to Jira server: ${message}`,
128
- hint: "Verify that JIRA_URL is correct and the server is reachable."
129
- })}
130
- `
131
- );
132
- } else if (axiosStatus === 500) {
133
- process.stderr.write(
134
- `${JSON.stringify({
135
- error: `Server error (HTTP 500): ${message}`,
136
- hint: "The server returned an internal error. Check that all parameters are valid (project keys, issue keys, JQL query syntax)."
137
- })}
138
- `
139
- );
140
- } else {
141
- const responseData = err?.response?.data;
142
- const detail = responseData && typeof responseData === "object" ? responseData : void 0;
143
- process.stderr.write(
144
- `${JSON.stringify({
145
- error: message,
146
- ...axiosStatus !== void 0 && { statusCode: axiosStatus },
147
- ...detail && { detail }
148
- })}
149
- `
150
- );
151
- }
152
- process.exit(1);
153
- }
154
331
 
155
332
  // src/utils/transformers/base.ts
156
333
  function jiraBaseUrl() {
@@ -379,8 +556,8 @@ function transformIssueFields(fields) {
379
556
  issuelinks,
380
557
  subtasks,
381
558
  parent,
382
- comment: comment2,
383
- worklog: worklog2,
559
+ comment,
560
+ worklog,
384
561
  attachment,
385
562
  // required scalars / structured fields we always keep verbatim
386
563
  summary,
@@ -412,20 +589,20 @@ function transformIssueFields(fields) {
412
589
  // Drop empty comment / worklog containers entirely. The default Jira
413
590
  // search response includes both wrappers on every issue regardless of
414
591
  // count; on a 25-issue page that's 25 × 2 empty objects of pure noise.
415
- ...comment2 && comment2.comments.length > 0 ? {
592
+ ...comment && comment.comments.length > 0 ? {
416
593
  comment: {
417
- comments: comment2.comments.map(transformComment),
418
- maxResults: comment2.maxResults,
419
- total: comment2.total,
420
- startAt: comment2.startAt
594
+ comments: comment.comments.map(transformComment),
595
+ maxResults: comment.maxResults,
596
+ total: comment.total,
597
+ startAt: comment.startAt
421
598
  }
422
599
  } : {},
423
- ...worklog2 && worklog2.worklogs.length > 0 ? {
600
+ ...worklog && worklog.worklogs.length > 0 ? {
424
601
  worklog: {
425
- worklogs: worklog2.worklogs.map(transformWorklog),
426
- maxResults: worklog2.maxResults,
427
- total: worklog2.total,
428
- startAt: worklog2.startAt
602
+ worklogs: worklog.worklogs.map(transformWorklog),
603
+ maxResults: worklog.maxResults,
604
+ total: worklog.total,
605
+ startAt: worklog.startAt
429
606
  }
430
607
  } : {},
431
608
  ...attachment && attachment.length > 0 ? { attachment: attachment.map(transformAttachment) } : {}
@@ -513,8 +690,8 @@ function list(parent) {
513
690
  }
514
691
 
515
692
  // src/commands/board/index.ts
516
- function registerBoardCommands(program2) {
517
- const board = program2.command("board").description("Board operations").addHelpText(
693
+ function registerBoardCommands(program) {
694
+ const board = program.command("board").description("Board operations").addHelpText(
518
695
  "after",
519
696
  `
520
697
  Examples:
@@ -635,8 +812,8 @@ Examples:
635
812
  }
636
813
 
637
814
  // src/commands/component/index.ts
638
- function registerComponentCommands(program2) {
639
- const component = program2.command("component").description("Project component operations").addHelpText(
815
+ function registerComponentCommands(program) {
816
+ const component = program.command("component").description("Project component operations").addHelpText(
640
817
  "after",
641
818
  `
642
819
  Examples:
@@ -658,16 +835,16 @@ Examples:
658
835
 
659
836
  // src/commands/field/options.ts
660
837
  function options(parent) {
661
- parent.command("options <id>").description("Get available options for a custom field").option("--query <text>", "Filter options by text").option("--limit <number>", "Max results to return (1-1000)", intInRange(1, 1e3), 25).option("--page <number>", "Page number (1-indexed)", positiveInt).addHelpText(
838
+ parent.command("options <id>").description("Get available options for a custom field").option("--query <text>", "Filter options by text").option("--limit <number>", "Max results to return (1-1000)", intInRange(1, 1e3), 25).option("--start <number>", "Page number (1-indexed)", positiveInt).addHelpText(
662
839
  "after",
663
- '\nExamples:\n jiradc field options 10001\n jiradc field options 10001 --query "High"\n jiradc field options 10001 --limit 20 --page 2'
840
+ '\nExamples:\n jiradc field options 10001\n jiradc field options 10001 --query "High"\n jiradc field options 10001 --limit 20 --start 2'
664
841
  ).action(async (id, opts) => {
665
842
  const client = getClient();
666
843
  const result = await client.fields.getFieldOptions({
667
844
  fieldId: id,
668
845
  query: opts.query,
669
846
  maxResults: opts.limit,
670
- page: opts.page
847
+ page: opts.start
671
848
  });
672
849
  output(transformPaged({ ...result, startAt: result.startAt ?? 0 }, transformCustomFieldOption));
673
850
  });
@@ -686,8 +863,8 @@ function search(parent) {
686
863
  }
687
864
 
688
865
  // src/commands/field/index.ts
689
- function registerFieldCommands(program2) {
690
- const field = program2.command("field").description("Field operations").addHelpText(
866
+ function registerFieldCommands(program) {
867
+ const field = program.command("field").description("Field operations").addHelpText(
691
868
  "after",
692
869
  `
693
870
  Examples:
@@ -718,15 +895,15 @@ async function resolveUserToken(token) {
718
895
 
719
896
  // src/commands/issue/assign.ts
720
897
  function assign(parent) {
721
- parent.command("assign <key> <user>").description('Assign an issue. <user> is a username, "me", or "none" to unassign.').addHelpText(
898
+ parent.command("assign <key>").description('Assign an issue. --assignee is a username, "me", or "none" to unassign.').requiredOption("--assignee <user>", 'Username to assign, "me" for the current user, or "none" to unassign').addHelpText(
722
899
  "after",
723
900
  `
724
901
  Examples:
725
- jiradc issue assign PROJ-123 jsmith
726
- jiradc issue assign PROJ-123 me
727
- jiradc issue assign PROJ-123 none`
728
- ).action(async (key, user) => {
729
- const resolved = await resolveUserToken(user);
902
+ jiradc issue assign PROJ-123 --assignee jsmith
903
+ jiradc issue assign PROJ-123 --assignee me
904
+ jiradc issue assign PROJ-123 --assignee none`
905
+ ).action(async (key, opts) => {
906
+ const resolved = await resolveUserToken(opts.assignee);
730
907
  const client = getClient();
731
908
  await client.issues.update({
732
909
  issueKeyOrId: key,
@@ -738,20 +915,22 @@ Examples:
738
915
 
739
916
  // src/commands/issue/attachment/delete.ts
740
917
  function deleteAttachment(parent) {
741
- parent.command("delete").description("Delete an attachment by ID").requiredOption("--id <attachmentId>", "Attachment ID to delete").addHelpText("after", "\nExamples:\n jiradc issue attachment delete --id 12345").action(async (opts) => {
918
+ const cmd = parent.command("delete <key>").description("Delete an attachment by ID");
919
+ subEntityOption(cmd, "attachment", { mandatory: true });
920
+ cmd.addHelpText("after", "\nExamples:\n jiradc issue attachment delete PROJ-123 --attachment-id 12345").action(async (key, opts) => {
742
921
  const client = getClient();
743
- await client.issues.deleteAttachment({ attachmentId: opts.id });
744
- output({ deleted: true, attachmentId: opts.id });
922
+ await client.issues.deleteAttachment({ attachmentId: String(opts.attachmentId) });
923
+ output({ deleted: true, issueKey: key, attachmentId: opts.attachmentId });
745
924
  });
746
925
  }
747
926
 
748
927
  // src/commands/issue/attachment/download-all.ts
749
- import { mkdirSync } from "fs";
750
- import { join } from "path";
928
+ import { mkdirSync as mkdirSync2 } from "fs";
929
+ import { join as join3 } from "path";
751
930
  function downloadAll(parent) {
752
931
  parent.command("download-all <key>").description("Download all attachments from an issue").requiredOption("--output <dir>", "Local directory to save attachments into").addHelpText("after", "\nExamples:\n jiradc issue attachment download-all PROJ-123 --output ./downloads").action(async (key, opts) => {
753
932
  const client = getClient();
754
- mkdirSync(opts.output, { recursive: true });
933
+ mkdirSync2(opts.output, { recursive: true });
755
934
  const issue = await client.issues.get({
756
935
  issueKeyOrId: key,
757
936
  fields: ["attachment"]
@@ -768,7 +947,7 @@ function downloadAll(parent) {
768
947
  failed.push({ filename: att.filename, error: "No content URL" });
769
948
  continue;
770
949
  }
771
- const destPath = join(opts.output, att.filename);
950
+ const destPath = join3(opts.output, att.filename);
772
951
  try {
773
952
  await client.issues.downloadAttachment({ url: att.content, destinationPath: destPath });
774
953
  results.push({ filename: att.filename, size: att.size, path: destPath });
@@ -788,11 +967,17 @@ function downloadAll(parent) {
788
967
 
789
968
  // src/commands/issue/attachment/download.ts
790
969
  function download(parent) {
791
- parent.command("download <key>").description("Download a single attachment by ID").requiredOption("--id <attachmentId>", "Attachment ID").requiredOption("--output <path>", "Local file path to save the attachment").addHelpText("after", "\nExamples:\n jiradc issue attachment download PROJ-123 --id 12345 --output ./report.pdf").action(async (key, opts) => {
970
+ const cmd = parent.command("download <key>").description("Download a single attachment by ID");
971
+ subEntityOption(cmd, "attachment", { mandatory: true });
972
+ cmd.requiredOption("--output <path>", "Local file path to save the attachment").addHelpText(
973
+ "after",
974
+ "\nExamples:\n jiradc issue attachment download PROJ-123 --attachment-id 12345 --output ./report.pdf"
975
+ ).action(async (key, opts) => {
792
976
  const client = getClient();
793
- const attachment = await client.issues.getAttachment({ attachmentId: opts.id });
977
+ const attachmentId = String(opts.attachmentId);
978
+ const attachment = await client.issues.getAttachment({ attachmentId });
794
979
  if (!attachment.content) {
795
- throw new Error(`Attachment ${opts.id} has no content URL`);
980
+ throw new Error(`Attachment ${attachmentId} has no content URL`);
796
981
  }
797
982
  await client.issues.downloadAttachment({
798
983
  url: attachment.content,
@@ -841,8 +1026,8 @@ function upload(parent) {
841
1026
  const filePaths = opts.files.split(",").map((f) => f.trim());
842
1027
  const results = [];
843
1028
  for (const filePath of filePaths) {
844
- const attachments2 = await client.issues.addAttachment({ issueKeyOrId: key, filePath });
845
- results.push(...attachments2);
1029
+ const attachments = await client.issues.addAttachment({ issueKeyOrId: key, filePath });
1030
+ results.push(...attachments);
846
1031
  }
847
1032
  output({
848
1033
  issueKey: key,
@@ -866,9 +1051,9 @@ function registerAttachmentCommands(parent) {
866
1051
  Examples:
867
1052
  $ jiradc issue attachment list PROJ-123
868
1053
  $ jiradc issue attachment upload PROJ-123 --files ./report.pdf
869
- $ jiradc issue attachment download PROJ-123 --id 12345 --output ./report.pdf
1054
+ $ jiradc issue attachment download PROJ-123 --attachment-id 12345 --output ./report.pdf
870
1055
  $ jiradc issue attachment download-all PROJ-123 --output ./downloads
871
- $ jiradc issue attachment delete --id 12345
1056
+ $ jiradc issue attachment delete PROJ-123 --attachment-id 12345
872
1057
  `
873
1058
  );
874
1059
  upload(attachment);
@@ -878,47 +1063,6 @@ Examples:
878
1063
  deleteAttachment(attachment);
879
1064
  }
880
1065
 
881
- // src/commands/issue/attachments.ts
882
- import { mkdirSync as mkdirSync2 } from "fs";
883
- import { join as join2 } from "path";
884
- function attachments(parent) {
885
- parent.command("attachments <key>").description("Download all attachments from an issue").requiredOption("--output <dir>", "Local directory to save attachments into").addHelpText("after", "\nExamples:\n jiradc issue attachments PROJ-123 --output ./downloads").action(async (key, opts) => {
886
- const client = getClient();
887
- mkdirSync2(opts.output, { recursive: true });
888
- const issue = await client.issues.get({
889
- issueKeyOrId: key,
890
- fields: ["attachment"]
891
- });
892
- const atts = issue.fields.attachment ?? [];
893
- if (atts.length === 0) {
894
- output({ issueKey: key, downloaded: 0, files: [] });
895
- return;
896
- }
897
- const results = [];
898
- const failed = [];
899
- for (const att of atts) {
900
- if (!att.content) {
901
- failed.push({ filename: att.filename, error: "No content URL" });
902
- continue;
903
- }
904
- const destPath = join2(opts.output, att.filename);
905
- try {
906
- await client.issues.downloadAttachment({ url: att.content, destinationPath: destPath });
907
- results.push({ filename: att.filename, size: att.size, path: destPath });
908
- } catch (err) {
909
- failed.push({ filename: att.filename, error: String(err) });
910
- }
911
- }
912
- output({
913
- issueKey: key,
914
- downloaded: results.length,
915
- total: atts.length,
916
- files: results,
917
- ...failed.length > 0 && { failed }
918
- });
919
- });
920
- }
921
-
922
1066
  // src/commands/issue/batch-changelog.ts
923
1067
  function batchChangelog(parent) {
924
1068
  parent.command("batch-changelog <keys>").description("Get changelogs for multiple issues at once").option("--limit <number>", "Max changelog entries per issue (1-50, Jira DC caps at 50)", intInRange(1, 50), 25).addHelpText(
@@ -979,7 +1123,7 @@ function changelog(parent) {
979
1123
  // src/commands/issue/clone.ts
980
1124
  import { unlink } from "fs/promises";
981
1125
  import { tmpdir } from "os";
982
- import { join as join3 } from "path";
1126
+ import { join as join4 } from "path";
983
1127
  var CLONE_FIELDS = [
984
1128
  "summary",
985
1129
  "description",
@@ -1030,7 +1174,7 @@ Examples:
1030
1174
  const tmpFiles = [];
1031
1175
  const copied = await Promise.all(
1032
1176
  f.attachment.map(async (att) => {
1033
- const tmpPath = join3(tmpdir(), `jiradc-clone-${Date.now()}-${att.filename}`);
1177
+ const tmpPath = join4(tmpdir(), `jiradc-clone-${Date.now()}-${att.filename}`);
1034
1178
  tmpFiles.push(tmpPath);
1035
1179
  await client.issues.downloadAttachment({ url: att.content, destinationPath: tmpPath });
1036
1180
  await client.issues.addAttachment({ issueKeyOrId: newKey, filePath: tmpPath });
@@ -1071,26 +1215,65 @@ Examples:
1071
1215
  );
1072
1216
  }
1073
1217
 
1074
- // src/commands/issue/comment-edit.ts
1075
- function commentEdit(parent) {
1076
- parent.command("comment-edit <key>").description("Edit an existing comment").requiredOption("--id <commentId>", "Comment ID to edit").requiredOption("--body <text>", "Updated comment body in wiki markup").addHelpText("after", '\nExamples:\n jiradc issue comment-edit PROJ-123 --id 12345 --body "Updated comment text"').action(async (key, opts) => {
1218
+ // src/commands/issue/comment/create.ts
1219
+ function create2(parent) {
1220
+ const cmd = parent.command("create <key>").description("Add a comment to an issue").addHelpText("after", '\nExamples:\n jiradc issue comment create PROJ-123 --body "Fixed in latest build"');
1221
+ bodyOption(cmd, { mandatory: true });
1222
+ cmd.action(async (key, opts) => {
1077
1223
  const client = getClient();
1078
- const result = await client.issues.editComment({ issueKeyOrId: key, commentId: opts.id, body: opts.body });
1224
+ const result = await client.issues.addComment({ issueKeyOrId: key, body: opts.body });
1079
1225
  output(transformComment(result));
1080
1226
  });
1081
1227
  }
1082
1228
 
1083
- // src/commands/issue/comment.ts
1084
- function comment(parent) {
1085
- parent.command("comment <key>").description("Add a comment to an issue").requiredOption("--body <text>", "Comment body in wiki markup").addHelpText("after", '\nExamples:\n jiradc issue comment PROJ-123 --body "Fixed in latest build"').action(async (key, opts) => {
1229
+ // src/commands/issue/comment/delete.ts
1230
+ function deleteComment(parent) {
1231
+ const cmd = parent.command("delete <key>").description("Delete a comment from an issue").addHelpText("after", "\nExamples:\n jiradc issue comment delete PROJ-123 --comment-id 12345");
1232
+ subEntityOption(cmd, "comment", { mandatory: true });
1233
+ cmd.action(async (key, opts) => {
1086
1234
  const client = getClient();
1087
- const result = await client.issues.addComment({ issueKeyOrId: key, body: opts.body });
1235
+ await client.issues.deleteComment({ issueKeyOrId: key, commentId: String(opts.commentId) });
1236
+ output({ deleted: true, issueKey: key, commentId: opts.commentId });
1237
+ });
1238
+ }
1239
+
1240
+ // src/commands/issue/comment/update.ts
1241
+ function update2(parent) {
1242
+ const cmd = parent.command("update <key>").description("Update an existing comment").addHelpText(
1243
+ "after",
1244
+ '\nExamples:\n jiradc issue comment update PROJ-123 --comment-id 12345 --body "Updated comment text"'
1245
+ );
1246
+ subEntityOption(cmd, "comment", { mandatory: true });
1247
+ bodyOption(cmd, { mandatory: true });
1248
+ cmd.action(async (key, opts) => {
1249
+ const client = getClient();
1250
+ const result = await client.issues.editComment({
1251
+ issueKeyOrId: key,
1252
+ commentId: String(opts.commentId),
1253
+ body: opts.body
1254
+ });
1088
1255
  output(transformComment(result));
1089
1256
  });
1090
1257
  }
1091
1258
 
1259
+ // src/commands/issue/comment/index.ts
1260
+ function registerCommentCommands(parent) {
1261
+ const comment = parent.command("comment").description("Comment operations").addHelpText(
1262
+ "after",
1263
+ `
1264
+ Examples:
1265
+ $ jiradc issue comment create PROJ-123 --body "Fixed in latest build"
1266
+ $ jiradc issue comment update PROJ-123 --comment-id 12345 --body "Updated comment text"
1267
+ $ jiradc issue comment delete PROJ-123 --comment-id 12345
1268
+ `
1269
+ );
1270
+ create2(comment);
1271
+ update2(comment);
1272
+ deleteComment(comment);
1273
+ }
1274
+
1092
1275
  // src/commands/issue/create.ts
1093
- function create2(parent) {
1276
+ function create3(parent) {
1094
1277
  parent.command("create").description("Create a new issue").requiredOption("--project <key>", "Project key or ID").requiredOption("--type <name>", "Issue type name (e.g., Task, Bug, Story)").requiredOption("--summary <text>", "Issue summary/title").option("--description <text>", "Issue description in wiki markup").option("--assignee <username>", "Assignee username").option("--reporter <username>", "Reporter username").option("--priority <name>", "Priority name (e.g., High, Medium, Low)").option("--labels <labels>", "Comma-separated labels").option("--components <names>", "Comma-separated component names").option("--fix-versions <versions>", "Comma-separated fix version names").option("--due-date <date>", "Due date in YYYY-MM-DD format").option("--parent <key>", "Parent issue key (for subtasks)").option("--custom-fields <json>", `Additional custom fields as JSON (e.g., '{"customfield_10100": "EPIC-1"}')`).addHelpText(
1095
1278
  "after",
1096
1279
  `
@@ -1213,22 +1396,6 @@ function devStatus(parent) {
1213
1396
  });
1214
1397
  }
1215
1398
 
1216
- // src/commands/issue/get-worklog.ts
1217
- function getWorklog(parent) {
1218
- parent.command("get-worklog <key>").description("Get worklogs for an issue").option("--start <number>", "Starting index for pagination", nonNegativeInt).option("--limit <number>", "Max results per page (1-1000)", intInRange(1, 1e3), 25).addHelpText(
1219
- "after",
1220
- "\nExamples:\n jiradc issue get-worklog PROJ-123\n jiradc issue get-worklog PROJ-123 --limit 10\n jiradc issue get-worklog PROJ-123 --start 10 --limit 5"
1221
- ).action(async (key, opts) => {
1222
- const client = getClient();
1223
- const result = await client.issues.getWorklogs({
1224
- issueKeyOrId: key,
1225
- startAt: opts.start,
1226
- maxResults: opts.limit
1227
- });
1228
- output(transformPaged(result, transformWorklog));
1229
- });
1230
- }
1231
-
1232
1399
  // src/utils/constants.ts
1233
1400
  var DEFAULT_FIELDS = [
1234
1401
  "summary",
@@ -1440,7 +1607,7 @@ function buildSetValue(parsed, wrap) {
1440
1607
  if (parsed.mode !== "set") return void 0;
1441
1608
  return parsed.values.map(wrap);
1442
1609
  }
1443
- function update2(parent) {
1610
+ function update3(parent) {
1444
1611
  parent.command("update <key>").description("Update issue fields").option("--fields <json>", "JSON string of fields to update (advanced; merges with shortcuts, wins on conflict)").option("--no-notify-users", "Suppress notification emails (default: notify)").option("--attachments <paths>", "Comma-separated local file paths to attach").option("--summary <text>", "Set the issue summary").option("--description <text>", "Set the issue description (wiki markup)").option("--priority <name>", "Set the priority by name (e.g. High)").option("--assignee <user>", 'Set the assignee. Username, "me", or "none" to unassign.').option("--labels <list>", 'Set labels ("a,b,c") or mutate ("+add,-remove")').option("--components <list>", 'Set components ("a,b") or mutate ("+add,-remove")').option("--fix-versions <list>", 'Set fix versions ("1.0,2.0") or mutate ("+1.0,-0.9")').addHelpText(
1445
1612
  "after",
1446
1613
  `
@@ -1521,11 +1688,11 @@ Examples:
1521
1688
  });
1522
1689
  }
1523
1690
 
1524
- // src/commands/issue/worklog.ts
1525
- function worklog(parent) {
1526
- parent.command("worklog <key>").description("Log time spent on an issue").requiredOption("--time <timeSpent>", "Time spent (e.g., '2h', '30m', '1d 4h')").option("--comment <text>", "Worklog comment").option("--started <datetime>", "Start time in ISO 8601 format").addHelpText(
1691
+ // src/commands/issue/worklog/create.ts
1692
+ function create4(parent) {
1693
+ parent.command("create <key>").description("Log time spent on an issue").requiredOption("--time <timeSpent>", "Time spent (e.g., '2h', '30m', '1d 4h')").option("--comment <text>", "Worklog comment").option("--started <datetime>", "Start time in ISO 8601 format").addHelpText(
1527
1694
  "after",
1528
- '\nExamples:\n jiradc issue worklog PROJ-123 --time 2h\n jiradc issue worklog PROJ-123 --time "1d 4h" --comment "Backend implementation"\n jiradc issue worklog PROJ-123 --time 3h --started "2026-03-19T09:00:00.000+0000"'
1695
+ '\nExamples:\n jiradc issue worklog create PROJ-123 --time 2h\n jiradc issue worklog create PROJ-123 --time "1d 4h" --comment "Backend implementation"\n jiradc issue worklog create PROJ-123 --time 3h --started "2026-03-19T09:00:00.000+0000"'
1529
1696
  ).action(async (key, opts) => {
1530
1697
  const client = getClient();
1531
1698
  const result = await client.issues.addWorklog({
@@ -1538,9 +1705,93 @@ function worklog(parent) {
1538
1705
  });
1539
1706
  }
1540
1707
 
1708
+ // src/commands/issue/worklog/delete.ts
1709
+ import { Option as Option4 } from "commander";
1710
+ var ADJUST_ESTIMATE = ["new", "leave", "manual", "auto"];
1711
+ function deleteWorklog(parent) {
1712
+ const cmd = parent.command("delete <key>").description("Delete a worklog entry");
1713
+ subEntityOption(cmd, "worklog", { mandatory: true });
1714
+ cmd.addOption(new Option4("--adjust-estimate <mode>", "How to adjust the remaining estimate").choices(ADJUST_ESTIMATE)).option("--new-estimate <estimate>", 'New remaining estimate; required when --adjust-estimate is "new"').option("--increase-by <amount>", 'Amount to increase the estimate by; required when --adjust-estimate is "manual"').addHelpText(
1715
+ "after",
1716
+ "\nExamples:\n jiradc issue worklog delete PROJ-123 --worklog-id 12345\n jiradc issue worklog delete PROJ-123 --worklog-id 12345 --adjust-estimate leave\n jiradc issue worklog delete PROJ-123 --worklog-id 12345 --adjust-estimate new --new-estimate 2h"
1717
+ ).action(
1718
+ async (key, opts) => {
1719
+ const client = getClient();
1720
+ await client.issues.deleteWorklog({
1721
+ issueKeyOrId: key,
1722
+ worklogId: String(opts.worklogId),
1723
+ adjustEstimate: opts.adjustEstimate,
1724
+ newEstimate: opts.newEstimate,
1725
+ increaseBy: opts.increaseBy
1726
+ });
1727
+ output({ deleted: true, issueKey: key, worklogId: opts.worklogId });
1728
+ }
1729
+ );
1730
+ }
1731
+
1732
+ // src/commands/issue/worklog/list.ts
1733
+ function list4(parent) {
1734
+ parent.command("list <key>").description("Get worklogs for an issue").option("--start <number>", "Starting index for pagination", nonNegativeInt).option("--limit <number>", "Max results per page (1-1000)", intInRange(1, 1e3), 25).addHelpText(
1735
+ "after",
1736
+ "\nExamples:\n jiradc issue worklog list PROJ-123\n jiradc issue worklog list PROJ-123 --limit 10\n jiradc issue worklog list PROJ-123 --start 10 --limit 5"
1737
+ ).action(async (key, opts) => {
1738
+ const client = getClient();
1739
+ const result = await client.issues.getWorklogs({
1740
+ issueKeyOrId: key,
1741
+ startAt: opts.start,
1742
+ maxResults: opts.limit
1743
+ });
1744
+ output(transformPaged(result, transformWorklog));
1745
+ });
1746
+ }
1747
+
1748
+ // src/commands/issue/worklog/update.ts
1749
+ import { Option as Option5 } from "commander";
1750
+ var ADJUST_ESTIMATE2 = ["new", "leave", "auto"];
1751
+ function update4(parent) {
1752
+ const cmd = parent.command("update <key>").description("Update an existing worklog entry");
1753
+ subEntityOption(cmd, "worklog", { mandatory: true });
1754
+ cmd.option("--time <timeSpent>", "Time spent (e.g., '2h', '30m', '1d 4h')").option("--comment <text>", "Worklog comment").option("--started <datetime>", "Start time in ISO 8601 format").addOption(new Option5("--adjust-estimate <mode>", "How to adjust the remaining estimate").choices(ADJUST_ESTIMATE2)).option("--new-estimate <estimate>", 'New remaining estimate; required when --adjust-estimate is "new"').addHelpText(
1755
+ "after",
1756
+ '\nExamples:\n jiradc issue worklog update PROJ-123 --worklog-id 12345 --time "1h 30m"\n jiradc issue worklog update PROJ-123 --worklog-id 12345 --comment "Revised note"\n jiradc issue worklog update PROJ-123 --worklog-id 12345 --time 2h --adjust-estimate new --new-estimate 4h'
1757
+ ).action(
1758
+ async (key, opts) => {
1759
+ const client = getClient();
1760
+ const result = await client.issues.updateWorklog({
1761
+ issueKeyOrId: key,
1762
+ worklogId: String(opts.worklogId),
1763
+ timeSpent: opts.time,
1764
+ comment: opts.comment,
1765
+ started: opts.started,
1766
+ adjustEstimate: opts.adjustEstimate,
1767
+ newEstimate: opts.newEstimate
1768
+ });
1769
+ output(transformWorklog(result));
1770
+ }
1771
+ );
1772
+ }
1773
+
1774
+ // src/commands/issue/worklog/index.ts
1775
+ function registerWorklogCommands(parent) {
1776
+ const worklog = parent.command("worklog").description("Worklog operations").addHelpText(
1777
+ "after",
1778
+ `
1779
+ Examples:
1780
+ $ jiradc issue worklog create PROJ-123 --time 2h --comment "Backend work"
1781
+ $ jiradc issue worklog list PROJ-123 --limit 10
1782
+ $ jiradc issue worklog update PROJ-123 --worklog-id 12345 --time "1h 30m"
1783
+ $ jiradc issue worklog delete PROJ-123 --worklog-id 12345
1784
+ `
1785
+ );
1786
+ create4(worklog);
1787
+ list4(worklog);
1788
+ update4(worklog);
1789
+ deleteWorklog(worklog);
1790
+ }
1791
+
1541
1792
  // src/commands/issue/index.ts
1542
- function registerIssueCommands(program2) {
1543
- const issue = program2.command("issue").description("Issue operations").addHelpText(
1793
+ function registerIssueCommands(program) {
1794
+ const issue = program.command("issue").description("Issue operations").addHelpText(
1544
1795
  "after",
1545
1796
  `
1546
1797
  Examples:
@@ -1554,16 +1805,14 @@ Examples:
1554
1805
  );
1555
1806
  get2(issue);
1556
1807
  search2(issue);
1557
- create2(issue);
1558
- update2(issue);
1808
+ create3(issue);
1809
+ update3(issue);
1559
1810
  deleteIssue(issue);
1560
1811
  transition(issue);
1561
1812
  transitions(issue);
1562
1813
  assign(issue);
1563
- comment(issue);
1564
- commentEdit(issue);
1565
- worklog(issue);
1566
- getWorklog(issue);
1814
+ registerCommentCommands(issue);
1815
+ registerWorklogCommands(issue);
1567
1816
  changelog(issue);
1568
1817
  batchChangelog(issue);
1569
1818
  link(issue);
@@ -1571,14 +1820,13 @@ Examples:
1571
1820
  linkTypes(issue);
1572
1821
  linkEpic(issue);
1573
1822
  registerAttachmentCommands(issue);
1574
- attachments(issue);
1575
1823
  batchCreate(issue);
1576
1824
  clone(issue);
1577
1825
  devStatus(issue);
1578
1826
  }
1579
1827
 
1580
1828
  // src/commands/project/list.ts
1581
- function list4(parent) {
1829
+ function list5(parent) {
1582
1830
  parent.command("list").description("List all projects").option("--expand <expand>", 'Expand options (e.g., "description,lead")').option("--include-archived", "Include archived projects (default: false)").addHelpText(
1583
1831
  "after",
1584
1832
  "\nExamples:\n jiradc project list\n jiradc project list --expand description,lead\n jiradc project list --include-archived"
@@ -1602,8 +1850,8 @@ function versions(parent) {
1602
1850
  }
1603
1851
 
1604
1852
  // src/commands/project/index.ts
1605
- function registerProjectCommands(program2) {
1606
- const project = program2.command("project").description("Project operations").addHelpText(
1853
+ function registerProjectCommands(program) {
1854
+ const project = program.command("project").description("Project operations").addHelpText(
1607
1855
  "after",
1608
1856
  `
1609
1857
  Examples:
@@ -1611,12 +1859,12 @@ Examples:
1611
1859
  $ jiradc project versions PROJ
1612
1860
  `
1613
1861
  );
1614
- list4(project);
1862
+ list5(project);
1615
1863
  versions(project);
1616
1864
  }
1617
1865
 
1618
1866
  // src/commands/sprint/create.ts
1619
- function create3(parent) {
1867
+ function create5(parent) {
1620
1868
  parent.command("create").description("Create a new sprint").requiredOption("--board <id>", "Board ID to create sprint in", positiveInt).requiredOption("--name <name>", "Sprint name").option("--start-date <date>", "Start date in ISO 8601 format").option("--end-date <date>", "End date in ISO 8601 format").option("--goal <goal>", "Sprint goal").addHelpText(
1621
1869
  "after",
1622
1870
  '\nExamples:\n jiradc sprint create --board 42 --name "Sprint 10"\n jiradc sprint create --board 42 --name "Sprint 10" --start-date 2026-03-20 --end-date 2026-04-03 --goal "Complete auth module"'
@@ -1633,10 +1881,20 @@ function create3(parent) {
1633
1881
  });
1634
1882
  }
1635
1883
 
1636
- // src/commands/sprint/issues.ts
1884
+ // src/commands/sprint/delete.ts
1637
1885
  import { Argument as Argument2 } from "commander";
1886
+ function deleteSprint(parent) {
1887
+ parent.command("delete").description("Delete a sprint (returns its issues to the backlog)").addArgument(new Argument2("<id>", "Sprint ID").argParser(positiveInt)).addHelpText("after", "\nExamples:\n jiradc sprint delete 100").action(async (id) => {
1888
+ const client = getClient();
1889
+ await client.agile.deleteSprint({ sprintId: id });
1890
+ output({ deleted: true, sprintId: id });
1891
+ });
1892
+ }
1893
+
1894
+ // src/commands/sprint/issues.ts
1895
+ import { Argument as Argument3 } from "commander";
1638
1896
  function issues2(parent) {
1639
- parent.command("issues").description("Get issues in a sprint").addArgument(new Argument2("<id>", "Sprint ID").argParser(positiveInt)).option("--limit <number>", "Max results (1-50, Jira DC caps at 50)", intInRange(1, 50), 25).option("--start <number>", "Starting index for pagination", nonNegativeInt).option("--fields <fields>", "Comma-separated field names to return").option("--jql <jql>", "Additional JQL filter within the sprint").addHelpText(
1897
+ parent.command("issues").description("Get issues in a sprint").addArgument(new Argument3("<id>", "Sprint ID").argParser(positiveInt)).option("--limit <number>", "Max results (1-50, Jira DC caps at 50)", intInRange(1, 50), 25).option("--start <number>", "Starting index for pagination", nonNegativeInt).option("--fields <fields>", "Comma-separated field names to return").option("--jql <jql>", "Additional JQL filter within the sprint").addHelpText(
1640
1898
  "after",
1641
1899
  '\nExamples:\n jiradc sprint issues 100\n jiradc sprint issues 100 --limit 20\n jiradc sprint issues 100 --jql "status = Done" --fields summary,status\n jiradc sprint issues 100 --start 50 --limit 25'
1642
1900
  ).action(async (id, opts) => {
@@ -1653,10 +1911,10 @@ function issues2(parent) {
1653
1911
  }
1654
1912
 
1655
1913
  // src/commands/sprint/list.ts
1656
- import { Option as Option4 } from "commander";
1914
+ import { Option as Option6 } from "commander";
1657
1915
  var SPRINT_STATES = ["future", "active", "closed"];
1658
- function list5(parent) {
1659
- parent.command("list").description("List sprints for a board").requiredOption("--board <id>", "Board ID", positiveInt).addOption(new Option4("--state <state>", "Filter by sprint state").choices(SPRINT_STATES)).addHelpText(
1916
+ function list6(parent) {
1917
+ parent.command("list").description("List sprints for a board").requiredOption("--board <id>", "Board ID", positiveInt).addOption(new Option6("--state <state>", "Filter by sprint state").choices(SPRINT_STATES)).addHelpText(
1660
1918
  "after",
1661
1919
  "\nExamples:\n jiradc sprint list --board 42\n jiradc sprint list --board 42 --state active"
1662
1920
  ).action(async (opts) => {
@@ -1670,10 +1928,10 @@ function list5(parent) {
1670
1928
  }
1671
1929
 
1672
1930
  // src/commands/sprint/update.ts
1673
- import { Argument as Argument3, Option as Option5 } from "commander";
1931
+ import { Argument as Argument4, Option as Option7 } from "commander";
1674
1932
  var SPRINT_STATES2 = ["future", "active", "closed"];
1675
- function update3(parent) {
1676
- parent.command("update").description("Update an existing sprint").addArgument(new Argument3("<id>", "Sprint ID").argParser(positiveInt)).option("--name <name>", "New sprint name").addOption(new Option5("--state <state>", "New sprint state").choices(SPRINT_STATES2)).option("--start-date <date>", "New start date in ISO 8601 format").option("--end-date <date>", "New end date in ISO 8601 format").option("--goal <goal>", "New sprint goal").addHelpText(
1933
+ function update5(parent) {
1934
+ parent.command("update").description("Update an existing sprint").addArgument(new Argument4("<id>", "Sprint ID").argParser(positiveInt)).option("--name <name>", "New sprint name").addOption(new Option7("--state <state>", "New sprint state").choices(SPRINT_STATES2)).option("--start-date <date>", "New start date in ISO 8601 format").option("--end-date <date>", "New end date in ISO 8601 format").option("--goal <goal>", "New sprint goal").addHelpText(
1677
1935
  "after",
1678
1936
  '\nExamples:\n jiradc sprint update 100 --name "Sprint 10 - Extended"\n jiradc sprint update 100 --state active\n jiradc sprint update 100 --end-date 2026-04-10 --goal "Updated goal"'
1679
1937
  ).action(
@@ -1693,8 +1951,8 @@ function update3(parent) {
1693
1951
  }
1694
1952
 
1695
1953
  // src/commands/sprint/index.ts
1696
- function registerSprintCommands(program2) {
1697
- const sprint = program2.command("sprint").description("Sprint operations").addHelpText(
1954
+ function registerSprintCommands(program) {
1955
+ const sprint = program.command("sprint").description("Sprint operations").addHelpText(
1698
1956
  "after",
1699
1957
  `
1700
1958
  Examples:
@@ -1704,10 +1962,11 @@ Examples:
1704
1962
  $ jiradc sprint create --board 42 --name "Sprint 10" --start-date 2026-04-01 --end-date 2026-04-14
1705
1963
  `
1706
1964
  );
1707
- list5(sprint);
1965
+ list6(sprint);
1708
1966
  issues2(sprint);
1709
- create3(sprint);
1710
- update3(sprint);
1967
+ create5(sprint);
1968
+ update5(sprint);
1969
+ deleteSprint(sprint);
1711
1970
  }
1712
1971
 
1713
1972
  // src/commands/token/client.ts
@@ -1736,7 +1995,7 @@ function getTokenClient(options2 = {}) {
1736
1995
  }
1737
1996
 
1738
1997
  // src/commands/token/create.ts
1739
- function create4(parent) {
1998
+ function create6(parent) {
1740
1999
  parent.command("create").description("Create a Personal Access Token. The secret is returned exactly once.").requiredOption("--name <name>", "Token name").option(
1741
2000
  "--expiration-duration <days>",
1742
2001
  "Token lifetime in days. Omit for a non-expiring token (admin policy permitting).",
@@ -1767,7 +2026,7 @@ Examples:
1767
2026
  }
1768
2027
 
1769
2028
  // src/commands/token/list.ts
1770
- function list6(parent) {
2029
+ function list7(parent) {
1771
2030
  parent.command("list").description("List Personal Access Tokens owned by the authenticated user (secrets not included)").option("--basic-username <u>", "Override $JIRA_BASIC_USERNAME").option(
1772
2031
  "--basic-password <p>",
1773
2032
  "Override $JIRA_BASIC_PASSWORD (caution: visible in process table; prefer the env var)"
@@ -1782,36 +2041,38 @@ function list6(parent) {
1782
2041
 
1783
2042
  // src/commands/token/revoke.ts
1784
2043
  function revoke(parent) {
1785
- parent.command("revoke").description("Revoke a Personal Access Token by id").requiredOption("--id <tokenId>", "Token id to revoke", positiveInt).option("--basic-username <u>", "Override $JIRA_BASIC_USERNAME").option(
2044
+ const cmd = parent.command("revoke").description("Revoke a Personal Access Token by id").option("--basic-username <u>", "Override $JIRA_BASIC_USERNAME").option(
1786
2045
  "--basic-password <p>",
1787
2046
  "Override $JIRA_BASIC_PASSWORD (caution: visible in process table; prefer the env var)"
1788
- ).action(async (opts) => {
2047
+ );
2048
+ subjectArg(cmd, "tokenId", { parser: positiveInt, description: "Token id to revoke" });
2049
+ cmd.action(async (tokenId, opts) => {
1789
2050
  const { client, username, password } = getTokenClient({
1790
2051
  basicUsername: opts.basicUsername,
1791
2052
  basicPassword: opts.basicPassword
1792
2053
  });
1793
- await client.accessTokens.revoke({ username, password, tokenId: opts.id });
1794
- output({ revoked: opts.id });
2054
+ await client.accessTokens.revoke({ username, password, tokenId });
2055
+ output({ revoked: tokenId });
1795
2056
  });
1796
2057
  }
1797
2058
 
1798
2059
  // src/commands/token/index.ts
1799
- function registerTokenCommands(program2) {
1800
- const token = program2.command("token").description("Personal Access Token management").addHelpText(
2060
+ function registerTokenCommands(program) {
2061
+ const token = program.command("token").description("Personal Access Token management").addHelpText(
1801
2062
  "after",
1802
2063
  `
1803
2064
  Examples:
1804
2065
  $ jiradc token list
1805
2066
  $ jiradc token create --name my-pat
1806
- $ jiradc token revoke --id 173
2067
+ $ jiradc token revoke 173
1807
2068
 
1808
2069
  Auth:
1809
2070
  Requires JIRA_BASIC_USERNAME + JIRA_BASIC_PASSWORD
1810
2071
  (or --basic-username / --basic-password on any subcommand).
1811
2072
  `
1812
2073
  );
1813
- create4(token);
1814
- list6(token);
2074
+ create6(token);
2075
+ list7(token);
1815
2076
  revoke(token);
1816
2077
  }
1817
2078
 
@@ -1852,8 +2113,8 @@ function search3(parent) {
1852
2113
  }
1853
2114
 
1854
2115
  // src/commands/user/index.ts
1855
- function registerUserCommands(program2) {
1856
- const user = program2.command("user").description("User operations").addHelpText(
2116
+ function registerUserCommands(program) {
2117
+ const user = program.command("user").description("User operations").addHelpText(
1857
2118
  "after",
1858
2119
  `
1859
2120
  Examples:
@@ -1867,31 +2128,22 @@ Examples:
1867
2128
  search3(user);
1868
2129
  }
1869
2130
 
1870
- // src/index.ts
1871
- function readPackageVersion() {
1872
- try {
1873
- const here = dirname(fileURLToPath(import.meta.url));
1874
- const pkgPath = join4(here, "..", "package.json");
1875
- const pkg = JSON.parse(readFileSync(pkgPath, "utf-8"));
1876
- return pkg.version ?? "0.0.0";
1877
- } catch {
1878
- return "0.0.0";
1879
- }
1880
- }
2131
+ // src/program.ts
1881
2132
  var DIM = "\x1B[2m";
1882
2133
  var RESET = "\x1B[0m";
1883
- var program = new Command8();
1884
- program.name("jiradc").description("Jira Data Center CLI").version(readPackageVersion()).configureHelp({
1885
- styleTitle: (str) => styleText("bold", str),
1886
- styleUsage: (str) => styleText("dim", str),
1887
- styleCommandDescription: (str) => styleText("dim", str),
1888
- styleOptionDescription: (str) => styleText("dim", str),
1889
- styleSubcommandDescription: (str) => styleText("dim", str)
1890
- }).addHelpText("beforeAll", `
2134
+ function buildProgram() {
2135
+ const program = new Command11();
2136
+ program.name("jiradc").description("Jira Data Center CLI").version(readPackageVersion(import.meta.url)).configureHelp({
2137
+ styleTitle: (str) => styleText("bold", str),
2138
+ styleUsage: (str) => styleText("dim", str),
2139
+ styleCommandDescription: (str) => styleText("dim", str),
2140
+ styleOptionDescription: (str) => styleText("dim", str),
2141
+ styleSubcommandDescription: (str) => styleText("dim", str)
2142
+ }).addHelpText("beforeAll", `
1891
2143
  ${styleText("bold", "jiradc")} ${DIM}\u2014 Jira Data Center CLI${RESET}
1892
2144
  `).addHelpText(
1893
- "after",
1894
- `
2145
+ "after",
2146
+ `
1895
2147
  ${styleText("bold", "Environment:")}
1896
2148
  JIRA_URL Jira Server base URL ${DIM}(e.g., https://jira.example.com)${RESET}
1897
2149
  JIRA_TOKEN Personal Access Token ${DIM}(generate in Jira > Profile > Personal Access Tokens)${RESET}
@@ -1905,21 +2157,25 @@ ${styleText("bold", "Examples:")}
1905
2157
  ${DIM}$${RESET} jiradc board list --type scrum
1906
2158
  ${DIM}$${RESET} jiradc sprint list --board 42 --state active
1907
2159
  `
1908
- );
1909
- program.option("--pretty", "Pretty-print JSON output");
1910
- program.hook("preAction", (thisCommand) => {
1911
- if (thisCommand.optsWithGlobals().pretty) setPretty(true);
1912
- });
1913
- registerIssueCommands(program);
1914
- registerProjectCommands(program);
1915
- registerComponentCommands(program);
1916
- registerBoardCommands(program);
1917
- registerSprintCommands(program);
1918
- registerFieldCommands(program);
1919
- registerUserCommands(program);
1920
- registerTokenCommands(program);
1921
- try {
1922
- await program.parseAsync();
1923
- } catch (err) {
1924
- handleError(err);
2160
+ );
2161
+ program.option("--pretty", "Pretty-print JSON output");
2162
+ program.hook("preAction", (thisCommand) => {
2163
+ if (thisCommand.optsWithGlobals().pretty) setPretty(true);
2164
+ });
2165
+ registerIssueCommands(program);
2166
+ registerProjectCommands(program);
2167
+ registerComponentCommands(program);
2168
+ registerBoardCommands(program);
2169
+ registerSprintCommands(program);
2170
+ registerFieldCommands(program);
2171
+ registerUserCommands(program);
2172
+ registerTokenCommands(program);
2173
+ return program;
1925
2174
  }
2175
+
2176
+ // src/index.ts
2177
+ await runCli(buildProgram(), {
2178
+ service: "Jira",
2179
+ authRecovery: "Set JIRA_URL and JIRA_TOKEN in your shell profile (~/.zshrc). Generate a token in Jira > Profile > Personal Access Tokens.",
2180
+ networkRecovery: "Verify JIRA_URL is correct, the server is reachable, and you are on the VPN if required."
2181
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jiradc-cli",
3
- "version": "1.0.20",
3
+ "version": "2.0.0-ga26d641.1",
4
4
  "publish": true,
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -12,7 +12,8 @@
12
12
  ],
13
13
  "dependencies": {
14
14
  "commander": "^13.1.0",
15
- "jira-data-center-client": "1.0.36"
15
+ "jira-data-center-client": "1.0.37-ga26d641.1",
16
+ "cli-utils": "1.0.0"
16
17
  },
17
18
  "devDependencies": {
18
19
  "@types/node": "24.10.4",
@@ -22,8 +23,8 @@
22
23
  "tsx": "^4.19.2",
23
24
  "typescript": "^5.7.2",
24
25
  "vitest": "^4.0.16",
25
- "config-typescript": "0.0.0",
26
- "config-eslint": "0.0.0"
26
+ "config-eslint": "0.0.0",
27
+ "config-typescript": "0.0.0"
27
28
  },
28
29
  "engines": {
29
30
  "node": ">=22.0.0"
@@ -34,6 +35,6 @@
34
35
  "lint": "eslint src",
35
36
  "lint:fix": "eslint src --fix",
36
37
  "test": "vitest run",
37
- "test:integration": "vitest run tests/integration"
38
+ "test:integration": "vitest run --config vitest.integration.config.ts"
38
39
  }
39
40
  }