centaurus-cli 2.0.0
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/AUTH_FLOW.md +138 -0
- package/CONFIG_GUIDE.md +255 -0
- package/LICENSE +21 -0
- package/README.md +346 -0
- package/dist/ai/provider-factory.d.ts +6 -0
- package/dist/ai/provider-factory.d.ts.map +1 -0
- package/dist/ai/provider-factory.js +27 -0
- package/dist/ai/provider-factory.js.map +1 -0
- package/dist/ai/providers/base.d.ts +25 -0
- package/dist/ai/providers/base.d.ts.map +1 -0
- package/dist/ai/providers/base.js +9 -0
- package/dist/ai/providers/base.js.map +1 -0
- package/dist/ai/providers/gemini.d.ts +34 -0
- package/dist/ai/providers/gemini.d.ts.map +1 -0
- package/dist/ai/providers/gemini.js +146 -0
- package/dist/ai/providers/gemini.js.map +1 -0
- package/dist/ai/types.d.ts +20 -0
- package/dist/ai/types.d.ts.map +1 -0
- package/dist/ai/types.js +2 -0
- package/dist/ai/types.js.map +1 -0
- package/dist/cli-adapter.d.ts +78 -0
- package/dist/cli-adapter.d.ts.map +1 -0
- package/dist/cli-adapter.js +605 -0
- package/dist/cli-adapter.js.map +1 -0
- package/dist/commands/CommandParser.d.ts +27 -0
- package/dist/commands/CommandParser.d.ts.map +1 -0
- package/dist/commands/CommandParser.js +238 -0
- package/dist/commands/CommandParser.js.map +1 -0
- package/dist/config/ConfigManager.d.ts +59 -0
- package/dist/config/ConfigManager.d.ts.map +1 -0
- package/dist/config/ConfigManager.js +332 -0
- package/dist/config/ConfigManager.js.map +1 -0
- package/dist/config/defaultConfig.d.ts +82 -0
- package/dist/config/defaultConfig.d.ts.map +1 -0
- package/dist/config/defaultConfig.js +88 -0
- package/dist/config/defaultConfig.js.map +1 -0
- package/dist/config/manager.d.ts +60 -0
- package/dist/config/manager.d.ts.map +1 -0
- package/dist/config/manager.js +162 -0
- package/dist/config/manager.js.map +1 -0
- package/dist/config/types.d.ts +9 -0
- package/dist/config/types.d.ts.map +1 -0
- package/dist/config/types.js +6 -0
- package/dist/config/types.js.map +1 -0
- package/dist/index-custom.d.ts +3 -0
- package/dist/index-custom.d.ts.map +1 -0
- package/dist/index-custom.js +65 -0
- package/dist/index-custom.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +102 -0
- package/dist/index.js.map +1 -0
- package/dist/prompts/system-prompt.d.ts +47 -0
- package/dist/prompts/system-prompt.d.ts.map +1 -0
- package/dist/prompts/system-prompt.js +378 -0
- package/dist/prompts/system-prompt.js.map +1 -0
- package/dist/providers/GoogleProvider.d.ts +26 -0
- package/dist/providers/GoogleProvider.d.ts.map +1 -0
- package/dist/providers/GoogleProvider.js +313 -0
- package/dist/providers/GoogleProvider.js.map +1 -0
- package/dist/providers/Provider.d.ts +114 -0
- package/dist/providers/Provider.d.ts.map +1 -0
- package/dist/providers/Provider.js +44 -0
- package/dist/providers/Provider.js.map +1 -0
- package/dist/services/api-client.d.ts +282 -0
- package/dist/services/api-client.d.ts.map +1 -0
- package/dist/services/api-client.js +339 -0
- package/dist/services/api-client.js.map +1 -0
- package/dist/services/auth-handler.d.ts +30 -0
- package/dist/services/auth-handler.d.ts.map +1 -0
- package/dist/services/auth-handler.js +210 -0
- package/dist/services/auth-handler.js.map +1 -0
- package/dist/services/conversation-manager.d.ts +73 -0
- package/dist/services/conversation-manager.d.ts.map +1 -0
- package/dist/services/conversation-manager.js +128 -0
- package/dist/services/conversation-manager.js.map +1 -0
- package/dist/tests/automated-verification.d.ts +27 -0
- package/dist/tests/automated-verification.d.ts.map +1 -0
- package/dist/tests/automated-verification.js +359 -0
- package/dist/tests/automated-verification.js.map +1 -0
- package/dist/tests/integration-tests.d.ts +50 -0
- package/dist/tests/integration-tests.d.ts.map +1 -0
- package/dist/tests/integration-tests.js +648 -0
- package/dist/tests/integration-tests.js.map +1 -0
- package/dist/tools/ToolRegistry.d.ts +44 -0
- package/dist/tools/ToolRegistry.d.ts.map +1 -0
- package/dist/tools/ToolRegistry.js +494 -0
- package/dist/tools/ToolRegistry.js.map +1 -0
- package/dist/tools/command.d.ts +4 -0
- package/dist/tools/command.d.ts.map +1 -0
- package/dist/tools/command.js +117 -0
- package/dist/tools/command.js.map +1 -0
- package/dist/tools/file-ops-test.d.ts +6 -0
- package/dist/tools/file-ops-test.d.ts.map +1 -0
- package/dist/tools/file-ops-test.js +197 -0
- package/dist/tools/file-ops-test.js.map +1 -0
- package/dist/tools/file-ops.d.ts +6 -0
- package/dist/tools/file-ops.d.ts.map +1 -0
- package/dist/tools/file-ops.js +189 -0
- package/dist/tools/file-ops.js.map +1 -0
- package/dist/tools/plan-mode.d.ts +53 -0
- package/dist/tools/plan-mode.d.ts.map +1 -0
- package/dist/tools/plan-mode.js +202 -0
- package/dist/tools/plan-mode.js.map +1 -0
- package/dist/tools/registry.d.ts +30 -0
- package/dist/tools/registry.d.ts.map +1 -0
- package/dist/tools/registry.js +67 -0
- package/dist/tools/registry.js.map +1 -0
- package/dist/tools/types.d.ts +34 -0
- package/dist/tools/types.d.ts.map +1 -0
- package/dist/tools/types.js +2 -0
- package/dist/tools/types.js.map +1 -0
- package/dist/tools/web-search.d.ts +24 -0
- package/dist/tools/web-search.d.ts.map +1 -0
- package/dist/tools/web-search.js +194 -0
- package/dist/tools/web-search.js.map +1 -0
- package/dist/types/index.d.ts +32 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +2 -0
- package/dist/types/index.js.map +1 -0
- package/dist/ui/DisplayHistory.d.ts +53 -0
- package/dist/ui/DisplayHistory.d.ts.map +1 -0
- package/dist/ui/DisplayHistory.js +82 -0
- package/dist/ui/DisplayHistory.js.map +1 -0
- package/dist/ui/clack-ui.d.ts +83 -0
- package/dist/ui/clack-ui.d.ts.map +1 -0
- package/dist/ui/clack-ui.js +304 -0
- package/dist/ui/clack-ui.js.map +1 -0
- package/dist/ui/components/App.d.ts +47 -0
- package/dist/ui/components/App.d.ts.map +1 -0
- package/dist/ui/components/App.js +389 -0
- package/dist/ui/components/App.js.map +1 -0
- package/dist/ui/components/AuthScreen.d.ts +8 -0
- package/dist/ui/components/AuthScreen.d.ts.map +1 -0
- package/dist/ui/components/AuthScreen.js +37 -0
- package/dist/ui/components/AuthScreen.js.map +1 -0
- package/dist/ui/components/AuthWelcomeScreen.d.ts +8 -0
- package/dist/ui/components/AuthWelcomeScreen.d.ts.map +1 -0
- package/dist/ui/components/AuthWelcomeScreen.js +34 -0
- package/dist/ui/components/AuthWelcomeScreen.js.map +1 -0
- package/dist/ui/components/CodeBlock.d.ts +9 -0
- package/dist/ui/components/CodeBlock.d.ts.map +1 -0
- package/dist/ui/components/CodeBlock.js +22 -0
- package/dist/ui/components/CodeBlock.js.map +1 -0
- package/dist/ui/components/ConfigViewer.d.ts +11 -0
- package/dist/ui/components/ConfigViewer.d.ts.map +1 -0
- package/dist/ui/components/ConfigViewer.js +27 -0
- package/dist/ui/components/ConfigViewer.js.map +1 -0
- package/dist/ui/components/ConfirmPrompt.d.ts +11 -0
- package/dist/ui/components/ConfirmPrompt.d.ts.map +1 -0
- package/dist/ui/components/ConfirmPrompt.js +55 -0
- package/dist/ui/components/ConfirmPrompt.js.map +1 -0
- package/dist/ui/components/DiffViewer.d.ts +8 -0
- package/dist/ui/components/DiffViewer.d.ts.map +1 -0
- package/dist/ui/components/DiffViewer.js +63 -0
- package/dist/ui/components/DiffViewer.js.map +1 -0
- package/dist/ui/components/DisplayItemRenderer.d.ts +18 -0
- package/dist/ui/components/DisplayItemRenderer.d.ts.map +1 -0
- package/dist/ui/components/DisplayItemRenderer.js +53 -0
- package/dist/ui/components/DisplayItemRenderer.js.map +1 -0
- package/dist/ui/components/DynamicMessage.d.ts +13 -0
- package/dist/ui/components/DynamicMessage.d.ts.map +1 -0
- package/dist/ui/components/DynamicMessage.js +27 -0
- package/dist/ui/components/DynamicMessage.js.map +1 -0
- package/dist/ui/components/ErrorBoundary.d.ts +16 -0
- package/dist/ui/components/ErrorBoundary.d.ts.map +1 -0
- package/dist/ui/components/ErrorBoundary.js +25 -0
- package/dist/ui/components/ErrorBoundary.js.map +1 -0
- package/dist/ui/components/FileOperation.d.ts +10 -0
- package/dist/ui/components/FileOperation.d.ts.map +1 -0
- package/dist/ui/components/FileOperation.js +31 -0
- package/dist/ui/components/FileOperation.js.map +1 -0
- package/dist/ui/components/InputBox.d.ts +12 -0
- package/dist/ui/components/InputBox.d.ts.map +1 -0
- package/dist/ui/components/InputBox.js +50 -0
- package/dist/ui/components/InputBox.js.map +1 -0
- package/dist/ui/components/KeyboardHelp.d.ts +7 -0
- package/dist/ui/components/KeyboardHelp.d.ts.map +1 -0
- package/dist/ui/components/KeyboardHelp.js +25 -0
- package/dist/ui/components/KeyboardHelp.js.map +1 -0
- package/dist/ui/components/LoadingIndicator.d.ts +3 -0
- package/dist/ui/components/LoadingIndicator.d.ts.map +1 -0
- package/dist/ui/components/LoadingIndicator.js +25 -0
- package/dist/ui/components/LoadingIndicator.js.map +1 -0
- package/dist/ui/components/MarkdownRenderer.d.ts +8 -0
- package/dist/ui/components/MarkdownRenderer.d.ts.map +1 -0
- package/dist/ui/components/MarkdownRenderer.js +96 -0
- package/dist/ui/components/MarkdownRenderer.js.map +1 -0
- package/dist/ui/components/MessageBox.d.ts +10 -0
- package/dist/ui/components/MessageBox.d.ts.map +1 -0
- package/dist/ui/components/MessageBox.js +50 -0
- package/dist/ui/components/MessageBox.js.map +1 -0
- package/dist/ui/components/MessageDisplay.d.ts +8 -0
- package/dist/ui/components/MessageDisplay.d.ts.map +1 -0
- package/dist/ui/components/MessageDisplay.js +43 -0
- package/dist/ui/components/MessageDisplay.js.map +1 -0
- package/dist/ui/components/ScrollableContent.d.ts +7 -0
- package/dist/ui/components/ScrollableContent.d.ts.map +1 -0
- package/dist/ui/components/ScrollableContent.js +6 -0
- package/dist/ui/components/ScrollableContent.js.map +1 -0
- package/dist/ui/components/ScrollableMessageList.d.ts +10 -0
- package/dist/ui/components/ScrollableMessageList.d.ts.map +1 -0
- package/dist/ui/components/ScrollableMessageList.js +133 -0
- package/dist/ui/components/ScrollableMessageList.js.map +1 -0
- package/dist/ui/components/ScrollableScreen.d.ts +9 -0
- package/dist/ui/components/ScrollableScreen.d.ts.map +1 -0
- package/dist/ui/components/ScrollableScreen.js +22 -0
- package/dist/ui/components/ScrollableScreen.js.map +1 -0
- package/dist/ui/components/SelectPrompt.d.ts +12 -0
- package/dist/ui/components/SelectPrompt.d.ts.map +1 -0
- package/dist/ui/components/SelectPrompt.js +10 -0
- package/dist/ui/components/SelectPrompt.js.map +1 -0
- package/dist/ui/components/StaticMessageHistory.d.ts +14 -0
- package/dist/ui/components/StaticMessageHistory.d.ts.map +1 -0
- package/dist/ui/components/StaticMessageHistory.js +19 -0
- package/dist/ui/components/StaticMessageHistory.js.map +1 -0
- package/dist/ui/components/StatusBar.d.ts +10 -0
- package/dist/ui/components/StatusBar.d.ts.map +1 -0
- package/dist/ui/components/StatusBar.js +20 -0
- package/dist/ui/components/StatusBar.js.map +1 -0
- package/dist/ui/components/StreamingMessageDisplay.d.ts +13 -0
- package/dist/ui/components/StreamingMessageDisplay.d.ts.map +1 -0
- package/dist/ui/components/StreamingMessageDisplay.js +26 -0
- package/dist/ui/components/StreamingMessageDisplay.js.map +1 -0
- package/dist/ui/components/ToolExecutionMessage.d.ts +8 -0
- package/dist/ui/components/ToolExecutionMessage.d.ts.map +1 -0
- package/dist/ui/components/ToolExecutionMessage.js +189 -0
- package/dist/ui/components/ToolExecutionMessage.js.map +1 -0
- package/dist/ui/components/ToolExecutionStatus.d.ts +10 -0
- package/dist/ui/components/ToolExecutionStatus.d.ts.map +1 -0
- package/dist/ui/components/ToolExecutionStatus.js +65 -0
- package/dist/ui/components/ToolExecutionStatus.js.map +1 -0
- package/dist/ui/components/ToolResult.d.ts +10 -0
- package/dist/ui/components/ToolResult.d.ts.map +1 -0
- package/dist/ui/components/ToolResult.js +17 -0
- package/dist/ui/components/ToolResult.js.map +1 -0
- package/dist/ui/components/WelcomeBanner.d.ts +3 -0
- package/dist/ui/components/WelcomeBanner.d.ts.map +1 -0
- package/dist/ui/components/WelcomeBanner.js +28 -0
- package/dist/ui/components/WelcomeBanner.js.map +1 -0
- package/dist/ui/components/code-block.d.ts +10 -0
- package/dist/ui/components/code-block.d.ts.map +1 -0
- package/dist/ui/components/code-block.js +74 -0
- package/dist/ui/components/code-block.js.map +1 -0
- package/dist/ui/components/confirm-prompt.d.ts +12 -0
- package/dist/ui/components/confirm-prompt.d.ts.map +1 -0
- package/dist/ui/components/confirm-prompt.js +104 -0
- package/dist/ui/components/confirm-prompt.js.map +1 -0
- package/dist/ui/components/diff-viewer.d.ts +9 -0
- package/dist/ui/components/diff-viewer.d.ts.map +1 -0
- package/dist/ui/components/diff-viewer.js +57 -0
- package/dist/ui/components/diff-viewer.js.map +1 -0
- package/dist/ui/components/input-box.d.ts +18 -0
- package/dist/ui/components/input-box.d.ts.map +1 -0
- package/dist/ui/components/input-box.js +157 -0
- package/dist/ui/components/input-box.js.map +1 -0
- package/dist/ui/components/keyboard-help.d.ts +7 -0
- package/dist/ui/components/keyboard-help.d.ts.map +1 -0
- package/dist/ui/components/keyboard-help.js +43 -0
- package/dist/ui/components/keyboard-help.js.map +1 -0
- package/dist/ui/components/loading-indicator.d.ts +3 -0
- package/dist/ui/components/loading-indicator.d.ts.map +1 -0
- package/dist/ui/components/loading-indicator.js +42 -0
- package/dist/ui/components/loading-indicator.js.map +1 -0
- package/dist/ui/components/message-display.d.ts +7 -0
- package/dist/ui/components/message-display.d.ts.map +1 -0
- package/dist/ui/components/message-display.js +104 -0
- package/dist/ui/components/message-display.js.map +1 -0
- package/dist/ui/components/misc.d.ts +28 -0
- package/dist/ui/components/misc.d.ts.map +1 -0
- package/dist/ui/components/misc.js +128 -0
- package/dist/ui/components/misc.js.map +1 -0
- package/dist/ui/components/select-prompt.d.ts +13 -0
- package/dist/ui/components/select-prompt.d.ts.map +1 -0
- package/dist/ui/components/select-prompt.js +42 -0
- package/dist/ui/components/select-prompt.js.map +1 -0
- package/dist/ui/components/status-bar.d.ts +11 -0
- package/dist/ui/components/status-bar.d.ts.map +1 -0
- package/dist/ui/components/status-bar.js +47 -0
- package/dist/ui/components/status-bar.js.map +1 -0
- package/dist/ui/components/tool-execution.d.ts +3 -0
- package/dist/ui/components/tool-execution.d.ts.map +1 -0
- package/dist/ui/components/tool-execution.js +374 -0
- package/dist/ui/components/tool-execution.js.map +1 -0
- package/dist/ui/components/tool-result.d.ts +11 -0
- package/dist/ui/components/tool-result.d.ts.map +1 -0
- package/dist/ui/components/tool-result.js +58 -0
- package/dist/ui/components/tool-result.js.map +1 -0
- package/dist/ui/components/welcome-banner.d.ts +3 -0
- package/dist/ui/components/welcome-banner.d.ts.map +1 -0
- package/dist/ui/components/welcome-banner.js +46 -0
- package/dist/ui/components/welcome-banner.js.map +1 -0
- package/dist/ui/hooks/useDisplayHistory.d.ts +13 -0
- package/dist/ui/hooks/useDisplayHistory.d.ts.map +1 -0
- package/dist/ui/hooks/useDisplayHistory.js +45 -0
- package/dist/ui/hooks/useDisplayHistory.js.map +1 -0
- package/dist/ui/render-engine.d.ts +69 -0
- package/dist/ui/render-engine.d.ts.map +1 -0
- package/dist/ui/render-engine.js +197 -0
- package/dist/ui/render-engine.js.map +1 -0
- package/dist/ui/terminal/TerminalRenderer.d.ts +84 -0
- package/dist/ui/terminal/TerminalRenderer.d.ts.map +1 -0
- package/dist/ui/terminal/TerminalRenderer.js +154 -0
- package/dist/ui/terminal/TerminalRenderer.js.map +1 -0
- package/dist/ui/terminal/TerminalUI.d.ts +139 -0
- package/dist/ui/terminal/TerminalUI.d.ts.map +1 -0
- package/dist/ui/terminal/TerminalUI.js +430 -0
- package/dist/ui/terminal/TerminalUI.js.map +1 -0
- package/dist/ui/terminal/VirtualChatBuffer.d.ts +32 -0
- package/dist/ui/terminal/VirtualChatBuffer.d.ts.map +1 -0
- package/dist/ui/terminal/VirtualChatBuffer.js +37 -0
- package/dist/ui/terminal/VirtualChatBuffer.js.map +1 -0
- package/dist/ui/terminal-kit-base.d.ts +117 -0
- package/dist/ui/terminal-kit-base.d.ts.map +1 -0
- package/dist/ui/terminal-kit-base.js +188 -0
- package/dist/ui/terminal-kit-base.js.map +1 -0
- package/dist/utils/file.d.ts +21 -0
- package/dist/utils/file.d.ts.map +1 -0
- package/dist/utils/file.js +68 -0
- package/dist/utils/file.js.map +1 -0
- package/dist/utils/logger.d.ts +17 -0
- package/dist/utils/logger.d.ts.map +1 -0
- package/dist/utils/logger.js +57 -0
- package/dist/utils/logger.js.map +1 -0
- package/dist/utils/markdown-parser.d.ts +56 -0
- package/dist/utils/markdown-parser.d.ts.map +1 -0
- package/dist/utils/markdown-parser.js +307 -0
- package/dist/utils/markdown-parser.js.map +1 -0
- package/dist/utils/shell.d.ts +7 -0
- package/dist/utils/shell.d.ts.map +1 -0
- package/dist/utils/shell.js +62 -0
- package/dist/utils/shell.js.map +1 -0
- package/dist/utils/state.d.ts +13 -0
- package/dist/utils/state.d.ts.map +1 -0
- package/dist/utils/state.js +25 -0
- package/dist/utils/state.js.map +1 -0
- package/package.json +81 -0
- package/postinstall.js +46 -0
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
import terminal from 'terminal-kit';
|
|
2
|
+
// Initialize terminal
|
|
3
|
+
export const term = terminal.terminal;
|
|
4
|
+
// Initialize ScreenBuffer - we'll create it on demand
|
|
5
|
+
export let screenBuffer = null;
|
|
6
|
+
// Function to ensure screenBuffer is initialized
|
|
7
|
+
export function ensureScreenBuffer() {
|
|
8
|
+
if (!screenBuffer) {
|
|
9
|
+
// Ensure we have valid dimensions
|
|
10
|
+
const width = Math.min(term.width || 120, 500);
|
|
11
|
+
const height = Math.min(term.height || 40, 200);
|
|
12
|
+
screenBuffer = new terminal.ScreenBuffer({
|
|
13
|
+
dst: term,
|
|
14
|
+
width: width,
|
|
15
|
+
height: height
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
return screenBuffer;
|
|
19
|
+
}
|
|
20
|
+
// Color palette mapping (from UI_ELEMENTS_REFERENCE.md)
|
|
21
|
+
export const colors = {
|
|
22
|
+
// Primary colors
|
|
23
|
+
primary: { r: 0x00, g: 0xcc, b: 0xff }, // #00ccff (Cyan)
|
|
24
|
+
success: { r: 0x00, g: 0xcc, b: 0x66 }, // #00cc66 (Green)
|
|
25
|
+
error: { r: 0xff, g: 0x33, b: 0x66 }, // #ff3366 (Red)
|
|
26
|
+
warning: { r: 0xff, g: 0xaa, b: 0x00 }, // #ffaa00 (Orange)
|
|
27
|
+
border: { r: 0x00, g: 0x3b, b: 0x59 }, // #003b59 (Dark Blue)
|
|
28
|
+
dimmed: { r: 0x66, g: 0x66, b: 0x66 }, // #666666 (Gray)
|
|
29
|
+
text: { r: 0xff, g: 0xff, b: 0xff }, // #ffffff (White)
|
|
30
|
+
// Secondary colors for diffs/edits
|
|
31
|
+
lightGreen: { r: 0x66, g: 0xff, b: 0x66 }, // #66ff66
|
|
32
|
+
lightRed: { r: 0xff, g: 0x66, b: 0x66 }, // #ff6666
|
|
33
|
+
lightGray: { r: 0xaa, g: 0xaa, b: 0xaa }, // #aaaaaa
|
|
34
|
+
};
|
|
35
|
+
// Border characters
|
|
36
|
+
export const borders = {
|
|
37
|
+
// Rounded corners (default for most components)
|
|
38
|
+
rounded: {
|
|
39
|
+
topLeft: '╭',
|
|
40
|
+
topRight: '╮',
|
|
41
|
+
bottomLeft: '╰',
|
|
42
|
+
bottomRight: '╯',
|
|
43
|
+
horizontal: '─',
|
|
44
|
+
vertical: '│',
|
|
45
|
+
},
|
|
46
|
+
// Single line (for inner boxes)
|
|
47
|
+
single: {
|
|
48
|
+
topLeft: '┌',
|
|
49
|
+
topRight: '┐',
|
|
50
|
+
bottomLeft: '└',
|
|
51
|
+
bottomRight: '┘',
|
|
52
|
+
horizontal: '─',
|
|
53
|
+
vertical: '│',
|
|
54
|
+
},
|
|
55
|
+
// Double line (for keyboard help)
|
|
56
|
+
double: {
|
|
57
|
+
topLeft: '╔',
|
|
58
|
+
topRight: '╗',
|
|
59
|
+
bottomLeft: '╚',
|
|
60
|
+
bottomRight: '╝',
|
|
61
|
+
horizontal: '═',
|
|
62
|
+
vertical: '║',
|
|
63
|
+
},
|
|
64
|
+
};
|
|
65
|
+
// Helper: Create color attributes for terminal-kit
|
|
66
|
+
export function createColorAttr(color, bold = false, dim = false) {
|
|
67
|
+
return {
|
|
68
|
+
color: [color.r, color.g, color.b],
|
|
69
|
+
bgColor: 'default',
|
|
70
|
+
bold,
|
|
71
|
+
dim,
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
export function drawBox(options) {
|
|
75
|
+
const { x, y, width, height, borderStyle = 'rounded', borderColor = colors.border, title, titleColor = colors.primary, } = options;
|
|
76
|
+
const border = borders[borderStyle];
|
|
77
|
+
const borderAttr = createColorAttr(borderColor);
|
|
78
|
+
const buffer = ensureScreenBuffer();
|
|
79
|
+
// Top border
|
|
80
|
+
buffer.put({
|
|
81
|
+
x,
|
|
82
|
+
y,
|
|
83
|
+
attr: borderAttr,
|
|
84
|
+
}, border.topLeft + border.horizontal.repeat(width - 2) + border.topRight);
|
|
85
|
+
// Title if provided
|
|
86
|
+
if (title) {
|
|
87
|
+
const titleAttr = createColorAttr(titleColor, true);
|
|
88
|
+
const titleX = x + 2; // 2 spaces from left
|
|
89
|
+
buffer.put({ x: titleX, y, attr: titleAttr }, ` ${title} `);
|
|
90
|
+
}
|
|
91
|
+
// Side borders
|
|
92
|
+
for (let i = 1; i < height - 1; i++) {
|
|
93
|
+
buffer.put({ x, y: y + i, attr: borderAttr }, border.vertical);
|
|
94
|
+
buffer.put({ x: x + width - 1, y: y + i, attr: borderAttr }, border.vertical);
|
|
95
|
+
}
|
|
96
|
+
// Bottom border
|
|
97
|
+
buffer.put({
|
|
98
|
+
x,
|
|
99
|
+
y: y + height - 1,
|
|
100
|
+
attr: borderAttr,
|
|
101
|
+
}, border.bottomLeft + border.horizontal.repeat(width - 2) + border.bottomRight);
|
|
102
|
+
}
|
|
103
|
+
// Helper: Clear a region
|
|
104
|
+
export function clearRegion(x, y, width, height) {
|
|
105
|
+
const buffer = ensureScreenBuffer();
|
|
106
|
+
for (let row = 0; row < height; row++) {
|
|
107
|
+
buffer.put({
|
|
108
|
+
x,
|
|
109
|
+
y: y + row,
|
|
110
|
+
attr: createColorAttr(colors.text),
|
|
111
|
+
}, ' '.repeat(width));
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
// Helper: Wrap text to fit width
|
|
115
|
+
export function wrapText(text, maxWidth) {
|
|
116
|
+
const lines = [];
|
|
117
|
+
const words = text.split(' ');
|
|
118
|
+
let currentLine = '';
|
|
119
|
+
for (const word of words) {
|
|
120
|
+
if (currentLine.length + word.length + 1 <= maxWidth) {
|
|
121
|
+
currentLine += (currentLine ? ' ' : '') + word;
|
|
122
|
+
}
|
|
123
|
+
else {
|
|
124
|
+
if (currentLine)
|
|
125
|
+
lines.push(currentLine);
|
|
126
|
+
currentLine = word;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
if (currentLine)
|
|
130
|
+
lines.push(currentLine);
|
|
131
|
+
return lines;
|
|
132
|
+
}
|
|
133
|
+
// Helper: Truncate text with ellipsis
|
|
134
|
+
export function truncate(text, maxLength) {
|
|
135
|
+
if (text.length <= maxLength)
|
|
136
|
+
return text;
|
|
137
|
+
return text.slice(0, maxLength - 3) + '...';
|
|
138
|
+
}
|
|
139
|
+
// Helper: Pad string to length
|
|
140
|
+
export function pad(text, length, char = ' ', align = 'left') {
|
|
141
|
+
if (text.length >= length)
|
|
142
|
+
return text.slice(0, length);
|
|
143
|
+
const padding = length - text.length;
|
|
144
|
+
switch (align) {
|
|
145
|
+
case 'right':
|
|
146
|
+
return char.repeat(padding) + text;
|
|
147
|
+
case 'center':
|
|
148
|
+
const leftPad = Math.floor(padding / 2);
|
|
149
|
+
const rightPad = padding - leftPad;
|
|
150
|
+
return char.repeat(leftPad) + text + char.repeat(rightPad);
|
|
151
|
+
default:
|
|
152
|
+
return text + char.repeat(padding);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
// Initialize terminal for application use
|
|
156
|
+
export function initializeTerminal() {
|
|
157
|
+
// Clear screen
|
|
158
|
+
term.clear();
|
|
159
|
+
// Initialize screen buffer
|
|
160
|
+
ensureScreenBuffer();
|
|
161
|
+
// Enable mouse support (for future scrolling, etc.)
|
|
162
|
+
term.grabInput({ mouse: 'button' });
|
|
163
|
+
// Handle terminal resize
|
|
164
|
+
term.on('resize', () => {
|
|
165
|
+
// Reinitialize screen buffer on resize
|
|
166
|
+
if (screenBuffer) {
|
|
167
|
+
screenBuffer.resize({
|
|
168
|
+
x: 0,
|
|
169
|
+
y: 0,
|
|
170
|
+
width: term.width,
|
|
171
|
+
height: term.height,
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
});
|
|
175
|
+
// Return cleanup function
|
|
176
|
+
return () => {
|
|
177
|
+
term.grabInput(false);
|
|
178
|
+
};
|
|
179
|
+
}
|
|
180
|
+
// Render the screen buffer
|
|
181
|
+
export function render() {
|
|
182
|
+
const buffer = ensureScreenBuffer();
|
|
183
|
+
// Draw the buffer to screen
|
|
184
|
+
buffer.draw();
|
|
185
|
+
// Move cursor to bottom for input
|
|
186
|
+
term.moveTo(1, term.height);
|
|
187
|
+
}
|
|
188
|
+
//# sourceMappingURL=terminal-kit-base.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"terminal-kit-base.js","sourceRoot":"","sources":["../../src/ui/terminal-kit-base.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,MAAM,cAAc,CAAC;AAEpC,sBAAsB;AACtB,MAAM,CAAC,MAAM,IAAI,GAAG,QAAQ,CAAC,QAAQ,CAAC;AAEtC,sDAAsD;AACtD,MAAM,CAAC,IAAI,YAAY,GAAQ,IAAI,CAAC;AAEpC,iDAAiD;AACjD,MAAM,UAAU,kBAAkB;IAChC,IAAI,CAAC,YAAY,EAAE,CAAC;QAClB,kCAA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AM,CAAC,OAAO,CAAC,CAAC;IACvC,CAAC;AACH,CAAC;AAED,0CAA0C;AAC1C,MAAM,UAAU,kBAAkB;IAChC,eAAe;IACf,IAAI,CAAC,KAAK,EAAE,CAAC;IAEb,2BAA2B;IAC3B,kBAAkB,EAAE,CAAC;IAErB,oDAAoD;IACpD,IAAI,CAAC,SAAS,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC,CAAC;IAEpC,yBAAyB;IACzB,IAAI,CAAC,EAAE,CAAC,QAAQ,EAAE,GAAG,EAAE;QACrB,uCAAuC;QACvC,IAAI,YAAY,EAAE,CAAC;YACjB,YAAY,CAAC,MAAM,CAAC;gBAClB,CAAC,EAAE,CAAC;gBACJ,CAAC,EAAE,CAAC;gBACJ,KAAK,EAAE,IAAI,CAAC,KAAK;gBACjB,MAAM,EAAE,IAAI,CAAC,MAAM;aACpB,CAAC,CAAC;QACL,CAAC;IACH,CAAC,CAAC,CAAC;IAEH,0BAA0B;IAC1B,OAAO,GAAG,EAAE;QACV,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;IACxB,CAAC,CAAC;AACJ,CAAC;AAED,2BAA2B;AAC3B,MAAM,UAAU,MAAM;IACpB,MAAM,MAAM,GAAG,kBAAkB,EAAE,CAAC;IACpC,4BAA4B;IAC5B,MAAM,CAAC,IAAI,EAAE,CAAC;IACd,kCAAkC;IAClC,IAAI,CAAC,MAAM,CAAC,CAAC,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;AAC9B,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Read file with optional line range
|
|
3
|
+
*/
|
|
4
|
+
export declare function readFile(filePath: string, startLine?: number, endLine?: number): string;
|
|
5
|
+
/**
|
|
6
|
+
* Write file safely
|
|
7
|
+
*/
|
|
8
|
+
export declare function writeFile(filePath: string, content: string): void;
|
|
9
|
+
/**
|
|
10
|
+
* Search and replace in file
|
|
11
|
+
*/
|
|
12
|
+
export declare function searchReplace(filePath: string, searchPattern: string, replacement: string): string;
|
|
13
|
+
/**
|
|
14
|
+
* List directory contents
|
|
15
|
+
*/
|
|
16
|
+
export declare function listDirectory(dirPath: string, recursive?: boolean): string[];
|
|
17
|
+
/**
|
|
18
|
+
* Check if path is safe (not trying to escape cwd)
|
|
19
|
+
*/
|
|
20
|
+
export declare function isSafePath(filePath: string, cwd: string): boolean;
|
|
21
|
+
//# sourceMappingURL=file.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"file.d.ts","sourceRoot":"","sources":["../../src/utils/file.ts"],"names":[],"mappings":"AAGA;;GAEG;AACH,wBAAgB,QAAQ,CAAC,QAAQ,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,CASvF;AAED;;GAEG;AACH,wBAAgB,SAAS,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI,CAMjE;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,QAAQ,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,MAAM,CAkBlG;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,MAAM,EAAE,SAAS,GAAE,OAAe,GAAG,MAAM,EAAE,CAoBnF;AAED;;GAEG;AACH,wBAAgB,UAAU,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAGjE"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import * as fs from 'fs';
|
|
2
|
+
import * as path from 'path';
|
|
3
|
+
/**
|
|
4
|
+
* Read file with optional line range
|
|
5
|
+
*/
|
|
6
|
+
export function readFile(filePath, startLine, endLine) {
|
|
7
|
+
const content = fs.readFileSync(filePath, 'utf-8');
|
|
8
|
+
if (startLine !== undefined && endLine !== undefined) {
|
|
9
|
+
const lines = content.split('\n');
|
|
10
|
+
return lines.slice(startLine - 1, endLine).join('\n');
|
|
11
|
+
}
|
|
12
|
+
return content;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Write file safely
|
|
16
|
+
*/
|
|
17
|
+
export function writeFile(filePath, content) {
|
|
18
|
+
const dir = path.dirname(filePath);
|
|
19
|
+
if (!fs.existsSync(dir)) {
|
|
20
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
21
|
+
}
|
|
22
|
+
fs.writeFileSync(filePath, content, 'utf-8');
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Search and replace in file
|
|
26
|
+
*/
|
|
27
|
+
export function searchReplace(filePath, searchPattern, replacement) {
|
|
28
|
+
const content = fs.readFileSync(filePath, 'utf-8');
|
|
29
|
+
// Check if pattern exists
|
|
30
|
+
if (!content.includes(searchPattern)) {
|
|
31
|
+
throw new Error(`Pattern not found in file: ${searchPattern}`);
|
|
32
|
+
}
|
|
33
|
+
// Count occurrences
|
|
34
|
+
const occurrences = content.split(searchPattern).length - 1;
|
|
35
|
+
if (occurrences > 1) {
|
|
36
|
+
throw new Error(`Pattern appears ${occurrences} times. Please use a more specific pattern.`);
|
|
37
|
+
}
|
|
38
|
+
const newContent = content.replace(searchPattern, replacement);
|
|
39
|
+
fs.writeFileSync(filePath, newContent, 'utf-8');
|
|
40
|
+
return `Successfully replaced pattern in ${filePath}`;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* List directory contents
|
|
44
|
+
*/
|
|
45
|
+
export function listDirectory(dirPath, recursive = false) {
|
|
46
|
+
const results = [];
|
|
47
|
+
function walk(dir, prefix = '') {
|
|
48
|
+
const entries = fs.readdirSync(dir, { withFileTypes: true });
|
|
49
|
+
for (const entry of entries) {
|
|
50
|
+
const fullPath = path.join(dir, entry.name);
|
|
51
|
+
const relativePath = path.join(prefix, entry.name);
|
|
52
|
+
results.push(relativePath);
|
|
53
|
+
if (recursive && entry.isDirectory()) {
|
|
54
|
+
walk(fullPath, relativePath);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
walk(dirPath);
|
|
59
|
+
return results;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Check if path is safe (not trying to escape cwd)
|
|
63
|
+
*/
|
|
64
|
+
export function isSafePath(filePath, cwd) {
|
|
65
|
+
const resolved = path.resolve(cwd, filePath);
|
|
66
|
+
return resolved.startsWith(cwd);
|
|
67
|
+
}
|
|
68
|
+
//# sourceMappingURL=file.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"file.js","sourceRoot":"","sources":["../../src/utils/file.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AACzB,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAE7B;;GAEG;AACH,MAAM,UAAU,QAAQ,CAAC,QAAgB,EAAE,SAAkB,EAAE,OAAgB;IAC7E,MAAM,OAAO,GAAG,EAAE,CAAC,YAAY,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;IAEnD,IAAI,SAAS,KAAK,SAAS,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;QACrD,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QAClC,OAAO,KAAK,CAAC,KAAK,CAAC,SAAS,GAAG,CAAC,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACxD,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,SAAS,CAAC,QAAgB,EAAE,OAAe;IACzD,MAAM,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;IACnC,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;QACxB,EAAE,CAAC,SAAS,CAAC,GAAG,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;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CAAC;YAC5C,MAAM,YAAY,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC;YAEnD,OAAO,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;YAE3B,IAAI,SAAS,IAAI,KAAK,CAAC,WAAW,EAAE,EAAE,CAAC;gBACrC,IAAI,CAAC,QAAQ,EAAE,YAAY,CAAC,CAAC;YAC/B,CAAC;QACH,CAAC;IACH,CAAC;IAED,IAAI,CAAC,OAAO,CAAC,CAAC;IACd,OAAO,OAAO,CAAC;AACjB,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,UAAU,CAAC,QAAgB,EAAE,GAAW;IACtD,MAAM,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC;IAC7C,OAAO,QAAQ,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;AAClC,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Log informational message
|
|
3
|
+
*/
|
|
4
|
+
export declare function logInfo(message: string): void;
|
|
5
|
+
/**
|
|
6
|
+
* Log error with optional Error object
|
|
7
|
+
*/
|
|
8
|
+
export declare function logError(message: string, error?: Error): void;
|
|
9
|
+
/**
|
|
10
|
+
* Log debug information
|
|
11
|
+
*/
|
|
12
|
+
export declare function logDebug(message: string): void;
|
|
13
|
+
/**
|
|
14
|
+
* Log warning
|
|
15
|
+
*/
|
|
16
|
+
export declare function logWarning(message: string): void;
|
|
17
|
+
//# sourceMappingURL=logger.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../src/utils/logger.ts"],"names":[],"mappings":"AAiCA;;GAEG;AACH,wBAAgB,OAAO,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAG7C;AAED;;GAEG;AACH,wBAAgB,QAAQ,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,KAAK,GAAG,IAAI,CAG7D;AAED;;GAEG;AACH,wBAAgB,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAG9C;AAED;;GAEG;AACH,wBAAgB,UAAU,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAGhD"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import * as fs from 'fs';
|
|
2
|
+
import * as path from 'path';
|
|
3
|
+
const LOG_FILE = path.join(process.cwd(), 'centaurus-cli.log');
|
|
4
|
+
/**
|
|
5
|
+
* Format a log entry with timestamp and level
|
|
6
|
+
*/
|
|
7
|
+
function formatLogEntry(level, message, error) {
|
|
8
|
+
const timestamp = new Date().toISOString();
|
|
9
|
+
let entry = `[${timestamp}] [${level}] ${message}`;
|
|
10
|
+
if (error) {
|
|
11
|
+
entry += `\n Error: ${error.message}`;
|
|
12
|
+
if (error.stack) {
|
|
13
|
+
entry += `\n Stack: ${error.stack}`;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
return entry + '\n';
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Write to log file (synchronous to ensure it completes before exit)
|
|
20
|
+
*/
|
|
21
|
+
function writeToLog(entry) {
|
|
22
|
+
try {
|
|
23
|
+
fs.appendFileSync(LOG_FILE, entry, 'utf8');
|
|
24
|
+
}
|
|
25
|
+
catch (error) {
|
|
26
|
+
// If we can't write to log, fail silently - don't use console in Ink app
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Log informational message
|
|
31
|
+
*/
|
|
32
|
+
export function logInfo(message) {
|
|
33
|
+
const entry = formatLogEntry('INFO', message);
|
|
34
|
+
writeToLog(entry);
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Log error with optional Error object
|
|
38
|
+
*/
|
|
39
|
+
export function logError(message, error) {
|
|
40
|
+
const entry = formatLogEntry('ERROR', message, error);
|
|
41
|
+
writeToLog(entry);
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Log debug information
|
|
45
|
+
*/
|
|
46
|
+
export function logDebug(message) {
|
|
47
|
+
const entry = formatLogEntry('DEBUG', message);
|
|
48
|
+
writeToLog(entry);
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Log warning
|
|
52
|
+
*/
|
|
53
|
+
export function logWarning(message) {
|
|
54
|
+
const entry = formatLogEntry('WARNING', message);
|
|
55
|
+
writeToLog(entry);
|
|
56
|
+
}
|
|
57
|
+
//# sourceMappingURL=logger.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../../src/utils/logger.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AACzB,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAE7B,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,mBAAmB,CAAC,CAAC;AAE/D;;GAEG;AACH,SAAS,cAAc,CAAC,KAAa,EAAE,OAAe,EAAE,KAAa;IACnE,MAAM,SAAS,GAAG,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;IAC3C,IAAI,KAAK,GAAG,IAAI,SAAS,MAAM,KAAK,KAAK,OAAO,EAAE,CAAC;IAEnD,IAAI,KAAK,EAAE,CAAC;QACV,KAAK,IAAI,cAAc,KAAK,CAAC,OAAO,EAAE,CAAC;QACvC,IAAI,KAAK,CAAC,KAAK,EAAE,CAAC;YAChB,KAAK,IAAI,cAAc,KAAK,CAAC,KAAK,EAAE,CAAC;QACvC,CAAC;IACH,CAAC;IAED,OAAO,KAAK,GAAG,IAAI,CAAC;AACtB,CAAC;AAED;;GAEG;AACH,SAAS,UAAU,CAAC,KAAa;IAC/B,IAAI,CAAC;QACH,EAAE,CAAC,cAAc,CAAC,QAAQ,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC;IAC7C,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,yEAAyE;IAC3E,CAAC;AACH,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,OAAO,CAAC,OAAe;IACrC,MAAM,KAAK,GAAG,cAAc,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC9C,UAAU,CAAC,KAAK,CAAC,CAAC;AACpB,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,QAAQ,CAAC,OAAe,EAAE,KAAa;IACrD,MAAM,KAAK,GAAG,cAAc,CAAC,OAAO,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC;IACtD,UAAU,CAAC,KAAK,CAAC,CAAC;AACpB,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,QAAQ,CAAC,OAAe;IACtC,MAAM,KAAK,GAAG,cAAc,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IAC/C,UAAU,CAAC,KAAK,CAAC,CAAC;AACpB,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,UAAU,CAAC,OAAe;IACxC,MAAM,KAAK,GAAG,cAAc,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;IACjD,UAAU,CAAC,KAAK,CAAC,CAAC;AACpB,CAAC"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
export interface ParsedElement {
|
|
2
|
+
type: 'text' | 'heading' | 'list-item' | 'code-block' | 'code-inline' | 'bold' | 'italic' | 'link' | 'blockquote' | 'horizontal-rule' | 'line-break';
|
|
3
|
+
content: string;
|
|
4
|
+
level?: number;
|
|
5
|
+
language?: string;
|
|
6
|
+
ordered?: boolean;
|
|
7
|
+
index?: number;
|
|
8
|
+
children?: ParsedElement[];
|
|
9
|
+
}
|
|
10
|
+
export declare class MarkdownParser {
|
|
11
|
+
/**
|
|
12
|
+
* Main parse function that processes markdown text into structured elements
|
|
13
|
+
*/
|
|
14
|
+
parse(markdown: string): ParsedElement[];
|
|
15
|
+
/**
|
|
16
|
+
* Parse code block (```)
|
|
17
|
+
*/
|
|
18
|
+
private parseCodeBlock;
|
|
19
|
+
/**
|
|
20
|
+
* Parse heading (# ## ### etc.)
|
|
21
|
+
*/
|
|
22
|
+
private parseHeading;
|
|
23
|
+
/**
|
|
24
|
+
* Check if line is horizontal rule
|
|
25
|
+
*/
|
|
26
|
+
private isHorizontalRule;
|
|
27
|
+
/**
|
|
28
|
+
* Parse blockquote
|
|
29
|
+
*/
|
|
30
|
+
private parseBlockquote;
|
|
31
|
+
/**
|
|
32
|
+
* Parse ordered list item
|
|
33
|
+
*/
|
|
34
|
+
private parseOrderedListItem;
|
|
35
|
+
/**
|
|
36
|
+
* Parse unordered list item
|
|
37
|
+
*/
|
|
38
|
+
private parseUnorderedListItem;
|
|
39
|
+
/**
|
|
40
|
+
* Parse inline formatting (bold, italic, code, links)
|
|
41
|
+
*/
|
|
42
|
+
private parseInlineFormatting;
|
|
43
|
+
/**
|
|
44
|
+
* Parse inline elements within text
|
|
45
|
+
*/
|
|
46
|
+
private parseInlineElements;
|
|
47
|
+
/**
|
|
48
|
+
* Merge adjacent text elements
|
|
49
|
+
*/
|
|
50
|
+
private mergeAdjacentText;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Utility to wrap text to a specific width
|
|
54
|
+
*/
|
|
55
|
+
export declare function wrapText(text: string, maxWidth: number, indent?: number): string[];
|
|
56
|
+
//# sourceMappingURL=markdown-parser.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"markdown-parser.d.ts","sourceRoot":"","sources":["../../src/utils/markdown-parser.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,GAAG,SAAS,GAAG,WAAW,GAAG,YAAY,GAAG,aAAa,GAAG,MAAM,GAAG,QAAQ,GAAG,MAAM,GAAG,YAAY,GAAG,iBAAiB,GAAG,YAAY,CAAC;IACrJ,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,aAAa,EAAE,CAAC;CAC5B;AAED,qBAAa,cAAc;IACzB;;OAEG;IACH,KAAK,CAAC,QAAQ,EAAE,MAAM,GAAG,aAAa,EAAE;IAwExC;;OAEG;IACH,OAAO,CAAC,cAAc;IA0BtB;;OAEG;IACH,OAAO,CAAC,YAAY;IAYpB;;OAEG;IACH,OAAO,CAAC,gBAAgB;IAKxB;;OAEG;IACH,OAAO,CAAC,eAAe;IASvB;;OAEG;IACH,OAAO,CAAC,oBAAoB;IAkB5B;;OAEG;IACH,OAAO,CAAC,sBAAsB;IAgB9B;;OAEG;IACH,OAAO,CAAC,qBAAqB;IAQ7B;;OAEG;IACH,OAAO,CAAC,mBAAmB;IA2F3B;;OAEG;IACH,OAAO,CAAC,iBAAiB;CA4B1B;AAED;;GAEG;AACH,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,GAAE,MAAU,GAAG,MAAM,EAAE,CAyBrF"}
|