workspai 0.75.1 → 0.76.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/contracts/agent-framework-capabilities.v1.json +2 -2
- package/contracts/cli-runtime-command-inventory.v1.snapshot.json +12 -0
- package/contracts/create-planner-capabilities.v1.json +24 -0
- package/contracts/extension-cli-compatibility.v1.json +4 -2
- package/contracts/published-contract-catalog.v1.json +10 -0
- package/contracts/runtime-command-surface.v1.json +3 -1
- package/contracts/workspace-intelligence/agent-framework-admission-candidate.v2.json +217 -0
- package/contracts/workspace-intelligence/agent-framework-conformance-report.v2.json +274 -0
- package/contracts/workspace-intelligence-architecture.v1.json +5 -3
- package/dist/analyze-QVRVJB7I.js +1 -0
- package/dist/{artifact-remediation-plan-HD5K52UJ.js → artifact-remediation-plan-SRH2Q6N2.js} +1 -1
- package/dist/autopilot-release-DOGIETAT.js +1 -0
- package/dist/capabilities-command-FYBUVHZ7.js +1 -0
- package/dist/{chunk-SCKEFXF5.js → chunk-23CNBYIW.js} +1 -1
- package/dist/chunk-2DZLCINC.js +1 -0
- package/dist/{chunk-2GWQ6NZV.js → chunk-2I2A55RE.js} +1 -1
- package/dist/{chunk-W7I65IXY.js → chunk-3HXEPDFF.js} +2 -2
- package/dist/{chunk-2OCJKLTW.js → chunk-4BBFEHPL.js} +1 -1
- package/dist/{chunk-VHMDWRDG.js → chunk-4BPZJR4Z.js} +4 -4
- package/dist/{chunk-UE7ART6X.js → chunk-4MXKXHLW.js} +1 -1
- package/dist/{chunk-JKAAKE4Z.js → chunk-4R44E7HN.js} +1 -1
- package/dist/chunk-5HNQIMGW.js +1 -0
- package/dist/chunk-5S6IZ6PY.js +2 -0
- package/dist/chunk-6BO4QHKA.js +1 -0
- package/dist/{chunk-25V5XMWB.js → chunk-AGI46TSQ.js} +1 -1
- package/dist/{chunk-2CT5SN2L.js → chunk-BZLDCASY.js} +1 -1
- package/dist/{chunk-OA2YJN22.js → chunk-DWDYLKVW.js} +1 -1
- package/dist/{chunk-6B7L4NZE.js → chunk-EFHSRPW7.js} +6 -6
- package/dist/{chunk-RTD5D35M.js → chunk-FBF767WP.js} +1 -1
- package/dist/{chunk-NGZF4YJS.js → chunk-FD2ZGGCQ.js} +1 -1
- package/dist/chunk-H4YHIOCT.js +7 -0
- package/dist/{chunk-ZI54C2AO.js → chunk-HRGIHWYH.js} +1 -1
- package/dist/{chunk-HDISUL3F.js → chunk-IKNWNGLY.js} +1 -1
- package/dist/{chunk-NRIMJMTF.js → chunk-KO4DM2AV.js} +8 -8
- package/dist/{chunk-6KMR5PKQ.js → chunk-KW35SWG6.js} +5 -5
- package/dist/{chunk-NI5QWBZK.js → chunk-L6VNI4DN.js} +1 -1
- package/dist/chunk-NSC4VWV2.js +1 -0
- package/dist/chunk-P5LI5DL3.js +1 -0
- package/dist/chunk-PSQPKK6H.js +97 -0
- package/dist/chunk-PUH3TSPC.js +1 -0
- package/dist/chunk-QFDTKOYS.js +2649 -0
- package/dist/chunk-QIPW3G2H.js +1 -0
- package/dist/chunk-QVFIR64T.js +10 -0
- package/dist/{chunk-AICCXYY5.js → chunk-R3Z4LY3O.js} +1 -1
- package/dist/chunk-RKFTUIZ4.js +4 -0
- package/dist/chunk-ROOPODG6.js +2 -0
- package/dist/{chunk-COOVCORC.js → chunk-SVO2GGTV.js} +1 -1
- package/dist/chunk-TFFNHWXY.js +4 -0
- package/dist/chunk-TJ3MDZMC.js +6 -0
- package/dist/{chunk-DJH2CH42.js → chunk-UHIN3RS6.js} +1 -1
- package/dist/chunk-UOTOJJI4.js +681 -0
- package/dist/chunk-VODNLROY.js +1 -0
- package/dist/{chunk-3WQ5TYCO.js → chunk-X7MDTBX5.js} +1 -1
- package/dist/{chunk-RPM67N7A.js → chunk-XHUM372O.js} +1 -1
- package/dist/chunk-YLLCZMKP.js +2 -0
- package/dist/{chunk-4VSQNSGH.js → chunk-Z2M2XCIB.js} +1 -1
- package/dist/chunk-ZXQC36NJ.js +1 -0
- package/dist/{create-P4XJVZCL.js → create-ZRUQ3KNZ.js} +1 -1
- package/dist/{demo-kit-ALW6OSQV.js → demo-kit-QNGY4KQ5.js} +1 -1
- package/dist/{doctor-PFN6KB6P.js → doctor-7V7LJLHX.js} +1 -1
- package/dist/{dotnet-webapi-clean-6Z4EXEJY.js → dotnet-webapi-clean-GXTNZMKO.js} +1 -1
- package/dist/{goal-lifecycle-BDWTWS55.js → goal-lifecycle-EM4DUJCR.js} +1 -1
- package/dist/{goal-pack-5JDNZFKV.js → goal-pack-YMWZHAH6.js} +1 -1
- package/dist/{gofiber-standard-TDJQIVQZ.js → gofiber-standard-PFBIAMGR.js} +1 -1
- package/dist/{gogin-standard-UEF3IHSJ.js → gogin-standard-DW5GL7YG.js} +1 -1
- package/dist/index.d.ts +12 -6
- package/dist/index.js +255 -253
- package/dist/{pipeline-OUYS4ZYV.js → pipeline-6MBH3MU2.js} +1 -1
- package/dist/platform-capabilities-RWOWND5Q.js +1 -0
- package/dist/{project-agent-entry-75WO3QWP.js → project-agent-entry-ZXAE2MAJ.js} +1 -1
- package/dist/{project-intelligence-lens-JCHFOIA7.js → project-intelligence-lens-NBTPOK2R.js} +1 -1
- package/dist/{project-test-coverage-3P5FH6E5.js → project-test-coverage-HOZC72EK.js} +1 -1
- package/dist/proof-carrying-change-WJFAKK3C.js +1 -0
- package/dist/{pythonRapidkitExec-UMFLDIYR.js → pythonRapidkitExec-S35OEIEF.js} +1 -1
- package/dist/{rust-axum-4TRVPFMB.js → rust-axum-L7UAYARA.js} +1 -1
- package/dist/{springboot-standard-COWL75GT.js → springboot-standard-CZH24KWD.js} +1 -1
- package/dist/verified-goal-B7EX2PBE.js +1 -0
- package/dist/{workspace-CBQDOUSH.js → workspace-EBPYCSEM.js} +1 -1
- package/dist/{workspace-agent-sync-RTOTO3DY.js → workspace-agent-sync-Y4F6FBBC.js} +1 -1
- package/dist/{workspace-context-STRZO2N3.js → workspace-context-Y7F7GJCQ.js} +1 -1
- package/dist/{workspace-contract-PMHUUKFM.js → workspace-contract-XJMWMVQE.js} +1 -1
- package/dist/{workspace-explain-CATMJUMN.js → workspace-explain-T2J5ZLY7.js} +1 -1
- package/dist/{workspace-foundation-OULCDCXG.js → workspace-foundation-2UP6IMTH.js} +1 -1
- package/dist/{workspace-graph-stream-Q55CI4K4.js → workspace-graph-stream-MZVL3OCX.js} +1 -1
- package/dist/workspace-graph-token-efficiency-WF6TGSK7.js +1 -0
- package/dist/{workspace-intelligence-3RPZRWSF.js → workspace-intelligence-FZRQIFFM.js} +1 -1
- package/dist/{workspace-intelligence-benchmark-R5MEGJQS.js → workspace-intelligence-benchmark-V6AEVDMB.js} +1 -1
- package/dist/{workspace-intelligence-runner-BNZUYUUN.js → workspace-intelligence-runner-IXT62JG7.js} +1 -1
- package/dist/{workspace-knowledge-graph-VJLD35ES.js → workspace-knowledge-graph-EFC4TUDZ.js} +1 -1
- package/dist/workspace-knowledge-graph-query-BROIV27M.js +1 -0
- package/dist/workspace-knowledge-graph-snapshot-QIMF7TCF.js +1 -0
- package/dist/{workspace-mcp-serve-67NTYD67.js → workspace-mcp-serve-C42UUU7W.js} +1 -1
- package/dist/{workspace-model-6TKZMNEF.js → workspace-model-72SJ6WXT.js} +1 -1
- package/dist/{workspace-onboarding-7V7EH3RH.js → workspace-onboarding-TFDAIHTS.js} +1 -1
- package/dist/{workspace-registry-summary-ILVO7DEU.js → workspace-registry-summary-ZNTXSUI4.js} +1 -1
- package/dist/{workspace-repair-engine-2VGFB3DJ.js → workspace-repair-engine-542TAL3Z.js} +1 -1
- package/dist/workspace-run-NAPJYNSZ.js +1 -0
- package/dist/{workspace-verify-VQWYDAF2.js → workspace-verify-UXKENOQU.js} +1 -1
- package/dist/{workspace-watch-2Z636HWS.js → workspace-watch-DV5AHLOK.js} +1 -1
- package/docs/README.md +2 -2
- package/docs/agent-framework-adapters.md +190 -46
- package/docs/ci-workflows.md +37 -14
- package/docs/commands-reference.md +30 -14
- package/docs/creating-workspaces-and-projects.md +30 -10
- package/docs/doctor-command.md +6 -0
- package/docs/native-kit-baselines.md +4 -0
- package/docs/workspace-run.md +10 -0
- package/package.json +7 -4
- package/scripts/enterprise-package-smoke.mjs +98 -5
- package/dist/analyze-Z3EZNJRI.js +0 -1
- package/dist/autopilot-release-T6XFRWZT.js +0 -1
- package/dist/capabilities-command-VK3LQLP2.js +0 -1
- package/dist/chunk-566NQQTJ.js +0 -97
- package/dist/chunk-5EEXLM45.js +0 -1
- package/dist/chunk-65AE7EC5.js +0 -2
- package/dist/chunk-6NSJBKKK.js +0 -4
- package/dist/chunk-7NKM6EHE.js +0 -7
- package/dist/chunk-ABUSBLBH.js +0 -1
- package/dist/chunk-BR6QIYQS.js +0 -1
- package/dist/chunk-CMLLERGG.js +0 -418
- package/dist/chunk-DFREJHG7.js +0 -1
- package/dist/chunk-FU6SQ2ND.js +0 -1
- package/dist/chunk-M6DVNC6X.js +0 -2
- package/dist/chunk-O5XQP5E7.js +0 -1
- package/dist/chunk-OH6LV5JP.js +0 -6
- package/dist/chunk-PTI743SC.js +0 -7
- package/dist/chunk-QBKOPXKC.js +0 -1
- package/dist/chunk-RGNCL5OB.js +0 -1
- package/dist/chunk-VJQPIH2S.js +0 -681
- package/dist/chunk-WPPRUFJW.js +0 -4
- package/dist/chunk-ZKYH44ER.js +0 -1
- package/dist/platform-capabilities-DB4BZPTD.js +0 -1
- package/dist/proof-carrying-change-LAYV4LTI.js +0 -1
- package/dist/verified-goal-75KGBWTE.js +0 -1
- package/dist/workspace-graph-token-efficiency-YHXFGH3Z.js +0 -1
- package/dist/workspace-knowledge-graph-query-TT2KK3SF.js +0 -1
- package/dist/workspace-knowledge-graph-snapshot-TQAKDDUA.js +0 -1
- package/dist/workspace-run-X7KV6MIT.js +0 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {l}from'./chunk-QBKOPXKC.js';import {a as a$1}from'./chunk-25V5XMWB.js';import {b}from'./chunk-OA2YJN22.js';import {j}from'./chunk-FU6SQ2ND.js';import {b as b$1}from'./chunk-VN2MKTQO.js';import {a}from'./chunk-AFIFZTOY.js';import {c}from'./chunk-EWZZUQBR.js';import {s,t,p}from'./chunk-ODK4LCEL.js';import Pe from'crypto';import O from'fs';import M from'fs/promises';import f from'path';var fe=s.projectAgentEntry.schemaVersion,L=t.projectAgentEntry,Ce="workspai.agent-bootstrap-receipt.v1",Ve="<!-- WORKSPAI:AGENT-ENTRY:START -->",Be="<!-- WORKSPAI:AGENT-ENTRY:END -->",B=["generic","codex","claude","gemini","qwen","kimi","grok","copilot","cursor","windsurf","amazon-q"],Ue=["CLAUDE.md","GEMINI.md","QWEN.md",".amazonq/rules/workspai-agent-entry.md"];function Se(t){let s=t?.trim().toLowerCase()||"generic";if(s==="orca")return "grok";if(B.includes(s))return s;throw new Error(`Unsupported agent host "${s}". Expected one of: ${B.join(", ")}.`)}function me(t){let s=t.map(c=>c.id).sort(),n=[...B].sort();if(s.length!==n.length||s.some((c,p)=>c!==n[p]))throw new Error("Project agent entry must define each supported host exactly once.")}function U(t){let{integrity:s,...n}=t;return n}function T(t){return c(t)}function Je(t$1){me(t$1.hosts);let s={schemaVersion:fe,generatedAt:t$1.context.generatedAt,project:{name:t$1.context.project.name,relativePath:t$1.context.project.relativePath,...t$1.context.project.runtime?{runtime:t$1.context.project.runtime}:{},...t$1.context.project.framework?{framework:t$1.context.project.framework}:{}},workspace:{name:t$1.context.workspace.name,relationship:t$1.context.workspace.relationship,localBinding:t.projectWorkspaceLink,identityIsFilesystemPath:false,resolverCommand:"workspai project workspace status --json",portableUriScheme:"workspace:",resolvedPathPolicy:"runtime-private-never-persist"},canonical:{projectContext:t.projectContextAgent,projectGrounding:".workspai/PROJECT-GROUNDING.md",projectKnowledgeGraph:t.projectKnowledgeGraphReference,goalIndex:`workspace:${t.goalIndex}`,workspaceIndex:`workspace:${p.agentIndex}`,workspaceContext:`workspace:${p.agentContext}`,workspaceModel:`workspace:${p.model}`,knowledgeGraph:`workspace:${p.knowledgeGraph}`,workspaceSkillsIndex:`workspace:${p.skillsIndex}`,boundedGraphSearch:"command:workspai workspace graph search <task-query> --scope project:<project> --limit 12 --json"},protocol:{mode:"canonical-first",bootstrapCommand:"workspai agent bootstrap --for-agent generic --strict --json",verifyCommand:"workspai project agent-entry verify --for-agent all --strict --json",requiredReadOrder:[L,"command:workspai agent bootstrap --for-agent generic --strict --json","command:workspai project workspace status --json",t.projectContextAgent,`workspace:${t.goalIndex}`,`workspace:${p.skillsIndex}`,"command:workspai workspace graph search <task-query> --scope project:<project> --limit 12 --json","source:targeted-live-files"],sourcePolicy:{liveSourceAuthority:"exact-implementation",workspaceEvidenceAuthority:"identity-topology-readiness-goals",broadScanBeforeBootstrap:false,sourceMutation:"governed-only",verificationClaims:"cli-evidence-only"},degradedMode:{discloseMissingEvidence:true,allowCompleteArchitectureClaims:false,allowReadOnlySourceInspection:true}},hosts:[...t$1.hosts].sort((c,p)=>c.id.localeCompare(p.id))},n={...s,integrity:{algorithm:"sha256",projectContextHash:t$1.context.integrity.payloadHash,payloadHash:T(s),portable:true,absolutePathsEmitted:false}};if(!A(n))throw new Error("Project agent entry rejected a non-portable local path.");return a(n,"contracts/workspace-intelligence/project-agent-entry.v1.json","Project agent entry"),n}function A(t){return typeof t=="string"?!(/^[A-Za-z]:[\\/]/.test(t)||/(?:^|[\s("'`])[A-Za-z]:[\\/]/.test(t)||/(?:^|[\s("'`])file:\/\//i.test(t)||/(?:^|[\s("'`])\\\\[^\\\s]+[\\]/.test(t)||/(?:^|[\s("'`])\/(?:Users|home|private|var|opt|srv|mnt|Volumes|tmp)\//.test(t)):Array.isArray(t)?t.every(A):t&&typeof t=="object"?Object.values(t).every(A):true}async function Te(t){let s=f.join(t,L),n=JSON.parse(await M.readFile(s,"utf8"));if(a(n,"contracts/workspace-intelligence/project-agent-entry.v1.json","Project agent entry"),n.integrity.payloadHash!==T(U(n)))throw new Error("Project agent entry integrity validation failed.");if(me(n.hosts),!A(n)||n.integrity.absolutePathsEmitted)throw new Error("Project agent entry contains a non-portable local path.");return n}async function Re(t$1){let s=f.join(t$1,t.projectContextAgent),n=JSON.parse(await M.readFile(s,"utf8"));a(n,"contracts/workspace-intelligence/project-context-agent.v1.json","Project context agent");let c=U(n),p=Pe.createHash("sha256").update(JSON.stringify(c)).digest("hex");if(n.integrity.payloadHash!==p)throw new Error("Project context agent integrity validation failed.");if(!A(n)||n.integrity.absolutePathsEmitted)throw new Error("Project context agent contains a non-portable local path.");return n}function xe(t){return t.includes("blocked")?"blocked":t.includes("degraded")?"degraded":"ready"}async function Ye(t$1){let s=b({startPath:f.resolve(t$1.startPath??process.cwd()),strict:true,requireProjectMembership:true});if(!s?.projectPath)throw new Error("No canonically bound Workspai project was resolved.");let n=s.projectPath,c$1=s.workspacePath,p$1=await Te(n),o=await Re(n);if(p$1.integrity.projectContextHash!==o.integrity.payloadHash||p$1.project.name!==o.project.name||p$1.workspace.name!==o.workspace.name)throw new Error("Project agent entry is not bound to the current project context.");let J=t$1.forAgent?.trim().toLowerCase()||"generic",Y=J==="all",g=Y?"all":Se(J),D=g,m=Y?p$1.hosts:p$1.hosts.filter(e=>e.id===g),z=p$1.hosts.find(e=>e.id==="generic");if(m.length===0&&z&&m.push(z),m.length===0)throw new Error("Project agent entry does not define generic host coverage.");let y=[],d=(e,r,P,h)=>y.push({id:e,status:r,message:P,...h?{artifact:h}:{}});d("workspace-binding","passed","Canonical workspace membership is resolved."),d("entry-integrity","passed","Project entry manifest integrity is valid.",L),d("project-context-integrity","passed","Project context integrity and manifest binding are valid.",t.projectContextAgent);let $=[...new Set(m.flatMap(e=>e.entryFiles))].sort(),ue=$.filter(e=>!O.existsSync(f.join(n,e))),k=m.some(e=>e.status==="blocked")||ue.length>0?"blocked":m.some(e=>e.status==="degraded")?"degraded":"ready";d("host-discovery",k==="ready"?"passed":k==="degraded"?"warning":"failed",k==="ready"?`${g} has discoverable Workspai entry coverage.`:k==="degraded"?m.find(e=>e.reason)?.reason??`${g} entry coverage is degraded.`:`${g} entry coverage is missing required files.`,$[0]);let Z=[p.agentIndex,p.agentContext,p.skillsIndex,p.model,p.knowledgeGraph],R=Z.filter(e=>!O.existsSync(f.join(c$1,e)));d("canonical-evidence",R.length===0?"passed":"failed",R.length===0?"Required canonical workspace evidence is present.":`Required canonical evidence is missing: ${R.join(", ")}.`);let E=[],x=null,u=null;for(let e of Z)if(!R.includes(e))try{let r=JSON.parse(await M.readFile(f.join(c$1,e),"utf8"));b$1(e,r,e),e===p.model&&(x=r),e===p.knowledgeGraph&&(u=r);}catch{E.push(e);}d("canonical-contracts",E.length===0?"passed":"failed",E.length===0?"Canonical workspace evidence satisfies its published schemas.":`Canonical evidence failed contract validation: ${E.join(", ")}.`);let b$2=t.projectKnowledgeGraphReference,Q=f.join(n,b$2),X="failed",I="The project Knowledge Graph reference is missing.";if(O.existsSync(Q)&&u)try{let e=JSON.parse(await M.readFile(Q,"utf8"));b$1(b$2,e,b$2);let r=j(u,o.project.name),{integrity:P,...h}=e,C=u.source;e.project.name===o.project.name&&e.canonical.sourceHash===C?.hash&&e.canonical.projectionHash===c(r)&&e.integrity.payloadHash===c(h)?(X="passed",I="The project reference integrity-binds the exact current projection of canonical workspace evidence."):I="The project Knowledge Graph reference is stale or does not match the canonical project projection.";}catch{I="The project Knowledge Graph reference failed schema or integrity validation.";}d("project-knowledge-graph",X,I,b$2);let ee=x?.workspace,te=u?.workspace,oe=Array.isArray(u?.entities)?u.entities:[],ne=Array.isArray(x?.projects)?x.projects:[],re=E.length===0&&ee?.name===o.workspace.name&&te?.name===o.workspace.name&&ne.some(e=>e.name===o.project.name)&&oe.some(e=>e.projectId===o.project.name);d("canonical-project-membership",re?"passed":"failed",re?"The project and workspace identities agree across the entry, Model, and Graph.":`The project or workspace identity is missing or inconsistent in canonical evidence (entry workspace=${o.workspace.name}, model workspace=${String(ee?.name??"missing")}, graph workspace=${String(te?.name??"missing")}, entry project=${o.project.name}, model projects=${ne.map(e=>String(e.name??"missing")).join(",")||"missing"}, graph projects=${[...new Set(oe.map(e=>e.projectId).filter(e=>typeof e=="string"))].join(",")||"missing"}).`);let se=!o.intelligence.freshness.graphMatchesModel||["missing","stale"].includes(o.intelligence.freshness.model)||["missing","stale"].includes(o.intelligence.freshness.graph)?"failed":o.intelligence.freshness.model==="unknown"||o.intelligence.freshness.graph==="unknown"?"warning":"passed",j$1=false,G;if(t$1.validateLiveInputs!==false)try{let e=await a$1(c$1);j$1=e.status==="hit";let r=e.status==="hit"?"Live project inputs match the persisted Model and Knowledge Graph snapshot.":`Live project inputs require an intelligence refresh (${e.reason}).`;G={id:"live-inputs",status:j$1?"passed":"failed",message:r};}catch{G={id:"live-inputs",status:"failed",message:"Live project inputs could not be validated against canonical graph evidence."};}else G={id:"live-inputs",status:"warning",message:"Live input validation was skipped; persisted compatibility was checked only."};let K=se==="warning"&&o.intelligence.freshness.model==="unknown"&&o.intelligence.freshness.graph==="fresh"&&o.intelligence.freshness.graphMatchesModel&&j$1?"passed":se;d("persisted-freshness",K,K==="passed"?o.intelligence.freshness.model==="unknown"?"Model and Graph bindings are current; live input validation closes structural freshness while verify-before-use facts remain individually governed.":"Persisted Model and Knowledge Graph bindings are current.":K==="warning"?"Persisted evidence is compatible, but at least one freshness state is unknown.":"Persisted Model or Knowledge Graph evidence is missing, stale, or mismatched."),y.push(G);let i={present:false,appliesToProject:false,status:"none"},_=[],we=f.join(c$1,t.goalIndex);if(O.existsSync(we)){let e=null;try{e=await l({workspacePath:c$1,validateBindings:false});}catch{_.push("workspai goal --list --json"),d("active-goal","failed","The Goal index is present but invalid.");}if(e?.active&&(i={present:true,appliesToProject:e.active.scope.projects.includes(o.project.name),status:"invalid",id:e.active.id,objective:e.active.objective,lifecycle:e.active.lifecycle,goalPack:`workspace:${e.active.goalPack}`,agentHandoff:`workspace:${e.active.agentHandoff}`}),e)try{let r=await l({workspacePath:c$1,validateBindings:true});r.active&&(i={present:true,appliesToProject:r.active.scope.projects.includes(o.project.name),status:"ready",id:r.active.id,objective:r.active.objective,lifecycle:r.active.lifecycle,goalPack:`workspace:${r.active.goalPack}`,agentHandoff:`workspace:${r.active.agentHandoff}`}),d("active-goal","passed",r.active?"The active Goal Pack and agent handoff have valid canonical bindings.":"No active Goal Pack is selected.");}catch(r){let P=r instanceof Error?r.message:String(r),h=i.present&&/\bstale\b|--refresh/i.test(P);if(i.present&&(i.status=h?"stale":"invalid"),h&&i.objective){let w=e.active,ve=w?.scope.kind==="project"&&w.scope.projects.length===1?`project:${w.scope.projects[0]}`:w?.scope.kind==="project-set"&&w.scope.projects.length>1?`projects:${w.scope.projects.join(",")}`:"workspace";_.push(`workspai goal ${JSON.stringify(i.objective)} --scope ${ve} --for-agent generic --refresh --json`);}else _.push("workspai goal --status --json");let C=!i.present||i.appliesToProject;d("active-goal",C?"failed":"warning",h?C?"The selected Goal Pack is present but stale; regenerate it against current canonical evidence before acting.":"The selected Goal Pack is stale, but it does not apply to this project; current project evidence remains usable while the Goal is refreshed for its own scope.":i.present?C?"The selected Goal Pack is present but its canonical binding or handoff is invalid.":"The selected Goal Pack has an invalid canonical binding, but it does not apply to this project; current project evidence remains usable while the Goal is repaired for its own scope.":"The Goal index could not be validated.");}}else d("active-goal","passed","No Goal index is present for this workspace.");let ae=y.filter(e=>e.id!=="active-goal"),W=ae.some(e=>e.status==="failed")?"blocked":ae.some(e=>e.status==="warning")?"degraded":"ready",ye=y.some(e=>e.id==="active-goal"&&e.status==="failed")?"blocked":y.some(e=>e.id==="active-goal"&&e.status==="warning")?"degraded":"ready",N=xe([k,W,ye]),v=o.blockers.some(e=>e.severity==="error")?"blocked":o.blockers.length>0?"degraded":"ready",ke=v==="blocked"?"blocked":v==="degraded"?"degraded":"not-verified",je=`command:workspai agent bootstrap --for-agent ${g} --strict --json`,Ae=p$1.protocol.requiredReadOrder.map(e=>e==="command:workspai agent bootstrap --for-agent generic --strict --json"?je:e),ie={schemaVersion:Ce,generatedAt:(t$1.now??new Date).toISOString(),status:N,statusScope:"agent-grounding",readiness:{agentGrounding:N,architectureEvidence:W,projectEnvironment:v,release:ke},requestedAgent:D,resolvedHost:g,project:{name:o.project.name,relativePath:o.project.relativePath,...o.project.runtime?{runtime:o.project.runtime}:{},...o.project.framework?{framework:o.project.framework}:{}},workspace:{name:o.workspace.name,relationship:o.workspace.relationship,resolved:true,identityIsFilesystemPath:false,resolverCommand:"workspai project workspace status --json",portableUriScheme:"workspace:",resolvedPathPolicy:"runtime-private-never-persist"},entry:{artifact:L,schemaVersion:fe,hostStatus:k,entryFiles:$},canonicalEvidence:{projectContext:t.projectContextAgent,projectKnowledgeGraph:t.projectKnowledgeGraphReference,workspaceIndex:`workspace:${p.agentIndex}`,workspaceContext:`workspace:${p.agentContext}`,workspaceModel:`workspace:${p.model}`,knowledgeGraph:`workspace:${p.knowledgeGraph}`,workspaceSkillsIndex:`workspace:${p.skillsIndex}`,boundedGraphSearch:"command:workspai workspace graph search <task-query> --scope project:<project> --limit 12 --json",modelFreshness:j$1?"fresh":o.intelligence.freshness.model,graphFreshness:j$1?"fresh":o.intelligence.freshness.graph,graphMatchesModel:o.intelligence.freshness.graphMatchesModel,liveInputsValidated:j$1,blockerCount:o.blockers.length},activeGoal:i,requiredReadOrder:Ae,claims:{architecture:W==="ready"?"allowed-with-citations":"prohibited",sourceInspection:"bounded-and-targeted",sourceMutation:"governed-cli-transaction-only",verification:"cli-evidence-only"},checks:y,nextActions:N==="ready"?[...i.present&&i.appliesToProject&&i.agentHandoff?[`read:${i.agentHandoff}`]:[],...v==="blocked"?["workspai doctor project --json","workspai workspace explain release-blocked --json"]:v==="degraded"?["workspai doctor project --json"]:[],`workspai workspace graph search <task-query> --scope project:${o.project.name} --limit 12 --json`,"inspect only the returned proof paths and target source files"]:[..._,"workspai workspace intelligence run --for-agent generic --strict --json",`workspai agent bootstrap --for-agent ${g} --strict --json`]},ce=T(U(p$1)),Ee=T({manifestHash:ce,projectContextHash:o.integrity.payloadHash,requestedAgent:D,status:N,generatedAt:ie.generatedAt}),pe={...ie,receiptId:Ee},F={...pe,integrity:{algorithm:"sha256",manifestHash:ce,projectContextHash:o.integrity.payloadHash,payloadHash:T(pe),portable:true,absolutePathsEmitted:false}};if(!A(F))throw new Error("Agent bootstrap receipt rejected a non-portable local path.");return a(F,"contracts/workspace-intelligence/agent-bootstrap-receipt.v1.json","Agent bootstrap receipt"),F}
|
|
1
|
+
import {l}from'./chunk-QIPW3G2H.js';import {a as a$1}from'./chunk-AGI46TSQ.js';import {b}from'./chunk-DWDYLKVW.js';import {j}from'./chunk-VODNLROY.js';import {b as b$1}from'./chunk-VN2MKTQO.js';import {a}from'./chunk-AFIFZTOY.js';import {c}from'./chunk-EWZZUQBR.js';import {s,t,p}from'./chunk-ODK4LCEL.js';import Pe from'crypto';import O from'fs';import M from'fs/promises';import f from'path';var fe=s.projectAgentEntry.schemaVersion,L=t.projectAgentEntry,Ce="workspai.agent-bootstrap-receipt.v1",Ve="<!-- WORKSPAI:AGENT-ENTRY:START -->",Be="<!-- WORKSPAI:AGENT-ENTRY:END -->",B=["generic","codex","claude","gemini","qwen","kimi","grok","copilot","cursor","windsurf","amazon-q"],Ue=["CLAUDE.md","GEMINI.md","QWEN.md",".amazonq/rules/workspai-agent-entry.md"];function Se(t){let s=t?.trim().toLowerCase()||"generic";if(s==="orca")return "grok";if(B.includes(s))return s;throw new Error(`Unsupported agent host "${s}". Expected one of: ${B.join(", ")}.`)}function me(t){let s=t.map(c=>c.id).sort(),n=[...B].sort();if(s.length!==n.length||s.some((c,p)=>c!==n[p]))throw new Error("Project agent entry must define each supported host exactly once.")}function U(t){let{integrity:s,...n}=t;return n}function T(t){return c(t)}function Je(t$1){me(t$1.hosts);let s={schemaVersion:fe,generatedAt:t$1.context.generatedAt,project:{name:t$1.context.project.name,relativePath:t$1.context.project.relativePath,...t$1.context.project.runtime?{runtime:t$1.context.project.runtime}:{},...t$1.context.project.framework?{framework:t$1.context.project.framework}:{}},workspace:{name:t$1.context.workspace.name,relationship:t$1.context.workspace.relationship,localBinding:t.projectWorkspaceLink,identityIsFilesystemPath:false,resolverCommand:"workspai project workspace status --json",portableUriScheme:"workspace:",resolvedPathPolicy:"runtime-private-never-persist"},canonical:{projectContext:t.projectContextAgent,projectGrounding:".workspai/PROJECT-GROUNDING.md",projectKnowledgeGraph:t.projectKnowledgeGraphReference,goalIndex:`workspace:${t.goalIndex}`,workspaceIndex:`workspace:${p.agentIndex}`,workspaceContext:`workspace:${p.agentContext}`,workspaceModel:`workspace:${p.model}`,knowledgeGraph:`workspace:${p.knowledgeGraph}`,workspaceSkillsIndex:`workspace:${p.skillsIndex}`,boundedGraphSearch:"command:workspai workspace graph search <task-query> --scope project:<project> --limit 12 --json"},protocol:{mode:"canonical-first",bootstrapCommand:"workspai agent bootstrap --for-agent generic --strict --json",verifyCommand:"workspai project agent-entry verify --for-agent all --strict --json",requiredReadOrder:[L,"command:workspai agent bootstrap --for-agent generic --strict --json","command:workspai project workspace status --json",t.projectContextAgent,`workspace:${t.goalIndex}`,`workspace:${p.skillsIndex}`,"command:workspai workspace graph search <task-query> --scope project:<project> --limit 12 --json","source:targeted-live-files"],sourcePolicy:{liveSourceAuthority:"exact-implementation",workspaceEvidenceAuthority:"identity-topology-readiness-goals",broadScanBeforeBootstrap:false,sourceMutation:"governed-only",verificationClaims:"cli-evidence-only"},degradedMode:{discloseMissingEvidence:true,allowCompleteArchitectureClaims:false,allowReadOnlySourceInspection:true}},hosts:[...t$1.hosts].sort((c,p)=>c.id.localeCompare(p.id))},n={...s,integrity:{algorithm:"sha256",projectContextHash:t$1.context.integrity.payloadHash,payloadHash:T(s),portable:true,absolutePathsEmitted:false}};if(!A(n))throw new Error("Project agent entry rejected a non-portable local path.");return a(n,"contracts/workspace-intelligence/project-agent-entry.v1.json","Project agent entry"),n}function A(t){return typeof t=="string"?!(/^[A-Za-z]:[\\/]/.test(t)||/(?:^|[\s("'`])[A-Za-z]:[\\/]/.test(t)||/(?:^|[\s("'`])file:\/\//i.test(t)||/(?:^|[\s("'`])\\\\[^\\\s]+[\\]/.test(t)||/(?:^|[\s("'`])\/(?:Users|home|private|var|opt|srv|mnt|Volumes|tmp)\//.test(t)):Array.isArray(t)?t.every(A):t&&typeof t=="object"?Object.values(t).every(A):true}async function Te(t){let s=f.join(t,L),n=JSON.parse(await M.readFile(s,"utf8"));if(a(n,"contracts/workspace-intelligence/project-agent-entry.v1.json","Project agent entry"),n.integrity.payloadHash!==T(U(n)))throw new Error("Project agent entry integrity validation failed.");if(me(n.hosts),!A(n)||n.integrity.absolutePathsEmitted)throw new Error("Project agent entry contains a non-portable local path.");return n}async function Re(t$1){let s=f.join(t$1,t.projectContextAgent),n=JSON.parse(await M.readFile(s,"utf8"));a(n,"contracts/workspace-intelligence/project-context-agent.v1.json","Project context agent");let c=U(n),p=Pe.createHash("sha256").update(JSON.stringify(c)).digest("hex");if(n.integrity.payloadHash!==p)throw new Error("Project context agent integrity validation failed.");if(!A(n)||n.integrity.absolutePathsEmitted)throw new Error("Project context agent contains a non-portable local path.");return n}function xe(t){return t.includes("blocked")?"blocked":t.includes("degraded")?"degraded":"ready"}async function Ye(t$1){let s=b({startPath:f.resolve(t$1.startPath??process.cwd()),strict:true,requireProjectMembership:true});if(!s?.projectPath)throw new Error("No canonically bound Workspai project was resolved.");let n=s.projectPath,c$1=s.workspacePath,p$1=await Te(n),o=await Re(n);if(p$1.integrity.projectContextHash!==o.integrity.payloadHash||p$1.project.name!==o.project.name||p$1.workspace.name!==o.workspace.name)throw new Error("Project agent entry is not bound to the current project context.");let J=t$1.forAgent?.trim().toLowerCase()||"generic",Y=J==="all",g=Y?"all":Se(J),D=g,m=Y?p$1.hosts:p$1.hosts.filter(e=>e.id===g),z=p$1.hosts.find(e=>e.id==="generic");if(m.length===0&&z&&m.push(z),m.length===0)throw new Error("Project agent entry does not define generic host coverage.");let y=[],d=(e,r,P,h)=>y.push({id:e,status:r,message:P,...h?{artifact:h}:{}});d("workspace-binding","passed","Canonical workspace membership is resolved."),d("entry-integrity","passed","Project entry manifest integrity is valid.",L),d("project-context-integrity","passed","Project context integrity and manifest binding are valid.",t.projectContextAgent);let $=[...new Set(m.flatMap(e=>e.entryFiles))].sort(),ue=$.filter(e=>!O.existsSync(f.join(n,e))),k=m.some(e=>e.status==="blocked")||ue.length>0?"blocked":m.some(e=>e.status==="degraded")?"degraded":"ready";d("host-discovery",k==="ready"?"passed":k==="degraded"?"warning":"failed",k==="ready"?`${g} has discoverable Workspai entry coverage.`:k==="degraded"?m.find(e=>e.reason)?.reason??`${g} entry coverage is degraded.`:`${g} entry coverage is missing required files.`,$[0]);let Z=[p.agentIndex,p.agentContext,p.skillsIndex,p.model,p.knowledgeGraph],R=Z.filter(e=>!O.existsSync(f.join(c$1,e)));d("canonical-evidence",R.length===0?"passed":"failed",R.length===0?"Required canonical workspace evidence is present.":`Required canonical evidence is missing: ${R.join(", ")}.`);let E=[],x=null,u=null;for(let e of Z)if(!R.includes(e))try{let r=JSON.parse(await M.readFile(f.join(c$1,e),"utf8"));b$1(e,r,e),e===p.model&&(x=r),e===p.knowledgeGraph&&(u=r);}catch{E.push(e);}d("canonical-contracts",E.length===0?"passed":"failed",E.length===0?"Canonical workspace evidence satisfies its published schemas.":`Canonical evidence failed contract validation: ${E.join(", ")}.`);let b$2=t.projectKnowledgeGraphReference,Q=f.join(n,b$2),X="failed",I="The project Knowledge Graph reference is missing.";if(O.existsSync(Q)&&u)try{let e=JSON.parse(await M.readFile(Q,"utf8"));b$1(b$2,e,b$2);let r=j(u,o.project.name),{integrity:P,...h}=e,C=u.source;e.project.name===o.project.name&&e.canonical.sourceHash===C?.hash&&e.canonical.projectionHash===c(r)&&e.integrity.payloadHash===c(h)?(X="passed",I="The project reference integrity-binds the exact current projection of canonical workspace evidence."):I="The project Knowledge Graph reference is stale or does not match the canonical project projection.";}catch{I="The project Knowledge Graph reference failed schema or integrity validation.";}d("project-knowledge-graph",X,I,b$2);let ee=x?.workspace,te=u?.workspace,oe=Array.isArray(u?.entities)?u.entities:[],ne=Array.isArray(x?.projects)?x.projects:[],re=E.length===0&&ee?.name===o.workspace.name&&te?.name===o.workspace.name&&ne.some(e=>e.name===o.project.name)&&oe.some(e=>e.projectId===o.project.name);d("canonical-project-membership",re?"passed":"failed",re?"The project and workspace identities agree across the entry, Model, and Graph.":`The project or workspace identity is missing or inconsistent in canonical evidence (entry workspace=${o.workspace.name}, model workspace=${String(ee?.name??"missing")}, graph workspace=${String(te?.name??"missing")}, entry project=${o.project.name}, model projects=${ne.map(e=>String(e.name??"missing")).join(",")||"missing"}, graph projects=${[...new Set(oe.map(e=>e.projectId).filter(e=>typeof e=="string"))].join(",")||"missing"}).`);let se=!o.intelligence.freshness.graphMatchesModel||["missing","stale"].includes(o.intelligence.freshness.model)||["missing","stale"].includes(o.intelligence.freshness.graph)?"failed":o.intelligence.freshness.model==="unknown"||o.intelligence.freshness.graph==="unknown"?"warning":"passed",j$1=false,G;if(t$1.validateLiveInputs!==false)try{let e=await a$1(c$1);j$1=e.status==="hit";let r=e.status==="hit"?"Live project inputs match the persisted Model and Knowledge Graph snapshot.":`Live project inputs require an intelligence refresh (${e.reason}).`;G={id:"live-inputs",status:j$1?"passed":"failed",message:r};}catch{G={id:"live-inputs",status:"failed",message:"Live project inputs could not be validated against canonical graph evidence."};}else G={id:"live-inputs",status:"warning",message:"Live input validation was skipped; persisted compatibility was checked only."};let K=se==="warning"&&o.intelligence.freshness.model==="unknown"&&o.intelligence.freshness.graph==="fresh"&&o.intelligence.freshness.graphMatchesModel&&j$1?"passed":se;d("persisted-freshness",K,K==="passed"?o.intelligence.freshness.model==="unknown"?"Model and Graph bindings are current; live input validation closes structural freshness while verify-before-use facts remain individually governed.":"Persisted Model and Knowledge Graph bindings are current.":K==="warning"?"Persisted evidence is compatible, but at least one freshness state is unknown.":"Persisted Model or Knowledge Graph evidence is missing, stale, or mismatched."),y.push(G);let i={present:false,appliesToProject:false,status:"none"},_=[],we=f.join(c$1,t.goalIndex);if(O.existsSync(we)){let e=null;try{e=await l({workspacePath:c$1,validateBindings:false});}catch{_.push("workspai goal --list --json"),d("active-goal","failed","The Goal index is present but invalid.");}if(e?.active&&(i={present:true,appliesToProject:e.active.scope.projects.includes(o.project.name),status:"invalid",id:e.active.id,objective:e.active.objective,lifecycle:e.active.lifecycle,goalPack:`workspace:${e.active.goalPack}`,agentHandoff:`workspace:${e.active.agentHandoff}`}),e)try{let r=await l({workspacePath:c$1,validateBindings:true});r.active&&(i={present:true,appliesToProject:r.active.scope.projects.includes(o.project.name),status:"ready",id:r.active.id,objective:r.active.objective,lifecycle:r.active.lifecycle,goalPack:`workspace:${r.active.goalPack}`,agentHandoff:`workspace:${r.active.agentHandoff}`}),d("active-goal","passed",r.active?"The active Goal Pack and agent handoff have valid canonical bindings.":"No active Goal Pack is selected.");}catch(r){let P=r instanceof Error?r.message:String(r),h=i.present&&/\bstale\b|--refresh/i.test(P);if(i.present&&(i.status=h?"stale":"invalid"),h&&i.objective){let w=e.active,ve=w?.scope.kind==="project"&&w.scope.projects.length===1?`project:${w.scope.projects[0]}`:w?.scope.kind==="project-set"&&w.scope.projects.length>1?`projects:${w.scope.projects.join(",")}`:"workspace";_.push(`workspai goal ${JSON.stringify(i.objective)} --scope ${ve} --for-agent generic --refresh --json`);}else _.push("workspai goal --status --json");let C=!i.present||i.appliesToProject;d("active-goal",C?"failed":"warning",h?C?"The selected Goal Pack is present but stale; regenerate it against current canonical evidence before acting.":"The selected Goal Pack is stale, but it does not apply to this project; current project evidence remains usable while the Goal is refreshed for its own scope.":i.present?C?"The selected Goal Pack is present but its canonical binding or handoff is invalid.":"The selected Goal Pack has an invalid canonical binding, but it does not apply to this project; current project evidence remains usable while the Goal is repaired for its own scope.":"The Goal index could not be validated.");}}else d("active-goal","passed","No Goal index is present for this workspace.");let ae=y.filter(e=>e.id!=="active-goal"),W=ae.some(e=>e.status==="failed")?"blocked":ae.some(e=>e.status==="warning")?"degraded":"ready",ye=y.some(e=>e.id==="active-goal"&&e.status==="failed")?"blocked":y.some(e=>e.id==="active-goal"&&e.status==="warning")?"degraded":"ready",N=xe([k,W,ye]),v=o.blockers.some(e=>e.severity==="error")?"blocked":o.blockers.length>0?"degraded":"ready",ke=v==="blocked"?"blocked":v==="degraded"?"degraded":"not-verified",je=`command:workspai agent bootstrap --for-agent ${g} --strict --json`,Ae=p$1.protocol.requiredReadOrder.map(e=>e==="command:workspai agent bootstrap --for-agent generic --strict --json"?je:e),ie={schemaVersion:Ce,generatedAt:(t$1.now??new Date).toISOString(),status:N,statusScope:"agent-grounding",readiness:{agentGrounding:N,architectureEvidence:W,projectEnvironment:v,release:ke},requestedAgent:D,resolvedHost:g,project:{name:o.project.name,relativePath:o.project.relativePath,...o.project.runtime?{runtime:o.project.runtime}:{},...o.project.framework?{framework:o.project.framework}:{}},workspace:{name:o.workspace.name,relationship:o.workspace.relationship,resolved:true,identityIsFilesystemPath:false,resolverCommand:"workspai project workspace status --json",portableUriScheme:"workspace:",resolvedPathPolicy:"runtime-private-never-persist"},entry:{artifact:L,schemaVersion:fe,hostStatus:k,entryFiles:$},canonicalEvidence:{projectContext:t.projectContextAgent,projectKnowledgeGraph:t.projectKnowledgeGraphReference,workspaceIndex:`workspace:${p.agentIndex}`,workspaceContext:`workspace:${p.agentContext}`,workspaceModel:`workspace:${p.model}`,knowledgeGraph:`workspace:${p.knowledgeGraph}`,workspaceSkillsIndex:`workspace:${p.skillsIndex}`,boundedGraphSearch:"command:workspai workspace graph search <task-query> --scope project:<project> --limit 12 --json",modelFreshness:j$1?"fresh":o.intelligence.freshness.model,graphFreshness:j$1?"fresh":o.intelligence.freshness.graph,graphMatchesModel:o.intelligence.freshness.graphMatchesModel,liveInputsValidated:j$1,blockerCount:o.blockers.length},activeGoal:i,requiredReadOrder:Ae,claims:{architecture:W==="ready"?"allowed-with-citations":"prohibited",sourceInspection:"bounded-and-targeted",sourceMutation:"governed-cli-transaction-only",verification:"cli-evidence-only"},checks:y,nextActions:N==="ready"?[...i.present&&i.appliesToProject&&i.agentHandoff?[`read:${i.agentHandoff}`]:[],...v==="blocked"?["workspai doctor project --json","workspai workspace explain release-blocked --json"]:v==="degraded"?["workspai doctor project --json"]:[],`workspai workspace graph search <task-query> --scope project:${o.project.name} --limit 12 --json`,"inspect only the returned proof paths and target source files"]:[..._,"workspai workspace intelligence run --for-agent generic --strict --json",`workspai agent bootstrap --for-agent ${g} --strict --json`]},ce=T(U(p$1)),Ee=T({manifestHash:ce,projectContextHash:o.integrity.payloadHash,requestedAgent:D,status:N,generatedAt:ie.generatedAt}),pe={...ie,receiptId:Ee},F={...pe,integrity:{algorithm:"sha256",manifestHash:ce,projectContextHash:o.integrity.payloadHash,payloadHash:T(pe),portable:true,absolutePathsEmitted:false}};if(!A(F))throw new Error("Agent bootstrap receipt rejected a non-portable local path.");return a(F,"contracts/workspace-intelligence/agent-bootstrap-receipt.v1.json","Agent bootstrap receipt"),F}
|
|
2
2
|
export{fe as a,L as b,Ce as c,Ve as d,Be as e,B as f,Ue as g,Se as h,Je as i,Ye as j};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import {s}from'./chunk-ODK4LCEL.js';var _=s.artifactRemediationPlan.schemaVersion;export{_ as a};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import {d,n}from'./chunk-
|
|
1
|
+
import {d,n}from'./chunk-VODNLROY.js';import {a,b}from'./chunk-S5KTATOU.js';function u(r){let s=new Map;for(let n of r.projects)s.has(n.name)||s.set(n.name,d(n));return s}function w(r){let s=u(r),n$1=n(r)??{nodes:r.projects.map(t=>({id:t.name,path:t.path})),edges:[]},a$1=a(n$1),o=new Map;for(let t of n$1.nodes){let e=s.get(t.id)??d({missing:t.id}),l=[...b(a$1,[t.id],{direction:"dependencies"}).keys()].filter(c=>c!==t.id).sort((c,f)=>c.localeCompare(f)).map(c=>({id:c,hash:s.get(c)??"<unknown>"}));o.set(t.id,{id:t.id,ownHash:e,transitiveInputsHash:d({own:e,dependencies:l})});}return o}function y(r,s){if(!s||Object.keys(s).length===0)return {verdict:"unknown",baseline:"none",changed:[],added:[],removed:[]};let n=[],a=[];for(let[e,i]of r.entries())e in s?s[e]!==i.transitiveInputsHash&&n.push(e):a.push(e);let o=[];for(let e of Object.keys(s))r.has(e)||o.push(e);return n.sort((e,i)=>e.localeCompare(i)),a.sort((e,i)=>e.localeCompare(i)),o.sort((e,i)=>e.localeCompare(i)),{verdict:n.length>0||a.length>0||o.length>0?"stale":"fresh",baseline:"recorded",changed:n,added:a,removed:o}}function M(r){let s={};for(let[n,a]of [...r.entries()].sort((o,t)=>o[0].localeCompare(t[0])))s[n]=a.transitiveInputsHash;return s}export{u as a,w as b,y as c,M as d};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import {a as a$1
|
|
1
|
+
import {a as a$1}from'./chunk-2DZLCINC.js';import {a as a$2}from'./chunk-7Q7X4X5I.js';import {b as b$1}from'./chunk-AO2ZI42U.js';import {a as a$3}from'./chunk-ROOPODG6.js';import {a,h,e}from'./chunk-BLEIUQL6.js';import {b}from'./chunk-252EKOR6.js';import {t,s}from'./chunk-ODK4LCEL.js';import y from'path';import {existsSync}from'fs';import ie from'fs-extra';var oe=[{artifactKind:"bootstrap-compliance",cardId:"bootstrap",fileNames:["bootstrap-compliance.latest.json"]},{artifactKind:"doctor-workspace",cardId:"doctor",fileNames:["doctor-remediation-plan-last-run.json","doctor-last-run.json"]},{artifactKind:"analyze",cardId:"analyze",fileNames:["analyze-last-run.json"]},{artifactKind:"readiness",cardId:"readiness",fileNames:["release-readiness-last-run.json"]},{artifactKind:"pipeline",cardId:"pipeline",fileNames:["pipeline-last-run.json"]},{artifactKind:"workspace-run",cardId:"workspaceRun",fileNames:["workspace-run-last.json"]},{artifactKind:"workspace-verify",cardId:"workspaceVerify",fileNames:["workspace-verify-last-run.json"]}];function f(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:void 0}function w(e){return Array.isArray(e)?e.filter(i=>typeof i=="string"&&i.trim().length>0):[]}function P(e){return [...new Set(e.map(i=>i.trim()).filter(Boolean))]}function J(e){return (e.notes.includes("Doctor finding status: blocking")?16:0)+(e.transaction?8:0)+(e.operation?4:0)+(e.invocation?2:0)+(e.strategy?.length?1:0)}function ne(e){let i=J(e.incoming)>J(e.existing),r=structuredClone(i?e.incoming:e.existing),o=i?e.existing:e.incoming,t=o.sourceStepId;return r.order=e.existing.order,r.files=P([...r.files,...o.files]),r.notes=P([...r.notes,...o.notes.filter(n=>!n.startsWith("Source Doctor capability:")&&!n.startsWith("Doctor finding status:")),...t?[`Also satisfies Doctor capability: ${t}`]:[]]),r}function ae(e,i,r){return r?i:y.relative(e,i).split(y.sep).join("/")}function D(e){return e.includeAbsolutePaths?e.projectPath:a$3({workspacePath:e.workspacePath,projectPath:e.projectPath,projectName:e.projectName}).contractRelativePath}function Z(e){let i=y.isAbsolute(e.filePath)?y.resolve(e.filePath):y.resolve(e.projectPath,e.filePath);if(e.includeAbsolutePaths)return i;let r=y.relative(e.projectPath,i);return !r||r===".."||r.startsWith(`..${y.sep}`)||y.isAbsolute(r)?void 0:`${D(e)}/${r.split(y.sep).join("/")}`}function se(e){let i=e?.trim()||"npx workspai bootstrap";if(!/(?:^|\s)--ci(?:\s|$)/.test(i)&&/(?:^|\s)--json(?:\s|$)/.test(i))return i.replace(/(?:^|\s)--json(?:\s|$)/,o=>{let t=o.startsWith(" ")?" ":"",n=o.endsWith(" ")?" ":"";return `${t}--ci --json${n}`}).trim();let r=/(?:^|\s)--ci(?:\s|$)/.test(i)?i:`${i} --ci`;return /(?:^|\s)--json(?:\s|$)/.test(r)?r:`${r} --json`}function M(e,i){return y.basename(e).toLowerCase().replace(/\.cmd$/,"")==="npx"&&i[0]==="workspai"&&!i.includes("--no-install")?["--no-install",...i]:i}function U(e){return {cwd:".",executable:"npx",args:M("npx",["workspai",...e])}}function ce(e){return `${JSON.stringify({schemaVersion:s.compatibilityMatrix.schemaVersion,generatedAt:e,source:"workspai workspace remediation-plan",runtimes:{},notes:["Minimal enterprise baseline. Add runtime and toolchain entries as governance matures."]},null,2)}
|
|
2
2
|
`}function de(e){return `${JSON.stringify({schema_version:"1.0",enabled:false,strategy:"on-demand",artifacts:[],created_at:e,note:"Minimal enterprise baseline. Set enabled: true and add artifact entries to activate mirroring."},null,2)}
|
|
3
|
-
`}function le(e){let i=e.payload,r=w(i.blockers),o=w(i.blockingReasons),t=w(i.failures),n=w(i.reasons),d=w(i.policyViolations),c=f(i.summary),l=w(c?.blockers);if(e.artifactKind==="analyze"){let k=(Array.isArray(i.findings)?i.findings:[]).map(b=>f(b)).filter(b=>!!b).map(b=>String(b.message??b.title??b.id??"").trim()).filter(Boolean);return P([...r,...k,...o])}if(e.artifactKind==="workspace-run"){let p=f(i.stages),k=Object.entries(p??{}).flatMap(([b,s])=>{let a=f(s);return (Array.isArray(a?.projects)?a.projects:[]).map(u=>f(u)).filter(u=>!!u).filter(u=>u.status==="failed"||u.ok===false).map(u=>`${b}: ${String(u.project??u.name??"project")} failed`)});return P([...r,...k,...o])}return P([...r,...o,...t,...n,...d,...l])}function v(e){let i=e.findingId?.trim()||e.sourceStepId?.trim()||e.id,r=e.findingStatus??"blocking",o=e.causalKey?.trim()||[e.cardId,e.projectName??e.scope??"workspace",i].map(t=>String(t).trim().toLowerCase()).join(":");return {id:e.id,artifactKind:e.artifactKind,cardId:e.cardId,title:e.title,order:e.order,phase:e.phase,scope:e.scope??"workspace",...e.projectName?{projectName:e.projectName}:{},...e.projectPath?{projectPath:e.projectPath}:{},...e.sourceStepId?{sourceStepId:e.sourceStepId}:{},findingId:i,findingStatus:r,causalKey:o,...e.dependsOn?{dependsOn:e.dependsOn}:{},...e.strategy?{strategy:structuredClone(e.strategy)}:{},...e.transaction?{transaction:structuredClone(e.transaction)}:{},...e.requirements?{requirements:structuredClone(e.requirements)}:{},...e.retryPolicy?{retryPolicy:structuredClone(e.retryPolicy)}:{},status:e.status??"ready",mode:e.mode,risk:e.risk,requiresApproval:true,blocker:e.blocker,summary:e.summary,...e.command?{command:e.command}:{},...e.invocation?{invocation:structuredClone(e.invocation)}:{},verifyCommand:e.verifyCommand,cwd:e.cwd??"workspace",files:e.files??[],...e.operation?{operation:e.operation}:{},rollback:e.rollback??(e.operation?{available:true,strategy:"idempotent"}:{available:false,strategy:"none"}),notes:e.notes??[]}}function pe(e){return (Array.isArray(e.report.payload.steps)?e.report.payload.steps:[]).flatMap((r,o)=>{let t=f(r),n=typeof t?.id=="string"?t.id.trim():"",d=typeof t?.projectName=="string"?t.projectName.trim():"",c=typeof t?.projectPath=="string"?t.projectPath.trim():"",l=typeof t?.originalCommand=="string"?t.originalCommand.trim():"";if(!t||!n||!d||!c)return [];let p=f(t.studioStatus),k=p?.state==="ready"||p?.state==="review-required"||p?.state==="blocked"||p?.state==="guidance-only"?p.state:"guidance-only",b=t.risk==="safe"||t.risk==="guarded"||t.risk==="invasive"?t.risk:"guarded",s=f(t.preview),a=D({workspacePath:e.workspacePath,projectPath:c,projectName:d,includeAbsolutePaths:e.includeAbsolutePaths}),g=H({capability:{...t,command:l},absoluteProjectPath:c,includeAbsolutePaths:e.includeAbsolutePaths}),u=X({capability:t,absoluteProjectPath:c,includeAbsolutePaths:e.includeAbsolutePaths}),R=E({operation:t.operation,absoluteProjectPath:c}),h=t.findingStatus==="blocking"||t.findingStatus==="advisory"||t.findingStatus==="informational"?t.findingStatus:"unknown",j=typeof t.diagnosisFindingId=="string"&&t.diagnosisFindingId.trim()?t.diagnosisFindingId.trim():typeof t.issueId=="string"&&t.issueId.trim()?t.issueId.trim():n,x=typeof t.causalKey=="string"&&t.causalKey.trim()?t.causalKey.trim():void 0,m=!!g&&(t.executable===true||t.executableInCurrentEnvironment===true),A=Q({strategy:t.strategy,includeAbsolutePaths:e.includeAbsolutePaths}),I=f(t.transaction),C=I?.schemaVersion==="workspai.doctor-dependency-repair-transaction.v1"?structuredClone(I):void 0;return C&&(C.projectPath=a),[v({id:`doctor.${n}`,artifactKind:e.report.artifactKind,cardId:e.report.cardId,title:typeof s?.title=="string"&&s.title.trim()?s.title.trim():`Repair ${d}`,order:e.startOrder+o,phase:typeof t.phase=="string"?t.phase:"doctor-remediation",blocker:typeof s?.summary=="string"&&s.summary.trim()?s.summary.trim():`Doctor remediation is pending for ${d}.`,summary:typeof s?.summary=="string"&&s.summary.trim()?s.summary.trim():`Execute the CLI-authored Doctor step for ${d}.`,mode:m?"run-command":"manual-guidance",risk:b,status:k,...m&&g?{command:g}:{},...m&&u?{invocation:u}:{},...R?{operation:R}:{},verifyCommand:typeof t.verifyCommand=="string"&&t.verifyCommand.trim()?t.verifyCommand.trim():"npx workspai doctor project --json",files:w(t.files).map($=>Z({workspacePath:e.workspacePath,projectPath:c,projectName:d,filePath:$,includeAbsolutePaths:e.includeAbsolutePaths})).filter($=>!!$),notes:[`Source Doctor step: ${n}`,`Doctor finding id: ${j}`,`Doctor finding status: ${h}`,...typeof p?.reason=="string"?[p.reason]:[]],scope:"project",projectName:d,projectPath:a,sourceStepId:n,findingId:j,findingStatus:h,causalKey:x,dependsOn:w(t.dependsOn).map($=>`doctor.${$}`),strategy:A,transaction:C,cwd:"project",...f(t.rollback)?.available===true?{rollback:{available:true,strategy:"manual"}}:{}})]})}function H(e){let i=typeof e.capability.command=="string"?e.capability.command.trim():"";if(e.includeAbsolutePaths&&i)return i;let r=E({operation:e.capability.operation,absoluteProjectPath:e.absoluteProjectPath});if(r)return b$2(r);let o=f(e.capability.invocation),t=typeof o?.executable=="string"?o.executable.trim():"",n=M(t,w(o?.args));if(t)return [t,...n].map(c=>/^[a-zA-Z0-9_./:@=+-]+$/.test(c)?c:JSON.stringify(c)).join(" ");if(!i)return;let d=e.absoluteProjectPath.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return i.replace(new RegExp(`^cd\\s+["']?${d}["']?\\s*&&\\s*`,"i"),"").replaceAll(e.absoluteProjectPath,".")}function X(e){let i=f(e.capability.invocation),r=typeof i?.executable=="string"?i.executable.trim():"",o=w(i?.args);if(!(!r||o.length!==(Array.isArray(i?.args)?i.args.length:0)))return {cwd:e.includeAbsolutePaths?e.absoluteProjectPath:".",executable:r,args:M(r,o)}}function E(e){let i=f(e.operation);if(!i||typeof i.type!="string")return;let r=structuredClone(i);for(let o of ["path","sourcePath"]){let t=r[o];if(typeof t!="string")continue;let n=y.isAbsolute(t)?y.relative(e.absoluteProjectPath,t):t;if(!n||n===".."||n.startsWith(`..${y.sep}`)||y.isAbsolute(n))return;r[o]=n.split(y.sep).join("/");}return r}function Q(e){if(!Array.isArray(e.strategy))return;let i=structuredClone(e.strategy);if(!e.includeAbsolutePaths)for(let r of i)r.invocation&&(r.invocation.cwd=".");return i}function me(e){let i=Array.isArray(e.report.payload.projects)?e.report.payload.projects:e.report.payload.project?[e.report.payload.project]:[],r=new Set,o=[];for(let t of i){let n=f(t);if(!n)continue;let d=typeof n.name=="string"?n.name.trim():"",c=typeof n.path=="string"?n.path.trim():"";if(!d||!c)continue;let l=Array.isArray(n.repairCapabilities)?n.repairCapabilities:Array.isArray(n.probes)?n.probes.map(s=>f(s)?.repairCapability).filter(s=>s!==void 0):[],p=new Map,k=new Map,b=f(n.diagnosis);for(let s of Array.isArray(b?.findings)?b.findings:[]){let a=f(s),g=f(a?.repair),u=typeof g?.capabilityId=="string"?g.capabilityId.trim():"",R=typeof a?.id=="string"?a.id.trim():"",h=typeof a?.causalKey=="string"?a.causalKey.trim():"",j=a?.status==="blocking"||a?.status==="advisory"||a?.status==="informational"||a?.status==="unknown"?a.status:"unknown";u&&R&&h&&k.set(u,{findingId:R,causalKey:h,findingStatus:j});}for(let s of Array.isArray(n.probes)?n.probes:[]){let a=f(s),g=f(a?.repairCapability),u=typeof g?.id=="string"?g.id.trim():"";u&&p.set(u,a?.status==="fail"?"blocking":"advisory");}for(let s of l){let a=f(s),g=typeof a?.id=="string"?a.id.trim():"";if(!a||!g)continue;let u=`${d}:${g}`;if(r.has(u))continue;r.add(u);let R=a.risk==="safe"||a.risk==="guarded"||a.risk==="invasive"?a.risk:"guarded",h=H({capability:a,absoluteProjectPath:c,includeAbsolutePaths:e.includeAbsolutePaths}),j=X({capability:a,absoluteProjectPath:c,includeAbsolutePaths:e.includeAbsolutePaths}),x=E({operation:a.operation,absoluteProjectPath:c}),m=a.status==="available"&&!!h,A=f(a.transaction),I=A?.schemaVersion==="workspai.doctor-dependency-repair-transaction.v1"?structuredClone(A):void 0,C=k.get(g),$=C?.findingStatus??p.get(g)??(I?"blocking":"advisory");I&&(I.projectPath=D({workspacePath:e.workspacePath,projectPath:c,projectName:d,includeAbsolutePaths:e.includeAbsolutePaths}));let ee=Q({strategy:a.strategy,includeAbsolutePaths:e.includeAbsolutePaths}),te=w(a.files).map(S=>Z({workspacePath:e.workspacePath,projectPath:c,projectName:d,filePath:S,includeAbsolutePaths:e.includeAbsolutePaths})).filter(S=>!!S),W=v({id:`doctor.${d}.${g}`,artifactKind:e.report.artifactKind,cardId:e.report.cardId,title:typeof a.title=="string"&&a.title.trim()?a.title.trim():`Repair ${d}`,order:e.startOrder+o.length,phase:I?"dependency-remediation":"doctor-remediation",blocker:typeof a.reason=="string"&&a.reason.trim()?a.reason.trim():`Doctor remediation is pending for ${d}.`,summary:typeof a.reason=="string"&&a.reason.trim()?a.reason.trim():`Execute the Doctor-authored repair capability for ${d}.`,mode:m?a.canEditFiles===true?"edit-file":"run-command":"manual-guidance",risk:R,status:m?"ready":a.status==="manual"?"guidance-only":"blocked",...h?{command:h}:{},...j?{invocation:j}:{},verifyCommand:typeof a.verifyCommand=="string"&&a.verifyCommand.trim()?a.verifyCommand.trim():"npx workspai doctor project --json",files:te,notes:[`Source Doctor capability: ${g}`,`Doctor finding status: ${$}`,...w(a.limitations)],scope:"project",projectName:d,projectPath:D({workspacePath:e.workspacePath,projectPath:c,projectName:d,includeAbsolutePaths:e.includeAbsolutePaths}),sourceStepId:g,findingId:C?.findingId??(typeof a.issueId=="string"&&a.issueId.trim()?a.issueId.trim():g),findingStatus:$,causalKey:C?.causalKey,strategy:ee,transaction:I,cwd:"project",...x?{operation:x,rollback:{available:true,strategy:"manual"}}:{}}),O=h?o.findIndex(S=>S.projectName===d&&S.command===h&&S.cwd==="project"):-1;if(O>=0){o[O]=ne({existing:o[O],incoming:W});continue}o.push(W);}}return o}function ue(e){let i=[],r=se("npx workspai bootstrap --json");for(let o of e.blockers)o.includes("profile.enterprise.ci")&&i.push(v({id:"bootstrap.enterprise-ci",artifactKind:"bootstrap-compliance",cardId:"bootstrap",title:"Run bootstrap in deterministic CI mode",order:10,phase:"bootstrap-preflight",blocker:o,summary:"Enterprise bootstrap compliance requires --ci for deterministic execution.",mode:"run-command",risk:"safe",command:r,verifyCommand:r})),o.includes("profile.enterprise.compatibility-matrix")&&i.push(v({id:"bootstrap.compatibility-matrix",artifactKind:"bootstrap-compliance",cardId:"bootstrap",title:"Create enterprise compatibility matrix baseline",order:20,phase:"bootstrap-config",blocker:o,summary:"Create the missing compatibility matrix baseline without overwriting user data.",mode:"edit-file",risk:"safe",verifyCommand:r,files:[t.compatibilityMatrix],operation:{type:"file-create",path:t.compatibilityMatrix,content:ce(e.generatedAt),overwrite:false}})),o.includes("profile.enterprise.mirror-config")&&i.push(v({id:"bootstrap.mirror-config",artifactKind:"bootstrap-compliance",cardId:"bootstrap",title:"Create enterprise mirror config baseline",order:30,phase:"bootstrap-config",blocker:o,summary:"Create the missing mirror configuration baseline without enabling mirroring.",mode:"edit-file",risk:"safe",verifyCommand:r,files:[".workspai/mirror-config.json"],operation:{type:"file-create",path:".workspai/mirror-config.json",content:de(e.generatedAt),overwrite:false}}));return i}function fe(e){let i=Array.isArray(e.report.payload.steps)?e.report.payload.steps:[],r=[],o=new Map;for(let t of i){let n=f(t),d=f(n?.command),c=typeof n?.id=="string"?n.id.trim():"",l=typeof n?.project=="string"?n.project.trim():"",p=typeof n?.status=="string"?n.status:"",k=typeof d?.display=="string"?d.display.trim():"",b=n?.required===true;if(!c.startsWith("project.")||!l||!b||p!=="fail"&&p!=="missing"||!/^npx\s+workspai\s+workspace\s+run\s+/i.test(k))continue;let s=c.split(".").at(-1)??"stage",a=`workspaceVerify.${c}`,g=o.get(l),u=/(?:^|\s)--no-gates(?:\s|$)/.test(k)?k:`${k} --no-gates`;r.push(v({id:a,artifactKind:e.report.artifactKind,cardId:e.report.cardId,title:typeof n.label=="string"&&n.label.trim()?n.label.trim():`Run ${s} for ${l}`,order:e.startOrder+r.length,phase:"fleet-run",blocker:typeof n.message=="string"&&n.message.trim()?n.message.trim():`${s} evidence is not current for ${l}.`,summary:`Produce fresh ${s} evidence for ${l} without re-entering the blocked aggregate gates.`,mode:"run-command",risk:s==="start"?"guarded":"safe",status:"ready",command:u,verifyCommand:e.ciMode?"npx workspai workspace verify --strict --json":"npx workspai workspace verify --json",scope:"project",projectName:l,projectPath:l,sourceStepId:c,...g?{dependsOn:[g]}:{},cwd:"workspace",notes:[`Source Workspace Verify step: ${c}`,"Aggregate verification must run only after this project evidence producer completes."]})),o.set(l,a);}return r}var T={python:["python3","python","py"],node:["node"],go:["go"],java:["java"],dotnet:["dotnet"],rust:["cargo"],php:["php"]};async function ge(e,i,r){for(let o of T[e]??[e])if(r?await r(o,i):await a$2({executable:o,cwd:i}))return o}async function ye(e){let i=P(e.blockers.flatMap(o=>{let t=o.match(/(?:project runtimes?|workspace)\s*\(([^)]+)\)\s+(?:is|are) not pinned/i);return t?.[1]?t[1].split(",").map(n=>n.trim().toLowerCase()).filter(n=>/^(python|node|go|java|dotnet|rust|php)$/.test(n)):[]})),r=[];for(let o of i){let t=T[o]??[o],n=await ge(o,e.workspacePath,e.toolAvailable),d=`environment.runtime.${o}`,c=`readiness.toolchain.${o}.setup`,l=e.blockers.find(p=>p.toLowerCase().includes(`(${o})`))??`The ${o} runtime is not pinned in the canonical workspace toolchain.`;n||r.push(v({id:d,artifactKind:e.report.artifactKind,cardId:e.report.cardId,title:`Provide the ${o} host runtime`,order:e.startOrder+r.length,phase:"host-prerequisite",blocker:`No launchable ${o} runtime is available in the current environment.`,summary:`Install or configure ${t.join(" or ")} outside Workspai, then refresh the remediation plan.`,mode:"manual-guidance",risk:"safe",status:"guidance-only",verifyCommand:`npx workspai setup ${o} --json`,requirements:[{kind:"executable",id:`executable:${o}`,status:"missing",executable:t.join("|"),message:`A launchable ${t.join(" or ")} executable must be visible to Workspai.`}],retryPolicy:{sameGeneration:"forbidden",resumeWhen:"environment-changed"},notes:["`workspai setup` detects and pins an existing runtime; it does not install host software."]})),r.push(v({id:c,artifactKind:e.report.artifactKind,cardId:e.report.cardId,title:`Pin ${o} in the workspace toolchain`,order:e.startOrder+r.length,phase:"toolchain-reconciliation",blocker:l,summary:`Detect and persist the current ${o} runtime in the canonical workspace toolchain lock.`,mode:"run-command",risk:"safe",status:n?"ready":"blocked",command:`npx workspai setup ${o} --json`,invocation:U(["setup",o,"--json"]),verifyCommand:e.ciMode?"npx workspai readiness --strict --json":"npx workspai readiness --json",dependsOn:n?void 0:[d],requirements:[{kind:"executable",id:`executable:${o}`,status:n?"satisfied":"missing",executable:n??t.join("|"),message:n?`Runtime prerequisite is launchable: ${n}.`:`Runtime prerequisite is unavailable: ${t.join(" or ")}.`},...n?[]:[{kind:"action",id:`action:${d}`,status:"pending",actionId:d,message:"The host runtime prerequisite must be resolved first."}]],retryPolicy:n?{sameGeneration:"allowed",resumeWhen:"immediate"}:{sameGeneration:"forbidden",resumeWhen:"environment-changed"},notes:["Run from the workspace root so the canonical toolchain.lock is updated."]})),r.push(v({id:`readiness.toolchain.${o}.bootstrap`,artifactKind:e.report.artifactKind,cardId:e.report.cardId,title:`Reconcile the ${o} workspace foundation`,order:e.startOrder+r.length,phase:"toolchain-reconciliation",blocker:`The ${o} runtime pin must be reconciled with the workspace foundation.`,summary:"Refresh the workspace foundation after the runtime pin is written.",mode:"run-command",risk:"guarded",status:n?"ready":"blocked",command:"npx workspai bootstrap --ci --json",invocation:U(["bootstrap","--ci","--json"]),verifyCommand:e.ciMode?"npx workspai readiness --strict --json":"npx workspai readiness --json",dependsOn:[c],requirements:[{kind:"action",id:`action:${c}`,status:"pending",actionId:c,message:`The ${o} toolchain pin must complete first.`}],retryPolicy:{sameGeneration:n?"allowed":"forbidden",resumeWhen:n?"dependencies-complete":"environment-changed"}}));}return r}function be(e){if(e.report.artifactKind==="readiness"&&/dependenc(?:y|ies).*vulnerabil|vulnerabil.*dependenc(?:y|ies)|security audit/i.test(e.blocker))return v({id:`${e.report.cardId}.doctor-owner.${e.order}`,artifactKind:e.report.artifactKind,cardId:e.report.cardId,title:"Resolve dependency vulnerability through Doctor",order:e.order,phase:"dependency-remediation",blocker:e.blocker,summary:"Release Readiness is the aggregate gate; use the project-scoped Doctor remediation capability that owns this dependency failure.",mode:"verify-before-fix",risk:"guarded",status:"review-required",command:"npx workspai doctor workspace --plan --json",verifyCommand:e.ciMode?"npx workspai readiness --strict --json":"npx workspai readiness --json",notes:["Read doctor-remediation-plan-last-run.json and execute the matching surface-security-hygiene capability before rerunning Readiness.","Do not treat a Readiness refresh as remediation for a source dependency vulnerability."]});let r={analyze:{title:"Refresh analyze evidence",phase:"analysis",command:"npx workspai analyze --strict --json",verify:"npx workspai analyze --strict --json"},readiness:{title:"Refresh release readiness",phase:"release-readiness",command:e.ciMode?"npx workspai readiness --strict --json":"npx workspai readiness --json",verify:e.ciMode?"npx workspai readiness --strict --json":"npx workspai readiness --json"},pipeline:{title:"Rerun governance pipeline",phase:"governance-pipeline",command:"npx workspai pipeline --json --strict",verify:"npx workspai pipeline --json --strict"},"workspace-run":{title:"Rerun failed workspace stage",phase:"fleet-run",command:e.ciMode?"npx workspai workspace run test --strict --json":"npx workspai workspace run test --json",verify:e.ciMode?"npx workspai workspace run test --strict --json":"npx workspai workspace run test --json"},"workspace-verify":{title:"Refresh workspace verify gate",phase:"verification",command:e.ciMode?"npx workspai workspace verify --strict --json":"npx workspai workspace verify --json",verify:e.ciMode?"npx workspai workspace verify --strict --json":"npx workspai workspace verify --json"},"doctor-workspace":{title:"Use Doctor remediation plan",phase:"doctor-remediation",command:"npx workspai doctor workspace --plan --json",verify:"npx workspai doctor workspace --json"}}[e.report.artifactKind]??{title:"Refresh artifact evidence",phase:"evidence-refresh",command:"npx workspai pipeline --json --strict",verify:"npx workspai pipeline --json --strict"};return v({id:`${e.report.cardId}.refresh.${e.order}`,artifactKind:e.report.artifactKind,cardId:e.report.cardId,title:r.title,order:e.order,phase:r.phase,blocker:e.blocker,summary:"No deterministic file operation is available for this artifact yet; refresh the evidence and continue with the card-specific plan.",mode:e.report.artifactKind==="doctor-workspace"?"verify-before-fix":"run-command",risk:"guarded",status:e.report.artifactKind==="doctor-workspace"?"review-required":"ready",command:r.command,verifyCommand:r.verify,notes:e.report.artifactKind==="doctor-workspace"?["Read doctor-remediation-plan-last-run.json for ordered file-level steps."]:[]})}function Y(e){let i=e.transaction?.ecosystem.toLowerCase(),r=y.basename(e.invocation?.executable??"").toLowerCase(),o=`${i??""}:${r}`;if(/(^|:)(python|pip|pip3|poetry|uv)(:|$)/.test(o))return "python";if(/(^|:)(node|npm|pnpm|yarn|bun)(:|$)/.test(o))return "node";if(/(^|:)(go)(:|$)/.test(o))return "go";if(/(^|:)(java|maven|mvn|mvnw|gradle|gradlew)(:|$)/.test(o))return "java";if(/(^|:)(dotnet|nuget)(:|$)/.test(o))return "dotnet";if(/(^|:)(rust|cargo|rustc)(:|$)/.test(o))return "rust";if(/(^|:)(php|composer)(:|$)/.test(o))return "php"}function he(e,i){let r=i.invocation?.cwd??e;return y.isAbsolute(r)?r:y.resolve(e,r)}function ke(e,i){let r=Y(e);if(r&&T[r]?.includes(y.basename(i)))return `environment.runtime.${r}`;let o=(e.projectName??"workspace").replace(/[^a-zA-Z0-9.-]+/g,"-"),t=y.basename(i).replace(/[^a-zA-Z0-9.-]+/g,"-");return `environment.executable.${o}.${t}`}async function Ae(e){let i=new Map,r=new Map(e.actions.map(t=>[t.id,t]));for(let t of e.actions){if(!t.invocation||t.status==="guidance-only")continue;let n=he(e.workspacePath,t),d=e.toolAvailable?await e.toolAvailable(t.invocation.executable,n):await a$2({executable:t.invocation.executable,cwd:n}),c={kind:"executable",id:`executable:${t.invocation.executable}`,status:d?"satisfied":"missing",executable:t.invocation.executable,message:d?`Required executable is launchable: ${t.invocation.executable}.`:`Required executable is unavailable: ${t.invocation.executable}.`};if(t.requirements=[...(t.requirements??[]).filter(p=>p.id!==c.id),c],d)continue;let l=ke(t,t.invocation.executable);!r.has(l)&&!i.has(l)&&i.set(l,v({id:l,artifactKind:t.artifactKind,cardId:"environment",title:`Provide ${y.basename(t.invocation.executable)}`,order:0,phase:"host-prerequisite",blocker:`The required executable ${t.invocation.executable} is unavailable.`,summary:"Install or configure the required executable outside Workspai, then refresh the plan.",mode:"manual-guidance",risk:"safe",status:"guidance-only",verifyCommand:t.verifyCommand,scope:t.scope,projectName:t.projectName,projectPath:t.projectPath,requirements:[c],retryPolicy:{sameGeneration:"forbidden",resumeWhen:"environment-changed"},notes:["The CLI does not install host runtimes or system package managers implicitly."]})),t.status="blocked",t.dependsOn=P([...t.dependsOn??[],l]),t.requirements.push({kind:"action",id:`action:${l}`,status:"pending",actionId:l,message:"Resolve the executable prerequisite and generate fresh evidence first."}),t.retryPolicy={sameGeneration:"forbidden",resumeWhen:"environment-changed"},t.notes.push("This action is not eligible in the current plan generation because its executable precondition failed.");}let o=[...i.values(),...e.actions];return o.forEach((t,n)=>{t.order=n+1;}),o}function we(e){let i=new Set(e.map(r=>r.id));for(let r of e){if(!r.transaction)continue;let o=Y(r);if(!o)continue;let t=`readiness.toolchain.${o}.bootstrap`;i.has(t)&&(r.dependsOn=P([...r.dependsOn??[],t]),r.requirements=[...r.requirements??[],{kind:"action",id:`action:${t}`,status:"pending",actionId:t,message:`The canonical ${o} workspace foundation must be reconciled first.`}],r.status==="ready"&&(r.retryPolicy={sameGeneration:"allowed",resumeWhen:"dependencies-complete"}));}}function ve(e){let i=e.filter(t=>t.status==="ready"&&(t.dependsOn?.length??0)===0).map(t=>t.id),r=e.filter(t=>t.status==="blocked").map(t=>t.id),o=e.find(t=>t.status==="guidance-only")?.id??null;return {nextActionId:i[0]??o,eligibleActionIds:i,blockedActionIds:r}}async function Re(e$1){let i=[a(e$1,".workspai/reports"),e(e$1,".workspai/reports")],r=[],o=new Set;for(let t of oe)for(let n of t.fileNames){let d=(await Promise.all(i.map(c=>y.join(c,n)))).find(c=>existsSync(c));if(!(!d||o.has(`${t.artifactKind}:${n}`))){o.add(`${t.artifactKind}:${n}`);try{let c=await ie.readJSON(d),l=f(c);if(!l)continue;r.push({artifactKind:t.artifactKind,cardId:t.cardId,fileName:n,absolutePath:d,payload:l});break}catch{r.push({artifactKind:t.artifactKind,cardId:t.cardId,fileName:n,absolutePath:d,payload:{blockers:[`${t.artifactKind}: report exists but could not be parsed.`]}});break}}}return r}async function Me(e){let i=y.resolve(e.workspacePath),r=e.includeAbsolutePaths===true,o=e.ciMode===true,t=new Date().toISOString(),n=a(i,".workspai/reports"),d=await Re(i),c=[],l=1;for(let s of d){if(s.artifactKind==="doctor-workspace"){let m=Array.isArray(s.payload.steps)?pe({report:s,workspacePath:i,includeAbsolutePaths:r,startOrder:l}):me({report:s,workspacePath:i,includeAbsolutePaths:r,startOrder:l});c.push(...m),l+=m.length;continue}let a=le(s);if(a.length===0)continue;if(s.artifactKind==="bootstrap-compliance"){c.push(...ue({blockers:a,generatedAt:t})),l=c.length+1;continue}if(s.artifactKind==="workspace-verify"){let m=fe({report:s,startOrder:l,ciMode:o});if(m.length>0){c.push(...m),l+=m.length;continue}}if(s.artifactKind==="readiness"){let m=await ye({report:s,blockers:a,startOrder:l,ciMode:o,workspacePath:i,toolAvailable:e.toolAvailable});if(m.length>0){c.push(...m),l+=m.length;continue}}let g=c.some(m=>m.transaction?.kind==="dependency-security"),u=s.artifactKind==="readiness"&&a.some(m=>/dependenc(?:y|ies).*vulnerabil|vulnerabil.*dependenc(?:y|ies)|security audit/i.test(m));if(g&&u)continue;let R=a[0],h=be({report:s,blocker:R,order:l,ciMode:o}),x={readiness:new Set(["bootstrap","doctor"]),pipeline:new Set(["bootstrap","doctor","analyze","readiness"]),workspaceVerify:new Set(["bootstrap","doctor","readiness","workspaceRun"])}[s.cardId];if(s.cardId==="pipeline"){let m=["doctor","analyze","readiness"].find(A=>R.toLowerCase().includes(A));m&&(x=new Set([m]));}if(x){let m=c.filter(A=>x.has(A.cardId)&&A.risk!=="invasive"&&A.status!=="blocked"&&A.status!=="guidance-only").map(A=>A.id);m.length>0&&(h.dependsOn=P([...h.dependsOn??[],...m]),h.notes.push("This aggregate gate must run after its contract-owned upstream remediation actions."));}a.length>1&&h.notes.push(...a.slice(1,8).map(m=>`Related blocker: ${m}`)),c.push(h),l+=1;}we(c);let p=await Ae({actions:c,workspacePath:i,toolAvailable:e.toolAvailable}),k=ve(p),b$1={safe:p.filter(s=>s.risk==="safe").length,guarded:p.filter(s=>s.risk==="guarded").length,invasive:p.filter(s=>s.risk==="invasive").length};return {schemaVersion:a$1,generatedAt:t,workspace:{name:await b(i),...r?{path:i}:{}},source:{command:"workspace remediation-plan",reportsDir:ae(i,n,r),includeAbsolutePaths:r,ciMode:o},summary:{artifactsScanned:d.length,cardsCovered:P(p.map(s=>s.cardId)).length,totalActions:p.length,executableActions:p.filter(s=>s.status==="ready").length,blockedActions:p.filter(s=>s.status==="blocked").length,guidanceActions:p.filter(s=>s.status==="guidance-only").length,risk:b$1},execution:k,actions:p}}async function Ee(e,i){return h(i,t.artifactRemediationPlan,e)}export{Me as a,Ee as b};
|
|
3
|
+
`}function le(e){let i=e.payload,r=w(i.blockers),o=w(i.blockingReasons),t=w(i.failures),n=w(i.reasons),d=w(i.policyViolations),c=f(i.summary),l=w(c?.blockers);if(e.artifactKind==="analyze"){let k=(Array.isArray(i.findings)?i.findings:[]).map(b=>f(b)).filter(b=>!!b).map(b=>String(b.message??b.title??b.id??"").trim()).filter(Boolean);return P([...r,...k,...o])}if(e.artifactKind==="workspace-run"){let p=f(i.stages),k=Object.entries(p??{}).flatMap(([b,s])=>{let a=f(s);return (Array.isArray(a?.projects)?a.projects:[]).map(u=>f(u)).filter(u=>!!u).filter(u=>u.status==="failed"||u.ok===false).map(u=>`${b}: ${String(u.project??u.name??"project")} failed`)});return P([...r,...k,...o])}return P([...r,...o,...t,...n,...d,...l])}function v(e){let i=e.findingId?.trim()||e.sourceStepId?.trim()||e.id,r=e.findingStatus??"blocking",o=e.causalKey?.trim()||[e.cardId,e.projectName??e.scope??"workspace",i].map(t=>String(t).trim().toLowerCase()).join(":");return {id:e.id,artifactKind:e.artifactKind,cardId:e.cardId,title:e.title,order:e.order,phase:e.phase,scope:e.scope??"workspace",...e.projectName?{projectName:e.projectName}:{},...e.projectPath?{projectPath:e.projectPath}:{},...e.sourceStepId?{sourceStepId:e.sourceStepId}:{},findingId:i,findingStatus:r,causalKey:o,...e.dependsOn?{dependsOn:e.dependsOn}:{},...e.strategy?{strategy:structuredClone(e.strategy)}:{},...e.transaction?{transaction:structuredClone(e.transaction)}:{},...e.requirements?{requirements:structuredClone(e.requirements)}:{},...e.retryPolicy?{retryPolicy:structuredClone(e.retryPolicy)}:{},status:e.status??"ready",mode:e.mode,risk:e.risk,requiresApproval:true,blocker:e.blocker,summary:e.summary,...e.command?{command:e.command}:{},...e.invocation?{invocation:structuredClone(e.invocation)}:{},verifyCommand:e.verifyCommand,cwd:e.cwd??"workspace",files:e.files??[],...e.operation?{operation:e.operation}:{},rollback:e.rollback??(e.operation?{available:true,strategy:"idempotent"}:{available:false,strategy:"none"}),notes:e.notes??[]}}function pe(e){return (Array.isArray(e.report.payload.steps)?e.report.payload.steps:[]).flatMap((r,o)=>{let t=f(r),n=typeof t?.id=="string"?t.id.trim():"",d=typeof t?.projectName=="string"?t.projectName.trim():"",c=typeof t?.projectPath=="string"?t.projectPath.trim():"",l=typeof t?.originalCommand=="string"?t.originalCommand.trim():"";if(!t||!n||!d||!c)return [];let p=f(t.studioStatus),k=p?.state==="ready"||p?.state==="review-required"||p?.state==="blocked"||p?.state==="guidance-only"?p.state:"guidance-only",b=t.risk==="safe"||t.risk==="guarded"||t.risk==="invasive"?t.risk:"guarded",s=f(t.preview),a=D({workspacePath:e.workspacePath,projectPath:c,projectName:d,includeAbsolutePaths:e.includeAbsolutePaths}),g=H({capability:{...t,command:l},absoluteProjectPath:c,includeAbsolutePaths:e.includeAbsolutePaths}),u=X({capability:t,absoluteProjectPath:c,includeAbsolutePaths:e.includeAbsolutePaths}),R=E({operation:t.operation,absoluteProjectPath:c}),h=t.findingStatus==="blocking"||t.findingStatus==="advisory"||t.findingStatus==="informational"?t.findingStatus:"unknown",j=typeof t.diagnosisFindingId=="string"&&t.diagnosisFindingId.trim()?t.diagnosisFindingId.trim():typeof t.issueId=="string"&&t.issueId.trim()?t.issueId.trim():n,x=typeof t.causalKey=="string"&&t.causalKey.trim()?t.causalKey.trim():void 0,m=!!g&&(t.executable===true||t.executableInCurrentEnvironment===true),A=Q({strategy:t.strategy,includeAbsolutePaths:e.includeAbsolutePaths}),I=f(t.transaction),C=I?.schemaVersion==="workspai.doctor-dependency-repair-transaction.v1"?structuredClone(I):void 0;return C&&(C.projectPath=a),[v({id:`doctor.${n}`,artifactKind:e.report.artifactKind,cardId:e.report.cardId,title:typeof s?.title=="string"&&s.title.trim()?s.title.trim():`Repair ${d}`,order:e.startOrder+o,phase:typeof t.phase=="string"?t.phase:"doctor-remediation",blocker:typeof s?.summary=="string"&&s.summary.trim()?s.summary.trim():`Doctor remediation is pending for ${d}.`,summary:typeof s?.summary=="string"&&s.summary.trim()?s.summary.trim():`Execute the CLI-authored Doctor step for ${d}.`,mode:m?"run-command":"manual-guidance",risk:b,status:k,...m&&g?{command:g}:{},...m&&u?{invocation:u}:{},...R?{operation:R}:{},verifyCommand:typeof t.verifyCommand=="string"&&t.verifyCommand.trim()?t.verifyCommand.trim():"npx workspai doctor project --json",files:w(t.files).map($=>Z({workspacePath:e.workspacePath,projectPath:c,projectName:d,filePath:$,includeAbsolutePaths:e.includeAbsolutePaths})).filter($=>!!$),notes:[`Source Doctor step: ${n}`,`Doctor finding id: ${j}`,`Doctor finding status: ${h}`,...typeof p?.reason=="string"?[p.reason]:[]],scope:"project",projectName:d,projectPath:a,sourceStepId:n,findingId:j,findingStatus:h,causalKey:x,dependsOn:w(t.dependsOn).map($=>`doctor.${$}`),strategy:A,transaction:C,cwd:"project",...f(t.rollback)?.available===true?{rollback:{available:true,strategy:"manual"}}:{}})]})}function H(e){let i=typeof e.capability.command=="string"?e.capability.command.trim():"";if(e.includeAbsolutePaths&&i)return i;let r=E({operation:e.capability.operation,absoluteProjectPath:e.absoluteProjectPath});if(r)return b$1(r);let o=f(e.capability.invocation),t=typeof o?.executable=="string"?o.executable.trim():"",n=M(t,w(o?.args));if(t)return [t,...n].map(c=>/^[a-zA-Z0-9_./:@=+-]+$/.test(c)?c:JSON.stringify(c)).join(" ");if(!i)return;let d=e.absoluteProjectPath.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return i.replace(new RegExp(`^cd\\s+["']?${d}["']?\\s*&&\\s*`,"i"),"").replaceAll(e.absoluteProjectPath,".")}function X(e){let i=f(e.capability.invocation),r=typeof i?.executable=="string"?i.executable.trim():"",o=w(i?.args);if(!(!r||o.length!==(Array.isArray(i?.args)?i.args.length:0)))return {cwd:e.includeAbsolutePaths?e.absoluteProjectPath:".",executable:r,args:M(r,o)}}function E(e){let i=f(e.operation);if(!i||typeof i.type!="string")return;let r=structuredClone(i);for(let o of ["path","sourcePath"]){let t=r[o];if(typeof t!="string")continue;let n=y.isAbsolute(t)?y.relative(e.absoluteProjectPath,t):t;if(!n||n===".."||n.startsWith(`..${y.sep}`)||y.isAbsolute(n))return;r[o]=n.split(y.sep).join("/");}return r}function Q(e){if(!Array.isArray(e.strategy))return;let i=structuredClone(e.strategy);if(!e.includeAbsolutePaths)for(let r of i)r.invocation&&(r.invocation.cwd=".");return i}function me(e){let i=Array.isArray(e.report.payload.projects)?e.report.payload.projects:e.report.payload.project?[e.report.payload.project]:[],r=new Set,o=[];for(let t of i){let n=f(t);if(!n)continue;let d=typeof n.name=="string"?n.name.trim():"",c=typeof n.path=="string"?n.path.trim():"";if(!d||!c)continue;let l=Array.isArray(n.repairCapabilities)?n.repairCapabilities:Array.isArray(n.probes)?n.probes.map(s=>f(s)?.repairCapability).filter(s=>s!==void 0):[],p=new Map,k=new Map,b=f(n.diagnosis);for(let s of Array.isArray(b?.findings)?b.findings:[]){let a=f(s),g=f(a?.repair),u=typeof g?.capabilityId=="string"?g.capabilityId.trim():"",R=typeof a?.id=="string"?a.id.trim():"",h=typeof a?.causalKey=="string"?a.causalKey.trim():"",j=a?.status==="blocking"||a?.status==="advisory"||a?.status==="informational"||a?.status==="unknown"?a.status:"unknown";u&&R&&h&&k.set(u,{findingId:R,causalKey:h,findingStatus:j});}for(let s of Array.isArray(n.probes)?n.probes:[]){let a=f(s),g=f(a?.repairCapability),u=typeof g?.id=="string"?g.id.trim():"";u&&p.set(u,a?.status==="fail"?"blocking":"advisory");}for(let s of l){let a=f(s),g=typeof a?.id=="string"?a.id.trim():"";if(!a||!g)continue;let u=`${d}:${g}`;if(r.has(u))continue;r.add(u);let R=a.risk==="safe"||a.risk==="guarded"||a.risk==="invasive"?a.risk:"guarded",h=H({capability:a,absoluteProjectPath:c,includeAbsolutePaths:e.includeAbsolutePaths}),j=X({capability:a,absoluteProjectPath:c,includeAbsolutePaths:e.includeAbsolutePaths}),x=E({operation:a.operation,absoluteProjectPath:c}),m=a.status==="available"&&!!h,A=f(a.transaction),I=A?.schemaVersion==="workspai.doctor-dependency-repair-transaction.v1"?structuredClone(A):void 0,C=k.get(g),$=C?.findingStatus??p.get(g)??(I?"blocking":"advisory");I&&(I.projectPath=D({workspacePath:e.workspacePath,projectPath:c,projectName:d,includeAbsolutePaths:e.includeAbsolutePaths}));let ee=Q({strategy:a.strategy,includeAbsolutePaths:e.includeAbsolutePaths}),te=w(a.files).map(S=>Z({workspacePath:e.workspacePath,projectPath:c,projectName:d,filePath:S,includeAbsolutePaths:e.includeAbsolutePaths})).filter(S=>!!S),W=v({id:`doctor.${d}.${g}`,artifactKind:e.report.artifactKind,cardId:e.report.cardId,title:typeof a.title=="string"&&a.title.trim()?a.title.trim():`Repair ${d}`,order:e.startOrder+o.length,phase:I?"dependency-remediation":"doctor-remediation",blocker:typeof a.reason=="string"&&a.reason.trim()?a.reason.trim():`Doctor remediation is pending for ${d}.`,summary:typeof a.reason=="string"&&a.reason.trim()?a.reason.trim():`Execute the Doctor-authored repair capability for ${d}.`,mode:m?a.canEditFiles===true?"edit-file":"run-command":"manual-guidance",risk:R,status:m?"ready":a.status==="manual"?"guidance-only":"blocked",...h?{command:h}:{},...j?{invocation:j}:{},verifyCommand:typeof a.verifyCommand=="string"&&a.verifyCommand.trim()?a.verifyCommand.trim():"npx workspai doctor project --json",files:te,notes:[`Source Doctor capability: ${g}`,`Doctor finding status: ${$}`,...w(a.limitations)],scope:"project",projectName:d,projectPath:D({workspacePath:e.workspacePath,projectPath:c,projectName:d,includeAbsolutePaths:e.includeAbsolutePaths}),sourceStepId:g,findingId:C?.findingId??(typeof a.issueId=="string"&&a.issueId.trim()?a.issueId.trim():g),findingStatus:$,causalKey:C?.causalKey,strategy:ee,transaction:I,cwd:"project",...x?{operation:x,rollback:{available:true,strategy:"manual"}}:{}}),O=h?o.findIndex(S=>S.projectName===d&&S.command===h&&S.cwd==="project"):-1;if(O>=0){o[O]=ne({existing:o[O],incoming:W});continue}o.push(W);}}return o}function ue(e){let i=[],r=se("npx workspai bootstrap --json");for(let o of e.blockers)o.includes("profile.enterprise.ci")&&i.push(v({id:"bootstrap.enterprise-ci",artifactKind:"bootstrap-compliance",cardId:"bootstrap",title:"Run bootstrap in deterministic CI mode",order:10,phase:"bootstrap-preflight",blocker:o,summary:"Enterprise bootstrap compliance requires --ci for deterministic execution.",mode:"run-command",risk:"safe",command:r,verifyCommand:r})),o.includes("profile.enterprise.compatibility-matrix")&&i.push(v({id:"bootstrap.compatibility-matrix",artifactKind:"bootstrap-compliance",cardId:"bootstrap",title:"Create enterprise compatibility matrix baseline",order:20,phase:"bootstrap-config",blocker:o,summary:"Create the missing compatibility matrix baseline without overwriting user data.",mode:"edit-file",risk:"safe",verifyCommand:r,files:[t.compatibilityMatrix],operation:{type:"file-create",path:t.compatibilityMatrix,content:ce(e.generatedAt),overwrite:false}})),o.includes("profile.enterprise.mirror-config")&&i.push(v({id:"bootstrap.mirror-config",artifactKind:"bootstrap-compliance",cardId:"bootstrap",title:"Create enterprise mirror config baseline",order:30,phase:"bootstrap-config",blocker:o,summary:"Create the missing mirror configuration baseline without enabling mirroring.",mode:"edit-file",risk:"safe",verifyCommand:r,files:[".workspai/mirror-config.json"],operation:{type:"file-create",path:".workspai/mirror-config.json",content:de(e.generatedAt),overwrite:false}}));return i}function fe(e){let i=Array.isArray(e.report.payload.steps)?e.report.payload.steps:[],r=[],o=new Map;for(let t of i){let n=f(t),d=f(n?.command),c=typeof n?.id=="string"?n.id.trim():"",l=typeof n?.project=="string"?n.project.trim():"",p=typeof n?.status=="string"?n.status:"",k=typeof d?.display=="string"?d.display.trim():"",b=n?.required===true;if(!c.startsWith("project.")||!l||!b||p!=="fail"&&p!=="missing"||!/^npx\s+workspai\s+workspace\s+run\s+/i.test(k))continue;let s=c.split(".").at(-1)??"stage",a=`workspaceVerify.${c}`,g=o.get(l),u=/(?:^|\s)--no-gates(?:\s|$)/.test(k)?k:`${k} --no-gates`;r.push(v({id:a,artifactKind:e.report.artifactKind,cardId:e.report.cardId,title:typeof n.label=="string"&&n.label.trim()?n.label.trim():`Run ${s} for ${l}`,order:e.startOrder+r.length,phase:"fleet-run",blocker:typeof n.message=="string"&&n.message.trim()?n.message.trim():`${s} evidence is not current for ${l}.`,summary:`Produce fresh ${s} evidence for ${l} without re-entering the blocked aggregate gates.`,mode:"run-command",risk:s==="start"?"guarded":"safe",status:"ready",command:u,verifyCommand:e.ciMode?"npx workspai workspace verify --strict --json":"npx workspai workspace verify --json",scope:"project",projectName:l,projectPath:l,sourceStepId:c,...g?{dependsOn:[g]}:{},cwd:"workspace",notes:[`Source Workspace Verify step: ${c}`,"Aggregate verification must run only after this project evidence producer completes."]})),o.set(l,a);}return r}var T={python:["python3","python","py"],node:["node"],go:["go"],java:["java"],dotnet:["dotnet"],rust:["cargo"],php:["php"]};async function ge(e,i,r){for(let o of T[e]??[e])if(r?await r(o,i):await a$2({executable:o,cwd:i}))return o}async function ye(e){let i=P(e.blockers.flatMap(o=>{let t=o.match(/(?:project runtimes?|workspace)\s*\(([^)]+)\)\s+(?:is|are) not pinned/i);return t?.[1]?t[1].split(",").map(n=>n.trim().toLowerCase()).filter(n=>/^(python|node|go|java|dotnet|rust|php)$/.test(n)):[]})),r=[];for(let o of i){let t=T[o]??[o],n=await ge(o,e.workspacePath,e.toolAvailable),d=`environment.runtime.${o}`,c=`readiness.toolchain.${o}.setup`,l=e.blockers.find(p=>p.toLowerCase().includes(`(${o})`))??`The ${o} runtime is not pinned in the canonical workspace toolchain.`;n||r.push(v({id:d,artifactKind:e.report.artifactKind,cardId:e.report.cardId,title:`Provide the ${o} host runtime`,order:e.startOrder+r.length,phase:"host-prerequisite",blocker:`No launchable ${o} runtime is available in the current environment.`,summary:`Install or configure ${t.join(" or ")} outside Workspai, then refresh the remediation plan.`,mode:"manual-guidance",risk:"safe",status:"guidance-only",verifyCommand:`npx workspai setup ${o} --json`,requirements:[{kind:"executable",id:`executable:${o}`,status:"missing",executable:t.join("|"),message:`A launchable ${t.join(" or ")} executable must be visible to Workspai.`}],retryPolicy:{sameGeneration:"forbidden",resumeWhen:"environment-changed"},notes:["`workspai setup` detects and pins an existing runtime; it does not install host software."]})),r.push(v({id:c,artifactKind:e.report.artifactKind,cardId:e.report.cardId,title:`Pin ${o} in the workspace toolchain`,order:e.startOrder+r.length,phase:"toolchain-reconciliation",blocker:l,summary:`Detect and persist the current ${o} runtime in the canonical workspace toolchain lock.`,mode:"run-command",risk:"safe",status:n?"ready":"blocked",command:`npx workspai setup ${o} --json`,invocation:U(["setup",o,"--json"]),verifyCommand:e.ciMode?"npx workspai readiness --strict --json":"npx workspai readiness --json",dependsOn:n?void 0:[d],requirements:[{kind:"executable",id:`executable:${o}`,status:n?"satisfied":"missing",executable:n??t.join("|"),message:n?`Runtime prerequisite is launchable: ${n}.`:`Runtime prerequisite is unavailable: ${t.join(" or ")}.`},...n?[]:[{kind:"action",id:`action:${d}`,status:"pending",actionId:d,message:"The host runtime prerequisite must be resolved first."}]],retryPolicy:n?{sameGeneration:"allowed",resumeWhen:"immediate"}:{sameGeneration:"forbidden",resumeWhen:"environment-changed"},notes:["Run from the workspace root so the canonical toolchain.lock is updated."]})),r.push(v({id:`readiness.toolchain.${o}.bootstrap`,artifactKind:e.report.artifactKind,cardId:e.report.cardId,title:`Reconcile the ${o} workspace foundation`,order:e.startOrder+r.length,phase:"toolchain-reconciliation",blocker:`The ${o} runtime pin must be reconciled with the workspace foundation.`,summary:"Refresh the workspace foundation after the runtime pin is written.",mode:"run-command",risk:"guarded",status:n?"ready":"blocked",command:"npx workspai bootstrap --ci --json",invocation:U(["bootstrap","--ci","--json"]),verifyCommand:e.ciMode?"npx workspai readiness --strict --json":"npx workspai readiness --json",dependsOn:[c],requirements:[{kind:"action",id:`action:${c}`,status:"pending",actionId:c,message:`The ${o} toolchain pin must complete first.`}],retryPolicy:{sameGeneration:n?"allowed":"forbidden",resumeWhen:n?"dependencies-complete":"environment-changed"}}));}return r}function be(e){if(e.report.artifactKind==="readiness"&&/dependenc(?:y|ies).*vulnerabil|vulnerabil.*dependenc(?:y|ies)|security audit/i.test(e.blocker))return v({id:`${e.report.cardId}.doctor-owner.${e.order}`,artifactKind:e.report.artifactKind,cardId:e.report.cardId,title:"Resolve dependency vulnerability through Doctor",order:e.order,phase:"dependency-remediation",blocker:e.blocker,summary:"Release Readiness is the aggregate gate; use the project-scoped Doctor remediation capability that owns this dependency failure.",mode:"verify-before-fix",risk:"guarded",status:"review-required",command:"npx workspai doctor workspace --plan --json",verifyCommand:e.ciMode?"npx workspai readiness --strict --json":"npx workspai readiness --json",notes:["Read doctor-remediation-plan-last-run.json and execute the matching surface-security-hygiene capability before rerunning Readiness.","Do not treat a Readiness refresh as remediation for a source dependency vulnerability."]});let r={analyze:{title:"Refresh analyze evidence",phase:"analysis",command:"npx workspai analyze --strict --json",verify:"npx workspai analyze --strict --json"},readiness:{title:"Refresh release readiness",phase:"release-readiness",command:e.ciMode?"npx workspai readiness --strict --json":"npx workspai readiness --json",verify:e.ciMode?"npx workspai readiness --strict --json":"npx workspai readiness --json"},pipeline:{title:"Rerun governance pipeline",phase:"governance-pipeline",command:"npx workspai pipeline --json --strict",verify:"npx workspai pipeline --json --strict"},"workspace-run":{title:"Rerun failed workspace stage",phase:"fleet-run",command:e.ciMode?"npx workspai workspace run test --strict --json":"npx workspai workspace run test --json",verify:e.ciMode?"npx workspai workspace run test --strict --json":"npx workspai workspace run test --json"},"workspace-verify":{title:"Refresh workspace verify gate",phase:"verification",command:e.ciMode?"npx workspai workspace verify --strict --json":"npx workspai workspace verify --json",verify:e.ciMode?"npx workspai workspace verify --strict --json":"npx workspai workspace verify --json"},"doctor-workspace":{title:"Use Doctor remediation plan",phase:"doctor-remediation",command:"npx workspai doctor workspace --plan --json",verify:"npx workspai doctor workspace --json"}}[e.report.artifactKind]??{title:"Refresh artifact evidence",phase:"evidence-refresh",command:"npx workspai pipeline --json --strict",verify:"npx workspai pipeline --json --strict"};return v({id:`${e.report.cardId}.refresh.${e.order}`,artifactKind:e.report.artifactKind,cardId:e.report.cardId,title:r.title,order:e.order,phase:r.phase,blocker:e.blocker,summary:"No deterministic file operation is available for this artifact yet; refresh the evidence and continue with the card-specific plan.",mode:e.report.artifactKind==="doctor-workspace"?"verify-before-fix":"run-command",risk:"guarded",status:e.report.artifactKind==="doctor-workspace"?"review-required":"ready",command:r.command,verifyCommand:r.verify,notes:e.report.artifactKind==="doctor-workspace"?["Read doctor-remediation-plan-last-run.json for ordered file-level steps."]:[]})}function Y(e){let i=e.transaction?.ecosystem.toLowerCase(),r=y.basename(e.invocation?.executable??"").toLowerCase(),o=`${i??""}:${r}`;if(/(^|:)(python|pip|pip3|poetry|uv)(:|$)/.test(o))return "python";if(/(^|:)(node|npm|pnpm|yarn|bun)(:|$)/.test(o))return "node";if(/(^|:)(go)(:|$)/.test(o))return "go";if(/(^|:)(java|maven|mvn|mvnw|gradle|gradlew)(:|$)/.test(o))return "java";if(/(^|:)(dotnet|nuget)(:|$)/.test(o))return "dotnet";if(/(^|:)(rust|cargo|rustc)(:|$)/.test(o))return "rust";if(/(^|:)(php|composer)(:|$)/.test(o))return "php"}function he(e,i){let r=i.invocation?.cwd??e;return y.isAbsolute(r)?r:y.resolve(e,r)}function ke(e,i){let r=Y(e);if(r&&T[r]?.includes(y.basename(i)))return `environment.runtime.${r}`;let o=(e.projectName??"workspace").replace(/[^a-zA-Z0-9.-]+/g,"-"),t=y.basename(i).replace(/[^a-zA-Z0-9.-]+/g,"-");return `environment.executable.${o}.${t}`}async function Ae(e){let i=new Map,r=new Map(e.actions.map(t=>[t.id,t]));for(let t of e.actions){if(!t.invocation||t.status==="guidance-only")continue;let n=he(e.workspacePath,t),d=e.toolAvailable?await e.toolAvailable(t.invocation.executable,n):await a$2({executable:t.invocation.executable,cwd:n}),c={kind:"executable",id:`executable:${t.invocation.executable}`,status:d?"satisfied":"missing",executable:t.invocation.executable,message:d?`Required executable is launchable: ${t.invocation.executable}.`:`Required executable is unavailable: ${t.invocation.executable}.`};if(t.requirements=[...(t.requirements??[]).filter(p=>p.id!==c.id),c],d)continue;let l=ke(t,t.invocation.executable);!r.has(l)&&!i.has(l)&&i.set(l,v({id:l,artifactKind:t.artifactKind,cardId:"environment",title:`Provide ${y.basename(t.invocation.executable)}`,order:0,phase:"host-prerequisite",blocker:`The required executable ${t.invocation.executable} is unavailable.`,summary:"Install or configure the required executable outside Workspai, then refresh the plan.",mode:"manual-guidance",risk:"safe",status:"guidance-only",verifyCommand:t.verifyCommand,scope:t.scope,projectName:t.projectName,projectPath:t.projectPath,requirements:[c],retryPolicy:{sameGeneration:"forbidden",resumeWhen:"environment-changed"},notes:["The CLI does not install host runtimes or system package managers implicitly."]})),t.status="blocked",t.dependsOn=P([...t.dependsOn??[],l]),t.requirements.push({kind:"action",id:`action:${l}`,status:"pending",actionId:l,message:"Resolve the executable prerequisite and generate fresh evidence first."}),t.retryPolicy={sameGeneration:"forbidden",resumeWhen:"environment-changed"},t.notes.push("This action is not eligible in the current plan generation because its executable precondition failed.");}let o=[...i.values(),...e.actions];return o.forEach((t,n)=>{t.order=n+1;}),o}function we(e){let i=new Set(e.map(r=>r.id));for(let r of e){if(!r.transaction)continue;let o=Y(r);if(!o)continue;let t=`readiness.toolchain.${o}.bootstrap`;i.has(t)&&(r.dependsOn=P([...r.dependsOn??[],t]),r.requirements=[...r.requirements??[],{kind:"action",id:`action:${t}`,status:"pending",actionId:t,message:`The canonical ${o} workspace foundation must be reconciled first.`}],r.status==="ready"&&(r.retryPolicy={sameGeneration:"allowed",resumeWhen:"dependencies-complete"}));}}function ve(e){let i=e.filter(t=>t.status==="ready"&&(t.dependsOn?.length??0)===0).map(t=>t.id),r=e.filter(t=>t.status==="blocked").map(t=>t.id),o=e.find(t=>t.status==="guidance-only")?.id??null;return {nextActionId:i[0]??o,eligibleActionIds:i,blockedActionIds:r}}async function Re(e$1){let i=[a(e$1,".workspai/reports"),e(e$1,".workspai/reports")],r=[],o=new Set;for(let t of oe)for(let n of t.fileNames){let d=(await Promise.all(i.map(c=>y.join(c,n)))).find(c=>existsSync(c));if(!(!d||o.has(`${t.artifactKind}:${n}`))){o.add(`${t.artifactKind}:${n}`);try{let c=await ie.readJSON(d),l=f(c);if(!l)continue;r.push({artifactKind:t.artifactKind,cardId:t.cardId,fileName:n,absolutePath:d,payload:l});break}catch{r.push({artifactKind:t.artifactKind,cardId:t.cardId,fileName:n,absolutePath:d,payload:{blockers:[`${t.artifactKind}: report exists but could not be parsed.`]}});break}}}return r}async function Me(e){let i=y.resolve(e.workspacePath),r=e.includeAbsolutePaths===true,o=e.ciMode===true,t=new Date().toISOString(),n=a(i,".workspai/reports"),d=await Re(i),c=[],l=1;for(let s of d){if(s.artifactKind==="doctor-workspace"){let m=Array.isArray(s.payload.steps)?pe({report:s,workspacePath:i,includeAbsolutePaths:r,startOrder:l}):me({report:s,workspacePath:i,includeAbsolutePaths:r,startOrder:l});c.push(...m),l+=m.length;continue}let a=le(s);if(a.length===0)continue;if(s.artifactKind==="bootstrap-compliance"){c.push(...ue({blockers:a,generatedAt:t})),l=c.length+1;continue}if(s.artifactKind==="workspace-verify"){let m=fe({report:s,startOrder:l,ciMode:o});if(m.length>0){c.push(...m),l+=m.length;continue}}if(s.artifactKind==="readiness"){let m=await ye({report:s,blockers:a,startOrder:l,ciMode:o,workspacePath:i,toolAvailable:e.toolAvailable});if(m.length>0){c.push(...m),l+=m.length;continue}}let g=c.some(m=>m.transaction?.kind==="dependency-security"),u=s.artifactKind==="readiness"&&a.some(m=>/dependenc(?:y|ies).*vulnerabil|vulnerabil.*dependenc(?:y|ies)|security audit/i.test(m));if(g&&u)continue;let R=a[0],h=be({report:s,blocker:R,order:l,ciMode:o}),x={readiness:new Set(["bootstrap","doctor"]),pipeline:new Set(["bootstrap","doctor","analyze","readiness"]),workspaceVerify:new Set(["bootstrap","doctor","readiness","workspaceRun"])}[s.cardId];if(s.cardId==="pipeline"){let m=["doctor","analyze","readiness"].find(A=>R.toLowerCase().includes(A));m&&(x=new Set([m]));}if(x){let m=c.filter(A=>x.has(A.cardId)&&A.risk!=="invasive"&&A.status!=="blocked"&&A.status!=="guidance-only").map(A=>A.id);m.length>0&&(h.dependsOn=P([...h.dependsOn??[],...m]),h.notes.push("This aggregate gate must run after its contract-owned upstream remediation actions."));}a.length>1&&h.notes.push(...a.slice(1,8).map(m=>`Related blocker: ${m}`)),c.push(h),l+=1;}we(c);let p=await Ae({actions:c,workspacePath:i,toolAvailable:e.toolAvailable}),k=ve(p),b$1={safe:p.filter(s=>s.risk==="safe").length,guarded:p.filter(s=>s.risk==="guarded").length,invasive:p.filter(s=>s.risk==="invasive").length};return {schemaVersion:a$1,generatedAt:t,workspace:{name:await b(i),...r?{path:i}:{}},source:{command:"workspace remediation-plan",reportsDir:ae(i,n,r),includeAbsolutePaths:r,ciMode:o},summary:{artifactsScanned:d.length,cardsCovered:P(p.map(s=>s.cardId)).length,totalActions:p.length,executableActions:p.filter(s=>s.status==="ready").length,blockedActions:p.filter(s=>s.status==="blocked").length,guidanceActions:p.filter(s=>s.status==="guidance-only").length,risk:b$1},execution:k,actions:p}}async function Ee(e,i){return h(i,t.artifactRemediationPlan,e)}export{Me as a,Ee as b};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import {a as a$1}from'./chunk-A5FBGRJA.js';import {g as g$1,p}from'./chunk-
|
|
1
|
+
import {a as a$1}from'./chunk-A5FBGRJA.js';import {g as g$1,p}from'./chunk-YLLCZMKP.js';import {g,h}from'./chunk-BLEIUQL6.js';import {y,w as w$1}from'./chunk-6BO4QHKA.js';import {t as t$1}from'./chunk-VQZ5PI5J.js';import {t,s}from'./chunk-ODK4LCEL.js';import a from'path';import {existsSync}from'fs';import m from'fs-extra';var f=t.workspaceRegistry,w=s.workspaceRegistry.schemaVersion;function E(r){return {slug:r.slug,relativePath:r.relativePath,framework:r.framework,kit:r.kit,source:r.source}}async function b(r){let e=t$1(r,"workspace.json").find(t=>existsSync(t));if(!e)return {exists:false,legacyProjectCount:0};try{let t=await m.readJson(e),c=Array.isArray(t.projects)?t.projects.length:0,o=typeof t.workspace_name=="string"&&t.workspace_name.trim()||typeof t.name=="string"&&t.name.trim()||a.basename(r);return {exists:true,manifestPath:e,workspaceName:o,profile:typeof t.profile=="string"?t.profile:void 0,legacyProjectCount:c}}catch{return {exists:true,manifestPath:e,legacyProjectCount:0,workspaceName:a.basename(r)}}}async function _(r){let e=a$1(r);for(let t of y())if(await m.pathExists(t))try{let o=((await m.readJson(t)).workspaces||[]).find(s=>a$1(s.path)===e);if(o)return {exists:true,projectCount:Array.isArray(o.projects)?o.projects.length:0,registryPath:t}}catch{continue}return {exists:false,projectCount:0,registryPath:a.join(w$1(),"workspaces.json")}}async function T(r,e){let t=a.resolve(r),c=await g(t,g$1),o=await b(t),s=await _(t),i=e?.contract!==void 0||!!c,n=[];if(e?.contract)n=e.contract.projects||[];else if(i)try{let{contract:A}=await p({workspacePath:t});n=A.projects||[];}catch{n=[];}let d={contract:{exists:i,projectCount:n.length,path:g$1},globalRegistry:{exists:s.exists,projectCount:s.projectCount,path:s.registryPath},legacyWorkspaceJson:{exists:o.exists,projectCount:o.legacyProjectCount,path:o.manifestPath?a.relative(t,o.manifestPath):void 0}},p$1="none",u=[],y=0;return i?(p$1="workspace.contract.json",u=n.map(E),y=u.length):s.projectCount>0?(p$1="global-registry",y=s.projectCount):o.legacyProjectCount>0&&(p$1="legacy-workspace.json",y=o.legacyProjectCount),{contractExists:i,summary:{schemaVersion:w,kind:"rapidkit.workspace.registry",workspacePath:t,workspaceName:o.workspaceName||a.basename(t),profile:o.profile,projectCount:y,authority:p$1,contractPath:g$1,projects:u,sources:d}}}async function U(r){let e=await g(r,f);if(!e)return null;try{let t=await m.readJson(e);return t?.schemaVersion!==w?null:t}catch{return null}}async function D(r,e){let t=await M(r,e);return await h(r,f,t),t}async function M(r,e){return {...(await T(r,{contract:e?.contract})).summary,generatedAt:(e?.now??new Date).toISOString(),registrySummaryPath:f}}function F(r,e=""){return r.projectCount>0?r.authority==="workspace.contract.json"?`${r.projectCount} project(s) registered in workspace contract${e}.`:r.authority==="global-registry"?`${r.projectCount} project(s) registered in global workspace registry${e}.`:`${r.projectCount} project(s) registered in legacy workspace manifest${e}.`:`Workspace state exists, but no projects are registered yet${e}.`}export{f as a,w as b,T as c,U as d,D as e,M as f,F as g};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {a as a$1}from'./chunk-XWKGZRHN.js';import {m,k,j as j$1,b,t,
|
|
1
|
+
import {a as a$1}from'./chunk-XWKGZRHN.js';import {m,k,j as j$1,b,z,t,i}from'./chunk-6BO4QHKA.js';import {a}from'./chunk-2FIX2MDC.js';import {c,d}from'./chunk-VQZ5PI5J.js';import Et from'crypto';import nt from'os';import l from'path';import*as p from'fs-extra';import {execa}from'execa';var vt=["version","project","create","add","list","info","upgrade","diff","doctor","license","commands","reconcile","rollback","uninstall","checkpoint","optimize","snapshot","frameworks","modules","merge"],B=new Set(vt);var y=a();async function it(t){for(let e of [c,d]){let n=l.join(t,e);if(await p.pathExists(n))try{let r=await p.readJson(n);if(r&&typeof r=="object")return r}catch{return null}}return null}function j(){let t=[],e=i=>{let o=i?.trim();o&&t.push(o);};e(process.env.RAPIDKIT_BRIDGE_PYTHON),e(process.env.RAPIDKIT_PYTHON_CMD),e(process.env.POETRY_PYTHON);let n=x();(n.startsWith("/")||n.startsWith(".")||n.startsWith(".."))&&!n.startsWith("file:")&&e(m(l.join(l.resolve(n),".venv")));for(let i of k())i.args.length===1&&i.args[0]==="--version"&&e(i.command);for(let i of j$1())e(i);return [...new Set(t)]}function w(t,e){return t==="py"?["-3",...e]:e}function Z(t){if(!t)return t;let e=["Installed Poetry version does not support '--no-update'. Falling back to 'poetry lock'."];return t.split(/\r?\n/).filter(i=>!e.some(o=>i.includes(o))).join(`
|
|
2
2
|
`)}var h=class extends Error{code;constructor(e,n){super(n),this.code=e;}};function O(t){if(t instanceof h)switch(t.code){case "PYTHON_NOT_FOUND":return `Workspai could not find Python (python3/python/py) on your PATH.
|
|
3
3
|
Install Python 3.10+ and ensure \`${i()}\` is available, then retry.
|
|
4
4
|
Tip: if you are inside a RapidKit project, use the local ./rapidkit launcher.`;case "BRIDGE_VENV_CREATE_FAILED":return `Workspai failed to create its bridge virtual environment.
|
|
@@ -15,10 +15,10 @@ Details: ${t.message}`;case "BRIDGE_VENV_LOCK_FAILED":return `Workspai could not
|
|
|
15
15
|
Another Workspai process may still be preparing the environment; retry after it completes.
|
|
16
16
|
Details: ${t.message}`;case "BRIDGE_VENV_HEALTH_FAILED":return `Workspai created the Python bridge environment, but its Core runtime health check failed.
|
|
17
17
|
The incomplete bridge was discarded so the next run can rebuild it safely.
|
|
18
|
-
Details: ${t.message}`;default:return `Workspai bridge error: ${t.message}`}return `Workspai failed to run the Python core engine: ${t instanceof Error?t.message:String(t)}`}function x(){let t=process.env.RAPIDKIT_CORE_PYTHON_PACKAGE;return t&&t.trim()?t.trim():"rapidkit-core"}function Pt(){let t=x(),e=process.env.RAPIDKIT_CORE_PYTHON_PACKAGE_ID,n=e&&e.trim()?`${t}|${e.trim()}`:t;return Et.createHash("sha256").update(n).digest("hex").slice(0,12)}function T(){let t=process.env.XDG_CACHE_HOME;return t&&t.trim()?t:l.join(nt.homedir(),".cache")}function Ct(){return l.join(T(),"rapidkit","npm-bridge","venv")}function K(){let t=Pt();return l.join(T(),"rapidkit","npm-bridge",`venv-${t}`)}function M(t){return m(t)}function L(t){return
|
|
18
|
+
Details: ${t.message}`;default:return `Workspai bridge error: ${t.message}`}return `Workspai failed to run the Python core engine: ${t instanceof Error?t.message:String(t)}`}function x(){let t=process.env.RAPIDKIT_CORE_PYTHON_PACKAGE;return t&&t.trim()?t.trim():"rapidkit-core"}function Pt(){let t=x(),e=process.env.RAPIDKIT_CORE_PYTHON_PACKAGE_ID,n=e&&e.trim()?`${t}|${e.trim()}`:t;return Et.createHash("sha256").update(n).digest("hex").slice(0,12)}function T(){let t=process.env.XDG_CACHE_HOME;return t&&t.trim()?t:l.join(nt.homedir(),".cache")}function Ct(){return l.join(T(),"rapidkit","npm-bridge","venv")}function K(){let t=Pt();return l.join(T(),"rapidkit","npm-bridge",`venv-${t}`)}function M(t){return m(t)}function L(t$1){return t(t$1)}async function F(t){let e=[],n=L(t);await p.pathExists(n)&&e.push({cmd:n,args:["--version","--json"]}),e.push({cmd:M(t),args:["-m","rapidkit","--version","--json"]});let r=[];for(let i of e)try{let o=await execa(i.cmd,i.args,{reject:false,stdio:"pipe",timeout:3e4});if(o.exitCode===0&&await _(o.stdout))return {healthy:true,details:""};let c=[o.stdout,o.stderr].map(s=>(s??"").toString().trim()).filter(Boolean).join(`
|
|
19
19
|
`);r.push(c||`${i.cmd} exited with ${String(o.exitCode)}`);}catch(o){r.push(o instanceof Error?o.message:String(o));}return {healthy:false,details:r.join(`
|
|
20
|
-
`)}}async function ot(t
|
|
21
|
-
`);};try{n("probing interpreter-specific rapidkit script");let i=((await execa(t,w(t,["-c","import sysconfig, os; print(os.path.join(sysconfig.get_path('scripts'), 'rapidkit'))"]),{reject:false,stdio:"pipe",timeout:2e3})).stdout??"").toString().trim();if(n(`script path: ${i}`),i)try{if(await p.pathExists(i)){n(`found script at ${i}; invoking --version --json`);let o=await execa(i,["--version","--json"],{reject:false,stdio:"pipe",timeout:4e3});if(n(`script exitCode=${o.exitCode}`),o.exitCode===0){let c=(o.stdout??"").toString().trim();try{let s=JSON.parse(c),a=!!s&&typeof s=="object"&&s!==null&&"version"in s;if(n(`script JSON parse ok=${a}`),a)return true}catch{n("script output not valid JSON");}}}}catch(o){n(`interpreter-specific script probe failed: ${String(o)}`);}}catch(r){n(`interpreter-specific script probe error: ${String(r)}`);}try{n('probing importlib.find_spec("rapidkit")');let r=await execa(t,w(t,["-c","import importlib.util; print(1 if importlib.util.find_spec('rapidkit') else 0)"]),{reject:false,stdio:"pipe",timeout:2e3});if(n(`import probe exitCode=${r.exitCode} stdout=${(r.stdout??"").toString().trim()}`),r.exitCode===0&&(r.stdout??"").toString().trim()==="1")return true}catch(r){n(`import probe error: ${String(r)}`);}try{n("probing python -m rapidkit");let r=await execa(t,w(t,["-m","rapidkit","--version","--json"]),{reject:false,stdio:"pipe",timeout:8e3});if(n(`-m probe exitCode=${r.exitCode}`),r.exitCode===0)return true}catch(r){n(`-m probe error: ${String(r)}`);}try{n("probing PATH for rapidkit executables");let r=(process.env.PATH??"").split(l.delimiter).filter(Boolean);for(let i of r){let o=l.join(i,b()?"rapidkit.exe":"rapidkit");try{if(await p.pathExists(o)){n(`found candidate on PATH: ${o}; invoking --version --json`);let c=await execa(o,["--version","--json"],{reject:false,stdio:"pipe",timeout:4e3});if(n(`candidate exitCode=${c.exitCode}`),c.exitCode===0){let s=(c.stdout??"").toString().trim();try{let a=JSON.parse(s),d=a;if(a&&typeof a=="object"&&a!==null&&"version"in d&&d.schema_version===1)return true}catch{n("candidate output not valid JSON, skipping");}}}}catch(c){n(`error probing candidate ${o}: ${String(c)}`);}}return n("no valid rapidkit found on PATH"),false}catch(r){return n(`PATH probe error: ${String(r)}`),false}}async function _(t,e){let n=(t??"").toString().trim();if(!n)return false;try{let r=JSON.parse(n);if(!r||typeof r!="object"||r===null)return false;let i=r;return "version"in i?e?.requireSchema?i.schema_version===1||i.schemaVersion==="rapidkit-core-version-v1":true:false}catch{return false}}async function ut(t,e=process.platform){let n
|
|
20
|
+
`)}}async function ot(t=process.platform,e=process.env){let n=b(t)?["rapidkit.exe","rapidkit.cmd"]:["rapidkit"],r=z(e,t).flatMap(i=>n.map(o=>l.join(i,o)));for(let i of [...new Set(r)])try{if(!await p.pathExists(i))continue;let o=await execa(i,["--version","--json"],{reject:false,stdio:"pipe",timeout:4e3});if(o.exitCode===0&&await _(o.stdout))return {cmd:i,baseArgs:[]}}catch{}return null}async function st(t=process.platform,e=process.env){let n=b(t)?"rapidkit.exe":"rapidkit",r=(e.PATH??"").split(l.delimiter).filter(Boolean);for(let i of r){let o=l.join(i,n);try{if(!await p.pathExists(o))continue;let c=await execa(o,["--version","--json"],{reject:false,stdio:"pipe",timeout:4e3});if(c.exitCode===0&&await _(c.stdout,{requireSchema:true}))return {cmd:o,baseArgs:[]}}catch{}}return null}function at(t){return /[<>=!~]=|@|\.whl$|\.tar\.gz$|\.zip$|git\+|https?:\/\//.test(t)}function _t(t){return l.dirname(l.dirname(t))}function ct(){return l.join(T(),"rapidkit","npm-bridge","core-commands.json")}async function dt(t){let e=!!process.env.RAPIDKIT_DEBUG,n=r=>{e&&process.stderr.write(`[DEBUG] tryRapidkit(${t}): ${r}
|
|
21
|
+
`);};try{n("probing interpreter-specific rapidkit script");let i=((await execa(t,w(t,["-c","import sysconfig, os; print(os.path.join(sysconfig.get_path('scripts'), 'rapidkit'))"]),{reject:false,stdio:"pipe",timeout:2e3})).stdout??"").toString().trim();if(n(`script path: ${i}`),i)try{if(await p.pathExists(i)){n(`found script at ${i}; invoking --version --json`);let o=await execa(i,["--version","--json"],{reject:false,stdio:"pipe",timeout:4e3});if(n(`script exitCode=${o.exitCode}`),o.exitCode===0){let c=(o.stdout??"").toString().trim();try{let s=JSON.parse(c),a=!!s&&typeof s=="object"&&s!==null&&"version"in s;if(n(`script JSON parse ok=${a}`),a)return true}catch{n("script output not valid JSON");}}}}catch(o){n(`interpreter-specific script probe failed: ${String(o)}`);}}catch(r){n(`interpreter-specific script probe error: ${String(r)}`);}try{n('probing importlib.find_spec("rapidkit")');let r=await execa(t,w(t,["-c","import importlib.util; print(1 if importlib.util.find_spec('rapidkit') else 0)"]),{reject:false,stdio:"pipe",timeout:2e3});if(n(`import probe exitCode=${r.exitCode} stdout=${(r.stdout??"").toString().trim()}`),r.exitCode===0&&(r.stdout??"").toString().trim()==="1")return true}catch(r){n(`import probe error: ${String(r)}`);}try{n("probing python -m rapidkit");let r=await execa(t,w(t,["-m","rapidkit","--version","--json"]),{reject:false,stdio:"pipe",timeout:8e3});if(n(`-m probe exitCode=${r.exitCode}`),r.exitCode===0)return true}catch(r){n(`-m probe error: ${String(r)}`);}try{n("probing PATH for rapidkit executables");let r=(process.env.PATH??"").split(l.delimiter).filter(Boolean);for(let i of r){let o=l.join(i,b()?"rapidkit.exe":"rapidkit");try{if(await p.pathExists(o)){n(`found candidate on PATH: ${o}; invoking --version --json`);let c=await execa(o,["--version","--json"],{reject:false,stdio:"pipe",timeout:4e3});if(n(`candidate exitCode=${c.exitCode}`),c.exitCode===0){let s=(c.stdout??"").toString().trim();try{let a=JSON.parse(s),d=a;if(a&&typeof a=="object"&&a!==null&&"version"in d&&d.schema_version===1)return true}catch{n("candidate output not valid JSON, skipping");}}}}catch(c){n(`error probing candidate ${o}: ${String(c)}`);}}return n("no valid rapidkit found on PATH"),false}catch(r){return n(`PATH probe error: ${String(r)}`),false}}async function _(t,e){let n=(t??"").toString().trim();if(!n)return false;try{let r=JSON.parse(n);if(!r||typeof r!="object"||r===null)return false;let i=r;return "version"in i?e?.requireSchema?i.schema_version===1||i.schemaVersion==="rapidkit-core-version-v1":true:false}catch{return false}}async function ut(t$1,e=process.platform){let n=async o=>{try{let a=(await it(o))?.metadata?.python?.venvPath;return typeof a!="string"||!a.trim()?null:l.isAbsolute(a)?a:l.join(o,a)}catch{return null}},r=async(o,c)=>{let s=t(c,e);if(await p.pathExists(s)){let d=await execa(s,["--version","--json"],{reject:false,stdio:"pipe",timeout:1500,cwd:o});if(d.exitCode===0&&await _(d.stdout))return {cmd:s,baseArgs:[],workspaceDir:o}}let a=m(c,e);if(await p.pathExists(a)){let d=await execa(a,["-m","rapidkit","--version","--json"],{reject:false,stdio:"pipe",timeout:1500,cwd:o});if(d.exitCode===0&&await _(d.stdout))return {cmd:a,baseArgs:["-m","rapidkit"],workspaceDir:o}}return null},i=t$1;for(let o=0;o<25;o+=1){let c=await n(i),s=[l.join(i,".venv"),c].filter(d=>!!d);for(let d of [...new Set(s)]){let E=await r(i,d);if(E)return E}let a=l.dirname(i);if(a===i)break;i=a;}return null}async function kt(t){try{let e=l.join(t,".python-version");if(await p.pathExists(e)){let r=(await p.readFile(e,"utf-8")).trim();if(r)return r}}catch{}try{let e=await it(t);if(typeof e?.pythonVersion=="string"&&e.pythonVersion.trim())return e.pythonVersion.trim();let r=e?.metadata?.python?.pythonVersion;if(typeof r=="string"&&r.trim())return r.trim()}catch{}return null}async function H(t){if(t&&t.trim())try{let s=await ut(t);if(s){let a=s.workspaceDir??(l.dirname(s.cmd).includes(".venv")?l.dirname(l.dirname(l.dirname(s.cmd))):l.dirname(s.cmd)),d=await kt(a);return d&&(process.env.PYENV_VERSION=d),s}}catch{}let e=await Ot();if(e.kind==="venv"){let s=_t(e.pythonPath),a=L(s);return await p.pathExists(a)?{cmd:a,baseArgs:[]}:{cmd:e.pythonPath,baseArgs:["-m","rapidkit"]}}try{if((await execa(e.cmd,["-m","rapidkit","--version","--json"],{reject:false,stdio:"pipe",timeout:4e3})).exitCode===0)return {cmd:e.cmd,baseArgs:["-m","rapidkit"]}}catch{}try{let a=((await execa(e.cmd,["-c","import sysconfig, os; print(os.path.join(sysconfig.get_path('scripts'), 'rapidkit'))"],{reject:false,stdio:"pipe",timeout:2e3})).stdout??"").toString().trim();if(a&&await p.pathExists(a))try{let d=await execa(a,["--version","--json"],{reject:false,stdio:"pipe",timeout:4e3});if(d.exitCode===0&&await _(d.stdout))return {cmd:a,baseArgs:[]}}catch{}}catch{}let n=await ot();if(n)return n;let r=await st();if(r)return r;let i=K(),o=await N(e.cmd),c=L(i);return await p.pathExists(c)?{cmd:c,baseArgs:[]}:{cmd:o,baseArgs:["-m","rapidkit"]}}async function pt(){for(let t of j())try{if((await execa(t,w(t,["--version"]),{reject:false,stdio:"pipe",timeout:2e3})).exitCode===0)return t}catch{}return null}async function G(){let t=null,e=false;for(let n of j()){try{if((await execa(n,w(n,["--version"]),{reject:false,stdio:"pipe",timeout:2e3})).exitCode!==0)continue;e=true;}catch{continue}try{return await N(n)}catch(r){t=r;continue}}throw e?t instanceof h?t:t instanceof Error?new h("BRIDGE_VENV_BOOTSTRAP_FAILED",t.message):new h("BRIDGE_VENV_BOOTSTRAP_FAILED","Python was detected, but the Workspai bridge environment could not be created."):new h("PYTHON_NOT_FOUND","No Python interpreter found (python3/python/py).")}async function xt(){let t=!!process.env.RAPIDKIT_DEBUG,e=r=>{t&&process.stderr.write(`[DEBUG] checkRapidkitCore: ${r}
|
|
22
22
|
`);},n=Array.from(new Set([...j$1(),...k(14,10).map(r=>r.command)]));for(let r of n)try{e(`Method 1: trying ${r} import`);let i=await execa(r,w(r,["-c","import rapidkit_core; print(1)"]),{reject:false,stdio:"pipe",timeout:y});if(i.exitCode===0&&i.stdout?.trim()==="1")return e(`\u2713 Found via ${r} import`),true}catch{continue}for(let r of n)try{e(`Method 2: trying ${r} -m pip show`);let i=await execa(r,w(r,["-m","pip","show","rapidkit-core"]),{reject:false,stdio:"pipe",timeout:y});if(i.exitCode===0&&i.stdout?.includes("Name: rapidkit-core"))return e(`\u2713 Found via ${r} -m pip show`),true}catch{continue}for(let r of ["pip","pip3"])try{e(`Method 3: trying ${r} show`);let i=await execa(r,["show","rapidkit-core"],{reject:false,stdio:"pipe",timeout:y});if(i.exitCode===0&&i.stdout?.includes("Name: rapidkit-core"))return e(`\u2713 Found via ${r} show`),true}catch{continue}try{e("Method 4: checking pyenv versions");let r=await execa("pyenv",["versions","--bare"],{reject:false,stdio:"pipe",timeout:y});if(r.exitCode===0&&r.stdout){let i=r.stdout.split(`
|
|
23
23
|
`).filter(o=>o.trim());e(`Found pyenv versions: ${i.join(", ")}`);for(let o of i){let c=process.env.PYENV_ROOT||l.join(nt.homedir(),".pyenv"),s=l.join(c,"versions",o.trim(),"bin","pip");try{let a=await execa(s,["show","rapidkit-core"],{reject:false,stdio:"pipe",timeout:y});if(a.exitCode===0&&a.stdout?.includes("Name: rapidkit-core"))return e(`\u2713 Found in pyenv ${o}`),true}catch{try{let a=await execa("pyenv",["exec","pip","show","rapidkit-core"],{reject:false,stdio:"pipe",timeout:y,env:{...process.env,PYENV_VERSION:o.trim()}});if(a.exitCode===0&&a.stdout?.includes("Name: rapidkit-core"))return e(`\u2713 Found in pyenv ${o} via PYENV_VERSION`),true}catch{continue}}}}}catch{e("pyenv not available");}for(let r of n)try{e(`Method 5: checking ${r} user site`);let i=await execa(r,w(r,["-m","site","--user-site"]),{reject:false,stdio:"pipe",timeout:y});if(i.exitCode===0&&i.stdout){let o=i.stdout.trim(),c=l.join(o,"rapidkit_core");if(await p.pathExists(c))return e("\u2713 Found in user site-packages"),true}}catch{continue}try{e("Method 6: checking pipx");let r=await execa("pipx",["list"],{reject:false,stdio:"pipe",timeout:y});if(r.exitCode===0&&r.stdout?.includes("rapidkit-core"))return e("\u2713 Found via pipx"),true}catch{e("pipx not available");}for(let r of n)try{e(`Method 6: checking ${r} -m pipx list`);let i=await execa(r,w(r,["-m","pipx","list"]),{reject:false,stdio:"pipe",timeout:y});if(i.exitCode===0&&i.stdout?.includes("rapidkit-core"))return e(`\u2713 Found via ${r} -m pipx list`),true}catch{continue}try{if(e("Method 7: checking poetry"),(await execa("poetry",["show","rapidkit-core"],{reject:false,stdio:"pipe",timeout:y})).exitCode===0)return e("\u2713 Found via poetry"),true}catch{e("poetry check failed");}for(let r of n)try{if(e(`Method 7: checking ${r} -m poetry show rapidkit-core`),(await execa(r,w(r,["-m","poetry","show","rapidkit-core"]),{reject:false,stdio:"pipe",timeout:y})).exitCode===0)return e(`\u2713 Found via ${r} -m poetry`),true}catch{continue}try{e("Method 8: checking conda");let r=await execa("conda",["list","rapidkit-core"],{reject:false,stdio:"pipe",timeout:y});if(r.exitCode===0&&r.stdout?.includes("rapidkit-core"))return e("\u2713 Found via conda"),true}catch{e("conda not available");}return e("\u2717 Not found in any environment"),false}function Rt(t){let e=t.trim();if(!e||!e.startsWith("rapidkit-core"))return null;let n=e.slice(13).trim();return !n||/[\/@]|\.whl$|\.tar\.gz$|\.zip$|git\+|https?:\/\//.test(n)?null:n}function X(t){let e=t.trim();if(!e)return null;let n=e.split("."),r=[];for(let i of n){let o=i.match(/^(\d+)/);if(!o){r.push(0);continue}r.push(Number.parseInt(o[1],10));}return r}function Q(t,e){let n=Math.max(t.length,e.length);for(let r=0;r<n;r+=1){let i=r<t.length?t[r]:0,o=r<e.length?e[r]:0;if(i>o)return 1;if(i<o)return -1}return 0}function bt(t){return t.length<=1?[t[0]+1]:t.length===2?[t[0]+1,0]:[t[0],t[1]+1,0]}function At(t){let e=t.split(",").map(r=>r.trim()).filter(Boolean);if(e.length===0)return null;let n=[];for(let r of e){let i=r.match(/^(==|>=|<=|>|<|~=)\s*([0-9][0-9A-Za-z+._-]*)$/);if(!i)return null;n.push({op:i[1],version:i[2]});}return n}function lt(t,e){let n=X(t);if(!n)return false;let r=At(e);if(!r)return false;for(let i of r){let o=X(i.version);if(!o)return false;let c=Q(n,o);if(i.op==="=="&&c!==0||i.op===">="&&c<0||i.op==="<="&&c>0||i.op===">"&&c<=0||i.op==="<"&&c>=0)return false;if(i.op==="~="){if(c<0)return false;let s=bt(o);if(Q(n,s)>=0)return false}}return true}async function It(){let t=Array.from(new Set([...j$1(),...k(14,10).map(n=>n.command)])),e=n=>{let r=n.match(/^Version:\s*(.+)$/m);return r?r[1].trim():null};for(let n of t)try{let r=await execa(n,w(n,["-m","pip","show","rapidkit-core"]),{reject:false,stdio:"pipe",timeout:y});if(r.exitCode===0){let i=e(r.stdout||"");if(i)return i}}catch{continue}for(let n of ["pip","pip3"])try{let r=await execa(n,["show","rapidkit-core"],{reject:false,stdio:"pipe",timeout:y});if(r.exitCode===0){let i=e(r.stdout||"");if(i)return i}}catch{continue}try{let n=await execa("pipx",["list"],{reject:false,stdio:"pipe",timeout:y});if(n.exitCode===0&&n.stdout){let r=n.stdout.match(/rapidkit-core\s+([0-9][0-9A-Za-z+._-]*)/i);if(r?.[1])return r[1]}}catch{}return null}async function Dt(){let t=x(),e=Rt(t);if(!e)return {isCompatible:false,installedVersion:null,expectedConstraint:null,reason:at(t)?"constraint-unsupported":"constraint-missing"};let n=await It();if(!n)return {isCompatible:false,installedVersion:null,expectedConstraint:e,reason:"version-not-detected"};let r=lt(n,e);return {isCompatible:r,installedVersion:n,expectedConstraint:e,reason:r?"compatible":"incompatible-version"}}async function N(t){let e=K(),n=Math.max(6e4,Number(process.env.RAPIDKIT_BRIDGE_LOCK_TIMEOUT_MS??10*6e4)),r=Math.max(n+6e4,Number(process.env.RAPIDKIT_BRIDGE_LOCK_STALE_MS??15*6e4));try{return await a$1(`${e}.lock`,()=>St(t),{timeoutMs:n,staleMs:r,purpose:"python-core-bridge-bootstrap"})}catch(i){if(i instanceof h)throw i;let o=i instanceof Error?i.message:String(i);throw new h("BRIDGE_VENV_LOCK_FAILED",o)}}async function St(t){let e=K(),n=Ct(),r=x(),i=[e];!at(r)&&!await p.pathExists(e)&&await p.pathExists(n)&&i.push(n);for(let m of i){let g=M(m);if(await p.pathExists(g))try{if((await F(m)).healthy)return g;await p.remove(m);}catch{await p.remove(m);}}let o=e,c={...process.env,PIP_DISABLE_PIP_VERSION_CHECK:"1"},s=Math.max(0,Number(process.env.RAPIDKIT_BRIDGE_PIP_RETRY??"2")),a=Math.max(200,Number(process.env.RAPIDKIT_BRIDGE_PIP_RETRY_DELAY_MS??"800")),d=Math.max(1e4,Number(process.env.RAPIDKIT_BRIDGE_PIP_TIMEOUT_MS??"120000")),E=m=>new Promise(g=>setTimeout(g,m)),k=async(m,g,P)=>{let f=await execa(m,g,{reject:false,stdio:["ignore","pipe","inherit"],env:c,timeout:P});if(f.exitCode===0)return;let v=(f.stdout??"").toString(),V=(f.stderr??"").toString(),A=[v,V].filter(Boolean).join(`
|
|
24
24
|
`),gt=A?`${m} ${g.join(" ")}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import {a as a$2}from'./chunk-WPPRUFJW.js';import {j,l as l$1}from'./chunk-AICCXYY5.js';import {g}from'./chunk-6KMR5PKQ.js';import {a as a$1}from'./chunk-4VSQNSGH.js';import {v}from'./chunk-566NQQTJ.js';import {j as j$1,e}from'./chunk-RU3UT7GJ.js';import {b,c as c$1}from'./chunk-RTD5D35M.js';import {c,d}from'./chunk-NGZF4YJS.js';import {a}from'./chunk-COICGD62.js';import {f as f$1,g as g$1,h as h$2}from'./chunk-5EEXLM45.js';import {k,l,h as h$1,m,n,p as p$1,q as q$1}from'./chunk-2CT5SN2L.js';import {a as a$3}from'./chunk-25V5XMWB.js';import {o as o$1,r as r$1,u}from'./chunk-FU6SQ2ND.js';import {o,r as r$2,s}from'./chunk-M6DVNC6X.js';import {f,h}from'./chunk-BLEIUQL6.js';import {b as b$1}from'./chunk-VN2MKTQO.js';import {c as c$2}from'./chunk-6B7L4NZE.js';import {p,q,z,A,y,x}from'./chunk-ODK4LCEL.js';import ge from'path';import pe from'fs-extra';function r(t,s){if(!t)throw new Error(`Workspace Intelligence run semantic violation: ${s}`)}function de(t,s){return t.length===s.length&&t.every((m,u)=>m===s[u])}function ue(t){b$1(p.intelligenceRun,t,"Workspace Intelligence run report"),r(t.chainSchemaVersion===a,`chainSchemaVersion must be ${a}`),r(t.artifactPath===p.intelligenceRun,`artifactPath must be ${p.intelligenceRun}`),r(t.preflight.length===y.length,`preflight must contain exactly ${y.length} entries`);for(let[d,n]of y.entries()){let a=t.preflight[d];r(a?.id===n,`preflight[${d}].id must be ${n}`),r(de(a.artifacts,z[n]),`${n} preflight artifacts must match the runtime registry`),n==="sync"?r(a.status==="passed"&&a.result==="synchronized"||a.status==="failed"&&a.result==="failed","sync preflight status and result are incoherent"):r(a.status==="passed"&&(a.result==="created"||a.result==="reused")||a.status==="failed"&&a.result==="failed"||a.status==="skipped"&&a.result==="skipped","baseline preflight status and result are incoherent");}let s=t.preflight[1];r(t.baselineCreated===(s?.result==="created"),"baselineCreated must match the baseline preflight result"),r(t.stages.length===x.length,`stages must contain exactly ${x.length} canonical steps`);let m=t.preflight[0],u=m?.status==="failed";for(let[d,n]of x.entries()){let a=t.stages[d];r(a?.id===n,`stages[${d}].id must be ${n}`),r(de(a.artifacts,A[n].produces),`${n} artifacts must match the runtime registry`),u&&r(a.status==="skipped",`${n} must be skipped after a hard failure`),a.status==="passed"?r(a.exitCode===0,`${n} passed stage must have exitCode 0`):a.status==="blocked"?r(a.exitCode!==0,`${n} blocked stage must have a non-zero exitCode`):a.status==="failed"?(r(a.exitCode===1,`${n} failed stage must have exitCode 1`),u=true):(r(a.exitCode===0,`${n} skipped stage must have exitCode 0`),r(a.durationMs===0,`${n} skipped stage must have durationMs 0`)),d===0&&((m?.status==="failed"||a.status==="failed")&&r(s?.status==="skipped","baseline must be skipped when sync or model fails"),s?.status==="skipped"&&r(m?.status==="failed"||a.status==="failed"||a.status==="skipped","baseline may be skipped only after an upstream failure"),s?.status!=="passed"&&(u=true));}let h=t.preflight.some(d=>d.status==="failed")||t.stages.some(d=>d.status==="failed"),y$1=t.stages.some(d=>d.status==="blocked"),l=h?"failed":y$1?"blocked":"passed",p$1=l==="failed"?1:l==="blocked"?2:0;r(t.status===l,`status must be ${l}`),r(t.exitCode===p$1,`exitCode must be ${p$1}`);}var we=p.intelligenceRun,Ee=q.intelligenceRun,L=we;function I(t){c$2({action:"intelligence",status:t.status==="started"?"started":t.status==="passed"?"succeeded":t.status==="failed"?"failed":"warn",message:t.message,metadata:{phase:`workspace.intelligence.${t.kind}.${t.id}`,intelligenceMilestoneId:t.id,intelligenceMilestoneKind:t.kind,intelligenceMilestoneStatus:t.status}});}async function Ue(t){let s=ge.resolve(t.workspacePath);return f(s,L,()=>ye({...t,workspacePath:s}),{timeoutMs:15*6e4,staleAfterMs:3e4})}async function ye(t){let s$1=t.workspacePath,m$1=[],u$1=[],h$3=false,y=async(e,o)=>{let c=[...z[e]];if(h$3){I({id:e,kind:"preflight",status:"skipped",message:`${e} prerequisite skipped after an upstream failure`}),m$1.push({id:e,status:"skipped",result:"skipped",durationMs:0,artifacts:c,message:"skipped because a required upstream operation failed"});return}let k=Date.now();I({id:e,kind:"preflight",status:"started",message:`${e} prerequisite started`});try{let i=await o();I({id:e,kind:"preflight",status:"passed",message:i.message}),m$1.push({id:e,status:"passed",result:i.result,durationMs:Date.now()-k,artifacts:c,message:i.message});}catch(i){h$3=true;let f=i instanceof Error?i.message:String(i);I({id:e,kind:"preflight",status:"failed",message:f}),m$1.push({id:e,status:"failed",result:"failed",durationMs:Date.now()-k,artifacts:c,message:f});}},l$2=async(e,o)=>{let c=[...A[e].produces];if(h$3){I({id:e,kind:"stage",status:"skipped",message:`${e} skipped after an upstream failure`}),u$1.push({id:e,status:"skipped",durationMs:0,artifacts:c,exitCode:0,message:"skipped because a required upstream stage failed"});return}let k=Date.now();I({id:e,kind:"stage",status:"started",message:`${e} started`});try{let i=await o(),f=i.exitCode??0,w=i.blocked||f!==0?"blocked":"passed";I({id:e,kind:"stage",status:w,message:i.message}),u$1.push({id:e,status:w,durationMs:Date.now()-k,artifacts:c,exitCode:f,message:i.message});}catch(i){h$3=true;let f=i instanceof Error?i.message:String(i);I({id:e,kind:"stage",status:"failed",message:f}),u$1.push({id:e,status:"failed",durationMs:Date.now()-k,artifacts:c,exitCode:1,message:f});}};await y("sync",async()=>{let e=await g(s$1,true),o$1=await o({workspacePath:s$1});return {result:"synchronized",message:`registry ${e.added.length} added/${e.skipped} existing; contract ${o$1.contract.projects.length} projects`}});let p$2,d$1=()=>{if(!p$2)throw new Error("canonical workspace model is unavailable");return p$2};await l$2("model",async()=>(p$2={...await r$1({workspacePath:s$1,includeEvidence:true}),build:o$1({mode:"full",engineStatus:"disabled"})},await u(p$2,s$1),{message:`${p$2.summary.projectCount} projects modeled`}));let n$1=ge.join(s$1,p.snapshot),a$4=false;await y("baseline",async()=>{if(!await pe.pathExists(n$1)){let c=await k({workspacePath:s$1,model:d$1()});return await l(c,s$1),a$4=true,{result:"created",message:"initial structural baseline created"}}let e=await pe.readJson(n$1),o=h$1(e);return o?(await l(o,s$1),{result:"reused",message:"legacy structural baseline migrated and reused"}):{result:"reused",message:"existing structural baseline reused"}}),await l$2("diff",async()=>{let e=await m({workspacePath:s$1,fromPath:p.snapshot,model:d$1()});return await n(e,s$1),{message:e.summary.changed?"workspace changes detected":"no workspace changes"}}),await l$2("impact",async()=>{let e=await p$1({workspacePath:s$1,fromPath:p.diff});return await q$1(e,s$1),{message:`${e.summary.risk} risk; ${e.summary.affectedProjects} affected`}}),await l$2("doctor-evidence",async()=>{let e=await v({workspace:s$1,json:true,quiet:true,profile:t.strict===true?"enterprise-strict":"local"});return {exitCode:e,blocked:e!==0,message:`doctor exit ${e}`}}),await l$2("contract-evidence",async()=>{let e=await r$2({workspacePath:s$1,strict:true});return await s({workspacePath:s$1,result:e}),{exitCode:e.status==="passed"?0:1,blocked:e.status!=="passed",message:`contract ${e.status}`}}),await l$2("analyze-evidence",async()=>{let e=await a$1({workspacePath:s$1,json:true,strict:t.strict===true});return {blocked:e.summary.verdict==="blocked"||t.strict===true&&e.summary.verdict==="needs-attention",exitCode:e.summary.verdict==="blocked"||t.strict===true&&e.summary.verdict==="needs-attention"?1:0,message:`analyze ${e.summary.verdict} (${e.summary.score}/100)`}}),await l$2("readiness-evidence",async()=>{let e=await a$2({startPath:s$1,writeReport:true,skipVerify:true});return {blocked:e.overallStatus==="fail"||t.strict===true&&e.overallStatus==="warn",exitCode:e.overallStatus==="fail"||t.strict===true&&e.overallStatus==="warn"?1:0,message:`pre-verify readiness ${e.overallStatus}`}}),await l$2("verify",async()=>{let e$1=await f$1({workspacePath:s$1,fromImpactPath:p.impact});await g$1(e$1,s$1);let o=h$2(e$1,{strict:t.strict===true});return await j$1(s$1,e(e$1,o.passed)),{blocked:!o.passed,exitCode:o.exitCode,message:`${e$1.summary.verdict}; gate ${o.passed?"passed":"blocked"}`}}),await l$2("context",async()=>{let e=await c({workspacePath:s$1,model:d$1(),agent:t.agent??"generic",includeEvidence:true});return await d(e,s$1),{message:`context grounded for ${e.agent}`}}),await l$2("agent-sync",async()=>{let e=await l$1({workspacePath:s$1,agent:t.agent??"generic",targets:["all"],write:true,refreshContext:false,strict:t.strict===true,preset:"enterprise"}),o=false,c$1=await a$3(s$1);if(c$1.status==="miss"){if(c$1.reason!=="live-input-mismatch")throw new Error(`Agent grounding left canonical evidence invalid (${c$1.reason}).`);p$2={...await r$1({workspacePath:s$1,includeEvidence:true}),build:o$1({mode:"full",engineStatus:"disabled"})},await u(p$2,s$1);let f=await c({workspacePath:s$1,model:p$2,agent:t.agent??"generic",includeEvidence:true});await d(f,s$1);let w=await l$1({workspacePath:s$1,agent:t.agent??"generic",targets:["all"],write:true,refreshContext:false,strict:t.strict===true,preset:"enterprise"});e={...w,writtenFiles:[...new Set([...e.writtenFiles,...w.writtenFiles])].sort(),strictViolations:[...new Set([...e.strictViolations??[],...w.strictViolations??[]])].sort()};let O=await a$3(s$1);if(O.status==="miss")throw new Error(`Agent grounding reconciliation did not produce fresh canonical evidence (${O.reason}).`);o=true;}let k=e.strictViolations??[],i=t.strict===true&&k.length>0;return {blocked:i,exitCode:i?2:0,message:i?`${e.writtenFiles.length} grounding files written; ${k.length} strict grounding violation(s): ${k.join("; ")}`:`${e.writtenFiles.length} grounding files written; portable entry surfaces prepared for all supported hosts${o?"; canonical Model/Graph freshness sealed":""}`}}),await l$2("explain",async()=>{let e=await b({workspacePath:s$1,target:{kind:"release-blocked"}});await c$1(e,s$1);let o=t.strict===true?u$1.filter(c=>c.status==="blocked").map(c=>c.id):[];return {message:o.length>0&&e.blocking!==true?`Strict policy blocked advisory or incomplete evidence in ${o.join(", ")}. ${e.summary}`:e.summary}});let me=u$1.some(e=>e.status==="blocked"),G=h$3?"failed":me?"blocked":"passed",fe=h$3?1:G==="blocked"?2:0,b$1={schemaVersion:Ee,chainSchemaVersion:a,generatedAt:new Date().toISOString(),workspacePath:s$1,baselineCreated:a$4,preflight:m$1,status:G,exitCode:fe,stages:u$1,artifactPath:L};ue(b$1),await h(s$1,L,b$1);let ke=await j({workspacePath:s$1});return await h(s$1,p.agentIndex,ke),b$1}export{we as a,Ee as b,Ue as c};
|
|
1
|
+
import {a as a$2}from'./chunk-TFFNHWXY.js';import {j,l as l$1}from'./chunk-R3Z4LY3O.js';import {g}from'./chunk-KW35SWG6.js';import {a as a$1}from'./chunk-Z2M2XCIB.js';import {v}from'./chunk-PSQPKK6H.js';import {j as j$1,e}from'./chunk-RU3UT7GJ.js';import {b,c as c$1}from'./chunk-FBF767WP.js';import {c,d}from'./chunk-FD2ZGGCQ.js';import {a}from'./chunk-COICGD62.js';import {f as f$1,g as g$1,h as h$2}from'./chunk-PUH3TSPC.js';import {k,l,h as h$1,m,n,p as p$1,q as q$1}from'./chunk-BZLDCASY.js';import {a as a$3}from'./chunk-AGI46TSQ.js';import {o as o$1,r as r$1,u}from'./chunk-VODNLROY.js';import {o,r as r$2,s}from'./chunk-YLLCZMKP.js';import {f,h}from'./chunk-BLEIUQL6.js';import {b as b$1}from'./chunk-VN2MKTQO.js';import {c as c$2}from'./chunk-EFHSRPW7.js';import {p,q,z,A,y,x}from'./chunk-ODK4LCEL.js';import ge from'path';import pe from'fs-extra';function r(t,s){if(!t)throw new Error(`Workspace Intelligence run semantic violation: ${s}`)}function de(t,s){return t.length===s.length&&t.every((m,u)=>m===s[u])}function ue(t){b$1(p.intelligenceRun,t,"Workspace Intelligence run report"),r(t.chainSchemaVersion===a,`chainSchemaVersion must be ${a}`),r(t.artifactPath===p.intelligenceRun,`artifactPath must be ${p.intelligenceRun}`),r(t.preflight.length===y.length,`preflight must contain exactly ${y.length} entries`);for(let[d,n]of y.entries()){let a=t.preflight[d];r(a?.id===n,`preflight[${d}].id must be ${n}`),r(de(a.artifacts,z[n]),`${n} preflight artifacts must match the runtime registry`),n==="sync"?r(a.status==="passed"&&a.result==="synchronized"||a.status==="failed"&&a.result==="failed","sync preflight status and result are incoherent"):r(a.status==="passed"&&(a.result==="created"||a.result==="reused")||a.status==="failed"&&a.result==="failed"||a.status==="skipped"&&a.result==="skipped","baseline preflight status and result are incoherent");}let s=t.preflight[1];r(t.baselineCreated===(s?.result==="created"),"baselineCreated must match the baseline preflight result"),r(t.stages.length===x.length,`stages must contain exactly ${x.length} canonical steps`);let m=t.preflight[0],u=m?.status==="failed";for(let[d,n]of x.entries()){let a=t.stages[d];r(a?.id===n,`stages[${d}].id must be ${n}`),r(de(a.artifacts,A[n].produces),`${n} artifacts must match the runtime registry`),u&&r(a.status==="skipped",`${n} must be skipped after a hard failure`),a.status==="passed"?r(a.exitCode===0,`${n} passed stage must have exitCode 0`):a.status==="blocked"?r(a.exitCode!==0,`${n} blocked stage must have a non-zero exitCode`):a.status==="failed"?(r(a.exitCode===1,`${n} failed stage must have exitCode 1`),u=true):(r(a.exitCode===0,`${n} skipped stage must have exitCode 0`),r(a.durationMs===0,`${n} skipped stage must have durationMs 0`)),d===0&&((m?.status==="failed"||a.status==="failed")&&r(s?.status==="skipped","baseline must be skipped when sync or model fails"),s?.status==="skipped"&&r(m?.status==="failed"||a.status==="failed"||a.status==="skipped","baseline may be skipped only after an upstream failure"),s?.status!=="passed"&&(u=true));}let h=t.preflight.some(d=>d.status==="failed")||t.stages.some(d=>d.status==="failed"),y$1=t.stages.some(d=>d.status==="blocked"),l=h?"failed":y$1?"blocked":"passed",p$1=l==="failed"?1:l==="blocked"?2:0;r(t.status===l,`status must be ${l}`),r(t.exitCode===p$1,`exitCode must be ${p$1}`);}var we=p.intelligenceRun,Ee=q.intelligenceRun,L=we;function I(t){c$2({action:"intelligence",status:t.status==="started"?"started":t.status==="passed"?"succeeded":t.status==="failed"?"failed":"warn",message:t.message,metadata:{phase:`workspace.intelligence.${t.kind}.${t.id}`,intelligenceMilestoneId:t.id,intelligenceMilestoneKind:t.kind,intelligenceMilestoneStatus:t.status}});}async function Ue(t){let s=ge.resolve(t.workspacePath);return f(s,L,()=>ye({...t,workspacePath:s}),{timeoutMs:15*6e4,staleAfterMs:3e4})}async function ye(t){let s$1=t.workspacePath,m$1=[],u$1=[],h$3=false,y=async(e,o)=>{let c=[...z[e]];if(h$3){I({id:e,kind:"preflight",status:"skipped",message:`${e} prerequisite skipped after an upstream failure`}),m$1.push({id:e,status:"skipped",result:"skipped",durationMs:0,artifacts:c,message:"skipped because a required upstream operation failed"});return}let k=Date.now();I({id:e,kind:"preflight",status:"started",message:`${e} prerequisite started`});try{let i=await o();I({id:e,kind:"preflight",status:"passed",message:i.message}),m$1.push({id:e,status:"passed",result:i.result,durationMs:Date.now()-k,artifacts:c,message:i.message});}catch(i){h$3=true;let f=i instanceof Error?i.message:String(i);I({id:e,kind:"preflight",status:"failed",message:f}),m$1.push({id:e,status:"failed",result:"failed",durationMs:Date.now()-k,artifacts:c,message:f});}},l$2=async(e,o)=>{let c=[...A[e].produces];if(h$3){I({id:e,kind:"stage",status:"skipped",message:`${e} skipped after an upstream failure`}),u$1.push({id:e,status:"skipped",durationMs:0,artifacts:c,exitCode:0,message:"skipped because a required upstream stage failed"});return}let k=Date.now();I({id:e,kind:"stage",status:"started",message:`${e} started`});try{let i=await o(),f=i.exitCode??0,w=i.blocked||f!==0?"blocked":"passed";I({id:e,kind:"stage",status:w,message:i.message}),u$1.push({id:e,status:w,durationMs:Date.now()-k,artifacts:c,exitCode:f,message:i.message});}catch(i){h$3=true;let f=i instanceof Error?i.message:String(i);I({id:e,kind:"stage",status:"failed",message:f}),u$1.push({id:e,status:"failed",durationMs:Date.now()-k,artifacts:c,exitCode:1,message:f});}};await y("sync",async()=>{let e=await g(s$1,true),o$1=await o({workspacePath:s$1});return {result:"synchronized",message:`registry ${e.added.length} added/${e.skipped} existing; contract ${o$1.contract.projects.length} projects`}});let p$2,d$1=()=>{if(!p$2)throw new Error("canonical workspace model is unavailable");return p$2};await l$2("model",async()=>(p$2={...await r$1({workspacePath:s$1,includeEvidence:true}),build:o$1({mode:"full",engineStatus:"disabled"})},await u(p$2,s$1),{message:`${p$2.summary.projectCount} projects modeled`}));let n$1=ge.join(s$1,p.snapshot),a$4=false;await y("baseline",async()=>{if(!await pe.pathExists(n$1)){let c=await k({workspacePath:s$1,model:d$1()});return await l(c,s$1),a$4=true,{result:"created",message:"initial structural baseline created"}}let e=await pe.readJson(n$1),o=h$1(e);return o?(await l(o,s$1),{result:"reused",message:"legacy structural baseline migrated and reused"}):{result:"reused",message:"existing structural baseline reused"}}),await l$2("diff",async()=>{let e=await m({workspacePath:s$1,fromPath:p.snapshot,model:d$1()});return await n(e,s$1),{message:e.summary.changed?"workspace changes detected":"no workspace changes"}}),await l$2("impact",async()=>{let e=await p$1({workspacePath:s$1,fromPath:p.diff});return await q$1(e,s$1),{message:`${e.summary.risk} risk; ${e.summary.affectedProjects} affected`}}),await l$2("doctor-evidence",async()=>{let e=await v({workspace:s$1,json:true,quiet:true,profile:t.strict===true?"enterprise-strict":"local"});return {exitCode:e,blocked:e!==0,message:`doctor exit ${e}`}}),await l$2("contract-evidence",async()=>{let e=await r$2({workspacePath:s$1,strict:true});return await s({workspacePath:s$1,result:e}),{exitCode:e.status==="passed"?0:1,blocked:e.status!=="passed",message:`contract ${e.status}`}}),await l$2("analyze-evidence",async()=>{let e=await a$1({workspacePath:s$1,json:true,strict:t.strict===true});return {blocked:e.summary.verdict==="blocked"||t.strict===true&&e.summary.verdict==="needs-attention",exitCode:e.summary.verdict==="blocked"||t.strict===true&&e.summary.verdict==="needs-attention"?1:0,message:`analyze ${e.summary.verdict} (${e.summary.score}/100)`}}),await l$2("readiness-evidence",async()=>{let e=await a$2({startPath:s$1,writeReport:true,skipVerify:true});return {blocked:e.overallStatus==="fail"||t.strict===true&&e.overallStatus==="warn",exitCode:e.overallStatus==="fail"||t.strict===true&&e.overallStatus==="warn"?1:0,message:`pre-verify readiness ${e.overallStatus}`}}),await l$2("verify",async()=>{let e$1=await f$1({workspacePath:s$1,fromImpactPath:p.impact});await g$1(e$1,s$1);let o=h$2(e$1,{strict:t.strict===true});return await j$1(s$1,e(e$1,o.passed)),{blocked:!o.passed,exitCode:o.exitCode,message:`${e$1.summary.verdict}; gate ${o.passed?"passed":"blocked"}`}}),await l$2("context",async()=>{let e=await c({workspacePath:s$1,model:d$1(),agent:t.agent??"generic",includeEvidence:true});return await d(e,s$1),{message:`context grounded for ${e.agent}`}}),await l$2("agent-sync",async()=>{let e=await l$1({workspacePath:s$1,agent:t.agent??"generic",targets:["all"],write:true,refreshContext:false,strict:t.strict===true,preset:"enterprise"}),o=false,c$1=await a$3(s$1);if(c$1.status==="miss"){if(c$1.reason!=="live-input-mismatch")throw new Error(`Agent grounding left canonical evidence invalid (${c$1.reason}).`);p$2={...await r$1({workspacePath:s$1,includeEvidence:true}),build:o$1({mode:"full",engineStatus:"disabled"})},await u(p$2,s$1);let f=await c({workspacePath:s$1,model:p$2,agent:t.agent??"generic",includeEvidence:true});await d(f,s$1);let w=await l$1({workspacePath:s$1,agent:t.agent??"generic",targets:["all"],write:true,refreshContext:false,strict:t.strict===true,preset:"enterprise"});e={...w,writtenFiles:[...new Set([...e.writtenFiles,...w.writtenFiles])].sort(),strictViolations:[...new Set([...e.strictViolations??[],...w.strictViolations??[]])].sort()};let O=await a$3(s$1);if(O.status==="miss")throw new Error(`Agent grounding reconciliation did not produce fresh canonical evidence (${O.reason}).`);o=true;}let k=e.strictViolations??[],i=t.strict===true&&k.length>0;return {blocked:i,exitCode:i?2:0,message:i?`${e.writtenFiles.length} grounding files written; ${k.length} strict grounding violation(s): ${k.join("; ")}`:`${e.writtenFiles.length} grounding files written; portable entry surfaces prepared for all supported hosts${o?"; canonical Model/Graph freshness sealed":""}`}}),await l$2("explain",async()=>{let e=await b({workspacePath:s$1,target:{kind:"release-blocked"}});await c$1(e,s$1);let o=t.strict===true?u$1.filter(c=>c.status==="blocked").map(c=>c.id):[];return {message:o.length>0&&e.blocking!==true?`Strict policy blocked advisory or incomplete evidence in ${o.join(", ")}. ${e.summary}`:e.summary}});let me=u$1.some(e=>e.status==="blocked"),G=h$3?"failed":me?"blocked":"passed",fe=h$3?1:G==="blocked"?2:0,b$1={schemaVersion:Ee,chainSchemaVersion:a,generatedAt:new Date().toISOString(),workspacePath:s$1,baselineCreated:a$4,preflight:m$1,status:G,exitCode:fe,stages:u$1,artifactPath:L};ue(b$1),await h(s$1,L,b$1);let ke=await j({workspacePath:s$1});return await h(s$1,p.agentIndex,ke),b$1}export{we as a,Ee as b,Ue as c};
|