@marver-design/marver 0.26.0 → 0.27.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/CHANGELOG.md +158 -0
- package/README.md +10 -5
- package/dist/{anchor-check-Dg5xpNnU.mjs → anchor-check-ChdDqL5z.mjs} +1 -1
- package/dist/{audio-CmSRYFEs.mjs → audio-Dw1lfMdb.mjs} +14 -0
- package/dist/{bake-DtVlm0_F.mjs → bake-DM_uWgAA.mjs} +1 -1
- package/dist/{boards-DYG22tOe.mjs → boards-DlTcpF47.mjs} +1 -1
- package/dist/{build-C_gUgcdC.mjs → build-DZnFysGU.mjs} +4 -4
- package/dist/{capture-CrqvU_jh.mjs → capture-vadKjuCo.mjs} +2 -1
- package/dist/cli.mjs +28 -16
- package/dist/{comments-BqXua-XL.mjs → comments-DxOkCSNE.mjs} +4 -4
- package/dist/{daemon-DZo6o3rU.mjs → daemon-BSA0lV8d.mjs} +400 -274
- package/dist/detect-C0wpaePX.mjs +125 -0
- package/dist/dev-eQJhWsqg.mjs +1273 -0
- package/dist/dev-lock-C_FC70Mu.mjs +65 -0
- package/dist/exclusive-B1RtpeeP.mjs +150 -0
- package/dist/{init-D8DtrK_F.mjs → init-COD0x48i.mjs} +5 -3
- package/dist/{link-BNzLvdhI.mjs → link-DDXZVGtv.mjs} +20 -8
- package/dist/ls-D7O1G505.mjs +38 -0
- package/dist/{marks-NQi0wZJ4.mjs → marks-CWM3WJjc.mjs} +1 -1
- package/dist/perf-BWzQwZqj.mjs +369 -0
- package/dist/perf-BoDSkbEb.mjs +429 -0
- package/dist/perf-jam-D55U3FZK.mjs +242 -0
- package/dist/{plugin-CTD0rydA.mjs → plugin-C-E7omsh.mjs} +425 -66
- package/dist/{poster-ChjXGTS5.mjs → poster-Bx83ZYVK.mjs} +2 -1
- package/dist/{profile-WU9qcbIo.mjs → profile-Bh5Y5zpW.mjs} +1 -1
- package/dist/{publish-bakes-CEP_2NRc.mjs → publish-bakes-aljgm45S.mjs} +2 -2
- package/dist/{queue-BuiCKSX1.mjs → queue-CAM_vNmX.mjs} +3 -3
- package/dist/recover-t9Pno3u9.mjs +66 -0
- package/dist/{session-qZWKt_VA.mjs → session-BAaJsK5c.mjs} +1 -1
- package/dist/{share--oFJ1bCI.mjs → share-W5H3BNvP.mjs} +1 -1
- package/dist/shot-DoHLl6ig.mjs +139 -0
- package/dist/{shot-DqcxJibP.mjs → shot-LFhC-WYD.mjs} +343 -19
- package/dist/slots-DCDo3N0x.mjs +471 -0
- package/dist/speech-worker.mjs +40 -5
- package/dist/{sync-DKk-yT1V.mjs → sync-BQVlHZpx.mjs} +4 -3
- package/dist/{work-F5u-twpJ.mjs → work-Bp1p39kq.mjs} +4 -2
- package/dist/{work-VvX_JIgl.mjs → work-BroFwnup.mjs} +4 -2
- package/docs/boards-and-folders.md +3 -1
- package/docs/jam-session.md +78 -7
- package/docs/live-jam.md +8 -0
- package/docs/performance.md +262 -0
- package/package.json +2 -2
- package/src/client/content/index.tsx +3 -0
- package/src/client/content/video.tsx +6 -2
- package/src/client/frame-host/bridge.js +22 -6
- package/src/client/frame-host/inspect.js +8 -3
- package/src/client/frame-host/keys.js +6 -2
- package/src/client/frame-host/main.tsx +17 -5
- package/src/client/shell/App.tsx +188 -29
- package/src/client/shell/BoardList.tsx +5 -5
- package/src/client/shell/Comments.tsx +3 -2
- package/src/client/shell/JamSurface.tsx +13 -5
- package/src/client/shell/LockedApp.tsx +5 -5
- package/src/client/shell/Play.tsx +27 -15
- package/src/client/shell/Toolbar.tsx +17 -5
- package/src/client/shell/api.ts +206 -0
- package/src/client/shell/canvas/Canvas.tsx +30 -3
- package/src/client/shell/canvas/FrameNode.tsx +15 -5
- package/src/client/shell/canvas/admission.ts +8 -1
- package/src/client/shell/canvas/camera-broadcast.ts +15 -5
- package/src/client/shell/canvas/ctl.ts +2 -0
- package/src/client/shell/canvas/frame-registry.ts +28 -2
- package/src/client/shell/canvas/sleep.ts +4 -1
- package/src/client/shell/comments-store.ts +12 -4
- package/src/client/shell/goto.ts +22 -10
- package/src/client/shell/icons.tsx +2 -0
- package/src/client/shell/jam-capture.ts +96 -16
- package/src/client/shell/jam-keys.ts +51 -18
- package/src/client/shell/jam-lane.tsx +46 -5
- package/src/client/shell/jam-panel.tsx +66 -13
- package/src/client/shell/jam-queue.ts +3 -3
- package/src/client/shell/jam-session.tsx +14 -8
- package/src/client/shell/jam-state.ts +48 -6
- package/src/client/shell/jam-surface-parts.tsx +10 -6
- package/src/client/shell/jam-voice.ts +7 -5
- package/src/client/shell/legacy-links.ts +2 -2
- package/src/client/shell/main.tsx +4 -0
- package/src/client/shell/notes.ts +8 -1
- package/src/client/shell/perf.ts +69 -58
- package/src/client/shell/recorder-core.ts +183 -0
- package/src/client/shell/recorder.ts +565 -0
- package/src/client/shell/store.ts +268 -103
- package/src/client/shell/styles.css +54 -9
- package/src/client/stage/main.tsx +2 -0
- package/templates/AGENTS-embedded.md +22 -4
- package/templates/AGENTS-studio.md +22 -4
- package/templates/demo/dark.tsx +1 -1
- package/templates/demo/welcome.tsx +1 -1
- package/templates/instructions/jam.md +5 -3
- package/templates/instructions/welcome.md +6 -3
- package/dist/config-Cf7EjAMf.mjs +0 -292
- package/dist/dev-_Nlsc6v9.mjs +0 -742
- package/dist/dev-lock-DWSpa6nj.mjs +0 -179
- package/dist/perf-D6VmmJ2q.mjs +0 -68
- package/dist/perf-DPbLGhhO.mjs +0 -49
- package/dist/shot-CNbHoZ6H.mjs +0 -86
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { a as readJson, i as portInUse, o as takeExclusive, r as pidRuns } from "./exclusive-B1RtpeeP.mjs";
|
|
2
|
+
import { mkdirSync } from "node:fs";
|
|
3
|
+
import { join } from "node:path";
|
|
4
|
+
import { randomUUID } from "node:crypto";
|
|
5
|
+
//#region src/server/dev-lock.ts
|
|
6
|
+
/**
|
|
7
|
+
* One canvas per folder (#19, spec 27 Part 7). `marver dev` takes design/.local/dev.lock before it
|
|
8
|
+
* starts the server, so a second `marver dev` in the same folder says where the first one runs
|
|
9
|
+
* instead of taking over dev.json (which the CLI - `work`, `shot`, `comments new --on` - reads to
|
|
10
|
+
* find the canvas).
|
|
11
|
+
*
|
|
12
|
+
* The rules, none of which guess a holder dead from time or from an unanswered request:
|
|
13
|
+
* - no lock: create it exclusively. Done.
|
|
14
|
+
* - a lock whose pid runs: a canvas runs here (a slow or paused one too) - stop with its link.
|
|
15
|
+
* - a lock whose pid is dead: reclaim it while holding dev.lock.reclaim (also exclusive): read it
|
|
16
|
+
* again, still the same dead holder -> replace it. A reclaim lock already there means another
|
|
17
|
+
* start is reclaiming: wait a second and start over once; still there -> fail closed.
|
|
18
|
+
* - a 0.25 server writes no lock and no pid: dev.json without a lock is decided by binding its port.
|
|
19
|
+
*
|
|
20
|
+
* Both files are created by linking a fully written temp file into place, so a reader never sees
|
|
21
|
+
* an empty or half-written lock - `link` fails if the name exists, which is the exclusive create.
|
|
22
|
+
* The file rules themselves live in exclusive.ts (spec 28 A1.2), shared with the slot files; this
|
|
23
|
+
* module keeps the lock's words and the 0.25 check.
|
|
24
|
+
*/
|
|
25
|
+
const localDir = (root) => join(root, "design", ".local");
|
|
26
|
+
const lockPath = (root) => join(localDir(root), "dev.lock");
|
|
27
|
+
const infoPath = (root) => join(localDir(root), "dev.json");
|
|
28
|
+
const runsHere = (root) => {
|
|
29
|
+
const port = readJson(infoPath(root))?.port;
|
|
30
|
+
return typeof port === "number" ? `a canvas already runs here: http://localhost:${port} - open it, or stop it first` : "a canvas already runs here - open it, or stop it first";
|
|
31
|
+
};
|
|
32
|
+
const RECLAIM_STUCK = "a canvas is starting here, or a start crashed: delete design/.local/dev.lock.reclaim if no canvas runs";
|
|
33
|
+
/** Take the folder's canvas lock. On success the caller owns dev.lock until `release()` (which
|
|
34
|
+
* removes it only while it still names this instance). */
|
|
35
|
+
async function takeDevLock(root, opts = {}) {
|
|
36
|
+
mkdirSync(localDir(root), { recursive: true });
|
|
37
|
+
const me = {
|
|
38
|
+
pid: opts.pid ?? process.pid,
|
|
39
|
+
instance: randomUUID(),
|
|
40
|
+
at: Date.now()
|
|
41
|
+
};
|
|
42
|
+
const r = await takeExclusive(lockPath(root), me, JSON.stringify(me), { reclaimWaitMs: opts.reclaimWaitMs });
|
|
43
|
+
if (!r.ok) return {
|
|
44
|
+
ok: false,
|
|
45
|
+
message: r.why === "held" ? runsHere(root) : r.why === "unreadable" ? "design/.local/dev.lock is unreadable: delete it if no canvas runs" : RECLAIM_STUCK
|
|
46
|
+
};
|
|
47
|
+
opts.onTaken?.(r.release);
|
|
48
|
+
const info = readJson(infoPath(root));
|
|
49
|
+
if (info && info.instance !== me.instance) {
|
|
50
|
+
if (typeof info.pid === "number" ? pidRuns(info.pid) : typeof info.port === "number" ? await portInUse(info.port) : false) {
|
|
51
|
+
r.release();
|
|
52
|
+
return {
|
|
53
|
+
ok: false,
|
|
54
|
+
message: `${runsHere(root)}${typeof info.pid === "number" ? "" : " (or delete design/.local/dev.json if it is not)"}`
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
return {
|
|
59
|
+
ok: true,
|
|
60
|
+
instance: me.instance,
|
|
61
|
+
release: r.release
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
//#endregion
|
|
65
|
+
export { takeDevLock };
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
import { linkSync, readFileSync, unlinkSync, writeFileSync } from "node:fs";
|
|
2
|
+
import { randomBytes } from "node:crypto";
|
|
3
|
+
import { createServer } from "node:net";
|
|
4
|
+
//#region src/server/exclusive.ts
|
|
5
|
+
/**
|
|
6
|
+
* One holder per file (spec 28 A1.2): dev.lock and the slot files in ~/.marver/running/ share it.
|
|
7
|
+
*
|
|
8
|
+
* The rules, none of which guess a holder dead from time or from an unanswered request:
|
|
9
|
+
* - no file: create it exclusively. Done.
|
|
10
|
+
* - a file whose pid runs: it is held (a slow or paused holder too).
|
|
11
|
+
* - a file whose pid is dead: reclaim it while holding `<file>.reclaim` (also exclusive): read it
|
|
12
|
+
* again, still the same dead holder -> replace it. A reclaim file already there means another
|
|
13
|
+
* start is reclaiming: wait a second and start over once; still there -> stuck. A `.reclaim` left
|
|
14
|
+
* by a process killed mid-reclaim is never guessed stale from its age.
|
|
15
|
+
* - a file that is there but names no holder: unreadable, never guessed stale either.
|
|
16
|
+
*
|
|
17
|
+
* Files are created by linking a fully written temp file into place, so a reader never sees an
|
|
18
|
+
* empty or half-written one - `link` fails if the name exists, which is the exclusive create.
|
|
19
|
+
*/
|
|
20
|
+
/** Is this pid a running process? EPERM means it runs under another user - still running. A
|
|
21
|
+
* process paused with SIGSTOP runs too, as far as this is concerned. */
|
|
22
|
+
function pidRuns(pid) {
|
|
23
|
+
if (typeof pid !== "number" || !Number.isInteger(pid) || pid <= 0) return false;
|
|
24
|
+
try {
|
|
25
|
+
process.kill(pid, 0);
|
|
26
|
+
return true;
|
|
27
|
+
} catch (err) {
|
|
28
|
+
return err.code === "EPERM";
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
/** Create `file` holding `body`, failing with EEXIST if it is there - atomically, content included. */
|
|
32
|
+
function createExclusive(file, body) {
|
|
33
|
+
const tmp = `${file}.${randomBytes(6).toString("hex")}.tmp`;
|
|
34
|
+
writeFileSync(tmp, body, { mode: 384 });
|
|
35
|
+
try {
|
|
36
|
+
linkSync(tmp, file);
|
|
37
|
+
} finally {
|
|
38
|
+
try {
|
|
39
|
+
unlinkSync(tmp);
|
|
40
|
+
} catch {}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
/** A JSON file's value: undefined when there is no file, null when it is there but unreadable. */
|
|
44
|
+
const readJson = (file) => {
|
|
45
|
+
try {
|
|
46
|
+
return JSON.parse(readFileSync(file, "utf8"));
|
|
47
|
+
} catch (err) {
|
|
48
|
+
return err.code === "ENOENT" ? void 0 : null;
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
/** The holder a file names - any JSON object with a numeric pid and a string instance (a slot file's
|
|
52
|
+
* other fields are ignored). */
|
|
53
|
+
const asHolder = (v) => {
|
|
54
|
+
const h = v;
|
|
55
|
+
return h && typeof h.pid === "number" && typeof h.instance === "string" ? {
|
|
56
|
+
pid: h.pid,
|
|
57
|
+
instance: h.instance,
|
|
58
|
+
at: Number(h.at) || 0
|
|
59
|
+
} : null;
|
|
60
|
+
};
|
|
61
|
+
/** Is anything listening on `port` on this machine? Vite binds ::1 for `localhost`, an older or
|
|
62
|
+
* configured one 127.0.0.1 - a port is in use if either refuses the bind. */
|
|
63
|
+
async function portInUse(port) {
|
|
64
|
+
const bind = (host) => new Promise((res) => {
|
|
65
|
+
const s = createServer();
|
|
66
|
+
s.once("error", (err) => res(err.code === "EADDRINUSE" || err.code === "EACCES"));
|
|
67
|
+
s.once("listening", () => s.close(() => res(false)));
|
|
68
|
+
s.listen(port, host);
|
|
69
|
+
});
|
|
70
|
+
return await bind("127.0.0.1") || await bind("::1");
|
|
71
|
+
}
|
|
72
|
+
const code = (err) => err.code;
|
|
73
|
+
/** Take `file` for `me`, writing `body` (which names me.pid and me.instance). On success the caller
|
|
74
|
+
* owns it until `release()`, which removes it only while it still names me.instance. */
|
|
75
|
+
async function takeExclusive(file, me, body, opts = {}) {
|
|
76
|
+
const reclaim = `${file}.reclaim`;
|
|
77
|
+
const release = () => releaseExclusive(file, me.instance);
|
|
78
|
+
for (let round = 0; round < 2; round++) {
|
|
79
|
+
try {
|
|
80
|
+
createExclusive(file, body);
|
|
81
|
+
return {
|
|
82
|
+
ok: true,
|
|
83
|
+
release
|
|
84
|
+
};
|
|
85
|
+
} catch (err) {
|
|
86
|
+
if (code(err) !== "EEXIST") throw err;
|
|
87
|
+
}
|
|
88
|
+
const raw = readJson(file);
|
|
89
|
+
if (raw === void 0) continue;
|
|
90
|
+
const holder = asHolder(raw);
|
|
91
|
+
if (!holder) return {
|
|
92
|
+
ok: false,
|
|
93
|
+
why: "unreadable"
|
|
94
|
+
};
|
|
95
|
+
if (pidRuns(holder.pid)) return {
|
|
96
|
+
ok: false,
|
|
97
|
+
why: "held",
|
|
98
|
+
holder
|
|
99
|
+
};
|
|
100
|
+
try {
|
|
101
|
+
createExclusive(reclaim, JSON.stringify(me));
|
|
102
|
+
} catch (err) {
|
|
103
|
+
if (code(err) !== "EEXIST") throw err;
|
|
104
|
+
if (round === 0) {
|
|
105
|
+
await new Promise((r) => setTimeout(r, opts.reclaimWaitMs ?? 1e3));
|
|
106
|
+
continue;
|
|
107
|
+
}
|
|
108
|
+
return {
|
|
109
|
+
ok: false,
|
|
110
|
+
why: "stuck"
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
try {
|
|
114
|
+
const again = asHolder(readJson(file));
|
|
115
|
+
if (again && again.pid === holder.pid && again.instance === holder.instance) {
|
|
116
|
+
unlinkSync(file);
|
|
117
|
+
try {
|
|
118
|
+
createExclusive(file, body);
|
|
119
|
+
return {
|
|
120
|
+
ok: true,
|
|
121
|
+
release
|
|
122
|
+
};
|
|
123
|
+
} catch (err) {
|
|
124
|
+
if (code(err) !== "EEXIST") throw err;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
} finally {
|
|
128
|
+
try {
|
|
129
|
+
unlinkSync(reclaim);
|
|
130
|
+
} catch {}
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
const last = asHolder(readJson(file));
|
|
134
|
+
return last && pidRuns(last.pid) ? {
|
|
135
|
+
ok: false,
|
|
136
|
+
why: "held",
|
|
137
|
+
holder: last
|
|
138
|
+
} : {
|
|
139
|
+
ok: false,
|
|
140
|
+
why: "stuck"
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
/** Remove `file` if it still names `instance` - a file some other start took over stays. */
|
|
144
|
+
function releaseExclusive(file, instance) {
|
|
145
|
+
try {
|
|
146
|
+
if (asHolder(readJson(file))?.instance === instance) unlinkSync(file);
|
|
147
|
+
} catch {}
|
|
148
|
+
}
|
|
149
|
+
//#endregion
|
|
150
|
+
export { readJson as a, portInUse as i, createExclusive as n, takeExclusive as o, pidRuns as r, asHolder as t };
|
|
@@ -5,7 +5,7 @@ import { s as scanFrames, u as writeManifest } from "./manifest-Nl3KSVOk.mjs";
|
|
|
5
5
|
import { r as detectAgent } from "./agent-BsieQGTD.mjs";
|
|
6
6
|
import { MANAGED_PREFIX, enumerateInstructionTemplates, hashBody, pkgDir } from "./managed-HwHVNI3h.mjs";
|
|
7
7
|
import { t as writeManaged } from "./managed-write-Bo-oPc-i.mjs";
|
|
8
|
-
import {
|
|
8
|
+
import { n as readJson, t as detectHost } from "./detect-C0wpaePX.mjs";
|
|
9
9
|
import { cpSync, existsSync, mkdirSync, readFileSync, readdirSync, rmSync, writeFileSync } from "node:fs";
|
|
10
10
|
import { basename, dirname, join, relative } from "node:path";
|
|
11
11
|
//#region src/cli/init.ts
|
|
@@ -264,7 +264,7 @@ function init(root, opts) {
|
|
|
264
264
|
if (!existsSync(join(root, "context"))) console.log(`\n note: no context/ yet - feature and project boards read Backlog until there is one, and nothing records what shipped. To start it, tell your agent: "Set up our context." (design/instructions/context.md)`);
|
|
265
265
|
if (!jamAgent) console.log(`\n note: Live Jam found no agent CLI on PATH (claude, codex, cursor, droid, opencode, grok, or pi) - install one and it arms itself on the next \`${NAME} dev\`.`);
|
|
266
266
|
else if (created.includes("design/config.ts")) console.log(`\n Live Jam is on (${jamAgent}): tag @${NAME} in a canvas comment and your agent does the work, then replies in the thread.`);
|
|
267
|
-
console.log(`\n next: npx ${NAME} dev (or: npx ${NAME} canvas - same thing;
|
|
267
|
+
console.log(`\n next: npx ${NAME} dev (or: npx ${NAME} canvas - same thing; it prints its link: a free slot, localhost:4805-4824, usually the same one next time)\n`);
|
|
268
268
|
if (!noApp(host) && created.includes("design/config.ts")) console.log(` then, to your agent: "Read design/AGENTS.md. This is our first session - follow design/instructions/welcome.md."\n`);
|
|
269
269
|
}
|
|
270
270
|
/** The host's path aliases, re-rooted one level down for design/tsconfig.json.
|
|
@@ -577,7 +577,9 @@ export default {
|
|
|
577
577
|
// tv: { width: 3840, height: 2160 },
|
|
578
578
|
},
|
|
579
579
|
themes: ["light", "dark"],
|
|
580
|
-
port
|
|
580
|
+
// A port of its own. Without one, \`${NAME} dev\` takes a free slot (localhost:4805-4824),
|
|
581
|
+
// usually the same one next time - \`npx ${NAME} ls\` lists the canvases running and their links.
|
|
582
|
+
// port: 5300,
|
|
581
583
|
// Canvas zoom feel: 1 = default, 1.2 = 20% faster, 0.8 = 20% slower.
|
|
582
584
|
// zoomSpeed: 1,
|
|
583
585
|
${jamBlock(jamAgent)}
|
|
@@ -2,7 +2,7 @@ import { r as NAME } from "./cli.mjs";
|
|
|
2
2
|
import { d as readMembership, i as checkBoardsDir, p as unplacedHint, s as listBoardFiles } from "./boards-CGg6piKF.mjs";
|
|
3
3
|
import { f as isBoardName } from "./board-tree-DRioF94d.mjs";
|
|
4
4
|
import { s as scanFrames } from "./manifest-Nl3KSVOk.mjs";
|
|
5
|
-
import { i as readDevInfo } from "./work-
|
|
5
|
+
import { i as readDevInfo } from "./work-Bp1p39kq.mjs";
|
|
6
6
|
import { join } from "node:path";
|
|
7
7
|
//#region src/cli/link.ts
|
|
8
8
|
/**
|
|
@@ -109,8 +109,7 @@ function resolveLink(root, targets, board) {
|
|
|
109
109
|
nodesOf
|
|
110
110
|
};
|
|
111
111
|
}
|
|
112
|
-
|
|
113
|
-
async function devOrigin(root) {
|
|
112
|
+
async function findDev(root) {
|
|
114
113
|
const info = readDevInfo(root);
|
|
115
114
|
if (!info) return null;
|
|
116
115
|
try {
|
|
@@ -119,18 +118,31 @@ async function devOrigin(root) {
|
|
|
119
118
|
signal: AbortSignal.timeout(1500)
|
|
120
119
|
});
|
|
121
120
|
const data = await res.json().catch(() => null);
|
|
122
|
-
return res.ok && Array.isArray(data?.frames) ? `http://localhost:${info.port}/` : null;
|
|
121
|
+
return res.ok && Array.isArray(data?.frames) ? { origin: `http://localhost:${info.port}/` } : null;
|
|
123
122
|
} catch {
|
|
124
|
-
return
|
|
123
|
+
return info.pid !== void 0 ? { unreachable: {
|
|
124
|
+
pid: info.pid,
|
|
125
|
+
port: info.port
|
|
126
|
+
} } : null;
|
|
125
127
|
}
|
|
126
128
|
}
|
|
129
|
+
/** The dev server's origin when it is running in this repo and answers like `marver dev` - else null. */
|
|
130
|
+
async function devOrigin(root) {
|
|
131
|
+
const found = await findDev(root);
|
|
132
|
+
return found && "origin" in found ? found.origin : null;
|
|
133
|
+
}
|
|
134
|
+
/** A canvas that runs where this command cannot reach it: said so, never "start it" - a second start would only find
|
|
135
|
+
* the first one's lock. */
|
|
136
|
+
const unreachable = (pid) => `\`${NAME} dev\` runs (pid ${pid}) but cannot be reached from here - a sandbox?`;
|
|
127
137
|
const NOT_RUNNING = `\`${NAME} dev\` is not running in this repo - start it (\`npx ${NAME} dev\`), then run this again: the link carries its port`;
|
|
128
138
|
async function linkCommand(root, targets, opts) {
|
|
129
139
|
const r = resolveLink(root, targets, opts.board);
|
|
130
140
|
if (!r.links.length) throw new Error(r.hints.join("\n"));
|
|
131
|
-
const
|
|
132
|
-
if (!
|
|
141
|
+
const found = await findDev(root);
|
|
142
|
+
if (!found) throw new Error(NOT_RUNNING);
|
|
143
|
+
const origin = "origin" in found ? found.origin : `http://localhost:${found.unreachable.port}/`;
|
|
133
144
|
for (const l of r.links) console.log(`${origin}${l.hash}`);
|
|
145
|
+
if ("unreachable" in found) console.error(` ${unreachable(found.unreachable.pid)} The link is its port, from design/.local/dev.json - the person's browser reaches it`);
|
|
134
146
|
for (const h of r.hints) console.error(` ${h}`);
|
|
135
147
|
}
|
|
136
148
|
/** The hand-back other commands print after their own output - a link per board when `dev` runs,
|
|
@@ -157,4 +169,4 @@ async function handBack(root, targets) {
|
|
|
157
169
|
}
|
|
158
170
|
}
|
|
159
171
|
//#endregion
|
|
160
|
-
export { devOrigin, handBack, linkCommand, resolveLink, resolveTargets };
|
|
172
|
+
export { devOrigin, handBack, linkCommand, resolveLink, resolveTargets, unreachable };
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { r as NAME } from "./cli.mjs";
|
|
2
|
+
import { l as readRunning, n as formatRunning } from "./slots-DCDo3N0x.mjs";
|
|
3
|
+
//#region src/cli/ls.ts
|
|
4
|
+
/**
|
|
5
|
+
* `marver ls` (spec 28 A1.5): the canvases running on this Mac, read from the registry
|
|
6
|
+
* (~/.marver/running/) - slot, link, name, version, state, uptime, folder. Dead holders are hidden.
|
|
7
|
+
* No repo needed. `--json` for agents prints the public fields only: never a canvas's key or instance.
|
|
8
|
+
*/
|
|
9
|
+
function lsCommand(opts) {
|
|
10
|
+
const list = readRunning();
|
|
11
|
+
const now = Date.now();
|
|
12
|
+
if (opts.json) {
|
|
13
|
+
const canvases = list.map((r) => ({
|
|
14
|
+
slot: r.slot,
|
|
15
|
+
port: r.port,
|
|
16
|
+
url: r.url,
|
|
17
|
+
origin: r.origin,
|
|
18
|
+
name: r.name,
|
|
19
|
+
folder: r.root,
|
|
20
|
+
version: r.version,
|
|
21
|
+
state: r.state,
|
|
22
|
+
pid: r.pid,
|
|
23
|
+
startedAt: r.startedAt,
|
|
24
|
+
uptimeMs: Math.max(0, now - r.startedAt)
|
|
25
|
+
}));
|
|
26
|
+
console.log(JSON.stringify({ canvases }, null, 2));
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
if (!list.length) {
|
|
30
|
+
console.log(`\n no canvas runs on this Mac - npx ${NAME} dev starts one\n`);
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
console.log("");
|
|
34
|
+
for (const line of formatRunning(list, now)) console.log(` ${line}`);
|
|
35
|
+
console.log("");
|
|
36
|
+
}
|
|
37
|
+
//#endregion
|
|
38
|
+
export { lsCommand };
|
|
@@ -2,7 +2,7 @@ import { s as scanFrames } from "./manifest-Nl3KSVOk.mjs";
|
|
|
2
2
|
import { r as replay, t as asks } from "./events-CLH4ijKP.mjs";
|
|
3
3
|
import { a as readLog, i as listBoards } from "./comments-0BSbb04K.mjs";
|
|
4
4
|
import { o as projectMarks } from "./marks-CKgzucHZ.mjs";
|
|
5
|
-
import { answers } from "./queue-
|
|
5
|
+
import { answers } from "./queue-CAM_vNmX.mjs";
|
|
6
6
|
import { join } from "node:path";
|
|
7
7
|
//#region src/shared/marks.ts
|
|
8
8
|
const isNew = (m, id) => !!m && (m.changed[id] ?? 0) > (m.seen[id] ?? 0);
|