@dendelion/paper-camp 0.26.0 → 0.27.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.
Files changed (34) hide show
  1. package/dist/app/assets/{index-DAhfAB9y.js → index-BEeox2IM.js} +2 -2
  2. package/dist/app/assets/{index-DAhfAB9y.js.map → index-BEeox2IM.js.map} +1 -1
  3. package/dist/app/assets/{index-X5ikcKAy.js → index-BW-jiFHN.js} +2 -2
  4. package/dist/app/assets/{index-X5ikcKAy.js.map → index-BW-jiFHN.js.map} +1 -1
  5. package/dist/app/assets/{index-DuhmLhzz.js → index-BhD5WS8p.js} +2 -2
  6. package/dist/app/assets/{index-DuhmLhzz.js.map → index-BhD5WS8p.js.map} +1 -1
  7. package/dist/app/assets/{index-HixYRYWW.js → index-C1zPjxRZ.js} +2 -2
  8. package/dist/app/assets/{index-HixYRYWW.js.map → index-C1zPjxRZ.js.map} +1 -1
  9. package/dist/app/assets/{index-sqaNs4DX.js → index-C2q1JS1i.js} +2 -2
  10. package/dist/app/assets/{index-sqaNs4DX.js.map → index-C2q1JS1i.js.map} +1 -1
  11. package/dist/app/assets/{index-CqDZ80wA.js → index-CHcj_gHq.js} +2 -2
  12. package/dist/app/assets/{index-CqDZ80wA.js.map → index-CHcj_gHq.js.map} +1 -1
  13. package/dist/app/assets/{index-DYGnWiFG.js → index-DN8Ti3Ov.js} +2 -2
  14. package/dist/app/assets/{index-DYGnWiFG.js.map → index-DN8Ti3Ov.js.map} +1 -1
  15. package/dist/app/assets/{index-VoRTCwB6.js → index-DX3JeGXT.js} +2 -2
  16. package/dist/app/assets/{index-VoRTCwB6.js.map → index-DX3JeGXT.js.map} +1 -1
  17. package/dist/app/assets/{main-Ceiva0Al.js → main-DCzV1FeH.js} +97 -97
  18. package/dist/app/assets/main-DCzV1FeH.js.map +1 -0
  19. package/dist/app/assets/{sidebar-section-CW3WaioH.js → sidebar-section-CFrPSdM0.js} +2 -2
  20. package/dist/app/assets/{sidebar-section-CW3WaioH.js.map → sidebar-section-CFrPSdM0.js.map} +1 -1
  21. package/dist/app/index.html +1 -1
  22. package/dist/chunks/{machine-registry.DF3kTKHr.js → phase-progress.DoB5EhtE.js} +276 -272
  23. package/dist/chunks/phase-progress.DoB5EhtE.js.map +1 -0
  24. package/dist/cli/index.js +3096 -3071
  25. package/dist/cli/index.js.map +1 -1
  26. package/dist/core/index.js +1 -1
  27. package/dist/core/runtime-reachability.d.ts +6 -0
  28. package/dist/core/runtime-reachability.d.ts.map +1 -0
  29. package/dist/core/runtime-reachability.test.d.ts +2 -0
  30. package/dist/core/runtime-reachability.test.d.ts.map +1 -0
  31. package/dist/core/scaffold/scaffold.d.ts.map +1 -1
  32. package/package.json +1 -1
  33. package/dist/app/assets/main-Ceiva0Al.js.map +0 -1
  34. package/dist/chunks/machine-registry.DF3kTKHr.js.map +0 -1
