quadwork 0.1.2 → 0.1.3

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 (86) hide show
  1. package/README.md +4 -4
  2. package/bin/quadwork.js +153 -52
  3. package/out/404.html +1 -1
  4. package/out/__next.__PAGE__.txt +1 -1
  5. package/out/__next._full.txt +2 -2
  6. package/out/__next._head.txt +1 -1
  7. package/out/__next._index.txt +2 -2
  8. package/out/__next._tree.txt +2 -2
  9. package/out/_next/static/chunks/02ul7y114vj2f.js +13 -0
  10. package/out/_next/static/chunks/{0jsosmtclw5n5.js → 038g944ax83al.js} +1 -1
  11. package/out/_next/static/chunks/0gy_9ugdx7ueh.js +1 -0
  12. package/out/_next/static/chunks/0idtc5k0469of.js +1 -0
  13. package/out/_next/static/chunks/{03hi.hdp6l230.js → 0wda-2lcle8c4.js} +8 -8
  14. package/out/_next/static/chunks/0yxmvmvm1dx_d.css +2 -0
  15. package/out/_not-found/__next._full.txt +2 -2
  16. package/out/_not-found/__next._head.txt +1 -1
  17. package/out/_not-found/__next._index.txt +2 -2
  18. package/out/_not-found/__next._not-found.__PAGE__.txt +1 -1
  19. package/out/_not-found/__next._not-found.txt +1 -1
  20. package/out/_not-found/__next._tree.txt +2 -2
  21. package/out/_not-found.html +1 -1
  22. package/out/_not-found.txt +2 -2
  23. package/out/index.html +1 -1
  24. package/out/index.txt +2 -2
  25. package/out/project/_/__next._full.txt +3 -3
  26. package/out/project/_/__next._head.txt +1 -1
  27. package/out/project/_/__next._index.txt +2 -2
  28. package/out/project/_/__next._tree.txt +2 -2
  29. package/out/project/_/__next.project.$d$id.__PAGE__.txt +2 -2
  30. package/out/project/_/__next.project.$d$id.txt +1 -1
  31. package/out/project/_/__next.project.txt +1 -1
  32. package/out/project/_/memory/__next._full.txt +3 -3
  33. package/out/project/_/memory/__next._head.txt +1 -1
  34. package/out/project/_/memory/__next._index.txt +2 -2
  35. package/out/project/_/memory/__next._tree.txt +2 -2
  36. package/out/project/_/memory/__next.project.$d$id.memory.__PAGE__.txt +2 -2
  37. package/out/project/_/memory/__next.project.$d$id.memory.txt +1 -1
  38. package/out/project/_/memory/__next.project.$d$id.txt +1 -1
  39. package/out/project/_/memory/__next.project.txt +1 -1
  40. package/out/project/_/memory.html +1 -1
  41. package/out/project/_/memory.txt +3 -3
  42. package/out/project/_/queue/__next._full.txt +3 -3
  43. package/out/project/_/queue/__next._head.txt +1 -1
  44. package/out/project/_/queue/__next._index.txt +2 -2
  45. package/out/project/_/queue/__next._tree.txt +2 -2
  46. package/out/project/_/queue/__next.project.$d$id.queue.__PAGE__.txt +2 -2
  47. package/out/project/_/queue/__next.project.$d$id.queue.txt +1 -1
  48. package/out/project/_/queue/__next.project.$d$id.txt +1 -1
  49. package/out/project/_/queue/__next.project.txt +1 -1
  50. package/out/project/_/queue.html +1 -1
  51. package/out/project/_/queue.txt +3 -3
  52. package/out/project/_.html +1 -1
  53. package/out/project/_.txt +3 -3
  54. package/out/settings/__next._full.txt +3 -3
  55. package/out/settings/__next._head.txt +1 -1
  56. package/out/settings/__next._index.txt +2 -2
  57. package/out/settings/__next._tree.txt +2 -2
  58. package/out/settings/__next.settings.__PAGE__.txt +2 -2
  59. package/out/settings/__next.settings.txt +1 -1
  60. package/out/settings.html +1 -1
  61. package/out/settings.txt +3 -3
  62. package/out/setup/__next._full.txt +3 -3
  63. package/out/setup/__next._head.txt +1 -1
  64. package/out/setup/__next._index.txt +2 -2
  65. package/out/setup/__next._tree.txt +2 -2
  66. package/out/setup/__next.setup.__PAGE__.txt +2 -2
  67. package/out/setup/__next.setup.txt +1 -1
  68. package/out/setup.html +1 -1
  69. package/out/setup.txt +3 -3
  70. package/package.json +1 -1
  71. package/server/config.js +42 -2
  72. package/server/index.js +103 -55
  73. package/server/routes.js +104 -66
  74. package/templates/CLAUDE.md +16 -17
  75. package/templates/config.toml +12 -12
  76. package/templates/seeds/{t3.AGENTS.md → dev.AGENTS.md} +19 -19
  77. package/templates/seeds/{t1.AGENTS.md → head.AGENTS.md} +18 -18
  78. package/templates/seeds/{t2a.AGENTS.md → reviewer1.AGENTS.md} +16 -16
  79. package/templates/seeds/{t2b.AGENTS.md → reviewer2.AGENTS.md} +16 -16
  80. package/out/_next/static/chunks/03yov._jigv17.js +0 -1
  81. package/out/_next/static/chunks/0iqqouh_3i5y5.js +0 -13
  82. package/out/_next/static/chunks/15kwal..m9r49.css +0 -2
  83. package/out/_next/static/chunks/17sk4qv6_d0co.js +0 -1
  84. /package/out/_next/static/{vELqtMegFMn5_6zFOkhtG → 91YUiFoMbLQ9sZW4uk45J}/_buildManifest.js +0 -0
  85. /package/out/_next/static/{vELqtMegFMn5_6zFOkhtG → 91YUiFoMbLQ9sZW4uk45J}/_clientMiddlewareManifest.js +0 -0
  86. /package/out/_next/static/{vELqtMegFMn5_6zFOkhtG → 91YUiFoMbLQ9sZW4uk45J}/_ssgManifest.js +0 -0
