@dexhq/canvas 0.13.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.
Files changed (341) hide show
  1. package/CHANGELOG.md +53 -0
  2. package/README.md +21 -18
  3. package/app/canvas/activity.tsx +8 -15
  4. package/app/canvas/anchoring.ts +3 -5
  5. package/app/canvas/canvas-input.ts +151 -14
  6. package/app/canvas/canvas-keys.ts +9 -0
  7. package/app/canvas/canvas-model.ts +5 -42
  8. package/app/canvas/canvas-panels.ts +1 -17
  9. package/app/canvas/canvas-scene.ts +7 -3
  10. package/app/canvas/canvas-ui.ts +2 -1
  11. package/app/canvas/canvas.css +61 -26
  12. package/app/canvas/change-notice.tsx +10 -1
  13. package/app/canvas/comment-layer.tsx +2 -1
  14. package/app/canvas/comments.tsx +204 -82
  15. package/app/canvas/element-picker.ts +200 -27
  16. package/app/canvas/engine/canvas-gestures.ts +72 -17
  17. package/app/canvas/engine/canvas-store.ts +17 -1
  18. package/app/canvas/engine/engine.css +6 -3
  19. package/app/canvas/find-bar.tsx +817 -0
  20. package/app/canvas/find-model.ts +135 -0
  21. package/app/canvas/flow-canvas.tsx +18 -2
  22. package/app/canvas/follow-pin.ts +26 -6
  23. package/app/canvas/frame-node.tsx +43 -26
  24. package/app/canvas/imported-reviews.tsx +12 -22
  25. package/app/canvas/layout.ts +27 -0
  26. package/app/canvas/live-page.ts +142 -19
  27. package/app/canvas/page-find.ts +220 -0
  28. package/app/canvas/page-style.ts +23 -0
  29. package/app/canvas/section-node.tsx +2 -0
  30. package/app/canvas/spec-threads.ts +24 -23
  31. package/app/canvas/thread-focus.tsx +14 -12
  32. package/app/canvas/tool-cursors.ts +16 -16
  33. package/app/canvas/use-activity.ts +0 -8
  34. package/app/canvas/use-agent-changes.tsx +34 -40
  35. package/app/canvas/use-canvas-clipboard.tsx +11 -14
  36. package/app/canvas/xray.ts +3 -12
  37. package/app/frame.tsx +5 -0
  38. package/app/i18n/locales/en/messages.po +114 -12
  39. package/app/i18n/locales/en/messages.ts +1 -1
  40. package/app/i18n/locales/pseudo/messages.po +114 -12
  41. package/app/i18n/locales/pseudo/messages.ts +1 -1
  42. package/app/icons/{sets/lucide.tsx → glyphs.tsx} +7 -5
  43. package/app/icons/index.tsx +3 -3
  44. package/app/icons/types.ts +3 -10
  45. package/app/index.html +3 -3
  46. package/app/main.tsx +3 -0
  47. package/app/pages/canvas-settings.tsx +35 -0
  48. package/app/pages/canvas.tsx +27 -8
  49. package/app/pages/commands-settings.tsx +16 -2
  50. package/app/shell/about.tsx +5 -4
  51. package/app/shell/feedback-details.ts +0 -3
  52. package/app/shell/feedback-form.tsx +10 -21
  53. package/app/shell/feedback-link.tsx +2 -1
  54. package/app/shell/instructions-editor.tsx +1 -1
  55. package/app/shell/presence-style.ts +59 -0
  56. package/app/shell/presence.tsx +6 -3
  57. package/app/shell/scaled-frame.tsx +21 -9
  58. package/app/shell/settings-sections.ts +12 -0
  59. package/app/shell/sidebar.tsx +1 -1
  60. package/app/studio-ui.d.ts +0 -9
  61. package/app/types.ts +21 -205
  62. package/app/ui/file-drop.ts +128 -0
  63. package/app/ui/prompt-editor.tsx +1 -1
  64. package/app/ui/shadcn/input-group.tsx +2 -2
  65. package/dist/cli/banner.d.mts +4 -2
  66. package/dist/cli/banner.mjs +34 -11
  67. package/dist/cli/commands/app.mjs +19 -11
  68. package/dist/cli/commands/create.d.mts +26 -14
  69. package/dist/cli/commands/create.mjs +13 -7
  70. package/dist/cli/commands/dev.mjs +2 -3
  71. package/dist/cli/commands/hook.mjs +2 -1
  72. package/dist/cli/commands/init.d.mts +11 -6
  73. package/dist/cli/help.d.mts +1 -1
  74. package/dist/cli/help.mjs +3 -3
  75. package/dist/cli/main.d.mts +22 -12
  76. package/dist/config/index.d.mts +6 -5
  77. package/dist/config/project-files.d.mts +6 -3
  78. package/dist/config/project-files.mjs +14 -5
  79. package/dist/config/renamed.d.mts +0 -2
  80. package/dist/config/renamed.mjs +1 -3
  81. package/dist/config/schema.d.mts +0 -5
  82. package/dist/config/schema.mjs +0 -5
  83. package/dist/content/capture.d.mts +2 -2
  84. package/dist/content/capture.mjs +2 -2
  85. package/dist/content/content.d.mts +3 -141
  86. package/dist/content/content.mjs +7 -65
  87. package/dist/content/flow-specs.mjs +1 -1
  88. package/dist/content/prototype-summary.d.mts +3 -39
  89. package/dist/content/prototype-summary.mjs +2 -3
  90. package/dist/content/prototypes.mjs +1 -1
  91. package/dist/content/snapshot-client.mjs +1 -1
  92. package/dist/content/text-replace.d.mts +30 -0
  93. package/dist/content/text-replace.mjs +309 -0
  94. package/dist/content/thread-module.mjs +1 -1
  95. package/dist/content/threads.mjs +1 -1
  96. package/dist/paths.d.mts +0 -2
  97. package/dist/paths.mjs +1 -3
  98. package/dist/server/agent-env.d.mts +5 -1
  99. package/dist/server/agent-env.mjs +7 -2
  100. package/dist/server/agent-session.d.mts +14 -1
  101. package/dist/server/agent-session.mjs +84 -19
  102. package/dist/server/brief.mjs +3 -3
  103. package/dist/server/build-pictures.mjs +1 -1
  104. package/dist/server/channel.d.mts +19 -24
  105. package/dist/server/channel.mjs +70 -37
  106. package/dist/server/claimed-presence.d.mts +18 -0
  107. package/dist/server/claimed-presence.mjs +58 -0
  108. package/dist/server/close-check.mjs +2 -2
  109. package/dist/server/comments/actions.d.mts +153 -0
  110. package/dist/server/comments/actions.mjs +154 -0
  111. package/dist/server/comments/routes.d.mts +25 -0
  112. package/dist/server/comments/routes.mjs +88 -0
  113. package/dist/server/comments/tools.d.mts +6 -0
  114. package/dist/server/comments/tools.mjs +154 -0
  115. package/dist/server/dev-server.mjs +36 -13
  116. package/dist/server/file-errors.d.mts +7 -2
  117. package/dist/server/file-errors.mjs +31 -8
  118. package/dist/server/file-lock.d.mts +2 -2
  119. package/dist/server/file-lock.mjs +130 -36
  120. package/dist/server/mcp.d.mts +0 -2
  121. package/dist/server/mcp.mjs +7 -8
  122. package/dist/server/me.d.mts +1 -1
  123. package/dist/server/open-page.d.mts +22 -0
  124. package/dist/server/open-page.mjs +20 -2
  125. package/dist/server/outcome.d.mts +22 -0
  126. package/dist/server/outcome.mjs +8 -0
  127. package/dist/server/own-copies.mjs +2 -2
  128. package/dist/server/people.d.mts +1 -1
  129. package/dist/server/port.d.mts +12 -0
  130. package/dist/server/port.mjs +66 -14
  131. package/dist/server/presence.d.mts +4 -1
  132. package/dist/server/presence.mjs +2 -2
  133. package/dist/server/requests.d.mts +5 -1
  134. package/dist/server/requests.mjs +32 -47
  135. package/dist/server/studio-for.d.mts +5 -0
  136. package/dist/server/studio-for.mjs +18 -4
  137. package/dist/server/sync-install.d.mts +8 -12
  138. package/dist/server/sync-install.mjs +12 -30
  139. package/dist/server/thread-source.mjs +2 -2
  140. package/dist/server/tools/describe.d.mts +1 -1
  141. package/dist/server/tools/describe.mjs +1 -1
  142. package/dist/server/tools/feedback.d.mts +1 -1
  143. package/dist/server/tools/reading.mjs +13 -4
  144. package/dist/server/tools/show.d.mts +1 -1
  145. package/dist/server/tools/snapshot.d.mts +1 -1
  146. package/dist/server/tools/thread-list.mjs +1 -1
  147. package/dist/server/tools/watch.mjs +5 -3
  148. package/dist/server/vite.mjs +28 -31
  149. package/dist/server/web-app.mjs +7 -10
  150. package/dist/server/work-groups.mjs +1 -1
  151. package/dist/setup/apply.mjs +8 -14
  152. package/dist/setup/create.d.mts +4 -2
  153. package/dist/setup/create.mjs +118 -36
  154. package/dist/setup/design-system-checks.mjs +3 -12
  155. package/dist/setup/desktop-app-script.mjs +4 -3
  156. package/dist/setup/desktop-app-start.d.mts +8 -2
  157. package/dist/setup/desktop-app-start.mjs +64 -29
  158. package/dist/setup/desktop-app.d.mts +8 -0
  159. package/dist/setup/desktop-app.mjs +20 -4
  160. package/dist/setup/detect.d.mts +14 -7
  161. package/dist/setup/detect.mjs +56 -10
  162. package/dist/setup/doctor.mjs +2 -4
  163. package/dist/setup/existing-setup.d.mts +1 -3
  164. package/dist/setup/existing-setup.mjs +10 -11
  165. package/dist/setup/migrate/row-titles.mjs +1 -1
  166. package/dist/setup/own-app.d.mts +1 -2
  167. package/dist/setup/own-app.mjs +4 -5
  168. package/dist/setup/plan.d.mts +8 -6
  169. package/dist/setup/plan.mjs +64 -48
  170. package/dist/setup/project.d.mts +6 -17
  171. package/dist/setup/project.mjs +17 -61
  172. package/dist/setup/prompts.d.mts +5 -5
  173. package/dist/setup/prompts.mjs +28 -61
  174. package/dist/setup/questions.d.mts +12 -4
  175. package/dist/setup/questions.mjs +10 -25
  176. package/dist/setup/starters.d.mts +2 -0
  177. package/dist/setup/starters.mjs +26 -9
  178. package/dist/setup/workspace-setup.d.mts +1 -2
  179. package/dist/setup/workspace-setup.mjs +4 -6
  180. package/dist/setup/write.d.mts +15 -5
  181. package/dist/setup/write.mjs +35 -9
  182. package/dist/shared/annotations-core.mjs +1 -1
  183. package/dist/shared/canvas-core.mjs +1 -1
  184. package/dist/shared/canvas-file.d.mts +201 -0
  185. package/dist/shared/canvas-file.mjs +1 -0
  186. package/dist/shared/comments/routes.d.mts +53 -0
  187. package/dist/shared/comments/routes.mjs +37 -0
  188. package/dist/shared/feedback.d.mts +8 -0
  189. package/dist/shared/feedback.mjs +10 -2
  190. package/dist/shared/page-review.d.mts +2 -11
  191. package/dist/shared/page-review.mjs +4 -13
  192. package/dist/shared/presence-core.d.mts +11 -0
  193. package/dist/shared/presence-core.mjs +11 -2
  194. package/dist/shared/review-file.d.mts +5 -0
  195. package/dist/shared/review-file.mjs +23 -13
  196. package/dist/shared/server-page.mjs +7 -1
  197. package/dist/shared/signup.d.mts +2 -5
  198. package/dist/shared/signup.mjs +2 -35
  199. package/dist/shared/studio-events.d.mts +0 -6
  200. package/dist/shared/studio-events.mjs +1 -5
  201. package/dist/shared/studio-files.d.mts +12 -0
  202. package/dist/shared/studio-files.mjs +6 -1
  203. package/dist/shared/studio-routes.d.mts +16 -62
  204. package/dist/shared/studio-routes.mjs +1 -69
  205. package/dist/shared/threads-core.d.mts +2 -2
  206. package/dist/shared/threads-core.mjs +1 -1
  207. package/extension/dist/feedback.js +148 -138
  208. package/extension/dist/manifest.json +1 -1
  209. package/extension/dist/picker.js +146 -136
  210. package/package.json +3 -20
  211. package/src/cli/banner.ts +45 -11
  212. package/src/cli/commands/app.ts +23 -8
  213. package/src/cli/commands/create.ts +17 -9
  214. package/src/cli/commands/dev.ts +0 -3
  215. package/src/cli/commands/hook.ts +4 -1
  216. package/src/cli/help.ts +3 -3
  217. package/src/config/index.ts +6 -5
  218. package/src/config/project-files.ts +21 -11
  219. package/src/config/renamed.ts +0 -3
  220. package/src/config/schema.ts +0 -1
  221. package/src/content/capture.ts +6 -12
  222. package/src/content/content.ts +7 -244
  223. package/src/content/flow-specs.ts +2 -1
  224. package/src/content/prototype-summary.ts +4 -44
  225. package/src/content/review-pages.ts +2 -1
  226. package/src/content/snapshot-client.ts +1 -1
  227. package/src/content/text-replace.ts +449 -0
  228. package/src/paths.ts +0 -8
  229. package/src/server/agent-env.ts +12 -2
  230. package/src/server/agent-session.ts +124 -34
  231. package/src/server/brief.ts +8 -3
  232. package/src/server/channel.ts +121 -52
  233. package/src/server/claimed-presence.ts +93 -0
  234. package/src/server/comments/actions.ts +352 -0
  235. package/src/server/comments/routes.ts +176 -0
  236. package/src/server/comments/tools.ts +317 -0
  237. package/src/server/dev-server.ts +49 -15
  238. package/src/server/file-errors.ts +47 -13
  239. package/src/server/file-lock.ts +205 -54
  240. package/src/server/mcp.ts +13 -14
  241. package/src/server/me.ts +2 -5
  242. package/src/server/open-page.ts +54 -4
  243. package/src/server/outcome.ts +26 -0
  244. package/src/server/people.ts +2 -1
  245. package/src/server/port.ts +94 -20
  246. package/src/server/presence.ts +11 -3
  247. package/src/server/requests.ts +60 -70
  248. package/src/server/studio-for.ts +27 -3
  249. package/src/server/sync-install.ts +35 -26
  250. package/src/server/thread-place.ts +2 -4
  251. package/src/server/tools/reading.ts +16 -3
  252. package/src/server/tools/watch.ts +7 -7
  253. package/src/server/vite.ts +37 -40
  254. package/src/server/web-app.ts +14 -12
  255. package/src/setup/apply.ts +10 -16
  256. package/src/setup/create.ts +143 -37
  257. package/src/setup/design-system-checks.ts +7 -15
  258. package/src/setup/desktop-app-script.ts +4 -3
  259. package/src/setup/desktop-app-start.ts +94 -26
  260. package/src/setup/desktop-app.ts +24 -3
  261. package/src/setup/detect.ts +56 -14
  262. package/src/setup/doctor.ts +4 -4
  263. package/src/setup/existing-setup.ts +10 -12
  264. package/src/setup/own-app.ts +2 -5
  265. package/src/setup/plan.ts +93 -84
  266. package/src/setup/project.ts +25 -118
  267. package/src/setup/prompts.ts +44 -127
  268. package/src/setup/questions.ts +27 -29
  269. package/src/setup/starters.ts +35 -10
  270. package/src/setup/workspace-setup.ts +8 -18
  271. package/src/setup/write.ts +52 -9
  272. package/src/shared/canvas-file.ts +205 -0
  273. package/src/shared/comments/routes.ts +79 -0
  274. package/src/shared/feedback.ts +14 -4
  275. package/src/shared/page-review.ts +11 -16
  276. package/src/shared/presence-core.ts +16 -2
  277. package/src/shared/review-file.ts +28 -12
  278. package/src/shared/server-page.ts +11 -1
  279. package/src/shared/signup.ts +4 -28
  280. package/src/shared/studio-events.ts +0 -13
  281. package/src/shared/studio-files.ts +14 -0
  282. package/src/shared/studio-routes.ts +21 -64
  283. package/src/shared/threads-core.ts +2 -2
  284. package/templates/methods/review.md +2 -2
  285. package/templates/rules/canvas-frames.md +104 -0
  286. package/templates/rules/canvas.md +8 -142
  287. package/templates/rules/prototypes.md +1 -1
  288. package/templates/rules/snapshots.md +52 -0
  289. package/templates/starters/standalone/README.md +7 -7
  290. package/templates/starters/standalone/components.json +1 -1
  291. package/templates/starters/standalone/package.json +1 -2
  292. package/templates/starters/turborepo/README.md +6 -6
  293. package/templates/starters/turborepo/apps/web/components.json +1 -1
  294. package/templates/starters/turborepo/apps/web/package.json +1 -2
  295. package/templates/starters/turborepo/apps/web/src/app.tsx +4 -5
  296. package/templates/starters/turborepo/packages/ui/components.json +1 -1
  297. package/templates/starters/turborepo/packages/ui/package.json +1 -2
  298. package/templates/starters/vite/README.md +7 -6
  299. package/templates/starters/vite/components.json +1 -1
  300. package/templates/starters/vite/package.json +1 -2
  301. package/templates/starters/vite/src/app.tsx +3 -4
  302. package/templates/starters/vite/src/components/ui/accordion.tsx +71 -0
  303. package/templates/starters/vite/src/components/ui/attachment.tsx +1 -1
  304. package/templates/starters/vite/src/components/ui/badge.tsx +2 -2
  305. package/templates/starters/vite/src/components/ui/button.tsx +17 -12
  306. package/templates/starters/vite/src/components/ui/card.tsx +1 -1
  307. package/templates/starters/vite/src/components/ui/checkbox.tsx +28 -0
  308. package/templates/starters/vite/src/components/ui/dialog.tsx +5 -5
  309. package/templates/starters/vite/src/components/ui/dropdown-menu.tsx +17 -14
  310. package/templates/starters/vite/src/components/ui/field.tsx +3 -1
  311. package/templates/starters/vite/src/components/ui/input-group.tsx +5 -3
  312. package/templates/starters/vite/src/components/ui/input.tsx +1 -1
  313. package/templates/starters/vite/src/components/ui/label.tsx +2 -0
  314. package/templates/starters/vite/src/components/ui/native-select.tsx +3 -4
  315. package/templates/starters/vite/src/components/ui/popover.tsx +1 -1
  316. package/templates/starters/vite/src/components/ui/separator.tsx +2 -0
  317. package/templates/starters/vite/src/components/ui/spinner.tsx +3 -7
  318. package/templates/starters/vite/src/components/ui/switch.tsx +1 -1
  319. package/templates/starters/vite/src/components/ui/textarea.tsx +1 -1
  320. package/templates/starters/vite/src/components/ui/toggle.tsx +4 -2
  321. package/templates/starters/vite/src/index.css +533 -111
  322. package/app/icons/sets/hugeicons.tsx +0 -259
  323. package/app/icons/sets/phosphor.tsx +0 -251
  324. package/dist/server/icon-set.d.mts +0 -15
  325. package/dist/server/icon-set.mjs +0 -31
  326. package/dist/server/tools/close-reply.d.mts +0 -6
  327. package/dist/server/tools/close-reply.mjs +0 -138
  328. package/dist/server/tools/comment.d.mts +0 -6
  329. package/dist/server/tools/comment.mjs +0 -49
  330. package/dist/shared/icon-sets.d.mts +0 -9
  331. package/dist/shared/icon-sets.mjs +0 -21
  332. package/src/server/icon-set.ts +0 -56
  333. package/src/server/tools/close-reply.ts +0 -271
  334. package/src/server/tools/comment.ts +0 -96
  335. package/src/shared/icon-sets.ts +0 -23
  336. /package/app/public/{sudio-192.png → dex-192.png} +0 -0
  337. /package/app/public/{sudio-512.png → dex-512.png} +0 -0
  338. /package/app/public/{apple-touch-icon.png → dex-apple-touch-icon.png} +0 -0
  339. /package/app/public/{favicon-32.png → dex-icon-32.png} +0 -0
  340. /package/app/public/{favicon.svg → dex-icon.svg} +0 -0
  341. /package/app/public/{sudio-maskable-512.png → dex-maskable-512.png} +0 -0
