@clagentic/console 1.0.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (221) hide show
  1. package/CREDITS.md +3 -0
  2. package/LICENSE +21 -0
  3. package/README.md +250 -0
  4. package/bin/cli.js +2812 -0
  5. package/lib/agents-favorites.js +164 -0
  6. package/lib/agents.js +282 -0
  7. package/lib/ask-user-mcp-server.js +120 -0
  8. package/lib/browser-mcp-server.js +484 -0
  9. package/lib/build-user-env.js +63 -0
  10. package/lib/certs/fullchain.pem +47 -0
  11. package/lib/certs/privkey.pem +5 -0
  12. package/lib/cli-sessions.js +265 -0
  13. package/lib/codex-defaults.js +18 -0
  14. package/lib/config.js +332 -0
  15. package/lib/crisis-safety.js +60 -0
  16. package/lib/daemon-projects.js +164 -0
  17. package/lib/daemon.js +1602 -0
  18. package/lib/dm.js +128 -0
  19. package/lib/ipc.js +125 -0
  20. package/lib/ipv4-only.js +39 -0
  21. package/lib/mcp-local.js +385 -0
  22. package/lib/notes.js +141 -0
  23. package/lib/os-users.js +529 -0
  24. package/lib/pages.js +1325 -0
  25. package/lib/project-connection.js +302 -0
  26. package/lib/project-external-trigger.js +236 -0
  27. package/lib/project-file-watch.js +120 -0
  28. package/lib/project-filesystem.js +528 -0
  29. package/lib/project-http.js +753 -0
  30. package/lib/project-image.js +95 -0
  31. package/lib/project-knowledge.js +88 -0
  32. package/lib/project-loop.js +1304 -0
  33. package/lib/project-mcp.js +374 -0
  34. package/lib/project-memory.js +39 -0
  35. package/lib/project-notifications.js +262 -0
  36. package/lib/project-sessions.js +1581 -0
  37. package/lib/project-user-mention.js +193 -0
  38. package/lib/project-user-message.js +628 -0
  39. package/lib/project.js +1303 -0
  40. package/lib/public/app.js +1031 -0
  41. package/lib/public/apple-touch-icon.png +0 -0
  42. package/lib/public/claude-code-avatar.png +0 -0
  43. package/lib/public/codex-avatar.png +0 -0
  44. package/lib/public/console-icon.png +0 -0
  45. package/lib/public/css/admin.css +736 -0
  46. package/lib/public/css/agent-picker.css +119 -0
  47. package/lib/public/css/base.css +235 -0
  48. package/lib/public/css/channel-layout.css +441 -0
  49. package/lib/public/css/command-palette.css +559 -0
  50. package/lib/public/css/debate.css +1609 -0
  51. package/lib/public/css/diff.css +139 -0
  52. package/lib/public/css/filebrowser.css +1976 -0
  53. package/lib/public/css/highlight.css +144 -0
  54. package/lib/public/css/home-hub.css +545 -0
  55. package/lib/public/css/icon-strip.css +1856 -0
  56. package/lib/public/css/input.css +1349 -0
  57. package/lib/public/css/loop.css +1248 -0
  58. package/lib/public/css/mention.css +317 -0
  59. package/lib/public/css/menus.css +857 -0
  60. package/lib/public/css/messages.css +1833 -0
  61. package/lib/public/css/mobile-nav.css +1332 -0
  62. package/lib/public/css/notifications-center.css +296 -0
  63. package/lib/public/css/overlays.css +1273 -0
  64. package/lib/public/css/playbook.css +264 -0
  65. package/lib/public/css/profile.css +397 -0
  66. package/lib/public/css/rewind.css +671 -0
  67. package/lib/public/css/scheduler-modal.css +1495 -0
  68. package/lib/public/css/scheduler.css +1420 -0
  69. package/lib/public/css/server-settings.css +909 -0
  70. package/lib/public/css/session-search.css +159 -0
  71. package/lib/public/css/sidebar.css +2012 -0
  72. package/lib/public/css/skills.css +789 -0
  73. package/lib/public/css/sticky-notes.css +854 -0
  74. package/lib/public/css/stt.css +155 -0
  75. package/lib/public/css/title-bar.css +674 -0
  76. package/lib/public/css/tooltip.css +67 -0
  77. package/lib/public/css/user-settings.css +702 -0
  78. package/lib/public/emoji-data.json +1 -0
  79. package/lib/public/favicon-banded-32.png +0 -0
  80. package/lib/public/favicon-banded.png +0 -0
  81. package/lib/public/favicon-dark.svg +32 -0
  82. package/lib/public/favicon.svg +32 -0
  83. package/lib/public/icon-192.png +0 -0
  84. package/lib/public/icon-512.png +0 -0
  85. package/lib/public/icon-banded-76.png +0 -0
  86. package/lib/public/icon-banded-96.png +0 -0
  87. package/lib/public/icon-mono.svg +25 -0
  88. package/lib/public/icons/email/gmail.svg +7 -0
  89. package/lib/public/icons/email/outlook.svg +35 -0
  90. package/lib/public/icons/email/yahoo.svg +1 -0
  91. package/lib/public/index.html +1946 -0
  92. package/lib/public/manifest.json +27 -0
  93. package/lib/public/markdown-worker.js +43 -0
  94. package/lib/public/marked.min.js +6 -0
  95. package/lib/public/modules/admin.js +954 -0
  96. package/lib/public/modules/agent-picker.js +429 -0
  97. package/lib/public/modules/app-connection.js +216 -0
  98. package/lib/public/modules/app-cursors.js +492 -0
  99. package/lib/public/modules/app-dm.js +265 -0
  100. package/lib/public/modules/app-favicon.js +231 -0
  101. package/lib/public/modules/app-header.js +242 -0
  102. package/lib/public/modules/app-home-hub.js +432 -0
  103. package/lib/public/modules/app-loop-ui.js +691 -0
  104. package/lib/public/modules/app-loop-wizard.js +439 -0
  105. package/lib/public/modules/app-messages.js +1415 -0
  106. package/lib/public/modules/app-misc.js +463 -0
  107. package/lib/public/modules/app-notifications.js +651 -0
  108. package/lib/public/modules/app-panels.js +1061 -0
  109. package/lib/public/modules/app-projects.js +875 -0
  110. package/lib/public/modules/app-rate-limit.js +529 -0
  111. package/lib/public/modules/app-rendering.js +739 -0
  112. package/lib/public/modules/app-skills-install.js +285 -0
  113. package/lib/public/modules/avatar.js +36 -0
  114. package/lib/public/modules/command-palette.js +491 -0
  115. package/lib/public/modules/console-logo.js +162 -0
  116. package/lib/public/modules/context-sources.js +365 -0
  117. package/lib/public/modules/diff.js +412 -0
  118. package/lib/public/modules/dom-refs.js +21 -0
  119. package/lib/public/modules/emoji-picker.js +222 -0
  120. package/lib/public/modules/events.js +21 -0
  121. package/lib/public/modules/filebrowser.js +1966 -0
  122. package/lib/public/modules/fileicons.js +172 -0
  123. package/lib/public/modules/icons.js +80 -0
  124. package/lib/public/modules/input.js +1102 -0
  125. package/lib/public/modules/longpress.js +74 -0
  126. package/lib/public/modules/markdown.js +486 -0
  127. package/lib/public/modules/mcp-ui.js +295 -0
  128. package/lib/public/modules/mention.js +1093 -0
  129. package/lib/public/modules/notifications.js +613 -0
  130. package/lib/public/modules/playbook.js +578 -0
  131. package/lib/public/modules/profile.js +594 -0
  132. package/lib/public/modules/project-settings.js +849 -0
  133. package/lib/public/modules/project-switcher.js +375 -0
  134. package/lib/public/modules/qrcode.js +87 -0
  135. package/lib/public/modules/rewind.js +381 -0
  136. package/lib/public/modules/scheduler-config.js +1611 -0
  137. package/lib/public/modules/scheduler-history.js +131 -0
  138. package/lib/public/modules/scheduler.js +1689 -0
  139. package/lib/public/modules/server-settings.js +842 -0
  140. package/lib/public/modules/session-search.js +456 -0
  141. package/lib/public/modules/settings-defaults.js +253 -0
  142. package/lib/public/modules/sidebar-mobile.js +1425 -0
  143. package/lib/public/modules/sidebar-projects.js +2022 -0
  144. package/lib/public/modules/sidebar-sessions.js +1548 -0
  145. package/lib/public/modules/sidebar-users.js +449 -0
  146. package/lib/public/modules/sidebar.js +348 -0
  147. package/lib/public/modules/skills.js +793 -0
  148. package/lib/public/modules/state.js +3 -0
  149. package/lib/public/modules/sticky-notes.js +1221 -0
  150. package/lib/public/modules/store.js +34 -0
  151. package/lib/public/modules/stt.js +266 -0
  152. package/lib/public/modules/terminal.js +987 -0
  153. package/lib/public/modules/theme.js +812 -0
  154. package/lib/public/modules/tool-palette.js +562 -0
  155. package/lib/public/modules/tools.js +2285 -0
  156. package/lib/public/modules/tooltip.js +150 -0
  157. package/lib/public/modules/user-settings.js +544 -0
  158. package/lib/public/modules/utils.js +56 -0
  159. package/lib/public/modules/ws-ref.js +26 -0
  160. package/lib/public/style.css +34 -0
  161. package/lib/public/sw.js +159 -0
  162. package/lib/push.js +149 -0
  163. package/lib/scheduler.js +471 -0
  164. package/lib/sdk-bridge.js +1792 -0
  165. package/lib/sdk-message-processor.js +740 -0
  166. package/lib/sdk-message-queue.js +42 -0
  167. package/lib/sdk-skill-discovery.js +131 -0
  168. package/lib/sdk-worker.js +677 -0
  169. package/lib/server-admin.js +712 -0
  170. package/lib/server-auth.js +737 -0
  171. package/lib/server-dm.js +170 -0
  172. package/lib/server-palette.js +104 -0
  173. package/lib/server-settings.js +553 -0
  174. package/lib/server-skills.js +280 -0
  175. package/lib/server.js +1390 -0
  176. package/lib/session-search.js +693 -0
  177. package/lib/sessions.js +946 -0
  178. package/lib/smtp.js +221 -0
  179. package/lib/terminal-manager.js +219 -0
  180. package/lib/terminal.js +39 -0
  181. package/lib/themes/ayu-light.json +9 -0
  182. package/lib/themes/catppuccin-latte.json +9 -0
  183. package/lib/themes/catppuccin-mocha.json +9 -0
  184. package/lib/themes/clagentic-dark.json +10 -0
  185. package/lib/themes/clagentic-light.json +10 -0
  186. package/lib/themes/dracula.json +9 -0
  187. package/lib/themes/everforest-light.json +9 -0
  188. package/lib/themes/everforest.json +9 -0
  189. package/lib/themes/github-light.json +9 -0
  190. package/lib/themes/gruvbox-dark.json +9 -0
  191. package/lib/themes/gruvbox-light.json +9 -0
  192. package/lib/themes/monokai.json +9 -0
  193. package/lib/themes/nord-light.json +9 -0
  194. package/lib/themes/nord.json +9 -0
  195. package/lib/themes/one-dark.json +9 -0
  196. package/lib/themes/one-light.json +9 -0
  197. package/lib/themes/rose-pine-dawn.json +9 -0
  198. package/lib/themes/rose-pine.json +9 -0
  199. package/lib/themes/solarized-dark.json +9 -0
  200. package/lib/themes/solarized-light.json +9 -0
  201. package/lib/themes/tokyo-night-light.json +9 -0
  202. package/lib/themes/tokyo-night.json +9 -0
  203. package/lib/updater.js +124 -0
  204. package/lib/user-presence.js +92 -0
  205. package/lib/users-auth.js +146 -0
  206. package/lib/users-permissions.js +118 -0
  207. package/lib/users-preferences.js +254 -0
  208. package/lib/users.js +465 -0
  209. package/lib/utils.js +64 -0
  210. package/lib/worktree.js +134 -0
  211. package/lib/ws-schema.js +464 -0
  212. package/lib/yoke/adapters/claude-worker.js +759 -0
  213. package/lib/yoke/adapters/claude.js +1599 -0
  214. package/lib/yoke/adapters/codex.js +1559 -0
  215. package/lib/yoke/codex-app-server.js +352 -0
  216. package/lib/yoke/index.js +319 -0
  217. package/lib/yoke/instructions.js +61 -0
  218. package/lib/yoke/interface.js +98 -0
  219. package/lib/yoke/mcp-bridge-server.js +302 -0
  220. package/lib/yoke/package.json +7 -0
  221. package/package.json +72 -0
