@kud/jira-cli 0.6.1 → 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.
package/dist/index.js CHANGED
@@ -900,7 +900,7 @@ var interactiveArgs = (argv) => {
900
900
  var main = async () => {
901
901
  const { screen, mock, board, isBare } = interactiveArgs(process.argv);
902
902
  if (screen === "list" && isBare) {
903
- const { SCREENS } = await import("./tui-SBHMIFC4.js");
903
+ const { SCREENS } = await import("./tui-Y4KR7SWS.js");
904
904
  process.stdout.write(`${SCREENS.join("\n")}
905
905
  `);
906
906
  return;
@@ -910,7 +910,7 @@ var main = async () => {
910
910
  program.outputHelp();
911
911
  return;
912
912
  }
913
- const { runTui } = await import("./tui-SBHMIFC4.js");
913
+ const { runTui } = await import("./tui-Y4KR7SWS.js");
914
914
  const [, key] = (screen ?? "").split(":");
915
915
  await runTui({
916
916
  screen: screen?.startsWith("detail") ? "detail" : "issues",
@@ -9,47 +9,62 @@ import { render } from "ink";
9
9
  import { execFile } from "child_process";
10
10
  import {
11
11
  Alert,
12
+ colors,
12
13
  ConfirmInput,
13
14
  Select,
14
15
  Spinner,
15
16
  TextInput,
16
17
  useAppKeys
17
18
  } from "@kud/ink-ui";
18
- import { Box as Box2, Text as Text2, useApp, useInput, useStdout } from "ink";
19
+ import { Box, Text, useApp, useInput, useStdout } from "ink";
19
20
  import { useCallback, useEffect, useState } from "react";
20
21
  import { errorMessagesOf, isJiraApiError } from "@kud/jira";
21
22
  import {
22
23
  IssueBoard,
23
- IssueDetailView
24
+ IssueDetailView,
25
+ pendingRow,
26
+ settleRow,
27
+ transitionRow
24
28
  } from "@kud/jira-ink";
25
29
 
26
30
  // src/tui/frame.tsx
27
- import { FooterHints, Panel } from "@kud/ink-ui";
28
- import { Box, Text } from "ink";
29
- import { jsx, jsxs } from "react/jsx-runtime";
31
+ import { Page } from "@kud/ink-ui";
32
+ import { jsx } from "react/jsx-runtime";
30
33
  var Frame = ({
31
34
  width,
32
35
  height,
33
36
  facts,
37
+ count,
38
+ user,
39
+ scope,
40
+ status,
34
41
  hints,
35
42
  page = "root",
43
+ gap = true,
36
44
  children
37
- }) => /* @__PURE__ */ jsxs(Panel, { width, height, children: [
38
- /* @__PURE__ */ jsxs(Box, { paddingLeft: 1, children: [
39
- /* @__PURE__ */ jsx(Text, { bold: true, children: "\u{1F3AB} Jira" }),
40
- /* @__PURE__ */ jsxs(Text, { dimColor: true, children: [
41
- " ",
42
- facts
43
- ] })
44
- ] }),
45
- /* @__PURE__ */ jsx(Box, { flexDirection: "column", flexGrow: 1, children }),
46
- hints ? /* @__PURE__ */ jsx(Box, { paddingLeft: 2, children: /* @__PURE__ */ jsx(FooterHints, { hints, page }) }) : null
47
- ] });
48
- var FRAME_CHROME = 3;
45
+ }) => /* @__PURE__ */ jsx(
46
+ Page,
47
+ {
48
+ icon: "\u{1F3AB}",
49
+ title: "Jira",
50
+ facts,
51
+ count,
52
+ user,
53
+ scope,
54
+ status,
55
+ hints,
56
+ page,
57
+ gap,
58
+ width,
59
+ height,
60
+ children
61
+ }
62
+ );
63
+ var FRAME_CHROME = 4;
49
64
 
50
65
  // src/tui/app.tsx
51
- import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
52
- var DETAIL_CHROME = 4;
66
+ import { jsx as jsx2, jsxs } from "react/jsx-runtime";
67
+ var DETAIL_CHROME = 3;
53
68
  var MIN_WIDTH = 60;
54
69
  var MIN_HEIGHT = 12;
55
70
  var App = ({ data, initialScreen, initialKey }) => {
@@ -69,6 +84,9 @@ var App = ({ data, initialScreen, initialKey }) => {
69
84
  const [showingAll, setShowingAll] = useState(false);
70
85
  const [error, setError] = useState(null);
71
86
  const [busy, setBusy] = useState(null);
87
+ const [parents, setParents] = useState([]);
88
+ const [flash, setFlash] = useState(null);
89
+ const [moving, setMoving] = useState(null);
72
90
  const loadList = useCallback(
73
91
  async (all) => {
74
92
  setError(null);
@@ -76,8 +94,11 @@ var App = ({ data, initialScreen, initialKey }) => {
76
94
  setScope({ kind: "mine" });
77
95
  setSearchError(null);
78
96
  try {
79
- setModel(await data.board(all));
97
+ const next = await data.board(all);
98
+ setModel(next);
80
99
  setLoadedAt(Date.now());
100
+ void data.parents(next.rows).then(setParents).catch(() => {
101
+ });
81
102
  } catch (e) {
82
103
  setError(e instanceof Error ? e.message : String(e));
83
104
  }
@@ -103,6 +124,8 @@ var App = ({ data, initialScreen, initialKey }) => {
103
124
  try {
104
125
  const result = await data.search(query, mode);
105
126
  setModel(result.model);
127
+ void data.parents(result.model.rows).then(setParents).catch(() => {
128
+ });
106
129
  setScope({ kind: "search", query, mode: result.mode });
107
130
  setLoadedAt(Date.now());
108
131
  } catch (e) {
@@ -111,6 +134,24 @@ var App = ({ data, initialScreen, initialKey }) => {
111
134
  },
112
135
  [data]
113
136
  );
137
+ const move = useCallback(
138
+ async (key, t) => {
139
+ setFlash(null);
140
+ setMoving(key);
141
+ setModel((m) => m ? pendingRow(m, key, t.to) : m);
142
+ try {
143
+ await data.transition(key, t.id);
144
+ setModel((m) => m ? transitionRow(m, key, t.to) : m);
145
+ setIssue((i) => i && i.key === key ? { ...i, status: t.to.name } : i);
146
+ } catch (e) {
147
+ setModel((m) => m ? settleRow(m, key) : m);
148
+ setFlash(jiraMessageOf(e));
149
+ } finally {
150
+ setMoving(null);
151
+ }
152
+ },
153
+ [data]
154
+ );
114
155
  useEffect(() => {
115
156
  void data.me().then((me) => setViewer(me.displayName)).catch(() => {
116
157
  });
@@ -142,7 +183,7 @@ var App = ({ data, initialScreen, initialKey }) => {
142
183
  }
143
184
  });
144
185
  if (width < MIN_WIDTH || height < MIN_HEIGHT) {
145
- return /* @__PURE__ */ jsxs2(Text2, { children: [
186
+ return /* @__PURE__ */ jsxs(Text, { children: [
146
187
  "Terminal too small \u2014 needs at least ",
147
188
  MIN_WIDTH,
148
189
  "\xD7",
@@ -155,7 +196,7 @@ var App = ({ data, initialScreen, initialKey }) => {
155
196
  "."
156
197
  ] });
157
198
  }
158
- const framed = (facts, body, hints, page = screen === "detail" ? "nested" : "root") => /* @__PURE__ */ jsx2(Frame, { width, height, facts, hints, page, children: /* @__PURE__ */ jsx2(Box2, { flexDirection: "column", marginTop: 1, paddingLeft: 2, flexGrow: 1, children: body }) });
199
+ const framed = (facts, body, hints, page = screen === "detail" ? "nested" : "root") => /* @__PURE__ */ jsx2(Frame, { width, height, facts, hints, page, children: /* @__PURE__ */ jsx2(Box, { flexDirection: "column", marginTop: 1, paddingLeft: 2, flexGrow: 1, children: body }) });
159
200
  if (error)
160
201
  return framed("error", /* @__PURE__ */ jsx2(Alert, { variant: "error", children: error }), [
161
202
  ["r", "retry"]
@@ -164,8 +205,8 @@ var App = ({ data, initialScreen, initialKey }) => {
164
205
  if (overlay.kind === "transition") {
165
206
  return framed(
166
207
  issue?.key ?? "",
167
- /* @__PURE__ */ jsxs2(Box2, { flexDirection: "column", gap: 1, children: [
168
- /* @__PURE__ */ jsxs2(Text2, { bold: true, children: [
208
+ /* @__PURE__ */ jsxs(Box, { flexDirection: "column", gap: 1, children: [
209
+ /* @__PURE__ */ jsxs(Text, { bold: true, children: [
169
210
  "Move ",
170
211
  issue?.key,
171
212
  " to\u2026"
@@ -174,34 +215,25 @@ var App = ({ data, initialScreen, initialKey }) => {
174
215
  Select,
175
216
  {
176
217
  options: overlay.options.map((t) => ({
177
- label: `${t.name} \u2192 ${t.to}`,
218
+ label: `${t.name} \u2192 ${t.to.name}`,
178
219
  value: t.id
179
220
  })),
180
221
  onSubmit: (id) => {
222
+ const chosen = overlay.options.find((t) => t.id === id);
181
223
  setOverlay({ kind: "none" });
182
- void (async () => {
183
- setBusy("Transitioning\u2026");
184
- try {
185
- await data.transition(issue.key, id);
186
- await loadIssue(issue.key);
187
- } catch (e) {
188
- setError(e instanceof Error ? e.message : String(e));
189
- } finally {
190
- setBusy(null);
191
- }
192
- })();
224
+ void move(issue.key, chosen);
193
225
  }
194
226
  }
195
227
  ),
196
- /* @__PURE__ */ jsx2(Text2, { dimColor: true, children: "esc cancel" })
228
+ /* @__PURE__ */ jsx2(Text, { dimColor: true, children: "esc cancel" })
197
229
  ] })
198
230
  );
199
231
  }
200
232
  if (overlay.kind === "comment") {
201
233
  return framed(
202
234
  issue?.key ?? "",
203
- /* @__PURE__ */ jsxs2(Box2, { flexDirection: "column", gap: 1, children: [
204
- /* @__PURE__ */ jsxs2(Text2, { bold: true, children: [
235
+ /* @__PURE__ */ jsxs(Box, { flexDirection: "column", gap: 1, children: [
236
+ /* @__PURE__ */ jsxs(Text, { bold: true, children: [
205
237
  "Comment on ",
206
238
  issue?.key
207
239
  ] }),
@@ -233,8 +265,8 @@ var App = ({ data, initialScreen, initialKey }) => {
233
265
  if (overlay.kind === "assign") {
234
266
  return framed(
235
267
  issue?.key ?? "",
236
- /* @__PURE__ */ jsxs2(Box2, { flexDirection: "column", gap: 1, children: [
237
- /* @__PURE__ */ jsxs2(Text2, { children: [
268
+ /* @__PURE__ */ jsxs(Box, { flexDirection: "column", gap: 1, children: [
269
+ /* @__PURE__ */ jsxs(Text, { children: [
238
270
  "Assign ",
239
271
  issue?.key,
240
272
  " to yourself?"
@@ -270,18 +302,22 @@ var App = ({ data, initialScreen, initialKey }) => {
270
302
  issue,
271
303
  width,
272
304
  height: height - FRAME_CHROME - DETAIL_CHROME,
273
- frame: ({ title, subtitle, hints, body }) => /* @__PURE__ */ jsxs2(
305
+ frame: ({ title, subtitle, hints, body }) => /* @__PURE__ */ jsxs(
274
306
  Frame,
275
307
  {
276
308
  width,
277
309
  height,
278
- facts: title,
310
+ scope: title,
279
311
  hints: hints.filter(([k]) => k !== "\u232B"),
280
312
  page: "nested",
281
313
  children: [
282
- /* @__PURE__ */ jsx2(Box2, { paddingLeft: 2, marginTop: 1, children: /* @__PURE__ */ jsx2(Text2, { dimColor: true, children: subtitle }) }),
314
+ /* @__PURE__ */ jsxs(Box, { paddingLeft: 2, children: [
315
+ /* @__PURE__ */ jsx2(Text, { dimColor: true, children: subtitle }),
316
+ moving === issue.key ? /* @__PURE__ */ jsx2(Text, { color: colors.accent, children: " \u22EF moving" }) : null
317
+ ] }),
318
+ flash ? /* @__PURE__ */ jsx2(Box, { paddingLeft: 2, children: /* @__PURE__ */ jsx2(Text, { color: colors.error, children: `\u2717 ${flash}` }) }) : null,
283
319
  /* @__PURE__ */ jsx2(
284
- Box2,
320
+ Box,
285
321
  {
286
322
  flexDirection: "column",
287
323
  marginTop: 1,
@@ -298,6 +334,7 @@ var App = ({ data, initialScreen, initialKey }) => {
298
334
  onAssign: () => setOverlay({ kind: "assign" }),
299
335
  onComment: () => setOverlay({ kind: "comment" }),
300
336
  onTransition: () => {
337
+ if (moving) return;
301
338
  void (async () => {
302
339
  setBusy("Loading transitions\u2026");
303
340
  try {
@@ -318,14 +355,28 @@ var App = ({ data, initialScreen, initialKey }) => {
318
355
  IssueBoard,
319
356
  {
320
357
  model,
321
- frame: ({ facts, hints, body }) => /* @__PURE__ */ jsx2(Frame, { width, height, facts, hints, children: body }),
358
+ parents,
359
+ frame: ({ title, hints, body }) => /* @__PURE__ */ jsx2(
360
+ Frame,
361
+ {
362
+ width,
363
+ height,
364
+ count: title.count,
365
+ user: title.user,
366
+ scope: title.scope,
367
+ status: title.status,
368
+ hints,
369
+ gap: false,
370
+ children: body
371
+ }
372
+ ),
322
373
  onInputFocus: setInputFocused,
323
374
  viewer,
324
375
  loadedAt,
325
376
  scope,
326
377
  searchError,
327
378
  width,
328
- height: height - FRAME_CHROME - 1,
379
+ height: height - (FRAME_CHROME - 1) - 1,
329
380
  showingAll,
330
381
  onOpen: (key) => void loadIssue(key),
331
382
  onRefresh: () => void (scope.kind === "search" ? runSearch(scope.query, scope.mode) : loadList(showingAll)),
@@ -347,27 +398,39 @@ import { searchJql } from "@kud/jira";
347
398
  import {
348
399
  boardOf,
349
400
  issueDetailOf,
350
- transitionsOf
401
+ parentsOf,
402
+ transitionsOf,
403
+ withBehind
351
404
  } from "@kud/jira-ink";
352
405
  var DEFAULT_SCOPE = "(statusCategory != Done OR (statusCategory = Done AND updated >= -14d))";
353
406
  var boardOptions = (ctx) => ({
354
407
  ...ctx.config.tabs ? { tabs: ctx.config.tabs } : {},
355
408
  ...ctx.board ?? ctx.config.defaultBoard !== void 0 ? { board: ctx.board ?? ctx.config.defaultBoard } : {}
356
409
  });
410
+ var marked = (model) => ({
411
+ ...model,
412
+ rows: withBehind(model.rows, model.tabs)
413
+ });
357
414
  var liveData = (ctx = context()) => ({
358
415
  baseUrl: ctx.config.baseUrl,
359
- board: (all) => boardOf(
360
- ctx.client,
361
- `assignee = currentUser()${all ? "" : ` AND ${DEFAULT_SCOPE}`} ORDER BY updated DESC`,
362
- boardOptions(ctx)
416
+ board: async (all) => marked(
417
+ await boardOf(
418
+ ctx.client,
419
+ `assignee = currentUser()${all ? "" : ` AND ${DEFAULT_SCOPE}`} ORDER BY updated DESC`,
420
+ boardOptions(ctx)
421
+ )
363
422
  ),
423
+ parents: (rows) => parentsOf(ctx.client, rows),
364
424
  me: async () => ({ displayName: (await ctx.client.getMe()).displayName }),
365
425
  search: async (query, mode) => {
366
426
  const { jql, mode: used } = searchJql(query, {
367
427
  mode,
368
428
  scope: "assignee = currentUser()"
369
429
  });
370
- return { model: await boardOf(ctx.client, jql, boardOptions(ctx)), mode: used };
430
+ return {
431
+ model: marked(await boardOf(ctx.client, jql, boardOptions(ctx))),
432
+ mode: used
433
+ };
371
434
  },
372
435
  getIssue: (key) => issueDetailOf(ctx.client, ctx.config.baseUrl, key),
373
436
  getTransitions: (key) => transitionsOf(ctx.client, key),
@@ -479,11 +542,25 @@ var mockData = () => ({
479
542
  }
480
543
  };
481
544
  },
545
+ // Nobody's epic is missing from the mock board, so the lookup has nothing
546
+ // to find — which is the honest answer here rather than an invented fence.
547
+ parents: async () => [],
482
548
  getIssue: async (key) => DETAIL[key] ?? fallbackDetail(key),
549
+ // The status ids match the mock board's own, so a transition here actually
550
+ // lands the row in the tab it names — a mock whose move goes nowhere cannot
551
+ // demonstrate the one thing the move is for.
483
552
  getTransitions: async () => [
484
- { id: "11", name: "Start progress", to: "In Progress" },
485
- { id: "21", name: "Ready for review", to: "In Review" },
486
- { id: "31", name: "Done", to: "Done" }
553
+ {
554
+ id: "11",
555
+ name: "Start progress",
556
+ to: { id: "10001", name: "In Progress", category: "indeterminate" }
557
+ },
558
+ {
559
+ id: "21",
560
+ name: "Ready for review",
561
+ to: { id: "10002", name: "In Review", category: "indeterminate" }
562
+ },
563
+ { id: "31", name: "Done", to: { id: "10003", name: "Done", category: "done" } }
487
564
  ],
488
565
  transition: async () => {
489
566
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kud/jira-cli",
3
- "version": "0.6.1",
3
+ "version": "0.7.0",
4
4
  "type": "module",
5
5
  "description": "Jira on the command line — read issues, comments and attachments as plain text",
6
6
  "keywords": [
@@ -37,9 +37,9 @@
37
37
  "prepublishOnly": "npm run build"
38
38
  },
39
39
  "dependencies": {
40
- "@kud/ink-ui": "0.27.0",
40
+ "@kud/ink-ui": "0.28.2",
41
41
  "@kud/jira": "0.4.0",
42
- "@kud/jira-ink": "0.4.3",
42
+ "@kud/jira-ink": "0.10.0",
43
43
  "commander": "14.0.1",
44
44
  "ink": "7.1.1",
45
45
  "react": "19.2.5"