@kud/jira-cli 0.9.0 → 0.10.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 (3) hide show
  1. package/README.md +14 -1
  2. package/dist/index.js +173 -8
  3. package/package.json +2 -2
package/README.md CHANGED
@@ -33,6 +33,7 @@ jira attachment list ABC-123
33
33
 
34
34
  jira attachment read ABC-123 error.log | grep -i timeout
35
35
  jira attachment get ABC-123 screen.png --output ~/Desktop/
36
+ jira attachment upload ABC-123 ./build.log ./screenshot.png
36
37
  ```
37
38
 
38
39
  Descriptions and comments render as Markdown, with embedded files named rather than left as opaque ids:
@@ -49,7 +50,7 @@ Run `jira` with no arguments:
49
50
  jira
50
51
  ```
51
52
 
52
- Your issues as a board. By default the tabs are Jira's three status *categories* — **To do**, **In progress**, **Done** — so it works on any instance without knowing what your board calls its columns. Pass `--board <id>` (or set `defaultBoard` in the config file) and the tabs become that board's own columns, matched by status id; statuses no column claims land on an **Off board** tab. Hand-written `tabs` in the config file win over both. Rows hang under their epic, carry a type pill, a priority glyph (`▲` high, `▼` low) and how long since they last moved. Closed work from the last fortnight is on the Done tab; `a` loads everything.
53
+ Your issues as a board. By default the tabs are Jira's three status _categories_ — **To do**, **In progress**, **Done** — so it works on any instance without knowing what your board calls its columns. Pass `--board <id>` (or set `defaultBoard` in the config file) and the tabs become that board's own columns, matched by status id; statuses no column claims land on an **Off board** tab. Hand-written `tabs` in the config file win over both. Rows hang under their epic, carry a type pill, a priority glyph (`▲` high, `▼` low) and how long since they last moved. Closed work from the last fortnight is on the Done tab; `a` loads everything.
53
54
 
54
55
  `↑↓` to move, `←→` (or `⇥`) to switch tab, `enter` to open, `?` for the legend, `r` to refresh. `q` quits from anywhere; `esc` or `⌫` goes back one level — a prompt, then the issue, then nothing.
55
56
 
@@ -91,14 +92,24 @@ jira issue edit ABC-123 --summary 'Better title'
91
92
  jira issue assign ABC-123 me # or a name, or 'none'
92
93
  jira issue comment add ABC-123 - # body from stdin
93
94
  jira issue comment list ABC-123
95
+ jira issue comment edit ABC-123 12345 'Actually fixed in 2.1'
96
+ jira issue delete ABC-123 # asks first; --yes to confirm in scripts
97
+ jira issue rank ABC-1 ABC-2 --before ABC-3
94
98
  jira issue link ABC-1 Blocks ABC-2
95
99
  jira issue watch add ABC-123
96
100
  jira issue worklog add ABC-123 '2h 30m'
101
+ jira issue worklog edit ABC-123 456 --time '3h'
102
+ jira issue worklog delete ABC-123 456
103
+ jira issue remotelink list ABC-123
104
+ jira issue remotelink add ABC-123 https://example.atlassian.net/wiki/spaces/ABC/pages/1234
105
+ jira issue remotelink remove ABC-123 789
97
106
  jira issue history ABC-123
98
107
  ```
99
108
 
100
109
  Bodies accept Markdown — paragraphs, headings, lists, fenced code, links and code spans are converted to ADF.
101
110
 
111
+ Deletes (`issue delete`, `comment delete`, `worklog delete`, `remotelink remove`) ask before they act; piped or scripted runs refuse unless `--yes` is passed, since there is no undo on Jira's side. `remotelink add` is idempotent: re-adding the same url updates the same link rather than creating duplicates.
112
+
102
113
  ## Projects, boards and sprints
103
114
 
104
115
  ```sh
@@ -115,6 +126,8 @@ jira epic ABC-100
115
126
 
116
127
  jira sprint list 42 --state active
117
128
  jira sprint issues 1234
129
+ jira sprint add 1234 ABC-1 ABC-2
130
+ jira backlog add ABC-1 ABC-2
118
131
  ```
119
132
 
120
133
  ## Knowing what this instance supports
package/dist/index.js CHANGED
@@ -75,6 +75,31 @@ var registerAttachmentCommands = (program2) => {
75
75
  `
