workspai 0.73.0 → 0.75.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 (163) hide show
  1. package/contracts/agent-framework-capabilities.v1.json +454 -0
  2. package/contracts/cli-runtime-command-inventory.v1.snapshot.json +166 -0
  3. package/contracts/create-planner-capabilities.v1.json +24 -0
  4. package/contracts/extension-cli-compatibility.v1.json +6 -0
  5. package/contracts/published-contract-catalog.v1.json +30 -0
  6. package/contracts/runtime-command-surface.v1.json +78 -4
  7. package/contracts/workspace-intelligence/agent-framework-adapter-manifest.v1.json +2127 -0
  8. package/contracts/workspace-intelligence/agent-framework-admission-candidate.v1.json +193 -0
  9. package/contracts/workspace-intelligence/agent-framework-change-plan.v1.json +280 -0
  10. package/contracts/workspace-intelligence/agent-framework-conformance-report.v1.json +269 -0
  11. package/contracts/workspace-intelligence/agent-framework-ownership-receipt.v1.json +147 -0
  12. package/contracts/workspace-intelligence/workspace-model.v1.json +4 -0
  13. package/contracts/workspace-intelligence-architecture.v1.json +28 -2
  14. package/dist/analyze-FRQVJ3VJ.js +1 -0
  15. package/dist/{artifact-remediation-plan-WDK5ISRU.js → artifact-remediation-plan-HD5K52UJ.js} +1 -1
  16. package/dist/autopilot-release-D3UES53H.js +1 -0
  17. package/dist/capabilities-command-VK3LQLP2.js +1 -0
  18. package/dist/chunk-252EKOR6.js +2 -0
  19. package/dist/chunk-36VNERGC.js +1 -0
  20. package/dist/{chunk-TZK2R6RD.js → chunk-4DX4HBG3.js} +1 -1
  21. package/dist/chunk-4KEZQLBU.js +2 -0
  22. package/dist/{chunk-PKKSRXUS.js → chunk-6B7L4NZE.js} +1 -1
  23. package/dist/chunk-7NKM6EHE.js +7 -0
  24. package/dist/{chunk-FE5R6EUV.js → chunk-BLEIUQL6.js} +1 -1
  25. package/dist/{chunk-37SWTS2B.js → chunk-BR6QIYQS.js} +1 -1
  26. package/dist/chunk-CGNMS32W.js +97 -0
  27. package/dist/{chunk-3GO7BJ5J.js → chunk-CK73SQFF.js} +1 -1
  28. package/dist/chunk-CMLLERGG.js +418 -0
  29. package/dist/{chunk-MGL6DBOR.js → chunk-COOVCORC.js} +1 -1
  30. package/dist/chunk-D4AMCZJU.js +7 -0
  31. package/dist/chunk-DFREJHG7.js +1 -0
  32. package/dist/{chunk-OIGI7MP6.js → chunk-DJH2CH42.js} +1 -1
  33. package/dist/chunk-DT3LRKZQ.js +1 -0
  34. package/dist/{chunk-D3N2WFDV.js → chunk-FS3WLRQ4.js} +1 -1
  35. package/dist/chunk-G3ZC5W4U.js +1 -0
  36. package/dist/{chunk-TIZCESKY.js → chunk-GE46XKD2.js} +1 -1
  37. package/dist/chunk-GIFAGOMK.js +2 -0
  38. package/dist/{chunk-FRH7AIGY.js → chunk-HLSOZOL3.js} +3 -3
  39. package/dist/chunk-J4J3RYCL.js +4 -0
  40. package/dist/{chunk-JK6XEF7K.js → chunk-JKAAKE4Z.js} +1 -1
  41. package/dist/chunk-LMOTDLJF.js +2 -0
  42. package/dist/{chunk-DNKELRK6.js → chunk-MXI2DWLL.js} +1 -1
  43. package/dist/chunk-NFWUAEVQ.js +12 -0
  44. package/dist/chunk-NGU7RYXA.js +9 -0
  45. package/dist/{chunk-3WHE7V4M.js → chunk-NLRZFIC6.js} +1 -1
  46. package/dist/chunk-O2CFT2A3.js +1 -0
  47. package/dist/{chunk-EBQS5T7Q.js → chunk-OA2YJN22.js} +1 -1
  48. package/dist/chunk-OH6LV5JP.js +6 -0
  49. package/dist/{chunk-J44PN2FX.js → chunk-P5RZO5BY.js} +18 -18
  50. package/dist/{chunk-TSYDTKXO.js → chunk-RPM67N7A.js} +1 -1
  51. package/dist/{chunk-XVTN5DDV.js → chunk-RU3UT7GJ.js} +1 -1
  52. package/dist/{chunk-IPZT6WKM.js → chunk-RX3U7JKF.js} +4 -4
  53. package/dist/chunk-SRCZX2KC.js +13 -0
  54. package/dist/chunk-TXVMHEJS.js +1 -0
  55. package/dist/chunk-V5WVGPOP.js +1 -0
  56. package/dist/{chunk-FY4X2VOE.js → chunk-VHMDWRDG.js} +2 -2
  57. package/dist/chunk-W7I65IXY.js +3 -0
  58. package/dist/chunk-WOPZX56J.js +2 -0
  59. package/dist/chunk-XF65LQ6M.js +1 -0
  60. package/dist/chunk-YP436V7Q.js +2 -0
  61. package/dist/{chunk-HAZGSAKP.js → chunk-ZI54C2AO.js} +1 -1
  62. package/dist/chunk-ZKYH44ER.js +1 -0
  63. package/dist/chunk-ZS7JHATN.js +1 -0
  64. package/dist/{chunk-NSMRQOWP.js → chunk-ZW4QV6SB.js} +1 -1
  65. package/dist/{create-XYKXS3JB.js → create-7UENFCJK.js} +1 -1
  66. package/dist/{demo-kit-RKTHTXHJ.js → demo-kit-ALW6OSQV.js} +1 -1
  67. package/dist/doctor-KGADT4PI.js +1 -0
  68. package/dist/{dotnet-webapi-clean-VJX6SGGP.js → dotnet-webapi-clean-6Z4EXEJY.js} +1 -1
  69. package/dist/{goal-lifecycle-BIX2JVNO.js → goal-lifecycle-HIQGDEEP.js} +1 -1
  70. package/dist/goal-pack-63PEP2ND.js +1 -0
  71. package/dist/{gofiber-standard-I6ASLOEE.js → gofiber-standard-TDJQIVQZ.js} +1 -1
  72. package/dist/{gogin-standard-U2LSRLIP.js → gogin-standard-UEF3IHSJ.js} +1 -1
  73. package/dist/index.d.ts +18 -0
  74. package/dist/index.js +266 -248
  75. package/dist/pipeline-VFI35PR4.js +5 -0
  76. package/dist/{project-agent-entry-Y3NEHZED.js → project-agent-entry-Z3OY3S7T.js} +1 -1
  77. package/dist/{project-intelligence-lens-6Q6XSUDJ.js → project-intelligence-lens-YWICXW6P.js} +1 -1
  78. package/dist/{project-test-coverage-5PXAHBYQ.js → project-test-coverage-3P5FH6E5.js} +1 -1
  79. package/dist/proof-carrying-change-BAP2C3KV.js +1 -0
  80. package/dist/{pythonRapidkitExec-44ORGQ4R.js → pythonRapidkitExec-UMFLDIYR.js} +1 -1
  81. package/dist/{rust-axum-JMV7UPO7.js → rust-axum-4TRVPFMB.js} +1 -1
  82. package/dist/{springboot-standard-OC2RS3KC.js → springboot-standard-COWL75GT.js} +1 -1
  83. package/dist/verified-goal-A6WOMNTU.js +1 -0
  84. package/dist/{workspace-ROUEA3RT.js → workspace-PAXTJCMH.js} +1 -1
  85. package/dist/{workspace-agent-sync-6UYG33EQ.js → workspace-agent-sync-MGCEF4ON.js} +1 -1
  86. package/dist/{workspace-archive-OSMU3CK6.js → workspace-archive-3AURTMYA.js} +1 -1
  87. package/dist/{workspace-context-H7ZXR6VI.js → workspace-context-2G6QZ6D3.js} +1 -1
  88. package/dist/{workspace-contract-2V2BI6A3.js → workspace-contract-VWPOIYHJ.js} +1 -1
  89. package/dist/{workspace-explain-IBMTRUSF.js → workspace-explain-HLEBUK4K.js} +1 -1
  90. package/dist/{workspace-feedback-D6HJLKBQ.js → workspace-feedback-FF34CSJE.js} +1 -1
  91. package/dist/{workspace-foundation-H5B3TTZD.js → workspace-foundation-X7LOGTS3.js} +1 -1
  92. package/dist/{workspace-graph-stream-YDEET5LK.js → workspace-graph-stream-XGSRDRLI.js} +1 -1
  93. package/dist/workspace-graph-token-efficiency-YHXFGH3Z.js +1 -0
  94. package/dist/{workspace-history-WWPS4U7H.js → workspace-history-EQG5UBKW.js} +1 -1
  95. package/dist/{workspace-intelligence-DXKQXTTM.js → workspace-intelligence-GFJKIWBX.js} +1 -1
  96. package/dist/{workspace-intelligence-benchmark-L46EGZZM.js → workspace-intelligence-benchmark-R5MEGJQS.js} +1 -1
  97. package/dist/{workspace-intelligence-evaluation-QDSOOUHH.js → workspace-intelligence-evaluation-4AB4BBRP.js} +1 -1
  98. package/dist/{workspace-intelligence-runner-SCB44IXU.js → workspace-intelligence-runner-BU6JKNUD.js} +1 -1
  99. package/dist/{workspace-knowledge-graph-BNEVFEOW.js → workspace-knowledge-graph-OUTCLYS2.js} +1 -1
  100. package/dist/{workspace-knowledge-graph-query-GOC365ZR.js → workspace-knowledge-graph-query-TT2KK3SF.js} +1 -1
  101. package/dist/workspace-knowledge-graph-snapshot-XWJRUMAC.js +1 -0
  102. package/dist/workspace-marker-7U3NYRPJ.js +1 -0
  103. package/dist/workspace-mcp-serve-JYUKX3YS.js +3 -0
  104. package/dist/workspace-model-DUGPW5IB.js +1 -0
  105. package/dist/{workspace-onboarding-IRBVZTT4.js → workspace-onboarding-C4CKWTJ3.js} +1 -1
  106. package/dist/{workspace-python-engine-state-BE4A3BL5.js → workspace-python-engine-state-VCOLSEWV.js} +2 -2
  107. package/dist/{workspace-readme-HA6XLDME.js → workspace-readme-4FCKAQME.js} +1 -1
  108. package/dist/{workspace-registry-summary-CBZDSG6I.js → workspace-registry-summary-4KX4QD55.js} +1 -1
  109. package/dist/workspace-repair-engine-OVW4J3DI.js +3 -0
  110. package/dist/workspace-run-NVQGRZYO.js +1 -0
  111. package/dist/{workspace-verify-QTRY7WW3.js → workspace-verify-B7HEFYO6.js} +1 -1
  112. package/dist/workspace-watch-TQYAMLIV.js +1 -0
  113. package/docs/README.md +4 -1
  114. package/docs/agent-framework-adapters.md +279 -0
  115. package/docs/ci-workflows.md +1 -1
  116. package/docs/commands-reference.md +16 -0
  117. package/docs/contracts/COMMAND_OWNERSHIP_MATRIX.md +5 -0
  118. package/docs/creating-workspaces-and-projects.md +18 -4
  119. package/package.json +7 -1
  120. package/scripts/enterprise-package-smoke.mjs +98 -0
  121. package/dist/analyze-WC2TY5AT.js +0 -1
  122. package/dist/autopilot-release-LJDRECFW.js +0 -1
  123. package/dist/capabilities-command-NFGX42CH.js +0 -1
  124. package/dist/chunk-2BCECNIW.js +0 -1
  125. package/dist/chunk-2LIVMG5C.js +0 -2
  126. package/dist/chunk-3SNP6M4M.js +0 -2
  127. package/dist/chunk-46QH3ZVI.js +0 -105
  128. package/dist/chunk-4HQU2GQM.js +0 -1
  129. package/dist/chunk-4JAURS76.js +0 -13
  130. package/dist/chunk-7O7P4MRD.js +0 -1
  131. package/dist/chunk-AQNU5RXV.js +0 -2
  132. package/dist/chunk-CQBM6BBP.js +0 -2
  133. package/dist/chunk-CY4QZ3PE.js +0 -3
  134. package/dist/chunk-EDDGQ6LM.js +0 -2
  135. package/dist/chunk-F6CTGVJA.js +0 -9
  136. package/dist/chunk-K3O3HENC.js +0 -5
  137. package/dist/chunk-LDJAUIAG.js +0 -1
  138. package/dist/chunk-LGC4CRUF.js +0 -3
  139. package/dist/chunk-ND5YAC4T.js +0 -1
  140. package/dist/chunk-NNQE4DS2.js +0 -2
  141. package/dist/chunk-NSH7TTSV.js +0 -1
  142. package/dist/chunk-R5OJD5K2.js +0 -1
  143. package/dist/chunk-SO4CGS35.js +0 -4
  144. package/dist/chunk-T5NBSCVX.js +0 -97
  145. package/dist/chunk-UCNIXOTL.js +0 -2
  146. package/dist/chunk-UNXG3ZFV.js +0 -1
  147. package/dist/chunk-VBMWFT7Q.js +0 -1
  148. package/dist/chunk-YYELANJO.js +0 -7
  149. package/dist/chunk-ZZWGD3X3.js +0 -12
  150. package/dist/doctor-LQ7FT6AZ.js +0 -1
  151. package/dist/goal-pack-SUWH6K7U.js +0 -1
  152. package/dist/pipeline-NSPPWD7U.js +0 -5
  153. package/dist/proof-carrying-change-456TYEDW.js +0 -1
  154. package/dist/verified-goal-GRH5UOJR.js +0 -1
  155. package/dist/workspace-graph-token-efficiency-XM3LYFUC.js +0 -1
  156. package/dist/workspace-knowledge-graph-snapshot-2NMV7LEJ.js +0 -1
  157. package/dist/workspace-marker-XGAWZZDX.js +0 -1
  158. package/dist/workspace-mcp-serve-JLZTTEVG.js +0 -3
  159. package/dist/workspace-model-XSNLDUI2.js +0 -1
  160. package/dist/workspace-repair-engine-TDUNQSFJ.js +0 -3
  161. package/dist/workspace-run-I2W5PIPK.js +0 -1
  162. package/dist/workspace-watch-PDQKYBYQ.js +0 -1
  163. /package/dist/{chunk-K33JJVQZ.js → chunk-VN2MKTQO.js} +0 -0
