workspai 0.49.0 → 0.51.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/README.md +123 -434
- package/contracts/analyze-last-run.v1.json +2 -2
- package/contracts/artifact-remediation-plan.v1.json +3 -9
- package/contracts/autopilot-release.v1.json +2 -0
- package/contracts/bootstrap-compliance.v1.json +2 -1
- package/contracts/cli-log-event.v1.json +1 -1
- package/contracts/cli-runtime-command-inventory.v1.snapshot.json +80 -0
- package/contracts/compatibility-matrix.v1.json +2 -0
- package/contracts/create-planner-capabilities.v1.json +153 -32
- package/contracts/doctor-project-evidence.v1.json +191 -11
- package/contracts/doctor-project-scan.v2.json +2 -0
- package/contracts/doctor-remediation-plan.v1.json +2 -2
- package/contracts/doctor-remediation-plan.v2.json +2 -2
- package/contracts/doctor-workspace-cache.v2.json +2 -0
- package/contracts/doctor-workspace-evidence.v1.json +189 -10
- package/contracts/extension-cli-compatibility.v1.json +10 -1
- package/contracts/infra-plan.v1.json +2 -0
- package/contracts/ingestion-plan.v1.json +85 -0
- package/contracts/ingestion-result.v1.json +59 -0
- package/contracts/mirror-ops.v1.json +2 -1
- package/contracts/pipeline-last-run.v1.json +2 -2
- package/contracts/private-product-manifest.v1.json +2 -0
- package/contracts/product-factory-plan.v1.json +2 -0
- package/contracts/project-archive.v1.json +2 -0
- package/contracts/project-entry-capability.v1.json +2 -3
- package/contracts/project-test-coverage.v1.json +189 -0
- package/contracts/project-workspace-link.v1.json +66 -0
- package/contracts/project-workspace-resolution.v1.json +28 -0
- package/contracts/published-contract-catalog.v1.json +45 -0
- package/contracts/release-readiness.v1.json +2 -2
- package/contracts/runtime-command-surface.v1.json +1456 -139
- package/contracts/transparency-evidence.v1.json +2 -1
- package/contracts/workspace-archive-capabilities.v1.json +11 -5
- package/contracts/workspace-archive-manifest.v1.json +236 -0
- package/contracts/workspace-archive-operation-result.v1.json +236 -0
- package/contracts/workspace-contract.v1.json +1 -1
- package/contracts/workspace-intelligence/agent-action-outcome.v1.json +2 -2
- package/contracts/workspace-intelligence/agent-customization-pack-report.v1.json +1 -1
- package/contracts/workspace-intelligence/agent-hooks.v1.json +2 -0
- package/contracts/workspace-intelligence/agent-reports-index.v1.json +1 -1
- package/contracts/workspace-intelligence/blocker-resolution.v1.json +3 -9
- package/contracts/workspace-intelligence/doctor-fix-result.v1.json +2 -2
- package/contracts/workspace-intelligence/doctor-graph-diagnosis.v1.json +208 -0
- package/contracts/workspace-intelligence/fact-freshness.v1.json +2 -2
- package/contracts/workspace-intelligence/mcp-design.v1.json +2 -0
- package/contracts/workspace-intelligence/model-usage-event.v1.json +1 -1
- package/contracts/workspace-intelligence/project-context-agent.v1.json +360 -0
- package/contracts/workspace-intelligence/studio-blocker-handoff.v1.json +1 -1
- package/contracts/workspace-intelligence/workspace-context.v1.json +1 -1
- package/contracts/workspace-intelligence/workspace-contract-verify.v1.json +2 -2
- package/contracts/workspace-intelligence/workspace-dependency-graph.v1.json +1 -1
- package/contracts/workspace-intelligence/workspace-explain.v1.json +1 -1
- package/contracts/workspace-intelligence/workspace-graph-stream.v1.json +1 -1
- package/contracts/workspace-intelligence/workspace-graph-token-efficiency.v1.json +1 -1
- package/contracts/workspace-intelligence/workspace-impact.v1.json +1 -1
- package/contracts/workspace-intelligence/workspace-intelligence-evaluation-comparison.v1.json +1 -1
- package/contracts/workspace-intelligence/workspace-intelligence-evaluation.v1.json +1 -1
- package/contracts/workspace-intelligence/workspace-intelligence-history.v1.json +1 -1
- package/contracts/workspace-intelligence/workspace-intelligence-run.v1.json +2 -2
- package/contracts/workspace-intelligence/workspace-knowledge-graph-change-overlay.v1.json +1 -1
- package/contracts/workspace-intelligence/workspace-knowledge-graph.v1.json +48 -5
- package/contracts/workspace-intelligence/workspace-knowledge-search.v1.json +1 -1
- package/contracts/workspace-intelligence/workspace-model-diff.v1.json +1 -1
- package/contracts/workspace-intelligence/workspace-model-snapshot.v1.json +1 -1
- package/contracts/workspace-intelligence/workspace-model.v1.json +97 -5
- package/contracts/workspace-intelligence/workspace-operational-skill.v1.json +1 -1
- package/contracts/workspace-intelligence/workspace-skills-index.v1.json +1 -1
- package/contracts/workspace-intelligence/workspace-verify.v1.json +1 -1
- package/contracts/workspace-intelligence-architecture.v1.json +33 -7
- package/contracts/workspace-intelligence-chain.v1.json +1 -1
- package/contracts/workspace-list.v1.json +2 -0
- package/contracts/workspace-model-cache.v1.json +2 -0
- package/contracts/workspace-registry.v1.json +1 -1
- package/contracts/workspace-run-last.v1.json +1 -1
- package/contracts/workspace-share-bundle.v1.json +2 -1
- package/contracts/workspace-snapshot.v1.json +2 -0
- package/contracts/workspace-snapshot.v2.json +2 -0
- package/contracts/workspace-sync.v1.json +2 -0
- package/contracts/workspace-watch-event.v1.json +2 -0
- package/dist/analyze-4H33PAUB.js +1 -0
- package/dist/{artifact-remediation-plan-SPOUHMK5.js → artifact-remediation-plan-TQ6KTTXD.js} +1 -1
- package/dist/autopilot-release-BHZYM5KX.js +1 -0
- package/dist/chunk-2D4UOYOJ.js +1 -0
- package/dist/chunk-2OIBHUVH.js +1 -0
- package/dist/chunk-3D2PAIRH.js +3 -0
- package/dist/chunk-3GRKUP5W.js +33 -0
- package/dist/{managed-agent-markers-AXUM75OE.js → chunk-3RBUSW7H.js} +1 -1
- package/dist/chunk-4WJC5QCD.js +2 -0
- package/dist/chunk-6HLPTJZ3.js +13 -0
- package/dist/{chunk-CV5HKU4P.js → chunk-7T4TSV5C.js} +1 -1
- package/dist/chunk-AFIFZTOY.js +2 -0
- package/dist/{chunk-BMWFQXGW.js → chunk-AHLMIL2T.js} +1 -1
- package/dist/chunk-AL237TSJ.js +7 -0
- package/dist/chunk-BBGNDMRU.js +2 -0
- package/dist/chunk-BG4FWJJ3.js +1 -0
- package/dist/{chunk-VU7NZHPM.js → chunk-BHYTI3RH.js} +1 -1
- package/dist/chunk-BYTFXQ6G.js +1 -0
- package/dist/chunk-CZC5P2MF.js +1 -0
- package/dist/chunk-DLM6C7FU.js +8 -0
- package/dist/{chunk-CRHYBQI3.js → chunk-DQ3PI7EP.js} +1 -1
- package/dist/chunk-E3CT7TYT.js +1 -0
- package/dist/chunk-EPVFKJF4.js +1 -0
- package/dist/chunk-EWZZUQBR.js +1 -0
- package/dist/chunk-FKWB66NQ.js +4 -0
- package/dist/{chunk-BGPXQQNY.js → chunk-FZ76CF2W.js} +1 -1
- package/dist/chunk-GBAO4GSW.js +2 -0
- package/dist/chunk-GQRWRHSR.js +86 -0
- package/dist/{chunk-ESLPI3XZ.js → chunk-HE4PUMU4.js} +1 -1
- package/dist/chunk-HMGPELXS.js +1 -0
- package/dist/chunk-HSZCINFX.js +2 -0
- package/dist/{chunk-3VFA7D5T.js → chunk-IND3TUVU.js} +1 -1
- package/dist/{chunk-NHN4QXPP.js → chunk-KVSYBHUR.js} +1 -1
- package/dist/chunk-L2E2Z4OE.js +5 -0
- package/dist/chunk-MAF3LLGK.js +691 -0
- package/dist/chunk-MOSXTVPU.js +1 -0
- package/dist/chunk-MVLIONQD.js +1 -0
- package/dist/chunk-PS5F4DCT.js +1 -0
- package/dist/{chunk-K4X3DM7R.js → chunk-Q6TKQVKQ.js} +1 -1
- package/dist/chunk-RJIYCDVC.js +1 -0
- package/dist/chunk-RVQLMTTI.js +2 -0
- package/dist/chunk-SHXJ2GDR.js +75 -0
- package/dist/chunk-TDTCMZK7.js +10 -0
- package/dist/chunk-TROHVI2V.js +2 -0
- package/dist/chunk-U2LR73E2.js +1 -0
- package/dist/chunk-U2QL5733.js +36 -0
- package/dist/{chunk-TIE2XMGH.js → chunk-VCW5HSPC.js} +12 -12
- package/dist/chunk-VRW6KXNK.js +6 -0
- package/dist/chunk-VU2BKKMB.js +1 -0
- package/dist/chunk-WJVB6SSD.js +16 -0
- package/dist/{chunk-32OJDBIG.js → chunk-XBM2P45G.js} +2 -2
- package/dist/chunk-Y5YAP4F3.js +2 -0
- package/dist/{create-S64IWHAP.js → create-SBFBFXKN.js} +1 -1
- package/dist/{demo-kit-DZ7TPG7K.js → demo-kit-KHH63TNA.js} +2 -2
- package/dist/{doctor-4NNUDNGZ.js → doctor-OPCMTBJB.js} +1 -1
- package/dist/{dotnet-webapi-clean-A6MVDYXX.js → dotnet-webapi-clean-VXEF4SHM.js} +5 -5
- package/dist/{gofiber-standard-I5YPQG5V.js → gofiber-standard-AQGSC7ON.js} +3 -3
- package/dist/{gogin-standard-VY2L4QT5.js → gogin-standard-7DU3OCBX.js} +3 -3
- package/dist/index.d.ts +38 -6
- package/dist/index.js +267 -355
- package/dist/managed-agent-markers-COE5DJ3W.js +1 -0
- package/dist/pipeline-7BUXAFS2.js +5 -0
- package/dist/platform-capabilities-PR6YL4KC.js +1 -0
- package/dist/project-intelligence-lens-BKKVPCLC.js +1 -0
- package/dist/project-test-coverage-BALEHHTT.js +1 -0
- package/dist/{pythonRapidkitExec-CVCIK225.js → pythonRapidkitExec-YR7P5LWG.js} +1 -1
- package/dist/rust-axum-4HXDICIB.js +140 -0
- package/dist/{springboot-standard-55XKCBIZ.js → springboot-standard-EK6GYN5T.js} +7 -7
- package/dist/workspace-U6ZQLELX.js +1 -0
- package/dist/{workspace-agent-sync-662QHXGF.js → workspace-agent-sync-L4SY7B4Q.js} +1 -1
- package/dist/workspace-archive-4JNT4S7N.js +1 -0
- package/dist/workspace-context-KOBSLZTI.js +1 -0
- package/dist/workspace-contract-SOD3OOVF.js +1 -0
- package/dist/workspace-explain-2CTMW2YW.js +1 -0
- package/dist/workspace-explain-contract-H7O26QJU.js +1 -0
- package/dist/{workspace-feedback-SUVH2LUJ.js → workspace-feedback-ZZ4HPW2T.js} +1 -1
- package/dist/{workspace-foundation-WPLD7OEO.js → workspace-foundation-PUIYBQUF.js} +1 -1
- package/dist/workspace-graph-stream-BLKIC7VN.js +1 -0
- package/dist/workspace-graph-token-efficiency-5FNH4JZ5.js +1 -0
- package/dist/{workspace-history-BANOJRQ2.js → workspace-history-SPKNRHIX.js} +1 -1
- package/dist/workspace-intelligence-I3ABOH2F.js +1 -0
- package/dist/{workspace-intelligence-evaluation-IPH7M3WV.js → workspace-intelligence-evaluation-7CABG5Y6.js} +1 -1
- package/dist/workspace-intelligence-runner-Q2XSR3ZL.js +1 -0
- package/dist/workspace-intelligence-runtime-registry-ZZ3GRAL2.js +1 -0
- package/dist/{workspace-knowledge-graph-ARDC6HHG.js → workspace-knowledge-graph-5MKEI4Z5.js} +1 -1
- package/dist/{workspace-knowledge-graph-query-VOSPPH4W.js → workspace-knowledge-graph-query-EKHIE3E2.js} +1 -1
- package/dist/{workspace-marker-SMBC3Z2Q.js → workspace-marker-7NHMDIRL.js} +1 -1
- package/dist/workspace-mcp-serve-ETNUA72W.js +3 -0
- package/dist/workspace-model-HHA37SNH.js +1 -0
- package/dist/workspace-model-hash-ZXYPIGCW.js +1 -0
- package/dist/workspace-onboarding-ELHZABJE.js +1 -0
- package/dist/{workspace-python-engine-state-2MLKJYQG.js → workspace-python-engine-state-J4QKW55K.js} +1 -1
- package/dist/workspace-readme-HGGZ4AZB.js +77 -0
- package/dist/{workspace-registry-summary-ORDK7A36.js → workspace-registry-summary-D2QM5JF6.js} +1 -1
- package/dist/workspace-run-DAAZBCN7.js +1 -0
- package/dist/{workspace-verify-EBVL7FWT.js → workspace-verify-4WJTLXRA.js} +1 -1
- package/dist/workspace-watch-2PIFTQ6B.js +1 -0
- package/docs/GLOSSARY.md +17 -16
- package/docs/OPEN_SOURCE_USER_SCENARIOS.md +8 -3
- package/docs/README.md +6 -3
- package/docs/README_CONTENT_CONTRACT.md +98 -115
- package/docs/ci-workflows.md +13 -4
- package/docs/commands-reference.md +43 -10
- package/docs/contracts/ARTIFACT_CATALOG.md +65 -26
- package/docs/contracts/COMMAND_OWNERSHIP_MATRIX.md +2 -0
- package/docs/contracts/RUNTIME_SUPPORT_MATRIX.md +3 -3
- package/docs/contracts/rapidkit-cli-contracts.json +2 -2
- package/docs/create-planner-capabilities.md +36 -5
- package/docs/creating-workspaces-and-projects.md +59 -3
- package/docs/doctor-command.md +118 -11
- package/docs/from-code-to-shared-understanding.md +4 -1
- package/docs/graph-benchmark-methodology.md +2 -2
- package/docs/workspace-intelligence-evaluation.md +5 -0
- package/docs/workspace-knowledge-graph.md +141 -7
- package/docs/workspace-operations.md +149 -10
- package/package.json +7 -4
- package/scripts/enterprise-package-smoke.mjs +24 -1
- package/templates/kits/fastapi-ddd/README.md.j2 +1 -1
- package/templates/kits/fastapi-standard/README.md.j2 +1 -1
- package/templates/kits/nestjs-standard/Dockerfile.j2 +1 -1
- package/templates/kits/nestjs-standard/README.md.j2 +1 -1
- package/templates/kits/nestjs-standard/package.json.j2 +11 -2
- package/dist/analyze-EEEU3MIF.js +0 -1
- package/dist/autopilot-release-R4XRTWEM.js +0 -1
- package/dist/chunk-22DT744Z.js +0 -1
- package/dist/chunk-37CVKXBD.js +0 -1
- package/dist/chunk-3NU32T4A.js +0 -2
- package/dist/chunk-3ZK2GU7C.js +0 -1
- package/dist/chunk-4HDYADHT.js +0 -13
- package/dist/chunk-4KUIFXHM.js +0 -5
- package/dist/chunk-52PBRX7F.js +0 -1
- package/dist/chunk-54EP5CEV.js +0 -8
- package/dist/chunk-5XATWNME.js +0 -1
- package/dist/chunk-7YHK5NM3.js +0 -2
- package/dist/chunk-AFL3ACCR.js +0 -2
- package/dist/chunk-BFLJ2R4D.js +0 -80
- package/dist/chunk-E2KJ5QWY.js +0 -4
- package/dist/chunk-EKZLUMCS.js +0 -933
- package/dist/chunk-EYJ2CQSK.js +0 -1
- package/dist/chunk-FTY7GGXJ.js +0 -33
- package/dist/chunk-FXQJX34Z.js +0 -1
- package/dist/chunk-GSWPGELT.js +0 -2
- package/dist/chunk-GZTYAEWX.js +0 -1
- package/dist/chunk-HDXNIN4N.js +0 -1
- package/dist/chunk-HZDXO65G.js +0 -36
- package/dist/chunk-J5ENLXDF.js +0 -1
- package/dist/chunk-KB44JP4M.js +0 -2
- package/dist/chunk-LHOZXC2M.js +0 -2
- package/dist/chunk-MER6ZBN2.js +0 -13
- package/dist/chunk-NAJCUQ4X.js +0 -2
- package/dist/chunk-OA537ZQ5.js +0 -1
- package/dist/chunk-OW42TZFB.js +0 -1
- package/dist/chunk-P3D5YQB2.js +0 -1
- package/dist/chunk-PHXQR6PX.js +0 -2
- package/dist/chunk-PRTR2DQ2.js +0 -1
- package/dist/chunk-RHQW3DTP.js +0 -1
- package/dist/chunk-T4YR4RAI.js +0 -2
- package/dist/chunk-WDKNMTJQ.js +0 -1
- package/dist/chunk-Y45WZR5N.js +0 -5
- package/dist/chunk-YJZOMRAS.js +0 -1
- package/dist/pipeline-LHTPE3DR.js +0 -5
- package/dist/platform-capabilities-2B4QMZXE.js +0 -1
- package/dist/workspace-PJPRBUMQ.js +0 -1
- package/dist/workspace-archive-P76EDIUG.js +0 -10
- package/dist/workspace-context-23YYCUCP.js +0 -1
- package/dist/workspace-contract-TU2I7GC2.js +0 -1
- package/dist/workspace-dependency-graph-BP4EXYQ5.js +0 -1
- package/dist/workspace-explain-MWUEN643.js +0 -1
- package/dist/workspace-explain-contract-ZPI3JXJU.js +0 -1
- package/dist/workspace-graph-stream-KAGGQPJT.js +0 -1
- package/dist/workspace-graph-token-efficiency-CFGFCJ5V.js +0 -1
- package/dist/workspace-intelligence-MFJE7W67.js +0 -1
- package/dist/workspace-intelligence-runner-OTYTHV6B.js +0 -1
- package/dist/workspace-mcp-serve-EZR6O76D.js +0 -3
- package/dist/workspace-model-7OU2M3LE.js +0 -1
- package/dist/workspace-model-hash-MHXK5MEI.js +0 -1
- package/dist/workspace-run-QND2SIYA.js +0 -1
- package/dist/workspace-watch-7HWGA5TF.js +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import s from'fs';import {homedir}from'os';import n from'path';var e=".workspai",a=".rapidkit",p=".workspai-workspace",g=".rapidkit-workspace",_="workspace-link.local.json",P="PROJECT-GROUNDING.md",d="project-context-agent.json",D=`${e}/${_}`,h=`${e}/${P}`,y=`${e}/reports/${d}`,c="workspai",K="Workspai";function R(t){return s.existsSync(n.join(t,p))||s.existsSync(n.join(t,g))||s.existsSync(n.join(t,e,"workspace.json"))||s.existsSync(n.join(t,a,"workspace.json"))}function A(t=homedir()){return n.join(t,".workspai","workspaces")}function E(t=homedir()){return n.join(t,"rapidkit","workspaces")}function l(t=homedir()){return n.join(t,"Workspai","rapidkits")}function u(t,r=homedir()){return n.join(A(r),t)}function k(t,r=homedir()){return [u(t,r),n.join(E(r),t),n.join(l(r),t)]}function S(t,r={}){let o=r.homeDir??homedir();return r.outputDir?n.resolve(r.outputDir,t):u(t,o)}function G(t,r=homedir()){for(let o of k(t,r))if(s.existsSync(o))return o}function N(t,r="my-workspace"){let o=1;for(;;){let f=o===1?r:`${r}-${o}`,x=n.join(t,f);if(!s.existsSync(x))return {name:f,targetPath:x};o+=1;}}function T(t=homedir()){return [n.join(A(t),c),n.join(E(t),c),n.join(l(t),c)]}function v(t=homedir()){for(let r of T(t))if(R(r))return r;return u(c,t)}function j(t,...r){return n.join(t,e,...r)}function W(t,...r){return n.join(t,a,...r)}function w(t){return n.join(t,p)}function $(t){return n.join(t,g)}function m(t,...r){return [j(t,...r),W(t,...r)]}function F(t,r){return [n.join(t,e,r),n.join(t,a,r)]}function J(t,r){return n.join(t,e,r)}function U(t){return t.replace(/\\/g,"/")===g?p:t.split(/[\\/]/g).map(o=>o===a?e:o).join("/")}function b(t){return t.replace(/\\/g,"/")===p?g:t.split(/[\\/]/g).map(o=>o===e?a:o).join("/")}export{e as a,a as b,p as c,g as d,_ as e,D as f,h as g,y as h,K as i,R as j,A as k,S as l,G as m,N as n,v as o,j as p,w as q,$ as r,m as s,F as t,J as u,U as v,b as w};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import {b}from'./chunk-AHLMIL2T.js';var y=b.doctor,m="doctor-project-evidence-v1";function n(e){return !e||typeof e!="object"||Array.isArray(e)?null:e}function R(e,o){let r=n(e);if(!r)return false;let s=r.schemaVersion,i=r.evidenceType;return !(typeof s=="string"&&(s!==y&&s!==m||o==="workspace"&&s!==y||o==="project"&&s!==m)||typeof i=="string"&&(i!=="workspace"&&i!=="project"||o&&i!==o))}function c(e,o){let r=e[o];if(!Number.isInteger(r)||Number(r)<0)throw new Error(`Doctor evidence ${o} must be a non-negative integer.`);return Number(r)}function v(e){if(Array.isArray(e.projects))return e.projects.map(n).filter(r=>r!==null);let o=n(e.project);return o?[o]:[]}function S(e){let o=n(e);if(!o)throw new Error("Doctor evidence must be an object.");let r=n(o.healthScore);if(!r||typeof r.verdict!="string")return;let s=c(r,"total"),i=c(r,"passed"),f=c(r,"warnings"),u=c(r,"errors");if(s!==i+f+u)throw new Error("Doctor healthScore total must equal passed + warnings + errors.");let p=u>0?"blocked":f>0?"attention":"passed";if(r.verdict!==p)throw new Error(`Doctor healthScore verdict ${String(r.verdict)} contradicts score counts (${p}).`);let l=0,g=0;for(let t of v(o)){let w=Array.isArray(t.probes)?t.probes:[];l+=w.filter(d=>n(d)?.status==="fail").length,g+=Array.isArray(t.issues)?t.issues.length:0;let a=n(t.probeSummary);if(a){let d=c(a,"blockingFindings"),h=w.filter(k=>n(k)?.status==="fail").length+(Array.isArray(t.issues)?t.issues.length:0);if(d!==h)throw new Error("Doctor project probeSummary.blockingFindings contradicts failed probes and runtime issues.");let E=d>0?"blocked":c(a,"advisoryFindings")>0?"attention":"passed";if(a.verdict!==E||t.verdict!==E)throw new Error("Doctor project verdict contradicts its probe summary.")}}if(l+g>0&&u===0)throw new Error("Doctor evidence contains blocking findings but healthScore.errors is zero.")}export{y as a,m as b,R as c,S as d};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var P="workspace-knowledge-search.v1";function w(e){return e.trim().toLowerCase()}var T=new WeakMap;function E(e){let n=T.get(e);if(n)return n;let r=new Map(e.relations.map(o=>[o.id,o])),s=new Map(e.entities.map(o=>[o.id,o])),a=new Map(e.proofs.map(o=>[o.id,o])),d=new Map,g=new Map,u=(o,i)=>{let l=g.get(o)??[];l.push(i),g.set(o,l);};for(let o of e.entities){let i=[o.id,o.label,o.identity.key,...o.kind==="project"&&o.projectId?[o.projectId]:[],...o.identity.aliases];for(let l of new Set(i.map(w))){let h=d.get(l)??[];h.push(o),d.set(l,h);}}for(let o of e.relations)u(o.from,{from:o.from,to:o.to,relationId:o.id,kind:o.kind,direction:"forward",proofIds:o.proofIds}),u(o.to,{from:o.to,to:o.from,relationId:o.id,kind:o.kind,direction:"reverse",proofIds:o.proofIds});for(let o of d.values())o.sort((i,l)=>i.id.localeCompare(l.id));for(let o of g.values())o.sort((i,l)=>i.to.localeCompare(l.to)||i.relationId.localeCompare(l.relationId));let c={entitiesById:s,relationsById:r,entitiesByAlias:d,proofsById:a,adjacency:g};return T.set(e,c),c}function S(e,n){let r=E(e),s=r.relationsById.get(n);if(s)return {found:true,targetType:"relation",relation:s};let a=w(n),d=r.entitiesByAlias.get(a)??[];return d.length===1?{found:true,targetType:"entity",entity:d[0]}:{found:false,query:n,candidates:d.map(g=>g.id).sort()}}function _(e,n){let r=S(e,n);if(!r.found)return {query:n,found:false,target:null,proofs:[],candidates:r.candidates};let s=r.targetType==="entity"?r.entity:r.relation,a=new Set(s.proofIds);return {query:n,found:true,target:s,candidates:[],proofs:[...a].map(d=>E(e).proofsById.get(d)).filter(d=>!!d).sort((d,g)=>d.id.localeCompare(g.id))}}function O(e,n,r){let s=S(e,n),a=S(e,r);if(!s.found||s.targetType!=="entity"||!a.found||a.targetType!=="entity")return {from:n,to:r,found:false,resolvedFrom:s.found&&s.targetType==="entity"?s.entity.id:null,resolvedTo:a.found&&a.targetType==="entity"?a.entity.id:null,entityPath:[],hops:[],proofs:[]};let d=E(e),g=[s.entity.id],u=new Map,c=new Set(g),o=0;for(;o<g.length&&!c.has(a.entity.id);){let p=g[o++];for(let f of d.adjacency.get(p)??[])c.has(f.to)||(c.add(f.to),u.set(f.to,f),g.push(f.to));}if(!c.has(a.entity.id))return {from:n,to:r,found:false,resolvedFrom:s.entity.id,resolvedTo:a.entity.id,entityPath:[],hops:[],proofs:[]};let i=[],l=a.entity.id;for(;l!==s.entity.id;){let p=u.get(l);if(!p)break;i.push(p),l=p.from;}i.reverse();let h=new Set(i.flatMap(p=>p.proofIds));return {from:n,to:r,found:true,resolvedFrom:s.entity.id,resolvedTo:a.entity.id,entityPath:[s.entity.id,...i.map(p=>p.to)],hops:i,proofs:[...h].map(p=>d.proofsById.get(p)).filter(p=>!!p).sort((p,f)=>p.id.localeCompare(f.id))}}function j(e,n){return e.entities.filter(r=>!n||r.kind===n).sort((r,s)=>r.kind.localeCompare(s.kind)||r.label.localeCompare(s.label))}function v(e){let n=Object.values(e.attributes).flatMap(r=>Array.isArray(r)?r:[r]);return [e.id,e.kind,e.label,e.projectId??"",e.identity.key,...e.identity.aliases,...n.map(r=>String(r??""))].join(" ").toLowerCase()}var x=new Set(["a","an","and","are","as","at","be","been","being","by","can","check","could","did","do","does","find","for","from","give","had","has","have","how","i","in","into","is","it","its","may","might","of","on","or","our","show","should","that","the","their","them","then","there","these","they","this","those","tell","to","was","we","were","what","when","where","which","who","why","will","with","would","you","your"]);function W(e){return w(e.replace(/([a-z0-9])([A-Z])/g,"$1 $2")).split(/[^a-z0-9]+/u).filter(n=>n.length>1)}function C(e){let n=w(e.label),r=w(e.identity.key),s=e.identity.aliases.map(w),a=v(e);return {entity:e,label:n,identity:r,aliases:s,haystack:a,labelTokens:new Set(W(n)),identityTokens:new Set(W(r)),aliasTokens:new Set(s.flatMap(W)),allTokens:new Set(W(a))}}function I(e,n){return e.has(n)||n.length>=3&&[...e].some(r=>r.startsWith(n))}function R(e,n,r,s){let{label:a,identity:d,aliases:g,haystack:u}=e,c=0;(a===n||d===n||g.includes(n))&&(c+=1e3),(a.startsWith(n)||d.startsWith(n))&&(c+=250),u.includes(n)&&(c+=100);let o=0;for(let i of r){let l=s.get(i)??1,h=I(e.labelTokens,i),p=I(e.identityTokens,i),f=I(e.aliasTokens,i),m=I(e.allTokens,i);m&&(o+=1),a===i?c+=80*l:h&&(c+=36*l),p&&(c+=24*l),f&&(c+=20*l),m&&(c+=10*l);}return r.length>0&&(c+=o/r.length*120),c}function D(e,n){let r=w(n.query),s=[...new Set(W(r))],a=s.filter(t=>!x.has(t)),d=a.length>0?a:s,g=Math.max(1,Math.min(Math.trunc(n.limit??12),100)),u=Math.max(0,Math.min(Math.trunc(n.relationsPerEntity??4),20)),c=e.entities.filter(t=>!n.kind||t.kind===n.kind).map(C),o=new Map(d.map(t=>{let y=c.filter(k=>I(k.allTokens,t)).length;return [t,Math.log((c.length+1)/(y+1))+1]})),i=c.map(t=>({entity:t.entity,score:R(t,r,d,o)})).filter(t=>r.length===0||t.score>0).sort((t,y)=>y.score-t.score||t.entity.kind.localeCompare(y.entity.kind)||t.entity.label.localeCompare(y.entity.label)),l=i.slice(0,g).map(t=>t.entity),h=new Set(l.map(t=>t.id)),p=new Map,f=e.relations.filter(t=>{if(!(h.has(t.from)||h.has(t.to)))return false;let k=h.has(t.from)?t.from:t.to,K=p.get(k)??0;return K>=u?false:(p.set(k,K+1),true)}),m=E(e),M=[...new Set(f.flatMap(t=>[t.from,t.to]).filter(t=>!h.has(t)))].map(t=>m.entitiesById.get(t)).filter(t=>!!t).map(({id:t,kind:y,label:k,projectId:K})=>({id:t,kind:y,label:k,...K?{projectId:K}:{}})).sort((t,y)=>t.kind.localeCompare(y.kind)||t.label.localeCompare(y.label)),b=[...new Set([...l.flatMap(t=>t.proofIds),...f.flatMap(t=>t.proofIds)])].map(t=>m.proofsById.get(t)).filter(t=>!!t).sort((t,y)=>t.id.localeCompare(y.id));return {schemaVersion:P,query:n.query,kind:n.kind??null,limit:g,totalMatches:i.length,truncated:i.length>l.length,entities:l,relatedEntities:M,relations:f,proofs:b}}export{P as a,S as b,_ as c,O as d,j as e,D as f};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {a as a$2}from'./chunk-
|
|
1
|
+
import {a as a$2}from'./chunk-FKWB66NQ.js';import {a as a$5}from'./chunk-2OIBHUVH.js';import {a as a$3,e}from'./chunk-BG4FWJJ3.js';import {d,a as a$1,e as e$1}from'./chunk-XBM2P45G.js';import {a}from'./chunk-AHLMIL2T.js';import a$4 from'chalk';import se from'fs';import b from'path';import {execa}from'execa';var G="autopilot-release-last-run.json",V="autopilot-release.json";function j(r){try{return JSON.parse(r)}catch{return null}}function Re(r){let e=b.resolve(r),n=a$5(e);if(!n)throw new Error("No Workspai workspace found in current directory or parents");return n}async function S(r,e){let n=process.argv[1];if(!n)return {exitCode:1,stdout:"",stderr:"RapidKit entrypoint is unavailable for autopilot execution.",crashed:true};try{let o=await execa(process.execPath,[n,...r],{cwd:e,reject:false,env:{...process.env,RAPIDKIT_AUTOPILOT_CHILD:"1"}});return {exitCode:Number(o.exitCode??1),stdout:o.stdout,stderr:o.stderr,crashed:false}}catch(o){return {exitCode:1,stdout:"",stderr:o instanceof Error?o.message:String(o),crashed:true}}}function re(r){let e=r.toLowerCase();return e==="pass"?"pass":e==="warn"?"warn":e==="fail"?"fail":"warn"}function oe(r){return r.summary.failed>0||r.gates.results.some(e=>e.status==="fail")?"fail":r.gates.results.some(e=>e.status==="warn")?"warn":"pass"}function Se(r){let e=r.filter(o=>o.status!=="skipped");if(e.length===0)return 100;let n=e.reduce((o,t)=>t.status==="pass"?o+1:t.status==="warn"?o+.6:o,0);return Math.round(n/e.length*100)}function be(r){return r.executionError?["Re-run: npx workspai autopilot release --mode audit --json","Inspect .workspai/reports/autopilot-release-last-run.json for execution failure details"]:r.blockers.length>0?["Run: npx workspai doctor workspace --plan","Run: npx workspai readiness --json --strict","Run: npx workspai workspace run test --affected --strict"]:r.hasWarnings&&r.mode!=="enforce"?["Review warning-level findings in autopilot report","Optionally run: npx workspai autopilot release --mode safe-fix"]:["Workspace is release-ready based on current autopilot policy"]}async function xe(r,e){await se.promises.mkdir(b.dirname(r),{recursive:true}),await se.promises.writeFile(r,`${JSON.stringify(e,null,2)}
|
|
2
2
|
`,"utf-8");}async function Me(r){let e$2=Re(r.workspacePath),n=r.mode,o=[],t=[],F,H,D,q,Q,X=0,f=false,T=0,L=0,N=-1,W=-1,c="skipped",d$1="skipped",ae=n==="enforce"?["doctor","workspace","--json","--strict"]:["doctor","workspace","--json","--ci"];if(r.skipPipelineStages)o.push({name:"doctor-workspace",status:"skipped",durationMs:0,summary:"doctor stage skipped (pipeline already executed)"},{name:"analyze",status:"skipped",durationMs:0,summary:"analyze stage skipped (pipeline already executed)"},{name:"readiness",status:"skipped",durationMs:0,summary:"readiness stage skipped (pipeline already executed)"});else {let s=Date.now(),l=await S([...ae],e$2),m=Date.now()-s;if(c="pass",l.crashed)c="fail",f=true,t.push(`doctor workspace execution error: ${l.stderr||"unknown error"}`);else if(l.exitCode===1)c="fail",t.push("doctor workspace command failed or reported errors");else if(l.exitCode===2)c="warn",t.push("doctor workspace reported warnings");else if(l.exitCode!==0)c="fail",t.push("doctor workspace command failed");else {let p=j(l.stdout),E=p&&p.healthScore&&typeof p.healthScore=="object"?p.healthScore:{},k=Number(E.errors??0),$=Number(E.warnings??0);Number.isFinite(k)&&k>0?(c="fail",t.push(`doctor workspace reports ${k} error(s)`)):Number.isFinite($)&&$>0&&(c="warn");}N=o.push({name:"doctor-workspace",status:c,durationMs:m,summary:c==="pass"?"doctor workspace passed":c==="warn"?"doctor workspace reported warnings":"doctor workspace reported errors"})-1,n==="enforce"&&c==="warn"&&t.push("doctor workspace reported warnings under enforce mode");let g=Date.now(),w=await S(["analyze","--json"],e$2),v=Date.now()-g;H=await d(e$2,a.analyze)??a$1(e$2,a.analyze);let i="pass";if(w.crashed)i="fail",f=true,t.push(`analyze execution error: ${w.stderr||"unknown error"}`);else if(w.exitCode!==0)i=w.exitCode===2?"warn":"fail",t.push(w.exitCode===2?"analyze reported needs-attention verdict":"analyze command failed or reported blocked verdict");else {let p=j(w.stdout),E=p&&p.summary&&typeof p.summary=="object"?p.summary:{},k=String(E.verdict??"ready");k==="blocked"?(i="fail",t.push("analyze reported blocked verdict")):k==="needs-attention"&&(i="warn");}o.push({name:"analyze",status:i,durationMs:v,summary:i==="pass"?"analyze passed":i==="warn"?"analyze reported needs-attention":"analyze reported blocked verdict"}),n==="enforce"&&i==="warn"&&t.push("analyze reported warnings under enforce mode");let P=Date.now(),h=await S(["readiness","--json"],e$2),y=Date.now()-P;if(d$1="fail",h.crashed)d$1="fail",f=true,t.push(`readiness execution error: ${h.stderr||"unknown error"}`);else if(h.exitCode!==0)d$1="fail",t.push("readiness command failed");else {let p=j(h.stdout),E=String(p?.overallStatus??"fail");if(d$1=re(E),typeof p?.evidencePath=="string"&&p.evidencePath.trim().length>0&&(F=p.evidencePath),d$1==="fail"){let k=Array.isArray(p?.blockingReasons)?p?.blockingReasons.filter($=>typeof $=="string"):[];k.length>0?t.push(...k.map($=>`readiness: ${$}`)):t.push("readiness overall status is fail");}}W=o.push({name:"readiness",status:d$1,durationMs:y,summary:`readiness overall status is ${d$1}`})-1,n==="enforce"&&d$1==="warn"&&t.push("readiness reported warnings under enforce mode");}let ne=Date.now(),z=await S(["doctor","workspace","--plan","--json"],e$2),ie=Date.now()-ne,R="warn";if(z.crashed)R="fail",f=true,t.push(`doctor remediation plan execution error: ${z.stderr||"unknown error"}`);else if(z.exitCode!==0)R="fail",t.push("doctor remediation plan command failed");else {let s=j(z.stdout),l=s&&s.remediationPlan&&typeof s.remediationPlan=="object"?s.remediationPlan:null,m=Number(l?.totalSteps??0),g=Number(l?.executableSteps??0);Number.isFinite(m)&&m>0&&(T=m),Number.isFinite(g)&&g>0&&(L=g),Number.isFinite(m)&&m===0?R="pass":R="warn";}if(o.push({name:"remediation-plan",status:R,durationMs:ie,summary:R==="pass"?"no remediation steps required":"remediation steps available"}),n==="enforce"&&R==="warn"&&t.push("remediation plan has pending steps under enforce mode"),n==="safe-fix"){let s=Date.now(),l=await S(["doctor","workspace","--apply"],e$2),m=Date.now()-s,g=l.crashed||l.exitCode!==0?"fail":"pass";if(l.crashed)f=true,t.push(`doctor remediation apply execution error: ${l.stderr||"unknown error"}`);else if(g==="fail")t.push("doctor remediation apply failed");else {X=L>0?L:T>0?T:1;let w=await S(["doctor","workspace","--json"],e$2);if(w.crashed)c="fail",f=true,t.push(`post-apply doctor execution error: ${w.stderr||"unknown error"}`);else if(w.exitCode!==0)c="fail",t.push("post-apply doctor workspace command failed");else {let i=j(w.stdout),P=i&&i.healthScore&&typeof i.healthScore=="object"?i.healthScore:{},h=Number(P.errors??0),y=Number(P.warnings??0);Number.isFinite(h)&&h>0?(c="fail",t.push(`post-apply doctor reports ${h} error(s)`)):Number.isFinite(y)&&y>0?c="warn":c="pass";}N>=0&&(o[N].status=c,o[N].summary=`doctor workspace post-apply status is ${c}`);let v=await S(["readiness","--json"],e$2);if(v.crashed)d$1="fail",f=true,t.push(`post-apply readiness execution error: ${v.stderr||"unknown error"}`);else if(v.exitCode!==0)d$1="fail",t.push("post-apply readiness command failed");else {let i=j(v.stdout),P=String(i?.overallStatus??"fail");if(d$1=re(P),typeof i?.evidencePath=="string"&&i.evidencePath.trim().length>0&&(F=i.evidencePath),d$1==="fail"){let h=Array.isArray(i?.blockingReasons)?i?.blockingReasons.filter(y=>typeof y=="string"):[];h.length>0?t.push(...h.map(y=>`post-apply readiness: ${y}`)):t.push("post-apply readiness overall status is fail");}}W>=0&&(o[W].status=d$1,o[W].summary=`readiness post-apply overall status is ${d$1}`);}o.push({name:"remediation-apply",status:g,durationMs:m,summary:g==="pass"?"safe remediation apply completed":"safe remediation apply failed"});}else o.push({name:"remediation-apply",status:"skipped",durationMs:0,summary:"remediation apply is skipped for this mode"});let le=Date.now(),x="pass",A="workspace test/build completed for selected projects";try{let s=await a$2({workspacePath:e$2,stage:"test",affected:true,since:r.since,parallel:r.parallel,maxWorkers:r.maxWorkers,strict:true,json:true,enforceGates:false});D=a$1(e$2,b.join(".workspai","reports",a$3)),await e(e$2,s),q=D;let l=oe(s);if(l==="fail")x="fail",A="workspace test stage failed for selected projects",t.push("workspace run test failed for selected projects");else {l==="warn"&&(x="warn",A="workspace test stage completed with warnings",n==="enforce"&&t.push("workspace run test reported warnings under enforce mode"));let m=await a$2({workspacePath:e$2,stage:"build",affected:true,since:r.since,parallel:r.parallel,maxWorkers:r.maxWorkers,strict:true,json:true,enforceGates:false});await e(e$2,m),Q=D;let g=oe(m);g==="fail"?(x="fail",A="workspace build stage failed for selected projects",t.push("workspace run build failed for selected projects")):g==="warn"&&(x="warn",A="workspace test/build completed with warnings",n==="enforce"&&t.push("workspace run test/build reported warnings under enforce mode"));}}catch(s){x="fail",A="workspace test/build orchestration failed",f=true,t.push(`workspace run orchestration error: ${s instanceof Error?s.message:String(s)}`);}let ce=Date.now()-le;o.push({name:"workspace-run-test-build",status:x,durationMs:ce,summary:A});let M=o.filter(s=>s.status==="warn").length,pe=o.filter(s=>s.status==="fail").length,_=n==="enforce"?o.some(s=>s.status==="warn"||s.status==="fail"):pe>0,C=[...new Set(t)],O=f||_?Math.max(1,C.length):0,ue=O>0?C:[],de=O===0?C:[],fe=Se(o),me=f||_?"blocked":M>0?"partial":"approved",ge=f?3:_?1:M>0?2:0,we=be({mode:n,executionError:f,blockers:C,hasWarnings:M>0}),Y=a$1(e$2,".workspai/reports"),he=b.join(Y,G),ke=b.join(Y,V),u={schemaVersion:"autopilot-release-v1",generatedAt:new Date().toISOString(),workspacePath:e$2,mode:n,summary:{releaseScore:fe,verdict:me,blockers:O,warnings:M,safeFixesApplied:X,manualActions:C.length,exitCode:ge},stages:o,blockingReasons:ue,warningReasons:de,nextActions:we,artifacts:{reportPath:he,aliasEvidencePath:ke,analyzeEvidencePath:H,readinessEvidencePath:F,workspaceRunEvidencePath:D,workspaceRunTestPath:q,workspaceRunBuildPath:Q},enterpriseControls:{jsonReady:true,evidencePath:`.workspai/reports/${G}`,aliasEvidencePath:`.workspai/reports/${V}`}};if(await e$1(e$2,`.workspai/reports/${G}`,u),await e$1(e$2,`.workspai/reports/${V}`,u),r.output&&await xe(b.resolve(r.output),u),!r.json){console.log(a$4.bold.cyan(`
|
|
3
3
|
\u{1F680} Workspai Autopilot Release
|
|
4
4
|
`)),console.log(a$4.bold(`Workspace: ${a$4.cyan(b.basename(e$2))}`)),console.log(a$4.gray(`Path: ${e$2}`)),console.log(a$4.white(`Mode: ${n}`)),console.log(a$4.white(`Verdict: ${u.summary.verdict==="approved"?a$4.green("approved"):u.summary.verdict==="partial"?a$4.yellow("partial"):a$4.red("blocked")}`)),console.log(a$4.white(`Release score: ${u.summary.releaseScore}`));for(let s of u.stages){let l=s.status==="pass"?a$4.green("PASS"):s.status==="warn"?a$4.yellow("WARN"):s.status==="skipped"?a$4.gray("SKIP"):a$4.red("FAIL");console.log(` - ${s.name}: ${l} ${s.summary} (${s.durationMs}ms)`);}if(u.blockingReasons.length>0){console.log(a$4.bold.red(`
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import d from'os';import e from'path';import m from'fs-extra';function g(n=process.platform){return n==="win32"?"windows":n==="linux"?"linux":n==="darwin"?"macos":"other"}function p(n=process.platform){return g(n)==="windows"}function w(n=process.platform){return p(n)}var x=new Set(["npx","npm","yarn","pnpm"]);function S(n){return n==="npx"?"npx-cli.js":"npm-cli.js"}function f(n){return p(n)?e.win32:e.posix}function h(n,o,i){let t=o.npm_execpath;if(!t)return null;let r=f(i),s=r.basename(t).toLowerCase();if(n==="npx"&&s!=="npx-cli.js"){let a=r.join(r.dirname(t),"npx-cli.js");return m.existsSync(a)?a:null}if(n==="npm"&&s==="npx-cli.js"){let a=r.join(r.dirname(t),"npm-cli.js");return m.existsSync(a)?a:null}return m.existsSync(t)?t:null}function j(n,o,i){if(n!=="npm"&&n!=="npx")return [];let t=S(n),r=f(i),s=r.dirname(o),a=r.dirname(s);return [r.join(s,"node_modules","npm","bin",t),r.join(a,"lib","node_modules","npm","bin",t),r.join(a,"lib64","node_modules","npm","bin",t),r.join("/usr","lib","node_modules","npm","bin",t),r.join("/usr","local","lib","node_modules","npm","bin",t),r.join("/usr","share","nodejs","npm","bin",t)]}function D(n,o=process.platform){return y(n,o).command}function y(n,o=process.platform,i=process.env,t=process.execPath){let r=n.trim();if(!x.has(r))return {command:r,prefixArgs:[]};if(r==="npm"||r==="npx"){let c=h(r,i,o);if(c)return {command:t,prefixArgs:[c]};for(let l of j(r,t,o))if(m.existsSync(l))return {command:t,prefixArgs:[l]}}let s=f(o),a=s.dirname(t),u=p(o)?".cmd":"",P=[s.join(a,`${r}${u}`),s.join(a,r)];for(let c of P)if(m.existsSync(c))return {command:c,prefixArgs:[]};return r==="npm"?{command:"corepack",prefixArgs:["npm"]}:{command:r,prefixArgs:[]}}function k(n,o=process.platform,i=process.execPath){let t=p(o)?";":":",r=f(o).dirname(i),s=(n??process.env.PATH??"").split(t).filter(Boolean);return s.includes(r)||s.unshift(r),s.join(t)}var N=["npm_config_package","npm_config__package"];function A(n=process.env,o=process.platform,i=process.execPath){let t=e.join(d.tmpdir(),"rapidkit-corepack"),r={...n,PATH:k(n.PATH,o,i),COREPACK_HOME:n.COREPACK_HOME??t};for(let s of N)delete r[s];return r}function O(n=process.env,o=process.platform,i=process.execPath){return {...A(n,o,i),npm_config_engine_strict:"true"}}function L(n=process.platform){return p(n)?"python":"python3"}function H(n=process.platform){return p(n)?["python","py","python3"]:["python3","python"]}function B(n=14,o=10,i=process.platform){let t=[];if(p(i)){for(let r=n;r>=o;r-=1)t.push({command:"py",args:[`-3.${r}`,"--version"]});return t.push({command:"py",args:["-3","--version"]}),t.push({command:"python",args:["--version"]}),t}for(let r=n;r>=o;r-=1)t.push({command:`python3.${r}`,args:["--version"]});return t.push({command:"python3",args:["--version"]}),t.push({command:"python",args:["--version"]}),t}function K(n,o=process.platform){return p(o)?e.join(n,"Scripts"):e.join(n,"bin")}function T(n,o=process.platform){return p(o)?e.join(n,"Scripts","python.exe"):e.join(n,"bin","python")}function V(n,o=process.platform){return p(o)?e.join(n,"Scripts","rapidkit.exe"):e.join(n,"bin","rapidkit")}function I(n,o=process.platform){return p(o)?e.join(n,"Scripts","activate"):e.join(n,"bin","activate")}function F(n,o=process.platform){return p(o)?[e.join(n,"workspai.cmd"),e.join(n,".workspai","rapidkit.cmd"),e.join(n,"rapidkit.cmd"),e.join(n,".rapidkit","rapidkit.cmd")]:[e.join(n,"workspai"),e.join(n,".workspai","rapidkit"),e.join(n,"rapidkit"),e.join(n,".rapidkit","rapidkit")]}function J(n=process.env,o=process.platform){let i=n.HOME||n.USERPROFILE||d.homedir();return e.join(i,".workspai")}function E(n=process.env,o=process.platform){let i=n.HOME||n.USERPROFILE||d.homedir();return e.join(i,".rapidkit")}function U(n=process.env,o=process.platform){let i=[e.join(J(n,o),"workspaces.json"),e.join(E(n,o),"workspaces.json")];if(p(o)){let t=n.XDG_CONFIG_HOME||n.APPDATA;t&&(i.push(e.join(t,"workspai","workspaces.json")),i.push(e.join(t,"rapidkit","workspaces.json")));}return [...new Set(i)]}function G(n=process.env,o=process.platform){let i=[];return p(o)?(n.USERPROFILE&&i.push(e.join(n.USERPROFILE,".local","bin")),n.APPDATA&&i.push(e.join(n.APPDATA,"Python","Scripts")),n.LOCALAPPDATA&&i.push(e.join(n.LOCALAPPDATA,"Programs","Python","Scripts"))):i.push(e.join(d.homedir(),".local","bin")),[...new Set(i.filter(Boolean))]}export{g as a,p as b,w as c,D as d,y as e,k as f,A as g,O as h,L as i,H as j,B as k,K as l,T as m,V as n,I as o,F as p,J as q,E as r,U as s,G as t};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import {a as a$1}from'./chunk-AFIFZTOY.js';import {a,c,b,i}from'./chunk-AHLMIL2T.js';import j from'path';var m=Object.keys(a).flatMap(r=>{let o=r,a$1=b[o],t=c[o];return !a$1||!t?[]:[{artifactPath:a[o],schemaVersion:a$1,contractPath:t}]}),d=[{artifactPath:".workspai/workspace-link.local.json",schemaVersion:"project-workspace-link.v1",contractPath:"contracts/project-workspace-link.v1.json"},{artifactPath:".workspai/reports/project-context-agent.json",schemaVersion:"project-context-agent.v1",contractPath:"contracts/workspace-intelligence/project-context-agent.v1.json"},{artifactPath:".workspai/workspace.contract.json",schemaVersion:1,contractPath:"contracts/workspace-contract.v1.json"},{artifactPath:".workspai/cache/workspace-model.v1.json",schemaVersion:"workspace-model-cache.v1",contractPath:"contracts/workspace-model-cache.v1.json"},{artifactPath:".workspai/workspace-registry.v1.json",schemaVersion:"workspace-registry.v1",contractPath:"contracts/workspace-registry.v1.json"},{artifactPath:".workspai/compatibility-matrix.json",schemaVersion:"rapidkit.compatibility-matrix.v1",contractPath:"contracts/compatibility-matrix.v1.json"},{artifactPath:".workspai/reports/doctor-workspace-cache.json",schemaVersion:"doctor-workspace-cache-v2",contractPath:"contracts/doctor-workspace-cache.v2.json"},{artifactPath:".workspai/reports/bootstrap-compliance.latest.json",schemaVersion:"bootstrap-compliance.v1",contractPath:"contracts/bootstrap-compliance.v1.json"},{artifactPath:".workspai/reports/mirror-ops.latest.json",schemaVersion:"mirror-ops.v1",contractPath:"contracts/mirror-ops.v1.json"},{artifactPath:".workspai/reports/transparency-evidence.latest.json",schemaVersion:"transparency-evidence.v1",contractPath:"contracts/transparency-evidence.v1.json"},{artifactPath:".workspai/reports/share-bundle.json",schemaVersion:"1.1",schemaVersionField:"schema_version",contractPath:"contracts/workspace-share-bundle.v1.json"},{artifactPath:".workspai/reports/doctor-project-last-run.json",schemaVersion:"doctor-project-evidence-v1",contractPath:"contracts/doctor-project-evidence.v1.json"},{artifactPath:".workspai/reports/project-test-coverage-last-run.json",schemaVersion:"workspai.project-test-coverage.v1",contractPath:"contracts/project-test-coverage.v1.json"},{artifactPath:".workspai/reports/doctor-remediation-plan-last-run.json",schemaVersion:"doctor-remediation-plan-v2",contractPath:"contracts/doctor-remediation-plan.v2.json"},{artifactPath:".workspai/reports/artifact-remediation-plan-last-run.json",schemaVersion:"artifact-remediation-plan-v1",contractPath:"contracts/artifact-remediation-plan.v1.json"},{artifactPath:".workspai/reports/doctor-fix-result-last-run.json",schemaVersion:"rapidkit-doctor-fix-result-v1",contractPath:"contracts/workspace-intelligence/doctor-fix-result.v1.json"},{artifactPath:".workspai/reports/pipeline-last-run.json",schemaVersion:"rapidkit-pipeline-v1",contractPath:"contracts/pipeline-last-run.v1.json"},{artifactPath:".workspai/reports/autopilot-release-last-run.json",schemaVersion:"autopilot-release-v1",contractPath:"contracts/autopilot-release.v1.json"},{artifactPath:".workspai/reports/autopilot-release.json",schemaVersion:"autopilot-release-v1",contractPath:"contracts/autopilot-release.v1.json"},{artifactPath:".workspai/reports/workspace-run-last.json",schemaVersion:"workspace-run-v1",contractPath:"contracts/workspace-run-last.v1.json"},{artifactPath:".workspai/reports/workspai-mcp-design.json",schemaVersion:"workspai-mcp-design.v1",contractPath:"contracts/workspace-intelligence/mcp-design.v1.json"},{artifactPath:".workspai/reports/rapidkit-mcp-design.json",schemaVersion:"workspai-mcp-design.v1",contractPath:"contracts/workspace-intelligence/mcp-design.v1.json"},{artifactPath:".workspai/reports/workspace-why-last-run.json",schemaVersion:b.explain,contractPath:c.explain},{artifactPath:".workspai/reports/workspace-trace-last-run.json",schemaVersion:b.explain,contractPath:c.explain},{artifactPath:".vscode/workspai-agent-hooks.json",schemaVersion:"workspai-agent-hooks.v1",contractPath:"contracts/workspace-intelligence/agent-hooks.v1.json"},{artifactPath:".workspai/reports/infra-plan.json",schemaVersion:"rapidkit.infra-plan.v1",contractPath:"contracts/infra-plan.v1.json"}],u={".workspai/workspace-link.local.json":[["adopt"],["import"],["project","workspace","relink"],["workspace","sync"]],".workspai/reports/project-context-agent.json":[["adopt"],["import"],["workspace","sync"],["workspace","agent-sync","--write"]],".workspai/workspace.contract.json":[["workspace","sync"],["workspace","contract","sync"]],[a.intelligenceRun]:[["workspace","intelligence","run"]],[a.snapshot]:[["workspace","snapshot"]],[a.history]:[["workspace","feedback","record","--json"]],[a.evaluationLive]:[["workspace","eval","init"],["workspace","eval","record","--json"]],[a.evaluationLastRun]:[["workspace","eval","report","--json"]],".workspai/cache/workspace-model.v1.json":[["workspace","model"]],".workspai/workspace-registry.v1.json":[["workspace","sync"]],".workspai/compatibility-matrix.json":[["bootstrap"]],".workspai/reports/doctor-workspace-cache.json":[["doctor","workspace"]],".workspai/reports/bootstrap-compliance.latest.json":[["bootstrap"]],".workspai/reports/mirror-ops.latest.json":[["mirror","status"]],".workspai/reports/transparency-evidence.latest.json":[["mirror","sync"]],".workspai/reports/share-bundle.json":[["workspace","share"]],".workspai/reports/doctor-project-last-run.json":[["doctor","project"]],".workspai/reports/project-test-coverage-last-run.json":[["project","coverage"]],".workspai/reports/doctor-remediation-plan-last-run.json":[["workspace","remediation-plan"]],".workspai/reports/artifact-remediation-plan-last-run.json":[["workspace","remediation-plan"]],".workspai/reports/doctor-fix-result-last-run.json":[["doctor","workspace"]],".workspai/reports/pipeline-last-run.json":[["pipeline"]],".workspai/reports/autopilot-release-last-run.json":[["autopilot","release"]],".workspai/reports/autopilot-release.json":[["autopilot","release"]],".workspai/reports/workspace-run-last.json":[["workspace","run"]],".workspai/reports/workspai-mcp-design.json":[["workspace","agent-sync","--write"]],".workspai/reports/rapidkit-mcp-design.json":[["workspace","agent-sync","--write"]],".workspai/reports/workspace-why-last-run.json":[["workspace","why"]],".workspai/reports/workspace-trace-last-run.json":[["workspace","trace"]],".vscode/workspai-agent-hooks.json":[["workspace","agent-sync"]],".workspai/reports/infra-plan.json":[["infra","plan"]]};function v(r){let o=Object.values(i).filter(t=>t.produces.includes(r)).map(t=>[...t.command]),a=u[r]??[];return [...o,...a.map(t=>[...t])]}var k=Object.freeze(Object.fromEntries([...m,...d].map(r=>[r.artifactPath,{...r,producerCommands:v(r.artifactPath)}])));function w(r){return r.split(j.sep).join("/").replace(/^\.\//,"")}var P=[{pattern:/^\.workspai\/reports\/bootstrap-compliance-[^/]+\.json$/,canonicalPath:".workspai/reports/bootstrap-compliance.latest.json"},{pattern:/^\.workspai\/reports\/mirror-ops-[^/]+\.json$/,canonicalPath:".workspai/reports/mirror-ops.latest.json"},{pattern:/^\.workspai\/reports\/transparency-evidence-[^/]+\.json$/,canonicalPath:".workspai/reports/transparency-evidence.latest.json"},{pattern:/^\.workspai\/reports\/projects\/[^/]+\/doctor-project-last-run\.json$/,canonicalPath:".workspai/reports/doctor-project-last-run.json"},{pattern:/^\.workspai\/reports\/projects\/[^/]+\/project-test-coverage-last-run\.json$/,canonicalPath:".workspai/reports/project-test-coverage-last-run.json"}];function f(r){let o=w(r),a=k[o];if(a)return a;let t=P.find(e=>e.pattern.test(o));return t?k[t.canonicalPath]??null:null}function E(r,o,a=r){let t=w(r),e=f(r);if(!e){if(t.startsWith(".workspai/reports/")&&t.endsWith(".json"))throw new Error(`${a} is a public workspace report without a registered artifact contract`);return}let h=e.schemaVersionField??"schemaVersion",i=o&&typeof o=="object"?o[h]:void 0;if(i!==e.schemaVersion)throw new Error(`${a} schemaVersion is ${String(i)}, expected ${e.schemaVersion}`);a$1(o,e.contractPath,a);}
|
|
2
|
+
export{f as a,E as b};
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import {c}from'./chunk-AL237TSJ.js';import {d as d$1,b,a as a$2}from'./chunk-3RBUSW7H.js';import {d}from'./chunk-EWZZUQBR.js';import {a as a$1}from'./chunk-AFIFZTOY.js';import {a}from'./chunk-AHLMIL2T.js';import {t,h,g}from'./chunk-MOSXTVPU.js';import z from'crypto';import I from'fs';import k from'fs/promises';import p from'path';import ne from'fs-extra';var oe="project-context-agent.v1",Ie=["managed","local","off"],X="<!-- WORKSPAI:PROJECT-GROUNDING:START -->",q="<!-- WORKSPAI:PROJECT-GROUNDING:END -->";function G(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:null}async function v(e){try{return JSON.parse(await k.readFile(e,"utf8"))}catch(t){return null}}function E(e){return e.replace(/\\/g,"/").replace(/^\.\/+/,"")}function W(e,t,r){let o=e.replace(/\\/g,"/"),s=/^[A-Za-z]:\//.test(o);if(!p.isAbsolute(e)&&!s)return E(o);if(s&&process.platform!=="win32")return null;let i=p.resolve(e),a=p.relative(r,i);if(a&&!a.startsWith("..")&&!p.isAbsolute(a))return E(a);let c=p.relative(t,i);return c&&!c.startsWith("..")&&!p.isAbsolute(c)?`workspace:${E(c)}`:null}function w(e,t,r){return [[r,"project:"],[r.replace(/\\/g,"/"),"project:"],[t,"workspace:"],[t.replace(/\\/g,"/"),"workspace:"]].reduce((s,[i,a])=>i.length>0?s.split(i).join(a):s,e)}function Z(e,t){return G(e?.adoption)?.mode==="linked"?"adopted":G(e?.import)?"imported":t}function se(e){if(!e.model)return null;let t=E(e.relativePath);return e.model.projects.find(r=>r.name===e.projectName||E(r.path)===t)??null}function B(e,t){e[t]=(e[t]??0)+1;}function ie(e,t){if(!e)return {entityCount:0,relationCount:0,proofCount:0,entitiesByKind:{},relationsByKind:{},relatedProjects:[],proofArtifacts:[],entities:[],relations:[],proofs:[],topology:{status:"unavailable",dependencies:[],dependents:[]},diagnostics:[]};let r=e.entities.find(n=>n.kind==="project"&&(n.id===t||n.label===t||n.projectId===t)),o=new Set(e.entities.filter(n=>n.projectId===t||n.id===r?.id||n.kind==="project"&&n.label===t).map(n=>n.id));r&&o.add(r.id);let s=e.relations.filter(n=>o.has(n.from)||o.has(n.to)),i=new Set(o);for(let n of s)i.add(n.from),i.add(n.to);let a=e.entities.filter(n=>i.has(n.id)),c=new Set,f={},y={};for(let n of a){B(f,n.kind);for(let d of n.proofIds)c.add(d);}for(let n of s){B(y,n.kind);for(let d of n.proofIds)c.add(d);}let m=e.proofs.filter(n=>c.has(n.id)),h=[...new Set(e.entities.filter(n=>i.has(n.id)&&n.projectId&&n.projectId!==t).map(n=>n.projectId))].sort(),j=e.diagnostics.filter(n=>n.entityIds?.some(d=>i.has(d))||n.relationIds?.some(d=>s.some(R=>R.id===d))).map(n=>({code:n.code,severity:n.severity,message:n.message,...n.recommendation?{recommendation:n.recommendation}:{}})),P=(n,d)=>({project:d,kind:n.kind,source:n.source,confidence:n.confidence,evidence:[...new Set(n.evidence.map(R=>R.file.replace(/\\/g,"/")))].sort()}),g=e.projectTopology.edges.filter(n=>n.from===t).map(n=>P(n,n.to)).sort((n,d)=>`${n.project}:${n.kind}`.localeCompare(`${d.project}:${d.kind}`)),u=e.projectTopology.edges.filter(n=>n.to===t).map(n=>P(n,n.from)).sort((n,d)=>`${n.project}:${n.kind}`.localeCompare(`${d.project}:${d.kind}`));return {entityCount:a.length,relationCount:s.length,proofCount:m.length,entitiesByKind:f,relationsByKind:y,relatedProjects:h,proofArtifacts:[...new Set(m.map(n=>n.artifact))].sort(),entities:[...a].sort((n,d)=>n.id.localeCompare(d.id)).slice(0,96),relations:[...s].sort((n,d)=>n.id.localeCompare(d.id)).slice(0,128),proofs:[...m].sort((n,d)=>n.id.localeCompare(d.id)).slice(0,128),topology:{status:g.length>0||u.length>0?"proven":e.projectTopology.nodes.some(n=>n.id===t)?"unproven":"unavailable",dependencies:g,dependents:u},diagnostics:j}}function Q(e,t,r){return Array.isArray(e)?e.map(o=>typeof o=="string"?w(o,t,r):o):typeof e=="string"?w(e,t,r):e}function ae(e,t,r){return {id:e.id,kind:e.kind,label:w(e.label,t,r),attributes:Object.fromEntries(Object.entries(e.attributes).map(([o,s])=>[o,Q(s,t,r)])),proofIds:[...e.proofIds].sort()}}function ce(e,t,r){let o=(...i)=>e.filter(a=>i.includes(a.kind)).map(a=>ae(a,t,r)).slice(0,32),s=[];for(let i of e){for(let[a,c]of Object.entries(i.attributes))if(/(?:^|[-_.])ports?(?:$|[-_.])/i.test(a)&&(s.push({entityId:i.id,label:w(i.label,t,r),attribute:a,value:Q(c,t,r)}),s.length>=32))break;if(s.length>=32)break}return {services:o("service"),apis:o("api"),endpoints:o("endpoint"),dataStores:o("database","queue"),deployments:o("container","deployment","environment"),pipelines:o("pipeline"),tests:o("test-suite"),owners:o("owner"),decisions:o("decision"),ports:s}}function le(e,t,r){let o=W(e.artifact,t,r);return o?{id:e.id,provider:e.provider,artifact:o,...e.pointer?{pointer:w(e.pointer,t,r)}:{},...e.line!==void 0?{line:e.line}:{},derivation:e.derivation,trust:e.trust,confidence:e.confidence,freshness:e.freshness}:null}async function pe(e,t,r){let o=[],s=await v(p.join(e,".workspai","reports","INDEX.json"));if(Array.isArray(s?.blockers))for(let a of s.blockers)typeof a=="string"&&(a.startsWith(`${r}:`)||a.includes(`project:${r}`)||a.includes(`project ${r}`))&&o.push({source:"workspace-report-index",severity:"error",message:w(a,e,t)});let i=await v(p.join(e,".workspai","reports","doctor-project-last-run.json"));if(i?.projectName===r){if(Array.isArray(i.project?.issues))for(let a of i.project.issues)typeof a=="string"&&o.push({source:"doctor-project",severity:"error",message:w(a,e,t)});if(Array.isArray(i.project?.probes))for(let a of i.project.probes){let c=G(a);if(!c||!["fail","warn"].includes(String(c.status)))continue;let f=typeof c.reason=="string"?c.reason:typeof c.label=="string"?c.label:"Project Doctor reported unresolved evidence.";o.push({source:"doctor-project",severity:c.status==="fail"?"error":"warning",message:w(f,e,t),...typeof c.id=="string"?{code:c.id}:{}});}}return [...new Map(o.map(a=>[`${a.source}:${a.code??""}:${a.message}`,a])).values()].slice(0,32)}function O(e,t=[]){return typeof e=="string"?/^[A-Za-z]:[\\/]/.test(e)||/(?:^|[\s("'`])[A-Za-z]:[\\/]/.test(e)||/(?:^|[\s("'`])\/(?:Users|home|private|var|opt|srv|mnt|Volumes|tmp)\//.test(e)||t.some(r=>r.length>0&&(e.includes(r)||e.includes(r.replace(/\\/g,"/")))):Array.isArray(e)?e.some(r=>O(r,t)):e&&typeof e=="object"?Object.values(e).some(r=>O(r,t)):false}function de(e){return z.createHash("sha256").update(JSON.stringify(e)).digest("hex")}async function ge(e){let t$1=p.resolve(e.workspacePath),r=p.resolve(e.projectPath),o=t(r,"project.json").find(l=>I.existsSync(l)),s=o?await v(o):null,i=await v(p.join(t$1,".workspai","workspace.contract.json")),a$2=p.resolve(r),c=i?.projects?.find(l=>l.externalPath?p.resolve(l.externalPath)===a$2:!l.relativePath||l.relativePath.startsWith("external/")?false:p.resolve(t$1,l.relativePath)===a$2)??i?.projects?.find(l=>l.slug===e.projectName||l.slug===p.basename(r)),f=e.projectName??(typeof s?.name=="string"?s.name:void 0)??c?.slug??p.basename(r),y=c?.relativePath??(()=>{let l=E(p.relative(t$1,r));return !l||l.startsWith("..")?`external/${f}`:l})(),m=await v(p.join(t$1,a.model)),h=await v(p.join(t$1,a.knowledgeGraph)),j=m?d(m):void 0,P=!!(j&&h?.source.hash===j),g=se({model:m,projectName:f,relativePath:y}),u=ie(P?h:null,f),n=await pe(t$1,r,f),d$1=u.proofs.map(l=>l.freshness),R=h?!P||d$1.includes("stale")?"stale":d$1.includes("unknown")?"unknown":"fresh":"missing",ee=m?m.factFreshness?.status??"unknown":"missing",te=[...m?[]:[{code:"project.context.model-missing",severity:"warning",message:"The canonical Workspace Model has not been generated yet. Refresh workspace intelligence before relying on project topology."}],...m&&!g?[{code:"project.context.project-not-materialized",severity:"warning",message:"The project is registered in the workspace contract but is not present in the current Workspace Model."}]:[],...h?[]:[{code:"project.context.graph-missing",severity:"warning",message:"The Workspace Knowledge Graph has not been generated yet. Run the workspace intelligence loop to build proof-backed relationships."}],...h&&!P?[{code:"project.context.graph-model-mismatch",severity:"warning",message:"The persisted Knowledge Graph does not match the current Workspace Model and was excluded from this project lens."}]:[]],re=Z(s,e.relationship??c?.relationship??"managed"),N={schemaVersion:oe,generatedAt:(e.now??new Date).toISOString(),workspace:{name:i?.workspace?.name??m?.workspace.name??p.basename(t$1),...i?.workspace?.profile||m?.workspace.profile?{profile:i?.workspace?.profile??m?.workspace.profile}:{},relationship:re,contract:".workspai/workspace.contract.json",model:a.model,knowledgeGraph:a.knowledgeGraph,access:{localBinding:".workspai/workspace-link.local.json",canonicalEvidenceAvailableAtGeneration:true}},project:{name:f,relativePath:y,...g?.kind?{kind:g.kind}:{},...g?.runtime||c?.runtime?{runtime:g?.runtime??c?.runtime}:{},...g?.framework||c?.framework?{framework:g?.framework??c?.framework}:{},...g?.kit||c?.kit?{kit:g?.kit??c?.kit}:{},...g?.supportTier?{supportTier:g.supportTier}:{},commands:{supported:[...g?.commands.supported??[]].sort(),unsupported:[...g?.commands.unsupported??[]].sort(),fleetStages:[...g?.commands.fleetStages??[]].sort()},importantFiles:[...new Set((g?.importantFiles??[]).map(l=>W(l,t$1,r)).filter(l=>l!==null))].sort()},intelligence:{...m?.generatedAt?{modelGeneratedAt:m.generatedAt}:{},...h?.generatedAt?{graphGeneratedAt:h.generatedAt}:{},...h?.source.hash?{graphModelHash:h.source.hash}:{},entityCount:u.entityCount,relationCount:u.relationCount,proofCount:u.proofCount,entitiesByKind:u.entitiesByKind,relationsByKind:u.relationsByKind,relatedProjects:u.relatedProjects,freshness:{model:ee,graph:R,graphMatchesModel:P},topology:{...u.topology,dependencies:u.topology.dependencies.map(l=>({...l,evidence:l.evidence.map(b=>W(b,t$1,r)).filter(b=>b!==null)})),dependents:u.topology.dependents.map(l=>({...l,evidence:l.evidence.map(b=>W(b,t$1,r)).filter(b=>b!==null)}))},surfaces:ce(u.entities,t$1,r),diagnostics:[...te,...u.diagnostics].map(l=>({...l,message:w(l.message,t$1,r),...l.recommendation?{recommendation:w(l.recommendation,t$1,r)}:{}}))},evidence:{readOrder:[".workspai/PROJECT-GROUNDING.md",".workspai/reports/project-context-agent.json","AGENTS.md","workspace:.workspai/reports/INDEX.json","workspace:.workspai/reports/workspace-context-agent.json",`workspace:${a.model}`,`workspace:${a.knowledgeGraph}`],projectProofArtifacts:[...new Set(u.proofArtifacts.map(l=>W(l,t$1,r)).filter(l=>l!==null))],relations:u.relations.map(l=>({id:l.id,from:l.from,to:l.to,kind:l.kind,derivation:l.derivation,trust:l.trust,confidence:l.confidence,proofIds:[...l.proofIds].sort()})),proofs:u.proofs.map(l=>le(l,t$1,r)).filter(l=>l!==null)},blockers:n,commands:{refresh:"npx workspai workspace intelligence run --for-agent generic --strict --json",verify:"npx workspai workspace verify --strict --json",graphSearch:`npx workspai workspace graph search ${JSON.stringify(f)} --limit 12 --json`,doctor:"npx workspai doctor project --json",workspaceStatus:"npx workspai project workspace status --json"}};if(O(N,[t$1,r]))throw new Error("Project context lens rejected a non-portable absolute path.");let L={...N,integrity:{algorithm:"sha256",...j?{modelHash:j}:{},payloadHash:de(N),portable:true,absolutePathsEmitted:false}};return a$1(L,"contracts/workspace-intelligence/project-context-agent.v1.json","Project context agent"),L}function ue(e){let t=e.intelligence.relatedProjects.length>0?e.intelligence.relatedProjects.map(s=>`\`${s}\``).join(", "):"No proven cross-project relation is currently available.",r=e.intelligence.diagnostics.length>0?e.intelligence.diagnostics.slice(0,8).map(s=>`- **${s.severity} \xB7 ${s.code}:** ${s.message}`).join(`
|
|
2
|
+
`):"- No project-scoped graph diagnostic is currently recorded.",o=e.blockers.length>0?e.blockers.slice(0,12).map(s=>`- **${s.severity}${s.code?` \xB7 ${s.code}`:""}:** ${s.message}`).join(`
|
|
3
|
+
`):"- No current project-scoped blocker is recorded.";return `# Workspai project grounding
|
|
4
|
+
|
|
5
|
+
This project is part of the **${e.workspace.name}** Workspai workspace.
|
|
6
|
+
Commands launched from this project resolve that workspace automatically; you do not need to change directories first.
|
|
7
|
+
|
|
8
|
+
## Start here
|
|
9
|
+
|
|
10
|
+
1. Read \`.workspai/reports/project-context-agent.json\` for the bounded project lens.
|
|
11
|
+
2. Read the workspace report index only when the task crosses the project boundary.
|
|
12
|
+
3. Use graph search/evidence commands instead of loading the full graph into a prompt.
|
|
13
|
+
4. Do not claim healthy, ready, or verified without current Workspai evidence.
|
|
14
|
+
|
|
15
|
+
The Workspace Model owns canonical project identity and its compact \`projectTopology\`.
|
|
16
|
+
The Workspace Knowledge Graph is a separate, proof-backed enrichment containing
|
|
17
|
+
files, symbols, APIs, infrastructure, tests, owners, and decisions. Do not treat
|
|
18
|
+
an unproven topology edge as proof that two projects are independent.
|
|
19
|
+
|
|
20
|
+
## Project
|
|
21
|
+
|
|
22
|
+
- Name: \`${e.project.name}\`
|
|
23
|
+
- Workspace-relative identity: \`${e.project.relativePath}\`
|
|
24
|
+
- Runtime: \`${e.project.runtime??"unknown"}\`
|
|
25
|
+
- Framework: \`${e.project.framework??"unknown"}\`
|
|
26
|
+
- Relationship: \`${e.workspace.relationship}\`
|
|
27
|
+
- Related projects: ${t}
|
|
28
|
+
- Topology status: \`${e.intelligence.topology.status}\`
|
|
29
|
+
- Model freshness: \`${e.intelligence.freshness.model}\`
|
|
30
|
+
- Knowledge Graph freshness: \`${e.intelligence.freshness.graph}\`
|
|
31
|
+
|
|
32
|
+
## Current evidence coverage
|
|
33
|
+
|
|
34
|
+
- Project-scoped entities: ${e.intelligence.entityCount}
|
|
35
|
+
- Project-scoped relations: ${e.intelligence.relationCount}
|
|
36
|
+
- Portable proofs: ${e.intelligence.proofCount}
|
|
37
|
+
|
|
38
|
+
${r}
|
|
39
|
+
|
|
40
|
+
## Current project blockers
|
|
41
|
+
|
|
42
|
+
${o}
|
|
43
|
+
|
|
44
|
+
## Safe commands from this project
|
|
45
|
+
|
|
46
|
+
\`\`\`bash
|
|
47
|
+
${e.commands.workspaceStatus}
|
|
48
|
+
${e.commands.doctor}
|
|
49
|
+
${e.commands.graphSearch}
|
|
50
|
+
${e.commands.verify}
|
|
51
|
+
\`\`\`
|
|
52
|
+
|
|
53
|
+
The machine-local workspace path lives only in \`.workspai/workspace-link.local.json\`, which is gitignored. Portable grounding files never publish that path.
|
|
54
|
+
`}function me(e){return `# Workspai project boundary
|
|
55
|
+
|
|
56
|
+
- Project: \`${e.project.name}\`
|
|
57
|
+
- Canonical workspace: \`${e.workspace.name}\`
|
|
58
|
+
- Portable project lens: \`.workspai/reports/project-context-agent.json\`
|
|
59
|
+
- Project grounding: \`.workspai/PROJECT-GROUNDING.md\`
|
|
60
|
+
- Workspace discovery: run \`npx workspai project workspace status --json\`
|
|
61
|
+
|
|
62
|
+
For project-local tasks, start with the project lens. When a change can affect another project, a contract, an API, infrastructure, or release readiness, follow the workspace evidence references and query the Workspai graph. The agent should run the bounded graph search/evidence commands itself when required; the user does not need to preload the full graph. \`projectTopology\` is the compact project dependency view in the canonical Workspace Model, while the Workspace Knowledge Graph is the proof-backed detail layer. Workspai commands launched here resolve the canonical workspace automatically. Never copy the machine-local workspace link into answers, commits, or generated portable artifacts.`}function F(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function U(e,t){return new RegExp(`${F(e)}[\\s\\S]*?${F(t)}`,"m")}function Y(e){let t=e.replace(U(X,q),"");return d$1(t)?.includes("# Workspai project boundary")&&(t=t.replace(U(a$2,b),"")),t.replace(/\n{3,}/g,`
|
|
63
|
+
|
|
64
|
+
`).trim()}function fe(e,t){let r=Y(e),o=`${X}
|
|
65
|
+
${t.trim()}
|
|
66
|
+
${q}`;return r?`${r}
|
|
67
|
+
|
|
68
|
+
${o}
|
|
69
|
+
`:`${o}
|
|
70
|
+
`}async function C(e,t){await k.mkdir(p.dirname(e),{recursive:true});let r=`${e}.${process.pid}.${z.randomUUID()}.tmp`;try{await k.writeFile(r,t,"utf8");try{await k.rename(r,e);}catch(o){let s=o.code;if(s!=="EEXIST"&&s!=="EPERM")throw o;await ne.move(r,e,{overwrite:true});}}finally{await k.rm(r,{force:true}).catch(()=>{});}}async function H(e,t){let r=p.join(e,".gitignore"),o=await k.readFile(r,"utf8").catch(c=>{if(c.code==="ENOENT")return "";throw c}),s=[g,h],i=o.split(/\r?\n/).filter(c=>c.trim()!=="# Workspai local project grounding"&&!s.includes(c.trim()));for(;i.length>0&&i[i.length-1]==="";)i.pop();t==="local"&&(i.length>0&&i.push(""),i.push("# Workspai local project grounding",...s));let a=i.length>0?`${i.join(`
|
|
71
|
+
`)}
|
|
72
|
+
`:"";a!==o&&await C(r,a);}async function V(e,t,r){let o=p.join(e,"AGENTS.md"),s=I.existsSync(o),i=await k.readFile(o,"utf8").catch(f=>{if(f.code==="ENOENT")return "";throw f});if(t==="managed"&&!r)throw new Error("Managed project grounding requires a project context.");let a=t==="managed"&&r?fe(i,me(r)):Y(i);if(!a){s&&await k.rm(o,{force:true});return}let c=`${a.trimEnd()}
|
|
73
|
+
`;return c!==i&&await C(o,c),t==="managed"?o:void 0}async function he(e){let t$1=e.mode??"managed",r=p.resolve(e.workspacePath),o=p.resolve(e.projectPath);if(t$1==="off"){let h$1=t(o,"project.json").find(n=>I.existsSync(n)),j=h$1?await v(h$1):null,P=e.projectName??(typeof j?.name=="string"?j.name:void 0)??p.basename(o),g$1=Z(j,e.relationship??"managed"),u=await c({workspacePath:r,projectPath:o,projectName:P,relationship:g$1,now:e.now});return await H(o,t$1),await V(o,t$1),await Promise.all([k.rm(p.join(o,h),{force:true}),k.rm(p.join(o,g),{force:true})]),{mode:t$1,projectPath:o,linkPath:u.linkPath,writtenFiles:[".workspai/workspace-link.local.json"]}}let s=await ge(e),i=s.workspace.relationship,a=await c({workspacePath:r,projectPath:o,projectName:s.project.name,relationship:i,workspaceName:s.workspace.name,relativePath:s.project.relativePath,now:e.now});await H(o,t$1);let c$1=await V(o,t$1,s),f=p.join(o,h),y=p.join(o,g);await C(f,`${JSON.stringify(s,null,2)}
|
|
74
|
+
`),await C(y,`${ue(s).trimEnd()}
|
|
75
|
+
`);let m=[".workspai/workspace-link.local.json",h,g];return c$1&&m.push("AGENTS.md"),{mode:t$1,projectPath:o,linkPath:a.linkPath,groundingPath:y,contextPath:f,agentsPath:c$1,writtenFiles:m}}async function Ne(e){let t=p.resolve(e.workspacePath),r=e.mode??"managed",o=await je(t),s=[],i=[];for(let a of o.resolved)try{s.push(await he({workspacePath:t,projectPath:a.projectPath,projectName:a.name,relationship:a.relationship,mode:r,now:e.now}));}catch(c){i.push({name:a.name,reason:c instanceof Error?c.message:String(c)});}return {workspacePath:t,mode:r,projects:s,skipped:[...o.skipped,...i]}}async function je(e){let t=p.resolve(e),r=await v(p.join(t,".workspai","workspace.contract.json")),o=[],s=[];for(let i of r?.projects??[]){let a=i.slug??i.relativePath??"unknown-project",c=typeof i.externalPath=="string"?p.resolve(i.externalPath):typeof i.relativePath=="string"&&!i.relativePath.startsWith("external/")?p.resolve(t,i.relativePath):null;if(!c||!I.existsSync(c)){s.push({name:a,reason:"project path is unavailable on this machine"});continue}o.push({name:a,projectPath:c,relationship:i.relationship??"managed"});}return {resolved:o,skipped:s}}export{oe as a,Ie as b,X as c,q as d,ge as e,he as f,Ne as g,je as h};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import {a}from'./chunk-AFIFZTOY.js';import {j,s,p as p$1,v}from'./chunk-MOSXTVPU.js';import z from'crypto';import J from'os';import l from'path';import {once}from'events';import {createWriteStream,createReadStream}from'fs';import*as Y from'readline';import {Transform,Readable}from'stream';import {pipeline}from'stream/promises';import {lookup}from'dns/promises';import I from'net';import p from'fs-extra';import*as G from'yauzl';import*as Q from'yazl';var He="workspai-workspace-archive-capabilities-v1",H="workspai-workspace-archive-manifest-v1",k="workspai-workspace-archive-operation-result-v1";var U="contracts/workspace-archive-manifest.v1.json",q="contracts/workspace-archive-operation-result.v1.json",Ue={archiveCompression:{signature:"--archive-compression <mode>",description:"Archive compression: store (default) or deflate",appliesTo:["export"]},maxDownloadSize:{signature:"--max-download-size <size>",description:"Maximum remote archive download size (secure default: 5gb)",appliesTo:["inspect","verify","doctor","hydrate","import"]},maxExpandedSize:{signature:"--max-expanded-size <size>",description:"Maximum expanded archive payload size (secure default: 20gb)",appliesTo:["inspect","verify","doctor","hydrate","import"]},downloadTimeoutMs:{signature:"--download-timeout-ms <ms>",description:"Remote archive download timeout in milliseconds; 0 disables it",appliesTo:["inspect","verify","doctor","hydrate","import"]},allowPrivateNetwork:{signature:"--allow-private-network",description:"Allow archive downloads from loopback/private networks (unsafe for untrusted input)",appliesTo:["inspect","verify","doctor","hydrate","import"]}};var A=".workspai/archive-manifest.json",R=".rapidkit/archive-manifest.json",fe="workspai.workspace.archive",ue=300*1e3,de=5*1024*1024*1024,ye=20*1024*1024*1024,K=2e5,ve=5*1024*1024*1024,we=1e3,M=5,ge=64*1024*1024;function ke(r){let t=r.toLowerCase().split("%")[0];if(I.isIPv4(t)){let e=t.split(".").map(Number);return e[0]===0||e[0]===10||e[0]===127||e[0]===169&&e[1]===254||e[0]===172&&e[1]>=16&&e[1]<=31||e[0]===192&&e[1]===168||e[0]===100&&e[1]>=64&&e[1]<=127||e[0]>=224}return I.isIPv6(t)?t==="::"||t==="::1"||t.startsWith("fc")||t.startsWith("fd")||/^fe[89ab]/.test(t)||t.startsWith("ff")||t.startsWith("::ffff:127.")||t.startsWith("::ffff:10.")||t.startsWith("::ffff:192.168."):true}async function Z(r,t){let e=new URL(r);if(e.protocol!=="https:"&&e.protocol!=="http:")throw new Error(`Workspace archive URL protocol is not supported: ${e.protocol}`);if(e.protocol!=="https:"&&!t)throw new Error("Remote workspace archives require HTTPS unless private-network access is explicitly enabled.");if(e.username||e.password)throw new Error("Workspace archive URL must not contain embedded credentials.");if(t)return e;let i=e.hostname.replace(/^\[|\]$/g,"").toLowerCase();if(i==="localhost"||i.endsWith(".localhost"))throw new Error("Workspace archive URL resolves to a private or local network address.");let a=I.isIP(i)?[{address:i}]:await lookup(i,{all:true,verbatim:true});if(a.length===0||a.some(({address:s})=>ke(s)))throw new Error("Workspace archive URL resolves to a private or local network address.");return e}async function Ee(r,t,e){let i=await Z(r,e);for(let a=0;a<=M;a+=1){let s=await fetch(i,{signal:t,redirect:"manual",credentials:"omit"});if(![301,302,303,307,308].includes(s.status))return s;let n=s.headers.get("location");if(await s.body?.cancel(),!n)throw new Error("Workspace archive redirect is missing a Location header.");if(a===M)throw new Error(`Workspace archive download exceeded ${M} redirects.`);i=await Z(new URL(n,i).href,e);}throw new Error("Workspace archive redirect policy failed.")}var Ae=new Set(["__pycache__",".venv","venv","node_modules",".git","dist","build","target",".pytest_cache",".mypy_cache",".ruff_cache","htmlcov",".next",".turbo",".cache"]),Pe=new Set([".DS_Store","Thumbs.db",".coverage","npm-debug.log","yarn-error.log","pnpm-debug.log","workspace-link.local.json","imported-projects.json","workspace-registry.v1.json"]),We=[/^\.env$/i,/^\.env\.(?!example$|sample$|template$).+/i,/^.*\.pem$/i,/^.*\.key$/i,/^id_rsa$/i,/^id_ed25519$/i];function _(r){return r.replace(/\\/g,"/")}function ee(r){return r.trim().replace(/\.workspai-archive\.zip$/i,"").replace(/\.rapidkit-archive\.zip$/i,"").replace(/\.zip$/i,"").trim().toLowerCase().replace(/[^a-z0-9._-]+/g,"-").replace(/-+/g,"-").replace(/^[-_.]+|[-_.]+$/g,"").slice(0,64)||"imported-workspace"}function te(r){let t=_(r).trim();if(!t||t.startsWith("/")||t.startsWith("~")||/^[a-zA-Z]:\//.test(t)||t.includes("\0"))return false;let e=t.split("/").filter(Boolean);return e.length>0&&!e.some(i=>i===".."||i===".")}function re(r){if(!te(r))throw new Error(`Archive contains an unsafe path: ${r}`)}function be(r,t){let e=l.relative(t,r);return e===""||!!e&&!e.startsWith("..")&&!l.isAbsolute(e)}function Se(r,t){let e=_(r),i=e.split("/").filter(Boolean);if((i[0]===".workspai"||i[0]===".rapidkit")&&["cache","reports"].includes(i[1]||"")||i.some(s=>Ae.has(s)))return true;let a=i[i.length-1]||"";return e===".workspai/workspace.contract.json"||e===".rapidkit/workspace.contract.json"||Pe.has(a)||/\.(?:workspai|rapidkit)-archive\.zip$/i.test(a)||!t?.includeEnv&&We.some(s=>s.test(a))?true:a.endsWith(".pyc")||a.endsWith(".log")}async function Re(r){for(let t of [l.join(r,".workspai","workspace.contract.json"),l.join(r,".rapidkit","workspace.contract.json")])if(await p.pathExists(t))try{return await p.readJson(t)}catch(e){throw new Error(`Workspace contract could not be inspected safely for archive portability: ${t}: ${e instanceof Error?e.message:String(e)}`)}return null}function _e(r){return (r?.projects??[]).filter(t=>typeof t.externalPath=="string"||typeof t.relativePath=="string"&&t.relativePath.startsWith("external/")).map(t=>({name:t.slug||t.relativePath||"external-project",relationship:["adopted","linked","imported","managed","restored"].includes(String(t.relationship))?t.relationship:"adopted",included:false,requiredAction:"relink"})).sort((t,e)=>t.name.localeCompare(e.name))}function Ce(r){if(r)return {...r,workspace:{...r.workspace},projects:r.projects.filter(t=>typeof t.externalPath!="string"&&!t.relativePath.startsWith("external/")).map(({externalPath:t,...e})=>({...e,modules:[...e.modules],ports:e.ports.map(i=>({...i})),contracts:{owns:[...e.contracts.owns],apis:e.contracts.apis.map(i=>({...i})),publishes:[...e.contracts.publishes],consumes:[...e.contracts.consumes],dependsOn:[...e.contracts.dependsOn],env:[...e.contracts.env]}}))}}async function*ie(r,t,e){let i=(await p.readdir(t,{withFileTypes:true})).sort((a,s)=>a.name.localeCompare(s.name));for(let a of i){let s=l.join(t,a.name),n=_(l.relative(r,s));if(!(!n||Se(n,e))){if(a.isDirectory()){yield*ie(r,s,e);continue}a.isFile()&&(yield {relativePath:n,fullPath:s});}}}async function xe(r){for(let t of s(r,"workspace.json"))try{let e=await p.readJson(t);if(typeof e.workspace_name=="string"&&e.workspace_name.trim())return e.workspace_name.trim();if(typeof e.name=="string"&&e.name.trim())return e.name.trim()}catch{}return l.basename(l.resolve(r))}async function Oe(r){let t=await p.stat(r.fullPath),e=z.createHash("sha256"),i=0;for await(let s of createReadStream(r.fullPath)){let n=Buffer.isBuffer(s)?s:Buffer.from(s);i+=n.length,e.update(n);}let a=await p.stat(r.fullPath);if(t.size!==a.size||t.mtimeMs!==a.mtimeMs||i!==a.size)throw new Error(`Workspace file changed while preparing archive: ${r.relativePath}`);return {...r,size:i,mtimeMs:a.mtimeMs,sha256:e.digest("hex")}}async function E(r,t){r.write(t)||await once(r,"drain");}async function ae(r){await new Promise((t,e)=>{r.once("error",e),r.end(t);});}async function*O(r){let t=Y.createInterface({input:createReadStream(r),crlfDelay:1/0});for await(let e of t){let i=e.trim();i&&(yield JSON.parse(i));}}async function ze(r){let t=createWriteStream(r.manifestPath,{flags:"wx"});try{await E(t,`{
|
|
2
|
+
`);for(let[i,a]of Object.entries(r.manifestBase))await E(t,` ${JSON.stringify(i)}: ${JSON.stringify(a,null,2)},
|
|
3
|
+
`);await E(t,` "files": [
|
|
4
|
+
`);let e=true;for await(let i of O(r.spoolPath)){let{mtimeMs:a,...s}=i;await E(t,`${e?"":`,
|
|
5
|
+
`} ${JSON.stringify(s)}`),e=false;}await E(t,`
|
|
6
|
+
]
|
|
7
|
+
}
|
|
8
|
+
`),await ae(t);}catch(e){throw t.destroy(),await p.remove(r.manifestPath).catch(()=>{}),e}}async function Ne(r,t){let e=[];for await(let i of O(t)){let{mtimeMs:a,...s}=i;e.push(s);}return {...r,files:e}}async function Me(r,t){try{await p.rename(r,t);}catch(e){let i=e.code;if(i!=="EEXIST"&&i!=="EPERM")throw e;await p.move(r,t,{overwrite:true});}}async function ot(r){let t=l.resolve(r.workspacePath);if(!j(t))throw new Error("Workspace export requires a Workspai workspace root with .workspai-workspace or a legacy .rapidkit-workspace marker.");let e=await xe(t),i=await Re(t),a=_e(i),s=Ce(i),n=l.resolve(r.outputPath||`${ee(e)}.workspai-archive.zip`),o={schemaVersion:H,version:1,kind:fe,workspaceName:e,exportedAt:(r.now??new Date).toISOString(),exportedBy:"workspai",archiveFormat:r.compression==="deflate"?"zip-deflate":"zip-store",containerFormat:"zip64",compression:r.compression==="deflate"?"deflate":"store",streaming:true,security:{envFilesIncluded:r.includeEnv===true,excludedByDefault:[".git","node_modules",".venv","dist","build","target",".env","*.pem","*.key","*.log"]},...a.length>0?{externalProjects:a}:{},...s?{portableContract:s}:{}},m=l.resolve(n);await p.ensureDir(l.dirname(n));let h=`${n}.${process.pid}.${z.randomUUID()}.tmp`,u=await p.mkdtemp(l.join(J.tmpdir(),"workspai-archive-export-")),y=l.join(u,"manifest-files.jsonl"),c=l.join(u,"archive-manifest.json"),f=new Q.ZipFile,w=r.now??new Date,v=r.compression==="deflate";try{let P=createWriteStream(y,{flags:"wx"});try{for await(let d of ie(t,t,{includeEnv:r.includeEnv===true})){if(l.resolve(d.fullPath)===m)continue;let g=await Oe(d),x={path:g.relativePath,size:g.size,sha256:g.sha256,mtimeMs:g.mtimeMs};await E(P,`${JSON.stringify(x)}
|
|
9
|
+
`);}await ae(P);}catch(d){throw P.destroy(),d}await ze({manifestBase:o,spoolPath:y,manifestPath:c});for await(let d of O(y)){let g=l.join(t,...d.path.split("/"));f.addFile(g,d.path,{compress:v,forceZip64Format:d.size>=4294967295,mtime:w});}f.addFile(c,A,{compress:v,mtime:w}),f.end({forceZip64Format:true,comment:""}),await pipeline(f.outputStream,createWriteStream(h,{flags:"wx"}));for await(let d of O(y)){let g=l.join(t,...d.path.split("/")),x=await p.stat(g);if(x.size!==d.size||x.mtimeMs!==d.mtimeMs)throw new Error(`Workspace file changed while writing archive: ${d.path}`)}let W=await p.stat(h);await Me(h,n);let b=await Ne(o,y);return C({schemaVersion:k,operation:"export",status:"passed",archivePath:n,manifest:b,bytesWritten:W.size})}finally{await p.remove(u).catch(()=>{}),await p.remove(h).catch(()=>{});}}async function se(r,t={}){if(/^https?:\/\//i.test(r)){let e=await p.mkdtemp(l.join(J.tmpdir(),"workspai-workspace-archive-")),i=l.join(e,"workspace.workspai-archive.zip"),a=new AbortController,s=t.downloadTimeoutMs??ue,n=s>0?setTimeout(()=>a.abort(new Error("Download timed out")),s):null;try{let o=await Ee(r,a.signal,t.allowPrivateNetwork===true);if(!o.ok)throw new Error(`Failed to download workspace archive: HTTP ${o.status}`);if(!o.body)throw new Error("Failed to download workspace archive: response body is empty.");let m=t.maxDownloadBytes??de,h=Number(o.headers.get("content-length"));if(Number.isFinite(h)&&h>m)throw new Error(`Workspace archive download exceeds configured limit (${h} > ${m} bytes).`);let u=0,y=new Transform({transform(f,w,v){if(u+=f.length,u>m){v(new Error(`Workspace archive download exceeds configured limit (${m} bytes).`));return}v(null,f);}}),c=Readable.fromWeb(o.body);return await pipeline(c,y,createWriteStream(i,{flags:"wx"})),{archivePath:i,cleanup:e}}catch(o){throw await p.remove(e).catch(()=>{}),a.signal.aborted?new Error(`Workspace archive download timed out after ${s}ms.`,{cause:o}):o}finally{n&&clearTimeout(n);}}return {archivePath:l.resolve(r)}}function Ie(r){return new Promise((t,e)=>{G.open(r,{autoClose:false,lazyEntries:true,decodeStrings:true,validateEntrySizes:true,strictFileNames:true},(i,a)=>{i||!a?e(i??new Error("Failed to open workspace archive.")):t(a);});})}function Te(r){return new Promise((t,e)=>{let i=[],a=s=>e(s);r.once("error",a),r.on("entry",s=>{try{if(re(s.fileName),s.isEncrypted())throw new Error(`Encrypted workspace archive entries are not supported: ${s.fileName}`);s.fileName.endsWith("/")||i.push({name:s.fileName,size:s.uncompressedSize,compressedSize:s.compressedSize,crc32:s.crc32,entry:s}),r.readEntry();}catch(n){e(n);}}),r.once("end",()=>{r.removeListener("error",a),t(i);}),r.readEntry();})}function $(r,t){return new Promise((e,i)=>{r.openReadStream(t,(a,s)=>{a||!s?i(a??new Error(`Failed to read ${t.fileName}.`)):e(s);});})}async function $e(r,t,e=ge){if(t.size>e)throw new Error(`Workspace archive manifest exceeds ${e} bytes.`);let i=[],a=0,s=await $(r,t.entry);for await(let n of s){let o=Buffer.isBuffer(n)?n:Buffer.from(n);if(a+=o.length,a>e)throw s.destroy(),new Error(`Workspace archive manifest exceeds ${e} bytes.`);i.push(o);}return Buffer.concat(i,a)}function Fe(r){let t=JSON.parse(r.toString("utf-8"));a(t,U,"Workspace archive manifest");let e=new Set;for(let i of t.files){if(!te(i.path)||_(i.path)!==i.path)throw new Error(`Workspace archive manifest contains an unsafe path: ${i.path}`);if(i.path===A||i.path===R)throw new Error(`Workspace archive manifest cannot inventory itself: ${i.path}`);if(e.has(i.path))throw new Error(`Workspace archive manifest contains duplicate path: ${i.path}`);e.add(i.path);}return t}function C(r){return a(r,q,"Workspace archive operation result"),r}function Le(r){return v(_(r))}function Be(r){let t=new Map;for(let e of r){if(e.name===A||e.name===R)continue;let i=Le(e.name),a=t.get(i);if(!a){t.set(i,{...e,sourceName:e.name,targetName:i});continue}let s=e.name===i,n=a.sourceName===a.targetName;if(s&&!n){t.set(i,{...e,sourceName:e.name,targetName:i});continue}if(!(a.size===e.size&&a.crc32===e.crc32)&&!n)throw new Error(`Workspace archive contains conflicting entries for ${i}: ${a.sourceName}, ${e.name}`)}return [...t.values()].sort((e,i)=>e.targetName.localeCompare(i.targetName))}async function F(r,t={}){let e=await se(r,t),i;try{i=await Ie(e.archivePath);let a=await Te(i);if(a.length>K)throw new Error(`Workspace archive contains too many entries (${a.length} > ${K}).`);for(let h of a){if(h.size>ve)throw new Error(`Workspace archive entry is too large: ${h.name}`);if(h.size/Math.max(1,h.compressedSize)>we)throw new Error(`Workspace archive entry has an unsafe compression ratio: ${h.name}`)}let s=a.reduce((h,u)=>h+u.size,0),n=t.maxExpandedBytes??ye;if(s>n)throw new Error(`Workspace archive payload exceeds configured limit (${s} > ${n} bytes).`);let o=a.find(h=>h.name===A||h.name===R);if(!o)throw new Error(`Workspace archive is missing ${p$1("","archive-manifest.json").replace(/^\//,"")}.`);let m=Fe(await $e(i,o));return {archivePath:e.archivePath,entries:a,manifest:m,zipFile:i,cleanup:e.cleanup}}catch(a){throw i?.close(),e.cleanup&&await p.remove(e.cleanup).catch(()=>{}),a}}async function L(r){r.zipFile?.close(),r.cleanup&&await p.remove(r.cleanup).catch(()=>{});}async function Ve(r){let t=await F(r.archivePathOrUrl,r.safety);try{let e=new Map(t.entries.filter(a=>a.name!==A&&a.name!==R).map(a=>[a.name,a])),i=t.manifest.files.map(a=>({path:a.path,size:e.get(a.path)?.size??a.size,hasChecksum:typeof a.sha256=="string"&&a.sha256.length>0}));return C({schemaVersion:k,operation:"inspect",status:"passed",archivePath:t.archivePath,manifest:t.manifest,fileCount:i.length,totalBytes:i.reduce((a,s)=>a+s.size,0),entries:i})}finally{await L(t);}}async function ne(r){let t=await F(r.archivePathOrUrl,r.safety);try{let e=new Map(t.entries.filter(c=>c.name!==A&&c.name!==R).map(c=>[c.name,c])),i=new Set(t.manifest.files.map(c=>c.path)),a=[...e.keys()].filter(c=>!i.has(c)).sort(),s=[],n=[],o=[],m=0;for(let c of t.manifest.files){re(c.path);let f=e.get(c.path);if(!f){s.push(c.path);continue}let w=z.createHash("sha256"),v=0,P=await $(t.zipFile,f.entry);for await(let b of P){let d=Buffer.isBuffer(b)?b:Buffer.from(b);v+=d.length,w.update(d);}let W={size:v,sha256:w.digest("hex")};if(v!==f.size||v!==c.size){o.push({path:c.path,expected:{size:c.size,sha256:c.sha256},actual:W});continue}if(!c.sha256){n.push(c.path);continue}if(W.sha256!==c.sha256){o.push({path:c.path,expected:{size:c.size,sha256:c.sha256},actual:W});continue}m+=1;}let h=r.requireChecksums===true&&n.length>0,u=s.length>0||o.length>0||h||a.length>0,y=n.length>0;return C({schemaVersion:k,operation:"verify",archivePath:t.archivePath,manifest:t.manifest,status:u?"failed":y?"warning":"passed",fileCount:t.manifest.files.length,totalBytes:t.manifest.files.reduce((c,f)=>c+f.size,0),verifiedFiles:m,missingChecksumFiles:n,missingArchiveEntries:s,extraArchiveEntries:a,mismatches:o})}finally{await L(t);}}async function ct(r){let t=await se(r.archivePathOrUrl,r.safety);try{return await je({archivePath:t.archivePath,strict:r.strict})}finally{t.cleanup&&await p.remove(t.cleanup).catch(()=>{});}}async function je(r){let t=await Ve({archivePathOrUrl:r.archivePath}),e=await ne({archivePathOrUrl:r.archivePath,requireChecksums:r.strict===true}),i=[],a=[];i.push({id:"manifest-present",status:"passed",message:`Archive manifest found for workspace "${t.manifest.workspaceName}".`}),i.push({id:"integrity",status:e.status,message:e.status==="passed"?`Verified ${e.verifiedFiles}/${e.fileCount} files.`:"Archive integrity verification did not fully pass."});let s=t.manifest.security?.envFilesIncluded===true;i.push({id:"secrets-policy",status:s?"warning":"passed",message:s?"Archive manifest says environment/private files were intentionally included.":"Archive manifest excludes environment/private files by default."}),s&&a.push("Share this archive only through trusted internal channels."),e.missingChecksumFiles.length>0&&a.push("Re-export the archive with the latest RapidKit/Workspai tooling."),e.mismatches.length>0&&a.push("Reject this archive and request a fresh export from the owner."),(e.extraArchiveEntries.length>0||e.missingArchiveEntries.length>0)&&a.push("Regenerate the archive so ZIP entries and manifest entries match."),r.strict===true&&e.status!=="passed"&&a.push("Do not hydrate this archive in strict or production workflows.");let n=i.some(m=>m.status==="failed"),o=i.some(m=>m.status==="warning");return C({schemaVersion:k,operation:"doctor",archivePath:t.archivePath,status:n?"failed":o?"warning":"passed",workspaceName:t.manifest.workspaceName,fileCount:t.fileCount,totalBytes:t.totalBytes,checks:i,recommendedActions:a})}async function De(r,t){let e=await p.lstat(r).catch(a=>{if(a.code==="ENOENT")return null;throw a});if(!e)return false;if(e.isSymbolicLink())throw new Error(`Output directory must not be a symbolic link: ${r}`);if(!e.isDirectory())throw new Error(`Output path is not a directory: ${r}`);if((await p.readdir(r)).length>0&&!t)throw new Error(`Output directory is not empty: ${r}. Use --force to overwrite.`);return true}async function pt(r){let t=await F(r.archivePathOrUrl,r.safety);try{let e=await ne({archivePathOrUrl:t.archivePath,requireChecksums:r.strict===true});if(e.status==="failed"){let o=[e.missingArchiveEntries.length?`missing entries: ${e.missingArchiveEntries.join(", ")}`:"",e.extraArchiveEntries.length?`unexpected entries: ${e.extraArchiveEntries.join(", ")}`:"",e.mismatches.length?`checksum/size mismatches: ${e.mismatches.map(m=>m.path).join(", ")}`:"",e.missingChecksumFiles.length&&r.strict===true?`missing checksums: ${e.missingChecksumFiles.join(", ")}`:""].filter(Boolean).join("; ");throw new Error(`Workspace archive verification failed${o?` (${o})`:""}.`)}if(e.status==="warning"&&r.strict===true)throw new Error(`Workspace archive verification requires checksums for every file: ${e.missingChecksumFiles.join(", ")}`);let i=Be(t.entries),a=t.manifest,s=l.resolve(r.outputPath||ee(a.workspaceName||"imported-workspace")),n=await De(s,r.force===true);if(!r.dryRun){let o=l.dirname(s),m=`${process.pid}-${z.randomUUID()}`,h=l.join(o,`.${l.basename(s)}.hydrate-${m}.tmp`),u=l.join(o,`.${l.basename(s)}.hydrate-${m}.backup`),y=false,c=false;await p.ensureDir(o);try{await p.ensureDir(h);for(let f of i){let w=l.resolve(h,f.targetName);if(!be(w,h))throw new Error(`Archive entry escapes output directory: ${f.targetName}`);await p.ensureDir(l.dirname(w));let v=await $(t.zipFile,f.entry);await pipeline(v,createWriteStream(w,{flags:"wx"}));}n&&(await p.rename(s,u),y=true),await p.rename(h,s),c=true,y&&await p.remove(u).catch(()=>{});}catch(f){throw y&&!await p.pathExists(s)&&await p.rename(u,s).catch(()=>{}),f}finally{await p.remove(h).catch(()=>{}),c&&await p.remove(u).catch(()=>{});}}return C({schemaVersion:k,operation:"hydrate",status:"passed",archivePath:t.archivePath,outputPath:s,dryRun:r.dryRun===true,manifest:a,files:i.map(o=>({path:o.targetName,size:o.size}))})}finally{await L(t);}}
|
|
10
|
+
export{He as a,H as b,k as c,Ue as d,A as e,fe as f,ke as g,Z as h,ee as i,te as j,Se as k,ot as l,Ve as m,ne as n,ct as o,pt as p};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import {a,c,j,g as g$1,h as h$1}from'./chunk-L2E2Z4OE.js';import {t,u as u$1}from'./chunk-MOSXTVPU.js';import T from'fs';import i from'path';import C from'fs-extra';var V=[{id:"fastapi.standard",aliases:["fastapi","fastapi.standard"],label:"fastapi \u2014 FastAPI Standard Kit",description:"Core-backed FastAPI service scaffold.",owner:"core",runtime:"python",framework:"fastapi",category:"backend",moduleSupport:true,stability:"stable",versionPolicy:"tested-baseline"},{id:"fastapi.ddd",aliases:["fastapi.ddd","fastapi-ddd"],label:"fastapi \u2014 FastAPI DDD Kit",description:"Core-backed FastAPI DDD service scaffold.",owner:"core",runtime:"python",framework:"fastapi",category:"backend",moduleSupport:true,stability:"stable",versionPolicy:"tested-baseline"},{id:"nestjs.standard",aliases:["nestjs","nest","nestjs.standard"],label:"nestjs \u2014 NestJS Standard Kit",description:"Core-backed NestJS service scaffold.",owner:"core",runtime:"node",framework:"nestjs",category:"backend",moduleSupport:true,stability:"stable",versionPolicy:"tested-baseline"},{id:"springboot.standard",aliases:["spring","springboot","springboot.standard","java"],label:"spring \u2014 Spring Boot Standard Kit",description:"npm-backed Spring Boot service scaffold.",owner:"npm",runtime:"java",framework:"springboot",category:"backend",moduleSupport:false,stability:"stable",versionPolicy:"tested-baseline",generator:"springboot",createUsage:"workspai create project springboot.standard <name> [--java-version <major>] [--spring-boot-version <semver>] [--group-id <com.example>] [--package-name <com.example.app>] [--port <number>]"},{id:"gofiber.standard",aliases:["go","go.standard","fiber","gofiber","gofiber.standard","go/fiber"],label:"go/fiber \u2014 Go Fiber Standard Kit",description:"npm-backed Go Fiber service scaffold.",owner:"npm",runtime:"go",framework:"gofiber",category:"backend",moduleSupport:false,stability:"stable",versionPolicy:"tested-baseline",generator:"gofiber",createUsage:"workspai create project gofiber.standard <name> [--output <dir>]"},{id:"gogin.standard",aliases:["gin","gogin","gogin.standard","go/gin"],label:"go/gin \u2014 Go Gin Standard Kit",description:"npm-backed Go Gin service scaffold.",owner:"npm",runtime:"go",framework:"gogin",category:"backend",moduleSupport:false,stability:"stable",versionPolicy:"tested-baseline",generator:"gogin",createUsage:"workspai create project gogin.standard <name> [--output <dir>]"},{id:"dotnet.webapi.clean",aliases:["dotnet","dotnet.webapi","dotnet.webapi.clean","aspnet","aspnetcore","asp.net","asp.net-core","csharp","c#"],label:"dotnet \u2014 ASP.NET Core Clean Web API",description:"npm-backed ASP.NET Core Web API with clean architecture boundaries.",owner:"npm",runtime:"dotnet",framework:"dotnet",category:"backend",moduleSupport:false,stability:"preview",versionPolicy:"tested-baseline",generator:"dotnet-webapi-clean",createUsage:"workspai create project dotnet.webapi.clean <name> [--target-framework net8.0] [--root-namespace <Company.Product>] [--port <number>]"},{id:"rust.axum",aliases:["rust.axum","axum","rust-axum"],label:"rust/axum \u2014 Rust Axum API",description:"Workspai-owned Axum service with health, tests, CI, and container baseline.",owner:"npm",runtime:"rust",framework:"axum",category:"backend",moduleSupport:false,stability:"preview",versionPolicy:"tested-baseline",generator:"rust-axum",createUsage:"workspai create project rust.axum <name> [--port <number>] [--output <dir>] [--skip-git]"}],O=new Map;for(let e of V){O.set(e.id.toLowerCase(),e);for(let t of e.aliases)O.set(t.toLowerCase(),e);}function R(e){return e?O.get(e.trim().toLowerCase())??null:null}function ze(e){return R(e)?.id??e}function Ve(){return V.filter(e=>e.owner==="core"||e.generator)}function Xe(e){return R(e)?.owner==="npm"}async function Qe(e,t){if(!e.generator)throw new Error(`Kit is not backed by an npm generator: ${e.id}`);if(e.generator==="gofiber"){let{generateGoFiberKit:r}=await import('./gofiber-standard-AQGSC7ON.js');await r(t.projectPath,{project_name:t.projectName,module_path:t.projectName,skipGit:t.skipGit,skipInstall:t.skipInstall});return}if(e.generator==="gogin"){let{generateGoGinKit:r}=await import('./gogin-standard-7DU3OCBX.js');await r(t.projectPath,{project_name:t.projectName,module_path:t.projectName,skipGit:t.skipGit,skipInstall:t.skipInstall});return}if(e.generator==="springboot"){let{generateSpringBootKit:r}=await import('./springboot-standard-EK6GYN5T.js');await r(t.projectPath,{project_name:t.projectName,artifact_id:t.projectName,java_version:m(t.args,"--java-version")?.trim(),spring_boot_version:m(t.args,"--spring-boot-version")?.trim(),springdoc_version:m(t.args,"--springdoc-version")?.trim(),group_id:m(t.args,"--group-id")?.trim(),package_name:m(t.args,"--package-name")?.trim(),description:m(t.args,"--description")?.trim(),port:m(t.args,"--port")?.trim(),skipGit:t.skipGit,skipInstall:t.skipInstall});return}if(e.generator==="dotnet-webapi-clean"){let{generateDotnetWebApiCleanKit:r}=await import('./dotnet-webapi-clean-VXEF4SHM.js');await r(t.projectPath,{project_name:t.projectName,target_framework:m(t.args,"--target-framework")?.trim(),root_namespace:m(t.args,"--root-namespace")?.trim(),description:m(t.args,"--description")?.trim(),port:m(t.args,"--port")?.trim(),skipGit:t.skipGit,skipInstall:t.skipInstall});return}if(e.generator==="rust-axum"){let{generateRustAxumKit:r}=await import('./rust-axum-4HXDICIB.js');await r(t.projectPath,{project_name:t.projectName,description:m(t.args,"--description")?.trim(),port:m(t.args,"--port")?.trim(),skipGit:t.skipGit,skipInstall:t.skipInstall});return}throw new Error(`Unhandled npm kit generator: ${e.generator}`)}function m(e,t){let r=e.indexOf(t);if(r>=0&&r+1<e.length)return e[r+1];let n=e.find(a=>a.startsWith(`${t}=`));return n?n.slice(t.length+1):void 0}var f=["init","dev","start","build","test","lint","format","help"],X={python:{runtime:"python",displayName:"Python",tier:"first-class",scaffoldSupport:true,importSupport:true,lifecycleCommands:f,moduleCommands:true,doctorSupport:"full",notes:["Core-backed Python projects support RapidKit Core modules and lifecycle commands."]},node:{runtime:"node",displayName:"Node.js",tier:"extended",scaffoldSupport:true,importSupport:true,lifecycleCommands:f,moduleCommands:true,doctorSupport:"full",notes:["Node projects support npm-owned lifecycle commands; NestJS is the first-class Node framework."]},go:{runtime:"go",displayName:"Go",tier:"extended",scaffoldSupport:true,importSupport:true,lifecycleCommands:f,moduleCommands:false,doctorSupport:"readiness",notes:["Go projects support workspace governance and lifecycle commands via Go tooling."]},java:{runtime:"java",displayName:"Java / Spring Boot",tier:"extended",scaffoldSupport:true,importSupport:true,lifecycleCommands:f,moduleCommands:false,doctorSupport:"readiness",notes:["Java projects support Maven/Gradle lifecycle commands and workspace governance."]},dotnet:{runtime:"dotnet",displayName:".NET / ASP.NET Core",tier:"extended",scaffoldSupport:true,importSupport:true,lifecycleCommands:f,moduleCommands:false,doctorSupport:"readiness",notes:[".NET projects support dotnet CLI lifecycle commands and workspace governance."]},php:{runtime:"php",displayName:"PHP",tier:"extended",scaffoldSupport:true,importSupport:true,lifecycleCommands:f,moduleCommands:false,doctorSupport:"readiness",notes:["Laravel projects use the official Composer generator and PHP/Composer lifecycle adapter."]},ruby:{runtime:"ruby",displayName:"Ruby",tier:"observed",scaffoldSupport:false,importSupport:true,lifecycleCommands:["help"],moduleCommands:false,doctorSupport:"observed",notes:["Ruby projects are importable and governed as observed projects until a kit exists."]},rust:{runtime:"rust",displayName:"Rust",tier:"extended",scaffoldSupport:true,importSupport:true,lifecycleCommands:f,moduleCommands:false,doctorSupport:"readiness",notes:["Rust projects support Axum and Tauri scaffolding plus Cargo lifecycle commands."]},elixir:{runtime:"elixir",displayName:"Elixir",tier:"observed",scaffoldSupport:false,importSupport:true,lifecycleCommands:["help"],moduleCommands:false,doctorSupport:"observed",notes:["Elixir projects are importable and governed as observed projects until a kit exists."]},clojure:{runtime:"clojure",displayName:"Clojure",tier:"observed",scaffoldSupport:false,importSupport:true,lifecycleCommands:["help"],moduleCommands:false,doctorSupport:"observed",notes:["Clojure projects are importable and governed as observed projects until a kit exists."]},scala:{runtime:"scala",displayName:"Scala",tier:"observed",scaffoldSupport:false,importSupport:true,lifecycleCommands:["help"],moduleCommands:false,doctorSupport:"observed",notes:["Scala projects are importable and governed as observed projects until a kit exists."]},kotlin:{runtime:"kotlin",displayName:"Kotlin",tier:"observed",scaffoldSupport:false,importSupport:true,lifecycleCommands:["help"],moduleCommands:false,doctorSupport:"observed",notes:["Kotlin projects are importable and governed as observed projects until a kit exists."]},deno:{runtime:"deno",displayName:"Deno",tier:"observed",scaffoldSupport:false,importSupport:true,lifecycleCommands:["help"],moduleCommands:false,doctorSupport:"observed",notes:["Deno projects are importable and governed as observed projects until a kit exists."]},bun:{runtime:"bun",displayName:"Bun",tier:"observed",scaffoldSupport:false,importSupport:true,lifecycleCommands:["help"],moduleCommands:false,doctorSupport:"observed",notes:["Bun projects are importable and governed as observed projects until a kit exists."]},c:{runtime:"c",displayName:"C",tier:"observed",scaffoldSupport:false,importSupport:true,lifecycleCommands:["help"],moduleCommands:false,doctorSupport:"observed",notes:["C projects are importable and receive manifest, test, quality, security, and coverage evidence without assuming a package manager."]},cpp:{runtime:"cpp",displayName:"C++",tier:"observed",scaffoldSupport:false,importSupport:true,lifecycleCommands:["help"],moduleCommands:false,doctorSupport:"observed",notes:["C++ projects are importable and receive manifest, test, quality, security, and coverage evidence without assuming a package manager."]},unknown:{runtime:"unknown",displayName:"Unknown",tier:"observed",scaffoldSupport:false,importSupport:true,lifecycleCommands:["help"],moduleCommands:false,doctorSupport:"observed",notes:["Unknown projects are tracked safely but require manual command configuration."]}},fe=["fastapi","nestjs"],ge=["django","flask","nextjs","remix","nuxt","react","vite","vue","sveltekit","svelte","angular","astro","solid","express","fastify","koa","echo","gofiber","gogin","springboot","dotnet","laravel","symfony","rails","sinatra","actix","axum","rocket","phoenix","clojure","scala","kotlin","deno","bun","tauri","electron","vscode-extension","c","cpp"];function x(e){return X[e||"unknown"]??X.unknown}function Q(e){return fe.includes(e)?"first-class":ge.includes(e)?"extended":"observed"}function Z(e){let t=x(e.runtime);return {lifecycleCommands:t.lifecycleCommands,moduleCommands:e.moduleSupport&&t.moduleCommands,unsupportedLifecycleCommands:f.filter(r=>!t.lifecycleCommands.includes(r))}}var ye=["python","node","go","java","dotnet","rust","php"];function w(e){return !!e&&ye.includes(e)}function E(e,t){return t!=="lint"&&t!=="format"&&t!=="docs"?false:e==="python"}function ee(e){let t=x(e),r=w(t.runtime),n=be[t.runtime]??[],a=Ce[t.runtime]??[];return {runtime:t.runtime,displayName:t.displayName,lifecycleCommands:t.lifecycleCommands,hasExecutor:r,packageManagers:n,primaryFiles:a,notes:t.notes}}var be={python:["poetry","pip","uv"],node:["npm","pnpm","yarn","bun"],go:["go"],java:["maven","gradle"],dotnet:["dotnet"],php:["composer"],ruby:["bundle"],rust:["cargo"],elixir:["mix"],kotlin:["gradle"],deno:["deno"],bun:["bun"]},Ce={python:["pyproject.toml","requirements.txt","requirements.in"],node:["package.json"],go:["go.mod"],java:["pom.xml","build.gradle","build.gradle.kts"],dotnet:["*.csproj","*.sln"],php:["composer.json"],ruby:["Gemfile"],rust:["Cargo.toml"],elixir:["mix.exs"],kotlin:["settings.gradle.kts"],deno:["deno.json","deno.jsonc"],bun:["package.json","bunfig.toml"]};function h(e,t){let r=g$1({runtime:typeof e?.runtime=="string"?e.runtime:void 0,framework:typeof e?.framework=="string"?e.framework:void 0,kitName:typeof e?.kit_name=="string"?e.kit_name:typeof e?.kit=="string"?e.kit:void 0});return r.runtime!=="unknown"?r.runtime:j(t,e).runtime}function re(e){let t$1=e;for(;;){for(let n of t(t$1,"project.json"))if(T.existsSync(n))try{return JSON.parse(T.readFileSync(n,"utf8"))}catch{return null}let r=i.dirname(t$1);if(r===t$1)break;t$1=r;}return null}function pt(e,t){return h(e,t)==="go"}function lt(e,t){return h(e,t)==="node"}function dt(e,t){return h(e,t)==="java"}function ut(e,t){return h(e,t)==="dotnet"}function ft(e,t){return h(e,t)==="python"}var Se=["project.json","context.json","file-hashes.json"];async function ht(e){let t=i.resolve(e),r=[];for(let n of Se){let a=u$1(t,n);if(await C.pathExists(a))continue;let c=i.join(t,".rapidkit",n);if(!await C.pathExists(c))continue;let y=await C.readJson(c);await C.ensureDir(i.dirname(a));let k=`${a}.${process.pid}.${Date.now()}.tmp`;try{await C.writeJson(k,y,{spaces:2}),await C.move(k,a,{overwrite:false}),r.push(a);}finally{await C.remove(k).catch(()=>{});}}return r}function je(e){for(let t$1 of t(e,"context.json"))if(T.existsSync(t$1))try{return JSON.parse(T.readFileSync(t$1,"utf8"))}catch{return null}return null}function we(e){let t=e?.engine;return t==="npm"||t==="pip"||t==="python"?t:"unknown"}function xe(e,t){if(e?.module_support===false||t?.module_support===false||!e&&t)return false;let r=typeof e?.kit_name=="string"?e.kit_name:typeof e?.kit=="string"?e.kit:typeof t?.kit=="string"?t.kit:void 0,n=r?R(r):void 0;return n?.owner==="core"&&n.moduleSupport===true}function he(e,t,r){let n=g$1({runtime:typeof t?.runtime=="string"?t.runtime:typeof r?.runtime=="string"?r.runtime:void 0,framework:typeof t?.framework=="string"?t.framework:typeof r?.framework=="string"?r.framework:void 0,kitName:typeof t?.kit_name=="string"?t.kit_name:typeof t?.kit=="string"?t.kit:typeof r?.kit=="string"?r.kit:void 0});return n.key!=="unknown"?n:j(e,t)}function ne(e){let t$1=i.resolve(e);if(![...t(t$1,"project.json"),...t(t$1,"context.json")].some(y=>T.existsSync(y)))return null;let n=re(t$1),a=je(t$1),c=he(t$1,n,a);return {projectRoot:t$1,projectJson:n,contextJson:a,detection:c,moduleSupport:xe(n,a),engine:we(a)}}var ve=["build","dev","start","test","lint","format"],I=["init","test","build","start"],Pt=["lint","format","docs"];function Rt(e){return !!e&&ve.includes(e)}var Ne={dev:["dev","start:dev"],start:["start","start:prod","preview"],build:["build"],test:["test","test:unit","test:ci"],lint:["lint"],format:["format","prettier"]},ae={nestjs:{dev:["dev","start:dev"],start:["start","start:prod"],build:["build"],test:["test","test:e2e"],lint:["lint"],format:["format"]},express:{dev:["dev","start:dev"],start:["start"],build:["build"],test:["test"],lint:["lint"],format:["format"]},fastify:{dev:["dev","start:dev"],start:["start"],build:["build"],test:["test"],lint:["lint"],format:["format"]},koa:{dev:["dev","start:dev"],start:["start"],build:["build"],test:["test"],lint:["lint"],format:["format"]}};function Pe(e){let t=i.join(e,"package.json");if(!T.existsSync(t))return {};try{let n=JSON.parse(T.readFileSync(t,"utf8")).scripts??{};return Object.fromEntries(Object.entries(n).filter(a=>typeof a[1]=="string"))}catch{return {}}}function Re(e,t){let r=t?c(t):"unknown",n=r!=="unknown"?a(r,e):[],a$1=t?ae[t]?.[e]??[]:[],c$1=Ne[e]??[],y=[...n,...a$1,...c$1];return [...new Set(y)]}function ie(e,t,r){let n=Pe(e),a$1=new Set(Object.keys(n));if(a$1.has(t))return {scriptName:t,source:"package.json"};for(let c$1 of Re(t,r?.framework))if(a$1.has(c$1))return {scriptName:c$1,source:a(c(r?.framework??"unknown"),t).includes(c$1)||ae[r?.framework??""]?.[t]?.includes(c$1)?"framework-candidate":"generic-candidate"};return null}function B(e){return T.existsSync(i.join(e,"package.json"))}function se(e){let t=ee(e);return t.runtime==="unknown"&&e!=="unknown"?null:{runtime:t.runtime,displayName:t.displayName,supportedCommands:t.lifecycleCommands,packageManagers:t.packageManagers,primaryFiles:t.primaryFiles,notes:t.notes,hasExecutor:t.hasExecutor}}function s(e){try{return T.existsSync(e)}catch{return false}}function g(e){try{return s(e)?T.readFileSync(e,"utf8"):""}catch{return ""}}function u(e,t){let r=g(i.join(e,"Makefile"));return r?new RegExp(`^${t}\\s*:`).test(r):false}function Ee(e){let t=[e];for(;t.length>0;){let r=t.shift();if(!r)break;let n=[];try{n=T.readdirSync(r,{withFileTypes:true});}catch{continue}for(let a of n){if(a.name==="node_modules"||a.name===".git"||a.name==="dist")continue;let c=i.join(r,a.name);if(a.isFile()&&a.name.endsWith(".csproj"))return true;a.isDirectory()&&t.push(c);}}return false}function ce(e,t){let r=s(i.join(e,"pyproject.toml")),n=s(i.join(e,"requirements.txt"))||s(i.join(e,"requirements.in")),a=s(i.join(e,"manage.py"));switch(t){case "init":return r||n;case "dev":case "start":return r||a||n;case "test":return r||n||s(i.join(e,"tests"));case "build":return r||n;case "lint":case "format":return r||n||a||s(i.join(e,"setup.py"))||s(i.join(e,"setup.cfg"));default:return false}}function Me(e,t){if(!s(i.join(e,"go.mod")))return false;switch(t){case "init":return true;case "dev":return u(e,"run")||s(i.join(e,"main.go"));case "test":return true;case "build":return true;case "start":return u(e,"run")||s(i.join(e,"main.go"))||s(i.join(e,"cmd"));case "lint":return s(i.join(e,".golangci.yml"))||s(i.join(e,".golangci.yaml"))||u(e,"lint");case "format":return u(e,"fmt")||u(e,"format");default:return false}}function _e(e,t){let r=s(i.join(e,"pom.xml")),n=s(i.join(e,"build.gradle"))||s(i.join(e,"build.gradle.kts"));if(!r&&!n)return false;switch(t){case "init":case "test":case "build":case "dev":case "start":return true;case "lint":return u(e,"lint")||g(i.join(e,"pom.xml")).includes("checkstyle")||g(i.join(e,"build.gradle")).includes("checkstyle")||g(i.join(e,"build.gradle.kts")).includes("checkstyle");case "format":return u(e,"format")||g(i.join(e,"build.gradle")).includes("spotless")||g(i.join(e,"build.gradle.kts")).includes("spotless");default:return false}}function Ae(e,t){if(!Ee(e))return false;switch(t){case "init":case "dev":case "test":case "build":case "start":return true;case "lint":return u(e,"lint")||g(i.join(e,"Directory.Build.props")).includes("EnforceCodeStyleInBuild");case "format":return u(e,"format")||s(i.join(e,".editorconfig"));default:return false}}function Fe(e,t,r){return t==="init"?B(e):ie(e,t,{framework:r})!==null}function Le(e,t,r){switch(t){case "php":return r==="init"&&s(i.join(e,"composer.json"));case "ruby":return r==="init"&&s(i.join(e,"Gemfile"));case "rust":return s(i.join(e,"Cargo.toml"))?r==="init"||r==="test"||r==="build"||r==="start":false;case "elixir":return r==="init"&&s(i.join(e,"mix.exs"));case "deno":return s(i.join(e,"deno.json"))||s(i.join(e,"deno.jsonc"))?r==="init"||r==="dev"||r==="test"||r==="start":r==="init"&&s(i.join(e,"package.json"));case "bun":return s(i.join(e,"bunfig.toml"))||s(i.join(e,"bun.lock"))?r==="init"||r==="dev"||r==="test"||r==="build"||r==="start":r==="init"&&s(i.join(e,"package.json"));default:return false}}function De(e){try{let t=JSON.parse(g(i.join(e,"composer.json")));return new Set(Object.keys(t.scripts??{}))}catch{return new Set}}function Oe(e,t){if(!s(i.join(e,"composer.json")))return false;let r=De(e),n=s(i.join(e,"artisan"));switch(t){case "init":return true;case "dev":return n||r.has("dev");case "start":return n||r.has("start");case "test":return n||r.has("test");case "build":return r.has("build");case "lint":return r.has("lint")||r.has("analyse")||r.has("analyze");case "format":return r.has("format")||r.has("fmt")||s(i.join(e,"pint.json"))||s(i.join(e,"vendor","bin","pint"));default:return false}}function Te(e,t){return s(i.join(e,"Cargo.toml"))?t==="init"||t==="dev"||t==="start"||t==="build"||t==="test"||t==="lint"||t==="format":false}function _(e,t,r,n){if(E(t,r))return ce(e,r);if(!w(t))return Le(e,t,r);switch(t){case "node":return Fe(e,r,n);case "python":return ce(e,r);case "go":return Me(e,r);case "java":return _e(e,r);case "dotnet":return Ae(e,r);case "rust":return Te(e,r);case "php":return Oe(e,r);default:return false}}function Ie(e,t,r){return ["init","dev","start","build","test","lint","format"].filter(a=>_(e,t,a,r))}function me(e){let t=Z({runtime:e.runtime,moduleSupport:e.moduleSupport});if(!e.projectPath)return t;let r=Ie(e.projectPath,e.runtime,e.framework),n=new Set(["help"]);for(let c of r)t.lifecycleCommands.includes(c)&&n.add(c);e.runtime==="node"&&B(e.projectPath)&&n.add("init");let a=[...n].sort();return {lifecycleCommands:a,moduleCommands:t.moduleCommands,unsupportedLifecycleCommands:t.lifecycleCommands.filter(c=>!a.includes(c)).sort()}}var W=["version","commands","doctor","project","help"],A=["init","dev","start","build","test","lint","format"],$=["add","modules","upgrade","diff","merge","reconcile","rollback","uninstall","checkpoint","snapshot","optimize"],J=["create","list","info","frameworks","license"];W.filter(e=>e!=="help");function Be(e){let t$1=i.resolve(e);for(;;){if([...t(t$1,"project.json"),...t(t$1,"context.json")].some(a=>T.existsSync(a)))return t$1;let n=i.dirname(t$1);if(n===t$1)break;t$1=n;}return null}function v(e,t){return {command:e,...t}}var Ge=new Set(["dev","lint","format"]),Ue=new Set(I);function We(e,t){return t?Ue.has(e)?{executionScope:"fleet",fleetEligible:true}:Ge.has(e)?{executionScope:"local-only",fleetEligible:false}:{executionScope:"local-only",fleetEligible:false}:{executionScope:"local-only",fleetEligible:false}}function $e(e,t){return E(t.runtime,e)?"core":"runtime"}function Je(e,t,r,n){return !e||!n.lifecycleCommands.includes(t)?false:_(e,r.runtime,t,r.key)}function qe(e,t){let r=!!e&&(t.runtime==="python"||w(t.runtime)&&_(e,t.runtime,"build",t.key));return v("docs",{owner:t.runtime==="python"?"core":"runtime",status:r?"supported":"unsupported",reason:r?t.runtime==="python"?"Documentation generation is delegated to Python Core for this project.":"Project documentation commands are available through the npm wrapper for this runtime.":"Documentation commands require a supported Python or npm-executor project manifest."})}function Ye(e){let t=i.resolve(e),r=Be(e);return r||(h$1(t).length>0?t:null)}function He(e=process.cwd()){let t=Ye(e),r=t?ne(t):null,n=r?.detection??j(e,r?.projectJson??null),a=r?.moduleSupport??false,c=r?.engine??"unknown",y=se(n.runtime),k=x(n.runtime),le=me({runtime:n.runtime,moduleSupport:a,projectPath:t??void 0,framework:n.key}),b={};for(let o of W)b[o]=v(o,{owner:o==="project"?"core":"npm",status:"supported",reason:o==="project"?"Project detection is a Core contract; workspace project lifecycle remains npm-owned.":o==="help"?"Help is available for every Workspai project through the npm CLI.":"Universal command available across Workspai project types."});for(let o of A){let S=Je(t,o,n,le),Y=$e(o,n),F=We(o,S);b[o]=v(o,{owner:Y,status:S?"supported":"unsupported",executionScope:F.executionScope,fleetEligible:F.fleetEligible,reason:S?Y==="core"?`Delegated to Python Core for ${n.displayName} projects.`:F.fleetEligible?`Handled by runtime adapter and eligible for workspace fleet stages (${o}).`:o==="dev"?"Local development command only; workspace fleet excludes dev by design.":n.runtime==="node"?`Handled by npm/pnpm/yarn via the resolved ${o} script in package.json.`:`Handled by the ${y?.displayName??n.displayName} runtime adapter for local project execution.`:t?n.runtime==="node"?`No ${o} script was found in package.json for this ${n.displayName} project.`:w(n.runtime)?`The ${n.displayName} runtime is tracked, but ${o} is not available from detected project manifests.`:`${n.displayName} is tracked as an observed runtime; ${o} requires project manifests or explicit scripts.`:"No Workspai project was detected."});}b.docs=qe(t,n);for(let o of $)b[o]=v(o,{owner:a?"core":"none",status:a?"supported":"unsupported",reason:a?"Core module/template command supported for this project.":`Core module/template commands are not available for ${n.displayName} projects.`});for(let o of J)b[o]=v(o,{owner:o==="create"?"npm":"core",status:"global",reason:o==="create"?"Create is orchestrated by npm for multi-language workspace support.":"Engine catalog command; not specific to the selected project runtime."});let N=Object.values(b),q=N.filter(o=>A.includes(o.command)).filter(o=>o.status==="supported"),de=I.filter(o=>q.some(S=>S.fleetEligible===true&&S.command===o)),ue=q.filter(o=>o.executionScope==="local-only").map(o=>o.command).sort();return {schemaVersion:1,scope:"project",projectRoot:t,engine:c,runtime:n.runtime,framework:n.key,frameworkDisplayName:n.displayName,frameworkConfidence:n.confidence,frameworkSupportTier:Q(n.key),runtimeSupportTier:k.tier,runtimeDoctorSupport:k.doctorSupport,moduleSupport:a,fleetStages:de,localOnlyCommands:ue,commandMap:b,supportedCommands:N.filter(o=>o.status==="supported").map(o=>o.command).sort(),unsupportedCommands:N.filter(o=>o.status==="unsupported").map(o=>o.command).sort(),globalCommands:N.filter(o=>o.status==="global").map(o=>o.command).sort()}}function cr(e,t=process.cwd()){let r=e[0];return r?He(t).commandMap[r]??null:null}function mr(e){if(e[0]==="project"&&e[1]==="commands")return true;if(e[0]==="commands"&&e.includes("--scope")){let t=e.indexOf("--scope");return e[t+1]==="project"}return e.some(t=>t==="--scope=project")&&e[0]==="commands"}function pr(e,t){return [`Workspai command not supported for this project: ${e.command}`,"",`Project: ${t.projectRoot??"not detected"}`,`Runtime: ${t.runtime}`,`Framework: ${t.frameworkDisplayName}`,`Reason: ${e.reason??"Unsupported for this project type."}`,"","Run `workspai project commands` to inspect supported commands for this project."].join(`
|
|
2
|
+
`)}export{R as a,ze as b,Ve as c,Xe as d,Qe as e,x as f,Q as g,w as h,re as i,pt as j,lt as k,dt as l,ut as m,ft as n,ht as o,ne as p,ve as q,Pt as r,Rt as s,ie as t,me as u,Be as v,He as w,cr as x,mr as y,pr as z};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import {a as a$1}from'./chunk-A5FBGRJA.js';import {g,p}from'./chunk-BBGNDMRU.js';import {d,e}from'./chunk-XBM2P45G.js';import {s}from'./chunk-MOSXTVPU.js';import {s as s$1,q}from'./chunk-RJIYCDVC.js';import a from'path';import {existsSync}from'fs';import u from'fs-extra';var f=".workspai/workspace-registry.v1.json",w="workspace-registry.v1";function x(r){return {slug:r.slug,relativePath:r.relativePath,framework:r.framework,kit:r.kit,source:r.source}}async function A(r){let e=s(r,"workspace.json").find(t=>existsSync(t));if(!e)return {exists:false,legacyProjectCount:0};try{let t=await u.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 b(r){let e=a$1(r);for(let t of s$1())if(await u.pathExists(t))try{let o=((await u.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(q(),"workspaces.json")}}async function E(r,e){let t=a.resolve(r),c=await d(t,g),o=await A(t),s=await b(t),i=e?.contract!==void 0||!!c,n=[];if(e?.contract)n=e.contract.projects||[];else if(i)try{let{contract:d}=await p({workspacePath:t});n=d.projects||[];}catch{n=[];}let S={contract:{exists:i,projectCount:n.length,path:g},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",m=[],y=0;return i?(p$1="workspace.contract.json",m=n.map(x),y=m.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,projects:m,sources:S}}}async function Y(r){let e=await d(r,f);if(!e)return null;try{let t=await u.readJson(e);return t?.schemaVersion!==w?null:t}catch{return null}}async function D(r,e$1){let t=await _(r,e$1);return await e(r,f,t),t}async function _(r,e){return {...(await E(r,{contract:e?.contract})).summary,generatedAt:(e?.now??new Date).toISOString(),registrySummaryPath:f}}function H(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,E as c,Y as d,D as e,_ as f,H as g};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import {b as b$4,a as a$1}from'./chunk-THIOE2PB.js';import {b as b$2,f as f$2,j,k,h as h$2,i,l,m,n,o,p as p$2,q,r,t,v,x,s as s$1,u as u$1,w,y,z,A,B,C,D,E,F,G,H as H$1,a as a$3,I}from'./chunk-DQ3PI7EP.js';import {b as b$1,c,d as d$1}from'./chunk-HSZCINFX.js';import {b as b$3}from'./chunk-EPVFKJF4.js';import {d as d$2}from'./chunk-VU2BKKMB.js';import {h,g as g$1}from'./chunk-SHXJ2GDR.js';import {p,k as k$1,f as f$3}from'./chunk-BYTFXQ6G.js';import {p as p$1}from'./chunk-BBGNDMRU.js';import {d}from'./chunk-XBM2P45G.js';import {a as a$2,b as b$5}from'./chunk-RVQLMTTI.js';import {b,a}from'./chunk-AHLMIL2T.js';import {f,g,h as h$1}from'./chunk-MOSXTVPU.js';import s from'path';import f$1 from'fs-extra';var Q=["Scope","Evidence","Diagnosis","Fix Plan","Run","Verify","Assumptions"];var kt="workspace-operational-skill.v1";function ft(e){if(typeof e!="string")return null;let t=e.trim();return !t||t.includes("/")||t.includes("..")?null:t}function Ze(e){let t=ft(e.skillId);if(!t)throw new Error(`Invalid skill id: ${e.skillId}`);return {schemaVersion:kt,skillId:t,canonicalPath:H$1(t),title:e.title,triggers:[...e.triggers].sort((r,n)=>r.localeCompare(n)),requiredReports:[...e.requiredReports].sort((r,n)=>r.localeCompare(n)),scopedProjects:[...e.scopedProjects??[]].sort((r,n)=>r.localeCompare(n)),verificationCommands:[...e.verificationCommands],answerContractSections:[...Q],...e.promptStem?{promptStem:e.promptStem}:{},markdown:e.markdown}}var ht=b.skillsIndex;function Qe(e){let t=[...e.skills].sort((n,c)=>n.skillId.localeCompare(c.skillId)),r=e.inputsHash??f$3({skillIds:t.map(n=>n.skillId),paths:t.map(n=>n.canonicalPath)});return {schemaVersion:ht,generatedAt:e.generatedAt,inputsHash:r,skills:t.map(n=>({skillId:n.skillId,path:n.canonicalPath,schemaVersion:n.schemaVersion,title:n.title}))}}var et=[a.agentIndex,b$1,d$2],wt=[{skillId:"workspai-diagnose-api-failure",title:"Diagnose API failure",triggers:["api failure","500 error","integration test failed","service unreachable"],objective:"Investigate a failing API or service using Workspai evidence before editing application code.",steps:[`Read \`${a.agentIndex}\` and identify fail/warn reports for the scoped project.`,`Read \`${a.doctor}\`, \`doctor-project-last-run.json\`, and project-scoped run evidence if present.`,"If a fix was requested, read `artifact-remediation-plan-last-run.json` for cross-artifact next steps, then `doctor-remediation-plan-last-run.json` for Doctor-specific file edits.","Map the failure to workspace vs project scope; cite exit codes and blocker messages.","Propose the smallest safe fix (config, env, dependency) with explicit verification commands."]},{skillId:"workspai-release-readiness",title:"Release readiness",triggers:["release","ship","production","readiness gate"],objective:"Assess whether this workspace is release-ready using governed Workspai gates.",steps:[`Read \`${a.readiness}\` and \`pipeline-last-run.json\`.`,`Read \`${a.verify}\` for verdict and blocking reasons.`,"Read `.workspai/reports/artifact-remediation-plan-last-run.json` when a Studio or agent repair path is needed.","List blocking gates first; never claim ready without cited report fields.","Provide one safe next command and a verification checklist."]},{skillId:"workspai-safe-schema-migration",title:"Safe schema migration",triggers:["migration","schema change","database migration","db migrate"],objective:"Plan and verify a schema migration with blast-radius awareness.",steps:["Identify affected projects from workspace model and dependency graph.","Run or review impact/verify evidence for transitive dependents.","Require project-scoped test/build commands before promoting the migration.","Document rollback and verification signals."]},{skillId:"workspai-dependency-upgrade",title:"Dependency upgrade",triggers:["upgrade dependency","bump package","security advisory","outdated deps"],objective:"Upgrade dependencies with graph-aware verification.",steps:["Scope the upgrade to the owning project from workspace model.","Check transitive dependents via workspace graph / impact reports.","Prefer workspace run test/build for affected projects.","Re-run `workspace verify` after evidence refresh."]},{skillId:"workspai-rename-contract",title:"Rename contract safely",triggers:["rename contract","rename event","breaking api","contract change"],objective:"Rename or change a shared contract with consumer awareness.",steps:["Read `.workspai/workspace.contract.json` for publishes/consumes/owns edges.","List all consumer projects before proposing renames.","Update contract file and regenerate workspace model.","Verify contract gate and integration tests for consumers."]}];function ee(e){return `npx workspai ${e}`.trim()}function At(e){let t=[`# ${e.template.title}`,"",`> Workspace: **${e.workspaceName}** \xB7 Skill: \`${e.template.skillId}\``,"","## Objective","",e.template.objective,"","## Triggers","",...e.template.triggers.map(r=>`- ${r}`),"","## Required evidence (read first)","",...et.map(r=>`- \`${r}\``),"","## Procedure","",...e.template.steps.map((r,n)=>`${n+1}. ${r}`),""];if(e.scopedProjects.length>0&&t.push("## Scoped projects","",...e.scopedProjects.map(r=>`- ${r}`),""),e.contractSummary&&t.push("## Contract context","",e.contractSummary,""),e.verificationCommands.length>0){t.push("## Verification commands (this workspace)","");for(let r of e.verificationCommands)t.push(`- \`${r}\``);t.push("");}return t.push("## Answer contract","","Return: Scope, Evidence, Diagnosis, Fix Plan, Run, Verify, Assumptions.","","## Refresh stale evidence","","```bash",ee("workspace agent-sync --write --refresh-context"),"```",""),t.join(`
|
|
2
|
+
`)}function Pt(e){return e?.safeCommands?.length?e.safeCommands.slice(0,8).map(t=>t.display):[ee("workspace verify --json"),ee("doctor workspace --json")]}function Rt(e){return e?.projects?.length?e.projects.slice(0,12).map(r=>{let n=r.contracts?.owns?.join(", ")||"none",c=r.contracts?.publishes?.join(", ")||"none",d=r.contracts?.consumes?.join(", ")||"none";return `- **${r.slug}**: owns \`${n}\`; publishes \`${c}\`; consumes \`${d}\``}).join(`
|
|
3
|
+
`):void 0}function tt(e){let t=e.model.workspace.name,r=e.model.projects.map(d=>d.name).sort(),n=Pt(e.context??null),c=Rt(e.contract??null);return wt.map(d=>{let p=At({template:d,workspaceName:t,scopedProjects:r,verificationCommands:n,contractSummary:c});return Ze({skillId:d.skillId,title:d.title,triggers:d.triggers,requiredReports:[...et],scopedProjects:r,verificationCommands:n,promptStem:I[d.skillId],markdown:p})})}async function rt(e){let t=s.resolve(e.workspacePath),r=[],n=f$3({skills:e.skills.map(d=>({id:d.skillId,path:d.canonicalPath,hash:f$3({markdown:d.markdown})}))}),c=Qe({generatedAt:e.generatedAt,skills:e.skills,inputsHash:n});if(e.write){for(let p of e.skills){let o=s.join(t,p.canonicalPath);await f$1.ensureDir(s.dirname(o)),await f$1.writeFile(o,p.markdown,"utf8"),r.push(p.canonicalPath);}let d=s.join(t,b$2);await f$1.ensureDir(s.dirname(d)),await f$1.writeJson(d,c,{spaces:2}),r.push(b$2);}return {skills:e.skills,index:c,writtenPaths:r}}function nt(e){return ["## Operational skills (canonical)","","Read workspace-native playbooks from `.workspai/skills/` before generic repo scans. Legacy `.rapidkit/skills/` playbooks are read only when already present from older workspaces:","",...e.skills.map(r=>`- \`${r.path}\` \u2014 ${r.title} (\`${r.skillId}\`)`),"","Regenerate:","","```bash",ee("workspace agent-sync --write --refresh-context"),"```",""].join(`
|
|
4
|
+
`)}var St={"workspai-diagnose-api-failure":p$2,"workspai-release-readiness":t},xe="## Workspace verification (hydrated)";function yt(e){let t=[xe,"","Verification commands for this workspace:","",...e.verificationCommands.length?e.verificationCommands.map(r=>`- \`${r}\``):["- `npx workspai workspace verify --json`"]];return e.scopedProjects.length>0&&t.push("","Scoped projects:","",...e.scopedProjects.map(r=>`- ${r}`)),t.push(""),t.join(`
|
|
5
|
+
`)}async function at(e){let t=s.resolve(e.workspacePath),r=[];for(let n of e.skills){let c=St[n.skillId];if(!c)continue;let d=s.join(t,c);if(!await f$1.pathExists(d))continue;let p=await f$1.readFile(d,"utf8"),o=yt(n),A=p.includes(xe)?p.replace(new RegExp(`${xe}[\\s\\S]*$`),o.trimEnd()):`${p.trimEnd()}
|
|
6
|
+
|
|
7
|
+
${o}`;e.write&&await f$1.writeFile(d,`${A.trimEnd()}
|
|
8
|
+
`,"utf8"),r.push(c);}return r}var Ct="workspai-agent-customization-pack-capabilities.v1";function ot(){return {schemaVersion:Ct,presets:{minimal:{meaning:"Generate the portable grounding index, AGENTS.md, and provider-specific lightweight instructions.",requiredOutputs:[a.agentIndex,a.agentCustomizationPack,a.agents]},enterprise:{meaning:"Generate the full VS Code-native pack: instructions, prompts, skills, custom agents, and validation metadata.",requiredOutputs:[a.agentIndex,a.agentCustomizationPack,a.agents,l,p$2,B,".github/agents/workspai-advisor.agent.md",D,b$2]}},targets:{all:{meaning:"Generate every supported customization surface.",outputFamilies:["portable","vscode","copilot","cursor","claude"]},vscode:{meaning:"Generate VS Code-native customizations for Copilot Chat and agent workflows.",outputFamilies:["instructions","prompts","skills","agents","hooks"]},agents:{meaning:"Generate portable AGENTS.md grounding for any agent.",outputFamilies:["portable"]},copilot:{meaning:"Generate GitHub Copilot instructions, prompts, and skills.",outputFamilies:["instructions","prompts","skills"]},cursor:{meaning:"Generate Cursor rules.",outputFamilies:["rules"]},claude:{meaning:"Generate Claude Code grounding files.",outputFamilies:["rules","portable"]},codex:{meaning:"Use AGENTS.md and the report index as the Codex grounding layer.",outputFamilies:["portable"]},orca:{meaning:"Use AGENTS.md and the report index as the Orca/Grok grounding layer.",outputFamilies:["portable"]}},standardAnswerContract:[...Q],requiredReports:$.map(e=>({path:e.relativePath,label:e.label,required:e.required})),strictRules:["Required reports must exist.","Generated report paths must stay inside the workspace root.","Generated customization text must be English-only.","Agent answers must not claim pass, ready, or healthy without cited evidence.","Commands must distinguish display guidance from execution requests.","Agent hook files must be advisory and disabled by default unless the user explicitly enables them.","MCP design artifacts must stay read-mostly until write tools have explicit approval boundaries."],outputKinds:["report","grounding","instruction","prompt","skill","skill-resource","operational-skill","skills-index","explain-report","agent","rule","hook","mcp-design"],pathLayers:{l1CanonicalRoots:[".workspai/reports/",`${a$3}/`],l2PrefixedMirrorRoots:[".github/",".cursor/",".claude/"],l3SharedIndustryFiles:["AGENTS.md",".github/copilot-instructions.md","CLAUDE.md"]}}}var xt=b.agentIndex,Et=b.agentCustomizationPack,H=a.agentIndex,K=a.agentCustomizationPack;var $=[{relativePath:b$1,label:"Agent context pack",required:true},{relativePath:b$2,label:"Operational skills index",required:true},{relativePath:a.model,label:"Workspace model",required:false},{relativePath:a.knowledgeGraph,label:"Workspace knowledge graph",required:false},{relativePath:a.evaluationLastRun,label:"Workspace Intelligence evaluation",required:false},{relativePath:a.doctor,label:"Workspace doctor",required:false},{relativePath:".workspai/reports/doctor-project-last-run.json",label:"Project doctor",required:false},{relativePath:".workspai/reports/doctor-remediation-plan-last-run.json",label:"Doctor remediation plan",required:false},{relativePath:".workspai/reports/artifact-remediation-plan-last-run.json",label:"Artifact remediation plan",required:false},{relativePath:".workspai/reports/doctor-fix-result-last-run.json",label:"Doctor fix result",required:false},{relativePath:a.analyze,label:"Workspace analyze",required:false},{relativePath:".workspai/reports/pipeline-last-run.json",label:"Governance pipeline",required:false},{relativePath:a.readiness,label:"Release readiness",required:false},{relativePath:a.impact,label:"Workspace impact",required:false},{relativePath:a.verify,label:"Workspace verify",required:false},{relativePath:a.snapshot,label:"Workspace model snapshot",required:false},{relativePath:a.diff,label:"Workspace model diff",required:false},{relativePath:a.explain,label:"Workspace explain",required:false},{relativePath:a.contractVerify,label:"Workspace contract verify",required:false},{relativePath:a.history,label:"Workspace intelligence history",required:false}];function It(){let e=$.map(n=>n.relativePath),r=b$3().consumers.agents.canonicalReadOrder.filter(n=>n!==H&&e.includes(n));return [...new Set([...r,...e])]}function P(e){return `npx workspai ${e}`.trim()}function Oe(e){return e&&typeof e=="object"?e:null}function Ee(e,t=12){return Array.isArray(e)?e.filter(r=>typeof r=="string"&&r.trim().length>0).slice(0,t):[]}function bt(e){let t=Ee(e.blockers,12);if(t.length>0)return t;let r=Ee(e.blockingReasons,12);if(r.length>0)return r;let n=Oe(e.summary);return n&&Array.isArray(n.blockingReasons)?Ee(n.blockingReasons,12):[]}function Ot(e){for(let t of ["generatedAt","updatedAt","timestamp"]){let r=e[t];if(typeof r=="string"&&r.trim())return r.trim()}if(Array.isArray(e.entries)){let t=e.entries.map(r=>Oe(r)?.generatedAt).filter(r=>typeof r=="string"&&r.trim().length>0).map(r=>r.trim()).filter(r=>Number.isFinite(Date.parse(r)));if(t.length>0)return t.reduce((r,n)=>Date.parse(n)>Date.parse(r)?n:r)}}function _t(e,t,r){if(!e)return true;let n=Date.parse(e);return Number.isFinite(n)?r.getTime()-n>t*60*60*1e3:true}function Tt(e,t,r){return e.path===a.snapshot?false:_t(e.generatedAt,t,r)}function vt(e){let t=e&&e.length>0?e:["all"];return t.includes("all")?new Set(["all","vscode","agents","copilot","cursor","claude","codex","orca"]):new Set(t)}function S(e,t){return e.has("all")||e.has(t)}function Wt(e){return S(e,"copilot")||S(e,"vscode")}function jt(e){return e??"enterprise"}function Lt(e){return e===b$2?"skills-index":e.includes("workspace-explain-last-run.json")?"explain-report":(e.startsWith(`${a$3}/`)||e.startsWith(".rapidkit/skills/"))&&e.endsWith(".md")?"operational-skill":e.includes("hooks")||e===F||e===G?"hook":e.includes("mcp")||e===D||e===E?"mcp-design":e.endsWith(".json")?"report":e.includes("/instructions/")||e.endsWith("copilot-instructions.md")?"instruction":e.includes("/prompts/")?"prompt":e.includes("/skills/")&&e.endsWith("/SKILL.md")?"skill":e.includes("/skills/")?"skill-resource":e.includes("/agents/")?"agent":e.includes("/rules/")||e.endsWith(".mdc")?"rule":"grounding"}function Nt(e){return e.startsWith(".github/")?["vscode","copilot"]:e.startsWith(".cursor/")?["cursor"]:e.startsWith(".claude/")||e==="CLAUDE.md"?["claude"]:e==="AGENTS.md"||e.startsWith(".rapidkit/")?["agents","codex","orca","vscode"]:e.startsWith(".vscode/")?["vscode"]:["agents"]}function Gt(e,t){return ot().presets[t].requiredOutputs.includes(e)}async function Dt(e,t){if(t)return t;let r=await d(e,k$1)??s.join(e,k$1);if(await f$1.pathExists(r))try{let n=await f$1.readJson(r);return b$5(k$1,n,r),n}catch{}return p({workspacePath:e,includeEvidence:true})}function $t(e){return e.length>0&&!s.isAbsolute(e)&&!e.split(/[\\/]+/).includes("..")}function Kt(e){return Object.fromEntries(["all","vscode","agents","copilot","cursor","claude","codex","orca"].map(r=>[r,{enabled:e.targets.includes("all")||e.targets.includes(r),outputs:e.outputs.filter(n=>n.targets.includes(r)).map(n=>n.path).sort()}]))}async function Ht(e,t){try{if(!await f$1.pathExists(e))return {payload:null,exists:false,validity:"missing"};let r=await f$1.readJson(e),n=Oe(r);return n?a$2(t)?(b$5(t,n,e),{payload:n,exists:true,validity:"valid"}):{payload:n,exists:true,validity:"uncontracted"}:{payload:null,exists:true,validity:"invalid",validationError:"Artifact root must be a JSON object"}}catch(r){return {payload:null,exists:true,validity:"invalid",validationError:r instanceof Error?r.message:String(r)}}}async function st(e){let t=e.now??new Date,r=e.staleAfterHours??24,n=[],c=[];for(let o of $){let A=await d(e.workspacePath,o.relativePath)??s.join(e.workspacePath,o.relativePath),h=await Ht(A,o.relativePath),g=h.payload;h.validity==="invalid"?c.push(`Invalid evidence contract: ${o.relativePath}`):g&&c.push(...bt(g)),n.push({path:o.relativePath,label:o.label,required:o.required,exists:h.exists,validity:h.validity,validationError:h.validationError,generatedAt:g?Ot(g):void 0,commandId:typeof g?.commandId=="string"?g.commandId:void 0,exitCode:typeof g?.exitCode=="number"?g.exitCode:void 0});}let d$1=[...new Set(c.map(o=>o.trim()).filter(Boolean))].slice(0,16),p=b$3();return {schemaVersion:xt,generatedAt:t.toISOString(),workspaceRoot:e.workspacePath,intelligenceChain:{schemaVersion:p.schemaVersion,contractPath:p.contractPath,currentStep:"agent-sync"},readOrder:It(),blockers:d$1,staleAfterHours:r,reports:n,refreshCommand:P("workspace agent-sync --write --refresh-context")}}function it(e){let t=["# Workspai agent grounding","","Cross-tool instructions for Copilot, Cursor, Claude Code, Codex, Grok, and other agents.","","## Read order (mandatory before workspace diagnosis)","",`1. \`${a.agentIndex}\` \u2014 latest blockers, timestamps, and report paths`,`2. \`${a.agentContext}\` \u2014 read only task-relevant context`,"3. Read only the task-relevant evidence artifacts listed in the index.","4. Use `workspace graph search <query> --limit 12 --json` or MCP `searchWorkspaceGraph` before loading the full graph.","","Do **not** full-repo scan or inject the complete graph when a bounded query can answer the task.","","## Regenerate intelligence","","```bash",P("workspace agent-sync --write --refresh-context"),P("workspace context --for-agent --json --write"),P("pipeline --json --write"),"```",""];if(e.index.blockers.length>0){t.push("## Current blockers","");for(let r of e.index.blockers.slice(0,12))t.push(`- ${r}`);t.push("");}if(e.context?.safeCommands?.length){t.push("## Safe commands (prefer these)","");for(let r of e.context.safeCommands.slice(0,10))t.push(`- \`${r.display}\` \u2014 ${r.description}`);t.push("");}return t.push("## Rules","","- Treat `.workspai/reports/*` as the source of truth for health, gates, and release posture.","- Prefer deterministic Workspai CLI commands over heuristic framework guesses.","- If evidence is missing or stale, run the refresh commands above before proposing fixes.","- Keep project-scoped advice aligned with the active project named in the context pack.",""),t.join(`
|
|
9
|
+
`)}function Mt(e){return ["# Workspai agent grounding","",`Generated: ${e.generatedAt}`,"",`This file is tool-agnostic. Synced agents should read it together with \`${a.agentIndex}\`.`,"","## Mandatory read order","",...e.readOrder.map((t,r)=>`${r+1}. \`${t}\``),"",e.blockers.length>0?"## Blockers":"",...e.blockers.length>0?e.blockers.map(t=>`- ${t}`):[],"","## Refresh","","```bash",e.refreshCommand,"```",""].filter(t=>t!=="").join(`
|
|
10
|
+
`)}function qt(){return ["# Workspai workspace grounding","","Before answering workspace, release, or architecture questions:","","1. Read `AGENTS.md` (managed Workspai section).",`2. Read \`${a.agentIndex}\` and only task-relevant context from \`${a.agentContext}\`.`,"3. Use bounded `workspace graph search` or MCP `searchWorkspaceGraph` before scanning the full repository.","","Regenerate stale intelligence:","","```bash",P("workspace agent-sync --write --refresh-context"),"```",""].join(`
|
|
11
|
+
`)}function Vt(){return ["## Claude Code","",`- Load \`${a.agentIndex}\` before diagnosing blockers.`,"- Use `.claude/rules/workspai-evidence.md` for scoped Workspai evidence rules.","- Treat `.claude/rules/rapidkit-evidence.md` as a legacy compatibility mirror.","- Refresh grounding with `npx workspai workspace agent-sync --write`.",""].join(`
|
|
12
|
+
`)}function Ut(){return ["---","description: Workspai workspace evidence and intelligence grounding","globs: []","alwaysApply: true","---","","Before proposing fixes in this workspace:","",`1. Read \`${a.agents}\` and \`${a.agentIndex}\`.`,`2. Read only task-relevant context from \`${a.agentContext}\`.`,"3. Prefer bounded graph search and evidence reports over full-repo exploration.","","Refresh when stale:","","```bash",P("workspace agent-sync --write --refresh-context"),"```",""].join(`
|
|
13
|
+
`)}function Ft(){return ["---",'applyTo: ".workspai/**,**/.workspai/**,.rapidkit/**,**/.rapidkit/**"',"description: Workspai evidence and intelligence artifacts","---","","When working under `.workspai/` or legacy `.rapidkit/`:","","- Treat `.workspai/reports/*` JSON reports as canonical gate and health evidence.",`- Start from \`${a.agentIndex}\` for read order and blockers.`,"- Do not invent pass/fail state \u2014 cite `exitCode`, `blockers`, and `generatedAt` fields.",""].join(`
|
|
14
|
+
`)}function zt(){return ["---",'applyTo: "**"',"description: Workspai workspace scope, evidence, and command discipline","---","","# Workspai Workspace Intelligence","","Use Workspai reports as the workspace source of truth before giving architectural, repair, release, or project lifecycle advice.","","## Scope rules","",`- Start from \`${a.agentIndex}\`; read only task-relevant context and evidence.`,"- Prefer bounded `workspace graph search` or MCP `searchWorkspaceGraph` over loading the complete graph.","- Distinguish workspace-level blockers from project-level blockers.","- When a project is active, cite its name, path, framework, and evidence source.","- Do not translate unsupported stack requests into unrelated native kits.","","## Answer contract","","Return answers with: Scope, Evidence, Diagnosis, Fix Plan, Run, Verify, Assumptions.",""].join(`
|
|
15
|
+
`)}function Bt(){return ["# Workspai evidence","","Applies when reading or editing `.workspai/reports/*`.","","- Start from `INDEX.json`, then `workspace-context-agent.json`.","- Use report blockers as the primary fix target.","- Regenerate with `npx workspai workspace agent-sync --write`.",""].join(`
|
|
16
|
+
`)}function Jt(){return ["# Legacy RapidKit evidence alias","","Compatibility path only. Use `.claude/rules/workspai-evidence.md` as the canonical rule.",""].join(`
|
|
17
|
+
`)}function Yt(){return ["---","description: Legacy RapidKit metadata compatibility alias",'globs: [".rapidkit/**", "**/.rapidkit/**"]',"alwaysApply: false","---","","Use `.cursor/rules/workspai-grounding.mdc` for canonical Workspai grounding.",""].join(`
|
|
18
|
+
`)}function ct(e){return ["---",'applyTo: ".rapidkit/**,**/.rapidkit/**"',"description: Legacy RapidKit metadata compatibility alias","---","",`Use \`.github/instructions/workspai-${e}.instructions.md\` as the canonical Workspai instruction.`,""].join(`
|
|
19
|
+
`)}function lt(){return ["---","description: Diagnose Workspai workspace blockers from evidence reports","---","","Diagnose this workspace using Workspai evidence only.","","Read:","",`- \`${a.agentIndex}\``,`- \`${a.agentContext}\``,"- Any fail/warn reports referenced in the index","","Return:","","1. Root cause grounded in report blockers","2. Smallest safe fix path (commands + file edits)","3. One verification command to prove recovery",""].join(`
|
|
20
|
+
`)}function te(e){return ["---",`description: ${e.description}`,"---","",e.objective,"","Read first:","",`- \`${a.agentIndex}\``,`- \`${a.agentContext}\``,"- Any report referenced by the current blocker or task","","Return:","",...e.expectedOutput.map((t,r)=>`${r+1}. ${t}`),"","Use the standard Workspai answer contract: Scope, Evidence, Diagnosis, Fix Plan, Run, Verify, Assumptions.",""].join(`
|
|
21
|
+
`)}function T(e){return ["# "+e.title,"",...e.lines,""].join(`
|
|
22
|
+
`)}function Xt(){return T({title:"MCP Tool Design",lines:["Workspai MCP is a read-mostly bridge over contract-validated workspace artifacts.","","Candidate read tools:",`- \`getWorkspaceModel\` \u2014 read \`${a.model}\`.`,`- \`getWorkspaceKnowledgeGraph\` \u2014 read \`${a.knowledgeGraph}\`.`,`- \`getWorkspaceEvaluation\` \u2014 read \`${a.evaluationLastRun}\` (or the live evaluation when requested).`,"- `queryWorkspaceEntities` \u2014 filter proof-backed graph entities by kind.","- `searchWorkspaceGraph` \u2014 retrieve bounded proof-backed context by text query.","- `getWorkspaceGraphEvidence` \u2014 resolve evidence for an entity or relation.","- `findWorkspaceGraphPath` \u2014 find a shortest proof-carrying relationship path.",`- \`getEvidenceIndex\` \u2014 read \`${a.agentIndex}\`.`,"- `getBlockers` \u2014 derive current blockers from INDEX and gate reports.","- `getSafeCommands` \u2014 read safe commands from `workspace-context-agent.json`.","- `getProjectContext` \u2014 return one project-scoped slice of the workspace model.","- `getArtifact` \u2014 read one explicit artifact path inside the workspace root.",`- \`listOperationalSkills\` \u2014 read \`${a.skillsIndex}\`.`,"- `getWorkspaceExplain` \u2014 read/build workspace explain for release-blocked or project scope.","- `refreshWorkspaceIntelligence` \u2014 explicit user-approved refresh command only.","","Write or repair tools require explicit approval boundaries and are intentionally not part of the first read-mostly design."]})}function Zt(e){return `${JSON.stringify({schemaVersion:"workspai-mcp-design.v1",generatedAt:e.generatedAt,workspaceRoot:e.workspacePath,status:"design-only",mode:"read-mostly",safety:{writeToolsEnabled:false,approvalRequiredForRefresh:true,artifactReadsMustStayInsideWorkspace:true},candidateTools:[{name:"getWorkspaceModel",reads:[a.model],mutates:false},{name:"getWorkspaceKnowledgeGraph",reads:[a.knowledgeGraph],mutates:false},{name:"getWorkspaceEvaluation",reads:[a.evaluationLive,a.evaluationLastRun],mutates:false},{name:"queryWorkspaceEntities",reads:[a.knowledgeGraph],mutates:false},{name:"searchWorkspaceGraph",reads:[a.knowledgeGraph],mutates:false},{name:"getWorkspaceGraphEvidence",reads:[a.knowledgeGraph],mutates:false},{name:"findWorkspaceGraphPath",reads:[a.knowledgeGraph],mutates:false},{name:"getEvidenceIndex",reads:[a.agentIndex],mutates:false},{name:"getBlockers",reads:[a.agentIndex,a.verify,".workspai/reports/pipeline-last-run.json"],mutates:false},{name:"getSafeCommands",reads:[a.agentContext],mutates:false},{name:"getProjectContext",reads:[a.model,a.agentContext],mutates:false},{name:"getArtifact",reads:["requested workspace-relative artifact path"],mutates:false},{name:"listOperationalSkills",reads:[a.skillsIndex],mutates:false},{name:"getWorkspaceExplain",reads:[a.explain,a.verify,a.impact],mutates:false},{name:"refreshWorkspaceIntelligence",command:P("workspace agent-sync --write --refresh-context"),mutates:true,approvalRequired:true}]},null,2)}
|
|
23
|
+
`}function Qt(e){return `${JSON.stringify({schemaVersion:"workspai-agent-hooks.v1",generatedAt:e.generatedAt,workspaceRoot:e.workspacePath,enabledByDefault:false,mode:"advisory",hooks:[{name:"workspai-pre-tool-use-workspace-boundary",event:"PreToolUse",purpose:"Block or warn on state-changing commands outside the active workspace root.",defaultAction:"warn",rules:["Allow read-only commands.","Warn before write/delete commands outside workspaceRoot.","Never run destructive commands without explicit user approval."]},{name:"workspai-post-tool-use-verify-suggestion",event:"PostToolUse",purpose:"Suggest non-destructive verification commands after edits.",defaultAction:"suggest",commands:[P("doctor workspace"),P("workspace verify --strict --json")]},{name:"workspai-user-prompt-submit-scope-hint",event:"UserPromptSubmit",purpose:"Inject lightweight workspace scope and evidence index hints.",defaultAction:"inject-context-hint",reads:[a.agentIndex,a.agentContext]}]},null,2)}
|
|
24
|
+
`}function dt(e){let t=["---","name: workspai-workspace-intelligence","description: Use Workspai workspace intelligence reports to answer, repair, verify, and release with evidence","---","","# Workspai Workspace Intelligence","","Use this skill for workspace architecture, project lifecycle, blocker repair, release readiness, agent grounding, and CI evidence questions.","","## Decision flow","","1. Load `resources/scope-model.md`.",`2. Load \`${a.agentIndex}\`.`,`3. Load \`${a.agentContext}\`.`,`4. Load \`${a.skillsIndex}\` when operational playbooks are needed.`,"5. Load the smallest evidence report required for the task.","6. Answer with Scope, Evidence, Diagnosis, Fix Plan, Run, Verify, Assumptions.","","## Rules","","- Prefer Workspai reports over full-repo scans.","- Never claim a gate passed without a cited report.","- Separate display commands from execution requests.","- Keep project-scoped fixes inside the active project unless workspace evidence says otherwise.",""];return e?.trim()&&t.push(e.trim(),""),t.join(`
|
|
25
|
+
`)}function re(e){return ["---",`name: ${e.name}`,`description: ${e.description}`,`tools: [${e.tools.map(t=>`'${t}'`).join(", ")}]`,"---","",`You are the ${e.name} agent for Workspai Workspace Intelligence.`,"",`Mode: ${e.mode}.`,"",`Start every task by reading \`${a.agentIndex}\` and \`${a.agentContext}\`.`,"","Use this answer contract:","","- Scope","- Evidence","- Diagnosis","- Fix Plan","- Run","- Verify","- Assumptions","","Do not invent health, readiness, or policy status. Cite report paths and command outputs.",""].join(`
|
|
26
|
+
`)}function pt(){return ["---","name: workspai-grounding","description: Load Workspai workspace intelligence reports before diagnosing or changing code","---","","# Workspai grounding","","Use when the user asks about workspace health, release gates, doctor/pipeline failures, or project structure.","","## Workflow","",`1. Read \`${a.agentIndex}\``,`2. Read \`${a.agentContext}\``,"3. Read fail/warn evidence artifacts listed in the index","4. Propose the smallest safe fix with explicit verification commands","","## Refresh stale evidence","","```bash",P("workspace agent-sync --write --refresh-context"),"```",""].join(`
|
|
27
|
+
`)}async function u(e,t,r){return r?(await f$1.ensureDir(s.dirname(e)),await f$1.writeFile(e,t,"utf8"),"written"):"skipped"}async function Ie(e){if(!e.write)return "skipped";let t=await f$1.pathExists(e.absolutePath)?await f$1.readFile(e.absolutePath,"utf8"):null,{upsertManagedAgentSection:r}=await import('./managed-agent-markers-COE5DJ3W.js'),n=r(t,e.generatedBody),c=e.preamble?`${e.preamble.trimEnd()}
|
|
28
|
+
|
|
29
|
+
${n}`:n;return await f$1.ensureDir(s.dirname(e.absolutePath)),await f$1.writeFile(e.absolutePath,c,"utf8"),"written"}function Fr(e){if(!e?.trim())return;let t=new Set(["all","vscode","agents","copilot","cursor","claude","codex","orca"]),r=e.split(",").map(n=>n.trim().toLowerCase()).filter(n=>t.has(n));return r.length>0?r:void 0}function er(e){let t=[...e.outputs].sort((n,c)=>n.path.localeCompare(c.path)),r=b$3();return {schemaVersion:Et,generatedAt:e.generatedAt,workspaceRoot:e.workspacePath,preset:e.preset,targets:[...e.targets].sort(),sourceReports:e.index.reports.filter(n=>n.exists).map(n=>n.path).sort(),intelligenceChain:{schemaVersion:r.schemaVersion,contractPath:r.contractPath,currentStep:"agent-sync"},outputInventory:t,capabilityMatrix:Kt({targets:e.targets,outputs:t}),drift:{missingRequired:e.missingRequired,staleReports:e.staleReports,strictViolations:e.strictViolations},answerContract:["Scope","Evidence","Diagnosis","Fix Plan","Run","Verify","Assumptions"],refreshCommand:P(`workspace agent-sync --write --refresh-context --preset ${e.preset}`),experimental:{hooksEnabled:e.experimentalHooks,mcpReady:t.some(n=>n.kind==="mcp-design")}}}async function be(e){let t$1=s.resolve(e.workspacePath),r$1=e.now??new Date,n$1=e.staleAfterHours??24,c$1=vt(e.targets),d=[...c$1].sort(),p$3=jt(e.preset),o$1=e.write===true,A$1=e.strict===true,h,g=null,ne=e.model;e.refreshContext&&(ne??=await p({workspacePath:t$1,includeEvidence:true}),g=await c({workspacePath:t$1,model:ne,agent:e.agent??"generic",scope:e.scope,includeEvidence:true}),o$1&&(h=await d$1(g,t$1)));let O=[],ae=[],oe=[],se=[],l$1=(i,k)=>{i==="written"?ae.push(k):oe.push(k),se.push({path:k,kind:Lt(k),targets:Nt(k),required:Gt(k,p$3),status:i==="written"?"written":e.dryRun?"planned":"skipped"});},ie="",ut=await Dt(t$1,ne),ce=null;try{ce=(await p$1({workspacePath:t$1})).contract;}catch{ce=null;}let gt=tt({model:ut,context:g,contract:ce}),le=await rt({workspacePath:t$1,skills:gt,generatedAt:r$1.toISOString(),write:o$1});for(let i of le.skills)l$1(o$1?"written":"skipped",i.canonicalPath);l$1(o$1?"written":"skipped",b$2),ie=nt(le.index);let y$1=await st({workspacePath:t$1,staleAfterHours:n$1,now:r$1});if(l$1(await u(s.join(t$1,H),`${JSON.stringify(y$1,null,2)}
|
|
30
|
+
`,o$1),H),l$1(await u(s.join(t$1,f$2),`${Mt(y$1)}
|
|
31
|
+
`,o$1),f$2),(S(c$1,"agents")||S(c$1,"vscode"))&&l$1(await Ie({absolutePath:s.join(t$1,"AGENTS.md"),generatedBody:it({index:y$1,context:g}),write:o$1}),"AGENTS.md"),S(c$1,"claude")){let i=s.join(t$1,"CLAUDE.md");if(o$1){let{upsertManagedAgentSection:k}=await import('./managed-agent-markers-COE5DJ3W.js'),m=await f$1.pathExists(i)?await f$1.readFile(i,"utf8"):"",w=k(m,Vt()),C=w.includes("@AGENTS.md")?w:`@AGENTS.md
|
|
32
|
+
|
|
33
|
+
${w}`;await f$1.ensureDir(s.dirname(i)),await f$1.writeFile(i,C,"utf8"),ae.push("CLAUDE.md");}else oe.push("CLAUDE.md");l$1(await u(s.join(t$1,j),`${Bt()}
|
|
34
|
+
`,o$1),j),l$1(await u(s.join(t$1,k),`${Jt()}
|
|
35
|
+
`,o$1),k);}if(S(c$1,"cursor")&&(l$1(await u(s.join(t$1,h$2),Ut(),o$1),h$2),l$1(await u(s.join(t$1,i),Yt(),o$1),i)),Wt(c$1)){if(l$1(await Ie({absolutePath:s.join(t$1,".github/copilot-instructions.md"),generatedBody:qt(),write:o$1}),".github/copilot-instructions.md"),l$1(await u(s.join(t$1,l),zt(),o$1),l),l$1(await u(s.join(t$1,m),ct("workspace"),o$1),m),l$1(await u(s.join(t$1,n),Ft(),o$1),n),l$1(await u(s.join(t$1,o),ct("evidence"),o$1),o),l$1(await u(s.join(t$1,p$2),lt(),o$1),p$2),l$1(await u(s.join(t$1,q),lt(),o$1),q),p$3==="enterprise"){let i=[[r,te({description:"Repair Workspai blockers with evidence and verification",objective:"Plan the smallest safe repair for the current Workspai blocker.",expectedOutput:["Blocker and affected workspace/project scope","Evidence paths and exact failing signals","Minimal fix plan","Human-run commands","Verification command and expected success signal"]})],[t,te({description:"Assess Workspai release readiness from evidence",objective:"Assess whether this workspace is release-ready using Workspai gates.",expectedOutput:["Readiness verdict with cited reports","Blocking gates","Safe next command","Verification checklist"]})],[v,te({description:"Onboard a project into Workspai Workspace Intelligence",objective:"Guide project onboarding using workspace model and create planner capabilities.",expectedOutput:["Target project scope","Native create, official generator, or existing lane","Safe commands","Post-onboarding verification"]})],[x,te({description:"Adopt an existing project into Workspai governance",objective:"Adopt an existing project without changing its runtime behavior.",expectedOutput:["Detected stack and confidence","Adoption plan","Generated metadata expectations","Doctor and workspace model verification"]})]];for(let[m,w]of i)l$1(await u(s.join(t$1,m),w,o$1),m);let k=[[s$1,i[0][1]],[u$1,i[1][1]],[w,i[2][1]],[y,i[3][1]]];for(let[m,w]of k)l$1(await u(s.join(t$1,m),w,o$1),m);if(e.hydratePrompts===true)for(let m of await at({workspacePath:t$1,skills:le.skills,write:o$1}))l$1(o$1?"written":"skipped",m);}if(l$1(await u(s.join(t$1,z),pt(),o$1),z),l$1(await u(s.join(t$1,A),pt(),o$1),A),p$3==="enterprise"){l$1(await u(s.join(t$1,B),dt(ie),o$1),B),l$1(await u(s.join(t$1,C),dt(ie),o$1),C);let i=[["artifact-map.md",T({title:"Artifact Map",lines:$.map(m=>`- \`${m.relativePath}\` \u2014 ${m.label}`)})],["command-map.md",T({title:"Command Map",lines:["- `npx workspai workspace agent-sync --write --refresh-context` \u2014 refresh agent grounding.","- `npx workspai workspace model --json --write` \u2014 refresh workspace model.","- `npx workspai doctor workspace` \u2014 refresh health evidence.","- `npx workspai workspace verify --strict --json` \u2014 verify release gates."]})],["scope-model.md",T({title:"Scope Model",lines:["- Workspace scope is the default source of truth.","- Project scope is selected only when the active task targets a specific project.","- Always name the workspace and project when giving repair or lifecycle advice."]})],["runtime-support.md",T({title:"Runtime Support",lines:["- Native create is available only for Workspai-owned scaffold contracts.","- Unsupported stacks should use the official lane when a stable ecosystem generator exists.","- Existing projects should use the existing lane when native create is unavailable."]})],["create-planner-capabilities.md",T({title:"Create Planner Capabilities",lines:["- Use `contracts/create-planner-capabilities.v1.json` to decide native, official, or existing.","- Do not map PHP, WordPress, Laravel, Rails, or Symfony requests to unrelated native kits.","- Explain unsupported native create requests and guide users to adopt/import."]})],["mcp-tools.md",Xt()]];for(let[m,w]of i){let C$1=`${s.dirname(B)}/resources/${m}`;l$1(await u(s.join(t$1,C$1),w,o$1),C$1);let Te=`${s.dirname(C)}/resources/${m}`;l$1(await u(s.join(t$1,Te),w,o$1),Te);}let k=[["workspai-advisor.agent.md",re({name:"Workspai Advisor",description:"Read-only workspace and project guidance using Workspai evidence",mode:"read-only",tools:["search","read"]})],["workspai-repair.agent.md",re({name:"Workspai Repair",description:"Turn Workspai blockers into minimal fixes and verification steps",mode:"repair",tools:["search","read","edit"]})],["workspai-release.agent.md",re({name:"Workspai Release",description:"Assess readiness, governance gates, and release safety from evidence",mode:"release",tools:["search","read"]})],["workspai-project-onboarder.agent.md",re({name:"Workspai Project Onboarder",description:"Guide create, import, and adopt flows with Workspai contracts",mode:"onboard",tools:["search","read","edit"]})]];for(let[m,w]of k){let C=`.github/agents/${m}`;l$1(await u(s.join(t$1,C),w,o$1),C);}}}if(p$3==="enterprise"){let i=Zt({workspacePath:t$1,generatedAt:y$1.generatedAt});b$5(D,JSON.parse(i)),l$1(await u(s.join(t$1,D),i,o$1),D),l$1(await u(s.join(t$1,E),i,o$1),E);}if(p$3==="enterprise"&&e.experimentalHooks===true){let i=Qt({workspacePath:t$1,generatedAt:y$1.generatedAt});b$5(F,JSON.parse(i)),l$1(await u(s.join(t$1,F),i,o$1),F),l$1(await u(s.join(t$1,G),i,o$1),G);}(S(c$1,"codex")||S(c$1,"orca"))&&(S(c$1,"agents")||l$1(await Ie({absolutePath:s.join(t$1,"AGENTS.md"),generatedBody:it({index:y$1,context:g}),write:o$1}),"AGENTS.md"));let de=o$1?await st({workspacePath:t$1,staleAfterHours:n$1,now:r$1}):y$1,M=de.reports.filter(i=>i.required&&!i.exists).map(i=>i.path),q$1=de.reports.filter(i=>i.exists&&Tt(i,n$1,r$1)).map(i=>i.path);if(A$1){M.length>0&&O.push(`Missing required reports: ${M.join(", ")}`),q$1.length>0&&O.push(`Stale reports (>${n$1}h): ${q$1.join(", ")}`);let i=se.map(k=>k.path).filter(k=>!$t(k));i.length>0&&O.push(`Unsafe generated output paths: ${i.join(", ")}`);}let V=o$1?await g$1({workspacePath:t$1,mode:e.projectGrounding??"managed",now:r$1}):void 0;A$1&&V&&V.skipped.length>0&&O.push(`Project grounding incomplete: ${V.skipped.map(i=>`${i.name} (${i.reason})`).join(", ")}`);let _e=er({workspacePath:t$1,generatedAt:r$1.toISOString(),preset:p$3,targets:d,index:de,outputs:[...se,{path:K,kind:"report",targets:["agents","vscode","copilot","codex","orca"],required:true,status:o$1?"written":e.dryRun?"planned":"skipped"}],missingRequired:M,staleReports:q$1,strictViolations:O,experimentalHooks:e.experimentalHooks===true});if(o$1&&process.env.WORKSPAI_TEST_FAIL_AGENT_SYNC_BEFORE_PACK==="1")throw new Error("Injected agent-sync failure before generation commit.");return l$1(await u(s.join(t$1,K),`${JSON.stringify(_e,null,2)}
|
|
36
|
+
`,o$1),K),{workspacePath:t$1,indexPath:s.join(t$1,H),packPath:s.join(t$1,K),pack:_e,contextPath:h,writtenFiles:ae,skippedFiles:oe,blockers:y$1.blockers,missingRequired:M,staleReports:q$1,strictViolations:O,projectLenses:V}}async function zr(e){if(e.write!==true)return be(e);let t=s.resolve(e.workspacePath),r=s.join(t,".workspai","transactions","agent-sync");await b$4(r);let n=await be({...e,write:false,dryRun:true});if(!n.pack)throw new Error("Agent-sync dry run did not produce an output inventory.");let c=[...n.pack.outputInventory.map(p=>p.path),H,K],d=await a$1({journalDirectory:r});try{for(let A of [...new Set(c)].sort()){let h=s.resolve(t,A),g=s.relative(t,h);if(g===".."||g.startsWith(`..${s.sep}`)||s.isAbsolute(g))throw new Error(`Agent-sync output escapes workspace root: ${A}`);await d.captureFile(h);}let p=await h(t);for(let A of p.resolved)for(let h of [f,g,h$1,"AGENTS.md",".gitignore"])await d.captureFile(s.join(A.projectPath,h));let o=await be(e);return await d.commit(),o}catch(p){try{await d.rollback();}catch(o){throw new AggregateError([p,o],"Agent-sync generation failed and rollback was incomplete.")}throw p}}export{kt as a,ht as b,Ct as c,xt as d,Et as e,H as f,K as g,$ as h,It as i,st as j,Fr as k,zr as l};
|