@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
|
@@ -9,6 +9,7 @@ import { prototypeTitle } from "../../content/prototypes.ts";
|
|
|
9
9
|
import type { ViewShot } from "../../content/screenshot.ts";
|
|
10
10
|
import { SnapshotError, snapshotView } from "../../content/snapshot-client.ts";
|
|
11
11
|
import { framePage } from "../../shared/prototypes-core.ts";
|
|
12
|
+
import { jsonText } from "../response-budget.ts";
|
|
12
13
|
import { notRunning, type StudioFor } from "../studio-for.ts";
|
|
13
14
|
import type { ToolContext } from "./context.ts";
|
|
14
15
|
import { PROTOTYPE, prototypeFor } from "./prototype-name.ts";
|
|
@@ -109,7 +110,7 @@ export function snapshotTool(
|
|
|
109
110
|
},
|
|
110
111
|
{
|
|
111
112
|
type: "text",
|
|
112
|
-
text:
|
|
113
|
+
text: jsonText({
|
|
113
114
|
prototype: found.slug,
|
|
114
115
|
title: await prototypeTitle(root, found.slug),
|
|
115
116
|
view: input.view,
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
import { join } from "node:path";
|
|
6
6
|
|
|
7
7
|
import { shownFrom } from "../../paths.ts";
|
|
8
|
+
import type { FindStudio } from "../change-pictures.ts";
|
|
8
9
|
import { studioCommentFiles } from "../comments/studio-files.ts";
|
|
9
10
|
import { componentsLine } from "../component-catalogue.ts";
|
|
10
11
|
import { openChangeNotices, sessionStore } from "../notices.ts";
|
|
@@ -16,19 +17,22 @@ import { type ToolContext, toolResults } from "./context.ts";
|
|
|
16
17
|
export type ToolContextOptions = ToolSetup;
|
|
17
18
|
|
|
18
19
|
/** The context the tools of one server share. */
|
|
19
|
-
export function openToolContext(
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
20
|
+
export function openToolContext(
|
|
21
|
+
{
|
|
22
|
+
agentName,
|
|
23
|
+
briefing,
|
|
24
|
+
channel,
|
|
25
|
+
claudeSession,
|
|
26
|
+
designSystem,
|
|
27
|
+
from,
|
|
28
|
+
onUpdateReady,
|
|
29
|
+
receipt,
|
|
30
|
+
root,
|
|
31
|
+
session,
|
|
32
|
+
threads,
|
|
33
|
+
}: ToolContextOptions,
|
|
34
|
+
findStudio: FindStudio
|
|
35
|
+
): ToolContext {
|
|
32
36
|
const toldOnce = sayOnce([
|
|
33
37
|
// A session feedback cannot be pushed to is told so once, with the loop
|
|
34
38
|
// to start (push-notice.ts).
|
|
@@ -54,7 +58,13 @@ export function openToolContext({
|
|
|
54
58
|
return {
|
|
55
59
|
agentName,
|
|
56
60
|
designSystem,
|
|
57
|
-
files: studioCommentFiles({
|
|
61
|
+
files: studioCommentFiles({
|
|
62
|
+
designSystem,
|
|
63
|
+
findStudio,
|
|
64
|
+
from,
|
|
65
|
+
inRoot,
|
|
66
|
+
root,
|
|
67
|
+
}),
|
|
58
68
|
from,
|
|
59
69
|
inRoot,
|
|
60
70
|
notices,
|
|
@@ -8,6 +8,8 @@ import { z } from "zod";
|
|
|
8
8
|
import type { ThreadFilter } from "../../content/thread-module.ts";
|
|
9
9
|
import {
|
|
10
10
|
needsAgent,
|
|
11
|
+
type ThreadAudience,
|
|
12
|
+
type ThreadStatus,
|
|
11
13
|
type ThreadWithPrototype,
|
|
12
14
|
} from "../../shared/threads-core.ts";
|
|
13
15
|
import { claimComment } from "../comments/agent-actions.ts";
|
|
@@ -20,6 +22,8 @@ import {
|
|
|
20
22
|
describedIn,
|
|
21
23
|
FOR_WORK,
|
|
22
24
|
fitThreads,
|
|
25
|
+
sharedPlace,
|
|
26
|
+
withoutSaid,
|
|
23
27
|
} from "../thread-forms.ts";
|
|
24
28
|
import { groupSummary, splitLine, type WorkGroup } from "../work-groups.ts";
|
|
25
29
|
import { ALWAYS_LOADED, type CommentToolContext } from "./context.ts";
|
|
@@ -42,6 +46,11 @@ const MAX_PASSED = 3;
|
|
|
42
46
|
/** The most threads a result names by id alone, beside those it describes. */
|
|
43
47
|
const MAX_IDS = 60;
|
|
44
48
|
|
|
49
|
+
const SAID_OF_EVERY_THREAD = {
|
|
50
|
+
for: "agent",
|
|
51
|
+
status: "acknowledged",
|
|
52
|
+
} as const satisfies { for: ThreadAudience; status: ThreadStatus };
|
|
53
|
+
|
|
45
54
|
/**
|
|
46
55
|
* What `watch` says of the threads it could not describe for work:
|
|
47
56
|
* nothing when it could describe them all.
|
|
@@ -67,9 +76,9 @@ const watchLeftOut = (short: number, left: number): string => {
|
|
|
67
76
|
};
|
|
68
77
|
|
|
69
78
|
/**
|
|
70
|
-
* Each group with its threads as described
|
|
71
|
-
*
|
|
72
|
-
*
|
|
79
|
+
* Each group with its threads as described (`shown`, in order; any past them
|
|
80
|
+
* named in `more`), its files as `show` gives them, where they are alike said
|
|
81
|
+
* once (`shared`), and each thread less what its group or `watch` says of it.
|
|
73
82
|
*/
|
|
74
83
|
const groupsWith = (
|
|
75
84
|
groups: WorkGroup[],
|
|
@@ -78,16 +87,25 @@ const groupsWith = (
|
|
|
78
87
|
) => {
|
|
79
88
|
let at = 0;
|
|
80
89
|
|
|
81
|
-
return groups.map((group) => {
|
|
90
|
+
return groups.map(({ threads, ...group }) => {
|
|
82
91
|
const from = at;
|
|
83
|
-
at +=
|
|
92
|
+
at += threads.length;
|
|
84
93
|
const described = shown.slice(from, at);
|
|
85
|
-
const named =
|
|
94
|
+
const named = threads.slice(described.length).map(({ id }) => id);
|
|
95
|
+
const shared = sharedPlace(described);
|
|
96
|
+
|
|
97
|
+
const said = {
|
|
98
|
+
prototype: group.prototype,
|
|
99
|
+
fileTitle: group.fileTitle,
|
|
100
|
+
...SAID_OF_EVERY_THREAD,
|
|
101
|
+
...shared,
|
|
102
|
+
};
|
|
86
103
|
|
|
87
104
|
return {
|
|
88
105
|
...group,
|
|
89
106
|
files: someOf(group.files.map(show)),
|
|
90
|
-
|
|
107
|
+
...(Object.keys(shared).length > 0 ? { shared } : undefined),
|
|
108
|
+
threads: described.map((thread) => withoutSaid(thread, said)),
|
|
91
109
|
...(named.length > 0
|
|
92
110
|
? { more: { threads: named.length, ids: named.slice(0, MAX_IDS) } }
|
|
93
111
|
: undefined),
|
|
@@ -116,10 +134,15 @@ const claimAll = async (
|
|
|
116
134
|
return claimed;
|
|
117
135
|
};
|
|
118
136
|
|
|
119
|
-
/** What threads come to in `watch`'s result, as
|
|
120
|
-
const inGroups = (
|
|
121
|
-
|
|
122
|
-
|
|
137
|
+
/** What the threads shown come to in `watch`'s result, as `groupsWith` gives them in `groups`. */
|
|
138
|
+
const inGroups = (groups: WorkGroup[], show: (path: string) => string) => {
|
|
139
|
+
const size = (shown: Described[]) =>
|
|
140
|
+
sizeOf({ groups: groupsWith(groups, shown, show) });
|
|
141
|
+
|
|
142
|
+
const none = size([]);
|
|
143
|
+
|
|
144
|
+
return (shown: Described[]) => size(shown) - none;
|
|
145
|
+
};
|
|
123
146
|
|
|
124
147
|
/**
|
|
125
148
|
* What a group comes to in `watch`'s result as an agent works from it: its
|
|
@@ -168,8 +191,10 @@ const describeGroups = async (
|
|
|
168
191
|
return described;
|
|
169
192
|
};
|
|
170
193
|
|
|
194
|
+
const measure = inGroups(groups, inRoot);
|
|
195
|
+
|
|
171
196
|
const build = async (room: number) => {
|
|
172
|
-
const fit = await fitThreads(all, describe, room,
|
|
197
|
+
const fit = await fitThreads(all, describe, room, measure);
|
|
173
198
|
const leftOut = watchLeftOut(fit.short, fit.left);
|
|
174
199
|
|
|
175
200
|
return {
|
|
@@ -361,7 +386,7 @@ export function watchTool(context: CommentToolContext) {
|
|
|
361
386
|
_meta: ALWAYS_LOADED,
|
|
362
387
|
annotations: { readOnlyHint: false, destructiveHint: false },
|
|
363
388
|
title: "Wait for studio feedback",
|
|
364
|
-
description: `Wait for comments or requests that need an agent and take them: each thread returned is yours (👀). They come in groups, each with the files it may change: one view's threads, one request for a new view, or comments on the whole file. Returns at once when some are waiting; takes as many groups as it has room to describe and says how many are left, for the next call. With \`split\`, give each group to its own sub-agent, all at once, where you can. ${FEEDBACK_WORKFLOW} Where one has \`commands\`, it runs skills: do what each \`follow\` (a SKILL.md, files beside it) says, the comment's words its arguments. ${FORKED_COMMAND_HOW} \`groups: 1\` takes one group; \`ids\` takes threads by id. It keeps waiting while Dex's Watch switch is off. ${WATCH_HOW} ${LOOP_HOW}`,
|
|
389
|
+
description: `Wait for comments or requests that need an agent and take them: each thread returned is yours (👀). They come in groups, each with the files it may change: one view's threads, one request for a new view, or comments on the whole file. What a group's \`threads\` share (file, frame, spec) is in its \`shared\`. Returns at once when some are waiting; takes as many groups as it has room to describe and says how many are left, for the next call. With \`split\`, give each group to its own sub-agent, all at once, where you can. ${FEEDBACK_WORKFLOW} Where one has \`commands\`, it runs skills: do what each \`follow\` (a SKILL.md, files beside it) says, the comment's words its arguments. ${FORKED_COMMAND_HOW} \`groups: 1\` takes one group; \`ids\` takes threads by id. It keeps waiting while Dex's Watch switch is off. ${WATCH_HOW} ${LOOP_HOW}`,
|
|
365
390
|
inputSchema: {
|
|
366
391
|
prototype: PROTOTYPE.optional(),
|
|
367
392
|
timeout_seconds: z
|
|
@@ -470,7 +470,7 @@ export function groupOnPaths(
|
|
|
470
470
|
* between sub-agents where the agent can run them, else take them in turn.
|
|
471
471
|
*/
|
|
472
472
|
export const splitLine = (count: number): string =>
|
|
473
|
-
`Split this work first: these ${count} groups change separate files, so they run side by side. If you can run sub-agents, start one per group now (\`dex-worker\` if you have it), all at once in one message, each with its group's threads and files, to change only those files and close its own threads (a sub-agent that shares your context needs no brief). Then do any group marked as the whole file yourself. Only without sub-agents take the groups one after another.`;
|
|
473
|
+
`Split this work first: these ${count} groups change separate files, so they run side by side. If you can run sub-agents, start one per group now (\`dex-worker\` if you have it), all at once in one message, each with its group's threads, what they share and its files, to change only those files and close its own threads (a sub-agent that shares your context needs no brief). Then do any group marked as the whole file yourself. Only without sub-agents take the groups one after another.`;
|
|
474
474
|
|
|
475
475
|
/** A group in a line, for what is left waiting. */
|
|
476
476
|
/** A group in brief: where it is and how many threads it has. */
|
|
@@ -355,8 +355,8 @@ export const isNoteFrame = (frame: KindKeys): boolean =>
|
|
|
355
355
|
frameKind(frame) === "spec" && isNotePath(frame.spec as string);
|
|
356
356
|
|
|
357
357
|
/**
|
|
358
|
-
* Whether a frame is a section header: a note marked `header`,
|
|
359
|
-
*
|
|
358
|
+
* Whether a frame is a section header: a note marked `header`, its words
|
|
359
|
+
* large, placed as any note is and filling what it is in (layout.ts).
|
|
360
360
|
*/
|
|
361
361
|
export const isHeaderFrame = (
|
|
362
362
|
frame: KindKeys & { header?: unknown }
|
|
@@ -364,12 +364,15 @@ export const isHeaderFrame = (
|
|
|
364
364
|
|
|
365
365
|
/**
|
|
366
366
|
* A section's one frame, when it stands on its own (`at`) with nothing else:
|
|
367
|
-
* where a section header
|
|
367
|
+
* where a section header across the canvas is.
|
|
368
368
|
*/
|
|
369
369
|
const aloneIn = <F>(section: { at?: unknown }, frames: readonly F[]) =>
|
|
370
370
|
placedAt(section) && frames.length === 1 ? frames[0] : undefined;
|
|
371
371
|
|
|
372
|
-
/**
|
|
372
|
+
/**
|
|
373
|
+
* Whether a section is a section header standing on its own: a band across
|
|
374
|
+
* the canvas's content, splitting it into parts (layout.ts).
|
|
375
|
+
*/
|
|
373
376
|
export const isHeaderSection = (section: {
|
|
374
377
|
at?: unknown;
|
|
375
378
|
rows: readonly { frames: readonly (KindKeys & { header?: unknown })[] }[];
|
|
@@ -1073,14 +1076,18 @@ const stackSectionPiles = <F extends Piled>(section: {
|
|
|
1073
1076
|
/**
|
|
1074
1077
|
* The cell a request for a new view fills: a step in its row, or in a new
|
|
1075
1078
|
* row, right above the row `above` names (a step in a row has no row to go
|
|
1076
|
-
* above), else at the end of the section.
|
|
1079
|
+
* above), else at the end of the section. An agent's may leave the step out
|
|
1080
|
+
* (AskedCell).
|
|
1077
1081
|
*/
|
|
1078
|
-
export const requestCell = ({
|
|
1082
|
+
export const requestCell = <S extends number | undefined>({
|
|
1079
1083
|
above,
|
|
1080
1084
|
row,
|
|
1081
1085
|
section,
|
|
1082
1086
|
step,
|
|
1083
|
-
}: Pick<Cell, "above" | "row" | "section"
|
|
1087
|
+
}: Pick<Cell, "above" | "row" | "section"> & { step: S }): Omit<
|
|
1088
|
+
Cell,
|
|
1089
|
+
"step"
|
|
1090
|
+
> & { step: S } => {
|
|
1084
1091
|
if (row) {
|
|
1085
1092
|
return { section, row, step };
|
|
1086
1093
|
}
|
|
@@ -1088,6 +1095,110 @@ export const requestCell = ({
|
|
|
1088
1095
|
return above ? { section, above, step } : { section, step };
|
|
1089
1096
|
};
|
|
1090
1097
|
|
|
1098
|
+
/**
|
|
1099
|
+
* A cell as an agent asks for it: its step may be left out, for the free
|
|
1100
|
+
* step at the end of its row, or right of `after`, a step of its row
|
|
1101
|
+
* (stepAsked).
|
|
1102
|
+
*/
|
|
1103
|
+
export type AskedCell = Omit<Cell, "step"> & { after?: number; step?: number };
|
|
1104
|
+
|
|
1105
|
+
/** A row's frames, or none when the section or row is not there. */
|
|
1106
|
+
const rowFrames = <F extends Stepped>(
|
|
1107
|
+
canvas: WalkedCanvas<F>,
|
|
1108
|
+
section: string,
|
|
1109
|
+
row: string | undefined
|
|
1110
|
+
): F[] =>
|
|
1111
|
+
canvas.sections
|
|
1112
|
+
.find((entry) => entry.id === section)
|
|
1113
|
+
?.rows.find((entry) => row !== undefined && entry.id === row)?.frames ?? [];
|
|
1114
|
+
|
|
1115
|
+
/**
|
|
1116
|
+
* The step of a cell an agent asks for: its own, when given; else the step
|
|
1117
|
+
* right of `after`, or the free step at the end of its row and of `past`
|
|
1118
|
+
* (the row it was asked in, when the frame goes in a row of the person's
|
|
1119
|
+
* own below it). A frame for the view already in the row from there on is
|
|
1120
|
+
* kept where it is, so asking again finds it. A new row's free step is its
|
|
1121
|
+
* first.
|
|
1122
|
+
*/
|
|
1123
|
+
export function stepAsked<F extends CellFrame>(
|
|
1124
|
+
canvas: WalkedCanvas<F>,
|
|
1125
|
+
cell: AskedCell,
|
|
1126
|
+
view: string,
|
|
1127
|
+
past?: string
|
|
1128
|
+
): number {
|
|
1129
|
+
if (cell.step !== undefined) {
|
|
1130
|
+
return cell.step;
|
|
1131
|
+
}
|
|
1132
|
+
|
|
1133
|
+
const frames = rowFrames(canvas, cell.section, cell.row);
|
|
1134
|
+
const steps = stepsOf(frames);
|
|
1135
|
+
const from = (cell.after ?? 0) + 1;
|
|
1136
|
+
|
|
1137
|
+
const kept = steps.find((step, index) => {
|
|
1138
|
+
const frame = frames[index];
|
|
1139
|
+
|
|
1140
|
+
return (
|
|
1141
|
+
step >= from &&
|
|
1142
|
+
frame !== undefined &&
|
|
1143
|
+
frameKind(frame) === "view" &&
|
|
1144
|
+
frame.view === view
|
|
1145
|
+
);
|
|
1146
|
+
});
|
|
1147
|
+
|
|
1148
|
+
if (kept !== undefined) {
|
|
1149
|
+
return kept;
|
|
1150
|
+
}
|
|
1151
|
+
|
|
1152
|
+
if (cell.after !== undefined) {
|
|
1153
|
+
return cell.after + 1;
|
|
1154
|
+
}
|
|
1155
|
+
|
|
1156
|
+
const ends = [cell.row, past].map((row) =>
|
|
1157
|
+
Math.max(0, ...stepsOf(rowFrames(canvas, cell.section, row)))
|
|
1158
|
+
);
|
|
1159
|
+
|
|
1160
|
+
return Math.max(...ends) + 1;
|
|
1161
|
+
}
|
|
1162
|
+
|
|
1163
|
+
/** Where a frame is in its row: its step, and the frame it is right of. */
|
|
1164
|
+
export interface WhereInRow {
|
|
1165
|
+
/** The key of the top of the nearest stack to its left; none at the row's start. */
|
|
1166
|
+
rightOf?: string;
|
|
1167
|
+
step: number;
|
|
1168
|
+
}
|
|
1169
|
+
|
|
1170
|
+
/** Where the frame with a key is in its row; undefined when none has it. */
|
|
1171
|
+
export const whereInRow = <F extends CellFrame>(
|
|
1172
|
+
canvas: WalkedCanvas<F>,
|
|
1173
|
+
key: string
|
|
1174
|
+
): WhereInRow | undefined => {
|
|
1175
|
+
const { section, row, frame } = parseFrameKey(key);
|
|
1176
|
+
const frames = rowFrames(canvas, section, row);
|
|
1177
|
+
const steps = stepsOf(frames);
|
|
1178
|
+
const step = steps[frames.findIndex((entry) => entry.id === frame)];
|
|
1179
|
+
|
|
1180
|
+
if (step === undefined) {
|
|
1181
|
+
return;
|
|
1182
|
+
}
|
|
1183
|
+
|
|
1184
|
+
// The nearest step to its left with a stack, not only words.
|
|
1185
|
+
const left = Math.max(
|
|
1186
|
+
0,
|
|
1187
|
+
...frames.flatMap((entry, index) => {
|
|
1188
|
+
const at = steps[index] ?? 0;
|
|
1189
|
+
|
|
1190
|
+
return at < step && !isWordsFrame(entry) ? [at] : [];
|
|
1191
|
+
})
|
|
1192
|
+
);
|
|
1193
|
+
|
|
1194
|
+
const top =
|
|
1195
|
+
left > 0 ? stackTopIn({ frames }, { section, row, step: left }) : undefined;
|
|
1196
|
+
|
|
1197
|
+
return top === undefined
|
|
1198
|
+
? { step }
|
|
1199
|
+
: { step, rightOf: frameKey({ section, row, frame: top }) };
|
|
1200
|
+
};
|
|
1201
|
+
|
|
1091
1202
|
/**
|
|
1092
1203
|
* Put a new row among a section's rows: right above the row `above` names,
|
|
1093
1204
|
* as the + on the line between two rows asks, else below the others.
|
|
@@ -1738,22 +1849,6 @@ const placeProblems = (
|
|
|
1738
1849
|
return problems;
|
|
1739
1850
|
};
|
|
1740
1851
|
|
|
1741
|
-
/**
|
|
1742
|
-
* A section header is a band across the whole canvas: it stands on its own,
|
|
1743
|
-
* the one frame of a section with `at`, never in a section's cells.
|
|
1744
|
-
*/
|
|
1745
|
-
const headerPlaceProblems = (
|
|
1746
|
-
section: UncheckedSection | null,
|
|
1747
|
-
where: string
|
|
1748
|
-
): string[] => {
|
|
1749
|
-
const frames = (section?.rows ?? []).flatMap((row) => row?.frames ?? []);
|
|
1750
|
-
const header = frames.some((frame) => frame?.header !== undefined);
|
|
1751
|
-
|
|
1752
|
-
return header && aloneIn(section ?? {}, frames) === undefined
|
|
1753
|
-
? [`${where}: a section header stands on its own, outside any section`]
|
|
1754
|
-
: [];
|
|
1755
|
-
};
|
|
1756
|
-
|
|
1757
1852
|
/** Check a canvas against the views and docs that exist. */
|
|
1758
1853
|
export function canvasProblems(canvas: unknown, known: Known): string[] {
|
|
1759
1854
|
// SAFETY: ?. leaves out null and undefined, and any other value can be read
|
|
@@ -1782,10 +1877,7 @@ export function canvasProblems(canvas: unknown, known: Known): string[] {
|
|
|
1782
1877
|
problems.push(`${where}: "title" is required`);
|
|
1783
1878
|
}
|
|
1784
1879
|
|
|
1785
|
-
problems.push(
|
|
1786
|
-
...placeProblems(section, where),
|
|
1787
|
-
...headerPlaceProblems(section, where)
|
|
1788
|
-
);
|
|
1880
|
+
problems.push(...placeProblems(section, where));
|
|
1789
1881
|
const rowIds = new Set<unknown>();
|
|
1790
1882
|
|
|
1791
1883
|
for (const row of section?.rows ?? []) {
|
|
@@ -77,10 +77,13 @@ export interface DocFrame extends FrameBase {
|
|
|
77
77
|
export interface SpecFrame extends FrameBase {
|
|
78
78
|
doc?: undefined;
|
|
79
79
|
/**
|
|
80
|
-
* A note drawn as a section header
|
|
81
|
-
*
|
|
82
|
-
*
|
|
83
|
-
*
|
|
80
|
+
* A note drawn as a section header, its words large. It goes where any
|
|
81
|
+
* note goes: in a section's cells, where it fills the section from its
|
|
82
|
+
* column to the right edge of its frames; or on its own (a section with
|
|
83
|
+
* `at`), a band across the canvas's content that splits it into parts.
|
|
84
|
+
* Its `size.width`, once resized, is its own. Only a note
|
|
85
|
+
* (people/<person>/notes/) has one; an older Dex shows it as the note it
|
|
86
|
+
* is.
|
|
84
87
|
*/
|
|
85
88
|
header?: true;
|
|
86
89
|
/**
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export const MOMENTS = ["before", "after"] as const;
|
|
2
|
+
|
|
3
|
+
export type Moment = (typeof MOMENTS)[number];
|
|
4
|
+
|
|
5
|
+
export type KeptPictures = Partial<Record<Moment, number>>;
|
|
6
|
+
|
|
7
|
+
export const isMoment = (value: string | null): value is Moment =>
|
|
8
|
+
MOMENTS.some((moment) => moment === value);
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import { VIEW_BROKE, VIEW_ROOT } from "./page-messages.ts";
|
|
2
|
+
|
|
3
|
+
export interface PageLooks {
|
|
4
|
+
blank: boolean;
|
|
5
|
+
error?: string;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export interface LooksSelectors {
|
|
9
|
+
brokenViewNote: string;
|
|
10
|
+
viewRoot: string;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export const LOOKS_SELECTORS: LooksSelectors = {
|
|
14
|
+
brokenViewNote: `[${VIEW_BROKE}]`,
|
|
15
|
+
viewRoot: `[${VIEW_ROOT}]`,
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
interface PageNode {
|
|
19
|
+
nodeType: number;
|
|
20
|
+
textContent: string | null;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
interface PageElement extends PageNode {
|
|
24
|
+
childNodes: Iterable<PageNode>;
|
|
25
|
+
children: Iterable<PageElement>;
|
|
26
|
+
getBoundingClientRect: () => { height: number; width: number };
|
|
27
|
+
matches: (selector: string) => boolean;
|
|
28
|
+
querySelector: (selector: string) => PageElement | null;
|
|
29
|
+
querySelectorAll: (selector: string) => Iterable<PageElement>;
|
|
30
|
+
shadowRoot: Pick<PageElement, "querySelector"> | null;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
declare const document: Pick<PageElement, "querySelector"> & {
|
|
34
|
+
body: PageElement;
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
declare const getComputedStyle: (element: PageElement) => {
|
|
38
|
+
backgroundColor: string;
|
|
39
|
+
backgroundImage: string;
|
|
40
|
+
borderBottomStyle: string;
|
|
41
|
+
borderBottomWidth: string;
|
|
42
|
+
borderLeftStyle: string;
|
|
43
|
+
borderLeftWidth: string;
|
|
44
|
+
borderRightStyle: string;
|
|
45
|
+
borderRightWidth: string;
|
|
46
|
+
borderTopStyle: string;
|
|
47
|
+
borderTopWidth: string;
|
|
48
|
+
boxShadow: string;
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
export const pageLooks = ({
|
|
52
|
+
brokenViewNote,
|
|
53
|
+
viewRoot,
|
|
54
|
+
}: LooksSelectors): PageLooks => {
|
|
55
|
+
const longestError = 500;
|
|
56
|
+
const textNode = 3;
|
|
57
|
+
const spaces = /\s+/gu;
|
|
58
|
+
const pixels = /px$/u;
|
|
59
|
+
|
|
60
|
+
const media =
|
|
61
|
+
"img, svg, canvas, video, picture, iframe, object, embed, input, textarea, select, button, [role=img]";
|
|
62
|
+
|
|
63
|
+
const unpainted = new Set(["", "none", "transparent", "rgba(0, 0, 0, 0)"]);
|
|
64
|
+
|
|
65
|
+
const tidy = (text: string | null) =>
|
|
66
|
+
(text ?? "").replaceAll(spaces, " ").trim();
|
|
67
|
+
|
|
68
|
+
const note = document.querySelector(brokenViewNote);
|
|
69
|
+
const overlay = document.querySelector("vite-error-overlay");
|
|
70
|
+
|
|
71
|
+
const noteLines = note
|
|
72
|
+
? [...note.children]
|
|
73
|
+
.flatMap((line) => {
|
|
74
|
+
const text = tidy(line.textContent);
|
|
75
|
+
|
|
76
|
+
return text ? [text] : [];
|
|
77
|
+
})
|
|
78
|
+
.join(" ")
|
|
79
|
+
: undefined;
|
|
80
|
+
|
|
81
|
+
const overlayMessage = overlay
|
|
82
|
+
? tidy(
|
|
83
|
+
(overlay.shadowRoot?.querySelector(".message") ?? overlay).textContent
|
|
84
|
+
) || "Vite's error overlay shows."
|
|
85
|
+
: undefined;
|
|
86
|
+
|
|
87
|
+
const error = noteLines ?? overlayMessage;
|
|
88
|
+
const view = document.querySelector(viewRoot) ?? document.body;
|
|
89
|
+
const pageBackground = getComputedStyle(view).backgroundColor;
|
|
90
|
+
|
|
91
|
+
const paintedApart = (element: PageElement) => {
|
|
92
|
+
const style = getComputedStyle(element);
|
|
93
|
+
const { backgroundColor, backgroundImage, boxShadow } = style;
|
|
94
|
+
|
|
95
|
+
const bordered = [
|
|
96
|
+
[style.borderTopStyle, style.borderTopWidth],
|
|
97
|
+
[style.borderRightStyle, style.borderRightWidth],
|
|
98
|
+
[style.borderBottomStyle, style.borderBottomWidth],
|
|
99
|
+
[style.borderLeftStyle, style.borderLeftWidth],
|
|
100
|
+
].some(
|
|
101
|
+
([lineStyle, width]) =>
|
|
102
|
+
!unpainted.has(lineStyle) && Number(width.replace(pixels, "")) > 0
|
|
103
|
+
);
|
|
104
|
+
|
|
105
|
+
return (
|
|
106
|
+
bordered ||
|
|
107
|
+
!unpainted.has(boxShadow) ||
|
|
108
|
+
!unpainted.has(backgroundImage) ||
|
|
109
|
+
(!unpainted.has(backgroundColor) && backgroundColor !== pageBackground)
|
|
110
|
+
);
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
const laidOut = [view, ...view.querySelectorAll("*")].filter((element) => {
|
|
114
|
+
const { height, width } = element.getBoundingClientRect();
|
|
115
|
+
|
|
116
|
+
return height > 0 && width > 0;
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
const showsSomething = laidOut.some(
|
|
120
|
+
(element) =>
|
|
121
|
+
[...element.childNodes].some(
|
|
122
|
+
(node) => node.nodeType === textNode && tidy(node.textContent) !== ""
|
|
123
|
+
) ||
|
|
124
|
+
element.matches(media) ||
|
|
125
|
+
element.shadowRoot !== null ||
|
|
126
|
+
paintedApart(element)
|
|
127
|
+
);
|
|
128
|
+
|
|
129
|
+
return {
|
|
130
|
+
blank: !showsSomething,
|
|
131
|
+
...(error !== undefined && { error: error.slice(0, longestError) }),
|
|
132
|
+
};
|
|
133
|
+
};
|
|
@@ -49,6 +49,12 @@ export interface Capture {
|
|
|
49
49
|
label?: string;
|
|
50
50
|
nodes?: number;
|
|
51
51
|
size: { height: number; width: number };
|
|
52
|
+
/**
|
|
53
|
+
* How many of its elements the page sized or placed on the element, in
|
|
54
|
+
* pixels, as its scripts do when they lay it out: they keep that size, and
|
|
55
|
+
* don't reflow when the frame is resized.
|
|
56
|
+
*/
|
|
57
|
+
sizedByScripts?: number;
|
|
52
58
|
source?: { title?: string; url?: string };
|
|
53
59
|
tree: CapturedElement;
|
|
54
60
|
truncated?: boolean;
|
|
@@ -16,6 +16,7 @@ import type { AgentLaunch, Launched } from "@dexhq/harness/agents";
|
|
|
16
16
|
|
|
17
17
|
import type { AvatarFile } from "./avatar-file.ts";
|
|
18
18
|
import type { BuildSettings } from "./build-settings.ts";
|
|
19
|
+
import type { KeptPictures } from "./change-pictures-core.ts";
|
|
19
20
|
import type {
|
|
20
21
|
CommandChange,
|
|
21
22
|
CommandSwitch,
|
|
@@ -32,6 +33,7 @@ import type {
|
|
|
32
33
|
SyncKeep,
|
|
33
34
|
SyncResult,
|
|
34
35
|
} from "./git-core.ts";
|
|
36
|
+
import type { PageLooks } from "./page-looks.ts";
|
|
35
37
|
import type { Authored } from "./picks-core.ts";
|
|
36
38
|
import type { RemovedView } from "./removed-views-core.ts";
|
|
37
39
|
import type { ReviewImport } from "./review-file.ts";
|
|
@@ -425,6 +427,8 @@ export interface StudioAnswers<
|
|
|
425
427
|
* marked `large` when the person's canvas.json is near live sync's limit.
|
|
426
428
|
*/
|
|
427
429
|
canvas: { GET: Own["canvas"]; PUT: Own["canvas"] & { large?: true } };
|
|
430
|
+
"change-picture": { GET: Blob; PUT: Done; DELETE: Done };
|
|
431
|
+
"change-pictures": { GET: KeptPictures };
|
|
428
432
|
/**
|
|
429
433
|
* Comment commands: Dex's and the team's. POST saves one's file, PUT
|
|
430
434
|
* turns one on or off in the / menu, DELETE ?name= removes the team's file.
|
|
@@ -566,7 +570,9 @@ export interface StudioAnswers<
|
|
|
566
570
|
*/
|
|
567
571
|
show: { POST: { pages: number } };
|
|
568
572
|
/** A PNG, base64, and what looked wrong on its page. */
|
|
569
|
-
snapshot: {
|
|
573
|
+
snapshot: {
|
|
574
|
+
POST: { image: string; looks: PageLooks; problems: string[] };
|
|
575
|
+
};
|
|
570
576
|
"spec-suggestion": { POST: ThreadWithPrototype };
|
|
571
577
|
/** The file each changed. */
|
|
572
578
|
text: { POST: { file: string } };
|
|
@@ -4,8 +4,9 @@ description: "Makes one group of Dex comments' change in the design system and c
|
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
You make one group of comments' change in a Dex file. The brief gives you
|
|
7
|
-
the group: its threads, the element each is on,
|
|
8
|
-
change. Change only those files;
|
|
7
|
+
the group: its threads, the element each is on, what they share (said
|
|
8
|
+
once for them all), and the files it may change. Change only those files;
|
|
9
|
+
other groups are someone else's.
|
|
9
10
|
|
|
10
11
|
Read every thread first: related ones are one change. Start from `source`
|
|
11
12
|
and `style` where a thread has them, the lines that render its element and
|
|
@@ -14,10 +15,11 @@ never markup or CSS of your own for what it has. Write only in the folder
|
|
|
14
15
|
of the person you work for. Dex's rules are in its `templates/rules/`;
|
|
15
16
|
read `rules/always.md` if you have not.
|
|
16
17
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
18
|
+
Close each thread with `close` as soon as its change is made, with one
|
|
19
|
+
short line on what changed and `where` it landed. `close` checks the code
|
|
20
|
+
and pictures the comment's frame, and keeps a thread open while the code is
|
|
21
|
+
broken or the view shows an error or nothing: fix it and close again. When
|
|
22
|
+
the change is about layout or states, look at the view with `snapshot`
|
|
23
|
+
first. Where a thread asks a question, answer it with `reply`.
|
|
22
24
|
|
|
23
25
|
When you are done, say in a line or two what you changed, by thread.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
Read them all first; related ones are one change. Start from `source` and `style` where a comment has them: the lines rendering its element and its CSS rule. Make clear fixes straight away; for a new view, a wireframe or a review, read `methods/review.md`. Close each group's threads with `close` once done, a line each on what changed: it checks the change
|
|
1
|
+
Read them all first; related ones are one change. Start from `source` and `style` where a comment has them: the lines rendering its element and its CSS rule. Make clear fixes straight away; for a new view, a wireframe or a review, read `methods/review.md`. Close each group's threads with `close` once done, a line each on what changed: it checks the change and pictures its frame, keeping a thread open while broken, so a small change needs no `snapshot`. Where one says "asked", answer it with `reply`; rarely, reply with ask: true when a request is too ambiguous to act on.
|