workspai 0.55.0 → 0.56.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/contracts/artifact-remediation-plan.v1.json +110 -2
- package/contracts/cli-runtime-command-inventory.v1.snapshot.json +29 -1
- package/contracts/doctor-project-evidence.v1.json +68 -2
- package/contracts/doctor-remediation-plan.v1.json +29 -2
- package/contracts/doctor-workspace-evidence.v1.json +68 -2
- package/contracts/extension-cli-compatibility.v1.json +6 -1
- package/contracts/published-contract-catalog.v1.json +25 -0
- package/contracts/runtime-command-surface.v1.json +63 -0
- package/contracts/workspace-intelligence/doctor-capabilities.v1.json +133 -0
- package/contracts/workspace-intelligence/doctor-diagnosis.v1.json +273 -0
- package/contracts/workspace-intelligence/doctor-graph-diagnosis.v1.json +3 -0
- package/contracts/workspace-intelligence/doctor-receipt.v1.json +136 -0
- package/contracts/workspace-intelligence/doctor-summary.v1.json +99 -0
- package/contracts/workspace-intelligence/doctor-validation.v1.json +109 -0
- package/contracts/workspace-intelligence/project-context-agent.v1.json +110 -0
- package/contracts/workspace-intelligence/studio-blocker-handoff.v1.json +25 -0
- package/contracts/workspace-intelligence/workspace-explain.v1.json +3 -0
- package/contracts/workspace-intelligence/workspace-knowledge-graph.v1.json +36 -0
- package/contracts/workspace-intelligence/workspace-knowledge-search.v1.json +54 -0
- package/contracts/workspace-intelligence/workspace-repair-transaction.v1.json +27 -0
- package/contracts/workspace-repair-capabilities.v1.json +1 -0
- package/dist/analyze-HJ774J3E.js +1 -0
- package/dist/{artifact-remediation-plan-O3YIULQN.js → artifact-remediation-plan-BPLON5VX.js} +1 -1
- package/dist/autopilot-release-CH57CGET.js +1 -0
- package/dist/capabilities-command-WEOGFCWF.js +1 -0
- package/dist/chunk-2647BYBC.js +1 -0
- package/dist/chunk-2L4PSZQB.js +1 -0
- package/dist/chunk-3U4VLIGW.js +1 -0
- package/dist/chunk-5BGPGNRQ.js +2 -0
- package/dist/chunk-5EPPPMAS.js +1 -0
- package/dist/{chunk-M5ICGR55.js → chunk-5RL254O2.js} +1 -1
- package/dist/chunk-5ZA4JYOP.js +1 -0
- package/dist/{chunk-AMB42V2F.js → chunk-64JUYYRC.js} +1 -1
- package/dist/chunk-664GXRLD.js +1 -0
- package/dist/chunk-6HCAGHCY.js +8 -0
- package/dist/chunk-7PNARN6S.js +4 -0
- package/dist/chunk-7Y3KVZJF.js +8 -0
- package/dist/{chunk-WIO6L24E.js → chunk-ADL3CK44.js} +1 -1
- package/dist/chunk-AO2ZI42U.js +4 -0
- package/dist/chunk-BDN32Y2N.js +81 -0
- package/dist/chunk-D4RST2HE.js +1 -0
- package/dist/{chunk-6HJJHEL6.js → chunk-DIZSHNZ5.js} +1 -1
- package/dist/chunk-DOIZANFA.js +2 -0
- package/dist/{chunk-HY3RMPW5.js → chunk-E53BGUOW.js} +1 -1
- package/dist/{chunk-FZCYTRBQ.js → chunk-ESWFBSYM.js} +1 -1
- package/dist/chunk-GBMCHFOV.js +1 -0
- package/dist/{chunk-HUPLAFZQ.js → chunk-HASVV34S.js} +1 -1
- package/dist/chunk-IZLEMTES.js +1 -0
- package/dist/chunk-KR7CIEQR.js +1 -0
- package/dist/chunk-KS4FB5W7.js +6 -0
- package/dist/chunk-LYVDRRDO.js +2 -0
- package/dist/chunk-NHTLE3WN.js +1 -0
- package/dist/chunk-NS53IPAC.js +1 -0
- package/dist/{chunk-WZA5ISAQ.js → chunk-OX53L237.js} +6 -6
- package/dist/chunk-PKIRVQLG.js +1 -0
- package/dist/chunk-QAF26ZQX.js +36 -0
- package/dist/{chunk-NWQ5VWUW.js → chunk-QFCKHUEP.js} +1 -1
- package/dist/chunk-QRWWYL52.js +88 -0
- package/dist/chunk-QTCZPS5I.js +1 -0
- package/dist/{chunk-WSAFBPS5.js → chunk-SV2SP22H.js} +4 -4
- package/dist/chunk-T5YRFRJV.js +1 -0
- package/dist/chunk-UQEQ6CXU.js +1 -0
- package/dist/chunk-V5EYVQ63.js +1 -0
- package/dist/chunk-VGJVIHHR.js +1 -0
- package/dist/{chunk-MRFN5ZQP.js → chunk-W5ZFXKSL.js} +1 -1
- package/dist/chunk-WLCBXCZV.js +5 -0
- package/dist/chunk-WOTTSPSF.js +2 -0
- package/dist/chunk-X7FYEKLI.js +1 -0
- package/dist/chunk-XH7PDHBF.js +1 -0
- package/dist/{chunk-KFKZOPZC.js → chunk-XMTLKDPP.js} +1 -1
- package/dist/chunk-YJTEMJFV.js +3 -0
- package/dist/chunk-YM77FQB3.js +8 -0
- package/dist/chunk-ZCPT6KC3.js +6 -0
- package/dist/chunk-ZPA6ECBJ.js +7 -0
- package/dist/{create-3NSOY7CA.js → create-DLUWG46F.js} +1 -1
- package/dist/doctor-IZ4YOCYE.js +1 -0
- package/dist/index.d.ts +15 -0
- package/dist/index.js +168 -168
- package/dist/pipeline-IBQYDLFF.js +5 -0
- package/dist/{project-intelligence-lens-ZOAWXYC5.js → project-intelligence-lens-SIU7IXKG.js} +1 -1
- package/dist/project-test-coverage-FRMVYTFB.js +1 -0
- package/dist/verified-goal-M4GPOXNL.js +1 -0
- package/dist/{workspace-C4UETGY7.js → workspace-3AAOUELG.js} +1 -1
- package/dist/{workspace-agent-sync-446AXPHJ.js → workspace-agent-sync-QGYLY7HH.js} +1 -1
- package/dist/{workspace-archive-VHUPOBAV.js → workspace-archive-BA3ONVXX.js} +1 -1
- package/dist/{workspace-context-XSECHC7O.js → workspace-context-JCLPRYNC.js} +1 -1
- package/dist/workspace-contract-IUUPBQXU.js +1 -0
- package/dist/workspace-explain-CZGBVDE6.js +1 -0
- package/dist/workspace-explain-contract-KVQO57RC.js +1 -0
- package/dist/{workspace-feedback-WXE7NVMV.js → workspace-feedback-PCZKXG5R.js} +1 -1
- package/dist/{workspace-foundation-3EVAQ5X6.js → workspace-foundation-7IGMO4CW.js} +1 -1
- package/dist/{workspace-graph-stream-AJPS45FD.js → workspace-graph-stream-5YMLJXAJ.js} +1 -1
- package/dist/workspace-graph-token-efficiency-HK4KNWWP.js +1 -0
- package/dist/{workspace-history-YY7YRDOH.js → workspace-history-CHJOABME.js} +1 -1
- package/dist/{workspace-intelligence-FWRB47EJ.js → workspace-intelligence-XHSUFTAT.js} +1 -1
- package/dist/workspace-intelligence-evaluation-YMY3C5AW.js +1 -0
- package/dist/{workspace-intelligence-runner-GLC666ER.js → workspace-intelligence-runner-EN5V4KSC.js} +1 -1
- package/dist/workspace-intelligence-runtime-registry-NCVHKCMP.js +1 -0
- package/dist/workspace-knowledge-graph-VWQTIEYK.js +1 -0
- package/dist/{workspace-knowledge-graph-query-EKHIE3E2.js → workspace-knowledge-graph-query-TXA3KVUV.js} +1 -1
- package/dist/workspace-knowledge-graph-snapshot-WB62AVDK.js +1 -0
- package/dist/workspace-mcp-serve-NCAGGWQS.js +3 -0
- package/dist/{workspace-model-MNJOGBPP.js → workspace-model-NXFIKX26.js} +1 -1
- package/dist/{workspace-onboarding-5KO7Z7AD.js → workspace-onboarding-OP22NHQ4.js} +1 -1
- package/dist/{workspace-readme-4S6PJ74A.js → workspace-readme-IVJXSIBS.js} +1 -1
- package/dist/{workspace-registry-summary-GPJEL7K7.js → workspace-registry-summary-A5VDPRHU.js} +1 -1
- package/dist/workspace-repair-engine-N4KXNSVL.js +3 -0
- package/dist/workspace-run-PXKC3ELS.js +1 -0
- package/dist/{workspace-verify-C6HWHRLJ.js → workspace-verify-TUVLFPPN.js} +1 -1
- package/dist/{workspace-watch-DLPHLF5R.js → workspace-watch-2ZNOYSUQ.js} +1 -1
- package/docs/commands-reference.md +35 -6
- package/docs/contracts/ARTIFACT_CATALOG.md +6 -1
- package/docs/contracts/README.md +5 -0
- package/docs/doctor-command.md +158 -7
- package/docs/graph-benchmark-methodology.md +13 -0
- package/docs/workspace-intelligence-runner.md +4 -0
- package/docs/workspace-knowledge-graph.md +53 -4
- package/docs/workspace-run.md +14 -3
- package/package.json +10 -3
- package/dist/analyze-AAZEJ4FC.js +0 -1
- package/dist/autopilot-release-EZXOGAVE.js +0 -1
- package/dist/chunk-2PY65U6X.js +0 -5
- package/dist/chunk-3DONU3DU.js +0 -1
- package/dist/chunk-44VJHNZB.js +0 -1
- package/dist/chunk-4GPKQFPY.js +0 -1
- package/dist/chunk-5XDPQ3CB.js +0 -1
- package/dist/chunk-7AR5PDLD.js +0 -1
- package/dist/chunk-7KKP7RNB.js +0 -3
- package/dist/chunk-7T4TSV5C.js +0 -1
- package/dist/chunk-B5AY55A5.js +0 -1
- package/dist/chunk-BQ24743S.js +0 -5
- package/dist/chunk-BYVTHIC3.js +0 -2
- package/dist/chunk-CEIJIFY7.js +0 -88
- package/dist/chunk-EBKYSDCX.js +0 -1
- package/dist/chunk-FQLB4BIC.js +0 -7
- package/dist/chunk-GDU7VP6G.js +0 -1
- package/dist/chunk-H7P7SSUW.js +0 -75
- package/dist/chunk-KJYLCZRI.js +0 -8
- package/dist/chunk-KVUYAYTY.js +0 -8
- package/dist/chunk-MQ73VS4E.js +0 -2
- package/dist/chunk-NYHVCFBT.js +0 -1
- package/dist/chunk-OUBBBC7T.js +0 -36
- package/dist/chunk-P7K5RHJC.js +0 -2
- package/dist/chunk-PS5F4DCT.js +0 -1
- package/dist/chunk-QZ7PNMVP.js +0 -1
- package/dist/chunk-RA24WQLF.js +0 -1
- package/dist/chunk-RMXXK64P.js +0 -4
- package/dist/chunk-S7Z4DP3P.js +0 -2
- package/dist/chunk-SJLUE6AY.js +0 -1
- package/dist/chunk-TEHQ7XKK.js +0 -3
- package/dist/chunk-UFOCUHG3.js +0 -1
- package/dist/chunk-WD2XDMGB.js +0 -1
- package/dist/chunk-XVRJVKOX.js +0 -1
- package/dist/doctor-UEFFNAUD.js +0 -1
- package/dist/pipeline-ZYKDWUKK.js +0 -5
- package/dist/project-test-coverage-44ZPCOPV.js +0 -1
- package/dist/verified-goal-PE2PGAHF.js +0 -1
- package/dist/workspace-contract-AYFTZIKM.js +0 -1
- package/dist/workspace-explain-SZI2WAAD.js +0 -1
- package/dist/workspace-explain-contract-N2XQHAPM.js +0 -1
- package/dist/workspace-graph-token-efficiency-5FNH4JZ5.js +0 -1
- package/dist/workspace-intelligence-evaluation-UP2K3L35.js +0 -1
- package/dist/workspace-intelligence-runtime-registry-MRSF7RTT.js +0 -1
- package/dist/workspace-knowledge-graph-BMMM2FUE.js +0 -1
- package/dist/workspace-mcp-serve-COA4FMCA.js +0 -3
- package/dist/workspace-repair-engine-NMKOWUQP.js +0 -3
- package/dist/workspace-run-2DEVJOVH.js +0 -1
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import a from'path';function d(e){if(!e||typeof e!="object"||Array.isArray(e))return null;let r=e,i=t=>typeof t=="string"&&t.trim().length>0&&!t.includes("\0");return r.type==="file-create"?i(r.path)&&typeof r.content=="string"&&r.overwrite===false?r:null:r.type==="file-append"?i(r.path)&&Array.isArray(r.lines)&&r.lines.every(t=>typeof t=="string"&&!t.includes(`
|
|
2
|
+
`)&&!t.includes("\r"))&&typeof r.ensureNewline=="boolean"?r:null:r.type==="file-copy"?i(r.sourcePath)&&i(r.path)&&r.overwrite===false?r:null:r.type==="package-json-script"?i(r.path)&&typeof r.scriptName=="string"&&typeof r.scriptValue=="string"?r:null:r.type==="json-edit"?i(r.path)&&Array.isArray(r.edits)&&r.edits.every(t=>t&&typeof t=="object"&&!Array.isArray(t)&&typeof t.pointer=="string"&&t.pointer.startsWith("/")&&!t.pointer.includes("\0")&&(typeof t.value=="string"||typeof t.value=="number"||typeof t.value=="boolean"||t.value===null))?r:null:r.type==="env-key-add"?i(r.path)&&Array.isArray(r.keys)&&r.keys.every(t=>t&&typeof t=="object"&&!Array.isArray(t)&&typeof t.name=="string"&&/^[A-Z_][A-Z0-9_]*$/i.test(t.name)&&typeof t.value=="string"&&!t.value.includes(`
|
|
3
|
+
`)&&!t.value.includes("\r")&&(t.comment===void 0||typeof t.comment=="string"&&!t.comment.includes(`
|
|
4
|
+
`)&&!t.comment.includes("\r")))?r:null:r.type==="makefile-target"&&i(r.path)&&typeof r.target=="string"&&/^[A-Za-z0-9_.:-]+$/.test(r.target)&&typeof r.command=="string"&&r.command.trim().length>0&&typeof r.phony=="boolean"?r:null}function o(e){return `"${e.replace(/"/g,'\\"')}"`}function n(e){let r=`scripts.${e.scriptName}=${e.scriptValue}`;return `cd ${o(e.projectPath)} && npm pkg set ${o(r)}`}function s(e){return `workspai:doctor:repair ${Buffer.from(JSON.stringify(e),"utf8").toString("base64url")}`}function m(e){return {id:`${e.issueId}.dependency-materialization`,issueId:e.issueId,title:e.title,status:"available",fixKind:"dependency-sync",risk:"guarded",canAutoFix:true,canEditFiles:false,requiresApproval:true,requiresReview:false,files:e.files.map(r=>a.join(e.projectPath,r)),command:e.command,invocation:{cwd:e.projectPath,executable:e.executable,args:[...e.args]},transaction:{schemaVersion:"workspai.doctor-dependency-repair-transaction.v1",kind:"dependency-materialization",state:"planned",projectPath:e.projectPath,ecosystem:e.ecosystem,sourceMutationRequired:false,observableState:"runtime-dependency-tree",requiredStages:["reconcile","test","build"],completion:{manifestLockConsistent:true,installedTreePresent:true,declaredTestsPass:true,declaredBuildPass:true,canonicalVerificationRequired:true}},verifyCommand:"npx workspai doctor project --json",refreshCommands:["npx workspai doctor project --json","npx workspai workspace verify --json"],reason:e.reason,limitations:e.limitations}}function u(e){let r=a.join(e.projectPath,e.relativePath),i={type:"file-create",path:r,content:e.content,overwrite:false};return {id:`${e.issueId}.file-create`,issueId:e.issueId,title:e.title,status:"available",fixKind:"file-create",risk:e.risk??"safe",canAutoFix:true,canEditFiles:true,requiresApproval:true,requiresReview:e.requiresReview??false,files:[r],command:s(i),operation:i,verifyCommand:"npx workspai doctor project --json",refreshCommands:["npx workspai doctor project --json","npx workspai workspace verify --json"],reason:e.reason,limitations:e.limitations}}function g(e){let r=a.join(e.projectPath,e.relativePath),i={type:"file-append",path:r,lines:e.lines,ensureNewline:true};return {id:`${e.issueId}.file-append`,issueId:e.issueId,title:e.title,status:"available",fixKind:"file-append",risk:e.risk??"safe",canAutoFix:true,canEditFiles:true,requiresApproval:true,requiresReview:e.requiresReview??false,files:[r],command:s(i),operation:i,verifyCommand:"npx workspai doctor project --json",refreshCommands:["npx workspai doctor project --json","npx workspai workspace verify --json"],reason:e.reason,limitations:e.limitations}}function f(e){let r=a.join(e.projectPath,e.sourceRelativePath),i=a.join(e.projectPath,e.targetRelativePath),t={type:"file-copy",sourcePath:r,path:i,overwrite:false};return {id:`${e.issueId}.file-copy`,issueId:e.issueId,title:e.title,status:"available",fixKind:"file-copy",risk:e.risk??"safe",canAutoFix:true,canEditFiles:true,requiresApproval:true,requiresReview:e.requiresReview??false,files:[r,i],command:s(t),operation:t,verifyCommand:"npx workspai doctor project --json",refreshCommands:["npx workspai doctor project --json","npx workspai workspace verify --json"],reason:e.reason,limitations:e.limitations}}function y(e){return e.lint&&e.lint.trim().length>0?"npm run lint":e.build&&e.build.trim().length>0?"npm run build":null}function v(e){let r=`frontend-script-${e.scriptName}`,i=a.join(e.projectPath,"package.json"),t=["npx workspai doctor project --json","npx workspai workspace verify --json"];return e.scriptValue?{id:`${r}.package-json-script`,issueId:r,title:`Add package.json ${e.scriptName} script`,status:"available",fixKind:"package-json-script",risk:"guarded",canAutoFix:true,canEditFiles:true,requiresApproval:true,requiresReview:false,files:[i],command:n({projectPath:e.projectPath,scriptName:e.scriptName,scriptValue:e.scriptValue}),operation:{type:"package-json-script",path:i,scriptName:e.scriptName,scriptValue:e.scriptValue},verifyCommand:"npx workspai doctor project --json",refreshCommands:t,reason:`Reuse the existing ${e.scriptValue} validation path as the ${e.scriptName} gate for ${e.frameworkDisplayName}.`}:{id:`${r}.manual`,issueId:r,title:`Define ${e.scriptName} script`,status:"manual",fixKind:"manual",risk:"guarded",canAutoFix:false,canEditFiles:false,requiresApproval:true,requiresReview:true,files:[i],refreshCommands:t,reason:`No safe ${e.frameworkDisplayName} fallback script could be inferred from existing package.json scripts.`,limitations:["Add a real test/lint/build command that matches the project quality gate before release."]}}function k(e){let r=a.join(e.projectPath,"package.json");return {id:`${e.issueId}.package-json-script`,issueId:e.issueId,title:e.title,status:"available",fixKind:"package-json-script",risk:e.risk??"guarded",canAutoFix:true,canEditFiles:true,requiresApproval:true,requiresReview:e.requiresReview??false,files:[r],command:n({projectPath:e.projectPath,scriptName:e.scriptName,scriptValue:e.scriptValue}),operation:{type:"package-json-script",path:r,scriptName:e.scriptName,scriptValue:e.scriptValue},verifyCommand:"npx workspai doctor project --json",refreshCommands:["npx workspai doctor project --json","npx workspai workspace verify --json"],reason:e.reason,limitations:e.limitations}}function R(e){let r=a.join(e.projectPath,"Makefile"),i={type:"makefile-target",path:r,target:e.targetName,command:e.command,phony:true};return {id:`${e.issueId}.makefile-target`,issueId:e.issueId,title:e.title,status:"available",fixKind:"file-append",risk:e.risk??"guarded",canAutoFix:true,canEditFiles:true,requiresApproval:true,requiresReview:e.requiresReview??true,files:[r],command:s(i),operation:i,verifyCommand:"npx workspai doctor project --json",refreshCommands:["npx workspai doctor project --json","npx workspai workspace verify --json"],reason:e.reason,limitations:e.limitations}}function j(e){return {id:`${e.issueId}.command`,issueId:e.issueId,title:e.title,status:"available",fixKind:e.fixKind??"command",risk:e.risk??"guarded",canAutoFix:true,canEditFiles:false,requiresApproval:true,requiresReview:e.requiresReview??true,files:e.files.map(r=>a.join(e.projectPath,r)),command:`cd ${o(e.projectPath)} && ${e.command}`,...e.invocation?{invocation:{cwd:e.projectPath,executable:e.invocation.executable,args:[...e.invocation.args]}}:{},...e.strategy?{strategy:e.strategy.map(r=>({...r}))}:{},...e.transaction?{transaction:structuredClone(e.transaction)}:{},verifyCommand:"npx workspai doctor project --json",refreshCommands:["npx workspai doctor project --json","npx workspai workspace verify --json"],reason:e.reason,limitations:e.limitations}}export{d as a,s as b,m as c,u as d,g as e,f,y as g,v as h,k as i,R as j,j as k};
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import {c}from'./chunk-ZPA6ECBJ.js';import {c as c$1}from'./chunk-X7FYEKLI.js';import {d as d$1,b as b$1,a as a$1}from'./chunk-3RBUSW7H.js';import {d}from'./chunk-EWZZUQBR.js';import {a}from'./chunk-AFIFZTOY.js';import {h,e,i}from'./chunk-5EPPPMAS.js';import {t,h as h$1,g}from'./chunk-MOSXTVPU.js';import ee from'crypto';import G from'fs';import w from'fs/promises';import p from'path';import ie from'fs-extra';var ae=h.projectContextAgent.schemaVersion,Ke=["managed","local","off"],te="<!-- WORKSPAI:PROJECT-GROUNDING:START -->",ne="<!-- WORKSPAI:PROJECT-GROUNDING:END -->";function V(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:null}async function b(e){try{return JSON.parse(await w.readFile(e,"utf8"))}catch(n){return null}}function R(e){return e.replace(/\\/g,"/").replace(/^\.\/+/,"")}function L(e,n,r){let o=e.replace(/\\/g,"/"),i=/^[A-Za-z]:\//.test(o);if(!p.isAbsolute(e)&&!i)return R(o);if(i&&process.platform!=="win32")return null;let c=p.resolve(e),a=p.relative(r,c);if(a&&!a.startsWith("..")&&!p.isAbsolute(a))return R(a);let l=p.relative(n,c);return l&&!l.startsWith("..")&&!p.isAbsolute(l)?`workspace:${R(l)}`:null}function y(e,n,r){return [[r,"project:"],[r.replace(/\\/g,"/"),"project:"],[n,"workspace:"],[n.replace(/\\/g,"/"),"workspace:"]].reduce((i,[c,a])=>c.length>0?i.split(c).join(a):i,e)}function re(e,n){return V(e?.adoption)?.mode==="linked"?"adopted":V(e?.import)?"imported":n}function ce(e){if(!e.model)return null;let n=R(e.relativePath);return e.model.projects.find(r=>r.name===e.projectName||R(r.path)===n)??null}function z(e,n){e[n]=(e[n]??0)+1;}var le=["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 pe(e,n=160){let r={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 le){let c=e.filter(a=>a.kind===i).sort((a,l)=>a.label.localeCompare(l.label)||a.id.localeCompare(l.id)).slice(0,r[i]??32);for(let a of c){if(o.length>=n)return o;o.push(a);}}return o}function de(e,n){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 r=e.entities.find(t=>t.kind==="project"&&(t.id===n||t.label===n||t.projectId===n)),o=new Set(e.entities.filter(t=>t.projectId===n||t.id===r?.id||t.kind==="project"&&t.label===n).map(t=>t.id));r&&o.add(r.id);let i=e.relations.filter(t=>o.has(t.from)||o.has(t.to)),c=new Set(o);for(let t of i)c.add(t.from),c.add(t.to);let a=e.entities.filter(t=>c.has(t.id)),l=new Set,m={},k={},g={},h=new Set(a.filter(t=>t.kind==="language").map(t=>t.attributes.language).filter(t=>typeof t=="string"));for(let t of a){z(m,t.kind);let s=typeof t.attributes.language=="string"?t.attributes.language:void 0;if(s&&t.kind==="language")g[s]={fileCount:typeof t.attributes.fileCount=="number"?t.attributes.fileCount:0,symbolCount:g[s]?.symbolCount??0,generatedFileCount:typeof t.attributes.generatedFileCount=="number"?t.attributes.generatedFileCount:0};else if(s&&(t.kind==="file"||t.kind==="symbol")){let f=g[s]??{fileCount:0,symbolCount:0,generatedFileCount:0};t.kind==="file"&&!h.has(s)?(f.fileCount+=1,t.attributes.generated===true&&(f.generatedFileCount+=1)):t.kind==="symbol"&&(f.symbolCount+=1),g[s]=f;}for(let f of t.proofIds)l.add(f);}for(let t of i){z(k,t.kind);for(let s of t.proofIds)l.add(s);}let j=e.proofs.filter(t=>l.has(t.id)),P=[...new Set(e.entities.filter(t=>c.has(t.id)&&t.projectId&&t.projectId!==n).map(t=>t.projectId))].sort(),u=e.diagnostics.filter(t=>t.entityIds?.some(s=>c.has(s))||t.relationIds?.some(s=>i.some(f=>f.id===s))).map(t=>({code:t.code,severity:t.severity,message:t.message,...t.recommendation?{recommendation:t.recommendation}:{}})),d=(t,s)=>({project:s,kind:t.kind,source:t.source,confidence:t.confidence,evidence:[...new Set(t.evidence.map(f=>f.file.replace(/\\/g,"/")))].sort()}),C=e.projectTopology.edges.filter(t=>t.from===n).map(t=>d(t,t.to)).sort((t,s)=>`${t.project}:${t.kind}`.localeCompare(`${s.project}:${s.kind}`)),S=e.projectTopology.edges.filter(t=>t.to===n).map(t=>d(t,t.from)).sort((t,s)=>`${t.project}:${t.kind}`.localeCompare(`${s.project}:${s.kind}`)),T=pe(a),$=a.filter(t=>t.kind==="runtime-unit"),A=new Set(T.map(t=>t.id)),x=[...i].sort((t,s)=>{let f=Number(A.has(t.from)||A.has(t.to));return Number(A.has(s.from)||A.has(s.to))-f||t.id.localeCompare(s.id)}).slice(0,128),I=new Set([...T.flatMap(t=>t.proofIds),...x.flatMap(t=>t.proofIds)]);return {entityCount:a.length,relationCount:i.length,proofCount:j.length,entitiesByKind:m,relationsByKind:k,languages:Object.fromEntries(Object.entries(g).sort(([t],[s])=>t.localeCompare(s))),semantic:{protocolConceptCount:m.protocol??0,protocolImplementationBindings:k["implements-protocol"]??0,equivalenceBindings:k["equivalent-to"]??0,generationBindings:(k["generated-from"]??0)+(k["generated-by"]??0),runtimeUnitCount:$.length,lifecycleStageCount:m["lifecycle-stage"]??0,runtimeCoverage:[...new Set($.map(t=>t.attributes.runtime).filter(t=>typeof t=="string"))].sort()},relatedProjects:P,proofArtifacts:[...new Set(j.map(t=>t.artifact))].sort(),entities:T,relations:x,proofs:j.filter(t=>I.has(t.id)).sort((t,s)=>t.id.localeCompare(s.id)).slice(0,128),topology:{status:C.length>0||S.length>0?"proven":e.projectTopology.nodes.some(t=>t.id===n)?"unproven":"unavailable",dependencies:C,dependents:S},diagnostics:u}}function oe(e,n,r){return Array.isArray(e)?e.map(o=>typeof o=="string"?y(o,n,r):o):typeof e=="string"?y(e,n,r):e}function ge(e,n,r){return {id:e.id,kind:e.kind,label:y(e.label,n,r),attributes:Object.fromEntries(Object.entries(e.attributes).map(([o,i])=>[o,oe(i,n,r)])),proofIds:[...e.proofIds].sort()}}function ue(e,n,r){let o=(...c)=>e.filter(a=>c.includes(a.kind)).map(a=>ge(a,n,r)).slice(0,32),i=[];for(let c of e){for(let[a,l]of Object.entries(c.attributes))if(/(?:^|[-_.])ports?(?:$|[-_.])/i.test(a)&&(i.push({entityId:c.id,label:y(c.label,n,r),attribute:a,value:oe(l,n,r)}),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 me(e,n,r){let o=L(e.artifact,n,r);return o?{id:e.id,provider:e.provider,artifact:o,...e.pointer?{pointer:y(e.pointer,n,r)}:{},...e.line!==void 0?{line:e.line}:{},derivation:e.derivation,trust:e.trust,confidence:e.confidence,freshness:e.freshness}:null}async function fe(e,n,r){let o=[],i=await b(p.join(e,".workspai","reports","INDEX.json"));if(Array.isArray(i?.blockers))for(let a of i.blockers)typeof a=="string"&&(a.startsWith(`${r}:`)||a.includes(`project:${r}`)||a.includes(`project ${r}`))&&o.push({source:"workspace-report-index",severity:"error",message:y(a,e,n)});let c=await b(p.join(e,".workspai","reports","doctor-project-last-run.json"));if(c?.projectName===r)for(let a of c$1({project:c.project}))o.push({source:"doctor-project",severity:a.status==="blocking"?"error":"warning",message:y(a.message,e,n),...a.id?{code:a.id}:{}});return [...new Map(o.map(a=>[`${a.source}:${a.code??""}:${a.message}`,a])).values()].slice(0,32)}function M(e,n=[]){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)||n.some(r=>r.length>0&&(e.includes(r)||e.includes(r.replace(/\\/g,"/")))):Array.isArray(e)?e.some(r=>M(r,n)):e&&typeof e=="object"?Object.values(e).some(r=>M(r,n)):false}function he(e){return ee.createHash("sha256").update(JSON.stringify(e)).digest("hex")}async function ke(e$1){let n=p.resolve(e$1.workspacePath),r=p.resolve(e$1.projectPath),o=t(r,"project.json").find(s=>G.existsSync(s)),i$1=o?await b(o):null,c=await b(p.join(n,".workspai","workspace.contract.json")),a$1=p.resolve(r),l=c?.projects?.find(s=>s.externalPath?p.resolve(s.externalPath)===a$1:!s.relativePath||s.relativePath.startsWith("external/")?false:p.resolve(n,s.relativePath)===a$1)??c?.projects?.find(s=>s.slug===e$1.projectName||s.slug===p.basename(r)),m=e$1.projectName??(typeof i$1?.name=="string"?i$1.name:void 0)??l?.slug??p.basename(r),k=l?.relativePath??(()=>{let s=R(p.relative(n,r));return !s||s.startsWith("..")?`external/${m}`:s})(),g=await b(p.join(n,e.model)),h=await b(p.join(n,e.knowledgeGraph)),j=g?d(g):void 0,P=!!(j&&h?.source.hash===j),u=ce({model:g,projectName:m,relativePath:k}),d$1=de(P?h:null,m),C=await fe(n,r,m),S=d$1.proofs.map(s=>s.freshness),T=h?!P||S.includes("stale")?"stale":S.includes("unknown")?"unknown":"fresh":"missing",$=g?g.factFreshness?.status??"unknown":"missing",A=[...g?[]:[{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."}],...g&&!u?[{code:"project.context.project-not-materialized",severity:"warning",message:"The project is registered in the workspace contract but is not present in the current Workspace Model."}]:[],...h?[]:[{code:"project.context.graph-missing",severity:"warning",message:"The Workspace Knowledge Graph has not been generated yet. Run the workspace intelligence loop to build proof-backed relationships."}],...h&&!P?[{code:"project.context.graph-model-mismatch",severity:"warning",message:"The persisted Knowledge Graph does not match the current Workspace Model and was excluded from this project lens."}]:[]],x=re(i$1,e$1.relationship??l?.relationship??"managed"),I={schemaVersion:ae,generatedAt:(e$1.now??new Date).toISOString(),workspace:{name:c?.workspace?.name??g?.workspace.name??p.basename(n),...c?.workspace?.profile||g?.workspace.profile?{profile:c?.workspace?.profile??g?.workspace.profile}:{},relationship:x,contract:i.workspaceContract,model:e.model,knowledgeGraph:e.knowledgeGraph,access:{localBinding:i.projectWorkspaceLink,canonicalEvidenceAvailableAtGeneration:true}},project:{name:m,relativePath:k,...u?.kind?{kind:u.kind}:{},...u?.runtime||l?.runtime?{runtime:u?.runtime??l?.runtime}:{},...u?.runtimeCandidates?.length?{runtimeCandidates:[...u.runtimeCandidates].sort()}:{},...u?.framework||l?.framework?{framework:u?.framework??l?.framework}:{},...u?.kit||l?.kit?{kit:u?.kit??l?.kit}:{},...u?.supportTier?{supportTier:u.supportTier}:{},commands:{supported:[...u?.commands.supported??[]].sort(),unsupported:[...u?.commands.unsupported??[]].sort(),fleetStages:[...u?.commands.fleetStages??[]].sort()},importantFiles:[...new Set((u?.importantFiles??[]).map(s=>L(s,n,r)).filter(s=>s!==null))].sort()},intelligence:{...g?.generatedAt?{modelGeneratedAt:g.generatedAt}:{},...h?.generatedAt?{graphGeneratedAt:h.generatedAt}:{},...h?.source.hash?{graphModelHash:h.source.hash}:{},entityCount:d$1.entityCount,relationCount:d$1.relationCount,proofCount:d$1.proofCount,entitiesByKind:d$1.entitiesByKind,relationsByKind:d$1.relationsByKind,languages:d$1.languages,semantic:d$1.semantic,relatedProjects:d$1.relatedProjects,freshness:{model:$,graph:T,graphMatchesModel:P},topology:{...d$1.topology,dependencies:d$1.topology.dependencies.map(s=>({...s,evidence:s.evidence.map(f=>L(f,n,r)).filter(f=>f!==null)})),dependents:d$1.topology.dependents.map(s=>({...s,evidence:s.evidence.map(f=>L(f,n,r)).filter(f=>f!==null)}))},surfaces:ue(d$1.entities,n,r),diagnostics:[...A,...d$1.diagnostics].map(s=>({...s,message:y(s.message,n,r),...s.recommendation?{recommendation:y(s.recommendation,n,r)}:{}}))},evidence:{readOrder:[".workspai/PROJECT-GROUNDING.md",i.projectContextAgent,"AGENTS.md","workspace:.workspai/reports/INDEX.json","workspace:.workspai/reports/workspace-context-agent.json",`workspace:${e.model}`,`workspace:${e.knowledgeGraph}`],projectProofArtifacts:[...new Set(d$1.proofArtifacts.map(s=>L(s,n,r)).filter(s=>s!==null))],relations:d$1.relations.map(s=>({id:s.id,from:s.from,to:s.to,kind:s.kind,derivation:s.derivation,trust:s.trust,confidence:s.confidence,proofIds:[...s.proofIds].sort()})),proofs:d$1.proofs.map(s=>me(s,n,r)).filter(s=>s!==null)},blockers:C,agentRouting:{enforcement:"required",mandatoryPreflight:{command:"npx workspai project workspace status --json",successCondition:"resolved"},workspaceEvidenceRequiredFor:["repository-analysis","architecture-analysis","change-impact","cross-project-change","contract-change","infrastructure-change","release-readiness"],requiredReadOrder:[i.projectContextAgent,"command:npx workspai project workspace status --json","workspace:.workspai/reports/INDEX.json","workspace:.workspai/reports/workspace-context-agent.json",`command:npx workspai workspace graph search ${JSON.stringify(m)} --scope ${JSON.stringify(`project:${m}`)} --limit 12 --json`],degradedMode:{allowCompleteArchitectureClaims:false,requireDisclosure:true}},commands:{refresh:"npx workspai workspace intelligence run --for-agent generic --strict --json",verify:"npx workspai workspace verify --strict --json",graphSearch:`npx workspai workspace graph search ${JSON.stringify(m)} --scope ${JSON.stringify(`project:${m}`)} --limit 12 --json`,doctor:"npx workspai doctor project --json",workspaceStatus:"npx workspai project workspace status --json"}};if(M(I,[n,r]))throw new Error("Project context lens rejected a non-portable absolute path.");let t$1={...I,integrity:{algorithm:"sha256",...j?{modelHash:j}:{},payloadHash:he(I),portable:true,absolutePathsEmitted:false}};return a(t$1,"contracts/workspace-intelligence/project-context-agent.v1.json","Project context agent"),t$1}function je(e){let n=e.intelligence.relatedProjects.length>0?e.intelligence.relatedProjects.map(i=>`\`${i}\``).join(", "):"No proven cross-project relation is currently available.",r=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 part of the **${e.workspace.name}** Workspai workspace.
|
|
6
|
+
Commands launched from this project resolve that workspace automatically; you do not need to change directories first.
|
|
7
|
+
|
|
8
|
+
## Start here
|
|
9
|
+
|
|
10
|
+
This is a mandatory agent preflight, not optional background material:
|
|
11
|
+
|
|
12
|
+
1. Read \`.workspai/reports/project-context-agent.json\` before broad source discovery.
|
|
13
|
+
2. Run \`${e.commands.workspaceStatus}\` and require a resolved workspace.
|
|
14
|
+
3. For repository analysis, architecture analysis, change impact, contracts, infrastructure, or release readiness, read the canonical workspace \`.workspai/reports/INDEX.json\` and \`workspace-context-agent.json\` even when the request names only this repository.
|
|
15
|
+
4. Run the bounded agent graph search below before broad source scanning, then use targeted graph evidence/path queries as needed.
|
|
16
|
+
5. Use source inspection to verify and deepen the workspace evidence, not to silently replace it.
|
|
17
|
+
6. Do not claim complete architecture, independence, health, readiness, or verification without current Workspai evidence.
|
|
18
|
+
|
|
19
|
+
If workspace resolution, required reports, or graph retrieval is unavailable, explicitly report degraded mode and the missing evidence. In degraded mode an agent may inspect source, but must not claim a complete architectural understanding.
|
|
20
|
+
|
|
21
|
+
The Workspace Model owns canonical project identity and its compact \`projectTopology\`.
|
|
22
|
+
The Workspace Knowledge Graph is a separate, proof-backed enrichment containing
|
|
23
|
+
files, symbols, APIs, infrastructure, tests, owners, and decisions. Do not treat
|
|
24
|
+
an unproven topology edge as proof that two projects are independent.
|
|
25
|
+
|
|
26
|
+
## Project
|
|
27
|
+
|
|
28
|
+
- Name: \`${e.project.name}\`
|
|
29
|
+
- Workspace-relative identity: \`${e.project.relativePath}\`
|
|
30
|
+
- Runtime: \`${e.project.runtime??"unknown"}\`
|
|
31
|
+
- Framework: \`${e.project.framework??"unknown"}\`
|
|
32
|
+
- Relationship: \`${e.workspace.relationship}\`
|
|
33
|
+
- Related projects: ${n}
|
|
34
|
+
- Topology status: \`${e.intelligence.topology.status}\`
|
|
35
|
+
- Model freshness: \`${e.intelligence.freshness.model}\`
|
|
36
|
+
- Knowledge Graph freshness: \`${e.intelligence.freshness.graph}\`
|
|
37
|
+
|
|
38
|
+
## Current evidence coverage
|
|
39
|
+
|
|
40
|
+
- Project-scoped entities: ${e.intelligence.entityCount}
|
|
41
|
+
- Project-scoped relations: ${e.intelligence.relationCount}
|
|
42
|
+
- Portable proofs: ${e.intelligence.proofCount}
|
|
43
|
+
|
|
44
|
+
${r}
|
|
45
|
+
|
|
46
|
+
## Current project blockers
|
|
47
|
+
|
|
48
|
+
${o}
|
|
49
|
+
|
|
50
|
+
## Safe commands from this project
|
|
51
|
+
|
|
52
|
+
\`\`\`bash
|
|
53
|
+
${e.commands.workspaceStatus}
|
|
54
|
+
${e.commands.doctor}
|
|
55
|
+
${e.commands.graphSearch}
|
|
56
|
+
${e.commands.verify}
|
|
57
|
+
\`\`\`
|
|
58
|
+
|
|
59
|
+
The machine-local workspace path lives only in \`.workspai/workspace-link.local.json\`, which is gitignored. Portable grounding files never publish that path.
|
|
60
|
+
`}function we(e){return `# Workspai project boundary
|
|
61
|
+
|
|
62
|
+
- Project: \`${e.project.name}\`
|
|
63
|
+
- Canonical workspace: \`${e.workspace.name}\`
|
|
64
|
+
- Portable project lens: \`.workspai/reports/project-context-agent.json\`
|
|
65
|
+
- Project grounding: \`.workspai/PROJECT-GROUNDING.md\`
|
|
66
|
+
- Workspace discovery: run \`npx workspai project workspace status --json\`
|
|
67
|
+
|
|
68
|
+
Before broad source discovery, every agent must read the project lens and run \`${e.commands.workspaceStatus}\`; continue as fully grounded only when workspace resolution succeeds. Repository analysis, architecture analysis, change impact, contracts, APIs, infrastructure, and release readiness always require canonical workspace evidence and the bounded agent graph search, even when the request names only this repository. Source inspection verifies and deepens that evidence; it does not replace it silently. If required evidence is unavailable or stale, disclose degraded mode and do not claim complete architecture, independence, health, readiness, or verification. The user does not need to preload the graph. \`projectTopology\` is the compact project dependency view in the canonical Workspace Model, while the Workspace Knowledge Graph is the proof-backed detail layer. Workspai commands launched here resolve the canonical workspace automatically. Never copy the machine-local workspace link into answers, commits, or generated portable artifacts.`}function X(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Z(e,n){return new RegExp(`${X(e)}[\\s\\S]*?${X(n)}`,"m")}function se(e){let n=e.replace(Z(te,ne),"");return d$1(n)?.includes("# Workspai project boundary")&&(n=n.replace(Z(a$1,b$1),"")),n.replace(/\n{3,}/g,`
|
|
69
|
+
|
|
70
|
+
`).trim()}function ye(e,n){let r=se(e),o=`${te}
|
|
71
|
+
${n.trim()}
|
|
72
|
+
${ne}`;return r?`${r}
|
|
73
|
+
|
|
74
|
+
${o}
|
|
75
|
+
`:`${o}
|
|
76
|
+
`}async function O(e,n){await w.mkdir(p.dirname(e),{recursive:true});let r=`${e}.${process.pid}.${ee.randomUUID()}.tmp`;try{await w.writeFile(r,n,"utf8");try{await w.rename(r,e);}catch(o){let i=o.code;if(i!=="EEXIST"&&i!=="EPERM")throw o;await ie.move(r,e,{overwrite:true});}}finally{await w.rm(r,{force:true}).catch(()=>{});}}async function Y(e,n){let r=p.join(e,".gitignore"),o=await w.readFile(r,"utf8").catch(l=>{if(l.code==="ENOENT")return "";throw l}),i=[g,h$1],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();n==="local"&&(c.length>0&&c.push(""),c.push("# Workspai local project grounding",...i));let a=c.length>0?`${c.join(`
|
|
77
|
+
`)}
|
|
78
|
+
`:"";a!==o&&await O(r,a);}async function Q(e,n,r){let o=p.join(e,"AGENTS.md"),i=G.existsSync(o),c=await w.readFile(o,"utf8").catch(m=>{if(m.code==="ENOENT")return "";throw m});if(n==="managed"&&!r)throw new Error("Managed project grounding requires a project context.");let a=n==="managed"&&r?ye(c,we(r)):se(c);if(!a){i&&await w.rm(o,{force:true});return}let l=`${a.trimEnd()}
|
|
79
|
+
`;return l!==c&&await O(o,l),n==="managed"?o:void 0}async function Pe(e){let n=e.mode??"managed",r=p.resolve(e.workspacePath),o=p.resolve(e.projectPath);if(n==="off"){let h=t(o,"project.json").find(C=>G.existsSync(C)),j=h?await b(h):null,P=e.projectName??(typeof j?.name=="string"?j.name:void 0)??p.basename(o),u=re(j,e.relationship??"managed"),d=await c({workspacePath:r,projectPath:o,projectName:P,relationship:u,now:e.now});return await Y(o,n),await Q(o,n),await Promise.all([w.rm(p.join(o,h$1),{force:true}),w.rm(p.join(o,g),{force:true})]),{mode:n,projectPath:o,linkPath:d.linkPath,writtenFiles:[i.projectWorkspaceLink]}}let i$1=await ke(e),c$1=i$1.workspace.relationship,a=await c({workspacePath:r,projectPath:o,projectName:i$1.project.name,relationship:c$1,workspaceName:i$1.workspace.name,relativePath:i$1.project.relativePath,now:e.now});await Y(o,n);let l=await Q(o,n,i$1),m=p.join(o,h$1),k=p.join(o,g);await O(m,`${JSON.stringify(i$1,null,2)}
|
|
80
|
+
`),await O(k,`${je(i$1).trimEnd()}
|
|
81
|
+
`);let g$1=[i.projectWorkspaceLink,h$1,g];return l&&g$1.push("AGENTS.md"),{mode:n,projectPath:o,linkPath:a.linkPath,groundingPath:k,contextPath:m,agentsPath:l,writtenFiles:g$1}}async function _e(e){let n=p.resolve(e.workspacePath),r=e.mode??"managed",o=await be(n),i=[],c=[];for(let a of o.resolved)try{i.push(await Pe({workspacePath:n,projectPath:a.projectPath,projectName:a.name,relationship:a.relationship,mode:r,now:e.now}));}catch(l){c.push({name:a.name,reason:l instanceof Error?l.message:String(l)});}return {workspacePath:n,mode:r,projects:i,skipped:[...o.skipped,...c]}}async function be(e){let n=p.resolve(e),r=await b(p.join(n,".workspai","workspace.contract.json")),o=[],i=[];for(let c of r?.projects??[]){let a=c.slug??c.relativePath??"unknown-project",l=typeof c.externalPath=="string"?p.resolve(c.externalPath):typeof c.relativePath=="string"&&!c.relativePath.startsWith("external/")?p.resolve(n,c.relativePath):null;if(!l||!G.existsSync(l)){i.push({name:a,reason:"project path is unavailable on this machine"});continue}o.push({name:a,projectPath:l,relationship:c.relationship??"managed"});}return {resolved:o,skipped:i}}export{ae as a,Ke as b,te as c,ne as d,ke as e,Pe as f,_e as g,be as h};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import {h}from'./chunk-5EPPPMAS.js';var _=h.artifactRemediationPlan.schemaVersion;export{_ as a};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {a,c,j,g as g$1,h as h$1}from'./chunk-2PY65U6X.js';import {t,u as u$1}from'./chunk-MOSXTVPU.js';import T from'fs';import i from'path';import C from'fs-extra';var V=[{id:"fastapi.standard",aliases:["fastapi","fastapi.standard"],label:"fastapi \u2014 FastAPI Standard Kit",description:"Core-backed FastAPI service scaffold.",owner:"core",runtime:"python",framework:"fastapi",category:"backend",moduleSupport:true,stability:"stable",versionPolicy:"tested-baseline"},{id:"fastapi.ddd",aliases:["fastapi.ddd","fastapi-ddd"],label:"fastapi \u2014 FastAPI DDD Kit",description:"Core-backed FastAPI DDD service scaffold.",owner:"core",runtime:"python",framework:"fastapi",category:"backend",moduleSupport:true,stability:"stable",versionPolicy:"tested-baseline"},{id:"nestjs.standard",aliases:["nestjs","nest","nestjs.standard"],label:"nestjs \u2014 NestJS Standard Kit",description:"Core-backed NestJS service scaffold.",owner:"core",runtime:"node",framework:"nestjs",category:"backend",moduleSupport:true,stability:"stable",versionPolicy:"tested-baseline"},{id:"springboot.standard",aliases:["spring","springboot","springboot.standard","java"],label:"spring \u2014 Spring Boot Standard Kit",description:"npm-backed Spring Boot service scaffold.",owner:"npm",runtime:"java",framework:"springboot",category:"backend",moduleSupport:false,stability:"stable",versionPolicy:"tested-baseline",generator:"springboot",createUsage:"workspai create project springboot.standard <name> [--java-version <major>] [--spring-boot-version <semver>] [--group-id <com.example>] [--package-name <com.example.app>] [--port <number>]"},{id:"gofiber.standard",aliases:["go","go.standard","fiber","gofiber","gofiber.standard","go/fiber"],label:"go/fiber \u2014 Go Fiber Standard Kit",description:"npm-backed Go Fiber service scaffold.",owner:"npm",runtime:"go",framework:"gofiber",category:"backend",moduleSupport:false,stability:"stable",versionPolicy:"tested-baseline",generator:"gofiber",createUsage:"workspai create project gofiber.standard <name> [--output <dir>]"},{id:"gogin.standard",aliases:["gin","gogin","gogin.standard","go/gin"],label:"go/gin \u2014 Go Gin Standard Kit",description:"npm-backed Go Gin service scaffold.",owner:"npm",runtime:"go",framework:"gogin",category:"backend",moduleSupport:false,stability:"stable",versionPolicy:"tested-baseline",generator:"gogin",createUsage:"workspai create project gogin.standard <name> [--output <dir>]"},{id:"dotnet.webapi.clean",aliases:["dotnet","dotnet.webapi","dotnet.webapi.clean","aspnet","aspnetcore","asp.net","asp.net-core","csharp","c#"],label:"dotnet \u2014 ASP.NET Core Clean Web API",description:"npm-backed ASP.NET Core Web API with clean architecture boundaries.",owner:"npm",runtime:"dotnet",framework:"dotnet",category:"backend",moduleSupport:false,stability:"preview",versionPolicy:"tested-baseline",generator:"dotnet-webapi-clean",createUsage:"workspai create project dotnet.webapi.clean <name> [--target-framework net8.0] [--root-namespace <Company.Product>] [--port <number>]"},{id:"rust.axum",aliases:["rust.axum","axum","rust-axum"],label:"rust/axum \u2014 Rust Axum API",description:"Workspai-owned Axum service with health, tests, CI, and container baseline.",owner:"npm",runtime:"rust",framework:"axum",category:"backend",moduleSupport:false,stability:"preview",versionPolicy:"tested-baseline",generator:"rust-axum",createUsage:"workspai create project rust.axum <name> [--port <number>] [--output <dir>] [--skip-git]"}],O=new Map;for(let e of V){O.set(e.id.toLowerCase(),e);for(let t of e.aliases)O.set(t.toLowerCase(),e);}function R(e){return e?O.get(e.trim().toLowerCase())??null:null}function ze(e){return R(e)?.id??e}function Ve(){return V.filter(e=>e.owner==="core"||e.generator)}function Xe(e){return R(e)?.owner==="npm"}async function Qe(e,t){if(!e.generator)throw new Error(`Kit is not backed by an npm generator: ${e.id}`);if(e.generator==="gofiber"){let{generateGoFiberKit:r}=await import('./gofiber-standard-AQGSC7ON.js');await r(t.projectPath,{project_name:t.projectName,module_path:t.projectName,skipGit:t.skipGit,skipInstall:t.skipInstall});return}if(e.generator==="gogin"){let{generateGoGinKit:r}=await import('./gogin-standard-7DU3OCBX.js');await r(t.projectPath,{project_name:t.projectName,module_path:t.projectName,skipGit:t.skipGit,skipInstall:t.skipInstall});return}if(e.generator==="springboot"){let{generateSpringBootKit:r}=await import('./springboot-standard-EK6GYN5T.js');await r(t.projectPath,{project_name:t.projectName,artifact_id:t.projectName,java_version:m(t.args,"--java-version")?.trim(),spring_boot_version:m(t.args,"--spring-boot-version")?.trim(),springdoc_version:m(t.args,"--springdoc-version")?.trim(),group_id:m(t.args,"--group-id")?.trim(),package_name:m(t.args,"--package-name")?.trim(),description:m(t.args,"--description")?.trim(),port:m(t.args,"--port")?.trim(),skipGit:t.skipGit,skipInstall:t.skipInstall});return}if(e.generator==="dotnet-webapi-clean"){let{generateDotnetWebApiCleanKit:r}=await import('./dotnet-webapi-clean-VXEF4SHM.js');await r(t.projectPath,{project_name:t.projectName,target_framework:m(t.args,"--target-framework")?.trim(),root_namespace:m(t.args,"--root-namespace")?.trim(),description:m(t.args,"--description")?.trim(),port:m(t.args,"--port")?.trim(),skipGit:t.skipGit,skipInstall:t.skipInstall});return}if(e.generator==="rust-axum"){let{generateRustAxumKit:r}=await import('./rust-axum-4HXDICIB.js');await r(t.projectPath,{project_name:t.projectName,description:m(t.args,"--description")?.trim(),port:m(t.args,"--port")?.trim(),skipGit:t.skipGit,skipInstall:t.skipInstall});return}throw new Error(`Unhandled npm kit generator: ${e.generator}`)}function m(e,t){let r=e.indexOf(t);if(r>=0&&r+1<e.length)return e[r+1];let n=e.find(a=>a.startsWith(`${t}=`));return n?n.slice(t.length+1):void 0}var f=["init","dev","start","build","test","lint","format","help"],X={python:{runtime:"python",displayName:"Python",tier:"first-class",scaffoldSupport:true,importSupport:true,lifecycleCommands:f,moduleCommands:true,doctorSupport:"full",notes:["Core-backed Python projects support RapidKit Core modules and lifecycle commands."]},node:{runtime:"node",displayName:"Node.js",tier:"extended",scaffoldSupport:true,importSupport:true,lifecycleCommands:f,moduleCommands:true,doctorSupport:"full",notes:["Node projects support npm-owned lifecycle commands; NestJS is the first-class Node framework."]},go:{runtime:"go",displayName:"Go",tier:"extended",scaffoldSupport:true,importSupport:true,lifecycleCommands:f,moduleCommands:false,doctorSupport:"readiness",notes:["Go projects support workspace governance and lifecycle commands via Go tooling."]},java:{runtime:"java",displayName:"Java / Spring Boot",tier:"extended",scaffoldSupport:true,importSupport:true,lifecycleCommands:f,moduleCommands:false,doctorSupport:"readiness",notes:["Java projects support Maven/Gradle lifecycle commands and workspace governance."]},dotnet:{runtime:"dotnet",displayName:".NET / ASP.NET Core",tier:"extended",scaffoldSupport:true,importSupport:true,lifecycleCommands:f,moduleCommands:false,doctorSupport:"readiness",notes:[".NET projects support dotnet CLI lifecycle commands and workspace governance."]},php:{runtime:"php",displayName:"PHP",tier:"extended",scaffoldSupport:true,importSupport:true,lifecycleCommands:f,moduleCommands:false,doctorSupport:"readiness",notes:["Laravel projects use the official Composer generator and PHP/Composer lifecycle adapter."]},ruby:{runtime:"ruby",displayName:"Ruby",tier:"observed",scaffoldSupport:false,importSupport:true,lifecycleCommands:["help"],moduleCommands:false,doctorSupport:"observed",notes:["Ruby projects are importable and governed as observed projects until a kit exists."]},rust:{runtime:"rust",displayName:"Rust",tier:"extended",scaffoldSupport:true,importSupport:true,lifecycleCommands:f,moduleCommands:false,doctorSupport:"readiness",notes:["Rust projects support Axum and Tauri scaffolding plus Cargo lifecycle commands."]},elixir:{runtime:"elixir",displayName:"Elixir",tier:"observed",scaffoldSupport:false,importSupport:true,lifecycleCommands:["help"],moduleCommands:false,doctorSupport:"observed",notes:["Elixir projects are importable and governed as observed projects until a kit exists."]},clojure:{runtime:"clojure",displayName:"Clojure",tier:"observed",scaffoldSupport:false,importSupport:true,lifecycleCommands:["help"],moduleCommands:false,doctorSupport:"observed",notes:["Clojure projects are importable and governed as observed projects until a kit exists."]},scala:{runtime:"scala",displayName:"Scala",tier:"observed",scaffoldSupport:false,importSupport:true,lifecycleCommands:["help"],moduleCommands:false,doctorSupport:"observed",notes:["Scala projects are importable and governed as observed projects until a kit exists."]},kotlin:{runtime:"kotlin",displayName:"Kotlin",tier:"observed",scaffoldSupport:false,importSupport:true,lifecycleCommands:["help"],moduleCommands:false,doctorSupport:"observed",notes:["Kotlin projects are importable and governed as observed projects until a kit exists."]},deno:{runtime:"deno",displayName:"Deno",tier:"observed",scaffoldSupport:false,importSupport:true,lifecycleCommands:["help"],moduleCommands:false,doctorSupport:"observed",notes:["Deno projects are importable and governed as observed projects until a kit exists."]},bun:{runtime:"bun",displayName:"Bun",tier:"observed",scaffoldSupport:false,importSupport:true,lifecycleCommands:["help"],moduleCommands:false,doctorSupport:"observed",notes:["Bun projects are importable and governed as observed projects until a kit exists."]},c:{runtime:"c",displayName:"C",tier:"observed",scaffoldSupport:false,importSupport:true,lifecycleCommands:["help"],moduleCommands:false,doctorSupport:"observed",notes:["C projects are importable and receive manifest, test, quality, security, and coverage evidence without assuming a package manager."]},cpp:{runtime:"cpp",displayName:"C++",tier:"observed",scaffoldSupport:false,importSupport:true,lifecycleCommands:["help"],moduleCommands:false,doctorSupport:"observed",notes:["C++ projects are importable and receive manifest, test, quality, security, and coverage evidence without assuming a package manager."]},unknown:{runtime:"unknown",displayName:"Unknown",tier:"observed",scaffoldSupport:false,importSupport:true,lifecycleCommands:["help"],moduleCommands:false,doctorSupport:"observed",notes:["Unknown projects are tracked safely but require manual command configuration."]}},fe=["fastapi","nestjs"],ge=["django","flask","nextjs","remix","nuxt","react","vite","vue","sveltekit","svelte","angular","astro","solid","express","fastify","koa","echo","gofiber","gogin","springboot","dotnet","laravel","symfony","rails","sinatra","actix","axum","rocket","phoenix","clojure","scala","kotlin","deno","bun","tauri","electron","vscode-extension","c","cpp"];function x(e){return X[e||"unknown"]??X.unknown}function Q(e){return fe.includes(e)?"first-class":ge.includes(e)?"extended":"observed"}function Z(e){let t=x(e.runtime);return {lifecycleCommands:t.lifecycleCommands,moduleCommands:e.moduleSupport&&t.moduleCommands,unsupportedLifecycleCommands:f.filter(r=>!t.lifecycleCommands.includes(r))}}var ye=["python","node","go","java","dotnet","rust","php"];function w(e){return !!e&&ye.includes(e)}function E(e,t){return t!=="lint"&&t!=="format"&&t!=="docs"?false:e==="python"}function ee(e){let t=x(e),r=w(t.runtime),n=be[t.runtime]??[],a=Ce[t.runtime]??[];return {runtime:t.runtime,displayName:t.displayName,lifecycleCommands:t.lifecycleCommands,hasExecutor:r,packageManagers:n,primaryFiles:a,notes:t.notes}}var be={python:["poetry","pip","uv"],node:["npm","pnpm","yarn","bun"],go:["go"],java:["maven","gradle"],dotnet:["dotnet"],php:["composer"],ruby:["bundle"],rust:["cargo"],elixir:["mix"],kotlin:["gradle"],deno:["deno"],bun:["bun"]},Ce={python:["pyproject.toml","requirements.txt","requirements.in"],node:["package.json"],go:["go.mod"],java:["pom.xml","build.gradle","build.gradle.kts"],dotnet:["*.csproj","*.sln"],php:["composer.json"],ruby:["Gemfile"],rust:["Cargo.toml"],elixir:["mix.exs"],kotlin:["settings.gradle.kts"],deno:["deno.json","deno.jsonc"],bun:["package.json","bunfig.toml"]};function h(e,t){let r=g$1({runtime:typeof e?.runtime=="string"?e.runtime:void 0,framework:typeof e?.framework=="string"?e.framework:void 0,kitName:typeof e?.kit_name=="string"?e.kit_name:typeof e?.kit=="string"?e.kit:void 0});return r.runtime!=="unknown"?r.runtime:j(t,e).runtime}function re(e){let t$1=e;for(;;){for(let n of t(t$1,"project.json"))if(T.existsSync(n))try{return JSON.parse(T.readFileSync(n,"utf8"))}catch{return null}let r=i.dirname(t$1);if(r===t$1)break;t$1=r;}return null}function pt(e,t){return h(e,t)==="go"}function lt(e,t){return h(e,t)==="node"}function dt(e,t){return h(e,t)==="java"}function ut(e,t){return h(e,t)==="dotnet"}function ft(e,t){return h(e,t)==="python"}var Se=["project.json","context.json","file-hashes.json"];async function ht(e){let t=i.resolve(e),r=[];for(let n of Se){let a=u$1(t,n);if(await C.pathExists(a))continue;let c=i.join(t,".rapidkit",n);if(!await C.pathExists(c))continue;let y=await C.readJson(c);await C.ensureDir(i.dirname(a));let k=`${a}.${process.pid}.${Date.now()}.tmp`;try{await C.writeJson(k,y,{spaces:2}),await C.move(k,a,{overwrite:false}),r.push(a);}finally{await C.remove(k).catch(()=>{});}}return r}function je(e){for(let t$1 of t(e,"context.json"))if(T.existsSync(t$1))try{return JSON.parse(T.readFileSync(t$1,"utf8"))}catch{return null}return null}function we(e){let t=e?.engine;return t==="npm"||t==="pip"||t==="python"?t:"unknown"}function xe(e,t){if(e?.module_support===false||t?.module_support===false||!e&&t)return false;let r=typeof e?.kit_name=="string"?e.kit_name:typeof e?.kit=="string"?e.kit:typeof t?.kit=="string"?t.kit:void 0,n=r?R(r):void 0;return n?.owner==="core"&&n.moduleSupport===true}function he(e,t,r){let n=g$1({runtime:typeof t?.runtime=="string"?t.runtime:typeof r?.runtime=="string"?r.runtime:void 0,framework:typeof t?.framework=="string"?t.framework:typeof r?.framework=="string"?r.framework:void 0,kitName:typeof t?.kit_name=="string"?t.kit_name:typeof t?.kit=="string"?t.kit:typeof r?.kit=="string"?r.kit:void 0});return n.key!=="unknown"?n:j(e,t)}function ne(e){let t$1=i.resolve(e);if(![...t(t$1,"project.json"),...t(t$1,"context.json")].some(y=>T.existsSync(y)))return null;let n=re(t$1),a=je(t$1),c=he(t$1,n,a);return {projectRoot:t$1,projectJson:n,contextJson:a,detection:c,moduleSupport:xe(n,a),engine:we(a)}}var ve=["build","dev","start","test","lint","format"],I=["init","test","build","start"],Pt=["lint","format","docs"];function Rt(e){return !!e&&ve.includes(e)}var Ne={dev:["dev","start:dev"],start:["start","start:prod","preview"],build:["build"],test:["test","test:unit","test:ci"],lint:["lint"],format:["format","prettier"]},ae={nestjs:{dev:["dev","start:dev"],start:["start","start:prod"],build:["build"],test:["test","test:e2e"],lint:["lint"],format:["format"]},express:{dev:["dev","start:dev"],start:["start"],build:["build"],test:["test"],lint:["lint"],format:["format"]},fastify:{dev:["dev","start:dev"],start:["start"],build:["build"],test:["test"],lint:["lint"],format:["format"]},koa:{dev:["dev","start:dev"],start:["start"],build:["build"],test:["test"],lint:["lint"],format:["format"]}};function Pe(e){let t=i.join(e,"package.json");if(!T.existsSync(t))return {};try{let n=JSON.parse(T.readFileSync(t,"utf8")).scripts??{};return Object.fromEntries(Object.entries(n).filter(a=>typeof a[1]=="string"))}catch{return {}}}function Re(e,t){let r=t?c(t):"unknown",n=r!=="unknown"?a(r,e):[],a$1=t?ae[t]?.[e]??[]:[],c$1=Ne[e]??[],y=[...n,...a$1,...c$1];return [...new Set(y)]}function ie(e,t,r){let n=Pe(e),a$1=new Set(Object.keys(n));if(a$1.has(t))return {scriptName:t,source:"package.json"};for(let c$1 of Re(t,r?.framework))if(a$1.has(c$1))return {scriptName:c$1,source:a(c(r?.framework??"unknown"),t).includes(c$1)||ae[r?.framework??""]?.[t]?.includes(c$1)?"framework-candidate":"generic-candidate"};return null}function B(e){return T.existsSync(i.join(e,"package.json"))}function se(e){let t=ee(e);return t.runtime==="unknown"&&e!=="unknown"?null:{runtime:t.runtime,displayName:t.displayName,supportedCommands:t.lifecycleCommands,packageManagers:t.packageManagers,primaryFiles:t.primaryFiles,notes:t.notes,hasExecutor:t.hasExecutor}}function s(e){try{return T.existsSync(e)}catch{return false}}function g(e){try{return s(e)?T.readFileSync(e,"utf8"):""}catch{return ""}}function u(e,t){let r=g(i.join(e,"Makefile"));return r?new RegExp(`^${t}\\s*:`).test(r):false}function Ee(e){let t=[e];for(;t.length>0;){let r=t.shift();if(!r)break;let n=[];try{n=T.readdirSync(r,{withFileTypes:true});}catch{continue}for(let a of n){if(a.name==="node_modules"||a.name===".git"||a.name==="dist")continue;let c=i.join(r,a.name);if(a.isFile()&&a.name.endsWith(".csproj"))return true;a.isDirectory()&&t.push(c);}}return false}function ce(e,t){let r=s(i.join(e,"pyproject.toml")),n=s(i.join(e,"requirements.txt"))||s(i.join(e,"requirements.in")),a=s(i.join(e,"manage.py"));switch(t){case "init":return r||n;case "dev":case "start":return r||a||n;case "test":return r||n||s(i.join(e,"tests"));case "build":return r||n;case "lint":case "format":return r||n||a||s(i.join(e,"setup.py"))||s(i.join(e,"setup.cfg"));default:return false}}function Me(e,t){if(!s(i.join(e,"go.mod")))return false;switch(t){case "init":return true;case "dev":return u(e,"run")||s(i.join(e,"main.go"));case "test":return true;case "build":return true;case "start":return u(e,"run")||s(i.join(e,"main.go"))||s(i.join(e,"cmd"));case "lint":return s(i.join(e,".golangci.yml"))||s(i.join(e,".golangci.yaml"))||u(e,"lint");case "format":return u(e,"fmt")||u(e,"format");default:return false}}function _e(e,t){let r=s(i.join(e,"pom.xml")),n=s(i.join(e,"build.gradle"))||s(i.join(e,"build.gradle.kts"));if(!r&&!n)return false;switch(t){case "init":case "test":case "build":case "dev":case "start":return true;case "lint":return u(e,"lint")||g(i.join(e,"pom.xml")).includes("checkstyle")||g(i.join(e,"build.gradle")).includes("checkstyle")||g(i.join(e,"build.gradle.kts")).includes("checkstyle");case "format":return u(e,"format")||g(i.join(e,"build.gradle")).includes("spotless")||g(i.join(e,"build.gradle.kts")).includes("spotless");default:return false}}function Ae(e,t){if(!Ee(e))return false;switch(t){case "init":case "dev":case "test":case "build":case "start":return true;case "lint":return u(e,"lint")||g(i.join(e,"Directory.Build.props")).includes("EnforceCodeStyleInBuild");case "format":return u(e,"format")||s(i.join(e,".editorconfig"));default:return false}}function Fe(e,t,r){return t==="init"?B(e):ie(e,t,{framework:r})!==null}function Le(e,t,r){switch(t){case "php":return r==="init"&&s(i.join(e,"composer.json"));case "ruby":return r==="init"&&s(i.join(e,"Gemfile"));case "rust":return s(i.join(e,"Cargo.toml"))?r==="init"||r==="test"||r==="build"||r==="start":false;case "elixir":return r==="init"&&s(i.join(e,"mix.exs"));case "deno":return s(i.join(e,"deno.json"))||s(i.join(e,"deno.jsonc"))?r==="init"||r==="dev"||r==="test"||r==="start":r==="init"&&s(i.join(e,"package.json"));case "bun":return s(i.join(e,"bunfig.toml"))||s(i.join(e,"bun.lock"))?r==="init"||r==="dev"||r==="test"||r==="build"||r==="start":r==="init"&&s(i.join(e,"package.json"));default:return false}}function De(e){try{let t=JSON.parse(g(i.join(e,"composer.json")));return new Set(Object.keys(t.scripts??{}))}catch{return new Set}}function Oe(e,t){if(!s(i.join(e,"composer.json")))return false;let r=De(e),n=s(i.join(e,"artisan"));switch(t){case "init":return true;case "dev":return n||r.has("dev");case "start":return n||r.has("start");case "test":return n||r.has("test");case "build":return r.has("build");case "lint":return r.has("lint")||r.has("analyse")||r.has("analyze");case "format":return r.has("format")||r.has("fmt")||s(i.join(e,"pint.json"))||s(i.join(e,"vendor","bin","pint"));default:return false}}function Te(e,t){return s(i.join(e,"Cargo.toml"))?t==="init"||t==="dev"||t==="start"||t==="build"||t==="test"||t==="lint"||t==="format":false}function _(e,t,r,n){if(E(t,r))return ce(e,r);if(!w(t))return Le(e,t,r);switch(t){case "node":return Fe(e,r,n);case "python":return ce(e,r);case "go":return Me(e,r);case "java":return _e(e,r);case "dotnet":return Ae(e,r);case "rust":return Te(e,r);case "php":return Oe(e,r);default:return false}}function Ie(e,t,r){return ["init","dev","start","build","test","lint","format"].filter(a=>_(e,t,a,r))}function me(e){let t=Z({runtime:e.runtime,moduleSupport:e.moduleSupport});if(!e.projectPath)return t;let r=Ie(e.projectPath,e.runtime,e.framework),n=new Set(["help"]);for(let c of r)t.lifecycleCommands.includes(c)&&n.add(c);e.runtime==="node"&&B(e.projectPath)&&n.add("init");let a=[...n].sort();return {lifecycleCommands:a,moduleCommands:t.moduleCommands,unsupportedLifecycleCommands:t.lifecycleCommands.filter(c=>!a.includes(c)).sort()}}var W=["version","commands","doctor","project","help"],A=["init","dev","start","build","test","lint","format"],$=["add","modules","upgrade","diff","merge","reconcile","rollback","uninstall","checkpoint","snapshot","optimize"],J=["create","list","info","frameworks","license"];W.filter(e=>e!=="help");function Be(e){let t$1=i.resolve(e);for(;;){if([...t(t$1,"project.json"),...t(t$1,"context.json")].some(a=>T.existsSync(a)))return t$1;let n=i.dirname(t$1);if(n===t$1)break;t$1=n;}return null}function v(e,t){return {command:e,...t}}var Ge=new Set(["dev","lint","format"]),Ue=new Set(I);function We(e,t){return t?Ue.has(e)?{executionScope:"fleet",fleetEligible:true}:Ge.has(e)?{executionScope:"local-only",fleetEligible:false}:{executionScope:"local-only",fleetEligible:false}:{executionScope:"local-only",fleetEligible:false}}function $e(e,t){return E(t.runtime,e)?"core":"runtime"}function Je(e,t,r,n){return !e||!n.lifecycleCommands.includes(t)?false:_(e,r.runtime,t,r.key)}function qe(e,t){let r=!!e&&(t.runtime==="python"||w(t.runtime)&&_(e,t.runtime,"build",t.key));return v("docs",{owner:t.runtime==="python"?"core":"runtime",status:r?"supported":"unsupported",reason:r?t.runtime==="python"?"Documentation generation is delegated to Python Core for this project.":"Project documentation commands are available through the npm wrapper for this runtime.":"Documentation commands require a supported Python or npm-executor project manifest."})}function Ye(e){let t=i.resolve(e),r=Be(e);return r||(h$1(t).length>0?t:null)}function He(e=process.cwd()){let t=Ye(e),r=t?ne(t):null,n=r?.detection??j(e,r?.projectJson??null),a=r?.moduleSupport??false,c=r?.engine??"unknown",y=se(n.runtime),k=x(n.runtime),le=me({runtime:n.runtime,moduleSupport:a,projectPath:t??void 0,framework:n.key}),b={};for(let o of W)b[o]=v(o,{owner:o==="project"?"core":"npm",status:"supported",reason:o==="project"?"Project detection is a Core contract; workspace project lifecycle remains npm-owned.":o==="help"?"Help is available for every Workspai project through the npm CLI.":"Universal command available across Workspai project types."});for(let o of A){let S=Je(t,o,n,le),Y=$e(o,n),F=We(o,S);b[o]=v(o,{owner:Y,status:S?"supported":"unsupported",executionScope:F.executionScope,fleetEligible:F.fleetEligible,reason:S?Y==="core"?`Delegated to Python Core for ${n.displayName} projects.`:F.fleetEligible?`Handled by runtime adapter and eligible for workspace fleet stages (${o}).`:o==="dev"?"Local development command only; workspace fleet excludes dev by design.":n.runtime==="node"?`Handled by npm/pnpm/yarn via the resolved ${o} script in package.json.`:`Handled by the ${y?.displayName??n.displayName} runtime adapter for local project execution.`:t?n.runtime==="node"?`No ${o} script was found in package.json for this ${n.displayName} project.`:w(n.runtime)?`The ${n.displayName} runtime is tracked, but ${o} is not available from detected project manifests.`:`${n.displayName} is tracked as an observed runtime; ${o} requires project manifests or explicit scripts.`:"No Workspai project was detected."});}b.docs=qe(t,n);for(let o of $)b[o]=v(o,{owner:a?"core":"none",status:a?"supported":"unsupported",reason:a?"Core module/template command supported for this project.":`Core module/template commands are not available for ${n.displayName} projects.`});for(let o of J)b[o]=v(o,{owner:o==="create"?"npm":"core",status:"global",reason:o==="create"?"Create is orchestrated by npm for multi-language workspace support.":"Engine catalog command; not specific to the selected project runtime."});let N=Object.values(b),q=N.filter(o=>A.includes(o.command)).filter(o=>o.status==="supported"),de=I.filter(o=>q.some(S=>S.fleetEligible===true&&S.command===o)),ue=q.filter(o=>o.executionScope==="local-only").map(o=>o.command).sort();return {schemaVersion:1,scope:"project",projectRoot:t,engine:c,runtime:n.runtime,framework:n.key,frameworkDisplayName:n.displayName,frameworkConfidence:n.confidence,frameworkSupportTier:Q(n.key),runtimeSupportTier:k.tier,runtimeDoctorSupport:k.doctorSupport,moduleSupport:a,fleetStages:de,localOnlyCommands:ue,commandMap:b,supportedCommands:N.filter(o=>o.status==="supported").map(o=>o.command).sort(),unsupportedCommands:N.filter(o=>o.status==="unsupported").map(o=>o.command).sort(),globalCommands:N.filter(o=>o.status==="global").map(o=>o.command).sort()}}function cr(e,t=process.cwd()){let r=e[0];return r?He(t).commandMap[r]??null:null}function mr(e){if(e[0]==="project"&&e[1]==="commands")return true;if(e[0]==="commands"&&e.includes("--scope")){let t=e.indexOf("--scope");return e[t+1]==="project"}return e.some(t=>t==="--scope=project")&&e[0]==="commands"}function pr(e,t){return [`Workspai command not supported for this project: ${e.command}`,"",`Project: ${t.projectRoot??"not detected"}`,`Runtime: ${t.runtime}`,`Framework: ${t.frameworkDisplayName}`,`Reason: ${e.reason??"Unsupported for this project type."}`,"","Run `workspai project commands` to inspect supported commands for this project."].join(`
|
|
1
|
+
import {a,c,j,g as g$1,h as h$1}from'./chunk-ZCPT6KC3.js';import {t,u as u$1}from'./chunk-MOSXTVPU.js';import T from'fs';import i from'path';import C from'fs-extra';var V=[{id:"fastapi.standard",aliases:["fastapi","fastapi.standard"],label:"fastapi \u2014 FastAPI Standard Kit",description:"Core-backed FastAPI service scaffold.",owner:"core",runtime:"python",framework:"fastapi",category:"backend",moduleSupport:true,stability:"stable",versionPolicy:"tested-baseline"},{id:"fastapi.ddd",aliases:["fastapi.ddd","fastapi-ddd"],label:"fastapi \u2014 FastAPI DDD Kit",description:"Core-backed FastAPI DDD service scaffold.",owner:"core",runtime:"python",framework:"fastapi",category:"backend",moduleSupport:true,stability:"stable",versionPolicy:"tested-baseline"},{id:"nestjs.standard",aliases:["nestjs","nest","nestjs.standard"],label:"nestjs \u2014 NestJS Standard Kit",description:"Core-backed NestJS service scaffold.",owner:"core",runtime:"node",framework:"nestjs",category:"backend",moduleSupport:true,stability:"stable",versionPolicy:"tested-baseline"},{id:"springboot.standard",aliases:["spring","springboot","springboot.standard","java"],label:"spring \u2014 Spring Boot Standard Kit",description:"npm-backed Spring Boot service scaffold.",owner:"npm",runtime:"java",framework:"springboot",category:"backend",moduleSupport:false,stability:"stable",versionPolicy:"tested-baseline",generator:"springboot",createUsage:"workspai create project springboot.standard <name> [--java-version <major>] [--spring-boot-version <semver>] [--group-id <com.example>] [--package-name <com.example.app>] [--port <number>]"},{id:"gofiber.standard",aliases:["go","go.standard","fiber","gofiber","gofiber.standard","go/fiber"],label:"go/fiber \u2014 Go Fiber Standard Kit",description:"npm-backed Go Fiber service scaffold.",owner:"npm",runtime:"go",framework:"gofiber",category:"backend",moduleSupport:false,stability:"stable",versionPolicy:"tested-baseline",generator:"gofiber",createUsage:"workspai create project gofiber.standard <name> [--output <dir>]"},{id:"gogin.standard",aliases:["gin","gogin","gogin.standard","go/gin"],label:"go/gin \u2014 Go Gin Standard Kit",description:"npm-backed Go Gin service scaffold.",owner:"npm",runtime:"go",framework:"gogin",category:"backend",moduleSupport:false,stability:"stable",versionPolicy:"tested-baseline",generator:"gogin",createUsage:"workspai create project gogin.standard <name> [--output <dir>]"},{id:"dotnet.webapi.clean",aliases:["dotnet","dotnet.webapi","dotnet.webapi.clean","aspnet","aspnetcore","asp.net","asp.net-core","csharp","c#"],label:"dotnet \u2014 ASP.NET Core Clean Web API",description:"npm-backed ASP.NET Core Web API with clean architecture boundaries.",owner:"npm",runtime:"dotnet",framework:"dotnet",category:"backend",moduleSupport:false,stability:"preview",versionPolicy:"tested-baseline",generator:"dotnet-webapi-clean",createUsage:"workspai create project dotnet.webapi.clean <name> [--target-framework net8.0] [--root-namespace <Company.Product>] [--port <number>]"},{id:"rust.axum",aliases:["rust.axum","axum","rust-axum"],label:"rust/axum \u2014 Rust Axum API",description:"Workspai-owned Axum service with health, tests, CI, and container baseline.",owner:"npm",runtime:"rust",framework:"axum",category:"backend",moduleSupport:false,stability:"preview",versionPolicy:"tested-baseline",generator:"rust-axum",createUsage:"workspai create project rust.axum <name> [--port <number>] [--output <dir>] [--skip-git]"}],O=new Map;for(let e of V){O.set(e.id.toLowerCase(),e);for(let t of e.aliases)O.set(t.toLowerCase(),e);}function R(e){return e?O.get(e.trim().toLowerCase())??null:null}function ze(e){return R(e)?.id??e}function Ve(){return V.filter(e=>e.owner==="core"||e.generator)}function Xe(e){return R(e)?.owner==="npm"}async function Qe(e,t){if(!e.generator)throw new Error(`Kit is not backed by an npm generator: ${e.id}`);if(e.generator==="gofiber"){let{generateGoFiberKit:r}=await import('./gofiber-standard-AQGSC7ON.js');await r(t.projectPath,{project_name:t.projectName,module_path:t.projectName,skipGit:t.skipGit,skipInstall:t.skipInstall});return}if(e.generator==="gogin"){let{generateGoGinKit:r}=await import('./gogin-standard-7DU3OCBX.js');await r(t.projectPath,{project_name:t.projectName,module_path:t.projectName,skipGit:t.skipGit,skipInstall:t.skipInstall});return}if(e.generator==="springboot"){let{generateSpringBootKit:r}=await import('./springboot-standard-EK6GYN5T.js');await r(t.projectPath,{project_name:t.projectName,artifact_id:t.projectName,java_version:m(t.args,"--java-version")?.trim(),spring_boot_version:m(t.args,"--spring-boot-version")?.trim(),springdoc_version:m(t.args,"--springdoc-version")?.trim(),group_id:m(t.args,"--group-id")?.trim(),package_name:m(t.args,"--package-name")?.trim(),description:m(t.args,"--description")?.trim(),port:m(t.args,"--port")?.trim(),skipGit:t.skipGit,skipInstall:t.skipInstall});return}if(e.generator==="dotnet-webapi-clean"){let{generateDotnetWebApiCleanKit:r}=await import('./dotnet-webapi-clean-VXEF4SHM.js');await r(t.projectPath,{project_name:t.projectName,target_framework:m(t.args,"--target-framework")?.trim(),root_namespace:m(t.args,"--root-namespace")?.trim(),description:m(t.args,"--description")?.trim(),port:m(t.args,"--port")?.trim(),skipGit:t.skipGit,skipInstall:t.skipInstall});return}if(e.generator==="rust-axum"){let{generateRustAxumKit:r}=await import('./rust-axum-4HXDICIB.js');await r(t.projectPath,{project_name:t.projectName,description:m(t.args,"--description")?.trim(),port:m(t.args,"--port")?.trim(),skipGit:t.skipGit,skipInstall:t.skipInstall});return}throw new Error(`Unhandled npm kit generator: ${e.generator}`)}function m(e,t){let r=e.indexOf(t);if(r>=0&&r+1<e.length)return e[r+1];let n=e.find(a=>a.startsWith(`${t}=`));return n?n.slice(t.length+1):void 0}var f=["init","dev","start","build","test","lint","format","help"],X={python:{runtime:"python",displayName:"Python",tier:"first-class",scaffoldSupport:true,importSupport:true,lifecycleCommands:f,moduleCommands:true,doctorSupport:"full",notes:["Core-backed Python projects support RapidKit Core modules and lifecycle commands."]},node:{runtime:"node",displayName:"Node.js",tier:"extended",scaffoldSupport:true,importSupport:true,lifecycleCommands:f,moduleCommands:true,doctorSupport:"full",notes:["Node projects support npm-owned lifecycle commands; NestJS is the first-class Node framework."]},go:{runtime:"go",displayName:"Go",tier:"extended",scaffoldSupport:true,importSupport:true,lifecycleCommands:f,moduleCommands:false,doctorSupport:"readiness",notes:["Go projects support workspace governance and lifecycle commands via Go tooling."]},java:{runtime:"java",displayName:"Java / Spring Boot",tier:"extended",scaffoldSupport:true,importSupport:true,lifecycleCommands:f,moduleCommands:false,doctorSupport:"readiness",notes:["Java projects support Maven/Gradle lifecycle commands and workspace governance."]},dotnet:{runtime:"dotnet",displayName:".NET / ASP.NET Core",tier:"extended",scaffoldSupport:true,importSupport:true,lifecycleCommands:f,moduleCommands:false,doctorSupport:"readiness",notes:[".NET projects support dotnet CLI lifecycle commands and workspace governance."]},php:{runtime:"php",displayName:"PHP",tier:"extended",scaffoldSupport:true,importSupport:true,lifecycleCommands:f,moduleCommands:false,doctorSupport:"readiness",notes:["Laravel projects use the official Composer generator and PHP/Composer lifecycle adapter."]},ruby:{runtime:"ruby",displayName:"Ruby",tier:"observed",scaffoldSupport:false,importSupport:true,lifecycleCommands:["help"],moduleCommands:false,doctorSupport:"observed",notes:["Ruby projects are importable and governed as observed projects until a kit exists."]},rust:{runtime:"rust",displayName:"Rust",tier:"extended",scaffoldSupport:true,importSupport:true,lifecycleCommands:f,moduleCommands:false,doctorSupport:"readiness",notes:["Rust projects support Axum and Tauri scaffolding plus Cargo lifecycle commands."]},elixir:{runtime:"elixir",displayName:"Elixir",tier:"observed",scaffoldSupport:false,importSupport:true,lifecycleCommands:["help"],moduleCommands:false,doctorSupport:"observed",notes:["Elixir projects are importable and governed as observed projects until a kit exists."]},clojure:{runtime:"clojure",displayName:"Clojure",tier:"observed",scaffoldSupport:false,importSupport:true,lifecycleCommands:["help"],moduleCommands:false,doctorSupport:"observed",notes:["Clojure projects are importable and governed as observed projects until a kit exists."]},scala:{runtime:"scala",displayName:"Scala",tier:"observed",scaffoldSupport:false,importSupport:true,lifecycleCommands:["help"],moduleCommands:false,doctorSupport:"observed",notes:["Scala projects are importable and governed as observed projects until a kit exists."]},kotlin:{runtime:"kotlin",displayName:"Kotlin",tier:"observed",scaffoldSupport:false,importSupport:true,lifecycleCommands:["help"],moduleCommands:false,doctorSupport:"observed",notes:["Kotlin projects are importable and governed as observed projects until a kit exists."]},deno:{runtime:"deno",displayName:"Deno",tier:"observed",scaffoldSupport:false,importSupport:true,lifecycleCommands:["help"],moduleCommands:false,doctorSupport:"observed",notes:["Deno projects are importable and governed as observed projects until a kit exists."]},bun:{runtime:"bun",displayName:"Bun",tier:"observed",scaffoldSupport:false,importSupport:true,lifecycleCommands:["help"],moduleCommands:false,doctorSupport:"observed",notes:["Bun projects are importable and governed as observed projects until a kit exists."]},c:{runtime:"c",displayName:"C",tier:"observed",scaffoldSupport:false,importSupport:true,lifecycleCommands:["help"],moduleCommands:false,doctorSupport:"observed",notes:["C projects are importable and receive manifest, test, quality, security, and coverage evidence without assuming a package manager."]},cpp:{runtime:"cpp",displayName:"C++",tier:"observed",scaffoldSupport:false,importSupport:true,lifecycleCommands:["help"],moduleCommands:false,doctorSupport:"observed",notes:["C++ projects are importable and receive manifest, test, quality, security, and coverage evidence without assuming a package manager."]},unknown:{runtime:"unknown",displayName:"Unknown",tier:"observed",scaffoldSupport:false,importSupport:true,lifecycleCommands:["help"],moduleCommands:false,doctorSupport:"observed",notes:["Unknown projects are tracked safely but require manual command configuration."]}},fe=["fastapi","nestjs"],ge=["django","flask","nextjs","remix","nuxt","react","vite","vue","sveltekit","svelte","angular","astro","solid","express","fastify","koa","echo","gofiber","gogin","springboot","dotnet","laravel","symfony","rails","sinatra","actix","axum","rocket","phoenix","clojure","scala","kotlin","deno","bun","tauri","electron","vscode-extension","c","cpp"];function x(e){return X[e||"unknown"]??X.unknown}function Q(e){return fe.includes(e)?"first-class":ge.includes(e)?"extended":"observed"}function Z(e){let t=x(e.runtime);return {lifecycleCommands:t.lifecycleCommands,moduleCommands:e.moduleSupport&&t.moduleCommands,unsupportedLifecycleCommands:f.filter(r=>!t.lifecycleCommands.includes(r))}}var ye=["python","node","go","java","dotnet","rust","php"];function w(e){return !!e&&ye.includes(e)}function E(e,t){return t!=="lint"&&t!=="format"&&t!=="docs"?false:e==="python"}function ee(e){let t=x(e),r=w(t.runtime),n=be[t.runtime]??[],a=Ce[t.runtime]??[];return {runtime:t.runtime,displayName:t.displayName,lifecycleCommands:t.lifecycleCommands,hasExecutor:r,packageManagers:n,primaryFiles:a,notes:t.notes}}var be={python:["poetry","pip","uv"],node:["npm","pnpm","yarn","bun"],go:["go"],java:["maven","gradle"],dotnet:["dotnet"],php:["composer"],ruby:["bundle"],rust:["cargo"],elixir:["mix"],kotlin:["gradle"],deno:["deno"],bun:["bun"]},Ce={python:["pyproject.toml","requirements.txt","requirements.in"],node:["package.json"],go:["go.mod"],java:["pom.xml","build.gradle","build.gradle.kts"],dotnet:["*.csproj","*.sln"],php:["composer.json"],ruby:["Gemfile"],rust:["Cargo.toml"],elixir:["mix.exs"],kotlin:["settings.gradle.kts"],deno:["deno.json","deno.jsonc"],bun:["package.json","bunfig.toml"]};function h(e,t){let r=g$1({runtime:typeof e?.runtime=="string"?e.runtime:void 0,framework:typeof e?.framework=="string"?e.framework:void 0,kitName:typeof e?.kit_name=="string"?e.kit_name:typeof e?.kit=="string"?e.kit:void 0});return r.runtime!=="unknown"?r.runtime:j(t,e).runtime}function re(e){let t$1=e;for(;;){for(let n of t(t$1,"project.json"))if(T.existsSync(n))try{return JSON.parse(T.readFileSync(n,"utf8"))}catch{return null}let r=i.dirname(t$1);if(r===t$1)break;t$1=r;}return null}function pt(e,t){return h(e,t)==="go"}function lt(e,t){return h(e,t)==="node"}function dt(e,t){return h(e,t)==="java"}function ut(e,t){return h(e,t)==="dotnet"}function ft(e,t){return h(e,t)==="python"}var Se=["project.json","context.json","file-hashes.json"];async function ht(e){let t=i.resolve(e),r=[];for(let n of Se){let a=u$1(t,n);if(await C.pathExists(a))continue;let c=i.join(t,".rapidkit",n);if(!await C.pathExists(c))continue;let y=await C.readJson(c);await C.ensureDir(i.dirname(a));let k=`${a}.${process.pid}.${Date.now()}.tmp`;try{await C.writeJson(k,y,{spaces:2}),await C.move(k,a,{overwrite:false}),r.push(a);}finally{await C.remove(k).catch(()=>{});}}return r}function je(e){for(let t$1 of t(e,"context.json"))if(T.existsSync(t$1))try{return JSON.parse(T.readFileSync(t$1,"utf8"))}catch{return null}return null}function we(e){let t=e?.engine;return t==="npm"||t==="pip"||t==="python"?t:"unknown"}function xe(e,t){if(e?.module_support===false||t?.module_support===false||!e&&t)return false;let r=typeof e?.kit_name=="string"?e.kit_name:typeof e?.kit=="string"?e.kit:typeof t?.kit=="string"?t.kit:void 0,n=r?R(r):void 0;return n?.owner==="core"&&n.moduleSupport===true}function he(e,t,r){let n=g$1({runtime:typeof t?.runtime=="string"?t.runtime:typeof r?.runtime=="string"?r.runtime:void 0,framework:typeof t?.framework=="string"?t.framework:typeof r?.framework=="string"?r.framework:void 0,kitName:typeof t?.kit_name=="string"?t.kit_name:typeof t?.kit=="string"?t.kit:typeof r?.kit=="string"?r.kit:void 0});return n.key!=="unknown"?n:j(e,t)}function ne(e){let t$1=i.resolve(e);if(![...t(t$1,"project.json"),...t(t$1,"context.json")].some(y=>T.existsSync(y)))return null;let n=re(t$1),a=je(t$1),c=he(t$1,n,a);return {projectRoot:t$1,projectJson:n,contextJson:a,detection:c,moduleSupport:xe(n,a),engine:we(a)}}var ve=["build","dev","start","test","lint","format"],I=["init","test","build","start"],Pt=["lint","format","docs"];function Rt(e){return !!e&&ve.includes(e)}var Ne={dev:["dev","start:dev"],start:["start","start:prod","preview"],build:["build"],test:["test","test:unit","test:ci"],lint:["lint"],format:["format","prettier"]},ae={nestjs:{dev:["dev","start:dev"],start:["start","start:prod"],build:["build"],test:["test","test:e2e"],lint:["lint"],format:["format"]},express:{dev:["dev","start:dev"],start:["start"],build:["build"],test:["test"],lint:["lint"],format:["format"]},fastify:{dev:["dev","start:dev"],start:["start"],build:["build"],test:["test"],lint:["lint"],format:["format"]},koa:{dev:["dev","start:dev"],start:["start"],build:["build"],test:["test"],lint:["lint"],format:["format"]}};function Pe(e){let t=i.join(e,"package.json");if(!T.existsSync(t))return {};try{let n=JSON.parse(T.readFileSync(t,"utf8")).scripts??{};return Object.fromEntries(Object.entries(n).filter(a=>typeof a[1]=="string"))}catch{return {}}}function Re(e,t){let r=t?c(t):"unknown",n=r!=="unknown"?a(r,e):[],a$1=t?ae[t]?.[e]??[]:[],c$1=Ne[e]??[],y=[...n,...a$1,...c$1];return [...new Set(y)]}function ie(e,t,r){let n=Pe(e),a$1=new Set(Object.keys(n));if(a$1.has(t))return {scriptName:t,source:"package.json"};for(let c$1 of Re(t,r?.framework))if(a$1.has(c$1))return {scriptName:c$1,source:a(c(r?.framework??"unknown"),t).includes(c$1)||ae[r?.framework??""]?.[t]?.includes(c$1)?"framework-candidate":"generic-candidate"};return null}function B(e){return T.existsSync(i.join(e,"package.json"))}function se(e){let t=ee(e);return t.runtime==="unknown"&&e!=="unknown"?null:{runtime:t.runtime,displayName:t.displayName,supportedCommands:t.lifecycleCommands,packageManagers:t.packageManagers,primaryFiles:t.primaryFiles,notes:t.notes,hasExecutor:t.hasExecutor}}function s(e){try{return T.existsSync(e)}catch{return false}}function g(e){try{return s(e)?T.readFileSync(e,"utf8"):""}catch{return ""}}function u(e,t){let r=g(i.join(e,"Makefile"));return r?new RegExp(`^${t}\\s*:`).test(r):false}function Ee(e){let t=[e];for(;t.length>0;){let r=t.shift();if(!r)break;let n=[];try{n=T.readdirSync(r,{withFileTypes:true});}catch{continue}for(let a of n){if(a.name==="node_modules"||a.name===".git"||a.name==="dist")continue;let c=i.join(r,a.name);if(a.isFile()&&a.name.endsWith(".csproj"))return true;a.isDirectory()&&t.push(c);}}return false}function ce(e,t){let r=s(i.join(e,"pyproject.toml")),n=s(i.join(e,"requirements.txt"))||s(i.join(e,"requirements.in")),a=s(i.join(e,"manage.py"));switch(t){case "init":return r||n;case "dev":case "start":return r||a||n;case "test":return r||n||s(i.join(e,"tests"));case "build":return r||n;case "lint":case "format":return r||n||a||s(i.join(e,"setup.py"))||s(i.join(e,"setup.cfg"));default:return false}}function Me(e,t){if(!s(i.join(e,"go.mod")))return false;switch(t){case "init":return true;case "dev":return u(e,"run")||s(i.join(e,"main.go"));case "test":return true;case "build":return true;case "start":return u(e,"run")||s(i.join(e,"main.go"))||s(i.join(e,"cmd"));case "lint":return s(i.join(e,".golangci.yml"))||s(i.join(e,".golangci.yaml"))||u(e,"lint");case "format":return u(e,"fmt")||u(e,"format");default:return false}}function _e(e,t){let r=s(i.join(e,"pom.xml")),n=s(i.join(e,"build.gradle"))||s(i.join(e,"build.gradle.kts"));if(!r&&!n)return false;switch(t){case "init":case "test":case "build":case "dev":case "start":return true;case "lint":return u(e,"lint")||g(i.join(e,"pom.xml")).includes("checkstyle")||g(i.join(e,"build.gradle")).includes("checkstyle")||g(i.join(e,"build.gradle.kts")).includes("checkstyle");case "format":return u(e,"format")||g(i.join(e,"build.gradle")).includes("spotless")||g(i.join(e,"build.gradle.kts")).includes("spotless");default:return false}}function Ae(e,t){if(!Ee(e))return false;switch(t){case "init":case "dev":case "test":case "build":case "start":return true;case "lint":return u(e,"lint")||g(i.join(e,"Directory.Build.props")).includes("EnforceCodeStyleInBuild");case "format":return u(e,"format")||s(i.join(e,".editorconfig"));default:return false}}function Fe(e,t,r){return t==="init"?B(e):ie(e,t,{framework:r})!==null}function Le(e,t,r){switch(t){case "php":return r==="init"&&s(i.join(e,"composer.json"));case "ruby":return r==="init"&&s(i.join(e,"Gemfile"));case "rust":return s(i.join(e,"Cargo.toml"))?r==="init"||r==="test"||r==="build"||r==="start":false;case "elixir":return r==="init"&&s(i.join(e,"mix.exs"));case "deno":return s(i.join(e,"deno.json"))||s(i.join(e,"deno.jsonc"))?r==="init"||r==="dev"||r==="test"||r==="start":r==="init"&&s(i.join(e,"package.json"));case "bun":return s(i.join(e,"bunfig.toml"))||s(i.join(e,"bun.lock"))?r==="init"||r==="dev"||r==="test"||r==="build"||r==="start":r==="init"&&s(i.join(e,"package.json"));default:return false}}function De(e){try{let t=JSON.parse(g(i.join(e,"composer.json")));return new Set(Object.keys(t.scripts??{}))}catch{return new Set}}function Oe(e,t){if(!s(i.join(e,"composer.json")))return false;let r=De(e),n=s(i.join(e,"artisan"));switch(t){case "init":return true;case "dev":return n||r.has("dev");case "start":return n||r.has("start");case "test":return n||r.has("test");case "build":return r.has("build");case "lint":return r.has("lint")||r.has("analyse")||r.has("analyze");case "format":return r.has("format")||r.has("fmt")||s(i.join(e,"pint.json"))||s(i.join(e,"vendor","bin","pint"));default:return false}}function Te(e,t){return s(i.join(e,"Cargo.toml"))?t==="init"||t==="dev"||t==="start"||t==="build"||t==="test"||t==="lint"||t==="format":false}function _(e,t,r,n){if(E(t,r))return ce(e,r);if(!w(t))return Le(e,t,r);switch(t){case "node":return Fe(e,r,n);case "python":return ce(e,r);case "go":return Me(e,r);case "java":return _e(e,r);case "dotnet":return Ae(e,r);case "rust":return Te(e,r);case "php":return Oe(e,r);default:return false}}function Ie(e,t,r){return ["init","dev","start","build","test","lint","format"].filter(a=>_(e,t,a,r))}function me(e){let t=Z({runtime:e.runtime,moduleSupport:e.moduleSupport});if(!e.projectPath)return t;let r=Ie(e.projectPath,e.runtime,e.framework),n=new Set(["help"]);for(let c of r)t.lifecycleCommands.includes(c)&&n.add(c);e.runtime==="node"&&B(e.projectPath)&&n.add("init");let a=[...n].sort();return {lifecycleCommands:a,moduleCommands:t.moduleCommands,unsupportedLifecycleCommands:t.lifecycleCommands.filter(c=>!a.includes(c)).sort()}}var W=["version","commands","doctor","project","help"],A=["init","dev","start","build","test","lint","format"],$=["add","modules","upgrade","diff","merge","reconcile","rollback","uninstall","checkpoint","snapshot","optimize"],J=["create","list","info","frameworks","license"];W.filter(e=>e!=="help");function Be(e){let t$1=i.resolve(e);for(;;){if([...t(t$1,"project.json"),...t(t$1,"context.json")].some(a=>T.existsSync(a)))return t$1;let n=i.dirname(t$1);if(n===t$1)break;t$1=n;}return null}function v(e,t){return {command:e,...t}}var Ge=new Set(["dev","lint","format"]),Ue=new Set(I);function We(e,t){return t?Ue.has(e)?{executionScope:"fleet",fleetEligible:true}:Ge.has(e)?{executionScope:"local-only",fleetEligible:false}:{executionScope:"local-only",fleetEligible:false}:{executionScope:"local-only",fleetEligible:false}}function $e(e,t){return E(t.runtime,e)?"core":"runtime"}function Je(e,t,r,n){return !e||!n.lifecycleCommands.includes(t)?false:_(e,r.runtime,t,r.key)}function qe(e,t){let r=!!e&&(t.runtime==="python"||w(t.runtime)&&_(e,t.runtime,"build",t.key));return v("docs",{owner:t.runtime==="python"?"core":"runtime",status:r?"supported":"unsupported",reason:r?t.runtime==="python"?"Documentation generation is delegated to Python Core for this project.":"Project documentation commands are available through the npm wrapper for this runtime.":"Documentation commands require a supported Python or npm-executor project manifest."})}function Ye(e){let t=i.resolve(e),r=Be(e);return r||(h$1(t).length>0?t:null)}function He(e=process.cwd()){let t=Ye(e),r=t?ne(t):null,n=r?.detection??j(e,r?.projectJson??null),a=r?.moduleSupport??false,c=r?.engine??"unknown",y=se(n.runtime),k=x(n.runtime),le=me({runtime:n.runtime,moduleSupport:a,projectPath:t??void 0,framework:n.key}),b={};for(let o of W)b[o]=v(o,{owner:o==="project"?"core":"npm",status:"supported",reason:o==="project"?"Project detection is a Core contract; workspace project lifecycle remains npm-owned.":o==="help"?"Help is available for every Workspai project through the npm CLI.":"Universal command available across Workspai project types."});for(let o of A){let S=Je(t,o,n,le),Y=$e(o,n),F=We(o,S);b[o]=v(o,{owner:Y,status:S?"supported":"unsupported",executionScope:F.executionScope,fleetEligible:F.fleetEligible,reason:S?Y==="core"?`Delegated to Python Core for ${n.displayName} projects.`:F.fleetEligible?`Handled by runtime adapter and eligible for workspace fleet stages (${o}).`:o==="dev"?"Local development command only; workspace fleet excludes dev by design.":n.runtime==="node"?`Handled by npm/pnpm/yarn via the resolved ${o} script in package.json.`:`Handled by the ${y?.displayName??n.displayName} runtime adapter for local project execution.`:t?n.runtime==="node"?`No ${o} script was found in package.json for this ${n.displayName} project.`:w(n.runtime)?`The ${n.displayName} runtime is tracked, but ${o} is not available from detected project manifests.`:`${n.displayName} is tracked as an observed runtime; ${o} requires project manifests or explicit scripts.`:"No Workspai project was detected."});}b.docs=qe(t,n);for(let o of $)b[o]=v(o,{owner:a?"core":"none",status:a?"supported":"unsupported",reason:a?"Core module/template command supported for this project.":`Core module/template commands are not available for ${n.displayName} projects.`});for(let o of J)b[o]=v(o,{owner:o==="create"?"npm":"core",status:"global",reason:o==="create"?"Create is orchestrated by npm for multi-language workspace support.":"Engine catalog command; not specific to the selected project runtime."});let N=Object.values(b),q=N.filter(o=>A.includes(o.command)).filter(o=>o.status==="supported"),de=I.filter(o=>q.some(S=>S.fleetEligible===true&&S.command===o)),ue=q.filter(o=>o.executionScope==="local-only").map(o=>o.command).sort();return {schemaVersion:1,scope:"project",projectRoot:t,engine:c,runtime:n.runtime,framework:n.key,frameworkDisplayName:n.displayName,frameworkConfidence:n.confidence,frameworkSupportTier:Q(n.key),runtimeSupportTier:k.tier,runtimeDoctorSupport:k.doctorSupport,moduleSupport:a,fleetStages:de,localOnlyCommands:ue,commandMap:b,supportedCommands:N.filter(o=>o.status==="supported").map(o=>o.command).sort(),unsupportedCommands:N.filter(o=>o.status==="unsupported").map(o=>o.command).sort(),globalCommands:N.filter(o=>o.status==="global").map(o=>o.command).sort()}}function cr(e,t=process.cwd()){let r=e[0];return r?He(t).commandMap[r]??null:null}function mr(e){if(e[0]==="project"&&e[1]==="commands")return true;if(e[0]==="commands"&&e.includes("--scope")){let t=e.indexOf("--scope");return e[t+1]==="project"}return e.some(t=>t==="--scope=project")&&e[0]==="commands"}function pr(e,t){return [`Workspai command not supported for this project: ${e.command}`,"",`Project: ${t.projectRoot??"not detected"}`,`Runtime: ${t.runtime}`,`Framework: ${t.frameworkDisplayName}`,`Reason: ${e.reason??"Unsupported for this project type."}`,"","Run `workspai project commands` to inspect supported commands for this project."].join(`
|
|
2
2
|
`)}export{R as a,ze as b,Ve as c,Xe as d,Qe as e,x as f,Q as g,w as h,re as i,pt as j,lt as k,dt as l,ut as m,ft as n,ht as o,ne as p,ve as q,Pt as r,Rt as s,ie as t,me as u,Be as v,He as w,cr as x,mr as y,pr as z};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import {a as a$1}from'./chunk-T5YRFRJV.js';import {w}from'./chunk-DIZSHNZ5.js';import {a}from'./chunk-GR6442P7.js';import {a as a$2,d,c,e as e$2}from'./chunk-ADL3CK44.js';import {b}from'./chunk-LYVDRRDO.js';import {i,e,h,f}from'./chunk-5EPPPMAS.js';import {l}from'./chunk-OCGZNSOE.js';import {e as e$1}from'./chunk-RO73VVHW.js';import {t,s}from'./chunk-MOSXTVPU.js';import g from'path';import h$1 from'fs-extra';var ue="unknown-run";function Z(e){let t=e$1();return !t||t===ue?e:{...e,runId:t}}var xe="workspace-dependency-graph.v1",Q=["code-import","package-dep","event-pub-sub","service-dependsOn","shared-resource"],X=["inferred","contract","manual"];var E=i.workspaceContract,me=e.contractVerify,S=h.workspaceContract.schemaVersion,ge=f.contractVerify,x=class extends Error{constructor(r){super(`Workspace contract verification failed: ${r.violations.join("; ")}`);this.verification=r;this.name="WorkspaceContractVerificationError";}verification};function ne(e){return e.replace(/\\/g,"/")}function V(e){let t=ne(e).trim();return !t||t.startsWith("/")||t.startsWith("~")||/^[a-zA-Z]:\//.test(t)||t.includes("\0")?false:!t.split("/").filter(Boolean).some(r=>r===".."||r===".")}function ee(e,t){return e.trim().toLowerCase().replace(/[^a-z0-9._-]+/g,"-").replace(/-+/g,"-").replace(/^[-_.]+|[-_.]+$/g,"").slice(0,80)||t}function fe(e){return Array.isArray(e)?e.filter(t=>typeof t=="string"&&t.trim().length>0):[]}function te(e){let r=(Array.isArray(e.ports)?e.ports:[]).map(p=>{if(!p||typeof p!="object"||Array.isArray(p))return null;let c=p,m=Number(c.port);if(!Number.isInteger(m)||m<1||m>65535)return null;let l=c.protocol==="https"||c.protocol==="grpc"||c.protocol==="tcp"||c.protocol==="udp"?c.protocol:"http";return {name:typeof c.name=="string"&&c.name.trim()?c.name:"http",port:m,protocol:l}}).filter(p=>p!==null);if(r.length>0)return r;let o=e.frontend&&typeof e.frontend=="object"&&!Array.isArray(e.frontend)?e.frontend:void 0,a=Number(e.port??o?.default_port);return Number.isInteger(a)&&a>=1&&a<=65535?[{name:"http",port:a,protocol:"http"}]:[]}async function he(e){let t=g.join(e,"Dockerfile");if(!await h$1.pathExists(t))return [];try{let r=await h$1.readFile(t,"utf8"),o=new Map;for(let a of r.matchAll(/^\s*EXPOSE\s+(.+)$/gim))for(let p of a[1].split(/\s+/)){let c=p.match(/^(\d{1,5})(?:\/(tcp|udp))?$/i),m=Number(c?.[1]);if(!c||!Number.isInteger(m)||m<1||m>65535)continue;let l=c[2]?.toLowerCase();o.set(m,{name:"http",port:m,protocol:l==="udp"?"udp":"http"});}return [...o.values()].sort((a,p)=>a.port-p.port)}catch{return []}}async function G(e){for(let t of e)if(await h$1.pathExists(t))return t;return null}async function ke(e){for(let t of s(e,"workspace.json"))try{let r=await h$1.readJson(t);return {name:typeof r.workspace_name=="string"&&r.workspace_name.trim()||typeof r.name=="string"&&r.name.trim()||g.basename(e),profile:typeof r.profile=="string"?r.profile:void 0}}catch{}return {name:g.basename(e)}}async function we(e){let t$1=[],r=[e],o=new Set,a$1=new Set([".git",".workspai",".rapidkit","node_modules",".venv","venv","dist","build","target",".next",".turbo",".cache"]);for(;r.length>0;){let p=r.shift();if(!p||o.has(p))continue;o.add(p);let c=await G(t(p,"project.json")),m=await G(t(p,"context.json"));if(c||m){t$1.push(c??m??"");continue}let l;try{l=await h$1.readdir(p,{withFileTypes:true});}catch{continue}for(let d of l)!d.isDirectory()||a$1.has(d.name)||a(d.name)||r.push(g.join(p,d.name));}return t$1.sort()}function Pe(e){let t=(e||"").toLowerCase();if(t.includes("fastapi"))return "fastapi";if(t.includes("nestjs"))return "nestjs";if(t.includes("springboot"))return "springboot";if(t.includes("gofiber"))return "fiber";if(t.includes("gogin"))return "gin"}function Ce(e,t){let r=(e||"").toLowerCase(),o=(t||"").toLowerCase();return r.includes("vscode-extension")?null:r.includes("fastapi")?8e3:r.includes("nestjs")?3e3:r.includes("springboot")?8080:r.includes("gofiber")?3e3:r.includes("gogin")?8080:r.startsWith("adopted.")?null:o==="node"?3e3:o==="python"?8e3:o==="java"||o==="go"?8080:null}function I(e,t){let r=e;for(;t.has(r)&&r<65535;)r+=1;return r}function T(e,t,r){let o=e!==void 0&&e.source===void 0,a=Ce(t.kit,t.runtime),p=e?.ports||[],c=t.ports||[],m=(t.kit||"").toLowerCase().includes("vscode-extension"),l=t.source==="adopted-local"&&e?.source==="adopted-local",d=l,i=(m&&c.length===0?[]:l?c.length>0?c:a?[{name:"http",port:I(a,r),protocol:"http"}]:[]:p.length>0?p:c.length>0?c:a?[{name:"http",port:I(a,r),protocol:"http"}]:[]).map(P=>({...P,port:I(P.port,r)}));for(let P of i)r.add(P.port);let k={...t,...e,slug:e?.slug||t.slug,relativePath:o&&e?.relativePath&&V(e.relativePath)?e.relativePath:t.relativePath,source:o&&e?.source||t.source,relationship:o&&e?.relationship||t.relationship,externalPath:o&&e?.externalPath||t.externalPath,runtime:d?t.runtime:e?.runtime||t.runtime,framework:d?t.framework:e?.framework||t.framework,kit:d?t.kit:e?.kit||t.kit,modules:e?.modules?.length?e.modules:t.modules,ports:i,contracts:{owns:e?.contracts?.owns||[],apis:e?.contracts?.apis||[],publishes:e?.contracts?.publishes||[],consumes:e?.contracts?.consumes||[],dependsOn:e?.contracts?.dependsOn||[],env:e?.contracts?.env||[]}},f=JSON.stringify(e||null)!==JSON.stringify(k);return {project:k,changed:f}}async function ae(e){let t$1=g.resolve(e.workspacePath),r=await ke(t$1),o=await we(t$1),a=await a$1(t$1),p=[];for(let d of a){let s=g.resolve(d.path),i=await G(t(s,"project.json"))??await G(t(s,"context.json"));!i||o.some(k=>g.resolve(k)===g.resolve(i))||p.push({projectJsonPath:i,registryEntry:d});}let c=[],m=[...o.map(d=>({projectJsonPath:d})),...p];for(let{projectJsonPath:d,registryEntry:s}of m){let i=g.dirname(g.dirname(d)),k=ne(g.relative(t$1,i)),f=s!==void 0&&!V(k),P=ee(s?.name||g.basename(i),g.basename(i)),C=f?`external/${P}`:k||P,w=await h$1.readJson(d),j=typeof w.kit_name=="string"&&w.kit_name||typeof w.kit=="string"&&w.kit||void 0,n=typeof w.framework=="string"&&w.framework||Pe(j);c.push({slug:s?.name||C||g.basename(i),relativePath:C,source:s?.source??"workspace",relationship:s?.relationship,externalPath:f?i:void 0,runtime:typeof w.runtime=="string"?w.runtime:void 0,framework:n,kit:j,modules:fe(w.modules),ports:te(w).length>0?te(w):await he(i),contracts:{owns:[],apis:[],publishes:[],consumes:[],dependsOn:[],env:[]}});}let l=new Map;for(let d of c){let s=ee(d.slug,d.relativePath),i=l.get(s);(!i||i.source!=="workspace"&&d.source==="workspace")&&l.set(s,d);}return {schemaVersion:S,kind:"rapidkit.workspace.contract",generatedAt:(e.now??new Date).toISOString(),workspace:r,projects:[...l.values()]}}async function Ue(e){let t=g.resolve(e.outputPath||a$2(e.workspacePath,E));if(await h$1.pathExists(t)&&e.force!==true)throw new Error(`Workspace contract already exists: ${t}. Use --force to overwrite.`);let r=await ae({workspacePath:e.workspacePath,now:e.now}),o=new Set,a={...r,projects:r.projects.map(c=>T(void 0,c,o).project)},p=await ie({workspacePath:e.workspacePath,contractPath:t,contract:a});if(e.strict&&p.status==="failed")throw new x(p);return await se({workspacePath:e.workspacePath,contractPath:t,contract:a,now:e.now}),{contractPath:t,contract:a}}async function ze(e){let t=g.resolve(e.workspacePath),r=a$2(t,E),o=await d(t,E)??r,a=await ae({workspacePath:t,now:e.now}),p=await h$1.pathExists(o)?await h$1.readJson(o):null,c=new Map((p?.projects||[]).map(f=>[f.slug,f])),m=new Set,l=[],d$1=[],s=[];for(let f of a.projects){let P=c.get(f.slug),C=T(P,f,m);P?C.changed&&d$1.push(f.slug):l.push(f.slug),s.push(C.project),c.delete(f.slug);}for(let f of c.values()){if(f.source)continue;let P=T(f,f,m);s.push(P.project);}let i={schemaVersion:S,kind:"rapidkit.workspace.contract",generatedAt:(e.now??new Date).toISOString(),workspace:{...p?.workspace||{},...a.workspace,name:a.workspace.name||p?.workspace?.name||g.basename(t)},projects:s.sort((f,P)=>f.slug.localeCompare(P.slug))},k=await ie({workspacePath:t,contractPath:r,contract:i});if(e.strict&&k.status==="failed")throw new x(k);return await se({workspacePath:t,contractPath:r,contract:i,now:e.now}),{contractPath:r,contract:i,addedProjects:l,updatedProjects:d$1,verification:k}}async function re(e){return await h$1.pathExists(e)?{exists:true,contents:await h$1.readFile(e)}:{exists:false}}async function oe(e,t){if(!t.exists){await h$1.remove(e);return}await h$1.outputFile(e,t.contents);}async function se(e){let{buildWorkspaceRegistrySummary:t,WORKSPACE_REGISTRY_SUMMARY_RELATIVE_PATH:r}=await import('./workspace-registry-summary-A5VDPRHU.js'),o=await t(e.workspacePath,{now:e.now,contract:e.contract}),a=a$2(e.workspacePath,r),p=c=>{if(!c||typeof c!="object"||Array.isArray(c))return JSON.stringify(c);let{generatedAt:m,...l}=c;return JSON.stringify(l)};if(await h$1.pathExists(e.contractPath)&&await h$1.pathExists(a)){let[c,m]=await Promise.all([h$1.readJson(e.contractPath),h$1.readJson(a)]);if(p(c)===p(e.contract)&&p(m)===p(o))return}b(E,e.contract),b(r,o),await c(e.workspacePath,E,async()=>{let[c,m]=await Promise.all([re(e.contractPath),re(a)]);try{if(e.contractPath===a$2(e.workspacePath,E)?await e$2(e.workspacePath,E,e.contract):(await h$1.ensureDir(g.dirname(e.contractPath)),await h$1.writeJson(e.contractPath,e.contract,{spaces:2})),process.env.WORKSPAI_TEST_FAIL_WORKSPACE_REGISTRY_PUBLISH==="1")throw new Error("Injected workspace registry summary publication failure.");await e$2(e.workspacePath,r,o);}catch(l){let s=(await Promise.allSettled([oe(e.contractPath,c),oe(a,m)])).filter(i=>i.status==="rejected");throw s.length>0?new AggregateError([l,...s.map(i=>i.reason)],"Workspace contract publication failed and rollback was incomplete."):l}});}async function ce(e){let t=e.contractPath??(await d(e.workspacePath,E)||a$2(e.workspacePath,E)),r=await h$1.readJson(t);return {contractPath:t,contract:r}}var ye={metadata:[".workspai/project.json",".workspai/context.json",".rapidkit/project.json",".rapidkit/context.json"],manifests:["package.json","package-lock.json","pnpm-lock.yaml","yarn.lock","pyproject.toml","poetry.lock","requirements.txt","go.mod","go.sum","pom.xml","build.gradle","build.gradle.kts","Cargo.toml","Gemfile","composer.json"],entrypoints:["src/main.ts","src/index.ts","src/app.ts","src/main.js","src/index.js","main.py","app/main.py","manage.py","main.go","cmd/main.go","Program.cs"],apiSpecifications:["openapi.yaml","openapi.yml","openapi.json","swagger.yaml","swagger.yml","swagger.json"],infrastructure:["Dockerfile","docker-compose.yml","docker-compose.yaml","compose.yml","compose.yaml","k8s","kubernetes","terraform"],documentation:["README.md","ARCHITECTURE.md","CONTRIBUTING.md","docs"]};function Ee(e,t){return t.externalPath?g.resolve(t.externalPath):g.resolve(e,t.relativePath)}async function be(e){let t={metadata:[],manifests:[],entrypoints:[],apiSpecifications:[],infrastructure:[],documentation:[]};for(let[r,o]of Object.entries(ye))for(let a of o)await h$1.pathExists(g.join(e,a))&&t[r].push(a);try{let r=await h$1.readdir(e,{withFileTypes:true});for(let o of r)o.isFile()&&(o.name.endsWith(".csproj")||o.name.endsWith(".sln"))&&t.manifests.push(o.name),o.isFile()&&o.name.endsWith(".tf")&&t.infrastructure.push(o.name);}catch{}for(let r of Object.values(t))r.sort((o,a)=>o.localeCompare(a));return t}function A(e){return !e||typeof e!="object"||Array.isArray(e)?[]:Object.keys(e).sort((t,r)=>t.localeCompare(r))}async function We(e){try{let t=await h$1.readJson(g.join(e,"package.json")),r={runtime:A(t.dependencies),development:A(t.devDependencies),peer:A(t.peerDependencies),optional:A(t.optionalDependencies)};return {...typeof t.name=="string"?{name:t.name}:{},...typeof t.version=="string"?{version:t.version}:{},...typeof t.private=="boolean"?{private:t.private}:{},scripts:A(t.scripts),dependencies:r,dependencyCount:new Set(Object.values(r).flat()).size}}catch{return}}async function ve(e){for(let t of [".env.example",".env.sample",".env.template"])try{return (await h$1.readFile(g.join(e,t),"utf8")).split(/\r?\n/).map(o=>o.trim()).filter(o=>o.length>0&&!o.startsWith("#")&&o.includes("=")).map(o=>o.slice(0,o.indexOf("=")).trim()).filter(o=>/^[A-Za-z_][A-Za-z0-9_]*$/.test(o)).sort((o,a)=>o.localeCompare(a))}catch{}return []}function Ae(e,t){try{let r=w(e);if(r.engine!=="unknown")return r;let o=h$1.pathExistsSync(g.join(e,"package.json"))?"npm":h$1.pathExistsSync(g.join(e,"pyproject.toml"))?"python":h$1.pathExistsSync(g.join(e,"requirements.txt"))?"pip":"unknown";return {...r,engine:o,runtime:t.runtime??r.runtime,framework:t.framework??r.framework,frameworkDisplayName:t.framework??r.frameworkDisplayName}}catch{return {schemaVersion:1,scope:"project",projectRoot:null,engine:"unknown",runtime:"unknown",framework:"unknown",frameworkDisplayName:"Unknown",frameworkConfidence:"low",frameworkSupportTier:"observed",runtimeSupportTier:"observed",runtimeDoctorSupport:"observed",moduleSupport:false,fleetStages:[],localOnlyCommands:[],commandMap:{},supportedCommands:[],unsupportedCommands:[],globalCommands:[]}}}function Se(e,t,r){let o=e.projects.map(a=>({id:a.slug,path:a.relativePath,runtime:a.runtime,framework:a.framework}));return {schemaVersion:"workspace-dependency-graph.v1",generatedAt:t,nodes:o,edges:[],stats:{nodeCount:o.length,edgeCount:0,inferredEdges:0,contractEdges:0,manualEdges:0,authoritativeEdges:0,lowConfidenceEdges:0,orphanCount:o.length,connectedNodeCount:0,density:0,edgeCoverageRatio:o.length===0?1:0,evidenceCoverageRatio:1,hotspotCount:0,hasCycle:false},diagnostics:[{code:"graph.enrichment.failed",severity:"warning",message:r,recommendation:"Review project manifests and graph overrides, then rerun workspace contract graph."}]}}async function Ye(e$1){let{contractPath:t,contract:r}=await ce(e$1),o=e$1.now??new Date,a=o.toISOString(),{buildWorkspaceModel:p,workspaceModelProjectTopology:c}=await import('./workspace-model-NXFIKX26.js'),{hashWorkspaceModel:m}=await import('./workspace-model-hash-ZXYPIGCW.js'),l=await p({workspacePath:e$1.workspacePath,includeEvidence:false,now:o}),d=c(l)??Se(r,a,"The canonical Workspace Model did not provide a project dependency topology."),s=new Map(d.nodes.map(n=>[n.id,n.operationalProfile])),{buildWorkspaceKnowledgeGraph:i}=await import('./workspace-knowledge-graph-VWQTIEYK.js'),k=await i({workspacePath:e$1.workspacePath,workspace:{name:l.workspace.name,...l.workspace.profile?{profile:l.workspace.profile}:{}},contract:r,projectTopology:d,now:o,projects:l.projects.map(n=>({id:n.name,path:n.path,...n.absolutePath?{absolutePath:n.absolutePath}:{},runtime:n.runtime,runtimeCandidates:n.runtimeCandidates,framework:n.framework,...n.kit?{kit:n.kit}:{}})),source:{kind:"workspace-model",artifact:e.model,hashAlgorithm:"sha256",hash:m(l)}}),f=await Promise.all(r.projects.map(async n=>{let u=Ee(e$1.workspacePath,n),[R,W,pe]=await Promise.all([be(u),We(u),ve(u)]),y=Ae(u,n);return {id:n.slug,label:n.slug,relativePath:n.relativePath,source:n.source,relationship:n.relationship,externalPath:n.externalPath,runtime:n.runtime??y.runtime,framework:n.framework??y.framework,kit:n.kit,modules:n.modules,ports:n.ports,apis:n.contracts.apis,owns:n.contracts.owns,env:[...new Set([...n.contracts.env,...pe])].sort((de,le)=>de.localeCompare(le)),contracts:{owns:[...n.contracts.owns],apis:[...n.contracts.apis],publishes:[...n.contracts.publishes],consumes:[...n.contracts.consumes],dependsOn:[...n.contracts.dependsOn],env:[...n.contracts.env]},capabilities:{engine:y.engine,supportTier:y.frameworkSupportTier,runtimeSupportTier:y.runtimeSupportTier,doctorSupport:y.runtimeDoctorSupport,moduleSupport:y.moduleSupport,fleetStages:[...y.fleetStages],localOnlyCommands:[...y.localOnlyCommands],supportedCommands:[...y.supportedCommands]},files:R,...W?{package:W}:{},...s.get(n.slug)?{operationalProfile:s.get(n.slug)}:{}}})),P=new Set(f.map(n=>n.id)),C=new Map,w=[];for(let n of r.projects){for(let u of n.contracts.dependsOn||[])P.has(u)&&w.push({from:u,to:n.slug,type:"dependency",label:"dependsOn"});for(let u of n.contracts.publishes||[])C.has(u)||C.set(u,new Set),C.get(u)?.add(n.slug);}for(let n of r.projects)for(let u of n.contracts.consumes||[]){let R=C.get(u);if(R)for(let W of R)W!==n.slug&&w.push({from:W,to:n.slug,type:"event",label:u});}let j={schemaVersion:1,kind:"rapidkit.workspace.contract.graph",workspace:r.workspace,generatedAt:a,nodes:f.sort((n,u)=>n.id.localeCompare(u.id)),edges:w.sort((n,u)=>`${n.from}:${n.to}:${n.type}:${n.label}`.localeCompare(`${u.from}:${u.to}:${u.type}:${u.label}`)),dependencyGraph:d,knowledgeGraph:k,semantics:{legacyEdges:"producer-to-consumer",dependencyGraphEdges:"consumer-to-dependency"},summary:{projectCount:f.length,dependencyEdges:w.filter(n=>n.type==="dependency").length,eventEdges:w.filter(n=>n.type==="event").length,portCount:f.reduce((n,u)=>n+u.ports.length,0),apiCount:f.reduce((n,u)=>n+u.apis.length,0),relationshipEdges:d.stats.edgeCount,inferredEdges:d.stats.inferredEdges,authoritativeEdges:d.stats.authoritativeEdges,orphanProjects:d.stats.orphanCount,hotspotProjects:d.stats.hotspotCount,evidenceCoverageRatio:d.stats.evidenceCoverageRatio,edgeCoverageRatio:d.stats.edgeCoverageRatio,connectedProjects:d.stats.connectedNodeCount,lowConfidenceEdges:d.stats.lowConfidenceEdges,hasCycle:d.stats.hasCycle,manifestCount:f.reduce((n,u)=>n+u.files.manifests.length,0),entrypointCount:f.reduce((n,u)=>n+u.files.entrypoints.length,0),diagnostics:d.diagnostics?.length??0,relationshipKinds:Object.fromEntries(Q.map(n=>[n,d.edges.filter(u=>u.kind===n).length])),relationshipSources:Object.fromEntries(X.map(n=>[n,d.edges.filter(u=>u.source===n).length])),entityCount:k.quality.entityCount,knowledgeRelations:k.quality.relationCount,proofCount:k.quality.proofCount,providerCount:k.providers.length,knowledgeUnknowns:k.quality.unknownCount}};return {contractPath:t,graph:j}}async function ie(e){let t=e.contract?{contractPath:e.contractPath??a$2(e.workspacePath,E),contract:e.contract}:await ce(e),{contractPath:r,contract:o}=t,a=[],p=[];o.kind!=="rapidkit.workspace.contract"&&a.push("Contract kind must be rapidkit.workspace.contract."),o.schemaVersion!==S&&a.push(`Contract schemaVersion must be ${S}.`),o.workspace?.name||a.push("Contract workspace.name is required."),Array.isArray(o.projects)||a.push("Contract projects must be an array.");let c=new Set,m=new Map;for(let s of o.projects||[]){if(!s.slug){a.push("Every project must declare slug.");continue}c.has(s.slug)&&a.push(`Duplicate project slug: ${s.slug}.`),c.add(s.slug),s.relativePath?V(s.relativePath)||a.push(`Project ${s.slug} declares unsafe relativePath: ${s.relativePath}.`):a.push(`Project ${s.slug} must declare relativePath.`),s.externalPath&&(s.relationship==="adopted"||s.source==="adopted-local"||s.source==="local-folder"||s.source==="git-url"||a.push(`Project ${s.slug} declares externalPath without imported/adopted provenance.`),g.isAbsolute(s.externalPath)||a.push(`Project ${s.slug} declares non-absolute externalPath.`));for(let i of s.ports||[]){(!Number.isInteger(i.port)||i.port<1||i.port>65535)&&a.push(`Project ${s.slug} declares invalid port: ${i.port}.`);let k=m.get(i.port);k&&a.push(`Port ${i.port} is claimed by both ${k} and ${s.slug}.`),m.set(i.port,s.slug);}for(let i of s.contracts?.apis||[])(!i.name?.trim()||!i.basePath?.startsWith("/"))&&a.push(`Project ${s.slug} declares invalid API contract.`);for(let i of [...s.contracts?.publishes||[],...s.contracts?.consumes||[]])i.trim()||a.push(`Project ${s.slug} declares an empty event contract.`);for(let i of s.contracts?.env||[])/^[A-Z_][A-Z0-9_]*$/.test(i)||a.push(`Project ${s.slug} declares invalid env contract: ${i}.`);for(let i of s.contracts?.dependsOn||[])c.has(i);}for(let s of o.projects||[])for(let i of s.contracts?.dependsOn||[])c.has(i)||a.push(`Project ${s.slug} depends on unknown project: ${i}.`);p.push({id:"schema",status:o.kind==="rapidkit.workspace.contract"&&o.schemaVersion===S?"passed":"failed",message:"Contract schema and kind are valid."}),p.push({id:"projects",status:Array.isArray(o.projects)?"passed":"failed",message:`Contract declares ${Array.isArray(o.projects)?o.projects.length:0} project(s).`}),p.push({id:"ports",status:a.some(s=>s.toLowerCase().includes("port"))?"failed":"passed",message:"Project port declarations are valid and collision-free."}),p.push({id:"dependencies",status:a.some(s=>s.includes("depends on unknown project"))?"failed":"passed",message:"Project dependencies point to known project slugs."}),p.push({id:"contracts",status:a.some(s=>s.includes("unsafe relativePath")||s.includes("invalid API contract")||s.includes("event contract")||s.includes("env contract"))?"failed":"passed",message:"Project path, API, event, and env contracts are valid."});let l$1=await l(e.workspacePath);if(l$1.moduleCount>0){for(let s of l$1.issues)a.push(`${g.basename(s.projectRoot)}: ${s.message} (slug=${s.slug})`);p.push({id:"module-paths",status:l$1.status,message:l$1.status==="passed"?`All ${l$1.moduleCount} registered module(s) resolve under canonical paths.`:`${l$1.issues.length} registered module(s) missing canonical install paths.`});}else e.strict&&p.push({id:"module-paths",status:"passed",message:"No registry-backed modules declared in workspace projects."});return {status:a.length>0?"failed":"passed",contractPath:r,projectCount:Array.isArray(o.projects)?o.projects.length:0,checks:p,violations:a}}async function qe(e){let t=g.resolve(e.workspacePath),r={schemaVersion:ge,generatedAt:e.generatedAt??new Date().toISOString(),status:e.result.status,contractPath:e.result.contractPath,projectCount:e.result.projectCount,checks:e.result.checks,violations:e.result.violations};return e$2(t,me,Z(r))}
|
|
2
|
+
export{Z as a,xe as b,Q as c,E as d,me as e,S as f,ge as g,x as h,we as i,ae as j,Ue as k,ze as l,ce as m,Ye as n,ie as o,qe as p};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {a}from'./chunk-GR6442P7.js';import {a as a$1}from'./chunk-AFIFZTOY.js';import {
|
|
1
|
+
import {a}from'./chunk-GR6442P7.js';import {a as a$1}from'./chunk-AFIFZTOY.js';import {i}from'./chunk-5EPPPMAS.js';import {j,s,p as p$1,v}from'./chunk-MOSXTVPU.js';import z from'crypto';import Y from'os';import l from'path';import {once}from'events';import {createWriteStream,createReadStream}from'fs';import*as Q from'readline';import {Transform,Readable}from'stream';import {pipeline}from'stream/promises';import {lookup}from'dns/promises';import T from'net';import p from'fs-extra';import*as ee from'yauzl';import*as te from'yazl';var qe="workspai-workspace-archive-capabilities-v1",q="workspai-workspace-archive-manifest-v1",k="workspai-workspace-archive-operation-result-v1";var K="contracts/workspace-archive-manifest.v1.json",Z="contracts/workspace-archive-operation-result.v1.json",Ke={archiveCompression:{signature:"--archive-compression <mode>",description:"Archive compression: store (default) or deflate",appliesTo:["export"]},maxDownloadSize:{signature:"--max-download-size <size>",description:"Maximum remote archive download size (secure default: 5gb)",appliesTo:["inspect","verify","doctor","hydrate","import"]},maxExpandedSize:{signature:"--max-expanded-size <size>",description:"Maximum expanded archive payload size (secure default: 20gb)",appliesTo:["inspect","verify","doctor","hydrate","import"]},downloadTimeoutMs:{signature:"--download-timeout-ms <ms>",description:"Remote archive download timeout in milliseconds; 0 disables it",appliesTo:["inspect","verify","doctor","hydrate","import"]},allowPrivateNetwork:{signature:"--allow-private-network",description:"Allow archive downloads from loopback/private networks (unsafe for untrusted input)",appliesTo:["inspect","verify","doctor","hydrate","import"]}};var A=".workspai/archive-manifest.json",R=".rapidkit/archive-manifest.json",de="workspai.workspace.archive",ye=300*1e3,ve=5*1024*1024*1024,we=20*1024*1024*1024,J=2e5,ge=5*1024*1024*1024,ke=1e3,M=5,Ee=64*1024*1024;function Ae(r){let t=r.toLowerCase().split("%")[0];if(T.isIPv4(t)){let e=t.split(".").map(Number);return e[0]===0||e[0]===10||e[0]===127||e[0]===169&&e[1]===254||e[0]===172&&e[1]>=16&&e[1]<=31||e[0]===192&&e[1]===168||e[0]===100&&e[1]>=64&&e[1]<=127||e[0]>=224}return T.isIPv6(t)?t==="::"||t==="::1"||t.startsWith("fc")||t.startsWith("fd")||/^fe[89ab]/.test(t)||t.startsWith("ff")||t.startsWith("::ffff:127.")||t.startsWith("::ffff:10.")||t.startsWith("::ffff:192.168."):true}async function X(r,t){let e=new URL(r);if(e.protocol!=="https:"&&e.protocol!=="http:")throw new Error(`Workspace archive URL protocol is not supported: ${e.protocol}`);if(e.protocol!=="https:"&&!t)throw new Error("Remote workspace archives require HTTPS unless private-network access is explicitly enabled.");if(e.username||e.password)throw new Error("Workspace archive URL must not contain embedded credentials.");if(t)return e;let i=e.hostname.replace(/^\[|\]$/g,"").toLowerCase();if(i==="localhost"||i.endsWith(".localhost"))throw new Error("Workspace archive URL resolves to a private or local network address.");let a=T.isIP(i)?[{address:i}]:await lookup(i,{all:true,verbatim:true});if(a.length===0||a.some(({address:s})=>Ae(s)))throw new Error("Workspace archive URL resolves to a private or local network address.");return e}async function Pe(r,t,e){let i=await X(r,e);for(let a=0;a<=M;a+=1){let s=await fetch(i,{signal:t,redirect:"manual",credentials:"omit"});if(![301,302,303,307,308].includes(s.status))return s;let n=s.headers.get("location");if(await s.body?.cancel(),!n)throw new Error("Workspace archive redirect is missing a Location header.");if(a===M)throw new Error(`Workspace archive download exceeded ${M} redirects.`);i=await X(new URL(n,i).href,e);}throw new Error("Workspace archive redirect policy failed.")}var We=new Set(["__pycache__",".venv","venv","node_modules",".git","dist","build","target",".pytest_cache",".mypy_cache",".ruff_cache","htmlcov",".next",".turbo",".cache"]),be=new Set([".DS_Store","Thumbs.db",".coverage","npm-debug.log","yarn-error.log","pnpm-debug.log","workspace-link.local.json","imported-projects.json","workspace-registry.v1.json"]),Se=[/^\.env$/i,/^\.env\.(?!example$|sample$|template$).+/i,/^.*\.pem$/i,/^.*\.key$/i,/^id_rsa$/i,/^id_ed25519$/i];function _(r){return r.replace(/\\/g,"/")}function re(r){return r.trim().replace(/\.workspai-archive\.zip$/i,"").replace(/\.rapidkit-archive\.zip$/i,"").replace(/\.zip$/i,"").trim().toLowerCase().replace(/[^a-z0-9._-]+/g,"-").replace(/-+/g,"-").replace(/^[-_.]+|[-_.]+$/g,"").slice(0,64)||"imported-workspace"}function ie(r){let t=_(r).trim();if(!t||t.startsWith("/")||t.startsWith("~")||/^[a-zA-Z]:\//.test(t)||t.includes("\0"))return false;let e=t.split("/").filter(Boolean);return e.length>0&&!e.some(i=>i===".."||i===".")}function ae(r){if(!ie(r))throw new Error(`Archive contains an unsafe path: ${r}`)}function Re(r,t){let e=l.relative(t,r);return e===""||!!e&&!e.startsWith("..")&&!l.isAbsolute(e)}function _e(r,t){let e=_(r),i$1=e.split("/").filter(Boolean);if(i$1.some((n,o)=>(n===".workspai"||n===".rapidkit")&&["cache","reports"].includes(i$1[o+1]||""))||i$1.some(n=>We.has(n)||a(n)))return true;let s=i$1[i$1.length-1]||"";return e===i.workspaceContract||e===".rapidkit/workspace.contract.json"||be.has(s)||/\.(?:workspai|rapidkit)-archive\.zip$/i.test(s)||!t?.includeEnv&&Se.some(n=>n.test(s))?true:s.endsWith(".pyc")||s.endsWith(".log")}async function Ce(r){for(let t of [l.join(r,".workspai","workspace.contract.json"),l.join(r,".rapidkit","workspace.contract.json")])if(await p.pathExists(t))try{return await p.readJson(t)}catch(e){throw new Error(`Workspace contract could not be inspected safely for archive portability: ${t}: ${e instanceof Error?e.message:String(e)}`)}return null}function xe(r){return (r?.projects??[]).filter(t=>typeof t.externalPath=="string"||typeof t.relativePath=="string"&&t.relativePath.startsWith("external/")).map(t=>({name:t.slug||t.relativePath||"external-project",relationship:["adopted","linked","imported","managed","restored"].includes(String(t.relationship))?t.relationship:"adopted",included:false,requiredAction:"relink"})).sort((t,e)=>t.name.localeCompare(e.name))}function Oe(r){if(r)return {...r,workspace:{...r.workspace},projects:r.projects.filter(t=>typeof t.externalPath!="string"&&!t.relativePath.startsWith("external/")).map(({externalPath:t,...e})=>({...e,modules:[...e.modules],ports:e.ports.map(i=>({...i})),contracts:{owns:[...e.contracts.owns],apis:e.contracts.apis.map(i=>({...i})),publishes:[...e.contracts.publishes],consumes:[...e.contracts.consumes],dependsOn:[...e.contracts.dependsOn],env:[...e.contracts.env]}}))}}async function*se(r,t,e){let i=(await p.readdir(t,{withFileTypes:true})).sort((a,s)=>a.name.localeCompare(s.name));for(let a of i){let s=l.join(t,a.name),n=_(l.relative(r,s));if(!(!n||_e(n,e))){if(a.isDirectory()){yield*se(r,s,e);continue}a.isFile()&&(yield {relativePath:n,fullPath:s});}}}async function ze(r){for(let t of s(r,"workspace.json"))try{let e=await p.readJson(t);if(typeof e.workspace_name=="string"&&e.workspace_name.trim())return e.workspace_name.trim();if(typeof e.name=="string"&&e.name.trim())return e.name.trim()}catch{}return l.basename(l.resolve(r))}async function Ne(r){let t=await p.stat(r.fullPath),e=z.createHash("sha256"),i=0;for await(let s of createReadStream(r.fullPath)){let n=Buffer.isBuffer(s)?s:Buffer.from(s);i+=n.length,e.update(n);}let a=await p.stat(r.fullPath);if(t.size!==a.size||t.mtimeMs!==a.mtimeMs||i!==a.size)throw new Error(`Workspace file changed while preparing archive: ${r.relativePath}`);return {...r,size:i,mtimeMs:a.mtimeMs,sha256:e.digest("hex")}}async function E(r,t){r.write(t)||await once(r,"drain");}async function ne(r){await new Promise((t,e)=>{r.once("error",e),r.end(t);});}async function*O(r){let t=Q.createInterface({input:createReadStream(r),crlfDelay:1/0});for await(let e of t){let i=e.trim();i&&(yield JSON.parse(i));}}async function Me(r){let t=createWriteStream(r.manifestPath,{flags:"wx"});try{await E(t,`{
|
|
2
2
|
`);for(let[i,a]of Object.entries(r.manifestBase))await E(t,` ${JSON.stringify(i)}: ${JSON.stringify(a,null,2)},
|
|
3
3
|
`);await E(t,` "files": [
|
|
4
4
|
`);let e=true;for await(let i of O(r.spoolPath)){let{mtimeMs:a,...s}=i;await E(t,`${e?"":`,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import {f,l}from'./chunk-
|
|
1
|
+
import {f,l}from'./chunk-5ZA4JYOP.js';import {a,b}from'./chunk-S5KTATOU.js';function u(r){let s=new Map;for(let n of r.projects)s.has(n.name)||s.set(n.name,f(n));return s}function w(r){let s=u(r),n=l(r)??{nodes:r.projects.map(t=>({id:t.name,path:t.path})),edges:[]},a$1=a(n),o=new Map;for(let t of n.nodes){let e=s.get(t.id)??f({missing:t.id}),l=[...b(a$1,[t.id],{direction:"dependencies"}).keys()].filter(c=>c!==t.id).sort((c,f)=>c.localeCompare(f)).map(c=>({id:c,hash:s.get(c)??"<unknown>"}));o.set(t.id,{id:t.id,ownHash:e,transitiveInputsHash:f({own:e,dependencies:l})});}return o}function y(r,s){if(!s||Object.keys(s).length===0)return {verdict:"unknown",baseline:"none",changed:[],added:[],removed:[]};let n=[],a=[];for(let[e,i]of r.entries())e in s?s[e]!==i.transitiveInputsHash&&n.push(e):a.push(e);let o=[];for(let e of Object.keys(s))r.has(e)||o.push(e);return n.sort((e,i)=>e.localeCompare(i)),a.sort((e,i)=>e.localeCompare(i)),o.sort((e,i)=>e.localeCompare(i)),{verdict:n.length>0||a.length>0||o.length>0?"stale":"fresh",baseline:"recorded",changed:n,added:a,removed:o}}function M(r){let s={};for(let[n,a]of [...r.entries()].sort((o,t)=>o[0].localeCompare(t[0])))s[n]=a.transitiveInputsHash;return s}export{u as a,w as b,y as c,M as d};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import {d as d$1,c,e as e$1}from'./chunk-ADL3CK44.js';import {f,e}from'./chunk-5EPPPMAS.js';import k from'fs-extra';var y=f.history,a=e.history,d=50;function A(t){if(!t||typeof t!="object"||Array.isArray(t))return null;let e=t;return typeof e.generatedAt!="string"?null:e.kind==="agent-action"?typeof e.actionId!="string"||typeof e.summary!="string"||e.outcome!=="ok"&&e.outcome!=="failed"?null:{kind:"agent-action",generatedAt:e.generatedAt,actionId:e.actionId,scope:typeof e.scope=="string"?e.scope:"workspace",summary:e.summary,outcome:e.outcome,...typeof e.evidenceSha256=="string"?{evidenceSha256:e.evidenceSha256}:{}}:e.kind==="doctor-fix"?e.scope!=="workspace"&&e.scope!=="project"||typeof e.summary!="string"||e.outcome!=="ok"&&e.outcome!=="failed"?null:{kind:"doctor-fix",generatedAt:e.generatedAt,scope:e.scope,summary:e.summary,outcome:e.outcome,applied:typeof e.applied=="number"?e.applied:0,failed:typeof e.failed=="number"?e.failed:0,skipped:typeof e.skipped=="number"?e.skipped:0,remainingBlockers:typeof e.remainingBlockers=="number"?e.remainingBlockers:0}:typeof e.verdict!="string"||typeof e.risk!="string"||typeof e.gatePassed!="boolean"?null:{kind:"verify",generatedAt:e.generatedAt,verdict:e.verdict,risk:String(e.risk),affectedProjects:typeof e.affectedProjects=="number"?e.affectedProjects:0,freshness:e.freshness??"unknown",gatePassed:e.gatePassed,blockingReasons:typeof e.blockingReasons=="number"?e.blockingReasons:0,policyViolations:typeof e.policyViolations=="number"?e.policyViolations:0}}function S(t,e){return {kind:"verify",generatedAt:t.generatedAt,verdict:t.summary.verdict,risk:t.impact.risk,affectedProjects:t.impact.affectedProjects,freshness:t.freshness.verdict,gatePassed:e,blockingReasons:t.blockingReasons.length,policyViolations:t.policyViolations.length}}function F(t){return {kind:"agent-action",generatedAt:t.generatedAt,actionId:t.actionId,scope:t.scope,summary:t.summary,outcome:t.outcome,...t.evidenceSha256?{evidenceSha256:t.evidenceSha256}:{}}}function V(t,e){let o=t.appliedFixes.filter(i=>i.outcome==="applied").length,r=t.appliedFixes.filter(i=>i.outcome==="failed").length,n=t.appliedFixes.filter(i=>i.outcome==="skipped").length,s=t.appliedFixes.filter(i=>i.outcome==="guidance").length,c=t.remainingBlockers.length,g=r>0||c>0?"failed":"ok";return {kind:"doctor-fix",generatedAt:t.generatedAt,scope:e,summary:`${o} applied, ${r} failed, ${n} skipped, ${s} guidance, ${c} blocker(s) remaining`,outcome:g,applied:o,failed:r,skipped:n,remainingBlockers:c}}async function E(t){let e=await d$1(t,a);try{if(!e||!await k.pathExists(e))return null;let o=await k.readJson(e);return o?.schemaVersion!==y||!Array.isArray(o.entries)?null:{schemaVersion:y,retention:typeof o.retention=="number"?o.retention:d,entries:o.entries.map(r=>A(r)).filter(r=>r!=null)}}catch{return null}}function x(t,e,o=d){let r=Math.max(1,Math.floor(o)),n=[...t?.entries??[],e],s=n.slice(Math.max(0,n.length-r));return {schemaVersion:y,retention:r,entries:s}}async function v(t,e,o){return c(t,a,async()=>{let r=await d$1(t,a),n=await E(t);if(r&&!n)throw new Error(`Workspace history is unreadable or invalid; refusing to overwrite: ${r}`);let s=x(n,e,o?.retention??d);return await e$1(t,a,s),s})}export{y as a,a as b,d as c,A as d,S as e,F as f,V as g,E as h,x as i,v as j};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import e from'path';import N from'fs-extra';import F from'chalk';async function K(n,o={}){let t=e.resolve(n),{WORKSPACE_CONTRACT_PATH:i,syncWorkspaceContract:c,verifyWorkspaceContract:m,writeWorkspaceContractVerifyEvidence:k}=await import('./workspace-contract-
|
|
1
|
+
import e from'path';import N from'fs-extra';import F from'chalk';async function K(n,o={}){let t=e.resolve(n),{WORKSPACE_CONTRACT_PATH:i,syncWorkspaceContract:c,verifyWorkspaceContract:m,writeWorkspaceContractVerifyEvidence:k}=await import('./workspace-contract-IUUPBQXU.js'),p=await c({workspacePath:t,strict:true}),{syncWorkspaceReadme:f,WORKSPACE_README_PATH:d}=await import('./workspace-readme-IVJXSIBS.js'),h=await f({workspacePath:t,workspaceName:p.contract.workspace.name,profile:p.contract.workspace.profile??"minimal",projectCount:p.contract.projects.length}),{buildWorkspaceModel:u,writeWorkspaceModel:g}=await import('./workspace-model-NXFIKX26.js'),a=await u({workspacePath:t,includeEvidence:true}),P=await g(a,t),{buildWorkspaceImpact:W,buildWorkspaceModelSnapshot:C,diffWorkspaceModel:y,writeWorkspaceImpact:A,writeWorkspaceModelDiff:j,writeWorkspaceModelSnapshot:E}=await import('./workspace-intelligence-XHSUFTAT.js'),{WORKSPACE_INTELLIGENCE_ARTIFACTS:s}=await import('./workspace-intelligence-runtime-registry-NCVHKCMP.js'),R=e.join(t,s.snapshot),l=false;if(!await N.pathExists(R)){let r=await C({workspacePath:t,model:a});await E(r,t),l=true;}let S=await y({workspacePath:t,fromPath:s.snapshot,model:a}),b=await j(S,t),v=await W({workspacePath:t,fromPath:s.diff}),O=await A(v,t),T=await m({workspacePath:t,strict:true}),_=await k({workspacePath:t,result:T}),{syncWorkspaceAgentGrounding:M}=await import('./workspace-agent-sync-QGYLY7HH.js'),w=await M({workspacePath:t,model:a,write:true,refreshContext:true,strict:false,preset:"enterprise",targets:["all"],projectGrounding:o.projectGrounding??"managed"}),x=[i,(await import('./workspace-registry-summary-A5VDPRHU.js')).WORKSPACE_REGISTRY_SUMMARY_RELATIVE_PATH,e.relative(t,h).split(e.sep).join("/")||d,e.relative(t,P).split(e.sep).join("/"),s.knowledgeGraph,...l?[s.snapshot]:[],e.relative(t,b).split(e.sep).join("/"),e.relative(t,O).split(e.sep).join("/"),e.relative(t,_).split(e.sep).join("/"),...w.writtenFiles].filter((r,I,G)=>G.indexOf(r)===I);return o.silent||console.log(F.gray(`\u2713 Workspace Intelligence synced \xB7 ${a.summary.projectCount} project(s) \xB7 model + graph + agent grounding`)),{workspacePath:t,projectCount:a.summary.projectCount,baselineCreated:l,writtenFiles:x,warnings:w.projectLenses?.skipped.map(r=>`${r.name}: ${r.reason}`)??[]}}async function D(n,o={}){let t=e.resolve(n),i=o.workspaceName??e.basename(t),{registerWorkspaceStrict:c}=await import('./workspace-3AAOUELG.js');return await c(t,i),K(t,{silent:o.silent})}export{K as a,D as b};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import {c,e}from'./chunk-ADL3CK44.js';import {i,h as h$1}from'./chunk-5EPPPMAS.js';import {s}from'./chunk-MOSXTVPU.js';import u from'fs';import A from'path';var a=h$1.workspaceRunLast.schemaVersion,W="workspace-run-last.json",o=i.workspaceRunLast;var P=new Set(["init","test","build","start"]);function _(e){return P.has(e)}async function d(e){try{return await u.promises.access(e,u.constants.F_OK),true}catch{return false}}async function w(e){try{let r=await u.promises.readFile(e,"utf-8");return JSON.parse(r)}catch{return null}}function m(e){return !e||typeof e!="object"||Array.isArray(e)?null:e}function h(e){let r=e.stage;return typeof r!="string"||r.trim().length===0||!Array.isArray(e.projects)?false:_(r)||/^[a-z][a-z0-9_-]*$/i.test(r)}function T(e){let r=m(e);return !r||r.schemaVersion===a?false:h(r)}function C(e){let r=m(e);return r?r.schemaVersion===a&&r.stages!=null:false}function p(e){if(C(e))return e;if(T(e)){let r=e.stage;return {schemaVersion:a,generatedAt:e.generatedAt,workspacePath:e.workspacePath,latestStage:r,stages:{[r]:e},enterpriseControls:e.enterpriseControls??{jsonReady:true,evidencePath:o}}}return null}function U(e,r){let n=p(e);if(!n)return null;let t=r??n.latestStage;return n.stages[t]??null}async function V(e){let r=(await Promise.all(s(A.resolve(e),"reports",W).map(async t=>await d(t)?t:null))).find(t=>typeof t=="string");if(!r)return null;let n=await w(r);return p(n)}async function j(e$1,r){let n=A.resolve(e$1);return c(n,o,async()=>{let t=(await Promise.all(s(n,"reports",W).map(async s=>await d(s)?s:null))).find(s=>typeof s=="string"),R=t?await w(t):null,i=p(R);if(t&&!i)throw new Error(`Workspace run evidence is unreadable or invalid; refusing to overwrite: ${t}`);let l=i?{...i.stages}:{};l[r.stage]=r;let g={schemaVersion:a,generatedAt:r.generatedAt,workspacePath:r.workspacePath,latestStage:r.stage,stages:l,enterpriseControls:{jsonReady:true,evidencePath:o}};return await e(n,o,g),g})}export{W as a,o as b,U as c,V as d,j as e};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import {f}from'./chunk-VGJVIHHR.js';import s from'path';import p from'fs-extra';var b=4,w="workspace-graph-token-efficiency.v1";function k(e){return Math.ceil(e/b)}function y(e,t){let r=s.resolve(e,t),o=s.relative(e,r);return !o||o.startsWith("..")||s.isAbsolute(o)?null:r}async function C(e){let t=new Map,r=[s.join(e,".workspai","workspace.contract.json"),s.join(e,".rapidkit","workspace.contract.json")];for(let o of r)if(await p.pathExists(o))try{let a=await p.readJson(o);for(let n of a.projects??[])typeof n.relativePath=="string"&&typeof n.externalPath=="string"&&s.isAbsolute(n.externalPath)&&t.set(n.relativePath.replace(/\\/g,"/").replace(/\/$/,""),n.externalPath);break}catch{}return t}function P(e,t,r){if(!t||s.isAbsolute(t))return null;let o=s.resolve(e),a=t.replace(/\\/g,"/");for(let[n,i]of [...r.entries()].sort(([u],[h])=>h.length-u.length))if(a.startsWith(`${n}/`))return y(i,a.slice(n.length+1));return y(o,a)}async function S(e){let t=s.resolve(e.workspacePath),r=f(e.graph,{query:e.query,...e.kind?{kind:e.kind}:{},...e.projectId?{projectId:e.projectId}:{},limit:e.limit,projection:"agent"}),o=[...new Set(e.graph.proofs.map(l=>l.artifact))].sort(),a=[],n=await C(t),i=0,u=0;for(let l of o){let f=P(t,l,n);if(!f){a.push(l);continue}try{let v=await p.readFile(f,"utf8");i+=v.length,u+=1;}catch{a.push(l);}}let h=JSON.stringify(r).length,c=k(i),d=k(h),g=Math.max(0,c-d);return {schemaVersion:w,generatedAt:(e.now??new Date).toISOString(),workspacePath:t,query:e.query,graph:{schemaVersion:e.graph.schemaVersion,sourceArtifact:e.graph.source.artifact,sourceHash:e.graph.source.hash,entityCount:e.graph.entities.length,relationCount:e.graph.relations.length,proofCount:e.graph.proofs.length},methodology:{id:"indexed-corpus-vs-bounded-retrieval.v1",estimated:true,charsPerToken:b,claimBoundary:"Measures retrieval payload reduction against readable proof-source text; it does not claim equivalent answer quality or model-specific billing savings."},corpus:{artifactCount:u,characterCount:i,estimatedTokens:c,unreadableArtifacts:a},retrieval:{matchCount:r.entities.length,characterCount:h,estimatedTokens:d,truncated:r.truncated,payload:r},savings:{estimatedTokensAvoided:g,reductionRatio:d===0?0:Number((c/d).toFixed(2)),reductionPercent:c===0?0:Number((g/c*100).toFixed(2))}}}export{w as a,S as b};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import {a as a$1}from'./chunk-W5ZFXKSL.js';import {a}from'./chunk-NS53IPAC.js';import {e}from'./chunk-ADL3CK44.js';import {h as h$1,b,a as a$2,d,c}from'./chunk-5EPPPMAS.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 S(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=S(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(S);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(S)){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(S))this.#t.set(c,t);return this}resolveWithDiagnostics(i){let t=i.runtimeFamily?this.#i.get(S(i.runtimeFamily)):void 0,s=i.framework?this.#t.get(S(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 A(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:`${A(i.id)}:${I(`${e.projectPath}\0${i.id}`)}`,causalKey:[A(e.projectName),I(e.projectPath),A(t),A(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:[A(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:${A(n)}:${I(e.projectPath)}`,reason:`${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
|
+
\u{1FA7A} Workspai Doctor capabilities
|
|
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
|
+
${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(`
|
|
5
|
+
Validation ${a.passedCases}/${a.totalCases} \xB7 precision ${a.precision} \xB7 recall ${a.recall}`));}s&&console.log(h.gray(`
|
|
6
|
+
Capabilities: ${s}`)),r&&console.log(h.gray(`Validation: ${r}`));}return t&&t.summary.failedCases>0?1:0}export{Z as a,Qe as b};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import {a}from'./chunk-AFIFZTOY.js';import {e,g,f,h,p,j}from'./chunk-5EPPPMAS.js';import h$1 from'path';function u(t){let r=Object.values(p).filter(e=>e.produces.includes(t)).map(e=>[...e.command]),o=j[t]??[];return [...r,...o.map(e=>[...e])]}var P=Object.keys(e).flatMap(t=>{let r=t,o=f[r],e$1=g[r];if(!o||!e$1)return [];let n=e[r];return [{artifactPath:n,schemaVersion:o,contractPath:e$1,producerCommands:u(n)}]}),T=Object.values(h).map(t=>({...t,producerCommands:t.producerCommands.map(r=>[...r])})),d=Object.freeze(Object.fromEntries([...P,...T].map(t=>[t.artifactPath,t])));function l(t){return t.split(h$1.sep).join("/").replace(/^\.\//,"")}var s=h,I=[{pattern:/^\.workspai\/reports\/bootstrap-compliance-[^/]+\.json$/,canonicalPath:s.bootstrapCompliance.artifactPath},{pattern:/^\.workspai\/reports\/mirror-ops-[^/]+\.json$/,canonicalPath:s.mirrorOps.artifactPath},{pattern:/^\.workspai\/reports\/transparency-evidence-[^/]+\.json$/,canonicalPath:s.transparencyEvidence.artifactPath},{pattern:/^\.workspai\/reports\/projects\/[^/]+\/doctor-project-last-run\.json$/,canonicalPath:s.doctorProject.artifactPath},{pattern:/^\.workspai\/reports\/projects\/[^/]+\/project-test-coverage-last-run\.json$/,canonicalPath:s.projectTestCoverage.artifactPath}];function R(t){let r=l(t),o=d[r];if(o)return o;let e=I.find(n=>n.pattern.test(r));return e?d[e.canonicalPath]??null:null}function k(t,r,o=t){let e=l(t),n=R(t);if(!n){if(e.startsWith(".workspai/reports/")&&e.endsWith(".json"))throw new Error(`${o} is a public workspace report without a registered artifact contract`);return}let f=n.schemaVersionField??"schemaVersion",i=r&&typeof r=="object"?r[f]:void 0;if(i!==n.schemaVersion)throw new Error(`${o} schemaVersion is ${String(i)}, expected ${n.schemaVersion}`);a(r,n.contractPath,o);}
|
|
2
|
+
export{R as a,k as b};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import {f}from'./chunk-5EPPPMAS.js';var i=f.explain,u=["project","release-blocked","blocker","trace"];function s(t){let e=t.trim();if(!e)return null;if(e==="release-blocked")return {kind:"release-blocked"};if(e.startsWith("project:")){let r=e.slice(8).trim();return r?{kind:"project",project:r}:null}if(e.startsWith("blocker:")){let r=e.slice(8).trim();return r?{kind:"blocker",blockerId:r}:null}if(e.startsWith("trace:")){let r=e.slice(6).trim();return r?{kind:"trace",diffRef:r}:null}return {kind:"project",project:e}}function E(t){let e=t.trim();if(!e)return null;if(e.startsWith("trace:")){let n=s(e);return n?.kind==="trace"?n:null}let r=e.replace(/\\/g,"/").trim().toLowerCase();return r.endsWith(".json")||r.includes("workspace-model-diff")||r.startsWith(".rapidkit/")||r.includes("/.rapidkit/")?{kind:"trace",diffRef:e}:null}function A(t){if(!t||typeof t!="object"||Array.isArray(t))return false;let e=t;return e.schemaVersion===i&&typeof e.generatedAt=="string"&&typeof e.summary=="string"&&Array.isArray(e.sections)&&e.target!=null&&typeof e.target=="object"&&!Array.isArray(e.target)&&typeof e.target.kind=="string"}export{i as a,u as b,s as c,E as d,A as e};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var o="workspai.doctor-diagnosis.v1";export{o as a};
|