@pipeup/agents 0.9.1 → 1.0.0
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 +1 -1
- package/dist/agents.min.js +1 -1
- package/dist/pipeup+agents.min.js +2 -2
- package/package.json +2 -2
package/dist/agents.esm.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
var Y=/^\/__pipeup\/[A-Za-z0-9_-]{16,}$/;function B(e){let t=document.documentElement,s=t.getAttribute("data-pipeup-link")??"",r=Y.test(s),n=!1,i=0,p=()=>{};async function c(){let l=!1;try{l=(await fetch(`${s}/comments`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(await e.snapshot())})).ok}catch{}if(!l)throw new Error("pipeup: the link to your agent isn't reachable; your comments are safe here")}let a=()=>{window.clearTimeout(i),p(),p=()=>{},n=!1};return{enabled:r,agent:t.getAttribute("data-pipeup-link-agent")??"",file:t.getAttribute("data-pipeup-link-file")??"",on:()=>n,set:async l=>{if(r){if(!l){a(),e.refresh();return}await c(),n=!0,p=e.changes(()=>{window.clearTimeout(i),i=window.setTimeout(()=>{c().catch(o=>{a(),e.refresh(),globalThis.reportError?.(o)})},300)}),e.refresh()}},destroy:a}}var G=/```[ \t]*pipeup-replies[^\n]*\n([\s\S]*?)(?:\n[ \t]*```|$)/g,Z=/^[ \t]*(agent|thread|reply|addressed|signed)[ \t]*:[ \t]?(.*)$/i,I="Agent";function C(e){let t=[];for(let[,s]of e.replace(/\r\n?/g,`
|
|
2
2
|
`).matchAll(G)){let r=I,n=null,i=null;for(let p of s.split(`
|
|
3
3
|
`)){let c=Z.exec(p);if(c){let a=c[1].toLowerCase(),l=c[2].trim();a==="agent"?(r=l||I,i=null):a==="thread"?(n={agent:r,thread:l,reply:"",addressed:"",signed:""},t.push(n),i=null):n&&(n[a]=l,i=a)}else n&&i&&i!=="signed"&&p.trim()?n[i]=`${n[i]}
|
|
4
|
-
${p.trim()}`:n&&i==="signed"&&(n.signed+=p.trim())}}return t.filter(s=>s.thread&&s.reply)}var L=(e,t)=>e.replace(/\s+/g," ").trim()===t.replace(/\s+/g," ").trim();function q(e){try{let t=e.replace(/-/g,"+").replace(/_/g,"/"),s=Uint8Array.from(atob(t+"=".repeat((4-t.length%4)%4)),r=>r.charCodeAt(0));return JSON.parse(new TextDecoder().decode(s))}catch{return null}}async function M(e,t){let s=new Set(t.threads.map(n=>n.id)),r=[];for(let n of e){if(!s.has(n.thread)){r.push({kind:"gone",entry:n});continue}if(!n.signed){r.push({kind:"unsigned",entry:n,why:"none"});continue}let i=q(n.signed),p=Array.isArray(i)?i:[],c=p.find(d=>d?.body?.kind==="reply"),a=p.find(d=>d?.body?.kind==="addressed"),l=c?.body.author??"";!!c&&p.length===(a?2:1)&&p.every(d=>d.body.doc===t.doc&&d.body.thread===n.thread&&d.body.author===l)&&L(c.body.text??"",n.reply)&&(a?L(a.body.text??"",n.addressed):!n.addressed)&&(await Promise.all(p.map(t.check))).every(Boolean)?t.listed.includes(l)?r.push({kind:"signed",entry:n,ops:p,author:l}):r.push({kind:"unsigned",entry:n,why:"unlisted"}):r.push({kind:"unsigned",entry:n,why:"changed"})}return r}var A=(e,t,s)=>`${e} ${e===1?t:s}`,O=e=>{let t=[...new Set(e)];return t.length<=1?t[0]??"":`${t.slice(0,-1).join(", ")} and ${t.at(-1)}`};function D(e){let t=e.filter(a=>a.kind==="signed"),s=e.filter(a=>a.kind==="unsigned"),r=e.filter(a=>a.kind==="gone"),n=t.length+s.length,i=[];t.length&&i.push(`${A(t.length,"reply","replies")} signed by ${O(t.map(a=>a.entry.agent))}, whom this page lists`);let p=(a,l)=>a==="none"?`${l?"is":"are"} not signed`:a==="unlisted"?`${l?"is":"are"} signed with a key this page doesn't list`:l?"was changed after it was signed":"were changed after they were signed";for(let a of["none","changed","unlisted"]){let l=s.filter(f=>f.why===a);if(!l.length)continue;let o=O(l.map(f=>f.entry.agent)),d=l.length===1;i.push(`${A(l.length,"reply","replies")} from ${o} ${p(a,d)}, so ${d?"it":"they"} will show as pasted by you`)}let c=[...t,...s].filter(a=>a.entry.addressed).length;return c&&i.push(`${c} of them ${c===1?"says":"say"} the comment is addressed`),r.length&&i.push(`${A(r.length,"reply is","replies are")} for a comment that's no longer here, so ${r.length===1?"it":"they"} will be left out`),{lines:i,adds:n}}function J(e){if(!e)return{cli:"npx --yes pipeup@
|
|
4
|
+
${p.trim()}`:n&&i==="signed"&&(n.signed+=p.trim())}}return t.filter(s=>s.thread&&s.reply)}var L=(e,t)=>e.replace(/\s+/g," ").trim()===t.replace(/\s+/g," ").trim();function q(e){try{let t=e.replace(/-/g,"+").replace(/_/g,"/"),s=Uint8Array.from(atob(t+"=".repeat((4-t.length%4)%4)),r=>r.charCodeAt(0));return JSON.parse(new TextDecoder().decode(s))}catch{return null}}async function M(e,t){let s=new Set(t.threads.map(n=>n.id)),r=[];for(let n of e){if(!s.has(n.thread)){r.push({kind:"gone",entry:n});continue}if(!n.signed){r.push({kind:"unsigned",entry:n,why:"none"});continue}let i=q(n.signed),p=Array.isArray(i)?i:[],c=p.find(d=>d?.body?.kind==="reply"),a=p.find(d=>d?.body?.kind==="addressed"),l=c?.body.author??"";!!c&&p.length===(a?2:1)&&p.every(d=>d.body.doc===t.doc&&d.body.thread===n.thread&&d.body.author===l)&&L(c.body.text??"",n.reply)&&(a?L(a.body.text??"",n.addressed):!n.addressed)&&(await Promise.all(p.map(t.check))).every(Boolean)?t.listed.includes(l)?r.push({kind:"signed",entry:n,ops:p,author:l}):r.push({kind:"unsigned",entry:n,why:"unlisted"}):r.push({kind:"unsigned",entry:n,why:"changed"})}return r}var A=(e,t,s)=>`${e} ${e===1?t:s}`,O=e=>{let t=[...new Set(e)];return t.length<=1?t[0]??"":`${t.slice(0,-1).join(", ")} and ${t.at(-1)}`};function D(e){let t=e.filter(a=>a.kind==="signed"),s=e.filter(a=>a.kind==="unsigned"),r=e.filter(a=>a.kind==="gone"),n=t.length+s.length,i=[];t.length&&i.push(`${A(t.length,"reply","replies")} signed by ${O(t.map(a=>a.entry.agent))}, whom this page lists`);let p=(a,l)=>a==="none"?`${l?"is":"are"} not signed`:a==="unlisted"?`${l?"is":"are"} signed with a key this page doesn't list`:l?"was changed after it was signed":"were changed after they were signed";for(let a of["none","changed","unlisted"]){let l=s.filter(f=>f.why===a);if(!l.length)continue;let o=O(l.map(f=>f.entry.agent)),d=l.length===1;i.push(`${A(l.length,"reply","replies")} from ${o} ${p(a,d)}, so ${d?"it":"they"} will show as pasted by you`)}let c=[...t,...s].filter(a=>a.entry.addressed).length;return c&&i.push(`${c} of them ${c===1?"says":"say"} the comment is addressed`),r.length&&i.push(`${A(r.length,"reply is","replies are")} for a comment that's no longer here, so ${r.length===1?"it":"they"} will be left out`),{lines:i,adds:n}}function J(e){if(!e)return{cli:"npx --yes pipeup@1",fallback:null};let s=`npx --yes pipeup@${e.split(".")[0]??"0"}`;return e.includes("-")?{cli:`npx --yes pipeup@${e}`,fallback:s}:{cli:s,fallback:null}}function V(e,t=""){if(t)return{page:t,served:!1};try{let s=new URL(e),r=decodeURIComponent(s.pathname);return r.endsWith("/")&&(r+="index.html"),s.protocol==="file:"?{page:/^\/[A-Za-z]:\//.test(r)?r.slice(1):r,served:!1}:{page:r,served:!0}}catch{return{page:"<the page's HTML file>",served:!1}}}var W=e=>{try{let t=new URL(e);return t.protocol==="file:"?decodeURIComponent(t.pathname).replace(/^\/([A-Za-z]:\/)/,"$1"):t.href}catch{return e}},S=e=>e.replace(/\s+/g," ").trim();function R(e){let{cli:t,fallback:s}=J(e.version),r=`https://pipeup-ai.github.io/pipeup/${e.version?.includes("-")?"next/":""}`,{page:n,served:i}=V(e.url,e.file),p=i?`<the HTML file your site serves at ${n}>`:n,c=`\`${t} reply --print --doc ${e.doc} --thread <thread id> "what you changed and where" --addressed "short note"\``;return[`Please act on my review comments on ${S(e.title)} (${S(e.url)}). The page uses Pipeup.`,"The comments were left in my browser. They are not in the page's file, so don't look for them there. Everything you need is below.","",`## ${e.open} open comment${e.open===1?"":"s"}${e.edition?` on the ${e.edition} edition`:""}`,"",e.comments.trim(),...e.resolved||e.earlier?["",`(${[e.resolved?`${e.resolved} resolved comment${e.resolved===1?"":"s"}`:"",e.earlier?`${e.earlier} open comment${e.earlier===1?"":"s"} on earlier editions`:""].filter(Boolean).join(" and ")} left out.)`]:[],"","## How to answer","","- For each thread, make the change I approved, or say why you didn't. Answer a question with an answer. Ask me before changing anything I haven't approved.","- Reply in one block I can paste back into the page with Paste my agent's replies, and tell me what you changed and where. Don't say the page was updated unless you updated it.","","```pipeup-replies","agent: <your name>","thread: <thread id>","reply: what you changed and where","addressed: short note, only if you made the change","```","",e.listed?`- This page lists an agent's key. If it's yours, sign the block so it shows as yours, not as pasted by me: ${c} prints each reply signed with the key you keep (in ~/.pipeup/agent.json). Without your key, send the same block unsigned.`:`- If you keep a Pipeup key between sessions, sign the block with ${c}, and ask me whether to list you on the page (\`${t} agent\` prints the line to add). If you can't keep a key, don't ask to be listed: the plain block works.`,...e.file?[`- You're on this computer, with a live link running: \`${t} comments ${e.file}\` reads the comments and \`${t} reply --page ${p} --thread <thread id> "\u2026" --addressed "\u2026"\` answers in the page by itself.`]:e.replies?[`- If you can write next to the page on this computer, \`${t} reply --page ${p} --thread <thread id> "\u2026" --addressed "\u2026"\` writes ${S(W(e.replies))}, and your replies appear by themselves. Pass the HTML file that runs Pipeup, not a file it shows.`]:[],...(e.file||e.replies)&&!e.listed?[`- The page doesn't list you yet. Ask me first; after my yes, run \`${t} agent --name <your name> --page ${p} --yes\`.`]:[],...s?[`- If npm refuses ${t.split(" ").at(-1)}, use ${s.split(" ").at(-1)}: it answers these commands the same way.`]:[],"- Only mark a thread addressed. Never resolve, reopen, edit or delete: I close threads. Never answer as me, and keep your key out of the page and its folder.","",`Guide: ${r}skills/pipeup-apply/SKILL.md`].join(`
|
|
5
5
|
`)}var _=()=>["Please send your replies again in one block I can paste into the page, like this:","","```pipeup-replies","agent: <your name>","thread: <thread id>","reply: what you changed and where","addressed: short note, only if you made the change","```"].join(`
|
|
6
6
|
`);var w=(e,t)=>t?t.getAttribute(e):globalThis.Pipeup?.setting?.(e)??globalThis.document?.documentElement.getAttribute(e)??null;var Oe=2n**256n-2n**32n-977n;var re=/^[A-Za-z0-9_-]{43}$/,oe="pipeupReplies",se=4e3,ie=4e3,ae=/^AI assistant\s*·?\s*/;function k(e){let t=w("data-pipeup-agents",e)??"";return[...new Set(t.split(/[\s,]+/).filter(s=>re.test(s)))]}function T(e=location,t){let s=w("data-pipeup-replies",t);try{let r=e.href.split(/[?#]/)[0],n=new URL(s??(/\/$/.test(r)?`${r}index.replies.js`:r.replace(/\.[^./]*$/,"")+".replies.js"),e.href),i=n.protocol==="file:"?e.protocol==="file:":n.origin===e.origin;return i||console.warn("pipeup: the replies file must be on this site or this computer; ignoring it"),i?n.href:null}catch{return null}}function H(e){let t=k(),s=0,r="",n=null;async function i(){let d=globalThis[oe];if(!Array.isArray(d))return 0;let f=d.splice(0),h=[];for(let u of f){let y=u;if(!(y?.format!=="pipeup-replies"||y.doc!==e.document.id||!Array.isArray(y.ops)))for(let g of y.ops){let m=g?.body;m&&t.includes(m.author)&&(m.kind==="reply"||m.kind==="addressed"||m.kind==="react"||m.kind==="unreact")?(h.push(g),(m.name==="AI assistant"||m.name.startsWith("AI assistant "))&&(r=m.name.replace(ae,""))):s++}}return h.length?e.merge(h):0}function p(){let d=T();return d?(n?.remove(),new Promise((f,h)=>{let u=document.createElement("script");n=u,u.src=`${d}?${Date.now()}`;let y=m=>{window.clearTimeout(g),u.remove(),n===u&&(n=null),m?h(new Error(`pipeup: ${m}`)):f()},g=window.setTimeout(()=>y("the replies file didn't answer"),se);u.addEventListener("load",()=>y()),u.addEventListener("error",()=>y("there is no replies file yet")),e.overlay().append(u)})):Promise.reject(new Error("pipeup: the replies file can't be read from here"))}async function c(){if(!t.length)return 0;let d=await i();return await p(),d+await i()}let a=!1,l=()=>{a||document.hidden||(a=!0,c().catch(()=>{}).finally(()=>a=!1))},o=0;return t.length?(l(),o=window.setInterval(l,ie),document.addEventListener("visibilitychange",l)):i(),{enabled:t.length>0,ignored:()=>s,who:()=>r,check:c,tally:d=>{let f=d.filter(g=>!g.resolved),h=g=>g.root.replies.some(m=>t.includes(m.author)||m.name.startsWith("AI assistant \xB7 ")),u=new Set(d.map(g=>g.id));return{stray:new Set(e.document.ops().filter(g=>t.includes(g.body.author)&&!u.has(g.body.thread)).map(g=>g.body.thread)).size,open:f.length,answered:f.filter(h).length,addressed:f.filter(g=>g.addressed).length}},destroy:()=>{window.clearInterval(o),document.removeEventListener("visibilitychange",l),n?.remove()}}}var N=`.ag-t{margin:0 0 8px;font-size:15px;font-weight:600}
|
|
7
7
|
.ag-f{display:block;width:100%;height:96px;margin:4px 0 8px;padding:8px;border:1px solid var(--ln);border-radius:8px;background:var(--so);color:var(--k);font:12px/1.5 ui-monospace,monospace;resize:vertical}
|
package/dist/agents.min.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";(()=>{function x(e){let t=globalThis;(t.pipeupAddons||=[]).push(e),typeof addEventListener=="function"&&addEventListener("load",()=>{t.Pipeup||console.error(`pipeup: the "${e.id}" add-on needs Pipeup on the page too; load pipeup.min.js.`)},{once:!0})}var w=(e,t)=>t?t.getAttribute(e):globalThis.Pipeup?.setting?.(e)??globalThis.document?.documentElement.getAttribute(e)??null;var Ie=2n**256n-2n**32n-977n;var X=/^\/__pipeup\/[A-Za-z0-9_-]{16,}$/;function I(e){let t=document.documentElement,s=t.getAttribute("data-pipeup-link")??"",r=X.test(s),n=!1,i=0,p=()=>{};async function c(){let l=!1;try{l=(await fetch(`${s}/comments`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(await e.snapshot())})).ok}catch{}if(!l)throw new Error("pipeup: the link to your agent isn't reachable; your comments are safe here")}let a=()=>{window.clearTimeout(i),p(),p=()=>{},n=!1};return{enabled:r,agent:t.getAttribute("data-pipeup-link-agent")??"",file:t.getAttribute("data-pipeup-link-file")??"",on:()=>n,set:async l=>{if(r){if(!l){a(),e.refresh();return}await c(),n=!0,p=e.changes(()=>{window.clearTimeout(i),i=window.setTimeout(()=>{c().catch(o=>{a(),e.refresh(),globalThis.reportError?.(o)})},300)}),e.refresh()}},destroy:a}}var Q=/```[ \t]*pipeup-replies[^\n]*\n([\s\S]*?)(?:\n[ \t]*```|$)/g,ee=/^[ \t]*(agent|thread|reply|addressed|signed)[ \t]*:[ \t]?(.*)$/i,L="Agent";function M(e){let t=[];for(let[,s]of e.replace(/\r\n?/g,`
|
|
2
2
|
`).matchAll(Q)){let r=L,n=null,i=null;for(let p of s.split(`
|
|
3
3
|
`)){let c=ee.exec(p);if(c){let a=c[1].toLowerCase(),l=c[2].trim();a==="agent"?(r=l||L,i=null):a==="thread"?(n={agent:r,thread:l,reply:"",addressed:"",signed:""},t.push(n),i=null):n&&(n[a]=l,i=a)}else n&&i&&i!=="signed"&&p.trim()?n[i]=`${n[i]}
|
|
4
|
-
${p.trim()}`:n&&i==="signed"&&(n.signed+=p.trim())}}return t.filter(s=>s.thread&&s.reply)}var O=(e,t)=>e.replace(/\s+/g," ").trim()===t.replace(/\s+/g," ").trim();function te(e){try{let t=e.replace(/-/g,"+").replace(/_/g,"/"),s=Uint8Array.from(atob(t+"=".repeat((4-t.length%4)%4)),r=>r.charCodeAt(0));return JSON.parse(new TextDecoder().decode(s))}catch{return null}}async function D(e,t){let s=new Set(t.threads.map(n=>n.id)),r=[];for(let n of e){if(!s.has(n.thread)){r.push({kind:"gone",entry:n});continue}if(!n.signed){r.push({kind:"unsigned",entry:n,why:"none"});continue}let i=te(n.signed),p=Array.isArray(i)?i:[],c=p.find(d=>d?.body?.kind==="reply"),a=p.find(d=>d?.body?.kind==="addressed"),l=c?.body.author??"";!!c&&p.length===(a?2:1)&&p.every(d=>d.body.doc===t.doc&&d.body.thread===n.thread&&d.body.author===l)&&O(c.body.text??"",n.reply)&&(a?O(a.body.text??"",n.addressed):!n.addressed)&&(await Promise.all(p.map(t.check))).every(Boolean)?t.listed.includes(l)?r.push({kind:"signed",entry:n,ops:p,author:l}):r.push({kind:"unsigned",entry:n,why:"unlisted"}):r.push({kind:"unsigned",entry:n,why:"changed"})}return r}var $=(e,t,s)=>`${e} ${e===1?t:s}`,C=e=>{let t=[...new Set(e)];return t.length<=1?t[0]??"":`${t.slice(0,-1).join(", ")} and ${t.at(-1)}`};function R(e){let t=e.filter(a=>a.kind==="signed"),s=e.filter(a=>a.kind==="unsigned"),r=e.filter(a=>a.kind==="gone"),n=t.length+s.length,i=[];t.length&&i.push(`${$(t.length,"reply","replies")} signed by ${C(t.map(a=>a.entry.agent))}, whom this page lists`);let p=(a,l)=>a==="none"?`${l?"is":"are"} not signed`:a==="unlisted"?`${l?"is":"are"} signed with a key this page doesn't list`:l?"was changed after it was signed":"were changed after they were signed";for(let a of["none","changed","unlisted"]){let l=s.filter(f=>f.why===a);if(!l.length)continue;let o=C(l.map(f=>f.entry.agent)),d=l.length===1;i.push(`${$(l.length,"reply","replies")} from ${o} ${p(a,d)}, so ${d?"it":"they"} will show as pasted by you`)}let c=[...t,...s].filter(a=>a.entry.addressed).length;return c&&i.push(`${c} of them ${c===1?"says":"say"} the comment is addressed`),r.length&&i.push(`${$(r.length,"reply is","replies are")} for a comment that's no longer here, so ${r.length===1?"it":"they"} will be left out`),{lines:i,adds:n}}function ne(e){if(!e)return{cli:"npx --yes pipeup@
|
|
4
|
+
${p.trim()}`:n&&i==="signed"&&(n.signed+=p.trim())}}return t.filter(s=>s.thread&&s.reply)}var O=(e,t)=>e.replace(/\s+/g," ").trim()===t.replace(/\s+/g," ").trim();function te(e){try{let t=e.replace(/-/g,"+").replace(/_/g,"/"),s=Uint8Array.from(atob(t+"=".repeat((4-t.length%4)%4)),r=>r.charCodeAt(0));return JSON.parse(new TextDecoder().decode(s))}catch{return null}}async function D(e,t){let s=new Set(t.threads.map(n=>n.id)),r=[];for(let n of e){if(!s.has(n.thread)){r.push({kind:"gone",entry:n});continue}if(!n.signed){r.push({kind:"unsigned",entry:n,why:"none"});continue}let i=te(n.signed),p=Array.isArray(i)?i:[],c=p.find(d=>d?.body?.kind==="reply"),a=p.find(d=>d?.body?.kind==="addressed"),l=c?.body.author??"";!!c&&p.length===(a?2:1)&&p.every(d=>d.body.doc===t.doc&&d.body.thread===n.thread&&d.body.author===l)&&O(c.body.text??"",n.reply)&&(a?O(a.body.text??"",n.addressed):!n.addressed)&&(await Promise.all(p.map(t.check))).every(Boolean)?t.listed.includes(l)?r.push({kind:"signed",entry:n,ops:p,author:l}):r.push({kind:"unsigned",entry:n,why:"unlisted"}):r.push({kind:"unsigned",entry:n,why:"changed"})}return r}var $=(e,t,s)=>`${e} ${e===1?t:s}`,C=e=>{let t=[...new Set(e)];return t.length<=1?t[0]??"":`${t.slice(0,-1).join(", ")} and ${t.at(-1)}`};function R(e){let t=e.filter(a=>a.kind==="signed"),s=e.filter(a=>a.kind==="unsigned"),r=e.filter(a=>a.kind==="gone"),n=t.length+s.length,i=[];t.length&&i.push(`${$(t.length,"reply","replies")} signed by ${C(t.map(a=>a.entry.agent))}, whom this page lists`);let p=(a,l)=>a==="none"?`${l?"is":"are"} not signed`:a==="unlisted"?`${l?"is":"are"} signed with a key this page doesn't list`:l?"was changed after it was signed":"were changed after they were signed";for(let a of["none","changed","unlisted"]){let l=s.filter(f=>f.why===a);if(!l.length)continue;let o=C(l.map(f=>f.entry.agent)),d=l.length===1;i.push(`${$(l.length,"reply","replies")} from ${o} ${p(a,d)}, so ${d?"it":"they"} will show as pasted by you`)}let c=[...t,...s].filter(a=>a.entry.addressed).length;return c&&i.push(`${c} of them ${c===1?"says":"say"} the comment is addressed`),r.length&&i.push(`${$(r.length,"reply is","replies are")} for a comment that's no longer here, so ${r.length===1?"it":"they"} will be left out`),{lines:i,adds:n}}function ne(e){if(!e)return{cli:"npx --yes pipeup@1",fallback:null};let s=`npx --yes pipeup@${e.split(".")[0]??"0"}`;return e.includes("-")?{cli:`npx --yes pipeup@${e}`,fallback:s}:{cli:s,fallback:null}}function re(e,t=""){if(t)return{page:t,served:!1};try{let s=new URL(e),r=decodeURIComponent(s.pathname);return r.endsWith("/")&&(r+="index.html"),s.protocol==="file:"?{page:/^\/[A-Za-z]:\//.test(r)?r.slice(1):r,served:!1}:{page:r,served:!0}}catch{return{page:"<the page's HTML file>",served:!1}}}var oe=e=>{try{let t=new URL(e);return t.protocol==="file:"?decodeURIComponent(t.pathname).replace(/^\/([A-Za-z]:\/)/,"$1"):t.href}catch{return e}},T=e=>e.replace(/\s+/g," ").trim();function _(e){let{cli:t,fallback:s}=ne(e.version),r=`https://pipeup-ai.github.io/pipeup/${e.version?.includes("-")?"next/":""}`,{page:n,served:i}=re(e.url,e.file),p=i?`<the HTML file your site serves at ${n}>`:n,c=`\`${t} reply --print --doc ${e.doc} --thread <thread id> "what you changed and where" --addressed "short note"\``;return[`Please act on my review comments on ${T(e.title)} (${T(e.url)}). The page uses Pipeup.`,"The comments were left in my browser. They are not in the page's file, so don't look for them there. Everything you need is below.","",`## ${e.open} open comment${e.open===1?"":"s"}${e.edition?` on the ${e.edition} edition`:""}`,"",e.comments.trim(),...e.resolved||e.earlier?["",`(${[e.resolved?`${e.resolved} resolved comment${e.resolved===1?"":"s"}`:"",e.earlier?`${e.earlier} open comment${e.earlier===1?"":"s"} on earlier editions`:""].filter(Boolean).join(" and ")} left out.)`]:[],"","## How to answer","","- For each thread, make the change I approved, or say why you didn't. Answer a question with an answer. Ask me before changing anything I haven't approved.","- Reply in one block I can paste back into the page with Paste my agent's replies, and tell me what you changed and where. Don't say the page was updated unless you updated it.","","```pipeup-replies","agent: <your name>","thread: <thread id>","reply: what you changed and where","addressed: short note, only if you made the change","```","",e.listed?`- This page lists an agent's key. If it's yours, sign the block so it shows as yours, not as pasted by me: ${c} prints each reply signed with the key you keep (in ~/.pipeup/agent.json). Without your key, send the same block unsigned.`:`- If you keep a Pipeup key between sessions, sign the block with ${c}, and ask me whether to list you on the page (\`${t} agent\` prints the line to add). If you can't keep a key, don't ask to be listed: the plain block works.`,...e.file?[`- You're on this computer, with a live link running: \`${t} comments ${e.file}\` reads the comments and \`${t} reply --page ${p} --thread <thread id> "\u2026" --addressed "\u2026"\` answers in the page by itself.`]:e.replies?[`- If you can write next to the page on this computer, \`${t} reply --page ${p} --thread <thread id> "\u2026" --addressed "\u2026"\` writes ${T(oe(e.replies))}, and your replies appear by themselves. Pass the HTML file that runs Pipeup, not a file it shows.`]:[],...(e.file||e.replies)&&!e.listed?[`- The page doesn't list you yet. Ask me first; after my yes, run \`${t} agent --name <your name> --page ${p} --yes\`.`]:[],...s?[`- If npm refuses ${t.split(" ").at(-1)}, use ${s.split(" ").at(-1)}: it answers these commands the same way.`]:[],"- Only mark a thread addressed. Never resolve, reopen, edit or delete: I close threads. Never answer as me, and keep your key out of the page and its folder.","",`Guide: ${r}skills/pipeup-apply/SKILL.md`].join(`
|
|
5
5
|
`)}var H=()=>["Please send your replies again in one block I can paste into the page, like this:","","```pipeup-replies","agent: <your name>","thread: <thread id>","reply: what you changed and where","addressed: short note, only if you made the change","```"].join(`
|
|
6
6
|
`);var se=/^[A-Za-z0-9_-]{43}$/,ie="pipeupReplies",ae=4e3,de=4e3,pe=/^AI assistant\s*·?\s*/;function k(e){let t=w("data-pipeup-agents",e)??"";return[...new Set(t.split(/[\s,]+/).filter(s=>se.test(s)))]}function E(e=location,t){let s=w("data-pipeup-replies",t);try{let r=e.href.split(/[?#]/)[0],n=new URL(s??(/\/$/.test(r)?`${r}index.replies.js`:r.replace(/\.[^./]*$/,"")+".replies.js"),e.href),i=n.protocol==="file:"?e.protocol==="file:":n.origin===e.origin;return i||console.warn("pipeup: the replies file must be on this site or this computer; ignoring it"),i?n.href:null}catch{return null}}function N(e){let t=k(),s=0,r="",n=null;async function i(){let d=globalThis[ie];if(!Array.isArray(d))return 0;let f=d.splice(0),h=[];for(let u of f){let y=u;if(!(y?.format!=="pipeup-replies"||y.doc!==e.document.id||!Array.isArray(y.ops)))for(let g of y.ops){let m=g?.body;m&&t.includes(m.author)&&(m.kind==="reply"||m.kind==="addressed"||m.kind==="react"||m.kind==="unreact")?(h.push(g),(m.name==="AI assistant"||m.name.startsWith("AI assistant "))&&(r=m.name.replace(pe,""))):s++}}return h.length?e.merge(h):0}function p(){let d=E();return d?(n?.remove(),new Promise((f,h)=>{let u=document.createElement("script");n=u,u.src=`${d}?${Date.now()}`;let y=m=>{window.clearTimeout(g),u.remove(),n===u&&(n=null),m?h(new Error(`pipeup: ${m}`)):f()},g=window.setTimeout(()=>y("the replies file didn't answer"),ae);u.addEventListener("load",()=>y()),u.addEventListener("error",()=>y("there is no replies file yet")),e.overlay().append(u)})):Promise.reject(new Error("pipeup: the replies file can't be read from here"))}async function c(){if(!t.length)return 0;let d=await i();return await p(),d+await i()}let a=!1,l=()=>{a||document.hidden||(a=!0,c().catch(()=>{}).finally(()=>a=!1))},o=0;return t.length?(l(),o=window.setInterval(l,de),document.addEventListener("visibilitychange",l)):i(),{enabled:t.length>0,ignored:()=>s,who:()=>r,check:c,tally:d=>{let f=d.filter(g=>!g.resolved),h=g=>g.root.replies.some(m=>t.includes(m.author)||m.name.startsWith("AI assistant \xB7 ")),u=new Set(d.map(g=>g.id));return{stray:new Set(e.document.ops().filter(g=>t.includes(g.body.author)&&!u.has(g.body.thread)).map(g=>g.body.thread)).size,open:f.length,answered:f.filter(h).length,addressed:f.filter(g=>g.addressed).length}},destroy:()=>{window.clearInterval(o),document.removeEventListener("visibilitychange",l),n?.remove()}}}var z=`.ag-t{margin:0 0 8px;font-size:15px;font-weight:600}
|
|
7
7
|
.ag-f{display:block;width:100%;height:96px;margin:4px 0 8px;padding:8px;border:1px solid var(--ln);border-radius:8px;background:var(--so);color:var(--k);font:12px/1.5 ui-monospace,monospace;resize:vertical}
|