werkmeister 0.96.4 → 0.96.6

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 (165) hide show
  1. package/dist/{budget-AMYNP35Q.js → budget-TUUI6WGZ.js} +2 -2
  2. package/dist/{cache-O3A5YBOT.js → cache-5OJXOLPF.js} +2 -2
  3. package/dist/{chunk-5IZDNFW6.js → chunk-2DZPE4HK.js} +2 -2
  4. package/dist/{chunk-53U2A5BU.js → chunk-2PAYCFDX.js} +2 -2
  5. package/dist/chunk-2R3TTVDD.js +5 -0
  6. package/dist/{chunk-GRX5O3CX.js → chunk-3EZX2NCC.js} +2 -2
  7. package/dist/chunk-3P2IUJ55.js +4 -0
  8. package/dist/{chunk-5RJFHLF4.js → chunk-43O2Z5F5.js} +6 -4
  9. package/dist/{chunk-KWH5X47W.js → chunk-443FHHSF.js} +2 -2
  10. package/dist/chunk-4HRKQKPW.js +6 -0
  11. package/dist/{chunk-EFTOYYTO.js → chunk-4Q5N4VVF.js} +2 -2
  12. package/dist/{chunk-JWVF334V.js → chunk-4ZXCC7N3.js} +2 -2
  13. package/dist/{chunk-JAOYJTT5.js → chunk-6XH3UM4W.js} +2 -2
  14. package/dist/{chunk-EPG7SWWC.js → chunk-7FLMMXQA.js} +2 -2
  15. package/dist/{chunk-V55RPDDX.js → chunk-7QEZMWPN.js} +2 -2
  16. package/dist/{chunk-ECSZJBNR.js → chunk-7QYU5PXD.js} +3 -3
  17. package/dist/{chunk-TNP5EKIO.js → chunk-AAM2FUZU.js} +2 -2
  18. package/dist/{chunk-HCSAC5Z6.js → chunk-ABY7DNTE.js} +2 -2
  19. package/dist/{chunk-JQVE776N.js → chunk-AJULLWA3.js} +2 -2
  20. package/dist/{chunk-J4YFXJND.js → chunk-BA6RZ57Q.js} +2 -2
  21. package/dist/{chunk-GKBMMUVJ.js → chunk-C24472A2.js} +2 -2
  22. package/dist/{chunk-4YZNJIQH.js → chunk-CBH6SVWW.js} +9 -9
  23. package/dist/chunk-CRB7AFYE.js +5 -0
  24. package/dist/chunk-CRERPUL7.js +82 -0
  25. package/dist/{chunk-WGFW7GL5.js → chunk-CXEPCQWZ.js} +2 -2
  26. package/dist/{chunk-BXNZOPMH.js → chunk-DA3UKURI.js} +3 -3
  27. package/dist/{chunk-3BPJRRF7.js → chunk-DAXUO6CD.js} +2 -2
  28. package/dist/{chunk-YYW2A7QM.js → chunk-DOTKDY53.js} +2 -2
  29. package/dist/{chunk-YRSIDQWL.js → chunk-EJFZWVFV.js} +2 -2
  30. package/dist/{chunk-4XASPQ6S.js → chunk-ENQNDPDP.js} +2 -2
  31. package/dist/{chunk-H5J25ZSC.js → chunk-ESYNFLSX.js} +2 -2
  32. package/dist/{chunk-WM7YOMQ4.js → chunk-FLYJZMJ4.js} +2 -2
  33. package/dist/{chunk-S4BBOGT6.js → chunk-GLJAGFNV.js} +2 -2
  34. package/dist/chunk-GRAAEXFE.js +71 -0
  35. package/dist/{chunk-5I6P3ZRZ.js → chunk-HPC4HZHD.js} +2 -2
  36. package/dist/{chunk-OJP6MUR6.js → chunk-ICBOFT25.js} +27 -3
  37. package/dist/{chunk-7VY2VMT3.js → chunk-IE4Y2XO4.js} +2 -2
  38. package/dist/{chunk-PQ3JOJF3.js → chunk-IJXRJHSE.js} +2 -2
  39. package/dist/{chunk-77HMVQR2.js → chunk-IKFNWBKS.js} +2 -2
  40. package/dist/{chunk-JPUELP4B.js → chunk-J2RRXPO6.js} +2 -2
  41. package/dist/{chunk-RGCJAFJX.js → chunk-J3243TDQ.js} +2 -2
  42. package/dist/{chunk-TXV3Q4D6.js → chunk-J3UHZQ2C.js} +2 -2
  43. package/dist/{chunk-PUJ267YF.js → chunk-K7PSTFHC.js} +2 -2
  44. package/dist/{chunk-O63RZA5G.js → chunk-KD5W3PUQ.js} +2 -2
  45. package/dist/{chunk-CKAM5T7Z.js → chunk-KLTQPIKL.js} +2 -2
  46. package/dist/chunk-KSUN7ZZK.js +146 -0
  47. package/dist/{chunk-2ZG5AQX6.js → chunk-LR4VZKK7.js} +2 -2
  48. package/dist/{chunk-OCSOMTAL.js → chunk-M7OLABFX.js} +2 -2
  49. package/dist/{chunk-AZGVJNBV.js → chunk-MHICRT4W.js} +3 -3
  50. package/dist/{chunk-JWK5KGBL.js → chunk-NWVBEWIZ.js} +2 -2
  51. package/dist/chunk-NZNWTE7L.js +119 -0
  52. package/dist/{chunk-D7OZEJBT.js → chunk-OZ54CGVR.js} +2 -2
  53. package/dist/{chunk-V2LECRKO.js → chunk-P4LYRKV2.js} +2 -2
  54. package/dist/{chunk-JBWSCNJ7.js → chunk-PNWBVVCB.js} +3 -3
  55. package/dist/{chunk-BHUT6E4G.js → chunk-Q3X77IN7.js} +2 -2
  56. package/dist/{chunk-YJ4BIMHP.js → chunk-QM23FCOA.js} +3 -3
  57. package/dist/{chunk-FBY2ENLK.js → chunk-ST6VN3TA.js} +2 -2
  58. package/dist/{chunk-5LW27KVM.js → chunk-SUESH3BY.js} +2 -2
  59. package/dist/{chunk-6PJBB7KP.js → chunk-U7F7OEJD.js} +2 -2
  60. package/dist/chunk-URWDJ4PG.js +4 -0
  61. package/dist/{chunk-I6JW6UJH.js → chunk-WH3SI5C7.js} +2 -2
  62. package/dist/{chunk-J45TDLET.js → chunk-XSPQUCPB.js} +2 -2
  63. package/dist/{chunk-DTHTT2LY.js → chunk-YAELVAID.js} +2 -2
  64. package/dist/{chunk-2TBRFIOS.js → chunk-YXE7P3P3.js} +2 -2
  65. package/dist/{chunk-6452JOFU.js → chunk-Z5T3QBI7.js} +2 -2
  66. package/dist/{chunk-U3B6LQPC.js → chunk-ZX55PJPG.js} +2 -2
  67. package/dist/clean-QW3IDVG7.js +8 -0
  68. package/dist/close_out-KSCU6ND2.js +8 -0
  69. package/dist/code-WPYJXPAJ.js +4 -0
  70. package/dist/{config-JSOAPK5M.js → config-CCIEE7DF.js} +2 -2
  71. package/dist/{connect-IUHCNO7V.js → connect-3C63UXYD.js} +2 -2
  72. package/dist/{daemon-JVYDS5HP.js → daemon-FDJYZS47.js} +2 -2
  73. package/dist/dashboard.js +1 -1
  74. package/dist/{detect-VR2C4V5H.js → detect-SCJGDHTL.js} +2 -2
  75. package/dist/{down-3F3SQT2G.js → down-Z2YDS76D.js} +3 -3
  76. package/dist/fixture-EQ2DDG2K.js +131 -0
  77. package/dist/form-cli.js +1 -1
  78. package/dist/hooks-ZNOJ56SY.js +4 -0
  79. package/dist/hooks_gen-QBZ3WVYH.js +4 -0
  80. package/dist/infra-O7LRZU2X.js +4 -0
  81. package/dist/init_workspace-TUV4RE42.js +4 -0
  82. package/dist/{intercept-QVMMKOOT.js → intercept-GKECH33N.js} +2 -2
  83. package/dist/issue-4UFEXM3O.js +7 -0
  84. package/dist/lib/agent_state.js +1 -1
  85. package/dist/lib/gate.js +1 -1
  86. package/dist/lib/pr_guard.js +1 -1
  87. package/dist/list_workspaces-ALPDEO4R.js +7 -0
  88. package/dist/logs-F6HUT2FZ.js +6 -0
  89. package/dist/main.js +7 -3
  90. package/dist/mcp-proxy.js +1 -1
  91. package/dist/mcp.js +12 -12
  92. package/dist/migrate-2XENAGXU.js +8 -0
  93. package/dist/notes-6ICOGD4H.js +4 -0
  94. package/dist/{open-Q3P6W62M.js → open-QKSCQPPA.js} +2 -2
  95. package/dist/{optimize-PDBHKQHM.js → optimize-ATIAANUW.js} +2 -2
  96. package/dist/pause-AARC2ZPR.js +4 -0
  97. package/dist/pr-JSLZ2CRF.js +5 -0
  98. package/dist/proxy_reload-UQSOX3W2.js +6 -0
  99. package/dist/{registry-ZW467J6Z.js → registry-73YKPBWG.js} +2 -2
  100. package/dist/remove-57FABBTN.js +7 -0
  101. package/dist/remove_workspace-JXC4S52U.js +8 -0
  102. package/dist/restart-T3JTLGV5.js +8 -0
  103. package/dist/resume-5VW6EDOX.js +8 -0
  104. package/dist/{safari-7UKLWOC4.js → safari-B4PPMH4P.js} +2 -2
  105. package/dist/sandbox-SHAZUUYS.js +4 -0
  106. package/dist/{services-RKX5AGON.js → services-MEO4UL7D.js} +2 -2
  107. package/dist/{setup-OO7THSID.js → setup-3N7WOACF.js} +2 -2
  108. package/dist/skills-YXDBPRMQ.js +4 -0
  109. package/dist/{slots-ITKQMMI3.js → slots-M5CGDEDY.js} +2 -2
  110. package/dist/{standards-OOQ2WRYH.js → standards-YNJDI2AZ.js} +2 -2
  111. package/dist/start_args-ADKZTILR.js +4 -0
  112. package/dist/starting_prompt-SJBA5IQP.js +4 -0
  113. package/dist/stats-JNRK4PTB.js +4 -0
  114. package/dist/{status-DGAJ7I4I.js → status-2PRB2FD7.js} +2 -2
  115. package/dist/{stop-3GVL5ISA.js → stop-Z4DXCZLG.js} +2 -2
  116. package/dist/{telepresence-WW7RQX47.js → telepresence-4FJAS53H.js} +2 -2
  117. package/dist/{test-WGIKPWAP.js → test-ULK423I4.js} +2 -2
  118. package/dist/tokens-HNQZCIQO.js +6 -0
  119. package/dist/{up-4CJIZFEB.js → up-VRPRF3NW.js} +3 -3
  120. package/dist/{v4-F75QTHCA.js → v4-ETOSO3EW.js} +2 -2
  121. package/dist/wait_load-RJF5DXEJ.js +4 -0
  122. package/dist/werkmeister-workspaces.vsix +0 -0
  123. package/dist/workspace-R5LWQC63.js +4 -0
  124. package/infra/schemas/services-fragment.schema.json +7 -1
  125. package/infra/templates/docker-compose.feature.yml.njk +43 -3
  126. package/man/werkmeister-infra-intercept.1 +2 -0
  127. package/package.json +4 -4
  128. package/dist/chunk-4DRDOYPG.js +0 -6
  129. package/dist/chunk-5C33Q2UM.js +0 -5
  130. package/dist/chunk-7HLIUWNT.js +0 -118
  131. package/dist/chunk-FXDGCA5X.js +0 -82
  132. package/dist/chunk-GABPQOQE.js +0 -4
  133. package/dist/chunk-RXXC6UIL.js +0 -141
  134. package/dist/chunk-SQP3OIZA.js +0 -71
  135. package/dist/chunk-T5PZGDIV.js +0 -146
  136. package/dist/chunk-U6T4JBVH.js +0 -5
  137. package/dist/chunk-UUKSAZGH.js +0 -4
  138. package/dist/clean-CAHEPB2B.js +0 -8
  139. package/dist/close_out-SQRRCKLM.js +0 -8
  140. package/dist/code-PI6DJLWT.js +0 -4
  141. package/dist/fixture-CQAVWYXK.js +0 -18
  142. package/dist/hooks-S5WFEZX2.js +0 -4
  143. package/dist/hooks_gen-6QU32ZRN.js +0 -4
  144. package/dist/infra-CQGTSW2L.js +0 -4
  145. package/dist/init_workspace-XA2GO7V4.js +0 -4
  146. package/dist/issue-T444B2HD.js +0 -5
  147. package/dist/list_workspaces-B2356IRL.js +0 -7
  148. package/dist/logs-XGGQKDFA.js +0 -6
  149. package/dist/migrate-DYXEFSSV.js +0 -8
  150. package/dist/notes-JHYDSTDT.js +0 -4
  151. package/dist/pause-HXMPM7YA.js +0 -4
  152. package/dist/pr-BKZ7IK6C.js +0 -5
  153. package/dist/proxy_reload-LVY7RK2R.js +0 -6
  154. package/dist/remove-RG75N3KH.js +0 -7
  155. package/dist/remove_workspace-4NCDQRF2.js +0 -8
  156. package/dist/restart-NUWOA6CT.js +0 -8
  157. package/dist/resume-OS7VMBVR.js +0 -8
  158. package/dist/sandbox-UMMO5INO.js +0 -4
  159. package/dist/skills-J5XIVLHO.js +0 -4
  160. package/dist/start_args-6Q2XQSHO.js +0 -4
  161. package/dist/starting_prompt-UQNHP33P.js +0 -4
  162. package/dist/stats-32YBXOCR.js +0 -4
  163. package/dist/tokens-HCPRR7P5.js +0 -6
  164. package/dist/wait_load-AJSMYUT5.js +0 -4
  165. package/dist/workspace-6QP2COBQ.js +0 -4
@@ -1,4 +1,4 @@
1
1
  import { createRequire as __sandboxCreateRequire } from "node:module";
2
2
  const require = __sandboxCreateRequire(import.meta.url);
3
- import{e as x,n as L}from"./chunk-AZGVJNBV.js";import"./chunk-BHUT6E4G.js";import"./chunk-FXDGCA5X.js";import"./chunk-YRSIDQWL.js";import"./chunk-JWVF334V.js";import"./chunk-77HMVQR2.js";import"./chunk-T5PZGDIV.js";import"./chunk-JPUELP4B.js";import"./chunk-TNP5EKIO.js";import"./chunk-DTHTT2LY.js";import"./chunk-OJP6MUR6.js";import"./chunk-SQP3OIZA.js";import"./chunk-JQVE776N.js";import"./chunk-GABPQOQE.js";import"./chunk-YJ4BIMHP.js";import"./chunk-5RJFHLF4.js";import"./chunk-V55RPDDX.js";import"./chunk-WGFW7GL5.js";import{D as b,E as y,K as w,N as k,S as v,v as g,w as $,x as h}from"./chunk-7VY2VMT3.js";import"./chunk-S4BBOGT6.js";import"./chunk-J45TDLET.js";import"./chunk-5LW27KVM.js";import"./chunk-5C33Q2UM.js";import{p as f}from"./chunk-2ZG5AQX6.js";import"./chunk-WM7YOMQ4.js";import"./chunk-KWH5X47W.js";import"./chunk-U6T4JBVH.js";import"./chunk-V2LECRKO.js";import"./chunk-PUJ267YF.js";import"./chunk-5IZDNFW6.js";import"./chunk-FBY2ENLK.js";import{a as i,f as p}from"./chunk-J4YFXJND.js";p();import O from"node:os";var S=2**30,M=i((n,t)=>Number.isFinite(n)?`${Number(n.toFixed(1))}${t}`:"no limit","limit");function P(n,t=process.platform){return n?`host load limit ${n}${t==="darwin"?" (not enforced on macOS)":""}`:"host load limit off"}i(P,"hostLoadText");async function T(n){let t=await b(),l=y(O.availableParallelism()),c=h(),m=await v(),r=L(),u=g(k(m,r??[])).map((e,o)=>{let s=c[e.feature]?.workspace,a=s&&f(s)?.services||null,N=s?w(s,a??void 0):null,B=o===0&&e.waitedMs>=3e5&&!e.parked&&$(t,r??[],e);return{...e,position:o+1,services:a,cost:N,holds:B}});if(n.json){let e=i(o=>Number.isFinite(o)?o:null,"n");console.log(JSON.stringify({budget:{memory:e(t.memory),cpus:e(t.cpus),preempt:t.preempt},host_load:l,leases:c,waiting:m,running:r?.map(o=>({feature:o.feature,cpus:o.cost.cpus,memory:o.cost.memory,rank:o.rank,busy:o.busy}))??null,waiters:u.map(o=>({feature:o.feature,position:o.position,services:o.services,cpus:o.cost?.cpus??null,memory:o.cost?.memory??null,waited_ms:o.waitedMs,gate:o.gate}))}));return}console.log(`Budget: ${M(t.memory/S," GiB")} memory, ${M(t.cpus," CPUs")}, ${P(l)}, preemption ${t.preempt?"on":"off"}`);let d=Object.entries(c).sort(([,e],[,o])=>e.slot-o.slot);console.log(d.length?"Slots:":"Slots: none held");for(let[e,o]of d)console.log(` ${o.slot} ${e}${o.workspace?` ${o.workspace}`:""}`);console.log(r?r.length?"Running:":"Running: none":"Running: docker unavailable");for(let e of[...r??[]].sort((o,s)=>s.cost.cpus-o.cost.cpus))console.log(` ${x(e)}`);console.log(u.length?"Waiting:":"Waiting: none");for(let e of u){let o=e.services?`${e.services.join(", ")}${e.gate?" for a running feature":""}`:"whole feature",s=e.cost?` (${Number(e.cost.cpus.toFixed(1))} CPUs, ${(e.cost.memory/S).toFixed(1)} GiB)`:"",a=e.waitedMs?` waited ${Math.round(e.waitedMs/6e4)} min${e.holds?", gets the next free room":""}`:"";console.log(` ${e.position}. ${e.feature} ${o}${s}${a}`)}}i(T,"run");export{P as hostLoadText,T as run};
4
- //# sourceMappingURL=budget-AMYNP35Q.js.map
3
+ import{e as x,n as L}from"./chunk-MHICRT4W.js";import"./chunk-Q3X77IN7.js";import"./chunk-CRERPUL7.js";import"./chunk-EJFZWVFV.js";import"./chunk-4ZXCC7N3.js";import"./chunk-IKFNWBKS.js";import"./chunk-KSUN7ZZK.js";import"./chunk-J2RRXPO6.js";import"./chunk-AAM2FUZU.js";import"./chunk-YAELVAID.js";import"./chunk-ICBOFT25.js";import"./chunk-GRAAEXFE.js";import"./chunk-AJULLWA3.js";import"./chunk-3P2IUJ55.js";import"./chunk-QM23FCOA.js";import"./chunk-43O2Z5F5.js";import"./chunk-7QEZMWPN.js";import"./chunk-CXEPCQWZ.js";import{D as b,E as y,K as w,N as k,S as v,v as g,w as $,x as h}from"./chunk-IE4Y2XO4.js";import"./chunk-GLJAGFNV.js";import"./chunk-XSPQUCPB.js";import"./chunk-SUESH3BY.js";import"./chunk-CRB7AFYE.js";import{p as f}from"./chunk-LR4VZKK7.js";import"./chunk-FLYJZMJ4.js";import"./chunk-443FHHSF.js";import"./chunk-2R3TTVDD.js";import"./chunk-P4LYRKV2.js";import"./chunk-K7PSTFHC.js";import"./chunk-2DZPE4HK.js";import"./chunk-ST6VN3TA.js";import{a as i,f as p}from"./chunk-BA6RZ57Q.js";p();import O from"node:os";var S=2**30,M=i((n,t)=>Number.isFinite(n)?`${Number(n.toFixed(1))}${t}`:"no limit","limit");function P(n,t=process.platform){return n?`host load limit ${n}${t==="darwin"?" (not enforced on macOS)":""}`:"host load limit off"}i(P,"hostLoadText");async function T(n){let t=await b(),l=y(O.availableParallelism()),c=h(),m=await v(),r=L(),u=g(k(m,r??[])).map((e,o)=>{let s=c[e.feature]?.workspace,a=s&&f(s)?.services||null,N=s?w(s,a??void 0):null,B=o===0&&e.waitedMs>=3e5&&!e.parked&&$(t,r??[],e);return{...e,position:o+1,services:a,cost:N,holds:B}});if(n.json){let e=i(o=>Number.isFinite(o)?o:null,"n");console.log(JSON.stringify({budget:{memory:e(t.memory),cpus:e(t.cpus),preempt:t.preempt},host_load:l,leases:c,waiting:m,running:r?.map(o=>({feature:o.feature,cpus:o.cost.cpus,memory:o.cost.memory,rank:o.rank,busy:o.busy}))??null,waiters:u.map(o=>({feature:o.feature,position:o.position,services:o.services,cpus:o.cost?.cpus??null,memory:o.cost?.memory??null,waited_ms:o.waitedMs,gate:o.gate}))}));return}console.log(`Budget: ${M(t.memory/S," GiB")} memory, ${M(t.cpus," CPUs")}, ${P(l)}, preemption ${t.preempt?"on":"off"}`);let d=Object.entries(c).sort(([,e],[,o])=>e.slot-o.slot);console.log(d.length?"Slots:":"Slots: none held");for(let[e,o]of d)console.log(` ${o.slot} ${e}${o.workspace?` ${o.workspace}`:""}`);console.log(r?r.length?"Running:":"Running: none":"Running: docker unavailable");for(let e of[...r??[]].sort((o,s)=>s.cost.cpus-o.cost.cpus))console.log(` ${x(e)}`);console.log(u.length?"Waiting:":"Waiting: none");for(let e of u){let o=e.services?`${e.services.join(", ")}${e.gate?" for a running feature":""}`:"whole feature",s=e.cost?` (${Number(e.cost.cpus.toFixed(1))} CPUs, ${(e.cost.memory/S).toFixed(1)} GiB)`:"",a=e.waitedMs?` waited ${Math.round(e.waitedMs/6e4)} min${e.holds?", gets the next free room":""}`:"";console.log(` ${e.position}. ${e.feature} ${o}${s}${a}`)}}i(T,"run");export{P as hostLoadText,T as run};
4
+ //# sourceMappingURL=budget-TUUI6WGZ.js.map
@@ -1,4 +1,4 @@
1
1
  import { createRequire as __sandboxCreateRequire } from "node:module";
2
2
  const require = __sandboxCreateRequire(import.meta.url);
3
- import"./chunk-UUKSAZGH.js";import{d as s}from"./chunk-DTHTT2LY.js";import"./chunk-GABPQOQE.js";import"./chunk-S4BBOGT6.js";import"./chunk-5LW27KVM.js";import"./chunk-PUJ267YF.js";import{h as e,l as c}from"./chunk-5IZDNFW6.js";import"./chunk-FBY2ENLK.js";import{a as r,f as i}from"./chunk-J4YFXJND.js";i();async function u(o){o.action!=="prune"&&(c(`Unknown action \`${String(o.action)}\` \u2014 the only action is \`prune\`.`),process.exit(2));let t=await s({name:typeof o.name=="string"?o.name:void 0,reset:!!o.reset,force:!!o.force,dryRun:!!o.dry_run});t.length||console.log("No caches in the registry.");for(let n of t){let a=n.ok?`${e.GREEN}\u2713${e.RESET}`:`${e.RED}\u2717${e.RESET}`;console.log(`${a} ${n.name} (${n.action}): ${n.detail}`)}t.some(n=>!n.ok)&&process.exit(1)}r(u,"run");export{u as run};
4
- //# sourceMappingURL=cache-O3A5YBOT.js.map
3
+ import"./chunk-URWDJ4PG.js";import{d as s}from"./chunk-YAELVAID.js";import"./chunk-3P2IUJ55.js";import"./chunk-GLJAGFNV.js";import"./chunk-SUESH3BY.js";import"./chunk-K7PSTFHC.js";import{h as e,l as c}from"./chunk-2DZPE4HK.js";import"./chunk-ST6VN3TA.js";import{a as r,f as i}from"./chunk-BA6RZ57Q.js";i();async function u(o){o.action!=="prune"&&(c(`Unknown action \`${String(o.action)}\` \u2014 the only action is \`prune\`.`),process.exit(2));let t=await s({name:typeof o.name=="string"?o.name:void 0,reset:!!o.reset,force:!!o.force,dryRun:!!o.dry_run});t.length||console.log("No caches in the registry.");for(let n of t){let a=n.ok?`${e.GREEN}\u2713${e.RESET}`:`${e.RED}\u2717${e.RESET}`;console.log(`${a} ${n.name} (${n.action}): ${n.detail}`)}t.some(n=>!n.ok)&&process.exit(1)}r(u,"run");export{u as run};
4
+ //# sourceMappingURL=cache-5OJXOLPF.js.map
@@ -1,6 +1,6 @@
1
1
  import { createRequire as __sandboxCreateRequire } from "node:module";
2
2
  const require = __sandboxCreateRequire(import.meta.url);
