poe-code 3.0.177 → 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.
- package/dist/cli/commands/dashboard-loop-shared.d.ts +16 -0
- package/dist/cli/commands/dashboard-loop-shared.js +48 -0
- package/dist/cli/commands/dashboard-loop-shared.js.map +1 -0
- package/dist/cli/commands/experiment.js +211 -22
- package/dist/cli/commands/experiment.js.map +1 -1
- package/dist/cli/commands/models.js +1 -1
- package/dist/cli/commands/pipeline.js +353 -60
- package/dist/cli/commands/pipeline.js.map +1 -1
- package/dist/cli/commands/plan.d.ts +6 -0
- package/dist/cli/commands/plan.js +190 -3
- package/dist/cli/commands/plan.js.map +1 -1
- package/dist/cli/commands/ralph.js +184 -24
- package/dist/cli/commands/ralph.js.map +1 -1
- package/dist/cli/commands/spawn.js +9 -1
- package/dist/cli/commands/spawn.js.map +1 -1
- package/dist/cli/constants.d.ts +4 -4
- package/dist/cli/constants.js +3 -3
- package/dist/cli/program.js +25 -1
- package/dist/cli/program.js.map +1 -1
- package/dist/index.js +23188 -17381
- package/dist/index.js.map +4 -4
- package/dist/providers/claude-code.js +39 -30
- package/dist/providers/claude-code.js.map +4 -4
- package/dist/providers/codex.js +39 -30
- package/dist/providers/codex.js.map +4 -4
- package/dist/providers/goose.js +40 -31
- package/dist/providers/goose.js.map +4 -4
- package/dist/providers/kimi.js +39 -30
- package/dist/providers/kimi.js.map +4 -4
- package/dist/providers/opencode.js +40 -31
- package/dist/providers/opencode.js.map +4 -4
- package/dist/providers/poe-agent.js +2 -2
- package/dist/providers/poe-agent.js.map +1 -1
- package/dist/sdk/autonomous.js +2 -20
- package/dist/sdk/autonomous.js.map +1 -1
- package/dist/sdk/pipeline.js +12 -11
- package/dist/sdk/pipeline.js.map +1 -1
- package/dist/sdk/ralph.js +10 -9
- package/dist/sdk/ralph.js.map +1 -1
- package/dist/sdk/spawn.js +5 -3
- package/dist/sdk/spawn.js.map +1 -1
- package/dist/sdk/types.d.ts +11 -0
- package/dist/services/config.d.ts +58 -0
- package/dist/services/config.js +35 -1
- package/dist/services/config.js.map +1 -1
- package/package.json +8 -3
- package/packages/cmdkit/dist/cli.compile-check.d.ts +1 -0
- package/packages/cmdkit/dist/cli.compile-check.js +26 -0
- package/packages/cmdkit/dist/cli.d.ts +12 -0
- package/packages/cmdkit/dist/cli.js +2306 -0
- package/packages/cmdkit/dist/cli.js.map +7 -0
- package/packages/cmdkit/dist/index.compile-check.d.ts +1 -0
- package/packages/cmdkit/dist/index.compile-check.js +50 -0
- package/packages/cmdkit/dist/index.d.ts +164 -0
- package/packages/cmdkit/dist/index.js +518 -0
- package/packages/cmdkit/dist/index.js.map +7 -0
- package/packages/cmdkit/dist/mcp.compile-check.d.ts +1 -0
- package/packages/cmdkit/dist/mcp.compile-check.js +26 -0
- package/packages/cmdkit/dist/mcp.d.ts +16 -0
- package/packages/cmdkit/dist/mcp.js +1153 -0
- package/packages/cmdkit/dist/mcp.js.map +7 -0
- package/packages/cmdkit/dist/renderer.d.ts +5 -0
- package/packages/cmdkit/dist/renderer.js +164 -0
- package/packages/cmdkit/dist/renderer.js.map +7 -0
- package/packages/cmdkit/dist/sdk.compile-check.d.ts +1 -0
- package/packages/cmdkit/dist/sdk.compile-check.js +79 -0
- package/packages/cmdkit/dist/sdk.d.ts +63 -0
- package/packages/cmdkit/dist/sdk.js +314 -0
- package/packages/cmdkit/dist/sdk.js.map +7 -0
- package/packages/cmdkit-schema/dist/index.compile-check.d.ts +1 -0
- package/packages/cmdkit-schema/dist/index.compile-check.js +11 -0
- package/packages/cmdkit-schema/dist/index.d.ts +81 -0
- package/packages/cmdkit-schema/dist/index.js +130 -0
- package/packages/design-system/dist/acp/components.d.ts +11 -0
- package/packages/design-system/dist/acp/components.js +121 -0
- package/packages/design-system/dist/acp/index.d.ts +3 -0
- package/packages/design-system/dist/acp/index.js +2 -0
- package/packages/design-system/dist/acp/writer.d.ts +13 -0
- package/packages/design-system/dist/acp/writer.js +21 -0
- package/packages/design-system/dist/components/command-errors.d.ts +16 -0
- package/packages/design-system/dist/components/command-errors.js +22 -0
- package/packages/design-system/dist/components/help-formatter.d.ts +20 -0
- package/packages/design-system/dist/components/help-formatter.js +27 -0
- package/packages/design-system/dist/components/index.d.ts +10 -0
- package/packages/design-system/dist/components/index.js +7 -0
- package/packages/design-system/dist/components/logger.d.ts +11 -0
- package/packages/design-system/dist/components/logger.js +60 -0
- package/packages/design-system/dist/components/symbols.d.ts +12 -0
- package/packages/design-system/dist/components/symbols.js +71 -0
- package/packages/design-system/dist/components/table.d.ts +13 -0
- package/packages/design-system/dist/components/table.js +74 -0
- package/packages/design-system/dist/components/text.d.ts +14 -0
- package/packages/design-system/dist/components/text.js +104 -0
- package/packages/design-system/dist/dashboard/ansi.d.ts +18 -0
- package/packages/design-system/dist/dashboard/ansi.js +298 -0
- package/packages/design-system/dist/dashboard/buffer.d.ts +25 -0
- package/packages/design-system/dist/dashboard/buffer.js +189 -0
- package/packages/design-system/dist/dashboard/components/border.d.ts +9 -0
- package/packages/design-system/dist/dashboard/components/border.js +123 -0
- package/packages/design-system/dist/dashboard/components/footer.d.ts +8 -0
- package/packages/design-system/dist/dashboard/components/footer.js +58 -0
- package/packages/design-system/dist/dashboard/components/output-pane.d.ts +21 -0
- package/packages/design-system/dist/dashboard/components/output-pane.js +323 -0
- package/packages/design-system/dist/dashboard/components/stats-pane.d.ts +7 -0
- package/packages/design-system/dist/dashboard/components/stats-pane.js +120 -0
- package/packages/design-system/dist/dashboard/dashboard.d.ts +20 -0
- package/packages/design-system/dist/dashboard/dashboard.js +187 -0
- package/packages/design-system/dist/dashboard/demo.d.ts +13 -0
- package/packages/design-system/dist/dashboard/demo.js +145 -0
- package/packages/design-system/dist/dashboard/index.d.ts +7 -0
- package/packages/design-system/dist/dashboard/index.js +3 -0
- package/packages/design-system/dist/dashboard/keymap.d.ts +3 -0
- package/packages/design-system/dist/dashboard/keymap.js +114 -0
- package/packages/design-system/dist/dashboard/layout.d.ts +25 -0
- package/packages/design-system/dist/dashboard/layout.js +79 -0
- package/packages/design-system/dist/dashboard/snapshot.d.ts +10 -0
- package/packages/design-system/dist/dashboard/snapshot.js +72 -0
- package/packages/design-system/dist/dashboard/store.d.ts +9 -0
- package/packages/design-system/dist/dashboard/store.js +107 -0
- package/packages/design-system/dist/dashboard/terminal.d.ts +35 -0
- package/packages/design-system/dist/dashboard/terminal.js +215 -0
- package/packages/design-system/dist/dashboard/types.d.ts +45 -0
- package/packages/design-system/dist/dashboard/types.js +1 -0
- package/packages/design-system/dist/index.d.ts +33 -0
- package/packages/design-system/dist/index.js +31 -0
- package/packages/design-system/dist/internal/output-format.d.ts +6 -0
- package/packages/design-system/dist/internal/output-format.js +22 -0
- package/packages/design-system/dist/internal/strip-ansi.d.ts +1 -0
- package/packages/design-system/dist/internal/strip-ansi.js +3 -0
- package/packages/design-system/dist/internal/theme-detect.d.ts +11 -0
- package/packages/design-system/dist/internal/theme-detect.js +49 -0
- package/packages/design-system/dist/prompts/index.d.ts +66 -0
- package/packages/design-system/dist/prompts/index.js +132 -0
- package/packages/design-system/dist/prompts/primitives/cancel.d.ts +2 -0
- package/packages/design-system/dist/prompts/primitives/cancel.js +9 -0
- package/packages/design-system/dist/prompts/primitives/intro.d.ts +1 -0
- package/packages/design-system/dist/prompts/primitives/intro.js +15 -0
- package/packages/design-system/dist/prompts/primitives/log.d.ts +18 -0
- package/packages/design-system/dist/prompts/primitives/log.js +101 -0
- package/packages/design-system/dist/prompts/primitives/note.d.ts +1 -0
- package/packages/design-system/dist/prompts/primitives/note.js +39 -0
- package/packages/design-system/dist/prompts/primitives/outro.d.ts +1 -0
- package/packages/design-system/dist/prompts/primitives/outro.js +16 -0
- package/packages/design-system/dist/prompts/primitives/spinner.d.ts +6 -0
- package/packages/design-system/dist/prompts/primitives/spinner.js +74 -0
- package/packages/design-system/dist/prompts/theme.d.ts +11 -0
- package/packages/design-system/dist/prompts/theme.js +12 -0
- package/packages/design-system/dist/static/index.d.ts +4 -0
- package/packages/design-system/dist/static/index.js +2 -0
- package/packages/design-system/dist/static/menu.d.ts +11 -0
- package/packages/design-system/dist/static/menu.js +36 -0
- package/packages/design-system/dist/static/spinner.d.ts +14 -0
- package/packages/design-system/dist/static/spinner.js +46 -0
- package/packages/design-system/dist/terminal-markdown/ast.d.ts +84 -0
- package/packages/design-system/dist/terminal-markdown/ast.js +1 -0
- package/packages/design-system/dist/terminal-markdown/demo-content.d.ts +2 -0
- package/packages/design-system/dist/terminal-markdown/demo-content.js +139 -0
- package/packages/design-system/dist/terminal-markdown/index.d.ts +6 -0
- package/packages/design-system/dist/terminal-markdown/index.js +8 -0
- package/packages/design-system/dist/terminal-markdown/parser/block.d.ts +6 -0
- package/packages/design-system/dist/terminal-markdown/parser/block.js +1205 -0
- package/packages/design-system/dist/terminal-markdown/parser/frontmatter.d.ts +6 -0
- package/packages/design-system/dist/terminal-markdown/parser/frontmatter.js +395 -0
- package/packages/design-system/dist/terminal-markdown/parser/inline.d.ts +6 -0
- package/packages/design-system/dist/terminal-markdown/parser/inline.js +1087 -0
- package/packages/design-system/dist/terminal-markdown/parser.d.ts +5 -0
- package/packages/design-system/dist/terminal-markdown/parser.js +13 -0
- package/packages/design-system/dist/terminal-markdown/renderer.d.ts +6 -0
- package/packages/design-system/dist/terminal-markdown/renderer.js +572 -0
- package/packages/design-system/dist/terminal-markdown/testing/theme-render-fixture.d.ts +1 -0
- package/packages/design-system/dist/terminal-markdown/testing/theme-render-fixture.js +27 -0
- package/packages/design-system/dist/tokens/colors.d.ts +35 -0
- package/packages/design-system/dist/tokens/colors.js +34 -0
- package/packages/design-system/dist/tokens/index.d.ts +4 -0
- package/packages/design-system/dist/tokens/index.js +4 -0
- package/packages/design-system/dist/tokens/spacing.d.ts +6 -0
- package/packages/design-system/dist/tokens/spacing.js +6 -0
- package/packages/design-system/dist/tokens/typography.d.ts +7 -0
- package/packages/design-system/dist/tokens/typography.js +8 -0
- package/packages/design-system/dist/tokens/widths.d.ts +5 -0
- package/packages/design-system/dist/tokens/widths.js +5 -0
- package/packages/tiny-stdio-mcp-server/dist/content/audio.d.ts +14 -0
- package/packages/tiny-stdio-mcp-server/dist/content/audio.js +76 -0
- package/packages/tiny-stdio-mcp-server/dist/content/convert.d.ts +16 -0
- package/packages/tiny-stdio-mcp-server/dist/content/convert.js +42 -0
- package/packages/tiny-stdio-mcp-server/dist/content/file-type.d.ts +11 -0
- package/packages/tiny-stdio-mcp-server/dist/content/file-type.js +93 -0
- package/packages/tiny-stdio-mcp-server/dist/content/file.d.ts +26 -0
- package/packages/tiny-stdio-mcp-server/dist/content/file.js +94 -0
- package/packages/tiny-stdio-mcp-server/dist/content/image.d.ts +14 -0
- package/packages/tiny-stdio-mcp-server/dist/content/image.js +64 -0
- package/packages/tiny-stdio-mcp-server/dist/content/index.d.ts +5 -0
- package/packages/tiny-stdio-mcp-server/dist/content/index.js +8 -0
- package/packages/tiny-stdio-mcp-server/dist/content/mime.d.ts +1 -0
- package/packages/tiny-stdio-mcp-server/dist/content/mime.js +1 -0
- package/packages/tiny-stdio-mcp-server/dist/index.d.ts +9 -0
- package/packages/tiny-stdio-mcp-server/dist/index.js +7 -0
- package/packages/tiny-stdio-mcp-server/dist/jsonrpc.d.ts +14 -0
- package/packages/tiny-stdio-mcp-server/dist/jsonrpc.js +99 -0
- package/packages/tiny-stdio-mcp-server/dist/schema.d.ts +19 -0
- package/packages/tiny-stdio-mcp-server/dist/schema.js +18 -0
- package/packages/tiny-stdio-mcp-server/dist/server.d.ts +13 -0
- package/packages/tiny-stdio-mcp-server/dist/server.js +226 -0
- package/packages/tiny-stdio-mcp-server/dist/testing.d.ts +7 -0
- package/packages/tiny-stdio-mcp-server/dist/testing.js +20 -0
- package/packages/tiny-stdio-mcp-server/dist/types.d.ts +119 -0
- package/packages/tiny-stdio-mcp-server/dist/types.js +16 -0
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import chalk from "chalk";
|
|
2
|
+
import * as clack from "@clack/prompts";
|
|
3
|
+
import { resolveOutputFormat } from "../internal/output-format.js";
|
|
4
|
+
import { stripAnsi } from "../internal/strip-ansi.js";
|
|
5
|
+
import { cancel, isCancel } from "./primitives/cancel.js";
|
|
6
|
+
import { intro } from "./primitives/intro.js";
|
|
7
|
+
import { log } from "./primitives/log.js";
|
|
8
|
+
import { note } from "./primitives/note.js";
|
|
9
|
+
import { outro } from "./primitives/outro.js";
|
|
10
|
+
import { spinner } from "./primitives/spinner.js";
|
|
11
|
+
export { isCancel, cancel, log };
|
|
12
|
+
export { intro, outro, note, spinner };
|
|
13
|
+
export function introPlain(title) {
|
|
14
|
+
const format = resolveOutputFormat();
|
|
15
|
+
if (format === "markdown") {
|
|
16
|
+
process.stdout.write(`# ${stripAnsi(title)}\n\n`);
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
if (format === "json") {
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
process.stdout.write(`${chalk.gray("┌")} ${title}\n`);
|
|
23
|
+
}
|
|
24
|
+
export async function select(opts) {
|
|
25
|
+
return clack.select(opts);
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Prompts the user to select one or more values from a list.
|
|
29
|
+
*
|
|
30
|
+
* Returns the selected values as an array, or a cancellation symbol if the
|
|
31
|
+
* user cancels. Use `isCancel` to check for cancellation.
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* const result = await multiselect({
|
|
35
|
+
* message: "Pick workflows to run",
|
|
36
|
+
* options: [{ label: "Fix Vulnerabilities", value: "fix-vulnerabilities" }],
|
|
37
|
+
* required: true
|
|
38
|
+
* });
|
|
39
|
+
* if (!isCancel(result)) {
|
|
40
|
+
* // result is Value[]
|
|
41
|
+
* }
|
|
42
|
+
*/
|
|
43
|
+
export async function multiselect(opts) {
|
|
44
|
+
return clack.multiselect(opts);
|
|
45
|
+
}
|
|
46
|
+
export async function text(opts) {
|
|
47
|
+
return clack.text(opts);
|
|
48
|
+
}
|
|
49
|
+
export async function confirm(opts) {
|
|
50
|
+
return clack.confirm(opts);
|
|
51
|
+
}
|
|
52
|
+
export class PromptCancelledError extends Error {
|
|
53
|
+
constructor(message = "Operation cancelled.") {
|
|
54
|
+
super(message);
|
|
55
|
+
this.name = "PromptCancelledError";
|
|
56
|
+
if (Error.captureStackTrace) {
|
|
57
|
+
Error.captureStackTrace(this, this.constructor);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
export async function confirmOrCancel(opts) {
|
|
62
|
+
const result = await confirm(opts);
|
|
63
|
+
if (isCancel(result)) {
|
|
64
|
+
cancel("Operation cancelled.");
|
|
65
|
+
throw new PromptCancelledError();
|
|
66
|
+
}
|
|
67
|
+
return result === true;
|
|
68
|
+
}
|
|
69
|
+
export async function password(opts) {
|
|
70
|
+
return clack.password(opts);
|
|
71
|
+
}
|
|
72
|
+
function formatElapsed(ms) {
|
|
73
|
+
const totalSeconds = Math.floor(ms / 1000);
|
|
74
|
+
if (totalSeconds < 60) {
|
|
75
|
+
return `${totalSeconds}s`;
|
|
76
|
+
}
|
|
77
|
+
const minutes = Math.floor(totalSeconds / 60);
|
|
78
|
+
const seconds = totalSeconds % 60;
|
|
79
|
+
return `${minutes}m ${seconds}s`;
|
|
80
|
+
}
|
|
81
|
+
export async function withSpinner(options) {
|
|
82
|
+
const { message, fn, stopMessage, subtext } = options;
|
|
83
|
+
if (resolveOutputFormat() === "json") {
|
|
84
|
+
const result = await fn();
|
|
85
|
+
const sub = subtext ? subtext(result) : undefined;
|
|
86
|
+
if (sub) {
|
|
87
|
+
process.stdout.write(sub + "\n");
|
|
88
|
+
}
|
|
89
|
+
return result;
|
|
90
|
+
}
|
|
91
|
+
const noSpinner = process.env.POE_NO_SPINNER === "1";
|
|
92
|
+
const isTTY = process.stdout.isTTY;
|
|
93
|
+
if (noSpinner || !isTTY) {
|
|
94
|
+
const result = await fn();
|
|
95
|
+
const msg = stopMessage ? stopMessage(result) : undefined;
|
|
96
|
+
if (msg) {
|
|
97
|
+
process.stdout.write(`\x1b[32m◆\x1b[0m ${msg}\n`);
|
|
98
|
+
}
|
|
99
|
+
const sub = subtext ? subtext(result) : undefined;
|
|
100
|
+
if (sub) {
|
|
101
|
+
for (const line of sub.split("\n")) {
|
|
102
|
+
process.stdout.write(`\x1b[90m│\x1b[0m ${line}\n`);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
return result;
|
|
106
|
+
}
|
|
107
|
+
const s = spinner();
|
|
108
|
+
const start = Date.now();
|
|
109
|
+
s.start(message);
|
|
110
|
+
const timer = setInterval(() => {
|
|
111
|
+
s.message(`${message} [${formatElapsed(Date.now() - start)}]`);
|
|
112
|
+
}, 1000);
|
|
113
|
+
try {
|
|
114
|
+
const result = await fn();
|
|
115
|
+
clearInterval(timer);
|
|
116
|
+
const elapsed = formatElapsed(Date.now() - start);
|
|
117
|
+
const msg = stopMessage ? stopMessage(result) : undefined;
|
|
118
|
+
s.stop(msg ? `${msg} [${elapsed}]` : `Done [${elapsed}]`);
|
|
119
|
+
const sub = subtext ? subtext(result) : undefined;
|
|
120
|
+
if (sub) {
|
|
121
|
+
for (const line of sub.split("\n")) {
|
|
122
|
+
process.stdout.write(`\x1b[90m│\x1b[0m ${line}\n`);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
return result;
|
|
126
|
+
}
|
|
127
|
+
catch (error) {
|
|
128
|
+
clearInterval(timer);
|
|
129
|
+
s.stop("", 1);
|
|
130
|
+
throw error;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import chalk from "chalk";
|
|
2
|
+
export { isCancel } from "@clack/core";
|
|
3
|
+
import { resolveOutputFormat } from "../../internal/output-format.js";
|
|
4
|
+
export function cancel(msg = "") {
|
|
5
|
+
if (resolveOutputFormat() !== "terminal") {
|
|
6
|
+
return;
|
|
7
|
+
}
|
|
8
|
+
process.stdout.write(`${chalk.gray("└")} ${chalk.red(msg)}\n\n`);
|
|
9
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function intro(title: string): void;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import chalk from "chalk";
|
|
2
|
+
import { text } from "../../components/text.js";
|
|
3
|
+
import { resolveOutputFormat } from "../../internal/output-format.js";
|
|
4
|
+
import { stripAnsi } from "../../internal/strip-ansi.js";
|
|
5
|
+
export function intro(title) {
|
|
6
|
+
const format = resolveOutputFormat();
|
|
7
|
+
if (format === "json") {
|
|
8
|
+
return;
|
|
9
|
+
}
|
|
10
|
+
if (format === "markdown") {
|
|
11
|
+
process.stdout.write(`# ${stripAnsi(title)}\n\n`);
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
process.stdout.write(`${chalk.gray("┌")} ${text.intro(title)}\n`);
|
|
15
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export interface LogMessageOptions {
|
|
2
|
+
symbol?: string;
|
|
3
|
+
secondarySymbol?: string;
|
|
4
|
+
spacing?: number;
|
|
5
|
+
withGuide?: boolean;
|
|
6
|
+
}
|
|
7
|
+
export declare function message(msg: string, options?: LogMessageOptions): void;
|
|
8
|
+
export declare function info(msg: string): void;
|
|
9
|
+
export declare function success(msg: string): void;
|
|
10
|
+
export declare function warn(msg: string): void;
|
|
11
|
+
export declare function error(msg: string): void;
|
|
12
|
+
export declare const log: {
|
|
13
|
+
info: typeof info;
|
|
14
|
+
success: typeof success;
|
|
15
|
+
message: typeof message;
|
|
16
|
+
warn: typeof warn;
|
|
17
|
+
error: typeof error;
|
|
18
|
+
};
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import chalk from "chalk";
|
|
2
|
+
import { symbols } from "../../components/symbols.js";
|
|
3
|
+
import { resolveOutputFormat } from "../../internal/output-format.js";
|
|
4
|
+
import { stripAnsi } from "../../internal/strip-ansi.js";
|
|
5
|
+
function writeTerminalMessage(msg, { symbol = chalk.gray("│"), secondarySymbol = chalk.gray("│"), spacing = 1, withGuide = true } = {}) {
|
|
6
|
+
const lines = [];
|
|
7
|
+
const showGuide = withGuide !== false;
|
|
8
|
+
const contentLines = msg.split("\n");
|
|
9
|
+
const prefix = showGuide ? `${symbol} ` : "";
|
|
10
|
+
const continuationPrefix = showGuide ? `${secondarySymbol} ` : "";
|
|
11
|
+
const emptyGuide = showGuide ? secondarySymbol : "";
|
|
12
|
+
for (let index = 0; index < spacing; index += 1) {
|
|
13
|
+
lines.push(emptyGuide);
|
|
14
|
+
}
|
|
15
|
+
if (contentLines.length === 0) {
|
|
16
|
+
process.stdout.write("\n");
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
const [firstLine = "", ...continuationLines] = contentLines;
|
|
20
|
+
if (firstLine.length > 0) {
|
|
21
|
+
lines.push(`${prefix}${firstLine}`);
|
|
22
|
+
}
|
|
23
|
+
else {
|
|
24
|
+
lines.push(showGuide ? symbol : "");
|
|
25
|
+
}
|
|
26
|
+
for (const line of continuationLines) {
|
|
27
|
+
if (line.length > 0) {
|
|
28
|
+
lines.push(`${continuationPrefix}${line}`);
|
|
29
|
+
continue;
|
|
30
|
+
}
|
|
31
|
+
lines.push(emptyGuide);
|
|
32
|
+
}
|
|
33
|
+
process.stdout.write(`${lines.join("\n")}\n`);
|
|
34
|
+
}
|
|
35
|
+
export function message(msg, options) {
|
|
36
|
+
const format = resolveOutputFormat();
|
|
37
|
+
if (format === "markdown") {
|
|
38
|
+
process.stdout.write(`- ${stripAnsi(msg)}\n`);
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
if (format === "json") {
|
|
42
|
+
process.stdout.write(`${JSON.stringify({ level: "message", message: stripAnsi(msg) })}\n`);
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
writeTerminalMessage(msg, options);
|
|
46
|
+
}
|
|
47
|
+
export function info(msg) {
|
|
48
|
+
const format = resolveOutputFormat();
|
|
49
|
+
if (format === "markdown") {
|
|
50
|
+
process.stdout.write(`- **info:** ${stripAnsi(msg)}\n`);
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
if (format === "json") {
|
|
54
|
+
process.stdout.write(`${JSON.stringify({ level: "info", message: stripAnsi(msg) })}\n`);
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
message(msg, { symbol: symbols.info });
|
|
58
|
+
}
|
|
59
|
+
export function success(msg) {
|
|
60
|
+
const format = resolveOutputFormat();
|
|
61
|
+
if (format === "markdown") {
|
|
62
|
+
process.stdout.write(`- **success:** ${stripAnsi(msg)}\n`);
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
if (format === "json") {
|
|
66
|
+
process.stdout.write(`${JSON.stringify({ level: "success", message: stripAnsi(msg) })}\n`);
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
message(msg, { symbol: symbols.success });
|
|
70
|
+
}
|
|
71
|
+
export function warn(msg) {
|
|
72
|
+
const format = resolveOutputFormat();
|
|
73
|
+
if (format === "markdown") {
|
|
74
|
+
process.stdout.write(`- **warning:** ${stripAnsi(msg)}\n`);
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
if (format === "json") {
|
|
78
|
+
process.stdout.write(`${JSON.stringify({ level: "warn", message: stripAnsi(msg) })}\n`);
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
message(msg, { symbol: chalk.yellow("▲") });
|
|
82
|
+
}
|
|
83
|
+
export function error(msg) {
|
|
84
|
+
const format = resolveOutputFormat();
|
|
85
|
+
if (format === "markdown") {
|
|
86
|
+
process.stdout.write(`- **error:** ${stripAnsi(msg)}\n`);
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
if (format === "json") {
|
|
90
|
+
process.stdout.write(`${JSON.stringify({ level: "error", message: stripAnsi(msg) })}\n`);
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
message(msg, { symbol: chalk.red("■") });
|
|
94
|
+
}
|
|
95
|
+
export const log = {
|
|
96
|
+
info,
|
|
97
|
+
success,
|
|
98
|
+
message,
|
|
99
|
+
warn,
|
|
100
|
+
error
|
|
101
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function note(message: string, title?: string): void;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import chalk from "chalk";
|
|
2
|
+
import { resolveOutputFormat } from "../../internal/output-format.js";
|
|
3
|
+
import { stripAnsi } from "../../internal/strip-ansi.js";
|
|
4
|
+
function getVisibleWidth(value) {
|
|
5
|
+
return stripAnsi(value).length;
|
|
6
|
+
}
|
|
7
|
+
function renderTerminalNote(message, title) {
|
|
8
|
+
const contentLines = ["", ...message.split("\n"), ""];
|
|
9
|
+
const visibleTitle = stripAnsi(title ?? "");
|
|
10
|
+
const contentWidth = Math.max(visibleTitle.length, ...contentLines.map((line) => getVisibleWidth(line))) + 2;
|
|
11
|
+
const titleLine = `${chalk.green("◇")} ${chalk.reset(title ?? "")} ${chalk.gray(`${"─".repeat(Math.max(contentWidth - visibleTitle.length - 1, 1))}╮`)}`;
|
|
12
|
+
const content = contentLines.map((line) => {
|
|
13
|
+
const padding = " ".repeat(contentWidth - getVisibleWidth(line));
|
|
14
|
+
return `${chalk.gray("│")} ${line}${padding}${chalk.gray("│")}`;
|
|
15
|
+
});
|
|
16
|
+
const bottom = chalk.gray(`├${"─".repeat(contentWidth + 2)}╯`);
|
|
17
|
+
return [chalk.gray("│"), titleLine, ...content, bottom].join("\n");
|
|
18
|
+
}
|
|
19
|
+
export function note(message, title) {
|
|
20
|
+
const format = resolveOutputFormat();
|
|
21
|
+
const strippedMessage = stripAnsi(message);
|
|
22
|
+
const strippedTitle = stripAnsi(title ?? "");
|
|
23
|
+
if (format === "markdown") {
|
|
24
|
+
const lines = strippedMessage.split("\n");
|
|
25
|
+
const heading = strippedTitle ? `> **${strippedTitle}**\n` : "";
|
|
26
|
+
const body = lines.map((line) => `> ${line}`).join("\n");
|
|
27
|
+
process.stdout.write(`${heading}${body}\n`);
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
if (format === "json") {
|
|
31
|
+
process.stdout.write(`${JSON.stringify({
|
|
32
|
+
type: "note",
|
|
33
|
+
title: strippedTitle,
|
|
34
|
+
message: strippedMessage
|
|
35
|
+
})}\n`);
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
process.stdout.write(`${renderTerminalNote(message, title)}\n`);
|
|
39
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function outro(message: string): void;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import chalk from "chalk";
|
|
2
|
+
import { resolveOutputFormat } from "../../internal/output-format.js";
|
|
3
|
+
import { stripAnsi } from "../../internal/strip-ansi.js";
|
|
4
|
+
export function outro(message) {
|
|
5
|
+
const format = resolveOutputFormat();
|
|
6
|
+
const stripped = stripAnsi(message);
|
|
7
|
+
if (format === "markdown") {
|
|
8
|
+
process.stdout.write(`---\n${stripped}\n`);
|
|
9
|
+
return;
|
|
10
|
+
}
|
|
11
|
+
if (format === "json") {
|
|
12
|
+
process.stdout.write(`${JSON.stringify({ type: "outro", message: stripped })}\n`);
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
process.stdout.write(`${chalk.gray("│")}\n${chalk.gray("└")} ${message}\n\n`);
|
|
16
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import chalk from "chalk";
|
|
2
|
+
import { resolveOutputFormat } from "../../internal/output-format.js";
|
|
3
|
+
import { stripAnsi } from "../../internal/strip-ansi.js";
|
|
4
|
+
import { SPINNER_FRAMES } from "../../static/spinner.js";
|
|
5
|
+
function writeTerminalFrame(frame, message) {
|
|
6
|
+
process.stdout.write(`\r\x1b[K${frame} ${message}`);
|
|
7
|
+
}
|
|
8
|
+
export function spinner() {
|
|
9
|
+
let currentMessage = "";
|
|
10
|
+
let frameIndex = 0;
|
|
11
|
+
let timer;
|
|
12
|
+
let fallback = false;
|
|
13
|
+
const format = resolveOutputFormat();
|
|
14
|
+
const renderFrame = () => {
|
|
15
|
+
writeTerminalFrame(SPINNER_FRAMES[frameIndex % SPINNER_FRAMES.length], currentMessage);
|
|
16
|
+
};
|
|
17
|
+
const clearTimer = () => {
|
|
18
|
+
if (!timer) {
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
clearInterval(timer);
|
|
22
|
+
timer = undefined;
|
|
23
|
+
};
|
|
24
|
+
return {
|
|
25
|
+
start(message = "") {
|
|
26
|
+
currentMessage = stripAnsi(message);
|
|
27
|
+
if (format === "json") {
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
if (format === "markdown") {
|
|
31
|
+
process.stdout.write(`- ${currentMessage}...\n`);
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
fallback = process.env.POE_NO_SPINNER === "1" || !process.stdout.isTTY;
|
|
35
|
+
if (fallback) {
|
|
36
|
+
process.stdout.write(`${currentMessage}\n`);
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
frameIndex = 0;
|
|
40
|
+
renderFrame();
|
|
41
|
+
timer = setInterval(() => {
|
|
42
|
+
frameIndex += 1;
|
|
43
|
+
renderFrame();
|
|
44
|
+
}, 16);
|
|
45
|
+
},
|
|
46
|
+
message(message = "") {
|
|
47
|
+
currentMessage = stripAnsi(message);
|
|
48
|
+
if (format !== "terminal" || fallback || !timer) {
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
renderFrame();
|
|
52
|
+
},
|
|
53
|
+
stop(message = currentMessage, code) {
|
|
54
|
+
currentMessage = stripAnsi(message);
|
|
55
|
+
if (format === "json") {
|
|
56
|
+
process.stdout.write(`${JSON.stringify({ type: "spinner", state: "stopped", message: currentMessage })}\n`);
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
if (format === "markdown") {
|
|
60
|
+
process.stdout.write(`- ${currentMessage}\n`);
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
clearTimer();
|
|
64
|
+
const symbol = code === undefined || code === 0
|
|
65
|
+
? chalk.green("◆")
|
|
66
|
+
: chalk.red("■");
|
|
67
|
+
if (fallback) {
|
|
68
|
+
process.stdout.write(`${symbol} ${currentMessage}\n`);
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
process.stdout.write(`\r\x1b[K${symbol} ${currentMessage}\n`);
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { SPINNER_FRAMES, renderSpinnerFrame, renderSpinnerStopped } from "./spinner.js";
|
|
2
|
+
export type { SpinnerFrameOptions, SpinnerStoppedOptions } from "./spinner.js";
|
|
3
|
+
export { renderMenu } from "./menu.js";
|
|
4
|
+
export type { MenuOption, RenderMenuOptions } from "./menu.js";
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export interface MenuOption {
|
|
2
|
+
label: string;
|
|
3
|
+
value: string;
|
|
4
|
+
hint?: string;
|
|
5
|
+
}
|
|
6
|
+
export interface RenderMenuOptions {
|
|
7
|
+
message: string;
|
|
8
|
+
options: MenuOption[];
|
|
9
|
+
selectedIndex?: number;
|
|
10
|
+
}
|
|
11
|
+
export declare function renderMenu(opts: RenderMenuOptions): string;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import chalk from "chalk";
|
|
2
|
+
import { symbols } from "../components/symbols.js";
|
|
3
|
+
import { resolveOutputFormat } from "../internal/output-format.js";
|
|
4
|
+
import { getTheme } from "../internal/theme-detect.js";
|
|
5
|
+
export function renderMenu(opts) {
|
|
6
|
+
const format = resolveOutputFormat();
|
|
7
|
+
const selectedIndex = opts.selectedIndex ?? 0;
|
|
8
|
+
if (format === "markdown") {
|
|
9
|
+
return [
|
|
10
|
+
`**${opts.message}**`,
|
|
11
|
+
...opts.options.map((option, index) => `- [${index === selectedIndex ? "x" : " "}] ${option.label}`)
|
|
12
|
+
].join("\n");
|
|
13
|
+
}
|
|
14
|
+
if (format === "json") {
|
|
15
|
+
return JSON.stringify({
|
|
16
|
+
type: "menu",
|
|
17
|
+
message: opts.message,
|
|
18
|
+
options: opts.options,
|
|
19
|
+
selected: selectedIndex
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
const theme = getTheme();
|
|
23
|
+
const bar = chalk.gray(symbols.bar);
|
|
24
|
+
const lines = [];
|
|
25
|
+
lines.push(`${chalk.cyan(symbols.active)} ${opts.message}`);
|
|
26
|
+
lines.push(bar);
|
|
27
|
+
opts.options.forEach((option, index) => {
|
|
28
|
+
const isSelected = index === selectedIndex;
|
|
29
|
+
const prefix = isSelected ? chalk.cyan(symbols.active) : chalk.gray(symbols.inactive);
|
|
30
|
+
const label = isSelected ? theme.accent(option.label) : option.label;
|
|
31
|
+
const hint = option.hint ? chalk.dim(` (${option.hint})`) : "";
|
|
32
|
+
lines.push(`${bar} ${prefix} ${label}${hint}`);
|
|
33
|
+
});
|
|
34
|
+
lines.push(`${bar}`);
|
|
35
|
+
return lines.join("\n");
|
|
36
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export declare const SPINNER_FRAMES: readonly ["◒", "◐", "◓", "◑"];
|
|
2
|
+
export interface SpinnerFrameOptions {
|
|
3
|
+
frame?: number;
|
|
4
|
+
message: string;
|
|
5
|
+
timer?: string;
|
|
6
|
+
}
|
|
7
|
+
export declare function renderSpinnerFrame(options: SpinnerFrameOptions): string;
|
|
8
|
+
export interface SpinnerStoppedOptions {
|
|
9
|
+
message: string;
|
|
10
|
+
code?: number;
|
|
11
|
+
timer?: string;
|
|
12
|
+
subtext?: string;
|
|
13
|
+
}
|
|
14
|
+
export declare function renderSpinnerStopped(options: SpinnerStoppedOptions): string;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import chalk from "chalk";
|
|
2
|
+
import { symbols } from "../components/symbols.js";
|
|
3
|
+
import { resolveOutputFormat } from "../internal/output-format.js";
|
|
4
|
+
export const SPINNER_FRAMES = ["◒", "◐", "◓", "◑"];
|
|
5
|
+
export function renderSpinnerFrame(options) {
|
|
6
|
+
const format = resolveOutputFormat();
|
|
7
|
+
if (format === "markdown") {
|
|
8
|
+
return `- ${options.message}${options.timer ? ` [${options.timer}]` : ""}...\n`;
|
|
9
|
+
}
|
|
10
|
+
if (format === "json") {
|
|
11
|
+
return `${JSON.stringify({
|
|
12
|
+
type: "spinner",
|
|
13
|
+
state: "running",
|
|
14
|
+
message: options.message,
|
|
15
|
+
...(options.timer ? { timer: options.timer } : {})
|
|
16
|
+
})}\n`;
|
|
17
|
+
}
|
|
18
|
+
const frame = options.frame ?? 0;
|
|
19
|
+
const spinnerChar = chalk.magenta(SPINNER_FRAMES[frame % SPINNER_FRAMES.length]);
|
|
20
|
+
const timerSuffix = options.timer ? chalk.dim(` [${options.timer}]`) : "";
|
|
21
|
+
const bar = chalk.gray(symbols.bar);
|
|
22
|
+
return `${spinnerChar} ${options.message}${timerSuffix}\n${bar}`;
|
|
23
|
+
}
|
|
24
|
+
export function renderSpinnerStopped(options) {
|
|
25
|
+
const format = resolveOutputFormat();
|
|
26
|
+
if (format === "markdown") {
|
|
27
|
+
return `- ${options.message}${options.timer ? ` [${options.timer}]` : ""}\n`;
|
|
28
|
+
}
|
|
29
|
+
if (format === "json") {
|
|
30
|
+
return `${JSON.stringify({
|
|
31
|
+
type: "spinner",
|
|
32
|
+
state: "stopped",
|
|
33
|
+
message: options.message,
|
|
34
|
+
...(options.timer ? { timer: options.timer } : {})
|
|
35
|
+
})}\n`;
|
|
36
|
+
}
|
|
37
|
+
const code = options.code ?? 0;
|
|
38
|
+
const symbol = code === 0 ? chalk.green("◆") : chalk.red("■");
|
|
39
|
+
const timerSuffix = options.timer ? chalk.dim(` [${options.timer}]`) : "";
|
|
40
|
+
const bar = chalk.gray(symbols.bar);
|
|
41
|
+
let output = `${symbol} ${options.message}${timerSuffix}`;
|
|
42
|
+
if (options.subtext) {
|
|
43
|
+
output += `\n${bar} ${chalk.dim(options.subtext)}`;
|
|
44
|
+
}
|
|
45
|
+
return output;
|
|
46
|
+
}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
export type MdNode = {
|
|
2
|
+
type: "root";
|
|
3
|
+
children: MdNode[];
|
|
4
|
+
} | {
|
|
5
|
+
type: "heading";
|
|
6
|
+
depth: 1 | 2 | 3 | 4 | 5 | 6;
|
|
7
|
+
children: MdNode[];
|
|
8
|
+
} | {
|
|
9
|
+
type: "paragraph";
|
|
10
|
+
children: MdNode[];
|
|
11
|
+
} | {
|
|
12
|
+
type: "blockquote";
|
|
13
|
+
children: MdNode[];
|
|
14
|
+
} | {
|
|
15
|
+
type: "code";
|
|
16
|
+
lang?: string;
|
|
17
|
+
meta?: string;
|
|
18
|
+
value: string;
|
|
19
|
+
} | {
|
|
20
|
+
type: "list";
|
|
21
|
+
ordered: boolean;
|
|
22
|
+
start?: number;
|
|
23
|
+
children: MdNode[];
|
|
24
|
+
} | {
|
|
25
|
+
type: "listItem";
|
|
26
|
+
checked?: boolean;
|
|
27
|
+
children: MdNode[];
|
|
28
|
+
} | {
|
|
29
|
+
type: "thematicBreak";
|
|
30
|
+
} | {
|
|
31
|
+
type: "table";
|
|
32
|
+
align: Array<"left" | "center" | "right" | null>;
|
|
33
|
+
children: MdNode[];
|
|
34
|
+
} | {
|
|
35
|
+
type: "tableRow";
|
|
36
|
+
children: MdNode[];
|
|
37
|
+
} | {
|
|
38
|
+
type: "tableCell";
|
|
39
|
+
children: MdNode[];
|
|
40
|
+
} | {
|
|
41
|
+
type: "html";
|
|
42
|
+
value: string;
|
|
43
|
+
} | {
|
|
44
|
+
type: "text";
|
|
45
|
+
value: string;
|
|
46
|
+
} | {
|
|
47
|
+
type: "emphasis";
|
|
48
|
+
children: MdNode[];
|
|
49
|
+
} | {
|
|
50
|
+
type: "strong";
|
|
51
|
+
children: MdNode[];
|
|
52
|
+
} | {
|
|
53
|
+
type: "strikethrough";
|
|
54
|
+
children: MdNode[];
|
|
55
|
+
} | {
|
|
56
|
+
type: "inlineCode";
|
|
57
|
+
value: string;
|
|
58
|
+
} | {
|
|
59
|
+
type: "link";
|
|
60
|
+
url: string;
|
|
61
|
+
title?: string;
|
|
62
|
+
children: MdNode[];
|
|
63
|
+
} | {
|
|
64
|
+
type: "image";
|
|
65
|
+
url: string;
|
|
66
|
+
alt: string;
|
|
67
|
+
title?: string;
|
|
68
|
+
} | {
|
|
69
|
+
type: "break";
|
|
70
|
+
} | {
|
|
71
|
+
type: "frontmatter";
|
|
72
|
+
data: Record<string, unknown>;
|
|
73
|
+
} | {
|
|
74
|
+
type: "alert";
|
|
75
|
+
kind: "NOTE" | "TIP" | "IMPORTANT" | "WARNING" | "CAUTION";
|
|
76
|
+
children: MdNode[];
|
|
77
|
+
} | {
|
|
78
|
+
type: "footnoteDefinition";
|
|
79
|
+
label: string;
|
|
80
|
+
children: MdNode[];
|
|
81
|
+
} | {
|
|
82
|
+
type: "footnoteReference";
|
|
83
|
+
label: string;
|
|
84
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|