workspai 0.64.0 → 0.65.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 (116) hide show
  1. package/README.md +37 -44
  2. package/contracts/cli-runtime-command-inventory.v1.snapshot.json +4 -0
  3. package/contracts/runtime-command-surface.v1.json +12 -1
  4. package/contracts/workspace-contract.v1.json +51 -6
  5. package/contracts/workspace-intelligence/project-context-agent.v1.json +29 -0
  6. package/contracts/workspace-intelligence/workspace-knowledge-graph.v1.json +11 -1
  7. package/contracts/workspace-intelligence/workspace-model.v1.json +28 -1
  8. package/contracts/workspace-model-cache.v1.json +4 -0
  9. package/contracts/workspace-repair-capabilities.v1.json +66 -0
  10. package/dist/analyze-5PDVWECJ.js +1 -0
  11. package/dist/autopilot-release-JVIJCTKX.js +1 -0
  12. package/dist/chunk-2C5ZBVBI.js +2 -0
  13. package/dist/{chunk-VB6I52ZT.js → chunk-2RL6RRT2.js} +2 -2
  14. package/dist/{chunk-FQSBOLM7.js → chunk-6JWNDWOA.js} +1 -1
  15. package/dist/chunk-D5YJOQYK.js +1 -0
  16. package/dist/{chunk-2VJUAKMS.js → chunk-DFG33SBR.js} +2 -2
  17. package/dist/chunk-FY4IIAIF.js +1 -0
  18. package/dist/{chunk-KJXMLBSY.js → chunk-HDNATYW7.js} +1 -1
  19. package/dist/chunk-HEZZ72V4.js +94 -0
  20. package/dist/{chunk-KANAJH65.js → chunk-HN7P4T3B.js} +1 -1
  21. package/dist/chunk-J7QYANXK.js +8 -0
  22. package/dist/{chunk-DK6JNE6K.js → chunk-JD3A5QM6.js} +1 -1
  23. package/dist/chunk-KLSSPJTV.js +1 -0
  24. package/dist/{chunk-DOXNVBX6.js → chunk-MDTI3UEB.js} +1 -1
  25. package/dist/chunk-MYJQGGIU.js +5 -0
  26. package/dist/chunk-NOV6723U.js +1 -0
  27. package/dist/chunk-NYEAMMUL.js +1 -0
  28. package/dist/chunk-O5B2L3R2.js +1 -0
  29. package/dist/chunk-OWB5KWSS.js +13 -0
  30. package/dist/chunk-P5PSZQPB.js +2 -0
  31. package/dist/chunk-QI3HG6IG.js +144 -0
  32. package/dist/chunk-SWGSFLTC.js +1 -0
  33. package/dist/chunk-U5FCQTVL.js +4 -0
  34. package/dist/chunk-VVJK5NFY.js +2 -0
  35. package/dist/chunk-VXKWWX7S.js +8 -0
  36. package/dist/chunk-W322YDHS.js +49 -0
  37. package/dist/chunk-WCJU3CFG.js +1 -0
  38. package/dist/chunk-WPRLXKWC.js +8 -0
  39. package/dist/{chunk-ZGS5NKEO.js → chunk-XGE2FDI4.js} +1 -1
  40. package/dist/{chunk-5SFCBZOH.js → chunk-YN5X2FTP.js} +1 -1
  41. package/dist/chunk-YOCN7GF4.js +1 -0
  42. package/dist/chunk-YYQEWAES.js +1 -0
  43. package/dist/chunk-ZEEV5J4I.js +1 -0
  44. package/dist/{create-PWJDTKDN.js → create-ALT2ME6H.js} +1 -1
  45. package/dist/{doctor-CGXY4IDE.js → doctor-RW4R3O5C.js} +1 -1
  46. package/dist/{goal-lifecycle-BRFFTIU2.js → goal-lifecycle-VYOKS6E6.js} +1 -1
  47. package/dist/goal-pack-YWPI43QL.js +1 -0
  48. package/dist/index.js +144 -144
  49. package/dist/{pipeline-DF4UIHAD.js → pipeline-U4N2DVD7.js} +1 -1
  50. package/dist/{project-agent-entry-IWUCV72J.js → project-agent-entry-YAQCHIMP.js} +1 -1
  51. package/dist/project-intelligence-lens-MRQR2LQW.js +1 -0
  52. package/dist/verified-goal-WM34TTGE.js +1 -0
  53. package/dist/{workspace-35Q2IXAR.js → workspace-HGUZWNAB.js} +1 -1
  54. package/dist/{workspace-agent-sync-FFNSW2PD.js → workspace-agent-sync-GEN3KBAX.js} +1 -1
  55. package/dist/{workspace-context-IJ36ZP6G.js → workspace-context-4WIWFW26.js} +1 -1
  56. package/dist/workspace-contract-7DXK4GF5.js +1 -0
  57. package/dist/{workspace-explain-TITIT5XN.js → workspace-explain-TE2LGOAV.js} +1 -1
  58. package/dist/{workspace-foundation-GMGDUMPR.js → workspace-foundation-J3NNRMI3.js} +1 -1
  59. package/dist/workspace-graph-stream-PQI7OGCE.js +1 -0
  60. package/dist/workspace-graph-token-efficiency-2I4X374C.js +1 -0
  61. package/dist/{workspace-intelligence-5NO4K5SC.js → workspace-intelligence-6FS26JOQ.js} +1 -1
  62. package/dist/{workspace-intelligence-runner-FGEBFVVM.js → workspace-intelligence-runner-XYUPCSLN.js} +1 -1
  63. package/dist/workspace-knowledge-graph-SWCKDTPF.js +1 -0
  64. package/dist/workspace-knowledge-graph-contract-L3CLAM2M.js +1 -0
  65. package/dist/{workspace-knowledge-graph-query-ON45H6Y7.js → workspace-knowledge-graph-query-FZXSPWGK.js} +1 -1
  66. package/dist/workspace-knowledge-graph-snapshot-M572JRB4.js +1 -0
  67. package/dist/workspace-mcp-serve-IBMTFQDY.js +3 -0
  68. package/dist/workspace-model-ZL6WCICX.js +1 -0
  69. package/dist/{workspace-onboarding-VS3YYNGK.js → workspace-onboarding-X3PWRIIS.js} +1 -1
  70. package/dist/{workspace-registry-summary-MIDFG6EC.js → workspace-registry-summary-LJN4WHIZ.js} +1 -1
  71. package/dist/workspace-repair-engine-NX7I632M.js +3 -0
  72. package/dist/workspace-run-6GT5OBQ5.js +1 -0
  73. package/dist/{workspace-verify-4R7QHUPO.js → workspace-verify-USRRIM2F.js} +1 -1
  74. package/dist/workspace-watch-43YZPLF7.js +1 -0
  75. package/docs/ci-workflows.md +1 -1
  76. package/docs/commands-reference.md +3 -1
  77. package/docs/workspace-knowledge-graph.md +36 -0
  78. package/docs/workspace-operations.md +22 -0
  79. package/docs/workspace-repair-engine.md +17 -0
  80. package/package.json +1 -1
  81. package/dist/analyze-NUGNB256.js +0 -1
  82. package/dist/autopilot-release-TWJWSVVF.js +0 -1
  83. package/dist/chunk-3A23KJAQ.js +0 -1
  84. package/dist/chunk-4PUJVYRM.js +0 -1
  85. package/dist/chunk-5B2GAZAC.js +0 -5
  86. package/dist/chunk-6DAQ7PYT.js +0 -13
  87. package/dist/chunk-CCAXADKP.js +0 -49
  88. package/dist/chunk-CJHWKXDN.js +0 -1
  89. package/dist/chunk-CT4IODPG.js +0 -2
  90. package/dist/chunk-DWB2RRF4.js +0 -1
  91. package/dist/chunk-ISOOENLW.js +0 -8
  92. package/dist/chunk-J7RU5WR5.js +0 -2
  93. package/dist/chunk-KV6PS54A.js +0 -8
  94. package/dist/chunk-NHTDPXTW.js +0 -4
  95. package/dist/chunk-Q2WF7D5U.js +0 -2
  96. package/dist/chunk-RSG2GJXT.js +0 -2
  97. package/dist/chunk-SFO5GVRT.js +0 -1
  98. package/dist/chunk-T5YRFRJV.js +0 -1
  99. package/dist/chunk-TOYN76K4.js +0 -144
  100. package/dist/chunk-U5WVR74V.js +0 -1
  101. package/dist/chunk-WY4DOMEA.js +0 -1
  102. package/dist/chunk-XKDR5BGS.js +0 -6
  103. package/dist/chunk-ZH7CXQH3.js +0 -94
  104. package/dist/goal-pack-FG3QDNQH.js +0 -1
  105. package/dist/project-intelligence-lens-PZPPSCUW.js +0 -1
  106. package/dist/verified-goal-BBHZRYYH.js +0 -1
  107. package/dist/workspace-contract-JS4LZZQZ.js +0 -1
  108. package/dist/workspace-graph-stream-7UU2YVHC.js +0 -1
  109. package/dist/workspace-graph-token-efficiency-D7CUT6NX.js +0 -1
  110. package/dist/workspace-knowledge-graph-RSDP2E36.js +0 -1
  111. package/dist/workspace-knowledge-graph-snapshot-3FJHH5IK.js +0 -1
  112. package/dist/workspace-mcp-serve-WUIQ2AE6.js +0 -3
  113. package/dist/workspace-model-OKY4CQ3X.js +0 -1
  114. package/dist/workspace-repair-engine-VUBT77Y7.js +0 -3
  115. package/dist/workspace-run-SSF6Z26G.js +0 -1
  116. package/dist/workspace-watch-IOPSHQS5.js +0 -1
