chamba 0.9.0 → 0.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. package/README.md +7 -2
  2. package/dist/commands/dev.js +11 -11
  3. package/dist/commands/menu.js +1 -1
  4. package/dist/commands/settings.js +9 -6
  5. package/dist/lib/awake-holder.js +3 -0
  6. package/dist/lib/awake-marker.js +4 -0
  7. package/dist/lib/awake.js +1 -0
  8. package/dist/lib/constants.js +1 -1
  9. package/dist/lib/global-config.js +3 -3
  10. package/dist/lib/skills.js +2 -2
  11. package/package.json +1 -1
  12. package/templates/pane-apps/client/assets/api-Cyoc3E6K.css +1 -0
  13. package/templates/pane-apps/client/assets/home-CLFnmg7u.css +1 -0
  14. package/templates/pane-apps/client/assets/home-CrhBkqDQ.js +1 -0
  15. package/templates/pane-apps/client/assets/reviews-Bq8EwmG-.js +153 -0
  16. package/templates/pane-apps/client/assets/reviews-DzHtA35Q.css +1 -0
  17. package/templates/pane-apps/client/assets/{files-BkmyervY.js → search-DgFnnu-J.js} +1 -1
  18. package/templates/pane-apps/client/assets/specs-JvdNFtXR.js +13 -0
  19. package/templates/pane-apps/client/assets/{useNow-BHFKFraS.js → useNow-Ww-Gffnk.js} +1 -1
  20. package/templates/pane-apps/client/home/index.html +5 -5
  21. package/templates/pane-apps/client/reviews/index.html +6 -6
  22. package/templates/pane-apps/client/specs/index.html +4 -4
  23. package/templates/pane-apps/server/home.mjs +11 -12
  24. package/templates/pane-apps/server/specs.mjs +4 -4
  25. package/templates/skills/dx-spec/SKILL.md +4 -16
  26. package/templates/skills/dx-spec/references/review-guide.md +13 -7
  27. package/templates/skills/dx-spec/references/spec-guide.md +11 -4
  28. package/templates/skills/dx-spec/references/stages.md +38 -22
  29. package/templates/skills/dx-spec-execute/SKILL.md +5 -21
  30. package/templates/webterm/README.md +11 -8
  31. package/templates/webterm/awake.js +27 -0
  32. package/templates/webterm/config.js +10 -0
  33. package/templates/webterm/public/app/state.js +4 -0
  34. package/templates/webterm/public/app/tabs.js +37 -3
  35. package/templates/webterm/public/styles.css +13 -0
  36. package/templates/webterm/server.js +24 -1
  37. package/templates/webterm/tools/home.js +25 -3
  38. package/templates/pane-apps/client/assets/api-DNLbSBpK.css +0 -1
  39. package/templates/pane-apps/client/assets/home-3SeGzySM.css +0 -1
  40. package/templates/pane-apps/client/assets/home-Cu9xOd2i.js +0 -1
  41. package/templates/pane-apps/client/assets/reviews-DMrGB-kG.js +0 -153
  42. package/templates/pane-apps/client/assets/reviews-nK_yRav9.css +0 -1
  43. package/templates/pane-apps/client/assets/specs-Cabb15F0.js +0 -13
  44. package/templates/skills/dx-spec/references/principles-template.md +0 -2
  45. /package/templates/pane-apps/client/assets/{api-BBDf_rzz.js → api-CguEsvNp.js} +0 -0
