notemend 0.1.25 → 0.1.27

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.
@@ -1,3 +1,3 @@
1
- import{readFileSync as B,writeFileSync as D,existsSync as y,mkdirSync as A,renameSync as J,rmSync as z,statSync as T}from"node:fs";import{dirname as G,join as g}from"node:path";import{categoryOf as K}from"./categories.mjs";import{BLOCKED as W,DOCS as C,FRAMES as _,docSlug as q,fileExt as H,frameOf as P,toggledReaction as Q}from"./thread.mjs";import{CATEGORIES as ue,categoryOf as fe}from"./categories.mjs";import{stateOf as de,STATE_LABEL as pe}from"./status.mjs";const $=n=>{const t=String(n??"").split(/[/\\]/).pop(),e=/^[\w-][\w.-]*\.([a-z0-9]{1,8})$/i.exec(t);return e&&!W.test(e[1])?t:""},V=n=>{const t=/^data:(image|video|audio)\/(png|jpeg|webp|gif|webm|mp4)(?:;[\w=.-]+)*;base64,(.+)$/s.exec(String(n||""));if(t&&!/^data:[^,]*;ext=/.test(String(n).slice(0,300))){const[,i,s,m]=t;return(i==="image"?!/^(png|jpeg|webp|gif)$/.test(s):i==="video"?s!=="webm":!/^(webm|mp4)$/.test(s))?null:{base64:m,voice:i==="audio",ext:s==="jpeg"?"jpg":s==="mp4"?"m4a":s,type:`${i}/${s}`}}const e=/^data:([\w.+-]+\/[\w.+-]+)((?:;[\w=.-]+)*);base64,(.+)$/s.exec(String(n||""));if(!e)return null;const o=/;ext=([a-z0-9]{1,8})(?:;|$)/i.exec(e[2])?.[1],r=o?H(`x.${o}`):Object.keys(C).find(i=>C[i]===e[1]);return r?{base64:e[3],voice:!1,ext:r,type:r==="pdf"?"application/pdf":"application/octet-stream",slug:q(/;name=([\w.-]+)/.exec(e[2])?.[1])||"file"}:null},L=(n,t,e,o)=>`${e.voice?"voice-":_.includes(o)?`${o}-`:""}${n}-${t}${e.slug?`.${e.slug}`:""}.${e.ext}`,oe=async(n,t,e,o,r)=>{if(typeof o!="string")return null;const i=t.comments.find(m=>m.id===Number(e))?.images?.filter(m=>P(m)===r)??[],s=await n.attach(t,e,o,r);if(s)for(const m of i)await n.detach(t,e,m);return s},j=n=>Math.max(n.nextId||0,n.comments.reduce((t,e)=>Math.max(t,e.id),0)+1);function X(n,{route:t,selector:e,rx:o,ry:r,text:i,label:s,viewport:m,breakpoint:x,browser:N,device:v,tag:k,classes:E,nth:I,category:M,suggest:c,assignee:l,ctx:S,logs:a,host:u,priority:f,shared:d,stage:w,from:h,client:p}){const b={id:j(n),route:t,selector:e,rx:o,ry:r,text:i,tag:k||"",classes:E||[],nth:Number.isInteger(I)?I:null,label:s||"",ctx:S||"",viewport:m||null,breakpoint:x||"desktop",browser:N||"",device:v||"",category:K(M).id,status:"open",note:"",replies:[],doneBy:null,images:[],...c?{suggest:c}:{},...l?{assignee:l}:{},...f?{priority:f}:{},...w?{stage:w}:{},...d?{shared:!0}:{},...p?{client:!0}:{},...Number.isInteger(h?.id)?{from:{id:h.id}}:{},...u?{host:u}:{},...a?.length?{logs:a}:{},createdAt:new Date().toISOString(),updatedAt:null};return n.comments.push(b),n.nextId=b.id+1,b}function Y(n,t,e,o,r,i){const s=n.comments.find(m=>m.id===Number(t));return s?((s.replies||=[]).push({author:e,text:o,at:new Date().toISOString(),...r&&r!=="claude"?{agent:r}:{},...i?{by:i}:{}}),s.updatedAt=new Date().toISOString(),s):null}function Z(n,t,e,o){const r=n.comments.find(s=>s.id===Number(t)),i=e?r?.replies?.find(s=>s.at===e&&s.author==="you"):r;return i?(i.text=o,r.updatedAt=new Date().toISOString(),r):null}function U(n,t,e){const o=n.comments.find(i=>i.id===Number(t)),r=o?.replies?.find(i=>i.at===e&&i.author==="you");return r?(r.text="",r.deleted=!0,delete r.mentions,o.updatedAt=new Date().toISOString(),o):null}function ie(n,t,e,o,r){const i=n.comments.find(x=>x.id===Number(t)),s=e?i?.replies?.find(x=>x.at===e&&!x.deleted):i;if(!s)return null;const m=Q(s.reactions,o,r);return m===null?!1:(m?s.reactions=m:delete s.reactions,i)}function ee(n,t,e){const o=n.comments.find(r=>r.id===Number(t));return o?(Object.assign(o,e,{updatedAt:new Date().toISOString()}),o):null}function ce(n){const t=g(n,"feedback","comments.json"),e=g(n,"feedback","images"),o=g(n,"feedback","archive"),r=g(o,"images"),i=c=>`feedback/images/${c}`,s=new WeakMap,m=()=>{const c=y(t)?JSON.parse(B(t,"utf8")):{comments:[]};return s.set(c,v()),c},x=c=>s.get(c)??v(),N=c=>{A(G(t),{recursive:!0});const l=`${t}.${process.pid}.${Date.now()}.tmp`;D(l,JSON.stringify(c,null,2)+`
2
- `),J(l,t)},v=()=>{try{const c=T(t);return`${c.mtimeMs}-${c.size}`}catch{return"0"}};return{root:n,file:t,imageDir:e,archiveDir:o,archiveImageDir:r,load:m,version:v,versionOf:x,save:N,attach:(c,l,S,a)=>{const u=c.comments.find(h=>h.id===Number(l)),f=V(S);if(!u||!f)return null;A(e,{recursive:!0});let d=Date.now();for(;y(g(e,L(u.id,d,f,a)));)d++;const w=L(u.id,d,f,a);return D(g(e,w),Buffer.from(f.base64,"base64")),(u.images||=[]).push(i(w)),u.updatedAt=new Date().toISOString(),i(w)},detach:(c,l,S)=>{const a=c.comments.find(d=>d.id===Number(l)),u=$(S),f=u&&a?.images?.find(d=>$(d)===u);return f?(z(g(e,u),{force:!0}),a.images=a.images.filter(d=>d!==f),a.updatedAt=new Date().toISOString(),!0):!1},remove:(c,l)=>{const S=c.comments.find(a=>a.id===Number(l));if(!S)return!1;for(const a of S.images||[])$(a)&&z(g(e,$(a)),{force:!0});return c.comments=c.comments.filter(a=>a.id!==Number(l)),!0},add:X,patch:ee,reply:Y,edit:Z,unsay:U,nextId:j,prune:(c,{dry:l=!1,date:S=new Date().toISOString().slice(0,10)}={})=>{const a=c.comments.filter(p=>p.status==="done"),u=c.comments.filter(p=>p.status!=="done"),f=g(o,`comments-${S}.json`);if(l||!a.length)return{moving:a,keeping:u,archiveFile:f,images:a.flatMap(p=>p.images||[])};A(r,{recursive:!0});const d=[];for(const p of a)p.images=(p.images||[]).map(b=>{const O=$(b);if(!O)return b;const F=g(e,O),R=g(r,O);return y(F)&&J(F,R),d.push(O),`feedback/archive/images/${O}`});const w=y(f)?JSON.parse(B(f,"utf8")).comments||[]:[],h=new Set(w.map(p=>p.id));return D(f,JSON.stringify({comments:[...w,...a.filter(p=>!h.has(p.id))]},null,2)+`
3
- `),c.nextId=j(c),c.comments=u,{moving:a,keeping:u,archiveFile:f,images:d}}}}export{ue as CATEGORIES,pe as STATE_LABEL,X as add,fe as categoryOf,ce as createStore,Z as edit,oe as fileFrame,L as mediaName,V as mediaOf,j as nextId,ee as patch,ie as react,Y as reply,$ as shotName,de as stateOf,U as unsay};
1
+ import{readFileSync as B,writeFileSync as D,existsSync as y,mkdirSync as A,renameSync as J,rmSync as z,statSync as T}from"node:fs";import{dirname as G,join as g}from"node:path";import{categoryOf as K}from"./categories.mjs";import{BLOCKED as W,DOCS as C,FRAMES as _,docSlug as q,fileExt as H,frameOf as P,toggledReaction as Q}from"./thread.mjs";import{CATEGORIES as ue,categoryIcon as fe,categoryOf as le}from"./categories.mjs";import{stateOf as pe,STATE_LABEL as ge}from"./status.mjs";const $=n=>{const t=String(n??"").split(/[/\\]/).pop(),e=/^[\w-][\w.-]*\.([a-z0-9]{1,8})$/i.exec(t);return e&&!W.test(e[1])?t:""},V=n=>{const t=/^data:(image|video|audio)\/(png|jpeg|webp|gif|webm|mp4)(?:;[\w=.-]+)*;base64,(.+)$/s.exec(String(n||""));if(t&&!/^data:[^,]*;ext=/.test(String(n).slice(0,300))){const[,i,s,m]=t;return(i==="image"?!/^(png|jpeg|webp|gif)$/.test(s):i==="video"?s!=="webm":!/^(webm|mp4)$/.test(s))?null:{base64:m,voice:i==="audio",ext:s==="jpeg"?"jpg":s==="mp4"?"m4a":s,type:`${i}/${s}`}}const e=/^data:([\w.+-]+\/[\w.+-]+)((?:;[\w=.-]+)*);base64,(.+)$/s.exec(String(n||""));if(!e)return null;const o=/;ext=([a-z0-9]{1,8})(?:;|$)/i.exec(e[2])?.[1],r=o?H(`x.${o}`):Object.keys(C).find(i=>C[i]===e[1]);return r?{base64:e[3],voice:!1,ext:r,type:r==="pdf"?"application/pdf":"application/octet-stream",slug:q(/;name=([\w.-]+)/.exec(e[2])?.[1])||"file"}:null},L=(n,t,e,o)=>`${e.voice?"voice-":_.includes(o)?`${o}-`:""}${n}-${t}${e.slug?`.${e.slug}`:""}.${e.ext}`,oe=async(n,t,e,o,r)=>{if(typeof o!="string")return null;const i=t.comments.find(m=>m.id===Number(e))?.images?.filter(m=>P(m)===r)??[],s=await n.attach(t,e,o,r);if(s)for(const m of i)await n.detach(t,e,m);return s},j=n=>Math.max(n.nextId||0,n.comments.reduce((t,e)=>Math.max(t,e.id),0)+1);function X(n,{route:t,selector:e,rx:o,ry:r,text:i,label:s,viewport:m,breakpoint:x,browser:I,device:v,tag:k,classes:E,nth:N,category:M,suggest:c,assignee:l,ctx:S,logs:a,host:u,priority:f,shared:d,stage:w,from:h,client:p}){const b={id:j(n),route:t,selector:e,rx:o,ry:r,text:i,tag:k||"",classes:E||[],nth:Number.isInteger(N)?N:null,label:s||"",ctx:S||"",viewport:m||null,breakpoint:x||"desktop",browser:I||"",device:v||"",category:K(M).id,status:"open",note:"",replies:[],doneBy:null,images:[],...c?{suggest:c}:{},...l?{assignee:l}:{},...f?{priority:f}:{},...w?{stage:w}:{},...d?{shared:!0}:{},...p?{client:!0}:{},...Number.isInteger(h?.id)?{from:{id:h.id}}:{},...u?{host:u}:{},...a?.length?{logs:a}:{},createdAt:new Date().toISOString(),updatedAt:null};return n.comments.push(b),n.nextId=b.id+1,b}function Y(n,t,e,o,r,i){const s=n.comments.find(m=>m.id===Number(t));return s?((s.replies||=[]).push({author:e,text:o,at:new Date().toISOString(),...r&&r!=="claude"?{agent:r}:{},...i?{by:i}:{}}),s.updatedAt=new Date().toISOString(),s):null}function Z(n,t,e,o){const r=n.comments.find(s=>s.id===Number(t)),i=e?r?.replies?.find(s=>s.at===e&&s.author==="you"):r;return i?(i.text=o,r.updatedAt=new Date().toISOString(),r):null}function U(n,t,e){const o=n.comments.find(i=>i.id===Number(t)),r=o?.replies?.find(i=>i.at===e&&i.author==="you");return r?(r.text="",r.deleted=!0,delete r.mentions,o.updatedAt=new Date().toISOString(),o):null}function ie(n,t,e,o,r){const i=n.comments.find(x=>x.id===Number(t)),s=e?i?.replies?.find(x=>x.at===e&&!x.deleted):i;if(!s)return null;const m=Q(s.reactions,o,r);return m===null?!1:(m?s.reactions=m:delete s.reactions,i)}function ee(n,t,e){const o=n.comments.find(r=>r.id===Number(t));return o?(Object.assign(o,e,{updatedAt:new Date().toISOString()}),o):null}function ce(n){const t=g(n,"feedback","comments.json"),e=g(n,"feedback","images"),o=g(n,"feedback","archive"),r=g(o,"images"),i=c=>`feedback/images/${c}`,s=new WeakMap,m=()=>{const c=y(t)?JSON.parse(B(t,"utf8")):{comments:[]};return s.set(c,v()),c},x=c=>s.get(c)??v(),I=c=>{A(G(t),{recursive:!0});const l=`${t}.${process.pid}.${Date.now()}.tmp`;D(l,JSON.stringify(c,null,2)+`
2
+ `),J(l,t)},v=()=>{try{const c=T(t);return`${c.mtimeMs}-${c.size}`}catch{return"0"}};return{root:n,file:t,imageDir:e,archiveDir:o,archiveImageDir:r,load:m,version:v,versionOf:x,save:I,attach:(c,l,S,a)=>{const u=c.comments.find(h=>h.id===Number(l)),f=V(S);if(!u||!f)return null;A(e,{recursive:!0});let d=Date.now();for(;y(g(e,L(u.id,d,f,a)));)d++;const w=L(u.id,d,f,a);return D(g(e,w),Buffer.from(f.base64,"base64")),(u.images||=[]).push(i(w)),u.updatedAt=new Date().toISOString(),i(w)},detach:(c,l,S)=>{const a=c.comments.find(d=>d.id===Number(l)),u=$(S),f=u&&a?.images?.find(d=>$(d)===u);return f?(z(g(e,u),{force:!0}),a.images=a.images.filter(d=>d!==f),a.updatedAt=new Date().toISOString(),!0):!1},remove:(c,l)=>{const S=c.comments.find(a=>a.id===Number(l));if(!S)return!1;for(const a of S.images||[])$(a)&&z(g(e,$(a)),{force:!0});return c.comments=c.comments.filter(a=>a.id!==Number(l)),!0},add:X,patch:ee,reply:Y,edit:Z,unsay:U,nextId:j,prune:(c,{dry:l=!1,date:S=new Date().toISOString().slice(0,10)}={})=>{const a=c.comments.filter(p=>p.status==="done"),u=c.comments.filter(p=>p.status!=="done"),f=g(o,`comments-${S}.json`);if(l||!a.length)return{moving:a,keeping:u,archiveFile:f,images:a.flatMap(p=>p.images||[])};A(r,{recursive:!0});const d=[];for(const p of a)p.images=(p.images||[]).map(b=>{const O=$(b);if(!O)return b;const F=g(e,O),R=g(r,O);return y(F)&&J(F,R),d.push(O),`feedback/archive/images/${O}`});const w=y(f)?JSON.parse(B(f,"utf8")).comments||[]:[],h=new Set(w.map(p=>p.id));return D(f,JSON.stringify({comments:[...w,...a.filter(p=>!h.has(p.id))]},null,2)+`
3
+ `),c.nextId=j(c),c.comments=u,{moving:a,keeping:u,archiveFile:f,images:d}}}}export{ue as CATEGORIES,ge as STATE_LABEL,X as add,fe as categoryIcon,le as categoryOf,ce as createStore,Z as edit,oe as fileFrame,L as mediaName,V as mediaOf,j as nextId,ee as patch,ie as react,Y as reply,$ as shotName,pe as stateOf,U as unsay};
@@ -1 +1 @@
1
- const v=["before","after"],l=e=>/(?:^|\/)(before|after)-[^/]*$/.exec(String(e))?.[1]??null,$=e=>{const t={};for(const n of e?.images||[]){const o=l(n);o&&(t[o]=n)}return t},d={pdf:"application/pdf",doc:"application/msword",docx:"application/vnd.openxmlformats-officedocument.wordprocessingml.document"},m=/^(exe|msi|msp|dmg|pkg|mpkg|app|sh|bash|zsh|command|bat|cmd|com|scr|cpl|ps1|psm1|vbs|vbe|js[e]?|wsf|wsh|hta|jar|apk|ipa|deb|rpm|bin|run|reg|lnk|inf|gadget|appimage)$/i,f=/^(png|jpe?g|webp|gif|webm)$/i,x=[["PDF","#e5484d","pdf"],["DOC","#0d99ff","doc docx rtf odt pages"],["XLS","#30a46c","xls xlsx csv tsv numbers ods"],["PPT","#f76b15","ppt pptx key odp"],["ZIP","#ffb224","zip rar 7z tar gz tgz bz2"],["FIG","#7c6cf2","fig sketch psd ai xd indd eps"],["TXT","#12a594","txt md json html htm css ts tsx jsx xml yml yaml svg log"],["MP3","#d6409f","mp3 wav m4a ogg flac aac"],["MP4","#e93d82","mp4 mov avi mkv m4v"]],N=e=>{const t=String(e??"").split(".").pop().toLowerCase(),n=x.find(([,,o])=>o.split(" ").includes(t));return n?{label:n[0],color:n[1]}:{label:"FILE",color:"#717171"}},_=e=>/\.(pdf|png|jpe?g|webp|gif|mp4|mov|webm|mp3|wav|m4a)$/i.test(String(e??"").split("?")[0]),h=Object.fromEntries([..."\u0430\u0431\u0432\u0433\u0491\u0434\u0435\u0454\u0436\u0437\u0438\u0456\u0457\u0439\u043A\u043B\u043C\u043D\u043E\u043F\u0440\u0441\u0442\u0443\u0444\u0445\u0446\u0447\u0448\u0449\u044C\u044E\u044F\u044B\u044D\u0451\u044A"].map((e,t)=>[e,["a","b","v","h","g","d","e","ie","zh","z","y","i","i","i","k","l","m","n","o","p","r","s","t","u","f","kh","ts","ch","sh","shch","","iu","ia","y","e","io",""][t]])),z=e=>String(e??"").replace(/\.[^.]*$/,"").toLowerCase().replace(/[а-яёєіїґ]/g,t=>h[t]??"").normalize("NFKD").replace(/[^\w-]+/g,"-").replace(/^[-_]+|-+$/g,"").slice(0,60),P=e=>{const t=/\.([a-z0-9]{1,8})$/i.exec(String(e??""));return t&&!m.test(t[1])?t[1].toLowerCase():""},T=e=>{const t=String(e??"");if(t.startsWith("data:")){const r=/^data:([^;,]+)((?:;[^;,]*)*)[;,]/.exec(t);if(!r)return null;const s=/;ext=([a-z0-9]{1,8})/i.exec(r[2])?.[1]?.toLowerCase()??Object.keys(d).find(a=>d[a]===r[1]);return s?`${/;name=([\w-]+)/.exec(r[2])?.[1]||"document"}.${s}`:null}const n=t.split("/").pop().split("?")[0];if(/^(voice|before|after)-/.test(n))return null;const o=/-\d+(?:\.([\w-]+))?\.([a-z0-9]{1,8})$/i.exec(n);return o&&!f.test(o[2])?`${o[1]||"document"}.${o[2].toLowerCase()}`:null},w=e=>{const t=[{author:"you",text:e.text,at:e.createdAt,by:e.by,byName:e.byName,images:[],...e.reactions?{reactions:e.reactions}:{}},...e.note?[{author:"claude",text:e.note,at:e.updatedAt,images:[]}]:[],...(e.replies||[]).map(n=>({...n,images:[]}))];for(const n of e.images||[]){if(l(n))continue;const o=Number(/-(\d+)(?:\.[\w-]+)?\.\w+$/.exec(n)?.[1]);let r=0;t.forEach((s,a)=>{Date.parse(s.at)<=o&&(r=a)}),t[r].images.push(n)}return t.filter(n=>!n.deleted)},j=["\u{1F44D}","\u2764\uFE0F","\u{1F602}","\u{1F389}","\u{1F440}","\u{1F525}"],R=["\u{1F44D}","\u{1F44E}","\u{1F44F}","\u{1F64C}","\u{1F64F}","\u{1F4AA}","\u{1F44C}","\u270C\uFE0F","\u{1F91D}","\u{1F44B}","\u2764\uFE0F","\u{1F525}","\u{1F389}","\u2728","\u2B50","\u2705","\u274C","\u26A0\uFE0F","\u{1F4AF}","\u{1F680}","\u{1F600}","\u{1F602}","\u{1F60A}","\u{1F60D}","\u{1F914}","\u{1F605}","\u{1F60E}","\u{1F973}","\u{1F622}","\u{1F62E}","\u{1F648}","\u{1F92F}","\u{1F62C}","\u{1F643}","\u{1F440}","\u{1F4A1}","\u{1F4CC}","\u{1F41B}","\u{1F3A8}","\u2615"],b=/^(?:\p{Extended_Pictographic}|\p{Emoji_Modifier}|\p{Regional_Indicator}|\u200d|\ufe0f)+$/u,W=e=>typeof e!="string"||!e||e.length>16||!b.test(e)?null:[...new Intl.Segmenter().segment(e)].length===1?e:null,k=20,B=(e,t,n)=>{const o={...e||{}},r=o[t]||[];if(!r.length&&Object.keys(o).length>=k)return null;const s=r.includes(n)?r.filter(a=>a!==n):[...r,n];return s.length?o[t]=s:delete o[t],Object.keys(o).length?o:void 0},F=e=>e.nickname||e.name||e.email,c=(e,t)=>{const n="@"+t.toLowerCase();let o=-1;for(let r=e.indexOf(n);r!==-1;r=e.indexOf(n,r+1))/[\p{L}\p{N}_.-]/u.test(e[r+n.length]??"")||(o=r);return o},G=(e,t)=>{const n=String(e||"").toLowerCase();return n.includes("@")?[...new Set(t.filter(o=>[o.name,o.nickname,o.email].some(r=>r&&c(n,r)!==-1)).map(o=>o.email))]:[]},A={claude:"Claude",codex:"Codex",gemini:"Gemini",cursor:"Cursor",copilot:"Copilot",windsurf:"Windsurf",amp:"Amp",aider:"Aider",opencode:"OpenCode",agent:"AI agent"},S=e=>A[e]||(e?"AI agent":"Claude"),K="3.6 3.6 10.8 10.8",L="M10.116 9H13.883M9.966 9.558L12.222 10.86M9.558 9.966L11.441 13.228M9 10.116V12.72M8.442 9.966L6.559 13.228M8.034 9.558L5.778 10.86M7.884 9H4.118M8.034 8.442L5.778 7.14M8.442 8.034L6.559 4.772M9 7.884V5.28M9.558 8.034L11.441 4.772M9.966 8.442L12.222 7.14",i=e=>typeof e=="string"&&e.startsWith("agent:")?e.slice(6):null,p=e=>e==="claude"||i(e)!=null,M=/^[^\s@]+@[^\s@]+$/,H=e=>{if(e==="claude")return e;if(typeof e!="string"||e.length>210)return null;const t=e.toLowerCase();return M.test(i(t)??t)?t:null},O=["new","approved","progress","review","waiting"],u=e=>O.includes(e?.stage)?e.stage:e?.stage==="accepted"?"review":p(e?.assignee)?"approved":"new",C=e=>e?.client===!0||e?.shared===!0,V=(e,t)=>{const n=i(e.assignee);return!C(e)&&u(e)==="approved"&&(!e.assignee||e.assignee==="claude"||n!=null&&(t===void 0||n===t))&&!g(e)},I=()=>[{assignee:"claude",handle:"Claude",owner:null}],X=(e,t=[])=>{const n=String(e||"").toLowerCase();let o=null,r=-1;for(const s of I()){const a=c(n,s.handle);a>r&&(r=a,o=s.assignee)}return o},Y=(e,t,n=o=>o)=>S(e)+(t?` \xB7 ${n(t)}`:""),y=2*36e5,E=(e,t=Date.now())=>e?.working&&e.status!=="done"&&t-Date.parse(e.working.at)<y?e.working:null,D=e=>/@guest\.notemend\.com$/i.test(String(e||"")),g=e=>D(e.by)&&!e.approvedBy,U=(e,t=Date.now())=>{if(!e)return null;if(e.status==="done")return e.doneBy==="claude"?"review":p(e.assignee)?"done":null;if(g(e))return"held";if(!p(e.assignee))return null;const n=w(e),o=n[n.length-1];return n.length>1&&o.author==="claude"&&!(e.reopenedAt&&Date.parse(e.reopenedAt)>=Date.parse(o.at))?"asks":E(e,t)?"working":e.working?"stuck":u(e)==="approved"?"queued":null},q={held:0,queued:2,asks:6,working:6,stuck:6,review:10,done:12},J=L.split("M").filter(Boolean).map(e=>{const t=e.match(/[\d.]+/g).map(Number),[n,o]=/H/.test(e)?[t[2],t[1]]:/V/.test(e)?[t[0],t[2]]:[t[2],t[3]];return{d:"M"+e,a:(Math.atan2(n-9,9-o)+2*Math.PI)%(2*Math.PI)}}).sort((e,t)=>e.a-t.a).map(e=>e.d),Q={plugin:"Claude Code: /plugin \u2192 Installed \u2192 notemend \u2192 Update now, then /reload-plugins",npx:'run it as npx -y notemend@latest (npx keeps an old copy of plain "notemend"), then restart the agent',project:"npm i -D notemend@latest in the site, then restart the agent",desktop:"Claude Desktop: download app.notemend.com/notemend.mcpb again and open it",source:"pull the notemend repository"},Z=(e,t)=>{const n=String(e).split(".").map(Number),o=String(t).split(".").map(Number);for(let r=0;r<3;r++)if((n[r]||0)!==(o[r]||0))return(n[r]||0)>(o[r]||0);return!1},ee=(e,t)=>{if(e.archivedAt)return!0;if(!t||e.status!=="done"||e.doneBy==="claude")return!1;const n=Math.max(Date.parse(e.confirmedAt||e.updatedAt||"")||0,...(e.replies||[]).filter(o=>!o.deleted).map(o=>Date.parse(o.at||"")||0));return!!n&&Date.now()-n>t*864e5};export{A as AGENTS,K as AI_BOX,L as AI_RAYS,J as AI_RAYS_CW,m as BLOCKED,d as DOCS,R as EMOJI,x as FILE_KINDS,v as FRAMES,k as MAX_REACTIONS,j as QUICK,O as STAGES,q as STEP_RAYS,Q as UPDATE_HOW,y as WORKING_TTL,I as agentHandles,Y as agentLabel,X as agentMentioned,S as agentName,i as agentOwner,U as agentStep,ee as archivedOf,H as cleanAssignee,W as cleanEmoji,C as clientSpace,T as docOf,z as docSlug,P as fileExt,N as fileKind,V as forAgentOf,l as frameOf,$ as framesOf,F as handleOf,g as held,D as isGuest,G as mentionsIn,Z as newer,_ as opensInTab,u as stageOf,w as threadOf,p as toAgent,B as toggledReaction,E as workingOn};
1
+ const j=["before","after"],u=e=>/(?:^|\/)(before|after)-[^/]*$/.exec(String(e))?.[1]??null,z=e=>{const t={};for(const n of e?.images||[]){const o=u(n);o&&(t[o]=n)}return t},g={pdf:"application/pdf",doc:"application/msword",docx:"application/vnd.openxmlformats-officedocument.wordprocessingml.document"},w=/^(exe|msi|msp|dmg|pkg|mpkg|app|sh|bash|zsh|command|bat|cmd|com|scr|cpl|ps1|psm1|vbs|vbe|js[e]?|wsf|wsh|hta|jar|apk|ipa|deb|rpm|bin|run|reg|lnk|inf|gadget|appimage)$/i,b=/^(png|jpe?g|webp|gif|webm)$/i,k=[["PDF","#e5484d","pdf"],["DOC","#0d99ff","doc docx rtf odt pages"],["XLS","#30a46c","xls xlsx csv tsv numbers ods"],["PPT","#f76b15","ppt pptx key odp"],["ZIP","#ffb224","zip rar 7z tar gz tgz bz2"],["FIG","#7c6cf2","fig sketch psd ai xd indd eps"],["TXT","#12a594","txt md json html htm css ts tsx jsx xml yml yaml svg log"],["MP3","#d6409f","mp3 wav m4a ogg flac aac"],["MP4","#e93d82","mp4 mov avi mkv m4v"]],T=e=>{const t=String(e??"").split(".").pop().toLowerCase(),n=k.find(([,,o])=>o.split(" ").includes(t));return n?{label:n[0],color:n[1]}:{label:"FILE",color:"#717171"}},B=e=>/\.(pdf|png|jpe?g|webp|gif|mp4|mov|webm|mp3|wav|m4a)$/i.test(String(e??"").split("?")[0]),L=Object.fromEntries([..."\u0430\u0431\u0432\u0433\u0491\u0434\u0435\u0454\u0436\u0437\u0438\u0456\u0457\u0439\u043A\u043B\u043C\u043D\u043E\u043F\u0440\u0441\u0442\u0443\u0444\u0445\u0446\u0447\u0448\u0449\u044C\u044E\u044F\u044B\u044D\u0451\u044A"].map((e,t)=>[e,["a","b","v","h","g","d","e","ie","zh","z","y","i","i","i","k","l","m","n","o","p","r","s","t","u","f","kh","ts","ch","sh","shch","","iu","ia","y","e","io",""][t]])),F=e=>String(e??"").replace(/\.[^.]*$/,"").toLowerCase().replace(/[а-яёєіїґ]/g,t=>L[t]??"").normalize("NFKD").replace(/[^\w-]+/g,"-").replace(/^[-_]+|-+$/g,"").slice(0,60),W=e=>{const t=/\.([a-z0-9]{1,8})$/i.exec(String(e??""));return t&&!w.test(t[1])?t[1].toLowerCase():""},G=e=>{const t=String(e??"");if(t.startsWith("data:")){const r=/^data:([^;,]+)((?:;[^;,]*)*)[;,]/.exec(t);if(!r)return null;const s=/;ext=([a-z0-9]{1,8})/i.exec(r[2])?.[1]?.toLowerCase()??Object.keys(g).find(a=>g[a]===r[1]);return s?`${/;name=([\w-]+)/.exec(r[2])?.[1]||"document"}.${s}`:null}const n=t.split("/").pop().split("?")[0];if(/^(voice|before|after)-/.test(n))return null;const o=/-\d+(?:\.([\w-]+))?\.([a-z0-9]{1,8})$/i.exec(n);return o&&!b.test(o[2])?`${o[1]||"document"}.${o[2].toLowerCase()}`:null},S=e=>{const t=[{author:"you",text:e.text,at:e.createdAt,by:e.by,byName:e.byName,images:[],...e.reactions?{reactions:e.reactions}:{}},...e.note?[{author:"claude",text:e.note,at:e.updatedAt,images:[]}]:[],...(e.replies||[]).map(n=>({...n,images:[]}))];for(const n of e.images||[]){if(u(n))continue;const o=Number(/-(\d+)(?:\.[\w-]+)?\.\w+$/.exec(n)?.[1]);let r=0;t.forEach((s,a)=>{Date.parse(s.at)<=o&&(r=a)}),t[r].images.push(n)}return t.filter(n=>!n.deleted)},H=["\u{1F44D}","\u2764\uFE0F","\u{1F602}","\u{1F389}","\u{1F440}","\u{1F525}"],K=["\u{1F44D}","\u{1F44E}","\u{1F44F}","\u{1F64C}","\u{1F64F}","\u{1F4AA}","\u{1F44C}","\u270C\uFE0F","\u{1F91D}","\u{1F44B}","\u2764\uFE0F","\u{1F525}","\u{1F389}","\u2728","\u2B50","\u2705","\u274C","\u26A0\uFE0F","\u{1F4AF}","\u{1F680}","\u{1F600}","\u{1F602}","\u{1F60A}","\u{1F60D}","\u{1F914}","\u{1F605}","\u{1F60E}","\u{1F973}","\u{1F622}","\u{1F62E}","\u{1F648}","\u{1F92F}","\u{1F62C}","\u{1F643}","\u{1F440}","\u{1F4A1}","\u{1F4CC}","\u{1F41B}","\u{1F3A8}","\u2615"],y=/^(?:\p{Extended_Pictographic}|\p{Emoji_Modifier}|\p{Regional_Indicator}|\u200d|\ufe0f)+$/u,U=e=>typeof e!="string"||!e||e.length>16||!y.test(e)?null:[...new Intl.Segmenter().segment(e)].length===1?e:null,A=20,V=(e,t,n)=>{const o={...e||{}},r=o[t]||[];if(!r.length&&Object.keys(o).length>=A)return null;const s=r.includes(n)?r.filter(a=>a!==n):[...r,n];return s.length?o[t]=s:delete o[t],Object.keys(o).length?o:void 0},X=e=>e.nickname||e.name||e.email,m=(e,t)=>{const n="@"+t.toLowerCase();let o=-1;for(let r=e.indexOf(n);r!==-1;r=e.indexOf(n,r+1))/[\p{L}\p{N}_.-]/u.test(e[r+n.length]??"")||(o=r);return o},Y=(e,t)=>{const n=String(e||"").toLowerCase();return n.includes("@")?[...new Set(t.filter(o=>[o.name,o.nickname,o.email].some(r=>r&&m(n,r)!==-1)).map(o=>o.email))]:[]},C=/https?:\/\/[^\s<>"']+/g,f=e=>{const t=e.filter(Boolean).pop();try{return t?decodeURIComponent(t):""}catch{return t}},M=e=>{let t;try{t=new URL(e)}catch{return{label:String(e),kind:"link"}}const n=t.hostname.replace(/^www\./,""),o=t.pathname.split("/").filter(Boolean);if(/(^|\.)figma\.com$/.test(n))return{label:o[2]?`Figma \xB7 ${f([o[2]]).replace(/-/g," ")}`:"Figma",kind:"link"};if(n==="github.com"&&o.length){const[s,a,c,d]=o;return{label:`GitHub \xB7 ${a??s}${/^(pull|issues)$/.test(c??"")&&d?` #${d}`:""}`,kind:c==="pull"?"pr":"github"}}if(/(^|\.)loom\.com$/.test(n))return{label:"Loom",kind:"link"};const r=f(o);return{label:r?`${n} \xB7 ${r.length>32?r.slice(0,31)+"\u2026":r}`:n,kind:"link"}},O=e=>{const t=String(e??""),n=[];let o=0;for(const r of t.matchAll(C)){const s=r[0].replace(/[.,;:!?)\]]+$/,"");r.index>o&&n.push(t.slice(o,r.index)),n.push({url:s,...M(s)}),o=r.index+s.length}return o<t.length&&n.push(t.slice(o)),n},q=e=>O(e).map(t=>typeof t=="string"?t:t.label).join(""),$={claude:"Claude",codex:"Codex",gemini:"Gemini",cursor:"Cursor",copilot:"Copilot",windsurf:"Windsurf",amp:"Amp",aider:"Aider",opencode:"OpenCode",agent:"AI agent"},I=e=>$[e]||(e?"AI agent":"Claude"),J="3.6 3.6 10.8 10.8",E="M10.116 9H13.883M9.966 9.558L12.222 10.86M9.558 9.966L11.441 13.228M9 10.116V12.72M8.442 9.966L6.559 13.228M8.034 9.558L5.778 10.86M7.884 9H4.118M8.034 8.442L5.778 7.14M8.442 8.034L6.559 4.772M9 7.884V5.28M9.558 8.034L11.441 4.772M9.966 8.442L12.222 7.14",i=e=>typeof e=="string"&&e.startsWith("agent:")?e.slice(6):null,l=e=>e==="claude"||i(e)!=null,D=/^[^\s@]+@[^\s@]+$/,Q=e=>{if(e==="claude")return e;if(typeof e!="string"||e.length>210)return null;const t=e.toLowerCase();return D.test(i(t)??t)?t:null},v=["new","approved","progress","review","waiting"],x=e=>v.includes(e?.stage)?e.stage:e?.stage==="accepted"?"review":l(e?.assignee)?"approved":"new",N=e=>e?.client===!0||e?.shared===!0,Z=(e,t)=>{const n=i(e.assignee);return!N(e)&&x(e)==="approved"&&(!e.assignee||e.assignee==="claude"||n!=null&&(t===void 0||n===t))&&!p(e)},_=()=>[{assignee:"claude",handle:"Claude",owner:null}],ee=(e,t=[])=>{const n=String(e||"").toLowerCase();let o=null,r=-1;for(const s of _()){const a=m(n,s.handle);a>r&&(r=a,o=s.assignee)}return o},te=(e,t,n=o=>o)=>I(e)+(t?` \xB7 ${n(t)}`:""),P=2*36e5,h=(e,t=Date.now())=>e?.working&&e.status!=="done"&&t-Date.parse(e.working.at)<P?e.working:null,ne=(e,t,n=Date.now())=>{const o=String(e?.by||e?.byName||"").toLowerCase();if(!o||t==="done")return null;const r=t==="claude"||l(e.assignee),s=p(e)?"":r?h(e,n)?.by||e.doneFor||e.handedBy||i(e.assignee)||o:e.assignee||"";return{writer:o,taker:String(s).toLowerCase(),claude:r}},R=e=>/@guest\.notemend\.com$/i.test(String(e||"")),p=e=>R(e.by)&&!e.approvedBy,oe=(e,t=Date.now())=>{if(!e)return null;if(e.status==="done")return e.doneBy==="claude"?"review":l(e.assignee)?"done":null;if(p(e))return"held";if(!l(e.assignee))return null;const n=S(e),o=n[n.length-1];return n.length>1&&o.author==="claude"&&!(e.reopenedAt&&Date.parse(e.reopenedAt)>=Date.parse(o.at))?"asks":h(e,t)?"working":e.working?"stuck":x(e)==="approved"?"queued":null},re={held:0,queued:2,asks:6,working:6,stuck:6,review:10,done:12},se=E.split("M").filter(Boolean).map(e=>{const t=e.match(/[\d.]+/g).map(Number),[n,o]=/H/.test(e)?[t[2],t[1]]:/V/.test(e)?[t[0],t[2]]:[t[2],t[3]];return{d:"M"+e,a:(Math.atan2(n-9,9-o)+2*Math.PI)%(2*Math.PI)}}).sort((e,t)=>e.a-t.a).map(e=>e.d),ae={plugin:"Claude Code: /plugin \u2192 Installed \u2192 notemend \u2192 Update now, then /reload-plugins",npx:'run it as npx -y notemend@latest (npx keeps an old copy of plain "notemend"), then restart the agent',project:"npm i -D notemend@latest in the site, then restart the agent",desktop:"Claude Desktop: download app.notemend.com/notemend.mcpb again and open it",source:"pull the notemend repository"},ie=(e,t)=>{const n=String(e).split(".").map(Number),o=String(t).split(".").map(Number);for(let r=0;r<3;r++)if((n[r]||0)!==(o[r]||0))return(n[r]||0)>(o[r]||0);return!1},le=(e,t)=>{if(e.archivedAt)return!0;if(!t||e.status!=="done"||e.doneBy==="claude")return!1;const n=Math.max(Date.parse(e.confirmedAt||e.updatedAt||"")||0,...(e.replies||[]).filter(o=>!o.deleted).map(o=>Date.parse(o.at||"")||0));return!!n&&Date.now()-n>t*864e5};export{$ as AGENTS,J as AI_BOX,E as AI_RAYS,se as AI_RAYS_CW,w as BLOCKED,g as DOCS,K as EMOJI,k as FILE_KINDS,j as FRAMES,A as MAX_REACTIONS,H as QUICK,v as STAGES,re as STEP_RAYS,ae as UPDATE_HOW,P as WORKING_TTL,_ as agentHandles,te as agentLabel,ee as agentMentioned,I as agentName,i as agentOwner,oe as agentStep,le as archivedOf,Q as cleanAssignee,U as cleanEmoji,N as clientSpace,G as docOf,F as docSlug,W as fileExt,T as fileKind,Z as forAgentOf,u as frameOf,z as framesOf,X as handleOf,p as held,R as isGuest,M as linkLabel,O as linkParts,q as linkWords,Y as mentionsIn,ie as newer,B as opensInTab,ne as pinWho,x as stageOf,S as threadOf,l as toAgent,V as toggledReaction,h as workingOn};
package/store.d.ts CHANGED
@@ -1,9 +1,9 @@
1
- import type { Working } from './thread.js';
1
+ import type { Reactions, Working } from './thread.js';
2
2
 
3
3
  /** One reply in a thread: `author: 'claude'` is any agent, `agent` says which */
4
4
  export interface Reply { author: 'you' | 'claude'; text: string; at: string; by?: string; byName?: string; agent?: string; mentions?: string[];
5
5
  /** taken back by its writer: kept in place, emptied */
6
- deleted?: boolean }
6
+ deleted?: boolean; reactions?: Reactions }
7
7
  /** A line the page logged before the comment was written (the bar's logs) */
