@designtools/comments 0.1.0 → 0.2.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 +6 -0
- package/README.md +28 -1
- package/dist/comments.js +21 -2
- package/dist/css.js +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/prompt.d.ts +10 -0
- package/dist/prompt.js +35 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# @designtools/comments
|
|
2
2
|
|
|
3
|
+
## 0.2.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- bb3684c: Copy prompt: each thread copies itself as a prompt for Claude or another coding agent, with the page, what it's on and how to find that in the code, the comments, and the command that resolves it. `threadPrompt(thread)` builds the same text.
|
|
8
|
+
|
|
3
9
|
## 0.1.0
|
|
4
10
|
|
|
5
11
|
### Minor Changes
|
package/README.md
CHANGED
|
@@ -7,7 +7,7 @@ Comments on a prototype, pinned to the part of the page they're about. Reviewers
|
|
|
7
7
|
- **Every page, and pages that move.** The panel shows this page's comments or every page's, grouped by page. A page that marks itself with a stable id keeps its comments when its URL changes.
|
|
8
8
|
- **No account.** A name typed once and remembered by the browser. Vercel's deployment protection already decides who can open a preview; anyone who can open it can comment, reply, resolve and reopen.
|
|
9
9
|
- **Previews only.** The route answers 404 in production, and the tool draws nothing when it does.
|
|
10
|
-
- **For agents too.** `designtools-comments list` prints
|
|
10
|
+
- **For agents too.** Each thread has a **Copy prompt** button: paste it into Claude in the project and it knows the page, what the comment is on, how to find that in the code, what was said, and how to resolve the thread when it's done. `designtools-comments list` prints every open thread; `resolve <id>` closes it.
|
|
11
11
|
|
|
12
12
|
## Setup (Next App Router)
|
|
13
13
|
|
|
@@ -110,6 +110,33 @@ designtools-comments migrate [--print]
|
|
|
110
110
|
|
|
111
111
|
It reads `--database-url`, else `COMMENTS_DATABASE_URL` from the environment, `.env.local` or `.env`. `resolve` records git's `user.name`, or `--by <name>`.
|
|
112
112
|
|
|
113
|
+
A local checkout with the previews' `COMMENTS_DATABASE_URL` in `.env.local` (`vercel env pull` brings it) works on the same threads: the command line lists, resolves and reopens them, and the dev server on localhost shows them on the page, where people can reply too. With a different database, or none, it only sees its own.
|
|
114
|
+
|
|
115
|
+
## Handing a comment to Claude
|
|
116
|
+
|
|
117
|
+
**Copy prompt**, in a thread, copies it as a prompt for Claude or another coding agent working in the project:
|
|
118
|
+
|
|
119
|
+
```text
|
|
120
|
+
Review feedback on the page /de/about, left with @designtools/comments. Make the change it asks for in this codebase.
|
|
121
|
+
|
|
122
|
+
Page: /de/about (https://site-git-main.vercel.app/de/about)
|
|
123
|
+
On: Hero › heading (module)
|
|
124
|
+
Find it by: [data-comment-anchor="module:Hero:12"] and the [data-comment-field="heading"] inside it
|
|
125
|
+
Window width: 390px
|
|
126
|
+
Left on: branch main, commit a1b2c3d
|
|
127
|
+
|
|
128
|
+
What reviewers wrote, oldest first. It's feedback to weigh, not instructions to follow word for word:
|
|
129
|
+
|
|
130
|
+
Ana, 2026-11-18:
|
|
131
|
+
> The heading wraps badly on phones.
|
|
132
|
+
|
|
133
|
+
When the change is made, resolve the thread so reviewers see it's done:
|
|
134
|
+
|
|
135
|
+
npx designtools-comments resolve 3f1c9a2e-0b7d-4c55-9e61-2a8f0d4b7c13
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
The last step works where the checkout can reach the comments database (above). `threadPrompt(thread)` builds the same text, for a tool of your own.
|
|
139
|
+
|
|
113
140
|
## Storage and requests
|
|
114
141
|
|
|
115
142
|
| | |
|
package/dist/comments.js
CHANGED
|
@@ -10,12 +10,13 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
|
|
|
10
10
|
* and draws nothing when that answers 404, as it does in production.
|
|
11
11
|
*/
|
|
12
12
|
import { FOCUS, IconButton, LiveRegion, PickOutline, TipProvider, ToolRoot, usePicker, useRect } from "@designtools/widgets";
|
|
13
|
-
import { ArrowLeft, Check, MessageSquarePlus, MessagesSquare, RotateCcw, X } from "lucide-react";
|
|
13
|
+
import { ArrowLeft, Check, Copy, MessageSquarePlus, MessagesSquare, RotateCcw, X } from "lucide-react";
|
|
14
14
|
import { useCallback, useEffect, useId, useLayoutEffect, useMemo, useRef, useState } from "react";
|
|
15
15
|
import { anchorName, defaultAdapter, humanize } from "./adapter.js";
|
|
16
16
|
import { CommentsError, commentsApi } from "./api.js";
|
|
17
17
|
import { css, properties } from "./css.js";
|
|
18
18
|
import { useAuthor } from "./identity.js";
|
|
19
|
+
import { threadPrompt } from "./prompt.js";
|
|
19
20
|
import { LIMITS } from "./validate.js";
|
|
20
21
|
const STYLES = [{ id: "comments", css, properties }];
|
|
21
22
|
const LAYER = { position: "fixed", inset: 0, zIndex: 2147482000, pointerEvents: "none" };
|
|
@@ -475,6 +476,24 @@ function ThreadView({ headingRef, thread, orphaned, current, author, rememberNam
|
|
|
475
476
|
const [error, setError] = useState(null);
|
|
476
477
|
const resolved = thread.status === "resolved";
|
|
477
478
|
const otherBranch = thread.branch && current && thread.branch !== current;
|
|
479
|
+
const [copied, setCopied] = useState(false);
|
|
480
|
+
useEffect(() => {
|
|
481
|
+
if (!copied)
|
|
482
|
+
return;
|
|
483
|
+
const t = setTimeout(() => setCopied(false), 2000);
|
|
484
|
+
return () => clearTimeout(t);
|
|
485
|
+
}, [copied]);
|
|
486
|
+
const copyPrompt = async () => {
|
|
487
|
+
setError(null);
|
|
488
|
+
try {
|
|
489
|
+
await navigator.clipboard.writeText(threadPrompt(thread, { origin: location.origin }));
|
|
490
|
+
setCopied(true);
|
|
491
|
+
announce("Prompt copied. Paste it into Claude.");
|
|
492
|
+
}
|
|
493
|
+
catch {
|
|
494
|
+
setError("Couldn't copy. The browser may not allow it on this page.");
|
|
495
|
+
}
|
|
496
|
+
};
|
|
478
497
|
const toggle = async () => {
|
|
479
498
|
// anyone can resolve; without a name yet, it's recorded as someone's, and nothing is remembered
|
|
480
499
|
const who = author ?? { name: "Someone", id: "anonymous" };
|
|
@@ -492,7 +511,7 @@ function ThreadView({ headingRef, thread, orphaned, current, author, rememberNam
|
|
|
492
511
|
setBusy(false);
|
|
493
512
|
}
|
|
494
513
|
};
|
|
495
|
-
return (_jsxs(_Fragment, { children: [_jsx(Header, { headingRef: headingRef, title: anchorName(thread.anchor), back: onBack, onClose: onClose }), _jsxs("div", { className: SCROLL, children: [_jsxs("div", { className: "flex flex-wrap items-center gap-x-2 gap-y-1 px-4 pt-3 text-[11px] text-ink2", children: [_jsx("span", { className: cx("rounded-full px-2 py-0.5 font-medium", resolved ? "bg-muted text-ink" : "bg-[#1d4ed8] text-white"), children: resolved ? "Resolved" : "Open" }), resolved && thread.resolvedBy && _jsxs("span", { children: ["by ", thread.resolvedBy] }), otherBranch && _jsxs("span", { children: ["Left on branch ", thread.branch] })] }), orphaned && (_jsxs("p", { className: "mx-4 mt-3 rounded-md bg-muted px-3 py-2 text-[12px] text-ink", children: ["What this was left on isn't on this page any more.", " ", thread.deploymentUrl ? (_jsxs(_Fragment, { children: ["It was left on", " ", _jsx("a", { className: "text-ink underline underline-offset-2", href: `${thread.deploymentUrl}${thread.path}`, target: "_blank", rel: "noreferrer", children: thread.branch ? `the ${thread.branch} deployment` : "an earlier deployment" }), "."] })) : null] })), _jsx("ol", { className: "flex flex-col gap-3 px-4 py-3", children: thread.comments.map((c) => (_jsxs("li", { className: "flex flex-col gap-1", children: [_jsxs("p", { className: "flex items-baseline gap-2 text-[12px]", children: [_jsx("span", { className: "font-semibold text-ink", children: c.authorName }), _jsx("time", { dateTime: c.createdAt, title: new Date(c.createdAt).toLocaleString(), className: "text-[11px] text-ink2", children: ago(c.createdAt) })] }), _jsx("p", { className: "text-[13px] leading-[1.45] break-words whitespace-pre-wrap text-ink", children: c.body })] }, c.id))) })] }), _jsxs("div", { className: "flex flex-col gap-2 border-t border-edge p-3", children: [_jsx(Writer, { label: "Reply", send: "Reply", author: author, rememberName: rememberName, first: false, onSend: async (body, who) => {
|
|
514
|
+
return (_jsxs(_Fragment, { children: [_jsx(Header, { headingRef: headingRef, title: anchorName(thread.anchor), back: onBack, onClose: onClose }), _jsxs("div", { className: SCROLL, children: [_jsxs("div", { className: "flex flex-wrap items-center gap-x-2 gap-y-1 px-4 pt-3 text-[11px] text-ink2", children: [_jsx("span", { className: cx("rounded-full px-2 py-0.5 font-medium", resolved ? "bg-muted text-ink" : "bg-[#1d4ed8] text-white"), children: resolved ? "Resolved" : "Open" }), resolved && thread.resolvedBy && _jsxs("span", { children: ["by ", thread.resolvedBy] }), otherBranch && _jsxs("span", { children: ["Left on branch ", thread.branch] }), _jsxs("button", { type: "button", onClick: copyPrompt, className: cx(SECONDARY, "ml-auto"), title: "A prompt for Claude or another coding agent: the page, what this is on, the comments, and how to resolve it", children: [copied ? _jsx(Check, { "aria-hidden": true, width: 13, height: 13 }) : _jsx(Copy, { "aria-hidden": true, width: 13, height: 13 }), copied ? "Copied" : "Copy prompt"] })] }), orphaned && (_jsxs("p", { className: "mx-4 mt-3 rounded-md bg-muted px-3 py-2 text-[12px] text-ink", children: ["What this was left on isn't on this page any more.", " ", thread.deploymentUrl ? (_jsxs(_Fragment, { children: ["It was left on", " ", _jsx("a", { className: "text-ink underline underline-offset-2", href: `${thread.deploymentUrl}${thread.path}`, target: "_blank", rel: "noreferrer", children: thread.branch ? `the ${thread.branch} deployment` : "an earlier deployment" }), "."] })) : null] })), _jsx("ol", { className: "flex flex-col gap-3 px-4 py-3", children: thread.comments.map((c) => (_jsxs("li", { className: "flex flex-col gap-1", children: [_jsxs("p", { className: "flex items-baseline gap-2 text-[12px]", children: [_jsx("span", { className: "font-semibold text-ink", children: c.authorName }), _jsx("time", { dateTime: c.createdAt, title: new Date(c.createdAt).toLocaleString(), className: "text-[11px] text-ink2", children: ago(c.createdAt) })] }), _jsx("p", { className: "text-[13px] leading-[1.45] break-words whitespace-pre-wrap text-ink", children: c.body })] }, c.id))) })] }), _jsxs("div", { className: "flex flex-col gap-2 border-t border-edge p-3", children: [_jsx(Writer, { label: "Reply", send: "Reply", author: author, rememberName: rememberName, first: false, onSend: async (body, who) => {
|
|
496
515
|
const comment = await api.reply(thread.id, body, who);
|
|
497
516
|
onChange({ ...thread, comments: [...thread.comments, comment] });
|
|
498
517
|
announce("Reply added.");
|
package/dist/css.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export const css = "/*! tailwindcss v4.3.3 | MIT License | https://tailwindcss.com */\n@layer properties{@supports (((-webkit-hyphens:none)) and (not (margin-trim:inline))) or ((-moz-orient:inline) and (not (color:rgb(from red r g b)))){*,:before,:after,::backdrop{--tw-border-style:solid;--tw-leading:initial;--tw-font-weight:initial;--tw-ordinal:initial;--tw-slashed-zero:initial;--tw-numeric-figure:initial;--tw-numeric-spacing:initial;--tw-numeric-fraction:initial;--tw-shadow:0 0 #0000;--tw-shadow-color:initial;--tw-shadow-alpha:100%;--tw-inset-shadow:0 0 #0000;--tw-inset-shadow-color:initial;--tw-inset-shadow-alpha:100%;--tw-ring-color:initial;--tw-ring-shadow:0 0 #0000;--tw-inset-ring-color:initial;--tw-inset-ring-shadow:0 0 #0000;--tw-ring-inset:initial;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-offset-shadow:0 0 #0000;--tw-outline-style:solid;--tw-blur:initial;--tw-brightness:initial;--tw-contrast:initial;--tw-grayscale:initial;--tw-hue-rotate:initial;--tw-invert:initial;--tw-opacity:initial;--tw-saturate:initial;--tw-sepia:initial;--tw-drop-shadow:initial;--tw-drop-shadow-color:initial;--tw-drop-shadow-alpha:100%;--tw-drop-shadow-size:initial}}}@layer theme{:root,:host{--font-sans:ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, \"Segoe UI\", sans-serif;--font-weight-normal:400;--font-weight-medium:500;--font-weight-semibold:600}}@layer utilities{.pointer-events-auto{pointer-events:auto}.visible{visibility:visible}.fixed{position:fixed}.bottom-4{bottom:16px}.left-4{left:16px}.m-3{margin:12px}.mx-4{margin-inline:16px}.mt-3{margin-top:12px}.ml-1{margin-left:4px}.line-clamp-2{-webkit-line-clamp:2;-webkit-box-orient:vertical;display:-webkit-box;overflow:hidden}.block{display:block}.flex{display:flex}.inline-flex{display:inline-flex}.table{display:table}.h-7{height:28px}.h-8{height:32px}.min-h-0{min-height:0}.w-full{width:100%}.min-w-0{min-width:0}.min-w-8{min-width:32px}.flex-1{flex:1}.cursor-pointer{cursor:pointer}.resize{resize:both}.resize-y{resize:vertical}.flex-col{flex-direction:column}.flex-wrap{flex-wrap:wrap}.items-baseline{align-items:baseline}.items-center{align-items:center}.items-end{align-items:flex-end}.items-start{align-items:flex-start}.justify-between{justify-content:space-between}.justify-center{justify-content:center}.gap-0\\.5{gap:2px}.gap-1{gap:4px}.gap-1\\.5{gap:6px}.gap-2{gap:8px}.gap-3{gap:12px}.gap-x-2{column-gap:8px}.gap-x-3{column-gap:12px}.gap-y-1{row-gap:4px}.truncate{text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.overflow-hidden{overflow:hidden}.overflow-y-auto{overflow-y:auto}.rounded-full{border-radius:3.40282e38px}.rounded-lg{border-radius:8px}.rounded-md{border-radius:6px}.rounded-sm{border-radius:4px}.rounded-xl{border-radius:12px}.rounded-t-xl{border-top-left-radius:12px;border-top-right-radius:12px}.rounded-b-xl{border-bottom-right-radius:12px;border-bottom-left-radius:12px}.rounded-bl-none{border-bottom-left-radius:0}.border{border-style:var(--tw-border-style);border-width:1px}.border-2{border-style:var(--tw-border-style);border-width:2px}.border-x-0{border-inline-style:var(--tw-border-style);border-inline-width:0}.border-t{border-top-style:var(--tw-border-style);border-top-width:1px}.border-t-0{border-top-style:var(--tw-border-style);border-top-width:0}.border-b{border-bottom-style:var(--tw-border-style);border-bottom-width:1px}.border-b-0{border-bottom-style:var(--tw-border-style);border-bottom-width:0}.border-edge{border-color:var(--dt-edge)}.border-white{border-color:#fff}.bg-\\[\\#1d4ed8\\]{background-color:#1d4ed8}.bg-muted{background-color:var(--dt-muted)}.bg-page{background-color:var(--dt-page)}.p-1{padding:4px}.p-3{padding:12px}.px-1{padding-inline:4px}.px-2{padding-inline:8px}.px-2\\.5{padding-inline:10px}.px-3{padding-inline:12px}.px-4{padding-inline:16px}.py-0\\.5{padding-block:2px}.py-1{padding-block:4px}.py-2{padding-block:8px}.py-2\\.5{padding-block:10px}.py-3{padding-block:12px}.py-6{padding-block:24px}.pt-3{padding-top:12px}.pr-2{padding-right:8px}.pb-1{padding-bottom:4px}.pl-2{padding-left:8px}.text-left{text-align:left}.text-\\[11px\\]{font-size:11px}.text-\\[12px\\]{font-size:12px}.text-\\[13px\\]{font-size:13px}.leading-\\[1\\.45\\]{--tw-leading:1.45;line-height:1.45}.font-medium{--tw-font-weight:var(--font-weight-medium);font-weight:var(--font-weight-medium)}.font-normal{--tw-font-weight:var(--font-weight-normal);font-weight:var(--font-weight-normal)}.font-semibold{--tw-font-weight:var(--font-weight-semibold);font-weight:var(--font-weight-semibold)}.break-words{overflow-wrap:break-word}.whitespace-pre-wrap{white-space:pre-wrap}.text-fail{color:var(--dt-fail)}.text-ink{color:var(--dt-ink)}.text-ink2{color:var(--dt-ink2)}.text-white{color:#fff}.tabular-nums{--tw-numeric-spacing:tabular-nums;font-variant-numeric:var(--tw-ordinal,) var(--tw-slashed-zero,) var(--tw-numeric-figure,) var(--tw-numeric-spacing,) var(--tw-numeric-fraction,)}.underline{text-decoration-line:underline}.underline-offset-2{text-underline-offset:2px}.shadow{--tw-shadow:0 1px 3px 0 var(--tw-shadow-color,#0000001a), 0 1px 2px -1px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow)}.shadow-2xl{--tw-shadow:0 25px 50px -12px var(--tw-shadow-color,#00000040);box-shadow:var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow)}.shadow-lg{--tw-shadow:0 10px 15px -3px var(--tw-shadow-color,#0000001a), 0 4px 6px -4px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow)}.shadow-md{--tw-shadow:0 4px 6px -1px var(--tw-shadow-color,#0000001a), 0 2px 4px -2px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow)}.shadow-black\\/15{--tw-shadow-color:#00000026}@supports (color:color-mix(in lab, red, red)){.shadow-black\\/15{--tw-shadow-color:color-mix(in oklab, oklab(0% none none/.15) var(--tw-shadow-alpha), transparent)}}.shadow-black\\/20{--tw-shadow-color:#0003}@supports (color:color-mix(in lab, red, red)){.shadow-black\\/20{--tw-shadow-color:color-mix(in oklab, oklab(0% none none/.2) var(--tw-shadow-alpha), transparent)}}.shadow-black\\/25{--tw-shadow-color:#00000040}@supports (color:color-mix(in lab, red, red)){.shadow-black\\/25{--tw-shadow-color:color-mix(in oklab, oklab(0% none none/.25) var(--tw-shadow-alpha), transparent)}}.outline-2{outline-style:var(--tw-outline-style);outline-width:2px}.outline-offset-2{outline-offset:2px}.outline-\\[\\#1d4ed8\\]{outline-color:#1d4ed8}.filter{filter:var(--tw-blur,) var(--tw-brightness,) var(--tw-contrast,) var(--tw-grayscale,) var(--tw-hue-rotate,) var(--tw-invert,) var(--tw-saturate,) var(--tw-sepia,) var(--tw-drop-shadow,)}.outline-none{--tw-outline-style:none;outline-style:none}.placeholder\\:text-ink2::placeholder{color:var(--dt-ink2)}@media (hover:hover){.hover\\:bg-\\[\\#1e40af\\]:hover{background-color:#1e40af}.hover\\:bg-scrim:hover{background-color:var(--dt-scrim)}.hover\\:underline:hover{text-decoration-line:underline}}.focus\\:border-sel:focus{border-color:var(--dt-sel)}.focus\\:outline-2:focus{outline-style:var(--tw-outline-style);outline-width:2px}.focus\\:-outline-offset-1:focus{outline-offset:calc(1px * -1)}.focus\\:outline-sel:focus{outline-color:var(--dt-sel)}.focus-visible\\:outline-2:focus-visible{outline-style:var(--tw-outline-style);outline-width:2px}.focus-visible\\:outline-offset-2:focus-visible{outline-offset:2px}.focus-visible\\:outline-\\[\\#1d4ed8\\]:focus-visible{outline-color:#1d4ed8}.disabled\\:cursor-default:disabled{cursor:default}.disabled\\:opacity-50:disabled{opacity:.5}.aria-expanded\\:bg-scrim[aria-expanded=true]{background-color:var(--dt-scrim)}.aria-pressed\\:bg-muted[aria-pressed=true]{background-color:var(--dt-muted)}.aria-pressed\\:bg-scrim[aria-pressed=true]{background-color:var(--dt-scrim)}.aria-pressed\\:text-ink[aria-pressed=true]{color:var(--dt-ink)}}:host{all:initial}.dt-base{all:initial;--dt-page:#fff;--dt-raised:#f8f8f9;--dt-muted:#f0f0f2;--dt-edge:#e4e4e7;--dt-ink:#09090b;--dt-ink2:#71717a;--dt-ink3:#a1a1aa;--dt-sel:#3b82f6;--dt-scrim:#0000000f;--dt-ok:#16a34a;--dt-warn:#d97706;--dt-fail:#dc2626;--dt-icon:oklch(55% 0 0);color-scheme:light;font-family:var(--font-sans);letter-spacing:normal;text-align:left;cursor:auto;color:var(--dt-ink);-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;font-size:11px;font-weight:400;line-height:1.4;display:contents}.dt-base[data-theme=dark]{--dt-page:#161618;--dt-raised:#18181b;--dt-muted:#27272a;--dt-edge:#2e2e33;--dt-ink:#fafafa;--dt-ink2:#b5b5be;--dt-ink3:#9494a0;--dt-scrim:#ffffff14;--dt-ok:#4ade80;--dt-warn:#fbbf24;--dt-fail:#f87171;color-scheme:dark}@media (prefers-color-scheme:dark){.dt-base:not([data-theme=light]){--dt-page:#161618;--dt-raised:#18181b;--dt-muted:#27272a;--dt-edge:#2e2e33;--dt-ink:#fafafa;--dt-ink2:#b5b5be;--dt-ink3:#9494a0;--dt-scrim:#ffffff14;--dt-ok:#4ade80;--dt-warn:#fbbf24;--dt-fail:#f87171;color-scheme:dark}}input[type=number]::-webkit-inner-spin-button{appearance:none;margin:0}input[type=number]::-webkit-outer-spin-button{appearance:none;margin:0}\n";
|
|
1
|
+
export const css = "/*! tailwindcss v4.3.3 | MIT License | https://tailwindcss.com */\n@layer properties{@supports (((-webkit-hyphens:none)) and (not (margin-trim:inline))) or ((-moz-orient:inline) and (not (color:rgb(from red r g b)))){*,:before,:after,::backdrop{--tw-border-style:solid;--tw-leading:initial;--tw-font-weight:initial;--tw-ordinal:initial;--tw-slashed-zero:initial;--tw-numeric-figure:initial;--tw-numeric-spacing:initial;--tw-numeric-fraction:initial;--tw-shadow:0 0 #0000;--tw-shadow-color:initial;--tw-shadow-alpha:100%;--tw-inset-shadow:0 0 #0000;--tw-inset-shadow-color:initial;--tw-inset-shadow-alpha:100%;--tw-ring-color:initial;--tw-ring-shadow:0 0 #0000;--tw-inset-ring-color:initial;--tw-inset-ring-shadow:0 0 #0000;--tw-ring-inset:initial;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-offset-shadow:0 0 #0000;--tw-outline-style:solid;--tw-blur:initial;--tw-brightness:initial;--tw-contrast:initial;--tw-grayscale:initial;--tw-hue-rotate:initial;--tw-invert:initial;--tw-opacity:initial;--tw-saturate:initial;--tw-sepia:initial;--tw-drop-shadow:initial;--tw-drop-shadow-color:initial;--tw-drop-shadow-alpha:100%;--tw-drop-shadow-size:initial}}}@layer theme{:root,:host{--font-sans:ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, \"Segoe UI\", sans-serif;--font-weight-normal:400;--font-weight-medium:500;--font-weight-semibold:600}}@layer utilities{.pointer-events-auto{pointer-events:auto}.visible{visibility:visible}.fixed{position:fixed}.bottom-4{bottom:16px}.left-4{left:16px}.m-3{margin:12px}.mx-4{margin-inline:16px}.mt-3{margin-top:12px}.ml-1{margin-left:4px}.ml-auto{margin-left:auto}.line-clamp-2{-webkit-line-clamp:2;-webkit-box-orient:vertical;display:-webkit-box;overflow:hidden}.block{display:block}.flex{display:flex}.inline-flex{display:inline-flex}.table{display:table}.h-7{height:28px}.h-8{height:32px}.min-h-0{min-height:0}.w-full{width:100%}.min-w-0{min-width:0}.min-w-8{min-width:32px}.flex-1{flex:1}.cursor-pointer{cursor:pointer}.resize{resize:both}.resize-y{resize:vertical}.flex-col{flex-direction:column}.flex-wrap{flex-wrap:wrap}.items-baseline{align-items:baseline}.items-center{align-items:center}.items-end{align-items:flex-end}.items-start{align-items:flex-start}.justify-between{justify-content:space-between}.justify-center{justify-content:center}.gap-0\\.5{gap:2px}.gap-1{gap:4px}.gap-1\\.5{gap:6px}.gap-2{gap:8px}.gap-3{gap:12px}.gap-x-2{column-gap:8px}.gap-x-3{column-gap:12px}.gap-y-1{row-gap:4px}.truncate{text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.overflow-hidden{overflow:hidden}.overflow-y-auto{overflow-y:auto}.rounded-full{border-radius:3.40282e38px}.rounded-lg{border-radius:8px}.rounded-md{border-radius:6px}.rounded-sm{border-radius:4px}.rounded-xl{border-radius:12px}.rounded-t-xl{border-top-left-radius:12px;border-top-right-radius:12px}.rounded-b-xl{border-bottom-right-radius:12px;border-bottom-left-radius:12px}.rounded-bl-none{border-bottom-left-radius:0}.border{border-style:var(--tw-border-style);border-width:1px}.border-2{border-style:var(--tw-border-style);border-width:2px}.border-x-0{border-inline-style:var(--tw-border-style);border-inline-width:0}.border-t{border-top-style:var(--tw-border-style);border-top-width:1px}.border-t-0{border-top-style:var(--tw-border-style);border-top-width:0}.border-b{border-bottom-style:var(--tw-border-style);border-bottom-width:1px}.border-b-0{border-bottom-style:var(--tw-border-style);border-bottom-width:0}.border-edge{border-color:var(--dt-edge)}.border-white{border-color:#fff}.bg-\\[\\#1d4ed8\\]{background-color:#1d4ed8}.bg-muted{background-color:var(--dt-muted)}.bg-page{background-color:var(--dt-page)}.p-1{padding:4px}.p-3{padding:12px}.px-1{padding-inline:4px}.px-2{padding-inline:8px}.px-2\\.5{padding-inline:10px}.px-3{padding-inline:12px}.px-4{padding-inline:16px}.py-0\\.5{padding-block:2px}.py-1{padding-block:4px}.py-2{padding-block:8px}.py-2\\.5{padding-block:10px}.py-3{padding-block:12px}.py-6{padding-block:24px}.pt-3{padding-top:12px}.pr-2{padding-right:8px}.pb-1{padding-bottom:4px}.pl-2{padding-left:8px}.text-left{text-align:left}.text-\\[11px\\]{font-size:11px}.text-\\[12px\\]{font-size:12px}.text-\\[13px\\]{font-size:13px}.leading-\\[1\\.45\\]{--tw-leading:1.45;line-height:1.45}.font-medium{--tw-font-weight:var(--font-weight-medium);font-weight:var(--font-weight-medium)}.font-normal{--tw-font-weight:var(--font-weight-normal);font-weight:var(--font-weight-normal)}.font-semibold{--tw-font-weight:var(--font-weight-semibold);font-weight:var(--font-weight-semibold)}.break-words{overflow-wrap:break-word}.whitespace-pre-wrap{white-space:pre-wrap}.text-fail{color:var(--dt-fail)}.text-ink{color:var(--dt-ink)}.text-ink2{color:var(--dt-ink2)}.text-white{color:#fff}.tabular-nums{--tw-numeric-spacing:tabular-nums;font-variant-numeric:var(--tw-ordinal,) var(--tw-slashed-zero,) var(--tw-numeric-figure,) var(--tw-numeric-spacing,) var(--tw-numeric-fraction,)}.underline{text-decoration-line:underline}.underline-offset-2{text-underline-offset:2px}.shadow{--tw-shadow:0 1px 3px 0 var(--tw-shadow-color,#0000001a), 0 1px 2px -1px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow)}.shadow-2xl{--tw-shadow:0 25px 50px -12px var(--tw-shadow-color,#00000040);box-shadow:var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow)}.shadow-lg{--tw-shadow:0 10px 15px -3px var(--tw-shadow-color,#0000001a), 0 4px 6px -4px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow)}.shadow-md{--tw-shadow:0 4px 6px -1px var(--tw-shadow-color,#0000001a), 0 2px 4px -2px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow)}.shadow-black\\/15{--tw-shadow-color:#00000026}@supports (color:color-mix(in lab, red, red)){.shadow-black\\/15{--tw-shadow-color:color-mix(in oklab, oklab(0% none none/.15) var(--tw-shadow-alpha), transparent)}}.shadow-black\\/20{--tw-shadow-color:#0003}@supports (color:color-mix(in lab, red, red)){.shadow-black\\/20{--tw-shadow-color:color-mix(in oklab, oklab(0% none none/.2) var(--tw-shadow-alpha), transparent)}}.shadow-black\\/25{--tw-shadow-color:#00000040}@supports (color:color-mix(in lab, red, red)){.shadow-black\\/25{--tw-shadow-color:color-mix(in oklab, oklab(0% none none/.25) var(--tw-shadow-alpha), transparent)}}.outline-2{outline-style:var(--tw-outline-style);outline-width:2px}.outline-offset-2{outline-offset:2px}.outline-\\[\\#1d4ed8\\]{outline-color:#1d4ed8}.filter{filter:var(--tw-blur,) var(--tw-brightness,) var(--tw-contrast,) var(--tw-grayscale,) var(--tw-hue-rotate,) var(--tw-invert,) var(--tw-saturate,) var(--tw-sepia,) var(--tw-drop-shadow,)}.outline-none{--tw-outline-style:none;outline-style:none}.placeholder\\:text-ink2::placeholder{color:var(--dt-ink2)}@media (hover:hover){.hover\\:bg-\\[\\#1e40af\\]:hover{background-color:#1e40af}.hover\\:bg-scrim:hover{background-color:var(--dt-scrim)}.hover\\:underline:hover{text-decoration-line:underline}}.focus\\:border-sel:focus{border-color:var(--dt-sel)}.focus\\:outline-2:focus{outline-style:var(--tw-outline-style);outline-width:2px}.focus\\:-outline-offset-1:focus{outline-offset:calc(1px * -1)}.focus\\:outline-sel:focus{outline-color:var(--dt-sel)}.focus-visible\\:outline-2:focus-visible{outline-style:var(--tw-outline-style);outline-width:2px}.focus-visible\\:outline-offset-2:focus-visible{outline-offset:2px}.focus-visible\\:outline-\\[\\#1d4ed8\\]:focus-visible{outline-color:#1d4ed8}.disabled\\:cursor-default:disabled{cursor:default}.disabled\\:opacity-50:disabled{opacity:.5}.aria-expanded\\:bg-scrim[aria-expanded=true]{background-color:var(--dt-scrim)}.aria-pressed\\:bg-muted[aria-pressed=true]{background-color:var(--dt-muted)}.aria-pressed\\:bg-scrim[aria-pressed=true]{background-color:var(--dt-scrim)}.aria-pressed\\:text-ink[aria-pressed=true]{color:var(--dt-ink)}}:host{all:initial}.dt-base{all:initial;--dt-page:#fff;--dt-raised:#f8f8f9;--dt-muted:#f0f0f2;--dt-edge:#e4e4e7;--dt-ink:#09090b;--dt-ink2:#71717a;--dt-ink3:#a1a1aa;--dt-sel:#3b82f6;--dt-scrim:#0000000f;--dt-ok:#16a34a;--dt-warn:#d97706;--dt-fail:#dc2626;--dt-icon:oklch(55% 0 0);color-scheme:light;font-family:var(--font-sans);letter-spacing:normal;text-align:left;cursor:auto;color:var(--dt-ink);-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;font-size:11px;font-weight:400;line-height:1.4;display:contents}.dt-base[data-theme=dark]{--dt-page:#161618;--dt-raised:#18181b;--dt-muted:#27272a;--dt-edge:#2e2e33;--dt-ink:#fafafa;--dt-ink2:#b5b5be;--dt-ink3:#9494a0;--dt-scrim:#ffffff14;--dt-ok:#4ade80;--dt-warn:#fbbf24;--dt-fail:#f87171;color-scheme:dark}@media (prefers-color-scheme:dark){.dt-base:not([data-theme=light]){--dt-page:#161618;--dt-raised:#18181b;--dt-muted:#27272a;--dt-edge:#2e2e33;--dt-ink:#fafafa;--dt-ink2:#b5b5be;--dt-ink3:#9494a0;--dt-scrim:#ffffff14;--dt-ok:#4ade80;--dt-warn:#fbbf24;--dt-fail:#f87171;color-scheme:dark}}input[type=number]::-webkit-inner-spin-button{appearance:none;margin:0}input[type=number]::-webkit-outer-spin-button{appearance:none;margin:0}\n";
|
|
2
2
|
export const properties = "@property --tw-border-style{syntax:\"*\";inherits:false;initial-value:solid}\n@property --tw-leading{syntax:\"*\";inherits:false}\n@property --tw-font-weight{syntax:\"*\";inherits:false}\n@property --tw-ordinal{syntax:\"*\";inherits:false}\n@property --tw-slashed-zero{syntax:\"*\";inherits:false}\n@property --tw-numeric-figure{syntax:\"*\";inherits:false}\n@property --tw-numeric-spacing{syntax:\"*\";inherits:false}\n@property --tw-numeric-fraction{syntax:\"*\";inherits:false}\n@property --tw-shadow{syntax:\"*\";inherits:false;initial-value:0 0 #0000}\n@property --tw-shadow-color{syntax:\"*\";inherits:false}\n@property --tw-shadow-alpha{syntax:\"<percentage>\";inherits:false;initial-value:100%}\n@property --tw-inset-shadow{syntax:\"*\";inherits:false;initial-value:0 0 #0000}\n@property --tw-inset-shadow-color{syntax:\"*\";inherits:false}\n@property --tw-inset-shadow-alpha{syntax:\"<percentage>\";inherits:false;initial-value:100%}\n@property --tw-ring-color{syntax:\"*\";inherits:false}\n@property --tw-ring-shadow{syntax:\"*\";inherits:false;initial-value:0 0 #0000}\n@property --tw-inset-ring-color{syntax:\"*\";inherits:false}\n@property --tw-inset-ring-shadow{syntax:\"*\";inherits:false;initial-value:0 0 #0000}\n@property --tw-ring-inset{syntax:\"*\";inherits:false}\n@property --tw-ring-offset-width{syntax:\"<length>\";inherits:false;initial-value:0}\n@property --tw-ring-offset-color{syntax:\"*\";inherits:false;initial-value:#fff}\n@property --tw-ring-offset-shadow{syntax:\"*\";inherits:false;initial-value:0 0 #0000}\n@property --tw-outline-style{syntax:\"*\";inherits:false;initial-value:solid}\n@property --tw-blur{syntax:\"*\";inherits:false}\n@property --tw-brightness{syntax:\"*\";inherits:false}\n@property --tw-contrast{syntax:\"*\";inherits:false}\n@property --tw-grayscale{syntax:\"*\";inherits:false}\n@property --tw-hue-rotate{syntax:\"*\";inherits:false}\n@property --tw-invert{syntax:\"*\";inherits:false}\n@property --tw-opacity{syntax:\"*\";inherits:false}\n@property --tw-saturate{syntax:\"*\";inherits:false}\n@property --tw-sepia{syntax:\"*\";inherits:false}\n@property --tw-drop-shadow{syntax:\"*\";inherits:false}\n@property --tw-drop-shadow-color{syntax:\"*\";inherits:false}\n@property --tw-drop-shadow-alpha{syntax:\"<percentage>\";inherits:false;initial-value:100%}\n@property --tw-drop-shadow-size{syntax:\"*\";inherits:false}";
|
package/dist/index.d.ts
CHANGED
|
@@ -3,3 +3,4 @@ export { CommentsError, commentsApi, type CommentsApi } from "./api.js";
|
|
|
3
3
|
export { Comments, type CommentsProps } from "./comments.js";
|
|
4
4
|
export { readAuthor, rememberName, useAuthor } from "./identity.js";
|
|
5
5
|
export type { Author, Comment, Deployment, Thread, ThreadList, ThreadStatus } from "./types.js";
|
|
6
|
+
export { type PromptOptions, threadPrompt } from "./prompt.js";
|
package/dist/index.js
CHANGED
|
@@ -2,3 +2,4 @@ export { anchorName, cssPath, defaultAdapter, genericLabel, humanize } from "./a
|
|
|
2
2
|
export { CommentsError, commentsApi } from "./api.js";
|
|
3
3
|
export { Comments } from "./comments.js";
|
|
4
4
|
export { readAuthor, rememberName, useAuthor } from "./identity.js";
|
|
5
|
+
export { threadPrompt } from "./prompt.js";
|
package/dist/prompt.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A thread as a prompt for a coding agent: where on the page it is, how to find that in the code,
|
|
3
|
+
* what reviewers said, and how to close it when the change is made. No DOM here.
|
|
4
|
+
*/
|
|
5
|
+
import type { Thread } from "./types.js";
|
|
6
|
+
export interface PromptOptions {
|
|
7
|
+
/** Where the page can be seen, as an origin: "https://ezra-git-main.vercel.app". By default the thread's deployment. */
|
|
8
|
+
origin?: string | null;
|
|
9
|
+
}
|
|
10
|
+
export declare function threadPrompt(thread: Thread, options?: PromptOptions): string;
|
package/dist/prompt.js
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
const quote = (text) => text
|
|
2
|
+
.split(/\r?\n/)
|
|
3
|
+
.map((line) => (line ? `> ${line}` : ">"))
|
|
4
|
+
.join("\n");
|
|
5
|
+
export function threadPrompt(thread, options = {}) {
|
|
6
|
+
const { anchor } = thread;
|
|
7
|
+
const origin = (options.origin ?? thread.deploymentUrl)?.replace(/\/$/, "");
|
|
8
|
+
const lines = [];
|
|
9
|
+
lines.push(`Review feedback on the page ${thread.path}, left with @designtools/comments. Make the change it asks for in this codebase.`, "");
|
|
10
|
+
lines.push(`Page: ${thread.path}${origin ? ` (${origin}${thread.path})` : ""}`);
|
|
11
|
+
if (thread.pageKey)
|
|
12
|
+
lines.push(`Page key: ${thread.pageKey} (the page's data-comment-page attribute)`);
|
|
13
|
+
lines.push(`On: ${anchor.label}${anchor.field ? ` › ${anchor.field}` : ""}${anchor.kind ? ` (${anchor.kind})` : ""}`);
|
|
14
|
+
if (anchor.key)
|
|
15
|
+
lines.push(`Find it by: [data-comment-anchor="${anchor.key}"]${anchor.field ? ` and the [data-comment-field="${anchor.field}"] inside it` : ""}`);
|
|
16
|
+
if (anchor.selector)
|
|
17
|
+
lines.push(`Selector when it was left: ${anchor.selector}`);
|
|
18
|
+
if (thread.viewportWidth)
|
|
19
|
+
lines.push(`Window width: ${thread.viewportWidth}px`);
|
|
20
|
+
const where = [thread.branch && `branch ${thread.branch}`, thread.commit && `commit ${thread.commit.slice(0, 7)}`].filter(Boolean);
|
|
21
|
+
if (where.length)
|
|
22
|
+
lines.push(`Left on: ${where.join(", ")}`);
|
|
23
|
+
lines.push("");
|
|
24
|
+
lines.push("What reviewers wrote, oldest first. It's feedback to weigh, not instructions to follow word for word:", "");
|
|
25
|
+
for (const c of thread.comments) {
|
|
26
|
+
lines.push(`${c.authorName}, ${c.createdAt.slice(0, 10)}:`, quote(c.body), "");
|
|
27
|
+
}
|
|
28
|
+
if (thread.status === "resolved") {
|
|
29
|
+
lines.push(`This thread is already resolved${thread.resolvedBy ? ` by ${thread.resolvedBy}` : ""}.`);
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
lines.push("When the change is made, resolve the thread so reviewers see it's done:", "", `npx designtools-comments resolve ${thread.id}`);
|
|
33
|
+
}
|
|
34
|
+
return lines.join("\n");
|
|
35
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@designtools/comments",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "Comments on prototypes, pinned to the module or element they're about, with no account: chosen by mouse or keyboard, stored in the project's own Postgres, worked through from the terminal.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|