chamba 0.7.0 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +53 -14
- package/README.md +28 -8
- package/dist/commands/advanced.js +7 -278
- package/dist/commands/dev.js +11 -612
- package/dist/commands/doctor.js +1 -29
- package/dist/commands/menu.js +1 -80
- package/dist/commands/onboard.js +6 -230
- package/dist/commands/settings.js +15 -349
- package/dist/lib/agent-commands.js +2 -0
- package/dist/lib/agent-context.js +6 -210
- package/dist/lib/browser.js +1 -40
- package/dist/lib/chamba-yaml.js +10 -191
- package/dist/lib/constants.js +1 -125
- package/dist/lib/dockerfile-builder.js +41 -261
- package/dist/lib/env.js +2 -78
- package/dist/lib/git-env.js +1 -21
- package/dist/lib/global-config.js +4 -66
- package/dist/lib/pnpm-store.js +1 -19
- package/dist/lib/ports.js +1 -210
- package/dist/lib/safe-rm.js +1 -36
- package/dist/lib/sessions.js +2 -34
- package/dist/lib/shadows.js +1 -176
- package/dist/lib/skills.js +2 -0
- package/dist/lib/templates.js +1 -0
- package/dist/lib/webterm.js +1 -305
- package/dist/lib/workspace-identity.js +4 -260
- package/package.json +4 -4
- package/templates/Dockerfile +12 -19
- package/templates/claude-statusline.sh +5 -7
- package/templates/context/baseline.md +2 -0
- package/templates/pane-apps/client/assets/c-BNa-DeUl.json +3552 -0
- package/templates/pane-apps/client/assets/cpp-B-T4NRoH.json +20239 -0
- package/templates/pane-apps/client/assets/csharp-BbxHChhA.json +6010 -0
- package/templates/pane-apps/client/assets/css-CWCxuwmz.json +1860 -0
- package/templates/pane-apps/client/assets/diff-B-2N89g8.json +154 -0
- package/templates/pane-apps/client/assets/docker-DWTvYW26.json +103 -0
- package/templates/pane-apps/client/assets/files-D0nJgFAA.js +12 -0
- package/templates/pane-apps/client/assets/files-h0K1vZyQ.css +1 -0
- package/templates/pane-apps/client/assets/go-B2hyYeNg.json +3156 -0
- package/templates/pane-apps/client/assets/graphql-Z6Id2aNO.json +1292 -0
- package/templates/pane-apps/client/assets/html-BtzvlIfu.json +2627 -0
- package/templates/pane-apps/client/assets/ini-Bn3Twap1.json +108 -0
- package/templates/pane-apps/client/assets/java-C7t2dwLO.json +1885 -0
- package/templates/pane-apps/client/assets/javascript-DuC2v0C0.json +5996 -0
- package/templates/pane-apps/client/assets/json-CwdkWeV5.json +206 -0
- package/templates/pane-apps/client/assets/jsonc-MYWDbTU3.json +206 -0
- package/templates/pane-apps/client/assets/jsx-Cn8EZuIC.json +5996 -0
- package/templates/pane-apps/client/assets/kotlin-CFNOz1gw.json +580 -0
- package/templates/pane-apps/client/assets/make-BVnlFCcl.json +629 -0
- package/templates/pane-apps/client/assets/markdown-B4Xk2WM_.json +3263 -0
- package/templates/pane-apps/client/assets/php-CAQzQmmI.json +4188 -0
- package/templates/pane-apps/client/assets/python-CYQee8m4.json +4174 -0
- package/templates/pane-apps/client/assets/reviews-BsoGZ35r.css +1 -0
- package/templates/pane-apps/client/assets/reviews-iW0Mbn4e.js +153 -0
- package/templates/pane-apps/client/assets/ruby-D7R58tus.json +3114 -0
- package/templates/pane-apps/client/assets/rust-BFBbFiei.json +1103 -0
- package/templates/pane-apps/client/assets/scss-TQRhBkPG.json +1874 -0
- package/templates/pane-apps/client/assets/shellscript-DieAkC4W.json +2375 -0
- package/templates/pane-apps/client/assets/specs-D9z3neR-.js +13 -0
- package/templates/pane-apps/client/assets/sql-Bxd030LV.json +634 -0
- package/templates/pane-apps/client/assets/toml-ChrKGzsV.json +430 -0
- package/templates/pane-apps/client/assets/tsx-D2e90MFw.json +5996 -0
- package/templates/pane-apps/client/assets/typescript-DonXQ_n1.json +5747 -0
- package/templates/pane-apps/client/assets/xml-B17r2RXF.json +382 -0
- package/templates/pane-apps/client/assets/yaml-CKn4h1zy.json +627 -0
- package/templates/pane-apps/client/reviews/index.html +15 -0
- package/templates/pane-apps/client/specs/index.html +3 -2
- package/templates/pane-apps/server/reviews.mjs +20 -0
- package/templates/pane-apps/server/specs.mjs +5 -1588
- package/templates/skills/chamba-statusline/SKILL.md +7 -19
- package/templates/skills/dx-review/SKILL.md +123 -0
- package/templates/skills/dx-review/references/acts.md +162 -0
- package/templates/skills/dx-spec/SKILL.md +223 -27
- package/templates/skills/dx-spec/references/principles-template.md +2 -0
- package/templates/skills/dx-spec/references/review-guide.md +4 -50
- package/templates/skills/dx-spec/references/spec-guide.md +24 -4
- package/templates/skills/dx-spec/references/stages.md +143 -58
- package/templates/skills/dx-spec-execute/SKILL.md +148 -35
- package/templates/startup.mjs +10 -4
- package/templates/tool-helper.sh +166 -0
- package/templates/webterm/README.md +60 -26
- package/templates/webterm/color.js +61 -0
- package/templates/webterm/config.js +35 -4
- package/templates/webterm/context/claude.md +0 -1
- package/templates/webterm/public/app/alerts.js +4 -4
- package/templates/webterm/public/app/anchored.js +81 -0
- package/templates/webterm/public/app/connection.js +9 -0
- package/templates/webterm/public/app/dom.js +2 -0
- package/templates/webterm/public/app/frames.js +51 -17
- package/templates/webterm/public/app/main.js +22 -8
- package/templates/webterm/public/app/new-session.js +13 -41
- package/templates/webterm/public/app/palette.js +58 -0
- package/templates/webterm/public/app/pane-shape.js +167 -0
- package/templates/webterm/public/app/pane-shell.js +199 -134
- package/templates/webterm/public/app/pane.js +33 -24
- package/templates/webterm/public/app/reviews-host.js +15 -0
- package/templates/webterm/public/app/specs-host.js +12 -218
- package/templates/webterm/public/app/state.js +5 -0
- package/templates/webterm/public/app/tabs.js +6 -2
- package/templates/webterm/public/app/theme.js +75 -27
- package/templates/webterm/public/app/tool-host.js +302 -0
- package/templates/webterm/public/app/workspace-color.js +192 -0
- package/templates/webterm/public/index.html +17 -3
- package/templates/webterm/public/styles.css +143 -21
- package/templates/webterm/server.js +198 -150
- package/templates/webterm/tools/commands.js +61 -0
- package/templates/webterm/tools/index.js +25 -0
- package/templates/webterm/tools/mount.js +337 -0
- package/templates/webterm/tools/paths.js +34 -0
- package/templates/webterm/tools/reviews.js +133 -0
- package/templates/webterm/tools/specs.js +154 -0
- package/templates/webterm/typed-line.js +70 -7
- package/templates/context/context-usage.md +0 -1
- package/templates/context-usage.sh +0 -266
- package/templates/pane-apps/client/assets/specs-B1970L17.css +0 -1
- package/templates/pane-apps/client/assets/specs-cEee_SPn.js +0 -23
- package/templates/skills/dx-spec-config/SKILL.md +0 -313
- package/templates/skills/dx-spec-config/references/principles-template.md +0 -12
- package/templates/specs.sh +0 -106
- package/templates/webterm/specs.js +0 -358
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import{C as e,D as t,E as n,S as r,T as i,_ as a,a as o,b as s,c,d as l,f as u,g as d,h as f,i as p,l as m,m as h,n as g,o as _,p as ee,s as v,u as te,v as y,w as b,x,y as S}from"./files-D0nJgFAA.js";var C=t(),w=n();function T(e){let t=e.replace(/\r\n?/g,`
|
|
2
|
+
`).trim(),n=5381;for(let e=0;e<t.length;e++)n=(n*33^t.charCodeAt(e))>>>0;return n.toString(36)}function ne(e,t){return t?.readHash?t.readHash===e?{read:!0,changed:!1}:{read:!1,changed:!0}:{read:!1,changed:!1}}function re(e){return e===`markdown`||e===`text`}function E(e){let t=[],n=[];if(e.kind===`markdown`&&typeof e.text==`string`)for(let r of b(e.text)){let a=T(r.heading?`## ${r.heading}\n${r.body}`:r.body);t.push({heading:r.heading,body:r.body,hash:a}),n.push(i(e.path,r.heading))}else{let r=e.text,a=T(typeof r==`string`?r:e.fingerprint??e.path);t.push({heading:null,body:typeof r==`string`?r:``,hash:a}),n.push(i(e.path,null))}let r=x(n);return t.map((e,t)=>({...e,id:r[t]}))}function ie(e,t,n){let r=i(t,n);return e.find(e=>e.id===r)??null}var D=600;function ae(e,t){let[n,r]=(0,C.useState)(t.empty),[i,a]=(0,C.useState)(null),o=(0,C.useRef)(t);o.current=t;let s=(0,C.useRef)(n),c=(0,C.useRef)(null),l=(0,C.useRef)(null),u=(0,C.useRef)(!1),d=(0,C.useRef)(0),f=(0,C.useRef)(0),p=(0,C.useRef)(!1),m=(0,C.useCallback)(e=>{s.current=e,r(e)},[]),h=(0,C.useCallback)(()=>{if(e===null)return;let t=e,n=d.current;o.current.get(t).then(e=>{if(d.current===n){if(f.current>0||l.current!==null){p.current=!0;return}u.current=!0,m(e),a(null)}}).catch(()=>{d.current===n&&(u.current=!1,a(o.current.whenUnreadable))})},[e,m]),g=(0,C.useCallback)(()=>{f.current>0||!p.current||(p.current=!1,h())},[h]),_=(0,C.useCallback)(t=>{if(e===null||!u.current||o.current.persist===!1){g();return}let n=d.current;f.current+=1,o.current.put(e,t).then(()=>a(null),()=>a(o.current.whenUnwritable)).finally(()=>{d.current===n&&(--f.current,g())})},[e,g]);return(0,C.useEffect)(()=>{d.current+=1,u.current=!1,f.current=0,p.current=!1,m(o.current.empty()),a(null),h()},[h,m]),(0,C.useEffect)(()=>()=>{c.current&&clearTimeout(c.current),l.current&&_(l.current),l.current=null,c.current=null},[_]),{value:n,update:(0,C.useCallback)((e,t=!1)=>{let n=e(s.current);if(n!==s.current){if(m(n),c.current&&clearTimeout(c.current),c.current=null,t){l.current=null,_(n);return}l.current=n,c.current=setTimeout(()=>{c.current=null;let e=l.current;l.current=null,e&&_(e)},D)}},[m,_]),reload:h,failure:i}}var O=S();function k(e){if(e===null)return[];let t=[],n=e.protocol.filter(e=>e.status!==`done`).length;n>0&&t.push(`${n} ${n===1?`stage`:`stages`} not done`);let r=e.phases.filter(e=>e.status!==`done`).length;r>0&&t.push(`${r} ${r===1?`phase`:`phases`} not done`);let i=e.awaiting.length;return i>0&&t.push(`${i} ${i===1?`thing`:`things`} waiting for an answer`),t}function oe(e){let t=k(e.state);return(0,O.jsx)(`div`,{className:`dialog-shade`,children:(0,O.jsxs)(`div`,{className:`dialog`,role:`dialog`,"aria-modal":`true`,"aria-label":`Archive this spec`,children:[(0,O.jsx)(`h2`,{className:`rail-head`,children:`Archive this spec`}),(0,O.jsxs)(`div`,{className:`dialog-body`,children:[(0,O.jsx)(`p`,{className:`rail-fact muted`,children:`It moves to:`}),(0,O.jsx)(`p`,{className:`archive-target`,children:e.filed}),t.length===0?(0,O.jsx)(`p`,{className:`rail-fact muted`,children:`Nothing is left open.`}):(0,O.jsxs)(O.Fragment,{children:[(0,O.jsxs)(`p`,{className:`rail-fact`,children:[`Still open in `,e.name,`:`]}),(0,O.jsx)(`ul`,{className:`archive-open`,children:t.map(e=>(0,O.jsx)(`li`,{children:e},e))})]}),(0,O.jsx)(`p`,{className:`rail-fact muted`,children:`The tool writes the sign-off and moves the directory. It deletes nothing.`})]}),e.failure!==null&&(0,O.jsx)(`p`,{className:`notice notice-failure`,children:e.failure}),(0,O.jsxs)(`div`,{className:`dialog-acts`,children:[(0,O.jsx)(`button`,{type:`button`,onClick:e.onCancel,disabled:e.working,children:`Cancel`}),(0,O.jsx)(`button`,{type:`button`,className:`send`,onClick:e.onArchive,disabled:e.working,children:e.working?`Filing it away…`:`Archive it`})]})]})})}var se=new Set(`address article aside audio blockquote br button canvas details div dl dd dt fieldset figcaption figure footer form h1 h2 h3 h4 h5 h6 header hr iframe img input label li main nav ol p picture pre section select span style summary svg table tbody td textarea tfoot th thead tr ul video`.split(` `)),ce=new Set(`br hr img input source track wbr col`.split(` `)),le=/^\s{0,3}(#{1,6})\s+(.*?)\s*#*\s*$/,A=/^(\s*)([-*+]|\d{1,9}[.)])(\s+)(.*)$/,j=/^\s{0,3}([-*_])\s*(?:\1\s*){2,}$/,M=/^\s{0,3}\|?\s*:?-{1,}:?\s*(\|\s*:?-{1,}:?\s*)*\|?\s*$/;function ue(e){return e.replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`)}function de(e){let t=e.match(/^\s{0,3}<([a-zA-Z][a-zA-Z0-9-]*)(?=[\s/>])/);if(!t)return null;let n=t[1].toLowerCase();return se.has(n)?n:null}function N(e){let t=ue(e),n=[];t=t.replace(/(`+)([\s\S]*?)\1/g,(e,t,r)=>(n.push(r.replace(/^ (.*) $/,`$1`)),`\uE000c${n.length-1}\uE000`));let r=e=>e.replace(/"/g,`"`);return t=t.replace(/!\[([^\]]*)\]\(([^)\s]+)(?:\s+"[^)]*")?\)/g,(e,t,n)=>`<img alt="${r(t)}" src="${r(n)}">`),t=t.replace(/\[([^\]]+)\]\(([^)\s]+)(?:\s+"[^)]*")?\)/g,(e,t,n)=>`<a href="${r(n)}">${t}</a>`),t=t.replace(/<((?:https?|mailto):[^\s&]+)>/g,`<a href="$1">$1</a>`),t=t.replace(/\*\*(?!\s)([\s\S]+?)(?<!\s)\*\*/g,`<strong>$1</strong>`),t=t.replace(/(^|[^\w\\])__(?!\s)([\s\S]+?)(?<!\s)__(?!\w)/g,`$1<strong>$2</strong>`),t=t.replace(/(^|[^\w*\\])\*(?!\s)([^*\n]+?)(?<!\s)\*(?!\w)/g,`$1<em>$2</em>`),t=t.replace(/(^|[^\w_\\])_(?!\s)([^_\n]+?)(?<!\s)_(?!\w)/g,`$1<em>$2</em>`),t=t.replace(/~~(?!\s)([\s\S]+?)(?<!\s)~~/g,`<del>$1</del>`),t=t.replace(/\uE000c(\d+)\uE000/g,(e,t)=>`<code>${n[+t]}</code>`),t}function fe(e){return!e.trim()||s.test(e)||le.test(e)||j.test(e)||A.test(e)||/^\s{0,3}>/.test(e)||de(e)!==null||/^\s{0,3}<!--/.test(e)}function pe(e){let t=e.replace(/\r\n?/g,`
|
|
3
|
+
`).split(`
|
|
4
|
+
`),n=[],r=0;for(;r<t.length;){let e=t[r];if(!e.trim()){r++;continue}let i=e.match(s);if(i){let e=i[2],a=i[3].trim().split(/\s+/)[0],o=[];for(r++;r<t.length;){let n=t[r].trim();if(n.startsWith(e[0].repeat(e.length))&&/^(`+|~+)$/.test(n)){r++;break}o.push(t[r]),r++}let s=a?` class="language-${ue(a)}"`:``;n.push(`<pre><code${s}>${ue(o.join(`
|
|
5
|
+
`))}</code></pre>`);continue}if(/^\s{0,3}<!--/.test(e)){for(;r<t.length&&!t[r].includes(`-->`);)r++;r++;continue}let a=de(e);if(a){let i=[t[r]];if(ce.has(a)||/\/>\s*$/.test(e)||e.includes(`</${a}>`))r++;else{let e=1;for(r++;r<t.length&&e>0;){let n=(t[r].match(RegExp(`<${a}(?=[\\s/>])`,`gi`))||[]).length,o=(t[r].match(RegExp(`</${a}\\s*>`,`gi`))||[]).length;e+=n-o,i.push(t[r]),r++}}n.push(i.join(`
|
|
6
|
+
`));continue}let o=e.match(le);if(o){let e=o[1].length;n.push(`<h${e}>${N(o[2])}</h${e}>`),r++;continue}if(j.test(e)){n.push(`<hr>`),r++;continue}if(/^\s{0,3}>/.test(e)){let e=[];for(;r<t.length&&(/^\s{0,3}>/.test(t[r])||t[r].trim()&&e.length>0&&!fe(t[r]));)e.push(t[r].replace(/^\s{0,3}>\s?/,``)),r++;n.push(`<blockquote>${pe(e.join(`
|
|
7
|
+
`))}</blockquote>`);continue}if(e.includes(`|`)&&r+1<t.length&&M.test(t[r+1])&&t[r+1].includes(`-`)){let e=e=>{let t=e.trim();return t.startsWith(`|`)&&(t=t.slice(1)),t.endsWith(`|`)&&!t.endsWith(`\\|`)&&(t=t.slice(0,-1)),t.split(/(?<!\\)\|/).map(e=>e.trim().replace(/\\\|/g,`|`))},i=e(t[r]),a=e(t[r+1]).map(e=>e.startsWith(`:`)&&e.endsWith(`:`)?`center`:e.endsWith(`:`)?`right`:e.startsWith(`:`)?`left`:``),o=e=>a[e]?` class="cell-${a[e]}"`:``,s=[];for(r+=2;r<t.length&&t[r].trim()&&t[r].includes(`|`);)s.push(e(t[r])),r++;n.push(`<table><thead><tr>${i.map((e,t)=>`<th${o(t)}>${N(e)}</th>`).join(``)}</tr></thead><tbody>${s.map(e=>`<tr>${e.map((e,t)=>`<td${o(t)}>${N(e)}</td>`).join(``)}</tr>`).join(``)}</tbody></table>`);continue}if(A.test(e)){let[e,i]=me(t,r);n.push(e),r=i;continue}let c=[];for(;r<t.length&&!fe(t[r]);)c.push(t[r].replace(/\s+$/,``)),r++;n.push(`<p>${N(c.join(`
|
|
8
|
+
`)).replace(/\n/g,`<br>
|
|
9
|
+
`)}</p>`)}return n.join(`
|
|
10
|
+
`)}function me(e,t){let n=e[t].match(A);if(!n)return[``,t+1];let r=n[1].length,i=/\d/.test(n[2]),a=[],o=t,s=null;for(;o<e.length;){let t=e[o];if(!t.trim()){let t=o+1;for(;t<e.length&&!e[t].trim();)t++;if(t>=e.length)break;let n=e[t].match(A),a=e[t].match(/^\s*/)[0].length,c=n!==null&&/\d/.test(n[2])===i;if(s&&(c&&a>=r||!n&&a>r)){s.push(``),o=t;continue}break}let n=t.match(A),c=t.match(/^\s*/)[0].length;if(n&&c<=r){if(/\d/.test(n[2])!==i)break;s=[n[4]],a.push({lines:s,offset:n[1].length+n[2].length+n[3].length}),o++;continue}if(c>r&&s){s.push(t.slice(Math.min(c,a[a.length-1].offset))),o++;continue}break}let c=a.map(e=>{let t=e.lines.join(`
|
|
11
|
+
`),n=``,r=``,i=t.match(/^\[([ xX])\]\s+([\s\S]*)$/);i&&(n=` class="task"`,r=`<span class="task-box${i[1]===` `?``:` is-done`}"></span>`,t=i[2]);let a=pe(t),o=a.match(/^<p>([\s\S]*?)<\/p>([\s\S]*)$/);return o&&!o[1].includes(`<p>`)&&(a=o[1]+o[2]),`<li${n}>${r}${a}</li>`}).join(`
|
|
12
|
+
`);return[(i?`<ol>`:`<ul>`)+c+(i?`</ol>`:`</ul>`),o]}var he=new Set(`p br hr span div a em strong b i u s del ins code pre kbd blockquote ul ol li dl dt dd h1 h2 h3 h4 h5 h6 table thead tbody tr th td caption img details summary figure figcaption sup sub small mark`.split(` `)),ge=new Set([`title`,`class`]),_e={a:new Set([`href`]),img:new Set([`src`,`alt`,`width`,`height`]),ol:new Set([`start`]),details:new Set([`open`]),th:new Set([`colspan`,`rowspan`]),td:new Set([`colspan`,`rowspan`])},ve=new Set([`script`,`style`,`textarea`,`title`,`xmp`,`noembed`,`noframes`,`noscript`,`template`]),ye={href:`a`,src:`img`},P=new Set([`http:`,`https:`,`mailto:`]);function F(e){let t=e.trim();if(t===``)return!1;let n;try{n=new URL(t)}catch{return!0}return P.has(n.protocol)}function I(e,t){return t.includes(`:`)?!1:ge.has(t)?!0:_e[e]?.has(t)??!1}function be(e){for(let t of[...e.children])be(t);for(let t of[...e.children]){let e=t.tagName.toLowerCase();if(!he.has(e)){ve.has(e)?t.remove():t.replaceWith(...t.childNodes);continue}for(let n of[...t.attributes]){let r=n.name.toLowerCase();if(!I(e,r)){t.removeAttribute(n.name);continue}ye[r]===e&&!F(n.value)&&t.removeAttribute(n.name)}}return e}function L(e,t,n={}){let r=new DOMParser().parseFromString(pe(t),`text/html`);be(r.body),n.imageUrl&&xe(r.body,n.imageUrl);let i=e.ownerDocument;e.replaceChildren(...[...r.body.childNodes].map(e=>i.adoptNode(e)))}function xe(e,t){for(let n of e.querySelectorAll(`img`)){let e=n.getAttribute(`src`);if(e===null)continue;let r=t(e);r!==null&&n.setAttribute(`src`,r)}}function Se({source:e,imageUrl:t,className:n}){let r=(0,C.useRef)(null);return(0,C.useEffect)(()=>{r.current&&L(r.current,e,t?{imageUrl:t}:{})},[e,t]),(0,O.jsx)(`div`,{className:n?`prose ${n}`:`prose`,ref:r})}var Ce=e=>typeof e==`object`&&!!e&&!Array.isArray(e),R=(e,t=``)=>typeof e==`string`?e:t;function we(e){let t=[];for(let n of Array.isArray(e)?e:[]){if(!Ce(n)||typeof n.id!=`string`)continue;let e=[];for(let t of Array.isArray(n.options)?n.options:[])!Ce(t)||typeof t.id!=`string`||e.push({id:t.id,said:R(t.said,t.id),...t.recommended===!0?{recommended:!0}:{}});t.push({id:n.id,ask:R(n.ask),options:e,multi:n.multi===!0,...typeof n.invite==`string`&&n.invite!==``?{invite:n.invite}:{}})}return t}function Te(e){if(!Ce(e))return{kind:`gate`,asks:``,offer:null};if(e.kind===`decision`){let t=R(e.heading),n=we(e.questions);return t!==``&&n.length===1?{kind:`decision`,heading:t,questions:n}:{kind:`gate`,asks:``,offer:null}}return e.kind===`round`||Array.isArray(e.questions)?{kind:`round`,questions:we(e.questions)}:{kind:`gate`,asks:R(e.asks),offer:Ee(e.offer)}}function Ee(e){if(!Ce(e))return null;let t=R(e.said);return t===``?null:{said:t,preset:e.preset===!0}}function De(e,t){return e.map(e=>{let n=t.get(e.id),r=n?.chosen??[],i=n?.said??``;return{question:e.id,chosen:r,said:i,answered:r.length>0||i.trim()!==``}})}var z=50,Oe=600,B={gate:`What should change?`,round:`Anything else?`,decision:`Your words`};function V(e){return e.split(`
|
|
13
|
+
`).find(e=>e.trim()!==``)?.trim()??e}function ke(e){let[t,n]=(0,C.useState)(()=>e.draft?.given??new Map),[r,i]=(0,C.useState)(()=>e.draft?.said??``),a=e.onDraft;(0,C.useEffect)(()=>{a({given:t,said:r})},[t,r,a]);let o=(0,C.useRef)(null),s=(0,C.useRef)(null);(0,C.useEffect)(()=>{let t=e.summon??0;if(!e.settled||s.current===t)return;s.current=t;let n=()=>o.current?.scrollIntoView?.({block:`start`}),r=setTimeout(n,z),i=[o.current?.parentElement,o.current?.previousElementSibling].filter(e=>e instanceof Element),a=typeof ResizeObserver==`function`&&i.length>0?new ResizeObserver(n):null;for(let e of i)a?.observe(e);let c=setTimeout(()=>a?.disconnect(),Oe);return()=>{clearTimeout(r),clearTimeout(c),a?.disconnect()}},[e.settled,e.summon]);let c=e.ask.kind===`gate`?e.ask.offer:null,[l,u]=(0,C.useState)(c?.preset===!0),d=e.ask.kind===`gate`?[]:e.ask.questions,f=(t,n=[])=>e.onAnswer({outcome:t,said:r.trim(),questions:n,accepted:t===`approved`&&c!==null&&l}),p=()=>{let n=e.ask.kind===`decision`&&d[0]!==void 0?new Map(t).set(d[0].id,{chosen:t.get(d[0].id)?.chosen??[],said:r.trim()}):t;f(`answered`,De(d,n))},m=e.ask.kind===`decision`?`Submit answer`:`Send the answers`,h=(e,t,r)=>n(n=>{let i=new Map(n),a=i.get(e)??{chosen:[],said:``},o=r?a.chosen.includes(t)?a.chosen.filter(e=>e!==t):[...a.chosen,t]:[t];return i.set(e,{...a,chosen:o}),i}),g=(e,t)=>n(n=>{let r=new Map(n),i=r.get(e)??{chosen:[],said:``};return r.set(e,{...i,said:t}),r});return(0,O.jsxs)(`section`,{className:`ask`,"aria-label":e.title,ref:o,children:[(0,O.jsxs)(`div`,{className:`ask-head`,children:[(0,O.jsx)(`h2`,{children:e.title}),e.file!==``&&(0,O.jsxs)(`p`,{className:`ask-about`,children:[`about `,(0,O.jsx)(`b`,{children:e.file}),e.ask.kind===`decision`&&(0,O.jsxs)(O.Fragment,{children:[` › `,(0,O.jsx)(`b`,{children:e.ask.heading})]})]})]}),e.ask.kind===`gate`&&e.ask.asks!==``&&(0,O.jsx)(Se,{className:`ask-asks`,source:e.ask.asks}),d.length>0&&(0,O.jsx)(`ol`,{className:`questions`,children:d.map(n=>(0,O.jsxs)(`li`,{children:[(0,O.jsx)(Se,{className:`question-ask`,source:n.ask}),(0,O.jsx)(`ul`,{className:`choices`,children:n.options.map(e=>(0,O.jsx)(`li`,{className:e.recommended?`is-recommended`:void 0,children:(0,O.jsxs)(`label`,{children:[(0,O.jsx)(`input`,{type:n.multi?`checkbox`:`radio`,name:n.id,checked:t.get(n.id)?.chosen.includes(e.id)??!1,onChange:()=>h(n.id,e.id,n.multi)}),(0,O.jsxs)(`span`,{className:`choice-title`,children:[e.said,e.recommended&&(0,O.jsx)(`span`,{className:`choice-flag`,children:`recommended`})]})]})},e.id))}),e.ask.kind===`round`&&(0,O.jsx)(`textarea`,{className:`question-said`,value:t.get(n.id)?.said??``,placeholder:n.invite??`Your words`,"aria-label":`Anything to add about: ${V(n.ask)}`,onChange:e=>g(n.id,e.target.value)})]},n.id))}),(0,O.jsx)(`textarea`,{className:`field-dump`,value:r,placeholder:B[e.ask.kind],"aria-label":e.ask.kind===`decision`?`Your words`:`Anything else`,onChange:e=>i(e.target.value)}),c!==null&&(0,O.jsxs)(`label`,{className:`ask-offer`,children:[(0,O.jsx)(`input`,{type:`checkbox`,checked:l,onChange:e=>u(e.target.checked)}),(0,O.jsx)(`span`,{children:c.said})]}),e.failure!==null&&(0,O.jsx)(`p`,{className:`notice notice-failure`,children:e.failure}),e.asked!==null&&(0,O.jsxs)(`p`,{className:`ask-asked`,children:[`Asked in the terminal: “`,e.asked,`”. This is still waiting for your answer.`]}),(0,O.jsxs)(`div`,{className:`form-acts`,children:[(0,O.jsx)(`button`,{type:`button`,onClick:e.onDismiss,children:`Later`}),(0,O.jsx)(`button`,{type:`button`,className:`ask-question`,disabled:e.sending||r.trim()===``,title:`Send this to the agent in the terminal, and answer nothing`,onClick:()=>void e.onAsk(r.trim()).then(e=>{e&&i(``)}),children:`Ask about this`}),e.ask.kind===`gate`&&(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(`button`,{type:`button`,disabled:e.sending||r.trim()===``,onClick:()=>f(`changes`),children:`Ask for changes`}),(0,O.jsx)(`button`,{type:`button`,className:`send`,disabled:e.sending,onClick:()=>f(`approved`),children:`Approve`})]}),e.ask.kind!==`gate`&&(0,O.jsx)(`button`,{type:`button`,className:`send`,disabled:e.sending,onClick:p,children:e.sending?`Sending…`:m})]})]})}function H(){return`a-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,8)}`}function Ae(e,t,n=``){return{id:H(),unit:e.unit,file:e.file,heading:e.heading,kind:t,quote:e.quote,text:n}}function je(e){return e.quote?`“${Me(e.quote)}”`:e.heading?`${e.file} - ${e.heading}`:e.file||`this spec`}function Me(e,t=80){let n=e.replace(/\s+/g,` `).trim();return n.length<=t?n:`${n.slice(0,t-1)}…`}function Ne(e){return e.filter(e=>e.kind===`remove`||e.text.trim()!==``)}function Pe(e){return{queued:e.map(e=>e.id),comments:Ne(e).map(e=>({unit:e.unit,file:e.file,heading:e.heading,kind:e.kind,quote:e.quote,text:e.text.trim(),assets:[]}))}}function Fe(e){let t=Ne(e);if(t.length===0)return``;let n=t.filter(e=>e.kind===`remove`).length,r=t.length-n,i=[];r>0&&i.push(`${r} ${r===1?`comment`:`comments`}`),n>0&&i.push(`${n} to remove`);let a=t[0];return`${i.join(`, `)} - first on ${je(a)}`}function Ie(){return{version:1,units:{},dismissed:[]}}function Le(e){return{version:1,entry:e,annotations:[]}}var U=e=>typeof e==`object`&&!!e&&!Array.isArray(e),Re=(e,t=``)=>typeof e==`string`?e:t;function ze(e){let t;try{t=JSON.parse(e||`null`)}catch{return Ie()}if(!U(t)||t.version!==1)return Ie();let n=Ie();if(U(t.units))for(let[e,r]of Object.entries(t.units)){if(!U(r))continue;let t={};typeof r.readHash==`string`&&(t.readHash=r.readHash),typeof r.readAt==`string`&&(t.readAt=r.readAt),n.units[e]=t}return Array.isArray(t.dismissed)&&(n.dismissed=t.dismissed.filter(e=>typeof e==`string`)),n}function Be(e,t){let n;try{n=JSON.parse(e||`null`)}catch{return Le(t)}if(!U(n)||n.version!==1)return Le(t);let r=[];if(Array.isArray(n.annotations))for(let e of n.annotations)!U(e)||typeof e.id!=`string`||typeof e.unit!=`string`||e.id===``||e.unit===``||r.push({id:e.id,unit:e.unit,file:Re(e.file),heading:Re(e.heading),kind:e.kind===`remove`?`remove`:`comment`,quote:Re(e.quote),text:Re(e.text)});return{version:1,entry:Re(n.entry,t),annotations:r}}var Ve=`quality-review`,He=[{id:`exploration`,title:`High-level exploration`,group:`discovery`,about:`We think the problem through together first - directions to take, risks, and what is still unclear.`},{id:`interview`,title:`Interview`,group:`discovery`,about:`I ask you focused questions until nothing important is left open.`},{id:`research`,title:`Research`,group:`discovery`,about:`I look outside your code - a library, a protocol, an algorithm, a subject area - and write up what I find.`},{id:`codebase-analysis`,title:`Codebase analysis`,group:`discovery`,about:`I read the parts of your code this work touches and note what shapes the design.`},{id:`technical-specs`,title:`Technical specs`,group:`deliverables`,about:`A written specification another agent can build from without asking you anything.`},{id:`ui-mocks`,title:`UI mocks`,group:`deliverables`,about:`Mock screens you open in your browser and comment on before anything is built.`},{id:`execution-plan`,title:`Execution plan`,group:`deliverables`,about:`The work split into phases, each with a goal and a way to tell it is done.`},{id:Ve,title:`Quality review`,group:`deliverables`,about:`Fresh helper agents review everything we wrote, and I fix what is plainly wrong and bring the judgment calls to you.`}],Ue=[`exploration`,`ui-mocks`];function W(e){return He.find(t=>t.id===e)??null}var We=`final`,Ge=[`consistency and completeness`,`principles alignment`,`better ways to do this`],Ke=[{id:`per-phase`,said:`a commit per phase`},{id:`single`,said:`a single commit at the end`},{id:`none`,said:`no commits`}],qe=[{id:`current`,said:`the current branch`},{id:`new`,said:`a new branch`}],G=[{id:`none`,said:`none`},{id:`chosen`,said:`after chosen phases`},{id:`every`,said:`every phase`}];function K(e){return{commits:`per-phase`,branch:`current`,branchName:`spec/${e}`,pauses:`none`,pausePhases:[],checkpoints:[{after:We,why:`judges the finished work as a whole`,panel:[...Ge],chosen:!0}]}}function Je(e,t=new Date){let{said:n,at:r}=e.activity;if(n===``||r===``||e.log.reduce((e,t)=>t.at>e?t.at:e,``)>r)return null;let i=Date.parse(r);return Number.isNaN(i)||t.getTime()-i>18e5?null:{said:n,at:r}}function q(e,t){return{version:1,name:e,created:t,status:`specifying`,protocol:[],modes:{imagination:!1},wish:{imagination:!1},stageSettings:{research:null},activity:{said:``,at:``},awaiting:[],phases:[],runRecommendations:null,runDecisions:null,reviews:[],approvals:[],log:[]}}var J=e=>typeof e==`object`&&!!e&&!Array.isArray(e),Y=(e,t=``)=>typeof e==`string`?e:t,Ye=(e,t,n)=>t.includes(e)?e:n,Xe=[`specifying`,`ready`,`executing`,`complete`],Ze=[`waiting`,`running`,`done`],Qe=[`gate`,`round`,`protocol`],$e=[`focused`,`named`,`broad`],X=Ke.map(e=>e.id),et=qe.map(e=>e.id),tt=G.map(e=>e.id);function nt(e){if(!J(e)||e.scope===void 0)return null;let t=Ye(e.scope,$e,`focused`);return{scope:t,subject:t===`named`?rt(Y(e.subject)):``}}function rt(e,t=200){return e.replace(/\p{C}+/gu,` `).replace(/\s+/g,` `).trim().slice(0,t)}function it(t){if(!J(t))return null;let n=[];for(let r of Array.isArray(t.checkpoints)?t.checkpoints:[]){if(!J(r))continue;let t=Array.isArray(r.panel)?r.panel.filter(e=>typeof e==`string`).map(e=>rt(e)):[];n.push({after:e(Y(r.after)),why:rt(Y(r.why)),panel:t,chosen:r.chosen!==!1&&t.length>0})}return{commits:Ye(t.commits,X,`per-phase`),branch:Ye(t.branch,et,`current`),branchName:rt(Y(t.branchName)),pauses:Ye(t.pauses,tt,`none`),pausePhases:Array.isArray(t.pausePhases)?t.pausePhases.filter(e=>typeof e==`string`).map(t=>e(t)):[],checkpoints:n}}function at(t){if(!J(t))return null;let n=it(t);if(n===null)return null;let r={};if(J(t.pauseReasons))for(let[n,i]of Object.entries(t.pauseReasons)){if(typeof i!=`string`)continue;let t=rt(i);t!==``&&(r[e(n)]=t)}return{...n,pauseReasons:r,noPauseReason:rt(Y(t.noPauseReason))}}function ot(e,t=``,n=``){let r;try{r=JSON.parse(e||`null`)}catch{return q(t,n)}if(!J(r)||r.version!==1)return q(t,n);let i=q(Y(r.name,t),Y(r.created,n)),a=Y(r.status);if(Xe.includes(a)&&(i.status=a),Array.isArray(r.protocol))for(let e of r.protocol){if(!J(e)||!W(Y(e.id)))continue;let t=Y(e.status);i.protocol.push({id:Y(e.id),status:Ze.includes(t)?t:`waiting`,artifacts:Array.isArray(e.artifacts)?e.artifacts.filter(e=>typeof e==`string`):[]})}if(J(r.modes)&&(i.modes.imagination=r.modes.imagination===!0),J(r.wish)&&(i.wish.imagination=r.wish.imagination===!0),J(r.stageSettings)&&(i.stageSettings={research:nt(r.stageSettings.research)}),J(r.activity)&&(i.activity={said:Y(r.activity.said),at:Y(r.activity.at)}),Array.isArray(r.awaiting))for(let e of r.awaiting){if(!J(e)||!e.id)continue;let t=Y(e.kind);i.awaiting.push({id:Y(e.id),kind:Qe.includes(t)?t:`round`,title:Y(e.title),file:Y(e.file),payload:Y(e.payload),declaredAt:Y(e.declaredAt)})}if(Array.isArray(r.phases))for(let e of r.phases){if(!J(e)||!e.id)continue;let t=Y(e.status);i.phases.push({id:Y(e.id),title:Y(e.title),status:Ze.includes(t)?t:`waiting`})}i.runRecommendations=at(r.runRecommendations);let o=it(r.runDecisions);if(o!==null&&J(r.runDecisions)&&(i.runDecisions={...o,decidedAt:Y(r.runDecisions.decidedAt)}),Array.isArray(r.reviews))for(let e of r.reviews)!J(e)||typeof e.round!=`number`||i.reviews.push({round:e.round,verdict:Y(e.verdict),findings:typeof e.findings==`number`?e.findings:0,judgments:typeof e.judgments==`number`?e.judgments:0,at:Y(e.at)});if(Array.isArray(r.approvals))for(let e of r.approvals)!J(e)||!e.id||i.approvals.push({id:Y(e.id),at:Y(e.at),outcome:Y(e.outcome)});if(Array.isArray(r.log))for(let e of r.log)J(e)&&i.log.push({at:Y(e.at),said:Y(e.said)});return i}var Z=o(`specs`);Z.receive;var st=Z.credentialsReady,ct=Z.onChange,lt=Z.onSession,ut=Z.openOutside,dt=Z.deliver,ft=Z.sayWaiting,pt=Z.listen;function mt(e){return Z.askTheme(e)}var ht=_({prefix:`specs`,label:`Specs`,credentialsReady:st});ht.keyHeader;var Q=ht.ask;function gt(){return Q(`dashboard`)}function _t(e){return Q(`entry?path=${encodeURIComponent(e)}`)}function vt(e){return Q(`archive?entry=${encodeURIComponent(e)}`,{method:`POST`})}function yt(e){return Q(`file?path=${encodeURIComponent(e)}`)}async function bt(e){let t=await Q(`state?entry=${encodeURIComponent(e)}`);return ze(JSON.stringify(t))}function xt(e,t){return Q(`state?entry=${encodeURIComponent(e)}`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)})}async function St(e){let t=await Q(`pending?entry=${encodeURIComponent(e)}`);return Be(JSON.stringify(t),e).annotations}function Ct(e,t){return Q(`pending?entry=${encodeURIComponent(e)}`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({...Le(e),annotations:t})})}function wt(e){return Q(`feedback?entry=${encodeURIComponent(e)}`)}function Tt(e,t){return Q(`feedback?entry=${encodeURIComponent(e)}`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)})}async function Et(e){let t=await Q(`protocol?entry=${encodeURIComponent(e)}`);return ot(JSON.stringify(t))}function Dt(e,t){return Q(`round?entry=${encodeURIComponent(e)}&id=${encodeURIComponent(t)}`)}function Ot(e){return Q(`intake`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)})}async function kt(e,t){let n=await Q(`confirm?entry=${encodeURIComponent(e)}`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)});return{state:ot(JSON.stringify(n.state)),change:n.change}}async function At(e,t){let n=await Q(`decide?entry=${encodeURIComponent(e)}`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)});return ot(JSON.stringify(n))}function jt(e,t,n){return Q(`answer?entry=${encodeURIComponent(e)}&id=${encodeURIComponent(t)}`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(n)})}var Mt=ht.rawUrl;ht.fileUrl;var Nt=`archive`;function Pt(e){let t=e=>String(e).padStart(2,`0`);return`${e.getFullYear()}-${t(e.getMonth()+1)}-${t(e.getDate())}`}function Ft(e,t){let n=e.split(`/`).pop()??e;return`${Nt}/${Pt(t)}-${n}`}var It=30,Lt=108,Rt=8,zt=240;function Bt(e){let t=e.lastIndexOf(`/`);return t===-1?``:e.slice(0,t)}function Vt({unit:e,state:t,name:n,onToggle:r}){let i=t?.read??!1;return(0,O.jsxs)(`button`,{type:`button`,className:`mark`,"aria-pressed":i,title:i?`Mark as unread`:`Mark as read`,onClick:()=>r(e),children:[`✓`,(0,O.jsxs)(`span`,{className:`visually-hidden`,children:[i?`Mark as unread`:`Mark as read`,`: `,n]})]})}function Ht({at:e,onPick:t,onDismiss:n}){return(0,O.jsxs)(`div`,{className:`annotate`,style:{top:e.top,left:e.left},children:[(0,O.jsxs)(`button`,{type:`button`,className:`annotate-drop`,title:`Ask for this to be removed`,onClick:()=>t(`remove`),children:[(0,O.jsx)(y,{}),(0,O.jsx)(`span`,{className:`visually-hidden`,children:`Ask for this to be removed`})]}),(0,O.jsxs)(`button`,{type:`button`,title:`Say something about this`,onClick:()=>t(`comment`),children:[(0,O.jsx)(u,{}),(0,O.jsx)(`span`,{className:`visually-hidden`,children:`Say something about this`})]}),(0,O.jsxs)(`button`,{type:`button`,className:`annotate-close`,title:`Dismiss`,onClick:n,children:[(0,O.jsx)(l,{}),(0,O.jsx)(`span`,{className:`visually-hidden`,children:`Dismiss`})]})]})}function Ut({at:e,onAdd:t,onDismiss:n}){let[r,i]=(0,C.useState)(``),a=(0,C.useRef)(null);return(0,C.useEffect)(()=>{let e=e=>{let t=e.target;t!==null&&a.current?.contains(t)===!0||n()},t=e=>{e.key===`Escape`&&n()};return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[n]),(0,O.jsxs)(`div`,{className:`annotate-composer`,style:{top:e.top,left:e.left},ref:a,children:[(0,O.jsx)(`p`,{className:`composer-target`,children:e.quote===``?e.name:`“${e.quote}”`}),(0,O.jsx)(`textarea`,{autoFocus:!0,value:r,placeholder:`What about it?`,"aria-label":`Your comment`,onChange:e=>i(e.target.value)}),(0,O.jsxs)(`div`,{className:`composer-acts`,children:[(0,O.jsx)(`button`,{type:`button`,className:`composer-cancel`,onClick:n,children:`Cancel`}),(0,O.jsx)(`button`,{type:`button`,className:`composer-add`,disabled:r.trim()===``,onClick:()=>t(r.trim()),children:`Add`})]})]})}function Wt(e){let{entry:t,file:n,units:i,text:a,marks:o,raw:s,landOn:c,onLanded:l,onCurrent:d,onOpen:f,onLeave:m}=e,h=Bt(n.path),_=(0,C.useRef)(null),ee=(0,C.useCallback)(e=>{let n=p(h,e);return n===null?null:Mt(s,t?`${t}/${n}`:n)},[h,t,s]),v=i[0],te=(0,C.useMemo)(()=>{let e=Mt(s,t?`${t}/${n.path}`:n.path);return v===void 0?e:`${e}?v=${encodeURIComponent(v.hash)}`},[t,n.path,s,v]),[y,b]=(0,C.useState)(null),[x,S]=(0,C.useState)(null),w=(0,C.useCallback)(()=>S(null),[]),T=(0,C.useCallback)(e=>{let t=_.current,n=t===null?e.left:t.clientWidth+t.scrollLeft-zt;S({...e,left:Math.max(0,Math.min(e.left,n))})},[]),ne=`${e.reader}/${t}/${n.path}`,re=(0,C.useRef)(ne);(0,C.useEffect)(()=>{re.current!==ne&&(re.current=ne,b(null),S(null))},[ne]);let E=(0,C.useCallback)(e=>{let t=(e instanceof Element?e:e?.parentElement)?.closest?.(`[data-unit]`),n=t instanceof HTMLElement?t.dataset.unit:void 0;return i.find(e=>e.id===n)??null},[i]),ie=e.onAnnotate,D=ie!==null,ae=(0,C.useCallback)((e,t,r,i)=>{let a=_.current;if(!a||!D)return;let o=a.getBoundingClientRect(),s=e.top-o.top+a.scrollTop,c=e.left-o.left+a.scrollLeft,l=s-a.scrollTop>=38;b({unit:t?.id??v?.id??``,file:n.path,heading:t?.heading??``,quote:r,name:i,top:l?s-It-Rt:s+e.height+Rt,left:Math.max(0,Math.min(c,a.clientWidth+a.scrollLeft-Lt))})},[D,n.path,v]);(0,C.useEffect)(()=>{let e=_.current;if(!e||typeof IntersectionObserver!=`function`)return;let t=[...e.querySelectorAll(`[data-unit]`)];if(t.length===0)return;let n=new Map,r=new IntersectionObserver(e=>{for(let t of e)n.set(t.target.getAttribute(`data-unit`)??``,t);let t=[...n.values()].filter(e=>e.isIntersecting).sort((e,t)=>e.boundingClientRect.top-t.boundingClientRect.top)[0]?.target.getAttribute(`data-unit`);t&&d(t)},{root:e,rootMargin:`0px 0px -65% 0px`,threshold:0});for(let e of t)r.observe(e);return()=>r.disconnect()},[d,i]),(0,C.useEffect)(()=>{if(c===null)return;let e=[..._.current?.querySelectorAll(`[data-unit]`)??[]].find(e=>e.dataset.unit===c);e&&(e.scrollIntoView?.({block:`start`}),l())},[c,l,i]),(0,C.useEffect)(()=>{let e=_.current;if(!e)return;let t=t=>{if(t.target?.closest?.(`.annotate, .annotate-composer`))return;let n=document.getSelection(),r=n?.toString()??``;if(!n||n.isCollapsed||r.trim()===``){b(null);return}let i=n.anchorNode;if(!i||!e.contains(i))return;let a=n.getRangeAt(0).getBoundingClientRect();ae(a,E(i),r,r)};return e.addEventListener(`mouseup`,t),()=>e.removeEventListener(`mouseup`,t)},[ae,E]),(0,C.useEffect)(()=>{let e=_.current;if(!e)return;let t=e=>{let t=e.target;if(t instanceof HTMLImageElement){e.preventDefault(),ae(t.getBoundingClientRect(),E(t),``,t.alt||n.name);return}let r=t?.closest?.(`a`);if(!r)return;let i=r.getAttribute(`href`);if(i===null)return;e.preventDefault();let[a,o=``]=i.split(`#`);if(a===``){f(n.path,o);return}let s=p(h,a);if(s!==null){f(s,o);return}let c=g(a);c!==null&&m(c)};return e.addEventListener(`click`,t),()=>e.removeEventListener(`click`,t)},[h,n.name,n.path,m,f,ae,E]);let k=e.failure===null&&!e.loading,oe=i.filter(e=>o[e.id]?.read).length,se=i.filter(e=>o[e.id]?.changed).length;return(0,O.jsxs)(`div`,{className:`doc`,ref:_,children:[y!==null&&ie!==null&&(0,O.jsx)(Ht,{at:y,onPick:e=>{e===`comment`?T(y):ie(y,e),b(null),document.getSelection()?.removeAllRanges()},onDismiss:()=>b(null)}),x!==null&&ie!==null&&(0,O.jsx)(Ut,{at:x,onAdd:e=>{ie(x,`comment`,e),S(null)},onDismiss:w}),e.failure!==null&&(0,O.jsx)(`p`,{className:`notice notice-failure`,children:e.failure}),e.failure===null&&e.loading&&(0,O.jsxs)(`p`,{className:`notice`,children:[`Reading `,n.name,`…`]}),k&&(0,O.jsxs)(`div`,{className:`doc-facts`,children:[(0,O.jsxs)(`span`,{children:[n.path,` · `,r(n.size)]}),i.length>0&&(0,O.jsxs)(`span`,{children:[`· `,oe,` of `,i.length,` read`]}),se>0&&(0,O.jsxs)(`span`,{className:`doc-changed`,children:[`· `,se,` changed since you read `,se===1?`it`:`them`]}),n.kind!==`markdown`&&v!==void 0&&(0,O.jsx)(Vt,{unit:v,state:o[v.id],name:n.name,onToggle:e.onToggleRead}),D&&(0,O.jsx)(`span`,{className:`doc-facts-acts`,children:(0,O.jsxs)(`button`,{type:`button`,className:`annotate-whole`,title:`Say something about this artifact`,onClick:e=>ae(e.currentTarget.getBoundingClientRect(),v??null,``,n.name),children:[(0,O.jsx)(u,{size:13}),(0,O.jsx)(`span`,{className:`visually-hidden`,children:`Say something about this artifact`})]})})]}),k&&n.kind===`markdown`&&i.map(t=>{let r=o[t.id];return(0,O.jsxs)(C.Fragment,{children:[(0,O.jsxs)(`section`,{"data-unit":t.id,className:`doc-section${r?.read?` is-read`:``}`,children:[(0,O.jsx)(`div`,{className:`sec-mark`,children:(0,O.jsx)(Vt,{unit:t,state:r,name:t.heading??n.name,onToggle:e.onToggleRead})}),t.heading!==null&&(0,O.jsxs)(`h2`,{children:[t.heading,r?.changed&&(0,O.jsx)(`span`,{className:`sec-changed`,children:`changed since you read it`})]}),t.heading===null&&r?.changed&&(0,O.jsx)(`p`,{className:`sec-changed`,children:`changed since you read it`}),(0,O.jsx)(Se,{source:t.body,imageUrl:ee})]}),e.under?.unit===t.id&&e.under.node]},t.id)}),k&&n.kind===`html`&&(0,O.jsx)(`iframe`,{className:`art-frame`,title:n.name,src:te,sandbox:`allow-scripts allow-forms`,referrerPolicy:`no-referrer`}),k&&n.kind===`image`&&(0,O.jsx)(`p`,{className:`art-image`,children:(0,O.jsx)(`img`,{src:te,alt:n.name})}),k&&n.kind===`text`&&(0,O.jsx)(`pre`,{className:`plain`,children:a??``}),k&&n.kind===`binary`&&(0,O.jsxs)(`p`,{className:`notice`,children:[n.name,` is `,r(n.size),` of something this tool does not render. It is in the spec directory, where the agent beside you can read it.`]})]})}function Gt(e){let t=(0,C.useId)();return(0,O.jsxs)(`div`,{className:e.className??`run-field`,children:[(0,O.jsx)(`span`,{id:t,children:e.label}),(0,O.jsxs)(`div`,{className:`run-with`,children:[(0,O.jsx)(`select`,{"aria-labelledby":t,value:e.value,onChange:t=>e.onPick(t.target.value),children:e.options.map(e=>(0,O.jsx)(`option`,{value:e.id,children:e.said},e.id))}),e.children]})]})}function Kt(e){let t=K(e.slug),n=e.decided??e.recommended??t;return{...n,branchName:n.branchName||t.branchName}}function $(e,t){if(e===`final`)return`final`;let n=t.find(t=>t.id===e);return n===void 0?null:n.title}var qt=0,Jt=()=>`k${++qt}`;function Yt(e){return e.map(e=>({key:Jt(),after:e.after,why:e.why,chosen:e.chosen,panel:e.panel.map(e=>({key:Jt(),focus:e})),typing:``}))}function Xt(e){return[...e.panel.map(e=>e.focus),e.typing].map(e=>e.trim()).filter(e=>e!==``)}function Zt(e){return e.map(e=>({after:e.after,why:e.why,chosen:e.chosen,panel:Xt(e)}))}function Qt(e){let[t]=(0,C.useState)(()=>Kt(e)),[n,r]=(0,C.useState)(t.commits),[i,a]=(0,C.useState)(t.branch),[o,s]=(0,C.useState)(t.branchName),[c,u]=(0,C.useState)(t.pauses),[f,p]=(0,C.useState)(t.pausePhases),[m,h]=(0,C.useState)(()=>Yt(t.checkpoints)),g=e.decided!==null,_=g?null:e.recommended,ee=e.phases.filter(e=>e.status===`done`).length,v=e.phases.length>0,te=f.filter(t=>!e.phases.some(e=>e.id===t)),y=_?.pauses===`chosen`?_.pausePhases.map(t=>({id:t,place:$(t,e.phases)??t,said:Object.hasOwn(_.pauseReasons,t)?_.pauseReasons[t]:``})).filter(e=>e.said!==``):[],b=_?.pauses===`none`?_.noPauseReason:``,x=(c===`chosen`?te.length:0)+m.filter(t=>t.chosen&&$(t.after,e.phases)===null).length,S=(e,t)=>e.map(e=>e.id===t&&_!==null?{...e,said:`${e.said} (recommended)`}:e),w=(e,t)=>h(n=>n.map(n=>n.key===e?t(n):n)),T=e=>e.typing.trim()===``?e:{...e,panel:[...e.panel,{key:Jt(),focus:e.typing.trim()}],typing:``},ne=(e,t)=>w(e,e=>{let n=e.panel.find(e=>e.key===t),r=T(e);return{...r,panel:r.panel.filter(e=>e.key!==t),typing:n?.focus??r.typing}});return(0,O.jsx)(`div`,{className:`dialog-shade`,children:(0,O.jsxs)(`div`,{className:`dialog dialog-wide`,role:`dialog`,"aria-modal":`true`,"aria-label":`Execute this spec`,children:[(0,O.jsx)(`h2`,{className:`rail-head`,children:`Execute this spec`}),(0,O.jsxs)(`div`,{className:`dialog-body`,children:[(0,O.jsxs)(`p`,{className:`rail-fact muted`,children:[`Set up the run for `,(0,O.jsx)(`b`,{children:e.name}),`.`,_!==null&&` Pre-filled from the recommendations in the plan - change anything.`]}),g&&(0,O.jsxs)(`p`,{className:`run-banner`,children:[(0,O.jsx)(`b`,{children:`Resuming a run in progress.`}),` `,(0,O.jsxs)(`span`,{className:`muted`,children:[ee,` of `,e.phases.length,` phases done - these are the choices this run started with.`]})]}),(0,O.jsx)(Gt,{label:`Commits`,options:S(Ke,_?.commits),value:n,onPick:r}),(0,O.jsx)(Gt,{label:`Branch`,options:S(qe,_?.branch),value:i,onPick:a,children:i===`new`&&(0,O.jsx)(`input`,{value:o,"aria-label":`The branch to make`,onChange:e=>s(e.target.value)})}),(0,O.jsx)(Gt,{label:`Pauses`,options:S(G.filter(e=>e.id!==`chosen`||v),_?.pauses),value:c,onPick:u}),(c===`chosen`||y.length>0||b!==``)&&(0,O.jsxs)(`div`,{className:`run-phases`,children:[c===`chosen`&&(0,O.jsxs)(O.Fragment,{children:[e.phases.map(e=>(0,O.jsxs)(`label`,{children:[(0,O.jsx)(`input`,{type:`checkbox`,checked:f.includes(e.id),onChange:()=>p(t=>t.includes(e.id)?t.filter(t=>t!==e.id):[...t,e.id])}),e.title]},e.id)),te.map(e=>(0,O.jsxs)(`p`,{className:`run-stale`,children:[e,` is not in the plan any more - re-place this pause`]},e))]}),y.map(e=>(0,O.jsxs)(`p`,{className:`run-why`,children:[(0,O.jsxs)(`b`,{children:[`After `,e.place,`:`]}),` `,e.said]},e.id)),b!==``&&(0,O.jsxs)(`p`,{className:`run-why`,children:[(0,O.jsx)(`b`,{children:`No pause recommended:`}),` `,b]})]}),(0,O.jsx)(`h3`,{className:`run-head`,children:`Review checkpoints`}),m.length===0&&(0,O.jsx)(`p`,{className:`rail-fact muted`,children:`None proposed.`}),m.map(t=>{let n=$(t.after,e.phases),r=n===null?`somewhere the plan no longer holds`:`after ${n}`;return(0,O.jsxs)(`div`,{className:`run-checkpoint`,children:[(0,O.jsxs)(`label`,{className:`run-checkpoint-head`,children:[(0,O.jsx)(`input`,{type:`checkbox`,checked:t.chosen,onChange:()=>w(t.key,e=>({...e,chosen:!e.chosen}))}),(0,O.jsx)(`span`,{children:r})]}),t.why!==``&&(0,O.jsx)(`p`,{className:`run-why`,children:t.why}),t.chosen&&n===null&&(0,O.jsx)(`p`,{className:`run-stale`,children:`This checkpoint has nowhere to sit - untick it, or re-place it in the plan`}),t.chosen&&Xt(t).length===0&&(0,O.jsx)(`p`,{className:`run-stale`,children:`Nobody is on this panel, so this checkpoint will not run`}),(0,O.jsxs)(`div`,{className:`run-panel`,children:[t.panel.map((e,n)=>(0,O.jsxs)(`span`,{className:`run-reviewer`,children:[(0,O.jsx)(`button`,{type:`button`,className:`run-focus`,title:`Change this reviewer`,onClick:()=>ne(t.key,e.key),children:e.focus}),(0,O.jsx)(`button`,{type:`button`,className:`run-drop`,"aria-label":`Drop reviewer ${n+1} ${r}`,onClick:()=>w(t.key,t=>({...t,panel:t.panel.filter(t=>t.key!==e.key)})),children:(0,O.jsx)(l,{size:11})})]},e.key)),(0,O.jsxs)(`span`,{className:`run-new`,children:[(0,O.jsx)(`input`,{value:t.typing,"aria-label":`New reviewer ${r}`,placeholder:`What the next reviewer judges`,onChange:e=>w(t.key,t=>({...t,typing:e.target.value})),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),w(t.key,T))}}),(0,O.jsxs)(`button`,{type:`button`,"aria-label":`Add a reviewer ${r}`,onClick:()=>w(t.key,T),children:[(0,O.jsx)(d,{size:11}),`add`]})]})]})]},t.key)})]}),x>0&&(0,O.jsxs)(`p`,{className:`notice notice-failure`,children:[x===1?`One choice names`:`${x} choices name`,` a phase this plan no longer holds. Re-place `,x===1?`it`:`them`,` before you run.`]}),e.failure!==null&&(0,O.jsx)(`p`,{className:`notice notice-failure`,children:e.failure}),(0,O.jsxs)(`div`,{className:`dialog-acts`,children:[(0,O.jsx)(`button`,{type:`button`,onClick:e.onCancel,disabled:e.working,children:`Cancel`}),(0,O.jsx)(`button`,{type:`button`,className:`send`,disabled:e.working||x>0,onClick:()=>e.onRun({commits:n,branch:i,branchName:o.trim(),pauses:c,pausePhases:c===`chosen`?f:[],checkpoints:Zt(m)}),children:e.working?`Recording…`:g?`Record and resume`:`Record and run`})]})]})})}function $t(e){return new Promise((t,n)=>{let r=new FileReader;r.onerror=()=>n(Error(`${e.name} could not be read`)),r.onload=()=>{let n=String(r.result??``);t({name:e.name,type:e.type,data:n.slice(n.indexOf(`,`)+1)})},r.readAsDataURL(e)})}var en=0;function tn(t){let[n,r]=(0,C.useState)(()=>t.draft?.name??``),[i,a]=(0,C.useState)(()=>t.draft?.text??``),[o,s]=(0,C.useState)(()=>t.draft?.attachments??[]),[c,l]=(0,C.useState)(null),[u,d]=(0,C.useState)(()=>t.draft?.imagination===!0),f=t.onDraft;(0,C.useEffect)(()=>{f({name:n,text:i,attachments:o,imagination:u})},[n,i,o,u,f]);let p=(0,C.useCallback)(async e=>{let t=[...e??[]];if(t.length!==0){l(null);try{let e=await Promise.all(t.map($t));s(t=>[...t,...e.map(e=>(en+=1,{key:`f${en}`,file:e}))])}catch(e){l(e.message)}}},[]),m=n.trim()!==``&&(i.trim()!==``||o.length>0),h=e(n.trim());return(0,O.jsx)(`div`,{className:`dialog-shade`,children:(0,O.jsxs)(`div`,{className:`dialog dialog-wide`,role:`dialog`,"aria-modal":`true`,"aria-label":`A new spec`,children:[(0,O.jsx)(`h2`,{className:`rail-head`,children:`A new piece of work`}),(0,O.jsxs)(`div`,{className:`dialog-body`,children:[(0,O.jsxs)(`label`,{className:`field`,children:[(0,O.jsx)(`span`,{children:`Working name`}),(0,O.jsx)(`input`,{value:n,placeholder:`What would you call it?`,onChange:e=>r(e.target.value)}),h!==``&&(0,O.jsxs)(`span`,{className:`field-slug`,children:[`Saved as `,(0,O.jsx)(`code`,{children:h})]})]}),(0,O.jsxs)(`label`,{className:`field`,children:[(0,O.jsx)(`span`,{children:`What is it about?`}),(0,O.jsx)(`textarea`,{className:`field-dump`,value:i,placeholder:`Say as much or as little as you have. Drop or paste files in here too.`,onChange:e=>a(e.target.value),onPaste:e=>void p(e.clipboardData?.files??null),onDragOver:e=>e.preventDefault(),onDrop:e=>{e.preventDefault(),p(e.dataTransfer?.files??null)}})]}),o.length>0&&(0,O.jsx)(`ul`,{className:`attached`,children:o.map(e=>(0,O.jsxs)(`li`,{children:[e.file.name,(0,O.jsx)(`button`,{type:`button`,onClick:()=>s(t=>t.filter(t=>t.key!==e.key)),children:`drop`})]},e.key))}),(0,O.jsxs)(`label`,{className:`flavour`,children:[(0,O.jsx)(`input`,{type:`checkbox`,checked:u,onChange:()=>d(!u)}),(0,O.jsxs)(`span`,{className:`flavour-what`,children:[`Imagination mode`,(0,O.jsx)(`span`,{className:`flavour-hint`,children:`Explore the ideal version first, before feasibility - best for open-ended or user-facing work. Confirmed with the steps.`})]})]})]}),c!==null&&(0,O.jsx)(`p`,{className:`notice notice-failure`,children:c}),t.failure!==null&&(0,O.jsx)(`p`,{className:`notice notice-failure`,children:t.failure}),(0,O.jsxs)(`div`,{className:`dialog-acts`,children:[(0,O.jsx)(`button`,{type:`button`,onClick:t.onCancel,children:`Cancel`}),(0,O.jsx)(`button`,{type:`button`,className:`send`,disabled:!m||t.filing,onClick:()=>void t.onFile({name:n.trim(),text:i.trim(),attachments:o.map(e=>e.file),wish:{imagination:u}}),children:t.filing?`Filing…`:`File it`})]})]})})}function nn(e){let t=[];for(let n of e){let e=t[t.length-1];e&&e.dir===n.dir?e.files.push(n):t.push({dir:n.dir,files:[n]})}return t}function rn(e){return e.openSpec===null?(0,O.jsx)(an,{...e}):(0,O.jsx)(on,{...e})}function an(e){let t=e.specs.filter(e=>!e.archived),n=e.specs.filter(e=>e.archived),r=t=>(0,O.jsx)(`li`,{children:(0,O.jsxs)(`button`,{type:`button`,className:`nav-entry`,onClick:()=>e.onOpenSpec(t.path),children:[(0,O.jsx)(`span`,{className:`nav-entry-name`,children:t.name}),t.status!==null&&(0,O.jsx)(`span`,{className:`nav-entry-status`,children:t.status}),t.awaiting>0&&(0,O.jsx)(`span`,{className:`nav-entry-awaiting`,title:`waiting for you`,children:t.awaiting})]})},t.path);return(0,O.jsxs)(`nav`,{className:`nav`,"aria-label":`Specs`,children:[(0,O.jsxs)(`button`,{type:`button`,className:`nav-new`,onClick:e.onNewSpec,children:[(0,O.jsx)(d,{size:12}),`New spec`]}),(0,O.jsx)(`h2`,{className:`nav-head`,children:`Specs`}),t.length===0?(0,O.jsx)(`p`,{className:`nav-empty`,children:`none yet`}):(0,O.jsx)(`ul`,{className:`nav-list`,children:t.map(r)}),n.length>0&&(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(`h2`,{className:`nav-head`,children:`Archive`}),(0,O.jsx)(`ul`,{className:`nav-list nav-archived`,children:n.map(r)})]})]})}function on(e){let t=e.spec?.name??e.openSpec??``;return(0,O.jsxs)(`nav`,{className:`nav`,"aria-label":t,children:[(0,O.jsxs)(`button`,{type:`button`,className:`nav-back`,onClick:e.onBack,children:[(0,O.jsx)(te,{size:11}),`All specs`]}),(0,O.jsxs)(`div`,{className:`nav-title`,children:[(0,O.jsx)(`div`,{className:`nav-title-name`,children:t}),e.spec?.status!=null&&(0,O.jsx)(`div`,{className:`nav-title-status`,children:e.spec.status})]}),nn(e.artifacts).map(t=>(0,O.jsxs)(`div`,{children:[t.dir!==``&&(0,O.jsxs)(`p`,{className:`nav-dir`,children:[t.dir,`/`]}),(0,O.jsx)(`ul`,{className:`nav-list`,children:t.files.map(t=>(0,O.jsxs)(`li`,{children:[(0,O.jsx)(`button`,{type:`button`,className:`nav-artifact`,"aria-current":t.path===e.openArtifact?`true`:void 0,onClick:()=>e.onOpenArtifact(t.path),children:t.name}),t.path===e.openArtifact&&e.units.length>1&&(0,O.jsx)(`ul`,{className:`nav-sections`,children:e.units.filter(e=>e.heading!==null).map(t=>(0,O.jsx)(`li`,{children:(0,O.jsxs)(`button`,{type:`button`,className:e.marks[t.id]?.read?`is-read`:void 0,"aria-current":t.id===e.currentUnit?`true`:void 0,onClick:()=>e.onOpenUnit(t.id),children:[t.heading,e.marks[t.id]?.changed&&(0,O.jsx)(`span`,{className:`nav-changed`,title:`Changed since you read it`,children:`●`})]})},t.id))})]},t.path))})]},t.dir||`.`))]})}var sn=[{id:`discovery`,head:`Before writing anything down`,said:`What we do first.`},{id:`deliverables`,head:`What this work produces`,said:`What we end up with.`}],cn=[{id:`focused`,said:`focused - the agent decides what to research`},{id:`named`,said:`focused on...`},{id:`broad`,said:`broad - deep research, can use many tokens`}];function ln(e){return new Map(e.stages.map(e=>[e.id,e]))}function un(e){let t=(0,C.useMemo)(()=>ln(e.proposal),[e.proposal]),{held:n}=e,[r,i]=(0,C.useState)(()=>n===null?new Set([...t.values()].filter(e=>e.recommended).map(e=>e.id)):new Set(n.stages.map(e=>e.id))),[a,o]=(0,C.useState)(n===null?e.wish:n.imagination),[s,c]=(0,C.useState)(n?.settings.research?.scope??`focused`),[l,u]=(0,C.useState)(n?.settings.research?.subject??``),[d,f]=(0,C.useState)(``),p=Ue.some(e=>r.has(e)),m=n===null&&e.wish,h=(0,C.useMemo)(()=>new Set((n?.stages??[]).filter(e=>e.status!==`waiting`).map(e=>e.id)),[n]),g=e=>{h.has(e)||i(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},_=(0,C.useMemo)(()=>{if(n===null)return!0;let e=new Set(n.stages.map(e=>e.id));if(e.size!==r.size||![...r].every(t=>e.has(t))||(a&&p)!==n.imagination)return!0;if(r.has(`research`)){let e=n.settings.research??{scope:`focused`,subject:``};if(s!==e.scope||s===`named`&&l.trim()!==e.subject)return!0}return!1},[n,r,a,p,s,l]);return(0,O.jsx)(`div`,{className:`doc`,children:(0,O.jsxs)(`div`,{className:`prose form`,children:[(0,O.jsxs)(`h1`,{children:[`The steps for `,e.name]}),n===null?e.proposal.note!==``&&(0,O.jsx)(`p`,{className:`lede`,children:e.proposal.note}):(0,O.jsx)(`p`,{className:`lede`,children:`Change what this work does. A step already under way stays where it is.`}),sn.map(e=>(0,O.jsxs)(`section`,{children:[(0,O.jsx)(`h2`,{children:e.head}),(0,O.jsx)(`ul`,{className:`choices`,children:He.filter(t=>t.group===e.id).map(e=>{let n=t.get(e.id),i=h.has(e.id);return(0,O.jsxs)(`li`,{className:n?.recommended?`is-recommended`:void 0,children:[(0,O.jsxs)(`label`,{children:[(0,O.jsx)(`input`,{type:`checkbox`,checked:r.has(e.id),disabled:i,onChange:()=>g(e.id)}),(0,O.jsxs)(`span`,{className:`choice-title`,children:[e.title,n?.recommended&&(0,O.jsx)(`span`,{className:`choice-flag`,children:`recommended`}),i&&(0,O.jsx)(`span`,{className:`choice-flag choice-locked`,children:`under way`})]})]}),(0,O.jsx)(`p`,{className:`choice-about`,children:e.about}),n?.why!==void 0&&n.why!==``&&(0,O.jsx)(`p`,{className:`choice-why`,children:n.why}),e.id===`research`&&r.has(e.id)&&(0,O.jsx)(`div`,{className:`extras`,children:(0,O.jsx)(Gt,{className:`extra`,label:`Scope`,options:cn,value:s,onPick:c,children:s===`named`&&(0,O.jsx)(`input`,{value:l,"aria-label":`What to research`,placeholder:`What to research`,onChange:e=>u(e.target.value)})})})]},e.id)})})]},e.id)),p&&(0,O.jsxs)(`section`,{children:[(0,O.jsx)(`h2`,{children:`Imagination mode`}),(0,O.jsxs)(`label`,{className:`choice-mode`,children:[(0,O.jsx)(`input`,{type:`checkbox`,checked:a,onChange:e=>o(e.target.checked)}),(0,O.jsxs)(`span`,{children:[`Imagine the ideal version first, as if anything were possible - trimming it back to what can be built comes after. Best while you are still deciding what this should be.`,m&&(0,O.jsx)(`span`,{className:`choice-flag`,children:`asked for at intake`})]})]})]}),(0,O.jsxs)(`section`,{children:[(0,O.jsx)(`h2`,{children:`Anything else`}),(0,O.jsx)(`textarea`,{className:`field-dump`,value:d,placeholder:`Anything the steps above do not cover.`,onChange:e=>f(e.target.value)})]}),e.failure!==null&&(0,O.jsx)(`p`,{className:`notice notice-failure`,children:e.failure}),(0,O.jsxs)(`div`,{className:`form-acts`,children:[e.onCancel!==null&&(0,O.jsx)(`button`,{type:`button`,onClick:e.onCancel,children:`Cancel`}),(0,O.jsx)(`button`,{type:`button`,onClick:()=>e.onAsk(d.trim()||`about the steps for this work`),children:`Ask the agent first`}),(0,O.jsx)(`button`,{type:`button`,className:`send`,disabled:e.sending||r.size===0||!_,onClick:()=>e.onConfirm({stages:[...r],imagination:a&&p,note:d,settings:{research:r.has(`research`)?{scope:s,subject:s===`named`?l.trim():``}:null}}),children:e.sending?n===null?`Confirming…`:`Updating…`:n===null?`Confirm ${r.size} ${r.size===1?`step`:`steps`}`:`Update protocol`})]})]})})}var dn={waiting:`○`,running:`◐`,done:`●`},fn=6e4;function pn(e){let{row:t}=e,n=(0,O.jsx)(`span`,{className:`board-mark`,"aria-hidden":`true`,children:dn[t.status]}),r=t.artifacts.length===1?t.artifacts[0]:null,i=t.artifacts.length>1;return(0,O.jsxs)(`li`,{className:`board-stage is-${t.status}`,children:[(0,O.jsxs)(`p`,{className:`board-stage-name`,children:[n,r!==null&&(0,O.jsx)(`button`,{type:`button`,title:`Open ${r}`,onClick:()=>e.onOpen(r),children:t.label}),i&&(0,O.jsxs)(`button`,{type:`button`,"aria-expanded":e.open,onClick:e.onFold,children:[t.label,(0,O.jsx)(`span`,{className:`board-chevron`,"aria-hidden":`true`,children:e.open?`▾`:`▸`})]}),r===null&&!i&&t.label]}),i&&e.open&&(0,O.jsx)(`ul`,{className:`board-artifacts`,children:t.artifacts.map(t=>(0,O.jsx)(`li`,{children:(0,O.jsx)(`button`,{type:`button`,onClick:()=>e.onOpen(t),children:t})},t))})]})}function mn(e){let{state:t}=e,n=t.awaiting.length>0,[r,i]=(0,C.useState)({}),a=e=>i(t=>({...t,[e]:!t[e]})),[o,s]=(0,C.useState)(()=>new Date),c=t.activity.said!==``;(0,C.useEffect)(()=>{if(!c)return;let e=setInterval(()=>s(new Date),fn);return()=>clearInterval(e)},[c]);let l=Je(t,o),u=t=>(0,O.jsx)(`ul`,{className:`board-list`,children:t.map(t=>(0,O.jsx)(pn,{row:t,onOpen:e.onOpen,open:r[t.id]===!0,onFold:()=>a(t.id)},t.id))});return(0,O.jsxs)(`section`,{className:`board`,children:[(0,O.jsxs)(`div`,{className:`board-head`,children:[(0,O.jsx)(`h2`,{className:`rail-head`,children:`Protocol`}),e.onAmend!==null&&t.protocol.length>0&&(0,O.jsx)(`button`,{type:`button`,className:`board-amend`,title:`Edit the protocol`,"aria-label":`Edit the protocol`,onClick:e.onAmend,children:(0,O.jsx)(h,{size:12})})]}),t.protocol.length===0?(0,O.jsx)(`p`,{className:`rail-fact muted`,children:n?`The steps are waiting for you.`:`No steps yet.`}):u(t.protocol.map(e=>({id:e.id,label:W(e.id)?.title??e.id,status:e.status,artifacts:e.artifacts}))),l!==null&&(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(`h2`,{className:`rail-head`,children:`Now`}),(0,O.jsxs)(`p`,{className:`board-now`,title:l.at,children:[(0,O.jsx)(`span`,{className:`pulse`,"aria-hidden":`true`}),l.said]})]}),t.phases.length>0&&(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(`h2`,{className:`rail-head`,children:`Execution`}),u(t.phases.map(e=>({id:e.id,label:e.title||e.id,status:e.status,artifacts:[]})))]}),t.reviews.length>0&&(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(`h2`,{className:`rail-head`,children:`Review`}),(0,O.jsx)(`ul`,{className:`board-list`,children:t.reviews.map(e=>(0,O.jsxs)(`li`,{className:`board-review`,children:[(0,O.jsxs)(`p`,{className:`board-stage-name`,children:[`round `,e.round,`: `,e.verdict]}),(0,O.jsxs)(`p`,{className:`rail-fact muted`,children:[e.findings,` `,e.findings===1?`finding`:`findings`,e.judgments>0?`, ${e.judgments} for you`:``]})]},e.round))})]})]})}function hn(e){let t=new Date(e);return Number.isNaN(t.getTime())?``:t.toLocaleString()}function gn(e){return(0,O.jsxs)(`section`,{children:[(0,O.jsx)(`h2`,{className:`rail-head`,children:`Needs you`}),(0,O.jsx)(`ul`,{className:`rail-awaiting`,children:e.awaiting.map(t=>(0,O.jsxs)(`li`,{children:[(0,O.jsx)(`button`,{type:`button`,className:`send`,onClick:()=>e.onAnswer(t.id),children:t.title}),t.file!==``&&(0,O.jsx)(`p`,{className:`rail-fact muted`,children:t.file})]},t.id))})]})}function _n(e){let[t,n]=(0,C.useState)(null),r=e.queue.length>0,i=Ne(e.queue).length;return(0,O.jsxs)(`section`,{className:`rail-annotations`,children:[(0,O.jsx)(`h2`,{className:`rail-head`,children:r?`Annotations (${e.queue.length})`:`Annotations`}),r&&(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(`ul`,{className:`queue`,children:e.queue.map(r=>(0,O.jsxs)(`li`,{className:`queued is-${r.kind}`,children:[(0,O.jsx)(`p`,{className:`queued-target`,children:je(r)}),r.kind===`remove`?(0,O.jsx)(`p`,{className:`queued-kind`,children:`Asking for this to be removed`}):t===r.id?(0,O.jsx)(`textarea`,{value:r.text,placeholder:`What about it?`,"aria-label":`Comment on ${je(r)}`,onChange:t=>e.onEdit(r.id,t.target.value)}):r.text===``?(0,O.jsx)(`p`,{className:`queued-empty`,children:`Nothing written yet - this one will not be sent`}):(0,O.jsx)(`p`,{className:`queued-text`,children:r.text}),(0,O.jsxs)(`div`,{className:`queued-acts`,children:[r.kind===`comment`&&(0,O.jsx)(`button`,{type:`button`,onClick:()=>n(t===r.id?null:r.id),children:t===r.id?`done`:`edit`}),(0,O.jsx)(`button`,{type:`button`,onClick:()=>e.onSendOne(r.id),disabled:e.sending,children:`send now`}),(0,O.jsx)(`button`,{type:`button`,onClick:()=>e.onDrop(r.id),children:`drop`})]})]},r.id))}),(0,O.jsx)(`button`,{type:`button`,className:`send`,onClick:e.onSendBatch,disabled:e.sending||i===0,children:e.sending?`Sending…`:`Send ${i===1?`it`:`them`} to the session`})]}),e.filed.length>0&&(0,O.jsx)(`ul`,{className:`filed`,children:e.filed.slice().reverse().map((t,n)=>(0,O.jsxs)(`li`,{children:[(0,O.jsxs)(`span`,{className:`filed-round`,children:[`round `,e.filed.length-n]}),(0,O.jsxs)(`span`,{className:`filed-count`,children:[t.comments.length,` `,t.comments.length===1?`note`:`notes`]}),(0,O.jsx)(`span`,{className:`filed-when`,children:hn(t.submittedAt)})]},t.submittedAt||String(n)))})]})}function vn(e){let t=e.queue.length>0,n=!t&&e.filed.length>0,r=(0,O.jsx)(_n,{...e});return(0,O.jsxs)(`aside`,{className:`rail`,"aria-label":`Status`,children:[e.spec!==null&&(0,O.jsxs)(`section`,{children:[(0,O.jsx)(`h2`,{className:`rail-head`,children:`Spec`}),(0,O.jsx)(`p`,{className:`rail-fact`,children:e.spec.name}),(0,O.jsxs)(`p`,{className:`rail-fact muted`,children:[e.spec.files,` `,e.spec.files===1?`artifact`:`artifacts`,e.spec.archived?` · archived`:``]}),(0,O.jsxs)(`p`,{className:`rail-fact muted`,children:[`last changed `,hn(e.spec.modified)]})]}),e.spec!==null&&(0,O.jsxs)(`section`,{children:[(0,O.jsx)(`h2`,{className:`rail-head`,children:`Actions`}),(0,O.jsxs)(`div`,{className:`rail-acts`,children:[(0,O.jsxs)(`button`,{type:`button`,className:`rail-act`,onClick:e.onContinue,children:[(0,O.jsx)(ee,{size:15}),`Continue`]}),e.executable&&(0,O.jsxs)(`button`,{type:`button`,className:`rail-act`,onClick:e.onExecute,children:[(0,O.jsx)(f,{size:15}),`Execute`]}),e.onQualityReview!==null&&(0,O.jsxs)(`button`,{type:`button`,className:`rail-act`,onClick:e.onQualityReview,children:[(0,O.jsx)(a,{size:15}),`Quality review`]}),!e.spec.archived&&(0,O.jsxs)(`button`,{type:`button`,className:`rail-act`,onClick:e.onArchive,children:[(0,O.jsx)(m,{size:15}),`Archive`]})]})]}),e.protocol!==null&&e.protocol.awaiting.length>0&&(0,O.jsx)(gn,{awaiting:e.protocol.awaiting,onAnswer:e.onAnswer}),t&&r,e.protocol!==null&&(0,O.jsx)(mn,{state:e.protocol,onOpen:e.onOpenArtifact,onAmend:e.onAmend}),n&&r,e.sent!==null&&(0,O.jsx)(`p`,{className:`rail-fact muted`,children:e.sent}),e.failure!==null&&(0,O.jsx)(`p`,{className:`notice notice-failure`,children:e.failure})]})}var yn={units:[],text:null,loading:!1,failure:null,from:null};function bn(e,t){return e?`${e}/${t.path}`:t.path}function xn(e,t){let[n,r]=(0,C.useState)(yn),i=(0,C.useRef)(null),a=(0,C.useCallback)((e,t)=>{let n=bn(e,t);if(i.current=n,!re(t.kind)){let e=E({path:t.path,kind:t.kind,fingerprint:t.hash??`${t.size}:${t.modified}`});r({units:e,text:null,loading:!1,failure:null,from:n});return}r(e=>({...e,loading:!0})),yt(n).then(e=>{if(i.current!==n)return;let a=E({path:t.path,kind:t.kind,text:e.text});r({units:a,text:e.text,loading:!1,failure:null,from:n})}).catch(e=>{i.current===n&&r({units:[],text:null,loading:!1,failure:e.message,from:n})})},[]);(0,C.useEffect)(()=>{if(!t){i.current=null,r(yn);return}a(e,t)},[e,t,a]),(0,C.useEffect)(()=>{if(!t)return;let n=bn(e,t);return ct(r=>{r.path===n&&a(e,t)})},[e,t,a]);let o=t?bn(e,t):null;return n.from===o?{units:n.units,text:n.text,loading:n.loading,failure:n.failure}:{units:[],text:null,loading:o!==null,failure:null}}function Sn(e){let[t,n]=(0,C.useState)({for:null,state:null}),[r,i]=(0,C.useState)(null),a=(0,C.useRef)(null),o=(0,C.useCallback)(()=>{if(e===null){a.current=null,n({for:null,state:null});return}a.current=e,Et(e).then(t=>{a.current===e&&(n({for:e,state:t}),i(null))}).catch(t=>{a.current===e&&i(t.message)})},[e]);return(0,C.useEffect)(o,[o]),(0,C.useEffect)(()=>{if(e!==null)return ct(t=>{t.entry===e&&o()})},[e,o]),{state:t.for===e?t.state:null,failure:r,refresh:o}}var Cn={openSpec:null,openArtifact:null,answering:null,intakeOpen:!1,draft:null,intake:null};function wn(){let[e,t]=(0,C.useState)(null),[n,r]=(0,C.useState)(null),[i,a]=(0,C.useState)(null),[o,s]=(0,C.useState)(null),[l,u]=(0,C.useState)(null),[d,f]=(0,C.useState)(null),[p,m]=(0,C.useState)(null),[h,g]=(0,C.useState)(null),[_,ee]=(0,C.useState)(null),[te,y]=(0,C.useState)(null),[b,x]=(0,C.useState)(!1),[S,w]=(0,C.useState)(null),[T,re]=(0,C.useState)(null),E=v({onSession:lt,askTheme:mt}),D=(0,C.useRef)(new Map),k=(0,C.useRef)(null),[se,ce]=(0,C.useState)(null),le=(0,C.useRef)(Cn),A=(0,C.useRef)(null),j=(0,C.useRef)(null);(0,C.useEffect)(()=>{st().then(e=>r(e.raw))},[]);let M=(0,C.useCallback)(()=>{gt().then(e=>{t(e),a(null)}).catch(e=>a(e.message))},[]);(0,C.useEffect)(M,[M]),(0,C.useEffect)(()=>ct(M),[M]);let ue=(0,C.useCallback)(e=>{u(e),m(null),f(null),X(!1),yt(!1),Bt(!1),w(null)},[]),de=(0,C.useRef)(null),N=(0,C.useCallback)(e=>{de.current=e,_t(e).then(t=>{de.current===e&&(f(t),s(null))}).catch(t=>{de.current===e&&s(t.message)})},[]);(0,C.useEffect)(()=>{l!==null&&N(l)},[l,N]);let[fe,pe]=(0,C.useState)([]),me=(0,C.useCallback)(e=>{wt(e).then(t=>{de.current===e&&pe(t.rounds)}).catch(()=>pe([]))},[]);(0,C.useEffect)(()=>{l===null?pe([]):me(l)},[l,me]);let he=d?.archived!==!0,ge=d!==null&&!d.archived,_e=ae(l,{get:bt,put:xt,empty:Ie,whenUnwritable:`Your marks are not being saved - the state file cannot be written.`,whenUnreadable:`This spec’s saved state could not be read, so nothing is being saved.`,persist:he}),ve=ae(ge?l:null,{get:St,put:Ct,empty:()=>[],whenUnwritable:`Your annotations are not being saved - the queue file cannot be written.`,whenUnreadable:`This spec’s queued annotations could not be read, so nothing is being saved.`}),ye=ve.reload;(0,C.useEffect)(()=>{if(l!==null)return ct(e=>{if(e.entry===l){if(e.path.endsWith(`/.specs/pending-annotations.json`)){ye();return}N(l),me(l)}})},[l,N,me,ye]);let P=(0,C.useMemo)(()=>d?.files??[],[d]);(0,C.useEffect)(()=>{P.length!==0&&(P.some(e=>e.path===p)||m(P[0].path))},[P,p]);let F=P.find(e=>e.path===p)??null,I=xn(l??``,F),be=(0,C.useMemo)(()=>{let e={};for(let t of I.units)e[t.id]=ne(t.hash,_e.value.units[t.id]);return e},[I.units,_e.value]);(0,C.useEffect)(()=>{_===null||F===null||I.units.length===0||(g(ie(I.units,F.path,_)?.id??null),ee(null))},[I.units,F,_]);let L=(0,C.useCallback)((e,t)=>{m(e),ee(t===``?null:t)},[]),xe=_e.update,Se=(0,C.useCallback)(e=>{xe(t=>{let n=t.units[e.id],r={...t.units};if(n?.readHash===e.hash){let{readHash:t,readAt:i,...a}=n;r[e.id]=a}else r[e.id]={...n,readHash:e.hash,readAt:new Date().toISOString()};return{...t,units:r}})},[xe]),Ce=(0,C.useCallback)(()=>g(null),[]),R=e?.entries.find(e=>e.path===l)??null,we=ve.value,Ee=ve.update,De=(0,C.useCallback)((e,t,n=``)=>{Ee(r=>[...r,Ae(e,t,n)],!0),w(null)},[Ee]),z=(0,C.useCallback)(async e=>{let t=await dt(e);return t.ok?!0:t.error===`no-session`?(re(e),!1):(w(`No agent was told: ${t.error}`),!1)},[]),Oe=(0,C.useCallback)(async e=>{if(!(l===null||Ne(e).length===0)){x(!0),w(null);try{let t=await Tt(l,Pe(e)),n=new Set(e.map(e=>e.id));Ee(e=>e.filter(e=>!n.has(e.id)),!0),me(l),await z({event:`annotations`,detail:Fe(e),path:t.path})||w(e=>e??`Round ${t.round} was filed. Nobody has been told yet.`)}catch(e){w(`That could not be filed: ${e.message}`)}finally{x(!1)}}},[l,z,me,Ee]),B=Sn(l),[V,H]=(0,C.useState)(null),[je,Me]=(0,C.useState)(0),[Le,U]=(0,C.useState)(null),[Re,ze]=(0,C.useState)(!1),[Be,He]=(0,C.useState)(!1),[Ue,W]=(0,C.useState)(null),[We,Ge]=(0,C.useState)(0);(0,C.useEffect)(()=>{le.current={openSpec:l,openArtifact:p,answering:V,intakeOpen:Be}},[l,p,V,Be]);let Ke=(0,C.useCallback)(e=>{if(k.current===e)return;let t=le.current,n=e===null?void 0:D.current.get(e);if(k.current===null&&n===void 0){k.current=e,ce(e),w(null);return}k.current!==null&&D.current.set(k.current,{...t,draft:A.current,intake:j.current}),k.current=e,ce(e);let r=n??Cn;le.current=r,A.current=r.draft,j.current=r.intake,u(r.openSpec),m(r.openArtifact),H(r.answering),He(r.intakeOpen),Ge(e=>e+1),X(!1),yt(!1),Bt(!1),w(null),W(null),r.openSpec!==t.openSpec&&(f(null),g(null),ee(null),y(null))},[]);(0,C.useEffect)(()=>lt(e=>Ke(e.sid)),[Ke]);let qe=B.state?.awaiting.length??0;(0,C.useEffect)(()=>{ft(qe)},[qe]),(0,C.useEffect)(()=>{if(l===null||V===null){U(null);return}let e=!0;return Dt(l,V).then(t=>{if(!e)return;U(t),W(null);let n=typeof t.file==`string`?t.file:``;n!==``&&L(n,``)}).catch(t=>{e&&W(t.message)}),()=>{e=!1}},[l,V,L]);let G=B.state?.awaiting.find(e=>e.id===V)??null,K=G?.kind??null,Je=Le===null?null:Le.payload??Le,q=Je===null?null:Te(Je),J=q?.kind===`decision`&&F!==null&&F.path===(G?.file??``)?ie(I.units,F.path,q.heading)?.id??null:null;(0,C.useEffect)(()=>{let e=B.state?.awaiting;V===null||e===void 0||e.some(e=>e.id===V)||H(null)},[V,B.state]);let Y=l===null||V===null?null:`${l}:${V}`,Ye=(0,C.useCallback)((e,t)=>{X(!1),K===`protocol`&&H(null),L(e,t)},[K,L]),Xe=(0,C.useCallback)(e=>{X(!1),K===`protocol`&&H(null),g(e)},[K]),[Ze,Qe]=(0,C.useState)(null),[$e,X]=(0,C.useState)(!1),et=(0,C.useMemo)(()=>{if(K===`protocol`&&Je!==null)return{proposal:Je,held:null};let e=B.state;return!$e||e===null||e.protocol.length===0?null:{proposal:{stages:[],note:``},held:{stages:e.protocol,imagination:e.modes.imagination,settings:e.stageSettings}}},[$e,K,Je,B.state]),tt=(0,C.useCallback)(e=>{if(Y===null||V===null)return Promise.resolve(!1);let t=G?.file??``;return z({event:`question`,detail:`${G?.title??V}: ${e}`,...t===``?{}:{path:`${l}/${t}`}}).then(t=>(t&&Qe({for:Y,said:e}),t))},[V,Y,G,l,z]),nt=(0,C.useCallback)(e=>{Y!==null&&(A.current={for:Y,...e})},[Y]),rt=(0,C.useCallback)(async e=>{if(!(l===null||V===null)){x(!0),W(null);try{let t=await jt(l,V,e);H(null),A.current=null,B.refresh(),await z({event:G?.kind===`gate`?`gate`:`answers`,detail:`${G?.title??V}: ${t.outcome}`,path:t.path})}catch(e){W(e.message)}finally{x(!1)}}},[V,G,l,B,z]),it=(0,C.useCallback)(e=>{j.current=e},[]),at=(0,C.useCallback)(e=>{if(e!==null&&e!==k.current){let t=D.current.get(e);if(t!==void 0){D.current.set(e,{...t,intakeOpen:!1,intake:null});return}}He(!1),j.current=null},[]),ot=(0,C.useCallback)(async e=>{let t=k.current;ze(!0),W(null);try{let n=await Ot(e);at(t),u(n.entry),m(n.path.slice(n.entry.length+1)),f(null),M(),await z({event:`brief`,detail:n.entry})}catch(e){W(e.message)}finally{ze(!1)}},[at,M,z]),Z=(0,C.useCallback)(async e=>{if(l===null)return null;x(!0),W(null);try{let{change:t}=await kt(l,e);if(H(null),X(!1),B.refresh(),t.amended&&!t.changed)return null;await z({event:t.amended?`amendment`:`answers`,detail:t.amended?`${R?.name??l}: ${t.said}`:`protocol confirmed - ${t.said}`,path:`${l}/README.md`})}catch(e){let t=e.message;return W(t),t}finally{x(!1)}return null},[l,B,z,R?.name]),pt=(0,C.useCallback)(()=>{R!==null&&(w(null),z({event:`brief`,detail:R.name}).then(e=>{e&&w(`An agent was asked to pick this spec up.`)}))},[z,R]),ht=(0,C.useMemo)(()=>he&&P.some(e=>e.path===`plan/PLAN.md`),[P,he]),[Q,yt]=(0,C.useState)(!1),[Et,Mt]=(0,C.useState)(!1),[Nt,Pt]=(0,C.useState)(null),It=(0,C.useCallback)(async e=>{if(!(l===null||R===null)){Mt(!0),Pt(null);try{await At(l,e),yt(!1),B.refresh(),w(null),await z({event:`execute`,detail:R.name})?w(`The run was started in the session beside this pane.`):w(e=>e??`The run is set up. Nobody has been told yet.`)}catch(e){Pt(e.message)}finally{Mt(!1)}}},[l,B,z,R]),Lt=(0,C.useCallback)(()=>{let e=B.state?.protocol??[];w(null),Z({stages:[...e.map(e=>e.id),Ve],imagination:null,note:``,settings:{research:null}}).then(e=>{e!==null&&w(`Quality review was not added: ${e}`)})},[Z,B.state]),Rt=(0,C.useMemo)(()=>{let e=B.state?.protocol??[];return he&&e.length>0&&!e.some(e=>e.id===`quality-review`)},[he,B.state]),[zt,Bt]=(0,C.useState)(!1),[Vt,Ht]=(0,C.useState)(!1),[Ut,Gt]=(0,C.useState)(null),Kt=(0,C.useCallback)(async()=>{if(l!==null){Ht(!0),Gt(null);try{let e=await vt(l);Bt(!1),f(null),m(e.path.slice(e.entry.length+1)),u(e.entry),w(`Signed off, and filed as ${e.entry}.`)}catch(e){Gt(e.message)}finally{Ht(!1)}}},[l]);if(n===null||e===null)return(0,O.jsx)(`p`,{className:`notice notice-failure`,children:i??`Waiting for the pane to hand over…`});let $=V===null||q===null||K===`protocol`?null:(0,O.jsx)(ke,{title:G?.title??V,ask:q,file:G?.file??``,onAnswer:e=>void rt(e),onAsk:tt,asked:Ze?.for===Y?Ze.said:null,onDismiss:()=>H(null),settled:F===null||!I.loading,summon:je,sending:b,failure:Ue,draft:A.current?.for===Y?A.current:null,onDraft:nt},Y);return(0,O.jsxs)(`div`,{className:l===null?`workspace is-alone`:`workspace`,children:[(0,O.jsx)(rn,{specs:e.entries,openSpec:l,spec:R,onOpenSpec:ue,onBack:()=>ue(null),artifacts:P,openArtifact:p,onOpenArtifact:e=>Ye(e,``),units:I.units,currentUnit:te,marks:be,onOpenUnit:Xe,onNewSpec:()=>{W(null),He(!0)}}),(0,O.jsxs)(`main`,{className:`stage`,"data-theme":E.theme,children:[(0,O.jsx)(c,{theme:E.theme,kept:E.kept,onToggle:E.toggle}),et===null?F===null?(0,O.jsxs)(`div`,{className:`doc`,children:[T!==null&&$!==null?null:(0,O.jsx)(`p`,{className:`notice`,children:o??(e.entries.length===0?`No work here yet. Start a piece with New spec.`:l===null?`Nothing is open. Pick a piece of work on the left.`:d===null?`Opening…`:`This spec holds nothing to read yet.`)}),$]}):(0,O.jsxs)(`div`,{className:`doc-and-ask`,children:[(0,O.jsx)(Wt,{reader:se??``,entry:l??``,file:F,units:I.units,text:I.text,marks:be,loading:I.loading,failure:I.failure,raw:n,onToggleRead:Se,landOn:h,onLanded:Ce,onCurrent:y,onOpen:L,onLeave:e=>void ut(e),onAnnotate:ge?De:null,under:J===null?null:{unit:J,node:$}}),J===null&&$]}):(0,O.jsx)(un,{name:R?.name??l??``,proposal:et.proposal,held:et.held,wish:B.state?.wish.imagination===!0,onConfirm:e=>void Z(e),onAsk:e=>void z({event:`question`,detail:`the steps: ${e}`}),onCancel:et.held===null?null:()=>X(!1),sending:b,failure:Ue},`${l}:${et.held===null?`propose:${et.proposal.offeredAt??``}`:`amend`}`)]}),l!==null&&(0,O.jsx)(vn,{spec:R,failure:_e.failure??ve.failure,queue:we,filed:fe,onEdit:(e,t)=>Ee(n=>n.map(n=>n.id===e?{...n,text:t}:n)),onDrop:e=>Ee(t=>t.filter(t=>t.id!==e),!0),onSendOne:e=>{let t=we.find(t=>t.id===e);t&&Oe([t])},onSendBatch:()=>void Oe(we),sending:b,sent:S,onContinue:pt,onExecute:()=>{Pt(null),yt(!0)},executable:ht,onQualityReview:Rt?Lt:null,onArchive:()=>{Gt(null),Bt(!0)},protocol:B.state,onOpenArtifact:e=>Ye(e,``),onAnswer:e=>{if(X(!1),e!==V){H(e);return}let t=G?.file??``;t!==``&&L(t,``),Me(e=>e+1)},onAmend:he?()=>{W(null),X(!0)}:null}),zt&&R!==null&&l!==null&&(0,O.jsx)(oe,{name:R.name,filed:Ft(l,new Date),state:B.state,onArchive:()=>void Kt(),onCancel:()=>Bt(!1),working:Vt,failure:Ut}),Q&&R!==null&&l!==null&&(0,O.jsx)(Qt,{name:R.name,slug:l.slice(l.lastIndexOf(`/`)+1),phases:B.state?.phases??[],recommended:B.state?.runRecommendations??null,decided:B.state?.runDecisions??null,onRun:e=>void It(e),onCancel:()=>yt(!1),working:Et,failure:Nt},l),Be&&(0,O.jsx)(tn,{onFile:ot,onCancel:()=>at(k.current),filing:Re,failure:Ue,draft:j.current,onDraft:it},We),T!==null&&(0,O.jsx)(Tn,{onCancel:()=>{re(null),w(`Nobody was told: there was no session in this window.`)},onConfirm:()=>{let e=T;re(null),dt({...e,create:!0}).then(e=>{w(e.ok?`A session was started, and it opens on this.`:`A session could not be started: ${e.error}`)})}})]})}function Tn({onCancel:e,onConfirm:t}){return(0,O.jsx)(`div`,{className:`dialog-shade`,children:(0,O.jsxs)(`div`,{className:`dialog`,role:`dialog`,"aria-modal":`true`,"aria-label":`No session is running`,children:[(0,O.jsx)(`div`,{className:`dialog-body`,children:(0,O.jsx)(`p`,{children:`No session is running in this window. Start one and let it pick this up?`})}),(0,O.jsxs)(`div`,{className:`dialog-acts`,children:[(0,O.jsx)(`button`,{type:`button`,onClick:e,children:`Not now`}),(0,O.jsx)(`button`,{type:`button`,className:`send`,onClick:t,children:`Start a session`})]})]})})}pt();var En=document.getElementById(`root`);En&&(0,w.createRoot)(En).render((0,O.jsx)(C.StrictMode,{children:(0,O.jsx)(wn,{})}));
|