3
- import{b as rs}from"./chunk-FBY2ENLK.js";import{a,b as rt,c as S,e as Qo,f as u}from"./chunk-J4YFXJND.js";var T=S(B=>{"use strict";u();var os=Symbol.for("yaml.alias"),zn=Symbol.for("yaml.document"),ot=Symbol.for("yaml.map"),Zn=Symbol.for("yaml.pair"),as=Symbol.for("yaml.scalar"),at=Symbol.for("yaml.seq"),J=Symbol.for("yaml.node.type"),Ho=a(s=>!!s&&typeof s=="object"&&s[J]===os,"isAlias"),Xo=a(s=>!!s&&typeof s=="object"&&s[J]===zn,"isDocument"),zo=a(s=>!!s&&typeof s=="object"&&s[J]===ot,"isMap"),Zo=a(s=>!!s&&typeof s=="object"&&s[J]===Zn,"isPair"),ei=a(s=>!!s&&typeof s=="object"&&s[J]===as,"isScalar"),ea=a(s=>!!s&&typeof s=="object"&&s[J]===at,"isSeq");function ti(s){if(s&&typeof s=="object")switch(s[J]){case ot:case at:return!0}return!1}a(ti,"isCollection");function ta(s){if(s&&typeof s=="object")switch(s[J]){case os:case ot:case as:case at:return!0}return!1}a(ta,"isNode");var sa=a(s=>(ei(s)||ti(s))&&!!s.anchor,"hasAnchor");B.ALIAS=os;B.DOC=zn;B.MAP=ot;B.NODE_TYPE=J;B.PAIR=Zn;B.SCALAR=as;B.SEQ=at;B.hasAnchor=sa;B.isAlias=Ho;B.isCollection=ti;B.isDocument=Xo;B.isMap=zo;B.isNode=ta;B.isPair=Zo;B.isScalar=ei;B.isSeq=ea});var Ee=S(ls=>{"use strict";u();var $=T(),R=Symbol("break visit"),si=Symbol("skip children"),U=Symbol("remove node");function lt(s,e){let t=ni(e);$.isDocument(s)?me(null,s.contents,t,Object.freeze([s]))===U&&(s.contents=null):me(null,s,t,Object.freeze([]))}a(lt,"visit");lt.BREAK=R;lt.SKIP=si;lt.REMOVE=U;function me(s,e,t,n){let i=ii(s,e,t,n);if($.isNode(i)||$.isPair(i))return ri(s,n,i),me(s,i,t,n);if(typeof i!="symbol"){if($.isCollection(e)){n=Object.freeze(n.concat(e));for(let r=0;r<e.items.length;++r){let o=me(r,e.items[r],t,n);if(typeof o=="number")r=o-1;else{if(o===R)return R;o===U&&(e.items.splice(r,1),r-=1)}}}else if($.isPair(e)){n=Object.freeze(n.concat(e));let r=me("key",e.key,t,n);if(r===R)return R;r===U&&(e.key=null);let o=me("value",e.value,t,n);if(o===R)return R;o===U&&(e.value=null)}}return i}a(me,"visit_");async function ct(s,e){let t=ni(e);$.isDocument(s)?await ge(null,s.contents,t,Object.freeze([s]))===U&&(s.contents=null):await ge(null,s,t,Object.freeze([]))}a(ct,"visitAsync");ct.BREAK=R;ct.SKIP=si;ct.REMOVE=U;async function ge(s,e,t,n){let i=await ii(s,e,t,n);if($.isNode(i)||$.isPair(i))return ri(s,n,i),ge(s,i,t,n);if(typeof i!="symbol"){if($.isCollection(e)){n=Object.freeze(n.concat(e));for(let r=0;r<e.items.length;++r){let o=await ge(r,e.items[r],t,n);if(typeof o=="number")r=o-1;else{if(o===R)return R;o===U&&(e.items.splice(r,1),r-=1)}}}else if($.isPair(e)){n=Object.freeze(n.concat(e));let r=await ge("key",e.key,t,n);if(r===R)return R;r===U&&(e.key=null);let o=await ge("value",e.value,t,n);if(o===R)return R;o===U&&(e.value=null)}}return i}a(ge,"visitAsync_");function ni(s){return typeof s=="object"&&(s.Collection||s.Node||s.Value)?Object.assign({Alias:s.Node,Map:s.Node,Scalar:s.Node,Seq:s.Node},s.Value&&{Map:s.Value,Scalar:s.Value,Seq:s.Value},s.Collection&&{Map:s.Collection,Seq:s.Collection},s):s}a(ni,"initVisitor");function ii(s,e,t,n){if(typeof t=="function")return t(s,e,n);if($.isMap(e))return t.Map?.(s,e,n);if($.isSeq(e))return t.Seq?.(s,e,n);if($.isPair(e))return t.Pair?.(s,e,n);if($.isScalar(e))return t.Scalar?.(s,e,n);if($.isAlias(e))return t.Alias?.(s,e,n)}a(ii,"callVisitor");function ri(s,e,t){let n=e[e.length-1];if($.isCollection(n))n.items[s]=t;else if($.isPair(n))s==="key"?n.key=t:n.value=t;else if($.isDocument(n))n.contents=t;else{let i=$.isAlias(n)?"alias":"scalar";throw new Error(`Cannot replace node with ${i} parent`)}}a(ri,"replaceNode");ls.visit=lt;ls.visitAsync=ct});var cs=S(ai=>{"use strict";u();var oi=T(),na=Ee(),ia={"!":"%21",",":"%2C","[":"%5B","]":"%5D","{":"%7B","}":"%7D"},ra=a(s=>s.replace(/[!,[\]{}]/g,e=>ia[e]),"escapeTagName"),Oe=class s{static{a(this,"Directives")}constructor(e,t){this.docStart=null,this.docEnd=!1,this.yaml=Object.assign({},s.defaultYaml,e),this.tags=Object.assign({},s.defaultTags,t)}clone(){let e=new s(this.yaml,this.tags);return e.docStart=this.docStart,e}atDocument(){let e=new s(this.yaml,this.tags);switch(this.yaml.version){case"1.1":this.atNextDocument=!0;break;case"1.2":this.atNextDocument=!1,this.yaml={explicit:s.defaultYaml.explicit,version:"1.2"},this.tags=Object.assign({},s.defaultTags);break}return e}add(e,t){this.atNextDocument&&(this.yaml={explicit:s.defaultYaml.explicit,version:"1.1"},this.tags=Object.assign({},s.defaultTags),this.atNextDocument=!1);let n=e.trim().split(/[ \t]+/),i=n.shift();switch(i){case"%TAG":{if(n.length!==2&&(t(0,"%TAG directive should contain exactly two parts"),n.length<2))return!1;let[r,o]=n;return this.tags[r]=o,!0}case"%YAML":{if(this.yaml.explicit=!0,n.length!==1)return t(0,"%YAML directive should contain exactly one part"),!1;let[r]=n;if(r==="1.1"||r==="1.2")return this.yaml.version=r,!0;{let o=/^\d+\.\d+$/.test(r);return t(6,`Unsupported YAML version ${r}`,o),!1}}default:return t(0,`Unknown directive ${i}`,!0),!1}}tagName(e,t){if(e==="!")return"!";if(e[0]!=="!")return t(`Not a valid tag: ${e}`),null;if(e[1]==="<"){let o=e.slice(2,-1);return o==="!"||o==="!!"?(t(`Verbatim tags aren't resolved, so ${e} is invalid.`),null):(e[e.length-1]!==">"&&t("Verbatim tags must end with a >"),o)}let[,n,i]=e.match(/^(.*!)([^!]*)$/s);i||t(`The ${e} tag has no suffix`);let r=this.tags[n];if(r)try{return r+decodeURIComponent(i)}catch(o){return t(String(o)),null}return n==="!"?e:(t(`Could not resolve tag: ${e}`),null)}tagString(e){for(let[t,n]of Object.entries(this.tags))if(e.startsWith(n))return t+ra(e.substring(n.length));return e[0]==="!"?e:`!<${e}>`}toString(e){let t=this.yaml.explicit?[`%YAML ${this.yaml.version||"1.2"}`]:[],n=Object.entries(this.tags),i;if(e&&n.length>0&&oi.isNode(e.contents)){let r={};na.visit(e.contents,(o,l)=>{oi.isNode(l)&&l.tag&&(r[l.tag]=!0)}),i=Object.keys(r)}else i=[];for(let[r,o]of n)r==="!!"&&o==="tag:yaml.org,2002:"||(!e||i.some(l=>l.startsWith(o)))&&t.push(`%TAG ${r} ${o}`);return t.join(`
3
+ import{b as rs}from"./chunk-ST6VN3TA.js";import{a,b as rt,c as S,e as Qo,f as u}from"./chunk-BA6RZ57Q.js";var T=S(B=>{"use strict";u();var os=Symbol.for("yaml.alias"),zn=Symbol.for("yaml.document"),ot=Symbol.for("yaml.map"),Zn=Symbol.for("yaml.pair"),as=Symbol.for("yaml.scalar"),at=Symbol.for("yaml.seq"),J=Symbol.for("yaml.node.type"),Ho=a(s=>!!s&&typeof s=="object"&&s[J]===os,"isAlias"),Xo=a(s=>!!s&&typeof s=="object"&&s[J]===zn,"isDocument"),zo=a(s=>!!s&&typeof s=="object"&&s[J]===ot,"isMap"),Zo=a(s=>!!s&&typeof s=="object"&&s[J]===Zn,"isPair"),ei=a(s=>!!s&&typeof s=="object"&&s[J]===as,"isScalar"),ea=a(s=>!!s&&typeof s=="object"&&s[J]===at,"isSeq");function ti(s){if(s&&typeof s=="object")switch(s[J]){case ot:case at:return!0}return!1}a(ti,"isCollection");function ta(s){if(s&&typeof s=="object")switch(s[J]){case os:case ot:case as:case at:return!0}return!1}a(ta,"isNode");var sa=a(s=>(ei(s)||ti(s))&&!!s.anchor,"hasAnchor");B.ALIAS=os;B.DOC=zn;B.MAP=ot;B.NODE_TYPE=J;B.PAIR=Zn;B.SCALAR=as;B.SEQ=at;B.hasAnchor=sa;B.isAlias=Ho;B.isCollection=ti;B.isDocument=Xo;B.isMap=zo;B.isNode=ta;B.isPair=Zo;B.isScalar=ei;B.isSeq=ea});var Ee=S(ls=>{"use strict";u();var $=T(),R=Symbol("break visit"),si=Symbol("skip children"),U=Symbol("remove node");function lt(s,e){let t=ni(e);$.isDocument(s)?me(null,s.contents,t,Object.freeze([s]))===U&&(s.contents=null):me(null,s,t,Object.freeze([]))}a(lt,"visit");lt.BREAK=R;lt.SKIP=si;lt.REMOVE=U;function me(s,e,t,n){let i=ii(s,e,t,n);if($.isNode(i)||$.isPair(i))return ri(s,n,i),me(s,i,t,n);if(typeof i!="symbol"){if($.isCollection(e)){n=Object.freeze(n.concat(e));for(let r=0;r<e.items.length;++r){let o=me(r,e.items[r],t,n);if(typeof o=="number")r=o-1;else{if(o===R)return R;o===U&&(e.items.splice(r,1),r-=1)}}}else if($.isPair(e)){n=Object.freeze(n.concat(e));let r=me("key",e.key,t,n);if(r===R)return R;r===U&&(e.key=null);let o=me("value",e.value,t,n);if(o===R)return R;o===U&&(e.value=null)}}return i}a(me,"visit_");async function ct(s,e){let t=ni(e);$.isDocument(s)?await ge(null,s.contents,t,Object.freeze([s]))===U&&(s.contents=null):await ge(null,s,t,Object.freeze([]))}a(ct,"visitAsync");ct.BREAK=R;ct.SKIP=si;ct.REMOVE=U;async function ge(s,e,t,n){let i=await ii(s,e,t,n);if($.isNode(i)||$.isPair(i))return ri(s,n,i),ge(s,i,t,n);if(typeof i!="symbol"){if($.isCollection(e)){n=Object.freeze(n.concat(e));for(let r=0;r<e.items.length;++r){let o=await ge(r,e.items[r],t,n);if(typeof o=="number")r=o-1;else{if(o===R)return R;o===U&&(e.items.splice(r,1),r-=1)}}}else if($.isPair(e)){n=Object.freeze(n.concat(e));let r=await ge("key",e.key,t,n);if(r===R)return R;r===U&&(e.key=null);let o=await ge("value",e.value,t,n);if(o===R)return R;o===U&&(e.value=null)}}return i}a(ge,"visitAsync_");function ni(s){return typeof s=="object"&&(s.Collection||s.Node||s.Value)?Object.assign({Alias:s.Node,Map:s.Node,Scalar:s.Node,Seq:s.Node},s.Value&&{Map:s.Value,Scalar:s.Value,Seq:s.Value},s.Collection&&{Map:s.Collection,Seq:s.Collection},s):s}a(ni,"initVisitor");function ii(s,e,t,n){if(typeof t=="function")return t(s,e,n);if($.isMap(e))return t.Map?.(s,e,n);if($.isSeq(e))return t.Seq?.(s,e,n);if($.isPair(e))return t.Pair?.(s,e,n);if($.isScalar(e))return t.Scalar?.(s,e,n);if($.isAlias(e))return t.Alias?.(s,e,n)}a(ii,"callVisitor");function ri(s,e,t){let n=e[e.length-1];if($.isCollection(n))n.items[s]=t;else if($.isPair(n))s==="key"?n.key=t:n.value=t;else if($.isDocument(n))n.contents=t;else{let i=$.isAlias(n)?"alias":"scalar";throw new Error(`Cannot replace node with ${i} parent`)}}a(ri,"replaceNode");ls.visit=lt;ls.visitAsync=ct});var cs=S(ai=>{"use strict";u();var oi=T(),na=Ee(),ia={"!":"%21",",":"%2C","[":"%5B","]":"%5D","{":"%7B","}":"%7D"},ra=a(s=>s.replace(/[!,[\]{}]/g,e=>ia[e]),"escapeTagName"),Oe=class s{static{a(this,"Directives")}constructor(e,t){this.docStart=null,this.docEnd=!1,this.yaml=Object.assign({},s.defaultYaml,e),this.tags=Object.assign({},s.defaultTags,t)}clone(){let e=new s(this.yaml,this.tags);return e.docStart=this.docStart,e}atDocument(){let e=new s(this.yaml,this.tags);switch(this.yaml.version){case"1.1":this.atNextDocument=!0;break;case"1.2":this.atNextDocument=!1,this.yaml={explicit:s.defaultYaml.explicit,version:"1.2"},this.tags=Object.assign({},s.defaultTags);break}return e}add(e,t){this.atNextDocument&&(this.yaml={explicit:s.defaultYaml.explicit,version:"1.1"},this.tags=Object.assign({},s.defaultTags),this.atNextDocument=!1);let n=e.trim().split(/[ \t]+/),i=n.shift();switch(i){case"%TAG":{if(n.length!==2&&(t(0,"%TAG directive should contain exactly two parts"),n.length<2))return!1;let[r,o]=n;return this.tags[r]=o,!0}case"%YAML":{if(this.yaml.explicit=!0,n.length!==1)return t(0,"%YAML directive should contain exactly one part"),!1;let[r]=n;if(r==="1.1"||r==="1.2")return this.yaml.version=r,!0;{let o=/^\d+\.\d+$/.test(r);return t(6,`Unsupported YAML version ${r}`,o),!1}}default:return t(0,`Unknown directive ${i}`,!0),!1}}tagName(e,t){if(e==="!")return"!";if(e[0]!=="!")return t(`Not a valid tag: ${e}`),null;if(e[1]==="<"){let o=e.slice(2,-1);return o==="!"||o==="!!"?(t(`Verbatim tags aren't resolved, so ${e} is invalid.`),null):(e[e.length-1]!==">"&&t("Verbatim tags must end with a >"),o)}let[,n,i]=e.match(/^(.*!)([^!]*)$/s);i||t(`The ${e} tag has no suffix`);let r=this.tags[n];if(r)try{return r+decodeURIComponent(i)}catch(o){return t(String(o)),null}return n==="!"?e:(t(`Could not resolve tag: ${e}`),null)}tagString(e){for(let[t,n]of Object.entries(this.tags))if(e.startsWith(n))return t+ra(e.substring(n.length));return e[0]==="!"?e:`!<${e}>`}toString(e){let t=this.yaml.explicit?[`%YAML ${this.yaml.version||"1.2"}`]:[],n=Object.entries(this.tags),i;if(e&&n.length>0&&oi.isNode(e.contents)){let r={};na.visit(e.contents,(o,l)=>{oi.isNode(l)&&l.tag&&(r[l.tag]=!0)}),i=Object.keys(r)}else i=[];for(let[r,o]of n)r==="!!"&&o==="tag:yaml.org,2002:"||(!e||i.some(l=>l.startsWith(o)))&&t.push(`%TAG ${r} ${o}`);return t.join(`
4
4
  `)}};Oe.defaultYaml={explicit:!1,version:"1.2"};Oe.defaultTags={"!!":"tag:yaml.org,2002:"};ai.Directives=Oe});var ft=S(Le=>{"use strict";u();var li=T(),oa=Ee();function aa(s){if(/[\x00-\x19\s,[\]{}]/.test(s)){let t=`Anchor must not contain whitespace or control characters: ${JSON.stringify(s)}`;throw new Error(t)}return!0}a(aa,"anchorIsValid");function ci(s){let e=new Set;return oa.visit(s,{Value(t,n){n.anchor&&e.add(n.anchor)}}),e}a(ci,"anchorNames");function fi(s,e){for(let t=1;;++t){let n=`${s}${t}`;if(!e.has(n))return n}}a(fi,"findNewAnchor");function la(s,e){let t=[],n=new Map,i=null;return{onAnchor:a(r=>{t.push(r),i??(i=ci(s));let o=fi(e,i);return i.add(o),o},"onAnchor"),setAnchors:a(()=>{for(let r of t){let o=n.get(r);if(typeof o=="object"&&o.anchor&&(li.isScalar(o.node)||li.isCollection(o.node)))o.node.anchor=o.anchor;else{let l=new Error("Failed to resolve repeated object (this should not happen)");throw l.source=r,l}}},"setAnchors"),sourceObjects:n}}a(la,"createNodeAnchors");Le.anchorIsValid=aa;Le.anchorNames=ci;Le.createNodeAnchors=la;Le.findNewAnchor=fi});var fs=S(ui=>{"use strict";u();function Te(s,e,t,n){if(n&&typeof n=="object")if(Array.isArray(n))for(let i=0,r=n.length;i<r;++i){let o=n[i],l=Te(s,n,String(i),o);l===void 0?delete n[i]:l!==o&&(n[i]=l)}else if(n instanceof Map)for(let i of Array.from(n.keys())){let r=n.get(i),o=Te(s,n,i,r);o===void 0?n.delete(i):o!==r&&n.set(i,o)}else if(n instanceof Set)for(let i of Array.from(n)){let r=Te(s,n,i,i);r===void 0?n.delete(i):r!==i&&(n.delete(i),n.add(r))}else for(let[i,r]of Object.entries(n)){let o=Te(s,n,i,r);o===void 0?delete n[i]:o!==r&&(n[i]=o)}return s.call(e,t,n)}a(Te,"applyReviver");ui.applyReviver=Te});var H=S(di=>{"use strict";u();var ca=T();function hi(s,e,t){if(Array.isArray(s))return s.map((n,i)=>hi(n,String(i),t));if(s&&typeof s.toJSON=="function"){if(!t||!ca.hasAnchor(s))return s.toJSON(e,t);let n={aliasCount:0,count:1,res:void 0};t.anchors.set(s,n),t.onCreate=r=>{n.res=r,delete t.onCreate};let i=s.toJSON(e,t);return t.onCreate&&t.onCreate(i),i}return typeof s=="bigint"&&!t?.keep?Number(s):s}a(hi,"toJS");di.toJS=hi});var ut=S(mi=>{"use strict";u();var fa=fs(),pi=T(),ua=H(),us=class{static{a(this,"NodeBase")}constructor(e){Object.defineProperty(this,pi.NODE_TYPE,{value:e})}clone(){let e=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));return this.range&&(e.range=this.range.slice()),e}toJS(e,{mapAsMap:t,maxAliasCount:n,onAnchor:i,reviver:r}={}){if(!pi.isDocument(e))throw new TypeError("A document argument is required");let o={anchors:new Map,doc:e,keep:!0,mapAsMap:t===!0,mapKeyWarned:!1,maxAliasCount:typeof n=="number"?n:100},l=ua.toJS(this,"",o);if(typeof i=="function")for(let{count:c,res:f}of o.anchors.values())i(f,c);return typeof r=="function"?fa.applyReviver(r,{"":l},"",l):l}};mi.NodeBase=us});var Ce=S(gi=>{"use strict";u();var ha=ft(),da=Ee(),ye=T(),pa=ut(),ma=H(),hs=class extends pa.NodeBase{static{a(this,"Alias")}constructor(e){super(ye.ALIAS),this.source=e,Object.defineProperty(this,"tag",{set(){throw new Error("Alias nodes cannot have tags")}})}resolve(e,t){if(t?.maxAliasCount===0)throw new ReferenceError("Alias resolution is disabled");let n;t?.aliasResolveCache?n=t.aliasResolveCache:(n=[],da.visit(e,{Node:a((r,o)=>{(ye.isAlias(o)||ye.hasAnchor(o))&&n.push(o)},"Node")}),t&&(t.aliasResolveCache=n));let i;for(let r of n){if(r===this)break;r.anchor===this.source&&(i=r)}return i}toJSON(e,t){if(!t)return{source:this.source};let{anchors:n,doc:i,maxAliasCount:r}=t,o=this.resolve(i,t);if(!o){let c=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw new ReferenceError(c)}let l=n.get(o);if(l||(ma.toJS(o,null,t),l=n.get(o)),l?.res===void 0){let c="This should not happen: Alias anchor was not resolved?";throw new ReferenceError(c)}if(r>=0&&(l.count+=1,l.aliasCount===0&&(l.aliasCount=ht(i,o,n)),l.count*l.aliasCount>r)){let c="Excessive alias count indicates a resource exhaustion attack";throw new ReferenceError(c)}return l.res}toString(e,t,n){let i=`*${this.source}`;if(e){if(ha.anchorIsValid(this.source),e.options.verifyAliasOrder&&!e.anchors.has(this.source)){let r=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw new Error(r)}if(e.implicitKey)return`${i} `}return i}};function ht(s,e,t){if(ye.isAlias(e)){let n=e.resolve(s),i=t&&n&&t.get(n);return i?i.count*i.aliasCount:0}else if(ye.isCollection(e)){let n=0;for(let i of e.items){let r=ht(s,i,t);r>n&&(n=r)}return n}else if(ye.isPair(e)){let n=ht(s,e.key,t),i=ht(s,e.value,t);return Math.max(n,i)}return 1}a(ht,"getAliasCount");gi.Alias=hs});var _=S(ds=>{"use strict";u();var ga=T(),ya=ut(),ba=H(),Sa=a(s=>!s||typeof s!="function"&&typeof s!="object","isScalarValue"),X=class extends ya.NodeBase{static{a(this,"Scalar")}constructor(e){super(ga.SCALAR),this.value=e}toJSON(e,t){return t?.keep?this.value:ba.toJS(this.value,e,t)}toString(){return String(this.value)}};X.BLOCK_FOLDED="BLOCK_FOLDED";X.BLOCK_LITERAL="BLOCK_LITERAL";X.PLAIN="PLAIN";X.QUOTE_DOUBLE="QUOTE_DOUBLE";X.QUOTE_SINGLE="QUOTE_SINGLE";ds.Scalar=X;ds.isScalarValue=Sa});var Ie=S(bi=>{"use strict";u();var wa=Ce(),le=T(),yi=_(),va="tag:yaml.org,2002:";function ka(s,e,t){if(e){let n=t.filter(r=>r.tag===e),i=n.find(r=>!r.format)??n[0];if(!i)throw new Error(`Tag ${e} not found`);return i}return t.find(n=>n.identify?.(s)&&!n.format)}a(ka,"findTagObject");function Na(s,e,t){if(le.isDocument(s)&&(s=s.contents),le.isNode(s))return s;if(le.isPair(s)){let h=t.schema[le.MAP].createNode?.(t.schema,null,t);return h.items.push(s),h}(s instanceof String||s instanceof Number||s instanceof Boolean||typeof BigInt<"u"&&s instanceof BigInt)&&(s=s.valueOf());let{aliasDuplicateObjects:n,onAnchor:i,onTagObj:r,schema:o,sourceObjects:l}=t,c;if(n&&s&&typeof s=="object"){if(c=l.get(s),c)return c.anchor??(c.anchor=i(s)),new wa.Alias(c.anchor);c={anchor:null,node:null},l.set(s,c)}e?.startsWith("!!")&&(e=va+e.slice(2));let f=ka(s,e,o.tags);if(!f){if(s&&typeof s.toJSON=="function"&&(s=s.toJSON()),!s||typeof s!="object"){let h=new yi.Scalar(s);return c&&(c.node=h),h}f=s instanceof Map?o[le.MAP]:Symbol.iterator in Object(s)?o[le.SEQ]:o[le.MAP]}r&&(r(f),delete t.onTagObj);let m=f?.createNode?f.createNode(t.schema,s,t):typeof f?.nodeClass?.from=="function"?f.nodeClass.from(t.schema,s,t):new yi.Scalar(s);return e?m.tag=e:f.default||(m.tag=f.tag),c&&(c.node=m),m}a(Na,"createNode");bi.createNode=Na});var pt=S(dt=>{"use strict";u();var Aa=Ie(),V=T(),qa=ut();function ps(s,e,t){let n=t;for(let i=e.length-1;i>=0;--i){let r=e[i];if(typeof r=="number"&&Number.isInteger(r)&&r>=0){let o=[];o[r]=n,n=o}else n=new Map([[r,n]])}return Aa.createNode(n,void 0,{aliasDuplicateObjects:!1,keepUndefined:!1,onAnchor:a(()=>{throw new Error("This should not happen, please report a bug.")},"onAnchor"),schema:s,sourceObjects:new Map})}a(ps,"collectionFromPath");var Si=a(s=>s==null||typeof s=="object"&&!!s[Symbol.iterator]().next().done,"isEmptyPath"),ms=class extends qa.NodeBase{static{a(this,"Collection")}constructor(e,t){super(e),Object.defineProperty(this,"schema",{value:t,configurable:!0,enumerable:!1,writable:!0})}clone(e){let t=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));return e&&(t.schema=e),t.items=t.items.map(n=>V.isNode(n)||V.isPair(n)?n.clone(e):n),this.range&&(t.range=this.range.slice()),t}addIn(e,t){if(Si(e))this.add(t);else{let[n,...i]=e,r=this.get(n,!0);if(V.isCollection(r))r.addIn(i,t);else if(r===void 0&&this.schema)this.set(n,ps(this.schema,i,t));else throw new Error(`Expected YAML collection at ${n}. Remaining path: ${i}`)}}deleteIn(e){let[t,...n]=e;if(n.length===0)return this.delete(t);let i=this.get(t,!0);if(V.isCollection(i))return i.deleteIn(n);throw new Error(`Expected YAML collection at ${t}. Remaining path: ${n}`)}getIn(e,t){let[n,...i]=e,r=this.get(n,!0);return i.length===0?!t&&V.isScalar(r)?r.value:r:V.isCollection(r)?r.getIn(i,t):void 0}hasAllNullValues(e){return this.items.every(t=>{if(!V.isPair(t))return!1;let n=t.value;return n==null||e&&V.isScalar(n)&&n.value==null&&!n.commentBefore&&!n.comment&&!n.tag})}hasIn(e){let[t,...n]=e;if(n.length===0)return this.has(t);let i=this.get(t,!0);return V.isCollection(i)?i.hasIn(n):!1}setIn(e,t){let[n,...i]=e;if(i.length===0)this.set(n,t);else{let r=this.get(n,!0);if(V.isCollection(r))r.setIn(i,t);else if(r===void 0&&this.schema)this.set(n,ps(this.schema,i,t));else throw new Error(`Expected YAML collection at ${n}. Remaining path: ${i}`)}}};dt.Collection=ms;dt.collectionFromPath=ps;dt.isEmptyPath=Si});var _e=S(mt=>{"use strict";u();var Ea=a(s=>s.replace(/^(?!$)(?: $)?/gm,"#"),"stringifyComment");function gs(s,e){return/^\n+$/.test(s)?s.substring(1):e?s.replace(/^(?! *$)/gm,e):s}a(gs,"indentComment");var Oa=a((s,e,t)=>s.endsWith(`
5
5
  `)?gs(t,e):t.includes(`
6
6
  `)?`
@@ -142,4 +142,4 @@ ${t.comment}`:t.comment}this.doc.range[2]=t.offset;break}default:this.errors.pus
142
142
  `;e.push(n),s?.(n)},text:a(()=>e.join(""),"text")}}a(Gm,"collectingReporter");u();var Gn=Qo(Fo(),1);import*as D from"node:fs";import*as oe from"node:os";import*as A from"node:path";function G(s){return s==="~"?oe.homedir():s.startsWith("~/")?A.join(oe.homedir(),s.slice(2)):s}a(G,"expandUser");function nt(s){return process.env[`WERKMEISTER_${s}`]}a(nt,"envVar");var Cu=a(()=>nt("FIXTURE")==="1","isFixture");function tg(){if(Cu())return"WERKMEISTER_FIXTURE";if(A.resolve(Qn())!==A.join(rs(oe.homedir()),"config.yaml"))return"WERKMEISTER_CONFIG_FILE is not the default home"}a(tg,"sharedProxySkipReason");function Qn(){let s=nt("CONFIG_FILE");return s?G(s):A.join(rs(oe.homedir()),"config.yaml")}a(Qn,"configPath");function Uo(){return A.dirname(Qn())}a(Uo,"sandboxHome");function Y(s){return typeof s=="object"&&s!==null&&!Array.isArray(s)}a(Y,"isDict");function it(){let s=Qn();if(!D.existsSync(s))return{};let e=(0,Gn.parse)(D.readFileSync(s,"utf8"));return Y(e)?e:{}}a(it,"loadConfig");function Hn(s,e,t){let n=it().overrides?.[s];if(n)return A.resolve(G(String(n)));let i=nt(e);return i?A.resolve(G(i)):A.join(Uo(),t)}a(Hn,"registryPath");function Vo(){return Hn("services_yaml","SERVICES_YAML","services.yaml")}a(Vo,"servicesYamlPath");function sg(){return A.join(A.dirname(Vo()),"services.local.yaml")}a(sg,"servicesLocalYamlPath");function Iu(){return Hn("ports_yaml","PORTS_YAML","ports.yaml")}a(Iu,"portsYamlPath");function ng(){return Hn("model_pricing_yaml","MODEL_PRICING_YAML","model-pricing.yaml")}a(ng,"modelPricingYamlPath");function ig(){let s=it().paths?.workspaces_root;if(s)return A.resolve(G(String(s)));let e=nt("WORKSPACES_ROOT");return e?A.resolve(G(e)):A.join(oe.homedir(),"workspace")}a(ig,"workspacesRoot");function _u(s,e){if(!Y(e)||e.baseline_upstream===void 0||e.baseline_upstream===null)return null;let t=e.baseline_upstream,n=typeof t=="string"?/^(\S+):([0-9]{1,5})$/.exec(t):null,i=n?Number(n[2]):0;if(!n||i<1||i>65535)throw new Error(`services.yaml: '${s}'.baseline_upstream must be host:port, got ${JSON.stringify(t)}`);return{host:n[1],port:i}}a(_u,"baselineUpstream");function rg(s,e){let t=[],n=a((i,r)=>{if(Y(i))for(let[o,l]of Object.entries(i))!Y(l)||l.k8s_forward_port===null||l.k8s_forward_port===void 0||_u(o,l)||t.push({name:r&&l.k8s_forward_name||o,listen:Number(l.k8s_forward_port),remote:l.internal_port,ns:l.k8s_namespace||"",prefix:l.k8s_pod_prefix||"",health:l.health_endpoint||""})},"collect");return n(s,!0),n(e,!1),t}a(rg,"forwardSpecs");function og(s,e){let t=Y(e)&&Y(e.feature_slots)?e.feature_slots:{},n=t.base_port??11100,i=t.ports_per_slot??20,r=n+(s-1)*100;return[r,r+i-1]}a(og,"slotPortRange");function Jo(s){return Y(s)?s:{}}a(Jo,"asDict");function ag(){let s=Jo(it().paths).repos_root;return s?A.resolve(G(s)):A.resolve(A.join(oe.homedir(),"workspace"))}a(ag,"getReposRoot");function Pu(){let s=process.cwd();try{for(let t of D.readdirSync(s,{withFileTypes:!0}))if(t.isDirectory()&&D.existsSync(A.join(s,t.name,".git")))return s}catch{}let e=s;for(;;){if(D.existsSync(A.join(e,".git")))return A.dirname(e);let t=A.dirname(e);if(t===e)break;e=t}return null}a(Pu,"detectWorkspaceFromCwd");function lg(s,e){if(e)return A.resolve(e);let t=Jo(it().paths).workspaces_root;if(t){let i=A.resolve(G(t)),r=A.resolve(process.cwd()),o=A.relative(i,r);if(o&&!o.startsWith("..")&&!A.isAbsolute(o))return A.join(i,o.split(A.sep)[0]);let l=A.join(i,s);return D.existsSync(l)&&D.statSync(l).isDirectory()?l:i}let n=Pu();return n||A.join(oe.homedir(),"workspace")}a(lg,"resolveWorkspace");function Wo(s,{required:e=!1}={}){if(!D.existsSync(s)){if(e){let n=`Required config file not found: ${s}
143
143
  Run \`werkmeister machine setup\` to seed the machine-global config in ~/.werkmeister.`;throw Wn(n),new Error(n)}return xo(`Config file not found: ${s}`),{}}let t=(0,Gn.parse)(D.readFileSync(s,"utf8"));if(!Y(t)||Object.keys(t).length===0){if(e){let n=`Required config file is empty or invalid: ${s}
144
144
  Run \`werkmeister machine setup\` to seed the machine-global config in ~/.werkmeister.`;throw Wn(n),new Error(n)}return{}}return t}a(Wo,"loadYaml");var cg=["cli","library","extension"];function fg(s,e){let t=a(n=>!s.includes(n),"remote");return s.some(n=>{let i=e[n];if(!Y(i))return!1;if(i.k8s_deployment)return!0;let r=Y(i.environment)?Object.values(i.environment):[];for(let o of r)if(typeof o=="string"){if(/\bk8s-[a-z0-9-]+/.test(o))return!0;for(let[,l]of o.matchAll(/(?<!\$)\{([a-zA-Z0-9_-]+)\}/g))if(t(l))return!0}return(i.depends_on??[]).some(t)})}a(fg,"needsCluster");var ug="1.0",hg="2.0";function ae({required:s=!0}={}){return Wo(Vo(),{required:s})}a(ae,"servicesDoc");function Mu(){let s=ae();return s.services??s}a(Mu,"loadServices");function dg(){let e=ae().k8s_context;if(!e||typeof e!="string")throw new Error("services.yaml has no top-level `k8s_context` key \u2014 add the dev cluster kube context there (e.g. `k8s_context: orbstack`); `kubectl config get-contexts` lists the available names.");return e}a(dg,"getK8sContext");function $u(){return ae({required:!1}).setup_services??{}}a($u,"loadSetupServices");function pg(){return ae({required:!1}).infrastructure??{}}a(pg,"loadInfrastructure");function mg(){return Wo(Iu(),{required:!0})}a(mg,"loadPorts");function gg(){return ae({required:!1}).repos??{}}a(gg,"loadReposConfig");function yg(){return ae({required:!1}).archetypes??{}}a(yg,"loadArchetypes");function bg(){return ae({required:!1}).mcp_servers??{}}a(bg,"loadMcpServers");function Sg(){return ae({required:!1}).caches??{}}a(Sg,"loadCaches");var Du="^";function Bu(){let s=new Set,e=a(t=>{for(let n of Object.values(t)){if(!Y(n))continue;let i=n.node_modules_volume;typeof i=="string"&&i&&(s.add(i),typeof n.repo=="string"&&n.repo&&s.add(`${n.repo}-${i}`));let r=n.extra_volumes;if(Array.isArray(r))for(let o of r){if(typeof o!="string")continue;let l=o.split(":")[0];l&&!l.startsWith(Du)&&!l.includes("/")&&s.add(l)}}},"collect");return e(Mu()),e($u()),s}a(Bu,"registryVolumeBases");function wg(){return[...Bu()].sort()}a(wg,"getVolumeBaseNames");function Go(){let s=import.meta.dirname;for(let e=0;e<8;e++){let t=A.join(s,"apps","cli");if(D.existsSync(t))return t;let n=A.dirname(s);if(n===s)break;s=n}return null}a(Go,"ownCheckoutCli");function Ru(){try{let s=it().paths?.werkmeister_root;return typeof s=="string"&&s?A.resolve(G(s)):null}catch{return null}}a(Ru,"storedWerkmeisterRoot");function is(){if(process.env.NODE_TEST_CONTEXT&&!process.env.WERKMEISTER_ROOT_PINNED)throw new Error("sandboxRoot() reached in a test without pinWerkmeisterRoot() (fixtures.mjs)");let s=nt("ROOT");if(s)return A.resolve(G(s));let e=Go();if(e)return e;let t=ju();if(t)return t;throw new Error("Could not locate the werkmeister CLI package. Install it (npm install -g werkmeister) or set WERKMEISTER_ROOT to its package directory (a checkout's apps/cli).")}a(is,"sandboxRoot");function ju(s=process.env.PATH??""){for(let e of s.split(A.delimiter)){if(!e)continue;let t;try{t=A.dirname(D.realpathSync(A.join(e,"werkmeister")))}catch{continue}for(;t!==A.dirname(t);t=A.dirname(t)){let n=A.join(t,"package.json");if(D.existsSync(n)){try{if(JSON.parse(D.readFileSync(n,"utf8")).name==="werkmeister")return t}catch{}break}}}return null}a(ju,"installedCliPackage");function vg(){return A.join(is(),"infra")}a(vg,"infraRoot");function kg(){let s=is(),e=Go(),t=e!==null&&e!==s&&s===Ru();return A.join(t?e:s,"infra")}a(kg,"sourceInfraRoot");function Ng(){return A.resolve(Uo(),"infra")}a(Ng,"stateInfraRoot");function Ag(s,e){return`${s}-${e}`}a(Ag,"containerOf");function qg(){let s=is();for(let e=0;e<4;e++){if(D.existsSync(A.join(s,"apps")))return s;let t=A.dirname(s);if(t===s)break;s=t}return is()}a(qg,"monorepoRoot");export{Fo as a,xn as b,Yn as c,Au as d,qu as e,Un as f,Vn as g,Bm as h,xm as i,Ym as j,Um as k,xo as l,Wn as m,Vm as n,Jm as o,Wm as p,Gm as q,G as r,nt as s,Cu as t,tg as u,Qn as v,Uo as w,it as x,Vo as y,sg as z,Iu as A,ng as B,ig as C,_u as D,rg as E,og as F,ag as G,lg as H,cg as I,fg as J,ug as K,hg as L,Mu as M,dg as N,$u as O,pg as P,mg as Q,gg as R,yg as S,bg as T,Sg as U,Du as V,wg as W,is as X,ju as Y,vg as Z,kg as _,Ng as $,Ag as aa,qg as ba};
145
- //# sourceMappingURL=chunk-5IZDNFW6.js.map
145
+ //# sourceMappingURL=chunk-2DZPE4HK.js.map
@@ -1,6 +1,6 @@
1
1
  import { createRequire as __sandboxCreateRequire } from "node:module";
2
2
  const require = __sandboxCreateRequire(import.meta.url);
3
- import{b as rt}from"./chunk-OCSOMTAL.js";import{a as ye,b as S,c as se,d as K,f as y,g as w,i as _e}from"./chunk-JPUELP4B.js";import{g as $e,h as be,i as H,j as xe,k as we,n as Se}from"./chunk-SQP3OIZA.js";import{r as ke}from"./chunk-V2LECRKO.js";import{A as ge,X as ve,a as F,w as ue,z as he}from"./chunk-5IZDNFW6.js";import{a as m,e as M,f as $}from"./chunk-J4YFXJND.js";$();var ie=M(F(),1);import*as z from"node:fs";import*as oe from"node:path";var re=class extends Error{static{m(this,"AllocationError")}};function Lt(e=ge()){try{let t=(0,ie.parse)(z.readFileSync(e,"utf8"))?.feature_slots?.ports_per_slot;return Number.isInteger(t)&&t>0?t:20}catch{return 20}}m(Lt,"portsPerSlot");function ne(e,t){for(let o of["services","infrastructure"])for(let c of Object.values(e?.[o]??{})){if(!c||typeof c!="object")continue;let r=c;Number.isInteger(r.port_offset)&&t.offsets.add(r.port_offset),Number.isInteger(r.k8s_forward_port)&&t.forwards.add(r.k8s_forward_port)}}m(ne,"collect");function je(e,t,o,c){let r={offsets:new Set,forwards:new Set};for(let n of H(e))oe.resolve(n.path)!==oe.resolve(t)&&ne(n.doc,r);return z.existsSync(o)&&ne((0,ie.parse)(z.readFileSync(o,"utf8"))??null,r),ne(c,r),r}m(je,"takenPorts");function Oe(e,t,o){let c=new Set(t),r=new Map;for(let n of[...e].sort()){let s=0;for(;c.has(s);)s++;if(s>=o)throw new re(`port_offset exhausted: ${o} offsets (ports.yaml ports_per_slot) are all used \u2014 raise ports_per_slot or free one`);c.add(s),r.set(n,s)}return r}m(Oe,"allocateOffsets");function Ee(e,t,o=9050){let c=new Set(t),r=new Map;for(let n of[...e].sort()){let s=o;for(;c.has(s);)s++;c.add(s),r.set(n,s)}return r}m(Ee,"allocateForwards");var it=m(e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),"escapeRe");function Ae(e,t,o){let c={...e},r=[];for(let n of t){let s=c[n];if(s===void 0)continue;let i=s;for(let a of o)i=i.replace(new RegExp(`(?<![\\w.-])${it(a.host??a.name)}:${a.port}\\b`,"g"),`k8s-${a.name}:${a.forward}`);i!==s&&(c[n]=i,r.push(n))}return{env:c,rewritten:r}}m(Ae,"rewriteEnv");$();var Re=M(F(),1);$();$();import*as U from"node:path";var ae={redis:{health:"redis",port:6379},postgres:{health:"postgres",port:5432},postgis:{health:"postgres",port:5432},mysql:{health:"",port:3306},mariadb:{health:"",port:3306},mongo:{health:"",port:27017},rabbitmq:{health:"",port:5672}};function Me(e){return(e.split("@")[0].split("/").pop()??e).split(":")[0]}m(Me,"imageRepoName");var Ne=m((e,t)=>e.name.localeCompare(t.name),"byName");function Pe(e){let t=e.image?Me(e.image):"";return Object.hasOwn(ae,t)?t:null}m(Pe,"datastoreOf");function De(e,t){let o=e.filter(f=>f.kind==="package"||f.kind==="dockerfile"),c=e.filter(f=>f.kind==="k8s"||f.kind==="compose"),r=[...new Set(o.map(f=>f.dir))].sort(),n=m(f=>f==="."?t:U.posix.basename(f),"base"),s=m(f=>{let h=U.posix.dirname(f);return h==="."?t:U.posix.basename(h)},"parent"),i=new Map;for(let f of r)i.set(n(f),(i.get(n(f))??0)+1);let a=r.map(f=>({dir:f,name:(i.get(n(f))??0)>1?`${s(f)}-${n(f)}`:n(f),findings:o.filter(h=>h.dir===f)})),u=[(f,h)=>f.kind==="k8s"&&f.dir!==null&&h.dir!=="."&&(f.dir===h.dir||f.dir.startsWith(`${h.dir}/`)),(f,h)=>f.kind==="compose"&&f.dir!==null&&f.dir===h.dir,(f,h)=>f.name===h.name,(f,h)=>!!f.image&&Me(f.image)===h.name],p=[];for(let f of c){let h=Pe(f)?[u[2]]:u,b;for(let N of h)if(b=a.find(j=>N(f,j)),b)break;b?b.findings.push(f):p.push(f)}let d=[],g=new Map,v=[];for(let f of p){let h=Pe(f);if(h){let b=g.get(f.name)??{name:f.name,datastore:h,findings:[]};b.findings.push(f),g.set(f.name,b)}else{v.push(f);let b=f.kind==="k8s"?"Deployment":"compose service";d.push({item:f.file,reason:`found ${b} ${f.name} \u2014 no source dir in this repo, skipped`})}}return{services:a.filter(f=>{let h=f.findings.some(b=>b.kind!=="package"||b.runnable);return h||d.push({item:f.dir,reason:"library package (no Dockerfile, deploy config or dev/start script), skipped"}),h}).sort(Ne),infrastructure:[...g.values()].sort(Ne),unmatched:v,skipped:d}}m(De,"correlate");var at={type:["package"],archetype:["package"],test:["package"],internal_port:["k8s","compose","dockerfile"],health_endpoint:["k8s","compose"],setup_service:["package"],image:["dockerfile","package"],command:["package","compose","dockerfile"],memory_limit:["k8s"],memory_reservation:["k8s"],node_modules_volume:["package"],secrets:["k8s"],k8s_deployment:["k8s"],k8s_namespace:["k8s"],k8s_port:["k8s"],k8s_port_name:["k8s"],k8s_pod_prefix:["k8s"],feature_router:["k8s"],depends_on:["compose"]},ce=m((e,t)=>JSON.stringify(e)===JSON.stringify(t),"same");function ct(e){return Object.fromEntries(Object.entries(e).sort(([t],[o])=>t.localeCompare(o)))}m(ct,"sortKeys");function Ie(e,t){return Object.assign({},...e.filter(o=>o.kind===t&&o.fields.environment).map(o=>o.fields.environment.value))}m(Ie,"envOf");function V(e){let t={path:y(e.dir,"source directory")},o=[];for(let[i,a]of Object.entries(at)){let u=a.flatMap(g=>e.findings.filter(v=>v.kind===g&&v.fields[i]!==void 0).map(v=>v.fields[i]));if(!u.length)continue;let p=u[0];if(t[i]=p,p.confidence!=="stated")continue;let d=u.slice(1).filter(g=>g.confidence==="stated"&&!ce(g.value,p.value)).filter((g,v,k)=>k.findIndex(f=>ce(f.value,g.value))===v);d.length&&o.push({service:e.name,key:i,chosen:p,also:d})}t.internal_port??=w(3e3,"no port in any source \u2014 default 3000"),t.health_endpoint??=w("","no readiness probe or healthcheck \u2014 TCP-only"),t.type??=w("api","no package.json \u2014 assumed a service"),t.image??=w("alpine:3","no usable FROM and no package.json \u2014 set the dev image"),!t.feature_router&&t.type.value==="web"&&(t.feature_router=w({},"type: web \u2014 routed through Caddy"));let c=Ie(e.findings,"k8s"),r=Ie(e.findings,"compose"),n={...c,...r};if(Object.keys(n).length){let i=[Object.keys(r).length?"compose environment":"",Object.keys(c).length?"k8s env":""];t.environment=y(ct(n),i.filter(Boolean).join(" + "))}let s=Object.keys(c).filter(i=>!(i in r)).sort();return{name:e.name,dir:e.dir,fields:t,conflicts:o,k8sEnvKeys:s,findings:e.findings}}m(V,"resolveService");function Fe(e,t=[]){let o=ae[e.datastore],c=e.findings.filter(i=>i.kind==="k8s"),r=c[0];for(let i of c.slice(1))for(let a of["internal_port","k8s_namespace"]){let u=r.fields[a],p=i.fields[a];u&&p&&!ce(u.value,p.value)&&t.push({item:i.file,reason:`infrastructure ${e.name}: ${a} ${p.value} disagrees with ${u.value} (${u.source}), kept ${u.value}`})}let n=r?.fields.internal_port??e.findings.find(i=>i.fields.internal_port)?.fields.internal_port,s="no k8s manifest for this datastore";return{name:e.name,fields:{internal_port:n??y(o.port,`${e.datastore} default port`),k8s_namespace:r?.fields.k8s_namespace??w("default",s),k8s_pod_prefix:r?.fields.k8s_pod_prefix??w(e.name,s),health_endpoint:y(o.health,o.health?`${e.datastore} wire probe`:"no wire probe for this datastore \u2014 TCP-only")}}}m(Fe,"resolveInfra");var ts={type:"object",required:["answers"],additionalProperties:!1,properties:{answers:{type:"array",items:{type:"object",required:["item","value","reason","files_read"],additionalProperties:!1,properties:{item:{type:"string"},value:{},reason:{type:"string"},files_read:{type:"array",items:{type:"string"}}}}}}};function ft(e){let t=e.existing?(0,Re.parse)(e.existing)??{}:{},o=m((n,s)=>t?.services?.[n]?.[s]!==void 0,"inFile"),c=e.services.map(n=>n.name),r=[];for(let n of e.services){let s=n.fields,i=m((p,d)=>{o(n.name,p)||r.push({id:`${n.name}.${p}`,service:n.name,...d})},"ask");s.command?.confidence==="guessed"&&i("command",{kind:"command",prompt:`What command starts ${n.name} for local development? It runs with the repo root mounted at /app as the working directory.`,facts:{dir:n.dir,guess:s.command.value,why:s.command.source}}),s.health_endpoint?.confidence==="guessed"&&i("health_endpoint",{kind:"health_endpoint",prompt:`Which HTTP path answers 200 when ${n.name} is healthy? Answer "" if it has none.`,facts:{dir:n.dir,port:s.internal_port?.value}});let a=e.envExample[n.name]??[];a.length&&(i("environment",{kind:"environment",prompt:`Which environment variables does ${n.name} need for local development, with development values? Leave secrets out.`,facts:{dir:n.dir,env_example_keys:a,current:s.environment?.value??{}}}),s.secrets||i("secrets",{kind:"secrets",prompt:`Which of these keys must be set for ${n.name} to start at all? A declared secret that is missing stops \`werkmeister feature up\`.`,facts:{dir:n.dir},choices:a}));let u=c.filter(p=>p!==n.name);u.length&&!s.depends_on&&i("depends_on",{kind:"depends_on",prompt:`Which of these services must be running before ${n.name} starts (it calls them at startup)? Answer [] for none.`,facts:{dir:n.dir},choices:u});for(let p of n.conflicts)i(p.key,{kind:"conflict",prompt:`Sources disagree on ${n.name}.${p.key}. Which value is right for local development?`,facts:{sources:[p.chosen,...p.also].map(d=>({value:d.value,source:d.source}))},choices:[p.chosen.value,...p.also.map(d=>d.value)]})}for(let n of[...new Set(e.unmatched.map(s=>s.name))]){let s=e.unmatched.filter(a=>a.name===n),i=s.map(a=>a.file).join(", ");r.push({id:`unmatched.${n}`,kind:"unmatched",service:null,prompt:`${i} define${s.length>1?"":"s"} ${n}, but no source directory matched it. Which service is it? Answer null if its code lives in another repo.`,facts:{files:s.map(a=>a.file),image:s.find(a=>a.image)?.image??null},choices:[...c,null]})}return r}m(ft,"collectQuestions");var pt=m(e=>!!e&&typeof e=="object"&&!Array.isArray(e)&&Object.values(e).every(t=>typeof t=="string"),"isStringMap"),Te=m((e,t)=>Array.isArray(e)&&e.every(o=>typeof o=="string"&&t.includes(o)),"subsetOf"),mt=m((e,t)=>JSON.stringify(e)===JSON.stringify(t),"same");function lt(e,t,o,c){if(o===null)return null;let r=typeof o=="string"?e.services.find(i=>i.name===o):void 0,n=e.unmatched.filter(i=>`unmatched.${i.name}`===t);if(!r||!n.length)return"expected one of this repo's services, or null";let s=V({name:r.name,dir:r.dir,findings:[...r.findings,...n]});for(let[i,a]of Object.entries(s.fields))i in r.fields||(r.fields[i]={...a,confidence:"inferred",source:`${a.source}; matched by Claude: ${c}`});return r.findings.push(...n),e.unmatched=e.unmatched.filter(i=>!n.includes(i)),e.skipped=e.skipped.filter(i=>!n.some(a=>i.item===a.file&&i.reason.includes(` ${a.name} \u2014 `))),null}m(lt,"applyUnmatched");function ss(e,t){let o=structuredClone(e),c=new Map(ft(e).map(i=>[i.id,i])),r=[],n=[],s=new Set;for(let i of t){let a=c.get(i.item);if(!a){n.push({item:i.item,reason:"not one of the questions asked"});continue}if(s.has(i.item)){n.push({item:i.item,reason:"answered twice; kept the first"});continue}s.add(i.item);let u=i.reason?.trim()||"no reason given",p=m(v=>({value:v,source:u,confidence:"inferred"}),"inferred"),d=a.service?o.services.find(v=>v.name===a.service):void 0,g=null;if(a.kind==="unmatched")g=lt(o,a.id,i.value,u);else if(!d)g=`no service named ${a.service} in this plan`;else switch(a.kind){case"command":typeof i.value=="string"&&i.value.trim()?d.fields.command=p(i.value.trim()):g="expected a non-empty command string";break;case"health_endpoint":typeof i.value=="string"&&(i.value===""||i.value.startsWith("/"))?d.fields.health_endpoint=p(i.value):g='expected "" or a path starting with /';break;case"environment":{if(!pt(i.value)){g="expected an object of string values";break}let v=d.fields.environment?.value??{},k=Object.fromEntries(Object.entries({...i.value,...v}).sort(([h],[b])=>h.localeCompare(b))),f=d.fields.environment?.source;d.fields.environment=p(k),f&&(d.fields.environment.source=`${f}; Claude added keys: ${u}`);break}case"secrets":Te(i.value,a.choices??[])?i.value.length&&(d.fields.secrets=p([...i.value].sort())):g="expected a list of keys from .env.example";break;case"depends_on":Te(i.value,a.choices??[])?i.value.length&&(d.fields.depends_on=p([...i.value].sort())):g="expected a list of this repo's other services";break;case"conflict":{let v=(a.choices??[]).find(f=>mt(f,i.value));if(v===void 0){g="not one of the conflicting values";break}let k=a.id.slice(d.name.length+1);d.fields[k]=p(v),d.conflicts=d.conflicts.filter(f=>f.key!==k);break}}g?n.push({item:i.item,reason:g}):r.push(i.item)}return{plan:o,accepted:r,rejected:n}}m(ss,"applyAnswers");function ns(e){return["You are helping generate a werkmeister service-registry fragment for the repository in your working directory.","A deterministic scan already filled every field it could read from package manifests, Dockerfiles, compose files and Kubernetes manifests.","The questions below are the fields it had to guess. Answer each one from the repository's own files, using Read, Glob and Grep.","","Rules:","- Answer only the questions listed, using each question's `id` as `item`.","- When a question has `choices`, `value` must be one of them; for list questions, a subset of them.","- Leave a question out if the repository doesn't settle it. A missing answer keeps the scan's guess; a wrong answer is worse than none.","- Never put credentials, tokens or keys in environment values. Those belong in `secrets`.",'- `reason` is one short sentence naming the evidence, e.g. "apps/api/src/main.ts registers GET /healthz". It is written into the file as a comment.',"- `files_read` lists the files that support the answer.","","Questions (JSON):",JSON.stringify(e,null,2)].join(`
3
+ import{b as rt}from"./chunk-M7OLABFX.js";import{a as ye,b as S,c as se,d as K,f as y,g as w,i as _e}from"./chunk-J2RRXPO6.js";import{g as $e,h as be,i as H,j as xe,k as we,n as Se}from"./chunk-GRAAEXFE.js";import{r as ke}from"./chunk-P4LYRKV2.js";import{A as ge,X as ve,a as F,w as ue,z as he}from"./chunk-2DZPE4HK.js";import{a as m,e as M,f as $}from"./chunk-BA6RZ57Q.js";$();var ie=M(F(),1);import*as z from"node:fs";import*as oe from"node:path";var re=class extends Error{static{m(this,"AllocationError")}};function Lt(e=ge()){try{let t=(0,ie.parse)(z.readFileSync(e,"utf8"))?.feature_slots?.ports_per_slot;return Number.isInteger(t)&&t>0?t:20}catch{return 20}}m(Lt,"portsPerSlot");function ne(e,t){for(let o of["services","infrastructure"])for(let c of Object.values(e?.[o]??{})){if(!c||typeof c!="object")continue;let r=c;Number.isInteger(r.port_offset)&&t.offsets.add(r.port_offset),Number.isInteger(r.k8s_forward_port)&&t.forwards.add(r.k8s_forward_port)}}m(ne,"collect");function je(e,t,o,c){let r={offsets:new Set,forwards:new Set};for(let n of H(e))oe.resolve(n.path)!==oe.resolve(t)&&ne(n.doc,r);return z.existsSync(o)&&ne((0,ie.parse)(z.readFileSync(o,"utf8"))??null,r),ne(c,r),r}m(je,"takenPorts");function Oe(e,t,o){let c=new Set(t),r=new Map;for(let n of[...e].sort()){let s=0;for(;c.has(s);)s++;if(s>=o)throw new re(`port_offset exhausted: ${o} offsets (ports.yaml ports_per_slot) are all used \u2014 raise ports_per_slot or free one`);c.add(s),r.set(n,s)}return r}m(Oe,"allocateOffsets");function Ee(e,t,o=9050){let c=new Set(t),r=new Map;for(let n of[...e].sort()){let s=o;for(;c.has(s);)s++;c.add(s),r.set(n,s)}return r}m(Ee,"allocateForwards");var it=m(e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),"escapeRe");function Ae(e,t,o){let c={...e},r=[];for(let n of t){let s=c[n];if(s===void 0)continue;let i=s;for(let a of o)i=i.replace(new RegExp(`(?<![\\w.-])${it(a.host??a.name)}:${a.port}\\b`,"g"),`k8s-${a.name}:${a.forward}`);i!==s&&(c[n]=i,r.push(n))}return{env:c,rewritten:r}}m(Ae,"rewriteEnv");$();var Re=M(F(),1);$();$();import*as U from"node:path";var ae={redis:{health:"redis",port:6379},postgres:{health:"postgres",port:5432},postgis:{health:"postgres",port:5432},mysql:{health:"",port:3306},mariadb:{health:"",port:3306},mongo:{health:"",port:27017},rabbitmq:{health:"",port:5672}};function Me(e){return(e.split("@")[0].split("/").pop()??e).split(":")[0]}m(Me,"imageRepoName");var Ne=m((e,t)=>e.name.localeCompare(t.name),"byName");function Pe(e){let t=e.image?Me(e.image):"";return Object.hasOwn(ae,t)?t:null}m(Pe,"datastoreOf");function De(e,t){let o=e.filter(f=>f.kind==="package"||f.kind==="dockerfile"),c=e.filter(f=>f.kind==="k8s"||f.kind==="compose"),r=[...new Set(o.map(f=>f.dir))].sort(),n=m(f=>f==="."?t:U.posix.basename(f),"base"),s=m(f=>{let h=U.posix.dirname(f);return h==="."?t:U.posix.basename(h)},"parent"),i=new Map;for(let f of r)i.set(n(f),(i.get(n(f))??0)+1);let a=r.map(f=>({dir:f,name:(i.get(n(f))??0)>1?`${s(f)}-${n(f)}`:n(f),findings:o.filter(h=>h.dir===f)})),u=[(f,h)=>f.kind==="k8s"&&f.dir!==null&&h.dir!=="."&&(f.dir===h.dir||f.dir.startsWith(`${h.dir}/`)),(f,h)=>f.kind==="compose"&&f.dir!==null&&f.dir===h.dir,(f,h)=>f.name===h.name,(f,h)=>!!f.image&&Me(f.image)===h.name],p=[];for(let f of c){let h=Pe(f)?[u[2]]:u,b;for(let N of h)if(b=a.find(j=>N(f,j)),b)break;b?b.findings.push(f):p.push(f)}let d=[],g=new Map,v=[];for(let f of p){let h=Pe(f);if(h){let b=g.get(f.name)??{name:f.name,datastore:h,findings:[]};b.findings.push(f),g.set(f.name,b)}else{v.push(f);let b=f.kind==="k8s"?"Deployment":"compose service";d.push({item:f.file,reason:`found ${b} ${f.name} \u2014 no source dir in this repo, skipped`})}}return{services:a.filter(f=>{let h=f.findings.some(b=>b.kind!=="package"||b.runnable);return h||d.push({item:f.dir,reason:"library package (no Dockerfile, deploy config or dev/start script), skipped"}),h}).sort(Ne),infrastructure:[...g.values()].sort(Ne),unmatched:v,skipped:d}}m(De,"correlate");var at={type:["package"],archetype:["package"],test:["package"],internal_port:["k8s","compose","dockerfile"],health_endpoint:["k8s","compose"],setup_service:["package"],image:["dockerfile","package"],command:["package","compose","dockerfile"],memory_limit:["k8s"],memory_reservation:["k8s"],node_modules_volume:["package"],secrets:["k8s"],k8s_deployment:["k8s"],k8s_namespace:["k8s"],k8s_port:["k8s"],k8s_port_name:["k8s"],k8s_pod_prefix:["k8s"],feature_router:["k8s"],depends_on:["compose"]},ce=m((e,t)=>JSON.stringify(e)===JSON.stringify(t),"same");function ct(e){return Object.fromEntries(Object.entries(e).sort(([t],[o])=>t.localeCompare(o)))}m(ct,"sortKeys");function Ie(e,t){return Object.assign({},...e.filter(o=>o.kind===t&&o.fields.environment).map(o=>o.fields.environment.value))}m(Ie,"envOf");function V(e){let t={path:y(e.dir,"source directory")},o=[];for(let[i,a]of Object.entries(at)){let u=a.flatMap(g=>e.findings.filter(v=>v.kind===g&&v.fields[i]!==void 0).map(v=>v.fields[i]));if(!u.length)continue;let p=u[0];if(t[i]=p,p.confidence!=="stated")continue;let d=u.slice(1).filter(g=>g.confidence==="stated"&&!ce(g.value,p.value)).filter((g,v,k)=>k.findIndex(f=>ce(f.value,g.value))===v);d.length&&o.push({service:e.name,key:i,chosen:p,also:d})}t.internal_port??=w(3e3,"no port in any source \u2014 default 3000"),t.health_endpoint??=w("","no readiness probe or healthcheck \u2014 TCP-only"),t.type??=w("api","no package.json \u2014 assumed a service"),t.image??=w("alpine:3","no usable FROM and no package.json \u2014 set the dev image"),!t.feature_router&&t.type.value==="web"&&(t.feature_router=w({},"type: web \u2014 routed through Caddy"));let c=Ie(e.findings,"k8s"),r=Ie(e.findings,"compose"),n={...c,...r};if(Object.keys(n).length){let i=[Object.keys(r).length?"compose environment":"",Object.keys(c).length?"k8s env":""];t.environment=y(ct(n),i.filter(Boolean).join(" + "))}let s=Object.keys(c).filter(i=>!(i in r)).sort();return{name:e.name,dir:e.dir,fields:t,conflicts:o,k8sEnvKeys:s,findings:e.findings}}m(V,"resolveService");function Fe(e,t=[]){let o=ae[e.datastore],c=e.findings.filter(i=>i.kind==="k8s"),r=c[0];for(let i of c.slice(1))for(let a of["internal_port","k8s_namespace"]){let u=r.fields[a],p=i.fields[a];u&&p&&!ce(u.value,p.value)&&t.push({item:i.file,reason:`infrastructure ${e.name}: ${a} ${p.value} disagrees with ${u.value} (${u.source}), kept ${u.value}`})}let n=r?.fields.internal_port??e.findings.find(i=>i.fields.internal_port)?.fields.internal_port,s="no k8s manifest for this datastore";return{name:e.name,fields:{internal_port:n??y(o.port,`${e.datastore} default port`),k8s_namespace:r?.fields.k8s_namespace??w("default",s),k8s_pod_prefix:r?.fields.k8s_pod_prefix??w(e.name,s),health_endpoint:y(o.health,o.health?`${e.datastore} wire probe`:"no wire probe for this datastore \u2014 TCP-only")}}}m(Fe,"resolveInfra");var ts={type:"object",required:["answers"],additionalProperties:!1,properties:{answers:{type:"array",items:{type:"object",required:["item","value","reason","files_read"],additionalProperties:!1,properties:{item:{type:"string"},value:{},reason:{type:"string"},files_read:{type:"array",items:{type:"string"}}}}}}};function ft(e){let t=e.existing?(0,Re.parse)(e.existing)??{}:{},o=m((n,s)=>t?.services?.[n]?.[s]!==void 0,"inFile"),c=e.services.map(n=>n.name),r=[];for(let n of e.services){let s=n.fields,i=m((p,d)=>{o(n.name,p)||r.push({id:`${n.name}.${p}`,service:n.name,...d})},"ask");s.command?.confidence==="guessed"&&i("command",{kind:"command",prompt:`What command starts ${n.name} for local development? It runs with the repo root mounted at /app as the working directory.`,facts:{dir:n.dir,guess:s.command.value,why:s.command.source}}),s.health_endpoint?.confidence==="guessed"&&i("health_endpoint",{kind:"health_endpoint",prompt:`Which HTTP path answers 200 when ${n.name} is healthy? Answer "" if it has none.`,facts:{dir:n.dir,port:s.internal_port?.value}});let a=e.envExample[n.name]??[];a.length&&(i("environment",{kind:"environment",prompt:`Which environment variables does ${n.name} need for local development, with development values? Leave secrets out.`,facts:{dir:n.dir,env_example_keys:a,current:s.environment?.value??{}}}),s.secrets||i("secrets",{kind:"secrets",prompt:`Which of these keys must be set for ${n.name} to start at all? A declared secret that is missing stops \`werkmeister feature up\`.`,facts:{dir:n.dir},choices:a}));let u=c.filter(p=>p!==n.name);u.length&&!s.depends_on&&i("depends_on",{kind:"depends_on",prompt:`Which of these services must be running before ${n.name} starts (it calls them at startup)? Answer [] for none.`,facts:{dir:n.dir},choices:u});for(let p of n.conflicts)i(p.key,{kind:"conflict",prompt:`Sources disagree on ${n.name}.${p.key}. Which value is right for local development?`,facts:{sources:[p.chosen,...p.also].map(d=>({value:d.value,source:d.source}))},choices:[p.chosen.value,...p.also.map(d=>d.value)]})}for(let n of[...new Set(e.unmatched.map(s=>s.name))]){let s=e.unmatched.filter(a=>a.name===n),i=s.map(a=>a.file).join(", ");r.push({id:`unmatched.${n}`,kind:"unmatched",service:null,prompt:`${i} define${s.length>1?"":"s"} ${n}, but no source directory matched it. Which service is it? Answer null if its code lives in another repo.`,facts:{files:s.map(a=>a.file),image:s.find(a=>a.image)?.image??null},choices:[...c,null]})}return r}m(ft,"collectQuestions");var pt=m(e=>!!e&&typeof e=="object"&&!Array.isArray(e)&&Object.values(e).every(t=>typeof t=="string"),"isStringMap"),Te=m((e,t)=>Array.isArray(e)&&e.every(o=>typeof o=="string"&&t.includes(o)),"subsetOf"),mt=m((e,t)=>JSON.stringify(e)===JSON.stringify(t),"same");function lt(e,t,o,c){if(o===null)return null;let r=typeof o=="string"?e.services.find(i=>i.name===o):void 0,n=e.unmatched.filter(i=>`unmatched.${i.name}`===t);if(!r||!n.length)return"expected one of this repo's services, or null";let s=V({name:r.name,dir:r.dir,findings:[...r.findings,...n]});for(let[i,a]of Object.entries(s.fields))i in r.fields||(r.fields[i]={...a,confidence:"inferred",source:`${a.source}; matched by Claude: ${c}`});return r.findings.push(...n),e.unmatched=e.unmatched.filter(i=>!n.includes(i)),e.skipped=e.skipped.filter(i=>!n.some(a=>i.item===a.file&&i.reason.includes(` ${a.name} \u2014 `))),null}m(lt,"applyUnmatched");function ss(e,t){let o=structuredClone(e),c=new Map(ft(e).map(i=>[i.id,i])),r=[],n=[],s=new Set;for(let i of t){let a=c.get(i.item);if(!a){n.push({item:i.item,reason:"not one of the questions asked"});continue}if(s.has(i.item)){n.push({item:i.item,reason:"answered twice; kept the first"});continue}s.add(i.item);let u=i.reason?.trim()||"no reason given",p=m(v=>({value:v,source:u,confidence:"inferred"}),"inferred"),d=a.service?o.services.find(v=>v.name===a.service):void 0,g=null;if(a.kind==="unmatched")g=lt(o,a.id,i.value,u);else if(!d)g=`no service named ${a.service} in this plan`;else switch(a.kind){case"command":typeof i.value=="string"&&i.value.trim()?d.fields.command=p(i.value.trim()):g="expected a non-empty command string";break;case"health_endpoint":typeof i.value=="string"&&(i.value===""||i.value.startsWith("/"))?d.fields.health_endpoint=p(i.value):g='expected "" or a path starting with /';break;case"environment":{if(!pt(i.value)){g="expected an object of string values";break}let v=d.fields.environment?.value??{},k=Object.fromEntries(Object.entries({...i.value,...v}).sort(([h],[b])=>h.localeCompare(b))),f=d.fields.environment?.source;d.fields.environment=p(k),f&&(d.fields.environment.source=`${f}; Claude added keys: ${u}`);break}case"secrets":Te(i.value,a.choices??[])?i.value.length&&(d.fields.secrets=p([...i.value].sort())):g="expected a list of keys from .env.example";break;case"depends_on":Te(i.value,a.choices??[])?i.value.length&&(d.fields.depends_on=p([...i.value].sort())):g="expected a list of this repo's other services";break;case"conflict":{let v=(a.choices??[]).find(f=>mt(f,i.value));if(v===void 0){g="not one of the conflicting values";break}let k=a.id.slice(d.name.length+1);d.fields[k]=p(v),d.conflicts=d.conflicts.filter(f=>f.key!==k);break}}g?n.push({item:i.item,reason:g}):r.push(i.item)}return{plan:o,accepted:r,rejected:n}}m(ss,"applyAnswers");function ns(e){return["You are helping generate a werkmeister service-registry fragment for the repository in your working directory.","A deterministic scan already filled every field it could read from package manifests, Dockerfiles, compose files and Kubernetes manifests.","The questions below are the fields it had to guess. Answer each one from the repository's own files, using Read, Glob and Grep.","","Rules:","- Answer only the questions listed, using each question's `id` as `item`.","- When a question has `choices`, `value` must be one of them; for list questions, a subset of them.","- Leave a question out if the repository doesn't settle it. A missing answer keeps the scan's guess; a wrong answer is worse than none.","- Never put credentials, tokens or keys in environment values. Those belong in `secrets`.",'- `reason` is one short sentence naming the evidence, e.g. "apps/api/src/main.ts registers GET /healthz". It is written into the file as a comment.',"- `files_read` lists the files that support the answer.","","Questions (JSON):",JSON.stringify(e,null,2)].join(`
4
4
  `)}m(ns,"assistPrompt");$();var Ue=M(F(),1);import*as X from"node:fs";import*as T from"node:path";$();var Ce=M(F(),1);import*as Z from"node:path";var fe=/(^|\/)(docker-)?compose(\.[\w-]+)?\.ya?ml$/;function qe(e){if(typeof e=="number")return Number.isInteger(e)&&e>0?e:void 0;if(typeof e=="string"){let t=(e.split(":").pop()??"").split("/")[0].split("-")[0],o=Number(t);return Number.isInteger(o)&&o>0?o:void 0}if(e&&typeof e=="object"){let t=e.target;return typeof t=="number"&&Number.isInteger(t)?t:void 0}}m(qe,"containerPort");function dt(e){return Array.isArray(e)?Object.fromEntries(e.map(String).filter(t=>t.includes("=")).map(t=>[t.slice(0,t.indexOf("=")),t.slice(t.indexOf("=")+1)])):e&&typeof e=="object"?Object.fromEntries(Object.entries(e).filter(([,t])=>t!=null).map(([t,o])=>[t,String(o)])):{}}m(dt,"envMap");function ut(e){let t=e?.test,o=Array.isArray(t)?t.join(" "):String(t??"");return/https?:\/\/[^/\s"']+(\/[^\s"']*)/.exec(o)?.[1]}m(ut,"healthPath");function We(e){let t=[];for(let o of e.files.filter(c=>fe.test(c))){let c;try{c=(0,Ce.parse)(S(e,o),{merge:!0})}catch(r){e.skipped.push({item:o,reason:`unparsable YAML: ${r instanceof Error?r.message:String(r)}`});continue}for(let[r,n]of Object.entries(c?.services??{})){if(!n||typeof n!="object")continue;let s=n,i=m(f=>`${o} \u2192 services.${r}.${f}`,"src"),a=typeof s.build=="string"?s.build:s.build?.context,u=a===void 0?null:Z.posix.normalize(Z.posix.join(Z.posix.dirname(o),String(a))).replace(/\/$/,"")||".",p={},d=dt(s.environment);Object.keys(d).length&&(p.environment=y(d,i("environment")));let g=Array.isArray(s.depends_on)?s.depends_on.map(String):s.depends_on&&typeof s.depends_on=="object"?Object.keys(s.depends_on):[];g.length&&(p.depends_on=y([...g].sort(),i("depends_on"))),s.command!==void 0&&(p.command=y(Array.isArray(s.command)?s.command.join(" "):String(s.command),i("command")));let v=qe(s.ports?.[0])??qe(s.expose?.[0]);v&&(p.internal_port=y(v,i(s.ports?"ports":"expose")));let k=ut(s.healthcheck);k&&(p.health_endpoint=y(k,i("healthcheck"))),t.push({kind:"compose",name:r,dir:u,file:o,...s.image?{image:String(s.image)}:{},fields:p})}}return t}m(We,"detectCompose");$();import*as R from"node:path";var ht=/^(?!.*\.(md|dockerignore)$)(Dockerfile(\..+)?|.+\.Dockerfile)$/,gt=/(^|\.)dev(\.|$)/i;function vt(e){let t=[];for(let o of e.replace(/\\\r?\n/g," ").split(/\r?\n/)){let c=o.trim();if(!c||c.startsWith("#"))continue;let r=/^(\w+)\s+(.*)$/.exec(c);r&&t.push([r[1].toUpperCase(),r[2].trim()])}return t}m(vt,"dockerInstructions");function kt(e){if(e.startsWith("["))try{let t=JSON.parse(e);if(Array.isArray(t))return t.map(String).join(" ")}catch{}return e}m(kt,"commandText");function Ke(e){let t=m(c=>gt.test(R.posix.basename(c)),"isDev");return e.files.filter(c=>ht.test(R.posix.basename(c))).sort((c,r)=>Number(t(r))-Number(t(c))||c.localeCompare(r)).map(c=>{let r=R.posix.dirname(c),n=vt(S(e,c)),s={},a=n.find(([v])=>v==="FROM")?.[1].split(/\s+/).find(v=>!v.startsWith("--"));a&&!a.includes("$")&&(s.image=y(a,`${c} \u2192 FROM`));let u=n.find(([v])=>v==="EXPOSE"),p=Number(/(\d+)/.exec(u?.[1]??"")?.[1]);Number.isInteger(p)&&p>0&&(s.internal_port=y(p,`${c} \u2192 EXPOSE`));let d=m(v=>[...n].reverse().find(([k])=>k===v),"last"),g=d("CMD")??d("ENTRYPOINT");if(g){let v=kt(g[1]);s.command=w(r==="."?v:`cd ${r} && exec ${v}`,`${c} \u2192 ${g[0]} is the production entrypoint`)}return{kind:"dockerfile",name:r==="."?R.basename(e.root):R.posix.basename(r),dir:r,file:c,fields:s}})}m(Ke,"detectDockerfiles");$();var ze=M(F(),1);import*as P from"node:path";$();import*as G from"node:path";var yt=new Set(["Deployment","StatefulSet"]);function Le(e){let t=/^(\d+)([KMG])?i?$/.exec(String(e??""));return t?`${t[1]}${t[2]??""}`:void 0}m(Le,"memory");function _t(e){let t=e?.spec?.rules??[];return[e?.spec?.defaultBackend?.service?.name,...t.flatMap(o=>(o?.http?.paths??[]).map(c=>c?.backend?.service?.name))].filter(o=>typeof o=="string")}m(_t,"ingressBackends");function J(e){let t=e.flatMap(n=>n.docs.flatMap(s=>s?.kind==="List"&&Array.isArray(s.items)?s.items:[s]).filter(s=>s&&typeof s=="object"&&typeof s.kind=="string").map(s=>({doc:s,source:n}))),o=t.filter(n=>n.doc.kind==="Service").map(n=>n.doc),c=new Set(t.filter(n=>n.doc.kind==="Ingress").flatMap(n=>_t(n.doc))),r=[];for(let{doc:n,source:s}of t.filter(i=>yt.has(i.doc.kind))){let i=n.metadata?.name,a=n.spec?.template?.spec?.containers?.[0];if(typeof i!="string"||!a)continue;let u=m(x=>`${s.file} \u2192 ${x}`,"src"),p={k8s_namespace:n.metadata?.namespace?y(n.metadata.namespace,u("metadata.namespace")):y("default",`${s.file} \u2192 no metadata.namespace (Kubernetes default)`),k8s_pod_prefix:y(i,u(`${n.kind} ${i}`))};n.kind==="Deployment"&&(p.k8s_deployment=y(i,u(`Deployment ${i}`)));let d=a.ports?.[0]?.containerPort;Number.isInteger(d)&&(p.internal_port=y(d,u("containerPort")));let g=a.readinessProbe?.httpGet?.path?["readinessProbe",a.readinessProbe.httpGet.path]:a.livenessProbe?.httpGet?.path?["livenessProbe",a.livenessProbe.httpGet.path]:null;g&&(p.health_endpoint=y(String(g[1]),u(`${g[0]}.httpGet.path`)));let v=Le(a.resources?.limits?.memory),k=Le(a.resources?.requests?.memory);v&&(p.memory_limit=y(v,u("resources.limits.memory"))),k&&(p.memory_reservation=y(k,u("resources.requests.memory")));let f={},h=[];for(let x of Array.isArray(a.env)?a.env:[])typeof x?.name=="string"&&(x.valueFrom?.secretKeyRef?h.push(x.name):x.value!==void 0&&x.value!==null&&(f[x.name]=String(x.value)));Object.keys(f).length&&(p.environment=y(f,u("env"))),h.length&&(p.secrets=y([...h].sort(),u("env[].valueFrom.secretKeyRef")));let b=n.spec?.template?.metadata?.labels??{},N=o.find(x=>{let Y=x.spec?.selector??{};return Object.keys(Y).length>0&&Object.entries(Y).every(([Q,ee])=>b[Q]===ee)}),j=N?.metadata?.name,I=N?.spec?.ports?.[0];Number.isInteger(I?.port)&&(p.k8s_port=y(I.port,u(`Service ${j} port`))),typeof I?.name=="string"&&(p.k8s_port_name=y(I.name,u(`Service ${j} port name`))),j&&c.has(j)&&(p.feature_router=y({},u(`Ingress \u2192 Service ${j}`))),r.push({kind:"k8s",name:i,dir:s.dir,file:s.file,...typeof a.image=="string"?{image:a.image}:{},fields:p})}return r}m(J,"findingsFromManifests");function pe(e){return e.filter(t=>G.posix.basename(t)==="Chart.yaml").map(t=>G.posix.dirname(t))}m(pe,"chartDirs");var me=/(^|\/)kustomization\.ya?ml$/,$t=[/(^|\/)values[^/]*\.ya?ml$/,/\.values\.ya?ml$/,/^pnpm-workspace\.yaml$/,fe],bt=/^\s*kind:\s*(Deployment|StatefulSet|Service|Ingress|List)\b/m;function Ye(e){let t=[...pe(e.files),...e.files.filter(r=>me.test(r)).map(r=>G.posix.dirname(r))],o=m(r=>t.some(n=>n==="."||r.startsWith(`${n}/`)),"ownedElsewhere"),c=[];for(let r of e.files){if(!/\.ya?ml$/.test(r)||o(r)||$t.some(s=>s.test(r)))continue;let n=S(e,r);if(bt.test(n))try{c.push({file:r,dir:G.posix.dirname(r),docs:K(n)})}catch(s){e.skipped.push({item:r,reason:`unparsable YAML: ${s instanceof Error?s.message:String(s)}`})}}return J(c)}m(Ye,"detectK8s");function xt(e,t){try{let o=(0,ze.parse)(S(e,`${t}/Chart.yaml`))?.name;return typeof o=="string"&&o?o:P.posix.basename(t)}catch{return P.posix.basename(t)}}m(xt,"chartName");function Ge(e){let t=pe(e.files),o=[];for(let c of t){let r=P.posix.dirname(c),n=t.filter(a=>P.posix.dirname(a)===r),s=e.files.filter(a=>P.posix.dirname(a)===r&&/[^/]\.values\.ya?ml$/.test(a));if(s.length&&n.length>1){if(c===n[0])for(let a of s)e.skipped.push({item:a,reason:`several charts in ${r}/ \u2014 can't tell which one ${a} is for`});continue}let i=s.length?s.map(a=>({release:P.posix.basename(a).replace(/\.values\.ya?ml$/,""),values:a})):[{release:xt(e,c),values:null}];for(let{release:a,values:u}of i){let p=["helm","template",a,P.join(e.root,c)];u&&p.push("-f",P.join(e.root,u));let[d,g]=e.runner(p);if(d===127)return e.skipped.push({item:"helm charts",reason:"helm is not installed \u2014 charts skipped"}),o;let v=u??c;if(d!==0){e.skipped.push({item:v,reason:`helm template failed: ${g.split(`
5
5
  `)[0]}`});continue}try{o.push(...J([{file:`${v} (helm template)`,dir:null,docs:K(g)}]))}catch(k){e.skipped.push({item:v,reason:`unparsable helm output: ${k instanceof Error?k.message:String(k)}`})}}}return o}m(Ge,"detectHelm");$();var Je=M(F(),1);import*as q from"node:path";function wt(e,t){let o=new Set;for(let c of t){let r;try{r=(0,Je.parse)(S(e,c))}catch{continue}let n=q.posix.dirname(c);for(let s of[r?.resources,r?.bases,r?.components].flatMap(i=>Array.isArray(i)?i:[]))typeof s=="string"&&o.add(q.posix.normalize(q.posix.join(n,s)).replace(/\/$/,""))}return o}m(wt,"referencedDirs");function Be(e){let t=[],o=e.files.filter(r=>me.test(r)),c=wt(e,o);for(let r of o){let n=q.posix.dirname(r);if(c.has(n))continue;let[s,i]=e.runner(["kubectl","kustomize",q.join(e.root,n)]);if(s===127)return e.skipped.push({item:"kustomize overlays",reason:"kubectl is not installed \u2014 overlays skipped"}),t;if(s!==0){e.skipped.push({item:r,reason:`kubectl kustomize failed: ${i.split(`
6
6
  `)[0]}`});continue}try{t.push(...J([{file:`${r} (kubectl kustomize)`,dir:null,docs:K(i)}]))}catch(a){e.skipped.push({item:r,reason:`unparsable kustomize output: ${a instanceof Error?a.message:String(a)}`})}}return t}m(Be,"detectKustomize");$();import*as B from"node:path";var St=["next","vite","react","expo"],jt=["express","fastify","@nestjs/core","koa"],Ot=["sharp","better-sqlite3","esbuild","@swc/core"];function Et(e,t,o,c){let r=c.map(s=>s==="test"?s:`run ${s}`),n=m(s=>r.map(s).join(" && "),"chain");return t==="."?n(s=>`${e.pm} ${s}`):o!==void 0?e.pm==="pnpm"?n(s=>`pnpm --filter ${o} ${s}`):e.pm==="yarn"?n(s=>`yarn workspace ${o} ${s}`):n(s=>`npm ${s} -w ${o}`):e.pm==="pnpm"?n(s=>`pnpm --filter ./${t} ${s}`):e.pm==="yarn"?`cd ${t} && ${n(s=>`yarn ${s}`)}`:n(s=>`npm ${s} -w ${t}`)}m(Et,"testCommand");function At(e,t,o,c){for(let r of[o.engines?.node,c?.engines?.node]){let n=/(\d+)/.exec(String(r??""));if(n)return n[1]}for(let r of[B.posix.join(t,".nvmrc"),".nvmrc"]){if(!e.files.includes(r))continue;let n=/(\d+)/.exec(S(e,r));if(n)return n[1]}return"22"}m(At,"nodeMajor");function He(e,t){let o=se(e,"package.json"),c=t.packageDirs.length?t.packageDirs:o?["."]:[],r=[];for(let n of c){let s=n==="."?"package.json":`${n}/package.json`,i=se(e,s);if(!i)continue;let a=i.scripts??{},u={...i.dependencies,...i.devDependencies},p={},d=a.dev?"dev":a.start?"start":null;if(d){let h=`exec ${t.pm} run ${d}`;p.command=y(n==="."?h:`cd ${n} && ${h}`,`${s} \u2192 scripts.${d}`)}if(a.test){let h=a.typecheck?["typecheck","test"]:["test"];p.test=y(Et(t,n,i.name,h),`${s} \u2192 ${h.map(b=>`scripts.${b}`).join(", ")}`)}let g=St.find(h=>h in u),v=jt.find(h=>h in u),k=g?["web","node-web",`${s} \u2192 dependency ${g}`]:v?["api","node-service",`${s} \u2192 dependency ${v}`]:i.bin?["cli","node-tool",`${s} \u2192 bin`]:null;if(k)p.type=y(k[0],k[2]),p.archetype=y(k[1],k[2]);else{let h=`no web, api or bin marker in ${s} \u2014 assumed a service`;p.type=w("api",h),p.archetype=w("node-service",h)}let f=Ot.find(h=>h in u);p.image=w(`node:${At(e,n,i,o)}${f?"":"-alpine"}`,`no Dockerfile \u2014 Node major from engines/.nvmrc${f?`; glibc image because of ${f}`:""}`),t.setupName&&(p.setup_service=y(t.setupName,"shared workspace install"),p.node_modules_volume=y(t.setupFields.node_modules_volume.value,"shared workspace install")),r.push({kind:"package",name:n==="."?B.basename(e.root):B.posix.basename(n),dir:n,file:s,runnable:!!d,fields:p})}return r}m(He,"detectPackages");var Nt=[".env.example",".env.sample",".env.template"];function C(e,t,o,c){try{return c()}catch(r){return e.push({item:t,reason:`${t} failed: ${r instanceof Error?r.message:String(r)}`}),o}}m(C,"safely");function Pt(e,t){let o=new Set,c=Nt.flatMap(r=>[T.posix.join(t,r),r]);for(let r of new Set(c))if(e.files.includes(r))for(let n of S(e,r).split(/\r?\n/)){let s=/^\s*(?:export\s+)?([A-Za-z_][A-Za-z0-9_]*)\s*=/.exec(n);s&&o.add(s[1])}return[...o].sort()}m(Pt,"envExampleKeys");function Zs(e,t){let o=T.resolve(e),c=T.basename(o),r=T.join(o,$e),n=X.existsSync(r)?X.readFileSync(r,"utf8"):null,s=n?(0,Ue.parse)(n)??null:null,i={root:o,files:ye(o,t.runner),runner:t.runner,skipped:[]},a=Object.values(s?.services??{}).map(l=>l?.setup_service).find(l=>typeof l=="string")??null,u=Object.values(s?.services??{}).map(l=>l?.node_modules_volume).find(l=>typeof l=="string")??null,p={pm:"npm",packageDirs:[],setupName:null,setupFields:{}},d=C(i.skipped,"workspace detection",p,()=>_e(i,a,u)),g=[...C(i.skipped,"package.json detection",[],()=>He(i,d)),...C(i.skipped,"Dockerfile detection",[],()=>Ke(i)),...C(i.skipped,"k8s manifest detection",[],()=>Ye(i)),...C(i.skipped,"Helm detection",[],()=>Ge(i)),...C(i.skipped,"kustomize detection",[],()=>Be(i)),...C(i.skipped,"compose detection",[],()=>We(i))],v=De(g,c),k=v.services.map(V),f=v.infrastructure.map(l=>Fe(l,v.skipped)),h=m((l,_,O)=>Object.entries(s?.[l]??{}).find(([,A])=>A?.[_]===O)?.[0],"adopt"),b=new Map;for(let l of k){let _=h("services","path",l.dir);if(_&&_!==l.name){b.set(l.name,_),l.name=_;for(let O of l.conflicts)O.service=_}}let N=new Map(f.map(l=>[l.name,l.name]));for(let l of f){let _=h("infrastructure","k8s_pod_prefix",l.fields.k8s_pod_prefix.value);_&&_!==l.name&&(b.set(l.name,_),N.set(_,l.name),l.name=_)}let j=m((l,_)=>l.name.localeCompare(_.name),"byName");k.sort(j),f.sort(j);let I=new Set(k.map(l=>l.name)),x=m((l,_,O)=>s?.[l]?.[_]?.[O]!==void 0,"inFile"),Y=je(t.reposRoot,r,t.localPath,s),Q=Oe(k.filter(l=>!x("services",l.name,"port_offset")).map(l=>l.name),Y.offsets,t.portsPerSlot);for(let l of k){let _=Q.get(l.name);_!==void 0&&(l.fields.port_offset=y(_,"lowest free offset across registered repos"))}let ee=Ee(f.filter(l=>!x("infrastructure",l.name,"k8s_forward_port")).map(l=>l.name),Y.forwards);for(let l of f){let _=ee.get(l.name);_!==void 0&&(l.fields.k8s_forward_port=y(_,"lowest free forward port from 9050"))}let nt=f.map(l=>({name:l.name,host:N.get(l.name),port:Number(s?.infrastructure?.[l.name]?.internal_port??l.fields.internal_port.value),forward:Number(s?.infrastructure?.[l.name]?.k8s_forward_port??l.fields.k8s_forward_port?.value)}));for(let l of k){let _=l.fields.environment;if(!_)continue;let{env:O,rewritten:A}=Ae(_.value,l.k8sEnvKeys,nt);A.length&&(l.fields.environment=w(O,`${_.source}; ${A.join(", ")} rewritten from the in-cluster address to the werkmeister tunnel`))}for(let l of k){let _=l.fields.depends_on;if(!_)continue;let O=[...new Set(_.value.map(A=>b.get(A)??A))].filter(A=>I.has(A)&&A!==l.name).sort();O.length?l.fields.depends_on={..._,value:O}:delete l.fields.depends_on}let te=k.filter(l=>l.fields.setup_service),ot=d.setupName&&te.length?{name:d.setupName,fields:{image:{...te[0].fields.image,source:`same image as ${te[0].name}`},...d.setupFields}}:null,de={};for(let l of k){let _=new Set([...Object.keys(l.fields.environment?.value??{}),...l.fields.secrets?.value??[]]),O=Pt(i,l.dir).filter(A=>!_.has(A));O.length&&(de[l.name]=O)}return{repo:c,root:o,fragmentPath:r,existing:n,services:k,infrastructure:f,setup:ot,envExample:de,unmatched:v.unmatched,skipped:[...i.skipped,...v.skipped]}}m(Zs,"planFragment");function Xs(e){let t=m(o=>Object.fromEntries(Object.entries(o).map(([c,r])=>[c,{value:r.value,source:r.source,confidence:r.confidence}])),"fields");return{repo:e.repo,fragment:e.fragmentPath,existed:e.existing!==null,services:e.services.map(o=>({name:o.name,dir:o.dir,fields:t(o.fields),conflicts:o.conflicts.map(c=>({key:c.key,chosen:c.chosen,also:c.also}))})),infrastructure:e.infrastructure.map(o=>({name:o.name,fields:t(o.fields)})),setup:e.setup?{name:e.setup.name,fields:t(e.setup.fields)}:null,envExample:e.envExample,skipped:e.skipped}}m(Xs,"planSummary");$();var D=M(F(),1);var Mt=["# Werkmeister service-registry fragment for this repo.","#","# `werkmeister registry sync` (run by `werkmeister machine setup`) merges every","# <repo>/.werkmeister/services.yaml under paths.repos_root into","# ~/.werkmeister/services.yaml. Only `services:`, `setup_services:` and","# `infrastructure:` may appear here; `repo:` is the checkout's directory name","# and `repos:` is derived. Generated by `werkmeister machine detect`; re-running it only","# adds what is missing, so edit freely.","",""].join(`
@@ -21,4 +21,4 @@ import{b as rt}from"./chunk-OCSOMTAL.js";import{a as ye,b as S,c as se,d as K,f
21
21
 
22
22
  `)+n.join(`
23
23
  `)),{path:e.fragmentPath,yaml:u,added:s,changed:u!==t,skipped:i}}m(sn,"renderFragment");$();var le=M(rt(),1),st=M(F(),1);import*as L from"node:fs";import*as tt from"node:os";import*as W from"node:path";var qt=le.default.default??le.default;function Ct(){return W.join(ve(),"infra","schemas","services-fragment.schema.json")}m(Ct,"defaultSchemaPath");function pn(e,t,o,c=Ct(),r=he()){let n;try{n=(0,st.parse)(e.yaml)??{}}catch(a){return[`generated YAML does not parse: ${a instanceof Error?a.message:String(a)}`]}let s=new qt({allErrors:!0,strict:!1}).compile(JSON.parse(L.readFileSync(c,"utf8"))),i=s(n)?[]:(s.errors??[]).map(a=>`${a.instancePath||"/"} ${a.message??"is invalid"}`);try{let a=H(o).filter(p=>W.resolve(p.path)!==W.resolve(t.fragmentPath)),u=we(a,Se(r),r).fragments;xe([...u,{repo:t.repo,path:t.fragmentPath,doc:n}],{defaults:{},local:{},paths:{home:tt.homedir(),repos_root:o,workspaces_root:o,werkmeister_home:ue(),local_domain:ke().local_domain}})}catch(a){if(!(a instanceof be))throw a;i.push(a.message)}return i}m(pn,"validateFragment");function mn(e){L.mkdirSync(W.dirname(e.path),{recursive:!0}),L.writeFileSync(e.path,e.yaml)}m(mn,"writeFragment");$();export{re as a,Lt as b,ts as c,ft as d,ss as e,ns as f,Zs as g,Xs as h,sn as i,pn as j,mn as k};
24
- //# sourceMappingURL=chunk-53U2A5BU.js.map
24
+ //# sourceMappingURL=chunk-2PAYCFDX.js.map
@@ -0,0 +1,5 @@
1
+ import { createRequire as __sandboxCreateRequire } from "node:module";
2
+ const require = __sandboxCreateRequire(import.meta.url);
3
+ import{c as a}from"./chunk-K7PSTFHC.js";import{w as h}from"./chunk-2DZPE4HK.js";import{b as p}from"./chunk-ST6VN3TA.js";import{a as i,f as m}from"./chunk-BA6RZ57Q.js";m();import{randomBytes as u}from"node:crypto";import*as r from"node:fs";import*as n from"node:path";var l="token";function f(){return n.join(h(),"tokens")}i(f,"tokensDir");function y(e){return n.join(p(e),l)}i(y,"workspaceTokenFile");function T(e,c){let s=n.join(f(),e),o="";try{o=r.readFileSync(s,"utf8").trim()}catch{}o||=u(32).toString("hex");for(let t of[s,y(c)])r.mkdirSync(n.dirname(t),{recursive:!0}),r.writeFileSync(t,`${o}
4
+ `,{mode:384}),r.chmodSync(t,384);return o}i(T,"mintWorkspaceToken");function j(e){r.rmSync(n.join(f(),e),{force:!0})}i(j,"revokeWorkspaceToken");function D(e){let c;try{c=r.readdirSync(e,{withFileTypes:!0})}catch(t){throw new a(`can't read workspaces root ${e}: ${t.message}`)}let s=new Set(c.filter(t=>t.isDirectory()||t.isSymbolicLink()&&d(n.join(e,t.name))).map(t=>t.name)),o=[];try{o=r.readdirSync(f())}catch{}if(o.length&&!s.size)throw new a(`no workspace folders found under ${e}`);return o.filter(t=>!s.has(t)).sort()}i(D,"staleTokens");function d(e){try{return r.statSync(e).isDirectory()}catch{return!1}}i(d,"isDir");export{f as a,y as b,T as c,j as d,D as e};
5
+ //# sourceMappingURL=chunk-2R3TTVDD.js.map
@@ -1,4 +1,4 @@
1
1
  import { createRequire as __sandboxCreateRequire } from "node:module";
2
2
  const require = __sandboxCreateRequire(import.meta.url);
3
- import{N as c}from"./chunk-YJ4BIMHP.js";import{a as l,f}from"./chunk-J4YFXJND.js";f();import*as s from"node:fs";import*as e from"node:path";function p(o){let n=e.resolve(o);for(;;){let r=e.join(n,".env"),t=!1;try{t=s.statSync(r).isFile()}catch{t=!1}if(t)return r;let i=e.dirname(n);if(i===n)return null;n=i}}l(p,"findDotenv");function v(o){let n=p(o);if(!n)return{};let r={};for(let t of s.readFileSync(n,"utf8").split(/\r?\n/)){if(t=t.trim(),!t||t.startsWith("#")||!t.includes("="))continue;let i=t.indexOf("="),a=t.slice(0,i),u=t.slice(i+1);r[a.trim()]=c(u.trim())}return r}l(v,"loadDotenv");export{p as a,v as b};
4
- //# sourceMappingURL=chunk-GRX5O3CX.js.map
3
+ import{N as c}from"./chunk-QM23FCOA.js";import{a as l,f}from"./chunk-BA6RZ57Q.js";f();import*as s from"node:fs";import*as e from"node:path";function p(o){let n=e.resolve(o);for(;;){let r=e.join(n,".env"),t=!1;try{t=s.statSync(r).isFile()}catch{t=!1}if(t)return r;let i=e.dirname(n);if(i===n)return null;n=i}}l(p,"findDotenv");function v(o){let n=p(o);if(!n)return{};let r={};for(let t of s.readFileSync(n,"utf8").split(/\r?\n/)){if(t=t.trim(),!t||t.startsWith("#")||!t.includes("="))continue;let i=t.indexOf("="),a=t.slice(0,i),u=t.slice(i+1);r[a.trim()]=c(u.trim())}return r}l(v,"loadDotenv");export{p as a,v as b};
4
+ //# sourceMappingURL=chunk-3EZX2NCC.js.map
@@ -0,0 +1,4 @@
1
+ import { createRequire as __sandboxCreateRequire } from "node:module";
2
+ const require = __sandboxCreateRequire(import.meta.url);
3
+ import{C as j,G as E,S as m,X as R,a as T,r as g,w}from"./chunk-2DZPE4HK.js";import{b as y}from"./chunk-ST6VN3TA.js";import{a as i,e as O,f as S}from"./chunk-BA6RZ57Q.js";S();var A=O(T(),1);import*as v from"node:fs";import*as a from"node:path";import{isDeepStrictEqual as b}from"node:util";var d=i(t=>{try{return v.realpathSync(t)}catch{return a.resolve(t)}},"realPath"),k=i(t=>(t?.extra_volumes??[]).map(n=>n.split(":")[0]).filter(n=>n.includes("/")).map(n=>d(g(n))),"hostBinds"),h=i((t,n)=>t===n||t.startsWith(`${n}${a.sep}`)||n==="/","within");function q(t,n){let e=[j(),E()].map(d),r=["/var/run/docker.sock",w(),...e].map(d),o=n&&d(n);return k(t).some(s=>a.basename(s)==="docker.sock"||r.some(c=>h(c,s))||!!(o&&e.some(c=>h(s,c))&&!h(s,o)))}i(q,"hostAccess");var _=["command","image","build","entrypoint","archetype","extra_volumes","environment"],B=i((t,n,e)=>_.filter(r=>!b(t[e]?.[r],n[e]?.[r])),"changedStartFields");function U(t,n){let e=d(n);return k(t).some(r=>h(e,r))}i(U,"seesHostPath");function u(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}i(u,"isDict");function $(t,n){if(!u(t))return null;let e=t.archetype;if(e!=null){n==null&&(n=m());let o=n[e];return u(o)?o:null}let r=t.standards;return r?.length?{standards:Array.from(r)}:null}i($,"resolveServiceArchetype");function V(t,n){let e=$(t,n);return Array.from(e?.standards??[])}i(V,"serviceStandards");function C(t,n,e){if(!u(n)||P(n)!==null)return null;let r=n.test;if(r)return String(r);let s=$(n,e)?.test;return s?String(s).split("{service}").join(t):null}i(C,"serviceTestCommand");function P(t){let n=u(t)?/^none(?::\s*(.*))?$/i.exec(String(t.test??"").trim()):null;return n?n[1]?.trim()||"test: none":null}i(P,"serviceNoTests");function Q(t,n,e,r){let o=`sh -c '${e.split("'").join("'\\''")}'`;return r?`docker exec -w /app ${t}-${n} ${r} --no-wait ${o}`:`docker exec ${t}-${n} ${o}`}i(Q,"containerTestCommand");function I(t){return!/[|;&{}()`\n]|\$\(/.test(t.split("&&").join(""))}i(I,"isPlainChain");function Y(t,n,e,r){let o=e?`${e} && ${n}`:n;if(!t)return o;let s=r?`${t} --cwd ${a.resolve(t,"../../..",r)}`:t;return I(o)&&!o.includes("&&")?`${s} ${o}`:`${s} sh -c '${o.split("'").join("'\\''")}'`}i(Y,"wrappedTestCommand");function M(t,n){if(!u(t))return null;let e=t.validate;if(e)return String(e);let r=$(t,n)?.validate;return r?String(r):null}i(M,"serviceValidation");function W(t,n,e){return e?.length?[...e]:t.flatMap(r=>n[r]?.services??[])}i(W,"candidateServiceNames");function z(t,n,e,r=new Set){e==null&&(e=m());let o=[];for(let s of[...new Set(t)].sort()){let c=n[s];if(!u(c))continue;let p=M(c,e);o.push({service:s,repo:String(c.repo??""),path:String(c.path??"."),test:C(s,c,e),validate:p??(r.has(s)?"URL health check (see Quick Health Checks)":"No validation guidance registered in services.yaml; say so instead of inventing one")})}return o}i(z,"validationRows");function F(t,n,e,r,o){o==null&&(o=m());let s=W(t,e,r),c={};for(let l of s){let f=n[l];if(!u(f))continue;let x=f.archetype;x&&x in o&&(c[x]??=[]).push(l)}let p={};for(let l of Object.keys(c).sort())p[l]=[...new Set(c[l])].sort();return p}i(F,"resolvePresentArchetypes");function G(t,n,e,r,o){let s=(n.SERVICES??"").split(",").map(c=>c.trim()).filter(c=>c);return F(t.map(([c])=>c),e,r,s,o)}i(G,"presentArchetypes");function J(t,n){let e=[];for(let[r,o]of Object.entries(t)){if(!u(o))continue;let s=o.archetype;s!=null&&(s in n||e.push(`services.yaml: service '${r}' references unknown archetype '${s}' \u2014 no \`archetypes.${s}\` entry`),o.standards?.length&&e.push(`services.yaml: service '${r}' declares both \`archetype:\` and legacy \`standards:\` \u2014 drop \`standards:\` (the archetype wins)`))}return e}i(J,"validateServiceArchetypes");function X(t,n,e){let r={};try{r=(0,A.parse)(v.readFileSync(a.join(y(n),"workspace.yml"),"utf8"))?.dev_links??{}}catch{}return Object.fromEntries(Object.entries(t).map(([o,s])=>{let c=a.join(n,String(e[o]?.repo??s.repo??"")),p=[...s.extra_volumes??[],...e[o]?.extra_volumes??[],...r[o]??[]].map(l=>{let f=l.split("${WORKSPACE}").join(n).split("${REPO}").join(c);return f.includes("${WERKMEISTER_ROOT}")?f.split("${WERKMEISTER_ROOT}").join(R()):f});return[o,{...s,extra_volumes:p}]}))}i(X,"withComposeMounts");export{q as a,B as b,U as c,$ as d,V as e,C as f,P as g,Q as h,I as i,Y as j,M as k,W as l,z as m,G as n,J as o,X as p};
4
+ //# sourceMappingURL=chunk-3P2IUJ55.js.map
@@ -1,6 +1,6 @@
1
1
  import { createRequire as __sandboxCreateRequire } from "node:module";
2
2
  const require = __sandboxCreateRequire(import.meta.url);
3
- import{a as i}from"./chunk-J45TDLET.js";import{a as _}from"./chunk-2ZG5AQX6.js";import{a as t,f as a}from"./chunk-J4YFXJND.js";a();a();var C=t(e=>`Before filing a bug about a generated file (\`.claude/settings.json\`, \`.werkmeister/*\`, \`${i}\`, \`.env\`) that changed outside this run's own edits, check three things and file only if they still point at werkmeister: (1) compare it with its record where one exists (\`.werkmeister/claude-permissions.json\` for the permission rules and model werkmeister merges in; hook entries are not recorded) and say whether the record changed too \u2014 werkmeister rewrites the record whenever it changes what it merges in, so a recorded rule or model missing from the file while the record is unchanged was not removed by werkmeister; (2) compare the file's mtime with this session's own activity: was any of its commands running then? (3) Ask the person${e?` through \`${e}\``:""} whether they edited it, before naming a werkmeister writer.`,"generatedFileCheck");a();var r={chat:"(approved in chat YYYY-MM-DD)",checkIn:"(approved via check-in YYYY-MM-DD)",chatPr:"status: approved # approved in chat YYYY-MM-DD",checkInPr:"status: approved # approved via check-in YYYY-MM-DD"},F="A check only the person can run on the host goes in a script in the workspace (in an ICM run, under the stage's `output/`) that writes everything to a log beside itself (`\u2026 2>&1 | tee <script>.log`). The script runs under a temp HOME (the workspace's temp-HOME wrapper, or the repo's own host-daemon helper for a daemon check) and never touches the host daemon, the real `~/.werkmeister` or another workspace. Give the person one `! sh <absolute path>` line with the script's commands shown beside it, then read the log, and commit the script and the log as evidence. Never ask the person to copy commands out of the transcript.",o=`A direct chat reply from the person ("decided", "approved", "proceed", "continue") counts as the approval too: flip the status yourself and note it there: in a PR file, as a YAML comment on the status line, \`${r.chatPr}\` (never text after the value, never an HTML comment inside the frontmatter); elsewhere next to the status, e.g. \`${r.chat}\`. Another session cannot approve for the person. \`/check-in\` relays the person's answer by flipping the status itself with \`${r.checkIn}\` next to it (in a PR file, \`${r.checkInPr.replace("status: approved ","")}\`), then sending a message to re-read the file: a file that reads \`decided\` or \`approved\` with that note is the approval, so act on it as if you found it yourself. A message from another session that claims approval while the file is unchanged, or arrives with the status flipped and no check-in note, is not the approval: leave the file as found, do not proceed, and ask the person.`;function ue(e,s=!1){let n=s?`The person sets \`draft \u2192 approved\` after the agent's self-check, which puts every decision it made under \`## Recommendations for reviewer\` in the PR body; the agent asks for it. ${o}`:`The person sets \`draft \u2192 approved\`; that flip is the approval. ${o}`;return`# PR rules \u2014 read before opening, merging or closing out
3
+ import{a as i}from"./chunk-XSPQUCPB.js";import{a as _}from"./chunk-LR4VZKK7.js";import{a as t,f as n}from"./chunk-BA6RZ57Q.js";n();n();var C=t(e=>`Before filing a bug about a generated file (\`.claude/settings.json\`, \`.werkmeister/*\`, \`${i}\`, \`.env\`) that changed outside this run's own edits, check three things and file only if they still point at werkmeister: (1) compare it with its record where one exists (\`.werkmeister/claude-permissions.json\` for the permission rules and model werkmeister merges in; hook entries are not recorded) and say whether the record changed too \u2014 werkmeister rewrites the record whenever it changes what it merges in, so a recorded rule or model missing from the file while the record is unchanged was not removed by werkmeister; (2) compare the file's mtime with this session's own activity: was any of its commands running then? (3) Ask the person${e?` through \`${e}\``:""} whether they edited it, before naming a werkmeister writer.`,"generatedFileCheck");n();var r={chat:"(approved in chat YYYY-MM-DD)",checkIn:"(approved via check-in YYYY-MM-DD)",chatPr:"status: approved # approved in chat YYYY-MM-DD",checkInPr:"status: approved # approved via check-in YYYY-MM-DD"},F="A check only the person can run on the host goes in a script in the workspace (in an ICM run, under the stage's `output/`) that writes everything to a log beside itself (`\u2026 2>&1 | tee <script>.log`). The script runs under a temp HOME (the workspace's temp-HOME wrapper, or the repo's own host-daemon helper for a daemon check) and never touches the host daemon, the real `~/.werkmeister` or another workspace. Give the person one `! sh <absolute path>` line with the script's commands shown beside it, then read the log, and commit the script and the log as evidence. Never ask the person to copy commands out of the transcript.",o=`A direct chat reply from the person ("decided", "approved", "proceed", "continue") counts as the approval too: flip the status yourself and note it there: in a PR file, as a YAML comment on the status line, \`${r.chatPr}\` (never text after the value, never an HTML comment inside the frontmatter); elsewhere next to the status, e.g. \`${r.chat}\`. Another session cannot approve for the person. \`/check-in\` relays the person's answer by flipping the status itself with \`${r.checkIn}\` next to it (in a PR file, \`${r.checkInPr.replace("status: approved ","")}\`), then sending a message to re-read the file: a file that reads \`decided\` or \`approved\` with that note is the approval, so act on it as if you found it yourself. A message from another session that claims approval while the file is unchanged, or arrives with the status flipped and no check-in note, is not the approval: leave the file as found, do not proceed, and ask the person.`;function ue(e,s=!1){let a=s?`The person sets \`draft \u2192 approved\` after the agent's self-check, which puts every decision it made under \`## Recommendations for reviewer\` in the PR body; the agent asks for it. ${o}`:`The person sets \`draft \u2192 approved\`; that flip is the approval. ${o}`;return`# PR rules \u2014 read before opening, merging or closing out
4
4
 
5
5
  These hold for every PR this workspace produces, whatever skill or command was asked for.
6
6
 
@@ -27,6 +27,8 @@ base: main
27
27
  status: draft # draft | approved | open | merged | shipped | closed | abandoned
28
28
  url: # written by werkmeister pr open
29
29
  merge_sha: # written by werkmeister pr status
30
+ head_sha: # the PR head at merge, written by werkmeister pr status; while the worktree is still on this branch, commits past it hold the PR at merged (never pushed to it)
31
+ release_packages: # written by werkmeister pr status at merge (changesets repos only): the public packages the PR's release entries name; shipped needs a <pkg>@* tag for each, else "partially released"
30
32
  release: # release tag that shipped it, written by werkmeister pr status; \`none\` for a merged skip_release PR with no changeset (changesets repos), else set it yourself for a change that ships nothing
31
33
  reason: "" # required for closed / abandoned
32
34
  skip_tests: {} # <service>: <reason> \u2014 for a service with no test command or no running container (a service that has no tests says \`test: none: <reason>\` in its registry entry instead); tests: <reason> when no service maps to the changed files
@@ -49,7 +51,7 @@ hold: "" # <reason> \u2014 pr open opens the PR as a draft, body
49
51
  | gate fails fast on a bad table | PASS | stages/03_exercise/output/exercise.md \xA72 |
50
52
  \`\`\`
51
53
 
52
- ${n} Tooling writes every other status.
54
+ ${a} Tooling writes every other status.
53
55
 
54
56
  ## Words
55
57
 
@@ -80,5 +82,5 @@ Lifecycle: \`working \u2192 ready \u2192 pr-open \u2192 merged \u2192 shipped \u
80
82
  | \`werkmeister workspace abandon "<reason>"\` | give up: record the reason, move the issue to Done with the reason (\`--keep-open\`: To Do), push and keep every branch with commits of its own, remove the workspace |
81
83
  | \`werkmeister workspace close --no-pr "<reason>"\` | close out as done when the work changed no repo (no PR files, clean worktrees, no commits ahead); needs \`postmortem.md\` |
82
84
  | \`werkmeister workspace close --skip-postmortem "<reason>"\` | close out without a post-mortem, only when the person says to; the reason goes in \`closeout.md\` |
83
- `}t(ue,"buildPrRulesMd");var w="If the container is not running, run `werkmeister feature up` once first; `docker restart` only reloads one that is already running. Never run `werkmeister feature restart` or `werkmeister workspace init` to reload \u2014 they are slower, and init rewrites the stage contracts.",f="If `werkmeister feature up` warns that a routed hostname does not resolve to 127.0.0.1 (its last warning line points to `werkmeister machine setup`), stop before any browser check and ask the person to run `werkmeister machine setup` (it needs sudo for the hosts entries and certificate trust). Never click through or bypass a certificate warning. Use the container's published port instead only when the person says to skip setup, and record it in `exercise.md` as a deviation.",g="A static HTML page with no service to load it from is served for the browser check, since the Chrome tool refuses `file://`: run `python3 -I -u -m http.server 0 -b 127.0.0.1 -d <dir>` as a background Bash job (never without `-b 127.0.0.1`: it binds every interface by default), open the port its first line prints, and stop the job by its task ID when the check ends. Record it in `exercise.md` as the method.",k='The Chrome window does not size below 477 px, so check a narrower width in an iframe on the same origin: open the server\'s root, then with the JS tool replace the body with `<iframe src="<page>" width="375" height="812">`, screenshot it, and check `frame.contentDocument.documentElement.scrollWidth === frame.contentDocument.documentElement.clientWidth`. A page on another origin can\'t be read in the frame: ask the person for that row.',b="A library or CLI has no service to restart: build it, then exercise the built artifact exactly as its Validation text in `werkmeister-context.md` \xA7 How to validate says.",p="A one-off probe is a `node --test` file run through `.werkmeister/bin/with-temp-home --no-wait node --test <file>`, in the service's container when the host has no node_modules, as `werkmeister-context.md` \xA7 How to validate says; never host `node <script>`, a compound shell line or `docker exec \u2026 node <script>`.",v="A filter, workaround or special case the exercise needs before the change passes is a finding: write it into `exercise.md` as a `FAIL` row until the code is fixed, or until the row says why it reflects real use rather than a defect.",y=["Confirm ponytail is active (see `_shared/standards.md`; invoke the skill only if it is not), then read the standards rows above. Restate the rule you are applying beside each edit."],x=t(e=>`Before writing code, fetch the base and list \`git log --oneline HEAD..origin/<base> -- <the files \`${e}\` changes>\` (\`<base>\` is \`main\` unless the workspace's PR base differs; name those files, never the whole tree), and run \`werkmeister issue view <KEY>\` for each ticket a decided question names. If the branch has no commits of its own and the tree is clean, rebase onto the base; with uncommitted changes, never stash (the stash stack is shared) \u2014 commit them first or leave the rebase to the person. When a new commit or a ticket change bears on a decided question, stop and ask the person before writing code.`,"baseCheck"),N="If `../../.werkmeister/werkmeister-context.md` gives the repo a format command (`Format:` under its repo commands), first run it on the files you touched (never a folder), where the service's tests run (its container when its How-to-validate text says so), so formatting lands in the ticket's own commit. Run the test command exactly as `../../.werkmeister/werkmeister-context.md` states it: through `.werkmeister/bin/with-temp-home`, which gives it a fresh temporary HOME \u2014 never hand-roll `HOME=\u2026`. That run is on the host, without the container's env (`HOST`, `WERKMEISTER_SLOT`, `NODE_ENV`, `<SVC>_URL`, \u2026), and the PR gate runs the same commands in the workspace container. When a service's How-to-validate text in `werkmeister-context.md` says to run in its container (`docker exec`), follow that text instead: starting this workspace's own container with `werkmeister feature up --service <name>` is expected for it and allowed. Before `werkmeister pr gate --tests`, run the repo's whole lint chain there too (every command the test command in `werkmeister-context.md` runs ahead of the service's own tests, when it has any; one `&&` segment alone is not it) and fix what it fails: a fast route that runs one test file skips it, and the gate's lint row then fails on it. ",j="A subagent you brief to run tests or the CLI gets that wrapped command verbatim in its brief. A skipped test is not a pass: name each one with its skip reason, and run it where it can run (the workspace container) or say where it will (the gate, CI). Redirect output to a file as one group, so every command in an `&&` chain lands there. For a background job (`run_in_background`) write background: `{ <test command>; } > <log> 2>&1` and read the exit code from the job's completion notice; for a foreground call write foreground: `{ <test command>; } > <log> 2>&1; echo \"exit $?\"`. Read back only the failing slice. For a background test or gate job you wait on, check its log's last-write time: after 10 minutes with no write, stop it and rerun it once, then tell the person if it stalls again.",Q=N+"Once it passes, run `werkmeister pr gate --tests` (from the workspace, as a background job with its log, as rule 3 of `_shared/pr-rules.md` shows) and fix what it fails; record both exit codes. "+j,D=`${N}Record its exit code. ${j}`,H="Once the review's fixes are in, run `werkmeister pr gate --tests` (from the workspace, as a background job with its log, as rule 3 of `_shared/pr-rules.md` shows) and fix what it fails; record its exit code. A fix here reruns the host test step first.",B="If the exercise below changes code, rerun the review on that delta: a fresh subagent with the same brief, over the commits and changes made since the first review. Fix its **Must fix** findings, rerun `werkmeister pr gate --tests` (not one service's test command: these edits come after the gate above, and the gate retests every service the diff touches), and append the result as new rows to `output/review.md`; the gate's review row covers them.",R=t(e=>`Before running tests, read \`git diff\` in each repo you touched and tick off each edit \`${e}\` settled against it: an edit reported as applied can be missing.`,"diffCheck"),A="Before asking for approval, list the exercise rows only a person can run (a real VS Code window, a device, a browser). Ask the person for each one's result, one question per row (pass / fail / not run). Each question states the URL to open, how to reach this workspace's copy (the `X-Feature` cookie or selector for a routed hostname, which serves another workspace's copy when none is set, or the container's direct published port, `localhost:<port>`, from `werkmeister-context.md`), and the visible before \u2192 after that means PASS; a question that only lists pages to open is not asked. Write the answer into `exercise.md`: PASS or FAIL in the table, and for a row not run a `MANUAL: not run (person's reason)` line under it (the table's result cell stays PASS or FAIL). An approval that skips this keeps those rows MANUAL, and the PR file says why. "+F,P="every skipped test by name with its skip reason and where it ran instead",$="the `pr gate --tests` result for each service it tested (one line per service row)",h=t(e=>e.map(s=>`\`${s}\``).join(", "),"keys"),U="`git commit --fixup <sha>`, then `git rebase --autosquash $(git merge-base HEAD origin/main)`",O=" Then, in each worktree, `git fetch origin <base>`; if `git rev-list --count HEAD..origin/<base>` is not 0, `git rebase origin/<base>` (keeping one commit per ticket) and rerun the tests before the PR file.",E=t(e=>e.group.length?[`This workspace is a grouped PR (\`group\` in \`workspace.yml\`): one commit per ticket, for the workspace's issue and each member, ${h(e.group)}, so each can be reverted alone. Take the tickets one at a time: make that ticket's changes and tests, run the diff check below on them, then commit on the worktree's branch with a message that starts with its key (\`<KEY> <summary>\`) before starting the next. Each commit builds and passes the host tests on its own. A ticket that changes a released package carries its release entry in its own commit. When a ticket's change alters a generated snapshot (e.g. \`strategy-jit.snapshot.json\`), regenerate it in that ticket's commit, so the commit passes the snapshot test alone; a brief that says to regenerate once for the whole PR does not override this. Commit order across tickets is free; a ticket whose change depends on another's evidence (a measurement) can come last. Never reorder commits to match the spec.`]:[],"groupStep"),Z="a `| criterion | result | evidence |` table whose result cell is exactly `PASS` or `FAIL` \u2014 nothing else in the cell \u2014 with the proof in the evidence column",Y=t((e,{group:s,questionTool:n})=>`Review the diff: for each code worktree you touched, start a fresh subagent and brief it with only the worktree path and "run the \`ponytail:ponytail-review\` skill over this worktree's ${s.length?"commits in `origin/main...HEAD` (the PR's base in place of `main` when it differs), plus any uncommitted changes and untracked files":"uncommitted changes, untracked files included"}" \u2014 not how you built it, so the review is not anchored on your reasoning. Run that subagent in the foreground when nothing else is pending. When it runs in the background, check its transcript's last-write time; after 10 minutes with no write, stop it and relaunch it once, and tell the person if the relaunch stalls too. If the change adds or widens an allow rule or another pre-approved command, add to the brief: "this change pre-approves a command: list every file, env var, network address or process it can reach from its arguments, and treat each that leaves the workspace or its temp HOME as Must fix". Always add: "any finding where the change can restart or write the host daemon, the real \`~/.werkmeister\` or another workspace, whether through an allow rule, a script or a test, is Must fix". Fix every **Must fix** finding in place, and any **Should fix** finding that shows the change's own docs, comments, help text or release entry state something false (fix the code, or reword that text so it is true), ${s.length?`fold each fix into the commit of the ticket it belongs to (${U}), `:""}then ${e}. Leave the other **Should fix** and **Nice to have** findings as they are. ${C(n)} Write \`output/review.md\`: per worktree, the findings as the review grouped them, each marked \`fixed\` or \`left: <why>\`, then ${Z}, with one row per worktree (\`PASS\` means no Must fix left open). The PR gate refuses to open a PR while \`review.md\` is missing or has a row that is not \`PASS\`; a file of prose alone fails with \`has no PASS row\`.`,"reviewStep"),G=t(e=>Y("rerun the host test step above",e),"implementReview"),V="When the change adds or widens an input to a pre-approved command (an allow rule, or a wrapper an allow rule covers), the decision defaults to an allowlist of accepted values and lists what each accepted value can reach: files, env vars, network addresses, processes. A blocklist needs a stated reason.",ee="When the ticket is about gate, test or build speed, sample the container cgroup `cpu.stat` `usage_usec` every 5 s across a cold run and report the cores in use per phase before naming a critical path or any lever. Task start and end times alone do not show whether a path matters. If the run holds all its CPUs, only a CPU cut shortens it, and the decision says so.",m="A CPU or wall-time number that a decision or acceptance criterion rests on comes from paired, alternating A/B runs (A1 B1 A2 B2 A3 B3, at least 3 each) through `.werkmeister/bin/with-temp-home` with its load wait on, in a Linux container (on macOS the wrapper waits on free memory only, never on load), never from a single run or `--no-wait`; record every run's numbers and the host load beside them.",te="When the change adds or moves markdown into a repo (a copied skill, doc or reference), copy it into the worktree, run the repo's lint command on it (the `<lint> &&` head of its test command in `werkmeister-context.md`, in the service's container, where the repo's docs checks run) and record each failure in `inventory.md`; then remove the copy. `decisions.md` names the edits the text needs, or that the copy passed unchanged.",J='For each decision that renames, keeps or removes a name, a fallback or an alias, record its definition site (file and line) and the commit that introduced it (`git log -S <name>`, in the repo that defines it). When that commit marks it as a transition or legacy alias, list "remove" as an option beside rename and keep.',c=t((e,s)=>`${s} Then change \`status: proposed\` at the top of \`output/${e}\` to \`status: decided\`: that flip is the approval, and the next session starts without asking again. ${o}`,"statusGate"),d=", its first line `status: proposed`",K="Before writing a recommended answer or proposed fix, name for each acceptance criterion in `BRIEF.md` how its stated verification runs on that design (which command, which platform or container). A criterion whose verification cannot reach the design is an open question, not a decided one.",se=t(e=>e?`Ask this check through \`${e}\`: at most 4 questions per call (more than 4: batches of 4, one call after another), each standing on its own (what was checked, 2\u20133 concrete options with the exact wording or behaviour, the recommended one first; "Other" takes edits). Write each answer into the output file as its status, noted \`${r.chat}\` (a PR file: \`${r.chatPr}\`). A check left as a sentence at the end of a reply is not asked.`:`Ask this check as one numbered block at the end of your reply: each question stands on its own, options lettered with the recommended one first, then "reply with the letters, or your edits". Write each answer into the output file as its status, noted \`${r.chat}\` (a PR file: \`${r.chatPr}\`).`,"askLine"),ve="Review `output/` once against `../../BRIEF.md` and the live issue (`werkmeister issue view`). Flip every `status: proposed` to `status: decided` yourself, and record each decision \u2014 and anything you would have asked a person \u2014 under `## Recommendations for reviewer` in the PR body. A question no option settles (none meets the acceptance criteria, or the issue says to ask the person) stays `status: proposed`: ask the person (a stop point) and wait. Never flip a question you have put to the person. Then start the next stage without asking.",S=t(e=>`a \`| check | result | ${e} |\` table whose result cell is exactly \`PASS\` or \`FAIL\` \u2014 nothing else in the cell \u2014 with the captured output in the ${e} column. The rule holds for every table in \`exercise.md\`; describe a superseded run in prose, not as a \`FAIL\` row`,"exerciseFormat"),W="Run the repo's release check (the `Release check:` command in `werkmeister-context.md`) after the commit, not before: a check that compares the branch with its base in git history does not see an uncommitted release entry. When it runs in a service's container, an earlier `werkmeister pr gate --tests` stopped the containers it started: start the one it runs in with `werkmeister feature up --service <name>` first.",M="the repo's lint command (the `<lint> &&` head of the test command in `werkmeister-context.md`, when it has one, which the PR gate's lint row runs) and fix what it fails, release entry included.",X=t(e=>`Before filing 3 or more follow-up tickets, ask the person where they go${e?` (through \`${e}\`)`:""}: an existing epic (by name), a new epic (with a proposed title), a label, or none. File each with that parent or label, and record the choice in this stage's output.`,"followUpGroup"),u=["issue start","issue view"],T={name:"propose",grants:["pr push:*"],job:"acceptance walk and PR files",writes:"the code commits (one per repo, or one per ticket in a grouped PR), `output/pr-<worktree>.md` per repo",check:"approve each PR file; `werkmeister pr open` opens it",standards:"none",contract:t(e=>({oneJob:`One job: prove each acceptance criterion, ${e.group.length?"check the per-ticket commits in":"commit in"} each code worktree, and write one PR file per repo touched. Approving is the person's act; opening is \`werkmeister pr open\`.`,inputs:["Working (this run): `../../BRIEF.md` \xA7 Acceptance criteria","Working (this run): `../*/output/` \u2014 every prior stage's artifacts","Working (this run): `git status` and `git diff --stat` in each repo you touched","Reference (every run): `../../_shared/pr-rules.md` \u2014 the PR file format and the gate"],doNotLoad:"`_shared/standards.md` (no code is written here), source files, `.werkmeister/`.",process:["Walk every acceptance criterion in `BRIEF.md`. For each, write a row whose result cell is exactly PASS or FAIL (MANUAL for a criterion only the reviewer can check, e.g. it needs a real PR or the desktop app, with why in the evidence; never PASS for a check nobody ran), with the file and line in a prior `output/` that proves it in a separate evidence column. A FAIL routes back to the owning stage \u2014 do not fix it here.",e.group.length?`The commits are already made, one per ticket: keep them, never squash to one per repo. For a repo with \`ship: tag\` and a \`release_check\` in the registry, write the release entry it needs (the \`Release check:\` line in \`werkmeister-context.md\` names its command). Run ${M} Then fold everything uncommitted into its ticket's commit (${U}), each ticket's release entry into that ticket's own commit, and check that \`git log --oneline origin/main..HEAD\` in each worktree shows one commit per ticket (the workspace's issue and ${h(e.group)}), each message starting with its key. ${W}${O}`:`In each code worktree you touched (\`git -C <repo>\`), commit on its branch with a message that names the change, not the stage. For a repo with \`ship: tag\` and a \`release_check\` in the registry, add the release entry it needs (the \`Release check:\` line in \`werkmeister-context.md\` names its command) in the same commit. Before committing, run ${M} ${W}${O}`,"Before the PR file: for each follow-up a decided question in `decisions.md` promises, file it through `../../_shared/issues-report.md` and write its issue key beside that decision. The gate's follow-ups check stays as the backstop. "+X(e.questionTool),"Write `output/pr-<worktree>.md` per repo touched, in the format of `_shared/pr-rules.md`, at `status: draft`, with `repo:` taken from `git -C <worktree> remote get-url origin` (as `owner/repo`; the gate rejects any other value). Title: `<type>(<scope>): <ISSUE-ID> <summary>`. Body: summary, the test and exercise results from prior outputs (every table with a `result` column \u2014 the gate reads them all \u2014 has a result cell of exactly `PASS` and the output in its own column: a FAIL cell anywhere in the PR file stops the PR, so describe a pre-fix reproduction in prose, not as a FAIL row), the acceptance table from step 1, and `Fixes <issue>` when the tracker is GitHub."+(e.group.length?" Start the body with `Rebase and merge, not squash: one commit per ticket, each revertable alone.` and list each member under the summary.":""),"Commit and push this folder's branch \u2014 the record. Never open a PR for it."],outputs:[e.group.length?"The per-ticket commits, kept, on each worktree's branch":"One commit per code repo touched, on that worktree's branch","`output/pr-<worktree>.md` per repo"],humanCheck:`Read each \`pr-*.md\`. Set \`status: approved\` on each one to open \u2014 that flip is the approval. Then \`werkmeister pr open\`, run detached as \`_shared/pr-rules.md\` rule 3 shows, runs the gate and opens it. Merging is yours. After the release, \`werkmeister pr status\`, then ${e.group.length?`check each member reads Done \u2014 \`werkmeister issue view <KEY>\` for ${h(e.group)}; \`pr status\` moves them with the workspace's issue, so move one by hand only if it didn't \u2014 then `:""}the post-mortem (\`postmortem\` skill), then ask the person before \`werkmeister workspace close\`. Code written after a PR merged (e.g. found at release) is a follow-up: \`werkmeister pr new <worktree> --slug <slug>\`. ${o}`,selfCheck:`Review each \`pr-*.md\` once against \`../../BRIEF.md\` and the live issue. Add \`## Recommendations for reviewer\` to its body \u2014 every decision and question collected on the way \u2014 then ask the person to approve each PR file. ${se(e.questionTool)} On their yes, run \`werkmeister pr open\` detached, as \`_shared/pr-rules.md\` rule 3 shows. Stop at the PR URL. Merging is the person's.`+(e.group.length?` When the PR ships, check each member reads Done (\`werkmeister issue view <KEY>\` for ${h(e.group)}) before the post-mortem; \`pr status\` moves them with the workspace's issue, so move one by hand only if it didn't.`:"")}),"contract")},I=t(e=>e.length?" The implement stage makes those commits; plan the work and its checks, not finer commits.":" Code changes stay uncommitted until the propose stage, so plan the work and its checks, not commits.","noCommitPlan"),re=[{name:"research",grants:u,job:"inventory the code, surface decisions",writes:"`output/inventory.md`, `output/decisions.md`",check:"answer every open question in `decisions.md`",standards:"none",contract:t(e=>({oneJob:"One job: establish what the code the brief touches does today, and turn the brief's open questions into an editable decision sheet. No code is written in this stage.",inputs:["Working (this run): `../../BRIEF.md`",`Working (this run): the files in ${e.repos} that \`BRIEF.md\` names \u2014 grep for call sites, don't read whole trees`],doNotLoad:`\`_shared/standards.md\` (nothing is written here), other stages' contracts, \`.werkmeister/*.yml\`, \`${i}\`.`,process:['List what exists that the brief touches: entry points, routes or exports, data shapes, and the tests that cover them. For each module the change adds an export to, grep the tests for whole-module mocks of it (e.g. `vi.mock("<module>"`, `mock.module`) and list every hit as a fixture the change must update. For each value the change alters (a string, a default, a command), grep tests and fixtures for that exact value and list the hits; never write that no test covers it without that grep.',"Find the test command in `../../.werkmeister/werkmeister-context.md` and copy it verbatim \u2014 do not restate it from memory.","Check what is already installed that could do the job before recommending anything new. When a decision rests on how an external tool behaves (a CLI command or flag, a plugin API, an event name), check it against the installed tool, not only its docs: record `<bin> --version`, and confirm each fact with `<bin> <cmd> --help` or a real run or plugin load. `decisions.md` names the version and, beside each fact, the command that confirmed it; a fact only the docs support is marked `unverified: docs only`, and no decision rests on it. If the tool cannot be installed, say so and mark every such fact `unverified`. A recommended answer that rests on an external API, permission or platform behaviour (a token scope, a hosted API's response, a cloud permission) is checked live, read-only (a list, get, `--help` or dry run, never a write), before it goes into `decisions.md`, with the command and its result beside it. When it cannot be checked read-only, write `unverified` in the option text itself, so the question the person is asked carries the word, not only the file. A probe of tool behaviour runs in the service's container, with the repo's own layout; starting it with `werkmeister feature up --service <svc>` is allowed for that. A probe in a host scratch project is marked `host scratch` beside the fact, and re-checked in the container before a decision rests on it. "+V+" "+ee+" "+m+" "+te,"Write `output/inventory.md`: steps 1\u20133.",J,`Write \`output/decisions.md\`: every open question in \`BRIEF.md\`, each as a heading with \`status: proposed\`, your recommended answer, and the evidence from steps 1\u20133 and 5. Leave the answer blank when only a person can give it (a ticket key, a preference). ${K}`],outputs:["`output/inventory.md`","`output/decisions.md`"],humanCheck:`Open \`output/decisions.md\`. Edit each answer as needed and change its \`status: proposed\` to \`status: decided\`. The next stage must not start while any question is still \`proposed\`. When every question reads \`decided\`, that is the approval \u2014 the next session starts the next stage without asking for confirmation. ${o}`}),"contract")},{name:"spec",job:"write the spec for the change",gate:"spec.md",writes:"`output/spec.md`, any checkable artifact in the repo",check:"the spec covers every acceptance criterion",enter:"every question in `stages/01_research/output/decisions.md` reads `status: decided` \u2014 the flip *is* the approval, do not ask again",standards:"all",contract:t(e=>({oneJob:"One job: turn the settled decisions into a spec precise enough that the next stage needs no judgment calls, and prove any machine-checkable part of it.",inputs:[`Working (this run): \`${e.at("research")}/output/inventory.md\``,`Working (this run): \`${e.at("research")}/output/decisions.md\` \u2014 every entry must read \`status: decided\`; if not, stop and route back to that stage's human check`,"Reference (every run): `../../BRIEF.md` \xA7 Acceptance criteria"],doNotLoad:"source files already summarised in `inventory.md` (if it looks wrong, fix `inventory.md` and tell the person), `.werkmeister/*.yml`, other stages.",process:[`Write \`output/spec.md\`: what changes, file by file; the interfaces or schemas added; the tests that will prove it; what is explicitly out of scope. Promise an unchanged (byte-for-byte) copy of markdown only when \`inventory.md\` records the repo's lint passing on it; otherwise list the edits.${e.group.length?" This is a grouped PR: list one commit per ticket (`<KEY> \u2026`) and what each holds, but do not fix their order.":""}${I(e.group)}`,"If the change has a machine-checkable artifact (a schema, an API document, a migration), write it in the repo and validate it with a command that needs no new dependency. Record the exact command in `spec.md`.","Map each acceptance criterion in `BRIEF.md` to the step or test in `spec.md` that satisfies it. A criterion with no mapping is a defect in this stage.","Load every `_shared/standards.md` row whose Applies-when matches a file `spec.md` changes, not only the universal ones. Under `## Conflicts` in `spec.md`, write one line per place the ticket's proposed shape breaks a loaded standard (the rule, and the shape that would satisfy it), or `none`.","In `spec.md`, answer: how does an existing user turn this on? Name the setup or config path (a setup command, a config key or file) and the doc that describes it, or say none is needed. Map the answer to a criterion as in step 3; a missing answer is a defect in this stage."],outputs:[`\`output/spec.md\`${d}`,"Any artifact from step 2, in the repo"],humanCheck:c("spec.md","Read `output/spec.md` against the brief. Edit it directly \u2014 the next stage builds whatever is on disk.")}),"contract")},{name:"implement",job:"build it and prove it",gate:"review.md",writes:"code diff, `output/exercise.md`, `output/review.md`",check:"read the diff and `review.md`; tests green",standards:"all",contract:t(e=>({oneJob:"One job: make the changes `spec.md` lists, add the tests it names, and prove them against the running service.",inputs:[`Working (this run): \`${e.at("spec")}/output/spec.md\` and the files it names`,`Working (this run): \`${e.at("research")}/output/decisions.md\``,"Reference (every run): `../../.werkmeister/werkmeister-context.md` \u2014 container names, published ports, test command"],doNotLoad:`\`BRIEF.md\` (\`decisions.md\` and \`spec.md\` carry the settled scope), \`inventory.md\`, \`.werkmeister/*.yml\`, \`${i}\`, other stages.`,process:[...y,x("spec.md"),...E(e),"Make the changes `spec.md` lists, and only those. No new runtime dependency unless `decisions.md` justified one in a line.","Add the tests `spec.md` names. Match the style of the nearest existing test; no new test framework.",R("spec.md"),D,G(e),H,B,`Reload the running code: ${e.restart}. ${w} ${f} ${g} ${k} Then exercise the change as the How-to-validate section of \`werkmeister-context.md\` describes for each service touched, and capture the output. ${b} ${p} ${v} ${m}`,`Write \`output/exercise.md\`: \`git diff --stat\` for each repo you touched, the host and \`pr gate --tests\` exit codes and summary lines, ${$}, ${P}, any deviation from \`spec.md\` with its reason, and the exercise checks as ${S("evidence")}.`,A],outputs:[e.group.length?"Code changes, one commit per ticket (`<KEY> \u2026`), on the worktree's branch \u2014 the next stage keeps them":"Code changes, uncommitted \u2014 the next stage commits after the person reads the diff","`output/exercise.md`",`\`output/review.md\`: a \`| criterion | result | evidence |\` table, result exactly \`PASS\` or \`FAIL\`${d}`],humanCheck:c("review.md",e.group.length?"Read each ticket's commit (`git log -p origin/main..HEAD` in each worktree) and `review.md`. Run the tests yourself. Edit the code in place if something is off and fold it into that ticket's commit \u2014 the next stage keeps the commits as they are.":"Read the diff and `review.md`. Run the tests yourself. Edit the code in place if something is off \u2014 the next stage commits what is on disk.")}),"contract")},T],q=[{name:"reproduce",grants:u,job:"reproduce and locate the root cause",writes:"`output/repro.md`",check:"agree the root cause",standards:["testing","engineering","comments"],contract:t(e=>({oneJob:"One job: make the failure happen on demand and name its root cause. No fix is written in this stage.",inputs:["Working (this run): `../../BRIEF.md`",`Working (this run): the files in ${e.repos} on the failing path \u2014 follow the call chain, don't read whole trees`,"Reference (every run): `../../.werkmeister/werkmeister-context.md` \u2014 container names, published ports, logs, test command"],doNotLoad:"other stages' contracts, `.werkmeister/*.yml`.",process:[`Reproduce the failure against the running service or with a test. Record the exact command and its output. Judge each run by its exit code, or by a check you have shown fails on a known-bad run \u2014 never by grepping the output for a line that may not be printed. ${p}`,"Write the smallest failing test that captures it, in the style of the nearest existing test. Do not commit it yet.","Trace to the root cause: the first place the code does something other than intended. A symptom site is not a root cause.","List every other caller of the function at the root cause and what each does with the result (an early return, a printed value, a stored state), so the fix's return shape is checked against every caller before the fix stage \u2014 a fix there reaches them too. When the fix belongs in shared code, list its call sites through every helper or entry point that reaches that code, not one argument shape, and record the search commands (greps) you used in `repro.md`.",`When the proposed fix branches on a predicate, list each condition that makes it true and give each one a test. ${V}`,J,"When the root cause is a permission rule (allow, deny, ask), step 4 lists every source of a matching rule: each builder, each rule derived from a registered command (its `&&` segments included), rules recorded in existing workspaces and how a refresh or migrate removes them, and the list a headless wake passes (`--allowedTools` / `--disallowedTools`). The failing test probes each source. Also `git grep -F` the exact old rule text across the whole repo, tests and `apps/` included, and list each hit as a site the fix must update (SW-820).",`Write \`output/repro.md\`: steps 1\u20137, and a proposed fix in one paragraph under a \`status: proposed\` line.${I(e.group)} Check the proposed fix against the standards rows above and name any rule that already prescribes it. ${K}`],outputs:["`output/repro.md`","One failing test, uncommitted"],humanCheck:`Read \`output/repro.md\`. Correct the root cause or the proposed fix if needed, then change \`status: proposed\` to \`status: decided\`. That is the approval \u2014 the next session starts the fix without asking again. ${o}`}),"contract")},{name:"fix",job:"fix it at the root cause",gate:"fix.md",writes:"code diff, `output/fix.md`",check:"read the diff; the failing test now passes",enter:"`stages/01_reproduce/output/repro.md` reads `status: decided` \u2014 the flip *is* the approval, do not ask again",standards:"all",contract:t(e=>({oneJob:"One job: make the failing test pass by changing the code at the root cause, and nothing else.",inputs:[`Working (this run): \`${e.at("reproduce")}/output/repro.md\` \u2014 must read \`status: decided\`; if not, stop and route back`,"Working (this run): the failing test and the files at the root cause","Reference (every run): `../../.werkmeister/werkmeister-context.md` \u2014 test command"],doNotLoad:"`BRIEF.md` (`repro.md` carries the settled scope), `.werkmeister/*.yml`, other stages.",process:[...y,x("repro.md"),...E(e),"Apply the fix `repro.md` settled, at the root cause. Every caller `repro.md` lists gets the fix through the shared function \u2014 do not patch callers one by one.",R("repro.md"),Q,`Write \`output/fix.md\`: \`git diff --stat\` per repo, the failing test's name, the test exit code and summary line, ${$}, and ${P}.`],outputs:[e.group.length?"Code changes plus the test, one commit per ticket":"Code changes plus the test, uncommitted",`\`output/fix.md\`${d}`],humanCheck:c("fix.md",`${e.group.length?"Read each ticket's commit (`git log -p origin/main..HEAD`)":"Read the diff"}. Confirm the fix sits where \`repro.md\` put the root cause. Edit in place if not.`)}),"contract")},{name:"exercise",job:"prove it against the running service or the built CLI",gate:"review.md",writes:"`output/exercise.md`, `output/review.md`",check:"the original reproduction no longer fails",standards:"all",contract:t(e=>({oneJob:"One job: show the original failure is gone in the running service or the built binary, not just in the test. Then review the diff and fix what must be fixed.",inputs:[`Working (this run): \`${e.at("reproduce")}/output/repro.md\` \u2014 the reproduction steps`,`Working (this run): \`${e.at("fix")}/output/fix.md\``,"Reference (every run): `../../.werkmeister/werkmeister-context.md` \u2014 container names, published ports, test command"],doNotLoad:"`BRIEF.md` (`repro.md` carries the settled scope), `.werkmeister/*.yml`.",process:[`Reload the running code: ${e.restart}. ${w} ${f} ${g} ${k} ${b} ${p}`,"Rerun the reproduction steps from `repro.md` exactly. Capture the output.",`Exercise one neighbouring path through each caller \`repro.md\` listed. Capture the output. ${v} ${m}`,`Write \`output/exercise.md\`: steps 2\u20133 as ${S("detail")}.`,A,Y("rerun `werkmeister pr gate --tests` (from the workspace, as a background job with its log, as rule 3 of `_shared/pr-rules.md` shows), not one service's test command: it retests every service the diff touches, and these edits come after the fix stage's gate. Then rerun steps 2\u20133 and update `exercise.md`",e)],outputs:["`output/exercise.md`",`\`output/review.md\`: a \`| criterion | result | evidence |\` table, result exactly \`PASS\` or \`FAIL\`${d}`,e.group.length?"Code changes from Must fix findings, folded into their tickets' commits":"Code changes from Must fix findings, uncommitted"],humanCheck:c("review.md","Read `exercise.md` and `review.md`. A FAIL sends the run back to the fix stage.")}),"contract")},T],oe=[{name:"scope",grants:u,job:"fix the boundary and the invariants",writes:"`output/scope.md`",check:"agree what must not change",standards:"none",contract:t(e=>({oneJob:"One job: pin down what the refactor may touch and what behaviour must not change. No code is written in this stage.",inputs:["Working (this run): `../../BRIEF.md`",`Working (this run): the files in ${e.repos} that \`BRIEF.md\` names, and their callers`],doNotLoad:"`_shared/standards.md` (nothing is written here), other stages' contracts, `.werkmeister/*.yml`.",process:["List the files in scope and every caller outside it.","State the invariants: observable behaviour that must be identical after the refactor.","Name the existing tests that pin each invariant, and the gaps no test covers.",`Write \`output/scope.md\`: steps 1\u20133, the sequence of small steps you propose${e.group.length?` under one heading per ticket key (the workspace's issue, then ${h(e.group)})`:""}, and a \`status: proposed\` line.${I(e.group)}`],outputs:["`output/scope.md`"],humanCheck:`Read \`output/scope.md\`. Correct the scope or invariants, then change \`status: proposed\` to \`status: decided\`. That is the approval \u2014 the next session starts without asking again. ${o}`}),"contract")},{name:"implement",job:"refactor in green steps",gate:"review.md",writes:"code diff, `output/exercise.md`, `output/review.md`",check:"read the diff and `review.md`; tests green at every step",enter:"`stages/01_scope/output/scope.md` reads `status: decided` \u2014 the flip *is* the approval, do not ask again",standards:"all",contract:t(e=>({oneJob:"One job: carry out the steps `scope.md` settled, keeping every invariant true after each one.",inputs:[`Working (this run): \`${e.at("scope")}/output/scope.md\` \u2014 must read \`status: decided\``,"Working (this run): the files in scope","Reference (every run): `../../.werkmeister/werkmeister-context.md` \u2014 test command"],doNotLoad:"`BRIEF.md` (`scope.md` carries the settled scope), `.werkmeister/*.yml`, other stages.",process:[...y,x("scope.md"),...E(e),"First add a test for each invariant gap `scope.md` named. They must pass before any code moves.",`${e.group.length?"For each ticket, take its `scope.md` steps in order, then commit it before the next ticket; do not commit after every step. After each step":"Take the steps in order. After each one"}: ${R("scope.md")} ${D}`,G(e),H,B,`After the last step, reload and exercise the service: ${e.restart}. ${w} ${f} ${g} ${k} ${b} ${p} ${v} ${m}`,`Write \`output/exercise.md\`: \`git diff --stat\` per repo, the test result after each step, the \`pr gate --tests\` exit code, ${$}, ${P}, and the final exercise checks as ${S("evidence")}.`,A],outputs:[e.group.length?"Code changes, one commit per ticket (`<KEY> \u2026`)":"Code changes, uncommitted","`output/exercise.md`",`\`output/review.md\`: a \`| criterion | result | evidence |\` table, result exactly \`PASS\` or \`FAIL\`${d}`],humanCheck:c("review.md",`Read the diff against \`scope.md\`. Anything outside scope goes back.${e.group.length?" Read it per commit: `git log -p origin/main..HEAD`.":""}`)}),"contract")},T],ne=[{name:"questions",grants:u,job:"frame what the spike must answer",writes:"`output/questions.md`",check:"agree the questions and what settles them",standards:"none",contract:t(()=>({oneJob:"One job: turn the brief into questions, each with the evidence that would settle it. No code is written in this stage.",inputs:["Working (this run): `../../BRIEF.md`"],doNotLoad:"source trees, `_shared/standards.md`, `.werkmeister/*.yml`.",process:["List the questions the brief asks or implies, most decision-relevant first.","For each: how it will be answered (read code, measure, prototype) and what result settles it.","Write `output/questions.md`: steps 1\u20132 and a `status: proposed` line."],outputs:["`output/questions.md`"],humanCheck:`Edit the questions, then change \`status: proposed\` to \`status: decided\`. That is the approval \u2014 the next session starts without asking again. ${o}`}),"contract")},{name:"findings",job:"answer them with evidence",writes:"`output/findings.md`",check:"decide the next piece of work",enter:"`stages/01_questions/output/questions.md` reads `status: decided` \u2014 the flip *is* the approval, do not ask again",standards:"none",contract:t(e=>({oneJob:"One job: answer each settled question with evidence, and recommend what to build next.",inputs:[`Working (this run): \`${e.at("questions")}/output/questions.md\` \u2014 must read \`status: decided\``,`Working (this run): whatever each question's method names, in ${e.repos}`,"Reference (every run): `../../.werkmeister/werkmeister-context.md` \u2014 ports, containers","Reference (when the brief asks for a repo deliverable): `../../_shared/pr-rules.md` \u2014 the PR file format and the gate"],doNotLoad:"`_shared/standards.md` (prototype code is throwaway), `.werkmeister/*.yml`.",process:["Answer each question by its method. Prototype code lives in `output/` or on a scratch branch, never on the workspace branch.","Write `output/findings.md`: per question, the answer, the evidence (commands and output), and confidence.",`End \`findings.md\` with a recommendation: the next work item and its work type. ${X(e.questionTool)}`,"If the brief asks for a deliverable in a code repo (e.g. a doc opened as a PR): commit it on that worktree's branch, and write `output/pr-<worktree>.md` in the format of `_shared/pr-rules.md` at `status: draft`, with `repo:` taken from `git -C <worktree> remote get-url origin` (as `owner/repo`; the gate rejects any other value), an acceptance table and `skip_exercise: <reason>` when there is nothing to exercise."],outputs:["`output/findings.md`","`output/pr-<worktree>.md` per repo \u2014 only when the brief asks for a repo deliverable"],humanCheck:"Read `findings.md`. The recommendation becomes the brief of the next workspace, or the spike ends here. If there is a `pr-*.md`, set `status: approved`; `werkmeister pr open` runs the gate and opens it, and close-out waits for it to ship. Otherwise, when the recommendation is recorded where it is needed, the post-mortem (`postmortem` skill), then `werkmeister workspace close`."}),"contract")}],l={feature:re,bugfix:q,incident:q,refactor:oe,spike:ne};function ae(e){let s=e.trim().toLowerCase();return Object.hasOwn(l,s)?l[s]:l.feature}t(ae,"templateFor");function z(e){return e.map((s,n)=>`${String(n+1).padStart(2,"0")}_${s.name}`)}t(z,"stageDirs");function ie(e){let s=e.findIndex(n=>n.name==="propose");return s<0?null:z(e)[s]}t(ie,"proposeDir");function ye(e){return ie(e)??z(e)[e.length-1]}t(ye,"prDir");function xe(e){return[...new Set(ae(e).flatMap(s=>s.grants??[]))]}t(xe,"stageGrants");export{C as a,F as b,o as c,ue as d,se as e,ve as f,l as g,ae as h,z as i,ie as j,ye as k,xe as l};
84
- //# sourceMappingURL=chunk-5RJFHLF4.js.map
85
+ `}t(ue,"buildPrRulesMd");var w="If the container is not running, run `werkmeister feature up` once first; `docker restart` only reloads one that is already running. Never run `werkmeister feature restart` or `werkmeister workspace init` to reload \u2014 they are slower, and init rewrites the stage contracts.",f="If `werkmeister feature up` warns that a routed hostname does not resolve to 127.0.0.1 (its last warning line points to `werkmeister machine setup`), stop before any browser check and ask the person to run `werkmeister machine setup` (it needs sudo for the hosts entries and certificate trust). Never click through or bypass a certificate warning. Use the container's published port instead only when the person says to skip setup, and record it in `exercise.md` as a deviation.",g="A static HTML page with no service to load it from is served for the browser check, since the Chrome tool refuses `file://`: run `python3 -I -u -m http.server 0 -b 127.0.0.1 -d <dir>` as a background Bash job (never without `-b 127.0.0.1`: it binds every interface by default), open the port its first line prints, and stop the job by its task ID when the check ends. Record it in `exercise.md` as the method.",k='The Chrome window does not size below 477 px, so check a narrower width in an iframe on the same origin: open the server\'s root, then with the JS tool replace the body with `<iframe src="<page>" width="375" height="812">`, screenshot it, and check `frame.contentDocument.documentElement.scrollWidth === frame.contentDocument.documentElement.clientWidth`. A page on another origin can\'t be read in the frame: ask the person for that row.',b="A library or CLI has no service to restart: build it, then exercise the built artifact exactly as its Validation text in `werkmeister-context.md` \xA7 How to validate says.",p="A one-off probe is a `node --test` file run through `.werkmeister/bin/with-temp-home --no-wait node --test <file>`, in the service's container when the host has no node_modules, as `werkmeister-context.md` \xA7 How to validate says; never host `node <script>`, a compound shell line or `docker exec \u2026 node <script>`.",y="A filter, workaround or special case the exercise needs before the change passes is a finding: write it into `exercise.md` as a `FAIL` row until the code is fixed, or until the row says why it reflects real use rather than a defect.",v=["Confirm ponytail is active (see `_shared/standards.md`; invoke the skill only if it is not), then read the standards rows above. Restate the rule you are applying beside each edit."],x=t(e=>`Before writing code, fetch the base and list \`git log --oneline HEAD..origin/<base> -- <the files \`${e}\` changes>\` (\`<base>\` is \`main\` unless the workspace's PR base differs; name those files, never the whole tree), and run \`werkmeister issue view <KEY>\` for each ticket a decided question names. If the branch has no commits of its own and the tree is clean, rebase onto the base; with uncommitted changes, never stash (the stash stack is shared) \u2014 commit them first or leave the rebase to the person. When a new commit or a ticket change bears on a decided question, stop and ask the person before writing code.`,"baseCheck"),N="If `../../.werkmeister/werkmeister-context.md` gives the repo a format command (`Format:` under its repo commands), first run it on the files you touched (never a folder), where the service's tests run (its container when its How-to-validate text says so), so formatting lands in the ticket's own commit. Run the test command exactly as `../../.werkmeister/werkmeister-context.md` states it: through `.werkmeister/bin/with-temp-home`, which gives it a fresh temporary HOME \u2014 never hand-roll `HOME=\u2026`. That run is on the host, without the container's env (`HOST`, `WERKMEISTER_SLOT`, `NODE_ENV`, `<SVC>_URL`, \u2026), and the PR gate runs the same commands in the workspace container. When a service's How-to-validate text in `werkmeister-context.md` says to run in its container (`docker exec`), follow that text instead: starting this workspace's own container with `werkmeister feature up --service <name>` is expected for it and allowed. Before `werkmeister pr gate --tests`, run the repo's whole lint chain there too (every command the test command in `werkmeister-context.md` runs ahead of the service's own tests, when it has any; one `&&` segment alone is not it) and fix what it fails: a fast route that runs one test file skips it, and the gate's lint row then fails on it. ",j="A subagent you brief to run tests or the CLI gets that wrapped command verbatim in its brief. A skipped test is not a pass: name each one with its skip reason, and run it where it can run (the workspace container) or say where it will (the gate, CI). Redirect output to a file as one group, so every command in an `&&` chain lands there. For a background job (`run_in_background`) write background: `{ <test command>; } > <log> 2>&1` and read the exit code from the job's completion notice; for a foreground call write foreground: `{ <test command>; } > <log> 2>&1; echo \"exit $?\"`. Read back only the failing slice. For a background test or gate job you wait on, check its log's last-write time: after 10 minutes with no write, stop it and rerun it once, then tell the person if it stalls again.",Q=N+"Once it passes, run `werkmeister pr gate --tests` (from the workspace, as a background job with its log, as rule 3 of `_shared/pr-rules.md` shows) and fix what it fails; record both exit codes. "+j,D=`${N}Record its exit code. ${j}`,H="Once the review's fixes are in, run `werkmeister pr gate --tests` (from the workspace, as a background job with its log, as rule 3 of `_shared/pr-rules.md` shows) and fix what it fails; record its exit code. A fix here reruns the host test step first.",B="If the exercise below changes code, rerun the review on that delta: a fresh subagent with the same brief, over the commits and changes made since the first review. Fix its **Must fix** findings, rerun `werkmeister pr gate --tests` (not one service's test command: these edits come after the gate above, and the gate retests every service the diff touches), and append the result as new rows to `output/review.md`; the gate's review row covers them.",R=t(e=>`Before running tests, read \`git diff\` in each repo you touched and tick off each edit \`${e}\` settled against it: an edit reported as applied can be missing.`,"diffCheck"),A="Before asking for approval, list the exercise rows only a person can run (a real VS Code window, a device, a browser). Ask the person for each one's result, one question per row (pass / fail / not run). Each question states the URL to open, how to reach this workspace's copy (the `X-Feature` cookie or selector for a routed hostname, which serves another workspace's copy when none is set, or the container's direct published port, `localhost:<port>`, from `werkmeister-context.md`), and the visible before \u2192 after that means PASS; a question that only lists pages to open is not asked. Write the answer into `exercise.md`: PASS or FAIL in the table, and for a row not run a `MANUAL: not run (person's reason)` line under it (the table's result cell stays PASS or FAIL). An approval that skips this keeps those rows MANUAL, and the PR file says why. "+F,P="every skipped test by name with its skip reason and where it ran instead",$="the `pr gate --tests` result for each service it tested (one line per service row)",h=t(e=>e.map(s=>`\`${s}\``).join(", "),"keys"),U="`git commit --fixup <sha>`, then `git rebase --autosquash $(git merge-base HEAD origin/main)`",O=" Then, in each worktree, `git fetch origin <base>`; if `git rev-list --count HEAD..origin/<base>` is not 0, `git rebase origin/<base>` (keeping one commit per ticket) and rerun the tests before the PR file.",E=t(e=>e.group.length?[`This workspace is a grouped PR (\`group\` in \`workspace.yml\`): one commit per ticket, for the workspace's issue and each member, ${h(e.group)}, so each can be reverted alone. Take the tickets one at a time: make that ticket's changes and tests, run the diff check below on them, then commit on the worktree's branch with a message that starts with its key (\`<KEY> <summary>\`) before starting the next. Each commit builds and passes the host tests on its own. A ticket that changes a released package carries its release entry in its own commit. When a ticket's change alters a generated snapshot (e.g. \`strategy-jit.snapshot.json\`), regenerate it in that ticket's commit, so the commit passes the snapshot test alone; a brief that says to regenerate once for the whole PR does not override this. Commit order across tickets is free; a ticket whose change depends on another's evidence (a measurement) can come last. Never reorder commits to match the spec.`]:[],"groupStep"),Z="a `| criterion | result | evidence |` table whose result cell is exactly `PASS` or `FAIL` \u2014 nothing else in the cell \u2014 with the proof in the evidence column",Y=t((e,{group:s,questionTool:a})=>`Review the diff: for each code worktree you touched, start a fresh subagent and brief it with only the worktree path and "run the \`ponytail:ponytail-review\` skill over this worktree's ${s.length?"commits in `origin/main...HEAD` (the PR's base in place of `main` when it differs), plus any uncommitted changes and untracked files":"uncommitted changes, untracked files included"}" \u2014 not how you built it, so the review is not anchored on your reasoning. Run that subagent in the foreground when nothing else is pending. When it runs in the background, check its transcript's last-write time; after 10 minutes with no write, stop it and relaunch it once, and tell the person if the relaunch stalls too. If the change adds or widens an allow rule or another pre-approved command, add to the brief: "this change pre-approves a command: list every file, env var, network address or process it can reach from its arguments, and treat each that leaves the workspace or its temp HOME as Must fix". Always add: "any finding where the change can restart or write the host daemon, the real \`~/.werkmeister\` or another workspace, whether through an allow rule, a script or a test, is Must fix". Fix every **Must fix** finding in place, and any **Should fix** finding that shows the change's own docs, comments, help text or release entry state something false (fix the code, or reword that text so it is true), ${s.length?`fold each fix into the commit of the ticket it belongs to (${U}), `:""}then ${e}. Leave the other **Should fix** and **Nice to have** findings as they are. ${C(a)} Write \`output/review.md\`: per worktree, the findings as the review grouped them, each marked \`fixed\` or \`left: <why>\`, then ${Z}, with one row per worktree (\`PASS\` means no Must fix left open). The PR gate refuses to open a PR while \`review.md\` is missing or has a row that is not \`PASS\`; a file of prose alone fails with \`has no PASS row\`.`,"reviewStep"),G=t(e=>Y("rerun the host test step above",e),"implementReview"),V="When the change adds or widens an input to a pre-approved command (an allow rule, or a wrapper an allow rule covers), the decision defaults to an allowlist of accepted values and lists what each accepted value can reach: files, env vars, network addresses, processes. A blocklist needs a stated reason.",ee="When the ticket is about gate, test or build speed, sample the container cgroup `cpu.stat` `usage_usec` every 5 s across a cold run and report the cores in use per phase before naming a critical path or any lever. Task start and end times alone do not show whether a path matters. If the run holds all its CPUs, only a CPU cut shortens it, and the decision says so.",m="A CPU or wall-time number that a decision or acceptance criterion rests on comes from paired, alternating A/B runs (A1 B1 A2 B2 A3 B3, at least 3 each) through `.werkmeister/bin/with-temp-home` with its load wait on, in a Linux container (on macOS the wrapper waits on free memory only, never on load), never from a single run or `--no-wait`; record every run's numbers and the host load beside them.",te="When the change adds or moves markdown into a repo (a copied skill, doc or reference), copy it into the worktree, run the repo's lint command on it (the `<lint> &&` head of its test command in `werkmeister-context.md`, in the service's container, where the repo's docs checks run) and record each failure in `inventory.md`; then remove the copy. `decisions.md` names the edits the text needs, or that the copy passed unchanged.",J='For each decision that renames, keeps or removes a name, a fallback or an alias, record its definition site (file and line) and the commit that introduced it (`git log -S <name>`, in the repo that defines it). When that commit marks it as a transition or legacy alias, list "remove" as an option beside rename and keep.',c=t((e,s)=>`${s} Then change \`status: proposed\` at the top of \`output/${e}\` to \`status: decided\`: that flip is the approval, and the next session starts without asking again. ${o}`,"statusGate"),d=", its first line `status: proposed`",K="Before writing a recommended answer or proposed fix, name for each acceptance criterion in `BRIEF.md` how its stated verification runs on that design (which command, which platform or container). A criterion whose verification cannot reach the design is an open question, not a decided one.",se=t(e=>e?`Ask this check through \`${e}\`: at most 4 questions per call (more than 4: batches of 4, one call after another), each standing on its own (what was checked, 2\u20133 concrete options with the exact wording or behaviour, the recommended one first; "Other" takes edits). Write each answer into the output file as its status, noted \`${r.chat}\` (a PR file: \`${r.chatPr}\`). A check left as a sentence at the end of a reply is not asked.`:`Ask this check as one numbered block at the end of your reply: each question stands on its own, options lettered with the recommended one first, then "reply with the letters, or your edits". Write each answer into the output file as its status, noted \`${r.chat}\` (a PR file: \`${r.chatPr}\`).`,"askLine"),ye="Review `output/` once against `../../BRIEF.md` and the live issue (`werkmeister issue view`). Flip every `status: proposed` to `status: decided` yourself, and record each decision \u2014 and anything you would have asked a person \u2014 under `## Recommendations for reviewer` in the PR body. A question no option settles (none meets the acceptance criteria, or the issue says to ask the person) stays `status: proposed`: ask the person (a stop point) and wait. Never flip a question you have put to the person. Then start the next stage without asking.",S=t(e=>`a \`| check | result | ${e} |\` table whose result cell is exactly \`PASS\` or \`FAIL\` \u2014 nothing else in the cell \u2014 with the captured output in the ${e} column. The rule holds for every table in \`exercise.md\`; describe a superseded run in prose, not as a \`FAIL\` row`,"exerciseFormat"),W="Run the repo's release check (the `Release check:` command in `werkmeister-context.md`) after the commit, not before: a check that compares the branch with its base in git history does not see an uncommitted release entry. When it runs in a service's container, an earlier `werkmeister pr gate --tests` stopped the containers it started: start the one it runs in with `werkmeister feature up --service <name>` first.",M="the repo's lint command (the `<lint> &&` head of the test command in `werkmeister-context.md`, when it has one, which the PR gate's lint row runs) and fix what it fails, release entry included.",X=t(e=>`Before filing 3 or more follow-up tickets, ask the person where they go${e?` (through \`${e}\`)`:""}: an existing epic (by name), a new epic (with a proposed title), a label, or none. File each with that parent or label, and record the choice in this stage's output.`,"followUpGroup"),u=["issue start","issue view"],T={name:"propose",grants:["pr push:*"],job:"acceptance walk and PR files",writes:"the code commits (one per repo, or one per ticket in a grouped PR), `output/pr-<worktree>.md` per repo",check:"approve each PR file; `werkmeister pr open` opens it",standards:"none",contract:t(e=>({oneJob:`One job: prove each acceptance criterion, ${e.group.length?"check the per-ticket commits in":"commit in"} each code worktree, and write one PR file per repo touched. Approving is the person's act; opening is \`werkmeister pr open\`.`,inputs:["Working (this run): `../../BRIEF.md` \xA7 Acceptance criteria","Working (this run): `../*/output/` \u2014 every prior stage's artifacts","Working (this run): `git status` and `git diff --stat` in each repo you touched","Reference (every run): `../../_shared/pr-rules.md` \u2014 the PR file format and the gate"],doNotLoad:"`_shared/standards.md` (no code is written here), source files, `.werkmeister/`.",process:["Walk every acceptance criterion in `BRIEF.md`. For each, write a row whose result cell is exactly PASS or FAIL (MANUAL for a criterion only the reviewer can check, e.g. it needs a real PR or the desktop app, with why in the evidence; never PASS for a check nobody ran), with the file and line in a prior `output/` that proves it in a separate evidence column. A FAIL routes back to the owning stage \u2014 do not fix it here.",e.group.length?`The commits are already made, one per ticket: keep them, never squash to one per repo. For a repo with \`ship: tag\` and a \`release_check\` in the registry, write the release entry it needs (the \`Release check:\` line in \`werkmeister-context.md\` names its command). Run ${M} Then fold everything uncommitted into its ticket's commit (${U}), each ticket's release entry into that ticket's own commit, and check that \`git log --oneline origin/main..HEAD\` in each worktree shows one commit per ticket (the workspace's issue and ${h(e.group)}), each message starting with its key. ${W}${O}`:`In each code worktree you touched (\`git -C <repo>\`), commit on its branch with a message that names the change, not the stage. For a repo with \`ship: tag\` and a \`release_check\` in the registry, add the release entry it needs (the \`Release check:\` line in \`werkmeister-context.md\` names its command) in the same commit. Before committing, run ${M} ${W}${O}`,"Before the PR file: for each follow-up a decided question in `decisions.md` promises, file it through `../../_shared/issues-report.md` and write its issue key beside that decision. The gate's follow-ups check stays as the backstop. "+X(e.questionTool),"Write `output/pr-<worktree>.md` per repo touched, in the format of `_shared/pr-rules.md`, at `status: draft`, with `repo:` taken from `git -C <worktree> remote get-url origin` (as `owner/repo`; the gate rejects any other value). Title: `<type>(<scope>): <ISSUE-ID> <summary>`. Body: summary, the test and exercise results from prior outputs (every table with a `result` column \u2014 the gate reads them all \u2014 has a result cell of exactly `PASS` and the output in its own column: a FAIL cell anywhere in the PR file stops the PR, so describe a pre-fix reproduction in prose, not as a FAIL row), the acceptance table from step 1, and `Fixes <issue>` when the tracker is GitHub."+(e.group.length?" Start the body with `Rebase and merge, not squash: one commit per ticket, each revertable alone.` and list each member under the summary.":""),"Commit and push this folder's branch \u2014 the record. Never open a PR for it."],outputs:[e.group.length?"The per-ticket commits, kept, on each worktree's branch":"One commit per code repo touched, on that worktree's branch","`output/pr-<worktree>.md` per repo"],humanCheck:`Read each \`pr-*.md\`. Set \`status: approved\` on each one to open \u2014 that flip is the approval. Then \`werkmeister pr open\`, run detached as \`_shared/pr-rules.md\` rule 3 shows, runs the gate and opens it. Merging is yours. After the release, \`werkmeister pr status\`, then ${e.group.length?`check each member reads Done \u2014 \`werkmeister issue view <KEY>\` for ${h(e.group)}; \`pr status\` moves them with the workspace's issue, so move one by hand only if it didn't \u2014 then `:""}the post-mortem (\`postmortem\` skill), then ask the person before \`werkmeister workspace close\`. Code written after a PR merged (e.g. found at release) is a follow-up: \`werkmeister pr new <worktree> --slug <slug>\`. ${o}`,selfCheck:`Review each \`pr-*.md\` once against \`../../BRIEF.md\` and the live issue. Add \`## Recommendations for reviewer\` to its body \u2014 every decision and question collected on the way \u2014 then ask the person to approve each PR file. ${se(e.questionTool)} On their yes, run \`werkmeister pr open\` detached, as \`_shared/pr-rules.md\` rule 3 shows. Stop at the PR URL. Merging is the person's.`+(e.group.length?` When the PR ships, check each member reads Done (\`werkmeister issue view <KEY>\` for ${h(e.group)}) before the post-mortem; \`pr status\` moves them with the workspace's issue, so move one by hand only if it didn't.`:"")}),"contract")},I=t(e=>e.length?" The implement stage makes those commits; plan the work and its checks, not finer commits.":" Code changes stay uncommitted until the propose stage, so plan the work and its checks, not commits.","noCommitPlan"),re=[{name:"research",grants:u,job:"inventory the code, surface decisions",writes:"`output/inventory.md`, `output/decisions.md`",check:"answer every open question in `decisions.md`",standards:"none",contract:t(e=>({oneJob:"One job: establish what the code the brief touches does today, and turn the brief's open questions into an editable decision sheet. No code is written in this stage.",inputs:["Working (this run): `../../BRIEF.md`",`Working (this run): the files in ${e.repos} that \`BRIEF.md\` names \u2014 grep for call sites, don't read whole trees`],doNotLoad:`\`_shared/standards.md\` (nothing is written here), other stages' contracts, \`.werkmeister/*.yml\`, \`${i}\`.`,process:['List what exists that the brief touches: entry points, routes or exports, data shapes, and the tests that cover them. For each module the change adds an export to, grep the tests for whole-module mocks of it (e.g. `vi.mock("<module>"`, `mock.module`) and list every hit as a fixture the change must update. For each value the change alters (a string, a default, a command), grep tests and fixtures for that exact value and list the hits; never write that no test covers it without that grep.',"Find the test command in `../../.werkmeister/werkmeister-context.md` and copy it verbatim \u2014 do not restate it from memory.","Check what is already installed that could do the job before recommending anything new. When a decision rests on how an external tool behaves (a CLI command or flag, a plugin API, an event name), check it against the installed tool, not only its docs: record `<bin> --version`, and confirm each fact with `<bin> <cmd> --help` or a real run or plugin load. `decisions.md` names the version and, beside each fact, the command that confirmed it; a fact only the docs support is marked `unverified: docs only`, and no decision rests on it. If the tool cannot be installed, say so and mark every such fact `unverified`. A recommended answer that rests on an external API, permission or platform behaviour (a token scope, a hosted API's response, a cloud permission) is checked live, read-only (a list, get, `--help` or dry run, never a write), before it goes into `decisions.md`, with the command and its result beside it. When it cannot be checked read-only, write `unverified` in the option text itself, so the question the person is asked carries the word, not only the file. A probe of tool behaviour runs in the service's container, with the repo's own layout; starting it with `werkmeister feature up --service <svc>` is allowed for that. A probe in a host scratch project is marked `host scratch` beside the fact, and re-checked in the container before a decision rests on it. "+V+" "+ee+" "+m+" "+te,"Write `output/inventory.md`: steps 1\u20133.",J,`Write \`output/decisions.md\`: every open question in \`BRIEF.md\`, each as a heading with \`status: proposed\`, your recommended answer, and the evidence from steps 1\u20133 and 5. Leave the answer blank when only a person can give it (a ticket key, a preference). ${K}`],outputs:["`output/inventory.md`","`output/decisions.md`"],humanCheck:`Open \`output/decisions.md\`. Edit each answer as needed and change its \`status: proposed\` to \`status: decided\`. The next stage must not start while any question is still \`proposed\`. When every question reads \`decided\`, that is the approval \u2014 the next session starts the next stage without asking for confirmation. ${o}`}),"contract")},{name:"spec",job:"write the spec for the change",gate:"spec.md",writes:"`output/spec.md`, any checkable artifact in the repo",check:"the spec covers every acceptance criterion",enter:"every question in `stages/01_research/output/decisions.md` reads `status: decided` \u2014 the flip *is* the approval, do not ask again",standards:"all",contract:t(e=>({oneJob:"One job: turn the settled decisions into a spec precise enough that the next stage needs no judgment calls, and prove any machine-checkable part of it.",inputs:[`Working (this run): \`${e.at("research")}/output/inventory.md\``,`Working (this run): \`${e.at("research")}/output/decisions.md\` \u2014 every entry must read \`status: decided\`; if not, stop and route back to that stage's human check`,"Reference (every run): `../../BRIEF.md` \xA7 Acceptance criteria"],doNotLoad:"source files already summarised in `inventory.md` (if it looks wrong, fix `inventory.md` and tell the person), `.werkmeister/*.yml`, other stages.",process:[`Write \`output/spec.md\`: what changes, file by file; the interfaces or schemas added; the tests that will prove it; what is explicitly out of scope. Promise an unchanged (byte-for-byte) copy of markdown only when \`inventory.md\` records the repo's lint passing on it; otherwise list the edits.${e.group.length?" This is a grouped PR: list one commit per ticket (`<KEY> \u2026`) and what each holds, but do not fix their order.":""}${I(e.group)}`,"If the change has a machine-checkable artifact (a schema, an API document, a migration), write it in the repo and validate it with a command that needs no new dependency. Record the exact command in `spec.md`.","Map each acceptance criterion in `BRIEF.md` to the step or test in `spec.md` that satisfies it. A criterion with no mapping is a defect in this stage.","Load every `_shared/standards.md` row whose Applies-when matches a file `spec.md` changes, not only the universal ones. Under `## Conflicts` in `spec.md`, write one line per place the ticket's proposed shape breaks a loaded standard (the rule, and the shape that would satisfy it), or `none`.","In `spec.md`, answer: how does an existing user turn this on? Name the setup or config path (a setup command, a config key or file) and the doc that describes it, or say none is needed. Map the answer to a criterion as in step 3; a missing answer is a defect in this stage."],outputs:[`\`output/spec.md\`${d}`,"Any artifact from step 2, in the repo"],humanCheck:c("spec.md","Read `output/spec.md` against the brief. Edit it directly \u2014 the next stage builds whatever is on disk.")}),"contract")},{name:"implement",job:"build it and prove it",gate:"review.md",writes:"code diff, `output/exercise.md`, `output/review.md`",check:"read the diff and `review.md`; tests green",standards:"all",contract:t(e=>({oneJob:"One job: make the changes `spec.md` lists, add the tests it names, and prove them against the running service.",inputs:[`Working (this run): \`${e.at("spec")}/output/spec.md\` and the files it names`,`Working (this run): \`${e.at("research")}/output/decisions.md\``,"Reference (every run): `../../.werkmeister/werkmeister-context.md` \u2014 container names, published ports, test command"],doNotLoad:`\`BRIEF.md\` (\`decisions.md\` and \`spec.md\` carry the settled scope), \`inventory.md\`, \`.werkmeister/*.yml\`, \`${i}\`, other stages.`,process:[...v,x("spec.md"),...E(e),"Make the changes `spec.md` lists, and only those. No new runtime dependency unless `decisions.md` justified one in a line.","Add the tests `spec.md` names. Match the style of the nearest existing test; no new test framework.",R("spec.md"),D,G(e),H,B,`Reload the running code: ${e.restart}. ${w} ${f} ${g} ${k} Then exercise the change as the How-to-validate section of \`werkmeister-context.md\` describes for each service touched, and capture the output. ${b} ${p} ${y} ${m}`,`Write \`output/exercise.md\`: \`git diff --stat\` for each repo you touched, the host and \`pr gate --tests\` exit codes and summary lines, ${$}, ${P}, any deviation from \`spec.md\` with its reason, and the exercise checks as ${S("evidence")}.`,A],outputs:[e.group.length?"Code changes, one commit per ticket (`<KEY> \u2026`), on the worktree's branch \u2014 the next stage keeps them":"Code changes, uncommitted \u2014 the next stage commits after the person reads the diff","`output/exercise.md`",`\`output/review.md\`: a \`| criterion | result | evidence |\` table, result exactly \`PASS\` or \`FAIL\`${d}`],humanCheck:c("review.md",e.group.length?"Read each ticket's commit (`git log -p origin/main..HEAD` in each worktree) and `review.md`. Run the tests yourself. Edit the code in place if something is off and fold it into that ticket's commit \u2014 the next stage keeps the commits as they are.":"Read the diff and `review.md`. Run the tests yourself. Edit the code in place if something is off \u2014 the next stage commits what is on disk.")}),"contract")},T],q=[{name:"reproduce",grants:u,job:"reproduce and locate the root cause",writes:"`output/repro.md`",check:"agree the root cause",standards:["testing","engineering","comments"],contract:t(e=>({oneJob:"One job: make the failure happen on demand and name its root cause. No fix is written in this stage.",inputs:["Working (this run): `../../BRIEF.md`",`Working (this run): the files in ${e.repos} on the failing path \u2014 follow the call chain, don't read whole trees`,"Reference (every run): `../../.werkmeister/werkmeister-context.md` \u2014 container names, published ports, logs, test command"],doNotLoad:"other stages' contracts, `.werkmeister/*.yml`.",process:[`Reproduce the failure against the running service or with a test. Record the exact command and its output. Judge each run by its exit code, or by a check you have shown fails on a known-bad run \u2014 never by grepping the output for a line that may not be printed. ${p}`,"Write the smallest failing test that captures it, in the style of the nearest existing test. Do not commit it yet.","Trace to the root cause: the first place the code does something other than intended. A symptom site is not a root cause.","List every other caller of the function at the root cause and what each does with the result (an early return, a printed value, a stored state), so the fix's return shape is checked against every caller before the fix stage \u2014 a fix there reaches them too. When the fix belongs in shared code, list its call sites through every helper or entry point that reaches that code, not one argument shape, and record the search commands (greps) you used in `repro.md`.",`When the proposed fix branches on a predicate, list each condition that makes it true and give each one a test. ${V}`,J,"When the root cause is a permission rule (allow, deny, ask), step 4 lists every source of a matching rule: each builder, each rule derived from a registered command (its `&&` segments included), rules recorded in existing workspaces and how a refresh or migrate removes them, and the list a headless wake passes (`--allowedTools` / `--disallowedTools`). The failing test probes each source. Also `git grep -F` the exact old rule text across the whole repo, tests and `apps/` included, and list each hit as a site the fix must update (SW-820).",`Write \`output/repro.md\`: steps 1\u20137, and a proposed fix in one paragraph under a \`status: proposed\` line.${I(e.group)} Check the proposed fix against the standards rows above and name any rule that already prescribes it. ${K}`],outputs:["`output/repro.md`","One failing test, uncommitted"],humanCheck:`Read \`output/repro.md\`. Correct the root cause or the proposed fix if needed, then change \`status: proposed\` to \`status: decided\`. That is the approval \u2014 the next session starts the fix without asking again. ${o}`}),"contract")},{name:"fix",job:"fix it at the root cause",gate:"fix.md",writes:"code diff, `output/fix.md`",check:"read the diff; the failing test now passes",enter:"`stages/01_reproduce/output/repro.md` reads `status: decided` \u2014 the flip *is* the approval, do not ask again",standards:"all",contract:t(e=>({oneJob:"One job: make the failing test pass by changing the code at the root cause, and nothing else.",inputs:[`Working (this run): \`${e.at("reproduce")}/output/repro.md\` \u2014 must read \`status: decided\`; if not, stop and route back`,"Working (this run): the failing test and the files at the root cause","Reference (every run): `../../.werkmeister/werkmeister-context.md` \u2014 test command"],doNotLoad:"`BRIEF.md` (`repro.md` carries the settled scope), `.werkmeister/*.yml`, other stages.",process:[...v,x("repro.md"),...E(e),"Apply the fix `repro.md` settled, at the root cause. Every caller `repro.md` lists gets the fix through the shared function \u2014 do not patch callers one by one.",R("repro.md"),Q,`Write \`output/fix.md\`: \`git diff --stat\` per repo, the failing test's name, the test exit code and summary line, ${$}, and ${P}.`],outputs:[e.group.length?"Code changes plus the test, one commit per ticket":"Code changes plus the test, uncommitted",`\`output/fix.md\`${d}`],humanCheck:c("fix.md",`${e.group.length?"Read each ticket's commit (`git log -p origin/main..HEAD`)":"Read the diff"}. Confirm the fix sits where \`repro.md\` put the root cause. Edit in place if not.`)}),"contract")},{name:"exercise",job:"prove it against the running service or the built CLI",gate:"review.md",writes:"`output/exercise.md`, `output/review.md`",check:"the original reproduction no longer fails",standards:"all",contract:t(e=>({oneJob:"One job: show the original failure is gone in the running service or the built binary, not just in the test. Then review the diff and fix what must be fixed.",inputs:[`Working (this run): \`${e.at("reproduce")}/output/repro.md\` \u2014 the reproduction steps`,`Working (this run): \`${e.at("fix")}/output/fix.md\``,"Reference (every run): `../../.werkmeister/werkmeister-context.md` \u2014 container names, published ports, test command"],doNotLoad:"`BRIEF.md` (`repro.md` carries the settled scope), `.werkmeister/*.yml`.",process:[`Reload the running code: ${e.restart}. ${w} ${f} ${g} ${k} ${b} ${p}`,"Rerun the reproduction steps from `repro.md` exactly. Capture the output.",`Exercise one neighbouring path through each caller \`repro.md\` listed. Capture the output. ${y} ${m}`,`Write \`output/exercise.md\`: steps 2\u20133 as ${S("detail")}.`,A,Y("rerun `werkmeister pr gate --tests` (from the workspace, as a background job with its log, as rule 3 of `_shared/pr-rules.md` shows), not one service's test command: it retests every service the diff touches, and these edits come after the fix stage's gate. Then rerun steps 2\u20133 and update `exercise.md`",e)],outputs:["`output/exercise.md`",`\`output/review.md\`: a \`| criterion | result | evidence |\` table, result exactly \`PASS\` or \`FAIL\`${d}`,e.group.length?"Code changes from Must fix findings, folded into their tickets' commits":"Code changes from Must fix findings, uncommitted"],humanCheck:c("review.md","Read `exercise.md` and `review.md`. A FAIL sends the run back to the fix stage.")}),"contract")},T],oe=[{name:"scope",grants:u,job:"fix the boundary and the invariants",writes:"`output/scope.md`",check:"agree what must not change",standards:"none",contract:t(e=>({oneJob:"One job: pin down what the refactor may touch and what behaviour must not change. No code is written in this stage.",inputs:["Working (this run): `../../BRIEF.md`",`Working (this run): the files in ${e.repos} that \`BRIEF.md\` names, and their callers`],doNotLoad:"`_shared/standards.md` (nothing is written here), other stages' contracts, `.werkmeister/*.yml`.",process:["List the files in scope and every caller outside it.","State the invariants: observable behaviour that must be identical after the refactor.","Name the existing tests that pin each invariant, and the gaps no test covers.",`Write \`output/scope.md\`: steps 1\u20133, the sequence of small steps you propose${e.group.length?` under one heading per ticket key (the workspace's issue, then ${h(e.group)})`:""}, and a \`status: proposed\` line.${I(e.group)}`],outputs:["`output/scope.md`"],humanCheck:`Read \`output/scope.md\`. Correct the scope or invariants, then change \`status: proposed\` to \`status: decided\`. That is the approval \u2014 the next session starts without asking again. ${o}`}),"contract")},{name:"implement",job:"refactor in green steps",gate:"review.md",writes:"code diff, `output/exercise.md`, `output/review.md`",check:"read the diff and `review.md`; tests green at every step",enter:"`stages/01_scope/output/scope.md` reads `status: decided` \u2014 the flip *is* the approval, do not ask again",standards:"all",contract:t(e=>({oneJob:"One job: carry out the steps `scope.md` settled, keeping every invariant true after each one.",inputs:[`Working (this run): \`${e.at("scope")}/output/scope.md\` \u2014 must read \`status: decided\``,"Working (this run): the files in scope","Reference (every run): `../../.werkmeister/werkmeister-context.md` \u2014 test command"],doNotLoad:"`BRIEF.md` (`scope.md` carries the settled scope), `.werkmeister/*.yml`, other stages.",process:[...v,x("scope.md"),...E(e),"First add a test for each invariant gap `scope.md` named. They must pass before any code moves.",`${e.group.length?"For each ticket, take its `scope.md` steps in order, then commit it before the next ticket; do not commit after every step. After each step":"Take the steps in order. After each one"}: ${R("scope.md")} ${D}`,G(e),H,B,`After the last step, reload and exercise the service: ${e.restart}. ${w} ${f} ${g} ${k} ${b} ${p} ${y} ${m}`,`Write \`output/exercise.md\`: \`git diff --stat\` per repo, the test result after each step, the \`pr gate --tests\` exit code, ${$}, ${P}, and the final exercise checks as ${S("evidence")}.`,A],outputs:[e.group.length?"Code changes, one commit per ticket (`<KEY> \u2026`)":"Code changes, uncommitted","`output/exercise.md`",`\`output/review.md\`: a \`| criterion | result | evidence |\` table, result exactly \`PASS\` or \`FAIL\`${d}`],humanCheck:c("review.md",`Read the diff against \`scope.md\`. Anything outside scope goes back.${e.group.length?" Read it per commit: `git log -p origin/main..HEAD`.":""}`)}),"contract")},T],ae=[{name:"questions",grants:u,job:"frame what the spike must answer",writes:"`output/questions.md`",check:"agree the questions and what settles them",standards:"none",contract:t(()=>({oneJob:"One job: turn the brief into questions, each with the evidence that would settle it. No code is written in this stage.",inputs:["Working (this run): `../../BRIEF.md`"],doNotLoad:"source trees, `_shared/standards.md`, `.werkmeister/*.yml`.",process:["List the questions the brief asks or implies, most decision-relevant first.","For each: how it will be answered (read code, measure, prototype) and what result settles it.","Write `output/questions.md`: steps 1\u20132 and a `status: proposed` line."],outputs:["`output/questions.md`"],humanCheck:`Edit the questions, then change \`status: proposed\` to \`status: decided\`. That is the approval \u2014 the next session starts without asking again. ${o}`}),"contract")},{name:"findings",job:"answer them with evidence",writes:"`output/findings.md`",check:"decide the next piece of work",enter:"`stages/01_questions/output/questions.md` reads `status: decided` \u2014 the flip *is* the approval, do not ask again",standards:"none",contract:t(e=>({oneJob:"One job: answer each settled question with evidence, and recommend what to build next.",inputs:[`Working (this run): \`${e.at("questions")}/output/questions.md\` \u2014 must read \`status: decided\``,`Working (this run): whatever each question's method names, in ${e.repos}`,"Reference (every run): `../../.werkmeister/werkmeister-context.md` \u2014 ports, containers","Reference (when the brief asks for a repo deliverable): `../../_shared/pr-rules.md` \u2014 the PR file format and the gate"],doNotLoad:"`_shared/standards.md` (prototype code is throwaway), `.werkmeister/*.yml`.",process:["Answer each question by its method. Prototype code lives in `output/` or on a scratch branch, never on the workspace branch.","Write `output/findings.md`: per question, the answer, the evidence (commands and output), and confidence.",`End \`findings.md\` with a recommendation: the next work item and its work type. ${X(e.questionTool)}`,"If the brief asks for a deliverable in a code repo (e.g. a doc opened as a PR): commit it on that worktree's branch, and write `output/pr-<worktree>.md` in the format of `_shared/pr-rules.md` at `status: draft`, with `repo:` taken from `git -C <worktree> remote get-url origin` (as `owner/repo`; the gate rejects any other value), an acceptance table and `skip_exercise: <reason>` when there is nothing to exercise."],outputs:["`output/findings.md`","`output/pr-<worktree>.md` per repo \u2014 only when the brief asks for a repo deliverable"],humanCheck:"Read `findings.md`. The recommendation becomes the brief of the next workspace, or the spike ends here. If there is a `pr-*.md`, set `status: approved`; `werkmeister pr open` runs the gate and opens it, and close-out waits for it to ship. Otherwise, when the recommendation is recorded where it is needed, the post-mortem (`postmortem` skill), then `werkmeister workspace close`."}),"contract")}],l={feature:re,bugfix:q,incident:q,refactor:oe,spike:ae};function ne(e){let s=e.trim().toLowerCase();return Object.hasOwn(l,s)?l[s]:l.feature}t(ne,"templateFor");function z(e){return e.map((s,a)=>`${String(a+1).padStart(2,"0")}_${s.name}`)}t(z,"stageDirs");function ie(e){let s=e.findIndex(a=>a.name==="propose");return s<0?null:z(e)[s]}t(ie,"proposeDir");function ve(e){return ie(e)??z(e)[e.length-1]}t(ve,"prDir");function xe(e){return[...new Set(ne(e).flatMap(s=>s.grants??[]))]}t(xe,"stageGrants");export{C as a,F as b,o as c,ue as d,se as e,ye as f,l as g,ne as h,z as i,ie as j,ve as k,xe as l};
86
+ //# sourceMappingURL=chunk-43O2Z5F5.js.map
@@ -1,4 +1,4 @@
1
1
  import { createRequire as __sandboxCreateRequire } from "node:module";
2
2
  const require = __sandboxCreateRequire(import.meta.url);
3
- import{b as O}from"./chunk-U6T4JBVH.js";import{n as N}from"./chunk-V2LECRKO.js";import{b as d}from"./chunk-PUJ267YF.js";import{l as x,s as l,w as g}from"./chunk-5IZDNFW6.js";import{a as n,f as T}from"./chunk-J4YFXJND.js";T();import*as c from"node:fs";import*as i from"node:path";var M=3002;function P(){let t=l("MCP_PORT")||N().overrides?.mcp_port,e=Number(t);return Number.isInteger(e)&&e>0?e:M}n(P,"daemonPort");function w(){return(l("HOST")||`http://127.0.0.1:${P()}`).replace(/\/+$/,"")}n(w,"daemonUrl");function S(t){try{return c.readFileSync(t,"utf8").trim()||null}catch{return null}}n(S,"readToken");function H(t){return l("MCP_TOKEN")||(t?S(O(t)):null)||S(i.join(g(),"mcp-token"))}n(H,"daemonToken");var m=class extends d{static{n(this,"DaemonUnavailable")}constructor(e){super(`werkmeister daemon not reachable at ${w()} (${e}). Run \`werkmeister machine setup\` (macOS) or \`werkmeister infra connect\`.`,"DAEMON_DOWN")}};function $(t){let e=t===void 0?H():t;return e?{Authorization:`Bearer ${e}`}:{}}n($,"headers");var p=class extends d{static{n(this,"DaemonTimeout")}constructor(e){super(`werkmeister daemon at ${w()} took the call but did not answer in time (${e}); it may still be running it.`,"DAEMON_TIMEOUT")}},b={ECONNREFUSED:"ECONNREFUSED: nothing is listening, the daemon is not running",ECONNRESET:"ECONNRESET: the daemon reset the connection while exiting or restarting"},U=n(()=>Number(l("DAEMON_RETRY_MS"))||15e3,"restartGapMs"),E=!1,I=n(t=>t==="TimeoutError"||t.startsWith("UND_ERR_")&&t!=="UND_ERR_CONNECT_TIMEOUT","tookTheCall"),y=n(t=>{let e=t;return e.cause?.code??e.name},"codeOf");async function R(t,e,r=!0){let s=Date.now()+(E?0:U());for(;;)try{let a=await fetch(t,e);return r&&(E=!1),a}catch(a){let o=y(a);if(I(o))throw new p(o);if(!(o in b))throw new m(o);if(!r||Date.now()>=s)throw r&&(E=!0),new m(b[o]);await new Promise(f=>setTimeout(f,500))}}n(R,"send");var A="x-werkmeister-build",_="x-werkmeister-stream",Z="x-werkmeister-launcher",q="x-werkmeister-client-ui";function z(t){if(!t)return null;try{let e=c.statSync(t).mtime.toISOString().replace(/\.\d+Z$/,"Z");for(let r=i.dirname(t);;r=i.dirname(r)){let s=i.join(r,"package.json");if(c.existsSync(s))return`${JSON.parse(c.readFileSync(s,"utf8")).version} @ ${e}`;if(i.dirname(r)===r)return null}}catch{return null}}n(z,"buildOf");var C=null,k=!1;function K(t){C=t}n(K,"expectDaemonBuild");function L(){try{return C?.()??null}catch{return null}}n(L,"buildToSend");function j(t,e){let r=e.headers.get(A);k||!t||!r||r===t||(k=!0,x(`The werkmeister daemon runs an older build (loaded ${r}, on disk ${t}); it restarts by itself once idle, or run \`werkmeister daemon restart\`.`))}n(j,"checkBuild");async function V(){try{let t=await R(`${w()}/api/status`,{headers:$(void 0),signal:AbortSignal.timeout(5e3)},!1);return t.ok?await t.json():null}catch{return null}}n(V,"daemonStatus");async function Y(t,e={},r={}){let s=AbortSignal.timeout(r.timeoutMs??12e4),a=L(),o=await R(`${w()}/api/tool`,{method:"POST",headers:{"Content-Type":"application/json",...$(r.token),...a?{[A]:a}:{},[_]:"1"},body:JSON.stringify({name:t,arguments:e}),signal:r.signal?AbortSignal.any([r.signal,s]):s});if(j(a,o),!o.headers.get("content-type")?.includes("json")&&o.status!==401&&o.status!==403)throw new m(`HTTP ${o.status}: the port is held by something that is not the werkmeister daemon`);let f=o.headers.get(_)==="1",u=await o.json().catch(D=>{if(f)throw new p(y(D));return{}}),h=f?u.status??500:o.status;if(h<200||h>299)throw u.error?.replace(/^MCP error -?\d+: /,"")===`Tool ${t} not found`?new d(`The werkmeister daemon is older than this CLI: it has no \`${t}\` tool. Run \`werkmeister daemon restart\`.`,"DAEMON_STALE"):new d(u.error??`daemon answered HTTP ${h} to ${t}`,u.code??`HTTP_${h}`);return{data:u.structuredContent,text:u.text??""}}n(Y,"callTool");export{M as a,P as b,w as c,H as d,m as e,A as f,_ as g,Z as h,q as i,z as j,K as k,V as l,Y as m};
4
- //# sourceMappingURL=chunk-KWH5X47W.js.map
3
+ import{b as O}from"./chunk-2R3TTVDD.js";import{n as N}from"./chunk-P4LYRKV2.js";import{b as d}from"./chunk-K7PSTFHC.js";import{l as x,s as l,w as g}from"./chunk-2DZPE4HK.js";import{a as n,f as T}from"./chunk-BA6RZ57Q.js";T();import*as c from"node:fs";import*as i from"node:path";var M=3002;function P(){let t=l("MCP_PORT")||N().overrides?.mcp_port,e=Number(t);return Number.isInteger(e)&&e>0?e:M}n(P,"daemonPort");function w(){return(l("HOST")||`http://127.0.0.1:${P()}`).replace(/\/+$/,"")}n(w,"daemonUrl");function S(t){try{return c.readFileSync(t,"utf8").trim()||null}catch{return null}}n(S,"readToken");function H(t){return l("MCP_TOKEN")||(t?S(O(t)):null)||S(i.join(g(),"mcp-token"))}n(H,"daemonToken");var m=class extends d{static{n(this,"DaemonUnavailable")}constructor(e){super(`werkmeister daemon not reachable at ${w()} (${e}). Run \`werkmeister machine setup\` (macOS) or \`werkmeister infra connect\`.`,"DAEMON_DOWN")}};function $(t){let e=t===void 0?H():t;return e?{Authorization:`Bearer ${e}`}:{}}n($,"headers");var p=class extends d{static{n(this,"DaemonTimeout")}constructor(e){super(`werkmeister daemon at ${w()} took the call but did not answer in time (${e}); it may still be running it.`,"DAEMON_TIMEOUT")}},b={ECONNREFUSED:"ECONNREFUSED: nothing is listening, the daemon is not running",ECONNRESET:"ECONNRESET: the daemon reset the connection while exiting or restarting"},U=n(()=>Number(l("DAEMON_RETRY_MS"))||15e3,"restartGapMs"),E=!1,I=n(t=>t==="TimeoutError"||t.startsWith("UND_ERR_")&&t!=="UND_ERR_CONNECT_TIMEOUT","tookTheCall"),y=n(t=>{let e=t;return e.cause?.code??e.name},"codeOf");async function R(t,e,r=!0){let s=Date.now()+(E?0:U());for(;;)try{let a=await fetch(t,e);return r&&(E=!1),a}catch(a){let o=y(a);if(I(o))throw new p(o);if(!(o in b))throw new m(o);if(!r||Date.now()>=s)throw r&&(E=!0),new m(b[o]);await new Promise(f=>setTimeout(f,500))}}n(R,"send");var A="x-werkmeister-build",_="x-werkmeister-stream",Z="x-werkmeister-launcher",q="x-werkmeister-client-ui";function z(t){if(!t)return null;try{let e=c.statSync(t).mtime.toISOString().replace(/\.\d+Z$/,"Z");for(let r=i.dirname(t);;r=i.dirname(r)){let s=i.join(r,"package.json");if(c.existsSync(s))return`${JSON.parse(c.readFileSync(s,"utf8")).version} @ ${e}`;if(i.dirname(r)===r)return null}}catch{return null}}n(z,"buildOf");var C=null,k=!1;function K(t){C=t}n(K,"expectDaemonBuild");function L(){try{return C?.()??null}catch{return null}}n(L,"buildToSend");function j(t,e){let r=e.headers.get(A);k||!t||!r||r===t||(k=!0,x(`The werkmeister daemon runs an older build (loaded ${r}, on disk ${t}); it restarts by itself once idle, or run \`werkmeister daemon restart\`.`))}n(j,"checkBuild");async function V(){try{let t=await R(`${w()}/api/status`,{headers:$(void 0),signal:AbortSignal.timeout(5e3)},!1);return t.ok?await t.json():null}catch{return null}}n(V,"daemonStatus");async function Y(t,e={},r={}){let s=AbortSignal.timeout(r.timeoutMs??12e4),a=L(),o=await R(`${w()}/api/tool`,{method:"POST",headers:{"Content-Type":"application/json",...$(r.token),...a?{[A]:a}:{},[_]:"1"},body:JSON.stringify({name:t,arguments:e}),signal:r.signal?AbortSignal.any([r.signal,s]):s});if(j(a,o),!o.headers.get("content-type")?.includes("json")&&o.status!==401&&o.status!==403)throw new m(`HTTP ${o.status}: the port is held by something that is not the werkmeister daemon`);let f=o.headers.get(_)==="1",u=await o.json().catch(D=>{if(f)throw new p(y(D));return{}}),h=f?u.status??500:o.status;if(h<200||h>299)throw u.error?.replace(/^MCP error -?\d+: /,"")===`Tool ${t} not found`?new d(`The werkmeister daemon is older than this CLI: it has no \`${t}\` tool. Run \`werkmeister daemon restart\`.`,"DAEMON_STALE"):new d(u.error??`daemon answered HTTP ${h} to ${t}`,u.code??`HTTP_${h}`);return{data:u.structuredContent,text:u.text??""}}n(Y,"callTool");export{M as a,P as b,w as c,H as d,m as e,A as f,_ as g,Z as h,q as i,z as j,K as k,V as l,Y as m};
4
+ //# sourceMappingURL=chunk-443FHHSF.js.map