geneseed 4.30.0 → 4.30.1

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.
Files changed (31) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/SHIPPED.md +1 -1
  3. package/docs/web-ui.md +21 -0
  4. package/harness.config.json +1 -1
  5. package/js/README.md +3 -3
  6. package/js/hosts/hooks.mjs +6 -4
  7. package/js/web/actions.mjs +31 -0
  8. package/js/web/handler.mjs +35 -11
  9. package/js/web/routes.mjs +27 -6
  10. package/js/web/state.mjs +22 -2
  11. package/package.json +1 -1
  12. package/web/dist/assets/{Activity-DfETiyWm.js → Activity-C8pQvnos.js} +1 -1
  13. package/web/dist/assets/{ActivityDetail-CnP3GPAN.js → ActivityDetail-D_8Bx-QO.js} +1 -1
  14. package/web/dist/assets/{CopyButton-CRAUXSG7.js → CopyButton-CYljsnLo.js} +1 -1
  15. package/web/dist/assets/{Dashboard-CaqOqtkG.js → Dashboard-DkUm4XMu.js} +2 -2
  16. package/web/dist/assets/{Docs-BFxyAVdN.js → Docs-DE04qOKj.js} +1 -1
  17. package/web/dist/assets/{GreenhouseView-19roNb5W.js → GreenhouseView-DPwhFO_j.js} +1 -1
  18. package/web/dist/assets/{Installs-BSoQN7w7.js → Installs-DmPzD4BW.js} +1 -1
  19. package/web/dist/assets/{JournalView-BgU2ybaq.js → JournalView-DQlDC-7i.js} +1 -1
  20. package/web/dist/assets/{KitApply-Ckc0P5kt.js → KitApply-BN2Az7dc.js} +1 -1
  21. package/web/dist/assets/{Kits-BZqWGWMu.js → Kits-C9qVd466.js} +1 -1
  22. package/web/dist/assets/{Laws-CnUWiNIx.js → Laws-T2wbwMmB.js} +1 -1
  23. package/web/dist/assets/{Library-rYO8owx_.js → Library-t3KocV0-.js} +1 -1
  24. package/web/dist/assets/{Loops-CljFhhQV.js → Loops-6lNY-9uR.js} +1 -1
  25. package/web/dist/assets/{OperatorHudView-xs7SCwCe.js → OperatorHudView-CLN6Qn25.js} +1 -1
  26. package/web/dist/assets/{Personal-CMPwtl36.js → Personal-xjoSqCzr.js} +1 -1
  27. package/web/dist/assets/{Tabs-CEfSUVQp.js → Tabs-DaExAgql.js} +1 -1
  28. package/web/dist/assets/api-LvBC0CnK.js +1 -0
  29. package/web/dist/assets/{index-FLVXXvV3.js → index-DhNNxhfg.js} +3 -3
  30. package/web/dist/index.html +2 -2
  31. package/web/dist/assets/api-BfpZmUMI.js +0 -1
