@kirosnn/mosaic 0.0.7
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/.mosaic/mosaic.local.jsonc +0 -0
- package/MOSAIC.md +188 -0
- package/README.md +127 -0
- package/docs/mosaic.png +0 -0
- package/package.json +42 -0
- package/src/agent/Agent.ts +131 -0
- package/src/agent/context.ts +96 -0
- package/src/agent/index.ts +2 -0
- package/src/agent/prompts/systemPrompt.ts +138 -0
- package/src/agent/prompts/toolsPrompt.ts +139 -0
- package/src/agent/provider/anthropic.ts +122 -0
- package/src/agent/provider/google.ts +124 -0
- package/src/agent/provider/mistral.ts +117 -0
- package/src/agent/provider/ollama.ts +531 -0
- package/src/agent/provider/openai.ts +220 -0
- package/src/agent/provider/xai.ts +122 -0
- package/src/agent/tools/bash.ts +20 -0
- package/src/agent/tools/definitions.ts +27 -0
- package/src/agent/tools/edit.ts +23 -0
- package/src/agent/tools/executor.ts +751 -0
- package/src/agent/tools/explore.ts +18 -0
- package/src/agent/tools/exploreExecutor.ts +320 -0
- package/src/agent/tools/glob.ts +16 -0
- package/src/agent/tools/grep.ts +19 -0
- package/src/agent/tools/index.ts +4 -0
- package/src/agent/tools/list.ts +20 -0
- package/src/agent/tools/question.ts +20 -0
- package/src/agent/tools/read.ts +15 -0
- package/src/agent/tools/write.ts +21 -0
- package/src/agent/types.ts +155 -0
- package/src/components/App.tsx +174 -0
- package/src/components/CommandsModal.tsx +77 -0
- package/src/components/CustomInput.tsx +328 -0
- package/src/components/Main.tsx +1112 -0
- package/src/components/Notification.tsx +91 -0
- package/src/components/SelectList.tsx +47 -0
- package/src/components/Setup.tsx +528 -0
- package/src/components/ShortcutsModal.tsx +67 -0
- package/src/components/Welcome.tsx +39 -0
- package/src/components/main/ApprovalPanel.tsx +134 -0
- package/src/components/main/ChatPage.tsx +516 -0
- package/src/components/main/HomePage.tsx +111 -0
- package/src/components/main/QuestionPanel.tsx +85 -0
- package/src/components/main/ThinkingIndicator.tsx +101 -0
- package/src/components/main/types.ts +55 -0
- package/src/components/main/wrapText.ts +41 -0
- package/src/index.tsx +212 -0
- package/src/utils/approvalBridge.ts +129 -0
- package/src/utils/commands/echo.ts +22 -0
- package/src/utils/commands/help.ts +25 -0
- package/src/utils/commands/index.ts +68 -0
- package/src/utils/commands/init.ts +68 -0
- package/src/utils/commands/redo.ts +74 -0
- package/src/utils/commands/registry.ts +29 -0
- package/src/utils/commands/sessions.ts +129 -0
- package/src/utils/commands/types.ts +20 -0
- package/src/utils/commands/undo.ts +75 -0
- package/src/utils/commands/web.ts +77 -0
- package/src/utils/config.ts +357 -0
- package/src/utils/diff.ts +201 -0
- package/src/utils/diffRendering.tsx +62 -0
- package/src/utils/exploreBridge.ts +87 -0
- package/src/utils/fileChangeTracker.ts +98 -0
- package/src/utils/fileChangesBridge.ts +18 -0
- package/src/utils/history.ts +106 -0
- package/src/utils/markdown.tsx +232 -0
- package/src/utils/models.ts +304 -0
- package/src/utils/questionBridge.ts +122 -0
- package/src/utils/terminalUtils.ts +25 -0
- package/src/utils/toolFormatting.ts +384 -0
- package/src/utils/undoRedo.ts +429 -0
- package/src/utils/undoRedoBridge.ts +45 -0
- package/src/utils/undoRedoDb.ts +338 -0
- package/src/utils/uninstall.ts +45 -0
- package/src/utils/version.ts +3 -0
- package/src/web/app.tsx +606 -0
- package/src/web/assets/css/ChatPage.css +212 -0
- package/src/web/assets/css/FileExplorer.css +202 -0
- package/src/web/assets/css/HomePage.css +119 -0
- package/src/web/assets/css/Markdown.css +178 -0
- package/src/web/assets/css/MessageItem.css +160 -0
- package/src/web/assets/css/Sidebar.css +208 -0
- package/src/web/assets/css/SidebarModal.css +137 -0
- package/src/web/assets/css/ThinkingIndicator.css +47 -0
- package/src/web/assets/css/ToolMessage.css +148 -0
- package/src/web/assets/css/global.css +226 -0
- package/src/web/assets/fonts/Geist-Black.woff2 +0 -0
- package/src/web/assets/fonts/Geist-BlackItalic.woff2 +0 -0
- package/src/web/assets/fonts/Geist-Bold.woff2 +0 -0
- package/src/web/assets/fonts/Geist-BoldItalic.woff2 +0 -0
- package/src/web/assets/fonts/Geist-ExtraBold.woff2 +0 -0
- package/src/web/assets/fonts/Geist-ExtraBoldItalic.woff2 +0 -0
- package/src/web/assets/fonts/Geist-ExtraLight.woff2 +0 -0
- package/src/web/assets/fonts/Geist-ExtraLightItalic.woff2 +0 -0
- package/src/web/assets/fonts/Geist-Italic[wght].woff2 +0 -0
- package/src/web/assets/fonts/Geist-Light.woff2 +0 -0
- package/src/web/assets/fonts/Geist-LightItalic.woff2 +0 -0
- package/src/web/assets/fonts/Geist-Medium.woff2 +0 -0
- package/src/web/assets/fonts/Geist-MediumItalic.woff2 +0 -0
- package/src/web/assets/fonts/Geist-Regular.woff2 +0 -0
- package/src/web/assets/fonts/Geist-RegularItalic.woff2 +0 -0
- package/src/web/assets/fonts/Geist-SemiBold.woff2 +0 -0
- package/src/web/assets/fonts/Geist-SemiBoldItalic.woff2 +0 -0
- package/src/web/assets/fonts/Geist-Thin.woff2 +0 -0
- package/src/web/assets/fonts/Geist-ThinItalic.woff2 +0 -0
- package/src/web/assets/fonts/GeistMono-Black.woff2 +0 -0
- package/src/web/assets/fonts/GeistMono-BlackItalic.woff2 +0 -0
- package/src/web/assets/fonts/GeistMono-Bold.woff2 +0 -0
- package/src/web/assets/fonts/GeistMono-BoldItalic.woff2 +0 -0
- package/src/web/assets/fonts/GeistMono-ExtraBold.woff2 +0 -0
- package/src/web/assets/fonts/GeistMono-ExtraBoldItalic.woff2 +0 -0
- package/src/web/assets/fonts/GeistMono-ExtraLight.woff2 +0 -0
- package/src/web/assets/fonts/GeistMono-ExtraLightItalic.woff2 +0 -0
- package/src/web/assets/fonts/GeistMono-Italic.woff2 +0 -0
- package/src/web/assets/fonts/GeistMono-Italic[wght].woff2 +0 -0
- package/src/web/assets/fonts/GeistMono-Light.woff2 +0 -0
- package/src/web/assets/fonts/GeistMono-LightItalic.woff2 +0 -0
- package/src/web/assets/fonts/GeistMono-Medium.woff2 +0 -0
- package/src/web/assets/fonts/GeistMono-MediumItalic.woff2 +0 -0
- package/src/web/assets/fonts/GeistMono-Regular.woff2 +0 -0
- package/src/web/assets/fonts/GeistMono-SemiBold.woff2 +0 -0
- package/src/web/assets/fonts/GeistMono-SemiBoldItalic.woff2 +0 -0
- package/src/web/assets/fonts/GeistMono-Thin.woff2 +0 -0
- package/src/web/assets/fonts/GeistMono-ThinItalic.woff2 +0 -0
- package/src/web/assets/fonts/GeistMono[wght].woff2 +0 -0
- package/src/web/assets/fonts/Geist[wght].woff2 +0 -0
- package/src/web/assets/fonts/blauer-nue-regular.woff2 +0 -0
- package/src/web/assets/fonts/neue-montreal-regular.woff2 +0 -0
- package/src/web/assets/images/favicon-v2.svg +6 -0
- package/src/web/assets/images/favicon.png +0 -0
- package/src/web/assets/images/foruse.svg +5 -0
- package/src/web/assets/images/logo_black.svg +5 -0
- package/src/web/assets/images/logo_white.svg +5 -0
- package/src/web/assets/images/logoblack.png +0 -0
- package/src/web/assets/images/logowhite.png +0 -0
- package/src/web/build.ts +23 -0
- package/src/web/components/ApprovalPanel.tsx +191 -0
- package/src/web/components/ChatPage.tsx +273 -0
- package/src/web/components/FileExplorer.tsx +162 -0
- package/src/web/components/HomePage.tsx +121 -0
- package/src/web/components/MessageItem.tsx +178 -0
- package/src/web/components/Modal.tsx +30 -0
- package/src/web/components/QuestionPanel.tsx +149 -0
- package/src/web/components/Setup.tsx +211 -0
- package/src/web/components/Sidebar.tsx +292 -0
- package/src/web/components/ThinkingIndicator.tsx +85 -0
- package/src/web/logo_black.svg +5 -0
- package/src/web/logo_white.svg +5 -0
- package/src/web/router.ts +46 -0
- package/src/web/server.tsx +662 -0
- package/src/web/storage.ts +92 -0
- package/src/web/types.ts +17 -0
- package/src/web/utils.ts +61 -0
- package/tsconfig.json +33 -0
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
@import "ChatPage.css";
|
|
2
|
+
@import "HomePage.css";
|
|
3
|
+
@import "Sidebar.css";
|
|
4
|
+
@import "SidebarModal.css";
|
|
5
|
+
@import "MessageItem.css";
|
|
6
|
+
@import "ToolMessage.css";
|
|
7
|
+
@import "Markdown.css";
|
|
8
|
+
|
|
9
|
+
:root {
|
|
10
|
+
--bg-app: #171717;
|
|
11
|
+
--bg-panel: #1a1a1a;
|
|
12
|
+
--bg-code: #0d0d0d;
|
|
13
|
+
--bg-panel-transparent: rgba(26, 26, 26, 0.5);
|
|
14
|
+
|
|
15
|
+
--text-primary: #ffffff;
|
|
16
|
+
--text-secondary: #aaaaaa;
|
|
17
|
+
--text-muted: #666666;
|
|
18
|
+
|
|
19
|
+
--accent-color: #ffca38;
|
|
20
|
+
--accent-hover: #ffd966;
|
|
21
|
+
|
|
22
|
+
--border-subtle: #333333;
|
|
23
|
+
--border-code: #2a2a2a;
|
|
24
|
+
--code-text: #e0e0e0;
|
|
25
|
+
|
|
26
|
+
--bg-tool: rgba(26, 42, 26, 0.2);
|
|
27
|
+
--border-tool: #1a2a1a;
|
|
28
|
+
|
|
29
|
+
--bg-tool-running: rgba(26, 26, 42, 0.2);
|
|
30
|
+
--border-tool-running: #1a1a2a;
|
|
31
|
+
|
|
32
|
+
--bg-tool-error: rgba(42, 26, 26, 0.2);
|
|
33
|
+
--border-tool-error: #2a1a1a;
|
|
34
|
+
|
|
35
|
+
--bg-error: #3a1a1a;
|
|
36
|
+
|
|
37
|
+
--status-success: #44aa88;
|
|
38
|
+
--status-running: #4488aa;
|
|
39
|
+
--status-error: #ff4444;
|
|
40
|
+
--status-error-dark: #ff3838;
|
|
41
|
+
|
|
42
|
+
--overlay-light: rgba(255, 255, 255, 0.05);
|
|
43
|
+
--overlay-medium: rgba(255, 255, 255, 0.08);
|
|
44
|
+
--overlay-strong: rgba(255, 255, 255, 0.12);
|
|
45
|
+
--border-overlay-light: rgba(255, 255, 255, 0.1);
|
|
46
|
+
--border-overlay-strong: rgba(255, 255, 255, 0.2);
|
|
47
|
+
|
|
48
|
+
--shadow-light: rgba(0, 0, 0, 0.1);
|
|
49
|
+
--shadow-medium: rgba(0, 0, 0, 0.15);
|
|
50
|
+
|
|
51
|
+
--gradient-hover: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.02), transparent);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
@media (prefers-color-scheme: light) {
|
|
55
|
+
:root {
|
|
56
|
+
--bg-app: #ffffff;
|
|
57
|
+
--bg-panel: #f5f5f5;
|
|
58
|
+
--bg-code: #f8f8f8;
|
|
59
|
+
|
|
60
|
+
--text-primary: #1a1a1a;
|
|
61
|
+
--text-secondary: #555555;
|
|
62
|
+
--text-muted: #888888;
|
|
63
|
+
|
|
64
|
+
--accent-color: #d9a510;
|
|
65
|
+
--accent-hover: #b88a0e;
|
|
66
|
+
|
|
67
|
+
--border-subtle: #dddddd;
|
|
68
|
+
--border-code: #e0e0e0;
|
|
69
|
+
--code-text: #333333;
|
|
70
|
+
|
|
71
|
+
--bg-tool: rgba(240, 253, 244, 0.2);
|
|
72
|
+
--border-tool: #f0fdf4;
|
|
73
|
+
|
|
74
|
+
--bg-tool-running: rgba(239, 246, 255, 0.2);
|
|
75
|
+
--border-tool-running: #eff6ff;
|
|
76
|
+
|
|
77
|
+
--bg-tool-error: rgba(254, 242, 242, 0.2);
|
|
78
|
+
--border-tool-error: #fef2f2;
|
|
79
|
+
|
|
80
|
+
--bg-error: #fff1f2;
|
|
81
|
+
|
|
82
|
+
--status-success: #059669;
|
|
83
|
+
--status-running: #0284c7;
|
|
84
|
+
--status-error: #dc2626;
|
|
85
|
+
--status-error-dark: #ef4444;
|
|
86
|
+
|
|
87
|
+
--overlay-light: rgba(0, 0, 0, 0.03);
|
|
88
|
+
--overlay-medium: rgba(0, 0, 0, 0.05);
|
|
89
|
+
--overlay-strong: rgba(0, 0, 0, 0.08);
|
|
90
|
+
--border-overlay-light: rgba(0, 0, 0, 0.1);
|
|
91
|
+
--border-overlay-strong: rgba(0, 0, 0, 0.15);
|
|
92
|
+
|
|
93
|
+
--shadow-light: rgba(0, 0, 0, 0.06);
|
|
94
|
+
--shadow-medium: rgba(0, 0, 0, 0.1);
|
|
95
|
+
|
|
96
|
+
--gradient-hover: linear-gradient(90deg, transparent, rgba(0, 0, 0, 0.02), transparent);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
@font-face {
|
|
101
|
+
font-family: "Geist";
|
|
102
|
+
src: url("../fonts/Geist[wght].woff2") format("woff2");
|
|
103
|
+
font-style: normal;
|
|
104
|
+
font-display: swap
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
@font-face {
|
|
108
|
+
font-family: "Geist Medium Monospace";
|
|
109
|
+
src: url("../fonts/GeistMono-Medium.woff2") format("woff2");
|
|
110
|
+
font-style: normal;
|
|
111
|
+
font-display: swap
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
@font-face {
|
|
115
|
+
font-family: "Blauer Nue Regular";
|
|
116
|
+
src: url("../fonts/blauer-nue-regular.woff2") format("woff2");
|
|
117
|
+
font-style: normal;
|
|
118
|
+
font-display: swap
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
@font-face {
|
|
122
|
+
font-family: "Neue Montreal Regular";
|
|
123
|
+
src: url("../fonts/neue-montreal-regular.woff2") format("woff2");
|
|
124
|
+
font-style: normal;
|
|
125
|
+
font-display: swap
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
* {
|
|
129
|
+
margin: 0;
|
|
130
|
+
padding: 0;
|
|
131
|
+
box-sizing: border-box;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
body {
|
|
135
|
+
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', sans-serif;
|
|
136
|
+
background: var(--bg-app);
|
|
137
|
+
color: var(--text-primary);
|
|
138
|
+
height: 100vh;
|
|
139
|
+
overflow: hidden;
|
|
140
|
+
transition: background-color 0.3s ease, color 0.3s ease;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
#root {
|
|
144
|
+
width: 100%;
|
|
145
|
+
height: 100%;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
::-webkit-scrollbar {
|
|
150
|
+
display: none;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
.modal-overlay {
|
|
154
|
+
position: fixed;
|
|
155
|
+
top: 0;
|
|
156
|
+
left: 0;
|
|
157
|
+
right: 0;
|
|
158
|
+
bottom: 0;
|
|
159
|
+
background-color: rgba(0, 0, 0, 0.7);
|
|
160
|
+
display: flex;
|
|
161
|
+
justify-content: center;
|
|
162
|
+
align-items: center;
|
|
163
|
+
z-index: 1000;
|
|
164
|
+
backdrop-filter: blur(4px);
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
.modal-content {
|
|
168
|
+
background: var(--bg-panel);
|
|
169
|
+
border: 1px solid var(--border-subtle);
|
|
170
|
+
border-radius: 16px;
|
|
171
|
+
width: 90%;
|
|
172
|
+
max-width: 500px;
|
|
173
|
+
overflow: hidden;
|
|
174
|
+
animation: modal-slide-up 0.3s ease-out;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
@keyframes modal-slide-up {
|
|
178
|
+
from {
|
|
179
|
+
opacity: 0;
|
|
180
|
+
transform: translateY(20px);
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
to {
|
|
184
|
+
opacity: 1;
|
|
185
|
+
transform: translateY(0);
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
.modal-header {
|
|
190
|
+
display: flex;
|
|
191
|
+
justify-content: space-between;
|
|
192
|
+
align-items: center;
|
|
193
|
+
padding: 1.5rem;
|
|
194
|
+
border-bottom: 1px solid var(--border-subtle);
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
.modal-header h2 {
|
|
198
|
+
font-size: 1.25rem;
|
|
199
|
+
font-weight: 600;
|
|
200
|
+
color: var(--text-primary);
|
|
201
|
+
margin: 0;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
.close-btn {
|
|
205
|
+
background: transparent;
|
|
206
|
+
border: none;
|
|
207
|
+
color: var(--text-muted);
|
|
208
|
+
cursor: pointer;
|
|
209
|
+
padding: 0.25rem;
|
|
210
|
+
border-radius: 4px;
|
|
211
|
+
transition: color 0.2s, background 0.2s;
|
|
212
|
+
display: flex;
|
|
213
|
+
align-items: center;
|
|
214
|
+
justify-content: center;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
.close-btn:hover {
|
|
218
|
+
color: var(--text-primary);
|
|
219
|
+
background: var(--overlay-light);
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
.modal-body {
|
|
223
|
+
padding: 1.5rem;
|
|
224
|
+
color: var(--text-secondary);
|
|
225
|
+
line-height: 1.6;
|
|
226
|
+
}
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
<?xml version="1.0" ?>
|
|
2
|
+
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="100" height="100" viewBox="0 0 100 100">
|
|
3
|
+
<rect width="100" height="100" fill="black"/>
|
|
4
|
+
<path d="M10 40 C 20 20, 40 20, 50 40 S 80 60, 90 40" fill="white"/>
|
|
5
|
+
<path d="M10 60 C 20 40, 40 40, 50 60 S 80 80, 90 60" fill="white"/>
|
|
6
|
+
</svg>
|
|
Binary file
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
<?xml version="1.0" ?>
|
|
2
|
+
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="400" height="400" viewBox="0 0 100 100">
|
|
3
|
+
<path d="M10 40 C 20 20, 40 20, 50 40 S 80 60, 90 40" fill="white"/>
|
|
4
|
+
<path d="M10 60 C 20 40, 40 40, 50 60 S 80 80, 90 60" fill="white"/>
|
|
5
|
+
</svg>
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
<?xml version="1.0" ?>
|
|
2
|
+
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="100" height="100" viewBox="0 0 100 100">
|
|
3
|
+
<path d="M10 40 C 20 20, 40 20, 50 40 S 80 60, 90 40" fill="black"/>
|
|
4
|
+
<path d="M10 60 C 20 40, 40 40, 50 60 S 80 80, 90 60" fill="black"/>
|
|
5
|
+
</svg>
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
<?xml version="1.0" ?>
|
|
2
|
+
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="100" height="100" viewBox="0 0 100 100">
|
|
3
|
+
<path d="M10 40 C 20 20, 40 20, 50 40 S 80 60, 90 40" fill="white"/>
|
|
4
|
+
<path d="M10 60 C 20 40, 40 40, 50 60 S 80 80, 90 60" fill="white"/>
|
|
5
|
+
</svg>
|
|
Binary file
|
|
Binary file
|
package/src/web/build.ts
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { build } from 'bun';
|
|
2
|
+
import { join } from 'path';
|
|
3
|
+
|
|
4
|
+
const result = await build({
|
|
5
|
+
entrypoints: [join(__dirname, 'app.tsx')],
|
|
6
|
+
outdir: join(__dirname, 'dist'),
|
|
7
|
+
target: 'browser',
|
|
8
|
+
format: 'esm',
|
|
9
|
+
minify: false,
|
|
10
|
+
splitting: false,
|
|
11
|
+
sourcemap: 'none',
|
|
12
|
+
naming: {
|
|
13
|
+
entry: 'app.js',
|
|
14
|
+
},
|
|
15
|
+
external: [],
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
if (!result.success) {
|
|
19
|
+
console.error('Build failed');
|
|
20
|
+
process.exit(1);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
console.log('Build completed successfully');
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
/** @jsxImportSource react */
|
|
2
|
+
import React, { useState, useEffect, useRef } from 'react';
|
|
3
|
+
import { ApprovalRequest } from '../../utils/approvalBridge';
|
|
4
|
+
|
|
5
|
+
interface ApprovalPanelProps {
|
|
6
|
+
request: ApprovalRequest;
|
|
7
|
+
onRespond: (approved: boolean, customResponse?: string) => void;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export function ApprovalPanel({ request, onRespond }: ApprovalPanelProps) {
|
|
11
|
+
const [customText, setCustomText] = useState('');
|
|
12
|
+
const inputRef = useRef<HTMLInputElement>(null);
|
|
13
|
+
const [selectedIndex, setSelectedIndex] = useState(0);
|
|
14
|
+
|
|
15
|
+
const titleMatch = request.preview.title.match(/^(.+?)\s*\((.+)\)$/);
|
|
16
|
+
const toolName = titleMatch ? titleMatch[1] : request.preview.title;
|
|
17
|
+
const toolInfo = titleMatch ? titleMatch[2] : null;
|
|
18
|
+
|
|
19
|
+
useEffect(() => {
|
|
20
|
+
setCustomText('');
|
|
21
|
+
setSelectedIndex(0);
|
|
22
|
+
if (inputRef.current) inputRef.current.focus();
|
|
23
|
+
}, [request.id]);
|
|
24
|
+
|
|
25
|
+
const handleKeyDown = (e: React.KeyboardEvent) => {
|
|
26
|
+
if (e.key === 'ArrowUp') {
|
|
27
|
+
e.preventDefault();
|
|
28
|
+
setSelectedIndex(prev => (prev === 0 ? 1 : 0));
|
|
29
|
+
} else if (e.key === 'ArrowDown') {
|
|
30
|
+
e.preventDefault();
|
|
31
|
+
setSelectedIndex(prev => (prev === 1 ? 0 : 1));
|
|
32
|
+
} else if (e.key === 'Enter') {
|
|
33
|
+
e.preventDefault();
|
|
34
|
+
if (customText.trim()) {
|
|
35
|
+
onRespond(false, customText);
|
|
36
|
+
} else {
|
|
37
|
+
if (selectedIndex === 0) onRespond(true);
|
|
38
|
+
else onRespond(false);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
const handleSubmitCustom = (e: React.FormEvent) => {
|
|
44
|
+
e.preventDefault();
|
|
45
|
+
onRespond(false, customText);
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
const renderDiffLine = (line: string, index: number) => {
|
|
49
|
+
const match = line.match(/^([+-])\s*(\d+)\s*\|?\s*(.*)$/);
|
|
50
|
+
if (match) {
|
|
51
|
+
const [, prefix, lineNum, content] = match;
|
|
52
|
+
const isAdded = prefix === '+';
|
|
53
|
+
const isRemoved = prefix === '-';
|
|
54
|
+
const bgClass = isAdded ? 'diff-added' : isRemoved ? 'diff-removed' : '';
|
|
55
|
+
|
|
56
|
+
return (
|
|
57
|
+
<div key={index} className={`diff-line ${bgClass}`}>
|
|
58
|
+
<span className="diff-linenum">{prefix}{lineNum}</span>
|
|
59
|
+
<span className="diff-content">{content}</span>
|
|
60
|
+
</div>
|
|
61
|
+
);
|
|
62
|
+
}
|
|
63
|
+
return <div key={index} className="diff-line">{line}</div>;
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
return (
|
|
67
|
+
<div className="panel approval-panel">
|
|
68
|
+
<div className="panel-header">
|
|
69
|
+
<strong>{toolName}</strong>
|
|
70
|
+
{toolInfo && <span className="text-muted"> ({toolInfo})</span>}
|
|
71
|
+
</div>
|
|
72
|
+
<div className="panel-content">
|
|
73
|
+
<div className="diff-preview">
|
|
74
|
+
{request.preview.content.split('\n').map((line, i) => renderDiffLine(line, i))}
|
|
75
|
+
</div>
|
|
76
|
+
|
|
77
|
+
<div className="approval-options">
|
|
78
|
+
<div
|
|
79
|
+
className={`approval-option ${selectedIndex === 0 ? 'selected' : ''}`}
|
|
80
|
+
onClick={() => onRespond(true)}
|
|
81
|
+
>
|
|
82
|
+
Yes
|
|
83
|
+
</div>
|
|
84
|
+
<div
|
|
85
|
+
className={`approval-option ${selectedIndex === 1 ? 'selected' : ''}`}
|
|
86
|
+
onClick={() => onRespond(false)}
|
|
87
|
+
>
|
|
88
|
+
No
|
|
89
|
+
</div>
|
|
90
|
+
</div>
|
|
91
|
+
|
|
92
|
+
<div className="custom-input-container">
|
|
93
|
+
<form onSubmit={handleSubmitCustom}>
|
|
94
|
+
<input
|
|
95
|
+
ref={inputRef}
|
|
96
|
+
type="text"
|
|
97
|
+
value={customText}
|
|
98
|
+
onChange={(e) => setCustomText(e.target.value)}
|
|
99
|
+
onKeyDown={handleKeyDown}
|
|
100
|
+
placeholder="> Tell Mosaic what to do instead..."
|
|
101
|
+
className="panel-input"
|
|
102
|
+
/>
|
|
103
|
+
</form>
|
|
104
|
+
</div>
|
|
105
|
+
</div>
|
|
106
|
+
<style>{`
|
|
107
|
+
.panel {
|
|
108
|
+
background: var(--bg-panel);
|
|
109
|
+
border: 1px solid var(--border-subtle);
|
|
110
|
+
border-radius: 8px;
|
|
111
|
+
margin: 1rem 0;
|
|
112
|
+
padding: 1rem;
|
|
113
|
+
}
|
|
114
|
+
.panel-header {
|
|
115
|
+
margin-bottom: 1rem;
|
|
116
|
+
color: var(--text-primary);
|
|
117
|
+
}
|
|
118
|
+
.text-muted {
|
|
119
|
+
color: var(--text-muted);
|
|
120
|
+
}
|
|
121
|
+
.diff-preview {
|
|
122
|
+
font-family: 'Geist Mono', monospace;
|
|
123
|
+
font-size: 0.9em;
|
|
124
|
+
background: var(--bg-code);
|
|
125
|
+
border-radius: 4px;
|
|
126
|
+
padding: 0.5rem;
|
|
127
|
+
margin-bottom: 1rem;
|
|
128
|
+
overflow-x: auto;
|
|
129
|
+
white-space: pre;
|
|
130
|
+
max-height: 300px;
|
|
131
|
+
overflow-y: auto;
|
|
132
|
+
}
|
|
133
|
+
.diff-line {
|
|
134
|
+
display: flex;
|
|
135
|
+
min-width: fit-content;
|
|
136
|
+
}
|
|
137
|
+
.diff-added {
|
|
138
|
+
background: rgba(5, 150, 105, 0.1);
|
|
139
|
+
}
|
|
140
|
+
.diff-removed {
|
|
141
|
+
background: rgba(220, 38, 38, 0.1);
|
|
142
|
+
}
|
|
143
|
+
.diff-linenum {
|
|
144
|
+
width: 3.5rem;
|
|
145
|
+
color: var(--text-muted);
|
|
146
|
+
flex-shrink: 0;
|
|
147
|
+
user-select: none;
|
|
148
|
+
}
|
|
149
|
+
.diff-content {
|
|
150
|
+
color: var(--text-primary);
|
|
151
|
+
}
|
|
152
|
+
.approval-options {
|
|
153
|
+
display: flex;
|
|
154
|
+
gap: 1rem;
|
|
155
|
+
margin-bottom: 1rem;
|
|
156
|
+
}
|
|
157
|
+
.approval-option {
|
|
158
|
+
padding: 0.5rem 1rem;
|
|
159
|
+
border: 1px solid var(--border-subtle);
|
|
160
|
+
border-radius: 4px;
|
|
161
|
+
cursor: pointer;
|
|
162
|
+
transition: all 0.2s;
|
|
163
|
+
min-width: 60px;
|
|
164
|
+
text-align: center;
|
|
165
|
+
}
|
|
166
|
+
.approval-option:hover {
|
|
167
|
+
background: var(--overlay-light);
|
|
168
|
+
}
|
|
169
|
+
.approval-option.selected {
|
|
170
|
+
background: var(--overlay-medium);
|
|
171
|
+
border-color: var(--accent-color);
|
|
172
|
+
color: var(--accent-color);
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
.panel-input {
|
|
176
|
+
width: 100%;
|
|
177
|
+
padding: 0.75rem;
|
|
178
|
+
background: var(--bg-app);
|
|
179
|
+
border: 1px solid var(--border-subtle);
|
|
180
|
+
color: var(--text-primary);
|
|
181
|
+
border-radius: 6px;
|
|
182
|
+
font-family: inherit;
|
|
183
|
+
}
|
|
184
|
+
.panel-input:focus {
|
|
185
|
+
outline: none;
|
|
186
|
+
border-color: var(--accent-color);
|
|
187
|
+
}
|
|
188
|
+
`}</style>
|
|
189
|
+
</div>
|
|
190
|
+
);
|
|
191
|
+
}
|