Package not found. Please check the package name and try again.

@sns-myagent/cli 0.3.5 → 0.3.6

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "type": "module",
3
3
  "name": "@sns-myagent/cli",
4
- "version": "0.3.5",
4
+ "version": "0.3.6",
5
5
  "description": "SNS-MyAgent \u2014 BYOK coding agent CLI. Multi-agent + Telegram + self-learning memory. ~120MB binary, zero forced cost.",
6
6
  "homepage": "https://github.com/Reihantt6/sns-myagent",
7
7
  "author": "Reihantt6",
@@ -11,15 +11,8 @@ import { renderChatBlock, renderSessionHeader } from "../src/tui/chat-blocks.js"
11
11
  import { CHAT_COMMANDS, renderCommandPalette } from "../src/tui/command-palette.js";
12
12
  import { renderErrorDisplay } from "../src/ui/error-display.js";
13
13
  import { renderMemoryToast, renderMemoryRecall } from "../src/ui/memory-toast.js";
14
- import {
15
- brand,
16
- accentGrad,
17
- subtle,
18
- gradientLine,
19
- labeledGradientLine,
20
- roleGradient,
21
- statusGradient,
22
- } from "../src/ui/gradient.js";
14
+ import { renderStatusBar } from "../src/ui/status-bar.js";
15
+ import { accent, brand, subtle, inline } from "../src/ui/gradient.js";
23
16
 
24
17
  // Stub stdout.columns so width-dependent renderers behave deterministically.
25
18
  Object.defineProperty(process.stdout, "columns", { value: 100, configurable: true });
@@ -69,7 +62,7 @@ console.log(
69
62
  );
70
63
 
71
64
  section("3. SESSION HEADER");
72
- console.log(renderSessionHeader("openai/gpt-4o-mini", "0.3.4"));
65
+ console.log(renderSessionHeader("openai/gpt-4o-mini", "0.3.5"));
73
66
 
74
67
  section("4. COMMAND PALETTE");