@@ -1,2 +1,2 @@
1
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import{i as t,t as n}from"./react-DlYQp10C.js";import{t as r}from"./api-BfpZmUMI.js";import{J as i,Y as a,pt as o,vt as s,yt as c}from"./index-FLVXXvV3.js";import{t as l}from"./EmptyState-1sPNleqv.js";import{t as u}from"./usePoll-bDFN-Hr6.js";import{a as d,n as f,o as p,r as m,t as h}from"./RailCats-BuJD4Jou.js";import{t as g}from"./CopyButton-CRAUXSG7.js";import{t as _}from"./Markdown-DpmmtW2Y.js";import{t as v}from"./DataTable-BWbUx4bY.js";var y=e(t(),1),b={x:260,y:190},x=110,S=28,C=14,w=44,T=e=>e*Math.PI/180,E=e=>Math.round(e*10)/10,D=(e,t=x,n=b)=>({x:E(n.x+t*Math.cos(T(e))),y:E(n.y+t*Math.sin(T(e)))}),O=e=>e/x*(180/Math.PI)+3,k=(e,t,n,r=0)=>`M${t.x},${t.y} A${e},${e} 0 ${r} 1 ${n.x},${n.y}`,A=E(D(205).x-6),j=e=>e.length*6.4,M=e=>({x:e.x-j(e.name)/2,y:e.y-7,w:j(e.name),h:14}),N=(e,t)=>e.x<t.x+t.w&&t.x<e.x+e.w&&e.y<t.y+t.h&&t.y<e.y+e.h,P=(e,t)=>e.some((n,r)=>[...e.slice(r+1),...t.filter(e=>!e.gate)].some(e=>N(M(n),M(e))));function F(e){return e?.gate===`human`?e.gateOn?.length?`Human gate on ${e.gateOn.join(`, `)}`:`Human gate`:null}function I(e,t=[]){let n=L(e,t,0);if(n.mode!==`ring`)return n;let r=Math.min(...n.entry.map(e=>e.y-30),...n.nodes.map(e=>e.y-e.r-12),...n.inner.map(e=>e.cy-e.r-12),...n.exit?[n.exit.y-24]:[]);return r<0?L(e,t,Math.ceil(-r)):n}function L(e,t,n){let r={x:b.x,y:b.y+n},i=(e,t=x)=>D(e,t,r),a=e=>t.find(t=>t.name===e),o=e=>a(e)?.effect??null,s=e=>F(a(e)),c=e.loops||[],l=c.find(e=>e.iteration);if(!l||l.nodes.length>8)return R(e,o,s);let u=Math.max(...e.nodes.map(e=>c.filter(t=>t.nodes.includes(e)).length)),d=c.filter(e=>e!==l);if(u>3||d.some(e=>!e.nodes.every(e=>l.nodes.includes(e))))return R(e,o,s);let f=l.nodes[0],p=new Set(e.edges.filter(e=>e.to===f).map(e=>e.from)),m=new Map;for(let e of[...d].sort((e,t)=>e.nodes.length-t.nodes.length))for(let t of e.nodes.slice(1))t!==f&&!p.has(t)&&!m.has(t)&&m.set(t,e);let h=l.nodes.filter(e=>!m.has(e));if(h.length<2||d.some(e=>m.has(e.nodes[0])))return R(e,o,s);let g=360/h.length,_=h.map((e,t)=>({name:e,a:-90+t*g,r:S})),v=_.findIndex(e=>o(e.name)===`mutate`);v>=0&&_.splice(v,0,{name:`validate`,a:_[v].a-g/2,r:C,gate:!0});let y=_.map(e=>({name:e.name,...i(e.a),r:e.r,effect:e.gate?null:o(e.name),gate:!!e.gate,inner:!1,human:e.gate?null:s(e.name)})),T=_.map((e,t)=>{let n=_[(t+1)%_.length],r=(t+1===_.length?n.a+360:n.a)-O(n.r)-2,a=e.a+O(e.r);return{d:k(x,i(a),i(r),+(r-a>180)),kind:`ring`}}),A=[],M=new Map;for(let e of d)M.set(e.nodes[0],[...M.get(e.nodes[0])||[],e]);for(let[e,t]of M){let n=_.find(t=>t.name===e),r=i(n.a),a=t.length>1;t.sort((e,t)=>e.nodes.length-t.nodes.length).forEach((e,t)=>{let c=i(n.a+(a?t?18:-18:0),x+(a?54:44)),l=Math.atan2(c.y-r.y,c.x-r.x)*(180/Math.PI),u=e.nodes.filter(t=>m.get(t)===e),d=e=>u.map((t,n)=>({name:t,...D(l+(n-(u.length-1)/2)*e,w,c)})),f=105;for(;f<150&&P(d(f),y);)f+=5;d(f).forEach(({name:e,...t})=>{y.push({name:e,...t,r:S,effect:o(e),gate:!1,inner:!0,human:s(e)})});let p=l+180;T.push({d:k(w,D(p+42,w,c),D(p+138,w,c)),kind:`inner`}),T.push({d:k(w,D(p+222,w,c),D(p+318,w,c)),kind:`inner`});let h=`${e.nodes.join(e.nodes.length===2?` ⇄ `:` → `)} · max ${e.max}`,g={lx:c.x,ly:c.y+w+20,anchor:`middle`};if(a){let e=c.x>=b.x,t=Math.max(w,...u.map(e=>{let t=y.find(t=>t.name===e);return Math.abs(t.x-c.x)+S}));g={lx:E(c.x+(e?t+8:-t-8)),ly:E(c.y+4),anchor:e?`start`:`end`}}A.push({loop:e.name,cx:c.x,cy:c.y,r:w,label:h,...g})})}let N=i(205).y,I=e.nodes.filter(e=>!l.nodes.includes(e)),L=I.map((e,t)=>({name:e,x:40,y:E(N-44*(I.length-1-t)),human:s(e)})),z=e.edges.find(e=>e.to===`$close`)?.from,B=y.find(e=>e.name===z),V=B?{from:z,x:B.x+200,y:B.y-30,d:`M${B.x+S},${B.y-6} C${B.x+90},${B.y-40} ${B.x+170},${B.y-40} ${B.x+200},${B.y-30}`}:null,ee=Math.max(540,...y.map(e=>e.x+e.r+8),...V?[V.x+6+j(`close`)+8]:[],...A.map(e=>e.cx+e.r+8),...A.map(e=>e.anchor===`start`?e.lx+j(e.label)+8:e.lx+j(e.label)/2+8)),H=Math.max(300,...y.map(e=>e.y+e.r+12),...A.map(e=>Math.max(e.cy+e.r,e.ly)+12));return{mode:`ring`,width:Math.ceil(ee),height:Math.ceil(H),center:{x:r.x,y:r.y,r:x},nodes:y,arcs:T,inner:A,entry:L,exit:V}}function R(e,t,n){let r=e.loops||[],i=e=>36+16*r.filter(t=>t!==e&&t.nodes.every(t=>e.nodes.includes(t))).length,a=Math.max(S,...r.map(i))+30,o=new Map(e.nodes.map((e,t)=>[e,60+t*100])),s=e.nodes.map(e=>({name:e,x:o.get(e),y:a,r:S,effect:t(e),gate:!1,inner:!1,human:n(e)})),c=e.nodes.slice(1).map((t,n)=>({d:`M${o.get(e.nodes[n])+S},${a} L${o.get(t)-S-4},${a}`,kind:`flow`})),l=r.map(e=>{let t=i(e),n=Math.min(...e.nodes.map(e=>o.get(e))),r=Math.max(...e.nodes.map(e=>o.get(e))),s={x:n-t,y:a-t,w:r-n+2*t,h:2*t};return c.push({d:`M${r},${s.y+s.h} L${n+4},${s.y+s.h}`,kind:`flow`}),{loop:e.name,label:`${e.name} · max ${e.max}`,box:s}});return{mode:`flow`,width:60+e.nodes.length*100,height:2*a,center:null,nodes:s,arcs:c,inner:l,entry:[],exit:null}}var z=n();function B({x:e,y:t,label:n}){return(0,z.jsxs)(`g`,{className:`lr-human`,children:[(0,z.jsx)(`title`,{children:n}),(0,z.jsx)(`circle`,{cx:e,cy:t,r:`9`}),(0,z.jsx)(`circle`,{cx:e,cy:t-2.4,r:`2.6`,className:`lr-human-fig`}),(0,z.jsx)(`path`,{d:`M${e-4.6},${t+5.6} a4.6,4.6 0 0 1 9.2,0 Z`,className:`lr-human-fig`})]})}function V({graph:e,bricks:t,onSelect:n,highlight:r}){let i=I(e,t),a=(e.loops||[]).find(e=>e.iteration),o=e=>`${e.name} brick${e.human?`, ${e.human.toLowerCase()}`:``}`,s=e=>t=>{(t.type===`click`||t.key===`Enter`||t.key===` `)&&(t.preventDefault(),n?.(e))};return(0,z.jsxs)(`svg`,{className:`loop-ring`,viewBox:`0 0 ${i.width} ${i.height}`,role:`group`,"aria-label":`${e.name} loop: ${e.nodes.join(`, `)}`,children:[(0,z.jsx)(`defs`,{children:[`ring`,`inner`,`flow`].map(e=>(0,z.jsx)(`marker`,{id:`lr-arrow-${e}`,markerWidth:`10`,markerHeight:`10`,refX:`7`,refY:`4`,orient:`auto`,children:(0,z.jsx)(`path`,{d:`M0,0 L8,4 L0,8 Z`,className:`lr-head-${e}`})},e))}),i.mode===`ring`&&i.inner.map(e=>(0,z.jsxs)(`g`,{children:[(0,z.jsx)(`circle`,{cx:e.cx,cy:e.cy,r:e.r,className:`lr-inner`}),(0,z.jsx)(`text`,{x:e.lx,y:e.ly,textAnchor:e.anchor,className:`lr-sub lr-good`,children:e.label})]},e.loop)),i.mode===`flow`&&i.inner.map(e=>(0,z.jsxs)(`g`,{children:[(0,z.jsx)(`rect`,{x:e.box.x,y:e.box.y,width:e.box.w,height:e.box.h,rx:`14`,className:`lr-box`}),(0,z.jsx)(`text`,{x:e.box.x+10,y:e.box.y-6,className:`lr-sub lr-good`,children:e.label})]},e.loop)),i.arcs.map((e,t)=>(0,z.jsx)(`path`,{d:e.d,className:`lr-${e.kind}`,markerEnd:`url(#lr-arrow-${e.kind})`},t)),i.entry.length>0&&(0,z.jsxs)(`g`,{children:[(0,z.jsx)(`path`,{d:`M40,${i.entry.at(-1).y} L${A},${i.entry.at(-1).y}`,className:`lr-flow`,markerEnd:`url(#lr-arrow-flow)`}),i.entry.map(e=>(0,z.jsxs)(`g`,{children:[(0,z.jsx)(`text`,{x:e.x,y:e.y-10,className:`lr-lbl`,children:e.name}),(0,z.jsx)(`text`,{x:e.x,y:e.y+18,className:`lr-sub`,children:`setup · 1×`}),e.human?(0,z.jsx)(B,{x:e.x-14,y:e.y-14,label:e.human}):null]},e.name))]}),i.nodes.map(e=>e.gate?(0,z.jsxs)(`g`,{className:`lr-gate`,children:[(0,z.jsx)(`title`,{children:`validate — the engine scores the change before the first mutate step`}),(0,z.jsx)(`circle`,{cx:e.x,cy:e.y,r:e.r}),(0,z.jsx)(`text`,{x:e.x,y:e.y+5,textAnchor:`middle`,children:`⛨`}),(0,z.jsx)(`text`,{x:e.x+20,y:e.y-10,className:`lr-sub lr-warn`,children:`validate`})]},e.name):(0,z.jsxs)(`g`,{className:`lr-node${e.inner?` inner`:``}${e.effect===`mutate`?` mutate`:``}${e.name===r?` current`:``}`,"aria-current":e.name===r?`step`:void 0,...n?{role:`button`,tabIndex:0,"aria-label":o(e),onClick:s(e.name),onKeyDown:s(e.name)}:{role:`img`,"aria-label":`${o(e)}${e.name===r?`, current step`:``}`},children:[(0,z.jsx)(`circle`,{cx:e.x,cy:e.y,r:e.r}),(0,z.jsx)(`text`,{x:e.x,y:e.y+4,textAnchor:`middle`,children:e.name}),e.human?(0,z.jsx)(B,{x:e.x+e.r*.74,y:e.y-e.r*.74,label:e.human}):null]},e.name)),i.exit&&(0,z.jsxs)(`g`,{children:[(0,z.jsx)(`path`,{d:i.exit.d,className:`lr-flow`,markerEnd:`url(#lr-arrow-flow)`}),(0,z.jsx)(`text`,{x:i.exit.x+6,y:i.exit.y+4,className:`lr-lbl`,children:`close`}),(0,z.jsx)(`text`,{x:i.exit.x-90,y:i.exit.y-10,textAnchor:`middle`,className:`lr-sub`,children:`done`})]}),i.center&&a&&(0,z.jsxs)(`g`,{children:[(0,z.jsx)(`text`,{x:i.center.x,y:i.center.y-4,textAnchor:`middle`,className:`lr-title`,children:e.name}),(0,z.jsxs)(`text`,{x:i.center.x,y:i.center.y+16,textAnchor:`middle`,className:`lr-sub lr-acc`,children:[`iterations · max `,a.max]})]})]})}var ee=5e3,H=[`prudent`,`balanced`,`aggressive`],U={running:`acc`,awaiting:`warn`,unreadable:`bad`},W=e=>!!e.graph;function te(){let[e,t]=(0,y.useState)(null),[n,i]=(0,y.useState)(null),[a,o]=(0,y.useState)(null),[s,c]=(0,y.useState)(0);return u(e=>r.activeLoops().then(n=>e()&&(t(n),i(null)),t=>e()&&i(t.message)),ee,[s]),{loops:e?.loops??null,error:a||n,onPreset:(e,t)=>(o(null),r.setLoopPreset(e,t).then(()=>c(e=>e+1),e=>o(e.message)))}}var G=e=>({key:e,label:e,align:`right`,render:t=>(0,z.jsx)(`span`,{className:`num`,children:t[e]})}),ne=[G(`iteration`),{key:`intent`,label:`intent`},G(`declared`),G(`actual`),{key:`decision`,label:`decision`},{key:`tests`,label:`tests`}];function re({history:e}){return e.length?(0,z.jsx)(`div`,{className:`loop-history`,children:(0,z.jsx)(v,{caption:`Iterations`,captionHidden:!0,columns:ne,rows:e,rowKey:e=>e.iteration})}):(0,z.jsx)(`p`,{className:`panel-note`,children:`No iteration finished yet.`})}function ie({loop:e,bricks:t,onPreset:n}){let r=W(e)?(e.graph.loops||[]).find(e=>e.iteration):null,[i,a]=(0,y.useState)(!1);return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(`div`,{className:`reader-tags`,children:[(0,z.jsx)(`span`,{className:`tag acc`,children:`Active loop`}),(0,z.jsx)(`span`,{className:`tag${U[e.status]?` ${U[e.status]}`:``}`,children:e.status})]}),(0,z.jsx)(`h2`,{className:`reader-title`,children:e.title}),(0,z.jsxs)(`p`,{className:`mono dim reader-src`,children:[e.branch,` · `,e.root]}),W(e)?(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(`p`,{className:`reader-lede`,children:[`Iteration `,e.iteration,r?` / ${r.max}`:``,` · at `,e.node]}),e.awaiting?(0,z.jsxs)(`p`,{className:`loop-run-wait t-warn`,children:[(0,z.jsxs)(`b`,{children:[`Awaiting `,e.awaiting.kind,e.awaiting.kind===`gate`?` at ${e.awaiting.node}`:``]}),` `,`— Answer in the agent's session.`]}):null,(0,z.jsxs)(`label`,{className:`panel-note loop-run-preset`,children:[`preset`,(0,z.jsx)(`select`,{className:`sel`,"aria-label":`Preset for ${e.title}`,value:e.preset,disabled:i,onChange:t=>{a(!0),Promise.resolve(n(e.root,t.target.value)).finally(()=>a(!1))},children:H.map(e=>(0,z.jsx)(`option`,{children:e},e))})]}),(0,z.jsx)(`a`,{href:`#/docs/loop-risk`,children:`What presets mean →`}),(0,z.jsx)(`hr`,{className:`hr`}),(0,z.jsx)(`div`,{className:`loop-graph`,children:(0,z.jsx)(V,{graph:e.graph,bricks:t,highlight:e.node})}),(0,z.jsx)(`h3`,{className:`loop-h2`,children:`Iterations`}),(0,z.jsx)(re,{history:e.history})]}):(0,z.jsx)(`p`,{className:`reader-lede`,children:e.status===`unreadable`?`Its LOOP.md cannot be read, so there is no state to show.`:`Its LOOP.md is gone: the loop closed and its state went with it.`})]})}var K=encodeURIComponent,q=s.loops.map(e=>[e,c[e]]),J={architecture:`Architecture`,tests:`Tests`,development:`Development`,refactoring:`Refactoring`,"day-to-day":`Day-to-day`},ae={project:`Project`,global:`Global`,shipped:`Shipped`},oe={templates:`Categories`,bricks:`Origins`,active:`Statuses`},se=[[`awaiting`,`Awaiting`],[`running`,`Running`],[`done`,`Done · stopped`],[`stopped`,`Done · stopped`],[`finished`,`Finished · unreadable`],[`unreadable`,`Finished · unreadable`]];function Y(e,t){let n=e.filter(e=>e.startsWith(`${t} (`)).at(-1);return n?/(overrides \w+)\)$/.exec(n)?.[1]:null}var X=(e,t,n)=>n.flatMap(([n,r])=>e.filter(e=>t(e)===n).map(e=>({...e,group:r})));function Z(e,t){let n=new Set(t.filter(e=>e.gate===`human`).map(e=>e.name));return X(e.map(e=>({...e,desc:e.description,human:e.graph.nodes.some(e=>n.has(e))})),e=>J[e.graph.category]?e.graph.category:`other`,[...Object.entries(J),[`other`,`Other`]])}function Q(e,t){return X(e.map(e=>({...e,desc:e.description,override:Y(t,e.name)})),e=>e.origin,Object.entries(ae))}function ce(e){return X(e.map(e=>({...e,name:e.root,desc:e.branch})),e=>e.status,se)}var $=(e,t)=>(0,z.jsx)(`span`,{className:`tag${e?` ${e}`:``}`,children:t},t),le={templates:e=>e.human?$(`human`,`human gate`):null,bricks:e=>[e.effect===`mutate`?$(`warn`,`mutate`):null,F(e)?$(`human`,`human gate`):null,e.override?$(`acc`,e.override):null,e.available===!1?$(`bad`,`unavailable`):null],active:e=>$(U[e.status],e.status)};function ue({name:e,brick:t,override:n,on:r}){let i=`loop-brick${r?` on`:``}${!t||t.available===!1?` dimmed`:``}`;return t?(0,z.jsxs)(`li`,{className:i,id:`brick-${e}`,children:[(0,z.jsx)(`b`,{children:(0,z.jsx)(`a`,{href:`#/loops/bricks/${K(e)}`,children:e})}),$(t.effect===`mutate`?`warn`:``,t.effect),(0,z.jsx)(`span`,{className:`mono dim`,children:t.agent||t.skill}),(0,z.jsx)(`span`,{className:`panel-note`,children:t.outcomes.join(` · `)}),F(t)?$(`human`,F(t).toLowerCase()):null,n?$(`acc`,n):null]}):(0,z.jsxs)(`li`,{className:i,id:`brick-${e}`,children:[(0,z.jsx)(`b`,{children:e}),(0,z.jsx)(`span`,{className:`panel-note`,children:`Not in the catalogue: this template cannot run as is.`})]})}function de(e){let t=e.loops||[],n=t.find(e=>e.iteration),r=n?.nodes[0],i=t=>{let n=new Map;for(let r of e.edges.filter(t))n.set(r.from,[...n.get(r.from)||[],r.on]);return[...n].map(([e,t])=>`${e} says ${t.join(` or `)}`).join(`, `)},a=t=>{let i=e.edges.filter(e=>e.to===t);return!!n&&t!==r&&i.length>0&&i.every(e=>e.from===r)&&e.edges.some(e=>e.from===t&&e.to===`$close`)},o=[...new Set(e.edges.filter(e=>e.to===`$close`).map(e=>e.from))].map(e=>a(e)?`${i(t=>t.to===e)} → ${e}; ${i(t=>t.from===e&&t.to===`$close`)} → close`:`${i(t=>t.from===e&&t.to===`$close`)} → close`),s=t.filter(e=>!e.iteration).map(e=>`${e.nodes.join(e.nodes.length===2?` ⇄ `:` → `)}, max ${e.max}`),c=n?e.nodes.filter(e=>!n.nodes.includes(e)):[],l=i(e=>e.to===`$stop`);return[c.length&&[`Setup`,`${c.join(` → `)}, once.`],n?[`Iteration (max ${n.max})`,`${n.nodes.filter(e=>!a(e)).join(` → `)}.`]:[`Steps`,`${e.nodes.join(` → `)}.`],s.length&&[`Retry`,`${s.join(`; `)}.`],o.length&&[`Exit`,`${o.join(`; `)}.`],[`Stop`,`${l?`${l}, or `:``}any step says error → stop.`]].filter(Boolean)}function fe({t:e,bricks:t,overridden:n,runs:r}){let[i,a]=(0,y.useState)(null),o=new Map(t.map(e=>[e.name,e])),s=de(e.graph),c=I(e.graph,t),l=c.mode===`ring`,u=`geneseed loop init --graph ${e.name} --title "<title>" --requirement "<requirement>"`,d=r?.filter(t=>W(t)&&t.graph.name===e.name).length;return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(`div`,{className:`reader-tags`,children:[(0,z.jsx)(`span`,{className:`tag acc`,children:`Template`}),J[e.graph.category]?$(``,J[e.graph.category]):null,e.human?$(`human`,`human gate`):null]}),(0,z.jsx)(`h2`,{className:`reader-title`,children:e.name}),e.description?(0,z.jsx)(`p`,{className:`reader-lede`,children:e.description}):null,(0,z.jsxs)(`p`,{className:`mono dim reader-src`,children:[`loops/`,e.name,`.json · `,e.origin]}),(0,z.jsx)(`hr`,{className:`hr`}),(0,z.jsxs)(`figure`,{className:`loop-console`,children:[(0,z.jsx)(`div`,{className:l?`loop-graph`:`loop-graph flow`,style:l?void 0:{"--loop-w":`${c.width}px`},children:(0,z.jsx)(V,{graph:e.graph,bricks:t,onSelect:e=>{a(e),document.getElementById(`brick-${e}`)?.scrollIntoView?.({behavior:`smooth`,block:`nearest`})}})}),(0,z.jsxs)(`figcaption`,{className:`loop-how`,children:[(0,z.jsx)(`span`,{className:`loop-kicker`,children:`How it runs`}),(0,z.jsx)(`ol`,{children:s.map(([e,t])=>(0,z.jsxs)(`li`,{children:[(0,z.jsxs)(`b`,{children:[e,`:`]}),` `,t]},e))}),l?(0,z.jsxs)(`span`,{className:`loop-legend`,children:[(0,z.jsxs)(`span`,{children:[(0,z.jsx)(`i`,{className:`ring`,"aria-hidden":`true`}),`iteration`]}),s.some(([e])=>e===`Retry`)?(0,z.jsxs)(`span`,{children:[(0,z.jsx)(`i`,{className:`inner`,"aria-hidden":`true`}),`retry`]}):null]}):null]})]}),(0,z.jsxs)(`section`,{className:`loop-start`,"aria-labelledby":`loop-start-h`,children:[(0,z.jsxs)(`div`,{className:`loop-start-bar`,children:[(0,z.jsx)(`h3`,{id:`loop-start-h`,className:`loop-kicker`,children:`Start it in your project`}),(0,z.jsx)(g,{text:u,label:`Copy command`})]}),(0,z.jsx)(`pre`,{className:`mono`,children:u})]}),r?(0,z.jsxs)(`p`,{className:`panel-note loop-running`,children:[`Running now: `,d?`${d} of this template`:`none`,`.`,` `,d?(0,z.jsx)(`a`,{href:`#/loops/active`,children:`Open Active →`}):`A started loop appears under Active with its iteration and preset.`]}):null,e.graph.rules?.length?(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`h3`,{className:`loop-h2`,children:`Rules`}),(0,z.jsx)(`ul`,{className:`loop-rules`,"aria-label":`Rules every brick follows`,children:e.graph.rules.map(e=>(0,z.jsx)(`li`,{children:e},e))})]}):null,(0,z.jsx)(`h3`,{className:`loop-h2`,children:`Bricks`}),(0,z.jsx)(`ul`,{className:`loop-brick-list`,"aria-label":`Bricks in ${e.name}`,children:e.graph.nodes.map(e=>(0,z.jsx)(ue,{name:e,brick:o.get(e),override:Y(n,e),on:i===e},e))})]})}function pe(e){return`---\n${[[`name`,e.name],[`description`,e.description],[`effect`,e.effect],[e.agent?`agent`:`skill`,e.agent||e.skill],[`gate`,e.gate],[`gateOn`,e.gateOn?.join(`, `)],[`outcomes`,e.outcomes.join(`, `)]].filter(([,e])=>e).map(([e,t])=>`${e}: ${t}`).join(`
1
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{i as t,t as n}from"./react-DlYQp10C.js";import{t as r}from"./api-LvBC0CnK.js";import{J as i,Y as a,pt as o,vt as s,yt as c}from"./index-DhNNxhfg.js";import{t as l}from"./EmptyState-1sPNleqv.js";import{t as u}from"./usePoll-bDFN-Hr6.js";import{a as d,n as f,o as p,r as m,t as h}from"./RailCats-BuJD4Jou.js";import{t as g}from"./CopyButton-CYljsnLo.js";import{t as _}from"./Markdown-DpmmtW2Y.js";import{t as v}from"./DataTable-BWbUx4bY.js";var y=e(t(),1),b={x:260,y:190},x=110,S=28,C=14,w=44,T=e=>e*Math.PI/180,E=e=>Math.round(e*10)/10,D=(e,t=x,n=b)=>({x:E(n.x+t*Math.cos(T(e))),y:E(n.y+t*Math.sin(T(e)))}),O=e=>e/x*(180/Math.PI)+3,k=(e,t,n,r=0)=>`M${t.x},${t.y} A${e},${e} 0 ${r} 1 ${n.x},${n.y}`,A=E(D(205).x-6),j=e=>e.length*6.4,M=e=>({x:e.x-j(e.name)/2,y:e.y-7,w:j(e.name),h:14}),N=(e,t)=>e.x<t.x+t.w&&t.x<e.x+e.w&&e.y<t.y+t.h&&t.y<e.y+e.h,P=(e,t)=>e.some((n,r)=>[...e.slice(r+1),...t.filter(e=>!e.gate)].some(e=>N(M(n),M(e))));function F(e){return e?.gate===`human`?e.gateOn?.length?`Human gate on ${e.gateOn.join(`, `)}`:`Human gate`:null}function I(e,t=[]){let n=L(e,t,0);if(n.mode!==`ring`)return n;let r=Math.min(...n.entry.map(e=>e.y-30),...n.nodes.map(e=>e.y-e.r-12),...n.inner.map(e=>e.cy-e.r-12),...n.exit?[n.exit.y-24]:[]);return r<0?L(e,t,Math.ceil(-r)):n}function L(e,t,n){let r={x:b.x,y:b.y+n},i=(e,t=x)=>D(e,t,r),a=e=>t.find(t=>t.name===e),o=e=>a(e)?.effect??null,s=e=>F(a(e)),c=e.loops||[],l=c.find(e=>e.iteration);if(!l||l.nodes.length>8)return R(e,o,s);let u=Math.max(...e.nodes.map(e=>c.filter(t=>t.nodes.includes(e)).length)),d=c.filter(e=>e!==l);if(u>3||d.some(e=>!e.nodes.every(e=>l.nodes.includes(e))))return R(e,o,s);let f=l.nodes[0],p=new Set(e.edges.filter(e=>e.to===f).map(e=>e.from)),m=new Map;for(let e of[...d].sort((e,t)=>e.nodes.length-t.nodes.length))for(let t of e.nodes.slice(1))t!==f&&!p.has(t)&&!m.has(t)&&m.set(t,e);let h=l.nodes.filter(e=>!m.has(e));if(h.length<2||d.some(e=>m.has(e.nodes[0])))return R(e,o,s);let g=360/h.length,_=h.map((e,t)=>({name:e,a:-90+t*g,r:S})),v=_.findIndex(e=>o(e.name)===`mutate`);v>=0&&_.splice(v,0,{name:`validate`,a:_[v].a-g/2,r:C,gate:!0});let y=_.map(e=>({name:e.name,...i(e.a),r:e.r,effect:e.gate?null:o(e.name),gate:!!e.gate,inner:!1,human:e.gate?null:s(e.name)})),T=_.map((e,t)=>{let n=_[(t+1)%_.length],r=(t+1===_.length?n.a+360:n.a)-O(n.r)-2,a=e.a+O(e.r);return{d:k(x,i(a),i(r),+(r-a>180)),kind:`ring`}}),A=[],M=new Map;for(let e of d)M.set(e.nodes[0],[...M.get(e.nodes[0])||[],e]);for(let[e,t]of M){let n=_.find(t=>t.name===e),r=i(n.a),a=t.length>1;t.sort((e,t)=>e.nodes.length-t.nodes.length).forEach((e,t)=>{let c=i(n.a+(a?t?18:-18:0),x+(a?54:44)),l=Math.atan2(c.y-r.y,c.x-r.x)*(180/Math.PI),u=e.nodes.filter(t=>m.get(t)===e),d=e=>u.map((t,n)=>({name:t,...D(l+(n-(u.length-1)/2)*e,w,c)})),f=105;for(;f<150&&P(d(f),y);)f+=5;d(f).forEach(({name:e,...t})=>{y.push({name:e,...t,r:S,effect:o(e),gate:!1,inner:!0,human:s(e)})});let p=l+180;T.push({d:k(w,D(p+42,w,c),D(p+138,w,c)),kind:`inner`}),T.push({d:k(w,D(p+222,w,c),D(p+318,w,c)),kind:`inner`});let h=`${e.nodes.join(e.nodes.length===2?` ⇄ `:` → `)} · max ${e.max}`,g={lx:c.x,ly:c.y+w+20,anchor:`middle`};if(a){let e=c.x>=b.x,t=Math.max(w,...u.map(e=>{let t=y.find(t=>t.name===e);return Math.abs(t.x-c.x)+S}));g={lx:E(c.x+(e?t+8:-t-8)),ly:E(c.y+4),anchor:e?`start`:`end`}}A.push({loop:e.name,cx:c.x,cy:c.y,r:w,label:h,...g})})}let N=i(205).y,I=e.nodes.filter(e=>!l.nodes.includes(e)),L=I.map((e,t)=>({name:e,x:40,y:E(N-44*(I.length-1-t)),human:s(e)})),z=e.edges.find(e=>e.to===`$close`)?.from,B=y.find(e=>e.name===z),V=B?{from:z,x:B.x+200,y:B.y-30,d:`M${B.x+S},${B.y-6} C${B.x+90},${B.y-40} ${B.x+170},${B.y-40} ${B.x+200},${B.y-30}`}:null,ee=Math.max(540,...y.map(e=>e.x+e.r+8),...V?[V.x+6+j(`close`)+8]:[],...A.map(e=>e.cx+e.r+8),...A.map(e=>e.anchor===`start`?e.lx+j(e.label)+8:e.lx+j(e.label)/2+8)),H=Math.max(300,...y.map(e=>e.y+e.r+12),...A.map(e=>Math.max(e.cy+e.r,e.ly)+12));return{mode:`ring`,width:Math.ceil(ee),height:Math.ceil(H),center:{x:r.x,y:r.y,r:x},nodes:y,arcs:T,inner:A,entry:L,exit:V}}function R(e,t,n){let r=e.loops||[],i=e=>36+16*r.filter(t=>t!==e&&t.nodes.every(t=>e.nodes.includes(t))).length,a=Math.max(S,...r.map(i))+30,o=new Map(e.nodes.map((e,t)=>[e,60+t*100])),s=e.nodes.map(e=>({name:e,x:o.get(e),y:a,r:S,effect:t(e),gate:!1,inner:!1,human:n(e)})),c=e.nodes.slice(1).map((t,n)=>({d:`M${o.get(e.nodes[n])+S},${a} L${o.get(t)-S-4},${a}`,kind:`flow`})),l=r.map(e=>{let t=i(e),n=Math.min(...e.nodes.map(e=>o.get(e))),r=Math.max(...e.nodes.map(e=>o.get(e))),s={x:n-t,y:a-t,w:r-n+2*t,h:2*t};return c.push({d:`M${r},${s.y+s.h} L${n+4},${s.y+s.h}`,kind:`flow`}),{loop:e.name,label:`${e.name} · max ${e.max}`,box:s}});return{mode:`flow`,width:60+e.nodes.length*100,height:2*a,center:null,nodes:s,arcs:c,inner:l,entry:[],exit:null}}var z=n();function B({x:e,y:t,label:n}){return(0,z.jsxs)(`g`,{className:`lr-human`,children:[(0,z.jsx)(`title`,{children:n}),(0,z.jsx)(`circle`,{cx:e,cy:t,r:`9`}),(0,z.jsx)(`circle`,{cx:e,cy:t-2.4,r:`2.6`,className:`lr-human-fig`}),(0,z.jsx)(`path`,{d:`M${e-4.6},${t+5.6} a4.6,4.6 0 0 1 9.2,0 Z`,className:`lr-human-fig`})]})}function V({graph:e,bricks:t,onSelect:n,highlight:r}){let i=I(e,t),a=(e.loops||[]).find(e=>e.iteration),o=e=>`${e.name} brick${e.human?`, ${e.human.toLowerCase()}`:``}`,s=e=>t=>{(t.type===`click`||t.key===`Enter`||t.key===` `)&&(t.preventDefault(),n?.(e))};return(0,z.jsxs)(`svg`,{className:`loop-ring`,viewBox:`0 0 ${i.width} ${i.height}`,role:`group`,"aria-label":`${e.name} loop: ${e.nodes.join(`, `)}`,children:[(0,z.jsx)(`defs`,{children:[`ring`,`inner`,`flow`].map(e=>(0,z.jsx)(`marker`,{id:`lr-arrow-${e}`,markerWidth:`10`,markerHeight:`10`,refX:`7`,refY:`4`,orient:`auto`,children:(0,z.jsx)(`path`,{d:`M0,0 L8,4 L0,8 Z`,className:`lr-head-${e}`})},e))}),i.mode===`ring`&&i.inner.map(e=>(0,z.jsxs)(`g`,{children:[(0,z.jsx)(`circle`,{cx:e.cx,cy:e.cy,r:e.r,className:`lr-inner`}),(0,z.jsx)(`text`,{x:e.lx,y:e.ly,textAnchor:e.anchor,className:`lr-sub lr-good`,children:e.label})]},e.loop)),i.mode===`flow`&&i.inner.map(e=>(0,z.jsxs)(`g`,{children:[(0,z.jsx)(`rect`,{x:e.box.x,y:e.box.y,width:e.box.w,height:e.box.h,rx:`14`,className:`lr-box`}),(0,z.jsx)(`text`,{x:e.box.x+10,y:e.box.y-6,className:`lr-sub lr-good`,children:e.label})]},e.loop)),i.arcs.map((e,t)=>(0,z.jsx)(`path`,{d:e.d,className:`lr-${e.kind}`,markerEnd:`url(#lr-arrow-${e.kind})`},t)),i.entry.length>0&&(0,z.jsxs)(`g`,{children:[(0,z.jsx)(`path`,{d:`M40,${i.entry.at(-1).y} L${A},${i.entry.at(-1).y}`,className:`lr-flow`,markerEnd:`url(#lr-arrow-flow)`}),i.entry.map(e=>(0,z.jsxs)(`g`,{children:[(0,z.jsx)(`text`,{x:e.x,y:e.y-10,className:`lr-lbl`,children:e.name}),(0,z.jsx)(`text`,{x:e.x,y:e.y+18,className:`lr-sub`,children:`setup · 1×`}),e.human?(0,z.jsx)(B,{x:e.x-14,y:e.y-14,label:e.human}):null]},e.name))]}),i.nodes.map(e=>e.gate?(0,z.jsxs)(`g`,{className:`lr-gate`,children:[(0,z.jsx)(`title`,{children:`validate — the engine scores the change before the first mutate step`}),(0,z.jsx)(`circle`,{cx:e.x,cy:e.y,r:e.r}),(0,z.jsx)(`text`,{x:e.x,y:e.y+5,textAnchor:`middle`,children:`⛨`}),(0,z.jsx)(`text`,{x:e.x+20,y:e.y-10,className:`lr-sub lr-warn`,children:`validate`})]},e.name):(0,z.jsxs)(`g`,{className:`lr-node${e.inner?` inner`:``}${e.effect===`mutate`?` mutate`:``}${e.name===r?` current`:``}`,"aria-current":e.name===r?`step`:void 0,...n?{role:`button`,tabIndex:0,"aria-label":o(e),onClick:s(e.name),onKeyDown:s(e.name)}:{role:`img`,"aria-label":`${o(e)}${e.name===r?`, current step`:``}`},children:[(0,z.jsx)(`circle`,{cx:e.x,cy:e.y,r:e.r}),(0,z.jsx)(`text`,{x:e.x,y:e.y+4,textAnchor:`middle`,children:e.name}),e.human?(0,z.jsx)(B,{x:e.x+e.r*.74,y:e.y-e.r*.74,label:e.human}):null]},e.name)),i.exit&&(0,z.jsxs)(`g`,{children:[(0,z.jsx)(`path`,{d:i.exit.d,className:`lr-flow`,markerEnd:`url(#lr-arrow-flow)`}),(0,z.jsx)(`text`,{x:i.exit.x+6,y:i.exit.y+4,className:`lr-lbl`,children:`close`}),(0,z.jsx)(`text`,{x:i.exit.x-90,y:i.exit.y-10,textAnchor:`middle`,className:`lr-sub`,children:`done`})]}),i.center&&a&&(0,z.jsxs)(`g`,{children:[(0,z.jsx)(`text`,{x:i.center.x,y:i.center.y-4,textAnchor:`middle`,className:`lr-title`,children:e.name}),(0,z.jsxs)(`text`,{x:i.center.x,y:i.center.y+16,textAnchor:`middle`,className:`lr-sub lr-acc`,children:[`iterations · max `,a.max]})]})]})}var ee=5e3,H=[`prudent`,`balanced`,`aggressive`],U={running:`acc`,awaiting:`warn`,unreadable:`bad`},W=e=>!!e.graph;function te(){let[e,t]=(0,y.useState)(null),[n,i]=(0,y.useState)(null),[a,o]=(0,y.useState)(null),[s,c]=(0,y.useState)(0);return u(e=>r.activeLoops().then(n=>e()&&(t(n),i(null)),t=>e()&&i(t.message)),ee,[s]),{loops:e?.loops??null,error:a||n,onPreset:(e,t)=>(o(null),r.setLoopPreset(e,t).then(()=>c(e=>e+1),e=>o(e.message)))}}var G=e=>({key:e,label:e,align:`right`,render:t=>(0,z.jsx)(`span`,{className:`num`,children:t[e]})}),ne=[G(`iteration`),{key:`intent`,label:`intent`},G(`declared`),G(`actual`),{key:`decision`,label:`decision`},{key:`tests`,label:`tests`}];function re({history:e}){return e.length?(0,z.jsx)(`div`,{className:`loop-history`,children:(0,z.jsx)(v,{caption:`Iterations`,captionHidden:!0,columns:ne,rows:e,rowKey:e=>e.iteration})}):(0,z.jsx)(`p`,{className:`panel-note`,children:`No iteration finished yet.`})}function ie({loop:e,bricks:t,onPreset:n}){let r=W(e)?(e.graph.loops||[]).find(e=>e.iteration):null,[i,a]=(0,y.useState)(!1);return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(`div`,{className:`reader-tags`,children:[(0,z.jsx)(`span`,{className:`tag acc`,children:`Active loop`}),(0,z.jsx)(`span`,{className:`tag${U[e.status]?` ${U[e.status]}`:``}`,children:e.status})]}),(0,z.jsx)(`h2`,{className:`reader-title`,children:e.title}),(0,z.jsxs)(`p`,{className:`mono dim reader-src`,children:[e.branch,` · `,e.root]}),W(e)?(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(`p`,{className:`reader-lede`,children:[`Iteration `,e.iteration,r?` / ${r.max}`:``,` · at `,e.node]}),e.awaiting?(0,z.jsxs)(`p`,{className:`loop-run-wait t-warn`,children:[(0,z.jsxs)(`b`,{children:[`Awaiting `,e.awaiting.kind,e.awaiting.kind===`gate`?` at ${e.awaiting.node}`:``]}),` `,`— Answer in the agent's session.`]}):null,(0,z.jsxs)(`label`,{className:`panel-note loop-run-preset`,children:[`preset`,(0,z.jsx)(`select`,{className:`sel`,"aria-label":`Preset for ${e.title}`,value:e.preset,disabled:i,onChange:t=>{a(!0),Promise.resolve(n(e.root,t.target.value)).finally(()=>a(!1))},children:H.map(e=>(0,z.jsx)(`option`,{children:e},e))})]}),(0,z.jsx)(`a`,{href:`#/docs/loop-risk`,children:`What presets mean →`}),(0,z.jsx)(`hr`,{className:`hr`}),(0,z.jsx)(`div`,{className:`loop-graph`,children:(0,z.jsx)(V,{graph:e.graph,bricks:t,highlight:e.node})}),(0,z.jsx)(`h3`,{className:`loop-h2`,children:`Iterations`}),(0,z.jsx)(re,{history:e.history})]}):(0,z.jsx)(`p`,{className:`reader-lede`,children:e.status===`unreadable`?`Its LOOP.md cannot be read, so there is no state to show.`:`Its LOOP.md is gone: the loop closed and its state went with it.`})]})}var K=encodeURIComponent,q=s.loops.map(e=>[e,c[e]]),J={architecture:`Architecture`,tests:`Tests`,development:`Development`,refactoring:`Refactoring`,"day-to-day":`Day-to-day`},ae={project:`Project`,global:`Global`,shipped:`Shipped`},oe={templates:`Categories`,bricks:`Origins`,active:`Statuses`},se=[[`awaiting`,`Awaiting`],[`running`,`Running`],[`done`,`Done · stopped`],[`stopped`,`Done · stopped`],[`finished`,`Finished · unreadable`],[`unreadable`,`Finished · unreadable`]];function Y(e,t){let n=e.filter(e=>e.startsWith(`${t} (`)).at(-1);return n?/(overrides \w+)\)$/.exec(n)?.[1]:null}var X=(e,t,n)=>n.flatMap(([n,r])=>e.filter(e=>t(e)===n).map(e=>({...e,group:r})));function Z(e,t){let n=new Set(t.filter(e=>e.gate===`human`).map(e=>e.name));return X(e.map(e=>({...e,desc:e.description,human:e.graph.nodes.some(e=>n.has(e))})),e=>J[e.graph.category]?e.graph.category:`other`,[...Object.entries(J),[`other`,`Other`]])}function Q(e,t){return X(e.map(e=>({...e,desc:e.description,override:Y(t,e.name)})),e=>e.origin,Object.entries(ae))}function ce(e){return X(e.map(e=>({...e,name:e.root,desc:e.branch})),e=>e.status,se)}var $=(e,t)=>(0,z.jsx)(`span`,{className:`tag${e?` ${e}`:``}`,children:t},t),le={templates:e=>e.human?$(`human`,`human gate`):null,bricks:e=>[e.effect===`mutate`?$(`warn`,`mutate`):null,F(e)?$(`human`,`human gate`):null,e.override?$(`acc`,e.override):null,e.available===!1?$(`bad`,`unavailable`):null],active:e=>$(U[e.status],e.status)};function ue({name:e,brick:t,override:n,on:r}){let i=`loop-brick${r?` on`:``}${!t||t.available===!1?` dimmed`:``}`;return t?(0,z.jsxs)(`li`,{className:i,id:`brick-${e}`,children:[(0,z.jsx)(`b`,{children:(0,z.jsx)(`a`,{href:`#/loops/bricks/${K(e)}`,children:e})}),$(t.effect===`mutate`?`warn`:``,t.effect),(0,z.jsx)(`span`,{className:`mono dim`,children:t.agent||t.skill}),(0,z.jsx)(`span`,{className:`panel-note`,children:t.outcomes.join(` · `)}),F(t)?$(`human`,F(t).toLowerCase()):null,n?$(`acc`,n):null]}):(0,z.jsxs)(`li`,{className:i,id:`brick-${e}`,children:[(0,z.jsx)(`b`,{children:e}),(0,z.jsx)(`span`,{className:`panel-note`,children:`Not in the catalogue: this template cannot run as is.`})]})}function de(e){let t=e.loops||[],n=t.find(e=>e.iteration),r=n?.nodes[0],i=t=>{let n=new Map;for(let r of e.edges.filter(t))n.set(r.from,[...n.get(r.from)||[],r.on]);return[...n].map(([e,t])=>`${e} says ${t.join(` or `)}`).join(`, `)},a=t=>{let i=e.edges.filter(e=>e.to===t);return!!n&&t!==r&&i.length>0&&i.every(e=>e.from===r)&&e.edges.some(e=>e.from===t&&e.to===`$close`)},o=[...new Set(e.edges.filter(e=>e.to===`$close`).map(e=>e.from))].map(e=>a(e)?`${i(t=>t.to===e)} → ${e}; ${i(t=>t.from===e&&t.to===`$close`)} → close`:`${i(t=>t.from===e&&t.to===`$close`)} → close`),s=t.filter(e=>!e.iteration).map(e=>`${e.nodes.join(e.nodes.length===2?` ⇄ `:` → `)}, max ${e.max}`),c=n?e.nodes.filter(e=>!n.nodes.includes(e)):[],l=i(e=>e.to===`$stop`);return[c.length&&[`Setup`,`${c.join(` → `)}, once.`],n?[`Iteration (max ${n.max})`,`${n.nodes.filter(e=>!a(e)).join(` → `)}.`]:[`Steps`,`${e.nodes.join(` → `)}.`],s.length&&[`Retry`,`${s.join(`; `)}.`],o.length&&[`Exit`,`${o.join(`; `)}.`],[`Stop`,`${l?`${l}, or `:``}any step says error → stop.`]].filter(Boolean)}function fe({t:e,bricks:t,overridden:n,runs:r}){let[i,a]=(0,y.useState)(null),o=new Map(t.map(e=>[e.name,e])),s=de(e.graph),c=I(e.graph,t),l=c.mode===`ring`,u=`geneseed loop init --graph ${e.name} --title "<title>" --requirement "<requirement>"`,d=r?.filter(t=>W(t)&&t.graph.name===e.name).length;return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(`div`,{className:`reader-tags`,children:[(0,z.jsx)(`span`,{className:`tag acc`,children:`Template`}),J[e.graph.category]?$(``,J[e.graph.category]):null,e.human?$(`human`,`human gate`):null]}),(0,z.jsx)(`h2`,{className:`reader-title`,children:e.name}),e.description?(0,z.jsx)(`p`,{className:`reader-lede`,children:e.description}):null,(0,z.jsxs)(`p`,{className:`mono dim reader-src`,children:[`loops/`,e.name,`.json · `,e.origin]}),(0,z.jsx)(`hr`,{className:`hr`}),(0,z.jsxs)(`figure`,{className:`loop-console`,children:[(0,z.jsx)(`div`,{className:l?`loop-graph`:`loop-graph flow`,style:l?void 0:{"--loop-w":`${c.width}px`},children:(0,z.jsx)(V,{graph:e.graph,bricks:t,onSelect:e=>{a(e),document.getElementById(`brick-${e}`)?.scrollIntoView?.({behavior:`smooth`,block:`nearest`})}})}),(0,z.jsxs)(`figcaption`,{className:`loop-how`,children:[(0,z.jsx)(`span`,{className:`loop-kicker`,children:`How it runs`}),(0,z.jsx)(`ol`,{children:s.map(([e,t])=>(0,z.jsxs)(`li`,{children:[(0,z.jsxs)(`b`,{children:[e,`:`]}),` `,t]},e))}),l?(0,z.jsxs)(`span`,{className:`loop-legend`,children:[(0,z.jsxs)(`span`,{children:[(0,z.jsx)(`i`,{className:`ring`,"aria-hidden":`true`}),`iteration`]}),s.some(([e])=>e===`Retry`)?(0,z.jsxs)(`span`,{children:[(0,z.jsx)(`i`,{className:`inner`,"aria-hidden":`true`}),`retry`]}):null]}):null]})]}),(0,z.jsxs)(`section`,{className:`loop-start`,"aria-labelledby":`loop-start-h`,children:[(0,z.jsxs)(`div`,{className:`loop-start-bar`,children:[(0,z.jsx)(`h3`,{id:`loop-start-h`,className:`loop-kicker`,children:`Start it in your project`}),(0,z.jsx)(g,{text:u,label:`Copy command`})]}),(0,z.jsx)(`pre`,{className:`mono`,children:u})]}),r?(0,z.jsxs)(`p`,{className:`panel-note loop-running`,children:[`Running now: `,d?`${d} of this template`:`none`,`.`,` `,d?(0,z.jsx)(`a`,{href:`#/loops/active`,children:`Open Active →`}):`A started loop appears under Active with its iteration and preset.`]}):null,e.graph.rules?.length?(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`h3`,{className:`loop-h2`,children:`Rules`}),(0,z.jsx)(`ul`,{className:`loop-rules`,"aria-label":`Rules every brick follows`,children:e.graph.rules.map(e=>(0,z.jsx)(`li`,{children:e},e))})]}):null,(0,z.jsx)(`h3`,{className:`loop-h2`,children:`Bricks`}),(0,z.jsx)(`ul`,{className:`loop-brick-list`,"aria-label":`Bricks in ${e.name}`,children:e.graph.nodes.map(e=>(0,z.jsx)(ue,{name:e,brick:o.get(e),override:Y(n,e),on:i===e},e))})]})}function pe(e){return`---\n${[[`name`,e.name],[`description`,e.description],[`effect`,e.effect],[e.agent?`agent`:`skill`,e.agent||e.skill],[`gate`,e.gate],[`gateOn`,e.gateOn?.join(`, `)],[`outcomes`,e.outcomes.join(`, `)]].filter(([,e])=>e).map(([e,t])=>`${e}: ${t}`).join(`
2
2
  `)}\n---\n${e.body}`}function me({b:e}){let[t,n]=(0,y.useState)(!1),r=[[`effect`,$(e.effect===`mutate`?`warn`:``,e.effect)],[e.agent?`agent`:`skill`,(0,z.jsx)(`span`,{className:`mono`,children:e.agent||e.skill},`who`)],[`outcomes`,e.outcomes.map(e=>$(``,e))],[`gate`,F(e)?$(`human`,F(e).toLowerCase()):`none`],[`origin`,e.override?`${e.origin}, ${e.override}`:e.origin],[`available`,e.available===!1?(0,z.jsxs)(`span`,{className:`t-warn`,children:[`no — `,e.reason]},`why`):`yes`]];return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(`div`,{className:`reader-tags`,children:[(0,z.jsx)(`span`,{className:`tag acc`,children:`Brick`}),le.bricks(e)]}),(0,z.jsx)(`h2`,{className:`reader-title`,children:e.name}),e.description?(0,z.jsx)(`p`,{className:`reader-lede`,children:e.description}):null,(0,z.jsxs)(`p`,{className:`mono dim reader-src`,children:[`bricks/`,e.name,`.md`]}),(0,z.jsx)(`dl`,{className:`loop-facts`,children:r.map(([e,t])=>(0,z.jsxs)(y.Fragment,{children:[(0,z.jsx)(`dt`,{children:e}),(0,z.jsx)(`dd`,{children:t})]},e))}),(0,z.jsx)(`hr`,{className:`hr`}),(0,z.jsx)(`div`,{className:`row gap-8 loop-src-bar`,children:(0,z.jsx)(`button`,{type:`button`,className:`btn ghost sm`,"aria-expanded":t,onClick:()=>n(!t),children:t?`Hide source`:`View source`})}),t?(0,z.jsx)(`pre`,{className:`loop-brick-src`,"aria-label":`Source`,children:pe(e)}):(0,z.jsx)(`div`,{className:`lib-doc detail-doc`,children:(0,z.jsx)(_,{body:e.body})})]})}function he({problems:e}){if(!e?.length)return null;let t=e.length;return(0,z.jsxs)(`div`,{className:`panel loop-problems`,role:`status`,"aria-label":`Catalogue files skipped`,children:[(0,z.jsxs)(`b`,{className:`t-warn`,children:[t,` catalogue `,t===1?`problem`:`problems`,`: these files were skipped`]}),(0,z.jsx)(`ul`,{className:`panel-note`,children:e.map(e=>(0,z.jsx)(`li`,{className:`mono`,children:e},e))})]})}var ge={templates:{title:`No templates`,body:(0,z.jsxs)(z.Fragment,{children:[`Add one under `,(0,z.jsx)(`code`,{className:`mono`,children:`.geneseed/loops/`}),` in the repo.`]})},bricks:{title:`No bricks`,body:(0,z.jsxs)(z.Fragment,{children:[`Add one under `,(0,z.jsx)(`code`,{className:`mono`,children:`.geneseed/bricks/`}),` in the repo.`]})},active:{title:`No loops yet`,body:(0,z.jsxs)(z.Fragment,{children:[`Start one with `,(0,z.jsx)(`code`,{className:`mono`,children:`geneseed loop init`}),` in a worktree, or ask the agent to run a loop. It shows up here while it runs.`]})}},_e={templates:(0,z.jsxs)(z.Fragment,{children:[`A template wires bricks into a loop. `,(0,z.jsx)(`a`,{href:`#/docs/loops`,children:`How loops work →`}),` `,(0,z.jsx)(`a`,{href:`#/docs/loop-which-template`,children:`Which template? →`})]}),bricks:(0,z.jsxs)(z.Fragment,{children:[`A brick is one step: a skill or agent and its outcomes.`,` `,(0,z.jsx)(`a`,{href:`#/docs/loop-bricks`,children:`About bricks →`})]}),active:(0,z.jsxs)(z.Fragment,{children:[`Loops registered on this machine, read from their LOOP.md.`,` `,(0,z.jsx)(`a`,{href:`#/docs/loop-running`,children:`Running a loop →`})]})};function ve({tab:e=`templates`,item:t,dataRev:n}){let{data:s,error:c}=o(()=>r.loops(),[n],`loops`),u=te(),[g,_]=(0,y.useState)(``),[v,b]=(0,y.useState)(`all`),[x,S]=(0,y.useState)(e);e!==x&&(S(e),_(``),b(`all`));let C=s?.bricks||[],w=e===`active`?u.loops&&ce(u.loops):s&&(e===`bricks`?Q(s.bricks,s.overridden):Z(s.templates,s.bricks)),T=w||[],E=f(T),D=v===`all`?T:T.filter(e=>e.group===v),O=g.trim(),k=p(D,O),A=!!(t&&w&&!T.some(e=>e.name===t)),j=A?null:T.find(e=>e.name===t)||e===`active`&&T.find(W)||T[0]||null,M={templates:s?.templates.length,bricks:s?.bricks.length,active:u.loops?.length},N=q.find(([t])=>t===e)[1],P=e===`active`?u.error:c;return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(i,{error:P,style:{margin:`0 0 var(--sp-3)`}}),(0,z.jsx)(he,{problems:s?.problems}),(0,z.jsxs)(`div`,{className:`library`,children:[(0,z.jsxs)(`aside`,{className:`lib-kinds`,"aria-label":`Loops sections`,children:[(0,z.jsxs)(`div`,{className:`lib-title`,children:[(0,z.jsx)(`h1`,{className:`h`,children:`Loops`}),(0,z.jsx)(`span`,{className:`dim`,children:`What the engine runs`})]}),(0,z.jsx)(`p`,{className:`panel-note lib-lede`,children:_e[e]}),(0,z.jsx)(`nav`,{className:`kind-list`,"aria-label":`Sections`,children:q.map(([t,n])=>(0,z.jsxs)(y.Fragment,{children:[(0,z.jsxs)(`a`,{href:`#/loops/${t}`,className:e===t?`on`:``,"aria-current":e===t?`page`:void 0,children:[n,(0,z.jsx)(`span`,{className:`mono dim`,children:M[t]??``})]}),e===t&&(0,z.jsx)(h,{label:oe[t],total:T.length,cats:E,cat:v,onChange:b})]},t))})]}),(0,z.jsx)(d,{label:N,count:O?`${k.length} of ${D.length}`:w?D.length:``,q:g,onQ:_,matched:k.length,inView:[e,t],children:w?T.length===0?(0,z.jsx)(l,{title:ge[e].title,children:ge[e].body}):(0,z.jsx)(m,{rows:k,activeName:j?.name,hrefOf:t=>`#/loops/${e}/${K(t.name)}`,pills:le[e]}):P?null:(0,z.jsx)(a,{})}),(0,z.jsx)(`article`,{className:`lib-reader`,"aria-label":`Entry`,children:A?(0,z.jsx)(l,{title:(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`code`,{className:`mono`,children:t}),` is not registered any more.`]}),docs:{href:`#/loops/${e}`,label:`All ${N.toLowerCase()} →`}}):j?e===`active`?(0,z.jsx)(ie,{loop:j,bricks:C,onPreset:u.onPreset}):e===`bricks`?(0,z.jsx)(me,{b:j}):(0,z.jsx)(fe,{t:j,bricks:C,overridden:s.overridden,runs:u.loops},j.name):e===`active`&&w?(0,z.jsx)(l,{title:`What is a loop?`,docs:{href:`#/docs/loops`,label:`How loops work →`},children:`A loop runs bricks in a ring until its gate passes.`}):null})]})]})}export{ce as activeRows,Q as brickRows,pe as brickSource,ve as default,de as howItRuns,Z as templateRows};
