openalmanac 0.4.1 → 0.4.2
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/setup/tui.js +53 -32
- package/package.json +1 -1
package/dist/setup/tui.js
CHANGED
|
@@ -57,6 +57,54 @@ function stepActive(msg) {
|
|
|
57
57
|
// Strip ANSI codes to measure visible length
|
|
58
58
|
const vis = (s) => s.replace(/\x1b\[[0-9;]*m/g, "").length;
|
|
59
59
|
const w = (s) => process.stdout.write(s + "\n");
|
|
60
|
+
function getBoxInnerWidth(contents, minWidth = 62) {
|
|
61
|
+
const terminalWidth = process.stdout.columns ?? 80;
|
|
62
|
+
const available = Math.max(40, terminalWidth - 6);
|
|
63
|
+
const widest = contents.reduce((max, content) => Math.max(max, vis(content)), 0);
|
|
64
|
+
return Math.min(Math.max(minWidth, widest), available);
|
|
65
|
+
}
|
|
66
|
+
function boxRow(content, innerW) {
|
|
67
|
+
const padding = Math.max(0, innerW - vis(content));
|
|
68
|
+
return ` ${BLUE_DIM}\u2502${RST}${content}${" ".repeat(padding)}${BLUE_DIM}\u2502${RST}`;
|
|
69
|
+
}
|
|
70
|
+
function wrapWithPrefixes(text, firstPrefix, nextPrefix, innerW) {
|
|
71
|
+
const words = text.split(" ").filter(Boolean);
|
|
72
|
+
if (words.length === 0)
|
|
73
|
+
return [firstPrefix];
|
|
74
|
+
const lines = [];
|
|
75
|
+
let prefix = firstPrefix;
|
|
76
|
+
let line = prefix;
|
|
77
|
+
let hasWord = false;
|
|
78
|
+
for (const word of words) {
|
|
79
|
+
const candidate = hasWord ? `${line} ${word}` : `${prefix}${word}`;
|
|
80
|
+
if (hasWord && vis(candidate) > innerW) {
|
|
81
|
+
lines.push(line);
|
|
82
|
+
prefix = nextPrefix;
|
|
83
|
+
line = `${prefix}${word}`;
|
|
84
|
+
hasWord = true;
|
|
85
|
+
continue;
|
|
86
|
+
}
|
|
87
|
+
line = candidate;
|
|
88
|
+
hasWord = true;
|
|
89
|
+
}
|
|
90
|
+
lines.push(line);
|
|
91
|
+
return lines;
|
|
92
|
+
}
|
|
93
|
+
function renderNextStepsBox(lines) {
|
|
94
|
+
const header = ` ${WHITE_BOLD}Next steps${RST}`;
|
|
95
|
+
const innerW = getBoxInnerWidth([header, ...lines]);
|
|
96
|
+
const empty = boxRow("", innerW);
|
|
97
|
+
w(` ${BLUE_DIM}\u256d${"─".repeat(innerW)}\u256e${RST}`);
|
|
98
|
+
w(empty);
|
|
99
|
+
w(boxRow(header, innerW));
|
|
100
|
+
w(empty);
|
|
101
|
+
for (const line of lines) {
|
|
102
|
+
w(boxRow(line, innerW));
|
|
103
|
+
}
|
|
104
|
+
w(empty);
|
|
105
|
+
w(` ${BLUE_DIM}\u2570${"─".repeat(innerW)}\u256f${RST}`);
|
|
106
|
+
w("");
|
|
107
|
+
}
|
|
60
108
|
function renderClientSelect(clients, selected, cursor, mode = "default") {
|
|
61
109
|
process.stdout.write("\x1b[2J\x1b[H");
|
|
62
110
|
renderHeader(mode);
|
|
@@ -395,24 +443,9 @@ export function printResult(clientsLabel, loginResult, configured, alreadyConfig
|
|
|
395
443
|
w(BAR);
|
|
396
444
|
stepDone(`${BLUE}Setup complete${RST}`);
|
|
397
445
|
w("");
|
|
398
|
-
// Next steps box
|
|
399
|
-
const innerW = 62;
|
|
400
|
-
const row = (content) => {
|
|
401
|
-
const padding = Math.max(0, innerW - vis(content));
|
|
402
|
-
return ` ${BLUE_DIM}\u2502${RST}${content}${" ".repeat(padding)}${BLUE_DIM}\u2502${RST}`;
|
|
403
|
-
};
|
|
404
|
-
const empty = row("");
|
|
405
446
|
const nextSteps = getNextSteps(clientsLabel);
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
w(row(` ${WHITE_BOLD}Next steps${RST}`));
|
|
409
|
-
w(empty);
|
|
410
|
-
for (let i = 0; i < nextSteps.length; i++) {
|
|
411
|
-
w(row(` ${BLUE}${i + 1}.${RST} ${nextSteps[i]}`));
|
|
412
|
-
}
|
|
413
|
-
w(empty);
|
|
414
|
-
w(` ${BLUE_DIM}\u2570${"─".repeat(innerW)}\u256f${RST}`);
|
|
415
|
-
w("");
|
|
447
|
+
const nextStepLines = nextSteps.flatMap((step, i) => wrapWithPrefixes(step, ` ${BLUE}${i + 1}.${RST} `, " ", 62));
|
|
448
|
+
renderNextStepsBox(nextStepLines);
|
|
416
449
|
}
|
|
417
450
|
function getNextSteps(clientsLabel) {
|
|
418
451
|
const exampleLine = `${BLUE}"${EXAMPLE_PROMPT}"${RST}`;
|
|
@@ -477,20 +510,8 @@ export function printRedditResult(agent, loginResult, mcpChanged, toolCount) {
|
|
|
477
510
|
w(BAR);
|
|
478
511
|
stepDone(`${BLUE}Setup complete${RST}`);
|
|
479
512
|
w("");
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
const padding = Math.max(0, innerW - vis(content));
|
|
484
|
-
return ` ${BLUE_DIM}\u2502${RST}${content}${" ".repeat(padding)}${BLUE_DIM}\u2502${RST}`;
|
|
485
|
-
};
|
|
486
|
-
const empty = row("");
|
|
487
|
-
w(` ${BLUE_DIM}\u256d${"─".repeat(innerW)}\u256e${RST}`);
|
|
488
|
-
w(empty);
|
|
489
|
-
w(row(` ${WHITE_BOLD}Next steps${RST}`));
|
|
490
|
-
w(empty);
|
|
491
|
-
w(row(` ${BLUE}1.${RST} Type ${WHITE_BOLD}claude${RST} to start Claude Code`));
|
|
492
|
-
w(empty);
|
|
493
|
-
w(` ${BLUE_DIM}\u2570${"─".repeat(innerW)}\u256f${RST}`);
|
|
494
|
-
w("");
|
|
513
|
+
renderNextStepsBox([
|
|
514
|
+
` ${BLUE}1.${RST} Type ${WHITE_BOLD}claude${RST} to start Claude Code`,
|
|
515
|
+
]);
|
|
495
516
|
}
|
|
496
517
|
/* ── Reddit entry point ────────────────────────────────────────── */
|