ccdeck 3.47.0 → 3.48.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 (34) hide show
  1. package/README.md +27 -3
  2. package/bin/cli/commands.js +17 -9
  3. package/bin/cli/help.js +9 -4
  4. package/bin/cli/second-start.js +4 -2
  5. package/bin/cli/startup.js +3 -2
  6. package/bin/cli/tui.js +544 -0
  7. package/dist/web/assets/BrowserWatchModal-DuopT2Oa.js +1 -0
  8. package/dist/web/assets/IntegrationModal-CszT-tts.js +7 -0
  9. package/dist/web/assets/{RadioPanel-DbmJJPsz.js → RadioPanel-Cn3WvPUG.js} +1 -1
  10. package/dist/web/assets/{TrafficRadar-CPjAXd5e.js → TrafficRadar-DZA8XSi7.js} +1 -1
  11. package/dist/web/assets/UsageHistoryModal-MgZJLXbF.js +1 -0
  12. package/dist/web/assets/app-DjlHxWHg.css +1 -0
  13. package/dist/web/assets/app-F1xryJpn.js +321 -0
  14. package/dist/web/assets/{index-Ca87aJP9.js → index-BK9avF1k.js} +1 -1
  15. package/dist/web/index.html +3 -3
  16. package/package.json +1 -1
  17. package/release-notes.json +28 -2
  18. package/src/server/args.mjs +1 -0
  19. package/src/server/cli-lines.mjs +46 -0
  20. package/src/server/gpu-metrics.mjs +78 -0
  21. package/src/server/integrations/jira-move.mjs +239 -0
  22. package/src/server/integrations/jira.mjs +30 -8
  23. package/src/server/integrations/proxy.mjs +3 -4
  24. package/src/server/integrations/routes.mjs +19 -5
  25. package/src/server/system-metrics.mjs +4 -0
  26. package/src/server/term.mjs +14 -5
  27. package/src/server/tui-screen.mjs +110 -0
  28. package/src/server/tui-view.mjs +1072 -0
  29. package/src/server/way-back.mjs +27 -0
  30. package/dist/web/assets/BrowserWatchModal-Bau0ttnH.js +0 -1
  31. package/dist/web/assets/IntegrationModal-8tTi25gA.js +0 -6
  32. package/dist/web/assets/UsageHistoryModal-qfmvXdWJ.js +0 -1
  33. package/dist/web/assets/app-BFFG6Wz8.js +0 -321
  34. package/dist/web/assets/app-DfcfHvcX.css +0 -1