@@ -0,0 +1,2 @@
1
+ import {b as b$1}from'./chunk-COICGD62.js';import {b}from'./chunk-NFWUAEVQ.js';import {r,f,g}from'./chunk-O2CFT2A3.js';import {d}from'./chunk-LMOTDLJF.js';import {h,g as g$1}from'./chunk-BLEIUQL6.js';import {q,p}from'./chunk-ODK4LCEL.js';import E from'path';import A from'fs-extra';var re=q.agentContext,se=p.agentContext;function ne(e){if(typeof e!="string"||!e.trim()||e==="true")return "generic";let t=e.trim().toLowerCase();return t==="codex"||t==="claude"||t==="cursor"||t==="gemini"||t==="qwen"||t==="kimi"||t==="grok"||t==="copilot"||t==="windsurf"||t==="amazon-q"||t==="orca"?t:"generic"}function G(e){return `npx --yes --package workspai workspai ${e}`.trim()}function x(e){return `npx workspai ${e}`.trim()}async function C(e,t,i){let s=E.join(e,t);if(!await A.pathExists(s))return null;try{let n=await A.readJson(s);return typeof n!="object"||n===null||!("schemaVersion"in n)||n.schemaVersion!==i?null:n}catch{return null}}function m(e){return {id:e.id,scope:e.scope,display:x(e.args),execute:G(e.args),description:e.description,...e.project?{project:e.project}:{},freshness:f({id:`command.${e.id}`,label:`${e.id} command`,scope:"command",value:{display:x(e.args),execute:G(e.args)},...e.project?{project:e.project}:{},freshness:{kind:"derived",category:"structure",generatedAt:e.generatedAt,now:e.now,sourceArtifact:p.model,sourcePath:`safeCommands.${e.id}`,reason:"Safe command surfaces are derived from workspace model command capabilities."}}).freshness}}function L(e,t){return `workspace run ${t} --scope project:${e.name}`}function ae(e){return (e.startsWith("project:")?e.slice(8):e).trim().toLowerCase()}function oe(e){return [e.name,e.path,E.basename(e.path),e.absolutePath].filter(t=>typeof t=="string"&&t.trim().length>0).map(t=>t.trim().toLowerCase())}function ie(e,t,i){let s={generatedAt:e.generatedAt,now:i},n=[m({id:"workspace.model",scope:"workspace",args:"workspace model --json",description:"Read the canonical workspace intelligence model.",...s}),m({id:"workspace.graph.entities",scope:"workspace",args:"workspace graph entities --json",description:"Query proof-backed workspace entities without loading the full graph.",...s}),m({id:"workspace.graph.evidence",scope:"workspace",args:"workspace graph evidence <entity-or-relation> --json",description:"Resolve portable evidence for a graph entity or relation.",...s}),m({id:"workspace.graph.path",scope:"workspace",args:"workspace graph path <from> <to> --json",description:"Find a shortest proof-carrying path between workspace entities.",...s}),m({id:"workspace.doctor",scope:"workspace",args:"doctor workspace --json",description:"Check workspace health before claiming verification.",...s}),m({id:"workspace.pipeline",scope:"workspace",args:"pipeline --json",description:"Run the governed sync, doctor, analyze, readiness, and autopilot loop.",...s}),m({id:"workspace.contract.verify",scope:"workspace",args:"workspace contract verify --json",description:"Verify workspace contract and dependency edges.",...s}),m({id:"workspace.verify",scope:"workspace",args:"workspace verify --json",description:"Evaluate evidence freshness and verification gates before release decisions.",...s})],c=t?[t]:e.projects;for(let a of c)a.commands.fleetStages.includes("test")&&n.push(m({id:`project.${a.name}.test`,scope:"project",project:a.name,args:L(a,"test"),description:`Run tests for ${a.name} through workspace orchestration.`,...s})),a.commands.fleetStages.includes("build")&&n.push(m({id:`project.${a.name}.build`,scope:"project",project:a.name,args:L(a,"build"),description:`Build ${a.name} through workspace orchestration.`,...s}));return n}function ce(e){return e.commands.fleetStages.filter(t=>t==="test"||t==="build").map(t=>`workspace run ${t}`)}function pe(e,t){if(!t?.startsWith("project:"))return;let i=ae(t);if(i)return e.projects.find(s=>oe(s).includes(i))}function de(e,t,i){let s=[...e.validation?.issues??[]];t?.startsWith("project:")&&!i&&s.push({severity:"error",code:"context.scope.project.missing",message:`Requested project scope was not found: ${t}`,target:t});let n=s.filter(a=>a.severity==="error").length,c=s.filter(a=>a.severity==="warning").length;return {status:n>0?"failed":c>0?"warning":"passed",errors:n,warnings:c,issues:s}}async function me(e,t){let i=[],s=[];for(let[n,c]of Object.entries(e.evidence))c&&await g$1(t,c.path)!==null?i.push(`${n}: ${c.path}`):s.push(n);return {available:i.sort(),missing:s.sort()}}function le(e){let t=e.summary.projectCount,i=e.summary.runtimes.length?`${e.summary.runtimes.join(", ")} runtime coverage`:"no runtime coverage",s=e.identity.surfaces.length?e.identity.surfaces.join(", "):"no detected surfaces";return `${e.workspace.name} is a ${e.identity.workspaceType} with ${t} project${t===1?"":"s"}, ${i}, and ${s}.`}function ge(e){let t=["Do not claim a command passed unless a report or command output proves it.","Do not infer secrets or environment values from file names.","Do not change project scope without checking the selected project."];return e.contracts.exists||t.push("Workspace contract is missing; dependency and API edges may be incomplete."),((e.summary.extendedProjects??0)>0||e.summary.observedProjects>0)&&t.push("Some projects use extended or observed support tiers; command coverage may be partial."),t}async function We(e){let t=e.model??await r({workspacePath:e.workspacePath,includeEvidence:e.includeEvidence===true,observableScanDepth:e.observableScanDepth,now:e.now}),i=ne(e.agent),s=pe(t,e.scope),n=de(t,e.scope,s);if(e.strict===true&&n.status!=="passed"){let r=n.issues.map(g=>`${g.severity}:${g.code}:${g.target}`).join(", ");throw new Error(`Workspace context strict validation failed: ${r}`)}let c=e.now??new Date,a=t.facts??[],K=new Set((s?[s]:t.projects).map(r=>r.name)),R=a.filter(r=>r.project?K.has(r.project):true),H=(s?[s]:t.projects).map(r=>{let g=R.filter(p=>p.project===r.name);return {name:r.name,path:r.path,kind:r.kind,category:r.category,runtime:r.runtime,framework:r.frameworkDisplayName,...r.generator?{generator:r.generator}:{},createCapability:r.createCapability,supportTier:r.supportTier,...r.governance?{governance:r.governance}:{},safeCommands:ce(r),importantFiles:r.importantFiles,facts:g}}),S=await me(t,e.workspacePath),F=E.join(e.workspacePath,p.knowledgeGraph),u=await A.pathExists(F)?await A.readJson(F).catch(()=>null):null,N=false;if(u?.schemaVersion===q.knowledgeGraph)try{b(u,t),N=true;}catch{}let $=le(t),M=ie(t,s,c),b$2=await C(e.workspacePath,p.impact,q.impact),l=await C(e.workspacePath,p.doctor,q.doctor),v=await C(e.workspacePath,p.analyze,q.analyze),k=await C(e.workspacePath,p.readiness,q.readiness),h=await C(e.workspacePath,p.verify,q.verify),w=await C(e.workspacePath,p.explain,q.explain),f$1=await C(e.workspacePath,p.diff,q.diff),B=b$2?.summary?{changed:b$2.summary.changed,risk:b$2.summary.risk,affectedProjects:b$2.summary.affectedProjects,blastRadius:b$2.summary.blastRadius,recommendedCommands:b$2.summary.recommendedCommands}:void 0,U=l?.summary?{verdict:l.summary.verdict,totalIssues:l.summary.totalIssues,advisoryFindings:l.summary.advisoryFindings,blockingFindings:l.summary.blockingFindings,unknownFindings:l.summary.unknownFindings,hasSystemErrors:l.summary.hasSystemErrors,topSignals:(()=>{let r=Array.isArray(l.projects)?l.projects:[],g=[];for(let p of r.slice(0,6)){let te=Array.isArray(p.probes)?p.probes:[];for(let y of te.slice(0,10))(y?.status==="fail"||y?.severity==="error")&&g.push({label:y.label,scope:y.scope,issueClass:y.issueClass,status:y.status,severity:y.severity,recommendation:y.recommendation});}return g.slice(0,8)})()}:void 0,J=v?.summary?{score:v.summary.score,verdict:v.summary.verdict,findingCounts:v.summary.findings,topFindings:(Array.isArray(v.findings)?v.findings:[]).filter(p=>p?.severity==="fail"||p?.severity==="warn").slice(0,8).map(p=>({severity:p.severity,title:p.title,target:p.target,remediation:p.remediation}))}:void 0,X=k?{overallStatus:k.overallStatus,blocking:k.blocking,blockingReasons:k.blockingReasons,evidencePath:k.evidencePath,gates:Array.isArray(k.gates)?k.gates.slice(0,6).map(r=>({gate:r.gate,status:r.status,summary:r.summary})):void 0}:void 0,Q=h?.summary?{verdict:h.summary.verdict,exitCode:h.summary.exitCode,stepsFailed:h.summary.stepsFailed,stepsMissing:h.summary.stepsMissing,blockingReasons:h.blockingReasons,missingEvidence:h.missingEvidence}:void 0,Y=w?{summary:w.summary,blockingReasons:w.blockingReasons,releaseVerdict:w.releaseVerdict,evidenceFreshness:w.evidenceFreshness,sections:Array.isArray(w.sections)?w.sections.slice(0,4).map(r=>({id:r.id,title:r.title,body:r.body})):void 0}:void 0,Z=f$1?.summary?{changed:f$1.summary.changed,addedProjects:f$1.summary.addedProjects,removedProjects:f$1.summary.removedProjects,changedProjects:f$1.summary.changedProjects,workspaceChanges:f$1.summary.workspaceChanges,validationChanges:f$1.summary.validationChanges,gitChangedFiles:f$1.summary.gitChangedFiles}:void 0,ee=M.map(r=>f({id:`context.command.${r.id}`,label:`${r.id} safe command`,scope:"command",value:{display:r.display,execute:r.execute,scope:r.scope},...r.project?{project:r.project}:{},freshness:{kind:"derived",category:"structure",generatedAt:t.generatedAt,now:c,sourceArtifact:p.agentContext,sourcePath:`safeCommands.${r.id}`,reason:"Context safe commands are derived from workspace model command capabilities."}})),I=[...R,...ee],W=g({facts:I,generatedAt:c.toISOString(),now:c}),j=b$1();return {schemaVersion:re,generatedAt:c.toISOString(),agent:i,workspaceSummary:$,modelRef:p.model,knowledgeGraph:{artifact:p.knowledgeGraph,schemaVersion:q.knowledgeGraph,available:N,...typeof u?.quality?.entityCount=="number"?{entityCount:u.quality.entityCount}:{},...typeof u?.quality?.relationCount=="number"?{relationCount:u.quality.relationCount}:{},...typeof u?.quality?.proofCount=="number"?{proofCount:u.quality.proofCount}:{},queryCommands:[x("workspace graph search <query> --limit 12 --json"),x("workspace graph entities [kind] --json"),x("workspace graph evidence <entity-or-relation> --json"),x("workspace graph path <from> <to> --json")]},intelligenceChain:{schemaVersion:j.schemaVersion,contractPath:j.contractPath,currentStep:"context",canonicalReadOrder:[...j.consumers.agents.canonicalReadOrder]},workspace:{name:t.workspace.name,root:`workspace:${t.workspace.name}`,type:t.identity.workspaceType,...t.workspace.profile?{profile:t.workspace.profile}:{}},scope:{requested:e.scope??"workspace",...s?{activeProject:s.name}:{}},projects:H,safeCommands:M,facts:I,factFreshness:W,evidence:S,policies:{mode:t.policies.mode,source:t.policies.source},contracts:{exists:t.contracts.exists,path:t.contracts.workspaceContractPath},validation:n,agentInstructions:[`Read \`${p.agentIndex}\` first, then this context pack and linked evidence reports.`,"Use `workspace graph search <query> --limit 12 --json` for bounded, proof-backed retrieval before loading the full graph.",`Load \`${p.knowledgeGraph}\` only when a complete graph export is explicitly required.`,"Use this context as the workspace source of truth before inspecting random files.","Prefer workspace-level evidence over generic framework assumptions.","Use `display` commands when explaining steps to a human.","Use `execute` commands when launching commands from automation or tooling.","Treat `facts[].freshness.verifyBeforeUse` as a hard refresh requirement before using that fact in advice, fixes, or release decisions.","Do not carry extracted facts beyond their freshness contract; re-read or regenerate evidence when the contract says stale, unknown, live, or verify-before-use.","Keep project-scoped advice tied to the active project scope.","Regenerate stale grounding with `npx workspai workspace agent-sync --write --refresh-context`."],unsafeAssumptions:[...ge(t),...W.verifyBeforeUseFacts>0?[`${W.verifyBeforeUseFacts} fact(s) require verification before use; do not treat them as durable workspace structure.`]:[]],humanSummary:[$,`Evidence available: ${S.available.length}. Missing evidence groups: ${S.missing.join(", ")||"none"}.`,s?`Active project scope: ${s.name} (${s.frameworkDisplayName}).`:"Scope: whole workspace."].join(`
2
+ `),impactSummary:B,doctorSummary:U,analyzeSummary:J,readinessSummary:X,verifySummary:Q,explainSummary:Y,diffSummary:Z}}async function je(e,t){return h(t,se,d(e))}export{re as a,se as b,We as c,je as d};
@@ -1,4 +1,4 @@
1
- import {a}from'./chunk-J7G3YL4O.js';import {d as d$1}from'./chunk-64XWHDZ3.js';import {b as b$1}from'./chunk-UJXE4UAX.js';import {b as b$2}from'./chunk-2FIX2MDC.js';import {spinner,log,note}from'@clack/prompts';import {execa}from'execa';import v from'chalk';import {createRequire}from'module';import {promises}from'fs';import C from'path';import _ from'os';function o(e,t,r){d$1({level:t==="failed"?"error":t==="warn"?"warn":"info",event:"progress",component:e.component,message:r,metadata:{phase:e.phase,status:t,...e.metadata}});}function A(e,t){let r=e;if(o(t,"started",e),b$1())return {start(n){return n&&(r=n),o(t,"started",r),this},succeed(n){o(t,"succeeded",n??r);},fail(n){o(t,"failed",n??r);},warn(n){o(t,"warn",n??r);},stop(n){o(t,"succeeded",n??r);},get text(){return r},set text(n){r=n,o(t,"started",n);}};let i=spinner();return i.start(e),{start(n){return i.start(n??r),n&&(r=n),o(t,"started",r),this},succeed(n){i.stop(n??r),o(t,"succeeded",n??r);},fail(n){i.stop(n??r,1),o(t,"failed",n??r);},warn(n){i.stop(n??r),o(t,"warn",n??r);},stop(n){i.stop(n??r),o(t,"succeeded",n??r);},get text(){return r},set text(n){r=n,i.message(n),o(t,"started",n);}}}function B(e,t){return A(e,t)}function E(e,t,r,i="create"){d$1({level:"info",event:"progress",component:i,message:r,metadata:{phase:"step",stepNum:e,total:t,status:"started"}});}function Q(e){d$1({level:e.status==="failed"?"error":e.status==="warn"?"warn":"info",event:"progress",component:"workspace",message:e.message,metadata:{phase:`workspace.${e.action}`,action:e.action,status:e.status,...e.metadata??{}}});}function X(e){d$1({level:e.status==="failed"?"error":"info",event:"progress",component:e.component??"create",message:e.message,metadata:{phase:e.phase??"workspace.install.pypi",status:e.status,installMethod:e.installMethod,...e.attempt!==void 0?{attempt:e.attempt}:{},...e.maxAttempts!==void 0?{maxAttempts:e.maxAttempts}:{}}});}function u(e,t,r){b$1()&&d$1({level:e,event:"log",component:"cli",message:t,metadata:r});}var d={info(e){u("info",e),!b$1()&&log.info(e);},success(e){u("info",e,{outcome:"success"}),!b$1()&&log.success(e);},warn(e){u("warn",e),!b$1()&&log.warn(e);},error(e){u("error",e),!b$1()&&log.error(e);},step(e){u("info",e,{phase:"step"}),!b$1()&&log.step(e);},stepNumbered(e,t,r){let i=`${a.dim(`[${e}/${t}]`)} ${r}`;u("info",r,{phase:"step",stepNum:e,total:t}),!b$1()&&log.step(i);},note(e,t){u("info",e,{kind:"note",title:t}),!b$1()&&note(e,t);},message(e,t=a.brand("\u25C7")){u("info",e),!b$1()&&log.message(e,{symbol:t});},dim(e){b$1()||console.log(a.dim(e));},plain(e){b$1()||console.log(e);},nextSteps(e){b$1()||d.note(e.map(t=>a.white(t)).join(`
1
+ import {a}from'./chunk-J7G3YL4O.js';import {b as b$2}from'./chunk-2FIX2MDC.js';import {d as d$1}from'./chunk-64XWHDZ3.js';import {b as b$1}from'./chunk-UJXE4UAX.js';import {spinner,log,note}from'@clack/prompts';import {execa}from'execa';import v from'chalk';import {createRequire}from'module';import {promises}from'fs';import C from'path';import _ from'os';function o(e,t,r){d$1({level:t==="failed"?"error":t==="warn"?"warn":"info",event:"progress",component:e.component,message:r,metadata:{phase:e.phase,status:t,...e.metadata}});}function A(e,t){let r=e;if(o(t,"started",e),b$1())return {start(n){return n&&(r=n),o(t,"started",r),this},succeed(n){o(t,"succeeded",n??r);},fail(n){o(t,"failed",n??r);},warn(n){o(t,"warn",n??r);},stop(n){o(t,"succeeded",n??r);},get text(){return r},set text(n){r=n,o(t,"started",n);}};let i=spinner();return i.start(e),{start(n){return i.start(n??r),n&&(r=n),o(t,"started",r),this},succeed(n){i.stop(n??r),o(t,"succeeded",n??r);},fail(n){i.stop(n??r,1),o(t,"failed",n??r);},warn(n){i.stop(n??r),o(t,"warn",n??r);},stop(n){i.stop(n??r),o(t,"succeeded",n??r);},get text(){return r},set text(n){r=n,i.message(n),o(t,"started",n);}}}function B(e,t){return A(e,t)}function E(e,t,r,i="create"){d$1({level:"info",event:"progress",component:i,message:r,metadata:{phase:"step",stepNum:e,total:t,status:"started"}});}function Q(e){d$1({level:e.status==="failed"?"error":e.status==="warn"?"warn":"info",event:"progress",component:"workspace",message:e.message,metadata:{phase:`workspace.${e.action}`,action:e.action,status:e.status,...e.metadata??{}}});}function X(e){d$1({level:e.status==="failed"?"error":"info",event:"progress",component:e.component??"create",message:e.message,metadata:{phase:e.phase??"workspace.install.pypi",status:e.status,installMethod:e.installMethod,...e.attempt!==void 0?{attempt:e.attempt}:{},...e.maxAttempts!==void 0?{maxAttempts:e.maxAttempts}:{}}});}function u(e,t,r){b$1()&&d$1({level:e,event:"log",component:"cli",message:t,metadata:r});}var d={info(e){u("info",e),!b$1()&&log.info(e);},success(e){u("info",e,{outcome:"success"}),!b$1()&&log.success(e);},warn(e){u("warn",e),!b$1()&&log.warn(e);},error(e){u("error",e),!b$1()&&log.error(e);},step(e){u("info",e,{phase:"step"}),!b$1()&&log.step(e);},stepNumbered(e,t,r){let i=`${a.dim(`[${e}/${t}]`)} ${r}`;u("info",r,{phase:"step",stepNum:e,total:t}),!b$1()&&log.step(i);},note(e,t){u("info",e,{kind:"note",title:t}),!b$1()&&note(e,t);},message(e,t=a.brand("\u25C7")){u("info",e),!b$1()&&log.message(e,{symbol:t});},dim(e){b$1()||console.log(a.dim(e));},plain(e){b$1()||console.log(e);},nextSteps(e){b$1()||d.note(e.map(t=>a.white(t)).join(`
2
2
  `),a.brand("Next steps"));}};var y=class{debugEnabled=false;setDebug(t){this.debugEnabled=t;}isJsonMode(){return b$1()}debug(t,...r){this.debugEnabled&&this.write("debug",t,r);}info(t,...r){this.write("info",t,r);}success(t,...r){this.write("info",t,r,{outcome:"success"},"success");}warn(t,...r){this.write("warn",t,r,void 0,"warn");}error(t,...r){this.write("error",t,r,void 0,"error");}step(t,r,i){if(b$1()){E(t,r,i);return}d.stepNumbered(t,r,i);}write(t,r,i,n,l="info"){let p=i.length>0?{details:i.map(k=>j(k))}:void 0;if(b$1()){d$1({level:t,event:"log",component:"cli",message:r,metadata:{...n,...p}});return}let a=t==="debug"?`[debug] ${r}`:r;switch(l){case "success":d.success(a);break;case "warn":d.warn(a);break;case "error":d.error(a);break;default:t==="debug"?d.dim(a):d.info(a);}}};function j(e){return e instanceof Error?{name:e.name,message:e.message}:e===null||typeof e=="string"||typeof e=="number"||typeof e=="boolean"?e:String(e)}var b=new y;function R(e){let t=e.startsWith("WORKSPAI_")?e:`WORKSPAI_${e.replace(/^RAPIDKIT_/,"")}`,r=e.startsWith("RAPIDKIT_")?e:`RAPIDKIT_${e.replace(/^WORKSPAI_/,"")}`,i=process.env[t]?.trim();return i||process.env[r]?.trim()||void 0}var T="workspai",W=createRequire(import.meta.url),O=W("../package.json"),g=O?.version??"0.0.0";function I(e){let r=e.trim().match(/^(\d+)\.(\d+)\.(\d+)(?:-([0-9A-Za-z.-]+))?(?:\+[0-9A-Za-z.-]+)?$/);if(!r)return null;let i=r[4]?r[4].split(".").map(n=>n.match(/^\d+$/)?Number(n):n):[];return {major:Number(r[1]),minor:Number(r[2]),patch:Number(r[3]),prerelease:i}}function V(e,t){let r=I(e),i=I(t);if(!r||!i)return 0;if(r.major!==i.major)return r.major>i.major?1:-1;if(r.minor!==i.minor)return r.minor>i.minor?1:-1;if(r.patch!==i.patch)return r.patch>i.patch?1:-1;if(r.prerelease.length===0&&i.prerelease.length===0)return 0;if(r.prerelease.length===0)return 1;if(i.prerelease.length===0)return -1;let n=Math.max(r.prerelease.length,i.prerelease.length);for(let l=0;l<n;l+=1){let p=r.prerelease[l],a=i.prerelease[l];if(p===void 0)return -1;if(a===void 0)return 1;if(p===a)continue;let k=typeof p=="number",P=typeof a=="number";return k&&P?p>a?1:-1:k?-1:P||String(p)>String(a)?1:-1}return 0}var K=14400*1e3;function $(){let e=R("CACHE_DIR")||(process.env.VITEST_WORKER_ID?C.join(_.homedir(),".workspai","cache",`vitest-${process.env.VITEST_WORKER_ID}`):C.join(_.homedir(),".workspai","cache"));return C.join(e,"update-check.json")}async function L(){try{let e=await promises.readFile($(),"utf-8"),t=JSON.parse(e);return typeof t.latestVersion=="string"&&typeof t.checkedAt=="number"&&t.currentVersion===g&&Date.now()-t.checkedAt<K?t:null}catch{return null}}async function F(e){try{let t=$();await promises.mkdir(C.dirname(t),{recursive:true}),await promises.writeFile(t,JSON.stringify({latestVersion:e,checkedAt:Date.now(),currentVersion:g}),"utf-8");}catch{}}async function Se(){try{b.debug("Checking for updates...");let e=await L();if(e){let i=Math.round((Date.now()-e.checkedAt)/6e4);b.debug(`Update check: cache hit (${i}m old)`),V(e.latestVersion,g)>0&&(console.log(v.yellow(`
3
3
  \u26A0\uFE0F Update available: ${g} \u2192 ${e.latestVersion}`)),console.log(v.cyan(`Run: npm install -g workspai@latest
4
4
  `)));return}let{stdout:t}=await execa("npm",["view",T,"version"],{timeout:b$2()}),r=t.trim();await F(r),r&&V(r,g)>0?(console.log(v.yellow(`
@@ -0,0 +1,7 @@
1
+ import {a as a$1}from'./chunk-GR6442P7.js';import a from'fs';import s from'path';var v={nextjs:{key:"nextjs",runtime:"node",displayName:"Next.js",supportTier:"extended",importStack:"nextjs",aliases:["next","nextjs","next.js"],dependencyHints:["next"],scriptHints:["next dev","next build","next start"],fileHints:["next.config.js","next.config.mjs","next.config.ts"]},remix:{key:"remix",runtime:"node",displayName:"Remix",supportTier:"extended",importStack:"remix",aliases:["remix"],dependencyHints:["@remix-run/react","@remix-run/node","@remix-run/dev"],scriptHints:["remix dev","remix vite:dev"],fileHints:["remix.config.js","remix.config.mjs"]},nuxt:{key:"nuxt",runtime:"node",displayName:"Nuxt",supportTier:"extended",importStack:"nuxt",aliases:["nuxt","nuxtjs","nuxt.js"],dependencyHints:["nuxt","nuxt3"],scriptHints:["nuxt dev","nuxt build","nuxi dev","nuxi build"],fileHints:["nuxt.config.js","nuxt.config.ts","nuxt.config.mjs"]},react:{key:"react",runtime:"node",displayName:"React",supportTier:"extended",importStack:"react",aliases:["react"],dependencyHints:["react","react-dom"],scriptHints:["react-scripts start","react-scripts build"],fileHints:[]},vite:{key:"vite",runtime:"node",displayName:"Vite",supportTier:"extended",importStack:"vite",aliases:["vite"],dependencyHints:["vite"],scriptHints:["vite","vite dev","vite build"],fileHints:["vite.config.js","vite.config.ts","vite.config.mjs"]},vue:{key:"vue",runtime:"node",displayName:"Vue",supportTier:"extended",importStack:"vue",aliases:["vue","vuejs","vue.js"],dependencyHints:["vue","@vue/cli-service"],scriptHints:["vue-cli-service serve","vue-cli-service build"],fileHints:["vue.config.js"]},sveltekit:{key:"sveltekit",runtime:"node",displayName:"SvelteKit",supportTier:"extended",importStack:"sveltekit",aliases:["sveltekit","svelte-kit"],dependencyHints:["@sveltejs/kit"],scriptHints:["svelte-kit dev","svelte-kit build"],fileHints:["svelte.config.js"]},svelte:{key:"svelte",runtime:"node",displayName:"Svelte",supportTier:"extended",importStack:"svelte",aliases:["svelte"],dependencyHints:["svelte"],scriptHints:["svelte"],fileHints:[]},angular:{key:"angular",runtime:"node",displayName:"Angular",supportTier:"extended",importStack:"angular",aliases:["angular","@angular/core"],dependencyHints:["@angular/core","@angular/cli"],scriptHints:["ng serve","ng build"],fileHints:["angular.json"]},astro:{key:"astro",runtime:"node",displayName:"Astro",supportTier:"extended",importStack:"astro",aliases:["astro"],dependencyHints:["astro"],scriptHints:["astro dev","astro build"],fileHints:["astro.config.js","astro.config.ts","astro.config.mjs"]},solid:{key:"solid",runtime:"node",displayName:"Solid",supportTier:"extended",importStack:"solid",aliases:["solid","solidjs","solid-js"],dependencyHints:["solid-js"],scriptHints:[],fileHints:[]},unknown:{key:"unknown",runtime:"unknown",displayName:"Unknown frontend",supportTier:"observed",importStack:"unknown",aliases:["unknown"],dependencyHints:[],scriptHints:[],fileHints:[]}},re={nextjs:{dev:["dev"],start:["start"],build:["build"],test:["test"],lint:["lint"],format:["format"]},remix:{dev:["dev"],start:["start"],build:["build"],test:["test"],lint:["lint"],format:["format"]},nuxt:{dev:["dev"],start:["start","preview"],build:["build"],test:["test"],lint:["lint"],format:["format"]},react:{dev:["dev","start"],start:["serve"],build:["build"],test:["test"],lint:["lint"],format:["format"]},vite:{dev:["dev"],start:["preview","start"],build:["build"],test:["test"],lint:["lint"],format:["format"]},vue:{dev:["dev","serve"],start:["preview","start"],build:["build"],test:["test"],lint:["lint"],format:["format"]},sveltekit:{dev:["dev"],start:["start","preview"],build:["build"],test:["test"],lint:["lint"],format:["format"]},svelte:{dev:["dev"],start:["preview","start"],build:["build"],test:["test"],lint:["lint"],format:["format"]},angular:{dev:["start","serve"],start:["serve"],build:["build"],test:["test"],lint:["lint"],format:["format"]},astro:{dev:["dev"],start:["start","preview"],build:["build"],test:["test"],lint:["lint"],format:["format"]},solid:{dev:["dev"],start:["preview","start"],build:["build"],test:["test"],lint:["lint"],format:["format"]}};function ge(e,n){let t=typeof e=="string"?L(e):e;return t==="unknown"?[]:re[t]?.[n]??[]}function se(e){try{return a.existsSync(e)?JSON.parse(a.readFileSync(e,"utf8")):null}catch{return null}}function oe(e){let n=se(s.join(e,"package.json"));if(!n)return {dependencies:{},scriptText:""};let t=n.dependencies??{},l=n.private===true&&(Array.isArray(n.workspaces)||n.workspaces!==null&&typeof n.workspaces=="object"||a.existsSync(s.join(e,"pnpm-workspace.yaml")))?t:{...t,...n.devDependencies??{},...n.peerDependencies??{}},m=n.scripts??{},d=Object.values(m).filter(c=>typeof c=="string").join(" ").toLowerCase();return {dependencies:l,scriptText:d}}function ae(e,n){return n.some(t=>a.existsSync(s.join(e,t)))}function ue(e,n){let t=n.trim().split(/\s+/u).map(i=>i.replace(/[.*+?^${}()|[\]\\]/gu,"\\$&")).join("\\s+");return new RegExp(`(?:^|[\\s;&|])${t}(?=$|[\\s;&|])`,"u").test(e)}function E(e){return e.vite?e.react||e["react-dom"]||e["@vitejs/plugin-react"]?"react":e.vue||e["@vitejs/plugin-vue"]?"vue":e.svelte||e["@sveltejs/vite-plugin-svelte"]?"svelte":e["solid-js"]||e["vite-plugin-solid"]?"solid":null:null}function g(e,n,t){let i=v[e]??v.unknown;return {key:i.key,runtime:i.runtime,displayName:i.displayName,supportTier:i.supportTier,importStack:i.importStack,confidence:n,source:t}}function xe(e){return v[e]??v.unknown}function L(e){let n=(e??"").trim().toLowerCase().replace(/[_\s]+/g,"-");if(!n)return "unknown";for(let t of Object.values(v))if(t.aliases.includes(n))return t.key;return "unknown"}function _(e,n){let t=n?.adoption,i=n?.import,l=t!==null&&typeof t=="object"&&!Array.isArray(t)&&t.managed_by==="workspai"&&t.mode==="linked"||i!==null&&typeof i=="object"&&!Array.isArray(i)&&i.managed_by==="workspai",m=L(l?void 0:typeof n?.framework=="string"?n.framework:typeof n?.kit_name=="string"?n.kit_name:typeof n?.kit=="string"?n.kit:void 0);if(m!=="unknown")return g(m,"high","framework");let{dependencies:d,scriptText:c}=oe(e);for(let p of ["nextjs","remix","nuxt","sveltekit","angular","astro","vue","solid","vite","react","svelte"]){let o=v[p];if(o.dependencyHints.some(f=>d[f])){if(p==="vite"){let f=E(d);if(f)return g(f,"high","manifest")}return g(p,"high","manifest")}if(o.fileHints.length>0&&ae(e,o.fileHints)){if(p==="vite"){let f=E(d);if(f)return g(f,"high","manifest")}return g(p,"high","manifest")}if(o.scriptHints.some(f=>ue(c,f)))return g(p,"medium","manifest")}return g("unknown","low","unknown")}var x={"microsoft-agent-framework":{key:"microsoft-agent-framework",runtime:"python",displayName:"Microsoft Agent Framework",supportTier:"extended",importStack:"unknown",aliases:["microsoft-agent-framework","microsoft agent framework"],kitPrefixes:["agent.microsoft"]},fastapi:{key:"fastapi",runtime:"python",displayName:"FastAPI",supportTier:"first-class",importStack:"fastapi",aliases:["fastapi"],kitPrefixes:["fastapi"]},django:{key:"django",runtime:"python",displayName:"Django",supportTier:"extended",importStack:"django",aliases:["django"]},flask:{key:"flask",runtime:"python",displayName:"Flask",supportTier:"extended",importStack:"flask",aliases:["flask"]},python:{key:"python",runtime:"python",displayName:"Python",supportTier:"observed",importStack:"unknown",aliases:["python"]},nestjs:{key:"nestjs",runtime:"node",displayName:"NestJS",supportTier:"first-class",importStack:"nestjs",aliases:["nestjs","nest"],kitPrefixes:["nestjs"]},nextjs:{key:"nextjs",runtime:"node",displayName:"Next.js",supportTier:"extended",importStack:"nextjs",aliases:["nextjs","next.js","next"]},remix:{key:"remix",runtime:"node",displayName:"Remix",supportTier:"extended",importStack:"remix",aliases:["remix"]},nuxt:{key:"nuxt",runtime:"node",displayName:"Nuxt",supportTier:"extended",importStack:"nuxt",aliases:["nuxt","nuxtjs","nuxt.js"]},react:{key:"react",runtime:"node",displayName:"React",supportTier:"extended",importStack:"react",aliases:["react"]},vite:{key:"vite",runtime:"node",displayName:"Vite",supportTier:"extended",importStack:"vite",aliases:["vite"]},vue:{key:"vue",runtime:"node",displayName:"Vue",supportTier:"extended",importStack:"vue",aliases:["vue","vuejs","vue.js"]},sveltekit:{key:"sveltekit",runtime:"node",displayName:"SvelteKit",supportTier:"extended",importStack:"sveltekit",aliases:["sveltekit","svelte-kit"]},svelte:{key:"svelte",runtime:"node",displayName:"Svelte",supportTier:"extended",importStack:"svelte",aliases:["svelte"]},angular:{key:"angular",runtime:"node",displayName:"Angular",supportTier:"extended",importStack:"angular",aliases:["angular","@angular/core"]},astro:{key:"astro",runtime:"node",displayName:"Astro",supportTier:"extended",importStack:"astro",aliases:["astro"]},solid:{key:"solid",runtime:"node",displayName:"Solid",supportTier:"extended",importStack:"solid",aliases:["solid","solidjs","solid-js"]},express:{key:"express",runtime:"node",displayName:"Express",supportTier:"extended",importStack:"express",aliases:["express"]},fastify:{key:"fastify",runtime:"node",displayName:"Fastify",supportTier:"extended",importStack:"unknown",aliases:["fastify"]},koa:{key:"koa",runtime:"node",displayName:"Koa",supportTier:"extended",importStack:"koa",aliases:["koa"]},node:{key:"node",runtime:"node",displayName:"Node.js",supportTier:"observed",importStack:"unknown",aliases:["node","nodejs","typescript","javascript"]},gofiber:{key:"gofiber",runtime:"go",displayName:"Go/Fiber",supportTier:"extended",importStack:"go",aliases:["gofiber","fiber","go-fiber","go/fiber"],kitPrefixes:["gofiber"]},gogin:{key:"gogin",runtime:"go",displayName:"Go/Gin",supportTier:"extended",importStack:"go",aliases:["gogin","gin","go-gin","go/gin"],kitPrefixes:["gogin"]},echo:{key:"echo",runtime:"go",displayName:"Echo",supportTier:"extended",importStack:"go",aliases:["echo"]},go:{key:"go",runtime:"go",displayName:"Go",supportTier:"observed",importStack:"go",aliases:["go","golang"],kitPrefixes:["go"]},springboot:{key:"springboot",runtime:"java",displayName:"Spring Boot",supportTier:"extended",importStack:"springboot",aliases:["springboot","spring","spring-boot"],kitPrefixes:["springboot"]},java:{key:"java",runtime:"java",displayName:"Java",supportTier:"observed",importStack:"unknown",aliases:["java"]},laravel:{key:"laravel",runtime:"php",displayName:"Laravel",supportTier:"extended",importStack:"unknown",aliases:["laravel"]},symfony:{key:"symfony",runtime:"php",displayName:"Symfony",supportTier:"extended",importStack:"unknown",aliases:["symfony"]},php:{key:"php",runtime:"php",displayName:"PHP",supportTier:"observed",importStack:"unknown",aliases:["php"]},rails:{key:"rails",runtime:"ruby",displayName:"Ruby on Rails",supportTier:"extended",importStack:"rails",aliases:["rails","ruby-on-rails","ruby on rails"]},sinatra:{key:"sinatra",runtime:"ruby",displayName:"Sinatra",supportTier:"extended",importStack:"unknown",aliases:["sinatra"]},ruby:{key:"ruby",runtime:"ruby",displayName:"Ruby",supportTier:"observed",importStack:"unknown",aliases:["ruby"]},dotnet:{key:"dotnet",runtime:"dotnet",displayName:"ASP.NET Core",supportTier:"extended",importStack:"dotnet",aliases:["dotnet","asp.net","aspnet","asp.net core","csharp","c#"],kitPrefixes:["dotnet","aspnet","aspnetcore"]},actix:{key:"actix",runtime:"rust",displayName:"Actix-web",supportTier:"extended",importStack:"unknown",aliases:["actix","actix-web"]},axum:{key:"axum",runtime:"rust",displayName:"Axum",supportTier:"extended",importStack:"unknown",aliases:["axum"]},rocket:{key:"rocket",runtime:"rust",displayName:"Rocket",supportTier:"extended",importStack:"unknown",aliases:["rocket"]},rust:{key:"rust",runtime:"rust",displayName:"Rust",supportTier:"observed",importStack:"unknown",aliases:["rust"]},phoenix:{key:"phoenix",runtime:"elixir",displayName:"Phoenix",supportTier:"extended",importStack:"unknown",aliases:["phoenix"]},elixir:{key:"elixir",runtime:"elixir",displayName:"Elixir",supportTier:"observed",importStack:"unknown",aliases:["elixir"]},clojure:{key:"clojure",runtime:"clojure",displayName:"Clojure",supportTier:"extended",importStack:"unknown",aliases:["clojure"]},scala:{key:"scala",runtime:"scala",displayName:"Scala",supportTier:"extended",importStack:"unknown",aliases:["scala"]},kotlin:{key:"kotlin",runtime:"kotlin",displayName:"Kotlin",supportTier:"extended",importStack:"unknown",aliases:["kotlin"]},deno:{key:"deno",runtime:"deno",displayName:"Deno",supportTier:"extended",importStack:"unknown",aliases:["deno"]},bun:{key:"bun",runtime:"bun",displayName:"Bun",supportTier:"extended",importStack:"unknown",aliases:["bun"]},tauri:{key:"tauri",runtime:"node",displayName:"Tauri",supportTier:"extended",importStack:"unknown",aliases:["tauri","tauri-app"],kitPrefixes:["desktop.tauri"]},electron:{key:"electron",runtime:"node",displayName:"Electron",supportTier:"extended",importStack:"unknown",aliases:["electron","electron-forge"],kitPrefixes:["desktop.electron"]},"vscode-extension":{key:"vscode-extension",runtime:"node",displayName:"VS Code Extension",supportTier:"extended",importStack:"unknown",aliases:["vscode-extension","visual-studio-code-extension"],kitPrefixes:["extension.vscode"]},c:{key:"c",runtime:"c",displayName:"C",supportTier:"observed",importStack:"unknown",aliases:["c","clang","gcc"]},cpp:{key:"cpp",runtime:"cpp",displayName:"C++",supportTier:"observed",importStack:"unknown",aliases:["cpp","c++","cplusplus","cc","clang++","g++"]},unknown:{key:"unknown",runtime:"unknown",displayName:"Unknown",supportTier:"observed",importStack:"unknown",aliases:["unknown"]}},X=new Map;for(let e of Object.values(x))for(let n of e.aliases)X.set(n,e.key);function r(e,n,t){let i=x[e]??x.unknown;return {key:i.key,runtime:i.runtime,displayName:i.displayName,supportTier:i.supportTier,importStack:i.importStack,confidence:n,source:t}}function Z(e){return e.trim().toLowerCase().replace(/[_\s]+/g,"-")}function k(e){try{return a.existsSync(e)?a.readFileSync(e,"utf8").toLowerCase():""}catch{return ""}}function J(e){try{return a.existsSync(e)?JSON.parse(a.readFileSync(e,"utf8")):null}catch{return null}}var P=new Set([".git",".hg",".svn",".workspai",".rapidkit",".venv","venv","node_modules","vendor","dist","build","target","coverage",".next",".cache","test","tests","spec","specs","testdata","fixtures","__fixtures__"]);function B(e,n){if(n<0||!a.existsSync(e))return [];let t=[],i=[];try{i=a.readdirSync(e,{withFileTypes:true});}catch{return []}for(let l of i){let m=s.join(e,l.name);l.isDirectory()?t.push(...B(m,n-1)):t.push(m);}return t}function ee(e,n){if(n<0||!a.existsSync(e))return [];let t=[];try{t=a.readdirSync(e,{withFileTypes:true});}catch{return []}let i=[];for(let l of t){let m=s.join(e,l.name);if(l.isDirectory()){if(P.has(l.name)||a$1(l.name))continue;i.push(...ee(m,n-1));}else i.push(m);}return i}function y(e,n,t=2){return B(e,t).some(i=>i.toLowerCase().endsWith(n.toLowerCase()))}function de(e){let n;try{n=a.readdirSync(e,{withFileTypes:true});}catch{return false}let t=0;for(let i of n){if(!i.isDirectory()||P.has(i.name)||a$1(i.name))continue;let l=s.join(e,i.name);if((a.existsSync(s.join(l,"CMakeLists.txt"))||a.existsSync(s.join(l,"meson.build")))&&(t+=1,t>=3))return true}return false}function h(e,n,t=2){return B(e,t).filter(i=>i.toLowerCase().endsWith(n.toLowerCase()))}function ce(e){let n=Z(e??"");if(!n)return "unknown";for(let t of Object.values(x))if(t.kitPrefixes?.some(i=>n.startsWith(i)))return t.key;return "unknown"}function b(e){return e?X.get(Z(e))??"unknown":"unknown"}function Ne(e){return b(e)}function I(e){let n=b(e);return n!=="unknown"?x[n].runtime:"unknown"}function Te(e){let n=x[e]??x.unknown;return {key:n.key,runtime:n.runtime,displayName:n.displayName,supportTier:n.supportTier,importStack:n.importStack}}function M(e){let n=ce(e.kitName);if(n!=="unknown"){let l=r(n,"high","kit");return n==="microsoft-agent-framework"&&e.runtime?{...l,runtime:I(e.runtime)}:l}let t=b(e.framework);if(t!=="unknown"){let l=r(t,"high","framework");return t==="microsoft-agent-framework"&&e.runtime?{...l,runtime:I(e.runtime)}:l}let i=b(e.runtime);return i!=="unknown"?r(i,"medium","runtime"):r("unknown","low","unknown")}function le(e){let n=e?.adoption;if(n&&typeof n=="object"&&!Array.isArray(n)){let i=n;if(i.managed_by==="workspai"&&i.mode==="linked")return true}let t=e?.import;return t!==null&&typeof t=="object"&&!Array.isArray(t)&&t.managed_by==="workspai"}function O(e){let n=J(s.join(e,"package.json"));if(!n)return r("unknown","low","unknown");let t=n.dependencies??{},i=n.devDependencies??{},m=n.private===true&&(Array.isArray(n.workspaces)||n.workspaces!==null&&typeof n.workspaces=="object"||a.existsSync(s.join(e,"pnpm-workspace.yaml")))?t:{...t,...i},d=n.scripts??{},c=Object.values(d).filter(p=>typeof p=="string").join(" ").toLowerCase();return m["@nestjs/core"]||c.includes("nest start")?r("nestjs","high","manifest"):m.express?r("express","high","manifest"):m.fastify?r("fastify","high","manifest"):m.koa?r("koa","high","manifest"):r("node","medium","marker")}function me(e){let n=J(s.join(e,"package.json"));if(!n)return r("unknown","low","unknown");let t={...n.dependencies??{},...n.devDependencies??{}},i=n.engines??{},l=n.scripts??{},m=Object.values(l).filter(d=>typeof d=="string").join(" ").toLowerCase();return t["@tauri-apps/api"]||t["@tauri-apps/cli"]||a.existsSync(s.join(e,"src-tauri","Cargo.toml"))?r("tauri","high","manifest"):t.electron||t["@electron-forge/cli"]||m.includes("electron-forge")||m.includes("electron ")?r("electron","high","manifest"):typeof i.vscode=="string"&&(n.activationEvents!==void 0||n.contributes!==void 0)?r("vscode-extension","high","manifest"):r("unknown","low","unknown")}function W(e){let n=[k(s.join(e,"pyproject.toml")),k(s.join(e,"requirements.txt")),k(s.join(e,"requirements.in"))].join(`
2
+ `);return n.includes("fastapi")?r("fastapi","high","manifest"):n.includes("django")?r("django","high","manifest"):n.includes("flask")?r("flask","high","manifest"):n.trim()?r("python","medium","marker"):r("unknown","low","unknown")}function G(e){let n=k(s.join(e,"go.mod")),t=k(s.join(e,"main.go")),i=[n,t].join(`
3
+ `);return i.includes("github.com/gofiber/fiber")?r("gofiber","high","manifest"):i.includes("github.com/gin-gonic/gin")?r("gogin","high","manifest"):i.includes("github.com/labstack/echo")?r("echo","high","manifest"):n.trim()?r("go","high","manifest"):t.trim()?r("go","medium","marker"):r("unknown","low","unknown")}function q(e){let n=[k(s.join(e,"pom.xml")),k(s.join(e,"build.gradle")),k(s.join(e,"build.gradle.kts"))].join(`
4
+ `);return n.includes("spring-boot")||n.includes("org.springframework")?r("springboot","high","manifest"):n.trim()?r("java","medium","marker"):r("unknown","low","unknown")}function V(e){let n=k(s.join(e,"composer.json"));return n.includes("laravel/framework")?r("laravel","high","manifest"):n.includes("symfony/")?r("symfony","high","manifest"):n.trim()?r("php","medium","marker"):r("unknown","low","unknown")}function z(e){let n=k(s.join(e,"Gemfile")),t=h(e,".gemspec",0).map(i=>k(i)).join(`
5
+ `);return n.includes("gem 'rails'")||n.includes('gem "rails"')?r("rails","high","manifest"):n.includes("gem 'sinatra'")||n.includes('gem "sinatra"')?r("sinatra","high","manifest"):n.trim()||t.trim()?r("ruby","medium","marker"):r("unknown","low","unknown")}function $(e){let t=[...h(e,".csproj",3),...h(e,".sln",2)].map(i=>k(i)).join(`
6
+ `);return t.includes("microsoft.net.sdk.web")||t.includes("microsoft.aspnetcore")||t.includes("swashbuckle.aspnetcore")?r("dotnet","high","manifest"):t.trim()?r("dotnet","medium","marker"):r("unknown","low","unknown")}function U(e){let n=k(s.join(e,"Cargo.toml"));return n.includes("actix-web")?r("actix","high","manifest"):n.includes("axum")?r("axum","high","manifest"):n.includes("rocket")?r("rocket","high","manifest"):n.trim()?r("rust","medium","marker"):r("unknown","low","unknown")}function Y(e){let n=k(s.join(e,"mix.exs"));return n.includes("phoenix")?r("phoenix","high","manifest"):n.trim()?r("elixir","medium","marker"):r("unknown","low","unknown")}function ke(e){let n=[],t=i=>{n.includes(i)||n.push(i);};return a.existsSync(s.join(e,"go.mod"))&&t("go"),(a.existsSync(s.join(e,"Cargo.toml"))||a.existsSync(s.join(e,"src-tauri","Cargo.toml")))&&t("rust"),(a.existsSync(s.join(e,"pom.xml"))||a.existsSync(s.join(e,"build.gradle"))||a.existsSync(s.join(e,"build.gradle.kts")))&&t("java"),a.existsSync(s.join(e,"mix.exs"))&&t("elixir"),a.existsSync(s.join(e,"composer.json"))&&t("php"),(y(e,".csproj")||y(e,".sln"))&&t("dotnet"),a.existsSync(s.join(e,"package.json"))&&t("node"),(a.existsSync(s.join(e,"Gemfile"))||y(e,".gemspec",0))&&t("ruby"),(a.existsSync(s.join(e,"pyproject.toml"))||a.existsSync(s.join(e,"setup.py"))||a.existsSync(s.join(e,"requirements.txt"))||a.existsSync(s.join(e,"requirements.in")))&&t("python"),(a.existsSync(s.join(e,"deps.edn"))||a.existsSync(s.join(e,"project.clj")))&&t("clojure"),a.existsSync(s.join(e,"build.sbt"))&&t("scala"),(a.existsSync(s.join(e,"deno.json"))||a.existsSync(s.join(e,"deno.jsonc")))&&t("deno"),(a.existsSync(s.join(e,"bun.lockb"))||a.existsSync(s.join(e,"bun.lock"))||a.existsSync(s.join(e,"bunfig.toml"))||a.existsSync(s.join(e,".bunfig.toml")))&&t("bun"),(a.existsSync(s.join(e,"CMakeLists.txt"))||a.existsSync(s.join(e,"meson.build"))||y(e,".cpp",3)||y(e,".cc",3)||y(e,".cxx",3)||y(e,".hpp",3)||y(e,".hh",3)||y(e,".hxx",3))&&t("cpp"),(y(e,".c",3)||y(e,".h",3))&&t("c"),(a.existsSync(s.join(e,"settings.gradle.kts"))||y(s.join(e,"src"),".kt",3)||k(s.join(e,"build.gradle.kts")).includes("kotlin"))&&t("kotlin"),n}function Q(e,n=4){let t=ee(e,Math.max(0,Math.min(12,n))),i=new Set(t.map(o=>s.basename(o))),l=t.map(o=>o.toLowerCase()),m=[],d=o=>{m.includes(o)||m.push(o);},c=(...o)=>o.some(f=>i.has(f)),p=(...o)=>l.some(f=>o.some(S=>f.endsWith(S)));return c("go.mod")&&d("go"),c("Cargo.toml")&&d("rust"),c("pom.xml","build.gradle","build.gradle.kts")&&d("java"),c("mix.exs")&&d("elixir"),c("composer.json")&&d("php"),p(".csproj",".sln")&&d("dotnet"),c("package.json")&&d("node"),(c("Gemfile")||p(".gemspec"))&&d("ruby"),c("pyproject.toml","setup.py","requirements.txt","requirements.in")&&d("python"),c("deps.edn","project.clj")&&d("clojure"),c("build.sbt")&&d("scala"),c("deno.json","deno.jsonc")&&d("deno"),c("bun.lockb","bun.lock","bunfig.toml",".bunfig.toml")&&d("bun"),(c("CMakeLists.txt","meson.build")||p(".cpp",".cc",".cxx",".hpp",".hh",".hxx"))&&d("cpp"),p(".c",".h")&&d("c"),(c("settings.gradle.kts")||p(".kt")||t.some(o=>s.basename(o)==="build.gradle.kts"&&k(o).includes("kotlin")))&&d("kotlin"),m}function he(e,n){let t=le(n),i=(()=>{try{return a.readdirSync(e,{withFileTypes:true})}catch{return []}})(),l=new Set(["package.json","Gemfile","go.mod","Cargo.toml","pom.xml","build.gradle","build.gradle.kts","mix.exs","composer.json","pyproject.toml","setup.py","requirements.txt","requirements.in","deps.edn","project.clj","build.sbt","deno.json","deno.jsonc","CMakeLists.txt","meson.build"]),m=i.some(u=>u.isFile()&&(l.has(u.name)||/\.(?:csproj|slnx?|gemspec)$/iu.test(u.name))),d=t&&!m?M({framework:typeof n?.framework=="string"?n.framework:void 0,runtime:typeof n?.runtime=="string"?n.runtime:void 0,kitName:typeof n?.kit_name=="string"?n.kit_name:typeof n?.kit=="string"?n.kit:void 0}):null;if(d?.runtime&&d.runtime!=="unknown"&&Q(e).includes(d.runtime))return d;let c=t?null:n,p=M({framework:typeof c?.framework=="string"?c.framework:void 0,runtime:typeof c?.runtime=="string"?c.runtime:void 0,kitName:typeof c?.kit_name=="string"?c.kit_name:typeof c?.kit=="string"?c.kit:void 0});if(p.key!=="unknown")return p;let o=ke(e),f=Q(e);if(o.length===0&&f.length===1)return r(b(f[0]),"medium","runtime");let S=k(s.join(e,"CMakeLists.txt")),R=k(s.join(e,"meson.build")),C=k(s.join(e,"Cargo.toml")),H=S.trim().length>0||R.trim().length>0,ne=de(e),F=y(e,".cpp",3)||y(e,".cc",3)||y(e,".cxx",3),D=y(e,".c",3),K=/(?:\bcxx\b|\bcplusplus\b|\bc\+\+\b)/u.test(`${S}
7
+ ${R}`);if((H||ne)&&o.includes("cpp")&&(F||K))return r("cpp","high","manifest");if(H&&o.includes("c")&&D&&!F&&!K)return r("c","high","manifest");if(o.includes("rust")&&/\[workspace\]/u.test(C)&&/^default-members\s*=/mu.test(C))return r("rust","high","manifest");if(o.includes("bun"))return r("bun","high","marker");if(o.includes("deno"))return r("deno","high","marker");if(o.includes("kotlin"))return r("kotlin","medium","marker");if(o.includes("node")){let u=me(e);if(u.key!=="unknown")return u;let w=O(e);if(w.key!=="unknown"&&w.key!=="node")return w}let A=[o.includes("python")?W(e):null,o.includes("go")?G(e):null,o.includes("java")?q(e):null,o.includes("php")?V(e):null,o.includes("ruby")?z(e):null,o.includes("rust")?U(e):null,o.includes("elixir")?Y(e):null,o.includes("dotnet")?$(e):null].filter(u=>u!==null).find(u=>u.key!=="unknown"&&u.key!==u.runtime);if(A)return A;if(o.includes("node")){let u=_(e,c);if(u.key!=="unknown")return u;let w=O(e);if(w.key!=="unknown")return w}if(o.includes("python")){let u=W(e);if(u.key!=="unknown")return u}if(o.includes("go")){let u=G(e);if(u.key!=="unknown")return u}if(o.includes("java")){let u=q(e);if(u.key!=="unknown")return u}if(o.includes("php")){let u=V(e);if(u.key!=="unknown")return u}if(o.includes("ruby")){let u=z(e);if(u.key!=="unknown")return u}if(o.includes("rust")){let u=U(e);if(u.key!=="unknown")return u}if(o.includes("elixir")){let u=Y(e);if(u.key!=="unknown")return u}if(o.includes("dotnet")){let u=$(e);if(u.key!=="unknown")return u}return o.includes("clojure")?r("clojure","medium","marker"):o.includes("scala")?r("scala","medium","marker"):o.includes("c")&&D&&!F?r("c","medium","marker"):o.includes("cpp")?r("cpp","medium","marker"):o.includes("c")?r("c","medium","marker"):o.length>0?r(b(o[0]),"medium","runtime"):r("unknown","low","unknown")}export{ge as a,xe as b,L as c,_ as d,de as e,Ne as f,I as g,Te as h,M as i,le as j,ke as k,Q as l,he as m};
@@ -1,2 +1,2 @@
1
- import {b}from'./chunk-K33JJVQZ.js';import {t}from'./chunk-ODK4LCEL.js';import {d}from'./chunk-25AWHAB5.js';import {w,x as x$1}from'./chunk-VQZ5PI5J.js';import s from'path';import {randomUUID}from'crypto';import {open,link,copyFile}from'fs/promises';import f from'fs-extra';function N(e,t){let n=s.resolve(e),r=t.trim();if(!r||s.isAbsolute(r))throw new Error(`Workspace artifact path must be non-empty and relative: ${t}`);let l=s.resolve(n,r),o=s.relative(n,l);if(o===".."||o.startsWith(`..${s.sep}`)||s.isAbsolute(o))throw new Error(`Workspace artifact path escapes workspace root: ${t}`);return l}function m(e,t){return N(e,w(t))}async function T(e,t,n="file"){let r=s.resolve(e),l=m(r,t);if(!await f.pathExists(r)||!await f.pathExists(l))return null;let[o,p,a]=await Promise.all([f.realpath(r),f.realpath(l),f.stat(l)]),c=s.relative(o,p);if(c===".."||c.startsWith(`..${s.sep}`)||s.isAbsolute(c))throw new Error(`Workspace artifact resolves outside workspace root: ${t}`);if(!(n==="file"?a.isFile():a.isDirectory()))throw new Error(`Workspace artifact is not a regular ${n}: ${t}`);return p}async function rt(e,t$1){let n=t$1.trim().replace(/\\/g,"/").replace(/^\.\//,"");if(!n||s.isAbsolute(n))return null;let r=await T(e,n);if(r)return r;let l=t.workspaceContract;for(let o of [l,x$1(l)]){let p=await T(e,o);if(!p)continue;let a=[];try{a=(await f.readJson(p)).projects??[];}catch{return null}let c=a.filter(i=>typeof i.relativePath=="string"&&typeof i.externalPath=="string"&&s.isAbsolute(i.externalPath)).map(i=>({prefix:i.relativePath.replace(/\\/g,"/").replace(/\/$/,""),root:s.resolve(i.externalPath)})).filter(({prefix:i})=>n.startsWith(`${i}/`)).sort((i,u)=>u.prefix.length-i.prefix.length);for(let i of c){let u=n.slice(i.prefix.length+1),d=s.resolve(i.root,u),w=s.relative(i.root,d);if(!w||w===".."||w.startsWith(`..${s.sep}`)||s.isAbsolute(w)||!await f.pathExists(i.root)||!await f.pathExists(d))continue;let[g,h,P]=await Promise.all([f.realpath(i.root),f.realpath(d),f.stat(d)]),v=s.relative(g,h);if(v===".."||v.startsWith(`..${s.sep}`)||s.isAbsolute(v))throw new Error(`External evidence resolves outside its contracted root: ${t$1}`);if(!P.isFile())throw new Error(`External evidence is not a regular file: ${t$1}`);return h}return null}return null}async function C(e,t,n){let r=s.resolve(e),l=s.resolve(r,t),o=s.relative(r,l);if(!o||o===".."||o.startsWith(`..${s.sep}`)||s.isAbsolute(o)||!await f.pathExists(r))return null;let p=await f.realpath(r),a=l;for(;!await f.pathExists(a);){let u=s.dirname(a);if(u===a)return null;a=u;}let c=await f.realpath(a),i=s.relative(p,c);if(i===".."||i.startsWith(`..${s.sep}`)||s.isAbsolute(i))throw new Error(n);return l}async function at(e,t$1){let n=t$1.trim().replace(/\\/g,"/").replace(/^\.\//,"");if(!n||s.isAbsolute(n))return null;let r=t.workspaceContract;for(let l of [r,x$1(r)]){let o=await T(e,l);if(!o)continue;let p=[];try{p=(await f.readJson(o)).projects??[];}catch{return null}let a=p.filter(c=>typeof c.relativePath=="string"&&typeof c.externalPath=="string"&&s.isAbsolute(c.externalPath)).map(c=>({prefix:c.relativePath.replace(/\\/g,"/").replace(/\/$/,""),root:s.resolve(c.externalPath)})).filter(({prefix:c})=>n.startsWith(`${c}/`)).sort((c,i)=>i.prefix.length-c.prefix.length);if(a.length>0){for(let c of a){let i=n.slice(c.prefix.length+1),u=await C(c.root,i,`External evidence candidate resolves outside its contracted root: ${t$1}`);if(u)return u}return null}break}return C(e,n,`Workspace evidence candidate resolves outside workspace root: ${t$1}`)}function O(e,t){return N(e,x$1(t))}async function _(e,t){let n=s.resolve(e);await f.ensureDir(n);let r=s.dirname(t);await f.ensureDir(r);let[l,o]=await Promise.all([f.realpath(n),f.realpath(r)]),p=s.relative(l,o);if(p===".."||p.startsWith(`..${s.sep}`)||s.isAbsolute(p))throw new Error(`Workspace artifact parent resolves outside workspace root: ${r}`)}async function J(e,t){let n=s.resolve(e),[r,l]=await Promise.all([f.realpath(n),f.realpath(t)]),o=s.relative(r,l);if(o===".."||o.startsWith(`..${s.sep}`)||s.isAbsolute(o))throw new Error(`Workspace artifact resolves outside workspace root: ${t}`)}function j(e){let t=e?.code;return process.platform==="win32"&&(t==="EPERM"||t==="EINVAL"||t==="ENOSYS")}function F(e,t=process.platform){if(t!=="win32")return false;let n=e?.code;return n==="EPERM"||n==="EACCES"||n==="EBUSY"}async function E(e){let t=process.platform==="win32"?6:1,n;for(let r=0;r<t;r+=1)try{await f.remove(e);return}catch(l){if(n=l,!F(l)||r===t-1)throw l;await new Promise(o=>setTimeout(o,10*2**r));}throw n}var x=new Map;async function K(e,t){let n=x.get(e)??Promise.resolve(),r,l=new Promise(p=>{r=p;}),o=n.catch(()=>{}).then(()=>l);x.set(e,o),await n.catch(()=>{});try{return await t()}finally{r(),x.get(e)===o&&x.delete(e);}}async function L(e){try{await e.sync();}catch(t){if(!j(t))throw t}}async function k(e,t,n){await _(e,t);let r=s.dirname(t),l=`${s.basename(t)}.`,o=Date.now();for(let a of await f.readdir(r)){if(!a.startsWith(l)||!a.endsWith(".tmp"))continue;let c=s.join(r,a),i=await f.stat(c).catch(()=>null);i&&o-i.mtimeMs>3e4&&await f.remove(c).catch(()=>{});}let p=`${t}.${process.pid}.${randomUUID()}.tmp`;try{await n(p);let a=await open(p,"r");try{await L(a);}finally{await a.close();}let c=Number(process.env.WORKSPAI_TEST_ATOMIC_WRITE_DELAY_MS??0);Number.isFinite(c)&&c>0&&await new Promise(i=>setTimeout(i,Math.min(c,3e4)));try{await f.rename(p,t);}catch(i){let u=i.code;if(u!=="EEXIST"&&u!=="EPERM")throw i;await f.move(p,t,{overwrite:true});}}finally{await f.remove(p).catch(()=>{});}}async function U(e,t,n,r={}){let l=m(e,t);await _(e,l);let o=`${l}.lock`;return K(o,()=>z(o,t,n,r))}async function z(e,t,n,r){let l=r.timeoutMs??1e4,o=r.staleAfterMs??3e4,p=Date.now(),a;for(;!a;)try{a=await open(e,"wx"),await a.writeFile(`${JSON.stringify({pid:process.pid,createdAt:new Date().toISOString()})}
1
+ import {b}from'./chunk-VN2MKTQO.js';import {d}from'./chunk-25AWHAB5.js';import {w,x as x$1}from'./chunk-VQZ5PI5J.js';import {t}from'./chunk-ODK4LCEL.js';import s from'path';import {randomUUID}from'crypto';import {open,link,copyFile}from'fs/promises';import f from'fs-extra';function N(e,t){let n=s.resolve(e),r=t.trim();if(!r||s.isAbsolute(r))throw new Error(`Workspace artifact path must be non-empty and relative: ${t}`);let l=s.resolve(n,r),o=s.relative(n,l);if(o===".."||o.startsWith(`..${s.sep}`)||s.isAbsolute(o))throw new Error(`Workspace artifact path escapes workspace root: ${t}`);return l}function m(e,t){return N(e,w(t))}async function T(e,t,n="file"){let r=s.resolve(e),l=m(r,t);if(!await f.pathExists(r)||!await f.pathExists(l))return null;let[o,p,a]=await Promise.all([f.realpath(r),f.realpath(l),f.stat(l)]),c=s.relative(o,p);if(c===".."||c.startsWith(`..${s.sep}`)||s.isAbsolute(c))throw new Error(`Workspace artifact resolves outside workspace root: ${t}`);if(!(n==="file"?a.isFile():a.isDirectory()))throw new Error(`Workspace artifact is not a regular ${n}: ${t}`);return p}async function rt(e,t$1){let n=t$1.trim().replace(/\\/g,"/").replace(/^\.\//,"");if(!n||s.isAbsolute(n))return null;let r=await T(e,n);if(r)return r;let l=t.workspaceContract;for(let o of [l,x$1(l)]){let p=await T(e,o);if(!p)continue;let a=[];try{a=(await f.readJson(p)).projects??[];}catch{return null}let c=a.filter(i=>typeof i.relativePath=="string"&&typeof i.externalPath=="string"&&s.isAbsolute(i.externalPath)).map(i=>({prefix:i.relativePath.replace(/\\/g,"/").replace(/\/$/,""),root:s.resolve(i.externalPath)})).filter(({prefix:i})=>n.startsWith(`${i}/`)).sort((i,u)=>u.prefix.length-i.prefix.length);for(let i of c){let u=n.slice(i.prefix.length+1),d=s.resolve(i.root,u),w=s.relative(i.root,d);if(!w||w===".."||w.startsWith(`..${s.sep}`)||s.isAbsolute(w)||!await f.pathExists(i.root)||!await f.pathExists(d))continue;let[g,h,P]=await Promise.all([f.realpath(i.root),f.realpath(d),f.stat(d)]),v=s.relative(g,h);if(v===".."||v.startsWith(`..${s.sep}`)||s.isAbsolute(v))throw new Error(`External evidence resolves outside its contracted root: ${t$1}`);if(!P.isFile())throw new Error(`External evidence is not a regular file: ${t$1}`);return h}return null}return null}async function C(e,t,n){let r=s.resolve(e),l=s.resolve(r,t),o=s.relative(r,l);if(!o||o===".."||o.startsWith(`..${s.sep}`)||s.isAbsolute(o)||!await f.pathExists(r))return null;let p=await f.realpath(r),a=l;for(;!await f.pathExists(a);){let u=s.dirname(a);if(u===a)return null;a=u;}let c=await f.realpath(a),i=s.relative(p,c);if(i===".."||i.startsWith(`..${s.sep}`)||s.isAbsolute(i))throw new Error(n);return l}async function at(e,t$1){let n=t$1.trim().replace(/\\/g,"/").replace(/^\.\//,"");if(!n||s.isAbsolute(n))return null;let r=t.workspaceContract;for(let l of [r,x$1(r)]){let o=await T(e,l);if(!o)continue;let p=[];try{p=(await f.readJson(o)).projects??[];}catch{return null}let a=p.filter(c=>typeof c.relativePath=="string"&&typeof c.externalPath=="string"&&s.isAbsolute(c.externalPath)).map(c=>({prefix:c.relativePath.replace(/\\/g,"/").replace(/\/$/,""),root:s.resolve(c.externalPath)})).filter(({prefix:c})=>n.startsWith(`${c}/`)).sort((c,i)=>i.prefix.length-c.prefix.length);if(a.length>0){for(let c of a){let i=n.slice(c.prefix.length+1),u=await C(c.root,i,`External evidence candidate resolves outside its contracted root: ${t$1}`);if(u)return u}return null}break}return C(e,n,`Workspace evidence candidate resolves outside workspace root: ${t$1}`)}function O(e,t){return N(e,x$1(t))}async function _(e,t){let n=s.resolve(e);await f.ensureDir(n);let r=s.dirname(t);await f.ensureDir(r);let[l,o]=await Promise.all([f.realpath(n),f.realpath(r)]),p=s.relative(l,o);if(p===".."||p.startsWith(`..${s.sep}`)||s.isAbsolute(p))throw new Error(`Workspace artifact parent resolves outside workspace root: ${r}`)}async function J(e,t){let n=s.resolve(e),[r,l]=await Promise.all([f.realpath(n),f.realpath(t)]),o=s.relative(r,l);if(o===".."||o.startsWith(`..${s.sep}`)||s.isAbsolute(o))throw new Error(`Workspace artifact resolves outside workspace root: ${t}`)}function j(e){let t=e?.code;return process.platform==="win32"&&(t==="EPERM"||t==="EINVAL"||t==="ENOSYS")}function F(e,t=process.platform){if(t!=="win32")return false;let n=e?.code;return n==="EPERM"||n==="EACCES"||n==="EBUSY"}async function E(e){let t=process.platform==="win32"?6:1,n;for(let r=0;r<t;r+=1)try{await f.remove(e);return}catch(l){if(n=l,!F(l)||r===t-1)throw l;await new Promise(o=>setTimeout(o,10*2**r));}throw n}var x=new Map;async function K(e,t){let n=x.get(e)??Promise.resolve(),r,l=new Promise(p=>{r=p;}),o=n.catch(()=>{}).then(()=>l);x.set(e,o),await n.catch(()=>{});try{return await t()}finally{r(),x.get(e)===o&&x.delete(e);}}async function L(e){try{await e.sync();}catch(t){if(!j(t))throw t}}async function k(e,t,n){await _(e,t);let r=s.dirname(t),l=`${s.basename(t)}.`,o=Date.now();for(let a of await f.readdir(r)){if(!a.startsWith(l)||!a.endsWith(".tmp"))continue;let c=s.join(r,a),i=await f.stat(c).catch(()=>null);i&&o-i.mtimeMs>3e4&&await f.remove(c).catch(()=>{});}let p=`${t}.${process.pid}.${randomUUID()}.tmp`;try{await n(p);let a=await open(p,"r");try{await L(a);}finally{await a.close();}let c=Number(process.env.WORKSPAI_TEST_ATOMIC_WRITE_DELAY_MS??0);Number.isFinite(c)&&c>0&&await new Promise(i=>setTimeout(i,Math.min(c,3e4)));try{await f.rename(p,t);}catch(i){let u=i.code;if(u!=="EEXIST"&&u!=="EPERM")throw i;await f.move(p,t,{overwrite:true});}}finally{await f.remove(p).catch(()=>{});}}async function U(e,t,n,r={}){let l=m(e,t);await _(e,l);let o=`${l}.lock`;return K(o,()=>z(o,t,n,r))}async function z(e,t,n,r){let l=r.timeoutMs??1e4,o=r.staleAfterMs??3e4,p=Date.now(),a;for(;!a;)try{a=await open(e,"wx"),await a.writeFile(`${JSON.stringify({pid:process.pid,createdAt:new Date().toISOString()})}
2
2
  `),await L(a);}catch(c){if(!(c.code==="EEXIST"||F(c)))throw a&&(await a.close().catch(()=>{}),a=void 0,await E(e).catch(()=>{})),c;a&&(await a.close().catch(()=>{}),a=void 0,await E(e).catch(()=>{}));let[d,w]=await Promise.all([f.stat(e).catch(()=>null),f.readJson(e).catch(()=>null)]),g=Number(w?.pid),h=Number.isInteger(g)&&g>0,P=false;if(h)try{process.kill(g,0),P=true;}catch(b){P=b.code==="EPERM";}let v=!h&&!!(d&&Date.now()-d.mtimeMs>o);if(h&&!P||v){await E(e).catch(()=>{});continue}if(Date.now()-p>=l)throw new Error(`Timed out waiting for workspace artifact lock: ${t}`);await new Promise(b=>setTimeout(b,20));}try{return await n()}finally{await a.close().catch(()=>{}),await E(e);}}async function nt(e,t){let n=[m(e,t),O(e,t)];for(let r of n)if(await f.pathExists(r))return await J(e,r),r;return null}async function ot(e,t,n){b(t,n);let r=m(e,t);return await k(e,r,l=>f.writeJson(l,n,{spaces:2})),d({workspacePath:e,relativePath:t}),r}async function it(e,t,n){return Y(e,t,n.map(r=>({rootPath:e,...r})))}async function Y(e,t,n){if(n.length===0)return [];let r=n.map(o=>({...o,rootPath:s.resolve(o.rootPath),path:m(o.rootPath,o.relativePath)})),l=r.find((o,p)=>r.findIndex(a=>a.path===o.path)!==p);if(l)throw new Error(`Duplicate workspace artifact transaction target: ${l.relativePath}`);for(let o of r)b(o.relativePath,o.payload);return U(e,t,async()=>{let o=randomUUID(),p=[];try{for(let a of r){let c=await f.pathExists(a.path),i={path:a.path,rootPath:a.rootPath,exists:c,backupPath:null};if(p.push(i),c){let u=`${a.path}.${process.pid}.${o}.rollback`;await J(a.rootPath,a.path);try{try{await link(a.path,u);}catch{await copyFile(a.path,u);}i.backupPath=u;}catch(d){throw await f.remove(u).catch(()=>{}),d}}}for(let a=0;a<r.length;a+=1){let c=r[a];await k(c.rootPath,c.path,u=>f.writeJson(u,c.payload,{spaces:2}));let i=Number(process.env.WORKSPAI_TEST_FAIL_ARTIFACT_SET_AFTER??0);if(Number.isInteger(i)&&i===a+1)throw new Error(`Injected artifact-set failure after ${i} write(s).`)}for(let a of r)d({workspacePath:a.rootPath,relativePath:a.relativePath});return r.map(a=>a.path)}catch(a){let i=(await Promise.allSettled(p.map(async u=>{if(!u.exists){await f.remove(u.path);return}u.backupPath&&await k(u.rootPath,u.path,d=>copyFile(u.backupPath,d));}))).filter(u=>u.status==="rejected");throw i.length>0?new AggregateError([a,...i.map(u=>u.reason)],"Workspace artifact transaction failed and rollback was incomplete."):a}finally{await Promise.all(p.map(a=>a.backupPath?f.remove(a.backupPath).catch(()=>{}):Promise.resolve()));}})}async function st(e,t,n){let r=m(e,t);return await k(e,r,l=>f.writeFile(l,n,"utf-8")),d({workspacePath:e,relativePath:t}),r}export{m as a,T as b,rt as c,at as d,O as e,U as f,nt as g,ot as h,it as i,Y as j,st as k};
@@ -1 +1 @@
1
- import {f,h as h$1}from'./chunk-FE5R6EUV.js';import {t,s}from'./chunk-ODK4LCEL.js';import {t as t$1}from'./chunk-VQZ5PI5J.js';import u from'fs';import A from'path';var a=s.workspaceRunLast.schemaVersion,W="workspace-run-last.json",o=t.workspaceRunLast;var P=new Set(["init","test","build","start"]);function _(e){return P.has(e)}async function d(e){try{return await u.promises.access(e,u.constants.F_OK),true}catch{return false}}async function w(e){try{let r=await u.promises.readFile(e,"utf-8");return JSON.parse(r)}catch{return null}}function m(e){return !e||typeof e!="object"||Array.isArray(e)?null:e}function h(e){let r=e.stage;return typeof r!="string"||r.trim().length===0||!Array.isArray(e.projects)?false:_(r)||/^[a-z][a-z0-9_-]*$/i.test(r)}function T(e){let r=m(e);return !r||r.schemaVersion===a?false:h(r)}function C(e){let r=m(e);return r?r.schemaVersion===a&&r.stages!=null:false}function p(e){if(C(e))return e;if(T(e)){let r=e.stage;return {schemaVersion:a,generatedAt:e.generatedAt,workspacePath:e.workspacePath,latestStage:r,stages:{[r]:e},enterpriseControls:e.enterpriseControls??{jsonReady:true,evidencePath:o}}}return null}function U(e,r){let n=p(e);if(!n)return null;let t=r??n.latestStage;return n.stages[t]??null}async function V(e){let r=(await Promise.all(t$1(A.resolve(e),"reports",W).map(async t=>await d(t)?t:null))).find(t=>typeof t=="string");if(!r)return null;let n=await w(r);return p(n)}async function j(e,r){let n=A.resolve(e);return f(n,o,async()=>{let t=(await Promise.all(t$1(n,"reports",W).map(async s=>await d(s)?s:null))).find(s=>typeof s=="string"),R=t?await w(t):null,i=p(R);if(t&&!i)throw new Error(`Workspace run evidence is unreadable or invalid; refusing to overwrite: ${t}`);let l=i?{...i.stages}:{};l[r.stage]=r;let g={schemaVersion:a,generatedAt:r.generatedAt,workspacePath:r.workspacePath,latestStage:r.stage,stages:l,enterpriseControls:{jsonReady:true,evidencePath:o}};return await h$1(n,o,g),g})}export{W as a,o as b,U as c,V as d,j as e};
1
+ import {f,h as h$1}from'./chunk-BLEIUQL6.js';import {t as t$1}from'./chunk-VQZ5PI5J.js';import {t,s}from'./chunk-ODK4LCEL.js';import u from'fs';import A from'path';var a=s.workspaceRunLast.schemaVersion,W="workspace-run-last.json",o=t.workspaceRunLast;var P=new Set(["init","test","build","start"]);function _(e){return P.has(e)}async function d(e){try{return await u.promises.access(e,u.constants.F_OK),true}catch{return false}}async function w(e){try{let r=await u.promises.readFile(e,"utf-8");return JSON.parse(r)}catch{return null}}function m(e){return !e||typeof e!="object"||Array.isArray(e)?null:e}function h(e){let r=e.stage;return typeof r!="string"||r.trim().length===0||!Array.isArray(e.projects)?false:_(r)||/^[a-z][a-z0-9_-]*$/i.test(r)}function T(e){let r=m(e);return !r||r.schemaVersion===a?false:h(r)}function C(e){let r=m(e);return r?r.schemaVersion===a&&r.stages!=null:false}function p(e){if(C(e))return e;if(T(e)){let r=e.stage;return {schemaVersion:a,generatedAt:e.generatedAt,workspacePath:e.workspacePath,latestStage:r,stages:{[r]:e},enterpriseControls:e.enterpriseControls??{jsonReady:true,evidencePath:o}}}return null}function U(e,r){let n=p(e);if(!n)return null;let t=r??n.latestStage;return n.stages[t]??null}async function V(e){let r=(await Promise.all(t$1(A.resolve(e),"reports",W).map(async t=>await d(t)?t:null))).find(t=>typeof t=="string");if(!r)return null;let n=await w(r);return p(n)}async function j(e,r){let n=A.resolve(e);return f(n,o,async()=>{let t=(await Promise.all(t$1(n,"reports",W).map(async s=>await d(s)?s:null))).find(s=>typeof s=="string"),R=t?await w(t):null,i=p(R);if(t&&!i)throw new Error(`Workspace run evidence is unreadable or invalid; refusing to overwrite: ${t}`);let l=i?{...i.stages}:{};l[r.stage]=r;let g={schemaVersion:a,generatedAt:r.generatedAt,workspacePath:r.workspacePath,latestStage:r.stage,stages:l,enterpriseControls:{jsonReady:true,evidencePath:o}};return await h$1(n,o,g),g})}export{W as a,o as b,U as c,V as d,j as e};