workspai 0.58.0 → 0.59.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +80 -32
- package/contracts/agent-customization-pack.v1.json +52 -4
- package/contracts/cli-runtime-command-inventory.v1.snapshot.json +90 -0
- package/contracts/extension-cli-compatibility.v1.json +3 -1
- package/contracts/project-workspace-resolution.v1.json +15 -2
- package/contracts/published-contract-catalog.v1.json +10 -0
- package/contracts/runtime-command-surface.v1.json +54 -0
- package/contracts/workspace-intelligence/agent-bootstrap-receipt.v1.json +247 -0
- package/contracts/workspace-intelligence/agent-customization-pack-report.v1.json +16 -1
- package/contracts/workspace-intelligence/goal-index.v1.json +7 -1
- package/contracts/workspace-intelligence/goal-pack.v1.json +2 -1
- package/contracts/workspace-intelligence/project-agent-entry.v1.json +204 -0
- package/contracts/workspace-intelligence/project-context-agent.v1.json +43 -26
- package/contracts/workspace-intelligence/workspace-context.v1.json +14 -1
- package/contracts/workspace-intelligence/workspace-repair-transaction.v1.json +15 -2
- package/contracts/workspace-repair-capabilities.v1.json +5 -0
- package/dist/analyze-52TEGLDR.js +1 -0
- package/dist/{artifact-remediation-plan-JRX4XZ7C.js → artifact-remediation-plan-HPNQTNJ2.js} +1 -1
- package/dist/autopilot-release-NFLAKBA3.js +1 -0
- package/dist/capabilities-command-VBLZXP2T.js +1 -0
- package/dist/{chunk-TTLVG5AR.js → chunk-3CGR6435.js} +1 -1
- package/dist/chunk-4PUJVYRM.js +1 -0
- package/dist/{chunk-4NN5QWOB.js → chunk-5NIZNXRS.js} +1 -1
- package/dist/{chunk-HYY5PQCV.js → chunk-5PSKBJKJ.js} +1 -1
- package/dist/{chunk-AA4PNQKR.js → chunk-5SFCBZOH.js} +1 -1
- package/dist/{chunk-MFJ6ZP7S.js → chunk-6FBNSTUS.js} +1 -1
- package/dist/{chunk-FY6OHOXR.js → chunk-7DSYI7YN.js} +1 -1
- package/dist/chunk-7SFXADXO.js +2 -0
- package/dist/{chunk-GRGUPSNP.js → chunk-CCDGHPEJ.js} +1 -1
- package/dist/{chunk-T63WRURN.js → chunk-D65FCQIO.js} +1 -1
- package/dist/{chunk-YYCPRYP7.js → chunk-DGGTTRYE.js} +1 -1
- package/dist/chunk-DQ6VXTDE.js +1 -0
- package/dist/{chunk-SM55RK3C.js → chunk-ENKGGWRX.js} +1 -1
- package/dist/chunk-FLTIFYTJ.js +142 -0
- package/dist/{chunk-RMDVRNU7.js → chunk-GPOZILMY.js} +1 -1
- package/dist/{chunk-C4NYG57I.js → chunk-HCFWT42C.js} +1 -1
- package/dist/{chunk-RJDGC6AQ.js → chunk-HS3DJMU5.js} +1 -1
- package/dist/{chunk-HI7ONEFI.js → chunk-J3X56S7L.js} +1 -1
- package/dist/{chunk-N3DFX4BY.js → chunk-KBR4Y4RW.js} +1 -1
- package/dist/{chunk-H545P6LN.js → chunk-KTN2ARZJ.js} +1 -1
- package/dist/chunk-LPCWROQ3.js +1 -0
- package/dist/chunk-MZKKRAAJ.js +2 -0
- package/dist/{chunk-LGJAAPNR.js → chunk-N4QQADXX.js} +1 -1
- package/dist/{chunk-FXIE2WVG.js → chunk-NOZ4JCH7.js} +1 -1
- package/dist/chunk-NZ3WZYD5.js +1 -0
- package/dist/{chunk-VAWV3UKV.js → chunk-OFWSZYUX.js} +1 -1
- package/dist/{chunk-XC26FNRL.js → chunk-P2WH7W2H.js} +11 -11
- package/dist/chunk-PVXSIYLP.js +1 -0
- package/dist/{chunk-7KXRA5ST.js → chunk-PXWKMPPI.js} +1 -1
- package/dist/{chunk-II4ROT6X.js → chunk-QCKWQFCD.js} +1 -1
- package/dist/{chunk-4YICCES6.js → chunk-QFBVQUKV.js} +1 -1
- package/dist/{chunk-G4VMNWSU.js → chunk-QJCCZLOF.js} +1 -1
- package/dist/{chunk-A3JCETSF.js → chunk-QMPFNXI7.js} +1 -1
- package/dist/{chunk-CFBAGPB4.js → chunk-QPE6VCDW.js} +1 -1
- package/dist/chunk-RTDEFUTL.js +39 -0
- package/dist/{chunk-YMY6EFX4.js → chunk-RVKMGKYL.js} +1 -1
- package/dist/chunk-S4CWUZ4K.js +1 -0
- package/dist/{chunk-EEMRRCGR.js → chunk-SP5EHSWG.js} +1 -1
- package/dist/{chunk-CHMCKYJJ.js → chunk-U3MGJN7A.js} +1 -1
- package/dist/{chunk-WSDVFLHT.js → chunk-W6FHVXNL.js} +1 -1
- package/dist/{chunk-M2BK3XTP.js → chunk-WQX3JYEP.js} +1 -1
- package/dist/{chunk-AUCHMXUZ.js → chunk-WSRUPDZN.js} +1 -1
- package/dist/{chunk-6TNSCVR4.js → chunk-Y4B55J5S.js} +1 -1
- package/dist/{chunk-GVS5OFUB.js → chunk-YEEAWZWI.js} +1 -1
- package/dist/{chunk-I5PDN2P2.js → chunk-ZJCM37KX.js} +1 -1
- package/dist/{create-QIN56Y4M.js → create-HUEDWYDM.js} +1 -1
- package/dist/{doctor-RP4Q2CKJ.js → doctor-NAZEKMGU.js} +1 -1
- package/dist/goal-lifecycle-NUKWVUAL.js +1 -0
- package/dist/goal-pack-TWOXHXN6.js +1 -0
- package/dist/index.d.ts +8 -1
- package/dist/index.js +134 -132
- package/dist/{pipeline-77NUVYQD.js → pipeline-62A2SDLC.js} +1 -1
- package/dist/project-agent-entry-7SYHRY7J.js +1 -0
- package/dist/{project-intelligence-lens-AM2B2PXU.js → project-intelligence-lens-BSG5LK6N.js} +1 -1
- package/dist/{project-test-coverage-MUSS7Z7V.js → project-test-coverage-HP37HUV2.js} +1 -1
- package/dist/{verified-goal-ZSIZYNVO.js → verified-goal-B6HQOZWA.js} +1 -1
- package/dist/{workspace-LFESVKE7.js → workspace-BNRSBWSL.js} +1 -1
- package/dist/{workspace-agent-sync-JMRX6J2Y.js → workspace-agent-sync-ANBHBZ2H.js} +1 -1
- package/dist/{workspace-archive-MFHCFCDO.js → workspace-archive-ZBCKJHXS.js} +1 -1
- package/dist/{workspace-context-TBKRMVMT.js → workspace-context-RAO62QVU.js} +1 -1
- package/dist/{workspace-contract-KKVC2DUQ.js → workspace-contract-ACSIHJIO.js} +1 -1
- package/dist/workspace-explain-RH27OQB4.js +1 -0
- package/dist/workspace-explain-contract-ZL4NMLZI.js +1 -0
- package/dist/{workspace-feedback-O6J3RQML.js → workspace-feedback-RQ4TGJW6.js} +1 -1
- package/dist/{workspace-foundation-JQWT7YGC.js → workspace-foundation-EWYJPPT6.js} +1 -1
- package/dist/{workspace-graph-stream-V5WOXP4B.js → workspace-graph-stream-ZZZEQQTE.js} +1 -1
- package/dist/workspace-graph-token-efficiency-D7CUT6NX.js +1 -0
- package/dist/{workspace-history-TOCRMJUJ.js → workspace-history-SYCDK7FO.js} +1 -1
- package/dist/{workspace-intelligence-SDBIRKMK.js → workspace-intelligence-3YERTBA3.js} +1 -1
- package/dist/{workspace-intelligence-evaluation-E4UMWDAZ.js → workspace-intelligence-evaluation-CQDKOYZZ.js} +1 -1
- package/dist/{workspace-intelligence-runner-DIMNL6CJ.js → workspace-intelligence-runner-QLLBUD6G.js} +1 -1
- package/dist/{workspace-intelligence-runtime-registry-YGWB2RRS.js → workspace-intelligence-runtime-registry-IW6J53LO.js} +1 -1
- package/dist/{workspace-knowledge-graph-MUW6UAGI.js → workspace-knowledge-graph-HZZP6ZRB.js} +1 -1
- package/dist/{workspace-knowledge-graph-query-6DAOXGGT.js → workspace-knowledge-graph-query-ON45H6Y7.js} +1 -1
- package/dist/workspace-knowledge-graph-snapshot-7DWHMEM2.js +1 -0
- package/dist/{workspace-mcp-serve-2SWLIH4I.js → workspace-mcp-serve-5TTAN243.js} +1 -1
- package/dist/{workspace-model-VPFCKTYQ.js → workspace-model-EIQSKDX7.js} +1 -1
- package/dist/{workspace-onboarding-GHI6UTQJ.js → workspace-onboarding-UW3CSURE.js} +1 -1
- package/dist/{workspace-readme-RASXBZRQ.js → workspace-readme-56YZ4EAZ.js} +1 -1
- package/dist/{workspace-registry-summary-7QT7YMIU.js → workspace-registry-summary-OV5KX3WC.js} +1 -1
- package/dist/workspace-repair-engine-DHH2UUJN.js +3 -0
- package/dist/workspace-run-BLHRXT2N.js +1 -0
- package/dist/{workspace-verify-RYCQZYYB.js → workspace-verify-W4P6LBIH.js} +1 -1
- package/dist/{workspace-watch-U3YGN3GG.js → workspace-watch-EZ4D4VCF.js} +1 -1
- package/docs/GLOSSARY.md +13 -10
- package/docs/README.md +24 -19
- package/docs/README_CONTENT_CONTRACT.md +12 -8
- package/docs/agent-entry.md +194 -0
- package/docs/ci-workflows.md +18 -1
- package/docs/commands-reference.md +26 -2
- package/docs/contracts/ARTIFACT_CATALOG.md +9 -3
- package/docs/contracts/COMMAND_OWNERSHIP_MATRIX.md +3 -0
- package/docs/contracts/README.md +22 -2
- package/docs/goal-packs.md +70 -9
- package/docs/workspace-operations.md +16 -8
- package/docs/workspace-repair-engine.md +36 -5
- package/package.json +4 -2
- package/scripts/enterprise-package-smoke.mjs +4 -0
- package/dist/analyze-MAU36FTX.js +0 -1
- package/dist/autopilot-release-TA2L7SCB.js +0 -1
- package/dist/capabilities-command-HE2FICLG.js +0 -1
- package/dist/chunk-42Q5E2YV.js +0 -1
- package/dist/chunk-7IRGSM25.js +0 -1
- package/dist/chunk-CNWUIXF3.js +0 -1
- package/dist/chunk-FPJNWPKU.js +0 -1
- package/dist/chunk-HH54C3XJ.js +0 -1
- package/dist/chunk-NQ5H4R2I.js +0 -83
- package/dist/chunk-PCXBPQO6.js +0 -1
- package/dist/chunk-QXW3SLEX.js +0 -1
- package/dist/chunk-TMOKXYAQ.js +0 -2
- package/dist/chunk-VIFTO53Y.js +0 -1
- package/dist/chunk-ZDYGO3T7.js +0 -36
- package/dist/goal-lifecycle-YTBU3ICP.js +0 -1
- package/dist/goal-pack-MYYH7K43.js +0 -1
- package/dist/workspace-explain-RGGZL5IW.js +0 -1
- package/dist/workspace-explain-contract-4ZZ6CJ44.js +0 -1
- package/dist/workspace-graph-token-efficiency-TF23UYEF.js +0 -1
- package/dist/workspace-knowledge-graph-snapshot-7IU2QAXI.js +0 -1
- package/dist/workspace-repair-engine-AZTJIFCY.js +0 -3
- package/dist/workspace-run-VMZY6LIF.js +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {a as a$8}from'./chunk-
|
|
1
|
+
import {a as a$8}from'./chunk-HS3DJMU5.js';import {c,b,e as e$1,d as d$2}from'./chunk-J3X56S7L.js';import {b as b$1}from'./chunk-KVSYBHUR.js';import {d as d$4}from'./chunk-4PUJVYRM.js';import {f as f$1,e as e$3}from'./chunk-T3GJ7YVG.js';import {a as a$1,b as b$2}from'./chunk-QJCCZLOF.js';import {c as c$4,a as a$6,d as d$3,b as b$5}from'./chunk-HCFWT42C.js';import {a,c as c$5,h as h$1,g as g$1,k,f as f$3,d as d$6,e as e$4,i as i$2,j as j$4}from'./chunk-AO2ZI42U.js';import {j,g}from'./chunk-N4QQADXX.js';import {c as c$2}from'./chunk-NOZ4JCH7.js';import {b as b$3,c as c$3}from'./chunk-QFBVQUKV.js';import {b as b$4}from'./chunk-WSRUPDZN.js';import {a as a$4}from'./chunk-27UR373Z.js';import {a as a$2}from'./chunk-Y5YAP4F3.js';import {w}from'./chunk-WP3CXMVA.js';import {a as a$3}from'./chunk-T5YRFRJV.js';import {j as j$3,d as d$5,i as i$1,b as b$7,a as a$b}from'./chunk-ZCPT6KC3.js';import {a as a$a}from'./chunk-GR6442P7.js';import {d as d$1,e as e$2,f as f$2}from'./chunk-CCDGHPEJ.js';import {a as a$5}from'./chunk-AFIFZTOY.js';import {e,i,h}from'./chunk-NZ3WZYD5.js';import {f}from'./chunk-VRW6KXNK.js';import {a as a$9}from'./chunk-TQEMLBAG.js';import {s,j as j$1,t}from'./chunk-MOSXTVPU.js';import {c as c$1,j as j$2,b as b$6,t as t$1,n,p,m as m$1}from'./chunk-RJIYCDVC.js';import {a as a$7}from'./chunk-2FIX2MDC.js';import m from'chalk';import {createHash}from'crypto';import {execa}from'execa';import u from'fs-extra';import d from'path';import {existsSync}from'fs';var Mi=[".eslintrc.js",".eslintrc.cjs",".eslintrc.json",".eslintrc.yaml",".eslintrc.yml","eslint.config.js","eslint.config.mjs","eslint.config.cjs"],Ti=["tests","test","src/test","__tests__","e2e","playwright","cypress"],Oi=["vitest.config.ts","vitest.config.js","vitest.config.mjs","jest.config.js","jest.config.ts","jest.config.mjs","playwright.config.ts","playwright.config.js","cypress.config.js","cypress.config.ts"],_i=["src","app","pages"],Bi=["dev","build","test","lint"];function Kn(e){let t=e?.scripts;if(!t||typeof t!="object"||Array.isArray(t))return {};let i={};for(let[n,r]of Object.entries(t))typeof r=="string"&&r.trim().length>0&&(i[n]=r);return i}async function Wn(e,t){for(let r of Mi)if(await u.pathExists(d.join(e,r)))return true;let i=t??(await u.pathExists(d.join(e,"package.json"))?await u.readJson(d.join(e,"package.json")):null);if(!i)return false;if(i.eslintConfig)return true;let n={...i.dependencies??{},...i.devDependencies??{}};return !!(n.eslint||n["@eslint/js"]||n["@eslint/eslintrc"])}async function Gn(e,t){for(let r of Ti)if(await u.pathExists(d.join(e,r)))return true;for(let r of Oi)if(await u.pathExists(d.join(e,r)))return true;let i=Kn(t);if(i.test||i["test:unit"]||i["test:e2e"]||i["test:ci"]||i["test:watch"])return true;let n={...t?.dependencies??{},...t?.devDependencies??{}};return n.vitest||n.jest||n["@playwright/test"]||n.cypress?true:await Ki(e)}async function Ki(e){let t=["src","app","pages","components"],i=/\.(test|spec)\.(tsx?|jsx?|vue|svelte)$/i,r=new Set(["node_modules",".git","dist","build",".next","coverage",".turbo"]);for(let s of t){let a=d.join(e,s);if(!await u.pathExists(a))continue;let c=[{dir:a,depth:0}];for(;c.length>0;){let o=c.shift();if(!o)break;let l=[];try{l=await u.readdir(o.dir);}catch{continue}for(let p of l){let g=d.join(o.dir,p);if(i.test(p))return true;if(!(o.depth>=3||r.has(p)||p.startsWith(".")))try{(await u.stat(g)).isDirectory()&&c.push({dir:g,depth:o.depth+1});}catch{continue}}}}return false}async function Gt(e){for(let t of _i){let i=d.join(e,t);if(await u.pathExists(i))try{if((await u.readdir(i)).some(r=>!r.startsWith(".")))return true}catch{continue}}return false}function Wi(e){let t=e.key;return b$7(t).key}function Gi(e,t,i){return a$b(t,i).some(r=>!!e[r])}async function Ln(e){let{projectPath:t,detection:i,packageJsonData:n}=e,r=Wi(i),s=b$7(r),a=Kn(n),c=[],o=await u.pathExists(d.join(t,"package-lock.json"))||await u.pathExists(d.join(t,"pnpm-lock.yaml"))||await u.pathExists(d.join(t,"yarn.lock"))||await u.pathExists(d.join(t,"bun.lockb"));c.push({id:"frontend-lockfile-integrity",label:"Frontend lockfile integrity",status:o?"pass":"warn",severity:"warn",scope:"project-scoped",reason:o?"Node lockfile detected for deterministic dependency restore.":"No Node lockfile detected (package-lock/yarn.lock/pnpm-lock.yaml/bun.lockb).",recommendation:o?void 0:"Commit a lockfile for deterministic installs and CI parity."});let l=await u.pathExists(d.join(t,"tsconfig.json")),p=await u.pathExists(d.join(t,"jsconfig.json")),g=l||p;c.push({id:"frontend-typescript-surface",label:"TypeScript project surface",status:g?"pass":"warn",severity:"warn",scope:"project-scoped",reason:g?l?"tsconfig.json detected.":"jsconfig.json detected.":"No tsconfig.json or jsconfig.json detected.",recommendation:g?void 0:"Add tsconfig.json (or jsconfig.json) for typed frontend builds and IDE parity."});let y=s.fileHints.length>0&&s.fileHints.some(b=>existsSync(d.join(t,b)));c.push({id:"frontend-framework-config",label:`${s.displayName} config surface`,status:y?"pass":"warn",severity:"warn",scope:"project-scoped",reason:y?`${s.displayName} configuration artifacts detected.`:`No ${s.displayName} config markers detected (${s.fileHints.join(", ")||"n/a"}).`,recommendation:y?void 0:"Keep framework config files in-repo for reproducible dev/build behavior."});for(let b of Bi){let w=Gi(a,r,b),h=b==="dev"||b==="build",j=!w&&b==="test"?h$1({projectPath:t,frameworkDisplayName:s.displayName,scriptName:b,scriptValue:g$1(a)}):void 0;c.push({id:`frontend-script-${b}`,label:`${b} script surface`,status:w?"pass":h?"fail":"warn",severity:h?"error":"warn",scope:"project-scoped",reason:w?`package.json exposes a ${b} script for ${s.displayName}.`:`No ${b} script detected for ${s.displayName}.`,recommendation:w?void 0:`Add a "${a$b(r,b)[0]??b}" script to package.json.`,repairCapability:j});}let k=await Gt(t);return c.push({id:"frontend-source-tree",label:"Frontend source tree",status:k?"pass":"warn",severity:"warn",scope:"project-scoped",reason:k?"Application source directories detected (src/app/pages).":"No frontend source directories detected under src/, app/, or pages/.",recommendation:k?void 0:"Ensure the scaffolded application tree exists before running lifecycle commands."}),c}var Li=["python","node","go","java","rust","elixir","clojure","deno","bun","php","ruby","dotnet","scala","kotlin","c","cpp","unknown"],Hn={node:["package-lock.json","pnpm-lock.yaml","yarn.lock","bun.lock","bun.lockb"],deno:["deno.lock"],bun:["bun.lock","bun.lockb"],python:["uv.lock","poetry.lock","requirements.txt","requirements.lock"],go:["go.sum"],java:["gradle.lockfile","gradle/libs.versions.toml"],rust:["Cargo.lock"],elixir:["mix.lock"],clojure:["deps.edn","project.clj"],php:["composer.lock"],ruby:["Gemfile.lock"],dotnet:["packages.lock.json","Directory.Packages.props"],scala:["project/build.properties","project/plugins.sbt"],kotlin:["gradle.lockfile","gradle/libs.versions.toml"],c:["conan.lock","vcpkg-lock.json","MODULE.bazel.lock","requirements.bazel.lock"],cpp:["conan.lock","vcpkg-lock.json","MODULE.bazel.lock","requirements.bazel.lock"],unknown:[]},qn={node:["package.json"],deno:["deno.json","deno.jsonc"],bun:["package.json","bunfig.toml"],python:["pyproject.toml","requirements.txt","setup.py"],go:["go.mod"],java:["pom.xml","build.gradle","build.gradle.kts"],rust:["Cargo.toml"],elixir:["mix.exs"],clojure:["deps.edn","project.clj"],php:["composer.json"],ruby:["Gemfile"],dotnet:["*.csproj","*.sln"],scala:["build.sbt"],kotlin:["build.gradle","build.gradle.kts","pom.xml"],c:["CMakeLists.txt","meson.build","Makefile","MODULE.bazel","WORKSPACE"],cpp:["CMakeLists.txt","meson.build","Makefile","MODULE.bazel","WORKSPACE"],unknown:[]},Hi=["node_modules",".git",".workspai/reports",".venv","dist","build","coverage",".env",".env.*","!.env.example"].join(`
|
|
2
2
|
`),Lt=[".env",".env.*","!.env.example"];function Me(e){return e&&Li.includes(e)?e:"unknown"}async function Ne(e,t){for(let i of t){if(i.includes("*")){let n=i.replace("*","");if(await qi(e,n,2))return true;continue}if(await u.pathExists(d.join(e,i)))return true}return false}async function qi(e,t,i){let n=[{dir:e,depth:0}],r=new Set(["node_modules",".git",".workspai",".rapidkit","dist","build","coverage"]);for(;n.length>0;){let s=n.shift();if(!s)break;let a=[];try{a=await u.readdir(s.dir,{withFileTypes:true});}catch{continue}for(let c of a){if(r.has(c.name))continue;let o=d.join(s.dir,c.name);if(c.isFile()&&c.name.endsWith(t))return true;c.isDirectory()&&s.depth<i&&!c.name.startsWith(".")&&n.push({dir:o,depth:s.depth+1});}}return false}async function Ze(e){try{return await u.pathExists(e)?await u.readFile(e,"utf8"):""}catch{return ""}}async function kt(e,t){let i=[];for(let n of t){let r=await Ze(d.join(e,n));r&&i.push(r);}return i.join(`
|
|
3
3
|
`)}var Vi=new Set([".c",".cc",".clj",".cljs",".cpp",".cs",".ex",".exs",".go",".h",".hpp",".java",".js",".jsx",".kt",".kts",".mjs",".cjs",".php",".py",".rb",".rs",".scala",".svelte",".ts",".tsx",".vue"]),Ji=[/\bprocess\.env(?:\.([A-Z][A-Z0-9_]*)|\[['"]([A-Z][A-Z0-9_]*)['"]\])/g,/\bimport\.meta\.env\.([A-Z][A-Z0-9_]*)/g,/\b(?:Deno\.env\.get|os\.getenv|os\.Getenv|os\.LookupEnv|System\.getenv|std::env::var|env!|option_env!|getenv|Environment\.GetEnvironmentVariable)\(\s*['"]([A-Z][A-Z0-9_]*)['"]/g,/\bos\.environ(?:\.get\(\s*['"]([A-Z][A-Z0-9_]*)['"]|\[\s*['"]([A-Z][A-Z0-9_]*)['"]\s*\])/g,/\bENV(?:\.fetch\(\s*['"]([A-Z][A-Z0-9_]*)['"]|\[\s*['"]([A-Z][A-Z0-9_]*)['"]\s*\])/g,/\$_ENV\[\s*['"]([A-Z][A-Z0-9_]*)['"]\s*\]/g,/@Value\(\s*['"]\$\{([A-Z][A-Z0-9_]*)(?::[^}]*)?\}['"]\s*\)/g];async function zi(e){let t=new Set,i=new Set([".git",".next",".nuxt",".output",".rapidkit",".svelte-kit",".venv",".workspai","build","coverage","dist","node_modules","target","vendor"]),n=[{dir:e,depth:0}],r=0;for(;n.length>0&&r<300;){let a=n.shift();if(!a)break;let c=[];try{c=await u.readdir(a.dir,{withFileTypes:true});}catch{continue}for(let o of c){if(i.has(o.name))continue;let l=d.join(a.dir,o.name);if(o.isDirectory()){a.depth<6&&!o.name.startsWith(".")&&n.push({dir:l,depth:a.depth+1});continue}if(!o.isFile()||!Vi.has(d.extname(o.name).toLowerCase()))continue;r+=1;let p="";try{if((await u.stat(l)).size>512*1024)continue;p=await u.readFile(l,"utf8");}catch{continue}for(let g of Ji){g.lastIndex=0;for(let y of p.matchAll(g)){let k=y.slice(1).find(b=>typeof b=="string"&&b.length>0);k&&t.add(k);}}}}let s=await Ze(d.join(e,".env"));for(let a of s.split(/\r?\n/)){let c=a.match(/^\s*(?:export\s+)?([A-Z][A-Z0-9_]*)\s*=/);c?.[1]&&t.add(c[1]);}return [...t].sort((a,c)=>a.localeCompare(c))}async function Ui(e){if(e.runtime==="node"){let t=typeof e.packageJsonData?.packageManager=="string"?e.packageJsonData.packageManager.split("@")[0]:null;return {command:t==="pnpm"?"pnpm install":t==="yarn"?"yarn install":t==="bun"?"bun install":"npm install",title:"Generate Node dependency lockfile",files:["package.json","package-lock.json","pnpm-lock.yaml","yarn.lock","bun.lock"],limitations:["Review dependency and lockfile changes before committing."]}}if(e.runtime==="go"&&await u.pathExists(d.join(e.projectPath,"go.mod")))return {command:"go mod tidy",title:"Reconcile Go module graph",files:["go.mod","go.sum"],limitations:["Review go.mod/go.sum changes before committing."]};if(e.runtime==="java"){let t=await u.pathExists(d.join(e.projectPath,"pom.xml")),i=await u.pathExists(d.join(e.projectPath,"mvnw"))||await u.pathExists(d.join(e.projectPath,"mvnw.cmd")),n=await u.pathExists(d.join(e.projectPath,"gradlew"))||await u.pathExists(d.join(e.projectPath,"gradlew.bat"));return {command:t?i?process.platform==="win32"?".\\mvnw.cmd -B -DskipTests -Dmaven.repo.local=.workspai/cache/java/m2 dependency:go-offline":"./mvnw -B -DskipTests -Dmaven.repo.local=.workspai/cache/java/m2 dependency:go-offline":"mvn -B -DskipTests -Dmaven.repo.local=.workspai/cache/java/m2 dependency:go-offline":n?process.platform==="win32"?".\\gradlew.bat --project-cache-dir .workspai/cache/java/gradle dependencies":"./gradlew --project-cache-dir .workspai/cache/java/gradle dependencies":"gradle --project-cache-dir .workspai/cache/java/gradle dependencies",title:"Prepare Java dependency baseline",files:["pom.xml","build.gradle","build.gradle.kts","gradle.lockfile"],limitations:["Review resolved dependency and lockfile changes before committing."]}}if(e.runtime==="scala")return {command:"sbt update",title:"Prepare Scala dependency baseline",files:["build.sbt","project/build.properties","project/plugins.sbt"],limitations:["Review resolved dependency and plugin changes before committing."]};if(e.runtime==="kotlin")return {command:process.platform==="win32"?".\\gradlew.bat dependencies":"./gradlew dependencies",title:"Prepare Kotlin dependency baseline",files:["build.gradle","build.gradle.kts","gradle.lockfile"],limitations:["Review resolved dependency and lockfile changes before committing."]};if(e.runtime==="rust")return {command:"cargo fetch",title:"Generate Rust dependency baseline",files:["Cargo.toml","Cargo.lock"],limitations:["Review Cargo.lock changes before committing."]};if(e.runtime==="php")return {command:"composer install",title:"Generate Composer lockfile",files:["composer.json","composer.lock"],limitations:["Review composer.lock changes before committing."]};if(e.runtime==="ruby")return {command:"bundle install",title:"Generate Bundler lockfile",files:["Gemfile","Gemfile.lock"],limitations:["Review Gemfile.lock changes before committing."]};if(e.runtime==="dotnet")return {command:"dotnet restore",title:".NET dependency restore",files:["*.sln","*.csproj","packages.lock.json","Directory.Packages.props"],limitations:["Enable NuGet lock files in the project when release policy requires deterministic restore."]};if(e.runtime==="elixir")return {command:"mix deps.get",title:"Generate Elixir dependency lockfile",files:["mix.exs","mix.lock"],limitations:["Review mix.lock changes before committing."]};if(e.runtime==="clojure")return {command:"clojure -P",title:"Prepare Clojure dependency baseline",files:["deps.edn","project.clj"],limitations:["Review dependency cache and CI restore policy before release."]};if(e.runtime==="python"){let t=await Ze(d.join(e.projectPath,"pyproject.toml"));if(/\[tool\.poetry\]/.test(t))return {command:"poetry install --no-root",title:"Install Poetry dependency baseline",files:["pyproject.toml","poetry.lock"],limitations:["Review poetry.lock changes before committing when Poetry resolves or updates the lockfile."]};if(/\[tool\.uv\]|\[project\]/.test(t))return {command:"uv lock",title:"Generate uv lockfile",files:["pyproject.toml","uv.lock"],limitations:["Review uv.lock changes before committing."]}}return null}function Ye(e){let t=e?.scripts;if(!t||typeof t!="object"||Array.isArray(t))return {};let i={};for(let[n,r]of Object.entries(t))typeof r=="string"&&r.trim().length>0&&(i[n]=r);return i}function Zi(e){if(e.runtime==="node"){let i=Ye(e.packageJsonData);if(!e.packageJsonData)return null;if(e.kind==="test"){let n=i.lint?"npm run lint":i.build?"npm run build":null;return n?{command:n,title:"Define Node test script",targetName:"test",files:["package.json"],limitations:["Replace this fallback with real tests when product coverage is required."]}:null}return e.kind==="security"?{command:"npm audit --audit-level=moderate",title:"Define Node security audit script",targetName:"audit",files:["package.json"]}:null}return {deno:{test:{command:"deno test --allow-none",title:"Define Deno test command",targetName:"test",files:["Makefile","deno.json","deno.jsonc"]},quality:{command:"deno fmt --check && deno lint",title:"Define Deno quality command",targetName:"quality",files:["Makefile","deno.json","deno.jsonc"]},security:{command:"deno info --json",title:"Define Deno dependency inspection command",targetName:"security",files:["Makefile","deno.json","deno.jsonc","deno.lock"],limitations:["Pair dependency inspection with the organization vulnerability service used by CI."]}},bun:{test:{command:"bun test",title:"Define Bun test script",targetName:"test",files:["package.json","bun.lock","bun.lockb"]},quality:{command:"bunx eslint .",title:"Define Bun quality script",targetName:"quality",files:["package.json"],limitations:["Ensure ESLint is declared before enforcing this command in CI."]},security:{command:"bun audit",title:"Define Bun security audit script",targetName:"audit",files:["package.json","bun.lock","bun.lockb"]}},python:{test:{command:"python -m pytest",title:"Define Python test command",targetName:"test",files:["Makefile","pyproject.toml"]},quality:{command:"python -m ruff check .",title:"Define Python quality command",targetName:"quality",files:["Makefile","pyproject.toml"],limitations:["Ensure ruff is declared in project dev dependencies before enforcing in CI."]},security:{command:"python -m pip_audit",title:"Define Python security audit command",targetName:"security",files:["Makefile","pyproject.toml"],limitations:["Ensure pip-audit is available in the project toolchain before enforcing in CI."]}},go:{test:{command:"go test ./...",title:"Define Go test command",targetName:"test",files:["Makefile","go.mod"]},quality:{command:"gofmt -w .",title:"Define Go formatting command",targetName:"quality",files:["Makefile","go.mod"],limitations:["Use CI-specific check mode if formatting should not mutate files in pipelines."]},security:{command:"govulncheck ./...",title:"Define Go vulnerability scan command",targetName:"security",files:["Makefile","go.mod"],limitations:["Ensure govulncheck is installed or provisioned by CI before enforcing."]}},rust:{test:{command:"cargo test",title:"Define Rust test command",targetName:"test",files:["Makefile","Cargo.toml"]},quality:{command:"cargo fmt -- --check && cargo clippy --all-targets -- -D warnings",title:"Define Rust quality command",targetName:"quality",files:["Makefile","Cargo.toml"]},security:{command:"cargo audit",title:"Define Rust security audit command",targetName:"security",files:["Makefile","Cargo.toml"],limitations:["Ensure cargo-audit is installed or provisioned by CI before enforcing."]}},php:{test:{command:"vendor/bin/phpunit",title:"Define PHP test command",targetName:"test",files:["Makefile","composer.json"]},quality:{command:"vendor/bin/phpstan analyse",title:"Define PHP static analysis command",targetName:"quality",files:["Makefile","composer.json"],limitations:["Ensure phpstan is declared in require-dev before enforcing in CI."]},security:{command:"composer audit",title:"Define Composer security audit command",targetName:"security",files:["Makefile","composer.json"]}},ruby:{test:{command:"bundle exec rspec",title:"Define Ruby test command",targetName:"test",files:["Makefile","Gemfile"],limitations:["Use bundle exec ruby -Itest when the project uses minitest instead of RSpec."]},quality:{command:"bundle exec rubocop",title:"Define Ruby quality command",targetName:"quality",files:["Makefile","Gemfile"]},security:{command:"bundle exec bundler-audit check",title:"Define Ruby security audit command",targetName:"security",files:["Makefile","Gemfile"],limitations:["Ensure bundler-audit is installed or provisioned by CI before enforcing."]}},dotnet:{test:{command:"dotnet test",title:"Define .NET test command",targetName:"test",files:["Makefile","*.sln","*.csproj"]},quality:{command:"dotnet format --verify-no-changes",title:"Define .NET formatting gate",targetName:"quality",files:["Makefile","*.sln","*.csproj"]},security:{command:"dotnet list package --vulnerable",title:"Define .NET package vulnerability check",targetName:"security",files:["Makefile","*.sln","*.csproj"]}},java:{test:{command:"mvn test",title:"Define Java test command",targetName:"test",files:["Makefile","pom.xml","build.gradle","build.gradle.kts"],limitations:["Use ./gradlew test when the project is Gradle-first."]},quality:{command:"mvn verify",title:"Define Java verification command",targetName:"quality",files:["Makefile","pom.xml","build.gradle","build.gradle.kts"],limitations:["Use ./gradlew check when the project is Gradle-first."]},security:{command:"mvn org.owasp:dependency-check-maven:check",title:"Define Java dependency vulnerability check",targetName:"security",files:["Makefile","pom.xml"],limitations:["Review OWASP dependency-check policy and cache behavior before enforcing in CI."]}},elixir:{test:{command:"mix test",title:"Define Elixir test command",targetName:"test",files:["Makefile","mix.exs"]},quality:{command:"mix format --check-formatted && mix credo --strict",title:"Define Elixir quality command",targetName:"quality",files:["Makefile","mix.exs",".formatter.exs","credo.exs"],limitations:["Ensure Credo is declared before enforcing the strict quality command."]},security:{command:"mix hex.audit",title:"Define Hex dependency audit command",targetName:"security",files:["Makefile","mix.exs","mix.lock"]}},clojure:{test:{command:"clojure -M:test",title:"Define Clojure test command",targetName:"test",files:["Makefile","deps.edn","project.clj"],limitations:["Align the alias with the test runner declared by the project."]},quality:{command:"clj-kondo --lint src test",title:"Define Clojure quality command",targetName:"quality",files:["Makefile","deps.edn","project.clj"],limitations:["Ensure clj-kondo is provisioned before enforcing this command in CI."]},security:{command:"clojure -Stree",title:"Define Clojure dependency inspection command",targetName:"security",files:["Makefile","deps.edn","project.clj"],limitations:["Pair dependency-tree inspection with the vulnerability scanner selected by the organization."]}},scala:{test:{command:"sbt test",title:"Define Scala test command",targetName:"test",files:["Makefile","build.sbt"]},quality:{command:"sbt scalafmtCheckAll scalafixAll",title:"Define Scala quality command",targetName:"quality",files:["Makefile","build.sbt",".scalafmt.conf"],limitations:["Declare Scalafmt and Scalafix plugins before enforcing this command."]},security:{command:"sbt dependencyTree",title:"Define Scala dependency inspection command",targetName:"security",files:["Makefile","build.sbt"],limitations:["Pair dependency inspection with the organization vulnerability scanner."]}},kotlin:{test:{command:"./gradlew test",title:"Define Kotlin test command",targetName:"test",files:["Makefile","build.gradle","build.gradle.kts"]},quality:{command:"./gradlew check",title:"Define Kotlin quality command",targetName:"quality",files:["Makefile","build.gradle","build.gradle.kts"]},security:{command:"./gradlew dependencies",title:"Define Kotlin dependency inspection command",targetName:"security",files:["Makefile","build.gradle","build.gradle.kts"],limitations:["Pair dependency inspection with the organization vulnerability scanner."]}},c:{test:{command:"ctest --test-dir build --output-on-failure",title:"Define C test command",targetName:"test",files:["Makefile","CMakeLists.txt"]},quality:{command:"clang-tidy src/**/*.c --",title:"Define C quality command",targetName:"quality",files:["Makefile","CMakeLists.txt",".clang-tidy"],limitations:["Align source globs and compile database with the project build."]},security:{command:"cmake --build build --target sbom",title:"Define C dependency evidence command",targetName:"security",files:["Makefile","CMakeLists.txt"],limitations:["Declare the SBOM target or replace it with the organization scanner."]}},cpp:{test:{command:"ctest --test-dir build --output-on-failure",title:"Define C++ test command",targetName:"test",files:["Makefile","CMakeLists.txt"]},quality:{command:"clang-tidy src/**/*.cpp --",title:"Define C++ quality command",targetName:"quality",files:["Makefile","CMakeLists.txt",".clang-tidy"],limitations:["Align source globs and compile database with the project build."]},security:{command:"cmake --build build --target sbom",title:"Define C++ dependency evidence command",targetName:"security",files:["Makefile","CMakeLists.txt"],limitations:["Declare the SBOM target or replace it with the organization scanner."]}}}[e.runtime]?.[e.kind]??null}async function Yi(e){return j$4({issueId:e.issueId,title:e.contract.title,projectPath:e.projectPath,targetName:e.contract.targetName,command:e.contract.command,reason:e.reason,risk:"guarded",requiresReview:true,limitations:e.contract.limitations})}async function Ht(e){let t=Zi({runtime:e.runtime,kind:e.kind,packageJsonData:e.packageJsonData});if(t)return (e.runtime==="node"||e.runtime==="bun")&&e.packageJsonData?i$2({issueId:e.issueId,title:t.title,projectPath:e.projectPath,scriptName:t.targetName,scriptValue:t.command,reason:e.reason,risk:"guarded",limitations:t.limitations}):Yi({issueId:e.issueId,projectPath:e.projectPath,contract:t,reason:e.reason})}function De(e){return {id:`${e.issueId}.manual`,issueId:e.issueId,title:e.title,status:"manual",fixKind:"manual",risk:"guarded",canAutoFix:false,canEditFiles:false,requiresApproval:true,requiresReview:true,files:e.files.map(t=>d.join(e.projectPath,t)),refreshCommands:["npx workspai doctor project --json","npx workspai workspace verify --json"],reason:e.reason,limitations:e.limitations}}function Xi(e){return d$6({issueId:"surface-dockerignore",title:"Create .dockerignore",projectPath:e,relativePath:".dockerignore",content:`${Hi}
|
|
4
4
|
`,reason:"Create a Docker build ignore baseline to keep secrets, dependencies, and reports out of container contexts."})}async function Qi(e){if(!await u.pathExists(d.join(e,".gitignore")))return d$6({issueId:"surface-security-hygiene",title:"Create .gitignore secret baseline",projectPath:e,relativePath:".gitignore",content:`${Lt.join(`
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import {g,b,i as i$1,d as d$2,e as e$1,f}from'./chunk-MZKKRAAJ.js';import {c}from'./chunk-GPOZILMY.js';import {c as c$1}from'./chunk-X7FYEKLI.js';import {d as d$3,b as b$1,a as a$1}from'./chunk-3RBUSW7H.js';import {d as d$1}from'./chunk-EWZZUQBR.js';import {a}from'./chunk-AFIFZTOY.js';import {h,e,i}from'./chunk-NZ3WZYD5.js';import {t,h as h$1,g as g$1}from'./chunk-MOSXTVPU.js';import le from'crypto';import H from'fs';import k from'fs/promises';import d from'path';import {execa}from'execa';import he from'fs-extra';var ke=h.projectContextAgent.schemaVersion,Ze=["managed","local","off"],de="<!-- WORKSPAI:PROJECT-GROUNDING:START -->",pe="<!-- WORKSPAI:PROJECT-GROUNDING:END -->";function oe(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:null}async function E(e){try{return JSON.parse(await k.readFile(e,"utf8"))}catch(t){return null}}function G(e){return e.replace(/\\/g,"/").replace(/^\.\/+/,"")}function x(e,t,n){let o=e.replace(/\\/g,"/"),i=/^[A-Za-z]:\//.test(o);if(!d.isAbsolute(e)&&!i)return G(o);if(i&&process.platform!=="win32")return null;let c=d.resolve(e),s=d.relative(n,c);if(s&&!s.startsWith("..")&&!d.isAbsolute(s))return G(s);let l=d.relative(t,c);return l&&!l.startsWith("..")&&!d.isAbsolute(l)?`workspace:${G(l)}`:null}function P(e,t,n){return [[n,"project:"],[n.replace(/\\/g,"/"),"project:"],[t,"workspace:"],[t.replace(/\\/g,"/"),"workspace:"]].reduce((i,[c,s])=>c.length>0?i.split(c).join(s):i,e)}function ge(e,t){return oe(e?.adoption)?.mode==="linked"?"adopted":oe(e?.import)?"imported":t}function we(e){if(!e.model)return null;let t=G(e.relativePath);return e.model.projects.find(n=>n.name===e.projectName||G(n.path)===t)??null}function ne(e,t){e[t]=(e[t]??0)+1;}var ye=["project","language","service","api","endpoint","schema","protocol","runtime-unit","lifecycle-stage","database","queue","container","deployment","pipeline","environment","test-suite","owner","decision","document","package","file","module","symbol"];function je(e,t=160){let n={language:32,api:32,service:32,endpoint:32,schema:32,protocol:32,"runtime-unit":32,"lifecycle-stage":32,file:8,module:8,symbol:8},o=[];for(let i of ye){let c=e.filter(s=>s.kind===i).sort((s,l)=>s.label.localeCompare(l.label)||s.id.localeCompare(l.id)).slice(0,n[i]??32);for(let s of c){if(o.length>=t)return o;o.push(s);}}return o}function Pe(e,t){if(!e)return {entityCount:0,relationCount:0,proofCount:0,entitiesByKind:{},relationsByKind:{},languages:{},semantic:{protocolConceptCount:0,protocolImplementationBindings:0,equivalenceBindings:0,generationBindings:0,runtimeUnitCount:0,lifecycleStageCount:0,runtimeCoverage:[]},relatedProjects:[],proofArtifacts:[],entities:[],relations:[],proofs:[],topology:{status:"unavailable",dependencies:[],dependents:[]},diagnostics:[]};let n=e.entities.find(r=>r.kind==="project"&&(r.id===t||r.label===t||r.projectId===t)),o=new Set(e.entities.filter(r=>r.projectId===t||r.id===n?.id||r.kind==="project"&&r.label===t).map(r=>r.id));n&&o.add(n.id);let i=e.relations.filter(r=>o.has(r.from)||o.has(r.to)),c=new Set(o);for(let r of i)c.add(r.from),c.add(r.to);let s=e.entities.filter(r=>c.has(r.id)),l=new Set,g={},u={},f={},w=new Set(s.filter(r=>r.kind==="language").map(r=>r.attributes.language).filter(r=>typeof r=="string"));for(let r of s){ne(g,r.kind);let a=typeof r.attributes.language=="string"?r.attributes.language:void 0;if(a&&r.kind==="language")f[a]={fileCount:typeof r.attributes.fileCount=="number"?r.attributes.fileCount:0,symbolCount:f[a]?.symbolCount??0,generatedFileCount:typeof r.attributes.generatedFileCount=="number"?r.attributes.generatedFileCount:0};else if(a&&(r.kind==="file"||r.kind==="symbol")){let h=f[a]??{fileCount:0,symbolCount:0,generatedFileCount:0};r.kind==="file"&&!w.has(a)?(h.fileCount+=1,r.attributes.generated===true&&(h.generatedFileCount+=1)):r.kind==="symbol"&&(h.symbolCount+=1),f[a]=h;}for(let h of r.proofIds)l.add(h);}for(let r of i){ne(u,r.kind);for(let a of r.proofIds)l.add(a);}let y=e.proofs.filter(r=>l.has(r.id)),b=[...new Set(e.entities.filter(r=>c.has(r.id)&&r.projectId&&r.projectId!==t).map(r=>r.projectId))].sort(),m=e.diagnostics.filter(r=>r.entityIds?.some(a=>c.has(a))||r.relationIds?.some(a=>i.some(h=>h.id===a))).map(r=>({code:r.code,severity:r.severity,message:r.message,...r.recommendation?{recommendation:r.recommendation}:{}})),p=(r,a)=>({project:a,kind:r.kind,source:r.source,confidence:r.confidence,evidence:[...new Set(r.evidence.map(h=>h.file.replace(/\\/g,"/")))].sort()}),v=e.projectTopology.edges.filter(r=>r.from===t).map(r=>p(r,r.to)).sort((r,a)=>`${r.project}:${r.kind}`.localeCompare(`${a.project}:${a.kind}`)),C=e.projectTopology.edges.filter(r=>r.to===t).map(r=>p(r,r.from)).sort((r,a)=>`${r.project}:${r.kind}`.localeCompare(`${a.project}:${a.kind}`)),R=je(s),N=s.filter(r=>r.kind==="runtime-unit"),j=new Set(R.map(r=>r.id)),_=[...i].sort((r,a)=>{let h=Number(j.has(r.from)||j.has(r.to));return Number(j.has(a.from)||j.has(a.to))-h||r.id.localeCompare(a.id)}).slice(0,128),$=new Set([...R.flatMap(r=>r.proofIds),..._.flatMap(r=>r.proofIds)]);return {entityCount:s.length,relationCount:i.length,proofCount:y.length,entitiesByKind:g,relationsByKind:u,languages:Object.fromEntries(Object.entries(f).sort(([r],[a])=>r.localeCompare(a))),semantic:{protocolConceptCount:g.protocol??0,protocolImplementationBindings:u["implements-protocol"]??0,equivalenceBindings:u["equivalent-to"]??0,generationBindings:(u["generated-from"]??0)+(u["generated-by"]??0),runtimeUnitCount:N.length,lifecycleStageCount:g["lifecycle-stage"]??0,runtimeCoverage:[...new Set(N.map(r=>r.attributes.runtime).filter(r=>typeof r=="string"))].sort()},relatedProjects:b,proofArtifacts:[...new Set(y.map(r=>r.artifact))].sort(),entities:R,relations:_,proofs:y.filter(r=>$.has(r.id)).sort((r,a)=>r.id.localeCompare(a.id)).slice(0,128),topology:{status:v.length>0||C.length>0?"proven":e.projectTopology.nodes.some(r=>r.id===t)?"unproven":"unavailable",dependencies:v,dependents:C},diagnostics:m}}function ue(e,t,n){return Array.isArray(e)?e.map(o=>typeof o=="string"?P(o,t,n):o):typeof e=="string"?P(e,t,n):e}function be(e,t,n){return {id:e.id,kind:e.kind,label:P(e.label,t,n),attributes:Object.fromEntries(Object.entries(e.attributes).map(([o,i])=>[o,ue(i,t,n)])),proofIds:[...e.proofIds].sort()}}function ve(e,t,n){let o=(...c)=>e.filter(s=>c.includes(s.kind)).map(s=>be(s,t,n)).slice(0,32),i=[];for(let c of e){for(let[s,l]of Object.entries(c.attributes))if(/(?:^|[-_.])ports?(?:$|[-_.])/i.test(s)&&(i.push({entityId:c.id,label:P(c.label,t,n),attribute:s,value:ue(l,t,n)}),i.length>=32))break;if(i.length>=32)break}return {services:o("service"),packages:o("package"),protocols:o("protocol"),runtimeUnits:o("runtime-unit"),lifecycleStages:o("lifecycle-stage"),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:i}}function Ae(e,t,n){let o=x(e.artifact,t,n);return o?{id:e.id,provider:e.provider,artifact:o,...e.pointer?{pointer:P(e.pointer,t,n)}:{},...e.line!==void 0?{line:e.line}:{},derivation:e.derivation,trust:e.trust,confidence:e.confidence,freshness:e.freshness}:null}async function Ee(e,t,n){let o=[],i=await E(d.join(e,".workspai","reports","INDEX.json"));if(Array.isArray(i?.blockers))for(let s of i.blockers)typeof s=="string"&&(s.startsWith(`${n}:`)||s.includes(`project:${n}`)||s.includes(`project ${n}`))&&o.push({source:"workspace-report-index",severity:"error",message:P(s,e,t)});let c=await E(d.join(e,".workspai","reports","doctor-project-last-run.json"));if(c?.projectName===n)for(let s of c$1({project:c.project}))o.push({source:"doctor-project",severity:s.status==="blocking"?"error":"warning",message:P(s.message,e,t),...s.id?{code:s.id}:{}});return [...new Map(o.map(s=>[`${s.source}:${s.code??""}:${s.message}`,s])).values()].slice(0,32)}function U(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(n=>n.length>0&&(e.includes(n)||e.includes(n.replace(/\\/g,"/")))):Array.isArray(e)?e.some(n=>U(n,t)):e&&typeof e=="object"?Object.values(e).some(n=>U(n,t)):false}function Ce(e){return le.createHash("sha256").update(JSON.stringify(e)).digest("hex")}async function Re(e$1){let t$1=d.resolve(e$1.workspacePath),n=d.resolve(e$1.projectPath),o=t(n,"project.json").find(a=>H.existsSync(a)),i$1=o?await E(o):null,c=await E(d.join(t$1,".workspai","workspace.contract.json")),s=d.resolve(n),l=c?.projects?.find(a=>a.externalPath?d.resolve(a.externalPath)===s:!a.relativePath||a.relativePath.startsWith("external/")?false:d.resolve(t$1,a.relativePath)===s)??c?.projects?.find(a=>a.slug===e$1.projectName||a.slug===d.basename(n)),g=e$1.projectName??(typeof i$1?.name=="string"?i$1.name:void 0)??l?.slug??d.basename(n),u=l?.relativePath??(()=>{let a=G(d.relative(t$1,n));return !a||a.startsWith("..")?`external/${g}`:a})(),f=await E(d.join(t$1,e.model)),w=await E(d.join(t$1,e.knowledgeGraph)),y=f?d$1(f):void 0,b$1=!!(y&&w?.source.hash===y),m=we({model:f,projectName:g,relativePath:u}),p=Pe(b$1?w:null,g),v=await Ee(t$1,n,g),C=p.proofs.map(a=>a.freshness),R=w?!b$1||C.includes("stale")?"stale":C.includes("unknown")?"unknown":"fresh":"missing",N=f?f.factFreshness?.status??"unknown":"missing",j=[...f?[]:[{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."}],...f&&!m?[{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."}]:[],...w?[]:[{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."}],...w&&!b$1?[{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."}]:[]],_=ge(i$1,e$1.relationship??l?.relationship??"managed"),$={schemaVersion:ke,generatedAt:(e$1.now??new Date).toISOString(),workspace:{name:c?.workspace?.name??f?.workspace.name??d.basename(t$1),...c?.workspace?.profile||f?.workspace.profile?{profile:c?.workspace?.profile??f?.workspace.profile}:{},relationship:_,contract:`workspace:${i.workspaceContract}`,model:`workspace:${e.model}`,knowledgeGraph:`workspace:${e.knowledgeGraph}`,access:{localBinding:i.projectWorkspaceLink,canonicalEvidenceAvailableAtGeneration:true,identityIsFilesystemPath:false,resolverCommand:"workspai project workspace status --json",portableUriScheme:"workspace:",resolvedPathPolicy:"runtime-private-never-persist"}},project:{name:g,relativePath:u,...m?.kind?{kind:m.kind}:{},...m?.runtime||l?.runtime?{runtime:m?.runtime??l?.runtime}:{},...m?.runtimeCandidates?.length?{runtimeCandidates:[...m.runtimeCandidates].sort()}:{},...m?.framework||l?.framework?{framework:m?.framework??l?.framework}:{},...m?.kit||l?.kit?{kit:m?.kit??l?.kit}:{},...m?.supportTier?{supportTier:m.supportTier}:{},commands:{supported:[...m?.commands.supported??[]].sort(),unsupported:[...m?.commands.unsupported??[]].sort(),fleetStages:[...m?.commands.fleetStages??[]].sort()},importantFiles:[...new Set((m?.importantFiles??[]).map(a=>x(a,t$1,n)).filter(a=>a!==null))].sort()},intelligence:{...f?.generatedAt?{modelGeneratedAt:f.generatedAt}:{},...w?.generatedAt?{graphGeneratedAt:w.generatedAt}:{},...w?.source.hash?{graphModelHash:w.source.hash}:{},entityCount:p.entityCount,relationCount:p.relationCount,proofCount:p.proofCount,entitiesByKind:p.entitiesByKind,relationsByKind:p.relationsByKind,languages:p.languages,semantic:p.semantic,relatedProjects:p.relatedProjects,freshness:{model:N,graph:R,graphMatchesModel:b$1},topology:{...p.topology,dependencies:p.topology.dependencies.map(a=>({...a,evidence:a.evidence.map(h=>x(h,t$1,n)).filter(h=>h!==null)})),dependents:p.topology.dependents.map(a=>({...a,evidence:a.evidence.map(h=>x(h,t$1,n)).filter(h=>h!==null)}))},surfaces:ve(p.entities,t$1,n),diagnostics:[...j,...p.diagnostics].map(a=>({...a,message:P(a.message,t$1,n),...a.recommendation?{recommendation:P(a.recommendation,t$1,n)}:{}}))},evidence:{readOrder:[b,".workspai/PROJECT-GROUNDING.md",i.projectContextAgent,"AGENTS.md","workspace:.workspai/goals/index.json",`workspace:${i.goalPackLastRun}`,"workspace:.workspai/reports/INDEX.json","workspace:.workspai/reports/workspace-context-agent.json",`workspace:${e.model}`,`workspace:${e.knowledgeGraph}`],projectProofArtifacts:[...new Set(p.proofArtifacts.map(a=>x(a,t$1,n)).filter(a=>a!==null))],relations:p.relations.map(a=>({id:a.id,from:a.from,to:a.to,kind:a.kind,derivation:a.derivation,trust:a.trust,confidence:a.confidence,proofIds:[...a.proofIds].sort()})),proofs:p.proofs.map(a=>Ae(a,t$1,n)).filter(a=>a!==null)},blockers:v,agentRouting:{enforcement:"required",mandatoryPreflight:{command:"workspai agent bootstrap --for-agent generic --strict --json",successCondition:"ready"},workspaceLocator:{command:"workspai project workspace status --json",successCondition:"resolved",outputClassification:"machine-local",persistence:"forbidden",disclosure:"forbidden",portableUriScheme:"workspace:"},workspaceEvidenceRequiredFor:["repository-analysis","architecture-analysis","change-impact","cross-project-change","contract-change","infrastructure-change","release-readiness"],requiredReadOrder:[b,"command:workspai agent bootstrap --for-agent generic --strict --json","command:workspai project workspace status --json",i.projectContextAgent,"workspace:.workspai/reports/INDEX.json","workspace:.workspai/reports/workspace-context-agent.json",`command:npx workspai workspace graph search ${JSON.stringify(g)} --scope ${JSON.stringify(`project:${g}`)} --limit 12 --json`],degradedMode:{allowCompleteArchitectureClaims:false,requireDisclosure:true}},commands:{refresh:"workspai workspace intelligence run --for-agent generic --strict --json",verify:"workspai workspace verify --strict --json",graphSearch:`workspai workspace graph search ${JSON.stringify(g)} --scope ${JSON.stringify(`project:${g}`)} --limit 12 --json`,doctor:"workspai doctor project --json",workspaceStatus:"workspai project workspace status --json"}};if(U($,[t$1,n]))throw new Error("Project context lens rejected a non-portable absolute path.");let r={...$,integrity:{algorithm:"sha256",...y?{modelHash:y}:{},payloadHash:Ce($),portable:true,absolutePathsEmitted:false}};return a(r,"contracts/workspace-intelligence/project-context-agent.v1.json","Project context agent"),r}function Te(e){let t=e.intelligence.relatedProjects.length>0?e.intelligence.relatedProjects.map(i=>`\`${i}\``).join(", "):"No proven cross-project relation is currently available.",n=e.intelligence.diagnostics.length>0?e.intelligence.diagnostics.slice(0,8).map(i=>`- **${i.severity} \xB7 ${i.code}:** ${i.message}`).join(`
|
|
2
|
+
`):"- No project-scoped graph diagnostic is currently recorded.",o=e.blockers.length>0?e.blockers.slice(0,12).map(i=>`- **${i.severity}${i.code?` \xB7 ${i.code}`:""}:** ${i.message}`).join(`
|
|
3
|
+
`):"- No current project-scoped blocker is recorded.";return `# Workspai project grounding
|
|
4
|
+
|
|
5
|
+
This project is adopted into the **${e.workspace.name}** Workspai workspace.
|
|
6
|
+
That value is the canonical workspace identity, not its filesystem path. Workspai
|
|
7
|
+
commands launched here resolve the machine-local workspace automatically.
|
|
8
|
+
|
|
9
|
+
## Mandatory first contact
|
|
10
|
+
|
|
11
|
+
Do not begin broad repository discovery, architecture claims, planning, or mutation
|
|
12
|
+
until this sequence is complete:
|
|
13
|
+
|
|
14
|
+
1. Read \`.workspai/agent-entry.v1.json\` to discover the portable protocol.
|
|
15
|
+
2. Run \`workspai agent bootstrap --for-agent generic --strict --json\`.
|
|
16
|
+
3. Follow the receipt's \`requiredReadOrder\` exactly.
|
|
17
|
+
4. Read \`.workspai/reports/project-context-agent.json\`.
|
|
18
|
+
5. If the receipt reports an active Goal, read its immutable Goal Pack and agent
|
|
19
|
+
handoff before choosing or expanding work.
|
|
20
|
+
6. Query the bounded Workspace Graph with the user's actual task before opening broad
|
|
21
|
+
source, then inspect only returned proof paths and targeted live files.
|
|
22
|
+
|
|
23
|
+
Receipt policy:
|
|
24
|
+
|
|
25
|
+
- \`ready\`: continue with bounded evidence and targeted source inspection.
|
|
26
|
+
- \`degraded\`: disclose the limitation and do not claim complete architecture or verification.
|
|
27
|
+
- \`blocked\`: stop governed claims, execute \`nextActions\`, and rerun bootstrap.
|
|
28
|
+
|
|
29
|
+
## Workspace location and portable paths
|
|
30
|
+
|
|
31
|
+
- \`${e.workspace.name}\` is an identity, not a directory name to guess.
|
|
32
|
+
- Project-local paths begin with \`.workspai/\`.
|
|
33
|
+
- Canonical workspace paths begin with \`workspace:\`.
|
|
34
|
+
- Resolve the exact local workspace root only when direct file access is necessary by
|
|
35
|
+
running \`workspai project workspace status --json\` from this project.
|
|
36
|
+
- The resolver's absolute paths are machine-local runtime data. Never persist or copy
|
|
37
|
+
them into answers, shared logs, commits, prompts, telemetry, or portable artifacts.
|
|
38
|
+
|
|
39
|
+
## Authority boundary
|
|
40
|
+
|
|
41
|
+
The Workspace Model owns canonical project identity and its compact \`projectTopology\`.
|
|
42
|
+
The Workspace Knowledge Graph is a separate, proof-backed enrichment containing
|
|
43
|
+
files, symbols, APIs, infrastructure, tests, owners, and decisions. Do not treat
|
|
44
|
+
an unproven topology edge as proof that two projects are independent. Live source owns
|
|
45
|
+
exact implementation. CLI evidence owns Goal, readiness, repair, and verification claims.
|
|
46
|
+
Repository-authored instructions remain authoritative for source changes after this
|
|
47
|
+
entry gate; Workspai preserves rather than replaces them.
|
|
48
|
+
|
|
49
|
+
## Project
|
|
50
|
+
|
|
51
|
+
- Name: \`${e.project.name}\`
|
|
52
|
+
- Workspace-relative identity: \`${e.project.relativePath}\`
|
|
53
|
+
- Runtime: \`${e.project.runtime??"unknown"}\`
|
|
54
|
+
- Framework: \`${e.project.framework??"unknown"}\`
|
|
55
|
+
- Relationship: \`${e.workspace.relationship}\`
|
|
56
|
+
- Related projects: ${t}
|
|
57
|
+
- Topology status: \`${e.intelligence.topology.status}\`
|
|
58
|
+
- Model freshness: \`${e.intelligence.freshness.model}\`
|
|
59
|
+
- Knowledge Graph freshness: \`${e.intelligence.freshness.graph}\`
|
|
60
|
+
|
|
61
|
+
## Current evidence coverage
|
|
62
|
+
|
|
63
|
+
- Project-scoped entities: ${e.intelligence.entityCount}
|
|
64
|
+
- Project-scoped relations: ${e.intelligence.relationCount}
|
|
65
|
+
- Portable proofs: ${e.intelligence.proofCount}
|
|
66
|
+
|
|
67
|
+
${n}
|
|
68
|
+
|
|
69
|
+
## Current project blockers
|
|
70
|
+
|
|
71
|
+
${o}
|
|
72
|
+
|
|
73
|
+
## Safe commands from this project
|
|
74
|
+
|
|
75
|
+
\`\`\`bash
|
|
76
|
+
${e.commands.workspaceStatus}
|
|
77
|
+
${e.commands.doctor}
|
|
78
|
+
${e.commands.graphSearch}
|
|
79
|
+
${e.commands.verify}
|
|
80
|
+
\`\`\`
|
|
81
|
+
|
|
82
|
+
The machine-local workspace binding lives only in
|
|
83
|
+
\`.workspai/workspace-link.local.json\`, which is gitignored. Portable grounding files
|
|
84
|
+
never publish its value.
|
|
85
|
+
`}function Se(e){return `# Workspai agent entry gate (mandatory)
|
|
86
|
+
|
|
87
|
+
- Project: \`${e.project.name}\`
|
|
88
|
+
- Workspace identity: \`${e.workspace.name}\` (logical name, not a filesystem path)
|
|
89
|
+
- Entry contract: \`.workspai/agent-entry.v1.json\`
|
|
90
|
+
|
|
91
|
+
Before broad repository discovery, architecture claims, planning, or mutation:
|
|
92
|
+
|
|
93
|
+
1. Read \`.workspai/agent-entry.v1.json\`.
|
|
94
|
+
2. Run \`workspai agent bootstrap --for-agent generic --strict --json\`.
|
|
95
|
+
3. Follow the receipt's \`requiredReadOrder\` exactly.
|
|
96
|
+
4. If a Goal is active, read its immutable Goal Pack and handoff before acting.
|
|
97
|
+
5. Query the bounded Workspace Graph with the user's task, then inspect only returned proofs and targeted live source.
|
|
98
|
+
|
|
99
|
+
Receipt policy: \`ready\` may proceed; \`degraded\` must disclose limitations and may not claim complete architecture or verification; \`blocked\` must stop governed claims, execute \`nextActions\`, and rerun bootstrap.
|
|
100
|
+
|
|
101
|
+
\`workspace:\` paths belong to the canonical workspace, not this project's \`.workspai\` directory. Resolve their machine-local root at runtime with \`workspai project workspace status --json\`. That output is machine-local: never copy it into answers, shared logs, commits, or portable artifacts.
|
|
102
|
+
|
|
103
|
+
Authority: Workspai evidence owns identity, topology, goals, readiness, and verification. Live source and repository-authored rules own exact implementation and source conventions.`}function se(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function q(e,t){return new RegExp(`${se(e)}[\\s\\S]*?${se(t)}`,"m")}function me(e){let t=e.replace(q(de,pe),"");return d$3(t)?.includes("# Workspai project boundary")&&(t=t.replace(q(a$1,b$1),"")),t.replace(/\n{3,}/g,`
|
|
104
|
+
|
|
105
|
+
`).trim()}function Ne(e,t){let n=me(e),o=`${de}
|
|
106
|
+
${t.trim()}
|
|
107
|
+
${pe}`;return n?`${o}
|
|
108
|
+
|
|
109
|
+
${n}
|
|
110
|
+
`:`${o}
|
|
111
|
+
`}async function W(e,t){await k.mkdir(d.dirname(e),{recursive:true});let n=`${e}.${process.pid}.${le.randomUUID()}.tmp`;try{await k.writeFile(n,t,"utf8");try{await k.rename(n,e);}catch(o){let i=o.code;if(i!=="EEXIST"&&i!=="EPERM")throw o;await he.move(n,e,{overwrite:true});}}finally{await k.rm(n,{force:true}).catch(()=>{});}}async function fe(e,t){let n;try{n=await execa("git",["rev-parse","--show-toplevel"],{cwd:e,reject:false});}catch{return false}if(n?.exitCode!==0)return false;let o=n.stdout.trim();if(!o)return false;let i,c;try{[i,c]=await Promise.all([k.realpath(d.resolve(o)),k.realpath(e)]);}catch{return false}let s=d.resolve(c,t),l=d.relative(i,s).replace(/\\/g,"/");if(!l||d.isAbsolute(l)||l===".."||l.startsWith("../"))return false;let g;try{g=await execa("git",["cat-file","-e",`HEAD:${l}`],{cwd:i,reject:false});}catch{return false}if(g?.exitCode!==0)return false;let u;try{u=await execa("git",["ls-files","--deleted","--error-unmatch","--",`:(top)${l}`],{cwd:i,reject:false});}catch{return false}return u?.exitCode===0}async function ae(e,t){let n=d.join(e,".gitignore"),o=await k.readFile(n,"utf8").catch(l=>{if(l.code==="ENOENT")return "";throw l}),i=[g$1,h$1,b],c=o.split(/\r?\n/).filter(l=>l.trim()!=="# Workspai local project grounding"&&!i.includes(l.trim()));for(;c.length>0&&c[c.length-1]==="";)c.pop();t==="local"&&(c.length>0&&c.push(""),c.push("# Workspai local project grounding",...i));let s=c.length>0?`${c.join(`
|
|
112
|
+
`)}
|
|
113
|
+
`:"";s!==o&&await W(n,s);}var L=[{host:"claude",relativePath:"CLAUDE.md",importFromAgents:"@AGENTS.md",importFromGrounding:"@.workspai/PROJECT-GROUNDING.md"},{host:"gemini",relativePath:"GEMINI.md",importFromAgents:"@./AGENTS.md",importFromGrounding:"@./.workspai/PROJECT-GROUNDING.md"},{host:"qwen",relativePath:"QWEN.md",importFromAgents:"@AGENTS.md",importFromGrounding:"@.workspai/PROJECT-GROUNDING.md"},{host:"amazon-q",relativePath:".amazonq/rules/workspai-agent-entry.md",importFromAgents:"",importFromGrounding:""}];if(L.length!==g.length||L.some((e,t)=>e.relativePath!==g[t]))throw new Error("Project agent adapter paths must match the portable entry contract.");async function Ie(e,t){let n=t.split("/").slice(0,-1),o=e;for(let i of n){o=d.join(o,i);let c=await k.lstat(o).catch(s=>{if(s.code==="ENOENT")return null;throw s});if(!c)return null;if(c.isSymbolicLink()||!c.isDirectory())return d.relative(e,o).split(d.sep).join("/")}return null}function Ge(e){let t=e.agentsAvailable?e.adapter.importFromAgents:e.adapter.importFromGrounding;return t?`${t}
|
|
114
|
+
|
|
115
|
+
# Workspai host binding \xB7 ${e.adapter.host}
|
|
116
|
+
|
|
117
|
+
The imported Workspai entry gate is mandatory. Validate this host with
|
|
118
|
+
\`workspai agent bootstrap --for-agent ${e.adapter.host} --strict --json\`, then follow
|
|
119
|
+
the receipt's \`requiredReadOrder\`, Goal handoff, bounded Graph queries, proof paths,
|
|
120
|
+
status policy, workspace locator privacy policy, and authority boundary. Do not repeat
|
|
121
|
+
the imported instructions or replace repository-authored source rules.`:`# Workspai entry for ${e.adapter.host}
|
|
122
|
+
|
|
123
|
+
Before broad repository discovery, architecture claims, planning, or mutation:
|
|
124
|
+
|
|
125
|
+
1. Read \`.workspai/agent-entry.v1.json\`.
|
|
126
|
+
2. Run \`workspai agent bootstrap --for-agent ${e.adapter.host} --strict --json\`.
|
|
127
|
+
3. Follow \`requiredReadOrder\`, any active Goal handoff, bounded Graph queries, and returned proof paths.
|
|
128
|
+
|
|
129
|
+
Receipt policy: \`ready\` may proceed; \`degraded\` must disclose limitations; \`blocked\` must execute \`nextActions\` and rerun bootstrap before governed claims.
|
|
130
|
+
|
|
131
|
+
The workspace name is a logical identity, not a path. Resolve \`workspace:\` URIs at runtime with \`workspai project workspace status --json\`; its absolute paths are machine-local and must never be copied into shared output or portable artifacts. Live source owns exact implementation; Workspai evidence owns identity, topology, goals, readiness, and verification. Repository-authored rules remain authoritative for source changes after this entry gate.`}async function ie(e){let t=await Ie(e.projectPath,e.adapter.relativePath);if(t)return {reason:`${e.adapter.relativePath} has an unsafe repository-authored parent at ${t}.`};let n=d.join(e.projectPath,e.adapter.relativePath),o=await k.lstat(n).catch(u=>{if(u.code==="ENOENT")return null;throw u});if(o?.isSymbolicLink())return {reason:`${e.adapter.relativePath} is a repository-authored symbolic link.`};let i=o?.isFile()===true,c=await k.readFile(n,"utf8").catch(u=>{if(u.code==="ENOENT")return "";throw u});if(e.mode==="managed"&&!i&&await fe(e.projectPath,e.adapter.relativePath))return {reason:`${e.adapter.relativePath} has an authored tracked deletion.`};let s=c.replace(q(d$2,e$1),"").replace(/\n{3,}/g,`
|
|
132
|
+
|
|
133
|
+
`).trim(),l=e.mode==="managed"?[s,`${d$2}
|
|
134
|
+
${Ge(e).trim()}
|
|
135
|
+
${e$1}`].filter(Boolean).join(`
|
|
136
|
+
|
|
137
|
+
`):s;if(!l)return i&&await k.rm(n,{force:true}),{};let g=`${l.trimEnd()}
|
|
138
|
+
`;return g!==c&&await W(n,g),e.mode==="managed"?{path:e.adapter.relativePath}:{}}function We(e){let t={id:"generic",discovery:"portable-fallback",entryFiles:[g$1],status:"ready",managed:e.mode==="managed"},o=["codex","kimi","grok","copilot","cursor","windsurf"].map(s=>({id:s,discovery:"native",entryFiles:["AGENTS.md"],status:e.agentsAvailable?"ready":"blocked",managed:e.mode==="managed"&&e.agentsAvailable,...e.agentsAvailable?{}:{reason:"AGENTS.md could not be managed without overriding authored repository state."}})),i=L.map(s=>{let l=e.adapters.get(s.host);return {id:s.host,discovery:"adapter",entryFiles:[s.relativePath],status:l?.path?"ready":e.mode==="managed"?"blocked":"degraded",managed:!!l?.path,...l?.path?{}:{reason:l?.reason??"Provider adapter generation is disabled by the project grounding policy."}}}),c=[t,...o,...i];return f.map(s=>c.find(l=>l.id===s))}async function ce(e,t,n){let o=d.join(e,"AGENTS.md"),i=await k.lstat(o).catch(u=>{if(u.code==="ENOENT")return null;throw u});if(i?.isSymbolicLink())return;let c=i?.isFile()===true,s=await k.readFile(o,"utf8").catch(u=>{if(u.code==="ENOENT")return "";throw u});if(t==="managed"&&!n)throw new Error("Managed project grounding requires a project context.");if(t==="managed"&&!c&&await fe(e,"AGENTS.md"))return;let l=t==="managed"&&n?Ne(s,Se(n)):me(s);if(!l){c&&await k.rm(o,{force:true});return}let g=`${l.trimEnd()}
|
|
139
|
+
`;return g!==s&&await W(o,g),t==="managed"?o:void 0}async function $e(e){let t$1=e.mode??"managed",n=d.resolve(e.workspacePath),o=d.resolve(e.projectPath);if(t$1==="off"){let p=t(o,"project.json").find(j=>H.existsSync(j)),v=p?await E(p):null,C=e.projectName??(typeof v?.name=="string"?v.name:void 0)??d.basename(o),R=ge(v,e.relationship??"managed"),N=await c({workspacePath:n,projectPath:o,projectName:C,relationship:R,now:e.now});return await ae(o,t$1),await ce(o,t$1),await Promise.all(L.map(j=>ie({projectPath:o,adapter:j,mode:t$1,agentsAvailable:false}))),await Promise.all([k.rm(d.join(o,h$1),{force:true}),k.rm(d.join(o,g$1),{force:true}),k.rm(d.join(o,b),{force:true})]),{mode:t$1,projectPath:o,linkPath:N.linkPath,writtenFiles:[i.projectWorkspaceLink]}}let i$2=await Re(e),c$1=i$2.workspace.relationship,s=await c({workspacePath:n,projectPath:o,projectName:i$2.project.name,relationship:c$1,workspaceName:i$2.workspace.name,relativePath:i$2.project.relativePath,now:e.now});await ae(o,t$1);let l=await ce(o,t$1,i$2),g=new Map;for(let p of L)g.set(p.host,await ie({projectPath:o,adapter:p,mode:t$1,agentsAvailable:!!l}));let u=We({mode:t$1,agentsAvailable:!!l,adapters:g}),f=d.join(o,h$1),w=d.join(o,g$1),y=d.join(o,b),b$1=i$1({context:i$2,hosts:u});await W(f,`${JSON.stringify(i$2,null,2)}
|
|
140
|
+
`),await W(w,`${Te(i$2).trimEnd()}
|
|
141
|
+
`),await W(y,`${JSON.stringify(b$1,null,2)}
|
|
142
|
+
`);let m=[i.projectWorkspaceLink,h$1,g$1,b];l&&m.push("AGENTS.md");for(let p of g.values())p.path&&m.push(p.path);return {mode:t$1,projectPath:o,linkPath:s.linkPath,groundingPath:w,contextPath:f,agentEntryPath:y,agentsPath:l,hostCoverage:u,writtenFiles:m}}async function et(e){let t=d.resolve(e.workspacePath),n=e.mode??"managed",o=await Oe(t),i=[],c=[];for(let s of o.resolved)try{i.push(await $e({workspacePath:t,projectPath:s.projectPath,projectName:s.name,relationship:s.relationship,mode:n,now:e.now}));}catch(l){c.push({name:s.name,reason:l instanceof Error?l.message:String(l)});}return {workspacePath:t,mode:n,projects:i,skipped:[...o.skipped,...c]}}async function Oe(e){let t=d.resolve(e),n=await E(d.join(t,".workspai","workspace.contract.json")),o=[],i=[];for(let c of n?.projects??[]){let s=c.slug??c.relativePath??"unknown-project",l=typeof c.externalPath=="string"?d.resolve(c.externalPath):typeof c.relativePath=="string"&&!c.relativePath.startsWith("external/")?d.resolve(t,c.relativePath):null;if(!l||!H.existsSync(l)){i.push({name:s,reason:"project path is unavailable on this machine"});continue}o.push({name:s,projectPath:l,relationship:c.relationship??"managed"});}return {resolved:o,skipped:i}}export{ke as a,Ze as b,de as c,pe as d,Re as e,$e as f,et as g,Oe as h};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {a}from'./chunk-A5FBGRJA.js';import {a as a$1}from'./chunk-AFIFZTOY.js';import {i as i$1,h}from'./chunk-
|
|
1
|
+
import {a}from'./chunk-A5FBGRJA.js';import {a as a$1}from'./chunk-AFIFZTOY.js';import {i as i$1,h}from'./chunk-NZ3WZYD5.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 from'fs/promises';import i from'path';import T from'fs-extra';var x=h.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!==i$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.mkdir(i.dirname(e),{recursive:true});let r=`${e}.${process.pid}.${b.randomUUID()}.tmp`;try{await d.writeFile(r,`${JSON.stringify(t,null,2)}
|
|
2
2
|
`,{encoding:"utf8",mode:384});try{await d.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.rm(r,{force:true}).catch(()=>{});}}async function D(e){let t=i.join(e,".gitignore"),r=await d.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
3
|
`)?`
|
|
4
4
|
`:""}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import {a
|
|
1
|
+
import {a}from'./chunk-NS53IPAC.js';import {a as a$1}from'./chunk-AO2ZI42U.js';import {f,h}from'./chunk-NZ3WZYD5.js';var R=f.doctor,O=h.doctorProject.schemaVersion;function s(a){return !a||typeof a!="object"||Array.isArray(a)?null:a}function M(a,o){let t=s(a);if(!t)return false;let i=t.schemaVersion,e=t.evidenceType;if(i!==void 0&&typeof i!="string"||e!==void 0&&typeof e!="string")return false;if(i===void 0){let l=Array.isArray(t.projects)||s(t.summary)!==null||s(t.healthScore)!==null,u=s(t.project)!==null;if(!(o==="workspace"?l:o==="project"?u:l||u))return false}return !(typeof i=="string"&&(i!==R&&i!==O||o==="workspace"&&i!==R||o==="project"&&i!==O)||typeof e=="string"&&(e!=="workspace"&&e!=="project"||o&&e!==o))}function r(a,o){let t=a[o];if(!Number.isInteger(t)||Number(t)<0)throw new Error(`Doctor evidence ${o} must be a non-negative integer.`);return Number(t)}function I(a){if(Array.isArray(a.projects))return a.projects.map(s).filter(t=>t!==null);let o=s(a.project);return o?[o]:[]}function _(a$1){let o=s(a$1.diagnosis);if(!o)return;if(o.schemaVersion!==a)throw new Error("Doctor diagnosis schemaVersion is missing or unsupported.");let t=Array.isArray(o.findings)?o.findings.map(s).filter(n=>n!==null):[],i=s(o.coverage);if(!i)throw new Error("Doctor diagnosis must publish coverage.");let e=s(o.capability);if(!e)throw new Error("Doctor diagnosis must publish capability truth.");let l=Array.isArray(o.domains)?o.domains.map(s).filter(n=>n!==null):[],u=l.map(n=>n.id);if(l.length!==6||new Set(u).size!==l.length)throw new Error("Doctor diagnosis must publish each canonical diagnostic domain exactly once.");let f=["nativeDomains","portableDomains","observableDomains","unsupportedDomains"].flatMap(n=>Array.isArray(e[n])?e[n]:[]);if(f.length!==6||new Set(f).size!==f.length||u.some(n=>!f.includes(n)))throw new Error("Doctor capability truth must classify every canonical domain exactly once.");if(e.tier==="fallback"&&e.confidence!=="low")throw new Error("Doctor fallback capability cannot claim medium or high confidence.");let h=new Set;for(let n of t){if(typeof n.id!="string"||!n.id.trim())throw new Error("Doctor diagnosis finding id must be non-empty.");if(h.has(n.id))throw new Error(`Doctor diagnosis finding id is duplicated: ${n.id}`);if(h.add(n.id),!Array.isArray(n.proofs)||n.proofs.length===0)throw new Error(`Doctor diagnosis finding ${n.id} has no proof.`)}let D=t.filter(n=>n.status==="blocking").length,v=t.filter(n=>n.status==="advisory").length;if(r(i,"blockingFindings")!==D)throw new Error("Doctor diagnosis blockingFindings contradicts its finding set.");if(r(i,"advisoryFindings")!==v)throw new Error("Doctor diagnosis advisoryFindings contradicts its finding set.");let k=r(i,"totalObservations"),w=r(i,"evaluatedObservations"),c=r(i,"passingObservations");if(w>k||c>w)throw new Error("Doctor diagnosis observation accounting is inconsistent.");if(r(i,"repairableFindings")+r(i,"manualFindings")+r(i,"unsupportedFindings")!==t.length)throw new Error("Doctor diagnosis repair disposition counts contradict its finding set.");let y=Array.isArray(o.unknowns)?o.unknowns:[];if(r(i,"unknownFindings")!==y.length)throw new Error("Doctor diagnosis unknownFindings contradicts its unknown set.");let g=i.diagnosisCompleteness;if(typeof g!="number"||g<0||g>100)throw new Error("Doctor diagnosis completeness must be between 0 and 100.");if(g===100&&l.some(n=>n.status==="not-run"||n.status==="stale"))throw new Error("Doctor diagnosis cannot claim complete coverage with missing or stale domains.");if(g===100&&y.length>0)throw new Error("Doctor diagnosis cannot claim complete coverage while unknowns remain.");let b=new Set;for(let n of Array.isArray(o.causalGroups)?o.causalGroups:[]){let d=s(n);if(!d||!Array.isArray(d.findingIds))throw new Error("Doctor diagnosis causal group is malformed.");for(let p of d.findingIds){if(typeof p!="string"||!h.has(p))throw new Error("Doctor diagnosis causal group references an unknown finding.");if(b.has(p))throw new Error("Doctor diagnosis finding belongs to more than one causal group.");b.add(p);}}if(b.size!==h.size)throw new Error("Doctor diagnosis causal groups do not cover every finding exactly once.")}function P(a){let o=[...Array.isArray(a.repairCapabilities)?a.repairCapabilities:[],...Array.isArray(a.probes)?a.probes.map(s).map(t=>t&&s(t.repairCapability)):[]];for(let t of o){let i=s(t);if(!(!i||i.operation===void 0)&&!a$1(i.operation)){let e=typeof i.id=="string"?i.id:"unknown";throw new Error(`Doctor repair capability ${e} contains an invalid typed operation.`)}}}function z(a){let o=s(a);if(!o)throw new Error("Doctor evidence must be an object.");let t=I(o),i=s(o.contract);for(let c of t)_(c),P(c);if(i?.scoringPolicyVersion==="doctor-score-policy-v2"&&t.some(c=>!s(c.diagnosis)))throw new Error("Canonical Doctor evidence contains a project without diagnosis.");let e=s(o.healthScore);if(!e||typeof e.verdict!="string")return;let l=r(e,"total"),u=r(e,"passed"),E=r(e,"warnings"),f=r(e,"errors");if(l!==u+E+f)throw new Error("Doctor healthScore total must equal passed + warnings + errors.");let h=f>0?"blocked":E>0?"attention":"passed";if(e.verdict!==h)throw new Error(`Doctor healthScore verdict ${String(e.verdict)} contradicts score counts (${h}).`);let D=s(e.components);if(D){let c=s(D.host),m=s(D.projects);if(!c||!m)throw new Error("Doctor healthScore components must publish host and projects.");for(let[y,g]of [["host",c],["projects",m]]){let b=r(g,"total"),n=r(g,"passed"),d=r(g,"warnings"),p=r(g,"errors");if(b!==n+d+p)throw new Error(`Doctor ${y} score total contradicts its component counts.`)}if(u!==r(c,"passed")+r(m,"passed")||E!==r(c,"warnings")+r(m,"warnings")||f!==r(c,"errors")+r(m,"errors"))throw new Error("Doctor healthScore contradicts its host/project components.")}let v=0,k=0;for(let c of t){let m=Array.isArray(c.probes)?c.probes:[],y=s(c.diagnosis),g=y?s(y.coverage):null,b=m.filter(p=>s(p)?.status==="fail").length+(Array.isArray(c.issues)?c.issues.length:0),n=g?r(g,"blockingFindings"):b;v+=n;let d=s(c.probeSummary);if(d){if(r(d,"total")!==r(d,"passed")+r(d,"warnings")+r(d,"failed"))throw new Error("Doctor project probeSummary total contradicts its probe counts.");let p=r(d,"blockingFindings");if(p!==n)throw new Error("Doctor project probeSummary.blockingFindings contradicts its canonical diagnosis.");let A=p>0?"blocked":r(d,"advisoryFindings")+Number(d.unknownFindings??0)+Number(d.contradictionFindings??0)>0?"attention":"passed";if(d.verdict!==A||c.verdict!==A)throw new Error("Doctor project verdict contradicts its probe summary.");k+=r(d,"advisoryFindings");}}if(v>0&&f===0)throw new Error("Doctor evidence contains blocking findings but healthScore.errors is zero.");let w=s(o.summary);if(w&&Array.isArray(o.projects)){if(w.blockingFindings!==void 0&&r(w,"blockingFindings")!==v)throw new Error("Doctor workspace summary blockingFindings contradicts project diagnosis.");if(w.advisoryFindings!==void 0&&r(w,"advisoryFindings")!==k)throw new Error("Doctor workspace summary advisoryFindings contradicts project diagnosis.")}}export{R as a,O as b,M as c,z as d};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {a as a$1}from'./chunk-G4VMNWSU.js';import {a}from'./chunk-NS53IPAC.js';import {e}from'./chunk-GRGUPSNP.js';import {h as h$1,b,a as a$2,d,c}from'./chunk-HH54C3XJ.js';import pe from'path';import h from'chalk';import {createHash}from'crypto';var F="workspai.doctor-adapter.v1",D=["runtime","dependency","security","configuration","test","quality"];function A(e){return e.trim().toLowerCase().replace(/[^a-z0-9+.#-]+/g,"-")}function ae(e){if(e.contractVersion!==F)throw new Error(`Unsupported Doctor adapter contract: ${e.contractVersion}`);if(!e.id.trim())throw new Error("Doctor adapter id must not be empty.");if(e.runtimeFamilies.length===0)throw new Error(`Doctor adapter ${e.id} must own at least one runtime family.`);if(e.platforms.length===0)throw new Error(`Doctor adapter ${e.id} must declare supported platforms.`);let i=e.domains.map(t=>t.domain);if(i.length!==D.length||new Set(i).size!==D.length||D.some(t=>!i.includes(t)))throw new Error(`Doctor adapter ${e.id} must declare every canonical diagnostic domain exactly once.`);for(let t of e.domains)if(t.level==="unsupported"&&t.limitations.length===0)throw new Error(`Doctor adapter ${e.id} must explain unsupported ${t.domain} coverage.`)}var $=class{#e=new Map;#i=new Map;#t=new Map;register(i){ae(i);let t=A(i.id);if(this.#e.has(t))throw new Error(`Doctor adapter id is already registered: ${i.id}`);let s=[...i.runtimeFamilies,...i.aliases].map(A);for(let c of s){let a=this.#i.get(c);if(a)throw new Error(`Doctor runtime ${c} is already owned by adapter ${a}.`)}for(let c of i.frameworks.map(A)){let a=this.#t.get(c);if(a)throw new Error(`Doctor framework ${c} is already owned by adapter ${a}.`)}let r=structuredClone(i);this.#e.set(t,r);for(let c of s)this.#i.set(c,t);for(let c of i.frameworks.map(A))this.#t.set(c,t);return this}resolveWithDiagnostics(i){let t=i.runtimeFamily?this.#i.get(A(i.runtimeFamily)):void 0,s=i.framework?this.#t.get(A(i.framework)):void 0;if(t&&s&&t!==s)return {status:"conflict",descriptor:null,runtimeOwner:t,frameworkOwner:s};let r=t??s;return {status:r?"matched":"unresolved",descriptor:r?structuredClone(this.#e.get(r)??null):null,...t?{runtimeOwner:t}:{},...s?{frameworkOwner:s}:{}}}resolve(i){return this.resolveWithDiagnostics(i).descriptor}list(){return [...this.#e.values()].map(i=>structuredClone(i)).sort((i,t)=>i.id.localeCompare(t.id))}};var Y=[...D],W=["linux","darwin","win32"],re=[{id:"node",aliases:["nodejs","javascript","typescript"],frameworks:["NestJS","Next.js","Remix","Nuxt","React","Vue","Angular","SvelteKit","Svelte","Vite","Astro","Solid","Express","Fastify","Koa","Electron","VS Code Extension"],tier:"first-class",native:Y},{id:"python",aliases:["py"],frameworks:["FastAPI","Django","Flask","Python"],tier:"first-class",native:Y},{id:"go",aliases:["golang"],frameworks:["Go","Go/Fiber","Go/Gin","Echo"],tier:"first-class",native:["runtime","dependency","test","quality"],portable:["security","configuration"]},{id:"java",aliases:["jvm"],frameworks:["Java","Spring Boot"],tier:"first-class",native:["runtime","dependency","test","quality"],portable:["security","configuration"]},{id:"dotnet",aliases:[".net","csharp","c#"],frameworks:["ASP.NET"],tier:"first-class",native:["runtime","dependency","test","quality"],portable:["security","configuration"]},{id:"rust",aliases:["cargo"],frameworks:["Rust","Axum"],tier:"first-class",native:["runtime","dependency","test","quality"],portable:["security","configuration"]},{id:"php",aliases:["composer"],frameworks:["PHP","Laravel"],tier:"first-class",native:["runtime","dependency","security"],portable:["configuration","test","quality"]},{id:"ruby",aliases:["bundler"],frameworks:["Ruby","Ruby on Rails"],tier:"extended",portable:["runtime","dependency","configuration","test","quality"],observable:["security"]},{id:"elixir",aliases:["beam"],frameworks:["Elixir","Phoenix"],tier:"extended",portable:["runtime","dependency","configuration","test","quality"],observable:["security"]},{id:"clojure",frameworks:["Clojure"],tier:"extended",portable:["runtime","dependency","configuration","test","quality"],observable:["security"]},{id:"deno",frameworks:["Deno"],tier:"extended",portable:["runtime","dependency","configuration","test","quality"],observable:["security"]},{id:"bun",frameworks:["Bun"],tier:"extended",portable:["runtime","dependency","configuration","test","quality"],observable:["security"]},{id:"scala",frameworks:["Scala"],tier:"extended",portable:["runtime","dependency","configuration","test","quality"],observable:["security"]},{id:"kotlin",frameworks:["Kotlin"],tier:"extended",portable:["runtime","dependency","configuration","test","quality"],observable:["security"]},{id:"c",aliases:["c-lang"],frameworks:["C"],tier:"extended",portable:["runtime","dependency","test","quality"],observable:["configuration"],limitations:["Security diagnosis requires a declared native scanner or workspace adapter."]},{id:"cpp",aliases:["c++","cplusplus"],frameworks:["C++"],tier:"extended",portable:["runtime","dependency","test","quality"],observable:["configuration"],limitations:["Security diagnosis requires a declared native scanner or workspace adapter."]}];function oe(e,i){let t={runtime:["project markers","entrypoints","toolchain evidence"],dependency:["dependency manifests","lockfiles","installed-tree evidence"],security:["runtime-native audit","advisory evidence"],configuration:["environment contracts","deployment/container markers"],test:["test scripts","test configuration","coverage evidence"],quality:["lint/format/static-analysis contracts"]};return [`${e} adapter`,...t[i]]}function ce(e,i){return e.native?.includes(i)?"native":e.portable?.includes(i)?"portable":e.observable?.includes(i)?"observable":"unsupported"}function le(e){let i=D.map(t=>{let s=ce(e,t);return {domain:t,level:s,evidenceSources:s==="unsupported"?[]:oe(e.id,t),limitations:s==="unsupported"?[`${e.id} has no built-in ${t} provider; declare a workspace adapter.`]:s==="observable"?[`${t} evidence is observable but not runtime-native for ${e.id}.`]:[]}});return {contractVersion:F,id:`builtin.${e.id}`,runtimeFamilies:[e.id],aliases:e.aliases??[],frameworks:e.frameworks,projectKinds:["backend","frontend","desktop","extension","fullstack","generic"],tier:e.tier,platforms:[...W],domains:i,repairModes:["typed-operation","structured-invocation","manual-guidance"],source:"builtin",limitations:e.limitations??[]}}function de(){return {contractVersion:F,id:"builtin.unknown",runtimeFamilies:["unknown"],aliases:["generic","unrecognized"],frameworks:["Unknown"],projectKinds:["backend","frontend","desktop","extension","fullstack","generic"],tier:"fallback",platforms:[...W],domains:D.map(e=>({domain:e,level:e==="security"?"unsupported":"observable",evidenceSources:e==="security"?[]:["portable workspace markers","declared custom checks"],limitations:[e==="security"?"No safe security claim is possible without a runtime-native audit provider.":`Only portable ${e} evidence is available until a runtime adapter is registered.`]})),repairModes:["manual-guidance"],source:"builtin",limitations:["Unknown runtimes are fail-closed: missing domain evidence is reported as unknown, never healthy.","Automatic repair is unavailable until a typed adapter owns the runtime."]}}function P(){let e=new $;for(let i of re)e.register(le(i));return e.register(de()),e}function J(e,i=P()){let t=i.resolveWithDiagnostics(e),s=t.descriptor??i.resolve({runtimeFamily:"unknown"});if(!s)throw new Error("Doctor fallback adapter is not registered.");let r=c=>s.domains.filter(a=>a.level===c).map(a=>a.domain);return {registryVersion:b,adapterId:s.id,runtimeFamily:s.runtimeFamilies[0]??"unknown",tier:s.tier,confidence:s.tier==="first-class"?"high":s.tier==="extended"?"medium":"low",nativeDomains:r("native"),portableDomains:r("portable"),observableDomains:r("observable"),unsupportedDomains:r("unsupported"),limitations:[...t.status==="conflict"?[`Runtime/framework ownership conflict (${t.runtimeOwner} vs ${t.frameworkOwner}); Doctor failed closed instead of selecting an ambiguous adapter.`]:[],...s.limitations,...s.domains.flatMap(c=>c.limitations)]}}function K(e={}){let i=P(),t=i.list(),s=i.resolveWithDiagnostics({runtimeFamily:e.runtime,framework:e.framework}),r=e.runtime||e.framework?[s.descriptor]:t;if((e.runtime||e.framework)&&!r[0]){let a=i.resolve({runtimeFamily:"unknown"});a&&(s.status==="conflict"&&a.limitations.unshift(`Runtime/framework ownership conflict (${s.runtimeOwner} vs ${s.frameworkOwner}); Doctor failed closed instead of selecting an ambiguous adapter.`),r[0]=a);}let c=r.filter(a=>!!a);return {schemaVersion:a$2,registryVersion:b,generatedBy:"workspai",policy:{unknownIsHealthy:false,unsupportedIsHealthy:false,repairRequiresTypedOperation:true,canonicalDomains:[...D]},summary:{adapterCount:c.length,firstClassRuntimes:c.filter(a=>a.tier==="first-class").length,extendedRuntimes:c.filter(a=>a.tier==="extended").length,fallbackRuntimes:c.filter(a=>a.tier==="fallback").length,frameworkCount:new Set(c.flatMap(a=>a.frameworks)).size,platformCount:new Set(c.flatMap(a=>a.platforms)).size},adapters:c}}var me=["runtime","dependency","security","configuration","test","quality"];function I(e){return createHash("sha256").update(e).digest("hex").slice(0,12)}function S(e){return e.trim().toLowerCase().replace(/[^a-z0-9._-]+/g,"-").replace(/^-+|-+$/g,"")||"unknown"}function Q(e){return e.trim().toLowerCase().replace(/[^a-z0-9]+/g," ").replace(/\s+/g," ").trim()}function ge(e,i){let t=Q(e);return t?i.some(s=>[s.reason,s.recommendation??""].map(Q).filter(Boolean).some(c=>c===t||c.includes(t)||t.includes(c))):true}function fe(e){return e.status==="fail"?"blocking":e.status==="warn"?"advisory":"informational"}function X(e){return e.issueClass==="dependency"?"dependency":e.issueClass==="security"?"security":e.issueClass==="environment"||e.issueClass==="configuration"||e.issueClass==="container"||e.issueClass==="deployment"||e.issueClass==="workspace-contract"?"configuration":e.issueClass==="test"?"test":e.issueClass==="quality"||e.issueClass==="custom"?"quality":e.issueClass==="runtime"||e.issueClass==="framework"||e.issueClass==="source-tree"?"runtime":null}function ye(e,i){return me.map(t=>{let s=e.filter(o=>X(o)===t),r=e.filter(o=>o.applicability!=="not-applicable"&&X(o)===t),c=i.unsupportedDomains.includes(t);if(r.length===0){let o=s.some(d=>d.applicability==="not-applicable");return {id:t,status:o?"not-applicable":"not-run",observationCount:0,blockingFindings:0,advisoryFindings:0,reason:o?`${t} checks ran and found no declared intent requiring this domain.`:c?`${t} is unsupported by Doctor adapter ${i.adapterId}; no healthy claim is allowed.`:`No ${t} diagnostic observation was produced.`}}let a=r.some(o=>o.freshness?.status==="stale"||o.freshness?.status==="unknown"),p=r.filter(o=>o.status==="fail").length,m=r.filter(o=>o.status==="warn").length,C=p>0||m>0;return {id:t,status:a?"stale":C?"findings":c?"not-run":"clean",observationCount:r.length,blockingFindings:p,advisoryFindings:m,reason:a?`${t} evidence is stale or has unknown freshness.`:C?`${t} diagnostics produced findings.`:c?`${t} observations cannot establish complete health because adapter ${i.adapterId} declares the domain unsupported.`:`${t} diagnostics completed without findings.`}})}function De(e){if(e.status==="pass")return "not-needed";let i=e.repairCapability;return i?i.status==="manual"||i.requiresReview?"manual":i.status!=="available"||!i.canAutoFix?"unavailable":i.requiresApproval?"approval-required":"automatic":"unavailable"}function be(e){if(e.freshness?.status==="stale"||e.freshness?.status==="unknown")return {label:"low",score:.35,state:"unknown"};let i=!!(e.issueClass&&e.issueClass!=="unknown"),t=!!(e.repairCapability?.operation?.type||e.repairCapability?.invocation?.executable);return i&&t&&e.repairIntent?.confidence==="high"?{label:"high",score:.95,state:"confirmed"}:i&&(e.status==="fail"||e.status==="warn")?{label:"medium",score:t?.82:.68,state:"candidate"}:e.status==="pass"?{label:"high",score:.98,state:"confirmed"}:{label:"low",score:.3,state:"unknown"}}function ve(e,i){let t=[{kind:"probe",role:"observation",ref:`probe:${e.id}`,claim:e.reason}];for(let r of e.repairCapability?.files??[])t.push({kind:"file",role:"repair-target",ref:r.split(pe.sep).join("/"),claim:"Structured repair capability declared this path as an affected target."});if(e.repairCapability?.invocation?.executable){let r=e.repairCapability.invocation;t.push({kind:"command",role:"verification",ref:[r.executable,...r.args??[]].join(" "),claim:"Structured command invocation is available for this diagnostic path."});}if(e.issueClass==="security"&&/(?:dependency|audit|vulnerab|security-hygiene)/i.test(`${e.id} ${e.label}`))for(let r of i??[])t.push({kind:"dependency",role:"subject",ref:r.version?`${r.name}@${r.version}`:r.name,claim:r.advisoryIds&&r.advisoryIds.length>0?`Dependency is referenced by ${r.advisoryIds.join(", ")}.`:"Dependency is present in security audit evidence."});return t}function we(e,i){let t=i.issueClass?.trim()||"unknown",s=be(i);return {id:`${S(i.id)}:${I(`${e.projectPath}\0${i.id}`)}`,causalKey:[S(e.projectName),I(e.projectPath),S(t),S(i.id)].join(":"),projectName:e.projectName,projectPath:e.projectPath,probeId:i.id,label:i.label,status:fe(i),severity:i.severity,issueClass:t,operationalImpact:i.operationalImpact?.trim()||"developer-friction",applicability:i.applicability??"applicable",confidence:s.label,confidenceScore:s.score,diagnosisState:s.state,symptom:i.reason,...i.recommendation?{recommendation:i.recommendation}:{},proofs:ve(i,e.dependencySubjects),repair:{disposition:De(i),...i.repairCapability?.id?{capabilityId:i.repairCapability.id}:{},...i.repairCapability?.operation?.type?{operationType:i.repairCapability.operation.type}:{},...i.repairCapability?.verifyCommand?{verifyCommand:i.repairCapability.verifyCommand}:{},requiresFreshEvidence:i.repairIntent?.requiresFreshEvidence===true||i.freshness?.verifyBeforeUse===true}}}function he(e,i,t){let s=`legacy-runtime-issue-${t+1}`;return {id:`${s}:${I(`${e.projectPath}\0${i}`)}`,causalKey:[S(e.projectName),I(e.projectPath),"unknown",I(i)].join(":"),projectName:e.projectName,projectPath:e.projectPath,probeId:s,label:"Runtime diagnostic issue",status:"blocking",severity:"error",issueClass:"unknown",operationalImpact:"runtime-risk",applicability:"applicable",confidence:"low",confidenceScore:.25,diagnosisState:"unknown",symptom:i,proofs:[{kind:"unknown",role:"observation",ref:`legacy-issue:${t+1}`,claim:i}],repair:{disposition:"unavailable",requiresFreshEvidence:true}}}function Z(e){let i=[...e.probes],t=[...new Set((e.runtimeFamilies&&e.runtimeFamilies.length>0?e.runtimeFamilies:[e.runtimeFamily??"unknown"]).filter(Boolean))],s=e.runtimeFamily??t[0]??"unknown",r=t.filter(n=>n!==s&&n!=="unknown"),c=J({runtimeFamily:e.runtimeFamily,framework:e.framework},e.adapterRegistry),a$1=ye(i,c),p=(e.legacyIssues??[]).filter(n=>!ge(n,i)),m=new Map;for(let n of i){let l=m.get(n.id)??new Set;l.add(n.status),m.set(n.id,l);}let C=[...m.entries()].filter(([,n])=>n.size>1).map(([n,l])=>({probeId:n,statuses:[...l].sort(),reason:"The same diagnostic probe produced contradictory states in one project scan."})),o=[...i.filter(n=>n.applicability!=="not-applicable"&&n.status!=="pass").map(n=>we(e,n)),...p.map((n,l)=>he(e,n,l))],d={blocking:4,unknown:3,advisory:2,informational:1},O=new Map;for(let n of o){let l=O.get(n.causalKey)??[];l.push(n),O.set(n.causalKey,l);}let g=[...O.values()].map(n=>{let u=[...n].sort((f,j)=>d[j.status]-d[f.status]||j.confidenceScore-f.confidenceScore||f.id.localeCompare(j.id)).at(0);if(!u)throw new Error("Doctor diagnosis causal group cannot be empty.");let G=structuredClone(u);return G.proofs=[...new Map(n.flatMap(f=>f.proofs).map(f=>[`${f.kind}:${f.role}:${f.ref}:${f.claim}`,f])).values()],G}).sort((n,l)=>n.causalKey.localeCompare(l.causalKey)||n.id.localeCompare(l.id)),k=new Map;for(let n of g){let l=k.get(n.causalKey)??[];l.push(n),k.set(n.causalKey,l);}let b=[...k.entries()].map(([n,l])=>({causalKey:n,issueClass:l[0]?.issueClass??"unknown",status:l.some(u=>u.status==="blocking")?"blocking":l.some(u=>u.status==="advisory")?"advisory":l.some(u=>u.status==="unknown")?"unknown":"informational",findingIds:l.map(u=>u.id),projectPaths:[...new Set(l.map(u=>u.projectPath))],repairable:l.some(u=>u.repair.disposition==="automatic"||u.repair.disposition==="approval-required")})),v=[...g.filter(n=>n.diagnosisState==="unknown"||n.issueClass==="unknown"||n.applicability==="unknown").map(n=>({id:`unknown:${n.id}`,probeId:n.probeId,reason:n.issueClass==="unknown"?"The observation is real, but Doctor cannot yet bind it to a typed issue class.":"Evidence is insufficient or stale for a confirmed diagnosis."})),...a$1.filter(n=>n.status==="not-run"||n.status==="stale").map(n=>({id:`unknown:domain:${n.id}:${I(e.projectPath)}`,reason:n.reason})),...r.map(n=>({id:`unknown:runtime:${S(n)}:${I(e.projectPath)}`,reason:e.projectArchetype==="platform"?`${n} is part of this cross-language platform, but only portable evidence and the primary ${s} runtime adapter were evaluated. Add a typed ${n} adapter before making runtime-specific health claims.`:`${n} was detected inside this composite project boundary, but the ${s} adapter is the only runtime-specific adapter evaluated for this scan. Declare a nested project boundary or a typed Doctor adapter before treating ${n} as healthy.`}))],y=g.filter(n=>n.diagnosisState!=="unknown").length,x=g.length===0?100:y/g.length*100,ie=a$1.filter(n=>n.status!=="not-run"&&n.status!=="stale").length/a$1.length*100,U=t.filter(n=>n!=="unknown").length,te=s!=="unknown"&&t.includes(s)?1:0,ne=U===0?0:te/U*100,se=Math.round(Math.min(x,ie,ne)*100)/100;return {schemaVersion:a,engineVersion:"universal-diagnosis-v1",project:{name:e.projectName,path:e.projectPath,runtimeFamily:e.runtimeFamily??"unknown",runtimeFamilies:t,framework:e.framework??"Unknown",projectKind:e.projectKind??"generic"},capability:c,domains:a$1,coverage:{totalObservations:i.length+p.length,evaluatedObservations:i.filter(n=>n.applicability!=="not-applicable").length,passingObservations:i.filter(n=>n.applicability!=="not-applicable"&&n.status==="pass").length,blockingFindings:g.filter(n=>n.status==="blocking").length,advisoryFindings:g.filter(n=>n.status==="advisory").length,unknownFindings:v.length,repairableFindings:g.filter(n=>n.repair.disposition==="automatic"||n.repair.disposition==="approval-required").length,manualFindings:g.filter(n=>n.repair.disposition==="manual").length,unsupportedFindings:g.filter(n=>n.repair.disposition==="unavailable").length,contradictionCount:C.length,diagnosisCompleteness:se},findings:g,causalGroups:b,unknowns:v,contradictions:C}}function w(e){let i=e.severity??"error",t=e.repair??"unavailable";return {id:e.id,label:e.label,status:i==="error"?"fail":"warn",severity:i,reason:`${e.label} detected by the validation corpus.`,issueClass:e.issueClass,operationalImpact:i==="error"?"release-risk":"ci-risk",repairIntent:{confidence:e.confidence??"medium",requiresFreshEvidence:true},...t==="unavailable"?{}:{repairCapability:{id:`repair.${e.id}`,status:t==="manual"?"manual":"available",canAutoFix:t==="automatic"||t==="approval-required",requiresApproval:t==="approval-required",requiresReview:t==="manual",operation:{type:"validation-operation"},verifyCommand:"npx workspai doctor project --json"}}}}var Ce=[{id:"runtime-missing",diseaseClass:"runtime",description:"Required runtime is absent.",probe:w({id:"runtime-missing",label:"Runtime missing",issueClass:"runtime"}),expected:{finding:true,domain:"runtime",status:"blocking",diagnosisState:"candidate",repairDisposition:"unavailable"}},{id:"dependencies-missing",diseaseClass:"dependency",description:"Installed dependency tree is absent.",probe:w({id:"dependencies-missing",label:"Dependencies missing",issueClass:"dependency",repair:"automatic",confidence:"high"}),expected:{finding:true,domain:"dependency",status:"blocking",diagnosisState:"confirmed",repairDisposition:"automatic"}},{id:"security-advisory",diseaseClass:"security",description:"A runtime-native audit reports a blocking advisory.",probe:w({id:"security-advisory",label:"Security advisory",issueClass:"security",repair:"approval-required",confidence:"high"}),expected:{finding:true,domain:"security",status:"blocking",diagnosisState:"confirmed",repairDisposition:"approval-required"}},{id:"environment-contract",diseaseClass:"configuration",description:"Environment/configuration contract is incomplete.",probe:w({id:"environment-contract",label:"Environment contract incomplete",issueClass:"environment",severity:"warn",repair:"manual"}),expected:{finding:true,domain:"configuration",status:"advisory",diagnosisState:"candidate",repairDisposition:"manual"}},{id:"container-contract",diseaseClass:"configuration",description:"Container delivery contract is incomplete.",probe:w({id:"container-contract",label:"Container contract incomplete",issueClass:"container",severity:"warn"}),expected:{finding:true,domain:"configuration",status:"advisory",diagnosisState:"candidate",repairDisposition:"unavailable"}},{id:"tests-missing",diseaseClass:"test",description:"No deterministic test surface is declared.",probe:w({id:"tests-missing",label:"Tests missing",issueClass:"test",severity:"warn",repair:"manual"}),expected:{finding:true,domain:"test",status:"advisory",diagnosisState:"candidate",repairDisposition:"manual"}},{id:"quality-missing",diseaseClass:"quality",description:"No lint/format/static-analysis surface is declared.",probe:w({id:"quality-missing",label:"Quality tooling missing",issueClass:"quality",severity:"warn"}),expected:{finding:true,domain:"quality",status:"advisory",diagnosisState:"candidate",repairDisposition:"unavailable"}},{id:"stale-evidence",diseaseClass:"freshness",description:"Evidence is stale and must not be treated as confirmed.",probe:{...w({id:"stale-evidence",label:"Stale evidence",issueClass:"security"}),freshness:{status:"stale",verifyBeforeUse:true}},expected:{finding:true,domain:"security",status:"blocking",diagnosisState:"unknown",repairDisposition:"unavailable"}},{id:"unknown-disease",diseaseClass:"unknown",description:"A real symptom cannot be bound to a typed disease class.",probe:w({id:"unknown-disease",label:"Unknown disease",issueClass:"unknown"}),expected:{finding:true,status:"blocking",diagnosisState:"unknown",repairDisposition:"unavailable"}},{id:"healthy-runtime",diseaseClass:"healthy-control",description:"Healthy evidence must not become a finding.",probe:{id:"healthy-runtime",label:"Healthy runtime",status:"pass",severity:"info",reason:"Runtime evidence is healthy.",issueClass:"runtime",operationalImpact:"none"},expected:{finding:false,domain:"runtime"}}];function _(e){return Math.round(e*1e4)/1e4}function ee(){let i=P().list(),t=i.flatMap(o=>Ce.map(d=>{let O=o.runtimeFamilies[0]??"unknown",g=o.frameworks[0]??"Unknown",k=Z({projectName:`validation-${o.id}-${d.id}`,projectPath:`/virtual/doctor-validation/${o.id}/${d.id}`,runtimeFamily:O,framework:g,projectKind:"generic",probes:[d.probe]}),b=k.findings.find(x=>x.probeId===d.probe.id),N=k.domains.find(x=>x.observationCount>0)?.id,v={finding:!!b,...N?{domain:N}:{},...b?.status?{status:b.status}:{},...b?.diagnosisState?{diagnosisState:b.diagnosisState}:{},...b?.repair.disposition?{repairDisposition:b.repair.disposition}:{}},y=[];return v.finding!==d.expected.finding&&y.push("finding-presence"),d.expected.domain&&v.domain!==d.expected.domain&&y.push("domain"),d.expected.status&&v.status!==d.expected.status&&y.push("status"),d.expected.diagnosisState&&v.diagnosisState!==d.expected.diagnosisState&&y.push("diagnosis-state"),d.expected.repairDisposition&&v.repairDisposition!==d.expected.repairDisposition&&y.push("repair-disposition"),k.capability.adapterId!==o.id&&y.push("adapter-binding"),{id:`${o.id}:${d.id}`,passed:y.length===0,expected:d.expected,actual:v,failures:y}})),s=t.filter(o=>o.expected.finding),r=t.filter(o=>!o.expected.finding),c$1=s.filter(o=>o.actual.finding).length,a=s.length-c$1,p=r.filter(o=>!o.actual.finding).length,m=r.length-p,C=new Set(t.map(o=>o.actual.domain).filter(o=>!!o));return {schemaVersion:c,corpusVersion:d,capabilityRegistryVersion:b,scope:"synthetic-contract-corpus",summary:{totalCases:t.length,passedCases:t.filter(o=>o.passed).length,failedCases:t.filter(o=>!o.passed).length,truePositives:c$1,trueNegatives:p,falsePositives:m,falseNegatives:a,precision:_(c$1/Math.max(1,c$1+m)),recall:_(c$1/Math.max(1,c$1+a)),domainCoverage:_(C.size/D.length),runtimeAdapterCoverage:_(new Set(t.map(o=>o.id.split(":",1)[0])).size/Math.max(1,i.length)),runtimeAdaptersExercised:i.length,declaredPlatforms:new Set(i.flatMap(o=>o.platforms)).size},cases:t,limitations:["Precision and recall describe the versioned synthetic contract corpus, not every public repository.","Every registered runtime adapter is exercised against the same disease corpus; this proves contract behavior, not tool availability on a host.","Runtime-native fixture and real Linux, macOS, and Windows acceptance gates remain separate evidence surfaces."]}}async function Qe(e$1={}){let i=K({runtime:e$1.runtime,framework:e$1.framework}),t=e$1.validate?ee():void 0,s,r;if(e$1.write){let a=e$1.workspace?pe.resolve(e$1.workspace):a$1(process.cwd());if(!a)return e$1.json?console.log(JSON.stringify({schemaVersion:i.schemaVersion,status:"error",error:{code:"doctor.capabilities.workspace-not-found",message:"--write requires a Workspai workspace or --workspace <path>."}},null,2)):console.log(h.red("Doctor capabilities could not be written: no workspace found.")),1;let p=K();s=await e(a,h$1.doctorCapabilities.artifactPath,p),t&&(r=await e(a,h$1.doctorValidation.artifactPath,t));}let c={...i,...t?{validation:t}:{},...s?{artifactPath:s}:{},...r?{validationArtifactPath:r}:{}};if(e$1.json)e$1.quiet||console.log(JSON.stringify(c,null,2));else if(!e$1.quiet){console.log(h.bold.cyan(`
|
|
1
|
+
import {a as a$1}from'./chunk-QJCCZLOF.js';import {a}from'./chunk-NS53IPAC.js';import {e}from'./chunk-CCDGHPEJ.js';import {h as h$1,b,a as a$2,d,c}from'./chunk-NZ3WZYD5.js';import pe from'path';import h from'chalk';import {createHash}from'crypto';var F="workspai.doctor-adapter.v1",D=["runtime","dependency","security","configuration","test","quality"];function A(e){return e.trim().toLowerCase().replace(/[^a-z0-9+.#-]+/g,"-")}function ae(e){if(e.contractVersion!==F)throw new Error(`Unsupported Doctor adapter contract: ${e.contractVersion}`);if(!e.id.trim())throw new Error("Doctor adapter id must not be empty.");if(e.runtimeFamilies.length===0)throw new Error(`Doctor adapter ${e.id} must own at least one runtime family.`);if(e.platforms.length===0)throw new Error(`Doctor adapter ${e.id} must declare supported platforms.`);let i=e.domains.map(t=>t.domain);if(i.length!==D.length||new Set(i).size!==D.length||D.some(t=>!i.includes(t)))throw new Error(`Doctor adapter ${e.id} must declare every canonical diagnostic domain exactly once.`);for(let t of e.domains)if(t.level==="unsupported"&&t.limitations.length===0)throw new Error(`Doctor adapter ${e.id} must explain unsupported ${t.domain} coverage.`)}var $=class{#e=new Map;#i=new Map;#t=new Map;register(i){ae(i);let t=A(i.id);if(this.#e.has(t))throw new Error(`Doctor adapter id is already registered: ${i.id}`);let s=[...i.runtimeFamilies,...i.aliases].map(A);for(let c of s){let a=this.#i.get(c);if(a)throw new Error(`Doctor runtime ${c} is already owned by adapter ${a}.`)}for(let c of i.frameworks.map(A)){let a=this.#t.get(c);if(a)throw new Error(`Doctor framework ${c} is already owned by adapter ${a}.`)}let r=structuredClone(i);this.#e.set(t,r);for(let c of s)this.#i.set(c,t);for(let c of i.frameworks.map(A))this.#t.set(c,t);return this}resolveWithDiagnostics(i){let t=i.runtimeFamily?this.#i.get(A(i.runtimeFamily)):void 0,s=i.framework?this.#t.get(A(i.framework)):void 0;if(t&&s&&t!==s)return {status:"conflict",descriptor:null,runtimeOwner:t,frameworkOwner:s};let r=t??s;return {status:r?"matched":"unresolved",descriptor:r?structuredClone(this.#e.get(r)??null):null,...t?{runtimeOwner:t}:{},...s?{frameworkOwner:s}:{}}}resolve(i){return this.resolveWithDiagnostics(i).descriptor}list(){return [...this.#e.values()].map(i=>structuredClone(i)).sort((i,t)=>i.id.localeCompare(t.id))}};var Y=[...D],W=["linux","darwin","win32"],re=[{id:"node",aliases:["nodejs","javascript","typescript"],frameworks:["NestJS","Next.js","Remix","Nuxt","React","Vue","Angular","SvelteKit","Svelte","Vite","Astro","Solid","Express","Fastify","Koa","Electron","VS Code Extension"],tier:"first-class",native:Y},{id:"python",aliases:["py"],frameworks:["FastAPI","Django","Flask","Python"],tier:"first-class",native:Y},{id:"go",aliases:["golang"],frameworks:["Go","Go/Fiber","Go/Gin","Echo"],tier:"first-class",native:["runtime","dependency","test","quality"],portable:["security","configuration"]},{id:"java",aliases:["jvm"],frameworks:["Java","Spring Boot"],tier:"first-class",native:["runtime","dependency","test","quality"],portable:["security","configuration"]},{id:"dotnet",aliases:[".net","csharp","c#"],frameworks:["ASP.NET"],tier:"first-class",native:["runtime","dependency","test","quality"],portable:["security","configuration"]},{id:"rust",aliases:["cargo"],frameworks:["Rust","Axum"],tier:"first-class",native:["runtime","dependency","test","quality"],portable:["security","configuration"]},{id:"php",aliases:["composer"],frameworks:["PHP","Laravel"],tier:"first-class",native:["runtime","dependency","security"],portable:["configuration","test","quality"]},{id:"ruby",aliases:["bundler"],frameworks:["Ruby","Ruby on Rails"],tier:"extended",portable:["runtime","dependency","configuration","test","quality"],observable:["security"]},{id:"elixir",aliases:["beam"],frameworks:["Elixir","Phoenix"],tier:"extended",portable:["runtime","dependency","configuration","test","quality"],observable:["security"]},{id:"clojure",frameworks:["Clojure"],tier:"extended",portable:["runtime","dependency","configuration","test","quality"],observable:["security"]},{id:"deno",frameworks:["Deno"],tier:"extended",portable:["runtime","dependency","configuration","test","quality"],observable:["security"]},{id:"bun",frameworks:["Bun"],tier:"extended",portable:["runtime","dependency","configuration","test","quality"],observable:["security"]},{id:"scala",frameworks:["Scala"],tier:"extended",portable:["runtime","dependency","configuration","test","quality"],observable:["security"]},{id:"kotlin",frameworks:["Kotlin"],tier:"extended",portable:["runtime","dependency","configuration","test","quality"],observable:["security"]},{id:"c",aliases:["c-lang"],frameworks:["C"],tier:"extended",portable:["runtime","dependency","test","quality"],observable:["configuration"],limitations:["Security diagnosis requires a declared native scanner or workspace adapter."]},{id:"cpp",aliases:["c++","cplusplus"],frameworks:["C++"],tier:"extended",portable:["runtime","dependency","test","quality"],observable:["configuration"],limitations:["Security diagnosis requires a declared native scanner or workspace adapter."]}];function oe(e,i){let t={runtime:["project markers","entrypoints","toolchain evidence"],dependency:["dependency manifests","lockfiles","installed-tree evidence"],security:["runtime-native audit","advisory evidence"],configuration:["environment contracts","deployment/container markers"],test:["test scripts","test configuration","coverage evidence"],quality:["lint/format/static-analysis contracts"]};return [`${e} adapter`,...t[i]]}function ce(e,i){return e.native?.includes(i)?"native":e.portable?.includes(i)?"portable":e.observable?.includes(i)?"observable":"unsupported"}function le(e){let i=D.map(t=>{let s=ce(e,t);return {domain:t,level:s,evidenceSources:s==="unsupported"?[]:oe(e.id,t),limitations:s==="unsupported"?[`${e.id} has no built-in ${t} provider; declare a workspace adapter.`]:s==="observable"?[`${t} evidence is observable but not runtime-native for ${e.id}.`]:[]}});return {contractVersion:F,id:`builtin.${e.id}`,runtimeFamilies:[e.id],aliases:e.aliases??[],frameworks:e.frameworks,projectKinds:["backend","frontend","desktop","extension","fullstack","generic"],tier:e.tier,platforms:[...W],domains:i,repairModes:["typed-operation","structured-invocation","manual-guidance"],source:"builtin",limitations:e.limitations??[]}}function de(){return {contractVersion:F,id:"builtin.unknown",runtimeFamilies:["unknown"],aliases:["generic","unrecognized"],frameworks:["Unknown"],projectKinds:["backend","frontend","desktop","extension","fullstack","generic"],tier:"fallback",platforms:[...W],domains:D.map(e=>({domain:e,level:e==="security"?"unsupported":"observable",evidenceSources:e==="security"?[]:["portable workspace markers","declared custom checks"],limitations:[e==="security"?"No safe security claim is possible without a runtime-native audit provider.":`Only portable ${e} evidence is available until a runtime adapter is registered.`]})),repairModes:["manual-guidance"],source:"builtin",limitations:["Unknown runtimes are fail-closed: missing domain evidence is reported as unknown, never healthy.","Automatic repair is unavailable until a typed adapter owns the runtime."]}}function P(){let e=new $;for(let i of re)e.register(le(i));return e.register(de()),e}function J(e,i=P()){let t=i.resolveWithDiagnostics(e),s=t.descriptor??i.resolve({runtimeFamily:"unknown"});if(!s)throw new Error("Doctor fallback adapter is not registered.");let r=c=>s.domains.filter(a=>a.level===c).map(a=>a.domain);return {registryVersion:b,adapterId:s.id,runtimeFamily:s.runtimeFamilies[0]??"unknown",tier:s.tier,confidence:s.tier==="first-class"?"high":s.tier==="extended"?"medium":"low",nativeDomains:r("native"),portableDomains:r("portable"),observableDomains:r("observable"),unsupportedDomains:r("unsupported"),limitations:[...t.status==="conflict"?[`Runtime/framework ownership conflict (${t.runtimeOwner} vs ${t.frameworkOwner}); Doctor failed closed instead of selecting an ambiguous adapter.`]:[],...s.limitations,...s.domains.flatMap(c=>c.limitations)]}}function K(e={}){let i=P(),t=i.list(),s=i.resolveWithDiagnostics({runtimeFamily:e.runtime,framework:e.framework}),r=e.runtime||e.framework?[s.descriptor]:t;if((e.runtime||e.framework)&&!r[0]){let a=i.resolve({runtimeFamily:"unknown"});a&&(s.status==="conflict"&&a.limitations.unshift(`Runtime/framework ownership conflict (${s.runtimeOwner} vs ${s.frameworkOwner}); Doctor failed closed instead of selecting an ambiguous adapter.`),r[0]=a);}let c=r.filter(a=>!!a);return {schemaVersion:a$2,registryVersion:b,generatedBy:"workspai",policy:{unknownIsHealthy:false,unsupportedIsHealthy:false,repairRequiresTypedOperation:true,canonicalDomains:[...D]},summary:{adapterCount:c.length,firstClassRuntimes:c.filter(a=>a.tier==="first-class").length,extendedRuntimes:c.filter(a=>a.tier==="extended").length,fallbackRuntimes:c.filter(a=>a.tier==="fallback").length,frameworkCount:new Set(c.flatMap(a=>a.frameworks)).size,platformCount:new Set(c.flatMap(a=>a.platforms)).size},adapters:c}}var me=["runtime","dependency","security","configuration","test","quality"];function I(e){return createHash("sha256").update(e).digest("hex").slice(0,12)}function S(e){return e.trim().toLowerCase().replace(/[^a-z0-9._-]+/g,"-").replace(/^-+|-+$/g,"")||"unknown"}function Q(e){return e.trim().toLowerCase().replace(/[^a-z0-9]+/g," ").replace(/\s+/g," ").trim()}function ge(e,i){let t=Q(e);return t?i.some(s=>[s.reason,s.recommendation??""].map(Q).filter(Boolean).some(c=>c===t||c.includes(t)||t.includes(c))):true}function fe(e){return e.status==="fail"?"blocking":e.status==="warn"?"advisory":"informational"}function X(e){return e.issueClass==="dependency"?"dependency":e.issueClass==="security"?"security":e.issueClass==="environment"||e.issueClass==="configuration"||e.issueClass==="container"||e.issueClass==="deployment"||e.issueClass==="workspace-contract"?"configuration":e.issueClass==="test"?"test":e.issueClass==="quality"||e.issueClass==="custom"?"quality":e.issueClass==="runtime"||e.issueClass==="framework"||e.issueClass==="source-tree"?"runtime":null}function ye(e,i){return me.map(t=>{let s=e.filter(o=>X(o)===t),r=e.filter(o=>o.applicability!=="not-applicable"&&X(o)===t),c=i.unsupportedDomains.includes(t);if(r.length===0){let o=s.some(d=>d.applicability==="not-applicable");return {id:t,status:o?"not-applicable":"not-run",observationCount:0,blockingFindings:0,advisoryFindings:0,reason:o?`${t} checks ran and found no declared intent requiring this domain.`:c?`${t} is unsupported by Doctor adapter ${i.adapterId}; no healthy claim is allowed.`:`No ${t} diagnostic observation was produced.`}}let a=r.some(o=>o.freshness?.status==="stale"||o.freshness?.status==="unknown"),p=r.filter(o=>o.status==="fail").length,m=r.filter(o=>o.status==="warn").length,C=p>0||m>0;return {id:t,status:a?"stale":C?"findings":c?"not-run":"clean",observationCount:r.length,blockingFindings:p,advisoryFindings:m,reason:a?`${t} evidence is stale or has unknown freshness.`:C?`${t} diagnostics produced findings.`:c?`${t} observations cannot establish complete health because adapter ${i.adapterId} declares the domain unsupported.`:`${t} diagnostics completed without findings.`}})}function De(e){if(e.status==="pass")return "not-needed";let i=e.repairCapability;return i?i.status==="manual"||i.requiresReview?"manual":i.status!=="available"||!i.canAutoFix?"unavailable":i.requiresApproval?"approval-required":"automatic":"unavailable"}function be(e){if(e.freshness?.status==="stale"||e.freshness?.status==="unknown")return {label:"low",score:.35,state:"unknown"};let i=!!(e.issueClass&&e.issueClass!=="unknown"),t=!!(e.repairCapability?.operation?.type||e.repairCapability?.invocation?.executable);return i&&t&&e.repairIntent?.confidence==="high"?{label:"high",score:.95,state:"confirmed"}:i&&(e.status==="fail"||e.status==="warn")?{label:"medium",score:t?.82:.68,state:"candidate"}:e.status==="pass"?{label:"high",score:.98,state:"confirmed"}:{label:"low",score:.3,state:"unknown"}}function ve(e,i){let t=[{kind:"probe",role:"observation",ref:`probe:${e.id}`,claim:e.reason}];for(let r of e.repairCapability?.files??[])t.push({kind:"file",role:"repair-target",ref:r.split(pe.sep).join("/"),claim:"Structured repair capability declared this path as an affected target."});if(e.repairCapability?.invocation?.executable){let r=e.repairCapability.invocation;t.push({kind:"command",role:"verification",ref:[r.executable,...r.args??[]].join(" "),claim:"Structured command invocation is available for this diagnostic path."});}if(e.issueClass==="security"&&/(?:dependency|audit|vulnerab|security-hygiene)/i.test(`${e.id} ${e.label}`))for(let r of i??[])t.push({kind:"dependency",role:"subject",ref:r.version?`${r.name}@${r.version}`:r.name,claim:r.advisoryIds&&r.advisoryIds.length>0?`Dependency is referenced by ${r.advisoryIds.join(", ")}.`:"Dependency is present in security audit evidence."});return t}function we(e,i){let t=i.issueClass?.trim()||"unknown",s=be(i);return {id:`${S(i.id)}:${I(`${e.projectPath}\0${i.id}`)}`,causalKey:[S(e.projectName),I(e.projectPath),S(t),S(i.id)].join(":"),projectName:e.projectName,projectPath:e.projectPath,probeId:i.id,label:i.label,status:fe(i),severity:i.severity,issueClass:t,operationalImpact:i.operationalImpact?.trim()||"developer-friction",applicability:i.applicability??"applicable",confidence:s.label,confidenceScore:s.score,diagnosisState:s.state,symptom:i.reason,...i.recommendation?{recommendation:i.recommendation}:{},proofs:ve(i,e.dependencySubjects),repair:{disposition:De(i),...i.repairCapability?.id?{capabilityId:i.repairCapability.id}:{},...i.repairCapability?.operation?.type?{operationType:i.repairCapability.operation.type}:{},...i.repairCapability?.verifyCommand?{verifyCommand:i.repairCapability.verifyCommand}:{},requiresFreshEvidence:i.repairIntent?.requiresFreshEvidence===true||i.freshness?.verifyBeforeUse===true}}}function he(e,i,t){let s=`legacy-runtime-issue-${t+1}`;return {id:`${s}:${I(`${e.projectPath}\0${i}`)}`,causalKey:[S(e.projectName),I(e.projectPath),"unknown",I(i)].join(":"),projectName:e.projectName,projectPath:e.projectPath,probeId:s,label:"Runtime diagnostic issue",status:"blocking",severity:"error",issueClass:"unknown",operationalImpact:"runtime-risk",applicability:"applicable",confidence:"low",confidenceScore:.25,diagnosisState:"unknown",symptom:i,proofs:[{kind:"unknown",role:"observation",ref:`legacy-issue:${t+1}`,claim:i}],repair:{disposition:"unavailable",requiresFreshEvidence:true}}}function Z(e){let i=[...e.probes],t=[...new Set((e.runtimeFamilies&&e.runtimeFamilies.length>0?e.runtimeFamilies:[e.runtimeFamily??"unknown"]).filter(Boolean))],s=e.runtimeFamily??t[0]??"unknown",r=t.filter(n=>n!==s&&n!=="unknown"),c=J({runtimeFamily:e.runtimeFamily,framework:e.framework},e.adapterRegistry),a$1=ye(i,c),p=(e.legacyIssues??[]).filter(n=>!ge(n,i)),m=new Map;for(let n of i){let l=m.get(n.id)??new Set;l.add(n.status),m.set(n.id,l);}let C=[...m.entries()].filter(([,n])=>n.size>1).map(([n,l])=>({probeId:n,statuses:[...l].sort(),reason:"The same diagnostic probe produced contradictory states in one project scan."})),o=[...i.filter(n=>n.applicability!=="not-applicable"&&n.status!=="pass").map(n=>we(e,n)),...p.map((n,l)=>he(e,n,l))],d={blocking:4,unknown:3,advisory:2,informational:1},O=new Map;for(let n of o){let l=O.get(n.causalKey)??[];l.push(n),O.set(n.causalKey,l);}let g=[...O.values()].map(n=>{let u=[...n].sort((f,j)=>d[j.status]-d[f.status]||j.confidenceScore-f.confidenceScore||f.id.localeCompare(j.id)).at(0);if(!u)throw new Error("Doctor diagnosis causal group cannot be empty.");let G=structuredClone(u);return G.proofs=[...new Map(n.flatMap(f=>f.proofs).map(f=>[`${f.kind}:${f.role}:${f.ref}:${f.claim}`,f])).values()],G}).sort((n,l)=>n.causalKey.localeCompare(l.causalKey)||n.id.localeCompare(l.id)),k=new Map;for(let n of g){let l=k.get(n.causalKey)??[];l.push(n),k.set(n.causalKey,l);}let b=[...k.entries()].map(([n,l])=>({causalKey:n,issueClass:l[0]?.issueClass??"unknown",status:l.some(u=>u.status==="blocking")?"blocking":l.some(u=>u.status==="advisory")?"advisory":l.some(u=>u.status==="unknown")?"unknown":"informational",findingIds:l.map(u=>u.id),projectPaths:[...new Set(l.map(u=>u.projectPath))],repairable:l.some(u=>u.repair.disposition==="automatic"||u.repair.disposition==="approval-required")})),v=[...g.filter(n=>n.diagnosisState==="unknown"||n.issueClass==="unknown"||n.applicability==="unknown").map(n=>({id:`unknown:${n.id}`,probeId:n.probeId,reason:n.issueClass==="unknown"?"The observation is real, but Doctor cannot yet bind it to a typed issue class.":"Evidence is insufficient or stale for a confirmed diagnosis."})),...a$1.filter(n=>n.status==="not-run"||n.status==="stale").map(n=>({id:`unknown:domain:${n.id}:${I(e.projectPath)}`,reason:n.reason})),...r.map(n=>({id:`unknown:runtime:${S(n)}:${I(e.projectPath)}`,reason:e.projectArchetype==="platform"?`${n} is part of this cross-language platform, but only portable evidence and the primary ${s} runtime adapter were evaluated. Add a typed ${n} adapter before making runtime-specific health claims.`:`${n} was detected inside this composite project boundary, but the ${s} adapter is the only runtime-specific adapter evaluated for this scan. Declare a nested project boundary or a typed Doctor adapter before treating ${n} as healthy.`}))],y=g.filter(n=>n.diagnosisState!=="unknown").length,x=g.length===0?100:y/g.length*100,ie=a$1.filter(n=>n.status!=="not-run"&&n.status!=="stale").length/a$1.length*100,U=t.filter(n=>n!=="unknown").length,te=s!=="unknown"&&t.includes(s)?1:0,ne=U===0?0:te/U*100,se=Math.round(Math.min(x,ie,ne)*100)/100;return {schemaVersion:a,engineVersion:"universal-diagnosis-v1",project:{name:e.projectName,path:e.projectPath,runtimeFamily:e.runtimeFamily??"unknown",runtimeFamilies:t,framework:e.framework??"Unknown",projectKind:e.projectKind??"generic"},capability:c,domains:a$1,coverage:{totalObservations:i.length+p.length,evaluatedObservations:i.filter(n=>n.applicability!=="not-applicable").length,passingObservations:i.filter(n=>n.applicability!=="not-applicable"&&n.status==="pass").length,blockingFindings:g.filter(n=>n.status==="blocking").length,advisoryFindings:g.filter(n=>n.status==="advisory").length,unknownFindings:v.length,repairableFindings:g.filter(n=>n.repair.disposition==="automatic"||n.repair.disposition==="approval-required").length,manualFindings:g.filter(n=>n.repair.disposition==="manual").length,unsupportedFindings:g.filter(n=>n.repair.disposition==="unavailable").length,contradictionCount:C.length,diagnosisCompleteness:se},findings:g,causalGroups:b,unknowns:v,contradictions:C}}function w(e){let i=e.severity??"error",t=e.repair??"unavailable";return {id:e.id,label:e.label,status:i==="error"?"fail":"warn",severity:i,reason:`${e.label} detected by the validation corpus.`,issueClass:e.issueClass,operationalImpact:i==="error"?"release-risk":"ci-risk",repairIntent:{confidence:e.confidence??"medium",requiresFreshEvidence:true},...t==="unavailable"?{}:{repairCapability:{id:`repair.${e.id}`,status:t==="manual"?"manual":"available",canAutoFix:t==="automatic"||t==="approval-required",requiresApproval:t==="approval-required",requiresReview:t==="manual",operation:{type:"validation-operation"},verifyCommand:"npx workspai doctor project --json"}}}}var Ce=[{id:"runtime-missing",diseaseClass:"runtime",description:"Required runtime is absent.",probe:w({id:"runtime-missing",label:"Runtime missing",issueClass:"runtime"}),expected:{finding:true,domain:"runtime",status:"blocking",diagnosisState:"candidate",repairDisposition:"unavailable"}},{id:"dependencies-missing",diseaseClass:"dependency",description:"Installed dependency tree is absent.",probe:w({id:"dependencies-missing",label:"Dependencies missing",issueClass:"dependency",repair:"automatic",confidence:"high"}),expected:{finding:true,domain:"dependency",status:"blocking",diagnosisState:"confirmed",repairDisposition:"automatic"}},{id:"security-advisory",diseaseClass:"security",description:"A runtime-native audit reports a blocking advisory.",probe:w({id:"security-advisory",label:"Security advisory",issueClass:"security",repair:"approval-required",confidence:"high"}),expected:{finding:true,domain:"security",status:"blocking",diagnosisState:"confirmed",repairDisposition:"approval-required"}},{id:"environment-contract",diseaseClass:"configuration",description:"Environment/configuration contract is incomplete.",probe:w({id:"environment-contract",label:"Environment contract incomplete",issueClass:"environment",severity:"warn",repair:"manual"}),expected:{finding:true,domain:"configuration",status:"advisory",diagnosisState:"candidate",repairDisposition:"manual"}},{id:"container-contract",diseaseClass:"configuration",description:"Container delivery contract is incomplete.",probe:w({id:"container-contract",label:"Container contract incomplete",issueClass:"container",severity:"warn"}),expected:{finding:true,domain:"configuration",status:"advisory",diagnosisState:"candidate",repairDisposition:"unavailable"}},{id:"tests-missing",diseaseClass:"test",description:"No deterministic test surface is declared.",probe:w({id:"tests-missing",label:"Tests missing",issueClass:"test",severity:"warn",repair:"manual"}),expected:{finding:true,domain:"test",status:"advisory",diagnosisState:"candidate",repairDisposition:"manual"}},{id:"quality-missing",diseaseClass:"quality",description:"No lint/format/static-analysis surface is declared.",probe:w({id:"quality-missing",label:"Quality tooling missing",issueClass:"quality",severity:"warn"}),expected:{finding:true,domain:"quality",status:"advisory",diagnosisState:"candidate",repairDisposition:"unavailable"}},{id:"stale-evidence",diseaseClass:"freshness",description:"Evidence is stale and must not be treated as confirmed.",probe:{...w({id:"stale-evidence",label:"Stale evidence",issueClass:"security"}),freshness:{status:"stale",verifyBeforeUse:true}},expected:{finding:true,domain:"security",status:"blocking",diagnosisState:"unknown",repairDisposition:"unavailable"}},{id:"unknown-disease",diseaseClass:"unknown",description:"A real symptom cannot be bound to a typed disease class.",probe:w({id:"unknown-disease",label:"Unknown disease",issueClass:"unknown"}),expected:{finding:true,status:"blocking",diagnosisState:"unknown",repairDisposition:"unavailable"}},{id:"healthy-runtime",diseaseClass:"healthy-control",description:"Healthy evidence must not become a finding.",probe:{id:"healthy-runtime",label:"Healthy runtime",status:"pass",severity:"info",reason:"Runtime evidence is healthy.",issueClass:"runtime",operationalImpact:"none"},expected:{finding:false,domain:"runtime"}}];function _(e){return Math.round(e*1e4)/1e4}function ee(){let i=P().list(),t=i.flatMap(o=>Ce.map(d=>{let O=o.runtimeFamilies[0]??"unknown",g=o.frameworks[0]??"Unknown",k=Z({projectName:`validation-${o.id}-${d.id}`,projectPath:`/virtual/doctor-validation/${o.id}/${d.id}`,runtimeFamily:O,framework:g,projectKind:"generic",probes:[d.probe]}),b=k.findings.find(x=>x.probeId===d.probe.id),N=k.domains.find(x=>x.observationCount>0)?.id,v={finding:!!b,...N?{domain:N}:{},...b?.status?{status:b.status}:{},...b?.diagnosisState?{diagnosisState:b.diagnosisState}:{},...b?.repair.disposition?{repairDisposition:b.repair.disposition}:{}},y=[];return v.finding!==d.expected.finding&&y.push("finding-presence"),d.expected.domain&&v.domain!==d.expected.domain&&y.push("domain"),d.expected.status&&v.status!==d.expected.status&&y.push("status"),d.expected.diagnosisState&&v.diagnosisState!==d.expected.diagnosisState&&y.push("diagnosis-state"),d.expected.repairDisposition&&v.repairDisposition!==d.expected.repairDisposition&&y.push("repair-disposition"),k.capability.adapterId!==o.id&&y.push("adapter-binding"),{id:`${o.id}:${d.id}`,passed:y.length===0,expected:d.expected,actual:v,failures:y}})),s=t.filter(o=>o.expected.finding),r=t.filter(o=>!o.expected.finding),c$1=s.filter(o=>o.actual.finding).length,a=s.length-c$1,p=r.filter(o=>!o.actual.finding).length,m=r.length-p,C=new Set(t.map(o=>o.actual.domain).filter(o=>!!o));return {schemaVersion:c,corpusVersion:d,capabilityRegistryVersion:b,scope:"synthetic-contract-corpus",summary:{totalCases:t.length,passedCases:t.filter(o=>o.passed).length,failedCases:t.filter(o=>!o.passed).length,truePositives:c$1,trueNegatives:p,falsePositives:m,falseNegatives:a,precision:_(c$1/Math.max(1,c$1+m)),recall:_(c$1/Math.max(1,c$1+a)),domainCoverage:_(C.size/D.length),runtimeAdapterCoverage:_(new Set(t.map(o=>o.id.split(":",1)[0])).size/Math.max(1,i.length)),runtimeAdaptersExercised:i.length,declaredPlatforms:new Set(i.flatMap(o=>o.platforms)).size},cases:t,limitations:["Precision and recall describe the versioned synthetic contract corpus, not every public repository.","Every registered runtime adapter is exercised against the same disease corpus; this proves contract behavior, not tool availability on a host.","Runtime-native fixture and real Linux, macOS, and Windows acceptance gates remain separate evidence surfaces."]}}async function Qe(e$1={}){let i=K({runtime:e$1.runtime,framework:e$1.framework}),t=e$1.validate?ee():void 0,s,r;if(e$1.write){let a=e$1.workspace?pe.resolve(e$1.workspace):a$1(process.cwd());if(!a)return e$1.json?console.log(JSON.stringify({schemaVersion:i.schemaVersion,status:"error",error:{code:"doctor.capabilities.workspace-not-found",message:"--write requires a Workspai workspace or --workspace <path>."}},null,2)):console.log(h.red("Doctor capabilities could not be written: no workspace found.")),1;let p=K();s=await e(a,h$1.doctorCapabilities.artifactPath,p),t&&(r=await e(a,h$1.doctorValidation.artifactPath,t));}let c={...i,...t?{validation:t}:{},...s?{artifactPath:s}:{},...r?{validationArtifactPath:r}:{}};if(e$1.json)e$1.quiet||console.log(JSON.stringify(c,null,2));else if(!e$1.quiet){console.log(h.bold.cyan(`
|
|
2
2
|
\u{1FA7A} Workspai Doctor capabilities
|
|
3
3
|
`)),console.log(`${i.summary.adapterCount} adapter(s) \xB7 ${i.summary.frameworkCount} framework mapping(s) \xB7 ${i.summary.platformCount} platform(s)`);for(let a of i.adapters){let p=a.domains.map(m=>`${m.domain}:${m.level}`).join(" \xB7 ");console.log(h.bold(`
|
|
4
4
|
${a.runtimeFamilies.join(", ")} \xB7 ${a.tier}`)),console.log(h.gray(p));for(let m of a.limitations)console.log(h.yellow(` ! ${m}`));}if(t){let a=t.summary,p=a.failedCases===0?h.green:h.red;console.log(p(`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import {h}from'./chunk-
|
|
1
|
+
import {h}from'./chunk-NZ3WZYD5.js';var i=h.doctorFixResult.schemaVersion,n="npx workspai workspace verify --from-impact .workspai/reports/workspace-impact-last-run.json --json";function a(t){return {schemaVersion:i,generatedAt:new Date().toISOString(),appliedFixes:t.appliedFixes,remainingBlockers:t.remainingBlockers,verifyRecommended:t.verifyRecommended??n}}var g="workspai.doctor-summary.v1";var m="doctor-graph-diagnosis.v1";export{i as a,n as b,a as c,m as d,g as e};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import {i as i$1,e}from'./chunk-
|
|
1
|
+
import {i as i$1,e}from'./chunk-NZ3WZYD5.js';var i=".workspai/skills";var _=e.skillsIndex,a=e.explain,P=i$1.workspaceWhy,O=i$1.workspaceTrace,c=".workspai/AGENT-GROUNDING.md",I=".rapidkit/AGENT-GROUNDING.md",A=".cursor/rules/workspai-grounding.mdc",T=".cursor/rules/rapidkit-grounding.mdc",E=".claude/rules/workspai-evidence.md",R=".claude/rules/rapidkit-evidence.md",L=".github/instructions/workspai-workspace.instructions.md",d=".github/instructions/rapidkit-workspace.instructions.md",S=".github/instructions/workspai-evidence.instructions.md",C=".github/instructions/rapidkit-evidence.instructions.md",k=".github/prompts/workspai-diagnose.prompt.md",N=".github/prompts/rapidkit-diagnose.prompt.md",l=".github/prompts/workspai-repair.prompt.md",m=".github/prompts/rapidkit-repair.prompt.md",u=".github/prompts/workspai-release-readiness.prompt.md",g=".github/prompts/rapidkit-release-readiness.prompt.md",K=".github/prompts/workspai-project-onboard.prompt.md",G=".github/prompts/rapidkit-project-onboard.prompt.md",x=".github/prompts/workspai-adopt-project.prompt.md",w=".github/prompts/rapidkit-adopt-project.prompt.md",H=".github/skills/workspai-grounding/SKILL.md",D=".github/skills/rapidkit-grounding/SKILL.md",W=".github/skills/workspai-workspace-intelligence/SKILL.md",h=".github/skills/rapidkit-workspace-intelligence/SKILL.md",U=i$1.workspaiMcpDesign,b=i$1.legacyMcpDesign,M=i$1.agentHooks,Y=".vscode/rapidkit-agent-hooks.json";function f(r){let s=r.trim();if(!s||s.includes("..")||s.includes("/"))throw new Error(`Invalid operational skill id: ${r}`);return `${i}/${s}.md`}var B={"workspai-diagnose-api-failure":"workspai-diagnose","workspai-release-readiness":"workspai-release-readiness","workspai-safe-schema-migration":"workspai-safe-schema-migration","workspai-dependency-upgrade":"workspai-dependency-upgrade","workspai-rename-contract":"workspai-rename-contract"};export{D as A,W as B,h as C,U as D,b as E,M as F,Y as G,f as H,B as I,i as a,_ as b,a as c,P as d,O as e,c as f,I as g,A as h,T as i,E as j,R as k,L as l,d as m,S as n,C as o,k as p,N as q,l as r,m as s,u as t,g as u,K as v,G as w,x,w as y,H as z};
|