ultimatehuman 0.1.2 → 0.1.4

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 +1 @@
1
- import{j as k,f as z}from"./fmt-BRV4RZz4.js";import{c as K,s as X}from"./ConversationWorkspace-6m6xkkC1.js";import"./index-pC0URNNS.js";function Q({lines:e,file:t}){return e.filter(r=>r.op!=="=").length?k.jsxs("div",{"data-diff":!0,className:"overflow-hidden rounded-lg ring-1 ring-gray-200",children:[t&&k.jsx("div",{className:"border-b border-gray-200 bg-gray-50 px-3 py-1.5 font-mono text-xs text-gray-600",children:t}),k.jsx("pre",{className:"max-h-[420px] overflow-auto bg-white py-1 font-mono text-xs leading-relaxed",children:e.map((r,a)=>k.jsxs("div",{"data-op":r.op,className:`whitespace-pre-wrap px-3 [overflow-wrap:anywhere] ${r.op==="+"?"bg-emerald-50 text-emerald-900":r.op==="-"?"bg-red-50 text-red-900 line-through decoration-red-300":"text-gray-500"}`,children:[k.jsx("span",{className:"mr-2 select-none opacity-60",children:r.op==="="?" ":r.op}),r.text||" "]},a))})]}):k.jsx("p",{className:"text-sm text-gray-500",children:"No change yet."})}const ee=new Set(["Posted on the ticket. The fix resumes on the next pipeline run.","The pipeline picks it up within 15 minutes."]),te='[data-ticket-card^="TEACH-"], [data-phone-card][data-ticket^="TEACH-"]',E=new Map;function ne({proposalOf:e,answerCopy:t}){const n=()=>{for(const i of document.querySelectorAll(te)){const s=i.getAttribute("data-ticket-card")||i.getAttribute("data-ticket");for(const b of i.querySelectorAll("[data-answer-status] > p")){const c=b.lastChild;c?.nodeType===3&&ee.has(c.nodeValue)&&(c.nodeValue=t(s))}const d=e(s),p=i.matches("[data-ticket-card]")&&i.querySelector(":scope > [data-question]");if(!d||!p||i.querySelector(":scope > [data-teach-diff]"))continue;const l=document.createElement("div");l.setAttribute("data-teach-diff",s),l.className="mt-3",p.after(l);const u=z.createRoot(l);u.render(k.jsx(Q,{lines:d.diff,file:`${d.brief}.md: the proposed change`})),E.set(l,u)}for(const[i,s]of E)i.isConnected||(s.unmount(),E.delete(i))};let r=!1;const a=()=>{r||(r=!0,queueMicrotask(()=>{r=!1,n()}))};new MutationObserver(a).observe(document.documentElement,{childList:!0,subtree:!0,characterData:!0}),a()}const D=["border-violet-200 bg-violet-50 text-violet-800","border-rose-200 bg-rose-50 text-rose-800","border-emerald-200 bg-emerald-50 text-emerald-800","border-sky-200 bg-sky-50 text-sky-800","border-amber-200 bg-amber-50 text-amber-800"],re=e=>e==="external"?"border-gray-300 bg-gray-100 text-gray-700":D[[...e].reduce((t,n)=>t*31+n.charCodeAt(0)>>>0,7)%D.length],ae="inline-flex min-h-[32px] items-center gap-1.5 rounded-full px-3 text-xs font-medium ring-1 ring-inset transition-colors";function ie({pipelineOf:e,pipelines:t,counts:n}){const r=p=>t().find(l=>l.id===p)?.name||p,a=()=>{for(const p of document.querySelectorAll("a[data-jira-key]")){const l=p.getAttribute("data-jira-key"),u=e(l),b=p.nextElementSibling;if(!u)continue;if(b?.hasAttribute("data-pipeline-badge")){if(b.getAttribute("data-pipeline-badge")===u)continue;b.remove()}const c=document.createElement("span");c.setAttribute("data-pipeline-badge",u),c.title=`Pipeline: ${r(u)}`,c.className=`shrink-0 whitespace-nowrap rounded border px-1.5 py-0.5 text-[11px] font-semibold ${re(u)}`,c.textContent=r(u),p.after(c)}i()},i=()=>{const l=(document.querySelector("[data-review-title]")||[...document.querySelectorAll("header h1")].find(g=>g.textContent.trim()==="Pipeline"))?.closest("header");if(!l||l.querySelector("[data-pipeline-filter]")||!t().length)return;const u=new URLSearchParams(window.location.search).get("pipeline")||"",b=n(),c=document.createElement("div");c.setAttribute("data-pipeline-filter",u||"all"),c.className="mt-3 flex flex-wrap items-center gap-2";const q=document.createElement("span");q.className="text-xs font-medium text-gray-500",q.textContent="Pipeline:",c.append(q);for(const g of[{id:"",name:"All"},...t().filter(_=>_.id!=="external"||b.external)]){const _=g.id===u,x=document.createElement("button");x.type="button",x.setAttribute("data-pipeline-chip",g.id||"all"),x.setAttribute("aria-pressed",_?"true":"false"),x.className=`${ae} ${_?"bg-gray-900 text-white ring-gray-900":"bg-white text-gray-700 ring-gray-300 hover:bg-gray-50"}`,x.textContent=g.id?`${g.name} · ${b[g.id]||0}`:"All",x.onclick=()=>{const O=new URL(window.location.href);g.id?O.searchParams.set("pipeline",g.id):O.searchParams.delete("pipeline"),window.location.assign(O)},c.append(x)}l.append(c)};let s=!1;const d=()=>{s||(s=!0,queueMicrotask(()=>{s=!1,a()}))};new MutationObserver(d).observe(document.documentElement,{childList:!0,subtree:!0}),d()}let C="",w=null,$=null;const I=new Map,m=new Map,v=new Map,f=new Map,G=window.fetch.bind(window);class J extends Error{constructor(t,n){super(n),this.status=t}}async function h(e,t){t!==void 0&&!C&&(C=(await h("/api/status")).csrf);const n=await G(e,t===void 0?{credentials:"same-origin",cache:"no-store"}:{method:"POST",credentials:"same-origin",headers:{"content-type":"application/json","x-uh-csrf":C},body:JSON.stringify(t)}),r=await n.json().catch(()=>({}));if(!n.ok)throw new J(n.status,r.error||`HTTP ${n.status}`);return r}const V=e=>(e.history||[]).map(t=>t.at).filter(Boolean).sort(),S=e=>V(e)[0]||e.finding?.createdAt||e.draft?.at||"",L=e=>V(e).pop()||S(e),y=()=>w?.output?.repo||"",se=()=>(y().split("/").pop()||"").toUpperCase().replace(/[^A-Z0-9]/g,"").replace(/^[^A-Z]+/,"")||"BUG",oe=e=>new Date(e).toLocaleString("en-GB",{day:"numeric",month:"short",hour:"2-digit",minute:"2-digit"}),R=e=>e?new Date(e).toLocaleDateString("en-GB",{day:"numeric",month:"short"}):"?",U=()=>[{letter:"A",label:y()?"File to GitHub":"Accept",text:y()?w?.output?.dryRun?`Records it as filed on ${y()}. Dry run: nothing is sent to GitHub while no GitHub token is set.`:`Opens the issue on ${y()}.`:"Accepts the ticket. No issue tracker is configured: the pipeline keeps its own tickets."},{letter:"B",label:"Dismiss",text:"Not a real problem. Say why in the box below: its pipeline keeps it out of the next passes unless its impact grows."},{letter:"C",label:"Not now",text:"Park it. It comes back for a fresh look the first time a pass sees a new occurrence."}];function M(e){const t=e.finding,n=e.draft;if(t){const r=t.impact||{};return{question:`${e.title}. ${y()?`File it as an issue on ${y()}?`:"Accept it as a ticket?"}`,options:U(),recommendation:"",context:[`What happens: ${t.symptom}`,t.rootCause?.statement&&`Root cause (${t.confidence}): ${t.rootCause.statement}`,`Impact: ${r.usersAffected?`${r.usersAffected} users, `:""}${r.occurrences} occurrence${r.occurrences===1?"":"s"}, ${R(r.firstSeen)} to ${R(r.lastSeen)}, trend ${r.trend}. Severity ${t.severity}.`,...(t.rootCause?.codePointers||[]).map(a=>`${a.path}:${a.line}: ${a.why}`)].filter(Boolean)}}return{question:`${e.title}. ${j(e.pipelineId)} dropped it: ${n.reason}.`,options:U(),recommendation:"",context:[`Dropped ${n.timesDropped||1} time${n.timesDropped===1?"":"s"}, last in the ${n.runLabel} (${R(n.at)}).`]}}function Y(e){const t=/#(\d+)$/.exec(e?.ref||"")?.[1];if(!t)return[];const n=e.repo||y();return[{repo:n.split("/").pop(),number:Number(t),url:`https://github.com/${n}/issues/${t}`,title:"",base:"",head:"",files:[]}]}function N(e,t){const n=e.finding,r=e.draft,a=e.ruling&&e.ruling.ruling!=="clear"&&e.ruling.ruling!=="resurfaced"?e.ruling:null,i={key:t,title:e.title,repo:n?.repo||null,plain:{improves:e.title,problem:n?n.symptom:r.reason,how:""},verdict:"",fix_class:"",hold:null,prs:[],evidence:[],flags:[],chat:[],decision:null,merged_at:null,cancelled_at:null,fix_round:null,manual:null,plan:null,jira_status:null,jira_created:S(e),jira_updated:L(e),createdAt:S(e),synced_at:L(e)};if(a?.ruling==="park")return{...i,queue:"decision",decision:M(e),answer:{option:"C",text:a.reason||"",answered_at:a.at,acked_at:a.at,ack_error:null}};if(n&&a?.ruling==="file")return{...i,queue:"shipped",merged_at:a.at,prs:Y(a)};if(a?.ruling==="dismiss")return{...i,queue:"cancelled",cancelled_at:a.at,cancel:{reason:`You dismissed it: ${a.reason}`,requested_at:a.at,acked_at:a.at,ack_error:null}};const s=n?.validation;return n&&(s?.state==="pending"||s?.state==="later")?{...i,queue:"backlog",gate:s.state,gate_at:s.at,plain:{...i.plain,how:n.rootCause?.statement||""}}:n?{...i,queue:"decision",decision:M(e),answer:null}:{...i,queue:"cancelled",cancelled_at:r.at,cancel:{reason:`${j(e.pipelineId)} dropped it in the ${r.runLabel}: ${r.reason}`,requested_at:r.at,acked_at:r.at,ack_error:null}}}const ce={mission:"mission.md",collector:"collector.md",admission:"admission.md",gate:"gate.md",scope:"scope.md"},j=e=>w?.pipelines?.find(t=>t.id===e)?.name||e,le=e=>e>0?`+${e}`:`${e}`;function de(e){const t=ce[e.brief]||e.brief,n=(w?.instructionsVersions?.[e.pipelineId]||e.baseVersion)+1,r=e.rulings[e.rulings.length-1],a=e.diff.filter(s=>s.op==="-").length,i=e.diff.filter(s=>s.op==="+").length;return{question:`Teach ${j(e.pipelineId)}: ${e.title}. Apply this change to ${t}?`,options:[{letter:"A",label:"Apply",text:`Saves it as ${j(e.pipelineId)} instructions v${n}; its next pass reads it. Config > Instructions reverts it in one tap.`},{letter:"B",label:"Reject",text:"Say why in the box below: the next retrospectives read your reason and do not propose it again without new evidence."},{letter:"C",label:"Not now",text:"Keep it here for later. Nothing changes meanwhile."}],recommendation:"",context:[e.status==="parked"&&`You parked it on ${oe(r.at)}. Apply, Reject or keep it parked.${r.reason?` Your note: "${r.reason}"`:""}`,`The gap: ${e.gap}`,...e.evidence.map(s=>`Evidence: ${s.label} (${s.ref}): ${s.what}`),`The change to ${t}: ${a} line${a===1?"":"s"} removed, ${i} added (red and green, under the question).`,...e.edits.map(s=>`Why: ${s.because}`),`Expected effect: ${e.expectedEffect}`,`Size of ${t}: about ${e.tokensBefore} to ${e.tokensAfter} tokens (${le(e.tokensAfter-e.tokensBefore)}), read on every agent step.`,`Drafted by the retrospective of ${e.runId} on instructions v${e.baseVersion}. It never applies itself.`].filter(Boolean)}}function T(e,t){const n=e.rulings[e.rulings.length-1]||null,r={key:t,title:`Instructions: ${e.title}`,plain:{improves:e.title,problem:e.gap,how:e.expectedEffect},verdict:"",fix_class:"",hold:null,prs:[],evidence:[],flags:[],chat:[],decision:null,merged_at:null,cancelled_at:null,fix_round:null,manual:null,plan:null,jira_status:null,jira_created:e.createdAt,jira_updated:n?.at||e.createdAt,createdAt:e.createdAt,synced_at:n?.at||e.createdAt};if(e.status==="applied")return{...r,queue:"shipped",merged_at:n.at};if(e.status==="rejected"||e.status==="stale"){const a=e.status==="rejected"?`You rejected it: ${n.reason}`:`Not applied: ${n.reason}`;return{...r,queue:"cancelled",cancelled_at:n.at,cancel:{reason:a,requested_at:n.at,acked_at:n.at,ack_error:null}}}return{...r,queue:"decision",decision:de(e),answer:null}}async function A(){w=await h("/api/cockpit");const e=[...w.cards].sort((n,r)=>S(n).localeCompare(S(r)));for(const n of e)I.has(n.clusterId)||I.set(n.clusterId,`${se()}-${I.size+1}`);m.clear();for(const n of e)m.set(I.get(n.clusterId),n);const t=[...w.proposals||[]].sort((n,r)=>n.createdAt.localeCompare(r.createdAt));for(const n of t)v.has(n.id)||v.set(n.id,`TEACH-${v.size+1}`);f.clear();for(const n of t)f.set(v.get(n.id),n)}const H=()=>new URLSearchParams(window.location.search).get("pipeline")||"",F=(e,t)=>(!H()||H()===e)&&(!$||$.pipelines.has(e)||$.repos.has(t)),B=()=>[...[...m].filter(([,e])=>F(e.pipelineId,e.finding?.repo)).map(([e,t])=>N(t,e)),...[...f].filter(([,e])=>F(e.pipelineId)).map(([e,t])=>T(t,e))],ue={A:"apply",B:"reject",C:"park"},W=new Map;function pe(e,t){return e.status==="applied"?`Saved as instructions v${t??"?"}: the next pass reads it. Config > Instructions reverts it in one tap.`:e.status==="rejected"?"Rejected. The next retrospectives read your reason and do not propose it again without new evidence.":e.status==="stale"?"Not applied: the brief changed since this was drafted.":"Parked. Nothing changes meanwhile; it stays in Needs decision with its options."}async function fe(e,t,n){const r=f.get(e),a=T(r,e),i=ue[t];if(!i)return o(400,{error:"Pick A, B or C: Apply, Reject or Not now."});if(i==="reject"&&!n)return o(400,{error:"Say why in the box: the next retrospectives read your reason."});const s=await h(`/api/proposals/${encodeURIComponent(r.id)}/rule`,{ruling:i,reason:n});await A(),W.set(e,pe(s.proposal||f.get(e),s.version));const d=new Date().toISOString();return o(200,{ticket:{...a,answer:{option:t,text:n,answered_at:d,acked_at:i==="park"?null:d,ack_error:null}}})}function Z(){const e=w?.runs?.[0];return e?{last_push_at:e.phase==="done"||e.phase==="failed"?e.finishedAt||e.startedAt:new Date().toISOString(),received:e.signals??0,changed:(e.findings??0)+(e.dropped??0)}:null}async function ve(){try{C=(await h("/api/status")).csrf,await A();const e=new URLSearchParams(window.location.search).get("project");if($=null,e&&e!=="all"){const t=(await h("/api/workspace")).projects.find(n=>n.id===e);$={pipelines:new Set(t?.pipelineIds||[]),repos:new Set(t?.repos.map(n=>n.name)||[])}}he()}catch(e){throw e instanceof J&&e.status===401&&window.location.replace("/"),e}}function he(){const e=new URL(window.location.href),t=e.searchParams.get("finding"),n=e.searchParams.get("proposal");if(!t&&!n)return;const r=t?[...m].find(([,i])=>i.finding?.id===t)?.[0]:v.get(n),a=r&&B().find(i=>i.key===r);if(a){const i=new URL(K(X(a),r),window.location.origin);e.searchParams.set("tab",i.searchParams.get("tab")),e.searchParams.set("focus",r)}e.searchParams.delete("finding"),e.searchParams.delete("proposal"),window.history.replaceState(null,"",e)}const P=e=>({lean:async()=>e()}),Se={find:()=>P(()=>[])},_e={find:()=>P(B)},Ie={findOne:()=>P(()=>null)},Ce={findOne:()=>P(Z)},o=(e,t)=>new Response(JSON.stringify(t),{status:e,headers:{"content-type":"application/json"}});async function me({key:e,option:t,text:n}){if(f.has(e))return fe(e,t,(n||"").trim());const r=m.get(e);if(!r)return o(404,{error:"Unknown ticket"});const a=N(r,e),i=(n||"").trim();if(t==="A"){if(!r.finding)return o(400,{error:"The radar dropped this one: there is no issue to file. Answer B or C."});await h(`/api/findings/${encodeURIComponent(r.finding.id)}/file`,{})}else if(t==="B"){if(!i)return o(400,{error:"Say why in the box: a dismissal keeps its reason."});await h("/api/rulings",{clusterId:r.clusterId,ruling:"dismiss",reason:i})}else if(t==="C")await h("/api/rulings",{clusterId:r.clusterId,ruling:"park",reason:i});else return o(400,{error:"Pick A, B or C: the radar acts on one of the three."});await A();const s=new Date().toISOString();return o(200,{ticket:{...a,answer:{option:t,text:i,answered_at:s,acked_at:s,ack_error:null}}})}async function ge({key:e,reason:t}){if(f.has(e)){if(!(t||"").trim())return o(400,{error:"Say why: the next retrospectives read your reason."});const s=T(f.get(e),e);await h(`/api/proposals/${encodeURIComponent(f.get(e).id)}/rule`,{ruling:"reject",reason:t.trim()}),await A();const d=new Date().toISOString();return o(200,{ticket:{...s,cancel:{reason:t.trim(),requested_at:d,acked_at:d,ack_error:null}}})}const n=m.get(e);if(!n)return o(404,{error:"Unknown ticket"});const r=(t||"").trim();if(!r)return o(400,{error:"Say why: the radar keeps the reason with the dismissal."});const a=N(n,e);await h("/api/rulings",{clusterId:n.clusterId,ruling:"dismiss",reason:r}),await A();const i=new Date().toISOString();return o(200,{ticket:{...a,cancel:{reason:r,requested_at:i,acked_at:i,ack_error:null}}})}async function we({key:e,action:t,note:n}){const r=m.get(e);return r?.finding?["validate","later","dismiss"].includes(t)?(await h(`/api/findings/${encodeURIComponent(r.finding.id)}/validate`,{action:t,note:n}),await A(),o(200,{ticket:N(m.get(e),e)})):o(400,{error:"Validate, Later or Dismiss only."}):o(404,{error:"Unknown ticket"})}async function be(){return await A(),o(200,JSON.parse(JSON.stringify({tickets:B(),sync:Z(),read_at:new Date})))}window.fetch=async(e,t={})=>{const n=typeof e=="string"?e:e.url;if(!n.startsWith("/api/admin/"))return G(e,t);const r=n.split("?")[0];try{const a=t.body&&typeof t.body=="string"?JSON.parse(t.body):{};return r==="/api/admin/pipeline/answer"?await me(a):r==="/api/admin/pipeline/cancel"?await ge(a):r==="/api/admin/pipeline/live"?await be():r==="/api/admin/pipeline/gate"?await we(a):o(404,{error:"Not available in this radar: it has no fix pipeline yet."})}catch(a){return o(a.status||500,{error:a.message})}};const ye=/^https:\/\/[^/]+\.atlassian\.net\/browse\/([A-Z][A-Z0-9]+-\d+)$/;function xe(e){for(const t of e.querySelectorAll?.('a[href*=".atlassian.net/browse/"]')||[]){const n=ye.exec(t.getAttribute("href"))?.[1],r=n&&Y(m.get(n)?.ruling)[0]?.url;r?t.setAttribute("href",r):(t.removeAttribute("href"),t.removeAttribute("target"))}}new MutationObserver(e=>e.forEach(t=>t.addedNodes.forEach(n=>n.nodeType===1&&xe(n.parentNode||n)))).observe(document.documentElement,{childList:!0,subtree:!0});ie({pipelineOf:e=>m.get(e)?.pipelineId||f.get(e)?.pipelineId,pipelines:()=>(w?.pipelines||[]).filter(e=>!$||$.pipelines.has(e.id)),counts:()=>{const e={};for(const t of m.values())e[t.pipelineId]=(e[t.pipelineId]||0)+1;return e}});ne({proposalOf:e=>f.get(e),answerCopy:e=>W.get(e)||"Recorded on the proposal."});export{Ie as PipelineBundles,Ce as PipelineSyncStatus,_e as PipelineTicket,Se as PlatformClaim,h as engineCall,ve as init};
1
+ import{j as k,f as z}from"./fmt-BRV4RZz4.js";import{c as K,s as X}from"./ConversationWorkspace-C_HyzEg6.js";import"./index-C7UNg0WM.js";function Q({lines:e,file:t}){return e.filter(r=>r.op!=="=").length?k.jsxs("div",{"data-diff":!0,className:"overflow-hidden rounded-lg ring-1 ring-gray-200",children:[t&&k.jsx("div",{className:"border-b border-gray-200 bg-gray-50 px-3 py-1.5 font-mono text-xs text-gray-600",children:t}),k.jsx("pre",{className:"max-h-[420px] overflow-auto bg-white py-1 font-mono text-xs leading-relaxed",children:e.map((r,a)=>k.jsxs("div",{"data-op":r.op,className:`whitespace-pre-wrap px-3 [overflow-wrap:anywhere] ${r.op==="+"?"bg-emerald-50 text-emerald-900":r.op==="-"?"bg-red-50 text-red-900 line-through decoration-red-300":"text-gray-500"}`,children:[k.jsx("span",{className:"mr-2 select-none opacity-60",children:r.op==="="?" ":r.op}),r.text||" "]},a))})]}):k.jsx("p",{className:"text-sm text-gray-500",children:"No change yet."})}const ee=new Set(["Posted on the ticket. The fix resumes on the next pipeline run.","The pipeline picks it up within 15 minutes."]),te='[data-ticket-card^="TEACH-"], [data-phone-card][data-ticket^="TEACH-"]',E=new Map;function ne({proposalOf:e,answerCopy:t}){const n=()=>{for(const i of document.querySelectorAll(te)){const s=i.getAttribute("data-ticket-card")||i.getAttribute("data-ticket");for(const b of i.querySelectorAll("[data-answer-status] > p")){const c=b.lastChild;c?.nodeType===3&&ee.has(c.nodeValue)&&(c.nodeValue=t(s))}const d=e(s),p=i.matches("[data-ticket-card]")&&i.querySelector(":scope > [data-question]");if(!d||!p||i.querySelector(":scope > [data-teach-diff]"))continue;const l=document.createElement("div");l.setAttribute("data-teach-diff",s),l.className="mt-3",p.after(l);const u=z.createRoot(l);u.render(k.jsx(Q,{lines:d.diff,file:`${d.brief}.md: the proposed change`})),E.set(l,u)}for(const[i,s]of E)i.isConnected||(s.unmount(),E.delete(i))};let r=!1;const a=()=>{r||(r=!0,queueMicrotask(()=>{r=!1,n()}))};new MutationObserver(a).observe(document.documentElement,{childList:!0,subtree:!0,characterData:!0}),a()}const D=["border-violet-200 bg-violet-50 text-violet-800","border-rose-200 bg-rose-50 text-rose-800","border-emerald-200 bg-emerald-50 text-emerald-800","border-sky-200 bg-sky-50 text-sky-800","border-amber-200 bg-amber-50 text-amber-800"],re=e=>e==="external"?"border-gray-300 bg-gray-100 text-gray-700":D[[...e].reduce((t,n)=>t*31+n.charCodeAt(0)>>>0,7)%D.length],ae="inline-flex min-h-[32px] items-center gap-1.5 rounded-full px-3 text-xs font-medium ring-1 ring-inset transition-colors";function ie({pipelineOf:e,pipelines:t,counts:n}){const r=p=>t().find(l=>l.id===p)?.name||p,a=()=>{for(const p of document.querySelectorAll("a[data-jira-key]")){const l=p.getAttribute("data-jira-key"),u=e(l),b=p.nextElementSibling;if(!u)continue;if(b?.hasAttribute("data-pipeline-badge")){if(b.getAttribute("data-pipeline-badge")===u)continue;b.remove()}const c=document.createElement("span");c.setAttribute("data-pipeline-badge",u),c.title=`Pipeline: ${r(u)}`,c.className=`shrink-0 whitespace-nowrap rounded border px-1.5 py-0.5 text-[11px] font-semibold ${re(u)}`,c.textContent=r(u),p.after(c)}i()},i=()=>{const l=(document.querySelector("[data-review-title]")||[...document.querySelectorAll("header h1")].find(g=>g.textContent.trim()==="Pipeline"))?.closest("header");if(!l||l.querySelector("[data-pipeline-filter]")||!t().length)return;const u=new URLSearchParams(window.location.search).get("pipeline")||"",b=n(),c=document.createElement("div");c.setAttribute("data-pipeline-filter",u||"all"),c.className="mt-3 flex flex-wrap items-center gap-2";const q=document.createElement("span");q.className="text-xs font-medium text-gray-500",q.textContent="Pipeline:",c.append(q);for(const g of[{id:"",name:"All"},...t().filter(_=>_.id!=="external"||b.external)]){const _=g.id===u,x=document.createElement("button");x.type="button",x.setAttribute("data-pipeline-chip",g.id||"all"),x.setAttribute("aria-pressed",_?"true":"false"),x.className=`${ae} ${_?"bg-gray-900 text-white ring-gray-900":"bg-white text-gray-700 ring-gray-300 hover:bg-gray-50"}`,x.textContent=g.id?`${g.name} · ${b[g.id]||0}`:"All",x.onclick=()=>{const O=new URL(window.location.href);g.id?O.searchParams.set("pipeline",g.id):O.searchParams.delete("pipeline"),window.location.assign(O)},c.append(x)}l.append(c)};let s=!1;const d=()=>{s||(s=!0,queueMicrotask(()=>{s=!1,a()}))};new MutationObserver(d).observe(document.documentElement,{childList:!0,subtree:!0}),d()}let C="",w=null,$=null;const I=new Map,m=new Map,v=new Map,f=new Map,G=window.fetch.bind(window);class J extends Error{constructor(t,n){super(n),this.status=t}}async function h(e,t){t!==void 0&&!C&&(C=(await h("/api/status")).csrf);const n=await G(e,t===void 0?{credentials:"same-origin",cache:"no-store"}:{method:"POST",credentials:"same-origin",headers:{"content-type":"application/json","x-uh-csrf":C},body:JSON.stringify(t)}),r=await n.json().catch(()=>({}));if(!n.ok)throw new J(n.status,r.error||`HTTP ${n.status}`);return r}const V=e=>(e.history||[]).map(t=>t.at).filter(Boolean).sort(),S=e=>V(e)[0]||e.finding?.createdAt||e.draft?.at||"",L=e=>V(e).pop()||S(e),y=()=>w?.output?.repo||"",se=()=>(y().split("/").pop()||"").toUpperCase().replace(/[^A-Z0-9]/g,"").replace(/^[^A-Z]+/,"")||"BUG",oe=e=>new Date(e).toLocaleString("en-GB",{day:"numeric",month:"short",hour:"2-digit",minute:"2-digit"}),R=e=>e?new Date(e).toLocaleDateString("en-GB",{day:"numeric",month:"short"}):"?",U=()=>[{letter:"A",label:y()?"File to GitHub":"Accept",text:y()?w?.output?.dryRun?`Records it as filed on ${y()}. Dry run: nothing is sent to GitHub while no GitHub token is set.`:`Opens the issue on ${y()}.`:"Accepts the ticket. No issue tracker is configured: the pipeline keeps its own tickets."},{letter:"B",label:"Dismiss",text:"Not a real problem. Say why in the box below: its pipeline keeps it out of the next passes unless its impact grows."},{letter:"C",label:"Not now",text:"Park it. It comes back for a fresh look the first time a pass sees a new occurrence."}];function M(e){const t=e.finding,n=e.draft;if(t){const r=t.impact||{};return{question:`${e.title}. ${y()?`File it as an issue on ${y()}?`:"Accept it as a ticket?"}`,options:U(),recommendation:"",context:[`What happens: ${t.symptom}`,t.rootCause?.statement&&`Root cause (${t.confidence}): ${t.rootCause.statement}`,`Impact: ${r.usersAffected?`${r.usersAffected} users, `:""}${r.occurrences} occurrence${r.occurrences===1?"":"s"}, ${R(r.firstSeen)} to ${R(r.lastSeen)}, trend ${r.trend}. Severity ${t.severity}.`,...(t.rootCause?.codePointers||[]).map(a=>`${a.path}:${a.line}: ${a.why}`)].filter(Boolean)}}return{question:`${e.title}. ${j(e.pipelineId)} dropped it: ${n.reason}.`,options:U(),recommendation:"",context:[`Dropped ${n.timesDropped||1} time${n.timesDropped===1?"":"s"}, last in the ${n.runLabel} (${R(n.at)}).`]}}function Y(e){const t=/#(\d+)$/.exec(e?.ref||"")?.[1];if(!t)return[];const n=e.repo||y();return[{repo:n.split("/").pop(),number:Number(t),url:`https://github.com/${n}/issues/${t}`,title:"",base:"",head:"",files:[]}]}function N(e,t){const n=e.finding,r=e.draft,a=e.ruling&&e.ruling.ruling!=="clear"&&e.ruling.ruling!=="resurfaced"?e.ruling:null,i={key:t,title:e.title,repo:n?.repo||null,plain:{improves:e.title,problem:n?n.symptom:r.reason,how:""},verdict:"",fix_class:"",hold:null,prs:[],evidence:[],flags:[],chat:[],decision:null,merged_at:null,cancelled_at:null,fix_round:null,manual:null,plan:null,jira_status:null,jira_created:S(e),jira_updated:L(e),createdAt:S(e),synced_at:L(e)};if(a?.ruling==="park")return{...i,queue:"decision",decision:M(e),answer:{option:"C",text:a.reason||"",answered_at:a.at,acked_at:a.at,ack_error:null}};if(n&&a?.ruling==="file")return{...i,queue:"shipped",merged_at:a.at,prs:Y(a)};if(a?.ruling==="dismiss")return{...i,queue:"cancelled",cancelled_at:a.at,cancel:{reason:`You dismissed it: ${a.reason}`,requested_at:a.at,acked_at:a.at,ack_error:null}};const s=n?.validation;return n&&(s?.state==="pending"||s?.state==="later")?{...i,queue:"backlog",gate:s.state,gate_at:s.at,plain:{...i.plain,how:n.rootCause?.statement||""}}:n?{...i,queue:"decision",decision:M(e),answer:null}:{...i,queue:"cancelled",cancelled_at:r.at,cancel:{reason:`${j(e.pipelineId)} dropped it in the ${r.runLabel}: ${r.reason}`,requested_at:r.at,acked_at:r.at,ack_error:null}}}const ce={mission:"mission.md",collector:"collector.md",admission:"admission.md",gate:"gate.md",scope:"scope.md"},j=e=>w?.pipelines?.find(t=>t.id===e)?.name||e,le=e=>e>0?`+${e}`:`${e}`;function de(e){const t=ce[e.brief]||e.brief,n=(w?.instructionsVersions?.[e.pipelineId]||e.baseVersion)+1,r=e.rulings[e.rulings.length-1],a=e.diff.filter(s=>s.op==="-").length,i=e.diff.filter(s=>s.op==="+").length;return{question:`Teach ${j(e.pipelineId)}: ${e.title}. Apply this change to ${t}?`,options:[{letter:"A",label:"Apply",text:`Saves it as ${j(e.pipelineId)} instructions v${n}; its next pass reads it. Config > Instructions reverts it in one tap.`},{letter:"B",label:"Reject",text:"Say why in the box below: the next retrospectives read your reason and do not propose it again without new evidence."},{letter:"C",label:"Not now",text:"Keep it here for later. Nothing changes meanwhile."}],recommendation:"",context:[e.status==="parked"&&`You parked it on ${oe(r.at)}. Apply, Reject or keep it parked.${r.reason?` Your note: "${r.reason}"`:""}`,`The gap: ${e.gap}`,...e.evidence.map(s=>`Evidence: ${s.label} (${s.ref}): ${s.what}`),`The change to ${t}: ${a} line${a===1?"":"s"} removed, ${i} added (red and green, under the question).`,...e.edits.map(s=>`Why: ${s.because}`),`Expected effect: ${e.expectedEffect}`,`Size of ${t}: about ${e.tokensBefore} to ${e.tokensAfter} tokens (${le(e.tokensAfter-e.tokensBefore)}), read on every agent step.`,`Drafted by the retrospective of ${e.runId} on instructions v${e.baseVersion}. It never applies itself.`].filter(Boolean)}}function T(e,t){const n=e.rulings[e.rulings.length-1]||null,r={key:t,title:`Instructions: ${e.title}`,plain:{improves:e.title,problem:e.gap,how:e.expectedEffect},verdict:"",fix_class:"",hold:null,prs:[],evidence:[],flags:[],chat:[],decision:null,merged_at:null,cancelled_at:null,fix_round:null,manual:null,plan:null,jira_status:null,jira_created:e.createdAt,jira_updated:n?.at||e.createdAt,createdAt:e.createdAt,synced_at:n?.at||e.createdAt};if(e.status==="applied")return{...r,queue:"shipped",merged_at:n.at};if(e.status==="rejected"||e.status==="stale"){const a=e.status==="rejected"?`You rejected it: ${n.reason}`:`Not applied: ${n.reason}`;return{...r,queue:"cancelled",cancelled_at:n.at,cancel:{reason:a,requested_at:n.at,acked_at:n.at,ack_error:null}}}return{...r,queue:"decision",decision:de(e),answer:null}}async function A(){w=await h("/api/cockpit");const e=[...w.cards].sort((n,r)=>S(n).localeCompare(S(r)));for(const n of e)I.has(n.clusterId)||I.set(n.clusterId,`${se()}-${I.size+1}`);m.clear();for(const n of e)m.set(I.get(n.clusterId),n);const t=[...w.proposals||[]].sort((n,r)=>n.createdAt.localeCompare(r.createdAt));for(const n of t)v.has(n.id)||v.set(n.id,`TEACH-${v.size+1}`);f.clear();for(const n of t)f.set(v.get(n.id),n)}const H=()=>new URLSearchParams(window.location.search).get("pipeline")||"",F=(e,t)=>(!H()||H()===e)&&(!$||$.pipelines.has(e)||$.repos.has(t)),B=()=>[...[...m].filter(([,e])=>F(e.pipelineId,e.finding?.repo)).map(([e,t])=>N(t,e)),...[...f].filter(([,e])=>F(e.pipelineId)).map(([e,t])=>T(t,e))],ue={A:"apply",B:"reject",C:"park"},W=new Map;function pe(e,t){return e.status==="applied"?`Saved as instructions v${t??"?"}: the next pass reads it. Config > Instructions reverts it in one tap.`:e.status==="rejected"?"Rejected. The next retrospectives read your reason and do not propose it again without new evidence.":e.status==="stale"?"Not applied: the brief changed since this was drafted.":"Parked. Nothing changes meanwhile; it stays in Needs decision with its options."}async function fe(e,t,n){const r=f.get(e),a=T(r,e),i=ue[t];if(!i)return o(400,{error:"Pick A, B or C: Apply, Reject or Not now."});if(i==="reject"&&!n)return o(400,{error:"Say why in the box: the next retrospectives read your reason."});const s=await h(`/api/proposals/${encodeURIComponent(r.id)}/rule`,{ruling:i,reason:n});await A(),W.set(e,pe(s.proposal||f.get(e),s.version));const d=new Date().toISOString();return o(200,{ticket:{...a,answer:{option:t,text:n,answered_at:d,acked_at:i==="park"?null:d,ack_error:null}}})}function Z(){const e=w?.runs?.[0];return e?{last_push_at:e.phase==="done"||e.phase==="failed"?e.finishedAt||e.startedAt:new Date().toISOString(),received:e.signals??0,changed:(e.findings??0)+(e.dropped??0)}:null}async function ve(){try{C=(await h("/api/status")).csrf,await A();const e=new URLSearchParams(window.location.search).get("project");if($=null,e&&e!=="all"){const t=(await h("/api/workspace")).projects.find(n=>n.id===e);$={pipelines:new Set(t?.pipelineIds||[]),repos:new Set(t?.repos.map(n=>n.name)||[])}}he()}catch(e){throw e instanceof J&&e.status===401&&window.location.replace("/"),e}}function he(){const e=new URL(window.location.href),t=e.searchParams.get("finding"),n=e.searchParams.get("proposal");if(!t&&!n)return;const r=t?[...m].find(([,i])=>i.finding?.id===t)?.[0]:v.get(n),a=r&&B().find(i=>i.key===r);if(a){const i=new URL(K(X(a),r),window.location.origin);e.searchParams.set("tab",i.searchParams.get("tab")),e.searchParams.set("focus",r)}e.searchParams.delete("finding"),e.searchParams.delete("proposal"),window.history.replaceState(null,"",e)}const P=e=>({lean:async()=>e()}),Se={find:()=>P(()=>[])},_e={find:()=>P(B)},Ie={findOne:()=>P(()=>null)},Ce={findOne:()=>P(Z)},o=(e,t)=>new Response(JSON.stringify(t),{status:e,headers:{"content-type":"application/json"}});async function me({key:e,option:t,text:n}){if(f.has(e))return fe(e,t,(n||"").trim());const r=m.get(e);if(!r)return o(404,{error:"Unknown ticket"});const a=N(r,e),i=(n||"").trim();if(t==="A"){if(!r.finding)return o(400,{error:"The radar dropped this one: there is no issue to file. Answer B or C."});await h(`/api/findings/${encodeURIComponent(r.finding.id)}/file`,{})}else if(t==="B"){if(!i)return o(400,{error:"Say why in the box: a dismissal keeps its reason."});await h("/api/rulings",{clusterId:r.clusterId,ruling:"dismiss",reason:i})}else if(t==="C")await h("/api/rulings",{clusterId:r.clusterId,ruling:"park",reason:i});else return o(400,{error:"Pick A, B or C: the radar acts on one of the three."});await A();const s=new Date().toISOString();return o(200,{ticket:{...a,answer:{option:t,text:i,answered_at:s,acked_at:s,ack_error:null}}})}async function ge({key:e,reason:t}){if(f.has(e)){if(!(t||"").trim())return o(400,{error:"Say why: the next retrospectives read your reason."});const s=T(f.get(e),e);await h(`/api/proposals/${encodeURIComponent(f.get(e).id)}/rule`,{ruling:"reject",reason:t.trim()}),await A();const d=new Date().toISOString();return o(200,{ticket:{...s,cancel:{reason:t.trim(),requested_at:d,acked_at:d,ack_error:null}}})}const n=m.get(e);if(!n)return o(404,{error:"Unknown ticket"});const r=(t||"").trim();if(!r)return o(400,{error:"Say why: the radar keeps the reason with the dismissal."});const a=N(n,e);await h("/api/rulings",{clusterId:n.clusterId,ruling:"dismiss",reason:r}),await A();const i=new Date().toISOString();return o(200,{ticket:{...a,cancel:{reason:r,requested_at:i,acked_at:i,ack_error:null}}})}async function we({key:e,action:t,note:n}){const r=m.get(e);return r?.finding?["validate","later","dismiss"].includes(t)?(await h(`/api/findings/${encodeURIComponent(r.finding.id)}/validate`,{action:t,note:n}),await A(),o(200,{ticket:N(m.get(e),e)})):o(400,{error:"Validate, Later or Dismiss only."}):o(404,{error:"Unknown ticket"})}async function be(){return await A(),o(200,JSON.parse(JSON.stringify({tickets:B(),sync:Z(),read_at:new Date})))}window.fetch=async(e,t={})=>{const n=typeof e=="string"?e:e.url;if(!n.startsWith("/api/admin/"))return G(e,t);const r=n.split("?")[0];try{const a=t.body&&typeof t.body=="string"?JSON.parse(t.body):{};return r==="/api/admin/pipeline/answer"?await me(a):r==="/api/admin/pipeline/cancel"?await ge(a):r==="/api/admin/pipeline/live"?await be():r==="/api/admin/pipeline/gate"?await we(a):o(404,{error:"Not available in this radar: it has no fix pipeline yet."})}catch(a){return o(a.status||500,{error:a.message})}};const ye=/^https:\/\/[^/]+\.atlassian\.net\/browse\/([A-Z][A-Z0-9]+-\d+)$/;function xe(e){for(const t of e.querySelectorAll?.('a[href*=".atlassian.net/browse/"]')||[]){const n=ye.exec(t.getAttribute("href"))?.[1],r=n&&Y(m.get(n)?.ruling)[0]?.url;r?t.setAttribute("href",r):(t.removeAttribute("href"),t.removeAttribute("target"))}}new MutationObserver(e=>e.forEach(t=>t.addedNodes.forEach(n=>n.nodeType===1&&xe(n.parentNode||n)))).observe(document.documentElement,{childList:!0,subtree:!0});ie({pipelineOf:e=>m.get(e)?.pipelineId||f.get(e)?.pipelineId,pipelines:()=>(w?.pipelines||[]).filter(e=>!$||$.pipelines.has(e.id)),counts:()=>{const e={};for(const t of m.values())e[t.pipelineId]=(e[t.pipelineId]||0)+1;return e}});ne({proposalOf:e=>f.get(e),answerCopy:e=>W.get(e)||"Recorded on the proposal."});export{Ie as PipelineBundles,Ce as PipelineSyncStatus,_e as PipelineTicket,Se as PlatformClaim,h as engineCall,ve as init};
@@ -1,2 +1,2 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/render-card-C8_wQGAe.js","assets/fmt-BRV4RZz4.js","assets/index-CIpIMh38.js","assets/render-card-BRSD9J_M.css","assets/ConversationWorkspace-6m6xkkC1.js","assets/ConversationWorkspace-De5tnYl0.css"])))=>i.map(i=>d[i]);
2
- (function(){const l=document.createElement("link").relList;if(l&&l.supports&&l.supports("modulepreload"))return;for(const e of document.querySelectorAll('link[rel="modulepreload"]'))d(e);new MutationObserver(e=>{for(const t of e)if(t.type==="childList")for(const r of t.addedNodes)r.tagName==="LINK"&&r.rel==="modulepreload"&&d(r)}).observe(document,{childList:!0,subtree:!0});function u(e){const t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),e.crossOrigin==="use-credentials"?t.credentials="include":e.crossOrigin==="anonymous"?t.credentials="omit":t.credentials="same-origin",t}function d(e){if(e.ep)return;e.ep=!0;const t=u(e);fetch(e.href,t)}})();const E="modulepreload",v=function(n){return"/"+n},f={},m=function(l,u,d){let e=Promise.resolve();if(u&&u.length>0){let h=function(o){return Promise.all(o.map(c=>Promise.resolve(c).then(a=>({status:"fulfilled",value:a}),a=>({status:"rejected",reason:a}))))};document.getElementsByTagName("link");const r=document.querySelector("meta[property=csp-nonce]"),s=r?.nonce||r?.getAttribute("nonce");e=h(u.map(o=>{if(o=v(o),o in f)return;f[o]=!0;const c=o.endsWith(".css"),a=c?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${o}"]${a}`))return;const i=document.createElement("link");if(i.rel=c?"stylesheet":E,c||(i.as="script"),i.crossOrigin="",i.href=o,s&&i.setAttribute("nonce",s),document.head.appendChild(i),c)return new Promise((y,g)=>{i.addEventListener("load",y),i.addEventListener("error",()=>g(new Error(`Unable to preload CSS for ${o}`)))})}))}function t(r){const s=new Event("vite:preloadError",{cancelable:!0});if(s.payload=r,window.dispatchEvent(s),!s.defaultPrevented)throw r}return e.then(r=>{for(const s of r||[])s.status==="rejected"&&t(s.reason);return l().catch(t)})},p=document.getElementById("root");location.pathname==="/render/finding-card"?m(()=>import("./render-card-C8_wQGAe.js"),__vite__mapDeps([0,1,2,3])).then(n=>n.mount(p)):m(()=>import("./ConversationWorkspace-6m6xkkC1.js").then(n=>n.C),__vite__mapDeps([4,1,5])).then(n=>n.mount(p));export{m as _};
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/render-card-C8_wQGAe.js","assets/fmt-BRV4RZz4.js","assets/index-CIpIMh38.js","assets/render-card-BRSD9J_M.css","assets/ConversationWorkspace-C_HyzEg6.js","assets/ConversationWorkspace-DPeUP7L6.css"])))=>i.map(i=>d[i]);
2
+ (function(){const l=document.createElement("link").relList;if(l&&l.supports&&l.supports("modulepreload"))return;for(const e of document.querySelectorAll('link[rel="modulepreload"]'))d(e);new MutationObserver(e=>{for(const t of e)if(t.type==="childList")for(const r of t.addedNodes)r.tagName==="LINK"&&r.rel==="modulepreload"&&d(r)}).observe(document,{childList:!0,subtree:!0});function u(e){const t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),e.crossOrigin==="use-credentials"?t.credentials="include":e.crossOrigin==="anonymous"?t.credentials="omit":t.credentials="same-origin",t}function d(e){if(e.ep)return;e.ep=!0;const t=u(e);fetch(e.href,t)}})();const E="modulepreload",v=function(n){return"/"+n},f={},m=function(l,u,d){let e=Promise.resolve();if(u&&u.length>0){let h=function(o){return Promise.all(o.map(c=>Promise.resolve(c).then(a=>({status:"fulfilled",value:a}),a=>({status:"rejected",reason:a}))))};document.getElementsByTagName("link");const r=document.querySelector("meta[property=csp-nonce]"),s=r?.nonce||r?.getAttribute("nonce");e=h(u.map(o=>{if(o=v(o),o in f)return;f[o]=!0;const c=o.endsWith(".css"),a=c?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${o}"]${a}`))return;const i=document.createElement("link");if(i.rel=c?"stylesheet":E,c||(i.as="script"),i.crossOrigin="",i.href=o,s&&i.setAttribute("nonce",s),document.head.appendChild(i),c)return new Promise((y,g)=>{i.addEventListener("load",y),i.addEventListener("error",()=>g(new Error(`Unable to preload CSS for ${o}`)))})}))}function t(r){const s=new Event("vite:preloadError",{cancelable:!0});if(s.payload=r,window.dispatchEvent(s),!s.defaultPrevented)throw r}return e.then(r=>{for(const s of r||[])s.status==="rejected"&&t(s.reason);return l().catch(t)})},p=document.getElementById("root");location.pathname==="/render/finding-card"?m(()=>import("./render-card-C8_wQGAe.js"),__vite__mapDeps([0,1,2,3])).then(n=>n.mount(p)):m(()=>import("./ConversationWorkspace-C_HyzEg6.js").then(n=>n.C),__vite__mapDeps([4,1,5])).then(n=>n.mount(p));export{m as _};