@@ -0,0 +1 @@
1
+ :root{--rv-accent-bg:#58a6ff1f;--rv-ok-bg:#3fb9501f;--rv-warn-bg:#d2992224;--rv-issue:#f85149;--rv-reply:#a371f7;--rv-add-bg:#12291b;--rv-add:#7ee787;--rv-del-bg:#2b1719;--rv-del:#ffa198;--rv-btn-text:#0d1117;--rv-shadow:#00000073}[data-theme=light]{--rv-accent-bg:#0969da1a;--rv-ok-bg:#1a7f371a;--rv-warn-bg:#9a67001f;--rv-issue:#cf222e;--rv-reply:#8250df;--rv-add-bg:#dafbe1;--rv-add:#116329;--rv-del-bg:#ffebe9;--rv-del:#82071e;--rv-btn-text:#fff;--rv-shadow:#1f23282e}.workspace.is-review .stage.has-bar .theme-toggle{background:0 0;top:8px;right:10px}.rv-mono{font-family:ui-monospace,Menlo,monospace;font-size:12px}.rv-row:disabled{cursor:default;opacity:.6}.rv-row-top{align-items:flex-start;gap:6px;display:flex}.rv-row-name{overflow-wrap:anywhere;flex:1;min-width:0;font-weight:600}.rv-row-chip{border:1px solid var(--border);color:var(--muted);border-radius:9px;flex:none;margin-top:2px;padding:0 6px;font-size:10.5px;line-height:15px}.rv-row-chip.is-merged{border-color:var(--accent);color:var(--accent)}.rv-bar{background:var(--border);border-radius:2px;height:3px;margin-top:5px;overflow:hidden}.rv-bar i{background:var(--ok);height:100%;display:block}.rv-row-state{color:var(--muted);margin-top:4px;font-size:11px}.rv-row-note{color:var(--muted);margin-top:2px;font-size:11px;font-style:italic}.rv-dot{background:var(--accent);vertical-align:middle;border-radius:50%;width:7px;height:7px;margin-right:5px;display:inline-block}@media (prefers-reduced-motion:no-preference){.rv-dot{animation:1.6s infinite rv-pulse}}@keyframes rv-pulse{0%,to{opacity:1}50%{opacity:.3}}.nav-list button.rv-gi{color:var(--fg);border-left:0;padding:6px 14px;font-size:12.5px}.rv-gdots{flex:none;gap:4px;display:inline-flex}.rv-gdot{background:var(--accent);border-radius:50%;width:7px;height:7px;display:inline-block}.rv-gdot.is-issue{background:var(--rv-issue)}.rv-gdot.is-attention{background:var(--warn)}.rv-gdot.is-reply{background:var(--rv-reply)}.rv-gright{line-height:var(--nav-line);color:var(--muted);white-space:nowrap;flex:none;align-items:center;gap:6px;margin-left:auto;font-size:11px;display:inline-flex}.rv-gcheck{font-size:12px}.rv-ring{width:14px;height:14px;display:block}.rv-ring circle{fill:none;stroke-width:2px}.rv-ring-bg{stroke:var(--border)}.rv-ring-fg{stroke:var(--ok);stroke-linecap:round;transform-origin:50%;transform:rotate(-90deg)}.rv-gsep{border-top:1px solid var(--border);margin-top:6px;padding-top:6px}.rv-gsep .rv-gname{color:var(--muted)}.rv-gi:hover{background:var(--sunken)}.nav-list button.rv-gi[aria-current=true]{background:var(--sel);box-shadow:inset 3px 0 0 var(--accent)}.rv-gi.is-done,.rv-gi.is-empty{color:var(--muted)}.rv-gi.is-done .rv-gright{color:var(--ok)}.rv-gwait{min-height:calc(var(--nav-line) * 1em);align-items:center;padding:6px 14px;display:flex}.rv-plus{color:var(--rv-add)}.rv-minus{color:var(--rv-del)}.rv-gnote{position:relative}.rv-info{all:unset;box-sizing:border-box;width:14px;height:14px;color:var(--muted);vertical-align:-2px;cursor:default;justify-content:center;align-items:center;display:inline-flex}.rv-info:hover,.rv-info:focus{color:var(--fg)}.rv-infotip{width:220px;box-shadow:0 6px 18px var(--rv-shadow)}.rv-screen{flex-direction:column;height:100%;min-height:0;display:flex}.rv-head{border-bottom:1px solid var(--border);background:var(--panel);align-items:center;gap:10px;padding:8px 40px 8px 12px;display:flex}.rv-head h2{white-space:nowrap;margin:0;font-size:14px;font-weight:600}.rv-head-what{color:var(--muted);white-space:nowrap;text-overflow:ellipsis;overflow:hidden}.rv-grow{flex:1}.rv-chip{white-space:nowrap;border:1px solid #0000;border-radius:10px;padding:0 7px;font-size:11px;line-height:18px;display:inline-block}.rv-chip.is-you{background:var(--rv-warn-bg);color:var(--warn);border-color:var(--warn)}.rv-chip.is-ready{background:var(--rv-ok-bg);color:var(--ok);border-color:var(--ok)}.rv-chip.is-ended{background:var(--ok);color:var(--rv-btn-text)}.rv-agentbar{border-bottom:1px solid var(--border);background:var(--rv-accent-bg);align-items:center;gap:12px;padding:8px 12px;display:flex}.rv-agentbar b{color:var(--accent);white-space:nowrap}.rv-say{flex:1;min-width:0}.rv-asked{color:var(--muted)}.rv-say .rv-late{color:var(--warn)}.rv-status{border-top:1px solid var(--border);background:var(--panel);color:var(--muted);white-space:nowrap;align-items:center;gap:12px;padding:6px 12px;font-size:12px;display:flex}.rv-loops{align-items:center;gap:4px;display:inline-flex}.rv-loops svg{width:14px;height:14px;display:block}.rv-prog{background:var(--border);border-radius:3px;width:150px;height:6px;overflow:hidden}.rv-prog i{background:var(--ok);height:100%;display:block}.rv-fact{color:var(--fg);align-items:center;gap:5px;display:inline-flex}.rv-fact i{background:var(--muted);border-radius:50%;width:6px;height:6px;display:inline-block}.rv-fact.is-issue i{background:var(--rv-issue)}.rv-fact.is-attention i,.rv-fact.is-you i,.rv-fact.is-changed i{background:var(--warn)}.rv-fact.is-reply i{background:var(--rv-reply)}.rv-log-toggle{all:unset;color:var(--muted);cursor:pointer;font:inherit;align-items:center;gap:5px;font-size:12px;display:inline-flex}.rv-log{border-top:1px solid var(--border);background:var(--bg);max-height:40%;color:var(--muted);padding:6px 12px 6px 30px;font-size:12px;line-height:1.7;overflow:auto}.rv-log b{color:var(--fg);font-weight:500}.rv-ghead{z-index:5;border-bottom:1px solid var(--border);background:var(--bg);margin:0 -12px 4px;padding:10px 12px 0;position:sticky;top:0}.rv-ghead.is-under{top:var(--rv-bar)}.rv-gtitle{align-items:center;gap:10px;display:flex}.rv-gacts{flex:none;gap:8px;display:inline-flex}.rv-ghead h3{margin:0;font-size:15px;font-weight:600}.rv-gnarr{max-width:820px;color:var(--muted);margin:6px 0 10px}.rv-gfacts{color:var(--muted);margin:0 0 8px;padding-left:18px;font-size:12px}.rv-gshared{color:var(--muted);margin:0 0 8px;font-size:12px}.rv-gstrip{background:var(--border);height:3px;margin:8px -12px 0;overflow:hidden}.rv-gstrip i{background:var(--ok);height:100%;display:block}.rv-gfold{height:calc(var(--rv-fold,0px) * (1 - var(--rv-collapse,0)));opacity:calc(1 - var(--rv-collapse,0));overflow:hidden}.rv-gfold-in{display:flow-root}.rv-gfold-in>:last-child{margin-bottom:0}.rv-ghead.is-compact{box-shadow:0 6px 12px -6px var(--rv-shadow)}.rv-ghead.is-skel{padding-bottom:10px;position:static}.rv-gtalk{flex-direction:column;gap:8px;display:flex}.rv-navrow{flex-wrap:wrap;gap:6px;padding-bottom:8px;display:flex}.rv-ghead .rv-navrow{padding-top:8px}.rv-nav{all:unset;box-sizing:border-box;border:1px solid var(--border);background:var(--panel);color:var(--fg);cursor:pointer;font:inherit;white-space:nowrap;border-radius:12px;align-items:center;gap:6px;padding:2px 9px 2px 6px;font-size:12px;display:inline-flex}.rv-nav:hover{border-color:var(--accent)}.rv-navn{background:var(--muted);min-width:16px;color:var(--rv-btn-text);text-align:center;border-radius:8px;padding:0 5px;font-size:11px;font-weight:600}.rv-nav.is-issue .rv-navn{background:var(--rv-issue)}.rv-nav.is-attention .rv-navn{background:var(--warn)}.rv-nav.is-reply .rv-navn{background:var(--rv-reply)}.rv-nav.is-morph{background:var(--rv-accent-bg);color:var(--muted);border-color:#0000}.rv-nav.is-morph b{color:var(--fg);font-weight:600}.rv-navdot{background:var(--accent);border-radius:50%;width:8px;height:8px;display:inline-block}.rv-nav.is-issue .rv-navdot{background:var(--rv-issue)}.rv-nav.is-attention .rv-navdot{background:var(--warn)}.rv-nav.is-reply .rv-navdot{background:var(--rv-reply)}.rv-nav.is-done{color:var(--muted);cursor:default;border-style:dashed}.rv-nav.is-done .rv-navn{color:var(--ok);background:0 0;font-size:12px}.rv-allbar{z-index:7;height:var(--rv-bar);border-bottom:1px solid var(--border);background:var(--bg);align-items:center;gap:10px;margin:0 -12px;padding:0 12px;display:flex;position:sticky;top:0}.rv-allbar h3{margin:0;font-size:13px;font-weight:600}.rv-allbar .rv-navrow{padding:0}.is-landed{animation:1.2s ease-out rv-landed}@keyframes rv-landed{0%{background:var(--rv-accent-bg)}to{background:0 0}}.rv-body{flex:1;min-height:0;display:flex;position:relative}.rv-feed{--rv-bar:44px;overflow-anchor:none;flex:1;min-width:0;overflow:auto}.rv-totop{z-index:5;border:1px solid var(--border);background:var(--panel);width:34px;height:34px;box-shadow:0 6px 18px var(--rv-shadow);color:var(--fg);cursor:pointer;font:inherit;border-radius:50%;font-size:16px;position:absolute;bottom:60px;right:52px}.rv-fgrid{padding:10px 4px 10px 12px;position:relative}.rv-fmain{flex-direction:column;gap:10px;min-width:0;padding-right:12px;display:flex}.rv-gcard{border:1px solid var(--border);background:var(--panel);border-radius:8px;padding:10px 12px}.rv-gcard-top{align-items:center;gap:8px;display:flex}.rv-gcard h3{margin:0;font-size:13px;font-weight:600}.rv-facts{color:var(--muted);font-size:12px}.rv-gcard p{margin:6px 0}.rv-gcard ul{color:var(--muted);margin:6px 0 0;padding-left:18px;font-size:12px}.rv-gcard-acts{gap:8px;margin-top:6px;display:flex}.rv-section{flex-direction:column;gap:10px;display:flex}.rv-fmain.is-all .rv-section+.rv-section{margin-top:8px}.rv-hunk{border:1px solid var(--border);background:var(--panel);border-radius:8px;min-width:0;position:relative}.rv-fh{border-bottom:1px solid var(--border);color:var(--muted);align-items:center;gap:8px;padding:6px 10px;font-size:12px;display:flex}.rv-fh.is-note,.rv-folded.is-note{padding-left:24px}.rv-nt-head.is-note{padding-left:14px}.rv-fh .rv-path{color:var(--fg);text-overflow:ellipsis;white-space:nowrap;min-width:0;overflow:hidden}.rv-fh .rv-path i{color:var(--muted);font-style:normal}.rv-also{border:1px solid var(--border);white-space:nowrap;border-radius:9px;padding:0 6px;font-size:11px}.rv-changed{border:1px solid var(--warn);background:var(--rv-warn-bg);color:var(--warn);white-space:nowrap;border-radius:9px;padding:0 6px;font-size:10.5px;line-height:15px}.rv-diff{margin:0;padding:4px 0 6px;overflow-x:auto}.rv-hd{color:var(--muted);background:var(--rv-accent-bg);padding:2px 10px 4px;font-family:ui-monospace,Menlo,monospace;font-size:12px}.rv-l{white-space:pre;grid-template-columns:34px 34px 1fr;font-family:ui-monospace,Menlo,monospace;font-size:12px;line-height:20px;display:grid}.rv-l .rv-ln{all:unset;box-sizing:border-box;color:var(--muted);text-align:right;font:inherit;padding-right:8px;font-size:11px;display:block}.rv-l button.rv-ln{cursor:pointer}.rv-l button.rv-ln:hover{color:var(--fg);background:var(--sunken)}.rv-l.is-picked{box-shadow:inset 0 0 0 1px var(--accent)}.rv-l,.rv-fh,.rv-folded,.rv-nt-head{position:relative}.rv-hdot{background:var(--accent);border:0;border-radius:50%;width:6px;height:6px;margin:-3px 0 0;padding:0;position:absolute;top:50%;left:10px}button.rv-hdot{cursor:pointer}.rv-fh.is-note .rv-hdot,.rv-nt-head .rv-hdot{background:var(--accent)}.rv-nt-head .rv-hdot{left:0}.rv-fh.is-note.is-attention .rv-hdot{background:var(--warn)}.rv-fh.is-note.is-issue .rv-hdot{background:var(--rv-issue)}.rv-folded.is-note:before{content:"";background:var(--accent);border-radius:50%;width:6px;height:6px;margin-top:-3px;position:absolute;top:50%;left:10px}.rv-folded.is-note.is-attention:before{background:var(--warn)}.rv-folded.is-note.is-issue:before{background:var(--rv-issue)}.rv-nl{background:var(--accent);border:0;width:3px;padding:0;position:absolute;top:0;bottom:0}button.rv-nl{cursor:pointer}button.rv-nl:hover{width:5px}.rv-nl.is-lane0{left:2px}.rv-nl.is-lane1{left:7px}.rv-nl.is-attention{background:var(--warn)}.rv-nl.is-issue{background:var(--rv-issue)}.rv-nl.is-first{border-radius:2px 2px 0 0;top:3px}.rv-nl.is-last{border-radius:0 0 2px 2px;bottom:3px}.rv-nl.is-first.is-last{border-radius:2px}.rv-l span:last-child{padding-left:10px}.rv-l.is-add{background:var(--rv-add-bg);color:var(--rv-add)}.rv-l.is-del{background:var(--rv-del-bg);color:var(--rv-del)}.rv-expand{background:var(--sunken);gap:10px;padding:2px 10px;font-size:11.5px;display:flex}.rv-trouble{color:var(--warn);margin:0;padding:4px 10px 6px;font-size:12px}.rv-folded{border:1px solid var(--border);background:var(--panel);min-width:0;color:var(--muted);border-radius:8px;align-items:center;gap:8px;padding:6px 10px;font-size:12px;display:flex}.rv-fnotes{color:var(--accent);font-size:11.5px}.rv-folded .rv-mono{text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.rv-ok{color:var(--ok)}.rv-link{all:unset;color:var(--accent);cursor:pointer;font:inherit;font-size:12px}.rv-fh .rv-link{white-space:nowrap;border:1px solid var(--border);border-radius:999px;flex:none;padding:1px 8px;font-size:11.5px}.rv-fh .rv-link:hover{border-color:var(--accent)}.rv-fh .rv-link:disabled{opacity:.5;cursor:default}.rv-state{font-size:11.5px}.rv-state.is-seen{color:var(--ok)}button.rv-state{all:unset;white-space:nowrap;cursor:pointer;font:inherit;color:var(--ok);border:1px solid #0000;border-radius:999px;flex:none;padding:1px 8px;font-size:11.5px}button.rv-state .rv-state-off{display:none}button.rv-state:hover,button.rv-state:focus-visible{border-color:var(--border);color:var(--fg)}button.rv-state:hover .rv-state-on,button.rv-state:focus-visible .rv-state-on{display:none}button.rv-state:hover .rv-state-off,button.rv-state:focus-visible .rv-state-off{display:inline}.rv-fab{background:var(--accent);width:30px;height:30px;color:var(--rv-btn-text);cursor:pointer;box-shadow:0 3px 10px var(--rv-shadow);opacity:0;border:0;border-radius:50%;justify-content:center;align-items:center;font-size:18px;font-weight:600;transition:opacity .12s;display:flex;position:absolute;bottom:10px;right:10px}.rv-hunk:hover .rv-fab,.rv-hunk:focus-within .rv-fab{opacity:1}.rv-fabmenu{background:var(--panel);border:1px solid var(--border);box-shadow:0 10px 24px var(--rv-shadow);z-index:3;border-radius:8px;min-width:170px;padding:4px;position:absolute;bottom:10px;right:46px;overflow:hidden}.rv-fabmenu button{all:unset;box-sizing:border-box;text-align:left;cursor:pointer;width:100%;font:inherit;border-radius:3px;padding:5px 9px;font-size:12.5px;display:block}.rv-fabmenu button.rv-seen{color:var(--ok);font-weight:600}.rv-fabmenu button:hover:not(:disabled){background:var(--sunken)}.rv-fabmenu button:disabled{opacity:.5;cursor:default}.rv-fabmenu hr{border:0;border-top:1px solid var(--border);margin:3px 0}.rv-nt{border:1px solid var(--border);background:var(--panel);border-radius:8px}.rv-nt>summary{color:var(--muted);cursor:pointer;padding:6px 10px;font-size:12px}.rv-nt-names{margin-left:8px;font-family:ui-monospace,Menlo,monospace;font-size:11.5px}.rv-nt-row{border-top:1px solid var(--border);padding:6px 10px}.rv-nt-head{align-items:center;gap:8px;min-width:0;font-size:12px;display:flex}.rv-nt-images{gap:12px;padding:8px 0 2px;display:flex}.rv-nt-images figure{color:var(--muted);margin:0;font-size:11px}.rv-nt-images img{border:1px solid var(--border);background:var(--sunken);border-radius:4px;max-width:220px;max-height:160px;display:block}.rv-waiting{min-height:70px}.rv-skel{background:var(--border);opacity:.7;border-radius:3px;height:12px;margin:8px 0}.rv-skel.is-narrow{width:40%}.rv-skel.is-wide{width:80%}.rv-skel.is-half{width:60%}.rv-gwait .rv-skel{width:70%;margin:0}.rv-inote{border-left:3px solid var(--accent);background:var(--sunken);color:var(--fg);white-space:normal;border-radius:0 6px 6px 0;margin:4px 10px 6px 2px;padding:6px 10px 7px;font-family:system-ui,-apple-system,Segoe UI,Roboto,sans-serif;font-size:12.5px;line-height:1.5}.rv-hunk>.rv-inote{margin:8px 10px 4px 2px}.rv-inote-top{align-items:baseline;gap:8px;display:flex}.rv-inote .rv-note-kind{color:var(--accent);letter-spacing:.04em;text-transform:uppercase;font-size:10.5px;font-weight:700}.rv-inote .rv-note-ln{color:var(--muted);font-family:ui-monospace,Menlo,monospace;font-size:11px}.rv-inote .rv-note-txt{margin:2px 0 6px}.rv-inote .rv-note-acts{gap:6px;display:flex}.rv-inote .rv-note-dismissed{color:var(--muted);margin-right:6px;font-size:11.5px}.rv-inote-box{margin:0 10px 8px 2px}.rv-inote .rv-note-locked{color:var(--muted);font-size:11.5px}.rv-inote.is-attention{border-left-color:var(--warn)}.rv-inote.is-attention .rv-note-kind{color:var(--warn)}.rv-inote.is-issue{border-left-color:var(--rv-issue)}.rv-inote.is-issue .rv-note-kind{color:var(--rv-issue)}.rv-inote.is-dismissed{display:none}.rv-inote.is-dismissed.is-back{display:block}.rv-note-act{border:1px solid var(--border);background:var(--panel);color:var(--fg);cursor:pointer;font:inherit;border-radius:5px;padding:2px 8px;font-size:11.5px}.rv-note-act:hover{border-color:var(--accent)}.rv-note-act.is-fix{border-color:var(--accent);color:var(--accent)}.rv-form{max-width:640px;margin:28px auto;padding:0 20px;overflow:auto}.rv-form h2{margin:0 0 4px;font-size:18px;font-weight:600}.rv-form h3{margin:22px 0 4px;font-size:15px;font-weight:600}.rv-form-row{justify-content:space-between;align-items:baseline;gap:10px;display:flex}.rv-form-row h3{margin-bottom:4px}.rv-opt.is-waiting{color:var(--muted);cursor:default;border-style:dashed;align-items:center;gap:10px;padding:12px 14px;display:flex}.rv-lead{color:var(--muted);margin:0 0 14px}.rv-opt{border:1px solid var(--border);background:var(--panel);cursor:pointer;border-radius:6px;grid-template-columns:16px minmax(0,1fr);gap:6px 8px;margin-bottom:6px;padding:8px 10px;display:grid;position:relative}.rv-opt.is-chosen{border-color:var(--accent);background:var(--rv-accent-bg)}.rv-opt.is-refused{border-color:var(--border);cursor:default}.rv-radio-input{opacity:0;width:0;height:0;margin:0;position:absolute}.rv-radio{border:1px solid var(--muted);border-radius:50%;width:12px;height:12px;margin-top:3px}.rv-opt.is-chosen .rv-radio{border:4px solid var(--accent)}.rv-opt-title{justify-content:space-between;gap:8px;min-width:0;display:flex}.rv-opt-title b{overflow-wrap:anywhere;min-width:0;font-weight:600}.rv-count{color:var(--muted);white-space:nowrap}.rv-opt-detail{min-width:0;color:var(--muted);overflow-wrap:anywhere;grid-column:2;font-size:12px}.rv-opt-detail input,.rv-opt-detail select{font:inherit;color:var(--fg);background:var(--sunken);border:1px solid var(--border);border-radius:5px;padding:1px 5px;font-size:12px}.rv-commits{min-width:0;color:var(--muted);grid-column:2;margin:0;padding:0;font-size:12px;list-style:none}.rv-commits li{white-space:nowrap;text-overflow:ellipsis;overflow:hidden}.rv-check{grid-column:2;align-items:center;gap:6px;font-size:12px;display:flex}.rv-form-foot{align-items:center;gap:10px;margin-top:12px;display:flex}.rv-form-foot label{color:var(--muted);font-size:12px}.rv-form-foot input{font:inherit;color:var(--fg);background:var(--sunken);border:1px solid var(--border);border-radius:5px;flex:1;padding:3px 7px}.rv-form-note{color:var(--muted);margin-top:8px;font-size:12px}.rv-form-acts{border-top:1px solid var(--border);justify-content:flex-end;gap:10px;margin-top:18px;padding-top:14px;display:flex}.rv-refused{border:1px solid var(--warn);background:var(--rv-warn-bg);color:var(--fg);border-radius:6px;margin-top:10px;padding:6px 10px;font-size:12px}.rv-btn{border:1px solid var(--border);background:var(--panel);color:var(--fg);cursor:pointer;font:inherit;white-space:nowrap;border-radius:6px;padding:4px 10px}.rv-btn.is-primary{background:var(--accent);border-color:var(--accent);color:var(--rv-btn-text);font-weight:600}.rv-btn.is-outline{border-color:var(--accent);color:var(--accent);background:0 0}.rv-btn.is-small{padding:2px 8px;font-size:12px}.rv-btn:disabled{opacity:.5;cursor:default}.rv-icon{all:unset;color:var(--muted);cursor:pointer;align-items:center;padding:0 2px;display:inline-flex}.rv-icon svg{stroke:currentColor;fill:none;stroke-width:1.5px;stroke-linecap:round;stroke-linejoin:round;width:14px;height:14px}.rv-thread{border-top:1px solid var(--border);padding:8px 10px;font-size:12.5px}.rv-msg{margin-bottom:6px}.rv-who{color:var(--muted);font-size:11px;display:block}.rv-who.is-agent{color:var(--accent)}.rv-new{border:1px solid var(--accent);color:var(--accent);vertical-align:middle;border-radius:8px;margin-left:6px;padding:0 5px;font-size:10px;line-height:14px;display:inline-block}.rv-msg.is-unread .rv-msg-body{border-left:2px solid var(--accent);padding-left:6px}.rv-msg-body.is-tool{color:var(--muted);font-style:italic}.rv-tf{color:var(--muted);justify-content:space-between;align-items:center;gap:8px;font-size:12px;display:flex}.rv-tag{border:1px solid var(--warn);color:var(--warn);border-radius:9px;margin-right:auto;padding:0 6px;font-size:10.5px;line-height:15px}.rv-compose{border-top:1px solid var(--border);padding:8px 10px}.rv-inote-box .rv-compose{border:1px solid var(--border);border-radius:6px}.rv-compose-head{align-items:baseline;gap:8px;margin:0 0 4px;display:flex}.rv-compose textarea,.rv-rdialog textarea,.rv-aclose textarea{box-sizing:border-box;border:1px solid var(--border);background:var(--sunken);width:100%;color:var(--fg);font:inherit;resize:vertical;border-radius:6px;padding:6px 8px;font-size:12.5px}.rv-compose-acts{gap:8px;margin:6px 0 0;display:flex}.rv-editing{z-index:7;border:1px solid var(--border);background:var(--panel);width:360px;box-shadow:0 10px 24px var(--rv-shadow);border-radius:10px;position:absolute;bottom:18px;right:18px}.rv-send{z-index:6;border:1px solid var(--border);background:var(--panel);box-shadow:0 10px 24px var(--rv-shadow);border-radius:17px;font-size:12px;position:absolute;bottom:18px;right:40px}.rv-send.is-open{border-radius:10px;width:360px}.rv-sendpill{all:unset;box-sizing:border-box;width:100%;color:var(--fg);cursor:pointer;font:inherit;white-space:nowrap;align-items:center;gap:8px;padding:7px 14px;font-weight:600;display:flex}.rv-n{background:var(--accent);color:var(--rv-btn-text);border-radius:999px;padding:0 6px;font-size:11px;line-height:16px}.rv-send-head{border-bottom:1px solid var(--border);margin:0;padding:8px 12px;font-size:13px;font-weight:600}.rv-si{border-bottom:1px solid var(--border);grid-template-columns:1fr auto;gap:1px 8px;padding:7px 12px;display:grid}.rv-si b,.rv-si .rv-f,.rv-si .rv-q{grid-column:1;min-width:0}.rv-si b{font-size:11.5px}.rv-si .rv-f{color:var(--muted);font-family:ui-monospace,Menlo,monospace;font-size:11px}.rv-si .rv-q:before{content:"“"}.rv-si .rv-q:after{content:"”"}.rv-si-ctl{grid-area:1/2/4;align-self:start;gap:4px;display:flex}.rv-si-ctl button{all:unset;width:20px;height:20px;color:var(--muted);cursor:pointer;font:inherit;border-radius:4px;justify-content:center;align-items:center;font-size:12px;display:inline-flex}.rv-si-ctl button:hover{background:var(--sunken);color:var(--fg)}.rv-send-foot{margin:0;padding:10px 12px}.rv-send-foot .rv-btn{width:100%;padding:6px 10px}.rv-send-foot small{color:var(--muted);text-align:center;margin-top:6px;font-size:11px;display:block}.rv-banner{border-bottom:1px solid var(--border);background:var(--rv-warn-bg);align-items:center;gap:10px;padding:7px 12px;font-size:13px;display:flex}.rv-banner b{color:var(--warn);white-space:nowrap}.rv-banner.is-merged{background:var(--rv-accent-bg)}.rv-banner.is-merged b{color:var(--accent)}.rv-hunk.is-dim,.rv-gcard.is-dim{opacity:.72}.rv-adialog{width:620px;max-width:100%}.rv-adialog-head{justify-content:space-between;align-items:center;gap:12px;font-size:14px;display:flex}.rv-adialog-x{font-size:18px;line-height:1}.rv-adialog .dialog-body{flex-direction:column;gap:14px;display:flex}.rv-asign{grid-template-columns:1fr 1fr;gap:14px;display:grid}.rv-adialog-acts{align-items:center}.rv-adialog-acts .rv-btn{width:auto}.rv-left{border:1px solid var(--warn);background:var(--rv-warn-bg);border-radius:8px;margin:0;padding:10px 14px}.rv-left.is-clean{border-color:var(--ok);background:var(--rv-ok-bg);font-size:13px}.rv-left h3{color:var(--warn);align-items:center;gap:8px;margin:0 0 6px;font-size:13px;font-weight:600;display:flex}.rv-left ul{margin:0;padding:0;list-style:none}.rv-left li{align-items:center;gap:8px;padding:3px 0;font-size:13px;display:flex}.rv-left li b{text-align:right;font-variant-numeric:tabular-nums;min-width:34px}.rv-left li .rv-link{white-space:nowrap;margin-left:auto;font-size:12px}.rv-left-ack{border-top:1px solid var(--warn);align-items:flex-start;gap:9px;margin-top:10px;padding-top:10px;font-size:13px;display:flex}.rv-left-ack input{margin-top:3px}.rv-left-mark{border:1px solid var(--warn);background:var(--rv-warn-bg);width:16px;height:16px;color:var(--warn);cursor:default;border-radius:50%;flex:none;justify-content:center;align-items:center;font-size:11px;font-weight:700;line-height:1;display:inline-flex;position:relative}.rv-left-mark.is-plain{border-color:var(--muted);width:14px;height:14px;color:var(--muted);vertical-align:-3px;background:0 0;margin-left:6px;font-size:10px}.rv-left h3 .rv-left-mark{cursor:default}.rv-tip{width:280px;box-shadow:0 10px 30px var(--rv-shadow);border-radius:8px;padding:10px 12px}.rv-tip b{color:var(--warn);margin-bottom:4px;display:block}.rv-tip.is-plain b{color:var(--fg)}.rv-tip ul{margin:0;padding-left:16px}.rv-tip li{margin:2px 0}.rv-tip small{color:var(--muted);margin-top:6px;display:block}.rv-abadge{background:var(--rv-warn-bg);min-width:16px;color:var(--warn);text-align:center;border-radius:9px;margin-left:6px;padding:0 5px;font-size:11px;line-height:16px;display:inline-block}.rv-abadge.is-warn{border-radius:50%;width:16px;padding:0;font-weight:700}.rv-ameta{grid-template-columns:1fr 1fr;gap:8px 18px;min-width:0;display:grid}.rv-ameta>div{border-bottom:1px dashed var(--border);justify-content:space-between;gap:12px;padding-bottom:3px;display:flex}.rv-ameta .rv-k{color:var(--muted);font-size:12px}.rv-ameta .rv-v{text-align:right;overflow-wrap:anywhere;font-size:13px}.rv-ameta .rv-v.rv-mono{font-size:12px}.rv-aact{flex-direction:column;gap:16px;min-width:0;margin:0;display:flex}.rv-field{flex-direction:column;gap:6px;margin:0;display:flex}.rv-field label,.rv-field .rv-label{color:var(--muted);font-size:12px}.rv-field label small,.rv-field .rv-label small{margin-left:4px;font-size:10.5px}.rv-field input{border:1px solid var(--border);background:var(--deep);width:100%;color:var(--fg);font:inherit;border-radius:6px;padding:5px 8px}.rv-sig{border:1px solid var(--border);background:var(--deep);border-radius:6px;min-height:80px;display:block;position:relative}.rv-sig canvas{touch-action:none;cursor:crosshair;width:100%;height:80px;display:block}.rv-sig .rv-link{font-size:10.5px;position:absolute;bottom:3px;right:6px}.rv-btn.is-ok{border-color:var(--ok);background:var(--rv-ok-bg);color:var(--fg);font-weight:600}.rv-btn.is-warn{border-color:var(--warn);background:var(--rv-warn-bg);color:var(--fg);font-weight:600}.rv-btn.is-quiet{border:1px dashed var(--border);color:var(--muted);background:0 0;font-weight:400}.rv-btn.is-quiet:hover,.rv-btn.is-quiet:focus-visible{background:var(--panel);color:var(--fg);border-style:solid}.rv-rdialog{max-width:560px}.rv-rdialog .dialog-body p{margin:0 0 12px;font-size:13px;line-height:1.5}.rv-rgoes{margin:0 0 14px;font-size:13px}.rv-rgoes h4{color:var(--muted);letter-spacing:.05em;text-transform:uppercase;margin:0 0 4px;font-size:11px;font-weight:600}.rv-rgoes ul{margin:0 0 12px;padding-left:18px;line-height:1.55}.rv-rgoes ul:last-child{margin-bottom:0}.rv-rdialog label{color:var(--muted);margin-bottom:6px;font-size:12px;display:block}.rv-rdialog textarea{min-height:84px}.rv-rdialog .dialog-acts{justify-content:flex-end;gap:8px;display:flex}.rv-aclose{flex-direction:column;align-items:center;gap:4px;display:flex}.rv-aclose textarea{background:var(--deep)}.rv-aclose-acts{gap:8px;display:flex}.rv-adialog-acts .rv-aclose{align-items:flex-start}.rv-ended{border-bottom:1px solid var(--border);background:var(--panel);color:var(--muted);white-space:nowrap;align-items:center;gap:16px;padding:6px 12px;font-size:12px;display:flex}.rv-ended b{color:var(--fg);font-weight:600}.rv-ended-how,.rv-ended .rv-left-mark,.rv-ended .rv-btn{flex:none}.rv-ended img{object-fit:contain;flex:none;width:96px;height:26px;display:block}.rv-ended-fact,.rv-ended .rv-reason{text-overflow:ellipsis;min-width:0;overflow:hidden}
@@ -1 +1 @@
1
- import{A as e,D as t,T as n,b as r}from"./api-BBDf_rzz.js";var i=t();function a(e){let t=e.theme===`dark`?`Light theme`:`Dark theme`,a=e.kept?t:`${t} - there is no session to keep it in`;return(0,i.jsxs)(`button`,{type:`button`,className:`theme-toggle`,title:a,disabled:!e.kept,onClick:e.onToggle,children:[e.theme===`dark`?(0,i.jsx)(n,{size:13}):(0,i.jsx)(r,{size:13}),(0,i.jsx)(`span`,{className:`visually-hidden`,children:a})]})}var o=e(),s=`(prefers-color-scheme: light)`;function c(){return typeof matchMedia==`function`&&matchMedia(s).matches?`light`:`dark`}function l(e){let[t,n]=(0,o.useState)(null),[r,i]=(0,o.useState)(c),[a,l]=(0,o.useState)(!0);(0,o.useEffect)(()=>{if(typeof matchMedia!=`function`)return;let e=matchMedia(s),t=()=>i(e.matches?`light`:`dark`);return e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)},[]),(0,o.useEffect)(()=>e.onSession(e=>{n(e.theme),l(e.sid!==null)}),[e.onSession]);let u=t??r;return{theme:u,kept:a,toggle:()=>void e.askTheme(u===`dark`?`light`:`dark`)}}var u=32*1024*1024,d=new Set([`md`,`markdown`,`mdown`,`mkd`]),f=new Set([`html`,`htm`]),p=new Set([`png`,`jpg`,`jpeg`,`gif`,`webp`,`svg`,`avif`,`bmp`,`ico`]),m=new Set(`txt text log json yaml yml toml ini cfg conf csv tsv xml css scss js jsx mjs cjs ts tsx py rb go rs java kt swift c h cpp hpp sh bash zsh fish sql graphql gql env diff patch lock gitignore editorconfig`.split(` `));function h(e){let t=e.slice(e.lastIndexOf(`/`)+1).slice(1).match(/\.([^.]+)$/);return t?t[1].toLowerCase():``}function g(e,t){if(!t||/^[a-zA-Z][a-zA-Z0-9+.-]*:/.test(t)||t.startsWith(`#`)||t.startsWith(`/`)||t.startsWith(`//`))return null;let n=t.split(/[#?]/)[0];if(!n)return null;let r=e?e.split(`/`).filter(Boolean):[];for(let e of n.split(`/`))if(!(e===``||e===`.`)){if(e===`..`){if(r.length===0)return null;r.pop();continue}r.push(e)}return r.join(`/`)}function _(e){try{let t=new URL(e);return t.protocol===`http:`||t.protocol===`https:`?t.href:null}catch{return null}}function v(e){let t=h(e);return d.has(t)?`markdown`:f.has(t)?`html`:p.has(t)?`image`:m.has(t)||!t?`text`:`binary`}export{l as a,g as i,_ as n,a as o,v as r,u as t};
1
+ import{A as e,D as t,T as n,b as r}from"./api-CguEsvNp.js";var i=t();function a(e){let t=e.theme===`dark`?`Light theme`:`Dark theme`,a=e.kept?t:`${t} - there is no session to keep it in`;return(0,i.jsxs)(`button`,{type:`button`,className:`theme-toggle`,title:a,disabled:!e.kept,onClick:e.onToggle,children:[e.theme===`dark`?(0,i.jsx)(n,{size:13}):(0,i.jsx)(r,{size:13}),(0,i.jsx)(`span`,{className:`visually-hidden`,children:a})]})}var o=e(),s=`(prefers-color-scheme: light)`;function c(){return typeof matchMedia==`function`&&matchMedia(s).matches?`light`:`dark`}function l(e){let[t,n]=(0,o.useState)(null),[r,i]=(0,o.useState)(c),[a,l]=(0,o.useState)(!0);(0,o.useEffect)(()=>{if(typeof matchMedia!=`function`)return;let e=matchMedia(s),t=()=>i(e.matches?`light`:`dark`);return e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)},[]),(0,o.useEffect)(()=>e.onSession(e=>{n(e.theme),l(e.sid!==null)}),[e.onSession]);let u=t??r;return{theme:u,kept:a,toggle:()=>void e.askTheme(u===`dark`?`light`:`dark`)}}var u=32*1024*1024,d=new Set([`md`,`markdown`,`mdown`,`mkd`]),f=new Set([`html`,`htm`]),p=new Set([`png`,`jpg`,`jpeg`,`gif`,`webp`,`svg`,`avif`,`bmp`,`ico`]),m=new Set(`txt text log json yaml yml toml ini cfg conf csv tsv xml css scss js jsx mjs cjs ts tsx py rb go rs java kt swift c h cpp hpp sh bash zsh fish sql graphql gql env diff patch lock gitignore editorconfig`.split(` `));function h(e){let t=e.slice(e.lastIndexOf(`/`)+1).slice(1).match(/\.([^.]+)$/);return t?t[1].toLowerCase():``}function g(e,t){if(!t||/^[a-zA-Z][a-zA-Z0-9+.-]*:/.test(t)||t.startsWith(`#`)||t.startsWith(`/`)||t.startsWith(`//`))return null;let n=t.split(/[#?]/)[0];if(!n)return null;let r=e?e.split(`/`).filter(Boolean):[];for(let e of n.split(`/`))if(!(e===``||e===`.`)){if(e===`..`){if(r.length===0)return null;r.pop();continue}r.push(e)}return r.join(`/`)}function _(e){try{let t=new URL(e);return t.protocol===`http:`||t.protocol===`https:`?t.href:null}catch{return null}}function v(e){let t=h(e);return d.has(t)?`markdown`:f.has(t)?`html`:p.has(t)?`image`:m.has(t)||!t?`text`:`binary`}function y(e,t,n){let r=t.trim().toLowerCase();return r===``?e:e.filter(e=>n(e).toLowerCase().includes(r))}export{g as a,v as i,u as n,l as o,_ as r,a as s,y as t};
@@ -0,0 +1,13 @@
1
+ import{A as e,D as t,E as n,O as r,S as i,_ as a,a as o,c as s,d as c,f as l,g as u,h as d,i as f,l as p,m,n as h,o as g,p as _,t as ee,u as v,v as y,w as b,x}from"./api-CguEsvNp.js";import{a as S,o as te,r as C,s as ne,t as w}from"./search-DgFnnu-J.js";var T=e(),re=r();function E(e){let t=e.replace(/\r\n?/g,`
2
+ `).trim(),n=5381;for(let e=0;e<t.length;e++)n=(n*33^t.charCodeAt(e))>>>0;return n.toString(36)}function ie(e,t){return t?.readHash?t.readHash===e?{read:!0,changed:!1}:{read:!1,changed:!0}:{read:!1,changed:!1}}function ae(e){return e===`markdown`||e===`text`}function D(e){let t=[],n=[];if(e.kind===`markdown`&&typeof e.text==`string`)for(let r of v(e.text)){let i=E(r.heading?`## ${r.heading}\n${r.body}`:r.body);t.push({heading:r.heading,body:r.body,hash:i}),n.push(c(e.path,r.heading))}else{let r=e.text,i=E(typeof r==`string`?r:e.fingerprint??e.path);t.push({heading:null,body:typeof r==`string`?r:``,hash:i}),n.push(c(e.path,null))}let r=g(n);return t.map((e,t)=>({...e,id:r[t]}))}function oe(e,t,n){let r=c(t,n);return e.find(e=>e.id===r)??null}var se=600;function ce(e,t){let[n,r]=(0,T.useState)(t.empty),[i,a]=(0,T.useState)(null),o=(0,T.useRef)(t);o.current=t;let s=(0,T.useRef)(n),c=(0,T.useRef)(null),l=(0,T.useRef)(null),u=(0,T.useRef)(!1),d=(0,T.useRef)(0),f=(0,T.useRef)(0),p=(0,T.useRef)(!1),m=(0,T.useCallback)(e=>{s.current=e,r(e)},[]),h=(0,T.useCallback)(()=>{if(e===null)return;let t=e,n=d.current;o.current.get(t).then(e=>{if(d.current===n){if(f.current>0||l.current!==null){p.current=!0;return}u.current=!0,m(e),a(null)}}).catch(()=>{d.current===n&&(u.current=!1,a(o.current.whenUnreadable))})},[e,m]),g=(0,T.useCallback)(()=>{f.current>0||!p.current||(p.current=!1,h())},[h]),_=(0,T.useCallback)(t=>{if(e===null||!u.current||o.current.persist===!1){g();return}let n=d.current;f.current+=1,o.current.put(e,t).then(()=>a(null),()=>a(o.current.whenUnwritable)).finally(()=>{d.current===n&&(--f.current,g())})},[e,g]);return(0,T.useEffect)(()=>{d.current+=1,u.current=!1,f.current=0,p.current=!1,m(o.current.empty()),a(null),h()},[h,m]),(0,T.useEffect)(()=>()=>{c.current&&clearTimeout(c.current),l.current&&_(l.current),l.current=null,c.current=null},[_]),{value:n,update:(0,T.useCallback)((e,t=!1)=>{let n=e(s.current);if(n!==s.current){if(m(n),c.current&&clearTimeout(c.current),c.current=null,t){l.current=null,_(n);return}l.current=n,c.current=setTimeout(()=>{c.current=null;let e=l.current;l.current=null,e&&_(e)},se)}},[m,_]),reload:h,failure:i}}var O=t();function le(e){if(e===null)return[];let t=[],n=e.protocol.filter(e=>e.status!==`done`).length;n>0&&t.push(`${n} ${n===1?`stage`:`stages`} not done`);let r=e.phases.filter(e=>e.status!==`done`).length;r>0&&t.push(`${r} ${r===1?`phase`:`phases`} not done`);let i=e.awaiting.length;return i>0&&t.push(`${i} ${i===1?`thing`:`things`} waiting for an answer`),t}function ue(e){let t=le(e.state);return(0,O.jsx)(`div`,{className:`dialog-shade`,children:(0,O.jsxs)(`div`,{className:`dialog`,role:`dialog`,"aria-modal":`true`,"aria-label":`Archive this spec`,children:[(0,O.jsx)(`h2`,{className:`rail-head`,children:`Archive this spec`}),(0,O.jsxs)(`div`,{className:`dialog-body`,children:[(0,O.jsx)(`p`,{className:`rail-fact muted`,children:`It moves to:`}),(0,O.jsx)(`p`,{className:`archive-target`,children:e.filed}),t.length===0?(0,O.jsx)(`p`,{className:`rail-fact muted`,children:`Nothing is left open.`}):(0,O.jsxs)(O.Fragment,{children:[(0,O.jsxs)(`p`,{className:`rail-fact`,children:[`Still open in `,e.name,`:`]}),(0,O.jsx)(`ul`,{className:`archive-open`,children:t.map(e=>(0,O.jsx)(`li`,{children:e},e))})]}),(0,O.jsx)(`p`,{className:`rail-fact muted`,children:`The tool writes the sign-off and moves the directory. It deletes nothing.`})]}),e.failure!==null&&(0,O.jsx)(`p`,{className:`notice notice-failure`,children:e.failure}),(0,O.jsxs)(`div`,{className:`dialog-acts`,children:[(0,O.jsx)(`button`,{type:`button`,onClick:e.onCancel,disabled:e.working,children:`Cancel`}),(0,O.jsx)(`button`,{type:`button`,className:`send`,onClick:e.onArchive,disabled:e.working,children:e.working?`Archiving…`:`Archive`})]})]})})}var k=new Set(`address article aside audio blockquote br button canvas details div dl dd dt fieldset figcaption figure footer form h1 h2 h3 h4 h5 h6 header hr iframe img input label li main nav ol p picture pre section select span style summary svg table tbody td textarea tfoot th thead tr ul video`.split(` `)),de=new Set(`br hr img input source track wbr col`.split(` `)),fe=/^\s{0,3}(#{1,6})\s+(.*?)\s*#*\s*$/,A=/^(\s*)([-*+]|\d{1,9}[.)])(\s+)(.*)$/,j=/^\s{0,3}([-*_])\s*(?:\1\s*){2,}$/,pe=/^\s{0,3}\|?\s*:?-{1,}:?\s*(\|\s*:?-{1,}:?\s*)*\|?\s*$/;function M(e){return e.replace(/&/g,`&amp;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`)}function me(e){let t=e.match(/^\s{0,3}<([a-zA-Z][a-zA-Z0-9-]*)(?=[\s/>])/);if(!t)return null;let n=t[1].toLowerCase();return k.has(n)?n:null}function N(e){let t=M(e),n=[];t=t.replace(/(`+)([\s\S]*?)\1/g,(e,t,r)=>(n.push(r.replace(/^ (.*) $/,`$1`)),`\uE000c${n.length-1}\uE000`));let r=e=>e.replace(/"/g,`&quot;`);return t=t.replace(/!\[([^\]]*)\]\(([^)\s]+)(?:\s+"[^)]*")?\)/g,(e,t,n)=>`<img alt="${r(t)}" src="${r(n)}">`),t=t.replace(/\[([^\]]+)\]\(([^)\s]+)(?:\s+"[^)]*")?\)/g,(e,t,n)=>`<a href="${r(n)}">${t}</a>`),t=t.replace(/&lt;((?:https?|mailto):[^\s&]+)&gt;/g,`<a href="$1">$1</a>`),t=t.replace(/\*\*(?!\s)([\s\S]+?)(?<!\s)\*\*/g,`<strong>$1</strong>`),t=t.replace(/(^|[^\w\\])__(?!\s)([\s\S]+?)(?<!\s)__(?!\w)/g,`$1<strong>$2</strong>`),t=t.replace(/(^|[^\w*\\])\*(?!\s)([^*\n]+?)(?<!\s)\*(?!\w)/g,`$1<em>$2</em>`),t=t.replace(/(^|[^\w_\\])_(?!\s)([^_\n]+?)(?<!\s)_(?!\w)/g,`$1<em>$2</em>`),t=t.replace(/~~(?!\s)([\s\S]+?)(?<!\s)~~/g,`<del>$1</del>`),t=t.replace(/\uE000c(\d+)\uE000/g,(e,t)=>`<code>${n[+t]}</code>`),t}function he(e){return!e.trim()||o.test(e)||fe.test(e)||j.test(e)||A.test(e)||/^\s{0,3}>/.test(e)||me(e)!==null||/^\s{0,3}<!--/.test(e)}function ge(e){let t=e.replace(/\r\n?/g,`
3
+ `).split(`
4
+ `),n=[],r=0;for(;r<t.length;){let e=t[r];if(!e.trim()){r++;continue}let i=e.match(o);if(i){let e=i[2],a=i[3].trim().split(/\s+/)[0],o=[];for(r++;r<t.length;){let n=t[r].trim();if(n.startsWith(e[0].repeat(e.length))&&/^(`+|~+)$/.test(n)){r++;break}o.push(t[r]),r++}let s=a?` class="language-${M(a)}"`:``;n.push(`<pre><code${s}>${M(o.join(`
5
+ `))}</code></pre>`);continue}if(/^\s{0,3}<!--/.test(e)){for(;r<t.length&&!t[r].includes(`-->`);)r++;r++;continue}let a=me(e);if(a){let i=[t[r]];if(de.has(a)||/\/>\s*$/.test(e)||e.includes(`</${a}>`))r++;else{let e=1;for(r++;r<t.length&&e>0;){let n=(t[r].match(RegExp(`<${a}(?=[\\s/>])`,`gi`))||[]).length,o=(t[r].match(RegExp(`</${a}\\s*>`,`gi`))||[]).length;e+=n-o,i.push(t[r]),r++}}n.push(i.join(`
6
+ `));continue}let s=e.match(fe);if(s){let e=s[1].length;n.push(`<h${e}>${N(s[2])}</h${e}>`),r++;continue}if(j.test(e)){n.push(`<hr>`),r++;continue}if(/^\s{0,3}>/.test(e)){let e=[];for(;r<t.length&&(/^\s{0,3}>/.test(t[r])||t[r].trim()&&e.length>0&&!he(t[r]));)e.push(t[r].replace(/^\s{0,3}>\s?/,``)),r++;n.push(`<blockquote>${ge(e.join(`
7
+ `))}</blockquote>`);continue}if(e.includes(`|`)&&r+1<t.length&&pe.test(t[r+1])&&t[r+1].includes(`-`)){let e=e=>{let t=e.trim();return t.startsWith(`|`)&&(t=t.slice(1)),t.endsWith(`|`)&&!t.endsWith(`\\|`)&&(t=t.slice(0,-1)),t.split(/(?<!\\)\|/).map(e=>e.trim().replace(/\\\|/g,`|`))},i=e(t[r]),a=e(t[r+1]).map(e=>e.startsWith(`:`)&&e.endsWith(`:`)?`center`:e.endsWith(`:`)?`right`:e.startsWith(`:`)?`left`:``),o=e=>a[e]?` class="cell-${a[e]}"`:``,s=[];for(r+=2;r<t.length&&t[r].trim()&&t[r].includes(`|`);)s.push(e(t[r])),r++;n.push(`<table><thead><tr>${i.map((e,t)=>`<th${o(t)}>${N(e)}</th>`).join(``)}</tr></thead><tbody>${s.map(e=>`<tr>${e.map((e,t)=>`<td${o(t)}>${N(e)}</td>`).join(``)}</tr>`).join(``)}</tbody></table>`);continue}if(A.test(e)){let[e,i]=_e(t,r);n.push(e),r=i;continue}let c=[];for(;r<t.length&&!he(t[r]);)c.push(t[r].replace(/\s+$/,``)),r++;n.push(`<p>${N(c.join(`
8
+ `)).replace(/\n/g,`<br>
9
+ `)}</p>`)}return n.join(`
10
+ `)}function _e(e,t){let n=e[t].match(A);if(!n)return[``,t+1];let r=n[1].length,i=/\d/.test(n[2]),a=[],o=t,s=null;for(;o<e.length;){let t=e[o];if(!t.trim()){let t=o+1;for(;t<e.length&&!e[t].trim();)t++;if(t>=e.length)break;let n=e[t].match(A),a=e[t].match(/^\s*/)[0].length,c=n!==null&&/\d/.test(n[2])===i;if(s&&(c&&a>=r||!n&&a>r)){s.push(``),o=t;continue}break}let n=t.match(A),c=t.match(/^\s*/)[0].length;if(n&&c<=r){if(/\d/.test(n[2])!==i)break;s=[n[4]],a.push({lines:s,offset:n[1].length+n[2].length+n[3].length}),o++;continue}if(c>r&&s){s.push(t.slice(Math.min(c,a[a.length-1].offset))),o++;continue}break}let c=a.map(e=>{let t=e.lines.join(`
11
+ `),n=``,r=``,i=t.match(/^\[([ xX])\]\s+([\s\S]*)$/);i&&(n=` class="task"`,r=`<span class="task-box${i[1]===` `?``:` is-done`}"></span>`,t=i[2]);let a=ge(t),o=a.match(/^<p>([\s\S]*?)<\/p>([\s\S]*)$/);return o&&!o[1].includes(`<p>`)&&(a=o[1]+o[2]),`<li${n}>${r}${a}</li>`}).join(`
12
+ `);return[(i?`<ol>`:`<ul>`)+c+(i?`</ol>`:`</ul>`),o]}var ve=new Set(`p br hr span div a em strong b i u s del ins code pre kbd blockquote ul ol li dl dt dd h1 h2 h3 h4 h5 h6 table thead tbody tr th td caption img details summary figure figcaption sup sub small mark`.split(` `)),ye=new Set([`title`,`class`]),be={a:new Set([`href`]),img:new Set([`src`,`alt`,`width`,`height`]),ol:new Set([`start`]),details:new Set([`open`]),th:new Set([`colspan`,`rowspan`]),td:new Set([`colspan`,`rowspan`])},xe=new Set([`script`,`style`,`textarea`,`title`,`xmp`,`noembed`,`noframes`,`noscript`,`template`]),Se={href:`a`,src:`img`},Ce=new Set([`http:`,`https:`,`mailto:`]);function P(e){let t=e.trim();if(t===``)return!1;let n;try{n=new URL(t)}catch{return!0}return Ce.has(n.protocol)}function F(e,t){return t.includes(`:`)?!1:ye.has(t)?!0:be[e]?.has(t)??!1}function I(e){for(let t of[...e.children])I(t);for(let t of[...e.children]){let e=t.tagName.toLowerCase();if(!ve.has(e)){xe.has(e)?t.remove():t.replaceWith(...t.childNodes);continue}for(let n of[...t.attributes]){let r=n.name.toLowerCase();if(!F(e,r)){t.removeAttribute(n.name);continue}Se[r]===e&&!P(n.value)&&t.removeAttribute(n.name)}}return e}function we(e,t,n={}){let r=new DOMParser().parseFromString(ge(t),`text/html`);I(r.body),n.imageUrl&&Te(r.body,n.imageUrl);let i=e.ownerDocument;e.replaceChildren(...[...r.body.childNodes].map(e=>i.adoptNode(e)))}function Te(e,t){for(let n of e.querySelectorAll(`img`)){let e=n.getAttribute(`src`);if(e===null)continue;let r=t(e);r!==null&&n.setAttribute(`src`,r)}}function Ee({source:e,imageUrl:t,className:n}){let r=(0,T.useRef)(null);return(0,T.useEffect)(()=>{r.current&&we(r.current,e,t?{imageUrl:t}:{})},[e,t]),(0,O.jsx)(`div`,{className:n?`prose ${n}`:`prose`,ref:r})}function De(e){if(Oe(e)){if(e.kind===`execution`)return{kind:`execution`};if(e.kind===`checkpoint`&&typeof e.after==`string`&&e.after!==``)return{kind:`checkpoint`,after:e.after}}return{kind:`spec`}}var Oe=e=>typeof e==`object`&&!!e&&!Array.isArray(e),L=(e,t=``)=>typeof e==`string`?e:t;function ke(e){let t=[];for(let n of Array.isArray(e)?e:[]){if(!Oe(n)||typeof n.id!=`string`)continue;let e=[];for(let t of Array.isArray(n.options)?n.options:[])!Oe(t)||typeof t.id!=`string`||e.push({id:t.id,said:L(t.said,t.id),...t.recommended===!0?{recommended:!0}:{}});t.push({id:n.id,ask:L(n.ask),options:e,multi:n.multi===!0,...typeof n.invite==`string`&&n.invite!==``?{invite:n.invite}:{}})}return t}function Ae(e){if(!Oe(e))return{kind:`gate`,asks:``,offer:null};if(e.kind===`decision`){let t=L(e.heading),n=ke(e.questions);return t!==``&&n.length===1?{kind:`decision`,heading:t,questions:n}:{kind:`gate`,asks:``,offer:null}}return e.kind===`round`||Array.isArray(e.questions)?{kind:`round`,questions:ke(e.questions)}:{kind:`gate`,asks:L(e.asks),offer:je(e.offer)}}function je(e){if(!Oe(e))return null;let t=L(e.said);return t===``?null:{said:t,preset:e.preset===!0}}function Me(e,t){return e.map(e=>{let n=t.get(e.id),r=n?.chosen??[],i=n?.said??``;return{question:e.id,chosen:r,said:i,answered:r.length>0||i.trim()!==``}})}var R=50,Ne=600,z={gate:`What should change?`,round:`Anything else?`,decision:`Your words`};function B(e){return e.split(`
13
+ `).find(e=>e.trim()!==``)?.trim()??e}function Pe(e){let[t,n]=(0,T.useState)(()=>e.draft?.given??new Map),[r,i]=(0,T.useState)(()=>e.draft?.said??``),a=e.onDraft;(0,T.useEffect)(()=>{a({given:t,said:r})},[t,r,a]);let o=(0,T.useRef)(null),s=(0,T.useRef)(null);(0,T.useEffect)(()=>{let t=e.summon??0;if(!e.settled||s.current===t)return;s.current=t;let n=()=>o.current?.scrollIntoView?.({block:`start`}),r=setTimeout(n,R),i=[o.current?.parentElement,o.current?.previousElementSibling].filter(e=>e instanceof Element),a=typeof ResizeObserver==`function`&&i.length>0?new ResizeObserver(n):null;for(let e of i)a?.observe(e);let c=setTimeout(()=>a?.disconnect(),Ne);return()=>{clearTimeout(r),clearTimeout(c),a?.disconnect()}},[e.settled,e.summon]);let c=e.ask.kind===`gate`?e.ask.offer:null,[l,u]=(0,T.useState)(c?.preset===!0),d=e.ask.kind===`gate`?[]:e.ask.questions,f=(t,n=[])=>e.onAnswer({outcome:t,said:r.trim(),questions:n,accepted:t===`approved`&&c!==null&&l}),p=()=>{let n=e.ask.kind===`decision`&&d[0]!==void 0?new Map(t).set(d[0].id,{chosen:t.get(d[0].id)?.chosen??[],said:r.trim()}):t;f(`answered`,Me(d,n))},m=(e,t,r)=>n(n=>{let i=new Map(n),a=i.get(e)??{chosen:[],said:``},o=r?a.chosen.includes(t)?a.chosen.filter(e=>e!==t):[...a.chosen,t]:[t];return i.set(e,{...a,chosen:o}),i}),h=(e,t)=>n(n=>{let r=new Map(n),i=r.get(e)??{chosen:[],said:``};return r.set(e,{...i,said:t}),r});return(0,O.jsxs)(`section`,{className:`ask`,"aria-label":e.title,ref:o,children:[(0,O.jsxs)(`div`,{className:`ask-head`,children:[(0,O.jsx)(`h2`,{children:e.title}),e.file!==``&&(0,O.jsxs)(`p`,{className:`ask-about`,children:[`about `,(0,O.jsx)(`b`,{children:e.file}),e.ask.kind===`decision`&&(0,O.jsxs)(O.Fragment,{children:[` › `,(0,O.jsx)(`b`,{children:e.ask.heading})]})]})]}),e.ask.kind===`gate`&&e.ask.asks!==``&&(0,O.jsx)(Ee,{className:`ask-asks`,source:e.ask.asks}),d.length>0&&(0,O.jsx)(`ol`,{className:`questions`,children:d.map(n=>(0,O.jsxs)(`li`,{children:[(0,O.jsx)(Ee,{className:`question-ask`,source:n.ask}),(0,O.jsx)(`ul`,{className:`choices`,children:n.options.map(e=>(0,O.jsx)(`li`,{className:e.recommended?`is-recommended`:void 0,children:(0,O.jsxs)(`label`,{children:[(0,O.jsx)(`input`,{type:n.multi?`checkbox`:`radio`,name:n.id,checked:t.get(n.id)?.chosen.includes(e.id)??!1,onChange:()=>m(n.id,e.id,n.multi)}),(0,O.jsxs)(`span`,{className:`choice-title`,children:[e.said,e.recommended&&(0,O.jsx)(`span`,{className:`choice-flag`,children:`recommended`})]})]})},e.id))}),e.ask.kind===`round`&&(0,O.jsx)(`textarea`,{className:`question-said`,value:t.get(n.id)?.said??``,placeholder:n.invite??`Your words`,"aria-label":`Anything to add about: ${B(n.ask)}`,onChange:e=>h(n.id,e.target.value)})]},n.id))}),(0,O.jsx)(`textarea`,{className:`field-dump`,value:r,placeholder:z[e.ask.kind],"aria-label":e.ask.kind===`decision`?`Your words`:`Anything else`,onChange:e=>i(e.target.value)}),c!==null&&(0,O.jsxs)(`label`,{className:`ask-offer`,children:[(0,O.jsx)(`input`,{type:`checkbox`,checked:l,onChange:e=>u(e.target.checked)}),(0,O.jsx)(`span`,{children:c.said})]}),e.failure!==null&&(0,O.jsx)(`p`,{className:`notice notice-failure`,children:e.failure}),e.asked!==null&&(0,O.jsxs)(`p`,{className:`ask-asked`,children:[`Asked in the terminal: “`,e.asked,`”. This is still waiting for your answer.`]}),(0,O.jsxs)(`div`,{className:`form-acts`,children:[(0,O.jsx)(`button`,{type:`button`,onClick:e.onDismiss,children:`Later`}),(0,O.jsx)(`button`,{type:`button`,className:`ask-question`,disabled:e.sending||r.trim()===``,title:`Send this to the agent in the terminal, and answer nothing`,onClick:()=>void e.onAsk(r.trim()).then(e=>{e&&i(``)}),children:`Ask`}),e.ask.kind===`gate`&&(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(`button`,{type:`button`,disabled:e.sending||r.trim()===``,onClick:()=>f(`changes`),children:`Request changes`}),(0,O.jsx)(`button`,{type:`button`,className:`send`,disabled:e.sending,onClick:()=>f(`approved`),children:`Approve`})]}),e.ask.kind!==`gate`&&(0,O.jsx)(`button`,{type:`button`,className:`send`,disabled:e.sending,onClick:p,children:e.sending?`Sending…`:`Submit`})]})]})}function V(){return`a-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,8)}`}function Fe(e,t,n=``){return{id:V(),unit:e.unit,file:e.file,heading:e.heading,kind:t,quote:e.quote,text:n}}function Ie(e){return e.quote?`“${Le(e.quote)}”`:e.heading?`${e.file} - ${e.heading}`:e.file||`this spec`}function Le(e,t=80){let n=e.replace(/\s+/g,` `).trim();return n.length<=t?n:`${n.slice(0,t-1)}…`}function Re(e){return e.filter(e=>e.kind===`remove`||e.text.trim()!==``)}function ze(e){return{queued:e.map(e=>e.id),comments:Re(e).map(e=>({unit:e.unit,file:e.file,heading:e.heading,kind:e.kind,quote:e.quote,text:e.text.trim(),assets:[]}))}}function Be(e){let t=Re(e);if(t.length===0)return``;let n=t.filter(e=>e.kind===`remove`).length,r=t.length-n,i=[];r>0&&i.push(`${r} ${r===1?`comment`:`comments`}`),n>0&&i.push(`${n} to remove`);let a=t[0];return`${i.join(`, `)} - first on ${Ie(a)}`}function Ve(){return{version:1,units:{},dismissed:[]}}function He(e){return{version:1,entry:e,annotations:[]}}var Ue=e=>typeof e==`object`&&!!e&&!Array.isArray(e),We=(e,t=``)=>typeof e==`string`?e:t;function H(e){let t;try{t=JSON.parse(e||`null`)}catch{return Ve()}if(!Ue(t)||t.version!==1)return Ve();let n=Ve();if(Ue(t.units))for(let[e,r]of Object.entries(t.units)){if(!Ue(r))continue;let t={};typeof r.readHash==`string`&&(t.readHash=r.readHash),typeof r.readAt==`string`&&(t.readAt=r.readAt),n.units[e]=t}return Array.isArray(t.dismissed)&&(n.dismissed=t.dismissed.filter(e=>typeof e==`string`)),n}function Ge(e,t){let n;try{n=JSON.parse(e||`null`)}catch{return He(t)}if(!Ue(n)||n.version!==1)return He(t);let r=[];if(Array.isArray(n.annotations))for(let e of n.annotations)!Ue(e)||typeof e.id!=`string`||typeof e.unit!=`string`||e.id===``||e.unit===``||r.push({id:e.id,unit:e.unit,file:We(e.file),heading:We(e.heading),kind:e.kind===`remove`?`remove`:`comment`,quote:We(e.quote),text:We(e.text)});return{version:1,entry:We(n.entry,t),annotations:r}}var Ke=`quality-review`,qe=[{id:`exploration`,title:`High-level exploration`,group:`discovery`,about:`We think the problem through together first - directions to take, risks, and what is still unclear.`},{id:`interview`,title:`Interview`,group:`discovery`,about:`I ask you focused questions until nothing important is left open.`},{id:`research`,title:`Research`,group:`discovery`,about:`I look outside your code - a library, a protocol, an algorithm, a subject area - and write up what I find.`},{id:`codebase-analysis`,title:`Codebase analysis`,group:`discovery`,about:`I read the parts of your code this work touches and note what shapes the design.`},{id:`technical-specs`,title:`Technical specs`,group:`deliverables`,about:`A written specification another agent can build from without asking you anything.`},{id:`ui-mocks`,title:`UI mocks`,group:`deliverables`,about:`Mock screens you open in your browser and comment on before anything is built.`},{id:`execution-plan`,title:`Execution plan`,group:`deliverables`,about:`The work split into phases, each with a goal and a way to tell it is done.`},{id:Ke,title:`Specs quality review`,group:`deliverables`,about:`Fresh helper agents review everything we wrote, and I fix what is plainly wrong and bring the judgment calls to you.`}],Je=[`exploration`,`ui-mocks`];function U(e){return qe.find(t=>t.id===e)??null}function Ye(e){return[...e].sort((e,t)=>e.startedAt===t.startedAt?0:e.startedAt?t.startedAt?e.startedAt<t.startedAt?-1:1:-1:1)}var W=`final`;function G(e,t){if(e===`final`)return W;let n=t.find(t=>t.id===e);return n===void 0?null:n.title}var Xe=[`consistency and completeness`,`repo rules`,`better ways to do this`],Ze=[{id:`per-phase`,said:`a commit per phase`},{id:`single`,said:`a single commit at the end`},{id:`none`,said:`no commits`}],Qe=[{id:`current`,said:`the current branch`},{id:`new`,said:`a new branch`}],$e=[{id:`none`,said:`none`},{id:`chosen`,said:`after chosen phases`},{id:`every`,said:`every phase`}];function K(e){return{commits:`per-phase`,branch:`current`,branchName:`spec/${e}`,pauses:`none`,pausePhases:[],checkpoints:[{after:W,why:`judges the finished work as a whole`,panel:[...Xe],chosen:!0}]}}function q(e,t=new Date){let{said:n,at:r}=e.activity;if(n===``||r===``||e.log.reduce((e,t)=>t.at>e?t.at:e,``)>r)return null;let i=Date.parse(r);return Number.isNaN(i)||t.getTime()-i>18e5?null:{said:n,at:r}}function et(e,t){return{version:1,name:e,created:t,status:`specifying`,protocol:[],modes:{imagination:!1},wish:{imagination:!1},stageSettings:{research:null},activity:{said:``,at:``},awaiting:[],phases:[],runRecommendations:null,runDecisions:null,reviews:[],approvals:[],log:[]}}var J=e=>typeof e==`object`&&!!e&&!Array.isArray(e),Y=(e,t=``)=>typeof e==`string`?e:t,X=(e,t,n)=>t.includes(e)?e:n,tt=[`specifying`,`ready`,`executing`,`complete`],nt=[`waiting`,`running`,`done`],rt=[`gate`,`round`,`protocol`],it=[`focused`,`named`,`broad`],at=Ze.map(e=>e.id),Z=Qe.map(e=>e.id),ot=$e.map(e=>e.id);function st(e){if(!J(e)||e.scope===void 0)return null;let t=X(e.scope,it,`focused`);return{scope:t,subject:t===`named`?ct(Y(e.subject)):``}}function ct(e,t=200){return e.replace(/\p{C}+/gu,` `).replace(/\s+/g,` `).trim().slice(0,t)}function lt(e){if(!J(e))return null;let t=[];for(let n of Array.isArray(e.checkpoints)?e.checkpoints:[]){if(!J(n))continue;let e=Array.isArray(n.panel)?n.panel.filter(e=>typeof e==`string`).map(e=>ct(e)):[];t.push({after:p(Y(n.after)),why:ct(Y(n.why)),panel:e,chosen:n.chosen!==!1&&e.length>0})}return{commits:X(e.commits,at,`per-phase`),branch:X(e.branch,Z,`current`),branchName:ct(Y(e.branchName)),pauses:X(e.pauses,ot,`none`),pausePhases:Array.isArray(e.pausePhases)?e.pausePhases.filter(e=>typeof e==`string`).map(e=>p(e)):[],checkpoints:t}}function ut(e){if(!J(e))return null;let t=lt(e);if(t===null)return null;let n={};if(J(e.pauseReasons))for(let[t,r]of Object.entries(e.pauseReasons)){if(typeof r!=`string`)continue;let e=ct(r);e!==``&&(n[p(t)]=e)}return{...t,pauseReasons:n,noPauseReason:ct(Y(e.noPauseReason))}}function dt(e,t=``,n=``){let r;try{r=JSON.parse(e||`null`)}catch{return et(t,n)}if(!J(r)||r.version!==1)return et(t,n);let i=et(Y(r.name,t),Y(r.created,n)),a=Y(r.status);if(tt.includes(a)&&(i.status=a),Array.isArray(r.protocol))for(let e of r.protocol){if(!J(e)||!U(Y(e.id)))continue;let t=Y(e.status);i.protocol.push({id:Y(e.id),status:nt.includes(t)?t:`waiting`,artifacts:Array.isArray(e.artifacts)?e.artifacts.filter(e=>typeof e==`string`):[],startedAt:Y(e.startedAt)})}if(J(r.modes)&&(i.modes.imagination=r.modes.imagination===!0),J(r.wish)&&(i.wish.imagination=r.wish.imagination===!0),J(r.stageSettings)&&(i.stageSettings={research:st(r.stageSettings.research)}),J(r.activity)&&(i.activity={said:Y(r.activity.said),at:Y(r.activity.at)}),Array.isArray(r.awaiting))for(let e of r.awaiting){if(!J(e)||!e.id)continue;let t=Y(e.kind);i.awaiting.push({id:Y(e.id),kind:rt.includes(t)?t:`round`,title:Y(e.title),file:Y(e.file),payload:Y(e.payload),declaredAt:Y(e.declaredAt)})}if(Array.isArray(r.phases))for(let e of r.phases){if(!J(e)||!e.id)continue;let t=Y(e.status);i.phases.push({id:Y(e.id),title:Y(e.title),status:nt.includes(t)?t:`waiting`})}i.runRecommendations=ut(r.runRecommendations);let o=lt(r.runDecisions);if(o!==null&&J(r.runDecisions)&&(i.runDecisions={...o,decidedAt:Y(r.runDecisions.decidedAt)}),Array.isArray(r.reviews))for(let e of r.reviews)!J(e)||typeof e.round!=`number`||i.reviews.push({round:e.round,verdict:Y(e.verdict),findings:typeof e.findings==`number`?e.findings:0,judgments:typeof e.judgments==`number`?e.judgments:0,source:De(e.source),at:Y(e.at)});if(Array.isArray(r.approvals))for(let e of r.approvals)!J(e)||!e.id||i.approvals.push({id:Y(e.id),at:Y(e.at),outcome:Y(e.outcome)});if(Array.isArray(r.log))for(let e of r.log)J(e)&&i.log.push({at:Y(e.at),said:Y(e.said)});return i}var Q=h(`specs`);Q.receive;var ft=Q.credentialsReady,pt=Q.onChange,mt=Q.onSession,ht=Q.openOutside,gt=Q.deliver,_t=Q.sayWaiting,vt=Q.listen;function yt(e){return Q.askTheme(e)}var bt=ee({prefix:`specs`,label:`Specs`,credentialsReady:ft});bt.keyHeader;var $=bt.ask;function xt(){return $(`dashboard`)}function St(e){return $(`entry?path=${encodeURIComponent(e)}`)}function Ct(e){return $(`archive?entry=${encodeURIComponent(e)}`,{method:`POST`})}function wt(e){return $(`file?path=${encodeURIComponent(e)}`)}async function Tt(e){let t=await $(`state?entry=${encodeURIComponent(e)}`);return H(JSON.stringify(t))}function Et(e,t){return $(`state?entry=${encodeURIComponent(e)}`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)})}async function Dt(e){let t=await $(`pending?entry=${encodeURIComponent(e)}`);return Ge(JSON.stringify(t),e).annotations}function Ot(e,t){return $(`pending?entry=${encodeURIComponent(e)}`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({...He(e),annotations:t})})}function kt(e){return $(`feedback?entry=${encodeURIComponent(e)}`)}function At(e,t){return $(`feedback?entry=${encodeURIComponent(e)}`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)})}async function jt(e){let t=await $(`protocol?entry=${encodeURIComponent(e)}`);return dt(JSON.stringify(t))}function Mt(e,t){return $(`round?entry=${encodeURIComponent(e)}&id=${encodeURIComponent(t)}`)}function Nt(e){return $(`intake`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)})}async function Pt(e,t){let n=await $(`confirm?entry=${encodeURIComponent(e)}`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)});return{state:dt(JSON.stringify(n.state)),change:n.change}}async function Ft(e,t){let n=await $(`decide?entry=${encodeURIComponent(e)}`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)});return dt(JSON.stringify(n))}function It(e,t,n){return $(`answer?entry=${encodeURIComponent(e)}&id=${encodeURIComponent(t)}`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(n)})}var Lt=bt.rawUrl;bt.fileUrl;var Rt=`archive`;function zt(e){let t=e=>String(e).padStart(2,`0`);return`${e.getFullYear()}-${t(e.getMonth()+1)}-${t(e.getDate())}`}function Bt(e,t){let n=e.split(`/`).pop()??e;return`${Rt}/${zt(t)}-${n}`}function Vt(e){let t=e.split(`/`).pop()??``;return/^\d{4}-\d{2}-\d{2}-/.test(t)?t.slice(0,10):``}var Ht=30,Ut=108,Wt=8,Gt=240;function Kt(e){let t=e.lastIndexOf(`/`);return t===-1?``:e.slice(0,t)}function qt({unit:e,state:t,name:n,onToggle:r}){let i=t?.read??!1;return(0,O.jsxs)(`button`,{type:`button`,className:`mark`,"aria-pressed":i,title:i?`Mark as unread`:`Mark as read`,onClick:()=>r(e),children:[`✓`,(0,O.jsxs)(`span`,{className:`visually-hidden`,children:[i?`Mark as unread`:`Mark as read`,`: `,n]})]})}function Jt({at:e,onPick:t,onDismiss:r}){return(0,O.jsxs)(`div`,{className:`annotate`,style:{top:e.top,left:e.left},children:[(0,O.jsxs)(`button`,{type:`button`,className:`annotate-drop`,title:`Ask for this to be removed`,onClick:()=>t(`remove`),children:[(0,O.jsx)(n,{}),(0,O.jsx)(`span`,{className:`visually-hidden`,children:`Ask for this to be removed`})]}),(0,O.jsxs)(`button`,{type:`button`,title:`Say something about this`,onClick:()=>t(`comment`),children:[(0,O.jsx)(d,{}),(0,O.jsx)(`span`,{className:`visually-hidden`,children:`Say something about this`})]}),(0,O.jsxs)(`button`,{type:`button`,className:`annotate-close`,title:`Dismiss`,onClick:r,children:[(0,O.jsx)(m,{}),(0,O.jsx)(`span`,{className:`visually-hidden`,children:`Dismiss`})]})]})}function Yt({at:e,onAdd:t,onDismiss:n}){let[r,i]=(0,T.useState)(``),a=(0,T.useRef)(null);return(0,T.useEffect)(()=>{let e=e=>{let t=e.target;t!==null&&a.current?.contains(t)===!0||n()},t=e=>{e.key===`Escape`&&n()};return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[n]),(0,O.jsxs)(`div`,{className:`annotate-composer`,style:{top:e.top,left:e.left},ref:a,children:[(0,O.jsx)(`p`,{className:`composer-target`,children:e.quote===``?e.name:`“${e.quote}”`}),(0,O.jsx)(`textarea`,{autoFocus:!0,value:r,placeholder:`What about it?`,"aria-label":`Your comment`,onChange:e=>i(e.target.value)}),(0,O.jsxs)(`div`,{className:`composer-acts`,children:[(0,O.jsx)(`button`,{type:`button`,className:`composer-cancel`,onClick:n,children:`Cancel`}),(0,O.jsx)(`button`,{type:`button`,className:`composer-add`,disabled:r.trim()===``,onClick:()=>t(r.trim()),children:`Add`})]})]})}function Xt(e){let{entry:t,file:n,units:r,text:i,marks:a,raw:o,landOn:c,onLanded:l,onCurrent:u,onOpen:f,onLeave:p}=e,m=Kt(n.path),h=(0,T.useRef)(null),g=(0,T.useCallback)(e=>{let n=S(m,e);return n===null?null:Lt(o,t?`${t}/${n}`:n)},[m,t,o]),_=r[0],ee=(0,T.useMemo)(()=>{let e=Lt(o,t?`${t}/${n.path}`:n.path);return _===void 0?e:`${e}?v=${encodeURIComponent(_.hash)}`},[t,n.path,o,_]),[v,y]=(0,T.useState)(null),[b,x]=(0,T.useState)(null),te=(0,T.useCallback)(()=>x(null),[]),ne=(0,T.useCallback)(e=>{let t=h.current,n=t===null?e.left:t.clientWidth+t.scrollLeft-Gt;x({...e,left:Math.max(0,Math.min(e.left,n))})},[]),w=`${e.reader}/${t}/${n.path}`,re=(0,T.useRef)(w);(0,T.useEffect)(()=>{re.current!==w&&(re.current=w,y(null),x(null))},[w]);let E=(0,T.useCallback)(e=>{let t=(e instanceof Element?e:e?.parentElement)?.closest?.(`[data-unit]`),n=t instanceof HTMLElement?t.dataset.unit:void 0;return r.find(e=>e.id===n)??null},[r]),ie=e.onAnnotate,ae=ie!==null,D=(0,T.useCallback)((e,t,r,i)=>{let a=h.current;if(!a||!ae)return;let o=a.getBoundingClientRect(),s=e.top-o.top+a.scrollTop,c=e.left-o.left+a.scrollLeft,l=s-a.scrollTop>=38;y({unit:t?.id??_?.id??``,file:n.path,heading:t?.heading??``,quote:r,name:i,top:l?s-Ht-Wt:s+e.height+Wt,left:Math.max(0,Math.min(c,a.clientWidth+a.scrollLeft-Ut))})},[ae,n.path,_]);(0,T.useEffect)(()=>{let e=h.current;if(!e||typeof IntersectionObserver!=`function`)return;let t=[...e.querySelectorAll(`[data-unit]`)];if(t.length===0)return;let n=new Map,r=new IntersectionObserver(e=>{for(let t of e)n.set(t.target.getAttribute(`data-unit`)??``,t);let t=[...n.values()].filter(e=>e.isIntersecting).sort((e,t)=>e.boundingClientRect.top-t.boundingClientRect.top)[0]?.target.getAttribute(`data-unit`);t&&u(t)},{root:e,rootMargin:`0px 0px -65% 0px`,threshold:0});for(let e of t)r.observe(e);return()=>r.disconnect()},[u,r]),(0,T.useEffect)(()=>{if(c===null)return;let e=[...h.current?.querySelectorAll(`[data-unit]`)??[]].find(e=>e.dataset.unit===c);e&&(e.scrollIntoView?.({block:`start`}),l())},[c,l,r]),(0,T.useEffect)(()=>{let e=h.current;if(!e)return;let t=t=>{if(t.target?.closest?.(`.annotate, .annotate-composer`))return;let n=document.getSelection(),r=n?.toString()??``;if(!n||n.isCollapsed||r.trim()===``){y(null);return}let i=n.anchorNode;if(!i||!e.contains(i))return;let a=n.getRangeAt(0).getBoundingClientRect();D(a,E(i),r,r)};return e.addEventListener(`mouseup`,t),()=>e.removeEventListener(`mouseup`,t)},[D,E]),(0,T.useEffect)(()=>{let e=h.current;if(!e)return;let t=e=>{let t=e.target;if(t instanceof HTMLImageElement){e.preventDefault(),D(t.getBoundingClientRect(),E(t),``,t.alt||n.name);return}let r=t?.closest?.(`a`);if(!r)return;let i=r.getAttribute(`href`);if(i===null)return;e.preventDefault();let[a,o=``]=i.split(`#`);if(a===``){f(n.path,o);return}let s=S(m,a);if(s!==null){f(s,o);return}let c=C(a);c!==null&&p(c)};return e.addEventListener(`click`,t),()=>e.removeEventListener(`click`,t)},[m,n.name,n.path,p,f,D,E]);let oe=e.failure===null&&!e.loading,se=r.filter(e=>a[e.id]?.read).length,ce=r.filter(e=>a[e.id]?.changed).length;return(0,O.jsxs)(`div`,{className:`doc`,ref:h,children:[v!==null&&ie!==null&&(0,O.jsx)(Jt,{at:v,onPick:e=>{e===`comment`?ne(v):ie(v,e),y(null),document.getSelection()?.removeAllRanges()},onDismiss:()=>y(null)}),b!==null&&ie!==null&&(0,O.jsx)(Yt,{at:b,onAdd:e=>{ie(b,`comment`,e),x(null)},onDismiss:te}),e.failure!==null&&(0,O.jsx)(`p`,{className:`notice notice-failure`,children:e.failure}),e.failure===null&&e.loading&&(0,O.jsxs)(`p`,{className:`notice`,children:[`Reading `,n.name,`…`]}),oe&&(0,O.jsxs)(`div`,{className:`doc-facts`,children:[(0,O.jsxs)(`span`,{children:[n.path,` · `,s(n.size)]}),r.length>0&&(0,O.jsxs)(`span`,{children:[`· `,se,` of `,r.length,` read`]}),ce>0&&(0,O.jsxs)(`span`,{className:`doc-changed`,children:[`· `,ce,` changed since you read `,ce===1?`it`:`them`]}),n.kind!==`markdown`&&_!==void 0&&(0,O.jsx)(qt,{unit:_,state:a[_.id],name:n.name,onToggle:e.onToggleRead}),ae&&(0,O.jsx)(`span`,{className:`doc-facts-acts`,children:(0,O.jsxs)(`button`,{type:`button`,className:`annotate-whole`,title:`Say something about this artifact`,onClick:e=>D(e.currentTarget.getBoundingClientRect(),_??null,``,n.name),children:[(0,O.jsx)(d,{size:13}),(0,O.jsx)(`span`,{className:`visually-hidden`,children:`Say something about this artifact`})]})})]}),oe&&n.kind===`markdown`&&r.map(t=>{let r=a[t.id];return(0,O.jsxs)(T.Fragment,{children:[(0,O.jsxs)(`section`,{"data-unit":t.id,className:`doc-section${r?.read?` is-read`:``}`,children:[(0,O.jsx)(`div`,{className:`sec-mark`,children:(0,O.jsx)(qt,{unit:t,state:r,name:t.heading??n.name,onToggle:e.onToggleRead})}),t.heading!==null&&(0,O.jsxs)(`h2`,{children:[t.heading,r?.changed&&(0,O.jsx)(`span`,{className:`sec-changed`,children:`changed since you read it`})]}),t.heading===null&&r?.changed&&(0,O.jsx)(`p`,{className:`sec-changed`,children:`changed since you read it`}),(0,O.jsx)(Ee,{source:t.body,imageUrl:g})]}),e.under?.unit===t.id&&e.under.node]},t.id)}),oe&&n.kind===`html`&&(0,O.jsx)(`iframe`,{className:`art-frame`,title:n.name,src:ee,sandbox:`allow-scripts allow-forms`,referrerPolicy:`no-referrer`}),oe&&n.kind===`image`&&(0,O.jsx)(`p`,{className:`art-image`,children:(0,O.jsx)(`img`,{src:ee,alt:n.name})}),oe&&n.kind===`text`&&(0,O.jsx)(`pre`,{className:`plain`,children:i??``}),oe&&n.kind===`binary`&&(0,O.jsxs)(`p`,{className:`notice`,children:[n.name,` is `,s(n.size),` of something this tool does not render. It is in the spec directory, where the agent beside you can read it.`]})]})}function Zt(e){let t=(0,T.useId)();return(0,O.jsxs)(`div`,{className:e.className??`run-field`,children:[(0,O.jsx)(`span`,{id:t,children:e.label}),(0,O.jsxs)(`div`,{className:`run-with`,children:[(0,O.jsx)(`select`,{"aria-labelledby":t,value:e.value,onChange:t=>e.onPick(t.target.value),children:e.options.map(e=>(0,O.jsx)(`option`,{value:e.id,children:e.said},e.id))}),e.children]})]})}function Qt(e){let t=K(e.slug),n=e.decided??e.recommended??t;return{...n,branchName:n.branchName||t.branchName}}var $t=0,en=()=>`k${++$t}`;function tn(e){return e.map(e=>({key:en(),after:e.after,why:e.why,chosen:e.chosen,panel:e.panel.map(e=>({key:en(),focus:e})),typing:``}))}function nn(e){return[...e.panel.map(e=>e.focus),e.typing].map(e=>e.trim()).filter(e=>e!==``)}function rn(e){return e.map(e=>({after:e.after,why:e.why,chosen:e.chosen,panel:nn(e)}))}function an(e){let[t]=(0,T.useState)(()=>Qt(e)),[n,r]=(0,T.useState)(t.commits),[a,o]=(0,T.useState)(t.branch),[s,c]=(0,T.useState)(t.branchName),[l,u]=(0,T.useState)(t.pauses),[d,f]=(0,T.useState)(t.pausePhases),[p,h]=(0,T.useState)(()=>tn(t.checkpoints)),g=e.decided!==null,_=g?null:e.recommended,ee=e.phases.filter(e=>e.status===`done`).length,v=e.phases.length>0,y=d.filter(t=>!e.phases.some(e=>e.id===t)),b=_?.pauses===`chosen`?_.pausePhases.map(t=>({id:t,place:G(t,e.phases)??t,said:Object.hasOwn(_.pauseReasons,t)?_.pauseReasons[t]:``})).filter(e=>e.said!==``):[],x=_?.pauses===`none`?_.noPauseReason:``,S=(l===`chosen`?y.length:0)+p.filter(t=>t.chosen&&G(t.after,e.phases)===null).length,te=(e,t)=>e.map(e=>e.id===t&&_!==null?{...e,said:`${e.said} (recommended)`}:e),C=(e,t)=>h(n=>n.map(n=>n.key===e?t(n):n)),ne=e=>e.typing.trim()===``?e:{...e,panel:[...e.panel,{key:en(),focus:e.typing.trim()}],typing:``},w=(e,t)=>C(e,e=>{let n=e.panel.find(e=>e.key===t),r=ne(e);return{...r,panel:r.panel.filter(e=>e.key!==t),typing:n?.focus??r.typing}});return(0,O.jsx)(`div`,{className:`dialog-shade`,children:(0,O.jsxs)(`div`,{className:`dialog dialog-wide`,role:`dialog`,"aria-modal":`true`,"aria-label":`Execute this spec`,children:[(0,O.jsx)(`h2`,{className:`rail-head`,children:`Execute this spec`}),(0,O.jsxs)(`div`,{className:`dialog-body`,children:[(0,O.jsxs)(`p`,{className:`rail-fact muted`,children:[`Set up the run for `,(0,O.jsx)(`b`,{children:e.name}),`.`,_!==null&&` Pre-filled from the recommendations in the plan - change anything.`]}),g&&(0,O.jsxs)(`p`,{className:`run-banner`,children:[(0,O.jsx)(`b`,{children:`Resuming a run in progress.`}),` `,(0,O.jsxs)(`span`,{className:`muted`,children:[ee,` of `,e.phases.length,` phases done - these are the choices this run started with.`]})]}),(0,O.jsx)(Zt,{label:`Commits`,options:te(Ze,_?.commits),value:n,onPick:r}),(0,O.jsx)(Zt,{label:`Branch`,options:te(Qe,_?.branch),value:a,onPick:o,children:a===`new`&&(0,O.jsx)(`input`,{value:s,"aria-label":`The branch to make`,onChange:e=>c(e.target.value)})}),(0,O.jsx)(Zt,{label:`Pauses`,options:te($e.filter(e=>e.id!==`chosen`||v),_?.pauses),value:l,onPick:u}),(l===`chosen`||b.length>0||x!==``)&&(0,O.jsxs)(`div`,{className:`run-phases`,children:[l===`chosen`&&(0,O.jsxs)(O.Fragment,{children:[e.phases.map(e=>(0,O.jsxs)(`label`,{children:[(0,O.jsx)(`input`,{type:`checkbox`,checked:d.includes(e.id),onChange:()=>f(t=>t.includes(e.id)?t.filter(t=>t!==e.id):[...t,e.id])}),e.title]},e.id)),y.map(e=>(0,O.jsxs)(`p`,{className:`run-stale`,children:[e,` is not in the plan any more - re-place this pause`]},e))]}),b.map(e=>(0,O.jsxs)(`p`,{className:`run-why`,children:[(0,O.jsxs)(`b`,{children:[`After `,e.place,`:`]}),` `,e.said]},e.id)),x!==``&&(0,O.jsxs)(`p`,{className:`run-why`,children:[(0,O.jsx)(`b`,{children:`No pause recommended:`}),` `,x]})]}),(0,O.jsx)(`h3`,{className:`run-head`,children:`Review checkpoints`}),p.length===0&&(0,O.jsx)(`p`,{className:`rail-fact muted`,children:`None proposed.`}),p.map(t=>{let n=G(t.after,e.phases),r=n===null?`somewhere the plan no longer holds`:`after ${n}`;return(0,O.jsxs)(`div`,{className:`run-checkpoint`,children:[(0,O.jsxs)(`label`,{className:`run-checkpoint-head`,children:[(0,O.jsx)(`input`,{type:`checkbox`,checked:t.chosen,onChange:()=>C(t.key,e=>({...e,chosen:!e.chosen}))}),(0,O.jsx)(`span`,{children:r})]}),t.why!==``&&(0,O.jsx)(`p`,{className:`run-why`,children:t.why}),t.chosen&&n===null&&(0,O.jsx)(`p`,{className:`run-stale`,children:`This checkpoint has nowhere to sit - untick it, or re-place it in the plan`}),t.chosen&&nn(t).length===0&&(0,O.jsx)(`p`,{className:`run-stale`,children:`Nobody is on this panel, so this checkpoint will not run`}),(0,O.jsxs)(`div`,{className:`run-panel`,children:[t.panel.map((e,n)=>(0,O.jsxs)(`span`,{className:`run-reviewer`,children:[(0,O.jsx)(`button`,{type:`button`,className:`run-focus`,title:`Change this reviewer`,onClick:()=>w(t.key,e.key),children:e.focus}),(0,O.jsx)(`button`,{type:`button`,className:`run-drop`,"aria-label":`Drop reviewer ${n+1} ${r}`,onClick:()=>C(t.key,t=>({...t,panel:t.panel.filter(t=>t.key!==e.key)})),children:(0,O.jsx)(m,{size:11})})]},e.key)),(0,O.jsxs)(`span`,{className:`run-new`,children:[(0,O.jsx)(`input`,{value:t.typing,"aria-label":`New reviewer ${r}`,placeholder:`What the next reviewer judges`,onChange:e=>C(t.key,t=>({...t,typing:e.target.value})),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),C(t.key,ne))}}),(0,O.jsxs)(`button`,{type:`button`,"aria-label":`Add a reviewer ${r}`,onClick:()=>C(t.key,ne),children:[(0,O.jsx)(i,{size:11}),`add`]})]})]})]},t.key)})]}),S>0&&(0,O.jsxs)(`p`,{className:`notice notice-failure`,children:[S===1?`One choice names`:`${S} choices name`,` a phase this plan no longer holds. Re-place `,S===1?`it`:`them`,` before you run.`]}),e.failure!==null&&(0,O.jsx)(`p`,{className:`notice notice-failure`,children:e.failure}),(0,O.jsxs)(`div`,{className:`dialog-acts`,children:[(0,O.jsx)(`button`,{type:`button`,onClick:e.onCancel,disabled:e.working,children:`Cancel`}),(0,O.jsx)(`button`,{type:`button`,className:`send`,disabled:e.working||S>0,onClick:()=>e.onRun({commits:n,branch:a,branchName:s.trim(),pauses:l,pausePhases:l===`chosen`?d:[],checkpoints:rn(p)}),children:e.working?`Starting…`:g?`Resume`:`Run`})]})]})})}function on(e){return new Promise((t,n)=>{let r=new FileReader;r.onerror=()=>n(Error(`${e.name} could not be read`)),r.onload=()=>{let n=String(r.result??``);t({name:e.name,type:e.type,data:n.slice(n.indexOf(`,`)+1)})},r.readAsDataURL(e)})}var sn=0;function cn(e){let[t,n]=(0,T.useState)(()=>e.draft?.name??``),[r,i]=(0,T.useState)(()=>e.draft?.text??``),[a,o]=(0,T.useState)(()=>e.draft?.attachments??[]),[s,c]=(0,T.useState)(null),[l,u]=(0,T.useState)(()=>e.draft?.imagination===!0),d=e.onDraft;(0,T.useEffect)(()=>{d({name:t,text:r,attachments:a,imagination:l})},[t,r,a,l,d]);let f=(0,T.useCallback)(async e=>{let t=[...e??[]];if(t.length!==0){c(null);try{let e=await Promise.all(t.map(on));o(t=>[...t,...e.map(e=>(sn+=1,{key:`f${sn}`,file:e}))])}catch(e){c(e.message)}}},[]),m=t.trim()!==``&&(r.trim()!==``||a.length>0),h=p(t.trim());return(0,O.jsx)(`div`,{className:`dialog-shade`,children:(0,O.jsxs)(`div`,{className:`dialog dialog-wide`,role:`dialog`,"aria-modal":`true`,"aria-label":`A new spec`,children:[(0,O.jsx)(`h2`,{className:`rail-head`,children:`A new piece of work`}),(0,O.jsxs)(`div`,{className:`dialog-body`,children:[(0,O.jsxs)(`label`,{className:`field`,children:[(0,O.jsx)(`span`,{children:`Working name`}),(0,O.jsx)(`input`,{value:t,placeholder:`What would you call it?`,onChange:e=>n(e.target.value)}),h!==``&&(0,O.jsxs)(`span`,{className:`field-slug`,children:[`Saved as `,(0,O.jsx)(`code`,{children:h})]})]}),(0,O.jsxs)(`label`,{className:`field`,children:[(0,O.jsx)(`span`,{children:`What is it about?`}),(0,O.jsx)(`textarea`,{className:`field-dump`,value:r,placeholder:`Say as much or as little as you have. Drop or paste files in here too.`,onChange:e=>i(e.target.value),onPaste:e=>void f(e.clipboardData?.files??null),onDragOver:e=>e.preventDefault(),onDrop:e=>{e.preventDefault(),f(e.dataTransfer?.files??null)}})]}),a.length>0&&(0,O.jsx)(`ul`,{className:`attached`,children:a.map(e=>(0,O.jsxs)(`li`,{children:[e.file.name,(0,O.jsx)(`button`,{type:`button`,onClick:()=>o(t=>t.filter(t=>t.key!==e.key)),children:`drop`})]},e.key))}),(0,O.jsxs)(`label`,{className:`flavour`,children:[(0,O.jsx)(`input`,{type:`checkbox`,checked:l,onChange:()=>u(!l)}),(0,O.jsxs)(`span`,{className:`flavour-what`,children:[`Imagination mode`,(0,O.jsx)(`span`,{className:`flavour-hint`,children:`Explore the ideal version first, before feasibility - best for open-ended or user-facing work. Confirmed with the steps.`})]})]})]}),s!==null&&(0,O.jsx)(`p`,{className:`notice notice-failure`,children:s}),e.failure!==null&&(0,O.jsx)(`p`,{className:`notice notice-failure`,children:e.failure}),(0,O.jsxs)(`div`,{className:`dialog-acts`,children:[(0,O.jsx)(`button`,{type:`button`,onClick:e.onCancel,children:`Cancel`}),(0,O.jsx)(`button`,{type:`button`,className:`send`,disabled:!m||e.filing,onClick:()=>void e.onFile({name:t.trim(),text:r.trim(),attachments:a.map(e=>e.file),wish:{imagination:l}}),children:e.filing?`Submitting…`:`Submit`})]})]})})}function ln(e){let t=[];for(let n of e){let e=t[t.length-1];e&&e.dir===n.dir?e.files.push(n):t.push({dir:n.dir,files:[n]})}return t}function un(e){return e.openSpec===null?(0,O.jsx)(fn,{...e}):(0,O.jsx)(pn,{...e})}function dn(e){return[e.name,e.path,e.status??``,Vt(e.path)].join(` `)}function fn(e){let[t,n]=(0,T.useMemo)(()=>[e.specs.filter(e=>!e.archived),e.specs.filter(e=>e.archived)],[e.specs]),r=(0,T.useMemo)(()=>w(n,e.archiveSearch,dn),[n,e.archiveSearch]);return(0,O.jsxs)(`nav`,{className:`nav`,"aria-label":`Specs`,children:[(0,O.jsxs)(`button`,{type:`button`,className:`nav-new`,onClick:e.onNewSpec,children:[(0,O.jsx)(i,{size:12}),`New spec`]}),(0,O.jsxs)(`h2`,{className:`nav-head`,children:[(0,O.jsx)(`span`,{children:`Specs`}),(0,O.jsx)(`span`,{className:`nav-head-count`,children:t.length})]}),t.length===0?(0,O.jsx)(`p`,{className:`nav-empty`,children:`none yet`}):(0,O.jsx)(`ul`,{className:`nav-list`,children:t.map(t=>(0,O.jsx)(`li`,{children:(0,O.jsxs)(`button`,{type:`button`,className:`nav-entry`,onClick:()=>e.onOpenSpec(t.path),children:[(0,O.jsx)(`span`,{className:`nav-entry-name`,children:t.name}),t.status!==null&&(0,O.jsx)(`span`,{className:`nav-entry-status`,children:t.status}),t.awaiting>0&&(0,O.jsx)(`span`,{className:`nav-entry-awaiting`,title:`waiting for you`,children:t.awaiting})]})},t.path))}),n.length>0&&(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(`h2`,{className:`nav-head`,children:(0,O.jsxs)(`button`,{type:`button`,"aria-expanded":e.archiveOpen,onClick:()=>e.onToggleArchive(!e.archiveOpen),children:[(0,O.jsx)(`span`,{children:`Archive`}),(0,O.jsxs)(`span`,{className:`nav-head-count`,children:[n.length,` `,e.archiveOpen?`▾`:`▸`]})]})}),e.archiveOpen&&(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(`div`,{className:`nav-search`,children:(0,O.jsx)(`input`,{type:`search`,"aria-label":`Search the archive`,placeholder:`Search name, status or date`,value:e.archiveSearch,onChange:t=>e.onArchiveSearch(t.target.value)})}),r.length===0?(0,O.jsx)(`p`,{className:`nav-empty`,children:`nothing by that name`}):(0,O.jsx)(`ul`,{className:`nav-list nav-archived`,children:r.map(t=>{let n=Vt(t.path);return(0,O.jsx)(`li`,{children:(0,O.jsxs)(`button`,{type:`button`,className:`nav-row`,onClick:()=>e.onOpenSpec(t.path),children:[(0,O.jsx)(`span`,{className:`nav-entry-name`,children:t.name}),n!==``&&(0,O.jsx)(`span`,{className:`nav-row-sub`,children:n})]})},t.path)})})]})]})]})}function pn(e){let t=e.spec?.name??e.openSpec??``;return(0,O.jsxs)(`nav`,{className:`nav`,"aria-label":t,children:[(0,O.jsxs)(`button`,{type:`button`,className:`nav-back`,onClick:e.onBack,children:[(0,O.jsx)(_,{size:11}),`All specs`]}),(0,O.jsxs)(`div`,{className:`nav-title`,children:[(0,O.jsx)(`div`,{className:`nav-title-name`,children:t}),e.spec?.status!=null&&(0,O.jsx)(`div`,{className:`nav-title-status`,children:e.spec.status})]}),ln(e.artifacts).map(t=>(0,O.jsxs)(`div`,{children:[t.dir!==``&&(0,O.jsxs)(`p`,{className:`nav-dir`,children:[t.dir,`/`]}),(0,O.jsx)(`ul`,{className:`nav-list`,children:t.files.map(t=>(0,O.jsxs)(`li`,{children:[(0,O.jsx)(`button`,{type:`button`,className:`nav-artifact`,"aria-current":t.path===e.openArtifact?`true`:void 0,onClick:()=>e.onOpenArtifact(t.path),children:t.name}),t.path===e.openArtifact&&e.units.length>1&&(0,O.jsx)(`ul`,{className:`nav-sections`,children:e.units.filter(e=>e.heading!==null).map(t=>(0,O.jsx)(`li`,{children:(0,O.jsxs)(`button`,{type:`button`,className:e.marks[t.id]?.read?`is-read`:void 0,"aria-current":t.id===e.currentUnit?`true`:void 0,onClick:()=>e.onOpenUnit(t.id),children:[t.heading,e.marks[t.id]?.changed&&(0,O.jsx)(`span`,{className:`nav-changed`,title:`Changed since you read it`,children:`●`})]})},t.id))})]},t.path))})]},t.dir||`.`))]})}var mn=[{id:`discovery`,head:`Before writing anything down`,said:`What we do first.`},{id:`deliverables`,head:`What this work produces`,said:`What we end up with.`}],hn=[{id:`focused`,said:`focused - the agent decides what to research`},{id:`named`,said:`focused on...`},{id:`broad`,said:`broad - deep research, can use many tokens`}];function gn(e){return new Map(e.stages.map(e=>[e.id,e]))}function _n(e){let t=(0,T.useMemo)(()=>gn(e.proposal),[e.proposal]),{held:n}=e,[r,i]=(0,T.useState)(()=>n===null?new Set([...t.values()].filter(e=>e.recommended).map(e=>e.id)):new Set(n.stages.map(e=>e.id))),[a,o]=(0,T.useState)(n===null?e.wish:n.imagination),[s,c]=(0,T.useState)(n?.settings.research?.scope??`focused`),[l,u]=(0,T.useState)(n?.settings.research?.subject??``),[d,f]=(0,T.useState)(``),p=Je.some(e=>r.has(e)),m=n===null&&e.wish,h=(0,T.useMemo)(()=>new Set((n?.stages??[]).filter(e=>e.status!==`waiting`).map(e=>e.id)),[n]),g=e=>{h.has(e)||i(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},_=(0,T.useMemo)(()=>{if(n===null)return!0;let e=new Set(n.stages.map(e=>e.id));if(e.size!==r.size||![...r].every(t=>e.has(t))||(a&&p)!==n.imagination)return!0;if(r.has(`research`)){let e=n.settings.research??{scope:`focused`,subject:``};if(s!==e.scope||s===`named`&&l.trim()!==e.subject)return!0}return!1},[n,r,a,p,s,l]);return(0,O.jsx)(`div`,{className:`doc`,children:(0,O.jsxs)(`div`,{className:`prose form`,children:[(0,O.jsxs)(`h1`,{children:[`The steps for `,e.name]}),n===null?e.proposal.note!==``&&(0,O.jsx)(`p`,{className:`lede`,children:e.proposal.note}):(0,O.jsx)(`p`,{className:`lede`,children:`Change what this work does. A step already under way stays where it is.`}),mn.map(e=>(0,O.jsxs)(`section`,{children:[(0,O.jsx)(`h2`,{children:e.head}),(0,O.jsx)(`ul`,{className:`choices`,children:qe.filter(t=>t.group===e.id).map(e=>{let n=t.get(e.id),i=h.has(e.id);return(0,O.jsxs)(`li`,{className:n?.recommended?`is-recommended`:void 0,children:[(0,O.jsxs)(`label`,{children:[(0,O.jsx)(`input`,{type:`checkbox`,checked:r.has(e.id),disabled:i,onChange:()=>g(e.id)}),(0,O.jsxs)(`span`,{className:`choice-title`,children:[e.title,n?.recommended&&(0,O.jsx)(`span`,{className:`choice-flag`,children:`recommended`}),i&&(0,O.jsx)(`span`,{className:`choice-flag choice-locked`,children:`under way`})]})]}),(0,O.jsx)(`p`,{className:`choice-about`,children:e.about}),n?.why!==void 0&&n.why!==``&&(0,O.jsx)(`p`,{className:`choice-why`,children:n.why}),e.id===`research`&&r.has(e.id)&&(0,O.jsx)(`div`,{className:`extras`,children:(0,O.jsx)(Zt,{className:`extra`,label:`Scope`,options:hn,value:s,onPick:c,children:s===`named`&&(0,O.jsx)(`input`,{value:l,"aria-label":`What to research`,placeholder:`What to research`,onChange:e=>u(e.target.value)})})})]},e.id)})})]},e.id)),p&&(0,O.jsxs)(`section`,{children:[(0,O.jsx)(`h2`,{children:`Imagination mode`}),(0,O.jsxs)(`label`,{className:`choice-mode`,children:[(0,O.jsx)(`input`,{type:`checkbox`,checked:a,onChange:e=>o(e.target.checked)}),(0,O.jsxs)(`span`,{children:[`Imagine the ideal version first, as if anything were possible - trimming it back to what can be built comes after. Best while you are still deciding what this should be.`,m&&(0,O.jsx)(`span`,{className:`choice-flag`,children:`asked for at intake`})]})]})]}),(0,O.jsxs)(`section`,{children:[(0,O.jsx)(`h2`,{children:`Anything else`}),(0,O.jsx)(`textarea`,{className:`field-dump`,value:d,placeholder:`Anything the steps above do not cover.`,onChange:e=>f(e.target.value)})]}),e.failure!==null&&(0,O.jsx)(`p`,{className:`notice notice-failure`,children:e.failure}),(0,O.jsxs)(`div`,{className:`form-acts`,children:[e.onCancel!==null&&(0,O.jsx)(`button`,{type:`button`,onClick:e.onCancel,children:`Cancel`}),(0,O.jsx)(`button`,{type:`button`,onClick:()=>e.onAsk(d.trim()||`about the steps for this work`),children:`Ask`}),(0,O.jsx)(`button`,{type:`button`,className:`send`,disabled:e.sending||r.size===0||!_,onClick:()=>e.onConfirm({stages:[...r],imagination:a&&p,note:d,settings:{research:r.has(`research`)?{scope:s,subject:s===`named`?l.trim():``}:null}}),children:e.sending?n===null?`Confirming…`:`Updating…`:n===null?`Confirm ${r.size} ${r.size===1?`step`:`steps`}`:`Update protocol`})]})]})})}var vn={waiting:`○`,running:`◐`,done:`●`},yn=6e4;function bn(e,t){let n=new Set([...e.phases.map(e=>e.id),W]),r=[];for(let n of e.phases){if(n.id===`final`)continue;let e=t.get(n.id)??[];e.length>0&&r.push({id:n.id,place:`after ${n.title||n.id}`,rounds:e})}let i=t.get(`final`)??[];i.length>0&&r.push({id:W,place:`Final review`,rounds:i});let a=e.reviews.filter(e=>e.source.kind===`execution`||e.source.kind===`checkpoint`&&!n.has(e.source.after));return a.length>0&&r.push({id:`no-place`,place:``,rounds:a}),r}function xn(e){let t=new Map;for(let n of e.reviews){if(n.source.kind!==`checkpoint`)continue;let e=t.get(n.source.after);e===void 0?t.set(n.source.after,[n]):e.push(n)}return t}function Sn(e,t){let n=e.runDecisions,r=e=>t.has(e),i=(n?.checkpoints??[]).filter(e=>e.chosen),a=e.phases.map(e=>{let t=[];if(n!==null&&((n.pauses===`every`||n.pauses===`chosen`&&n.pausePhases.includes(e.id))&&t.push({kind:`pause`,said:`Pause after this phase`}),i.some(t=>t.after===e.id))){let n=r(e.id);t.push({kind:`review`,ran:n,said:n?`Reviewed after this phase`:`Review after this phase`})}return{id:e.id,label:e.title||e.id,status:e.status,artifacts:[],marks:t}});if(i.some(e=>e.after===`final`)&&a.length>0){let e=r(W);a.push({id:W,label:`Final review`,status:e?`done`:`waiting`,artifacts:[],className:`board-final`,marks:[{kind:`review`,ran:e,said:e?`Reviewed after the last phase`:`Review after the last phase`}]})}return a}function Cn(e){return(0,O.jsx)(`ul`,{className:`board-list`,children:e.map(e=>(0,O.jsxs)(`li`,{className:`board-review`,children:[(0,O.jsxs)(`p`,{className:`board-stage-name`,children:[`round `,e.round,`: `,e.verdict]}),(0,O.jsxs)(`p`,{className:`rail-fact muted`,children:[e.findings,` `,e.findings===1?`finding`:`findings`,e.judgments>0?`, ${e.judgments} for you`:``]})]},`${wn(e.source)}-${e.round}-${e.at}`))})}function wn(e){return e.kind===`checkpoint`?`checkpoint:${e.after}`:e.kind}function Tn(e){let{flag:t}=e,n=t.kind===`pause`?``:t.ran?` is-ran`:` is-waiting`,r=f({className:`board-tip`,side:`bottom`,delay:250});return(0,O.jsxs)(`span`,{className:`board-flag${n}`,...r.anchor,children:[t.kind===`pause`?(0,O.jsx)(x,{size:13}):(0,O.jsx)(b,{size:13}),(0,O.jsx)(`span`,{className:`visually-hidden`,children:t.said}),r.says(t.said)]})}function En(e){let{row:t}=e,n=(0,O.jsx)(`span`,{className:`board-mark`,"aria-hidden":`true`,children:vn[t.status]}),r=t.artifacts.length===1?t.artifacts[0]:null,i=t.artifacts.length>1;return(0,O.jsxs)(`li`,{className:`board-stage is-${t.status}${t.className?` ${t.className}`:``}`,children:[(0,O.jsxs)(`p`,{className:`board-stage-name`,children:[n,r!==null&&(0,O.jsx)(`button`,{type:`button`,title:`Open ${r}`,onClick:()=>e.onOpen(r),children:t.label}),i&&(0,O.jsxs)(`button`,{type:`button`,"aria-expanded":e.open,onClick:e.onFold,children:[t.label,(0,O.jsx)(`span`,{className:`board-chevron`,"aria-hidden":`true`,children:e.open?`▾`:`▸`})]}),r===null&&!i&&t.label,t.marks!==void 0&&t.marks.length>0&&(0,O.jsx)(`span`,{className:`board-marks`,children:t.marks.map(e=>(0,O.jsx)(Tn,{flag:e},e.kind))})]}),i&&e.open&&(0,O.jsx)(`ul`,{className:`board-artifacts`,children:t.artifacts.map(t=>(0,O.jsx)(`li`,{children:(0,O.jsx)(`button`,{type:`button`,onClick:()=>e.onOpen(t),children:t})},t))})]})}function Dn(e){let{state:t}=e,n=t.awaiting.length>0,[r,i]=(0,T.useState)({}),o=e=>i(t=>({...t,[e]:!t[e]})),[s,c]=(0,T.useState)(()=>new Date),l=t.activity.said!==``;(0,T.useEffect)(()=>{if(!l)return;let e=setInterval(()=>c(new Date),yn);return()=>clearInterval(e)},[l]);let u=q(t,s),d=t.reviews.filter(e=>e.source.kind===`spec`),f=xn(t),p=bn(t,f),m=t=>(0,O.jsx)(`ul`,{className:`board-list`,children:t.map(t=>(0,O.jsx)(En,{row:t,onOpen:e.onOpen,open:r[t.id]===!0,onFold:()=>o(t.id)},t.id))});return(0,O.jsxs)(`section`,{className:`board`,children:[(0,O.jsxs)(`div`,{className:`board-head`,children:[(0,O.jsx)(`h2`,{className:`rail-head`,children:`Protocol`}),e.onAmend!==null&&t.protocol.length>0&&(0,O.jsx)(`button`,{type:`button`,className:`board-amend`,title:`Edit the protocol`,"aria-label":`Edit the protocol`,onClick:e.onAmend,children:(0,O.jsx)(a,{size:12})})]}),t.protocol.length===0?(0,O.jsx)(`p`,{className:`rail-fact muted`,children:n?`The steps are waiting for you.`:`No steps yet.`}):m(Ye(t.protocol).map(e=>({id:e.id,label:U(e.id)?.title??e.id,status:e.status,artifacts:e.artifacts}))),u!==null&&(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(`h2`,{className:`rail-head`,children:`Now`}),(0,O.jsxs)(`p`,{className:`board-now`,title:u.at,children:[(0,O.jsx)(`span`,{className:`pulse`,"aria-hidden":`true`}),u.said]})]}),t.phases.length>0&&(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(`h2`,{className:`rail-head`,children:`Execution`}),m(Sn(t,f))]}),t.reviews.length>0&&(0,O.jsxs)(`div`,{className:`board-log`,children:[d.length>0&&(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(`h2`,{className:`rail-head`,children:`Specs review`}),Cn(d)]}),p.length>0&&(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(`h2`,{className:`rail-head`,children:`Execution review`}),(0,O.jsx)(`ul`,{className:`board-list board-nested`,children:p.map(e=>(0,O.jsxs)(`li`,{className:`board-under`,children:[e.place!==``&&(0,O.jsx)(`p`,{className:`board-under-name`,children:e.place}),Cn(e.rounds)]},e.id))})]})]})]})}function On(e){let t=new Date(e);return Number.isNaN(t.getTime())?``:t.toLocaleString()}function kn(e){return(0,O.jsxs)(`section`,{children:[(0,O.jsx)(`h2`,{className:`rail-head`,children:`Needs you`}),(0,O.jsx)(`ul`,{className:`rail-awaiting`,children:e.awaiting.map(t=>(0,O.jsxs)(`li`,{children:[(0,O.jsx)(`button`,{type:`button`,className:`send`,onClick:()=>e.onAnswer(t.id),children:t.title}),t.file!==``&&(0,O.jsx)(`p`,{className:`rail-fact muted`,children:t.file})]},t.id))})]})}function An(e){let[t,n]=(0,T.useState)(null),r=e.queue.length>0,i=Re(e.queue).length;return(0,O.jsxs)(`section`,{className:`rail-annotations`,children:[(0,O.jsx)(`h2`,{className:`rail-head`,children:r?`Annotations (${e.queue.length})`:`Annotations`}),r&&(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(`ul`,{className:`queue`,children:e.queue.map(r=>(0,O.jsxs)(`li`,{className:`queued is-${r.kind}`,children:[(0,O.jsx)(`p`,{className:`queued-target`,children:Ie(r)}),r.kind===`remove`?(0,O.jsx)(`p`,{className:`queued-kind`,children:`Asking for this to be removed`}):t===r.id?(0,O.jsx)(`textarea`,{value:r.text,placeholder:`What about it?`,"aria-label":`Comment on ${Ie(r)}`,onChange:t=>e.onEdit(r.id,t.target.value)}):r.text===``?(0,O.jsx)(`p`,{className:`queued-empty`,children:`Nothing written yet - this one will not be sent`}):(0,O.jsx)(`p`,{className:`queued-text`,children:r.text}),(0,O.jsxs)(`div`,{className:`queued-acts`,children:[r.kind===`comment`&&(0,O.jsx)(`button`,{type:`button`,onClick:()=>n(t===r.id?null:r.id),children:t===r.id?`done`:`edit`}),(0,O.jsx)(`button`,{type:`button`,onClick:()=>e.onSendOne(r.id),disabled:e.sending,children:`send now`}),(0,O.jsx)(`button`,{type:`button`,onClick:()=>e.onDrop(r.id),children:`drop`})]})]},r.id))}),(0,O.jsx)(`button`,{type:`button`,className:`send`,onClick:e.onSendBatch,disabled:e.sending||i===0,children:e.sending?`Sending…`:`Send`})]}),e.filed.length>0&&(0,O.jsx)(`ul`,{className:`filed`,children:e.filed.slice().reverse().map((t,n)=>(0,O.jsxs)(`li`,{children:[(0,O.jsxs)(`span`,{className:`filed-round`,children:[`round `,e.filed.length-n]}),(0,O.jsxs)(`span`,{className:`filed-count`,children:[t.comments.length,` `,t.comments.length===1?`note`:`notes`]}),(0,O.jsx)(`span`,{className:`filed-when`,children:On(t.submittedAt)})]},t.submittedAt||String(n)))})]})}function jn(e){let t=e.queue.length>0,n=!t&&e.filed.length>0,r=(0,O.jsx)(An,{...e});return(0,O.jsxs)(`aside`,{className:`rail`,"aria-label":`Status`,children:[e.spec!==null&&(0,O.jsxs)(`section`,{children:[(0,O.jsx)(`h2`,{className:`rail-head`,children:`Spec`}),(0,O.jsx)(`p`,{className:`rail-fact`,children:e.spec.name}),(0,O.jsxs)(`p`,{className:`rail-fact muted`,children:[e.spec.files,` `,e.spec.files===1?`artifact`:`artifacts`,e.spec.archived?` · archived`:``]}),(0,O.jsxs)(`p`,{className:`rail-fact muted`,children:[`last changed `,On(e.spec.modified)]})]}),e.spec!==null&&(0,O.jsxs)(`section`,{children:[(0,O.jsx)(`h2`,{className:`rail-head`,children:`Actions`}),(0,O.jsxs)(`div`,{className:`rail-acts`,children:[(0,O.jsxs)(`button`,{type:`button`,className:`rail-act`,onClick:e.onContinue,children:[(0,O.jsx)(u,{size:15}),`Continue`]}),e.executable&&(0,O.jsxs)(`button`,{type:`button`,className:`rail-act`,onClick:e.onExecute,children:[(0,O.jsx)(y,{size:15}),`Execute`]}),e.onQualityReview!==null&&(0,O.jsxs)(`button`,{type:`button`,className:`rail-act`,onClick:e.onQualityReview,children:[(0,O.jsx)(b,{size:15}),`Specs quality review`]}),!e.spec.archived&&(0,O.jsxs)(`button`,{type:`button`,className:`rail-act`,onClick:e.onArchive,children:[(0,O.jsx)(l,{size:15}),`Archive`]})]})]}),e.protocol!==null&&e.protocol.awaiting.length>0&&(0,O.jsx)(kn,{awaiting:e.protocol.awaiting,onAnswer:e.onAnswer}),t&&r,e.protocol!==null&&(0,O.jsx)(Dn,{state:e.protocol,onOpen:e.onOpenArtifact,onAmend:e.onAmend}),n&&r,e.sent!==null&&(0,O.jsx)(`p`,{className:`rail-fact muted`,children:e.sent}),e.failure!==null&&(0,O.jsx)(`p`,{className:`notice notice-failure`,children:e.failure})]})}var Mn={units:[],text:null,loading:!1,failure:null,from:null};function Nn(e,t){return e?`${e}/${t.path}`:t.path}function Pn(e,t){let[n,r]=(0,T.useState)(Mn),i=(0,T.useRef)(null),a=(0,T.useCallback)((e,t)=>{let n=Nn(e,t);if(i.current=n,!ae(t.kind)){let e=D({path:t.path,kind:t.kind,fingerprint:t.hash??`${t.size}:${t.modified}`});r({units:e,text:null,loading:!1,failure:null,from:n});return}r(e=>({...e,loading:!0})),wt(n).then(e=>{if(i.current!==n)return;let a=D({path:t.path,kind:t.kind,text:e.text});r({units:a,text:e.text,loading:!1,failure:null,from:n})}).catch(e=>{i.current===n&&r({units:[],text:null,loading:!1,failure:e.message,from:n})})},[]);(0,T.useEffect)(()=>{if(!t){i.current=null,r(Mn);return}a(e,t)},[e,t,a]),(0,T.useEffect)(()=>{if(!t)return;let n=Nn(e,t);return pt(r=>{r.path===n&&a(e,t)})},[e,t,a]);let o=t?Nn(e,t):null;return n.from===o?{units:n.units,text:n.text,loading:n.loading,failure:n.failure}:{units:[],text:null,loading:o!==null,failure:null}}function Fn(e){let[t,n]=(0,T.useState)({for:null,state:null}),[r,i]=(0,T.useState)(null),a=(0,T.useRef)(null),o=(0,T.useCallback)(()=>{if(e===null){a.current=null,n({for:null,state:null});return}a.current=e,jt(e).then(t=>{a.current===e&&(n({for:e,state:t}),i(null))}).catch(t=>{a.current===e&&i(t.message)})},[e]);return(0,T.useEffect)(o,[o]),(0,T.useEffect)(()=>{if(e!==null)return pt(t=>{t.entry===e&&o()})},[e,o]),{state:t.for===e?t.state:null,failure:r,refresh:o}}var In={openSpec:null,openArtifact:null,answering:null,shade:null,archiveOpen:!1,archiveSearch:``,draft:null,intake:null};function Ln(){let[e,t]=(0,T.useState)(null),[n,r]=(0,T.useState)(null),[i,a]=(0,T.useState)(null),[o,s]=(0,T.useState)(null),[c,l]=(0,T.useState)(null),[u,d]=(0,T.useState)(!1),[f,p]=(0,T.useState)(``),[m,h]=(0,T.useState)(null),[g,_]=(0,T.useState)(null),[ee,v]=(0,T.useState)(null),[y,b]=(0,T.useState)(null),[x,S]=(0,T.useState)(null),[C,w]=(0,T.useState)(!1),[re,E]=(0,T.useState)(null),[ae,D]=(0,T.useState)(null),se=te({onSession:mt,askTheme:yt}),le=(0,T.useRef)(new Map),k=(0,T.useRef)(null),[de,fe]=(0,T.useState)(null),A=(0,T.useRef)(In),j=(0,T.useRef)(null),pe=(0,T.useRef)(null);(0,T.useEffect)(()=>{ft().then(e=>r(e.raw))},[]);let M=(0,T.useCallback)(()=>{xt().then(e=>{t(e),a(null)}).catch(e=>a(e.message))},[]);(0,T.useEffect)(M,[M]),(0,T.useEffect)(()=>pt(M),[M]);let me=(0,T.useCallback)(e=>{l(e),_(null),h(null),Z(!1),qe(e=>e===`intake`?e:null),E(null)},[]),N=(0,T.useRef)(null),he=(0,T.useCallback)(e=>{N.current=e,St(e).then(t=>{N.current===e&&(h(t),s(null))}).catch(t=>{N.current===e&&s(t.message)})},[]);(0,T.useEffect)(()=>{c!==null&&he(c)},[c,he]);let[ge,_e]=(0,T.useState)([]),ve=(0,T.useCallback)(e=>{kt(e).then(t=>{N.current===e&&_e(t.rounds)}).catch(()=>_e([]))},[]);(0,T.useEffect)(()=>{c===null?_e([]):ve(c)},[c,ve]);let ye=m?.archived!==!0,be=m!==null&&!m.archived,xe=ce(c,{get:Tt,put:Et,empty:Ve,whenUnwritable:`Your marks are not being saved - the state file cannot be written.`,whenUnreadable:`This spec’s saved state could not be read, so nothing is being saved.`,persist:ye}),Se=ce(be?c:null,{get:Dt,put:Ot,empty:()=>[],whenUnwritable:`Your annotations are not being saved - the queue file cannot be written.`,whenUnreadable:`This spec’s queued annotations could not be read, so nothing is being saved.`}),Ce=Se.reload;(0,T.useEffect)(()=>{if(c!==null)return pt(e=>{if(e.entry===c){if(e.path.endsWith(`/.specs/pending-annotations.json`)){Ce();return}he(c),ve(c)}})},[c,he,ve,Ce]);let P=(0,T.useMemo)(()=>m?.files??[],[m]);(0,T.useEffect)(()=>{P.length!==0&&(P.some(e=>e.path===g)||_(P[0].path))},[P,g]);let F=P.find(e=>e.path===g)??null,I=Pn(c??``,F),we=(0,T.useMemo)(()=>{let e={};for(let t of I.units)e[t.id]=ie(t.hash,xe.value.units[t.id]);return e},[I.units,xe.value]);(0,T.useEffect)(()=>{y===null||F===null||I.units.length===0||(v(oe(I.units,F.path,y)?.id??null),b(null))},[I.units,F,y]);let Te=(0,T.useCallback)((e,t)=>{_(e),b(t===``?null:t)},[]),Ee=xe.update,De=(0,T.useCallback)(e=>{Ee(t=>{let n=t.units[e.id],r={...t.units};if(n?.readHash===e.hash){let{readHash:t,readAt:i,...a}=n;r[e.id]=a}else r[e.id]={...n,readHash:e.hash,readAt:new Date().toISOString()};return{...t,units:r}})},[Ee]),Oe=(0,T.useCallback)(()=>v(null),[]),L=e?.entries.find(e=>e.path===c)??null,ke=Se.value,je=Se.update,Me=(0,T.useCallback)((e,t,n=``)=>{je(r=>[...r,Fe(e,t,n)],!0),E(null)},[je]),R=(0,T.useCallback)(async e=>{let t=await gt(e);return t.ok?!0:t.error===`no-session`?(D(e),!1):(E(`No agent was told: ${t.error}`),!1)},[]),Ne=(0,T.useCallback)(async e=>{if(!(c===null||Re(e).length===0)){w(!0),E(null);try{let t=await At(c,ze(e)),n=new Set(e.map(e=>e.id));je(e=>e.filter(e=>!n.has(e.id)),!0),ve(c),await R({event:`annotations`,detail:Be(e),path:t.path})||E(e=>e??`Round ${t.round} was filed. Nobody has been told yet.`)}catch(e){E(`That could not be filed: ${e.message}`)}finally{w(!1)}}},[c,R,ve,je]),z=Fn(c),[B,V]=(0,T.useState)(null),[Ie,Le]=(0,T.useState)(0),[He,Ue]=(0,T.useState)(null),[We,H]=(0,T.useState)(null),[Ge,qe]=(0,T.useState)(null),[Je,U]=(0,T.useState)(null),[Ye,W]=(0,T.useState)(!1),G=(0,T.useCallback)(e=>{U(null),W(!1),qe(e)},[]),[Xe,Ze]=(0,T.useState)(0);(0,T.useEffect)(()=>{A.current={openSpec:c,openArtifact:g,answering:B,shade:Ge===`intake`?`intake`:null,archiveOpen:u,archiveSearch:f}},[c,g,B,Ge,u,f]);let Qe=(0,T.useCallback)(e=>{if(k.current===e)return;let t=A.current,n=e===null?void 0:le.current.get(e);if(k.current===null&&n===void 0){k.current=e,fe(e),E(null);return}k.current!==null&&le.current.set(k.current,{...t,draft:j.current,intake:pe.current}),k.current=e,fe(e);let r=n??In;A.current=r,j.current=r.draft,pe.current=r.intake,l(r.openSpec),_(r.openArtifact),V(r.answering),qe(r.shade),d(r.archiveOpen),p(r.archiveSearch),Ze(e=>e+1),Z(!1),E(null),H(null),U(null),W(!1),r.openSpec!==t.openSpec&&(h(null),v(null),b(null),S(null))},[]);(0,T.useEffect)(()=>mt(e=>Qe(e.sid)),[Qe]);let $e=z.state?.awaiting.length??0;(0,T.useEffect)(()=>{_t($e)},[$e]),(0,T.useEffect)(()=>{if(c===null||B===null){Ue(null);return}let e=!0;return Mt(c,B).then(t=>{if(!e)return;Ue(t),H(null);let n=typeof t.file==`string`?t.file:``;n!==``&&Te(n,``)}).catch(t=>{e&&H(t.message)}),()=>{e=!1}},[c,B,Te]);let K=z.state?.awaiting.find(e=>e.id===B)??null,q=K?.kind??null,et=He===null?null:He.payload??He,J=et===null?null:Ae(et),Y=J?.kind===`decision`&&F!==null&&F.path===(K?.file??``)?oe(I.units,F.path,J.heading)?.id??null:null;(0,T.useEffect)(()=>{let e=z.state?.awaiting;B===null||e===void 0||e.some(e=>e.id===B)||V(null)},[B,z.state]);let X=c===null||B===null?null:`${c}:${B}`,tt=(0,T.useCallback)((e,t)=>{Z(!1),q===`protocol`&&V(null),Te(e,t)},[q,Te]),nt=(0,T.useCallback)(e=>{Z(!1),q===`protocol`&&V(null),v(e)},[q]),[rt,it]=(0,T.useState)(null),[at,Z]=(0,T.useState)(!1),ot=(0,T.useMemo)(()=>{if(q===`protocol`&&et!==null)return{proposal:et,held:null};let e=z.state;return!at||e===null||e.protocol.length===0?null:{proposal:{stages:[],note:``},held:{stages:e.protocol,imagination:e.modes.imagination,settings:e.stageSettings}}},[at,q,et,z.state]),st=(0,T.useCallback)(e=>{if(X===null||B===null)return Promise.resolve(!1);let t=K?.file??``;return R({event:`question`,detail:`${K?.title??B}: ${e}`,...t===``?{}:{path:`${c}/${t}`}}).then(t=>(t&&it({for:X,said:e}),t))},[B,X,K,c,R]),ct=(0,T.useCallback)(e=>{X!==null&&(j.current={for:X,...e})},[X]),lt=(0,T.useCallback)(async e=>{if(!(c===null||B===null)){w(!0),H(null);try{let t=await It(c,B,e);V(null),j.current=null,z.refresh(),await R({event:K?.kind===`gate`?`gate`:`answers`,detail:`${K?.title??B}: ${t.outcome}`,path:t.path})}catch(e){H(e.message)}finally{w(!1)}}},[B,K,c,z,R]),ut=(0,T.useCallback)(e=>{pe.current=e},[]),dt=(0,T.useCallback)(e=>{if(e!==null&&e!==k.current){let t=le.current.get(e);if(t!==void 0){le.current.set(e,{...t,shade:null,intake:null});return}}G(null),pe.current=null},[G]),Q=(0,T.useCallback)(async e=>{let t=k.current;W(!0),U(null);try{let n=await Nt(e);dt(t),l(n.entry),_(n.path.slice(n.entry.length+1)),h(null),M(),await R({event:`brief`,detail:n.entry})}catch(e){U(e.message)}finally{W(!1)}},[dt,M,R]),vt=(0,T.useCallback)(async e=>{if(c===null)return null;w(!0),H(null);try{let{change:t}=await Pt(c,e);if(V(null),Z(!1),z.refresh(),t.amended&&!t.changed)return null;await R({event:t.amended?`amendment`:`answers`,detail:t.amended?`${L?.name??c}: ${t.said}`:`protocol confirmed - ${t.said}`,path:`${c}/README.md`})}catch(e){let t=e.message;return H(t),t}finally{w(!1)}return null},[c,z,R,L?.name]),bt=(0,T.useCallback)(()=>{L!==null&&(E(null),R({event:`brief`,detail:L.path}).then(e=>{e&&E(`An agent was asked to pick this spec up.`)}))},[R,L]),$=(0,T.useMemo)(()=>ye&&P.some(e=>e.path===`plan/PLAN.md`),[P,ye]),wt=(0,T.useCallback)(async e=>{if(!(c===null||L===null)){W(!0),U(null);try{await Ft(c,e),G(null),z.refresh(),E(null),await R({event:`execute`,detail:L.path})?E(`The run was started in the session beside this pane.`):E(e=>e??`The run is set up. Nobody has been told yet.`)}catch(e){U(e.message)}finally{W(!1)}}},[c,z,R,G,L]),jt=(0,T.useCallback)(()=>{let e=z.state?.protocol??[];E(null),vt({stages:[...e.map(e=>e.id),Ke],imagination:null,note:``,settings:{research:null}}).then(e=>{e!==null&&E(`Specs quality review was not added: ${e}`)})},[vt,z.state]),Lt=(0,T.useMemo)(()=>{let e=z.state?.protocol??[];return ye&&e.length>0&&!e.some(e=>e.id===`quality-review`)},[ye,z.state]),Rt=(0,T.useCallback)(async()=>{if(c!==null){W(!0),U(null);try{let e=await Ct(c);G(null),h(null),_(e.path.slice(e.entry.length+1)),l(e.entry),E(`Signed off, and filed as ${e.entry}.`)}catch(e){U(e.message)}finally{W(!1)}}},[c,G]);if(n===null||e===null)return(0,O.jsx)(`p`,{className:`notice notice-failure`,children:i??`Waiting for the pane to hand over…`});let zt=B===null||J===null||q===`protocol`?null:(0,O.jsx)(Pe,{title:K?.title??B,ask:J,file:K?.file??``,onAnswer:e=>void lt(e),onAsk:st,asked:rt?.for===X?rt.said:null,onDismiss:()=>V(null),settled:F===null||!I.loading,summon:Ie,sending:C,failure:We,draft:j.current?.for===X?j.current:null,onDraft:ct},X);return(0,O.jsxs)(`div`,{className:c===null?`workspace is-alone`:`workspace`,children:[(0,O.jsx)(un,{specs:e.entries,openSpec:c,spec:L,onOpenSpec:me,onBack:()=>me(null),artifacts:P,openArtifact:g,onOpenArtifact:e=>tt(e,``),units:I.units,currentUnit:x,marks:we,onOpenUnit:nt,onNewSpec:()=>G(`intake`),archiveOpen:u,onToggleArchive:d,archiveSearch:f,onArchiveSearch:p}),(0,O.jsxs)(`main`,{className:`stage`,"data-theme":se.theme,children:[(0,O.jsx)(ne,{theme:se.theme,kept:se.kept,onToggle:se.toggle}),ot===null?F===null?(0,O.jsxs)(`div`,{className:`doc`,children:[ae!==null&&zt!==null?null:(0,O.jsx)(`p`,{className:`notice`,children:o??(e.entries.length===0?`No work here yet. Start a piece with New spec.`:c===null?`Nothing is open. Pick a piece of work on the left.`:m===null?`Opening…`:`This spec holds nothing to read yet.`)}),zt]}):(0,O.jsxs)(`div`,{className:`doc-and-ask`,children:[(0,O.jsx)(Xt,{reader:de??``,entry:c??``,file:F,units:I.units,text:I.text,marks:we,loading:I.loading,failure:I.failure,raw:n,onToggleRead:De,landOn:ee,onLanded:Oe,onCurrent:S,onOpen:Te,onLeave:e=>void ht(e),onAnnotate:be?Me:null,under:Y===null?null:{unit:Y,node:zt}}),Y===null&&zt]}):(0,O.jsx)(_n,{name:L?.name??c??``,proposal:ot.proposal,held:ot.held,wish:z.state?.wish.imagination===!0,onConfirm:e=>void vt(e),onAsk:e=>void R({event:`question`,detail:`the steps: ${e}`}),onCancel:ot.held===null?null:()=>Z(!1),sending:C,failure:We},`${c}:${ot.held===null?`propose:${ot.proposal.offeredAt??``}`:`amend`}`)]}),c!==null&&(0,O.jsx)(jn,{spec:L,failure:xe.failure??Se.failure,queue:ke,filed:ge,onEdit:(e,t)=>je(n=>n.map(n=>n.id===e?{...n,text:t}:n)),onDrop:e=>je(t=>t.filter(t=>t.id!==e),!0),onSendOne:e=>{let t=ke.find(t=>t.id===e);t&&Ne([t])},onSendBatch:()=>void Ne(ke),sending:C,sent:re,onContinue:bt,onExecute:()=>G(`execute`),executable:$,onQualityReview:Lt?jt:null,onArchive:()=>G(`archive`),protocol:z.state,onOpenArtifact:e=>tt(e,``),onAnswer:e=>{if(Z(!1),e!==B){V(e);return}let t=K?.file??``;t!==``&&Te(t,``),Le(e=>e+1)},onAmend:ye?()=>{H(null),Z(!0)}:null}),Ge===`archive`&&L!==null&&c!==null&&(0,O.jsx)(ue,{name:L.name,filed:Bt(c,new Date),state:z.state,onArchive:()=>void Rt(),onCancel:()=>G(null),working:Ye,failure:Je}),Ge===`execute`&&L!==null&&c!==null&&(0,O.jsx)(an,{name:L.name,slug:c.slice(c.lastIndexOf(`/`)+1),phases:z.state?.phases??[],recommended:z.state?.runRecommendations??null,decided:z.state?.runDecisions??null,onRun:e=>void wt(e),onCancel:()=>G(null),working:Ye,failure:Je},c),Ge===`intake`&&(0,O.jsx)(cn,{onFile:Q,onCancel:()=>dt(k.current),filing:Ye,failure:Je,draft:pe.current,onDraft:ut},Xe),ae!==null&&(0,O.jsx)(Rn,{onCancel:()=>{D(null),E(`Nobody was told: there was no session in this window.`)},onConfirm:()=>{let e=ae;D(null),gt({...e,create:!0}).then(e=>{E(e.ok?`A session was started, and it opens on this.`:`A session could not be started: ${e.error}`)})}})]})}function Rn({onCancel:e,onConfirm:t}){return(0,O.jsx)(`div`,{className:`dialog-shade`,children:(0,O.jsxs)(`div`,{className:`dialog`,role:`dialog`,"aria-modal":`true`,"aria-label":`No session is running`,children:[(0,O.jsx)(`div`,{className:`dialog-body`,children:(0,O.jsx)(`p`,{children:`No session is running in this window. Start one and let it pick this up?`})}),(0,O.jsxs)(`div`,{className:`dialog-acts`,children:[(0,O.jsx)(`button`,{type:`button`,onClick:e,children:`Not now`}),(0,O.jsx)(`button`,{type:`button`,className:`send`,onClick:t,children:`Start`})]})]})})}vt();var zn=document.getElementById(`root`);zn&&(0,re.createRoot)(zn).render((0,O.jsx)(T.StrictMode,{children:(0,O.jsx)(Ln,{})}));
@@ -1 +1 @@
1
- import{A as e}from"./api-BBDf_rzz.js";var t=e(),n=3e4;function r(e,r){let[i,a]=(0,t.useState)(()=>r??new Date);return(0,t.useEffect)(()=>{if(r!==void 0||!e)return;let t=setInterval(()=>a(new Date),n);return()=>clearInterval(t)},[e,r]),r??i}export{r as t};
1
+ import{A as e}from"./api-CguEsvNp.js";var t=e(),n=3e4;function r(e,r){let[i,a]=(0,t.useState)(()=>r??new Date);return(0,t.useEffect)(()=>{if(r!==void 0||!e)return;let t=setInterval(()=>a(new Date),n);return()=>clearInterval(t)},[e,r]),r??i}export{r as t};
@@ -4,11 +4,11 @@
4
4
  <meta charset="utf-8" />