@@ -0,0 +1 @@
1
+ var Z="workspace-knowledge-search.v1";function b(e){return e.trim().toLowerCase()}var F=new WeakMap;function A(e){let t=F.get(e);if(t)return t;let o=new Map(e.relations.map(s=>[s.id,s])),a=new Map(e.entities.map(s=>[s.id,s])),l=new Map(e.proofs.map(s=>[s.id,s])),r=new Map,d=new Map,u=(s,p)=>{let g=d.get(s)??[];g.push(p),d.set(s,g);};for(let s of e.entities){let p=[s.id,s.label,s.identity.key,...s.kind==="project"&&s.projectId?[s.projectId]:[],...s.identity.aliases];for(let g of new Set(p.map(b))){let k=r.get(g)??[];k.push(s),r.set(g,k);}}for(let s of e.relations)u(s.from,{from:s.from,to:s.to,relationId:s.id,kind:s.kind,direction:"forward",proofIds:s.proofIds}),u(s.to,{from:s.to,to:s.from,relationId:s.id,kind:s.kind,direction:"reverse",proofIds:s.proofIds});for(let s of r.values())s.sort((p,g)=>p.id.localeCompare(g.id));for(let s of d.values())s.sort((p,g)=>p.to.localeCompare(g.to)||p.relationId.localeCompare(g.relationId));let c={entitiesById:a,relationsById:o,entitiesByAlias:r,proofsById:l,adjacency:d};return F.set(e,c),c}function O(e,t){let o=A(e),a=o.relationsById.get(t);if(a)return {found:true,targetType:"relation",relation:a};let l=b(t),r=o.entitiesByAlias.get(l)??[];return r.length===1?{found:true,targetType:"entity",entity:r[0]}:{found:false,query:t,candidates:r.map(d=>d.id).sort()}}function ye(e,t){let o=O(e,t);if(!o.found)return {query:t,found:false,target:null,proofs:[],candidates:o.candidates};let a=o.targetType==="entity"?o.entity:o.relation,l=new Set(a.proofIds);return {query:t,found:true,target:a,candidates:[],proofs:[...l].map(r=>A(e).proofsById.get(r)).filter(r=>!!r).sort((r,d)=>r.id.localeCompare(d.id))}}function we(e,t,o){let a=O(e,t),l=O(e,o);if(!a.found||a.targetType!=="entity"||!l.found||l.targetType!=="entity")return {from:t,to:o,found:false,resolvedFrom:a.found&&a.targetType==="entity"?a.entity.id:null,resolvedTo:l.found&&l.targetType==="entity"?l.entity.id:null,entityPath:[],hops:[],proofs:[]};let r=A(e),d=[a.entity.id],u=new Map,c=new Set(d),s=0;for(;s<d.length&&!c.has(l.entity.id);){let h=d[s++];for(let y of r.adjacency.get(h)??[])c.has(y.to)||(c.add(y.to),u.set(y.to,y),d.push(y.to));}if(!c.has(l.entity.id))return {from:t,to:o,found:false,resolvedFrom:a.entity.id,resolvedTo:l.entity.id,entityPath:[],hops:[],proofs:[]};let p=[],g=l.entity.id;for(;g!==a.entity.id;){let h=u.get(g);if(!h)break;p.push(h),g=h.from;}p.reverse();let k=new Set(p.flatMap(h=>h.proofIds));return {from:t,to:o,found:true,resolvedFrom:a.entity.id,resolvedTo:l.entity.id,entityPath:[a.entity.id,...p.map(h=>h.to)],hops:p,proofs:[...k].map(h=>r.proofsById.get(h)).filter(h=>!!h).sort((h,y)=>h.id.localeCompare(y.id))}}function ke(e,t){return e.entities.filter(o=>!t||o.kind===t).sort((o,a)=>o.kind.localeCompare(a.kind)||o.label.localeCompare(a.label))}var m={relations:24,relatedEntities:24,proofs:16,proofIdsPerItem:4,aliasesPerEntity:8,attributeArrayItems:8,attributeStringCharacters:256};function J(e){let t=[],o=new Set;for(let a=0;a<m.proofIdsPerItem&&t.length<m.proofs;a+=1)for(let l of e){let r=l.proofIds[a];if(!(!r||o.has(r))&&(o.add(r),t.push(r),t.length>=m.proofs))break}return t}function ee(e,t,o){let a=e.identity.aliases.slice(0,m.aliasesPerEntity);o.aliases+=e.identity.aliases.length-a.length;let l=Object.fromEntries(Object.entries(e.attributes).map(([d,u])=>{if(Array.isArray(u)){let c=u.slice(0,m.attributeArrayItems);return o.attributeValues+=u.length-c.length,[d,c]}return typeof u=="string"&&u.length>m.attributeStringCharacters?(o.attributeValues+=1,[d,u.slice(0,m.attributeStringCharacters)]):[d,u]})),r=e.proofIds.filter(d=>t.has(d)).slice(0,m.proofIdsPerItem);return o.proofReferences+=e.proofIds.length-r.length,{...e,identity:{...e.identity,aliases:a},attributes:l,proofIds:r}}function te(e){let t=Object.values(e.attributes).flatMap(o=>Array.isArray(o)?o:[o]);return [e.id,e.kind,e.label,e.projectId??"",e.identity.key,...e.identity.aliases,...t.map(o=>String(o??""))].join(" ").toLowerCase()}var ne=new Set(["a","an","and","are","as","at","be","been","being","by","can","check","could","did","do","does","find","for","from","give","had","has","have","how","i","in","into","is","it","its","may","might","of","on","or","our","show","should","that","the","their","them","then","there","these","they","this","those","tell","to","was","we","were","what","when","where","which","who","why","will","with","would","you","your"]),oe=new Map([["authenticate","auth"],["authenticated","auth"],["authentication","auth"],["authorization","auth"],["authorizing","auth"],["config","configuration"],["configs","configuration"],["dependencies","dependency"],["diagnostics","diagnostic"],["reliable","reliability"],["tested","test"],["testing","test"],["tests","test"],["verification","verify"],["verified","verify"],["verifies","verify"],["verifying","verify"]]);function T(e){let t=o=>b(o).replace(/\bc\+\+/gu," cplusplus ").replace(/\bc#/gu," csharp ").split(/[^a-z0-9]+/u).filter(a=>a.length>1||a==="c"||a==="r").map(a=>oe.get(a)??a);return [...new Set([...t(e),...t(e.replace(/([a-z0-9])([A-Z])/g,"$1 $2"))])]}function se(e){let t=b(e.label),o=b(e.identity.key),a=e.identity.aliases.map(b),l=te(e);return {entity:e,label:t,identity:o,aliases:a,haystack:l,labelTokens:new Set(T(e.label)),identityTokens:new Set(T(e.identity.key)),aliasTokens:new Set(e.identity.aliases.flatMap(T)),allTokens:new Set(T(l))}}function S(e,t){return e.has(t)||t.length>=3&&[...e].some(o=>o.startsWith(t))}function G(e,t){return S(e.labelTokens,t)||S(e.identityTokens,t)||S(e.aliasTokens,t)||S(e.allTokens,t)}function ae(e,t,o,a){let{label:l,identity:r,aliases:d,haystack:u}=e,c=0;(l===t||r===t||d.includes(t))&&(c+=1e4),(l.startsWith(t)||r.startsWith(t))&&(c+=250),u.includes(t)&&(c+=100);let s=0;for(let p of o){let g=a.get(p)??1,k=S(e.labelTokens,p),h=S(e.identityTokens,p),y=S(e.aliasTokens,p),f=G(e,p);f&&(s+=1),l===p?c+=80*g:k&&(c+=36*g),h&&(c+=24*g),y&&(c+=20*g),f&&(c+=10*g);}return o.length>0&&(c+=s/o.length*120),c}function re(e,t){return t.filter(o=>G(e,o)).length}var ie=new Map([["c","c"],["clojure","clojure"],["cplusplus","cpp"],["cpp","cpp"],["typescript","typescript"],["ts","typescript"],["javascript","javascript"],["js","javascript"],["nodejs","javascript"],["python","python"],["py","python"],["go","go"],["golang","go"],["csharp","csharp"],["dotnet","csharp"],["dart","dart"],["elixir","elixir"],["fsharp","fsharp"],["java","java"],["kotlin","kotlin"],["lua","lua"],["php","php"],["r","r"],["ruby","ruby"],["rust","rust"],["scala","scala"],["svelte","svelte"],["swift","swift"],["vue","vue"]]);function ce(e){return new Set(e.map(t=>ie.get(t)).filter(t=>!!t))}function U(e){let t=e.attributes.language;return typeof t=="string"?b(t):null}function le(e){return {project:1e3,service:900,api:900,package:850,endpoint:800,container:700,deployment:700,environment:650,pipeline:600,"test-suite":550,owner:500,decision:450,document:400}[e.kind]??0}function de(e,t){let o=t.has("language")||t.has("languages"),a=t.has("binding")||t.has("bindings")||t.has("bridge")||t.has("bridges"),l=t.has("dependency")||t.has("dependencies")||t.has("depends"),r=t.has("core")||t.has("runtime"),d=t.has("owner")||t.has("owners")||t.has("ownership")||t.has("maintainer"),u=t.has("ci")||t.has("pipeline")||t.has("pipelines")||t.has("workflow"),c=t.has("deploy")||t.has("deployment")||t.has("infrastructure")||t.has("container"),s=t.has("doc")||t.has("docs")||t.has("document")||t.has("documentation"),p=t.has("service")||t.has("services")||t.has("api")||t.has("rpc"),g=t.has("schema")||t.has("schemas")||t.has("message")||t.has("protobuf")||t.has("proto")||t.has("contract"),k=typeof e.attributes.mechanism=="string"?b(e.attributes.mechanism):"",h=typeof e.attributes.specification=="string"?b(e.attributes.specification):"",y=b(e.label),f=0;if(o&&e.kind==="language"){let v=typeof e.attributes.fileCount=="number"?e.attributes.fileCount:0;f+=900+Math.min(v,1e4)/10;}return a&&e.kind==="protocol"&&(f+=800),l&&e.kind==="package"&&(f+=650),r&&e.kind==="package"&&/(?:^|[_-])core(?:$|[_-])/u.test(y)&&(f+=700),r&&e.kind==="protocol"&&k.includes("core")&&(f+=300),d&&e.kind==="owner"&&(f+=850),u&&e.kind==="pipeline"&&(f+=800),c&&["deployment","container","environment"].includes(e.kind)&&(f+=775),s&&["document","decision"].includes(e.kind)&&(f+=725),p&&["api","endpoint","service"].includes(e.kind)&&(f+=700),g&&(e.kind==="schema"||(e.kind==="api"||e.kind==="protocol")&&(h.includes("protobuf")||k.includes("protobuf")))&&(f+=750),f}function pe(e){return [e.has("language")||e.has("languages"),e.has("binding")||e.has("bindings")||e.has("bridge")||e.has("bridges"),e.has("dependency")||e.has("dependencies")||e.has("depends"),e.has("core")||e.has("runtime"),e.has("owner")||e.has("ownership")||e.has("maintainer"),e.has("ci")||e.has("pipeline")||e.has("workflow"),e.has("deploy")||e.has("deployment")||e.has("infrastructure"),e.has("doc")||e.has("docs")||e.has("documentation"),e.has("service")||e.has("api")||e.has("rpc"),e.has("schema")||e.has("protobuf")||e.has("proto")||e.has("contract")].filter(Boolean).length>=3}function me(e,t){let o=b(t.query),a=[...new Set(T(t.query))],l=new Set(T(t.projectId??"")),r=t.projectId?a.filter(n=>!l.has(n)):a,d=!!(t.projectId&&a.length>0&&r.length===0),u=r.filter(n=>!ne.has(n)),c=u.length>0?u:r,s=ce(c),p=new Set(c),g=pe(p),k=c.length<=1?c.length:Math.min(3,Math.ceil(c.length/3)),h=t.minimumTermMatches===void 0?k:Math.min(k,Math.max(1,Math.trunc(t.minimumTermMatches))),y=Math.max(1,Math.min(Math.trunc(t.limit??12),100)),f=Math.max(0,Math.min(Math.trunc(t.relationsPerEntity??4),20)),v=new Set;if(t.projectId){let n=new Set(e.entities.filter(i=>i.kind==="project"&&(i.projectId===t.projectId||i.label===t.projectId)).map(i=>i.id));for(let i of e.relations)n.has(i.from)&&v.add(i.to),n.has(i.to)&&v.add(i.from);}let x=e.entities.filter(n=>(!t.kind||n.kind===t.kind)&&(!t.projectId||n.projectId===t.projectId||n.projectId===void 0&&v.has(n.id))).map(se),Q=new Map(c.map(n=>{let i=x.filter(w=>G(w,n)).length;return [n,Math.log((x.length+1)/(i+1))+1]})),j=x.map(n=>{let i=re(n,c),w=U(n.entity),I=w&&s.has(w)?400:0,K=de(n.entity,p);return {entity:n.entity,matchedTerms:i,intentScore:K,score:d?le(n.entity):ae(n,o,c,Q)+I+K}}).filter(n=>{let i=U(n.entity);return (s.size===0||i===null||s.has(i))&&(o.length===0||n.score>0&&(d||n.matchedTerms>=h||n.intentScore>0&&(g||c.length<=2)))}).sort((n,i)=>i.score-n.score||n.entity.kind.localeCompare(i.entity.kind)||n.entity.label.localeCompare(i.entity.label)),E=(g?(()=>{let n=[],i=[],w=new Map,I=new Set;for(let K of j){let q=w.get(K.entity.kind)??0,V=b(K.entity.label);q<2&&!I.has(V)?(n.push(K),w.set(K.entity.kind,q+1),I.add(V)):i.push(K);}return [...n,...i]})():j).slice(0,y).map(n=>n.entity),P=new Set(E.map(n=>n.id)),H=new Map,B=e.relations.filter(n=>{if(!(P.has(n.from)||P.has(n.to)))return false;let w=P.has(n.from)?n.from:n.to,I=H.get(w)??0;return I>=f?false:(H.set(w,I+1),true)}),W=t.projection==="agent",M=W?B.slice(0,m.relations):B,D=A(e),_=[...new Set(M.flatMap(n=>[n.from,n.to]).filter(n=>!P.has(n)))].map(n=>D.entitiesById.get(n)).filter(n=>!!n).map(({id:n,kind:i,label:w,projectId:I})=>({id:n,kind:i,label:w,...I?{projectId:I}:{}})).sort((n,i)=>n.kind.localeCompare(i.kind)||n.label.localeCompare(i.label)),L=W?_.slice(0,m.relatedEntities):_,N=new Set([...E.flatMap(n=>n.proofIds),...M.flatMap(n=>n.proofIds)]),$=W?J([...E,...M]):[...N],C=new Set($),R={entities:j.length-E.length,relations:B.length-M.length,relatedEntities:_.length-L.length,proofs:N.size-C.size,proofReferences:0,aliases:0,attributeValues:0},z=W?E.map(n=>ee(n,C,R)):E,Y=W?M.map(n=>{let i=n.proofIds.filter(w=>C.has(w)).slice(0,m.proofIdsPerItem);return R.proofReferences+=n.proofIds.length-i.length,{...n,proofIds:i}}):M,X=[...C].map(n=>D.proofsById.get(n)).filter(n=>!!n).sort((n,i)=>n.id.localeCompare(i.id));return {schemaVersion:Z,query:t.query,kind:t.kind??null,...t.projectId?{projectId:t.projectId}:{},limit:y,totalMatches:j.length,truncated:j.length>z.length||W&&Object.values(R).some(n=>n>0),entities:z,relatedEntities:L,relations:Y,proofs:X,...W?{budget:{mode:"agent",limits:{...m},omitted:R}}:{}}}export{Z as a,O as b,ye as c,we as d,ke as e,me as f};
@@ -0,0 +1 @@
1
+ import {a as a$1}from'./chunk-LPCWROQ3.js';import {f,e as e$1,g,i}from'./chunk-NZ3WZYD5.js';var R=f.repairTransaction,C=e$1.repairTransaction,E=g.repairTransaction;var y="workspai.workspace-repair-proposal.v1",j="contracts/workspace-intelligence/workspace-repair-proposal.v1.json";var A="workspai.workspace-repair-capabilities.v1",b="workspai.workspace-repair-consumer-protocol.v1",v=["project","workspace","linked-project","polyglot-project"],d=["missing-tool","stale-evidence","missing-artifact","no-op-proposal","source-drift","validation-failure","producer-failure","provider-outage","interrupted-rollback","unsupported-runtime"],u=["automatic-refresh","bounded-replan","decision-required","checkpoint-rollback","durable-resume","manual-repair"],w={"missing-tool":"decision-required","stale-evidence":"automatic-refresh","missing-artifact":"automatic-refresh","no-op-proposal":"bounded-replan","source-drift":"bounded-replan","validation-failure":"checkpoint-rollback","producer-failure":"bounded-replan","provider-outage":"durable-resume","interrupted-rollback":"durable-resume","unsupported-runtime":"manual-repair"};function P(){let i=[],s=c.map(o=>o.id);new Set(s).size!==s.length&&i.push("adapter ids are not unique"),v.length<4&&i.push("scope matrix is incomplete"),d.length<10&&i.push("failure-family matrix is incomplete"),u.length<6&&i.push("recovery-path matrix is incomplete");for(let o of d){let t=w[o];u.includes(t)||i.push(`${o} has no bounded recovery policy`);}for(let o of c)for(let t of ["reconcile","audit","test","build"])o.stages[t]||i.push(`${o.id}.${t} is undeclared`);return i}var c=[{id:"node",ecosystem:"JavaScript / TypeScript",manifests:["package.json"],lockfiles:["package-lock.json","npm-shrinkwrap.json","pnpm-lock.yaml","yarn.lock","bun.lock","bun.lockb"],packageManagers:["npm","pnpm","yarn","bun"],support:"full",stages:{reconcile:"native",audit:"native",test:"declared",build:"declared"},requiredToolFamilies:["selected package manager"]},{id:"python",ecosystem:"Python",manifests:["pyproject.toml","requirements.txt"],lockfiles:["uv.lock","poetry.lock","requirements.txt"],packageManagers:["uv","poetry","pip"],support:"conditional",stages:{reconcile:"conditional",audit:"conditional",test:"conditional",build:"declared"},requiredToolFamilies:["isolated Python","selected environment manager","pip-audit or governed Doctor audit"],limitation:"A bounded isolated environment and an installed audit surface are required."},{id:"go",ecosystem:"Go",manifests:["go.mod"],lockfiles:["go.sum"],packageManagers:["go modules"],support:"conditional",stages:{reconcile:"native",audit:"conditional",test:"native",build:"native"},requiredToolFamilies:["go","govulncheck"],limitation:"govulncheck must be installed; the engine never fetches an unreviewed tool."},{id:"rust",ecosystem:"Rust",manifests:["Cargo.toml"],lockfiles:["Cargo.lock"],packageManagers:["cargo"],support:"conditional",stages:{reconcile:"native",audit:"conditional",test:"native",build:"native"},requiredToolFamilies:["cargo","cargo-audit"],limitation:"The cargo-audit subcommand must already be installed."},{id:"php-composer",ecosystem:"PHP",manifests:["composer.json"],lockfiles:["composer.lock"],packageManagers:["composer"],support:"full",stages:{reconcile:"native",audit:"native",test:"declared",build:"declared"},requiredToolFamilies:["composer"]},{id:"ruby-bundler",ecosystem:"Ruby",manifests:["Gemfile"],lockfiles:["Gemfile.lock"],packageManagers:["bundler"],support:"conditional",stages:{reconcile:"native",audit:"conditional",test:"declared",build:"declared"},requiredToolFamilies:["bundle","bundle-audit"],limitation:"bundle-audit and the declared Rake tasks must already exist."},{id:"elixir-mix",ecosystem:"Elixir",manifests:["mix.exs"],lockfiles:["mix.lock"],packageManagers:["mix"],support:"conditional",stages:{reconcile:"native",audit:"conditional",test:"native",build:"native"},requiredToolFamilies:["mix","Hex audit task"],limitation:"The project must expose the Hex audit task used by its dependency policy."},{id:"deno",ecosystem:"Deno",manifests:["deno.json","deno.jsonc"],lockfiles:["deno.lock"],packageManagers:["deno"],support:"full",stages:{reconcile:"native",audit:"native",test:"declared",build:"declared"},requiredToolFamilies:["deno"]},{id:"dotnet",ecosystem:".NET",manifests:["*.sln","*.csproj","*.fsproj","*.vbproj"],lockfiles:["Directory.Packages.props","packages.lock.json"],packageManagers:["NuGet / dotnet"],support:"full",stages:{reconcile:"native",audit:"native",test:"native",build:"native"},requiredToolFamilies:["dotnet"]},{id:"jvm-maven",ecosystem:"JVM / Maven",manifests:["pom.xml"],lockfiles:[],packageManagers:["Maven Wrapper","Maven"],support:"conditional",stages:{reconcile:"native",audit:"conditional",test:"native",build:"native"},requiredToolFamilies:["mvnw or mvn","governed Doctor audit"],limitation:"A project-specific dependency audit command must be declared by Doctor evidence."},{id:"jvm-gradle",ecosystem:"JVM / Gradle",manifests:["build.gradle.kts","build.gradle"],lockfiles:["gradle.lockfile","gradle/libs.versions.toml"],packageManagers:["Gradle Wrapper","Gradle"],support:"conditional",stages:{reconcile:"native",audit:"conditional",test:"native",build:"native"},requiredToolFamilies:["gradlew or gradle","governed Doctor audit"],limitation:"A project-specific dependency audit command must be declared by Doctor evidence."},{id:"clojure",ecosystem:"Clojure",manifests:["deps.edn","project.clj"],lockfiles:[],packageManagers:["Clojure CLI","Leiningen"],support:"conditional",stages:{reconcile:"native",audit:"conditional",test:"conditional",build:"conditional"},requiredToolFamilies:["clojure or lein","governed project audit"],limitation:"Tests and builds run only when the selected Clojure project surface declares a deterministic entrypoint."},{id:"scala-sbt",ecosystem:"Scala / sbt",manifests:["build.sbt"],lockfiles:[],packageManagers:["sbt"],support:"conditional",stages:{reconcile:"native",audit:"conditional",test:"native",build:"native"},requiredToolFamilies:["sbt","governed project audit"],limitation:"A project-specific dependency audit command must be declared by Doctor evidence."}];function M(){let i=P();if(i.length>0)throw new Error(`Workspace Repair qualification matrix is incomplete: ${i.join("; ")}`);return {schemaVersion:A,owner:"Workspai CLI",workflow:["plan","preconditions","approval","target-precondition","checkpoint","execute","reconcile","audit","test","build","target-producer-verify","canonical-verify","close-or-rollback-or-decision"],invariants:{multiAdapterProjects:true,missingTools:"decision-required",unsupportedEcosystems:"decision-required",silentFallbackToModelExecution:false,mutationAuthority:"cli-only",targetClosure:"selected-causal-action-set",changeReceipt:"checkpoint-hash-delta",consumerTimeline:"durable-transaction-events",typedDecisionCauses:true,registeredLinkedProjectMutationBoundary:true,sourceProposalIntegrity:"project-bound-hash-pinned",completionAuthority:"cli-verification-receipt",goalSourceTransition:"closed-integrity-bound-v1",goalAttemptBudget:"durable-serialized-v1",consumerHandshakeRequired:true,ephemeralProposalsAreEvidence:false,approvalBoundToPlanHash:true,canonicalVerificationRequired:true,rollbackConflictDetection:true},consumerProtocol:{protocolVersion:b,versionProbe:{args:["--version","--json"],schemaVersion:"rapidkit-version-v1"},capabilityProbe:{args:["workspace","repair","capabilities","--json"],schemaVersion:A},invocation:{command:"workspace repair",workspaceResolution:["process-cwd","--workspace"],actions:["capabilities","plan","propose","approve","decide","execute","resume","status","list","rollback","cancel"]},contracts:{operationResult:a$1,proposal:y,transaction:R},transientPaths:[".workspai/repair/inbox/*.json",".workspai/repair/engine.lock"]},qualificationMatrix:{schemaVersion:"workspai.workspace-repair-qualification-matrix.v1",status:"contract-enforced",dimensions:{adapters:c.map(s=>s.id),scopes:v,failureFamilies:d,recoveryPaths:u,failureRecoveryPolicy:w},invariants:{everyAdapterDeclaresClosureStages:true,everyFailureTerminates:true,everyMutationIsCheckpointed:true,workspaceAndProjectScopesUseTheSameEngine:true,linkedProjectsRemainBoundaryChecked:true}},adapters:c}}var V="workspai.studio-card-repair-capabilities.v1",h="npx workspai workspace verify --json",r=e$1,a=i;function e(i,s,o,t={}){return {cardId:i,scope:t.scope??"workspace",producerCommand:s,producerArtifact:o,verifyCommand:s,verifyArtifact:o,aggregateVerifyCommand:h,targetClosure:"exact-producer-and-causal-action-set",aggregateRepair:"sequential-causal-queue",transactionScope:"one-causal-finding-family",workspacePosture:"reported-separately",repairPolicy:t.repairPolicy??"refresh-producer",remediationArtifacts:t.remediationArtifacts??[]}}var H=[e("doctor","npx workspai doctor workspace --json",r.doctor,{repairPolicy:"diagnose-and-repair",remediationArtifacts:[a.doctorRemediationPlan,a.artifactRemediationPlan]}),e("projectDoctor","npx workspai doctor project --json",a.doctorProject,{scope:"project",repairPolicy:"diagnose-and-repair",remediationArtifacts:[a.doctorRemediationPlan,a.artifactRemediationPlan]}),e("pipeline","npx workspai pipeline --json --strict",a.pipelineLastRun,{repairPolicy:"source-repair-then-produce",remediationArtifacts:[a.artifactRemediationPlan]}),e("analyze","npx workspai analyze --json",r.analyze,{repairPolicy:"source-repair-then-produce",remediationArtifacts:[a.artifactRemediationPlan]}),e("readiness","npx workspai readiness --json",r.readiness,{repairPolicy:"source-repair-then-produce",remediationArtifacts:[a.artifactRemediationPlan]}),e("bootstrap","npx workspai bootstrap --ci --json",a.bootstrapCompliance,{repairPolicy:"source-repair-then-produce",remediationArtifacts:[a.artifactRemediationPlan]}),e("workspaceSync","npx workspai workspace sync --json",a.workspaceRegistry),e("foundation","npx workspai workspace foundation ensure --json",".workspai/workspace.json"),e("contract","npx workspai workspace contract verify --strict --json",r.contractVerify,{repairPolicy:"source-repair-then-produce"}),e("autopilot","npx workspai autopilot release --json",a.autopilotReleaseLastRun,{repairPolicy:"source-repair-then-produce"}),e("workspaceRun","npx workspai workspace run test --json",a.workspaceRunLast,{repairPolicy:"source-repair-then-produce",remediationArtifacts:[a.artifactRemediationPlan]}),e("setup","npx workspai setup --json",".workspai/toolchain.lock",{repairPolicy:"source-repair-then-produce"}),e("importReadiness","npx workspai doctor project --json",a.doctorProject,{scope:"project",repairPolicy:"diagnose-and-repair",remediationArtifacts:[a.artifactRemediationPlan]}),e("snapshot","npx workspai snapshot create --json",".workspai/reports/snapshot-last-run.json"),e("workspaceModel","npx workspai workspace model --json --write",r.model),e("intelligenceSnapshot","npx workspai workspace snapshot --json",r.snapshot),e("workspaceDiff",`npx workspai workspace diff --from ${r.snapshot} --json`,r.diff),e("workspaceImpact",`npx workspai workspace impact --from ${r.diff} --json`,r.impact),e("workspaceIntelligenceRun","npx workspai workspace intelligence run --for-agent generic --strict --json",r.intelligenceRun,{repairPolicy:"source-repair-then-produce"}),e("workspaceVerify",h,r.verify,{repairPolicy:"source-repair-then-produce",remediationArtifacts:[a.artifactRemediationPlan]}),e("workspaceExplain","npx workspai workspace explain release-blocked --json --write",r.explain),e("workspaceWhy","npx workspai workspace why release-blocked --json --write",a.workspaceWhy),e("workspaceTrace",`npx workspai workspace trace --from ${r.diff} --json --write`,a.workspaceTrace),e("workspaceWatch","npx workspai workspace watch --once --json",r.model),e("workspaceContextAgent","npx workspai workspace context --for-agent --json --write",r.agentContext),e("agentGrounding","npx workspai workspace agent-sync --write --refresh-context --json --preset enterprise --target vscode",r.agentCustomizationPack),e("share",`npx workspai workspace share --output ${a.workspaceShareBundle} --json`,a.workspaceShareBundle),e("archive","npx workspai workspace export --output team-workspace.workspai-archive.zip --json",".workspai/archive-manifest.json"),e("mirror","npx workspai mirror status --json",a.mirrorOps),e("cache","npx workspai cache status --json",".workspai/cache-config.yml"),e("policy","npx workspai workspace policy show --json",".workspai/policies.yml",{repairPolicy:"source-repair-then-produce"}),e("infra","npx workspai infra plan --json",a.infraPlan,{repairPolicy:"source-repair-then-produce"})];export{R as a,C as b,E as c,y as d,j as e,A as f,c as g,M as h,V as i,H as j};
@@ -0,0 +1 @@
1
+ import p from'path';import m from'fs-extra';var y=new Set([".git",".workspai",".rapidkit",".venv","node_modules","target","dist","build","coverage","vendor"]),x=new Set(["test","tests","__tests__","spec","specs"]);function f(n){let t=n.toLowerCase();return t.endsWith(".rs")?"rust":t.endsWith(".go")?"go":t.endsWith(".py")?"python":/\.(?:test|spec)\.[cm]?[jt]sx?$/.test(t)?"node":t.endsWith(".java")?"java":t.endsWith(".kt")||t.endsWith(".kts")?"kotlin":t.endsWith(".exs")?"elixir":t.endsWith(".php")?"php":t.endsWith(".rb")?"ruby":t.endsWith(".cs")?"dotnet":t.endsWith(".c")?"c":/\.(?:cc|cpp|cxx)$/.test(t)?"cpp":null}function g(n,t){return t&&f(n)?true:/(?:^test[_-].+|[_-]test|\.test|\.spec|tests?)\.(?:rs|go|py|[cm]?[jt]sx?|java|kts?|exs|php|rb|cs|c|cc|cpp|cxx)$/i.test(n)}async function w(n,t={}){let h=t.maxDepth??6,u=t.maxEntries??5e3,c=new Set,r=false,a=0;try{let s=(await m.readJson(p.join(n,"package.json")))?.scripts?.test;typeof s=="string"&&s.trim()&&(r=true,c.add("node"));}catch{}let d=[{dir:n,depth:0,insideTestDirectory:false}];for(;d.length>0&&a<u;){let i=d.shift();if(!i)break;let s;try{s=await m.readdir(i.dir,{withFileTypes:true});}catch{continue}for(let e of s){if(a+=1,a>u)break;if(y.has(e.name))continue;let l=p.join(i.dir,e.name);if(e.isDirectory()){let o=i.insideTestDirectory||x.has(e.name.toLowerCase());o&&(r=true),i.depth<h&&!e.name.startsWith(".")&&d.push({dir:l,depth:i.depth+1,insideTestDirectory:o});continue}if(e.isFile()){if(g(e.name,i.insideTestDirectory)){r=true;let o=f(e.name);o&&c.add(o);}/^(?:pytest\.ini|tox\.ini|noxfile\.py|phpunit\.xml(?:\.dist)?|\.rspec)$/i.test(e.name)&&(r=true),/^(?:vitest|jest|playwright|cypress)\.config\.[cm]?[jt]s$/i.test(e.name)&&(r=true,c.add("node"));}}}return {detected:r,runtimeFamilies:[...c].sort()}}export{w as a};
@@ -1 +1 @@
1
- export{b as buildWorkspaceManifest,f as createProject,a as initializeStandaloneGitRepository,g as registerWorkspaceAtPath,d as resolvePythonFreeFallbackProfile,c as syncWorkspaceFoundationFiles,e as writeWorkspaceLauncher}from'./chunk-KANAJH65.js';
1
+ export{b as buildWorkspaceManifest,f as createProject,a as initializeStandaloneGitRepository,g as registerWorkspaceAtPath,d as resolvePythonFreeFallbackProfile,c as syncWorkspaceFoundationFiles,e as writeWorkspaceLauncher}from'./chunk-HN7P4T3B.js';
@@ -1 +1 @@
1
- export{a as DOCTOR_WORKSPACE_REPORT_PATH,n as applyEnvKeyAddFix,j as applyFileAppendFix,k as applyFileCopyFix,i as applyFileCreateFix,m as applyJsonEditFix,o as applyMakefileTargetFix,h as applyPackageScriptFix,f as assertOperationPathInsideProject,g as assertOperationPathInsideProjectResolved,e as buildRepairOperationIdentity,q as computeDoctorFixAwareExitCode,p as computeDoctorGateExitCode,l as decodeJsonPointerSegment,d as parseInternalRepairCommand,c as parsePackageScriptFix,b as resolveDoctorPolicyProfile,r as runDoctor}from'./chunk-ZH7CXQH3.js';
1
+ export{a as DOCTOR_WORKSPACE_REPORT_PATH,n as applyEnvKeyAddFix,j as applyFileAppendFix,k as applyFileCopyFix,i as applyFileCreateFix,m as applyJsonEditFix,o as applyMakefileTargetFix,h as applyPackageScriptFix,f as assertOperationPathInsideProject,g as assertOperationPathInsideProjectResolved,e as buildRepairOperationIdentity,q as computeDoctorFixAwareExitCode,p as computeDoctorGateExitCode,l as decodeJsonPointerSegment,d as parseInternalRepairCommand,c as parsePackageScriptFix,b as resolveDoctorPolicyProfile,r as runDoctor}from'./chunk-HEZZ72V4.js';
@@ -1 +1 @@
1
- export{f as GOAL_INDEX_PATH,e as GOAL_INDEX_SCHEMA_VERSION,k as buildGoalLifecycleResult,l as inspectGoalLifecycle,p as linkGoalRepairTransaction,n as prepareGoalVerification,m as transitionGoalLifecycle,o as verifyGoalLifecycle}from'./chunk-DOXNVBX6.js';
1
+ export{f as GOAL_INDEX_PATH,e as GOAL_INDEX_SCHEMA_VERSION,k as buildGoalLifecycleResult,l as inspectGoalLifecycle,p as linkGoalRepairTransaction,n as prepareGoalVerification,m as transitionGoalLifecycle,o as verifyGoalLifecycle}from'./chunk-MDTI3UEB.js';
@@ -0,0 +1 @@
1
+ import {c}from'./chunk-NYEAMMUL.js';import {c as c$4}from'./chunk-JQLJBK5N.js';import {j,i,d as d$1,f as f$2,c as c$3,e as e$1,h}from'./chunk-MDTI3UEB.js';export{b as GOAL_AGENT_HANDOFF_SCHEMA_VERSION,f as GOAL_INDEX_PATH,e as GOAL_INDEX_SCHEMA_VERSION,g as GOAL_LIFECYCLE_RESULT_SCHEMA_VERSION,d as GOAL_PACK_LAST_RUN_PATH,a as GOAL_PACK_SCHEMA_VERSION,c as GOAL_PLAN_RESULT_SCHEMA_VERSION}from'./chunk-MDTI3UEB.js';import {f as f$3}from'./chunk-YOCN7GF4.js';import {b}from'./chunk-L22EABIC.js';import {a as a$1}from'./chunk-O5B2L3R2.js';import {b as b$1}from'./chunk-VXKWWX7S.js';import {c as c$2,f as f$1}from'./chunk-CCDGHPEJ.js';import {a}from'./chunk-AFIFZTOY.js';import {d,c as c$1}from'./chunk-EWZZUQBR.js';import {f,e}from'./chunk-NZ3WZYD5.js';import C from'path';import _ from'fs-extra';var ve=/[\u0000-\u0008\u000b\u000c\u000e-\u001f\u007f]/,ye=/(?:^|\s)(?:\/(?:home|Users|private|var|tmp|mnt|opt|srv|root|workspace|workspaces|data|Volumes|etc|usr|run|dev|proc|sys)\/[^\s]+|[A-Za-z]:[\\/][^\s]+|\\\\[^\\\s]+\\[^\s]+)/,Pe=/(?:-----BEGIN (?:RSA |EC |OPENSSH )?PRIVATE KEY-----|\b(?:github_pat_|gh[pousr]_|glpat-|npm_|xox[baprs]-|sk-(?:proj-)?)[A-Za-z0-9_-]{12,}|\b(?:AKIA|ASIA)[A-Z0-9]{16}\b|\bAIza[A-Za-z0-9_-]{20,}|\bBearer\s+[A-Za-z0-9._~+/-]{16,}|[a-z][a-z0-9+.-]*:\/\/[^\s:/]+:[^\s@/]+@|\b(?:password|passwd|secret|token|api[_-]?key)\s*[:=]\s*[^\s]{6,})/i,je=[{category:"test-coverage",patterns:[/\b(?:test\s+)?coverage\b/i,/\bcoverage\s+(?:to|above|at least)\b/i]},{category:"dependency-security",patterns:[/\b(?:dependency|dependencies|package|packages)\b.*\b(?:security|vulnerab|audit)\b/i,/\b(?:security|vulnerab|audit)\b.*\b(?:dependency|dependencies|package|packages)\b/i]},{category:"release-readiness",patterns:[/\brelease[ -]readiness\b/i,/\bready (?:this |the )?(?:workspace|project) for release\b/i,/\bprepare (?:this |the )?(?:workspace|project) for release\b/i,/\bprepare\b[^\n]{0,80}\bfor release\b/i]},{category:"defect-repair",patterns:[/\b(?:fix|repair|resolve|debug)\b.*\b(?:bug|error|failure|issue|regression)\b/i]},{category:"performance",patterns:[/\b(?:performance|latency|throughput|cpu|optimi[sz]e|faster|slower)\b/i,/\b(?:memory\s+(?:allocation|consumption|footprint|leak|pressure|usage)|out[ -]of[ -]memory|heap|ram)\b/i]},{category:"refactor",patterns:[/\b(?:refactor|restructure|decouple|extract|simplify|cleanup|clean up)\b/i]},{category:"documentation",patterns:[/\b(?:document|documentation|readme|guide|tutorial|docs)\b/i]},{category:"feature-change",patterns:[/\b(?:add|build|create|enforce|enhance|harden|implement|improve|introduce|support)\b/i]},{category:"system-understanding",patterns:[/\b(?:understand|explain|map|find|where|how|architecture|analy[sz]e|search)\b/i]}];function Ge(e){if(typeof e!="string")throw new Error("Goal intent must be text.");let t=e.trim().replace(/\s+/g," ");if(!t)throw new Error("Goal intent cannot be empty.");if(t.length>2e3)throw new Error("Goal intent exceeds the 2000 character safety limit.");if(ve.test(t))throw new Error("Goal intent contains unsupported control characters.");if(ye.test(t))throw new Error("Goal intent contains a machine-local absolute path. Use a workspace-relative path or project scope.");if(Pe.test(t))throw new Error("Goal intent appears to contain secret material and was not persisted.");return t}function Ce(e){let t=e.match(/\b(?:coverage\D{0,24})?(100|\d{1,2})(?:\.\d+)?\s*%/i);if(!t||!/coverage/i.test(e))return null;let n=Number(t[1]);return Number.isFinite(n)&&n>=0&&n<=100?n:null}var ne=[{runtime:"cpp",patterns:[/\bc\+\+/i,/\bcpp\b/i]},{runtime:"dotnet",patterns:[/\.net\b/i,/\bdotnet\b/i,/\bc#/i,/\bcsharp\b/i]},{runtime:"node",patterns:[/\bnode(?:\.js)?\b/i,/\btypescript\b/i,/\bjavascript\b/i,/\b(?:js|ts)\b/i]},{runtime:"python",patterns:[/\bpython\b/i,/\bpytest\b/i]},{runtime:"go",patterns:[/\bgolang\b/i,/\bgo(?:\s+(?:test|coverage|tests))\b/i]},{runtime:"java",patterns:[/\bjava\b/i,/\bjunit\b/i,/\bjacoco\b/i]},{runtime:"rust",patterns:[/\brust\b/i,/\bcargo\b/i]},{runtime:"php",patterns:[/\bphp\b/i,/\bphpunit\b/i]},{runtime:"ruby",patterns:[/\bruby\b/i,/\brspec\b/i]},{runtime:"kotlin",patterns:[/\bkotlin\b/i]},{runtime:"scala",patterns:[/\bscala\b/i]},{runtime:"clojure",patterns:[/\bclojure\b/i]},{runtime:"elixir",patterns:[/\belixir\b/i]},{runtime:"deno",patterns:[/\bdeno\b/i]},{runtime:"bun",patterns:[/\bbun\b/i]},{runtime:"c",patterns:[/\bc(?:\s+(?:test|coverage|tests|code))\b/i]}];function Ae(e){return ne.filter(t=>t.patterns.some(n=>n.test(e))).map(t=>t.runtime)}function K(e,t={}){let n=Ge(e),r=je.filter(u=>u.patterns.some(j=>j.test(n))).map(u=>u.category),a=r.some(u=>u!=="feature-change")?r.filter(u=>u!=="feature-change"):r,s=a[0]??"feature-change",l=Ce(n),d=Ae(n),p=d.length===0&&t.selectedCoverageRuntime?[t.selectedCoverageRuntime]:d,m=[...new Set((t.availableCoverageRuntimes??[]).filter(u=>ne.some(j=>j.runtime===u)))].sort(),b=[];return a.length>1&&a[0]!=="test-coverage"&&b.push(`The intent also contains signals for: ${a.slice(1).join(", ")}.`),s==="test-coverage"&&l===null&&b.push("A numeric test coverage target is required for machine verification."),s==="test-coverage"&&p.length>1&&b.push(`The Goal names multiple coverage runtimes: ${p.join(", ")}. Select one runtime per Goal.`),s==="test-coverage"&&p.length===0&&m.length>1&&b.push(`Coverage scope is ambiguous across detected runtimes: ${m.join(", ")}. Name one runtime or language in the Goal.`),s==="test-coverage"&&p.length===1&&m.length>0&&!m.includes(p[0])&&b.push(`The requested ${p[0]} coverage runtime is not present in the selected scope. Detected runtimes: ${m.join(", ")}.`),{original:n,normalized:n.toLocaleLowerCase("en-US"),statement:n.replace(/[.!?]+$/,""),category:s,confidence:a.length===1?"high":a.length>1?"medium":"low",ambiguities:b,...l===null?{}:{requestedTarget:{metric:"test-coverage-percent",operator:"at-least",value:l,...p.length===1?{runtime:p[0]}:{}}}}}function oe(e){let t={"test-coverage":["test suite coverage configuration instrumentation","CI tests LCOV Cobertura JaCoCo LLVM coverage"],"dependency-security":["dependency manifest lockfile security audit vulnerability"],"release-readiness":["release pipeline readiness gates build test deploy"],"defect-repair":["failure error test implementation call path"],"feature-change":["API implementation module dependency tests"],refactor:["module dependency ownership implementation tests"],performance:["performance benchmark latency throughput runtime"],documentation:["documentation README guide architecture decision"],"system-understanding":["architecture service API dependency ownership"]};return [...new Set([e.statement,...t[e.category]])].slice(0,3)}var ae="contracts/workspace-intelligence/goal-pack.v1.json",se="contracts/workspace-intelligence/goal-agent-handoff.v1.json",Re="contracts/workspace-intelligence/goal-plan-result.v1.json",pe="contracts/workspace-intelligence/goal-index.v1.json",ue=new Set(["node","bun","deno","python","go","java","dotnet","rust","php","ruby","elixir","clojure","scala","kotlin","c","cpp"]);function Se(e,t){let n=e.match(/[A-Za-z0-9][A-Za-z0-9+#.%_-]*/g)??[],r=new Set(t.map(m=>m.toLocaleLowerCase("en-US").replace(/[^a-z0-9]/g,"")).filter(Boolean)),a=[];for(let m=0;m<n.length;){let b=0;for(let u=Math.min(4,n.length-m);u>=1;u-=1){let j=n.slice(m,m+u).join("").toLocaleLowerCase("en-US").replace(/[^a-z0-9]/g,"");if(r.has(j)){b=u;break}}if(b>0){m+=b;continue}a.push(n[m]),m+=1;}let s=a.findIndex((m,b)=>{let u=m.toLocaleLowerCase("en-US"),j=a[b+1]?.toLocaleLowerCase("en-US");return u==="without"&&["breaking","changing","modifying","removing"].includes(j??"")||u==="while"&&["keeping","maintaining","preserving"].includes(j??"")}),l=s>=2?a.slice(0,s):a,d=l.length>=2?l.join(" "):e;if(s<2)return [d];let p=a.slice(s).filter(m=>!["without","while","breaking","changing","modifying","removing","keeping","maintaining","preserving"].includes(m.toLocaleLowerCase("en-US")));return p.length>0?[d,p.join(" ")]:[d]}function ie(e){return e.split(C.sep).join("/")}function V(e,t){return C.resolve(t.absolutePath??C.join(e,t.path))}function ce(e){let t=e.requested.trim().replace(/^project:/,"");if(!t)throw new Error("Project goal scope must name a project.");let n=C.isAbsolute(t)?C.resolve(t):null,r=e.model.projects.filter(a=>a.name===t||ie(a.path)===ie(t)||n!==null&&V(e.workspacePath,a)===n);if(r.length!==1)throw new Error(r.length===0?`Project goal scope was not found in the canonical model: ${t}`:`Project goal scope is ambiguous in the canonical model: ${t}`);return r[0]}async function Ee(e){let t=await a$1(e);if(t.status==="miss")throw new Error(`Canonical model and live graph evidence are required (${t.reason}). Run \`workspai workspace intelligence run --for-agent generic --strict --json\` or retry with --refresh.`);let{model:n,graph:r}=t;return a(n,"contracts/workspace-intelligence/workspace-model.v1.json","Goal source model"),a(r,"contracts/workspace-intelligence/workspace-knowledge-graph.v1.json","Goal source graph"),b$1(r,n),{model:n,graph:r}}function le(e){let t=e.scope.trim();if(t==="workspace")return {kind:"workspace",projects:e.model.projects.map(r=>r.name).sort(),selectionSource:e.selectionSource,resolution:"selected"};let n=t.startsWith("projects:")?"projects:":t.startsWith("project:")&&t.slice(8).includes(",")?"project:":null;if(n){let r=t.slice(n.length).split(",").map(l=>l.trim()).filter(Boolean);if(r.length<2)throw new Error("A project-set Goal scope must name at least two projects.");let a=r.map(l=>ce({workspacePath:e.workspacePath,model:e.model,requested:l})),s=[...new Set(a.map(l=>l.name))].sort();if(s.length!==r.length)throw new Error("A project-set Goal scope must not contain duplicate projects.");return {kind:"project-set",projects:s,selectionSource:e.selectionSource,resolution:"selected"}}if(t)return {kind:"project",projects:[ce({workspacePath:e.workspacePath,model:e.model,requested:t}).name],selectionSource:e.selectionSource,resolution:"selected"};throw new Error("Goal scope cannot be empty.")}async function Ie(e){if(e.explicitScope?.trim())return {scope:le({workspacePath:e.workspacePath,model:e.model,scope:e.explicitScope,selectionSource:"explicit"}),selectionRequired:false};if(e.invocationProjectPath){let t=C.resolve(e.invocationProjectPath),n=e.model.projects.filter(r=>V(e.workspacePath,r)===t);if(n.length!==1)throw new Error("The invocation project is not represented uniquely in the canonical workspace model. Refresh intelligence or pass --scope explicitly.");return {scope:{kind:"project",projects:[n[0].name],selectionSource:"invocation-project",resolution:"selected"},selectionRequired:false}}if(e.model.projects.length===1)return {scope:{kind:"project",projects:[e.model.projects[0].name],selectionSource:"single-project-workspace",resolution:"selected"},selectionRequired:false};if(e.selectScope){let t=await e.selectScope({workspaceName:e.model.workspace.name,projects:e.model.projects.map(r=>({name:r.name,runtime:r.runtime,runtimeCandidates:[...r.runtimeCandidates].sort(),framework:r.framework})).sort((r,a)=>r.name.localeCompare(a.name))}),n=t.kind==="workspace"?"workspace":t.projects.length===1?`project:${t.projects[0]}`:`projects:${t.projects.join(",")}`;return {scope:le({workspacePath:e.workspacePath,model:e.model,scope:n,selectionSource:"interactive"}),selectionRequired:false}}return {scope:{kind:"workspace",projects:e.model.projects.map(t=>t.name).sort(),selectionSource:"workspace",resolution:"selection-required"},selectionRequired:true}}function xe(e,t){if(t.kind==="workspace")return {entities:e.quality.entityCount,relationships:e.quality.relationCount,proofs:e.quality.proofCount,unresolved:e.quality.unknownCount,proofCoveragePercent:Number((e.quality.relationProofCoverageRatio*100).toFixed(2))};let n=new Set(t.projects),r=e.entities.filter(p=>p.projectId!==void 0&&n.has(p.projectId)),a=new Set(r.map(p=>p.id)),s=e.relations.filter(p=>a.has(p.from)||a.has(p.to)),l=new Set([...r.flatMap(p=>p.proofIds),...s.flatMap(p=>p.proofIds)]),d=s.filter(p=>p.proofIds.length>0).length;return {entities:r.length,relationships:s.length,proofs:l.size,unresolved:s.length-d,proofCoveragePercent:s.length===0?100:Number((d/s.length*100).toFixed(2))}}function Te(e){let t=new Map;for(let r of e){let a=t.get(r.kind)??[];a.push(r),t.set(r.kind,a);}let n=[];for(let r=0;[...t.values()].some(a=>r<a.length);r+=1)for(let a of t.values()){let s=a[r];s&&n.push(s);}return n}async function _e(e$1){let t=C.join(e$1.workspacePath,e.intelligenceRun),n=await _.readJson(t).catch(()=>null),a=(Array.isArray(n?.stages)?n.stages:[]).filter(o=>o.status==="blocked"||o.status==="failed").map(o=>String(o.id??"unknown")).sort(),s=n?.status,l={status:s==="passed"?"passed":s==="blocked"||s==="failed"?"blocked":"unknown",artifact:e.intelligenceRun,blockedStages:a},d={status:"not-applicable",runtime:null,runtimeChoices:[],runner:null,existingEvidence:[],prerequisites:[]};if(e$1.intent.category==="test-coverage"){let o=e$1.intent.requestedTarget?.runtime;if(e$1.intent.ambiguities.some(P=>P.startsWith("Coverage scope is ambiguous")||P.startsWith("The Goal names multiple coverage runtimes")||P.startsWith("The selected projects do not share a common canonical coverage runtime")||P.startsWith("The requested ")))d={status:"requires-setup",runtime:o??null,runtimeChoices:e$1.coverageRuntimeChoices,runner:null,existingEvidence:[],prerequisites:["Select exactly one detected runtime or language for this coverage Goal."]};else {let P=o?e$1.projects.filter(c=>c.runtimeCandidates.includes(o)):e$1.projects,i=await Promise.all(P.map(async c=>({project:c,capability:await c$4(V(e$1.workspacePath,c),o??(ue.has(c.runtime)?c.runtime:"unknown"))}))),h=i.map(c=>c.capability.status);d={status:h.includes("unsupported")?"unsupported":h.includes("requires-setup")?"requires-setup":"available",runtime:i.length===1?i[0].capability.runtime:[...new Set(i.map(c=>c.capability.runtime))].join(","),runtimeChoices:e$1.coverageRuntimeChoices,runner:i.length===1?i[0].capability.runner:[...new Set(i.flatMap(c=>c.capability.runner?[c.capability.runner]:[]))].join(",")||null,existingEvidence:i.flatMap(c=>c.capability.existingEvidence.map(A=>({project:c.project.name,...A}))).filter((c,A,w)=>w.findIndex(k=>k.project===c.project&&k.path===c.path&&k.sha256===c.sha256)===A).sort((c,A)=>c.project.localeCompare(A.project)||c.path.localeCompare(A.path)),prerequisites:[...new Set(i.flatMap(c=>c.capability.prerequisites))].sort()};}}let p=oe(e$1.intent),m=[...Se(p[0],e$1.projects.map(o=>o.name)),...p.slice(1)].filter((o,y,P)=>P.indexOf(o)===y).slice(0,3),b=m.map((o,y)=>{let P=o.match(/[A-Za-z0-9][A-Za-z0-9+#.%_-]*/g)?.length??0,i=y===0&&P>=4?2:1,h=e$1.projects.map(w=>{let k=G=>f$3(e$1.graph,{query:o,projectId:w.name,...G?{kind:G}:{},limit:60,relationsPerEntity:0,minimumTermMatches:i}).entities,S=k(),de=[...new Set(e$1.graph.entities.filter(G=>G.projectId===w.name||G.projectId===void 0&&G.identity.scope==="workspace").map(G=>G.kind))].flatMap(G=>k(G).slice(0,8)),U=[...S,...de];return U.filter((G,me)=>U.findIndex(ge=>ge.id===G.id)===me)}),c=[],A=new Set;for(let w=0;h.some(k=>w<k.length);w+=1)for(let k of h){let S=k[w];!S||A.has(S.id)||(A.add(S.id),c.push(S));}return Te(c)}),u={"test-coverage":["test-suite"],"dependency-security":["package","module"],"release-readiness":["pipeline","deployment","lifecycle-stage"],"defect-repair":["test-suite","lifecycle-stage"],"feature-change":["project","runtime-unit","api","package","module","test-suite"],refactor:["package","module","api","test-suite"],performance:["lifecycle-stage","test-suite","pipeline"],documentation:["document","decision"],"system-understanding":["project","service","api","package","protocol"]},j=new Set(e$1.projects.map(o=>o.name)),v=e$1.graph.entities.filter(o=>o.proofIds.length>0&&(!o.projectId||j.has(o.projectId))&&u[e$1.intent.category].includes(o.kind)).sort((o,y)=>u[e$1.intent.category].indexOf(o.kind)-u[e$1.intent.category].indexOf(y.kind)||o.label.localeCompare(y.label)),f=[],M=new Set,E=o=>{!o||f.length>=20||M.has(o.id)||(M.add(o.id),f.push(o));},I=(e$1.intent.statement.match(/[A-Za-z][A-Za-z0-9+#.-]{1,}/g)??[]).length>=2,g=I?b[0]??[]:[];for(let o of g.slice(0,12))E(o);if(!I)for(let o of v)E(o);for(let o=0;f.length<20&&b.slice(1).some(y=>o<y.length);o+=1)for(let y of b.slice(1))E(y[o]);if(I)for(let o of v)E(o);for(let o of g.slice(12))E(o);let x=f.map(o=>({entityId:o.id,kind:o.kind,label:o.label,proofIds:o.proofIds.slice(0,12)})),L=b[0]?.length??0;return {workspaceIntelligence:l,measurement:d,retrieval:{status:I&&L>=3?"grounded":x.length>0?"partial":"empty",strategy:"deterministic-category-v1",queries:m,anchors:x}}}async function Le(e){let t=C.join(e,f$2);if(!await _.pathExists(t))return {schemaVersion:e$1,generatedAt:new Date(0).toISOString(),activeGoalId:null,goals:[]};let n=await _.readJson(t);a(n,pe,"Goal index");try{i(n);}catch(r){let a=h(n);if(!(a!==null&&r instanceof Error&&r.message==="Goal index is inconsistent: activeGoalId must identify the only selected actionable lifecycle entry.")||!a)throw r;return a}return n}function Ne(e,t,n){let r=e.goals.find(l=>l.id===t.id),a=t.state==="ready-to-plan",s={id:t.id,fingerprint:t.fingerprint,objective:t.intent.statement,category:t.intent.category,state:t.state,lifecycle:r?.lifecycle==="cancelled"?"cancelled":a?"active":"planned",scope:t.scope,createdAt:r?.createdAt??t.generatedAt,updatedAt:n,goalPack:t.artifacts.goalPack,agentHandoff:t.artifacts.agentHandoff,...r?.verifiedGoalId?{verifiedGoalId:r.verifiedGoalId}:{},...r?.repairTransactionId?{repairTransactionId:r.repairTransactionId}:{},...r?.repairTransactionIds?{repairTransactionIds:r.repairTransactionIds}:{},...r?.verificationReceipt?{verificationReceipt:r.verificationReceipt}:{}};return {schemaVersion:e$1,generatedAt:n,activeGoalId:s.lifecycle==="active"?t.id:e.activeGoalId===t.id?null:e.activeGoalId,goals:[...e.goals.filter(l=>l.id!==t.id).map(l=>s.lifecycle==="active"&&l.lifecycle==="active"?{...l,lifecycle:"planned",updatedAt:n}:l),s].sort((l,d)=>l.id.localeCompare(d.id))}}async function et(e$1){let t=b({startPath:C.resolve(e$1.startPath),explicitWorkspacePath:e$1.workspacePath,strict:true,requireProjectMembership:true});if(!t)throw new Error("No canonical Workspai workspace could be resolved.");let n=C.resolve(t.workspacePath);e$1.refresh&&await c({workspacePath:n,strict:false,agent:"generic"});let{model:r,graph:a$1}=await Ee(n),s=await Ie({workspacePath:n,invocationProjectPath:t.projectPath,model:r,explicitScope:e$1.scope,selectScope:e$1.selectScope}),l=s.scope,d$2=r.projects.filter(i=>l.projects.includes(i.name));if(d$2.length===0)throw new Error("A Goal Pack requires at least one registered project in its selected scope.");let p=e$1.maxAttempts??5;if(!Number.isInteger(p)||p<1||p>25)throw new Error("--max-attempts must be an integer from 1 to 25.");let m=new Date().toISOString(),b$1=d(r),u=d$2.map(i=>({name:i.name,runtimes:[...new Set(i.runtimeCandidates.filter(h=>ue.has(h)))].sort()})),j$1=[...new Set(u.flatMap(i=>i.runtimes))].sort(),v=u.length<=1?j$1:u[0].runtimes.filter(i=>u.every(h=>h.runtimes.includes(i))),f$3=K(e$1.intent,{availableCoverageRuntimes:v,...e$1.runtime?{selectedCoverageRuntime:e$1.runtime}:v.length===1?{selectedCoverageRuntime:v[0]}:{}});if(e$1.runtime&&!v.includes(e$1.runtime)){let i=e$1.runtime,h=u.filter(c=>!c.runtimes.includes(i)).map(c=>c.name);throw new Error(d$2.length>1&&h.length>0?`--runtime ${e$1.runtime} is not canonical for every project in the selected Goal scope. Missing from: ${h.join(", ")}. Split the projects into runtime-compatible Goal scopes.`:`--runtime ${e$1.runtime} is not present in the canonical Workspace Model for the selected Goal scope. Available runtimes: ${v.join(", ")||"none"}.`)}if(e$1.runtime&&f$3.category!=="test-coverage")throw new Error("--runtime is valid only for a test-coverage Goal.");if(e$1.runtime&&f$3.requestedTarget?.runtime&&f$3.requestedTarget.runtime!==e$1.runtime)throw new Error(`--runtime ${e$1.runtime} conflicts with the ${f$3.requestedTarget.runtime} runtime named in the Goal intent.`);if(!s.selectionRequired&&f$3.category==="test-coverage"&&f$3.requestedTarget&&!f$3.requestedTarget.runtime&&v.length>1&&!e$1.runtime&&e$1.selectCoverageRuntime){let i=await e$1.selectCoverageRuntime({workspaceName:r.workspace.name,scope:l,projects:d$2.map(h=>({name:h.name,runtime:h.runtime,runtimeCandidates:[...h.runtimeCandidates].sort()})),runtimes:v});if(!v.includes(i))throw new Error("The selected coverage runtime is outside the canonical Goal scope.");f$3=K(e$1.intent,{availableCoverageRuntimes:v,selectedCoverageRuntime:i});}!s.selectionRequired&&f$3.category==="test-coverage"&&d$2.length>1&&v.length===0&&(f$3={...f$3,ambiguities:[`The selected projects do not share a common canonical coverage runtime: ${u.map(i=>`${i.name} (${i.runtimes.join(", ")||"none"})`).join("; ")}. Split them into runtime-compatible Goal scopes so every selected project is verified.`,...f$3.ambiguities]}),s.selectionRequired&&(f$3={...f$3,ambiguities:[`Goal scope is unresolved across ${l.projects.length} registered projects: ${l.projects.join(", ")}. Select one project, multiple projects, or the entire workspace.`,...f$3.ambiguities]});let M=await _e({workspacePath:n,projects:d$2,graph:a$1,intent:f$3,coverageRuntimeChoices:v}),E={generatedAt:m,intent:f$3,workspaceName:r.workspace.name,scope:l,sourceBinding:{model:{artifact:e.model,schemaVersion:f.model,hashAlgorithm:"sha256",hashSemantics:"workspace-model-structural-v1",hash:b$1,generatedAt:r.generatedAt},graph:{artifact:e.knowledgeGraph,schemaVersion:f.knowledgeGraph,hashAlgorithm:"sha256",hashSemantics:"canonical-json-v1",hash:c$1(a$1),generatedAt:a$1.generatedAt,modelHash:a$1.source.hash,...a$1.source.inputs?.hash?{inputHash:a$1.source.inputs.hash}:{}}},preflight:M,baseline:{projectCount:d$2.length,runtimes:[...new Set(d$2.flatMap(i=>i.runtimeCandidates))].sort(),frameworks:[...new Set(d$2.map(i=>i.framework))].sort(),graph:xe(a$1,l)},maxAttempts:p,consumer:e$1.consumer??"generic"},I={digestCanonical:c$1},{goalPack:g,handoff:x}=j(E,I);a(g,ae,"Goal Pack"),a(x,se,"Goal agent handoff");let L=false,o=async()=>{let i=C.join(n,g.artifacts.goalPack),h=C.join(n,g.artifacts.agentHandoff),[c,A]=await Promise.all([_.pathExists(i),_.pathExists(h)]);if(c!==A)throw new Error(`Goal Pack instance is incomplete and cannot be resumed: ${g.id}`);if(!c)return;let[w,k]=await Promise.all([_.readJson(i),_.readJson(h)]);a(w,ae,"Persisted Goal Pack"),a(k,se,"Persisted goal agent handoff");let S=j({...E,generatedAt:w.generatedAt,sourceBinding:w.sourceBinding},I);if(w.id!==g.id||k.goalId!==g.id||c$1(w)!==c$1(S.goalPack)||c$1(k)!==c$1(S.handoff))throw new Error(`Goal Pack instance failed immutable integrity validation: ${g.id}`);g=w,x=k,L=true;};if(e$1.dryRun)await o();else {let i$1=`.workspai/goals/${g.id}/publication`;await c$2(n,i$1,async()=>{await o();let h=Ne(await Le(n),g,new Date().toISOString());a(h,pe,"Goal index"),i(h),await f$1(n,d$1,L?[{relativePath:d$1,payload:g},{relativePath:f$2,payload:h}]:[{relativePath:g.artifacts.goalPack,payload:g},{relativePath:g.artifacts.agentHandoff,payload:x},{relativePath:d$1,payload:g},{relativePath:f$2,payload:h}]);});}let y=[g.artifacts.goalPack,g.artifacts.agentHandoff,d$1,f$2],P={schemaVersion:c$3,result:g.state==="needs-confirmation"?"needs-confirmation":g.state==="blocked"?"blocked":g.state==="needs-evidence"?"needs-evidence":"planned",resolution:{source:t.source,invocationScope:t.projectPath?"project":"workspace"},goalPack:g,agentHandoff:x,writtenArtifacts:e$1.dryRun?[]:L?[d$1,f$2]:y,dryRun:e$1.dryRun===true,resumed:L};return a(P,Re,"Goal plan result"),P}export{et as planGoalPack};