notemend 0.1.26 → 0.1.28
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/.claude-plugin/plugin.json +1 -1
- package/README.md +42 -14
- package/bin/init.mjs +15 -15
- package/bin/notemend.mjs +18 -18
- package/bin/step.mjs +2 -0
- package/hooks/hooks.json +3 -0
- package/package.json +1 -1
- package/src/client/index.js +167 -145
- package/src/client/notemend.css +1 -1
- package/src/integration.mjs +1 -1
- package/src/next.mjs +7 -1
- package/src/server/middleware.mjs +7 -1
- package/src/store/cloud.mjs +3 -3
- package/src/store/comments.mjs +3 -3
- package/src/store/thread.mjs +1 -1
- package/store.d.ts +18 -3
- package/thread.d.ts +42 -1
package/README.md
CHANGED
|
@@ -63,14 +63,15 @@ npx notemend open comments for the agent
|
|
|
63
63
|
npx notemend all including resolved ones and those given to people
|
|
64
64
|
npx notemend start <id> [--force] take it before fixing: the thread shows the agent is on it,
|
|
65
65
|
and another agent is refused (--force takes it anyway)
|
|
66
|
-
npx notemend reply <id> "..." answer in the thread (
|
|
66
|
+
npx notemend reply <id> "..." answer in the thread (note: the same, but the thread stays in hand; not with an agent key)
|
|
67
67
|
npx notemend done <id> "..." [--shot] resolve as the agent, with a note (stays marked until a
|
|
68
68
|
person confirms); --shot files a picture after the fix
|
|
69
69
|
npx notemend reopen <id>
|
|
70
70
|
npx notemend rm <id> delete the thread and its screenshots
|
|
71
71
|
npx notemend shot <id> ["note"] [--before] [--url <dev server>] a picture of the element at the comment's
|
|
72
72
|
width (Playwright); a note goes in the thread as the agent's reply
|
|
73
|
-
npx notemend watch [--timeout <min>] [--start | --stop] turbo: wait for a comment for the agent, print it, exit
|
|
73
|
+
npx notemend watch [--timeout <min>] [--push] [--start | --stop] turbo: wait for a comment for the agent, print it, exit;
|
|
74
|
+
--push waits for the bar's Push to Claude batch instead
|
|
74
75
|
npx notemend prune [--dry] local store: move resolved threads to feedback/archive/
|
|
75
76
|
npx notemend digest | count short forms for the agents' hooks (--format claude|codex|gemini|cursor)
|
|
76
77
|
npx notemend mcp the same queue as an MCP server (stdio)
|
|
@@ -81,7 +82,8 @@ npx notemend --version | --help
|
|
|
81
82
|
```
|
|
82
83
|
|
|
83
84
|
`NOTEMEND_URL` is the dev server for screenshots when there is no `--url`; `NOTEMEND_KEY`
|
|
84
|
-
and `NOTEMEND_PROJECT` are for an agent on its own (below)
|
|
85
|
+
and `NOTEMEND_PROJECT` are for an agent on its own (below); `NOTEMEND_HOME` moves the CLI's
|
|
86
|
+
session and version check (default `~/.config/notemend`).
|
|
85
87
|
|
|
86
88
|
The root is the nearest directory with a `package.json` above the working directory, or
|
|
87
89
|
`--root <dir>`. The panel numbers threads per page and breakpoint (`#4`); the CLI prints
|
|
@@ -149,7 +151,8 @@ The hooks and the tools in one, no `init` needed for Claude Code:
|
|
|
149
151
|
/plugin install notemend@notemend
|
|
150
152
|
```
|
|
151
153
|
|
|
152
|
-
|
|
154
|
+
It adds `/notemend:turbo` (takes each comment for the agent as it lands) and `/notemend:push`
|
|
155
|
+
(takes the batch sent with Push to Claude); `off` ends either. Its files are in `plugin/`; `npm run pack` puts them at the package root, and
|
|
153
156
|
`npm run mcpb` rebuilds the Claude Desktop bundle (`web/public/notemend.mcpb`) after a pack.
|
|
154
157
|
|
|
155
158
|
### An agent that works on its own
|
|
@@ -175,13 +178,25 @@ Review a site the way you review a design file:
|
|
|
175
178
|
Figma states them), its fill and text colour, or its border per side and radius per
|
|
176
179
|
corner — each colour by the CSS variable it was written with. Values are *design* px:
|
|
177
180
|
actual px ÷ the root font scale.
|
|
178
|
-
- **
|
|
181
|
+
- **Contrast · Vision** — the ratio of the text under the pointer with WCAG's three checks and,
|
|
182
|
+
when it fails, the nearest passing colour of the same hue (a click copies it) (`K`); the page as
|
|
183
|
+
six kinds of eyes see it — normal, greyscale, low vision, deuteranopia, protanopia, tritanopia (`V`).
|
|
184
|
+
- **Customize** — the gear menu's *Customize the bar* hides the inspectors and screen sizes you
|
|
185
|
+
never use (kept per browser); comments, the panel and the rest always stay.
|
|
186
|
+
- **Comments** — Figma-style pins (a teardrop in the status colour with the faces inside): threads, six types (General, Bug, Text, Motion, Design, Content), screenshots (paste, drop or pick)
|
|
179
187
|
that go with the message they were sent with, your own messages editable, a half-written
|
|
180
188
|
comment parked as a draft — a pencil pin on the page and a row in the panel — when you
|
|
181
189
|
close it or click somewhere else; drafts never block a new comment. Filed per page and
|
|
182
190
|
per breakpoint.
|
|
183
|
-
- **
|
|
184
|
-
|
|
191
|
+
- **Agents** — the round **Turbo** button is lit while an agent session listens (`/notemend:turbo`)
|
|
192
|
+
and pauses or resumes it; **Push to Claude** sends the threads marked for the agent in one
|
|
193
|
+
batch (right click picks which). A pin shows the agent at work the moment it takes a thread.
|
|
194
|
+
- **Spaces** — a linked project keeps the studio's workspace and the clients' space apart (`M`
|
|
195
|
+
switches); archived threads stay out of the way until shown (`A`).
|
|
196
|
+
- **Voice and translation** — record a reply, or translate anyone's message into your
|
|
197
|
+
language; both need a linked project or `notemend login`. Messages take emoji reactions.
|
|
198
|
+
- **Keys** — one key per tool, Figma-style: `C` comments, `⇧C` panel, `/` search threads, `R` resolved, `A` archived, `M` spaces,
|
|
199
|
+
`F` pin filter, `G` grid, `P`/`S`/`T`/`O`/`K`/`V`/`B` inspectors, `E` Sanity, `1`–`9` breakpoints, `D` devices, `[` `]` pages, `\` hide
|
|
185
200
|
the bar, `?` the list (also behind the keyboard button). Physical keys, so any layout works;
|
|
186
201
|
never while you type; inside the canvas too.
|
|
187
202
|
- **Breakpoints** — the page in a canvas at a band's width; drag either edge inside the
|
|
@@ -200,23 +215,29 @@ Review a site the way you review a design file:
|
|
|
200
215
|
|
|
201
216
|
| Control | |
|
|
202
217
|
|---|---|
|
|
203
|
-
| **Pages** | jump to any page. Chips show comment counts, one per breakpoint and status, in the
|
|
218
|
+
| **Pages** | jump to any page. Chips show comment counts, one per breakpoint and status, in the five status colours: new, in progress, to check (an agent's fix waiting for a look), waiting, and resolved while resolved threads are shown |
|
|
204
219
|
| **Grid** | the layout grid overlay |
|
|
205
220
|
| **Spacing / Size / Type / Colour / Border** | inspectors, one at a time. Hold **Alt** to measure the parent |
|
|
221
|
+
| **Contrast** | point at text: its colours, the ratio, WCAG's checks, the nearest colour that passes |
|
|
222
|
+
| **Vision** | a snapshot of the window drawn six ways; a click puts that filter on the page until **Esc** |
|
|
206
223
|
| **Sanity** | hides Sanity's visual-editing overlay (only with `sanity: true`) |
|
|
207
224
|
| **Comment** | comment mode: click anything to pin a note. The badge counts open threads |
|
|
208
|
-
| **
|
|
209
|
-
| **
|
|
225
|
+
| **Pin filter** | the funnel after the spaces pill: only nobody's, yours, everyone else's, your Claude's, yours to check or the resolved pins; the rest dim |
|
|
226
|
+
| **Panel** | the list of this page's threads at this breakpoint; *Show resolved* and *Show archived* at its foot bring those back, on the page and in the menu |
|
|
210
227
|
| **Breakpoints** | open the canvas at a band. The widest band is your own window |
|
|
211
228
|
| **Device** | *Preview*: a real screen with its browser. *DevTools*: the canvas at a device's size. Comments work in both |
|
|
212
|
-
| **
|
|
229
|
+
| **Turbo** | lit while an agent listens; a click pauses or resumes it |
|
|
230
|
+
| **Push to Claude** | sends the threads marked for the agent; right click picks which |
|
|
231
|
+
| **Settings** (the gear) | who you are signed in as, Grid, Customize the bar, Keyboard shortcuts, Hide the bar and, with bar.js, Sign out |
|
|
232
|
+
| **Tab** on the window's bottom edge | hides the bar and brings it back |
|
|
213
233
|
|
|
214
234
|
Keys: **Esc** closes a menu, then the note you are writing, then the open thread, then
|
|
215
235
|
comment mode. **Enter** sends, **Shift+Enter** is a new line. Double-click a canvas
|
|
216
236
|
handle to snap to the band's edge.
|
|
217
237
|
|
|
218
|
-
Everything the bar remembers (modes, canvas width, a half-typed comment
|
|
219
|
-
`localStorage`, per browser
|
|
238
|
+
Everything the bar remembers (modes, canvas width, a half-typed comment, the last threads it
|
|
239
|
+
saw) is in `localStorage`, per browser; what lasts one visit (a review round, the last push)
|
|
240
|
+
in `sessionStorage`.
|
|
220
241
|
|
|
221
242
|
## The bar in your dev server
|
|
222
243
|
|
|
@@ -351,6 +372,10 @@ export default defineConfig({ integrations: [...(notemend ? [notemend()] : [])]
|
|
|
351
372
|
endpoints under `/__devbar/` from Vite middleware. Under `astro build` it does nothing.
|
|
352
373
|
Under Next the same endpoints are a route handler, and the script waits for React to
|
|
353
374
|
hydrate `<html>` before it touches it — an attribute set earlier is a hydration error.
|
|
375
|
+
- Each open bar keeps `/__devbar/events` open (server-sent events, local addresses only, only
|
|
376
|
+
while the tab is in view): when the store moves — a write from this bar, the CLI, an agent,
|
|
377
|
+
a teammate in a linked project — every tab reads it again and redraws only what changed.
|
|
378
|
+
Under Astro the bar's first two reads start from the page's `<head>`.
|
|
354
379
|
- A client-side navigation (Next's `<Link>`, anything built on `pushState`) keeps the bar
|
|
355
380
|
and moves it to the new page: its threads, its drafts, its row in the menu.
|
|
356
381
|
- The canvas is the same page in an iframe. The bar runs in both copies; the one inside
|
|
@@ -376,13 +401,16 @@ src/integration.mjs the Astro integration
|
|
|
376
401
|
src/next.mjs the Next.js route handler (notemend/next)
|
|
377
402
|
src/server/middleware.mjs /__devbar/* endpoints, notemend.config.mjs loading
|
|
378
403
|
src/hosted.ts bar.js: the bar as one script for any site, signed in through the cabinet
|
|
404
|
+
src/hosted-app.ts bar.app.js: the bar itself, fetched by bar.js once someone is signed in
|
|
379
405
|
src/hosting.mjs the same endpoints as the cabinet serves them to bar.js (notemend/hosting)
|
|
380
406
|
src/store/ comments.json store, tags, statuses, thread helpers — shared by CLI, server, browser
|
|
381
407
|
src/store/cloud.mjs the store in the cabinet's database, the CLI's session, `notemend login`
|
|
382
408
|
src/presets.mjs the preview shelf, default breakpoints, switcher icons
|
|
383
|
-
src/client/ the bar: markup.ts builds the DOM, run.ts is the behaviour,
|
|
409
|
+
src/client/ the bar: markup.ts builds the DOM, run.ts is the behaviour, morph.ts the redraw
|
|
410
|
+
that keeps unchanged pins and cards, notemend.css
|
|
384
411
|
src/client/devices.ts the preview devices: bodies as SVG, status bars and browsers as HTML
|
|
385
412
|
bin/notemend.mjs the CLI; bin/init.mjs is `notemend init`; bin/mcp.mjs the MCP server over it
|
|
413
|
+
bin/step.mjs the PostToolUse hook (`notemend step`) that tells the bar what the agent is doing
|
|
386
414
|
tools/ pack.mjs (the minified package for npm), mcpb.mjs (the Claude Desktop bundle),
|
|
387
415
|
sync-devtools-devices.mjs (Chrome's device list)
|
|
388
416
|
```
|
package/bin/init.mjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import{existsSync as m,readFileSync as x,writeFileSync as $,readdirSync as K,mkdirSync as v,appendFileSync as I}from"node:fs";import{join as d,relative as
|
|
2
|
-
`))if(i.includes("@media")){for(const n of i.matchAll(/(min|max)-width\s*:\s*([\d.]+)(px|r?em)/g)){const c=t(n[2],n[3]);a(n[1]==="max"?Math.floor(c)+1:c)}for(const n of i.matchAll(/width\s*([<>]=?)\s*([\d.]+)(px|r?em)/g)){const c=t(n[2],n[3]);a(n[1]==="<="||n[1]===">"?Math.floor(c)+1:c)}}}return[...s].filter(([,o])=>o>1).sort((o,i)=>i[1]-o[1]).slice(0,4).map(([o])=>o).sort((o,i)=>i-o)}const X={2:["desktop","mobile"],3:["desktop","tablet","mobile"],4:["desktop","tablet","landscape","portrait"],5:["desktop","laptop","tablet","landscape","portrait"]},Z={desktop:"Desktop",laptop:"Laptop",tablet:"Tablet",landscape:"Mobile landscape",portrait:"Mobile portrait",mobile:"Mobile"},ee={desktop:1440,laptop:1280,tablet:834,landscape:667,portrait:390,mobile:390};function te(e){const s=[...new Set(e)].sort((t,r)=>r-t).slice(0,4);return(X[s.length+1]??["desktop"]).map((t,r)=>{const o=s[r]??0,i=r===0?1/0:s[r-1]-1;return{id:t,label:Z[t],min:o,max:i,ideal:Math.min(Math.max(ee[t],o),i)}})}function ne(e){const s=d(e,"src","pages"),a=[];for(const t of C(s)){const r=
|
|
1
|
+
import{existsSync as m,readFileSync as x,writeFileSync as $,readdirSync as K,mkdirSync as v,appendFileSync as I}from"node:fs";import{join as d,relative as N,extname as U,dirname as A}from"node:path";import{createInterface as H}from"node:readline/promises";import{titleOf as Y,titled as j,scanApp as V}from"../src/server/middleware.mjs";const z=new Set(["node_modules","dist",".astro",".next",".git",".vercel",".netlify","public"]);function*C(e){let s=[];try{s=K(e,{withFileTypes:!0})}catch{return}for(const a of s)a.isDirectory()?z.has(a.name)||(yield*C(d(e,a.name))):yield d(e,a.name)}function Q(e){const s=new Map,a=o=>{const i=Math.round(o);i>=320&&i<=2560&&s.set(i,(s.get(i)||0)+1)},t=(o,i)=>Number(o)*(i==="px"?1:16),r=["src","app","components","styles"].flatMap(o=>[...C(d(e,o))]);for(const o of r)if(/\.(css|scss|sass|less|astro|svelte|vue|jsx|tsx)$/.test(o)){for(const i of x(o,"utf8").split(`
|
|
2
|
+
`))if(i.includes("@media")){for(const n of i.matchAll(/(min|max)-width\s*:\s*([\d.]+)(px|r?em)/g)){const c=t(n[2],n[3]);a(n[1]==="max"?Math.floor(c)+1:c)}for(const n of i.matchAll(/width\s*([<>]=?)\s*([\d.]+)(px|r?em)/g)){const c=t(n[2],n[3]);a(n[1]==="<="||n[1]===">"?Math.floor(c)+1:c)}}}return[...s].filter(([,o])=>o>1).sort((o,i)=>i[1]-o[1]).slice(0,4).map(([o])=>o).sort((o,i)=>i-o)}const X={2:["desktop","mobile"],3:["desktop","tablet","mobile"],4:["desktop","tablet","landscape","portrait"],5:["desktop","laptop","tablet","landscape","portrait"]},Z={desktop:"Desktop",laptop:"Laptop",tablet:"Tablet",landscape:"Mobile landscape",portrait:"Mobile portrait",mobile:"Mobile"},ee={desktop:1440,laptop:1280,tablet:834,landscape:667,portrait:390,mobile:390};function te(e){const s=[...new Set(e)].sort((t,r)=>r-t).slice(0,4);return(X[s.length+1]??["desktop"]).map((t,r)=>{const o=s[r]??0,i=r===0?1/0:s[r-1]-1;return{id:t,label:Z[t],min:o,max:i,ideal:Math.min(Math.max(ee[t],o),i)}})}function ne(e){const s=d(e,"src","pages"),a=[];for(const t of C(s)){const r=N(s,t).replace(/\\/g,"/");!/\.(astro|md|mdx|html)$/.test(r)||r.split("/").some(o=>o.startsWith("_"))||a.push({route:("/"+r.slice(0,-U(r).length)).replace(/\/index$/,"")||"/",file:t})}return a}function se(e,s="astro"){const a=s==="next"?V(e).map(n=>({route:n.pattern,file:n.entrypoint})):ne(e),t=[],r=[];for(const{route:n,file:c}of a)n.includes("[")?r.push({route:n,file:N(e,c).replace(/\\/g,"/")}):/^\/(404|500)$/.test(n)||t.push({route:n,name:Y(e,c)??j(n.split("/").pop()||"home")});const o={};for(const{route:n}of t){const c=n.split("/")[1];c&&(o[c]=(o[c]||0)+1)}for(const n of t){const c=n.route.split("/")[1];n.group=c&&o[c]>1?j(c):"Pages"}const i=n=>n==="Pages"?"":n;return t.sort((n,c)=>i(n.group).localeCompare(i(c.group))||n.route.localeCompare(c.route)),{pages:t,dynamic:r}}const w=e=>`'${String(e).replace(/\\/g,"\\\\").replace(/'/g,"\\'")}'`;function oe({bands:e,pages:s,dynamic:a,grid:t,sanity:r}){const o=n=>` { id: ${w(n.id)}, label: ${w(n.label)}, min: ${n.min}, max: ${Number.isFinite(n.max)?n.max:"Infinity"}, ideal: ${n.ideal} },`,i=["// Notemend \u2014 the dev bar. Re-read on every page load: edit and refresh, no restart.","// Every export is optional; delete one to fall back to the default.","","// Where the layout switches, widest first. The widest band is your own window; the","// others open as a canvas at `ideal` and can be dragged anywhere inside the band.","export const breakpoints = [",...e.map(o),"];","","// The pages menu: route \u2192 [name, group]. A page left out still shows up, named by","// its <title> and grouped by folder. A number in front of a name only orders the",'// rows inside a group ("1.2. About") \u2014 the menu does not show it.',"export const pages = {",...s.map(n=>` ${w(n.route)}: [${w(n.name)}, ${w(n.group)}],`)];if(a.length){i.push(""," // Dynamic routes cannot be listed for you \u2014 name the addresses they serve:");for(const n of a){const c=n.route.replace(/\[\.{3}[^\]]+\]|\[[^\]]+\]/g,"example"),u=n.route.split("/")[1];i.push(` // ${w(c)}: [${w(j(u||"page"))}, ${w(u?j(u):"Pages")}], // ${n.file}`)}}return i.push("};",""),i.push("// The layout grid overlay borrows these classes from your own CSS."),i.push(`export const grid = { container: ${w(t.container)}, grid: ${w(t.grid)}, columns: ${t.columns} };`),r&&i.push("","// Adds a toggle that hides Sanity's visual-editing overlay.","export const sanity = true;"),i.join(`
|
|
3
3
|
`)+`
|
|
4
|
-
`}const
|
|
5
|
-
`)),t}const
|
|
6
|
-
`)};function ce(e,s){const a=d(e,{codex:".codex/hooks.json",gemini:".gemini/settings.json",cursor:".cursor/hooks.json"}[s]),t=ae(a);if(!t)return console.warn(`[notemend] ${a} is not valid JSON \u2014 left alone.`),0;if(JSON.stringify(t.hooks??{}).includes("notemend"))return 0;const r=o=>({type:"command",command:
|
|
4
|
+
`}const M=e=>{const s=`$CLAUDE_PROJECT_DIR/node_modules/notemend/bin/${e==="step"?"step":"notemend"}.mjs`;return`if [ -f "${s}" ]; then node "${s}" --root "$CLAUDE_PROJECT_DIR"${e==="step"?"":` ${e}`}; fi`};function ie(e){const s=d(e,".claude","settings.json");let a={};try{a=m(s)?JSON.parse(x(s,"utf8")):{}}catch{return console.warn(`[notemend] ${s} is not valid JSON \u2014 the Claude Code hooks were not added. Fix it and run npx notemend init again.`),0}a.hooks??={};let t=0;for(const[r,o]of[["SessionStart","digest"],["UserPromptSubmit","count"],["PostToolUse","step"]]){const i=a.hooks[r]??=[];for(const n of i.flatMap(c=>c.hooks??[]))typeof n.command=="string"&&n.command.startsWith("[ -f")&&n.command.includes("notemend")&&(n.command=M(o),t++);JSON.stringify(i).includes("notemend")||(i.push({hooks:[{type:"command",command:M(o)}]}),t++)}return t&&(v(A(s),{recursive:!0}),$(s,JSON.stringify(a,null,2)+`
|
|
5
|
+
`)),t}const R=(e,s)=>`D="\${CLAUDE_PROJECT_DIR:-\${GEMINI_PROJECT_DIR:-\${CURSOR_PROJECT_DIR:-$PWD}}}"; if [ -f "$D/node_modules/notemend/bin/notemend.mjs" ]; then node "$D/node_modules/notemend/bin/notemend.mjs" --root "$D" ${s} --format ${e}; fi`,ae=e=>{try{return m(e)?JSON.parse(x(e,"utf8")):{}}catch{return null}},re=(e,s)=>{v(A(e),{recursive:!0}),$(e,JSON.stringify(s,null,2)+`
|
|
6
|
+
`)};function ce(e,s){const a=d(e,{codex:".codex/hooks.json",gemini:".gemini/settings.json",cursor:".cursor/hooks.json"}[s]),t=ae(a);if(!t)return console.warn(`[notemend] ${a} is not valid JSON \u2014 left alone.`),0;if(JSON.stringify(t.hooks??{}).includes("notemend"))return 0;const r=o=>({type:"command",command:R(s,o)});if(t.hooks??={},s==="cursor"?(t.version??=1,(t.hooks.sessionStart??=[]).push({command:R("cursor","digest")})):((t.hooks.SessionStart??=[]).push({hooks:[r("digest")]}),(t.hooks[s==="gemini"?"BeforeAgent":"UserPromptSubmit"]??=[]).push({hooks:[r("count")]})),re(a,t),s==="codex"){const o=d(e,".codex","config.toml"),i=m(o)?x(o,"utf8"):"";/codex_hooks\s*=/.test(i)||I(o,`${i&&!i.endsWith(`
|
|
7
7
|
`)?`
|
|
8
8
|
`:""}
|
|
9
9
|
[features]
|
|
@@ -45,26 +45,26 @@ jobs:
|
|
|
45
45
|
and close it with \`npx notemend done <id> "what you changed"\`.
|
|
46
46
|
Commit the changes on a new branch and open a pull request that lists the threads.
|
|
47
47
|
claude_args: --allowedTools "Bash(npx notemend:*),Bash(git:*),Bash(gh pr create:*),Read,Edit,Write,Glob,Grep"
|
|
48
|
-
`;function ye(e){const s=d(e,".github","workflows","notemend.yml");return m(s)?0:(v(
|
|
48
|
+
`;function ye(e){const s=d(e,".github","workflows","notemend.yml");return m(s)?0:(v(A(s),{recursive:!0}),$(s,le),1)}const ue=["feedback/images/","feedback/archive/images/"];function pe(e,s=!1){const a=["astro.config.mjs","astro.config.ts","astro.config.js","astro.config.mts"].map(u=>d(e,u)).find(m);if(!a)return{status:"missing"};let t=x(a,"utf8");if(/['"]notemend['"]/.test(t))return{status:"present",file:a};const r=u=>t.split(u).length-1,o=s?"...(notemend ? [notemend()] : [])":"notemend()",i=s?"const notemend = await import('notemend').then((m) => m.default).catch(() => null);":"import notemend from 'notemend';";if(t.includes("integrations: []"))t=t.replace("integrations: []",`integrations: [${o}]`);else if(r("integrations: [")===1)t=t.replace("integrations: [",`integrations: [${o}, `);else if(!t.includes("integrations")&&r("defineConfig({")===1)t=t.replace("defineConfig({",`defineConfig({
|
|
49
49
|
integrations: [${o}],`);else return{status:"manual",file:a};const n=[...t.matchAll(/^import\s[\s\S]*?['"][^'"\n]+['"][ \t]*;?[ \t]*$/gm)],c=n.length?n.at(-1).index+n.at(-1)[0].length:0;return t=`${t.slice(0,c)}${c?`
|
|
50
50
|
`:""}${i}${c?"":`
|
|
51
51
|
`}${t.slice(c)}`,$(a,t),{status:"added",file:a}}function me(e){const s=["src/app","app"].find(p=>m(d(e,p)));if(!s)return{written:[],manual:["no app/ folder \u2014 notemend supports Next's App Router"]};const a=s==="src/app"?"src/":"",t=m(d(e,"tsconfig.json"))?"ts":"js",r=[],o=[],i=`if (process.env.NODE_ENV === 'development') import('notemend/client');
|
|
52
52
|
`,n=["ts","js","mjs","tsx","jsx"].map(p=>`${a}instrumentation-client.${p}`).find(p=>m(d(e,p)));if(!n)$(d(e,`${a}instrumentation-client.${t}`),i),r.push(`${a}instrumentation-client.${t}`);else if(!x(d(e,n),"utf8").includes("notemend")){const p=x(d(e,n),"utf8");$(d(e,n),`${p}${p&&!p.endsWith(`
|
|
53
53
|
`)?`
|
|
54
|
-
`:""}${i}`),r.push(`${n} (loads the bar)`)}const c=d(e,s,"%5F%5Fdevbar","[...path]");["ts","js"].some(p=>m(d(c,`route.${p}`)))||(v(c,{recursive:!0}),$(d(c,`route.${t}`),"// notemend's dev endpoints at /__devbar/ \u2014 answers 404 outside `next dev`.\nexport { GET, POST, PATCH, DELETE } from 'notemend/next';\n"),r.push(`${s}/%5F%5Fdevbar/[...path]/route.${t}`));const u=["next.config.ts","next.config.mjs","next.config.js","next.config.mts","next.config.cjs"].find(p=>m(d(e,p))),
|
|
54
|
+
`:""}${i}`),r.push(`${n} (loads the bar)`)}const c=d(e,s,"%5F%5Fdevbar","[...path]");["ts","js"].some(p=>m(d(c,`route.${p}`)))||(v(c,{recursive:!0}),$(d(c,`route.${t}`),"// notemend's dev endpoints at /__devbar/ \u2014 answers 404 outside `next dev`.\nexport { GET, POST, PATCH, DELETE } from 'notemend/next';\n"),r.push(`${s}/%5F%5Fdevbar/[...path]/route.${t}`));const u=["next.config.ts","next.config.mjs","next.config.js","next.config.mts","next.config.cjs"].find(p=>m(d(e,p))),b=u?x(d(e,u),"utf8"):null;let f=b;const h=/(const\s+nextConfig\b[^=]*=\s*\{|module\.exports\s*=\s*\{|export\s+default\s+\{)/;return f===null?($(d(e,`next.config.${t==="ts"?"ts":"mjs"}`),`export default { transpilePackages: ['notemend'] };
|
|
55
55
|
`),r.push(`next.config.${t==="ts"?"ts":"mjs"}`)):/['"]notemend['"]/.test(f)||(f.split("transpilePackages: [").length===2?f=f.replace("transpilePackages: [","transpilePackages: ['notemend', "):!f.includes("transpilePackages")&&f.split(h).length===3?f=f.replace(h,`$1
|
|
56
|
-
transpilePackages: ['notemend'],`):o.push(`add to ${u}: transpilePackages: ['notemend'],`)),u&&f!==
|
|
57
|
-
Stopped.`),process.exit(130)}return
|
|
56
|
+
transpilePackages: ['notemend'],`):o.push(`add to ${u}: transpilePackages: ['notemend'],`)),u&&f!==b&&($(d(e,u),f),r.push(`${u} (transpilePackages)`)),{written:r,manual:o}}async function we(e,s){const a=s.includes("--yes")||s.includes("-y")||!process.stdin.isTTY,t=s.includes("--force"),r=d(e,"package.json"),o=m(r)?JSON.parse(x(r,"utf8")):{},i={...o.dependencies,...o.devDependencies,...o.optionalDependencies},n=i.astro?"astro":i.next?"next":null;n||(console.error(`Neither astro nor next in ${N(process.cwd(),r)||"package.json"} \u2014 notemend is a dev bar for Astro and Next.js.`),process.exit(1));const c=a?null:H({input:process.stdin,output:process.stdout}),u=async(l,g)=>{if(!c)return g;let k="";try{k=(await c.question(`${l} [${g}] `)).trim()}catch{console.log(`
|
|
57
|
+
Stopped.`),process.exit(130)}return k||g},b=async l=>!/^n/i.test(await u(l,"Y"));console.log(`Setting up notemend in ${e}
|
|
58
58
|
`);const f=d(e,"notemend.config.mjs"),h=[];if(m(f)&&!t)console.log(`notemend.config.mjs is already here \u2014 leaving it alone (--force to start over).
|
|
59
|
-
`);else{let l=Q(e),g="your CSS";!l.length&&i.tailwindcss&&(l=[1024,768,640],g="Tailwind's lg / md / sm"),l.length||(l=[992,768,480],g="the defaults");const S=((await u(`Breakpoints \u2014 the widths where your layout switches, from ${g}:`,l.join(" "))).match(/\d+/g)||[]).map(Number).filter(y=>y>=200&&y<=4e3),O=te(S.length?S:l);for(const y of O)console.log(` ${y.label.padEnd(17)} ${y.min}\u2013${Number.isFinite(y.max)?y.max:"\u221E"}, opens at ${y.ideal}`);const{pages:
|
|
60
|
-
Pages: ${
|
|
61
|
-
Grid overlay \u2014 container class, grid class, columns:`,"container grid 12"),[W="container",
|
|
62
|
-
Which coding agents should see open comments? (claude, codex, gemini, cursor)`,F.join(","))).toLowerCase().split(/[\s,]+/).filter(l=>["claude","codex","gemini","cursor"].includes(l));
|
|
63
|
-
`).includes(S));
|
|
59
|
+
`);else{let l=Q(e),g="your CSS";!l.length&&i.tailwindcss&&(l=[1024,768,640],g="Tailwind's lg / md / sm"),l.length||(l=[992,768,480],g="the defaults");const S=((await u(`Breakpoints \u2014 the widths where your layout switches, from ${g}:`,l.join(" "))).match(/\d+/g)||[]).map(Number).filter(y=>y>=200&&y<=4e3),O=te(S.length?S:l);for(const y of O)console.log(` ${y.label.padEnd(17)} ${y.min}\u2013${Number.isFinite(y.max)?y.max:"\u221E"}, opens at ${y.ideal}`);const{pages:P,dynamic:_}=se(e,n);console.log(`
|
|
60
|
+
Pages: ${P.length} found in ${n==="next"?"app/":"src/pages"}${_.length?`, ${_.length} dynamic (listed as examples to fill in)`:""}.`);const D=[...new Set(P.map(y=>y.group))];D.length>1&&console.log(` grouped by folder: ${D.join(", ")}`);const G=await u(`
|
|
61
|
+
Grid overlay \u2014 container class, grid class, columns:`,"container grid 12"),[W="container",q="grid",L="12"]=G.split(/[\s,]+/),B=!!(i["@sanity/astro"]||i["next-sanity"]||i.sanity);$(f,oe({bands:O,pages:P,dynamic:_,grid:{container:W,grid:q,columns:Number(L)||12},sanity:B})),h.push("notemend.config.mjs")}const p=n==="astro"?pe(e,!!o.optionalDependencies?.notemend):{};p.status==="added"&&h.push(`${N(e,p.file)} (added notemend())`);const T=n==="next"?me(e):{written:[],manual:[]};h.push(...T.written);const F=["claude","codex","gemini","cursor"].filter(l=>l==="claude"||m(d(e,`.${l}`))),E=(s.find(l=>l.startsWith("--agents="))?.slice(9)??await u(`
|
|
62
|
+
Which coding agents should see open comments? (claude, codex, gemini, cursor)`,F.join(","))).toLowerCase().split(/[\s,]+/).filter(l=>["claude","codex","gemini","cursor"].includes(l));E.includes("claude")&&ie(e)&&h.push(".claude/settings.json (hooks)");for(const l of E.filter(g=>g!=="claude"))ce(e,l)&&h.push({codex:".codex/hooks.json",gemini:".gemini/settings.json",cursor:".cursor/hooks.json"}[l]+" (hooks)");if(J(e)&&h.push("AGENTS.md (how to answer comments)"),E.includes("gemini")&&J(e,"GEMINI.md")&&h.push("GEMINI.md"),await b("Keep pasted screenshots out of git?")){const l=d(e,".gitignore"),g=m(l)?x(l,"utf8"):"",k=ue.filter(S=>!g.split(`
|
|
63
|
+
`).includes(S));k.length&&(I(l,`${g&&!g.endsWith(`
|
|
64
64
|
`)?`
|
|
65
65
|
`:""}
|
|
66
66
|
# notemend: pasted screenshots
|
|
67
|
-
${
|
|
67
|
+
${k.join(`
|
|
68
68
|
`)}
|
|
69
69
|
`),h.push(".gitignore"))}c?.close(),console.log(h.length?`
|
|
70
70
|
Wrote: ${h.join(", ")}.`:`
|