@point-seven-studio/jq-deck-server 0.2.2 → 0.2.3
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 +4 -0
- package/dist/index.mjs +57 -12
- package/dist/jq-deck-server.mjs +61 -16
- package/dist/types/page.d.ts +0 -4
- package/dist/types/presence.d.ts +38 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -100,6 +100,10 @@ import { handle, buildTeam, readReports, readConfig, sanitizeReport } from '@poi
|
|
|
100
100
|
- **A repository name is itself information.** That is why a machine must list what it reports.
|
|
101
101
|
- A git remote written with an SSH host alias (`github.com-work:acme/shop`) is sent as written, so that repository will not group with the same one cloned without the alias.
|
|
102
102
|
|
|
103
|
+
## Links to the other tools
|
|
104
|
+
|
|
105
|
+
The team page has a bar at the bottom naming the four local tools. A page served from a server cannot see a viewer's computer, so it does not say whether a tool is running there. Each name opens a short note with the address the tool would be at on the viewer's own machine (`http://127.0.0.1:` and its usual port) and the command that starts it. The page still loads nothing and runs no script.
|
|
106
|
+
|
|
103
107
|
## Related tools
|
|
104
108
|
|
|
105
109
|
- [jq-deck](https://www.npmjs.com/package/@point-seven-studio/jq-deck): all of these on one local page, from one command.
|
package/dist/index.mjs
CHANGED
|
@@ -225,8 +225,53 @@ function readReports(dir, config) {
|
|
|
225
225
|
// src/server.ts
|
|
226
226
|
import { createServer } from "http";
|
|
227
227
|
|
|
228
|
-
// src/
|
|
228
|
+
// src/presence.ts
|
|
229
|
+
var TOOLS = [
|
|
230
|
+
{ id: "deck", name: "JQ Deck", what: "sessions, setup and mail on one page", port: 4316, run: "npx @point-seven-studio/jq-deck" },
|
|
231
|
+
{ id: "agents", name: "JQ Agents", what: "every session, and which wait on a person", port: 4319, run: "npx @point-seven-studio/jq-agents" },
|
|
232
|
+
{ id: "groundcrew", name: "JQ Groundcrew", what: "the setup check for one project", port: 4317, run: "npx @point-seven-studio/jq-groundcrew" },
|
|
233
|
+
{ id: "crosstalk", name: "JQ Crosstalk", what: "the mailbox between sessions", port: 4318, run: "npx @point-seven-studio/jq-crosstalk view" }
|
|
234
|
+
];
|
|
229
235
|
var esc = (s) => String(s ?? "").replace(/[&<>"']/g, (c) => ({ "&": "&", "<": "<", ">": ">", '"': """, "'": "'" })[c]);
|
|
236
|
+
var TOOLBAR_CSS = `
|
|
237
|
+
body{padding-bottom:64px}
|
|
238
|
+
.jqbar{position:fixed;left:0;right:0;bottom:0;z-index:5;display:flex;flex-wrap:wrap;align-items:center;gap:4px 14px;padding:8px 16px;font:13px/1.4 system-ui,sans-serif;background:var(--card,Canvas);color:var(--fg,CanvasText);border-top:1px solid var(--line,GrayText)}
|
|
239
|
+
.jqbar a{color:var(--link,LinkText)}
|
|
240
|
+
.jqbar .here{font-weight:700}
|
|
241
|
+
.jqbar details[open]{order:-1;flex-basis:100%}
|
|
242
|
+
.jqbar summary{cursor:pointer;color:var(--mut,GrayText);list-style:none;display:inline-block;padding:2px 0}
|
|
243
|
+
.jqbar summary::-webkit-details-marker{display:none}
|
|
244
|
+
.jqbar summary::after{content:" \u25B8"}
|
|
245
|
+
.jqbar details[open] summary::after{content:" \u25BE"}
|
|
246
|
+
.jqbar summary small,.jqbar a small{font-size:11px;font-weight:400}
|
|
247
|
+
.jqbar details>div{margin:4px 0 6px;padding:8px 10px;max-width:640px;border:1px solid var(--line,GrayText);border-radius:8px;background:var(--well,Canvas)}
|
|
248
|
+
.jqbar details>div p{margin:0 0 4px}
|
|
249
|
+
.jqbar code{font:12px ui-monospace,Menlo,monospace;word-break:break-all}
|
|
250
|
+
.jqbar a:focus-visible,.jqbar summary:focus-visible{outline:2px solid var(--link,LinkText);outline-offset:2px}
|
|
251
|
+
@media print{.jqbar{display:none}body{padding-bottom:0}}
|
|
252
|
+
`;
|
|
253
|
+
var local = (port) => `http://127.0.0.1:${port}`;
|
|
254
|
+
function toolItem(t, o) {
|
|
255
|
+
if (o.here === t.id) return `<span class="here" aria-current="page">${esc(t.name)}</span>`;
|
|
256
|
+
const start = `<p>To start it: <code>${esc(t.run)}</code></p>`;
|
|
257
|
+
if (o.running === null) {
|
|
258
|
+
return `<details><summary>${esc(t.name)} <small>on your computer</small></summary><div><p>${esc(t.name)} shows ${esc(t.what)}. It runs on your own computer, and this page cannot see whether it is running there.</p><p>If it is, it is at <a href="${local(t.port)}">${local(t.port)}</a>.</p>${start}</div></details>`;
|
|
259
|
+
}
|
|
260
|
+
const port = o.running[t.id];
|
|
261
|
+
if (port !== null) return `<a href="${local(port)}" title="${esc(t.what)}">${esc(t.name)}</a>`;
|
|
262
|
+
return `<details><summary>${esc(t.name)} <small>not running</small></summary><div><p>${esc(t.name)} shows ${esc(t.what)}. It is not running on this machine.</p>${start}<p>Then refresh this page.</p></div></details>`;
|
|
263
|
+
}
|
|
264
|
+
function teamItem(o) {
|
|
265
|
+
if (o.here === "team") return '<span class="here" aria-current="page">Team board</span>';
|
|
266
|
+
if (o.team) return `<a href="${esc(o.team)}" title="every machine on the team, on one page">Team board</a>`;
|
|
267
|
+
return '<details><summary>Team board <small>not set up</small></summary><div><p>A team board shows every machine on a team on one page. This machine has no address for one.</p><p>If your team has one, add a <code>"team"</code> line holding its address to <code>~/.jq/config.json</code>.</p><p>To host one: <code>npx @point-seven-studio/jq-deck-server</code></p></div></details>';
|
|
268
|
+
}
|
|
269
|
+
function toolbar(o) {
|
|
270
|
+
return `<nav class="jqbar" aria-label="JQ tools">${TOOLS.map((t) => toolItem(t, o)).join("")}${teamItem(o)}</nav>`;
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
// src/page.ts
|
|
274
|
+
var esc2 = (s) => String(s ?? "").replace(/[&<>"']/g, (c) => ({ "&": "&", "<": "<", ">": ">", '"': """, "'": "'" })[c]);
|
|
230
275
|
var STYLE = `
|
|
231
276
|
:root{--bg:#f7f6f2;--card:#fff;--fg:#1d1c19;--mut:#6b675e;--line:#dedbd2;--well:#f1efe9;--warn:#a1500a;--ok:#1f6b45;--bad:#a3262b;--link:#1d4f91}
|
|
232
277
|
@media (prefers-color-scheme:dark){:root{--bg:#161512;--card:#1f1e1a;--fg:#ece9e1;--mut:#a09c91;--line:#35332d;--well:#161512;--warn:#e0a25a;--ok:#7ccba0;--bad:#ef8a8e;--link:#8fb8ee}}
|
|
@@ -259,12 +304,12 @@ var minutesSince = (iso, now) => Math.max(0, Math.floor((now - Date.parse(iso))
|
|
|
259
304
|
var clock = (iso) => `${iso.slice(11, 16)} UTC`;
|
|
260
305
|
function row(r, now) {
|
|
261
306
|
const quiet = r.freshness !== "fresh";
|
|
262
|
-
const waiting = quiet ? '<span class="mut">not current</span>' : r.needs_you > 0 ? `<span class="warn">${r.needs_you} waiting${r.waiting_minutes !== null ? `, ${
|
|
307
|
+
const waiting = quiet ? '<span class="mut">not current</span>' : r.needs_you > 0 ? `<span class="warn">${r.needs_you} waiting${r.waiting_minutes !== null ? `, ${esc2(duration(r.waiting_minutes))}` : ""}</span>` : '<span class="mut">none</span>';
|
|
263
308
|
const setup = !r.setup ? '<span class="mut">not checked</span>' : `${r.setup.score}% ${r.setup.fail > 0 ? `<span class="bad">${r.setup.fail} to fix</span>` : r.setup.warn > 0 ? `<span class="warn">${r.setup.warn} to look at</span>` : '<span class="ok">all good</span>'}`;
|
|
264
309
|
const mail = r.unread === null ? '<span class="mut">no inbox</span>' : r.unread === 0 ? '<span class="mut">none unread</span>' : `${r.unread} unread`;
|
|
265
|
-
const asked = (r.questions ?? []).map((q) => `<div class="q"><span class="mut">${
|
|
310
|
+
const asked = (r.questions ?? []).map((q) => `<div class="q"><span class="mut">${esc2(r.who)}'s session asked${q.asked_at ? ` ${esc2(heard(minutesSince(q.asked_at, now)))}` : ""}</span><p>${esc2(q.text)}</p></div>`).join("");
|
|
266
311
|
const askedRow = asked ? `<tr class="asked"><td colspan="6">${asked}</td></tr>` : "";
|
|
267
|
-
return `<tr${quiet ? ' class="quiet"' : ""}><th scope="row">${
|
|
312
|
+
return `<tr${quiet ? ' class="quiet"' : ""}><th scope="row">${esc2(r.who)} <span class="mut">${esc2(r.machine)}</span></th><td data-l="Sessions">${r.sessions} <span class="mut">(${r.live} live)</span></td><td data-l="Waiting on a person">${waiting}</td><td data-l="Setup">${setup}</td><td data-l="Mail">${mail}</td><td data-l="Last heard"><span class="mut">${esc2(heard(r.minutes_ago))}</span></td></tr>${askedRow}`;
|
|
268
313
|
}
|
|
269
314
|
function renderTeam(team, viewerName, version) {
|
|
270
315
|
const now = Date.parse(team.generated_at);
|
|
@@ -272,20 +317,20 @@ function renderTeam(team, viewerName, version) {
|
|
|
272
317
|
const known = t.machines_fresh + t.machines_quiet + t.machines_silent;
|
|
273
318
|
const tiles = `<div class="tiles"><div class="tile${t.needs_you > 0 ? " hot" : ""}"><b>${t.needs_you}</b><span class="mut">waiting on a person</span></div><div class="tile"><b>${t.sessions}</b><span class="mut">${t.sessions === 1 ? "session" : "sessions"}</span></div><div class="tile"><b>${t.machines_fresh}<span class="mut"> of ${known}</span></b><span class="mut">${known === 1 ? "machine" : "machines"} reporting</span></div></div>`;
|
|
274
319
|
const groups = team.groups.map(
|
|
275
|
-
(g) => `<section class="card"><h3>${
|
|
320
|
+
(g) => `<section class="card"><h3>${esc2(g.name)}${g.remote ? ` <span class="mut">${esc2(g.remote)}</span>` : ""}</h3><table><colgroup><col class="who"><col class="n"><col class="wait"><col class="setup"><col class="mail"><col class="heard"></colgroup><thead><tr><th scope="col">Who</th><th scope="col">Sessions</th><th scope="col">Waiting on a person</th><th scope="col">Setup</th><th scope="col">Mail</th><th scope="col">Last heard</th></tr></thead><tbody>${g.rows.map((r) => row(r, now)).join("")}</tbody></table></section>`
|
|
276
321
|
).join("");
|
|
277
|
-
const machines = team.machines.map((m) => `<li>${
|
|
322
|
+
const machines = team.machines.map((m) => `<li>${esc2(m.who)} <span class="mut">${esc2(m.machine)} \xB7 last heard ${esc2(heard(m.minutes_ago))}</span>${m.freshness === "fresh" ? "" : ` <span class="warn">${m.freshness === "quiet" ? "quiet, not counted" : "silent for over a day, rows hidden"}</span>`}</li>`).join("");
|
|
278
323
|
return `<!doctype html>
|
|
279
324
|
<html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><meta http-equiv="refresh" content="60">
|
|
280
|
-
<title>${t.needs_you > 0 ? `(${t.needs_you}) ` : ""}JQ Deck: team</title><link rel="icon" href="data:,"><style>${STYLE}</style></head><body><main>
|
|
281
|
-
<div class="top"><div><h1>JQ Deck: team</h1><p class="head">${
|
|
325
|
+
<title>${t.needs_you > 0 ? `(${t.needs_you}) ` : ""}JQ Deck: team</title><link rel="icon" href="data:,"><style>${STYLE}${TOOLBAR_CSS}</style></head><body><main>
|
|
326
|
+
<div class="top"><div><h1>JQ Deck: team</h1><p class="head">${esc2(team.headline)}</p></div><form method="post" action="/logout"><button>Sign out</button></form></div>
|
|
282
327
|
${known > 0 ? tiles : ""}
|
|
283
|
-
<p class="mut">Read at ${
|
|
328
|
+
<p class="mut">Read at ${esc2(clock(team.generated_at))}, signed in as ${esc2(viewerName)}${team.scoped ? ", who sees some repositories only" : ""}. Reloads every minute. Read-only: answer a session where it is running.</p>
|
|
284
329
|
${groups || '<p class="card pad mut">No repository to show.</p>'}
|
|
285
330
|
<h2>Machines</h2>
|
|
286
331
|
<div class="card"><ul>${machines || '<li class="mut">None yet. On each machine: <code>jq-deck --watch --exec "jq-deck-server send --url THIS-ADDRESS"</code></li>'}</ul></div>
|
|
287
|
-
<p class="mut">A machine sends counts and scores: no folder path and no message. What a session asked is sent only where that machine opted the folder in. JQ Deck Server ${
|
|
288
|
-
</main
|
|
332
|
+
<p class="mut">A machine sends counts and scores: no folder path and no message. What a session asked is sent only where that machine opted the folder in. JQ Deck Server ${esc2(version)}.</p>
|
|
333
|
+
</main>${toolbar({ here: "team", running: null })}</body></html>`;
|
|
289
334
|
}
|
|
290
335
|
function renderLogin(message) {
|
|
291
336
|
return `<!doctype html>
|
|
@@ -294,7 +339,7 @@ function renderLogin(message) {
|
|
|
294
339
|
<h1>JQ Deck: team</h1>
|
|
295
340
|
<p class="mut" style="font-size:14px;margin:4px 0 12px">Which Claude Code sessions are waiting on a person, across this team's machines.</p>
|
|
296
341
|
<form class="card pad" method="post" action="/login">
|
|
297
|
-
${message ? `<p class="bad" role="alert">${
|
|
342
|
+
${message ? `<p class="bad" role="alert">${esc2(message)}</p>` : ""}
|
|
298
343
|
<label for="token">Viewer token</label>
|
|
299
344
|
<input id="token" name="token" type="password" autocomplete="current-password" placeholder="jqv_..." aria-describedby="token-help" required autofocus>
|
|
300
345
|
<p class="mut" id="token-help">It starts with <code>jqv_</code>. Whoever runs this server gives you one. A machine token (<code>jqm_</code>) does not sign in.</p>
|
package/dist/jq-deck-server.mjs
CHANGED
|
@@ -95,6 +95,51 @@ async function send(base, token, input, post = fetch) {
|
|
|
95
95
|
// src/server.ts
|
|
96
96
|
import { createServer } from "http";
|
|
97
97
|
|
|
98
|
+
// src/presence.ts
|
|
99
|
+
var TOOLS = [
|
|
100
|
+
{ id: "deck", name: "JQ Deck", what: "sessions, setup and mail on one page", port: 4316, run: "npx @point-seven-studio/jq-deck" },
|
|
101
|
+
{ id: "agents", name: "JQ Agents", what: "every session, and which wait on a person", port: 4319, run: "npx @point-seven-studio/jq-agents" },
|
|
102
|
+
{ id: "groundcrew", name: "JQ Groundcrew", what: "the setup check for one project", port: 4317, run: "npx @point-seven-studio/jq-groundcrew" },
|
|
103
|
+
{ id: "crosstalk", name: "JQ Crosstalk", what: "the mailbox between sessions", port: 4318, run: "npx @point-seven-studio/jq-crosstalk view" }
|
|
104
|
+
];
|
|
105
|
+
var esc = (s) => String(s ?? "").replace(/[&<>"']/g, (c) => ({ "&": "&", "<": "<", ">": ">", '"': """, "'": "'" })[c]);
|
|
106
|
+
var TOOLBAR_CSS = `
|
|
107
|
+
body{padding-bottom:64px}
|
|
108
|
+
.jqbar{position:fixed;left:0;right:0;bottom:0;z-index:5;display:flex;flex-wrap:wrap;align-items:center;gap:4px 14px;padding:8px 16px;font:13px/1.4 system-ui,sans-serif;background:var(--card,Canvas);color:var(--fg,CanvasText);border-top:1px solid var(--line,GrayText)}
|
|
109
|
+
.jqbar a{color:var(--link,LinkText)}
|
|
110
|
+
.jqbar .here{font-weight:700}
|
|
111
|
+
.jqbar details[open]{order:-1;flex-basis:100%}
|
|
112
|
+
.jqbar summary{cursor:pointer;color:var(--mut,GrayText);list-style:none;display:inline-block;padding:2px 0}
|
|
113
|
+
.jqbar summary::-webkit-details-marker{display:none}
|
|
114
|
+
.jqbar summary::after{content:" \u25B8"}
|
|
115
|
+
.jqbar details[open] summary::after{content:" \u25BE"}
|
|
116
|
+
.jqbar summary small,.jqbar a small{font-size:11px;font-weight:400}
|
|
117
|
+
.jqbar details>div{margin:4px 0 6px;padding:8px 10px;max-width:640px;border:1px solid var(--line,GrayText);border-radius:8px;background:var(--well,Canvas)}
|
|
118
|
+
.jqbar details>div p{margin:0 0 4px}
|
|
119
|
+
.jqbar code{font:12px ui-monospace,Menlo,monospace;word-break:break-all}
|
|
120
|
+
.jqbar a:focus-visible,.jqbar summary:focus-visible{outline:2px solid var(--link,LinkText);outline-offset:2px}
|
|
121
|
+
@media print{.jqbar{display:none}body{padding-bottom:0}}
|
|
122
|
+
`;
|
|
123
|
+
var local = (port) => `http://127.0.0.1:${port}`;
|
|
124
|
+
function toolItem(t, o) {
|
|
125
|
+
if (o.here === t.id) return `<span class="here" aria-current="page">${esc(t.name)}</span>`;
|
|
126
|
+
const start = `<p>To start it: <code>${esc(t.run)}</code></p>`;
|
|
127
|
+
if (o.running === null) {
|
|
128
|
+
return `<details><summary>${esc(t.name)} <small>on your computer</small></summary><div><p>${esc(t.name)} shows ${esc(t.what)}. It runs on your own computer, and this page cannot see whether it is running there.</p><p>If it is, it is at <a href="${local(t.port)}">${local(t.port)}</a>.</p>${start}</div></details>`;
|
|
129
|
+
}
|
|
130
|
+
const port = o.running[t.id];
|
|
131
|
+
if (port !== null) return `<a href="${local(port)}" title="${esc(t.what)}">${esc(t.name)}</a>`;
|
|
132
|
+
return `<details><summary>${esc(t.name)} <small>not running</small></summary><div><p>${esc(t.name)} shows ${esc(t.what)}. It is not running on this machine.</p>${start}<p>Then refresh this page.</p></div></details>`;
|
|
133
|
+
}
|
|
134
|
+
function teamItem(o) {
|
|
135
|
+
if (o.here === "team") return '<span class="here" aria-current="page">Team board</span>';
|
|
136
|
+
if (o.team) return `<a href="${esc(o.team)}" title="every machine on the team, on one page">Team board</a>`;
|
|
137
|
+
return '<details><summary>Team board <small>not set up</small></summary><div><p>A team board shows every machine on a team on one page. This machine has no address for one.</p><p>If your team has one, add a <code>"team"</code> line holding its address to <code>~/.jq/config.json</code>.</p><p>To host one: <code>npx @point-seven-studio/jq-deck-server</code></p></div></details>';
|
|
138
|
+
}
|
|
139
|
+
function toolbar(o) {
|
|
140
|
+
return `<nav class="jqbar" aria-label="JQ tools">${TOOLS.map((t) => toolItem(t, o)).join("")}${teamItem(o)}</nav>`;
|
|
141
|
+
}
|
|
142
|
+
|
|
98
143
|
// src/team.ts
|
|
99
144
|
var FRESH_MS = 5 * 6e4;
|
|
100
145
|
var SILENT_MS = 24 * 36e5;
|
|
@@ -164,7 +209,7 @@ function buildTeam(reports, now, viewer = null) {
|
|
|
164
209
|
}
|
|
165
210
|
|
|
166
211
|
// src/page.ts
|
|
167
|
-
var
|
|
212
|
+
var esc2 = (s) => String(s ?? "").replace(/[&<>"']/g, (c) => ({ "&": "&", "<": "<", ">": ">", '"': """, "'": "'" })[c]);
|
|
168
213
|
var STYLE = `
|
|
169
214
|
:root{--bg:#f7f6f2;--card:#fff;--fg:#1d1c19;--mut:#6b675e;--line:#dedbd2;--well:#f1efe9;--warn:#a1500a;--ok:#1f6b45;--bad:#a3262b;--link:#1d4f91}
|
|
170
215
|
@media (prefers-color-scheme:dark){:root{--bg:#161512;--card:#1f1e1a;--fg:#ece9e1;--mut:#a09c91;--line:#35332d;--well:#161512;--warn:#e0a25a;--ok:#7ccba0;--bad:#ef8a8e;--link:#8fb8ee}}
|
|
@@ -197,12 +242,12 @@ var minutesSince = (iso, now) => Math.max(0, Math.floor((now - Date.parse(iso))
|
|
|
197
242
|
var clock = (iso) => `${iso.slice(11, 16)} UTC`;
|
|
198
243
|
function row(r, now) {
|
|
199
244
|
const quiet = r.freshness !== "fresh";
|
|
200
|
-
const waiting = quiet ? '<span class="mut">not current</span>' : r.needs_you > 0 ? `<span class="warn">${r.needs_you} waiting${r.waiting_minutes !== null ? `, ${
|
|
245
|
+
const waiting = quiet ? '<span class="mut">not current</span>' : r.needs_you > 0 ? `<span class="warn">${r.needs_you} waiting${r.waiting_minutes !== null ? `, ${esc2(duration(r.waiting_minutes))}` : ""}</span>` : '<span class="mut">none</span>';
|
|
201
246
|
const setup = !r.setup ? '<span class="mut">not checked</span>' : `${r.setup.score}% ${r.setup.fail > 0 ? `<span class="bad">${r.setup.fail} to fix</span>` : r.setup.warn > 0 ? `<span class="warn">${r.setup.warn} to look at</span>` : '<span class="ok">all good</span>'}`;
|
|
202
247
|
const mail = r.unread === null ? '<span class="mut">no inbox</span>' : r.unread === 0 ? '<span class="mut">none unread</span>' : `${r.unread} unread`;
|
|
203
|
-
const asked = (r.questions ?? []).map((q) => `<div class="q"><span class="mut">${
|
|
248
|
+
const asked = (r.questions ?? []).map((q) => `<div class="q"><span class="mut">${esc2(r.who)}'s session asked${q.asked_at ? ` ${esc2(heard(minutesSince(q.asked_at, now)))}` : ""}</span><p>${esc2(q.text)}</p></div>`).join("");
|
|
204
249
|
const askedRow = asked ? `<tr class="asked"><td colspan="6">${asked}</td></tr>` : "";
|
|
205
|
-
return `<tr${quiet ? ' class="quiet"' : ""}><th scope="row">${
|
|
250
|
+
return `<tr${quiet ? ' class="quiet"' : ""}><th scope="row">${esc2(r.who)} <span class="mut">${esc2(r.machine)}</span></th><td data-l="Sessions">${r.sessions} <span class="mut">(${r.live} live)</span></td><td data-l="Waiting on a person">${waiting}</td><td data-l="Setup">${setup}</td><td data-l="Mail">${mail}</td><td data-l="Last heard"><span class="mut">${esc2(heard(r.minutes_ago))}</span></td></tr>${askedRow}`;
|
|
206
251
|
}
|
|
207
252
|
function renderTeam(team, viewerName, version) {
|
|
208
253
|
const now = Date.parse(team.generated_at);
|
|
@@ -210,20 +255,20 @@ function renderTeam(team, viewerName, version) {
|
|
|
210
255
|
const known = t.machines_fresh + t.machines_quiet + t.machines_silent;
|
|
211
256
|
const tiles = `<div class="tiles"><div class="tile${t.needs_you > 0 ? " hot" : ""}"><b>${t.needs_you}</b><span class="mut">waiting on a person</span></div><div class="tile"><b>${t.sessions}</b><span class="mut">${t.sessions === 1 ? "session" : "sessions"}</span></div><div class="tile"><b>${t.machines_fresh}<span class="mut"> of ${known}</span></b><span class="mut">${known === 1 ? "machine" : "machines"} reporting</span></div></div>`;
|
|
212
257
|
const groups = team.groups.map(
|
|
213
|
-
(g) => `<section class="card"><h3>${
|
|
258
|
+
(g) => `<section class="card"><h3>${esc2(g.name)}${g.remote ? ` <span class="mut">${esc2(g.remote)}</span>` : ""}</h3><table><colgroup><col class="who"><col class="n"><col class="wait"><col class="setup"><col class="mail"><col class="heard"></colgroup><thead><tr><th scope="col">Who</th><th scope="col">Sessions</th><th scope="col">Waiting on a person</th><th scope="col">Setup</th><th scope="col">Mail</th><th scope="col">Last heard</th></tr></thead><tbody>${g.rows.map((r) => row(r, now)).join("")}</tbody></table></section>`
|
|
214
259
|
).join("");
|
|
215
|
-
const machines = team.machines.map((m) => `<li>${
|
|
260
|
+
const machines = team.machines.map((m) => `<li>${esc2(m.who)} <span class="mut">${esc2(m.machine)} \xB7 last heard ${esc2(heard(m.minutes_ago))}</span>${m.freshness === "fresh" ? "" : ` <span class="warn">${m.freshness === "quiet" ? "quiet, not counted" : "silent for over a day, rows hidden"}</span>`}</li>`).join("");
|
|
216
261
|
return `<!doctype html>
|
|
217
262
|
<html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><meta http-equiv="refresh" content="60">
|
|
218
|
-
<title>${t.needs_you > 0 ? `(${t.needs_you}) ` : ""}JQ Deck: team</title><link rel="icon" href="data:,"><style>${STYLE}</style></head><body><main>
|
|
219
|
-
<div class="top"><div><h1>JQ Deck: team</h1><p class="head">${
|
|
263
|
+
<title>${t.needs_you > 0 ? `(${t.needs_you}) ` : ""}JQ Deck: team</title><link rel="icon" href="data:,"><style>${STYLE}${TOOLBAR_CSS}</style></head><body><main>
|
|
264
|
+
<div class="top"><div><h1>JQ Deck: team</h1><p class="head">${esc2(team.headline)}</p></div><form method="post" action="/logout"><button>Sign out</button></form></div>
|
|
220
265
|
${known > 0 ? tiles : ""}
|
|
221
|
-
<p class="mut">Read at ${
|
|
266
|
+
<p class="mut">Read at ${esc2(clock(team.generated_at))}, signed in as ${esc2(viewerName)}${team.scoped ? ", who sees some repositories only" : ""}. Reloads every minute. Read-only: answer a session where it is running.</p>
|
|
222
267
|
${groups || '<p class="card pad mut">No repository to show.</p>'}
|
|
223
268
|
<h2>Machines</h2>
|
|
224
269
|
<div class="card"><ul>${machines || '<li class="mut">None yet. On each machine: <code>jq-deck --watch --exec "jq-deck-server send --url THIS-ADDRESS"</code></li>'}</ul></div>
|
|
225
|
-
<p class="mut">A machine sends counts and scores: no folder path and no message. What a session asked is sent only where that machine opted the folder in. JQ Deck Server ${
|
|
226
|
-
</main
|
|
270
|
+
<p class="mut">A machine sends counts and scores: no folder path and no message. What a session asked is sent only where that machine opted the folder in. JQ Deck Server ${esc2(version)}.</p>
|
|
271
|
+
</main>${toolbar({ here: "team", running: null })}</body></html>`;
|
|
227
272
|
}
|
|
228
273
|
function renderLogin(message) {
|
|
229
274
|
return `<!doctype html>
|
|
@@ -232,7 +277,7 @@ function renderLogin(message) {
|
|
|
232
277
|
<h1>JQ Deck: team</h1>
|
|
233
278
|
<p class="mut" style="font-size:14px;margin:4px 0 12px">Which Claude Code sessions are waiting on a person, across this team's machines.</p>
|
|
234
279
|
<form class="card pad" method="post" action="/login">
|
|
235
|
-
${message ? `<p class="bad" role="alert">${
|
|
280
|
+
${message ? `<p class="bad" role="alert">${esc2(message)}</p>` : ""}
|
|
236
281
|
<label for="token">Viewer token</label>
|
|
237
282
|
<input id="token" name="token" type="password" autocomplete="current-password" placeholder="jqv_..." aria-describedby="token-help" required autofocus>
|
|
238
283
|
<p class="mut" id="token-help">It starts with <code>jqv_</code>. Whoever runs this server gives you one. A machine token (<code>jqm_</code>) does not sign in.</p>
|
|
@@ -512,11 +557,11 @@ They paste it into the sign-in page.`);
|
|
|
512
557
|
const port = Number(p.options["--port"] ?? DEFAULT_PORT);
|
|
513
558
|
if (!Number.isInteger(port) || port < 1 || port > 65535) throw new Error("--port needs a number from 1 to 65535");
|
|
514
559
|
const host = p.options["--host"] || "127.0.0.1";
|
|
515
|
-
const
|
|
516
|
-
const secureCookie = !
|
|
560
|
+
const local2 = LOOPBACK.has(host);
|
|
561
|
+
const secureCookie = !local2 && !p.flags.has("--plain-http");
|
|
517
562
|
startServer({ dir, version, secureCookie }, port, host, (bound) => {
|
|
518
563
|
console.log(`jq-deck-server: http://${host}:${bound} (Ctrl-C to stop), data in ${dir}`);
|
|
519
|
-
if (!
|
|
564
|
+
if (!local2) console.log(secureCookie ? "jq-deck-server: reachable from other machines. Put HTTPS in front of it: sign-in needs it." : "jq-deck-server: WARNING: reachable from other machines over plain HTTP. Tokens travel in the clear.");
|
|
520
565
|
});
|
|
521
566
|
return;
|
|
522
567
|
}
|
|
@@ -526,7 +571,7 @@ They paste it into the sign-in page.`);
|
|
|
526
571
|
}
|
|
527
572
|
|
|
528
573
|
// src/main.ts
|
|
529
|
-
var VERSION = true ? "0.2.
|
|
574
|
+
var VERSION = true ? "0.2.3" : "dev";
|
|
530
575
|
var HELP = `JQ Deck Server ${VERSION}: one page for a team's Claude Code sessions.
|
|
531
576
|
|
|
532
577
|
On the server:
|
package/dist/types/page.d.ts
CHANGED
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The team page and the sign-in page. One HTML string each, no script, no
|
|
3
|
-
* outside request. Every value is escaped: names come from other machines.
|
|
4
|
-
*/
|
|
5
1
|
import { type Team } from './team.js';
|
|
6
2
|
/** "23:34 UTC": the page has no script, so it cannot show the reader's own time zone. */
|
|
7
3
|
export declare const clock: (iso: string) => string;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
export type ToolId = 'deck' | 'groundcrew' | 'crosstalk' | 'agents';
|
|
2
|
+
export interface ToolInfo {
|
|
3
|
+
id: ToolId;
|
|
4
|
+
name: string;
|
|
5
|
+
/** What it shows, in a few words. */
|
|
6
|
+
what: string;
|
|
7
|
+
/** The port it serves on unless told otherwise. */
|
|
8
|
+
port: number;
|
|
9
|
+
/** The command that starts its page. */
|
|
10
|
+
run: string;
|
|
11
|
+
}
|
|
12
|
+
export declare const TOOLS: readonly ToolInfo[];
|
|
13
|
+
export declare function runningDir(env?: Record<string, string | undefined>): string;
|
|
14
|
+
/** Every tool, with the port of its running page or null. `isAlive` is a parameter so a test can decide. */
|
|
15
|
+
export declare function readRunning(dir?: string, isAlive?: (pid: number) => boolean): Record<ToolId, number | null>;
|
|
16
|
+
/**
|
|
17
|
+
* Say "this tool is serving on this port" until the process ends. Returns a function
|
|
18
|
+
* that takes the note away. Never throws: a tool that cannot write the note still runs,
|
|
19
|
+
* and the other pages show it as not running.
|
|
20
|
+
*/
|
|
21
|
+
export declare function announce(tool: ToolId, port: number, dir?: string): () => void;
|
|
22
|
+
/** `"team": "https://..."` in ~/.jq/config.json. Null when absent, unreadable, or not an http(s) address. */
|
|
23
|
+
export declare function readTeamUrl(file?: string): string | null;
|
|
24
|
+
/** Works on every JQ page: each defines these colours, and the fallbacks cover one that does not. */
|
|
25
|
+
export declare const TOOLBAR_CSS = "\nbody{padding-bottom:64px}\n.jqbar{position:fixed;left:0;right:0;bottom:0;z-index:5;display:flex;flex-wrap:wrap;align-items:center;gap:4px 14px;padding:8px 16px;font:13px/1.4 system-ui,sans-serif;background:var(--card,Canvas);color:var(--fg,CanvasText);border-top:1px solid var(--line,GrayText)}\n.jqbar a{color:var(--link,LinkText)}\n.jqbar .here{font-weight:700}\n.jqbar details[open]{order:-1;flex-basis:100%}\n.jqbar summary{cursor:pointer;color:var(--mut,GrayText);list-style:none;display:inline-block;padding:2px 0}\n.jqbar summary::-webkit-details-marker{display:none}\n.jqbar summary::after{content:\" \u25B8\"}\n.jqbar details[open] summary::after{content:\" \u25BE\"}\n.jqbar summary small,.jqbar a small{font-size:11px;font-weight:400}\n.jqbar details>div{margin:4px 0 6px;padding:8px 10px;max-width:640px;border:1px solid var(--line,GrayText);border-radius:8px;background:var(--well,Canvas)}\n.jqbar details>div p{margin:0 0 4px}\n.jqbar code{font:12px ui-monospace,Menlo,monospace;word-break:break-all}\n.jqbar a:focus-visible,.jqbar summary:focus-visible{outline:2px solid var(--link,LinkText);outline-offset:2px}\n@media print{.jqbar{display:none}body{padding-bottom:0}}\n";
|
|
26
|
+
export interface ToolbarOptions {
|
|
27
|
+
/** The page this bar is on: a tool, or 'team' for the team board. */
|
|
28
|
+
here: ToolId | 'team';
|
|
29
|
+
/**
|
|
30
|
+
* What is running on the reader's own machine, when the page can know. Null when it
|
|
31
|
+
* cannot: the page is served from somewhere else.
|
|
32
|
+
*/
|
|
33
|
+
running: Record<ToolId, number | null> | null;
|
|
34
|
+
/** The team board's address, when this machine knows one. Ignored on the team board itself. */
|
|
35
|
+
team?: string | null;
|
|
36
|
+
}
|
|
37
|
+
/** The bar's HTML. Put TOOLBAR_CSS in the page's style, and this just before </body>. */
|
|
38
|
+
export declare function toolbar(o: ToolbarOptions): string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@point-seven-studio/jq-deck-server",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.3",
|
|
4
4
|
"description": "A small server for a team's JQ Deck: each machine reports counts and scores per repository, and one page shows what is waiting on a person across the team. Self-hosted; stores files in one folder; no dependency. Unofficial; not affiliated with or endorsed by Anthropic.",
|
|
5
5
|
"bin": {
|
|
6
6
|
"jq-deck-server": "dist/jq-deck-server.mjs"
|