@@ -1 +1 @@
1
- import"./rolldown-runtime-hePW80VL.js";import{i as e,t}from"./react-DlYQp10C.js";import{n,r}from"./sections-ChwaobfW.js";import{F as i,ct as a}from"./index-FLVXXvV3.js";import{n as o,r as s}from"./Dashboard-CaqOqtkG.js";e();var c=t(),l=14;function u({title:e,right:t,children:n,span:r}){return(0,c.jsxs)(`div`,{className:`c-mod`,style:r?{gridColumn:`span ${r}`}:null,children:[(0,c.jsxs)(`div`,{className:`c-mod-head`,children:[(0,c.jsx)(`span`,{className:`c-tab`}),(0,c.jsx)(`h3`,{children:e}),t&&(0,c.jsx)(`span`,{className:`c-mod-right`,children:t})]}),(0,c.jsx)(`div`,{className:`c-mod-body`,children:n})]})}function d({label:e,value:t}){return(0,c.jsxs)(`div`,{className:`c-kpi`,children:[(0,c.jsx)(`div`,{className:`c-kpi-label`,children:e}),(0,c.jsx)(`div`,{className:`c-kpi-val`+(t===0?` zero`:``),children:t})]})}function f({data:e,height:t=120,hi:n}){if(!e.length)return null;let r=Math.max(...e.map(e=>e.v),1);return(0,c.jsx)(`div`,{className:`c-cols`,style:{height:t},children:e.map((e,i)=>{let a=Math.max(e.v/r*(t-6),2);return(0,c.jsx)(`div`,{className:`c-col ${i===n?`hi`:``}`,style:{height:a},title:`${e.t}: ${e.v}`},i)})})}function p({checks:e}){return(0,c.jsx)(`div`,{className:`c-band`,children:e.map((e,t)=>(0,c.jsx)(`span`,{className:`c-band-cell ${e.problems.length===0?`ok`:`bad`}`,title:`${e.label}: ${e.problems.length===0?`pass`:`${e.problems.length} problem(s)`}`},t))})}function m(e){let t={};for(let n of e||[]){let e=n.action||`unknown`;t[e]=(t[e]||0)+1}return Object.entries(t).map(([e,t])=>({label:e,value:t})).sort((e,t)=>t.value-e.value)}function h({overview:e,jobs:t,lens:h}){let g=e.counts||{},_=r.reduce((e,t)=>e+(g[t]||0),0),v=Math.max(...r.map(e=>g[e]||0),1),y=h?.doctor?.state||`loading`,b=h?.doctor?.data?.groups||[],x=b.filter(e=>e.problems.length===0).length,S=i(t||[],10,`0d`),C=S.reduce((e,t)=>e+t.v,0),w=m(t),T=Math.max(...w.map(e=>e.value),1),E=a(e.diff),D=[[`status`,e.deployed?(0,c.jsx)(`span`,{className:`c-pill ok`,children:`DEPLOYED`}):(0,c.jsx)(`span`,{className:`c-pill warn`,children:`NOT DEPLOYED`})],[`voice`,(0,c.jsx)(`span`,{className:`t-cap`,children:e.theme})],[`mode`,e.emit],[`doctor`,y===`failed`?(0,c.jsx)(`span`,{className:`c-pill warn`,children:`NO ANSWER`}):y===`ok`?b.length===0?(0,c.jsx)(`span`,{className:`c-pill`,children:`—`}):x===b.length?(0,c.jsx)(`span`,{className:`c-pill ok`,children:`CLEAN`}):(0,c.jsxs)(`span`,{className:`c-pill warn`,children:[b.length-x,` ISSUES`]}):(0,c.jsx)(`span`,{className:`c-pill`,children:`…`})],[`edits`,String(E)],[`built`,e.build_time||`—`],[`target`,(0,c.jsx)(`span`,{className:`c-dim mono`,children:e.target})]];return(0,c.jsxs)(`div`,{className:`c-root`,children:[(0,c.jsx)(`div`,{className:`c-titlebar`,children:(0,c.jsxs)(`div`,{children:[(0,c.jsx)(`h2`,{className:`c-h1`,children:`HARNESS // STATUS READOUT`}),(0,c.jsxs)(`div`,{className:`c-sub`,children:[e.target,` · rendered from src/ · inherited everywhere`]}),(0,c.jsx)(o,{verdict:h?.verdict})]})}),(0,c.jsx)(`div`,{className:`c-strip`,children:D.map(([e,t],n)=>(0,c.jsxs)(`div`,{className:`c-strip-cell`,children:[(0,c.jsx)(`div`,{className:`c-strip-k`,children:e}),(0,c.jsx)(`div`,{className:`c-strip-v`,children:t})]},n))}),(0,c.jsxs)(`div`,{className:`c-kpi-row`,children:[(0,c.jsx)(d,{label:`AGENTS`,value:g.agents??`—`}),(0,c.jsx)(d,{label:`SKILLS`,value:g.skills??`—`}),(0,c.jsx)(d,{label:`DICTATES`,value:g.laws??`—`}),(0,c.jsx)(d,{label:`PACKS`,value:g.doctrines?`${g.doctrines.active}/${g.doctrines.total}`:`—`}),(0,c.jsx)(d,{label:`MEMORY`,value:g.memory??`—`}),(0,c.jsx)(d,{label:`NOTEBOOK`,value:g.notebook??`—`}),(0,c.jsx)(d,{label:`EDITS`,value:E})]}),(0,c.jsxs)(`div`,{className:`c-grid`,children:[(0,c.jsx)(u,{title:`CAPABILITY DISTRIBUTION`,right:`${_} ENTRIES`,span:2,children:(0,c.jsxs)(`table`,{className:`c-tbl`,children:[(0,c.jsx)(`thead`,{children:(0,c.jsxs)(`tr`,{children:[(0,c.jsx)(`th`,{children:`SECTION`}),(0,c.jsx)(`th`,{children:`DETAIL`}),(0,c.jsx)(`th`,{style:{width:150},children:`SHARE`}),(0,c.jsx)(`th`,{className:`num`,children:`N`})]})}),(0,c.jsx)(`tbody`,{children:r.map(e=>(0,c.jsxs)(`tr`,{children:[(0,c.jsx)(`td`,{className:`c-name`,children:n[e].label}),(0,c.jsx)(`td`,{className:`c-dim`,children:n[e].desc}),(0,c.jsx)(`td`,{children:(0,c.jsx)(`div`,{className:`c-bar`,children:(0,c.jsx)(`i`,{style:{width:`${(g[e]||0)/v*100}%`,background:e===`agents`||e===`skills`?`var(--accent)`:`var(--line-3)`}})})}),(0,c.jsx)(`td`,{className:(g[e]||0)>0?`num`:`num c-dim`,children:g[e]??0})]},e))})]})}),(0,c.jsx)(u,{title:`DOCTOR // CHECKS`,right:b.length?`${x}/${b.length}`:`—`,children:b.length>0?(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)(p,{checks:b}),(0,c.jsx)(`div`,{className:`c-check-list`,children:b.map(e=>{let t=e.problems.length===0;return(0,c.jsxs)(`div`,{className:`c-check-row`,children:[(0,c.jsx)(`span`,{className:`c-dotmark ${t?`ok`:`bad`}`}),(0,c.jsx)(`span`,{className:`c-check-name`,children:e.label}),(0,c.jsx)(`span`,{className:`c-check-detail`,children:t?`clean`:`${e.problems.length} problem${e.problems.length===1?``:`s`}`})]},e.label)})})]}):(0,c.jsx)(`p`,{className:`c-dim mono c-fine`,children:y===`failed`?`Doctor did not answer.`:y===`ok`?`Doctor reported no checks.`:`Checking…`})}),(0,c.jsxs)(u,{title:`RUN RATE // 10D`,right:`${C} RUNS`,span:2,children:[(0,c.jsx)(f,{data:S,height:120,hi:S.length-1}),(0,c.jsx)(`div`,{className:`c-axis`,children:S.map((e,t)=>(0,c.jsx)(`span`,{children:t%2==0?e.t:``},t))})]}),(0,c.jsx)(u,{title:`RUN LOG // BY TYPE`,right:`${(t||[]).length} LOGGED`,children:w.length>0?(0,c.jsx)(`table`,{className:`c-tbl`,children:(0,c.jsx)(`tbody`,{children:w.map(e=>(0,c.jsxs)(`tr`,{children:[(0,c.jsx)(`td`,{className:`c-name`,style:{textTransform:`uppercase`,fontWeight:400},children:e.label}),(0,c.jsx)(`td`,{children:(0,c.jsx)(`div`,{className:`c-bar`,children:(0,c.jsx)(`i`,{style:{width:`${e.value/T*100}%`,background:`var(--accent)`}})})}),(0,c.jsx)(`td`,{className:`num`,children:e.value})]},e.label))})}):(0,c.jsx)(`p`,{className:`c-dim mono c-fine`,children:`No runs logged.`})}),(0,c.jsx)(u,{title:`RECENT // RUN LOG`,span:3,children:(0,c.jsx)(s,{jobs:t,max:l,empty:(0,c.jsx)(`p`,{className:`c-dim mono c-fine`,children:`No runs logged.`})})})]})]})}export{h as default};
1
+ import"./rolldown-runtime-hePW80VL.js";import{i as e,t}from"./react-DlYQp10C.js";import{n,r}from"./sections-ChwaobfW.js";import{F as i,ct as a}from"./index-DhNNxhfg.js";import{n as o,r as s}from"./Dashboard-DkUm4XMu.js";e();var c=t(),l=14;function u({title:e,right:t,children:n,span:r}){return(0,c.jsxs)(`div`,{className:`c-mod`,style:r?{gridColumn:`span ${r}`}:null,children:[(0,c.jsxs)(`div`,{className:`c-mod-head`,children:[(0,c.jsx)(`span`,{className:`c-tab`}),(0,c.jsx)(`h3`,{children:e}),t&&(0,c.jsx)(`span`,{className:`c-mod-right`,children:t})]}),(0,c.jsx)(`div`,{className:`c-mod-body`,children:n})]})}function d({label:e,value:t}){return(0,c.jsxs)(`div`,{className:`c-kpi`,children:[(0,c.jsx)(`div`,{className:`c-kpi-label`,children:e}),(0,c.jsx)(`div`,{className:`c-kpi-val`+(t===0?` zero`:``),children:t})]})}function f({data:e,height:t=120,hi:n}){if(!e.length)return null;let r=Math.max(...e.map(e=>e.v),1);return(0,c.jsx)(`div`,{className:`c-cols`,style:{height:t},children:e.map((e,i)=>{let a=Math.max(e.v/r*(t-6),2);return(0,c.jsx)(`div`,{className:`c-col ${i===n?`hi`:``}`,style:{height:a},title:`${e.t}: ${e.v}`},i)})})}function p({checks:e}){return(0,c.jsx)(`div`,{className:`c-band`,children:e.map((e,t)=>(0,c.jsx)(`span`,{className:`c-band-cell ${e.problems.length===0?`ok`:`bad`}`,title:`${e.label}: ${e.problems.length===0?`pass`:`${e.problems.length} problem(s)`}`},t))})}function m(e){let t={};for(let n of e||[]){let e=n.action||`unknown`;t[e]=(t[e]||0)+1}return Object.entries(t).map(([e,t])=>({label:e,value:t})).sort((e,t)=>t.value-e.value)}function h({overview:e,jobs:t,lens:h}){let g=e.counts||{},_=r.reduce((e,t)=>e+(g[t]||0),0),v=Math.max(...r.map(e=>g[e]||0),1),y=h?.doctor?.state||`loading`,b=h?.doctor?.data?.groups||[],x=b.filter(e=>e.problems.length===0).length,S=i(t||[],10,`0d`),C=S.reduce((e,t)=>e+t.v,0),w=m(t),T=Math.max(...w.map(e=>e.value),1),E=a(e.diff),D=[[`status`,e.deployed?(0,c.jsx)(`span`,{className:`c-pill ok`,children:`DEPLOYED`}):(0,c.jsx)(`span`,{className:`c-pill warn`,children:`NOT DEPLOYED`})],[`voice`,(0,c.jsx)(`span`,{className:`t-cap`,children:e.theme})],[`mode`,e.emit],[`doctor`,y===`failed`?(0,c.jsx)(`span`,{className:`c-pill warn`,children:`NO ANSWER`}):y===`ok`?b.length===0?(0,c.jsx)(`span`,{className:`c-pill`,children:`—`}):x===b.length?(0,c.jsx)(`span`,{className:`c-pill ok`,children:`CLEAN`}):(0,c.jsxs)(`span`,{className:`c-pill warn`,children:[b.length-x,` ISSUES`]}):(0,c.jsx)(`span`,{className:`c-pill`,children:`…`})],[`edits`,String(E)],[`built`,e.build_time||`—`],[`target`,(0,c.jsx)(`span`,{className:`c-dim mono`,children:e.target})]];return(0,c.jsxs)(`div`,{className:`c-root`,children:[(0,c.jsx)(`div`,{className:`c-titlebar`,children:(0,c.jsxs)(`div`,{children:[(0,c.jsx)(`h2`,{className:`c-h1`,children:`HARNESS // STATUS READOUT`}),(0,c.jsxs)(`div`,{className:`c-sub`,children:[e.target,` · rendered from src/ · inherited everywhere`]}),(0,c.jsx)(o,{verdict:h?.verdict})]})}),(0,c.jsx)(`div`,{className:`c-strip`,children:D.map(([e,t],n)=>(0,c.jsxs)(`div`,{className:`c-strip-cell`,children:[(0,c.jsx)(`div`,{className:`c-strip-k`,children:e}),(0,c.jsx)(`div`,{className:`c-strip-v`,children:t})]},n))}),(0,c.jsxs)(`div`,{className:`c-kpi-row`,children:[(0,c.jsx)(d,{label:`AGENTS`,value:g.agents??`—`}),(0,c.jsx)(d,{label:`SKILLS`,value:g.skills??`—`}),(0,c.jsx)(d,{label:`DICTATES`,value:g.laws??`—`}),(0,c.jsx)(d,{label:`PACKS`,value:g.doctrines?`${g.doctrines.active}/${g.doctrines.total}`:`—`}),(0,c.jsx)(d,{label:`MEMORY`,value:g.memory??`—`}),(0,c.jsx)(d,{label:`NOTEBOOK`,value:g.notebook??`—`}),(0,c.jsx)(d,{label:`EDITS`,value:E})]}),(0,c.jsxs)(`div`,{className:`c-grid`,children:[(0,c.jsx)(u,{title:`CAPABILITY DISTRIBUTION`,right:`${_} ENTRIES`,span:2,children:(0,c.jsxs)(`table`,{className:`c-tbl`,children:[(0,c.jsx)(`thead`,{children:(0,c.jsxs)(`tr`,{children:[(0,c.jsx)(`th`,{children:`SECTION`}),(0,c.jsx)(`th`,{children:`DETAIL`}),(0,c.jsx)(`th`,{style:{width:150},children:`SHARE`}),(0,c.jsx)(`th`,{className:`num`,children:`N`})]})}),(0,c.jsx)(`tbody`,{children:r.map(e=>(0,c.jsxs)(`tr`,{children:[(0,c.jsx)(`td`,{className:`c-name`,children:n[e].label}),(0,c.jsx)(`td`,{className:`c-dim`,children:n[e].desc}),(0,c.jsx)(`td`,{children:(0,c.jsx)(`div`,{className:`c-bar`,children:(0,c.jsx)(`i`,{style:{width:`${(g[e]||0)/v*100}%`,background:e===`agents`||e===`skills`?`var(--accent)`:`var(--line-3)`}})})}),(0,c.jsx)(`td`,{className:(g[e]||0)>0?`num`:`num c-dim`,children:g[e]??0})]},e))})]})}),(0,c.jsx)(u,{title:`DOCTOR // CHECKS`,right:b.length?`${x}/${b.length}`:`—`,children:b.length>0?(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)(p,{checks:b}),(0,c.jsx)(`div`,{className:`c-check-list`,children:b.map(e=>{let t=e.problems.length===0;return(0,c.jsxs)(`div`,{className:`c-check-row`,children:[(0,c.jsx)(`span`,{className:`c-dotmark ${t?`ok`:`bad`}`}),(0,c.jsx)(`span`,{className:`c-check-name`,children:e.label}),(0,c.jsx)(`span`,{className:`c-check-detail`,children:t?`clean`:`${e.problems.length} problem${e.problems.length===1?``:`s`}`})]},e.label)})})]}):(0,c.jsx)(`p`,{className:`c-dim mono c-fine`,children:y===`failed`?`Doctor did not answer.`:y===`ok`?`Doctor reported no checks.`:`Checking…`})}),(0,c.jsxs)(u,{title:`RUN RATE // 10D`,right:`${C} RUNS`,span:2,children:[(0,c.jsx)(f,{data:S,height:120,hi:S.length-1}),(0,c.jsx)(`div`,{className:`c-axis`,children:S.map((e,t)=>(0,c.jsx)(`span`,{children:t%2==0?e.t:``},t))})]}),(0,c.jsx)(u,{title:`RUN LOG // BY TYPE`,right:`${(t||[]).length} LOGGED`,children:w.length>0?(0,c.jsx)(`table`,{className:`c-tbl`,children:(0,c.jsx)(`tbody`,{children:w.map(e=>(0,c.jsxs)(`tr`,{children:[(0,c.jsx)(`td`,{className:`c-name`,style:{textTransform:`uppercase`,fontWeight:400},children:e.label}),(0,c.jsx)(`td`,{children:(0,c.jsx)(`div`,{className:`c-bar`,children:(0,c.jsx)(`i`,{style:{width:`${e.value/T*100}%`,background:`var(--accent)`}})})}),(0,c.jsx)(`td`,{className:`num`,children:e.value})]},e.label))})}):(0,c.jsx)(`p`,{className:`c-dim mono c-fine`,children:`No runs logged.`})}),(0,c.jsx)(u,{title:`RECENT // RUN LOG`,span:3,children:(0,c.jsx)(s,{jobs:t,max:l,empty:(0,c.jsx)(`p`,{className:`c-dim mono c-fine`,children:`No runs logged.`})})})]})]})}export{h as default};
@@ -1,2 +1,2 @@
1
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import{i as t,t as n}from"./react-DlYQp10C.js";import{t as r}from"./api-BfpZmUMI.js";import{H as i,J as a,Q as o,R as s,W as c,Y as l,Z as u,bt as d,pt as f,xt as p}from"./index-FLVXXvV3.js";import{t as m}from"./EmptyState-1sPNleqv.js";import{t as h}from"./Markdown-DpmmtW2Y.js";import{t as g}from"./Tabs-CEfSUVQp.js";import _ from"./Library-rYO8owx_.js";var v=e(t(),1),y=e=>e(`Discard your unsaved edit?`,{title:`Unsaved edit`,confirmLabel:`Discard`,tone:`danger`}),b=`The file changed on disk — reloaded the fresh copy. Your draft is kept.`;function x({data:e,reload:t}){let n=o(),[r,i]=(0,v.useState)(null),[a,s]=(0,v.useState)(null),[c,l]=(0,v.useState)(!1),[u,f]=(0,v.useState)(``),m=e?.fingerprint||``,h=r!==null&&JSON.stringify(r)!==JSON.stringify(a),g=(0,v.useRef)(!1),_=e=>{i(e),s(e)},x=()=>i(null);return(0,v.useEffect)(()=>{if(!h)return;let e=e=>{e.preventDefault(),e.returnValue=``};window.addEventListener(`beforeunload`,e);let t=p(({to:e})=>(g.current||(g.current=!0,y(n).then(n=>{n&&(t(),i(null),d(e))}).finally(()=>{g.current=!1})),!1));return()=>{window.removeEventListener(`beforeunload`,e),t()}},[h,n]),{draft:r,setDraft:i,open:_,close:x,discard:async()=>h&&!await y(n)?!1:(x(),!0),dirty:h,busy:c,notice:u,setNotice:f,save:async(e,{conflict:n}={})=>{l(!0),f(``);try{return await e(m)||!0}catch(e){e.status===409?f(n??b):f(e.message);return}finally{l(!1),t()}}}}var S=n(),C={title:``,body:``,scope:`project`,trial_until:``},w=[`project`,`global`],T=e=>e===`user`?`global`:e,E=/\r\n|[\n\r\v\f\x1c\x1d\x1e\x85\u2028\u2029]/,D=e=>e.startsWith(`## `)||/^##\s+R\d+\s*[—–-]+\s*\S/.test(e),O=`user-rules.md changed on disk (an agent session?) — reloaded the fresh copy. Your draft is kept — Save again.`,k=`user-rules.md changed on disk (an agent session?) — reloaded the fresh copy. Try again.`;function A({value:e,onChange:t,onCancel:n,onSave:r,busy:i}){let[a]=(0,v.useState)(e.scope),o=n=>r=>t({...e,[n]:r.target.value}),s=e.body.trim().split(E).some(D)?`A line cannot start with “## ” — user-rules.md reads it as a new rule heading. Use ### or plain text.`:``,c=!(e.title.trim()&&e.body.trim()),l=!c&&!s;return(0,S.jsxs)(`div`,{className:`rule-form`,children:[(0,S.jsxs)(`label`,{className:`field`,children:[(0,S.jsx)(`span`,{children:`Rule title`}),(0,S.jsx)(`input`,{className:`lib-filter`,type:`text`,value:e.title,onChange:o(`title`),placeholder:`Title — short and imperative (e.g. No emoji in commit subjects)`,autoFocus:!0})]}),(0,S.jsxs)(`label`,{className:`field`,children:[(0,S.jsx)(`span`,{children:`Rule body`}),(0,S.jsx)(`textarea`,{className:`rule-body-input`,value:e.body,onChange:o(`body`),rows:4,placeholder:`The rule, stated plainly and testably, in one short paragraph.`,"aria-invalid":s?!0:void 0,"aria-describedby":s?`rule-body-error`:void 0})]}),s?(0,S.jsx)(`p`,{id:`rule-body-error`,className:`sub rule-notice`,role:`alert`,children:s}):null,(0,S.jsxs)(`div`,{className:`row wrap`,children:[(0,S.jsxs)(`label`,{className:`field`,children:[(0,S.jsx)(`span`,{children:`Rule scope`}),(0,S.jsxs)(`select`,{className:`sel`,value:e.scope,onChange:o(`scope`),children:[(0,S.jsx)(`option`,{value:`project`,children:`scope: project (this repo, committable)`}),(0,S.jsx)(`option`,{value:`global`,children:`scope: global (every repository)`}),w.includes(a)?null:(0,S.jsxs)(`option`,{value:a,children:[`scope: `,a,` (as written in the file)`]})]})]}),(0,S.jsxs)(`label`,{className:`rule-trial-label`,children:[`trial until`,(0,S.jsx)(`input`,{className:`lib-filter rule-date`,type:`date`,value:e.trial_until,onChange:o(`trial_until`),"aria-label":`Trial until date (optional)`})]}),(0,S.jsxs)(`div`,{className:`row gap-8`,style:{marginLeft:`auto`},children:[(0,S.jsx)(`button`,{className:`btn sm`,disabled:!l||i,onClick:()=>r(e),"aria-describedby":c?`rule-form-hint`:void 0,children:i?`Saving…`:`Save rule`}),(0,S.jsx)(`button`,{className:`btn ghost sm`,disabled:i,onClick:n,children:`Cancel`})]})]}),c?(0,S.jsx)(`p`,{id:`rule-form-hint`,className:`panel-note`,children:`A rule needs a title and a body.`}):null]})}function j({rule:e,isOpen:t,onToggle:n,onEdit:r,onDelete:i,onGraduate:a}){return(0,S.jsxs)(`div`,{className:`rule-row ${t?`on`:``}`,children:[(0,S.jsxs)(`button`,{className:`rule-head`,onClick:n,"aria-expanded":t,"data-rule-head":e.id,children:[(0,S.jsxs)(`span`,{className:`rule-no`,children:[`R`,e.id]}),(0,S.jsx)(`span`,{className:`rule-title`,children:e.title}),(0,S.jsx)(`span`,{className:`rule-chip ${e.scope===`user`?`user`:``}`,children:e.scope}),e.status===`trial`&&(0,S.jsx)(`span`,{className:`rule-chip trial ${e.overdue?`overdue`:``}`,children:e.overdue?`review due`:`trial · ${e.trial_until}`})]}),t&&(0,S.jsxs)(`div`,{className:`rule-expand`,children:[(0,S.jsx)(`p`,{children:e.body}),e.source?(0,S.jsxs)(`div`,{className:`rule-src`,children:[`source: `,e.source]}):null,(0,S.jsxs)(`div`,{className:`row gap-8`,style:{marginTop:10},children:[e.status===`trial`&&(0,S.jsx)(`button`,{className:`btn ghost sm`,onClick:a,title:`Adopt for good — drop the trial marker`,"aria-label":`Graduate R${e.id}`,children:`Graduate`}),(0,S.jsx)(`button`,{className:`btn ghost sm`,onClick:r,"aria-label":`Edit R${e.id}`,children:`Edit`}),(0,S.jsx)(`button`,{className:`btn ghost sm`,onClick:i,"aria-label":`Retire R${e.id}`,children:`Retire`})]})]})]})}function M({onChanged:e}){let t=o(),[n,i]=(0,v.useState)(0),{data:s,error:c}=f(()=>r.rules(),[n]),[u,d]=(0,v.useState)(null),p=()=>i(e=>e+1),h=x({data:s,reload:p}),{draft:g,busy:_,notice:y}=h,b=(0,v.useRef)(null),[w,E]=(0,v.useState)(0),D=e=>{b.current=e,E(e=>e+1)},M=(0,v.useRef)(null),N=(0,v.useRef)(null);if((0,v.useEffect)(()=>{let e=b.current;b.current=null,e!==null&&(e===`add`?M.current:N.current?.querySelector(`[data-rule-head="${e}"]`))?.focus()},[w]),c)return(0,S.jsx)(a,{error:c,onRetry:p});if(!s)return(0,S.jsx)(l,{});let P=s.rules||[],F=g?.target,I=F!==void 0&&F!==`new`&&!P.some(e=>e.id===F&&e.title===g.title0),L=F===`new`||I,R=async(t,n)=>{let i=await h.save(e=>r.rulesMutate({...t,fingerprint:e}),{conflict:n?O:k});return i&&n&&h.close(),e?.(),i},z=e=>h.setDraft({...g,form:e}),B=async(e,t)=>{await R(e,!0)&&D(t)},V=async e=>{await h.discard()&&D(e)},H=async e=>{await t(`Retire rule R${e.id} — “${e.title}”? It moves to user-rules-retired.md, which is never loaded.`,{title:`Retire this rule?`,confirmLabel:`Retire`,tone:`danger`})&&await R({op:`delete`,id:e.id})&&g===null&&D(`add`)},U=async e=>{await R({op:`update`,id:e.id,title:e.title,body:e.body,scope:e.scope,source:e.source,trial_until:``})&&D(e.id)};return(0,S.jsxs)(S.Fragment,{children:[(0,S.jsxs)(`div`,{className:`head-row mb-16`,children:[(0,S.jsxs)(`div`,{children:[(0,S.jsx)(`div`,{className:`eyebrow`,children:`governance · yours`}),(0,S.jsx)(`h2`,{className:`h`,children:`Rules`}),(0,S.jsxs)(`p`,{className:`sub`,children:[`Your own standing rules, from `,(0,S.jsx)(`code`,{className:`mono`,children:`user-rules.md`}),` beside the deployed AGENT.md. The agent obeys them with the same force as the Laws — they may tighten a Law, never repeal one — and no update ever touches the file. Keep the set small: every rule is loaded every session.`]})]}),s.exists&&g===null&&(0,S.jsx)(`button`,{className:`btn`,ref:M,onClick:()=>h.open({target:`new`,title0:``,form:C}),children:`Add rule`})]}),y?(0,S.jsx)(`p`,{className:`sub rule-notice`,role:`status`,children:y}):null,(s.warnings||[]).map(e=>(0,S.jsxs)(`p`,{className:`sub rule-notice`,children:[`format warning: `,e]},e)),L&&(0,S.jsxs)(`div`,{className:`card pad-lg mb-16`,children:[(0,S.jsx)(`div`,{className:`eyebrow`,style:{marginBottom:10},children:`new rule`}),I?(0,S.jsxs)(`p`,{className:`sub rule-notice`,role:`status`,children:[`Rule R`,F,` is no longer in user-rules.md (an agent session removed or renumbered it). Your draft is kept — Save adds it as a new rule.`]}):null,(0,S.jsx)(A,{value:g.form,onChange:z,busy:_,onCancel:()=>V(`add`),onSave:e=>B({op:`add`,...e},`add`)})]}),s.exists?P.length===0&&!L?(0,S.jsx)(m,{title:`No rules yet`,children:`The file is seeded and loaded every session — it is just empty. Add your first standing rule here, ask the agent for one in-session (the rule skill), or promote a recurring memory fact from the Library.`}):(0,S.jsx)(`div`,{className:`card rules-list`,ref:N,children:P.map(e=>!I&&F===e.id?(0,S.jsx)(`div`,{className:`rule-row on`,children:(0,S.jsx)(`div`,{className:`rule-expand`,style:{paddingTop:14},children:(0,S.jsx)(A,{value:g.form,onChange:z,busy:_,onCancel:()=>V(e.id),onSave:t=>B({op:`update`,id:e.id,source:e.source,...t},e.id)})})},e.id):(0,S.jsx)(j,{rule:e,isOpen:u===e.id,onToggle:()=>d(u===e.id?null:e.id),onEdit:()=>{d(e.id),h.open({target:e.id,title0:e.title,form:{title:e.title,body:e.body,scope:T(e.scope),trial_until:e.trial_until}})},onDelete:()=>H(e),onGraduate:()=>U(e)},e.id))}):(0,S.jsxs)(m,{title:`No user-rules.md here yet`,children:[`The build seeds it beside AGENT.md — run a build/update from the Dashboard (or`,` `,(0,S.jsx)(`code`,{className:`mono`,children:`geneseed update`}),`) and it appears, ready for your rules.`]})]})}var N=`PROFILE.md changed on disk since you opened it — reloaded the fresh copy. Your draft is kept — Save again.`;function P({onChanged:e}){let{data:t,error:n,loading:i,reload:o,setData:s}=f(()=>r.profile(),[]),c=x({data:t,reload:o}),{draft:d,dirty:p,busy:g,notice:_}=c,[y,b]=(0,v.useState)(!1);if(t&&!y&&(b(!0),(t.text||``).trim()||c.open(t.text||``)),i&&!t)return(0,S.jsx)(l,{});if(n)return(0,S.jsx)(a,{error:n,onRetry:o});let C=d!==null,w=t?.text||``;return(0,S.jsxs)(S.Fragment,{children:[(0,S.jsxs)(`div`,{className:`head-row mb-16`,children:[(0,S.jsxs)(`div`,{children:[(0,S.jsx)(`div`,{className:`eyebrow`,children:`identity · yours`}),(0,S.jsx)(`h2`,{className:`h`,children:`Profile`}),(0,S.jsxs)(`p`,{className:`sub`,children:[`Who you are and how you like to work, from `,(0,S.jsx)(`code`,{className:`mono`,children:`PROFILE.md`}),` `,`beside the deployed AGENT.md. Unlike `,(0,S.jsx)(`code`,{className:`mono`,children:`user-rules.md`}),`, it is identity, not rules — it colours how the agent works but never binds (precedence is Laws, then rules, then this). Seeded once, never overwritten by an update. Prefer not to write it by hand? Ask the agent to run the `,(0,S.jsx)(`code`,{className:`mono`,children:`profile`}),` skill — it interviews you and drafts this file with your consent.`]})]}),(0,S.jsxs)(`div`,{className:`row`,children:[(0,S.jsxs)(u,{"aria-label":`Profile mode`,children:[(0,S.jsx)(`button`,{className:C?``:`on`,"aria-pressed":!C,onClick:c.discard,children:`View`}),(0,S.jsx)(`button`,{className:C?`on`:``,"aria-pressed":C,onClick:()=>C||c.open(w),children:`Edit`})]}),C&&(0,S.jsx)(`button`,{className:`btn`,disabled:!p||g,onClick:async()=>{let t=await c.save(e=>r.profileSave({text:d,fingerprint:e}),{conflict:N});t&&(s(e=>({...e,text:d,seeded:!1,fingerprint:t.fingerprint||``})),c.setNotice(`Saved.`),c.close(),e?.())},children:g?`Saving…`:`Save`})]})]}),_?(0,S.jsx)(`p`,{className:`sub rule-notice`,role:`status`,children:_}):null,C?(0,S.jsx)(`textarea`,{className:`rule-body-input`,style:{width:`100%`,minHeight:`60vh`,fontFamily:`var(--mono, monospace)`},value:d,onChange:e=>c.setDraft(e.target.value),spellCheck:!1,"aria-label":`Profile markdown`}):w.trim()?(0,S.jsxs)(S.Fragment,{children:[t?.seeded?(0,S.jsxs)(m,{title:`This is still the template`,action:(0,S.jsx)(`button`,{type:`button`,className:`btn ghost`,onClick:()=>c.open(w),children:`Edit it here`}),children:[`Ask the agent to run the `,(0,S.jsx)(`code`,{className:`mono`,children:`profile`}),` skill — it interviews you and drafts this file with your consent.`]}):null,(0,S.jsx)(`div`,{className:`card pad-lg`,children:(0,S.jsx)(h,{body:w})})]}):(0,S.jsxs)(m,{title:`No profile yet`,children:[`Switch to Edit to write one, or ask the agent to run the`,` `,(0,S.jsx)(`code`,{className:`mono`,children:`profile`}),` skill.`]})]})}var F=(e,t)=>`${e} ${t}${e===1?``:`s`}`,I=new Set([`MEMORY`,`NOTEBOOK`,`README`]),L=e=>e?(e.items||[]).filter(e=>!I.has(String(e.name).toUpperCase())).length:null;function R({rules:e,profile:t,facts:n,notes:r}){let i=e?.exists?e.stats:null;if(!i)return null;let a=Math.round(Math.max(i.rules/i.max_rules,i.tokens/i.max_tokens)*100),[o,c]=a>=100?[`bad`,`over budget: a bloated rule set dilutes the rules that matter`]:a>=70?[`warn`,`getting heavy; consider merging or pruning`]:[`accent`,i.rules?`${i.rules} rules in ${i.lines} lines.`:`All of it is the file’s preamble; no rule text yet.`],l=[{k:`Profile`,v:t?.seeded?`template`:t?.exists?`written`:`missing`,warn:!!t?.seeded},{k:`Rules`,v:`${i.rules}/${i.max_rules}`},{k:`Memory`,v:n==null?`n/a`:F(n,`fact`)},{k:`Notebook`,v:r==null?`n/a`:F(r,`note`)}];return(0,S.jsxs)(`div`,{className:`card-row`,children:[(0,S.jsxs)(`section`,{className:`panel`,"aria-labelledby":`pc-budget`,children:[(0,S.jsxs)(`div`,{className:`panel-head`,children:[(0,S.jsx)(`h2`,{id:`pc-budget`,children:`Rule budget`}),(0,S.jsxs)(`span`,{className:`mono dim`,children:[i.rules,` of `,i.max_rules]})]}),(0,S.jsx)(`div`,{className:`slots`,style:{"--slots":i.max_rules},role:`img`,"aria-label":`${i.rules} of ${i.max_rules} rule slots used`,children:Array.from({length:i.max_rules},(e,t)=>(0,S.jsx)(`span`,{className:t<i.rules?`used`:``},t))}),(0,S.jsxs)(`p`,{className:`big-num`,children:[(0,S.jsx)(`span`,{className:`mono`,children:i.tokens}),` `,(0,S.jsxs)(`span`,{className:`dim`,children:[`/ `,i.max_tokens.toLocaleString(`en-US`),` tokens, every turn`]})]}),(0,S.jsx)(s,{value:i.tokens,max:i.max_tokens,label:`tokens`,tone:o}),(0,S.jsx)(`p`,{className:`panel-note`,children:c})]}),(0,S.jsxs)(`section`,{className:`panel`,"aria-labelledby":`pc-known`,children:[(0,S.jsx)(`div`,{className:`panel-head`,children:(0,S.jsx)(`h2`,{id:`pc-known`,children:`What the agent knows about you`})}),(0,S.jsx)(`ul`,{className:`hbars`,children:l.map(e=>(0,S.jsxs)(`li`,{children:[(0,S.jsx)(`span`,{className:`hb-label`,children:e.k}),(0,S.jsx)(`span`,{className:`mono hb-n${e.warn?` warn`:``}`,children:e.v})]},e.k))})]})]})}var z=/^- \[([^\]]*)\]\(topics\/[^)]+\.md\) — (\d+) facts?$/,B=e=>String(e||``).split(`
1
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{i as t,t as n}from"./react-DlYQp10C.js";import{t as r}from"./api-LvBC0CnK.js";import{H as i,J as a,Q as o,R as s,W as c,Y as l,Z as u,bt as d,pt as f,xt as p}from"./index-DhNNxhfg.js";import{t as m}from"./EmptyState-1sPNleqv.js";import{t as h}from"./Markdown-DpmmtW2Y.js";import{t as g}from"./Tabs-DaExAgql.js";import _ from"./Library-t3KocV0-.js";var v=e(t(),1),y=e=>e(`Discard your unsaved edit?`,{title:`Unsaved edit`,confirmLabel:`Discard`,tone:`danger`}),b=`The file changed on disk — reloaded the fresh copy. Your draft is kept.`;function x({data:e,reload:t}){let n=o(),[r,i]=(0,v.useState)(null),[a,s]=(0,v.useState)(null),[c,l]=(0,v.useState)(!1),[u,f]=(0,v.useState)(``),m=e?.fingerprint||``,h=r!==null&&JSON.stringify(r)!==JSON.stringify(a),g=(0,v.useRef)(!1),_=e=>{i(e),s(e)},x=()=>i(null);return(0,v.useEffect)(()=>{if(!h)return;let e=e=>{e.preventDefault(),e.returnValue=``};window.addEventListener(`beforeunload`,e);let t=p(({to:e})=>(g.current||(g.current=!0,y(n).then(n=>{n&&(t(),i(null),d(e))}).finally(()=>{g.current=!1})),!1));return()=>{window.removeEventListener(`beforeunload`,e),t()}},[h,n]),{draft:r,setDraft:i,open:_,close:x,discard:async()=>h&&!await y(n)?!1:(x(),!0),dirty:h,busy:c,notice:u,setNotice:f,save:async(e,{conflict:n}={})=>{l(!0),f(``);try{return await e(m)||!0}catch(e){e.status===409?f(n??b):f(e.message);return}finally{l(!1),t()}}}}var S=n(),C={title:``,body:``,scope:`project`,trial_until:``},w=[`project`,`global`],T=e=>e===`user`?`global`:e,E=/\r\n|[\n\r\v\f\x1c\x1d\x1e\x85\u2028\u2029]/,D=e=>e.startsWith(`## `)||/^##\s+R\d+\s*[—–-]+\s*\S/.test(e),O=`user-rules.md changed on disk (an agent session?) — reloaded the fresh copy. Your draft is kept — Save again.`,k=`user-rules.md changed on disk (an agent session?) — reloaded the fresh copy. Try again.`;function A({value:e,onChange:t,onCancel:n,onSave:r,busy:i}){let[a]=(0,v.useState)(e.scope),o=n=>r=>t({...e,[n]:r.target.value}),s=e.body.trim().split(E).some(D)?`A line cannot start with “## ” — user-rules.md reads it as a new rule heading. Use ### or plain text.`:``,c=!(e.title.trim()&&e.body.trim()),l=!c&&!s;return(0,S.jsxs)(`div`,{className:`rule-form`,children:[(0,S.jsxs)(`label`,{className:`field`,children:[(0,S.jsx)(`span`,{children:`Rule title`}),(0,S.jsx)(`input`,{className:`lib-filter`,type:`text`,value:e.title,onChange:o(`title`),placeholder:`Title — short and imperative (e.g. No emoji in commit subjects)`,autoFocus:!0})]}),(0,S.jsxs)(`label`,{className:`field`,children:[(0,S.jsx)(`span`,{children:`Rule body`}),(0,S.jsx)(`textarea`,{className:`rule-body-input`,value:e.body,onChange:o(`body`),rows:4,placeholder:`The rule, stated plainly and testably, in one short paragraph.`,"aria-invalid":s?!0:void 0,"aria-describedby":s?`rule-body-error`:void 0})]}),s?(0,S.jsx)(`p`,{id:`rule-body-error`,className:`sub rule-notice`,role:`alert`,children:s}):null,(0,S.jsxs)(`div`,{className:`row wrap`,children:[(0,S.jsxs)(`label`,{className:`field`,children:[(0,S.jsx)(`span`,{children:`Rule scope`}),(0,S.jsxs)(`select`,{className:`sel`,value:e.scope,onChange:o(`scope`),children:[(0,S.jsx)(`option`,{value:`project`,children:`scope: project (this repo, committable)`}),(0,S.jsx)(`option`,{value:`global`,children:`scope: global (every repository)`}),w.includes(a)?null:(0,S.jsxs)(`option`,{value:a,children:[`scope: `,a,` (as written in the file)`]})]})]}),(0,S.jsxs)(`label`,{className:`rule-trial-label`,children:[`trial until`,(0,S.jsx)(`input`,{className:`lib-filter rule-date`,type:`date`,value:e.trial_until,onChange:o(`trial_until`),"aria-label":`Trial until date (optional)`})]}),(0,S.jsxs)(`div`,{className:`row gap-8`,style:{marginLeft:`auto`},children:[(0,S.jsx)(`button`,{className:`btn sm`,disabled:!l||i,onClick:()=>r(e),"aria-describedby":c?`rule-form-hint`:void 0,children:i?`Saving…`:`Save rule`}),(0,S.jsx)(`button`,{className:`btn ghost sm`,disabled:i,onClick:n,children:`Cancel`})]})]}),c?(0,S.jsx)(`p`,{id:`rule-form-hint`,className:`panel-note`,children:`A rule needs a title and a body.`}):null]})}function j({rule:e,isOpen:t,onToggle:n,onEdit:r,onDelete:i,onGraduate:a}){return(0,S.jsxs)(`div`,{className:`rule-row ${t?`on`:``}`,children:[(0,S.jsxs)(`button`,{className:`rule-head`,onClick:n,"aria-expanded":t,"data-rule-head":e.id,children:[(0,S.jsxs)(`span`,{className:`rule-no`,children:[`R`,e.id]}),(0,S.jsx)(`span`,{className:`rule-title`,children:e.title}),(0,S.jsx)(`span`,{className:`rule-chip ${e.scope===`user`?`user`:``}`,children:e.scope}),e.status===`trial`&&(0,S.jsx)(`span`,{className:`rule-chip trial ${e.overdue?`overdue`:``}`,children:e.overdue?`review due`:`trial · ${e.trial_until}`})]}),t&&(0,S.jsxs)(`div`,{className:`rule-expand`,children:[(0,S.jsx)(`p`,{children:e.body}),e.source?(0,S.jsxs)(`div`,{className:`rule-src`,children:[`source: `,e.source]}):null,(0,S.jsxs)(`div`,{className:`row gap-8`,style:{marginTop:10},children:[e.status===`trial`&&(0,S.jsx)(`button`,{className:`btn ghost sm`,onClick:a,title:`Adopt for good — drop the trial marker`,"aria-label":`Graduate R${e.id}`,children:`Graduate`}),(0,S.jsx)(`button`,{className:`btn ghost sm`,onClick:r,"aria-label":`Edit R${e.id}`,children:`Edit`}),(0,S.jsx)(`button`,{className:`btn ghost sm`,onClick:i,"aria-label":`Retire R${e.id}`,children:`Retire`})]})]})]})}function M({onChanged:e}){let t=o(),[n,i]=(0,v.useState)(0),{data:s,error:c}=f(()=>r.rules(),[n]),[u,d]=(0,v.useState)(null),p=()=>i(e=>e+1),h=x({data:s,reload:p}),{draft:g,busy:_,notice:y}=h,b=(0,v.useRef)(null),[w,E]=(0,v.useState)(0),D=e=>{b.current=e,E(e=>e+1)},M=(0,v.useRef)(null),N=(0,v.useRef)(null);if((0,v.useEffect)(()=>{let e=b.current;b.current=null,e!==null&&(e===`add`?M.current:N.current?.querySelector(`[data-rule-head="${e}"]`))?.focus()},[w]),c)return(0,S.jsx)(a,{error:c,onRetry:p});if(!s)return(0,S.jsx)(l,{});let P=s.rules||[],F=g?.target,I=F!==void 0&&F!==`new`&&!P.some(e=>e.id===F&&e.title===g.title0),L=F===`new`||I,R=async(t,n)=>{let i=await h.save(e=>r.rulesMutate({...t,fingerprint:e}),{conflict:n?O:k});return i&&n&&h.close(),e?.(),i},z=e=>h.setDraft({...g,form:e}),B=async(e,t)=>{await R(e,!0)&&D(t)},V=async e=>{await h.discard()&&D(e)},H=async e=>{await t(`Retire rule R${e.id} — “${e.title}”? It moves to user-rules-retired.md, which is never loaded.`,{title:`Retire this rule?`,confirmLabel:`Retire`,tone:`danger`})&&await R({op:`delete`,id:e.id})&&g===null&&D(`add`)},U=async e=>{await R({op:`update`,id:e.id,title:e.title,body:e.body,scope:e.scope,source:e.source,trial_until:``})&&D(e.id)};return(0,S.jsxs)(S.Fragment,{children:[(0,S.jsxs)(`div`,{className:`head-row mb-16`,children:[(0,S.jsxs)(`div`,{children:[(0,S.jsx)(`div`,{className:`eyebrow`,children:`governance · yours`}),(0,S.jsx)(`h2`,{className:`h`,children:`Rules`}),(0,S.jsxs)(`p`,{className:`sub`,children:[`Your own standing rules, from `,(0,S.jsx)(`code`,{className:`mono`,children:`user-rules.md`}),` beside the deployed AGENT.md. The agent obeys them with the same force as the Laws — they may tighten a Law, never repeal one — and no update ever touches the file. Keep the set small: every rule is loaded every session.`]})]}),s.exists&&g===null&&(0,S.jsx)(`button`,{className:`btn`,ref:M,onClick:()=>h.open({target:`new`,title0:``,form:C}),children:`Add rule`})]}),y?(0,S.jsx)(`p`,{className:`sub rule-notice`,role:`status`,children:y}):null,(s.warnings||[]).map(e=>(0,S.jsxs)(`p`,{className:`sub rule-notice`,children:[`format warning: `,e]},e)),L&&(0,S.jsxs)(`div`,{className:`card pad-lg mb-16`,children:[(0,S.jsx)(`div`,{className:`eyebrow`,style:{marginBottom:10},children:`new rule`}),I?(0,S.jsxs)(`p`,{className:`sub rule-notice`,role:`status`,children:[`Rule R`,F,` is no longer in user-rules.md (an agent session removed or renumbered it). Your draft is kept — Save adds it as a new rule.`]}):null,(0,S.jsx)(A,{value:g.form,onChange:z,busy:_,onCancel:()=>V(`add`),onSave:e=>B({op:`add`,...e},`add`)})]}),s.exists?P.length===0&&!L?(0,S.jsx)(m,{title:`No rules yet`,children:`The file is seeded and loaded every session — it is just empty. Add your first standing rule here, ask the agent for one in-session (the rule skill), or promote a recurring memory fact from the Library.`}):(0,S.jsx)(`div`,{className:`card rules-list`,ref:N,children:P.map(e=>!I&&F===e.id?(0,S.jsx)(`div`,{className:`rule-row on`,children:(0,S.jsx)(`div`,{className:`rule-expand`,style:{paddingTop:14},children:(0,S.jsx)(A,{value:g.form,onChange:z,busy:_,onCancel:()=>V(e.id),onSave:t=>B({op:`update`,id:e.id,source:e.source,...t},e.id)})})},e.id):(0,S.jsx)(j,{rule:e,isOpen:u===e.id,onToggle:()=>d(u===e.id?null:e.id),onEdit:()=>{d(e.id),h.open({target:e.id,title0:e.title,form:{title:e.title,body:e.body,scope:T(e.scope),trial_until:e.trial_until}})},onDelete:()=>H(e),onGraduate:()=>U(e)},e.id))}):(0,S.jsxs)(m,{title:`No user-rules.md here yet`,children:[`The build seeds it beside AGENT.md — run a build/update from the Dashboard (or`,` `,(0,S.jsx)(`code`,{className:`mono`,children:`geneseed update`}),`) and it appears, ready for your rules.`]})]})}var N=`PROFILE.md changed on disk since you opened it — reloaded the fresh copy. Your draft is kept — Save again.`;function P({onChanged:e}){let{data:t,error:n,loading:i,reload:o,setData:s}=f(()=>r.profile(),[]),c=x({data:t,reload:o}),{draft:d,dirty:p,busy:g,notice:_}=c,[y,b]=(0,v.useState)(!1);if(t&&!y&&(b(!0),(t.text||``).trim()||c.open(t.text||``)),i&&!t)return(0,S.jsx)(l,{});if(n)return(0,S.jsx)(a,{error:n,onRetry:o});let C=d!==null,w=t?.text||``;return(0,S.jsxs)(S.Fragment,{children:[(0,S.jsxs)(`div`,{className:`head-row mb-16`,children:[(0,S.jsxs)(`div`,{children:[(0,S.jsx)(`div`,{className:`eyebrow`,children:`identity · yours`}),(0,S.jsx)(`h2`,{className:`h`,children:`Profile`}),(0,S.jsxs)(`p`,{className:`sub`,children:[`Who you are and how you like to work, from `,(0,S.jsx)(`code`,{className:`mono`,children:`PROFILE.md`}),` `,`beside the deployed AGENT.md. Unlike `,(0,S.jsx)(`code`,{className:`mono`,children:`user-rules.md`}),`, it is identity, not rules — it colours how the agent works but never binds (precedence is Laws, then rules, then this). Seeded once, never overwritten by an update. Prefer not to write it by hand? Ask the agent to run the `,(0,S.jsx)(`code`,{className:`mono`,children:`profile`}),` skill — it interviews you and drafts this file with your consent.`]})]}),(0,S.jsxs)(`div`,{className:`row`,children:[(0,S.jsxs)(u,{"aria-label":`Profile mode`,children:[(0,S.jsx)(`button`,{className:C?``:`on`,"aria-pressed":!C,onClick:c.discard,children:`View`}),(0,S.jsx)(`button`,{className:C?`on`:``,"aria-pressed":C,onClick:()=>C||c.open(w),children:`Edit`})]}),C&&(0,S.jsx)(`button`,{className:`btn`,disabled:!p||g,onClick:async()=>{let t=await c.save(e=>r.profileSave({text:d,fingerprint:e}),{conflict:N});t&&(s(e=>({...e,text:d,seeded:!1,fingerprint:t.fingerprint||``})),c.setNotice(`Saved.`),c.close(),e?.())},children:g?`Saving…`:`Save`})]})]}),_?(0,S.jsx)(`p`,{className:`sub rule-notice`,role:`status`,children:_}):null,C?(0,S.jsx)(`textarea`,{className:`rule-body-input`,style:{width:`100%`,minHeight:`60vh`,fontFamily:`var(--mono, monospace)`},value:d,onChange:e=>c.setDraft(e.target.value),spellCheck:!1,"aria-label":`Profile markdown`}):w.trim()?(0,S.jsxs)(S.Fragment,{children:[t?.seeded?(0,S.jsxs)(m,{title:`This is still the template`,action:(0,S.jsx)(`button`,{type:`button`,className:`btn ghost`,onClick:()=>c.open(w),children:`Edit it here`}),children:[`Ask the agent to run the `,(0,S.jsx)(`code`,{className:`mono`,children:`profile`}),` skill — it interviews you and drafts this file with your consent.`]}):null,(0,S.jsx)(`div`,{className:`card pad-lg`,children:(0,S.jsx)(h,{body:w})})]}):(0,S.jsxs)(m,{title:`No profile yet`,children:[`Switch to Edit to write one, or ask the agent to run the`,` `,(0,S.jsx)(`code`,{className:`mono`,children:`profile`}),` skill.`]})]})}var F=(e,t)=>`${e} ${t}${e===1?``:`s`}`,I=new Set([`MEMORY`,`NOTEBOOK`,`README`]),L=e=>e?(e.items||[]).filter(e=>!I.has(String(e.name).toUpperCase())).length:null;function R({rules:e,profile:t,facts:n,notes:r}){let i=e?.exists?e.stats:null;if(!i)return null;let a=Math.round(Math.max(i.rules/i.max_rules,i.tokens/i.max_tokens)*100),[o,c]=a>=100?[`bad`,`over budget: a bloated rule set dilutes the rules that matter`]:a>=70?[`warn`,`getting heavy; consider merging or pruning`]:[`accent`,i.rules?`${i.rules} rules in ${i.lines} lines.`:`All of it is the file’s preamble; no rule text yet.`],l=[{k:`Profile`,v:t?.seeded?`template`:t?.exists?`written`:`missing`,warn:!!t?.seeded},{k:`Rules`,v:`${i.rules}/${i.max_rules}`},{k:`Memory`,v:n==null?`n/a`:F(n,`fact`)},{k:`Notebook`,v:r==null?`n/a`:F(r,`note`)}];return(0,S.jsxs)(`div`,{className:`card-row`,children:[(0,S.jsxs)(`section`,{className:`panel`,"aria-labelledby":`pc-budget`,children:[(0,S.jsxs)(`div`,{className:`panel-head`,children:[(0,S.jsx)(`h2`,{id:`pc-budget`,children:`Rule budget`}),(0,S.jsxs)(`span`,{className:`mono dim`,children:[i.rules,` of `,i.max_rules]})]}),(0,S.jsx)(`div`,{className:`slots`,style:{"--slots":i.max_rules},role:`img`,"aria-label":`${i.rules} of ${i.max_rules} rule slots used`,children:Array.from({length:i.max_rules},(e,t)=>(0,S.jsx)(`span`,{className:t<i.rules?`used`:``},t))}),(0,S.jsxs)(`p`,{className:`big-num`,children:[(0,S.jsx)(`span`,{className:`mono`,children:i.tokens}),` `,(0,S.jsxs)(`span`,{className:`dim`,children:[`/ `,i.max_tokens.toLocaleString(`en-US`),` tokens, every turn`]})]}),(0,S.jsx)(s,{value:i.tokens,max:i.max_tokens,label:`tokens`,tone:o}),(0,S.jsx)(`p`,{className:`panel-note`,children:c})]}),(0,S.jsxs)(`section`,{className:`panel`,"aria-labelledby":`pc-known`,children:[(0,S.jsx)(`div`,{className:`panel-head`,children:(0,S.jsx)(`h2`,{id:`pc-known`,children:`What the agent knows about you`})}),(0,S.jsx)(`ul`,{className:`hbars`,children:l.map(e=>(0,S.jsxs)(`li`,{children:[(0,S.jsx)(`span`,{className:`hb-label`,children:e.k}),(0,S.jsx)(`span`,{className:`mono hb-n${e.warn?` warn`:``}`,children:e.v})]},e.k))})]})]})}var z=/^- \[([^\]]*)\]\(topics\/[^)]+\.md\) — (\d+) facts?$/,B=e=>String(e||``).split(`
2
2
  `).map(e=>z.exec(e.trim())).filter(Boolean).map(e=>({topic:e[1],n:Number(e[2])}));function V({topics:e}){return e.length?(0,S.jsxs)(`section`,{className:`panel pm-topics`,"aria-labelledby":`pm-topics`,children:[(0,S.jsxs)(`div`,{className:`panel-head`,children:[(0,S.jsx)(`h2`,{id:`pm-topics`,children:`Topics`}),(0,S.jsx)(`span`,{className:`mono dim`,children:F(e.length,`topic`)})]}),(0,S.jsx)(`ul`,{className:`hbars`,children:e.map(e=>(0,S.jsxs)(`li`,{children:[(0,S.jsx)(`span`,{className:`hb-label`,children:e.topic}),(0,S.jsx)(`span`,{className:`mono hb-n`,children:F(e.n,`fact`)})]},e.topic))})]}):null}var H={memory:{title:`No facts yet`,body:(0,S.jsxs)(`div`,{className:`pm-first`,children:[(0,S.jsx)(`p`,{children:`The agent writes a fact when a session teaches it something durable: a decision, a correction, a trap. Say “remember that…” in any session, and it asks whether that belongs here or in your standing rules.`}),(0,S.jsxs)(`ul`,{children:[(0,S.jsx)(`li`,{children:`One fact per file, filed under a topic.`}),(0,S.jsx)(`li`,{children:`Stale facts move to Archived; nothing is deleted without you.`}),(0,S.jsx)(`li`,{children:`The store stays on this machine and out of git.`})]})]}),action:(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(`a`,{className:`btn ghost`,href:`#/docs/memory`,children:`How memory works`}),(0,S.jsx)(`a`,{className:`btn ghost`,href:`#/item/skill/rule`,children:`The rule skill`})]})},notebook:{title:`No notes yet`,body:`The notebook is the agent’s own scratch space: plans and notes it keeps for itself.`}};function U({tab:e=`rules`,item:t,dataRev:n}){let a=e=>Promise.resolve(e).catch(()=>null),{data:o,reload:s}=i(n),{data:l,reload:u}=f(()=>a(r.profile()),[n]),{data:d,reload:p}=f(()=>r.catalog(`memory`),[`memory`,n],`catalog`),{data:h}=f(()=>r.catalog(`notebook`),[`notebook`,n],`catalog`),v=L(d),{data:y}=f(()=>e===`memory`?a(r.item(`memory`,`MEMORY`)):Promise.resolve(null),[`memory-map`,e,n,v]),b=L(h),x={memory:v,notebook:b},C={rules:o?.stats?.rules,profile:l?.seeded?`template`:null,memory:v,notebook:b},w=e===`memory`||e===`notebook`;return(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(c,{title:`Personal`,sub:`The only files you write. They survive updates, reinstalls and voice changes.`}),(0,S.jsx)(g,{page:`personal`,current:e,badges:C,label:`Personal files`}),e===`rules`&&(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(R,{rules:o,profile:l,facts:v,notes:b}),(0,S.jsx)(M,{onChanged:s})]}),e===`profile`&&(0,S.jsx)(P,{onChanged:u}),w&&x[e]===0&&!t?(0,S.jsx)(m,{title:H[e].title,action:H[e].action,children:H[e].body}):w?(0,S.jsxs)(S.Fragment,{children:[e===`memory`&&(0,S.jsx)(V,{topics:B(y?.body)}),(0,S.jsx)(_,{lock:e,base:`#/personal/${e}`,selected:t,dataRev:n,onRulesChanged:()=>{s(),p()}},e)]}):null]})}export{U as default};