5
5
  <meta name="viewport" content="width=device-width, initial-scale=1" />
6
6
  <title>Home</title>
7
- <script type="module" crossorigin src="../assets/home-Cu9xOd2i.js"></script>
8
- <link rel="modulepreload" crossorigin href="../assets/api-BBDf_rzz.js">
9
- <link rel="modulepreload" crossorigin href="../assets/useNow-BHFKFraS.js">
10
- <link rel="stylesheet" crossorigin href="../assets/api-DNLbSBpK.css">
11
- <link rel="stylesheet" crossorigin href="../assets/home-3SeGzySM.css">
7
+ <script type="module" crossorigin src="../assets/home-CrhBkqDQ.js"></script>
8
+ <link rel="modulepreload" crossorigin href="../assets/api-CguEsvNp.js">
9
+ <link rel="modulepreload" crossorigin href="../assets/useNow-Ww-Gffnk.js">
10
+ <link rel="stylesheet" crossorigin href="../assets/api-Cyoc3E6K.css">
11
+ <link rel="stylesheet" crossorigin href="../assets/home-CLFnmg7u.css">
12
12
  </head>
13
13
  <body>
14
14
  <div id="root"></div>
@@ -4,12 +4,12 @@
4
4
  <meta charset="utf-8" />
5
5
  <meta name="viewport" content="width=device-width, initial-scale=1" />
