toolcraft-openapi 0.0.1
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/README.md +64 -0
- package/dist/api-command.d.ts +7 -0
- package/dist/api-command.js +4 -0
- package/dist/auth/bearer-token-auth.d.ts +8 -0
- package/dist/auth/bearer-token-auth.js +216 -0
- package/dist/auth/types.d.ts +9 -0
- package/dist/auth/types.js +1 -0
- package/dist/bin/generate.d.ts +40 -0
- package/dist/bin/generate.js +248 -0
- package/dist/define-client.d.ts +20 -0
- package/dist/define-client.js +148 -0
- package/dist/generate.d.ts +210 -0
- package/dist/generate.js +1131 -0
- package/dist/group-by-noun.d.ts +6 -0
- package/dist/group-by-noun.js +17 -0
- package/dist/http.d.ts +26 -0
- package/dist/http.js +123 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.js +6 -0
- package/dist/interpreter.d.ts +6 -0
- package/dist/interpreter.js +289 -0
- package/dist/lock.d.ts +14 -0
- package/dist/lock.js +48 -0
- package/dist/naming.d.ts +24 -0
- package/dist/naming.js +218 -0
- package/dist/request-shape.d.ts +15 -0
- package/dist/request-shape.js +5 -0
- package/dist/runtime.d.ts +13 -0
- package/dist/runtime.js +94 -0
- package/dist/spec-source.d.ts +11 -0
- package/dist/spec-source.js +63 -0
- package/node_modules/@poe-code/design-system/dist/acp/components.d.ts +11 -0
- package/node_modules/@poe-code/design-system/dist/acp/components.js +121 -0
- package/node_modules/@poe-code/design-system/dist/acp/index.d.ts +3 -0
- package/node_modules/@poe-code/design-system/dist/acp/index.js +2 -0
- package/node_modules/@poe-code/design-system/dist/acp/writer.d.ts +13 -0
- package/node_modules/@poe-code/design-system/dist/acp/writer.js +21 -0
- package/node_modules/@poe-code/design-system/dist/components/command-errors.d.ts +16 -0
- package/node_modules/@poe-code/design-system/dist/components/command-errors.js +22 -0
- package/node_modules/@poe-code/design-system/dist/components/help-formatter.d.ts +20 -0
- package/node_modules/@poe-code/design-system/dist/components/help-formatter.js +27 -0
- package/node_modules/@poe-code/design-system/dist/components/index.d.ts +10 -0
- package/node_modules/@poe-code/design-system/dist/components/index.js +7 -0
- package/node_modules/@poe-code/design-system/dist/components/logger.d.ts +11 -0
- package/node_modules/@poe-code/design-system/dist/components/logger.js +60 -0
- package/node_modules/@poe-code/design-system/dist/components/symbols.d.ts +12 -0
- package/node_modules/@poe-code/design-system/dist/components/symbols.js +71 -0
- package/node_modules/@poe-code/design-system/dist/components/table.d.ts +13 -0
- package/node_modules/@poe-code/design-system/dist/components/table.js +74 -0
- package/node_modules/@poe-code/design-system/dist/components/text.d.ts +14 -0
- package/node_modules/@poe-code/design-system/dist/components/text.js +104 -0
- package/node_modules/@poe-code/design-system/dist/dashboard/ansi.d.ts +18 -0
- package/node_modules/@poe-code/design-system/dist/dashboard/ansi.js +298 -0
- package/node_modules/@poe-code/design-system/dist/dashboard/buffer.d.ts +25 -0
- package/node_modules/@poe-code/design-system/dist/dashboard/buffer.js +189 -0
- package/node_modules/@poe-code/design-system/dist/dashboard/components/border.d.ts +9 -0
- package/node_modules/@poe-code/design-system/dist/dashboard/components/border.js +123 -0
- package/node_modules/@poe-code/design-system/dist/dashboard/components/footer.d.ts +8 -0
- package/node_modules/@poe-code/design-system/dist/dashboard/components/footer.js +57 -0
- package/node_modules/@poe-code/design-system/dist/dashboard/components/output-pane.d.ts +12 -0
- package/node_modules/@poe-code/design-system/dist/dashboard/components/output-pane.js +254 -0
- package/node_modules/@poe-code/design-system/dist/dashboard/components/stats-pane.d.ts +7 -0
- package/node_modules/@poe-code/design-system/dist/dashboard/components/stats-pane.js +121 -0
- package/node_modules/@poe-code/design-system/dist/dashboard/dashboard.d.ts +20 -0
- package/node_modules/@poe-code/design-system/dist/dashboard/dashboard.js +167 -0
- package/node_modules/@poe-code/design-system/dist/dashboard/demo.d.ts +13 -0
- package/node_modules/@poe-code/design-system/dist/dashboard/demo.js +145 -0
- package/node_modules/@poe-code/design-system/dist/dashboard/index.d.ts +8 -0
- package/node_modules/@poe-code/design-system/dist/dashboard/index.js +4 -0
- package/node_modules/@poe-code/design-system/dist/dashboard/keymap.d.ts +3 -0
- package/node_modules/@poe-code/design-system/dist/dashboard/keymap.js +99 -0
- package/node_modules/@poe-code/design-system/dist/dashboard/layout.d.ts +25 -0
- package/node_modules/@poe-code/design-system/dist/dashboard/layout.js +79 -0
- package/node_modules/@poe-code/design-system/dist/dashboard/should-use-dashboard.d.ts +10 -0
- package/node_modules/@poe-code/design-system/dist/dashboard/should-use-dashboard.js +7 -0
- package/node_modules/@poe-code/design-system/dist/dashboard/snapshot.d.ts +10 -0
- package/node_modules/@poe-code/design-system/dist/dashboard/snapshot.js +68 -0
- package/node_modules/@poe-code/design-system/dist/dashboard/store.d.ts +8 -0
- package/node_modules/@poe-code/design-system/dist/dashboard/store.js +51 -0
- package/node_modules/@poe-code/design-system/dist/dashboard/terminal.d.ts +37 -0
- package/node_modules/@poe-code/design-system/dist/dashboard/terminal.js +233 -0
- package/node_modules/@poe-code/design-system/dist/dashboard/types.d.ts +36 -0
- package/node_modules/@poe-code/design-system/dist/dashboard/types.js +1 -0
- package/node_modules/@poe-code/design-system/dist/index.d.ts +33 -0
- package/node_modules/@poe-code/design-system/dist/index.js +31 -0
- package/node_modules/@poe-code/design-system/dist/internal/output-format.d.ts +6 -0
- package/node_modules/@poe-code/design-system/dist/internal/output-format.js +22 -0
- package/node_modules/@poe-code/design-system/dist/internal/strip-ansi.d.ts +1 -0
- package/node_modules/@poe-code/design-system/dist/internal/strip-ansi.js +3 -0
- package/node_modules/@poe-code/design-system/dist/internal/theme-detect.d.ts +11 -0
- package/node_modules/@poe-code/design-system/dist/internal/theme-detect.js +49 -0
- package/node_modules/@poe-code/design-system/dist/prompts/index.d.ts +66 -0
- package/node_modules/@poe-code/design-system/dist/prompts/index.js +132 -0
- package/node_modules/@poe-code/design-system/dist/prompts/primitives/cancel.d.ts +2 -0
- package/node_modules/@poe-code/design-system/dist/prompts/primitives/cancel.js +9 -0
- package/node_modules/@poe-code/design-system/dist/prompts/primitives/intro.d.ts +1 -0
- package/node_modules/@poe-code/design-system/dist/prompts/primitives/intro.js +15 -0
- package/node_modules/@poe-code/design-system/dist/prompts/primitives/log.d.ts +18 -0
- package/node_modules/@poe-code/design-system/dist/prompts/primitives/log.js +101 -0
- package/node_modules/@poe-code/design-system/dist/prompts/primitives/note.d.ts +1 -0
- package/node_modules/@poe-code/design-system/dist/prompts/primitives/note.js +39 -0
- package/node_modules/@poe-code/design-system/dist/prompts/primitives/outro.d.ts +1 -0
- package/node_modules/@poe-code/design-system/dist/prompts/primitives/outro.js +16 -0
- package/node_modules/@poe-code/design-system/dist/prompts/primitives/spinner.d.ts +6 -0
- package/node_modules/@poe-code/design-system/dist/prompts/primitives/spinner.js +74 -0
- package/node_modules/@poe-code/design-system/dist/prompts/theme.d.ts +11 -0
- package/node_modules/@poe-code/design-system/dist/prompts/theme.js +12 -0
- package/node_modules/@poe-code/design-system/dist/static/index.d.ts +4 -0
- package/node_modules/@poe-code/design-system/dist/static/index.js +2 -0
- package/node_modules/@poe-code/design-system/dist/static/menu.d.ts +11 -0
- package/node_modules/@poe-code/design-system/dist/static/menu.js +36 -0
- package/node_modules/@poe-code/design-system/dist/static/spinner.d.ts +14 -0
- package/node_modules/@poe-code/design-system/dist/static/spinner.js +46 -0
- package/node_modules/@poe-code/design-system/dist/terminal-markdown/ast.d.ts +92 -0
- package/node_modules/@poe-code/design-system/dist/terminal-markdown/ast.js +1 -0
- package/node_modules/@poe-code/design-system/dist/terminal-markdown/demo-content.d.ts +2 -0
- package/node_modules/@poe-code/design-system/dist/terminal-markdown/demo-content.js +139 -0
- package/node_modules/@poe-code/design-system/dist/terminal-markdown/index.d.ts +6 -0
- package/node_modules/@poe-code/design-system/dist/terminal-markdown/index.js +8 -0
- package/node_modules/@poe-code/design-system/dist/terminal-markdown/parser/block.d.ts +7 -0
- package/node_modules/@poe-code/design-system/dist/terminal-markdown/parser/block.js +1495 -0
- package/node_modules/@poe-code/design-system/dist/terminal-markdown/parser/frontmatter.d.ts +8 -0
- package/node_modules/@poe-code/design-system/dist/terminal-markdown/parser/frontmatter.js +412 -0
- package/node_modules/@poe-code/design-system/dist/terminal-markdown/parser/inline.d.ts +10 -0
- package/node_modules/@poe-code/design-system/dist/terminal-markdown/parser/inline.js +1166 -0
- package/node_modules/@poe-code/design-system/dist/terminal-markdown/parser.d.ts +5 -0
- package/node_modules/@poe-code/design-system/dist/terminal-markdown/parser.js +42 -0
- package/node_modules/@poe-code/design-system/dist/terminal-markdown/renderer.d.ts +6 -0
- package/node_modules/@poe-code/design-system/dist/terminal-markdown/renderer.js +572 -0
- package/node_modules/@poe-code/design-system/dist/terminal-markdown/testing/theme-render-fixture.d.ts +1 -0
- package/node_modules/@poe-code/design-system/dist/terminal-markdown/testing/theme-render-fixture.js +27 -0
- package/node_modules/@poe-code/design-system/dist/tokens/colors.d.ts +35 -0
- package/node_modules/@poe-code/design-system/dist/tokens/colors.js +34 -0
- package/node_modules/@poe-code/design-system/dist/tokens/index.d.ts +4 -0
- package/node_modules/@poe-code/design-system/dist/tokens/index.js +4 -0
- package/node_modules/@poe-code/design-system/dist/tokens/spacing.d.ts +6 -0
- package/node_modules/@poe-code/design-system/dist/tokens/spacing.js +6 -0
- package/node_modules/@poe-code/design-system/dist/tokens/typography.d.ts +7 -0
- package/node_modules/@poe-code/design-system/dist/tokens/typography.js +8 -0
- package/node_modules/@poe-code/design-system/dist/tokens/widths.d.ts +5 -0
- package/node_modules/@poe-code/design-system/dist/tokens/widths.js +5 -0
- package/node_modules/@poe-code/design-system/package.json +25 -0
- package/node_modules/auth-store/README.md +47 -0
- package/node_modules/auth-store/dist/create-secret-store.d.ts +2 -0
- package/node_modules/auth-store/dist/create-secret-store.js +35 -0
- package/node_modules/auth-store/dist/encrypted-file-store.d.ts +39 -0
- package/node_modules/auth-store/dist/encrypted-file-store.js +156 -0
- package/node_modules/auth-store/dist/index.d.ts +7 -0
- package/node_modules/auth-store/dist/index.js +4 -0
- package/node_modules/auth-store/dist/keychain-store.d.ts +22 -0
- package/node_modules/auth-store/dist/keychain-store.js +111 -0
- package/node_modules/auth-store/dist/provider-store.d.ts +10 -0
- package/node_modules/auth-store/dist/provider-store.js +28 -0
- package/node_modules/auth-store/dist/types.d.ts +20 -0
- package/node_modules/auth-store/dist/types.js +1 -0
- package/node_modules/auth-store/package.json +25 -0
- package/package.json +48 -0
|
@@ -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,92 @@
|
|
|
1
|
+
export type MdRange = {
|
|
2
|
+
start: number;
|
|
3
|
+
end: number;
|
|
4
|
+
};
|
|
5
|
+
type MdNodeWithRange = {
|
|
6
|
+
range?: MdRange;
|
|
7
|
+
};
|
|
8
|
+
export type MdNode = MdNodeWithRange & ({
|
|
9
|
+
type: "root";
|
|
10
|
+
children: MdNode[];
|
|
11
|
+
} | {
|
|
12
|
+
type: "heading";
|
|
13
|
+
depth: 1 | 2 | 3 | 4 | 5 | 6;
|
|
14
|
+
children: MdNode[];
|
|
15
|
+
} | {
|
|
16
|
+
type: "paragraph";
|
|
17
|
+
children: MdNode[];
|
|
18
|
+
} | {
|
|
19
|
+
type: "blockquote";
|
|
20
|
+
children: MdNode[];
|
|
21
|
+
} | {
|
|
22
|
+
type: "code";
|
|
23
|
+
lang?: string;
|
|
24
|
+
meta?: string;
|
|
25
|
+
value: string;
|
|
26
|
+
} | {
|
|
27
|
+
type: "list";
|
|
28
|
+
ordered: boolean;
|
|
29
|
+
start?: number;
|
|
30
|
+
children: MdNode[];
|
|
31
|
+
} | {
|
|
32
|
+
type: "listItem";
|
|
33
|
+
checked?: boolean;
|
|
34
|
+
children: MdNode[];
|
|
35
|
+
} | {
|
|
36
|
+
type: "thematicBreak";
|
|
37
|
+
} | {
|
|
38
|
+
type: "table";
|
|
39
|
+
align: Array<"left" | "center" | "right" | null>;
|
|
40
|
+
children: MdNode[];
|
|
41
|
+
} | {
|
|
42
|
+
type: "tableRow";
|
|
43
|
+
children: MdNode[];
|
|
44
|
+
} | {
|
|
45
|
+
type: "tableCell";
|
|
46
|
+
children: MdNode[];
|
|
47
|
+
} | {
|
|
48
|
+
type: "html";
|
|
49
|
+
value: string;
|
|
50
|
+
} | {
|
|
51
|
+
type: "text";
|
|
52
|
+
value: string;
|
|
53
|
+
} | {
|
|
54
|
+
type: "emphasis";
|
|
55
|
+
children: MdNode[];
|
|
56
|
+
} | {
|
|
57
|
+
type: "strong";
|
|
58
|
+
children: MdNode[];
|
|
59
|
+
} | {
|
|
60
|
+
type: "strikethrough";
|
|
61
|
+
children: MdNode[];
|
|
62
|
+
} | {
|
|
63
|
+
type: "inlineCode";
|
|
64
|
+
value: string;
|
|
65
|
+
} | {
|
|
66
|
+
type: "link";
|
|
67
|
+
url: string;
|
|
68
|
+
title?: string;
|
|
69
|
+
children: MdNode[];
|
|
70
|
+
} | {
|
|
71
|
+
type: "image";
|
|
72
|
+
url: string;
|
|
73
|
+
alt: string;
|
|
74
|
+
title?: string;
|
|
75
|
+
} | {
|
|
76
|
+
type: "break";
|
|
77
|
+
} | {
|
|
78
|
+
type: "frontmatter";
|
|
79
|
+
data: Record<string, unknown>;
|
|
80
|
+
} | {
|
|
81
|
+
type: "alert";
|
|
82
|
+
kind: "NOTE" | "TIP" | "IMPORTANT" | "WARNING" | "CAUTION";
|
|
83
|
+
children: MdNode[];
|
|
84
|
+
} | {
|
|
85
|
+
type: "footnoteDefinition";
|
|
86
|
+
label: string;
|
|
87
|
+
children: MdNode[];
|
|
88
|
+
} | {
|
|
89
|
+
type: "footnoteReference";
|
|
90
|
+
label: string;
|
|
91
|
+
});
|
|
92
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
export function getMarkdownDemo(name = "default") {
|
|
2
|
+
switch (name) {
|
|
3
|
+
case "minimal":
|
|
4
|
+
return [
|
|
5
|
+
"# Markdown Minimal",
|
|
6
|
+
"",
|
|
7
|
+
"Quick validation paragraph.",
|
|
8
|
+
"",
|
|
9
|
+
"```ts",
|
|
10
|
+
'console.log("demo");',
|
|
11
|
+
"```"
|
|
12
|
+
].join("\n");
|
|
13
|
+
case "code-blocks":
|
|
14
|
+
return [
|
|
15
|
+
"# Code Blocks",
|
|
16
|
+
"",
|
|
17
|
+
"```ts",
|
|
18
|
+
'const sample = "**still literal**";',
|
|
19
|
+
"",
|
|
20
|
+
"function increment(value: number): number {",
|
|
21
|
+
" return value + 1;",
|
|
22
|
+
"}",
|
|
23
|
+
"",
|
|
24
|
+
'console.log("``` also literal inside code");',
|
|
25
|
+
"```"
|
|
26
|
+
].join("\n");
|
|
27
|
+
case "blockquotes":
|
|
28
|
+
return [
|
|
29
|
+
"# Blockquotes",
|
|
30
|
+
"",
|
|
31
|
+
"> Outer quote",
|
|
32
|
+
"> with a second line for spacing.",
|
|
33
|
+
">",
|
|
34
|
+
"> > Nested quote",
|
|
35
|
+
"> > keeps its own bar prefix.",
|
|
36
|
+
"> >",
|
|
37
|
+
"> > > Deep quote",
|
|
38
|
+
"> > > stays indented."
|
|
39
|
+
].join("\n");
|
|
40
|
+
case "lists":
|
|
41
|
+
return [
|
|
42
|
+
"# Lists",
|
|
43
|
+
"",
|
|
44
|
+
"- unordered item",
|
|
45
|
+
" - nested item",
|
|
46
|
+
" - another nested item",
|
|
47
|
+
"- another unordered item",
|
|
48
|
+
"",
|
|
49
|
+
"1. ordered item",
|
|
50
|
+
"2. ordered item",
|
|
51
|
+
" 1. nested ordered item",
|
|
52
|
+
" 2. another nested ordered item",
|
|
53
|
+
"",
|
|
54
|
+
"- [x] completed task",
|
|
55
|
+
"- [ ] pending task",
|
|
56
|
+
" - [x] nested done task",
|
|
57
|
+
" - [ ] nested pending task"
|
|
58
|
+
].join("\n");
|
|
59
|
+
case "tables":
|
|
60
|
+
return [
|
|
61
|
+
"# Tables",
|
|
62
|
+
"",
|
|
63
|
+
"| Column | Left | Center | Right |",
|
|
64
|
+
"| :----- | :--- | :----: | ----: |",
|
|
65
|
+
"| Alignment | alpha | beta | 42 |",
|
|
66
|
+
"| Separators | left | mid | 9000 |",
|
|
67
|
+
"| Header | visible | x | 7 |"
|
|
68
|
+
].join("\n");
|
|
69
|
+
case "alerts":
|
|
70
|
+
return [
|
|
71
|
+
"# Alerts",
|
|
72
|
+
"",
|
|
73
|
+
"> [!NOTE]",
|
|
74
|
+
"> Note labels use info styling.",
|
|
75
|
+
">",
|
|
76
|
+
"> Wrapped content stays aligned beneath the bar.",
|
|
77
|
+
"",
|
|
78
|
+
"> [!TIP]",
|
|
79
|
+
"> Tip labels use success styling.",
|
|
80
|
+
">",
|
|
81
|
+
"> Multi-line content keeps its indentation.",
|
|
82
|
+
"",
|
|
83
|
+
"> [!IMPORTANT]",
|
|
84
|
+
"> Important labels reuse the info color.",
|
|
85
|
+
">",
|
|
86
|
+
"> The follow-up line stays under the same prefix.",
|
|
87
|
+
"",
|
|
88
|
+
"> [!WARNING]",
|
|
89
|
+
"> Warning labels use warning styling.",
|
|
90
|
+
">",
|
|
91
|
+
"> Additional detail remains aligned.",
|
|
92
|
+
"",
|
|
93
|
+
"> [!CAUTION]",
|
|
94
|
+
"> Caution labels use error styling.",
|
|
95
|
+
">",
|
|
96
|
+
"> The final alert confirms the red variant."
|
|
97
|
+
].join("\n");
|
|
98
|
+
case "default":
|
|
99
|
+
return [
|
|
100
|
+
"# Design System Markdown",
|
|
101
|
+
"",
|
|
102
|
+
"## Overview",
|
|
103
|
+
"",
|
|
104
|
+
"### Renderer Features",
|
|
105
|
+
"",
|
|
106
|
+
"Paragraph with **bold**, *italic*, ~~strikethrough~~, `code span`, a [docs link](https://example.com/docs), an image , and a footnote reference[^demo].",
|
|
107
|
+
"",
|
|
108
|
+
"```ts",
|
|
109
|
+
'const agent = "poe-code";',
|
|
110
|
+
"console.log(agent);",
|
|
111
|
+
"```",
|
|
112
|
+
"",
|
|
113
|
+
"> Outer quote",
|
|
114
|
+
">",
|
|
115
|
+
"> > Nested quote",
|
|
116
|
+
"",
|
|
117
|
+
"- unordered item",
|
|
118
|
+
"- another unordered item",
|
|
119
|
+
"",
|
|
120
|
+
"1. ordered item",
|
|
121
|
+
"2. another ordered item",
|
|
122
|
+
"",
|
|
123
|
+
"- [x] completed task",
|
|
124
|
+
"- [ ] pending task",
|
|
125
|
+
"",
|
|
126
|
+
"| Feature | Alignment | Status |",
|
|
127
|
+
"| :------ | :-------: | -----: |",
|
|
128
|
+
"| Headings | center | Ready |",
|
|
129
|
+
"| Tables | aligned | 100% |",
|
|
130
|
+
"",
|
|
131
|
+
"> [!NOTE]",
|
|
132
|
+
"> Alerts are rendered as styled notes.",
|
|
133
|
+
"",
|
|
134
|
+
"---",
|
|
135
|
+
"",
|
|
136
|
+
"[^demo]: Footnote definition for the markdown demo."
|
|
137
|
+
].join("\n");
|
|
138
|
+
}
|
|
139
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { type RenderOptions } from "./renderer.js";
|
|
2
|
+
export type { MdNode } from "./ast.js";
|
|
3
|
+
export { parse } from "./parser.js";
|
|
4
|
+
export { render } from "./renderer.js";
|
|
5
|
+
export type { RenderOptions } from "./renderer.js";
|
|
6
|
+
export declare function renderMarkdown(markdown: string, options?: RenderOptions): string;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { parse } from "./parser.js";
|
|
2
|
+
import { render } from "./renderer.js";
|
|
3
|
+
export { parse } from "./parser.js";
|
|
4
|
+
export { render } from "./renderer.js";
|
|
5
|
+
export function renderMarkdown(markdown, options) {
|
|
6
|
+
const { ast } = parse(markdown);
|
|
7
|
+
return render(ast, options);
|
|
8
|
+
}
|