poe-code 3.0.178 → 3.0.180
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/index.js +6 -2
- package/dist/index.js.map +2 -2
- package/dist/prompts/github-issue-opened.md +7 -1
- package/dist/prompts/github-pull-request-opened.md +4 -0
- package/dist/prompts/github-pull-request-synchronized.md +4 -0
- package/dist/variables.yaml +46 -1
- package/dist/workflow-templates/github-issue-opened.caller.yml +1 -0
- package/dist/workflow-templates/github-issue-opened.ejected.yml +52 -0
- package/dist/workflow-templates/github-pull-request-opened.caller.yml +1 -0
- package/dist/workflow-templates/github-pull-request-opened.ejected.yml +52 -0
- package/dist/workflow-templates/github-pull-request-synchronized.caller.yml +1 -0
- package/dist/workflow-templates/github-pull-request-synchronized.ejected.yml +52 -0
- package/package.json +6 -2
- 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,107 @@
|
|
|
1
|
+
import { scrollDown, scrollToBottom, scrollToTop, scrollUp } from "./components/output-pane.js";
|
|
2
|
+
export function createStore() {
|
|
3
|
+
let state = {
|
|
4
|
+
output: [],
|
|
5
|
+
outputScroll: 0,
|
|
6
|
+
autoFollow: true,
|
|
7
|
+
stats: {
|
|
8
|
+
status: "idle",
|
|
9
|
+
iterations: 0,
|
|
10
|
+
tokensIn: 0,
|
|
11
|
+
tokensOut: 0,
|
|
12
|
+
elapsedMs: 0
|
|
13
|
+
},
|
|
14
|
+
paused: false,
|
|
15
|
+
activeDialog: { kind: "none" }
|
|
16
|
+
};
|
|
17
|
+
const listeners = new Set();
|
|
18
|
+
function notify() {
|
|
19
|
+
for (const listener of listeners) {
|
|
20
|
+
listener();
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
function getState() {
|
|
24
|
+
return state;
|
|
25
|
+
}
|
|
26
|
+
function appendOutput(item) {
|
|
27
|
+
const output = [...state.output, item];
|
|
28
|
+
state = {
|
|
29
|
+
...state,
|
|
30
|
+
output,
|
|
31
|
+
outputScroll: state.autoFollow ? Math.max(0, output.length - 1) : state.outputScroll
|
|
32
|
+
};
|
|
33
|
+
notify();
|
|
34
|
+
}
|
|
35
|
+
function updateStats(partial) {
|
|
36
|
+
state = {
|
|
37
|
+
...state,
|
|
38
|
+
stats: {
|
|
39
|
+
...state.stats,
|
|
40
|
+
...partial
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
notify();
|
|
44
|
+
}
|
|
45
|
+
function dispatch(command, paneHeight) {
|
|
46
|
+
const totalVisualLines = state.output.length;
|
|
47
|
+
const currentPaneState = state.autoFollow
|
|
48
|
+
? toStateFromPane(state, scrollToBottom(toPaneState(state), totalVisualLines, paneHeight))
|
|
49
|
+
: state;
|
|
50
|
+
if (command === "scrollUp") {
|
|
51
|
+
state = toStateFromPane(currentPaneState, scrollUp(toPaneState(currentPaneState), 1));
|
|
52
|
+
notify();
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
if (command === "scrollDown") {
|
|
56
|
+
state = toStateFromPane(currentPaneState, scrollDown(toPaneState(currentPaneState), 1, totalVisualLines));
|
|
57
|
+
notify();
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
if (command === "pageUp") {
|
|
61
|
+
state = toStateFromPane(currentPaneState, scrollUp(toPaneState(currentPaneState), paneHeight));
|
|
62
|
+
notify();
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
if (command === "pageDown") {
|
|
66
|
+
state = toStateFromPane(currentPaneState, scrollDown(toPaneState(currentPaneState), paneHeight, totalVisualLines));
|
|
67
|
+
notify();
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
if (command === "scrollToTop") {
|
|
71
|
+
state = toStateFromPane(currentPaneState, scrollToTop(toPaneState(currentPaneState)));
|
|
72
|
+
notify();
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
if (command === "scrollToBottom") {
|
|
76
|
+
state = toStateFromPane(currentPaneState, scrollToBottom(toPaneState(currentPaneState), totalVisualLines, paneHeight));
|
|
77
|
+
notify();
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
function onChange(handler) {
|
|
81
|
+
listeners.add(handler);
|
|
82
|
+
return () => {
|
|
83
|
+
listeners.delete(handler);
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
return {
|
|
87
|
+
getState,
|
|
88
|
+
appendOutput,
|
|
89
|
+
updateStats,
|
|
90
|
+
dispatch,
|
|
91
|
+
onChange
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
function toPaneState(state) {
|
|
95
|
+
return {
|
|
96
|
+
items: state.output,
|
|
97
|
+
scrollOffset: state.outputScroll,
|
|
98
|
+
autoFollow: state.autoFollow
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
function toStateFromPane(state, paneState) {
|
|
102
|
+
return {
|
|
103
|
+
...state,
|
|
104
|
+
outputScroll: paneState.scrollOffset,
|
|
105
|
+
autoFollow: paneState.autoFollow
|
|
106
|
+
};
|
|
107
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { Cell } from "./types.js";
|
|
2
|
+
export type KeypressEvent = {
|
|
3
|
+
name?: string;
|
|
4
|
+
ch?: string;
|
|
5
|
+
ctrl: boolean;
|
|
6
|
+
meta: boolean;
|
|
7
|
+
shift: boolean;
|
|
8
|
+
};
|
|
9
|
+
export type TerminalDriver = {
|
|
10
|
+
enterRawMode(): void;
|
|
11
|
+
exitRawMode(): void;
|
|
12
|
+
enterAltScreen(): void;
|
|
13
|
+
exitAltScreen(): void;
|
|
14
|
+
hideCursor(): void;
|
|
15
|
+
showCursor(): void;
|
|
16
|
+
moveTo(x: number, y: number): void;
|
|
17
|
+
write(text: string): void;
|
|
18
|
+
flush(changes: Array<{
|
|
19
|
+
x: number;
|
|
20
|
+
y: number;
|
|
21
|
+
cell: Cell;
|
|
22
|
+
}>): void;
|
|
23
|
+
getSize(): {
|
|
24
|
+
cols: number;
|
|
25
|
+
rows: number;
|
|
26
|
+
};
|
|
27
|
+
onResize(handler: () => void): () => void;
|
|
28
|
+
onKeypress(handler: (key: KeypressEvent) => void): () => void;
|
|
29
|
+
destroy(): void;
|
|
30
|
+
};
|
|
31
|
+
export declare function createTerminalDriver(opts?: {
|
|
32
|
+
stdin?: NodeJS.ReadStream;
|
|
33
|
+
stdout?: NodeJS.WriteStream;
|
|
34
|
+
}): TerminalDriver;
|
|
35
|
+
export declare function parseKeypress(data: Buffer): KeypressEvent | undefined;
|
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
import readline from "node:readline";
|
|
2
|
+
import { PassThrough } from "node:stream";
|
|
3
|
+
import { cellToAnsi } from "./buffer.js";
|
|
4
|
+
export function createTerminalDriver(opts) {
|
|
5
|
+
const stdin = (opts?.stdin ?? process.stdin);
|
|
6
|
+
const stdout = (opts?.stdout ?? process.stdout);
|
|
7
|
+
const resizeListeners = new Set();
|
|
8
|
+
const keypressListeners = new Set();
|
|
9
|
+
let rawMode = false;
|
|
10
|
+
let altScreen = false;
|
|
11
|
+
let cursorHidden = false;
|
|
12
|
+
let destroyed = false;
|
|
13
|
+
readline.emitKeypressEvents(stdin);
|
|
14
|
+
function enterRawMode() {
|
|
15
|
+
if (destroyed || rawMode) {
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
stdin.setRawMode?.(true);
|
|
19
|
+
stdin.resume();
|
|
20
|
+
rawMode = true;
|
|
21
|
+
}
|
|
22
|
+
function exitRawMode() {
|
|
23
|
+
if (destroyed || !rawMode) {
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
stdin.setRawMode?.(false);
|
|
27
|
+
stdin.pause();
|
|
28
|
+
rawMode = false;
|
|
29
|
+
}
|
|
30
|
+
function enterAltScreen() {
|
|
31
|
+
if (destroyed || altScreen) {
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
write("\u001b[?1049h");
|
|
35
|
+
altScreen = true;
|
|
36
|
+
}
|
|
37
|
+
function exitAltScreen() {
|
|
38
|
+
if (destroyed || !altScreen) {
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
write("\u001b[?1049l");
|
|
42
|
+
altScreen = false;
|
|
43
|
+
}
|
|
44
|
+
function hideCursor() {
|
|
45
|
+
if (destroyed || cursorHidden) {
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
write("\u001b[?25l");
|
|
49
|
+
cursorHidden = true;
|
|
50
|
+
}
|
|
51
|
+
function showCursor() {
|
|
52
|
+
if (destroyed || !cursorHidden) {
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
write("\u001b[?25h");
|
|
56
|
+
cursorHidden = false;
|
|
57
|
+
}
|
|
58
|
+
function moveTo(x, y) {
|
|
59
|
+
if (destroyed) {
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
write(cursorPositionAnsi(x, y));
|
|
63
|
+
}
|
|
64
|
+
function write(text) {
|
|
65
|
+
if (destroyed || text.length === 0) {
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
stdout.write(text);
|
|
69
|
+
}
|
|
70
|
+
function flush(changes) {
|
|
71
|
+
if (destroyed || changes.length === 0) {
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
let output = "";
|
|
75
|
+
for (const change of changes) {
|
|
76
|
+
output += `${cursorPositionAnsi(change.x, change.y)}${cellToAnsi(change.cell)}`;
|
|
77
|
+
}
|
|
78
|
+
write(output);
|
|
79
|
+
}
|
|
80
|
+
function getSize() {
|
|
81
|
+
return {
|
|
82
|
+
cols: normalizeSize(stdout.columns),
|
|
83
|
+
rows: normalizeSize(stdout.rows)
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
function onResize(handler) {
|
|
87
|
+
if (destroyed) {
|
|
88
|
+
return () => { };
|
|
89
|
+
}
|
|
90
|
+
const listener = () => {
|
|
91
|
+
handler();
|
|
92
|
+
};
|
|
93
|
+
resizeListeners.add(listener);
|
|
94
|
+
stdout.on("resize", listener);
|
|
95
|
+
return () => {
|
|
96
|
+
if (!resizeListeners.delete(listener)) {
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
stdout.off("resize", listener);
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
function onKeypress(handler) {
|
|
103
|
+
if (destroyed) {
|
|
104
|
+
return () => { };
|
|
105
|
+
}
|
|
106
|
+
const listener = (str, key) => {
|
|
107
|
+
const event = toKeypressEvent(str, key);
|
|
108
|
+
if (event !== undefined) {
|
|
109
|
+
handler(event);
|
|
110
|
+
}
|
|
111
|
+
};
|
|
112
|
+
keypressListeners.add(listener);
|
|
113
|
+
stdin.on("keypress", listener);
|
|
114
|
+
return () => {
|
|
115
|
+
if (!keypressListeners.delete(listener)) {
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
stdin.off("keypress", listener);
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
function destroy() {
|
|
122
|
+
if (destroyed) {
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
125
|
+
for (const listener of keypressListeners) {
|
|
126
|
+
stdin.off("keypress", listener);
|
|
127
|
+
}
|
|
128
|
+
keypressListeners.clear();
|
|
129
|
+
for (const listener of resizeListeners) {
|
|
130
|
+
stdout.off("resize", listener);
|
|
131
|
+
}
|
|
132
|
+
resizeListeners.clear();
|
|
133
|
+
exitRawMode();
|
|
134
|
+
exitAltScreen();
|
|
135
|
+
showCursor();
|
|
136
|
+
destroyed = true;
|
|
137
|
+
}
|
|
138
|
+
return {
|
|
139
|
+
enterRawMode,
|
|
140
|
+
exitRawMode,
|
|
141
|
+
enterAltScreen,
|
|
142
|
+
exitAltScreen,
|
|
143
|
+
hideCursor,
|
|
144
|
+
showCursor,
|
|
145
|
+
moveTo,
|
|
146
|
+
write,
|
|
147
|
+
flush,
|
|
148
|
+
getSize,
|
|
149
|
+
onResize,
|
|
150
|
+
onKeypress,
|
|
151
|
+
destroy
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
export function parseKeypress(data) {
|
|
155
|
+
if (data.length === 0) {
|
|
156
|
+
return undefined;
|
|
157
|
+
}
|
|
158
|
+
const stream = new PassThrough();
|
|
159
|
+
const stdin = stream;
|
|
160
|
+
let event;
|
|
161
|
+
readline.emitKeypressEvents(stdin);
|
|
162
|
+
stdin.on("keypress", (str, key) => {
|
|
163
|
+
event = toKeypressEvent(str, key);
|
|
164
|
+
});
|
|
165
|
+
stream.emit("data", data);
|
|
166
|
+
stream.destroy();
|
|
167
|
+
return event;
|
|
168
|
+
}
|
|
169
|
+
function toKeypressEvent(str, key) {
|
|
170
|
+
const ctrl = key?.ctrl ?? false;
|
|
171
|
+
const meta = key?.meta ?? false;
|
|
172
|
+
const shift = key?.shift ?? false;
|
|
173
|
+
const ch = extractPrintableCharacter(str, key?.sequence);
|
|
174
|
+
if (ch !== undefined) {
|
|
175
|
+
return { ch, ctrl, meta, shift };
|
|
176
|
+
}
|
|
177
|
+
if (key?.name === undefined) {
|
|
178
|
+
return undefined;
|
|
179
|
+
}
|
|
180
|
+
return {
|
|
181
|
+
name: key.name,
|
|
182
|
+
ctrl,
|
|
183
|
+
meta,
|
|
184
|
+
shift
|
|
185
|
+
};
|
|
186
|
+
}
|
|
187
|
+
function extractPrintableCharacter(str, sequence) {
|
|
188
|
+
if (isPrintableCharacter(str)) {
|
|
189
|
+
return str;
|
|
190
|
+
}
|
|
191
|
+
if (sequence === undefined || sequence.length <= 1 || sequence[0] !== "\u001b") {
|
|
192
|
+
return undefined;
|
|
193
|
+
}
|
|
194
|
+
const candidate = sequence.slice(1);
|
|
195
|
+
return isPrintableCharacter(candidate) ? candidate : undefined;
|
|
196
|
+
}
|
|
197
|
+
function isPrintableCharacter(value) {
|
|
198
|
+
if (value === undefined || Array.from(value).length !== 1) {
|
|
199
|
+
return false;
|
|
200
|
+
}
|
|
201
|
+
const codePoint = value.codePointAt(0);
|
|
202
|
+
return codePoint !== undefined && codePoint >= 0x20 && codePoint !== 0x7f;
|
|
203
|
+
}
|
|
204
|
+
function cursorPositionAnsi(x, y) {
|
|
205
|
+
return `\u001b[${normalizeCoordinate(y) + 1};${normalizeCoordinate(x) + 1}H`;
|
|
206
|
+
}
|
|
207
|
+
function normalizeCoordinate(value) {
|
|
208
|
+
return Math.max(0, Math.floor(value));
|
|
209
|
+
}
|
|
210
|
+
function normalizeSize(value) {
|
|
211
|
+
if (value === undefined || !Number.isFinite(value)) {
|
|
212
|
+
return 0;
|
|
213
|
+
}
|
|
214
|
+
return Math.max(0, Math.floor(value));
|
|
215
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
export type OutputItemKind = "info" | "success" | "error" | "tool" | "status";
|
|
2
|
+
export type OutputItem = {
|
|
3
|
+
kind: OutputItemKind;
|
|
4
|
+
text: string;
|
|
5
|
+
ts: number;
|
|
6
|
+
};
|
|
7
|
+
export type DashboardStats = {
|
|
8
|
+
status: "idle" | "running" | "paused" | "done" | "error";
|
|
9
|
+
iterations: number;
|
|
10
|
+
tokensIn: number;
|
|
11
|
+
tokensOut: number;
|
|
12
|
+
elapsedMs: number;
|
|
13
|
+
currentAction?: string;
|
|
14
|
+
};
|
|
15
|
+
export type Command = "quit" | "edit" | "pause" | "retry" | "scrollUp" | "scrollDown" | "pageUp" | "pageDown" | "scrollToTop" | "scrollToBottom";
|
|
16
|
+
export type DialogState = {
|
|
17
|
+
kind: "none";
|
|
18
|
+
} | {
|
|
19
|
+
kind: "edit";
|
|
20
|
+
initialValue: string;
|
|
21
|
+
};
|
|
22
|
+
export type DashboardState = {
|
|
23
|
+
output: OutputItem[];
|
|
24
|
+
outputScroll: number;
|
|
25
|
+
autoFollow: boolean;
|
|
26
|
+
stats: DashboardStats;
|
|
27
|
+
paused: boolean;
|
|
28
|
+
activeDialog: DialogState;
|
|
29
|
+
};
|
|
30
|
+
export type CellStyle = {
|
|
31
|
+
fg?: string;
|
|
32
|
+
bg?: string;
|
|
33
|
+
bold?: boolean;
|
|
34
|
+
dim?: boolean;
|
|
35
|
+
};
|
|
36
|
+
export type Cell = {
|
|
37
|
+
ch: string;
|
|
38
|
+
style: CellStyle;
|
|
39
|
+
};
|
|
40
|
+
export type Rect = {
|
|
41
|
+
x: number;
|
|
42
|
+
y: number;
|
|
43
|
+
width: number;
|
|
44
|
+
height: number;
|
|
45
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
export * as tokens from "./tokens/index.js";
|
|
2
|
+
export { brand, dark, light } from "./tokens/colors.js";
|
|
3
|
+
export type { ThemeName, ThemePalette } from "./tokens/colors.js";
|
|
4
|
+
export { spacing } from "./tokens/spacing.js";
|
|
5
|
+
export { typography } from "./tokens/typography.js";
|
|
6
|
+
export { widths } from "./tokens/widths.js";
|
|
7
|
+
export { text } from "./components/text.js";
|
|
8
|
+
export { symbols } from "./components/symbols.js";
|
|
9
|
+
export { createLogger, logger } from "./components/logger.js";
|
|
10
|
+
export type { LoggerOutput } from "./components/logger.js";
|
|
11
|
+
export { helpFormatter, formatCommand, formatUsage, formatOption, formatCommandList, formatOptionList } from "./components/help-formatter.js";
|
|
12
|
+
export type { CommandInfo, OptionInfo } from "./components/help-formatter.js";
|
|
13
|
+
export { formatCommandNotFound } from "./components/command-errors.js";
|
|
14
|
+
export { formatCommandNotFoundPanel } from "./components/command-errors.js";
|
|
15
|
+
export { renderTable } from "./components/table.js";
|
|
16
|
+
export type { TableColumn, RenderTableOptions } from "./components/table.js";
|
|
17
|
+
export * as acp from "./acp/index.js";
|
|
18
|
+
export * as dashboard from "./dashboard/index.js";
|
|
19
|
+
export { createDashboard } from "./dashboard/index.js";
|
|
20
|
+
export type { Dashboard, DashboardOptions } from "./dashboard/index.js";
|
|
21
|
+
export * as prompts from "./prompts/index.js";
|
|
22
|
+
export { intro, introPlain, outro, note, select, multiselect, text as promptText, confirm, confirmOrCancel, password, spinner, withSpinner, isCancel, cancel, log, PromptCancelledError } from "./prompts/index.js";
|
|
23
|
+
export type { SelectOptions, MultiselectOptions, TextOptions, ConfirmOptions, PasswordOptions, SpinnerOptions, WithSpinnerOptions } from "./prompts/index.js";
|
|
24
|
+
export { promptTheme } from "./prompts/theme.js";
|
|
25
|
+
export * as staticRender from "./static/index.js";
|
|
26
|
+
export { SPINNER_FRAMES, renderSpinnerFrame, renderSpinnerStopped, renderMenu } from "./static/index.js";
|
|
27
|
+
export type { SpinnerFrameOptions, SpinnerStoppedOptions, MenuOption, RenderMenuOptions } from "./static/index.js";
|
|
28
|
+
export { parse, render, renderMarkdown } from "./terminal-markdown/index.js";
|
|
29
|
+
export type { MdNode, RenderOptions } from "./terminal-markdown/index.js";
|
|
30
|
+
export { getTheme, resolveThemeName, resetThemeCache } from "./internal/theme-detect.js";
|
|
31
|
+
export type { ThemeEnv } from "./internal/theme-detect.js";
|
|
32
|
+
export { resolveOutputFormat, resetOutputFormatCache, withOutputFormat } from "./internal/output-format.js";
|
|
33
|
+
export type { OutputFormat } from "./internal/output-format.js";
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
// Tokens
|
|
2
|
+
export * as tokens from "./tokens/index.js";
|
|
3
|
+
export { brand, dark, light } from "./tokens/colors.js";
|
|
4
|
+
export { spacing } from "./tokens/spacing.js";
|
|
5
|
+
export { typography } from "./tokens/typography.js";
|
|
6
|
+
export { widths } from "./tokens/widths.js";
|
|
7
|
+
// Components
|
|
8
|
+
export { text } from "./components/text.js";
|
|
9
|
+
export { symbols } from "./components/symbols.js";
|
|
10
|
+
export { createLogger, logger } from "./components/logger.js";
|
|
11
|
+
export { helpFormatter, formatCommand, formatUsage, formatOption, formatCommandList, formatOptionList } from "./components/help-formatter.js";
|
|
12
|
+
export { formatCommandNotFound } from "./components/command-errors.js";
|
|
13
|
+
export { formatCommandNotFoundPanel } from "./components/command-errors.js";
|
|
14
|
+
export { renderTable } from "./components/table.js";
|
|
15
|
+
// ACP rendering
|
|
16
|
+
export * as acp from "./acp/index.js";
|
|
17
|
+
// Dashboard
|
|
18
|
+
export * as dashboard from "./dashboard/index.js";
|
|
19
|
+
export { createDashboard } from "./dashboard/index.js";
|
|
20
|
+
// Prompts
|
|
21
|
+
export * as prompts from "./prompts/index.js";
|
|
22
|
+
export { intro, introPlain, outro, note, select, multiselect, text as promptText, confirm, confirmOrCancel, password, spinner, withSpinner, isCancel, cancel, log, PromptCancelledError } from "./prompts/index.js";
|
|
23
|
+
export { promptTheme } from "./prompts/theme.js";
|
|
24
|
+
// Static rendering
|
|
25
|
+
export * as staticRender from "./static/index.js";
|
|
26
|
+
export { SPINNER_FRAMES, renderSpinnerFrame, renderSpinnerStopped, renderMenu } from "./static/index.js";
|
|
27
|
+
// Terminal markdown
|
|
28
|
+
export { parse, render, renderMarkdown } from "./terminal-markdown/index.js";
|
|
29
|
+
// Internal utilities (for advanced use)
|
|
30
|
+
export { getTheme, resolveThemeName, resetThemeCache } from "./internal/theme-detect.js";
|
|
31
|
+
export { resolveOutputFormat, resetOutputFormatCache, withOutputFormat } from "./internal/output-format.js";
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export type OutputFormat = "terminal" | "markdown" | "json";
|
|
2
|
+
export declare function resolveOutputFormat(env?: {
|
|
3
|
+
OUTPUT_FORMAT?: string;
|
|
4
|
+
}): OutputFormat;
|
|
5
|
+
export declare function withOutputFormat<T>(format: OutputFormat, fn: () => T): T;
|
|
6
|
+
export declare function resetOutputFormatCache(): void;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { AsyncLocalStorage } from "node:async_hooks";
|
|
2
|
+
const VALID_FORMATS = new Set(["terminal", "markdown", "json"]);
|
|
3
|
+
const formatStorage = new AsyncLocalStorage();
|
|
4
|
+
let cached;
|
|
5
|
+
export function resolveOutputFormat(env = process.env) {
|
|
6
|
+
const scoped = formatStorage.getStore();
|
|
7
|
+
if (scoped) {
|
|
8
|
+
return scoped;
|
|
9
|
+
}
|
|
10
|
+
if (cached) {
|
|
11
|
+
return cached;
|
|
12
|
+
}
|
|
13
|
+
const raw = env.OUTPUT_FORMAT?.toLowerCase();
|
|
14
|
+
cached = VALID_FORMATS.has(raw) ? raw : "terminal";
|
|
15
|
+
return cached;
|
|
16
|
+
}
|
|
17
|
+
export function withOutputFormat(format, fn) {
|
|
18
|
+
return formatStorage.run(format, fn);
|
|
19
|
+
}
|
|
20
|
+
export function resetOutputFormatCache() {
|
|
21
|
+
cached = undefined;
|
|
22
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function stripAnsi(value: string): string;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { type ThemeName, type ThemePalette } from "../tokens/colors.js";
|
|
2
|
+
export interface ThemeEnv {
|
|
3
|
+
POE_CODE_THEME?: string;
|
|
4
|
+
POE_THEME?: string;
|
|
5
|
+
APPLE_INTERFACE_STYLE?: string;
|
|
6
|
+
VSCODE_COLOR_THEME_KIND?: string;
|
|
7
|
+
COLORFGBG?: string;
|
|
8
|
+
}
|
|
9
|
+
export declare function resolveThemeName(env?: ThemeEnv): ThemeName;
|
|
10
|
+
export declare function getTheme(env?: ThemeEnv): ThemePalette;
|
|
11
|
+
export declare function resetThemeCache(): void;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { dark, light } from "../tokens/colors.js";
|
|
2
|
+
function detectThemeFromEnv(env) {
|
|
3
|
+
const apple = env.APPLE_INTERFACE_STYLE;
|
|
4
|
+
if (typeof apple === "string") {
|
|
5
|
+
return apple.toLowerCase() === "dark" ? "dark" : "light";
|
|
6
|
+
}
|
|
7
|
+
const vscodeKind = env.VSCODE_COLOR_THEME_KIND;
|
|
8
|
+
if (typeof vscodeKind === "string") {
|
|
9
|
+
const normalized = vscodeKind.toLowerCase();
|
|
10
|
+
if (normalized.includes("light")) {
|
|
11
|
+
return "light";
|
|
12
|
+
}
|
|
13
|
+
if (normalized.includes("dark")) {
|
|
14
|
+
return "dark";
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
const colorFGBG = env.COLORFGBG;
|
|
18
|
+
if (typeof colorFGBG === "string") {
|
|
19
|
+
const parts = colorFGBG.split(";").map((part) => Number.parseInt(part, 10));
|
|
20
|
+
const background = parts.at(-1);
|
|
21
|
+
if (Number.isFinite(background)) {
|
|
22
|
+
return background >= 8 ? "light" : "dark";
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
return undefined;
|
|
26
|
+
}
|
|
27
|
+
export function resolveThemeName(env = process.env) {
|
|
28
|
+
const raw = (env.POE_CODE_THEME ?? env.POE_THEME)?.toLowerCase();
|
|
29
|
+
if (raw === "light" || raw === "dark") {
|
|
30
|
+
return raw;
|
|
31
|
+
}
|
|
32
|
+
const detected = detectThemeFromEnv(env);
|
|
33
|
+
if (detected) {
|
|
34
|
+
return detected;
|
|
35
|
+
}
|
|
36
|
+
return "dark";
|
|
37
|
+
}
|
|
38
|
+
let cachedTheme;
|
|
39
|
+
export function getTheme(env) {
|
|
40
|
+
if (cachedTheme) {
|
|
41
|
+
return cachedTheme;
|
|
42
|
+
}
|
|
43
|
+
const themeName = resolveThemeName(env);
|
|
44
|
+
cachedTheme = themeName === "light" ? light : dark;
|
|
45
|
+
return cachedTheme;
|
|
46
|
+
}
|
|
47
|
+
export function resetThemeCache() {
|
|
48
|
+
cachedTheme = undefined;
|
|
49
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import * as clack from "@clack/prompts";
|
|
2
|
+
import { cancel, isCancel } from "./primitives/cancel.js";
|
|
3
|
+
import { intro } from "./primitives/intro.js";
|
|
4
|
+
import { log } from "./primitives/log.js";
|
|
5
|
+
import { note } from "./primitives/note.js";
|
|
6
|
+
import { outro } from "./primitives/outro.js";
|
|
7
|
+
import { spinner } from "./primitives/spinner.js";
|
|
8
|
+
export { isCancel, cancel, log };
|
|
9
|
+
export { intro, outro, note, spinner };
|
|
10
|
+
export declare function introPlain(title: string): void;
|
|
11
|
+
export interface SelectOptions<Value> {
|
|
12
|
+
message: string;
|
|
13
|
+
options: Array<{
|
|
14
|
+
value: Value;
|
|
15
|
+
label: string;
|
|
16
|
+
hint?: string;
|
|
17
|
+
}>;
|
|
18
|
+
initialValue?: Value;
|
|
19
|
+
}
|
|
20
|
+
export declare function select<Value>(opts: SelectOptions<Value>): Promise<Value | symbol>;
|
|
21
|
+
export type MultiselectOptions<Value> = Parameters<typeof clack.multiselect<Value>>[0];
|
|
22
|
+
/**
|
|
23
|
+
* Prompts the user to select one or more values from a list.
|
|
24
|
+
*
|
|
25
|
+
* Returns the selected values as an array, or a cancellation symbol if the
|
|
26
|
+
* user cancels. Use `isCancel` to check for cancellation.
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* const result = await multiselect({
|
|
30
|
+
* message: "Pick workflows to run",
|
|
31
|
+
* options: [{ label: "Fix Vulnerabilities", value: "fix-vulnerabilities" }],
|
|
32
|
+
* required: true
|
|
33
|
+
* });
|
|
34
|
+
* if (!isCancel(result)) {
|
|
35
|
+
* // result is Value[]
|
|
36
|
+
* }
|
|
37
|
+
*/
|
|
38
|
+
export declare function multiselect<Value>(opts: MultiselectOptions<Value>): Promise<Value[] | symbol>;
|
|
39
|
+
export type TextOptions = Parameters<typeof clack.text>[0];
|
|
40
|
+
export declare function text(opts: TextOptions): Promise<string | symbol>;
|
|
41
|
+
export interface ConfirmOptions {
|
|
42
|
+
message: string;
|
|
43
|
+
initialValue?: boolean;
|
|
44
|
+
}
|
|
45
|
+
export declare function confirm(opts: ConfirmOptions): Promise<boolean | symbol>;
|
|
46
|
+
export declare class PromptCancelledError extends Error {
|
|
47
|
+
constructor(message?: string);
|
|
48
|
+
}
|
|
49
|
+
export declare function confirmOrCancel(opts: ConfirmOptions): Promise<boolean>;
|
|
50
|
+
export interface PasswordOptions {
|
|
51
|
+
message: string;
|
|
52
|
+
validate?: (value: string) => string | undefined;
|
|
53
|
+
}
|
|
54
|
+
export declare function password(opts: PasswordOptions): Promise<string | symbol>;
|
|
55
|
+
export type SpinnerOptions = {
|
|
56
|
+
start: (message?: string) => void;
|
|
57
|
+
stop: (message?: string, code?: number) => void;
|
|
58
|
+
message: (message?: string) => void;
|
|
59
|
+
};
|
|
60
|
+
export interface WithSpinnerOptions<T> {
|
|
61
|
+
message: string;
|
|
62
|
+
fn: () => Promise<T>;
|
|
63
|
+
stopMessage?: (result: T) => string;
|
|
64
|
+
subtext?: (result: T) => string | undefined;
|
|
65
|
+
}
|
|
66
|
+
export declare function withSpinner<T>(options: WithSpinnerOptions<T>): Promise<T>;
|