@dexhq/canvas 0.14.0 → 0.15.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 +36 -0
- package/README.md +5 -3
- package/app/canvas/activity.tsx +8 -15
- package/app/canvas/anchoring.ts +3 -5
- package/app/canvas/canvas-input.ts +151 -14
- package/app/canvas/canvas-keys.ts +9 -0
- package/app/canvas/canvas-model.ts +5 -42
- package/app/canvas/canvas-panels.ts +1 -17
- package/app/canvas/canvas-scene.ts +7 -3
- package/app/canvas/canvas-ui.ts +2 -1
- package/app/canvas/canvas.css +61 -26
- package/app/canvas/change-notice.tsx +10 -1
- package/app/canvas/comment-layer.tsx +2 -1
- package/app/canvas/comments.tsx +204 -82
- package/app/canvas/element-picker.ts +200 -27
- package/app/canvas/engine/canvas-gestures.ts +72 -17
- package/app/canvas/engine/canvas-store.ts +17 -1
- package/app/canvas/engine/engine.css +6 -3
- package/app/canvas/find-bar.tsx +817 -0
- package/app/canvas/find-model.ts +135 -0
- package/app/canvas/flow-canvas.tsx +18 -2
- package/app/canvas/follow-pin.ts +26 -6
- package/app/canvas/frame-node.tsx +9 -9
- package/app/canvas/imported-reviews.tsx +12 -22
- package/app/canvas/layout.ts +27 -0
- package/app/canvas/live-page.ts +142 -19
- package/app/canvas/page-find.ts +220 -0
- package/app/canvas/page-style.ts +23 -0
- package/app/canvas/section-node.tsx +2 -0
- package/app/canvas/spec-threads.ts +24 -23
- package/app/canvas/thread-focus.tsx +14 -12
- package/app/canvas/use-activity.ts +0 -8
- package/app/canvas/use-agent-changes.tsx +34 -40
- package/app/canvas/use-canvas-clipboard.tsx +11 -14
- package/app/canvas/xray.ts +3 -12
- package/app/frame.tsx +5 -0
- package/app/i18n/locales/en/messages.po +88 -8
- package/app/i18n/locales/en/messages.ts +1 -1
- package/app/i18n/locales/pseudo/messages.po +88 -8
- package/app/i18n/locales/pseudo/messages.ts +1 -1
- package/app/icons/glyphs.tsx +4 -0
- package/app/main.tsx +3 -0
- package/app/pages/canvas.tsx +27 -8
- package/app/pages/commands-settings.tsx +16 -2
- package/app/shell/feedback-form.tsx +10 -21
- package/app/shell/feedback-link.tsx +2 -1
- package/app/shell/scaled-frame.tsx +21 -9
- package/app/types.ts +21 -205
- package/app/ui/file-drop.ts +128 -0
- package/app/ui/shadcn/input-group.tsx +2 -2
- package/dist/cli/banner.d.mts +4 -2
- package/dist/cli/banner.mjs +34 -11
- package/dist/cli/commands/app.mjs +19 -11
- package/dist/cli/commands/hook.mjs +2 -1
- package/dist/config/project-files.d.mts +6 -0
- package/dist/config/project-files.mjs +14 -2
- package/dist/config/renamed.d.mts +0 -2
- package/dist/config/renamed.mjs +1 -3
- package/dist/content/capture.d.mts +2 -2
- package/dist/content/capture.mjs +2 -2
- package/dist/content/content.d.mts +3 -141
- package/dist/content/content.mjs +7 -62
- package/dist/content/flow-specs.mjs +1 -1
- package/dist/content/prototype-summary.d.mts +3 -39
- package/dist/content/prototype-summary.mjs +2 -3
- package/dist/content/prototypes.mjs +1 -1
- package/dist/content/text-replace.d.mts +30 -0
- package/dist/content/text-replace.mjs +309 -0
- package/dist/content/thread-module.mjs +1 -1
- package/dist/content/threads.mjs +1 -1
- package/dist/paste/paste.mjs +1 -1
- package/dist/paths.d.mts +0 -2
- package/dist/paths.mjs +1 -3
- package/dist/server/agent-env.d.mts +5 -1
- package/dist/server/agent-env.mjs +7 -2
- package/dist/server/agent-session.d.mts +14 -1
- package/dist/server/agent-session.mjs +84 -19
- package/dist/server/build-pictures.mjs +1 -1
- package/dist/server/channel.d.mts +13 -24
- package/dist/server/channel.mjs +55 -37
- package/dist/server/claimed-presence.d.mts +3 -2
- package/dist/server/claimed-presence.mjs +15 -7
- package/dist/server/close-check.mjs +2 -2
- package/dist/server/comments/actions.d.mts +153 -0
- package/dist/server/comments/actions.mjs +154 -0
- package/dist/server/comments/routes.d.mts +25 -0
- package/dist/server/comments/routes.mjs +88 -0
- package/dist/server/comments/tools.d.mts +6 -0
- package/dist/server/comments/tools.mjs +154 -0
- package/dist/server/dev-server.mjs +27 -13
- package/dist/server/file-lock.d.mts +2 -2
- package/dist/server/file-lock.mjs +130 -36
- package/dist/server/mcp.d.mts +0 -2
- package/dist/server/mcp.mjs +7 -8
- package/dist/server/me.d.mts +1 -1
- package/dist/server/open-page.d.mts +22 -0
- package/dist/server/open-page.mjs +20 -2
- package/dist/server/outcome.d.mts +22 -0
- package/dist/server/outcome.mjs +8 -0
- package/dist/server/own-copies.mjs +2 -2
- package/dist/server/people.d.mts +1 -1
- package/dist/server/port.d.mts +12 -0
- package/dist/server/port.mjs +66 -14
- package/dist/server/presence.d.mts +4 -1
- package/dist/server/presence.mjs +2 -2
- package/dist/server/requests.d.mts +5 -1
- package/dist/server/requests.mjs +33 -48
- package/dist/server/studio-for.d.mts +5 -0
- package/dist/server/studio-for.mjs +17 -3
- package/dist/server/sync-install.d.mts +8 -12
- package/dist/server/sync-install.mjs +12 -30
- package/dist/server/thread-source.mjs +2 -2
- package/dist/server/tools/describe.d.mts +1 -1
- package/dist/server/tools/describe.mjs +1 -1
- package/dist/server/tools/feedback.d.mts +1 -1
- package/dist/server/tools/reading.mjs +13 -4
- package/dist/server/tools/show.d.mts +1 -1
- package/dist/server/tools/snapshot.d.mts +1 -1
- package/dist/server/tools/thread-list.mjs +1 -1
- package/dist/server/tools/watch.mjs +5 -3
- package/dist/server/vite.mjs +2 -2
- package/dist/server/web-app.mjs +4 -7
- package/dist/server/work-groups.mjs +1 -1
- package/dist/setup/create.d.mts +4 -2
- package/dist/setup/create.mjs +67 -17
- package/dist/setup/design-system-checks.mjs +3 -12
- package/dist/setup/desktop-app-script.mjs +4 -3
- package/dist/setup/desktop-app-start.d.mts +8 -2
- package/dist/setup/desktop-app-start.mjs +64 -29
- package/dist/setup/desktop-app.d.mts +8 -0
- package/dist/setup/desktop-app.mjs +19 -3
- package/dist/setup/detect.d.mts +0 -2
- package/dist/setup/detect.mjs +1 -3
- package/dist/setup/doctor.mjs +1 -1
- package/dist/setup/migrate/row-titles.mjs +1 -1
- package/dist/setup/project.d.mts +6 -1
- package/dist/setup/project.mjs +9 -9
- package/dist/setup/starters.d.mts +2 -0
- package/dist/setup/starters.mjs +7 -1
- package/dist/shared/annotations-core.mjs +1 -1
- package/dist/shared/canvas-core.mjs +1 -1
- package/dist/shared/canvas-file.d.mts +201 -0
- package/dist/shared/canvas-file.mjs +1 -0
- package/dist/shared/comments/routes.d.mts +53 -0
- package/dist/shared/comments/routes.mjs +37 -0
- package/dist/shared/feedback.d.mts +8 -0
- package/dist/shared/feedback.mjs +10 -2
- package/dist/shared/page-review.d.mts +2 -11
- package/dist/shared/page-review.mjs +4 -13
- package/dist/shared/presence-core.d.mts +11 -0
- package/dist/shared/presence-core.mjs +11 -2
- package/dist/shared/review-file.d.mts +5 -0
- package/dist/shared/review-file.mjs +23 -13
- package/dist/shared/server-page.mjs +1 -1
- package/dist/shared/signup.d.mts +2 -5
- package/dist/shared/signup.mjs +2 -35
- package/dist/shared/studio-events.d.mts +0 -6
- package/dist/shared/studio-events.mjs +1 -5
- package/dist/shared/studio-files.d.mts +12 -0
- package/dist/shared/studio-files.mjs +6 -1
- package/dist/shared/studio-routes.d.mts +16 -62
- package/dist/shared/studio-routes.mjs +1 -69
- package/dist/shared/threads-core.d.mts +2 -2
- package/dist/shared/threads-core.mjs +1 -1
- package/extension/dist/feedback.js +148 -138
- package/extension/dist/manifest.json +1 -1
- package/extension/dist/picker.js +146 -136
- package/package.json +2 -2
- package/src/cli/banner.ts +45 -11
- package/src/cli/commands/app.ts +23 -8
- package/src/cli/commands/hook.ts +4 -1
- package/src/config/project-files.ts +21 -6
- package/src/config/renamed.ts +0 -3
- package/src/content/capture.ts +6 -12
- package/src/content/content.ts +7 -241
- package/src/content/flow-specs.ts +2 -1
- package/src/content/prototype-summary.ts +4 -44
- package/src/content/review-pages.ts +2 -1
- package/src/content/text-replace.ts +449 -0
- package/src/paths.ts +0 -8
- package/src/server/agent-env.ts +12 -2
- package/src/server/agent-session.ts +124 -34
- package/src/server/channel.ts +94 -52
- package/src/server/claimed-presence.ts +26 -10
- package/src/server/comments/actions.ts +352 -0
- package/src/server/comments/routes.ts +176 -0
- package/src/server/comments/tools.ts +317 -0
- package/src/server/dev-server.ts +36 -15
- package/src/server/file-lock.ts +205 -54
- package/src/server/mcp.ts +13 -14
- package/src/server/me.ts +2 -5
- package/src/server/open-page.ts +54 -4
- package/src/server/outcome.ts +26 -0
- package/src/server/people.ts +2 -1
- package/src/server/port.ts +94 -20
- package/src/server/presence.ts +11 -3
- package/src/server/requests.ts +60 -70
- package/src/server/studio-for.ts +26 -2
- package/src/server/sync-install.ts +35 -26
- package/src/server/thread-place.ts +2 -4
- package/src/server/tools/reading.ts +16 -3
- package/src/server/tools/watch.ts +7 -7
- package/src/server/web-app.ts +11 -9
- package/src/setup/create.ts +91 -17
- package/src/setup/design-system-checks.ts +7 -15
- package/src/setup/desktop-app-script.ts +4 -3
- package/src/setup/desktop-app-start.ts +94 -26
- package/src/setup/desktop-app.ts +23 -2
- package/src/setup/detect.ts +0 -4
- package/src/setup/project.ts +9 -8
- package/src/setup/starters.ts +8 -1
- package/src/shared/canvas-file.ts +205 -0
- package/src/shared/comments/routes.ts +79 -0
- package/src/shared/feedback.ts +14 -4
- package/src/shared/page-review.ts +11 -16
- package/src/shared/presence-core.ts +16 -2
- package/src/shared/review-file.ts +28 -12
- package/src/shared/server-page.ts +2 -1
- package/src/shared/signup.ts +4 -28
- package/src/shared/studio-events.ts +0 -13
- package/src/shared/studio-files.ts +14 -0
- package/src/shared/studio-routes.ts +21 -64
- package/src/shared/threads-core.ts +2 -2
- package/dist/server/tools/close-reply.d.mts +0 -6
- package/dist/server/tools/close-reply.mjs +0 -138
- package/dist/server/tools/comment.d.mts +0 -6
- package/dist/server/tools/comment.mjs +0 -49
- package/src/server/tools/close-reply.ts +0 -271
- package/src/server/tools/comment.ts +0 -96
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
// canvas.json: the frames, rows and sections of a prototype's canvas, as
|
|
2
|
+
// people/<person>/canvas.json has them and the studio reads them. The one
|
|
3
|
+
// declaration the commands, the server and the interface all use;
|
|
4
|
+
// canvas-core.ts has the rules that check one. Types only, so the browser can
|
|
5
|
+
// use it too.
|
|
6
|
+
|
|
7
|
+
import type { CanvasPoint, SlideLayout, Viewport } from "./canvas-core.ts";
|
|
8
|
+
import type { FrameGrid, FrameGuide } from "./frame-grids.ts";
|
|
9
|
+
import type { Sketch } from "./sketch-core.ts";
|
|
10
|
+
|
|
11
|
+
interface FrameBase {
|
|
12
|
+
/**
|
|
13
|
+
* On a column's first frame: the id of a frame stacked further down a
|
|
14
|
+
* column to its left, in its row, for this column to start level with
|
|
15
|
+
* rather than at the row's top.
|
|
16
|
+
*/
|
|
17
|
+
beside?: string;
|
|
18
|
+
id: string;
|
|
19
|
+
/**
|
|
20
|
+
* The step this frame shows, counted from 1: its column on the canvas. Leave
|
|
21
|
+
* out to follow the previous frame in the row.
|
|
22
|
+
*/
|
|
23
|
+
step?: number;
|
|
24
|
+
title?: string;
|
|
25
|
+
/**
|
|
26
|
+
* Which frame this is, for good: kept when it moves or is renamed, new on
|
|
27
|
+
* a copy. Picks follow it. Given to the saver's frames that have none when
|
|
28
|
+
* they save.
|
|
29
|
+
*/
|
|
30
|
+
uid?: string;
|
|
31
|
+
/**
|
|
32
|
+
* Stacked directly below the frame before it in its row, in that frame's
|
|
33
|
+
* column, rather than in a column of its own.
|
|
34
|
+
*/
|
|
35
|
+
under?: true;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/** A live, interactive render of one of the prototype's views. */
|
|
39
|
+
export interface ViewFrame extends FrameBase {
|
|
40
|
+
doc?: undefined;
|
|
41
|
+
/** The frame's own grids, shown in place of the canvas's (Figma's, pasted). */
|
|
42
|
+
grids?: FrameGrid[];
|
|
43
|
+
/** Guide lines on the frame. */
|
|
44
|
+
guides?: FrameGuide[];
|
|
45
|
+
params?: Record<string, string>;
|
|
46
|
+
/** A fixed size in pixels, for a snapshot of one element; else the viewport's. */
|
|
47
|
+
size?: { height: number; width: number };
|
|
48
|
+
sketch?: undefined;
|
|
49
|
+
/**
|
|
50
|
+
* Where a snapshot was captured from, and when; and the image it is, when
|
|
51
|
+
* it is one, in the prototype's folder: "images/….png".
|
|
52
|
+
*/
|
|
53
|
+
snapshot?: { captured: string; image?: string; url: string };
|
|
54
|
+
spec?: undefined;
|
|
55
|
+
view: string;
|
|
56
|
+
viewport?: Viewport;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/** A markdown document from the prototype's docs folder. */
|
|
60
|
+
export interface DocFrame extends FrameBase {
|
|
61
|
+
doc: string;
|
|
62
|
+
/** A size of its own in pixels, set by resizing it; else 640 by 900. */
|
|
63
|
+
size?: { height: number; width: number };
|
|
64
|
+
sketch?: undefined;
|
|
65
|
+
spec?: undefined;
|
|
66
|
+
view?: undefined;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* A spec, edited in place on the canvas: a markdown file in its placer's
|
|
71
|
+
* folder. In a section, it is that section's spec; outside any section, it is part
|
|
72
|
+
* of the file spec.
|
|
73
|
+
*/
|
|
74
|
+
export interface SpecFrame extends FrameBase {
|
|
75
|
+
doc?: undefined;
|
|
76
|
+
/**
|
|
77
|
+
* A slide's layout: its first frame beside its words (the default), or
|
|
78
|
+
* centred above them. Only a slide (people/<person>/slides/) has one.
|
|
79
|
+
*/
|
|
80
|
+
layout?: SlideLayout;
|
|
81
|
+
/**
|
|
82
|
+
* A width of its own in pixels, set by resizing it; else 520. With a
|
|
83
|
+
* height, it is never taller than that, and scrolls; without one, it is
|
|
84
|
+
* as tall as its words (never less than 240). A slide's is fixed, both
|
|
85
|
+
* ways: 1920 by 1080 until resized.
|
|
86
|
+
*/
|
|
87
|
+
size?: { height?: number; width: number };
|
|
88
|
+
sketch?: undefined;
|
|
89
|
+
/** Its file, from the file's folder: "people/ana/specs/checkout.md". */
|
|
90
|
+
spec: string;
|
|
91
|
+
view?: undefined;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
export interface SketchFrame extends FrameBase {
|
|
95
|
+
doc?: undefined;
|
|
96
|
+
sketch: Sketch;
|
|
97
|
+
spec?: undefined;
|
|
98
|
+
/** Required, as an older Dex names a frame by its title or view. */
|
|
99
|
+
title: string;
|
|
100
|
+
view?: undefined;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
declare const readFromDisk: unique symbol;
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* A frame this Dex cannot show: a kind from a newer Dex, or a mistake.
|
|
107
|
+
* Only reading a canvas makes one, so Dex never writes a frame that shows
|
|
108
|
+
* nothing.
|
|
109
|
+
*/
|
|
110
|
+
export interface UnknownFrame extends FrameBase {
|
|
111
|
+
doc?: undefined;
|
|
112
|
+
sketch?: undefined;
|
|
113
|
+
spec?: undefined;
|
|
114
|
+
view?: undefined;
|
|
115
|
+
readonly [readFromDisk]: true;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
export type Frame =
|
|
119
|
+
| ViewFrame
|
|
120
|
+
| DocFrame
|
|
121
|
+
| SpecFrame
|
|
122
|
+
| SketchFrame
|
|
123
|
+
| UnknownFrame;
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* One pass through the section's steps: the main path, an error state, an
|
|
127
|
+
* alternative. Its frames are the steps, left to right.
|
|
128
|
+
*/
|
|
129
|
+
export interface Row {
|
|
130
|
+
/**
|
|
131
|
+
* In a person's copy of someone else's section: the id of their row this one
|
|
132
|
+
* is shown under (people-core.ts).
|
|
133
|
+
*/
|
|
134
|
+
after?: string;
|
|
135
|
+
/**
|
|
136
|
+
* Whose it is, when not its section's: someone's version of a row in
|
|
137
|
+
* another person's section. Set when the canvas is read, never written.
|
|
138
|
+
*/
|
|
139
|
+
author?: string;
|
|
140
|
+
/** The id of the section in its author's file that keeps it. */
|
|
141
|
+
copy?: string;
|
|
142
|
+
frames: Frame[];
|
|
143
|
+
id: string;
|
|
144
|
+
title?: string;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* A section. Rows below the first are iterations of it. With `at`, a frame of
|
|
149
|
+
* its own instead: one frame, drawn at that point, with no section around it.
|
|
150
|
+
*/
|
|
151
|
+
export interface Section {
|
|
152
|
+
/** Where a frame of its own's top left corner is, in canvas pixels. */
|
|
153
|
+
at?: CanvasPoint;
|
|
154
|
+
/**
|
|
155
|
+
* Whose it is: the person whose people/<person>/canvas.json it is in. Set
|
|
156
|
+
* when the canvas is read, never written; only they change it.
|
|
157
|
+
*/
|
|
158
|
+
author?: string;
|
|
159
|
+
/** The id of the section it is a copy of, shown right below it. */
|
|
160
|
+
copyOf?: string;
|
|
161
|
+
/** When it was added, as an ISO date. */
|
|
162
|
+
created?: string;
|
|
163
|
+
description?: string;
|
|
164
|
+
/** Whose section it was copied from, when it is a copy. */
|
|
165
|
+
from?: string;
|
|
166
|
+
id: string;
|
|
167
|
+
/**
|
|
168
|
+
* Where the section's area starts, its top left corner in canvas pixels,
|
|
169
|
+
* once someone has drawn it or dragged it there. None stacks it with the
|
|
170
|
+
* others, top to bottom.
|
|
171
|
+
*/
|
|
172
|
+
position?: CanvasPoint;
|
|
173
|
+
rows: Row[];
|
|
174
|
+
/**
|
|
175
|
+
* The least size of a section's area, in canvas pixels, once someone has
|
|
176
|
+
* sized it or frames have left it: its frames still grow it, but it never
|
|
177
|
+
* shrinks below this.
|
|
178
|
+
*/
|
|
179
|
+
size?: { height: number; width: number };
|
|
180
|
+
title: string;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
/**
|
|
184
|
+
* canvas.json: sections stacked top to bottom, and frames of their own where
|
|
185
|
+
* they were drawn. In each section, steps run left to right and iterations
|
|
186
|
+
* (states, errors, alternatives) top to bottom.
|
|
187
|
+
*/
|
|
188
|
+
export interface Canvas {
|
|
189
|
+
/**
|
|
190
|
+
* Set in a person's file once their frames have uids: from then on, a
|
|
191
|
+
* frame of theirs with none is new.
|
|
192
|
+
*/
|
|
193
|
+
frameUids?: true;
|
|
194
|
+
/**
|
|
195
|
+
* Whose sections come first, as the canvas was read: each
|
|
196
|
+
* person by when they joined. Never saved.
|
|
197
|
+
*/
|
|
198
|
+
people?: readonly string[];
|
|
199
|
+
sections: Section[];
|
|
200
|
+
/**
|
|
201
|
+
* Whose canvas.json has given its frames uids, as the canvas was read: a
|
|
202
|
+
* frame of theirs with none is new. Never saved.
|
|
203
|
+
*/
|
|
204
|
+
uidsGiven?: readonly string[];
|
|
205
|
+
}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
// The comment requests, as the interface and the server both know them:
|
|
2
|
+
// each one's name, the methods it takes, the body it takes, as the zod
|
|
3
|
+
// schema the server checks every request against, and what it answers to
|
|
4
|
+
// each. The list of every request and its types take them from here, so a
|
|
5
|
+
// comment request is declared once, in this file. The interface imports
|
|
6
|
+
// this module for its types alone, so zod never runs in the browser.
|
|
7
|
+
//
|
|
8
|
+
// Only a field's type is checked here. What a value may be (a target's
|
|
9
|
+
// kinds, the statuses, who a comment is for) is the thread rules'
|
|
10
|
+
// (threads-core.ts), which refuse it where it is kept.
|
|
11
|
+
|
|
12
|
+
import { z } from "zod";
|
|
13
|
+
import { isRecord } from "../checks.ts";
|
|
14
|
+
import type {
|
|
15
|
+
Sketch,
|
|
16
|
+
ThreadAudience,
|
|
17
|
+
ThreadStatus,
|
|
18
|
+
ThreadTarget,
|
|
19
|
+
ThreadWithPrototype,
|
|
20
|
+
} from "../threads-core.ts";
|
|
21
|
+
|
|
22
|
+
/** An object, of a type whose fields the thread rules check. */
|
|
23
|
+
const record = <T>(what: string) => z.custom<T>(isRecord, `Expected ${what}`);
|
|
24
|
+
|
|
25
|
+
/** Text, of a type whose words the thread rules check. */
|
|
26
|
+
const word = <T extends string>() =>
|
|
27
|
+
z.custom<T>((value) => typeof value === "string", "Expected text");
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* A comment to start: what it is on, its first message (left out with a
|
|
31
|
+
* wireframe), who it is for, and a wireframe for an agent to build.
|
|
32
|
+
*/
|
|
33
|
+
export const NEW_COMMENT = z.object({
|
|
34
|
+
target: record<ThreadTarget>("what the comment is on, with its kind"),
|
|
35
|
+
body: z.string().optional(),
|
|
36
|
+
for: word<ThreadAudience>().optional(),
|
|
37
|
+
sketch: record<Sketch>("a wireframe").optional(),
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* A person's change to a comment, by its id: a reply, a status, who it is
|
|
42
|
+
* for, a reaction, an edit or removal of their own message (`on`, by its
|
|
43
|
+
* `at`), or a review's comment hidden from the published site.
|
|
44
|
+
*/
|
|
45
|
+
export const COMMENT_CHANGE = z.object({
|
|
46
|
+
id: z.string(),
|
|
47
|
+
body: z.string().optional(),
|
|
48
|
+
edit: z.string().optional(),
|
|
49
|
+
for: word<ThreadAudience>().optional(),
|
|
50
|
+
hidden: z.boolean().optional(),
|
|
51
|
+
on: z.string().optional(),
|
|
52
|
+
react: z.string().optional(),
|
|
53
|
+
remove: z.boolean().optional(),
|
|
54
|
+
status: word<ThreadStatus>().optional(),
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Each comment request, by name, and its answer to each method it takes.
|
|
59
|
+
* The query a request needs is in its comment.
|
|
60
|
+
*/
|
|
61
|
+
export interface CommentAnswers {
|
|
62
|
+
/** ?slug= for one prototype's, or none for every one's. */
|
|
63
|
+
threads: { GET: ThreadWithPrototype[]; POST: ThreadWithPrototype };
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/** The bodies they take, by request and method, as the schemas above check them. */
|
|
67
|
+
export interface CommentBodies {
|
|
68
|
+
/** A comment to start, or a change to one, by its id. */
|
|
69
|
+
threads: {
|
|
70
|
+
POST: z.input<typeof NEW_COMMENT> | z.input<typeof COMMENT_CHANGE>;
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/** The comment requests and the methods each takes. */
|
|
75
|
+
export const COMMENT_ROUTES = {
|
|
76
|
+
threads: ["GET", "POST"],
|
|
77
|
+
} as const satisfies {
|
|
78
|
+
[Name in keyof CommentAnswers]: readonly (keyof CommentAnswers[Name])[];
|
|
79
|
+
};
|
package/src/shared/feedback.ts
CHANGED
|
@@ -259,11 +259,21 @@ export const sendFeedback = async (
|
|
|
259
259
|
if (problems.length > 0) {
|
|
260
260
|
return { ok: false, reason: "invalid", problems };
|
|
261
261
|
}
|
|
262
|
+
return await postToRelay(url, toForm(feedback), fetch);
|
|
263
|
+
};
|
|
264
|
+
|
|
265
|
+
/**
|
|
266
|
+
* Post a form to a relay and read its answer: the tracker's id, or why not.
|
|
267
|
+
* A form, so a simple request with no preflight; sign-ups travel this way
|
|
268
|
+
* too (signup.ts). Never throws.
|
|
269
|
+
*/
|
|
270
|
+
export const postToRelay = async (
|
|
271
|
+
url: string,
|
|
272
|
+
form: FormData,
|
|
273
|
+
fetch: NonNullable<SendOptions["fetch"]>
|
|
274
|
+
): Promise<Exclude<Sent, { reason: "invalid" }>> => {
|
|
262
275
|
try {
|
|
263
|
-
const response = await fetch(url, {
|
|
264
|
-
method: "POST",
|
|
265
|
-
body: toForm(feedback),
|
|
266
|
-
});
|
|
276
|
+
const response = await fetch(url, { method: "POST", body: form });
|
|
267
277
|
if (response.ok) {
|
|
268
278
|
// Sent only once the relay says what it filed it as.
|
|
269
279
|
const { id } = (await response.json()) as { id?: unknown };
|
|
@@ -8,7 +8,12 @@
|
|
|
8
8
|
// Browser-safe, so the import dialog can say what a file is first.
|
|
9
9
|
|
|
10
10
|
import { isRecord, isText } from "./checks.ts";
|
|
11
|
-
import {
|
|
11
|
+
import {
|
|
12
|
+
isReviewFormat,
|
|
13
|
+
REVIEW_VERSION,
|
|
14
|
+
type ReviewFile,
|
|
15
|
+
reviewHeader,
|
|
16
|
+
} from "./review-file.ts";
|
|
12
17
|
import { THREAD_ID_RE } from "./threads-core.ts";
|
|
13
18
|
import { unzip } from "./unzip.ts";
|
|
14
19
|
|
|
@@ -70,14 +75,13 @@ export interface ReviewPage {
|
|
|
70
75
|
}
|
|
71
76
|
|
|
72
77
|
/** A Markup review, checked. */
|
|
73
|
-
export interface PageReviewFile
|
|
78
|
+
export interface PageReviewFile
|
|
79
|
+
extends Pick<ReviewFile, "review" | "reviewer"> {
|
|
74
80
|
/** The app it is of: its origin, unless its config names it. */
|
|
75
81
|
app: string;
|
|
76
82
|
/** The outline's tasks, in its order. */
|
|
77
83
|
outline?: { tasks: { id: string; title: string }[] };
|
|
78
84
|
pages: ReviewPage[];
|
|
79
|
-
review: { completed?: string; created?: string; id: string; title: string };
|
|
80
|
-
reviewer: { key: string; name: string };
|
|
81
85
|
threads: PageComment[];
|
|
82
86
|
}
|
|
83
87
|
|
|
@@ -204,8 +208,8 @@ export function parsePageReview(value: unknown): PageReviewAnswer {
|
|
|
204
208
|
if (value.version !== REVIEW_VERSION) {
|
|
205
209
|
return { problem: "newer" };
|
|
206
210
|
}
|
|
207
|
-
const
|
|
208
|
-
if (!(
|
|
211
|
+
const header = reviewHeader(value.review, value.reviewer);
|
|
212
|
+
if (!(header && isText(value.app))) {
|
|
209
213
|
return { problem: "unreadable" };
|
|
210
214
|
}
|
|
211
215
|
const listed: unknown[] = Array.isArray(value.threads) ? value.threads : [];
|
|
@@ -220,16 +224,7 @@ export function parsePageReview(value: unknown): PageReviewAnswer {
|
|
|
220
224
|
return {
|
|
221
225
|
review: {
|
|
222
226
|
app: value.app,
|
|
223
|
-
|
|
224
|
-
id: review.id,
|
|
225
|
-
title: isText(review.title) ? review.title.trim() : "",
|
|
226
|
-
...(isText(review.created) ? { created: review.created } : {}),
|
|
227
|
-
...(isText(review.completed) ? { completed: review.completed } : {}),
|
|
228
|
-
},
|
|
229
|
-
reviewer: {
|
|
230
|
-
key: reviewer.key,
|
|
231
|
-
name: isText(reviewer.name) ? reviewer.name.trim() : GUEST_NAME,
|
|
232
|
-
},
|
|
227
|
+
...header,
|
|
233
228
|
...(outline ? { outline } : {}),
|
|
234
229
|
threads,
|
|
235
230
|
pages,
|
|
@@ -19,12 +19,26 @@ export interface PresenceEntry extends PresenceTarget {
|
|
|
19
19
|
updated: string;
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
+
/**
|
|
23
|
+
* The session a Claude Code sub-agent's marks are under: its agent's
|
|
24
|
+
* session, then its own id, so each sub-agent shows on its own.
|
|
25
|
+
*/
|
|
26
|
+
export const workerSession = (session: string, agentId: string): string =>
|
|
27
|
+
`${session}/${agentId}`;
|
|
28
|
+
|
|
29
|
+
/** Whether marks under session `marked` are `session`'s own or its sub-agents'. */
|
|
30
|
+
export const underSession = (marked: string, session: string): boolean =>
|
|
31
|
+
marked === session || marked.startsWith(`${session}/`);
|
|
32
|
+
|
|
22
33
|
/** How long an entry lasts after it was last marked. */
|
|
23
34
|
export const PRESENCE_TTL_MS = 120_000;
|
|
24
35
|
|
|
36
|
+
/** When an entry ends, unless it is marked again first: as an epoch time. */
|
|
37
|
+
export const endsAt = (entry: { updated: string }): number =>
|
|
38
|
+
Date.parse(entry.updated) + PRESENCE_TTL_MS;
|
|
39
|
+
|
|
25
40
|
/** The entries that have not expired at `now`. */
|
|
26
41
|
export const freshPresence = <Entry extends { updated: string }>(
|
|
27
42
|
entries: Entry[],
|
|
28
43
|
now: number
|
|
29
|
-
): Entry[] =>
|
|
30
|
-
entries.filter((entry) => now - Date.parse(entry.updated) < PRESENCE_TTL_MS);
|
|
44
|
+
): Entry[] => entries.filter((entry) => now < endsAt(entry));
|
|
@@ -95,6 +95,31 @@ const commentOf = (value: unknown): ReviewComment | undefined => {
|
|
|
95
95
|
};
|
|
96
96
|
};
|
|
97
97
|
|
|
98
|
+
/**
|
|
99
|
+
* Who reviewed and which review, as a review file and a Markup review both
|
|
100
|
+
* keep them; undefined without the review's id and the reviewer's key.
|
|
101
|
+
*/
|
|
102
|
+
export const reviewHeader = (
|
|
103
|
+
review: Record<string, unknown>,
|
|
104
|
+
reviewer: Record<string, unknown>
|
|
105
|
+
): Pick<ReviewFile, "review" | "reviewer"> | undefined => {
|
|
106
|
+
if (!(isText(review.id) && isText(reviewer.key))) {
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
return {
|
|
110
|
+
review: {
|
|
111
|
+
id: review.id,
|
|
112
|
+
title: isText(review.title) ? review.title.trim() : "",
|
|
113
|
+
...(isText(review.created) ? { created: review.created } : {}),
|
|
114
|
+
...(isText(review.completed) ? { completed: review.completed } : {}),
|
|
115
|
+
},
|
|
116
|
+
reviewer: {
|
|
117
|
+
key: reviewer.key,
|
|
118
|
+
name: isText(reviewer.name) ? reviewer.name.trim() : GUEST_NAME,
|
|
119
|
+
},
|
|
120
|
+
};
|
|
121
|
+
};
|
|
122
|
+
|
|
98
123
|
/** A file's review, checked, or why it cannot be imported. */
|
|
99
124
|
export function parseReviewFile(value: unknown): ReviewFileAnswer {
|
|
100
125
|
if (
|
|
@@ -110,8 +135,8 @@ export function parseReviewFile(value: unknown): ReviewFileAnswer {
|
|
|
110
135
|
if (value.version !== REVIEW_VERSION) {
|
|
111
136
|
return { problem: "newer" };
|
|
112
137
|
}
|
|
113
|
-
const
|
|
114
|
-
if (!
|
|
138
|
+
const header = reviewHeader(value.review, value.reviewer);
|
|
139
|
+
if (!header) {
|
|
115
140
|
return { problem: "not-a-review" };
|
|
116
141
|
}
|
|
117
142
|
const listed: unknown[] = Array.isArray(value.threads) ? value.threads : [];
|
|
@@ -125,16 +150,7 @@ export function parseReviewFile(value: unknown): ReviewFileAnswer {
|
|
|
125
150
|
return {
|
|
126
151
|
review: {
|
|
127
152
|
...(isText(value.prototype) ? { prototype: value.prototype } : {}),
|
|
128
|
-
|
|
129
|
-
id: review.id,
|
|
130
|
-
title: isText(review.title) ? review.title.trim() : "",
|
|
131
|
-
...(isText(review.created) ? { created: review.created } : {}),
|
|
132
|
-
...(isText(review.completed) ? { completed: review.completed } : {}),
|
|
133
|
-
},
|
|
134
|
-
reviewer: {
|
|
135
|
-
key: reviewer.key,
|
|
136
|
-
name: isText(reviewer.name) ? reviewer.name.trim() : GUEST_NAME,
|
|
137
|
-
},
|
|
153
|
+
...header,
|
|
138
154
|
threads: read,
|
|
139
155
|
},
|
|
140
156
|
};
|
|
@@ -60,7 +60,8 @@ export const FAILURE_CAUSES: readonly { pattern: string; cause: string }[] = [
|
|
|
60
60
|
"Its packages aren't installed in {project}. Install them, then try again.",
|
|
61
61
|
},
|
|
62
62
|
{
|
|
63
|
-
|
|
63
|
+
// Node's error, or Dex's own refusal (cli/banner.ts), which names it.
|
|
64
|
+
pattern: "EADDRINUSE|Port [0-9]+ is in use",
|
|
64
65
|
cause: "Another program is using its port. Close it, then try again.",
|
|
65
66
|
},
|
|
66
67
|
{
|
package/src/shared/signup.ts
CHANGED
|
@@ -5,6 +5,8 @@
|
|
|
5
5
|
//
|
|
6
6
|
// Only what the person typed is sent, and only when they choose Send.
|
|
7
7
|
|
|
8
|
+
import { postToRelay, type SendOptions } from "./feedback.ts";
|
|
9
|
+
|
|
8
10
|
/** Where sign-ups go: the relay on Dex's site. */
|
|
9
11
|
export const SIGNUP_URL = "https://sudio-site.vercel.app/api/signup";
|
|
10
12
|
|
|
@@ -62,42 +64,16 @@ export type SignupSent =
|
|
|
62
64
|
| { ok: true; id: string }
|
|
63
65
|
| { ok: false; reason: "invalid" | "limited" | "unavailable" | "failed" };
|
|
64
66
|
|
|
65
|
-
const TOO_MANY_REQUESTS = 429;
|
|
66
|
-
const SERVICE_UNAVAILABLE = 503;
|
|
67
|
-
|
|
68
|
-
export interface SignupSendOptions {
|
|
69
|
-
fetch?: (url: string, init: RequestInit) => Promise<Response>;
|
|
70
|
-
url?: string;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
67
|
/** Send a sign-up to the relay, if it is ready; never throws. */
|
|
74
68
|
export const sendSignup = async (
|
|
75
69
|
signup: Signup,
|
|
76
|
-
{ fetch = globalThis.fetch, url = SIGNUP_URL }:
|
|
70
|
+
{ fetch = globalThis.fetch, url = SIGNUP_URL }: SendOptions = {}
|
|
77
71
|
): Promise<SignupSent> => {
|
|
78
72
|
if (checkSignup(signup).length > 0) {
|
|
79
73
|
return { ok: false, reason: "invalid" };
|
|
80
74
|
}
|
|
81
|
-
// A form, as feedback travels: a simple request, with no preflight.
|
|
82
75
|
const form = new FormData();
|
|
83
76
|
form.set("name", signup.name.trim());
|
|
84
77
|
form.set("email", signup.email.trim());
|
|
85
|
-
|
|
86
|
-
const response = await fetch(url, { method: "POST", body: form });
|
|
87
|
-
if (response.ok) {
|
|
88
|
-
const { id } = (await response.json()) as { id?: unknown };
|
|
89
|
-
return typeof id === "string" && id
|
|
90
|
-
? { ok: true, id }
|
|
91
|
-
: { ok: false, reason: "failed" };
|
|
92
|
-
}
|
|
93
|
-
if (response.status === TOO_MANY_REQUESTS) {
|
|
94
|
-
return { ok: false, reason: "limited" };
|
|
95
|
-
}
|
|
96
|
-
if (response.status === SERVICE_UNAVAILABLE) {
|
|
97
|
-
return { ok: false, reason: "unavailable" };
|
|
98
|
-
}
|
|
99
|
-
return { ok: false, reason: "failed" };
|
|
100
|
-
} catch {
|
|
101
|
-
return { ok: false, reason: "failed" };
|
|
102
|
-
}
|
|
78
|
+
return await postToRelay(url, form, fetch);
|
|
103
79
|
};
|
|
@@ -51,19 +51,6 @@ export interface ConnectedAgent {
|
|
|
51
51
|
watching?: boolean;
|
|
52
52
|
}
|
|
53
53
|
|
|
54
|
-
/**
|
|
55
|
-
* How an agent comes by new feedback: pushed to it as it is left, pushed
|
|
56
|
-
* with nothing yet to say it arrives, or only when it is asked or watches.
|
|
57
|
-
*/
|
|
58
|
-
export type Hearing = "pushed" | "unproven" | "asked";
|
|
59
|
-
|
|
60
|
-
export const hearingOf = (agent: ConnectedAgent): Hearing => {
|
|
61
|
-
if (agent.channel) {
|
|
62
|
-
return "pushed";
|
|
63
|
-
}
|
|
64
|
-
return agent.unproven ? "unproven" : "asked";
|
|
65
|
-
};
|
|
66
|
-
|
|
67
54
|
export type StudioEvent =
|
|
68
55
|
| { type: "presence"; presence: PresenceEntry[] }
|
|
69
56
|
| { type: "canvas"; slug: string }
|
|
@@ -22,6 +22,20 @@ import {
|
|
|
22
22
|
splitPrototypePath,
|
|
23
23
|
} from "./prototypes-core.ts";
|
|
24
24
|
|
|
25
|
+
export const DISCIPLINES = ["product", "brand", "engineering"] as const;
|
|
26
|
+
export type Discipline = (typeof DISCIPLINES)[number];
|
|
27
|
+
|
|
28
|
+
/** A person who makes prototypes, from contributors.json. */
|
|
29
|
+
export interface Contributor {
|
|
30
|
+
discipline: Discipline;
|
|
31
|
+
/** Git user names that identify this person, so the agent knows who it is working for. */
|
|
32
|
+
git: string[];
|
|
33
|
+
/** Their GitHub username, for their avatar. */
|
|
34
|
+
github?: string;
|
|
35
|
+
name: string;
|
|
36
|
+
slug: string;
|
|
37
|
+
}
|
|
38
|
+
|
|
25
39
|
/** Where each of the studio's own files is, relative to its content root. */
|
|
26
40
|
export const STUDIO_FILES = {
|
|
27
41
|
/** Who works in the studio, and the git users that are them. */
|