@retasc/cli 1.15.0 → 1.16.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/CHANGELOG.md CHANGED
@@ -6,6 +6,28 @@ release commits and the issues they reference.
6
6
 
7
7
  Dates are the npm publish date. Each entry names the RTSC issue behind it.
8
8
 
9
+ ## 1.16.0 (2026-08-02)
10
+
11
+ - **RTSC-526** — `retasc import` catches up with the Dash on four things.
12
+
13
+ **It warns before a second import.** Re-importing does not duplicate anything, but it
14
+ does re-sync: status, labels, title and body are replaced with whatever the source says
15
+ now. Import from Jira, spend two weeks moving issues along in Retasc, re-import to pick up
16
+ new tickets, and those two weeks of changes snap back. You now get told, with the date of
17
+ the last import, before the confirmation.
18
+
19
+ **The run shows progress**, as a bar that fills while it works, rather than a silent wait
20
+ that looks like it has hung. The run is server-side, so pressing Ctrl-C out of boredom
21
+ never stopped it anyway.
22
+
23
+ **The column list is grouped** under your own tool's sections (Not started, Active, Done,
24
+ Closed) instead of arriving flat. On a twenty-column board that is the difference between
25
+ scannable and a wall.
26
+
27
+ **Columns that were not mapped are named.** If a column appears between the moment you set
28
+ the mapping and the moment the import runs, its issues land in `todo`. They used to show
29
+ as a number; now they are listed, with what to do about it.
30
+
9
31
  ## 1.15.0 (2026-08-02)
10
32
 
11
33
  - **RTSC-524** — new command: `retasc import`. Bring a Linear, Jira, Asana, ClickUp or