@@ -1 +1 @@
1
- import"./rolldown-runtime-hePW80VL.js";import{i as e,t}from"./react-DlYQp10C.js";import{vt as n,yt as r}from"./index-FLVXXvV3.js";e();var i=t();function a({page:e,current:t,badges:a={},label:o}){return(0,i.jsx)(`nav`,{className:`tabs`,"aria-label":o,children:n[e].map(n=>(0,i.jsxs)(`a`,{href:`#/${e}/${n}`,className:t===n?`on`:``,"aria-current":t===n?`page`:void 0,children:[r[n],a[n]==null?null:(0,i.jsx)(`span`,{className:`tab-badge`,children:a[n]})]},n))})}export{a as t};
1
+ import"./rolldown-runtime-hePW80VL.js";import{i as e,t}from"./react-DlYQp10C.js";import{vt as n,yt as r}from"./index-DhNNxhfg.js";e();var i=t();function a({page:e,current:t,badges:a={},label:o}){return(0,i.jsx)(`nav`,{className:`tabs`,"aria-label":o,children:n[e].map(n=>(0,i.jsxs)(`a`,{href:`#/${e}/${n}`,className:t===n?`on`:``,"aria-current":t===n?`page`:void 0,children:[r[n],a[n]==null?null:(0,i.jsx)(`span`,{className:`tab-badge`,children:a[n]})]},n))})}export{a as t};
@@ -0,0 +1 @@
1
+ var e=typeof window<`u`?window.__GENESEED_TOKEN__:``;async function t(e){let t=await e.json().catch(()=>({})),n=e.status===403&&t.error===`forbidden`?`the web server restarted since this page loaded — reload the page, then re-apply your edit`:t.error||t.message||e.statusText,r=Error(n);return r.status=e.status,r.body=t,r}async function n(e){let n=await fetch(e);if(!n.ok)throw await t(n);return n.json()}async function r(n,r={}){let i=await fetch(n,{method:`POST`,headers:{"X-Geneseed-Token":e||``,"Content-Type":`application/json`},body:JSON.stringify(r)});if(!i.ok)throw await t(i);return i.json()}var i=e=>{if(e==null)return!1;if(typeof e.host==`string`&&typeof e.path==`string`)return!0;throw Error(`an install needs both host and path`)},a=(e,t)=>{if(!i(t))return e;let n=new URLSearchParams({host:t.host,path:t.path});return`${e}${e.includes(`?`)?`&`:`?`}${n}`},o=(e,t)=>{let n=e??{};if(!i(t))return n;if(`host`in n||`path`in n)throw Error(`this body already has host or path`);return{...n,host:t.host,path:t.path}},s=e=>{try{return e()}catch(e){return Promise.reject(e)}},c=(e,t)=>s(()=>n(a(e,t))),l=(e,t,n)=>s(()=>r(e,o(t,n))),u=e=>c(`/api/overview`,e),d=()=>n(`/api/fleet`),f=()=>n(`/api/kits`),p=()=>n(`/api/usage`),m=()=>n(`/api/gates`),h=()=>n(`/api/update`),g=e=>c(`/api/recent`,e),_=e=>c(`/api/activity`,e),v=(e,t)=>c(`/api/activity/`+encodeURIComponent(e),t),y=(e,t)=>l(`/api/activity`,{enabled:e},t),b=e=>c(`/api/setup`,e),x=(e=!1,t)=>c(e?`/api/doctor?fresh=1`:`/api/doctor`,t),S=e=>c(`/api/themes`,e),C=(e,t)=>c(`/api/catalog/${e}`,t),w=(e,t,n)=>c(`/api/item/${e}/${encodeURIComponent(t)}`,n),T=(e,t)=>l(`/api/memory/delete`,{name:e},t),E=e=>c(`/api/diff`,e),D=(e,t)=>l(`/api/actions/restore`,{files:e},t),O=409,k=e=>n(`/api/jobs/${e}`),A=()=>n(`/api/jobs`),j=e=>r(`/api/jobs/${e}/cancel`),M=new Set([`build`,`restore`]);async function N(e,t,n){let i=t||{},a=`/api/actions/${e}`;try{return await(M.has(e)?l(a,i,n):r(a,i))}catch(e){throw e.status===O&&e.body?.error===`busy`?Error(`An action is already running.`,{cause:e}):e}}var P=e=>c(`/api/loops`,e),F=()=>n(`/api/loops/active`),I=(e,t)=>r(`/api/loops/preset`,{root:e,preset:t}),L=()=>n(`/api/mcp`),R=e=>r(`/api/reveal`,{path:e}),z=()=>n(`/api/installs`),B=(e,t,n)=>r(`/api/install`,{host:e,path:t,action:n}),V=(e,t,n)=>r(`/api/install`,{host:e,path:t,action:`remove`,memory:n}),H=(e,t)=>r(`/api/view`,{host:e,path:t}),U=()=>r(`/api/pick-folder`,{}),W=()=>n(`/api/ping`),G=()=>r(`/api/shutdown`),K=()=>r(`/api/restart`),q=e=>e?`?harness=${encodeURIComponent(e)}`:``,J={fleet:d,kits:f,usage:p,gates:m,update:h,loops:P,activeLoops:F,setLoopPreset:I,overview:u,recent:g,activity:_,activityDetail:v,activityToggle:y,setup:b,doctor:x,themes:S,catalog:C,item:w,memoryDelete:T,diff:E,restore:D,job:k,jobs:A,cancelJob:j,action:N,mcp:L,mcpReveal:R,installs:z,installToggle:B,installRemove:V,selectView:H,pickFolder:U,ping:W,shutdown:G,restart:K,docs:(e,t)=>c(`/api/docs${q(e)}`,t),docsPage:(e,t,n)=>c(`/api/docs/page/${encodeURIComponent(e)}${q(t)}`,n),rules:e=>c(`/api/rules`,e),rulesMutate:(e,t)=>l(`/api/rules`,e,t),rulesPromote:(e,t)=>l(`/api/rules/promote`,e,t),profile:e=>c(`/api/profile`,e),profileSave:(e,t)=>l(`/api/profile`,e,t),excludes:()=>n(`/api/excludes`),excludeMutate:(e,t)=>r(`/api/excludes`,{action:e,path:t})};export{J as t};