@@ -1,2 +1,2 @@
1
- import{c as se,r as h,C as U,j as e,e as T,g as q,R as E,J as C,w as A,h as de,k as _,s as L,l as me,m as he,D as R,n as pe,o as V,q as ue,u as O,t as te,$ as xe,v as ge,a as ae,A as G,x as Y,y as je,z as fe,i as D,B as ne,E as le,F as ve,G as be,H as J,I as ye,K as ke,L as ie,P as Se,p as F}from"./main-Ceiva0Al.js";import{S as $}from"./sidebar-section-CW3WaioH.js";const Ne=async()=>{try{const s=await fetch(se("/api/merge-policy"));return s.ok?await s.json():null}catch{return null}},Ce=async()=>{try{const s=await fetch(se("/api/merge-policy/apply"),{method:"POST"});return s.ok?await s.json():null}catch{return null}},W=["phase","planDraft","ideaExtend","commitSuggest","feedback","codeReview","deskDiscovery"],we={phase:"Phase run",planDraft:"Plan draft",ideaExtend:"Idea extend",commitSuggest:"Commit suggest",feedback:"Scout chat",codeReview:"Code review",deskDiscovery:"Desk discovery"},Ae={ok:{fill:"rgba(143, 185, 150, 0.25)",text:"#5E8A66",label:"Ready"},warn:{fill:"rgba(212, 163, 115, 0.25)",text:"#A67B4F",label:"Needs attention"},missing:{fill:"rgba(201, 139, 139, 0.25)",text:"#6E3A3A",label:"Missing"}},B={upToDate:{fill:"rgba(143, 185, 150, 0.25)",text:"#5E8A66"},outdated:{fill:"rgba(212, 163, 115, 0.25)",text:"#A67B4F"}},De="rgba(143, 185, 150, 0.25)",oe={allowSquashMerge:!0,allowMergeCommit:!1,allowRebaseMerge:!1,squashMergeCommitTitle:"PR_TITLE",squashMergeCommitMessage:"PR_BODY"},H=[{key:"allowSquashMerge",label:"Allow squash merge"},{key:"allowMergeCommit",label:"Allow merge commit"},{key:"allowRebaseMerge",label:"Allow rebase merge"},{key:"squashMergeCommitTitle",label:"Squash commit title"},{key:"squashMergeCommitMessage",label:"Squash commit message"}];function K(s){return typeof s=="boolean"?s?"Yes":"No":s}function Ie(s){return H.every(t=>s[t.key]===oe[t.key])}const Re=({label:s,current:t,recommended:n,isLast:i})=>{const l=t===n;return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center gap-3 pb-2 pt-2",children:[e.jsx("span",{className:"flex-1",children:s}),e.jsx("span",{className:l?"opacity-[0.65] font-normal":"font-semibold",children:K(t)}),!l&&e.jsxs("span",{className:"opacity-[0.45]",children:["→ ",K(n)]})]}),!i&&e.jsx(A,{})]})},ze=()=>{const[s,t]=h.useState(void 0),[n,i]=h.useState(!1),{toast:l}=U();h.useEffect(()=>{Ne().then(t)},[]);const o=async()=>{i(!0);const c=await Ce();i(!1),(c==null?void 0:c.status)==="ok"?(t(c),l({title:"Merge policy applied",variant:"success"})):l({title:"Failed to apply merge policy",description:(c==null?void 0:c.status)==="unavailable"?c.reason:void 0,variant:"error"})},r=(s==null?void 0:s.status)==="ok"&&Ie(s.policy);return e.jsxs("div",{children:[e.jsxs("div",{className:"mb-6",children:[e.jsx("h2",{className:"m-0",children:"Merge Policy"}),e.jsx("p",{className:"opacity-50 mt-1",children:"Paper Camp's canonical policy: squash-only merges, with the commit title and body taken from the PR."})]}),s===void 0&&e.jsx("p",{children:"Loading…"}),s===null&&e.jsx(T,{variant:"warning",children:"Failed to load merge policy."}),(s==null?void 0:s.status)==="unavailable"&&e.jsx(T,{variant:"warning",children:s.reason}),(s==null?void 0:s.status)==="ok"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center gap-3 mb-3",children:[e.jsx("span",{className:"font-medium",children:s.repo}),e.jsx(q,{size:"small",fillColor:r?B.upToDate.fill:B.outdated.fill,textColor:r?B.upToDate.text:B.outdated.text,children:r?"Matches recommended policy":"Differs from recommended policy"})]}),e.jsx(E,{size:"small",texture:"kraft",children:H.map((c,m)=>e.jsx(Re,{label:c.label,current:s.policy[c.key],recommended:oe[c.key],isLast:m===H.length-1},c.key))}),e.jsx("div",{className:"mt-4",children:e.jsx(C,{size:"small",onClick:o,disabled:n||r,children:n?"Applying…":"Apply recommended policy"})})]})]})},X={repo:""},Pe=s=>s.name.trim()!==""&&s.cmd.trim()!=="",Ee=s=>s.name.trim()!==""&&s.cmd.trim()!=="",Q=({id:s,...t})=>t;function Z(s,t){const n=new Set,i=t.map(o=>{const r=o.cmd?s.find(j=>!n.has(j.id)&&j.cmd===o.cmd):void 0;if(!r)return{...o,id:crypto.randomUUID()};n.add(r.id);const{id:c,...m}=r;return JSON.stringify(m)===JSON.stringify(o)?r:{...o,id:c}}),l=s.filter(o=>!n.has(o.id)&&(o.name.trim()===""||o.cmd.trim()===""));return[...i,...l]}const Le=()=>{const[s,t]=h.useState(void 0),[n,i]=h.useState([]),[l,o]=h.useState([]),[r,c]=h.useState(X),{toast:m}=U(),j=de(),v=h.useCallback(a=>{var x;t(a),i(d=>{var u;return Z(d,((u=a==null?void 0:a.desk)==null?void 0:u.services)??[])}),o(d=>{var u;return Z(d,((u=a==null?void 0:a.desk)==null?void 0:u.checks)??[])}),c(((x=a==null?void 0:a.desk)==null?void 0:x.ci)??X)},[]);h.useEffect(()=>{_().then(v)},[v]);const f=h.useCallback(async()=>{const a=await _();v(a)},[v]),k=async(a,x,d)=>{const u=a.filter(Pe).map(Q),I=x.filter(Ee).map(Q),z=d.repo.trim()?d:void 0,P={services:u.length?u:void 0,checks:I.length?I:void 0,ci:z},{ok:M,error:ce}=await L({desk:P});if(M){await j.reloadCurrent();const re=await _();v(re),m({title:"Saved",variant:"success"})}else m({title:"Failed to save",description:ce,variant:"error"})},w=()=>i(a=>[...a,{id:crypto.randomUUID(),name:"",cmd:""}]),b=(a,x)=>{const d=n.map(u=>u.id===a?{...x,id:a}:u);i(d),k(d,l,r)},g=a=>{const x=n.filter(d=>d.id!==a);i(x),k(x,l,r)},y=()=>o(a=>[...a,{id:crypto.randomUUID(),name:"",cmd:""}]),S=(a,x)=>{const d=l.map(u=>u.id===a?{...x,id:a}:u);o(d),k(n,d,r)},p=a=>{const x=l.filter(d=>d.id!==a);o(x),k(n,x,r)},N=a=>{c(a),k(n,l,a)};return{config:s,services:n,checks:l,ci:r,proposal:j.proposal,diff:j.diff,discovering:j.discovering,addService:w,updateService:b,removeService:g,addCheck:y,updateCheck:S,removeCheck:p,updateCi:N,startDiscovery:j.startDiscovery,cancelProposal:j.cancelProposal,applyProposal:async a=>{await j.applyProposal(a),await f()}}},Te=()=>{const s=h.useRef(null),[t,n]=h.useState(void 0),{iconDataUri:i,loading:l}=me(),[o,r]=h.useState(null),c=o??i,[m,j]=h.useState(!1),[v,f]=h.useState(""),[k,w]=h.useState(""),{toast:b}=U();return h.useEffect(()=>{_().then(a=>{n(a),(a==null?void 0:a.port)!==void 0&&f(String(a.port)),(a==null?void 0:a.projectName)!==void 0&&w(a.projectName)})},[]),{fileRef:s,config:t,identityLoading:l,iconDataUri:c,uploading:m,portInput:v,setPortInput:f,nameInput:k,setNameInput:w,handleSaveAgentConfig:async(a,x)=>{const d=t==null?void 0:t.defaultAgents,u={phase:(d==null?void 0:d.phase)??R.phase,planDraft:(d==null?void 0:d.planDraft)??R.planDraft,ideaExtend:(d==null?void 0:d.ideaExtend)??R.ideaExtend,commitSuggest:(d==null?void 0:d.commitSuggest)??R.commitSuggest,feedback:(d==null?void 0:d.feedback)??R.feedback,codeReview:(d==null?void 0:d.codeReview)??R.codeReview,deskDiscovery:(d==null?void 0:d.deskDiscovery)??R.deskDiscovery,[a]:x};if(a==="codeReview"&&pe(x,u.phase)){b({title:"Failed to save",description:"Code review must use a different model than Phase run.",variant:"error"});return}const{ok:I,error:z}=await L({defaultAgents:u});I?(n(P=>P&&{...P,defaultAgents:u}),b({title:"Saved",variant:"success"})):b({title:"Failed to save",description:z,variant:"error"})},handleSavePort:async()=>{const a=Number(v);if(!t||!Number.isInteger(a)||a<=0||a===t.port)return;const{ok:x,error:d}=await L({port:a});x?(n(u=>u&&{...u,port:a}),b({title:"Saved",description:"Restart `paper-camp dev` to apply the new port.",variant:"success"})):b({title:"Failed to save",description:d,variant:"error"})},handleToggleIntegration:async()=>{var I,z,P;if(!t)return;const a=!(((z=(I=t.integration)==null?void 0:I.toolbar)==null?void 0:z.enabled)??!0),x={...t.integration,toolbar:{...(P=t.integration)==null?void 0:P.toolbar,enabled:a}},{ok:d,error:u}=await L({integration:x});d?(n(M=>M&&{...M,integration:x}),b({title:"Saved",variant:"success"})):b({title:"Failed to save",description:u,variant:"error"})},handleSaveName:async()=>{const a=k.trim();if(!t||!a||a===t.projectName)return;const{ok:x,error:d}=await L({projectName:a});x?(n(u=>u&&{...u,projectName:a}),w(a),b({title:"Saved",variant:"success"})):b({title:"Failed to save",description:d,variant:"error"})},handleFile:async a=>{var u;const x=(u=a.target.files)==null?void 0:u[0];if(!x)return;j(!0);const d=new FileReader;d.onloadend=async()=>{const I=d.result,z=await he(I);j(!1),z?(r(I),b({title:"Saved",variant:"success"})):b({title:"Failed to save",variant:"error"})},d.readAsDataURL(x)}}},Me=()=>{const[s,t]=h.useState(null),[n,i]=h.useState(!1),[l,o]=h.useState(null),[r,c]=h.useState(null),[m,j]=h.useState(!1),{toast:v}=U(),f=h.useCallback(p=>{if(p===null){i(!0);return}i(!1),t(p)},[]);h.useEffect(()=>{V().then(f),_().then(p=>j((p==null?void 0:p.setupDismissed)??!1))},[f]);const k=async p=>{o(p),f(await V()),o(null)},w=async p=>{c(p);const N=await ue(p);N?t(a=>(a==null?void 0:a.map(x=>x.id===p?N:x))??a):v({title:"Failed to connect",variant:"error"}),c(null)},b=async()=>{const p=!m,{ok:N}=await L({setupDismissed:p});N?(j(p),v({title:"Saved",variant:"success"})):v({title:"Failed to save",variant:"error"})},g=(s==null?void 0:s.every(p=>p.status==="ok"))??!0,y=(s==null?void 0:s.filter(p=>p.kind==="external"))??[],S=(s==null?void 0:s.filter(p=>p.kind==="local"))??[];return{connections:s,loadFailed:n,reloadingId:l,connectingId:r,setupDismissed:m,handleRecheck:k,handleConnect:w,handleDismissToggle:b,allOk:g,externalConnections:y,localConnections:S}},Fe=2e3,_e=s=>{const t=O(m=>m.loginRelay),n=O(m=>m.startLoginRelay),i=O(m=>m.loadLoginRelayStatus),l=O(m=>m.cancelLoginRelay),{toast:o}=U(),r=h.useRef(null),c=t==null?void 0:t.phase;return h.useEffect(()=>{if(c!=="starting"&&c!=="awaiting-authorization")return;const m=window.setInterval(()=>i(),Fe);return()=>window.clearInterval(m)},[c,i]),h.useEffect(()=>{const m=t==null?void 0:t.authorizeUrl;c!=="awaiting-authorization"||!m||r.current===m||(r.current=m,window.open(m,"_blank","noopener,noreferrer"))},[c,t==null?void 0:t.authorizeUrl]),h.useEffect(()=>{c==="success"?(o({title:"Signed in",variant:"success"}),s()):c==="error"&&o({title:"Sign-in failed",description:t==null?void 0:t.error,variant:"error"})},[c]),{phase:c,authorizeUrl:t==null?void 0:t.authorizeUrl,startLoginRelay:n,cancelLoginRelay:l}},Ue=({connection:s,onConnect:t,connecting:n})=>{const{connect:i}=s;return i?i.kind==="command"&&i.runnable?e.jsx(C,{size:"small",onClick:()=>t(s.id),disabled:n,children:n?"Running…":`Run \`${i.command}\``}):i.kind==="command"?e.jsx("div",{className:"mt-2",children:e.jsx(te,{code:i.command})}):i.kind==="link"?e.jsx(C,{size:"small",onClick:()=>window.open(i.url,"_blank","noopener,noreferrer"),children:i.label}):e.jsx("p",{className:"opacity-[0.65] text-sm mt-2 mx-0 mb-0",children:i.message}):null},Oe=["claude auth login","claude setup-token"],Be=()=>e.jsxs("div",{className:"mt-2 flex flex-col gap-2",children:[e.jsx("p",{className:"opacity-[0.65] text-sm m-0",children:"The in-app relay couldn't complete. Run one of these in a terminal instead:"}),Oe.map(s=>e.jsx(te,{code:s},s)),e.jsxs("p",{className:"opacity-50 text-sm m-0",children:["Alternatively, set ",e.jsx("code",{children:"ANTHROPIC_API_KEY"})," in the server's environment — that bills as API usage rather than your Max subscription, so treat it as a fallback, not the default."]})]}),qe=({onSignedIn:s})=>{const{phase:t,authorizeUrl:n,startLoginRelay:i,cancelLoginRelay:l}=_e(s);return t==="starting"?e.jsx(C,{size:"small",disabled:!0,children:"Starting…"}):t==="awaiting-authorization"?e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(C,{size:"small",onClick:()=>n&&window.open(n,"_blank","noopener,noreferrer"),children:"Reopen sign-in tab"}),e.jsx(C,{size:"small",onClick:()=>l(),children:"Cancel"})]}):e.jsxs("div",{children:[e.jsx(C,{size:"small",onClick:()=>i(),children:"Sign in"}),t==="error"&&e.jsx(Be,{})]})},Ge="agent:claude-code",ee=({connection:s,isLast:t,onRecheck:n,rechecking:i,onConnect:l,connecting:o})=>{const r=Ae[s.status];return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"pb-3 pt-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:"flex-1 font-medium",children:s.label}),s.authenticated===!1&&e.jsx(xe,{content:"Installed, but not signed in",children:e.jsx(q,{size:"small",variant:"warning",children:"Not signed in"})}),e.jsx(q,{size:"small",fillColor:r.fill,textColor:r.text,children:r.label}),e.jsx(C,{size:"small",onClick:()=>n(s.id),disabled:i,children:i?"Checking…":"Recheck"})]}),e.jsxs("p",{className:"opacity-[0.65] text-sm mt-1 mx-0 mb-0",children:["Unlocks: ",s.unlocks]}),e.jsx("p",{className:"opacity-50 text-sm mt-1 mx-0 mb-0",children:s.detail}),e.jsx("div",{className:"mt-2",children:s.id===Ge&&s.authenticated===!1?e.jsx(qe,{onSignedIn:()=>n(s.id)}):e.jsx(Ue,{connection:s,onConnect:l,connecting:o})})]}),!t&&e.jsx(A,{})]})},Ye=()=>{const{connections:s,loadFailed:t,reloadingId:n,connectingId:i,setupDismissed:l,handleRecheck:o,handleConnect:r,handleDismissToggle:c,allOk:m,externalConnections:j,localConnections:v}=Me();return e.jsxs("div",{children:[e.jsx("div",{className:"mb-6",children:e.jsx("h2",{className:"m-0",children:"Setup"})}),s===null&&!t&&e.jsx("p",{children:"Loading…"}),t&&e.jsx("div",{className:"mb-4",children:e.jsx(T,{variant:"warning",children:"Failed to load connections. Try refreshing."})}),s&&e.jsxs(e.Fragment,{children:[!m&&e.jsx("div",{className:"mb-4",children:e.jsx(T,{variant:"warning",children:"Some connections are incomplete — features that depend on them stay disabled until fixed. Run the connect command below, then recheck."})}),j.length>0&&e.jsxs("div",{className:"mb-4",children:[e.jsx("p",{className:"opacity-[0.45] text-sm mt-0 mb-2",children:"External services — reached on your behalf with their own remote credential."}),e.jsx(E,{size:"small",texture:"kraft",children:j.map((f,k)=>e.jsx(ee,{connection:f,isLast:k===j.length-1,onRecheck:o,rechecking:n===f.id,onConnect:r,connecting:i===f.id},f.id))})]}),v.length>0&&e.jsxs("div",{className:"mb-4",children:[e.jsx("p",{className:"opacity-[0.45] text-sm mt-0 mb-2",children:"Local adapters — driven on this machine with their own local session."}),e.jsx(E,{size:"small",texture:"kraft",children:v.map((f,k)=>e.jsx(ee,{connection:f,isLast:k===v.length-1,onRecheck:o,rechecking:n===f.id,onConnect:r,connecting:i===f.id},f.id))})]}),e.jsx("div",{className:"mt-4",children:e.jsx(C,{size:"small",onClick:c,children:l?"Show Setup on open again":"Don't show Setup on open"})})]})]})},$e=()=>{const{subjects:s,loading:t,available:n}=ge(),i=ae();return e.jsxs("div",{children:[e.jsxs("div",{className:"mb-6",children:[e.jsx("h2",{className:"m-0",children:"Subjects"}),e.jsx("p",{className:"opacity-50 mt-1",children:"Subjects are the roadmap's bets and standing concerns. Edit the vocabulary on the Roadmap page."})]}),t&&e.jsx("p",{children:"Loading…"}),!t&&!n&&e.jsx("p",{className:"opacity-60 m-0",children:"Couldn't load subjects — check the server config."}),!t&&n&&e.jsxs(E,{size:"small",texture:"kraft",children:[s.length===0&&e.jsx("p",{className:"opacity-[0.45] m-0 pb-2",children:"No subjects yet."}),s.map((l,o)=>e.jsxs("div",{children:[e.jsx("div",{className:"pb-2 pt-2",children:l}),o<s.length-1&&e.jsx(A,{})]},l)),s.length>0&&e.jsx(A,{}),e.jsx("div",{className:"pt-3",children:e.jsx(C,{size:"small",onClick:()=>i({to:"/roadmap"}),children:"Go to Roadmap"})})]})]})},He=140,Ve=160,Je=110,We=({taskKey:s,agentConfig:t,isLast:n,onSave:i,authorConfig:l})=>{const o=G[t.agent]??G["claude-code"],r=l&&l.agent===t.agent?l.model??"":void 0,c=Array.isArray(o.model)?o.model.filter(g=>g!==r):o.model,m=o.effort,[j,v]=h.useState(t.model??"");h.useEffect(()=>{v(t.model??"")},[t.model]);const f=g=>{var N;const y=g,S=G[y],p={agent:y};t.model&&(S.model===null||(N=S.model)!=null&&N.includes(t.model))&&(p.model=t.model),t.effort&&Array.isArray(S.effort)&&(p.effort=t.effort),i(s,p)},k=g=>{i(s,{...t,model:g||void 0})},w=()=>{i(s,{...t,model:j||void 0})},b=g=>{i(s,{...t,effort:g||void 0})};return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center gap-3 pb-2 pt-2",children:[e.jsx("span",{className:"w-[110px] shrink-0 text-sm opacity-[0.65]",children:we[s]}),e.jsx(Y,{size:"small",width:He,value:t.agent,onChange:f,options:je.map(g=>({value:g,label:fe[g]}))}),Array.isArray(c)?e.jsx(Y,{size:"small",width:Ve,value:t.model??"",onChange:k,options:[...r===""?[]:[{value:"",label:"Default"}],...c.map(g=>({value:g,label:g}))]}):c===null?e.jsx(D,{size:"small",className:"w-[160px]",value:j,placeholder:"Default model",onChange:g=>v(g.target.value),onBlur:w}):null,e.jsx("div",{className:Array.isArray(m)?"visible":"invisible",children:e.jsx(Y,{size:"small",width:Je,value:t.effort??"",onChange:b,options:[{value:"",label:"Default"},...(Array.isArray(m)?m:[]).map(g=>({value:g,label:g}))]})})]}),!n&&e.jsx(A,{})]})},Ke=()=>e.jsxs("div",{className:"flex items-center gap-3 pb-1",children:[e.jsx("span",{className:"w-[110px] shrink-0 text-sm opacity-[0.45]",children:"Task"}),e.jsx("span",{className:"w-[140px] shrink-0 text-sm opacity-[0.45]",children:"Agent"}),e.jsx("span",{className:"w-[160px] shrink-0 text-sm opacity-[0.45]",children:"Model"}),e.jsx("span",{className:"w-[110px] shrink-0 text-sm opacity-[0.45]",children:"Effort"})]}),Xe=({check:s,onSave:t,onRemove:n,isLast:i})=>{const[l,o]=h.useState(s);h.useEffect(()=>o(s),[s]);const r=()=>{l.name===s.name&&l.cmd===s.cmd||t(l)};return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-end gap-3 pb-2 pt-2",children:[e.jsx(D,{size:"small",label:"Name",value:l.name,onChange:c=>o({...l,name:c.target.value}),onBlur:r}),e.jsx(D,{size:"small",label:"Command",value:l.cmd,onChange:c=>o({...l,cmd:c.target.value}),onBlur:r}),e.jsx(ne,{icon:e.jsx(le,{size:16}),variant:"danger",size:"small",onClick:n,label:`Remove ${s.name||"check"}`})]}),!i&&e.jsx(A,{})]})},Qe=({ci:s,onSave:t})=>{const[n,i]=h.useState(s);h.useEffect(()=>i(s),[s]);const l=()=>{n.repo===s.repo&&(n.branch??"")===(s.branch??"")&&(n.releasePlease??!1)===(s.releasePlease??!1)||t(n)};return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-end gap-3 pb-3",children:[e.jsx(D,{size:"small",label:"Repo (owner/name)",value:n.repo,onChange:o=>i({...n,repo:o.target.value}),onBlur:l}),e.jsx(D,{size:"small",label:"Branch",value:n.branch??"",onChange:o=>i({...n,branch:o.target.value||void 0}),onBlur:l})]}),e.jsx(A,{}),e.jsxs("div",{className:"flex items-center justify-between pt-3",children:[e.jsx("span",{children:"Release Please"}),e.jsx(ve,{checked:n.releasePlease??!1,onChange:o=>{const r={...n,releasePlease:o.target.checked};i(r),t(r)}})]})]})},Ze=({service:s,onSave:t,onRemove:n,isLast:i})=>{const[l,o]=h.useState(s);h.useEffect(()=>o(s),[s]);const r=()=>{l.name===s.name&&l.cmd===s.cmd&&(l.port??void 0)===(s.port??void 0)&&(l.healthcheck??void 0)===(s.healthcheck??void 0)||t(l)};return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-end gap-3 pb-2 pt-2",children:[e.jsx(D,{size:"small",label:"Name",value:l.name,onChange:c=>o({...l,name:c.target.value}),onBlur:r}),e.jsx(D,{size:"small",label:"Command",value:l.cmd,onChange:c=>o({...l,cmd:c.target.value}),onBlur:r}),e.jsx(D,{size:"small",type:"number",label:"Port",className:"w-[100px]",value:l.port??"",onChange:c=>o({...l,port:c.target.value?Number(c.target.value):void 0}),onBlur:r}),e.jsx(D,{size:"small",label:"Healthcheck URL",value:l.healthcheck??"",onChange:c=>o({...l,healthcheck:c.target.value||void 0}),onBlur:r}),e.jsx(ne,{icon:e.jsx(le,{size:16}),variant:"danger",size:"small",onClick:n,label:`Remove ${s.name||"service"}`})]}),!i&&e.jsx(A,{})]})},es=()=>{const{config:s,services:t,checks:n,ci:i,proposal:l,diff:o,discovering:r,addService:c,updateService:m,removeService:j,addCheck:v,updateCheck:f,removeCheck:k,updateCi:w,startDiscovery:b,cancelProposal:g,applyProposal:y}=Le();return e.jsxs("div",{children:[e.jsxs("div",{className:"mb-6 flex items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"m-0",children:"Desk"}),e.jsx("p",{className:"opacity-50 mt-1",children:"Services, checks, and CI/release sources for this project's Stack panel."})]}),s&&e.jsx(C,{size:"small",onClick:b,disabled:r,children:r?e.jsxs(e.Fragment,{children:[e.jsx(be,{size:"small",label:"Discovering"})," Discovering…"]}):s.desk?"Re-scan with discovery":"Discover from project"})]}),s===void 0&&e.jsx("p",{children:"Loading…"}),s===null&&e.jsxs(T,{variant:"warning",children:["No papercamp/config.json found — run ",e.jsx("code",{children:"paper-camp init"})," in this directory first."]}),s&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"mb-6",children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsx("h3",{className:"m-0",children:"Services"}),e.jsx(C,{size:"small",icon:e.jsx(J,{size:16}),onClick:c,children:"Add service"})]}),e.jsxs(E,{size:"small",texture:"kraft",children:[t.length===0&&e.jsx("p",{className:"opacity-[0.45] m-0 pb-2",children:"No services yet."}),t.map((S,p)=>e.jsx(Ze,{service:S,onSave:N=>m(S.id,N),onRemove:()=>j(S.id),isLast:p===t.length-1},S.id))]})]}),e.jsxs("div",{className:"mb-6",children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsx("h3",{className:"m-0",children:"Checks"}),e.jsx(C,{size:"small",icon:e.jsx(J,{size:16}),onClick:v,children:"Add check"})]}),e.jsxs(E,{size:"small",texture:"kraft",children:[n.length===0&&e.jsx("p",{className:"opacity-[0.45] m-0 pb-2",children:"No checks yet."}),n.map((S,p)=>e.jsx(Xe,{check:S,onSave:N=>f(S.id,N),onRemove:()=>k(S.id),isLast:p===n.length-1},S.id))]})]}),e.jsxs("div",{children:[e.jsx("h3",{className:"m-0 mb-3",children:"CI"}),e.jsx(E,{size:"small",texture:"kraft",children:e.jsx(Qe,{ci:i,onSave:w})})]}),l&&o&&e.jsx(ye,{current:s.desk,proposal:l,diff:o,onApply:y,onCancel:g})]})]})},ss=()=>{var b,g;const{fileRef:s,config:t,identityLoading:n,iconDataUri:i,uploading:l,portInput:o,setPortInput:r,nameInput:c,setNameInput:m,handleSaveAgentConfig:j,handleSavePort:v,handleToggleIntegration:f,handleSaveName:k,handleFile:w}=Te();return e.jsxs("div",{children:[e.jsx("div",{className:"mb-6",children:e.jsx("h2",{className:"m-0",children:"Project Info"})}),t===void 0&&e.jsx("p",{children:"Loading…"}),t===null&&e.jsxs(T,{variant:"warning",children:["No papercamp/config.json found — run ",e.jsx("code",{children:"paper-camp init"})," in this directory first."]}),t&&e.jsxs(E,{size:"small",texture:"kraft",children:[e.jsxs("div",{className:"flex items-end gap-3 pb-3",children:[e.jsx(D,{value:c,onChange:y=>m(y.target.value),onBlur:k,label:"Project Name"}),e.jsxs(q,{size:"small",fillColor:De,textColor:ke.accentGreenDark,children:["v",t.version]})]}),e.jsx(A,{}),e.jsxs("div",{className:"flex items-center gap-3 pb-3 pt-3",children:[i&&e.jsx("img",{src:i,alt:"Project icon",className:"w-10 h-10 object-contain shrink-0 rounded"}),e.jsxs("div",{children:[e.jsx("input",{ref:s,type:"file",accept:".svg,.png,.jpg,.jpeg,.gif,.webp",onChange:w,className:"hidden"}),e.jsx(C,{size:"small",onClick:()=>{var y;return(y=s.current)==null?void 0:y.click()},disabled:l,children:l?"Uploading…":"Choose File"}),n&&e.jsx("p",{className:"text-sm opacity-50 mt-1 mx-0 mb-0",children:"Loading…"}),!n&&!i&&!l&&e.jsx("p",{className:"text-sm opacity-[0.45] mt-1 mx-0 mb-0",children:"No icon set."})]})]}),e.jsx(A,{}),e.jsx("div",{className:"flex items-end gap-3 pb-3 pt-3",children:e.jsx(D,{type:"number",value:o,onChange:y=>r(y.target.value),onBlur:v,label:"Port",helperText:"Default for `paper-camp dev`. Restart the server to apply a change."})}),e.jsx(A,{}),e.jsxs("div",{className:"flex items-center justify-between gap-3 pb-3 pt-3",children:[e.jsxs("div",{children:[e.jsx("p",{className:"m-0",children:"In-app dev toolbar"}),e.jsx("p",{className:"opacity-[0.45] text-sm mt-1 mx-0 mb-0",children:"Inject the paper-camp toolbar into this project's dev server via the Vite plugin."})]}),e.jsx(C,{size:"small",onClick:f,children:((g=(b=t.integration)==null?void 0:b.toolbar)==null?void 0:g.enabled)??!0?"Disable":"Enable"})]}),e.jsx(A,{}),e.jsx(Ke,{}),W.map((y,S)=>{var p,N;return e.jsx(We,{taskKey:y,agentConfig:((p=t.defaultAgents)==null?void 0:p[y])??R[y],isLast:S===W.length-1,onSave:j,authorConfig:y==="codeReview"?((N=t.defaultAgents)==null?void 0:N.phase)??R.phase:void 0},y)})]}),e.jsxs("p",{className:"opacity-[0.45] text-sm mt-4",children:[e.jsx("strong",{children:"Initialized:"})," ",t?new Date(t.initializedAt).toLocaleString():"—"]})]})},ns=()=>{const s=ie();return e.jsxs("div",{children:[e.jsx(Se,{children:"Settings"}),s==="subjects"?e.jsx($e,{}):s==="setup"?e.jsx(Ye,{}):s==="merge-policy"?e.jsx(ze,{}):s==="desk"?e.jsx(es,{}):e.jsx(ss,{})]})},ls=()=>{const s=ie(),t=ae();return e.jsxs(e.Fragment,{children:[e.jsxs($,{label:"General",children:[e.jsx(F,{size:"small",className:"pc-row text-xs",active:s===null,onClick:()=>t({to:"/settings"}),children:"Project Info"}),e.jsx(F,{size:"small",className:"pc-row text-xs",active:s==="setup",onClick:()=>t({to:"/settings/$section",params:{section:"setup"}}),children:"Setup"}),e.jsx(F,{size:"small",className:"pc-row text-xs",active:s==="merge-policy",onClick:()=>t({to:"/settings/$section",params:{section:"merge-policy"}}),children:"Merge Policy"})]}),e.jsx($,{label:"Ideas",children:e.jsx(F,{size:"small",className:"pc-row text-xs",active:s==="subjects",onClick:()=>t({to:"/settings/$section",params:{section:"subjects"}}),children:"Subjects"})}),e.jsx($,{label:"Stack",children:e.jsx(F,{size:"small",className:"pc-row text-xs",active:s==="desk",onClick:()=>t({to:"/settings/$section",params:{section:"desk"}}),children:"Desk"})})]})};export{ns as SettingsPage,ls as SettingsSidebar};
2
- //# sourceMappingURL=index-HixYRYWW.js.map
1
+ import{c as se,r as h,C as U,j as e,e as T,g as q,R as E,J as C,w as A,h as de,k as _,s as L,l as me,m as he,D as R,n as pe,o as V,q as ue,u as O,t as te,$ as xe,v as ge,a as ae,A as G,x as Y,y as je,z as fe,i as D,B as ne,E as le,F as ve,G as be,H as J,I as ye,K as ke,L as ie,P as Se,p as F}from"./main-DCzV1FeH.js";import{S as $}from"./sidebar-section-CFrPSdM0.js";const Ne=async()=>{try{const s=await fetch(se("/api/merge-policy"));return s.ok?await s.json():null}catch{return null}},Ce=async()=>{try{const s=await fetch(se("/api/merge-policy/apply"),{method:"POST"});return s.ok?await s.json():null}catch{return null}},W=["phase","planDraft","ideaExtend","commitSuggest","feedback","codeReview","deskDiscovery"],we={phase:"Phase run",planDraft:"Plan draft",ideaExtend:"Idea extend",commitSuggest:"Commit suggest",feedback:"Scout chat",codeReview:"Code review",deskDiscovery:"Desk discovery"},Ae={ok:{fill:"rgba(143, 185, 150, 0.25)",text:"#5E8A66",label:"Ready"},warn:{fill:"rgba(212, 163, 115, 0.25)",text:"#A67B4F",label:"Needs attention"},missing:{fill:"rgba(201, 139, 139, 0.25)",text:"#6E3A3A",label:"Missing"}},B={upToDate:{fill:"rgba(143, 185, 150, 0.25)",text:"#5E8A66"},outdated:{fill:"rgba(212, 163, 115, 0.25)",text:"#A67B4F"}},De="rgba(143, 185, 150, 0.25)",oe={allowSquashMerge:!0,allowMergeCommit:!1,allowRebaseMerge:!1,squashMergeCommitTitle:"PR_TITLE",squashMergeCommitMessage:"PR_BODY"},H=[{key:"allowSquashMerge",label:"Allow squash merge"},{key:"allowMergeCommit",label:"Allow merge commit"},{key:"allowRebaseMerge",label:"Allow rebase merge"},{key:"squashMergeCommitTitle",label:"Squash commit title"},{key:"squashMergeCommitMessage",label:"Squash commit message"}];function K(s){return typeof s=="boolean"?s?"Yes":"No":s}function Ie(s){return H.every(t=>s[t.key]===oe[t.key])}const Re=({label:s,current:t,recommended:n,isLast:i})=>{const l=t===n;return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center gap-3 pb-2 pt-2",children:[e.jsx("span",{className:"flex-1",children:s}),e.jsx("span",{className:l?"opacity-[0.65] font-normal":"font-semibold",children:K(t)}),!l&&e.jsxs("span",{className:"opacity-[0.45]",children:["→ ",K(n)]})]}),!i&&e.jsx(A,{})]})},ze=()=>{const[s,t]=h.useState(void 0),[n,i]=h.useState(!1),{toast:l}=U();h.useEffect(()=>{Ne().then(t)},[]);const o=async()=>{i(!0);const c=await Ce();i(!1),(c==null?void 0:c.status)==="ok"?(t(c),l({title:"Merge policy applied",variant:"success"})):l({title:"Failed to apply merge policy",description:(c==null?void 0:c.status)==="unavailable"?c.reason:void 0,variant:"error"})},r=(s==null?void 0:s.status)==="ok"&&Ie(s.policy);return e.jsxs("div",{children:[e.jsxs("div",{className:"mb-6",children:[e.jsx("h2",{className:"m-0",children:"Merge Policy"}),e.jsx("p",{className:"opacity-50 mt-1",children:"Paper Camp's canonical policy: squash-only merges, with the commit title and body taken from the PR."})]}),s===void 0&&e.jsx("p",{children:"Loading…"}),s===null&&e.jsx(T,{variant:"warning",children:"Failed to load merge policy."}),(s==null?void 0:s.status)==="unavailable"&&e.jsx(T,{variant:"warning",children:s.reason}),(s==null?void 0:s.status)==="ok"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center gap-3 mb-3",children:[e.jsx("span",{className:"font-medium",children:s.repo}),e.jsx(q,{size:"small",fillColor:r?B.upToDate.fill:B.outdated.fill,textColor:r?B.upToDate.text:B.outdated.text,children:r?"Matches recommended policy":"Differs from recommended policy"})]}),e.jsx(E,{size:"small",texture:"kraft",children:H.map((c,m)=>e.jsx(Re,{label:c.label,current:s.policy[c.key],recommended:oe[c.key],isLast:m===H.length-1},c.key))}),e.jsx("div",{className:"mt-4",children:e.jsx(C,{size:"small",onClick:o,disabled:n||r,children:n?"Applying…":"Apply recommended policy"})})]})]})},X={repo:""},Pe=s=>s.name.trim()!==""&&s.cmd.trim()!=="",Ee=s=>s.name.trim()!==""&&s.cmd.trim()!=="",Q=({id:s,...t})=>t;function Z(s,t){const n=new Set,i=t.map(o=>{const r=o.cmd?s.find(j=>!n.has(j.id)&&j.cmd===o.cmd):void 0;if(!r)return{...o,id:crypto.randomUUID()};n.add(r.id);const{id:c,...m}=r;return JSON.stringify(m)===JSON.stringify(o)?r:{...o,id:c}}),l=s.filter(o=>!n.has(o.id)&&(o.name.trim()===""||o.cmd.trim()===""));return[...i,...l]}const Le=()=>{const[s,t]=h.useState(void 0),[n,i]=h.useState([]),[l,o]=h.useState([]),[r,c]=h.useState(X),{toast:m}=U(),j=de(),v=h.useCallback(a=>{var x;t(a),i(d=>{var u;return Z(d,((u=a==null?void 0:a.desk)==null?void 0:u.services)??[])}),o(d=>{var u;return Z(d,((u=a==null?void 0:a.desk)==null?void 0:u.checks)??[])}),c(((x=a==null?void 0:a.desk)==null?void 0:x.ci)??X)},[]);h.useEffect(()=>{_().then(v)},[v]);const f=h.useCallback(async()=>{const a=await _();v(a)},[v]),k=async(a,x,d)=>{const u=a.filter(Pe).map(Q),I=x.filter(Ee).map(Q),z=d.repo.trim()?d:void 0,P={services:u.length?u:void 0,checks:I.length?I:void 0,ci:z},{ok:M,error:ce}=await L({desk:P});if(M){await j.reloadCurrent();const re=await _();v(re),m({title:"Saved",variant:"success"})}else m({title:"Failed to save",description:ce,variant:"error"})},w=()=>i(a=>[...a,{id:crypto.randomUUID(),name:"",cmd:""}]),b=(a,x)=>{const d=n.map(u=>u.id===a?{...x,id:a}:u);i(d),k(d,l,r)},g=a=>{const x=n.filter(d=>d.id!==a);i(x),k(x,l,r)},y=()=>o(a=>[...a,{id:crypto.randomUUID(),name:"",cmd:""}]),S=(a,x)=>{const d=l.map(u=>u.id===a?{...x,id:a}:u);o(d),k(n,d,r)},p=a=>{const x=l.filter(d=>d.id!==a);o(x),k(n,x,r)},N=a=>{c(a),k(n,l,a)};return{config:s,services:n,checks:l,ci:r,proposal:j.proposal,diff:j.diff,discovering:j.discovering,addService:w,updateService:b,removeService:g,addCheck:y,updateCheck:S,removeCheck:p,updateCi:N,startDiscovery:j.startDiscovery,cancelProposal:j.cancelProposal,applyProposal:async a=>{await j.applyProposal(a),await f()}}},Te=()=>{const s=h.useRef(null),[t,n]=h.useState(void 0),{iconDataUri:i,loading:l}=me(),[o,r]=h.useState(null),c=o??i,[m,j]=h.useState(!1),[v,f]=h.useState(""),[k,w]=h.useState(""),{toast:b}=U();return h.useEffect(()=>{_().then(a=>{n(a),(a==null?void 0:a.port)!==void 0&&f(String(a.port)),(a==null?void 0:a.projectName)!==void 0&&w(a.projectName)})},[]),{fileRef:s,config:t,identityLoading:l,iconDataUri:c,uploading:m,portInput:v,setPortInput:f,nameInput:k,setNameInput:w,handleSaveAgentConfig:async(a,x)=>{const d=t==null?void 0:t.defaultAgents,u={phase:(d==null?void 0:d.phase)??R.phase,planDraft:(d==null?void 0:d.planDraft)??R.planDraft,ideaExtend:(d==null?void 0:d.ideaExtend)??R.ideaExtend,commitSuggest:(d==null?void 0:d.commitSuggest)??R.commitSuggest,feedback:(d==null?void 0:d.feedback)??R.feedback,codeReview:(d==null?void 0:d.codeReview)??R.codeReview,deskDiscovery:(d==null?void 0:d.deskDiscovery)??R.deskDiscovery,[a]:x};if(a==="codeReview"&&pe(x,u.phase)){b({title:"Failed to save",description:"Code review must use a different model than Phase run.",variant:"error"});return}const{ok:I,error:z}=await L({defaultAgents:u});I?(n(P=>P&&{...P,defaultAgents:u}),b({title:"Saved",variant:"success"})):b({title:"Failed to save",description:z,variant:"error"})},handleSavePort:async()=>{const a=Number(v);if(!t||!Number.isInteger(a)||a<=0||a===t.port)return;const{ok:x,error:d}=await L({port:a});x?(n(u=>u&&{...u,port:a}),b({title:"Saved",description:"Restart `paper-camp dev` to apply the new port.",variant:"success"})):b({title:"Failed to save",description:d,variant:"error"})},handleToggleIntegration:async()=>{var I,z,P;if(!t)return;const a=!(((z=(I=t.integration)==null?void 0:I.toolbar)==null?void 0:z.enabled)??!0),x={...t.integration,toolbar:{...(P=t.integration)==null?void 0:P.toolbar,enabled:a}},{ok:d,error:u}=await L({integration:x});d?(n(M=>M&&{...M,integration:x}),b({title:"Saved",variant:"success"})):b({title:"Failed to save",description:u,variant:"error"})},handleSaveName:async()=>{const a=k.trim();if(!t||!a||a===t.projectName)return;const{ok:x,error:d}=await L({projectName:a});x?(n(u=>u&&{...u,projectName:a}),w(a),b({title:"Saved",variant:"success"})):b({title:"Failed to save",description:d,variant:"error"})},handleFile:async a=>{var u;const x=(u=a.target.files)==null?void 0:u[0];if(!x)return;j(!0);const d=new FileReader;d.onloadend=async()=>{const I=d.result,z=await he(I);j(!1),z?(r(I),b({title:"Saved",variant:"success"})):b({title:"Failed to save",variant:"error"})},d.readAsDataURL(x)}}},Me=()=>{const[s,t]=h.useState(null),[n,i]=h.useState(!1),[l,o]=h.useState(null),[r,c]=h.useState(null),[m,j]=h.useState(!1),{toast:v}=U(),f=h.useCallback(p=>{if(p===null){i(!0);return}i(!1),t(p)},[]);h.useEffect(()=>{V().then(f),_().then(p=>j((p==null?void 0:p.setupDismissed)??!1))},[f]);const k=async p=>{o(p),f(await V()),o(null)},w=async p=>{c(p);const N=await ue(p);N?t(a=>(a==null?void 0:a.map(x=>x.id===p?N:x))??a):v({title:"Failed to connect",variant:"error"}),c(null)},b=async()=>{const p=!m,{ok:N}=await L({setupDismissed:p});N?(j(p),v({title:"Saved",variant:"success"})):v({title:"Failed to save",variant:"error"})},g=(s==null?void 0:s.every(p=>p.status==="ok"))??!0,y=(s==null?void 0:s.filter(p=>p.kind==="external"))??[],S=(s==null?void 0:s.filter(p=>p.kind==="local"))??[];return{connections:s,loadFailed:n,reloadingId:l,connectingId:r,setupDismissed:m,handleRecheck:k,handleConnect:w,handleDismissToggle:b,allOk:g,externalConnections:y,localConnections:S}},Fe=2e3,_e=s=>{const t=O(m=>m.loginRelay),n=O(m=>m.startLoginRelay),i=O(m=>m.loadLoginRelayStatus),l=O(m=>m.cancelLoginRelay),{toast:o}=U(),r=h.useRef(null),c=t==null?void 0:t.phase;return h.useEffect(()=>{if(c!=="starting"&&c!=="awaiting-authorization")return;const m=window.setInterval(()=>i(),Fe);return()=>window.clearInterval(m)},[c,i]),h.useEffect(()=>{const m=t==null?void 0:t.authorizeUrl;c!=="awaiting-authorization"||!m||r.current===m||(r.current=m,window.open(m,"_blank","noopener,noreferrer"))},[c,t==null?void 0:t.authorizeUrl]),h.useEffect(()=>{c==="success"?(o({title:"Signed in",variant:"success"}),s()):c==="error"&&o({title:"Sign-in failed",description:t==null?void 0:t.error,variant:"error"})},[c]),{phase:c,authorizeUrl:t==null?void 0:t.authorizeUrl,startLoginRelay:n,cancelLoginRelay:l}},Ue=({connection:s,onConnect:t,connecting:n})=>{const{connect:i}=s;return i?i.kind==="command"&&i.runnable?e.jsx(C,{size:"small",onClick:()=>t(s.id),disabled:n,children:n?"Running…":`Run \`${i.command}\``}):i.kind==="command"?e.jsx("div",{className:"mt-2",children:e.jsx(te,{code:i.command})}):i.kind==="link"?e.jsx(C,{size:"small",onClick:()=>window.open(i.url,"_blank","noopener,noreferrer"),children:i.label}):e.jsx("p",{className:"opacity-[0.65] text-sm mt-2 mx-0 mb-0",children:i.message}):null},Oe=["claude auth login","claude setup-token"],Be=()=>e.jsxs("div",{className:"mt-2 flex flex-col gap-2",children:[e.jsx("p",{className:"opacity-[0.65] text-sm m-0",children:"The in-app relay couldn't complete. Run one of these in a terminal instead:"}),Oe.map(s=>e.jsx(te,{code:s},s)),e.jsxs("p",{className:"opacity-50 text-sm m-0",children:["Alternatively, set ",e.jsx("code",{children:"ANTHROPIC_API_KEY"})," in the server's environment — that bills as API usage rather than your Max subscription, so treat it as a fallback, not the default."]})]}),qe=({onSignedIn:s})=>{const{phase:t,authorizeUrl:n,startLoginRelay:i,cancelLoginRelay:l}=_e(s);return t==="starting"?e.jsx(C,{size:"small",disabled:!0,children:"Starting…"}):t==="awaiting-authorization"?e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(C,{size:"small",onClick:()=>n&&window.open(n,"_blank","noopener,noreferrer"),children:"Reopen sign-in tab"}),e.jsx(C,{size:"small",onClick:()=>l(),children:"Cancel"})]}):e.jsxs("div",{children:[e.jsx(C,{size:"small",onClick:()=>i(),children:"Sign in"}),t==="error"&&e.jsx(Be,{})]})},Ge="agent:claude-code",ee=({connection:s,isLast:t,onRecheck:n,rechecking:i,onConnect:l,connecting:o})=>{const r=Ae[s.status];return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"pb-3 pt-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:"flex-1 font-medium",children:s.label}),s.authenticated===!1&&e.jsx(xe,{content:"Installed, but not signed in",children:e.jsx(q,{size:"small",variant:"warning",children:"Not signed in"})}),e.jsx(q,{size:"small",fillColor:r.fill,textColor:r.text,children:r.label}),e.jsx(C,{size:"small",onClick:()=>n(s.id),disabled:i,children:i?"Checking…":"Recheck"})]}),e.jsxs("p",{className:"opacity-[0.65] text-sm mt-1 mx-0 mb-0",children:["Unlocks: ",s.unlocks]}),e.jsx("p",{className:"opacity-50 text-sm mt-1 mx-0 mb-0",children:s.detail}),e.jsx("div",{className:"mt-2",children:s.id===Ge&&s.authenticated===!1?e.jsx(qe,{onSignedIn:()=>n(s.id)}):e.jsx(Ue,{connection:s,onConnect:l,connecting:o})})]}),!t&&e.jsx(A,{})]})},Ye=()=>{const{connections:s,loadFailed:t,reloadingId:n,connectingId:i,setupDismissed:l,handleRecheck:o,handleConnect:r,handleDismissToggle:c,allOk:m,externalConnections:j,localConnections:v}=Me();return e.jsxs("div",{children:[e.jsx("div",{className:"mb-6",children:e.jsx("h2",{className:"m-0",children:"Setup"})}),s===null&&!t&&e.jsx("p",{children:"Loading…"}),t&&e.jsx("div",{className:"mb-4",children:e.jsx(T,{variant:"warning",children:"Failed to load connections. Try refreshing."})}),s&&e.jsxs(e.Fragment,{children:[!m&&e.jsx("div",{className:"mb-4",children:e.jsx(T,{variant:"warning",children:"Some connections are incomplete — features that depend on them stay disabled until fixed. Run the connect command below, then recheck."})}),j.length>0&&e.jsxs("div",{className:"mb-4",children:[e.jsx("p",{className:"opacity-[0.45] text-sm mt-0 mb-2",children:"External services — reached on your behalf with their own remote credential."}),e.jsx(E,{size:"small",texture:"kraft",children:j.map((f,k)=>e.jsx(ee,{connection:f,isLast:k===j.length-1,onRecheck:o,rechecking:n===f.id,onConnect:r,connecting:i===f.id},f.id))})]}),v.length>0&&e.jsxs("div",{className:"mb-4",children:[e.jsx("p",{className:"opacity-[0.45] text-sm mt-0 mb-2",children:"Local adapters — driven on this machine with their own local session."}),e.jsx(E,{size:"small",texture:"kraft",children:v.map((f,k)=>e.jsx(ee,{connection:f,isLast:k===v.length-1,onRecheck:o,rechecking:n===f.id,onConnect:r,connecting:i===f.id},f.id))})]}),e.jsx("div",{className:"mt-4",children:e.jsx(C,{size:"small",onClick:c,children:l?"Show Setup on open again":"Don't show Setup on open"})})]})]})},$e=()=>{const{subjects:s,loading:t,available:n}=ge(),i=ae();return e.jsxs("div",{children:[e.jsxs("div",{className:"mb-6",children:[e.jsx("h2",{className:"m-0",children:"Subjects"}),e.jsx("p",{className:"opacity-50 mt-1",children:"Subjects are the roadmap's bets and standing concerns. Edit the vocabulary on the Roadmap page."})]}),t&&e.jsx("p",{children:"Loading…"}),!t&&!n&&e.jsx("p",{className:"opacity-60 m-0",children:"Couldn't load subjects — check the server config."}),!t&&n&&e.jsxs(E,{size:"small",texture:"kraft",children:[s.length===0&&e.jsx("p",{className:"opacity-[0.45] m-0 pb-2",children:"No subjects yet."}),s.map((l,o)=>e.jsxs("div",{children:[e.jsx("div",{className:"pb-2 pt-2",children:l}),o<s.length-1&&e.jsx(A,{})]},l)),s.length>0&&e.jsx(A,{}),e.jsx("div",{className:"pt-3",children:e.jsx(C,{size:"small",onClick:()=>i({to:"/roadmap"}),children:"Go to Roadmap"})})]})]})},He=140,Ve=160,Je=110,We=({taskKey:s,agentConfig:t,isLast:n,onSave:i,authorConfig:l})=>{const o=G[t.agent]??G["claude-code"],r=l&&l.agent===t.agent?l.model??"":void 0,c=Array.isArray(o.model)?o.model.filter(g=>g!==r):o.model,m=o.effort,[j,v]=h.useState(t.model??"");h.useEffect(()=>{v(t.model??"")},[t.model]);const f=g=>{var N;const y=g,S=G[y],p={agent:y};t.model&&(S.model===null||(N=S.model)!=null&&N.includes(t.model))&&(p.model=t.model),t.effort&&Array.isArray(S.effort)&&(p.effort=t.effort),i(s,p)},k=g=>{i(s,{...t,model:g||void 0})},w=()=>{i(s,{...t,model:j||void 0})},b=g=>{i(s,{...t,effort:g||void 0})};return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center gap-3 pb-2 pt-2",children:[e.jsx("span",{className:"w-[110px] shrink-0 text-sm opacity-[0.65]",children:we[s]}),e.jsx(Y,{size:"small",width:He,value:t.agent,onChange:f,options:je.map(g=>({value:g,label:fe[g]}))}),Array.isArray(c)?e.jsx(Y,{size:"small",width:Ve,value:t.model??"",onChange:k,options:[...r===""?[]:[{value:"",label:"Default"}],...c.map(g=>({value:g,label:g}))]}):c===null?e.jsx(D,{size:"small",className:"w-[160px]",value:j,placeholder:"Default model",onChange:g=>v(g.target.value),onBlur:w}):null,e.jsx("div",{className:Array.isArray(m)?"visible":"invisible",children:e.jsx(Y,{size:"small",width:Je,value:t.effort??"",onChange:b,options:[{value:"",label:"Default"},...(Array.isArray(m)?m:[]).map(g=>({value:g,label:g}))]})})]}),!n&&e.jsx(A,{})]})},Ke=()=>e.jsxs("div",{className:"flex items-center gap-3 pb-1",children:[e.jsx("span",{className:"w-[110px] shrink-0 text-sm opacity-[0.45]",children:"Task"}),e.jsx("span",{className:"w-[140px] shrink-0 text-sm opacity-[0.45]",children:"Agent"}),e.jsx("span",{className:"w-[160px] shrink-0 text-sm opacity-[0.45]",children:"Model"}),e.jsx("span",{className:"w-[110px] shrink-0 text-sm opacity-[0.45]",children:"Effort"})]}),Xe=({check:s,onSave:t,onRemove:n,isLast:i})=>{const[l,o]=h.useState(s);h.useEffect(()=>o(s),[s]);const r=()=>{l.name===s.name&&l.cmd===s.cmd||t(l)};return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-end gap-3 pb-2 pt-2",children:[e.jsx(D,{size:"small",label:"Name",value:l.name,onChange:c=>o({...l,name:c.target.value}),onBlur:r}),e.jsx(D,{size:"small",label:"Command",value:l.cmd,onChange:c=>o({...l,cmd:c.target.value}),onBlur:r}),e.jsx(ne,{icon:e.jsx(le,{size:16}),variant:"danger",size:"small",onClick:n,label:`Remove ${s.name||"check"}`})]}),!i&&e.jsx(A,{})]})},Qe=({ci:s,onSave:t})=>{const[n,i]=h.useState(s);h.useEffect(()=>i(s),[s]);const l=()=>{n.repo===s.repo&&(n.branch??"")===(s.branch??"")&&(n.releasePlease??!1)===(s.releasePlease??!1)||t(n)};return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-end gap-3 pb-3",children:[e.jsx(D,{size:"small",label:"Repo (owner/name)",value:n.repo,onChange:o=>i({...n,repo:o.target.value}),onBlur:l}),e.jsx(D,{size:"small",label:"Branch",value:n.branch??"",onChange:o=>i({...n,branch:o.target.value||void 0}),onBlur:l})]}),e.jsx(A,{}),e.jsxs("div",{className:"flex items-center justify-between pt-3",children:[e.jsx("span",{children:"Release Please"}),e.jsx(ve,{checked:n.releasePlease??!1,onChange:o=>{const r={...n,releasePlease:o.target.checked};i(r),t(r)}})]})]})},Ze=({service:s,onSave:t,onRemove:n,isLast:i})=>{const[l,o]=h.useState(s);h.useEffect(()=>o(s),[s]);const r=()=>{l.name===s.name&&l.cmd===s.cmd&&(l.port??void 0)===(s.port??void 0)&&(l.healthcheck??void 0)===(s.healthcheck??void 0)||t(l)};return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-end gap-3 pb-2 pt-2",children:[e.jsx(D,{size:"small",label:"Name",value:l.name,onChange:c=>o({...l,name:c.target.value}),onBlur:r}),e.jsx(D,{size:"small",label:"Command",value:l.cmd,onChange:c=>o({...l,cmd:c.target.value}),onBlur:r}),e.jsx(D,{size:"small",type:"number",label:"Port",className:"w-[100px]",value:l.port??"",onChange:c=>o({...l,port:c.target.value?Number(c.target.value):void 0}),onBlur:r}),e.jsx(D,{size:"small",label:"Healthcheck URL",value:l.healthcheck??"",onChange:c=>o({...l,healthcheck:c.target.value||void 0}),onBlur:r}),e.jsx(ne,{icon:e.jsx(le,{size:16}),variant:"danger",size:"small",onClick:n,label:`Remove ${s.name||"service"}`})]}),!i&&e.jsx(A,{})]})},es=()=>{const{config:s,services:t,checks:n,ci:i,proposal:l,diff:o,discovering:r,addService:c,updateService:m,removeService:j,addCheck:v,updateCheck:f,removeCheck:k,updateCi:w,startDiscovery:b,cancelProposal:g,applyProposal:y}=Le();return e.jsxs("div",{children:[e.jsxs("div",{className:"mb-6 flex items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"m-0",children:"Desk"}),e.jsx("p",{className:"opacity-50 mt-1",children:"Services, checks, and CI/release sources for this project's Stack panel."})]}),s&&e.jsx(C,{size:"small",onClick:b,disabled:r,children:r?e.jsxs(e.Fragment,{children:[e.jsx(be,{size:"small",label:"Discovering"})," Discovering…"]}):s.desk?"Re-scan with discovery":"Discover from project"})]}),s===void 0&&e.jsx("p",{children:"Loading…"}),s===null&&e.jsxs(T,{variant:"warning",children:["No papercamp/config.json found — run ",e.jsx("code",{children:"paper-camp init"})," in this directory first."]}),s&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"mb-6",children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsx("h3",{className:"m-0",children:"Services"}),e.jsx(C,{size:"small",icon:e.jsx(J,{size:16}),onClick:c,children:"Add service"})]}),e.jsxs(E,{size:"small",texture:"kraft",children:[t.length===0&&e.jsx("p",{className:"opacity-[0.45] m-0 pb-2",children:"No services yet."}),t.map((S,p)=>e.jsx(Ze,{service:S,onSave:N=>m(S.id,N),onRemove:()=>j(S.id),isLast:p===t.length-1},S.id))]})]}),e.jsxs("div",{className:"mb-6",children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsx("h3",{className:"m-0",children:"Checks"}),e.jsx(C,{size:"small",icon:e.jsx(J,{size:16}),onClick:v,children:"Add check"})]}),e.jsxs(E,{size:"small",texture:"kraft",children:[n.length===0&&e.jsx("p",{className:"opacity-[0.45] m-0 pb-2",children:"No checks yet."}),n.map((S,p)=>e.jsx(Xe,{check:S,onSave:N=>f(S.id,N),onRemove:()=>k(S.id),isLast:p===n.length-1},S.id))]})]}),e.jsxs("div",{children:[e.jsx("h3",{className:"m-0 mb-3",children:"CI"}),e.jsx(E,{size:"small",texture:"kraft",children:e.jsx(Qe,{ci:i,onSave:w})})]}),l&&o&&e.jsx(ye,{current:s.desk,proposal:l,diff:o,onApply:y,onCancel:g})]})]})},ss=()=>{var b,g;const{fileRef:s,config:t,identityLoading:n,iconDataUri:i,uploading:l,portInput:o,setPortInput:r,nameInput:c,setNameInput:m,handleSaveAgentConfig:j,handleSavePort:v,handleToggleIntegration:f,handleSaveName:k,handleFile:w}=Te();return e.jsxs("div",{children:[e.jsx("div",{className:"mb-6",children:e.jsx("h2",{className:"m-0",children:"Project Info"})}),t===void 0&&e.jsx("p",{children:"Loading…"}),t===null&&e.jsxs(T,{variant:"warning",children:["No papercamp/config.json found — run ",e.jsx("code",{children:"paper-camp init"})," in this directory first."]}),t&&e.jsxs(E,{size:"small",texture:"kraft",children:[e.jsxs("div",{className:"flex items-end gap-3 pb-3",children:[e.jsx(D,{value:c,onChange:y=>m(y.target.value),onBlur:k,label:"Project Name"}),e.jsxs(q,{size:"small",fillColor:De,textColor:ke.accentGreenDark,children:["v",t.version]})]}),e.jsx(A,{}),e.jsxs("div",{className:"flex items-center gap-3 pb-3 pt-3",children:[i&&e.jsx("img",{src:i,alt:"Project icon",className:"w-10 h-10 object-contain shrink-0 rounded"}),e.jsxs("div",{children:[e.jsx("input",{ref:s,type:"file",accept:".svg,.png,.jpg,.jpeg,.gif,.webp",onChange:w,className:"hidden"}),e.jsx(C,{size:"small",onClick:()=>{var y;return(y=s.current)==null?void 0:y.click()},disabled:l,children:l?"Uploading…":"Choose File"}),n&&e.jsx("p",{className:"text-sm opacity-50 mt-1 mx-0 mb-0",children:"Loading…"}),!n&&!i&&!l&&e.jsx("p",{className:"text-sm opacity-[0.45] mt-1 mx-0 mb-0",children:"No icon set."})]})]}),e.jsx(A,{}),e.jsx("div",{className:"flex items-end gap-3 pb-3 pt-3",children:e.jsx(D,{type:"number",value:o,onChange:y=>r(y.target.value),onBlur:v,label:"Port",helperText:"Default for `paper-camp dev`. Restart the server to apply a change."})}),e.jsx(A,{}),e.jsxs("div",{className:"flex items-center justify-between gap-3 pb-3 pt-3",children:[e.jsxs("div",{children:[e.jsx("p",{className:"m-0",children:"In-app dev toolbar"}),e.jsx("p",{className:"opacity-[0.45] text-sm mt-1 mx-0 mb-0",children:"Inject the paper-camp toolbar into this project's dev server via the Vite plugin."})]}),e.jsx(C,{size:"small",onClick:f,children:((g=(b=t.integration)==null?void 0:b.toolbar)==null?void 0:g.enabled)??!0?"Disable":"Enable"})]}),e.jsx(A,{}),e.jsx(Ke,{}),W.map((y,S)=>{var p,N;return e.jsx(We,{taskKey:y,agentConfig:((p=t.defaultAgents)==null?void 0:p[y])??R[y],isLast:S===W.length-1,onSave:j,authorConfig:y==="codeReview"?((N=t.defaultAgents)==null?void 0:N.phase)??R.phase:void 0},y)})]}),e.jsxs("p",{className:"opacity-[0.45] text-sm mt-4",children:[e.jsx("strong",{children:"Initialized:"})," ",t?new Date(t.initializedAt).toLocaleString():"—"]})]})},ns=()=>{const s=ie();return e.jsxs("div",{children:[e.jsx(Se,{children:"Settings"}),s==="subjects"?e.jsx($e,{}):s==="setup"?e.jsx(Ye,{}):s==="merge-policy"?e.jsx(ze,{}):s==="desk"?e.jsx(es,{}):e.jsx(ss,{})]})},ls=()=>{const s=ie(),t=ae();return e.jsxs(e.Fragment,{children:[e.jsxs($,{label:"General",children:[e.jsx(F,{size:"small",className:"pc-row text-xs",active:s===null,onClick:()=>t({to:"/settings"}),children:"Project Info"}),e.jsx(F,{size:"small",className:"pc-row text-xs",active:s==="setup",onClick:()=>t({to:"/settings/$section",params:{section:"setup"}}),children:"Setup"}),e.jsx(F,{size:"small",className:"pc-row text-xs",active:s==="merge-policy",onClick:()=>t({to:"/settings/$section",params:{section:"merge-policy"}}),children:"Merge Policy"})]}),e.jsx($,{label:"Ideas",children:e.jsx(F,{size:"small",className:"pc-row text-xs",active:s==="subjects",onClick:()=>t({to:"/settings/$section",params:{section:"subjects"}}),children:"Subjects"})}),e.jsx($,{label:"Stack",children:e.jsx(F,{size:"small",className:"pc-row text-xs",active:s==="desk",onClick:()=>t({to:"/settings/$section",params:{section:"desk"}}),children:"Desk"})})]})};export{ns as SettingsPage,ls as SettingsSidebar};
2
+ //# sourceMappingURL=index-C1zPjxRZ.js.map