workspai 0.55.1 → 0.56.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/contracts/artifact-remediation-plan.v1.json +110 -2
- package/contracts/cli-runtime-command-inventory.v1.snapshot.json +29 -1
- package/contracts/doctor-project-evidence.v1.json +68 -2
- package/contracts/doctor-remediation-plan.v1.json +29 -2
- package/contracts/doctor-workspace-evidence.v1.json +68 -2
- package/contracts/extension-cli-compatibility.v1.json +6 -1
- package/contracts/published-contract-catalog.v1.json +25 -0
- package/contracts/runtime-command-surface.v1.json +63 -0
- package/contracts/workspace-intelligence/doctor-capabilities.v1.json +133 -0
- package/contracts/workspace-intelligence/doctor-diagnosis.v1.json +273 -0
- package/contracts/workspace-intelligence/doctor-graph-diagnosis.v1.json +3 -0
- package/contracts/workspace-intelligence/doctor-receipt.v1.json +136 -0
- package/contracts/workspace-intelligence/doctor-summary.v1.json +99 -0
- package/contracts/workspace-intelligence/doctor-validation.v1.json +109 -0
- package/contracts/workspace-intelligence/project-context-agent.v1.json +110 -0
- package/contracts/workspace-intelligence/studio-blocker-handoff.v1.json +25 -0
- package/contracts/workspace-intelligence/workspace-knowledge-graph.v1.json +36 -0
- package/contracts/workspace-intelligence/workspace-knowledge-search.v1.json +54 -0
- package/dist/analyze-HJ774J3E.js +1 -0
- package/dist/{artifact-remediation-plan-O3YIULQN.js → artifact-remediation-plan-BPLON5VX.js} +1 -1
- package/dist/autopilot-release-CH57CGET.js +1 -0
- package/dist/capabilities-command-WEOGFCWF.js +1 -0
- package/dist/chunk-2647BYBC.js +1 -0
- package/dist/chunk-2L4PSZQB.js +1 -0
- package/dist/chunk-3U4VLIGW.js +1 -0
- package/dist/chunk-5BGPGNRQ.js +2 -0
- package/dist/chunk-5EPPPMAS.js +1 -0
- package/dist/{chunk-M5ICGR55.js → chunk-5RL254O2.js} +1 -1
- package/dist/chunk-5ZA4JYOP.js +1 -0
- package/dist/{chunk-AMB42V2F.js → chunk-64JUYYRC.js} +1 -1
- package/dist/chunk-664GXRLD.js +1 -0
- package/dist/chunk-6HCAGHCY.js +8 -0
- package/dist/chunk-7PNARN6S.js +4 -0
- package/dist/chunk-7Y3KVZJF.js +8 -0
- package/dist/{chunk-WIO6L24E.js → chunk-ADL3CK44.js} +1 -1
- package/dist/chunk-AO2ZI42U.js +4 -0
- package/dist/chunk-BDN32Y2N.js +81 -0
- package/dist/chunk-D4RST2HE.js +1 -0
- package/dist/{chunk-6HJJHEL6.js → chunk-DIZSHNZ5.js} +1 -1
- package/dist/chunk-DOIZANFA.js +2 -0
- package/dist/{chunk-HY3RMPW5.js → chunk-E53BGUOW.js} +1 -1
- package/dist/{chunk-FZCYTRBQ.js → chunk-ESWFBSYM.js} +1 -1
- package/dist/chunk-GBMCHFOV.js +1 -0
- package/dist/{chunk-HUPLAFZQ.js → chunk-HASVV34S.js} +1 -1
- package/dist/chunk-IZLEMTES.js +1 -0
- package/dist/chunk-KR7CIEQR.js +1 -0
- package/dist/chunk-KS4FB5W7.js +6 -0
- package/dist/chunk-LYVDRRDO.js +2 -0
- package/dist/{chunk-IBPPMOHM.js → chunk-NHTLE3WN.js} +1 -1
- package/dist/chunk-NS53IPAC.js +1 -0
- package/dist/{chunk-YTLUT6IA.js → chunk-OX53L237.js} +2 -2
- package/dist/chunk-PKIRVQLG.js +1 -0
- package/dist/chunk-QAF26ZQX.js +36 -0
- package/dist/{chunk-NWQ5VWUW.js → chunk-QFCKHUEP.js} +1 -1
- package/dist/chunk-QRWWYL52.js +88 -0
- package/dist/chunk-QTCZPS5I.js +1 -0
- package/dist/{chunk-WSAFBPS5.js → chunk-SV2SP22H.js} +4 -4
- package/dist/chunk-T5YRFRJV.js +1 -0
- package/dist/chunk-UQEQ6CXU.js +1 -0
- package/dist/chunk-V5EYVQ63.js +1 -0
- package/dist/chunk-VGJVIHHR.js +1 -0
- package/dist/{chunk-MRFN5ZQP.js → chunk-W5ZFXKSL.js} +1 -1
- package/dist/chunk-WLCBXCZV.js +5 -0
- package/dist/chunk-WOTTSPSF.js +2 -0
- package/dist/chunk-X7FYEKLI.js +1 -0
- package/dist/chunk-XH7PDHBF.js +1 -0
- package/dist/{chunk-KFKZOPZC.js → chunk-XMTLKDPP.js} +1 -1
- package/dist/chunk-YJTEMJFV.js +3 -0
- package/dist/chunk-YM77FQB3.js +8 -0
- package/dist/chunk-ZCPT6KC3.js +6 -0
- package/dist/chunk-ZPA6ECBJ.js +7 -0
- package/dist/{create-3NSOY7CA.js → create-DLUWG46F.js} +1 -1
- package/dist/doctor-IZ4YOCYE.js +1 -0
- package/dist/index.d.ts +15 -0
- package/dist/index.js +168 -168
- package/dist/pipeline-IBQYDLFF.js +5 -0
- package/dist/{project-intelligence-lens-ZOAWXYC5.js → project-intelligence-lens-SIU7IXKG.js} +1 -1
- package/dist/project-test-coverage-FRMVYTFB.js +1 -0
- package/dist/verified-goal-M4GPOXNL.js +1 -0
- package/dist/{workspace-C4UETGY7.js → workspace-3AAOUELG.js} +1 -1
- package/dist/{workspace-agent-sync-446AXPHJ.js → workspace-agent-sync-QGYLY7HH.js} +1 -1
- package/dist/{workspace-archive-VHUPOBAV.js → workspace-archive-BA3ONVXX.js} +1 -1
- package/dist/{workspace-context-XSECHC7O.js → workspace-context-JCLPRYNC.js} +1 -1
- package/dist/workspace-contract-IUUPBQXU.js +1 -0
- package/dist/workspace-explain-CZGBVDE6.js +1 -0
- package/dist/workspace-explain-contract-KVQO57RC.js +1 -0
- package/dist/{workspace-feedback-WXE7NVMV.js → workspace-feedback-PCZKXG5R.js} +1 -1
- package/dist/{workspace-foundation-3EVAQ5X6.js → workspace-foundation-7IGMO4CW.js} +1 -1
- package/dist/{workspace-graph-stream-AJPS45FD.js → workspace-graph-stream-5YMLJXAJ.js} +1 -1
- package/dist/workspace-graph-token-efficiency-HK4KNWWP.js +1 -0
- package/dist/{workspace-history-YY7YRDOH.js → workspace-history-CHJOABME.js} +1 -1
- package/dist/{workspace-intelligence-FWRB47EJ.js → workspace-intelligence-XHSUFTAT.js} +1 -1
- package/dist/workspace-intelligence-evaluation-YMY3C5AW.js +1 -0
- package/dist/{workspace-intelligence-runner-SMEAB4CO.js → workspace-intelligence-runner-EN5V4KSC.js} +1 -1
- package/dist/workspace-intelligence-runtime-registry-NCVHKCMP.js +1 -0
- package/dist/workspace-knowledge-graph-VWQTIEYK.js +1 -0
- package/dist/{workspace-knowledge-graph-query-EKHIE3E2.js → workspace-knowledge-graph-query-TXA3KVUV.js} +1 -1
- package/dist/workspace-knowledge-graph-snapshot-WB62AVDK.js +1 -0
- package/dist/workspace-mcp-serve-NCAGGWQS.js +3 -0
- package/dist/{workspace-model-MNJOGBPP.js → workspace-model-NXFIKX26.js} +1 -1
- package/dist/{workspace-onboarding-5KO7Z7AD.js → workspace-onboarding-OP22NHQ4.js} +1 -1
- package/dist/{workspace-readme-4S6PJ74A.js → workspace-readme-IVJXSIBS.js} +1 -1
- package/dist/{workspace-registry-summary-GPJEL7K7.js → workspace-registry-summary-A5VDPRHU.js} +1 -1
- package/dist/workspace-repair-engine-N4KXNSVL.js +3 -0
- package/dist/workspace-run-PXKC3ELS.js +1 -0
- package/dist/{workspace-verify-C6HWHRLJ.js → workspace-verify-TUVLFPPN.js} +1 -1
- package/dist/{workspace-watch-DLPHLF5R.js → workspace-watch-2ZNOYSUQ.js} +1 -1
- package/docs/commands-reference.md +35 -6
- package/docs/contracts/ARTIFACT_CATALOG.md +6 -1
- package/docs/contracts/README.md +5 -0
- package/docs/doctor-command.md +158 -7
- package/docs/graph-benchmark-methodology.md +13 -0
- package/docs/workspace-intelligence-runner.md +4 -0
- package/docs/workspace-knowledge-graph.md +53 -4
- package/docs/workspace-run.md +14 -3
- package/package.json +10 -3
- package/dist/analyze-AAZEJ4FC.js +0 -1
- package/dist/autopilot-release-3H5FTF6H.js +0 -1
- package/dist/chunk-2PY65U6X.js +0 -5
- package/dist/chunk-3DONU3DU.js +0 -1
- package/dist/chunk-44VJHNZB.js +0 -1
- package/dist/chunk-5XDPQ3CB.js +0 -1
- package/dist/chunk-7AR5PDLD.js +0 -1
- package/dist/chunk-7KKP7RNB.js +0 -3
- package/dist/chunk-7S4QNH5A.js +0 -5
- package/dist/chunk-7T4TSV5C.js +0 -1
- package/dist/chunk-BYVTHIC3.js +0 -2
- package/dist/chunk-CEIJIFY7.js +0 -88
- package/dist/chunk-D37NEYV6.js +0 -1
- package/dist/chunk-DPMO4U3Z.js +0 -8
- package/dist/chunk-DS4UYMLX.js +0 -1
- package/dist/chunk-FQLB4BIC.js +0 -7
- package/dist/chunk-GDU7VP6G.js +0 -1
- package/dist/chunk-H7P7SSUW.js +0 -75
- package/dist/chunk-KVUYAYTY.js +0 -8
- package/dist/chunk-MQ73VS4E.js +0 -2
- package/dist/chunk-NYHVCFBT.js +0 -1
- package/dist/chunk-OUBBBC7T.js +0 -36
- package/dist/chunk-P7K5RHJC.js +0 -2
- package/dist/chunk-PS5F4DCT.js +0 -1
- package/dist/chunk-QZ7PNMVP.js +0 -1
- package/dist/chunk-RA24WQLF.js +0 -1
- package/dist/chunk-RMXXK64P.js +0 -4
- package/dist/chunk-S7Z4DP3P.js +0 -2
- package/dist/chunk-SJLUE6AY.js +0 -1
- package/dist/chunk-TEHQ7XKK.js +0 -3
- package/dist/chunk-UFOCUHG3.js +0 -1
- package/dist/chunk-WD2XDMGB.js +0 -1
- package/dist/chunk-XVRJVKOX.js +0 -1
- package/dist/doctor-UEFFNAUD.js +0 -1
- package/dist/pipeline-B5S6P36F.js +0 -5
- package/dist/project-test-coverage-44ZPCOPV.js +0 -1
- package/dist/verified-goal-KOU3WJYN.js +0 -1
- package/dist/workspace-contract-AYFTZIKM.js +0 -1
- package/dist/workspace-explain-ZEWVKDBF.js +0 -1
- package/dist/workspace-explain-contract-6CCC26QT.js +0 -1
- package/dist/workspace-graph-token-efficiency-5FNH4JZ5.js +0 -1
- package/dist/workspace-intelligence-evaluation-UP2K3L35.js +0 -1
- package/dist/workspace-intelligence-runtime-registry-MRSF7RTT.js +0 -1
- package/dist/workspace-knowledge-graph-BMMM2FUE.js +0 -1
- package/dist/workspace-mcp-serve-X6C3AWTA.js +0 -3
- package/dist/workspace-repair-engine-GWTXVVKB.js +0 -3
- package/dist/workspace-run-FJTBX4JQ.js +0 -1
package/dist/chunk-D37NEYV6.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import {a as a$2}from'./chunk-FPJNWPKU.js';import {b as b$1,a as a$1,c,e as e$1}from'./chunk-44VJHNZB.js';var v="workspai.studio-card-repair-capabilities.v1",k="npx workspai workspace verify --json",r=a$1,a=e$1;function e(f,n,c,o={}){return {cardId:f,scope:o.scope??"workspace",producerCommand:n,producerArtifact:c,verifyCommand:n,verifyArtifact:c,aggregateVerifyCommand:k,targetClosure:"exact-producer-and-causal-action-set",workspacePosture:"reported-separately",repairPolicy:o.repairPolicy??"refresh-producer",remediationArtifacts:o.remediationArtifacts??[]}}var b=[e("doctor","npx workspai doctor workspace --json",r.doctor,{repairPolicy:"diagnose-and-repair",remediationArtifacts:[a.doctorRemediationPlan,a.artifactRemediationPlan]}),e("projectDoctor","npx workspai doctor project --json",a.doctorProject,{scope:"project",repairPolicy:"diagnose-and-repair",remediationArtifacts:[a.doctorRemediationPlan,a.artifactRemediationPlan]}),e("pipeline","npx workspai pipeline --json --strict",a.pipelineLastRun,{repairPolicy:"source-repair-then-produce",remediationArtifacts:[a.artifactRemediationPlan]}),e("analyze","npx workspai analyze --json",r.analyze,{repairPolicy:"source-repair-then-produce",remediationArtifacts:[a.artifactRemediationPlan]}),e("readiness","npx workspai readiness --json",r.readiness,{repairPolicy:"source-repair-then-produce",remediationArtifacts:[a.artifactRemediationPlan]}),e("bootstrap","npx workspai bootstrap --ci --json",a.bootstrapCompliance,{repairPolicy:"source-repair-then-produce",remediationArtifacts:[a.artifactRemediationPlan]}),e("workspaceSync","npx workspai workspace sync --json",a.workspaceRegistry),e("foundation","npx workspai workspace foundation ensure --json",".workspai/workspace.json"),e("contract","npx workspai workspace contract verify --strict --json",r.contractVerify,{repairPolicy:"source-repair-then-produce"}),e("autopilot","npx workspai autopilot release --json",a.autopilotReleaseLastRun,{repairPolicy:"source-repair-then-produce"}),e("workspaceRun","npx workspai workspace run test --json",a.workspaceRunLast,{repairPolicy:"source-repair-then-produce",remediationArtifacts:[a.artifactRemediationPlan]}),e("setup","npx workspai setup --json",".workspai/toolchain.lock",{repairPolicy:"source-repair-then-produce"}),e("importReadiness","npx workspai doctor project --json",a.doctorProject,{scope:"project",repairPolicy:"diagnose-and-repair",remediationArtifacts:[a.artifactRemediationPlan]}),e("snapshot","npx workspai snapshot create --json",".workspai/reports/snapshot-last-run.json"),e("workspaceModel","npx workspai workspace model --json --write",r.model),e("intelligenceSnapshot","npx workspai workspace snapshot --json",r.snapshot),e("workspaceDiff",`npx workspai workspace diff --from ${r.snapshot} --json`,r.diff),e("workspaceImpact",`npx workspai workspace impact --from ${r.diff} --json`,r.impact),e("workspaceIntelligenceRun","npx workspai workspace intelligence run --for-agent generic --strict --json",r.intelligenceRun,{repairPolicy:"source-repair-then-produce"}),e("workspaceVerify",k,r.verify,{repairPolicy:"source-repair-then-produce",remediationArtifacts:[a.artifactRemediationPlan]}),e("workspaceExplain","npx workspai workspace explain release-blocked --json --write",r.explain),e("workspaceWhy","npx workspai workspace why release-blocked --json --write",a.workspaceWhy),e("workspaceTrace",`npx workspai workspace trace --from ${r.diff} --json --write`,a.workspaceTrace),e("workspaceWatch","npx workspai workspace watch --once --json",r.model),e("workspaceContextAgent","npx workspai workspace context --for-agent --json --write",r.agentContext),e("agentGrounding","npx workspai workspace agent-sync --write --refresh-context --json --preset enterprise --target vscode",r.agentCustomizationPack),e("share",`npx workspai workspace share --output ${a.workspaceShareBundle} --json`,a.workspaceShareBundle),e("archive","npx workspai workspace export --output team-workspace.workspai-archive.zip --json",".workspai/archive-manifest.json"),e("mirror","npx workspai mirror status --json",a.mirrorOps),e("cache","npx workspai cache status --json",".workspai/cache-config.yml"),e("policy","npx workspai workspace policy show --json",".workspai/policies.yml",{repairPolicy:"source-repair-then-produce"}),e("infra","npx workspai infra plan --json",a.infraPlan,{repairPolicy:"source-repair-then-produce"})];var g=b$1.repairTransaction,h=a$1.repairTransaction,E=c.repairTransaction;var m="workspai.workspace-repair-proposal.v1",I="contracts/workspace-intelligence/workspace-repair-proposal.v1.json";var R="workspai.workspace-repair-capabilities.v1",y="workspai.workspace-repair-consumer-protocol.v1",w=[{id:"node",ecosystem:"JavaScript / TypeScript",manifests:["package.json"],lockfiles:["package-lock.json","npm-shrinkwrap.json","pnpm-lock.yaml","yarn.lock","bun.lock","bun.lockb"],packageManagers:["npm","pnpm","yarn","bun"],support:"full",stages:{reconcile:"native",audit:"native",test:"declared",build:"declared"},requiredToolFamilies:["selected package manager"]},{id:"python",ecosystem:"Python",manifests:["pyproject.toml","requirements.txt"],lockfiles:["uv.lock","poetry.lock","requirements.txt"],packageManagers:["uv","poetry","pip"],support:"conditional",stages:{reconcile:"conditional",audit:"conditional",test:"conditional",build:"declared"},requiredToolFamilies:["isolated Python","selected environment manager","pip-audit or governed Doctor audit"],limitation:"A bounded isolated environment and an installed audit surface are required."},{id:"go",ecosystem:"Go",manifests:["go.mod"],lockfiles:["go.sum"],packageManagers:["go modules"],support:"conditional",stages:{reconcile:"native",audit:"conditional",test:"native",build:"native"},requiredToolFamilies:["go","govulncheck"],limitation:"govulncheck must be installed; the engine never fetches an unreviewed tool."},{id:"rust",ecosystem:"Rust",manifests:["Cargo.toml"],lockfiles:["Cargo.lock"],packageManagers:["cargo"],support:"conditional",stages:{reconcile:"native",audit:"conditional",test:"native",build:"native"},requiredToolFamilies:["cargo","cargo-audit"],limitation:"The cargo-audit subcommand must already be installed."},{id:"php-composer",ecosystem:"PHP",manifests:["composer.json"],lockfiles:["composer.lock"],packageManagers:["composer"],support:"full",stages:{reconcile:"native",audit:"native",test:"declared",build:"declared"},requiredToolFamilies:["composer"]},{id:"ruby-bundler",ecosystem:"Ruby",manifests:["Gemfile"],lockfiles:["Gemfile.lock"],packageManagers:["bundler"],support:"conditional",stages:{reconcile:"native",audit:"conditional",test:"declared",build:"declared"},requiredToolFamilies:["bundle","bundle-audit"],limitation:"bundle-audit and the declared Rake tasks must already exist."},{id:"elixir-mix",ecosystem:"Elixir",manifests:["mix.exs"],lockfiles:["mix.lock"],packageManagers:["mix"],support:"conditional",stages:{reconcile:"native",audit:"conditional",test:"native",build:"native"},requiredToolFamilies:["mix","Hex audit task"],limitation:"The project must expose the Hex audit task used by its dependency policy."},{id:"deno",ecosystem:"Deno",manifests:["deno.json","deno.jsonc"],lockfiles:["deno.lock"],packageManagers:["deno"],support:"full",stages:{reconcile:"native",audit:"native",test:"declared",build:"declared"},requiredToolFamilies:["deno"]},{id:"dotnet",ecosystem:".NET",manifests:["*.sln","*.csproj","*.fsproj","*.vbproj"],lockfiles:["Directory.Packages.props","packages.lock.json"],packageManagers:["NuGet / dotnet"],support:"full",stages:{reconcile:"native",audit:"native",test:"native",build:"native"},requiredToolFamilies:["dotnet"]},{id:"jvm-maven",ecosystem:"JVM / Maven",manifests:["pom.xml"],lockfiles:[],packageManagers:["Maven Wrapper","Maven"],support:"conditional",stages:{reconcile:"native",audit:"conditional",test:"native",build:"native"},requiredToolFamilies:["mvnw or mvn","governed Doctor audit"],limitation:"A project-specific dependency audit command must be declared by Doctor evidence."},{id:"jvm-gradle",ecosystem:"JVM / Gradle",manifests:["build.gradle.kts","build.gradle"],lockfiles:["gradle.lockfile","gradle/libs.versions.toml"],packageManagers:["Gradle Wrapper","Gradle"],support:"conditional",stages:{reconcile:"native",audit:"conditional",test:"native",build:"native"},requiredToolFamilies:["gradlew or gradle","governed Doctor audit"],limitation:"A project-specific dependency audit command must be declared by Doctor evidence."},{id:"clojure",ecosystem:"Clojure",manifests:["deps.edn","project.clj"],lockfiles:[],packageManagers:["Clojure CLI","Leiningen"],support:"conditional",stages:{reconcile:"native",audit:"conditional",test:"conditional",build:"conditional"},requiredToolFamilies:["clojure or lein","governed project audit"],limitation:"Tests and builds run only when the selected Clojure project surface declares a deterministic entrypoint."},{id:"scala-sbt",ecosystem:"Scala / sbt",manifests:["build.sbt"],lockfiles:[],packageManagers:["sbt"],support:"conditional",stages:{reconcile:"native",audit:"conditional",test:"native",build:"native"},requiredToolFamilies:["sbt","governed project audit"],limitation:"A project-specific dependency audit command must be declared by Doctor evidence."}];function M(){return {schemaVersion:R,owner:"Workspai CLI",workflow:["plan","preconditions","approval","target-precondition","checkpoint","execute","reconcile","audit","test","build","target-producer-verify","canonical-verify","close-or-rollback-or-decision"],invariants:{multiAdapterProjects:true,missingTools:"decision-required",unsupportedEcosystems:"decision-required",silentFallbackToModelExecution:false,mutationAuthority:"cli-only",targetClosure:"selected-causal-action-set",changeReceipt:"checkpoint-hash-delta",consumerTimeline:"durable-transaction-events",typedDecisionCauses:true,consumerHandshakeRequired:true,ephemeralProposalsAreEvidence:false,approvalBoundToPlanHash:true,canonicalVerificationRequired:true,rollbackConflictDetection:true},consumerProtocol:{protocolVersion:y,versionProbe:{args:["--version","--json"],schemaVersion:"rapidkit-version-v1"},capabilityProbe:{args:["workspace","repair","capabilities","--json"],schemaVersion:R},invocation:{command:"workspace repair",workspaceResolution:["process-cwd","--workspace"],actions:["capabilities","plan","propose","approve","decide","execute","resume","status","list","rollback","cancel"]},contracts:{operationResult:a$2,proposal:m,transaction:g},transientPaths:[".workspai/repair/inbox/*.json",".workspai/repair/engine.lock"]},adapters:w}}export{v as a,b,g as c,h as d,E as e,m as f,I as g,R as h,w as i,M as j};
|
package/dist/chunk-DPMO4U3Z.js
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import {a as a$2}from'./chunk-7S4QNH5A.js';import {a as a$5}from'./chunk-MRFN5ZQP.js';import {a as a$3,e}from'./chunk-WD2XDMGB.js';import {d,a as a$1,e as e$1}from'./chunk-WIO6L24E.js';import {a,d as d$1}from'./chunk-44VJHNZB.js';import a$4 from'chalk';import re from'fs';import b from'path';import {execa}from'execa';var V="autopilot-release-last-run.json",G="autopilot-release.json";function $(r){try{return JSON.parse(r)}catch{return null}}function Se(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 oe(r){let e=r.toLowerCase();return e==="pass"?"pass":e==="warn"?"warn":e==="fail"?"fail":"warn"}function ae(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 be(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 Ae(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 re.promises.mkdir(b.dirname(r),{recursive:true}),await re.promises.writeFile(r,`${JSON.stringify(e,null,2)}
|
|
2
|
-
`,"utf-8");}async function ze(r){let e$2=Se(r.workspacePath),n=r.mode,o=[],t=[],L,H,N,q,Q,X=0,f=false,I=0,_=0,W=-1,T=-1,c="skipped",d$2="skipped",ne=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([...ne],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=$(l.stdout),E=p&&p.healthScore&&typeof p.healthScore=="object"?p.healthScore:{},k=Number(E.errors??0),C=Number(E.warnings??0);Number.isFinite(k)&&k>0?(c="fail",t.push(`doctor workspace reports ${k} error(s)`)):Number.isFinite(C)&&C>0&&(c="warn");}W=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),P=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=$(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:P,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 v=Date.now(),h=await S(["readiness","--json"],e$2),y=Date.now()-v;if(d$2="fail",h.crashed)d$2="fail",f=true,t.push(`readiness execution error: ${h.stderr||"unknown error"}`);else if(h.exitCode!==0)d$2="fail",t.push("readiness command failed");else {let p=$(h.stdout),E=String(p?.overallStatus??"fail");if(d$2=oe(E),typeof p?.evidencePath=="string"&&p.evidencePath.trim().length>0&&(L=p.evidencePath),d$2==="fail"){let k=Array.isArray(p?.blockingReasons)?p?.blockingReasons.filter(C=>typeof C=="string"):[];k.length>0?t.push(...k.map(C=>`readiness: ${C}`)):t.push("readiness overall status is fail");}}T=o.push({name:"readiness",status:d$2,durationMs:y,summary:`readiness overall status is ${d$2}`})-1,n==="enforce"&&d$2==="warn"&&t.push("readiness reported warnings under enforce mode");}let ie=Date.now(),D=await S(["doctor","workspace","--plan","--json"],e$2),le=Date.now()-ie,R="warn";if(D.crashed)R="fail",f=true,t.push(`doctor remediation plan execution error: ${D.stderr||"unknown error"}`);else if(D.exitCode!==0)R="fail",t.push("doctor remediation plan command failed");else {let s=$(D.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&&(I=m),Number.isFinite(g)&&g>0&&(_=g),Number.isFinite(m)&&m===0?R="pass":R="warn";}if(o.push({name:"remediation-plan",status:R,durationMs:le,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=_>0?_:I>0?I: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=$(w.stdout),v=i&&i.healthScore&&typeof i.healthScore=="object"?i.healthScore:{},h=Number(v.errors??0),y=Number(v.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";}W>=0&&(o[W].status=c,o[W].summary=`doctor workspace post-apply status is ${c}`);let P=await S(["readiness","--json"],e$2);if(P.crashed)d$2="fail",f=true,t.push(`post-apply readiness execution error: ${P.stderr||"unknown error"}`);else if(P.exitCode!==0)d$2="fail",t.push("post-apply readiness command failed");else {let i=$(P.stdout),v=String(i?.overallStatus??"fail");if(d$2=oe(v),typeof i?.evidencePath=="string"&&i.evidencePath.trim().length>0&&(L=i.evidencePath),d$2==="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");}}T>=0&&(o[T].status=d$2,o[T].summary=`readiness post-apply overall status is ${d$2}`);}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 ce=Date.now(),A="pass",x="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});N=a$1(e$2,b.join(".workspai","reports",a$3)),await e(e$2,s),q=N;let l=ae(s);if(l==="fail")A="fail",x="workspace test stage failed for selected projects",t.push("workspace run test failed for selected projects");else {l==="warn"&&(A="warn",x="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=N;let g=ae(m);g==="fail"?(A="fail",x="workspace build stage failed for selected projects",t.push("workspace run build failed for selected projects")):g==="warn"&&(A="warn",x="workspace test/build completed with warnings",n==="enforce"&&t.push("workspace run test/build reported warnings under enforce mode"));}}catch(s){A="fail",x="workspace test/build orchestration failed",f=true,t.push(`workspace run orchestration error: ${s instanceof Error?s.message:String(s)}`);}let pe=Date.now()-ce;o.push({name:"workspace-run-test-build",status:A,durationMs:pe,summary:x});let M=o.filter(s=>s.status==="warn").length,ue=o.filter(s=>s.status==="fail").length,F=n==="enforce"?o.some(s=>s.status==="warn"||s.status==="fail"):ue>0,j=[...new Set(t)],O=f||F?Math.max(1,j.length):0,de=O>0?j:[],fe=O===0?j:[],me=be(o),ge=f||F?"blocked":M>0?"partial":"approved",we=f?3:F?1:M>0?2:0,he=Ae({mode:n,executionError:f,blockers:j,hasWarnings:M>0}),Y=a$1(e$2,".workspai/reports"),ke=b.join(Y,V),ye=b.join(Y,G),u={schemaVersion:d$1.autopilotReleaseLastRun.schemaVersion,generatedAt:new Date().toISOString(),workspacePath:e$2,mode:n,summary:{releaseScore:me,verdict:ge,blockers:O,warnings:M,safeFixesApplied:X,manualActions:j.length,exitCode:we},stages:o,blockingReasons:de,warningReasons:fe,nextActions:he,artifacts:{reportPath:ke,aliasEvidencePath:ye,analyzeEvidencePath:H,readinessEvidencePath:L,workspaceRunEvidencePath:N,workspaceRunTestPath:q,workspaceRunBuildPath:Q},enterpriseControls:{jsonReady:true,evidencePath:`.workspai/reports/${V}`,aliasEvidencePath:`.workspai/reports/${G}`}};if(await e$1(e$2,`.workspai/reports/${V}`,u),await e$1(e$2,`.workspai/reports/${G}`,u),r.output&&await xe(b.resolve(r.output),u),!r.json){console.log(a$4.bold.cyan(`
|
|
3
|
-
\u{1F680} Workspai Autopilot Release
|
|
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(`
|
|
5
|
-
Blocking reasons:`));for(let s of u.blockingReasons)console.log(a$4.red(` - ${s}`));}if(u.warningReasons.length>0){console.log(a$4.bold.yellow(`
|
|
6
|
-
Warning reasons:`));for(let s of u.warningReasons)console.log(a$4.yellow(` - ${s}`));}if(u.nextActions.length>0){console.log(a$4.bold(`
|
|
7
|
-
Next actions:`));for(let s of u.nextActions)console.log(a$4.gray(` - ${s}`));}console.log(a$4.gray(`
|
|
8
|
-
Report: ${u.artifacts.reportPath}`));}return u}export{V as a,G as b,ze as c};
|
package/dist/chunk-DS4UYMLX.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import {b as b$1,c as c$1}from'./chunk-YTLUT6IA.js';import {a as a$2}from'./chunk-KVUYAYTY.js';import {q as q$1}from'./chunk-CEIJIFY7.js';import {a as a$3}from'./chunk-RMXXK64P.js';import {g}from'./chunk-WSAFBPS5.js';import {j as j$1,e as e$1}from'./chunk-GDU7VP6G.js';import {j,l as l$2}from'./chunk-OUBBBC7T.js';import {c,d}from'./chunk-P7K5RHJC.js';import {a as a$1}from'./chunk-RA24WQLF.js';import {f,g as g$1,h as h$2}from'./chunk-XVRJVKOX.js';import {k as k$1,l as l$1,h as h$1,m as m$1,n,p as p$1,q}from'./chunk-S7Z4DP3P.js';import {m,p,s}from'./chunk-7AR5PDLD.js';import {o,r as r$1,s as s$1}from'./chunk-MQ73VS4E.js';import {e}from'./chunk-WIO6L24E.js';import {b as b$2}from'./chunk-BYVTHIC3.js';import {a,b,k,l,j as j$2,i}from'./chunk-44VJHNZB.js';import {d as d$1}from'./chunk-VRW6KXNK.js';import ce from'path';import le from'fs-extra';function r(t,s){if(!t)throw new Error(`Workspace Intelligence run semantic violation: ${s}`)}function ne(t,s){return t.length===s.length&&t.every((p,d)=>p===s[d])}function oe(t){b$2(a.intelligenceRun,t,"Workspace Intelligence run report"),r(t.chainSchemaVersion===a$1,`chainSchemaVersion must be ${a$1}`),r(t.artifactPath===a.intelligenceRun,`artifactPath must be ${a.intelligenceRun}`),r(t.preflight.length===j$2.length,`preflight must contain exactly ${j$2.length} entries`);for(let[o,i]of j$2.entries()){let a=t.preflight[o];r(a?.id===i,`preflight[${o}].id must be ${i}`),r(ne(a.artifacts,k[i]),`${i} preflight artifacts must match the runtime registry`),i==="sync"?r(a.status==="passed"&&a.result==="synchronized"||a.status==="failed"&&a.result==="failed","sync preflight status and result are incoherent"):r(a.status==="passed"&&(a.result==="created"||a.result==="reused")||a.status==="failed"&&a.result==="failed"||a.status==="skipped"&&a.result==="skipped","baseline preflight status and result are incoherent");}let s=t.preflight[1];r(t.baselineCreated===(s?.result==="created"),"baselineCreated must match the baseline preflight result"),r(t.stages.length===i.length,`stages must contain exactly ${i.length} canonical steps`);let p=t.preflight[0],d=p?.status==="failed";for(let[o,i$1]of i.entries()){let a=t.stages[o];r(a?.id===i$1,`stages[${o}].id must be ${i$1}`),r(ne(a.artifacts,l[i$1].produces),`${i$1} artifacts must match the runtime registry`),d&&r(a.status==="skipped",`${i$1} must be skipped after a hard failure`),a.status==="passed"?r(a.exitCode===0,`${i$1} passed stage must have exitCode 0`):a.status==="blocked"?r(a.exitCode!==0,`${i$1} blocked stage must have a non-zero exitCode`):a.status==="failed"?(r(a.exitCode===1,`${i$1} failed stage must have exitCode 1`),d=true):(r(a.exitCode===0,`${i$1} skipped stage must have exitCode 0`),r(a.durationMs===0,`${i$1} skipped stage must have durationMs 0`)),o===0&&((p?.status==="failed"||a.status==="failed")&&r(s?.status==="skipped","baseline must be skipped when sync or model fails"),s?.status==="skipped"&&r(p?.status==="failed"||a.status==="failed"||a.status==="skipped","baseline may be skipped only after an upstream failure"),s?.status!=="passed"&&(d=true));}let m=t.preflight.some(o=>o.status==="failed")||t.stages.some(o=>o.status==="failed"),y=t.stages.some(o=>o.status==="blocked"),n=m?"failed":y?"blocked":"passed",f=n==="failed"?1:n==="blocked"?2:0;r(t.status===n,`status must be ${n}`),r(t.exitCode===f,`exitCode must be ${f}`);}var ke=a.intelligenceRun,he=b.intelligenceRun,de=ke;function h(t){d$1({action:"intelligence",status:t.status==="started"?"started":t.status==="passed"?"succeeded":t.status==="failed"?"failed":"warn",message:t.message,metadata:{phase:`workspace.intelligence.${t.kind}.${t.id}`,intelligenceMilestoneId:t.id,intelligenceMilestoneKind:t.kind,intelligenceMilestoneStatus:t.status}});}async function De(t){let s$2=ce.resolve(t.workspacePath),p$2=[],d$1=[],m$2=false,y=async(e,l)=>{let g=[...k[e]];if(m$2){h({id:e,kind:"preflight",status:"skipped",message:`${e} prerequisite skipped after an upstream failure`}),p$2.push({id:e,status:"skipped",result:"skipped",durationMs:0,artifacts:g,message:"skipped because a required upstream operation failed"});return}let I=Date.now();h({id:e,kind:"preflight",status:"started",message:`${e} prerequisite started`});try{let c=await l();h({id:e,kind:"preflight",status:"passed",message:c.message}),p$2.push({id:e,status:"passed",result:c.result,durationMs:Date.now()-I,artifacts:g,message:c.message});}catch(c){m$2=true;let k=c instanceof Error?c.message:String(c);h({id:e,kind:"preflight",status:"failed",message:k}),p$2.push({id:e,status:"failed",result:"failed",durationMs:Date.now()-I,artifacts:g,message:k});}},n$1=async(e,l$1)=>{let g=[...l[e].produces];if(m$2){h({id:e,kind:"stage",status:"skipped",message:`${e} skipped after an upstream failure`}),d$1.push({id:e,status:"skipped",durationMs:0,artifacts:g,exitCode:0,message:"skipped because a required upstream stage failed"});return}let I=Date.now();h({id:e,kind:"stage",status:"started",message:`${e} started`});try{let c=await l$1(),k=c.exitCode??0,A=c.blocked||k!==0?"blocked":"passed";h({id:e,kind:"stage",status:A,message:c.message}),d$1.push({id:e,status:A,durationMs:Date.now()-I,artifacts:g,exitCode:k,message:c.message});}catch(c){m$2=true;let k=c instanceof Error?c.message:String(c);h({id:e,kind:"stage",status:"failed",message:k}),d$1.push({id:e,status:"failed",durationMs:Date.now()-I,artifacts:g,exitCode:1,message:k});}};await y("sync",async()=>{let e=await g(s$2,true),l=await o({workspacePath:s$2});return {result:"synchronized",message:`registry ${e.added.length} added/${e.skipped} existing; contract ${l.contract.projects.length} projects`}});let f$1,o$1=()=>{if(!f$1)throw new Error("canonical workspace model is unavailable");return f$1};await n$1("model",async()=>(f$1={...await p({workspacePath:s$2,includeEvidence:true}),build:m({mode:"full",engineStatus:"disabled"})},await s(f$1,s$2),{message:`${f$1.summary.projectCount} projects modeled`}));let i=ce.join(s$2,a.snapshot),a$4=false;await y("baseline",async()=>{if(!await le.pathExists(i)){let g=await k$1({workspacePath:s$2,model:o$1()});return await l$1(g,s$2),a$4=true,{result:"created",message:"initial structural baseline created"}}let e=await le.readJson(i),l=h$1(e);return l?(await l$1(l,s$2),{result:"reused",message:"legacy structural baseline migrated and reused"}):{result:"reused",message:"existing structural baseline reused"}}),await n$1("diff",async()=>{let e=await m$1({workspacePath:s$2,fromPath:a.snapshot,model:o$1()});return await n(e,s$2),{message:e.summary.changed?"workspace changes detected":"no workspace changes"}}),await n$1("impact",async()=>{let e=await p$1({workspacePath:s$2,fromPath:a.diff});return await q(e,s$2),{message:`${e.summary.risk} risk; ${e.summary.affectedProjects} affected`}}),await n$1("doctor-evidence",async()=>{let e=await q$1({workspace:s$2,json:true,quiet:true});return {exitCode:e,blocked:e!==0,message:`doctor exit ${e}`}}),await n$1("contract-evidence",async()=>{let e=await r$1({workspacePath:s$2,strict:true});return await s$1({workspacePath:s$2,result:e}),{exitCode:e.status==="passed"?0:1,blocked:e.status!=="passed",message:`contract ${e.status}`}}),await n$1("analyze-evidence",async()=>{let e=await a$2({workspacePath:s$2,json:true,strict:false});return {blocked:e.summary.verdict==="blocked"||t.strict===true&&e.summary.verdict==="needs-attention",exitCode:e.summary.verdict==="blocked"||t.strict===true&&e.summary.verdict==="needs-attention"?1:0,message:`analyze ${e.summary.verdict} (${e.summary.score}/100)`}}),await n$1("readiness-evidence",async()=>{let e=await a$3({startPath:s$2,writeReport:true,skipVerify:true});return {blocked:e.overallStatus==="fail"||t.strict===true&&e.overallStatus==="warn",exitCode:e.overallStatus==="fail"||t.strict===true&&e.overallStatus==="warn"?1:0,message:`pre-verify readiness ${e.overallStatus}`}}),await n$1("verify",async()=>{let e=await f({workspacePath:s$2,fromImpactPath:a.impact});await g$1(e,s$2);let l=h$2(e,{strict:t.strict===true});return await j$1(s$2,e$1(e,l.passed)),{blocked:!l.passed,exitCode:l.exitCode,message:`${e.summary.verdict}; gate ${l.passed?"passed":"blocked"}`}}),await n$1("context",async()=>{let e=await c({workspacePath:s$2,model:o$1(),agent:t.agent??"generic",includeEvidence:true});return await d(e,s$2),{message:`context grounded for ${e.agent}`}}),await n$1("agent-sync",async()=>({message:`${(await l$2({workspacePath:s$2,agent:t.agent??"generic",write:true,refreshContext:false,strict:false,preset:"enterprise"})).writtenFiles.length} grounding files written`})),await n$1("explain",async()=>{let e=await b$1({workspacePath:s$2,target:{kind:"release-blocked"}});return await c$1(e,s$2),{message:e.summary}});let ue=d$1.some(e=>e.status==="blocked"),x=m$2?"failed":ue?"blocked":"passed",pe=m$2?1:x==="blocked"?2:0,R={schemaVersion:he,chainSchemaVersion:a$1,generatedAt:new Date().toISOString(),workspacePath:s$2,baselineCreated:a$4,preflight:p$2,status:x,exitCode:pe,stages:d$1,artifactPath:de};oe(R),await e(s$2,de,R);let ge=await j({workspacePath:s$2});return await e(s$2,a.agentIndex,ge),R}export{ke as a,he as b,De as c};
|
package/dist/chunk-FQLB4BIC.js
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import {a}from'./chunk-A5FBGRJA.js';import {a as a$1}from'./chunk-AFIFZTOY.js';import {e as e$1,d}from'./chunk-44VJHNZB.js';import {j,u,e,a as a$2,t,f as f$1}from'./chunk-MOSXTVPU.js';import {s}from'./chunk-RJIYCDVC.js';import b from'crypto';import P from'fs';import d$1 from'fs/promises';import i from'path';import T from'fs-extra';var x=d.projectWorkspaceLink.schemaVersion,L="workspai.project-workspace-link",l=class extends Error{constructor(r,a,o={}){super(a);this.code=r;this.context=o;this.name="ProjectWorkspaceResolutionError";}code;context};function $(e){return P.existsSync(i.join(e,".workspai-workspace"))?".workspai-workspace":".workspai/workspace.json"}function _(e){return b.createHash("sha256").update([e.workspaceName,a(e.workspacePath),e.projectName,a(e.projectPath),e.relativePath.replace(/\\/g,"/"),e.relationship].join("\0")).digest("hex")}function I(e){let t=i.resolve(e);for(;;){if(j(t))return t;let r=i.dirname(t);if(r===t)return null;t=r;}}function J(e){let t$1=i.resolve(e);for(;;){if([...t(t$1,"project.json"),...t(t$1,"context.json")].some(a=>P.existsSync(a)))return t$1;let r=i.dirname(t$1);if(r===t$1)return null;t$1=r;}}function y(e){return JSON.parse(P.readFileSync(e,"utf8"))}function K(e){let t=y(e);if(!t||typeof t!="object"||Array.isArray(t))throw new l("project.workspace.link-invalid",`Project workspace link is not a JSON object: ${e}`,{linkPath:e});let r=t;if(r.schemaVersion!==x||r.kind!==L||r.state!=="active"||!r.workspace||typeof r.workspace.name!="string"||r.workspace.name.trim().length===0||typeof r.workspace.root!="string"||!i.isAbsolute(r.workspace.root)||![".workspai-workspace",".workspai/workspace.json"].includes(r.workspace.marker??"")||r.workspace.contract!==e$1.workspaceContract||!r.project||typeof r.project.name!="string"||r.project.name.trim().length===0||typeof r.project.relativePath!="string"||i.isAbsolute(r.project.relativePath)||r.project.relativePath.split(/[\\/]/).includes("..")||!["managed","adopted","imported","linked","restored"].includes(r.project.relationship??"")||!r.integrity||r.integrity.algorithm!=="sha256"||typeof r.integrity.binding!="string"||!/^[a-f0-9]{64}$/.test(r.integrity.binding))throw new l("project.workspace.link-invalid",`Project workspace link does not satisfy ${x}: ${e}`,{linkPath:e});try{a$1(t,"contracts/project-workspace-link.v1.json","Project workspace link");}catch(a){throw new l("project.workspace.link-invalid",`Project workspace link does not satisfy ${x}: ${e}`,{linkPath:e,validationError:a instanceof Error?a.message:String(a)})}return r}function f(e,t){let r=i.join(e,".workspai","workspace.contract.json");if(!P.existsSync(r))return null;try{let a$1=y(r);if(!Array.isArray(a$1.projects))return false;let o=a(t);return a$1.projects.some(n=>typeof n.externalPath=="string"?a(n.externalPath)===o:typeof n.relativePath!="string"||n.relativePath.startsWith("external/")?false:a(i.resolve(e,n.relativePath))===o)}catch{return false}}function M(e,t,r){let a$1=a(e),o=new Map;for(let n of s(t,r)){if(!P.existsSync(n))continue;let c;try{c=y(n);}catch{continue}if(Array.isArray(c.workspaces))for(let p of c.workspaces){if(!p||typeof p.name!="string"||typeof p.path!="string"||!Array.isArray(p.projects)||!p.projects.some(w=>w&&typeof w.path=="string"&&a(w.path)===a$1))continue;let s=a(p.path);!j(s)||f(s,e)!==true||o.set(s,{name:p.name,path:s});}}return [...o.values()].sort((n,c)=>n.path.localeCompare(c.path))}function m(e,t){if(e)throw t;return null}function te(e$1){let t=e$1.strict===true,r=i.resolve(e$1.startPath),a=e$1.explicitWorkspacePath?i.resolve(e$1.explicitWorkspacePath):null,o=J(r);if(a)return j(a)?e$1.requireProjectMembership===true&&o&&f(a,o)!==true?m(t,new l("project.workspace.membership-missing",`Project is not registered in the explicit workspace contract: ${a}`,{workspacePath:a,projectPath:o})):{workspacePath:a,projectPath:o,source:"explicit",linkPath:o?u(o,e):null,recovered:false}:m(t,new l("project.workspace.explicit-invalid",`Explicit workspace path is not a Workspai workspace: ${a}`,{workspacePath:a,projectPath:o}));let n=I(r);if(n)return e$1.requireProjectMembership===true&&o&&f(n,o)!==true?m(t,new l("project.workspace.membership-missing",`Project is not registered in its parent workspace contract: ${n}`,{workspacePath:n,projectPath:o})):{workspacePath:n,projectPath:o,source:"parent",linkPath:o?u(o,e):null,recovered:false};if(!o)return m(t,new l("project.workspace.unlinked","No Workspai project or workspace could be resolved from the current directory.",{startPath:r}));let c=u(o,e),p=null;if(P.existsSync(c)){let s;try{s=K(c);}catch(O){if(t)throw O;return null}let u=_({workspaceName:s.workspace.name,workspacePath:s.workspace.root,projectName:s.project.name,projectPath:o,relativePath:s.project.relativePath,relationship:s.project.relationship}),w=f(s.workspace.root,o);if(s.integrity.binding===u&&j(s.workspace.root)&&P.existsSync(i.join(s.workspace.root,s.workspace.marker))&&w===true)return {workspacePath:i.resolve(s.workspace.root),projectPath:o,source:"local-link",linkPath:c,recovered:false};p=s;}let h=M(o,e$1.env??process.env,e$1.platform??process.platform);return h.length>1?m(t,new l("project.workspace.ambiguous",`Project is registered in more than one valid workspace: ${h.map(s=>s.name).join(", ")}. Pass --workspace <path> or run project workspace relink.`,{projectPath:o,candidates:h})):h.length===1?{workspacePath:h[0].path,projectPath:o,source:"registry",linkPath:c,recovered:p!==null}:p?m(t,new l("project.workspace.link-stale",`Project workspace link is stale and no valid registry relocation was found: ${p.workspace.root}`,{projectPath:o,linkPath:c,linkedWorkspacePath:p.workspace.root})):m(t,new l("project.workspace.unlinked","This Workspai project is not linked to a valid workspace. Run `npx workspai adopt .` or `npx workspai project workspace relink --workspace <path>`.",{projectPath:o,linkPath:c}))}async function F(e,t){await d$1.mkdir(i.dirname(e),{recursive:true});let r=`${e}.${process.pid}.${b.randomUUID()}.tmp`;try{await d$1.writeFile(r,`${JSON.stringify(t,null,2)}
|
|
2
|
-
`,{encoding:"utf8",mode:384});try{await d$1.rename(r,e);}catch(a){let o=a.code;if(o!=="EEXIST"&&o!=="EPERM")throw a;await T.move(r,e,{overwrite:true});}}finally{await d$1.rm(r,{force:true}).catch(()=>{});}}async function D(e){let t=i.join(e,".gitignore"),r=await d$1.readFile(t,"utf8").catch(c=>{if(c.code==="ENOENT")return "";throw c});if(r.split(/\r?\n/).map(c=>c.trim()).includes(f$1))return;let n=`${r.length>0&&!r.endsWith(`
|
|
3
|
-
`)?`
|
|
4
|
-
`:""}
|
|
5
|
-
# Workspai machine-local workspace binding
|
|
6
|
-
${f$1}
|
|
7
|
-
`;await d$1.writeFile(t,`${r}${n}`,"utf8");}async function V(e$2){let t=i.resolve(e$2.workspacePath),r=i.resolve(e$2.projectPath);if(!j(t))throw new l("project.workspace.explicit-invalid",`Cannot link project to an invalid Workspai workspace: ${t}`,{workspacePath:t,projectPath:r});let a$3=i.join(t,".workspai","workspace.contract.json"),o=e$2.workspaceName??i.basename(t),n=e$2.relativePath;if(P.existsSync(a$3)){let h=y(a$3);typeof h.workspace?.name=="string"&&(o=h.workspace.name);let s=a(r),u=h.projects?.find(w=>typeof w.externalPath=="string"?a(w.externalPath)===s:typeof w.relativePath=="string"&&!w.relativePath.startsWith("external/")&&a(i.resolve(t,w.relativePath))===s);u&&typeof u.relativePath=="string"&&(n=u.relativePath);}if(n??=i.relative(t,r).replace(/\\/g,"/"),(!n||n.startsWith(".."))&&(n=`external/${e$2.projectName}`),f(t,r)!==true)throw new l("project.workspace.membership-missing",`Project is not registered in the canonical workspace contract: ${e$2.projectName}`,{workspacePath:t,projectPath:r,projectName:e$2.projectName});let c={schemaVersion:x,kind:L,generatedAt:(e$2.now??new Date).toISOString(),state:"active",workspace:{name:o,root:t,marker:$(t),contract:e$1.workspaceContract},project:{name:e$2.projectName,relativePath:n,relationship:e$2.relationship},integrity:{algorithm:"sha256",binding:_({workspaceName:o,workspacePath:t,projectName:e$2.projectName,projectPath:r,relativePath:n,relationship:e$2.relationship})}};a$1(c,"contracts/project-workspace-link.v1.json","Project workspace link");let p=i.join(r,a$2,e);return await D(r),await F(p,c),{linkPath:p,link:c}}async function oe(e,t$1="linked"){if(!e.projectPath)return null;let r=t(e.projectPath,"project.json").find(o=>P.existsSync(o)),a=i.basename(e.projectPath);if(r)try{let o=y(r);typeof o.name=="string"?a=o.name:typeof o.slug=="string"&&(a=o.slug);}catch{}return V({workspacePath:e.workspacePath,projectPath:e.projectPath,projectName:a,relationship:t$1})}export{l as a,te as b,V as c,oe as d};
|
package/dist/chunk-GDU7VP6G.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import {d as d$1,c,e}from'./chunk-WIO6L24E.js';import {b,a as a$1}from'./chunk-44VJHNZB.js';import k from'fs-extra';var y=b.history,a=a$1.history,d=50;function A(t){if(!t||typeof t!="object"||Array.isArray(t))return null;let e=t;return typeof e.generatedAt!="string"?null:e.kind==="agent-action"?typeof e.actionId!="string"||typeof e.summary!="string"||e.outcome!=="ok"&&e.outcome!=="failed"?null:{kind:"agent-action",generatedAt:e.generatedAt,actionId:e.actionId,scope:typeof e.scope=="string"?e.scope:"workspace",summary:e.summary,outcome:e.outcome,...typeof e.evidenceSha256=="string"?{evidenceSha256:e.evidenceSha256}:{}}:e.kind==="doctor-fix"?e.scope!=="workspace"&&e.scope!=="project"||typeof e.summary!="string"||e.outcome!=="ok"&&e.outcome!=="failed"?null:{kind:"doctor-fix",generatedAt:e.generatedAt,scope:e.scope,summary:e.summary,outcome:e.outcome,applied:typeof e.applied=="number"?e.applied:0,failed:typeof e.failed=="number"?e.failed:0,skipped:typeof e.skipped=="number"?e.skipped:0,remainingBlockers:typeof e.remainingBlockers=="number"?e.remainingBlockers:0}:typeof e.verdict!="string"||typeof e.risk!="string"||typeof e.gatePassed!="boolean"?null:{kind:"verify",generatedAt:e.generatedAt,verdict:e.verdict,risk:String(e.risk),affectedProjects:typeof e.affectedProjects=="number"?e.affectedProjects:0,freshness:e.freshness??"unknown",gatePassed:e.gatePassed,blockingReasons:typeof e.blockingReasons=="number"?e.blockingReasons:0,policyViolations:typeof e.policyViolations=="number"?e.policyViolations:0}}function S(t,e){return {kind:"verify",generatedAt:t.generatedAt,verdict:t.summary.verdict,risk:t.impact.risk,affectedProjects:t.impact.affectedProjects,freshness:t.freshness.verdict,gatePassed:e,blockingReasons:t.blockingReasons.length,policyViolations:t.policyViolations.length}}function F(t){return {kind:"agent-action",generatedAt:t.generatedAt,actionId:t.actionId,scope:t.scope,summary:t.summary,outcome:t.outcome,...t.evidenceSha256?{evidenceSha256:t.evidenceSha256}:{}}}function V(t,e){let o=t.appliedFixes.filter(i=>i.outcome==="applied").length,r=t.appliedFixes.filter(i=>i.outcome==="failed").length,n=t.appliedFixes.filter(i=>i.outcome==="skipped").length,s=t.appliedFixes.filter(i=>i.outcome==="guidance").length,c=t.remainingBlockers.length,g=r>0||c>0?"failed":"ok";return {kind:"doctor-fix",generatedAt:t.generatedAt,scope:e,summary:`${o} applied, ${r} failed, ${n} skipped, ${s} guidance, ${c} blocker(s) remaining`,outcome:g,applied:o,failed:r,skipped:n,remainingBlockers:c}}async function E(t){let e=await d$1(t,a);try{if(!e||!await k.pathExists(e))return null;let o=await k.readJson(e);return o?.schemaVersion!==y||!Array.isArray(o.entries)?null:{schemaVersion:y,retention:typeof o.retention=="number"?o.retention:d,entries:o.entries.map(r=>A(r)).filter(r=>r!=null)}}catch{return null}}function x(t,e,o=d){let r=Math.max(1,Math.floor(o)),n=[...t?.entries??[],e],s=n.slice(Math.max(0,n.length-r));return {schemaVersion:y,retention:r,entries:s}}async function v(t,e$1,o){return c(t,a,async()=>{let r=await d$1(t,a),n=await E(t);if(r&&!n)throw new Error(`Workspace history is unreadable or invalid; refusing to overwrite: ${r}`);let s=x(n,e$1,o?.retention??d);return await e(t,a,s),s})}export{y as a,a as b,d as c,A as d,S as e,F as f,V as g,E as h,x as i,v as j};
|
package/dist/chunk-H7P7SSUW.js
DELETED
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
import {c}from'./chunk-FQLB4BIC.js';import {d as d$2,b,a as a$2}from'./chunk-3RBUSW7H.js';import {d as d$1}from'./chunk-EWZZUQBR.js';import {a as a$1}from'./chunk-AFIFZTOY.js';import {d,a,e}from'./chunk-44VJHNZB.js';import {t,h,g}from'./chunk-MOSXTVPU.js';import q from'crypto';import N from'fs';import k from'fs/promises';import l from'path';import se from'fs-extra';var ie=d.projectContextAgent.schemaVersion,$e=["managed","local","off"],Z="<!-- WORKSPAI:PROJECT-GROUNDING:START -->",Q="<!-- WORKSPAI:PROJECT-GROUNDING:END -->";function G(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:null}async function A(e){try{return JSON.parse(await k.readFile(e,"utf8"))}catch(t){return null}}function R(e){return e.replace(/\\/g,"/").replace(/^\.\/+/,"")}function W(e,t,r){let o=e.replace(/\\/g,"/"),s=/^[A-Za-z]:\//.test(o);if(!l.isAbsolute(e)&&!s)return R(o);if(s&&process.platform!=="win32")return null;let i=l.resolve(e),a=l.relative(r,i);if(a&&!a.startsWith("..")&&!l.isAbsolute(a))return R(a);let c=l.relative(t,i);return c&&!c.startsWith("..")&&!l.isAbsolute(c)?`workspace:${R(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 Y(e,t){return G(e?.adoption)?.mode==="linked"?"adopted":G(e?.import)?"imported":t}function ae(e){if(!e.model)return null;let t=R(e.relativePath);return e.model.projects.find(r=>r.name===e.projectName||R(r.path)===t)??null}function U(e,t){e[t]=(e[t]??0)+1;}function ce(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){U(f,n.kind);for(let d of n.proofIds)c.add(d);}for(let n of s){U(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(T=>T.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(T=>T.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 ee(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 pe(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,ee(s,t,r)])),proofIds:[...e.proofIds].sort()}}function le(e,t,r){let o=(...i)=>e.filter(a=>i.includes(a.kind)).map(a=>pe(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:ee(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 de(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 ge(e,t,r){let o=[],s=await A(l.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 A(l.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 ue(e){return q.createHash("sha256").update(JSON.stringify(e)).digest("hex")}async function me(e$1){let t$1=l.resolve(e$1.workspacePath),r=l.resolve(e$1.projectPath),o=t(r,"project.json").find(p=>N.existsSync(p)),s=o?await A(o):null,i=await A(l.join(t$1,".workspai","workspace.contract.json")),a$2=l.resolve(r),c=i?.projects?.find(p=>p.externalPath?l.resolve(p.externalPath)===a$2:!p.relativePath||p.relativePath.startsWith("external/")?false:l.resolve(t$1,p.relativePath)===a$2)??i?.projects?.find(p=>p.slug===e$1.projectName||p.slug===l.basename(r)),f=e$1.projectName??(typeof s?.name=="string"?s.name:void 0)??c?.slug??l.basename(r),y=c?.relativePath??(()=>{let p=R(l.relative(t$1,r));return !p||p.startsWith("..")?`external/${f}`:p})(),m=await A(l.join(t$1,a.model)),h=await A(l.join(t$1,a.knowledgeGraph)),j=m?d$1(m):void 0,P=!!(j&&h?.source.hash===j),g=ae({model:m,projectName:f,relativePath:y}),u=ce(P?h:null,f),n=await ge(t$1,r,f),d=u.proofs.map(p=>p.freshness),T=h?!P||d.includes("stale")?"stale":d.includes("unknown")?"unknown":"fresh":"missing",re=m?m.factFreshness?.status??"unknown":"missing",ne=[...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."}]:[]],oe=Y(s,e$1.relationship??c?.relationship??"managed"),$={schemaVersion:ie,generatedAt:(e$1.now??new Date).toISOString(),workspace:{name:i?.workspace?.name??m?.workspace.name??l.basename(t$1),...i?.workspace?.profile||m?.workspace.profile?{profile:i?.workspace?.profile??m?.workspace.profile}:{},relationship:oe,contract:e.workspaceContract,model:a.model,knowledgeGraph:a.knowledgeGraph,access:{localBinding:e.projectWorkspaceLink,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(p=>W(p,t$1,r)).filter(p=>p!==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:re,graph:T,graphMatchesModel:P},topology:{...u.topology,dependencies:u.topology.dependencies.map(p=>({...p,evidence:p.evidence.map(E=>W(E,t$1,r)).filter(E=>E!==null)})),dependents:u.topology.dependents.map(p=>({...p,evidence:p.evidence.map(E=>W(E,t$1,r)).filter(E=>E!==null)}))},surfaces:le(u.entities,t$1,r),diagnostics:[...ne,...u.diagnostics].map(p=>({...p,message:w(p.message,t$1,r),...p.recommendation?{recommendation:w(p.recommendation,t$1,r)}:{}}))},evidence:{readOrder:[".workspai/PROJECT-GROUNDING.md",e.projectContextAgent,"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(p=>W(p,t$1,r)).filter(p=>p!==null))],relations:u.relations.map(p=>({id:p.id,from:p.from,to:p.to,kind:p.kind,derivation:p.derivation,trust:p.trust,confidence:p.confidence,proofIds:[...p.proofIds].sort()})),proofs:u.proofs.map(p=>de(p,t$1,r)).filter(p=>p!==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($,[t$1,r]))throw new Error("Project context lens rejected a non-portable absolute path.");let K={...$,integrity:{algorithm:"sha256",...j?{modelHash:j}:{},payloadHash:ue($),portable:true,absolutePathsEmitted:false}};return a$1(K,"contracts/workspace-intelligence/project-context-agent.v1.json","Project context agent"),K}function fe(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 he(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 H(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function V(e,t){return new RegExp(`${H(e)}[\\s\\S]*?${H(t)}`,"m")}function te(e){let t=e.replace(V(Z,Q),"");return d$2(t)?.includes("# Workspai project boundary")&&(t=t.replace(V(a$2,b),"")),t.replace(/\n{3,}/g,`
|
|
63
|
-
|
|
64
|
-
`).trim()}function je(e,t){let r=te(e),o=`${Z}
|
|
65
|
-
${t.trim()}
|
|
66
|
-
${Q}`;return r?`${r}
|
|
67
|
-
|
|
68
|
-
${o}
|
|
69
|
-
`:`${o}
|
|
70
|
-
`}async function I(e,t){await k.mkdir(l.dirname(e),{recursive:true});let r=`${e}.${process.pid}.${q.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 se.move(r,e,{overwrite:true});}}finally{await k.rm(r,{force:true}).catch(()=>{});}}async function z(e,t){let r=l.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 I(r,a);}async function X(e,t,r){let o=l.join(e,"AGENTS.md"),s=N.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?je(i,he(r)):te(i);if(!a){s&&await k.rm(o,{force:true});return}let c=`${a.trimEnd()}
|
|
73
|
-
`;return c!==i&&await I(o,c),t==="managed"?o:void 0}async function ke(e$1){let t$1=e$1.mode??"managed",r=l.resolve(e$1.workspacePath),o=l.resolve(e$1.projectPath);if(t$1==="off"){let h$1=t(o,"project.json").find(n=>N.existsSync(n)),j=h$1?await A(h$1):null,P=e$1.projectName??(typeof j?.name=="string"?j.name:void 0)??l.basename(o),g$1=Y(j,e$1.relationship??"managed"),u=await c({workspacePath:r,projectPath:o,projectName:P,relationship:g$1,now:e$1.now});return await z(o,t$1),await X(o,t$1),await Promise.all([k.rm(l.join(o,h),{force:true}),k.rm(l.join(o,g),{force:true})]),{mode:t$1,projectPath:o,linkPath:u.linkPath,writtenFiles:[e.projectWorkspaceLink]}}let s=await me(e$1),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$1.now});await z(o,t$1);let c$1=await X(o,t$1,s),f=l.join(o,h),y=l.join(o,g);await I(f,`${JSON.stringify(s,null,2)}
|
|
74
|
-
`),await I(y,`${fe(s).trimEnd()}
|
|
75
|
-
`);let m=[e.projectWorkspaceLink,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 xe(e){let t=l.resolve(e.workspacePath),r=e.mode??"managed",o=await we(t),s=[],i=[];for(let a of o.resolved)try{s.push(await ke({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 we(e){let t=l.resolve(e),r=await A(l.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"?l.resolve(i.externalPath):typeof i.relativePath=="string"&&!i.relativePath.startsWith("external/")?l.resolve(t,i.relativePath):null;if(!c||!N.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{ie as a,$e as b,Z as c,Q as d,me as e,ke as f,xe as g,we as h};
|
package/dist/chunk-KVUYAYTY.js
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import {f as f$1,e}from'./chunk-T3GJ7YVG.js';import {a as a$1,b as b$2}from'./chunk-MRFN5ZQP.js';import {a as a$2}from'./chunk-27UR373Z.js';import {h,j as j$1}from'./chunk-2PY65U6X.js';import {e as e$1}from'./chunk-WIO6L24E.js';import {a,b as b$1}from'./chunk-44VJHNZB.js';import {j,s,t}from'./chunk-MOSXTVPU.js';import b from'fs';import p from'path';import o from'chalk';var H=new Set([".git",".workspai",".rapidkit",".venv","node_modules","dist","build","target","coverage","htmlcov",".next"]);async function D(e){try{return await b.promises.access(e,b.constants.F_OK),true}catch{return false}}async function P(e){try{let n=JSON.parse(await b.promises.readFile(e,"utf-8"));return n&&typeof n=="object"&&!Array.isArray(n)?n:null}catch{return null}}async function L(e){try{return await b.promises.readFile(e,"utf-8")}catch{return ""}}function K(e){return a$1(e)}async function B(e,n){return await N([...t(e,"project.json"),...t(e,"context.json")])?true:b$2(e)?false:p.resolve(e)===p.resolve(n)?h(e).length>0:h(e).length>0}async function U(e){let n=await a$2(e,{skipDirs:H,includeHiddenDirs:false,descendIntoMatchedProjects:false,isProjectDir:B});return n.length>0?n:b$2(e)?[]:h(e).length>0?[e]:[]}function V(e,n){return p.relative(e,n).replace(/\\/g,"/")||"."}async function A(e,n){for(let t of n)if(await D(p.join(e,t)))return true;return false}async function N(e){for(let n of e)if(await D(n))return true;return false}async function M(e){for(let n of e){let t=await P(n);if(t)return t}return null}async function q(e){return A(e,["health","health.ts","health.js","health.py","health.go","health.kt","health.rb","health.php","healthcheck","health-check","src/health.ts","src/health.js","src/health.py","src/health.go","src/health.kt","src/health.rb","src/health.php","src/healthcheck.ts","src/healthcheck.js","src/liveness.ts","src/readiness.ts","src/ping.ts"])}async function Q(e){if(await A(e,["tests","test","__tests__","src/__tests__","pytest.ini","vitest.config.ts","jest.config.ts"]))return true;let t=await P(p.join(e,"package.json")),r=t?.scripts&&typeof t.scripts=="object"?t.scripts:{};return typeof r.test=="string"&&r.test.trim().length>0}async function X(e){let n=await P(p.join(e,"package.json")),t=n?.scripts&&typeof n.scripts=="object"?n.scripts:{};return Object.keys(t).sort()}function f(e,n,t,r,s,a){return {id:e,severity:n,target:t,title:r,detail:s,remediation:a}}function Y(e){let n=e.reduce((t,r)=>r.severity==="fail"?t+28:r.severity==="warn"?t+12:t+3,0);return Math.max(0,100-n)}async function Z(e,n){let t$1=await M(t(n,"project.json")),r=j$1(n,t$1),s=h(n),a=r.runtime==="unknown"?s[0]||"unknown":r.runtime,i=V(e,n),l=i,u=await X(n),g=await N([...t(n,"project.json"),...t(n,"context.json")]),d=await Q(n),h$1=await A(n,["Dockerfile","dockerfile"]),k=await A(n,[".env.example","env.example","config/env.example"]),z=await A(n,[".github/workflows/ci.yml",".github/workflows/ci.yaml",".github/workflows/main.yml",".github/workflows/build.yml",".github/workflows/test.yml",".github/workflows/deploy.yml",".gitlab-ci.yml",".circleci/config.yml","azure-pipelines.yml","bitbucket-pipelines.yml","cloudbuild.yaml"]),C=await q(n),m=[];return r.key==="unknown"&&m.push(f("project.stack.unknown","fail",l,"Project stack is unknown","Workspai cannot confidently classify this backend project.","Add .workspai/project.json metadata or import the project with `workspai import`.")),g||m.push(f("project.marker.missing","warn",l,"Workspai marker is missing","The project can be detected by files, but it is not registered with Workspai metadata.","Run `workspai import <path>` from a workspace or create the project through Workspai.")),d||m.push(f("project.tests.missing","warn",l,"Test entrypoint is missing","No common test folder, config, or package test script was found.","Add a test command so `workspai workspace run test --affected` can gate changes.")),k||m.push(f("project.env.example.missing","info",l,"Environment example is missing","No .env.example or env.example file was found.","Add an env example for onboarding and CI secret documentation.")),z||m.push(f("project.ci.missing","warn",l,"Continuous integration is missing","No recognized CI/CD configuration file was detected for this project.","Add CI configuration so tests and checks run automatically for every change.")),C||m.push(f("project.health.missing","info",l,"Health or readiness probe is missing","The project has no obvious health or readiness endpoint to support automated deployment and runtime checks.","Add a simple health endpoint and document it for readiness gates and observability.")),h$1||m.push(f("project.container.missing","info",l,"Container recipe is missing","No Dockerfile was found for this project.","Add a Dockerfile when the service is intended for containerized deployment.")),{name:p.basename(n),path:n,relativePath:i,runtime:a,framework:r.key,confidence:r.confidence,supportTier:r.supportTier,hasRapidKitMarker:g,hasTests:d,hasDockerfile:h$1,hasEnvExample:k,hasCiConfig:z,hasHealthEndpoint:C,scripts:u,findings:m,score:Y(m)}}function ee(e){return e.name.toLowerCase()}async function ne(e){let n=new Map(e.map(s=>[ee(s),s])),t=[];for(let s of e){let a=await P(p.join(s.path,"package.json")),i={...a?.dependencies??{},...a?.devDependencies??{},...a?.peerDependencies??{}};for(let u of Object.keys(i)){let g=u.replace(/^@[^/]+\//,"").toLowerCase(),d=n.get(g);d&&d.relativePath!==s.relativePath&&t.push({from:s.relativePath,to:d.relativePath,kind:"package"});}let l=await L(p.join(s.path,"pyproject.toml"));for(let u of e)u.relativePath!==s.relativePath&&l.includes(u.name)&&t.push({from:s.relativePath,to:u.relativePath,kind:"workspace-reference"});}let r=new Set;return t.filter(s=>{let a=`${s.from}\0${s.to}\0${s.kind}`;return r.has(a)?false:(r.add(a),true)})}function te(e,n){let t=new Map;for(let r of e)t.set(r.relativePath,{project:r.relativePath,directDependents:0,directDependencies:0});for(let r of n){let s=t.get(r.from),a=t.get(r.to);s&&(s.directDependencies+=1),a&&(a.directDependents+=1);}return Array.from(t.values()).sort((r,s)=>s.directDependents-r.directDependents||s.directDependencies-r.directDependencies)}async function re(e){let n=await M(s(e,"workspace.json"));return typeof n?.profile=="string"?n.profile:null}function se(e){return {fail:e.filter(n=>n.severity==="fail").length,warn:e.filter(n=>n.severity==="warn").length,info:e.filter(n=>n.severity==="info").length}}function oe(e){if(e.projectCount===0)return e.workspaceDetected?["Add your first project: npx workspai create project <name> --kit <kit>","Import an existing service: npx workspai import <path>"]:["Create a Workspai workspace: npx workspai create workspace my-workspace --profile polyglot","Import an existing service: npx workspai import ../service"];let n=[];return e.findings.some(t=>t.id==="workspace.marker.missing")&&n.push("Initialize workspace metadata with `workspai bootstrap --profile polyglot`."),e.findings.some(t=>t.id==="project.marker.missing")&&n.push("Register detected projects with `workspai import <path>` or recreate them via `workspai create project`."),e.findings.some(t=>t.id==="project.tests.missing")&&n.push("Add test entrypoints, then gate changes with `workspai workspace run test --affected --strict`."),e.findings.some(t=>t.id==="project.ci.missing")&&n.push("Add CI/CD configuration to catch regressions early and make workspace health checks actionable."),e.findings.some(t=>t.id==="project.health.missing")&&n.push("Add a health/readiness endpoint so runtime probes and deployment checks can verify service health."),e.hasGraph||n.push("Create `.workspai/workspace-dependency-graph.json` or use analyze output as the first graph seed."),n.push("Run `workspai autopilot release --mode audit --json` before release."),Array.from(new Set(n))}async function ke(e$2={}){let n=p.resolve(e$2.workspacePath||process.cwd());if(!await D(n))throw new Error(`Workspace path does not exist: ${n}`);let t=K(n)??n,r=j(t),s=await re(t),a$1=await U(t),i=await Promise.all(a$1.map(c=>Z(t,c))),l=await ne(i),u=te(i,l),g=[];r||g.push(f("workspace.marker.missing","warn",".","Workspace metadata is missing","The directory can be analyzed, but it is not a registered Workspai workspace.","Run `workspai create workspace` or `workspai bootstrap --profile polyglot` in a workspace root.")),i.length===0&&g.push(f("workspace.projects.missing","warn",".","No backend projects detected","Workspai did not find runtime markers or project metadata under this root.","Create a project with `workspai create project` or import one with `workspai import <path>`."));let d=[...g,...i.flatMap(c=>c.findings)],h=se(d),k={};for(let c of i)k[c.runtime]=(k[c.runtime]||0)+1;let z=i.length>0?Math.round(i.reduce((c,y)=>c+y.score,0)/i.length):0,C=g.reduce((c,y)=>c+(y.severity==="fail"?20:y.severity==="warn"?8:2),0),m=Math.max(0,z-C),O=i.length===0&&h.fail===0&&d.length>0&&d.every(c=>c.id==="workspace.projects.missing"&&c.severity==="warn"),J=h.fail>0||e$2.strict&&h.warn>0&&!O?"blocked":h.warn>0?"needs-attention":"ready",w={schemaVersion:b$1.analyze,generatedAt:new Date().toISOString(),workspacePath:t,workspaceDetected:r,profile:s,summary:{score:m,verdict:J,projectCount:i.length,runtimeCount:Object.keys(k).length,findings:h},runtimes:k,projects:i,dependencyGraph:{status:l.length>0?"generated":"empty",edges:l,topImpactedProjects:u.slice(0,5)},findings:d,nextActions:oe({findings:d,projectCount:i.length,hasGraph:l.length>0,workspaceDetected:r}),enterpriseControls:{jsonReady:true,ciGateCommand:"workspai analyze --json --strict",releaseGateCommand:"workspai autopilot release --mode enforce --json",evidencePath:a.analyze}};if(e$2.output&&(await b.promises.mkdir(p.dirname(p.resolve(e$2.output)),{recursive:true}),await b.promises.writeFile(p.resolve(e$2.output),`${JSON.stringify(w,null,2)}
|
|
2
|
-
`)),!e$2.output&&r){let c=f$1(w,{commandId:"workspaceAnalyze",exitCode:w.summary.verdict==="blocked"?2:w.summary.verdict==="needs-attention"?1:0,generatedAt:w.generatedAt,blockers:w.findings.filter(y=>y.severity==="fail").map(y=>y.title).slice(0,12),runId:e()});await e$1(t,a.analyze,c);}return w}function we(e){let n=e.summary.verdict==="ready"?o.green:e.summary.verdict==="needs-attention"?o.yellow:o.red;if(console.log(o.bold(`
|
|
3
|
-
Workspai Workspace Analysis
|
|
4
|
-
`)),console.log(o.cyan("Workspace:"),e.workspacePath),console.log(o.cyan("Profile:"),e.profile||"not configured"),console.log(o.cyan("Score:"),`${e.summary.score}/100`),console.log(o.cyan("Verdict:"),n(e.summary.verdict)),console.log(o.gray(`Projects: ${e.summary.projectCount}, runtimes: ${e.summary.runtimeCount}, findings: ${e.summary.findings.fail} fail / ${e.summary.findings.warn} warn / ${e.summary.findings.info} info`)),e.projects.length>0){console.log(o.bold(`
|
|
5
|
-
Projects`));for(let t of e.projects){let r=t.score>=85?o.green("pass"):t.score>=65?o.yellow("watch"):o.red("risk");console.log(` ${t.relativePath} ${o.gray(`${t.runtime}/${t.framework}`)} ${r} ${t.score}/100`);}}if(e.dependencyGraph.status==="generated"&&(console.log(o.bold(`
|
|
6
|
-
Dependency Graph`)),console.log(o.gray(` edges: ${e.dependencyGraph.edges.length}`)),e.dependencyGraph.topImpactedProjects.length>0)){console.log(o.gray(" Top impacted projects:"));for(let t of e.dependencyGraph.topImpactedProjects.slice(0,3))console.log(` ${t.project} (${t.directDependents} dependents, ${t.directDependencies} dependencies)`);}if(e.findings.length>0){console.log(o.bold(`
|
|
7
|
-
Top Findings`));for(let t of e.findings.slice(0,8)){let r=t.severity==="fail"?o.red:t.severity==="warn"?o.yellow:o.gray;console.log(` ${r(t.severity.toUpperCase())} ${t.target}: ${t.title}`),console.log(o.gray(` ${t.remediation}`));}}console.log(o.bold(`
|
|
8
|
-
Next Actions`));for(let t of e.nextActions.slice(0,5))console.log(o.gray(` - ${t}`));console.log();}export{ke as a,we as b};
|
package/dist/chunk-MQ73VS4E.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import {w}from'./chunk-6HJJHEL6.js';import {a as a$1}from'./chunk-GR6442P7.js';import {a as a$2,d as d$1,c,e as e$2}from'./chunk-WIO6L24E.js';import {b as b$1}from'./chunk-BYVTHIC3.js';import {e,a,d,b}from'./chunk-44VJHNZB.js';import {l}from'./chunk-OCGZNSOE.js';import {e as e$1}from'./chunk-RO73VVHW.js';import {s,t,p}from'./chunk-MOSXTVPU.js';import*as g from'path';import g__default from'path';import h from'fs-extra';var he="unknown-run";function X(e){let t=e$1();return !t||t===he?e:{...e,runId:t}}async function ee(e,t){await h.ensureDir(g.dirname(e));let r=`${e}.${process.pid}.${Date.now()}.tmp`;try{await h.writeJSON(r,t,{spaces:2}),await h.move(r,e,{overwrite:true});}finally{await h.remove(r).catch(()=>{});}}function te(e){return p(e,"imported-projects.json")}async function I(e){let t=(await Promise.all(s(e,"imported-projects.json").map(async r=>await h.pathExists(r)?r:null))).find(r=>typeof r=="string");if(!t)return [];try{let r=await h.readJSON(t);if(!r||typeof r!="object"||r.version!==1||!Array.isArray(r.projects))throw new Error("expected a version 1 registry with a projects array");let o=r.projects,a=o.filter(c=>{if(!c||typeof c!="object")return false;let i=c;return typeof i.name=="string"&&typeof i.path=="string"&&typeof i.stack=="string"&&typeof i.confidence=="string"&&typeof i.importedAt=="string"});if(a.length!==o.length)throw new Error("one or more project entries are invalid");return a}catch(r){throw new Error(`Imported-project registry is invalid: ${t}`,{cause:r})}}async function Te(e,t){if(t.length===0)return;let r=await I(e),o=new Map;for(let l of r)o.set(l.path,l);for(let l of t)o.set(l.path,l);let a=Array.from(o.values()).sort((l,u)=>l.name.localeCompare(u.name)).map(l=>({...l})),c={version:1,updatedAt:new Date().toISOString(),projects:a},i=te(e);await ee(i,c);}async function Ve(e,t){if(t.length===0)return;let r=await I(e),o=new Set(t.map(l=>g.resolve(l))),a=r.filter(l=>!o.has(g.resolve(l.path))),c={version:1,updatedAt:new Date().toISOString(),projects:a},i=te(e);await ee(i,c);}var Fe="workspace-dependency-graph.v1",re=["code-import","package-dep","event-pub-sub","service-dependsOn","shared-resource"],oe=["inferred","contract","manual"];var E=e.workspaceContract,ke=a.contractVerify,R=d.workspaceContract.schemaVersion,we=b.contractVerify,N=class extends Error{constructor(r){super(`Workspace contract verification failed: ${r.violations.join("; ")}`);this.verification=r;this.name="WorkspaceContractVerificationError";}verification};function ie(e){return e.replace(/\\/g,"/")}function H(e){let t=ie(e).trim();return !t||t.startsWith("/")||t.startsWith("~")||/^[a-zA-Z]:\//.test(t)||t.includes("\0")?false:!t.split("/").filter(Boolean).some(r=>r===".."||r===".")}function ne(e,t){return e.trim().toLowerCase().replace(/[^a-z0-9._-]+/g,"-").replace(/-+/g,"-").replace(/^[-_.]+|[-_.]+$/g,"").slice(0,80)||t}function Pe(e){return Array.isArray(e)?e.filter(t=>typeof t=="string"&&t.trim().length>0):[]}function ye(e){let r=(Array.isArray(e.ports)?e.ports:[]).map(c=>{if(!c||typeof c!="object"||Array.isArray(c))return null;let i=c,l=Number(i.port);if(!Number.isInteger(l)||l<1||l>65535)return null;let u=i.protocol==="https"||i.protocol==="grpc"||i.protocol==="tcp"||i.protocol==="udp"?i.protocol:"http";return {name:typeof i.name=="string"&&i.name.trim()?i.name:"http",port:l,protocol:u}}).filter(c=>c!==null);if(r.length>0)return r;let o=e.frontend&&typeof e.frontend=="object"&&!Array.isArray(e.frontend)?e.frontend:void 0,a=Number(e.port??o?.default_port);return Number.isInteger(a)&&a>=1&&a<=65535?[{name:"http",port:a,protocol:"http"}]:[]}async function D(e){for(let t of e)if(await h.pathExists(t))return t;return null}async function Ce(e){for(let t of s(e,"workspace.json"))try{let r=await h.readJson(t);return {name:typeof r.workspace_name=="string"&&r.workspace_name.trim()||typeof r.name=="string"&&r.name.trim()||g__default.basename(e),profile:typeof r.profile=="string"?r.profile:void 0}}catch{}return {name:g__default.basename(e)}}async function Ee(e){let t$1=[],r=[e],o=new Set,a=new Set([".git",".workspai",".rapidkit","node_modules",".venv","venv","dist","build","target",".next",".turbo",".cache"]);for(;r.length>0;){let c=r.shift();if(!c||o.has(c))continue;o.add(c);let i=await D(t(c,"project.json")),l=await D(t(c,"context.json"));if(i||l){t$1.push(i??l??"");continue}let u;try{u=await h.readdir(c,{withFileTypes:true});}catch{continue}for(let d of u)!d.isDirectory()||a.has(d.name)||a$1(d.name)||r.push(g__default.join(c,d.name));}return t$1.sort()}function je(e){let t=(e||"").toLowerCase();if(t.includes("fastapi"))return "fastapi";if(t.includes("nestjs"))return "nestjs";if(t.includes("springboot"))return "springboot";if(t.includes("gofiber"))return "fiber";if(t.includes("gogin"))return "gin"}function be(e,t){let r=(e||"").toLowerCase(),o=(t||"").toLowerCase();return r.includes("fastapi")?8e3:r.includes("nestjs")?3e3:r.includes("springboot")?8080:r.includes("gofiber")?3e3:r.includes("gogin")?8080:o==="node"?3e3:o==="python"?8e3:o==="java"||o==="go"?8080:null}function ae(e,t){let r=e;for(;t.has(r)&&r<65535;)r+=1;return r}function M(e,t,r){let o=e!==void 0&&e.source===void 0,a=be(t.kit,t.runtime),c=e?.ports||[],i=t.ports||[],u=(c.length>0?c:i.length>0?i:a?[{name:"http",port:ae(a,r),protocol:"http"}]:[]).map(p=>({...p,port:ae(p.port,r)}));for(let p of u)r.add(p.port);let d={...t,...e,slug:e?.slug||t.slug,relativePath:o&&e?.relativePath&&H(e.relativePath)?e.relativePath:t.relativePath,source:o&&e?.source||t.source,relationship:o&&e?.relationship||t.relationship,externalPath:o&&e?.externalPath||t.externalPath,runtime:e?.runtime||t.runtime,framework:e?.framework||t.framework,kit:e?.kit||t.kit,modules:e?.modules?.length?e.modules:t.modules,ports:u,contracts:{owns:e?.contracts?.owns||[],apis:e?.contracts?.apis||[],publishes:e?.contracts?.publishes||[],consumes:e?.contracts?.consumes||[],dependsOn:e?.contracts?.dependsOn||[],env:e?.contracts?.env||[]}},s=JSON.stringify(e||null)!==JSON.stringify(d);return {project:d,changed:s}}async function pe(e){let t$1=g__default.resolve(e.workspacePath),r=await Ce(t$1),o=await Ee(t$1),a=await I(t$1),c=[];for(let d of a){let s=g__default.resolve(d.path),p=await D(t(s,"project.json"))??await D(t(s,"context.json"));!p||o.some(k=>g__default.resolve(k)===g__default.resolve(p))||c.push({projectJsonPath:p,registryEntry:d});}let i=[],l=[...o.map(d=>({projectJsonPath:d})),...c];for(let{projectJsonPath:d,registryEntry:s}of l){let p=g__default.dirname(g__default.dirname(d)),k=ie(g__default.relative(t$1,p)),f=s!==void 0&&!H(k),P=ne(s?.name||g__default.basename(p),g__default.basename(p)),y=f?`external/${P}`:k||P,w=await h.readJson(d),x=typeof w.kit_name=="string"&&w.kit_name||typeof w.kit=="string"&&w.kit||void 0,n=typeof w.framework=="string"&&w.framework||je(x);i.push({slug:s?.name||y||g__default.basename(p),relativePath:y,source:s?.source??"workspace",relationship:s?.relationship,externalPath:f?p:void 0,runtime:typeof w.runtime=="string"?w.runtime:void 0,framework:n,kit:x,modules:Pe(w.modules),ports:ye(w),contracts:{owns:[],apis:[],publishes:[],consumes:[],dependsOn:[],env:[]}});}let u=new Map;for(let d of i){let s=ne(d.slug,d.relativePath),p=u.get(s);(!p||p.source!=="workspace"&&d.source==="workspace")&&u.set(s,d);}return {schemaVersion:R,kind:"rapidkit.workspace.contract",generatedAt:(e.now??new Date).toISOString(),workspace:r,projects:[...u.values()]}}async function rt(e){let t=g__default.resolve(e.outputPath||a$2(e.workspacePath,E));if(await h.pathExists(t)&&e.force!==true)throw new Error(`Workspace contract already exists: ${t}. Use --force to overwrite.`);let r=await pe({workspacePath:e.workspacePath,now:e.now}),o=new Set,a={...r,projects:r.projects.map(i=>M(void 0,i,o).project)},c=await ue({workspacePath:e.workspacePath,contractPath:t,contract:a});if(e.strict&&c.status==="failed")throw new N(c);return await de({workspacePath:e.workspacePath,contractPath:t,contract:a,now:e.now}),{contractPath:t,contract:a}}async function ot(e){let t=g__default.resolve(e.workspacePath),r=a$2(t,E),o=await d$1(t,E)??r,a=await pe({workspacePath:t,now:e.now}),c=await h.pathExists(o)?await h.readJson(o):null,i=new Map((c?.projects||[]).map(f=>[f.slug,f])),l=new Set,u=[],d=[],s=[];for(let f of a.projects){let P=i.get(f.slug),y=M(P,f,l);P?y.changed&&d.push(f.slug):u.push(f.slug),s.push(y.project),i.delete(f.slug);}for(let f of i.values()){if(f.source)continue;let P=M(f,f,l);s.push(P.project);}let p={schemaVersion:R,kind:"rapidkit.workspace.contract",generatedAt:(e.now??new Date).toISOString(),workspace:{...c?.workspace||{},...a.workspace,name:a.workspace.name||c?.workspace?.name||g__default.basename(t)},projects:s.sort((f,P)=>f.slug.localeCompare(P.slug))},k=await ue({workspacePath:t,contractPath:r,contract:p});if(e.strict&&k.status==="failed")throw new N(k);return await de({workspacePath:t,contractPath:r,contract:p,now:e.now}),{contractPath:r,contract:p,addedProjects:u,updatedProjects:d,verification:k}}async function se(e){return await h.pathExists(e)?{exists:true,contents:await h.readFile(e)}:{exists:false}}async function ce(e,t){if(!t.exists){await h.remove(e);return}await h.outputFile(e,t.contents);}async function de(e){let{buildWorkspaceRegistrySummary:t,WORKSPACE_REGISTRY_SUMMARY_RELATIVE_PATH:r}=await import('./workspace-registry-summary-GPJEL7K7.js'),o=await t(e.workspacePath,{now:e.now,contract:e.contract}),a=a$2(e.workspacePath,r),c$1=i=>{if(!i||typeof i!="object"||Array.isArray(i))return JSON.stringify(i);let{generatedAt:l,...u}=i;return JSON.stringify(u)};if(await h.pathExists(e.contractPath)&&await h.pathExists(a)){let[i,l]=await Promise.all([h.readJson(e.contractPath),h.readJson(a)]);if(c$1(i)===c$1(e.contract)&&c$1(l)===c$1(o))return}b$1(E,e.contract),b$1(r,o),await c(e.workspacePath,E,async()=>{let[i,l]=await Promise.all([se(e.contractPath),se(a)]);try{if(e.contractPath===a$2(e.workspacePath,E)?await e$2(e.workspacePath,E,e.contract):(await h.ensureDir(g__default.dirname(e.contractPath)),await h.writeJson(e.contractPath,e.contract,{spaces:2})),process.env.WORKSPAI_TEST_FAIL_WORKSPACE_REGISTRY_PUBLISH==="1")throw new Error("Injected workspace registry summary publication failure.");await e$2(e.workspacePath,r,o);}catch(u){let s=(await Promise.allSettled([ce(e.contractPath,i),ce(a,l)])).filter(p=>p.status==="rejected");throw s.length>0?new AggregateError([u,...s.map(p=>p.reason)],"Workspace contract publication failed and rollback was incomplete."):u}});}async function le(e){let t=e.contractPath??(await d$1(e.workspacePath,E)||a$2(e.workspacePath,E)),r=await h.readJson(t);return {contractPath:t,contract:r}}var ve={metadata:[".workspai/project.json",".workspai/context.json",".rapidkit/project.json",".rapidkit/context.json"],manifests:["package.json","package-lock.json","pnpm-lock.yaml","yarn.lock","pyproject.toml","poetry.lock","requirements.txt","go.mod","go.sum","pom.xml","build.gradle","build.gradle.kts","Cargo.toml","Gemfile","composer.json"],entrypoints:["src/main.ts","src/index.ts","src/app.ts","src/main.js","src/index.js","main.py","app/main.py","manage.py","main.go","cmd/main.go","Program.cs"],apiSpecifications:["openapi.yaml","openapi.yml","openapi.json","swagger.yaml","swagger.yml","swagger.json"],infrastructure:["Dockerfile","docker-compose.yml","docker-compose.yaml","compose.yml","compose.yaml","k8s","kubernetes","terraform"],documentation:["README.md","ARCHITECTURE.md","CONTRIBUTING.md","docs"]};function We(e,t){return t.externalPath?g__default.resolve(t.externalPath):g__default.resolve(e,t.relativePath)}async function Se(e){let t={metadata:[],manifests:[],entrypoints:[],apiSpecifications:[],infrastructure:[],documentation:[]};for(let[r,o]of Object.entries(ve))for(let a of o)await h.pathExists(g__default.join(e,a))&&t[r].push(a);try{let r=await h.readdir(e,{withFileTypes:true});for(let o of r)o.isFile()&&(o.name.endsWith(".csproj")||o.name.endsWith(".sln"))&&t.manifests.push(o.name),o.isFile()&&o.name.endsWith(".tf")&&t.infrastructure.push(o.name);}catch{}for(let r of Object.values(t))r.sort((o,a)=>o.localeCompare(a));return t}function A(e){return !e||typeof e!="object"||Array.isArray(e)?[]:Object.keys(e).sort((t,r)=>t.localeCompare(r))}async function Ae(e){try{let t=await h.readJson(g__default.join(e,"package.json")),r={runtime:A(t.dependencies),development:A(t.devDependencies),peer:A(t.peerDependencies),optional:A(t.optionalDependencies)};return {...typeof t.name=="string"?{name:t.name}:{},...typeof t.version=="string"?{version:t.version}:{},...typeof t.private=="boolean"?{private:t.private}:{},scripts:A(t.scripts),dependencies:r,dependencyCount:new Set(Object.values(r).flat()).size}}catch{return}}async function Re(e){for(let t of [".env.example",".env.sample",".env.template"])try{return (await h.readFile(g__default.join(e,t),"utf8")).split(/\r?\n/).map(o=>o.trim()).filter(o=>o.length>0&&!o.startsWith("#")&&o.includes("=")).map(o=>o.slice(0,o.indexOf("=")).trim()).filter(o=>/^[A-Za-z_][A-Za-z0-9_]*$/.test(o)).sort((o,a)=>o.localeCompare(a))}catch{}return []}function xe(e,t){try{let r=w(e);if(r.engine!=="unknown")return r;let o=h.pathExistsSync(g__default.join(e,"package.json"))?"npm":h.pathExistsSync(g__default.join(e,"pyproject.toml"))?"python":h.pathExistsSync(g__default.join(e,"requirements.txt"))?"pip":"unknown";return {...r,engine:o,runtime:t.runtime??r.runtime,framework:t.framework??r.framework,frameworkDisplayName:t.framework??r.frameworkDisplayName}}catch{return {schemaVersion:1,scope:"project",projectRoot:null,engine:"unknown",runtime:"unknown",framework:"unknown",frameworkDisplayName:"Unknown",frameworkConfidence:"low",frameworkSupportTier:"observed",runtimeSupportTier:"observed",runtimeDoctorSupport:"observed",moduleSupport:false,fleetStages:[],localOnlyCommands:[],commandMap:{},supportedCommands:[],unsupportedCommands:[],globalCommands:[]}}}function _e(e,t,r){let o=e.projects.map(a=>({id:a.slug,path:a.relativePath,runtime:a.runtime,framework:a.framework}));return {schemaVersion:"workspace-dependency-graph.v1",generatedAt:t,nodes:o,edges:[],stats:{nodeCount:o.length,edgeCount:0,inferredEdges:0,contractEdges:0,manualEdges:0,authoritativeEdges:0,lowConfidenceEdges:0,orphanCount:o.length,connectedNodeCount:0,density:0,edgeCoverageRatio:o.length===0?1:0,evidenceCoverageRatio:1,hotspotCount:0,hasCycle:false},diagnostics:[{code:"graph.enrichment.failed",severity:"warning",message:r,recommendation:"Review project manifests and graph overrides, then rerun workspace contract graph."}]}}async function nt(e){let{contractPath:t,contract:r}=await le(e),o=e.now??new Date,a$1=o.toISOString(),{buildWorkspaceModel:c,workspaceModelProjectTopology:i}=await import('./workspace-model-MNJOGBPP.js'),{hashWorkspaceModel:l}=await import('./workspace-model-hash-ZXYPIGCW.js'),u=await c({workspacePath:e.workspacePath,includeEvidence:false,now:o}),d=i(u)??_e(r,a$1,"The canonical Workspace Model did not provide a project dependency topology."),s=new Map(d.nodes.map(n=>[n.id,n.operationalProfile])),{buildWorkspaceKnowledgeGraph:p}=await import('./workspace-knowledge-graph-BMMM2FUE.js'),k=await p({workspacePath:e.workspacePath,workspace:{name:u.workspace.name,...u.workspace.profile?{profile:u.workspace.profile}:{}},contract:r,projectTopology:d,now:o,projects:u.projects.map(n=>({id:n.name,path:n.path,...n.absolutePath?{absolutePath:n.absolutePath}:{},runtime:n.runtime,runtimeCandidates:n.runtimeCandidates,framework:n.framework,...n.kit?{kit:n.kit}:{}})),source:{kind:"workspace-model",artifact:a.model,hashAlgorithm:"sha256",hash:l(u)}}),f=await Promise.all(r.projects.map(async n=>{let m=We(e.workspacePath,n),[_,v,me]=await Promise.all([Se(m),Ae(m),Re(m)]),C=xe(m,n);return {id:n.slug,label:n.slug,relativePath:n.relativePath,source:n.source,relationship:n.relationship,externalPath:n.externalPath,runtime:n.runtime??C.runtime,framework:n.framework??C.framework,kit:n.kit,modules:n.modules,ports:n.ports,apis:n.contracts.apis,owns:n.contracts.owns,env:[...new Set([...n.contracts.env,...me])].sort((ge,fe)=>ge.localeCompare(fe)),contracts:{owns:[...n.contracts.owns],apis:[...n.contracts.apis],publishes:[...n.contracts.publishes],consumes:[...n.contracts.consumes],dependsOn:[...n.contracts.dependsOn],env:[...n.contracts.env]},capabilities:{engine:C.engine,supportTier:C.frameworkSupportTier,runtimeSupportTier:C.runtimeSupportTier,doctorSupport:C.runtimeDoctorSupport,moduleSupport:C.moduleSupport,fleetStages:[...C.fleetStages],localOnlyCommands:[...C.localOnlyCommands],supportedCommands:[...C.supportedCommands]},files:_,...v?{package:v}:{},...s.get(n.slug)?{operationalProfile:s.get(n.slug)}:{}}})),P=new Set(f.map(n=>n.id)),y=new Map,w=[];for(let n of r.projects){for(let m of n.contracts.dependsOn||[])P.has(m)&&w.push({from:m,to:n.slug,type:"dependency",label:"dependsOn"});for(let m of n.contracts.publishes||[])y.has(m)||y.set(m,new Set),y.get(m)?.add(n.slug);}for(let n of r.projects)for(let m of n.contracts.consumes||[]){let _=y.get(m);if(_)for(let v of _)v!==n.slug&&w.push({from:v,to:n.slug,type:"event",label:m});}let x={schemaVersion:1,kind:"rapidkit.workspace.contract.graph",workspace:r.workspace,generatedAt:a$1,nodes:f.sort((n,m)=>n.id.localeCompare(m.id)),edges:w.sort((n,m)=>`${n.from}:${n.to}:${n.type}:${n.label}`.localeCompare(`${m.from}:${m.to}:${m.type}:${m.label}`)),dependencyGraph:d,knowledgeGraph:k,semantics:{legacyEdges:"producer-to-consumer",dependencyGraphEdges:"consumer-to-dependency"},summary:{projectCount:f.length,dependencyEdges:w.filter(n=>n.type==="dependency").length,eventEdges:w.filter(n=>n.type==="event").length,portCount:f.reduce((n,m)=>n+m.ports.length,0),apiCount:f.reduce((n,m)=>n+m.apis.length,0),relationshipEdges:d.stats.edgeCount,inferredEdges:d.stats.inferredEdges,authoritativeEdges:d.stats.authoritativeEdges,orphanProjects:d.stats.orphanCount,hotspotProjects:d.stats.hotspotCount,evidenceCoverageRatio:d.stats.evidenceCoverageRatio,edgeCoverageRatio:d.stats.edgeCoverageRatio,connectedProjects:d.stats.connectedNodeCount,lowConfidenceEdges:d.stats.lowConfidenceEdges,hasCycle:d.stats.hasCycle,manifestCount:f.reduce((n,m)=>n+m.files.manifests.length,0),entrypointCount:f.reduce((n,m)=>n+m.files.entrypoints.length,0),diagnostics:d.diagnostics?.length??0,relationshipKinds:Object.fromEntries(re.map(n=>[n,d.edges.filter(m=>m.kind===n).length])),relationshipSources:Object.fromEntries(oe.map(n=>[n,d.edges.filter(m=>m.source===n).length])),entityCount:k.quality.entityCount,knowledgeRelations:k.quality.relationCount,proofCount:k.quality.proofCount,providerCount:k.providers.length,knowledgeUnknowns:k.quality.unknownCount}};return {contractPath:t,graph:x}}async function ue(e){let t=e.contract?{contractPath:e.contractPath??a$2(e.workspacePath,E),contract:e.contract}:await le(e),{contractPath:r,contract:o}=t,a=[],c=[];o.kind!=="rapidkit.workspace.contract"&&a.push("Contract kind must be rapidkit.workspace.contract."),o.schemaVersion!==R&&a.push(`Contract schemaVersion must be ${R}.`),o.workspace?.name||a.push("Contract workspace.name is required."),Array.isArray(o.projects)||a.push("Contract projects must be an array.");let i=new Set,l$1=new Map;for(let s of o.projects||[]){if(!s.slug){a.push("Every project must declare slug.");continue}i.has(s.slug)&&a.push(`Duplicate project slug: ${s.slug}.`),i.add(s.slug),s.relativePath?H(s.relativePath)||a.push(`Project ${s.slug} declares unsafe relativePath: ${s.relativePath}.`):a.push(`Project ${s.slug} must declare relativePath.`),s.externalPath&&(s.relationship==="adopted"||s.source==="adopted-local"||s.source==="local-folder"||s.source==="git-url"||a.push(`Project ${s.slug} declares externalPath without imported/adopted provenance.`),g__default.isAbsolute(s.externalPath)||a.push(`Project ${s.slug} declares non-absolute externalPath.`));for(let p of s.ports||[]){(!Number.isInteger(p.port)||p.port<1||p.port>65535)&&a.push(`Project ${s.slug} declares invalid port: ${p.port}.`);let k=l$1.get(p.port);k&&a.push(`Port ${p.port} is claimed by both ${k} and ${s.slug}.`),l$1.set(p.port,s.slug);}for(let p of s.contracts?.apis||[])(!p.name?.trim()||!p.basePath?.startsWith("/"))&&a.push(`Project ${s.slug} declares invalid API contract.`);for(let p of [...s.contracts?.publishes||[],...s.contracts?.consumes||[]])p.trim()||a.push(`Project ${s.slug} declares an empty event contract.`);for(let p of s.contracts?.env||[])/^[A-Z_][A-Z0-9_]*$/.test(p)||a.push(`Project ${s.slug} declares invalid env contract: ${p}.`);for(let p of s.contracts?.dependsOn||[])i.has(p);}for(let s of o.projects||[])for(let p of s.contracts?.dependsOn||[])i.has(p)||a.push(`Project ${s.slug} depends on unknown project: ${p}.`);c.push({id:"schema",status:o.kind==="rapidkit.workspace.contract"&&o.schemaVersion===R?"passed":"failed",message:"Contract schema and kind are valid."}),c.push({id:"projects",status:Array.isArray(o.projects)?"passed":"failed",message:`Contract declares ${Array.isArray(o.projects)?o.projects.length:0} project(s).`}),c.push({id:"ports",status:a.some(s=>s.toLowerCase().includes("port"))?"failed":"passed",message:"Project port declarations are valid and collision-free."}),c.push({id:"dependencies",status:a.some(s=>s.includes("depends on unknown project"))?"failed":"passed",message:"Project dependencies point to known project slugs."}),c.push({id:"contracts",status:a.some(s=>s.includes("unsafe relativePath")||s.includes("invalid API contract")||s.includes("event contract")||s.includes("env contract"))?"failed":"passed",message:"Project path, API, event, and env contracts are valid."});let u=await l(e.workspacePath);if(u.moduleCount>0){for(let s of u.issues)a.push(`${g__default.basename(s.projectRoot)}: ${s.message} (slug=${s.slug})`);c.push({id:"module-paths",status:u.status,message:u.status==="passed"?`All ${u.moduleCount} registered module(s) resolve under canonical paths.`:`${u.issues.length} registered module(s) missing canonical install paths.`});}else e.strict&&c.push({id:"module-paths",status:"passed",message:"No registry-backed modules declared in workspace projects."});return {status:a.length>0?"failed":"passed",contractPath:r,projectCount:Array.isArray(o.projects)?o.projects.length:0,checks:c,violations:a}}async function at(e){let t=g__default.resolve(e.workspacePath),r={schemaVersion:we,generatedAt:e.generatedAt??new Date().toISOString(),status:e.result.status,contractPath:e.result.contractPath,projectCount:e.result.projectCount,checks:e.result.checks,violations:e.result.violations};return e$2(t,ke,X(r))}
|
|
2
|
-
export{I as a,Te as b,Ve as c,X as d,Fe as e,re as f,E as g,ke as h,R as i,we as j,N as k,Ee as l,pe as m,rt as n,ot as o,le as p,nt as q,ue as r,at as s};
|
package/dist/chunk-NYHVCFBT.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import {b}from'./chunk-44VJHNZB.js';var o="model-usage-event.v1",s=b.evaluationLive,a="workspace-intelligence-evaluation-comparison.v1",i=["provider-reported","tokenizer-counted","estimated","unavailable"];export{o as a,s as b,a as c,i as d};
|
package/dist/chunk-OUBBBC7T.js
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
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 as i$1,l,m,n,o,p as p$2,q,r,t,v as v$1,x,s,u as u$1,w,y,z,A,B,C as C$1,D,E,F,G,H as H$1,a as a$3,I}from'./chunk-AMB42V2F.js';import {b as b$1,c,d as d$1}from'./chunk-P7K5RHJC.js';import {b as b$3}from'./chunk-RA24WQLF.js';import {d as d$3}from'./chunk-XVRJVKOX.js';import {h,g as g$1}from'./chunk-H7P7SSUW.js';import {p,k as k$1,f as f$3}from'./chunk-7AR5PDLD.js';import {p as p$1}from'./chunk-MQ73VS4E.js';import {d}from'./chunk-WIO6L24E.js';import {a as a$2,b as b$5}from'./chunk-BYVTHIC3.js';import {b,a,e,d as d$2}from'./chunk-44VJHNZB.js';import {f,g,h as h$1}from'./chunk-MOSXTVPU.js';import i from'path';import f$1 from'fs-extra';var ee=["Scope","Evidence","Diagnosis","Fix Plan","Run","Verify","Assumptions"];var ht="workspace-operational-skill.v1";function At(e){if(typeof e!="string")return null;let t=e.trim();return !t||t.includes("/")||t.includes("..")?null:t}function et(e){let t=At(e.skillId);if(!t)throw new Error(`Invalid skill id: ${e.skillId}`);return {schemaVersion:ht,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:[...ee],...e.promptStem?{promptStem:e.promptStem}:{},markdown:e.markdown}}var wt=b.skillsIndex;function tt(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:wt,generatedAt:e.generatedAt,inputsHash:r,skills:t.map(n=>({skillId:n.skillId,path:n.canonicalPath,schemaVersion:n.schemaVersion,title:n.title}))}}var rt=[a.agentIndex,b$1,d$3],Pt=[{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 \`${e.artifactRemediationPlan}\` 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 \`${e.workspaceContract}\` 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 te(e){return `npx workspai ${e}`.trim()}function Rt(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)","",...rt.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",te("workspace agent-sync --write --refresh-context"),"```",""),t.join(`
|
|
2
|
-
`)}function St(e){return e?.safeCommands?.length?e.safeCommands.slice(0,8).map(t=>t.display):[te("workspace verify --json"),te("doctor workspace --json")]}function Ct(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",l=r.contracts?.consumes?.join(", ")||"none";return `- **${r.slug}**: owns \`${n}\`; publishes \`${c}\`; consumes \`${l}\``}).join(`
|
|
3
|
-
`):void 0}function nt(e){let t=e.model.workspace.name,r=e.model.projects.map(l=>l.name).sort(),n=St(e.context??null),c=Ct(e.contract??null);return Pt.map(l=>{let p=Rt({template:l,workspaceName:t,scopedProjects:r,verificationCommands:n,contractSummary:c});return et({skillId:l.skillId,title:l.title,triggers:l.triggers,requiredReports:[...rt],scopedProjects:r,verificationCommands:n,promptStem:I[l.skillId],markdown:p})})}async function at(e){let t=i.resolve(e.workspacePath),r=[],n=f$3({skills:e.skills.map(l=>({id:l.skillId,path:l.canonicalPath,hash:f$3({markdown:l.markdown})}))}),c=tt({generatedAt:e.generatedAt,skills:e.skills,inputsHash:n});if(e.write){for(let p of e.skills){let o=i.join(t,p.canonicalPath);await f$1.ensureDir(i.dirname(o)),await f$1.writeFile(o,p.markdown,"utf8"),r.push(p.canonicalPath);}let l=i.join(t,b$2);await f$1.ensureDir(i.dirname(l)),await f$1.writeJson(l,c,{spaces:2}),r.push(b$2);}return {skills:e.skills,index:c,writtenPaths:r}}function ot(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",te("workspace agent-sync --write --refresh-context"),"```",""].join(`
|
|
4
|
-
`)}var yt={"workspai-diagnose-api-failure":p$2,"workspai-release-readiness":t},Ie="## Workspace verification (hydrated)";function Et(e){let t=[Ie,"","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 it(e){let t=i.resolve(e.workspacePath),r=[];for(let n of e.skills){let c=yt[n.skillId];if(!c)continue;let l=i.join(t,c);if(!await f$1.pathExists(l))continue;let p=await f$1.readFile(l,"utf8"),o=Et(n),w=p.includes(Ie)?p.replace(new RegExp(`${Ie}[\\s\\S]*$`),o.trimEnd()):`${p.trimEnd()}
|
|
6
|
-
|
|
7
|
-
${o}`;e.write&&await f$1.writeFile(l,`${w.trimEnd()}
|
|
8
|
-
`,"utf8"),r.push(c);}return r}var xt="workspai-agent-customization-pack-capabilities.v1";function st(){return {schemaVersion:xt,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:[...ee],requiredReports:K.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 It=b.agentIndex,Ot=b.agentCustomizationPack,H=a.agentIndex,M=a.agentCustomizationPack;var K=[{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:e.doctorProject,label:"Project doctor",required:false},{relativePath:e.doctorRemediationPlan,label:"Doctor remediation plan",required:false},{relativePath:e.artifactRemediationPlan,label:"Artifact remediation plan",required:false},{relativePath:e.doctorFixResult,label:"Doctor fix result",required:false},{relativePath:a.analyze,label:"Workspace analyze",required:false},{relativePath:e.pipelineLastRun,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 bt(){let e=K.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 Te(e){return e&&typeof e=="object"?e:null}function Oe(e,t=12){return Array.isArray(e)?e.filter(r=>typeof r=="string"&&r.trim().length>0).slice(0,t):[]}function _t(e){let t=Oe(e.blockers,12);if(t.length>0)return t;let r=Oe(e.blockingReasons,12);if(r.length>0)return r;let n=Te(e.summary);return n&&Array.isArray(n.blockingReasons)?Oe(n.blockingReasons,12):[]}function Tt(e){let t=[...new Set(e.map(r=>r.trim()).filter(Boolean))];return t.filter(r=>{let n=r.toLowerCase();return !t.some(c=>{if(c===r||!c.includes(":"))return false;let l=c.toLowerCase();return l.length>n.length&&l.endsWith(n)})})}function vt(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=>Te(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 Wt(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 jt(e,t,r){return e.path===a.snapshot?false:Wt(e.generatedAt,t,r)}function Lt(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 C(e,t){return e.has("all")||e.has(t)}function Nt(e){return C(e,"copilot")||C(e,"vscode")}function Gt(e){return e??"enterprise"}function Dt(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 $t(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 Kt(e,t){return st().presets[t].requiredOutputs.includes(e)}async function Mt(e,t){if(t)return t;let r=await d(e,k$1)??i.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 Ht(e){return e.length>0&&!i.isAbsolute(e)&&!e.split(/[\\/]+/).includes("..")}function qt(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 Vt(e,t){try{if(!await f$1.pathExists(e))return {payload:null,exists:false,validity:"missing"};let r=await f$1.readJson(e),n=Te(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 ct(e){let t=e.now??new Date,r=e.staleAfterHours??24,n=[],c=[];for(let o of K){let w=await d(e.workspacePath,o.relativePath)??i.join(e.workspacePath,o.relativePath),h=await Vt(w,o.relativePath),g=h.payload;h.validity==="invalid"?c.push(`Invalid evidence contract: ${o.relativePath}`):g&&c.push(..._t(g)),n.push({path:o.relativePath,label:o.label,required:o.required,exists:h.exists,validity:h.validity,validationError:h.validationError,generatedAt:g?vt(g):void 0,commandId:typeof g?.commandId=="string"?g.commandId:void 0,exitCode:typeof g?.exitCode=="number"?g.exitCode:void 0});}let l=Tt(c).slice(0,16),p=b$3();return {schemaVersion:It,generatedAt:t.toISOString(),workspaceRoot:e.workspacePath,intelligenceChain:{schemaVersion:p.schemaVersion,contractPath:p.contractPath,currentStep:"agent-sync"},readOrder:bt(),blockers:l,staleAfterHours:r,reports:n,refreshCommand:P("workspace agent-sync --write --refresh-context")}}function lt(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 Ut(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 Ft(){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 zt(){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 Bt(){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 Jt(){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 Yt(){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 Xt(){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 Zt(){return ["# Legacy RapidKit evidence alias","","Compatibility path only. Use `.claude/rules/workspai-evidence.md` as the canonical rule.",""].join(`
|
|
17
|
-
`)}function Qt(){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 dt(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 pt(){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 re(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 v(e){return ["# "+e.title,"",...e.lines,""].join(`
|
|
22
|
-
`)}function er(){return v({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 tr(e$1){return `${JSON.stringify({schemaVersion:d$2.workspaiMcpDesign.schemaVersion,generatedAt:e$1.generatedAt,workspaceRoot:e$1.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,e.pipelineLastRun],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 rr(e){return `${JSON.stringify({schemaVersion:d$2.agentHooks.schemaVersion,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 ut(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 ne(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 gt(){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(i.dirname(e)),await f$1.writeFile(e,t,"utf8"),"written"):"skipped"}async function be(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(i.dirname(e.absolutePath)),await f$1.writeFile(e.absolutePath,c,"utf8"),"written"}function Jr(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 nr(e){let t=[...e.outputs].sort((n,c)=>n.path.localeCompare(c.path)),r=b$3();return {schemaVersion:Ot,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:qt({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 _e(e){let t$1=i.resolve(e.workspacePath),r$1=e.now??new Date,n$1=e.staleAfterHours??24,c$1=Lt(e.targets),l$1=[...c$1].sort(),p$3=Gt(e.preset),o$1=e.write===true,w$1=e.strict===true,h,g=null,ae=e.model;e.refreshContext&&(ae??=await p({workspacePath:t$1,includeEvidence:true}),g=await c({workspacePath:t$1,model:ae,agent:e.agent??"generic",scope:e.scope,includeEvidence:true}),o$1&&(h=await d$1(g,t$1)));let _=[],oe=[],ie=[],se=[],d=(s,k)=>{s==="written"?oe.push(k):ie.push(k),se.push({path:k,kind:Dt(k),targets:$t(k),required:Kt(k,p$3),status:s==="written"?"written":e.dryRun?"planned":"skipped"});},ce="",mt=await Mt(t$1,ae),le=null;try{le=(await p$1({workspacePath:t$1})).contract;}catch{le=null;}let kt=nt({model:mt,context:g,contract:le}),de=await at({workspacePath:t$1,skills:kt,generatedAt:r$1.toISOString(),write:o$1});for(let s of de.skills)d(o$1?"written":"skipped",s.canonicalPath);d(o$1?"written":"skipped",b$2),ce=ot(de.index);let y$1=await ct({workspacePath:t$1,staleAfterHours:n$1,now:r$1});if(d(await u(i.join(t$1,H),`${JSON.stringify(y$1,null,2)}
|
|
30
|
-
`,o$1),H),d(await u(i.join(t$1,f$2),`${Ut(y$1)}
|
|
31
|
-
`,o$1),f$2),(C(c$1,"agents")||C(c$1,"vscode"))&&d(await be({absolutePath:i.join(t$1,"AGENTS.md"),generatedBody:lt({index:y$1,context:g}),write:o$1}),"AGENTS.md"),C(c$1,"claude")){let s=i.join(t$1,"CLAUDE.md");if(o$1){let{upsertManagedAgentSection:k}=await import('./managed-agent-markers-COE5DJ3W.js'),m=await f$1.pathExists(s)?await f$1.readFile(s,"utf8"):"",A=k(m,zt()),E=A.includes("@AGENTS.md")?A:`@AGENTS.md
|
|
32
|
-
|
|
33
|
-
${A}`;await f$1.ensureDir(i.dirname(s)),await f$1.writeFile(s,E,"utf8"),oe.push("CLAUDE.md");}else ie.push("CLAUDE.md");d(await u(i.join(t$1,j),`${Xt()}
|
|
34
|
-
`,o$1),j),d(await u(i.join(t$1,k),`${Zt()}
|
|
35
|
-
`,o$1),k);}if(C(c$1,"cursor")&&(d(await u(i.join(t$1,h$2),Bt(),o$1),h$2),d(await u(i.join(t$1,i$1),Qt(),o$1),i$1)),Nt(c$1)){if(d(await be({absolutePath:i.join(t$1,".github/copilot-instructions.md"),generatedBody:Ft(),write:o$1}),".github/copilot-instructions.md"),d(await u(i.join(t$1,l),Yt(),o$1),l),d(await u(i.join(t$1,m),dt("workspace"),o$1),m),d(await u(i.join(t$1,n),Jt(),o$1),n),d(await u(i.join(t$1,o),dt("evidence"),o$1),o),d(await u(i.join(t$1,p$2),pt(),o$1),p$2),d(await u(i.join(t$1,q),pt(),o$1),q),p$3==="enterprise"){let s$1=[[r,re({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,re({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$1,re({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,re({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,A]of s$1)d(await u(i.join(t$1,m),A,o$1),m);let k=[[s,s$1[0][1]],[u$1,s$1[1][1]],[w,s$1[2][1]],[y,s$1[3][1]]];for(let[m,A]of k)d(await u(i.join(t$1,m),A,o$1),m);if(e.hydratePrompts===true)for(let m of await it({workspacePath:t$1,skills:de.skills,write:o$1}))d(o$1?"written":"skipped",m);}if(d(await u(i.join(t$1,z),gt(),o$1),z),d(await u(i.join(t$1,A),gt(),o$1),A),p$3==="enterprise"){d(await u(i.join(t$1,B),ut(ce),o$1),B),d(await u(i.join(t$1,C$1),ut(ce),o$1),C$1);let s=[["artifact-map.md",v({title:"Artifact Map",lines:K.map(m=>`- \`${m.relativePath}\` \u2014 ${m.label}`)})],["command-map.md",v({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",v({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",v({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",v({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",er()]];for(let[m,A]of s){let E=`${i.dirname(B)}/resources/${m}`;d(await u(i.join(t$1,E),A,o$1),E);let We=`${i.dirname(C$1)}/resources/${m}`;d(await u(i.join(t$1,We),A,o$1),We);}let k=[["workspai-advisor.agent.md",ne({name:"Workspai Advisor",description:"Read-only workspace and project guidance using Workspai evidence",mode:"read-only",tools:["search","read"]})],["workspai-repair.agent.md",ne({name:"Workspai Repair",description:"Turn Workspai blockers into minimal fixes and verification steps",mode:"repair",tools:["search","read","edit"]})],["workspai-release.agent.md",ne({name:"Workspai Release",description:"Assess readiness, governance gates, and release safety from evidence",mode:"release",tools:["search","read"]})],["workspai-project-onboarder.agent.md",ne({name:"Workspai Project Onboarder",description:"Guide create, import, and adopt flows with Workspai contracts",mode:"onboard",tools:["search","read","edit"]})]];for(let[m,A]of k){let E=`.github/agents/${m}`;d(await u(i.join(t$1,E),A,o$1),E);}}}if(p$3==="enterprise"){let s=tr({workspacePath:t$1,generatedAt:y$1.generatedAt});b$5(D,JSON.parse(s)),d(await u(i.join(t$1,D),s,o$1),D),d(await u(i.join(t$1,E),s,o$1),E);}if(p$3==="enterprise"&&e.experimentalHooks===true){let s=rr({workspacePath:t$1,generatedAt:y$1.generatedAt});b$5(F,JSON.parse(s)),d(await u(i.join(t$1,F),s,o$1),F),d(await u(i.join(t$1,G),s,o$1),G);}(C(c$1,"codex")||C(c$1,"orca"))&&(C(c$1,"agents")||d(await be({absolutePath:i.join(t$1,"AGENTS.md"),generatedBody:lt({index:y$1,context:g}),write:o$1}),"AGENTS.md"));let pe=o$1?await ct({workspacePath:t$1,staleAfterHours:n$1,now:r$1}):y$1,q$1=pe.reports.filter(s=>s.required&&!s.exists).map(s=>s.path),V=pe.reports.filter(s=>s.exists&&jt(s,n$1,r$1)).map(s=>s.path);if(w$1){q$1.length>0&&_.push(`Missing required reports: ${q$1.join(", ")}`),V.length>0&&_.push(`Stale reports (>${n$1}h): ${V.join(", ")}`);let s=se.map(k=>k.path).filter(k=>!Ht(k));s.length>0&&_.push(`Unsafe generated output paths: ${s.join(", ")}`);}let U=o$1?await g$1({workspacePath:t$1,mode:e.projectGrounding??"managed",now:r$1}):void 0;w$1&&U&&U.skipped.length>0&&_.push(`Project grounding incomplete: ${U.skipped.map(s=>`${s.name} (${s.reason})`).join(", ")}`);let ve=nr({workspacePath:t$1,generatedAt:r$1.toISOString(),preset:p$3,targets:l$1,index:pe,outputs:[...se,{path:M,kind:"report",targets:["agents","vscode","copilot","codex","orca"],required:true,status:o$1?"written":e.dryRun?"planned":"skipped"}],missingRequired:q$1,staleReports:V,strictViolations:_,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 d(await u(i.join(t$1,M),`${JSON.stringify(ve,null,2)}
|
|
36
|
-
`,o$1),M),{workspacePath:t$1,indexPath:i.join(t$1,H),packPath:i.join(t$1,M),pack:ve,contextPath:h,writtenFiles:oe,skippedFiles:ie,blockers:y$1.blockers,missingRequired:q$1,staleReports:V,strictViolations:_,projectLenses:U}}async function Yr(e){if(e.write!==true)return _e(e);let t=i.resolve(e.workspacePath),r=i.join(t,".workspai","transactions","agent-sync");await b$4(r);let n=await _e({...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,M],l=await a$1({journalDirectory:r});try{for(let w of [...new Set(c)].sort()){let h=i.resolve(t,w),g=i.relative(t,h);if(g===".."||g.startsWith(`..${i.sep}`)||i.isAbsolute(g))throw new Error(`Agent-sync output escapes workspace root: ${w}`);await l.captureFile(h);}let p=await h(t);for(let w of p.resolved)for(let h of [f,g,h$1,"AGENTS.md",".gitignore"])await l.captureFile(i.join(w.projectPath,h));let o=await _e(e);return await l.commit(),o}catch(p){try{await l.rollback();}catch(o){throw new AggregateError([p,o],"Agent-sync generation failed and rollback was incomplete.")}throw p}}export{ht as a,wt as b,xt as c,It as d,Ot as e,H as f,M as g,K as h,bt as i,ct as j,Jr as k,Yr as l};
|
package/dist/chunk-P7K5RHJC.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import {b as b$1}from'./chunk-RA24WQLF.js';import {c}from'./chunk-7KKP7RNB.js';import {p,h,i as i$1}from'./chunk-7AR5PDLD.js';import {d}from'./chunk-MQ73VS4E.js';import {e,d as d$1}from'./chunk-WIO6L24E.js';import {b,a}from'./chunk-44VJHNZB.js';import I from'path';import R from'fs-extra';var G=b.agentContext,V=a.agentContext;function q(e){if(typeof e!="string"||!e.trim()||e==="true")return "generic";let t=e.trim().toLowerCase();return t==="codex"||t==="claude"||t==="cursor"||t==="orca"?t:"generic"}function M(e){return `npx --yes --package workspai workspai ${e}`.trim()}function l(e){return `npx workspai ${e}`.trim()}function i(e){return {id:e.id,scope:e.scope,display:l(e.args),execute:M(e.args),description:e.description,...e.project?{project:e.project}:{},freshness:h({id:`command.${e.id}`,label:`${e.id} command`,scope:"command",value:{display:l(e.args),execute:M(e.args)},...e.project?{project:e.project}:{},freshness:{kind:"derived",category:"structure",generatedAt:e.generatedAt,now:e.now,sourceArtifact:a.model,sourcePath:`safeCommands.${e.id}`,reason:"Safe command surfaces are derived from workspace model command capabilities."}}).freshness}}function F(e,t){return `workspace run ${t} --scope project:${e.name}`}function L(e){return (e.startsWith("project:")?e.slice(8):e).trim().toLowerCase()}function D(e){return [e.name,e.path,I.basename(e.path),e.absolutePath].filter(t=>typeof t=="string"&&t.trim().length>0).map(t=>t.trim().toLowerCase())}function K(e,t,n){let r={generatedAt:e.generatedAt,now:n},c=[i({id:"workspace.model",scope:"workspace",args:"workspace model --json",description:"Read the canonical workspace intelligence model.",...r}),i({id:"workspace.graph.entities",scope:"workspace",args:"workspace graph entities --json",description:"Query proof-backed workspace entities without loading the full graph.",...r}),i({id:"workspace.graph.evidence",scope:"workspace",args:"workspace graph evidence <entity-or-relation> --json",description:"Resolve portable evidence for a graph entity or relation.",...r}),i({id:"workspace.graph.path",scope:"workspace",args:"workspace graph path <from> <to> --json",description:"Find a shortest proof-carrying path between workspace entities.",...r}),i({id:"workspace.doctor",scope:"workspace",args:"doctor workspace --json",description:"Check workspace health before claiming verification.",...r}),i({id:"workspace.pipeline",scope:"workspace",args:"pipeline --json",description:"Run the governed sync, doctor, analyze, readiness, and autopilot loop.",...r}),i({id:"workspace.contract.verify",scope:"workspace",args:"workspace contract verify --json",description:"Verify workspace contract and dependency edges.",...r}),i({id:"workspace.verify",scope:"workspace",args:"workspace verify --json",description:"Evaluate evidence freshness and verification gates before release decisions.",...r})],a=t?[t]:e.projects;for(let s of a)s.commands.fleetStages.includes("test")&&c.push(i({id:`project.${s.name}.test`,scope:"project",project:s.name,args:F(s,"test"),description:`Run tests for ${s.name} through workspace orchestration.`,...r})),s.commands.fleetStages.includes("build")&&c.push(i({id:`project.${s.name}.build`,scope:"project",project:s.name,args:F(s,"build"),description:`Build ${s.name} through workspace orchestration.`,...r}));return c}function H(e){return e.commands.fleetStages.filter(t=>t==="test"||t==="build").map(t=>`workspace run ${t}`)}function z(e,t){if(!t?.startsWith("project:"))return;let n=L(t);if(n)return e.projects.find(r=>D(r).includes(n))}function B(e,t,n){let r=[...e.validation?.issues??[]];t?.startsWith("project:")&&!n&&r.push({severity:"error",code:"context.scope.project.missing",message:`Requested project scope was not found: ${t}`,target:t});let c=r.filter(s=>s.severity==="error").length,a=r.filter(s=>s.severity==="warning").length;return {status:c>0?"failed":a>0?"warning":"passed",errors:c,warnings:a,issues:r}}async function U(e,t){let n=[],r=[];for(let[c,a]of Object.entries(e.evidence))a&&await d$1(t,a.path)!==null?n.push(`${c}: ${a.path}`):r.push(c);return {available:n.sort(),missing:r.sort()}}function X(e){let t=e.summary.projectCount,n=e.summary.runtimes.length?`${e.summary.runtimes.join(", ")} runtime coverage`:"no runtime coverage",r=e.identity.surfaces.length?e.identity.surfaces.join(", "):"no detected surfaces";return `${e.workspace.name} is a ${e.identity.workspaceType} with ${t} project${t===1?"":"s"}, ${n}, and ${r}.`}function J(e){let t=["Do not claim a command passed unless a report or command output proves it.","Do not infer secrets or environment values from file names.","Do not change project scope without checking the selected project."];return e.contracts.exists||t.push("Workspace contract is missing; dependency and API edges may be incomplete."),e.summary.observedProjects>0&&t.push("Some projects are observed rather than first-class; command support may be partial."),t}async function pe(e){let t=e.model??await p({workspacePath:e.workspacePath,includeEvidence:e.includeEvidence===true,observableScanDepth:e.observableScanDepth,now:e.now}),n=q(e.agent),r=z(t,e.scope),c$1=B(t,e.scope,r);if(e.strict===true&&c$1.status!=="passed"){let o=c$1.issues.map(m=>`${m.severity}:${m.code}:${m.target}`).join(", ");throw new Error(`Workspace context strict validation failed: ${o}`)}let a$1=e.now??new Date,s=t.facts??[],T=new Set((r?[r]:t.projects).map(o=>o.name)),w=s.filter(o=>o.project?T.has(o.project):true),_=(r?[r]:t.projects).map(o=>{let m=w.filter(N=>N.project===o.name);return {name:o.name,path:o.path,kind:o.kind,category:o.category,runtime:o.runtime,framework:o.frameworkDisplayName,...o.generator?{generator:o.generator}:{},createCapability:o.createCapability,supportTier:o.supportTier,safeCommands:H(o),importantFiles:o.importantFiles,facts:m}}),u=await U(t,e.workspacePath),y=I.join(e.workspacePath,a.knowledgeGraph),d=await R.pathExists(y)?await R.readJson(y).catch(()=>null):null,C=false;if(d?.schemaVersion===b.knowledgeGraph)try{c(d,t),C=true;}catch{}let v=X(t),j=K(t,r,a$1),O=j.map(o=>h({id:`context.command.${o.id}`,label:`${o.id} safe command`,scope:"command",value:{display:o.display,execute:o.execute,scope:o.scope},...o.project?{project:o.project}:{},freshness:{kind:"derived",category:"structure",generatedAt:t.generatedAt,now:a$1,sourceArtifact:a.agentContext,sourcePath:`safeCommands.${o.id}`,reason:"Context safe commands are derived from workspace model command capabilities."}})),b$2=[...w,...O],f=i$1({facts:b$2,generatedAt:a$1.toISOString(),now:a$1}),h$1=b$1();return {schemaVersion:G,generatedAt:a$1.toISOString(),agent:n,workspaceSummary:v,modelRef:a.model,knowledgeGraph:{artifact:a.knowledgeGraph,schemaVersion:b.knowledgeGraph,available:C,...typeof d?.quality?.entityCount=="number"?{entityCount:d.quality.entityCount}:{},...typeof d?.quality?.relationCount=="number"?{relationCount:d.quality.relationCount}:{},...typeof d?.quality?.proofCount=="number"?{proofCount:d.quality.proofCount}:{},queryCommands:[l("workspace graph search <query> --limit 12 --json"),l("workspace graph entities [kind] --json"),l("workspace graph evidence <entity-or-relation> --json"),l("workspace graph path <from> <to> --json")]},intelligenceChain:{schemaVersion:h$1.schemaVersion,contractPath:h$1.contractPath,currentStep:"context",canonicalReadOrder:[...h$1.consumers.agents.canonicalReadOrder]},workspace:{name:t.workspace.name,root:t.workspace.root,type:t.identity.workspaceType,...t.workspace.profile?{profile:t.workspace.profile}:{}},scope:{requested:e.scope??"workspace",...r?{activeProject:r.name}:{}},projects:_,safeCommands:j,facts:b$2,factFreshness:f,evidence:u,policies:{mode:t.policies.mode,source:t.policies.source},contracts:{exists:t.contracts.exists,path:t.contracts.workspaceContractPath},validation:c$1,agentInstructions:[`Read \`${a.agentIndex}\` first, then this context pack and linked evidence reports.`,"Use `workspace graph search <query> --limit 12 --json` for bounded, proof-backed retrieval before loading the full graph.",`Load \`${a.knowledgeGraph}\` only when a complete graph export is explicitly required.`,"Use this context as the workspace source of truth before inspecting random files.","Prefer workspace-level evidence over generic framework assumptions.","Use `display` commands when explaining steps to a human.","Use `execute` commands when launching commands from automation or tooling.","Treat `facts[].freshness.verifyBeforeUse` as a hard refresh requirement before using that fact in advice, fixes, or release decisions.","Do not carry extracted facts beyond their freshness contract; re-read or regenerate evidence when the contract says stale, unknown, live, or verify-before-use.","Keep project-scoped advice tied to the active project scope.","Regenerate stale grounding with `npx workspai workspace agent-sync --write --refresh-context`."],unsafeAssumptions:[...J(t),...f.verifyBeforeUseFacts>0?[`${f.verifyBeforeUseFacts} fact(s) require verification before use; do not treat them as durable workspace structure.`]:[]],humanSummary:[v,`Evidence available: ${u.available.length}. Missing evidence groups: ${u.missing.join(", ")||"none"}.`,r?`Active project scope: ${r.name} (${r.frameworkDisplayName}).`:"Scope: whole workspace."].join(`
|
|
2
|
-
`)}}async function de(e$1,t){return e(t,V,d(e$1))}export{G as a,V as b,pe as c,de as d};
|
package/dist/chunk-PS5F4DCT.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
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};
|
package/dist/chunk-QZ7PNMVP.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import {b,d}from'./chunk-44VJHNZB.js';var y=b.doctor,h=d.doctorProject.schemaVersion;function n(e){return !e||typeof e!="object"||Array.isArray(e)?null:e}function S(e,o){let r=n(e);if(!r)return false;let s=r.schemaVersion,i=r.evidenceType;return !(typeof s=="string"&&(s!==y&&s!==h||o==="workspace"&&s!==y||o==="project"&&s!==h)||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 D(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"),d=c(r,"errors");if(s!==i+f+d)throw new Error("Doctor healthScore total must equal passed + warnings + errors.");let l=d>0?"blocked":f>0?"attention":"passed";if(r.verdict!==l)throw new Error(`Doctor healthScore verdict ${String(r.verdict)} contradicts score counts (${l}).`);let p=0,g=0;for(let t of v(o)){let w=Array.isArray(t.probes)?t.probes:[];p+=w.filter(u=>n(u)?.status==="fail").length,g+=Array.isArray(t.issues)?t.issues.length:0;let a=n(t.probeSummary);if(a){let u=c(a,"blockingFindings"),A=w.filter(k=>n(k)?.status==="fail").length+(Array.isArray(t.issues)?t.issues.length:0);if(u!==A)throw new Error("Doctor project probeSummary.blockingFindings contradicts failed probes and runtime issues.");let E=u>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(p+g>0&&d===0)throw new Error("Doctor evidence contains blocking findings but healthScore.errors is zero.")}export{y as a,h as b,S as c,D as d};
|