@eserstack/noskills-web 0.0.0-stage → 5.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +13 -0
- package/README.md +247 -2
- package/dist/auth.d.ts +50 -0
- package/dist/auth.js +107 -0
- package/dist/mod.d.ts +13 -0
- package/dist/mod.js +11 -0
- package/dist/request-context.d.ts +35 -0
- package/dist/request-context.js +19 -0
- package/dist/routes/api.d.ts +45 -0
- package/dist/routes/api.js +167 -0
- package/dist/routes/pages.d.ts +20 -0
- package/dist/routes/pages.js +80 -0
- package/dist/routes/sse.d.ts +15 -0
- package/dist/routes/sse.js +61 -0
- package/dist/routes/static.d.ts +10 -0
- package/dist/routes/static.js +52 -0
- package/dist/server.d.ts +53 -0
- package/dist/server.js +228 -0
- package/dist/static/client.js +257 -0
- package/dist/static/icons/icon.svg +12 -0
- package/dist/static/manifest.json +17 -0
- package/dist/static/mux-remote.js +192 -0
- package/dist/static/mux-render.js +224 -0
- package/dist/static/style.css +391 -0
- package/dist/static/sw-register.js +31 -0
- package/dist/static/sw.js +109 -0
- package/dist/templates/components.d.ts +17 -0
- package/dist/templates/components.js +89 -0
- package/dist/templates/dashboard.d.ts +8 -0
- package/dist/templates/dashboard.js +28 -0
- package/dist/templates/escape.d.ts +8 -0
- package/dist/templates/escape.js +14 -0
- package/dist/templates/layout.d.ts +12 -0
- package/dist/templates/layout.js +83 -0
- package/dist/templates/spec-detail.d.ts +7 -0
- package/dist/templates/spec-detail.js +83 -0
- package/dist/terminal/mux-host.d.ts +65 -0
- package/dist/terminal/mux-host.js +166 -0
- package/dist/terminal/ws-bridge.d.ts +9 -0
- package/dist/terminal/ws-bridge.js +26 -0
- package/package.json +32 -3
|
@@ -0,0 +1,391 @@
|
|
|
1
|
+
/* noskills web — dark terminal aesthetic */
|
|
2
|
+
|
|
3
|
+
:root {
|
|
4
|
+
--bg: #0d1117;
|
|
5
|
+
--bg-surface: #161b22;
|
|
6
|
+
--bg-hover: #1c2128;
|
|
7
|
+
--border: #30363d;
|
|
8
|
+
--text: #e6edf3;
|
|
9
|
+
--text-dim: #7d8590;
|
|
10
|
+
--accent: #58a6ff;
|
|
11
|
+
--green: #3fb950;
|
|
12
|
+
--yellow: #d29922;
|
|
13
|
+
--red: #f85149;
|
|
14
|
+
--cyan: #39d2c0;
|
|
15
|
+
--font-mono: "SF Mono", "Cascadia Code", "Fira Code", monospace;
|
|
16
|
+
--font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
* {
|
|
20
|
+
margin: 0;
|
|
21
|
+
padding: 0;
|
|
22
|
+
box-sizing: border-box;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
body {
|
|
26
|
+
font-family: var(--font-sans);
|
|
27
|
+
background: var(--bg);
|
|
28
|
+
color: var(--text);
|
|
29
|
+
min-height: 100vh;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/* Top bar */
|
|
33
|
+
.top-bar {
|
|
34
|
+
display: flex;
|
|
35
|
+
align-items: center;
|
|
36
|
+
justify-content: space-between;
|
|
37
|
+
padding: 0.5rem 1rem;
|
|
38
|
+
background: var(--bg-surface);
|
|
39
|
+
border-bottom: 1px solid var(--border);
|
|
40
|
+
height: 2.5rem;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
.logo {
|
|
44
|
+
font-family: var(--font-mono);
|
|
45
|
+
font-weight: 700;
|
|
46
|
+
font-size: 0.875rem;
|
|
47
|
+
color: var(--accent);
|
|
48
|
+
text-decoration: none;
|
|
49
|
+
letter-spacing: 0.05em;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
.user-info {
|
|
53
|
+
color: var(--text-dim);
|
|
54
|
+
font-size: 0.75rem;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/* Dashboard layout */
|
|
58
|
+
.dashboard {
|
|
59
|
+
display: grid;
|
|
60
|
+
grid-template-columns: 260px 1fr;
|
|
61
|
+
height: calc(100vh - 2.5rem);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/* Sidebar */
|
|
65
|
+
.sidebar {
|
|
66
|
+
background: var(--bg-surface);
|
|
67
|
+
border-right: 1px solid var(--border);
|
|
68
|
+
overflow-y: auto;
|
|
69
|
+
padding: 0.75rem 0;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
.sidebar h2 {
|
|
73
|
+
font-size: 0.6875rem;
|
|
74
|
+
text-transform: uppercase;
|
|
75
|
+
letter-spacing: 0.1em;
|
|
76
|
+
color: var(--text-dim);
|
|
77
|
+
padding: 0 0.75rem;
|
|
78
|
+
margin-bottom: 0.5rem;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
.spec-item {
|
|
82
|
+
display: flex;
|
|
83
|
+
align-items: center;
|
|
84
|
+
gap: 0.5rem;
|
|
85
|
+
padding: 0.5rem 0.75rem;
|
|
86
|
+
text-decoration: none;
|
|
87
|
+
color: var(--text);
|
|
88
|
+
font-size: 0.8125rem;
|
|
89
|
+
border-left: 2px solid transparent;
|
|
90
|
+
transition: background 0.1s;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
.spec-item:hover {
|
|
94
|
+
background: var(--bg-hover);
|
|
95
|
+
}
|
|
96
|
+
.spec-item.active {
|
|
97
|
+
border-left-color: var(--accent);
|
|
98
|
+
background: var(--bg-hover);
|
|
99
|
+
}
|
|
100
|
+
.spec-name {
|
|
101
|
+
flex: 1;
|
|
102
|
+
overflow: hidden;
|
|
103
|
+
text-overflow: ellipsis;
|
|
104
|
+
white-space: nowrap;
|
|
105
|
+
}
|
|
106
|
+
.task-progress {
|
|
107
|
+
color: var(--text-dim);
|
|
108
|
+
font-size: 0.75rem;
|
|
109
|
+
font-family: var(--font-mono);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
.phase-badge {
|
|
113
|
+
display: inline-block;
|
|
114
|
+
padding: 0.125rem 0.375rem;
|
|
115
|
+
border-radius: 3px;
|
|
116
|
+
font-size: 0.625rem;
|
|
117
|
+
font-weight: 600;
|
|
118
|
+
color: #fff;
|
|
119
|
+
text-transform: uppercase;
|
|
120
|
+
letter-spacing: 0.05em;
|
|
121
|
+
font-family: var(--font-mono);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
.empty-state {
|
|
125
|
+
padding: 1rem 0.75rem;
|
|
126
|
+
color: var(--text-dim);
|
|
127
|
+
font-size: 0.8125rem;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/* Pending section */
|
|
131
|
+
.pending-section {
|
|
132
|
+
padding: 0.75rem;
|
|
133
|
+
border-top: 1px solid var(--border);
|
|
134
|
+
margin-top: 0.5rem;
|
|
135
|
+
}
|
|
136
|
+
.pending-section h3 {
|
|
137
|
+
font-size: 0.6875rem;
|
|
138
|
+
text-transform: uppercase;
|
|
139
|
+
letter-spacing: 0.1em;
|
|
140
|
+
color: var(--text-dim);
|
|
141
|
+
margin-bottom: 0.5rem;
|
|
142
|
+
}
|
|
143
|
+
.mention-item {
|
|
144
|
+
padding: 0.5rem 0;
|
|
145
|
+
border-bottom: 1px solid var(--border);
|
|
146
|
+
font-size: 0.8125rem;
|
|
147
|
+
}
|
|
148
|
+
.mention-from {
|
|
149
|
+
color: var(--accent);
|
|
150
|
+
font-weight: 500;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
/* Main area */
|
|
154
|
+
.main-area {
|
|
155
|
+
display: flex;
|
|
156
|
+
flex-direction: column;
|
|
157
|
+
overflow: hidden;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
/* Tab bar */
|
|
161
|
+
.tab-bar {
|
|
162
|
+
display: flex;
|
|
163
|
+
align-items: center;
|
|
164
|
+
background: var(--bg-surface);
|
|
165
|
+
border-bottom: 1px solid var(--border);
|
|
166
|
+
overflow-x: auto;
|
|
167
|
+
min-height: 2.25rem;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
.tab {
|
|
171
|
+
display: flex;
|
|
172
|
+
align-items: center;
|
|
173
|
+
gap: 0.375rem;
|
|
174
|
+
padding-right: 0.75rem;
|
|
175
|
+
color: var(--text-dim);
|
|
176
|
+
font-size: 0.75rem;
|
|
177
|
+
font-family: var(--font-mono);
|
|
178
|
+
white-space: nowrap;
|
|
179
|
+
border-bottom: 2px solid transparent;
|
|
180
|
+
transition:
|
|
181
|
+
color 0.1s,
|
|
182
|
+
border-color 0.1s;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
.tab:hover {
|
|
186
|
+
color: var(--text);
|
|
187
|
+
}
|
|
188
|
+
.tab.active {
|
|
189
|
+
color: var(--text);
|
|
190
|
+
border-bottom-color: var(--accent);
|
|
191
|
+
}
|
|
192
|
+
.tab-select,
|
|
193
|
+
.tab-close {
|
|
194
|
+
background: transparent;
|
|
195
|
+
border: none;
|
|
196
|
+
color: inherit;
|
|
197
|
+
font: inherit;
|
|
198
|
+
cursor: pointer;
|
|
199
|
+
}
|
|
200
|
+
.tab-select {
|
|
201
|
+
padding: 0.375rem 0 0.375rem 0.75rem;
|
|
202
|
+
}
|
|
203
|
+
.tab-close {
|
|
204
|
+
padding: 0;
|
|
205
|
+
font-size: 0.875rem;
|
|
206
|
+
opacity: 0.5;
|
|
207
|
+
}
|
|
208
|
+
.tab-close:hover,
|
|
209
|
+
.tab-close:focus-visible {
|
|
210
|
+
opacity: 1;
|
|
211
|
+
color: var(--red);
|
|
212
|
+
}
|
|
213
|
+
.tab-select:focus-visible,
|
|
214
|
+
.tab-close:focus-visible,
|
|
215
|
+
.tab-add:focus-visible {
|
|
216
|
+
outline: 2px solid var(--accent);
|
|
217
|
+
outline-offset: -2px;
|
|
218
|
+
}
|
|
219
|
+
.tab-add {
|
|
220
|
+
background: transparent;
|
|
221
|
+
border: none;
|
|
222
|
+
color: var(--text-dim);
|
|
223
|
+
font-size: 1rem;
|
|
224
|
+
cursor: pointer;
|
|
225
|
+
padding: 0.375rem 0.75rem;
|
|
226
|
+
}
|
|
227
|
+
.tab-add:hover {
|
|
228
|
+
color: var(--accent);
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
/* Terminal */
|
|
232
|
+
.terminal-container {
|
|
233
|
+
flex: 1;
|
|
234
|
+
position: relative; /* mux panes are absolutely positioned within */
|
|
235
|
+
background: #000;
|
|
236
|
+
overflow: hidden;
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
/* A single mux pane: an xterm.js instance positioned from scene geometry. */
|
|
240
|
+
.mux-pane {
|
|
241
|
+
background: #000;
|
|
242
|
+
border: 1px solid var(--border);
|
|
243
|
+
overflow: hidden;
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
.mux-pane.focused {
|
|
247
|
+
border-color: var(--accent, #58a6ff);
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
.mux-pane.exited {
|
|
251
|
+
opacity: 0.6;
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
.terminal-placeholder {
|
|
255
|
+
display: flex;
|
|
256
|
+
align-items: center;
|
|
257
|
+
justify-content: center;
|
|
258
|
+
height: 100%;
|
|
259
|
+
color: var(--text-dim);
|
|
260
|
+
font-family: var(--font-mono);
|
|
261
|
+
font-size: 0.875rem;
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
/* Spec detail */
|
|
265
|
+
.spec-detail {
|
|
266
|
+
max-width: 900px;
|
|
267
|
+
margin: 0 auto;
|
|
268
|
+
padding: 2rem;
|
|
269
|
+
}
|
|
270
|
+
.spec-header {
|
|
271
|
+
margin-bottom: 2rem;
|
|
272
|
+
}
|
|
273
|
+
.back-link {
|
|
274
|
+
color: var(--accent);
|
|
275
|
+
text-decoration: none;
|
|
276
|
+
font-size: 0.8125rem;
|
|
277
|
+
}
|
|
278
|
+
.back-link:hover {
|
|
279
|
+
text-decoration: underline;
|
|
280
|
+
}
|
|
281
|
+
.spec-header h1 {
|
|
282
|
+
margin-top: 0.5rem;
|
|
283
|
+
display: flex;
|
|
284
|
+
align-items: center;
|
|
285
|
+
gap: 0.75rem;
|
|
286
|
+
}
|
|
287
|
+
.spec-description {
|
|
288
|
+
color: var(--text-dim);
|
|
289
|
+
margin-top: 0.5rem;
|
|
290
|
+
}
|
|
291
|
+
.roadmap {
|
|
292
|
+
font-family: var(--font-mono);
|
|
293
|
+
font-size: 0.75rem;
|
|
294
|
+
color: var(--text-dim);
|
|
295
|
+
margin-top: 0.75rem;
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
/* CTA buttons */
|
|
299
|
+
.cta-bar {
|
|
300
|
+
display: flex;
|
|
301
|
+
gap: 0.5rem;
|
|
302
|
+
margin-top: 1rem;
|
|
303
|
+
flex-wrap: wrap;
|
|
304
|
+
}
|
|
305
|
+
.cta-btn {
|
|
306
|
+
background: var(--accent);
|
|
307
|
+
color: #fff;
|
|
308
|
+
border: none;
|
|
309
|
+
padding: 0.5rem 1rem;
|
|
310
|
+
border-radius: 4px;
|
|
311
|
+
font-size: 0.8125rem;
|
|
312
|
+
font-weight: 500;
|
|
313
|
+
cursor: pointer;
|
|
314
|
+
transition: opacity 0.15s;
|
|
315
|
+
}
|
|
316
|
+
.cta-btn:hover {
|
|
317
|
+
opacity: 0.85;
|
|
318
|
+
}
|
|
319
|
+
.cta-btn.small {
|
|
320
|
+
padding: 0.25rem 0.5rem;
|
|
321
|
+
font-size: 0.75rem;
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
/* Tasks */
|
|
325
|
+
.tasks-section {
|
|
326
|
+
margin-top: 1.5rem;
|
|
327
|
+
}
|
|
328
|
+
.tasks-section h3 {
|
|
329
|
+
font-size: 0.875rem;
|
|
330
|
+
margin-bottom: 0.75rem;
|
|
331
|
+
}
|
|
332
|
+
.task-list {
|
|
333
|
+
list-style: none;
|
|
334
|
+
}
|
|
335
|
+
.task-list li {
|
|
336
|
+
display: flex;
|
|
337
|
+
align-items: flex-start;
|
|
338
|
+
gap: 0.5rem;
|
|
339
|
+
padding: 0.375rem 0;
|
|
340
|
+
border-bottom: 1px solid var(--border);
|
|
341
|
+
font-size: 0.8125rem;
|
|
342
|
+
}
|
|
343
|
+
.task-list li.done {
|
|
344
|
+
color: var(--text-dim);
|
|
345
|
+
text-decoration: line-through;
|
|
346
|
+
}
|
|
347
|
+
.file-hints {
|
|
348
|
+
color: var(--text-dim);
|
|
349
|
+
font-size: 0.75rem;
|
|
350
|
+
}
|
|
351
|
+
.file-hints code {
|
|
352
|
+
background: var(--bg-surface);
|
|
353
|
+
padding: 0.125rem 0.25rem;
|
|
354
|
+
border-radius: 2px;
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
/* Questions */
|
|
358
|
+
.questions-section {
|
|
359
|
+
margin-top: 1.5rem;
|
|
360
|
+
}
|
|
361
|
+
.questions-section h3 {
|
|
362
|
+
font-size: 0.875rem;
|
|
363
|
+
margin-bottom: 0.75rem;
|
|
364
|
+
}
|
|
365
|
+
.question-item {
|
|
366
|
+
padding: 0.75rem 0;
|
|
367
|
+
border-bottom: 1px solid var(--border);
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
/* Spec content */
|
|
371
|
+
.spec-content {
|
|
372
|
+
margin-top: 1.5rem;
|
|
373
|
+
}
|
|
374
|
+
.spec-content pre {
|
|
375
|
+
background: var(--bg-surface);
|
|
376
|
+
padding: 1rem;
|
|
377
|
+
border-radius: 6px;
|
|
378
|
+
overflow-x: auto;
|
|
379
|
+
font-family: var(--font-mono);
|
|
380
|
+
font-size: 0.8125rem;
|
|
381
|
+
line-height: 1.5;
|
|
382
|
+
color: var(--text);
|
|
383
|
+
border: 1px solid var(--border);
|
|
384
|
+
white-space: pre-wrap;
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
.contributors {
|
|
388
|
+
margin-top: 1rem;
|
|
389
|
+
color: var(--text-dim);
|
|
390
|
+
font-size: 0.75rem;
|
|
391
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
// Copyright 2023-present Eser Ozvataf and other contributors. All rights reserved. Apache-2.0 license.
|
|
2
|
+
|
|
3
|
+
// Registers the service worker. Kept out of the page so the CSP needs no
|
|
4
|
+
// inline scripts. A page served over HTTPS (the noskills-server daemon) also
|
|
5
|
+
// hands the worker the server's certificate fingerprint from
|
|
6
|
+
// /api/cert-fingerprint, which WebTransport pins. A plain-HTTP page (the
|
|
7
|
+
// local `noskills web` dashboard) has no certificate to pin, and its server
|
|
8
|
+
// has no such route.
|
|
9
|
+
if ("serviceWorker" in navigator) {
|
|
10
|
+
navigator.serviceWorker
|
|
11
|
+
.register("/sw.js")
|
|
12
|
+
.then((reg) => {
|
|
13
|
+
if (location.protocol !== "https:") return;
|
|
14
|
+
fetch("/api/cert-fingerprint")
|
|
15
|
+
.then((r) => r.json())
|
|
16
|
+
.then((d) => {
|
|
17
|
+
if (
|
|
18
|
+
typeof d.fingerprint === "string" &&
|
|
19
|
+
d.fingerprint !== "" &&
|
|
20
|
+
reg.active !== null
|
|
21
|
+
) {
|
|
22
|
+
reg.active.postMessage({
|
|
23
|
+
type: "store_cert_fingerprint",
|
|
24
|
+
fingerprint: d.fingerprint,
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
})
|
|
28
|
+
.catch(() => {});
|
|
29
|
+
})
|
|
30
|
+
.catch(() => {});
|
|
31
|
+
}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
// Copyright 2023-present Eser Ozvataf and other contributors. All rights reserved. Apache-2.0 license.
|
|
2
|
+
// noskills-server service worker
|
|
3
|
+
// Handles Web Push notifications and notificationclick → PWA focus.
|
|
4
|
+
// Served at /sw.js (root scope) by the daemon's HTTP/3 server.
|
|
5
|
+
|
|
6
|
+
// ── Install & activate ────────────────────────────────────────────────────────
|
|
7
|
+
|
|
8
|
+
self.addEventListener("install", () => {
|
|
9
|
+
// Activate immediately — no waiting for existing tabs to close.
|
|
10
|
+
// This ensures cert fingerprint refreshes reach the SW promptly.
|
|
11
|
+
self.skipWaiting();
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
self.addEventListener("activate", (event) => {
|
|
15
|
+
event.waitUntil(self.clients.claim());
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
// ── Push event ────────────────────────────────────────────────────────────────
|
|
19
|
+
|
|
20
|
+
self.addEventListener("push", (event) => {
|
|
21
|
+
if (event.data === null) return;
|
|
22
|
+
|
|
23
|
+
let payload;
|
|
24
|
+
try {
|
|
25
|
+
payload = event.data.json();
|
|
26
|
+
} catch {
|
|
27
|
+
payload = { kind: "unknown", summary: event.data.text() };
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const title = "noskills";
|
|
31
|
+
const kind = payload.kind ?? "notification";
|
|
32
|
+
const body = payload.summary ?? "Activity in your session";
|
|
33
|
+
const sessionId = payload.sessionId ?? "";
|
|
34
|
+
const tag = sessionId !== "" ? `${sessionId}:${kind}` : kind;
|
|
35
|
+
|
|
36
|
+
const options = {
|
|
37
|
+
body,
|
|
38
|
+
tag, // collapses duplicate notifications for same session+kind
|
|
39
|
+
renotify: false, // don't vibrate if same tag is already shown
|
|
40
|
+
requireInteraction: kind === "permission_request", // stay visible for permission requests
|
|
41
|
+
data: { sessionId, projectSlug: payload.projectSlug ?? "", kind, url: "/" },
|
|
42
|
+
icon: "/static/icons/icon.svg",
|
|
43
|
+
badge: "/static/icons/icon.svg",
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
event.waitUntil(self.registration.showNotification(title, options));
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
// ── Notification click ────────────────────────────────────────────────────────
|
|
50
|
+
|
|
51
|
+
self.addEventListener("notificationclick", (event) => {
|
|
52
|
+
event.notification.close();
|
|
53
|
+
|
|
54
|
+
const { url, sessionId } = event.notification.data ?? {};
|
|
55
|
+
const targetUrl =
|
|
56
|
+
typeof sessionId === "string" && sessionId !== ""
|
|
57
|
+
? `/?session=${encodeURIComponent(sessionId)}`
|
|
58
|
+
: (url ?? "/");
|
|
59
|
+
|
|
60
|
+
event.waitUntil(
|
|
61
|
+
self.clients
|
|
62
|
+
.matchAll({ type: "window", includeUncontrolled: true })
|
|
63
|
+
.then((clientList) => {
|
|
64
|
+
// Focus an existing PWA window if one is open.
|
|
65
|
+
for (const client of clientList) {
|
|
66
|
+
if ("focus" in client) {
|
|
67
|
+
client.navigate(targetUrl);
|
|
68
|
+
return client.focus();
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
// Otherwise open a new window.
|
|
72
|
+
if (typeof self.clients.openWindow === "function") {
|
|
73
|
+
return self.clients.openWindow(targetUrl);
|
|
74
|
+
}
|
|
75
|
+
}),
|
|
76
|
+
);
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
// ── Cert fingerprint storage ──────────────────────────────────────────────────
|
|
80
|
+
// Stores the daemon's TLS fingerprint so WebTransport clients can use
|
|
81
|
+
// serverCertificateHashes without relying on OS CA trust (required for iOS PWA).
|
|
82
|
+
|
|
83
|
+
const DB_NAME = "noskills-cert";
|
|
84
|
+
const DB_STORE = "fingerprints";
|
|
85
|
+
|
|
86
|
+
function openCertDB() {
|
|
87
|
+
return new Promise((resolve, reject) => {
|
|
88
|
+
const req = self.indexedDB.open(DB_NAME, 1);
|
|
89
|
+
req.onupgradeneeded = () => req.result.createObjectStore(DB_STORE);
|
|
90
|
+
req.onsuccess = () => resolve(req.result);
|
|
91
|
+
req.onerror = () => reject(req.error);
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
// storeCertFingerprint is called by the main page after fetching /api/cert-fingerprint.
|
|
96
|
+
// Exposed as a message handler so the page can update the stored fingerprint.
|
|
97
|
+
self.addEventListener("message", (event) => {
|
|
98
|
+
if (event.data?.type !== "store_cert_fingerprint") return;
|
|
99
|
+
|
|
100
|
+
const { fingerprint } = event.data;
|
|
101
|
+
if (typeof fingerprint !== "string" || fingerprint === "") return;
|
|
102
|
+
|
|
103
|
+
openCertDB()
|
|
104
|
+
.then((db) => {
|
|
105
|
+
const tx = db.transaction(DB_STORE, "readwrite");
|
|
106
|
+
tx.objectStore(DB_STORE).put(fingerprint, "active");
|
|
107
|
+
})
|
|
108
|
+
.catch(() => {});
|
|
109
|
+
});
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reusable HTML fragments.
|
|
3
|
+
*
|
|
4
|
+
* @module
|
|
5
|
+
*/
|
|
6
|
+
import type * as dashboard from "@eserstack/noskills/dashboard";
|
|
7
|
+
export declare const phaseBadge: (phase: string) => string;
|
|
8
|
+
export declare const specListItem: (spec: dashboard.SpecSummary, isActive: boolean) => string;
|
|
9
|
+
export type TabInfo = {
|
|
10
|
+
readonly id: string;
|
|
11
|
+
readonly specName: string | null;
|
|
12
|
+
readonly phase: string | null;
|
|
13
|
+
};
|
|
14
|
+
export declare const tabBar: (tabs: readonly TabInfo[], activeTabId: string | null) => string;
|
|
15
|
+
export declare const ctaButton: (label: string, specName: string, action: string, extraData?: Record<string, string>) => string;
|
|
16
|
+
export declare const pendingMentions: (mentions: readonly dashboard.Mention[]) => string;
|
|
17
|
+
export declare const terminalContainer: () => string;
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
// Copyright 2023-present Eser Ozvataf and other contributors. All rights reserved. Apache-2.0 license.
|
|
2
|
+
import * as escape from "./escape.js";
|
|
3
|
+
// =============================================================================
|
|
4
|
+
// Phase badge
|
|
5
|
+
// =============================================================================
|
|
6
|
+
const PHASE_COLORS = {
|
|
7
|
+
IDLE: "#6b7280",
|
|
8
|
+
DISCOVERY: "#06b6d4",
|
|
9
|
+
DISCOVERY_REFINEMENT: "#06b6d4",
|
|
10
|
+
SPEC_PROPOSAL: "#eab308",
|
|
11
|
+
SPEC_APPROVED: "#eab308",
|
|
12
|
+
EXECUTING: "#22c55e",
|
|
13
|
+
BLOCKED: "#ef4444",
|
|
14
|
+
COMPLETED: "#6b7280",
|
|
15
|
+
};
|
|
16
|
+
export const phaseBadge = (phase) => {
|
|
17
|
+
const color = PHASE_COLORS[phase] ?? "#6b7280";
|
|
18
|
+
const label = phase
|
|
19
|
+
.replace("DISCOVERY_REFINEMENT", "REFINEMENT")
|
|
20
|
+
.replace("SPEC_PROPOSAL", "PROPOSAL")
|
|
21
|
+
.replace("SPEC_APPROVED", "APPROVED");
|
|
22
|
+
return `<span class="phase-badge" style="background:${color}">${escape.escHtml(label)}</span>`;
|
|
23
|
+
};
|
|
24
|
+
// =============================================================================
|
|
25
|
+
// Spec list item
|
|
26
|
+
// =============================================================================
|
|
27
|
+
export const specListItem = (spec, isActive) => {
|
|
28
|
+
const active = isActive ? " active" : "";
|
|
29
|
+
const done = spec.tasks.filter((t) => t.done).length;
|
|
30
|
+
const total = spec.tasks.length;
|
|
31
|
+
const progress = total > 0 ? `<span class="task-progress">${done}/${total}</span>` : "";
|
|
32
|
+
return `<a href="/spec/${escape.escHtml(spec.slug)}" class="spec-item${active}">
|
|
33
|
+
<span class="spec-name">${escape.escHtml(spec.name)}</span>
|
|
34
|
+
${phaseBadge(spec.phase)}
|
|
35
|
+
${progress}
|
|
36
|
+
</a>`;
|
|
37
|
+
};
|
|
38
|
+
export const tabBar = (tabs, activeTabId) => {
|
|
39
|
+
const items = tabs
|
|
40
|
+
.map((t, i) => {
|
|
41
|
+
const active = t.id === activeTabId ? " active" : "";
|
|
42
|
+
const phase = t.phase !== null && t.phase !== ""
|
|
43
|
+
? ` (${escape.escHtml(t.phase)})`
|
|
44
|
+
: "";
|
|
45
|
+
const label = t.specName !== null ? `${escape.escHtml(t.specName)}${phase}` : "IDLE";
|
|
46
|
+
// Two sibling buttons per tab, so each is reachable by keyboard: a
|
|
47
|
+
// button inside a button is invalid HTML and cannot take focus.
|
|
48
|
+
// data-index drives the client's gotoTab so SSR tabs are switchable before
|
|
49
|
+
// the /mux socket re-renders the bar (mux-render.js renders the same
|
|
50
|
+
// markup).
|
|
51
|
+
return `<div class="tab${active}" data-tab="${escape.escHtml(t.id)}"><button type="button" class="tab-select" data-index="${i}">${label}</button><button type="button" class="tab-close" data-close="${escape.escHtml(t.id)}" aria-label="Close ${label}">×</button></div>`;
|
|
52
|
+
})
|
|
53
|
+
.join("");
|
|
54
|
+
return `<div class="tab-bar">${items}<button type="button" class="tab-add" id="add-tab" aria-label="New tab">+</button></div>`;
|
|
55
|
+
};
|
|
56
|
+
// =============================================================================
|
|
57
|
+
// CTA buttons
|
|
58
|
+
// =============================================================================
|
|
59
|
+
export const ctaButton = (label, specName, action, extraData) => {
|
|
60
|
+
const dataAttrs = extraData === undefined
|
|
61
|
+
? ""
|
|
62
|
+
: Object.entries(extraData)
|
|
63
|
+
.map(([k, v]) => `data-${k}="${escape.escHtml(v)}"`)
|
|
64
|
+
.join(" ");
|
|
65
|
+
return `<button class="cta-btn" data-spec="${escape.escHtml(specName)}" data-action="${escape.escHtml(action)}" ${dataAttrs}>${escape.escHtml(label)}</button>`;
|
|
66
|
+
};
|
|
67
|
+
// =============================================================================
|
|
68
|
+
// Pending items
|
|
69
|
+
// =============================================================================
|
|
70
|
+
export const pendingMentions = (mentions) => {
|
|
71
|
+
if (mentions.length === 0)
|
|
72
|
+
return "";
|
|
73
|
+
const items = mentions
|
|
74
|
+
.map((m) => `<div class="mention-item">
|
|
75
|
+
<span class="mention-from">${escape.escHtml(m.from)}</span> asks about <strong>${escape.escHtml(m.spec)}</strong>:
|
|
76
|
+
<p>${escape.escHtml(m.question)}</p>
|
|
77
|
+
<button class="cta-btn small" data-spec="${escape.escHtml(m.spec)}" data-action="reply" data-mention-id="${escape.escHtml(m.id)}">Reply</button>
|
|
78
|
+
</div>`)
|
|
79
|
+
.join("");
|
|
80
|
+
return `<div class="pending-section"><h3>Pending Mentions (${mentions.length})</h3>${items}</div>`;
|
|
81
|
+
};
|
|
82
|
+
// =============================================================================
|
|
83
|
+
// Terminal container
|
|
84
|
+
// =============================================================================
|
|
85
|
+
// The mux frontend (client.js) fills this container with one xterm.js per pane,
|
|
86
|
+
// positioned from the scene geometry it receives over the /mux WebSocket. It is
|
|
87
|
+
// always rendered (even with no tabs) so the browser has a mount point; an empty
|
|
88
|
+
// multiplexer just shows a black canvas plus the "+" in the tab bar.
|
|
89
|
+
export const terminalContainer = () => `<div class="terminal-container" id="terminal-container"></div>`;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Dashboard view — main page mirroring TUI layout.
|
|
3
|
+
*
|
|
4
|
+
* @module
|
|
5
|
+
*/
|
|
6
|
+
import type * as dashboard from "@eserstack/noskills/dashboard";
|
|
7
|
+
import * as components from "./components.ts";
|
|
8
|
+
export declare const renderDashboard: (state: dashboard.DashboardState, tabs: readonly components.TabInfo[], activeTabId: string | null, token?: string) => string;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
// Copyright 2023-present Eser Ozvataf and other contributors. All rights reserved. Apache-2.0 license.
|
|
2
|
+
import * as layout from "./layout.js";
|
|
3
|
+
import * as components from "./components.js";
|
|
4
|
+
export const renderDashboard = (state, tabs, activeTabId, token) => {
|
|
5
|
+
// Spec list
|
|
6
|
+
const specItems = state.specs.length > 0
|
|
7
|
+
? state.specs
|
|
8
|
+
.map((s) => components.specListItem(s, state.activeSpec?.slug === s.slug))
|
|
9
|
+
.join("")
|
|
10
|
+
: '<div class="empty-state">No specs yet. Create one from the terminal.</div>';
|
|
11
|
+
// Pending items
|
|
12
|
+
const pending = components.pendingMentions(state.pendingMentions);
|
|
13
|
+
const body = `
|
|
14
|
+
<div class="dashboard">
|
|
15
|
+
<aside class="sidebar">
|
|
16
|
+
<div class="spec-list">
|
|
17
|
+
<h2>Specs</h2>
|
|
18
|
+
${specItems}
|
|
19
|
+
</div>
|
|
20
|
+
${pending}
|
|
21
|
+
</aside>
|
|
22
|
+
<main class="main-area">
|
|
23
|
+
${components.tabBar(tabs, activeTabId)}
|
|
24
|
+
${components.terminalContainer()}
|
|
25
|
+
</main>
|
|
26
|
+
</div>`;
|
|
27
|
+
return layout.layout("noskills", body, { includeTerminal: true, token });
|
|
28
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared HTML escaping for the server-rendered templates.
|
|
3
|
+
*
|
|
4
|
+
* @module
|
|
5
|
+
*/
|
|
6
|
+
/** Escape the five HTML-significant characters for safe interpolation into
|
|
7
|
+
* element text and double-quoted attribute values. */
|
|
8
|
+
export declare const escHtml: (s: string) => string;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
// Copyright 2023-present Eser Ozvataf and other contributors. All rights reserved. Apache-2.0 license.
|
|
2
|
+
/**
|
|
3
|
+
* Shared HTML escaping for the server-rendered templates.
|
|
4
|
+
*
|
|
5
|
+
* @module
|
|
6
|
+
*/
|
|
7
|
+
/** Escape the five HTML-significant characters for safe interpolation into
|
|
8
|
+
* element text and double-quoted attribute values. */
|
|
9
|
+
export const escHtml = (s) => s
|
|
10
|
+
.replace(/&/g, "&")
|
|
11
|
+
.replace(/</g, "<")
|
|
12
|
+
.replace(/>/g, ">")
|
|
13
|
+
.replace(/"/g, """)
|
|
14
|
+
.replace(/'/g, "'");
|