poe-code 3.0.178 → 3.0.179

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 (164) hide show
  1. package/dist/index.js +6 -2
  2. package/dist/index.js.map +2 -2
  3. package/package.json +6 -2
  4. package/packages/cmdkit/dist/cli.compile-check.d.ts +1 -0
  5. package/packages/cmdkit/dist/cli.compile-check.js +26 -0
  6. package/packages/cmdkit/dist/cli.d.ts +12 -0
  7. package/packages/cmdkit/dist/cli.js +2306 -0
  8. package/packages/cmdkit/dist/cli.js.map +7 -0
  9. package/packages/cmdkit/dist/index.compile-check.d.ts +1 -0
  10. package/packages/cmdkit/dist/index.compile-check.js +50 -0
  11. package/packages/cmdkit/dist/index.d.ts +164 -0
  12. package/packages/cmdkit/dist/index.js +518 -0
  13. package/packages/cmdkit/dist/index.js.map +7 -0
  14. package/packages/cmdkit/dist/mcp.compile-check.d.ts +1 -0
  15. package/packages/cmdkit/dist/mcp.compile-check.js +26 -0
  16. package/packages/cmdkit/dist/mcp.d.ts +16 -0
  17. package/packages/cmdkit/dist/mcp.js +1153 -0
  18. package/packages/cmdkit/dist/mcp.js.map +7 -0
  19. package/packages/cmdkit/dist/renderer.d.ts +5 -0
  20. package/packages/cmdkit/dist/renderer.js +164 -0
  21. package/packages/cmdkit/dist/renderer.js.map +7 -0
  22. package/packages/cmdkit/dist/sdk.compile-check.d.ts +1 -0
  23. package/packages/cmdkit/dist/sdk.compile-check.js +79 -0
  24. package/packages/cmdkit/dist/sdk.d.ts +63 -0
  25. package/packages/cmdkit/dist/sdk.js +314 -0
  26. package/packages/cmdkit/dist/sdk.js.map +7 -0
  27. package/packages/cmdkit-schema/dist/index.compile-check.d.ts +1 -0
  28. package/packages/cmdkit-schema/dist/index.compile-check.js +11 -0
  29. package/packages/cmdkit-schema/dist/index.d.ts +81 -0
  30. package/packages/cmdkit-schema/dist/index.js +130 -0
  31. package/packages/design-system/dist/acp/components.d.ts +11 -0
  32. package/packages/design-system/dist/acp/components.js +121 -0
  33. package/packages/design-system/dist/acp/index.d.ts +3 -0
  34. package/packages/design-system/dist/acp/index.js +2 -0
  35. package/packages/design-system/dist/acp/writer.d.ts +13 -0
  36. package/packages/design-system/dist/acp/writer.js +21 -0
  37. package/packages/design-system/dist/components/command-errors.d.ts +16 -0
  38. package/packages/design-system/dist/components/command-errors.js +22 -0
  39. package/packages/design-system/dist/components/help-formatter.d.ts +20 -0
  40. package/packages/design-system/dist/components/help-formatter.js +27 -0
  41. package/packages/design-system/dist/components/index.d.ts +10 -0
  42. package/packages/design-system/dist/components/index.js +7 -0
  43. package/packages/design-system/dist/components/logger.d.ts +11 -0
  44. package/packages/design-system/dist/components/logger.js +60 -0
  45. package/packages/design-system/dist/components/symbols.d.ts +12 -0
  46. package/packages/design-system/dist/components/symbols.js +71 -0
  47. package/packages/design-system/dist/components/table.d.ts +13 -0
  48. package/packages/design-system/dist/components/table.js +74 -0
  49. package/packages/design-system/dist/components/text.d.ts +14 -0
  50. package/packages/design-system/dist/components/text.js +104 -0
  51. package/packages/design-system/dist/dashboard/ansi.d.ts +18 -0
  52. package/packages/design-system/dist/dashboard/ansi.js +298 -0
  53. package/packages/design-system/dist/dashboard/buffer.d.ts +25 -0
  54. package/packages/design-system/dist/dashboard/buffer.js +189 -0
  55. package/packages/design-system/dist/dashboard/components/border.d.ts +9 -0
  56. package/packages/design-system/dist/dashboard/components/border.js +123 -0
  57. package/packages/design-system/dist/dashboard/components/footer.d.ts +8 -0
  58. package/packages/design-system/dist/dashboard/components/footer.js +58 -0
  59. package/packages/design-system/dist/dashboard/components/output-pane.d.ts +21 -0
  60. package/packages/design-system/dist/dashboard/components/output-pane.js +323 -0
  61. package/packages/design-system/dist/dashboard/components/stats-pane.d.ts +7 -0
  62. package/packages/design-system/dist/dashboard/components/stats-pane.js +120 -0
  63. package/packages/design-system/dist/dashboard/dashboard.d.ts +20 -0
  64. package/packages/design-system/dist/dashboard/dashboard.js +187 -0
  65. package/packages/design-system/dist/dashboard/demo.d.ts +13 -0
  66. package/packages/design-system/dist/dashboard/demo.js +145 -0
  67. package/packages/design-system/dist/dashboard/index.d.ts +7 -0
  68. package/packages/design-system/dist/dashboard/index.js +3 -0
  69. package/packages/design-system/dist/dashboard/keymap.d.ts +3 -0
  70. package/packages/design-system/dist/dashboard/keymap.js +114 -0
  71. package/packages/design-system/dist/dashboard/layout.d.ts +25 -0
  72. package/packages/design-system/dist/dashboard/layout.js +79 -0
  73. package/packages/design-system/dist/dashboard/snapshot.d.ts +10 -0
  74. package/packages/design-system/dist/dashboard/snapshot.js +72 -0
  75. package/packages/design-system/dist/dashboard/store.d.ts +9 -0
  76. package/packages/design-system/dist/dashboard/store.js +107 -0
  77. package/packages/design-system/dist/dashboard/terminal.d.ts +35 -0
  78. package/packages/design-system/dist/dashboard/terminal.js +215 -0
  79. package/packages/design-system/dist/dashboard/types.d.ts +45 -0
  80. package/packages/design-system/dist/dashboard/types.js +1 -0
  81. package/packages/design-system/dist/index.d.ts +33 -0
  82. package/packages/design-system/dist/index.js +31 -0
  83. package/packages/design-system/dist/internal/output-format.d.ts +6 -0
  84. package/packages/design-system/dist/internal/output-format.js +22 -0
  85. package/packages/design-system/dist/internal/strip-ansi.d.ts +1 -0
  86. package/packages/design-system/dist/internal/strip-ansi.js +3 -0
  87. package/packages/design-system/dist/internal/theme-detect.d.ts +11 -0
  88. package/packages/design-system/dist/internal/theme-detect.js +49 -0
  89. package/packages/design-system/dist/prompts/index.d.ts +66 -0
  90. package/packages/design-system/dist/prompts/index.js +132 -0
  91. package/packages/design-system/dist/prompts/primitives/cancel.d.ts +2 -0
  92. package/packages/design-system/dist/prompts/primitives/cancel.js +9 -0
  93. package/packages/design-system/dist/prompts/primitives/intro.d.ts +1 -0
  94. package/packages/design-system/dist/prompts/primitives/intro.js +15 -0
  95. package/packages/design-system/dist/prompts/primitives/log.d.ts +18 -0
  96. package/packages/design-system/dist/prompts/primitives/log.js +101 -0
  97. package/packages/design-system/dist/prompts/primitives/note.d.ts +1 -0
  98. package/packages/design-system/dist/prompts/primitives/note.js +39 -0
  99. package/packages/design-system/dist/prompts/primitives/outro.d.ts +1 -0
  100. package/packages/design-system/dist/prompts/primitives/outro.js +16 -0
  101. package/packages/design-system/dist/prompts/primitives/spinner.d.ts +6 -0
  102. package/packages/design-system/dist/prompts/primitives/spinner.js +74 -0
  103. package/packages/design-system/dist/prompts/theme.d.ts +11 -0
  104. package/packages/design-system/dist/prompts/theme.js +12 -0
  105. package/packages/design-system/dist/static/index.d.ts +4 -0
  106. package/packages/design-system/dist/static/index.js +2 -0
  107. package/packages/design-system/dist/static/menu.d.ts +11 -0
  108. package/packages/design-system/dist/static/menu.js +36 -0
  109. package/packages/design-system/dist/static/spinner.d.ts +14 -0
  110. package/packages/design-system/dist/static/spinner.js +46 -0
  111. package/packages/design-system/dist/terminal-markdown/ast.d.ts +84 -0
  112. package/packages/design-system/dist/terminal-markdown/ast.js +1 -0
  113. package/packages/design-system/dist/terminal-markdown/demo-content.d.ts +2 -0
  114. package/packages/design-system/dist/terminal-markdown/demo-content.js +139 -0
  115. package/packages/design-system/dist/terminal-markdown/index.d.ts +6 -0
  116. package/packages/design-system/dist/terminal-markdown/index.js +8 -0
  117. package/packages/design-system/dist/terminal-markdown/parser/block.d.ts +6 -0
  118. package/packages/design-system/dist/terminal-markdown/parser/block.js +1205 -0
  119. package/packages/design-system/dist/terminal-markdown/parser/frontmatter.d.ts +6 -0
  120. package/packages/design-system/dist/terminal-markdown/parser/frontmatter.js +395 -0
  121. package/packages/design-system/dist/terminal-markdown/parser/inline.d.ts +6 -0
  122. package/packages/design-system/dist/terminal-markdown/parser/inline.js +1087 -0
  123. package/packages/design-system/dist/terminal-markdown/parser.d.ts +5 -0
  124. package/packages/design-system/dist/terminal-markdown/parser.js +13 -0
  125. package/packages/design-system/dist/terminal-markdown/renderer.d.ts +6 -0
  126. package/packages/design-system/dist/terminal-markdown/renderer.js +572 -0
  127. package/packages/design-system/dist/terminal-markdown/testing/theme-render-fixture.d.ts +1 -0
  128. package/packages/design-system/dist/terminal-markdown/testing/theme-render-fixture.js +27 -0
  129. package/packages/design-system/dist/tokens/colors.d.ts +35 -0
  130. package/packages/design-system/dist/tokens/colors.js +34 -0
  131. package/packages/design-system/dist/tokens/index.d.ts +4 -0
  132. package/packages/design-system/dist/tokens/index.js +4 -0
  133. package/packages/design-system/dist/tokens/spacing.d.ts +6 -0
  134. package/packages/design-system/dist/tokens/spacing.js +6 -0
  135. package/packages/design-system/dist/tokens/typography.d.ts +7 -0
  136. package/packages/design-system/dist/tokens/typography.js +8 -0
  137. package/packages/design-system/dist/tokens/widths.d.ts +5 -0
  138. package/packages/design-system/dist/tokens/widths.js +5 -0
  139. package/packages/tiny-stdio-mcp-server/dist/content/audio.d.ts +14 -0
  140. package/packages/tiny-stdio-mcp-server/dist/content/audio.js +76 -0
  141. package/packages/tiny-stdio-mcp-server/dist/content/convert.d.ts +16 -0
  142. package/packages/tiny-stdio-mcp-server/dist/content/convert.js +42 -0
  143. package/packages/tiny-stdio-mcp-server/dist/content/file-type.d.ts +11 -0
  144. package/packages/tiny-stdio-mcp-server/dist/content/file-type.js +93 -0
  145. package/packages/tiny-stdio-mcp-server/dist/content/file.d.ts +26 -0
  146. package/packages/tiny-stdio-mcp-server/dist/content/file.js +94 -0
  147. package/packages/tiny-stdio-mcp-server/dist/content/image.d.ts +14 -0
  148. package/packages/tiny-stdio-mcp-server/dist/content/image.js +64 -0
  149. package/packages/tiny-stdio-mcp-server/dist/content/index.d.ts +5 -0
  150. package/packages/tiny-stdio-mcp-server/dist/content/index.js +8 -0
  151. package/packages/tiny-stdio-mcp-server/dist/content/mime.d.ts +1 -0
  152. package/packages/tiny-stdio-mcp-server/dist/content/mime.js +1 -0
  153. package/packages/tiny-stdio-mcp-server/dist/index.d.ts +9 -0
  154. package/packages/tiny-stdio-mcp-server/dist/index.js +7 -0
  155. package/packages/tiny-stdio-mcp-server/dist/jsonrpc.d.ts +14 -0
  156. package/packages/tiny-stdio-mcp-server/dist/jsonrpc.js +99 -0
  157. package/packages/tiny-stdio-mcp-server/dist/schema.d.ts +19 -0
  158. package/packages/tiny-stdio-mcp-server/dist/schema.js +18 -0
  159. package/packages/tiny-stdio-mcp-server/dist/server.d.ts +13 -0
  160. package/packages/tiny-stdio-mcp-server/dist/server.js +226 -0
  161. package/packages/tiny-stdio-mcp-server/dist/testing.d.ts +7 -0
  162. package/packages/tiny-stdio-mcp-server/dist/testing.js +20 -0
  163. package/packages/tiny-stdio-mcp-server/dist/types.d.ts +119 -0
  164. package/packages/tiny-stdio-mcp-server/dist/types.js +16 -0
