workspai 0.45.0 → 0.47.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +307 -532
- package/contracts/agent-customization-pack.v1.json +6 -1
- package/contracts/bootstrap-compliance.v1.json +14 -0
- package/contracts/cli-runtime-command-inventory.v1.snapshot.json +8 -0
- package/contracts/extension-cli-compatibility.v1.json +9 -2
- package/contracts/mirror-ops.v1.json +16 -0
- package/contracts/published-contract-catalog.v1.json +38 -1
- package/contracts/runtime-command-surface.v1.json +190 -7
- package/contracts/transparency-evidence.v1.json +13 -0
- package/contracts/workspace-archive-capabilities.v1.json +17 -6
- package/contracts/workspace-contract.v1.json +78 -0
- package/contracts/workspace-intelligence/studio-blocker-handoff.v1.json +4 -0
- package/contracts/workspace-intelligence/workspace-context.v1.json +20 -0
- package/contracts/workspace-intelligence/workspace-graph-token-efficiency.v1.json +72 -0
- package/contracts/workspace-intelligence/workspace-intelligence-run.v1.json +212 -0
- package/contracts/workspace-intelligence/workspace-knowledge-graph-change-overlay.v1.json +200 -0
- package/contracts/workspace-intelligence/workspace-knowledge-graph.v1.json +260 -0
- package/contracts/workspace-intelligence/workspace-knowledge-search.v1.json +60 -0
- package/contracts/workspace-intelligence-architecture.v1.json +7 -4
- package/contracts/workspace-intelligence-chain.v1.json +51 -4
- package/contracts/workspace-share-bundle.v1.json +16 -0
- package/dist/analyze-UVXPRGYZ.js +1 -0
- package/dist/artifact-remediation-plan-EPALZ2LC.js +3 -0
- package/dist/autopilot-release-5BQ6F5L2.js +1 -0
- package/dist/chunk-22NJ2ZMG.js +2 -0
- package/dist/{chunk-XIVFLY6G.js → chunk-2GHUZDYA.js} +1 -1
- package/dist/chunk-2TEDAKP6.js +2 -0
- package/dist/chunk-52PBRX7F.js +1 -0
- package/dist/chunk-6SWRNA47.js +4 -0
- package/dist/chunk-76YOPAOT.js +1 -0
- package/dist/chunk-7VLCK5JW.js +1 -0
- package/dist/{chunk-DXPU4DDV.js → chunk-BSRVO52Y.js} +92 -78
- package/dist/chunk-COARSXRC.js +1 -0
- package/dist/chunk-CV5HKU4P.js +1 -0
- package/dist/chunk-CW7PGBIQ.js +13 -0
- package/dist/{chunk-KU4S7RCM.js → chunk-DV6GJD4K.js} +1 -1
- package/dist/chunk-EYJ2CQSK.js +1 -0
- package/dist/chunk-FB7SCXAZ.js +1 -0
- package/dist/chunk-FPJNWPKU.js +1 -0
- package/dist/{chunk-JP25YL3J.js → chunk-FTY7GGXJ.js} +2 -2
- package/dist/chunk-FXQJX34Z.js +1 -0
- package/dist/{chunk-J4AICQFB.js → chunk-HSGFUKCN.js} +1 -1
- package/dist/{chunk-OOOPYUL2.js → chunk-ITCAMC2E.js} +1 -1
- package/dist/chunk-KB44JP4M.js +2 -0
- package/dist/{chunk-WANW4QA4.js → chunk-KZZ36CK5.js} +1 -1
- package/dist/chunk-LNRAB7UY.js +1 -0
- package/dist/chunk-MEMHNE7Y.js +80 -0
- package/dist/chunk-MER6ZBN2.js +13 -0
- package/dist/chunk-NOFM7MNA.js +2 -0
- package/dist/chunk-NRYS4CLR.js +2 -0
- package/dist/chunk-OA537ZQ5.js +1 -0
- package/dist/chunk-PBHP6JNY.js +8 -0
- package/dist/chunk-QDWYIRHR.js +8 -0
- package/dist/chunk-RWRLFSKW.js +2 -0
- package/dist/chunk-SK6XRKGG.js +1 -0
- package/dist/chunk-THIOE2PB.js +2 -0
- package/dist/chunk-TNQI5VCW.js +36 -0
- package/dist/chunk-TWNFECMN.js +2 -0
- package/dist/{chunk-2QOWRBQD.js → chunk-U5EZHZBX.js} +1 -1
- package/dist/{chunk-K63BSU56.js → chunk-VBSQ7MF6.js} +62 -51
- package/dist/chunk-WDKNMTJQ.js +1 -0
- package/dist/chunk-YCL3I2JO.js +2 -0
- package/dist/chunk-ZDN7RHXJ.js +1 -0
- package/dist/chunk-ZM5NQ5Z2.js +1 -0
- package/dist/{create-KFR6FLRT.js → create-7JKJDAQV.js} +1 -1
- package/dist/doctor-PGPNIS76.js +1 -0
- package/dist/{dotnet-webapi-clean-BYUUHX5Y.js → dotnet-webapi-clean-6TVFBTVI.js} +20 -20
- package/dist/{gofiber-standard-B6UK5GR7.js → gofiber-standard-2BL7GWZB.js} +1 -1
- package/dist/{gogin-standard-BXU44VEM.js → gogin-standard-XGP3KBXA.js} +1 -1
- package/dist/index.d.ts +112 -16
- package/dist/index.js +198 -195
- package/dist/pipeline-IB6ILJSV.js +5 -0
- package/dist/{platform-capabilities-YICBF4FA.js → platform-capabilities-2B4QMZXE.js} +1 -1
- package/dist/{pythonRapidkitExec-UJYIB6FL.js → pythonRapidkitExec-CVCIK225.js} +1 -1
- package/dist/{springboot-standard-PEHDKH2L.js → springboot-standard-JJNUID6M.js} +6 -6
- package/dist/workspace-H3QXBFGB.js +1 -0
- package/dist/{workspace-agent-sync-G5YVI3BJ.js → workspace-agent-sync-C7SG2Z5W.js} +1 -1
- package/dist/workspace-archive-P76EDIUG.js +10 -0
- package/dist/{workspace-context-E3UFWL5X.js → workspace-context-BKQBKA4C.js} +1 -1
- package/dist/workspace-contract-RPQQBQXR.js +1 -0
- package/dist/workspace-dependency-graph-23BI2HG7.js +1 -0
- package/dist/workspace-explain-WVN7JH3U.js +1 -0
- package/dist/workspace-explain-contract-SEFTVF6J.js +1 -0
- package/dist/{workspace-feedback-YY6WQPWQ.js → workspace-feedback-WAID3IOE.js} +1 -1
- package/dist/{workspace-foundation-3C2DLCVI.js → workspace-foundation-5OOJEO2D.js} +1 -1
- package/dist/workspace-graph-token-efficiency-CFGFCJ5V.js +1 -0
- package/dist/{workspace-history-VF3CHDYQ.js → workspace-history-C6OP3IAQ.js} +1 -1
- package/dist/workspace-intelligence-VKDL3H2J.js +1 -0
- package/dist/workspace-intelligence-runner-LVALAZY7.js +1 -0
- package/dist/workspace-knowledge-graph-FE2NTZKV.js +1 -0
- package/dist/workspace-knowledge-graph-change-overlay-XG6FC4IX.js +1 -0
- package/dist/workspace-knowledge-graph-query-VOSPPH4W.js +1 -0
- package/dist/workspace-mcp-serve-KT2I676Z.js +3 -0
- package/dist/workspace-model-S33CIB2R.js +1 -0
- package/dist/workspace-model-hash-MHXK5MEI.js +1 -0
- package/dist/workspace-python-engine-state-2MLKJYQG.js +2 -0
- package/dist/workspace-registry-summary-A3YDL63D.js +1 -0
- package/dist/workspace-run-M4LNJILC.js +1 -0
- package/dist/{workspace-verify-ZNT6JX7D.js → workspace-verify-ZGH3NXAH.js} +1 -1
- package/dist/workspace-watch-EVBJTMV7.js +1 -0
- package/docs/AI_DYNAMIC_INTEGRATION.md +73 -432
- package/docs/AI_EXAMPLES.md +37 -395
- package/docs/AI_FEATURES.md +76 -465
- package/docs/AI_QUICKSTART.md +49 -209
- package/docs/DEVELOPMENT.md +5 -5
- package/docs/From Code to Shared Understanding.png +0 -0
- package/docs/GLOSSARY.md +60 -0
- package/docs/OPEN_SOURCE_USER_SCENARIOS.md +91 -9
- package/docs/OPTIMIZATION_GUIDE.md +19 -51
- package/docs/PACKAGE_MANAGER_POLICY.md +4 -1
- package/docs/README.md +91 -42
- package/docs/SECURITY.md +13 -6
- package/docs/SETUP.md +6 -3
- package/docs/UTILITIES.md +8 -20
- package/docs/WORKSPACE_MARKER_SPEC.md +27 -20
- package/docs/ci-workflows.md +19 -5
- package/docs/commands-reference.md +88 -13
- package/docs/config-file-guide.md +67 -246
- package/docs/contracts/ARTIFACT_CATALOG.md +78 -36
- package/docs/contracts/CLI_LOG_EVENT_STREAM.md +1 -1
- package/docs/contracts/README.md +48 -9
- package/docs/contracts/RUNTIME_ACCEPTANCE_MATRIX.md +4 -4
- package/docs/contracts/RUNTIME_SUPPORT_MATRIX.md +14 -10
- package/docs/creating-workspaces-and-projects.md +649 -0
- package/docs/doctor-command.md +5 -4
- package/docs/examples/ci-agent-grounding.yml +16 -10
- package/docs/from-code-to-shared-understanding.md +69 -38
- package/docs/graph-benchmark-methodology.md +121 -0
- package/docs/workspace-intelligence-runner.md +186 -0
- package/docs/workspace-knowledge-graph.md +295 -0
- package/docs/workspace-operations.md +78 -11
- package/docs/workspace-run.md +4 -1
- package/package.json +10 -8
- package/rapidkit.config.example.cjs +5 -5
- package/scripts/enforce-package-manager.cjs +1 -1
- package/scripts/prepack-enterprise.mjs +4 -0
- package/workspai.config.example.cjs +12 -47
- package/dist/analyze-YLV7NVLF.js +0 -1
- package/dist/artifact-remediation-plan-WLZGROUU.js +0 -3
- package/dist/autopilot-release-YBN3SWAA.js +0 -1
- package/dist/chunk-2K3GYCPS.js +0 -1
- package/dist/chunk-42G2OK64.js +0 -1
- package/dist/chunk-5AKYMAIL.js +0 -1
- package/dist/chunk-5GNT4RJI.js +0 -8
- package/dist/chunk-5PVEQ6CZ.js +0 -13
- package/dist/chunk-6AA3WWQZ.js +0 -2
- package/dist/chunk-6ZENXBMG.js +0 -33
- package/dist/chunk-7RIWU5TZ.js +0 -1
- package/dist/chunk-7UZVOYF5.js +0 -2
- package/dist/chunk-BJLE5CH7.js +0 -4
- package/dist/chunk-G3H5R3RR.js +0 -1
- package/dist/chunk-HYJK7W3B.js +0 -1
- package/dist/chunk-IMUU5Q2V.js +0 -13
- package/dist/chunk-KPPGZCUW.js +0 -78
- package/dist/chunk-LCRROMRR.js +0 -2
- package/dist/chunk-LG6RFLPZ.js +0 -1
- package/dist/chunk-P424XYHP.js +0 -1
- package/dist/chunk-P7SCWJFG.js +0 -8
- package/dist/chunk-QWU2CZBG.js +0 -2
- package/dist/chunk-V2H2KRMZ.js +0 -1
- package/dist/chunk-XZGVNGRB.js +0 -1
- package/dist/chunk-ZWO6K24C.js +0 -2
- package/dist/doctor-YJDM5XBH.js +0 -1
- package/dist/imported-projects-registry-FOIE27WT.js +0 -1
- package/dist/pipeline-FEDYO3IA.js +0 -5
- package/dist/workspace-PLXOO6ST.js +0 -1
- package/dist/workspace-archive-EEGLHZDW.js +0 -10
- package/dist/workspace-contract-LQJDZV36.js +0 -1
- package/dist/workspace-explain-G74ZIF23.js +0 -1
- package/dist/workspace-explain-contract-KT757JGQ.js +0 -1
- package/dist/workspace-intelligence-3GG7GEDQ.js +0 -1
- package/dist/workspace-mcp-serve-MJMUV4RY.js +0 -3
- package/dist/workspace-model-NG45SRM5.js +0 -1
- package/dist/workspace-python-engine-state-MTWIIZPY.js +0 -2
- package/dist/workspace-registry-summary-JM2XY52C.js +0 -1
- package/dist/workspace-run-WEQYIERE.js +0 -1
- package/dist/workspace-watch-W47T4RX2.js +0 -1
package/dist/chunk-P7SCWJFG.js
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import {f as f$2,e}from'./chunk-T3GJ7YVG.js';import {a as a$1,b as b$2}from'./chunk-22DT744Z.js';import {h,i}from'./chunk-4KUIFXHM.js';import {g}from'./chunk-6AA3WWQZ.js';import {a as a$2}from'./chunk-GZTYAEWX.js';import {a,b as b$1}from'./chunk-5AKYMAIL.js';import {f as f$1,o as o$1,p as p$1}from'./chunk-5XATWNME.js';import b from'fs';import p from'path';import o from'chalk';var H=new Set([".git",".workspai",".rapidkit",".venv","node_modules","dist","build","target","coverage","htmlcov",".next"]);async function D(e){try{return await b.promises.access(e,b.constants.F_OK),true}catch{return false}}async function P(e){try{let n=JSON.parse(await b.promises.readFile(e,"utf-8"));return n&&typeof n=="object"&&!Array.isArray(n)?n:null}catch{return null}}async function L(e){try{return await b.promises.readFile(e,"utf-8")}catch{return ""}}function K(e){return a$1(e)}async function B(e,n){return await N([...p$1(e,"project.json"),...p$1(e,"context.json")])?true:b$2(e)?false:p.resolve(e)===p.resolve(n)?h(e).length>0:h(e).length>0}async function U(e){let n=await a$2(e,{skipDirs:H,includeHiddenDirs:false,descendIntoMatchedProjects:false,isProjectDir:B});return n.length>0?n:b$2(e)?[]:h(e).length>0?[e]:[]}function V(e,n){return p.relative(e,n).replace(/\\/g,"/")||"."}async function A(e,n){for(let t of n)if(await D(p.join(e,t)))return true;return false}async function N(e){for(let n of e)if(await D(n))return true;return false}async function M(e){for(let n of e){let t=await P(n);if(t)return t}return null}async function q(e){return A(e,["health","health.ts","health.js","health.py","health.go","health.kt","health.rb","health.php","healthcheck","health-check","src/health.ts","src/health.js","src/health.py","src/health.go","src/health.kt","src/health.rb","src/health.php","src/healthcheck.ts","src/healthcheck.js","src/liveness.ts","src/readiness.ts","src/ping.ts"])}async function Q(e){if(await A(e,["tests","test","__tests__","src/__tests__","pytest.ini","vitest.config.ts","jest.config.ts"]))return true;let t=await P(p.join(e,"package.json")),r=t?.scripts&&typeof t.scripts=="object"?t.scripts:{};return typeof r.test=="string"&&r.test.trim().length>0}async function X(e){let n=await P(p.join(e,"package.json")),t=n?.scripts&&typeof n.scripts=="object"?n.scripts:{};return Object.keys(t).sort()}function f(e,n,t,r,s,a){return {id:e,severity:n,target:t,title:r,detail:s,remediation:a}}function Y(e){let n=e.reduce((t,r)=>r.severity==="fail"?t+28:r.severity==="warn"?t+12:t+3,0);return Math.max(0,100-n)}async function Z(e,n){let t=await M(p$1(n,"project.json")),r=i(n,t),s=h(n),a=r.runtime==="unknown"?s[0]||"unknown":r.runtime,i$1=V(e,n),l=i$1,u=await X(n),g=await N([...p$1(n,"project.json"),...p$1(n,"context.json")]),d=await Q(n),h$1=await A(n,["Dockerfile","dockerfile"]),k=await A(n,[".env.example","env.example","config/env.example"]),z=await A(n,[".github/workflows/ci.yml",".github/workflows/ci.yaml",".github/workflows/main.yml",".github/workflows/build.yml",".github/workflows/test.yml",".github/workflows/deploy.yml",".gitlab-ci.yml",".circleci/config.yml","azure-pipelines.yml","bitbucket-pipelines.yml","cloudbuild.yaml"]),C=await q(n),m=[];return r.key==="unknown"&&m.push(f("project.stack.unknown","fail",l,"Project stack is unknown","Workspai cannot confidently classify this backend project.","Add .workspai/project.json metadata or import the project with `workspai import`.")),g||m.push(f("project.marker.missing","warn",l,"Workspai marker is missing","The project can be detected by files, but it is not registered with Workspai metadata.","Run `workspai import <path>` from a workspace or create the project through Workspai.")),d||m.push(f("project.tests.missing","warn",l,"Test entrypoint is missing","No common test folder, config, or package test script was found.","Add a test command so `workspai workspace run test --affected` can gate changes.")),k||m.push(f("project.env.example.missing","info",l,"Environment example is missing","No .env.example or env.example file was found.","Add an env example for onboarding and CI secret documentation.")),z||m.push(f("project.ci.missing","warn",l,"Continuous integration is missing","No recognized CI/CD configuration file was detected for this project.","Add CI configuration so tests and checks run automatically for every change.")),C||m.push(f("project.health.missing","info",l,"Health or readiness probe is missing","The project has no obvious health or readiness endpoint to support automated deployment and runtime checks.","Add a simple health endpoint and document it for readiness gates and observability.")),h$1||m.push(f("project.container.missing","info",l,"Container recipe is missing","No Dockerfile was found for this project.","Add a Dockerfile when the service is intended for containerized deployment.")),{name:p.basename(n),path:n,relativePath:i$1,runtime:a,framework:r.key,confidence:r.confidence,supportTier:r.supportTier,hasRapidKitMarker:g,hasTests:d,hasDockerfile:h$1,hasEnvExample:k,hasCiConfig:z,hasHealthEndpoint:C,scripts:u,findings:m,score:Y(m)}}function ee(e){return e.name.toLowerCase()}async function ne(e){let n=new Map(e.map(s=>[ee(s),s])),t=[];for(let s of e){let a=await P(p.join(s.path,"package.json")),i={...a?.dependencies??{},...a?.devDependencies??{},...a?.peerDependencies??{}};for(let u of Object.keys(i)){let g=u.replace(/^@[^/]+\//,"").toLowerCase(),d=n.get(g);d&&d.relativePath!==s.relativePath&&t.push({from:s.relativePath,to:d.relativePath,kind:"package"});}let l=await L(p.join(s.path,"pyproject.toml"));for(let u of e)u.relativePath!==s.relativePath&&l.includes(u.name)&&t.push({from:s.relativePath,to:u.relativePath,kind:"workspace-reference"});}let r=new Set;return t.filter(s=>{let a=`${s.from}\0${s.to}\0${s.kind}`;return r.has(a)?false:(r.add(a),true)})}function te(e,n){let t=new Map;for(let r of e)t.set(r.relativePath,{project:r.relativePath,directDependents:0,directDependencies:0});for(let r of n){let s=t.get(r.from),a=t.get(r.to);s&&(s.directDependencies+=1),a&&(a.directDependents+=1);}return Array.from(t.values()).sort((r,s)=>s.directDependents-r.directDependents||s.directDependencies-r.directDependencies)}async function re(e){let n=await M(o$1(e,"workspace.json"));return typeof n?.profile=="string"?n.profile:null}function se(e){return {fail:e.filter(n=>n.severity==="fail").length,warn:e.filter(n=>n.severity==="warn").length,info:e.filter(n=>n.severity==="info").length}}function oe(e){if(e.projectCount===0)return e.workspaceDetected?["Add your first project: npx workspai create project <name> --kit <kit>","Import an existing service: npx workspai import <path>"]:["Create a Workspai workspace: npx workspai create workspace my-workspace --profile polyglot","Import an existing service: npx workspai import ../service"];let n=[];return e.findings.some(t=>t.id==="workspace.marker.missing")&&n.push("Initialize workspace metadata with `workspai bootstrap --profile polyglot`."),e.findings.some(t=>t.id==="project.marker.missing")&&n.push("Register detected projects with `workspai import <path>` or recreate them via `workspai create project`."),e.findings.some(t=>t.id==="project.tests.missing")&&n.push("Add test entrypoints, then gate changes with `workspai workspace run test --affected --strict`."),e.findings.some(t=>t.id==="project.ci.missing")&&n.push("Add CI/CD configuration to catch regressions early and make workspace health checks actionable."),e.findings.some(t=>t.id==="project.health.missing")&&n.push("Add a health/readiness endpoint so runtime probes and deployment checks can verify service health."),e.hasGraph||n.push("Create `.workspai/workspace-dependency-graph.json` or use analyze output as the first graph seed."),n.push("Run `workspai autopilot release --mode audit --json` before release."),Array.from(new Set(n))}async function ke(e$1={}){let n=p.resolve(e$1.workspacePath||process.cwd());if(!await D(n))throw new Error(`Workspace path does not exist: ${n}`);let t=K(n)??n,r=f$1(t),s=await re(t),a$1=await U(t),i=await Promise.all(a$1.map(c=>Z(t,c))),l=await ne(i),u=te(i,l),g$1=[];r||g$1.push(f("workspace.marker.missing","warn",".","Workspace metadata is missing","The directory can be analyzed, but it is not a registered Workspai workspace.","Run `workspai create workspace` or `workspai bootstrap --profile polyglot` in a workspace root.")),i.length===0&&g$1.push(f("workspace.projects.missing","warn",".","No backend projects detected","Workspai did not find runtime markers or project metadata under this root.","Create a project with `workspai create project` or import one with `workspai import <path>`."));let d=[...g$1,...i.flatMap(c=>c.findings)],h=se(d),k={};for(let c of i)k[c.runtime]=(k[c.runtime]||0)+1;let z=i.length>0?Math.round(i.reduce((c,y)=>c+y.score,0)/i.length):0,C=g$1.reduce((c,y)=>c+(y.severity==="fail"?20:y.severity==="warn"?8:2),0),m=Math.max(0,z-C),O=i.length===0&&h.fail===0&&d.length>0&&d.every(c=>c.id==="workspace.projects.missing"&&c.severity==="warn"),J=h.fail>0||e$1.strict&&h.warn>0&&!O?"blocked":h.warn>0?"needs-attention":"ready",w={schemaVersion:b$1.analyze,generatedAt:new Date().toISOString(),workspacePath:t,workspaceDetected:r,profile:s,summary:{score:m,verdict:J,projectCount:i.length,runtimeCount:Object.keys(k).length,findings:h},runtimes:k,projects:i,dependencyGraph:{status:l.length>0?"generated":"empty",edges:l,topImpactedProjects:u.slice(0,5)},findings:d,nextActions:oe({findings:d,projectCount:i.length,hasGraph:l.length>0,workspaceDetected:r}),enterpriseControls:{jsonReady:true,ciGateCommand:"workspai analyze --json --strict",releaseGateCommand:"workspai autopilot release --mode enforce --json",evidencePath:a.analyze}};if(e$1.output&&(await b.promises.mkdir(p.dirname(p.resolve(e$1.output)),{recursive:true}),await b.promises.writeFile(p.resolve(e$1.output),`${JSON.stringify(w,null,2)}
|
|
2
|
-
`)),!e$1.output&&r){let c=f$2(w,{commandId:"workspaceAnalyze",exitCode:w.summary.verdict==="blocked"?2:w.summary.verdict==="needs-attention"?1:0,generatedAt:w.generatedAt,blockers:w.findings.filter(y=>y.severity==="fail").map(y=>y.title).slice(0,12),runId:e()});await g(t,a.analyze,c);}return w}function we(e){let n=e.summary.verdict==="ready"?o.green:e.summary.verdict==="needs-attention"?o.yellow:o.red;if(console.log(o.bold(`
|
|
3
|
-
Workspai Workspace Analysis
|
|
4
|
-
`)),console.log(o.cyan("Workspace:"),e.workspacePath),console.log(o.cyan("Profile:"),e.profile||"not configured"),console.log(o.cyan("Score:"),`${e.summary.score}/100`),console.log(o.cyan("Verdict:"),n(e.summary.verdict)),console.log(o.gray(`Projects: ${e.summary.projectCount}, runtimes: ${e.summary.runtimeCount}, findings: ${e.summary.findings.fail} fail / ${e.summary.findings.warn} warn / ${e.summary.findings.info} info`)),e.projects.length>0){console.log(o.bold(`
|
|
5
|
-
Projects`));for(let t of e.projects){let r=t.score>=85?o.green("pass"):t.score>=65?o.yellow("watch"):o.red("risk");console.log(` ${t.relativePath} ${o.gray(`${t.runtime}/${t.framework}`)} ${r} ${t.score}/100`);}}if(e.dependencyGraph.status==="generated"&&(console.log(o.bold(`
|
|
6
|
-
Dependency Graph`)),console.log(o.gray(` edges: ${e.dependencyGraph.edges.length}`)),e.dependencyGraph.topImpactedProjects.length>0)){console.log(o.gray(" Top impacted projects:"));for(let t of e.dependencyGraph.topImpactedProjects.slice(0,3))console.log(` ${t.project} (${t.directDependents} dependents, ${t.directDependencies} dependencies)`);}if(e.findings.length>0){console.log(o.bold(`
|
|
7
|
-
Top Findings`));for(let t of e.findings.slice(0,8)){let r=t.severity==="fail"?o.red:t.severity==="warn"?o.yellow:o.gray;console.log(` ${r(t.severity.toUpperCase())} ${t.target}: ${t.title}`),console.log(o.gray(` ${t.remediation}`));}}console.log(o.bold(`
|
|
8
|
-
Next Actions`));for(let t of e.nextActions.slice(0,5))console.log(o.gray(` - ${t}`));console.log();}export{ke as a,we as b};
|
package/dist/chunk-QWU2CZBG.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import {c,g,f}from'./chunk-6AA3WWQZ.js';import {l as l$1}from'./chunk-OCGZNSOE.js';import {a,b as b$1}from'./chunk-5AKYMAIL.js';import {e}from'./chunk-RO73VVHW.js';import {a as a$1}from'./chunk-XZGVNGRB.js';import {p,o}from'./chunk-5XATWNME.js';import l from'path';import h from'fs-extra';var K="unknown-run";function I(e$1){let r=e();return !r||r===K?e$1:{...e$1,runId:r}}var k=".workspai/workspace.contract.json",z=a.contractVerify,C=1,L=b$1.contractVerify;function T(e){return e.replace(/\\/g,"/")}function E(e){let r=T(e).trim();return !r||r.startsWith("/")||r.startsWith("~")||/^[a-zA-Z]:\//.test(r)||r.includes("\0")?false:!r.split("/").filter(Boolean).some(s=>s===".."||s===".")}function V(e,r){return e.trim().toLowerCase().replace(/[^a-z0-9._-]+/g,"-").replace(/-+/g,"-").replace(/^[-_.]+|[-_.]+$/g,"").slice(0,80)||r}function H(e){return Array.isArray(e)?e.filter(r=>typeof r=="string"&&r.trim().length>0):[]}function B(e){let s=(Array.isArray(e.ports)?e.ports:[]).map(a=>{if(!a||typeof a!="object"||Array.isArray(a))return null;let c=a,p=Number(c.port);if(!Number.isInteger(p)||p<1||p>65535)return null;let t=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:p,protocol:t}}).filter(a=>a!==null);if(s.length>0)return s;let n=e.frontend&&typeof e.frontend=="object"&&!Array.isArray(e.frontend)?e.frontend:void 0,i=Number(e.port??n?.default_port);return Number.isInteger(i)&&i>=1&&i<=65535?[{name:"http",port:i,protocol:"http"}]:[]}async function v(e){for(let r of e)if(await h.pathExists(r))return r;return null}async function U(e){for(let r of o(e,"workspace.json"))try{let s=await h.readJson(r);return {name:typeof s.workspace_name=="string"&&s.workspace_name.trim()||typeof s.name=="string"&&s.name.trim()||l.basename(e),profile:typeof s.profile=="string"?s.profile:void 0}}catch{}return {name:l.basename(e)}}async function Y(e){let r=[],s=[e],n=new Set,i=new Set([".git",".workspai",".rapidkit","node_modules",".venv","venv","dist","build","target",".next",".turbo",".cache"]);for(;s.length>0;){let a=s.shift();if(!a||n.has(a))continue;n.add(a);let c=await v(p(a,"project.json")),p$1=await v(p(a,"context.json"));if(c||p$1){r.push(c??p$1??"");continue}let t;try{t=await h.readdir(a,{withFileTypes:true});}catch{continue}for(let o of t)!o.isDirectory()||i.has(o.name)||s.push(l.join(a,o.name));}return r.sort()}function Z(e){let r=(e||"").toLowerCase();if(r.includes("fastapi"))return "fastapi";if(r.includes("nestjs"))return "nestjs";if(r.includes("springboot"))return "springboot";if(r.includes("gofiber"))return "fiber";if(r.includes("gogin"))return "gin"}function q(e,r){let s=(e||"").toLowerCase(),n=(r||"").toLowerCase();return s.includes("fastapi")?8e3:s.includes("nestjs")?3e3:s.includes("springboot")?8080:s.includes("gofiber")?3e3:s.includes("gogin")?8080:n==="node"?3e3:n==="python"?8e3:n==="java"||n==="go"?8080:null}function Q(e,r){let s=e;for(;r.has(s)&&s<65535;)s+=1;return s}function b(e,r,s){let n=e!==void 0&&e.source===void 0,i=q(r.kit,r.runtime),a=e?.ports||[],c=r.ports||[],p=a.length>0?a:c.length>0?c:i?[{name:"http",port:Q(i,s),protocol:"http"}]:[];for(let u of p)s.add(u.port);let t={...r,...e,slug:e?.slug||r.slug,relativePath:n&&e?.relativePath&&E(e.relativePath)?e.relativePath:r.relativePath,source:n&&e?.source||r.source,relationship:n&&e?.relationship||r.relationship,externalPath:n&&e?.externalPath||r.externalPath,runtime:e?.runtime||r.runtime,framework:e?.framework||r.framework,kit:e?.kit||r.kit,modules:e?.modules?.length?e.modules:r.modules,ports:p,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||[]}},o=JSON.stringify(e||null)!==JSON.stringify(t);return {project:t,changed:o}}async function J(e){let r=l.resolve(e.workspacePath),s=await U(r),n=await Y(r),i=await a$1(r),a=[];for(let o of i){let u=l.resolve(o.path),d=await v(p(u,"project.json"))??await v(p(u,"context.json"));!d||n.some(P=>l.resolve(P)===l.resolve(d))||a.push({projectJsonPath:d,registryEntry:o});}let c=[],p$1=[...n.map(o=>({projectJsonPath:o})),...a];for(let{projectJsonPath:o,registryEntry:u}of p$1){let d=l.dirname(l.dirname(o)),P=T(l.relative(r,d)),j=u!==void 0&&!E(P),f=V(u?.name||l.basename(d),l.basename(d)),m=j?`external/${f}`:P||f,g=await h.readJson(o),R=typeof g.kit_name=="string"&&g.kit_name||typeof g.kit=="string"&&g.kit||void 0,D=typeof g.framework=="string"&&g.framework||Z(R);c.push({slug:u?.name||m||l.basename(d),relativePath:m,source:u?.source??"workspace",relationship:u?.relationship,externalPath:j?d:void 0,runtime:typeof g.runtime=="string"?g.runtime:void 0,framework:D,kit:R,modules:H(g.modules),ports:B(g),contracts:{owns:[],apis:[],publishes:[],consumes:[],dependsOn:[],env:[]}});}let t=new Map;for(let o of c){let u=V(o.slug,o.relativePath),d=t.get(u);(!d||d.source!=="workspace"&&o.source==="workspace")&&t.set(u,o);}return {schemaVersion:C,kind:"rapidkit.workspace.contract",generatedAt:(e.now??new Date).toISOString(),workspace:s,projects:[...t.values()]}}async function lt(e){let r=l.resolve(e.outputPath||c(e.workspacePath,k));if(await h.pathExists(r)&&e.force!==true)throw new Error(`Workspace contract already exists: ${r}. Use --force to overwrite.`);let s=await J({workspacePath:e.workspacePath,now:e.now}),n=new Set,i={...s,projects:s.projects.map(c=>b(void 0,c,n).project)};e.outputPath?(await h.ensureDir(l.dirname(r)),await h.writeJson(r,i,{spaces:2})):await g(e.workspacePath,k,i);let{publishWorkspaceRegistrySummary:a}=await import('./workspace-registry-summary-JM2XY52C.js');return await a(e.workspacePath,{now:e.now}),{contractPath:r,contract:i}}async function dt(e){let r=l.resolve(e.workspacePath),s=c(r,k),n=await f(r,k)??s,i=await J({workspacePath:r,now:e.now}),a=await h.pathExists(n)?await h.readJson(n):null,c$1=new Map((a?.projects||[]).map(f=>[f.slug,f])),p=new Set,t=[],o=[],u=[];for(let f of i.projects){let m=c$1.get(f.slug),g=b(m,f,p);m?g.changed&&o.push(f.slug):t.push(f.slug),u.push(g.project),c$1.delete(f.slug);}for(let f of c$1.values()){if(f.source)continue;let m=b(f,f,p);u.push(m.project);}let d={schemaVersion:C,kind:"rapidkit.workspace.contract",generatedAt:(e.now??new Date).toISOString(),workspace:{...i.workspace,...a?.workspace||{},name:a?.workspace?.name||i.workspace.name},projects:u.sort((f,m)=>f.slug.localeCompare(m.slug))};await g(r,k,d);let P=await X({workspacePath:r}),{publishWorkspaceRegistrySummary:j}=await import('./workspace-registry-summary-JM2XY52C.js');return await j(r,{now:e.now}),{contractPath:s,contract:d,addedProjects:t,updatedProjects:o,verification:P}}async function M(e){let r=e.contractPath??(await f(e.workspacePath,k)||c(e.workspacePath,k)),s=await h.readJson(r);return {contractPath:r,contract:s}}async function ft(e){let{contractPath:r,contract:s}=await M(e),n=s.projects.map(t=>({id:t.slug,label:t.slug,relativePath:t.relativePath,source:t.source,relationship:t.relationship,externalPath:t.externalPath,runtime:t.runtime,framework:t.framework,kit:t.kit,modules:t.modules,ports:t.ports,apis:t.contracts.apis,owns:t.contracts.owns,env:t.contracts.env})),i=new Set(n.map(t=>t.id)),a=new Map,c=[];for(let t of s.projects){for(let o of t.contracts.dependsOn||[])i.has(o)&&c.push({from:o,to:t.slug,type:"dependency",label:"dependsOn"});for(let o of t.contracts.publishes||[])a.has(o)||a.set(o,new Set),a.get(o)?.add(t.slug);}for(let t of s.projects)for(let o of t.contracts.consumes||[]){let u=a.get(o);if(u)for(let d of u)d!==t.slug&&c.push({from:d,to:t.slug,type:"event",label:o});}let p={schemaVersion:1,kind:"rapidkit.workspace.contract.graph",workspace:s.workspace,generatedAt:new Date().toISOString(),nodes:n.sort((t,o)=>t.id.localeCompare(o.id)),edges:c.sort((t,o)=>`${t.from}:${t.to}:${t.type}:${t.label}`.localeCompare(`${o.from}:${o.to}:${o.type}:${o.label}`)),summary:{projectCount:n.length,dependencyEdges:c.filter(t=>t.type==="dependency").length,eventEdges:c.filter(t=>t.type==="event").length,portCount:n.reduce((t,o)=>t+o.ports.length,0),apiCount:n.reduce((t,o)=>t+o.apis.length,0)}};return {contractPath:r,graph:p}}async function X(e){let{contractPath:r,contract:s}=await M(e),n=[],i=[];s.kind!=="rapidkit.workspace.contract"&&n.push("Contract kind must be rapidkit.workspace.contract."),s.schemaVersion!==C&&n.push(`Contract schemaVersion must be ${C}.`),s.workspace?.name||n.push("Contract workspace.name is required."),Array.isArray(s.projects)||n.push("Contract projects must be an array.");let a=new Set,c=new Map;for(let t of s.projects||[]){if(!t.slug){n.push("Every project must declare slug.");continue}a.has(t.slug)&&n.push(`Duplicate project slug: ${t.slug}.`),a.add(t.slug),t.relativePath?E(t.relativePath)||n.push(`Project ${t.slug} declares unsafe relativePath: ${t.relativePath}.`):n.push(`Project ${t.slug} must declare relativePath.`),t.externalPath&&(t.relationship==="adopted"||t.source==="adopted-local"||t.source==="local-folder"||t.source==="git-url"||n.push(`Project ${t.slug} declares externalPath without imported/adopted provenance.`),l.isAbsolute(t.externalPath)||n.push(`Project ${t.slug} declares non-absolute externalPath.`));for(let o of t.ports||[]){(!Number.isInteger(o.port)||o.port<1||o.port>65535)&&n.push(`Project ${t.slug} declares invalid port: ${o.port}.`);let u=c.get(o.port);u&&n.push(`Port ${o.port} is claimed by both ${u} and ${t.slug}.`),c.set(o.port,t.slug);}for(let o of t.contracts?.apis||[])(!o.name?.trim()||!o.basePath?.startsWith("/"))&&n.push(`Project ${t.slug} declares invalid API contract.`);for(let o of [...t.contracts?.publishes||[],...t.contracts?.consumes||[]])o.trim()||n.push(`Project ${t.slug} declares an empty event contract.`);for(let o of t.contracts?.env||[])/^[A-Z_][A-Z0-9_]*$/.test(o)||n.push(`Project ${t.slug} declares invalid env contract: ${o}.`);for(let o of t.contracts?.dependsOn||[])a.has(o);}for(let t of s.projects||[])for(let o of t.contracts?.dependsOn||[])a.has(o)||n.push(`Project ${t.slug} depends on unknown project: ${o}.`);i.push({id:"schema",status:s.kind==="rapidkit.workspace.contract"&&s.schemaVersion===C?"passed":"failed",message:"Contract schema and kind are valid."}),i.push({id:"projects",status:Array.isArray(s.projects)?"passed":"failed",message:`Contract declares ${Array.isArray(s.projects)?s.projects.length:0} project(s).`}),i.push({id:"ports",status:n.some(t=>t.toLowerCase().includes("port"))?"failed":"passed",message:"Project port declarations are valid and collision-free."}),i.push({id:"dependencies",status:n.some(t=>t.includes("depends on unknown project"))?"failed":"passed",message:"Project dependencies point to known project slugs."}),i.push({id:"contracts",status:n.some(t=>t.includes("unsafe relativePath")||t.includes("invalid API contract")||t.includes("event contract")||t.includes("env contract"))?"failed":"passed",message:"Project path, API, event, and env contracts are valid."});let p=await l$1(e.workspacePath);if(p.moduleCount>0){for(let t of p.issues)n.push(`${l.basename(t.projectRoot)}: ${t.message} (slug=${t.slug})`);i.push({id:"module-paths",status:p.status,message:p.status==="passed"?`All ${p.moduleCount} registered module(s) resolve under canonical paths.`:`${p.issues.length} registered module(s) missing canonical install paths.`});}else e.strict&&i.push({id:"module-paths",status:"passed",message:"No registry-backed modules declared in workspace projects."});return {status:n.length>0?"failed":"passed",contractPath:r,projectCount:Array.isArray(s.projects)?s.projects.length:0,checks:i,violations:n}}async function gt(e){let r=l.resolve(e.workspacePath),s={schemaVersion:L,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 g(r,z,I(s))}
|
|
2
|
-
export{I as a,k as b,z as c,C as d,L as e,Y as f,J as g,lt as h,dt as i,M as j,ft as k,X as l,gt as m};
|
package/dist/chunk-V2H2KRMZ.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import {f,e,g}from'./chunk-6AA3WWQZ.js';import {b,a as a$1}from'./chunk-5AKYMAIL.js';import k from'fs-extra';var y=b.history,a=a$1.history,d=50;function A(t){if(!t||typeof t!="object"||Array.isArray(t))return null;let e=t;return typeof e.generatedAt!="string"?null:e.kind==="agent-action"?typeof e.actionId!="string"||typeof e.summary!="string"||e.outcome!=="ok"&&e.outcome!=="failed"?null:{kind:"agent-action",generatedAt:e.generatedAt,actionId:e.actionId,scope:typeof e.scope=="string"?e.scope:"workspace",summary:e.summary,outcome:e.outcome,...typeof e.evidenceSha256=="string"?{evidenceSha256:e.evidenceSha256}:{}}:e.kind==="doctor-fix"?e.scope!=="workspace"&&e.scope!=="project"||typeof e.summary!="string"||e.outcome!=="ok"&&e.outcome!=="failed"?null:{kind:"doctor-fix",generatedAt:e.generatedAt,scope:e.scope,summary:e.summary,outcome:e.outcome,applied:typeof e.applied=="number"?e.applied:0,failed:typeof e.failed=="number"?e.failed:0,skipped:typeof e.skipped=="number"?e.skipped:0,remainingBlockers:typeof e.remainingBlockers=="number"?e.remainingBlockers:0}:typeof e.verdict!="string"||typeof e.risk!="string"||typeof e.gatePassed!="boolean"?null:{kind:"verify",generatedAt:e.generatedAt,verdict:e.verdict,risk:String(e.risk),affectedProjects:typeof e.affectedProjects=="number"?e.affectedProjects:0,freshness:e.freshness??"unknown",gatePassed:e.gatePassed,blockingReasons:typeof e.blockingReasons=="number"?e.blockingReasons:0,policyViolations:typeof e.policyViolations=="number"?e.policyViolations:0}}function S(t,e){return {kind:"verify",generatedAt:t.generatedAt,verdict:t.summary.verdict,risk:t.impact.risk,affectedProjects:t.impact.affectedProjects,freshness:t.freshness.verdict,gatePassed:e,blockingReasons:t.blockingReasons.length,policyViolations:t.policyViolations.length}}function F(t){return {kind:"agent-action",generatedAt:t.generatedAt,actionId:t.actionId,scope:t.scope,summary:t.summary,outcome:t.outcome,...t.evidenceSha256?{evidenceSha256:t.evidenceSha256}:{}}}function V(t,e){let o=t.appliedFixes.filter(i=>i.outcome==="applied").length,r=t.appliedFixes.filter(i=>i.outcome==="failed").length,n=t.appliedFixes.filter(i=>i.outcome==="skipped").length,s=t.appliedFixes.filter(i=>i.outcome==="guidance").length,c=t.remainingBlockers.length,g=r>0||c>0?"failed":"ok";return {kind:"doctor-fix",generatedAt:t.generatedAt,scope:e,summary:`${o} applied, ${r} failed, ${n} skipped, ${s} guidance, ${c} blocker(s) remaining`,outcome:g,applied:o,failed:r,skipped:n,remainingBlockers:c}}async function E(t){let e=await f(t,a);try{if(!e||!await k.pathExists(e))return null;let o=await k.readJson(e);return o?.schemaVersion!==y||!Array.isArray(o.entries)?null:{schemaVersion:y,retention:typeof o.retention=="number"?o.retention:d,entries:o.entries.map(r=>A(r)).filter(r=>r!=null)}}catch{return null}}function x(t,e,o=d){let r=Math.max(1,Math.floor(o)),n=[...t?.entries??[],e],s=n.slice(Math.max(0,n.length-r));return {schemaVersion:y,retention:r,entries:s}}async function v(t,e$1,o){return e(t,a,async()=>{let r=await f(t,a),n=await E(t);if(r&&!n)throw new Error(`Workspace history is unreadable or invalid; refusing to overwrite: ${r}`);let s=x(n,e$1,o?.retention??d);return await g(t,a,s),s})}export{y as a,a as b,d as c,A as d,S as e,F as f,V as g,E as h,x as i,v as j};
|
package/dist/chunk-XZGVNGRB.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import {o,l}from'./chunk-5XATWNME.js';import s from'fs-extra';import*as p from'path';function y(r){return l(r,"imported-projects.json")}async function f(r){let n=(await Promise.all(o(r,"imported-projects.json").map(async e=>await s.pathExists(e)?e:null))).find(e=>typeof e=="string");if(!n)return [];try{let e=await s.readJSON(n);return (Array.isArray(e?.projects)?e.projects:[]).filter(i=>{if(!i||typeof i!="object")return false;let o=i;return typeof o.name=="string"&&typeof o.path=="string"&&typeof o.stack=="string"&&typeof o.confidence=="string"&&typeof o.importedAt=="string"})}catch{return []}}async function k(r,n){if(n.length===0)return;let e=await f(r),a=new Map;for(let t of e)a.set(t.path,t);for(let t of n)a.set(t.path,t);let i=Array.from(a.values()).sort((t,g)=>t.name.localeCompare(g.name)).map(t=>({...t})),o={version:1,updatedAt:new Date().toISOString(),projects:i},c=y(r);await s.ensureDir(p.dirname(c)),await s.writeJSON(c,o,{spaces:2});}async function P(r,n){if(n.length===0)return;let e=await f(r),a=new Set(n.map(t=>p.resolve(t))),i=e.filter(t=>!a.has(p.resolve(t.path))),o={version:1,updatedAt:new Date().toISOString(),projects:i},c=y(r);await s.ensureDir(p.dirname(c)),await s.writeJSON(c,o,{spaces:2});}export{f as a,k as b,P as c};
|
package/dist/chunk-ZWO6K24C.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import {n,k,j}from'./chunk-HYJK7W3B.js';import {a as a$2}from'./chunk-HTYMXMQM.js';import {c}from'./chunk-S5KTATOU.js';import {a as a$1}from'./chunk-QWU2CZBG.js';import {g as g$1}from'./chunk-6AA3WWQZ.js';import {a as a$3}from'./chunk-LG6RFLPZ.js';import {b,a}from'./chunk-5AKYMAIL.js';import ke from'crypto';import k$1 from'path';import L from'fs-extra';import {spawnSync}from'child_process';function fe(){let e={...process.env};return delete e.GIT_DIR,delete e.GIT_WORK_TREE,delete e.GIT_INDEX_FILE,delete e.GIT_PREFIX,e}function F(e,t){let o=spawnSync("git",t,{cwd:e,env:fe(),encoding:"utf8",stdio:["ignore","pipe","ignore"]});return o.status!==0?{ok:false,stdout:""}:{ok:true,stdout:(o.stdout??"").trim()}}function ue(e){let t=e.replace(/\\/g,"/").replace(/^\.\//,"");return [".workspai/reports/",".workspai/cache/",".rapidkit/reports/",".rapidkit/cache/"].some(o=>t.startsWith(o))}function ge(e){let t=[],o=[],r=[];for(let l of e.split(`
|
|
2
|
-
`)){if(!l.trim())continue;let a=l.slice(0,2),i=l.slice(3).trim();if(i&&!ue(i)){if(a==="??"){o.push(i);continue}a.includes("D")&&r.push(i),t.push(i);}}return {changedFiles:[...new Set(t)].sort(),untrackedFiles:[...new Set(o)].sort(),deletedFiles:[...new Set(r)].sort()}}function Y(e,t){let o={available:false,dirty:false,changedFiles:[],untrackedFiles:[],deletedFiles:[]},r=F(e,["rev-parse","--is-inside-work-tree"]);if(!r.ok||r.stdout!=="true")return o;let l=F(e,["rev-parse","--abbrev-ref","HEAD"]),a=F(e,["rev-parse","HEAD"]),i=F(e,["status","--porcelain=v1","--untracked-files=all"]),c=ge(i.stdout),m=c.changedFiles.length>0||c.untrackedFiles.length>0||c.deletedFiles.length>0;return {available:true,branch:l.ok?l.stdout:void 0,commit:a.ok?a.stdout:void 0,ref:t?.ref,dirty:m,changedFiles:c.changedFiles,untrackedFiles:c.untrackedFiles,deletedFiles:c.deletedFiles}}var re=b.snapshot,K=b.diff,T=a.snapshot,oe=a.diff,he=b.impact,we=a.impact;function ne(e){let t=e.trim().toLowerCase();return t==="git"||t.startsWith("git:")}function ye(e){let t=e.trim();return t.toLowerCase()==="git"?"HEAD":t.toLowerCase().startsWith("git:")&&t.slice(4).trim()||"HEAD"}function V(e){if(Array.isArray(e))return e.map(t=>V(t));if(e&&typeof e=="object"){let t={};for(let o of Object.keys(e).sort())t[o]=V(e[o]);return t}return e}function g(e){return JSON.stringify(V(e))}function I(e){let{runId:t,evidence:o,facts:r,factFreshness:l,projects:a,...i}=e,c=a.map(p=>{let{evidence:f,...h}=p;return h}),m={...i,generatedAt:"<ignored>",projects:c,graph:e.graph?{...e.graph,generatedAt:"<ignored>"}:void 0,validation:e.validation?{...e.validation,issues:e.validation.issues.map(p=>({...p})).sort((p,f)=>{let h=`${p.severity}:${p.code}:${p.target}:${p.message}`,b=`${f.severity}:${f.code}:${f.target}:${f.message}`;return h.localeCompare(b)})}:void 0};return ke.createHash("sha256").update(g(m)).digest("hex")}function Xe(e){return I(e)}function ae(e,t){return k$1.isAbsolute(t)?t:k$1.join(e,t)}async function We(e){let t=await L.readJson(e);if(!t||typeof t!="object"||Array.isArray(t))throw new Error(`Workspace model input is not a JSON object: ${e}`);let o=t;if(o.schemaVersion===re){a$3(t,"contracts/workspace-intelligence/workspace-model-snapshot.v1.json",`Workspace model snapshot ${e}`);let r=o;if(!r.model||r.model.schemaVersion!==j)throw new Error(`Invalid workspace model snapshot: ${e}`);let l=I(r.model);if(r.modelHash!==l)throw new Error(`Workspace model snapshot hash mismatch: ${e}`);return {model:r.model,hash:r.modelHash}}if(o.schemaVersion===j){a$3(t,"contracts/workspace-intelligence/workspace-model.v1.json",`Workspace model ${e}`);let r=o;return {model:r,hash:I(r)}}throw o.schemaVersion===K?new Error(`workspace diff --from received a diff report (${k$1.basename(e)}). Use a workspace model snapshot or model report as baseline, e.g. ${T}. To analyze an existing diff report, run: npx workspai workspace impact --from ${k$1.basename(e)} --json`):new Error(`Unsupported workspace model input schema: ${String(o.schemaVersion)}`)}async function ve(e){let t=await L.readJson(e);if(!t||typeof t!="object"||Array.isArray(t))throw new Error(`Workspace diff input is not a JSON object: ${e}`);let o=t;if(o.schemaVersion!==K)return null;a$3(t,"contracts/workspace-intelligence/workspace-model-diff.v1.json",`Workspace model diff ${e}`);let r=o;if(!r.currentModel||r.currentModel.schemaVersion!==j||!r.summary||!Array.isArray(r.changes))throw new Error(`Invalid workspace model diff report: ${e}`);if(r.toHash!==I(r.currentModel))throw new Error(`Workspace model diff current-model hash mismatch: ${e}`);return r}async function Ye(e){let t=e.model??await n({workspacePath:e.workspacePath,includeAbsolutePaths:e.includeAbsolutePaths,includeEvidence:e.includeEvidence,observableScanDepth:e.observableScanDepth,now:e.now});return {schemaVersion:re,generatedAt:(e.now??new Date).toISOString(),modelHash:I(t),modelRef:k,model:t}}async function Qe(e,t){return g$1(t,T,a$1(e))}function x(e){return {name:e.name,path:e.path,kind:e.kind,runtime:e.runtime,framework:e.framework,generator:e.generator,supportTier:e.supportTier,commands:e.commands,importantFiles:e.importantFiles}}function w(e,t){e.push(t);}function be(e,t){let o=[],r=["name","profile","type"],l=["workspaceType","surfaces","runtimeFamilies","businessCapabilities"];for(let a of r){let i=e.workspace[a],c=t.workspace[a];g(i)!==g(c)&&w(o,{type:"workspace.changed",severity:"info",target:`workspace.${a}`,message:`Workspace metadata field changed: ${String(a)}`,before:i,after:c});}for(let a of l){let i=e.identity[a],c=t.identity[a];g(i)!==g(c)&&w(o,{type:"workspace.changed",severity:"info",target:`identity.${a}`,message:`Workspace identity field changed: ${String(a)}`,before:i,after:c});}return g(e.policies)!==g(t.policies)&&w(o,{type:"workspace.changed",severity:"warning",target:"policies",message:"Workspace policy summary changed.",before:e.policies,after:t.policies}),g(e.evidence)!==g(t.evidence)&&w(o,{type:"workspace.changed",severity:"info",target:"evidence",message:"Workspace evidence summary changed.",before:e.evidence,after:t.evidence}),g(e.discovery)!==g(t.discovery)&&w(o,{type:"workspace.changed",severity:"info",target:"discovery",message:"Workspace discovery settings changed.",before:e.discovery,after:t.discovery}),e.contracts.exists!==t.contracts.exists&&w(o,{type:"workspace.changed",severity:t.contracts.exists?"info":"warning",target:t.contracts.workspaceContractPath,message:"Workspace contract presence changed.",before:e.contracts.exists,after:t.contracts.exists}),o}function je(e,t){let o=e.validation??null,r=t.validation??null;return g(o)===g(r)?[]:[{type:"validation.changed",severity:r?.status==="failed"?"critical":"warning",target:"validation",message:"Workspace model validation changed.",before:o,after:r}]}function Me(e,t){let o=[],r=new Map(e.projects.map(a=>[a.path,a])),l=new Map(t.projects.map(a=>[a.path,a]));for(let[a,i]of l.entries()){let c=r.get(a);if(!c){w(o,{type:"project.added",severity:"info",target:a,message:`Project added: ${i.name}`,after:x(i)});continue}let m=x(c),p=x(i);if(g(m)!==g(p)){let f=c.runtime!==i.runtime||c.framework!==i.framework;w(o,{type:"project.changed",severity:f?"warning":"info",target:a,message:`Project changed: ${i.name}`,before:m,after:p});}}for(let[a,i]of r.entries())l.has(a)||w(o,{type:"project.removed",severity:"warning",target:a,message:`Project removed: ${i.name}`,before:x(i)});return o.sort((a,i)=>`${a.type}:${a.target}`.localeCompare(`${i.type}:${i.target}`))}async function Ie(e){let t=k$1.resolve(e.workspacePath),o=ne(e.fromPath),r=o?ye(e.fromPath):void 0,l=e.fromPath;if(o){let u=k$1.join(t,T);if(!await L.pathExists(u))throw new Error("Git-aware workspace diff requires an existing snapshot at .workspai/reports/workspace-model-snapshot.json. Run: npx workspai workspace snapshot --json");l=T;}let a=ae(t,l),i=await We(a),c=e.model??await n({workspacePath:t,includeAbsolutePaths:e.includeAbsolutePaths,includeEvidence:e.includeEvidence,observableScanDepth:e.observableScanDepth,now:e.now}),m=I(c),p=[...be(i.model,c),...Me(i.model,c),...je(i.model,c)],f;e.includeGitObservation!==false&&(f=e.gitObservation??Y(t,{ref:r}),f.available&&Ee(p,f,c));let h=p.filter(u=>u.type.startsWith("git.")).length,b=i.hash!==m,W=o?`git:${r??"HEAD"}`:k$1.relative(t,a).split(k$1.sep).join("/");return {schemaVersion:K,generatedAt:(e.now??new Date).toISOString(),fromRef:W,toRef:k,fromHash:i.hash,toHash:m,summary:{changed:b||h>0,addedProjects:p.filter(u=>u.type==="project.added").length,removedProjects:p.filter(u=>u.type==="project.removed").length,changedProjects:p.filter(u=>u.type==="project.changed").length,workspaceChanges:p.filter(u=>u.type==="workspace.changed").length,validationChanges:p.filter(u=>u.type==="validation.changed").length,gitChangedFiles:h},git:f?.available?Se(f,r):{available:false,dirty:false,changedFiles:0,untrackedFiles:0,deletedFiles:0},changes:p,currentModel:c}}async function Ze(e,t){return g$1(t,oe,a$1(e))}function P(e){return {none:0,low:1,medium:2,high:3,critical:4}[e]}function Q(e){return e.reduce((t,o)=>P(o)>P(t)?o:t,"none")}var N=["none","low","medium","high","critical"];function Pe(e){let t=Math.max(1,P(e)-1);return N[t]}function Re(e){let t=Math.min(N.length-1,P(e)+1);return N[t]}function Z(e){return e.join(" ")}function y(e,t,o,r){return {id:e,label:t,scope:r.scope,project:r.project,display:Z(["npx","workspai",...o]),execute:Z(["npx","--yes","--package","workspai","workspai",...o]),required:r.required!==false}}function ee(e){let t=`project:${e.name}`,o=e.commands.fleetStages;return [y(`project.${e.name}.init`,`Run init for ${e.name}`,["workspace","run","init","--scope",t,"--json"],{scope:"project",project:e.name,required:o.includes("init")}),y(`project.${e.name}.test`,`Run tests for ${e.name}`,["workspace","run","test","--scope",t,"--json"],{scope:"project",project:e.name,required:o.includes("test")}),y(`project.${e.name}.build`,`Run build for ${e.name}`,["workspace","run","build","--scope",t,"--json"],{scope:"project",project:e.name,required:o.includes("build")}),y(`project.${e.name}.start`,`Run start for ${e.name}`,["workspace","run","start","--scope",t,"--json"],{scope:"project",project:e.name,required:o.includes("start")})]}function _(){return [y("workspace.doctor","Run workspace doctor",["doctor","workspace","--json"],{scope:"workspace"}),y("workspace.contract.verify","Verify workspace contract",["workspace","contract","verify","--json"],{scope:"workspace"}),y("workspace.readiness","Run release readiness",["readiness","--json"],{scope:"workspace"}),y("workspace.analyze","Run workspace analyze",["analyze","--json"],{scope:"workspace",required:false}),y("workspace.pipeline","Run governance pipeline",["pipeline","--json"],{scope:"workspace",required:false}),y("workspace.doctor-fix","Verify doctor fix result",["doctor","workspace","--fix","--json"],{scope:"workspace",required:false})]}function Ce(e,t){let o=t.split(k$1.sep).join("/");return e.projects.filter(l=>{let a=l.path.split(k$1.sep).join("/");return o===a||o.startsWith(`${a}/`)}).sort((l,a)=>a.path.length-l.path.length)[0]}function Ee(e,t,o){let r=new Set(e.map(a=>a.target)),l=(a,i)=>{let c=i.split(k$1.sep).join("/"),m=`git:${c}`;if(r.has(m))return;let p=Ce(o,c),f=p?`${p.name} (${p.path})`:"workspace";w(e,{type:a,severity:a==="git.deleted"?"warning":"info",target:m,message:`Git ${a==="git.untracked"?"untracked":a==="git.deleted"?"deleted":"changed"} file affects ${f}: ${c}`,after:{path:c,project:p?.name,projectPath:p?.path}}),r.add(m);};for(let a of t.changedFiles)l("git.file.changed",a);for(let a of t.untrackedFiles)l("git.untracked",a);for(let a of t.deletedFiles)l("git.deleted",a);}function Se(e,t){return {available:true,ref:t??e.ref,branch:e.branch,commit:e.commit,dirty:e.dirty,changedFiles:e.changedFiles.length,untrackedFiles:e.untrackedFiles.length,deletedFiles:e.deletedFiles.length}}function Oe(e){let t=new Set,o=[];for(let r of e){let l=`${r.scope}:${r.project??""}:${r.display}`;t.has(l)||(t.add(l),o.push(r));}return o}function Ae(e){return e.type==="project.removed"?"high":e.severity==="critical"?"critical":e.severity==="warning"?"high":("medium")}function $e(e,t){return e.severity==="critical"?"critical":e.target==="policies"||e.target.includes("contract")?"high":e.type==="validation.changed"?(t?.projectCount??0)===0?"low":"high":e.target==="evidence"?"low":e.severity==="warning"?"medium":"low"}function De(e){return e.affectedProjects>0||e.projectCount>0||!e.changes.every(o=>o.severity==="critical"?false:o.type.startsWith("git.")||o.type==="validation.changed")?e.risk:P(e.risk)>=P("high")||e.risk==="medium"?"low":e.risk}function te(e,t){if(!e||e==="workspace")return true;let o=(e.startsWith("project:")?e.slice(8):e).trim().toLowerCase();return [t.name,t.path,k$1.basename(t.path),t.absolutePath].filter(r=>typeof r=="string"&&r.trim().length>0).map(r=>r.trim().toLowerCase()).includes(o)}function Fe(e){if(!e.changed)return {headline:"No workspace model impact detected.",bullets:["The current workspace model matches the provided snapshot/report."],unsafeAssumptions:["Do not claim runtime verification passed unless a report exists."]};let t=e.affectedProjects.map(o=>o.project?.name??o.target);return {headline:`Workspace impact risk: ${e.risk}.`,bullets:[`Affected projects: ${t.length?t.join(", "):"none"}.`,`Workspace-level items: ${e.workspaceImpact.length}.`,"Use the verification plan before recommending apply, rollback, or release actions."],unsafeAssumptions:["Do not infer test/build success from impact alone.","Do not apply fixes without project scope and verification evidence.","Use display commands for users and execute commands for automation."]}}async function et(e){let t=k$1.resolve(e.workspacePath),o=ne(e.fromPath),r=e.diff;if(!r&&!o){let n=ae(t,e.fromPath);r=await ve(n)??void 0;}r||(r=await Ie({workspacePath:t,fromPath:e.fromPath,includeAbsolutePaths:e.includeAbsolutePaths,includeEvidence:e.includeEvidence,includeGitObservation:e.includeGitObservation,gitObservation:e.gitObservation,now:e.now,model:e.model}));let l=new Map(r.currentModel.projects.map(n=>[n.path,n])),a=new Map(r.currentModel.projects.map(n=>[n.name,n])),i=r.changes.filter(n=>n.type.startsWith("project.")),c$1=new Map;for(let n of i){let d=(l.get(n.target)??(typeof n.before?.name=="string"?a.get(n.before.name):void 0))?.path??n.target,v=c$1.get(d)??[];v.push(n),c$1.set(d,v);}let m=[];for(let[n,s]of c$1.entries()){let d=l.get(n);if(d&&!te(e.scope,d))continue;let v=Q(s.map(Ae)),C=d?.name??(typeof s[0]?.before?.name=="string"?String(s[0].before.name):n);m.push({id:`project:${C}`,scope:"project",target:n,title:`Project impact: ${C}`,summary:s.map(j=>j.message).join(" "),risk:v,reasons:s.map(j=>`${j.type}: ${j.message}`),project:d?{name:d.name,path:d.path,kind:d.kind,runtime:d.runtime,framework:d.framework,supportTier:d.supportTier,...d.generator?{generator:d.generator}:{}}:void 0,verification:d?ee(d):_()});}let p=r.currentModel.graph,f=p?a$2(p):void 0,h=new Set(m.map(n=>n.project?.name).filter(n=>typeof n=="string")),b=new Map;for(let n of m)if(n.project?.name){let s=f?.byId.get(n.project.name);s&&(n.centrality={fanIn:s.fanIn,fanOut:s.fanOut,reach:s.reach,betweenness:s.betweenness,isHotspot:s.isHotspot},s.isHotspot&&(n.risk=Re(n.risk),n.reasons=[...n.reasons,`graph.hotspot: critical-path project with ${s.reach} transitive dependent(s); risk escalated.`])),n.origin="direct",n.distance=0,b.set(n.project.name,n.risk);}let W=[],u=0;if(p&&h.size>0){let n=c(p,h);for(let s of n.values()){if(s.distance===0||h.has(s.id))continue;let d=a.get(s.id);if(d&&!te(e.scope,d))continue;let v=s.path[0],C=s.path[s.path.length-2]??v,j=b.get(v)??"medium",pe=Pe(j),M=f?.byId.get(s.id);u=Math.max(u,s.distance),W.push({id:`transitive:${s.id}`,scope:"project",target:d?.path??s.id,title:`Transitive impact: ${s.id}`,summary:`Depends on changed project ${v}${s.via?` via ${s.via}`:""} (distance ${s.distance}).`,risk:pe,reasons:[`graph.dependent: depends on ${C}${s.via?` via ${s.via}`:""} (path ${s.path.join(" -> ")})`],project:d?{name:d.name,path:d.path,kind:d.kind,runtime:d.runtime,framework:d.framework,supportTier:d.supportTier,...d.generator?{generator:d.generator}:{}}:void 0,verification:d?ee(d):_(),origin:"transitive",distance:s.distance,path:s.path,via:s.via,...M?{centrality:{fanIn:M.fanIn,fanOut:M.fanOut,reach:M.reach,betweenness:M.betweenness,isHotspot:M.isHotspot}}:{}});}}W.sort((n,s)=>n.target.localeCompare(s.target));let se=f?f.hotspots.flatMap(n=>{let s=f.byId.get(n);return s?[{project:n,fanIn:s.fanIn,fanOut:s.fanOut,reach:s.reach,betweenness:s.betweenness}]:[]}):[],ie=r.changes.filter(n=>!n.type.startsWith("project.")),B=r.currentModel.summary?.projectCount??r.currentModel.projects.length,R=ie.map(n=>({id:`workspace:${n.target}`,scope:"workspace",target:n.target,title:`Workspace impact: ${n.target}`,summary:n.message,risk:$e(n,{projectCount:B}),reasons:[`${n.type}: ${n.message}`],verification:_()})),q=Oe([...m.flatMap(n=>n.verification),...W.flatMap(n=>n.verification),...R.flatMap(n=>n.verification),...r.summary.changed?_():[]]).filter(n=>n.required),ce=Q([...m.map(n=>n.risk),...W.map(n=>n.risk),...R.map(n=>n.risk)]),z=De({risk:ce,affectedProjects:m.length,projectCount:B,changes:r.changes}),J={changed:r.summary.changed,risk:z,affectedProjects:m.length,workspaceItems:R.length,recommendedCommands:q.length,blastRadius:{directlyAffected:m.length,transitivelyAffected:W.length,maxDistance:u,graphEdges:p?.edges.length??0}};return {schemaVersion:he,generatedAt:(e.now??new Date).toISOString(),fromRef:r.fromRef,diffRef:oe,workspace:{name:r.currentModel.workspace.name,profile:r.currentModel.workspace.profile,type:r.currentModel.workspace.type},summary:J,affectedProjects:m.sort((n,s)=>n.target.localeCompare(s.target)),transitiveImpact:W,criticalPathHotspots:se,workspaceImpact:R.sort((n,s)=>n.target.localeCompare(s.target)),verificationPlan:q,agentBrief:Fe({changed:J.changed,risk:z,affectedProjects:m,workspaceImpact:R}),diff:r}}async function tt(e,t){return g$1(t,we,a$1(e))}export{Y as a,re as b,K as c,T as d,oe as e,he as f,we as g,ne as h,ye as i,Xe as j,Ye as k,Qe as l,Ie as m,Ze as n,_ as o,et as p,tt as q};
|
package/dist/doctor-YJDM5XBH.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export{a as DOCTOR_WORKSPACE_REPORT_PATH,d as computeDoctorFixAwareExitCode,c as computeDoctorGateExitCode,b as resolveDoctorPolicyProfile,e as runDoctor}from'./chunk-KPPGZCUW.js';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export{a as readImportedProjectsRegistry,c as removeImportedProjectsRegistryEntries,b as upsertImportedProjectsRegistry}from'./chunk-XZGVNGRB.js';
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import {a as a$2}from'./chunk-P7SCWJFG.js';import {c as c$1}from'./chunk-5GNT4RJI.js';import {e}from'./chunk-KPPGZCUW.js';import {b}from'./chunk-K63BSU56.js';import {d,c as c$2}from'./chunk-BJLE5CH7.js';import {f as f$1,e as e$1}from'./chunk-T3GJ7YVG.js';import {a}from'./chunk-22DT744Z.js';import {f,c,g}from'./chunk-6AA3WWQZ.js';import {a as a$1}from'./chunk-5AKYMAIL.js';import c$3 from'chalk';import p from'path';function G(a){return a===0?"pass":a===2?"warn":"fail"}function I(a){return a.some(r=>r.status==="fail")?"blocked":a.some(r=>r.status==="warn")?"needs-attention":"ready"}function j(a,r){if(r)return 3;let i=a.some(o=>o.status==="fail"),t=a.some(o=>o.status==="warn");return i?1:t?2:0}function N(a,r){return a===2&&!r?0:a}async function O(a){let r=await b(a,true),i=false;try{let{syncWorkspaceContract:t}=await import('./workspace-contract-LQJDZV36.js');await t({workspacePath:a}),i=true;}catch{i=false;}return {sync:r,contractSynced:i}}async function V(a$3={}){let r=p.resolve(a$3.workspacePath??process.cwd()),i=a(r);if(!i)throw new Error("No Workspai workspace found in current directory or parents");let t=[],o=[],l=false,d$1,f$2,m,y=Date.now();try{let{sync:e,contractSynced:s}=await O(i),n=e.workspaceFound&&(e.added.length>0||e.skipped>=0)||e.workspaceFound?"pass":"warn";t.push({name:"sync",status:n,durationMs:Date.now()-y,summary:e.workspaceFound?`registry sync complete (${e.added.length} added, ${e.skipped} existing)${s?", contract synced":""}`:"workspace not registered in global registry; contract sync attempted"}),e.workspaceFound||o.push("workspace registry entry missing \u2014 run workspai create workspace or register manually");}catch(e){l=true,t.push({name:"sync",status:"fail",durationMs:Date.now()-y,summary:`sync failed: ${e instanceof Error?e.message:String(e)}`}),o.push("workspace sync stage failed");}let w=Date.now();try{let e$1=await e({workspace:true,json:true,quiet:true,strict:a$3.strict===true,ci:a$3.strict!==true}),s=G(e$1),n=await f(i,a$1.doctor)??c(i,a$1.doctor);t.push({name:"doctor",status:s,durationMs:Date.now()-w,summary:s==="pass"?"doctor workspace passed":s==="warn"?"doctor workspace reported warnings":"doctor workspace did not pass",exitCode:e$1,evidencePath:n}),s==="fail"?o.push("doctor workspace gate failed"):s==="warn"&&o.push("doctor workspace reported warnings");}catch(e){l=true,t.push({name:"doctor",status:"fail",durationMs:Date.now()-w,summary:`doctor failed: ${e instanceof Error?e.message:String(e)}`}),o.push("doctor workspace stage failed");}if(a$3.skipAnalyze)t.push({name:"analyze",status:"skipped",durationMs:0,summary:"analyze stage skipped"});else {let e=Date.now();try{let s=await a$2({workspacePath:i,json:true,strict:a$3.strict===true});d$1=p.isAbsolute(s.enterpriseControls.evidencePath)?s.enterpriseControls.evidencePath:p.join(i,s.enterpriseControls.evidencePath);let n=s.summary.verdict==="blocked"?"fail":s.summary.verdict==="needs-attention"?"warn":"pass";t.push({name:"analyze",status:n,durationMs:Date.now()-e,summary:`analyze verdict: ${s.summary.verdict} (score ${s.summary.score}/100)`,evidencePath:d$1}),n==="fail"?o.push("analyze reported blocked verdict"):n==="warn"&&o.push("analyze reported needs-attention verdict");}catch(s){l=true,t.push({name:"analyze",status:"fail",durationMs:Date.now()-e,summary:`analyze failed: ${s instanceof Error?s.message:String(s)}`}),o.push("analyze stage failed");}}let h=Date.now();try{let e=await d({startPath:i,writeReport:true,skipVerify:a$3.skipVerify===true});f$2=e.evidencePath;let s=e.overallStatus==="pass"?"pass":e.overallStatus==="warn"?"warn":"fail";t.push({name:"readiness",status:s,durationMs:Date.now()-h,summary:`readiness overall: ${e.overallStatus}`,evidencePath:e.evidencePath}),s==="fail"?o.push(...e.blockingReasons.map(n=>`readiness: ${n}`)):s==="warn"&&o.push(...e.gates.filter(n=>n.status==="warn").map(n=>`readiness warn: ${n.gate}: ${n.summary}`));}catch(e){l=true,t.push({name:"readiness",status:"fail",durationMs:Date.now()-h,summary:`readiness failed: ${e instanceof Error?e.message:String(e)}`}),o.push("readiness stage failed");}if(a$3.skipAutopilot)t.push({name:"autopilot",status:"skipped",durationMs:0,summary:"autopilot stage skipped"});else {let e=Date.now(),s=a$3.autopilotMode??"audit";try{let n=await c$1({workspacePath:i,mode:s,json:true,skipPipelineStages:true});m=n.artifacts.reportPath;let P=n.summary.verdict==="approved"?"pass":n.summary.verdict==="partial"?"warn":"fail";t.push({name:"autopilot",status:P,durationMs:Date.now()-e,summary:`autopilot ${s}: ${n.summary.verdict}`,exitCode:n.summary.exitCode,evidencePath:m}),P!=="pass"&&o.push(...n.blockingReasons.slice(0,5));}catch(n){l=true,t.push({name:"autopilot",status:"fail",durationMs:Date.now()-e,summary:`autopilot failed: ${n instanceof Error?n.message:String(n)}`}),o.push("autopilot release stage failed");}}let M=I(t),k=j(t,l),F=p.join(i,".workspai","reports","pipeline-last-run.json"),u={schemaVersion:"rapidkit-pipeline-v1",generatedAt:new Date().toISOString(),workspacePath:i,summary:{verdict:M,exitCode:k,stagesPassed:t.filter(e=>e.status==="pass").length,stagesWarn:t.filter(e=>e.status==="warn").length,stagesFailed:t.filter(e=>e.status==="fail").length},stages:t,blockingReasons:[...new Set(o)],artifacts:{reportPath:F,analyzeEvidencePath:d$1,readinessEvidencePath:f$2,autopilotEvidencePath:m}};if(a$3.writeReport!==false){let e=f$1(u,{commandId:"workspacePipeline",exitCode:k,generatedAt:u.generatedAt,blockers:u.blockingReasons,runId:e$1()});await g(i,".workspai/reports/pipeline-last-run.json",e);}if(a$3.writeReport!==false&&a$3.noAgentSync!==true&&process.env.RAPIDKIT_NO_AGENT_SYNC!=="1"&&a$3.agentSync!==false)try{let{syncWorkspaceAgentGrounding:e}=await import('./workspace-agent-sync-G5YVI3BJ.js'),s=await e({workspacePath:i,write:true,refreshContext:true,strict:false});u.agentGrounding={indexPath:s.indexPath,writtenFiles:s.writtenFiles,blockers:s.blockers};}catch{}return u}async function ae(a){let r;try{r=await V(a);}catch(t){let o=t instanceof Error?t.message:String(t);a.json?console.log(JSON.stringify(c$2({operation:"pipeline",code:"pipeline.failed",message:o}),null,2)):console.log(c$3.red(`Pipeline failed: ${o}`)),process.exit(1);}if(a.json)console.log(JSON.stringify(r,null,2));else {console.log(c$3.bold.cyan(`
|
|
2
|
-
\u{1F517} Workspai Governance Pipeline
|
|
3
|
-
`)),console.log(c$3.bold(`Workspace: ${c$3.cyan(p.basename(r.workspacePath))}`)),console.log(c$3.gray(`Path: ${r.workspacePath}`)),console.log(c$3.white(`Verdict: ${r.summary.verdict} Exit: ${r.summary.exitCode} (${r.summary.stagesPassed} pass / ${r.summary.stagesWarn} warn / ${r.summary.stagesFailed} fail)`));for(let t of r.stages){let o=t.status==="pass"?c$3.green("PASS"):t.status==="warn"?c$3.yellow("WARN"):t.status==="skipped"?c$3.gray("SKIP"):c$3.red("FAIL");console.log(` - ${t.name}: ${o} ${t.summary}`);}if(r.blockingReasons.length>0){console.log(c$3.bold(`
|
|
4
|
-
Blocking reasons:`));for(let t of r.blockingReasons.slice(0,8))console.log(c$3.gray(` \u2022 ${t}`));}console.log(c$3.gray(`
|
|
5
|
-
Evidence: ${r.artifacts.reportPath}`)),r.agentGrounding?.writtenFiles.length&&console.log(c$3.gray(`Agent grounding: ${r.agentGrounding.writtenFiles.length} file(s) synced (INDEX + AGENTS.md + Copilot/Cursor/Claude hooks)`));}let i=N(r.summary.exitCode,a.strict===true);i!==0&&process.exit(i);}export{N as pipelineProcessExitCode,V as runPipeline,ae as runPipelineCommand};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export{e as createProject,d as createWorkspace,g as createWorkspaceShareBundle,f as listWorkspaces,c as registerProjectInWorkspace,a as registerWorkspace,b as syncWorkspaceProjects}from'./chunk-K63BSU56.js';
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import {e,c,b as b$1,d}from'./chunk-7RIWU5TZ.js';import {a}from'./chunk-LG6RFLPZ.js';import {f as f$1,o,l,r}from'./chunk-5XATWNME.js';import x from'crypto';import U from'os';import f from'path';import {once}from'events';import {createWriteStream,createReadStream}from'fs';import*as L from'readline';import {Transform,Readable}from'stream';import {pipeline}from'stream/promises';import h from'fs-extra';import*as K from'yauzl';import*as Z from'yazl';var P=".workspai/archive-manifest.json",S=".rapidkit/archive-manifest.json",ie="workspai.workspace.archive",se=1800*1e3,ne=256*1024*1024,oe=new Set(["__pycache__",".venv","venv","node_modules",".git","dist","build","target",".pytest_cache",".mypy_cache",".ruff_cache","htmlcov",".next",".turbo",".cache"]),ce=new Set([".DS_Store","Thumbs.db",".coverage","npm-debug.log","yarn-error.log","pnpm-debug.log"]),he=[/^\.env$/i,/^\.env\.(?!example$|sample$|template$).+/i,/^.*\.pem$/i,/^.*\.key$/i,/^id_rsa$/i,/^id_ed25519$/i];function R(e){return e.replace(/\\/g,"/")}function J(e){return e.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 q(e){let t=R(e).trim();if(!t||t.startsWith("/")||t.startsWith("~")||/^[a-zA-Z]:\//.test(t)||t.includes("\0"))return false;let r=t.split("/").filter(Boolean);return r.length>0&&!r.some(a=>a===".."||a===".")}function G(e){if(!q(e))throw new Error(`Archive contains an unsafe path: ${e}`)}function fe(e,t){let r=f.relative(t,e);return r===""||!!r&&!r.startsWith("..")&&!f.isAbsolute(r)}function le(e,t){let a=R(e).split("/").filter(Boolean);if((a[0]===".workspai"||a[0]===".rapidkit")&&["cache","reports"].includes(a[1]||"")||a.some(s=>oe.has(s)))return true;let i=a[a.length-1]||"";return ce.has(i)||/\.(?:workspai|rapidkit)-archive\.zip$/i.test(i)||!t?.includeEnv&&he.some(s=>s.test(i))?true:i.endsWith(".pyc")||i.endsWith(".log")}async function*X(e,t,r){let a=(await h.readdir(t,{withFileTypes:true})).sort((i,s)=>i.name.localeCompare(s.name));for(let i of a){let s=f.join(t,i.name),n=R(f.relative(e,s));if(!(!n||le(n,r))){if(i.isDirectory()){yield*X(e,s,r);continue}i.isFile()&&(yield {relativePath:n,fullPath:s});}}}async function pe(e){for(let t of o(e,"workspace.json"))try{let r=await h.readJson(t);if(typeof r.workspace_name=="string"&&r.workspace_name.trim())return r.workspace_name.trim();if(typeof r.name=="string"&&r.name.trim())return r.name.trim()}catch{}return f.basename(f.resolve(e))}async function me(e){let t=await h.stat(e.fullPath),r=x.createHash("sha256"),a=0;for await(let s of createReadStream(e.fullPath)){let n=Buffer.isBuffer(s)?s:Buffer.from(s);a+=n.length,r.update(n);}let i=await h.stat(e.fullPath);if(t.size!==i.size||t.mtimeMs!==i.mtimeMs||a!==i.size)throw new Error(`Workspace file changed while preparing archive: ${e.relativePath}`);return {...e,size:a,mtimeMs:i.mtimeMs,sha256:r.digest("hex")}}async function k(e,t){e.write(t)||await once(e,"drain");}async function Y(e){await new Promise((t,r)=>{e.once("error",r),e.end(t);});}async function*b(e){let t=L.createInterface({input:createReadStream(e),crlfDelay:1/0});for await(let r of t){let a=r.trim();a&&(yield JSON.parse(a));}}async function ue(e){let t=createWriteStream(e.manifestPath,{flags:"wx"});try{await k(t,`{
|
|
2
|
-
`);for(let[a,i]of Object.entries(e.manifestBase))await k(t,` ${JSON.stringify(a)}: ${JSON.stringify(i,null,2)},
|
|
3
|
-
`);await k(t,` "files": [
|
|
4
|
-
`);let r=true;for await(let a of b(e.spoolPath)){let{mtimeMs:i,...s}=a;await k(t,`${r?"":`,
|
|
5
|
-
`} ${JSON.stringify(s)}`),r=false;}await k(t,`
|
|
6
|
-
]
|
|
7
|
-
}
|
|
8
|
-
`),await Y(t);}catch(r){throw t.destroy(),await h.remove(e.manifestPath).catch(()=>{}),r}}async function de(e,t){let r=[];for await(let a of b(t)){let{mtimeMs:i,...s}=a;r.push(s);}return {...e,files:r}}async function ve(e,t){try{await h.rename(e,t);}catch(r){let a=r.code;if(a!=="EEXIST"&&a!=="EPERM")throw r;await h.move(e,t,{overwrite:true});}}async function Fe(e){let t=f.resolve(e.workspacePath);if(!f$1(t))throw new Error("Workspace export requires a Workspai workspace root with .workspai-workspace or a legacy .rapidkit-workspace marker.");let r=await pe(t),a=f.resolve(e.outputPath||`${J(r)}.workspai-archive.zip`),i={schemaVersion:b$1,version:1,kind:ie,workspaceName:r,exportedAt:(e.now??new Date).toISOString(),exportedBy:"workspai",archiveFormat:e.compression==="deflate"?"zip-deflate":"zip-store",containerFormat:"zip64",compression:e.compression==="deflate"?"deflate":"store",streaming:true,security:{envFilesIncluded:e.includeEnv===true,excludedByDefault:[".git","node_modules",".venv","dist","build","target",".env","*.pem","*.key","*.log"]}},s=f.resolve(a);await h.ensureDir(f.dirname(a));let n=`${a}.${process.pid}.${x.randomUUID()}.tmp`,o=await h.mkdtemp(f.join(U.tmpdir(),"workspai-archive-export-")),l=f.join(o,"manifest-files.jsonl"),m=f.join(o,"archive-manifest.json"),d=new Z.ZipFile,y=e.now??new Date,c$1=e.compression==="deflate";try{let p=createWriteStream(l,{flags:"wx"});try{for await(let u of X(t,t,{includeEnv:e.includeEnv===true})){if(f.resolve(u.fullPath)===s)continue;let v=await me(u),E={path:v.relativePath,size:v.size,sha256:v.sha256,mtimeMs:v.mtimeMs};await k(p,`${JSON.stringify(E)}
|
|
9
|
-
`);}await Y(p);}catch(u){throw p.destroy(),u}await ue({manifestBase:i,spoolPath:l,manifestPath:m});for await(let u of b(l)){let v=f.join(t,...u.path.split("/"));d.addFile(v,u.path,{compress:c$1,forceZip64Format:u.size>=4294967295,mtime:y});}d.addFile(m,P,{compress:c$1,mtime:y}),d.end({forceZip64Format:true,comment:""}),await pipeline(d.outputStream,createWriteStream(n,{flags:"wx"}));for await(let u of b(l)){let v=f.join(t,...u.path.split("/")),E=await h.stat(v);if(E.size!==u.size||E.mtimeMs!==u.mtimeMs)throw new Error(`Workspace file changed while writing archive: ${u.path}`)}let w=await h.stat(n);await ve(n,a);let g=await de(i,l);return _({schemaVersion:c,operation:"export",status:"passed",archivePath:a,manifest:g,bytesWritten:w.size})}finally{await h.remove(o).catch(()=>{}),await h.remove(n).catch(()=>{});}}async function Q(e,t={}){if(/^https?:\/\//i.test(e)){let r=await h.mkdtemp(f.join(U.tmpdir(),"workspai-workspace-archive-")),a=f.join(r,"workspace.workspai-archive.zip"),i=new AbortController,s=t.downloadTimeoutMs??se,n=s>0?setTimeout(()=>i.abort(new Error("Download timed out")),s):null;try{let o=await fetch(e,{signal:i.signal});if(!o.ok)throw new Error(`Failed to download workspace archive: HTTP ${o.status}`);if(!o.body)throw new Error("Failed to download workspace archive: response body is empty.");let l=Number(o.headers.get("content-length"));if(t.maxDownloadBytes!==void 0&&Number.isFinite(l)&&l>t.maxDownloadBytes)throw new Error(`Workspace archive download exceeds configured limit (${l} > ${t.maxDownloadBytes} bytes).`);let m=0,d=new Transform({transform(c,p,w){if(m+=c.length,t.maxDownloadBytes!==void 0&&m>t.maxDownloadBytes){w(new Error(`Workspace archive download exceeds configured limit (${t.maxDownloadBytes} bytes).`));return}w(null,c);}}),y=Readable.fromWeb(o.body);return await pipeline(y,d,createWriteStream(a,{flags:"wx"})),{archivePath:a,cleanup:r}}catch(o){throw await h.remove(r).catch(()=>{}),i.signal.aborted?new Error(`Workspace archive download timed out after ${s}ms.`,{cause:o}):o}finally{n&&clearTimeout(n);}}return {archivePath:f.resolve(e)}}function we(e){return new Promise((t,r)=>{K.open(e,{autoClose:false,lazyEntries:true,decodeStrings:true,validateEntrySizes:true,strictFileNames:true},(a,i)=>{a||!i?r(a??new Error("Failed to open workspace archive.")):t(i);});})}function ye(e){return new Promise((t,r)=>{let a=[],i=s=>r(s);e.once("error",i),e.on("entry",s=>{try{if(G(s.fileName),s.isEncrypted())throw new Error(`Encrypted workspace archive entries are not supported: ${s.fileName}`);s.fileName.endsWith("/")||a.push({name:s.fileName,size:s.uncompressedSize,compressedSize:s.compressedSize,crc32:s.crc32,entry:s}),e.readEntry();}catch(n){r(n);}}),e.once("end",()=>{e.removeListener("error",i),t(a);}),e.readEntry();})}function N(e,t){return new Promise((r,a)=>{e.openReadStream(t,(i,s)=>{i||!s?a(i??new Error(`Failed to read ${t.fileName}.`)):r(s);});})}async function ge(e,t,r=ne){if(t.size>r)throw new Error(`Workspace archive manifest exceeds ${r} bytes.`);let a=[],i=0,s=await N(e,t.entry);for await(let n of s){let o=Buffer.isBuffer(n)?n:Buffer.from(n);if(i+=o.length,i>r)throw s.destroy(),new Error(`Workspace archive manifest exceeds ${r} bytes.`);a.push(o);}return Buffer.concat(a,i)}function Ee(e){let t=JSON.parse(e.toString("utf-8"));a(t,d,"Workspace archive manifest");let r=new Set;for(let a of t.files){if(!q(a.path)||R(a.path)!==a.path)throw new Error(`Workspace archive manifest contains an unsafe path: ${a.path}`);if(a.path===P||a.path===S)throw new Error(`Workspace archive manifest cannot inventory itself: ${a.path}`);if(r.has(a.path))throw new Error(`Workspace archive manifest contains duplicate path: ${a.path}`);r.add(a.path);}return t}function _(e$1){return a(e$1,e,"Workspace archive operation result"),e$1}function Ae(e){return r(R(e))}function ke(e){let t=new Map;for(let r of e){if(r.name===P||r.name===S)continue;let a=Ae(r.name),i=t.get(a);if(!i){t.set(a,{...r,sourceName:r.name,targetName:a});continue}let s=r.name===a,n=i.sourceName===i.targetName;if(s&&!n){t.set(a,{...r,sourceName:r.name,targetName:a});continue}if(!(i.size===r.size&&i.crc32===r.crc32)&&!n)throw new Error(`Workspace archive contains conflicting entries for ${a}: ${i.sourceName}, ${r.name}`)}return [...t.values()].sort((r,a)=>r.targetName.localeCompare(a.targetName))}async function C(e,t={}){let r=await Q(e,t),a;try{a=await we(r.archivePath);let i=await ye(a),s=i.reduce((l,m)=>l+m.size,0);if(t.maxExpandedBytes!==void 0&&s>t.maxExpandedBytes)throw new Error(`Workspace archive payload exceeds configured limit (${s} > ${t.maxExpandedBytes} bytes).`);let n=i.find(l=>l.name===P||l.name===S);if(!n)throw new Error(`Workspace archive is missing ${l("","archive-manifest.json").replace(/^\//,"")}.`);let o=Ee(await ge(a,n));return {archivePath:r.archivePath,entries:i,manifest:o,zipFile:a,cleanup:r.cleanup}}catch(i){throw a?.close(),r.cleanup&&await h.remove(r.cleanup).catch(()=>{}),i}}async function M(e){e.zipFile?.close(),e.cleanup&&await h.remove(e.cleanup).catch(()=>{});}async function Pe(e){let t=await C(e.archivePathOrUrl,e.safety);try{let r=new Map(t.entries.filter(i=>i.name!==P&&i.name!==S).map(i=>[i.name,i])),a=t.manifest.files.map(i=>({path:i.path,size:r.get(i.path)?.size??i.size,hasChecksum:typeof i.sha256=="string"&&i.sha256.length>0}));return _({schemaVersion:c,operation:"inspect",status:"passed",archivePath:t.archivePath,manifest:t.manifest,fileCount:a.length,totalBytes:a.reduce((i,s)=>i+s.size,0),entries:a})}finally{await M(t);}}async function ee(e){let t=await C(e.archivePathOrUrl,e.safety);try{let r=new Map(t.entries.filter(c=>c.name!==P&&c.name!==S).map(c=>[c.name,c])),a=new Set(t.manifest.files.map(c=>c.path)),i=[...r.keys()].filter(c=>!a.has(c)).sort(),s=[],n=[],o=[],l=0;for(let c of t.manifest.files){G(c.path);let p=r.get(c.path);if(!p){s.push(c.path);continue}let w=x.createHash("sha256"),g=0,u=await N(t.zipFile,p.entry);for await(let E of u){let $=Buffer.isBuffer(E)?E:Buffer.from(E);g+=$.length,w.update($);}let v={size:g,sha256:w.digest("hex")};if(g!==p.size||g!==c.size){o.push({path:c.path,expected:{size:c.size,sha256:c.sha256},actual:v});continue}if(!c.sha256){n.push(c.path);continue}if(v.sha256!==c.sha256){o.push({path:c.path,expected:{size:c.size,sha256:c.sha256},actual:v});continue}l+=1;}let m=e.requireChecksums===true&&n.length>0,d=s.length>0||o.length>0||m||i.length>0,y=n.length>0;return _({schemaVersion:c,operation:"verify",archivePath:t.archivePath,manifest:t.manifest,status:d?"failed":y?"warning":"passed",fileCount:t.manifest.files.length,totalBytes:t.manifest.files.reduce((c,p)=>c+p.size,0),verifiedFiles:l,missingChecksumFiles:n,missingArchiveEntries:s,extraArchiveEntries:i,mismatches:o})}finally{await M(t);}}async function Ve(e){let t=await Q(e.archivePathOrUrl,e.safety);try{return await We({archivePath:t.archivePath,strict:e.strict})}finally{t.cleanup&&await h.remove(t.cleanup).catch(()=>{});}}async function We(e){let t=await Pe({archivePathOrUrl:e.archivePath}),r=await ee({archivePathOrUrl:e.archivePath,requireChecksums:e.strict===true}),a=[],i=[];a.push({id:"manifest-present",status:"passed",message:`Archive manifest found for workspace "${t.manifest.workspaceName}".`}),a.push({id:"integrity",status:r.status,message:r.status==="passed"?`Verified ${r.verifiedFiles}/${r.fileCount} files.`:"Archive integrity verification did not fully pass."});let s=t.manifest.security?.envFilesIncluded===true;a.push({id:"secrets-policy",status:s?"warning":"passed",message:s?"Archive manifest says environment/private files were intentionally included.":"Archive manifest excludes environment/private files by default."}),s&&i.push("Share this archive only through trusted internal channels."),r.missingChecksumFiles.length>0&&i.push("Re-export the archive with the latest RapidKit/Workspai tooling."),r.mismatches.length>0&&i.push("Reject this archive and request a fresh export from the owner."),(r.extraArchiveEntries.length>0||r.missingArchiveEntries.length>0)&&i.push("Regenerate the archive so ZIP entries and manifest entries match."),e.strict===true&&r.status!=="passed"&&i.push("Do not hydrate this archive in strict or production workflows.");let n=a.some(l=>l.status==="failed"),o=a.some(l=>l.status==="warning");return _({schemaVersion:c,operation:"doctor",archivePath:t.archivePath,status:n?"failed":o?"warning":"passed",workspaceName:t.manifest.workspaceName,fileCount:t.fileCount,totalBytes:t.totalBytes,checks:a,recommendedActions:i})}async function Se(e,t){let r=await h.lstat(e).catch(i=>{if(i.code==="ENOENT")return null;throw i});if(!r)return false;if(r.isSymbolicLink())throw new Error(`Output directory must not be a symbolic link: ${e}`);if(!r.isDirectory())throw new Error(`Output path is not a directory: ${e}`);if((await h.readdir(e)).length>0&&!t)throw new Error(`Output directory is not empty: ${e}. Use --force to overwrite.`);return true}async function De(e){let t=await C(e.archivePathOrUrl,e.safety);try{let r=await ee({archivePathOrUrl:t.archivePath,requireChecksums:e.strict===true});if(r.status==="failed"){let o=[r.missingArchiveEntries.length?`missing entries: ${r.missingArchiveEntries.join(", ")}`:"",r.extraArchiveEntries.length?`unexpected entries: ${r.extraArchiveEntries.join(", ")}`:"",r.mismatches.length?`checksum/size mismatches: ${r.mismatches.map(l=>l.path).join(", ")}`:"",r.missingChecksumFiles.length&&e.strict===true?`missing checksums: ${r.missingChecksumFiles.join(", ")}`:""].filter(Boolean).join("; ");throw new Error(`Workspace archive verification failed${o?` (${o})`:""}.`)}if(r.status==="warning"&&e.strict===true)throw new Error(`Workspace archive verification requires checksums for every file: ${r.missingChecksumFiles.join(", ")}`);let a=ke(t.entries),i=t.manifest,s=f.resolve(e.outputPath||J(i.workspaceName||"imported-workspace")),n=await Se(s,e.force===true);if(!e.dryRun){let o=f.dirname(s),l=`${process.pid}-${x.randomUUID()}`,m=f.join(o,`.${f.basename(s)}.hydrate-${l}.tmp`),d=f.join(o,`.${f.basename(s)}.hydrate-${l}.backup`),y=false,c=false;await h.ensureDir(o);try{await h.ensureDir(m);for(let p of a){let w=f.resolve(m,p.targetName);if(!fe(w,m))throw new Error(`Archive entry escapes output directory: ${p.targetName}`);await h.ensureDir(f.dirname(w));let g=await N(t.zipFile,p.entry);await pipeline(g,createWriteStream(w,{flags:"wx"}));}n&&(await h.rename(s,d),y=true),await h.rename(m,s),c=true,y&&await h.remove(d).catch(()=>{});}catch(p){throw y&&!await h.pathExists(s)&&await h.rename(d,s).catch(()=>{}),p}finally{await h.remove(m).catch(()=>{}),c&&await h.remove(d).catch(()=>{});}}return _({schemaVersion:c,operation:"hydrate",status:"passed",archivePath:t.archivePath,outputPath:s,dryRun:e.dryRun===true,manifest:i,files:a.map(o=>({path:o.targetName,size:o.size}))})}finally{await M(t);}}
|
|
10
|
-
export{ie as WORKSPACE_ARCHIVE_KIND,P as WORKSPACE_ARCHIVE_MANIFEST_PATH,Ve as doctorWorkspaceArchive,Fe as exportWorkspaceArchive,De as hydrateWorkspaceArchive,Pe as inspectWorkspaceArchive,q as isSafeArchiveEntryName,J as sanitizeWorkspaceArchiveName,le as shouldExcludeWorkspaceArchivePath,ee as verifyWorkspaceArchive};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export{b as WORKSPACE_CONTRACT_PATH,d as WORKSPACE_CONTRACT_SCHEMA_VERSION,c as WORKSPACE_CONTRACT_VERIFY_REPORT_PATH,e as WORKSPACE_CONTRACT_VERIFY_SCHEMA_VERSION,g as buildWorkspaceContract,k as buildWorkspaceContractGraph,f as discoverProjectJsonFiles,j as readWorkspaceContract,i as syncWorkspaceContract,l as verifyWorkspaceContract,h as writeWorkspaceContract,m as writeWorkspaceContractVerifyEvidence}from'./chunk-QWU2CZBG.js';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export{b as buildWorkspaceExplain,a as resolveWorkspaceExplainArtifactPath,c as writeWorkspaceExplainReport}from'./chunk-IMUU5Q2V.js';export{e as WORKSPACE_MODEL_DIFF_REPORT_PATH}from'./chunk-ZWO6K24C.js';export{c as WORKSPACE_EXPLAIN_REPORT_PATH,e as WORKSPACE_TRACE_REPORT_PATH,d as WORKSPACE_WHY_REPORT_PATH}from'./chunk-XIVFLY6G.js';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export{a as WORKSPACE_EXPLAIN_SCHEMA_VERSION,b as WORKSPACE_EXPLAIN_TARGETS,e as isWorkspaceExplainReport,c as parseWorkspaceExplainTarget,d as resolveWorkspaceTraceTarget}from'./chunk-J4AICQFB.js';export{c as WORKSPACE_EXPLAIN_REPORT_PATH,e as WORKSPACE_TRACE_REPORT_PATH,d as WORKSPACE_WHY_REPORT_PATH}from'./chunk-XIVFLY6G.js';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export{g as WORKSPACE_IMPACT_REPORT_PATH,f as WORKSPACE_IMPACT_SCHEMA_VERSION,e as WORKSPACE_MODEL_DIFF_REPORT_PATH,c as WORKSPACE_MODEL_DIFF_SCHEMA_VERSION,d as WORKSPACE_MODEL_SNAPSHOT_REPORT_PATH,b as WORKSPACE_MODEL_SNAPSHOT_SCHEMA_VERSION,p as buildWorkspaceImpact,k as buildWorkspaceModelSnapshot,m as diffWorkspaceModel,j as hashWorkspaceModel,h as isGitDiffSource,i as parseGitDiffRef,o as workspaceVerificationPlan,q as writeWorkspaceImpact,n as writeWorkspaceModelDiff,l as writeWorkspaceModelSnapshot}from'./chunk-ZWO6K24C.js';
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import {b}from'./chunk-IMUU5Q2V.js';import {d}from'./chunk-LCRROMRR.js';import {d as d$1}from'./chunk-42G2OK64.js';import {c as c$1,e}from'./chunk-J4AICQFB.js';import {c as c$2,b as b$2}from'./chunk-XIVFLY6G.js';import {k}from'./chunk-HYJK7W3B.js';import {c as c$3}from'./chunk-QWU2CZBG.js';import {f}from'./chunk-6AA3WWQZ.js';import {a as a$1}from'./chunk-LG6RFLPZ.js';import {a,c}from'./chunk-5AKYMAIL.js';import {r}from'./chunk-5XATWNME.js';import m from'path';import v from'readline';import b$1 from'fs-extra';var W=a.agentIndex,I=new Map(Object.keys(a).flatMap(e=>{let t=c[e];return t?[[a[e],t]]:[]}));function N(e,t){return e.kind!==t.kind?false:e.kind==="project"&&t.kind==="project"?e.project.toLowerCase()===t.project.toLowerCase():e.kind==="blocker"&&t.kind==="blocker"?e.blockerId===t.blockerId:e.kind==="trace"&&t.kind==="trace"?e.diffRef===t.diffRef:true}var L=[{name:"getWorkspaceModel",description:"Read workspace-model.json",inputSchema:{type:"object",properties:{}}},{name:"getEvidenceIndex",description:"Read agent reports INDEX.json",inputSchema:{type:"object",properties:{}}},{name:"getBlockers",description:"Aggregate blocking reasons from verify, explain, and contract-verify reports",inputSchema:{type:"object",properties:{}}},{name:"getSafeCommands",description:"Read safe commands from workspace-context-agent.json",inputSchema:{type:"object",properties:{}}},{name:"getProjectContext",description:"Read scoped project context from workspace-context-agent.json",inputSchema:{type:"object",properties:{project:{type:"string",description:"Optional project name; defaults to active scope"}}}},{name:"getArtifact",description:"Read one workspace-relative artifact path",inputSchema:{type:"object",properties:{relativePath:{type:"string"}},required:["relativePath"]}},{name:"listOperationalSkills",description:"Read workspace-skills-index.json",inputSchema:{type:"object",properties:{}}},{name:"getWorkspaceExplain",description:"Build or read workspace explain report",inputSchema:{type:"object",properties:{target:{type:"string",description:"release-blocked | project:<name> | blocker:<id> | trace:<diffRef> | <project>"}}}}];function M(e){let t=e.trim().replace(/\\/g,"/");return t.length>0&&!m.isAbsolute(t)&&!t.split("/").includes("..")&&(t.startsWith(".workspai/")||t.startsWith(".rapidkit/"))}async function l(e,t){if(!M(t))throw new Error(`Unsafe artifact path: ${t}`);let i=await f(e,t)??m.join(e,t);if(!await b$1.pathExists(i))return null;let r$1=await b$1.readJson(i),s=r(t),a=I.get(s);return a&&a$1(r$1,a,`MCP artifact ${s}`),r$1}async function J(e$1){let t=[],i=new Set,s=((await l(e$1,d$1))?.blockingReasons??[]).filter(n=>typeof n=="string"&&n.trim().length>0);if(s.length>0){t.push({artifact:d$1,reasons:s});for(let n of s)i.add(n);}let a=await l(e$1,c$2);if(e(a)){let n=(a.blockingReasons??[]).filter(o=>typeof o=="string"&&o.trim().length>0);if(n.length>0){t.push({artifact:c$2,reasons:n});for(let o of n)i.add(o);}}let c=await l(e$1,c$3),p=(c?.violations??[]).filter(n=>typeof n=="string"&&n.trim().length>0);if(p.length>0||String(c?.status??"").toLowerCase()==="failed"){let n=p.length>0?p:["Workspace contract verification failed"];t.push({artifact:c$3,reasons:n});for(let o of n)i.add(o);}return {blockingReasons:[...i],sources:t}}async function O(e$1,t,i){switch(t){case "getWorkspaceModel":return l(e$1,k);case "getEvidenceIndex":return l(e$1,W);case "getBlockers":return J(e$1);case "getSafeCommands":return {safeCommands:(await l(e$1,d))?.safeCommands??[]};case "getProjectContext":{let r=await l(e$1,d);if(!r)return null;let s=String(i.project??"").trim(),a=r.scope?.activeProject??void 0,c=s||a,p=Array.isArray(r.projects)?r.projects:[],n=c&&p.find(o=>typeof o.name=="string"&&o.name.toLowerCase()===c.toLowerCase());return {workspace:r.workspace??null,scope:r.scope??null,validation:r.validation??null,project:n??null,safeCommands:r.safeCommands??[]}}case "getArtifact":{let r=String(i.relativePath??"").trim();return l(e$1,r)}case "listOperationalSkills":return l(e$1,b$2);case "getWorkspaceExplain":{let r=String(i.target??"release-blocked").trim(),s=c$1(r);if(!s)throw new Error(`Invalid explain target: ${r}`);let a=await l(e$1,c$2);return e(a)&&N(a.target,s)?a:b({workspacePath:e$1,target:s})}default:throw new Error(`Unknown tool: ${t}`)}}function E(e,t){process.stdout.write(`${JSON.stringify({jsonrpc:"2.0",id:e??null,result:t})}
|
|
2
|
-
`);}function w(e,t){process.stdout.write(`${JSON.stringify({jsonrpc:"2.0",id:e??null,error:{code:-32e3,message:t}})}
|
|
3
|
-
`);}async function et(e){let t=m.resolve(e.workspacePath),i=v.createInterface({input:process.stdin,terminal:false});for await(let r of i){let s=r.trim();if(!s)continue;let a;try{a=JSON.parse(s);}catch{w(null,"Invalid JSON-RPC request");continue}let{id:c,method:p,params:n}=a;try{if(p==="initialize"){E(c,{protocolVersion:"2024-11-05",capabilities:{tools:{}},serverInfo:{name:"workspai-workspace-mcp",version:"0.1.0"}});continue}if(p==="notifications/initialized")continue;if(p==="tools/list"){E(c,{tools:L.map(o=>({name:o.name,description:o.description,inputSchema:o.inputSchema}))});continue}if(p==="tools/call"){let o=String(n?.name??""),h=n?.arguments&&typeof n.arguments=="object"?n.arguments:{},A=await O(t,o,h);E(c,{content:[{type:"text",text:JSON.stringify(A,null,2)}],isError:A==null});continue}w(c,`Unsupported method: ${p??"unknown"}`);}catch(o){w(c,o instanceof Error?o.message:String(o));}}}async function nt(e,t,i={}){return O(m.resolve(e),t,i)}export{L as WORKSPACE_MCP_READ_TOOLS,nt as invokeMcpToolForTest,et as runWorkspaceMcpServe};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export{k as WORKSPACE_MODEL_REPORT_PATH,j as WORKSPACE_MODEL_SCHEMA_VERSION,n as buildWorkspaceModel,o as buildWorkspaceModelCached,m as buildWorkspaceModelFacts,p as buildWorkspaceModelIncremental,l as validateWorkspaceModelStrict,q as writeWorkspaceModel}from'./chunk-HYJK7W3B.js';
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import {a,b}from'./chunk-GSWPGELT.js';import {o}from'./chunk-5XATWNME.js';import l from'fs-extra';function c(n){return n&&typeof n=="object"&&!Array.isArray(n)?n:{}}async function m(n,e){if(!await l.pathExists(n))return false;let o=c(await l.readJson(n));return await l.outputJson(n,e(o),{spaces:2}),await l.appendFile(n,`
|
|
2
|
-
`,"utf-8"),true}async function f(n,e){let o$1=e.now??new Date().toISOString(),d=e.installMethod==="pip"?"venv":e.installMethod;for(let r of o(n,"workspace.json"))await m(r,a=>{let s=c(a.engine),i=c(s.python_core);return delete a.bootstrap_note,delete i.reason,{...a,engine:{...s,install_method:d,python_version:e.pythonVersion??s.python_version??null,python_core:{...i,status:"installed",installed_at:o$1,...e.coreVersion?{version:e.coreVersion}:{}}}}});for(let r of o(n,"toolchain.lock"))await m(r,a=>{let s=c(a.runtime),i=c(s.python),h=c(i.core);return delete h.reason,{...a,generated_at:o$1,runtime:{...s,python:{...i,version:e.pythonVersion??i.version??null,install_method:d,core:{...h,status:"installed",installed_at:o$1,...e.coreVersion?{version:e.coreVersion}:{}}}}}});let t=await a(n);if(t){let r={...t.metadata?.python??{}};delete r.coreReason,t.metadata={...t.metadata,python:{...r,coreStatus:"installed",...e.coreVersion?{coreVersion:e.coreVersion}:{},...e.pythonVersion?{pythonVersion:e.pythonVersion}:{},...e.venvPath?{venvPath:e.venvPath}:{}},npm:{...t.metadata?.npm??{},packageVersion:t.metadata?.npm?.packageVersion??t.version,installMethod:d,lastUsedAt:o$1}},await b(n,t);}}export{f as markWorkspacePythonEngineInstalled};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import {a}from'./chunk-A5FBGRJA.js';import {b as b$1,j}from'./chunk-QWU2CZBG.js';import {f,g}from'./chunk-6AA3WWQZ.js';import {r,p}from'./chunk-2K3GYCPS.js';import {o}from'./chunk-5XATWNME.js';import n from'path';import {existsSync}from'fs';import y from'fs-extra';var k=".workspai/workspace-registry.v1.json",w="workspace-registry.v1";function C(t){return {slug:t.slug,relativePath:t.relativePath,framework:t.framework,kit:t.kit,source:t.source}}async function x(t){let r=o(t,"workspace.json").find(e=>existsSync(e));if(!r)return {exists:false,legacyProjectCount:0};try{let e=await y.readJson(r),s=Array.isArray(e.projects)?e.projects.length:0,o=typeof e.workspace_name=="string"&&e.workspace_name.trim()||typeof e.name=="string"&&e.name.trim()||n.basename(t);return {exists:true,manifestPath:r,workspaceName:o,profile:typeof e.profile=="string"?e.profile:void 0,legacyProjectCount:s}}catch{return {exists:true,manifestPath:r,legacyProjectCount:0,workspaceName:n.basename(t)}}}async function A(t){let r$1=a(t);for(let e of r())if(await y.pathExists(e))try{let o=((await y.readJson(e)).workspaces||[]).find(a$1=>a(a$1.path)===r$1);if(o)return {exists:true,projectCount:Array.isArray(o.projects)?o.projects.length:0,registryPath:e}}catch{continue}return {exists:false,projectCount:0,registryPath:n.join(p(),"workspaces.json")}}async function b(t){let r=n.resolve(t),e=await f(r,b$1),s=await x(r),o=await A(r),a=!!e,c=[];if(a)try{let{contract:S}=await j({workspacePath:r});c=S.projects||[];}catch{c=[];}let W={contract:{exists:a,projectCount:c.length,path:b$1},globalRegistry:{exists:o.exists,projectCount:o.projectCount,path:o.registryPath},legacyWorkspaceJson:{exists:s.exists,projectCount:s.legacyProjectCount,path:s.manifestPath?n.relative(r,s.manifestPath):void 0}},i="none",u=[],p=0;return a?(i="workspace.contract.json",u=c.map(C),p=u.length):o.projectCount>0?(i="global-registry",p=o.projectCount):s.legacyProjectCount>0&&(i="legacy-workspace.json",p=s.legacyProjectCount),{contractExists:a,summary:{schemaVersion:w,kind:"rapidkit.workspace.registry",workspacePath:r,workspaceName:s.workspaceName||n.basename(r),profile:s.profile,projectCount:p,authority:i,contractPath:b$1,projects:u,sources:W}}}async function J(t){let r=await f(t,k);if(!r)return null;try{let e=await y.readJson(r);return e?.schemaVersion!==w?null:e}catch{return null}}async function V(t,r){let s={...(await b(t)).summary,generatedAt:(r?.now??new Date).toISOString(),registrySummaryPath:k};return await g(t,k,s),s}function Y(t,r=""){return t.projectCount>0?t.authority==="workspace.contract.json"?`${t.projectCount} project(s) registered in workspace contract${r}.`:t.authority==="global-registry"?`${t.projectCount} project(s) registered in global workspace registry${r}.`:`${t.projectCount} project(s) registered in legacy workspace manifest${r}.`:`Workspace state exists, but no projects are registered yet${r}.`}export{k as WORKSPACE_REGISTRY_SUMMARY_RELATIVE_PATH,w as WORKSPACE_REGISTRY_SUMMARY_SCHEMA_VERSION,Y as formatWorkspaceRegistrySyncSummary,V as publishWorkspaceRegistrySummary,J as readWorkspaceRegistrySummary,b as resolveWorkspaceRegisteredProjects};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export{a as runWorkspaceStage}from'./chunk-WANW4QA4.js';export{a as WORKSPACE_RUN_LAST_REPORT_FILENAME}from'./chunk-KU4S7RCM.js';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import {a}from'./chunk-OOOPYUL2.js';import {b as b$1,p}from'./chunk-HYJK7W3B.js';import {a as a$1}from'./chunk-LG6RFLPZ.js';import P from'fs';var w="workspace-watch-event.v1";function b(t){return a$1(t,"contracts/workspace-watch-event.v1.json","Workspace watch event"),t}function g(t){return `${t.from}\0${t.to}\0${t.kind}`}function f(t){return (t.graph?.edges??[]).map(r=>({from:r.from,to:r.to,kind:r.kind}))}function m(t){let o=[...a(t).entries()].sort((a,n)=>a[0].localeCompare(n[0])).map(([a,n])=>({id:a,hash:n})),c=f(t).map(g).sort((a,n)=>a.localeCompare(n));return b$1({projects:o,edges:c})}function R(t,r){let o=a(r),c=t?a(t):new Map,a$1=[],n=[];for(let[e,s]of o.entries())c.has(e)?c.get(e)!==s&&a$1.push(e):n.push(e);let d=[];for(let e of c.keys())o.has(e)||d.push(e);let i=new Map(t?f(t).map(e=>[g(e),e]):[]),l=new Map(f(r).map(e=>[g(e),e])),p=[];for(let[e,s]of l.entries())i.has(e)||p.push(s);let h=[];for(let[e,s]of i.entries())l.has(e)||h.push(s);let u=(e,s)=>g(e).localeCompare(g(s));return a$1.sort((e,s)=>e.localeCompare(s)),n.sort((e,s)=>e.localeCompare(s)),d.sort((e,s)=>e.localeCompare(s)),p.sort(u),h.sort(u),{changedProjects:a$1,addedProjects:n,removedProjects:d,edgesAdded:p,edgesRemoved:h}}var k=class{model=null;sequence=0;rebuild;now;constructor(r,o){this.rebuild=o?.rebuild??(()=>p({...r})),this.now=o?.now??(()=>new Date);}get currentModel(){return this.model}async start(){let r=Date.now(),{model:o}=await this.rebuild();return this.model=o,this.buildEvent("ready","initial",null,o,Date.now()-r)}async pulse(){let r=Date.now(),o=this.model,{model:c,mode:a}=await this.rebuild(),n=this.buildEvent(this.hasStructuralChange(o,c)?"changed":"unchanged",a,o,c,Date.now()-r);return this.model=c,n}hasStructuralChange(r,o){return r?m(r)!==m(o):true}buildEvent(r,o,c,a,n){let d=R(c,a),i=m(a),l=c?m(c)!==i:true;return b({schemaVersion:w,kind:r,sequence:this.sequence++,timestamp:this.now().toISOString(),mode:o,modelHash:i,modelHashChanged:l,changedProjects:d.changedProjects,addedProjects:d.addedProjects,removedProjects:d.removedProjects,graph:{nodeCount:a.graph?.nodes.length??0,edgeCount:a.graph?.edges.length??0,edgesAdded:d.edgesAdded,edgesRemoved:d.edgesRemoved},durationMs:n})}},C=new Set([".git",".hg",".svn","node_modules",".venv","venv","dist","build","out","target","coverage","htmlcov",".next",".turbo",".cache"]),y=new Set(["reports","cache","tmp",".cache"]);function S(t){if(!t)return false;let r=t.split(/[\\/]/).filter(Boolean);if(r.some(o=>C.has(o)))return false;for(let o=0;o<r.length-1;o+=1)if((r[o]===".workspai"||r[o]===".rapidkit")&&y.has(r[o+1]))return false;return true}async function I(t){let r=new k(t.buildOptions,t.engineOptions),o=await r.start();if(t.emit(o),t.once)return;let c=t.debounceMs??250,a=t.selfWriteSuppressionMs??Math.max(400,c+150),n=null,d=false,i=false,l=0,p=async()=>{if(d){i=true;return}d=true;try{let e=await r.pulse();t.emit(e);}catch(e){t.emit(b({schemaVersion:w,kind:"error",sequence:-1,timestamp:new Date().toISOString(),mode:"full",modelHash:r.currentModel?m(r.currentModel):"",modelHashChanged:false,changedProjects:[],addedProjects:[],removedProjects:[],graph:{nodeCount:0,edgeCount:0,edgesAdded:[],edgesRemoved:[]},durationMs:0,error:e instanceof Error?e.message:String(e)}));}finally{d=false,l=Date.now()+a,i&&(i=false,p());}},h=e=>{S(e)&&(d||Date.now()<l||(n&&clearTimeout(n),n=setTimeout(()=>{n=null,p();},c)));};t.onProgress?.(`Watching ${t.workspacePath} for changes (Ctrl+C to stop).`);let u=P.watch(t.workspacePath,{recursive:true},(e,s)=>{typeof s=="string"?h(s):s&&h(Buffer.from(s).toString("utf8"));});await new Promise(e=>{let s=()=>{n&&clearTimeout(n),u.close(),e();};if(t.signal){if(t.signal.aborted){s();return}t.signal.addEventListener("abort",s,{once:true});}u.on("error",()=>s());});}export{w as WORKSPACE_WATCH_EVENT_SCHEMA_VERSION,k as WorkspaceWatchEngine,m as computeWatchModelHash,R as diffWatchModels,S as isWatchRelevantPath,I as runWorkspaceWatch};
|