@@ -0,0 +1,153 @@
1
+ import { Sketch } from "../../shared/sketch-core.mjs";
2
+ import { ChangePlace, PersonChange, ThreadAudience, ThreadTarget, ThreadWithPrototype } from "../../shared/threads-core.mjs";
3
+ import { ResolvedDesignSystem } from "../../config/design-system.mjs";
4
+ import { PrototypeReference } from "../../content/prototypes.mjs";
5
+ import { ThreadModule } from "../../content/thread-module.mjs";
6
+ import { AgentSession } from "../agent-session.mjs";
7
+ import { Outcome } from "../outcome.mjs";
8
+ //#region src/server/comments/actions.d.ts
9
+ /**
10
+ * A person who writes on a comment, by the name the account menu shows
11
+ * them by, and who they are to Dex (their contributor's slug) when it can
12
+ * tell.
13
+ */
14
+ export interface PersonAuthor {
15
+ id?: string;
16
+ kind: "person";
17
+ name: string;
18
+ }
19
+ /** An agent: an author without an account, known by its name. */
20
+ export interface AgentAuthor {
21
+ kind: "agent";
22
+ name: string;
23
+ }
24
+ /** Who writes a comment or a reply: a person, or an agent. */
25
+ export type Author = PersonAuthor | AgentAuthor;
26
+ /** Where the comments are: the content folder and its thread module. */
27
+ export interface CommentBase {
28
+ root: string;
29
+ threads: ThreadModule;
30
+ }
31
+ /**
32
+ * One file's comments, by its slug, and who acts on them: what starting a
33
+ * comment takes, from either door.
34
+ */
35
+ export interface FileComments extends CommentBase {
36
+ author: Author;
37
+ prototype: string;
38
+ }
39
+ /** A person acting on one file's comments, as the interface's requests do. */
40
+ export interface PersonComments extends FileComments {
41
+ author: PersonAuthor;
42
+ }
43
+ /**
44
+ * An agent acting on comments by their ids, which name them on any file:
45
+ * its session signs what it does with the agent's name, and holds what it
46
+ * starts until it closes, asks or lets it go (agent-session.ts).
47
+ */
48
+ export interface AgentWork extends CommentBase {
49
+ /** The project's design system, as it is when the agent closes a comment. */
50
+ designSystem: () => Promise<ResolvedDesignSystem | undefined>;
51
+ /** Where the agent works: the files its problems name are shown from here. */
52
+ from: string;
53
+ session: AgentSession;
54
+ }
55
+ /**
56
+ * The file a request or a tool names, by its slug, or an invalid problem:
57
+ * the name finds no file. A name from before files/ finds the file it
58
+ * became.
59
+ */
60
+ export declare const findPrototype: (root: string, reference: PrototypeReference) => Outcome<string>;
61
+ /**
62
+ * The context an action on one file's comments takes, built the same way
63
+ * for the interface's requests and an agent's tools: the file a name finds,
64
+ * and who acts on it. Who a person is, is read only once the file is found.
65
+ */
66
+ export declare function commentsOn(base: CommentBase, asked: {
67
+ by: {
68
+ kind: "person";
69
+ };
70
+ prototype: PrototypeReference;
71
+ }): Promise<Outcome<PersonComments>>;
72
+ export declare function commentsOn(base: CommentBase, asked: {
73
+ by: AgentAuthor;
74
+ prototype: PrototypeReference;
75
+ }): Promise<Outcome<FileComments>>;
76
+ /** The comments on one file, by its slug, or on every file: oldest first. */
77
+ export declare const listComments: ({ threads }: CommentBase, prototype?: string) => Promise<ThreadWithPrototype[]>;
78
+ /** A new comment: what it is on, its first message, who it is for. */
79
+ export interface NewComment {
80
+ /** Left out only with a wireframe, which says what it asks. */
81
+ body?: string;
82
+ for?: ThreadAudience;
83
+ /** A wireframe for an agent to build, on a frame or in an empty cell. */
84
+ sketch?: Sketch;
85
+ target: ThreadTarget;
86
+ }
87
+ /**
88
+ * Start a comment on the file, signed by its author: the comment, or what
89
+ * the thread rules find wrong with it, and nothing kept.
90
+ */
91
+ export declare function startComment({ author, prototype, threads }: FileComments, { body, ...comment }: NewComment): Promise<Outcome<ThreadWithPrototype>>;
92
+ /**
93
+ * A person's change to one of the file's comments, signed by them: the
94
+ * comment as it is after, or why not. A request for one file never changes
95
+ * another's comment: one there is not found.
96
+ */
97
+ export declare function changeComment({ author, prototype, threads }: PersonComments, id: string, change: Omit<PersonChange, "authorId">): Promise<Outcome<ThreadWithPrototype>>;
98
+ /** A person's reply: a closed comment opens again with it. */
99
+ export declare const replyToComment: (context: PersonComments, id: string, body: string) => Promise<Outcome<ThreadWithPrototype>>;
100
+ /** A person resolves a comment. */
101
+ export declare const resolveComment: (context: PersonComments, id: string) => Promise<Outcome<ThreadWithPrototype>>;
102
+ /** A person dismisses a comment: how one is deleted. */
103
+ export declare const dismissComment: (context: PersonComments, id: string) => Promise<Outcome<ThreadWithPrototype>>;
104
+ /** A person opens a closed comment again. */
105
+ export declare const reopenComment: (context: PersonComments, id: string) => Promise<Outcome<ThreadWithPrototype>>;
106
+ /**
107
+ * An agent starts on a comment (its 👀): claimed for its session, the
108
+ * comment is that session's alone until it closes, asks or lets it go.
109
+ * One another session holds is a conflict.
110
+ */
111
+ export declare function claimComment({ session }: {
112
+ session: Pick<AgentSession, "claim">;
113
+ }, id: string): Promise<Outcome<ThreadWithPrototype>>;
114
+ /**
115
+ * An agent writes on a comment: an answer where someone mentions it, or,
116
+ * with `ask`, a question about a request too ambiguous to act on. Either
117
+ * hands the comment back to the person (Asked), and a copy of someone
118
+ * else's view made for it goes. Anywhere else it is not allowed.
119
+ */
120
+ export declare function askOnComment({ root, session }: AgentWork, id: string, { ask, message }: {
121
+ ask?: boolean;
122
+ message: string;
123
+ }): Promise<Outcome<ThreadWithPrototype>>;
124
+ /**
125
+ * How an agent closes a comment it took: Done, with a summary of what
126
+ * changed, or Not done, with why.
127
+ */
128
+ export interface Closing {
129
+ /** Not done: why not. */
130
+ dismiss?: string;
131
+ id: string;
132
+ /** Done: one short line on what changed. */
133
+ summary?: string;
134
+ /** Done: where the change landed on the canvas, kept with the summary. */
135
+ where?: ChangePlace;
136
+ }
137
+ /**
138
+ * A comment an agent closed, and, when the person's copy of someone else's
139
+ * view was changed for it, the frame it now has in their row.
140
+ */
141
+ export interface Closed {
142
+ copy?: string;
143
+ thread: ThreadWithPrototype;
144
+ }
145
+ /**
146
+ * Close a comment an agent took. Done keeps the summary and the files its
147
+ * change touched, once that code passes the checks (close-check.ts): while
148
+ * it does not, the comment stays open and the problem says why. Not done
149
+ * is never held up. The person's copy of someone else's view is settled
150
+ * as the comment ends (own-copies.ts).
151
+ */
152
+ export declare function closeComment({ designSystem, from, root, session, threads }: AgentWork, { dismiss, id, summary, where }: Closing): Promise<Outcome<Closed>>;
153
+ //#endregion
@@ -0,0 +1,154 @@
1
+ import { resolvePrototype } from "../../content/prototypes.mjs";
2
+ import { errorsBeforeClose, filesChangedSincePickup } from "../close-check.mjs";
3
+ import { readAuthor } from "../me.mjs";
4
+ import { refused } from "../outcome.mjs";
5
+ import { onCopyIfAny, settleCopy } from "../own-copies.mjs";
6
+ //#region src/server/comments/actions.ts
7
+ /**
8
+ * An author as a comment keeps it: the name, with a person's id or an
9
+ * agent's mark (ThreadMessage's `authorId` and `agent`). The one place an
10
+ * author becomes what is stored.
11
+ */
12
+ const storedAuthor = (author) => author.kind === "agent" ? {
13
+ author: author.name,
14
+ agent: true
15
+ } : {
16
+ author: author.name,
17
+ ...author.id ? { authorId: author.id } : {}
18
+ };
19
+ const UNKNOWN_FILE = "Unknown file.";
20
+ /** A person's change to a comment that is gone, or is another file's. */
21
+ const GONE = "That thread is gone.";
22
+ /** An agent's comment, by an id it gave, that is not there. */
23
+ const noThread = (id) => `No thread ${id}.`;
24
+ /**
25
+ * The file a request or a tool names, by its slug, or an invalid problem:
26
+ * the name finds no file. A name from before files/ finds the file it
27
+ * became.
28
+ */
29
+ const findPrototype = (root, reference) => {
30
+ const found = resolvePrototype(root, reference, { mustExist: true });
31
+ return found ? { value: found.slug } : refused("invalid", [UNKNOWN_FILE]);
32
+ };
33
+ /**
34
+ * The person using Dex, as they sign what they write: named as the account
35
+ * menu names them, with their slug. A newcomer joins first (readAuthor).
36
+ */
37
+ const personAuthor = async (root) => {
38
+ const { name, slug } = await readAuthor(root);
39
+ return {
40
+ kind: "person",
41
+ name,
42
+ ...slug ? { id: slug } : {}
43
+ };
44
+ };
45
+ async function commentsOn({ root, threads }, { by, prototype }) {
46
+ const found = findPrototype(root, prototype);
47
+ if (found.problem) return found;
48
+ return { value: {
49
+ author: by.kind === "agent" ? by : await personAuthor(root),
50
+ prototype: found.value,
51
+ root,
52
+ threads
53
+ } };
54
+ }
55
+ /** The comments on one file, by its slug, or on every file: oldest first. */
56
+ const listComments = ({ threads }, prototype) => threads.list(prototype === void 0 ? {} : { prototype });
57
+ /**
58
+ * Start a comment on the file, signed by its author: the comment, or what
59
+ * the thread rules find wrong with it, and nothing kept.
60
+ */
61
+ async function startComment({ author, prototype, threads }, { body = "", ...comment }) {
62
+ const started = await threads.start({
63
+ prototype,
64
+ ...comment,
65
+ body,
66
+ ...storedAuthor(author)
67
+ });
68
+ return started.problems ? refused("invalid", started.problems) : { value: started.thread };
69
+ }
70
+ /**
71
+ * A person's change to one of the file's comments, signed by them: the
72
+ * comment as it is after, or why not. A request for one file never changes
73
+ * another's comment: one there is not found.
74
+ */
75
+ async function changeComment({ author, prototype, threads }, id, change) {
76
+ if ((await threads.find(id))?.slug !== prototype) return refused("not-found", [GONE]);
77
+ const changed = await threads.respond(id, {
78
+ ...change,
79
+ ...storedAuthor(author)
80
+ });
81
+ if (!changed) return refused("not-found", [GONE]);
82
+ return changed.problems ? refused("invalid", changed.problems) : { value: changed.thread };
83
+ }
84
+ /** A person's reply: a closed comment opens again with it. */
85
+ const replyToComment = (context, id, body) => changeComment(context, id, { body });
86
+ /** A person resolves a comment. */
87
+ const resolveComment = (context, id) => changeComment(context, id, { status: "resolved" });
88
+ /** A person dismisses a comment: how one is deleted. */
89
+ const dismissComment = (context, id) => changeComment(context, id, { status: "dismissed" });
90
+ /** A person opens a closed comment again. */
91
+ const reopenComment = (context, id) => changeComment(context, id, { status: "open" });
92
+ /**
93
+ * An agent starts on a comment (its 👀): claimed for its session, the
94
+ * comment is that session's alone until it closes, asks or lets it go.
95
+ * One another session holds is a conflict.
96
+ */
97
+ async function claimComment({ session }, id) {
98
+ const claimed = await session.claim(id);
99
+ if (!claimed) return refused("not-found", [noThread(id)]);
100
+ return claimed.problems ? refused("conflict", claimed.problems) : { value: claimed.thread };
101
+ }
102
+ /**
103
+ * An agent writes on a comment: an answer where someone mentions it, or,
104
+ * with `ask`, a question about a request too ambiguous to act on. Either
105
+ * hands the comment back to the person (Asked), and a copy of someone
106
+ * else's view made for it goes. Anywhere else it is not allowed.
107
+ */
108
+ async function askOnComment({ root, session }, id, { ask, message }) {
109
+ const answered = await session.act(id, {
110
+ action: "reply",
111
+ message,
112
+ ask
113
+ });
114
+ if (!answered) return refused("not-found", [noThread(id)]);
115
+ if (answered.problems) return refused("not-allowed", answered.problems);
116
+ await settleCopy(root, answered.thread).catch(() => void 0);
117
+ return { value: answered.thread };
118
+ }
119
+ /**
120
+ * Close a comment an agent took. Done keeps the summary and the files its
121
+ * change touched, once that code passes the checks (close-check.ts): while
122
+ * it does not, the comment stays open and the problem says why. Not done
123
+ * is never held up. The person's copy of someone else's view is settled
124
+ * as the comment ends (own-copies.ts).
125
+ */
126
+ async function closeComment({ designSystem, from, root, session, threads }, { dismiss, id, summary, where }) {
127
+ if (Boolean(summary) === Boolean(dismiss)) return refused("invalid", [`${id}: give a summary or dismiss, one of them.`]);
128
+ let files = [];
129
+ if (summary) {
130
+ const thread = await threads.find(id);
131
+ if (!thread) return refused("not-found", [noThread(id)]);
132
+ const broken = await errorsBeforeClose(root, await onCopyIfAny(root, thread), await designSystem(), from);
133
+ if (broken.length > 0) return refused("conflict", [`${id}: not closed, the code it changed has errors: ${broken.join(" ")} Fix them, then close it.`]);
134
+ files = await filesChangedSincePickup(root, thread);
135
+ }
136
+ const closed = await session.act(id, summary ? {
137
+ action: "resolve",
138
+ note: summary,
139
+ files,
140
+ ...where ? { where } : {}
141
+ } : {
142
+ action: "dismiss",
143
+ note: dismiss
144
+ });
145
+ if (!closed) return refused("not-found", [noThread(id)]);
146
+ if (closed.problems) return refused("conflict", [`${id}: ${closed.problems.join(" ")}`]);
147
+ const settled = await settleCopy(root, closed.thread).catch(() => void 0);
148
+ return { value: {
149
+ thread: closed.thread,
150
+ ...settled && "placed" in settled ? { copy: settled.placed } : {}
151
+ } };
152
+ }
153
+ //#endregion
154
+ export { askOnComment, changeComment, claimComment, closeComment, commentsOn, dismissComment, findPrototype, listComments, reopenComment, replyToComment, resolveComment, startComment };
@@ -0,0 +1,25 @@
1
+ import { ThreadWithPrototype } from "../../shared/threads-core.mjs";
2
+ import { ThreadModule } from "../../content/thread-module.mjs";
3
+ //#region src/server/comments/routes.d.ts
4
+ /** What a comment request is given: requests.ts's route context has it. */
5
+ interface CommentRequest {
6
+ body: unknown;
7
+ project: {
8
+ content: string;
9
+ };
10
+ threads: ThreadModule;
11
+ url: URL;
12
+ }
13
+ /** Start a comment, or change one by its id, as the person using Dex. */
14
+ declare function postThread({ body, project, threads, url }: CommentRequest): Promise<ThreadWithPrototype>;
15
+ /**
16
+ * The comment requests, by name and method, for requests.ts's route table:
17
+ * a handler for each method the contract declares, and no other.
18
+ */
19
+ export declare const COMMENT_HANDLERS: {
20
+ threads: {
21
+ GET: ({ project, threads, url }: CommentRequest) => Promise<ThreadWithPrototype[]>;
22
+ POST: typeof postThread;
23
+ };
24
+ };
25
+ //#endregion
@@ -0,0 +1,88 @@
1
+ import { isRecord } from "../../shared/checks.mjs";
2
+ import { refused } from "../outcome.mjs";
3
+ import { changeComment, commentsOn, dismissComment, findPrototype, listComments, reopenComment, replyToComment, resolveComment, startComment } from "./actions.mjs";
4
+ import { COMMENT_CHANGE, NEW_COMMENT } from "../../shared/comments/routes.mjs";
5
+ //#region src/server/comments/routes.ts
6
+ /**
7
+ * Each kind of problem an action answers with, as a status. What the
8
+ * thread rules refuse is invalid, and answered 422 as the interface has
9
+ * always had it; a request whose own fields are wrong is a 400 (asked).
10
+ */
11
+ const STATUS = {
12
+ "not-found": 404,
13
+ conflict: 409,
14
+ invalid: 422,
15
+ "not-allowed": 403
16
+ };
17
+ /** A request that names no file, or whose body is not as its schema says. */
18
+ const BAD_REQUEST = 400;
19
+ /** A refusal, as the request handler (requests.ts) sends one. */
20
+ var Refusal = class extends Error {
21
+ problems;
22
+ status;
23
+ constructor(status, problems) {
24
+ super(problems.join(" "));
25
+ this.status = status;
26
+ this.problems = problems;
27
+ }
28
+ };
29
+ /** What an action did, or its problem refused with the status for its kind. */
30
+ const answer = (outcome) => {
31
+ if (outcome.problem) throw new Refusal(STATUS[outcome.problem.kind], outcome.problem.messages);
32
+ return outcome.value;
33
+ };
34
+ /** What the request asks for, or a 400 saying what is wrong with it. */
35
+ const asked = (outcome) => {
36
+ if (outcome.problem) throw new Refusal(BAD_REQUEST, outcome.problem.messages);
37
+ return outcome.value;
38
+ };
39
+ /** A body as its schema reads it, or an invalid problem naming each field. */
40
+ const checked = (schema, body) => {
41
+ const parsed = schema.safeParse(body);
42
+ return parsed.success ? { value: parsed.data } : refused("invalid", parsed.error.issues.map(({ message, path }) => path.length > 0 ? `${path.join(".")}: ${message}` : message));
43
+ };
44
+ /** The file a request's ?slug= names. */
45
+ const slugOf = (url) => ({ slug: url.searchParams.get("slug") });
46
+ const listThreads = ({ project, threads, url }) => listComments({
47
+ root: project.content,
48
+ threads
49
+ }, url.searchParams.has("slug") ? asked(findPrototype(project.content, slugOf(url))) : void 0);
50
+ /** The person's actions that a change of one status alone is. */
51
+ const BY_STATUS = /* @__PURE__ */ new Map([
52
+ ["resolved", resolveComment],
53
+ ["dismissed", dismissComment],
54
+ ["open", reopenComment]
55
+ ]);
56
+ /**
57
+ * A person's change, as the action it asks for: a reply alone, or a status
58
+ * alone, is its own; anything else, or several at once, is one change.
59
+ */
60
+ const changeAsked = (context, { id, ...change }) => {
61
+ const fields = Object.keys(change);
62
+ if (fields.length === 1 && change.body !== void 0) return replyToComment(context, id, change.body);
63
+ const status = fields.length === 1 && change.status !== void 0 ? BY_STATUS.get(change.status) : void 0;
64
+ return status ? status(context, id) : changeComment(context, id, change);
65
+ };
66
+ /** Start a comment, or change one by its id, as the person using Dex. */
67
+ async function postThread({ body, project, threads, url }) {
68
+ if (!body) throw new Refusal(BAD_REQUEST, ["Send a thread to start, or a change to one."]);
69
+ const sent = isRecord(body) && body.id !== void 0 ? asked(checked(COMMENT_CHANGE, body)) : asked(checked(NEW_COMMENT, body));
70
+ const context = asked(await commentsOn({
71
+ root: project.content,
72
+ threads
73
+ }, {
74
+ prototype: slugOf(url),
75
+ by: { kind: "person" }
76
+ }));
77
+ return answer("id" in sent ? await changeAsked(context, sent) : await startComment(context, sent));
78
+ }
79
+ /**
80
+ * The comment requests, by name and method, for requests.ts's route table:
81
+ * a handler for each method the contract declares, and no other.
82
+ */
83
+ const COMMENT_HANDLERS = { threads: {
84
+ GET: listThreads,
85
+ POST: postThread
86
+ } };
87
+ //#endregion
88
+ export { COMMENT_HANDLERS };
@@ -0,0 +1,6 @@
1
+ import { ToolContext } from "../tools/context.mjs";
2
+ import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
3
+ //#region src/server/comments/tools.d.ts
4
+ /** Register `comment`, `close` and `reply` on `server`. */
5
+ export declare function registerCommentTools(server: McpServer, context: ToolContext): void;
6
+ //#endregion
@@ -0,0 +1,154 @@
1
+ import { describeAt, placeThreads } from "../thread-source.mjs";
2
+ import { askOnComment, closeComment, commentsOn, startComment } from "./actions.mjs";
3
+ import { RESPONSE_BUDGETS, cutText, fitting, sizeOf } from "../response-budget.mjs";
4
+ import { SHORT, shaped } from "../thread-forms.mjs";
5
+ import { changePlaceFor, targetFor } from "../thread-place.mjs";
6
+ import { someOf } from "../tools/result.mjs";
7
+ import { ALWAYS_LOADED } from "../tools/context.mjs";
8
+ import { describeChanged } from "../tools/describe.mjs";
9
+ import { PROTOTYPE } from "../tools/prototype-name.mjs";
10
+ import { z } from "zod";
11
+ //#region src/server/comments/tools.ts
12
+ /** Room kept in `close`'s result for what says how many more it closed. */
13
+ const CLOSE_ROOM = 300;
14
+ /** The most characters of one problem a result gives. */
15
+ const MAX_PROBLEM = 400;
16
+ /**
17
+ * A problem as an agent is told it: one about a comment it named that is
18
+ * not there says where to find the others.
19
+ */
20
+ const toAgent = ({ kind, messages }) => kind === "not-found" ? `${messages.join(" ")} List them with \`threads\`.` : messages.join(" ");
21
+ /**
22
+ * Where an agent says its change to a comment landed, as a place on that
23
+ * comment's canvas; else a line saying why it was left out.
24
+ */
25
+ const landingOf = async ({ root, threads }, id, where) => {
26
+ const thread = await threads.find(id);
27
+ if (!thread) return {};
28
+ const found = await changePlaceFor(root, thread.slug, where);
29
+ return "place" in found ? { place: found.place } : { unplaced: `\`where\` names no place on the canvas, so it was left out: ${found.problem}` };
30
+ };
31
+ /**
32
+ * Close one comment, Done (`summary`, with `where` its change landed) or
33
+ * Not done (`dismiss`): what it is now, which it was and how it closed, or
34
+ * why not.
35
+ */
36
+ const closeOne = async (context, { id, summary, dismiss, where }) => {
37
+ const { inRoot, root } = context;
38
+ const landed = summary && where ? await landingOf(context, id, where) : void 0;
39
+ const closed = await closeComment(context, {
40
+ id,
41
+ summary,
42
+ dismiss,
43
+ ...landed?.place ? { where: landed.place } : {}
44
+ });
45
+ if (closed.problem) return toAgent(closed.problem);
46
+ const { copy, thread } = closed.value;
47
+ const { messages: _, ...shown } = shaped(describeAt(thread, (await placeThreads(root, [thread])).get(id), inRoot), SHORT).thread;
48
+ return {
49
+ ...shown,
50
+ ...copy ? { copy: `Your copy's frame is under theirs: ${copy}.` } : {},
51
+ ...landed?.unplaced ? { unplaced: landed.unplaced } : {}
52
+ };
53
+ };
54
+ /** Register `comment`, `close` and `reply` on `server`. */
55
+ function registerCommentTools(server, context) {
56
+ const { agentName, ok, okAboutCode, refuse, root } = context;
57
+ server.registerTool("comment", {
58
+ annotations: {
59
+ readOnlyHint: false,
60
+ destructiveHint: false
61
+ },
62
+ title: "Leave a comment",
63
+ description: "Start a thread on a file, as people do in Dex: on an element (a frame or view plus a CSS selector, which pins the comment to that element), on a whole frame, on words in a spec (`spec` and `quote`; add `replace` to suggest new words for a person to accept), or on the file. Use it to show people what you found, for example each point of a critique where it applies, or to ask a question about a specific screen. \"for\": \"people\" (the default) is a note for people to read and answer; \"agent\" makes it a work item for an agent.",
64
+ inputSchema: {
65
+ prototype: PROTOTYPE,
66
+ message: z.string().min(1),
67
+ for: z.enum(["people", "agent"]).default("people"),
68
+ frame: z.string().optional().describe("A frame key from canvas.json: \"section/row/frame\"."),
69
+ view: z.string().optional().describe("A view name; the first frame showing it is used."),
70
+ doc: z.string().optional().describe("A document name, instead."),
71
+ selector: z.string().optional().describe("A CSS selector for the element, e.g. [data-slot=\"card\"]:nth-of-type(2) h3."),
72
+ text: z.string().optional().describe("The start of the element's text, to help people find it."),
73
+ spec: z.string().optional().describe("A spec's or a document's file from the file's folder: a spec frame's \"spec\", or \"docs/<name>.md\"."),
74
+ quote: z.string().optional().describe("With spec: the words the comment is about, as the spec's markdown has them, enough to appear once."),
75
+ replace: z.string().optional().describe("With spec and quote: a suggestion, the words to put in their place.")
76
+ }
77
+ }, async (input) => {
78
+ const found = await commentsOn(context, {
79
+ prototype: input.prototype,
80
+ by: {
81
+ kind: "agent",
82
+ name: agentName()
83
+ }
84
+ });
85
+ if (found.problem) return refuse(`No file ${input.prototype}.`);
86
+ const place = await targetFor(root, found.value.prototype, input);
87
+ if ("problem" in place) return refuse(place.problem);
88
+ const started = await startComment(found.value, {
89
+ target: place.target,
90
+ body: input.message,
91
+ for: input.for
92
+ });
93
+ return started.problem ? refuse(toAgent(started.problem)) : ok(await describeChanged(context, started.value, RESPONSE_BUDGETS.comment));
94
+ });
95
+ server.registerTool("close", {
96
+ _meta: ALWAYS_LOADED,
97
+ annotations: {
98
+ readOnlyHint: false,
99
+ destructiveHint: false,
100
+ idempotentHint: true
101
+ },
102
+ title: "Close threads",
103
+ 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 it does not, the thread stays open and the result says why. 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.",
104
+ inputSchema: { threads: z.array(z.object({
105
+ id: z.string(),
106
+ summary: z.string().min(1).optional().describe("What changed: the thread is resolved"),
107
+ dismiss: z.string().min(1).optional().describe("Why not: the thread is dismissed"),
108
+ where: z.object({
109
+ frame: z.string().optional().describe("A frame key from canvas.json: \"section/row/frame\"."),
110
+ view: z.string().optional().describe("A view name; the first frame showing it."),
111
+ selector: z.string().optional().describe("A CSS selector for the element you changed."),
112
+ text: z.string().optional().describe("The start of the element's text.")
113
+ }).optional().describe("Where the change landed: people are taken there, and a pin marks it")
114
+ })).min(1) }
115
+ }, async (input) => {
116
+ const closed = [];
117
+ const problems = [];
118
+ for (const request of input.threads) {
119
+ const outcome = await closeOne(context, request);
120
+ if (typeof outcome === "string") problems.push(outcome);
121
+ else closed.push(outcome);
122
+ }
123
+ const said = someOf(problems.map((problem) => cutText(problem, MAX_PROBLEM)));
124
+ if (closed.length === 0) return refuse(said.join(" "));
125
+ const room = RESPONSE_BUDGETS.close - sizeOf(said) - CLOSE_ROOM;
126
+ const { left, shown } = fitting(closed, room, (some) => sizeOf({ closed: some }));
127
+ return okAboutCode({
128
+ closed: shown,
129
+ ...left > 0 ? { leftOut: `${left.toLocaleString("en")} more closed with these, ${closed.length.toLocaleString("en")} in all: \`threads\` with \`status\` "resolved" or "dismissed" lists them.` } : {},
130
+ ...said.length > 0 ? { problems: said } : {}
131
+ });
132
+ });
133
+ server.registerTool("reply", {
134
+ annotations: {
135
+ readOnlyHint: false,
136
+ destructiveHint: false
137
+ },
138
+ title: "Write a message on a thread",
139
+ description: "Write a message on a thread, briefly. It hands the thread back to the person. Where someone @mentions you (the thread says \"asked\"), answer them. Anywhere else it fails unless ask is true, which is for a question about a request so ambiguous you cannot pick a sensible reading. That should be rare: when one reading is sensible, take it, do the work and close the thread with a summary (`close`).",
140
+ inputSchema: {
141
+ id: z.string(),
142
+ message: z.string().min(1),
143
+ ask: z.boolean().optional()
144
+ }
145
+ }, async ({ id, message, ask }) => {
146
+ const asked = await askOnComment(context, id, {
147
+ message,
148
+ ask
149
+ });
150
+ return asked.problem ? refuse(toAgent(asked.problem)) : ok(await describeChanged(context, asked.value, RESPONSE_BUDGETS.reply));
151
+ });
152
+ }
153
+ //#endregion
154
+ export { registerCommentTools };