@@ -0,0 +1,412 @@
1
+ // diff.js - Shared diff module with LCS-based line diffing
2
+ // Produces unified and split diff views similar to GitHub
3
+
4
+ /**
5
+ * Compute LCS (Longest Common Subsequence) table for two arrays of lines.
6
+ * Returns a 2D table where table[i][j] = length of LCS of a[0..i-1] and b[0..j-1].
7
+ */
8
+ function lcsTable(a, b) {
9
+ var m = a.length;
10
+ var n = b.length;
11
+ // Use flat array for performance
12
+ var t = new Array((m + 1) * (n + 1));
13
+ var w = n + 1;
14
+ for (var i = 0; i <= m; i++) t[i * w] = 0;
15
+ for (var j = 0; j <= n; j++) t[j] = 0;
16
+ for (var i2 = 1; i2 <= m; i2++) {
17
+ for (var j2 = 1; j2 <= n; j2++) {
18
+ if (a[i2 - 1] === b[j2 - 1]) {
19
+ t[i2 * w + j2] = t[(i2 - 1) * w + (j2 - 1)] + 1;
20
+ } else {
21
+ var up = t[(i2 - 1) * w + j2];
22
+ var left = t[i2 * w + (j2 - 1)];
23
+ t[i2 * w + j2] = up > left ? up : left;
24
+ }
25
+ }
26
+ }
27
+ return { data: t, width: w };
28
+ }
29
+
30
+ /**
31
+ * Backtrack LCS table to produce a list of diff operations.
32
+ * Each op: { type: "equal"|"remove"|"add", oldLine, newLine, text }
33
+ */
34
+ function backtrack(a, b, table) {
35
+ var ops = [];
36
+ var t = table.data;
37
+ var w = table.width;
38
+ var i = a.length;
39
+ var j = b.length;
40
+
41
+ while (i > 0 || j > 0) {
42
+ if (i > 0 && j > 0 && a[i - 1] === b[j - 1]) {
43
+ ops.push({ type: "equal", oldLine: i, newLine: j, text: a[i - 1] });
44
+ i--;
45
+ j--;
46
+ } else if (j > 0 && (i === 0 || t[(i) * w + (j - 1)] >= t[(i - 1) * w + j])) {
47
+ ops.push({ type: "add", oldLine: null, newLine: j, text: b[j - 1] });
48
+ j--;
49
+ } else {
50
+ ops.push({ type: "remove", oldLine: i, newLine: null, text: a[i - 1] });
51
+ i--;
52
+ }
53
+ }
54
+
55
+ ops.reverse();
56
+ return ops;
57
+ }
58
+
59
+ /**
60
+ * Compute line-level diff between two strings.
61
+ * Returns array of { type: "equal"|"remove"|"add", oldLine, newLine, text }
62
+ */
63
+ export function diffLines(oldStr, newStr) {
64
+ var a = oldStr ? oldStr.split("\n") : [];
65
+ var b = newStr ? newStr.split("\n") : [];
66
+ var table = lcsTable(a, b);
67
+ return backtrack(a, b, table);
68
+ }
69
+
70
+ /**
71
+ * Highlight all lines of a source string via hljs.
72
+ * Returns an array of HTML strings, one per line.
73
+ * Falls back to escaped text if hljs is unavailable or fails.
74
+ */
75
+ function highlightLines(src, lang) {
76
+ if (!lang || typeof hljs === "undefined" || !src) return null;
77
+ try {
78
+ var result = hljs.highlight(src, { language: lang });
79
+ return result.value.split("\n");
80
+ } catch (e) {
81
+ return null;
82
+ }
83
+ }
84
+
85
+ /**
86
+ * Build a map from line number (1-based) to highlighted HTML.
87
+ * oldMap[lineNum] = html, newMap[lineNum] = html
88
+ */
89
+ function buildHighlightMaps(oldStr, newStr, lang) {
90
+ if (!lang) return null;
91
+ var oldHL = highlightLines(oldStr, lang);
92
+ var newHL = highlightLines(newStr, lang);
93
+ if (!oldHL && !newHL) return null;
94
+ return { oldLines: oldHL, newLines: newHL };
95
+ }
96
+
97
+ /**
98
+ * Set cell content: use highlighted HTML if available, otherwise plain text.
99
+ */
100
+ function setCellContent(td, text, hlLines, lineNum) {
101
+ if (hlLines && lineNum != null && lineNum > 0 && lineNum <= hlLines.length) {
102
+ td.innerHTML = hlLines[lineNum - 1];
103
+ } else {
104
+ td.textContent = text;
105
+ }
106
+ }
107
+
108
+ /**
109
+ * Render a unified diff view (single column, +/- markers).
110
+ * Optional lang parameter enables syntax highlighting.
111
+ * Returns a DOM element.
112
+ */
113
+ export function renderUnifiedDiff(oldStr, newStr, lang) {
114
+ var ops = diffLines(oldStr, newStr);
115
+ var hl = buildHighlightMaps(oldStr, newStr, lang);
116
+ var container = document.createElement("div");
117
+ container.className = "diff-unified" + (lang === "markdown" ? " diff-wrap" : "");
118
+
119
+ var table = document.createElement("table");
120
+ table.className = "diff-table";
121
+
122
+ for (var i = 0; i < ops.length; i++) {
123
+ var op = ops[i];
124
+ var tr = document.createElement("tr");
125
+ tr.className = "diff-row diff-row-" + op.type;
126
+
127
+ // Old line number
128
+ var tdOldLn = document.createElement("td");
129
+ tdOldLn.className = "diff-ln diff-ln-old";
130
+ tdOldLn.textContent = op.oldLine != null ? op.oldLine : "";
131
+
132
+ // New line number
133
+ var tdNewLn = document.createElement("td");
134
+ tdNewLn.className = "diff-ln diff-ln-new";
135
+ tdNewLn.textContent = op.newLine != null ? op.newLine : "";
136
+
137
+ // Marker
138
+ var tdMarker = document.createElement("td");
139
+ tdMarker.className = "diff-marker";
140
+ if (op.type === "remove") tdMarker.textContent = "-";
141
+ else if (op.type === "add") tdMarker.textContent = "+";
142
+ else tdMarker.textContent = " ";
143
+
144
+ // Code (with optional highlighting)
145
+ var tdCode = document.createElement("td");
146
+ tdCode.className = "diff-code";
147
+ if (hl) {
148
+ var hlSrc = (op.type === "add") ? hl.newLines : hl.oldLines;
149
+ var ln = (op.type === "add") ? op.newLine : op.oldLine;
150
+ setCellContent(tdCode, op.text, hlSrc, ln);
151
+ } else {
152
+ tdCode.textContent = op.text;
153
+ }
154
+
155
+ tr.appendChild(tdOldLn);
156
+ tr.appendChild(tdNewLn);
157
+ tr.appendChild(tdMarker);
158
+ tr.appendChild(tdCode);
159
+ table.appendChild(tr);
160
+ }
161
+
162
+ container.appendChild(table);
163
+ return container;
164
+ }
165
+
166
+ /**
167
+ * Render a split (side-by-side) diff view like GitHub.
168
+ * Optional lang parameter enables syntax highlighting.
169
+ * Returns a DOM element.
170
+ */
171
+ export function renderSplitDiff(oldStr, newStr, lang) {
172
+ var ops = diffLines(oldStr, newStr);
173
+ var hl = buildHighlightMaps(oldStr, newStr, lang);
174
+ var container = document.createElement("div");
175
+ container.className = "diff-split-view" + (lang === "markdown" ? " diff-wrap" : "");
176
+
177
+ var table = document.createElement("table");
178
+ table.className = "diff-table diff-table-split";
179
+
180
+ // Group consecutive removes and adds into change blocks
181
+ var i = 0;
182
+ while (i < ops.length) {
183
+ var op = ops[i];
184
+
185
+ if (op.type === "equal") {
186
+ var tr = document.createElement("tr");
187
+ tr.className = "diff-row diff-row-equal";
188
+ appendSplitCells(tr, op.oldLine, op.text, op.newLine, op.text, hl);
189
+ table.appendChild(tr);
190
+ i++;
191
+ } else {
192
+ // Collect consecutive removes and adds
193
+ var removes = [];
194
+ var adds = [];
195
+ while (i < ops.length && ops[i].type === "remove") {
196
+ removes.push(ops[i]);
197
+ i++;
198
+ }
199
+ while (i < ops.length && ops[i].type === "add") {
200
+ adds.push(ops[i]);
201
+ i++;
202
+ }
203
+
204
+ // Pair them up row by row
205
+ var maxLen = Math.max(removes.length, adds.length);
206
+ for (var k = 0; k < maxLen; k++) {
207
+ var tr2 = document.createElement("tr");
208
+ var rm = k < removes.length ? removes[k] : null;
209
+ var ad = k < adds.length ? adds[k] : null;
210
+
211
+ if (rm && ad) {
212
+ tr2.className = "diff-row diff-row-change";
213
+ } else if (rm) {
214
+ tr2.className = "diff-row diff-row-remove";
215
+ } else {
216
+ tr2.className = "diff-row diff-row-add";
217
+ }
218
+
219
+ appendSplitCells(
220
+ tr2,
221
+ rm ? rm.oldLine : null,
222
+ rm ? rm.text : "",
223
+ ad ? ad.newLine : null,
224
+ ad ? ad.text : "",
225
+ hl
226
+ );
227
+ table.appendChild(tr2);
228
+ }
229
+ }
230
+ }
231
+
232
+ container.appendChild(table);
233
+ return container;
234
+ }
235
+
236
+ /**
237
+ * Render a pre-formatted patch/diff text (with @@, +, - markers) using table layout.
238
+ * Parses hunk headers for line numbers. Optional lang for syntax highlighting.
239
+ * Returns a DOM element.
240
+ */
241
+ /**
242
+ * Reconstruct old and new source text from a unified patch string.
243
+ * Skips file headers, "diff --git" lines, index lines, and hunk headers.
244
+ * Returns { oldStr, newStr }.
245
+ */
246
+ export function reconstructPatchSources(text) {
247
+ var lines = text.split("\n");
248
+ var oldSrc = [];
249
+ var newSrc = [];
250
+ for (var p = 0; p < lines.length; p++) {
251
+ var pl = lines[p];
252
+ if (pl.startsWith("---") || pl.startsWith("+++")) continue;
253
+ if (pl.startsWith("diff ") || pl.startsWith("index ")) continue;
254
+ if (pl.startsWith("@@")) continue;
255
+ if (pl.startsWith("-")) {
256
+ oldSrc.push(pl.substring(1));
257
+ } else if (pl.startsWith("+")) {
258
+ newSrc.push(pl.substring(1));
259
+ } else if (pl.startsWith(" ")) {
260
+ oldSrc.push(pl.substring(1));
261
+ newSrc.push(pl.substring(1));
262
+ }
263
+ }
264
+ return { oldStr: oldSrc.join("\n"), newStr: newSrc.join("\n") };
265
+ }
266
+
267
+ export function renderPatchDiff(text, lang) {
268
+ var lines = text.split("\n");
269
+
270
+ // Reconstruct old and new source for highlighting
271
+ var sources = reconstructPatchSources(text);
272
+ var oldHL = highlightLines(sources.oldStr, lang);
273
+ var newHL = highlightLines(sources.newStr, lang);
274
+ var oldHLIdx = 0;
275
+ var newHLIdx = 0;
276
+
277
+ var container = document.createElement("div");
278
+ container.className = "diff-unified" + (lang === "markdown" ? " diff-wrap" : "");
279
+
280
+ var table = document.createElement("table");
281
+ table.className = "diff-table";
282
+
283
+ var oldLn = 0;
284
+ var newLn = 0;
285
+
286
+ for (var i = 0; i < lines.length; i++) {
287
+ var line = lines[i];
288
+
289
+ // Skip file headers
290
+ if (line.startsWith("---") || line.startsWith("+++")) continue;
291
+ // Skip "diff --git" lines
292
+ if (line.startsWith("diff ")) continue;
293
+ // Skip index lines
294
+ if (line.startsWith("index ")) continue;
295
+
296
+ // Hunk header: @@ -oldStart,oldLen +newStart,newLen @@
297
+ var hunkMatch = line.match(/^@@\s+-(\d+)(?:,\d+)?\s+\+(\d+)(?:,\d+)?\s+@@/);
298
+ if (hunkMatch) {
299
+ oldLn = parseInt(hunkMatch[1], 10);
300
+ newLn = parseInt(hunkMatch[2], 10);
301
+
302
+ // Render hunk separator row
303
+ var tr = document.createElement("tr");
304
+ tr.className = "diff-row diff-row-hunk";
305
+ var tdLn1 = document.createElement("td");
306
+ tdLn1.className = "diff-ln";
307
+ var tdLn2 = document.createElement("td");
308
+ tdLn2.className = "diff-ln";
309
+ var tdMarker = document.createElement("td");
310
+ tdMarker.className = "diff-marker";
311
+ var tdCode = document.createElement("td");
312
+ tdCode.className = "diff-code diff-hunk-text";
313
+ tdCode.textContent = line;
314
+ tr.appendChild(tdLn1);
315
+ tr.appendChild(tdLn2);
316
+ tr.appendChild(tdMarker);
317
+ tr.appendChild(tdCode);
318
+ table.appendChild(tr);
319
+ continue;
320
+ }
321
+
322
+ var tr2 = document.createElement("tr");
323
+ var tdOldLn = document.createElement("td");
324
+ tdOldLn.className = "diff-ln diff-ln-old";
325
+ var tdNewLn = document.createElement("td");
326
+ tdNewLn.className = "diff-ln diff-ln-new";
327
+ var tdMark = document.createElement("td");
328
+ tdMark.className = "diff-marker";
329
+ var tdText = document.createElement("td");
330
+ tdText.className = "diff-code";
331
+
332
+ if (line.startsWith("-")) {
333
+ tr2.className = "diff-row diff-row-remove";
334
+ tdOldLn.textContent = oldLn;
335
+ tdMark.textContent = "-";
336
+ if (oldHL && oldHLIdx < oldHL.length) {
337
+ tdText.innerHTML = oldHL[oldHLIdx];
338
+ } else {
339
+ tdText.textContent = line.substring(1);
340
+ }
341
+ oldHLIdx++;
342
+ oldLn++;
343
+ } else if (line.startsWith("+")) {
344
+ tr2.className = "diff-row diff-row-add";
345
+ tdNewLn.textContent = newLn;
346
+ tdMark.textContent = "+";
347
+ if (newHL && newHLIdx < newHL.length) {
348
+ tdText.innerHTML = newHL[newHLIdx];
349
+ } else {
350
+ tdText.textContent = line.substring(1);
351
+ }
352
+ newHLIdx++;
353
+ newLn++;
354
+ } else if (line.startsWith(" ") || line === "") {
355
+ tr2.className = "diff-row diff-row-equal";
356
+ tdOldLn.textContent = oldLn;
357
+ tdNewLn.textContent = newLn;
358
+ tdMark.textContent = " ";
359
+ if (oldHL && oldHLIdx < oldHL.length) {
360
+ tdText.innerHTML = oldHL[oldHLIdx];
361
+ } else {
362
+ tdText.textContent = line.startsWith(" ") ? line.substring(1) : line;
363
+ }
364
+ oldHLIdx++;
365
+ newHLIdx++;
366
+ oldLn++;
367
+ newLn++;
368
+ } else {
369
+ // Unknown line, just render as context
370
+ tr2.className = "diff-row diff-row-equal";
371
+ tdText.textContent = line;
372
+ }
373
+
374
+ tr2.appendChild(tdOldLn);
375
+ tr2.appendChild(tdNewLn);
376
+ tr2.appendChild(tdMark);
377
+ tr2.appendChild(tdText);
378
+ table.appendChild(tr2);
379
+ }
380
+
381
+ container.appendChild(table);
382
+ return container;
383
+ }
384
+
385
+ function appendSplitCells(tr, oldLn, oldText, newLn, newText, hl) {
386
+ // Left side
387
+ var tdOldLn = document.createElement("td");
388
+ tdOldLn.className = "diff-ln";
389
+ tdOldLn.textContent = oldLn != null ? oldLn : "";
390
+
391
+ var tdOldCode = document.createElement("td");
392
+ tdOldCode.className = "diff-code diff-code-old";
393
+ if (oldLn != null) {
394
+ setCellContent(tdOldCode, oldText, hl ? hl.oldLines : null, oldLn);
395
+ }
396
+
397
+ // Right side
398
+ var tdNewLn = document.createElement("td");
399
+ tdNewLn.className = "diff-ln";
400
+ tdNewLn.textContent = newLn != null ? newLn : "";
401
+
402
+ var tdNewCode = document.createElement("td");
403
+ tdNewCode.className = "diff-code diff-code-new";
404
+ if (newLn != null) {
405
+ setCellContent(tdNewCode, newText, hl ? hl.newLines : null, newLn);
406
+ }
407
+
408
+ tr.appendChild(tdOldLn);
409
+ tr.appendChild(tdOldCode);
410
+ tr.appendChild(tdNewLn);
411
+ tr.appendChild(tdNewCode);
412
+ }
@@ -0,0 +1,21 @@
1
+ // dom-refs.js - Shared DOM element references
2
+ // Lazy-cached getElementById lookups for elements used across multiple modules.
3
+ // Same pattern as ws-ref.js: infrastructure singleton, not state.
4
+
5
+ var _cache = {};
6
+
7
+ function ref(id) {
8
+ if (!_cache[id]) _cache[id] = document.getElementById(id);
9
+ return _cache[id];
10
+ }
11
+
12
+ export function getMessagesEl() { return ref("messages"); }
13
+ export function getInputEl() { return ref("input"); }
14
+ export function getSendBtn() { return ref("send-btn"); }
15
+ export function getSessionListEl() { return ref("session-list"); }
16
+
17
+ export function getStatusDot() {
18
+ return document.querySelector("#icon-strip-projects .icon-strip-item.active .icon-strip-status") ||
19
+ document.querySelector("#icon-strip-projects .icon-strip-wt-item.active .icon-strip-status") ||
20
+ document.querySelector("#icon-strip-users .icon-strip-mate.active .icon-strip-status");
21
+ }
@@ -0,0 +1,222 @@
1
+ // emoji-picker.js — Shared emoji picker with search, backed by emoji-data.json
2
+ // Replaces hand-curated EMOJI_CATEGORIES in sidebar-projects.js / project-settings.js
3
+
4
+ import { parseEmojis } from './markdown.js';
5
+
6
+ // Group metadata matching emojibase-data group numbers
7
+ var GROUP_META = [
8
+ { g: 0, icon: "😀", label: "Smileys & Emotion" },
9
+ { g: 3, icon: "🐻", label: "Animals & Nature" },
10
+ { g: 4, icon: "🍔", label: "Food & Drink" },
11
+ { g: 5, icon: "🚗", label: "Travel & Places" },
12
+ { g: 6, icon: "⚽", label: "Activities" },
13
+ { g: 7, icon: "💡", label: "Objects" },
14
+ { g: 8, icon: "❤️", label: "Symbols" },
15
+ { g: 9, icon: "🏁", label: "Flags" },
16
+ ];
17
+
18
+ // Cached data promise — fetched once
19
+ var _dataPromise = null;
20
+ var _emojiData = null; // flat array of {e, l, g, t}
21
+ var _byGroup = null; // Map<groupNum, emoji[]>
22
+
23
+ function loadEmojiData() {
24
+ if (_dataPromise) return _dataPromise;
25
+ _dataPromise = fetch("/emoji-data.json")
26
+ .then(function (r) { return r.json(); })
27
+ .then(function (data) {
28
+ _emojiData = data;
29
+ _byGroup = {};
30
+ for (var i = 0; i < GROUP_META.length; i++) {
31
+ _byGroup[GROUP_META[i].g] = [];
32
+ }
33
+ for (var j = 0; j < data.length; j++) {
34
+ var entry = data[j];
35
+ if (_byGroup[entry.g] !== undefined) {
36
+ _byGroup[entry.g].push(entry.e);
37
+ }
38
+ }
39
+ return data;
40
+ });
41
+ return _dataPromise;
42
+ }
43
+
44
+ // Pre-built search index: flat array of {e, s} where s is the searchable string
45
+ var _searchIndex = null;
46
+ function getSearchIndex() {
47
+ if (_searchIndex) return _searchIndex;
48
+ if (!_emojiData) return null;
49
+ _searchIndex = _emojiData.map(function (entry) {
50
+ var s = entry.l;
51
+ if (entry.t && entry.t.length) s += " " + entry.t.join(" ");
52
+ return { e: entry.e, s: s.toLowerCase() };
53
+ });
54
+ return _searchIndex;
55
+ }
56
+
57
+ function searchEmojis(query) {
58
+ var idx = getSearchIndex();
59
+ if (!idx) return [];
60
+ var q = query.toLowerCase().trim();
61
+ if (!q) return [];
62
+ var results = [];
63
+ for (var i = 0; i < idx.length; i++) {
64
+ if (idx[i].s.indexOf(q) !== -1) {
65
+ results.push(idx[i].e);
66
+ }
67
+ if (results.length >= 80) break;
68
+ }
69
+ return results;
70
+ }
71
+
72
+ /**
73
+ * Build and return an emoji picker element.
74
+ *
75
+ * @param {object} opts
76
+ * onSelect(emoji) — called when user picks an emoji
77
+ * onRemove() — if provided, shows a "Remove" button
78
+ * headerLabel — string shown in header (default "Choose Icon")
79
+ */
80
+ export function buildEmojiPicker(opts) {
81
+ var onSelect = opts.onSelect || function () {};
82
+ var onRemove = opts.onRemove || null;
83
+ var headerLabel = opts.headerLabel || "Choose Icon";
84
+
85
+ var picker = document.createElement("div");
86
+ picker.className = "emoji-picker";
87
+ picker.addEventListener("click", function (e) { e.stopPropagation(); });
88
+
89
+ // Header
90
+ var header = document.createElement("div");
91
+ header.className = "emoji-picker-header";
92
+ header.textContent = headerLabel;
93
+ if (onRemove) {
94
+ var removeBtn = document.createElement("button");
95
+ removeBtn.className = "emoji-picker-remove";
96
+ removeBtn.textContent = "Remove";
97
+ removeBtn.addEventListener("click", function (e) {
98
+ e.stopPropagation();
99
+ onRemove();
100
+ });
101
+ header.appendChild(removeBtn);
102
+ }
103
+ picker.appendChild(header);
104
+
105
+ // Search input
106
+ var searchWrap = document.createElement("div");
107
+ searchWrap.className = "emoji-picker-search-wrap";
108
+ var searchInput = document.createElement("input");
109
+ searchInput.type = "text";
110
+ searchInput.placeholder = "Search emoji…";
111
+ searchInput.className = "emoji-picker-search";
112
+ searchInput.setAttribute("autocomplete", "off");
113
+ searchInput.setAttribute("spellcheck", "false");
114
+ searchWrap.appendChild(searchInput);
115
+ picker.appendChild(searchWrap);
116
+
117
+ // Tab bar (hidden during search)
118
+ var tabBar = document.createElement("div");
119
+ tabBar.className = "emoji-picker-tabs";
120
+ var tabBtns = [];
121
+ picker.appendChild(tabBar);
122
+
123
+ // Scroll + grid
124
+ var scrollArea = document.createElement("div");
125
+ scrollArea.className = "emoji-picker-scroll";
126
+ var grid = document.createElement("div");
127
+ grid.className = "emoji-picker-grid";
128
+ scrollArea.appendChild(grid);
129
+ picker.appendChild(scrollArea);
130
+
131
+ var noResults = document.createElement("div");
132
+ noResults.className = "emoji-picker-no-results";
133
+ noResults.textContent = "No results";
134
+ noResults.style.display = "none";
135
+ scrollArea.appendChild(noResults);
136
+
137
+ var currentCatIdx = 0;
138
+
139
+ function buildGrid(emojis) {
140
+ grid.innerHTML = "";
141
+ noResults.style.display = "none";
142
+ if (!emojis || emojis.length === 0) {
143
+ noResults.style.display = "block";
144
+ return;
145
+ }
146
+ var frag = document.createDocumentFragment();
147
+ for (var i = 0; i < emojis.length; i++) {
148
+ (function (emoji) {
149
+ var btn = document.createElement("button");
150
+ btn.className = "emoji-picker-item";
151
+ btn.textContent = emoji;
152
+ btn.addEventListener("click", function (e) {
153
+ e.stopPropagation();
154
+ onSelect(emoji);
155
+ });
156
+ frag.appendChild(btn);
157
+ })(emojis[i]);
158
+ }
159
+ grid.appendChild(frag);
160
+ parseEmojis(grid);
161
+ scrollArea.scrollTop = 0;
162
+ }
163
+
164
+ function switchCategory(idx) {
165
+ currentCatIdx = idx;
166
+ for (var j = 0; j < tabBtns.length; j++) {
167
+ tabBtns[j].classList.toggle("active", j === idx);
168
+ }
169
+ if (_byGroup) {
170
+ buildGrid(_byGroup[GROUP_META[idx].g] || []);
171
+ }
172
+ }
173
+
174
+ function showSearchResults(query) {
175
+ tabBar.style.display = "none";
176
+ buildGrid(searchEmojis(query));
177
+ }
178
+
179
+ function showCategory() {
180
+ tabBar.style.display = "";
181
+ switchCategory(currentCatIdx);
182
+ }
183
+
184
+ // Debounced search
185
+ var searchTimer = null;
186
+ searchInput.addEventListener("input", function () {
187
+ clearTimeout(searchTimer);
188
+ var q = searchInput.value;
189
+ searchTimer = setTimeout(function () {
190
+ if (q.trim()) {
191
+ showSearchResults(q);
192
+ } else {
193
+ showCategory();
194
+ }
195
+ }, 150);
196
+ });
197
+
198
+ // Load data, then populate tabs + initial grid
199
+ loadEmojiData().then(function () {
200
+ // Build tabs
201
+ for (var t = 0; t < GROUP_META.length; t++) {
202
+ (function (meta, idx) {
203
+ var tab = document.createElement("button");
204
+ tab.className = "emoji-picker-tab" + (idx === 0 ? " active" : "");
205
+ tab.textContent = meta.icon;
206
+ tab.title = meta.label;
207
+ tab.addEventListener("click", function (e) {
208
+ e.stopPropagation();
209
+ searchInput.value = "";
210
+ showCategory();
211
+ switchCategory(idx);
212
+ });
213
+ tabBar.appendChild(tab);
214
+ tabBtns.push(tab);
215
+ })(GROUP_META[t], t);
216
+ }
217
+ parseEmojis(tabBar);
218
+ switchCategory(0);
219
+ });
220
+
221
+ return picker;
222
+ }
@@ -0,0 +1,21 @@
1
+ // EventBus — lightweight pub/sub for module decoupling
2
+ export class EventBus {
3
+ constructor() {
4
+ this._listeners = {};
5
+ }
6
+
7
+ on(event, fn) {
8
+ (this._listeners[event] || (this._listeners[event] = [])).push(fn);
9
+ return () => this.off(event, fn);
10
+ }
11
+
12
+ off(event, fn) {
13
+ var list = this._listeners[event];
14
+ if (list) this._listeners[event] = list.filter(f => f !== fn);
15
+ }
16
+
17
+ emit(event, data) {
18
+ var list = this._listeners[event];
19
+ if (list) list.forEach(fn => fn(data));
20
+ }
21
+ }