notemend 0.1.27 → 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.
@@ -13,5 +13,5 @@
13
13
  "design-review",
14
14
  "mcp"
15
15
  ],
16
- "version": "0.1.27"
16
+ "version": "0.1.28"
17
17
  }
package/README.md CHANGED
@@ -178,7 +178,12 @@ Review a site the way you review a design file:
178
178
  Figma states them), its fill and text colour, or its border per side and radius per
179
179
  corner — each colour by the CSS variable it was written with. Values are *design* px:
180
180
  actual px ÷ the root font scale.
181
- - **Comments** — Figma-style pins: threads, six types (General, Bug, Text, Motion, Design, Content), screenshots (paste, drop or pick)
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)
182
187
  that go with the message they were sent with, your own messages editable, a half-written
183
188
  comment parked as a draft — a pencil pin on the page and a row in the panel — when you
184
189
  close it or click somewhere else; drafts never block a new comment. Filed per page and
@@ -190,8 +195,8 @@ Review a site the way you review a design file:
190
195
  switches); archived threads stay out of the way until shown (`A`).
191
196
  - **Voice and translation** — record a reply, or translate anyone's message into your
192
197
  language; both need a linked project or `notemend login`. Messages take emoji reactions.
193
- - **Keys** — one key per tool, Figma-style: `C` comments, `⇧C` panel, `R` resolved, `A` archived, `M` spaces, `F` pin filter, `G` grid,
194
- `P`/`S`/`T`/`O`/`B` inspectors, `E` Sanity, `1`–`9` breakpoints, `D` devices, `[` `]` pages, `\` hide
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
195
200
  the bar, `?` the list (also behind the keyboard button). Physical keys, so any layout works;
196
201
  never while you type; inside the canvas too.
197
202
  - **Breakpoints** — the page in a canvas at a band's width; drag either edge inside the
@@ -213,15 +218,18 @@ Review a site the way you review a design file:
213
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 |
214
219
  | **Grid** | the layout grid overlay |
215
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** |
216
223
  | **Sanity** | hides Sanity's visual-editing overlay (only with `sanity: true`) |
217
224
  | **Comment** | comment mode: click anything to pin a note. The badge counts open threads |
218
- | **Panel** | the list of this page's threads at this breakpoint |
219
- | **Resolved** | shows or hides resolved threads, on the page and in the menu |
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 |
220
227
  | **Breakpoints** | open the canvas at a band. The widest band is your own window |
221
228
  | **Device** | *Preview*: a real screen with its browser. *DevTools*: the canvas at a device's size. Comments work in both |
222
229
  | **Turbo** | lit while an agent listens; a click pauses or resumes it |
223
230
  | **Push to Claude** | sends the threads marked for the agent; right click picks which |
224
- | **Tab** on top of the bar | folds the bar below the window edge and back |
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 |
225
233
 
226
234
  Keys: **Esc** closes a menu, then the note you are writing, then the open thread, then
227
235
  comment mode. **Enter** sends, **Shift+Enter** is a new line. Double-click a canvas
@@ -393,6 +401,7 @@ src/integration.mjs the Astro integration
393
401
  src/next.mjs the Next.js route handler (notemend/next)
394
402
  src/server/middleware.mjs /__devbar/* endpoints, notemend.config.mjs loading
395
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
396
405
  src/hosting.mjs the same endpoints as the cabinet serves them to bar.js (notemend/hosting)
397
406
  src/store/ comments.json store, tags, statuses, thread helpers — shared by CLI, server, browser
398
407
  src/store/cloud.mjs the store in the cabinet's database, the CLI's session, `notemend login`
@@ -401,6 +410,7 @@ src/client/ the bar: markup.ts builds the DOM, run.ts is the behav
401
410
  that keeps unchanged pins and cards, notemend.css
402
411
  src/client/devices.ts the preview devices: bodies as SVG, status bars and browsers as HTML
403
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
404
414
  tools/ pack.mjs (the minified package for npm), mcpb.mjs (the Claude Desktop bundle),
405
415
  sync-devtools-devices.mjs (Chrome's device list)
406
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 E,extname as U,dirname as P}from"node:path";import{createInterface as H}from"node:readline/promises";import{titleOf as Y,titled as N,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=E(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:E(e,c).replace(/\\/g,"/")}):/^\/(404|500)$/.test(n)||t.push({route:n,name:Y(e,c)??N(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?N(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(N(u||"page"))}, ${w(u?N(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(`
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 R=e=>`if [ -f "$CLAUDE_PROJECT_DIR/node_modules/notemend/bin/notemend.mjs" ]; then node "$CLAUDE_PROJECT_DIR/node_modules/notemend/bin/notemend.mjs" --root "$CLAUDE_PROJECT_DIR" ${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"]]){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=R(o),t++);JSON.stringify(i).includes("notemend")||(i.push({hooks:[{type:"command",command:R(o)}]}),t++)}return t&&(v(P(s),{recursive:!0}),$(s,JSON.stringify(a,null,2)+`
5
- `)),t}const M=(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(P(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:M(s,o)});if(t.hooks??={},s==="cursor"?(t.version??=1,(t.hooks.sessionStart??=[]).push({command:M("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(`
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(P(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({
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))),k=u?x(d(e,u),"utf8"):null;let f=k;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'] };
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!==k&&($(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 ${E(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 b="";try{b=(await c.question(`${l} [${g}] `)).trim()}catch{console.log(`
57
- Stopped.`),process.exit(130)}return b||g},k=async l=>!/^n/i.test(await u(l,"Y"));console.log(`Setting up notemend in ${e}
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:_,dynamic:A}=se(e,n);console.log(`
60
- Pages: ${_.length} found in ${n==="next"?"app/":"src/pages"}${A.length?`, ${A.length} dynamic (listed as examples to fill in)`:""}.`);const D=[...new Set(_.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",L="grid",q="12"]=G.split(/[\s,]+/),B=!!(i["@sanity/astro"]||i["next-sanity"]||i.sanity);$(f,oe({bands:O,pages:_,dynamic:A,grid:{container:W,grid:L,columns:Number(q)||12},sanity:B})),h.push("notemend.config.mjs")}const p=n==="astro"?pe(e,!!o.optionalDependencies?.notemend):{};p.status==="added"&&h.push(`${E(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}`))),j=(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));j.includes("claude")&&ie(e)&&h.push(".claude/settings.json (hooks)");for(const l of j.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)"),j.includes("gemini")&&J(e,"GEMINI.md")&&h.push("GEMINI.md"),await k("Keep pasted screenshots out of git?")){const l=d(e,".gitignore"),g=m(l)?x(l,"utf8"):"",b=ue.filter(S=>!g.split(`
63
- `).includes(S));b.length&&(I(l,`${g&&!g.endsWith(`
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
- ${b.join(`
67
+ ${k.join(`
68
68
  `)}
69
69
  `),h.push(".gitignore"))}c?.close(),console.log(h.length?`
70
70
  Wrote: ${h.join(", ")}.`:`