frameboard 0.4.0 → 0.5.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/README.md +2 -2
- package/dist/cli.js +356 -105
- package/dist/client/assets/index-D-VR2nQK.css +2 -0
- package/dist/client/assets/index-rlhpPZLV.js +111 -0
- package/dist/client/index.html +2 -2
- package/package.json +1 -1
- package/dist/client/assets/index-DOWds8pT.css +0 -2
- package/dist/client/assets/index-DPM4_A1Q.js +0 -111
package/README.md
CHANGED
|
@@ -38,13 +38,13 @@ Frames share one look through a `tokens.css` in the board folder, which a projec
|
|
|
38
38
|
|
|
39
39
|
Pin a note on a frame or one element with the Note tool, and Send hands it to a Claude Code session listening on the board. The agent answers in the note's thread through `notes reply` and closes it with `notes done`, and the notes stay in each page's `notes.json`.
|
|
40
40
|
|
|
41
|
-
An agent runs `editing` on a frame before rewriting it. The board then outlines the frame and tags it with the agent and how long it has held it, and a second session that tries to claim it is told it is taken. A claim lapses five minutes after the agent last ran `editing`, and a note sent from a claimed frame goes to the session holding it.
|
|
41
|
+
An agent runs `editing` on a frame before rewriting it. The board then outlines the frame and tags it with the agent and how long it has held it, and a second session that tries to claim it is told it is taken. A claim lapses five minutes after the agent last ran `editing`, and a note sent from a claimed frame goes to the session holding it. When you move, resize, edit, rename, or delete a claimed frame, your edit waits until the claim ends, under a card naming the agent. A move, resize, or element edit then goes only if the agent left the frame as you saw it, and a rename or delete goes once the claim ends.
|
|
42
42
|
|
|
43
43
|
When an agent writes a frame, the board marks it with a dot and counts it on its page and project until you look at it. A toast names the agent and offers Show, which takes you to the change and makes the edited elements glow, and Next, or `]`, steps to the next one.
|
|
44
44
|
|
|
45
45
|
The Claude Code plugin in `plugins/frameboard/` runs the static checks after each agent write and hands the findings back in the same turn. Its monitor runs `inbox --follow` for the session, so a sent note reaches the agent at once. `frameboard docs` prints every command, flag, record shape, and exit code.
|
|
46
46
|
|
|
47
|
-
In the board you move and resize frames, add, rename, reorder, delete, and search pages, and add a frame at a phone, tablet, or desktop size with the Frame tool. On the home view, New project adds a project, and a card's right-click menu opens, renames, duplicates, or deletes one. The inspector edits a selected element's name, opacity, radius, type size, weight, alignment, fill, stroke color, shadow, and text, offers the project's tokens first, and flags a color no token names. The layers panel selects, renames, restacks, hides, and locks frames, and Cmd+D, Cmd+C, Cmd+X, and Cmd+V duplicate, copy, cut, and paste them across pages and projects. Undo any of it with Cmd+Z. An undo of something an agent has changed since is refused and named on the board, so it never reverts the agent's work. Releases before 1.0 ship the board in stages, and the rest of editing by hand arrives in later 0.x releases.
|
|
47
|
+
In the board you move and resize frames, add, rename, reorder, delete, and search pages, and add a frame at a phone, tablet, or desktop size with the Frame tool. On the home view, New project adds a project, and a card's right-click menu opens, renames, duplicates, or deletes one. The inspector edits a selected element's name, opacity, radius, type size, weight, alignment, fill, stroke color, shadow, and text, offers the project's tokens first, and flags a color no token names. The layers panel selects, renames, restacks, hides, and locks frames, and Cmd+D, Cmd+C, Cmd+X, and Cmd+V duplicate, copy, cut, and paste them across pages and projects. Cmd+F finds a frame, an element, or a line of copy on any page of the project and jumps to it. Undo any of it with Cmd+Z. An undo of something an agent has changed since is refused and named on the board, so it never reverts the agent's work. Releases before 1.0 ship the board in stages, and the rest of editing by hand arrives in later 0.x releases.
|
|
48
48
|
|
|
49
49
|
## Requirements
|
|
50
50
|
|
package/dist/cli.js
CHANGED
|
@@ -9360,7 +9360,7 @@ async function isDirectory(path) {
|
|
|
9360
9360
|
}
|
|
9361
9361
|
//#endregion
|
|
9362
9362
|
//#region package.json
|
|
9363
|
-
var version$1 = "0.
|
|
9363
|
+
var version$1 = "0.5.0";
|
|
9364
9364
|
var dependencies = { "playwright-core": "1.64.1" };
|
|
9365
9365
|
//#endregion
|
|
9366
9366
|
//#region src/shared/version.ts
|
|
@@ -9383,7 +9383,7 @@ const addressFileSchema = looseObject({
|
|
|
9383
9383
|
//#endregion
|
|
9384
9384
|
//#region src/server/address.ts
|
|
9385
9385
|
/** How long a live server has to answer the health check. */
|
|
9386
|
-
const HEALTH_TIMEOUT_MS =
|
|
9386
|
+
const HEALTH_TIMEOUT_MS = 5e3;
|
|
9387
9387
|
function addressPath(root) {
|
|
9388
9388
|
return join(root, RUN_FOLDER, ADDRESS_FILE);
|
|
9389
9389
|
}
|
|
@@ -9438,7 +9438,7 @@ async function removeAddress(root, token) {
|
|
|
9438
9438
|
}
|
|
9439
9439
|
/**
|
|
9440
9440
|
* The server recorded for this board when it is live: its pid answers and its
|
|
9441
|
-
* health check answers within
|
|
9441
|
+
* health check answers within 5000 ms with the same root. Anything else is
|
|
9442
9442
|
* stale, and a new `serve` replaces it.
|
|
9443
9443
|
*/
|
|
9444
9444
|
async function findLiveServer(root) {
|
|
@@ -13548,6 +13548,124 @@ async function readAuthor(root, env = process.env) {
|
|
|
13548
13548
|
}
|
|
13549
13549
|
}
|
|
13550
13550
|
//#endregion
|
|
13551
|
+
//#region src/shared/records/claims.ts
|
|
13552
|
+
/** One session's hold on a frame while its agent rewrites it. */
|
|
13553
|
+
const claimSchema = looseObject({
|
|
13554
|
+
/** The canonical frame ref, `<project>/<page>/<frame>`. */
|
|
13555
|
+
frame: string$1(),
|
|
13556
|
+
/** The session holding it, the id `inbox` and a note's `to` use. */
|
|
13557
|
+
session: string$1(),
|
|
13558
|
+
/** The agent's name, such as `claude`, whose first letter the board shows. */
|
|
13559
|
+
agent: string$1(),
|
|
13560
|
+
/** The listener's tag form, `<agent> · <project folder>`. */
|
|
13561
|
+
tag: string$1(),
|
|
13562
|
+
/** When the session first claimed it, kept across renewals. */
|
|
13563
|
+
claimedAt: string$1(),
|
|
13564
|
+
/** When it lapses unless the session claims it again. */
|
|
13565
|
+
expiresAt: string$1()
|
|
13566
|
+
});
|
|
13567
|
+
/**
|
|
13568
|
+
* Whether a write naming `ref` reaches the frame a claim holds, being the
|
|
13569
|
+
* frame itself, its page, or its project, so a page ref never matches a
|
|
13570
|
+
* sibling page whose name only starts the same.
|
|
13571
|
+
*/
|
|
13572
|
+
function claimCovers(ref, frame) {
|
|
13573
|
+
return frame === ref || frame.startsWith(`${ref}/`);
|
|
13574
|
+
}
|
|
13575
|
+
/** `.run/claims.json`. */
|
|
13576
|
+
const claimsFileSchema = looseObject({
|
|
13577
|
+
version: literal(1),
|
|
13578
|
+
claims: array$1(claimSchema)
|
|
13579
|
+
});
|
|
13580
|
+
//#endregion
|
|
13581
|
+
//#region src/server/claims/store.ts
|
|
13582
|
+
/** How long a claim holds after its last claim or renewal. */
|
|
13583
|
+
const CLAIM_TTL_MS = 3e5;
|
|
13584
|
+
const claimsSpec = {
|
|
13585
|
+
schema: claimsFileSchema,
|
|
13586
|
+
invalidCode: "claims-invalid",
|
|
13587
|
+
empty: () => ({
|
|
13588
|
+
version: 1,
|
|
13589
|
+
claims: []
|
|
13590
|
+
})
|
|
13591
|
+
};
|
|
13592
|
+
function claimsPath(root) {
|
|
13593
|
+
return join(root, RUN_FOLDER, CLAIMS_FILE);
|
|
13594
|
+
}
|
|
13595
|
+
function isLive(claim, now) {
|
|
13596
|
+
return Date.parse(claim.expiresAt) > now.getTime();
|
|
13597
|
+
}
|
|
13598
|
+
/** The claims still live at `now`, refusing a file that does not parse. */
|
|
13599
|
+
async function readClaims(root, now) {
|
|
13600
|
+
return (await readRecord(claimsPath(root), claimsSpec)).claims.filter((claim) => isLive(claim, now));
|
|
13601
|
+
}
|
|
13602
|
+
/**
|
|
13603
|
+
* Claims a frame for a session, or renews the session's own claim keeping
|
|
13604
|
+
* `claimedAt`. A frame another session holds live refuses `frame-claimed`.
|
|
13605
|
+
*/
|
|
13606
|
+
async function claim(root, fields, now) {
|
|
13607
|
+
await ensureRunFolder(root);
|
|
13608
|
+
return (await updateRecord(claimsPath(root), claimsSpec, (file) => {
|
|
13609
|
+
const live = file.claims.filter((each) => isLive(each, now));
|
|
13610
|
+
const current = live.find((each) => each.frame === fields.frame);
|
|
13611
|
+
if (current && current.session !== fields.session) throw new FrameboardError("frame-claimed", `${current.tag} is editing ${fields.frame} until ${current.expiresAt}.`, {
|
|
13612
|
+
frame: current.frame,
|
|
13613
|
+
session: current.session,
|
|
13614
|
+
tag: current.tag,
|
|
13615
|
+
expiresAt: current.expiresAt
|
|
13616
|
+
});
|
|
13617
|
+
const held = {
|
|
13618
|
+
...fields,
|
|
13619
|
+
claimedAt: current?.claimedAt ?? now.toISOString(),
|
|
13620
|
+
expiresAt: new Date(now.getTime() + CLAIM_TTL_MS).toISOString()
|
|
13621
|
+
};
|
|
13622
|
+
return {
|
|
13623
|
+
...file,
|
|
13624
|
+
claims: [...live.filter((each) => each !== current), held]
|
|
13625
|
+
};
|
|
13626
|
+
})).claims.at(-1);
|
|
13627
|
+
}
|
|
13628
|
+
/**
|
|
13629
|
+
* Drops a session's claim on one frame, or every claim it holds when no
|
|
13630
|
+
* frame is named, returning what it dropped.
|
|
13631
|
+
*/
|
|
13632
|
+
async function release(root, session, frame, now) {
|
|
13633
|
+
const dropped = [];
|
|
13634
|
+
await ensureRunFolder(root);
|
|
13635
|
+
await updateRecord(claimsPath(root), claimsSpec, (file) => {
|
|
13636
|
+
const kept = [];
|
|
13637
|
+
for (const each of file.claims) {
|
|
13638
|
+
if (!isLive(each, now)) continue;
|
|
13639
|
+
(each.session === session && (frame === void 0 || each.frame === frame) ? dropped : kept).push(each);
|
|
13640
|
+
}
|
|
13641
|
+
return {
|
|
13642
|
+
...file,
|
|
13643
|
+
claims: kept
|
|
13644
|
+
};
|
|
13645
|
+
});
|
|
13646
|
+
return dropped;
|
|
13647
|
+
}
|
|
13648
|
+
//#endregion
|
|
13649
|
+
//#region src/server/claims/gate.ts
|
|
13650
|
+
/**
|
|
13651
|
+
* Refuses `frame-claimed` when another session holds a frame the hand write
|
|
13652
|
+
* would change. Each ref is a frame, page, or project ref, and a page or
|
|
13653
|
+
* project ref matches every claim under it. The claims are read without the
|
|
13654
|
+
* lock, so a claim landing between this read and the write lets that one
|
|
13655
|
+
* write through, where the file hash still guards the agent's own write.
|
|
13656
|
+
*/
|
|
13657
|
+
async function refuseClaimed(root, refs, now) {
|
|
13658
|
+
if (refs.length === 0) return;
|
|
13659
|
+
const held = (await readClaims(root, now)).find((claim) => refs.some((ref) => claimCovers(ref, claim.frame)));
|
|
13660
|
+
if (!held) return;
|
|
13661
|
+
throw new FrameboardError("frame-claimed", `${held.tag} is editing ${held.frame} until ${held.expiresAt}.`, {
|
|
13662
|
+
frame: held.frame,
|
|
13663
|
+
tag: held.tag,
|
|
13664
|
+
claimedAt: held.claimedAt,
|
|
13665
|
+
expiresAt: held.expiresAt
|
|
13666
|
+
});
|
|
13667
|
+
}
|
|
13668
|
+
//#endregion
|
|
13551
13669
|
//#region node_modules/picocolors/picocolors.js
|
|
13552
13670
|
var require_picocolors = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
13553
13671
|
let p = process || {};
|
|
@@ -27616,6 +27734,7 @@ const STATUS$4 = {
|
|
|
27616
27734
|
"page-not-found": 404,
|
|
27617
27735
|
"frame-not-found": 404,
|
|
27618
27736
|
"stale-layout": 409,
|
|
27737
|
+
"frame-claimed": 409,
|
|
27619
27738
|
"frame-locked": 423,
|
|
27620
27739
|
"layout-invalid": 422,
|
|
27621
27740
|
"lock-timeout": 503
|
|
@@ -27683,6 +27802,8 @@ function apiRoutes(root, actions, look, history) {
|
|
|
27683
27802
|
}, 400);
|
|
27684
27803
|
const { page, boxes, expected } = body.data;
|
|
27685
27804
|
try {
|
|
27805
|
+
const target = await resolvePageRef(root, page, { cwd: root });
|
|
27806
|
+
await refuseClaimed(root, Object.keys(boxes).map((name) => `${target.project}/${target.name}/${name}`), /* @__PURE__ */ new Date());
|
|
27686
27807
|
const journal = history?.journal();
|
|
27687
27808
|
const frames = await setBoxes(root, page, boxes, expected, {
|
|
27688
27809
|
cwd: root,
|
|
@@ -28616,6 +28737,7 @@ const STATUS$3 = {
|
|
|
28616
28737
|
"frame-not-found": 404,
|
|
28617
28738
|
"name-taken": 409,
|
|
28618
28739
|
"stale-layout": 409,
|
|
28740
|
+
"frame-claimed": 409,
|
|
28619
28741
|
"undo-overtaken": 409,
|
|
28620
28742
|
"nothing-to-undo": 409,
|
|
28621
28743
|
"frame-locked": 423,
|
|
@@ -28682,6 +28804,7 @@ function editRoutes(root, access, history) {
|
|
|
28682
28804
|
const body = await parseBody$1(c.req.raw, editSchema);
|
|
28683
28805
|
const frame = await resolveFrameRef(root, body.ref, { cwd: root });
|
|
28684
28806
|
const ref = `${frame.project}/${frame.page}/${frame.name}`;
|
|
28807
|
+
await refuseClaimed(root, [ref], /* @__PURE__ */ new Date());
|
|
28685
28808
|
const before = readFileSync(frame.path);
|
|
28686
28809
|
const result = editFrameFile(frame.path, {
|
|
28687
28810
|
index: body.index,
|
|
@@ -34243,23 +34366,148 @@ function elementsRoutes(root, access, selection, tokens = null) {
|
|
|
34243
34366
|
});
|
|
34244
34367
|
return app;
|
|
34245
34368
|
}
|
|
34369
|
+
/** How much of a text hit's text shows before the match, and in all. */
|
|
34370
|
+
const SNIPPET_BEFORE = 20;
|
|
34371
|
+
const SNIPPET_LENGTH = 80;
|
|
34372
|
+
/** Elements whose text is code rather than copy. */
|
|
34373
|
+
const NOT_COPY = /* @__PURE__ */ new Set(["script", "style"]);
|
|
34374
|
+
/**
|
|
34375
|
+
* Every hit for `query` across the shown frames of a project, in page order
|
|
34376
|
+
* and then stacking order, matching case-insensitively against each frame's
|
|
34377
|
+
* name, each element's name by the layers rule, and each element's own text.
|
|
34378
|
+
* An element named by its own text hits as text alone, so it is not listed
|
|
34379
|
+
* twice, and a frame `elementTree` refuses hits by its name alone.
|
|
34380
|
+
*/
|
|
34381
|
+
async function findInProject(root, project, query) {
|
|
34382
|
+
const { name } = await resolveProject(root, project);
|
|
34383
|
+
const needle = query.trim().toLowerCase();
|
|
34384
|
+
if (needle === "") return {
|
|
34385
|
+
project: name,
|
|
34386
|
+
query,
|
|
34387
|
+
hits: [],
|
|
34388
|
+
truncated: false
|
|
34389
|
+
};
|
|
34390
|
+
const frames = (await scanProject(root, name)).pages.flatMap((page) => page.frames.filter((frame) => !frame.hidden));
|
|
34391
|
+
const hits = (await Promise.all(frames.map((frame) => frameHits(frame, needle)))).flat();
|
|
34392
|
+
return {
|
|
34393
|
+
project: name,
|
|
34394
|
+
query,
|
|
34395
|
+
hits: hits.slice(0, 200),
|
|
34396
|
+
truncated: hits.length > 200
|
|
34397
|
+
};
|
|
34398
|
+
}
|
|
34399
|
+
async function frameHits(frame, needle) {
|
|
34400
|
+
let bytes;
|
|
34401
|
+
try {
|
|
34402
|
+
bytes = await readFile(frame.path);
|
|
34403
|
+
} catch (error) {
|
|
34404
|
+
if (isCode(error, "ENOENT")) return [];
|
|
34405
|
+
throw error;
|
|
34406
|
+
}
|
|
34407
|
+
const base = {
|
|
34408
|
+
page: frame.page,
|
|
34409
|
+
frame: frame.name,
|
|
34410
|
+
ref: frame.ref
|
|
34411
|
+
};
|
|
34412
|
+
const hits = [];
|
|
34413
|
+
if (frame.name.toLowerCase().includes(needle)) hits.push({
|
|
34414
|
+
...base,
|
|
34415
|
+
kind: "frame",
|
|
34416
|
+
index: null,
|
|
34417
|
+
hash: null,
|
|
34418
|
+
name: frame.name,
|
|
34419
|
+
snippet: null
|
|
34420
|
+
});
|
|
34421
|
+
const source = bytes.toString("utf8");
|
|
34422
|
+
const rows = elementTree(source);
|
|
34423
|
+
if (!Array.isArray(rows)) return hits;
|
|
34424
|
+
const hash = contentHash(bytes);
|
|
34425
|
+
const { elements } = parseFrame(source);
|
|
34426
|
+
for (const row of rows) {
|
|
34427
|
+
const element = elements[row.index];
|
|
34428
|
+
if (!element) continue;
|
|
34429
|
+
const text = NOT_COPY.has(row.tag) ? "" : directText(element);
|
|
34430
|
+
const at = text.toLowerCase().indexOf(needle);
|
|
34431
|
+
const namedByText = row.textOnly && !hasDataName(element);
|
|
34432
|
+
const address = {
|
|
34433
|
+
...base,
|
|
34434
|
+
index: row.index,
|
|
34435
|
+
hash,
|
|
34436
|
+
name: row.name
|
|
34437
|
+
};
|
|
34438
|
+
if (at !== -1) hits.push({
|
|
34439
|
+
...address,
|
|
34440
|
+
kind: "text",
|
|
34441
|
+
snippet: snippet(text, at)
|
|
34442
|
+
});
|
|
34443
|
+
else if (!namedByText && row.name.toLowerCase().includes(needle)) hits.push({
|
|
34444
|
+
...address,
|
|
34445
|
+
kind: "element",
|
|
34446
|
+
snippet: null
|
|
34447
|
+
});
|
|
34448
|
+
}
|
|
34449
|
+
return hits;
|
|
34450
|
+
}
|
|
34451
|
+
/**
|
|
34452
|
+
* The element's own text nodes joined and whitespace-collapsed, leaving out
|
|
34453
|
+
* its children's text, so a phrase split by an inline child is found by
|
|
34454
|
+
* either side and the hit selects the element holding it.
|
|
34455
|
+
*/
|
|
34456
|
+
function directText(element) {
|
|
34457
|
+
return element.childNodes.filter((node) => node.nodeName === "#text").map((node) => node.value).join(" ").replace(/\s+/g, " ").trim();
|
|
34458
|
+
}
|
|
34459
|
+
function hasDataName(element) {
|
|
34460
|
+
return element.attrs.some((attr) => attr.name === "data-name" && attr.value.trim() !== "");
|
|
34461
|
+
}
|
|
34462
|
+
function snippet(text, at) {
|
|
34463
|
+
const start = Math.max(0, at - SNIPPET_BEFORE);
|
|
34464
|
+
const end = start + SNIPPET_LENGTH;
|
|
34465
|
+
return `${start > 0 ? "…" : ""}${text.slice(start, end)}${end < text.length ? "…" : ""}`;
|
|
34466
|
+
}
|
|
34467
|
+
//#endregion
|
|
34468
|
+
//#region src/server/routes/find.ts
|
|
34469
|
+
/** Longer than any name or line of copy anyone types into the field. */
|
|
34470
|
+
const MAX_QUERY = 200;
|
|
34471
|
+
/**
|
|
34472
|
+
* `GET /api/find?project=&q=` answers the `find` record over the project's
|
|
34473
|
+
* frame files, so a frame culled offscreen or on another page is found like
|
|
34474
|
+
* any other. It only reads, so it takes no writer guard.
|
|
34475
|
+
*/
|
|
34476
|
+
function findRoutes(root) {
|
|
34477
|
+
const app = new Hono();
|
|
34478
|
+
app.get("/api/find", async (c) => {
|
|
34479
|
+
const project = c.req.query("project");
|
|
34480
|
+
if (!project) throw new FrameboardError("usage", "Name the project as ?project=.");
|
|
34481
|
+
const query = c.req.query("q") ?? "";
|
|
34482
|
+
if (query.length > MAX_QUERY) throw new FrameboardError("usage", `Keep ?q= to ${MAX_QUERY} characters.`);
|
|
34483
|
+
const data = await findInProject(root, project, query);
|
|
34484
|
+
return c.json({
|
|
34485
|
+
ok: true,
|
|
34486
|
+
data
|
|
34487
|
+
});
|
|
34488
|
+
});
|
|
34489
|
+
app.onError(answerRefusal);
|
|
34490
|
+
return app;
|
|
34491
|
+
}
|
|
34246
34492
|
//#endregion
|
|
34247
34493
|
//#region src/server/routes/history.ts
|
|
34248
34494
|
/**
|
|
34249
34495
|
* Undo and redo of the board's own writes, behind `requireWriter`. Each
|
|
34250
34496
|
* answers the page to show and the frames the step touched, and refuses with
|
|
34251
|
-
* `undo-overtaken` when an agent changed what the step would write
|
|
34497
|
+
* `undo-overtaken` when an agent changed what the step would write, or
|
|
34498
|
+
* `frame-claimed`, keeping the step, while another session holds what it names.
|
|
34252
34499
|
*/
|
|
34253
34500
|
function historyRoutes(access, history) {
|
|
34254
34501
|
const app = new Hono();
|
|
34255
34502
|
const authorized = requireWriter(access);
|
|
34503
|
+
const unclaimed = (refs) => refuseClaimed(history.root, refs, /* @__PURE__ */ new Date());
|
|
34256
34504
|
app.post("/api/undo", authorized, async (c) => c.json({
|
|
34257
34505
|
ok: true,
|
|
34258
|
-
data: await history.undo()
|
|
34506
|
+
data: await history.undo(unclaimed)
|
|
34259
34507
|
}));
|
|
34260
34508
|
app.post("/api/redo", authorized, async (c) => c.json({
|
|
34261
34509
|
ok: true,
|
|
34262
|
-
data: await history.redo()
|
|
34510
|
+
data: await history.redo(unclaimed)
|
|
34263
34511
|
}));
|
|
34264
34512
|
app.onError(answerRefusal);
|
|
34265
34513
|
return app;
|
|
@@ -35356,6 +35604,18 @@ function structureRoutes(root, access, history) {
|
|
|
35356
35604
|
});
|
|
35357
35605
|
return result;
|
|
35358
35606
|
};
|
|
35607
|
+
/**
|
|
35608
|
+
* Refuses a write that would rename, move, or remove a frame another
|
|
35609
|
+
* session holds, before anything is written. Writes that leave every
|
|
35610
|
+
* existing frame file and box alone, being an add, a duplicate, a flag, a
|
|
35611
|
+
* copy, a paste, and a move of a page or frame in its order, go at once.
|
|
35612
|
+
*/
|
|
35613
|
+
const refuseHeld = (refs) => refuseClaimed(root, refs, /* @__PURE__ */ new Date());
|
|
35614
|
+
/** `refuseHeld` for frames as the body names them, read back to their canonical refs. */
|
|
35615
|
+
const refuseHeldFrames = async (frames) => {
|
|
35616
|
+
const records = await Promise.all(frames.map((frame) => readFrame$1(root, frame, { cwd })));
|
|
35617
|
+
await refuseHeld(records.map((record) => record.ref));
|
|
35618
|
+
};
|
|
35359
35619
|
const orderOf = async (project) => (await readPageOrder(join(root, project))).pages;
|
|
35360
35620
|
app.post("/api/page/add", async (c) => {
|
|
35361
35621
|
const body = await parseBody$1(c.req.raw, addSchema);
|
|
@@ -35402,6 +35662,7 @@ function structureRoutes(root, access, history) {
|
|
|
35402
35662
|
app.post("/api/page/rename", async (c) => {
|
|
35403
35663
|
const body = await parseBody$1(c.req.raw, renameSchema);
|
|
35404
35664
|
const source = await resolvePageRef(root, body.ref, { cwd });
|
|
35665
|
+
await refuseHeld([`${source.project}/${source.name}`]);
|
|
35405
35666
|
const page = await recorded((journal) => renamePage(root, body.ref, body.name, {
|
|
35406
35667
|
cwd,
|
|
35407
35668
|
journal
|
|
@@ -35435,6 +35696,7 @@ function structureRoutes(root, access, history) {
|
|
|
35435
35696
|
app.post("/api/page/delete", async (c) => {
|
|
35436
35697
|
const body = await parseBody$1(c.req.raw, deleteSchema);
|
|
35437
35698
|
const source = await resolvePageRef(root, body.ref, { cwd });
|
|
35699
|
+
await refuseHeld([`${source.project}/${source.name}`]);
|
|
35438
35700
|
const order = await orderOf(source.project);
|
|
35439
35701
|
const at = order.indexOf(source.name);
|
|
35440
35702
|
const beside = order[at + 1] ?? order[at - 1];
|
|
@@ -35494,6 +35756,7 @@ function structureRoutes(root, access, history) {
|
|
|
35494
35756
|
});
|
|
35495
35757
|
app.post("/api/frame/rename", async (c) => {
|
|
35496
35758
|
const body = await parseBody$1(c.req.raw, renameSchema);
|
|
35759
|
+
await refuseHeldFrames([body.ref]);
|
|
35497
35760
|
const frame = await recorded((journal) => renameFrame(root, body.ref, body.name, {
|
|
35498
35761
|
cwd,
|
|
35499
35762
|
journal
|
|
@@ -35530,6 +35793,7 @@ function structureRoutes(root, access, history) {
|
|
|
35530
35793
|
app.post("/api/frame/delete", async (c) => {
|
|
35531
35794
|
const body = await parseBody$1(c.req.raw, framesSchema);
|
|
35532
35795
|
await refuseLocked(body.refs);
|
|
35796
|
+
await refuseHeldFrames(body.refs);
|
|
35533
35797
|
const deleted = await eachFrame(body.refs, (frame, journal) => deleteFrame(root, frame, {
|
|
35534
35798
|
cwd,
|
|
35535
35799
|
journal
|
|
@@ -35555,6 +35819,7 @@ function structureRoutes(root, access, history) {
|
|
|
35555
35819
|
app.post("/api/clipboard/cut", async (c) => {
|
|
35556
35820
|
const body = await parseBody$1(c.req.raw, framesSchema);
|
|
35557
35821
|
await refuseLocked(body.refs);
|
|
35822
|
+
await refuseHeldFrames(body.refs);
|
|
35558
35823
|
const held = await holdFrames(root, body.refs, { cwd });
|
|
35559
35824
|
await eachFrame(body.refs, (frame, journal) => deleteFrame(root, frame, {
|
|
35560
35825
|
cwd,
|
|
@@ -35594,6 +35859,7 @@ function structureRoutes(root, access, history) {
|
|
|
35594
35859
|
});
|
|
35595
35860
|
app.post("/api/project/rename", async (c) => {
|
|
35596
35861
|
const body = await parseBody$1(c.req.raw, renameSchema);
|
|
35862
|
+
await refuseHeld([(await resolveProject(root, body.ref)).name]);
|
|
35597
35863
|
const project = await recorded((journal) => renameProject(root, body.ref, body.name, { journal }), onHome);
|
|
35598
35864
|
return c.json({
|
|
35599
35865
|
ok: true,
|
|
@@ -35610,6 +35876,7 @@ function structureRoutes(root, access, history) {
|
|
|
35610
35876
|
});
|
|
35611
35877
|
app.post("/api/project/delete", async (c) => {
|
|
35612
35878
|
const body = await parseBody$1(c.req.raw, projectSchema);
|
|
35879
|
+
await refuseHeld([(await resolveProject(root, body.ref)).name]);
|
|
35613
35880
|
const result = await recorded((journal) => deleteProject(root, body.ref, { journal }), onHome);
|
|
35614
35881
|
return c.json({
|
|
35615
35882
|
ok: true,
|
|
@@ -35667,6 +35934,7 @@ function createApp({ clientDir, root, port, actions, tickets, renderFrame, faces
|
|
|
35667
35934
|
app.route("/", notesRoutes(root, actions.access, delivery));
|
|
35668
35935
|
app.route("/", assetsRoutes(root, actions.access));
|
|
35669
35936
|
app.route("/", elementsRoutes(root, actions.access, selection, given));
|
|
35937
|
+
app.route("/", findRoutes(root));
|
|
35670
35938
|
app.route("/", editRoutes(root, actions.access, history));
|
|
35671
35939
|
app.route("/", pngRoutes(root, renderFrame));
|
|
35672
35940
|
if (checks) app.route("/", checkRoutes(actions.access, checks));
|
|
@@ -36695,8 +36963,19 @@ async function measure(browser, baseUrl, ref, box) {
|
|
|
36695
36963
|
}
|
|
36696
36964
|
function readContentSize() {
|
|
36697
36965
|
const root = document.documentElement;
|
|
36966
|
+
const crops = (element) => {
|
|
36967
|
+
const style = getComputedStyle(element);
|
|
36968
|
+
return style.overflowX !== "visible" || style.overflowY !== "visible";
|
|
36969
|
+
};
|
|
36970
|
+
const isCropped = (element) => {
|
|
36971
|
+
for (let parent = element.parentElement; parent && parent !== document.body; parent = parent.parentElement) if (crops(parent)) return true;
|
|
36972
|
+
return false;
|
|
36973
|
+
};
|
|
36698
36974
|
let bottom = root.getBoundingClientRect().bottom;
|
|
36699
|
-
for (const element of document.querySelectorAll("body *"))
|
|
36975
|
+
for (const element of document.querySelectorAll("body *")) {
|
|
36976
|
+
if (isCropped(element)) continue;
|
|
36977
|
+
bottom = Math.max(bottom, element.getBoundingClientRect().bottom);
|
|
36978
|
+
}
|
|
36700
36979
|
return {
|
|
36701
36980
|
height: Math.max(1, Math.ceil(bottom + window.scrollY)),
|
|
36702
36981
|
width: root.scrollWidth
|
|
@@ -36900,7 +37179,7 @@ async function checkPages(root, project, pages, context) {
|
|
|
36900
37179
|
//#endregion
|
|
36901
37180
|
//#region src/cli/board-server.ts
|
|
36902
37181
|
/** How long a running server has to answer before the verb gives up on it. */
|
|
36903
|
-
const REQUEST_TIMEOUT_MS =
|
|
37182
|
+
const REQUEST_TIMEOUT_MS = 5e3;
|
|
36904
37183
|
/**
|
|
36905
37184
|
* Posts to a running board server's write route with the address file's
|
|
36906
37185
|
* token, resolving the `data` of its envelope. `timeoutMs` lengthens the
|
|
@@ -37305,28 +37584,6 @@ const checkResultSchema = /* @__PURE__ */ object({
|
|
|
37305
37584
|
browser: /* @__PURE__ */ optional(browserRunSchema)
|
|
37306
37585
|
});
|
|
37307
37586
|
//#endregion
|
|
37308
|
-
//#region src/shared/records/claims.ts
|
|
37309
|
-
/** One session's hold on a frame while its agent rewrites it. */
|
|
37310
|
-
const claimSchema = looseObject({
|
|
37311
|
-
/** The canonical frame ref, `<project>/<page>/<frame>`. */
|
|
37312
|
-
frame: string$1(),
|
|
37313
|
-
/** The session holding it, the id `inbox` and a note's `to` use. */
|
|
37314
|
-
session: string$1(),
|
|
37315
|
-
/** The agent's name, such as `claude`, whose first letter the board shows. */
|
|
37316
|
-
agent: string$1(),
|
|
37317
|
-
/** The listener's tag form, `<agent> · <project folder>`. */
|
|
37318
|
-
tag: string$1(),
|
|
37319
|
-
/** When the session first claimed it, kept across renewals. */
|
|
37320
|
-
claimedAt: string$1(),
|
|
37321
|
-
/** When it lapses unless the session claims it again. */
|
|
37322
|
-
expiresAt: string$1()
|
|
37323
|
-
});
|
|
37324
|
-
/** `.run/claims.json`. */
|
|
37325
|
-
const claimsFileSchema = looseObject({
|
|
37326
|
-
version: literal(1),
|
|
37327
|
-
claims: array$1(claimSchema)
|
|
37328
|
-
});
|
|
37329
|
-
//#endregion
|
|
37330
37587
|
//#region src/shared/records/edit.ts
|
|
37331
37588
|
/** What `edit` returns: the frame it wrote, the element, and the hash the next edit is made from. */
|
|
37332
37589
|
const editResultSchema = object$1({
|
|
@@ -37377,6 +37634,36 @@ object$1({
|
|
|
37377
37634
|
colors: array$1(styleValueSchema)
|
|
37378
37635
|
});
|
|
37379
37636
|
//#endregion
|
|
37637
|
+
//#region src/shared/records/find.ts
|
|
37638
|
+
/** One match: a frame by its name, an element by its name, or an element's own text. */
|
|
37639
|
+
const findHitSchema = object$1({
|
|
37640
|
+
kind: _enum$1([
|
|
37641
|
+
"frame",
|
|
37642
|
+
"element",
|
|
37643
|
+
"text"
|
|
37644
|
+
]),
|
|
37645
|
+
page: string$1(),
|
|
37646
|
+
/** The frame's name. */
|
|
37647
|
+
frame: string$1(),
|
|
37648
|
+
/** The frame ref, `<project>/<page>/<frame>`. */
|
|
37649
|
+
ref: string$1(),
|
|
37650
|
+
/** The element's index as `edit --index` takes it, null for a frame hit. */
|
|
37651
|
+
index: int$1().min(0).nullable(),
|
|
37652
|
+
/** The hash of the file the index was read from, null for a frame hit. */
|
|
37653
|
+
hash: string$1().regex(/^[0-9a-f]{64}$/).nullable(),
|
|
37654
|
+
/** The frame's name for a frame hit, else the element's name by the layers rule. */
|
|
37655
|
+
name: string$1(),
|
|
37656
|
+
/** A text hit's own text around the match, null for any other hit. */
|
|
37657
|
+
snippet: string$1().nullable()
|
|
37658
|
+
});
|
|
37659
|
+
/** What `GET /api/find` answers, in page order, with `truncated` set once the hits were cut. */
|
|
37660
|
+
const findResultSchema = object$1({
|
|
37661
|
+
project: string$1(),
|
|
37662
|
+
query: string$1(),
|
|
37663
|
+
hits: array$1(findHitSchema),
|
|
37664
|
+
truncated: boolean$1()
|
|
37665
|
+
});
|
|
37666
|
+
//#endregion
|
|
37380
37667
|
//#region src/shared/records/inspect.ts
|
|
37381
37668
|
const themeSchema = _enum$1(["light", "dark"]);
|
|
37382
37669
|
/** One rendered element, addressed by the index `edit --index` takes. */
|
|
@@ -37460,7 +37747,8 @@ const RECORDS = {
|
|
|
37460
37747
|
assetList: assetListSchema,
|
|
37461
37748
|
assetAdd: assetAddResultSchema,
|
|
37462
37749
|
elements: elementTreeSchema,
|
|
37463
|
-
selection: selectionResultSchema
|
|
37750
|
+
selection: selectionResultSchema,
|
|
37751
|
+
find: findResultSchema
|
|
37464
37752
|
};
|
|
37465
37753
|
//#endregion
|
|
37466
37754
|
//#region src/cli/docs/content-format.ts
|
|
@@ -37613,74 +37901,6 @@ function registerEdit(program, context) {
|
|
|
37613
37901
|
});
|
|
37614
37902
|
}
|
|
37615
37903
|
//#endregion
|
|
37616
|
-
//#region src/server/claims/store.ts
|
|
37617
|
-
/** How long a claim holds after its last claim or renewal. */
|
|
37618
|
-
const CLAIM_TTL_MS = 3e5;
|
|
37619
|
-
const claimsSpec = {
|
|
37620
|
-
schema: claimsFileSchema,
|
|
37621
|
-
invalidCode: "claims-invalid",
|
|
37622
|
-
empty: () => ({
|
|
37623
|
-
version: 1,
|
|
37624
|
-
claims: []
|
|
37625
|
-
})
|
|
37626
|
-
};
|
|
37627
|
-
function claimsPath(root) {
|
|
37628
|
-
return join(root, RUN_FOLDER, CLAIMS_FILE);
|
|
37629
|
-
}
|
|
37630
|
-
function isLive(claim, now) {
|
|
37631
|
-
return Date.parse(claim.expiresAt) > now.getTime();
|
|
37632
|
-
}
|
|
37633
|
-
/** The claims still live at `now`, refusing a file that does not parse. */
|
|
37634
|
-
async function readClaims(root, now) {
|
|
37635
|
-
return (await readRecord(claimsPath(root), claimsSpec)).claims.filter((claim) => isLive(claim, now));
|
|
37636
|
-
}
|
|
37637
|
-
/**
|
|
37638
|
-
* Claims a frame for a session, or renews the session's own claim keeping
|
|
37639
|
-
* `claimedAt`. A frame another session holds live refuses `frame-claimed`.
|
|
37640
|
-
*/
|
|
37641
|
-
async function claim(root, fields, now) {
|
|
37642
|
-
await ensureRunFolder(root);
|
|
37643
|
-
return (await updateRecord(claimsPath(root), claimsSpec, (file) => {
|
|
37644
|
-
const live = file.claims.filter((each) => isLive(each, now));
|
|
37645
|
-
const current = live.find((each) => each.frame === fields.frame);
|
|
37646
|
-
if (current && current.session !== fields.session) throw new FrameboardError("frame-claimed", `${current.tag} is editing ${fields.frame} until ${current.expiresAt}.`, {
|
|
37647
|
-
frame: current.frame,
|
|
37648
|
-
session: current.session,
|
|
37649
|
-
tag: current.tag,
|
|
37650
|
-
expiresAt: current.expiresAt
|
|
37651
|
-
});
|
|
37652
|
-
const held = {
|
|
37653
|
-
...fields,
|
|
37654
|
-
claimedAt: current?.claimedAt ?? now.toISOString(),
|
|
37655
|
-
expiresAt: new Date(now.getTime() + CLAIM_TTL_MS).toISOString()
|
|
37656
|
-
};
|
|
37657
|
-
return {
|
|
37658
|
-
...file,
|
|
37659
|
-
claims: [...live.filter((each) => each !== current), held]
|
|
37660
|
-
};
|
|
37661
|
-
})).claims.at(-1);
|
|
37662
|
-
}
|
|
37663
|
-
/**
|
|
37664
|
-
* Drops a session's claim on one frame, or every claim it holds when no
|
|
37665
|
-
* frame is named, returning what it dropped.
|
|
37666
|
-
*/
|
|
37667
|
-
async function release(root, session, frame, now) {
|
|
37668
|
-
const dropped = [];
|
|
37669
|
-
await ensureRunFolder(root);
|
|
37670
|
-
await updateRecord(claimsPath(root), claimsSpec, (file) => {
|
|
37671
|
-
const kept = [];
|
|
37672
|
-
for (const each of file.claims) {
|
|
37673
|
-
if (!isLive(each, now)) continue;
|
|
37674
|
-
(each.session === session && (frame === void 0 || each.frame === frame) ? dropped : kept).push(each);
|
|
37675
|
-
}
|
|
37676
|
-
return {
|
|
37677
|
-
...file,
|
|
37678
|
-
claims: kept
|
|
37679
|
-
};
|
|
37680
|
-
});
|
|
37681
|
-
return dropped;
|
|
37682
|
-
}
|
|
37683
|
-
//#endregion
|
|
37684
37904
|
//#region src/cli/session.ts
|
|
37685
37905
|
/** The variable Claude Code sets to the session a command runs in. */
|
|
37686
37906
|
const SESSION_ENV = "CLAUDE_CODE_SESSION_ID";
|
|
@@ -42511,6 +42731,7 @@ async function exists(path) {
|
|
|
42511
42731
|
throw error;
|
|
42512
42732
|
}
|
|
42513
42733
|
}
|
|
42734
|
+
const OPEN = async () => {};
|
|
42514
42735
|
/**
|
|
42515
42736
|
* The developer's undo and redo stacks, in memory, holding the board's own
|
|
42516
42737
|
* writes and never an agent's. Undo and redo run one at a time, each
|
|
@@ -42550,16 +42771,46 @@ var History = class {
|
|
|
42550
42771
|
this.onChange(this.counts());
|
|
42551
42772
|
this.onWrite(step);
|
|
42552
42773
|
}
|
|
42553
|
-
|
|
42554
|
-
|
|
42774
|
+
/**
|
|
42775
|
+
* The refs the top undo or redo step would write, without popping it, so a
|
|
42776
|
+
* route can refuse a claimed frame before the step is taken. These are the
|
|
42777
|
+
* step's frames, and the page or project folder and frame file each move
|
|
42778
|
+
* or removal names, since a page or project step names no frames.
|
|
42779
|
+
*/
|
|
42780
|
+
peek(side) {
|
|
42781
|
+
const step = (side === "undo" ? this.#undo : this.#redo).at(-1);
|
|
42782
|
+
if (!step) return [];
|
|
42783
|
+
const refs = step.changes.flatMap((change) => {
|
|
42784
|
+
if (change.kind === "moved") return [change.from, change.to];
|
|
42785
|
+
if (change.kind === "path") return [change.path];
|
|
42786
|
+
return [];
|
|
42787
|
+
}).flatMap((path) => {
|
|
42788
|
+
const inBoard = relative(this.root, path);
|
|
42789
|
+
if (inBoard === "" || inBoard.startsWith("..") || isAbsolute(inBoard)) return [];
|
|
42790
|
+
const ref = inBoard.split(sep).join("/");
|
|
42791
|
+
return [ref.endsWith(".html") ? ref.slice(0, -5) : ref];
|
|
42792
|
+
});
|
|
42793
|
+
return [.../* @__PURE__ */ new Set([...step.frames, ...refs])];
|
|
42794
|
+
}
|
|
42795
|
+
/**
|
|
42796
|
+
* Undoes the top step. `gate` reads what `peek` names of that step in turn,
|
|
42797
|
+
* before it is taken, so a refusal it throws leaves the step on its stack
|
|
42798
|
+
* and a quick second undo never checks one step and takes another.
|
|
42799
|
+
*/
|
|
42800
|
+
undo(gate = OPEN) {
|
|
42801
|
+
return this.#inTurn(() => this.#move(this.#undo, this.#redo, "before", gate));
|
|
42555
42802
|
}
|
|
42556
|
-
|
|
42557
|
-
|
|
42803
|
+
/** Redoes the top step, gated as `undo` is. */
|
|
42804
|
+
redo(gate = OPEN) {
|
|
42805
|
+
return this.#inTurn(() => this.#move(this.#redo, this.#undo, "after", gate));
|
|
42558
42806
|
}
|
|
42559
42807
|
/** Takes the top step of `from`, writes `to` side of it, and pushes it onto `onto`. */
|
|
42560
|
-
async #move(from, onto, to) {
|
|
42808
|
+
async #move(from, onto, to, gate) {
|
|
42809
|
+
const empty = () => new FrameboardError("nothing-to-undo", `There is nothing to ${to === "before" ? "undo" : "redo"}.`);
|
|
42810
|
+
if (from.length === 0) throw empty();
|
|
42811
|
+
await gate(this.peek(from === this.#undo ? "undo" : "redo"));
|
|
42561
42812
|
const step = from.pop();
|
|
42562
|
-
if (!step) throw
|
|
42813
|
+
if (!step) throw empty();
|
|
42563
42814
|
const was = to === "before" ? "after" : "before";
|
|
42564
42815
|
const locks = step.changes.flatMap(lockPaths).filter((path) => existsSync(dirname(path)));
|
|
42565
42816
|
try {
|