75
68
  console.log(
@@ -99,16 +92,19 @@ console.log(
99
92
  renderMemoryRecall("dark theme", "user prefers dark theme for terminal UI", 0.92),
100
93
  );
101
94
 
102
- section("7. GRADIENT HELPERS");
103
- console.log("brand: ", brand("SnsAgent — premium CLI"));
104
- console.log("accentGrad: ", accentGrad("accent gradient text"));
105
- console.log("subtle: ", subtle("subtle gradient"));
106
- console.log("gradientLine: ", gradientLine(60));
107
- console.log("labeledLine: ", labeledGradientLine("VERIFIED", 60));
108
- console.log("roleGradient: ", roleGradient("assistant")("assistant message border"));
109
- console.log("statusGradient(success):", statusGradient("success")("✓ ok"));
110
- console.log("statusGradient(warning):", statusGradient("warning")("⚠ warning"));
111
- console.log("statusGradient(error): ", statusGradient("error")("✗ failed"));
112
- console.log("statusGradient(info): ", statusGradient("info")("ℹ info"));
95
+ section("8. STATUS BAR");
96
+ renderStatusBar({
97
+ model: "gpt-4o-mini",
98
+ tokensUsed: 12345,
99
+ sessionStarted: Date.now() - 10_000,
100
+ memoryHits: 3,
101
+ });
102
+ console.log(); // newline after status bar (renderStatusBar writes to stdout directly)
113
103
 
114
- console.log("\n\x1b[1m\x1b[32m✓ All 7 TUI components rendered without crashing.\x1b[0m");
104
+ section("9. GRADIENT HELPERS (minimal)");
105
+ console.log("brand: ", brand("SnsAgent — coding agent CLI"));
106
+ console.log("accent: ", accent("accent cyan"));
107
+ console.log("subtle: ", subtle("dim text"));
108
+ console.log("inline: ", inline("file.ts:42"));
109
+
110
+ console.log("\n\x1b[1m\x1b[32m✓ All 7 TUI components rendered without crashing.\x1b[0m");
@@ -1,205 +1,148 @@
1
1
  /**
2
- * Chat message block renderers — bordered terminal blocks for each message role.
3
- * User, assistant, tool, system messages each get distinct gradient border treatment.
4
- * Premium branded terminal UI for SNS-MyAgent.
2
+ * Chat message block renderers — single-accent bordered blocks.
3
+ * One border style (rounded), one accent color (cyan). No role-specific
4
+ * rainbow. Per-role distinction via bold label only.
5
5
  */
6
6
  import chalk from "chalk";
7
- import gradient from "gradient-string";
8
7
  import { visibleWidth } from "@oh-my-pi/pi-tui";
9
- import { BRAND_GRADIENT, ROLE_HEX } from "#src/ui/colors.js";
10
8
 
11
- // ── Box-drawing chars (rounded) ──
12
9
  const BOX = {
13
- topLeft: "╭",
14
- topRight: "╮",
15
- bottomLeft: "╰",
16
- bottomRight: "╯",
17
- horizontal: "─",
18
- vertical: "│",
19
- teeRight: "├",
20
- teeLeft: "┤",
10
+ topLeft: "╭",
11
+ topRight: "╮",
12
+ bottomLeft: "╰",
13
+ bottomRight: "╯",
14
+ horizontal: "─",
15
+ vertical: "│",
21
16
  } as const;
22
17
 
23
- // ── Color themes per role ──
24
- const ROLE_COLORS = {
25
- user: { border: chalk.cyan, label: chalk.cyan.bold, gradient: [ROLE_HEX.user, "#0099cc"] },
26
- assistant: { border: chalk.magenta, label: chalk.magenta.bold, gradient: [ROLE_HEX.assistant, "#9b59b6"] },
27
- tool: { border: chalk.yellow, label: chalk.yellow, gradient: [ROLE_HEX.tool, "#e6a700"] },
28
- system: { border: chalk.dim, label: chalk.dim, gradient: [ROLE_HEX.system, "#555555"] },
29
- error: { border: chalk.red, label: chalk.red.bold, gradient: [ROLE_HEX.error, "#cc0000"] },
30
- } as const;
18
+ const ACCENT = chalk.cyan;
19
+
20
+ export type MessageRole = "user" | "assistant" | "tool" | "system" | "error";
31
21
 
32
- export type MessageRole = keyof typeof ROLE_COLORS;
22
+ const ROLE_LABEL: Record<MessageRole, string> = {
23
+ user: "you",
24
+ assistant: "snsagent",
25
+ tool: "tool",
26
+ system: "system",
27
+ error: "error",
28
+ };
33
29
 
34
30
  export interface ChatBlockOptions {
35
- role: MessageRole;
36
- label?: string;
37
- content: string;
38
- width?: number;
39
- meta?: string;
40
- streaming?: boolean;
31
+ role: MessageRole;
32
+ label?: string;
33
+ content: string;
34
+ width?: number;
35
+ meta?: string;
36
+ streaming?: boolean;
41
37
  }
42
38
 
43
- /**
44
- * Word-wrap text respecting ANSI escape sequences.
45
- * Returns array of lines fitting within `maxWidth` visible columns.
46
- */
47
39
  function wrapAnsi(text: string, maxWidth: number): string[] {
48
- const lines: string[] = [];
49
- for (const rawLine of text.split("\n")) {
50
- if (visibleWidth(rawLine) <= maxWidth) {
51
- lines.push(rawLine);
52
- continue;
53
- }
54
- // Simple word-wrap
55
- let current = "";
56
- let currentWidth = 0;
57
- const words = rawLine.split(/(\s+)/);
58
- for (const word of words) {
59
- const wWidth = visibleWidth(word);
60
- if (currentWidth + wWidth > maxWidth && current.length > 0) {
61
- lines.push(current);
62
- current = word.trimStart();
63
- currentWidth = visibleWidth(current);
64
- } else {
65
- current += word;
66
- currentWidth += wWidth;
67
- }
68
- }
69
- if (current.length > 0) lines.push(current);
70
- }
71
- return lines;
40
+ const lines: string[] = [];
41
+ for (const rawLine of text.split("\n")) {
42
+ if (visibleWidth(rawLine) <= maxWidth) {
43
+ lines.push(rawLine);
44
+ continue;
45
+ }
46
+ let current = "";
47
+ let currentWidth = 0;
48
+ const words = rawLine.split(/(\s+)/);
49
+ for (const word of words) {
50
+ const wWidth = visibleWidth(word);
51
+ if (currentWidth + wWidth > maxWidth && current.length > 0) {
52
+ lines.push(current);
53
+ current = word.trimStart();
54
+ currentWidth = visibleWidth(current);
55
+ } else {
56
+ current += word;
57
+ currentWidth += wWidth;
58
+ }
59
+ }
60
+ if (current.length > 0) lines.push(current);
61
+ }
62
+ return lines;
72
63
  }
73
64
 
74
- /**
75
- * Render a single chat message as a bordered block with gradient border.
76
- */
77
65
  export function renderChatBlock(opts: ChatBlockOptions): string {
78
- const cols = process.stdout.columns ?? 80;
79
- const width = Math.min(opts.width ?? cols, cols) - 2; // margin
80
- const colors = ROLE_COLORS[opts.role];
81
- const border = colors.border;
82
-
83
- const pad = 1;
84
- const innerWidth = width - 2 - pad * 2; // borders + padding
85
-
86
- const lines: string[] = [];
87
-
88
- // ── Top bar with gradient label ──
89
- const label = opts.label ?? opts.role.toUpperCase();
90
- const labelText = ` ${label} `;
91
- const topFill = BOX.horizontal.repeat(
92
- Math.max(0, innerWidth - visibleWidth(labelText) + pad * 2)
93
- );
94
- const gradBorder = gradient(colors.gradient as [string, string]);
95
- lines.push(
96
- gradBorder(BOX.topLeft + BOX.horizontal.repeat(2)) +
97
- colors.label(labelText) +
98
- gradBorder(topFill + BOX.topRight)
99
- );
100
-
101
- // ── Content lines with gradient side borders ──
102
- const contentLines = wrapAnsi(opts.content, innerWidth);
103
- const padStr = " ".repeat(pad);
104
- for (const line of contentLines) {
105
- const vis = visibleWidth(line);
106
- const fill = " ".repeat(Math.max(0, innerWidth - vis));
107
- lines.push(
108
- gradBorder(BOX.vertical) + padStr + line + fill + padStr + gradBorder(BOX.vertical)
109
- );
110
- }
111
-
112
- // ── Meta line (timestamp, tokens, etc.) ──
113
- if (opts.meta) {
114
- const metaText = chalk.dim(opts.meta);
115
- const metaFill = " ".repeat(Math.max(0, innerWidth - visibleWidth(opts.meta)));
116
- lines.push(
117
- gradBorder(BOX.vertical) + padStr + metaText + metaFill + padStr + gradBorder(BOX.vertical)
118
- );
119
- }
120
-
121
- // ── Streaming indicator (animated) ──
122
- if (opts.streaming) {
123
- const frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"];
124
- const frameIdx = Date.now() % (frames.length * 80);
125
- const frame = frames[Math.floor(frameIdx / 80)];
126
- const spinnerText = `${chalk.cyan(frame)} ${chalk.dim("thinking...")}`;
127
- const spinFill = " ".repeat(Math.max(0, innerWidth - visibleWidth(spinnerText)));
128
- lines.push(
129
- gradBorder(BOX.vertical) + padStr + spinnerText + spinFill + padStr + gradBorder(BOX.vertical)
130
- );
131
- }
132
-
133
- // ── Bottom bar ──
134
- lines.push(
135
- gradBorder(BOX.bottomLeft + BOX.horizontal.repeat(width - 2) + BOX.bottomRight)
136
- );
137
-
138
- return lines.join("\n");
66
+ const cols = process.stdout.columns ?? 80;
67
+ const width = Math.min(opts.width ?? cols, cols) - 2;
68
+ const pad = 1;
69
+ const innerWidth = width - 2 - pad * 2;
70
+
71
+ const lines: string[] = [];
72
+
73
+ // Top bar: accent line + label
74
+ const label = opts.label ?? ROLE_LABEL[opts.role];
75
+ const labelText = ` ${label} `;
76
+ const topFill = BOX.horizontal.repeat(Math.max(0, innerWidth - visibleWidth(labelText) + pad * 2));
77
+ lines.push(ACCENT(BOX.topLeft + BOX.horizontal.repeat(2)) + chalk.bold(labelText) + ACCENT(topFill + BOX.topRight));
78
+
79
+ // Content
80
+ const contentLines = wrapAnsi(opts.content, innerWidth);
81
+ const padStr = " ".repeat(pad);
82
+ for (const line of contentLines) {
83
+ const vis = visibleWidth(line);
84
+ const fill = " ".repeat(Math.max(0, innerWidth - vis));
85
+ lines.push(ACCENT(BOX.vertical) + padStr + line + fill + padStr + ACCENT(BOX.vertical));
86
+ }
87
+
88
+ // Meta
89
+ if (opts.meta) {
90
+ const metaText = chalk.dim(opts.meta);
91
+ const metaFill = " ".repeat(Math.max(0, innerWidth - visibleWidth(opts.meta)));
92
+ lines.push(ACCENT(BOX.vertical) + padStr + metaText + metaFill + padStr + ACCENT(BOX.vertical));
93
+ }
94
+
95
+ // Streaming
96
+ if (opts.streaming) {
97
+ const frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"];
98
+ const frameIdx = Date.now() % (frames.length * 80);
99
+ const frame = frames[Math.floor(frameIdx / 80)];
100
+ const spinnerText = `${ACCENT(frame)} ${chalk.dim("thinking...")}`;
101
+ const spinFill = " ".repeat(Math.max(0, innerWidth - visibleWidth(spinnerText)));
102
+ lines.push(ACCENT(BOX.vertical) + padStr + spinnerText + spinFill + padStr + ACCENT(BOX.vertical));
103
+ }
104
+
105
+ // Bottom bar
106
+ lines.push(ACCENT(BOX.bottomLeft + BOX.horizontal.repeat(width - 2) + BOX.bottomRight));
107
+
108
+ return lines.join("\n");
139
109
  }
140
110
 
141
- /**
142
- * Render a compact inline message (no box, just colored prefix).
143
- */
111
+ /** Compact inline message — no box. */
144
112
  export function renderInline(role: MessageRole, text: string): string {
145
- const colors = ROLE_COLORS[role];
146
- const prefix = colors.label(`[${role}]`);
147
- return `${prefix} ${text}`;
113
+ const label = chalk.bold(`[${ROLE_LABEL[role]}]`);
114
+ return `${label} ${text}`;
148
115
  }
149
116
 
150
- /**
151
- * Render a separator/divider line with gradient accent.
152
- */
117
+ /** Separator line, optional label. */
153
118
  export function renderDivider(label?: string): string {
154
- const cols = process.stdout.columns ?? 80;
155
- const grad = gradient(BRAND_GRADIENT);
156
- if (!label) {
157
- return grad("─".repeat(cols - 2));
158
- }
159
- const labelText = ` ${label} `;
160
- const fill = BOX.horizontal.repeat(Math.max(0, cols - 4 - visibleWidth(labelText)));
161
- return grad(`${fill.slice(0, Math.floor(fill.length / 2))}`) +
162
- chalk.dim(labelText) +
163
- grad(`${fill.slice(Math.floor(fill.length / 2))}`);
119
+ const cols = process.stdout.columns ?? 80;
120
+ if (!label) {
121
+ return chalk.dim("─".repeat(cols - 2));
122
+ }
123
+ const labelText = ` ${label} `;
124
+ const fill = "─".repeat(Math.max(0, cols - 2 - visibleWidth(labelText)));
125
+ return chalk.dim(fill.slice(0, Math.floor(fill.length / 2))) + chalk.dim(labelText) + chalk.dim(fill.slice(Math.floor(fill.length / 2)));
164
126
  }
165
127
 
166
- /**
167
- * Render a tool-call status block (compact, with gradient border).
168
- */
128
+ /** Tool-call status line. */
169
129
  export function renderToolBlock(
170
- toolName: string,
171
- status: "running" | "done" | "error",
172
- detail?: string,
130
+ toolName: string,
131
+ status: "running" | "done" | "error",
132
+ detail?: string,
173
133
  ): string {
174
- const cols = process.stdout.columns ?? 80;
175
- const width = Math.min(cols - 2, 72);
176
- const gradColors = status === "error"
177
- ? ["#ff4444", "#cc0000"]
178
- : status === "running"
179
- ? ["#ffd700", "#e6a700"]
180
- : ["#00d2ff", "#7b2ff7"];
181
- const grad = gradient(gradColors as [string, string]);
182
-
183
- const icon = status === "running" ? chalk.yellow("⚙") : status === "done" ? chalk.green("✓") : chalk.red("✗");
184
- const label = ` ${icon} tool:${toolName} `;
185
- const detailText = detail ? chalk.dim(` ${detail}`) : "";
186
- const fill = BOX.horizontal.repeat(
187
- Math.max(0, width - 2 - visibleWidth(` ⚙ tool:${toolName} `) - visibleWidth(detail ?? ""))
188
- );
189
-
190
- return grad(BOX.topLeft + BOX.horizontal) + label + detailText + grad(fill + BOX.topRight);
134
+ const icon = status === "running" ? chalk.cyan("⚙") : status === "done" ? chalk.green("✓") : chalk.red("✗");
135
+ const label = ` ${icon} tool:${toolName} `;
136
+ const detailText = detail ? chalk.dim(` ${detail}`) : "";
137
+ return label + detailText;
191
138
  }
192
139
 
193
- /**
194
- * Build a gradient header line for the top of the session.
195
- */
140
+ /** Session header. */
196
141
  export function renderSessionHeader(model: string, version: string): string {
197
- const cols = process.stdout.columns ?? 80;
198
- const left = gradient(["#00d2ff", "#7b2ff7"])(" SnsAgent");
199
- const ver = chalk.dim(` v${version}`);
200
- const modelStr = chalk.cyan(` ${model}`);
201
- const sep = chalk.dim(" ");
202
- const line = `${left}${ver}${sep}${modelStr}`;
203
- const fill = chalk.dim("─".repeat(Math.max(0, cols - visibleWidth(line) - 2)));
204
- return `\n${line}\n${fill}\n`;
142
+ const cols = process.stdout.columns ?? 80;
143
+ const left = ACCENT.bold(" snsagent");
144
+ const ver = chalk.dim(` v${version}`);
145
+ const modelStr = chalk.dim(" · ") + chalk.cyan(model);
146
+ const sep = chalk.dim("─".repeat(Math.max(0, cols - visibleWidth(left + ver + modelStr) - 2)));
147
+ return `\n${left}${ver}${modelStr}\n${sep}\n`;
205
148
  }
@@ -3,7 +3,6 @@
3
3
  */
4
4
  import { Markdown, visibleWidth } from "@oh-my-pi/pi-tui";
5
5
  import chalk from "chalk";
6
- import gradient from "gradient-string";
7
6
  import { getMarkdownTheme, highlightCode, type Theme } from "../modes/theme/theme";
8
7
  import {
9
8
  formatDuration,
@@ -241,7 +240,6 @@ export function renderCollapsibleOutput(
241
240
  theme: Theme,
242
241
  maxLines: number = 8,
243
242
  ): string[] {
244
- const grad = theme.fg;
245
243
  const lines: string[] = [];
246
244
  const inner = Math.max(20, width - 4);
247
245
 
@@ -249,20 +247,22 @@ export function renderCollapsibleOutput(
249
247
  // Collapsed: just header + hint
250
248
  const lineCount = content.split("\n").length;
251
249
  const hint = chalk.dim(` (${lineCount} lines, click to expand)`);
252
- lines.push(` ${grad("accent", "▸")} ${grad("toolTitle", label)}${hint}`);
250
+ lines.push(` ${chalk.cyan("▸")} ${chalk.bold(label)}${hint}`);
253
251
  return lines;
254
252
  }
255
253
 
256
254
  // Expanded: bordered block
257
- const gradColors = ["#00d2ff", "#7b2ff7"] as [string, string];
258
- const g = gradient(gradColors);
255
+ const accent = chalk.cyan;
256
+
257
+ // Expanded: bordered block
258
+ const accentFn = (s: string) => chalk.cyan(s);
259
259
 
260
260
  // Header
261
261
  const headerText = ` ${label} `;
262
262
  const headerFill = COLLAPSE_BORDER.horizontal.repeat(
263
263
  Math.max(0, inner - headerText.length - 2),
264
264
  );
265
- lines.push(g(COLLAPSE_BORDER.topLeft + COLLAPSE_BORDER.horizontal) + grad("toolTitle", headerText) + g(headerFill + COLLAPSE_BORDER.topRight));
265
+ lines.push(accent(COLLAPSE_BORDER.topLeft + COLLAPSE_BORDER.horizontal) + chalk.bold(headerText) + accent(headerFill + COLLAPSE_BORDER.topRight));
266
266
 
267
267
  // Content
268
268
  const rawLines = content.split("\n");
@@ -270,7 +270,7 @@ export function renderCollapsibleOutput(
270
270
  for (const line of visibleLines) {
271
271
  const visLen = visibleWidth(line);
272
272
  const fill = " ".repeat(Math.max(0, inner - visLen));
273
- lines.push(g(COLLAPSE_BORDER.vertical) + " " + line + fill + " " + g(COLLAPSE_BORDER.vertical));
273
+ lines.push(accent(COLLAPSE_BORDER.vertical) + " " + line + fill + " " + accent(COLLAPSE_BORDER.vertical));
274
274
  }
275
275
 
276
276
  // Hidden lines hint
@@ -278,11 +278,11 @@ export function renderCollapsibleOutput(
278
278
  if (remaining > 0) {
279
279
  const moreText = ` ... +${remaining} more lines`;
280
280
  const moreFill = " ".repeat(Math.max(0, inner - moreText.length));
281
- lines.push(g(COLLAPSE_BORDER.vertical) + chalk.dim(moreText) + moreFill + g(COLLAPSE_BORDER.vertical));
281
+ lines.push(accent(COLLAPSE_BORDER.vertical) + chalk.dim(moreText) + moreFill + accent(COLLAPSE_BORDER.vertical));
282
282
  }
283
283
 
284
284
  // Footer
285
- lines.push(g(COLLAPSE_BORDER.bottomLeft + COLLAPSE_BORDER.horizontal.repeat(inner) + COLLAPSE_BORDER.bottomRight));
285
+ lines.push(accent(COLLAPSE_BORDER.bottomLeft + COLLAPSE_BORDER.horizontal.repeat(inner) + COLLAPSE_BORDER.bottomRight));
286
286
 
287
287
  return lines;
288
288
  }