@@ -1,4 +1,4 @@
1
1
  (globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,40768,e=>{"use strict";var t=e.i(85899),s=e.i(16353),a=e.i(4232);function r({projectId:e}){let[s,n]=(0,a.useState)([]),[o,c]=(0,a.useState)(""),[l,d]=(0,a.useState)(null),[i,x]=(0,a.useState)({}),[m,p]=(0,a.useState)(""),[h,b]=(0,a.useState)(""),[u,f]=(0,a.useState)(!1),[j,g]=(0,a.useState)(!1),[y,v]=(0,a.useState)(!1),[N,S]=(0,a.useState)("cards"),[C,_]=(0,a.useState)({memory_cards_dir:"",shared_memory_path:"",butler_scripts_dir:""}),[k,$]=(0,a.useState)(!1),[T,w]=(0,a.useState)(!1),R=(0,a.useCallback)(()=>{fetch(`/api/memory?project=${encodeURIComponent(e)}&action=cards&search=${encodeURIComponent(o)}`).then(e=>e.ok?e.json():[]).then(n).catch(()=>{})},[e,o]);(0,a.useEffect)(()=>{R()},[R]),(0,a.useEffect)(()=>{fetch(`/api/memory?project=${encodeURIComponent(e)}&action=status`).then(e=>e.ok?e.json():{agents:{}}).then(e=>x(e.agents||{})).catch(()=>{})},[e]),(0,a.useEffect)(()=>{fetch(`/api/memory?project=${encodeURIComponent(e)}&action=shared-memory`).then(e=>e.ok?e.json():{content:""}).then(e=>p(e.content)).catch(()=>{})},[e]),(0,a.useEffect)(()=>{fetch(`/api/memory?project=${encodeURIComponent(e)}&action=settings`).then(e=>e.ok?e.json():{}).then(e=>_({memory_cards_dir:e.memory_cards_dir||"",shared_memory_path:e.shared_memory_path||"",butler_scripts_dir:e.butler_scripts_dir||""})).catch(()=>{})},[e]);let U=t=>{f(!0),b(e=>e+`
2
2
  > ${t}
3
3
  `),fetch(`/api/memory?project=${encodeURIComponent(e)}&action=butler`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({command:t})}).then(e=>e.json()).then(s=>{b(e=>e+(s.ok?s.output:`Error: ${s.error}`)+"\n"),"inject.sh"===t&&fetch(`/api/memory?project=${encodeURIComponent(e)}&action=status`).then(e=>e.ok?e.json():{agents:{}}).then(e=>x(e.agents||{})).catch(()=>{}),("butler-scan.sh"===t||"butler-consolidate.sh"===t)&&R()}).catch(e=>b(t=>t+`Error: ${e.message}
4
- `)).finally(()=>f(!1))};return(0,t.jsxs)("div",{className:"h-full flex flex-col p-6 max-w-5xl",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between mb-4",children:[(0,t.jsx)("h1",{className:"text-lg font-semibold text-text tracking-tight",children:"Shared Memory"}),(0,t.jsxs)("div",{className:"flex items-center gap-1 border border-border",children:[(0,t.jsx)("button",{onClick:()=>S("cards"),className:`px-3 py-1 text-[11px] ${"cards"===N?"bg-accent text-bg":"text-text-muted hover:text-text"}`,children:"Cards"}),(0,t.jsx)("button",{onClick:()=>S("editor"),className:`px-3 py-1 text-[11px] ${"editor"===N?"bg-accent text-bg":"text-text-muted hover:text-text"}`,children:"Editor"}),(0,t.jsx)("button",{onClick:()=>S("settings"),className:`px-3 py-1 text-[11px] ${"settings"===N?"bg-accent text-bg":"text-text-muted hover:text-text"}`,children:"Settings"})]})]}),(0,t.jsx)("div",{className:"flex items-center gap-4 mb-4 text-[11px]",children:Object.entries(i).map(([e,s])=>(0,t.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,t.jsx)("span",{className:`w-1.5 h-1.5 rounded-full ${s.injected?"bg-accent":"bg-text-muted"}`}),(0,t.jsx)("span",{className:"text-text-muted",children:e.toUpperCase()}),s.lastModified&&(0,t.jsx)("span",{className:"text-text-muted text-[10px]",children:new Date(s.lastModified).toLocaleTimeString()})]},e))}),(0,t.jsxs)("div",{className:"flex items-center gap-2 mb-4",children:[(0,t.jsx)("button",{onClick:()=>U("butler-scan.sh"),disabled:u,className:"px-3 py-1 text-[11px] border border-border text-text-muted hover:text-text hover:border-accent transition-colors disabled:opacity-50",children:"Scan"}),(0,t.jsx)("button",{onClick:()=>U("butler-consolidate.sh"),disabled:u,className:"px-3 py-1 text-[11px] border border-border text-text-muted hover:text-text hover:border-accent transition-colors disabled:opacity-50",children:"Consolidate"}),(0,t.jsx)("button",{onClick:()=>U("inject.sh"),disabled:u,className:"px-3 py-1 text-[11px] border border-border text-text-muted hover:text-text hover:border-accent transition-colors disabled:opacity-50",children:"Inject"}),u&&(0,t.jsx)("span",{className:"text-[10px] text-text-muted",children:"Running..."})]}),h&&(0,t.jsx)("div",{className:"mb-4 border border-border bg-bg-surface max-h-32 overflow-y-auto",children:(0,t.jsx)("pre",{className:"p-2 text-[10px] text-text-muted whitespace-pre-wrap",children:h.trim()})}),"cards"===N&&(0,t.jsxs)("div",{className:"flex-1 min-h-0 flex flex-col",children:[(0,t.jsx)("input",{value:o,onChange:e=>c(e.target.value),placeholder:"Search cards...",className:"mb-3 bg-transparent border border-border px-2 py-1.5 text-[12px] text-text outline-none focus:border-accent"}),(0,t.jsxs)("div",{className:"flex-1 overflow-y-auto border border-border",children:[0===s.length&&(0,t.jsx)("div",{className:"p-3 text-[11px] text-text-muted",children:"No memory cards found"}),s.map(e=>(0,t.jsxs)("div",{className:"border-b border-border/50 last:border-b-0",children:[(0,t.jsxs)("button",{onClick:()=>d(l===e.file?null:e.file),className:"w-full flex items-center gap-3 px-3 py-1.5 hover:bg-[#1a1a1a] transition-colors text-left",children:[(0,t.jsx)("span",{className:"text-[11px] text-text flex-1 truncate",children:e.title}),(0,t.jsx)("span",{className:"text-[10px] text-text-muted shrink-0",children:e.agent}),(0,t.jsx)("span",{className:"text-[10px] text-text-muted shrink-0",children:e.date}),e.tags&&(0,t.jsx)("span",{className:"text-[10px] text-accent shrink-0",children:e.tags})]}),l===e.file&&(0,t.jsx)("div",{className:"px-3 pb-2 bg-bg-surface",children:(0,t.jsx)("pre",{className:"text-[11px] text-text whitespace-pre-wrap",children:e.content})})]},e.file))]})]}),"editor"===N&&(0,t.jsxs)("div",{className:"flex-1 min-h-0 flex flex-col",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between mb-2",children:[(0,t.jsx)("span",{className:"text-[11px] text-text-muted",children:"shared-memory.md"}),(0,t.jsx)("button",{onClick:()=>{g(!0),fetch(`/api/memory?project=${encodeURIComponent(e)}&action=save-memory`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:m})}).then(e=>e.json()).then(e=>{e.ok&&(v(!0),setTimeout(()=>v(!1),2e3))}).catch(()=>{}).finally(()=>g(!1))},disabled:j,className:"px-4 py-1 bg-accent text-bg text-[12px] font-semibold hover:bg-accent-dim transition-colors disabled:opacity-50",children:j?"Saving...":y?"Saved":"Save"})]}),(0,t.jsx)("textarea",{value:m,onChange:e=>p(e.target.value),className:"flex-1 bg-bg-surface border border-border p-3 text-[12px] text-text outline-none focus:border-accent resize-none"})]}),"settings"===N&&(0,t.jsxs)("div",{className:"flex-1 min-h-0 flex flex-col gap-4",children:[(0,t.jsx)("p",{className:"text-[11px] text-text-muted",children:"Override default paths for this project. Leave blank to use defaults."}),(0,t.jsxs)("label",{className:"flex flex-col gap-1",children:[(0,t.jsx)("span",{className:"text-[11px] text-text-muted",children:"Memory Cards Directory"}),(0,t.jsx)("input",{value:C.memory_cards_dir,onChange:e=>_({...C,memory_cards_dir:e.target.value}),placeholder:"../agent-memory/archive/v2/cards",className:"bg-transparent border border-border px-2 py-1.5 text-[12px] text-text outline-none focus:border-accent"})]}),(0,t.jsxs)("label",{className:"flex flex-col gap-1",children:[(0,t.jsx)("span",{className:"text-[11px] text-text-muted",children:"Shared Memory Path"}),(0,t.jsx)("input",{value:C.shared_memory_path,onChange:e=>_({...C,shared_memory_path:e.target.value}),placeholder:"../agent-memory/central/short-term/agent-os.md",className:"bg-transparent border border-border px-2 py-1.5 text-[12px] text-text outline-none focus:border-accent"})]}),(0,t.jsxs)("label",{className:"flex flex-col gap-1",children:[(0,t.jsx)("span",{className:"text-[11px] text-text-muted",children:"Butler Scripts Directory"}),(0,t.jsx)("input",{value:C.butler_scripts_dir,onChange:e=>_({...C,butler_scripts_dir:e.target.value}),placeholder:"../agent-memory/scripts",className:"bg-transparent border border-border px-2 py-1.5 text-[12px] text-text outline-none focus:border-accent"})]}),(0,t.jsx)("div",{children:(0,t.jsx)("button",{onClick:()=>{$(!0),fetch(`/api/memory?project=${encodeURIComponent(e)}&action=save-settings`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(C)}).then(e=>e.json()).then(e=>{e.ok&&(w(!0),setTimeout(()=>w(!1),2e3))}).catch(()=>{}).finally(()=>$(!1))},disabled:k,className:"px-4 py-1 bg-accent text-bg text-[12px] font-semibold hover:bg-accent-dim transition-colors disabled:opacity-50",children:k?"Saving...":T?"Saved":"Save Settings"})})]})]})}e.s(["default",0,function(){let{id:e}=(0,s.useParams)();return(0,t.jsx)(r,{projectId:e})}],40768)}]);
4
+ `)).finally(()=>f(!1))};return(0,t.jsxs)("div",{className:"h-full flex flex-col p-6 max-w-5xl",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between mb-4",children:[(0,t.jsx)("h1",{className:"text-lg font-semibold text-text tracking-tight",children:"Shared Memory"}),(0,t.jsxs)("div",{className:"flex items-center gap-1 border border-border",children:[(0,t.jsx)("button",{onClick:()=>S("cards"),className:`px-3 py-1 text-[11px] ${"cards"===N?"bg-accent text-bg":"text-text-muted hover:text-text"}`,children:"Cards"}),(0,t.jsx)("button",{onClick:()=>S("editor"),className:`px-3 py-1 text-[11px] ${"editor"===N?"bg-accent text-bg":"text-text-muted hover:text-text"}`,children:"Editor"}),(0,t.jsx)("button",{onClick:()=>S("settings"),className:`px-3 py-1 text-[11px] ${"settings"===N?"bg-accent text-bg":"text-text-muted hover:text-text"}`,children:"Settings"})]})]}),(0,t.jsx)("div",{className:"flex items-center gap-4 mb-4 text-[11px]",children:Object.entries(i).map(([e,s])=>(0,t.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,t.jsx)("span",{className:`w-1.5 h-1.5 rounded-full ${s.injected?"bg-accent":"bg-text-muted"}`}),(0,t.jsx)("span",{className:"text-text-muted",children:e.toUpperCase()}),s.lastModified&&(0,t.jsx)("span",{className:"text-text-muted text-[10px]",children:new Date(s.lastModified).toLocaleTimeString()})]},e))}),(0,t.jsxs)("div",{className:"flex items-center gap-2 mb-4",children:[(0,t.jsx)("button",{onClick:()=>U("butler-scan.sh"),disabled:u,className:"px-3 py-1 text-[11px] border border-border text-text-muted hover:text-text hover:border-accent transition-colors disabled:opacity-50",children:"Scan"}),(0,t.jsx)("button",{onClick:()=>U("butler-consolidate.sh"),disabled:u,className:"px-3 py-1 text-[11px] border border-border text-text-muted hover:text-text hover:border-accent transition-colors disabled:opacity-50",children:"Consolidate"}),(0,t.jsx)("button",{onClick:()=>U("inject.sh"),disabled:u,className:"px-3 py-1 text-[11px] border border-border text-text-muted hover:text-text hover:border-accent transition-colors disabled:opacity-50",children:"Inject"}),u&&(0,t.jsx)("span",{className:"text-[10px] text-text-muted",children:"Running..."})]}),h&&(0,t.jsx)("div",{className:"mb-4 border border-border bg-bg-surface max-h-32 overflow-y-auto",children:(0,t.jsx)("pre",{className:"p-2 text-[10px] text-text-muted whitespace-pre-wrap",children:h.trim()})}),"cards"===N&&(0,t.jsxs)("div",{className:"flex-1 min-h-0 flex flex-col",children:[(0,t.jsx)("input",{value:o,onChange:e=>c(e.target.value),placeholder:"Search cards...",className:"mb-3 bg-transparent border border-border px-2 py-1.5 text-[12px] text-text outline-none focus:border-accent"}),(0,t.jsxs)("div",{className:"flex-1 overflow-y-auto border border-border",children:[0===s.length&&(0,t.jsx)("div",{className:"p-3 text-[11px] text-text-muted",children:"No memory cards found"}),s.map(e=>(0,t.jsxs)("div",{className:"border-b border-border/50 last:border-b-0",children:[(0,t.jsxs)("button",{onClick:()=>d(l===e.file?null:e.file),className:"w-full flex items-center gap-3 px-3 py-1.5 hover:bg-[#1a1a1a] transition-colors text-left",children:[(0,t.jsx)("span",{className:"text-[11px] text-text flex-1 truncate",children:e.title}),(0,t.jsx)("span",{className:"text-[10px] text-text-muted shrink-0",children:e.agent}),(0,t.jsx)("span",{className:"text-[10px] text-text-muted shrink-0",children:e.date}),e.tags&&(0,t.jsx)("span",{className:"text-[10px] text-accent shrink-0",children:e.tags})]}),l===e.file&&(0,t.jsx)("div",{className:"px-3 pb-2 bg-bg-surface",children:(0,t.jsx)("pre",{className:"text-[11px] text-text whitespace-pre-wrap",children:e.content})})]},e.file))]})]}),"editor"===N&&(0,t.jsxs)("div",{className:"flex-1 min-h-0 flex flex-col",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between mb-2",children:[(0,t.jsx)("span",{className:"text-[11px] text-text-muted",children:"shared-memory.md"}),(0,t.jsx)("button",{onClick:()=>{g(!0),fetch(`/api/memory?project=${encodeURIComponent(e)}&action=save-memory`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:m})}).then(e=>e.json()).then(e=>{e.ok&&(v(!0),setTimeout(()=>v(!1),2e3))}).catch(()=>{}).finally(()=>g(!1))},disabled:j,className:"px-4 py-1 bg-accent text-bg text-[12px] font-semibold hover:bg-accent-dim transition-colors disabled:opacity-50",children:j?"Saving...":y?"Saved":"Save"})]}),(0,t.jsx)("textarea",{value:m,onChange:e=>p(e.target.value),className:"flex-1 bg-bg-surface border border-border p-3 text-[12px] text-text outline-none focus:border-accent resize-none"})]}),"settings"===N&&(0,t.jsxs)("div",{className:"flex-1 min-h-0 flex flex-col gap-4",children:[(0,t.jsx)("p",{className:"text-[11px] text-text-muted",children:"Override default paths for this project. Leave blank to use defaults."}),(0,t.jsxs)("label",{className:"flex flex-col gap-1",children:[(0,t.jsx)("span",{className:"text-[11px] text-text-muted",children:"Memory Cards Directory"}),(0,t.jsx)("input",{value:C.memory_cards_dir,onChange:e=>_({...C,memory_cards_dir:e.target.value}),placeholder:"../agent-memory/archive/v2/cards",className:"bg-transparent border border-border px-2 py-1.5 text-[12px] text-text outline-none focus:border-accent"})]}),(0,t.jsxs)("label",{className:"flex flex-col gap-1",children:[(0,t.jsx)("span",{className:"text-[11px] text-text-muted",children:"Shared Memory Path"}),(0,t.jsx)("input",{value:C.shared_memory_path,onChange:e=>_({...C,shared_memory_path:e.target.value}),placeholder:"../agent-memory/central/short-term/agent-os.md",className:"bg-transparent border border-border px-2 py-1.5 text-[12px] text-text outline-none focus:border-accent"})]}),(0,t.jsxs)("label",{className:"flex flex-col gap-1",children:[(0,t.jsx)("span",{className:"text-[11px] text-text-muted",children:"Butler Scripts Directory"}),(0,t.jsx)("input",{value:C.butler_scripts_dir,onChange:e=>_({...C,butler_scripts_dir:e.target.value}),placeholder:"../agent-memory/scripts",className:"bg-transparent border border-border px-2 py-1.5 text-[12px] text-text outline-none focus:border-accent"})]}),(0,t.jsx)("div",{children:(0,t.jsx)("button",{onClick:()=>{$(!0),fetch(`/api/memory?project=${encodeURIComponent(e)}&action=save-settings`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(C)}).then(e=>e.json()).then(e=>{e.ok&&(w(!0),setTimeout(()=>w(!1),2e3))}).catch(()=>{}).finally(()=>$(!1))},disabled:k,className:"px-4 py-1 bg-accent text-bg text-[12px] font-semibold hover:bg-accent-dim transition-colors disabled:opacity-50",children:k?"Saving...":T?"Saved":"Save Settings"})})]})]})}e.s(["default",0,function(){let e=(0,s.usePathname)().split("/")[2]||"";return e&&"_"!==e?(0,t.jsx)(r,{projectId:e}):null}],40768)}]);
@@ -0,0 +1 @@
1
+ (globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,64618,e=>{"use strict";var t=e.i(85899),r=e.i(4232),s=e.i(16353);let a=[{id:"name",label:"Project Name",status:"active"},{id:"repo",label:"GitHub Repo",status:"pending"},{id:"protection",label:"Branch Protection",status:"pending",optional:!0},{id:"backend",label:"CLI Backend",status:"pending"},{id:"workdir",label:"Working Directory",status:"pending"},{id:"worktrees",label:"Worktree Setup",status:"pending"},{id:"seeds",label:"Seed Files",status:"pending"},{id:"agentchattr",label:"AgentChattr Config",status:"pending",optional:!0},{id:"config",label:"Save Config",status:"pending"}],o=[{value:"claude",label:"Claude Code"},{value:"codex",label:"Codex"}];e.s(["default",0,function(){let e=(0,s.useRouter)(),[n,c]=(0,r.useState)(a),[i,l]=(0,r.useState)(0),[d,x]=(0,r.useState)(""),[p,b]=(0,r.useState)(""),[m,h]=(0,r.useState)({}),[u,g]=(0,r.useState)({head:"claude",reviewer1:"claude",reviewer2:"claude",dev:"claude"}),[j,f]=(0,r.useState)(""),[v,N]=(0,r.useState)(""),[k,w]=(0,r.useState)(""),[y,C]=(0,r.useState)(!1);(0,r.useEffect)(()=>{fetch("/api/config").then(e=>e.ok?e.json():null).then(e=>{let t=e?.default_backend;t&&("claude"===t||"codex"===t)&&g({head:t,reviewer1:t,reviewer2:t,dev:t})}).catch(()=>{})},[]);let _=(e,t)=>{c(r=>r.map((r,s)=>s===e?{...r,...t}:r))},S=()=>{_(i,{status:"done"});let e=i+1;e<n.length&&(_(e,{status:"active"}),l(e))},R=()=>{_(i,{status:"skipped"});let e=i+1;e<n.length&&(_(e,{status:"active"}),l(e))},U=async(e,t)=>{C(!0);try{let r=await fetch(`/api/setup?step=${e}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)}),s=await r.json();return C(!1),s}catch{return C(!1),{ok:!1,error:"Request failed"}}},A=async()=>{let e=await U("verify-repo",{repo:p});e.ok?S():_(i,{status:"error",error:e.error})},T=async()=>{let e=await U("create-worktrees",{workingDir:j,repo:p});e.ok?S():_(i,{status:"error",error:e.errors?.join(", ")||e.error})},P=async()=>{let e=await U("seed-files",{workingDir:j,projectName:d,repo:p,reviewerUser:v,reviewerTokenPath:k});e.ok?S():_(i,{status:"error",error:e.error})},$=async()=>{let t=j.split("/").pop()||d.toLowerCase().replace(/\s+/g,"-").replace(/[^a-z0-9-]/g,""),r=await U("add-config",{id:t,name:d,repo:p,workingDir:j,backends:u,...m});r.ok?(_(i,{status:"done"}),setTimeout(()=>e.push(`/project/${t}`),500)):_(i,{status:"error",error:r.error})},q=n[i];return(0,t.jsxs)("div",{className:"h-full overflow-y-auto p-6 max-w-4xl",children:[(0,t.jsx)("h1",{className:"text-lg font-semibold text-text tracking-tight mb-6",children:"New Project Setup"}),(0,t.jsxs)("div",{className:"flex gap-8",children:[(0,t.jsx)("div",{className:"w-48 shrink-0",children:n.map((e,r)=>(0,t.jsxs)("div",{className:"flex items-center gap-2 py-1.5",children:[(0,t.jsx)("span",{className:`w-5 h-5 flex items-center justify-center text-[10px] border ${"done"===e.status?"border-accent text-accent":"error"===e.status?"border-error text-error":"active"===e.status?"border-accent text-accent bg-accent/10":"skipped"===e.status?"border-border text-text-muted line-through":"border-border text-text-muted"}`,children:"done"===e.status?"✓":"error"===e.status?"!":"skipped"===e.status?"—":r+1}),(0,t.jsx)("span",{className:`text-[11px] ${"active"===e.status?"text-text font-semibold":"done"===e.status?"text-accent":"text-text-muted"}`,children:e.label})]},e.id))}),(0,t.jsxs)("div",{className:"flex-1 border border-border p-4",children:[q?.id==="name"&&(0,t.jsxs)("div",{children:[(0,t.jsx)("h2",{className:"text-sm font-semibold text-text mb-3",children:"Project Name"}),(0,t.jsx)("input",{value:d,onChange:e=>x(e.target.value),placeholder:"My Project",className:"w-full bg-transparent border border-border px-2 py-1.5 text-[12px] text-text outline-none focus:border-accent mb-3"}),(0,t.jsx)("button",{onClick:S,disabled:!d,className:"px-4 py-1.5 bg-accent text-bg text-[12px] font-semibold hover:bg-accent-dim transition-colors disabled:opacity-50",children:"Next"})]}),q?.id==="repo"&&(0,t.jsxs)("div",{children:[(0,t.jsx)("h2",{className:"text-sm font-semibold text-text mb-3",children:"GitHub Repository"}),(0,t.jsx)("input",{value:p,onChange:e=>b(e.target.value),placeholder:"owner/repo",className:"w-full bg-transparent border border-border px-2 py-1.5 text-[12px] text-text outline-none focus:border-accent mb-3"}),q.error&&(0,t.jsx)("p",{className:"text-[11px] text-error mb-2",children:q.error}),(0,t.jsx)("button",{onClick:A,disabled:!p||y,className:"px-4 py-1.5 bg-accent text-bg text-[12px] font-semibold hover:bg-accent-dim transition-colors disabled:opacity-50",children:y?"Verifying...":"Verify & Continue"})]}),q?.id==="protection"&&(0,t.jsxs)("div",{children:[(0,t.jsx)("h2",{className:"text-sm font-semibold text-text mb-3",children:"Branch Protection"}),(0,t.jsxs)("p",{className:"text-[11px] text-text-muted mb-3",children:["Configure branch protection on ",(0,t.jsx)("code",{className:"text-accent",children:"main"}),". Run these commands or configure via GitHub UI:"]}),(0,t.jsxs)("div",{className:"border border-border bg-bg-surface p-3 mb-3 text-[11px] space-y-2",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"text-text-muted mb-1",children:"Enable branch protection via gh CLI:"}),(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)("code",{className:"text-accent flex-1 select-all",children:`gh api repos/${p}/branches/main/protection -X PUT -f "required_pull_request_reviews[required_approving_review_count]=1" -f "enforce_admins=false" -f "required_status_checks=null" -f "restrictions=null"`}),(0,t.jsx)("button",{onClick:()=>navigator.clipboard.writeText(`gh api repos/${p}/branches/main/protection -X PUT -f "required_pull_request_reviews[required_approving_review_count]=1" -f "enforce_admins=false" -f "required_status_checks=null" -f "restrictions=null"`),className:"text-[10px] text-text-muted hover:text-accent shrink-0",children:"copy"})]})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"text-text-muted mb-1",children:"Or manually in GitHub UI:"}),(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)("code",{className:"text-accent flex-1 select-all",children:`https://github.com/${p}/settings/branches`}),(0,t.jsx)("button",{onClick:()=>navigator.clipboard.writeText(`https://github.com/${p}/settings/branches`),className:"text-[10px] text-text-muted hover:text-accent shrink-0",children:"copy"})]}),(0,t.jsx)("p",{className:"text-text mt-1",children:'→ Add rule for "main" → Require 1 approval → Save'})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"text-text-muted mb-1",children:"Add reviewer as collaborator (replace USERNAME):"}),(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)("code",{className:"text-accent flex-1 select-all",children:`gh api repos/${p}/collaborators/USERNAME -X PUT -f permission=push`}),(0,t.jsx)("button",{onClick:()=>navigator.clipboard.writeText(`gh api repos/${p}/collaborators/USERNAME -X PUT -f permission=push`),className:"text-[10px] text-text-muted hover:text-accent shrink-0",children:"copy"})]})]})]}),(0,t.jsxs)("div",{className:"flex gap-2",children:[(0,t.jsx)("button",{onClick:S,className:"px-4 py-1.5 bg-accent text-bg text-[12px] font-semibold hover:bg-accent-dim transition-colors",children:"Done"}),(0,t.jsx)("button",{onClick:R,className:"px-3 py-1.5 text-[12px] text-text-muted border border-border hover:text-text transition-colors",children:"Skip"})]})]}),q?.id==="backend"&&(0,t.jsxs)("div",{children:[(0,t.jsx)("h2",{className:"text-sm font-semibold text-text mb-3",children:"CLI Backend per Agent"}),(0,t.jsx)("div",{className:"border border-border mb-3",children:["head","reviewer1","reviewer2","dev"].map(e=>(0,t.jsxs)("div",{className:"flex items-center justify-between px-3 py-1.5 border-b border-border/50 last:border-b-0",children:[(0,t.jsx)("span",{className:"text-[11px] text-text font-semibold w-10",children:e.charAt(0).toUpperCase()+e.slice(1)}),(0,t.jsx)("span",{className:"text-[10px] text-text-muted w-16",children:"head"===e?"Owner":e.startsWith("reviewer")?"Reviewer":"Builder"}),(0,t.jsx)("select",{value:u[e],onChange:t=>g({...u,[e]:t.target.value}),className:"bg-transparent border border-border px-2 py-0.5 text-[11px] text-text outline-none focus:border-accent cursor-pointer",children:o.map(e=>(0,t.jsx)("option",{value:e.value,className:"bg-bg-surface",children:e.label},e.value))})]},e))}),(0,t.jsx)("h2",{className:"text-sm font-semibold text-text mb-2 mt-4",children:"Reviewer Credentials"}),(0,t.jsx)("p",{className:"text-[11px] text-text-muted mb-2",children:"Used by reviewer1/reviewer2 to post GitHub reviews"}),(0,t.jsx)("input",{value:v,onChange:e=>N(e.target.value),placeholder:"Reviewer GitHub username",className:"w-full bg-transparent border border-border px-2 py-1.5 text-[12px] text-text outline-none focus:border-accent mb-2"}),(0,t.jsx)("input",{value:k,onChange:e=>w(e.target.value),placeholder:"Token file path (default: ~/.quadwork/reviewer-token)",className:"w-full bg-transparent border border-border px-2 py-1.5 text-[12px] text-text outline-none focus:border-accent mb-3"}),(0,t.jsx)("button",{onClick:S,className:"px-4 py-1.5 bg-accent text-bg text-[12px] font-semibold hover:bg-accent-dim transition-colors",children:"Next"})]}),q?.id==="workdir"&&(0,t.jsxs)("div",{children:[(0,t.jsx)("h2",{className:"text-sm font-semibold text-text mb-3",children:"Working Directory"}),(0,t.jsx)("input",{value:j,onChange:e=>f(e.target.value),placeholder:"/path/to/project",className:"w-full bg-transparent border border-border px-2 py-1.5 text-[12px] text-text outline-none focus:border-accent mb-3"}),(0,t.jsx)("button",{onClick:S,disabled:!j,className:"px-4 py-1.5 bg-accent text-bg text-[12px] font-semibold hover:bg-accent-dim transition-colors disabled:opacity-50",children:"Next"})]}),q?.id==="worktrees"&&(0,t.jsxs)("div",{children:[(0,t.jsx)("h2",{className:"text-sm font-semibold text-text mb-3",children:"Create Worktrees"}),(0,t.jsxs)("p",{className:"text-[11px] text-text-muted mb-3",children:["Creates 4 git worktrees as sibling directories: ",(0,t.jsx)("code",{className:"text-accent",children:j?`${j.split("/").pop()}-head/`:"project-head/"}),", etc."]}),q.error&&(0,t.jsx)("p",{className:"text-[11px] text-error mb-2",children:q.error}),(0,t.jsxs)("div",{className:"flex gap-2",children:[(0,t.jsx)("button",{onClick:T,disabled:y,className:"px-4 py-1.5 bg-accent text-bg text-[12px] font-semibold hover:bg-accent-dim transition-colors disabled:opacity-50",children:y?"Creating...":"Create Worktrees"}),(0,t.jsx)("button",{onClick:R,className:"px-3 py-1.5 text-[12px] text-text-muted border border-border hover:text-text transition-colors",children:"Skip"})]})]}),q?.id==="seeds"&&(0,t.jsxs)("div",{children:[(0,t.jsx)("h2",{className:"text-sm font-semibold text-text mb-3",children:"Seed Files"}),(0,t.jsx)("p",{className:"text-[11px] text-text-muted mb-3",children:"Creates default AGENTS.md + CLAUDE.md in each worktree"}),q.error&&(0,t.jsx)("p",{className:"text-[11px] text-error mb-2",children:q.error}),(0,t.jsxs)("div",{className:"flex gap-2",children:[(0,t.jsx)("button",{onClick:P,disabled:y,className:"px-4 py-1.5 bg-accent text-bg text-[12px] font-semibold hover:bg-accent-dim transition-colors disabled:opacity-50",children:y?"Creating...":"Create Seed Files"}),(0,t.jsx)("button",{onClick:R,className:"px-3 py-1.5 text-[12px] text-text-muted border border-border hover:text-text transition-colors",children:"Skip"})]})]}),q?.id==="agentchattr"&&(0,t.jsxs)("div",{children:[(0,t.jsx)("h2",{className:"text-sm font-semibold text-text mb-3",children:"AgentChattr Configuration"}),(0,t.jsx)("p",{className:"text-[11px] text-text-muted mb-3",children:"Add agents to AgentChattr config.toml and restart the server."}),q.error&&(0,t.jsx)("p",{className:"text-[11px] text-error mb-2",children:q.error}),(0,t.jsxs)("div",{className:"flex gap-2",children:[(0,t.jsx)("button",{onClick:async()=>{let e=8300,t=8200,r=8201;try{let s=await fetch("/api/config");if(s.ok){let a=await s.json(),o=new Set((a.projects||[]).map(e=>{try{return parseInt(new URL(e.agentchattr_url||"").port,10)}catch{return 0}}).filter(Boolean)),n=new Set((a.projects||[]).flatMap(e=>[e.mcp_http_port,e.mcp_sse_port]).filter(Boolean));for(;o.has(e);)e++;for(;n.has(t);)t++;for(r=t+1;n.has(r);)r++}}catch{}let s=await U("agentchattr-config",{workingDir:j,projectName:d,repo:p,backends:u,agentchattr_port:e,mcp_http_port:t,mcp_sse_port:r});s.ok?(h({agentchattr_token:s.agentchattr_token,agentchattr_port:s.agentchattr_port,mcp_http_port:s.mcp_http_port,mcp_sse_port:s.mcp_sse_port}),S()):_(i,{status:"error",error:s.error})},disabled:y,className:"px-4 py-1.5 bg-accent text-bg text-[12px] font-semibold hover:bg-accent-dim transition-colors disabled:opacity-50",children:y?"Updating...":"Update AgentChattr Config"}),(0,t.jsx)("button",{onClick:R,className:"px-3 py-1.5 text-[12px] text-text-muted border border-border hover:text-text transition-colors",children:"Skip"})]})]}),q?.id==="config"&&(0,t.jsxs)("div",{children:[(0,t.jsx)("h2",{className:"text-sm font-semibold text-text mb-3",children:"Save Configuration"}),(0,t.jsxs)("div",{className:"border border-border bg-bg-surface p-3 mb-3 text-[11px] text-text space-y-1",children:[(0,t.jsxs)("p",{children:[(0,t.jsx)("strong",{children:"Name:"})," ",d]}),(0,t.jsxs)("p",{children:[(0,t.jsx)("strong",{children:"Repo:"})," ",p]}),(0,t.jsxs)("p",{children:[(0,t.jsx)("strong",{children:"Backends:"})," ",Object.entries(u).map(([e,t])=>`${e.toUpperCase()}=${t}`).join(", ")]}),(0,t.jsxs)("p",{children:[(0,t.jsx)("strong",{children:"Directory:"})," ",j]}),(0,t.jsxs)("p",{children:[(0,t.jsx)("strong",{children:"Agents:"})," Head, Reviewer1, Reviewer2, Dev"]})]}),q.error&&(0,t.jsx)("p",{className:"text-[11px] text-error mb-2",children:q.error}),(0,t.jsx)("button",{onClick:$,disabled:y,className:"px-4 py-1.5 bg-accent text-bg text-[12px] font-semibold hover:bg-accent-dim transition-colors disabled:opacity-50",children:y?"Saving...":"Save & Open Project"})]}),i>=n.length&&(0,t.jsxs)("div",{className:"text-center py-8",children:[(0,t.jsx)("p",{className:"text-accent text-sm font-semibold",children:"Setup complete!"}),(0,t.jsx)("p",{className:"text-[11px] text-text-muted mt-2",children:"Redirecting to project dashboard..."})]})]})]})]})}])}]);
@@ -0,0 +1 @@
1
+ (globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,69513,e=>{"use strict";var t=e.i(85899),r=e.i(4232),a=e.i(16353);let s={head:{display_name:"Head",command:"claude",cwd:"",model:"opus",agents_md:""},reviewer1:{display_name:"Reviewer1",command:"claude",cwd:"",model:"sonnet",agents_md:""},reviewer2:{display_name:"Reviewer2",command:"claude",cwd:"",model:"sonnet",agents_md:""},dev:{display_name:"Dev",command:"claude",cwd:"",model:"sonnet",agents_md:""}},n=[{value:"claude",label:"Claude Code"},{value:"codex",label:"Codex"}],l=["opus","sonnet","haiku"];function o({label:e,value:r,onChange:a,type:s="text",placeholder:n}){return(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,t.jsx)("label",{className:"text-[11px] text-text-muted uppercase tracking-wider",children:e}),(0,t.jsx)("input",{type:s,value:r,onChange:e=>a(e.target.value),placeholder:n,className:"bg-transparent border border-border px-2 py-1.5 text-[12px] text-text outline-none focus:border-accent"})]})}function d({label:e,value:r,onChange:a,options:s}){return(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,t.jsx)("label",{className:"text-[11px] text-text-muted uppercase tracking-wider",children:e}),(0,t.jsx)("select",{value:r,onChange:e=>a(e.target.value),className:"bg-transparent border border-border px-2 py-1.5 text-[12px] text-text outline-none focus:border-accent cursor-pointer",children:s.map(e=>(0,t.jsx)("option",{value:e.value,className:"bg-bg-surface",children:e.label},e.value))})]})}e.s(["default",0,function(){let e=(0,a.useSearchParams)(),[c,i]=(0,r.useState)(null),[x,p]=(0,r.useState)(!1),[m,h]=(0,r.useState)(!1),[b,u]=(0,r.useState)({}),[g,j]=(0,r.useState)(null),[v,f]=(0,r.useState)(!1),[N,_]=(0,r.useState)({}),y=(0,r.useCallback)(()=>{fetch("/api/config").then(e=>{if(!e.ok)throw Error(`${e.status}`);return e.json()}).then(e=>i({port:e.port||8400,agentchattr_url:e.agentchattr_url||"http://127.0.0.1:8300",agentchattr_token:e.agentchattr_token||"",default_backend:e.default_backend||"claude",projects:e.projects||[]})).catch(()=>{})},[]);(0,r.useEffect)(()=>{y()},[y]),(0,r.useEffect)(()=>{if(c)for(let e of c.projects)e.telegram?.bot_token&&fetch(`/api/telegram?project=${encodeURIComponent(e.id)}`).then(e=>e.ok?e.json():null).then(t=>{t&&_(r=>({...r,[e.id]:t.running}))}).catch(()=>{})},[c]),(0,r.useEffect)(()=>{c&&"true"===e.get("add")&&!v&&(f(!0),$())},[c,e,v]);let C=async()=>{if(c){p(!0);try{let e=JSON.parse(JSON.stringify(c));for(let t of e.projects)if(t.telegram?.bot_token&&!t.telegram.bot_token.startsWith("env:")){await fetch("/api/telegram?action=save-token",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({project_id:t.id,bot_token:t.telegram.bot_token})});let e=`TELEGRAM_BOT_TOKEN_${t.id.toUpperCase().replace(/[^A-Z0-9]/g,"_")}`;t.telegram.bot_token=`env:${e}`}let t=await fetch("/api/config",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(!t.ok)throw Error(`${t.status}`);h(!0),setTimeout(()=>h(!1),2e3)}catch(e){console.error(e)}p(!1)}},k=(e,t)=>{c&&i({...c,[e]:t})},w=(e,t)=>{if(!c)return;let r=[...c.projects];r[e]={...r[e],...t},i({...c,projects:r})},S=(e,t,r)=>{if(!c)return;let a=[...c.projects],s={...a[e].agents};s[t]={...s[t],...r},a[e]={...a[e],agents:s},i({...c,projects:a})},T=(e,t)=>{if(!c)return;let r=[...c.projects],a={enabled:!1,bot_token:"",chat_id:"",...r[e].telegram,...t};r[e]={...r[e],telegram:a},i({...c,projects:r})},$=()=>{if(!c)return;let e=`project-${Date.now()}`,t={id:e,name:"New Project",repo:"owner/repo",working_dir:"",agents:{...s}};i({...c,projects:[...c.projects,t]}),u({...b,[e]:!0})},O=(0,r.useRef)({}),P=(0,r.useRef)({}),R=e=>{c&&w(e,{archived:!1})},E=e=>{if(!c)return;let t=c.projects.filter((t,r)=>r!==e);i({...c,projects:t}),j(null)};return c?(0,t.jsxs)("div",{className:"h-full overflow-y-auto p-6 max-w-3xl",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between mb-6",children:[(0,t.jsx)("h1",{className:"text-lg font-semibold text-text tracking-tight",children:"Settings"}),(0,t.jsx)("button",{onClick:C,disabled:x,className:"px-4 py-1.5 bg-accent text-bg text-[12px] font-semibold hover:bg-accent-dim transition-colors disabled:opacity-50",children:x?"Saving...":m?"Saved":"Save"})]}),(0,t.jsxs)("section",{className:"mb-6",children:[(0,t.jsx)("h2",{className:"text-[11px] text-text-muted uppercase tracking-wider mb-3",children:"Global"}),(0,t.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-3",children:[(0,t.jsx)(o,{label:"AgentChattr URL",value:c.agentchattr_url,onChange:e=>k("agentchattr_url",e),placeholder:"http://127.0.0.1:8300"}),(0,t.jsx)(d,{label:"Default CLI Backend",value:c.default_backend,onChange:e=>k("default_backend",e),options:n}),(0,t.jsx)(o,{label:"QuadWork Port",value:String(c.port),onChange:e=>k("port",parseInt(e,10)||8400),type:"number"})]})]}),(0,t.jsx)("hr",{className:"border-border mb-6"}),(0,t.jsxs)("section",{className:"mb-6",children:[(0,t.jsx)("h2",{className:"text-[11px] text-text-muted uppercase tracking-wider mb-3",children:"Active Projects"}),c.projects.filter(e=>!e.archived).map(e=>{let r=c.projects.indexOf(e),a=b[e.id]??!1,s=e.telegram||{enabled:!1,bot_token:"",chat_id:""};return(0,t.jsxs)("div",{className:"border border-border mb-3",children:[(0,t.jsxs)("button",{className:"w-full flex items-center justify-between px-3 py-2 hover:bg-[#1a1a1a] transition-colors",onClick:()=>u({...b,[e.id]:!a}),children:[(0,t.jsx)("span",{className:"text-[12px] text-text font-semibold",children:e.name}),(0,t.jsx)("span",{className:"text-[11px] text-text-muted",children:a?"▾":"▸"})]}),a&&(0,t.jsxs)("div",{className:"px-3 pb-3 border-t border-border",children:[(0,t.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-3 mt-3",children:[(0,t.jsx)(o,{label:"Project Name",value:e.name,onChange:e=>((e,t)=>{if(!c)return;let r=c.projects[e],a=`project:${r.id}`;a in O.current||(O.current[a]=r.name),w(e,{name:t}),P.current[a]&&clearTimeout(P.current[a]),P.current[a]=setTimeout(()=>{let e=O.current[a];e&&e!==t&&fetch("/api/rename",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({type:"project",projectId:r.id,oldName:e,newName:t})}).then(()=>y()).catch(()=>{}),delete O.current[a],delete P.current[a]},800)})(r,e)}),(0,t.jsx)(o,{label:"GitHub Repo",value:e.repo,onChange:e=>w(r,{repo:e}),placeholder:"owner/repo"}),(0,t.jsx)(o,{label:"Working Directory",value:e.working_dir||"",onChange:e=>w(r,{working_dir:e}),placeholder:"/path/to/project"})]}),(0,t.jsxs)("div",{className:"mt-4",children:[(0,t.jsx)("h3",{className:"text-[10px] text-text-muted uppercase tracking-wider mb-2",children:"Agents"}),(0,t.jsxs)("div",{className:"border border-border",children:[(0,t.jsxs)("div",{className:"grid grid-cols-5 gap-0 px-2 py-1 border-b border-border text-[10px] text-text-muted uppercase",children:[(0,t.jsx)("span",{children:"Name"}),(0,t.jsx)("span",{children:"Command"}),(0,t.jsx)("span",{children:"Model"}),(0,t.jsx)("span",{children:"CWD"}),(0,t.jsx)("span",{children:"AGENTS.md"})]}),Object.entries(e.agents||{}).map(([a,s])=>(0,t.jsxs)("div",{className:"border-b border-border/50 last:border-b-0",children:[(0,t.jsxs)("div",{className:"grid grid-cols-5 gap-0 px-2 py-1",children:[(0,t.jsxs)("div",{className:"flex flex-col gap-0.5",children:[(0,t.jsx)("input",{value:s.display_name||a.toUpperCase(),onChange:e=>((e,t,r)=>{if(!c)return;let a=c.projects[e],s=a.agents?.[t],n=`agent:${a.id}:${t}`;n in O.current||(O.current[n]=s?.display_name||t.toUpperCase()),S(e,t,{display_name:r}),P.current[n]&&clearTimeout(P.current[n]),P.current[n]=setTimeout(()=>{let e=O.current[n];e&&e!==r&&fetch("/api/rename",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({type:"agent",projectId:a.id,agentId:t,oldName:e,newName:r})}).then(()=>y()).catch(()=>{}),delete O.current[n],delete P.current[n]},800)})(r,a,e.target.value),className:"bg-transparent text-[11px] text-text font-semibold outline-none border border-border px-1 py-0.5 focus:border-accent"}),(0,t.jsx)("span",{className:"text-[9px] text-text-muted px-1",children:"head"===a?"Owner":a.startsWith("reviewer")?"Reviewer":"Builder"})]}),(0,t.jsx)("select",{value:s.command||"claude",onChange:e=>S(r,a,{command:e.target.value}),className:"bg-transparent text-[11px] text-text outline-none border border-border px-1 py-0.5 focus:border-accent",children:n.map(e=>(0,t.jsx)("option",{value:e.value,className:"bg-bg-surface",children:e.label},e.value))}),(0,t.jsx)("select",{value:s.model||"sonnet",onChange:e=>S(r,a,{model:e.target.value}),className:"bg-transparent text-[11px] text-text outline-none border border-border px-1 py-0.5 focus:border-accent",children:l.map(e=>(0,t.jsx)("option",{value:e,className:"bg-bg-surface",children:e},e))}),(0,t.jsx)("input",{value:s.cwd||"",onChange:e=>S(r,a,{cwd:e.target.value}),placeholder:"/path/to/worktree",className:"bg-transparent text-[11px] text-text outline-none border border-border px-1 py-0.5 focus:border-accent"}),(0,t.jsx)("button",{onClick:()=>u({...b,[`${e.id}-${a}-md`]:!b[`${e.id}-${a}-md`]}),className:"text-[10px] text-text-muted hover:text-accent transition-colors text-left px-1",children:b[`${e.id}-${a}-md`]?"▾ edit":"▸ edit"})]}),b[`${e.id}-${a}-md`]&&(0,t.jsx)("div",{className:"px-2 pb-2",children:(0,t.jsx)("textarea",{value:s.agents_md||"",onChange:e=>S(r,a,{agents_md:e.target.value}),placeholder:"# AGENTS.md seed content for this agent...",rows:8,className:"w-full bg-transparent border border-border px-2 py-1.5 text-[11px] text-text outline-none focus:border-accent resize-y"})})]},a))]})]}),(0,t.jsxs)("div",{className:"mt-4",children:[(0,t.jsx)("h3",{className:"text-[10px] text-text-muted uppercase tracking-wider mb-2",children:"AgentChattr"}),(0,t.jsx)("div",{className:"border border-border p-3",children:(0,t.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:[(0,t.jsx)(o,{label:"AgentChattr URL",value:e.agentchattr_url||"",onChange:e=>w(r,{agentchattr_url:e}),placeholder:"http://127.0.0.1:8300"}),(0,t.jsx)(o,{label:"Session Token",value:e.agentchattr_token||"",onChange:e=>w(r,{agentchattr_token:e}),placeholder:"(optional)"}),(0,t.jsx)(o,{label:"MCP HTTP Port",value:String(e.mcp_http_port||""),onChange:e=>w(r,{mcp_http_port:parseInt(e,10)||void 0}),type:"number",placeholder:"8200"}),(0,t.jsx)(o,{label:"MCP SSE Port",value:String(e.mcp_sse_port||""),onChange:e=>w(r,{mcp_sse_port:parseInt(e,10)||void 0}),type:"number",placeholder:"8201"})]})})]}),(0,t.jsxs)("div",{className:"mt-4",children:[(0,t.jsx)("h3",{className:"text-[10px] text-text-muted uppercase tracking-wider mb-2",children:"Scheduled Trigger"}),(0,t.jsxs)("div",{className:"border border-border p-3",children:[(0,t.jsxs)("div",{className:"flex items-center gap-3 mb-3",children:[(0,t.jsx)("button",{onClick:()=>w(r,{trigger_enabled:!e.trigger_enabled}),className:`w-8 h-4 rounded-full transition-colors relative ${e.trigger_enabled?"bg-accent":"bg-border"}`,children:(0,t.jsx)("span",{className:`absolute top-0.5 w-3 h-3 rounded-full bg-text transition-transform ${e.trigger_enabled?"left-4":"left-0.5"}`})}),(0,t.jsx)("span",{className:"text-[11px] text-text",children:e.trigger_enabled?"Enabled":"Disabled"})]}),(0,t.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3 mb-3",children:[(0,t.jsx)(o,{label:"Interval (minutes)",value:String(e.trigger_interval||30),onChange:e=>w(r,{trigger_interval:parseInt(e,10)||30}),type:"number"}),(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,t.jsx)("label",{className:"text-[11px] text-text-muted uppercase tracking-wider",children:"Message Template"}),(0,t.jsx)("textarea",{value:e.trigger_message||"",onChange:e=>w(r,{trigger_message:e.target.value}),placeholder:"@head @reviewer1 @reviewer2 @dev — Queue check...",rows:4,className:"bg-transparent border border-border px-2 py-1.5 text-[11px] text-text outline-none focus:border-accent resize-y"})]})]})]})]}),(0,t.jsxs)("div",{className:"mt-4",children:[(0,t.jsx)("h3",{className:"text-[10px] text-text-muted uppercase tracking-wider mb-2",children:"Telegram Bridge"}),(0,t.jsxs)("div",{className:"border border-border p-3",children:[(0,t.jsxs)("div",{className:"flex items-center gap-3 mb-3",children:[(0,t.jsx)("button",{onClick:()=>T(r,{enabled:!s.enabled}),className:`w-8 h-4 rounded-full transition-colors relative ${s.enabled?"bg-accent":"bg-border"}`,children:(0,t.jsx)("span",{className:`absolute top-0.5 w-3 h-3 rounded-full bg-text transition-transform ${s.enabled?"left-4":"left-0.5"}`})}),(0,t.jsx)("span",{className:"text-[11px] text-text",children:s.enabled?"Enabled":"Disabled"}),(0,t.jsx)("span",{className:"text-[11px] text-text-muted",children:"·"}),(0,t.jsx)("span",{className:`w-1.5 h-1.5 rounded-full ${N[e.id]?"bg-accent":"bg-text-muted"}`}),(0,t.jsx)("span",{className:"text-[11px] text-text-muted",children:N[e.id]?"running":"stopped"})]}),(0,t.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3 mb-3",children:[(0,t.jsx)(o,{label:"Bot Token",value:s.bot_token,onChange:e=>T(r,{bot_token:e}),type:"password",placeholder:"123456:ABC-DEF..."}),(0,t.jsx)(o,{label:"Chat ID",value:s.chat_id,onChange:e=>T(r,{chat_id:e}),placeholder:"-1001234567890"})]}),(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)("button",{onClick:()=>{fetch("/api/telegram?action=test",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({bot_token:s.bot_token,chat_id:s.chat_id})}).then(e=>e.json()).then(e=>alert(e.ok?"Connection OK":`Error: ${e.error}`)).catch(()=>alert("Test failed"))},className:"px-2 py-1 text-[11px] border border-border text-text-muted hover:text-text hover:border-accent transition-colors",children:"Test Connection"}),(0,t.jsx)("button",{onClick:()=>{fetch("/api/telegram?action=install",{method:"POST"}).then(e=>e.json()).then(e=>alert(e.ok?"Installed":`Error: ${e.error}`)).catch(()=>alert("Install failed"))},className:"px-2 py-1 text-[11px] border border-border text-text-muted hover:text-text hover:border-accent transition-colors",children:"Install Bridge"}),(0,t.jsx)("button",{onClick:()=>{let t=N[e.id]?"stop":"start";fetch(`/api/telegram?action=${t}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({project_id:e.id})}).then(e=>e.json()).then(t=>{t.ok?_(r=>({...r,[e.id]:t.running})):alert(`Error: ${t.error}`)}).catch(()=>alert(`${t} failed`))},className:`px-2 py-1 text-[11px] border border-border transition-colors ${N[e.id]?"text-error hover:border-error":"text-accent hover:border-accent"}`,children:N[e.id]?"Stop Daemon":"Start Daemon"})]})]})]}),(0,t.jsxs)("div",{className:"mt-4 flex justify-end gap-3",children:[e.archived?(0,t.jsx)("button",{onClick:()=>R(r),className:"text-[11px] text-accent hover:underline",children:"Restore Project"}):(0,t.jsx)("button",{onClick:()=>{c&&w(r,{archived:!0})},className:"text-[11px] text-text-muted hover:text-text transition-colors",children:"Archive"}),g===e.id?(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)("span",{className:"text-[11px] text-error",children:"Remove?"}),(0,t.jsx)("button",{onClick:()=>E(r),className:"px-2 py-1 text-[11px] bg-error text-bg font-semibold",children:"Confirm"}),(0,t.jsx)("button",{onClick:()=>j(null),className:"px-2 py-1 text-[11px] text-text-muted border border-border",children:"Cancel"})]}):(0,t.jsx)("button",{onClick:()=>j(e.id),className:"text-[11px] text-error hover:text-text transition-colors",children:"Remove"})]})]})]},e.id)}),(0,t.jsx)("button",{onClick:$,className:"w-full border border-dashed border-border py-2 text-[12px] text-text-muted hover:text-text hover:border-text-muted transition-colors",children:"+ Add Project"}),c.projects.some(e=>e.archived)&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("hr",{className:"border-border my-4"}),(0,t.jsx)("h2",{className:"text-[11px] text-text-muted uppercase tracking-wider mb-3",children:"Archived"}),c.projects.filter(e=>e.archived).map(e=>{let r=c.projects.indexOf(e);return(0,t.jsx)("div",{className:"border border-border mb-3 opacity-60",children:(0,t.jsxs)("div",{className:"flex items-center justify-between px-3 py-2",children:[(0,t.jsx)("span",{className:"text-[12px] text-text-muted",children:e.name}),(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)("button",{onClick:()=>R(r),className:"text-[11px] text-accent hover:underline",children:"Restore"}),(0,t.jsx)("button",{onClick:()=>{g===e.id?E(r):j(e.id)},className:"text-[11px] text-error hover:underline",children:g===e.id?"Confirm Remove":"Remove"})]})]})},e.id)})]})]}),(0,t.jsx)("div",{className:"flex justify-end pb-6",children:(0,t.jsx)("button",{onClick:C,disabled:x,className:"px-4 py-1.5 bg-accent text-bg text-[12px] font-semibold hover:bg-accent-dim transition-colors disabled:opacity-50",children:x?"Saving...":m?"Saved":"Save"})})]}):(0,t.jsx)("div",{className:"p-6 text-text-muted text-xs",children:"Loading..."})}])}]);