notemend 0.1.14 → 0.1.16
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/bin/notemend.mjs +15 -15
- package/package.json +1 -1
- package/src/client/canvas.js +1 -0
- package/src/client/field-menu.js +1 -1
- package/src/client/markup.js +14 -14
- package/src/client/notemend.css +1 -1
- package/src/client/panel.js +39 -0
- package/src/client/review.js +8 -0
- package/src/client/run.js +52 -100
- package/src/client/turbo.js +1 -0
- package/src/server/middleware.mjs +1 -1
- package/src/store/categories.mjs +1 -1
- package/src/store/comments.mjs +3 -3
- package/src/store/thread.mjs +1 -1
- package/store.d.ts +3 -1
- package/thread.d.ts +17 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{agentName as d}from"../store/thread.mjs";import{api as p}from"./api";function f(c,r){let a=null,i=null;const e=document.querySelector(".dt-turbo"),u="/notemend:turbo",s=()=>{const n=!!a&&Date.now()-Date.parse(a.at)<18e4,t=n?i?.paused?"paused":"on":"none",o=n?d(a.agent):"",l=t==="none"?`Turbo is off. Run ${u} in Claude Code and comments for the agent are taken as they land \u2014 click to copy it`:t==="on"?`Turbo on: ${o} takes comments for the agent as they land \u2014 click to pause`:`Turbo paused: ${o} is listening but waits \u2014 click to resume`;e.dataset.state=t,e.dataset.tip=l,e.setAttribute("aria-label",l),e.setAttribute("aria-checked",String(t==="on")),c&&(e.hidden=!0)};return setInterval(s,3e4),e.addEventListener("click",async()=>{const n=e.dataset.state;if(n==="none"){await navigator.clipboard?.writeText(u).catch(()=>{}),r(`Copied ${u} \u2014 paste it in Claude Code`);return}const t=n==="on"?"off":"on";i={paused:t==="off"},s();try{const o=await p("comments",{method:"PATCH",headers:{"content-type":"application/json"},body:JSON.stringify({turbo:t})});if(!o.ok)throw new Error(String(o.status));r(t==="off"?"Turbo paused":"Turbo on")}catch{i={paused:t==="on"},s(),r("Could not switch turbo \u2014 try again")}}),n=>{a=n.listening??null,i=n.turbo??null,s()}}export{f as turbo};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{readFileSync as H,existsSync as _,statSync as Y,readdirSync as q}from"node:fs";import{mask as tt}from"../store/mask.mjs";import{join as I,isAbsolute as et}from"node:path";import{isIP as b}from"node:net";import{pathToFileURL as rt}from"node:url";import{openStore as nt,retry as ot,CABINET as st,session as G}from"../store/cloud.mjs";import{mentionsIn as at,cleanAssignee as D,STAGES as M,frameOf as it}from"../store/thread.mjs";import{CATEGORIES as ct,categoryOf as ut}from"../store/categories.mjs";import{BREAKPOINTS as lt,DEVICES as mt,ICONS as z,SHELLS as J,BROWSERS as U}from"../presets.mjs";const W={png:"image/png",jpg:"image/jpeg",jpeg:"image/jpeg",webp:"image/webp",gif:"image/gif",svg:"image/svg+xml",webm:"video/webm",m4a:"audio/mp4"},V=t=>t.split(".").slice(0,2).map(Number).reduce((r,l)=>r*100+(Number.isNaN(l)?9999:l),0),ft=(t,r)=>{try{const m=H(et(r)?r:I(t,r),"utf8").match(/title="([^"]+)"|\btitle:\s*["'`]([^"'`]+)["'`]/);return(m?.[1]??m?.[2])?.split("\u2014").pop()?.trim()||null}catch{return null}};function Bt(t){const r=["app","src/app"].map(c=>I(t,c)).find(_),l=[],m=(c,g)=>{for(const a of q(c,{withFileTypes:!0})){const u=a.name;if(a.isDirectory()){if(/^[_@]|^\(\./.test(u))continue;m(I(c,u),/^\(.+\)$/.test(u)?g:[...g,u])}else/^page\.(jsx?|tsx?|mdx?)$/.test(u)&&l.push({origin:"project",type:"page",pattern:"/"+g.join("/"),entrypoint:I(c,u)})}};return r&&m(r,[]),l}const dt=t=>t[0].toUpperCase()+t.slice(1).replace(/[-_]+/g," ");function gt({root:t,options:r,routes:l}){const m=r.pages??{},c=(e,f,v)=>({route:e,name:f,label:f.replace(/^[\d.]+[A-Z]?\.\s*/,""),group:v}),g=l.filter(e=>e.origin==="project"&&e.type==="page"&&!e.pattern.includes("[")).map(e=>({route:e.pattern.replace(/\/+$/,"")||"/",entrypoint:e.entrypoint})),a=new Set(g.map(e=>e.route)),u=[...g,...Object.keys(m).filter(e=>!a.has(e)).map(e=>({route:e}))],j={};for(const{route:e}of u){const f=e.split("/")[1];f&&(j[f]=(j[f]||0)+1)}const $=e=>{const f=e.split("/")[1];return f&&j[f]>1?dt(f):"Pages"},L=r.groups?()=>r.groups[r.groups.length-1]:$,P=u.map(({route:e,entrypoint:f})=>{const[v,E]=m[e]??[];return c(e,v??(f&&ft(t,f))??e,E??L(e))}),o=r.groups??[...new Set([...Object.values(m).map(([,e])=>e).filter(Boolean),"Pages",...P.map(e=>e.group).sort()])],d=P.sort((e,f)=>o.indexOf(e.group)-o.indexOf(f.group)||V(e.name)-V(f.name)||e.route.localeCompare(f.route)),n=(r.breakpoints??lt).map(e=>({id:e.id,label:e.label,min:e.min,ideal:e.ideal,max:Number.isFinite(e.max)?e.max:null,icon:e.icon??z[e.id]??z.desktop})),s=(r.devices??mt).filter(e=>e.w>0&&e.h>0&&J.includes(e.shell)&&U.includes(e.browser)?!0:(console.warn(`[notemend] device "${e.id}" skipped: it needs w and h, shell (${J.join(", ")}) and browser (${U.join(", ")})${e.frame?"; `frame` pictures were replaced by shell + browser in 0.3":""}`),!1));return{pages:d,groups:o.filter(e=>d.some(f=>f.group===e)),breakpoints:n,devices:s,categories:ct,sanity:!!r.sanity,shortcuts:r.shortcuts!==!1,ignore:r.ignore??[],grid:{container:"container",grid:"grid",columns:12,...r.grid},zIndex:r.zIndex??2000000020}}const pt=t=>{const r=I(t,"notemend.config.mjs");let l=0,m={};return async()=>{if(!_(r))return{};const c=Y(r).mtimeMs;if(c===l)return m;l=c;try{const{default:g,...a}=await import(/* webpackIgnore: true */ /* turbopackIgnore: true */ `${rt(r).href}?t=${c}`);m={...a,...g}}catch(g){console.warn(`[notemend] notemend.config.mjs: ${g.message}`)}return m}},ht=t=>{const r=String(t.headers.host||"").toLowerCase(),l=r.startsWith("[")?r.slice(1,r.indexOf("]")):r.replace(/:\d+$/,"");return l.includes(":")?b(l)===6:!l||!l.includes(".")||b(l)===4||/\.(localhost|local|test|internal|lan|home\.arpa)$/.test(l)},S=(t,r)=>String(t??"").replace(/[\u0000-\u001f\u007f]+/g," ").trim().slice(0,r),yt=t=>({route:S(t.route,500),text:String(t.text??"").slice(0,1e4),selector:S(t.selector,2e3),rx:Number.isFinite(t.rx)?t.rx:0,ry:Number.isFinite(t.ry)?t.ry:0,label:S(t.label,200),ctx:S(t.ctx,120),breakpoint:S(t.breakpoint,40),browser:S(t.browser,80),device:S(t.device,80),tag:S(t.tag,40),classes:Array.isArray(t.classes)?t.classes.slice(0,20).map(r=>S(r,80)):[],nth:Number.isInteger(t.nth)?t.nth:null,category:S(t.category,40),...["urgent","high","normal","low"].includes(t.priority)?{priority:t.priority}:{},...t.shared===!0?{shared:!0}:{},viewport:t.viewport&&Number.isFinite(t.viewport.w)&&Number.isFinite(t.viewport.h)?{w:t.viewport.w,h:t.viewport.h}:null,...D(t.assignee)?{assignee:D(t.assignee)}:{},...M.includes(t.stage)?{stage:t.stage}:{},...typeof t.host=="string"&&/^[a-z0-9.-]{1,120}(:\d{1,5})?$/i.test(t.host)?{host:t.host.toLowerCase()}:{},...Array.isArray(t.logs)&&t.logs.length?{logs:t.logs.slice(-20).map(r=>({at:S(r?.at,30),kind:["console","error","rejection","network"].includes(r?.kind)?r.kind:"console",text:tt(S(r?.text,500))})).filter(r=>r.text)}:{},...t.suggest&&typeof t.suggest.from=="string"&&typeof t.suggest.to=="string"&&t.suggest.to.trim()?{suggest:{from:t.suggest.from.slice(0,2e3),to:t.suggest.to.slice(0,2e3)}}:{}}),wt=t=>{const r={};return(t.status==="open"||t.status==="done")&&(r.status=t.status),"doneBy"in t&&(r.doneBy=t.doneBy==="you"?"you":null),typeof t.category=="string"&&(r.category=ut(t.category).id),"priority"in t&&(r.priority=["urgent","high","normal","low"].includes(t.priority)?t.priority:null),typeof t.shared=="boolean"&&(r.shared=t.shared||null),"assignee"in t&&(r.assignee=D(t.assignee)),"stage"in t&&(r.stage=M.includes(t.stage)?t.stage:null),r},K=async(t,r,l,m,c)=>{if(typeof m!="string")return;const g=r.comments.find(a=>a.id===Number(l))?.images?.filter(a=>it(a)===c)??[];if(await t.attach(r,l,m,c))for(const a of g)await t.detach(r,l,a)},Z=t=>{const r=t.headers.origin;if(!r)return!1;try{return new URL(r).host!==t.headers.host}catch{return!0}};function xt({root:t,options:r,routes:l,open:m=()=>nt(t),crossOrigin:c=!1}){const g=pt(t),a=(o,d=200)=>({status:d,type:"application/json",body:JSON.stringify(o)}),u=(o,d)=>({status:o,type:"text/plain",body:d}),j=async o=>{const d=await o.body();if(d.length>45e5)throw Object.assign(new Error("too large"),{status:413});try{return d.length?JSON.parse(d.toString("utf8")):{}}catch{throw Object.assign(new Error("not JSON"),{status:400})}},$=async(o,d)=>{const n=async s=>{const e=await d(s);if(e.status>=400)throw Object.assign(new Error("not written"),{out:e});return e};try{if(o.cloud)return await ot(o,n);const s=o.load(),e=await n(s);return o.save(s),e}catch(s){if(s.out)return s.out;throw s}},L=async(o,d)=>{if(o.method!=="GET"&&!c&&Z(o))return u(403,"Cross-origin write refused");const n=await m();if(o.method==="GET"){const i=d.searchParams.get("route"),y=n.version?String(await n.version()):null;if(y&&d.searchParams.get("since")===y)return{status:204,type:"text/plain",body:""};const w=await n.load();return a({version:y,comments:i?w.comments.filter(A=>A.route===i):w.comments,listening:w.listening??null,turbo:w.turbo??null})}let s=null,e=null;const f=n.cloud&&o.method!=="DELETE"?n.people().then(i=>{s=i,e=i.me},i=>{throw i}).catch(i=>i):Promise.resolve(),v=async()=>{const i=await f;if(i instanceof Error)throw i},E=i=>{if(e&&i){i.by=e.email,i.byName=e.name;const y=at(i.text,s.team.filter(w=>w.email!==e.email));y.length&&(i.mentions=y)}return i};if(o.method==="POST"){const{image:i,images:y,before:w,...A}=await j(o),B=yt(A);return B.text.trim()?/^\/(?![\/\\])/.test(B.route)?$(n,async C=>{await v();const N=E(n.add(C,B));for(const T of[].concat(y??i??[]))await n.attach(C,N.id,T);return await K(n,C,N.id,w,"before"),a(N,201)}):a({error:"route must be a path"},400):a({error:"empty comment"},400)}if(o.method==="PATCH"){const i=await j(o);if(i.turbo==="on"||i.turbo==="off")return $(n,async h=>(h.turbo={paused:i.turbo==="off",at:new Date().toISOString()},a({turbo:h.turbo})));const{id:y,reply:w,image:A,images:B,removeImage:C,edit:N,unsay:T,after:Q,...X}=i,p=Number(y);if(!Number.isInteger(p))return a({error:"bad id"},400);const k=wt(X);return $(n,async h=>{if(await v(),N){const x=h.comments.find(F=>F.id===Number(p)),O=N.at?x?.replies?.find(F=>F.at===N.at):x;if(e&&O?.by&&O.by!==e.email||!(N.text?.trim?.()&&n.edit(h,p,N.at??null,N.text.trim().slice(0,1e4))))return a({error:`no message of yours to edit in #${p}`},404)}if(typeof T=="string"){const x=h.comments.find(O=>O.id===p)?.replies?.find(O=>O.at===T);return!x||e&&x.by&&x.by!==e.email||!n.unsay(h,p,T)?a({error:`no reply of yours to delete in #${p}`},404):a(h.comments.find(O=>O.id===p))}w?.trim?.()&&E(n.reply(h,p,"you",w.trim().slice(0,1e4))?.replies.at(-1));for(const x of[].concat(B??A??[]))await n.attach(h,p,x);for(const x of[].concat(C||[]))await n.detach(h,p,x);await K(n,h,p,Q,"after"),e&&k.status==="done"&&Object.assign(k,{confirmedBy:e.email,confirmedAt:new Date().toISOString()}),e&&k.status==="open"&&Object.assign(k,{confirmedBy:null,confirmedAt:null});const R=Object.keys(k).length||!w?n.patch(h,p,k):h.comments.find(x=>x.id===Number(p));return R?a(R):a({error:`no comment #${p}`},404)})}if(o.method==="DELETE"){const i=Number(d.searchParams.get("id"));return $(n,async y=>await n.remove(y,i)?a({ok:!0,id:i}):a({error:`no comment #${i}`},404))}return u(405,"Method not allowed")},P=(o,d)=>{const n=d.replace(/^.*[/\\]/,""),s=n.split(".").pop()?.toLowerCase()??"";if(!/^[\w.-]+$/.test(n)||!W[s])return u(400,"Bad name");const e=I(o,n);return _(e)?{status:200,type:W[s],body:H(e)}:u(404,"Not found")};return async o=>{const d=new URL(o.url,"http://devbar"),n=d.pathname.slice(10);if(!c&&!ht(o))return u(403,"Notemend answers local addresses only");try{if(n==="config"){const s=gt({root:t,options:{...await g(),...r},routes:l()}),e=await m();return e.cloud&&Object.assign(s,await e.people().catch(()=>({}))),(e.cloud||await G().catch(()=>null))&&(s.voice=!0),a(s)}if(n==="transcribe"&&o.method==="POST"){if(!c&&Z(o))return u(403,"Cross-origin write refused");const s=await m(),e=s.cloud?await s.token():(await G().catch(()=>null))?.access_token;if(!e)return u(401,"Voice replies need Notemend \u2014 run `npx notemend login`.");const{audio:f}=await j(o),v=/^data:(audio\/(?:webm|mp4))(?:;[\w=.-]+)*;base64,(.+)$/s.exec(String(f||""));if(!v)return u(400,"Not a recording");const E=await fetch(`${st}/api/transcribe`,{method:"POST",body:Buffer.from(v[2],"base64"),headers:{authorization:`Bearer ${e}`,"content-type":v[1]}});return{status:E.status,type:"application/json",body:await E.text()}}if(n==="comments")return await L(o,d);if(n==="image"){const s=await m(),e=(d.searchParams.get("name")||"").replace(/^.*[/\\]/,"");return s.cloud&&/^[\w.-]+$/.test(e)&&await s.fetchImage(e).catch(()=>null),P(s.imageDir,e)}return u(404,"Not found")}catch(s){return s.status===400||s.status===413?u(s.status,s.message):(console.error("[notemend]",s),u(500,"Something went wrong \u2014 the dev server log says what."))}}}function Ct(t){const r=xt(t),l=m=>new Promise((c,g)=>{const a=[];m.on("data",u=>a.push(u)),m.on("end",()=>c(Buffer.concat(a))),m.on("error",g)});return async function(c,g,a){if(!c.url||!c.url.startsWith("/__devbar/"))return a();const u=await r({method:c.method,url:c.url,headers:c.headers,body:()=>l(c)});g.statusCode=u.status,g.setHeader("content-type",u.type),g.setHeader("cache-control","no-store"),g.end(u.body)}}export{gt as buildConfig,xt as notemendHandler,Ct as notemendMiddleware,Bt as scanApp,ft as titleOf,dt as titled};
|
|
1
|
+
import{readFileSync as z,existsSync as F,statSync as q,readdirSync as tt}from"node:fs";import{mask as et}from"../store/mask.mjs";import{join as I,isAbsolute as nt}from"node:path";import{isIP as G}from"node:net";import{pathToFileURL as rt}from"node:url";import{openStore as ot,retry as st,CABINET as J,session as D}from"../store/cloud.mjs";import{mentionsIn as at,cleanAssignee as R,STAGES as M,frameOf as it}from"../store/thread.mjs";import{CATEGORIES as ct,categoryOf as ut}from"../store/categories.mjs";import{BREAKPOINTS as lt,DEVICES as mt,ICONS as U,SHELLS as W,BROWSERS as V}from"../presets.mjs";const K={png:"image/png",jpg:"image/jpeg",jpeg:"image/jpeg",webp:"image/webp",gif:"image/gif",svg:"image/svg+xml",webm:"video/webm",m4a:"audio/mp4",pdf:"application/pdf",doc:"application/msword",docx:"application/vnd.openxmlformats-officedocument.wordprocessingml.document"},Z=t=>t.split(".").slice(0,2).map(Number).reduce((n,m)=>n*100+(Number.isNaN(m)?9999:m),0),ft=(t,n)=>{try{const l=z(nt(n)?n:I(t,n),"utf8").match(/title="([^"]+)"|\btitle:\s*["'`]([^"'`]+)["'`]/);return(l?.[1]??l?.[2])?.split("\u2014").pop()?.trim()||null}catch{return null}};function At(t){const n=["app","src/app"].map(u=>I(t,u)).find(F),m=[],l=(u,p)=>{for(const a of tt(u,{withFileTypes:!0})){const c=a.name;if(a.isDirectory()){if(/^[_@]|^\(\./.test(c))continue;l(I(u,c),/^\(.+\)$/.test(c)?p:[...p,c])}else/^page\.(jsx?|tsx?|mdx?)$/.test(c)&&m.push({origin:"project",type:"page",pattern:"/"+p.join("/"),entrypoint:I(u,c)})}};return n&&l(n,[]),m}const dt=t=>t[0].toUpperCase()+t.slice(1).replace(/[-_]+/g," ");function pt({root:t,options:n,routes:m}){const l=n.pages??{},u=(e,f,w)=>({route:e,name:f,label:f.replace(/^[\d.]+[A-Z]?\.\s*/,""),group:w}),p=m.filter(e=>e.origin==="project"&&e.type==="page"&&!e.pattern.includes("[")).map(e=>({route:e.pattern.replace(/\/+$/,"")||"/",entrypoint:e.entrypoint})),a=new Set(p.map(e=>e.route)),c=[...p,...Object.keys(l).filter(e=>!a.has(e)).map(e=>({route:e}))],j={};for(const{route:e}of c){const f=e.split("/")[1];f&&(j[f]=(j[f]||0)+1)}const k=e=>{const f=e.split("/")[1];return f&&j[f]>1?dt(f):"Pages"},L=n.groups?()=>n.groups[n.groups.length-1]:k,P=c.map(({route:e,entrypoint:f})=>{const[w,N]=l[e]??[];return u(e,w??(f&&ft(t,f))??e,N??L(e))}),r=n.groups??[...new Set([...Object.values(l).map(([,e])=>e).filter(Boolean),"Pages",...P.map(e=>e.group).sort()])],d=P.sort((e,f)=>r.indexOf(e.group)-r.indexOf(f.group)||Z(e.name)-Z(f.name)||e.route.localeCompare(f.route)),s=(n.breakpoints??lt).map(e=>({id:e.id,label:e.label,min:e.min,ideal:e.ideal,max:Number.isFinite(e.max)?e.max:null,icon:e.icon??U[e.id]??U.desktop})),o=(n.devices??mt).filter(e=>e.w>0&&e.h>0&&W.includes(e.shell)&&V.includes(e.browser)?!0:(console.warn(`[notemend] device "${e.id}" skipped: it needs w and h, shell (${W.join(", ")}) and browser (${V.join(", ")})${e.frame?"; `frame` pictures were replaced by shell + browser in 0.3":""}`),!1));return{pages:d,groups:r.filter(e=>d.some(f=>f.group===e)),breakpoints:s,devices:o,categories:ct,sanity:!!n.sanity,shortcuts:n.shortcuts!==!1,ignore:n.ignore??[],grid:{container:"container",grid:"grid",columns:12,...n.grid},zIndex:n.zIndex??2000000020}}const gt=t=>{const n=I(t,"notemend.config.mjs");let m=0,l={};return async()=>{if(!F(n))return{};const u=q(n).mtimeMs;if(u===m)return l;m=u;try{const{default:p,...a}=await import(/* webpackIgnore: true */ /* turbopackIgnore: true */ `${rt(n).href}?t=${u}`);l={...a,...p}}catch(p){console.warn(`[notemend] notemend.config.mjs: ${p.message}`)}return l}},ht=t=>{const n=String(t.headers.host||"").toLowerCase(),m=n.startsWith("[")?n.slice(1,n.indexOf("]")):n.replace(/:\d+$/,"");return m.includes(":")?G(m)===6:!m||!m.includes(".")||G(m)===4||/\.(localhost|local|test|internal|lan|home\.arpa)$/.test(m)},v=(t,n)=>String(t??"").replace(/[\u0000-\u001f\u007f]+/g," ").trim().slice(0,n),wt=t=>({route:v(t.route,500),text:String(t.text??"").slice(0,1e4),selector:v(t.selector,2e3),rx:Number.isFinite(t.rx)?t.rx:0,ry:Number.isFinite(t.ry)?t.ry:0,label:v(t.label,200),ctx:v(t.ctx,120),breakpoint:v(t.breakpoint,40),browser:v(t.browser,80),device:v(t.device,80),tag:v(t.tag,40),classes:Array.isArray(t.classes)?t.classes.slice(0,20).map(n=>v(n,80)):[],nth:Number.isInteger(t.nth)?t.nth:null,category:v(t.category,40),...["urgent","high","normal","low"].includes(t.priority)?{priority:t.priority}:{},...t.shared===!0?{shared:!0}:{},viewport:t.viewport&&Number.isFinite(t.viewport.w)&&Number.isFinite(t.viewport.h)?{w:t.viewport.w,h:t.viewport.h}:null,...R(t.assignee)?{assignee:R(t.assignee)}:{},...M.includes(t.stage)?{stage:t.stage}:{},...typeof t.host=="string"&&/^[a-z0-9.-]{1,120}(:\d{1,5})?$/i.test(t.host)?{host:t.host.toLowerCase()}:{},...Array.isArray(t.logs)&&t.logs.length?{logs:t.logs.slice(-20).map(n=>({at:v(n?.at,30),kind:["console","error","rejection","network"].includes(n?.kind)?n.kind:"console",text:et(v(n?.text,500))})).filter(n=>n.text)}:{},...t.suggest&&typeof t.suggest.from=="string"&&typeof t.suggest.to=="string"&&t.suggest.to.trim()?{suggest:{from:t.suggest.from.slice(0,2e3),to:t.suggest.to.slice(0,2e3)}}:{}}),yt=t=>{const n={};return(t.status==="open"||t.status==="done")&&(n.status=t.status),t.status==="open"&&(n.reopenedAt=new Date().toISOString()),"doneBy"in t&&(n.doneBy=t.doneBy==="you"?"you":null),typeof t.category=="string"&&(n.category=ut(t.category).id),"priority"in t&&(n.priority=["urgent","high","normal","low"].includes(t.priority)?t.priority:null),typeof t.shared=="boolean"&&(n.shared=t.shared||null),"assignee"in t&&(n.assignee=R(t.assignee)),"stage"in t&&(n.stage=M.includes(t.stage)?t.stage:null),n},Q=async(t,n,m,l,u)=>{if(typeof l!="string")return;const p=n.comments.find(a=>a.id===Number(m))?.images?.filter(a=>it(a)===u)??[];if(await t.attach(n,m,l,u))for(const a of p)await t.detach(n,m,a)},b=t=>{const n=t.headers.origin;if(!n)return!1;try{return new URL(n).host!==t.headers.host}catch{return!0}};function xt({root:t,options:n,routes:m,open:l=()=>ot(t),crossOrigin:u=!1}){const p=gt(t),a=(r,d=200)=>({status:d,type:"application/json",body:JSON.stringify(r)}),c=(r,d)=>({status:r,type:"text/plain",body:d}),j=async r=>{const d=await r.body();if(d.length>45e5)throw Object.assign(new Error("too large"),{status:413});try{return d.length?JSON.parse(d.toString("utf8")):{}}catch{throw Object.assign(new Error("not JSON"),{status:400})}},k=async(r,d)=>{const s=async o=>{const e=await d(o);if(e.status>=400)throw Object.assign(new Error("not written"),{out:e});return e};try{if(r.cloud)return await st(r,s);const o=r.load(),e=await s(o);return r.save(o),e}catch(o){if(o.out)return o.out;throw o}},L=async(r,d)=>{if(r.method!=="GET"&&!u&&b(r))return c(403,"Cross-origin write refused");const s=await l();if(r.method==="GET"){const i=d.searchParams.get("route"),y=s.version?String(await s.version()):null;if(y&&d.searchParams.get("since")===y)return{status:204,type:"text/plain",body:""};const x=await s.load();return a({version:y,comments:i?x.comments.filter(T=>T.route===i):x.comments,listening:x.listening??null,turbo:x.turbo??null})}let o=null,e=null;const f=s.cloud&&r.method!=="DELETE"?s.people().then(i=>{o=i,e=i.me},i=>{throw i}).catch(i=>i):Promise.resolve(),w=async()=>{const i=await f;if(i instanceof Error)throw i},N=i=>{if(e&&i){i.by=e.email,i.byName=e.name;const y=at(i.text,o.team.filter(x=>x.email!==e.email));y.length&&(i.mentions=y)}return i};if(r.method==="POST"){const{image:i,images:y,before:x,...T}=await j(r),A=wt(T);return A.text.trim()?/^\/(?![\/\\])/.test(A.route)?k(s,async B=>{await w();const O=N(s.add(B,A));for(const C of[].concat(y??i??[]))await s.attach(B,O.id,C);return await Q(s,B,O.id,x,"before"),a(O,201)}):a({error:"route must be a path"},400):a({error:"empty comment"},400)}if(r.method==="PATCH"){const i=await j(r);if(i.turbo==="on"||i.turbo==="off")return k(s,async h=>(h.turbo={paused:i.turbo==="off",at:new Date().toISOString()},a({turbo:h.turbo})));const{id:y,reply:x,image:T,images:A,removeImage:B,edit:O,unsay:C,after:X,...Y}=i,g=Number(y);if(!Number.isInteger(g))return a({error:"bad id"},400);const E=yt(Y);return k(s,async h=>{if(await w(),O){const S=h.comments.find(_=>_.id===Number(g)),$=O.at?S?.replies?.find(_=>_.at===O.at):S;if(e&&$?.by&&$.by!==e.email||!(O.text?.trim?.()&&s.edit(h,g,O.at??null,O.text.trim().slice(0,1e4))))return a({error:`no message of yours to edit in #${g}`},404)}if(typeof C=="string"){const S=h.comments.find($=>$.id===g)?.replies?.find($=>$.at===C);return!S||e&&S.by&&S.by!==e.email||!s.unsay(h,g,C)?a({error:`no reply of yours to delete in #${g}`},404):a(h.comments.find($=>$.id===g))}x?.trim?.()&&N(s.reply(h,g,"you",x.trim().slice(0,1e4))?.replies.at(-1));for(const S of[].concat(A??T??[]))await s.attach(h,g,S);for(const S of[].concat(B||[]))await s.detach(h,g,S);await Q(s,h,g,X,"after"),e&&E.status==="done"&&Object.assign(E,{confirmedBy:e.email,confirmedAt:new Date().toISOString()}),e&&E.status==="open"&&Object.assign(E,{confirmedBy:null,confirmedAt:null});const H=Object.keys(E).length||!x?s.patch(h,g,E):h.comments.find(S=>S.id===Number(g));return H?a(H):a({error:`no comment #${g}`},404)})}if(r.method==="DELETE"){const i=Number(d.searchParams.get("id"));return k(s,async y=>await s.remove(y,i)?a({ok:!0,id:i}):a({error:`no comment #${i}`},404))}return c(405,"Method not allowed")},P=(r,d)=>{const s=d.replace(/^.*[/\\]/,""),o=s.split(".").pop()?.toLowerCase()??"";if(!/^[\w.-]+$/.test(s)||!K[o])return c(400,"Bad name");const e=I(r,s);return F(e)?{status:200,type:K[o],body:z(e)}:c(404,"Not found")};return async r=>{const d=new URL(r.url,"http://devbar"),s=d.pathname.slice(10);if(!u&&!ht(r))return c(403,"Notemend answers local addresses only");try{if(s==="config"){const o=pt({root:t,options:{...await p(),...n},routes:m()}),e=await l();return e.cloud&&Object.assign(o,await e.people().catch(()=>({}))),(e.cloud||await D().catch(()=>null))&&(o.voice=!0),a(o)}if(s==="transcribe"&&r.method==="POST"){if(!u&&b(r))return c(403,"Cross-origin write refused");const o=await l(),e=o.cloud?await o.token():(await D().catch(()=>null))?.access_token;if(!e)return c(401,"Voice replies need Notemend \u2014 run `npx notemend login`.");const{audio:f}=await j(r),w=/^data:(audio\/(?:webm|mp4))(?:;[\w=.-]+)*;base64,(.+)$/s.exec(String(f||""));if(!w)return c(400,"Not a recording");const N=await fetch(`${J}/api/transcribe`,{method:"POST",body:Buffer.from(w[2],"base64"),headers:{authorization:`Bearer ${e}`,"content-type":w[1]}});return{status:N.status,type:"application/json",body:await N.text()}}if(s==="translate"&&r.method==="POST"){if(!u&&b(r))return c(403,"Cross-origin write refused");const o=await l(),e=o.cloud?await o.token():(await D().catch(()=>null))?.access_token;if(!e)return c(401,"Translating needs Notemend \u2014 run `npx notemend login`.");const{text:f,to:w}=await j(r),N=await fetch(`${J}/api/translate`,{method:"POST",body:JSON.stringify({text:f,to:w}),headers:{authorization:`Bearer ${e}`,"content-type":"application/json"}});return{status:N.status,type:"application/json",body:await N.text()}}if(s==="comments")return await L(r,d);if(s==="image"){const o=await l(),e=(d.searchParams.get("name")||"").replace(/^.*[/\\]/,"");return o.cloud&&/^[\w.-]+$/.test(e)&&await o.fetchImage(e).catch(()=>null),P(o.imageDir,e)}return c(404,"Not found")}catch(o){return o.status===400||o.status===413?c(o.status,o.message):(console.error("[notemend]",o),c(500,"Something went wrong \u2014 the dev server log says what."))}}}function Bt(t){const n=xt(t),m=l=>new Promise((u,p)=>{const a=[];l.on("data",c=>a.push(c)),l.on("end",()=>u(Buffer.concat(a))),l.on("error",p)});return async function(u,p,a){if(!u.url||!u.url.startsWith("/__devbar/"))return a();const c=await n({method:u.method,url:u.url,headers:u.headers,body:()=>m(u)});p.statusCode=c.status,p.setHeader("content-type",c.type),p.setHeader("cache-control","no-store"),p.end(c.body)}}export{pt as buildConfig,xt as notemendHandler,Bt as notemendMiddleware,At as scanApp,ft as titleOf,dt as titled};
|
package/src/store/categories.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const e=[{id:"general",label:"General",color:"#0d99ff",icon:'<path d="M8.3 10a.7.7 0 0 1-.626-1.079L11.4 3a.7.7 0 0 1 1.198-.043L16.3 8.9a.7.7 0 0 1-.572 1.1Z"/><rect x="3" y="14" width="7" height="7" rx="1"/><circle cx="17.5" cy="17.5" r="3.5"/>'},{id:"bug",label:"Bug",color:"#e5484d",icon:'<path d="m8 2 1.88 1.88M14.12 3.88 16 2M9 7.13v-1a3 3 0 1 1 6 0v1"/><path d="M12 20c-3.3 0-6-2.7-6-6v-3a4 4 0 0 1 4-4h4a4 4 0 0 1 4 4v3c0 3.3-2.7 6-6 6M12 20v-9M6.53 9C4.6 8.8 3 7.1 3 5M6 13H2M3 21c0-2.1 1.7-3.9 3.8-4M20.97 5c0 2.1-1.6 3.8-3.5 4M22 13h-4M17.2 17c2.1.1 3.8 1.9 3.8 4"/>'},{id:"text",label:"Text",color:"#f5c451",icon:'<path d="M4 7V4h16v3M9 20h6M12 4v16"/>'},{id:"motion",label:"Motion",color:"#a475f9",icon:'<path d="M17.7 7.7a2.5 2.5 0 1 1 1.8 4.3H2M9.6 4.6A2 2 0 1 1 11 8H2M12.6 19.4A2 2 0 1 0 14 16H2"/>'},{id:"design",label:"Design",color:"#d6409f",icon:'<path d="M12 2C6.5 2 2 6.5 2 12s4.5 10 10 10c.93 0 1.65-.75 1.65-1.69 0-.44-.18-.84-.44-1.13-.29-.29-.44-.65-.44-1.13a1.64 1.64 0 0 1 1.67-1.67h2c3.05 0 5.55-2.5 5.55-5.55C21.97 6.01 17.46 2 12 2z"/><circle cx="13.5" cy="6.5" r="1"/><circle cx="17.5" cy="10.5" r="1"/><circle cx="8.5" cy="7.5" r="1"/><circle cx="6.5" cy="12.5" r="1"/>'},{id:"content",label:"Content",color:"#30a46c",icon:'<path d="M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z"/><path d="M14 2v4a2 2 0 0 0 2 2h4M10 9H8M16 13H8M16 17H8"/>'}],t=(c,o=14)=>`<svg viewBox="0 0 24 24" width="${o}" height="${o}" fill="none" stroke="${c.color}" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">${c.icon}</svg>`,a=c=>e.find(o=>o.id===c)||e[0];export{e as CATEGORIES,t as categoryIcon,a as categoryOf};
|
package/src/store/comments.mjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{readFileSync as E,writeFileSync as
|
|
2
|
-
`),F(`${
|
|
3
|
-
`),
|
|
1
|
+
import{readFileSync as E,writeFileSync as y,existsSync as $,mkdirSync as I,renameSync as F,rmSync as J}from"node:fs";import{dirname as C,join as l}from"node:path";import{categoryOf as L}from"./categories.mjs";import{DOCS as M,FRAMES as R,docSlug as G}from"./thread.mjs";import{CATEGORIES as ee,categoryOf as te}from"./categories.mjs";import{stateOf as re,STATE_LABEL as oe}from"./status.mjs";const v=r=>{const e=String(r??"").split(/[/\\]/).pop();return/^[\w-][\w.-]*\.(png|jpe?g|webp|gif|webm|m4a|pdf|docx?)$/i.test(e)?e:""},_=r=>{const e=/^data:(application\/[\w.+-]+)((?:;[\w=.-]+)*);base64,(.+)$/s.exec(String(r||""));if(e){const x=Object.keys(M).find(O=>M[O]===e[1]);return x?{base64:e[3],voice:!1,ext:x,type:e[1],slug:G(/;name=([\w.-]+)/.exec(e[2])?.[1])}:null}const n=/^data:(image|video|audio)\/(png|jpeg|webp|gif|webm|mp4)(?:;[\w=.-]+)*;base64,(.+)$/s.exec(String(r||""));if(!n)return null;const[,o,t,c]=n;return(o==="image"?!/^(png|jpeg|webp|gif)$/.test(t):o==="video"?t!=="webm":!/^(webm|mp4)$/.test(t))?null:{base64:c,voice:o==="audio",ext:t==="jpeg"?"jpg":t==="mp4"?"m4a":t,type:`${o}/${t}`}},B=(r,e,n,o)=>`${n.voice?"voice-":R.includes(o)?`${o}-`:""}${r}-${e}${n.slug?`.${n.slug}`:""}.${n.ext}`,N=r=>Math.max(r.nextId||0,r.comments.reduce((e,n)=>Math.max(e,n.id),0)+1);function q(r,{route:e,selector:n,rx:o,ry:t,text:c,label:d,viewport:x,breakpoint:O,browser:D,device:A,tag:j,classes:i,nth:p,category:g,suggest:s,assignee:a,ctx:m,logs:u,host:S,priority:b,shared:f,stage:h}){const w={id:N(r),route:e,selector:n,rx:o,ry:t,text:c,tag:j||"",classes:i||[],nth:Number.isInteger(p)?p:null,label:d||"",ctx:m||"",viewport:x||null,breakpoint:O||"desktop",browser:D||"",device:A||"",category:L(g).id,status:"open",note:"",replies:[],doneBy:null,images:[],...s?{suggest:s}:{},...a?{assignee:a}:{},...b?{priority:b}:{},...h?{stage:h}:{},...f?{shared:!0}:{},...S?{host:S}:{},...u?.length?{logs:u}:{},createdAt:new Date().toISOString(),updatedAt:null};return r.comments.push(w),r.nextId=w.id+1,w}function z(r,e,n,o,t,c){const d=r.comments.find(x=>x.id===Number(e));return d?((d.replies||=[]).push({author:n,text:o,at:new Date().toISOString(),...t&&t!=="claude"?{agent:t}:{},...c?{by:c}:{}}),d.updatedAt=new Date().toISOString(),d):null}function H(r,e,n,o){const t=r.comments.find(d=>d.id===Number(e)),c=n?t?.replies?.find(d=>d.at===n&&d.author==="you"):t;return c?(c.text=o,t.updatedAt=new Date().toISOString(),t):null}function K(r,e,n){const o=r.comments.find(c=>c.id===Number(e)),t=o?.replies?.find(c=>c.at===n&&c.author==="you");return t?(t.text="",t.deleted=!0,delete t.mentions,o.updatedAt=new Date().toISOString(),o):null}function P(r,e,n){const o=r.comments.find(t=>t.id===Number(e));return o?(Object.assign(o,n,{updatedAt:new Date().toISOString()}),o):null}function Y(r){const e=l(r,"feedback","comments.json"),n=l(r,"feedback","images"),o=l(r,"feedback","archive"),t=l(o,"images"),c=i=>`feedback/images/${i}`;return{root:r,file:e,imageDir:n,archiveDir:o,archiveImageDir:t,load:()=>$(e)?JSON.parse(E(e,"utf8")):{comments:[]},save:i=>{I(C(e),{recursive:!0}),y(`${e}.tmp`,JSON.stringify(i,null,2)+`
|
|
2
|
+
`),F(`${e}.tmp`,e)},attach:(i,p,g,s)=>{const a=i.comments.find(b=>b.id===Number(p)),m=_(g);if(!a||!m)return null;I(n,{recursive:!0});let u=Date.now();for(;$(l(n,B(a.id,u,m,s)));)u++;const S=B(a.id,u,m,s);return y(l(n,S),Buffer.from(m.base64,"base64")),(a.images||=[]).push(c(S)),a.updatedAt=new Date().toISOString(),c(S)},detach:(i,p,g)=>{const s=i.comments.find(u=>u.id===Number(p)),a=v(g),m=a&&s?.images?.find(u=>v(u)===a);return m?(J(l(n,a),{force:!0}),s.images=s.images.filter(u=>u!==m),s.updatedAt=new Date().toISOString(),!0):!1},remove:(i,p)=>{const g=i.comments.find(s=>s.id===Number(p));if(!g)return!1;for(const s of g.images||[])v(s)&&J(l(n,v(s)),{force:!0});return i.comments=i.comments.filter(s=>s.id!==Number(p)),!0},add:q,patch:P,reply:z,edit:H,unsay:K,nextId:N,prune:(i,{dry:p=!1,date:g=new Date().toISOString().slice(0,10)}={})=>{const s=i.comments.filter(f=>f.status==="done"),a=i.comments.filter(f=>f.status!=="done"),m=l(o,`comments-${g}.json`);if(p||!s.length)return{moving:s,keeping:a,archiveFile:m,images:s.flatMap(f=>f.images||[])};I(t,{recursive:!0});const u=[];for(const f of s)f.images=(f.images||[]).map(h=>{const w=v(h);if(!w)return h;const k=l(n,w),T=l(t,w);return $(k)&&F(k,T),u.push(w),`feedback/archive/images/${w}`});const S=$(m)?JSON.parse(E(m,"utf8")).comments||[]:[],b=new Set(S.map(f=>f.id));return y(m,JSON.stringify({comments:[...S,...s.filter(f=>!b.has(f.id))]},null,2)+`
|
|
3
|
+
`),i.nextId=N(i),i.comments=a,{moving:s,keeping:a,archiveFile:m,images:u}}}}export{ee as CATEGORIES,oe as STATE_LABEL,q as add,te as categoryOf,Y as createStore,H as edit,B as mediaName,_ as mediaOf,N as nextId,P as patch,z as reply,v as shotName,re as stateOf,K as unsay};
|
package/src/store/thread.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const O=["before","after"],d=e=>/(?:^|\/)(before|after)-[^/]*$/.exec(String(e))?.[1]??null,y=e=>{const t={};for(const n of e?.images||[]){const o=d(n);o&&(t[o]=n)}return t},u={pdf:"application/pdf",doc:"application/msword",docx:"application/vnd.openxmlformats-officedocument.wordprocessingml.document"},f=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]])),b=e=>String(e??"").replace(/\.[^.]*$/,"").toLowerCase().replace(/[а-яёєіїґ]/g,t=>f[t]??"").normalize("NFKD").replace(/[^\w-]+/g,"-").replace(/^[-_]+|-+$/g,"").slice(0,60),N=e=>{const t=String(e??"");if(t.startsWith("data:")){const o=/^data:([^;,]+)((?:;[^;,]*)*)[;,]/.exec(t),r=o&&Object.keys(u).find(s=>u[s]===o[1]);return r?`${/;name=([\w-]+)/.exec(o[2])?.[1]||"document"}.${r}`:null}const n=/-\d+(?:\.([\w-]+))?\.(pdf|docx?)(?:\?|$)/i.exec(t.split("/").pop());return n?`${n[1]||"document"}.${n[2].toLowerCase()}`:null},m=e=>{const t=[{author:"you",text:e.text,at:e.createdAt,by:e.by,byName:e.byName,images:[]},...e.note?[{author:"claude",text:e.note,at:e.updatedAt,images:[]}]:[],...(e.replies||[]).map(n=>({...n,images:[]}))];for(const n of e.images||[]){if(d(n))continue;const o=Number(/-(\d+)(?:\.[\w-]+)?\.\w+$/.exec(n)?.[1]);let r=0;t.forEach((s,i)=>{Date.parse(s.at)<=o&&(r=i)}),t[r].images.push(n)}return t.filter(n=>!n.deleted)},I=e=>e.nickname||e.name||e.email,$=(e,t)=>{const n=String(e||"").toLowerCase();return n.includes("@")?[...new Set(t.filter(o=>[o.name,o.nickname,o.email].some(r=>{if(!r)return!1;const s=n.indexOf("@"+r.toLowerCase());return s!==-1&&!/[\p{L}\p{N}_.-]/u.test(n[s+r.length+1]??"")})).map(o=>o.email))]:[]},x={claude:"Claude",codex:"Codex",gemini:"Gemini",cursor:"Cursor",copilot:"Copilot",windsurf:"Windsurf",amp:"Amp",aider:"Aider",opencode:"OpenCode",agent:"AI agent"},h=e=>x[e]||(e?"AI agent":"Claude"),D="3.6 3.6 10.8 10.8",w="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",p=e=>typeof e=="string"&&e.startsWith("agent:")?e.slice(6):null,l=e=>e==="claude"||p(e)!=null,A=/^[^\s@]+@[^\s@]+$/,_=e=>{if(e==="claude")return e;if(typeof e!="string"||e.length>210)return null;const t=e.toLowerCase();return A.test(p(t)??t)?t:null},L=["new","approved","progress","review","waiting"],c=e=>L.includes(e?.stage)?e.stage:l(e?.assignee)?"approved":"new",E=(e,t)=>{const n=p(e.assignee);return c(e)==="approved"&&(!e.assignee||e.assignee==="claude"||n!=null&&(t===void 0||n===t))&&!g(e)},k=()=>[{assignee:"claude",handle:"Claude",owner:null}],T=(e,t=[])=>{const n=String(e||"").toLowerCase();let o=null,r=-1;for(const s of k()){const i="@"+s.handle.toLowerCase();for(let a=n.indexOf(i);a!==-1;a=n.indexOf(i,a+1))!/[\p{L}\p{N}_.-]/u.test(n[a+i.length]??"")&&a>r&&(r=a,o=s.assignee)}return o},v=(e,t,n=o=>o)=>h(e)+(t?` \xB7 ${n(t)}`:""),M=2*36e5,S=(e,t=Date.now())=>e?.working&&e.status!=="done"&&t-Date.parse(e.working.at)<M?e.working:null,C=e=>/@guest\.notemend\.com$/i.test(String(e||"")),g=e=>C(e.by)&&!e.approvedBy,W=(e,t=Date.now())=>{if(!e)return null;if(e.status==="done")return e.doneBy==="claude"?"review":l(e.assignee)?"done":null;if(g(e))return"held";if(!l(e.assignee))return null;const n=m(e),o=n[n.length-1];return n.length>1&&o.author==="claude"&&!(e.reopenedAt&&Date.parse(e.reopenedAt)>=Date.parse(o.at))?"asks":S(e,t)?"working":e.working?"stuck":c(e)==="approved"?"queued":null},G={held:0,queued:2,asks:6,working:6,stuck:6,review:10,done:12},H=w.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),R={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"},B=(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};export{x as AGENTS,D as AI_BOX,w as AI_RAYS,H as AI_RAYS_CW,u as DOCS,O as FRAMES,L as STAGES,G as STEP_RAYS,R as UPDATE_HOW,M as WORKING_TTL,k as agentHandles,v as agentLabel,T as agentMentioned,h as agentName,p as agentOwner,W as agentStep,_ as cleanAssignee,N as docOf,b as docSlug,E as forAgentOf,d as frameOf,y as framesOf,I as handleOf,g as held,C as isGuest,$ as mentionsIn,B as newer,c as stageOf,m as threadOf,l as toAgent,S as workingOn};
|
package/store.d.ts
CHANGED
|
@@ -22,7 +22,9 @@ export interface Comment {
|
|
|
22
22
|
export interface Db { comments: Comment[]; nextId?: number }
|
|
23
23
|
export type NewComment = Partial<Omit<Comment, 'id' | 'status' | 'replies' | 'images' | 'createdAt' | 'updatedAt'>> & Pick<Comment, 'route' | 'selector' | 'rx' | 'ry' | 'text'>;
|
|
24
24
|
|
|
25
|
-
export interface Category { id: string; label: string; color: string }
|
|
25
|
+
export interface Category { id: string; label: string; color: string; icon: string }
|
|
26
|
+
/** A type's icon as an inline <svg>, stroked in its colour */
|
|
27
|
+
export function categoryIcon(k: Category, size?: number): string;
|
|
26
28
|
export const CATEGORIES: Category[];
|
|
27
29
|
export function categoryOf(id?: string | null): Category;
|
|
28
30
|
/** open, done (by a person) or claude (by an agent, waiting for a look) */
|
package/thread.d.ts
CHANGED
|
@@ -32,7 +32,24 @@ export function workingOn(c: { working?: Working | null; status?: string } | nul
|
|
|
32
32
|
export function isGuest(email?: string | null): boolean;
|
|
33
33
|
/** A guest's thread the studio has not approved yet: no agent takes it */
|
|
34
34
|
export function held(c: { by?: string | null; approvedBy?: string | null }): boolean;
|
|
35
|
+
/** The agents a message can @mention: the shared queue, and each person's own */
|
|
36
|
+
export function agentHandles(people?: { email: string; name?: string | null; agent_name?: string | null }[]): { assignee: string; handle: string; owner: string | null }[];
|
|
37
|
+
/** The agent a text hands its thread to: the last one it @mentions, else null */
|
|
38
|
+
export function agentMentioned(text: string, people?: { email: string; name?: string | null; agent_name?: string | null }[]): string | null;
|
|
39
|
+
export type AgentStep = "held" | "queued" | "asks" | "working" | "stuck" | "review" | "done";
|
|
40
|
+
/** Where a thread is on an agent's way; null when no agent is in it */
|
|
41
|
+
export function agentStep(c: Record<string, any> | null | undefined, now?: number): AgentStep | null;
|
|
42
|
+
/** How far along each step is: rays of the agent mark lit, of 12 */
|
|
43
|
+
export const STEP_RAYS: Record<AgentStep, number>;
|
|
44
|
+
/** The agent mark's rays one by one, clockwise from the top (viewBox AI_BOX) */
|
|
45
|
+
export const AI_RAYS_CW: string[];
|
|
35
46
|
/** How each kind of install is brought up to date: plugin, npx, project, desktop, source */
|
|
36
47
|
export const UPDATE_HOW: Record<string, string>;
|
|
37
48
|
/** Is version a newer than b (x.y.z) */
|
|
38
49
|
export function newer(a: string, b: string): boolean;
|
|
50
|
+
/** The documents a message may carry, by extension: their MIME types */
|
|
51
|
+
export const DOCS: { pdf: string; doc: string; docx: string };
|
|
52
|
+
/** A file's own name made safe for a filed one: lower-case word characters and dashes */
|
|
53
|
+
export function docSlug(name: string): string;
|
|
54
|
+
/** What to call a document — "brief.pdf" — by its path or data: URL; null when it is not one */
|
|
55
|
+
export function docOf(path: string): string | null;
|