claude-code-session-manager 0.97.0 → 0.98.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/{DataModel-D93FoaOm.js → DataModel-DCEgMTjH.js} +1 -1
- package/dist/assets/{History-CXxxqNP1.js → History-Bfdoywlh.js} +1 -1
- package/dist/assets/{Hooks-CzeYFQjq.js → Hooks-CKDJjTJV.js} +1 -1
- package/dist/assets/{HostBilko-nESrTRIg.js → HostBilko-CDVHE0hT.js} +1 -1
- package/dist/assets/{Library-D2zPkwOC.js → Library-7akfgy67.js} +1 -1
- package/dist/assets/{MarkdownEditor-DbinP78A.js → MarkdownEditor-DDesiqet.js} +1 -1
- package/dist/assets/{McpServers-Bu_sVGLr.js → McpServers-D4lZtXof.js} +1 -1
- package/dist/assets/{Memory-BgiI6LZ_.js → Memory-CeI8G1w5.js} +1 -1
- package/dist/assets/{Permissions-C1MMzZRm.js → Permissions-BGleLja4.js} +1 -1
- package/dist/assets/{Plugins-Dhu6wAZi.js → Plugins-P4eCXy_S.js} +2 -2
- package/dist/assets/{ProvenanceBadge-C3AcWKMG.js → ProvenanceBadge-BFczzI1B.js} +1 -1
- package/dist/assets/{SaveBar-plwYm0iO.js → SaveBar-l9jnEMES.js} +1 -1
- package/dist/assets/{Scheduler-BVYTeh39.js → Scheduler-C_phpeUS.js} +1 -1
- package/dist/assets/{ScopeSwitcher-DFy0vv_o.js → ScopeSwitcher-CjJi8ST5.js} +1 -1
- package/dist/assets/{Settings-DIhGgdfs.js → Settings-BIwZ3FGQ.js} +1 -1
- package/dist/assets/{SkillReferenceGraph-DsI7hRPB.js → SkillReferenceGraph-CjbO01Sg.js} +1 -1
- package/dist/assets/{Skills-3E748UfB.js → Skills-BxZ9_fCR.js} +1 -1
- package/dist/assets/{SystemPrompt-BqmfUJOd.js → SystemPrompt-D8vfFb8b.js} +1 -1
- package/dist/assets/{TagLibrary-CPz6fO8Q.js → TagLibrary-2vzUo7YL.js} +1 -1
- package/dist/assets/{TiptapBody-D9EoBQ1P.js → TiptapBody-B8ZfbK90.js} +1 -1
- package/dist/assets/{Toggle-BHAmZNDn.js → Toggle-BbW4nGGf.js} +1 -1
- package/dist/assets/{index-tn5JIVPj.js → index-Cd98Q1lD.js} +3 -3
- package/dist/assets/{settingsSchema-Crqy_aNz.js → settingsSchema-IhUfucCF.js} +1 -1
- package/dist/index.html +1 -1
- package/package.json +2 -1
- package/plugins/session-manager-dev/skills/builder/4-manual/SKILL.md +2 -0
- package/src/main/__tests__/prdCreateAdoption.test.cjs +205 -0
- package/src/main/__tests__/queueOpsAutoArchive.test.cjs +63 -6
- package/src/main/__tests__/scheduler-mutate-reentrancy.test.cjs +117 -0
- package/src/main/build-info.json +4 -4
- package/src/main/lib/__tests__/watchdog-helpers.test.cjs +66 -0
- package/src/main/lib/prdCreate.cjs +32 -7
- package/src/main/lib/watchdogHelpers.cjs +21 -5
- package/src/main/queueOps.cjs +17 -6
- package/src/main/scheduler.cjs +65 -5
|
@@ -1 +1 @@
|
|
|
1
|
-
import{az as b,ak as n,S as N,aR as k,ax as K}from"./index-tn5JIVPj.js";function T({node:e,targetScope:r,onOverride:s,schema:a,rootLabel:m}){const[f,x]=b.useState(""),[u,o]=b.useState(!0),g=[],d=e.kind==="object"&&Object.keys(e.children).length===0,y=((a==null?void 0:a.rootKeys())??[]).length>0;return n.jsxs("div",{className:"h-full flex flex-col",children:[n.jsxs("div",{className:"shrink-0 border-b border-line bg-bg-elev px-3 py-1.5 flex items-center gap-2 text-xs",children:[n.jsxs("span",{className:"text-fg-faint",children:["merged · overrides → ",n.jsx("span",{className:"text-fg-dim",children:N[r].label})]}),y&&n.jsxs("label",{className:"flex items-center gap-1 text-fg-faint cursor-pointer",children:[n.jsx("input",{type:"checkbox",checked:u,onChange:t=>o(t.target.checked),className:"accent-accent"}),"show unset keys"]}),n.jsx("div",{className:"flex-1"}),n.jsx("input",{value:f,onChange:t=>x(t.target.value),placeholder:"filter keys or descriptions…",className:"bg-bg border border-line rounded px-2 py-0.5 text-xs text-fg w-56"})]}),n.jsx("div",{className:"flex-1 overflow-auto px-3 py-2 font-mono text-xs",children:d&&!u?n.jsx("div",{className:"text-fg-faint italic px-2 py-4",children:"no settings resolved — all scope files empty or missing"}):n.jsx(E,{node:e,path:g,label:m??"(root)",targetScope:r,onOverride:s,filter:f,depth:0,schema:a,showGhosts:u,defaultOpen:!0})})]})}function E(e){return e.node.kind==="object"?n.jsx(P,{...e,node:e.node}):e.node.kind==="array"?n.jsx(R,{...e,node:e.node}):n.jsx(J,{...e,node:e.node})}function A(e,r){return r.trim()?e.toLowerCase().includes(r.toLowerCase()):!0}function w(e,r,s){return!!(!s.trim()||e.some(a=>A(a,s))||r!=null&&r.description&&A(r.description,s))}function P({node:e,path:r,label:s,targetScope:a,onOverride:m,filter:f,depth:x,schema:u,showGhosts:o,defaultOpen:g}){const[d,h]=b.useState(g??x<2),y=(u==null?void 0:u.at(r))??null,t=new Set(Object.keys(e.children)),i=o?(y==null?void 0:y.knownChildren)??[]:[],c=Array.from(new Set([...t,...i])).sort(),l=b.useMemo(()=>f.trim()?c.filter(p=>{const v=(u==null?void 0:u.at([...r,p]))??null;return w([...r,p],v,f)?!0:t.has(p)?L(e.children[p],[...r,p],f,u):!1}):c,[c.join(","),f,e,r.join("."),u]);if(f.trim()&&l.length===0&&!w(r,y,f))return null;if(r.length===0)return n.jsx("div",{children:l.map(p=>j(p))});return n.jsxs("div",{children:[n.jsxs("div",{className:"flex items-center gap-1 py-0.5 hover:bg-bg-elev/50 rounded cursor-pointer",style:{paddingLeft:x*14},onClick:()=>h(!d),children:[n.jsx("span",{className:"text-fg-faint w-3 shrink-0",children:d?"▾":"▸"}),n.jsx("span",{className:"text-fg",children:s}),n.jsxs("span",{className:"text-fg-faint",children:[" {",t.size,i.length>t.size?`/${new Set([...t,...i]).size}`:"","}"]}),(y==null?void 0:y.description)&&n.jsxs("span",{className:"text-fg-faint truncate max-w-md",title:y.description,children:["— ",y.description]})]}),d&&l.map(p=>j(p))]});function j(p){if(t.has(p))return n.jsx(E,{node:e.children[p],path:[...r,p],label:p,targetScope:a,onOverride:m,filter:f,depth:x+1,schema:u,showGhosts:o},p);const v=(u==null?void 0:u.at([...r,p]))??null;return v?n.jsx(I,{path:[...r,p],label:p,info:v,targetScope:a,onSet:m,depth:x+1,filter:f},p):null}}function L(e,r,s,a){const m=(a==null?void 0:a.at(r))??null;if(w(r,m,s))return!0;if(e.kind!=="object")return!1;for(const f of Object.keys(e.children))if(L(e.children[f],[...r,f],s,a))return!0;return!1}function R({node:e,path:r,label:s,filter:a,depth:m,schema:f}){const[x,u]=b.useState(!0),o=(f==null?void 0:f.at(r))??null;return w(r,o,a)?n.jsxs("div",{children:[n.jsxs("div",{className:"flex items-center gap-1 py-0.5 hover:bg-bg-elev/50 rounded cursor-pointer",style:{paddingLeft:m*14},onClick:()=>u(!x),children:[n.jsx("span",{className:"text-fg-faint w-3 shrink-0",children:x?"▾":"▸"}),n.jsx("span",{className:"text-fg",children:s}),n.jsxs("span",{className:"text-fg-faint",children:[" [",e.items.length,"]"]}),n.jsx(S,{tone:"warn",children:"accumulated"}),(o==null?void 0:o.description)&&n.jsxs("span",{className:"text-fg-faint truncate max-w-md",title:o.description,children:["— ",o.description]})]}),x&&e.items.map((g,d)=>n.jsxs("div",{className:"flex items-start gap-2 py-0.5",style:{paddingLeft:(m+1)*14},children:[n.jsx("span",{className:"text-fg-faint w-3 shrink-0"}),n.jsxs("span",{className:"text-fg-faint",children:[d,":"]}),n.jsx("span",{className:"text-fg-dim truncate max-w-xl",children:O(g.value)}),n.jsx(C,{scope:g.fromScope})]},d))]}):null}function J({node:e,path:r,label:s,targetScope:a,onOverride:m,filter:f,depth:x,schema:u}){const[o,g]=b.useState(!1),d=(u==null?void 0:u.at(r))??null;if(!w(r,d,f))return null;const h=e.winner!==a,y=e.shadowed.length>0;return n.jsxs("div",{children:[n.jsxs("div",{className:"group flex items-center gap-2 py-0.5 hover:bg-bg-elev/50 rounded",style:{paddingLeft:x*14},children:[n.jsx("span",{className:`w-3 shrink-0 ${y?"text-fg-faint cursor-pointer":""}`,onClick:()=>y&&g(!o),children:y?o?"▾":"▸":""}),n.jsxs("span",{className:"text-fg",children:[s,":"]}),n.jsx("span",{className:"text-fg-dim truncate max-w-md",children:O(e.value)}),n.jsx(C,{scope:e.winner}),(d==null?void 0:d.deprecated)&&n.jsx(S,{tone:"warn",children:"deprecated"}),(d==null?void 0:d.default)!==void 0&&_(e.value,d.default)&&n.jsx(S,{tone:"dim",children:"= default"}),e.typeMismatch&&n.jsx("span",{className:"text-yellow-500/80",title:"shadowed scopes have a different value type",children:"⚠"}),(d==null?void 0:d.description)&&n.jsxs("span",{className:"text-fg-faint truncate max-w-md",title:d.description,children:["— ",d.description]}),n.jsx("div",{className:"flex-1"}),(d==null?void 0:d.enum)&&n.jsx(F,{values:d.enum}),n.jsx("button",{disabled:!h,onClick:()=>m(r,e.value),className:`opacity-0 group-hover:opacity-100 px-1.5 py-0 text-[10px] border rounded transition-opacity ${h?"border-accent/50 text-accent hover:bg-accent hover:text-bg":"border-line text-fg-faint cursor-not-allowed"}`,title:h?`copy into ${N[a].label} draft`:`already winning in ${N[a].label}`,children:"override"})]}),o&&e.shadowed.map((t,i)=>n.jsxs("div",{className:"flex items-center gap-2 py-0.5 text-fg-faint line-through",style:{paddingLeft:(x+1)*14+12},children:[n.jsx("span",{children:"shadowed:"}),n.jsx("span",{className:"truncate max-w-xl",children:O(t.value)}),n.jsx(C,{scope:t.scope,dim:!0})]},i))]})}function I({path:e,label:r,info:s,targetScope:a,onSet:m,depth:f,filter:x}){if(!w(e,s,x))return null;const u=s.default!==void 0?s.default:M(s.type),o=Array.isArray(s.type)?s.type.join("|"):s.type??"?";return n.jsxs("div",{className:"group flex items-center gap-2 py-0.5 hover:bg-bg-elev/50 rounded opacity-60",style:{paddingLeft:f*14},children:[n.jsx("span",{className:"w-3 shrink-0"}),n.jsx("span",{className:"text-fg-dim",children:r}),n.jsx(S,{tone:"dim",children:o}),s.required&&n.jsx(S,{tone:"warn",children:"required"}),s.default!==void 0&&n.jsxs("span",{className:"text-fg-faint",children:["default: ",O(s.default)]}),s.description&&n.jsxs("span",{className:"text-fg-faint truncate max-w-md",title:s.description,children:["— ",s.description]}),n.jsx("div",{className:"flex-1"}),s.enum&&n.jsx(F,{values:s.enum}),n.jsx("button",{onClick:()=>m(e,u),className:"opacity-0 group-hover:opacity-100 px-1.5 py-0 text-[10px] border border-accent/50 rounded text-accent hover:bg-accent hover:text-bg transition-opacity",title:`write to ${N[a].label} draft`,children:"set"})]})}function _(e,r){return e===r?!0:typeof e!=typeof r?!1:e&&r&&typeof e=="object"?JSON.stringify(e)===JSON.stringify(r):!1}function M(e){switch(Array.isArray(e)?e[0]:e){case"boolean":return!1;case"integer":case"number":return 0;case"string":return"";case"array":return[];case"object":return{};case"null":return null;default:return null}}function O(e){if(typeof e=="string")return JSON.stringify(e);if(e===null)return"null";if(typeof e=="object"){const r=JSON.stringify(e);return r.length>100?r.slice(0,100)+"…":r}return String(e)}function C({scope:e,dim:r}){const s=e==="user"?"bg-bg-hi text-fg-dim border-line":e==="project"?"bg-blue-950/30 text-blue-400/80 border-blue-900/40":"bg-purple-950/30 text-purple-400/80 border-purple-900/40";return n.jsx("span",{className:`text-[10px] px-1 py-0 rounded border uppercase tracking-wide shrink-0 ${s} ${r?"opacity-60":""}`,children:N[e].label})}function S({children:e,tone:r="default"}){const s={default:"bg-bg-hi text-fg-dim border-line",warn:"bg-yellow-950/30 text-yellow-500/80 border-yellow-900/40",dim:"bg-bg-elev text-fg-faint border-line"}[r];return n.jsx("span",{className:`text-[10px] px-1 py-0 rounded border uppercase tracking-wide shrink-0 ${s}`,children:e})}function F({values:e}){const r=e.map(s=>String(s)).join(" | ");return n.jsxs("span",{className:"text-[10px] text-fg-faint truncate max-w-xs",title:`allowed: ${r}`,children:["∈ ",r.length>30?r.slice(0,30)+"…":r]})}function G(e,r,s){const a=k(o=>o.files),m=k(o=>o.loadJson),f=k(o=>o.watchFile),x=k(o=>o.unwatchFile),u=b.useMemo(()=>{const o={};for(const g of e.scopes){const d=e.resolve(g,r??"",s);d&&(o[g]=d)}return o},[e,r,s]);return b.useEffect(()=>{const o=Object.values(u).filter(Boolean);return o.forEach(g=>{a[g]||m(g),f(g)}),()=>{o.forEach(g=>x(g))}},[JSON.stringify(u)]),u}function z(e){const r=e??{},s={...r.$defs??{},...r.definitions??{}},a=t=>{if(!t)return{};if(!t.$ref)return x(t);const i=/^#\/(\$defs|definitions)\/(.+)$/.exec(t.$ref);if(!i)return x(t);const c=s[i[2]];return c?a({...c,...u(t)}):x(t)},m=new Set(["__proto__","constructor","prototype"]),f=t=>{if(!t)return{};const i={};for(const[c,l]of Object.entries(t))m.has(c)||(i[c]=l);return i},x=t=>{if(!t.allOf||t.allOf.length===0)return t;const i={...t};delete i.allOf;for(const c of t.allOf){const l=a(c);Object.assign(i,{properties:{...f(i.properties),...f(l.properties)},required:B([...i.required??[],...l.required??[]])}),!i.description&&l.description&&(i.description=l.description),i.default===void 0&&l.default!==void 0&&(i.default=l.default),!i.type&&l.type&&(i.type=l.type)}return i},u=t=>{const{$ref:i,...c}=t;return c},o=(t,i)=>{let c=a(t);for(const l of i){if(!c)return null;if(/^\d+$/.test(l)){const v=Array.isArray(c.items)?c.items[Number(l)]:c.items;c=v?a(v):null;continue}const j=c.properties;if(j&&!m.has(l)&&l in j){c=a(j[l]);continue}const p=c.additionalProperties;if(p&&typeof p=="object"){c=a(p);continue}return null}return c},g=(t,i,c)=>{if(!t)return null;const l={};if(t.description&&(l.description=t.description),t.type&&(l.type=t.type),t.default!==void 0&&(l.default=t.default),t.enum&&(l.enum=t.enum),t.const!==void 0&&(l.const=t.const),t.deprecated&&(l.deprecated=!0),t.examples&&(l.examples=t.examples),t.properties&&(l.knownChildren=Object.keys(t.properties)),c&&(i!=null&&i.includes(c))&&(l.required=!0),t.items&&!Array.isArray(t.items)){const j=a(t.items),p=g(j,void 0,null);p&&(l.itemsInfo=p)}return(t.additionalProperties===!0||typeof t.additionalProperties=="object")&&(l.open=!0),l},d=t=>i=>{if(i.length===0)return g(a(t),void 0,null);const c=o(t,i.slice(0,-1));if(!c)return null;const l=i[i.length-1],j=o(c,[l]);return g(j,c.required,l)},h=t=>{const i=a(t);return Object.keys(i.properties??{})},y=t=>({at:d(t),rootKeys:()=>h(t),rootedAt:i=>{const c=o(t,i);return y(c??{})}});return y(r)}function B(e){return Array.from(new Set(e))}let $=null;function V(){return $||($=z(K)),$}export{T as E,V as s,G as u};
|
|
1
|
+
import{az as b,ak as n,S as N,aR as k,ax as K}from"./index-Cd98Q1lD.js";function T({node:e,targetScope:r,onOverride:s,schema:a,rootLabel:m}){const[f,x]=b.useState(""),[u,o]=b.useState(!0),g=[],d=e.kind==="object"&&Object.keys(e.children).length===0,y=((a==null?void 0:a.rootKeys())??[]).length>0;return n.jsxs("div",{className:"h-full flex flex-col",children:[n.jsxs("div",{className:"shrink-0 border-b border-line bg-bg-elev px-3 py-1.5 flex items-center gap-2 text-xs",children:[n.jsxs("span",{className:"text-fg-faint",children:["merged · overrides → ",n.jsx("span",{className:"text-fg-dim",children:N[r].label})]}),y&&n.jsxs("label",{className:"flex items-center gap-1 text-fg-faint cursor-pointer",children:[n.jsx("input",{type:"checkbox",checked:u,onChange:t=>o(t.target.checked),className:"accent-accent"}),"show unset keys"]}),n.jsx("div",{className:"flex-1"}),n.jsx("input",{value:f,onChange:t=>x(t.target.value),placeholder:"filter keys or descriptions…",className:"bg-bg border border-line rounded px-2 py-0.5 text-xs text-fg w-56"})]}),n.jsx("div",{className:"flex-1 overflow-auto px-3 py-2 font-mono text-xs",children:d&&!u?n.jsx("div",{className:"text-fg-faint italic px-2 py-4",children:"no settings resolved — all scope files empty or missing"}):n.jsx(E,{node:e,path:g,label:m??"(root)",targetScope:r,onOverride:s,filter:f,depth:0,schema:a,showGhosts:u,defaultOpen:!0})})]})}function E(e){return e.node.kind==="object"?n.jsx(P,{...e,node:e.node}):e.node.kind==="array"?n.jsx(R,{...e,node:e.node}):n.jsx(J,{...e,node:e.node})}function A(e,r){return r.trim()?e.toLowerCase().includes(r.toLowerCase()):!0}function w(e,r,s){return!!(!s.trim()||e.some(a=>A(a,s))||r!=null&&r.description&&A(r.description,s))}function P({node:e,path:r,label:s,targetScope:a,onOverride:m,filter:f,depth:x,schema:u,showGhosts:o,defaultOpen:g}){const[d,h]=b.useState(g??x<2),y=(u==null?void 0:u.at(r))??null,t=new Set(Object.keys(e.children)),i=o?(y==null?void 0:y.knownChildren)??[]:[],c=Array.from(new Set([...t,...i])).sort(),l=b.useMemo(()=>f.trim()?c.filter(p=>{const v=(u==null?void 0:u.at([...r,p]))??null;return w([...r,p],v,f)?!0:t.has(p)?L(e.children[p],[...r,p],f,u):!1}):c,[c.join(","),f,e,r.join("."),u]);if(f.trim()&&l.length===0&&!w(r,y,f))return null;if(r.length===0)return n.jsx("div",{children:l.map(p=>j(p))});return n.jsxs("div",{children:[n.jsxs("div",{className:"flex items-center gap-1 py-0.5 hover:bg-bg-elev/50 rounded cursor-pointer",style:{paddingLeft:x*14},onClick:()=>h(!d),children:[n.jsx("span",{className:"text-fg-faint w-3 shrink-0",children:d?"▾":"▸"}),n.jsx("span",{className:"text-fg",children:s}),n.jsxs("span",{className:"text-fg-faint",children:[" {",t.size,i.length>t.size?`/${new Set([...t,...i]).size}`:"","}"]}),(y==null?void 0:y.description)&&n.jsxs("span",{className:"text-fg-faint truncate max-w-md",title:y.description,children:["— ",y.description]})]}),d&&l.map(p=>j(p))]});function j(p){if(t.has(p))return n.jsx(E,{node:e.children[p],path:[...r,p],label:p,targetScope:a,onOverride:m,filter:f,depth:x+1,schema:u,showGhosts:o},p);const v=(u==null?void 0:u.at([...r,p]))??null;return v?n.jsx(I,{path:[...r,p],label:p,info:v,targetScope:a,onSet:m,depth:x+1,filter:f},p):null}}function L(e,r,s,a){const m=(a==null?void 0:a.at(r))??null;if(w(r,m,s))return!0;if(e.kind!=="object")return!1;for(const f of Object.keys(e.children))if(L(e.children[f],[...r,f],s,a))return!0;return!1}function R({node:e,path:r,label:s,filter:a,depth:m,schema:f}){const[x,u]=b.useState(!0),o=(f==null?void 0:f.at(r))??null;return w(r,o,a)?n.jsxs("div",{children:[n.jsxs("div",{className:"flex items-center gap-1 py-0.5 hover:bg-bg-elev/50 rounded cursor-pointer",style:{paddingLeft:m*14},onClick:()=>u(!x),children:[n.jsx("span",{className:"text-fg-faint w-3 shrink-0",children:x?"▾":"▸"}),n.jsx("span",{className:"text-fg",children:s}),n.jsxs("span",{className:"text-fg-faint",children:[" [",e.items.length,"]"]}),n.jsx(S,{tone:"warn",children:"accumulated"}),(o==null?void 0:o.description)&&n.jsxs("span",{className:"text-fg-faint truncate max-w-md",title:o.description,children:["— ",o.description]})]}),x&&e.items.map((g,d)=>n.jsxs("div",{className:"flex items-start gap-2 py-0.5",style:{paddingLeft:(m+1)*14},children:[n.jsx("span",{className:"text-fg-faint w-3 shrink-0"}),n.jsxs("span",{className:"text-fg-faint",children:[d,":"]}),n.jsx("span",{className:"text-fg-dim truncate max-w-xl",children:O(g.value)}),n.jsx(C,{scope:g.fromScope})]},d))]}):null}function J({node:e,path:r,label:s,targetScope:a,onOverride:m,filter:f,depth:x,schema:u}){const[o,g]=b.useState(!1),d=(u==null?void 0:u.at(r))??null;if(!w(r,d,f))return null;const h=e.winner!==a,y=e.shadowed.length>0;return n.jsxs("div",{children:[n.jsxs("div",{className:"group flex items-center gap-2 py-0.5 hover:bg-bg-elev/50 rounded",style:{paddingLeft:x*14},children:[n.jsx("span",{className:`w-3 shrink-0 ${y?"text-fg-faint cursor-pointer":""}`,onClick:()=>y&&g(!o),children:y?o?"▾":"▸":""}),n.jsxs("span",{className:"text-fg",children:[s,":"]}),n.jsx("span",{className:"text-fg-dim truncate max-w-md",children:O(e.value)}),n.jsx(C,{scope:e.winner}),(d==null?void 0:d.deprecated)&&n.jsx(S,{tone:"warn",children:"deprecated"}),(d==null?void 0:d.default)!==void 0&&_(e.value,d.default)&&n.jsx(S,{tone:"dim",children:"= default"}),e.typeMismatch&&n.jsx("span",{className:"text-yellow-500/80",title:"shadowed scopes have a different value type",children:"⚠"}),(d==null?void 0:d.description)&&n.jsxs("span",{className:"text-fg-faint truncate max-w-md",title:d.description,children:["— ",d.description]}),n.jsx("div",{className:"flex-1"}),(d==null?void 0:d.enum)&&n.jsx(F,{values:d.enum}),n.jsx("button",{disabled:!h,onClick:()=>m(r,e.value),className:`opacity-0 group-hover:opacity-100 px-1.5 py-0 text-[10px] border rounded transition-opacity ${h?"border-accent/50 text-accent hover:bg-accent hover:text-bg":"border-line text-fg-faint cursor-not-allowed"}`,title:h?`copy into ${N[a].label} draft`:`already winning in ${N[a].label}`,children:"override"})]}),o&&e.shadowed.map((t,i)=>n.jsxs("div",{className:"flex items-center gap-2 py-0.5 text-fg-faint line-through",style:{paddingLeft:(x+1)*14+12},children:[n.jsx("span",{children:"shadowed:"}),n.jsx("span",{className:"truncate max-w-xl",children:O(t.value)}),n.jsx(C,{scope:t.scope,dim:!0})]},i))]})}function I({path:e,label:r,info:s,targetScope:a,onSet:m,depth:f,filter:x}){if(!w(e,s,x))return null;const u=s.default!==void 0?s.default:M(s.type),o=Array.isArray(s.type)?s.type.join("|"):s.type??"?";return n.jsxs("div",{className:"group flex items-center gap-2 py-0.5 hover:bg-bg-elev/50 rounded opacity-60",style:{paddingLeft:f*14},children:[n.jsx("span",{className:"w-3 shrink-0"}),n.jsx("span",{className:"text-fg-dim",children:r}),n.jsx(S,{tone:"dim",children:o}),s.required&&n.jsx(S,{tone:"warn",children:"required"}),s.default!==void 0&&n.jsxs("span",{className:"text-fg-faint",children:["default: ",O(s.default)]}),s.description&&n.jsxs("span",{className:"text-fg-faint truncate max-w-md",title:s.description,children:["— ",s.description]}),n.jsx("div",{className:"flex-1"}),s.enum&&n.jsx(F,{values:s.enum}),n.jsx("button",{onClick:()=>m(e,u),className:"opacity-0 group-hover:opacity-100 px-1.5 py-0 text-[10px] border border-accent/50 rounded text-accent hover:bg-accent hover:text-bg transition-opacity",title:`write to ${N[a].label} draft`,children:"set"})]})}function _(e,r){return e===r?!0:typeof e!=typeof r?!1:e&&r&&typeof e=="object"?JSON.stringify(e)===JSON.stringify(r):!1}function M(e){switch(Array.isArray(e)?e[0]:e){case"boolean":return!1;case"integer":case"number":return 0;case"string":return"";case"array":return[];case"object":return{};case"null":return null;default:return null}}function O(e){if(typeof e=="string")return JSON.stringify(e);if(e===null)return"null";if(typeof e=="object"){const r=JSON.stringify(e);return r.length>100?r.slice(0,100)+"…":r}return String(e)}function C({scope:e,dim:r}){const s=e==="user"?"bg-bg-hi text-fg-dim border-line":e==="project"?"bg-blue-950/30 text-blue-400/80 border-blue-900/40":"bg-purple-950/30 text-purple-400/80 border-purple-900/40";return n.jsx("span",{className:`text-[10px] px-1 py-0 rounded border uppercase tracking-wide shrink-0 ${s} ${r?"opacity-60":""}`,children:N[e].label})}function S({children:e,tone:r="default"}){const s={default:"bg-bg-hi text-fg-dim border-line",warn:"bg-yellow-950/30 text-yellow-500/80 border-yellow-900/40",dim:"bg-bg-elev text-fg-faint border-line"}[r];return n.jsx("span",{className:`text-[10px] px-1 py-0 rounded border uppercase tracking-wide shrink-0 ${s}`,children:e})}function F({values:e}){const r=e.map(s=>String(s)).join(" | ");return n.jsxs("span",{className:"text-[10px] text-fg-faint truncate max-w-xs",title:`allowed: ${r}`,children:["∈ ",r.length>30?r.slice(0,30)+"…":r]})}function G(e,r,s){const a=k(o=>o.files),m=k(o=>o.loadJson),f=k(o=>o.watchFile),x=k(o=>o.unwatchFile),u=b.useMemo(()=>{const o={};for(const g of e.scopes){const d=e.resolve(g,r??"",s);d&&(o[g]=d)}return o},[e,r,s]);return b.useEffect(()=>{const o=Object.values(u).filter(Boolean);return o.forEach(g=>{a[g]||m(g),f(g)}),()=>{o.forEach(g=>x(g))}},[JSON.stringify(u)]),u}function z(e){const r=e??{},s={...r.$defs??{},...r.definitions??{}},a=t=>{if(!t)return{};if(!t.$ref)return x(t);const i=/^#\/(\$defs|definitions)\/(.+)$/.exec(t.$ref);if(!i)return x(t);const c=s[i[2]];return c?a({...c,...u(t)}):x(t)},m=new Set(["__proto__","constructor","prototype"]),f=t=>{if(!t)return{};const i={};for(const[c,l]of Object.entries(t))m.has(c)||(i[c]=l);return i},x=t=>{if(!t.allOf||t.allOf.length===0)return t;const i={...t};delete i.allOf;for(const c of t.allOf){const l=a(c);Object.assign(i,{properties:{...f(i.properties),...f(l.properties)},required:B([...i.required??[],...l.required??[]])}),!i.description&&l.description&&(i.description=l.description),i.default===void 0&&l.default!==void 0&&(i.default=l.default),!i.type&&l.type&&(i.type=l.type)}return i},u=t=>{const{$ref:i,...c}=t;return c},o=(t,i)=>{let c=a(t);for(const l of i){if(!c)return null;if(/^\d+$/.test(l)){const v=Array.isArray(c.items)?c.items[Number(l)]:c.items;c=v?a(v):null;continue}const j=c.properties;if(j&&!m.has(l)&&l in j){c=a(j[l]);continue}const p=c.additionalProperties;if(p&&typeof p=="object"){c=a(p);continue}return null}return c},g=(t,i,c)=>{if(!t)return null;const l={};if(t.description&&(l.description=t.description),t.type&&(l.type=t.type),t.default!==void 0&&(l.default=t.default),t.enum&&(l.enum=t.enum),t.const!==void 0&&(l.const=t.const),t.deprecated&&(l.deprecated=!0),t.examples&&(l.examples=t.examples),t.properties&&(l.knownChildren=Object.keys(t.properties)),c&&(i!=null&&i.includes(c))&&(l.required=!0),t.items&&!Array.isArray(t.items)){const j=a(t.items),p=g(j,void 0,null);p&&(l.itemsInfo=p)}return(t.additionalProperties===!0||typeof t.additionalProperties=="object")&&(l.open=!0),l},d=t=>i=>{if(i.length===0)return g(a(t),void 0,null);const c=o(t,i.slice(0,-1));if(!c)return null;const l=i[i.length-1],j=o(c,[l]);return g(j,c.required,l)},h=t=>{const i=a(t);return Object.keys(i.properties??{})},y=t=>({at:d(t),rootKeys:()=>h(t),rootedAt:i=>{const c=o(t,i);return y(c??{})}});return y(r)}function B(e){return Array.from(new Set(e))}let $=null;function V(){return $||($=z(K)),$}export{T as E,V as s,G as u};
|
package/dist/index.html
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
<link rel="preconnect" href="https://fonts.googleapis.com">
|
|
8
8
|
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
|
9
9
|
<link href="https://fonts.googleapis.com/css2?family=Newsreader:ital,opsz,wght@0,6..72,400;0,6..72,500;0,6..72,600;0,6..72,700;1,6..72,400&family=Geist:wght@300;400;500;600;700&family=IBM+Plex+Mono:wght@400;500;600&display=swap" rel="stylesheet">
|
|
10
|
-
<script type="module" crossorigin src="./assets/index-
|
|
10
|
+
<script type="module" crossorigin src="./assets/index-Cd98Q1lD.js"></script>
|
|
11
11
|
<link rel="modulepreload" crossorigin href="./assets/monaco-editor-BW5C4Iv1.js">
|
|
12
12
|
<link rel="stylesheet" crossorigin href="./assets/monaco-editor-BTnBOi8r.css">
|
|
13
13
|
<link rel="stylesheet" crossorigin href="./assets/index-CKH5Uxik.css">
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "claude-code-session-manager",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.98.0",
|
|
4
4
|
"description": "Local cockpit for the Claude Code CLI — multi-tab terminal, full config surface, scheduler, voice dictation, and live observability.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "src/main/index.cjs",
|
|
@@ -53,6 +53,7 @@
|
|
|
53
53
|
"refresh:vad-assets": "node scripts/refresh-vad-assets.mjs",
|
|
54
54
|
"health": "node src/main/health.cjs",
|
|
55
55
|
"manual:check": "node web/manual/build.mjs --check",
|
|
56
|
+
"manual:readability": "node web/manual/readability.mjs",
|
|
56
57
|
"manual:build": "node web/manual/build.mjs",
|
|
57
58
|
"manual:figures": "xvfb-run -a node web/manual/capture-figures.mjs",
|
|
58
59
|
"lint:selectors": "node scripts/check-unstable-selectors.cjs",
|
|
@@ -45,6 +45,8 @@ Edit the chapter HTML in `session-manager-operations/manual/chapters/`.
|
|
|
45
45
|
|
|
46
46
|
Hard rules — these are the ones that protect a paying customer:
|
|
47
47
|
|
|
48
|
+
- **Follow `manual/STYLE.md`** (voice, reading level, component vocabulary) — it is the single
|
|
49
|
+
writing contract for every chapter, revisions included.
|
|
48
50
|
- **Every claim must be checkable against real code right now.** Read the file, run the
|
|
49
51
|
command, confirm the constant. A wrong instruction in a paid product is a refund.
|
|
50
52
|
- **Never invent a screenshot.** A figure slot that has no captured image stays a
|
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* prdCreateAdoption.test.cjs — PRD 1446: scheduler_create_prd wrote a PRD
|
|
3
|
+
* file and promised its queue row "on the next reconcile pass (~1 minute)",
|
|
4
|
+
* but nothing reliably ran that pass. The 60s pollLoop only reaches
|
|
5
|
+
* reconcile() via maybeLaunchWhenAvailable, which returns early while zero
|
|
6
|
+
* rows are pending; the 10-minute rescheduleTimer awaits refreshNextReset()
|
|
7
|
+
* -> billing.fetchUsage() BEFORE reconciling, and stalled indefinitely while
|
|
8
|
+
* the usage meter was rate-limited (PRDs 1420-1441 sat unadopted 17+
|
|
9
|
+
* minutes, 2026-09-25).
|
|
10
|
+
*
|
|
11
|
+
* Two fixes, exercised here:
|
|
12
|
+
* 1. scheduler.remote gained `requestReconcile()` — the SAME broadcast
|
|
13
|
+
* coalescer / reconcile() seam `remote.resetJob` already used (no
|
|
14
|
+
* second reconcile implementation) — and prdCreate.cjs's createPrd()
|
|
15
|
+
* calls it right after a successful write.
|
|
16
|
+
* 2. rescheduleTimer's refreshNextReset() await is now bounded by a
|
|
17
|
+
* RESCHEDULE_TIMER_BILLING_RACE_MS Promise.race against the cached
|
|
18
|
+
* reset value, so its own mutate(reconcile) still runs even when
|
|
19
|
+
* billing.fetchUsage() never resolves.
|
|
20
|
+
*
|
|
21
|
+
* HOME-isolated + fixture-project pattern mirrors reconcileTiming.test.cjs.
|
|
22
|
+
*
|
|
23
|
+
* Run: timeout 300 npx vitest run src/main/__tests__/prdCreateAdoption.test.cjs
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
'use strict';
|
|
27
|
+
|
|
28
|
+
import {
|
|
29
|
+
test, expect, beforeAll, afterAll, afterEach, vi,
|
|
30
|
+
} from 'vitest';
|
|
31
|
+
const fs = require('node:fs');
|
|
32
|
+
const os = require('node:os');
|
|
33
|
+
const path = require('node:path');
|
|
34
|
+
|
|
35
|
+
let tmpHome;
|
|
36
|
+
let originalHome;
|
|
37
|
+
let scheduler;
|
|
38
|
+
let usage;
|
|
39
|
+
let config;
|
|
40
|
+
let createPrd;
|
|
41
|
+
|
|
42
|
+
/** A bare cwd for the fake-remote createPrd() tests below — these don't go
|
|
43
|
+
* through a real Epic/queue, so all they need is a directory config.cjs's
|
|
44
|
+
* validatePath will accept. Not os.homedir(): this file's beforeAll swaps
|
|
45
|
+
* process.env.HOME for scheduler.cjs's isolation, so os.homedir() called
|
|
46
|
+
* from inside a test would resolve to tmpHome instead of the real home
|
|
47
|
+
* config.cjs's allowedRoots snapshot was seeded with at import time. */
|
|
48
|
+
function makeAllowedCwd(prefix) {
|
|
49
|
+
const cwd = fs.mkdtempSync(path.join(os.tmpdir(), prefix));
|
|
50
|
+
config.addAllowedRoot(cwd);
|
|
51
|
+
return cwd;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
beforeAll(() => {
|
|
55
|
+
originalHome = process.env.HOME;
|
|
56
|
+
tmpHome = fs.mkdtempSync(path.join(os.tmpdir(), 'sm-prd-adoption-home-'));
|
|
57
|
+
process.env.HOME = tmpHome;
|
|
58
|
+
|
|
59
|
+
// Required AFTER HOME is swapped, never at module top level: activeSessions.cjs
|
|
60
|
+
// (pulled in transitively by prdCreate.cjs/scheduler.cjs) snapshots
|
|
61
|
+
// `os.homedir()` into a module-scope constant at first require — loading it
|
|
62
|
+
// before this reassignment would permanently bake in the vitest sandbox's
|
|
63
|
+
// own HOME (tests/setup/schedulerSandbox.globalSetup.cjs) instead of this
|
|
64
|
+
// file's tmpHome, silently breaking every ~/.claude/projects-scan-dependent
|
|
65
|
+
// assertion below (allProjectCwds/reconcile would always come back empty).
|
|
66
|
+
scheduler = require('../scheduler.cjs');
|
|
67
|
+
usage = require('../usage.cjs');
|
|
68
|
+
config = require('../config.cjs');
|
|
69
|
+
({ createPrd } = require('../lib/prdCreate.cjs'));
|
|
70
|
+
|
|
71
|
+
if (!scheduler.PRDS_DIR.startsWith(tmpHome)) {
|
|
72
|
+
throw new Error(`refusing to run: PRDS_DIR (${scheduler.PRDS_DIR}) is not under the temp HOME (${tmpHome})`);
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
afterAll(() => {
|
|
77
|
+
process.env.HOME = originalHome;
|
|
78
|
+
fs.rmSync(tmpHome, { recursive: true, force: true });
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
afterEach(() => {
|
|
82
|
+
vi.restoreAllMocks();
|
|
83
|
+
vi.useRealTimers();
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
function registerActiveProject(cwd) {
|
|
87
|
+
const projectsDir = path.join(tmpHome, '.claude', 'projects');
|
|
88
|
+
const slugDir = path.join(projectsDir, `fake-project-slug-${path.basename(cwd)}`);
|
|
89
|
+
fs.mkdirSync(slugDir, { recursive: true });
|
|
90
|
+
fs.writeFileSync(path.join(slugDir, 'transcript.jsonl'), `${JSON.stringify({ cwd })}\n`);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
function makeFixtureProject(prefix) {
|
|
94
|
+
const cwd = fs.mkdtempSync(path.join(os.tmpdir(), prefix));
|
|
95
|
+
registerActiveProject(cwd);
|
|
96
|
+
return cwd;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
function writeCanonicalPrd(cwd, epicId, slug) {
|
|
100
|
+
const epicPrdsDir = path.join(cwd, 'session-manager-operations', 'scheduler', 'epics', epicId, 'prds');
|
|
101
|
+
fs.mkdirSync(epicPrdsDir, { recursive: true });
|
|
102
|
+
fs.writeFileSync(
|
|
103
|
+
path.join(epicPrdsDir, `${slug}.md`),
|
|
104
|
+
`---\ntitle: Adoption fixture\ncwd: ${cwd}\nestimateMinutes: 10\nsourcePromptId: ${epicId}\ncreatedVia: scheduler-api\nissuedAt: 2026-09-25T00:00:00.000Z\n---\n\n# Goal\n\nSomething.\n`,
|
|
105
|
+
'utf8',
|
|
106
|
+
);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
test('remote.requestReconcile() adopts a freshly-created PRD into a pending row with no tickQueue call', async () => {
|
|
110
|
+
const cwd = makeFixtureProject('sm-prd-adoption-fresh-');
|
|
111
|
+
writeCanonicalPrd(cwd, 'epic-fresh', '9001-fresh');
|
|
112
|
+
|
|
113
|
+
const tickQueueSpy = vi.spyOn(scheduler, 'tickQueue');
|
|
114
|
+
|
|
115
|
+
await scheduler.remote.requestReconcile();
|
|
116
|
+
|
|
117
|
+
expect(tickQueueSpy).not.toHaveBeenCalled();
|
|
118
|
+
const job = await scheduler.remote.getJob('9001-fresh');
|
|
119
|
+
expect(job).not.toBeNull();
|
|
120
|
+
expect(job.status).toBe('pending');
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
test('createPrd() calls remote.requestReconcile() once after a successful write and reports enqueued:true once the row exists', async () => {
|
|
124
|
+
const writes = new Map();
|
|
125
|
+
const requestReconcile = vi.fn(async () => {});
|
|
126
|
+
const remote = {
|
|
127
|
+
async allocateParallelGroup() { return '9002'; },
|
|
128
|
+
async readPrd(slug) {
|
|
129
|
+
return writes.has(slug) ? { ok: true, text: writes.get(slug) } : { ok: false, error: 'missing' };
|
|
130
|
+
},
|
|
131
|
+
async writePrd(slug, body) {
|
|
132
|
+
writes.set(slug, body);
|
|
133
|
+
return { ok: true, path: `/fake/${slug}.md` };
|
|
134
|
+
},
|
|
135
|
+
async listPrds() { return { prds: [], total: 0, limit: 0, offset: 0, hasMore: false }; },
|
|
136
|
+
requestReconcile,
|
|
137
|
+
// Simulates the reconcile pass having already produced the queue row by
|
|
138
|
+
// the time createPrd() checks for it.
|
|
139
|
+
async getJob(slug) { return writes.has(slug) ? { slug, status: 'pending' } : null; },
|
|
140
|
+
};
|
|
141
|
+
|
|
142
|
+
const result = await createPrd({
|
|
143
|
+
title: 'Adoption wiring check',
|
|
144
|
+
cwd: makeAllowedCwd('sm-prd-adoption-hit-'),
|
|
145
|
+
estimateMinutes: 10,
|
|
146
|
+
goal: 'g',
|
|
147
|
+
acceptanceCriteria: ['a'],
|
|
148
|
+
implementationNotes: 'n',
|
|
149
|
+
}, remote);
|
|
150
|
+
|
|
151
|
+
expect(result.ok).toBe(true);
|
|
152
|
+
expect(requestReconcile).toHaveBeenCalledTimes(1);
|
|
153
|
+
expect(result.enqueued).toBe(true);
|
|
154
|
+
expect(result.note).not.toMatch(/derived by the next scheduler reconcile pass/);
|
|
155
|
+
});
|
|
156
|
+
|
|
157
|
+
test('createPrd() reports enqueued:false with the deferred-pass note when the row is not visible right after reconcile', async () => {
|
|
158
|
+
const writes = new Map();
|
|
159
|
+
const requestReconcile = vi.fn(async () => {});
|
|
160
|
+
const remote = {
|
|
161
|
+
async allocateParallelGroup() { return '9003'; },
|
|
162
|
+
async readPrd(slug) {
|
|
163
|
+
return writes.has(slug) ? { ok: true, text: writes.get(slug) } : { ok: false, error: 'missing' };
|
|
164
|
+
},
|
|
165
|
+
async writePrd(slug, body) {
|
|
166
|
+
writes.set(slug, body);
|
|
167
|
+
return { ok: true, path: `/fake/${slug}.md` };
|
|
168
|
+
},
|
|
169
|
+
async listPrds() { return { prds: [], total: 0, limit: 0, offset: 0, hasMore: false }; },
|
|
170
|
+
requestReconcile,
|
|
171
|
+
async getJob() { return null; },
|
|
172
|
+
};
|
|
173
|
+
|
|
174
|
+
const result = await createPrd({
|
|
175
|
+
title: 'Adoption wiring miss',
|
|
176
|
+
cwd: makeAllowedCwd('sm-prd-adoption-miss-'),
|
|
177
|
+
estimateMinutes: 10,
|
|
178
|
+
goal: 'g',
|
|
179
|
+
acceptanceCriteria: ['a'],
|
|
180
|
+
implementationNotes: 'n',
|
|
181
|
+
}, remote);
|
|
182
|
+
|
|
183
|
+
expect(result.ok).toBe(true);
|
|
184
|
+
expect(requestReconcile).toHaveBeenCalledTimes(1);
|
|
185
|
+
expect(result.enqueued).toBe(false);
|
|
186
|
+
expect(result.note).toMatch(/derived by the next scheduler reconcile pass/);
|
|
187
|
+
});
|
|
188
|
+
|
|
189
|
+
test('rescheduleTimer still reconciles when billing.fetchUsage() never resolves', async () => {
|
|
190
|
+
const cwd = makeFixtureProject('sm-prd-adoption-stall-');
|
|
191
|
+
writeCanonicalPrd(cwd, 'epic-stall', '9004-stall');
|
|
192
|
+
|
|
193
|
+
vi.spyOn(usage, 'fetchUsage').mockImplementation(() => new Promise(() => {}));
|
|
194
|
+
vi.useFakeTimers({ toFake: ['setTimeout', 'clearTimeout'] });
|
|
195
|
+
|
|
196
|
+
const pending = scheduler.rescheduleTimer();
|
|
197
|
+
await vi.advanceTimersByTimeAsync(scheduler.RESCHEDULE_TIMER_BILLING_RACE_MS);
|
|
198
|
+
await pending;
|
|
199
|
+
|
|
200
|
+
vi.useRealTimers();
|
|
201
|
+
|
|
202
|
+
const job = await scheduler.remote.getJob('9004-stall');
|
|
203
|
+
expect(job).not.toBeNull();
|
|
204
|
+
expect(job.status).toBe('pending');
|
|
205
|
+
}, 15_000);
|
|
@@ -5,22 +5,39 @@
|
|
|
5
5
|
*
|
|
6
6
|
* selectAutoArchivable is pure (no fs) so it's fully covered here without
|
|
7
7
|
* touching disk. autoArchiveCompleted's disk-mutating path (archiveMany) is
|
|
8
|
-
* exercised only via its kill-switch / no-op branches, since
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
8
|
+
* mostly exercised only via its kill-switch / no-op branches, since
|
|
9
|
+
* archiveMany's default destination is not test-injectable — except for the
|
|
10
|
+
* two retire-flag tests below, which write into PRDS_DIR (a lazy getter
|
|
11
|
+
* resolved under this run's SM_SCHEDULER_HOME sandbox — see
|
|
12
|
+
* tests/setup/schedulerSandbox.cjs — so they never touch a real
|
|
13
|
+
* ~/.claude/session-manager tree) and stub 'electron' via require.cache so
|
|
14
|
+
* registerQueueOpsHandlers' ipcMain.handle calls are no-ops outside a real
|
|
15
|
+
* Electron process. 'electron' is an externalized node_modules dependency
|
|
16
|
+
* under vitest, so vi.mock('electron', ...) never intercepts queueOps.cjs's
|
|
17
|
+
* own require('electron') — pre-seeding require.cache for its resolved path
|
|
18
|
+
* is the one hook that reaches it.
|
|
12
19
|
*
|
|
13
20
|
* Run: timeout 300 npx vitest run src/main/__tests__/queueOpsAutoArchive.test.cjs
|
|
14
21
|
*/
|
|
15
22
|
|
|
16
23
|
'use strict';
|
|
17
24
|
|
|
18
|
-
import { test, expect, afterEach } from 'vitest';
|
|
25
|
+
import { test, expect, afterEach, vi } from 'vitest';
|
|
26
|
+
const fs = require('node:fs');
|
|
27
|
+
const path = require('node:path');
|
|
28
|
+
|
|
29
|
+
const electronPath = require.resolve('electron');
|
|
30
|
+
require.cache[electronPath] = {
|
|
31
|
+
id: electronPath,
|
|
32
|
+
filename: electronPath,
|
|
33
|
+
loaded: true,
|
|
34
|
+
exports: { ipcMain: { handle: () => {} } },
|
|
35
|
+
};
|
|
19
36
|
|
|
20
37
|
const RETENTION_MS = 7 * 24 * 60 * 60_000;
|
|
21
38
|
const NOW = Date.parse('2026-07-24T12:00:00.000Z');
|
|
22
39
|
|
|
23
|
-
const { selectAutoArchivable, autoArchiveCompleted } = require('../queueOps.cjs');
|
|
40
|
+
const { selectAutoArchivable, autoArchiveCompleted, archiveMany, registerQueueOpsHandlers, PRDS_DIR } = require('../queueOps.cjs');
|
|
24
41
|
|
|
25
42
|
function fresh(overrides = {}) {
|
|
26
43
|
return {
|
|
@@ -152,3 +169,43 @@ test('selectAutoArchivable never selects a slug whose job is still pending or ru
|
|
|
152
169
|
const slugs = selectAutoArchivable([pending, running, completed], { nowMs: NOW });
|
|
153
170
|
expect(slugs).toEqual(['15-done']);
|
|
154
171
|
});
|
|
172
|
+
|
|
173
|
+
// ---------- retire-flag deadlock guard (PRD 1442: reconcile() -> mutate()
|
|
174
|
+
// body -> autoArchiveCompleted -> archiveMany -> retireCompletedSlugsFn ->
|
|
175
|
+
// mutate() re-entered every tick, so mutateTail never settled) ----------
|
|
176
|
+
|
|
177
|
+
test('autoArchiveCompleted never invokes retireCompletedSlugs', async () => {
|
|
178
|
+
const slug = 'test-auto-archive-no-retire';
|
|
179
|
+
fs.mkdirSync(PRDS_DIR, { recursive: true });
|
|
180
|
+
const src = path.join(PRDS_DIR, `${slug}.md`);
|
|
181
|
+
fs.writeFileSync(src, '# Goal\n\ntest\n', 'utf8');
|
|
182
|
+
|
|
183
|
+
const spy = vi.fn(async () => {});
|
|
184
|
+
registerQueueOpsHandlers({ retireCompletedSlugs: spy });
|
|
185
|
+
|
|
186
|
+
const job = old({ slug, status: 'completed' });
|
|
187
|
+
const result = await autoArchiveCompleted({ jobs: [job] }, { nowMs: NOW });
|
|
188
|
+
|
|
189
|
+
expect(result.archived).toBe(1);
|
|
190
|
+
expect(fs.existsSync(src)).toBe(false);
|
|
191
|
+
expect(result.results[0].ok).toBe(true);
|
|
192
|
+
expect(fs.existsSync(result.results[0].archivedTo)).toBe(true);
|
|
193
|
+
expect(spy).not.toHaveBeenCalled();
|
|
194
|
+
});
|
|
195
|
+
|
|
196
|
+
test('manual archiveMany still retires', async () => {
|
|
197
|
+
const slug = 'test-manual-archive-still-retires';
|
|
198
|
+
fs.mkdirSync(PRDS_DIR, { recursive: true });
|
|
199
|
+
const src = path.join(PRDS_DIR, `${slug}.md`);
|
|
200
|
+
fs.writeFileSync(src, '# Goal\n\ntest\n', 'utf8');
|
|
201
|
+
|
|
202
|
+
const spy = vi.fn(async () => {});
|
|
203
|
+
registerQueueOpsHandlers({ retireCompletedSlugs: spy });
|
|
204
|
+
|
|
205
|
+
const result = await archiveMany([slug]);
|
|
206
|
+
|
|
207
|
+
expect(result.archived).toBe(1);
|
|
208
|
+
expect(fs.existsSync(src)).toBe(false);
|
|
209
|
+
expect(spy).toHaveBeenCalledTimes(1);
|
|
210
|
+
expect(spy).toHaveBeenCalledWith([slug]);
|
|
211
|
+
});
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* scheduler-mutate-reentrancy.test.cjs — regression cover for PRD 1443.
|
|
3
|
+
*
|
|
4
|
+
* mutate()'s chain (`mutateTail = mutateTail.then(...)`) is the single-writer
|
|
5
|
+
* lock over queue.json. Calling mutate() again from INSIDE a still-running
|
|
6
|
+
* mutate body (and awaiting it) used to queue the inner call behind
|
|
7
|
+
* mutateTail — which the outer call itself is holding — so the inner
|
|
8
|
+
* `await` never resolved and the whole scheduler froze (PRD 1442 was the one
|
|
9
|
+
* known path: reconcile -> autoArchiveCompleted -> retireCompletedSlugs ->
|
|
10
|
+
* mutate). The fix tracks "am I inside a live mutate body" via
|
|
11
|
+
* AsyncLocalStorage and rejects immediately on re-entry instead of
|
|
12
|
+
* deadlocking.
|
|
13
|
+
*
|
|
14
|
+
* HOME-isolated (mirrors scheduler-broadcast-reconcile.test.cjs): stub HOME to
|
|
15
|
+
* a mkdtemp dir and mock queueStore's read/write so this never touches real
|
|
16
|
+
* queue.json.
|
|
17
|
+
*
|
|
18
|
+
* Run: timeout 120 npx vitest run src/main/__tests__/scheduler-mutate-reentrancy.test.cjs
|
|
19
|
+
*/
|
|
20
|
+
'use strict';
|
|
21
|
+
|
|
22
|
+
import { test, expect, beforeAll, afterAll, afterEach, vi } from 'vitest';
|
|
23
|
+
const fs = require('node:fs');
|
|
24
|
+
const os = require('node:os');
|
|
25
|
+
const path = require('node:path');
|
|
26
|
+
|
|
27
|
+
let tmpHome;
|
|
28
|
+
let originalHome;
|
|
29
|
+
let scheduler;
|
|
30
|
+
let queueStore;
|
|
31
|
+
|
|
32
|
+
beforeAll(() => {
|
|
33
|
+
originalHome = process.env.HOME;
|
|
34
|
+
tmpHome = fs.mkdtempSync(path.join(os.tmpdir(), 'sm-mutate-reentrancy-home-'));
|
|
35
|
+
process.env.HOME = tmpHome;
|
|
36
|
+
|
|
37
|
+
scheduler = require('../scheduler.cjs');
|
|
38
|
+
queueStore = require('../lib/queueStore.cjs');
|
|
39
|
+
|
|
40
|
+
if (!scheduler.PRDS_DIR.startsWith(tmpHome)) {
|
|
41
|
+
throw new Error(`refusing to run: PRDS_DIR (${scheduler.PRDS_DIR}) is not under the temp HOME (${tmpHome})`);
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
afterAll(() => {
|
|
46
|
+
process.env.HOME = originalHome;
|
|
47
|
+
fs.rmSync(tmpHome, { recursive: true, force: true });
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
function freshState() {
|
|
51
|
+
return { config: {}, jobs: [], scheduledFor: null, lastRunAt: null, paused: null };
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
function wait(ms) {
|
|
55
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
afterEach(() => {
|
|
59
|
+
vi.restoreAllMocks();
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
test('nested awaited mutate rejects instead of hanging', async () => {
|
|
63
|
+
vi.spyOn(queueStore, 'readMerged').mockImplementation(async () => freshState());
|
|
64
|
+
vi.spyOn(queueStore, 'writeSplit').mockResolvedValue(undefined);
|
|
65
|
+
|
|
66
|
+
let innerRejection = null;
|
|
67
|
+
const outerPromise = scheduler._mutateForTests(async () => {
|
|
68
|
+
try {
|
|
69
|
+
await scheduler._mutateForTests(async () => 'inner-should-never-resolve');
|
|
70
|
+
} catch (err) {
|
|
71
|
+
innerRejection = err;
|
|
72
|
+
}
|
|
73
|
+
return 'outer-done';
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
const result = await Promise.race([
|
|
77
|
+
outerPromise,
|
|
78
|
+
wait(2000).then(() => { throw new Error('outer mutate did not settle within 2s'); }),
|
|
79
|
+
]);
|
|
80
|
+
|
|
81
|
+
expect(result).toBe('outer-done');
|
|
82
|
+
expect(innerRejection).toBeInstanceOf(Error);
|
|
83
|
+
expect(innerRejection.message).toMatch(/re-entered/i);
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
test('mutate scheduled via setTimeout from a finished body runs normally', async () => {
|
|
87
|
+
vi.spyOn(queueStore, 'readMerged').mockImplementation(async () => freshState());
|
|
88
|
+
vi.spyOn(queueStore, 'writeSplit').mockResolvedValue(undefined);
|
|
89
|
+
|
|
90
|
+
let deferredResult = null;
|
|
91
|
+
let deferredError = null;
|
|
92
|
+
|
|
93
|
+
await scheduler._mutateForTests(async () => {
|
|
94
|
+
setTimeout(() => {
|
|
95
|
+
scheduler._mutateForTests(async () => 'deferred-ok')
|
|
96
|
+
.then((r) => { deferredResult = r; })
|
|
97
|
+
.catch((err) => { deferredError = err; });
|
|
98
|
+
}, 10);
|
|
99
|
+
return 'immediate';
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
await wait(300);
|
|
103
|
+
|
|
104
|
+
expect(deferredError).toBeNull();
|
|
105
|
+
expect(deferredResult).toBe('deferred-ok');
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
test('sequential mutates unaffected', async () => {
|
|
109
|
+
vi.spyOn(queueStore, 'readMerged').mockImplementation(async () => freshState());
|
|
110
|
+
vi.spyOn(queueStore, 'writeSplit').mockResolvedValue(undefined);
|
|
111
|
+
|
|
112
|
+
const r1 = await scheduler._mutateForTests(async () => 'first');
|
|
113
|
+
const r2 = await scheduler._mutateForTests(async () => 'second');
|
|
114
|
+
|
|
115
|
+
expect(r1).toBe('first');
|
|
116
|
+
expect(r2).toBe('second');
|
|
117
|
+
});
|
package/src/main/build-info.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "0.
|
|
3
|
-
"gitSha": "
|
|
4
|
-
"gitShortSha": "
|
|
2
|
+
"version": "0.98.0",
|
|
3
|
+
"gitSha": "a733808122aabbe14f7b37834196eb78bb0c339f",
|
|
4
|
+
"gitShortSha": "a7338081",
|
|
5
5
|
"gitBranch": "HEAD",
|
|
6
|
-
"builtAt": "2026-09-
|
|
6
|
+
"builtAt": "2026-09-26T00:17:48.074Z",
|
|
7
7
|
"dirty": false
|
|
8
8
|
}
|
|
@@ -372,4 +372,70 @@ describe('evaluateDispatchLiveness', () => {
|
|
|
372
372
|
assert.equal(evaluateDispatchLiveness(null, now).dead, false);
|
|
373
373
|
assert.equal(evaluateDispatchLiveness({ ts: now }, now).dead, false);
|
|
374
374
|
});
|
|
375
|
+
|
|
376
|
+
const wedgedDeadMs = 10 * 60_000;
|
|
377
|
+
|
|
378
|
+
test('wedged + stale lastDispatchAttemptAt → tick-wedged dead', () => {
|
|
379
|
+
const e = base();
|
|
380
|
+
e.dispatch.lastTickReason = 'wedged';
|
|
381
|
+
e.dispatch.lastDispatchAttemptAt = new Date(now - wedgedDeadMs - 60_000).toISOString();
|
|
382
|
+
assert.deepEqual(
|
|
383
|
+
evaluateDispatchLiveness(e, now, { deadMs, wedgedDeadMs }),
|
|
384
|
+
{ dead: true, reason: 'tick-wedged' },
|
|
385
|
+
);
|
|
386
|
+
});
|
|
387
|
+
|
|
388
|
+
test('wedged but recent attempt → not dead', () => {
|
|
389
|
+
const e = base();
|
|
390
|
+
e.dispatch.lastTickReason = 'wedged';
|
|
391
|
+
e.dispatch.lastDispatchAttemptAt = new Date(now - 60_000).toISOString();
|
|
392
|
+
// Also clear the unrelated dispatch-dead conditions so a recent wedged
|
|
393
|
+
// attempt reads as genuinely alive, not merely falling through to a
|
|
394
|
+
// different dead reason.
|
|
395
|
+
e.dispatch.lastRunAt = new Date(now - 60_000).toISOString();
|
|
396
|
+
assert.equal(evaluateDispatchLiveness(e, now, { deadMs, wedgedDeadMs }).dead, false);
|
|
397
|
+
});
|
|
398
|
+
|
|
399
|
+
test('wedged while paused → paused (not dead)', () => {
|
|
400
|
+
const e = base();
|
|
401
|
+
e.dispatch.lastTickReason = 'wedged';
|
|
402
|
+
e.dispatch.lastDispatchAttemptAt = new Date(now - wedgedDeadMs - 60_000).toISOString();
|
|
403
|
+
e.dispatch.paused = true;
|
|
404
|
+
assert.deepEqual(
|
|
405
|
+
evaluateDispatchLiveness(e, now, { deadMs, wedgedDeadMs }),
|
|
406
|
+
{ dead: false, reason: 'paused' },
|
|
407
|
+
);
|
|
408
|
+
});
|
|
409
|
+
|
|
410
|
+
test('wedged with pendingDispatchable 0 still dead (the 2026-09-25 shape)', () => {
|
|
411
|
+
const e = base();
|
|
412
|
+
e.dispatch.lastTickReason = 'wedged';
|
|
413
|
+
e.dispatch.lastDispatchAttemptAt = new Date(now - wedgedDeadMs - 60_000).toISOString();
|
|
414
|
+
e.dispatch.pendingDispatchable = 0;
|
|
415
|
+
assert.deepEqual(
|
|
416
|
+
evaluateDispatchLiveness(e, now, { deadMs, wedgedDeadMs }),
|
|
417
|
+
{ dead: true, reason: 'tick-wedged' },
|
|
418
|
+
);
|
|
419
|
+
});
|
|
420
|
+
|
|
421
|
+
test('wedged with unparseable lastDispatchAttemptAt → tick-wedged dead', () => {
|
|
422
|
+
const e = base();
|
|
423
|
+
e.dispatch.lastTickReason = 'wedged';
|
|
424
|
+
e.dispatch.lastDispatchAttemptAt = null;
|
|
425
|
+
assert.deepEqual(
|
|
426
|
+
evaluateDispatchLiveness(e, now, { deadMs, wedgedDeadMs }),
|
|
427
|
+
{ dead: true, reason: 'tick-wedged' },
|
|
428
|
+
);
|
|
429
|
+
});
|
|
430
|
+
|
|
431
|
+
test('default wedgedDeadMs is 10 min', () => {
|
|
432
|
+
const e = base();
|
|
433
|
+
e.dispatch.lastTickReason = 'wedged';
|
|
434
|
+
e.dispatch.lastDispatchAttemptAt = new Date(now - 9 * 60_000).toISOString();
|
|
435
|
+
assert.equal(evaluateDispatchLiveness(e, now, { deadMs }).reason, 'dispatch-dead');
|
|
436
|
+
const e2 = base();
|
|
437
|
+
e2.dispatch.lastTickReason = 'wedged';
|
|
438
|
+
e2.dispatch.lastDispatchAttemptAt = new Date(now - 11 * 60_000).toISOString();
|
|
439
|
+
assert.deepEqual(evaluateDispatchLiveness(e2, now, { deadMs }), { dead: true, reason: 'tick-wedged' });
|
|
440
|
+
});
|
|
375
441
|
});
|
|
@@ -480,23 +480,48 @@ async function createPrd(input, remote) {
|
|
|
480
480
|
sourceTabId: input.sourceTabId ?? null,
|
|
481
481
|
});
|
|
482
482
|
|
|
483
|
+
// PRD 1446: writePrd() succeeding used to just promise "the next scheduler
|
|
484
|
+
// reconcile pass (~1 minute)" adopts this file — but nothing reliably ran
|
|
485
|
+
// that pass (the 60s pollLoop only reaches reconcile() via
|
|
486
|
+
// maybeLaunchWhenAvailable, which returns early while zero rows are
|
|
487
|
+
// pending; the 10-minute rescheduleTimer could itself stall behind a slow
|
|
488
|
+
// billing fetch). Trigger one reconcile immediately through the EXISTING
|
|
489
|
+
// broadcast-coalescer seam (remote.requestReconcile(), same one resetJob
|
|
490
|
+
// already uses) instead of waiting on either. Best-effort: a reconcile
|
|
491
|
+
// failure here must not fail a write that already landed on disk — the
|
|
492
|
+
// PRD file is real regardless, and the next scheduled pass still adopts
|
|
493
|
+
// it if this one didn't stick.
|
|
494
|
+
let enqueued = false;
|
|
495
|
+
if (typeof remote.requestReconcile === 'function') {
|
|
496
|
+
try {
|
|
497
|
+
await remote.requestReconcile();
|
|
498
|
+
if (typeof remote.getJob === 'function') {
|
|
499
|
+
enqueued = Boolean(await remote.getJob(filenameSlug));
|
|
500
|
+
}
|
|
501
|
+
} catch (e) {
|
|
502
|
+
console.warn(`[prdCreate] immediate requestReconcile failed (non-fatal, next scheduled pass will adopt it): ${e?.message ?? e}`);
|
|
503
|
+
}
|
|
504
|
+
}
|
|
505
|
+
|
|
483
506
|
// No `status` field here, and never one named 'queued' — that string was
|
|
484
507
|
// handed straight to callers as if it were a real ScheduleJob status, and
|
|
485
508
|
// is exactly how the 1021/1022 incident's invalid `"status": "queued"`
|
|
486
509
|
// rows got onto disk (this route's own response was the most likely
|
|
487
510
|
// source). A PRD is a queue row's SOURCE, not the row itself: writePrd
|
|
488
|
-
// only ever joins an Epic and writes the .md file — the queue row
|
|
489
|
-
// created separately, by
|
|
490
|
-
//
|
|
491
|
-
//
|
|
511
|
+
// only ever joins an Epic and writes the .md file — the queue row above
|
|
512
|
+
// is created separately, by reconcile(). `enqueued` reflects whether that
|
|
513
|
+
// reconcile pass (triggered synchronously above) actually produced the
|
|
514
|
+
// row before this function returned — it is not a fabricated status.
|
|
492
515
|
return {
|
|
493
516
|
ok: true,
|
|
494
517
|
nn,
|
|
495
518
|
filename: `${filenameSlug}.md`,
|
|
496
519
|
prdPath: writeResult.path ?? null,
|
|
497
520
|
epicId: writeResult.epicId ?? null,
|
|
498
|
-
enqueued
|
|
499
|
-
note:
|
|
521
|
+
enqueued,
|
|
522
|
+
note: enqueued
|
|
523
|
+
? 'PRD file written and adopted into the queue as a pending row'
|
|
524
|
+
: 'PRD file written; the queue row is derived by the next scheduler reconcile pass, not created here',
|
|
500
525
|
// Advisory only (PRD 1403) — never blocks the write. See prdSizing.cjs.
|
|
501
526
|
warnings: sizingWarnings(input),
|
|
502
527
|
};
|
|
@@ -542,7 +567,7 @@ function registerAdminRoute(adminHttp, remote) {
|
|
|
542
567
|
filename: result.filename,
|
|
543
568
|
prdPath: result.prdPath ?? null,
|
|
544
569
|
epicId: result.epicId ?? null,
|
|
545
|
-
enqueued:
|
|
570
|
+
enqueued: result.enqueued,
|
|
546
571
|
note: result.note,
|
|
547
572
|
warnings: result.warnings,
|
|
548
573
|
});
|