@dexhq/canvas 0.17.0 → 0.18.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 +31 -0
- package/app/canvas/canvas-commands.ts +2 -10
- package/app/canvas/canvas-context.tsx +11 -2
- package/app/canvas/canvas-document.ts +5 -1
- package/app/canvas/canvas-keys.ts +1 -1
- package/app/canvas/canvas-model.ts +195 -20
- package/app/canvas/canvas-scene.ts +176 -171
- package/app/canvas/canvas-ui.ts +4 -11
- package/app/canvas/canvas.css +159 -179
- package/app/canvas/change-pictures.tsx +156 -0
- package/app/canvas/comment-drafts.ts +31 -0
- package/app/canvas/comment-layer.tsx +125 -71
- package/app/canvas/comments.tsx +38 -2
- package/app/canvas/element-picker.ts +20 -0
- package/app/canvas/engine/canvas-gestures.ts +15 -3
- package/app/canvas/engine/canvas-store.ts +5 -0
- package/app/canvas/engine/canvas-view.tsx +22 -5
- package/app/canvas/find-bar.tsx +57 -41
- package/app/canvas/flow-canvas.tsx +147 -272
- package/app/canvas/frame-copies.ts +14 -17
- package/app/canvas/frame-drops.ts +15 -7
- package/app/canvas/frame-inspector.ts +192 -41
- package/app/canvas/frame-node.tsx +123 -75
- package/app/canvas/frame-resize.tsx +321 -83
- package/app/canvas/insert-hint.tsx +5 -15
- package/app/canvas/inspect-layer.tsx +73 -19
- package/app/canvas/label-action.tsx +13 -2
- package/app/canvas/layout.ts +233 -98
- package/app/canvas/live-page.ts +5 -0
- package/app/canvas/new-frame.ts +10 -25
- package/app/canvas/note-placing.ts +55 -84
- package/app/canvas/picked-box.tsx +5 -0
- package/app/canvas/picks-menu.tsx +3 -9
- package/app/canvas/readable-colour.ts +52 -0
- package/app/canvas/request-node.tsx +19 -10
- package/app/canvas/scrolling-page.ts +45 -0
- package/app/canvas/section-node.tsx +36 -53
- package/app/canvas/settle.ts +21 -0
- package/app/canvas/snapping.ts +96 -8
- package/app/canvas/spec-frame.tsx +8 -5
- package/app/canvas/spot-pins.tsx +15 -3
- package/app/canvas/stack-frame.tsx +13 -57
- package/app/canvas/stack-model.ts +5 -0
- package/app/canvas/stack-toggle.tsx +89 -0
- package/app/canvas/styles-layer.tsx +23 -43
- package/app/canvas/text-layer.tsx +26 -10
- package/app/canvas/thread-focus.tsx +18 -1
- package/app/canvas/tool-cursors.ts +2 -2
- package/app/canvas/toolbar-parts.tsx +48 -8
- package/app/canvas/toolbar.tsx +12 -10
- package/app/canvas/use-canvas-clipboard.tsx +13 -5
- package/app/canvas/use-reveal.ts +86 -0
- package/app/editor/extensions.ts +2 -0
- package/app/editor/line-break-caret.ts +57 -0
- package/app/git/branch-panel.tsx +61 -20
- package/app/i18n/locales/en/messages.po +64 -17
- package/app/i18n/locales/en/messages.ts +1 -1
- package/app/i18n/locales/pseudo/messages.po +64 -17
- package/app/i18n/locales/pseudo/messages.ts +1 -1
- package/app/icons/glyphs.tsx +2 -0
- package/app/live/studio-live.ts +29 -9
- package/app/pages/canvas.tsx +1 -1
- package/app/pages/commands-settings.tsx +70 -76
- package/app/pages/play-bar.tsx +6 -11
- package/app/pages/play.tsx +52 -33
- package/app/shell/feedback-form.tsx +29 -5
- package/app/ui/prompt-editor.tsx +2 -0
- package/app/ui/use-field-list.ts +90 -0
- package/dist/cli/commands/mcp.mjs +6 -4
- package/dist/cli/mcp-relay.mjs +10 -6
- package/dist/content/content.d.mts +26 -9
- package/dist/content/content.mjs +65 -8
- package/dist/content/screenshot.d.mts +2 -0
- package/dist/content/screenshot.mjs +3 -0
- package/dist/content/snapshot-client.d.mts +2 -0
- package/dist/content/snapshot-client.mjs +12 -1
- package/dist/inspector.js +96 -19
- package/dist/paste/paste.d.mts +5 -0
- package/dist/paste/paste.mjs +7 -2
- package/dist/server/agent-tools.d.mts +1 -0
- package/dist/server/agent-tools.mjs +4 -3
- package/dist/server/change-picture-store.d.mts +13 -0
- package/dist/server/change-picture-store.mjs +42 -0
- package/dist/server/change-pictures.d.mts +25 -0
- package/dist/server/change-pictures.mjs +104 -0
- package/dist/server/close-check.d.mts +11 -0
- package/dist/server/close-check.mjs +37 -5
- package/dist/server/comments/agent-actions.d.mts +8 -4
- package/dist/server/comments/agent-actions.mjs +16 -7
- package/dist/server/comments/close-tools.mjs +7 -5
- package/dist/server/comments/files.d.mts +5 -1
- package/dist/server/comments/hand-out.d.mts +1 -1
- package/dist/server/comments/hand-out.mjs +4 -1
- package/dist/server/comments/push.d.mts +19 -10
- package/dist/server/comments/push.mjs +45 -30
- package/dist/server/comments/studio-files.d.mts +14 -1
- package/dist/server/comments/studio-files.mjs +44 -31
- package/dist/server/comments/tools.d.mts +1 -1
- package/dist/server/comments/workspace.mjs +1 -0
- package/dist/server/dev-server.mjs +34 -0
- package/dist/server/own-copies.mjs +4 -23
- package/dist/server/requests.mjs +57 -3
- package/dist/server/response-budget.d.mts +2 -1
- package/dist/server/response-budget.mjs +4 -3
- package/dist/server/roster.d.mts +19 -8
- package/dist/server/roster.mjs +50 -22
- package/dist/server/studio-for.d.mts +7 -0
- package/dist/server/studio-for.mjs +23 -7
- package/dist/server/thread-forms.d.mts +3 -0
- package/dist/server/thread-forms.mjs +21 -1
- package/dist/server/tools/place-frame.d.mts +1 -0
- package/dist/server/tools/place-frame.mjs +33 -9
- package/dist/server/tools/result.mjs +2 -2
- package/dist/server/tools/snapshot.d.mts +1 -1
- package/dist/server/tools/snapshot.mjs +2 -1
- package/dist/server/tools/studio-context.d.mts +2 -1
- package/dist/server/tools/studio-context.mjs +2 -1
- package/dist/server/tools/watch.mjs +29 -12
- package/dist/server/work-groups.mjs +1 -1
- package/dist/shared/canvas-core.d.mts +39 -5
- package/dist/shared/canvas-core.mjs +60 -15
- package/dist/shared/canvas-file.d.mts +7 -4
- package/dist/shared/change-pictures-core.d.mts +6 -0
- package/dist/shared/change-pictures-core.mjs +5 -0
- package/dist/shared/page-looks.d.mts +12 -0
- package/dist/shared/page-looks.mjs +49 -0
- package/dist/shared/snapshot-clipboard.d.mts +6 -0
- package/dist/shared/studio-routes.d.mts +11 -0
- package/extension/dist/manifest.json +1 -1
- package/extension/dist/picker.js +114 -108
- package/package.json +4 -3
- package/src/cli/commands/mcp.ts +18 -8
- package/src/cli/mcp-relay.ts +13 -6
- package/src/content/content.ts +90 -16
- package/src/content/screenshot.ts +9 -1
- package/src/content/snapshot-client.ts +17 -0
- package/src/paste/paste.ts +18 -1
- package/src/server/agent-tools.ts +5 -4
- package/src/server/change-picture-store.ts +71 -0
- package/src/server/change-pictures.ts +244 -0
- package/src/server/close-check.ts +69 -6
- package/src/server/comments/agent-actions.ts +51 -12
- package/src/server/comments/close-tools.ts +20 -10
- package/src/server/comments/files.ts +10 -2
- package/src/server/comments/hand-out.ts +2 -2
- package/src/server/comments/push.ts +94 -46
- package/src/server/comments/studio-files.ts +77 -46
- package/src/server/comments/workspace.ts +1 -0
- package/src/server/dev-server.ts +70 -0
- package/src/server/own-copies.ts +5 -33
- package/src/server/requests.ts +84 -4
- package/src/server/response-budget.ts +5 -3
- package/src/server/roster.ts +78 -28
- package/src/server/studio-for.ts +32 -7
- package/src/server/thread-forms.ts +41 -1
- package/src/server/tools/place-frame.ts +71 -14
- package/src/server/tools/result.ts +2 -2
- package/src/server/tools/snapshot.ts +2 -1
- package/src/server/tools/studio-context.ts +24 -14
- package/src/server/tools/watch.ts +38 -13
- package/src/server/work-groups.ts +1 -1
- package/src/shared/canvas-core.ts +119 -27
- package/src/shared/canvas-file.ts +7 -4
- package/src/shared/change-pictures-core.ts +8 -0
- package/src/shared/page-looks.ts +133 -0
- package/src/shared/snapshot-clipboard.ts +6 -0
- package/src/shared/studio-routes.ts +7 -1
- package/templates/agents/dex-worker.md +9 -7
- package/templates/feedback-workflow.md +1 -1
- package/templates/methods/review.md +7 -6
- package/templates/rules/canvas-frames.md +8 -7
- package/templates/rules/canvas.md +10 -8
- package/templates/rules/prototypes.md +5 -3
- package/app/canvas/stack-node.tsx +0 -100
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { MOMENTS } from "../shared/change-pictures-core.mjs";
|
|
2
|
+
//#region src/server/change-picture-store.ts
|
|
3
|
+
const MOST_PICTURE_BYTES = 2e8;
|
|
4
|
+
function changePictureStore({ mostBytes = MOST_PICTURE_BYTES } = {}) {
|
|
5
|
+
const comments = /* @__PURE__ */ new Map();
|
|
6
|
+
let bytes = 0;
|
|
7
|
+
let lastAt = 0;
|
|
8
|
+
const forget = (id, moment) => {
|
|
9
|
+
bytes -= comments.get(id)?.get(moment)?.image.length ?? 0;
|
|
10
|
+
comments.get(id)?.delete(moment);
|
|
11
|
+
};
|
|
12
|
+
const forgetOldest = () => {
|
|
13
|
+
for (const [oldest, pictures] of comments) {
|
|
14
|
+
if (bytes <= mostBytes) return;
|
|
15
|
+
for (const moment of pictures.keys()) forget(oldest, moment);
|
|
16
|
+
comments.delete(oldest);
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
return {
|
|
20
|
+
drop: forget,
|
|
21
|
+
image: (id, moment) => comments.get(id)?.get(moment)?.image,
|
|
22
|
+
keep: (id, moment, image) => {
|
|
23
|
+
forget(id, moment);
|
|
24
|
+
lastAt = Math.max(Date.now(), lastAt + 1);
|
|
25
|
+
const pictures = comments.get(id) ?? /* @__PURE__ */ new Map();
|
|
26
|
+
pictures.set(moment, {
|
|
27
|
+
at: lastAt,
|
|
28
|
+
image
|
|
29
|
+
});
|
|
30
|
+
bytes += image.length;
|
|
31
|
+
comments.delete(id);
|
|
32
|
+
comments.set(id, pictures);
|
|
33
|
+
forgetOldest();
|
|
34
|
+
},
|
|
35
|
+
kept: (id) => Object.fromEntries(MOMENTS.flatMap((moment) => {
|
|
36
|
+
const kept = comments.get(id)?.get(moment);
|
|
37
|
+
return kept ? [[moment, kept.at]] : [];
|
|
38
|
+
}))
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
//#endregion
|
|
42
|
+
export { MOST_PICTURE_BYTES, changePictureStore };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { ThreadWithPrototype } from "../shared/threads-core.mjs";
|
|
2
|
+
import { KeptPictures, Moment } from "../shared/change-pictures-core.mjs";
|
|
3
|
+
import { ViewShot } from "../content/screenshot.mjs";
|
|
4
|
+
import { SnapshotRequest } from "../content/snapshot-client.mjs";
|
|
5
|
+
import { StudioFor } from "./studio-for.mjs";
|
|
6
|
+
//#region src/server/change-pictures.d.ts
|
|
7
|
+
export type FindStudio = () => Promise<StudioFor>;
|
|
8
|
+
export type Picture = ViewShot | {
|
|
9
|
+
missing: string;
|
|
10
|
+
};
|
|
11
|
+
export type PicturesTaken = Map<string, Promise<Picture>>;
|
|
12
|
+
export declare const startedAt: (thread: ThreadWithPrototype) => number;
|
|
13
|
+
export declare function pictureRequest(thread: ThreadWithPrototype): SnapshotRequest | undefined;
|
|
14
|
+
export declare function viewChangedAt(root: string, thread: ThreadWithPrototype): Promise<number>;
|
|
15
|
+
export declare function runningStudio(findStudio: FindStudio): Promise<{
|
|
16
|
+
url: string;
|
|
17
|
+
} | {
|
|
18
|
+
missing: string;
|
|
19
|
+
}>;
|
|
20
|
+
export declare function takePictureOnce(taken: PicturesTaken, studio: string, request: SnapshotRequest): Promise<Picture>;
|
|
21
|
+
export declare function keptPictures(studio: string, id: string): Promise<KeptPictures>;
|
|
22
|
+
export declare function keepPicture(studio: string, id: string, moment: Moment, image: Buffer): Promise<void>;
|
|
23
|
+
export declare function dropPicture(studio: string, id: string, moment: Moment): Promise<void>;
|
|
24
|
+
export declare function pictureBefore(root: string, threads: ThreadWithPrototype[], findStudio: FindStudio): Promise<void>;
|
|
25
|
+
//#endregion
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { isFiniteNumber, isRecord } from "../shared/checks.mjs";
|
|
2
|
+
import { framePage, prototypeFiles } from "../shared/prototypes-core.mjs";
|
|
3
|
+
import { claimOf } from "../shared/threads-core.mjs";
|
|
4
|
+
import { whyNotRunning } from "./studio-for.mjs";
|
|
5
|
+
import { SnapshotError, snapshotView } from "../content/snapshot-client.mjs";
|
|
6
|
+
import { MOMENTS } from "../shared/change-pictures-core.mjs";
|
|
7
|
+
import { latestChange } from "./pictures.mjs";
|
|
8
|
+
//#region src/server/change-pictures.ts
|
|
9
|
+
const NEVER_RENDERED = 409;
|
|
10
|
+
const startedAt = (thread) => Date.parse(claimOf(thread)?.at ?? thread.created);
|
|
11
|
+
const viewOf = ({ target }) => target.kind === "element" || target.kind === "frame" ? target.view : void 0;
|
|
12
|
+
function pictureRequest(thread) {
|
|
13
|
+
const view = viewOf(thread);
|
|
14
|
+
const { target } = thread;
|
|
15
|
+
if (!view || target.kind !== "element" && target.kind !== "frame") return;
|
|
16
|
+
const search = new URLSearchParams(target.params ?? {});
|
|
17
|
+
const href = framePage(thread.slug, view, search.size > 0 ? `?${search}` : "");
|
|
18
|
+
return href ? {
|
|
19
|
+
href,
|
|
20
|
+
viewport: target.viewport ?? "desktop",
|
|
21
|
+
scheme: "light",
|
|
22
|
+
scale: 1
|
|
23
|
+
} : void 0;
|
|
24
|
+
}
|
|
25
|
+
async function viewChangedAt(root, thread) {
|
|
26
|
+
const folder = prototypeFiles(thread.slug)?.folder;
|
|
27
|
+
const view = viewOf(thread);
|
|
28
|
+
return folder && view ? await latestChange(root, folder, view).catch(() => Number.POSITIVE_INFINITY) : Number.POSITIVE_INFINITY;
|
|
29
|
+
}
|
|
30
|
+
async function runningStudio(findStudio) {
|
|
31
|
+
try {
|
|
32
|
+
const studio = await findStudio();
|
|
33
|
+
return studio.kind === "running" ? { url: studio.url } : { missing: whyNotRunning(studio).why };
|
|
34
|
+
} catch (error) {
|
|
35
|
+
return { missing: error instanceof Error ? error.message : String(error) };
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
async function takePicture(studio, request) {
|
|
39
|
+
try {
|
|
40
|
+
return await snapshotView(studio, request);
|
|
41
|
+
} catch (error) {
|
|
42
|
+
if (error instanceof SnapshotError && error.status === NEVER_RENDERED) return { missing: `Dex couldn't render the view's page: ${error.message}` };
|
|
43
|
+
return { missing: error instanceof Error ? error.message : String(error) };
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
function takePictureOnce(taken, studio, request) {
|
|
47
|
+
const page = JSON.stringify(request);
|
|
48
|
+
const known = taken.get(page);
|
|
49
|
+
if (known) return known;
|
|
50
|
+
const picture = takePicture(studio, request);
|
|
51
|
+
taken.set(page, picture);
|
|
52
|
+
return picture;
|
|
53
|
+
}
|
|
54
|
+
const pictureOf = (studio, id, moment) => `${studio}/__studio/change-picture?${new URLSearchParams({
|
|
55
|
+
thread: id,
|
|
56
|
+
moment
|
|
57
|
+
})}`;
|
|
58
|
+
async function askStudio(url, init) {
|
|
59
|
+
const response = await fetch(url, init);
|
|
60
|
+
if (!response.ok) {
|
|
61
|
+
const said = await response.text();
|
|
62
|
+
throw new Error(`Dex answered ${response.status}: ${said.slice(0, 200)}`);
|
|
63
|
+
}
|
|
64
|
+
return response;
|
|
65
|
+
}
|
|
66
|
+
async function keptPictures(studio, id) {
|
|
67
|
+
const said = await (await askStudio(`${studio}/__studio/change-pictures?${new URLSearchParams({ thread: id })}`)).json();
|
|
68
|
+
return isRecord(said) ? Object.fromEntries(MOMENTS.flatMap((moment) => {
|
|
69
|
+
const at = said[moment];
|
|
70
|
+
return isFiniteNumber(at) ? [[moment, at]] : [];
|
|
71
|
+
})) : {};
|
|
72
|
+
}
|
|
73
|
+
async function keepPicture(studio, id, moment, image) {
|
|
74
|
+
await askStudio(pictureOf(studio, id, moment), {
|
|
75
|
+
method: "PUT",
|
|
76
|
+
headers: { "content-type": "application/json" },
|
|
77
|
+
body: JSON.stringify({ data: image.toString("base64") })
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
async function dropPicture(studio, id, moment) {
|
|
81
|
+
await askStudio(pictureOf(studio, id, moment), { method: "DELETE" });
|
|
82
|
+
}
|
|
83
|
+
const lastWordAt = (thread) => Math.max(Date.parse(thread.created), ...thread.messages.map(({ at }) => Date.parse(at)), thread.resolution ? Date.parse(thread.resolution.at) : 0);
|
|
84
|
+
async function beforeFromThisStart(studio, thread) {
|
|
85
|
+
const { before } = await keptPictures(studio, thread.id);
|
|
86
|
+
return before !== void 0 && before > lastWordAt(thread);
|
|
87
|
+
}
|
|
88
|
+
async function pictureOneBefore(root, thread, studio, taken) {
|
|
89
|
+
const request = pictureRequest(thread);
|
|
90
|
+
if (!request || await beforeFromThisStart(studio, thread)) return;
|
|
91
|
+
await dropPicture(studio, thread.id, "before");
|
|
92
|
+
const picture = await takePictureOnce(taken, studio, request);
|
|
93
|
+
if ("missing" in picture || await viewChangedAt(root, thread) > startedAt(thread)) return;
|
|
94
|
+
await keepPicture(studio, thread.id, "before", picture.image);
|
|
95
|
+
}
|
|
96
|
+
async function pictureBefore(root, threads, findStudio) {
|
|
97
|
+
if (!threads.some((thread) => pictureRequest(thread))) return;
|
|
98
|
+
const studio = await runningStudio(findStudio);
|
|
99
|
+
if ("missing" in studio) return;
|
|
100
|
+
const taken = /* @__PURE__ */ new Map();
|
|
101
|
+
await Promise.all(threads.map((thread) => pictureOneBefore(root, thread, studio.url, taken).catch(() => void 0)));
|
|
102
|
+
}
|
|
103
|
+
//#endregion
|
|
104
|
+
export { dropPicture, keepPicture, keptPictures, pictureBefore, pictureRequest, runningStudio, startedAt, takePictureOnce, viewChangedAt };
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { ThreadWithPrototype } from "../shared/threads-core.mjs";
|
|
2
2
|
import { ResolvedDesignSystem } from "../config/design-system.mjs";
|
|
3
|
+
import { PageLooks } from "../shared/page-looks.mjs";
|
|
4
|
+
import { FindStudio, PicturesTaken } from "./change-pictures.mjs";
|
|
3
5
|
//#region src/server/close-check.d.ts
|
|
4
6
|
/**
|
|
5
7
|
* Why `code` cannot be read as TSX, as "file:line: …", or undefined when it
|
|
@@ -28,4 +30,13 @@ export declare function filesChangedSincePickup(root: string, thread: ThreadWith
|
|
|
28
30
|
export declare function errorsBeforeClose(root: string, thread: ThreadWithPrototype, designSystem: ResolvedDesignSystem | undefined,
|
|
29
31
|
/** Where the agent works: the files are named from here. */
|
|
30
32
|
from?: string): Promise<string[]>;
|
|
33
|
+
export interface ChangeLook {
|
|
34
|
+
missing?: string;
|
|
35
|
+
wrong: string[];
|
|
36
|
+
}
|
|
37
|
+
export declare const looksWrong: (looks: PageLooks | undefined) => string[];
|
|
38
|
+
export declare function lookAtChange(thread: ThreadWithPrototype, { findStudio, taken }: {
|
|
39
|
+
findStudio: FindStudio;
|
|
40
|
+
taken: PicturesTaken;
|
|
41
|
+
}): Promise<ChangeLook | undefined>;
|
|
31
42
|
//#endregion
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { shownFrom } from "../paths.mjs";
|
|
2
2
|
import { prototypeFiles } from "../shared/prototypes-core.mjs";
|
|
3
|
-
import { claimOf } from "../shared/threads-core.mjs";
|
|
4
3
|
import { checkPrototypeSource, errorLines, sourceFiles } from "../content/prototype-checks.mjs";
|
|
5
4
|
import { babel } from "../setup/design-system-checks.mjs";
|
|
5
|
+
import { dropPicture, keepPicture, pictureRequest, runningStudio, startedAt, takePictureOnce } from "./change-pictures.mjs";
|
|
6
6
|
import { stylesheetOf } from "./thread-source.mjs";
|
|
7
7
|
import { groupWork } from "./work-groups.mjs";
|
|
8
8
|
import { join, relative, sep } from "node:path";
|
|
@@ -69,8 +69,6 @@ async function prototypeCode(folder) {
|
|
|
69
69
|
};
|
|
70
70
|
}));
|
|
71
71
|
}
|
|
72
|
-
/** When the thread was picked up: its claim's 👀, else when it was posted. */
|
|
73
|
-
const pickedUpAt = (thread) => Date.parse(claimOf(thread)?.at ?? thread.created);
|
|
74
72
|
/**
|
|
75
73
|
* The prototype's code and style that changed since the thread was picked
|
|
76
74
|
* up, absolute.
|
|
@@ -78,7 +76,7 @@ const pickedUpAt = (thread) => Date.parse(claimOf(thread)?.at ?? thread.created)
|
|
|
78
76
|
async function pathsChangedSincePickup(root, thread) {
|
|
79
77
|
const folder = prototypeFiles(thread.slug)?.folder;
|
|
80
78
|
if (!folder) return [];
|
|
81
|
-
const since =
|
|
79
|
+
const since = startedAt(thread);
|
|
82
80
|
return (await prototypeCode(join(root, folder))).filter(({ changed }) => changed >= since).map(({ file }) => file);
|
|
83
81
|
}
|
|
84
82
|
/** The files a thread's change may have touched, absolute. */
|
|
@@ -127,5 +125,39 @@ async function errorsBeforeClose(root, thread, designSystem, from = root) {
|
|
|
127
125
|
const files = await touchedFiles(root, thread).catch(() => []);
|
|
128
126
|
return (await Promise.all(files.map((file) => errorsInFile(from, file, designSystem)))).flat();
|
|
129
127
|
}
|
|
128
|
+
const looksWrong = (looks) => [...looks?.error === void 0 ? [] : [`its view shows an error: ${looks.error}`], ...looks?.blank ? ["its view renders nothing to see"] : []];
|
|
129
|
+
async function lookAtChange(thread, { findStudio, taken }) {
|
|
130
|
+
const request = pictureRequest(thread);
|
|
131
|
+
if (!request) return;
|
|
132
|
+
const studio = await runningStudio(findStudio);
|
|
133
|
+
if ("missing" in studio) return {
|
|
134
|
+
missing: studio.missing,
|
|
135
|
+
wrong: []
|
|
136
|
+
};
|
|
137
|
+
const picture = await takePictureOnce(taken, studio.url, request);
|
|
138
|
+
if ("missing" in picture) {
|
|
139
|
+
await dropPicture(studio.url, thread.id, "after").catch(() => void 0);
|
|
140
|
+
return {
|
|
141
|
+
missing: picture.missing,
|
|
142
|
+
wrong: []
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
const wrong = looksWrong(picture.looks);
|
|
146
|
+
if (wrong.length > 0) {
|
|
147
|
+
await dropPicture(studio.url, thread.id, "after").catch(() => void 0);
|
|
148
|
+
return { wrong };
|
|
149
|
+
}
|
|
150
|
+
try {
|
|
151
|
+
await keepPicture(studio.url, thread.id, "after", picture.image);
|
|
152
|
+
return { wrong };
|
|
153
|
+
} catch (error) {
|
|
154
|
+
const why = error instanceof Error ? error.message : String(error);
|
|
155
|
+
await dropPicture(studio.url, thread.id, "after").catch(() => void 0);
|
|
156
|
+
return {
|
|
157
|
+
missing: `It couldn't be kept: ${why}`,
|
|
158
|
+
wrong
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
}
|
|
130
162
|
//#endregion
|
|
131
|
-
export { cssError, errorsBeforeClose, filesChangedSincePickup, syntaxError };
|
|
163
|
+
export { cssError, errorsBeforeClose, filesChangedSincePickup, lookAtChange, looksWrong, syntaxError };
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { ChangePlace, ThreadWithPrototype } from "../../shared/threads-core.mjs";
|
|
2
2
|
import { ThreadModule } from "../../content/thread-module.mjs";
|
|
3
3
|
import { AgentSession } from "../agent-session.mjs";
|
|
4
|
+
import { PicturesTaken } from "../change-pictures.mjs";
|
|
4
5
|
import { Outcome } from "../outcome.mjs";
|
|
5
6
|
import { CommentFiles } from "./files.mjs";
|
|
6
7
|
//#region src/server/comments/agent-actions.d.ts
|
|
@@ -11,7 +12,7 @@ import { CommentFiles } from "./files.mjs";
|
|
|
11
12
|
*/
|
|
12
13
|
export interface AgentWork {
|
|
13
14
|
/** What closing and answering need of the files the comments are on. */
|
|
14
|
-
files: Pick<CommentFiles, "beforeDone" | "settle">;
|
|
15
|
+
files: Pick<CommentFiles, "beforeDone" | "pictureBefore" | "settle">;
|
|
15
16
|
session: AgentSession;
|
|
16
17
|
threads: Pick<ThreadModule, "find">;
|
|
17
18
|
}
|
|
@@ -20,7 +21,8 @@ export interface AgentWork {
|
|
|
20
21
|
* comment is that session's alone until it closes, asks or lets it go.
|
|
21
22
|
* One another session holds is a conflict.
|
|
22
23
|
*/
|
|
23
|
-
export declare function claimComment({ session }: {
|
|
24
|
+
export declare function claimComment({ files, session }: {
|
|
25
|
+
files: Pick<CommentFiles, "pictureBefore">;
|
|
24
26
|
session: Pick<AgentSession, "claim">;
|
|
25
27
|
}, id: string): Promise<Outcome<ThreadWithPrototype>>;
|
|
26
28
|
/**
|
|
@@ -28,7 +30,8 @@ export declare function claimComment({ session }: {
|
|
|
28
30
|
* once: every one is claimed for its session, or, when another session
|
|
29
31
|
* holds one or one is closed or gone, none is (a conflict).
|
|
30
32
|
*/
|
|
31
|
-
export declare function claimComments({ session }: {
|
|
33
|
+
export declare function claimComments({ files, session }: {
|
|
34
|
+
files: Pick<CommentFiles, "pictureBefore">;
|
|
32
35
|
session: Pick<AgentSession, "claimAll">;
|
|
33
36
|
}, group: ThreadWithPrototype[]): Promise<Outcome<ThreadWithPrototype[]>>;
|
|
34
37
|
/**
|
|
@@ -60,6 +63,7 @@ export interface Closing {
|
|
|
60
63
|
*/
|
|
61
64
|
export interface Closed {
|
|
62
65
|
copy?: string;
|
|
66
|
+
noPicture?: string;
|
|
63
67
|
thread: ThreadWithPrototype;
|
|
64
68
|
}
|
|
65
69
|
/**
|
|
@@ -69,5 +73,5 @@ export interface Closed {
|
|
|
69
73
|
* says why. Not done is never held up. The person's copy of someone else's
|
|
70
74
|
* view is settled as the comment ends.
|
|
71
75
|
*/
|
|
72
|
-
export declare function closeComment({ files, session, threads }: AgentWork, { dismiss, id, summary, where }: Closing): Promise<Outcome<Closed>>;
|
|
76
|
+
export declare function closeComment({ files, session, threads }: AgentWork, { dismiss, id, summary, where }: Closing, taken?: PicturesTaken): Promise<Outcome<Closed>>;
|
|
73
77
|
//#endregion
|
|
@@ -7,19 +7,23 @@ const noThread = (id) => `No thread ${id}.`;
|
|
|
7
7
|
* comment is that session's alone until it closes, asks or lets it go.
|
|
8
8
|
* One another session holds is a conflict.
|
|
9
9
|
*/
|
|
10
|
-
async function claimComment({ session }, id) {
|
|
10
|
+
async function claimComment({ files, session }, id) {
|
|
11
11
|
const claimed = await session.claim(id);
|
|
12
12
|
if (!claimed) return refused("not-found", [noThread(id)]);
|
|
13
|
-
|
|
13
|
+
if (claimed.problems) return refused("conflict", claimed.problems);
|
|
14
|
+
files.pictureBefore([claimed.thread]).catch(() => void 0);
|
|
15
|
+
return { value: claimed.thread };
|
|
14
16
|
}
|
|
15
17
|
/**
|
|
16
18
|
* An agent starts on a group of one file's comments (work-groups.ts) at
|
|
17
19
|
* once: every one is claimed for its session, or, when another session
|
|
18
20
|
* holds one or one is closed or gone, none is (a conflict).
|
|
19
21
|
*/
|
|
20
|
-
async function claimComments({ session }, group) {
|
|
22
|
+
async function claimComments({ files, session }, group) {
|
|
21
23
|
const claimed = await session.claimAll(group);
|
|
22
|
-
|
|
24
|
+
if (claimed.problems) return refused("conflict", claimed.problems);
|
|
25
|
+
files.pictureBefore(claimed.thread).catch(() => void 0);
|
|
26
|
+
return { value: claimed.thread };
|
|
23
27
|
}
|
|
24
28
|
/**
|
|
25
29
|
* An agent writes on a comment: an answer where someone mentions it, or,
|
|
@@ -38,6 +42,7 @@ async function askOnComment({ files, session }, id, { ask, message }) {
|
|
|
38
42
|
await files.settle(answered.thread);
|
|
39
43
|
return { value: answered.thread };
|
|
40
44
|
}
|
|
45
|
+
const heldForItsView = (id, { wrong }) => `${id}: not closed, ${wrong.join("; ")}. Fix it, then close it.`;
|
|
41
46
|
/**
|
|
42
47
|
* Close a comment an agent took. Done keeps the summary and the files its
|
|
43
48
|
* change touched, once that code passes the checks (files.ts's
|
|
@@ -45,15 +50,18 @@ async function askOnComment({ files, session }, id, { ask, message }) {
|
|
|
45
50
|
* says why. Not done is never held up. The person's copy of someone else's
|
|
46
51
|
* view is settled as the comment ends.
|
|
47
52
|
*/
|
|
48
|
-
async function closeComment({ files, session, threads }, { dismiss, id, summary, where }) {
|
|
53
|
+
async function closeComment({ files, session, threads }, { dismiss, id, summary, where }, taken = /* @__PURE__ */ new Map()) {
|
|
49
54
|
if (Boolean(summary) === Boolean(dismiss)) return refused("invalid", [`${id}: give a summary or dismiss, one of them.`]);
|
|
50
55
|
let changed = [];
|
|
56
|
+
let look;
|
|
51
57
|
if (summary) {
|
|
52
58
|
const thread = await threads.find(id);
|
|
53
59
|
if (!thread) return refused("not-found", [noThread(id)]);
|
|
54
|
-
const checked = await files.beforeDone(thread);
|
|
60
|
+
const checked = await files.beforeDone(thread, taken);
|
|
55
61
|
if (checked.broken.length > 0) return refused("conflict", [`${id}: not closed, the code it changed has errors: ${checked.broken.join(" ")} Fix them, then close it.`]);
|
|
62
|
+
if (checked.look?.wrong.length) return refused("conflict", [heldForItsView(id, checked.look)]);
|
|
56
63
|
changed = checked.files;
|
|
64
|
+
({look} = checked);
|
|
57
65
|
}
|
|
58
66
|
const closed = await session.act(id, summary ? {
|
|
59
67
|
action: "resolve",
|
|
@@ -69,7 +77,8 @@ async function closeComment({ files, session, threads }, { dismiss, id, summary,
|
|
|
69
77
|
const copy = await files.settle(closed.thread);
|
|
70
78
|
return { value: {
|
|
71
79
|
thread: closed.thread,
|
|
72
|
-
...copy && { copy }
|
|
80
|
+
...copy && { copy },
|
|
81
|
+
...look?.missing && { noPicture: look.missing }
|
|
73
82
|
} };
|
|
74
83
|
}
|
|
75
84
|
//#endregion
|
|
@@ -30,20 +30,21 @@ const landingOf = async ({ files, threads }, id, where) => {
|
|
|
30
30
|
* Not done (`dismiss`): what it is now, which it was and how it closed, or
|
|
31
31
|
* why not.
|
|
32
32
|
*/
|
|
33
|
-
const closeOne = async (context, { id, summary, dismiss, where }) => {
|
|
33
|
+
const closeOne = async (context, { id, summary, dismiss, where }, taken) => {
|
|
34
34
|
const landed = summary && where ? await landingOf(context, id, where) : void 0;
|
|
35
35
|
const closed = await closeComment(context, {
|
|
36
36
|
id,
|
|
37
37
|
summary,
|
|
38
38
|
dismiss,
|
|
39
39
|
...landed?.place ? { where: landed.place } : void 0
|
|
40
|
-
});
|
|
40
|
+
}, taken);
|
|
41
41
|
if (closed.problem) return toAgent(closed.problem);
|
|
42
|
-
const { copy, thread } = closed.value;
|
|
42
|
+
const { copy, noPicture, thread } = closed.value;
|
|
43
43
|
const { messages: _, ...shown } = describedIn(await context.files.describeClosed(thread), SHORT).thread;
|
|
44
44
|
return {
|
|
45
45
|
...shown,
|
|
46
46
|
...copy ? { copy: `Your copy's frame is under theirs: ${copy}.` } : void 0,
|
|
47
|
+
...noPicture ? { noPicture: `Closed without a picture of the change: ${noPicture}` } : void 0,
|
|
47
48
|
...landed?.unplaced ? { unplaced: landed.unplaced } : void 0
|
|
48
49
|
};
|
|
49
50
|
};
|
|
@@ -60,7 +61,7 @@ function closeTool(context) {
|
|
|
60
61
|
idempotentHint: true
|
|
61
62
|
},
|
|
62
63
|
title: "Close threads",
|
|
63
|
-
description: "Close comments and requests, several at once: every thread you take ends here (or with `reply`); one you have not closed when your session ends goes back to waiting. The code each change touched is checked first (it parses, its stylesheet's braces close, it imports only what Dex allows): while
|
|
64
|
+
description: "Close comments and requests, several at once: every thread you take ends here (or with `reply`); one you have not closed when your session ends goes back to waiting. The code each change touched is checked first (it parses, its stylesheet's braces close, it imports only what Dex allows), then, with Dex running, it pictures the comment's frame: while the code fails or the view shows an error or nothing, the thread stays open and the result says why, so a small change needs no `snapshot`. Give each thread's `summary` as soon as its change is made, one short line on what changed (what people would look for, such as \"Header padding 24 to 12px; title now semibold\"): the thread gets ✅ and the line shows on it and as a note in Dex. Give `dismiss` instead to close one without acting on it (for example, the owner decided against it, or it is already so): it gets 🚫 with that line. A longer line is taken too, but Dex shows only its start until someone opens it, so keep it short. With a summary, give `where` too: the element your change landed on (a frame key or view, and a CSS selector, as `comment` takes them), above all when it is not the element the comment is on. People are taken there, and a pin marks it.",
|
|
64
65
|
inputSchema: { threads: z.array(z.object({
|
|
65
66
|
id: z.string(),
|
|
66
67
|
summary: z.string().min(1).optional().describe("What changed: the thread is resolved"),
|
|
@@ -76,8 +77,9 @@ function closeTool(context) {
|
|
|
76
77
|
run: async (input) => {
|
|
77
78
|
const closed = [];
|
|
78
79
|
const problems = [];
|
|
80
|
+
const taken = /* @__PURE__ */ new Map();
|
|
79
81
|
for (const request of input.threads) {
|
|
80
|
-
const outcome = await closeOne(context, request);
|
|
82
|
+
const outcome = await closeOne(context, request, taken);
|
|
81
83
|
if (isString(outcome)) problems.push(outcome);
|
|
82
84
|
else closed.push(outcome);
|
|
83
85
|
}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { ChangePlace, ThreadWithPrototype } from "../../shared/threads-core.mjs";
|
|
2
|
+
import { PicturesTaken } from "../change-pictures.mjs";
|
|
3
|
+
import { ChangeLook } from "../close-check.mjs";
|
|
2
4
|
import { PlacedThread } from "../open-page.mjs";
|
|
3
5
|
import { Described } from "../thread-forms.mjs";
|
|
4
6
|
import { CanvasPlace } from "../thread-place.mjs";
|
|
@@ -11,9 +13,10 @@ export interface CommentFiles {
|
|
|
11
13
|
* change touched (none to close), and the files it changed since it took
|
|
12
14
|
* the comment, kept on the comment.
|
|
13
15
|
*/
|
|
14
|
-
beforeDone: (thread: ThreadWithPrototype) => Promise<{
|
|
16
|
+
beforeDone: (thread: ThreadWithPrototype, taken: PicturesTaken) => Promise<{
|
|
15
17
|
broken: string[];
|
|
16
18
|
files: string[];
|
|
19
|
+
look?: ChangeLook;
|
|
17
20
|
}>;
|
|
18
21
|
/** A thread as an agent reads it, for work: where it is, its file's title, its spec. */
|
|
19
22
|
describe: (thread: ThreadWithPrototype) => Promise<Described>;
|
|
@@ -36,6 +39,7 @@ export interface CommentFiles {
|
|
|
36
39
|
}>;
|
|
37
40
|
/** The longest `watch` waits here, in seconds. */
|
|
38
41
|
longestWait: number;
|
|
42
|
+
pictureBefore: (threads: ThreadWithPrototype[]) => Promise<void>;
|
|
39
43
|
/**
|
|
40
44
|
* After an agent answers or closes a comment: the person's copy of
|
|
41
45
|
* someone else's view, settled. The frame the copy now has in their row,
|
|
@@ -15,7 +15,7 @@ export type GroupClaim = {
|
|
|
15
15
|
};
|
|
16
16
|
/** What handing out needs: the session, its threads, and how they group. */
|
|
17
17
|
export interface HandOutContext {
|
|
18
|
-
files: Pick<CommentFiles, "group">;
|
|
18
|
+
files: Pick<CommentFiles, "group" | "pictureBefore">;
|
|
19
19
|
session: Pick<AgentSession, "claimAll" | "id">;
|
|
20
20
|
threads: Pick<ThreadModule, "list">;
|
|
21
21
|
}
|
|
@@ -33,7 +33,10 @@ function openHandOut({ files, session, threads }) {
|
|
|
33
33
|
* still wait for an agent, to hand out once what stopped it changes.
|
|
34
34
|
*/
|
|
35
35
|
async claim(group) {
|
|
36
|
-
const claimed = await claimComments({
|
|
36
|
+
const claimed = await claimComments({
|
|
37
|
+
files,
|
|
38
|
+
session
|
|
39
|
+
}, group.threads);
|
|
37
40
|
if (claimed.value) return { won: claimed.value };
|
|
38
41
|
const ids = new Set(group.threads.map(({ id }) => id));
|
|
39
42
|
return { waiting: async () => {
|
|
@@ -1,26 +1,35 @@
|
|
|
1
|
+
import { ThreadWithPrototype } from "../../shared/threads-core.mjs";
|
|
1
2
|
import { ChannelEvent, ChannelWork } from "../../harness/src/events/channel.mjs";
|
|
2
3
|
import { ThreadModule } from "../../content/thread-module.mjs";
|
|
3
4
|
import { AgentSession } from "../agent-session.mjs";
|
|
4
5
|
import { WorkGroup } from "../work-groups.mjs";
|
|
5
|
-
import {
|
|
6
|
+
import { CommentFiles } from "./files.mjs";
|
|
7
|
+
import { DescribedInStudio } from "./studio-files.mjs";
|
|
6
8
|
//#region src/server/comments/push.d.ts
|
|
9
|
+
/**
|
|
10
|
+
* The event for what a session won, in the studio's folder at `root`, each
|
|
11
|
+
* file shown from `from`: on someone else's view, the person's copy is what
|
|
12
|
+
* is handed out.
|
|
13
|
+
*/
|
|
14
|
+
export declare const claimedEvent: (root: string, claimed: ThreadWithPrototype[], from: string) => Promise<ChannelEvent>;
|
|
7
15
|
/**
|
|
8
16
|
* The comments to push to `session`, heard of from the change feed of
|
|
9
17
|
* `threads` (thread-module.ts), for the channel to deliver. Threads already
|
|
10
18
|
* waiting when it starts listening are not pushed; `threads` lists them.
|
|
11
19
|
* Each file in an event is shown from `from`, where the agent works.
|
|
12
20
|
*/
|
|
13
|
-
export declare function commentsToPush(root: string, threads: ThreadModule, session: Pick<AgentSession, "act" | "claimAll" | "hasNews" | "id" | "take">, { from }?: {
|
|
21
|
+
export declare function commentsToPush(root: string, threads: ThreadModule, session: Pick<AgentSession, "act" | "claimAll" | "hasNews" | "id" | "take">, { from, pictureBefore }?: {
|
|
14
22
|
from?: string;
|
|
23
|
+
pictureBefore?: CommentFiles["pictureBefore"];
|
|
15
24
|
}): ChannelWork;
|
|
16
25
|
/**
|
|
17
|
-
* Threads as one event: each
|
|
18
|
-
*
|
|
19
|
-
* then by unit of work (work-groups.ts) with the files it may
|
|
20
|
-
* with how to work on them. Each file is
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
26
|
+
* Threads as one event: each as `described` has it by id (studio-files.ts:
|
|
27
|
+
* where it is, its spec, whether someone asked) and its messages, by
|
|
28
|
+
* prototype and then by unit of work (work-groups.ts) with the files it may
|
|
29
|
+
* change, ending with how to work on them. Each file is as `show` gives it:
|
|
30
|
+
* as the agent opens it from where it works. Within the event's budget
|
|
31
|
+
* (response-budget.ts): threads there is no room for go short, then by id
|
|
32
|
+
* alone, and the event says which.
|
|
24
33
|
*/
|
|
25
|
-
export declare function channelEvent(groups: WorkGroup[],
|
|
34
|
+
export declare function channelEvent(groups: WorkGroup[], described: ReadonlyMap<string, DescribedInStudio>, show?: (path: string) => string): ChannelEvent;
|
|
26
35
|
//#endregion
|