8
8
  export interface LogLine { at: string; kind: 'console' | 'error' | 'rejection' | 'network'; text: string }
9
9
 
@@ -21,12 +21,21 @@ export interface Comment {
21
21
  priority?: 'urgent' | 'high' | 'normal' | 'low';
22
22
  /** the project's clients see it too */
23
23
  shared?: boolean;
24
+ /** written by a client or a guest: the clients' space */
25
+ client?: boolean;
26
+ /** a copy of this thread, in the other space */
27
+ from?: { id: number };
28
+ reactions?: Reactions;
29
+ /** put away by a person */
30
+ archivedAt?: string | null;
24
31
  /** a person sent it back: the agent's last word before this is no question */
25
32
  reopenedAt?: string; acceptedAt?: string;
26
33
  /** who ticked it as fixed, in a team */
27
34
  confirmedBy?: string | null; confirmedAt?: string | null;
28
35
  /** the person the agent ran as when it resolved it */
29
36
  doneFor?: string | null;
37
+ /** who handed it to an agent — whose Claude its pin shows (the server sets it) */
38
+ handedBy?: string | null;
30
39
  /** a guest's thread, approved by the studio */
31
40
  approvedBy?: string | null;
32
41
  /** the copy of the site it was written on — live, staging, localhost — as host[:port] */
@@ -55,6 +64,8 @@ export function reply(db: Db, id: number | string, author: 'you' | 'claude', tex
55
64
  export function edit(db: Db, id: number | string, at: string | null, text: string): Comment | null;
56
65
  /** Take back one of your replies, found by when it was written */
57
66
  export function unsay(db: Db, id: number | string, at: string): Comment | null;
67
+ /** Put `who`'s `emoji` on the comment (`at` null) or a reply, or take it back: null when there is no such message, false past the most kinds */
68
+ export function react(db: Db, id: number | string, at: string | null, emoji: string, who: string): Comment | null | false;
58
69
  export function patch(db: Db, id: number | string, changes: Partial<Comment>): Comment | null;
59
70
  export type Media = { base64: string; voice: boolean; ext: string; type: string; slug?: string };
60
71
  /** What a data: URL files as — a screenshot, a recording, a voice note or a document — else null */
@@ -71,6 +82,8 @@ export function createStore(root: string): {
71
82
  save(db: Db): void;
72
83
  /** the file's stamp, for ?since= polls: '0' when there is no file yet */
73
84
  version(): string;
85
+ /** the stamp the file had when `db` was loaded, else the file's now */
86
+ versionOf(db: Db): string;
74
87
  /** file a data: URL screenshot (or webm) under the comment — `kind` makes it a frame; returns its path or null */
75
88
  attach(db: Db, id: number | string, dataUrl: string, kind?: 'before' | 'after'): string | null;
76
89
  detach(db: Db, id: number | string, name: string): boolean;
package/thread.d.ts CHANGED
@@ -3,6 +3,12 @@ export type Mentionable = { email: string; name?: string | null; nickname?: stri
3
3
  export function handleOf(p: Mentionable): string;
4
4
  /** Everyone a text @mentions, by email */
5
5
  export function mentionsIn(text: string, people: Mentionable[]): string[];
6
+ /** A link named the way a message shows it: "Figma · Notemend", "GitHub · notemend #42", or the host and the last part */
7
+ export function linkLabel(url: string): { label: string; kind: "link" | "github" | "pr" };
8
+ /** A text cut into its words and its links, in order */
9
+ export function linkParts(text: string | null | undefined): (string | { url: string; label: string; kind: "link" | "github" | "pr" })[];
10
+ /** The text with each link as its name, for a one-line preview */
11
+ export function linkWords(text: string | null | undefined): string;
6
12
  /** Display names of the coding agents, by id */
7
13
  export const AGENTS: Record<string, string>;
8
14
  /** The name to show for an agent's message: its `agent`, or Claude when there is none */
@@ -29,6 +35,8 @@ export type Working = { agent: string; by?: string | null; at: string; v?: strin
29
35
  export const WORKING_TTL: number;
30
36
  /** The agent working on an open thread now, or null when nobody is or the mark is stale */
31
37
  export function workingOn(c: { working?: Working | null; status?: string } | null | undefined, now?: number): Working | null;
38
+ /** Who is on a thread, for its pin: its writer and whoever has it ('' nobody yet); null when resolved or no writer is known. `st` as stateOf gives it */
39
+ export function pinWho(c: Record<string, any>, st: 'open' | 'done' | 'claude', now?: number): { writer: string; taker: string; claude: boolean } | null;
32
40
  /** A guest's address: someone let in by link, without an account */
33
41
  export function isGuest(email?: string | null): boolean;
34
42
  /** A guest's thread the studio has not approved yet: no agent takes it */