@pipeup/agents 0.8.1 → 0.8.2
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/dist/agents.esm.js +2 -2
- package/dist/agents.min.js +2 -2
- package/dist/pipeup+agents.min.js +3 -3
- package/package.json +2 -2
package/dist/agents.esm.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var E=/^\/__pipeup\/[A-Za-z0-9_-]{16,}$/;function
|
|
2
|
-
`)}var
|
|
1
|
+
var E=/^\/__pipeup\/[A-Za-z0-9_-]{16,}$/;function v(e){let n=document.documentElement,t=n.getAttribute("data-pipeup-link")??"",o=E.test(t),s=!1,i=0,h=()=>{};async function r(){let c=!1;try{c=(await fetch(`${t}/comments`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(await e.snapshot())})).ok}catch{}if(!c)throw new Error("pipeup: the link to your agent isn't reachable; your comments are safe here")}let p=()=>{window.clearTimeout(i),h(),h=()=>{},s=!1};return{enabled:o,agent:n.getAttribute("data-pipeup-link-agent")??"",file:n.getAttribute("data-pipeup-link-file")??"",on:()=>s,set:async c=>{if(o){if(!c){p(),e.refresh();return}await r(),s=!0,h=e.changes(()=>{window.clearTimeout(i),i=window.setTimeout(()=>{r().catch(g=>{p(),e.refresh(),globalThis.reportError?.(g)})},300)}),e.refresh()}},destroy:p}}function P(e){if(!e)return{cli:"npx --yes pipeup@0",fallback:null};let t=`npx --yes pipeup@${e.split(".")[0]??"0"}`;return e.includes("-")?{cli:`npx --yes pipeup@${e}`,fallback:t}:{cli:t,fallback:null}}function S(e,n=""){if(n)return{page:n,served:!1};try{let t=new URL(e),o=decodeURIComponent(t.pathname);return o.endsWith("/")&&(o+="index.html"),t.protocol==="file:"?{page:/^\/[A-Za-z]:\//.test(o)?o.slice(1):o,served:!1}:{page:o,served:!0}}catch{return{page:"<the page's HTML file>",served:!1}}}var T=e=>{try{let n=new URL(e);return n.protocol==="file:"?decodeURIComponent(n.pathname).replace(/^\/([A-Za-z]:\/)/,"$1"):n.href}catch{return e}};function A(e){let n=p=>p.replace(/\s+/g," ").trim(),{cli:t,fallback:o}=P(e.version),s=`https://pipeup-ai.github.io/pipeup/${e.version?.includes("-")?"next/":""}`,{page:i,served:h}=S(e.url,e.file),r=h?`<the HTML file your site serves at ${i}>`:i;return[`Act on the review comments on this page, which uses Pipeup: ${n(e.title)} (${n(e.url)}).`,"",e.file?`1. Read the comments: \`${t} comments ${e.file}\` (add --all for resolved ones). If it says nothing is shared, ask me to switch on Share with my agent.`:"1. Read the comments. Open the page in a browser and run `await Pipeup.comments()`, then read `.markdown`. If you can't run the page, ask me to paste its comments (Copy comments \u203A As Markdown).","2. Work through the open threads in order. For each, make the change I approved, or say why you didn't. Ask me before changing anything I haven't approved, and answer a question with an answer.",e.replies?`3. Answer in each thread: \`${t} reply --page ${r} --thread <Thread id> "what you changed and where" --addressed "short note"\`. Pass that file, the one that runs Pipeup, not a file it shows. It writes ${n(T(e.replies))}, which the page reads by itself.`+(e.listed?"":` The page doesn't list you yet. Ask me first; after my yes, run \`${t} agent --name <your name> --page ${r} --yes\`.`)+(o?` If npm refuses ${t.split(" ").at(-1)}, use ${o.split(" ").at(-1)}: it answers these commands the same way.`:""):"3. Tell me what you would reply in each thread, in words I can paste.","4. Only mark a thread addressed. Never resolve, reopen, edit or delete: I close threads. Keep your key out of the page and its folder, and never answer as me.","",`Guide: ${s}skills/pipeup-apply/SKILL.md`].join(`
|
|
2
|
+
`)}var I=/^[A-Za-z0-9_-]{43}$/,x="pipeupReplies";var L=/^AI assistant\s*·?\s*/;function w(e=document.documentElement){let n=e.getAttribute("data-pipeup-agents")??"";return[...new Set(n.split(/[\s,]+/).filter(t=>I.test(t)))]}function b(e=location,n=document.documentElement){let t=n.getAttribute("data-pipeup-replies");try{let o=e.href.split(/[?#]/)[0],s=new URL(t??(/\/$/.test(o)?`${o}index.replies.js`:o.replace(/\.[^./]*$/,"")+".replies.js"),e.href),i=s.protocol==="file:"?e.protocol==="file:":s.origin===e.origin;return i||console.warn("pipeup: the replies file must be on this site or this computer; ignoring it"),i?s.href:null}catch{return null}}function $(e){let n=w(),t=0,o="",s=null;async function i(){let u=globalThis[x];if(!Array.isArray(u))return 0;let d=u.splice(0),y=[];for(let m of d){let f=m;if(!(f?.format!=="pipeup-replies"||f.doc!==e.document.id||!Array.isArray(f.ops)))for(let a of f.ops){let l=a?.body;l&&n.includes(l.author)&&(l.kind==="reply"||l.kind==="addressed"||l.kind==="react"||l.kind==="unreact")?(y.push(a),(l.name==="AI assistant"||l.name.startsWith("AI assistant "))&&(o=l.name.replace(L,""))):t++}}return y.length?e.merge(y):0}function h(){let u=b();return u?(s?.remove(),new Promise((d,y)=>{let m=document.createElement("script");s=m,m.src=`${u}?${Date.now()}`;let f=l=>{window.clearTimeout(a),m.remove(),s===m&&(s=null),l?y(new Error(`pipeup: ${l}`)):d()},a=window.setTimeout(()=>f("the replies file didn't answer"),4e3);m.addEventListener("load",()=>f()),m.addEventListener("error",()=>f("there is no replies file yet")),e.overlay().append(m)})):Promise.reject(new Error("pipeup: the replies file can't be read from here"))}async function r(){if(!n.length)return 0;let u=await i();return await h(),u+await i()}let p=!1,c=()=>{p||document.hidden||(p=!0,r().catch(()=>{}).finally(()=>p=!1))},g=0;return n.length?(c(),g=window.setInterval(c,4e3),document.addEventListener("visibilitychange",c)):i(),{enabled:n.length>0,ignored:()=>t,who:()=>o,check:r,tally:u=>{let d=u.filter(a=>!a.resolved),y=a=>a.root.replies.some(l=>n.includes(l.author)),m=new Set(u.map(a=>a.id));return{stray:new Set(e.document.ops().filter(a=>n.includes(a.body.author)&&!m.has(a.body.thread)).map(a=>a.body.thread)).size,open:d.length,answered:d.filter(y).length,addressed:d.filter(a=>a.addressed).length}},destroy:()=>{window.clearInterval(g),document.removeEventListener("visibilitychange",c),s?.remove()}}}var M=()=>globalThis.Pipeup??{},R=["M10 8h8a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2h-8a2 2 0 0 1-2-2v-8a2 2 0 0 1 2-2z","M16 8V6a2 2 0 0 0-2-2H6a2 2 0 0 0-2 2v8a2 2 0 0 0 2 2h2"],C=["M21 12L3.5 4.5 6.2 12l-2.7 7.5zM6.2 12H13"],H="Reads a replies file next to this page. When the page is shown through pipeup watch, and only after you switch it on, it sends this page's comments to the program running on this computer. Nothing leaves this computer.",k=e=>e instanceof Error?e.message.replace(/^pipeup: /,""):"Something went wrong";async function O(e,n){try{await navigator.clipboard.writeText(e);return}catch{}let t=document.createElement("textarea");t.value=e,t.setAttribute("readonly",""),t.style.cssText="position:fixed;opacity:0;pointer-events:none",n.append(t),t.select();let o=document.execCommand("copy");if(t.remove(),!o)throw new Error("pipeup: your browser blocked copying")}function N(){return{id:"agents",api:1,version:"0.6.0",needs:["menu","status","notify","listnote"],network:{when:"page-configured",to:["page"],says:H},setup(e){let n=$(e),t=v({snapshot:async()=>{let r=M();if(!r.comments)throw new Error("pipeup: this page has no Pipeup to read comments from");let[p,c]=await Promise.all([r.comments(),r.comments({all:!0})]);return{v:1,at:new Date().toISOString(),title:document.title,open:p,all:c}},changes:r=>e.document.onChange(r),refresh:()=>s()}),o=()=>n.who()||t.agent,s=()=>{if(e.setStatus(n.enabled||t.enabled?{text:t.on()?`Sharing comments with ${o()||"your agent"}`:`${o()||"An AI agent"} can answer comments here`}:null),!n.enabled)return e.setListNote(null);let r=n.tally(e.document.threads()),p=o()||"An agent",c=r.answered?`${p} has answered ${r.answered} of ${r.open} open comments${r.addressed?`; ${r.addressed} ${r.addressed===1?"is":"are"} marked addressed`:""}`:"No replies from an agent yet",g=n.ignored(),u=(t.on()?`Sharing with ${t.agent||"your agent"} \xB7 `:"")+c+(g?` \xB7 ${g} from other writers ignored`:"")+(r.stray?` \xB7 replies for ${r.stray} comment${r.stray===1?"":"s"} this page doesn't have`:"");e.setListNote({text:u,action:{label:"Check for replies",run:async()=>{try{let d=await n.check();e.notify(d?`${d} new ${d===1?"reply":"replies"}`:"No new replies")}catch(d){e.notify(k(d))}finally{s()}}}})},i=[e.addMenuItem({id:"prompt",icon:R,label:()=>"Copy a prompt for my agent",hint:()=>"Tells an AI agent where the comments are and how to answer them",select:async()=>{try{await O(A({title:document.title,url:location.href,replies:b(),file:t.enabled?t.file:"",listed:w().length>0,version:globalThis.Pipeup?.VERSION}),e.overlay()),e.notify("Copied a prompt for your agent")}catch(r){e.notify(k(r))}}})];t.enabled&&i.push(e.addMenuItem({id:"link",icon:C,label:()=>"Share with my agent",hint:()=>"Sends this page's comments to the program running on this computer, and nothing else",checked:()=>t.on(),select:async()=>{try{await t.set(!t.on())}catch(r){e.notify(k(r))}s()}}));let h=e.document.onChange(s);return s(),()=>{h(),n.destroy(),t.destroy()}}}}export{N as default};
|
package/dist/agents.min.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";(()=>{function b(e){let n=globalThis;(n.pipeupAddons||=[]).push(e),typeof addEventListener=="function"&&addEventListener("load",()=>{n.Pipeup||console.error(`pipeup: the "${e.id}" add-on needs Pipeup on the page too; load pipeup.min.js.`)},{once:!0})}var
|
|
2
|
-
`)}var
|
|
1
|
+
"use strict";(()=>{function b(e){let n=globalThis;(n.pipeupAddons||=[]).push(e),typeof addEventListener=="function"&&addEventListener("load",()=>{n.Pipeup||console.error(`pipeup: the "${e.id}" add-on needs Pipeup on the page too; load pipeup.min.js.`)},{once:!0})}var se=2n**256n-2n**32n-977n;var L=/^\/__pipeup\/[A-Za-z0-9_-]{16,}$/;function P(e){let n=document.documentElement,t=n.getAttribute("data-pipeup-link")??"",o=L.test(t),i=!1,a=0,m=()=>{};async function r(){let c=!1;try{c=(await fetch(`${t}/comments`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(await e.snapshot())})).ok}catch{}if(!c)throw new Error("pipeup: the link to your agent isn't reachable; your comments are safe here")}let d=()=>{window.clearTimeout(a),m(),m=()=>{},i=!1};return{enabled:o,agent:n.getAttribute("data-pipeup-link-agent")??"",file:n.getAttribute("data-pipeup-link-file")??"",on:()=>i,set:async c=>{if(o){if(!c){d(),e.refresh();return}await r(),i=!0,m=e.changes(()=>{window.clearTimeout(a),a=window.setTimeout(()=>{r().catch(y=>{d(),e.refresh(),globalThis.reportError?.(y)})},300)}),e.refresh()}},destroy:d}}function C(e){if(!e)return{cli:"npx --yes pipeup@0",fallback:null};let t=`npx --yes pipeup@${e.split(".")[0]??"0"}`;return e.includes("-")?{cli:`npx --yes pipeup@${e}`,fallback:t}:{cli:t,fallback:null}}function R(e,n=""){if(n)return{page:n,served:!1};try{let t=new URL(e),o=decodeURIComponent(t.pathname);return o.endsWith("/")&&(o+="index.html"),t.protocol==="file:"?{page:/^\/[A-Za-z]:\//.test(o)?o.slice(1):o,served:!1}:{page:o,served:!0}}catch{return{page:"<the page's HTML file>",served:!1}}}var _=e=>{try{let n=new URL(e);return n.protocol==="file:"?decodeURIComponent(n.pathname).replace(/^\/([A-Za-z]:\/)/,"$1"):n.href}catch{return e}};function T(e){let n=d=>d.replace(/\s+/g," ").trim(),{cli:t,fallback:o}=C(e.version),i=`https://pipeup-ai.github.io/pipeup/${e.version?.includes("-")?"next/":""}`,{page:a,served:m}=R(e.url,e.file),r=m?`<the HTML file your site serves at ${a}>`:a;return[`Act on the review comments on this page, which uses Pipeup: ${n(e.title)} (${n(e.url)}).`,"",e.file?`1. Read the comments: \`${t} comments ${e.file}\` (add --all for resolved ones). If it says nothing is shared, ask me to switch on Share with my agent.`:"1. Read the comments. Open the page in a browser and run `await Pipeup.comments()`, then read `.markdown`. If you can't run the page, ask me to paste its comments (Copy comments \u203A As Markdown).","2. Work through the open threads in order. For each, make the change I approved, or say why you didn't. Ask me before changing anything I haven't approved, and answer a question with an answer.",e.replies?`3. Answer in each thread: \`${t} reply --page ${r} --thread <Thread id> "what you changed and where" --addressed "short note"\`. Pass that file, the one that runs Pipeup, not a file it shows. It writes ${n(_(e.replies))}, which the page reads by itself.`+(e.listed?"":` The page doesn't list you yet. Ask me first; after my yes, run \`${t} agent --name <your name> --page ${r} --yes\`.`)+(o?` If npm refuses ${t.split(" ").at(-1)}, use ${o.split(" ").at(-1)}: it answers these commands the same way.`:""):"3. Tell me what you would reply in each thread, in words I can paste.","4. Only mark a thread addressed. Never resolve, reopen, edit or delete: I close threads. Keep your key out of the page and its folder, and never answer as me.","",`Guide: ${i}skills/pipeup-apply/SKILL.md`].join(`
|
|
2
|
+
`)}var D=/^[A-Za-z0-9_-]{43}$/,H="pipeupReplies";var N=/^AI assistant\s*·?\s*/;function x(e=document.documentElement){let n=e.getAttribute("data-pipeup-agents")??"";return[...new Set(n.split(/[\s,]+/).filter(t=>D.test(t)))]}function k(e=location,n=document.documentElement){let t=n.getAttribute("data-pipeup-replies");try{let o=e.href.split(/[?#]/)[0],i=new URL(t??(/\/$/.test(o)?`${o}index.replies.js`:o.replace(/\.[^./]*$/,"")+".replies.js"),e.href),a=i.protocol==="file:"?e.protocol==="file:":i.origin===e.origin;return a||console.warn("pipeup: the replies file must be on this site or this computer; ignoring it"),a?i.href:null}catch{return null}}function U(e){let n=x(),t=0,o="",i=null;async function a(){let u=globalThis[H];if(!Array.isArray(u))return 0;let l=u.splice(0),g=[];for(let f of l){let h=f;if(!(h?.format!=="pipeup-replies"||h.doc!==e.document.id||!Array.isArray(h.ops)))for(let s of h.ops){let p=s?.body;p&&n.includes(p.author)&&(p.kind==="reply"||p.kind==="addressed"||p.kind==="react"||p.kind==="unreact")?(g.push(s),(p.name==="AI assistant"||p.name.startsWith("AI assistant "))&&(o=p.name.replace(N,""))):t++}}return g.length?e.merge(g):0}function m(){let u=k();return u?(i?.remove(),new Promise((l,g)=>{let f=document.createElement("script");i=f,f.src=`${u}?${Date.now()}`;let h=p=>{window.clearTimeout(s),f.remove(),i===f&&(i=null),p?g(new Error(`pipeup: ${p}`)):l()},s=window.setTimeout(()=>h("the replies file didn't answer"),4e3);f.addEventListener("load",()=>h()),f.addEventListener("error",()=>h("there is no replies file yet")),e.overlay().append(f)})):Promise.reject(new Error("pipeup: the replies file can't be read from here"))}async function r(){if(!n.length)return 0;let u=await a();return await m(),u+await a()}let d=!1,c=()=>{d||document.hidden||(d=!0,r().catch(()=>{}).finally(()=>d=!1))},y=0;return n.length?(c(),y=window.setInterval(c,4e3),document.addEventListener("visibilitychange",c)):a(),{enabled:n.length>0,ignored:()=>t,who:()=>o,check:r,tally:u=>{let l=u.filter(s=>!s.resolved),g=s=>s.root.replies.some(p=>n.includes(p.author)),f=new Set(u.map(s=>s.id));return{stray:new Set(e.document.ops().filter(s=>n.includes(s.body.author)&&!f.has(s.body.thread)).map(s=>s.body.thread)).size,open:l.length,answered:l.filter(g).length,addressed:l.filter(s=>s.addressed).length}},destroy:()=>{window.clearInterval(y),document.removeEventListener("visibilitychange",c),i?.remove()}}}var z=()=>globalThis.Pipeup??{},K=["M10 8h8a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2h-8a2 2 0 0 1-2-2v-8a2 2 0 0 1 2-2z","M16 8V6a2 2 0 0 0-2-2H6a2 2 0 0 0-2 2v8a2 2 0 0 0 2 2h2"],j=["M21 12L3.5 4.5 6.2 12l-2.7 7.5zM6.2 12H13"],F="Reads a replies file next to this page. When the page is shown through pipeup watch, and only after you switch it on, it sends this page's comments to the program running on this computer. Nothing leaves this computer.",S=e=>e instanceof Error?e.message.replace(/^pipeup: /,""):"Something went wrong";async function Z(e,n){try{await navigator.clipboard.writeText(e);return}catch{}let t=document.createElement("textarea");t.value=e,t.setAttribute("readonly",""),t.style.cssText="position:fixed;opacity:0;pointer-events:none",n.append(t),t.select();let o=document.execCommand("copy");if(t.remove(),!o)throw new Error("pipeup: your browser blocked copying")}function E(){return{id:"agents",api:1,version:"0.6.0",needs:["menu","status","notify","listnote"],network:{when:"page-configured",to:["page"],says:F},setup(e){let n=U(e),t=P({snapshot:async()=>{let r=z();if(!r.comments)throw new Error("pipeup: this page has no Pipeup to read comments from");let[d,c]=await Promise.all([r.comments(),r.comments({all:!0})]);return{v:1,at:new Date().toISOString(),title:document.title,open:d,all:c}},changes:r=>e.document.onChange(r),refresh:()=>i()}),o=()=>n.who()||t.agent,i=()=>{if(e.setStatus(n.enabled||t.enabled?{text:t.on()?`Sharing comments with ${o()||"your agent"}`:`${o()||"An AI agent"} can answer comments here`}:null),!n.enabled)return e.setListNote(null);let r=n.tally(e.document.threads()),d=o()||"An agent",c=r.answered?`${d} has answered ${r.answered} of ${r.open} open comments${r.addressed?`; ${r.addressed} ${r.addressed===1?"is":"are"} marked addressed`:""}`:"No replies from an agent yet",y=n.ignored(),u=(t.on()?`Sharing with ${t.agent||"your agent"} \xB7 `:"")+c+(y?` \xB7 ${y} from other writers ignored`:"")+(r.stray?` \xB7 replies for ${r.stray} comment${r.stray===1?"":"s"} this page doesn't have`:"");e.setListNote({text:u,action:{label:"Check for replies",run:async()=>{try{let l=await n.check();e.notify(l?`${l} new ${l===1?"reply":"replies"}`:"No new replies")}catch(l){e.notify(S(l))}finally{i()}}}})},a=[e.addMenuItem({id:"prompt",icon:K,label:()=>"Copy a prompt for my agent",hint:()=>"Tells an AI agent where the comments are and how to answer them",select:async()=>{try{await Z(T({title:document.title,url:location.href,replies:k(),file:t.enabled?t.file:"",listed:x().length>0,version:globalThis.Pipeup?.VERSION}),e.overlay()),e.notify("Copied a prompt for your agent")}catch(r){e.notify(S(r))}}})];t.enabled&&a.push(e.addMenuItem({id:"link",icon:j,label:()=>"Share with my agent",hint:()=>"Sends this page's comments to the program running on this computer, and nothing else",checked:()=>t.on(),select:async()=>{try{await t.set(!t.on())}catch(r){e.notify(S(r))}i()}}));let m=e.document.onChange(i);return i(),()=>{m(),n.destroy(),t.destroy()}}}}b(E());})();
|