76
76
  );
77
77
  });
78
+ attachment.command("upload <key> <file...>").description("attach files to an issue").option("--json", "emit JSON").action(
79
+ async (key, files, options) => {
80
+ const ctx = context();
81
+ const uploaded = [];
82
+ for (const file of files) {
83
+ try {
84
+ uploaded.push(...await ctx.client.uploadAttachment(key, file));
85
+ } catch (err) {
86
+ const done = uploaded.map((a) => a.filename).join(", ");
87
+ throw new Error(
88
+ `${file}: ${err.message}${done ? ` (already attached: ${done})` : ""}`
89
+ );
90
+ }
91
+ }
92
+ if (options.json) return printJson(uploaded);
93
+ process.stdout.write(
94
+ `${table(uploaded, [
95
+ { header: "ID", value: (a) => a.id },
96
+ { header: "FILENAME", value: (a) => a.filename },
97
+ { header: "SIZE", value: (a) => humanSize(a.size), align: "right" }
98
+ ])}
99
+ `
100
+ );
101
+ }
102
+ );
78
103
  attachment.command("read <key> <selector>").alias("cat").description("print a text attachment to stdout").action(async (key, selector) => {
79
104
  const ctx = context();
80
105
  const attachments = locateAttachments(await ctx.client.getIssue(key));
@@ -203,6 +228,11 @@ var registerSprintCommands = (program2) => {
203
228
  const { issues } = await ctx.client.getSprintIssues(Number(id));
204
229
  writeIssues(issues, options.json);
205
230
  });
231
+ sprint.command("add <sprintId> <keys...>").description("move issues into a sprint").action(async (sprintId, keys) => {
232
+ await context().client.moveIssuesToSprint(Number(sprintId), keys);
233
+ process.stderr.write(`moved ${keys.join(", ")} to sprint ${sprintId}
234
+ `);
235
+ });
206
236
  sprint.command("view <id>").description("show one sprint").option("--json", "emit JSON").action(async (id, options) => {
207
237
  const ctx = context();
208
238
  const found = await ctx.client.getSprint(Number(id));
@@ -226,17 +256,50 @@ var registerEpicCommands = (program2) => {
226
256
  writeIssues(issues, options.json);
227
257
  });
228
258
  };
259
+ var registerBacklogCommand = (program2) => {
260
+ const backlog = program2.command("backlog").description("backlog management");
261
+ backlog.command("add <keys...>").description("move issues to the backlog").action(async (keys) => {
262
+ await context().client.moveIssuesToBacklog(keys);
263
+ process.stderr.write(`moved ${keys.join(", ")} to the backlog
264
+ `);
265
+ });
266
+ };
229
267
 
230
268
  // src/commands/issue.ts
231
269
  import { execFile } from "child_process";
232
- import {
233
- adfToMarkdown as adfToMarkdown2,
234
- locateAttachments as locateAttachments2
235
- } from "@kud/jira";
270
+ import { adfToMarkdown as adfToMarkdown2, locateAttachments as locateAttachments2 } from "@kud/jira";
236
271
 
237
272
  // src/commands/issue-write.ts
238
273
  import { readFileSync } from "fs";
239
274
  import { adfToMarkdown, markdownToAdf } from "@kud/jira";
275
+
276
+ // src/commands/confirm.ts
277
+ import { createInterface } from "readline/promises";
278
+ var confirmDestructive = async (what, options) => {
279
+ if (options.yes) return;
280
+ if (!process.stdin.isTTY)
281
+ throw exitError(
282
+ 1,
283
+ `${what} is destructive \u2014 re-run with --yes to confirm it non-interactively`
284
+ );
285
+ const rl = createInterface({ input: process.stdin, output: process.stderr });
286
+ try {
287
+ const answer = await rl.question(`${what} \u2014 proceed? [y/N] `);
288
+ if (answer.trim().toLowerCase() !== "y") throw exitError(1, "aborted");
289
+ } finally {
290
+ rl.close();
291
+ }
292
+ };
293
+
294
+ // src/commands/issue-write.ts
295
+ var rankPosition = (options) => {
296
+ const { before, after } = options;
297
+ if (before && after) throw exitError(1, "pass --before or --after, not both");
298
+ if (!before && !after)
299
+ throw exitError(1, "pass one of --before <key> or --after <key>");
300
+ if (before) return { before };
301
+ return { after };
302
+ };
240
303
  var readBody = (value) => value === "-" ? readFileSync(0, "utf8") : value;
241
304
  var resolveAccountId = async (who, projectKey) => {
242
305
  if (who === "none" || who === "unassigned") return null;
@@ -293,6 +356,12 @@ var registerIssueWriteCommands = (issue) => {
293
356
  `);
294
357
  }
295
358
  );
359
+ issue.command("delete <key>").description("delete an issue, permanently").option("--yes", "skip the confirmation").action(async (key, options) => {
360
+ await confirmDestructive(`permanently delete ${key}`, options);
361
+ await context().client.deleteIssue(key);
362
+ process.stderr.write(`deleted ${key}
363
+ `);
364
+ });
296
365
  issue.command("assign <key> <who>").description("assign an issue; 'me' or 'none' both work").action(async (key, who) => {
297
366
  const accountId = await resolveAccountId(who);
298
367
  await context().client.assignIssue(key, accountId);
@@ -321,6 +390,26 @@ var registerIssueWriteCommands = (issue) => {
321
390
  process.stderr.write(`commented on ${key}
322
391
  `);
323
392
  });
393
+ comment.command("edit <key> <commentId> <text>").description("edit a comment; '-' reads stdin").action(async (key, commentId, text) => {
394
+ await context().client.updateComment(
395
+ key,
396
+ commentId,
397
+ markdownToAdf(readBody(text))
398
+ );
399
+ process.stderr.write(`comment ${commentId} on ${key} updated
400
+ `);
401
+ });
402
+ comment.command("delete <key> <commentId>").description("delete a comment").option("--yes", "skip the confirmation").action(
403
+ async (key, commentId, options) => {
404
+ await confirmDestructive(
405
+ `delete comment ${commentId} on ${key}`,
406
+ options
407
+ );
408
+ await context().client.deleteComment(key, commentId);
409
+ process.stderr.write(`deleted comment ${commentId} on ${key}
410
+ `);
411
+ }
412
+ );
324
413
  const watch = issue.command("watch").description("watchers");
325
414
  watch.command("list <key>").alias("ls").description("who is watching an issue").action(async (key) => {
326
415
  const { watchers } = await context().client.getWatchers(key);
@@ -369,6 +458,80 @@ var registerIssueWriteCommands = (issue) => {
369
458
  `);
370
459
  }
371
460
  );
