workspai 0.55.1 → 0.56.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/contracts/artifact-remediation-plan.v1.json +110 -2
- package/contracts/cli-runtime-command-inventory.v1.snapshot.json +29 -1
- package/contracts/doctor-project-evidence.v1.json +68 -2
- package/contracts/doctor-remediation-plan.v1.json +29 -2
- package/contracts/doctor-workspace-evidence.v1.json +68 -2
- package/contracts/extension-cli-compatibility.v1.json +6 -1
- package/contracts/published-contract-catalog.v1.json +25 -0
- package/contracts/runtime-command-surface.v1.json +63 -0
- package/contracts/workspace-intelligence/doctor-capabilities.v1.json +133 -0
- package/contracts/workspace-intelligence/doctor-diagnosis.v1.json +273 -0
- package/contracts/workspace-intelligence/doctor-graph-diagnosis.v1.json +3 -0
- package/contracts/workspace-intelligence/doctor-receipt.v1.json +136 -0
- package/contracts/workspace-intelligence/doctor-summary.v1.json +99 -0
- package/contracts/workspace-intelligence/doctor-validation.v1.json +109 -0
- package/contracts/workspace-intelligence/project-context-agent.v1.json +110 -0
- package/contracts/workspace-intelligence/studio-blocker-handoff.v1.json +25 -0
- package/contracts/workspace-intelligence/workspace-knowledge-graph.v1.json +36 -0
- package/contracts/workspace-intelligence/workspace-knowledge-search.v1.json +54 -0
- package/dist/analyze-HJ774J3E.js +1 -0
- package/dist/{artifact-remediation-plan-O3YIULQN.js → artifact-remediation-plan-BPLON5VX.js} +1 -1
- package/dist/autopilot-release-CH57CGET.js +1 -0
- package/dist/capabilities-command-WEOGFCWF.js +1 -0
- package/dist/chunk-2647BYBC.js +1 -0
- package/dist/chunk-2L4PSZQB.js +1 -0
- package/dist/chunk-3U4VLIGW.js +1 -0
- package/dist/chunk-5BGPGNRQ.js +2 -0
- package/dist/chunk-5EPPPMAS.js +1 -0
- package/dist/{chunk-M5ICGR55.js → chunk-5RL254O2.js} +1 -1
- package/dist/chunk-5ZA4JYOP.js +1 -0
- package/dist/{chunk-AMB42V2F.js → chunk-64JUYYRC.js} +1 -1
- package/dist/chunk-664GXRLD.js +1 -0
- package/dist/chunk-6HCAGHCY.js +8 -0
- package/dist/chunk-7PNARN6S.js +4 -0
- package/dist/chunk-7Y3KVZJF.js +8 -0
- package/dist/{chunk-WIO6L24E.js → chunk-ADL3CK44.js} +1 -1
- package/dist/chunk-AO2ZI42U.js +4 -0
- package/dist/chunk-BDN32Y2N.js +81 -0
- package/dist/chunk-D4RST2HE.js +1 -0
- package/dist/{chunk-6HJJHEL6.js → chunk-DIZSHNZ5.js} +1 -1
- package/dist/chunk-DOIZANFA.js +2 -0
- package/dist/{chunk-HY3RMPW5.js → chunk-E53BGUOW.js} +1 -1
- package/dist/{chunk-FZCYTRBQ.js → chunk-ESWFBSYM.js} +1 -1
- package/dist/chunk-GBMCHFOV.js +1 -0
- package/dist/{chunk-HUPLAFZQ.js → chunk-HASVV34S.js} +1 -1
- package/dist/chunk-IZLEMTES.js +1 -0
- package/dist/chunk-KR7CIEQR.js +1 -0
- package/dist/chunk-KS4FB5W7.js +6 -0
- package/dist/chunk-LYVDRRDO.js +2 -0
- package/dist/{chunk-IBPPMOHM.js → chunk-NHTLE3WN.js} +1 -1
- package/dist/chunk-NS53IPAC.js +1 -0
- package/dist/{chunk-YTLUT6IA.js → chunk-OX53L237.js} +2 -2
- package/dist/chunk-PKIRVQLG.js +1 -0
- package/dist/chunk-QAF26ZQX.js +36 -0
- package/dist/{chunk-NWQ5VWUW.js → chunk-QFCKHUEP.js} +1 -1
- package/dist/chunk-QRWWYL52.js +88 -0
- package/dist/chunk-QTCZPS5I.js +1 -0
- package/dist/{chunk-WSAFBPS5.js → chunk-SV2SP22H.js} +4 -4
- package/dist/chunk-T5YRFRJV.js +1 -0
- package/dist/chunk-UQEQ6CXU.js +1 -0
- package/dist/chunk-V5EYVQ63.js +1 -0
- package/dist/chunk-VGJVIHHR.js +1 -0
- package/dist/{chunk-MRFN5ZQP.js → chunk-W5ZFXKSL.js} +1 -1
- package/dist/chunk-WLCBXCZV.js +5 -0
- package/dist/chunk-WOTTSPSF.js +2 -0
- package/dist/chunk-X7FYEKLI.js +1 -0
- package/dist/chunk-XH7PDHBF.js +1 -0
- package/dist/{chunk-KFKZOPZC.js → chunk-XMTLKDPP.js} +1 -1
- package/dist/chunk-YJTEMJFV.js +3 -0
- package/dist/chunk-YM77FQB3.js +8 -0
- package/dist/chunk-ZCPT6KC3.js +6 -0
- package/dist/chunk-ZPA6ECBJ.js +7 -0
- package/dist/{create-3NSOY7CA.js → create-DLUWG46F.js} +1 -1
- package/dist/doctor-IZ4YOCYE.js +1 -0
- package/dist/index.d.ts +15 -0
- package/dist/index.js +168 -168
- package/dist/pipeline-IBQYDLFF.js +5 -0
- package/dist/{project-intelligence-lens-ZOAWXYC5.js → project-intelligence-lens-SIU7IXKG.js} +1 -1
- package/dist/project-test-coverage-FRMVYTFB.js +1 -0
- package/dist/verified-goal-M4GPOXNL.js +1 -0
- package/dist/{workspace-C4UETGY7.js → workspace-3AAOUELG.js} +1 -1
- package/dist/{workspace-agent-sync-446AXPHJ.js → workspace-agent-sync-QGYLY7HH.js} +1 -1
- package/dist/{workspace-archive-VHUPOBAV.js → workspace-archive-BA3ONVXX.js} +1 -1
- package/dist/{workspace-context-XSECHC7O.js → workspace-context-JCLPRYNC.js} +1 -1
- package/dist/workspace-contract-IUUPBQXU.js +1 -0
- package/dist/workspace-explain-CZGBVDE6.js +1 -0
- package/dist/workspace-explain-contract-KVQO57RC.js +1 -0
- package/dist/{workspace-feedback-WXE7NVMV.js → workspace-feedback-PCZKXG5R.js} +1 -1
- package/dist/{workspace-foundation-3EVAQ5X6.js → workspace-foundation-7IGMO4CW.js} +1 -1
- package/dist/{workspace-graph-stream-AJPS45FD.js → workspace-graph-stream-5YMLJXAJ.js} +1 -1
- package/dist/workspace-graph-token-efficiency-HK4KNWWP.js +1 -0
- package/dist/{workspace-history-YY7YRDOH.js → workspace-history-CHJOABME.js} +1 -1
- package/dist/{workspace-intelligence-FWRB47EJ.js → workspace-intelligence-XHSUFTAT.js} +1 -1
- package/dist/workspace-intelligence-evaluation-YMY3C5AW.js +1 -0
- package/dist/{workspace-intelligence-runner-SMEAB4CO.js → workspace-intelligence-runner-EN5V4KSC.js} +1 -1
- package/dist/workspace-intelligence-runtime-registry-NCVHKCMP.js +1 -0
- package/dist/workspace-knowledge-graph-VWQTIEYK.js +1 -0
- package/dist/{workspace-knowledge-graph-query-EKHIE3E2.js → workspace-knowledge-graph-query-TXA3KVUV.js} +1 -1
- package/dist/workspace-knowledge-graph-snapshot-WB62AVDK.js +1 -0
- package/dist/workspace-mcp-serve-NCAGGWQS.js +3 -0
- package/dist/{workspace-model-MNJOGBPP.js → workspace-model-NXFIKX26.js} +1 -1
- package/dist/{workspace-onboarding-5KO7Z7AD.js → workspace-onboarding-OP22NHQ4.js} +1 -1
- package/dist/{workspace-readme-4S6PJ74A.js → workspace-readme-IVJXSIBS.js} +1 -1
- package/dist/{workspace-registry-summary-GPJEL7K7.js → workspace-registry-summary-A5VDPRHU.js} +1 -1
- package/dist/workspace-repair-engine-N4KXNSVL.js +3 -0
- package/dist/workspace-run-PXKC3ELS.js +1 -0
- package/dist/{workspace-verify-C6HWHRLJ.js → workspace-verify-TUVLFPPN.js} +1 -1
- package/dist/{workspace-watch-DLPHLF5R.js → workspace-watch-2ZNOYSUQ.js} +1 -1
- package/docs/commands-reference.md +35 -6
- package/docs/contracts/ARTIFACT_CATALOG.md +6 -1
- package/docs/contracts/README.md +5 -0
- package/docs/doctor-command.md +158 -7
- package/docs/graph-benchmark-methodology.md +13 -0
- package/docs/workspace-intelligence-runner.md +4 -0
- package/docs/workspace-knowledge-graph.md +53 -4
- package/docs/workspace-run.md +14 -3
- package/package.json +10 -3
- package/dist/analyze-AAZEJ4FC.js +0 -1
- package/dist/autopilot-release-3H5FTF6H.js +0 -1
- package/dist/chunk-2PY65U6X.js +0 -5
- package/dist/chunk-3DONU3DU.js +0 -1
- package/dist/chunk-44VJHNZB.js +0 -1
- package/dist/chunk-5XDPQ3CB.js +0 -1
- package/dist/chunk-7AR5PDLD.js +0 -1
- package/dist/chunk-7KKP7RNB.js +0 -3
- package/dist/chunk-7S4QNH5A.js +0 -5
- package/dist/chunk-7T4TSV5C.js +0 -1
- package/dist/chunk-BYVTHIC3.js +0 -2
- package/dist/chunk-CEIJIFY7.js +0 -88
- package/dist/chunk-D37NEYV6.js +0 -1
- package/dist/chunk-DPMO4U3Z.js +0 -8
- package/dist/chunk-DS4UYMLX.js +0 -1
- package/dist/chunk-FQLB4BIC.js +0 -7
- package/dist/chunk-GDU7VP6G.js +0 -1
- package/dist/chunk-H7P7SSUW.js +0 -75
- package/dist/chunk-KVUYAYTY.js +0 -8
- package/dist/chunk-MQ73VS4E.js +0 -2
- package/dist/chunk-NYHVCFBT.js +0 -1
- package/dist/chunk-OUBBBC7T.js +0 -36
- package/dist/chunk-P7K5RHJC.js +0 -2
- package/dist/chunk-PS5F4DCT.js +0 -1
- package/dist/chunk-QZ7PNMVP.js +0 -1
- package/dist/chunk-RA24WQLF.js +0 -1
- package/dist/chunk-RMXXK64P.js +0 -4
- package/dist/chunk-S7Z4DP3P.js +0 -2
- package/dist/chunk-SJLUE6AY.js +0 -1
- package/dist/chunk-TEHQ7XKK.js +0 -3
- package/dist/chunk-UFOCUHG3.js +0 -1
- package/dist/chunk-WD2XDMGB.js +0 -1
- package/dist/chunk-XVRJVKOX.js +0 -1
- package/dist/doctor-UEFFNAUD.js +0 -1
- package/dist/pipeline-B5S6P36F.js +0 -5
- package/dist/project-test-coverage-44ZPCOPV.js +0 -1
- package/dist/verified-goal-KOU3WJYN.js +0 -1
- package/dist/workspace-contract-AYFTZIKM.js +0 -1
- package/dist/workspace-explain-ZEWVKDBF.js +0 -1
- package/dist/workspace-explain-contract-6CCC26QT.js +0 -1
- package/dist/workspace-graph-token-efficiency-5FNH4JZ5.js +0 -1
- package/dist/workspace-intelligence-evaluation-UP2K3L35.js +0 -1
- package/dist/workspace-intelligence-runtime-registry-MRSF7RTT.js +0 -1
- package/dist/workspace-knowledge-graph-BMMM2FUE.js +0 -1
- package/dist/workspace-mcp-serve-X6C3AWTA.js +0 -3
- package/dist/workspace-repair-engine-GWTXVVKB.js +0 -3
- package/dist/workspace-run-FJTBX4JQ.js +0 -1
package/dist/chunk-RA24WQLF.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import {a,l as l$1,e,b,c}from'./chunk-44VJHNZB.js';var l="workspai-workspace-intelligence-chain-v1",u="contracts/workspace-intelligence-chain.v1.json";function f(){let e$1=a,t=l$1,n=[{id:"model",ordinal:1,phase:"understand",label:"Model",command:[...t.model.command],consumes:["workspace markers","project metadata","registry","contract","policies"],inputRefs:["projects-repositories","runtime-dependencies","workspace-rules","existing-evidence"],consumesArtifacts:[],produces:[...t.model.produces],dependsOn:[],exitPolicy:"stop-on-error",purpose:"Build the canonical current model and its structurally bound, derived Knowledge Graph."},{id:"diff",ordinal:2,phase:"change",label:"Diff",command:[...t.diff.command],consumes:[e$1.model,e$1.snapshot],inputRefs:["changes","model-baseline"],consumesArtifacts:[e$1.model,e$1.snapshot],produces:[...t.diff.produces],dependsOn:["model"],exitPolicy:"stop-on-error",purpose:"Describe structural change against the selected baseline."},{id:"impact",ordinal:3,phase:"change",label:"Impact",command:[...t.impact.command],consumes:[e$1.model,e$1.diff],inputRefs:[],consumesArtifacts:[e$1.model,e$1.diff],produces:[...t.impact.produces],dependsOn:["diff"],exitPolicy:"stop-on-error",purpose:"Calculate transitive blast radius over the workspace graph."},{id:"doctor-evidence",ordinal:4,phase:"evidence",label:"Doctor Evidence",command:[...t["doctor-evidence"].command],consumes:["workspace runtime and project health signals"],inputRefs:["projects-repositories","runtime-dependencies","existing-evidence"],consumesArtifacts:[],produces:[...t["doctor-evidence"].produces],dependsOn:["impact"],exitPolicy:"continue-on-structured-verdict",purpose:"Refresh health evidence after the impact artifact exists."},{id:"contract-evidence",ordinal:5,phase:"evidence",label:"Contract Evidence",command:[...t["contract-evidence"].command],consumes:[e.workspaceContract],inputRefs:["workspace-rules"],consumesArtifacts:[],produces:[...t["contract-evidence"].produces],dependsOn:["impact"],exitPolicy:"continue-on-structured-verdict",purpose:"Refresh structural contract evidence without hiding failed verdicts."},{id:"analyze-evidence",ordinal:6,phase:"evidence",label:"Analyze Evidence",command:[...t["analyze-evidence"].command],consumes:[e$1.model,"workspace runtime and dependency signals"],inputRefs:["projects-repositories","runtime-dependencies","workspace-rules"],consumesArtifacts:[e$1.model],produces:[...t["analyze-evidence"].produces],dependsOn:["impact"],exitPolicy:"continue-on-structured-verdict",purpose:"Refresh analysis evidence required by the release-readiness gate."},{id:"readiness-evidence",ordinal:7,phase:"evidence",label:"Readiness Evidence",command:[...t["readiness-evidence"].command],consumes:["doctor, analysis, runtime, and release signals"],inputRefs:["runtime-dependencies","existing-evidence"],consumesArtifacts:[e$1.doctor,e$1.contractVerify,e$1.analyze],produces:[...t["readiness-evidence"].produces],dependsOn:["doctor-evidence","contract-evidence","analyze-evidence"],exitPolicy:"continue-on-structured-verdict",purpose:"Refresh release-readiness evidence before the definitive gate."},{id:"verify",ordinal:8,phase:"gate",label:"Verify",command:[...t.verify.command],consumes:[e$1.impact,e$1.doctor,e$1.contractVerify,e$1.readiness],inputRefs:[],consumesArtifacts:[e$1.impact,e$1.doctor,e$1.contractVerify,e$1.readiness],produces:[...t.verify.produces],dependsOn:["impact","doctor-evidence","contract-evidence","analyze-evidence","readiness-evidence"],exitPolicy:"continue-on-structured-verdict",purpose:"Emit the definitive evidence-backed workspace gate."},{id:"context",ordinal:9,phase:"ground",label:"Agent Context",command:[...t.context.command],consumes:[e$1.model,e$1.impact,e$1.verify],inputRefs:[],consumesArtifacts:[e$1.model,e$1.impact,e$1.verify],produces:[...t.context.produces],dependsOn:["verify"],exitPolicy:"stop-on-error",purpose:"Build compact agent context from the same verified evidence."},{id:"agent-sync",ordinal:10,phase:"distribute",label:"Agent Grounding",command:[...t["agent-sync"].command],consumerArgs:{vscode:["--target","vscode"]},consumes:[e$1.agentContext],inputRefs:[],consumesArtifacts:[e$1.agentContext],produces:[...t["agent-sync"].produces],dependsOn:["context"],exitPolicy:"stop-on-error",purpose:"Distribute one context into portable agent and IDE surfaces."},{id:"explain",ordinal:11,phase:"explain",label:"Explain",command:[...t.explain.command],consumes:[e$1.verify,e$1.impact],inputRefs:[],consumesArtifacts:[e$1.verify,e$1.impact],produces:[...t.explain.produces],dependsOn:["verify"],exitPolicy:"continue-on-structured-verdict",purpose:"Translate evidence and blockers into a human and agent-readable narrative."}];return {schemaVersion:l,name:"Workspace Intelligence Chain",contractPath:u,invariant:"Every consumer must preserve step identity, dependencies, artifact flow, and verdict semantics; presentation may change, chain meaning may not.",invariants:["Missing or unreadable input is unknown or unavailable; it must not be presented as verified absence.","Freshness and provenance travel with evidence and must not be discarded by projections.","The current graph is an evidence-backed workspace knowledge graph with bounded source intelligence, not a complete cross-language symbol or call graph.","Simple and standard presentations summarize the contract; their contractRefs must preserve complete traceability.","Conditional provider outputs must be resolved through their dedicated inventory contract.","Auxiliary capabilities expose or refresh intelligence but are not mandatory execution-chain steps.","Canonical step commands are stage-pure: they must not implicitly execute a downstream chain step or regenerate an upstream artifact.","Canonical JSON artifacts must satisfy their registered schema both when produced and when consumed across CLI, MCP, IDE, and CI trust boundaries.","Schema validity is necessary but not sufficient: hashes, embedded models, summaries, counts, graph statistics, and artifact references must remain semantically coherent.","Persisted impact evidence must be rejected as stale when the current workspace model or Git observation no longer matches its embedded diff.","Canonical artifact replacement must be atomic and workspace-contained; an interrupted or denied write must preserve the last valid artifact.","Concurrent history updates must be serialized without silently dropping entries, and invalid history must never be overwritten as if it were absent.","The canonical global registry is ~/.workspai/workspaces.json; ~/.rapidkit/workspaces.json is a non-authoritative compatibility mirror for legacy consumers and must not diverge after a CLI registry mutation."],semantics:{workspace:"The governed operating boundary that relates one or more projects and repositories to shared metadata, policies, contracts, evidence, and consumers.",repository:"A source-control boundary that may contain one or more projects and may live inside or outside the workspace root.",project:"A discoverable build or runtime unit with its own path, metadata or observable manifests, command capabilities, and evidence.",evidence:"A sourced observation or generated verification result with provenance and freshness; evidence may be consumed by a later run.",artifact:"A durable generated file that another command or consumer can read without parsing terminal prose.",gate:"A structured verdict with reasons and exit semantics derived from current evidence."},workspaceLifecycle:{ingestionRoutes:[{id:"create",label:"Create",commands:["create workspace","create project"],result:"Create a workspace or supported project and write canonical Workspai metadata."},{id:"adopt",label:"Adopt",commands:["adopt"],result:"Register an existing project in place without requiring source relocation."},{id:"import",label:"Import",commands:["import","workspace import"],result:"Attach an existing project or repository path to the workspace inventory."}],durableState:[{id:"workspace-identity",paths:[".workspai-workspace",".workspai/workspace.json"],purpose:"Identify the workspace boundary, profile, and canonical root."},{id:"project-inventory",paths:[".workspai/project.json",".workspai/context.json",".workspai/adopt.json","~/.workspai/workspaces.json","~/.rapidkit/workspaces.json (legacy compatibility mirror)"],purpose:"Record native, adopted, imported, and globally registered project locations while preserving a non-authoritative mirror for legacy extension discovery."},{id:"governance",paths:[".workspai/policies.yml",e.workspaceContract],purpose:"Define workspace policy and explicit structural relationships."},{id:"graph-overrides",paths:[".workspai/workspace-graph.overrides.json"],purpose:"Provide explicit dependency edges that override inferred relationships."}],rule:"Create, adopt, and import are ingestion routes, not intelligence facts. Their durable state becomes observable input to Model."},runtimeRegistry:{authority:"contracts/workspace-intelligence-runtime-registry.ts",artifacts:Object.entries(a).map(([r,s])=>({id:r,path:s,schemaVersion:b[r],schemaContract:c[r]}))},executionEnvelope:{rule:"Sync and baseline resolution are deterministic execution prerequisites, not canonical intelligence stages; every run reports them separately and preserves the exact canonical stage sequence.",operations:[{id:"sync",executionPoint:"before:model",artifacts:[e.workspaceContract,e.workspaceRegistry],failurePolicy:"stop-and-report",purpose:"Reconcile portable workspace inventory and contract inputs before modeling."},{id:"baseline",executionPoint:"after:model-before:diff",artifacts:[e$1.snapshot],failurePolicy:"stop-and-report",purpose:"Create an initial structural baseline when absent or reuse the existing baseline before Diff."}],report:{artifact:e$1.intelligenceRun,schemaVersion:b.intelligenceRun,invariant:"The report must preserve exact preflight and stage order, registry-owned artifacts, failure propagation, and aggregate status/exit semantics."}},boundaries:{inputs:[{id:"projects-repositories",label:"Projects and repositories",sources:["projects","repositories","services","modules","imported paths"],entersAt:"model"},{id:"runtime-dependencies",label:"Runtime and dependencies",sources:["runtime manifests","lockfiles","scripts","framework markers","package dependencies","bounded multi-language source observations for supported file extensions"],entersAt:"model"},{id:"workspace-rules",label:"Workspace rules",sources:["workspace markers","registry","project metadata","contracts","policies","ownership","graph overrides"],entersAt:"model"},{id:"changes",label:"Changes",sources:["repository state","git state","model baseline","workspace diff"],entersAt:"diff"},{id:"model-baseline",label:"Explicit model baseline",sources:[e$1.snapshot],entersAt:"diff"},{id:"existing-evidence",label:"Existing evidence",sources:["doctor reports","analysis reports","contract verification","release readiness","pipeline results","tests and runtime evidence","previous intelligence artifacts"],entersAt:"doctor-evidence"}],outputs:[{id:"understanding",label:"System understanding",artifacts:[e$1.model,e$1.knowledgeGraph,e$1.diff,e$1.impact],producedBy:["model","diff","impact"],inventory:"complete-for-chain"},{id:"governance-evidence",label:"Governance evidence",artifacts:[e$1.doctor,e$1.contractVerify,e$1.analyze,e$1.readiness,e$1.verify,e$1.history],producedBy:["doctor-evidence","contract-evidence","analyze-evidence","readiness-evidence","verify"],inventory:"complete-for-chain"},{id:"agent-grounding",label:"Agent grounding",artifacts:[e$1.agentContext,e$1.agentIndex,e$1.agentCustomizationPack,e$1.skillsIndex,e$1.agents],producedBy:["context","agent-sync"],inventory:"canonical-minimum",inventoryContract:"contracts/agent-customization-pack.v1.json"},{id:"explanations",label:"Explainable decisions",artifacts:[e$1.explain],producedBy:["explain"],inventory:"complete-for-chain"}],consumers:[{id:"developers",label:"Developers",channels:["CLI","reports","AGENTS.md"]},{id:"ci",label:"CI",channels:["JSON artifacts","exit codes","release gates"]},{id:"ides",label:"IDEs",channels:["synced contracts","extension","agent context"]},{id:"ai-agents",label:"AI agents",channels:["INDEX.json","context","skills","MCP"]}]},deliveryChannels:[{id:"artifacts",carries:["reports","models","context","grounding","skills"],authority:"canonical"},{id:"json-stdout",carries:["structured command results"],authority:"projection"},{id:"human-cli",carries:["summaries","diagnostics","next actions"],authority:"projection"},{id:"exit-codes",carries:["gate and command status"],authority:"projection"},{id:"watch-events",carries:["incremental workspace change events"],authority:"projection"},{id:"mcp",carries:["read-mostly access to current workspace artifacts"],authority:"projection"}],feedback:{from:["developers","ci","ides","ai-agents"],signals:["source commits","dependency updates","policy and contract edits","repairs","test and runtime results","agent action outcomes"],reentersThrough:["projects-repositories","runtime-dependencies","workspace-rules","changes","existing-evidence"],rule:"Consumer actions are not silently treated as truth. They re-enter as observable changes or evidence and must be modeled and verified again."},auxiliaryCapabilities:[{id:"graph",commands:["workspace graph emit","workspace graph explain","workspace graph entities","workspace graph evidence","workspace graph path","workspace graph search","workspace graph benchmark","workspace graph overlay","workspace graph dot","workspace graph mermaid","workspace graph jsonld","workspace graph graphml","workspace graph gexf"],reads:[e$1.model,e$1.knowledgeGraph],role:"Query the proof-backed graph derived from the canonical workspace model.",chainStep:false},{id:"evaluation",commands:["workspace eval init","workspace eval record","workspace eval status","workspace eval report","workspace eval compare"],reads:[e$1.evaluationLive,e$1.evaluationLastRun],produces:[e$1.evaluationLive,e$1.evaluationLastRun],role:"Measure model usage, activity, cost provenance, and verified outcomes without storing prompt or response bodies.",chainStep:false},{id:"watch",commands:["workspace watch"],reads:["workspace inputs",e$1.model],role:"Refresh the model incrementally and emit deterministic change events.",chainStep:false},{id:"mcp",commands:["workspace mcp serve"],reads:["workspace evidence artifacts"],role:"Expose read-mostly workspace evidence to compatible clients.",chainStep:false}],presentations:{simple:{layers:["inputs","intelligence","outputs","consumers"],nodes:[{id:"input-layer",kind:"inputs",label:"Input Layer",summary:"Projects \xB7 Repositories \xB7 Dependencies \xB7 Changes",contractRefs:["projects-repositories","runtime-dependencies","workspace-rules","changes","model-baseline","existing-evidence"]},{id:"workspace-intelligence",kind:"intelligence",label:"Workspace Intelligence",summary:"Model \xB7 Graph \xB7 Impact \xB7 Verify",contractRefs:n.map(r=>r.id)},{id:"agent-grounding",kind:"outputs",label:"Agent Grounding",summary:"AGENTS.md \xB7 Skills \xB7 Context",contractRefs:["agent-grounding"]},{id:"evidence-and-decisions",kind:"outputs",label:"Evidence Contracts",summary:"Reports \xB7 Artifacts \xB7 Gates",contractRefs:["understanding","governance-evidence","explanations"]},{id:"shared-consumers",kind:"consumers",label:"Shared Consumers",summary:"Developers \xB7 CI \xB7 IDEs \xB7 AI agents",contractRefs:["developers","ci","ides","ai-agents"]}],rule:"Use concrete user-facing language for first-contact explanations. Every input, output, consumer, and chain step must remain traceable through contractRefs even when details are summarized."},standard:{phases:["understand","change","evidence","gate","ground","distribute","explain"],nodes:[{id:"understand",label:"Understand",question:"What exists in the current workspace?",stepRefs:["model"]},{id:"change",label:"Change",question:"What changed, and what can it affect?",stepRefs:["diff","impact"]},{id:"evidence",label:"Evidence",question:"What health, contract, and readiness facts were observed?",stepRefs:["doctor-evidence","contract-evidence","analyze-evidence","readiness-evidence"]},{id:"gate",label:"Gate",question:"Is the current state acceptable and trustworthy?",stepRefs:["verify"]},{id:"ground",label:"Ground",question:"What should an agent know before acting?",stepRefs:["context"]},{id:"distribute",label:"Distribute",question:"Which durable agent and IDE surfaces receive that context?",stepRefs:["agent-sync"]},{id:"explain",label:"Explain",question:"Why did the system reach this result or verdict?",stepRefs:["explain"]}],rule:"Use for architecture education and product surfaces. Every phase must appear once and in order."},advanced:{steps:n.map(r=>r.id),requiredFields:["command","inputRefs","consumesArtifacts","produces","dependsOn","exitPolicy","purpose"],rule:"Use for implementers, adapters, IDEs, and CI. Preserve every step and its artifact and verdict semantics."}},steps:n,diagram:{direction:"TB",nodes:n.map(({id:r,label:s,phase:p})=>({id:r,label:s,phase:p})),edges:n.flatMap(r=>r.dependsOn.map(s=>({from:s,to:r.id,meaning:"required before"})))},consumers:{agents:{canonicalReadOrder:[e$1.agentIndex,e$1.agentContext,e$1.verify,e$1.impact,e$1.explain,e$1.model,e$1.knowledgeGraph,e$1.agentCustomizationPack,e$1.skillsIndex],entrypoints:[e$1.agents,".workspai/AGENT-GROUNDING.md"],rule:"Agents must cite current artifacts, preserve verified versus inferred status, and re-run the producing step when evidence is missing or stale."},ideAndCi:{requiredArtifacts:[e$1.model,e$1.knowledgeGraph,e$1.impact,e$1.verify],rule:"IDEs and CI must consume structured artifacts and verdict exit semantics rather than parse human help or terminal prose."},docsAndDiagrams:{rule:"Documentation and diagrams must derive labels, ordering, and edges from this contract and must not invent implemented steps."}}}}export{l as a,f as b};
|
package/dist/chunk-RMXXK64P.js
DELETED
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import {f,e}from'./chunk-T3GJ7YVG.js';import {a,b}from'./chunk-MRFN5ZQP.js';import {c}from'./chunk-QZ7PNMVP.js';import {i,j as j$1,l as l$1,k,n}from'./chunk-6HJJHEL6.js';import {a as a$2,e as e$1}from'./chunk-WIO6L24E.js';import {b as b$2}from'./chunk-BYVTHIC3.js';import {b as b$1,a as a$1}from'./chunk-44VJHNZB.js';import {s}from'./chunk-MOSXTVPU.js';import u from'chalk';import l from'fs';import y from'path';var M=a$1.readiness,T=b$1.readiness;function H(t,e){let a=y.resolve(t);if(!b(a))return a;let n=_(e,"workspace.contract.json");if(l.existsSync(n))try{let o=JSON.parse(l.readFileSync(n,"utf-8")),s=Array.isArray(o.projects)?o.projects:[];for(let i of s){let d=g(i),p=typeof d.relativePath=="string"?d.relativePath.trim():"";if(p)return y.join(e,p)}}catch{}let r=J(e),c=Array.isArray(r.payload?.projects)?r.payload.projects:[];for(let o of c){let s=g(o),i=typeof s.path=="string"?s.path.trim():"";if(i)return y.resolve(i)}return a}function L(t){let e=i(t);return j$1(e,t)?"go":l$1(e,t)?"java":k(e,t)?"node":n(e,t)?"python":"unknown"}function z(t,e){if(!l.existsSync(t))return null;let a=l.readdirSync(t).filter(n=>n.endsWith(".json")&&e.some(r=>r.test(n))).map(n=>y.join(t,n));return a.length===0?null:(a.sort((n,r)=>l.statSync(r).mtimeMs-l.statSync(n).mtimeMs),a[0])}function g(t){return t&&typeof t=="object"&&!Array.isArray(t)?t:{}}function D(t){for(let e of t)if(l.existsSync(e))return e;return null}function _(t,...e){let a=s(t,...e);return D(a)??a[0]}function j(t,e){let a=a$2(t,`.workspai/reports/${e}`);return D([a,y.join(t,".rapidkit","reports",e)])??a}async function K(t){let{readWorkspaceRegistrySummary:e,resolveWorkspaceRegisteredProjects:a}=await import('./workspace-registry-summary-GPJEL7K7.js'),n=await e(t);return n?n.projectCount:(await a(t)).summary.projectCount}function q(t,e,a){let n=_(t,"toolchain.lock");if(!l.existsSync(n))return {gate:"env",status:"fail",summary:"toolchain.lock is missing",details:["Run workspai bootstrap to pin runtime versions and generate a reproducible toolchain."],evidencePath:n};try{let r=JSON.parse(l.readFileSync(n,"utf-8")),c=g(r.runtime),s=["python","node","go","java"].filter(p=>{let f=g(c[p]);return typeof f.version=="string"&&f.version.trim().length>0});if(s.length===0)return {gate:"env",status:"fail",summary:"No runtime versions are pinned in toolchain.lock",details:["Pin at least one runtime version via workspai setup <runtime> and re-run bootstrap."],evidencePath:n};let d=[...new Set((Array.isArray(e)?e:[e]).filter(p=>p!=="unknown"))].filter(p=>{let f=g(c[p]);return typeof f.version!="string"||f.version.trim().length===0});return d.length>0?{gate:"env",status:"fail",summary:`${a?.hasRegisteredProjects?"Project runtime":"Workspace"}${d.length===1?"":"s"} (${d.join(", ")}) ${d.length===1?"is":"are"} not pinned in toolchain.lock`,details:d.map(f=>`Run workspai setup ${f} and workspai bootstrap to lock ${f} for this workspace.`),evidencePath:n}:{gate:"env",status:"pass",summary:`Pinned runtimes: ${s.join(", ")}`,details:[],evidencePath:n}}catch{return {gate:"env",status:"fail",summary:"toolchain.lock is invalid JSON",details:["Regenerate lockfile with workspai bootstrap."],evidencePath:n}}}function J(t){let e=j(t,"doctor-last-run.json");if(!l.existsSync(e))return {payload:null,path:e};try{let a=JSON.parse(l.readFileSync(e,"utf-8"));return c(a,"workspace")?{payload:a,path:e}:{payload:null,path:e}}catch{return {payload:null,path:e}}}function B(t){let e=J(t);if(!e.payload)return {gate:{gate:"doctor",status:"fail",summary:"Doctor evidence is missing",details:["Run workspai doctor workspace --json before release readiness checks."],evidencePath:e.path},payload:null};let a=g(e.payload.summary),n=Number(a.totalIssues??0);return a.hasSystemErrors?{gate:{gate:"doctor",status:"fail",summary:"Doctor reported system errors",details:["Resolve system-level doctor errors before proceeding."],evidencePath:e.path},payload:e.payload}:n>0?{gate:{gate:"doctor",status:"warn",summary:`Doctor found ${n} issue(s)`,details:["Run workspai doctor workspace --fix and re-run readiness checks."],evidencePath:e.path},payload:e.payload}:{gate:{gate:"doctor",status:"pass",summary:"Doctor checks passed without issues",details:[],evidencePath:e.path},payload:e.payload}}function U(t){let e=j(t,"analyze-last-run.json");if(!l.existsSync(e))return {gate:"analyze",status:"fail",summary:"Analyze evidence is missing",details:["Run workspai analyze --json before release readiness checks."],evidencePath:e};try{let a=JSON.parse(l.readFileSync(e,"utf-8"));b$2(a$1.analyze,a,e);let n=g(a.summary),r=String(n.verdict??"").toLowerCase(),c=Number(n.score??0),o=g(n.findings),s=Number(o.fail??0);return r==="blocked"||s>0?{gate:"analyze",status:"fail",summary:`Analyze verdict is blocked (score ${c}/100)`,details:["Resolve analyze findings and regenerate analyze-last-run.json."],evidencePath:e}:r==="needs-attention"?{gate:"analyze",status:"warn",summary:`Analyze needs attention (score ${c}/100)`,details:["Review analyze warnings before release."],evidencePath:e}:{gate:"analyze",status:"pass",summary:`Analyze passed (score ${c}/100)`,details:[],evidencePath:e}}catch{return {gate:"analyze",status:"fail",summary:"Analyze evidence is invalid or violates its contract",details:["Re-run workspai analyze --json to regenerate evidence."],evidencePath:e}}}function Q(t){try{let e=JSON.parse(l.readFileSync(t,"utf-8")),a=String(e.status??"").toLowerCase(),n=g(e.summary),r=Number(n.failedChecks??0);return a==="fail"||r>0?{gate:"verify",status:"fail",summary:"Verify-pack contract reports failed checks",details:["Fix failed verify checks and regenerate verify-pack contract evidence."],evidencePath:t}:a==="pass"?{gate:"verify",status:"pass",summary:"Verify-pack contract passed",details:[],evidencePath:t}:{gate:"verify",status:"warn",summary:"Verify-pack contract status is not explicit",details:["Ensure contract status is pass/fail and keep schema aligned with v1 contract."],evidencePath:t}}catch{return {gate:"verify",status:"fail",summary:"Verify-pack contract is invalid JSON",details:["Regenerate verify-pack contract artifact."],evidencePath:t}}}async function X(t,e){if(e.skipVerify)return {gate:"verify",status:"pass",summary:"Verify gate skipped (--skip-verify)",details:["Verification was explicitly skipped for this readiness run."]};let a=[a$2(t,".workspai/reports"),y.join(t,".rapidkit","reports")],n=a[0],r=a.map(s=>z(s,[/verify-pack-contract/i,/^verify.*\.json$/i])).find(s=>typeof s=="string")??null;if(r)return Q(r);let c=a$2(t,a$1.contractVerify),o=a.map(s=>z(s,[/workspace-contract-verify-last-run/i,/workspace-contract-verify/i])).find(s=>typeof s=="string")??null;if(o)try{let s=JSON.parse(l.readFileSync(o,"utf-8")),i=String(s.status??"").toLowerCase();if(i==="passed"||i==="pass")return {gate:"verify",status:"pass",summary:"Workspace contract verification passed (CLI cache)",details:[],evidencePath:o};if(i==="failed"||i==="fail")return {gate:"verify",status:"fail",summary:"Workspace contract verification failed (CLI cache)",details:(Array.isArray(s.violations)?s.violations:[]).slice(0,5),evidencePath:o}}catch{}try{let{verifyWorkspaceContract:s}=await import('./workspace-contract-AYFTZIKM.js'),i=await s({workspacePath:t}),d={schemaVersion:"v1",source:"cli",generatedAt:new Date().toISOString(),status:i.status,contractPath:i.contractPath,projectCount:i.projectCount,checks:i.checks,violations:i.violations};return await e$1(t,a$1.contractVerify,d),i.status==="failed"?{gate:"verify",status:"fail",summary:"Workspace contract verification failed (CLI)",details:i.violations.slice(0,5),evidencePath:c}:{gate:"verify",status:"pass",summary:"Workspace contract verification passed (CLI)",details:[],evidencePath:c}}catch(s){return {gate:"verify",status:"fail",summary:"No verify evidence and workspace contract verification unavailable",details:["Run workspai workspace contract verify --json or export verify-pack contract from CI.",s instanceof Error?s.message:String(s)],evidencePath:y.join(n,"*verify*.json")}}}function Y(t,e){let a=j(e,"doctor-last-run.json");if(!t)return {gate:"dependency",status:"warn",summary:"Dependency risk check skipped (doctor evidence missing)",details:["Run workspai doctor workspace --json to include dependency findings."],evidencePath:a};let n=Array.isArray(t.projects)?t.projects:[],r=n.reduce((o,s)=>{let i=Number(s.vulnerabilities??0);return Number.isFinite(i)?o+Math.max(0,i):o},0),c=n.filter(o=>o.depsInstalled===false).length;return r>0?{gate:"dependency",status:"fail",summary:`${r} dependency vulnerability(ies) reported`,details:["Resolve vulnerabilities (npm/pip/go audit pipelines) before release."],evidencePath:a}:c>0?{gate:"dependency",status:"warn",summary:`${c} project(s) report missing dependencies`,details:["Run project init/bootstrap and regenerate doctor evidence."],evidencePath:a}:{gate:"dependency",status:"pass",summary:"No dependency vulnerabilities reported",details:[],evidencePath:a}}function Z(t){return t.some(e=>e.status==="fail")?"fail":t.some(e=>e.status==="warn")?"warn":"pass"}async function ee(t,e){return e$1(t,M,e)}async function te(t={}){let e$1=y.resolve(t.startPath??process.cwd()),a$1=a(e$1)??e$1,n=await K(a$1)>0,r=n&&b(e$1)?a$1:H(e$1,a$1),c=r===a$1?"unknown":L(r),o=n?c:"unknown";if(n&&r===a$1){let{resolveWorkspaceRegisteredProjects:m}=await import('./workspace-registry-summary-GPJEL7K7.js');o=(await m(a$1)).summary.projects.map(F=>L(y.resolve(a$1,F.relativePath)));}let s=q(a$1,o,{hasRegisteredProjects:n}),i=B(a$1),d=U(a$1),p=await X(a$1,{skipVerify:t.skipVerify}),f$1=Y(i.payload,a$1),w=[s,i.gate,d,p,f$1],k=Z(w),v={schemaVersion:T,generatedAt:new Date().toISOString(),workspacePath:a$1,projectPath:r,action:t.action,overallStatus:k,blocking:k==="fail",blockingReasons:w.filter(m=>m.status==="fail").map(m=>`${m.gate}: ${m.summary}`),gates:w};if(t.writeReport!==false){let m=f(v,{commandId:"workspaceReadiness",exitCode:k==="fail"?2:k==="warn"?1:0,generatedAt:v.generatedAt,blockers:v.blockingReasons,runId:e()});v.evidencePath=await ee(a$1,m);}return v}function ae(t){return t==="pass"?u.green("PASS"):t==="warn"?u.yellow("WARN"):u.red("FAIL")}function ne(t){return t==="pass"?u.green("PASS"):t==="warn"?u.yellow("WARN"):u.red("FAIL")}async function he(t){let e=await te({startPath:t.workspace,writeReport:true,skipVerify:t.skipVerify===true});if(t.json)console.log(JSON.stringify(e,null,2));else {console.log(u.bold.cyan(`
|
|
2
|
-
\u{1F6A6} Workspai Release Readiness
|
|
3
|
-
`)),console.log(u.bold(`Workspace: ${u.cyan(y.basename(e.workspacePath))}`)),console.log(u.gray(`Path: ${e.workspacePath}`)),console.log(`Overall: ${ne(e.overallStatus)}`);for(let a of e.gates){console.log(` - ${a.gate}: ${ae(a.status)} ${a.summary}`);for(let n of a.details)console.log(u.gray(` ${n}`));a.evidencePath&&console.log(u.gray(` evidence: ${a.evidencePath}`));}e.evidencePath&&console.log(u.gray(`
|
|
4
|
-
Evidence saved: ${e.evidencePath}`));}t.strict&&e.overallStatus!=="pass"&&process.exit(1);}export{te as a,he as b};
|
package/dist/chunk-S7Z4DP3P.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import {p,k,l,j}from'./chunk-7AR5PDLD.js';import {a as a$1}from'./chunk-HTYMXMQM.js';import {c}from'./chunk-S5KTATOU.js';import {e,d,b as b$1}from'./chunk-EWZZUQBR.js';import {d as d$1}from'./chunk-MQ73VS4E.js';import {e as e$1}from'./chunk-WIO6L24E.js';import {a as a$2}from'./chunk-AFIFZTOY.js';import {b,a}from'./chunk-44VJHNZB.js';import k$1 from'path';import V from'fs-extra';import {spawnSync}from'child_process';function ue(){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,a){let r=spawnSync("git",t,{cwd:e,env:ue(),encoding:"utf8",stdio:["ignore","pipe","ignore"]});if(r.status!==0)return {ok:false,stdout:""};let c=r.stdout??"";return {ok:true,stdout:a?.preserveWhitespace?c:c.trim()}}function ge(e){let t=e.replace(/\\/g,"/").replace(/^\.\//,"");return t===".workspai/AGENT-GROUNDING.md"?true:[".workspai/reports/",".workspai/cache/",".rapidkit/reports/",".rapidkit/cache/"].some(a=>t.startsWith(a))}function ke(e){let t=[],a=[],r=[];for(let c of e.split(`
|
|
2
|
-
`)){if(!c.trim())continue;let n=c.slice(0,2),i=c.slice(3).trim();if(i&&!ge(i)){if(n==="??"){a.push(i);continue}n.includes("D")&&r.push(i),t.push(i);}}return {changedFiles:[...new Set(t)].sort(),untrackedFiles:[...new Set(a)].sort(),deletedFiles:[...new Set(r)].sort()}}function Q(e,t){let a={available:false,dirty:false,changedFiles:[],untrackedFiles:[],deletedFiles:[]},r=F(e,["rev-parse","--is-inside-work-tree"]);if(!r.ok||r.stdout!=="true")return a;let c=F(e,["rev-parse","--abbrev-ref","HEAD"]),n=F(e,["rev-parse","HEAD"]),i=F(e,["status","--porcelain=v1","--untracked-files=all"],{preserveWhitespace:true}),p=ke(i.stdout),m=p.changedFiles.length>0||p.untrackedFiles.length>0||p.deletedFiles.length>0;return {available:true,branch:c.ok?c.stdout:void 0,commit:n.ok?n.stdout:void 0,ref:t?.ref,dirty:m,changedFiles:p.changedFiles,untrackedFiles:p.untrackedFiles,deletedFiles:p.deletedFiles}}var oe=b.snapshot,L=b.diff,_=a.snapshot,ae=a.diff,he=b.impact,we=a.impact;function ye(e$1){if(e$1.model.projectTopology||!e$1.model.graph||e$1.modelHash!==e(e$1.model))return null;let t={...e$1.model,projectTopology:e$1.model.graph,graph:e$1.model.graph};return {...e$1,modelHash:d(t),model:t}}function ne(e){let t=e.trim().toLowerCase();return t==="git"||t.startsWith("git:")}function We(e){let t=e.trim();return t.toLowerCase()==="git"?"HEAD":t.toLowerCase().startsWith("git:")&&t.slice(4).trim()||"HEAD"}function se(e,t){return k$1.isAbsolute(t)?t:k$1.join(e,t)}async function be(e){let t=await V.readJson(e);if(!t||typeof t!="object"||Array.isArray(t))throw new Error(`Workspace model input is not a JSON object: ${e}`);let a=t;if(a.schemaVersion===oe){a$2(t,"contracts/workspace-intelligence/workspace-model-snapshot.v1.json",`Workspace model snapshot ${e}`);let r=a;if(!r.model||r.model.schemaVersion!==j)throw new Error(`Invalid workspace model snapshot: ${e}`);let c=d(r.model);if(r.modelHash!==c){let n=ye(r);if(!n)throw new Error(`Workspace model snapshot hash mismatch: ${e}`);return {model:n.model,hash:n.modelHash}}return {model:r.model,hash:r.modelHash}}if(a.schemaVersion===j){a$2(t,"contracts/workspace-intelligence/workspace-model.v1.json",`Workspace model ${e}`);let r=a;return {model:r,hash:d(r)}}throw a.schemaVersion===L?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. ${_}. 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(a.schemaVersion)}`)}async function ve(e){let t=await V.readJson(e);if(!t||typeof t!="object"||Array.isArray(t))throw new Error(`Workspace diff input is not a JSON object: ${e}`);let a=t;if(a.schemaVersion!==L)return null;a$2(t,"contracts/workspace-intelligence/workspace-model-diff.v1.json",`Workspace model diff ${e}`);let r=a;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!==d(r.currentModel))throw new Error(`Workspace model diff current-model hash mismatch: ${e}`);return r}async function Ye(e){let t=e.model??await p({workspacePath:e.workspacePath,includeAbsolutePaths:e.includeAbsolutePaths,includeEvidence:e.includeEvidence,observableScanDepth:e.observableScanDepth,now:e.now});return {schemaVersion:oe,generatedAt:(e.now??new Date).toISOString(),modelHash:d(t),modelRef:k,model:t}}async function Qe(e,t){return e$1(t,_,d$1(e))}function x(e){return {name:e.name,path:e.path,kind:e.kind,category:e.category,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 Me(e,t){let a=[],r=["name","profile","type"],c=["workspaceType","surfaces","runtimeFamilies","businessCapabilities"];for(let n of r){let i=e.workspace[n],p=t.workspace[n];b$1(i)!==b$1(p)&&w(a,{type:"workspace.changed",severity:"info",target:`workspace.${n}`,message:`Workspace metadata field changed: ${String(n)}`,before:i,after:p});}for(let n of c){let i=e.identity[n],p=t.identity[n];b$1(i)!==b$1(p)&&w(a,{type:"workspace.changed",severity:"info",target:`identity.${n}`,message:`Workspace identity field changed: ${String(n)}`,before:i,after:p});}return b$1(e.policies)!==b$1(t.policies)&&w(a,{type:"workspace.changed",severity:"warning",target:"policies",message:"Workspace policy summary changed.",before:e.policies,after:t.policies}),b$1(e.discovery)!==b$1(t.discovery)&&w(a,{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(a,{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}),a}function je(e,t){let a=e.validation??null,r=t.validation??null;return b$1(a)===b$1(r)?[]:[{type:"validation.changed",severity:r?.status==="failed"?"critical":"warning",target:"validation",message:"Workspace model validation changed.",before:a,after:r}]}function Ie(e,t){let a=[],r=new Map(e.projects.map(n=>[n.path,n])),c=new Map(t.projects.map(n=>[n.path,n]));for(let[n,i]of c.entries()){let p=r.get(n);if(!p){w(a,{type:"project.added",severity:"info",target:n,message:`Project added: ${i.name}`,after:x(i)});continue}let m=x(p),l=x(i);if(b$1(m)!==b$1(l)){let u=p.runtime!==i.runtime||p.framework!==i.framework;w(a,{type:"project.changed",severity:u?"warning":"info",target:n,message:`Project changed: ${i.name}`,before:m,after:l});}}for(let[n,i]of r.entries())c.has(n)||w(a,{type:"project.removed",severity:"warning",target:n,message:`Project removed: ${i.name}`,before:x(i)});return a.sort((n,i)=>`${n.type}:${n.target}`.localeCompare(`${i.type}:${i.target}`))}async function Pe(e){let t=k$1.resolve(e.workspacePath),a=ne(e.fromPath),r=a?We(e.fromPath):void 0,c=e.fromPath;if(a){let f=k$1.join(t,_);if(!await V.pathExists(f))throw new Error("Git-aware workspace diff requires an existing snapshot at .workspai/reports/workspace-model-snapshot.json. Run: npx workspai workspace snapshot --json");c=_;}let n=se(t,c),i=await be(n),p$1=e.model??await p({workspacePath:t,includeAbsolutePaths:e.includeAbsolutePaths,includeEvidence:e.includeEvidence,observableScanDepth:e.observableScanDepth,now:e.now}),m=d(p$1),l=[...Me(i.model,p$1),...Ie(i.model,p$1),...je(i.model,p$1)],u;e.includeGitObservation!==false&&(u=e.gitObservation??Q(t,{ref:r}),u.available&&Ee(l,u,p$1));let v=l.filter(f=>f.type.startsWith("git.")).length,R=i.hash!==m,y=a?`git:${r??"HEAD"}`:k$1.relative(t,n).split(k$1.sep).join("/");return {schemaVersion:L,generatedAt:(e.now??new Date).toISOString(),fromRef:y,toRef:k,fromHash:i.hash,toHash:m,summary:{changed:R||v>0,addedProjects:l.filter(f=>f.type==="project.added").length,removedProjects:l.filter(f=>f.type==="project.removed").length,changedProjects:l.filter(f=>f.type==="project.changed").length,workspaceChanges:l.filter(f=>f.type==="workspace.changed").length,validationChanges:l.filter(f=>f.type==="validation.changed").length,gitChangedFiles:v},git:u?.available?Oe(u,r):{available:false,dirty:false,changedFiles:0,untrackedFiles:0,deletedFiles:0},changes:l,currentModel:p$1}}async function Ze(e,t){return e$1(t,ae,d$1(e))}function I(e){return {none:0,low:1,medium:2,high:3,critical:4}[e]}function Z(e){return e.reduce((t,a)=>I(a)>I(t)?a:t,"none")}var N=["none","low","medium","high","critical"];function Re(e){let t=Math.max(1,I(e)-1);return N[t]}function Ce(e){let t=Math.min(N.length-1,I(e)+1);return N[t]}function ee(e){return e.join(" ")}function h(e,t,a,r){return {id:e,label:t,scope:r.scope,project:r.project,display:ee(["npx","workspai",...a]),execute:ee(["npx","--yes","--package","workspai","workspai",...a]),required:r.required!==false}}function te(e){let t=`project:${e.name}`,a=e.commands.fleetStages;return [h(`project.${e.name}.init`,`Run init for ${e.name}`,["workspace","run","init","--scope",t,"--json"],{scope:"project",project:e.name,required:a.includes("init")}),h(`project.${e.name}.test`,`Run tests for ${e.name}`,["workspace","run","test","--scope",t,"--json"],{scope:"project",project:e.name,required:a.includes("test")}),h(`project.${e.name}.build`,`Run build for ${e.name}`,["workspace","run","build","--scope",t,"--json"],{scope:"project",project:e.name,required:a.includes("build")}),h(`project.${e.name}.start`,`Run start for ${e.name}`,["workspace","run","start","--scope",t,"--json"],{scope:"project",project:e.name,required:a.includes("start")})]}function T(){return [h("workspace.doctor","Run workspace doctor",["doctor","workspace","--json"],{scope:"workspace"}),h("workspace.contract.verify","Verify workspace contract",["workspace","contract","verify","--json"],{scope:"workspace"}),h("workspace.readiness","Run release readiness",["readiness","--json"],{scope:"workspace"}),h("workspace.analyze","Run workspace analyze",["analyze","--json"],{scope:"workspace",required:false}),h("workspace.pipeline","Run governance pipeline",["pipeline","--json"],{scope:"workspace",required:false}),h("workspace.doctor-fix","Verify doctor fix result",["doctor","workspace","--fix","--json"],{scope:"workspace",required:false})]}function Se(e,t){let a=t.split(k$1.sep).join("/");return e.projects.filter(c=>{let n=c.path.split(k$1.sep).join("/");return a===n||a.startsWith(`${n}/`)}).sort((c,n)=>n.path.length-c.path.length)[0]}function Ee(e,t,a){let r=new Set(e.map(n=>n.target)),c=(n,i)=>{let p=i.split(k$1.sep).join("/"),m=`git:${p}`;if(r.has(m))return;let l=Se(a,p),u=l?`${l.name} (${l.path})`:"workspace";w(e,{type:n,severity:n==="git.deleted"?"warning":"info",target:m,message:`Git ${n==="git.untracked"?"untracked":n==="git.deleted"?"deleted":"changed"} file affects ${u}: ${p}`,after:{path:p,project:l?.name,projectPath:l?.path}}),r.add(m);};for(let n of t.changedFiles)c("git.file.changed",n);for(let n of t.untrackedFiles)c("git.untracked",n);for(let n of t.deletedFiles)c("git.deleted",n);}function Oe(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 Ae(e){let t=new Set,a=[];for(let r of e){let c=`${r.scope}:${r.project??""}:${r.display}`;t.has(c)||(t.add(c),a.push(r));}return a}function De(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 Fe(e){return e.affectedProjects>0||e.projectCount>0||!e.changes.every(a=>a.severity==="critical"?false:a.type.startsWith("git.")||a.type==="validation.changed")?e.risk:I(e.risk)>=I("high")||e.risk==="medium"?"low":e.risk}function re(e,t){if(!e||e==="workspace")return true;let a=(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(a)}function xe(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(a=>a.project?.name??a.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),a=ne(e.fromPath),r=e.diff;if(!r&&!a){let o=se(t,e.fromPath);r=await ve(o)??void 0;}r||(r=await Pe({workspacePath:t,fromPath:e.fromPath,includeAbsolutePaths:e.includeAbsolutePaths,includeEvidence:e.includeEvidence,includeGitObservation:e.includeGitObservation,gitObservation:e.gitObservation,now:e.now,model:e.model}));let c$1=new Map(r.currentModel.projects.map(o=>[o.path,o])),n=new Map(r.currentModel.projects.map(o=>[o.name,o])),i=r.changes.filter(o=>o.type.startsWith("project.")),p=new Map;for(let o of i){let d=(c$1.get(o.target)??(typeof o.before?.name=="string"?n.get(o.before.name):void 0))?.path??o.target,W=p.get(d)??[];W.push(o),p.set(d,W);}let m=[];for(let[o,s]of p.entries()){let d=c$1.get(o);if(d&&!re(e.scope,d))continue;let W=Z(s.map(De)),C=d?.name??(typeof s[0]?.before?.name=="string"?String(s[0].before.name):o);m.push({id:`project:${C}`,scope:"project",target:o,title:`Project impact: ${C}`,summary:s.map(M=>M.message).join(" "),risk:W,reasons:s.map(M=>`${M.type}: ${M.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?te(d):T()});}let l$1=l(r.currentModel),u=l$1?a$1(l$1):void 0,v=new Set(m.map(o=>o.project?.name).filter(o=>typeof o=="string")),R=new Map;for(let o of m)if(o.project?.name){let s=u?.byId.get(o.project.name);s&&(o.centrality={fanIn:s.fanIn,fanOut:s.fanOut,reach:s.reach,betweenness:s.betweenness,isHotspot:s.isHotspot},s.isHotspot&&(o.risk=Ce(o.risk),o.reasons=[...o.reasons,`graph.hotspot: critical-path project with ${s.reach} transitive dependent(s); risk escalated.`])),o.origin="direct",o.distance=0,R.set(o.project.name,o.risk);}let y=[],f=0;if(l$1&&v.size>0){let o=c(l$1,v);for(let s of o.values()){if(s.distance===0||v.has(s.id))continue;let d=n.get(s.id);if(d&&!re(e.scope,d))continue;let W=s.path[0],C=s.path[s.path.length-2]??W,M=R.get(W)??"medium",de=Re(M),j=u?.byId.get(s.id);f=Math.max(f,s.distance),y.push({id:`transitive:${s.id}`,scope:"project",target:d?.path??s.id,title:`Transitive impact: ${s.id}`,summary:`Depends on changed project ${W}${s.via?` via ${s.via}`:""} (distance ${s.distance}).`,risk:de,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?te(d):T(),origin:"transitive",distance:s.distance,path:s.path,via:s.via,...j?{centrality:{fanIn:j.fanIn,fanOut:j.fanOut,reach:j.reach,betweenness:j.betweenness,isHotspot:j.isHotspot}}:{}});}}y.sort((o,s)=>o.target.localeCompare(s.target));let ie=u?u.hotspots.flatMap(o=>{let s=u.byId.get(o);return s?[{project:o,fanIn:s.fanIn,fanOut:s.fanOut,reach:s.reach,betweenness:s.betweenness}]:[]}):[],ce=r.changes.filter(o=>!o.type.startsWith("project.")),K=r.currentModel.summary?.projectCount??r.currentModel.projects.length,P=ce.map(o=>({id:`workspace:${o.target}`,scope:"workspace",target:o.target,title:`Workspace impact: ${o.target}`,summary:o.message,risk:$e(o,{projectCount:K}),reasons:[`${o.type}: ${o.message}`],verification:T()})),B=Ae([...m.flatMap(o=>o.verification),...y.flatMap(o=>o.verification),...P.flatMap(o=>o.verification),...r.summary.changed?T():[]]).filter(o=>o.required),pe=Z([...m.map(o=>o.risk),...y.map(o=>o.risk),...P.map(o=>o.risk)]),q=Fe({risk:pe,affectedProjects:m.length,projectCount:K,changes:r.changes}),z={changed:r.summary.changed,risk:q,affectedProjects:m.length,workspaceItems:P.length,recommendedCommands:B.length,blastRadius:{directlyAffected:m.length,transitivelyAffected:y.length,maxDistance:f,graphEdges:l$1?.edges.length??0}};return {schemaVersion:he,generatedAt:(e.now??new Date).toISOString(),fromRef:r.fromRef,diffRef:ae,workspace:{name:r.currentModel.workspace.name,profile:r.currentModel.workspace.profile,type:r.currentModel.workspace.type},summary:z,affectedProjects:m.sort((o,s)=>o.target.localeCompare(s.target)),transitiveImpact:y,criticalPathHotspots:ie,workspaceImpact:P.sort((o,s)=>o.target.localeCompare(s.target)),verificationPlan:B,agentBrief:xe({changed:z.changed,risk:q,affectedProjects:m,workspaceImpact:P}),diff:r}}async function tt(e,t){return e$1(t,we,d$1(e))}export{Q as a,oe as b,L as c,_ as d,ae as e,he as f,we as g,ye as h,ne as i,We as j,Ye as k,Qe as l,Pe as m,Ze as n,T as o,et as p,tt as q};
|
package/dist/chunk-SJLUE6AY.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import {a}from'./chunk-MRFN5ZQP.js';import {a as a$1}from'./chunk-GR6442P7.js';import {f,e as e$1}from'./chunk-WIO6L24E.js';import {d,e}from'./chunk-44VJHNZB.js';import {createHash}from'crypto';import c from'path';import {execa}from'execa';import u from'fs-extra';var V=d.projectTestCoverage.schemaVersion,k=e.projectTestCoverage,$=["package.json","pyproject.toml","requirements.txt","go.mod","pom.xml","build.gradle","build.gradle.kts","Cargo.toml","composer.json","Gemfile","mix.exs","deps.edn","project.clj","build.sbt","CMakeLists.txt","meson.build","deno.json","deno.jsonc"];function p(e){let t=Number(e);return Number.isFinite(t)&&t>=0?t:0}function m(e,t,o=0){let n=p(e),r=Math.min(p(t),n),i=p(o);return {total:n,covered:r,skipped:i,percent:n>0?Math.round(r/n*1e4)/100:null}}function W(e){if(!e||typeof e!="object"||Array.isArray(e))return;let t=e;return m(t.total,t.covered,t.skipped)}function y(e,t){let o=c.isAbsolute(t)?t:c.resolve(e,t),n=c.relative(e,o);return n&&!n.startsWith("..")?n.split(c.sep).join("/"):t}async function x(e){return createHash("sha256").update(await u.readFile(e)).digest("hex")}async function H(e){let t=c.resolve(e);for(;;){if(await u.pathExists(c.join(t,".workspai","project.json"))||await u.pathExists(c.join(t,".rapidkit","project.json"))||(await Promise.all($.map(r=>u.pathExists(c.join(t,r))))).some(Boolean))return t;let n=c.dirname(t);if(n===t)return c.resolve(e);t=n;}}async function D(e){if(await u.pathExists(c.join(e,"deno.json"))||await u.pathExists(c.join(e,"deno.jsonc")))return "deno";if(await u.pathExists(c.join(e,"bun.lock"))||await u.pathExists(c.join(e,"bun.lockb")))return "bun";if(await u.pathExists(c.join(e,"package.json")))return "node";if(await u.pathExists(c.join(e,"pyproject.toml"))||await u.pathExists(c.join(e,"requirements.txt")))return "python";if(await u.pathExists(c.join(e,"go.mod")))return "go";let t=await u.pathExists(c.join(e,"pom.xml"))||await u.pathExists(c.join(e,"build.gradle"))||await u.pathExists(c.join(e,"build.gradle.kts"));return t&&(await P(e,o=>o.endsWith(".kt")||o.endsWith(".kts")&&o!=="build.gradle.kts"&&o!=="settings.gradle.kts",4)).length>0?"kotlin":t?"java":await u.pathExists(c.join(e,"Cargo.toml"))?"rust":await u.pathExists(c.join(e,"composer.json"))?"php":await u.pathExists(c.join(e,"Gemfile"))?"ruby":await u.pathExists(c.join(e,"mix.exs"))?"elixir":await u.pathExists(c.join(e,"deps.edn"))||await u.pathExists(c.join(e,"project.clj"))?"clojure":await u.pathExists(c.join(e,"build.sbt"))?"scala":await u.pathExists(c.join(e,"CMakeLists.txt"))?(await P(e,n=>/\.(c|cc|cpp|cxx)$/.test(n),3)).some(n=>/\.(cc|cpp|cxx)$/.test(n))?"cpp":"c":(await P(e,o=>/\.(sln|csproj)$/.test(o),2)).length>0?"dotnet":"unknown"}async function P(e,t,o=5){let n=[],r=[{dir:e,depth:0}],i=new Set([".git",".workspai",".rapidkit","node_modules",".venv","vendor","deps"]);for(;r.length>0;){let s=r.shift();if(!s)break;let a=await u.readdir(s.dir,{withFileTypes:true}).catch(()=>[]);for(let l of a){if(i.has(l.name)||a$1(l.name))continue;let d=c.join(s.dir,l.name),g=c.relative(e,d).split(c.sep).join("/");l.isFile()&&t(l.name,g)&&n.push(d),l.isDirectory()&&s.depth<o&&r.push({dir:d,depth:s.depth+1});}}return n}async function L(e,t){let o=await u.readJson(t),n=o.total??o,r={};for(let s of ["lines","branches","functions","statements"]){let a=W(n[s]);a&&(r[s]=a);}let i=[];for(let[s,a]of Object.entries(o)){if(s==="total"||!a||typeof a!="object"||Array.isArray(a))continue;let l=a,d={};for(let g of ["lines","branches","functions","statements"]){let b=W(l[g]);b&&(d[g]=b);}i.push({path:y(e,s),metrics:d});}return {metrics:r,files:i,source:{format:"istanbul-json",path:t,sha256:await x(t)}}}async function G(e,t){let o=await u.readJson(t),n=o.totals??{},r={lines:m(n.num_statements,n.covered_lines)};p(n.num_branches)>0&&(r.branches=m(n.num_branches,n.covered_branches));let i=[];for(let[s,a]of Object.entries(o.files??{})){let l=a?.summary??{};i.push({path:y(e,s),metrics:{lines:m(l.num_statements,l.covered_lines),...p(l.num_branches)>0?{branches:m(l.num_branches,l.covered_branches)}:{}}});}return {metrics:r,files:i,source:{format:"coverage-py-json",path:t,sha256:await x(t)}}}function j(e){if(!e||typeof e!="object"||Array.isArray(e))return;let t=e,o=p(t.count),n=p(t.covered);return o>0?m(o,n):void 0}async function q(e,t){let o=await u.readJson(t),n=Array.isArray(o.data)?o.data[0]??{}:o,r=n.totals??{},i={};i.lines=j(r.lines),i.functions=j(r.functions),i.branches=j(r.branches),i.statements=j(r.regions);let s=[];for(let a of Array.isArray(n.files)?n.files:[]){if(!a||typeof a!="object"||Array.isArray(a))continue;let l=a,d=l.summary??{};s.push({path:y(e,String(l.filename??"unknown")),metrics:{lines:j(d.lines),functions:j(d.functions),branches:j(d.branches),statements:j(d.regions)}});}return {metrics:i,files:s,source:{format:"llvm-cov-json",path:t,sha256:await x(t)}}}async function A(e,t){let o=await u.readFile(t,"utf8"),n=[],r="",i=0,s=0,a=0,l=0,d=0,g=0,b=v=>{r&&(n.push({path:y(e,r),metrics:{lines:m(v.lineTotal,v.lineCovered),functions:m(v.functionTotal,v.functionCovered),branches:m(v.branchTotal,v.branchCovered)}}),i+=v.lineTotal,s+=v.lineCovered,a+=v.functionTotal,l+=v.functionCovered,d+=v.branchTotal,g+=v.branchCovered);},h={lineTotal:0,lineCovered:0,functionTotal:0,functionCovered:0,branchTotal:0,branchCovered:0};for(let v of o.split(/\r?\n/))v.startsWith("SF:")?r=v.slice(3):v.startsWith("LF:")?h.lineTotal=p(v.slice(3)):v.startsWith("LH:")?h.lineCovered=p(v.slice(3)):v.startsWith("FNF:")?h.functionTotal=p(v.slice(4)):v.startsWith("FNH:")?h.functionCovered=p(v.slice(4)):v.startsWith("BRF:")?h.branchTotal=p(v.slice(4)):v.startsWith("BRH:")?h.branchCovered=p(v.slice(4)):v==="end_of_record"&&(b(h),r="",h={lineTotal:0,lineCovered:0,functionTotal:0,functionCovered:0,branchTotal:0,branchCovered:0});return {metrics:{lines:m(i,s),functions:m(a,l),branches:m(d,g)},files:n,source:{format:"lcov",path:t,sha256:await x(t)}}}async function U(e,t){let o=await u.readFile(t,"utf8"),n=new Map;for(let s of o.split(/\r?\n/).slice(1)){let a=/^(.+?):\d+\.\d+,\d+\.\d+\s+(\d+)\s+(\d+)$/.exec(s.trim());if(!a)continue;let l=n.get(a[1])??{total:0,covered:0},d=p(a[2]);l.total+=d,p(a[3])>0&&(l.covered+=d),n.set(a[1],l);}let r=[...n.entries()].map(([s,a])=>({path:y(e,s),metrics:{statements:m(a.total,a.covered)}})),i=[...n.values()].reduce((s,a)=>({total:s.total+a.total,covered:s.covered+a.covered}),{total:0,covered:0});return {metrics:{statements:m(i.total,i.covered)},files:r,source:{format:"go-coverprofile",path:t,sha256:await x(t)}}}function T(e,t){let n=[...e.matchAll(new RegExp(`<counter\\s+type=["']${t}["']\\s+missed=["'](\\d+)["']\\s+covered=["'](\\d+)["']\\s*\\/?\\s*>`,"gi"))].at(-1);return n?m(Number(n[1])+Number(n[2]),n[2]):void 0}async function C(e,t){let o=await u.readFile(e,"utf8"),n={};if(t==="cobertura-xml"){let r=/<coverage\b([^>]*)>/i.exec(o)?.[1]??"",i=/\bline-rate=["']([\d.]+)["']/i.exec(r)?.[1],s=/\bbranch-rate=["']([\d.]+)["']/i.exec(r)?.[1];i&&(n.lines=m(1e4,Math.round(Number(i)*1e4))),s&&(n.branches=m(1e4,Math.round(Number(s)*1e4)));}if(t==="clover-xml"){let i=[...o.matchAll(/<metrics\b([^>]*)\/?>/gi)].at(-1)?.[1]??"",s=g=>p(new RegExp(`\\b${g}=["'](\\d+)["']`,"i").exec(i)?.[1]),a=s("statements"),l=s("methods"),d=s("conditionals");a>0&&(n.statements=m(a,s("coveredstatements"))),l>0&&(n.functions=m(l,s("coveredmethods"))),d>0&&(n.branches=m(d,s("coveredconditionals")));}return n.lines??=T(o,"LINE"),n.branches??=T(o,"BRANCH"),n.functions??=T(o,"METHOD"),n.statements??=T(o,"INSTRUCTION"),{metrics:n,files:[],source:{format:t,path:e,sha256:await x(e)}}}async function z(e){let t=await u.readFile(e,"utf8"),o=/<scoverage\b([^>]*)>/i.exec(t)?.[1]??"",n=b=>p(new RegExp(`\\b${b}=["']([\\d.]+)["']`,"i").exec(o)?.[1]),r=n("statement-count"),i=n("statements-invoked"),s=n("branch-count"),a=n("branches-invoked"),l=n("statement-rate"),d=n("branch-rate"),g={};return r>0?g.statements=m(r,i):l>0&&(g.statements=m(1e4,Math.round(l*100))),s>0?g.branches=m(s,a):d>0&&(g.branches=m(1e4,Math.round(d*100))),{metrics:g,files:[],source:{format:"scoverage-xml",path:e,sha256:await x(e)}}}async function B(e,t){let o=await u.readJson(t),n=new Map;for(let s of Object.values(o)){let a=s?.coverage;if(!(!a||typeof a!="object"||Array.isArray(a)))for(let[l,d]of Object.entries(a)){if(!Array.isArray(d))continue;let g=n.get(l)??[];d.forEach((b,h)=>{typeof b=="number"&&(g[h]=Math.max(g[h]??0,b));}),n.set(l,g);}}let r=[...n.entries()].map(([s,a])=>{let l=a.filter(d=>typeof d=="number");return {path:y(e,s),metrics:{lines:m(l.length,l.filter(d=>d>0).length)}}}),i=r.reduce((s,a)=>{let l=a.metrics.lines;return {total:s.total+(l?.total??0),covered:s.covered+(l?.covered??0)}},{total:0,covered:0});return {metrics:{lines:m(i.total,i.covered)},files:r,source:{format:"simplecov-json",path:t,sha256:await x(t)}}}async function K(e){let t=[{relativePath:"coverage/coverage-summary.json",parser:r=>L(e,r)},{relativePath:"coverage.json",parser:async r=>{let i=await u.readJson(r);return Array.isArray(i.data)?q(e,r):G(e,r)}},{relativePath:"coverage/lcov.info",parser:r=>A(e,r)},{relativePath:"cover/lcov.info",parser:r=>A(e,r)},{relativePath:"lcov.info",parser:r=>A(e,r)},{relativePath:"coverage.out",parser:r=>U(e,r)},{relativePath:"target/site/jacoco/jacoco.xml",parser:r=>C(r,"jacoco-xml")},{relativePath:"build/reports/jacoco/test/jacocoTestReport.xml",parser:r=>C(r,"jacoco-xml")},{relativePath:"coverage.xml",parser:r=>C(r,"clover-xml")},{relativePath:".resultset.json",parser:r=>B(e,r)}];for(let r of t){let i=c.join(e,r.relativePath);if(await u.pathExists(i))return r.parser(i)}let n=(await P(e,(r,i)=>r==="coverage.cobertura.xml"||r==="jacoco.xml"||r==="clover.xml"||r==="scoverage.xml"||i.endsWith("/coverage-summary.json"),7)).sort()[0];return n?n.endsWith("coverage-summary.json")?L(e,n):n.endsWith("jacoco.xml")?C(n,"jacoco-xml"):n.endsWith("coverage.cobertura.xml")?C(n,"cobertura-xml"):n.endsWith("scoverage.xml")?z(n):C(n,"clover-xml"):null}async function X(e){return u.readJson(c.join(e,"package.json")).catch(()=>null)}async function Q(e,t){let o=(n,r)=>({cwd:e,executable:n,args:r});if(t==="node"||t==="bun"){let r=(await X(e))?.scripts??{},i=["test:coverage","test:cov","coverage"].find(a=>typeof r[a]=="string"),s=t==="bun"?"bun":await u.pathExists(c.join(e,"pnpm-lock.yaml"))?"pnpm":await u.pathExists(c.join(e,"yarn.lock"))?"yarn":"npm";if(i)return {runner:String(r[i]).split(/\s+/)[0]||s,invocations:[o(s,s==="yarn"?[i]:["run",i])],diagnostics:[]};if(typeof r.test=="string"){let a=s==="yarn"?["test","--coverage"]:s==="bun"?["test","--coverage","--coverage-reporter=lcov"]:["test","--","--coverage"];return {runner:String(r.test).split(/\s+/)[0]||s,invocations:[o(s,a)],diagnostics:[]}}return {runner:null,invocations:[],diagnostics:["No project-owned test or coverage script was detected."]}}if(t==="deno")return {runner:"deno",invocations:[o("deno",["test","--coverage=coverage"]),o("deno",["coverage","--lcov","--output=coverage/lcov.info","coverage"])],diagnostics:[]};if(t==="python")return {runner:"pytest-cov",invocations:[o(await u.pathExists(c.join(e,".venv",process.platform==="win32"?"Scripts":"bin",process.platform==="win32"?"python.exe":"python"))?c.join(".venv",process.platform==="win32"?"Scripts":"bin",process.platform==="win32"?"python.exe":"python"):process.platform==="win32"?"python":"python3",["-m","pytest","--cov=.","--cov-report=json:coverage.json"])],diagnostics:[]};if(t==="go")return {runner:"go test",invocations:[o("go",["test","./...","-coverprofile=coverage.out"])],diagnostics:[]};if(t==="java"){let n=await u.pathExists(c.join(e,"gradlew")),r=await u.pathExists(c.join(e,"gradlew.bat")),i=n||r,s=await u.pathExists(c.join(e,"mvnw")),a=await u.pathExists(c.join(e,"mvnw.cmd")),l=i?process.platform==="win32"&&r?".\\gradlew.bat":"./gradlew":await u.pathExists(c.join(e,"pom.xml"))?process.platform==="win32"&&a?".\\mvnw.cmd":s?"./mvnw":"mvn":"gradle";return {runner:i?"jacoco/gradle":"jacoco/maven",invocations:[o(l,i?["test","jacocoTestReport"]:["test","jacoco:report"])],diagnostics:[]}}return t==="dotnet"?{runner:"dotnet coverlet",invocations:[o("dotnet",["test","--collect:XPlat Code Coverage"])],diagnostics:[]}:t==="rust"?{runner:"cargo llvm-cov",invocations:[o("cargo",["llvm-cov","--json","--output-path","coverage.json"])],diagnostics:["cargo-llvm-cov must be available in the project toolchain."]}:t==="php"?{runner:"phpunit",invocations:[o(process.platform==="win32"?"vendor\\bin\\phpunit.bat":"vendor/bin/phpunit",["--coverage-clover","coverage.xml"])],diagnostics:[]}:t==="ruby"?{runner:"simplecov",invocations:[o("bundle",["exec","rspec"])],diagnostics:["The test suite must enable SimpleCov to emit .resultset.json."]}:t==="elixir"?{runner:"mix cover",invocations:[o("mix",["test","--cover"])],diagnostics:["Configure ExCoveralls for JSON or LCOV interchange when machine-readable coverage is required."]}:t==="clojure"?{runner:"cloverage",invocations:[o("clojure",["-M:coverage"])],diagnostics:["The project must declare a coverage alias such as cloverage."]}:t==="scala"?{runner:"sbt-scoverage",invocations:[o("sbt",["clean","coverage","test","coverageReport"])],diagnostics:["The project must declare the scoverage plugin."]}:t==="kotlin"?{runner:"jacoco/gradle",invocations:[o(await u.pathExists(c.join(e,process.platform==="win32"?"gradlew.bat":"gradlew"))?process.platform==="win32"?".\\gradlew.bat":"./gradlew":"gradle",["test","jacocoTestReport"])],diagnostics:["The project must declare the JaCoCo Gradle plugin."]}:t==="c"||t==="cpp"?{runner:"CTest/LLVM coverage",invocations:[o("ctest",["--test-dir","build","--output-on-failure"])],diagnostics:["The native build must be instrumented for coverage and export LCOV, Cobertura, or LLVM JSON evidence."]}:{runner:null,invocations:[],diagnostics:["Project runtime could not be detected."]}}function Y(e,t){let o=e?c.relative(e,t).split(c.sep).join("/"):c.resolve(t),n=c.basename(t).toLowerCase().replace(/[^a-z0-9._-]+/g,"-").replace(/^-+|-+$/g,"").slice(0,48)||"project",r=createHash("sha256").update(o).digest("hex").slice(0,12);return `${n}--${r}`}function Z(e){return e.lines?"lines":e.statements?"statements":e.branches?"branches":"functions"}async function ue(e={}){let t=await H(e.projectPath??process.cwd()),o=a(t),n=await D(t),r=Math.max(0,Math.min(100,Math.round(e.target??80))),i=await Q(t,n),s=[],a$1=Date.now();if(e.run)for(let f of i.invocations){let w=await execa(f.executable,f.args,{cwd:f.cwd,reject:false,timeout:6e5}).catch(()=>({exitCode:1}));if(s.push(Number(w.exitCode??1)),Number(w.exitCode??1)!==0)break}let l=await K(t).catch(()=>null),d=l?Z(l.metrics):"lines",g=l?.metrics[d]?.percent??null,b=e.run&&s.some(f=>f!==0)?"failed":g===null?"unavailable":g>=r?"passed":"below-target",h=Y(o,t),v=c.join(t,k),E=o?`.workspai/reports/projects/${h}/project-test-coverage-last-run.json`:null,R={schemaVersion:V,generatedAt:new Date().toISOString(),status:b,project:{id:h,name:c.basename(t),path:t,workspacePath:o},runtime:n,runner:i.runner,target:{metric:d,percent:r},metrics:l?.metrics??{},files:l?.files??[],lowCoverageFiles:(l?.files??[]).map(f=>{let w=f.metrics[d]??f.metrics.lines??f.metrics.statements;return {path:f.path,percent:w?.percent??null,uncovered:Math.max(0,(w?.total??0)-(w?.covered??0))}}).filter(f=>f.percent===null||f.percent<r).sort((f,w)=>w.uncovered-f.uncovered||f.path.localeCompare(w.path)),source:l?.source??{format:"unknown",path:null,sha256:null},execution:{requested:e.run===true,invocations:i.invocations,exitCodes:s,durationMs:Date.now()-a$1},diagnostics:[...i.diagnostics,...l?[]:["No supported machine-readable coverage artifact was found."]],artifactPaths:{project:v,workspaceLatest:o?c.join(o,k):null,workspaceProject:o&&E?c.join(o,E):null}};return o&&E&&await f(o,k,[{relativePath:k,payload:R},{relativePath:E,payload:R}]),await e$1(t,k,R),R}export{V as a,k as b,ue as c};
|
package/dist/chunk-TEHQ7XKK.js
DELETED
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import {a as a$2}from'./chunk-UFOCUHG3.js';import {a as a$1}from'./chunk-5XDPQ3CB.js';import {a,e,b}from'./chunk-WIO6L24E.js';import {e as e$1,d}from'./chunk-44VJHNZB.js';import A from'path';import {existsSync}from'fs';import L from'fs-extra';var q=[{artifactKind:"bootstrap-compliance",cardId:"bootstrap",fileNames:["bootstrap-compliance.latest.json"]},{artifactKind:"doctor-workspace",cardId:"doctor",fileNames:["doctor-remediation-plan-last-run.json","doctor-last-run.json"]},{artifactKind:"analyze",cardId:"analyze",fileNames:["analyze-last-run.json"]},{artifactKind:"readiness",cardId:"readiness",fileNames:["release-readiness-last-run.json"]},{artifactKind:"pipeline",cardId:"pipeline",fileNames:["pipeline-last-run.json"]},{artifactKind:"workspace-run",cardId:"workspaceRun",fileNames:["workspace-run-last.json"]},{artifactKind:"workspace-verify",cardId:"workspaceVerify",fileNames:["workspace-verify-last-run.json"]}];function u(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:void 0}function k(e){return Array.isArray(e)?e.filter(t=>typeof t=="string"&&t.trim().length>0):[]}function v(e){return [...new Set(e.map(t=>t.trim()).filter(Boolean))]}function _(e){return (e.notes.includes("Doctor finding status: blocking")?16:0)+(e.transaction?8:0)+(e.operation?4:0)+(e.invocation?2:0)+(e.strategy?.length?1:0)}function J(e){let t=_(e.incoming)>_(e.existing),o=structuredClone(t?e.incoming:e.existing),i=t?e.existing:e.incoming,r=i.sourceStepId;return o.order=e.existing.order,o.files=v([...o.files,...i.files]),o.notes=v([...o.notes,...i.notes.filter(a=>!a.startsWith("Source Doctor capability:")&&!a.startsWith("Doctor finding status:")),...r?[`Also satisfies Doctor capability: ${r}`]:[]]),o}function x(e,t,o){return o?t:A.relative(e,t).split(A.sep).join("/")}function U(e){let t=e?.trim()||"npx workspai bootstrap";if(!/(?:^|\s)--ci(?:\s|$)/.test(t)&&/(?:^|\s)--json(?:\s|$)/.test(t))return t.replace(/(?:^|\s)--json(?:\s|$)/,i=>{let r=i.startsWith(" ")?" ":"",a=i.endsWith(" ")?" ":"";return `${r}--ci --json${a}`}).trim();let o=/(?:^|\s)--ci(?:\s|$)/.test(t)?t:`${t} --ci`;return /(?:^|\s)--json(?:\s|$)/.test(o)?o:`${o} --json`}function H(e){return `${JSON.stringify({schemaVersion:d.compatibilityMatrix.schemaVersion,generatedAt:e,source:"workspai workspace remediation-plan",runtimes:{},notes:["Minimal enterprise baseline. Add runtime and toolchain entries as governance matures."]},null,2)}
|
|
2
|
-
`}function Z(e){return `${JSON.stringify({schema_version:"1.0",enabled:false,strategy:"on-demand",artifacts:[],created_at:e,note:"Minimal enterprise baseline. Set enabled: true and add artifact entries to activate mirroring."},null,2)}
|
|
3
|
-
`}function G(e){let t=e.payload,o=k(t.blockers),i=k(t.blockingReasons),r=k(t.failures),a=k(t.reasons),d=k(t.policyViolations),s=u(t.summary),p=k(s?.blockers);if(e.artifactKind==="analyze"){let c=(Array.isArray(t.findings)?t.findings:[]).map(n=>u(n)).filter(n=>!!n).map(n=>String(n.message??n.title??n.id??"").trim()).filter(Boolean);return v([...o,...c,...i])}if(e.artifactKind==="workspace-run"){let g=u(t.stages),c=Object.entries(g??{}).flatMap(([n,l])=>{let b=u(l);return (Array.isArray(b?.projects)?b.projects:[]).map(f=>u(f)).filter(f=>!!f).filter(f=>f.status==="failed"||f.ok===false).map(f=>`${n}: ${String(f.project??f.name??"project")} failed`)});return v([...o,...c,...i])}return v([...o,...i,...r,...a,...d,...p])}function w(e){return {id:e.id,artifactKind:e.artifactKind,cardId:e.cardId,title:e.title,order:e.order,phase:e.phase,scope:e.scope??"workspace",...e.projectName?{projectName:e.projectName}:{},...e.projectPath?{projectPath:e.projectPath}:{},...e.sourceStepId?{sourceStepId:e.sourceStepId}:{},...e.dependsOn?{dependsOn:e.dependsOn}:{},...e.strategy?{strategy:structuredClone(e.strategy)}:{},...e.transaction?{transaction:structuredClone(e.transaction)}:{},status:e.status??"ready",mode:e.mode,risk:e.risk,requiresApproval:true,blocker:e.blocker,summary:e.summary,...e.command?{command:e.command}:{},...e.invocation?{invocation:structuredClone(e.invocation)}:{},verifyCommand:e.verifyCommand,cwd:e.cwd??"workspace",files:e.files??[],...e.operation?{operation:e.operation}:{},rollback:e.rollback??(e.operation?{available:true,strategy:"idempotent"}:{available:false,strategy:"none"}),notes:e.notes??[]}}function Q(e){return (Array.isArray(e.report.payload.steps)?e.report.payload.steps:[]).flatMap((o,i)=>{let r=u(o),a=typeof r?.id=="string"?r.id.trim():"",d=typeof r?.projectName=="string"?r.projectName.trim():"",s=typeof r?.projectPath=="string"?r.projectPath.trim():"",p=typeof r?.originalCommand=="string"?r.originalCommand.trim():"";if(!r||!a||!d||!s)return [];let g=u(r.studioStatus),c=g?.state==="ready"||g?.state==="review-required"||g?.state==="blocked"||g?.state==="guidance-only"?g.state:"guidance-only",n=r.risk==="safe"||r.risk==="guarded"||r.risk==="invasive"?r.risk:"guarded",l=u(r.preview),b=x(e.workspacePath,s,e.includeAbsolutePaths),h=B({capability:{...r,command:p},absoluteProjectPath:s,includeAbsolutePaths:e.includeAbsolutePaths}),f=V({capability:r,absoluteProjectPath:s,includeAbsolutePaths:e.includeAbsolutePaths}),j=r.executableInCurrentEnvironment===true&&!!h,R=W({strategy:r.strategy,includeAbsolutePaths:e.includeAbsolutePaths}),m=u(r.transaction),y=m?.schemaVersion==="workspai.doctor-dependency-repair-transaction.v1"?structuredClone(m):void 0;return y&&(y.projectPath=b),[w({id:`doctor.${a}`,artifactKind:e.report.artifactKind,cardId:e.report.cardId,title:typeof l?.title=="string"&&l.title.trim()?l.title.trim():`Repair ${d}`,order:e.startOrder+i,phase:typeof r.phase=="string"?r.phase:"doctor-remediation",blocker:typeof l?.summary=="string"&&l.summary.trim()?l.summary.trim():`Doctor remediation is pending for ${d}.`,summary:typeof l?.summary=="string"&&l.summary.trim()?l.summary.trim():`Execute the CLI-authored Doctor step for ${d}.`,mode:j?"run-command":"manual-guidance",risk:n,status:c,...j&&h?{command:h}:{},...j&&f?{invocation:f}:{},verifyCommand:typeof r.verifyCommand=="string"&&r.verifyCommand.trim()?r.verifyCommand.trim():"npx workspai doctor project --json",files:k(r.files).map(P=>{let $=A.isAbsolute(P)?P:A.resolve(s,P);return x(e.workspacePath,$,e.includeAbsolutePaths)}),notes:[`Source Doctor step: ${a}`,...typeof g?.reason=="string"?[g.reason]:[]],scope:"project",projectName:d,projectPath:b,sourceStepId:a,dependsOn:k(r.dependsOn).map(P=>`doctor.${P}`),strategy:R,transaction:y,cwd:"project",...u(r.rollback)?.available===true?{rollback:{available:true,strategy:"manual"}}:{}})]})}function B(e){let t=typeof e.capability.command=="string"?e.capability.command.trim():"";if(e.includeAbsolutePaths&&t)return t;let o=X({operation:e.capability.operation,absoluteProjectPath:e.absoluteProjectPath});if(o)return a$2(o);let i=u(e.capability.invocation),r=typeof i?.executable=="string"?i.executable.trim():"",a=k(i?.args);if(r)return [r,...a].map(s=>/^[a-zA-Z0-9_./:@=+-]+$/.test(s)?s:JSON.stringify(s)).join(" ");if(!t)return;let d=e.absoluteProjectPath.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return t.replace(new RegExp(`^cd\\s+["']?${d}["']?\\s*&&\\s*`,"i"),"").replaceAll(e.absoluteProjectPath,".")}function V(e){let t=u(e.capability.invocation),o=typeof t?.executable=="string"?t.executable.trim():"",i=k(t?.args);if(!(!o||i.length!==(Array.isArray(t?.args)?t.args.length:0)))return {cwd:e.includeAbsolutePaths?e.absoluteProjectPath:".",executable:o,args:i}}function X(e){let t=u(e.operation);if(!t||typeof t.type!="string")return;let o=structuredClone(t);for(let i of ["path","sourcePath"]){let r=o[i];if(typeof r!="string")continue;let a=A.isAbsolute(r)?A.relative(e.absoluteProjectPath,r):r;if(!a||a===".."||a.startsWith(`..${A.sep}`)||A.isAbsolute(a))return;o[i]=a.split(A.sep).join("/");}return o}function W(e){if(!Array.isArray(e.strategy))return;let t=structuredClone(e.strategy);if(!e.includeAbsolutePaths)for(let o of t)o.invocation&&(o.invocation.cwd=".");return t}function Y(e){let t=Array.isArray(e.report.payload.projects)?e.report.payload.projects:e.report.payload.project?[e.report.payload.project]:[],o=new Set,i=[];for(let r of t){let a=u(r);if(!a)continue;let d=typeof a.name=="string"?a.name.trim():"",s=typeof a.path=="string"?a.path.trim():"";if(!d||!s)continue;let p=Array.isArray(a.repairCapabilities)?a.repairCapabilities:Array.isArray(a.probes)?a.probes.map(c=>u(c)?.repairCapability).filter(c=>c!==void 0):[],g=new Map;for(let c of Array.isArray(a.probes)?a.probes:[]){let n=u(c),l=u(n?.repairCapability),b=typeof l?.id=="string"?l.id.trim():"";b&&g.set(b,n?.status==="fail"?"blocking":"advisory");}for(let c of p){let n=u(c),l=typeof n?.id=="string"?n.id.trim():"";if(!n||!l)continue;let b=`${d}:${l}`;if(o.has(b))continue;o.add(b);let h=n.risk==="safe"||n.risk==="guarded"||n.risk==="invasive"?n.risk:"guarded",f=B({capability:n,absoluteProjectPath:s,includeAbsolutePaths:e.includeAbsolutePaths}),j=V({capability:n,absoluteProjectPath:s,includeAbsolutePaths:e.includeAbsolutePaths}),R=n.status==="available"&&!!f,m=u(n.transaction),y=m?.schemaVersion==="workspai.doctor-dependency-repair-transaction.v1"?structuredClone(m):void 0,P=g.get(l)??(y?"blocking":"advisory");y&&(y.projectPath=x(e.workspacePath,s,e.includeAbsolutePaths));let $=W({strategy:n.strategy,includeAbsolutePaths:e.includeAbsolutePaths}),z=k(n.files).map(C=>x(e.workspacePath,C,e.includeAbsolutePaths)),D=w({id:`doctor.${d}.${l}`,artifactKind:e.report.artifactKind,cardId:e.report.cardId,title:typeof n.title=="string"&&n.title.trim()?n.title.trim():`Repair ${d}`,order:e.startOrder+i.length,phase:y?"dependency-remediation":"doctor-remediation",blocker:typeof n.reason=="string"&&n.reason.trim()?n.reason.trim():`Doctor remediation is pending for ${d}.`,summary:typeof n.reason=="string"&&n.reason.trim()?n.reason.trim():`Execute the Doctor-authored repair capability for ${d}.`,mode:R?n.canEditFiles===true?"edit-file":"run-command":"manual-guidance",risk:h,status:R?"ready":n.status==="manual"?"guidance-only":"blocked",...f?{command:f}:{},...j?{invocation:j}:{},verifyCommand:typeof n.verifyCommand=="string"&&n.verifyCommand.trim()?n.verifyCommand.trim():"npx workspai doctor project --json",files:z,notes:[`Source Doctor capability: ${l}`,`Doctor finding status: ${P}`,...k(n.limitations)],scope:"project",projectName:d,projectPath:x(e.workspacePath,s,e.includeAbsolutePaths),sourceStepId:l,strategy:$,transaction:y,cwd:"project",...n.operation?{rollback:{available:true,strategy:"manual"}}:{}}),S=f?i.findIndex(C=>C.projectName===d&&C.command===f&&C.cwd==="project"):-1;if(S>=0){i[S]=J({existing:i[S],incoming:D});continue}i.push(D);}}return i}function ee(e){let t=[],o=U("npx workspai bootstrap --json");for(let i of e.blockers)i.includes("profile.enterprise.ci")&&t.push(w({id:"bootstrap.enterprise-ci",artifactKind:"bootstrap-compliance",cardId:"bootstrap",title:"Run bootstrap in deterministic CI mode",order:10,phase:"bootstrap-preflight",blocker:i,summary:"Enterprise bootstrap compliance requires --ci for deterministic execution.",mode:"run-command",risk:"safe",command:o,verifyCommand:o})),i.includes("profile.enterprise.compatibility-matrix")&&t.push(w({id:"bootstrap.compatibility-matrix",artifactKind:"bootstrap-compliance",cardId:"bootstrap",title:"Create enterprise compatibility matrix baseline",order:20,phase:"bootstrap-config",blocker:i,summary:"Create the missing compatibility matrix baseline without overwriting user data.",mode:"edit-file",risk:"safe",verifyCommand:o,files:[e$1.compatibilityMatrix],operation:{type:"file-create",path:e$1.compatibilityMatrix,content:H(e.generatedAt),overwrite:false}})),i.includes("profile.enterprise.mirror-config")&&t.push(w({id:"bootstrap.mirror-config",artifactKind:"bootstrap-compliance",cardId:"bootstrap",title:"Create enterprise mirror config baseline",order:30,phase:"bootstrap-config",blocker:i,summary:"Create the missing mirror configuration baseline without enabling mirroring.",mode:"edit-file",risk:"safe",verifyCommand:o,files:[".workspai/mirror-config.json"],operation:{type:"file-create",path:".workspai/mirror-config.json",content:Z(e.generatedAt),overwrite:false}}));return t}function te(e){let t=Array.isArray(e.report.payload.steps)?e.report.payload.steps:[],o=[],i=new Map;for(let r of t){let a=u(r),d=u(a?.command),s=typeof a?.id=="string"?a.id.trim():"",p=typeof a?.project=="string"?a.project.trim():"",g=typeof a?.status=="string"?a.status:"",c=typeof d?.display=="string"?d.display.trim():"",n=a?.required===true;if(!s.startsWith("project.")||!p||!n||g!=="fail"&&g!=="missing"||!/^npx\s+workspai\s+workspace\s+run\s+/i.test(c))continue;let l=s.split(".").at(-1)??"stage",b=`workspaceVerify.${s}`,h=i.get(p),f=/(?:^|\s)--no-gates(?:\s|$)/.test(c)?c:`${c} --no-gates`;o.push(w({id:b,artifactKind:e.report.artifactKind,cardId:e.report.cardId,title:typeof a.label=="string"&&a.label.trim()?a.label.trim():`Run ${l} for ${p}`,order:e.startOrder+o.length,phase:"fleet-run",blocker:typeof a.message=="string"&&a.message.trim()?a.message.trim():`${l} evidence is not current for ${p}.`,summary:`Produce fresh ${l} evidence for ${p} without re-entering the blocked aggregate gates.`,mode:"run-command",risk:l==="start"?"guarded":"safe",status:"ready",command:f,verifyCommand:e.ciMode?"npx workspai workspace verify --strict --json":"npx workspai workspace verify --json",scope:"project",projectName:p,projectPath:p,sourceStepId:s,...h?{dependsOn:[h]}:{},cwd:"workspace",notes:[`Source Workspace Verify step: ${s}`,"Aggregate verification must run only after this project evidence producer completes."]})),i.set(p,b);}return o}function re(e){let t=v(e.blockers.flatMap(i=>{let r=i.match(/(?:project runtimes?|workspace)\s*\(([^)]+)\)\s+(?:is|are) not pinned/i);return r?.[1]?r[1].split(",").map(a=>a.trim().toLowerCase()).filter(a=>/^(python|node|go|java|dotnet|rust|php)$/.test(a)):[]})),o=[];for(let i of t){let r=`readiness.toolchain.${i}.setup`,a=e.blockers.find(d=>d.toLowerCase().includes(`(${i})`))??`The ${i} runtime is not pinned in the canonical workspace toolchain.`;o.push(w({id:r,artifactKind:e.report.artifactKind,cardId:e.report.cardId,title:`Pin ${i} in the workspace toolchain`,order:e.startOrder+o.length,phase:"toolchain-reconciliation",blocker:a,summary:`Detect and persist the current ${i} runtime in the canonical workspace toolchain lock.`,mode:"run-command",risk:"safe",command:`npx workspai setup ${i} --json`,verifyCommand:e.ciMode?"npx workspai readiness --strict --json":"npx workspai readiness --json",notes:["Run from the workspace root so the canonical toolchain.lock is updated."]})),o.push(w({id:`readiness.toolchain.${i}.bootstrap`,artifactKind:e.report.artifactKind,cardId:e.report.cardId,title:`Reconcile the ${i} workspace foundation`,order:e.startOrder+o.length,phase:"toolchain-reconciliation",blocker:`The ${i} runtime pin must be reconciled with the workspace foundation.`,summary:"Refresh the workspace foundation after the runtime pin is written.",mode:"run-command",risk:"guarded",command:"npx workspai bootstrap --ci --json",verifyCommand:e.ciMode?"npx workspai readiness --strict --json":"npx workspai readiness --json",dependsOn:[r]}));}return o}function oe(e){if(e.report.artifactKind==="readiness"&&/dependenc(?:y|ies).*vulnerabil|vulnerabil.*dependenc(?:y|ies)|security audit/i.test(e.blocker))return w({id:`${e.report.cardId}.doctor-owner.${e.order}`,artifactKind:e.report.artifactKind,cardId:e.report.cardId,title:"Resolve dependency vulnerability through Doctor",order:e.order,phase:"dependency-remediation",blocker:e.blocker,summary:"Release Readiness is the aggregate gate; use the project-scoped Doctor remediation capability that owns this dependency failure.",mode:"verify-before-fix",risk:"guarded",status:"review-required",command:"npx workspai doctor workspace --plan --json",verifyCommand:e.ciMode?"npx workspai readiness --strict --json":"npx workspai readiness --json",notes:["Read doctor-remediation-plan-last-run.json and execute the matching surface-security-hygiene capability before rerunning Readiness.","Do not treat a Readiness refresh as remediation for a source dependency vulnerability."]});let o={analyze:{title:"Refresh analyze evidence",phase:"analysis",command:"npx workspai analyze --strict --json",verify:"npx workspai analyze --strict --json"},readiness:{title:"Refresh release readiness",phase:"release-readiness",command:e.ciMode?"npx workspai readiness --strict --json":"npx workspai readiness --json",verify:e.ciMode?"npx workspai readiness --strict --json":"npx workspai readiness --json"},pipeline:{title:"Rerun governance pipeline",phase:"governance-pipeline",command:"npx workspai pipeline --json --strict",verify:"npx workspai pipeline --json --strict"},"workspace-run":{title:"Rerun failed workspace stage",phase:"fleet-run",command:e.ciMode?"npx workspai workspace run test --strict --json":"npx workspai workspace run test --json",verify:e.ciMode?"npx workspai workspace run test --strict --json":"npx workspai workspace run test --json"},"workspace-verify":{title:"Refresh workspace verify gate",phase:"verification",command:e.ciMode?"npx workspai workspace verify --strict --json":"npx workspai workspace verify --json",verify:e.ciMode?"npx workspai workspace verify --strict --json":"npx workspai workspace verify --json"},"doctor-workspace":{title:"Use Doctor remediation plan",phase:"doctor-remediation",command:"npx workspai doctor workspace --plan --json",verify:"npx workspai doctor workspace --json"}}[e.report.artifactKind]??{title:"Refresh artifact evidence",phase:"evidence-refresh",command:"npx workspai pipeline --json --strict",verify:"npx workspai pipeline --json --strict"};return w({id:`${e.report.cardId}.refresh.${e.order}`,artifactKind:e.report.artifactKind,cardId:e.report.cardId,title:o.title,order:e.order,phase:o.phase,blocker:e.blocker,summary:"No deterministic file operation is available for this artifact yet; refresh the evidence and continue with the card-specific plan.",mode:e.report.artifactKind==="doctor-workspace"?"verify-before-fix":"run-command",risk:"guarded",status:e.report.artifactKind==="doctor-workspace"?"review-required":"ready",command:o.command,verifyCommand:o.verify,notes:e.report.artifactKind==="doctor-workspace"?["Read doctor-remediation-plan-last-run.json for ordered file-level steps."]:[]})}async function ae(e){let t=[a(e,".workspai/reports"),b(e,".workspai/reports")],o=[],i=new Set;for(let r of q)for(let a of r.fileNames){let d=(await Promise.all(t.map(s=>A.join(s,a)))).find(s=>existsSync(s));if(!(!d||i.has(`${r.artifactKind}:${a}`))){i.add(`${r.artifactKind}:${a}`);try{let s=await L.readJSON(d),p=u(s);if(!p)continue;o.push({artifactKind:r.artifactKind,cardId:r.cardId,fileName:a,absolutePath:d,payload:p});break}catch{o.push({artifactKind:r.artifactKind,cardId:r.cardId,fileName:a,absolutePath:d,payload:{blockers:[`${r.artifactKind}: report exists but could not be parsed.`]}});break}}}return o}async function ue(e){let t=A.resolve(e.workspacePath),o=e.includeAbsolutePaths===true,i=e.ciMode===true,r=new Date().toISOString(),a$2=a(t,".workspai/reports"),d=await ae(t),s=[],p=1;for(let c of d){if(c.artifactKind==="doctor-workspace"){let m=Array.isArray(c.payload.steps)?Q({report:c,workspacePath:t,includeAbsolutePaths:o,startOrder:p}):Y({report:c,workspacePath:t,includeAbsolutePaths:o,startOrder:p});s.push(...m),p+=m.length;continue}let n=G(c);if(n.length===0)continue;if(c.artifactKind==="bootstrap-compliance"){s.push(...ee({blockers:n,generatedAt:r})),p=s.length+1;continue}if(c.artifactKind==="workspace-verify"){let m=te({report:c,startOrder:p,ciMode:i});if(m.length>0){s.push(...m),p+=m.length;continue}}if(c.artifactKind==="readiness"){let m=re({report:c,blockers:n,startOrder:p,ciMode:i});if(m.length>0){s.push(...m),p+=m.length;continue}}let l=s.some(m=>m.transaction?.kind==="dependency-security"),b=c.artifactKind==="readiness"&&n.some(m=>/dependenc(?:y|ies).*vulnerabil|vulnerabil.*dependenc(?:y|ies)|security audit/i.test(m));if(l&&b)continue;let h=n[0],f=oe({report:c,blocker:h,order:p,ciMode:i}),R={readiness:new Set(["bootstrap","doctor"]),pipeline:new Set(["bootstrap","doctor","analyze","readiness"]),workspaceVerify:new Set(["bootstrap","doctor","readiness","workspaceRun"])}[c.cardId];if(c.cardId==="pipeline"){let m=["doctor","analyze","readiness"].find(y=>h.toLowerCase().includes(y));m&&(R=new Set([m]));}if(R){let m=s.filter(y=>R.has(y.cardId)&&y.risk!=="invasive"&&y.status!=="blocked"&&y.status!=="guidance-only").map(y=>y.id);m.length>0&&(f.dependsOn=v([...f.dependsOn??[],...m]),f.notes.push("This aggregate gate must run after its contract-owned upstream remediation actions."));}n.length>1&&f.notes.push(...n.slice(1,8).map(m=>`Related blocker: ${m}`)),s.push(f),p+=1;}let g={safe:s.filter(c=>c.risk==="safe").length,guarded:s.filter(c=>c.risk==="guarded").length,invasive:s.filter(c=>c.risk==="invasive").length};return {schemaVersion:a$1,generatedAt:r,workspace:{name:A.basename(t),...o?{path:t}:{}},source:{command:"workspace remediation-plan",reportsDir:x(t,a$2,o),includeAbsolutePaths:o,ciMode:i},summary:{artifactsScanned:d.length,cardsCovered:v(s.map(c=>c.cardId)).length,totalActions:s.length,executableActions:s.filter(c=>c.status==="ready").length,risk:g},actions:s}}async function ge(e$2,t){return e(t,e$1.artifactRemediationPlan,e$2)}export{ue as a,ge as b};
|
package/dist/chunk-UFOCUHG3.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import t from'path';function o(e){return `"${e.replace(/"/g,'\\"')}"`}function n(e){let r=`scripts.${e.scriptName}=${e.scriptValue}`;return `cd ${o(e.projectPath)} && npm pkg set ${o(r)}`}function s(e){return `workspai:doctor:repair ${Buffer.from(JSON.stringify(e),"utf8").toString("base64url")}`}function d(e){return {id:`${e.issueId}.dependency-materialization`,issueId:e.issueId,title:e.title,status:"available",fixKind:"dependency-sync",risk:"guarded",canAutoFix:true,canEditFiles:false,requiresApproval:true,requiresReview:false,files:e.files.map(r=>t.join(e.projectPath,r)),command:e.command,invocation:{cwd:e.projectPath,executable:e.executable,args:[...e.args]},transaction:{schemaVersion:"workspai.doctor-dependency-repair-transaction.v1",kind:"dependency-materialization",state:"planned",projectPath:e.projectPath,ecosystem:e.ecosystem,sourceMutationRequired:false,observableState:"runtime-dependency-tree",requiredStages:["reconcile","test","build"],completion:{manifestLockConsistent:true,installedTreePresent:true,declaredTestsPass:true,declaredBuildPass:true,canonicalVerificationRequired:true}},verifyCommand:"npx workspai doctor project --json",refreshCommands:["npx workspai doctor project --json","npx workspai workspace verify --json"],reason:e.reason,limitations:e.limitations}}function m(e){let r=t.join(e.projectPath,e.relativePath),i={type:"file-create",path:r,content:e.content,overwrite:false};return {id:`${e.issueId}.file-create`,issueId:e.issueId,title:e.title,status:"available",fixKind:"file-create",risk:e.risk??"safe",canAutoFix:true,canEditFiles:true,requiresApproval:true,requiresReview:e.requiresReview??false,files:[r],command:s(i),operation:i,verifyCommand:"npx workspai doctor project --json",refreshCommands:["npx workspai doctor project --json","npx workspai workspace verify --json"],reason:e.reason,limitations:e.limitations}}function g(e){let r=t.join(e.projectPath,e.relativePath),i={type:"file-append",path:r,lines:e.lines,ensureNewline:true};return {id:`${e.issueId}.file-append`,issueId:e.issueId,title:e.title,status:"available",fixKind:"file-append",risk:e.risk??"safe",canAutoFix:true,canEditFiles:true,requiresApproval:true,requiresReview:e.requiresReview??false,files:[r],command:s(i),operation:i,verifyCommand:"npx workspai doctor project --json",refreshCommands:["npx workspai doctor project --json","npx workspai workspace verify --json"],reason:e.reason,limitations:e.limitations}}function u(e){let r=t.join(e.projectPath,e.sourceRelativePath),i=t.join(e.projectPath,e.targetRelativePath),a={type:"file-copy",sourcePath:r,path:i,overwrite:false};return {id:`${e.issueId}.file-copy`,issueId:e.issueId,title:e.title,status:"available",fixKind:"file-copy",risk:e.risk??"safe",canAutoFix:true,canEditFiles:true,requiresApproval:true,requiresReview:e.requiresReview??false,files:[r,i],command:s(a),operation:a,verifyCommand:"npx workspai doctor project --json",refreshCommands:["npx workspai doctor project --json","npx workspai workspace verify --json"],reason:e.reason,limitations:e.limitations}}function f(e){return e.lint&&e.lint.trim().length>0?"npm run lint":e.build&&e.build.trim().length>0?"npm run build":null}function y(e){let r=`frontend-script-${e.scriptName}`,i=t.join(e.projectPath,"package.json"),a=["npx workspai doctor project --json","npx workspai workspace verify --json"];return e.scriptValue?{id:`${r}.package-json-script`,issueId:r,title:`Add package.json ${e.scriptName} script`,status:"available",fixKind:"package-json-script",risk:"guarded",canAutoFix:true,canEditFiles:true,requiresApproval:true,requiresReview:false,files:[i],command:n({projectPath:e.projectPath,scriptName:e.scriptName,scriptValue:e.scriptValue}),operation:{type:"package-json-script",path:i,scriptName:e.scriptName,scriptValue:e.scriptValue},verifyCommand:"npx workspai doctor project --json",refreshCommands:a,reason:`Reuse the existing ${e.scriptValue} validation path as the ${e.scriptName} gate for ${e.frameworkDisplayName}.`}:{id:`${r}.manual`,issueId:r,title:`Define ${e.scriptName} script`,status:"manual",fixKind:"manual",risk:"guarded",canAutoFix:false,canEditFiles:false,requiresApproval:true,requiresReview:true,files:[i],refreshCommands:a,reason:`No safe ${e.frameworkDisplayName} fallback script could be inferred from existing package.json scripts.`,limitations:["Add a real test/lint/build command that matches the project quality gate before release."]}}function k(e){let r=t.join(e.projectPath,"package.json");return {id:`${e.issueId}.package-json-script`,issueId:e.issueId,title:e.title,status:"available",fixKind:"package-json-script",risk:e.risk??"guarded",canAutoFix:true,canEditFiles:true,requiresApproval:true,requiresReview:e.requiresReview??false,files:[r],command:n({projectPath:e.projectPath,scriptName:e.scriptName,scriptValue:e.scriptValue}),operation:{type:"package-json-script",path:r,scriptName:e.scriptName,scriptValue:e.scriptValue},verifyCommand:"npx workspai doctor project --json",refreshCommands:["npx workspai doctor project --json","npx workspai workspace verify --json"],reason:e.reason,limitations:e.limitations}}function v(e){let r=t.join(e.projectPath,"Makefile"),i={type:"makefile-target",path:r,target:e.targetName,command:e.command,phony:true};return {id:`${e.issueId}.makefile-target`,issueId:e.issueId,title:e.title,status:"available",fixKind:"file-append",risk:e.risk??"guarded",canAutoFix:true,canEditFiles:true,requiresApproval:true,requiresReview:e.requiresReview??true,files:[r],command:s(i),operation:i,verifyCommand:"npx workspai doctor project --json",refreshCommands:["npx workspai doctor project --json","npx workspai workspace verify --json"],reason:e.reason,limitations:e.limitations}}function j(e){return {id:`${e.issueId}.command`,issueId:e.issueId,title:e.title,status:"available",fixKind:e.fixKind??"command",risk:e.risk??"guarded",canAutoFix:true,canEditFiles:false,requiresApproval:true,requiresReview:e.requiresReview??true,files:e.files.map(r=>t.join(e.projectPath,r)),command:`cd ${o(e.projectPath)} && ${e.command}`,...e.invocation?{invocation:{cwd:e.projectPath,executable:e.invocation.executable,args:[...e.invocation.args]}}:{},...e.strategy?{strategy:e.strategy.map(r=>({...r}))}:{},...e.transaction?{transaction:structuredClone(e.transaction)}:{},verifyCommand:"npx workspai doctor project --json",refreshCommands:["npx workspai doctor project --json","npx workspai workspace verify --json"],reason:e.reason,limitations:e.limitations}}export{s as a,d as b,m as c,g as d,u as e,f,y as g,k as h,v as i,j};
|
package/dist/chunk-WD2XDMGB.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import {c,e as e$1}from'./chunk-WIO6L24E.js';import {e,d as d$1}from'./chunk-44VJHNZB.js';import {s}from'./chunk-MOSXTVPU.js';import u from'fs';import A from'path';var a=d$1.workspaceRunLast.schemaVersion,W="workspace-run-last.json",o=e.workspaceRunLast;var P=new Set(["init","test","build","start"]);function _(e){return P.has(e)}async function d(e){try{return await u.promises.access(e,u.constants.F_OK),true}catch{return false}}async function w(e){try{let r=await u.promises.readFile(e,"utf-8");return JSON.parse(r)}catch{return null}}function m(e){return !e||typeof e!="object"||Array.isArray(e)?null:e}function h(e){let r=e.stage;return typeof r!="string"||r.trim().length===0||!Array.isArray(e.projects)?false:_(r)||/^[a-z][a-z0-9_-]*$/i.test(r)}function T(e){let r=m(e);return !r||r.schemaVersion===a?false:h(r)}function C(e){let r=m(e);return r?r.schemaVersion===a&&r.stages!=null:false}function p(e){if(C(e))return e;if(T(e)){let r=e.stage;return {schemaVersion:a,generatedAt:e.generatedAt,workspacePath:e.workspacePath,latestStage:r,stages:{[r]:e},enterpriseControls:e.enterpriseControls??{jsonReady:true,evidencePath:o}}}return null}function U(e,r){let n=p(e);if(!n)return null;let t=r??n.latestStage;return n.stages[t]??null}async function V(e){let r=(await Promise.all(s(A.resolve(e),"reports",W).map(async t=>await d(t)?t:null))).find(t=>typeof t=="string");if(!r)return null;let n=await w(r);return p(n)}async function j(e,r){let n=A.resolve(e);return c(n,o,async()=>{let t=(await Promise.all(s(n,"reports",W).map(async s=>await d(s)?s:null))).find(s=>typeof s=="string"),R=t?await w(t):null,i=p(R);if(t&&!i)throw new Error(`Workspace run evidence is unreadable or invalid; refusing to overwrite: ${t}`);let l=i?{...i.stages}:{};l[r.stage]=r;let g={schemaVersion:a,generatedAt:r.generatedAt,workspacePath:r.workspacePath,latestStage:r.stage,stages:l,enterpriseControls:{jsonReady:true,evidencePath:o}};return await e$1(n,o,g),g})}export{W as a,o as b,U as c,V as d,j as e};
|
package/dist/chunk-XVRJVKOX.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import {b as b$2,c,d as d$1}from'./chunk-FZCYTRBQ.js';import {c as c$1}from'./chunk-WD2XDMGB.js';import {a as a$2,b as b$3}from'./chunk-PYCJWW4B.js';import {p as p$1,a as a$1,o,g,d as d$4,f}from'./chunk-S7Z4DP3P.js';import {p,l,f as f$1}from'./chunk-7AR5PDLD.js';import {d}from'./chunk-EWZZUQBR.js';import {d as d$3}from'./chunk-MQ73VS4E.js';import {d as d$2,e}from'./chunk-WIO6L24E.js';import {a as a$3}from'./chunk-AFIFZTOY.js';import {b as b$1,a,e as e$1,c as c$2,d as d$5}from'./chunk-44VJHNZB.js';import m from'path';import v from'fs-extra';var de="rapidkit-blocker-resolution-v1";function le(e){let t=e.blockers.map(s=>s.trim()).filter(Boolean).slice(0,12),r=e.stderrTail?.trim().slice(-400)??"";return f$1({blockers:t,exitCode:e.exitCode??null,stderrTail:r})}function he(e){let t=e.trim().toLowerCase();return t?t.includes("missing evidence")||t.includes(": missing")||t.includes("artifact missing")||t.includes("not found on disk")?"artifact-missing":t.includes("policy.")||t.includes("contract")?"config-fixable":t.includes("impact")||t.includes("untracked")||t.includes("grounding")?"semantic-attention":t.includes("failed")||t.includes("blocked")||t.includes(": fail")?"command-failed-repeat":"config-fixable":"unresolvable-without-human"}function ve(e){let t=he(e.reason),r=le({blockers:[e.reason]}),s=t==="artifact-missing"?[{actionKind:"run-once",detail:e.sourceCommand?`Run the source command once: ${e.sourceCommand}`:"Run the mapped workspace intelligence command once to generate the missing artifact.",studioActionId:"run-analyze"}]:t==="semantic-attention"?[{actionKind:"commit-files",detail:"Review workspace-level grounding files (AGENTS.md, agent-sync outputs) and commit or refresh the impact baseline."},{actionKind:"refresh-baseline",detail:"Refresh snapshot + diff + impact before re-running verify."}]:[{actionKind:"edit-file",detail:"Apply the smallest safe file or policy fix for this blocker before re-running verification.",studioActionId:"fix-lens"}];return {schemaVersion:de,blockerId:e.blockerId,sourceCommand:e.sourceCommand,sourceArtifact:e.sourceArtifact,resolutionClass:t,blockerSignature:r,commandRetryHint:t==="artifact-missing"?"Run the source command once, then verify.":"Do not re-run the same failing command; fix the source issue first, then verify.",fixHints:s,verifyCommand:e.verifyCommand,verifyArtifact:e.verifyArtifact}}function ue(e){return Array.from(new Set(e.blockingReasons.map(r=>r.trim()).filter(Boolean))).slice(0,12).map((r,s)=>ve({reason:r,blockerId:`blocker-${s+1}`,sourceCommand:e.sourceCommand,sourceArtifact:e.sourceArtifact,verifyCommand:e.verifyCommand,verifyArtifact:e.verifyArtifact}))}function be(e){let t=e.toLowerCase();return t.includes("stale")||t.includes("missing evidence")||t.includes("no projects")||t.includes("projects.empty")||t.includes("projects discovered")||t.includes("projects.missing")||t.includes("not yet run")||t.includes("doctor-last-run")||t.includes("doctor-project-last-run")||t.includes("doctor-remediation-plan-last-run")||t.includes("doctor-fix-result-last-run")||t.includes("pipeline-last-run")||t.includes("release-readiness")||t.includes("analyze-last-run")||t.includes("analyze reported")||t.includes("analyze verdict")||t.includes("analyze needs attention")||t.includes("toolchain.lock")||t.includes("not pinned")||t.includes("readiness:")||t.includes("env:")||t.includes("workspace-run-last")||t.includes("pre-project")||t.includes("before adding projects")||t.includes("workspace.projects.missing")||t.includes("no backend projects")||t.includes("index.json")||t.includes("workspace-intelligence-history")||t.includes("validation warning")||t.includes("workspace model validation")||t.includes("workspace.marker")||t.includes("no project roots")||t.includes("no infrastructure services")||t.includes("infra/overrides")||t.includes("infra dependencies")||t.includes("contract verify")||t.includes("contract inspect")||t.includes("publish verify evidence")}function we(e){return e.length===0||e.every(t=>be(t))}function fe(e){return e.projectCount>0||e.policyErrorCount>0?{verdict:e.verdict,exitCode:e.exitCode}:e.verdict==="blocked"&&we(e.blockingReasons)?{verdict:"needs-attention",exitCode:1}:{verdict:e.verdict,exitCode:e.exitCode}}function Qe(e,t){let r=t&&t!=="ready"?` (${t.replace(/-/g," ")})`:"";return e===0?`Workspace scaffold ready${r} \u2014 add your first project to continue.`:`Workspace scaffold${r}: ${e} pre-project signal(s) \u2014 add your first project to continue.`}var me=b$1.verify,G=a.verify;function Re(e,t){return m.isAbsolute(t)?t:m.join(e,t)}async function pe(e){let t=await v.readJson(e);if(!t||typeof t!="object"||Array.isArray(t))throw new Error(`Workspace impact input is not a JSON object: ${e}`);let r=t;if(r.schemaVersion!==f)throw new Error(`Unsupported workspace impact schema: ${String(r.schemaVersion)}`);a$3(t,"contracts/workspace-intelligence/workspace-impact.v1.json",`Workspace impact ${e}`);let s=r;a$3(s.diff,"contracts/workspace-intelligence/workspace-model-diff.v1.json",`Embedded workspace diff in ${e}`);let i=[];s.summary.affectedProjects!==s.affectedProjects.length&&i.push("summary.affectedProjects does not match affectedProjects.length"),s.summary.workspaceItems!==s.workspaceImpact.length&&i.push("summary.workspaceItems does not match workspaceImpact.length"),s.summary.recommendedCommands!==s.verificationPlan.length&&i.push("summary.recommendedCommands does not match verificationPlan.length"),s.summary.blastRadius.directlyAffected!==s.affectedProjects.length&&i.push("blastRadius.directlyAffected does not match affectedProjects.length"),s.summary.blastRadius.transitivelyAffected!==s.transitiveImpact.length&&i.push("blastRadius.transitivelyAffected does not match transitiveImpact.length");let o=s.transitiveImpact.reduce((u,d)=>Math.max(u,d.distance??0),0);s.summary.blastRadius.maxDistance!==o&&i.push("blastRadius.maxDistance does not match transitive impact distances");let k=l(s.diff.currentModel)?.edges.length??0;if(s.summary.blastRadius.graphEdges!==k&&i.push("blastRadius.graphEdges does not match the embedded model graph"),s.summary.changed!==s.diff.summary.changed&&i.push("summary.changed does not match embedded diff summary"),s.fromRef!==s.diff.fromRef&&i.push("fromRef does not match embedded diff fromRef"),s.workspace.name!==s.diff.currentModel.workspace.name&&i.push("workspace.name does not match the embedded model"),s.diff.toHash!==d(s.diff.currentModel)&&i.push("embedded diff current-model hash does not match toHash"),i.length>0)throw new Error(`Workspace impact semantic integrity failed: ${i.join("; ")} (${e})`);return s}function Ce(e){let t=new Set,r=[];for(let s of e){let i=`${s.scope}:${s.project??""}:${s.display}`;t.has(i)||(t.add(i),r.push(s));}return r}function Ae(e,t){if(!e||e==="workspace")return true;let r=(e.startsWith("project:")?e.slice(8):e).trim().toLowerCase();return t.scope==="workspace"?true:(t.project??"").trim().toLowerCase()===r}function Ee(e,t){if(e.id==="workspace.doctor")return m.join(t,a.doctor);if(e.id==="workspace.contract.verify")return m.join(t,a.contractVerify);if(e.id==="workspace.readiness")return m.join(t,a.readiness);if(e.id==="workspace.analyze")return m.join(t,".workspai","reports","analyze-last-run.json");if(e.id==="workspace.pipeline")return m.join(t,".workspai","reports","pipeline-last-run.json");if(e.id==="workspace.doctor-fix")return m.join(t,".workspai","reports","doctor-fix-result-last-run.json");if(e.id.startsWith("project.")&&e.id.includes("."))return m.join(t,".workspai","reports","workspace-run-last.json")}function b(e){return !e||typeof e!="object"||Array.isArray(e)?null:e}function Se(e){let t=b(e.healthScore),r=b(e.summary),s=typeof t?.errors=="number"?t.errors:0,i=typeof t?.percent=="number"?t.percent:void 0;return s>0||r?.hasSystemErrors===true?{status:"fail",message:`Doctor evidence reports ${s} error(s).`}:typeof i=="number"&&i<70?{status:"warn",message:`Doctor health score is ${i}%.`}:{status:"pass",message:"Doctor evidence is present and healthy."}}function We(e){let t=typeof e.overallStatus=="string"?e.overallStatus:"unknown";return t==="fail"?{status:"fail",message:"Release readiness evidence reports blocking failures."}:t==="warn"?{status:"warn",message:"Release readiness evidence reports warnings."}:t==="pass"?{status:"pass",message:"Release readiness evidence passed."}:{status:"warn",message:`Release readiness evidence status is ${t}.`}}function je(e){let t=typeof e.status=="string"?e.status:"unknown";return t==="failed"||t==="fail"?{status:"fail",message:"Workspace contract verify evidence failed."}:t==="passed"||t==="pass"?{status:"pass",message:"Workspace contract verify evidence passed."}:{status:"warn",message:`Workspace contract verify evidence status is ${t}.`}}function xe(e){let t=b(e.summary),r=typeof t?.verdict=="string"?t.verdict:void 0;return r==="blocked"?{status:"fail",message:"Analyze evidence reports blocking findings."}:r==="needs-attention"?{status:"warn",message:"Analyze evidence reports warnings."}:{status:"pass",message:"Analyze evidence is ready."}}function Pe(e){let t=e.schemaVersion===d$5.doctorFixResult.schemaVersion?e:e.fixResult;if(!t||typeof t!="object"||Array.isArray(t))return {status:"skipped",message:"Doctor fix result not present; run doctor workspace --fix --json to record fixes."};let r=t,s=Array.isArray(r.remainingBlockers)?r.remainingBlockers:[];if(s.length>0)return {status:"fail",message:`Doctor fix result reports ${s.length} remaining blocker(s).`};let i=Array.isArray(r.appliedFixes)?r.appliedFixes:[];return i.length===0?{status:"pass",message:"Doctor fix result recorded with no remaining blockers."}:{status:"pass",message:`Doctor fix result recorded ${i.length} applied fix(es) with no remaining blockers.`}}async function Ie(e,t){let r=await d$2(e,e$1.doctorRemediationPlan);if(!r)return false;try{let s=b(await v.readJson(r));if(!s||(Array.isArray(s.steps)?s.steps:[]).length>0)return false;let o=typeof s.generatedAt=="string"?s.generatedAt:void 0;if(!o||!t)return true;let k=Date.parse(o),u=Date.parse(t);return !Number.isFinite(k)||!Number.isFinite(u)?true:k>=u}catch{return false}}function Ve(e){return e.id.endsWith(".init")?"init":e.id.endsWith(".test")?"test":e.id.endsWith(".build")?"build":e.id.endsWith(".start")?"start":null}function Fe(e){let t=b(e.summary),r=typeof t?.verdict=="string"?t.verdict:void 0;return r==="blocked"?{status:"fail",message:"Pipeline evidence is blocked."}:r==="needs-attention"?{status:"warn",message:"Pipeline evidence needs attention."}:r==="ready"?{status:"pass",message:"Pipeline evidence is ready."}:{status:"warn",message:"Pipeline evidence status is unknown."}}function $e(e,t,r){let s=Ve(t),i=c$1(e,s??void 0);if(!i)return {status:"missing",message:"Workspace run evidence is missing or unreadable."};let o=i.stage;if(s&&o!==s)return {status:"missing",message:`Workspace run evidence is for stage "${o}", expected "${s}".`};let k=Array.isArray(i.projects)?i.projects:[],u=t.project?.toLowerCase();if(!u)return {status:"missing",message:"Project-scoped workspace run evidence is missing a project identifier."};let d=k.find(g=>{let c=b(g);if(!c)return false;let n=typeof c.projectName=="string"?c.projectName.toLowerCase():"",a=["projectPath","relativePath","path"].map(f=>c[f]).filter(f=>typeof f=="string"&&f.trim().length>0).map(f=>f.replace(/\\/g,"/").toLowerCase());return n===u||a.some(f=>f.endsWith(`/${u}`)||f===u)});if(d){let g=C(i.generatedAt,r,`Workspace run evidence for ${t.project??t.id}`);if(g)return {status:"fail",message:g};let c=b(d),n=typeof c?.status=="string"?c.status:"unknown";return n==="failed"?{status:"fail",message:`Workspace run evidence failed for ${t.project}.`}:n==="passed"?{status:"pass",message:`Workspace run evidence passed for ${t.project}.`}:n==="skipped"?{status:"warn",message:`Workspace run evidence skipped for ${t.project}.`}:{status:"warn",message:`Workspace run evidence status is ${n} for ${t.project}.`}}return {status:"missing",message:`Workspace run evidence does not include project ${t.project}.`}}function C(e,t,r){if(!t)return null;if(typeof e!="string"||e.trim().length===0)return `${r} is stale: missing generatedAt timestamp (required after impact ${t}).`;let s=Date.parse(e),i=Date.parse(t);return Number.isFinite(s)?Number.isFinite(i)&&s<i?`${r} is stale: generated at ${e}, before impact ${t}.`:null:`${r} is stale: invalid generatedAt timestamp (required after impact ${t}).`}function Oe(e){if(e.id==="workspace.doctor")return c$2.doctor;if(e.id==="workspace.readiness")return c$2.readiness;if(e.id==="workspace.contract.verify")return c$2.contractVerify;if(e.id==="workspace.analyze")return c$2.analyze;if(e.id==="workspace.pipeline")return "contracts/pipeline-last-run.v1.json"}async function _e(e,t,r,s){let i=Ee(e,t),o=i?m.relative(t,i).split(m.sep).join("/"):void 0;if(e.id==="workspace.contract.verify"&&!r)return {id:e.id,label:e.label,scope:e.scope,project:e.project,command:e,status:"skipped",required:e.required,message:"Workspace contract is not present; contract verify skipped."};let k=i?await d$2(t,o??""):null;if(!i||!k)return {id:e.id,label:e.label,scope:e.scope,project:e.project,command:e,status:"missing",required:e.required,evidencePath:o,message:o?`Missing evidence report: ${o}`:"No evidence mapping exists for this command."};let u;try{u=await v.readJson(k);}catch(n){return {id:e.id,label:e.label,scope:e.scope,project:e.project,command:e,status:"fail",required:e.required,evidencePath:o,message:`Evidence report is unreadable JSON: ${n instanceof Error?n.message:String(n)}`}}let d=b(u);if(!d)return {id:e.id,label:e.label,scope:e.scope,project:e.project,command:e,status:"fail",required:e.required,evidencePath:o,message:"Evidence report is not a JSON object."};let g=Oe(e);if(g)try{a$3(d,g,`${e.label} evidence`);}catch(n){return {id:e.id,label:e.label,scope:e.scope,project:e.project,command:e,status:"fail",required:e.required,evidencePath:o,message:`Evidence report is invalid: ${n instanceof Error?n.message:String(n)}`}}let c;if(e.id==="workspace.doctor"){let n=C(d.generatedAt,s,"Doctor evidence");n?c={status:"fail",message:n}:c=Se(d);}else if(e.id==="workspace.readiness"){let n=C(d.generatedAt,s,"Release readiness evidence");n?c={status:"fail",message:n}:c=We(d);}else if(e.id==="workspace.contract.verify"){let n=C(d.generatedAt,s,"Workspace contract verify evidence");n?c={status:"fail",message:n}:c=je(d);}else if(e.id==="workspace.analyze"){let n=C(d.generatedAt,s,"Analyze evidence");n?c={status:"fail",message:n}:c=xe(d);}else if(e.id==="workspace.pipeline"){let n=C(d.generatedAt,s,"Pipeline evidence");n?c={status:"fail",message:n}:c=Fe(d);}else if(e.id==="workspace.doctor-fix"){let n=d.schemaVersion===d$5.doctorFixResult.schemaVersion?d:d.fixResult,a=b(n),f=typeof a?.generatedAt=="string"?a.generatedAt:void 0,y=C(f,s,"Doctor fix result");y?c={status:"fail",message:y}:await Ie(t,f)?c={status:"skipped",message:"No current doctor remediation steps are pending."}:c=Pe(d);}else if(e.id.startsWith("project."))c=$e(d,e,s);else {let n=C(d.generatedAt,s,"Evidence report");n?c={status:"fail",message:n}:c={status:"pass",message:"Evidence report is present."};}return {id:e.id,label:e.label,scope:e.scope,project:e.project,command:e,status:c.status,required:e.required,evidencePath:o,message:c.message}}function Be(e,t={blockingReasons:[],needsAttention:false}){let r=e.filter(n=>n.status==="pass").length,s=e.filter(n=>n.status==="warn").length,i=e.filter(n=>n.status==="fail").length,o=e.filter(n=>n.status==="missing").length,k=e.filter(n=>n.status==="skipped").length,u=e.filter(n=>n.required&&(n.status==="fail"||n.status==="missing")).map(n=>`${n.id}: ${n.message}`),d=e.filter(n=>n.required&&n.status==="missing").length,g="ready",c=0;return u.length>0||t.blockingReasons.length>0?(g="blocked",c=2):(s>0||e.some(n=>!n.required&&n.status==="fail")||d>0||t.needsAttention)&&(g="needs-attention",c=1),{verdict:g,exitCode:c,stepsPassed:r,stepsWarn:s,stepsFailed:i,stepsMissing:o,stepsSkipped:k}}function Ne(e,t){let r=W(e.affectedProjects.map(a=>a.project?.name).filter(a=>typeof a=="string")),s=new Set(r.map(a=>a.toLowerCase())),i=W(e.transitiveImpact.map(a=>a.project?.name).filter(a=>typeof a=="string").filter(a=>!s.has(a.toLowerCase()))),o=new Map;for(let a of t){if(a.scope!=="project"||!a.project)continue;let f=a.project.toLowerCase(),y=o.get(f)??[];y.push(a),o.set(f,y);}let k=[],u=[],d=[],g=[],c=false,n=(a,f)=>{let y=o.get(a.toLowerCase())??[];if(y.length===0){d.push(a);return}let j=y.filter(p=>p.status==="fail"),w=j.filter(p=>p.required),x=y.filter(p=>p.status==="missing"),A=x.filter(p=>p.required),P=y.some(p=>p.status==="pass"||p.status==="warn");if(w.length>0){u.push(a),g.push(`graph.subgraph.${a}: ${f} has failed verification evidence (${w.map(p=>p.id).join(", ")}).`);return}if(j.length>0){u.push(a),c=true;return}if(A.length>0){u.push(a),g.push(`graph.subgraph.${a}: ${f} has missing required verification evidence (${A.map(p=>p.id).join(", ")}).`);return}if(x.length>0){u.push(a),c=true;return}if(P){k.push(a);return}d.push(a);};for(let a of r)n(a,"directly-changed");for(let a of i)n(a,"transitive dependent");return {subgraph:{totalProjects:r.length+i.length,directlyChanged:r,transitiveDependents:i,covered:W(k),uncovered:W(u),unverifiable:W(d)},blockingReasons:g,needsAttention:c}}function W(e){return [...new Set(e)].sort((t,r)=>t.localeCompare(r))}async function De(e){let t=m.resolve(e.workspacePath);if(e.fromImpactPath){let o=Re(t,e.fromImpactPath);return {impact:await pe(o),fromImpactRef:m.relative(t,o).split(m.sep).join("/"),impactFromDisk:true}}let r=m.join(t,g);if(await v.pathExists(r))return {impact:await pe(r),fromImpactRef:g,impactFromDisk:true};let s=m.join(t,d$4);if(await v.pathExists(s))return {impact:await p$1({workspacePath:t,fromPath:d$4,scope:e.scope,includeAbsolutePaths:e.includeAbsolutePaths,includeEvidence:e.includeEvidence,observableScanDepth:e.observableScanDepth,now:e.now}),fromImpactRef:d$4,impactFromDisk:false};let i=await p({workspacePath:t,includeAbsolutePaths:e.includeAbsolutePaths,includeEvidence:e.includeEvidence,observableScanDepth:e.observableScanDepth,now:e.now});return {impact:{schemaVersion:f,generatedAt:(e.now??new Date).toISOString(),fromRef:"baseline",diffRef:a.diff,workspace:{name:i.workspace.name,profile:i.workspace.profile,type:i.workspace.type},summary:{changed:false,risk:"none",affectedProjects:0,workspaceItems:0,recommendedCommands:0,blastRadius:{directlyAffected:0,transitivelyAffected:0,maxDistance:0,graphEdges:l(i)?.edges.length??0}},affectedProjects:[],transitiveImpact:[],criticalPathHotspots:[],workspaceImpact:[],verificationPlan:[],agentBrief:{headline:"Baseline workspace verify run.",bullets:["No impact report or snapshot was available; baseline gates were evaluated."],unsafeAssumptions:["Do not claim runtime verification passed unless evidence exists."]},diff:{schemaVersion:b$1.diff,generatedAt:(e.now??new Date).toISOString(),fromRef:"baseline",toRef:a.model,fromHash:"baseline",toHash:"baseline",summary:{changed:false,addedProjects:0,removedProjects:0,changedProjects:0,workspaceChanges:0,validationChanges:0,gitChangedFiles:0},git:{available:false,dirty:false,changedFiles:0,untrackedFiles:0,deletedFiles:0},changes:[],currentModel:i}},impactFromDisk:false}}function He(e,t){if(t)return e.generatedAt}async function gt(e){let t=m.resolve(e.workspacePath),{impact:r,fromImpactRef:s,impactFromDisk:i}=await De(e),o$1=r.diff.currentModel,k=i?await p({workspacePath:t,includeAbsolutePaths:e.includeAbsolutePaths,includeEvidence:e.includeEvidence,observableScanDepth:e.observableScanDepth,now:e.now}):o$1,u=[];if(i){let l=await p$1({workspacePath:t,fromPath:r.diff.fromRef,diff:r.diff,scope:e.scope,now:e.now}),B=[r.affectedProjects,r.transitiveImpact,r.verificationPlan],N=[l.affectedProjects,l.transitiveImpact,l.verificationPlan];JSON.stringify(B)!==JSON.stringify(N)&&u.push("workspace.impact: Persisted impact semantics do not match the impact re-derived from the embedded diff. Regenerate diff and impact.");}i&&d(k)!==r.diff.toHash&&u.push("workspace.impact: Impact evidence is stale because the current workspace model no longer matches the embedded model. Regenerate diff and impact.");let d$2=r.diff.git;if(i&&d$2?.available){let l=a$1(t,{ref:d$2.ref}),B=r.diff.changes.filter(h=>h.type.startsWith("git.")).map(h=>`${h.type}:${h.target.replace(/^git:/,"")}`).sort(),N=[...l.changedFiles.map(h=>`git.file.changed:${h}`),...l.untrackedFiles.map(h=>`git.untracked:${h}`),...l.deletedFiles.map(h=>`git.deleted:${h}`)].sort();(!l.available||l.commit!==d$2.commit||JSON.stringify(N)!==JSON.stringify(B))&&u.push("workspace.impact: Impact evidence is stale because Git changes no longer match the diff observation. Regenerate diff and impact.");}let g=He(r,i),c$1=Ce([...o(),...r.verificationPlan]).filter(l=>Ae(e.scope,l)),n=[];for(let l of c$1)n.push(await _e(l,t,o$1.contracts.exists===true,g));let a=Ne(r,n),f=a$2(l(o$1)??{nodes:[],edges:[]}),y=b$2(o$1),j=await Le(t),w=c(y,j?.freshness?.projectHashes),x={verdict:w.verdict,baseline:w.baseline,changed:w.changed,added:w.added,removed:w.removed,projectHashes:d$1(y)},A=b$3(f),P=o$1.policies?.mode??"warn",p$2=await Me(o$1,t),_=Te(P,p$2),E=Be(n,{blockingReasons:[...a.blockingReasons,...A,..._.blockingReasons,...u],needsAttention:a.needsAttention||_.needsAttention}),ge=n.filter(l=>l.status==="missing"&&l.evidencePath).map(l=>l.evidencePath),I=[...n.filter(l=>l.required&&(l.status==="fail"||l.status==="missing")).map(l=>`${l.id}: ${l.message}`),...a.blockingReasons,...A,..._.blockingReasons,...u],ke=p$2.filter(l=>l.severity==="error").length,ye=o$1.summary?.projectCount??o$1.projects.length,U=fe({projectCount:ye,verdict:E.verdict,exitCode:E.exitCode,blockingReasons:I,policyErrorCount:ke});E.verdict=U.verdict,E.exitCode=U.exitCode;let Y=I.length>0?ue({blockingReasons:I,verifyCommand:"npx workspai workspace verify --from-impact .workspai/reports/workspace-impact-last-run.json --json",verifyArtifact:G}):[];return {schemaVersion:me,generatedAt:(e.now??new Date).toISOString(),workspacePath:t,mode:"evidence",fromImpactRef:s,scope:e.scope,impact:{changed:r.summary.changed,risk:r.summary.risk,affectedProjects:r.summary.affectedProjects,recommendedCommands:r.summary.recommendedCommands},summary:E,steps:n,missingEvidence:ge,blockingReasons:I,...Y.length>0?{resolutionHints:Y}:{},verificationPlan:c$1,affectedSubgraph:a.subgraph,graphIntegrity:f,freshness:x,policyMode:P,policyViolations:p$2}}async function Me(e,t){let r=[];for(let i of e.validation?.issues??[])r.push({source:"model",severity:i.severity,code:i.code,message:i.message,target:i.target});let s=await d$2(t,a.contractVerify);try{if(s&&await v.pathExists(s)){let i=await v.readJson(s);if(Array.isArray(i.violations))for(let o of i.violations)typeof o=="string"&&o.trim().length>0&&r.push({source:"contract",severity:"error",code:"contract.violation",message:o});}}catch{}return r.sort((i,o)=>i.source!==o.source?i.source.localeCompare(o.source):i.code!==o.code?i.code.localeCompare(o.code):i.message.localeCompare(o.message))}function Te(e,t){let r=t.filter(s=>s.severity==="error");return e==="enforce"&&r.length>0?{blockingReasons:r.map(s=>`policy.${s.code}: ${s.message}`),needsAttention:false}:{blockingReasons:[],needsAttention:r.length>0}}async function Le(e){let t=m.join(e,G);try{if(!await v.pathExists(t))return null;let r=await v.readJson(t);return r&&r.schemaVersion===me?r:null}catch{return null}}async function kt(e$1,t){return e(t,G,d$3(e$1))}function qe(e,t){let r=t?.strict?"strict":"default",s=[];if(e.summary.verdict==="blocked")return s.push(...e.blockingReasons),s.length===0&&s.push("verify verdict is blocked."),{passed:false,mode:r,exitCode:2,reasons:s};if(r==="strict"){if(e.summary.verdict!=="ready"&&s.push(`verify verdict is ${e.summary.verdict} (strict requires ready).`),e.freshness.verdict==="stale"){let i=[...e.freshness.changed,...e.freshness.added].slice(0,5);s.push(`freshness is stale${i.length>0?`: ${i.join(", ")}`:""} (strict requires fresh).`);}if(s.length>0)return {passed:false,mode:r,exitCode:1,reasons:s}}return {passed:true,mode:r,exitCode:0,reasons:s}}function yt(e,t){return qe(e,t).exitCode}export{de as a,Qe as b,me as c,G as d,Ne as e,gt as f,kt as g,qe as h,yt as i};
|
package/dist/doctor-UEFFNAUD.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export{a as DOCTOR_WORKSPACE_REPORT_PATH,m as applyEnvKeyAddFix,i as applyFileAppendFix,j as applyFileCopyFix,h as applyFileCreateFix,l as applyJsonEditFix,n as applyMakefileTargetFix,g as applyPackageScriptFix,f as assertOperationPathInsideProject,e as buildRepairOperationIdentity,p as computeDoctorFixAwareExitCode,o as computeDoctorGateExitCode,k as decodeJsonPointerSegment,d as parseInternalRepairCommand,c as parsePackageScriptFix,b as resolveDoctorPolicyProfile,q as runDoctor}from'./chunk-CEIJIFY7.js';
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import {a as a$3}from'./chunk-KVUYAYTY.js';import {c}from'./chunk-DPMO4U3Z.js';import {q}from'./chunk-CEIJIFY7.js';import {c as c$1}from'./chunk-FPJNWPKU.js';import {a as a$4}from'./chunk-RMXXK64P.js';import {f,e as e$1}from'./chunk-T3GJ7YVG.js';import {a}from'./chunk-MRFN5ZQP.js';import {g}from'./chunk-WSAFBPS5.js';import {d,a as a$2,e as e$2}from'./chunk-WIO6L24E.js';import {a as a$1,e,d as d$1}from'./chunk-44VJHNZB.js';import c$2 from'chalk';import h from'path';import I from'fs-extra';function O(s){return s===0?"pass":s===2?"warn":"fail"}async function G(s){try{let r=I.readJsonSync(s),i=r.policyProfile,o=(Array.isArray(r.projects)?r.projects:[]).flatMap(u=>{let l=u,m=typeof l.name=="string"?l.name:"project",f=Array.isArray(l.issues)?l.issues.filter(p=>typeof p=="string"):[],P=(Array.isArray(l.probes)?l.probes:[]).flatMap(p=>{let g=p;if(g.status!=="fail"&&g.status!=="warn")return [];let y=typeof g.reason=="string"?g.reason.trim():"";return y?[`${m}: ${y}`]:[]});return [...f.map(p=>`${m}: ${p}`),...P]});return {policyProfile:typeof i?.name=="string"?i.name:void 0,blockers:[...new Set(o)].slice(0,12)}}catch{return {blockers:[]}}}function L(s){return s.some(r=>r.status==="fail")?"blocked":s.some(r=>r.status==="warn")?"needs-attention":"ready"}function _(s,r){if(r)return 3;let i=s.some(o=>o.status==="fail"),t=s.some(o=>o.status==="warn");return i?1:t?2:0}function V(s,r){return s===2&&!r?0:s}async function K(s){let r=await g(s,true),i=false;try{let{syncWorkspaceContract:t}=await import('./workspace-contract-AYFTZIKM.js');await t({workspacePath:s}),i=true;}catch{i=false;}return {sync:r,contractSynced:i}}async function J(s={}){let r=h.resolve(s.workspacePath??process.cwd()),i=a(r);if(!i)throw new Error("No Workspai workspace found in current directory or parents");let t=[],o=[],u=false,l,m,f$1,k=Date.now();try{let{sync:e,contractSynced:a}=await K(i),n=e.workspaceFound&&(e.added.length>0||e.skipped>=0)||e.workspaceFound?"pass":"warn";t.push({name:"sync",status:n,durationMs:Date.now()-k,summary:e.workspaceFound?`registry sync complete (${e.added.length} added, ${e.skipped} existing)${a?", 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){u=true,t.push({name:"sync",status:"fail",durationMs:Date.now()-k,summary:`sync failed: ${e instanceof Error?e.message:String(e)}`}),o.push("workspace sync stage failed");}let P=Date.now();try{let e=await q({workspace:true,json:true,quiet:true,strict:s.strict===true,ci:s.strict!==true}),a=O(e),n=await d(i,a$1.doctor)??a$2(i,a$1.doctor),d$1=await G(n);t.push({name:"doctor",status:a,durationMs:Date.now()-P,summary:a==="pass"?"doctor workspace passed":a==="warn"?"doctor workspace reported warnings":"doctor workspace did not pass",exitCode:e,evidencePath:n,policyProfile:d$1.policyProfile,blockers:d$1.blockers}),a==="fail"?o.push(...d$1.blockers.length>0?d$1.blockers.map(j=>`doctor: ${j}`):["doctor workspace gate failed"]):a==="warn"&&o.push("doctor workspace reported warnings");}catch(e){u=true,t.push({name:"doctor",status:"fail",durationMs:Date.now()-P,summary:`doctor failed: ${e instanceof Error?e.message:String(e)}`}),o.push("doctor workspace stage failed");}if(s.skipAnalyze)t.push({name:"analyze",status:"skipped",durationMs:0,summary:"analyze stage skipped"});else {let e=Date.now();try{let a=await a$3({workspacePath:i,json:true,strict:s.strict===true});l=h.isAbsolute(a.enterpriseControls.evidencePath)?a.enterpriseControls.evidencePath:h.join(i,a.enterpriseControls.evidencePath);let n=a.summary.verdict==="blocked"?"fail":a.summary.verdict==="needs-attention"?"warn":"pass";t.push({name:"analyze",status:n,durationMs:Date.now()-e,summary:`analyze verdict: ${a.summary.verdict} (score ${a.summary.score}/100)`,evidencePath:l}),n==="fail"?o.push("analyze reported blocked verdict"):n==="warn"&&o.push("analyze reported needs-attention verdict");}catch(a){u=true,t.push({name:"analyze",status:"fail",durationMs:Date.now()-e,summary:`analyze failed: ${a instanceof Error?a.message:String(a)}`}),o.push("analyze stage failed");}}let p=Date.now();try{let e=await a$4({startPath:i,writeReport:true,skipVerify:s.skipVerify===true});m=e.evidencePath;let a=e.overallStatus==="pass"?"pass":e.overallStatus==="warn"?"warn":"fail";t.push({name:"readiness",status:a,durationMs:Date.now()-p,summary:`readiness overall: ${e.overallStatus}`,evidencePath:e.evidencePath}),a==="fail"?o.push(...e.blockingReasons.map(n=>`readiness: ${n}`)):a==="warn"&&o.push(...e.gates.filter(n=>n.status==="warn").map(n=>`readiness warn: ${n.gate}: ${n.summary}`));}catch(e){u=true,t.push({name:"readiness",status:"fail",durationMs:Date.now()-p,summary:`readiness failed: ${e instanceof Error?e.message:String(e)}`}),o.push("readiness stage failed");}if(s.skipAutopilot)t.push({name:"autopilot",status:"skipped",durationMs:0,summary:"autopilot stage skipped"});else {let e=Date.now(),a=s.autopilotMode??"audit";try{let n=await c({workspacePath:i,mode:a,json:true,skipPipelineStages:true});f$1=n.artifacts.reportPath;let d=n.summary.verdict==="approved"?"pass":n.summary.verdict==="partial"?"warn":"fail";t.push({name:"autopilot",status:d,durationMs:Date.now()-e,summary:`autopilot ${a}: ${n.summary.verdict}`,exitCode:n.summary.exitCode,evidencePath:f$1}),d!=="pass"&&o.push(...n.blockingReasons.slice(0,5));}catch(n){u=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 g=L(t),y=_(t,u),N=h.join(i,e.pipelineLastRun),w={schemaVersion:d$1.pipelineLastRun.schemaVersion,generatedAt:new Date().toISOString(),workspacePath:i,summary:{verdict:g,exitCode:y,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:N,analyzeEvidencePath:l,readinessEvidencePath:m,autopilotEvidencePath:f$1}};if(s.writeReport!==false){let e$3=f(w,{commandId:"workspacePipeline",exitCode:y,generatedAt:w.generatedAt,blockers:w.blockingReasons,runId:e$1()});await e$2(i,e.pipelineLastRun,e$3);}if(s.writeReport!==false&&s.noAgentSync!==true&&process.env.RAPIDKIT_NO_AGENT_SYNC!=="1"&&s.agentSync!==false)try{let{syncWorkspaceAgentGrounding:e}=await import('./workspace-agent-sync-446AXPHJ.js'),a=await e({workspacePath:i,write:true,refreshContext:true,strict:false});w.agentGrounding={indexPath:a.indexPath,writtenFiles:a.writtenFiles,blockers:a.blockers};}catch{}return w}async function ce(s){let r;try{r=await J(s);}catch(t){let o=t instanceof Error?t.message:String(t);s.json?console.log(JSON.stringify(c$1({operation:"pipeline",code:"pipeline.failed",message:o}),null,2)):console.log(c$2.red(`Pipeline failed: ${o}`)),process.exit(1);}if(s.json)console.log(JSON.stringify(r,null,2));else {console.log(c$2.bold.cyan(`
|
|
2
|
-
\u{1F517} Workspai Governance Pipeline
|
|
3
|
-
`)),console.log(c$2.bold(`Workspace: ${c$2.cyan(h.basename(r.workspacePath))}`)),console.log(c$2.gray(`Path: ${r.workspacePath}`)),console.log(c$2.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$2.green("PASS"):t.status==="warn"?c$2.yellow("WARN"):t.status==="skipped"?c$2.gray("SKIP"):c$2.red("FAIL");console.log(` - ${t.name}: ${o} ${t.summary}`);}if(r.blockingReasons.length>0){console.log(c$2.bold(`
|
|
4
|
-
Blocking reasons:`));for(let t of r.blockingReasons.slice(0,8))console.log(c$2.gray(` \u2022 ${t}`));}console.log(c$2.gray(`
|
|
5
|
-
Evidence: ${r.artifacts.reportPath}`)),r.agentGrounding?.writtenFiles.length&&console.log(c$2.gray(`Agent grounding: ${r.agentGrounding.writtenFiles.length} file(s) synced (INDEX + AGENTS.md + Copilot/Cursor/Claude hooks)`));}let i=V(r.summary.exitCode,s.strict===true);i!==0&&process.exit(i);}export{V as pipelineProcessExitCode,J as runPipeline,ce as runPipelineCommand};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export{b as PROJECT_TEST_COVERAGE_ARTIFACT,a as PROJECT_TEST_COVERAGE_SCHEMA,c as collectProjectTestCoverage}from'./chunk-SJLUE6AY.js';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import {c}from'./chunk-DS4UYMLX.js';import {a as a$3}from'./chunk-7S4QNH5A.js';import {c as c$1}from'./chunk-SJLUE6AY.js';import {a as a$2}from'./chunk-RMXXK64P.js';import {p}from'./chunk-7AR5PDLD.js';import {a as a$4}from'./chunk-GR6442P7.js';import {e,d}from'./chunk-WIO6L24E.js';import {a as a$1}from'./chunk-AFIFZTOY.js';import {a,b}from'./chunk-44VJHNZB.js';import {createHash}from'crypto';import l from'path';import y from'fs-extra';var W="workspai.verified-goal.v1",x=b.verifiedGoalStatus,C=a.verifiedGoalStatus,J="contracts/workspace-intelligence/verified-goal.v1.json",G="contracts/workspace-intelligence/verified-goal-status.v1.json";function A(e){return Array.isArray(e)?`[${e.map(A).join(",")}]`:e&&typeof e=="object"?`{${Object.entries(e).sort(([t],[a])=>t.localeCompare(a)).map(([t,a])=>`${JSON.stringify(t)}:${A(a)}`).join(",")}}`:JSON.stringify(e)}function H(e){return createHash("sha256").update(A(e)).digest("hex")}var te=["package.json","package-lock.json","npm-shrinkwrap.json","pnpm-lock.yaml","yarn.lock","bun.lock","bun.lockb","pyproject.toml","requirements.txt","Pipfile","Pipfile.lock","poetry.lock","uv.lock","go.mod","go.sum","Cargo.toml","Cargo.lock","pom.xml","build.gradle","build.gradle.kts","gradle.lockfile","packages.lock.json","Directory.Packages.props","composer.json","composer.lock","Gemfile","Gemfile.lock","mix.exs","mix.lock","deps.edn","project.clj","build.sbt"],ae=new Set(te.map(e=>e.toLowerCase())),se=new Set([".git",".hg",".svn",".workspai",".venv","venv",".tox",".mypy_cache",".pytest_cache","__pycache__","node_modules","vendor","pods","dist","build","out","target","bin","obj","coverage",".coverage",".next",".nuxt",".svelte-kit"]),F=1e5;function ne(e){return ae.has(e.toLowerCase())||/\.(?:csproj|fsproj|vbproj)$/i.test(e)}async function re(e){let t=[e],a=[],s=0;for(;t.length>0;){let o=t.shift();if(o===void 0)break;let i=await y.readdir(o,{withFileTypes:true});if(i.sort((n,r)=>n.name.localeCompare(r.name)),s+=i.length,s>F)throw new Error(`Dependency safety baseline exceeded ${F} filesystem entries under ${e}. Narrow the project boundary before creating this goal.`);for(let n of i){let r=l.join(o,n.name);if(n.isDirectory()){!se.has(n.name.toLowerCase())&&!a$4(n.name)&&t.push(r);continue}n.isFile()&&ne(n.name)&&a.push(r);}}return a}function ie(e){return /^(?:package\.json|package-lock\.json|npm-shrinkwrap\.json|pnpm-lock\.yaml|yarn\.lock|bun\.lockb?)$/i.test(e)?"node":/^(?:pyproject\.toml|requirements\.txt|Pipfile(?:\.lock)?|poetry\.lock|uv\.lock)$/i.test(e)?"python":/^go\.(?:mod|sum)$/i.test(e)?"go":/^Cargo\.(?:toml|lock)$/i.test(e)?"rust":/^(?:pom\.xml|build\.gradle(?:\.kts)?|gradle\.lockfile)$/i.test(e)?"jvm":/^(?:Directory\.Packages\.props|packages\.lock\.json)$/i.test(e)?"dotnet":/^composer\.(?:json|lock)$/i.test(e)?"php":/^Gemfile(?:\.lock)?$/i.test(e)?"ruby":/^mix\.(?:exs|lock)$/i.test(e)?"elixir":/^(?:deps\.edn|project\.clj)$/i.test(e)?"clojure":/^build\.sbt$/i.test(e)?"scala":/\.(?:csproj|fsproj|vbproj)$/i.test(e)?"dotnet":"unknown"}function K(e){try{let t=JSON.parse(e),a={};for(let s of ["dependencies","devDependencies","peerDependencies","optionalDependencies"]){let o=t[s];if(!(!o||typeof o!="object"||Array.isArray(o)))for(let[i,n]of Object.entries(o))typeof n=="string"&&(a[`${s}:${i}`]=n);}return a}catch{return}}async function U(e,t){let s=(await p({workspacePath:e,includeAbsolutePaths:true})).projects.filter(i=>t.kind==="workspace"||i.name===t.projectName||l.resolve(e,i.path)===l.resolve(t.projectPath??"")),o=new Map;for(let i of s){let n=l.resolve(e,i.path),r=await re(n);for(let c of r){let p=l.basename(c),f=await y.readFile(c,"utf8"),d=l.relative(e,c).split(l.sep).join("/");o.set(d,{path:d,ecosystem:ie(p),sha256:createHash("sha256").update(f).digest("hex"),...p==="package.json"?{dependencies:K(f)??{}}:{}});}}return {manifests:[...o.values()].sort((i,n)=>i.path.localeCompare(n.path))}}function O(e){let a=e.replace(/^(?:workspace:|npm:[^@]+@)/,"").match(/(?:^|[^\d])(\d+)(?:\.\d+)?(?:\.\d+)?/);return a?Number(a[1]):null}function S(e){return /(?:^|\/)(?:package-lock\.json|npm-shrinkwrap\.json|pnpm-lock\.yaml|yarn\.lock|bun\.lockb?|poetry\.lock|uv\.lock|Pipfile\.lock|go\.sum|Cargo\.lock|gradle\.lockfile|packages\.lock\.json|composer\.lock|Gemfile\.lock|mix\.lock)$/i.test(e)}async function oe(e){let t=e.dependencySafetyBaseline;if(!t)return k({id:"change-policy",label:"Change safety policy",status:"missing",expected:"dependency manifest safety baseline",actual:"baseline unavailable"});let a=[],s=await U(e.workspace.path,e.scope),o=new Map(s.manifests.map(r=>[r.path,r])),i=new Map(t.manifests.map(r=>[r.path,r])),n=new Set;for(let r of t.manifests){let c=o.get(r.path);(!c||c.sha256!==r.sha256)&&n.add(r.path);}for(let r of s.manifests)i.has(r.path)||n.add(r.path);for(let r of s.manifests)!i.has(r.path)&&!S(r.path)&&a.push(`${r.path} was added after the safety baseline`);for(let r of t.manifests){let c=o.get(r.path);if(!c){a.push(`${r.path} was removed`);continue}if(c.sha256===r.sha256)continue;if(r.dependencies){let d=await y.readFile(l.join(e.workspace.path,r.path),"utf8"),m=K(d);if(!m){a.push(`${r.path} is not valid dependency JSON`);continue}for(let[u,g]of Object.entries(r.dependencies)){let h=m[u];if(!h){a.push(`${u.replace(/^[^:]+:/,"")} was removed`);continue}if(h===g)continue;let $=O(g),R=O(h);($===null||R===null||$!==R||/(?:latest|\*)/i.test(h))&&a.push(`${u.replace(/^[^:]+:/,"")} changed outside its proven major range (${g} \u2192 ${h})`);}continue}if(S(r.path))continue;let p=l.posix.dirname(r.path);[...o.values()].some(d=>{let m=l.posix.dirname(d.path);return d.ecosystem===r.ecosystem&&(m===p||p.startsWith(`${m}/`))&&S(d.path)&&n.has(d.path)})||a.push(`${r.path} changed without a matching reconciled ${r.ecosystem} lockfile`);}return k({id:"change-policy",label:"Change safety policy",status:a.length===0?"passed":"blocked",expected:"no force, removal, unbounded, or major dependency changes",actual:a.length===0?"manifest changes are within proven bounds":a.join("; ")})}function E(e,t){if(!/^[a-z0-9][a-z0-9._-]{7,95}$/i.test(t))throw new Error(`Invalid verified goal id: ${t}`);let a=l.join(e,".workspai","goals",t);return {directory:a,goal:l.join(a,"goal.json"),status:l.join(a,"status.json"),latestReport:l.join(e,C)}}function ce(e){return {workspacePath:l.resolve(e.workspace.path),kind:e.kind,scope:e.scope,target:e.criteria.kind==="test-coverage"?e.criteria.minimumPercent:null,constraints:e.constraints}}async function V(e,t){await y.ensureDir(l.dirname(e));let a=`${e}.${process.pid}.${Date.now()}.tmp`;await y.writeJson(a,t,{spaces:2}),await y.rename(a,e);}async function le(e,t){let a=t?.trim();if(!a||a==="workspace")return {scope:{kind:"workspace"}};let s=a.startsWith("project:")?a.slice(8).trim():a;if(!s)throw new Error("Project goal scope must name a project.");let i=(await p({workspacePath:e,includeAbsolutePaths:true})).projects.filter(c=>{let p=l.resolve(e,c.path);return c.name===s||c.path===s||p===l.resolve(s)});if(i.length!==1)throw new Error(i.length===0?`Project goal scope was not found: ${s}`:`Project goal scope is ambiguous: ${s}`);let n=i[0],r=l.resolve(e,n.path);return {project:n,scope:{kind:"project",projectName:n.name,projectPath:r}}}function z(e,t,a){return e===null?"unavailable":a==="minimum"?e>=t?"satisfied":"unsatisfied":e<=t?"satisfied":"unsatisfied"}async function Y(e){if(!e)return null;try{let t=await y.readJson(e);return t&&typeof t=="object"&&!Array.isArray(t)?t:null}catch{return null}}function de(e){return Array.isArray(e.projects)?e.projects.filter(t=>!!t&&typeof t=="object"&&!Array.isArray(t)):e.project&&typeof e.project=="object"&&!Array.isArray(e.project)?[e.project]:[]}function ue(e){let t=e.dependencyAudit;return t&&typeof t=="object"&&!Array.isArray(t)?t:null}async function X(e,t){let a$1=await d(e,a.doctor),s=await Y(a$1);if(!s)return {measuredAt:new Date().toISOString(),value:null,target:0,unit:"blocking-vulnerabilities",status:"unavailable",evidencePaths:[],message:"Fresh Doctor dependency evidence is not available."};let o=de(s).filter(c=>{if(t.kind==="workspace")return true;let p=typeof c.name=="string"?c.name:typeof c.projectName=="string"?c.projectName:"",f=typeof c.path=="string"?l.resolve(c.path):typeof c.projectPath=="string"?l.resolve(c.projectPath):"";return p===t.projectName||t.projectPath!==void 0&&f===l.resolve(t.projectPath)}),i=o.map(ue).filter(c=>c!==null),n=i.map(c=>c.blockingFindingCount).filter(c=>Number.isInteger(c)&&Number(c)>=0),r=o.length>0&&n.length===o.length?n.reduce((c,p)=>c+p,0):null;return {measuredAt:(()=>{let c=i.map(p=>p.generatedAt).filter(p=>typeof p=="string").sort();return c[c.length-1]??new Date().toISOString()})(),value:r,target:0,unit:"blocking-vulnerabilities",status:z(r,0,"maximum"),evidencePaths:a$1?[a$1]:[],message:r===null?"Doctor did not publish complete dependency audit counts for the selected scope.":`${r} blocking dependency vulnerability finding(s) remain.`}}async function Q(e){let t=await a$2({startPath:e,writeReport:false}),a=t.gates.filter(o=>o.status==="pass").length,s=t.gates.length;return {measuredAt:t.generatedAt,value:a,target:s,unit:"gates",status:t.overallStatus==="pass"?"satisfied":"unsatisfied",evidencePaths:[...new Set(t.gates.map(o=>o.evidencePath).filter(o=>typeof o=="string"))],message:t.overallStatus==="pass"?"All release readiness gates pass.":`${s-a} release readiness gate(s) still require work.`}}async function B(e){let t=await c$1({projectPath:e.projectPath,target:e.target,run:e.run}),s=t.metrics[t.target.metric]?.percent??null;return {executionStatus:t.status,measurement:{measuredAt:t.generatedAt,value:s,target:e.target,unit:"percent",status:z(s,e.target,"minimum"),evidencePaths:[t.artifactPaths.project],message:t.status==="failed"?"The runtime-native coverage test command failed.":s===null?"Machine-readable coverage evidence is unavailable.":`${t.target.metric} coverage is ${s}% (target ${e.target}%).`}}}async function Z(e){if(e.scope.kind==="project"){if(!e.scope.projectPath)throw new Error("Coverage goal project scope does not have a project path.");return B({projectPath:e.scope.projectPath,target:e.target,run:e.run})}let t=await p({workspacePath:e.workspacePath,includeAbsolutePaths:true});if(t.projects.length===0)return {executionStatus:"unavailable",measurement:{measuredAt:new Date().toISOString(),value:null,target:e.target,unit:"percent",status:"unavailable",evidencePaths:[],message:"The workspace does not contain a registered project to measure."}};let a=[];for(let d of t.projects)a.push({projectName:d.name,result:await B({projectPath:l.resolve(e.workspacePath,d.path),target:e.target,run:e.run})});let s=a.filter(d=>d.result.executionStatus==="failed"),o=a.filter(d=>d.result.measurement.status==="unavailable"),i=a.filter(d=>d.result.measurement.status==="unsatisfied"),n=a.map(d=>d.result.measurement.value).filter(d=>d!==null),r=n.length===a.length&&n.length>0?Math.min(...n):null,c=s.length>0?"failed":o.length>0?"unavailable":i.length>0?"below-target":"passed",p$1=a.map(d=>d.result.measurement.measuredAt).sort(),f=[...s.map(d=>`${d.projectName}: coverage command failed`),...o.map(d=>`${d.projectName}: coverage unavailable`),...i.map(d=>`${d.projectName}: ${d.result.measurement.value??"unknown"}%`)];return {executionStatus:c,measurement:{measuredAt:p$1[p$1.length-1]??new Date().toISOString(),value:r,target:e.target,unit:"percent",status:c==="passed"?"satisfied":c==="below-target"?"unsatisfied":"unavailable",evidencePaths:[...new Set(a.flatMap(d=>d.result.measurement.evidencePaths))],message:c==="passed"?`Every registered project has at least ${e.target}% test coverage.`:`Workspace coverage is not verified: ${f.join("; ")}.`}}}function pe(e){let t=e.scope.kind==="project"?`project ${e.scope.projectName??"selected project"}`:"workspace";return e.kind==="release-readiness"?`Prepare the ${t} for release.`:e.kind==="dependency-security"?`Resolve blocking dependency vulnerabilities in the ${t} without unsafe changes.`:`Raise ${t} test coverage to ${e.target??80}% without breaking its build.`}function ge(e,t){return e==="release-readiness"?{kind:e,readiness:"pass",workspaceVerify:"ready"}:e==="dependency-security"?{kind:e,maximumBlockingVulnerabilities:0,requireFreshAudit:true}:{kind:e,metric:"auto",minimumPercent:t}}async function fe(e){return e.kind==="release-readiness"?Q(e.workspacePath):e.kind==="dependency-security"?X(e.workspacePath,e.scope):(await Z({workspacePath:e.workspacePath,scope:e.scope,target:e.target,run:false})).measurement}async function Ge(e$1){let t=l.resolve(e$1.workspacePath),a=Math.max(0,Math.min(100,Math.round(e$1.target??80))),{scope:s}=await le(t,e$1.scope),o={workspacePath:l.resolve(t),kind:e$1.kind,scope:s,target:e$1.kind==="test-coverage"?a:null,constraints:{allowBreakingChanges:e$1.allowBreakingChanges===true,allowForce:e$1.allowForce===true,requireBuild:e$1.requireBuild!==false,requireTests:e$1.requireTests!==false}},i=H(o),n=`goal-${e$1.kind}-${i.slice(0,16)}`,r=E(t,n);if(await y.pathExists(r.goal)){let{goal:m,status:u}=await ee(t,n);if(m.fingerprint===i)return {goal:m,status:u,resumed:u.state!=="verified"}}let c=new Date().toISOString(),p=await fe({workspacePath:t,kind:e$1.kind,scope:s,target:a}),f={schemaVersion:W,id:n,fingerprint:i,createdAt:c,updatedAt:c,workspace:{name:l.basename(t),path:t},scope:s,kind:e$1.kind,summary:pe({kind:e$1.kind,scope:s,target:a}),constraints:o.constraints,criteria:ge(e$1.kind,a),baseline:p,...e$1.kind==="dependency-security"?{dependencySafetyBaseline:await U(t,s)}:{},artifactPaths:{goal:r.goal,status:r.status,latestReport:r.latestReport}},d={schemaVersion:x,goalId:n,goalFingerprint:i,workspacePath:t,updatedAt:c,state:"planned",attempt:0,progress:p,checks:[],blockingReasons:[],evidencePaths:p.evidencePaths,nextActions:e$1.kind==="test-coverage"?["Add focused tests for the lowest-coverage source paths.","Run verified goal checks."]:e$1.kind==="dependency-security"?["Inspect the fresh project dependency audit.","Apply only compatible non-force dependency repairs.","Reconcile the lockfile, test, build, and verify again."]:["Inspect the current remediation plan and failing release gates.","Repair the next causal blocker, then verify again."],artifactPath:r.status};return a$1(f,J,"Verified goal"),a$1(d,G,"Verified goal status"),await V(r.goal,f),await V(r.status,d),await e(t,C,d),{goal:f,status:d,resumed:false}}async function ee(e,t){let a=E(l.resolve(e),t),s=await y.readJson(a.goal),o=await y.readJson(a.status);a$1(s,J,"Verified goal"),a$1(o,G,"Verified goal status");let i=l.resolve(e),n=l.resolve(s.artifactPaths.goal)===l.resolve(a.goal)&&l.resolve(s.artifactPaths.status)===l.resolve(a.status)&&l.resolve(s.artifactPaths.latestReport)===l.resolve(a.latestReport);if(s.schemaVersion!==W||o.schemaVersion!==x||s.id!==o.goalId||s.fingerprint!==o.goalFingerprint||s.fingerprint!==H(ce(s))||l.resolve(s.workspace.path)!==i||l.resolve(o.workspacePath)!==i||!n)throw new Error(`Verified goal artifacts are inconsistent: ${t}`);return {goal:s,status:o}}function k(e){return {...e,message:e.message??`${e.label}: ${e.actual}; expected ${e.expected}.`}}async function q(e){let t=[],a=e.goal.scope.kind==="project"&&e.goal.scope.projectName?`project:${e.goal.scope.projectName}`:void 0;for(let s of ["test","build"]){if(s==="test"&&e.includeTests===false)continue;if(!(s==="test"?e.goal.constraints.requireTests:e.goal.constraints.requireBuild)){t.push(k({id:s,label:`${s} validation`,status:"skipped",expected:"not required",actual:"skipped by goal contract"}));continue}if(!e.run){t.push(k({id:s,label:`${s} validation`,status:"missing",expected:"fresh passed evidence",actual:"execution disabled"}));continue}let i=await a$3({workspacePath:e.goal.workspace.path,stage:s,scope:a,parallel:false,continueOnError:false,strict:true,json:true,enforceGates:false});if(t.push(k({id:s,label:`${s} validation`,status:i.summary.exitCode===0?"passed":"failed",expected:"exit 0",actual:`exit ${i.summary.exitCode}`,evidencePath:l.join(e.goal.workspace.path,".workspai","reports","workspace-run-last.json")})),i.summary.exitCode!==0)break}return t}async function Ee(e$1){let t=l.resolve(e$1.workspacePath),{goal:a$2,status:s}=await ee(t,e$1.goalId),o=e$1.run!==false,i=[],n;if(o&&e$1.runIntelligence!==false){let u=await c({workspacePath:t,strict:true,agent:"generic"}),g=u.exitCode===0||u.exitCode===2,h=a$2.kind==="release-readiness";i.push(k({id:"workspace-intelligence-chain",label:"Workspace Intelligence chain",status:u.exitCode===0||u.exitCode===2&&!h?"passed":u.exitCode===2?"blocked":"failed",expected:"passed",actual:u.exitCode===2&&g&&!h?`${u.status}; canonical evidence refreshed for goal-scoped verification`:u.status,evidencePath:l.join(t,a.intelligenceRun)}));}if(a$2.kind==="release-readiness"){n=await Q(t),i.push(k({id:"release-readiness",label:"Release readiness",status:n.status==="satisfied"?"passed":"blocked",expected:"all gates pass",actual:n.message,evidencePath:l.join(t,a.readiness)}));let u=await d(t,a.verify),g=await Y(u),h=g?.summary&&typeof g.summary=="object"&&!Array.isArray(g.summary)?String(g.summary.verdict??"missing"):"missing";i.push(k({id:"workspace-verify",label:"Workspace verification",status:h==="ready"?"passed":h==="missing"?"missing":"blocked",expected:"ready",actual:h,evidencePath:l.join(t,a.verify)}));}else if(a$2.kind==="dependency-security")n=await X(t,a$2.scope),i.push(k({id:"dependency-audit",label:"Dependency security audit",status:n.status==="satisfied"?"passed":n.status==="unavailable"?"missing":"blocked",expected:"0 blocking vulnerabilities",actual:n.message,evidencePath:n.evidencePaths[0]})),i.push(a$2.constraints.allowBreakingChanges||a$2.constraints.allowForce?k({id:"change-policy",label:"Change safety policy",status:"blocked",expected:"breaking and force changes disabled",actual:`allowBreakingChanges=${a$2.constraints.allowBreakingChanges}, allowForce=${a$2.constraints.allowForce}`}):await oe(a$2)),n.status==="satisfied"&&i.push(...await q({goal:a$2,run:o}));else {let u=a$2.criteria.kind==="test-coverage"?a$2.criteria.minimumPercent:a$2.baseline.target;if(u===null)throw new Error("Coverage goal does not have a valid target.");let g=await Z({workspacePath:t,scope:a$2.scope,target:u,run:o});n=g.measurement,i.push(k({id:"coverage",label:"Test coverage",status:n.status==="satisfied"?"passed":n.status==="unavailable"?"missing":"blocked",expected:`at least ${u}%`,actual:n.message,evidencePath:n.evidencePaths[0]})),i.push(k({id:"test",label:"Coverage test execution",status:g.executionStatus==="failed"?"failed":g.executionStatus==="unavailable"?"missing":"passed",expected:"runtime-native coverage test command completed",actual:g.executionStatus==="failed"?"coverage test command failed":g.executionStatus==="unavailable"?"coverage execution evidence unavailable":"coverage evidence produced by the test runner",evidencePath:n.evidencePaths[0]})),n.status==="satisfied"&&i.push(...await q({goal:a$2,run:o,includeTests:false}));}let r=i.filter(u=>u.status==="blocked"||u.status==="failed"||u.status==="missing").map(u=>u.message),c$1=[...new Set([...n.evidencePaths,...i.map(u=>u.evidencePath).filter(u=>typeof u=="string")])],p=n.status==="satisfied"&&i.every(u=>u.status==="passed"||u.status==="skipped"),f=E(t,a$2.id),d$1=p?[]:a$2.kind==="test-coverage"?["Inspect low-coverage files from the coverage artifact.","Add focused tests and verify again."]:a$2.kind==="dependency-security"?["Use fresh audit candidates and compatible package-manager repairs.","Reconcile lockfiles before running verified goal checks again."]:["Repair the first blocking readiness gate and verify the goal again."],m={schemaVersion:x,goalId:a$2.id,goalFingerprint:a$2.fingerprint,workspacePath:t,updatedAt:new Date().toISOString(),state:p?"verified":i.some(u=>u.status==="failed")?"failed":"blocked",attempt:s.attempt+1,progress:n,checks:i,blockingReasons:r,evidencePaths:c$1,nextActions:d$1,artifactPath:f.status};return a$1(m,G,"Verified goal status"),await V(f.status,m),await e(t,C,m),m}export{C as VERIFIED_GOAL_LAST_RUN_REPORT_PATH,W as VERIFIED_GOAL_SCHEMA_VERSION,x as VERIFIED_GOAL_STATUS_SCHEMA_VERSION,Ge as planVerifiedGoal,ee as readVerifiedGoal,Ee as verifyVerifiedGoal};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export{g as WORKSPACE_CONTRACT_PATH,i as WORKSPACE_CONTRACT_SCHEMA_VERSION,h as WORKSPACE_CONTRACT_VERIFY_REPORT_PATH,j as WORKSPACE_CONTRACT_VERIFY_SCHEMA_VERSION,k as WorkspaceContractVerificationError,m as buildWorkspaceContract,q as buildWorkspaceContractGraph,l as discoverProjectJsonFiles,p as readWorkspaceContract,o as syncWorkspaceContract,r as verifyWorkspaceContract,n as writeWorkspaceContract,s as writeWorkspaceContractVerifyEvidence}from'./chunk-MQ73VS4E.js';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export{b as buildWorkspaceExplain,a as resolveWorkspaceExplainArtifactPath,c as writeWorkspaceExplainReport}from'./chunk-YTLUT6IA.js';export{c as WORKSPACE_EXPLAIN_REPORT_PATH,e as WORKSPACE_TRACE_REPORT_PATH,d as WORKSPACE_WHY_REPORT_PATH}from'./chunk-AMB42V2F.js';export{e as WORKSPACE_MODEL_DIFF_REPORT_PATH}from'./chunk-S7Z4DP3P.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-IBPPMOHM.js';export{c as WORKSPACE_EXPLAIN_REPORT_PATH,e as WORKSPACE_TRACE_REPORT_PATH,d as WORKSPACE_WHY_REPORT_PATH}from'./chunk-AMB42V2F.js';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export{a as WORKSPACE_GRAPH_TOKEN_EFFICIENCY_SCHEMA_VERSION,b as buildWorkspaceGraphTokenEfficiencyReport}from'./chunk-7T4TSV5C.js';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import {a as a$2,b as b$1,c,d as d$1}from'./chunk-NYHVCFBT.js';import {a as a$1}from'./chunk-AFIFZTOY.js';import {a}from'./chunk-44VJHNZB.js';import d from'crypto';import s from'path';import {open,unlink,stat}from'fs/promises';import u from'fs-extra';var k=a.evaluationLive,O=a.evaluationLastRun,W="contracts/workspace-intelligence/model-usage-event.v1.json",E="contracts/workspace-intelligence/workspace-intelligence-evaluation.v1.json",P="contracts/workspace-intelligence/workspace-intelligence-evaluation-comparison.v1.json",_=3e4,N=100,b=25;function C(){return {modelCalls:0,toolCalls:0,tokenSources:{providerReported:0,tokenizerCounted:0,estimated:0,unavailable:0},tokens:{input:0,output:0,cachedInput:0,reasoning:0,observedTotal:0},latencyMs:0,costs:[],outcome:{status:"unknown",verified:false,blockersResolved:0},efficiency:{tokensPerVerifiedOutcome:null,noProgressDecisions:0,repeatedArtifactReads:0}}}function m(t){return t??0}function S(t){let e=C(),a=new Map,n=new Map;for(let o of t){if(o.kind==="model-call"){e.modelCalls+=1;let r={"provider-reported":"providerReported","tokenizer-counted":"tokenizerCounted",estimated:"estimated",unavailable:"unavailable"}[o.modelCall.source];if(e.tokenSources[r]+=1,e.tokens.input+=m(o.modelCall.inputTokens),e.tokens.output+=m(o.modelCall.outputTokens),e.tokens.cachedInput+=m(o.modelCall.cachedInputTokens),e.tokens.reasoning+=m(o.modelCall.reasoningTokens),e.latencyMs+=o.modelCall.latencyMs??0,o.modelCall.cost){let i=o.modelCall.cost.currency.toUpperCase(),l=n.get(i)??{currency:i,amount:0,providerReported:0,estimated:0};l.amount+=o.modelCall.cost.amount,o.modelCall.cost.source==="provider-reported"?l.providerReported+=o.modelCall.cost.amount:l.estimated+=o.modelCall.cost.amount,n.set(i,l);}continue}if(o.kind==="tool-call"){e.toolCalls+=1,e.latencyMs+=o.toolCall.durationMs??0,!o.toolCall.changedSource&&o.toolCall.result==="passed"&&(e.efficiency.noProgressDecisions+=1),o.toolCall.artifact&&a.set(o.toolCall.artifact,(a.get(o.toolCall.artifact)??0)+1);continue}o.kind==="outcome"&&(e.outcome={status:o.outcome.status,verified:o.outcome.verified,blockersResolved:o.outcome.blockersResolved});}return e.tokens.observedTotal=e.tokens.input+e.tokens.output,e.costs=[...n.values()].map(o=>({...o,amount:Number(o.amount.toFixed(8)),providerReported:Number(o.providerReported.toFixed(8)),estimated:Number(o.estimated.toFixed(8))})).sort((o,r)=>o.currency.localeCompare(r.currency)),e.efficiency.repeatedArtifactReads=[...a.values()].reduce((o,r)=>o+Math.max(0,r-1),0),e.efficiency.tokensPerVerifiedOutcome=e.outcome.verified&&e.outcome.status==="passed"?e.tokens.observedTotal:null,e}function x(t,e=new Date){if(!t||typeof t!="object"||Array.isArray(t))throw new Error("Evaluation event must be a JSON object.");let a=t,n={...a,schemaVersion:a$2,eventId:typeof a.eventId=="string"&&a.eventId.trim()?a.eventId.trim():d.randomUUID(),recordedAt:typeof a.recordedAt=="string"&&a.recordedAt.trim()?a.recordedAt:e.toISOString()};a$1(n,W,"workspace evaluation event");let o={"model-call":"modelCall","tool-call":"toolCall",outcome:"outcome",milestone:"milestone"}[n.kind],r=["modelCall","toolCall","outcome","milestone"].filter(i=>a[i]!==void 0);if(r.length!==1||r[0]!==o)throw new Error(`Evaluation event kind ${n.kind} requires only ${o}.`);if(n.kind==="model-call"&&n.modelCall.source!=="unavailable"&&n.modelCall.inputTokens===null&&n.modelCall.outputTokens===null)throw new Error("Measured model calls require at least one input or output token count.");return n}function J(t){let e=t.now??new Date,a=s.resolve(t.workspacePath),n={schemaVersion:b$1,runId:t.runId??d.randomUUID(),sessionId:t.sessionId??d.randomUUID(),status:"live",startedAt:e.toISOString(),updatedAt:e.toISOString(),workspace:{name:t.workspaceName?.trim()||s.basename(a),path:a},configuration:{taskId:t.taskId.trim(),strategy:t.strategy??"workspace-intelligence",...t.provider?{provider:t.provider}:{},...t.model?{model:t.model}:{},...t.temperature!==void 0?{temperature:t.temperature}:{},...t.baselineRunId?{baselineRunId:t.baselineRunId}:{}},methodology:{id:"provider-usage-and-verified-outcome.v1",claimBoundary:"Provider-reported and tokenizer-counted values are measured; estimated values remain explicitly labelled. Verified task success is required before reporting tokens per successful outcome."},events:[],summary:C()};return a$1(n,E,"workspace evaluation"),n}async function L(t,e){await u.ensureDir(s.dirname(t));let a=`${t}.${process.pid}.${d.randomUUID()}.tmp`;try{await u.writeJson(a,e,{spaces:2}),await u.rename(a,t);}finally{await u.remove(a).catch(()=>{});}}async function A(t,e){let a=s.join(s.resolve(t),`${k}.lock`);await u.ensureDir(s.dirname(a));for(let n=0;n<N;n+=1)try{let o=await open(a,"wx");try{return await o.writeFile(JSON.stringify({pid:process.pid,acquiredAt:new Date().toISOString()})),await e()}finally{await o.close(),await unlink(a).catch(()=>{});}}catch(o){if(o.code!=="EEXIST")throw o;let i=await stat(a).catch(()=>null);if(i&&Date.now()-i.mtimeMs>_){await unlink(a).catch(()=>{});continue}await new Promise(l=>setTimeout(l,b));}throw new Error("Timed out waiting for the workspace evaluation writer lock.")}async function v(t,e,a=k){let n=s.join(s.resolve(t),a);return a$1(e,E,a),await L(n,e),n}async function T(t,e=k){let a=s.isAbsolute(e)?e:s.join(s.resolve(t),e),n=await u.readJson(a);return a$1(n,E,a),n}async function G(t){return A(t.workspacePath,async()=>{let e=await T(t.workspacePath);if(e.status!=="live")throw new Error(`Evaluation ${e.runId} is ${e.status}; initialize a new run.`);let a=x(t.payload,t.now);if(e.events.some(o=>o.eventId===a.eventId))return e;let n={...e,updatedAt:(t.now??new Date).toISOString(),events:[...e.events,a],summary:S([...e.events,a])};return await v(t.workspacePath,n),n})}async function H(t){return A(t.workspacePath,async()=>{let e=await T(t.workspacePath),a=(t.now??new Date).toISOString(),n={...e,status:t.status??"completed",updatedAt:a,completedAt:a,summary:S(e.events)},o=await v(t.workspacePath,n,O);return await v(t.workspacePath,n),{report:n,outputPath:o}})}function q(t,e){let a=t.summary.tokens.observedTotal,n=e.summary.tokens.observedTotal,o=a-n,r={schemaVersion:c,generatedAt:new Date().toISOString(),taskAligned:t.configuration.taskId===e.configuration.taskId,current:{runId:t.runId,strategy:t.configuration.strategy,tokens:a,verified:t.summary.outcome.verified,status:t.summary.outcome.status},baseline:{runId:e.runId,strategy:e.configuration.strategy,tokens:n,verified:e.summary.outcome.verified,status:e.summary.outcome.status},delta:{tokens:o,reductionPercent:n===0?null:Number((-o/n*100).toFixed(2)),modelCalls:t.summary.modelCalls-e.summary.modelCalls,toolCalls:t.summary.toolCalls-e.summary.toolCalls,latencyMs:Number((t.summary.latencyMs-e.summary.latencyMs).toFixed(2))},comparableOutcome:t.summary.outcome.verified&&e.summary.outcome.verified&&t.summary.outcome.status===e.summary.outcome.status};return a$1(r,P,"workspace evaluation comparison"),r}function B(){if(d$1.length!==4)throw new Error("Model usage source taxonomy is incomplete.")}export{O as WORKSPACE_EVALUATION_LAST_RUN_PATH,k as WORKSPACE_EVALUATION_LIVE_PATH,G as appendWorkspaceEvaluationEvent,B as assertWorkspaceEvaluationSourceTaxonomy,q as compareWorkspaceEvaluations,J as createWorkspaceEvaluation,H as finalizeWorkspaceEvaluation,x as normalizeWorkspaceEvaluationEvent,T as readWorkspaceEvaluation,S as summarizeWorkspaceEvaluation,v as writeWorkspaceEvaluation};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export{f as WORKSPACE_INTELLIGENCE_ADDITIONAL_PRODUCERS,a as WORKSPACE_INTELLIGENCE_ARTIFACTS,b as WORKSPACE_INTELLIGENCE_ARTIFACT_SCHEMAS,c as WORKSPACE_INTELLIGENCE_ARTIFACT_SCHEMA_CONTRACTS,g as WORKSPACE_INTELLIGENCE_COMMAND_SIGNATURES,k as WORKSPACE_INTELLIGENCE_PREFLIGHT_ARTIFACTS,j as WORKSPACE_INTELLIGENCE_PREFLIGHT_IDS,h as WORKSPACE_INTELLIGENCE_ROOT_COMMANDS,l as WORKSPACE_INTELLIGENCE_RUNTIME_STEPS,i as WORKSPACE_INTELLIGENCE_STEP_IDS,e as WORKSPACE_SUPPLEMENTAL_ARTIFACTS,d as WORKSPACE_SUPPLEMENTAL_ARTIFACT_CONTRACTS,m as workspaceIntelligenceRuntimeStep}from'./chunk-44VJHNZB.js';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export{b as WORKSPACE_KNOWLEDGE_GRAPH_REPORT_PATH,c as assertWorkspaceKnowledgeGraphSourceBinding,d as buildWorkspaceKnowledgeGraph,e as knowledgeEntityId}from'./chunk-7KKP7RNB.js';
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import {b}from'./chunk-YTLUT6IA.js';import {c as c$1,e}from'./chunk-IBPPMOHM.js';import {d,c as c$2,f,e as e$1}from'./chunk-PS5F4DCT.js';import {c as c$4,b as b$2}from'./chunk-AMB42V2F.js';import {b as b$1}from'./chunk-P7K5RHJC.js';import {d as d$2}from'./chunk-XVRJVKOX.js';import {c as c$3}from'./chunk-7KKP7RNB.js';import {k}from'./chunk-7AR5PDLD.js';import {h}from'./chunk-MQ73VS4E.js';import {d as d$1}from'./chunk-WIO6L24E.js';import {a as a$2}from'./chunk-AFIFZTOY.js';import {a as a$1,c}from'./chunk-44VJHNZB.js';import {v}from'./chunk-MOSXTVPU.js';import u from'path';import N from'readline';import g from'fs-extra';var L=a$1.agentIndex,q=new Map(Object.keys(a$1).flatMap(e=>{let t=c[e];return t?[[a$1[e],t]]:[]}));function M(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 J=[{name:"getWorkspaceModel",description:"Read workspace-model.json",inputSchema:{type:"object",properties:{}}},{name:"getWorkspaceKnowledgeGraph",description:"Read the current proof-backed workspace knowledge graph artifact",inputSchema:{type:"object",properties:{}}},{name:"getWorkspaceEvaluation",description:"Read the live or finalized provenance-aware model usage and verified-outcome report",inputSchema:{type:"object",properties:{live:{type:"boolean",description:"Read the live report instead of the finalized last-run report"}}}},{name:"queryWorkspaceEntities",description:"List workspace knowledge entities, optionally filtered by kind",inputSchema:{type:"object",properties:{kind:{type:"string",description:"Optional entity kind"}}}},{name:"searchWorkspaceGraph",description:"Return bounded, proof-carrying workspace context matching a text query",inputSchema:{type:"object",properties:{query:{type:"string",description:"Text, path, symbol, service, or concept to find"},kind:{type:"string",description:"Optional entity kind filter"},limit:{type:"integer",minimum:1,maximum:100,default:12}},required:["query"]}},{name:"getWorkspaceGraphEvidence",description:"Resolve portable evidence for a knowledge graph entity or relation",inputSchema:{type:"object",properties:{query:{type:"string"}},required:["query"]}},{name:"findWorkspaceGraphPath",description:"Find a shortest proof-carrying path between two workspace entities",inputSchema:{type:"object",properties:{from:{type:"string"},to:{type:"string"}},required:["from","to"]}},{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 H(e){let t=e.trim().replace(/\\/g,"/");return t.length>0&&!u.isAbsolute(t)&&!t.split("/").includes("..")&&(t.startsWith(".workspai/")||t.startsWith(".rapidkit/"))}async function a(e,t){if(!H(t))throw new Error(`Unsafe artifact path: ${t}`);let r=await d$1(e,t)??u.join(e,t);if(!await g.pathExists(r))return null;let n=await g.readJson(r),o=v(t),c=q.get(o);if(c&&a$2(n,c,`MCP artifact ${o}`),o===a$1.knowledgeGraph){let p=u.join(e,k);if(!await g.pathExists(p))throw new Error("Workspace knowledge graph cannot be consumed without its source model.");let l=await g.readJson(p);c$3(n,l);}return n}async function F(e$1){let t=[],r=new Set,o=((await a(e$1,d$2))?.blockingReasons??[]).filter(i=>typeof i=="string"&&i.trim().length>0);if(o.length>0){t.push({artifact:d$2,reasons:o});for(let i of o)r.add(i);}let c=await a(e$1,c$4);if(e(c)){let i=(c.blockingReasons??[]).filter(s=>typeof s=="string"&&s.trim().length>0);if(i.length>0){t.push({artifact:c$4,reasons:i});for(let s of i)r.add(s);}}let p=await a(e$1,h),l=(p?.violations??[]).filter(i=>typeof i=="string"&&i.trim().length>0);if(l.length>0||String(p?.status??"").toLowerCase()==="failed"){let i=l.length>0?l:["Workspace contract verification failed"];t.push({artifact:h,reasons:i});for(let s of i)r.add(s);}return {blockingReasons:[...r],sources:t}}async function I(e$2,t,r){switch(t){case "getWorkspaceModel":return a(e$2,k);case "getWorkspaceKnowledgeGraph":return a(e$2,a$1.knowledgeGraph);case "getWorkspaceEvaluation":return a(e$2,r.live===true?a$1.evaluationLive:a$1.evaluationLastRun);case "queryWorkspaceEntities":{let n=await a(e$2,a$1.knowledgeGraph);if(!n)return null;let o=String(r.kind??"").trim();return {schemaVersion:n.schemaVersion,generatedAt:n.generatedAt,entities:e$1(n,o||void 0)}}case "searchWorkspaceGraph":{let n=await a(e$2,a$1.knowledgeGraph);if(!n)return null;let o=typeof r.limit=="number"?r.limit:Number(r.limit??12);return f(n,{query:String(r.query??""),...typeof r.kind=="string"&&r.kind.trim()?{kind:r.kind.trim()}:{},limit:Number.isFinite(o)?o:12})}case "getWorkspaceGraphEvidence":{let n=await a(e$2,a$1.knowledgeGraph);return n?c$2(n,String(r.query??"")):null}case "findWorkspaceGraphPath":{let n=await a(e$2,a$1.knowledgeGraph);return n?d(n,String(r.from??""),String(r.to??"")):null}case "getEvidenceIndex":return a(e$2,L);case "getBlockers":return F(e$2);case "getSafeCommands":return {safeCommands:(await a(e$2,b$1))?.safeCommands??[]};case "getProjectContext":{let n=await a(e$2,b$1);if(!n)return null;let o=String(r.project??"").trim(),c=n.scope?.activeProject??void 0,p=o||c,l=Array.isArray(n.projects)?n.projects:[],i=p&&l.find(s=>typeof s.name=="string"&&s.name.toLowerCase()===p.toLowerCase());return {workspace:n.workspace??null,scope:n.scope??null,validation:n.validation??null,project:i??null,safeCommands:n.safeCommands??[]}}case "getArtifact":{let n=String(r.relativePath??"").trim();return a(e$2,n)}case "listOperationalSkills":return a(e$2,b$2);case "getWorkspaceExplain":{let n=String(r.target??"release-blocked").trim(),o=c$1(n);if(!o)throw new Error(`Invalid explain target: ${n}`);let c=await a(e$2,c$4);return e(c)&&M(c.target,o)?c:b({workspacePath:e$2,target:o})}default:throw new Error(`Unknown tool: ${t}`)}}function R(e,t){process.stdout.write(`${JSON.stringify({jsonrpc:"2.0",id:e??null,result:t})}
|
|
2
|
-
`);}function E(e,t){process.stdout.write(`${JSON.stringify({jsonrpc:"2.0",id:e??null,error:{code:-32e3,message:t}})}
|
|
3
|
-
`);}async function ce(e){let t=u.resolve(e.workspacePath),r=N.createInterface({input:process.stdin,terminal:false});for await(let n of r){let o=n.trim();if(!o)continue;let c;try{c=JSON.parse(o);}catch{E(null,"Invalid JSON-RPC request");continue}let{id:p,method:l,params:i}=c;try{if(l==="initialize"){R(p,{protocolVersion:"2024-11-05",capabilities:{tools:{}},serverInfo:{name:"workspai-workspace-mcp",version:"0.1.0"}});continue}if(l==="notifications/initialized")continue;if(l==="tools/list"){R(p,{tools:J.map(s=>({name:s.name,description:s.description,inputSchema:s.inputSchema}))});continue}if(l==="tools/call"){let s=String(i?.name??""),K=i?.arguments&&typeof i.arguments=="object"?i.arguments:{},S=await I(t,s,K);R(p,{content:[{type:"text",text:JSON.stringify(S,null,2)}],isError:S==null});continue}E(p,`Unsupported method: ${l??"unknown"}`);}catch(s){E(p,s instanceof Error?s.message:String(s));}}}async function pe(e,t,r={}){return I(u.resolve(e),t,r)}export{J as WORKSPACE_MCP_READ_TOOLS,pe as invokeMcpToolForTest,ce as runWorkspaceMcpServe};
|