package/dist/api.js CHANGED
@@ -35,6 +35,11 @@ const fns = {
35
35
  listImportStatuses: makeFunctionReference("import:listImportStatuses"),
36
36
  listReviewCandidates: makeFunctionReference("import:listReviewCandidates"),
37
37
  runImport: makeFunctionReference("import:runImport"),
38
+ // RTSC-526: `latestImport` is LIVE progress and is swept after 24h; `importHistory` is
39
+ // permanent and per source, so it is the only thing that can answer "has this org
40
+ // imported from X before?" once the progress row is gone.
41
+ latestImport: makeFunctionReference("import:latestImport"),
42
+ importHistory: makeFunctionReference("import:importHistory"),
38
43
  claimableGhosts: makeFunctionReference("ghosts:claimableGhosts"),
39
44
  claimGhost: makeFunctionReference("ghosts:claimGhost"),
40
45
  dismissGhostPrompt: makeFunctionReference("ghosts:dismissGhostPrompt"),
@@ -171,6 +176,8 @@ export const api = {
171
176
  listImportStatuses: (args) => withAuth(() => client().action(fns.listImportStatuses, args)),
172
177
  listReviewCandidates: (args) => withAuth(() => client().query(fns.listReviewCandidates, args)),
173
178
  runImport: (args) => withAuth(() => client().action(fns.runImport, args)),
179
+ latestImport: (args) => withAuth(() => client().query(fns.latestImport, args)),
180
+ importHistory: (args) => withAuth(() => client().query(fns.importHistory, args)),
174
181
  claimableGhosts: (args) => withAuth(() => client().query(fns.claimableGhosts, args)),
175
182
  claimGhost: (args) => withAuth(() => client().mutation(fns.claimGhost, args)),
176
183
  dismissGhostPrompt: (args) => withAuth(() => client().mutation(fns.dismissGhostPrompt, args)),
@@ -6,6 +6,91 @@ import { ask, confirm, isInteractive } from "../lib/prompt.js";
6
6
  import { pickExisting } from "./bind.js";
7
7
  /** The five destinations a column can be mapped to. Mirrors `MappedStatus`. */
8
8
  const MAPPED = ["todo", "doing", "review", "done", "canceled"];
9
+ /**
10
+ * The source's own section names, so the list reads as the shape the human already knows
11
+ * from their tool. Mirrors `GROUP_LABEL` in `dash/src/lib/statusMapping.ts` (RTSC-436).
12
+ */
13
+ const GROUP_LABEL = {
14
+ not_started: "Not started",
15
+ active: "Active",
16
+ done: "Done",
17
+ closed: "Closed",
18
+ };
19
+ /** Section order, matching the Dash. */
20
+ const GROUP_ORDER = ["not_started", "active", "done", "closed"];
21
+ /**
22
+ * What to say before a SECOND import into the same org (RTSC-526).
23
+ *
24
+ * Not a formality. `convex/importWrite.ts` upserts by `sourceIssueId` and patches the match,
25
+ * so a re-import does not duplicate — the identifier and number survive even a rename — but
26
+ * it DOES replace status, labels, title and body with whatever the source says now. Two
27
+ * weeks of moving issues along in Retasc snap back to the source's version.
28
+ *
29
+ * Read from `importHistory`, NOT `latestImport`. The latter is live progress and is swept
30
+ * after 24h, so gating on it means the warning stops firing for exactly the person most at
31
+ * risk: the one who imported last week and has been working in Retasc since.
32
+ *
33
+ * Null when this source has never been imported, so a first run says nothing.
34
+ */
35
+ export function reimportWarning(history, source, label) {
36
+ const prior = history.find((h) => h.source === source);
37
+ if (!prior)
38
+ return null;
39
+ const when = prior.lastImportedAt
40
+ ? ` (last on ${new Date(prior.lastImportedAt).toISOString().slice(0, 10)})`
41
+ : "";
42
+ return (`\n! You've imported from ${clean(label)} into this org before${when}.\n` +
43
+ ` Re-importing re-syncs those issues, so any edits you made in Retasc to them\n` +
44
+ ` (status, labels, and so on) will be replaced by ${clean(label)}'s version.`);
45
+ }
46
+ /**
47
+ * The summary after a run, with the one field that needs words rather than a number.
48
+ *
49
+ * `unmappedStatuses` holds columns that appeared BETWEEN the mapping being set and the run;
50
+ * their issues landed in `todo`. As a count it is a silent slice of work in the wrong place,
51
+ * which is the whole reason the Dash names them.
52
+ */
53
+ export function summaryLines(summary, label) {
54
+ const out = [];
55
+ const unmapped = [];
56
+ for (const [k, v] of Object.entries(summary ?? {})) {
57
+ if (k === "unmappedStatuses") {
58
+ if (Array.isArray(v))
59
+ unmapped.push(...v.map(String));
60
+ continue;
61
+ }
62
+ if (typeof v === "number" || typeof v === "string")
63
+ out.push(` ${k.padEnd(20)}${clean(v)}`);
64
+ }
65
+ if (unmapped.length) {
66
+ out.push("", `! These ${clean(label)} statuses weren't mapped, so their issues landed in todo:`, ` ${unmapped.map((u) => clean(u)).join(", ")}`, " They appeared after you set the mapping. Re-import to place them.");
67
+ }
68
+ return out;
69
+ }
70
+ // --- the progress bar --------------------------------------------------------
71
+ /** Lime, in 256-colour. Bright enough to read on both a light and a dark terminal. */
72
+ const LIME = "\x1b[38;5;154m";
73
+ const DIM = "\x1b[38;5;240m";
74
+ const RESET = "\x1b[0m";
75
+ /**
76
+ * One line of progress bar.
77
+ *
78
+ * Pure, so the shape can be tested without a terminal. Colour is opt-out via `color`, which
79
+ * the caller ties to a TTY and to `NO_COLOR` — a bar full of escape sequences in a piped log
80
+ * is worse than no bar.
81
+ */
82
+ export function progressBar(done, total, width = 24, color = true) {
83
+ const known = typeof total === "number" && total > 0;
84
+ // Clamp: a server that reports more done than total must not print a bar wider than the
85
+ // terminal, or a negative one.
86
+ const frac = known ? Math.max(0, Math.min(1, done / total)) : 0;
87
+ const filled = Math.round(frac * width);
88
+ const bar = known
89
+ ? `${color ? LIME : ""}${"█".repeat(filled)}${color ? DIM : ""}${"░".repeat(width - filled)}${color ? RESET : ""}`
90
+ : `${color ? DIM : ""}${"░".repeat(width)}${color ? RESET : ""}`;
91
+ const count = known ? `${Math.round(frac * 100)}% ${done}/${total}` : `${done} so far`;
92
+ return ` ${bar} ${count}`;
93
+ }
9
94
  /**
10
95
  * May this column be mapped to `review`?
11
96
  *
@@ -83,8 +168,16 @@ export async function mapStatuses(statuses, reviewers, askFn) {
83
168
  const reviewerByStatus = {};
84
169
  console.log(`\nWhat does each column mean? ${statuses.length} to confirm.\n` +
85
170
  " Enter keeps the suggestion. It comes from the column's type in your tool, not its name.");
86
- // The source's own order, so the list reads the way it does in the tool they know.
87
- for (const s of [...statuses].sort((a, b) => a.order - b.order)) {
171
+ // Grouped under the source's own section names, in the source's own order within each
172
+ // (RTSC-436/526). On a twenty-column Jira board a flat list is a wall; the sections are
173
+ // the shape the human already has in front of them in their tool.
174
+ const ordered = GROUP_ORDER.flatMap((g) => {
175
+ const rows = statuses.filter((s) => s.group === g).sort((a, b) => a.order - b.order);
176
+ return rows.map((s, i) => ({ s, heading: i === 0 ? GROUP_LABEL[g] : null }));
177
+ });
178
+ for (const { s, heading } of ordered) {
179
+ if (heading)
180
+ console.log(`\n ${heading}`);
88
181
  const allowed = MAPPED.filter((m) => m !== "review" || (reviewAllowed(s.group) && reviewers.length > 0));
89
182
  const suggested = allowed.includes(s.suggested)
90
183
  ? s.suggested
@@ -119,6 +212,43 @@ export async function mapStatuses(statuses, reviewers, askFn) {
119
212
  }
120
213
  return { statusMap, reviewerByStatus };
121
214
  }
215
+ /**
216
+ * Poll `latestImport` and redraw one line until told to stop. Returns the stopper.
217
+ *
218
+ * One LINE, rewritten in place, rather than a scrolling log: the interesting number is the
219
+ * current one. Silent without a TTY — a progress bar in a piped log is noise, and the
220
+ * escape codes would end up in whatever reads it.
221
+ *
222
+ * Every failure here is swallowed. This is decoration on top of a run that is happening
223
+ * server-side regardless; a hiccup in the progress query must never be what surfaces as an
224
+ * import failure.
225
+ */
226
+ function followProgress(orgId) {
227
+ const tty = Boolean(stdout.isTTY) && !process.env.NO_COLOR;
228
+ if (!stdout.isTTY)
229
+ return () => { };
230
+ let stopped = false;
231
+ const tick = async () => {
232
+ while (!stopped) {
233
+ try {
234
+ const p = (await api.latestImport({ orgId }));
235
+ if (!stopped && p && p.status === "running") {
236
+ stdout.write(`\r\x1b[2K${progressBar(p.issuesDone ?? 0, p.issuesTotal ?? null, 24, tty)}`);
237
+ }
238
+ }
239
+ catch {
240
+ /* progress is decoration; never let it speak for the run */
241
+ }
242
+ await new Promise((r) => setTimeout(r, 1200));
243
+ }
244
+ };
245
+ void tick();
246
+ return () => {
247
+ stopped = true;
248
+ // Clear the line so the summary does not land on top of a half-drawn bar.
249
+ stdout.write("\r\x1b[2K");
250
+ };
251
+ }
122
252
  export async function importAction(opts) {
123
253
  if (!isInteractive() && !opts.yes) {
124
254
  cliError("NEEDS_TERMINAL", "Importing asks what each of your columns means, so it needs a terminal.", "Run it interactively, or use the Dash.");
@@ -182,12 +312,24 @@ export async function importAction(opts) {
182
312
  // undoing a mistake means an org-level cleanup.
183
313
  console.log(`\nAbout to import ${clean(target.name)} from ${clean(src.label)} into org ${orgLabel},\n` +
184
314
  `as a new project. Issues, comments and their authors come across.`);
315
+ // RTSC-526 — the second run is the dangerous one, and the terminal is where a command
316
+ // gets re-run casually. Read from `importHistory` (permanent) rather than `latestImport`
317
+ // (live progress, swept after 24h), so this still fires for someone who imported last
318
+ // week and has been working in Retasc since — the person with the most to lose.
319
+ const history = (await api.importHistory({ orgId: orgId }));
320
+ const warning = reimportWarning(history, src.source, src.label);
321
+ if (warning)
322
+ console.log(warning);
185
323
  if (!opts.yes && !(await confirm("This can't be undone. Go ahead?"))) {
186
324
  console.log("Nothing imported.");
187
325
  return;
188
326
  }
189
327
  // --- run -------------------------------------------------------------------
190
- console.log("\nImporting. This can take a few minutes on a big project…");
328
+ console.log("\nImporting…\n");
329
+ // RTSC-526 — show it moving. The run is server-side and can take minutes on a big
330
+ // project; a silent wait is exactly when someone decides it has hung and presses Ctrl-C,
331
+ // which is the worst moment to do it because the server keeps going regardless.
332
+ const stop = followProgress(orgId);
191
333
  let res;
192
334
  try {
193
335
  res = (await api.runImport({
@@ -200,6 +342,7 @@ export async function importAction(opts) {
200
342
  }));
201
343
  }
202
344
  catch (e) {
345
+ stop();
203
346
  // The run is server-side, so a dead connection here does NOT mean a dead import.
204
347
  // Saying "failed" would be a guess, and the wrong one sends someone re-importing on
205
348
  // top of a run that is still writing.
@@ -211,10 +354,10 @@ export async function importAction(opts) {
211
354
  console.error(" Check the Dash before running it again.");
212
355
  throw e;
213
356
  }
357
+ stop();
214
358
  console.log("\n✓ Imported.");
215
- for (const [k, v] of Object.entries(res.summary ?? {})) {
216
- if (typeof v === "number" || typeof v === "string")
217
- console.log(` ${k.padEnd(18)}${clean(v)}`);
359
+ for (const line of summaryLines(res.summary, src.label)) {
360
+ console.log(line);
218
361
  }
219
362
  // The import just minted a placeholder for whoever authored that work, and the person
220
363
  // who ran it is very often one of them. `identityLoop` is the same prompt `join` uses and
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@retasc/cli",
3
- "version": "1.15.0",
3
+ "version": "1.16.0",
4
4
  "description": "Retasc CLI \u2014 the issue tracker AI agents pull work from. Sign in with GitHub or Google, create projects, mint agent API keys, and wire your agent to the Retasc MCP server in one command.",
5
5
  "type": "module",
6
6
  "bin": {