codemeld 2.1.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/README.md +514 -0
- package/bin/cli.js +2 -0
- package/dist/ai/agent.d.ts +124 -0
- package/dist/ai/agent.d.ts.map +1 -0
- package/dist/ai/agent.js +289 -0
- package/dist/ai/agent.js.map +1 -0
- package/dist/ai/index.d.ts +10 -0
- package/dist/ai/index.d.ts.map +1 -0
- package/dist/ai/index.js +10 -0
- package/dist/ai/index.js.map +1 -0
- package/dist/ai/prompts.d.ts +35 -0
- package/dist/ai/prompts.d.ts.map +1 -0
- package/dist/ai/prompts.js +166 -0
- package/dist/ai/prompts.js.map +1 -0
- package/dist/ai/refinement-loop.d.ts +29 -0
- package/dist/ai/refinement-loop.d.ts.map +1 -0
- package/dist/ai/refinement-loop.js +180 -0
- package/dist/ai/refinement-loop.js.map +1 -0
- package/dist/ai/tools.d.ts +17 -0
- package/dist/ai/tools.d.ts.map +1 -0
- package/dist/ai/tools.js +353 -0
- package/dist/ai/tools.js.map +1 -0
- package/dist/ai/visual-compare.d.ts +43 -0
- package/dist/ai/visual-compare.d.ts.map +1 -0
- package/dist/ai/visual-compare.js +176 -0
- package/dist/ai/visual-compare.js.map +1 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +179 -0
- package/dist/cli.js.map +1 -0
- package/dist/converter.d.ts +10 -0
- package/dist/converter.d.ts.map +1 -0
- package/dist/converter.js +836 -0
- package/dist/converter.js.map +1 -0
- package/dist/deconverter.d.ts +19 -0
- package/dist/deconverter.d.ts.map +1 -0
- package/dist/deconverter.js +188 -0
- package/dist/deconverter.js.map +1 -0
- package/dist/frameworks/angular-adapter.d.ts +27 -0
- package/dist/frameworks/angular-adapter.d.ts.map +1 -0
- package/dist/frameworks/angular-adapter.js +617 -0
- package/dist/frameworks/angular-adapter.js.map +1 -0
- package/dist/frameworks/index.d.ts +10 -0
- package/dist/frameworks/index.d.ts.map +1 -0
- package/dist/frameworks/index.js +21 -0
- package/dist/frameworks/index.js.map +1 -0
- package/dist/frameworks/nextjs-adapter.d.ts +22 -0
- package/dist/frameworks/nextjs-adapter.d.ts.map +1 -0
- package/dist/frameworks/nextjs-adapter.js +392 -0
- package/dist/frameworks/nextjs-adapter.js.map +1 -0
- package/dist/frameworks/react-adapter.d.ts +21 -0
- package/dist/frameworks/react-adapter.d.ts.map +1 -0
- package/dist/frameworks/react-adapter.js +71 -0
- package/dist/frameworks/react-adapter.js.map +1 -0
- package/dist/frameworks/svelte-adapter.d.ts +27 -0
- package/dist/frameworks/svelte-adapter.d.ts.map +1 -0
- package/dist/frameworks/svelte-adapter.js +519 -0
- package/dist/frameworks/svelte-adapter.js.map +1 -0
- package/dist/frameworks/types.d.ts +78 -0
- package/dist/frameworks/types.d.ts.map +1 -0
- package/dist/frameworks/types.js +2 -0
- package/dist/frameworks/types.js.map +1 -0
- package/dist/frameworks/vue-adapter.d.ts +34 -0
- package/dist/frameworks/vue-adapter.d.ts.map +1 -0
- package/dist/frameworks/vue-adapter.js +632 -0
- package/dist/frameworks/vue-adapter.js.map +1 -0
- package/dist/generators/accessibility-generator.d.ts +43 -0
- package/dist/generators/accessibility-generator.d.ts.map +1 -0
- package/dist/generators/accessibility-generator.js +507 -0
- package/dist/generators/accessibility-generator.js.map +1 -0
- package/dist/generators/asset-handler.d.ts +14 -0
- package/dist/generators/asset-handler.d.ts.map +1 -0
- package/dist/generators/asset-handler.js +79 -0
- package/dist/generators/asset-handler.js.map +1 -0
- package/dist/generators/build-verifier.d.ts +8 -0
- package/dist/generators/build-verifier.d.ts.map +1 -0
- package/dist/generators/build-verifier.js +64 -0
- package/dist/generators/build-verifier.js.map +1 -0
- package/dist/generators/component-extractor.d.ts +25 -0
- package/dist/generators/component-extractor.d.ts.map +1 -0
- package/dist/generators/component-extractor.js +146 -0
- package/dist/generators/component-extractor.js.map +1 -0
- package/dist/generators/component-generator.d.ts +12 -0
- package/dist/generators/component-generator.d.ts.map +1 -0
- package/dist/generators/component-generator.js +724 -0
- package/dist/generators/component-generator.js.map +1 -0
- package/dist/generators/deploy-generator.d.ts +9 -0
- package/dist/generators/deploy-generator.d.ts.map +1 -0
- package/dist/generators/deploy-generator.js +409 -0
- package/dist/generators/deploy-generator.js.map +1 -0
- package/dist/generators/error-boundary.d.ts +5 -0
- package/dist/generators/error-boundary.d.ts.map +1 -0
- package/dist/generators/error-boundary.js +59 -0
- package/dist/generators/error-boundary.js.map +1 -0
- package/dist/generators/form-generator.d.ts +42 -0
- package/dist/generators/form-generator.d.ts.map +1 -0
- package/dist/generators/form-generator.js +662 -0
- package/dist/generators/form-generator.js.map +1 -0
- package/dist/generators/hooks-generator.d.ts +40 -0
- package/dist/generators/hooks-generator.d.ts.map +1 -0
- package/dist/generators/hooks-generator.js +297 -0
- package/dist/generators/hooks-generator.js.map +1 -0
- package/dist/generators/html-generator.d.ts +27 -0
- package/dist/generators/html-generator.d.ts.map +1 -0
- package/dist/generators/html-generator.js +772 -0
- package/dist/generators/html-generator.js.map +1 -0
- package/dist/generators/jquery-converter.d.ts +41 -0
- package/dist/generators/jquery-converter.d.ts.map +1 -0
- package/dist/generators/jquery-converter.js +594 -0
- package/dist/generators/jquery-converter.js.map +1 -0
- package/dist/generators/pattern-implementer.d.ts +26 -0
- package/dist/generators/pattern-implementer.d.ts.map +1 -0
- package/dist/generators/pattern-implementer.js +336 -0
- package/dist/generators/pattern-implementer.js.map +1 -0
- package/dist/generators/performance-generator.d.ts +51 -0
- package/dist/generators/performance-generator.d.ts.map +1 -0
- package/dist/generators/performance-generator.js +428 -0
- package/dist/generators/performance-generator.js.map +1 -0
- package/dist/generators/router-generator.d.ts +21 -0
- package/dist/generators/router-generator.d.ts.map +1 -0
- package/dist/generators/router-generator.js +178 -0
- package/dist/generators/router-generator.js.map +1 -0
- package/dist/generators/scaffolder.d.ts +28 -0
- package/dist/generators/scaffolder.d.ts.map +1 -0
- package/dist/generators/scaffolder.js +266 -0
- package/dist/generators/scaffolder.js.map +1 -0
- package/dist/generators/seo-generator.d.ts +29 -0
- package/dist/generators/seo-generator.d.ts.map +1 -0
- package/dist/generators/seo-generator.js +223 -0
- package/dist/generators/seo-generator.js.map +1 -0
- package/dist/generators/test-generator.d.ts +19 -0
- package/dist/generators/test-generator.d.ts.map +1 -0
- package/dist/generators/test-generator.js +398 -0
- package/dist/generators/test-generator.js.map +1 -0
- package/dist/generators/type-generator.d.ts +33 -0
- package/dist/generators/type-generator.d.ts.map +1 -0
- package/dist/generators/type-generator.js +663 -0
- package/dist/generators/type-generator.js.map +1 -0
- package/dist/index.d.ts +23 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +12 -0
- package/dist/index.js.map +1 -0
- package/dist/parsers/css-processor.d.ts +23 -0
- package/dist/parsers/css-processor.d.ts.map +1 -0
- package/dist/parsers/css-processor.js +129 -0
- package/dist/parsers/css-processor.js.map +1 -0
- package/dist/parsers/framework-parser.d.ts +48 -0
- package/dist/parsers/framework-parser.d.ts.map +1 -0
- package/dist/parsers/framework-parser.js +770 -0
- package/dist/parsers/framework-parser.js.map +1 -0
- package/dist/parsers/html-parser.d.ts +12 -0
- package/dist/parsers/html-parser.d.ts.map +1 -0
- package/dist/parsers/html-parser.js +444 -0
- package/dist/parsers/html-parser.js.map +1 -0
- package/dist/parsers/js-analyzer.d.ts +199 -0
- package/dist/parsers/js-analyzer.d.ts.map +1 -0
- package/dist/parsers/js-analyzer.js +680 -0
- package/dist/parsers/js-analyzer.js.map +1 -0
- package/dist/parsers/js-resolver.d.ts +8 -0
- package/dist/parsers/js-resolver.d.ts.map +1 -0
- package/dist/parsers/js-resolver.js +45 -0
- package/dist/parsers/js-resolver.js.map +1 -0
- package/dist/parsers/tailwind-detector.d.ts +23 -0
- package/dist/parsers/tailwind-detector.d.ts.map +1 -0
- package/dist/parsers/tailwind-detector.js +104 -0
- package/dist/parsers/tailwind-detector.js.map +1 -0
- package/dist/tests/advanced-features.test.d.ts +2 -0
- package/dist/tests/advanced-features.test.d.ts.map +1 -0
- package/dist/tests/advanced-features.test.js +235 -0
- package/dist/tests/advanced-features.test.js.map +1 -0
- package/dist/tests/css-modules.test.d.ts +2 -0
- package/dist/tests/css-modules.test.d.ts.map +1 -0
- package/dist/tests/css-modules.test.js +61 -0
- package/dist/tests/css-modules.test.js.map +1 -0
- package/dist/tests/css-processor.test.d.ts +2 -0
- package/dist/tests/css-processor.test.d.ts.map +1 -0
- package/dist/tests/css-processor.test.js +48 -0
- package/dist/tests/css-processor.test.js.map +1 -0
- package/dist/tests/html-parser.test.d.ts +2 -0
- package/dist/tests/html-parser.test.d.ts.map +1 -0
- package/dist/tests/html-parser.test.js +78 -0
- package/dist/tests/html-parser.test.js.map +1 -0
- package/dist/tests/integration.test.d.ts +2 -0
- package/dist/tests/integration.test.d.ts.map +1 -0
- package/dist/tests/integration.test.js +65 -0
- package/dist/tests/integration.test.js.map +1 -0
- package/dist/tests/js-analyzer.test.d.ts +2 -0
- package/dist/tests/js-analyzer.test.d.ts.map +1 -0
- package/dist/tests/js-analyzer.test.js +58 -0
- package/dist/tests/js-analyzer.test.js.map +1 -0
- package/dist/tests/naming.test.d.ts +2 -0
- package/dist/tests/naming.test.d.ts.map +1 -0
- package/dist/tests/naming.test.js +43 -0
- package/dist/tests/naming.test.js.map +1 -0
- package/dist/tests/router-generator.test.d.ts +2 -0
- package/dist/tests/router-generator.test.d.ts.map +1 -0
- package/dist/tests/router-generator.test.js +60 -0
- package/dist/tests/router-generator.test.js.map +1 -0
- package/dist/tui/chat.d.ts +13 -0
- package/dist/tui/chat.d.ts.map +1 -0
- package/dist/tui/chat.js +499 -0
- package/dist/tui/chat.js.map +1 -0
- package/dist/tui/design-guide.d.ts +41 -0
- package/dist/tui/design-guide.d.ts.map +1 -0
- package/dist/tui/design-guide.js +184 -0
- package/dist/tui/design-guide.js.map +1 -0
- package/dist/tui/input.d.ts +30 -0
- package/dist/tui/input.d.ts.map +1 -0
- package/dist/tui/input.js +239 -0
- package/dist/tui/input.js.map +1 -0
- package/dist/tui/renderer.d.ts +48 -0
- package/dist/tui/renderer.d.ts.map +1 -0
- package/dist/tui/renderer.js +212 -0
- package/dist/tui/renderer.js.map +1 -0
- package/dist/tui/tools.d.ts +14 -0
- package/dist/tui/tools.d.ts.map +1 -0
- package/dist/tui/tools.js +1370 -0
- package/dist/tui/tools.js.map +1 -0
- package/dist/types.d.ts +93 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/dist/utils/config.d.ts +20 -0
- package/dist/utils/config.d.ts.map +1 -0
- package/dist/utils/config.js +33 -0
- package/dist/utils/config.js.map +1 -0
- package/dist/utils/formatter.d.ts +5 -0
- package/dist/utils/formatter.d.ts.map +1 -0
- package/dist/utils/formatter.js +68 -0
- package/dist/utils/formatter.js.map +1 -0
- package/dist/utils/logger.d.ts +8 -0
- package/dist/utils/logger.d.ts.map +1 -0
- package/dist/utils/logger.js +19 -0
- package/dist/utils/logger.js.map +1 -0
- package/dist/utils/naming.d.ts +17 -0
- package/dist/utils/naming.d.ts.map +1 -0
- package/dist/utils/naming.js +48 -0
- package/dist/utils/naming.js.map +1 -0
- package/dist/utils/report.d.ts +56 -0
- package/dist/utils/report.d.ts.map +1 -0
- package/dist/utils/report.js +339 -0
- package/dist/utils/report.js.map +1 -0
- package/package.json +61 -0
package/dist/tui/chat.js
ADDED
|
@@ -0,0 +1,499 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Interactive TUI Chat — Claude Code-style terminal interface
|
|
3
|
+
* for the CodeMeld AI agent.
|
|
4
|
+
*
|
|
5
|
+
* Features:
|
|
6
|
+
* - Highlighted input box with borders
|
|
7
|
+
* - Slash command autocomplete dropdown
|
|
8
|
+
* - @file attachment support
|
|
9
|
+
* - Auto-compact when history > 30 turns
|
|
10
|
+
* - Input history navigation
|
|
11
|
+
*/
|
|
12
|
+
import { resolve, join } from 'path';
|
|
13
|
+
import { existsSync } from 'fs';
|
|
14
|
+
import { chatCompletion, truncateToolResult } from '../ai/agent.js';
|
|
15
|
+
import { chatToolDefinitions, createChatToolExecutor } from './tools.js';
|
|
16
|
+
import { createEnhancedInput, parseFileAttachments, buildMessageWithAttachments, clipboardRead, clipboardWrite, } from './input.js';
|
|
17
|
+
import { COLORS, Spinner, printHeader, printAssistantMessage, printToolCall, printToolResult, printError, printHelp, } from './renderer.js';
|
|
18
|
+
// ─── Constants ───────────────────────────────────────────────────────
|
|
19
|
+
const AUTO_COMPACT_THRESHOLD = 30; // Auto-compact when user+assistant messages exceed this
|
|
20
|
+
const COMPACT_KEEP_RECENT = 8; // Keep this many recent messages when compacting
|
|
21
|
+
/** Sanitize error messages to never leak internal URLs, commands, or file paths. */
|
|
22
|
+
function sanitizeError(err) {
|
|
23
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
24
|
+
// If the message already looks user-friendly (from our sanitized throws), pass it through
|
|
25
|
+
const leakPatterns = [
|
|
26
|
+
/https?:\/\/\S+/i, // URLs
|
|
27
|
+
/curl\s/i, // curl commands
|
|
28
|
+
/Command failed:/i, // child_process errors
|
|
29
|
+
/<html/i, // raw HTML responses
|
|
30
|
+
/ECONNREFUSED|ENOTFOUND|ETIMEDOUT|ENAMETOOLONG/i, // raw Node errors
|
|
31
|
+
/\/tmp\/|\\AppData\\|\\Temp\\/i, // temp file paths
|
|
32
|
+
];
|
|
33
|
+
if (leakPatterns.some(p => p.test(msg))) {
|
|
34
|
+
return 'AI request failed. Please try again.';
|
|
35
|
+
}
|
|
36
|
+
return msg;
|
|
37
|
+
}
|
|
38
|
+
// ─── System Prompt ───────────────────────────────────────────────────
|
|
39
|
+
function buildSystemPrompt(projectDir) {
|
|
40
|
+
return `You are an expert full-stack developer and coding assistant inside a terminal chat. You have full access to the user's project through a comprehensive set of development tools.
|
|
41
|
+
|
|
42
|
+
CRITICAL — TOOL USAGE:
|
|
43
|
+
- You MUST ONLY use the tools explicitly listed below. These are YOUR tools that execute on the user's machine.
|
|
44
|
+
- NEVER use any built-in/internal/server-side tools. If you have access to any tools not listed below (like built-in file reading, code execution, web browsing, or any other internal capability), DO NOT use them.
|
|
45
|
+
- ONLY call the function tools provided in the tools array of this conversation. Nothing else.
|
|
46
|
+
- When you need to perform an action, ALWAYS return a tool_call using one of the listed tools. Never try to handle it internally.
|
|
47
|
+
|
|
48
|
+
ENVIRONMENT:
|
|
49
|
+
- Project directory: ${projectDir}
|
|
50
|
+
- Platform: ${process.platform === 'win32' ? 'Windows' : process.platform === 'darwin' ? 'macOS' : 'Linux'}
|
|
51
|
+
- CRITICAL: All file/directory paths must be RELATIVE to the project root.
|
|
52
|
+
Good: "src/App.tsx", "package.json", ".", "src/components"
|
|
53
|
+
Bad: "${projectDir}/src/App.tsx" (NEVER use absolute paths)
|
|
54
|
+
|
|
55
|
+
YOUR TOOLS:
|
|
56
|
+
File Operations:
|
|
57
|
+
- read_file (with offset/limit), write_file, edit_file (with replace_all), multi_edit, insert_at_line
|
|
58
|
+
- delete_file, move_file, copy_file
|
|
59
|
+
|
|
60
|
+
Search & Discovery:
|
|
61
|
+
- glob ("**/*.tsx"), grep (regex with context/file_type), list_files (recursive), file_info, project_overview
|
|
62
|
+
|
|
63
|
+
Build & Dev:
|
|
64
|
+
- run_build, run_typecheck, npm_install, bash (any shell command)
|
|
65
|
+
|
|
66
|
+
Git:
|
|
67
|
+
- git_status, git_diff, git_log, git_commit
|
|
68
|
+
|
|
69
|
+
Todo Management (persisted to .todos.json):
|
|
70
|
+
- todo_list, todo_add, todo_update, todo_remove, todo_batch
|
|
71
|
+
|
|
72
|
+
Design System:
|
|
73
|
+
- generate_design_guide: Generate a unique design system (fonts, colors, layouts, animations)
|
|
74
|
+
with the a0 design AI. Saves to .design-guide.md. Call this BEFORE creating UI components.
|
|
75
|
+
|
|
76
|
+
BEHAVIOR RULES:
|
|
77
|
+
1. ALWAYS use tools. Do NOT guess file contents or project structure.
|
|
78
|
+
2. Before editing, read the file first.
|
|
79
|
+
3. Use edit_file for small changes, write_file for large rewrites.
|
|
80
|
+
4. After code changes, verify with run_build or run_typecheck.
|
|
81
|
+
5. Use glob and grep to find things — don't ask the user.
|
|
82
|
+
6. Be concise. Lead with actions, not explanations.
|
|
83
|
+
7. For complex tasks, use todo_batch to create a plan, then IMMEDIATELY start executing.
|
|
84
|
+
Flow: explore → plan (create todos) → execute (mark in_progress) → verify (mark done).
|
|
85
|
+
8. Use bash for anything not covered by specialized tools.
|
|
86
|
+
9. When working on multi-step tasks, use todo tools to track your progress.
|
|
87
|
+
10. BEFORE creating or modifying UI components, call generate_design_guide to get a
|
|
88
|
+
unique design system. If .design-guide.md already exists, read it first.
|
|
89
|
+
|
|
90
|
+
CRITICAL — AUTONOMOUS EXECUTION:
|
|
91
|
+
- NEVER ask the user to confirm before proceeding. NEVER say "if that sounds good" or "shall I proceed" or "let me know". Just DO IT.
|
|
92
|
+
- When the user asks you to build something, START BUILDING IMMEDIATELY. Create the plan with todos, then execute every step without stopping.
|
|
93
|
+
- You have full permission to create files, install packages, modify code, and run commands. USE that permission.
|
|
94
|
+
- Do NOT stop after making a plan. The plan is step 1 — execute ALL steps in one go.
|
|
95
|
+
- Only stop to ask the user if there is a genuine ambiguity that cannot be resolved (e.g., two contradictory requirements).
|
|
96
|
+
|
|
97
|
+
DESIGN GUIDE RULES:
|
|
98
|
+
- When the user asks to create UI, build pages, or style components, FIRST call
|
|
99
|
+
generate_design_guide with the project type to get typography, colors, and layout direction.
|
|
100
|
+
- Apply the design system consistently: use the CSS variables, Google Fonts, and layout patterns.
|
|
101
|
+
- BANNED: Inter, Roboto, Arial, Poppins fonts. BANNED: purple gradients, floating blobs, emojis as icons.
|
|
102
|
+
- Use Lucide React icons (20px, stroke-width 1.5). NEVER use emojis as icons.
|
|
103
|
+
- Images: use https://api.a0.dev/assets/image?text={description}&aspect=16:9
|
|
104
|
+
- Real content only: specific names, prices, dates — never lorem ipsum or "coming soon".
|
|
105
|
+
- Mobile-first responsive: hamburger nav, grid-cols-1→md:2→lg:3, min 44px touch targets.
|
|
106
|
+
- Every dark:bg-* needs matching dark:text-* on all children.
|
|
107
|
+
|
|
108
|
+
CONTEXT:
|
|
109
|
+
The user may attach file contents using @filename. When they do, the file content appears in the message under "Attached file contents:". Use this context to understand the code they're referencing.
|
|
110
|
+
|
|
111
|
+
FORMATTING:
|
|
112
|
+
- Use markdown: **bold**, \`code\`, \`\`\`code blocks\`\`\`
|
|
113
|
+
- Keep responses focused and concise`;
|
|
114
|
+
}
|
|
115
|
+
// ─── Auto-Compact (AI-powered summarization) ───────────────────────
|
|
116
|
+
async function autoCompact(session) {
|
|
117
|
+
const conversationMsgs = session.messages.filter(m => m.role === 'user' || m.role === 'assistant');
|
|
118
|
+
if (conversationMsgs.length < AUTO_COMPACT_THRESHOLD)
|
|
119
|
+
return false;
|
|
120
|
+
const systemMsg = session.messages[0];
|
|
121
|
+
const recentMessages = session.messages.slice(-COMPACT_KEEP_RECENT);
|
|
122
|
+
const oldMessages = session.messages.slice(1, -COMPACT_KEEP_RECENT);
|
|
123
|
+
// Build conversation text to summarize
|
|
124
|
+
const conversationText = oldMessages
|
|
125
|
+
.filter(m => (m.role === 'user' || m.role === 'assistant') && m.content)
|
|
126
|
+
.map(m => `[${m.role}]: ${(m.content || '').slice(0, 300)}`)
|
|
127
|
+
.join('\n');
|
|
128
|
+
// Use the AI API to generate a proper synthesized summary
|
|
129
|
+
let summary;
|
|
130
|
+
try {
|
|
131
|
+
const summaryResponse = await chatCompletion({
|
|
132
|
+
messages: [
|
|
133
|
+
{
|
|
134
|
+
role: 'system',
|
|
135
|
+
content: 'You are a conversation summarizer. Summarize the following conversation history into a concise but complete summary. Include: key decisions made, files modified, errors encountered and how they were fixed, what the user asked for, and the current state of the project. Keep it under 500 words. Output ONLY the summary, no preamble.',
|
|
136
|
+
},
|
|
137
|
+
{
|
|
138
|
+
role: 'user',
|
|
139
|
+
content: `Summarize this conversation:\n\n${conversationText}`,
|
|
140
|
+
},
|
|
141
|
+
],
|
|
142
|
+
temperature: 0.2,
|
|
143
|
+
max_tokens: 1024,
|
|
144
|
+
});
|
|
145
|
+
summary = summaryResponse.choices[0]?.message?.content || '';
|
|
146
|
+
if (summaryResponse.usage) {
|
|
147
|
+
session.totalTokens += summaryResponse.usage.total_tokens;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
catch {
|
|
151
|
+
// Fallback to simple truncation if API fails
|
|
152
|
+
const turns = oldMessages.filter(m => m.role === 'user' || (m.role === 'assistant' && m.content));
|
|
153
|
+
summary = turns
|
|
154
|
+
.map(m => `[${m.role}]: ${(m.content || '').slice(0, 150)}`)
|
|
155
|
+
.slice(0, 15)
|
|
156
|
+
.join('\n');
|
|
157
|
+
}
|
|
158
|
+
session.messages = [
|
|
159
|
+
systemMsg,
|
|
160
|
+
{
|
|
161
|
+
role: 'user',
|
|
162
|
+
content: `[Conversation History Summary — ${conversationMsgs.length} messages compacted]\n\n${summary}\n\n[End of summary. Continue the conversation from here.]`,
|
|
163
|
+
},
|
|
164
|
+
{
|
|
165
|
+
role: 'assistant',
|
|
166
|
+
content: 'I have the full context from our previous conversation. Ready to continue.',
|
|
167
|
+
},
|
|
168
|
+
...recentMessages,
|
|
169
|
+
];
|
|
170
|
+
return true;
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* Force compact (for /compact command). Always runs even below threshold.
|
|
174
|
+
*/
|
|
175
|
+
async function forceCompact(session) {
|
|
176
|
+
if (session.messages.length <= 6)
|
|
177
|
+
return false;
|
|
178
|
+
const systemMsg = session.messages[0];
|
|
179
|
+
const recentMessages = session.messages.slice(-6);
|
|
180
|
+
const oldMessages = session.messages.slice(1, -6);
|
|
181
|
+
const conversationText = oldMessages
|
|
182
|
+
.filter(m => (m.role === 'user' || m.role === 'assistant') && m.content)
|
|
183
|
+
.map(m => `[${m.role}]: ${(m.content || '').slice(0, 300)}`)
|
|
184
|
+
.join('\n');
|
|
185
|
+
let summary;
|
|
186
|
+
try {
|
|
187
|
+
const summaryResponse = await chatCompletion({
|
|
188
|
+
messages: [
|
|
189
|
+
{
|
|
190
|
+
role: 'system',
|
|
191
|
+
content: 'Summarize this conversation concisely. Include key decisions, files changed, errors fixed, and current state. Under 400 words. Output ONLY the summary.',
|
|
192
|
+
},
|
|
193
|
+
{ role: 'user', content: conversationText },
|
|
194
|
+
],
|
|
195
|
+
temperature: 0.2,
|
|
196
|
+
max_tokens: 800,
|
|
197
|
+
});
|
|
198
|
+
summary = summaryResponse.choices[0]?.message?.content || '';
|
|
199
|
+
if (summaryResponse.usage) {
|
|
200
|
+
session.totalTokens += summaryResponse.usage.total_tokens;
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
catch {
|
|
204
|
+
const turns = oldMessages.filter(m => (m.role === 'user' || m.role === 'assistant') && m.content);
|
|
205
|
+
summary = turns.map(m => `[${m.role}]: ${(m.content || '').slice(0, 150)}`).slice(0, 15).join('\n');
|
|
206
|
+
}
|
|
207
|
+
session.messages = [
|
|
208
|
+
systemMsg,
|
|
209
|
+
{
|
|
210
|
+
role: 'user',
|
|
211
|
+
content: `[Conversation Summary]\n\n${summary}\n\n[Continue from here.]`,
|
|
212
|
+
},
|
|
213
|
+
{ role: 'assistant', content: 'Understood, continuing with full context.' },
|
|
214
|
+
...recentMessages,
|
|
215
|
+
];
|
|
216
|
+
return true;
|
|
217
|
+
}
|
|
218
|
+
// ─── Process Message ────────────────────────────────────────────────
|
|
219
|
+
async function processMessage(session, userInput) {
|
|
220
|
+
const { messages, projectDir } = session;
|
|
221
|
+
messages.push({ role: 'user', content: userInput });
|
|
222
|
+
session.turnCount++;
|
|
223
|
+
const toolCtx = {
|
|
224
|
+
projectDir,
|
|
225
|
+
onToolStart: (name, args) => printToolCall(name, args),
|
|
226
|
+
onToolEnd: (name, result, success) => printToolResult(name, result, success),
|
|
227
|
+
};
|
|
228
|
+
const toolExecutor = createChatToolExecutor(toolCtx);
|
|
229
|
+
const spinner = new Spinner('Thinking...');
|
|
230
|
+
spinner.start();
|
|
231
|
+
let step = 0;
|
|
232
|
+
let finalContent = '';
|
|
233
|
+
try {
|
|
234
|
+
let consecutiveCheckCalls = 0;
|
|
235
|
+
while (step < 50) {
|
|
236
|
+
step++;
|
|
237
|
+
const response = await chatCompletion({
|
|
238
|
+
messages,
|
|
239
|
+
tools: chatToolDefinitions,
|
|
240
|
+
temperature: 0.3,
|
|
241
|
+
max_tokens: 16000,
|
|
242
|
+
});
|
|
243
|
+
const choice = response.choices[0];
|
|
244
|
+
const content = choice.message.content || '';
|
|
245
|
+
const toolCalls = choice.message.tool_calls || [];
|
|
246
|
+
const finishReason = choice.finish_reason;
|
|
247
|
+
if (response.usage) {
|
|
248
|
+
session.totalTokens += response.usage.total_tokens;
|
|
249
|
+
}
|
|
250
|
+
spinner.stop();
|
|
251
|
+
if (finishReason === 'stop' || toolCalls.length === 0) {
|
|
252
|
+
finalContent = content;
|
|
253
|
+
break;
|
|
254
|
+
}
|
|
255
|
+
if (content) {
|
|
256
|
+
console.log(COLORS.dim(` ${content.split('\n')[0].slice(0, 100)}`));
|
|
257
|
+
}
|
|
258
|
+
messages.push({
|
|
259
|
+
role: 'assistant',
|
|
260
|
+
content: content || null,
|
|
261
|
+
tool_calls: toolCalls,
|
|
262
|
+
});
|
|
263
|
+
// Loop detection
|
|
264
|
+
const toolNames = toolCalls.map(tc => tc.function.name);
|
|
265
|
+
const isFileOp = toolNames.some(n => !['run_build', 'run_typecheck'].includes(n));
|
|
266
|
+
const isCheckOp = toolNames.some(n => ['run_build', 'run_typecheck'].includes(n));
|
|
267
|
+
if (isCheckOp && !isFileOp) {
|
|
268
|
+
consecutiveCheckCalls++;
|
|
269
|
+
}
|
|
270
|
+
else {
|
|
271
|
+
consecutiveCheckCalls = 0;
|
|
272
|
+
}
|
|
273
|
+
// Execute tools
|
|
274
|
+
for (const tc of toolCalls) {
|
|
275
|
+
let args;
|
|
276
|
+
try {
|
|
277
|
+
args = JSON.parse(tc.function.arguments);
|
|
278
|
+
}
|
|
279
|
+
catch {
|
|
280
|
+
args = {};
|
|
281
|
+
}
|
|
282
|
+
let result;
|
|
283
|
+
try {
|
|
284
|
+
result = await toolExecutor(tc.function.name, args);
|
|
285
|
+
}
|
|
286
|
+
catch (err) {
|
|
287
|
+
result = `Error: ${err instanceof Error ? err.message : String(err)}`;
|
|
288
|
+
}
|
|
289
|
+
result = truncateToolResult(result);
|
|
290
|
+
messages.push({
|
|
291
|
+
role: 'tool',
|
|
292
|
+
tool_call_id: tc.id,
|
|
293
|
+
content: result,
|
|
294
|
+
});
|
|
295
|
+
}
|
|
296
|
+
if (consecutiveCheckCalls >= 2) {
|
|
297
|
+
messages.push({
|
|
298
|
+
role: 'user',
|
|
299
|
+
content: 'You are running build/typecheck repeatedly. Use read_file then edit_file/write_file to fix issues before checking again.',
|
|
300
|
+
});
|
|
301
|
+
consecutiveCheckCalls = 0;
|
|
302
|
+
}
|
|
303
|
+
spinner.update(`Step ${step}...`);
|
|
304
|
+
spinner.start();
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
catch (err) {
|
|
308
|
+
spinner.stop();
|
|
309
|
+
printError(sanitizeError(err));
|
|
310
|
+
return;
|
|
311
|
+
}
|
|
312
|
+
if (finalContent) {
|
|
313
|
+
printAssistantMessage(finalContent);
|
|
314
|
+
messages.push({ role: 'assistant', content: finalContent });
|
|
315
|
+
session.turnCount++;
|
|
316
|
+
}
|
|
317
|
+
// Auto-compact check
|
|
318
|
+
const compacted = await autoCompact(session);
|
|
319
|
+
if (compacted) {
|
|
320
|
+
console.log(COLORS.dim(' ⟳ Chat history auto-compacted (AI-summarized) to save context\n'));
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
// ─── Slash Commands ──────────────────────────────────────────────────
|
|
324
|
+
async function handleSlashCommand(command, session) {
|
|
325
|
+
const parts = command.trim().split(/\s+/);
|
|
326
|
+
const cmd = parts[0].toLowerCase();
|
|
327
|
+
const rest = parts.slice(1).join(' ');
|
|
328
|
+
switch (cmd) {
|
|
329
|
+
case '/quit':
|
|
330
|
+
case '/exit':
|
|
331
|
+
case '/q':
|
|
332
|
+
console.log(COLORS.dim('\n Goodbye!\n'));
|
|
333
|
+
return true;
|
|
334
|
+
case '/help':
|
|
335
|
+
case '/h':
|
|
336
|
+
printHelp();
|
|
337
|
+
return false;
|
|
338
|
+
case '/clear':
|
|
339
|
+
console.clear();
|
|
340
|
+
session.messages = [{ role: 'system', content: buildSystemPrompt(session.projectDir) }];
|
|
341
|
+
session.turnCount = 0;
|
|
342
|
+
printHeader(session.projectDir);
|
|
343
|
+
console.log(COLORS.success(' Chat history cleared.\n'));
|
|
344
|
+
return false;
|
|
345
|
+
case '/build':
|
|
346
|
+
await processMessage(session, 'Run vite build and show me the results. If it fails, show the errors clearly.');
|
|
347
|
+
return false;
|
|
348
|
+
case '/typecheck':
|
|
349
|
+
case '/tsc':
|
|
350
|
+
await processMessage(session, 'Run TypeScript type checking and show me any errors with file locations.');
|
|
351
|
+
return false;
|
|
352
|
+
case '/files':
|
|
353
|
+
case '/tree':
|
|
354
|
+
await processMessage(session, 'Show me the project directory tree recursively.');
|
|
355
|
+
return false;
|
|
356
|
+
case '/git':
|
|
357
|
+
await processMessage(session, `Run git ${rest || 'status'} and show me the output.`);
|
|
358
|
+
return false;
|
|
359
|
+
case '/fix':
|
|
360
|
+
await processMessage(session, 'Run a typecheck and build. If there are any errors, read the broken files, fix them, and verify the fixes. Keep going until everything passes.');
|
|
361
|
+
return false;
|
|
362
|
+
case '/overview':
|
|
363
|
+
await processMessage(session, 'Give me a comprehensive overview of this project: structure, dependencies, config, and key files.');
|
|
364
|
+
return false;
|
|
365
|
+
case '/install':
|
|
366
|
+
await processMessage(session, rest ? `Install the npm package(s): ${rest}` : 'Run npm install to install all dependencies.');
|
|
367
|
+
return false;
|
|
368
|
+
case '/design': {
|
|
369
|
+
if (rest) {
|
|
370
|
+
await processMessage(session, `Generate a unique design system for this project type: "${rest}". Call generate_design_guide and then show me the key design decisions (fonts, colors, layout approach).`);
|
|
371
|
+
}
|
|
372
|
+
else {
|
|
373
|
+
await processMessage(session, 'Generate a unique design system for this project. Analyze the project type from package.json and existing code, then call generate_design_guide. Show me the key design decisions.');
|
|
374
|
+
}
|
|
375
|
+
return false;
|
|
376
|
+
}
|
|
377
|
+
case '/todos':
|
|
378
|
+
case '/todo': {
|
|
379
|
+
if (rest === 'clear') {
|
|
380
|
+
await processMessage(session, 'Remove all completed (done) todos from the list.');
|
|
381
|
+
}
|
|
382
|
+
else if (rest) {
|
|
383
|
+
await processMessage(session, `Add a todo: "${rest}"`);
|
|
384
|
+
}
|
|
385
|
+
else {
|
|
386
|
+
await processMessage(session, 'Show me the current todo list with progress.');
|
|
387
|
+
}
|
|
388
|
+
return false;
|
|
389
|
+
}
|
|
390
|
+
case '/compact': {
|
|
391
|
+
const before = session.messages.length;
|
|
392
|
+
const spinner = new Spinner('Summarizing conversation...');
|
|
393
|
+
spinner.start();
|
|
394
|
+
const didCompact = await forceCompact(session);
|
|
395
|
+
spinner.stop();
|
|
396
|
+
if (didCompact) {
|
|
397
|
+
console.log(COLORS.success(` ✓ Compacted ${before} → ${session.messages.length} messages (AI-summarized).\n`));
|
|
398
|
+
}
|
|
399
|
+
else {
|
|
400
|
+
console.log(COLORS.dim(' Nothing to compact.\n'));
|
|
401
|
+
}
|
|
402
|
+
return false;
|
|
403
|
+
}
|
|
404
|
+
case '/copy': {
|
|
405
|
+
// Copy last assistant response to clipboard
|
|
406
|
+
const lastAssistant = [...session.messages].reverse().find(m => m.role === 'assistant');
|
|
407
|
+
if (lastAssistant && lastAssistant.content) {
|
|
408
|
+
const text = typeof lastAssistant.content === 'string' ? lastAssistant.content : JSON.stringify(lastAssistant.content);
|
|
409
|
+
if (clipboardWrite(text)) {
|
|
410
|
+
console.log(COLORS.success(' ✓ Last response copied to clipboard.\n'));
|
|
411
|
+
}
|
|
412
|
+
else {
|
|
413
|
+
printError('Could not access clipboard. Install xclip or xsel on Linux.');
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
else {
|
|
417
|
+
console.log(COLORS.dim(' No assistant response to copy.\n'));
|
|
418
|
+
}
|
|
419
|
+
return false;
|
|
420
|
+
}
|
|
421
|
+
case '/paste': {
|
|
422
|
+
// Paste clipboard content as a user message
|
|
423
|
+
const pasted = clipboardRead();
|
|
424
|
+
if (pasted) {
|
|
425
|
+
console.log(COLORS.dim(` ✓ Pasted ${pasted.length} chars from clipboard.\n`));
|
|
426
|
+
await processMessage(session, pasted);
|
|
427
|
+
}
|
|
428
|
+
else {
|
|
429
|
+
printError('Clipboard is empty or not accessible. Install xclip or xsel on Linux.');
|
|
430
|
+
}
|
|
431
|
+
return false;
|
|
432
|
+
}
|
|
433
|
+
default:
|
|
434
|
+
printError(`Unknown command: ${cmd}. Type /help for available commands.`);
|
|
435
|
+
return false;
|
|
436
|
+
}
|
|
437
|
+
}
|
|
438
|
+
// ─── Main Entry Point ───────────────────────────────────────────────
|
|
439
|
+
export async function startChat(projectDir) {
|
|
440
|
+
const dir = resolve(projectDir || process.cwd());
|
|
441
|
+
const hasPackageJson = existsSync(join(dir, 'package.json'));
|
|
442
|
+
printHeader(dir);
|
|
443
|
+
if (!hasPackageJson) {
|
|
444
|
+
console.log(COLORS.warning(' Warning: No package.json found. Some tools may not work.\n'));
|
|
445
|
+
}
|
|
446
|
+
const session = {
|
|
447
|
+
messages: [{ role: 'system', content: buildSystemPrompt(dir) }],
|
|
448
|
+
projectDir: dir,
|
|
449
|
+
totalTokens: 0,
|
|
450
|
+
turnCount: 0,
|
|
451
|
+
};
|
|
452
|
+
let running = true;
|
|
453
|
+
while (running) {
|
|
454
|
+
try {
|
|
455
|
+
// Show token usage in input box
|
|
456
|
+
const tokenInfo = session.totalTokens > 0
|
|
457
|
+
? `tokens: ${(session.totalTokens / 1000).toFixed(1)}k • turns: ${session.turnCount}`
|
|
458
|
+
: undefined;
|
|
459
|
+
const { text, attachedFiles } = await createEnhancedInput(dir, tokenInfo);
|
|
460
|
+
const trimmed = text.trim();
|
|
461
|
+
if (!trimmed)
|
|
462
|
+
continue;
|
|
463
|
+
// Handle slash commands
|
|
464
|
+
if (trimmed.startsWith('/')) {
|
|
465
|
+
const shouldExit = await handleSlashCommand(trimmed, session);
|
|
466
|
+
if (shouldExit) {
|
|
467
|
+
running = false;
|
|
468
|
+
break;
|
|
469
|
+
}
|
|
470
|
+
continue;
|
|
471
|
+
}
|
|
472
|
+
// Parse @file attachments
|
|
473
|
+
const parsed = await parseFileAttachments(trimmed, dir);
|
|
474
|
+
const fullMessage = buildMessageWithAttachments(parsed);
|
|
475
|
+
// Display attached files (user's typed text is already visible in the input line)
|
|
476
|
+
if (attachedFiles.length > 0 || parsed.attachedFiles.length > 0) {
|
|
477
|
+
const allFiles = [...new Set([...attachedFiles, ...parsed.attachedFiles.map(f => f.path)])];
|
|
478
|
+
for (const f of allFiles) {
|
|
479
|
+
console.log(` ${COLORS.success('📎')} ${COLORS.dim(f)} attached`);
|
|
480
|
+
}
|
|
481
|
+
}
|
|
482
|
+
console.log(''); // spacing before response
|
|
483
|
+
await processMessage(session, fullMessage);
|
|
484
|
+
}
|
|
485
|
+
catch (err) {
|
|
486
|
+
if (err.code === 'ERR_USE_AFTER_CLOSE') {
|
|
487
|
+
break;
|
|
488
|
+
}
|
|
489
|
+
printError(sanitizeError(err));
|
|
490
|
+
}
|
|
491
|
+
}
|
|
492
|
+
}
|
|
493
|
+
// Allow running directly
|
|
494
|
+
import { fileURLToPath } from 'url';
|
|
495
|
+
const currentFile = fileURLToPath(import.meta.url);
|
|
496
|
+
if (process.argv[1] === currentFile) {
|
|
497
|
+
startChat(process.argv[2]).catch(console.error);
|
|
498
|
+
}
|
|
499
|
+
//# sourceMappingURL=chat.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chat.js","sourceRoot":"","sources":["../../src/tui/chat.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAA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,MAAM,GAAG,CAAC,EAAE,CAAC;gBAChE,MAAM,QAAQ,GAAG,CAAC,GAAG,IAAI,GAAG,CAAC,CAAC,GAAG,aAAa,EAAE,GAAG,MAAM,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;gBAC5F,KAAK,MAAM,CAAC,IAAI,QAAQ,EAAE,CAAC;oBACzB,OAAO,CAAC,GAAG,CAAC,KAAK,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC;gBACrE,CAAC;YACH,CAAC;YACD,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC,0BAA0B;YAE3C,MAAM,cAAc,CAAC,OAAO,EAAE,WAAW,CAAC,CAAC;QAC7C,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,IAAK,GAA6B,CAAC,IAAI,KAAK,qBAAqB,EAAE,CAAC;gBAClE,MAAM;YACR,CAAC;YACD,UAAU,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC,CAAC;QACjC,CAAC;IACH,CAAC;AACH,CAAC;AAED,yBAAyB;AACzB,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AAEpC,MAAM,WAAW,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AACnD,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,WAAW,EAAE,CAAC;IACpC,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AAClD,CAAC"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Design Guide Generator — calls the a0 LLM API to create
|
|
3
|
+
* project-specific design systems with unique typography, colors, and layouts.
|
|
4
|
+
* Uses native Node.js fetch — no curl dependency.
|
|
5
|
+
*/
|
|
6
|
+
export interface DesignData {
|
|
7
|
+
a: string;
|
|
8
|
+
df: string;
|
|
9
|
+
bf: string;
|
|
10
|
+
p: string;
|
|
11
|
+
pl: string;
|
|
12
|
+
ac: string;
|
|
13
|
+
s: string;
|
|
14
|
+
sa: string;
|
|
15
|
+
t: string;
|
|
16
|
+
tm: string;
|
|
17
|
+
bd: string;
|
|
18
|
+
ds: string;
|
|
19
|
+
dt: string;
|
|
20
|
+
hero: string;
|
|
21
|
+
layouts: string;
|
|
22
|
+
motion: string;
|
|
23
|
+
texture: string;
|
|
24
|
+
unique: string;
|
|
25
|
+
heading: string;
|
|
26
|
+
sub: string;
|
|
27
|
+
cta: string;
|
|
28
|
+
sections: string;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Generate a design guide for a project type using the a0 LLM API.
|
|
32
|
+
*/
|
|
33
|
+
export declare function generateDesignGuide(projectType: string, userMessage?: string): Promise<{
|
|
34
|
+
guide: string;
|
|
35
|
+
design: DesignData;
|
|
36
|
+
}>;
|
|
37
|
+
/**
|
|
38
|
+
* Fallback design guide when API call fails.
|
|
39
|
+
*/
|
|
40
|
+
export declare function getFallbackGuide(projectType: string): string;
|
|
41
|
+
//# sourceMappingURL=design-guide.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"design-guide.d.ts","sourceRoot":"","sources":["../../src/tui/design-guide.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAKH,MAAM,WAAW,UAAU;IACzB,CAAC,EAAE,MAAM,CAAC;IACV,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;IACX,CAAC,EAAE,MAAM,CAAC;IACV,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;IACX,CAAC,EAAE,MAAM,CAAC;IACV,EAAE,EAAE,MAAM,CAAC;IACX,CAAC,EAAE,MAAM,CAAC;IACV,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;IACZ,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED;;GAEG;AACH,wBAAsB,mBAAmB,CACvC,WAAW,EAAE,MAAM,EACnB,WAAW,CAAC,EAAE,MAAM,GACnB,OAAO,CAAC;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,UAAU,CAAA;CAAE,CAAC,CAyDhD;AAyFD;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CA2B5D"}
|