@@ -0,0 +1,121 @@
1
+ import chalk from "chalk";
2
+ import { resolveOutputFormat } from "../internal/output-format.js";
3
+ import { renderMarkdown } from "../terminal-markdown/index.js";
4
+ import { getAcpWriter } from "./writer.js";
5
+ function truncate(text, maxLength) {
6
+ if (text.length <= maxLength)
7
+ return text;
8
+ if (maxLength <= 3)
9
+ return text.slice(0, maxLength);
10
+ return `${text.slice(0, maxLength - 3)}...`;
11
+ }
12
+ const KIND_COLORS = {
13
+ exec: (text) => chalk.yellow(text),
14
+ edit: (text) => chalk.magenta(text),
15
+ read: (text) => chalk.cyan(text),
16
+ search: (text) => chalk.blue(text),
17
+ think: (text) => chalk.dim(text),
18
+ other: (text) => chalk.dim(text)
19
+ };
20
+ function colorForKind(kind) {
21
+ return KIND_COLORS[kind] ?? ((text) => chalk.dim(text));
22
+ }
23
+ function writeLine(line) {
24
+ getAcpWriter()(line);
25
+ }
26
+ const AGENT_PREFIX = `${chalk.green.bold("✓")} agent: `;
27
+ function formatCost(costUsd) {
28
+ return new Intl.NumberFormat("en-US", {
29
+ style: "currency",
30
+ currency: "USD",
31
+ minimumFractionDigits: 2,
32
+ maximumFractionDigits: 6
33
+ }).format(costUsd);
34
+ }
35
+ export function renderAgentMessage(text) {
36
+ const format = resolveOutputFormat();
37
+ if (format === "markdown") {
38
+ writeLine(`- **agent:** ${text}`);
39
+ return;
40
+ }
41
+ if (format === "json") {
42
+ writeLine(JSON.stringify({ event: "agent_message", text }));
43
+ return;
44
+ }
45
+ const rendered = renderMarkdown(text).trimEnd();
46
+ writeLine(`${AGENT_PREFIX}${rendered}`);
47
+ }
48
+ export function renderToolStart(kind, title) {
49
+ const format = resolveOutputFormat();
50
+ if (format === "markdown") {
51
+ writeLine(`- *→ ${kind}: ${title}*`);
52
+ return;
53
+ }
54
+ if (format === "json") {
55
+ writeLine(JSON.stringify({ event: "tool_start", kind, title }));
56
+ return;
57
+ }
58
+ const color = colorForKind(kind);
59
+ writeLine(color(` → ${kind}: ${title}`));
60
+ }
61
+ export function renderToolComplete(kind) {
62
+ const format = resolveOutputFormat();
63
+ if (format === "markdown") {
64
+ writeLine(`- *✓ ${kind}*`);
65
+ return;
66
+ }
67
+ if (format === "json") {
68
+ writeLine(JSON.stringify({ event: "tool_complete", kind }));
69
+ return;
70
+ }
71
+ const color = colorForKind(kind);
72
+ writeLine(color(` ✓ ${kind}`));
73
+ }
74
+ export function renderReasoning(text) {
75
+ const format = resolveOutputFormat();
76
+ if (format === "markdown") {
77
+ writeLine(`- *thinking:* ${truncate(text, 80)}`);
78
+ return;
79
+ }
80
+ if (format === "json") {
81
+ writeLine(JSON.stringify({ event: "reasoning", text }));
82
+ return;
83
+ }
84
+ writeLine(chalk.dim(` ✓ ${truncate(text, 80)}`));
85
+ }
86
+ export function renderUsage(tokens) {
87
+ const format = resolveOutputFormat();
88
+ const cached = typeof tokens.cached === "number" && tokens.cached > 0 ? ` (${tokens.cached} cached)` : "";
89
+ let cost = "";
90
+ if (typeof tokens.costUsd === "number") {
91
+ cost = ` (${formatCost(tokens.costUsd)})`;
92
+ }
93
+ if (format === "markdown") {
94
+ writeLine(`- **tokens:** ${tokens.input} in → ${tokens.output} out${cost}`);
95
+ return;
96
+ }
97
+ if (format === "json") {
98
+ writeLine(JSON.stringify({
99
+ event: "usage",
100
+ inputTokens: tokens.input,
101
+ outputTokens: tokens.output,
102
+ cachedTokens: tokens.cached ?? 0,
103
+ costUsd: tokens.costUsd ?? 0
104
+ }));
105
+ return;
106
+ }
107
+ writeLine("");
108
+ writeLine(chalk.green(`✓ tokens: ${tokens.input} in${cached} → ${tokens.output} out${cost}`));
109
+ }
110
+ export function renderError(message) {
111
+ const format = resolveOutputFormat();
112
+ if (format === "markdown") {
113
+ writeLine(`- **error:** ${message}`);
114
+ return;
115
+ }
116
+ if (format === "json") {
117
+ writeLine(JSON.stringify({ event: "error", message }));
118
+ return;
119
+ }
120
+ writeLine(chalk.red(`✗ ${message}`));
121
+ }
@@ -0,0 +1,3 @@
1
+ export { renderAgentMessage, renderToolStart, renderToolComplete, renderReasoning, renderUsage, renderError } from "./components.js";
2
+ export { getAcpWriter, withAcpWriter } from "./writer.js";
3
+ export type { AcpLineWriter } from "./writer.js";
@@ -0,0 +1,2 @@
1
+ export { renderAgentMessage, renderToolStart, renderToolComplete, renderReasoning, renderUsage, renderError } from "./components.js";
2
+ export { getAcpWriter, withAcpWriter } from "./writer.js";
@@ -0,0 +1,13 @@
1
+ export type AcpLineWriter = (line: string) => void;
2
+ /**
3
+ * Return the writer active in the current async context, or the default
4
+ * stdout writer if none is bound.
5
+ */
6
+ export declare function getAcpWriter(): AcpLineWriter;
7
+ /**
8
+ * Run `fn` with `writer` bound as the active ACP line writer. All calls to
9
+ * `renderAgentMessage`, `renderToolStart`, `renderAcpEvent`, etc. made inside
10
+ * `fn` (or async work awaited from `fn`) will go through `writer` instead of
11
+ * writing to `process.stdout`.
12
+ */
13
+ export declare function withAcpWriter<T>(writer: AcpLineWriter, fn: () => Promise<T>): Promise<T>;
@@ -0,0 +1,21 @@
1
+ import { AsyncLocalStorage } from "node:async_hooks";
2
+ const storage = new AsyncLocalStorage();
3
+ const defaultWriter = (line) => {
4
+ process.stdout.write(`${line}\n`);
5
+ };
6
+ /**
7
+ * Return the writer active in the current async context, or the default
8
+ * stdout writer if none is bound.
9
+ */
10
+ export function getAcpWriter() {
11
+ return storage.getStore() ?? defaultWriter;
12
+ }
13
+ /**
14
+ * Run `fn` with `writer` bound as the active ACP line writer. All calls to
15
+ * `renderAgentMessage`, `renderToolStart`, `renderAcpEvent`, etc. made inside
16
+ * `fn` (or async work awaited from `fn`) will go through `writer` instead of
17
+ * writing to `process.stdout`.
18
+ */
19
+ export function withAcpWriter(writer, fn) {
20
+ return storage.run(writer, fn);
21
+ }
@@ -0,0 +1,16 @@
1
+ export declare function formatCommandNotFound(input: {
2
+ unknownCommand: string;
3
+ helpCommand: string;
4
+ }): {
5
+ label: string;
6
+ hint: string;
7
+ };
8
+ export declare function formatCommandNotFoundPanel(input: {
9
+ unknownCommand: string;
10
+ helpCommand: string;
11
+ title?: string;
12
+ }): {
13
+ title: string;
14
+ label: string;
15
+ footer: string;
16
+ };
@@ -0,0 +1,22 @@
1
+ import { typography } from "../tokens/typography.js";
2
+ import { text } from "./text.js";
3
+ export function formatCommandNotFound(input) {
4
+ const unknown = input.unknownCommand.length > 0
5
+ ? input.unknownCommand
6
+ : "<command>";
7
+ return {
8
+ label: `${typography.bold("Unknown command:")} ${text.command(unknown)}`,
9
+ hint: `${text.muted("Run")} ${text.usageCommand(input.helpCommand)} ${text.muted("for available commands.")}`
10
+ };
11
+ }
12
+ export function formatCommandNotFoundPanel(input) {
13
+ const message = formatCommandNotFound({
14
+ unknownCommand: input.unknownCommand,
15
+ helpCommand: input.helpCommand
16
+ });
17
+ return {
18
+ title: input.title ?? "command not found",
19
+ label: message.label,
20
+ footer: message.hint
21
+ };
22
+ }
@@ -0,0 +1,20 @@
1
+ export interface CommandInfo {
2
+ name: string;
3
+ description: string;
4
+ }
5
+ export interface OptionInfo {
6
+ flags: string;
7
+ description: string;
8
+ }
9
+ export declare function formatCommand(name: string, description: string): string;
10
+ export declare function formatUsage(command: string, args?: string): string;
11
+ export declare function formatOption(flags: string, description: string): string;
12
+ export declare function formatCommandList(commands: CommandInfo[]): string;
13
+ export declare function formatOptionList(options: OptionInfo[]): string;
14
+ export declare const helpFormatter: {
15
+ readonly formatCommand: typeof formatCommand;
16
+ readonly formatUsage: typeof formatUsage;
17
+ readonly formatOption: typeof formatOption;
18
+ readonly formatCommandList: typeof formatCommandList;
19
+ readonly formatOptionList: typeof formatOptionList;
20
+ };
@@ -0,0 +1,27 @@
1
+ import { text } from "./text.js";
2
+ import { widths } from "../tokens/widths.js";
3
+ export function formatCommand(name, description) {
4
+ const paddedName = name.padEnd(widths.helpColumn);
5
+ return ` ${text.command(paddedName)} ${description}`;
6
+ }
7
+ export function formatUsage(command, args) {
8
+ const argsStr = args ? ` ${text.argument(args)}` : "";
9
+ return `${text.usageCommand(command)}${argsStr}`;
10
+ }
11
+ export function formatOption(flags, description) {
12
+ const paddedFlags = flags.padEnd(widths.helpColumn);
13
+ return ` ${text.option(paddedFlags)} ${description}`;
14
+ }
15
+ export function formatCommandList(commands) {
16
+ return commands.map((cmd) => formatCommand(cmd.name, cmd.description)).join("\n");
17
+ }
18
+ export function formatOptionList(options) {
19
+ return options.map((opt) => formatOption(opt.flags, opt.description)).join("\n");
20
+ }
21
+ export const helpFormatter = {
22
+ formatCommand,
23
+ formatUsage,
24
+ formatOption,
25
+ formatCommandList,
26
+ formatOptionList
27
+ };
@@ -0,0 +1,10 @@
1
+ export { text } from "./text.js";
2
+ export { symbols } from "./symbols.js";
3
+ export { createLogger, logger } from "./logger.js";
4
+ export type { LoggerOutput } from "./logger.js";
5
+ export { helpFormatter, formatCommand, formatUsage, formatOption, formatCommandList, formatOptionList } from "./help-formatter.js";
6
+ export type { CommandInfo, OptionInfo } from "./help-formatter.js";
7
+ export { formatCommandNotFound } from "./command-errors.js";
8
+ export { formatCommandNotFoundPanel } from "./command-errors.js";
9
+ export { renderTable } from "./table.js";
10
+ export type { TableColumn, RenderTableOptions } from "./table.js";
@@ -0,0 +1,7 @@
1
+ export { text } from "./text.js";
2
+ export { symbols } from "./symbols.js";
3
+ export { createLogger, logger } from "./logger.js";
4
+ export { helpFormatter, formatCommand, formatUsage, formatOption, formatCommandList, formatOptionList } from "./help-formatter.js";
5
+ export { formatCommandNotFound } from "./command-errors.js";
6
+ export { formatCommandNotFoundPanel } from "./command-errors.js";
7
+ export { renderTable } from "./table.js";
@@ -0,0 +1,11 @@
1
+ export interface LoggerOutput {
2
+ info(message: string): void;
3
+ success(message: string): void;
4
+ warn(message: string): void;
5
+ error(message: string): void;
6
+ resolved(label: string, value: string): void;
7
+ errorResolved(label: string, value: string): void;
8
+ message(message: string, symbol?: string): void;
9
+ }
10
+ export declare function createLogger(emitter?: (message: string) => void): LoggerOutput;
11
+ export declare const logger: LoggerOutput;
@@ -0,0 +1,60 @@
1
+ import chalk from "chalk";
2
+ import { log } from "../prompts/primitives/log.js";
3
+ import { symbols } from "./symbols.js";
4
+ export function createLogger(emitter) {
5
+ const emit = (level, message) => {
6
+ if (emitter) {
7
+ emitter(message);
8
+ return;
9
+ }
10
+ if (level === "success") {
11
+ log.success(message);
12
+ return;
13
+ }
14
+ if (level === "warn") {
15
+ log.warn(message);
16
+ return;
17
+ }
18
+ if (level === "error") {
19
+ log.error(message);
20
+ return;
21
+ }
22
+ log.info(message);
23
+ };
24
+ return {
25
+ info(message) {
26
+ emit("info", message);
27
+ },
28
+ success(message) {
29
+ emit("success", message);
30
+ },
31
+ warn(message) {
32
+ emit("warn", message);
33
+ },
34
+ error(message) {
35
+ emit("error", message);
36
+ },
37
+ resolved(label, value) {
38
+ if (emitter) {
39
+ emitter(`${label}: ${value}`);
40
+ return;
41
+ }
42
+ log.message(`${label}\n ${value}`, { symbol: symbols.resolved });
43
+ },
44
+ errorResolved(label, value) {
45
+ if (emitter) {
46
+ emitter(`${label}: ${value}`);
47
+ return;
48
+ }
49
+ log.message(`${label}\n ${value}`, { symbol: symbols.errorResolved });
50
+ },
51
+ message(message, symbol) {
52
+ if (emitter) {
53
+ emitter(message);
54
+ return;
55
+ }
56
+ log.message(message, { symbol: symbol ?? chalk.gray("│") });
57
+ }
58
+ };
59
+ }
60
+ export const logger = createLogger();
@@ -0,0 +1,12 @@
1
+ export declare const symbols: {
2
+ readonly info: string;
3
+ readonly success: string;
4
+ readonly resolved: string;
5
+ readonly errorResolved: string;
6
+ readonly bar: string;
7
+ readonly cornerTopRight: "╮";
8
+ readonly cornerBottomRight: "╯";
9
+ readonly warning: string;
10
+ readonly active: string;
11
+ readonly inactive: string;
12
+ };
@@ -0,0 +1,71 @@
1
+ import chalk from "chalk";
2
+ import { resolveOutputFormat } from "../internal/output-format.js";
3
+ import { getTheme } from "../internal/theme-detect.js";
4
+ export const symbols = {
5
+ get info() {
6
+ const format = resolveOutputFormat();
7
+ if (format === "json")
8
+ return "info";
9
+ if (format === "markdown")
10
+ return "(i)";
11
+ return chalk.magenta("●");
12
+ },
13
+ get success() {
14
+ const format = resolveOutputFormat();
15
+ if (format === "json")
16
+ return "success";
17
+ if (format === "markdown")
18
+ return "[ok]";
19
+ return chalk.magenta("◆");
20
+ },
21
+ get resolved() {
22
+ const format = resolveOutputFormat();
23
+ if (format === "json")
24
+ return "resolved";
25
+ if (format === "markdown")
26
+ return ">";
27
+ return getTheme().resolvedSymbol;
28
+ },
29
+ get errorResolved() {
30
+ const format = resolveOutputFormat();
31
+ if (format === "json")
32
+ return "error";
33
+ if (format === "markdown")
34
+ return "[!]";
35
+ return getTheme().errorSymbol;
36
+ },
37
+ get bar() {
38
+ const format = resolveOutputFormat();
39
+ if (format === "json")
40
+ return "";
41
+ if (format === "markdown")
42
+ return "|";
43
+ return "│";
44
+ },
45
+ cornerTopRight: "╮",
46
+ cornerBottomRight: "╯",
47
+ get warning() {
48
+ const format = resolveOutputFormat();
49
+ if (format === "json")
50
+ return "warning";
51
+ if (format === "markdown")
52
+ return "[!]";
53
+ return "▲";
54
+ },
55
+ get active() {
56
+ const format = resolveOutputFormat();
57
+ if (format === "json")
58
+ return "active";
59
+ if (format === "markdown")
60
+ return "[x]";
61
+ return "◆";
62
+ },
63
+ get inactive() {
64
+ const format = resolveOutputFormat();
65
+ if (format === "json")
66
+ return "inactive";
67
+ if (format === "markdown")
68
+ return "[ ]";
69
+ return "○";
70
+ }
71
+ };
@@ -0,0 +1,13 @@
1
+ import type { ThemePalette } from "../tokens/colors.js";
2
+ export interface TableColumn {
3
+ name: string;
4
+ title: string;
5
+ alignment: "left" | "right";
6
+ maxLen: number;
7
+ }
8
+ export interface RenderTableOptions {
9
+ theme: ThemePalette;
10
+ columns: TableColumn[];
11
+ rows: Record<string, string>[];
12
+ }
13
+ export declare function renderTable(options: RenderTableOptions): string;
@@ -0,0 +1,74 @@
1
+ import { Table } from "console-table-printer";
2
+ import { resolveOutputFormat } from "../internal/output-format.js";
3
+ import { stripAnsi } from "../internal/strip-ansi.js";
4
+ function renderTableTerminal(options) {
5
+ const { theme, columns, rows } = options;
6
+ const table = new Table({
7
+ style: {
8
+ headerTop: {
9
+ left: theme.muted("┌"),
10
+ mid: theme.muted("┬"),
11
+ right: theme.muted("┐"),
12
+ other: theme.muted("─")
13
+ },
14
+ headerBottom: {
15
+ left: theme.muted("├"),
16
+ mid: theme.muted("┼"),
17
+ right: theme.muted("┤"),
18
+ other: theme.muted("─")
19
+ },
20
+ tableBottom: {
21
+ left: theme.muted("└"),
22
+ mid: theme.muted("┴"),
23
+ right: theme.muted("┘"),
24
+ other: theme.muted("─")
25
+ },
26
+ vertical: theme.muted("│"),
27
+ rowSeparator: {
28
+ left: theme.muted("├"),
29
+ mid: theme.muted("┼"),
30
+ right: theme.muted("┤"),
31
+ other: theme.muted("─")
32
+ }
33
+ },
34
+ columns: columns.map((col) => ({
35
+ name: col.name,
36
+ title: theme.header(col.title),
37
+ alignment: col.alignment,
38
+ maxLen: col.maxLen
39
+ }))
40
+ });
41
+ for (const row of rows) {
42
+ table.addRow(row);
43
+ }
44
+ return table.render();
45
+ }
46
+ function renderTableMarkdown(options) {
47
+ const { columns, rows } = options;
48
+ const header = `| ${columns.map((c) => c.title).join(" | ")} |`;
49
+ const separator = `| ${columns.map((c) => (c.alignment === "right" ? "---:" : ":---")).join(" | ")} |`;
50
+ const dataRows = rows.map((row) => `| ${columns.map((c) => stripAnsi(row[c.name] ?? "").replace(/\|/g, "\\|")).join(" | ")} |`);
51
+ return [header, separator, ...dataRows].join("\n");
52
+ }
53
+ function renderTableJson(options) {
54
+ const { columns, rows } = options;
55
+ const cleaned = rows.map((row) => {
56
+ const obj = {};
57
+ for (const col of columns) {
58
+ obj[col.name] = stripAnsi(row[col.name] ?? "");
59
+ }
60
+ return obj;
61
+ });
62
+ return JSON.stringify(cleaned, null, 2);
63
+ }
64
+ export function renderTable(options) {
65
+ const format = resolveOutputFormat();
66
+ switch (format) {
67
+ case "markdown":
68
+ return renderTableMarkdown(options);
69
+ case "json":
70
+ return renderTableJson(options);
71
+ default:
72
+ return renderTableTerminal(options);
73
+ }
74
+ }
@@ -0,0 +1,14 @@
1
+ export declare const text: {
2
+ readonly intro: (content: string) => string;
3
+ readonly heading: (content: string) => string;
4
+ readonly section: (content: string) => string;
5
+ readonly command: (content: string) => string;
6
+ readonly argument: (content: string) => string;
7
+ readonly option: (content: string) => string;
8
+ readonly example: (content: string) => string;
9
+ readonly usageCommand: (content: string) => string;
10
+ readonly link: (content: string) => string;
11
+ readonly muted: (content: string) => string;
12
+ readonly badge: (content: string) => string;
13
+ readonly selectLabel: (label: string, detail?: string) => string;
14
+ };
@@ -0,0 +1,104 @@
1
+ import chalk from "chalk";
2
+ import { resolveOutputFormat } from "../internal/output-format.js";
3
+ import { getTheme } from "../internal/theme-detect.js";
4
+ import { typography } from "../tokens/typography.js";
5
+ export const text = {
6
+ intro(content) {
7
+ const format = resolveOutputFormat();
8
+ if (format === "json")
9
+ return content;
10
+ if (format === "markdown")
11
+ return `**${content}**`;
12
+ return getTheme().intro(content);
13
+ },
14
+ heading(content) {
15
+ const format = resolveOutputFormat();
16
+ if (format === "json")
17
+ return content;
18
+ if (format === "markdown")
19
+ return `## ${content}`;
20
+ return getTheme().header(content);
21
+ },
22
+ section(content) {
23
+ const format = resolveOutputFormat();
24
+ if (format === "json")
25
+ return content;
26
+ if (format === "markdown")
27
+ return `**${content}**`;
28
+ return typography.bold(content);
29
+ },
30
+ command(content) {
31
+ const format = resolveOutputFormat();
32
+ if (format === "json")
33
+ return content;
34
+ if (format === "markdown")
35
+ return `\`${content}\``;
36
+ return getTheme().accent(content);
37
+ },
38
+ argument(content) {
39
+ const format = resolveOutputFormat();
40
+ if (format === "json")
41
+ return content;
42
+ if (format === "markdown")
43
+ return `<${content}>`;
44
+ return getTheme().muted(content);
45
+ },
46
+ option(content) {
47
+ const format = resolveOutputFormat();
48
+ if (format === "json")
49
+ return content;
50
+ if (format === "markdown")
51
+ return `\`${content}\``;
52
+ return chalk.yellow(content);
53
+ },
54
+ example(content) {
55
+ const format = resolveOutputFormat();
56
+ if (format === "json")
57
+ return content;
58
+ if (format === "markdown")
59
+ return `\`${content}\``;
60
+ return getTheme().muted(content);
61
+ },
62
+ usageCommand(content) {
63
+ const format = resolveOutputFormat();
64
+ if (format === "json")
65
+ return content;
66
+ if (format === "markdown")
67
+ return `\`${content}\``;
68
+ return chalk.green(content);
69
+ },
70
+ link(content) {
71
+ const format = resolveOutputFormat();
72
+ if (format === "json")
73
+ return content;
74
+ if (format === "markdown")
75
+ return `[${content}](${content})`;
76
+ return getTheme().accent(content);
77
+ },
78
+ muted(content) {
79
+ const format = resolveOutputFormat();
80
+ if (format === "json")
81
+ return content;
82
+ if (format === "markdown")
83
+ return `*${content}*`;
84
+ return getTheme().muted(content);
85
+ },
86
+ badge(content) {
87
+ const format = resolveOutputFormat();
88
+ if (format === "json")
89
+ return content;
90
+ if (format === "markdown")
91
+ return `[${content}]`;
92
+ return getTheme().badge(content);
93
+ },
94
+ selectLabel(label, detail) {
95
+ if (!detail) {
96
+ return label;
97
+ }
98
+ const format = resolveOutputFormat();
99
+ if (format !== "terminal") {
100
+ return `${label} — ${detail}`;
101
+ }
102
+ return `${label} ${typography.dim("—")} ${typography.dim(detail)}`;
103
+ }
104
+ };
@@ -0,0 +1,18 @@
1
+ import type { CellStyle } from "./types.js";
2
+ export interface StyledSegment {
3
+ text: string;
4
+ style: CellStyle;
5
+ }
6
+ export interface StyledLine {
7
+ segments: StyledSegment[];
8
+ }
9
+ export declare function hasAnsi(text: string): boolean;
10
+ /**
11
+ * Parse a block of text that may contain ANSI SGR escape codes into a sequence of
12
+ * logical lines split on "\n". Each line is a list of styled segments: contiguous
13
+ * printable runs of characters sharing the same style.
14
+ *
15
+ * Non-SGR CSI sequences and other control characters are discarded. `baseStyle` is
16
+ * used as the initial style and as the restore target for SGR reset / default color.
17
+ */
18
+ export declare function parseAnsi(text: string, baseStyle?: CellStyle): StyledLine[];