461
+ worklog.command("edit <key> <worklogId>").description("change logged work").option("--time <timeSpent>", "new time spent, e.g. '1h 30m'").option("-b, --body <text>", "what you did; '-' reads stdin").option(
462
+ "--started <datetime>",
463
+ "start time, e.g. 2026-10-27T09:00:00.000+0000"
464
+ ).action(
465
+ async (key, worklogId, options) => {
466
+ if (!options.time && !options.body && !options.started)
467
+ throw exitError(2, "nothing to change \u2014 pass at least one option");
468
+ await context().client.updateWorklog(key, worklogId, {
469
+ ...options.time ? { timeSpent: options.time } : {},
470
+ ...options.body ? { comment: markdownToAdf(readBody(options.body)) } : {},
471
+ ...options.started ? { started: options.started } : {}
472
+ });
473
+ process.stderr.write(`worklog ${worklogId} on ${key} updated
474
+ `);
475
+ }
476
+ );
477
+ worklog.command("delete <key> <worklogId>").description("delete logged work").option("--yes", "skip the confirmation").action(
478
+ async (key, worklogId, options) => {
479
+ await confirmDestructive(
480
+ `delete worklog ${worklogId} on ${key}`,
481
+ options
482
+ );
483
+ await context().client.deleteWorklog(key, worklogId);
484
+ process.stderr.write(`deleted worklog ${worklogId} on ${key}
485
+ `);
486
+ }
487
+ );
488
+ const remotelink = issue.command("remotelink").description("links to pages outside Jira");
489
+ remotelink.command("list <key>").alias("ls").description("remote links on an issue").option("--json", "emit JSON").action(async (key, options) => {
490
+ const links = await context().client.getRemoteLinks(key);
491
+ if (options.json) return printJson(links);
492
+ if (links.length === 0) {
493
+ process.stderr.write(`${key} has no remote links
494
+ `);
495
+ return;
496
+ }
497
+ process.stdout.write(
498
+ `${table(links, [
499
+ { header: "ID", value: (l) => String(l.id) },
500
+ { header: "TITLE", value: (l) => l.object.title },
501
+ { header: "URL", value: (l) => l.object.url }
502
+ ])}
503
+ `
504
+ );
505
+ });
506
+ remotelink.command("add <key> <url>").description("link a url to an issue; re-adding the same url is a no-op").option("--title <text>", "link title, defaulting to the url").action(async (key, url, options) => {
507
+ await context().client.createRemoteLink(key, {
508
+ url,
509
+ title: options.title ?? url,
510
+ globalId: url
511
+ });
512
+ process.stderr.write(`linked ${url} to ${key}
513
+ `);
514
+ });
515
+ remotelink.command("remove <key> <linkId>").description("remove a remote link").option("--yes", "skip the confirmation").action(async (key, linkId, options) => {
516
+ await confirmDestructive(
517
+ `remove remote link ${linkId} from ${key}`,
518
+ options
519
+ );
520
+ await context().client.deleteRemoteLink(key, linkId);
521
+ process.stderr.write(`removed remote link ${linkId} from ${key}
522
+ `);
523
+ });
524
+ issue.command("rank <keys...>").description("order issues before or after another issue").option("--before <key>", "place the issues before this one").option("--after <key>", "place the issues after this one").action(
525
+ async (keys, options) => {
526
+ const position = rankPosition(options);
527
+ await context().client.rankIssues(keys, position);
528
+ const anchor = "before" in position ? position.before : position.after;
529
+ process.stderr.write(
530
+ `ranked ${keys.join(", ")} ${"before" in position ? "before" : "after"} ${anchor}
531
+ `
532
+ );
533
+ }
534
+ );
372
535
  issue.command("link <inward> <type> <outward>").description("link two issues, e.g. ABC-1 Blocks ABC-2").action(async (inward, type, outward) => {
373
536
  await context().client.linkIssues(type, inward, outward);
374
537
  process.stderr.write(`${inward} ${type} ${outward}
@@ -390,9 +553,7 @@ var registerIssueWriteCommands = (issue) => {
390
553
  };
391
554
 
392
555
  // src/commands/issue.ts
393
- import {
394
- buildJql
395
- } from "@kud/jira";
556
+ import { buildJql } from "@kud/jira";
396
557
  var issueColumns = (ctx) => [
397
558
  { header: "KEY", value: (i) => i.key },
398
559
  { header: "STATUS", value: (i) => i.fields.status?.name ?? "\u2014" },
@@ -807,7 +968,10 @@ var registerInitCommand = (program2) => {
807
968
  const path = configPath();
808
969
  const existing = readFileConfig(path);
809
970
  if (Object.keys(existing).length > 0 && !options.force)
810
- throw exitError(1, `${path} already exists \u2014 pass --force to replace it`);
971
+ throw exitError(
972
+ 1,
973
+ `${path} already exists \u2014 pass --force to replace it`
974
+ );
811
975
  const config = {
812
976
  baseUrl: options.baseUrl ?? process.env["ATLASSIAN_BASE_URL"] ?? "",
813
977
  email: options.email ?? process.env["ATLASSIAN_USER_EMAIL"] ?? "",
@@ -861,6 +1025,7 @@ registerInitCommand(program);
861
1025
  registerProjectCommands(program);
862
1026
  registerBoardCommands(program);
863
1027
  registerSprintCommands(program);
1028
+ registerBacklogCommand(program);
864
1029
  registerEpicCommands(program);
865
1030
  registerUserCommands(program);
866
1031
  registerMetaCommands(program);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kud/jira-cli",
3
- "version": "0.9.0",
3
+ "version": "0.10.0",
4
4
  "type": "module",
5
5
  "description": "Jira on the command line — read issues, comments and attachments as plain text",
6
6
  "keywords": [
@@ -38,7 +38,7 @@
38
38
  },
39
39
  "dependencies": {
40
40
  "@kud/ink-ui": "0.32.0",
41
- "@kud/jira": "0.4.0",
41
+ "@kud/jira": "0.5.0",
42
42
  "@kud/jira-ink": "0.11.0",
43
43
  "commander": "14.0.1",
44
44
  "ink": "7.1.1",