rapidkit 0.41.4 → 0.41.5
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/extension-cli-compatibility.v1.json +1 -1
- package/dist/analyze-JYHEGUSH.js +1 -0
- package/dist/autopilot-release-ZADU63OD.js +1 -0
- package/dist/{chunk-L3R2AS2W.js → chunk-3VI4Y7LZ.js} +1 -1
- package/dist/{chunk-KZLRUBQ5.js → chunk-GDWLW7GF.js} +1 -1
- package/dist/{chunk-ALCH4JAS.js → chunk-HCJV2ITA.js} +1 -1
- package/dist/{chunk-42ARJBM7.js → chunk-P5NZE2RV.js} +1 -1
- package/dist/{chunk-AM5OJWXF.js → chunk-Q4HEXEDW.js} +1 -1
- package/dist/{chunk-DKNVDNT4.js → chunk-SO2SSVWN.js} +1 -1
- package/dist/chunk-T7B3GF3Q.js +1 -0
- package/dist/{chunk-4RJESJ23.js → chunk-TXUBE6KV.js} +1 -1
- package/dist/{chunk-HT3G7HOV.js → chunk-U5IRABWC.js} +32 -32
- package/dist/{chunk-56GL3GG7.js → chunk-U7TS7W2V.js} +1 -1
- package/dist/{create-XTKHAYH7.js → create-P3USIH52.js} +1 -1
- package/dist/{doctor-4UQZIELO.js → doctor-KYNACWFC.js} +1 -1
- package/dist/index.js +104 -104
- package/dist/{pipeline-UOGPOG7S.js → pipeline-SU3FJUKI.js} +1 -1
- package/dist/{workspace-VKUBU4M4.js → workspace-5DKOA7TN.js} +1 -1
- package/dist/{workspace-agent-sync-RWDOTSWV.js → workspace-agent-sync-HZ4UBSZ2.js} +1 -1
- package/dist/{workspace-explain-JIAM63TE.js → workspace-explain-5RDFGHUN.js} +1 -1
- package/dist/{workspace-foundation-V6SLZRBY.js → workspace-foundation-H6IPS4MW.js} +1 -1
- package/dist/{workspace-mcp-serve-GPSSYKZK.js → workspace-mcp-serve-TQTJ4HWI.js} +1 -1
- package/dist/workspace-run-P5UOJSLQ.js +1 -0
- package/dist/{workspace-verify-YDPCHWGQ.js → workspace-verify-5RZSDKGR.js} +1 -1
- package/docs/commands-reference.md +1 -1
- package/package.json +1 -1
- package/dist/analyze-UTB3PNKM.js +0 -1
- package/dist/autopilot-release-MSK4ELKR.js +0 -1
- package/dist/chunk-JU3VNLTY.js +0 -1
- package/dist/workspace-run-MNVPNDUK.js +0 -1
- /package/dist/{chunk-WHQWVQJH.js → chunk-DAPZJHMN.js} +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"schemaVersion": "rapidkit-extension-cli-compatibility.v1",
|
|
3
3
|
"cli": "rapidkit-npm",
|
|
4
|
-
"minimumVerifiedCliVersion": "0.41.
|
|
4
|
+
"minimumVerifiedCliVersion": "0.41.5",
|
|
5
5
|
"publishedContractSchemas": {
|
|
6
6
|
"runtimeCommandSurface": "rapidkit-runtime-command-surface-v1",
|
|
7
7
|
"cliLogEvent": "cli-log-event-v1",
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{b as printAnalyzeReport,a as runAnalyze}from'./chunk-SO2SSVWN.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{b as AUTOPILOT_RELEASE_ALIAS_FILENAME,a as AUTOPILOT_RELEASE_LAST_RUN_FILENAME,c as runAutopilotRelease}from'./chunk-HCJV2ITA.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import {a,b as b$2}from'./chunk-PYCJWW4B.js';import {b as b$1,c,d}from'./chunk-FI4VMG2I.js';import {m,f,c as c$1,n,e}from'./chunk-THSTNVE3.js';import {c as c$2}from'./chunk-64RTZBHU.js';import {n as n$1,b as b$3}from'./chunk-LRF6PQOZ.js';import {a as a$1}from'./chunk-3PTJID76.js';import u from'path';import y from'fs-extra';var K="rapidkit-blocker-resolution-v1";function J(e){let t=e.blockers.map(r=>r.trim()).filter(Boolean).slice(0,12),s=e.stderrTail?.trim().slice(-400)??"";return b$3({blockers:t,exitCode:e.exitCode??null,stderrTail:s})}function te(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 se(e){let t=te(e.reason),s=J({blockers:[e.reason]}),r=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:K,blockerId:e.blockerId,sourceCommand:e.sourceCommand,sourceArtifact:e.sourceArtifact,resolutionClass:t,blockerSignature:s,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:r,verifyCommand:e.verifyCommand,verifyArtifact:e.verifyArtifact}}function U(e){return Array.from(new Set(e.blockingReasons.map(s=>s.trim()).filter(Boolean))).slice(0,12).map((s,r)=>se({reason:s,blockerId:`blocker-${r+1}`,sourceCommand:e.sourceCommand,sourceArtifact:e.sourceArtifact,verifyCommand:e.verifyCommand,verifyArtifact:e.verifyArtifact}))}function re(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 ne(e){return e.length===0||e.every(t=>re(t))}function G(e){return e.projectCount>0||e.policyErrorCount>0?{verdict:e.verdict,exitCode:e.exitCode}:e.verdict==="blocked"&&ne(e.blockingReasons)?{verdict:"needs-attention",exitCode:1}:{verdict:e.verdict,exitCode:e.exitCode}}function Be(e,t){let s=t&&t!=="ready"?` (${t.replace(/-/g," ")})`:"";return e===0?`Workspace scaffold ready${s} \u2014 add your first project to continue.`:`Workspace scaffold${s}: ${e} pre-project signal(s) \u2014 add your first project to continue.`}var X="workspace-verify.v1",I=".rapidkit/reports/workspace-verify-last-run.json";function ie(e,t){return u.isAbsolute(t)?t:u.join(e,t)}async function Y(e$1){let t=await y.readJson(e$1);if(!t||typeof t!="object"||Array.isArray(t))throw new Error(`Workspace impact input is not a JSON object: ${e$1}`);let s=t;if(s.schemaVersion!==e)throw new Error(`Unsupported workspace impact schema: ${String(s.schemaVersion)}`);return s}function oe(e){let t=new Set,s=[];for(let r of e){let n=`${r.scope}:${r.project??""}:${r.display}`;t.has(n)||(t.add(n),s.push(r));}return s}function ae(e,t){if(!e||e==="workspace")return true;let s=(e.startsWith("project:")?e.slice(8):e).trim().toLowerCase();return t.scope==="workspace"?true:(t.project??"").trim().toLowerCase()===s}function ce(e,t){if(e.id==="workspace.doctor")return u.join(t,".rapidkit","reports","doctor-last-run.json");if(e.id==="workspace.contract.verify")return u.join(t,".rapidkit","reports","workspace-contract-verify-last-run.json");if(e.id==="workspace.readiness")return u.join(t,".rapidkit","reports","release-readiness-last-run.json");if(e.id==="workspace.analyze")return u.join(t,".rapidkit","reports","analyze-last-run.json");if(e.id==="workspace.pipeline")return u.join(t,".rapidkit","reports","pipeline-last-run.json");if(e.id==="workspace.doctor-fix")return u.join(t,".rapidkit","reports","doctor-fix-result-last-run.json");if(e.id.startsWith("project.")&&e.id.includes("."))return u.join(t,".rapidkit","reports","workspace-run-last.json")}function b(e){return !e||typeof e!="object"||Array.isArray(e)?null:e}function le(e){let t=b(e.healthScore),s=typeof t?.errors=="number"?t.errors:0,r=typeof t?.percent=="number"?t.percent:void 0;return s>0?{status:"fail",message:`Doctor evidence reports ${s} error(s).`}:typeof r=="number"&&r<70?{status:"warn",message:`Doctor health score is ${r}%.`}:{status:"pass",message:"Doctor evidence is present and healthy."}}function de(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 ue(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 pe(e){let t=b(e.summary);if(t?.blocking===true||e.blocking===true)return {status:"fail",message:"Analyze evidence reports blocking findings."};let r=typeof t?.status=="string"?t.status:void 0;return r==="warn"||r==="warning"?{status:"warn",message:"Analyze evidence reports warnings."}:{status:"pass",message:"Analyze evidence is present."}}function fe(e){let t=e.schemaVersion==="rapidkit-doctor-fix-result-v1"?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 s=t,r=Array.isArray(s.remainingBlockers)?s.remainingBlockers:[];if(r.length>0)return {status:"fail",message:`Doctor fix result reports ${r.length} remaining blocker(s).`};let n=Array.isArray(s.appliedFixes)?s.appliedFixes:[];return n.length===0?{status:"pass",message:"Doctor fix result recorded with no remaining blockers."}:{status:"pass",message:`Doctor fix result recorded ${n.length} applied fix(es) with no remaining blockers.`}}async function ge(e,t){let s=u.join(e,".rapidkit","reports","doctor-remediation-plan-last-run.json");try{let r=b(await y.readJson(s));if(!r||(Array.isArray(r.steps)?r.steps:[]).length>0)return false;let i=typeof r.generatedAt=="string"?r.generatedAt:void 0;if(!i||!t)return true;let d=Date.parse(i),o=Date.parse(t);return !Number.isFinite(d)||!Number.isFinite(o)?true:d>=o}catch{return false}}function me(e){return e.id.endsWith(".init")?"init":e.id.endsWith(".test")?"test":e.id.endsWith(".build")?"build":e.id.endsWith(".start")?"start":null}function ke(e){let t=b(e.summary),s=typeof t?.verdict=="string"?t.verdict:void 0;return s==="blocked"?{status:"fail",message:"Pipeline evidence is blocked."}:s==="needs-attention"?{status:"warn",message:"Pipeline evidence needs attention."}:s==="ready"?{status:"pass",message:"Pipeline evidence is ready."}:{status:"warn",message:"Pipeline evidence status is unknown."}}function ye(e,t,s){let r=me(t),n=c$2(e,r??void 0);if(!n)return {status:"missing",message:"Workspace run evidence is missing or unreadable."};let i=n.stage;if(r&&i!==r)return {status:"missing",message:`Workspace run evidence is for stage "${i}", expected "${r}".`};let d=Array.isArray(n.projects)?n.projects:[],o=t.project?.toLowerCase();if(!o)return {status:"missing",message:"Project-scoped workspace run evidence is missing a project identifier."};let a=d.find(f=>{let g=b(f);if(!g)return false;let c=typeof g.projectName=="string"?g.projectName.toLowerCase():"",l=["projectPath","relativePath","path"].map(p=>g[p]).filter(p=>typeof p=="string"&&p.trim().length>0).map(p=>p.replace(/\\/g,"/").toLowerCase());return c===o||l.some(p=>p.endsWith(`/${o}`)||p===o)});if(a){let f=v(n.generatedAt,s,`Workspace run evidence for ${t.project??t.id}`);if(f)return {status:"fail",message:f};let g=b(a),c=typeof g?.status=="string"?g.status:"unknown";return c==="failed"?{status:"fail",message:`Workspace run evidence failed for ${t.project}.`}:c==="passed"?{status:"pass",message:`Workspace run evidence passed for ${t.project}.`}:c==="skipped"?{status:"warn",message:`Workspace run evidence skipped for ${t.project}.`}:{status:"warn",message:`Workspace run evidence status is ${c} for ${t.project}.`}}return {status:"missing",message:`Workspace run evidence does not include project ${t.project}.`}}function v(e,t,s){if(!t)return null;if(typeof e!="string"||e.trim().length===0)return `${s} is stale: missing generatedAt timestamp (required after impact ${t}).`;let r=Date.parse(e),n=Date.parse(t);return Number.isFinite(r)?Number.isFinite(n)&&r<n?`${s} is stale: generated at ${e}, before impact ${t}.`:null:`${s} is stale: invalid generatedAt timestamp (required after impact ${t}).`}async function he(e,t,s,r){let n=ce(e,t),i=n?u.relative(t,n).split(u.sep).join("/"):void 0;if(e.id==="workspace.contract.verify"&&!s)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."};if(!n||!await y.pathExists(n))return {id:e.id,label:e.label,scope:e.scope,project:e.project,command:e,status:"missing",required:e.required,evidencePath:i,message:i?`Missing evidence report: ${i}`:"No evidence mapping exists for this command."};let d=b(await y.readJson(n));if(!d)return {id:e.id,label:e.label,scope:e.scope,project:e.project,command:e,status:"fail",required:e.required,evidencePath:i,message:"Evidence report is not a JSON object."};let o;if(e.id==="workspace.doctor"){let a=v(d.generatedAt,r,"Doctor evidence");a?o={status:"fail",message:a}:o=le(d);}else if(e.id==="workspace.readiness"){let a=v(d.generatedAt,r,"Release readiness evidence");a?o={status:"fail",message:a}:o=de(d);}else if(e.id==="workspace.contract.verify"){let a=v(d.generatedAt,r,"Workspace contract verify evidence");a?o={status:"fail",message:a}:o=ue(d);}else if(e.id==="workspace.analyze"){let a=v(d.generatedAt,r,"Analyze evidence");a?o={status:"fail",message:a}:o=pe(d);}else if(e.id==="workspace.pipeline"){let a=v(d.generatedAt,r,"Pipeline evidence");a?o={status:"fail",message:a}:o=ke(d);}else if(e.id==="workspace.doctor-fix"){let a=d.schemaVersion==="rapidkit-doctor-fix-result-v1"?d:d.fixResult,f=b(a),g=typeof f?.generatedAt=="string"?f.generatedAt:void 0,c=v(g,r,"Doctor fix result");c?o={status:"fail",message:c}:await ge(t,g)?o={status:"skipped",message:"No current doctor remediation steps are pending."}:o=fe(d);}else if(e.id.startsWith("project."))o=ye(d,e,r);else {let a=v(d.generatedAt,r,"Evidence report");a?o={status:"fail",message:a}:o={status:"pass",message:"Evidence report is present."};}return {id:e.id,label:e.label,scope:e.scope,project:e.project,command:e,status:o.status,required:e.required,evidencePath:i,message:o.message}}function ve(e,t={blockingReasons:[],needsAttention:false}){let s=e.filter(c=>c.status==="pass").length,r=e.filter(c=>c.status==="warn").length,n=e.filter(c=>c.status==="fail").length,i=e.filter(c=>c.status==="missing").length,d=e.filter(c=>c.status==="skipped").length,o=e.filter(c=>c.required&&(c.status==="fail"||c.status==="missing")).map(c=>`${c.id}: ${c.message}`),a=e.filter(c=>c.required&&c.status==="missing").length,f="ready",g=0;return o.length>0||t.blockingReasons.length>0?(f="blocked",g=2):(r>0||a>0||t.needsAttention)&&(f="needs-attention",g=1),{verdict:f,exitCode:g,stepsPassed:s,stepsWarn:r,stepsFailed:n,stepsMissing:i,stepsSkipped:d}}function be(e,t){let s=x(e.affectedProjects.map(l=>l.project?.name).filter(l=>typeof l=="string")),r=new Set(s.map(l=>l.toLowerCase())),n=x(e.transitiveImpact.map(l=>l.project?.name).filter(l=>typeof l=="string").filter(l=>!r.has(l.toLowerCase()))),i=new Map;for(let l of t){if(l.scope!=="project"||!l.project)continue;let p=l.project.toLowerCase(),h=i.get(p)??[];h.push(l),i.set(p,h);}let d=[],o=[],a=[],f=[],g=false,c=(l,p)=>{let h=i.get(l.toLowerCase())??[];if(h.length===0){a.push(l);return}let R=h.filter(m=>m.status==="fail"),C=h.filter(m=>m.status==="missing"),w=C.filter(m=>m.required),j=h.some(m=>m.status==="pass"||m.status==="warn");if(R.length>0){o.push(l),f.push(`graph.subgraph.${l}: ${p} has failed verification evidence (${R.map(m=>m.id).join(", ")}).`);return}if(w.length>0){o.push(l),f.push(`graph.subgraph.${l}: ${p} has missing required verification evidence (${w.map(m=>m.id).join(", ")}).`);return}if(C.length>0){o.push(l),g=true;return}if(j){d.push(l);return}a.push(l);};for(let l of s)c(l,"directly-changed");for(let l of n)c(l,"transitive dependent");return {subgraph:{totalProjects:s.length+n.length,directlyChanged:s,transitiveDependents:n,covered:x(d),uncovered:x(o),unverifiable:x(a)},blockingReasons:f,needsAttention:g}}function x(e){return [...new Set(e)].sort((t,s)=>t.localeCompare(s))}async function we(e$1){let t=u.resolve(e$1.workspacePath);if(e$1.fromImpactPath){let i=ie(t,e$1.fromImpactPath);return {impact:await Y(i),fromImpactRef:u.relative(t,i).split(u.sep).join("/"),impactFromDisk:true}}let s=u.join(t,f);if(await y.pathExists(s))return {impact:await Y(s),fromImpactRef:f,impactFromDisk:true};let r=u.join(t,c$1);if(await y.pathExists(r))return {impact:await n({workspacePath:t,fromPath:c$1,scope:e$1.scope,includeAbsolutePaths:e$1.includeAbsolutePaths,includeEvidence:e$1.includeEvidence,observableScanDepth:e$1.observableScanDepth,now:e$1.now}),fromImpactRef:c$1,impactFromDisk:false};let n$2=await n$1({workspacePath:t,includeAbsolutePaths:e$1.includeAbsolutePaths,includeEvidence:e$1.includeEvidence,observableScanDepth:e$1.observableScanDepth,now:e$1.now});return {impact:{schemaVersion:e,generatedAt:(e$1.now??new Date).toISOString(),fromRef:"baseline",diffRef:".rapidkit/reports/workspace-model-diff-last-run.json",workspace:{name:n$2.workspace.name,profile:n$2.workspace.profile,type:n$2.workspace.type},summary:{changed:false,risk:"none",affectedProjects:0,workspaceItems:0,recommendedCommands:0,blastRadius:{directlyAffected:0,transitivelyAffected:0,maxDistance:0,graphEdges:n$2.graph?.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:"workspace-model-diff.v1",generatedAt:(e$1.now??new Date).toISOString(),fromRef:"baseline",toRef:".rapidkit/reports/workspace-model.json",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:n$2}},impactFromDisk:false}}function Re(e,t){if(t)return e.generatedAt}async function Je(e){let t=u.resolve(e.workspacePath),{impact:s,fromImpactRef:r,impactFromDisk:n}=await we(e),i=s.diff.currentModel,d$1=Re(s,n),o=oe([...m(),...s.verificationPlan]).filter(k=>ae(e.scope,k)),a$1=[];for(let k of o)a$1.push(await he(k,t,i.contracts.exists===true,d$1));let f=be(s,a$1),g=a(i.graph??{nodes:[],edges:[]}),c$1=b$1(i),l=await xe(t),p=c(c$1,l?.freshness?.projectHashes),h={verdict:p.verdict,baseline:p.baseline,changed:p.changed,added:p.added,removed:p.removed,projectHashes:d(c$1)},R=b$2(g),C=i.policies?.mode??"warn",w=await Ce(i,t),j=je(C,w),m$1=ve(a$1,{blockingReasons:[...f.blockingReasons,...R,...j.blockingReasons],needsAttention:f.needsAttention||j.needsAttention}),Q=a$1.filter(k=>k.status==="missing"&&k.evidencePath).map(k=>k.evidencePath),W=[...a$1.filter(k=>k.required&&(k.status==="fail"||k.status==="missing")).map(k=>`${k.id}: ${k.message}`),...f.blockingReasons,...R,...j.blockingReasons],Z=w.filter(k=>k.severity==="error").length,ee=i.summary?.projectCount??i.projects.length,$=G({projectCount:ee,verdict:m$1.verdict,exitCode:m$1.exitCode,blockingReasons:W,policyErrorCount:Z});m$1.verdict=$.verdict,m$1.exitCode=$.exitCode;let B=W.length>0?U({blockingReasons:W,verifyCommand:"npx rapidkit workspace verify --from-impact .rapidkit/reports/workspace-impact-last-run.json --json",verifyArtifact:I}):[];return {schemaVersion:X,generatedAt:(e.now??new Date).toISOString(),workspacePath:t,mode:"evidence",fromImpactRef:r,scope:e.scope,impact:{changed:s.summary.changed,risk:s.summary.risk,affectedProjects:s.summary.affectedProjects,recommendedCommands:s.summary.recommendedCommands},summary:m$1,steps:a$1,missingEvidence:Q,blockingReasons:W,...B.length>0?{resolutionHints:B}:{},verificationPlan:o,affectedSubgraph:f.subgraph,graphIntegrity:g,freshness:h,policyMode:C,policyViolations:w}}async function Ce(e,t){let s=[];for(let n of e.validation?.issues??[])s.push({source:"model",severity:n.severity,code:n.code,message:n.message,target:n.target});let r=u.join(t,".rapidkit","reports","workspace-contract-verify-last-run.json");try{if(await y.pathExists(r)){let n=await y.readJson(r);if(Array.isArray(n.violations))for(let i of n.violations)typeof i=="string"&&i.trim().length>0&&s.push({source:"contract",severity:"error",code:"contract.violation",message:i});}}catch{}return s.sort((n,i)=>n.source!==i.source?n.source.localeCompare(i.source):n.code!==i.code?n.code.localeCompare(i.code):n.message.localeCompare(i.message))}function je(e,t){let s=t.filter(r=>r.severity==="error");return e==="enforce"&&s.length>0?{blockingReasons:s.map(r=>`policy.${r.code}: ${r.message}`),needsAttention:false}:{blockingReasons:[],needsAttention:s.length>0}}async function xe(e){let t=u.join(e,I);try{if(!await y.pathExists(t))return null;let s=await y.readJson(t);return s&&s.schemaVersion===X?s:null}catch{return null}}async function Ue(e,t){let s=u.join(t,I);return await y.ensureDir(u.dirname(s)),await y.writeJson(s,a$1(e),{spaces:2}),s}function We(e,t){let s=t?.strict?"strict":"default",r=[];if(e.summary.verdict==="blocked")return r.push(...e.blockingReasons),r.length===0&&r.push("verify verdict is blocked."),{passed:false,mode:s,exitCode:2,reasons:r};if(s==="strict"){if(e.summary.verdict!=="ready"&&r.push(`verify verdict is ${e.summary.verdict} (strict requires ready).`),e.freshness.verdict==="stale"){let n=[...e.freshness.changed,...e.freshness.added].slice(0,5);r.push(`freshness is stale${n.length>0?`: ${n.join(", ")}`:""} (strict requires fresh).`);}if(r.length>0)return {passed:false,mode:s,exitCode:1,reasons:r}}return {passed:true,mode:s,exitCode:e.summary.exitCode===2?0:e.summary.exitCode,reasons:r}}function Ge(e,t){let s=We(e,t);return s.passed?e.summary.verdict==="blocked"?2:t?.strict&&e.summary.verdict!=="ready"?1:e.summary.exitCode:s.exitCode}export{K as a,Be as b,X as c,I as d,be as e,Je as f,Ue as g,We as h,Ge as i};
|
|
1
|
+
import {a,b as b$2}from'./chunk-PYCJWW4B.js';import {b as b$1,c,d}from'./chunk-FI4VMG2I.js';import {m,f,c as c$1,n,e}from'./chunk-THSTNVE3.js';import {c as c$2}from'./chunk-64RTZBHU.js';import {n as n$1,b as b$3}from'./chunk-LRF6PQOZ.js';import {a as a$1}from'./chunk-3PTJID76.js';import u from'path';import y from'fs-extra';var K="rapidkit-blocker-resolution-v1";function J(e){let t=e.blockers.map(r=>r.trim()).filter(Boolean).slice(0,12),s=e.stderrTail?.trim().slice(-400)??"";return b$3({blockers:t,exitCode:e.exitCode??null,stderrTail:s})}function te(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 se(e){let t=te(e.reason),s=J({blockers:[e.reason]}),r=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:K,blockerId:e.blockerId,sourceCommand:e.sourceCommand,sourceArtifact:e.sourceArtifact,resolutionClass:t,blockerSignature:s,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:r,verifyCommand:e.verifyCommand,verifyArtifact:e.verifyArtifact}}function U(e){return Array.from(new Set(e.blockingReasons.map(s=>s.trim()).filter(Boolean))).slice(0,12).map((s,r)=>se({reason:s,blockerId:`blocker-${r+1}`,sourceCommand:e.sourceCommand,sourceArtifact:e.sourceArtifact,verifyCommand:e.verifyCommand,verifyArtifact:e.verifyArtifact}))}function re(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 ne(e){return e.length===0||e.every(t=>re(t))}function G(e){return e.projectCount>0||e.policyErrorCount>0?{verdict:e.verdict,exitCode:e.exitCode}:e.verdict==="blocked"&&ne(e.blockingReasons)?{verdict:"needs-attention",exitCode:1}:{verdict:e.verdict,exitCode:e.exitCode}}function Be(e,t){let s=t&&t!=="ready"?` (${t.replace(/-/g," ")})`:"";return e===0?`Workspace scaffold ready${s} \u2014 add your first project to continue.`:`Workspace scaffold${s}: ${e} pre-project signal(s) \u2014 add your first project to continue.`}var X="workspace-verify.v1",I=".rapidkit/reports/workspace-verify-last-run.json";function ie(e,t){return u.isAbsolute(t)?t:u.join(e,t)}async function Y(e$1){let t=await y.readJson(e$1);if(!t||typeof t!="object"||Array.isArray(t))throw new Error(`Workspace impact input is not a JSON object: ${e$1}`);let s=t;if(s.schemaVersion!==e)throw new Error(`Unsupported workspace impact schema: ${String(s.schemaVersion)}`);return s}function oe(e){let t=new Set,s=[];for(let r of e){let n=`${r.scope}:${r.project??""}:${r.display}`;t.has(n)||(t.add(n),s.push(r));}return s}function ae(e,t){if(!e||e==="workspace")return true;let s=(e.startsWith("project:")?e.slice(8):e).trim().toLowerCase();return t.scope==="workspace"?true:(t.project??"").trim().toLowerCase()===s}function ce(e,t){if(e.id==="workspace.doctor")return u.join(t,".rapidkit","reports","doctor-last-run.json");if(e.id==="workspace.contract.verify")return u.join(t,".rapidkit","reports","workspace-contract-verify-last-run.json");if(e.id==="workspace.readiness")return u.join(t,".rapidkit","reports","release-readiness-last-run.json");if(e.id==="workspace.analyze")return u.join(t,".rapidkit","reports","analyze-last-run.json");if(e.id==="workspace.pipeline")return u.join(t,".rapidkit","reports","pipeline-last-run.json");if(e.id==="workspace.doctor-fix")return u.join(t,".rapidkit","reports","doctor-fix-result-last-run.json");if(e.id.startsWith("project.")&&e.id.includes("."))return u.join(t,".rapidkit","reports","workspace-run-last.json")}function b(e){return !e||typeof e!="object"||Array.isArray(e)?null:e}function le(e){let t=b(e.healthScore),s=typeof t?.errors=="number"?t.errors:0,r=typeof t?.percent=="number"?t.percent:void 0;return s>0?{status:"fail",message:`Doctor evidence reports ${s} error(s).`}:typeof r=="number"&&r<70?{status:"warn",message:`Doctor health score is ${r}%.`}:{status:"pass",message:"Doctor evidence is present and healthy."}}function de(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 ue(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 pe(e){let t=b(e.summary);if(t?.blocking===true||e.blocking===true)return {status:"fail",message:"Analyze evidence reports blocking findings."};let r=typeof t?.status=="string"?t.status:void 0;return r==="warn"||r==="warning"?{status:"warn",message:"Analyze evidence reports warnings."}:{status:"pass",message:"Analyze evidence is present."}}function fe(e){let t=e.schemaVersion==="rapidkit-doctor-fix-result-v1"?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 s=t,r=Array.isArray(s.remainingBlockers)?s.remainingBlockers:[];if(r.length>0)return {status:"fail",message:`Doctor fix result reports ${r.length} remaining blocker(s).`};let n=Array.isArray(s.appliedFixes)?s.appliedFixes:[];return n.length===0?{status:"pass",message:"Doctor fix result recorded with no remaining blockers."}:{status:"pass",message:`Doctor fix result recorded ${n.length} applied fix(es) with no remaining blockers.`}}async function ge(e,t){let s=u.join(e,".rapidkit","reports","doctor-remediation-plan-last-run.json");try{let r=b(await y.readJson(s));if(!r||(Array.isArray(r.steps)?r.steps:[]).length>0)return false;let i=typeof r.generatedAt=="string"?r.generatedAt:void 0;if(!i||!t)return true;let d=Date.parse(i),o=Date.parse(t);return !Number.isFinite(d)||!Number.isFinite(o)?true:d>=o}catch{return false}}function me(e){return e.id.endsWith(".init")?"init":e.id.endsWith(".test")?"test":e.id.endsWith(".build")?"build":e.id.endsWith(".start")?"start":null}function ke(e){let t=b(e.summary),s=typeof t?.verdict=="string"?t.verdict:void 0;return s==="blocked"?{status:"fail",message:"Pipeline evidence is blocked."}:s==="needs-attention"?{status:"warn",message:"Pipeline evidence needs attention."}:s==="ready"?{status:"pass",message:"Pipeline evidence is ready."}:{status:"warn",message:"Pipeline evidence status is unknown."}}function ye(e,t,s){let r=me(t),n=c$2(e,r??void 0);if(!n)return {status:"missing",message:"Workspace run evidence is missing or unreadable."};let i=n.stage;if(r&&i!==r)return {status:"missing",message:`Workspace run evidence is for stage "${i}", expected "${r}".`};let d=Array.isArray(n.projects)?n.projects:[],o=t.project?.toLowerCase();if(!o)return {status:"missing",message:"Project-scoped workspace run evidence is missing a project identifier."};let a=d.find(f=>{let g=b(f);if(!g)return false;let c=typeof g.projectName=="string"?g.projectName.toLowerCase():"",l=["projectPath","relativePath","path"].map(p=>g[p]).filter(p=>typeof p=="string"&&p.trim().length>0).map(p=>p.replace(/\\/g,"/").toLowerCase());return c===o||l.some(p=>p.endsWith(`/${o}`)||p===o)});if(a){let f=v(n.generatedAt,s,`Workspace run evidence for ${t.project??t.id}`);if(f)return {status:"fail",message:f};let g=b(a),c=typeof g?.status=="string"?g.status:"unknown";return c==="failed"?{status:"fail",message:`Workspace run evidence failed for ${t.project}.`}:c==="passed"?{status:"pass",message:`Workspace run evidence passed for ${t.project}.`}:c==="skipped"?{status:"warn",message:`Workspace run evidence skipped for ${t.project}.`}:{status:"warn",message:`Workspace run evidence status is ${c} for ${t.project}.`}}return {status:"missing",message:`Workspace run evidence does not include project ${t.project}.`}}function v(e,t,s){if(!t)return null;if(typeof e!="string"||e.trim().length===0)return `${s} is stale: missing generatedAt timestamp (required after impact ${t}).`;let r=Date.parse(e),n=Date.parse(t);return Number.isFinite(r)?Number.isFinite(n)&&r<n?`${s} is stale: generated at ${e}, before impact ${t}.`:null:`${s} is stale: invalid generatedAt timestamp (required after impact ${t}).`}async function he(e,t,s,r){let n=ce(e,t),i=n?u.relative(t,n).split(u.sep).join("/"):void 0;if(e.id==="workspace.contract.verify"&&!s)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."};if(!n||!await y.pathExists(n))return {id:e.id,label:e.label,scope:e.scope,project:e.project,command:e,status:"missing",required:e.required,evidencePath:i,message:i?`Missing evidence report: ${i}`:"No evidence mapping exists for this command."};let d=b(await y.readJson(n));if(!d)return {id:e.id,label:e.label,scope:e.scope,project:e.project,command:e,status:"fail",required:e.required,evidencePath:i,message:"Evidence report is not a JSON object."};let o;if(e.id==="workspace.doctor"){let a=v(d.generatedAt,r,"Doctor evidence");a?o={status:"fail",message:a}:o=le(d);}else if(e.id==="workspace.readiness"){let a=v(d.generatedAt,r,"Release readiness evidence");a?o={status:"fail",message:a}:o=de(d);}else if(e.id==="workspace.contract.verify"){let a=v(d.generatedAt,r,"Workspace contract verify evidence");a?o={status:"fail",message:a}:o=ue(d);}else if(e.id==="workspace.analyze"){let a=v(d.generatedAt,r,"Analyze evidence");a?o={status:"fail",message:a}:o=pe(d);}else if(e.id==="workspace.pipeline"){let a=v(d.generatedAt,r,"Pipeline evidence");a?o={status:"fail",message:a}:o=ke(d);}else if(e.id==="workspace.doctor-fix"){let a=d.schemaVersion==="rapidkit-doctor-fix-result-v1"?d:d.fixResult,f=b(a),g=typeof f?.generatedAt=="string"?f.generatedAt:void 0,c=v(g,r,"Doctor fix result");c?o={status:"fail",message:c}:await ge(t,g)?o={status:"skipped",message:"No current doctor remediation steps are pending."}:o=fe(d);}else if(e.id.startsWith("project."))o=ye(d,e,r);else {let a=v(d.generatedAt,r,"Evidence report");a?o={status:"fail",message:a}:o={status:"pass",message:"Evidence report is present."};}return {id:e.id,label:e.label,scope:e.scope,project:e.project,command:e,status:o.status,required:e.required,evidencePath:i,message:o.message}}function ve(e,t={blockingReasons:[],needsAttention:false}){let s=e.filter(c=>c.status==="pass").length,r=e.filter(c=>c.status==="warn").length,n=e.filter(c=>c.status==="fail").length,i=e.filter(c=>c.status==="missing").length,d=e.filter(c=>c.status==="skipped").length,o=e.filter(c=>c.required&&(c.status==="fail"||c.status==="missing")).map(c=>`${c.id}: ${c.message}`),a=e.filter(c=>c.required&&c.status==="missing").length,f="ready",g=0;return o.length>0||t.blockingReasons.length>0?(f="blocked",g=2):(r>0||a>0||t.needsAttention)&&(f="needs-attention",g=1),{verdict:f,exitCode:g,stepsPassed:s,stepsWarn:r,stepsFailed:n,stepsMissing:i,stepsSkipped:d}}function be(e,t){let s=W(e.affectedProjects.map(l=>l.project?.name).filter(l=>typeof l=="string")),r=new Set(s.map(l=>l.toLowerCase())),n=W(e.transitiveImpact.map(l=>l.project?.name).filter(l=>typeof l=="string").filter(l=>!r.has(l.toLowerCase()))),i=new Map;for(let l of t){if(l.scope!=="project"||!l.project)continue;let p=l.project.toLowerCase(),h=i.get(p)??[];h.push(l),i.set(p,h);}let d=[],o=[],a=[],f=[],g=false,c=(l,p)=>{let h=i.get(l.toLowerCase())??[];if(h.length===0){a.push(l);return}let R=h.filter(m=>m.status==="fail"),C=h.filter(m=>m.status==="missing"),w=C.filter(m=>m.required),j=h.some(m=>m.status==="pass"||m.status==="warn");if(R.length>0){o.push(l),f.push(`graph.subgraph.${l}: ${p} has failed verification evidence (${R.map(m=>m.id).join(", ")}).`);return}if(w.length>0){o.push(l),f.push(`graph.subgraph.${l}: ${p} has missing required verification evidence (${w.map(m=>m.id).join(", ")}).`);return}if(C.length>0){o.push(l),g=true;return}if(j){d.push(l);return}a.push(l);};for(let l of s)c(l,"directly-changed");for(let l of n)c(l,"transitive dependent");return {subgraph:{totalProjects:s.length+n.length,directlyChanged:s,transitiveDependents:n,covered:W(d),uncovered:W(o),unverifiable:W(a)},blockingReasons:f,needsAttention:g}}function W(e){return [...new Set(e)].sort((t,s)=>t.localeCompare(s))}async function we(e$1){let t=u.resolve(e$1.workspacePath);if(e$1.fromImpactPath){let i=ie(t,e$1.fromImpactPath);return {impact:await Y(i),fromImpactRef:u.relative(t,i).split(u.sep).join("/"),impactFromDisk:true}}let s=u.join(t,f);if(await y.pathExists(s))return {impact:await Y(s),fromImpactRef:f,impactFromDisk:true};let r=u.join(t,c$1);if(await y.pathExists(r))return {impact:await n({workspacePath:t,fromPath:c$1,scope:e$1.scope,includeAbsolutePaths:e$1.includeAbsolutePaths,includeEvidence:e$1.includeEvidence,observableScanDepth:e$1.observableScanDepth,now:e$1.now}),fromImpactRef:c$1,impactFromDisk:false};let n$2=await n$1({workspacePath:t,includeAbsolutePaths:e$1.includeAbsolutePaths,includeEvidence:e$1.includeEvidence,observableScanDepth:e$1.observableScanDepth,now:e$1.now});return {impact:{schemaVersion:e,generatedAt:(e$1.now??new Date).toISOString(),fromRef:"baseline",diffRef:".rapidkit/reports/workspace-model-diff-last-run.json",workspace:{name:n$2.workspace.name,profile:n$2.workspace.profile,type:n$2.workspace.type},summary:{changed:false,risk:"none",affectedProjects:0,workspaceItems:0,recommendedCommands:0,blastRadius:{directlyAffected:0,transitivelyAffected:0,maxDistance:0,graphEdges:n$2.graph?.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:"workspace-model-diff.v1",generatedAt:(e$1.now??new Date).toISOString(),fromRef:"baseline",toRef:".rapidkit/reports/workspace-model.json",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:n$2}},impactFromDisk:false}}function Re(e,t){if(t)return e.generatedAt}async function Je(e){let t=u.resolve(e.workspacePath),{impact:s,fromImpactRef:r,impactFromDisk:n}=await we(e),i=s.diff.currentModel,d$1=Re(s,n),o=oe([...m(),...s.verificationPlan]).filter(k=>ae(e.scope,k)),a$1=[];for(let k of o)a$1.push(await he(k,t,i.contracts.exists===true,d$1));let f=be(s,a$1),g=a(i.graph??{nodes:[],edges:[]}),c$1=b$1(i),l=await We(t),p=c(c$1,l?.freshness?.projectHashes),h={verdict:p.verdict,baseline:p.baseline,changed:p.changed,added:p.added,removed:p.removed,projectHashes:d(c$1)},R=b$2(g),C=i.policies?.mode??"warn",w=await Ce(i,t),j=je(C,w),m$1=ve(a$1,{blockingReasons:[...f.blockingReasons,...R,...j.blockingReasons],needsAttention:f.needsAttention||j.needsAttention}),Q=a$1.filter(k=>k.status==="missing"&&k.evidencePath).map(k=>k.evidencePath),x=[...a$1.filter(k=>k.required&&(k.status==="fail"||k.status==="missing")).map(k=>`${k.id}: ${k.message}`),...f.blockingReasons,...R,...j.blockingReasons],Z=w.filter(k=>k.severity==="error").length,ee=i.summary?.projectCount??i.projects.length,$=G({projectCount:ee,verdict:m$1.verdict,exitCode:m$1.exitCode,blockingReasons:x,policyErrorCount:Z});m$1.verdict=$.verdict,m$1.exitCode=$.exitCode;let B=x.length>0?U({blockingReasons:x,verifyCommand:"npx rapidkit workspace verify --from-impact .rapidkit/reports/workspace-impact-last-run.json --json",verifyArtifact:I}):[];return {schemaVersion:X,generatedAt:(e.now??new Date).toISOString(),workspacePath:t,mode:"evidence",fromImpactRef:r,scope:e.scope,impact:{changed:s.summary.changed,risk:s.summary.risk,affectedProjects:s.summary.affectedProjects,recommendedCommands:s.summary.recommendedCommands},summary:m$1,steps:a$1,missingEvidence:Q,blockingReasons:x,...B.length>0?{resolutionHints:B}:{},verificationPlan:o,affectedSubgraph:f.subgraph,graphIntegrity:g,freshness:h,policyMode:C,policyViolations:w}}async function Ce(e,t){let s=[];for(let n of e.validation?.issues??[])s.push({source:"model",severity:n.severity,code:n.code,message:n.message,target:n.target});let r=u.join(t,".rapidkit","reports","workspace-contract-verify-last-run.json");try{if(await y.pathExists(r)){let n=await y.readJson(r);if(Array.isArray(n.violations))for(let i of n.violations)typeof i=="string"&&i.trim().length>0&&s.push({source:"contract",severity:"error",code:"contract.violation",message:i});}}catch{}return s.sort((n,i)=>n.source!==i.source?n.source.localeCompare(i.source):n.code!==i.code?n.code.localeCompare(i.code):n.message.localeCompare(i.message))}function je(e,t){let s=t.filter(r=>r.severity==="error");return e==="enforce"&&s.length>0?{blockingReasons:s.map(r=>`policy.${r.code}: ${r.message}`),needsAttention:false}:{blockingReasons:[],needsAttention:s.length>0}}async function We(e){let t=u.join(e,I);try{if(!await y.pathExists(t))return null;let s=await y.readJson(t);return s&&s.schemaVersion===X?s:null}catch{return null}}async function Ue(e,t){let s=u.join(t,I);return await y.ensureDir(u.dirname(s)),await y.writeJson(s,a$1(e),{spaces:2}),s}function xe(e,t){let s=t?.strict?"strict":"default",r=[];if(e.summary.verdict==="blocked")return r.push(...e.blockingReasons),r.length===0&&r.push("verify verdict is blocked."),{passed:false,mode:s,exitCode:2,reasons:r};if(s==="strict"){if(e.summary.verdict!=="ready"&&r.push(`verify verdict is ${e.summary.verdict} (strict requires ready).`),e.freshness.verdict==="stale"){let n=[...e.freshness.changed,...e.freshness.added].slice(0,5);r.push(`freshness is stale${n.length>0?`: ${n.join(", ")}`:""} (strict requires fresh).`);}if(r.length>0)return {passed:false,mode:s,exitCode:1,reasons:r}}return {passed:true,mode:s,exitCode:0,reasons:r}}function Ge(e,t){return xe(e,t).exitCode}export{K as a,Be as b,X as c,I as d,be as e,Je as f,Ue as g,xe as h,Ge as i};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {c}from'./chunk-NFUXULIF.js';import {a}from'./chunk-A5FBGRJA.js';import {a as a$1}from'./chunk-TDSIF42O.js';import {b}from'./chunk-Q2KZIBV4.js';import {p}from'./chunk-WRMCPKGA.js';import {promises}from'fs';import n from'path';import i from'chalk';import E from'ora';import {execa}from'execa';function B(e){let r=a(e.path),t=Array.isArray(e.projects)?e.projects:[],a$1=[],o=new Set;for(let d of t){if(!d||typeof d.name!="string"||typeof d.path!="string")continue;let c=a(d.path);o.has(c)||(o.add(c),a$1.push({name:d.name,path:c}));}return {name:e.name,path:r,mode:e.mode,projects:a$1}}function P(e){let r=[],t=new Set;for(let a of e.workspaces||[]){if(!a||typeof a.name!="string"||typeof a.path!="string")continue;let o=B(a);t.has(o.path)||(t.add(o.path),r.push(o));}return {workspaces:r}}async function A(e){try{let r=await promises.readFile(e,"utf8"),t=JSON.parse(r);if(t&&Array.isArray(t.workspaces))return P(t)}catch{}return {workspaces:[]}}async function T(e,r){try{let t=a(e),a$1=p(),o=n.join(a$1,"workspaces.json");await promises.mkdir(a$1,{recursive:true});let d={name:r,path:t,mode:"full",projects:[]};for(let c=0;c<3;c+=1){let s=await A(o);if(s.workspaces.some(u=>u.path===t)||(s.workspaces.push(d),await promises.writeFile(o,JSON.stringify(s,null,2)),(await A(o)).workspaces.some(u=>u.path===t)))return}console.warn(i.gray("Note: Could not register workspace in shared registry"));}catch{console.warn(i.gray("Note: Could not register workspace in shared registry"));}}async function ne(e,r=false){let t=a(e),a$1={workspacePath:t,workspaceFound:false,added:[],skipped:0};try{let o=p(),d=n.join(o,"workspaces.json"),c={workspaces:[]};try{let f=await promises.readFile(d,"utf8"),h=JSON.parse(f);h&&Array.isArray(h.workspaces)&&(c=P(h));}catch{return r||console.log("\u26A0\uFE0F Workspace registry not found"),a$1}let s=c.workspaces.find(f=>f.path===t);if(!s)return r||console.log("\u26A0\uFE0F Workspace not registered in registry"),a$1;Array.isArray(s.projects)||(s.projects=[]);let p$1=0,u=0,k=[],m=[e],y=new Set;for(;m.length>0;){let f=m.shift();if(!f||y.has(f))continue;y.add(f);let h=await promises.readdir(f,{withFileTypes:true});for(let w of h){if(!w.isDirectory()||w.name.startsWith(".")||["node_modules","dist","build","target","coverage","htmlcov"].includes(w.name))continue;let S=n.join(f,w.name),g=a(S),$=n.join(g,".rapidkit","context.json"),W=n.join(g,".rapidkit","project.json");try{let b=false;try{await promises.access($),b=true;}catch{await promises.access(W),b=true;}if(b){let v=n.basename(g);s.projects.some(_=>_.path===g||_.name===v)?u++:(s.projects.push({name:v,path:g}),p$1++,k.push(g),r||console.log(`\u2714 Added: ${n.relative(e,g)}`));continue}}catch{}m.push(S);}}return p$1>0?(await promises.writeFile(d,JSON.stringify(c,null,2)),r||console.log(`
|
|
2
2
|
\u2705 Synced ${p$1} project(s) to registry`)):r||console.log(`
|
|
3
|
-
\u2705 All projects already registered (${u} found)`),{workspacePath:t,workspaceFound:true,added:k,skipped:u}}catch(o){return r||console.error("\u274C Failed to sync projects:",o.message),a$1}}async function se(e,r,t){try{let a$1=a(e),o=a(t),d=p(),c=n.join(d,"workspaces.json"),s={workspaces:[]};try{let m=await promises.readFile(c,"utf8"),y=JSON.parse(m);y&&Array.isArray(y.workspaces)&&(s=P(y));}catch{return}let p$1=s.workspaces.find(m=>m.path===a$1);if(!p$1)return;Array.isArray(p$1.projects)||(p$1.projects=[]);let u=p$1.projects.findIndex(m=>m.path===o||m.name===r),k={name:r,path:o};if(u>=0){let m=p$1.projects[u];(m.name!==k.name||m.path!==k.path)&&(p$1.projects[u]=k,await promises.writeFile(c,JSON.stringify(s,null,2)));}else p$1.projects.push({name:r,path:o}),await promises.writeFile(c,JSON.stringify(s,null,2));}catch{}}async function ce(e,r){let t=E("Creating RapidKit workspace...").start();try{await promises.mkdir(e,{recursive:true}),await promises.mkdir(n.join(e,".rapidkit"),{recursive:true});let a={workspace_name:r.name,author:r.author,rapidkit_version:b(),created_at:new Date().toISOString(),type:"workspace"};await promises.writeFile(n.join(e,".rapidkit","config.json"),JSON.stringify(a,null,2));let{syncWorkspaceFoundationFiles:o}=await import('./create-
|
|
3
|
+
\u2705 All projects already registered (${u} found)`),{workspacePath:t,workspaceFound:true,added:k,skipped:u}}catch(o){return r||console.error("\u274C Failed to sync projects:",o.message),a$1}}async function se(e,r,t){try{let a$1=a(e),o=a(t),d=p(),c=n.join(d,"workspaces.json"),s={workspaces:[]};try{let m=await promises.readFile(c,"utf8"),y=JSON.parse(m);y&&Array.isArray(y.workspaces)&&(s=P(y));}catch{return}let p$1=s.workspaces.find(m=>m.path===a$1);if(!p$1)return;Array.isArray(p$1.projects)||(p$1.projects=[]);let u=p$1.projects.findIndex(m=>m.path===o||m.name===r),k={name:r,path:o};if(u>=0){let m=p$1.projects[u];(m.name!==k.name||m.path!==k.path)&&(p$1.projects[u]=k,await promises.writeFile(c,JSON.stringify(s,null,2)));}else p$1.projects.push({name:r,path:o}),await promises.writeFile(c,JSON.stringify(s,null,2));}catch{}}async function ce(e,r){let t=E("Creating RapidKit workspace...").start();try{await promises.mkdir(e,{recursive:true}),await promises.mkdir(n.join(e,".rapidkit"),{recursive:true});let a={workspace_name:r.name,author:r.author,rapidkit_version:b(),created_at:new Date().toISOString(),type:"workspace"};await promises.writeFile(n.join(e,".rapidkit","config.json"),JSON.stringify(a,null,2));let{syncWorkspaceFoundationFiles:o}=await import('./create-P3USIH52.js');await o(e,{workspaceName:r.name,installMethod:"venv",writeMarker:true,writeGitignore:false,onlyIfMissing:true});let{publishWorkspaceRegistrySummary:d}=await import('./workspace-registry-summary-X5WRUU3T.js');await d(e);let c=J();await promises.writeFile(n.join(e,"rapidkit"),c),await promises.chmod(n.join(e,"rapidkit"),493);let s=z();await promises.writeFile(n.join(e,"rapidkit.cmd"),s);let p=U(r.name);if(await promises.writeFile(n.join(e,"README.md"),p),await promises.writeFile(n.join(e,".gitignore"),`# RapidKit workspace
|
|
4
4
|
.env
|
|
5
5
|
.env.*
|
|
6
6
|
!.env.example
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {a}from'./chunk-
|
|
1
|
+
import {a}from'./chunk-DAPZJHMN.js';import {a as a$2}from'./chunk-KMUWWZRT.js';import {a as a$1,e}from'./chunk-64RTZBHU.js';import l from'chalk';import Y from'fs';import y from'path';import {execa}from'execa';var Z="autopilot-release-last-run.json",ee="autopilot-release.json";function $(s){try{return JSON.parse(s)}catch{return null}}function ge(s){let t=y.resolve(s),o=a$2(t);if(!o)throw new Error("No RapidKit workspace found in current directory or parents");return o}async function b(s,t){let o=process.argv[1];if(!o)return {exitCode:1,stdout:"",stderr:"RapidKit entrypoint is unavailable for autopilot execution.",crashed:true};try{let a=await execa(process.execPath,[o,...s],{cwd:t,reject:false,env:{...process.env,RAPIDKIT_AUTOPILOT_CHILD:"1"}});return {exitCode:Number(a.exitCode??1),stdout:a.stdout,stderr:a.stderr,crashed:false}}catch(a){return {exitCode:1,stdout:"",stderr:a instanceof Error?a.message:String(a),crashed:true}}}function te(s){let t=s.toLowerCase();return t==="pass"?"pass":t==="warn"?"warn":t==="fail"?"fail":"warn"}function se(s){return s.summary.failed>0||s.gates.results.some(t=>t.status==="fail")?"fail":s.gates.results.some(t=>t.status==="warn")?"warn":"pass"}function we(s){let t=s.filter(a=>a.status!=="skipped");if(t.length===0)return 100;let o=t.reduce((a,e)=>e.status==="pass"?a+1:e.status==="warn"?a+.6:a,0);return Math.round(o/t.length*100)}function he(s){return s.executionError?["Re-run: npx rapidkit autopilot release --mode audit --json","Inspect .rapidkit/reports/autopilot-release-last-run.json for execution failure details"]:s.blockers.length>0?["Run: npx rapidkit doctor workspace --plan","Run: npx rapidkit readiness --json --strict","Run: npx rapidkit workspace run test --affected --strict"]:s.hasWarnings&&s.mode!=="enforce"?["Review warning-level findings in autopilot report","Optionally run: npx rapidkit autopilot release --mode safe-fix"]:["Workspace is release-ready based on current autopilot policy"]}async function U(s,t){await Y.promises.mkdir(y.dirname(s),{recursive:true}),await Y.promises.writeFile(s,`${JSON.stringify(t,null,2)}
|
|
2
2
|
`,"utf-8");}async function je(s){let t=ge(s.workspacePath),o=s.mode,a$2=[],e$1=[],F,B,C,O,J,G=0,f=false,I=0,T=0,D=-1,N=-1,c="skipped",p="skipped",re=o==="enforce"?["doctor","workspace","--json","--strict"]:["doctor","workspace","--json","--ci"];if(s.skipPipelineStages)a$2.push({name:"doctor-workspace",status:"skipped",durationMs:0,summary:"doctor stage skipped (pipeline already executed)"},{name:"analyze",status:"skipped",durationMs:0,summary:"analyze stage skipped (pipeline already executed)"},{name:"readiness",status:"skipped",durationMs:0,summary:"readiness stage skipped (pipeline already executed)"});else {let r=Date.now(),i=await b([...re],t),m=Date.now()-r;if(c="pass",i.crashed)c="fail",f=true,e$1.push(`doctor workspace execution error: ${i.stderr||"unknown error"}`);else if(i.exitCode===1)c="fail",e$1.push("doctor workspace command failed or reported errors");else if(i.exitCode===2)c="warn",e$1.push("doctor workspace reported warnings");else if(i.exitCode!==0)c="fail",e$1.push("doctor workspace command failed");else {let d=$(i.stdout),j=d&&d.healthScore&&typeof d.healthScore=="object"?d.healthScore:{},k=Number(j.errors??0),E=Number(j.warnings??0);Number.isFinite(k)&&k>0?(c="fail",e$1.push(`doctor workspace reports ${k} error(s)`)):Number.isFinite(E)&&E>0&&(c="warn");}D=a$2.push({name:"doctor-workspace",status:c,durationMs:m,summary:c==="pass"?"doctor workspace passed":c==="warn"?"doctor workspace reported warnings":"doctor workspace reported errors"})-1,o==="enforce"&&c==="warn"&&e$1.push("doctor workspace reported warnings under enforce mode");let g=Date.now(),w=await b(["analyze","--json"],t),v=Date.now()-g;B=y.join(t,".rapidkit","reports","analyze-last-run.json");let n="pass";if(w.crashed)n="fail",f=true,e$1.push(`analyze execution error: ${w.stderr||"unknown error"}`);else if(w.exitCode!==0)n=w.exitCode===2?"warn":"fail",e$1.push(w.exitCode===2?"analyze reported needs-attention verdict":"analyze command failed or reported blocked verdict");else {let d=$(w.stdout),j=d&&d.summary&&typeof d.summary=="object"?d.summary:{},k=String(j.verdict??"ready");k==="blocked"?(n="fail",e$1.push("analyze reported blocked verdict")):k==="needs-attention"&&(n="warn");}a$2.push({name:"analyze",status:n,durationMs:v,summary:n==="pass"?"analyze passed":n==="warn"?"analyze reported needs-attention":"analyze reported blocked verdict"}),o==="enforce"&&n==="warn"&&e$1.push("analyze reported warnings under enforce mode");let P=Date.now(),h=await b(["readiness","--json"],t),R=Date.now()-P;if(p="fail",h.crashed)p="fail",f=true,e$1.push(`readiness execution error: ${h.stderr||"unknown error"}`);else if(h.exitCode!==0)p="fail",e$1.push("readiness command failed");else {let d=$(h.stdout),j=String(d?.overallStatus??"fail");if(p=te(j),typeof d?.evidencePath=="string"&&d.evidencePath.trim().length>0&&(F=d.evidencePath),p==="fail"){let k=Array.isArray(d?.blockingReasons)?d?.blockingReasons.filter(E=>typeof E=="string"):[];k.length>0?e$1.push(...k.map(E=>`readiness: ${E}`)):e$1.push("readiness overall status is fail");}}N=a$2.push({name:"readiness",status:p,durationMs:R,summary:`readiness overall status is ${p}`})-1,o==="enforce"&&p==="warn"&&e$1.push("readiness reported warnings under enforce mode");}let ae=Date.now(),M=await b(["doctor","workspace","--plan","--json"],t),oe=Date.now()-ae,S="warn";if(M.crashed)S="fail",f=true,e$1.push(`doctor remediation plan execution error: ${M.stderr||"unknown error"}`);else if(M.exitCode!==0)S="fail",e$1.push("doctor remediation plan command failed");else {let r=$(M.stdout),i=r&&r.remediationPlan&&typeof r.remediationPlan=="object"?r.remediationPlan:null,m=Number(i?.totalSteps??0),g=Number(i?.executableSteps??0);Number.isFinite(m)&&m>0&&(I=m),Number.isFinite(g)&&g>0&&(T=g),Number.isFinite(m)&&m===0?S="pass":S="warn";}if(a$2.push({name:"remediation-plan",status:S,durationMs:oe,summary:S==="pass"?"no remediation steps required":"remediation steps available"}),o==="enforce"&&S==="warn"&&e$1.push("remediation plan has pending steps under enforce mode"),o==="safe-fix"){let r=Date.now(),i=await b(["doctor","workspace","--apply"],t),m=Date.now()-r,g=i.crashed||i.exitCode!==0?"fail":"pass";if(i.crashed)f=true,e$1.push(`doctor remediation apply execution error: ${i.stderr||"unknown error"}`);else if(g==="fail")e$1.push("doctor remediation apply failed");else {G=T>0?T:I>0?I:1;let w=await b(["doctor","workspace","--json"],t);if(w.crashed)c="fail",f=true,e$1.push(`post-apply doctor execution error: ${w.stderr||"unknown error"}`);else if(w.exitCode!==0)c="fail",e$1.push("post-apply doctor workspace command failed");else {let n=$(w.stdout),P=n&&n.healthScore&&typeof n.healthScore=="object"?n.healthScore:{},h=Number(P.errors??0),R=Number(P.warnings??0);Number.isFinite(h)&&h>0?(c="fail",e$1.push(`post-apply doctor reports ${h} error(s)`)):Number.isFinite(R)&&R>0?c="warn":c="pass";}D>=0&&(a$2[D].status=c,a$2[D].summary=`doctor workspace post-apply status is ${c}`);let v=await b(["readiness","--json"],t);if(v.crashed)p="fail",f=true,e$1.push(`post-apply readiness execution error: ${v.stderr||"unknown error"}`);else if(v.exitCode!==0)p="fail",e$1.push("post-apply readiness command failed");else {let n=$(v.stdout),P=String(n?.overallStatus??"fail");if(p=te(P),typeof n?.evidencePath=="string"&&n.evidencePath.trim().length>0&&(F=n.evidencePath),p==="fail"){let h=Array.isArray(n?.blockingReasons)?n?.blockingReasons.filter(R=>typeof R=="string"):[];h.length>0?e$1.push(...h.map(R=>`post-apply readiness: ${R}`)):e$1.push("post-apply readiness overall status is fail");}}N>=0&&(a$2[N].status=p,a$2[N].summary=`readiness post-apply overall status is ${p}`);}a$2.push({name:"remediation-apply",status:g,durationMs:m,summary:g==="pass"?"safe remediation apply completed":"safe remediation apply failed"});}else a$2.push({name:"remediation-apply",status:"skipped",durationMs:0,summary:"remediation apply is skipped for this mode"});let ne=Date.now(),x="pass",A="workspace test/build completed for selected projects";try{let r=await a({workspacePath:t,stage:"test",affected:true,since:s.since,parallel:s.parallel,maxWorkers:s.maxWorkers,strict:true,json:true,enforceGates:false});C=y.join(t,".rapidkit","reports",a$1),await e(t,r),O=C;let i=se(r);if(i==="fail")x="fail",A="workspace test stage failed for selected projects",e$1.push("workspace run test failed for selected projects");else {i==="warn"&&(x="warn",A="workspace test stage completed with warnings",o==="enforce"&&e$1.push("workspace run test reported warnings under enforce mode"));let m=await a({workspacePath:t,stage:"build",affected:true,since:s.since,parallel:s.parallel,maxWorkers:s.maxWorkers,strict:true,json:true,enforceGates:false});await e(t,m),J=C;let g=se(m);g==="fail"?(x="fail",A="workspace build stage failed for selected projects",e$1.push("workspace run build failed for selected projects")):g==="warn"&&(x="warn",A="workspace test/build completed with warnings",o==="enforce"&&e$1.push("workspace run test/build reported warnings under enforce mode"));}}catch(r){x="fail",A="workspace test/build orchestration failed",f=true,e$1.push(`workspace run orchestration error: ${r instanceof Error?r.message:String(r)}`);}let ie=Date.now()-ne;a$2.push({name:"workspace-run-test-build",status:x,durationMs:ie,summary:A});let z=a$2.filter(r=>r.status==="warn").length,le=a$2.filter(r=>r.status==="fail").length,L=o==="enforce"?a$2.some(r=>r.status==="warn"||r.status==="fail"):le>0,W=[...new Set(e$1)],ce=f||L?Math.max(1,W.length):0,de=we(a$2),pe=f||L?"blocked":z>0?"partial":"approved",ue=f?3:L?1:z>0?2:0,fe=he({mode:o,executionError:f,blockers:W,hasWarnings:z>0}),V=y.join(t,".rapidkit","reports"),H=y.join(V,Z),q=y.join(V,ee),u={schemaVersion:"autopilot-release-v1",generatedAt:new Date().toISOString(),workspacePath:t,mode:o,summary:{releaseScore:de,verdict:pe,blockers:ce,warnings:z,safeFixesApplied:G,manualActions:W.length,exitCode:ue},stages:a$2,blockingReasons:W,nextActions:fe,artifacts:{reportPath:H,aliasEvidencePath:q,analyzeEvidencePath:B,readinessEvidencePath:F,workspaceRunEvidencePath:C,workspaceRunTestPath:O,workspaceRunBuildPath:J},enterpriseControls:{jsonReady:true,evidencePath:`.rapidkit/reports/${Z}`,aliasEvidencePath:`.rapidkit/reports/${ee}`}};if(await U(H,u),await U(q,u),s.output&&await U(y.resolve(s.output),u),!s.json){console.log(l.bold.cyan(`
|
|
3
3
|
\u{1F680} RapidKit Autopilot Release
|
|
4
4
|
`)),console.log(l.bold(`Workspace: ${l.cyan(y.basename(t))}`)),console.log(l.gray(`Path: ${t}`)),console.log(l.white(`Mode: ${o}`)),console.log(l.white(`Verdict: ${u.summary.verdict==="approved"?l.green("approved"):u.summary.verdict==="partial"?l.yellow("partial"):l.red("blocked")}`)),console.log(l.white(`Release score: ${u.summary.releaseScore}`));for(let r of u.stages){let i=r.status==="pass"?l.green("PASS"):r.status==="warn"?l.yellow("WARN"):r.status==="skipped"?l.gray("SKIP"):l.red("FAIL");console.log(` - ${r.name}: ${i} ${r.summary} (${r.durationMs}ms)`);}if(u.blockingReasons.length>0){console.log(l.bold.red(`
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {k,e as e$1}from'./chunk-
|
|
1
|
+
import {k,e as e$1}from'./chunk-T7B3GF3Q.js';import {b as b$2}from'./chunk-CDCYRBAY.js';import {e,g,f as f$1,b as b$4,c as c$1,d as d$1}from'./chunk-E5ZVQL3C.js';import {a,d,b as b$1}from'./chunk-7BEZH5LE.js';import {b}from'./chunk-Q2KZIBV4.js';import {f,c,e as e$2}from'./chunk-OLDPVVSV.js';import {b as b$3,j,i,l,h,q}from'./chunk-WRMCPKGA.js';import {promises}from'fs';import*as P from'fs-extra';import m from'path';import t from'chalk';import {execa}from'execa';async function H(e,o={}){let n=m.resolve(e),r=o.workspaceName??m.basename(n);try{let{registerWorkspace:a}=await import('./workspace-5DKOA7TN.js');await a(n,r);}catch(a){o.silent||console.warn(t.gray(`Note: Could not register workspace in shared registry: ${a?.message??a}`));}try{let{syncWorkspaceContract:a}=await import('./workspace-contract-OO4GMENV.js'),c=await a({workspacePath:n});if(o.silent||console.log(t.gray(`\u2139\uFE0F Workspace intelligence synced (contract + registry summary, ${c.contract.projects.length} project(s)).`)),!o.silent&&c.verification.status!=="passed"){console.log(t.yellow("\u26A0\uFE0F Workspace contract verification reported issues."));for(let d of c.verification.violations)console.log(t.gray(` Violation: ${d}`));console.log(t.white(" Next: npx rapidkit workspace contract inspect"));}}catch(a){o.silent||console.warn(t.gray(`Note: Could not sync workspace intelligence layer: ${a?.message??a}`));}}function S(){return h()}async function B(e,o,n,r){let a=d(o,b(),n);r&&(a.metadata||(a.metadata={}),a.metadata.python={version:r}),await b$1(e,a);}async function z(e){await P.outputFile(m.join(e,".gitignore"),`.venv/
|
|
2
2
|
__pycache__/
|
|
3
3
|
*.pyc
|
|
4
4
|
.env
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {f,e}from'./chunk-PCXSTKZ5.js';import {a,b}from'./chunk-KMUWWZRT.js';import {c as c$1}from'./chunk-NFUXULIF.js';import {a as a$1,b as b$1,d as d$1,c,f as f$1}from'./chunk-YBS2HGO3.js';import u from'chalk';import d from'fs';import h from'fs-extra';import l from'path';var $="release-readiness-v1";function I(t,e){let a=l.resolve(t);if(!b(a))return a;let s=l.join(e,".rapidkit","workspace.contract.json");if(d.existsSync(s))try{let i=JSON.parse(d.readFileSync(s,"utf-8")),n=Array.isArray(i.projects)?i.projects:[];for(let c of n){let f=p(c),g=typeof f.relativePath=="string"?f.relativePath.trim():"";if(g)return l.join(e,g)}}catch{}let r=x(e),o=Array.isArray(r.payload?.projects)?r.payload.projects:[];for(let i of o){let n=p(i),c=typeof n.path=="string"?n.path.trim():"";if(c)return l.resolve(c)}return a}function V(t){let e=a$1(t);return b$1(e,t)?"go":d$1(e,t)?"java":c(e,t)?"node":f$1(e,t)?"python":"unknown"}function O(t,e){if(!d.existsSync(t))return null;let a=d.readdirSync(t).filter(s=>s.endsWith(".json")&&e.some(r=>r.test(s))).map(s=>l.join(t,s));return a.length===0?null:(a.sort((s,r)=>d.statSync(r).mtimeMs-d.statSync(s).mtimeMs),a[0])}function p(t){return t&&typeof t=="object"&&!Array.isArray(t)?t:{}}async function z(t){let{readWorkspaceRegistrySummary:e,resolveWorkspaceRegisteredProjects:a}=await import('./workspace-registry-summary-X5WRUU3T.js'),s=await e(t);return s?s.projectCount:(await a(t)).summary.projectCount}function L(t,e,a){let s=l.join(t,".rapidkit","toolchain.lock");if(!d.existsSync(s))return {gate:"env",status:"fail",summary:"toolchain.lock is missing",details:["Run rapidkit bootstrap to pin runtime versions and generate a reproducible toolchain."],evidencePath:s};try{let r=JSON.parse(d.readFileSync(s,"utf-8")),o=p(r.runtime),n=["python","node","go","java"].filter(c=>{let f=p(o[c]);return typeof f.version=="string"&&f.version.trim().length>0});if(n.length===0)return {gate:"env",status:"fail",summary:"No runtime versions are pinned in toolchain.lock",details:["Pin at least one runtime version via rapidkit setup <runtime> and re-run bootstrap."],evidencePath:s};if(e!=="unknown"){let c=p(o[e]);if(typeof c.version!="string"||c.version.trim().length===0)return {gate:"env",status:"fail",summary:`${a?.hasRegisteredProjects?"Project runtime":"Workspace"} (${e}) is not pinned in toolchain.lock`,details:[`Run rapidkit setup ${e} and rapidkit bootstrap to lock ${e} for this workspace.`],evidencePath:s}}return {gate:"env",status:"pass",summary:`Pinned runtimes: ${n.join(", ")}`,details:[],evidencePath:s}}catch{return {gate:"env",status:"fail",summary:"toolchain.lock is invalid JSON",details:["Regenerate lockfile with rapidkit bootstrap."],evidencePath:s}}}function x(t){let e=l.join(t,".rapidkit","reports","doctor-last-run.json");if(!d.existsSync(e))return {payload:null,path:e};try{let a=JSON.parse(d.readFileSync(e,"utf-8"));return c$1(a,"workspace")?{payload:a,path:e}:{payload:null,path:e}}catch{return {payload:null,path:e}}}function D(t){let e=x(t);if(!e.payload)return {gate:{gate:"doctor",status:"fail",summary:"Doctor evidence is missing",details:["Run rapidkit doctor workspace --json before release readiness checks."],evidencePath:e.path},payload:null};let a=p(e.payload.summary),s=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}:s>0?{gate:{gate:"doctor",status:"warn",summary:`Doctor found ${s} issue(s)`,details:["Run rapidkit 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 J(t){let e=l.join(t,".rapidkit","reports","analyze-last-run.json");if(!d.existsSync(e))return {gate:"analyze",status:"fail",summary:"Analyze evidence is missing",details:["Run rapidkit analyze --json before release readiness checks."],evidencePath:e};try{let a=JSON.parse(d.readFileSync(e,"utf-8")),s=p(a.summary),r=String(s.verdict??"").toLowerCase(),o=Number(s.score??0),i=p(s.findings),n=Number(i.fail??0);return r==="blocked"||n>0?{gate:"analyze",status:"fail",summary:`Analyze verdict is blocked (score ${o}/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 ${o}/100)`,details:["Review analyze warnings before release."],evidencePath:e}:{gate:"analyze",status:"pass",summary:`Analyze passed (score ${o}/100)`,details:[],evidencePath:e}}catch{return {gate:"analyze",status:"fail",summary:"Analyze evidence is invalid JSON",details:["Re-run rapidkit analyze --json to regenerate evidence."],evidencePath:e}}}function W(t){try{let e=JSON.parse(d.readFileSync(t,"utf-8")),a=String(e.status??"").toLowerCase(),s=p(e.summary),r=Number(s.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 F(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=l.join(t,".rapidkit","reports"),s=O(a,[/verify-pack-contract/i,/^verify.*\.json$/i]);if(s)return W(s);let r=l.join(a,"workspace-contract-verify-last-run.json"),o=O(a,[/workspace-contract-verify-last-run/i,/workspace-contract-verify/i]);if(o)try{let i=JSON.parse(d.readFileSync(o,"utf-8")),n=String(i.status??"").toLowerCase();if(n==="passed"||n==="pass")return {gate:"verify",status:"pass",summary:"Workspace contract verification passed (CLI cache)",details:[],evidencePath:o};if(n==="failed"||n==="fail")return {gate:"verify",status:"fail",summary:"Workspace contract verification failed (CLI cache)",details:(Array.isArray(i.violations)?i.violations:[]).slice(0,5),evidencePath:o}}catch{}try{let{verifyWorkspaceContract:i}=await import('./workspace-contract-OO4GMENV.js'),n=await i({workspacePath:t}),c={schemaVersion:"v1",source:"cli",generatedAt:new Date().toISOString(),status:n.status,contractPath:n.contractPath,projectCount:n.projectCount,checks:n.checks,violations:n.violations};return await h.ensureDir(a),await h.writeJSON(r,c,{spaces:2}),n.status==="failed"?{gate:"verify",status:"fail",summary:"Workspace contract verification failed (CLI)",details:n.violations.slice(0,5),evidencePath:r}:{gate:"verify",status:"pass",summary:"Workspace contract verification passed (CLI)",details:[],evidencePath:r}}catch(i){return {gate:"verify",status:"fail",summary:"No verify evidence and workspace contract verification unavailable",details:["Run rapidkit workspace contract verify --json or export verify-pack contract from CI.",i instanceof Error?i.message:String(i)],evidencePath:l.join(a,"*verify*.json")}}}function M(t,e){let a=l.join(e,".rapidkit","reports","doctor-last-run.json");if(!t)return {gate:"dependency",status:"warn",summary:"Dependency risk check skipped (doctor evidence missing)",details:["Run rapidkit doctor workspace --json to include dependency findings."],evidencePath:a};let s=Array.isArray(t.projects)?t.projects:[],r=s.reduce((i,n)=>{let c=Number(n.vulnerabilities??0);return Number.isFinite(c)?i+Math.max(0,c):i},0),o=s.filter(i=>i.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}:o>0?{gate:"dependency",status:"warn",summary:`${o} 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 _(t){return t.some(e=>e.status==="fail")?"fail":t.some(e=>e.status==="warn")?"warn":"pass"}async function K(t,e){let a=l.join(t,".rapidkit","reports","release-readiness-last-run.json");return await h.ensureDir(l.dirname(a)),await h.writeJSON(a,e,{spaces:2}),a}async function H(t={}){let e$1=l.resolve(t.startPath??process.cwd()),a$1=a(e$1)??e$1,s=await z(a$1)>0,r=s&&b(e$1)?a$1:I(e$1,a$1),o=r===a$1?"unknown":V(r),n=L(a$1,s?o:"unknown",{hasRegisteredProjects:s}),c=D(a$1),f$1=J(a$1),g=await F(a$1,{skipVerify:t.skipVerify}),G=M(c.payload,a$1),k=[n,c.gate,f$1,g,G],v=_(k),m={schemaVersion:$,generatedAt:new Date().toISOString(),workspacePath:a$1,projectPath:r,action:t.action,overallStatus:v,blocking:v==="fail",blockingReasons:k.filter(y=>y.status==="fail").map(y=>`${y.gate}: ${y.summary}`),gates:k};if(t.writeReport!==false){let y=f(m,{commandId:"workspaceReadiness",exitCode:v==="fail"?2:v==="warn"?1:0,generatedAt:m.generatedAt,blockers:m.blockingReasons,runId:e()});m.evidencePath=await K(a$1,y);}return m}function B(t){return t==="pass"?u.green("PASS"):t==="warn"?u.yellow("WARN"):u.red("FAIL")}function U(t){return t==="pass"?u.green("PASS"):t==="warn"?u.yellow("WARN"):u.red("FAIL")}async function ne(t){let e=await H({writeReport:true,skipVerify:t.skipVerify===true});if(t.json)console.log(JSON.stringify(e,null,2));else {console.log(u.bold.cyan(`
|
|
2
2
|
\u{1F6A6} RapidKit Release Readiness
|
|
3
3
|
`)),console.log(u.bold(`Workspace: ${u.cyan(l.basename(e.workspacePath))}`)),console.log(u.gray(`Path: ${e.workspacePath}`)),console.log(`Overall: ${U(e.overallStatus)}`);for(let a of e.gates){console.log(` - ${a.gate}: ${B(a.status)} ${a.summary}`);for(let s of a.details)console.log(u.gray(` ${s}`));a.evidencePath&&console.log(u.gray(` evidence: ${a.evidencePath}`));}e.evidencePath&&console.log(u.gray(`
|
|
4
4
|
Evidence saved: ${e.evidencePath}`));}t.strict&&e.overallStatus!=="pass"&&process.exit(1);}export{H as a,ne as b};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {f as f$1,e}from'./chunk-PCXSTKZ5.js';import {a,b}from'./chunk-KMUWWZRT.js';import {h,i}from'./chunk-UZW5QFRW.js';import {a as a$1}from'./chunk-TDSIF42O.js';import y from'fs';import o from'path';import s from'chalk';var T=new Set([".git",".rapidkit",".venv","node_modules","dist","build","target","coverage","htmlcov",".next"]);async function k(e){try{return await y.promises.access(e,y.constants.F_OK),true}catch{return false}}async function z(e){try{let n=JSON.parse(await y.promises.readFile(e,"utf-8"));return n&&typeof n=="object"&&!Array.isArray(n)?n:null}catch{return null}}async function N(e){try{return await y.promises.readFile(e,"utf-8")}catch{return ""}}function O(e){return a(e)}async function K(e,n){return await k(o.join(e,".rapidkit","project.json"))||await k(o.join(e,".rapidkit","context.json"))?true:b(e)?false:o.resolve(e)===o.resolve(n)?h(e).length>0:h(e).length>0}async function M(e){let n=await a$1(e,{skipDirs:T,includeHiddenDirs:false,descendIntoMatchedProjects:false,isProjectDir:K});return n.length>0?n:b(e)?[]:h(e).length>0?[e]:[]}function _(e,n){return o.relative(e,n).replace(/\\/g,"/")||"."}async function A(e,n){for(let t of n)if(await k(o.join(e,t)))return true;return false}async function J(e){return A(e,["health","health.ts","health.js","health.py","health.go","health.kt","health.rb","health.php","healthcheck","health-check","src/health.ts","src/health.js","src/health.py","src/health.go","src/health.kt","src/health.rb","src/health.php","src/healthcheck.ts","src/healthcheck.js","src/liveness.ts","src/readiness.ts","src/ping.ts"])}async function W(e){if(await A(e,["tests","test","__tests__","src/__tests__","pytest.ini","vitest.config.ts","jest.config.ts"]))return true;let t=await z(o.join(e,"package.json")),i=t?.scripts&&typeof t.scripts=="object"?t.scripts:{};return typeof i.test=="string"&&i.test.trim().length>0}async function H(e){let n=await z(o.join(e,"package.json")),t=n?.scripts&&typeof n.scripts=="object"?n.scripts:{};return Object.keys(t).sort()}function f(e,n,t,i,r,d){return {id:e,severity:n,target:t,title:i,detail:r,remediation:d}}function B(e){let n=e.reduce((t,i)=>i.severity==="fail"?t+28:i.severity==="warn"?t+12:t+3,0);return Math.max(0,100-n)}async function U(e,n){let t=await z(o.join(n,".rapidkit","project.json")),i$1=i(n,t),r=h(n),d=i$1.runtime==="unknown"?r[0]||"unknown":i$1.runtime,a=_(e,n),p=a,g=await H(n),u=await k(o.join(n,".rapidkit","project.json"))||await k(o.join(n,".rapidkit","context.json")),l=await W(n),h$1=await A(n,["Dockerfile","dockerfile"]),w=await A(n,[".env.example","env.example","config/env.example"]),P=await A(n,[".github/workflows/ci.yml",".github/workflows/ci.yaml",".github/workflows/main.yml",".github/workflows/build.yml",".github/workflows/test.yml",".github/workflows/deploy.yml",".gitlab-ci.yml",".circleci/config.yml","azure-pipelines.yml","bitbucket-pipelines.yml","cloudbuild.yaml"]),R=await J(n),m=[];return i$1.key==="unknown"&&m.push(f("project.stack.unknown","fail",p,"Project stack is unknown","RapidKit cannot confidently classify this backend project.","Add .rapidkit/project.json metadata or import the project with `rapidkit import`.")),u||m.push(f("project.marker.missing","warn",p,"RapidKit marker is missing","The project can be detected by files, but it is not registered with RapidKit metadata.","Run `rapidkit import <path>` from a workspace or create the project through RapidKit.")),l||m.push(f("project.tests.missing","warn",p,"Test entrypoint is missing","No common test folder, config, or package test script was found.","Add a test command so `rapidkit workspace run test --affected` can gate changes.")),w||m.push(f("project.env.example.missing","info",p,"Environment example is missing","No .env.example or env.example file was found.","Add an env example for onboarding and CI secret documentation.")),P||m.push(f("project.ci.missing","warn",p,"Continuous integration is missing","No recognized CI/CD configuration file was detected for this project.","Add CI configuration so tests and checks run automatically for every change.")),R||m.push(f("project.health.missing","info",p,"Health or readiness probe is missing","The project has no obvious health or readiness endpoint to support automated deployment and runtime checks.","Add a simple health endpoint and document it for readiness gates and observability.")),h$1||m.push(f("project.container.missing","info",p,"Container recipe is missing","No Dockerfile was found for this project.","Add a Dockerfile when the service is intended for containerized deployment.")),{name:o.basename(n),path:n,relativePath:a,runtime:d,framework:i$1.key,confidence:i$1.confidence,supportTier:i$1.supportTier,hasRapidKitMarker:u,hasTests:l,hasDockerfile:h$1,hasEnvExample:w,hasCiConfig:P,hasHealthEndpoint:R,scripts:g,findings:m,score:B(m)}}function V(e){return e.name.toLowerCase()}async function L(e){let n=new Map(e.map(r=>[V(r),r])),t=[];for(let r of e){let d=await z(o.join(r.path,"package.json")),a={...d?.dependencies??{},...d?.devDependencies??{},...d?.peerDependencies??{}};for(let g of Object.keys(a)){let u=g.replace(/^@[^/]+\//,"").toLowerCase(),l=n.get(u);l&&l.relativePath!==r.relativePath&&t.push({from:r.relativePath,to:l.relativePath,kind:"package"});}let p=await N(o.join(r.path,"pyproject.toml"));for(let g of e)g.relativePath!==r.relativePath&&p.includes(g.name)&&t.push({from:r.relativePath,to:g.relativePath,kind:"workspace-reference"});}let i=new Set;return t.filter(r=>{let d=`${r.from}\0${r.to}\0${r.kind}`;return i.has(d)?false:(i.add(d),true)})}function q(e,n){let t=new Map;for(let i of e)t.set(i.relativePath,{project:i.relativePath,directDependents:0,directDependencies:0});for(let i of n){let r=t.get(i.from),d=t.get(i.to);r&&(r.directDependencies+=1),d&&(d.directDependents+=1);}return Array.from(t.values()).sort((i,r)=>r.directDependents-i.directDependents||r.directDependencies-i.directDependencies)}async function Q(e){let n=await z(o.join(e,".rapidkit","workspace.json"));return typeof n?.profile=="string"?n.profile:null}function X(e){return {fail:e.filter(n=>n.severity==="fail").length,warn:e.filter(n=>n.severity==="warn").length,info:e.filter(n=>n.severity==="info").length}}function Y(e){if(e.projectCount===0)return e.workspaceDetected?["Add your first project: npx rapidkit create project <name> --kit <kit>","Import an existing service: npx rapidkit import <path>"]:["Create a RapidKit workspace: npx rapidkit create workspace my-workspace --profile polyglot","Import an existing service: npx rapidkit import ../service"];let n=[];return e.findings.some(t=>t.id==="workspace.marker.missing")&&n.push("Initialize workspace metadata with `rapidkit bootstrap --profile polyglot`."),e.findings.some(t=>t.id==="project.marker.missing")&&n.push("Register detected projects with `rapidkit import <path>` or recreate them via `rapidkit create project`."),e.findings.some(t=>t.id==="project.tests.missing")&&n.push("Add test entrypoints, then gate changes with `rapidkit workspace run test --affected --strict`."),e.findings.some(t=>t.id==="project.ci.missing")&&n.push("Add CI/CD configuration to catch regressions early and make workspace health checks actionable."),e.findings.some(t=>t.id==="project.health.missing")&&n.push("Add a health/readiness endpoint so runtime probes and deployment checks can verify service health."),e.hasGraph||n.push("Create `.rapidkit/workspace-dependency-graph.json` or use analyze output as the first graph seed."),n.push("Run `rapidkit autopilot release --mode audit --json` before release."),Array.from(new Set(n))}async function ce(e$1={}){let n=o.resolve(e$1.workspacePath||process.cwd());if(!await k(n))throw new Error(`Workspace path does not exist: ${n}`);let t=O(n)??n,i=await k(o.join(t,".rapidkit-workspace"))||await k(o.join(t,".rapidkit","workspace.json")),r=await Q(t),d=await M(t),a=await Promise.all(d.map(c=>U(t,c))),p=await L(a),g=q(a,p),u=[];i||u.push(f("workspace.marker.missing","warn",".","Workspace metadata is missing","The directory can be analyzed, but it is not a registered RapidKit workspace.","Run `rapidkit create workspace` or `rapidkit bootstrap --profile polyglot` in a workspace root.")),a.length===0&&u.push(f("workspace.projects.missing","warn",".","No backend projects detected","RapidKit did not find runtime markers or project metadata under this root.","Create a project with `rapidkit create project` or import one with `rapidkit import <path>`."));let l=[...u,...a.flatMap(c=>c.findings)],h=X(l),w={};for(let c of a)w[c.runtime]=(w[c.runtime]||0)+1;let P=a.length>0?Math.round(a.reduce((c,v)=>c+v.score,0)/a.length):0,R=u.reduce((c,v)=>c+(v.severity==="fail"?20:v.severity==="warn"?8:2),0),m=Math.max(0,P-R),E=a.length===0&&h.fail===0&&l.length>0&&l.every(c=>c.id==="workspace.projects.missing"&&c.severity==="warn"),S=h.fail>0||e$1.strict&&h.warn>0&&!E?"blocked":h.warn>0?"needs-attention":"ready",j={schemaVersion:"rapidkit-analyze-v1",generatedAt:new Date().toISOString(),workspacePath:t,workspaceDetected:i,profile:r,summary:{score:m,verdict:S,projectCount:a.length,runtimeCount:Object.keys(w).length,findings:h},runtimes:w,projects:a,dependencyGraph:{status:p.length>0?"generated":"empty",edges:p,topImpactedProjects:g.slice(0,5)},findings:l,nextActions:Y({findings:l,projectCount:a.length,hasGraph:p.length>0,workspaceDetected:i}),enterpriseControls:{jsonReady:true,ciGateCommand:"rapidkit analyze --json --strict",releaseGateCommand:"rapidkit autopilot release --mode enforce --json",evidencePath:".rapidkit/reports/analyze-last-run.json"}};if(e$1.output&&(await y.promises.mkdir(o.dirname(o.resolve(e$1.output)),{recursive:true}),await y.promises.writeFile(o.resolve(e$1.output),`${JSON.stringify(j,null,2)}
|
|
2
2
|
`)),!e$1.output&&i){let c=o.join(t,".rapidkit","reports","analyze-last-run.json");await y.promises.mkdir(o.dirname(c),{recursive:true});let v=f$1(j,{commandId:"workspaceAnalyze",exitCode:j.summary.verdict==="blocked"?2:j.summary.verdict==="needs-attention"?1:0,generatedAt:j.generatedAt,blockers:j.findings.filter(x=>x.severity==="fail").map(x=>x.title).slice(0,12),runId:e()});await y.promises.writeFile(c,`${JSON.stringify(v,null,2)}
|
|
3
3
|
`);}return j}function de(e){let n=e.summary.verdict==="ready"?s.green:e.summary.verdict==="needs-attention"?s.yellow:s.red;if(console.log(s.bold(`
|
|
4
4
|
RapidKit Workspace Analysis
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import {b as b$1}from'./chunk-CDCYRBAY.js';import {r,j}from'./chunk-E5ZVQL3C.js';import {f}from'./chunk-OLDPVVSV.js';import {b}from'./chunk-MIWDCR6I.js';import f$1,{promises}from'fs';import i from'path';import j$1,{homedir}from'os';import {pathToFileURL}from'url';import l from'process';function R(t){let r=t.label.indexOf(" \u2014 ");return r>=0?t.label.slice(r+3).trim():t.label.trim()}function E(){let t=r().map(r=>({value:r.id,label:R(r),hint:r.description,name:r.label})),e=j().map(r=>({value:r.kitId,label:r.displayName,hint:r.commandDisplay("my-app"),name:`${r.displayName} \u2014 ${r.framework}`}));return [...t,...e]}var _=".rapidkitrc.json",F=["rapidkit.config.js","rapidkit.config.mjs","rapidkit.config.cjs"];async function yt(){let t=i.join(j$1.homedir(),_);try{let e=await promises.readFile(t,"utf-8"),r=JSON.parse(e);return f.debug(`Loaded config from ${t}`),r}catch{return f.debug("No user config found, using defaults"),{}}}async function vt(t=process.cwd()){let e=t,r=i.parse(e).root;for(;e!==r;){for(let n of F){let o=i.join(e,n);try{await promises.access(o),f.debug(`Found config file: ${o}`);let m=await import(pathToFileURL(o).href),P=m.default||m;return f.debug(`Loaded RapidKit config from ${n}`),P}catch{continue}}e=i.dirname(e);}return f.debug("No RapidKit config file found, using defaults"),{}}function bt(t,e,r){return {author:r.author||e.workspace?.defaultAuthor||t.author,pythonVersion:r.pythonVersion||e.workspace?.pythonVersion||t.pythonVersion,defaultInstallMethod:r.defaultInstallMethod||e.workspace?.installMethod||t.defaultInstallMethod,defaultKit:r.defaultKit||e.projects?.defaultKit||t.defaultKit,skipGit:r.skipGit??e.projects?.skipGit??t.skipGit,license:r.license||t.license,testRapidKitPath:r.testRapidKitPath||t.testRapidKitPath}}function wt(t){return process.env.RAPIDKIT_DEV_PATH||t.testRapidKitPath||void 0}var x="workspai",Rt="Workspai";function L(t){return f$1.existsSync(i.join(t,".rapidkit-workspace"))||f$1.existsSync(i.join(t,".rapidkit","workspace.json"))}function g(t=homedir()){return i.join(t,"rapidkit","workspaces")}function K(t=homedir()){return i.join(t,"Workspai","rapidkits")}function y(t,e=homedir()){return i.join(g(e),t)}function U(t,e=homedir()){return [y(t,e),i.join(K(e),t)]}function D(t,e={}){let r=e.homeDir??homedir();return e.outputDir?i.resolve(e.outputDir,t):y(t,r)}function Et(t,e=homedir()){for(let r of U(t,e))if(f$1.existsSync(r))return r}function jt(t,e="my-workspace"){let r=1;for(;;){let n=r===1?e:`${e}-${r}`,o=i.join(t,n);if(!f$1.existsSync(o))return {name:n,targetPath:o};r+=1;}}function S(t=homedir()){return [i.join(g(t),x),i.join(K(t),x)]}function Mt(t=homedir()){for(let e of S(t))if(L(e))return e;return y(x,t)}function T(t,e){let r=t.indexOf(e);if(r>=0&&r+1<t.length)return t[r+1];let n=t.find(o=>o.startsWith(`${e}=`));if(n)return n.slice(e.length+1)}function N(t){return t.includes("--here")}function W(t,e=l.cwd()){if(N(t))return i.resolve(e);let r=T(t,"--output");if(r)return i.resolve(r)}function $t(t,e=l.cwd()){let r=i.resolve(t),n=i.resolve(e),o=i.relative(n,r);return o.length>0&&!o.startsWith("..")&&!i.isAbsolute(o)?`cd ${o}`:`cd ${r}`}function Gt(t,e={}){let r=e.argv??[],n=e.outputParent??W(r,l.cwd());return D(t.trim(),{homeDir:e.homeDir,outputDir:n})}function Ot(t,e,r={}){return t?i.resolve(t)===i.resolve(e)?true:r.outputParent===void 0:false}async function Vt(t,e={}){let r=e.cwd??l.cwd(),n=e.homeDir??homedir(),o=W(t,r);if(o!==void 0)return o;let h=e.hasYes??(t.includes("--yes")||t.includes("-y"));if(!(e.interactive??(!h&&!!l.stdin.isTTY&&!b())))return;let P=g(n),{location:A}=await b$1([{type:"rawlist",name:"location",message:"Where should the workspace be created?",choices:[{value:"managed",label:"Managed home",hint:P},{value:"here",label:"Current directory",hint:r}],default:0}]);if(A==="here")return i.resolve(r)}export{E as a,yt as b,vt as c,bt as d,wt as e,Rt as f,g,Et as h,jt as i,Mt as j,$t as k,Gt as l,Ot as m,Vt as n};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {a as a$1}from'./chunk-JEI6BTZI.js';import {d as d$1,b}from'./chunk-
|
|
1
|
+
import {a as a$1}from'./chunk-JEI6BTZI.js';import {d as d$1,b}from'./chunk-3VI4Y7LZ.js';import {f}from'./chunk-THSTNVE3.js';import {a}from'./chunk-AQ4XZZC6.js';import {c,e,d}from'./chunk-GBJBQ43T.js';import {n}from'./chunk-LRF6PQOZ.js';import {j,a as a$2}from'./chunk-3PTJID76.js';import y from'path';import $ from'fs-extra';function B(e$1){switch(e$1){case "why":return d;case "trace":return e;default:return c}}async function C(e){try{return await $.pathExists(e)?await $.readJson(e):null}catch{return null}}function M(e,o){if(!e)return null;let s=o.trim().toLowerCase();return e.projects.find(r=>r.slug.toLowerCase()===s||r.relativePath.toLowerCase()===s)??null}function F(e,o,s){let r=s.trim().toLowerCase(),t=(e.graph?.nodes.map(i=>i.id)??e.projects.map(i=>i.name)).find(i=>i.toLowerCase()===r);if(t)return t;let d=e.projects.find(i=>[i.name,i.path,y.basename(i.path)].filter(u=>u.trim().length>0).some(u=>u.toLowerCase()===r));if(d)return d.name;let p=M(o,s);if(p){let i=e.projects.find(u=>u.path===p.relativePath||u.path.endsWith(`/${p.relativePath}`));if(i)return i.name}return s}function z(e,o){if(!e)return [];let s=o.trim().toLowerCase(),r=new Set;for(let a of e.projects){a.contracts.dependsOn?.some(t=>t.toLowerCase()===s)&&r.add(a.slug);for(let t of a.contracts.consumes??[])for(let d of e.projects)d.contracts.publishes?.includes(t)&&d.slug===s&&r.add(a.slug);}return [...r].sort()}function G(e,o){if(!e)return [];let s=o.trim().toLowerCase();return e.steps.filter(r=>r.scope==="project"&&r.project?.toLowerCase()===s&&r.command?.display).map(r=>r.command.display).slice(0,8)}function l(e,o,s){return {id:e,title:o,body:s.trim()}}async function ae(e){let o=y.resolve(e.workspacePath),s=(e.now??new Date).toISOString(),r=e.model??await n({workspacePath:o,includeEvidence:true}),a$2=e.contract;if(a$2===void 0)try{a$2=(await j({workspacePath:o})).contract;}catch{a$2=null;}let t=e.verify;t===void 0&&(t=await C(y.join(o,d$1)));let d=e.impact;if(d===void 0&&(d=await C(y.join(o,f))),e.target.kind==="release-blocked"){let n=t?.blockingReasons??[],c=(r.summary?.projectCount??r.projects.length)===0,g=[l("verdict",c?"Workspace scaffold posture":"Release verdict",t?c?`Scaffold posture: **${t.summary.verdict}** (exit ${t.summary.exitCode}). Freshness: **${t.freshness.verdict}**. No registered projects yet \u2014 release gates apply after the first project is added.`:`Verdict: **${t.summary.verdict}** (exit ${t.summary.exitCode}). Risk: **${t.impact.risk}**. Freshness: **${t.freshness.verdict}**.`:"No workspace verify report found. Run `npx rapidkit workspace verify --json --write` first."),l("blockers",c?"Pre-project signals":"Blocking reasons",n.length?n.map(k=>`- ${k}`).join(`
|
|
2
2
|
`):c?"No pre-project signals in the latest verify report.":"No blocking reasons in the latest verify report.")];return t?.resolutionHints?.length&&g.push(l("resolution","Resolution hints",t.resolutionHints.map(k=>`- **${k.blockerId}** (${k.resolutionClass}): ${k.commandRetryHint??k.fixHints[0]?.detail??"See fix hints"}`).join(`
|
|
3
3
|
`))),{schemaVersion:a,generatedAt:s,workspacePath:o,target:e.target,summary:t?c?b(n.length,t.summary.verdict):`Release blocked: ${t.summary.verdict} with ${n.length} blocking reason(s).`:"Release posture unknown \u2014 verify report missing.",sections:g,releaseRisk:t?.impact.risk,blockingReasons:n,resolutionHints:t?.resolutionHints}}if(e.target.kind==="blocker"){let n=e.target,m=t?.resolutionHints?.find(g=>g.blockerId===n.blockerId),c=t?.blockingReasons.find(g=>g.includes(n.blockerId))??t?.blockingReasons[0];return {schemaVersion:a,generatedAt:s,workspacePath:o,target:n,summary:m?`Blocker ${n.blockerId}: ${m.resolutionClass}`:`Blocker ${n.blockerId} (no structured hint)`,sections:[l("reason","Blocking signal",c??"No matching blocking reason in verify."),l("hint","Resolution class",m?`${m.resolutionClass}
|
|
4
4
|
|