6
6
  <title>Code Reviews</title>
7
- <script type="module" crossorigin src="../assets/reviews-DMrGB-kG.js"></script>
8
- <link rel="modulepreload" crossorigin href="../assets/api-BBDf_rzz.js">
9
- <link rel="modulepreload" crossorigin href="../assets/useNow-BHFKFraS.js">
10
- <link rel="modulepreload" crossorigin href="../assets/files-BkmyervY.js">
11
- <link rel="stylesheet" crossorigin href="../assets/api-DNLbSBpK.css">
12
- <link rel="stylesheet" crossorigin href="../assets/reviews-nK_yRav9.css">
7
+ <script type="module" crossorigin src="../assets/reviews-Bq8EwmG-.js"></script>
8
+ <link rel="modulepreload" crossorigin href="../assets/api-CguEsvNp.js">
9
+ <link rel="modulepreload" crossorigin href="../assets/useNow-Ww-Gffnk.js">
10
+ <link rel="modulepreload" crossorigin href="../assets/search-DgFnnu-J.js">
11
+ <link rel="stylesheet" crossorigin href="../assets/api-Cyoc3E6K.css">
12
+ <link rel="stylesheet" crossorigin href="../assets/reviews-DzHtA35Q.css">
13
13
  </head>
14
14
  <body>