@@ -83,12 +83,15 @@ export function colorProfile({ env = process.env, isTTY = false, platform = proc
83
83
  // ── colours ──────────────────────────────────────────────────────────────────
84
84
 
85
85
  /** rgb → the nearest xterm-256 index: the 6×6×6 cube, or the 24-step grey ramp
86
- * for anything neutral, which is where the muted tones land. */
86
+ * for anything neutral, which is where the muted tones land. Neutral is near
87
+ * grey, not exactly grey: the muted tone is a cool grey, and the cube's
88
+ * nearest to it is a teal — every border and every quiet word, under tmux. */
87
89
  function to256(r, g, b) {
88
- if (r === g && g === b) {
89
- if (r < 8) return 16;
90
- if (r > 248) return 231;
91
- return Math.round(((r - 8) / 247) * 24) + 232;
90
+ if (Math.max(r, g, b) - Math.min(r, g, b) < 16) {
91
+ const v = Math.round((r + g + b) / 3);
92
+ if (v < 8) return 16;
93
+ if (v > 248) return 231;
94
+ return Math.round(((v - 8) / 247) * 24) + 232;
92
95
  }
93
96
  return 16 + 36 * Math.round((r / 255) * 5) + 6 * Math.round((g / 255) * 5) + Math.round((b / 255) * 5);
94
97
  }
@@ -189,6 +192,12 @@ const ASCII_GLYPHS = {
189
192
  arrow: "->", ellipsis: "...", dash: "-", bullet: "-",
190
193
  };
191
194
 
195
+ /** Whether this shell came in over SSH: sshd sets one of these in every
196
+ * session it starts, interactive or not. */
197
+ export function overSsh(env = process.env) {
198
+ return set(env.SSH_CONNECTION) || set(env.SSH_CLIENT) || set(env.SSH_TTY);
199
+ }
200
+
192
201
  /**
193
202
  * Whether this terminal can be trusted with the box-drawing and arrow glyphs.
194
203
  *
@@ -0,0 +1,110 @@
1
+ // The terminal `ccdeck tui` draws on: the alternate screen, painted a row at a
2
+ // time, and handed back exactly as it was found.
3
+ //
4
+ // THE ALTERNATE SCREEN, so the view never scrolls the shell's own history away
5
+ // and leaves nothing behind when it closes — what `less`, `top` and every
6
+ // editor do. Wrapping is turned off for as long as the view is up: a row one
7
+ // column too wide would otherwise push every row under it down by one, and the
8
+ // view would go on painting rows that are no longer where it thinks they are.
9
+ //
10
+ // ONLY THE ROWS THAT CHANGED are written, each addressed by its row and cleared
11
+ // to its end, so a refresh every second over a slow SSH link sends a few bytes
12
+ // rather than the screen. A frame is written between the synchronized-output
13
+ // marks (DEC mode 2026): a terminal that knows them shows it whole, and one
14
+ // that does not ignores them, which is what an unknown private mode is for.
15
+ // Except on Windows, where every console is conhost's: it froze on the first
16
+ // frame held between the marks and drew the ones after it seconds later or
17
+ // only once the view was left (Windows 11 24H2, under sshd). Conhost draws the
18
+ // screen from its own copy of it anyway, so there no frame is held.
19
+ //
20
+ // ONE RUN OF TEXT MAY FLOW: a sign-in link is hundreds of characters, and cut
21
+ // into rows by us it is a link no terminal can click and no mouse can copy
22
+ // whole. So a frame can carry one `run`, written edge to edge with wrapping on,
23
+ // which the terminal wraps itself and knows to be one line. The rows it wrapped
24
+ // into stay marked as wrapped after it has gone, and a row still marked is
25
+ // joined to the one above it for selecting and for finding links. Erasing such
26
+ // a row from its first column takes the mark off in xterm.js, but not over
27
+ // conhost, which passes on only what changed; clearing the screen takes it off
28
+ // everywhere. So a frame that leaves a wrapped row behind is written whole.
29
+ //
30
+ // Pure in the sense that matters for a test: everything goes through `write`,
31
+ // and nothing reads the terminal.
32
+ import { CURSOR_HIDE, CURSOR_SHOW } from "./term.mjs";
33
+
34
+ export const ALT_SCREEN_ON = "\x1b[?1049h";
35
+ export const ALT_SCREEN_OFF = "\x1b[?1049l";
36
+ export const WRAP_OFF = "\x1b[?7l";
37
+ export const WRAP_ON = "\x1b[?7h";
38
+ export const SYNC_ON = "\x1b[?2026h";
39
+ export const SYNC_OFF = "\x1b[?2026l";
40
+ const RESET = "\x1b[0m";
41
+ const CLEAR = "\x1b[2J";
42
+ const HOME = "\x1b[H";
43
+
44
+ /** Whether a frame is held between the synchronized-output marks here. */
45
+ export const framesHeld = (platform = process.platform) => platform !== "win32";
46
+
47
+ /**
48
+ * A screen over `write`. `enter` takes the terminal, `paint(lines, run)` shows
49
+ * a frame, `invalidate` forgets what is on screen so the next frame is written
50
+ * whole (a resize, Ctrl+L), and `leave` puts the terminal back. `leave` is
51
+ * safe to call twice and before `enter`, since every way out calls it.
52
+ * `held` says whether a frame goes between the synchronized-output marks.
53
+ *
54
+ * `run` is `{ row, rows, text, full }`: `text` written from the start of `row`
55
+ * with wrapping on, over the `rows` rows whose `lines` are its pieces, and
56
+ * `full` when its last piece reaches the last column — the cursor waits there
57
+ * to wrap, and clearing the row from it would take the last character.
58
+ */
59
+ export function createScreen(write, { held = framesHeld() } = {}) {
60
+ let shown = null;
61
+ let shownRun = null;
62
+ let wrapped = new Set();
63
+ let on = false;
64
+ const send = (s) => {
65
+ try { write(s); } catch { /* the terminal went away; nothing left to draw on */ }
66
+ };
67
+ return {
68
+ get active() { return on; },
69
+ enter() {
70
+ on = true;
71
+ shown = null;
72
+ send(`${ALT_SCREEN_ON}${CURSOR_HIDE}${WRAP_OFF}${HOME}${CLEAR}`);
73
+ },
74
+ paint(lines, run = null) {
75
+ if (!on) return;
76
+ let out = "";
77
+ const flows = new Set(run ? Array.from({ length: run.rows - 1 }, (_, k) => run.row + 1 + k) : []);
78
+ if ([...wrapped].some(i => !flows.has(i))) shown = null;
79
+ const whole = shown == null;
80
+ if (whole) out += `${RESET}${HOME}${CLEAR}`;
81
+ const inRun = (i) => run != null && i >= run.row && i < run.row + run.rows;
82
+ for (let i = 0; i < lines.length; i++) {
83
+ if (inRun(i) || (!whole && shown[i] === lines[i])) continue;
84
+ // The reset before the clear, so the rest of the row is cleared in the
85
+ // terminal's own background rather than in the last colour drawn.
86
+ out += `\x1b[${i + 1};1H${lines[i]}${RESET}\x1b[K`;
87
+ }
88
+ if (run) {
89
+ let same = !whole && shownRun === run.text;
90
+ for (let i = run.row; same && i < run.row + run.rows; i++) same = shown[i] === lines[i];
91
+ if (!same) out += `\x1b[${run.row + 1};1H${RESET}${WRAP_ON}${run.text}${RESET}${WRAP_OFF}${run.full ? "" : "\x1b[K"}`;
92
+ }
93
+ // A frame shorter than the last one: the rows it no longer has.
94
+ if (!whole) for (let i = lines.length; i < shown.length; i++) out += `\x1b[${i + 1};1H\x1b[K`;
95
+ shown = lines.slice();
96
+ shownRun = run?.text ?? null;
97
+ wrapped = flows;
98
+ if (out) send(held ? `${SYNC_ON}${out}${SYNC_OFF}` : out);
99
+ },
100
+ invalidate() { shown = null; shownRun = null; },
101
+ leave() {
102
+ if (!on) return;
103
+ on = false;
104
+ shown = null;
105
+ shownRun = null;
106
+ wrapped = new Set();
107
+ send(`${held ? SYNC_OFF : ""}${RESET}${WRAP_ON}${CURSOR_SHOW}${ALT_SCREEN_OFF}`);
108
+ },
109
+ };
110
+ }