15
15
  <div id="root"></div>
@@ -4,10 +4,10 @@
4
4
  <meta charset="utf-8" />
5
5
  <meta name="viewport" content="width=device-width, initial-scale=1" />
6
6
  <title>Specs</title>
7
- <script type="module" crossorigin src="../assets/specs-Cabb15F0.js"></script>
8
- <link rel="modulepreload" crossorigin href="../assets/api-BBDf_rzz.js">
9
- <link rel="modulepreload" crossorigin href="../assets/files-BkmyervY.js">
10
- <link rel="stylesheet" crossorigin href="../assets/api-DNLbSBpK.css">
7
+ <script type="module" crossorigin src="../assets/specs-JvdNFtXR.js"></script>
8
+ <link rel="modulepreload" crossorigin href="../assets/api-CguEsvNp.js">
9
+ <link rel="modulepreload" crossorigin href="../assets/search-DgFnnu-J.js">
10
+ <link rel="stylesheet" crossorigin href="../assets/api-Cyoc3E6K.css">
11
11
  </head>
12
12
  <body>
13
13
  <div id="root"></div>
@@ -1,12 +1,11 @@
1
- import{existsSync as e,mkdirSync as t,readFileSync as n,realpathSync as r,renameSync as i,rmSync as a,writeFileSync as o}from"node:fs";import{basename as s,dirname as c,isAbsolute as l,join as u,relative as d,resolve as f,sep as p}from"node:path";import{execFile as ee}from"node:child_process";import{createHash as te}from"node:crypto";import{lstat as ne,readdir as re}from"node:fs/promises";function ie(e){let t=e?.code;return typeof t==`string`&&ae.has(t)?t:null}var ae=new Set([`path-refused`,`no-entry`,`no-file`,`bad-request`,`too-large`,`upstream-failed`,`unreadable-answer`]),m=class extends Error{requested;code=`path-refused`;constructor(e,t){super(`${e}: refused path ${t}`),this.requested=t,this.name=`PathRefused`}},oe=class extends Error{requested;code=`no-file`;constructor(e,t,n=`not a file`){super(`${e}: ${n} - ${t}`),this.requested=t,this.name=`NoSuchFile`}};function h(e){switch(ie(e)){case`path-refused`:return 403;case`no-entry`:case`no-file`:return 404;case`bad-request`:return 400;case`too-large`:return 413;case`upstream-failed`:case`unreadable-answer`:return 502}return g(e)?404:500}function g(e){let t=e?.code;return t===`ENOENT`||t===`ENOTDIR`}var se=`/usr/bin/git`,ce=3e4,le=64*1024*1024,ue=[`core.fsmonitor=false`,`core.hooksPath=/dev/null`],_=[`--no-color`,`--no-ext-diff`,`--no-textconv`],de={GIT_CONFIG_NOSYSTEM:`1`,GIT_CONFIG_GLOBAL:`/dev/null`,GIT_OPTIONAL_LOCKS:`0`,LC_ALL:`C`,PATH:`/usr/bin:/bin`},v=class extends Error{operation;said;tooMuch;overLimit;code=`upstream-failed`;constructor(e,t,n,r=!1,i=!1){super(`${e}: git ${t} failed - ${n}`),this.operation=t,this.said=n,this.tooMuch=r,this.overLimit=i,this.name=`GitFailed`}},y=class extends Error{code=`bad-request`;constructor(e,t){super(`${e}: ${t}`),this.name=`NotAllowed`}};function b(e){return/^[0-9a-f]{40}$|^[0-9a-f]{64}$/.test(e)}function fe(e){let t=t=>new y(e,t),n=(e,n)=>{if(n===``)throw t(`${e} is empty`);if(n.startsWith(`-`))throw t(`${e} is spelled as an option: ${n}`);if(/[\0\n\r]/.test(n))throw t(`${e} holds a line break or a null byte`);return n};return{mustBeValue:n,mustBeInsideWorkspace:(e,r)=>{if(n(e,r),r.startsWith(`/`))throw t(`${e} is absolute: ${r}`);if(r.split(`/`).includes(`..`))throw t(`${e} climbs out of the workspace: ${r}`);return r},mustBePath:(e,n)=>{if(n===``)throw t(`${e} is empty`);if(n.includes(`\0`))throw t(`${e} holds a null byte`);if(n.startsWith(`/`))throw t(`${e} is absolute: ${n}`);if(n.split(`/`).includes(`..`))throw t(`${e} climbs out of the workspace: ${n}`);return n},mustBeOid:e=>{if(!b(e))throw t(`${e} is not an object id`);return e},asCommit:e=>{if(!b(e))throw t(`${e} is not a resolved commit`);return e},refuse:t}}function pe(e){let{tool:t,table:n,workspace:r}=e,i=[...e.config??[],...ue].flatMap(e=>[`-c`,e]),a=new Set(e.answersWithStatus??[]),o=(e,...r)=>{let a=n[e];if(!a)throw new y(t,`no git operation named ${String(e)}`);return[...i,...a(...r)]},s=(e,n)=>new Promise((i,o)=>{ee(se,n,{cwd:r,env:{...de},encoding:`buffer`,maxBuffer:le,timeout:ce,shell:!1,windowsHide:!0},(n,r,s)=>{let c=Buffer.isBuffer(r)?r:Buffer.from(String(r)),l=x(s);if(!n)return i({ok:!0,out:c,said:l});let u=n,d=u.code===`ERR_CHILD_PROCESS_STDIO_MAXBUFFER`;if(u.killed||u.code===`ENOENT`||d){let n=u.killed===!0||d;return o(new v(t,String(e),l||u.message,d,n))}i({ok:(typeof u.code==`number`?u.code:null)===1&&a.has(String(e))&&l.trim()===``,out:c,said:l})})}),c=(e,n)=>new v(t,String(e),n||`it said nothing`);return{vector:o,async text(e,...t){let n=await s(e,o(e,...t));if(!n.ok)throw c(e,n.said);return n.out.toString(`utf8`).replace(/\n$/,``)},async bytes(e,...t){let n=await s(e,o(e,...t));if(!n.ok)throw c(e,n.said);return n.out},async ok(e,...t){return(await s(e,o(e,...t))).ok},async commit(e){let n=o(`rev-parse`,e),r=await s(`rev-parse`,n),i=r.out.toString(`utf8`).trim();if(!r.ok||!b(i))throw new y(t,`there is no commit at ${e}`);return i}}}function x(e){return(Buffer.isBuffer(e)?e.toString(`utf8`):String(e)).split(`
2
- `).map(e=>e.trim()).filter(Boolean)[0]??``}new Set(`txt text log json yaml yml toml ini cfg conf csv tsv xml css scss js jsx mjs cjs ts tsx py rb go rs java kt swift c h cpp hpp sh bash zsh fish sql graphql gql env diff patch lock gitignore editorconfig`.split(` `));function me(e){return e.startsWith(`.`)}function S(e){let t=e,n=[];for(;;)try{return u(r(t),...n)}catch{let r=c(t);if(r===t)return e;n.unshift(s(t)),t=r}}function C(e){return S(f(e))}function w(e){return e.split(`/`).some(e=>e!==``&&me(e))}function he(e,t,n,r){let i=n.replace(/^\/+/,``);if(l(n)||i.includes(`\0`))throw new m(e,n);let a=r===`require`;if(w(i)!==a)throw new m(e,n);let o=S(f(t)),s=f(o,i);if(!E(o,s)||!E(o,S(s))||w(d(o,s).split(p).join(`/`))!==a)throw new m(e,n);return s}function T(e,t,n){return he(e,t,n,`require`)}function E(e,t){return t===e||t.startsWith(e+p)}var ge=[`main`,`master`],_e=7;async function D(e,t,n){if(!await e.ok(`rev-parse-git-dir`))return null;let r=await e.text(`rev-parse-top`).catch(()=>null);if(r===null||C(r)!==C(t))return null;let i=await e.text(`symbolic-ref-head`).catch(()=>null),a=i===null||i===``,o=a?await e.text(`rev-parse`,`HEAD`).catch(()=>null):null;return{name:n===void 0||n===``?s(C(t)):n,branch:a?o?.slice(0,_e)??`HEAD`:i,detached:a}}async function ve(e,t){let n=await e.text(`symbolic-ref`).catch(()=>null),r=n?.startsWith(`refs/remotes/origin/`)?n.slice(20):null;if(r!==null&&r!==``&&await O(e,r)!==null)return r;for(let t of ge)if(await O(e,t)!==null)return t;return t!==null&&await O(e,t)!==null?t:null}async function O(e,t){let n=await e.text(`rev-parse`,`refs/heads/${t}`).catch(()=>null);return n===null||n===``?null:n}async function ye(e){return be(await e.text(`status`))}function be(e){return k(e).length}function k(e){let t=e.split(`\0`),n=[];for(let e=0;e<t.length;e++){let r=t[e];if(r===void 0||r===``)continue;let i=r.slice(0,2);n.push({status:i,path:r.slice(3)}),(i.startsWith(`R`)||i.startsWith(`C`))&&(e+=1)}return n}async function A(e){return await e.text(`rev-parse-shallow`).catch(()=>`false`)===`true`}var{mustBeValue:j,mustBeOid:M,refuse:N}=fe(`home`),xe=[`diff.algorithm=histogram`,`diff.context=3`,`diff.interHunkContext=0`,`diff.indentHeuristic=true`,`diff.renames=true`,`diff.renameLimit=1000`,`diff.relative=false`,`diff.srcPrefix=a/`,`diff.dstPrefix=b/`,`core.quotepath=false`,`diff.noprefix=false`,`diff.mnemonicPrefix=false`,`core.autocrlf=false`,`core.bigFileThreshold=512m`,`diff.suppressBlankEmpty=false`],Se=`4b825dc642cb6eb9a060e54bf8d69288fbee4904`,Ce=`%x00%H%x09%aI`;function we(e){let t=`%(refname:short)%09%(objectname)%09%(authordate:iso-strict)%09%(tree)`;return e===null?t:`${t}%09%(ahead-behind:${M(e)})`}function P(e,t){let n=j(`a ref`,t);return e===null?[n]:[`${j(`a ref`,e)}..${n}`]}function F(e){if(!Number.isInteger(e)||e<=0)throw N(`${e} is not a count`);return String(e)}function I(e){if(!/^\d{4}-\d{2}-\d{2}$/.test(e))throw N(`${e} is not a date`);return e}var L={"rev-parse":e=>[`rev-parse`,`--verify`,`--quiet`,`--end-of-options`,`${j(`a ref`,e)}^{commit}`],"rev-parse-git-dir":()=>[`rev-parse`,`--git-dir`],"rev-parse-top":()=>[`rev-parse`,`--show-toplevel`],"symbolic-ref-head":()=>[`symbolic-ref`,`--quiet`,`--short`,`--end-of-options`,`HEAD`],"rev-parse-shallow":()=>[`rev-parse`,`--is-shallow-repository`],"rev-parse-tree":()=>[`rev-parse`,`--verify`,`--quiet`,`HEAD^{tree}`],"symbolic-ref":()=>[`symbolic-ref`,`--quiet`,`--end-of-options`,`refs/remotes/origin/HEAD`],"for-each-ref":e=>[`for-each-ref`,`--format=${we(e)}`,`--`,`refs/heads/`],"rev-list-distance":(e,t)=>[`rev-list`,`--left-right`,`--count`,`--end-of-options`,`${M(e)}...${M(t)}`],"for-each-ref-tag":e=>[`for-each-ref`,`--format=%(creatordate:iso-strict)`,`--`,`refs/tags/${j(`a tag`,e)}`],"stash-list":()=>[`stash`,`list`,`--format=%H`],log:(e,t,n)=>[`log`,..._,`--format=${Ce}`,`--shortstat`,...n===null?[]:[`--since=${I(n)}`],`--end-of-options`,...P(e,t)],"log-numstat":e=>[`log`,..._,`--format=%x00%H%x09%aI`,`--numstat`,`--find-renames`,`--since=${I(e)}`,`--end-of-options`,`HEAD`],"log-patch":(e,t,n)=>[`log`,..._,`--diff-algorithm=histogram`,`--patch`,`--format=%x00%H`,`--find-renames`,`--unified=3`,`--max-count=${F(n)}`,`--end-of-options`,...P(e,t)],"rev-list-count":(e,t)=>[`rev-list`,`--count`,`--end-of-options`,...P(e,t)],"rev-list-trees":(e,t,n)=>[`rev-list`,`--format=%T`,`--max-count=${F(n)}`,`--end-of-options`,...P(e,t)],status:()=>[`status`,`--porcelain`,`-z`],"status-ignored":()=>[`status`,`--ignored`,`--porcelain`,`-z`],"ls-tree":()=>[`ls-tree`,`-r`,`-l`,`-z`,`--end-of-options`,`HEAD`],grep:()=>[`grep`,`--no-color`,`-I`,`-c`,`-z`,`-e`,``,`--end-of-options`,`HEAD`],"grep-plain":()=>[`grep`,`--no-color`,`-I`,`-c`,`-e`,``,`HEAD`],describe:()=>[`describe`,`--tags`,`--abbrev=0`],"merge-base":(e,t)=>[`merge-base`,`--end-of-options`,j(`a ref`,e),j(`a ref`,t)],"merge-base-ancestor":(e,t)=>[`merge-base`,`--is-ancestor`,`--end-of-options`,j(`a ref`,e),j(`a ref`,t)],"diff-tree-patch":(e,t)=>[`diff-tree`,..._,`--diff-algorithm=histogram`,`--patch`,`--find-renames`,`--unified=3`,`-r`,`--end-of-options`,M(e),M(t)]};Object.keys(L);function Te(e){return pe({tool:`home`,table:L,workspace:e,config:xe,answersWithStatus:[`grep`,`grep-plain`]})}var R=2e3;function z(e){let t=[];for(let n of e.split(`
3
- `)){if(n===``)continue;let[e,r,i,a,o]=n.split(` `);if(e===void 0||r===void 0||i===void 0||a===void 0)continue;let[s,c]=(o??``).split(` `);t.push({name:e,tip:r,lastCommit:i,tree:a,ahead:Number(s??0)||0,behind:Number(c??0)||0})}return t}var Ee=[`index `,`old mode `,`new mode `,`new file mode `,`deleted file mode `,`similarity index `,`dissimilarity index `,`\\ No newline`];function B(e){let t=e.split(`
4
- `).filter(e=>!Ee.some(t=>e.startsWith(t))).map(e=>e.startsWith(`@@`)?`@@`:e).join(`
5
- `).trim();return te(`sha256`).update(t).digest(`hex`)}function De(){return{trees:new Map,patches:new Map}}function Oe(e){return e.split(`
6
- `).filter(e=>e!==``&&!e.startsWith(`commit `))}function ke(e){let t=[];for(let n of e.split(`\0`)){if(n===``)continue;let e=n.indexOf(`
7
- `);if(e===-1)continue;let r=n.slice(e+1).trim();r!==``&&t.push(r)}return t}async function Ae(e,t,n,r,i,a){let o=`${r.tip}:${i}`,s=t.verdicts[o]??n[o]??await je(e,r,i,a);return n[o]=s,s}async function je(e,t,n,r){let i=await e.text(`merge-base`,t.tip,n).catch(()=>null);if(i===null||i===``)return!1;if((await Me(e,i,n,r)).includes(t.tree))return!0;let a=await e.text(`diff-tree-patch`,i===t.tip?Se:i,t.tip).catch(()=>null);return a===null?!1:a.trim()===``||(await Ne(e,i,n,r)).includes(B(a))}async function Me(e,t,n,r){let i=r.trees.get(t);if(i!==void 0)return i;let a=Oe(await e.text(`rev-list-trees`,t,n,R).catch(()=>``));return r.trees.set(t,a),a}async function Ne(e,t,n,r){let i=r.patches.get(t);if(i!==void 0)return i;let a=Number(await e.text(`rev-list-count`,t,n).catch(()=>`0`));if(!Number.isFinite(a)||a>2e3)return r.patches.set(t,[]),[];let o=ke(await e.text(`log-patch`,t,n,R).catch(()=>``)).map(B);return r.patches.set(t,o),o}function V(e,t){let n=Date.parse(e);return!Number.isNaN(n)&&t-n>30*864e5}async function Pe(e,t){if(t===null)return z(await e.text(`for-each-ref`,null));let n=await e.text(`for-each-ref`,t).catch(()=>null);if(n!==null)return z(n);let r=z(await e.text(`for-each-ref`,null));for(let n of r){let r=await e.text(`rev-list-distance`,n.tip,t).catch(()=>null);if(r===null)continue;let[i,a]=r.trim().split(/\s+/);n.ahead=Number(i??0)||0,n.behind=Number(a??0)||0}return r}async function Fe(e,t,n){let r=n.now??Date.now(),i=n.defaultBranch===null?null:await O(e,n.defaultBranch),a=await Pe(e,i),o=t.read(`squash`,4)??{version:4,verdicts:{}},s={},c=De(),l=[];for(let t of a){let a=t.name===n.current;l.push({name:t.name,current:a,lastCommit:t.lastCommit,ahead:t.ahead,state:await Ie(e,o,s,t,{current:a,isDefault:t.name===n.defaultBranch,defaultTip:i,bases:c,now:r})})}return t.write(`squash`,{version:4,verdicts:s}),l.sort((e,t)=>e.current===t.current?Date.parse(t.lastCommit)-Date.parse(e.lastCommit):e.current?-1:1),{default:n.defaultBranch,branches:l}}async function Ie(e,t,n,r,i){return i.current?`current`:i.isDefault?`default`:i.defaultTip===null?V(r.lastCommit,i.now)?`stale`:`ahead`:r.ahead===0?`merged`:await Ae(e,t,n,r,i.defaultTip,i.bases)?`squash`:V(r.lastCommit,i.now)?`stale`:`ahead`}var Le=`.tmp-`;function Re(e,n){t(c(e),{recursive:!0});let r=`${e}${Le}${process.pid}-${Math.random().toString(36).slice(2)}`;try{o(r,n),i(r,e)}finally{a(r,{force:!0})}}function ze(e,t,n,r){Re(T(e,t,n),r)}function Be(e,t,r){let i=T(e,t,r);try{return n(i,`utf8`)}catch{return null}}var H=`home`,U=`.home`;function W(e){let t=C(e.cacheDir);if(E(C(e.workspace),t))throw new y(H,`the cache directory ${t} is inside the workspace`);let n=!1;return{directory:t,read(e,n){try{let r=Be(H,t,`${U}/${e}.json`);if(r===null)return null;let i=JSON.parse(r);return i?.version===n?i:null}catch{return null}},write(e,r){try{return ze(H,t,`${U}/${e}.json`,JSON.stringify(r)),!0}catch(e){if(e?.code===`path-refused`)throw e;return n||(n=!0,console.error(`home: the cache directory ${t} cannot be written - ${String(e)}`)),!1}}}}var Ve=new Set([`packages`,`apps`,`libs`,`services`,`crates`,`modules`]),He=`(root)`,Ue=`other`;function We(e){let t=/^(.*)\{(.*) => (.*)\}(.*)$/.exec(e);if(t!==null){let[,e=``,,n=``,r=``]=t;return`${e}${n}${r}`.replace(/\/\//g,`/`)}let n=/ => /.exec(e);return n===null?e:e.slice(n.index+4)}function Ge(e){let t=e.split(`/`).filter(e=>e!==``),[n,r]=t;return n===void 0||t.length===1?He:Ve.has(n)&&r!==void 0&&t.length>2?`${n}/${r}`:n}function Ke(e){let t=[];for(let n of e.split(`\0`)){if(n===``)continue;let e=n.indexOf(`
8
- `);if(e===-1)continue;let[r,i]=n.slice(0,e).split(` `);if(!(r===void 0||i===void 0||i===``))for(let a of n.slice(e+1).split(`
9
- `)){let[e,n,o]=a.split(` `);e===void 0||n===void 0||o===void 0||o===``||t.push({hash:r,date:i,path:We(o),added:e===`-`?0:Number(e)||0,deleted:n===`-`?0:Number(n)||0})}}return t}function qe(){return{commits:new Set,lines:0}}function Je(e,t){let n=Math.floor(t/1e3)-30*86400,r=n-30*86400,i=new Map,a=new Map;for(let t of e){let e=K(t.date),o=e>=n?i:e>=r?a:null;if(o===null)continue;let s=Ge(t.path),c=o.get(s)??qe();c.commits.add(t.hash),c.lines+=t.added+t.deleted,o.set(s,c)}let o=[...new Set([...i.keys(),...a.keys()])].map(e=>({area:e,commits:i.get(e)?.commits.size??0,lines:i.get(e)?.lines??0,before:{commits:a.get(e)?.commits.size??0,lines:a.get(e)?.lines??0}})).sort((e,t)=>t.lines-e.lines||t.before.lines-e.before.lines||e.area.localeCompare(t.area));if(o.length<=8)return o;let s=o.slice(0,8),c=o.slice(8);return s.push({area:Ue,commits:c.reduce((e,t)=>e+t.commits,0),lines:c.reduce((e,t)=>e+t.lines,0),before:{commits:c.reduce((e,t)=>e+t.before.commits,0),lines:c.reduce((e,t)=>e+t.before.lines,0)}}),s}async function Ye(e,t=Date.now()){let n=new Date(t-74*864e5).toISOString().slice(0,10);return Je(Ke(await e.text(`log-numstat`,n).catch(()=>``)),t)}var Xe=2;function G(e){return e.slice(0,10)}function Ze(e){return Number(e.slice(11,13))}function Qe(e){let t=Date.UTC(Number(e.slice(0,4)),Number(e.slice(5,7))-1,Number(e.slice(8,10)),12);return(new Date(t).getUTCDay()+6)%7}function K(e){let t=Date.parse(e);return Number.isNaN(t)?0:Math.round(t/1e3)}function q(e){let t=[];for(let n of e.split(`\0`)){if(n===``)continue;let e=n.indexOf(`
10
- `),[r,i]=(e===-1?n:n.slice(0,e)).split(` `);if(r===void 0||i===void 0)continue;let a=/(\d+) files? changed(?:, (\d+) insertions?\(\+\))?(?:, (\d+) deletions?\(-\))?/.exec(e===-1?``:n.slice(e));t.push({hash:r,date:i,added:Number(a?.[2]??0),deleted:Number(a?.[3]??0)})}return t}function J(e){return{version:4,tip:e,commits:0,firstCommit:null,lastCommit:null,days:{},hours:Array.from({length:24},()=>0),weekdays:Array.from({length:7},()=>0),cut:!1}}function Y(e,t){let n={...e.days},r=[...e.hours],i=[...e.weekdays];for(let e of t){let t=G(e.date),[a=0,o=0,s=0]=n[t]??[0,0,0];n[t]=[a+1,o+e.added,s+e.deleted];let c=Ze(e.date);c>=0&&c<24&&(r[c]=(r[c]??0)+1);let l=Qe(e.date);l>=0&&l<7&&(i[l]=(i[l]??0)+1)}return{...e,commits:e.commits+t.length,firstCommit:$e(e.firstCommit,t),lastCommit:et(e.lastCommit,t),days:n,hours:r,weekdays:i}}function $e(e,t){let n=e;for(let e of t)G(e.date)<`1990-01-01`||(n===null||K(e.date)<K(n))&&(n=e.date);if(n!==null)return n;for(let e of t)(n===null||K(e.date)<K(n))&&(n=e.date);return n}function et(e,t){let n=e;for(let e of t)(n===null||K(e.date)>K(n))&&(n=e.date);return n}async function tt(e,t,n){let r=t.read(`history`,4);if(r?.tip===n)return r;let i=r&&!r.cut&&await e.ok(`merge-base-ancestor`,r.tip,n)?{...Y(r,q(await e.text(`log`,r.tip,n,null))),tip:n}:{...await nt(e,n),tip:n};return t.write(`history`,i),i}async function nt(e,t){try{return Y(J(t),q(await e.text(`log`,null,t,null)))}catch(n){let r=n;if(r?.code!==`upstream-failed`||r.overLimit!==!0)throw n;let i=new Date(Date.now()-Xe*365*864e5).toISOString().slice(0,10),a=await e.text(`log`,null,t,i);return{...Y(J(t),q(a)),cut:!0}}}function rt(e,t){let n=X(t),r=Object.keys(e).filter(e=>e>=`1990-01-01`&&e<=n).sort()[0]??t,i=new Map;for(let[t,a]of Object.entries(e)){let e=t>n?n:t<`1990-01-01`?r:t,[o=0,s=0,c=0]=i.get(e)??[0,0,0];i.set(e,[o+a[0],s+a[1],c+a[2]])}return[...i.entries()].sort(([e],[t])=>e.localeCompare(t)).map(([e,[t,n,r]])=>({date:e,commits:t,added:n,deleted:r}))}function it(e){if(e.length===0)return null;let t=[...e].sort(),n={days:1,from:t[0]??``,to:t[0]??``},r=t[0]??``,i=1;for(let e=1;e<t.length;e++){let a=t[e]??``;X(t[e-1]??``)===a?i+=1:(r=a,i=1),i>n.days&&(n={days:i,from:r,to:a})}return n}function X(e){let t=Date.parse(`${e}T00:00:00Z`);return new Date(t+864e5).toISOString().slice(0,10)}function at(e,t){let n=Date.parse(`${t}T00:00:00Z`)-Date.parse(`${e}T00:00:00Z`);return Math.max(1,Math.round(n/864e5)+1)}async function ot(e){let t=await e.text(`describe`).catch(()=>null);if(t===null||t===``)return null;let n=await e.text(`for-each-ref-tag`,t).catch(()=>null);return{name:t,date:n===null||n===``?``:n}}async function Z(e){let t=await e.text(`stash-list`).catch(()=>``);return t===``?0:t.split(`
11
- `).filter(e=>e!==``).length}async function st(e,t,n,r=Date.now()){let i=await e.text(`rev-parse`,`HEAD`).catch(()=>null),a=await ye(e).catch(()=>0),o=await A(e);if(i===null){let t=J(``);return{repository:{...n,changedFiles:a,firstCommit:null,lastCommit:null,commits:0,shallow:o,cut:!1},days:[],hours:t.hours,weekdays:t.weekdays,areas:[],milestones:{firstCommit:null,commitsPerDay:0,longestStreak:null,biggestDay:null,lastTag:null,stashes:await Z(e)}}}let s=await tt(e,t,i),c=new Date(r).toISOString().slice(0,10),l=rt(s.days,c),u=l.reduce((e,t)=>e===null||t.commits>e.commits?{date:t.date,commits:t.commits}:e,null),d=l[0]?.date??null;return{repository:{...n,changedFiles:a,firstCommit:s.firstCommit,lastCommit:s.lastCommit,commits:s.commits,shallow:o,cut:s.cut},days:l,hours:s.hours,weekdays:s.weekdays,areas:await Ye(e,r),milestones:{firstCommit:s.firstCommit,commitsPerDay:d===null?0:Math.round(s.commits/at(d,c)*100)/100,longestStreak:it(l.map(e=>e.date)),biggestDay:u,lastTag:await ot(e),stashes:await Z(e)}}}var Q=`other`,ct={dockerfile:`Dockerfile`,makefile:`Makefile`,license:`License`,"license.md":`License`,licence:`License`,readme:`Markdown`,".gitignore":`Config`,".gitattributes":`Config`,".dockerignore":`Config`,".editorconfig":`Config`,".npmrc":`Config`,".nvmrc":`Config`,".env":`Config`},lt={ts:`TypeScript`,tsx:`TypeScript`,mts:`TypeScript`,cts:`TypeScript`,js:`JavaScript`,jsx:`JavaScript`,mjs:`JavaScript`,cjs:`JavaScript`,py:`Python`,rb:`Ruby`,go:`Go`,rs:`Rust`,java:`Java`,kt:`Kotlin`,swift:`Swift`,c:`C`,h:`C`,cc:`C++`,cpp:`C++`,cxx:`C++`,hpp:`C++`,cs:`C#`,php:`PHP`,lua:`Lua`,sh:`Shell`,bash:`Shell`,zsh:`Shell`,fish:`Shell`,ps1:`Shell`,sql:`SQL`,html:`HTML`,htm:`HTML`,css:`CSS`,scss:`CSS`,sass:`CSS`,less:`CSS`,md:`Markdown`,mdx:`Markdown`,rst:`Markdown`,txt:`Text`,json:`JSON`,jsonc:`JSON`,yaml:`YAML`,yml:`YAML`,toml:`Config`,ini:`Config`,cfg:`Config`,conf:`Config`,xml:`XML`,svg:`Image`,png:`Image`,jpg:`Image`,jpeg:`Image`,gif:`Image`,webp:`Image`,avif:`Image`,ico:`Image`,mp3:`Audio`,wav:`Audio`,ogg:`Audio`,mp4:`Video`,webm:`Video`,mov:`Video`,woff:`Font`,woff2:`Font`,ttf:`Font`,otf:`Font`,pdf:`Document`,zip:`Archive`,gz:`Archive`,tar:`Archive`,lock:`Lockfile`};function ut(e){let t=e.slice(e.lastIndexOf(`/`)+1),n=ct[t.toLowerCase()];if(n!==void 0)return n;let r=t.lastIndexOf(`.`);return r<=0?Q:lt[t.slice(r+1).toLowerCase()]??`other`}function dt(e){let t=[];for(let n of e.split(`\0`)){if(n===``)continue;let e=n.indexOf(` `);if(e===-1)continue;let r=n.slice(0,e).split(/\s+/);if(r[1]!==`blob`)continue;let i=Number(r[3]);t.push({path:n.slice(e+1),bytes:Number.isFinite(i)?i:0})}return t}function ft(e){let t=0;for(let n of e.split(`
12
- `)){if(n===``)continue;let e=Math.max(n.lastIndexOf(`\0`),n.lastIndexOf(`:`));e!==-1&&(t+=Number(n.slice(e+1))||0)}return t}function pt(e){let t=e.reduce((e,t)=>e+t,0);if(t<=0)return e.map(()=>0);let n=e.map(e=>e/t*100),r=n.map(e=>Math.floor(e)),i=100-r.reduce((e,t)=>e+t,0),a=n.map((e,t)=>({at:t,remainder:e-Math.floor(e)})).sort((e,t)=>t.remainder-e.remainder);for(let{at:e}of a){if(i<=0)break;r[e]=(r[e]??0)+1,--i}return r}function mt(e){let t=Object.entries(e).filter(([,e])=>e>0).sort((e,t)=>t[1]-e[1]||e[0].localeCompare(t[0])),n=t.filter(([e])=>e!==Q).slice(0,6),r=t.filter(([e])=>!n.some(([t])=>t===e)).reduce((e,[,t])=>e+t,0),i=r>0?[...n,[Q,r]]:n,a=pt(i.map(([,e])=>e));return i.map(([e,t],n)=>({kind:e,bytes:t,share:a[n]??0}))}async function ht(e){let t=await e.text(`grep`).catch(()=>null);return t===null?e.text(`grep-plain`).catch(()=>null):t}async function gt(e,t){let n=await e.text(`rev-parse-tree`).catch(()=>null);if(n===null||n===``)return null;let r=t.read(`tree`,4);if(r?.tree===n)return r;let i=dt(await e.text(`ls-tree`)),a={},o=0;for(let e of i){let t=ut(e.path);a[t]=(a[t]??0)+e.bytes,o+=e.bytes}let s=await ht(e),c={version:4,tree:n,bytesByKind:a,files:i.length,lines:s===null?0:ft(s),bytes:o};return s!==null&&t.write(`tree`,c),c}async function _t(e,t,n){let r=0,i=[e];for(;i.length>0;){if(n()||Date.now()>t)return{bytes:r,whole:!1};let e=i.pop();if(e===void 0)continue;let a;try{a=await ne(e)}catch{continue}if(a.isSymbolicLink()){r+=a.size;continue}if(a.isFile()){r+=a.size;continue}if(a.isDirectory())try{for(let t of await re(e))i.push(u(e,t))}catch{}}return{bytes:r,whole:!0}}function vt(e){let t=e.limitMs??1e4,n=e.cache.read(`ignored`,4),r=null,i=!1;async function a(){let r=Date.now()+t,a=await e.git.text(`status-ignored`).catch(()=>``);if(i)return;let o=k(a).filter(e=>e.status===`!!`).map(e=>e.path),s=[],c=0,l=!0;for(let t of o){if(i)return;if(Date.now()>r){l=!1;break}let n=await _t(f(e.workspace,t),r,()=>i);l&&=n.whole,c+=n.bytes,s.push({path:t,bytes:n.bytes})}if(i)return;let u={version:4,bytes:c,atLeast:!l,countedAt:new Date().toISOString(),largest:s.sort((e,t)=>t.bytes-e.bytes).slice(0,2)};n=u,e.cache.write(`ignored`,u)}return{last:()=>n===null?null:{...n},start(){return i?Promise.resolve():(r??=a().finally(()=>{r=null}),r)},close(){i=!0}}}var $=`home`;function yt(e){let t=f(e.root),n=W({cacheDir:e.cacheDir,workspace:t}),r=Te(t),i=vt({git:r,cache:n,workspace:t,...e.walkLimitMs===void 0?{}:{limitMs:e.walkLimitMs}}),a=e.name??``,o=()=>new Date().toISOString();return{root:t,async history(){let e=await D(r,t,a);if(e===null)return{readAt:o(),repository:null};let i=await st(r,n,e);return{readAt:o(),...i}},async branches(){let e=await D(r,t,a);if(e===null)return{readAt:o(),repository:null};let i=e.detached?null:e.branch,s=await Fe(r,n,{defaultBranch:await ve(r,i),current:i});return{readAt:o(),repository:e,...s}},async tree(){let e=await D(r,t,a);if(e===null)return{readAt:o(),repository:null};let s=i.last();i.start().catch(()=>{});let c=await gt(r,n);return{readAt:o(),repository:e,kinds:c===null?[]:mt(c.bytesByKind),tracked:{files:c?.files??0,lines:c?.lines??0,bytes:c?.bytes??0},ignored:s}},toolPath(e){throw new oe($,e,`no entry`)},close(){i.close()}}}function bt(e){throw new y($,`home serves no workspace file: ${e}`)}function xt(t){return e(f(t))}export{yt as createHomeModule,xt as hasRoot,bt as refuseRaw,h as statusFor};
1
+ import{existsSync as e,mkdirSync as t,readFileSync as n,realpathSync as r,renameSync as i,rmSync as a,writeFileSync as o}from"node:fs";import{basename as s,dirname as c,isAbsolute as l,join as u,relative as d,resolve as f,sep as p}from"node:path";import{execFile as m}from"node:child_process";import{createHash as ee}from"node:crypto";import{lstat as te,readdir as ne}from"node:fs/promises";var h={all:0,work:0};function re(e){let t=e?.code;return typeof t==`string`&&ie.has(t)?t:null}var ie=new Set([`path-refused`,`no-entry`,`no-file`,`bad-request`,`too-large`,`upstream-failed`,`unreadable-answer`]),g=class extends Error{requested;code=`path-refused`;constructor(e,t){super(`${e}: refused path ${t}`),this.requested=t,this.name=`PathRefused`}},ae=class extends Error{requested;code=`no-file`;constructor(e,t,n=`not a file`){super(`${e}: ${n} - ${t}`),this.requested=t,this.name=`NoSuchFile`}};function oe(e){switch(re(e)){case`path-refused`:return 403;case`no-entry`:case`no-file`:return 404;case`bad-request`:return 400;case`too-large`:return 413;case`upstream-failed`:case`unreadable-answer`:return 502}return se(e)?404:500}function se(e){let t=e?.code;return t===`ENOENT`||t===`ENOTDIR`}var ce=`/usr/bin/git`,le=3e4,ue=64*1024*1024,de=[`core.fsmonitor=false`,`core.hooksPath=/dev/null`],_=[`--no-color`,`--no-ext-diff`,`--no-textconv`],fe={GIT_CONFIG_NOSYSTEM:`1`,GIT_CONFIG_GLOBAL:`/dev/null`,GIT_OPTIONAL_LOCKS:`0`,LC_ALL:`C`,PATH:`/usr/bin:/bin`},v=class extends Error{operation;said;tooMuch;overLimit;code=`upstream-failed`;constructor(e,t,n,r=!1,i=!1){super(`${e}: git ${t} failed - ${n}`),this.operation=t,this.said=n,this.tooMuch=r,this.overLimit=i,this.name=`GitFailed`}},y=class extends Error{code=`bad-request`;constructor(e,t){super(`${e}: ${t}`),this.name=`NotAllowed`}};function b(e){return/^[0-9a-f]{40}$|^[0-9a-f]{64}$/.test(e)}function pe(e){let t=t=>new y(e,t),n=(e,n)=>{if(n===``)throw t(`${e} is empty`);if(n.startsWith(`-`))throw t(`${e} is spelled as an option: ${n}`);if(/[\0\n\r]/.test(n))throw t(`${e} holds a line break or a null byte`);return n};return{mustBeValue:n,mustBeInsideWorkspace:(e,r)=>{if(n(e,r),r.startsWith(`/`))throw t(`${e} is absolute: ${r}`);if(r.split(`/`).includes(`..`))throw t(`${e} climbs out of the workspace: ${r}`);return r},mustBePath:(e,n)=>{if(n===``)throw t(`${e} is empty`);if(n.includes(`\0`))throw t(`${e} holds a null byte`);if(n.startsWith(`/`))throw t(`${e} is absolute: ${n}`);if(n.split(`/`).includes(`..`))throw t(`${e} climbs out of the workspace: ${n}`);return n},mustBeOid:e=>{if(!b(e))throw t(`${e} is not an object id`);return e},asCommit:e=>{if(!b(e))throw t(`${e} is not a resolved commit`);return e},refuse:t}}function me(e){let{tool:t,table:n,workspace:r}=e,i=[...e.config??[],...de].flatMap(e=>[`-c`,e]),a=new Set(e.answersWithStatus??[]),o=(e,...r)=>{let a=n[e];if(!a)throw new y(t,`no git operation named ${String(e)}`);return[...i,...a(...r)]},s=(e,n)=>new Promise((i,o)=>{m(ce,n,{cwd:r,env:{...fe},encoding:`buffer`,maxBuffer:ue,timeout:le,shell:!1,windowsHide:!0},(n,r,s)=>{let c=Buffer.isBuffer(r)?r:Buffer.from(String(r)),l=he(s);if(!n)return i({ok:!0,out:c,said:l});let u=n,d=u.code===`ERR_CHILD_PROCESS_STDIO_MAXBUFFER`;if(u.killed||u.code===`ENOENT`||d){let n=u.killed===!0||d;return o(new v(t,String(e),l||u.message,d,n))}i({ok:(typeof u.code==`number`?u.code:null)===1&&a.has(String(e))&&l.trim()===``,out:c,said:l})})}),c=(e,n)=>new v(t,String(e),n||`it said nothing`);return{vector:o,async text(e,...t){let n=await s(e,o(e,...t));if(!n.ok)throw c(e,n.said);return n.out.toString(`utf8`).replace(/\n$/,``)},async bytes(e,...t){let n=await s(e,o(e,...t));if(!n.ok)throw c(e,n.said);return n.out},async ok(e,...t){return(await s(e,o(e,...t))).ok},async commit(e){let n=o(`rev-parse`,e),r=await s(`rev-parse`,n),i=r.out.toString(`utf8`).trim();if(!r.ok||!b(i))throw new y(t,`there is no commit at ${e}`);return i}}}function he(e){return(Buffer.isBuffer(e)?e.toString(`utf8`):String(e)).split(`
2
+ `).map(e=>e.trim()).filter(Boolean)[0]??``}new Set(`txt text log json yaml yml toml ini cfg conf csv tsv xml css scss js jsx mjs cjs ts tsx py rb go rs java kt swift c h cpp hpp sh bash zsh fish sql graphql gql env diff patch lock gitignore editorconfig`.split(` `));function ge(e){return e.startsWith(`.`)}function x(e){let t=e,n=[];for(;;)try{return u(r(t),...n)}catch{let r=c(t);if(r===t)return e;n.unshift(s(t)),t=r}}function S(e){return x(f(e))}function C(e){return e.split(`/`).some(e=>e!==``&&ge(e))}function _e(e,t,n,r){let i=n.replace(/^\/+/,``);if(l(n)||i.includes(`\0`))throw new g(e,n);let a=r===`require`;if(C(i)!==a)throw new g(e,n);let o=x(f(t)),s=f(o,i);if(!T(o,s)||!T(o,x(s))||C(d(o,s).split(p).join(`/`))!==a)throw new g(e,n);return s}function w(e,t,n){return _e(e,t,n,`require`)}function T(e,t){return t===e||t.startsWith(e+p)}var ve=[`main`,`master`],ye=7;async function E(e,t,n,r=[]){if(!await e.ok(`rev-parse-git-dir`))return null;let i=await e.text(`rev-parse-top`).catch(()=>null);if(i===null||S(i)!==S(t))return null;let a=await e.text(`symbolic-ref-head`).catch(()=>null),o=a===null||a===``,c=o?await e.text(`rev-parse`,`HEAD`).catch(()=>null):null;return{name:n===void 0||n===``?s(S(t)):n,branch:o?c?.slice(0,ye)??`HEAD`:a,detached:o,toolPaths:r}}async function be(e,t){let n=await e.text(`symbolic-ref`).catch(()=>null),r=n?.startsWith(`refs/remotes/origin/`)?n.slice(20):null;if(r!==null&&r!==``&&await D(e,r)!==null)return r;for(let t of ve)if(await D(e,t)!==null)return t;return t!==null&&await D(e,t)!==null?t:null}async function D(e,t){let n=await e.text(`rev-parse`,`refs/heads/${t}`).catch(()=>null);return n===null||n===``?null:n}async function xe(e){return Se(await e.text(`status`))}function Se(e){return Ce(e).length}function Ce(e){let t=e.split(`\0`),n=[];for(let e=0;e<t.length;e++){let r=t[e];if(r===void 0||r===``)continue;let i=r.slice(0,2);n.push({status:i,path:r.slice(3)}),(i.startsWith(`R`)||i.startsWith(`C`))&&(e+=1)}return n}async function we(e){return await e.text(`rev-parse-shallow`).catch(()=>`false`)===`true`}var{mustBeValue:O,mustBeOid:k,refuse:A}=pe(`home`),Te=[`diff.algorithm=histogram`,`diff.context=3`,`diff.interHunkContext=0`,`diff.indentHeuristic=true`,`diff.renames=true`,`diff.renameLimit=1000`,`diff.relative=false`,`diff.srcPrefix=a/`,`diff.dstPrefix=b/`,`core.quotepath=false`,`diff.noprefix=false`,`diff.mnemonicPrefix=false`,`core.autocrlf=false`,`core.bigFileThreshold=512m`,`diff.suppressBlankEmpty=false`],Ee=`4b825dc642cb6eb9a060e54bf8d69288fbee4904`,j=`%x00%H%x09%aI`;function De(e){let t=`%(refname:short)%09%(objectname)%09%(authordate:iso-strict)%09%(tree)`;return e===null?t:`${t}%09%(ahead-behind:${k(e)})`}function M(e,t){let n=O(`a ref`,t);return e===null?[n]:[`${O(`a ref`,e)}..${n}`]}function N(e){if(!Number.isInteger(e)||e<=0)throw A(`${e} is not a count`);return String(e)}function Oe(e){if(!/^\d{4}-\d{2}-\d{2}$/.test(e))throw A(`${e} is not a date`);return e}var P={"rev-parse":e=>[`rev-parse`,`--verify`,`--quiet`,`--end-of-options`,`${O(`a ref`,e)}^{commit}`],"rev-parse-git-dir":()=>[`rev-parse`,`--git-dir`],"rev-parse-top":()=>[`rev-parse`,`--show-toplevel`],"symbolic-ref-head":()=>[`symbolic-ref`,`--quiet`,`--short`,`--end-of-options`,`HEAD`],"rev-parse-shallow":()=>[`rev-parse`,`--is-shallow-repository`],"rev-parse-tree":()=>[`rev-parse`,`--verify`,`--quiet`,`HEAD^{tree}`],"symbolic-ref":()=>[`symbolic-ref`,`--quiet`,`--end-of-options`,`refs/remotes/origin/HEAD`],"for-each-ref":e=>[`for-each-ref`,`--format=${De(e)}`,`--`,`refs/heads/`],"rev-list-distance":(e,t)=>[`rev-list`,`--left-right`,`--count`,`--end-of-options`,`${k(e)}...${k(t)}`],"for-each-ref-tag":e=>[`for-each-ref`,`--format=%(creatordate:iso-strict)`,`--`,`refs/tags/${O(`a tag`,e)}`],"stash-list":()=>[`stash`,`list`,`--format=%H`],log:(e,t,n)=>[`log`,..._,`--format=${j}`,`--numstat`,`--find-renames`,...n===null?[]:[`--since=${Oe(n)}`],`--end-of-options`,...M(e,t)],"log-spine":e=>[`log`,`--first-parent`,`--format=${j}`,`--end-of-options`,k(e)],"log-patch":(e,t,n)=>[`log`,..._,`--diff-algorithm=histogram`,`--patch`,`--format=%x00%H`,`--find-renames`,`--unified=3`,`--max-count=${N(n)}`,`--end-of-options`,...M(e,t)],"rev-list-count":(e,t)=>[`rev-list`,`--count`,`--end-of-options`,...M(e,t)],"rev-list-trees":(e,t,n)=>[`rev-list`,`--format=%T`,`--max-count=${N(n)}`,`--end-of-options`,...M(e,t)],status:()=>[`status`,`--porcelain`,`-z`],"status-ignored":()=>[`status`,`--ignored`,`--porcelain`,`-z`],"ls-tree":e=>[`ls-tree`,`-r`,`-l`,`-z`,`--end-of-options`,k(e)],grep:e=>[`grep`,`--no-color`,`-I`,`-c`,`-z`,`-e`,``,`--end-of-options`,k(e)],"grep-plain":e=>[`grep`,`--no-color`,`-I`,`-c`,`-e`,``,k(e)],describe:()=>[`describe`,`--tags`,`--abbrev=0`],"merge-base":(e,t)=>[`merge-base`,`--end-of-options`,O(`a ref`,e),O(`a ref`,t)],"merge-base-ancestor":(e,t)=>[`merge-base`,`--is-ancestor`,`--end-of-options`,O(`a ref`,e),O(`a ref`,t)],"diff-tree-patch":(e,t)=>[`diff-tree`,..._,`--diff-algorithm=histogram`,`--patch`,`--find-renames`,`--unified=3`,`-r`,`--end-of-options`,k(e),k(t)]};Object.keys(P);function ke(e){return me({tool:`home`,table:P,workspace:e,config:Te,answersWithStatus:[`grep`,`grep-plain`]})}var F=2e3;function I(e){let t=[];for(let n of e.split(`
3
+ `)){if(n===``)continue;let[e,r,i,a,o]=n.split(` `);if(e===void 0||r===void 0||i===void 0||a===void 0)continue;let[s,c]=(o??``).split(` `);t.push({name:e,tip:r,lastCommit:i,tree:a,ahead:Number(s??0)||0,behind:Number(c??0)||0})}return t}var Ae=[`index `,`old mode `,`new mode `,`new file mode `,`deleted file mode `,`similarity index `,`dissimilarity index `,`\\ No newline`];function L(e){let t=e.split(`
4
+ `).filter(e=>!Ae.some(t=>e.startsWith(t))).map(e=>e.startsWith(`@@`)?`@@`:e).join(`
5
+ `).trim();return ee(`sha256`).update(t).digest(`hex`)}function je(){return{trees:new Map,patches:new Map}}function Me(e){return e.split(`
6
+ `).filter(e=>e!==``&&!e.startsWith(`commit `))}function Ne(e){let t=[];for(let n of e.split(`\0`)){if(n===``)continue;let e=n.indexOf(`
7
+ `);if(e===-1)continue;let r=n.slice(e+1).trim();r!==``&&t.push(r)}return t}async function Pe(e,t,n,r,i,a){let o=`${r.tip}:${i}`,s=t.verdicts[o]??n[o]??await Fe(e,r,i,a);return n[o]=s,s}async function Fe(e,t,n,r){let i=await e.text(`merge-base`,t.tip,n).catch(()=>null);if(i===null||i===``)return!1;if((await Ie(e,i,n,r)).includes(t.tree))return!0;let a=await e.text(`diff-tree-patch`,i===t.tip?Ee:i,t.tip).catch(()=>null);return a===null?!1:a.trim()===``||(await Le(e,i,n,r)).includes(L(a))}async function Ie(e,t,n,r){let i=r.trees.get(t);if(i!==void 0)return i;let a=Me(await e.text(`rev-list-trees`,t,n,F).catch(()=>``));return r.trees.set(t,a),a}async function Le(e,t,n,r){let i=r.patches.get(t);if(i!==void 0)return i;let a=Number(await e.text(`rev-list-count`,t,n).catch(()=>`0`));if(!Number.isFinite(a)||a>2e3)return r.patches.set(t,[]),[];let o=Ne(await e.text(`log-patch`,t,n,F).catch(()=>``)).map(L);return r.patches.set(t,o),o}function R(e,t){let n=Date.parse(e);return!Number.isNaN(n)&&t-n>30*864e5}async function Re(e,t){if(t===null)return I(await e.text(`for-each-ref`,null));let n=await e.text(`for-each-ref`,t).catch(()=>null);if(n!==null)return I(n);let r=I(await e.text(`for-each-ref`,null));for(let n of r){let r=await e.text(`rev-list-distance`,n.tip,t).catch(()=>null);if(r===null)continue;let[i,a]=r.trim().split(/\s+/);n.ahead=Number(i??0)||0,n.behind=Number(a??0)||0}return r}async function ze(e,t,n){let r=n.now??Date.now(),i=n.defaultBranch===null?null:await D(e,n.defaultBranch),a=await Re(e,i),o=t.read(`squash`,5)??{version:5,verdicts:{}},s={},c=je(),l=[];for(let t of a){let a=t.name===n.current;l.push({name:t.name,current:a,lastCommit:t.lastCommit,ahead:t.ahead,state:await Be(e,o,s,t,{current:a,isDefault:t.name===n.defaultBranch,defaultTip:i,bases:c,now:r})})}return t.write(`squash`,{version:5,verdicts:s}),l.sort((e,t)=>e.current===t.current?Date.parse(t.lastCommit)-Date.parse(e.lastCommit):e.current?-1:1),{default:n.defaultBranch,branches:l}}async function Be(e,t,n,r,i){return i.current?`current`:i.isDefault?`default`:i.defaultTip===null?R(r.lastCommit,i.now)?`stale`:`ahead`:r.ahead===0?`merged`:await Pe(e,t,n,r,i.defaultTip,i.bases)?`squash`:R(r.lastCommit,i.now)?`stale`:`ahead`}var Ve=`.tmp-`;function He(e,n){t(c(e),{recursive:!0});let r=`${e}${Ve}${process.pid}-${Math.random().toString(36).slice(2)}`;try{o(r,n),i(r,e)}finally{a(r,{force:!0})}}function Ue(e,t,n,r){He(w(e,t,n),r)}function We(e,t,r){let i=w(e,t,r);try{return n(i,`utf8`)}catch{return null}}var z=`home`,B=`.home`;function Ge(e){let t=S(e.cacheDir);if(T(S(e.workspace),t))throw new y(z,`the cache directory ${t} is inside the workspace`);let n=!1;return{directory:t,read(e,n){try{let r=We(z,t,`${B}/${e}.json`);if(r===null)return null;let i=JSON.parse(r);return i?.version===n?i:null}catch{return null}},write(e,r){try{return Ue(z,t,`${B}/${e}.json`,JSON.stringify(r)),!0}catch(e){if(e?.code===`path-refused`)throw e;return n||(n=!0,console.error(`home: the cache directory ${t} cannot be written - ${String(e)}`)),!1}}}}function Ke(e,t=[]){let n=f(e),r=[];for(let e of t){if(e===``)continue;let t=d(n,f(e)).split(p).join(`/`);if(t===``||t===`..`||t.startsWith(`../`)||t.startsWith(`/`))continue;let i=`${t}/`;r.includes(i)||r.push(i)}return{prefixes:r,holds:e=>r.some(t=>e.startsWith(t))}}function V(e,t){return e===void 0||e.length!==t.prefixes.length?!1:e.every((e,n)=>e===t.prefixes[n])}var qe=2;function H(e){return e.slice(0,10)}function Je(e){return Number(e.slice(11,13))}function Ye(e){let t=Date.UTC(Number(e.slice(0,4)),Number(e.slice(5,7))-1,Number(e.slice(8,10)),12);return(new Date(t).getUTCDay()+6)%7}function U(e){let t=Date.parse(e);return Number.isNaN(t)?0:Math.round(t/1e3)}function Xe(e){let t=/^(.*)\{(.*) => (.*)\}(.*)$/.exec(e);if(t!==null){let[,e=``,,n=``,r=``]=t;return`${e}${n}${r}`.replace(/\/\//g,`/`)}let n=/ => /.exec(e);return n===null?e:e.slice(n.index+4)}function W(e){let t=[];for(let n of e.split(`\0`)){if(n===``)continue;let e=n.indexOf(`
8
+ `),[r,i]=(e===-1?n:n.slice(0,e)).split(` `);r===void 0||i===void 0||t.push({hash:r,date:i,body:e===-1?``:n.slice(e+1)})}return t}function G(e,t){return W(e).map(({hash:e,date:n,body:r})=>{let i={all:0,work:0},a={all:0,work:0};for(let e of r===``?[]:r.split(`
9
+ `)){let[n,r,o]=e.split(` `);if(n===void 0||r===void 0||o===void 0||o===``)continue;let s=n===`-`?0:Number(n)||0,c=r===`-`?0:Number(r)||0;i.all+=s,a.all+=c,!t.holds(Xe(o))&&(i.work+=s,a.work+=c)}return{hash:e,date:n,added:i,deleted:a}})}function K(e,t){return{version:5,tip:e,tools:t.prefixes,commits:0,firstCommit:null,lastCommit:null,days:{},hours:Array.from({length:24},()=>0),weekdays:Array.from({length:7},()=>0),cut:!1}}function q(e,t){let n={...e.days},r=[...e.hours],i=[...e.weekdays];for(let e of t){let t=H(e.date),[a=0,o=0,s=0,c=0,l=0]=n[t]??[0,0,0,0,0];n[t]=[a+1,o+e.added.all,s+e.deleted.all,c+e.added.work,l+e.deleted.work];let u=Je(e.date);u>=0&&u<24&&(r[u]=(r[u]??0)+1);let d=Ye(e.date);d>=0&&d<7&&(i[d]=(i[d]??0)+1)}return{...e,commits:e.commits+t.length,firstCommit:Ze(e.firstCommit,t),lastCommit:Qe(e.lastCommit,t),days:n,hours:r,weekdays:i}}function Ze(e,t){let n=e;for(let e of t)H(e.date)<`1990-01-01`||(n===null||U(e.date)<U(n))&&(n=e.date);if(n!==null)return n;for(let e of t)(n===null||U(e.date)<U(n))&&(n=e.date);return n}function Qe(e,t){let n=e;for(let e of t)(n===null||U(e.date)>U(n))&&(n=e.date);return n}async function $e(e,t,n,r){let i=t.read(`history`,5),a=i!==null&&V(i.tools,r)?i:null;if(a?.tip===n)return a;let o=a&&!a.cut&&await e.ok(`merge-base-ancestor`,a.tip,n)?{...q(a,G(await e.text(`log`,a.tip,n,null),r)),tip:n}:{...await et(e,n,r),tip:n};return t.write(`history`,o),o}async function et(e,t,n){try{return q(K(t,n),G(await e.text(`log`,null,t,null),n))}catch(r){let i=r;if(i?.code!==`upstream-failed`||i.overLimit!==!0)throw r;let a=new Date(Date.now()-qe*365*864e5).toISOString().slice(0,10),o=await e.text(`log`,null,t,a);return{...q(K(t,n),G(o,n)),cut:!0}}}function tt(e,t){let n=J(t),r=Object.keys(e).filter(e=>e>=`1990-01-01`&&e<=n).sort()[0]??t,i=new Map;for(let[t,a]of Object.entries(e)){let e=t>n?n:t<`1990-01-01`?r:t,o=i.get(e)??[0,0,0,0,0];i.set(e,[o[0]+a[0],o[1]+a[1],o[2]+a[2],o[3]+a[3],o[4]+a[4]])}return[...i.entries()].sort(([e],[t])=>e.localeCompare(t)).map(([e,[t,n,r,i,a]])=>({date:e,commits:t,added:{all:n,work:i},deleted:{all:r,work:a}}))}function nt(e){if(e.length===0)return null;let t=[...e].sort(),n={days:1,from:t[0]??``,to:t[0]??``},r=t[0]??``,i=1;for(let e=1;e<t.length;e++){let a=t[e]??``;J(t[e-1]??``)===a?i+=1:(r=a,i=1),i>n.days&&(n={days:i,from:r,to:a})}return n}function J(e){let t=Date.parse(`${e}T00:00:00Z`);return new Date(t+864e5).toISOString().slice(0,10)}function rt(e,t){let n=Date.parse(`${t}T00:00:00Z`)-Date.parse(`${e}T00:00:00Z`);return Math.max(1,Math.round(n/864e5)+1)}async function it(e){let t=await e.text(`describe`).catch(()=>null);if(t===null||t===``)return null;let n=await e.text(`for-each-ref-tag`,t).catch(()=>null);return{name:t,date:n===null||n===``?``:n}}async function Y(e){let t=await e.text(`stash-list`).catch(()=>``);return t===``?0:t.split(`
10
+ `).filter(e=>e!==``).length}async function at(e,t,n,r,i=Date.now()){let a=await e.text(`rev-parse`,`HEAD`).catch(()=>null),o=await xe(e).catch(()=>0),s=await we(e);if(a===null){let t=K(``,r);return{repository:{...n,changedFiles:o,firstCommit:null,lastCommit:null,commits:0,shallow:s,cut:!1},days:[],hours:t.hours,weekdays:t.weekdays,milestones:{firstCommit:null,commitsPerDay:0,longestStreak:null,biggestDay:null,lastTag:null,stashes:await Y(e)}}}let c=await $e(e,t,a,r),l=new Date(i).toISOString().slice(0,10),u=tt(c.days,l),d=u.reduce((e,t)=>e===null||t.commits>e.commits?{date:t.date,commits:t.commits}:e,null),f=u[0]?.date??null;return{repository:{...n,changedFiles:o,firstCommit:c.firstCommit,lastCommit:c.lastCommit,commits:c.commits,shallow:s,cut:c.cut},days:u,hours:c.hours,weekdays:c.weekdays,milestones:{firstCommit:c.firstCommit,commitsPerDay:f===null?0:Math.round(c.commits/rt(f,l)*100)/100,longestStreak:nt(u.map(e=>e.date)),biggestDay:d,lastTag:await it(e),stashes:await Y(e)}}}var X=`other`,ot={dockerfile:`Dockerfile`,makefile:`Makefile`,license:`License`,"license.md":`License`,licence:`License`,readme:`Markdown`,".gitignore":`Config`,".gitattributes":`Config`,".dockerignore":`Config`,".editorconfig":`Config`,".npmrc":`Config`,".nvmrc":`Config`,".env":`Config`},st={ts:`TypeScript`,tsx:`TypeScript`,mts:`TypeScript`,cts:`TypeScript`,js:`JavaScript`,jsx:`JavaScript`,mjs:`JavaScript`,cjs:`JavaScript`,py:`Python`,rb:`Ruby`,go:`Go`,rs:`Rust`,java:`Java`,kt:`Kotlin`,swift:`Swift`,c:`C`,h:`C`,cc:`C++`,cpp:`C++`,cxx:`C++`,hpp:`C++`,cs:`C#`,php:`PHP`,lua:`Lua`,sh:`Shell`,bash:`Shell`,zsh:`Shell`,fish:`Shell`,ps1:`Shell`,sql:`SQL`,html:`HTML`,htm:`HTML`,css:`CSS`,scss:`CSS`,sass:`CSS`,less:`CSS`,md:`Markdown`,mdx:`Markdown`,rst:`Markdown`,txt:`Text`,json:`JSON`,jsonc:`JSON`,yaml:`YAML`,yml:`YAML`,toml:`Config`,ini:`Config`,cfg:`Config`,conf:`Config`,xml:`XML`,svg:`Image`,png:`Image`,jpg:`Image`,jpeg:`Image`,gif:`Image`,webp:`Image`,avif:`Image`,ico:`Image`,mp3:`Audio`,wav:`Audio`,ogg:`Audio`,mp4:`Video`,webm:`Video`,mov:`Video`,woff:`Font`,woff2:`Font`,ttf:`Font`,otf:`Font`,pdf:`Document`,zip:`Archive`,gz:`Archive`,tar:`Archive`,lock:`Lockfile`};function ct(e){let t=e.slice(e.lastIndexOf(`/`)+1),n=ot[t.toLowerCase()];if(n!==void 0)return n;let r=t.lastIndexOf(`.`);return r<=0?X:st[t.slice(r+1).toLowerCase()]??`other`}function lt(e){let t=[];for(let n of e.split(`\0`)){if(n===``)continue;let e=n.indexOf(` `);if(e===-1)continue;let r=n.slice(0,e).split(/\s+/);if(r[1]!==`blob`)continue;let i=Number(r[3]);t.push({path:n.slice(e+1),bytes:Number.isFinite(i)?i:0})}return t}function ut(e){let t=[];for(let n of e.split(`
11
+ `)){if(n===``)continue;let e=Math.max(n.lastIndexOf(`\0`),n.lastIndexOf(`:`));if(e===-1)continue;let r=n.slice(0,e),i=r.indexOf(`:`);t.push({path:i===-1?``:r.slice(i+1),lines:Number(n.slice(e+1))||0})}return t}function dt(e){let t=e.reduce((e,t)=>e+t,0);if(t<=0)return e.map(()=>0);let n=e.map(e=>e/t*100),r=n.map(e=>Math.floor(e)),i=100-r.reduce((e,t)=>e+t,0),a=n.map((e,t)=>({at:t,remainder:e-Math.floor(e)})).sort((e,t)=>t.remainder-e.remainder);for(let{at:e}of a){if(i<=0)break;r[e]=(r[e]??0)+1,--i}return r}function Z(e){let t=Object.entries(e).filter(([,e])=>e>0).sort((e,t)=>t[1]-e[1]||e[0].localeCompare(t[0])),n=t.filter(([e])=>e!==X).slice(0,6),r=t.filter(([e])=>!n.some(([t])=>t===e)).reduce((e,[,t])=>e+t,0),i=r>0?[...n,[X,r]]:n,a=dt(i.map(([,e])=>e));return i.map(([e,t],n)=>({kind:e,bytes:t,share:a[n]??0}))}async function ft(e,t){let n=await e.text(`grep`,t).catch(()=>null);return n===null?e.text(`grep-plain`,t).catch(()=>null):n}async function Q(e,t,n){let r=lt(await e.text(`ls-tree`,t)),i={},a={},o=0,s=0,c=0;for(let e of r){let t=ct(e.path);i[t]=(i[t]??0)+e.bytes,s+=e.bytes,!n.holds(e.path)&&(a[t]=(a[t]??0)+e.bytes,c+=e.bytes,o+=1)}let l=await ft(e,t),u=0,d=0;for(let e of ut(l??``))u+=e.lines,n.holds(e.path)||(d+=e.lines);return{bytesByKind:i,bytesByKindWork:a,files:{all:r.length,work:o},lines:{all:u,work:d},bytes:{all:s,work:c},counted:l!==null}}async function pt(e,t,n){let r=await e.text(`rev-parse-tree`).catch(()=>null);if(r===null||r===``)return null;let i=t.read(`tree`,5);if(i?.tree===r&&V(i.tools,n))return i;let{counted:a,...o}=await Q(e,r,n),s={version:5,tree:r,tools:n.prefixes,...o};return a&&t.write(`tree`,s),s}async function mt(e,t,n){let r=0,i=[e];for(;i.length>0;){if(n()||Date.now()>t)return{bytes:r,whole:!1};let e=i.pop();if(e===void 0)continue;let a;try{a=await te(e)}catch{continue}if(a.isSymbolicLink()){r+=a.size;continue}if(a.isFile()){r+=a.size;continue}if(a.isDirectory())try{for(let t of await ne(e))i.push(u(e,t))}catch{}}return{bytes:r,whole:!0}}function ht(e){let t=e.limitMs??1e4,n=e.cache.read(`ignored`,5),r=null,i=!1;async function a(){let r=Date.now()+t,a=await e.git.text(`status-ignored`).catch(()=>``);if(i)return;let o=Ce(a).filter(e=>e.status===`!!`).map(e=>e.path),s=0,c=!0;for(let t of o){if(i)return;if(Date.now()>r){c=!1;break}let n=await mt(f(e.workspace,t),r,()=>i);c&&=n.whole,s+=n.bytes}if(i)return;let l={version:5,bytes:s,atLeast:!c,countedAt:new Date().toISOString()};n=l,e.cache.write(`ignored`,l)}return{last:()=>n===null?null:{...n},start(){return i?Promise.resolve():(r??=a().finally(()=>{r=null}),r)},close(){i=!0}}}function $(e){return Date.parse(`${H(e)}T00:00:00Z`)}function gt(e,t=60){let n=[...e].reverse(),r=n[0],i=n[n.length-1];if(r===void 0||i===void 0)return[];if(n.length<=t)return n;let a=$(r.date),o=Math.max(1,$(i.date)-a),s=t-1,c=new Map;for(let e of n){let t=($(e.date)-a)/o,n=Number.isFinite(t)?Math.floor(t*s):0;c.set(Math.min(s-1,Math.max(0,n)),e)}let l=[...c.entries()].sort(([e],[t])=>e-t).map(([,e])=>e);return l[0]?.oid!==r.oid&&l.unshift(r),l[l.length-1]?.oid!==i.oid&&l.push(i),l}async function _t(e,t){return W(await e.text(`log-spine`,t).catch(()=>``)).map(e=>({oid:e.hash,date:e.date}))}function vt(e){let t=e.limitMs??1e4,n=e.cache.read(`growth`,5),r=n!==null&&V(n.tools,e.tools)?n:null,i=null,a=!1;async function o(t){let n=await Q(e.git,t,e.tools).catch(()=>null);return n===null||!n.counted?null:{files:n.files,lines:n.lines}}async function s(t){let n=gt(await _t(e.git,t)),i={};for(let e of n){let t=r?.points[e.oid];t!==void 0&&(i[e.oid]=t)}return{version:5,tip:t,tools:e.tools.prefixes,samples:n,points:i}}async function c(n){let i=Date.now()+t,c=r!==null&&r.tip===n?r:await s(n);if(!a){c!==r&&(r=c,e.cache.write(`growth`,c));for(let t of[...c.samples].reverse()){if(a||Date.now()>i)return;if(c.points[t.oid]!==void 0)continue;let n=await o(t.oid);if(a)return;n!==null&&(c={...c,points:{...c.points,[t.oid]:n}},r=c,e.cache.write(`growth`,c))}}}return{last(){let e=r;if(e===null)return{points:[],counted:0,of:0};let t=[];for(let n of e.samples){let r=e.points[n.oid];r!==void 0&&t.push({date:H(n.date),files:r.files,lines:r.lines})}return{points:t,counted:t.length,of:e.samples.length}},start(e){return a?Promise.resolve():(i??=c(e).catch(()=>{}).finally(()=>{i=null}),i)},close(){a=!0}}}var yt=`home`;function bt(e){let t=f(e.root),n=Ge({cacheDir:e.cacheDir,workspace:t}),r=ke(t),i=Ke(t,e.toolPaths),a=ht({git:r,cache:n,workspace:t,...e.walkLimitMs===void 0?{}:{limitMs:e.walkLimitMs}}),o=vt({git:r,cache:n,tools:i,...e.sampleLimitMs===void 0?{}:{limitMs:e.sampleLimitMs}}),s=e.name??``,c=()=>new Date().toISOString();return{root:t,async history(){let e=await E(r,t,s,i.prefixes);if(e===null)return{readAt:c(),repository:null};let a=await at(r,n,e,i);return{readAt:c(),...a}},async branches(){let e=await E(r,t,s,i.prefixes);if(e===null)return{readAt:c(),repository:null};let a=e.detached?null:e.branch,o=await ze(r,n,{defaultBranch:await be(r,a),current:a});return{readAt:c(),repository:e,...o}},async tree(){let e=await E(r,t,s,i.prefixes);if(e===null)return{readAt:c(),repository:null};let l=a.last();a.start().catch(()=>{});let u=await pt(r,n,i),d=o.last(),f=await r.text(`rev-parse`,`HEAD`).catch(()=>null),p=f!==null&&f!==``;p&&o.start(f).catch(()=>{});let m=p&&(d.of===0||d.counted<d.of);return{readAt:c(),repository:e,kinds:u===null?[]:Z(u.bytesByKind),kindsWork:u===null?[]:Z(u.bytesByKindWork),tracked:{files:u?.files??h,lines:u?.lines??h,bytes:u?.bytes??h},ignored:l,growth:{...d,filling:m}}},toolPath(e){throw new ae(yt,e,`no entry`)},close(){a.close(),o.close()}}}function xt(e){throw new y(yt,`home serves no workspace file: ${e}`)}function St(t){return e(f(t))}export{bt as createHomeModule,St as hasRoot,xt as refuseRaw,oe as statusFor};