rapidkit 0.37.0 → 0.37.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +23 -44
- package/dist/autopilot-release-QNZ2IL7K.js +1 -0
- package/dist/chunk-3SWQKRXH.js +2 -0
- package/dist/{chunk-7VSYTOOG.js → chunk-7RBZGQ7T.js} +1 -1
- package/dist/index.js +4 -4
- package/dist/{pipeline-BOU4KETN.js → pipeline-IMB3C3JY.js} +1 -1
- package/dist/{workspace-agent-sync-V2H6NTGD.js → workspace-agent-sync-4R7S3F6T.js} +1 -1
- package/dist/{workspace-context-KCKNV5VQ.js → workspace-context-CKACDTVE.js} +1 -1
- package/dist/workspace-run-PNMZJNDC.js +1 -0
- package/dist/workspace-verify-EO435PS4.js +1 -0
- package/docs/AI_DYNAMIC_INTEGRATION.md +440 -0
- package/docs/AI_EXAMPLES.md +419 -0
- package/docs/AI_FEATURES.md +460 -0
- package/docs/AI_QUICKSTART.md +245 -0
- package/docs/DEVELOPMENT.md +88 -0
- package/docs/From Code to Shared Understanding.png +0 -0
- package/docs/OPEN_SOURCE_USER_SCENARIOS.md +170 -0
- package/docs/OPTIMIZATION_GUIDE.md +504 -0
- package/docs/PACKAGE_MANAGER_POLICY.md +25 -0
- package/docs/README.md +120 -0
- package/docs/SECURITY.md +63 -0
- package/docs/SETUP.md +107 -0
- package/docs/UTILITIES.md +221 -0
- package/docs/WORKSPACE_MARKER_SPEC.md +276 -0
- package/docs/ci-workflows.md +56 -0
- package/docs/commands-reference.md +136 -0
- package/docs/config-file-guide.md +295 -0
- package/docs/contracts/ARTIFACT_CATALOG.md +104 -0
- package/docs/contracts/COMMAND_OWNERSHIP_MATRIX.md +138 -0
- package/docs/contracts/README.md +70 -0
- package/docs/contracts/RUNTIME_ACCEPTANCE_MATRIX.md +98 -0
- package/docs/contracts/RUNTIME_SUPPORT_MATRIX.md +74 -0
- package/docs/contracts/rapidkit-cli-contracts.json +239 -0
- package/docs/doctor-command.md +263 -0
- package/docs/examples/ci-agent-grounding.yml +62 -0
- package/docs/from-code-to-shared-understanding.md +46 -0
- package/docs/governance-policy.enterprise.example.json +40 -0
- package/docs/mirror-config.enterprise.example.json +60 -0
- package/docs/policies.workspace.example.yml +23 -0
- package/docs/workspace-operations.md +160 -0
- package/docs/workspace-run.md +80 -0
- package/package.json +3 -2
- package/dist/autopilot-release-AUXP2ZIF.js +0 -1
- package/dist/chunk-EJGKBFV4.js +0 -2
- package/dist/workspace-run-DEXI52KO.js +0 -1
- package/dist/workspace-verify-HBCQNNGU.js +0 -1
- /package/dist/{chunk-D23L2GFT.js → chunk-TRXYRHD7.js} +0 -0
package/README.md
CHANGED
|
@@ -3,13 +3,15 @@
|
|
|
3
3
|
### Open-Source Workspace Intelligence for Software Systems
|
|
4
4
|
|
|
5
5
|
> AI agents understand files.
|
|
6
|
-
> RapidKit helps developers, CI, and AI agents share the same understanding of the workspace.
|
|
6
|
+
> RapidKit helps developers, CI, IDEs, and AI agents share the same understanding of the workspace.
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
**One workspace. One truth. Humans and AI aligned.**
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
RapidKit is the open-source workspace intelligence engine that turns scattered projects into a governed, agent-ready software system.
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
Build, adopt, and operate polyglot software systems with a shared, evidence-backed understanding for developers, CI pipelines, IDEs, and AI agents.
|
|
13
|
+
|
|
14
|
+
Instead of every tool rebuilding its own view of your system from files alone, RapidKit provides a shared source of truth: a workspace model, agent context, impact analysis, verification evidence, and release gates that all surfaces can consume.
|
|
13
15
|
|
|
14
16
|
## Quick start in 5 minutes
|
|
15
17
|
|
|
@@ -50,10 +52,10 @@ npx rapidkit pipeline --strict
|
|
|
50
52
|
|
|
51
53
|
* Adopt existing projects without migration
|
|
52
54
|
* Create and manage polyglot workspaces
|
|
53
|
-
* Generate agent-ready context
|
|
55
|
+
* Generate canonical workspace models and agent-ready context
|
|
54
56
|
* Analyze impact before changes ship
|
|
55
57
|
* Verify release readiness with evidence-backed gates
|
|
56
|
-
* Keep developers, CI, and AI agents aligned
|
|
58
|
+
* Keep developers, CI, IDEs, and AI agents aligned on the same workspace truth
|
|
57
59
|
|
|
58
60
|
### Workspace Intelligence
|
|
59
61
|
|
|
@@ -76,49 +78,26 @@ RapidKit adds the missing layer:
|
|
|
76
78
|
|
|
77
79
|
**Workspace Intelligence.**
|
|
78
80
|
|
|
79
|
-
**One workspace. One truth.**
|
|
80
|
-
|
|
81
|
-
A shared understanding of software systems for developers, CI pipelines, IDEs, and AI agents.
|
|
82
|
-
|
|
83
|
-
### From Code to Shared Understanding
|
|
84
|
-
How RapidKit transforms projects and repositories into workspace intelligence for developers, CI, and AI agents.
|
|
85
|
-
|
|
86
|
-
```mermaid
|
|
87
|
-
flowchart TB
|
|
81
|
+
**One workspace. One truth. Humans and AI aligned.**
|
|
88
82
|
|
|
89
|
-
|
|
90
|
-
Projects["Projects"]
|
|
91
|
-
Workspace["Workspace"]
|
|
83
|
+
A shared, evidence-backed understanding of software systems for developers, CI pipelines, IDEs, and AI agents.
|
|
92
84
|
|
|
93
|
-
|
|
94
|
-
Projects --> Workspace
|
|
85
|
+
In RapidKit, Workspace Intelligence is not a chat feature. It is the deterministic workspace layer behind the CLI:
|
|
95
86
|
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
end
|
|
87
|
+
* **Model** — what projects, runtimes, frameworks, commands, policies, contracts, and evidence exist
|
|
88
|
+
* **Context** — what AI agents and IDEs should know before giving advice
|
|
89
|
+
* **Impact** — what changed and which projects, commands, and release gates are affected
|
|
90
|
+
* **Verify** — which evidence proves the workspace is ready, blocked, or needs attention
|
|
91
|
+
* **Sync** — how developers, CI, Workspai, and AI agents stay grounded in the same truth
|
|
102
92
|
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
Workspace --> Impact
|
|
106
|
-
Workspace --> Verify
|
|
107
|
-
|
|
108
|
-
Model --> Dev["Developers"]
|
|
109
|
-
Model --> CI["CI"]
|
|
110
|
-
Model --> Agents["AI Agents"]
|
|
111
|
-
|
|
112
|
-
Context --> Agents
|
|
93
|
+
### From Code to Shared Understanding
|
|
94
|
+
How RapidKit transforms projects and repositories into workspace intelligence for developers, CI, and AI agents.
|
|
113
95
|
|
|
114
|
-
|
|
115
|
-
Impact --> CI
|
|
96
|
+

|
|
116
97
|
|
|
117
|
-
|
|
118
|
-
Verify --> Agents
|
|
119
|
-
```
|
|
98
|
+
Mermaid source for GitHub docs: [from-code-to-shared-understanding.md](docs/from-code-to-shared-understanding.md).
|
|
120
99
|
|
|
121
|
-
RapidKit provides the workspace engine,
|
|
100
|
+
RapidKit provides the workspace intelligence engine: model, context, impact, verification, evidence, contracts, and governance.
|
|
122
101
|
|
|
123
102
|
Workspai provides the VS Code experience on top of that foundation.
|
|
124
103
|
|
|
@@ -349,9 +328,9 @@ Full syntax: [docs/commands-reference.md](docs/commands-reference.md). CI workfl
|
|
|
349
328
|
|
|
350
329
|
RapidKit and Workspai form a single workspace intelligence platform.
|
|
351
330
|
|
|
352
|
-
RapidKit provides the workspace engine,
|
|
331
|
+
RapidKit provides the workspace intelligence engine: model, context, impact, verification, evidence, contracts, and governance.
|
|
353
332
|
|
|
354
|
-
Workspai provides the VS Code
|
|
333
|
+
Workspai — Workspace + Intelligence — provides the VS Code surface: dashboard, sidebar, Incident Studio, AI workflows, and developer-facing workspace operations.
|
|
355
334
|
|
|
356
335
|
| Component | Repository | Role |
|
|
357
336
|
| --- | --- | --- |
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{b as AUTOPILOT_RELEASE_ALIAS_FILENAME,a as AUTOPILOT_RELEASE_LAST_RUN_FILENAME,c as runAutopilotRelease}from'./chunk-7RBZGQ7T.js';
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import {d}from'./chunk-C7OVQQXT.js';import d$1 from'path';import l from'fs-extra';var k="workspace-context.v1",f=".rapidkit/reports/workspace-context-agent.json";function w(e){if(typeof e!="string"||!e.trim()||e==="true")return "generic";let t=e.trim().toLowerCase();return t==="codex"||t==="claude"||t==="cursor"||t==="orca"?t:"generic"}function h(e){return `npx --yes --package rapidkit rapidkit ${e}`.trim()}function y(e){return `npx rapidkit ${e}`.trim()}function i(e){return {id:e.id,scope:e.scope,display:y(e.args),execute:h(e.args),description:e.description,...e.project?{project:e.project}:{}}}function g(e,t){return `workspace run ${t} --scope project:${e.name}`}function j(e){return (e.startsWith("project:")?e.slice(8):e).trim().toLowerCase()}function v(e){return [e.name,e.path,d$1.basename(e.path),e.absolutePath].filter(t=>typeof t=="string"&&t.trim().length>0).map(t=>t.trim().toLowerCase())}function x(e,t){let s=[i({id:"workspace.model",scope:"workspace",args:"workspace model --json",description:"Read the canonical workspace intelligence model."}),i({id:"workspace.doctor",scope:"workspace",args:"doctor workspace --json",description:"Check workspace health before claiming verification."}),i({id:"workspace.pipeline",scope:"workspace",args:"pipeline --json",description:"Run the governed sync, doctor, analyze, readiness, and autopilot loop."}),i({id:"workspace.contract.verify",scope:"workspace",args:"workspace contract verify --json",description:"Verify workspace contract and dependency edges."}),i({id:"workspace.verify",scope:"workspace",args:"workspace verify --json",description:"Evaluate evidence freshness and verification gates before release decisions."})],o=t?[t]:e.projects;for(let r of o)r.commands.fleetStages.includes("test")&&s.push(i({id:`project.${r.name}.test`,scope:"project",project:r.name,args:g(r,"test"),description:`Run tests for ${r.name} through workspace orchestration.`})),r.commands.fleetStages.includes("build")&&s.push(i({id:`project.${r.name}.build`,scope:"project",project:r.name,args:g(r,"build"),description:`Build ${r.name} through workspace orchestration.`}));return s}function C(e){return e.commands.fleetStages.filter(t=>t==="test"||t==="build").map(t=>`workspace run ${t}`)}function W(e,t){if(!t?.startsWith("project:"))return;let s=j(t);if(s)return e.projects.find(o=>v(o).includes(s))}function b(e,t,s){let o=[...e.validation?.issues??[]];t?.startsWith("project:")&&!s&&o.push({severity:"error",code:"context.scope.project.missing",message:`Requested project scope was not found: ${t}`,target:t});let r=o.filter(a=>a.severity==="error").length,c=o.filter(a=>a.severity==="warning").length;return {status:r>0?"failed":c>0?"warning":"passed",errors:r,warnings:c,issues:o}}function S(e){let t=[],s=[];for(let[o,r]of Object.entries(e.evidence))r?.exists?t.push(`${o}: ${r.path}`):s.push(o);return {available:t.sort(),missing:s.sort()}}function P(e){let t=e.summary.projectCount,s=e.summary.runtimes.length?e.summary.runtimes.join(", "):"no runtime",o=e.identity.surfaces.length?e.identity.surfaces.join(", "):"no detected surfaces";return `${e.workspace.name} is a ${e.identity.workspaceType} with ${t} project${t===1?"":"s"}, ${s} runtime coverage, and ${o}.`}function A(e){let t=["Do not claim a command passed unless a report or command output proves it.","Do not infer secrets or environment values from file names.","Do not change project scope without checking the selected project."];return e.contracts.exists||t.push("Workspace contract is missing; dependency and API edges may be incomplete."),e.summary.observedProjects>0&&t.push("Some projects are observed rather than first-class; command support may be partial."),t}async function O(e){let t=e.model??await d({workspacePath:e.workspacePath,includeEvidence:e.includeEvidence===true,observableScanDepth:e.observableScanDepth,now:e.now}),s=w(e.agent),o=W(t,e.scope),r=b(t,e.scope,o);if(e.strict===true&&r.status!=="passed"){let n=r.issues.map(p=>`${p.severity}:${p.code}:${p.target}`).join(", ");throw new Error(`Workspace context strict validation failed: ${n}`)}let c=(o?[o]:t.projects).map(n=>({name:n.name,path:n.path,kind:n.kind,runtime:n.runtime,framework:n.frameworkDisplayName,...n.generator?{generator:n.generator}:{},supportTier:n.supportTier,safeCommands:C(n),importantFiles:n.importantFiles})),a=S(t),m=P(t);return {schemaVersion:k,generatedAt:(e.now??new Date).toISOString(),agent:s,workspaceSummary:m,modelRef:".rapidkit/reports/workspace-model.json",workspace:{name:t.workspace.name,root:t.workspace.root,type:t.identity.workspaceType,...t.workspace.profile?{profile:t.workspace.profile}:{}},scope:{requested:e.scope??"workspace",...o?{activeProject:o.name}:{}},projects:c,safeCommands:x(t,o),evidence:a,policies:{mode:t.policies.mode,source:t.policies.source},contracts:{exists:t.contracts.exists,path:t.contracts.workspaceContractPath},validation:r,agentInstructions:["Read `.rapidkit/reports/INDEX.json` first, then this context pack and linked evidence reports.","Use this context as the workspace source of truth before inspecting random files.","Prefer workspace-level evidence over generic framework assumptions.","Use `display` commands when explaining steps to a human.","Use `execute` commands when launching commands from automation or tooling.","Keep project-scoped advice tied to the active project scope.","Regenerate stale grounding with `npx rapidkit workspace agent-sync --write --refresh-context`."],unsafeAssumptions:A(t),humanSummary:[m,`Evidence available: ${a.available.length}. Missing evidence groups: ${a.missing.join(", ")||"none"}.`,o?`Active project scope: ${o.name} (${o.frameworkDisplayName}).`:"Scope: whole workspace."].join(`
|
|
2
|
+
`)}}async function D(e,t){let s=d$1.join(t,f);return await l.ensureDir(d$1.dirname(s)),await l.writeJSON(s,e,{spaces:2}),s}export{k as a,f as b,O as c,D as d};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {a}from'./chunk-
|
|
1
|
+
import {a}from'./chunk-TRXYRHD7.js';import {a as a$1,d}from'./chunk-FV5A3N3I.js';import {a as a$2}from'./chunk-KMUWWZRT.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=[],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.push(`doctor workspace execution error: ${i.stderr||"unknown error"}`);else if(i.exitCode===1)c="fail",e.push("doctor workspace command failed or reported errors");else if(i.exitCode===2)c="warn",e.push("doctor workspace reported warnings");else if(i.exitCode!==0)c="fail",e.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.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.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.push(`analyze execution error: ${w.stderr||"unknown error"}`);else if(w.exitCode!==0)n=w.exitCode===2?"warn":"fail",e.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.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.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.push(`readiness execution error: ${h.stderr||"unknown error"}`);else if(h.exitCode!==0)p="fail",e.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.push(...k.map(E=>`readiness: ${E}`)):e.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.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.push(`doctor remediation plan execution error: ${M.stderr||"unknown error"}`);else if(M.exitCode!==0)S="fail",e.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.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.push(`doctor remediation apply execution error: ${i.stderr||"unknown error"}`);else if(g==="fail")e.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.push(`post-apply doctor execution error: ${w.stderr||"unknown error"}`);else if(w.exitCode!==0)c="fail",e.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.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.push(`post-apply readiness execution error: ${v.stderr||"unknown error"}`);else if(v.exitCode!==0)p="fail",e.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.push(...h.map(R=>`post-apply readiness: ${R}`)):e.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 d(t,r),O=C;let i=se(r);if(i==="fail")x="fail",A="workspace test stage failed for selected projects",e.push("workspace run test failed for selected projects");else {i==="warn"&&(x="warn",A="workspace test stage completed with warnings",o==="enforce"&&e.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 d(t,m),J=C;let g=se(m);g==="fail"?(x="fail",A="workspace build stage failed for selected projects",e.push("workspace run build failed for selected projects")):g==="warn"&&(x="warn",A="workspace test/build completed with warnings",o==="enforce"&&e.push("workspace run test/build reported warnings under enforce mode"));}}catch(r){x="fail",A="workspace test/build orchestration failed",f=true,e.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)],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(`
|
package/dist/index.js
CHANGED
|
@@ -208,7 +208,7 @@ Hints:`));for(let p of a)console.log(s.gray(`- ${p}`));}return i.exitCode}functi
|
|
|
208
208
|
`),0):(console.log(s.cyan("RapidKit mirror status")),console.log(s.gray(`Workspace: ${r}`)),console.log(s.gray(`Config: ${d?"present":"missing"} (${i})`)),console.log(s.gray(`Lock: ${g?"present":"missing"} (${a})`)),console.log(s.gray(`Artifacts: ${w}`)),0)}if(e==="sync"||e==="verify"||e==="rotate"){let p=await br(r,{ciMode:true,offlineMode:e==="verify",forceRun:true}),d=p.checks.filter(w=>w.status==="failed"),u=p.checks.some(w=>w.id.startsWith("mirror.verify.")&&w.status==="failed");if(e==="verify"&&u){let w={command:"mirror",action:e,result:"failed",timestamp:new Date().toISOString(),workspacePath:r,mirror:await m(),details:p.details,checks:p.checks};if(await f(w),o)return process.stdout.write(`${JSON.stringify(w,null,2)}
|
|
209
209
|
`),1;console.log(s.red("\u274C Mirror verify failed."));for(let y of p.checks.filter(P=>P.id.startsWith("mirror.verify.")))console.log(s.gray(`- ${y.id}: ${y.message}`));return 1}if(d.length>0){let w={command:"mirror",action:e,result:"failed",timestamp:new Date().toISOString(),workspacePath:r,mirror:await m(),details:p.details,checks:p.checks};if(await f(w),o)return process.stdout.write(`${JSON.stringify(w,null,2)}
|
|
210
210
|
`),1;console.log(s.yellow(`\u26A0\uFE0F Mirror ${e} completed with ${d.length} issue(s).`));for(let y of d)console.log(s.gray(`- ${y.id}: ${y.message}`));return 1}let g={command:"mirror",action:e,result:"ok",timestamp:new Date().toISOString(),workspacePath:r,mirror:await m(),details:p.details,checks:p.checks};return await f(g),o?(process.stdout.write(`${JSON.stringify(g,null,2)}
|
|
211
|
-
`),0):e==="rotate"?(console.log(s.green(`\u2705 Mirror rotate completed. Rotated files: ${p.details.rotatedFiles}.`)),0):e==="verify"?(console.log(s.green(`\u2705 Mirror verify completed. Verified artifacts: ${p.details.verifiedArtifacts}.`)),0):(console.log(s.green(`\u2705 Mirror sync completed. Synced artifacts: ${p.details.syncedArtifacts}.`)),0)}return console.log(s.yellow("Usage: rapidkit mirror <status|sync|verify|rotate> [--json]")),1}async function Tr(t$1){let e=process.env.RAPIDKIT_SKIP_LOCK_SYNC;typeof e>"u"&&(process.env.RAPIDKIT_SKIP_LOCK_SYNC="1");try{let o=process.cwd(),r=await ji(o,async()=>{let n=oe(o),i=Be("python",{runCommandInCwd:H,runCoreRapidkit:e$1}),a=Be("dotnet",{runCommandInCwd:H,runCoreRapidkit:e$1}),c=t$1.slice(1).filter(g=>!g.startsWith("-"));if(c.length>0){let g=h.resolve(o,c[0]),w=a$5(g),y=await lt(g);return b$4(w,g)||y==="go"?await Ar(g):d(w,g)||y==="java"?await Ve("init",g):e$2(w,g)||y==="dotnet"?Z(await a.initProject(g)):c$1(w,g)||y==="node"?await Er(g):f$1(w,g)||y==="python"?await Rr(g,i):await e$1(t$1,{cwd:o})}let l=a$5(o),f=!!oe(o)&&o===oe(o);if(!f&&b$4(l,o))return await Ar(o);let m=await lt(o);if(!f&&(d(l,o)||m==="java"))return await Ve("init",o);if(!f&&(e$2(l,o)||m==="dotnet"))return Z(await a.initProject(o));if(!f&&(c$1(l,o)||m==="node"))return await Er(o);if(!f&&(f$1(l,o)||m==="python"))return await Rr(o,i);let p=n||oe(o),d$1=wi(o),u=d$1?h.dirname(h.dirname(d$1)):null;if(u&&u!==p){let g=a$5(u),w=await lt(u);return b$4(g,u)||w==="go"?await Ar(u):d(g,u)||w==="java"?await Ve("init",u):e$2(g,u)||w==="dotnet"?Z(await a.initProject(u)):c$1(g,u)||w==="node"?await Er(u):f$1(g,u)||w==="python"?await Rr(u,i):await e$1(["init"],{cwd:u})}if(p&&o===p){console.log(s.yellow("\u26A0\uFE0F Running `npx rapidkit init` at workspace root.")),console.log(s.gray(" Root `init`, `workspace init`, and `workspace run init` now share the same full-init flow:\n workspace-profile dependencies first, then project dependency initialization.\n"));let g=await Dr(p);if(g!==0)return g;let{runWorkspaceStage:w}=await import('./workspace-run-
|
|
211
|
+
`),0):e==="rotate"?(console.log(s.green(`\u2705 Mirror rotate completed. Rotated files: ${p.details.rotatedFiles}.`)),0):e==="verify"?(console.log(s.green(`\u2705 Mirror verify completed. Verified artifacts: ${p.details.verifiedArtifacts}.`)),0):(console.log(s.green(`\u2705 Mirror sync completed. Synced artifacts: ${p.details.syncedArtifacts}.`)),0)}return console.log(s.yellow("Usage: rapidkit mirror <status|sync|verify|rotate> [--json]")),1}async function Tr(t$1){let e=process.env.RAPIDKIT_SKIP_LOCK_SYNC;typeof e>"u"&&(process.env.RAPIDKIT_SKIP_LOCK_SYNC="1");try{let o=process.cwd(),r=await ji(o,async()=>{let n=oe(o),i=Be("python",{runCommandInCwd:H,runCoreRapidkit:e$1}),a=Be("dotnet",{runCommandInCwd:H,runCoreRapidkit:e$1}),c=t$1.slice(1).filter(g=>!g.startsWith("-"));if(c.length>0){let g=h.resolve(o,c[0]),w=a$5(g),y=await lt(g);return b$4(w,g)||y==="go"?await Ar(g):d(w,g)||y==="java"?await Ve("init",g):e$2(w,g)||y==="dotnet"?Z(await a.initProject(g)):c$1(w,g)||y==="node"?await Er(g):f$1(w,g)||y==="python"?await Rr(g,i):await e$1(t$1,{cwd:o})}let l=a$5(o),f=!!oe(o)&&o===oe(o);if(!f&&b$4(l,o))return await Ar(o);let m=await lt(o);if(!f&&(d(l,o)||m==="java"))return await Ve("init",o);if(!f&&(e$2(l,o)||m==="dotnet"))return Z(await a.initProject(o));if(!f&&(c$1(l,o)||m==="node"))return await Er(o);if(!f&&(f$1(l,o)||m==="python"))return await Rr(o,i);let p=n||oe(o),d$1=wi(o),u=d$1?h.dirname(h.dirname(d$1)):null;if(u&&u!==p){let g=a$5(u),w=await lt(u);return b$4(g,u)||w==="go"?await Ar(u):d(g,u)||w==="java"?await Ve("init",u):e$2(g,u)||w==="dotnet"?Z(await a.initProject(u)):c$1(g,u)||w==="node"?await Er(u):f$1(g,u)||w==="python"?await Rr(u,i):await e$1(["init"],{cwd:u})}if(p&&o===p){console.log(s.yellow("\u26A0\uFE0F Running `npx rapidkit init` at workspace root.")),console.log(s.gray(" Root `init`, `workspace init`, and `workspace run init` now share the same full-init flow:\n workspace-profile dependencies first, then project dependency initialization.\n"));let g=await Dr(p);if(g!==0)return g;let{runWorkspaceStage:w}=await import('./workspace-run-PNMZJNDC.js');return (await w({workspacePath:p,stage:"init",affected:false,blastRadius:false,parallel:false,continueOnError:false,strict:false,json:false,enforceGates:false})).summary.exitCode}if(!p){let g=await t(),w=y(),{name:y$1}=Xc(w);await C__default.ensureDir(w);let{createProject:P}=await import('./create-HN5HOGQ4.js');return await P(y$1,{yes:true,userConfig:g,parentDirectory:w}),0}return await e$1(t$1,{cwd:o})});return r.ok?r.value:r.code}finally{typeof e>"u"?delete process.env.RAPIDKIT_SKIP_LOCK_SYNC:process.env.RAPIDKIT_SKIP_LOCK_SYNC=e;}}async function ci(t){let e=oe(t);if(!e)return [];let o="warn";try{let l=await j.promises.readFile(h.join(e,".rapidkit","policies.yml"),"utf-8");(l.match(/^\s*enforcement_mode:\s*(warn|strict)\s*(?:#.*)?$/m)??l.match(/^\s*mode:\s*(warn|strict)\s*(?:#.*)?$/m))?.[1]==="strict"&&(o="strict");}catch{return []}if(o!=="strict")return [];let r=[],n=h.join(e,".rapidkit","toolchain.lock");if(!j.existsSync(n))return r.push("toolchain.lock is missing \u2014 run `rapidkit bootstrap` first (strict mode requires a reproducible toolchain)."),r;let i={};try{i=JSON.parse(await j.promises.readFile(n,"utf-8"));}catch{return r.push("toolchain.lock is invalid JSON \u2014 regenerate it with `rapidkit bootstrap` before running commands in strict mode."),r}let a=i.runtime??{},c=a$5(t);b$4(c,t)&&!a.go?.version?r.push("go.version is not pinned in toolchain.lock \u2014 run `rapidkit setup go` first."):c$1(c,t)&&!a.node?.version?r.push("node.version is not pinned in toolchain.lock \u2014 run `rapidkit setup node` first."):d(c,t)&&!a.java?.version?r.push("java.version is not pinned in toolchain.lock \u2014 run `rapidkit setup java` first."):e$2(c,t)&&!a.dotnet?.version?r.push("dotnet.version is not pinned in toolchain.lock \u2014 run `rapidkit setup dotnet` first."):f$1(c,t)&&!a.python?.version&&r.push("python.version is not pinned in toolchain.lock \u2014 run `rapidkit setup python` first.");try{let f=JSON.parse(await j.promises.readFile(h.join(e,".rapidkit","workspace.json"),"utf-8")).profile??"";f==="python-only"&&(b$4(c,t)||c$1(c,t)||d(c,t)||e$2(c,t))?r.push('Workspace profile is "python-only" but this project is not Python.'):f==="node-only"&&(b$4(c,t)||f$1(c,t)||d(c,t)||e$2(c,t))?r.push('Workspace profile is "node-only" but this project is not Node.'):f==="go-only"&&(c$1(c,t)||f$1(c,t)||d(c,t)||e$2(c,t))?r.push('Workspace profile is "go-only" but this project is not Go.'):f==="java-only"&&(f$1(c,t)||c$1(c,t)||b$4(c,t)||e$2(c,t))?r.push('Workspace profile is "java-only" but this project is not Java.'):f==="dotnet-only"&&(f$1(c,t)||c$1(c,t)||b$4(c,t)||d(c,t))&&r.push('Workspace profile is "dotnet-only" but this project is not .NET.');}catch{}return r}async function ol(){let t=async k=>{if(!a()||!k.toLowerCase().endsWith(".cmd"))return false;try{let S=(await C__default.readFile(k,"utf8")).replace(/\r\n/g,`
|
|
212
212
|
`).toLowerCase(),A=S.includes("\\.rapidkit\\rapidkit"),z=S.includes("\\.rapidkit\\rapidkit.cmd")||S.includes("\\.rapidkit\\rapidkit.exe")||S.includes("\\.venv\\scripts\\rapidkit.exe");return A&&!z}catch{return false}},e$3=process.cwd(),o=process.argv.slice(2),r=o[0],n=r==="init",i$1=new Set(h$3),a$1=!r||r==="--help"||r==="-h"||r==="help",c=We(e$3),l=j.existsSync(h.join(e$3,".rapidkit","project.json")),f=a$5(e$3),m$1=await lt(e$3),p=b$4(f,e$3)||c$1(f,e$3)||f$1(f,e$3)||d(f,e$3)||e$2(f,e$3)||m(m$1??void 0),d$1=!!r&&i$1.has(r)&&p,u=process.env.RAPIDKIT_LOCAL_LAUNCHER_BYPASS==="1";if(Ft(o)||o[0]==="create")return false;if(Mr(o))return true;if(o[0]==="init"&&c&&!l)return false;if(Nr(o))return true;try{let k=r==="shell"&&o[1]==="activate",_=r==="create",S=await xn(e$3,{cwd:e$3,timeoutMs:1200});if(S.ok&&S.data?.isRapidkitProject&&S.data.engine==="python"){let A=_||Ft(o);if(!a$1&&!k&&!A&&!n&&!d$1&&Bo(o)){if(r&&Qs.includes(r)){let Y=await ci(e$3).catch(()=>[]);if(Y.length>0){process.stderr.write(s.red("\u274C Strict policy violations prevent running this command:")+`
|
|
213
213
|
`);for(let re of Y)process.stderr.write(s.red(` \u2022 ${re}`)+`
|
|
214
214
|
`);process.exit(1);}}let z=await e$1(process.argv.slice(2),{cwd:e$3});process.exit(z);}}}catch{}let g=wi(e$3),w=a(),y=u?[]:i(e$3),P=null;for(let k of y)if(await C__default.pathExists(k)){if(await t(k)){e.warn(`Skipping legacy/broken Windows launcher candidate: ${k}. Falling back to core bridge.`);continue}P=k;break}let v=r==="create";if(r==="init"&&c&&!l)return false;if(r&&Qs.includes(r)){let k=await ci(e$3);if(k.length>0){process.stderr.write(s.red("\u274C Strict policy violations prevent running this command:")+`
|
|
@@ -291,11 +291,11 @@ Use "rapidkit help <command>" for more information.
|
|
|
291
291
|
`),e.debug(`Synced Python version ${S.trim()} from workspace to project`);}}catch(S){e.debug("Could not sync Python version from workspace:",S);}}if(!e$2.skipInstall){let v=await e$1(["init",c],{cwd:process.cwd()});if(v!==0&&process.exit(v),P){let k=h.dirname(P),_=h.join(k,".python-version"),S=h.join(c,".python-version");try{if(await C__default.pathExists(_)){let A=j.readFileSync(_,"utf-8");j.writeFileSync(S,A.trim()+`
|
|
292
292
|
`),e.debug(`Re-synced Python version ${A.trim()} after init`);}}catch(A){e.debug("Could not re-sync Python version after init:",A);}}}}else {let{createProject:l}=await import('./create-HN5HOGQ4.js');await l(t$1,{skipGit:e$2.skipGit,dryRun:e$2.dryRun,yes:e$2.yes,userConfig:n,installMethod:e$2.installMethod,profile:e$2.profile,parentDirectory:h.dirname(c)}),console.log(s.gray(`\u2139\uFE0F Workspace root: ${c}`)),console.log(s.gray(` Next: ${C$1(c)} && npx rapidkit create project`));}}catch(o){o instanceof a$3?(e.error(`
|
|
293
293
|
\u274C ${o.message}`),o.details&&e.warn(`\u{1F4A1} ${o.details}`),e.debug("Error code:",o.code)):(e.error(`
|
|
294
|
-
\u274C An unexpected error occurred:`),console.error(o)),process.exit(1);}finally{ot=null;}});zn(ne);es(ne);Es(ne);ne.command("commands").description("Show effective RapidKit command ownership and runtime support").option("--json","Emit machine-readable JSON output").action(async t=>{Gc({json:t.json});});ne.command("analyze").description("Analyze workspace/project health and generate enterprise-ready evidence").option("--workspace <path>","Workspace/root path to analyze").option("--json","Output as JSON").option("--output <file>","Write JSON report to a file").option("--strict","Treat warnings as blocking in the verdict").action(async t=>{try{let{runAnalyze:e,printAnalyzeReport:o}=await import('./analyze-6RFG7C7Z.js'),r=await e({workspacePath:t.workspace,json:t.json===true,output:t.output,strict:t.strict===true});t.json?console.log(JSON.stringify(r,null,2)):o(r),r.summary.verdict==="blocked"&&process.exit(2);}catch(e){let o=e instanceof Error?e.message:String(e);t.json?console.log(JSON.stringify({schemaVersion:"rapidkit-analyze-error-v1",ok:false,error:{message:o}},null,2)):console.error(s.red(`Analyze failed: ${o}`)),process.exit(1);}});In(ne);ne.command("shell <action>").description("Shell helpers (activate virtualenv in current shell)").action(async t=>{t!=="activate"&&(console.log(s.red(`Unknown shell command: ${t}`)),process.exit(1));let e=process.cwd();function o(l){let f=l;for(;;){let m=h.join(f,".rapidkit","context.json");if(j.existsSync(m))return m;let p=h.dirname(f);if(p===f)break;f=p;}return null}let r=o(e);function n(l){let f=l;for(;;){let m=h.join(f,".venv"),p=h.join(f,".rapidkit","activate");if(j.existsSync(p)||j.existsSync(m))return {venv:m,activateFile:p};let d=h.dirname(f);if(d===f)break;f=d;}return null}let i=n(e);!r&&!i&&(console.log(s.yellow("No RapidKit project found in this directory")),process.exit(1));let a$1;i&&j.existsSync(i.activateFile)?a$1=i.activateFile:i&&j.existsSync(i.venv)?a$1=h$2(i.venv):(console.log(s.yellow("No virtual environment found")),process.exit(1));let c=a();console.log(c?`call "${a$1}"`:`. "${a$1}"`);});ne.command("readiness").description("\u{1F6A6} Generate machine-readable release readiness summary (env + doctor + analyze + verify + dependency)").option("--json","Output readiness result in JSON format").option("--strict","Exit with code 1 unless overall readiness is pass").option("--skip-verify","Skip verify gate (use for workspaces without extension verify artifacts)").action(async t=>{await b$2({json:t.json,strict:t.strict,skipVerify:t.skipVerify});});ne.command("pipeline").description("\u{1F517} Run governance pipeline: sync \u2192 doctor \u2192 analyze \u2192 readiness \u2192 autopilot (writes pipeline-last-run.json)").option("--json","Output pipeline report as JSON").option("--strict","Treat warnings as blocking and propagate non-zero exit codes").option("--skip-verify","Skip readiness verify gate").option("--skip-analyze","Skip analyze stage").option("--skip-autopilot","Skip autopilot release stage").option("--autopilot-mode <mode>","Autopilot mode when stage is enabled: audit | safe-fix | enforce","audit").option("--no-agent-sync","Skip cross-tool agent grounding sync after pipeline evidence write").option("--agent-sync","Force agent grounding sync after pipeline (default when report is written)").action(async t=>{let e=String(t.autopilotMode||"audit").trim().toLowerCase();["audit","safe-fix","enforce"].includes(e)||(console.log(s.red(`Invalid autopilot mode: ${t.autopilotMode}`)),process.exit(1));let{runPipelineCommand:o}=await import('./pipeline-BOU4KETN.js');await o({json:t.json===true,strict:t.strict===true,skipVerify:t.skipVerify===true,skipAnalyze:t.skipAnalyze===true,skipAutopilot:t.skipAutopilot===true,autopilotMode:e,noAgentSync:t.noAgentSync===true,agentSync:t.agentSync===true?true:t.noAgentSync?false:void 0});});ne.command("autopilot <action>").description("Run end-to-end release autopilot workflows").option("--mode <mode>","Autopilot mode: audit | safe-fix | enforce","audit").option("--json","Emit machine-readable JSON output").option("--output <file>","Write autopilot report to an additional output path").option("--since <ref>","Git ref for affected project selection (default: HEAD~1)").option("--parallel","Run workspace stage execution in parallel").option("--max-workers <count>","Maximum parallel workers").action(async(t,e)=>{t!=="release"&&(console.log(s.red(`Unknown autopilot action: ${t}`)),console.log(s.gray("Available: release")),process.exit(1));let o=String(e.mode||"audit").trim().toLowerCase();["audit","safe-fix","enforce"].includes(o)||(console.log(s.red(`Invalid autopilot mode: ${e.mode}`)),console.log(s.gray("Allowed modes: audit | safe-fix | enforce")),process.exit(1));let r=Number(e.maxWorkers??""),n=Number.isFinite(r)?Math.max(1,Math.trunc(r)):void 0,{runAutopilotRelease:i}=await import('./autopilot-release-AUXP2ZIF.js'),a;try{a=await i({workspacePath:process.cwd(),mode:o,since:e.since,parallel:e.parallel===true,maxWorkers:n,json:e.json===true,output:e.output});}catch(c){let l=c instanceof Error?c.message:String(c);console.log(s.red(`Autopilot release failed: ${l}`)),process.exit(3);}e.json&&console.log(JSON.stringify(a,null,2)),a.summary.exitCode!==0&&process.exit(a.summary.exitCode);});ne.command("import <source>").description("Import a local backend project folder or clone a git repository into the current workspace").option("--workspace <path>","Workspace root path (defaults to nearest RapidKit workspace)").option("--name <projectName>","Override imported project folder name").option("--enable-modules","Enable Core module/template commands for supported runtimes").option("--git","Force source to be treated as a git repository URL").option("--json","Emit machine-readable JSON output").action(async(t,e)=>{let o=await Qc(t,e);o!==0&&process.exit(o);});ne.command("adopt [source]").description("Adopt an existing local project into a RapidKit workspace without moving or copying source").option("--workspace <path>","Workspace root path (defaults to nearest or managed default)").option("--name <projectName>","Override adopted project name").option("--enable-modules","Enable Core module/template commands for supported runtimes").option("--dry-run","Preview adoption without writing project or registry metadata").option("--json","Emit machine-readable JSON output").action(async(t,e)=>{let o=await Zc(t,e);o!==0&&process.exit(o);});var _o=ne.command("snapshot").description("Create, list, and restore RapidKit workspace snapshots");_o.command("create [name]").description("Create a recoverable workspace snapshot").option("--workspace <path>","Workspace root path (defaults to nearest RapidKit workspace)").option("--reason <text>","Reason recorded in the snapshot manifest").option("--include-projects","Include project source files in the snapshot").option("--json","Emit machine-readable JSON output").action(async(t,e)=>{try{let o=await vt({workspacePath:e.workspace,name:t,reason:e.reason,includeProjects:e.includeProjects===true});if(e.json){console.log(JSON.stringify(o,null,2));return}console.log(s.green(`\u2714 Workspace snapshot created: ${o.manifest.name}`)),console.log(s.gray(` Mode: ${o.manifest.mode}`)),console.log(s.gray(` Path: ${o.snapshotPath}`));}catch(o){console.log(s.red(`\u274C Snapshot create failed: ${o.message}`)),process.exit(1);}});_o.command("list").description("List workspace snapshots").option("--workspace <path>","Workspace root path (defaults to nearest RapidKit workspace)").option("--json","Emit machine-readable JSON output").action(async t=>{try{let e=await ss({workspacePath:t.workspace});if(t.json){console.log(JSON.stringify({snapshots:e},null,2));return}if(e.length===0){console.log(s.yellow("No workspace snapshots found."));return}for(let o of e)console.log(s.cyan(o.name)),console.log(s.gray(` ${o.createdAt} | ${o.mode} | ${o.projects.length} project(s)`)),console.log(s.gray(` ${o.snapshotPath}`));}catch(e){console.log(s.red(`\u274C Snapshot list failed: ${e.message}`)),process.exit(1);}});_o.command("inspect <name>").description("Inspect snapshot manifest and estimated payload size").option("--workspace <path>","Workspace root path (defaults to nearest RapidKit workspace)").option("--json","Emit machine-readable JSON output").action(async(t,e)=>{try{let o=await ns({workspacePath:e.workspace,name:t});if(e.json){console.log(JSON.stringify(o,null,2));return}console.log(s.cyan(`Snapshot: ${o.manifest.name}`)),console.log(s.gray(` Mode: ${o.manifest.mode}`)),console.log(s.gray(` Created: ${o.manifest.createdAt}`)),console.log(s.gray(` Projects: ${o.manifest.projects.length}`)),console.log(s.gray(` Files: ${o.estimatedFileCount}`)),console.log(s.gray(` Bytes: ${o.estimatedBytes}`)),console.log(s.gray(` Path: ${o.snapshotPath}`));}catch(o){console.log(s.red(`\u274C Snapshot inspect failed: ${o.message}`)),process.exit(1);}});_o.command("restore <name>").description("Restore a workspace snapshot").option("--workspace <path>","Workspace root path (defaults to nearest RapidKit workspace)").option("--reason <text>","Reason recorded in the audit log").option("--dry-run","Show what would be restored without changing files").option("--force","Required to apply a restore").option("--no-safety-snapshot","Do not create a pre-restore metadata snapshot").option("--json","Emit machine-readable JSON output").action(async(t,e)=>{try{let o=await is({workspacePath:e.workspace,name:t,reason:e.reason,dryRun:e.dryRun===true||process.argv.includes("--dry-run"),force:e.force===true,safetySnapshot:e.safetySnapshot});if(e.json){console.log(JSON.stringify(o,null,2));return}o.dryRun?console.log(s.cyan(`Snapshot restore dry-run: ${t}`)):console.log(s.green(`\u2714 Workspace snapshot restored: ${t}`)),console.log(s.gray(` Snapshot: ${o.snapshotPath}`)),console.log(s.gray(` Restored paths: ${o.restoredPaths.join(", ")}`)),o.safetySnapshotPath&&console.log(s.gray(` Safety snapshot: ${o.safetySnapshotPath}`));}catch(o){console.log(s.red(`\u274C Snapshot restore failed: ${o.message}`)),process.exit(1);}});var Jt=ne.command("project").description("Safe workspace project lifecycle operations");Jt.command("commands").description("Show effective commands supported by the current RapidKit project").option("--json","Emit machine-readable JSON output").action(async t=>{yi({json:t.json});});Jt.command("archives").description("List archived workspace projects").option("--workspace <path>","Workspace root path (defaults to nearest RapidKit workspace)").option("--json","Emit machine-readable JSON output").action(async t=>{try{let e=await ar({workspacePath:t.workspace});if(t.json){console.log(JSON.stringify({archives:e},null,2));return}if(e.length===0){console.log(s.yellow("No archived projects found."));return}for(let o of e)console.log(s.cyan(o.projectName)),console.log(s.gray(` Archived: ${o.archivedAt}`)),console.log(s.gray(` Path: ${o.archivePath}`)),o.reason&&console.log(s.gray(` Reason: ${o.reason}`));}catch(e){console.log(s.red(`\u274C Project archive list failed: ${e.message}`)),process.exit(1);}});Jt.command("archive <project>").description("Move a project into .rapidkit/archive with a safety snapshot").option("--workspace <path>","Workspace root path (defaults to nearest RapidKit workspace)").option("--reason <text>","Reason recorded in the archive manifest").option("--dry-run","Show what would be archived without changing files").option("--json","Emit machine-readable JSON output").action(async(t,e)=>{try{let o=await cr({workspacePath:e.workspace,project:t,reason:e.reason,dryRun:e.dryRun===true||process.argv.includes("--dry-run")});if(e.json){console.log(JSON.stringify(o,null,2));return}console.log(o.dryRun?s.cyan(`Project archive dry-run: ${o.projectName}`):s.green(`\u2714 Project archived: ${o.projectName}`)),console.log(s.gray(` From: ${o.projectPath}`)),o.archivePath&&console.log(s.gray(` To: ${o.archivePath}`)),o.safetySnapshotPath&&console.log(s.gray(` Safety snapshot: ${o.safetySnapshotPath}`));}catch(o){console.log(s.red(`\u274C Project archive failed: ${o.message}`)),process.exit(1);}});Jt.command("restore <archive>").description("Restore an archived project back into the workspace").option("--workspace <path>","Workspace root path (defaults to nearest RapidKit workspace)").option("--name <projectName>","Restore using a new project folder name").option("--reason <text>","Reason recorded in the audit log").option("--force","Overwrite an existing restore target").option("--dry-run","Show what would be restored without changing files").option("--json","Emit machine-readable JSON output").action(async(t,e)=>{try{let o=await ps({workspacePath:e.workspace,archive:t,targetName:e.name,reason:e.reason,force:e.force===true,dryRun:e.dryRun===true});if(e.json){console.log(JSON.stringify(o,null,2));return}console.log(o.dryRun?s.cyan(`Project restore dry-run: ${o.projectName}`):s.green(`\u2714 Project restored: ${o.projectName}`)),console.log(s.gray(` From: ${o.archivePath}`)),console.log(s.gray(` To: ${o.projectPath}`)),o.safetySnapshotPath&&console.log(s.gray(` Safety snapshot: ${o.safetySnapshotPath}`));}catch(o){console.log(s.red(`\u274C Project restore failed: ${o.message}`)),process.exit(1);}});Jt.command("delete <project>").description("Archive by default; permanently delete only with --permanent and exact --confirm").option("--workspace <path>","Workspace root path (defaults to nearest RapidKit workspace)").option("--reason <text>","Reason recorded in the safety snapshot/archive manifest").option("--permanent","Permanently delete the project directory").option("--confirm <projectName>","Required exact project name for --permanent").option("--dry-run","Show what would be deleted without changing files").option("--json","Emit machine-readable JSON output").action(async(t,e)=>{try{let o=await ds({workspacePath:e.workspace,project:t,reason:e.reason,permanent:e.permanent===true,confirm:e.confirm,dryRun:e.dryRun===true||process.argv.includes("--dry-run")});if(e.json){console.log(JSON.stringify(o,null,2));return}let r=o.action==="archive"?"archived":"deleted";console.log(o.dryRun?s.cyan(`Project ${r} dry-run: ${o.projectName}`):s.green(`\u2714 Project ${r}: ${o.projectName}`)),console.log(s.gray(` Path: ${o.projectPath}`)),o.archivePath&&console.log(s.gray(` Archive: ${o.archivePath}`)),o.safetySnapshotPath&&console.log(s.gray(` Safety snapshot: ${o.safetySnapshotPath}`));}catch(o){console.log(s.red(`\u274C Project delete failed: ${o.message}`)),process.exit(1);}});ne.command("doctor [scope]").description("\u{1FA7A} Check RapidKit system health by default; use workspace or project for scoped checks").option("--workspace","Check entire workspace (including all projects)").option("--project","Check only the current project (or nearest parent project)").option("--json","Output results in JSON format (for CI/CD pipelines)").option("--strict","Exit 1 on health errors or warnings (workspace/project scope)").option("--ci","CI gate: exit 1 on errors, exit 2 on warnings only").option("--fix","Automatically fix common issues (with confirmation)").option("--plan","Generate remediation plan without applying changes").option("--apply","Apply remediation plan non-interactively").action(async(t,e)=>{t&&t!=="workspace"&&t!=="project"&&(console.log(s.red(`Unknown doctor scope: ${t}`)),console.log(s.gray("Available: workspace, project")),console.log(s.gray("Usage: npx rapidkit doctor | npx rapidkit doctor workspace | npx rapidkit doctor project")),process.exit(1)),e.plan&&(e.fix||e.apply)&&(console.log(s.red("Invalid doctor flags: --plan cannot be combined with --fix or --apply")),process.exit(1));let o=await Bc({scope:t,workspaceFlag:e.workspace});o.detected&&!e.json&&(console.log(s.yellow("\u26A0\uFE0F Local launcher shadow detected for doctor workspace checks.")),o.candidatePath&&console.log(s.gray(` Candidate: ${o.candidatePath}`)),console.log(s.gray(" Running npm-wrapper doctor workflow directly as safe fallback to avoid ambiguous rapidkit binary resolution.")),console.log(s.gray(" If this happens in a shell call, run: npx --yes --package rapidkit rapidkit doctor workspace")));let{runDoctor:r}=await import('./doctor-QC662YLH.js'),n=await r({...e,workspace:e.workspace||t==="workspace",project:e.project||t==="project",strict:e.strict===true,ci:e.ci===true});n!==0&&process.exit(n);});ne.command("workspace <action> [subaction] [key] [value]").description(`Manage RapidKit workspaces (list, sync, policy, share, export, hydrate, run)
|
|
294
|
+
\u274C An unexpected error occurred:`),console.error(o)),process.exit(1);}finally{ot=null;}});zn(ne);es(ne);Es(ne);ne.command("commands").description("Show effective RapidKit command ownership and runtime support").option("--json","Emit machine-readable JSON output").action(async t=>{Gc({json:t.json});});ne.command("analyze").description("Analyze workspace/project health and generate enterprise-ready evidence").option("--workspace <path>","Workspace/root path to analyze").option("--json","Output as JSON").option("--output <file>","Write JSON report to a file").option("--strict","Treat warnings as blocking in the verdict").action(async t=>{try{let{runAnalyze:e,printAnalyzeReport:o}=await import('./analyze-6RFG7C7Z.js'),r=await e({workspacePath:t.workspace,json:t.json===true,output:t.output,strict:t.strict===true});t.json?console.log(JSON.stringify(r,null,2)):o(r),r.summary.verdict==="blocked"&&process.exit(2);}catch(e){let o=e instanceof Error?e.message:String(e);t.json?console.log(JSON.stringify({schemaVersion:"rapidkit-analyze-error-v1",ok:false,error:{message:o}},null,2)):console.error(s.red(`Analyze failed: ${o}`)),process.exit(1);}});In(ne);ne.command("shell <action>").description("Shell helpers (activate virtualenv in current shell)").action(async t=>{t!=="activate"&&(console.log(s.red(`Unknown shell command: ${t}`)),process.exit(1));let e=process.cwd();function o(l){let f=l;for(;;){let m=h.join(f,".rapidkit","context.json");if(j.existsSync(m))return m;let p=h.dirname(f);if(p===f)break;f=p;}return null}let r=o(e);function n(l){let f=l;for(;;){let m=h.join(f,".venv"),p=h.join(f,".rapidkit","activate");if(j.existsSync(p)||j.existsSync(m))return {venv:m,activateFile:p};let d=h.dirname(f);if(d===f)break;f=d;}return null}let i=n(e);!r&&!i&&(console.log(s.yellow("No RapidKit project found in this directory")),process.exit(1));let a$1;i&&j.existsSync(i.activateFile)?a$1=i.activateFile:i&&j.existsSync(i.venv)?a$1=h$2(i.venv):(console.log(s.yellow("No virtual environment found")),process.exit(1));let c=a();console.log(c?`call "${a$1}"`:`. "${a$1}"`);});ne.command("readiness").description("\u{1F6A6} Generate machine-readable release readiness summary (env + doctor + analyze + verify + dependency)").option("--json","Output readiness result in JSON format").option("--strict","Exit with code 1 unless overall readiness is pass").option("--skip-verify","Skip verify gate (use for workspaces without extension verify artifacts)").action(async t=>{await b$2({json:t.json,strict:t.strict,skipVerify:t.skipVerify});});ne.command("pipeline").description("\u{1F517} Run governance pipeline: sync \u2192 doctor \u2192 analyze \u2192 readiness \u2192 autopilot (writes pipeline-last-run.json)").option("--json","Output pipeline report as JSON").option("--strict","Treat warnings as blocking and propagate non-zero exit codes").option("--skip-verify","Skip readiness verify gate").option("--skip-analyze","Skip analyze stage").option("--skip-autopilot","Skip autopilot release stage").option("--autopilot-mode <mode>","Autopilot mode when stage is enabled: audit | safe-fix | enforce","audit").option("--no-agent-sync","Skip cross-tool agent grounding sync after pipeline evidence write").option("--agent-sync","Force agent grounding sync after pipeline (default when report is written)").action(async t=>{let e=String(t.autopilotMode||"audit").trim().toLowerCase();["audit","safe-fix","enforce"].includes(e)||(console.log(s.red(`Invalid autopilot mode: ${t.autopilotMode}`)),process.exit(1));let{runPipelineCommand:o}=await import('./pipeline-IMB3C3JY.js');await o({json:t.json===true,strict:t.strict===true,skipVerify:t.skipVerify===true,skipAnalyze:t.skipAnalyze===true,skipAutopilot:t.skipAutopilot===true,autopilotMode:e,noAgentSync:t.noAgentSync===true,agentSync:t.agentSync===true?true:t.noAgentSync?false:void 0});});ne.command("autopilot <action>").description("Run end-to-end release autopilot workflows").option("--mode <mode>","Autopilot mode: audit | safe-fix | enforce","audit").option("--json","Emit machine-readable JSON output").option("--output <file>","Write autopilot report to an additional output path").option("--since <ref>","Git ref for affected project selection (default: HEAD~1)").option("--parallel","Run workspace stage execution in parallel").option("--max-workers <count>","Maximum parallel workers").action(async(t,e)=>{t!=="release"&&(console.log(s.red(`Unknown autopilot action: ${t}`)),console.log(s.gray("Available: release")),process.exit(1));let o=String(e.mode||"audit").trim().toLowerCase();["audit","safe-fix","enforce"].includes(o)||(console.log(s.red(`Invalid autopilot mode: ${e.mode}`)),console.log(s.gray("Allowed modes: audit | safe-fix | enforce")),process.exit(1));let r=Number(e.maxWorkers??""),n=Number.isFinite(r)?Math.max(1,Math.trunc(r)):void 0,{runAutopilotRelease:i}=await import('./autopilot-release-QNZ2IL7K.js'),a;try{a=await i({workspacePath:process.cwd(),mode:o,since:e.since,parallel:e.parallel===true,maxWorkers:n,json:e.json===true,output:e.output});}catch(c){let l=c instanceof Error?c.message:String(c);console.log(s.red(`Autopilot release failed: ${l}`)),process.exit(3);}e.json&&console.log(JSON.stringify(a,null,2)),a.summary.exitCode!==0&&process.exit(a.summary.exitCode);});ne.command("import <source>").description("Import a local backend project folder or clone a git repository into the current workspace").option("--workspace <path>","Workspace root path (defaults to nearest RapidKit workspace)").option("--name <projectName>","Override imported project folder name").option("--enable-modules","Enable Core module/template commands for supported runtimes").option("--git","Force source to be treated as a git repository URL").option("--json","Emit machine-readable JSON output").action(async(t,e)=>{let o=await Qc(t,e);o!==0&&process.exit(o);});ne.command("adopt [source]").description("Adopt an existing local project into a RapidKit workspace without moving or copying source").option("--workspace <path>","Workspace root path (defaults to nearest or managed default)").option("--name <projectName>","Override adopted project name").option("--enable-modules","Enable Core module/template commands for supported runtimes").option("--dry-run","Preview adoption without writing project or registry metadata").option("--json","Emit machine-readable JSON output").action(async(t,e)=>{let o=await Zc(t,e);o!==0&&process.exit(o);});var _o=ne.command("snapshot").description("Create, list, and restore RapidKit workspace snapshots");_o.command("create [name]").description("Create a recoverable workspace snapshot").option("--workspace <path>","Workspace root path (defaults to nearest RapidKit workspace)").option("--reason <text>","Reason recorded in the snapshot manifest").option("--include-projects","Include project source files in the snapshot").option("--json","Emit machine-readable JSON output").action(async(t,e)=>{try{let o=await vt({workspacePath:e.workspace,name:t,reason:e.reason,includeProjects:e.includeProjects===true});if(e.json){console.log(JSON.stringify(o,null,2));return}console.log(s.green(`\u2714 Workspace snapshot created: ${o.manifest.name}`)),console.log(s.gray(` Mode: ${o.manifest.mode}`)),console.log(s.gray(` Path: ${o.snapshotPath}`));}catch(o){console.log(s.red(`\u274C Snapshot create failed: ${o.message}`)),process.exit(1);}});_o.command("list").description("List workspace snapshots").option("--workspace <path>","Workspace root path (defaults to nearest RapidKit workspace)").option("--json","Emit machine-readable JSON output").action(async t=>{try{let e=await ss({workspacePath:t.workspace});if(t.json){console.log(JSON.stringify({snapshots:e},null,2));return}if(e.length===0){console.log(s.yellow("No workspace snapshots found."));return}for(let o of e)console.log(s.cyan(o.name)),console.log(s.gray(` ${o.createdAt} | ${o.mode} | ${o.projects.length} project(s)`)),console.log(s.gray(` ${o.snapshotPath}`));}catch(e){console.log(s.red(`\u274C Snapshot list failed: ${e.message}`)),process.exit(1);}});_o.command("inspect <name>").description("Inspect snapshot manifest and estimated payload size").option("--workspace <path>","Workspace root path (defaults to nearest RapidKit workspace)").option("--json","Emit machine-readable JSON output").action(async(t,e)=>{try{let o=await ns({workspacePath:e.workspace,name:t});if(e.json){console.log(JSON.stringify(o,null,2));return}console.log(s.cyan(`Snapshot: ${o.manifest.name}`)),console.log(s.gray(` Mode: ${o.manifest.mode}`)),console.log(s.gray(` Created: ${o.manifest.createdAt}`)),console.log(s.gray(` Projects: ${o.manifest.projects.length}`)),console.log(s.gray(` Files: ${o.estimatedFileCount}`)),console.log(s.gray(` Bytes: ${o.estimatedBytes}`)),console.log(s.gray(` Path: ${o.snapshotPath}`));}catch(o){console.log(s.red(`\u274C Snapshot inspect failed: ${o.message}`)),process.exit(1);}});_o.command("restore <name>").description("Restore a workspace snapshot").option("--workspace <path>","Workspace root path (defaults to nearest RapidKit workspace)").option("--reason <text>","Reason recorded in the audit log").option("--dry-run","Show what would be restored without changing files").option("--force","Required to apply a restore").option("--no-safety-snapshot","Do not create a pre-restore metadata snapshot").option("--json","Emit machine-readable JSON output").action(async(t,e)=>{try{let o=await is({workspacePath:e.workspace,name:t,reason:e.reason,dryRun:e.dryRun===true||process.argv.includes("--dry-run"),force:e.force===true,safetySnapshot:e.safetySnapshot});if(e.json){console.log(JSON.stringify(o,null,2));return}o.dryRun?console.log(s.cyan(`Snapshot restore dry-run: ${t}`)):console.log(s.green(`\u2714 Workspace snapshot restored: ${t}`)),console.log(s.gray(` Snapshot: ${o.snapshotPath}`)),console.log(s.gray(` Restored paths: ${o.restoredPaths.join(", ")}`)),o.safetySnapshotPath&&console.log(s.gray(` Safety snapshot: ${o.safetySnapshotPath}`));}catch(o){console.log(s.red(`\u274C Snapshot restore failed: ${o.message}`)),process.exit(1);}});var Jt=ne.command("project").description("Safe workspace project lifecycle operations");Jt.command("commands").description("Show effective commands supported by the current RapidKit project").option("--json","Emit machine-readable JSON output").action(async t=>{yi({json:t.json});});Jt.command("archives").description("List archived workspace projects").option("--workspace <path>","Workspace root path (defaults to nearest RapidKit workspace)").option("--json","Emit machine-readable JSON output").action(async t=>{try{let e=await ar({workspacePath:t.workspace});if(t.json){console.log(JSON.stringify({archives:e},null,2));return}if(e.length===0){console.log(s.yellow("No archived projects found."));return}for(let o of e)console.log(s.cyan(o.projectName)),console.log(s.gray(` Archived: ${o.archivedAt}`)),console.log(s.gray(` Path: ${o.archivePath}`)),o.reason&&console.log(s.gray(` Reason: ${o.reason}`));}catch(e){console.log(s.red(`\u274C Project archive list failed: ${e.message}`)),process.exit(1);}});Jt.command("archive <project>").description("Move a project into .rapidkit/archive with a safety snapshot").option("--workspace <path>","Workspace root path (defaults to nearest RapidKit workspace)").option("--reason <text>","Reason recorded in the archive manifest").option("--dry-run","Show what would be archived without changing files").option("--json","Emit machine-readable JSON output").action(async(t,e)=>{try{let o=await cr({workspacePath:e.workspace,project:t,reason:e.reason,dryRun:e.dryRun===true||process.argv.includes("--dry-run")});if(e.json){console.log(JSON.stringify(o,null,2));return}console.log(o.dryRun?s.cyan(`Project archive dry-run: ${o.projectName}`):s.green(`\u2714 Project archived: ${o.projectName}`)),console.log(s.gray(` From: ${o.projectPath}`)),o.archivePath&&console.log(s.gray(` To: ${o.archivePath}`)),o.safetySnapshotPath&&console.log(s.gray(` Safety snapshot: ${o.safetySnapshotPath}`));}catch(o){console.log(s.red(`\u274C Project archive failed: ${o.message}`)),process.exit(1);}});Jt.command("restore <archive>").description("Restore an archived project back into the workspace").option("--workspace <path>","Workspace root path (defaults to nearest RapidKit workspace)").option("--name <projectName>","Restore using a new project folder name").option("--reason <text>","Reason recorded in the audit log").option("--force","Overwrite an existing restore target").option("--dry-run","Show what would be restored without changing files").option("--json","Emit machine-readable JSON output").action(async(t,e)=>{try{let o=await ps({workspacePath:e.workspace,archive:t,targetName:e.name,reason:e.reason,force:e.force===true,dryRun:e.dryRun===true});if(e.json){console.log(JSON.stringify(o,null,2));return}console.log(o.dryRun?s.cyan(`Project restore dry-run: ${o.projectName}`):s.green(`\u2714 Project restored: ${o.projectName}`)),console.log(s.gray(` From: ${o.archivePath}`)),console.log(s.gray(` To: ${o.projectPath}`)),o.safetySnapshotPath&&console.log(s.gray(` Safety snapshot: ${o.safetySnapshotPath}`));}catch(o){console.log(s.red(`\u274C Project restore failed: ${o.message}`)),process.exit(1);}});Jt.command("delete <project>").description("Archive by default; permanently delete only with --permanent and exact --confirm").option("--workspace <path>","Workspace root path (defaults to nearest RapidKit workspace)").option("--reason <text>","Reason recorded in the safety snapshot/archive manifest").option("--permanent","Permanently delete the project directory").option("--confirm <projectName>","Required exact project name for --permanent").option("--dry-run","Show what would be deleted without changing files").option("--json","Emit machine-readable JSON output").action(async(t,e)=>{try{let o=await ds({workspacePath:e.workspace,project:t,reason:e.reason,permanent:e.permanent===true,confirm:e.confirm,dryRun:e.dryRun===true||process.argv.includes("--dry-run")});if(e.json){console.log(JSON.stringify(o,null,2));return}let r=o.action==="archive"?"archived":"deleted";console.log(o.dryRun?s.cyan(`Project ${r} dry-run: ${o.projectName}`):s.green(`\u2714 Project ${r}: ${o.projectName}`)),console.log(s.gray(` Path: ${o.projectPath}`)),o.archivePath&&console.log(s.gray(` Archive: ${o.archivePath}`)),o.safetySnapshotPath&&console.log(s.gray(` Safety snapshot: ${o.safetySnapshotPath}`));}catch(o){console.log(s.red(`\u274C Project delete failed: ${o.message}`)),process.exit(1);}});ne.command("doctor [scope]").description("\u{1FA7A} Check RapidKit system health by default; use workspace or project for scoped checks").option("--workspace","Check entire workspace (including all projects)").option("--project","Check only the current project (or nearest parent project)").option("--json","Output results in JSON format (for CI/CD pipelines)").option("--strict","Exit 1 on health errors or warnings (workspace/project scope)").option("--ci","CI gate: exit 1 on errors, exit 2 on warnings only").option("--fix","Automatically fix common issues (with confirmation)").option("--plan","Generate remediation plan without applying changes").option("--apply","Apply remediation plan non-interactively").action(async(t,e)=>{t&&t!=="workspace"&&t!=="project"&&(console.log(s.red(`Unknown doctor scope: ${t}`)),console.log(s.gray("Available: workspace, project")),console.log(s.gray("Usage: npx rapidkit doctor | npx rapidkit doctor workspace | npx rapidkit doctor project")),process.exit(1)),e.plan&&(e.fix||e.apply)&&(console.log(s.red("Invalid doctor flags: --plan cannot be combined with --fix or --apply")),process.exit(1));let o=await Bc({scope:t,workspaceFlag:e.workspace});o.detected&&!e.json&&(console.log(s.yellow("\u26A0\uFE0F Local launcher shadow detected for doctor workspace checks.")),o.candidatePath&&console.log(s.gray(` Candidate: ${o.candidatePath}`)),console.log(s.gray(" Running npm-wrapper doctor workflow directly as safe fallback to avoid ambiguous rapidkit binary resolution.")),console.log(s.gray(" If this happens in a shell call, run: npx --yes --package rapidkit rapidkit doctor workspace")));let{runDoctor:r}=await import('./doctor-QC662YLH.js'),n=await r({...e,workspace:e.workspace||t==="workspace",project:e.project||t==="project",strict:e.strict===true,ci:e.ci===true});n!==0&&process.exit(n);});ne.command("workspace <action> [subaction] [key] [value]").description(`Manage RapidKit workspaces (list, sync, policy, share, export, hydrate, run)
|
|
295
295
|
workspace run <stage> \u2014 fleet stage execution across discovered projects
|
|
296
|
-
stages: init | test | build | start (dev excluded by design)`).option("--workspace <path>","Workspace root path (defaults to nearest RapidKit workspace)").option("--output <file>","Output file path for workspace share bundle").option("--from <file>","Input workspace model snapshot/report for workspace diff").option("--from-impact <file>","Input workspace impact report for workspace verify (defaults to last-run impact)").option("--include-paths","Include absolute paths in workspace share bundle").option("--write","Write workspace intelligence artifact to .rapidkit/reports").option("--include-evidence","Read status metadata from referenced evidence reports").option("--scan-depth <count>","Observable project discovery depth for large monorepos").option("--for-agent [agent]","Build an agent-ready workspace context pack").option("--agent-sync","After --write on context, sync cross-tool agent grounding files (AGENTS.md, Copilot, Cursor, Claude)").option("--no-agent-sync","Skip automatic agent grounding sync after context --write").option("--target <targets>","Agent grounding targets for agent-sync (all|agents,copilot,cursor,claude,codex,orca)").option("--refresh-context","Rebuild workspace-context-agent.json during agent-sync").option("--scope <scope>","Scope workspace intelligence output, e.g. project:<name>").option("--no-doctor","Exclude doctor evidence in workspace share bundle").option("--no-blueprint","Exclude reproducibility blueprint from workspace share bundle").option("--include-env","Include .env/private key files in workspace export archive").option("--force","Overwrite an existing hydrate output directory").option("--refresh","Publish workspace registry summary before reading status").option("--dry-run","Preview hydrate without writing files").option("--affected","Run only affected projects (requires git diff context)").option("--blast-radius","Include downstream dependents from workspace dependency graph").option("--since <ref>","Git ref for affected calculation (default: HEAD~1)").option("--parallel","Run project stages in parallel").option("--max-workers <count>","Maximum parallel workers (default: min(4, selected))").option("--continue-on-error","Continue running remaining projects after a failure").option("--json","Emit machine-readable JSON output").option("--strict","Return non-zero exit on warn/fail gate outcomes").option("--no-gates","Skip doctor/readiness pre-run gates").action(async function(t,e,o,r){let n=this.opts(),i=l=>{let m=(n.workspace?h.resolve(n.workspace):null)??a$7(process.cwd())??oe(process.cwd());(!m||!We(m))&&(console.log(s.red("\u274C Not inside a RapidKit workspace")),console.log(s.gray("\u{1F4A1} Run from a workspace directory or pass --workspace <path>.")),process.exit(1));let p=h.resolve(process.cwd()),d=h.resolve(m);return p!==d&&console.log(s.gray(`\u2139 Using workspace root ${m} for "${l}" (current directory: ${p}).`)),m},a=l=>process.argv.includes(l),c=()=>{if(!n.scanDepth)return;let l=Number.parseInt(n.scanDepth,10);return Number.isFinite(l)?l:void 0};if(t==="list"){let{listWorkspaces:l}=await import('./workspace-2AL5C3QZ.js');await l();}else if(t==="model"){let l=i("model"),{buildWorkspaceModel:f,writeWorkspaceModel:m}=await import('./workspace-model-NQVZN5W4.js'),p=await f({workspacePath:l,includeAbsolutePaths:n.includePaths===true||a("--include-paths"),includeEvidence:n.includeEvidence===true||a("--include-evidence"),observableScanDepth:c(),strict:n.strict===true||a("--strict")}),d;(n.write===true||a("--write"))&&(d=await m(p,l));let u=(n.strict===true||a("--strict"))&&p.validation?.status!=="passed";if(n.json){console.log(JSON.stringify({...p,...d?{outputPath:d}:{}},null,2)),u&&process.exit(1);return}console.log(s.green(`\u2714 Workspace model: ${p.workspace.name}`)),console.log(s.gray(` Projects: ${p.summary.projectCount}`)),console.log(s.gray(` Runtimes: ${p.summary.runtimes.join(", ")||"none"}`)),console.log(s.gray(` Frameworks: ${p.summary.frameworks.join(", ")||"none"}`)),console.log(s.gray(` Workspace type: ${p.identity.workspaceType}`)),console.log(s.gray(` Validation: ${p.validation?.status??"unknown"} (${p.validation?.errors??0} error, ${p.validation?.warnings??0} warning)`)),console.log(d?s.gray(` Written: ${d}`):s.gray(" Add --write to persist .rapidkit/reports/workspace-model.json")),u&&process.exit(1);}else if(t==="agent-sync"){let l=i("agent-sync"),{syncWorkspaceAgentGrounding:f,parseAgentGroundingTargets:m}=await import('./workspace-agent-sync-V2H6NTGD.js'),p=n.strict===true||a("--strict"),d=n.write===true||a("--write"),u=a("--dry-run"),g=await f({workspacePath:l,scope:n.scope,agent:n.forAgent,write:d&&!u,dryRun:u,strict:p,refreshContext:n.refreshContext===true||a("--refresh-context")||a("--refresh"),targets:m(n.target),staleAfterHours:24});if(n.json)console.log(JSON.stringify(g,null,2));else {console.log(s.green(`\u2714 Agent grounding ${d&&!u?"synced":"planned"}`)),console.log(s.gray(` Index: ${g.indexPath}`)),g.contextPath&&console.log(s.gray(` Context: ${g.contextPath}`)),g.blockers.length>0&&console.log(s.yellow(` Blockers: ${g.blockers.slice(0,3).join(" \xB7 ")}`));let w=d&&!u?g.writtenFiles:g.skippedFiles;if(w.length>0&&console.log(s.gray(` Files: ${w.join(", ")}`)),g.strictViolations.length>0)for(let y of g.strictViolations)console.log(s.red(`\u274C ${y}`));}p&&g.strictViolations.length>0&&process.exit(1);}else if(t==="context"){let l=i("context");n.forAgent!==true&&typeof n.forAgent!="string"&&e!=="agent"&&(console.log(s.red("\u274C workspace context currently requires --for-agent")),console.log(s.gray(" npx rapidkit workspace context --for-agent --json [--scope project:<name>]")),process.exit(1));let{buildWorkspaceAgentContext:f,writeWorkspaceAgentContext:m}=await import('./workspace-context-KCKNV5VQ.js'),p=n.strict===true||a("--strict"),d=await f({workspacePath:l,agent:n.forAgent||o||e,scope:n.scope,includeEvidence:n.includeEvidence===true||a("--include-evidence"),observableScanDepth:c(),strict:p&&!n.json}),u,g;if((n.write===true||a("--write"))&&(u=await m(d,l),(n.agentSync===true||a("--agent-sync")||n.noAgentSync!==true)&&!a("--no-agent-sync"))){let{syncWorkspaceAgentGrounding:P,parseAgentGroundingTargets:v}=await import('./workspace-agent-sync-V2H6NTGD.js');if(g=await P({workspacePath:l,scope:n.scope,agent:d.agent,write:true,refreshContext:false,strict:p,targets:v(n.target)}),n.json||console.log(s.gray(` Agent grounding synced: ${g.writtenFiles.length} file(s) updated`)),p&&g.strictViolations.length>0){for(let k of g.strictViolations)console.log(s.red(`\u274C ${k}`));process.exit(1);}}let w=p&&d.validation.status!=="passed";if(n.json){console.log(JSON.stringify({...d,...u?{outputPath:u}:{},...g?{agentGroundingSync:g}:{}},null,2)),w&&process.exit(1);return}console.log(s.green(`\u2714 Workspace context: ${d.workspace.name}`)),console.log(s.gray(` Agent: ${d.agent}`)),console.log(s.gray(` Scope: ${d.scope.activeProject??d.scope.requested}`)),console.log(s.gray(` Projects included: ${d.projects.length}`)),console.log(s.gray(` Safe commands: ${d.safeCommands.length}`)),console.log(s.gray(` Validation: ${d.validation.status} (${d.validation.errors} error, ${d.validation.warnings} warning)`)),console.log(u?s.gray(` Written: ${u}`):s.gray(" Add --write to persist .rapidkit/reports/workspace-context-agent.json"));}else if(t==="snapshot"){let l=i("snapshot"),{buildWorkspaceModelSnapshot:f,writeWorkspaceModelSnapshot:m}=await import('./workspace-intelligence-3TWXJQ7Y.js'),p=await f({workspacePath:l,includeAbsolutePaths:n.includePaths===true||a("--include-paths"),includeEvidence:n.includeEvidence===true||a("--include-evidence"),observableScanDepth:c()}),d=await m(p,l);if(n.json){console.log(JSON.stringify({...p,outputPath:d},null,2));return}console.log(s.green(`\u2714 Workspace model snapshot: ${p.model.workspace.name}`)),console.log(s.gray(` Hash: ${p.modelHash}`)),console.log(s.gray(` Projects: ${p.model.summary.projectCount}`)),console.log(s.gray(` Workspace type: ${p.model.identity.workspaceType}`)),console.log(s.gray(` Written: ${d}`));}else if(t==="diff"){let l=i("diff"),f=n.from||e;f||(console.log(s.red("\u274C workspace diff requires --from <snapshot-or-model-report|git[:ref]>")),console.log(s.gray(" npx rapidkit workspace diff --from .rapidkit/reports/workspace-model-snapshot.json --json")),console.log(s.gray(" npx rapidkit workspace diff --from .rapidkit/reports/workspace-model.json --json")),console.log(s.gray(" npx rapidkit workspace impact --from .rapidkit/reports/workspace-model-diff-last-run.json --json")),console.log(s.gray(" npx rapidkit workspace diff --from git --json (uses snapshot baseline + git working tree)")),process.exit(1));let{diffWorkspaceModel:m,writeWorkspaceModelDiff:p}=await import('./workspace-intelligence-3TWXJQ7Y.js'),d=await m({workspacePath:l,fromPath:f,includeAbsolutePaths:n.includePaths===true||a("--include-paths"),includeEvidence:n.includeEvidence===true||a("--include-evidence"),observableScanDepth:c()}),u=await p(d,l);if(n.json){console.log(JSON.stringify({...d,outputPath:u},null,2));return}let g=d.summary.changed?s.yellow:s.green;console.log(g(`\u2714 Workspace model diff: ${d.summary.changed?"changed":"clean"}`)),console.log(s.gray(` From: ${d.fromRef}`)),console.log(s.gray(` Added projects: ${d.summary.addedProjects}`)),console.log(s.gray(` Removed projects: ${d.summary.removedProjects}`)),console.log(s.gray(` Changed projects: ${d.summary.changedProjects}`)),console.log(s.gray(` Workspace changes: ${d.summary.workspaceChanges}`)),console.log(s.gray(` Validation changes: ${d.summary.validationChanges}`)),d.git?.available&&console.log(s.gray(` Git: ${d.git.dirty?"dirty":"clean"} (${d.summary.gitChangedFiles} mapped change(s))`));for(let w of d.changes.slice(0,12))console.log(s.gray(` \u2022 ${w.type} ${w.target}: ${w.message}`));d.changes.length>12&&console.log(s.gray(` \u2026 ${d.changes.length-12} more change(s)`)),console.log(s.gray(` Written: ${u}`));}else if(t==="impact"){let l=i("impact"),f=n.from||e;f||(console.log(s.red("\u274C workspace impact requires --from <snapshot-model-or-diff-report>")),console.log(s.gray(" npx rapidkit workspace impact --from .rapidkit/reports/workspace-model-diff-last-run.json --json")),process.exit(1));let{buildWorkspaceImpact:m,writeWorkspaceImpact:p}=await import('./workspace-intelligence-3TWXJQ7Y.js'),d=await m({workspacePath:l,fromPath:f,scope:n.scope,includeAbsolutePaths:n.includePaths===true||a("--include-paths"),includeEvidence:n.includeEvidence===true||a("--include-evidence"),observableScanDepth:c()}),u=await p(d,l);if(n.json){console.log(JSON.stringify({...d,outputPath:u},null,2));return}let g=d.summary.risk==="critical"||d.summary.risk==="high"?s.red:d.summary.risk==="medium"?s.yellow:s.green;console.log(g(`\u2714 Workspace impact: ${d.summary.risk}`)),console.log(s.gray(` From: ${d.fromRef}`)),console.log(s.gray(` Affected projects: ${d.summary.affectedProjects}`)),console.log(s.gray(` Workspace items: ${d.summary.workspaceItems}`)),console.log(s.gray(` Recommended commands: ${d.summary.recommendedCommands}`));for(let w of d.affectedProjects.slice(0,8))console.log(s.gray(` \u2022 ${w.title}: ${w.summary}`));d.affectedProjects.length>8&&console.log(s.gray(` \u2026 ${d.affectedProjects.length-8} more project(s)`)),console.log(s.gray(` Written: ${u}`));}else if(t==="verify"){let l=i("verify"),{buildWorkspaceVerify:f,writeWorkspaceVerify:m,workspaceVerifyExitCode:p}=await import('./workspace-verify-HBCQNNGU.js'),d=await f({workspacePath:l,fromImpactPath:n.fromImpact||e,scope:n.scope,includeAbsolutePaths:n.includePaths===true||a("--include-paths"),includeEvidence:n.includeEvidence===true||a("--include-evidence"),observableScanDepth:c()}),u=await m(d,l),g=p(d,{strict:n.strict===true||a("--strict")});if(n.json){console.log(JSON.stringify({...d,outputPath:u},null,2)),g!==0&&process.exit(g);return}let w=d.summary.verdict==="ready"?s.green:d.summary.verdict==="needs-attention"?s.yellow:s.red;console.log(w(`\u2714 Workspace verify: ${d.summary.verdict}`)),console.log(s.gray(` Impact risk: ${d.impact.risk}`)),console.log(s.gray(` Steps: ${d.steps.length}`)),console.log(s.gray(` Passed ${d.summary.stepsPassed}, warn ${d.summary.stepsWarn}, failed ${d.summary.stepsFailed}, missing ${d.summary.stepsMissing}`));for(let y of d.steps.slice(0,10))console.log(s.gray(` \u2022 ${y.id}: ${y.status} \u2014 ${y.message}`));d.steps.length>10&&console.log(s.gray(` \u2026 ${d.steps.length-10} more step(s)`)),console.log(s.gray(` Written: ${u}`)),g!==0&&process.exit(g);}else if(t==="sync"){let l=i("sync"),{syncWorkspaceProjects:f}=await import('./workspace-2AL5C3QZ.js');n.json||console.log(s.cyan(`\u{1F4C2} Scanning workspace: ${h.basename(l)}`));let m=await f(l,n.json===true);await Ue(l,{silent:n.json===true});let{readWorkspaceRegistrySummary:p}=await import('./workspace-registry-summary-MIPHVB56.js'),d=await p(l);n.json&&console.log(JSON.stringify({schemaVersion:"rapidkit-workspace-sync-v1",workspacePath:l,registry:m,contractSynced:true,registrySummary:d},null,2));}else if(t==="registry"){let l=i("registry"),f=e||"status";f!=="status"&&(console.log(s.red(`\u274C Unknown workspace registry action: ${f}`)),console.log(s.gray(" npx rapidkit workspace registry status [--refresh] [--json]")),process.exit(1));let{publishWorkspaceRegistrySummary:m,readWorkspaceRegistrySummary:p,resolveWorkspaceRegisteredProjects:d}=await import('./workspace-registry-summary-MIPHVB56.js'),g=n.refresh===true||a("--refresh")||n.force===true||a("--force")?await m(l):await p(l)||await m(l);if(n.json){console.log(JSON.stringify(g,null,2));return}let w=await d(l);console.log(s.cyan("Workspace registry")),console.log(s.gray(` Authority: ${g.authority}`)),console.log(s.gray(` Projects: ${g.projectCount}`)),console.log(s.gray(` Summary: ${g.registrySummaryPath}`)),w.summary.projectCount===0&&console.log(s.yellow(" No registered projects \u2014 run workspace sync after adding projects."));}else if(t==="foundation"){let l=i("foundation"),f=e||"ensure";f!=="ensure"&&(console.log(s.red(`\u274C Unknown workspace foundation action: ${f}`)),console.log(s.gray(" npx rapidkit workspace foundation ensure [--force] [--json]")),process.exit(1));let{ensureWorkspaceFoundation:m}=await import('./workspace-foundation-L6ZBGMVE.js'),p=await m(l,{force:n.force===true||a("--force")});if(n.json){console.log(JSON.stringify(p,null,2));return}p.created.length>0?console.log(s.green(`\u2714 Workspace foundation ensured: ${p.created.join(", ")}`)):console.log(s.gray("Workspace foundation files are already up to date."));}else if(t==="policy"){let l=i("policy"),f=await tl(l,e,o,r);f!==0&&process.exit(f);}else if(t==="contract"){let l=i("contract"),{buildWorkspaceContractGraph:f,readWorkspaceContract:m,verifyWorkspaceContract:p,writeWorkspaceContract:d,WORKSPACE_CONTRACT_PATH:u}=await import('./workspace-contract-D5O4OZD5.js'),g=e||"inspect",w=n.output;try{if(g==="init"){let y=await d({workspacePath:l,outputPath:w,force:n.force===true||a("--force")});if(n.json){console.log(JSON.stringify(y,null,2));return}console.log(s.green(`\u2714 Workspace contract initialized: ${y.contractPath}`)),console.log(s.gray(` Projects: ${y.contract.projects.length}`));return}if(g==="inspect"){let y=await m({workspacePath:l,contractPath:w});if(n.json){console.log(JSON.stringify(y,null,2));return}console.log(s.green(`\u2714 Workspace contract: ${y.contractPath}`)),console.log(s.gray(` Workspace: ${y.contract.workspace.name}`)),console.log(s.gray(` Projects: ${y.contract.projects.length}`)),console.log(s.gray(` Schema: v${y.contract.schemaVersion}`));return}if(g==="verify"){let y=await p({workspacePath:l,contractPath:w,strict:n.strict===true||a("--strict")});if(n.json)console.log(JSON.stringify(y,null,2));else {let P=y.status==="passed"?s.green:s.red;console.log(P(`\u2714 Workspace contract verification ${y.status}: ${y.contractPath}`)),console.log(s.gray(` Projects: ${y.projectCount}`));for(let v of y.checks){let k=v.status==="passed"?"\u2714":"\u2718";console.log(s.gray(` ${k} ${v.id}: ${v.message}`));}for(let v of y.violations)console.log(s.gray(` Violation: ${v}`));}(y.status==="failed"||y.status!=="passed"&&n.strict)&&process.exit(1);return}if(g==="graph"){let y=await f({workspacePath:l,contractPath:w});if(n.json){console.log(JSON.stringify(y,null,2));return}console.log(s.green(`\u2714 Workspace contract graph: ${y.contractPath}`)),console.log(s.gray(` Workspace: ${y.graph.workspace.name}`)),console.log(s.gray(` Projects: ${y.graph.summary.projectCount}`)),console.log(s.gray(` Dependencies: ${y.graph.summary.dependencyEdges}`)),console.log(s.gray(` Event links: ${y.graph.summary.eventEdges}`)),console.log(s.gray(` Ports: ${y.graph.summary.portCount}`));for(let P of y.graph.nodes){let v=P.ports.map(k=>`${k.name}:${k.port}`).join(", ")||"none";console.log(s.gray(` \u2022 ${P.id} (${P.runtime||"unknown"}${P.framework?`/${P.framework}`:""}) ports=${v}`));}for(let P of y.graph.edges){let v=P.type==="event"?`event:${P.label}`:P.label;console.log(s.gray(` ${P.from} -> ${P.to} [${v}]`));}return}console.log(s.red(`\u274C Unknown workspace contract action: ${g}`)),console.log(s.white(` npx rapidkit workspace contract init|inspect|verify|graph [--output ${u}]`)),process.exit(1);}catch(y){console.log(s.red(`\u274C Workspace contract ${g} failed: ${y.message}`)),process.exit(1);}}else if(t==="share"){let l=i("share"),f=n.output||e,{createWorkspaceShareBundle:m}=await import('./workspace-2AL5C3QZ.js'),p=await m(l,{outputPath:f,includePaths:n.includePaths===true,includeDoctorEvidence:n.doctor!==false,includeBlueprint:n.blueprint!==false});console.log(s.green(`\u2714 Workspace share bundle exported: ${p}`)),console.log(s.gray("Share this JSON with your team for reproducible workspace/project diagnostics."));}else if(t==="export"){let l=i("export"),{exportWorkspaceArchive:f}=await import('./workspace-archive-EJIGYKSR.js'),m=await f({workspacePath:l,outputPath:n.output||e,includeEnv:n.includeEnv===true||a("--include-env")});if(n.json){console.log(JSON.stringify(m,null,2));return}let p=(m.bytesWritten/(1024*1024)).toFixed(2);console.log(s.green(`\u2714 Workspace archive exported: ${m.archivePath}`)),console.log(s.gray(` Files: ${m.manifest.files.length}`)),console.log(s.gray(` Size: ${p} MB`)),m.manifest.security.envFilesIncluded||console.log(s.gray(" Secrets: excluded (.env, private keys, logs, dependency caches)"));}else if(t==="archive"&&(e==="inspect"||e==="verify"||e==="doctor")){let l=o;l||(console.log(s.red(`\u274C workspace archive ${e} requires an archive path or URL.`)),console.log(s.white(` npx rapidkit workspace archive ${e} team.rapidkit-archive.zip`)),process.exit(1));let{doctorWorkspaceArchive:f,inspectWorkspaceArchive:m,verifyWorkspaceArchive:p}=await import('./workspace-archive-EJIGYKSR.js');try{if(e==="inspect"){let u=await m({archivePathOrUrl:l});if(n.json){console.log(JSON.stringify(u,null,2));return}let g=(u.totalBytes/(1024*1024)).toFixed(2);console.log(s.green(`\u2714 Workspace archive: ${u.archivePath}`)),console.log(s.gray(` Workspace: ${u.manifest.workspaceName}`)),console.log(s.gray(` Exported: ${u.manifest.exportedAt}`)),console.log(s.gray(` Exporter: ${u.manifest.exportedBy||"unknown"}`)),console.log(s.gray(` Files: ${u.fileCount}`)),console.log(s.gray(` Payload: ${g} MB`));return}if(e==="doctor"){let u=await f({archivePathOrUrl:l,strict:n.strict===true||a("--strict")});if(n.json)console.log(JSON.stringify(u,null,2));else {let g=u.status==="passed"?s.green:u.status==="warning"?s.yellow:s.red;console.log(g(`\u2714 Workspace archive doctor ${u.status}: ${u.archivePath}`)),console.log(s.gray(` Workspace: ${u.workspaceName}`)),console.log(s.gray(` Files: ${u.fileCount}`));for(let w of u.checks){let y=w.status==="passed"?"\u2714":w.status==="warning"?"\u26A0":"\u2718";console.log(s.gray(` ${y} ${w.id}: ${w.message}`));}for(let w of u.recommendedActions)console.log(s.gray(` Next: ${w}`));}(u.status==="failed"||u.status==="warning"&&n.strict)&&process.exit(1);return}let d=await p({archivePathOrUrl:l,requireChecksums:n.strict===true||a("--strict")});if(n.json)console.log(JSON.stringify(d,null,2));else if(d.status==="passed")console.log(s.green(`\u2714 Workspace archive verified: ${d.archivePath}`)),console.log(s.gray(` Files: ${d.verifiedFiles}/${d.fileCount}`));else {let u=d.status==="failed"?s.red:s.yellow;console.log(u(`\u274C Workspace archive verification ${d.status}: ${d.archivePath}`)),d.missingArchiveEntries.length&&console.log(s.gray(` Missing entries: ${d.missingArchiveEntries.join(", ")}`)),d.extraArchiveEntries.length&&console.log(s.gray(` Unexpected entries: ${d.extraArchiveEntries.join(", ")}`)),d.mismatches.length&&console.log(s.gray(` Mismatches: ${d.mismatches.map(g=>g.path).join(", ")}`)),d.missingChecksumFiles.length&&console.log(s.gray(` Missing checksums: ${d.missingChecksumFiles.join(", ")}`));}(d.status==="failed"||d.status==="warning"&&n.strict)&&process.exit(1);}catch(d){console.log(s.red(`\u274C Workspace archive ${e} failed: ${d.message}`)),process.exit(1);}}else if(t==="hydrate"||t==="import"){let l=e;l||(console.log(s.red(`\u274C workspace ${t} requires an archive path or URL.`)),console.log(s.white(` npx rapidkit workspace ${t} team.rapidkit-archive.zip --output ./team`)),process.exit(1));let{hydrateWorkspaceArchive:f}=await import('./workspace-archive-EJIGYKSR.js');try{let m=await f({archivePathOrUrl:l,outputPath:n.output,force:n.force===true||a("--force"),dryRun:n.dryRun===true||a("--dry-run"),strict:n.strict===true||a("--strict")});if(n.json){console.log(JSON.stringify(m,null,2));return}console.log(s.green(m.dryRun?`\u2714 Workspace archive hydrate preview: ${m.outputPath}`:`\u2714 Workspace archive hydrated: ${m.outputPath}`)),console.log(s.gray(` Files: ${m.files.length}`)),m.manifest?.workspaceName&&console.log(s.gray(` Workspace: ${m.manifest.workspaceName}`));}catch(m){console.log(s.red(`\u274C Workspace ${t} failed: ${m.message}`)),process.exit(1);}}else if(t==="run"){let l=i(`run ${e||""}`.trim());(!e||!["init","test","build","start"].includes(e))&&(console.log(s.red(`Unknown workspace run stage: ${e||"(none provided)"}`)),console.log(s.gray("Available stages: init | test | build | start")),console.log(s.gray(" \u2022 init \u2014 run install/bootstrap across the project fleet")),console.log(s.gray(" \u2022 test \u2014 run test suite across selected projects")),console.log(s.gray(" \u2022 build \u2014 compile/package across selected projects")),console.log(s.gray(" \u2022 start \u2014 start services (smoke/e2e scenarios)")),console.log(s.gray(" Note: dev is excluded \u2014 it is a local-only primitive, not a CI stage")),process.exit(2));let f=Number(n.maxWorkers??""),m=Number.isFinite(f)?Math.max(1,Math.trunc(f)):void 0;if(e==="init"){let u=await Dr(l);u!==0&&process.exit(u);}let{runWorkspaceStage:p}=await import('./workspace-run-DEXI52KO.js'),d=await p({workspacePath:l,stage:e,scope:n.scope,affected:n.affected===true,blastRadius:n.blastRadius===true,since:n.since,parallel:n.parallel===true,maxWorkers:m,continueOnError:n.continueOnError===true,strict:n.strict===true,json:n.json===true,enforceGates:n.gates});n.json&&console.log(JSON.stringify(d,null,2)),d.summary.exitCode!==0&&process.exit(d.summary.exitCode);}else if(t==="init"){console.log(s.yellow("\u2139 workspace init is an alias of: npx rapidkit workspace run init")),console.log(s.gray(` Equivalent full-init aliases at workspace root:
|
|
296
|
+
stages: init | test | build | start (dev excluded by design)`).option("--workspace <path>","Workspace root path (defaults to nearest RapidKit workspace)").option("--output <file>","Output file path for workspace share bundle").option("--from <file>","Input workspace model snapshot/report for workspace diff").option("--from-impact <file>","Input workspace impact report for workspace verify (defaults to last-run impact)").option("--include-paths","Include absolute paths in workspace share bundle").option("--write","Write workspace intelligence artifact to .rapidkit/reports").option("--include-evidence","Read status metadata from referenced evidence reports").option("--scan-depth <count>","Observable project discovery depth for large monorepos").option("--for-agent [agent]","Build an agent-ready workspace context pack").option("--agent-sync","After --write on context, sync cross-tool agent grounding files (AGENTS.md, Copilot, Cursor, Claude)").option("--no-agent-sync","Skip automatic agent grounding sync after context --write").option("--target <targets>","Agent grounding targets for agent-sync (all|agents,copilot,cursor,claude,codex,orca)").option("--refresh-context","Rebuild workspace-context-agent.json during agent-sync").option("--scope <scope>","Scope workspace intelligence output, e.g. project:<name>").option("--no-doctor","Exclude doctor evidence in workspace share bundle").option("--no-blueprint","Exclude reproducibility blueprint from workspace share bundle").option("--include-env","Include .env/private key files in workspace export archive").option("--force","Overwrite an existing hydrate output directory").option("--refresh","Publish workspace registry summary before reading status").option("--dry-run","Preview hydrate without writing files").option("--affected","Run only affected projects (requires git diff context)").option("--blast-radius","Include downstream dependents from workspace dependency graph").option("--since <ref>","Git ref for affected calculation (default: HEAD~1)").option("--parallel","Run project stages in parallel").option("--max-workers <count>","Maximum parallel workers (default: min(4, selected))").option("--continue-on-error","Continue running remaining projects after a failure").option("--json","Emit machine-readable JSON output").option("--strict","Return non-zero exit on warn/fail gate outcomes").option("--no-gates","Skip doctor/readiness pre-run gates").action(async function(t,e,o,r){let n=this.opts(),i=l=>{let m=(n.workspace?h.resolve(n.workspace):null)??a$7(process.cwd())??oe(process.cwd());(!m||!We(m))&&(console.log(s.red("\u274C Not inside a RapidKit workspace")),console.log(s.gray("\u{1F4A1} Run from a workspace directory or pass --workspace <path>.")),process.exit(1));let p=h.resolve(process.cwd()),d=h.resolve(m);return p!==d&&console.log(s.gray(`\u2139 Using workspace root ${m} for "${l}" (current directory: ${p}).`)),m},a=l=>process.argv.includes(l),c=()=>{if(!n.scanDepth)return;let l=Number.parseInt(n.scanDepth,10);return Number.isFinite(l)?l:void 0};if(t==="list"){let{listWorkspaces:l}=await import('./workspace-2AL5C3QZ.js');await l();}else if(t==="model"){let l=i("model"),{buildWorkspaceModel:f,writeWorkspaceModel:m}=await import('./workspace-model-NQVZN5W4.js'),p=await f({workspacePath:l,includeAbsolutePaths:n.includePaths===true||a("--include-paths"),includeEvidence:n.includeEvidence===true||a("--include-evidence"),observableScanDepth:c(),strict:n.strict===true||a("--strict")}),d;(n.write===true||a("--write"))&&(d=await m(p,l));let u=(n.strict===true||a("--strict"))&&p.validation?.status!=="passed";if(n.json){console.log(JSON.stringify({...p,...d?{outputPath:d}:{}},null,2)),u&&process.exit(1);return}console.log(s.green(`\u2714 Workspace model: ${p.workspace.name}`)),console.log(s.gray(` Projects: ${p.summary.projectCount}`)),console.log(s.gray(` Runtimes: ${p.summary.runtimes.join(", ")||"none"}`)),console.log(s.gray(` Frameworks: ${p.summary.frameworks.join(", ")||"none"}`)),console.log(s.gray(` Workspace type: ${p.identity.workspaceType}`)),console.log(s.gray(` Validation: ${p.validation?.status??"unknown"} (${p.validation?.errors??0} error, ${p.validation?.warnings??0} warning)`)),console.log(d?s.gray(` Written: ${d}`):s.gray(" Add --write to persist .rapidkit/reports/workspace-model.json")),u&&process.exit(1);}else if(t==="agent-sync"){let l=i("agent-sync"),{syncWorkspaceAgentGrounding:f,parseAgentGroundingTargets:m}=await import('./workspace-agent-sync-4R7S3F6T.js'),p=n.strict===true||a("--strict"),d=n.write===true||a("--write"),u=a("--dry-run"),g=await f({workspacePath:l,scope:n.scope,agent:n.forAgent,write:d&&!u,dryRun:u,strict:p,refreshContext:n.refreshContext===true||a("--refresh-context")||a("--refresh"),targets:m(n.target),staleAfterHours:24});if(n.json)console.log(JSON.stringify(g,null,2));else {console.log(s.green(`\u2714 Agent grounding ${d&&!u?"synced":"planned"}`)),console.log(s.gray(` Index: ${g.indexPath}`)),g.contextPath&&console.log(s.gray(` Context: ${g.contextPath}`)),g.blockers.length>0&&console.log(s.yellow(` Blockers: ${g.blockers.slice(0,3).join(" \xB7 ")}`));let w=d&&!u?g.writtenFiles:g.skippedFiles;if(w.length>0&&console.log(s.gray(` Files: ${w.join(", ")}`)),g.strictViolations.length>0)for(let y of g.strictViolations)console.log(s.red(`\u274C ${y}`));}p&&g.strictViolations.length>0&&process.exit(1);}else if(t==="context"){let l=i("context");n.forAgent!==true&&typeof n.forAgent!="string"&&e!=="agent"&&(console.log(s.red("\u274C workspace context currently requires --for-agent")),console.log(s.gray(" npx rapidkit workspace context --for-agent --json [--scope project:<name>]")),process.exit(1));let{buildWorkspaceAgentContext:f,writeWorkspaceAgentContext:m}=await import('./workspace-context-CKACDTVE.js'),p=n.strict===true||a("--strict"),d=await f({workspacePath:l,agent:n.forAgent||o||e,scope:n.scope,includeEvidence:n.includeEvidence===true||a("--include-evidence"),observableScanDepth:c(),strict:p&&!n.json}),u,g;if((n.write===true||a("--write"))&&(u=await m(d,l),(n.agentSync===true||a("--agent-sync")||n.noAgentSync!==true)&&!a("--no-agent-sync"))){let{syncWorkspaceAgentGrounding:P,parseAgentGroundingTargets:v}=await import('./workspace-agent-sync-4R7S3F6T.js');if(g=await P({workspacePath:l,scope:n.scope,agent:d.agent,write:true,refreshContext:false,strict:p,targets:v(n.target)}),n.json||console.log(s.gray(` Agent grounding synced: ${g.writtenFiles.length} file(s) updated`)),p&&g.strictViolations.length>0){for(let k of g.strictViolations)console.log(s.red(`\u274C ${k}`));process.exit(1);}}let w=p&&d.validation.status!=="passed";if(n.json){console.log(JSON.stringify({...d,...u?{outputPath:u}:{},...g?{agentGroundingSync:g}:{}},null,2)),w&&process.exit(1);return}console.log(s.green(`\u2714 Workspace context: ${d.workspace.name}`)),console.log(s.gray(` Agent: ${d.agent}`)),console.log(s.gray(` Scope: ${d.scope.activeProject??d.scope.requested}`)),console.log(s.gray(` Projects included: ${d.projects.length}`)),console.log(s.gray(` Safe commands: ${d.safeCommands.length}`)),console.log(s.gray(` Validation: ${d.validation.status} (${d.validation.errors} error, ${d.validation.warnings} warning)`)),console.log(u?s.gray(` Written: ${u}`):s.gray(" Add --write to persist .rapidkit/reports/workspace-context-agent.json"));}else if(t==="snapshot"){let l=i("snapshot"),{buildWorkspaceModelSnapshot:f,writeWorkspaceModelSnapshot:m}=await import('./workspace-intelligence-3TWXJQ7Y.js'),p=await f({workspacePath:l,includeAbsolutePaths:n.includePaths===true||a("--include-paths"),includeEvidence:n.includeEvidence===true||a("--include-evidence"),observableScanDepth:c()}),d=await m(p,l);if(n.json){console.log(JSON.stringify({...p,outputPath:d},null,2));return}console.log(s.green(`\u2714 Workspace model snapshot: ${p.model.workspace.name}`)),console.log(s.gray(` Hash: ${p.modelHash}`)),console.log(s.gray(` Projects: ${p.model.summary.projectCount}`)),console.log(s.gray(` Workspace type: ${p.model.identity.workspaceType}`)),console.log(s.gray(` Written: ${d}`));}else if(t==="diff"){let l=i("diff"),f=n.from||e;f||(console.log(s.red("\u274C workspace diff requires --from <snapshot-or-model-report|git[:ref]>")),console.log(s.gray(" npx rapidkit workspace diff --from .rapidkit/reports/workspace-model-snapshot.json --json")),console.log(s.gray(" npx rapidkit workspace diff --from .rapidkit/reports/workspace-model.json --json")),console.log(s.gray(" npx rapidkit workspace impact --from .rapidkit/reports/workspace-model-diff-last-run.json --json")),console.log(s.gray(" npx rapidkit workspace diff --from git --json (uses snapshot baseline + git working tree)")),process.exit(1));let{diffWorkspaceModel:m,writeWorkspaceModelDiff:p}=await import('./workspace-intelligence-3TWXJQ7Y.js'),d=await m({workspacePath:l,fromPath:f,includeAbsolutePaths:n.includePaths===true||a("--include-paths"),includeEvidence:n.includeEvidence===true||a("--include-evidence"),observableScanDepth:c()}),u=await p(d,l);if(n.json){console.log(JSON.stringify({...d,outputPath:u},null,2));return}let g=d.summary.changed?s.yellow:s.green;console.log(g(`\u2714 Workspace model diff: ${d.summary.changed?"changed":"clean"}`)),console.log(s.gray(` From: ${d.fromRef}`)),console.log(s.gray(` Added projects: ${d.summary.addedProjects}`)),console.log(s.gray(` Removed projects: ${d.summary.removedProjects}`)),console.log(s.gray(` Changed projects: ${d.summary.changedProjects}`)),console.log(s.gray(` Workspace changes: ${d.summary.workspaceChanges}`)),console.log(s.gray(` Validation changes: ${d.summary.validationChanges}`)),d.git?.available&&console.log(s.gray(` Git: ${d.git.dirty?"dirty":"clean"} (${d.summary.gitChangedFiles} mapped change(s))`));for(let w of d.changes.slice(0,12))console.log(s.gray(` \u2022 ${w.type} ${w.target}: ${w.message}`));d.changes.length>12&&console.log(s.gray(` \u2026 ${d.changes.length-12} more change(s)`)),console.log(s.gray(` Written: ${u}`));}else if(t==="impact"){let l=i("impact"),f=n.from||e;f||(console.log(s.red("\u274C workspace impact requires --from <snapshot-model-or-diff-report>")),console.log(s.gray(" npx rapidkit workspace impact --from .rapidkit/reports/workspace-model-diff-last-run.json --json")),process.exit(1));let{buildWorkspaceImpact:m,writeWorkspaceImpact:p}=await import('./workspace-intelligence-3TWXJQ7Y.js'),d=await m({workspacePath:l,fromPath:f,scope:n.scope,includeAbsolutePaths:n.includePaths===true||a("--include-paths"),includeEvidence:n.includeEvidence===true||a("--include-evidence"),observableScanDepth:c()}),u=await p(d,l);if(n.json){console.log(JSON.stringify({...d,outputPath:u},null,2));return}let g=d.summary.risk==="critical"||d.summary.risk==="high"?s.red:d.summary.risk==="medium"?s.yellow:s.green;console.log(g(`\u2714 Workspace impact: ${d.summary.risk}`)),console.log(s.gray(` From: ${d.fromRef}`)),console.log(s.gray(` Affected projects: ${d.summary.affectedProjects}`)),console.log(s.gray(` Workspace items: ${d.summary.workspaceItems}`)),console.log(s.gray(` Recommended commands: ${d.summary.recommendedCommands}`));for(let w of d.affectedProjects.slice(0,8))console.log(s.gray(` \u2022 ${w.title}: ${w.summary}`));d.affectedProjects.length>8&&console.log(s.gray(` \u2026 ${d.affectedProjects.length-8} more project(s)`)),console.log(s.gray(` Written: ${u}`));}else if(t==="verify"){let l=i("verify"),{buildWorkspaceVerify:f,writeWorkspaceVerify:m,workspaceVerifyExitCode:p}=await import('./workspace-verify-EO435PS4.js'),d=await f({workspacePath:l,fromImpactPath:n.fromImpact||e,scope:n.scope,includeAbsolutePaths:n.includePaths===true||a("--include-paths"),includeEvidence:n.includeEvidence===true||a("--include-evidence"),observableScanDepth:c()}),u=await m(d,l),g=p(d,{strict:n.strict===true||a("--strict")});if(n.json){console.log(JSON.stringify({...d,outputPath:u},null,2)),g!==0&&process.exit(g);return}let w=d.summary.verdict==="ready"?s.green:d.summary.verdict==="needs-attention"?s.yellow:s.red;console.log(w(`\u2714 Workspace verify: ${d.summary.verdict}`)),console.log(s.gray(` Impact risk: ${d.impact.risk}`)),console.log(s.gray(` Steps: ${d.steps.length}`)),console.log(s.gray(` Passed ${d.summary.stepsPassed}, warn ${d.summary.stepsWarn}, failed ${d.summary.stepsFailed}, missing ${d.summary.stepsMissing}`));for(let y of d.steps.slice(0,10))console.log(s.gray(` \u2022 ${y.id}: ${y.status} \u2014 ${y.message}`));d.steps.length>10&&console.log(s.gray(` \u2026 ${d.steps.length-10} more step(s)`)),console.log(s.gray(` Written: ${u}`)),g!==0&&process.exit(g);}else if(t==="sync"){let l=i("sync"),{syncWorkspaceProjects:f}=await import('./workspace-2AL5C3QZ.js');n.json||console.log(s.cyan(`\u{1F4C2} Scanning workspace: ${h.basename(l)}`));let m=await f(l,n.json===true);await Ue(l,{silent:n.json===true});let{readWorkspaceRegistrySummary:p}=await import('./workspace-registry-summary-MIPHVB56.js'),d=await p(l);n.json&&console.log(JSON.stringify({schemaVersion:"rapidkit-workspace-sync-v1",workspacePath:l,registry:m,contractSynced:true,registrySummary:d},null,2));}else if(t==="registry"){let l=i("registry"),f=e||"status";f!=="status"&&(console.log(s.red(`\u274C Unknown workspace registry action: ${f}`)),console.log(s.gray(" npx rapidkit workspace registry status [--refresh] [--json]")),process.exit(1));let{publishWorkspaceRegistrySummary:m,readWorkspaceRegistrySummary:p,resolveWorkspaceRegisteredProjects:d}=await import('./workspace-registry-summary-MIPHVB56.js'),g=n.refresh===true||a("--refresh")||n.force===true||a("--force")?await m(l):await p(l)||await m(l);if(n.json){console.log(JSON.stringify(g,null,2));return}let w=await d(l);console.log(s.cyan("Workspace registry")),console.log(s.gray(` Authority: ${g.authority}`)),console.log(s.gray(` Projects: ${g.projectCount}`)),console.log(s.gray(` Summary: ${g.registrySummaryPath}`)),w.summary.projectCount===0&&console.log(s.yellow(" No registered projects \u2014 run workspace sync after adding projects."));}else if(t==="foundation"){let l=i("foundation"),f=e||"ensure";f!=="ensure"&&(console.log(s.red(`\u274C Unknown workspace foundation action: ${f}`)),console.log(s.gray(" npx rapidkit workspace foundation ensure [--force] [--json]")),process.exit(1));let{ensureWorkspaceFoundation:m}=await import('./workspace-foundation-L6ZBGMVE.js'),p=await m(l,{force:n.force===true||a("--force")});if(n.json){console.log(JSON.stringify(p,null,2));return}p.created.length>0?console.log(s.green(`\u2714 Workspace foundation ensured: ${p.created.join(", ")}`)):console.log(s.gray("Workspace foundation files are already up to date."));}else if(t==="policy"){let l=i("policy"),f=await tl(l,e,o,r);f!==0&&process.exit(f);}else if(t==="contract"){let l=i("contract"),{buildWorkspaceContractGraph:f,readWorkspaceContract:m,verifyWorkspaceContract:p,writeWorkspaceContract:d,WORKSPACE_CONTRACT_PATH:u}=await import('./workspace-contract-D5O4OZD5.js'),g=e||"inspect",w=n.output;try{if(g==="init"){let y=await d({workspacePath:l,outputPath:w,force:n.force===true||a("--force")});if(n.json){console.log(JSON.stringify(y,null,2));return}console.log(s.green(`\u2714 Workspace contract initialized: ${y.contractPath}`)),console.log(s.gray(` Projects: ${y.contract.projects.length}`));return}if(g==="inspect"){let y=await m({workspacePath:l,contractPath:w});if(n.json){console.log(JSON.stringify(y,null,2));return}console.log(s.green(`\u2714 Workspace contract: ${y.contractPath}`)),console.log(s.gray(` Workspace: ${y.contract.workspace.name}`)),console.log(s.gray(` Projects: ${y.contract.projects.length}`)),console.log(s.gray(` Schema: v${y.contract.schemaVersion}`));return}if(g==="verify"){let y=await p({workspacePath:l,contractPath:w,strict:n.strict===true||a("--strict")});if(n.json)console.log(JSON.stringify(y,null,2));else {let P=y.status==="passed"?s.green:s.red;console.log(P(`\u2714 Workspace contract verification ${y.status}: ${y.contractPath}`)),console.log(s.gray(` Projects: ${y.projectCount}`));for(let v of y.checks){let k=v.status==="passed"?"\u2714":"\u2718";console.log(s.gray(` ${k} ${v.id}: ${v.message}`));}for(let v of y.violations)console.log(s.gray(` Violation: ${v}`));}(y.status==="failed"||y.status!=="passed"&&n.strict)&&process.exit(1);return}if(g==="graph"){let y=await f({workspacePath:l,contractPath:w});if(n.json){console.log(JSON.stringify(y,null,2));return}console.log(s.green(`\u2714 Workspace contract graph: ${y.contractPath}`)),console.log(s.gray(` Workspace: ${y.graph.workspace.name}`)),console.log(s.gray(` Projects: ${y.graph.summary.projectCount}`)),console.log(s.gray(` Dependencies: ${y.graph.summary.dependencyEdges}`)),console.log(s.gray(` Event links: ${y.graph.summary.eventEdges}`)),console.log(s.gray(` Ports: ${y.graph.summary.portCount}`));for(let P of y.graph.nodes){let v=P.ports.map(k=>`${k.name}:${k.port}`).join(", ")||"none";console.log(s.gray(` \u2022 ${P.id} (${P.runtime||"unknown"}${P.framework?`/${P.framework}`:""}) ports=${v}`));}for(let P of y.graph.edges){let v=P.type==="event"?`event:${P.label}`:P.label;console.log(s.gray(` ${P.from} -> ${P.to} [${v}]`));}return}console.log(s.red(`\u274C Unknown workspace contract action: ${g}`)),console.log(s.white(` npx rapidkit workspace contract init|inspect|verify|graph [--output ${u}]`)),process.exit(1);}catch(y){console.log(s.red(`\u274C Workspace contract ${g} failed: ${y.message}`)),process.exit(1);}}else if(t==="share"){let l=i("share"),f=n.output||e,{createWorkspaceShareBundle:m}=await import('./workspace-2AL5C3QZ.js'),p=await m(l,{outputPath:f,includePaths:n.includePaths===true,includeDoctorEvidence:n.doctor!==false,includeBlueprint:n.blueprint!==false});console.log(s.green(`\u2714 Workspace share bundle exported: ${p}`)),console.log(s.gray("Share this JSON with your team for reproducible workspace/project diagnostics."));}else if(t==="export"){let l=i("export"),{exportWorkspaceArchive:f}=await import('./workspace-archive-EJIGYKSR.js'),m=await f({workspacePath:l,outputPath:n.output||e,includeEnv:n.includeEnv===true||a("--include-env")});if(n.json){console.log(JSON.stringify(m,null,2));return}let p=(m.bytesWritten/(1024*1024)).toFixed(2);console.log(s.green(`\u2714 Workspace archive exported: ${m.archivePath}`)),console.log(s.gray(` Files: ${m.manifest.files.length}`)),console.log(s.gray(` Size: ${p} MB`)),m.manifest.security.envFilesIncluded||console.log(s.gray(" Secrets: excluded (.env, private keys, logs, dependency caches)"));}else if(t==="archive"&&(e==="inspect"||e==="verify"||e==="doctor")){let l=o;l||(console.log(s.red(`\u274C workspace archive ${e} requires an archive path or URL.`)),console.log(s.white(` npx rapidkit workspace archive ${e} team.rapidkit-archive.zip`)),process.exit(1));let{doctorWorkspaceArchive:f,inspectWorkspaceArchive:m,verifyWorkspaceArchive:p}=await import('./workspace-archive-EJIGYKSR.js');try{if(e==="inspect"){let u=await m({archivePathOrUrl:l});if(n.json){console.log(JSON.stringify(u,null,2));return}let g=(u.totalBytes/(1024*1024)).toFixed(2);console.log(s.green(`\u2714 Workspace archive: ${u.archivePath}`)),console.log(s.gray(` Workspace: ${u.manifest.workspaceName}`)),console.log(s.gray(` Exported: ${u.manifest.exportedAt}`)),console.log(s.gray(` Exporter: ${u.manifest.exportedBy||"unknown"}`)),console.log(s.gray(` Files: ${u.fileCount}`)),console.log(s.gray(` Payload: ${g} MB`));return}if(e==="doctor"){let u=await f({archivePathOrUrl:l,strict:n.strict===true||a("--strict")});if(n.json)console.log(JSON.stringify(u,null,2));else {let g=u.status==="passed"?s.green:u.status==="warning"?s.yellow:s.red;console.log(g(`\u2714 Workspace archive doctor ${u.status}: ${u.archivePath}`)),console.log(s.gray(` Workspace: ${u.workspaceName}`)),console.log(s.gray(` Files: ${u.fileCount}`));for(let w of u.checks){let y=w.status==="passed"?"\u2714":w.status==="warning"?"\u26A0":"\u2718";console.log(s.gray(` ${y} ${w.id}: ${w.message}`));}for(let w of u.recommendedActions)console.log(s.gray(` Next: ${w}`));}(u.status==="failed"||u.status==="warning"&&n.strict)&&process.exit(1);return}let d=await p({archivePathOrUrl:l,requireChecksums:n.strict===true||a("--strict")});if(n.json)console.log(JSON.stringify(d,null,2));else if(d.status==="passed")console.log(s.green(`\u2714 Workspace archive verified: ${d.archivePath}`)),console.log(s.gray(` Files: ${d.verifiedFiles}/${d.fileCount}`));else {let u=d.status==="failed"?s.red:s.yellow;console.log(u(`\u274C Workspace archive verification ${d.status}: ${d.archivePath}`)),d.missingArchiveEntries.length&&console.log(s.gray(` Missing entries: ${d.missingArchiveEntries.join(", ")}`)),d.extraArchiveEntries.length&&console.log(s.gray(` Unexpected entries: ${d.extraArchiveEntries.join(", ")}`)),d.mismatches.length&&console.log(s.gray(` Mismatches: ${d.mismatches.map(g=>g.path).join(", ")}`)),d.missingChecksumFiles.length&&console.log(s.gray(` Missing checksums: ${d.missingChecksumFiles.join(", ")}`));}(d.status==="failed"||d.status==="warning"&&n.strict)&&process.exit(1);}catch(d){console.log(s.red(`\u274C Workspace archive ${e} failed: ${d.message}`)),process.exit(1);}}else if(t==="hydrate"||t==="import"){let l=e;l||(console.log(s.red(`\u274C workspace ${t} requires an archive path or URL.`)),console.log(s.white(` npx rapidkit workspace ${t} team.rapidkit-archive.zip --output ./team`)),process.exit(1));let{hydrateWorkspaceArchive:f}=await import('./workspace-archive-EJIGYKSR.js');try{let m=await f({archivePathOrUrl:l,outputPath:n.output,force:n.force===true||a("--force"),dryRun:n.dryRun===true||a("--dry-run"),strict:n.strict===true||a("--strict")});if(n.json){console.log(JSON.stringify(m,null,2));return}console.log(s.green(m.dryRun?`\u2714 Workspace archive hydrate preview: ${m.outputPath}`:`\u2714 Workspace archive hydrated: ${m.outputPath}`)),console.log(s.gray(` Files: ${m.files.length}`)),m.manifest?.workspaceName&&console.log(s.gray(` Workspace: ${m.manifest.workspaceName}`));}catch(m){console.log(s.red(`\u274C Workspace ${t} failed: ${m.message}`)),process.exit(1);}}else if(t==="run"){let l=i(`run ${e||""}`.trim());(!e||!["init","test","build","start"].includes(e))&&(console.log(s.red(`Unknown workspace run stage: ${e||"(none provided)"}`)),console.log(s.gray("Available stages: init | test | build | start")),console.log(s.gray(" \u2022 init \u2014 run install/bootstrap across the project fleet")),console.log(s.gray(" \u2022 test \u2014 run test suite across selected projects")),console.log(s.gray(" \u2022 build \u2014 compile/package across selected projects")),console.log(s.gray(" \u2022 start \u2014 start services (smoke/e2e scenarios)")),console.log(s.gray(" Note: dev is excluded \u2014 it is a local-only primitive, not a CI stage")),process.exit(2));let f=Number(n.maxWorkers??""),m=Number.isFinite(f)?Math.max(1,Math.trunc(f)):void 0;if(e==="init"){let u=await Dr(l);u!==0&&process.exit(u);}let{runWorkspaceStage:p}=await import('./workspace-run-PNMZJNDC.js'),d=await p({workspacePath:l,stage:e,scope:n.scope,affected:n.affected===true,blastRadius:n.blastRadius===true,since:n.since,parallel:n.parallel===true,maxWorkers:m,continueOnError:n.continueOnError===true,strict:n.strict===true,json:n.json===true,enforceGates:n.gates});n.json&&console.log(JSON.stringify(d,null,2)),d.summary.exitCode!==0&&process.exit(d.summary.exitCode);}else if(t==="init"){console.log(s.yellow("\u2139 workspace init is an alias of: npx rapidkit workspace run init")),console.log(s.gray(` Equivalent full-init aliases at workspace root:
|
|
297
297
|
npx rapidkit init | npx rapidkit workspace init | npx rapidkit workspace run init
|
|
298
|
-
`));let l=i("init"),f=Number(n.maxWorkers??""),m=Number.isFinite(f)?Math.max(1,Math.trunc(f)):void 0,p=await Dr(l);p!==0&&process.exit(p);let{runWorkspaceStage:d}=await import('./workspace-run-
|
|
298
|
+
`));let l=i("init"),f=Number(n.maxWorkers??""),m=Number.isFinite(f)?Math.max(1,Math.trunc(f)):void 0,p=await Dr(l);p!==0&&process.exit(p);let{runWorkspaceStage:d}=await import('./workspace-run-PNMZJNDC.js'),u=await d({workspacePath:l,stage:"init",scope:n.scope,affected:n.affected===true,blastRadius:n.blastRadius===true,since:n.since,parallel:n.parallel===true,maxWorkers:m,continueOnError:n.continueOnError===true,strict:n.strict===true,json:n.json===true,enforceGates:n.gates});n.json&&console.log(JSON.stringify(u,null,2)),u.summary.exitCode!==0&&process.exit(u.summary.exitCode);}else console.log(s.red(`Unknown workspace action: ${t}`)),console.log(s.gray("Available: list, model, context, snapshot, diff, impact, sync, policy, share, export, hydrate, import, run")),process.exit(1);});function bi(){let t=a()?"npx rapidkit init; npx rapidkit dev":"npx rapidkit init && npx rapidkit dev";console.log(s.white(`Usage:
|
|
299
299
|
`)),console.log(s.cyan(` npx rapidkit <workspace-name> [options]
|
|
300
300
|
`)),console.log(s.bold("Quick start \u2014 workspace workflow:")),console.log(s.cyan(" npx rapidkit my-workspace ")+s.gray("# Create workspace (interactive profile picker)")),console.log(s.cyan(` cd ${h.join(y(),"my-workspace")}`)+s.gray(" # default managed location")),console.log(s.cyan(" npx rapidkit my-workspace --here ")+s.gray("# Create in current directory, then cd my-workspace")),console.log(s.cyan(" npx rapidkit bootstrap ")+s.gray("# Bootstrap all runtime toolchains")),console.log(s.cyan(" npx rapidkit create project ")+s.gray("# Interactive kit picker")),console.log(s.cyan(" npx rapidkit create frontend nextjs web ")+s.gray("# Create a frontend with the official generator")),console.log(s.cyan(" cd my-api")),console.log(s.cyan(` ${t}
|
|
301
301
|
`)),console.log(s.bold("Workspace profiles (asked during creation):")),console.log(s.gray(" minimal Foundation files only \u2014 fastest bootstrap (default)")),console.log(s.gray(" java-only Java runtime (Spring Boot services)")),console.log(s.gray(" python-only Python + Poetry (FastAPI, Django, ML)")),console.log(s.gray(" node-only Node.js runtime (NestJS, Express, Next.js)")),console.log(s.gray(" go-only Go runtime (Fiber, Gin, gRPC)")),console.log(s.gray(" dotnet-only .NET runtime (ASP.NET Core services)")),console.log(s.gray(" polyglot Python + Node.js + Go + Java + .NET multi-runtime")),console.log(s.gray(` enterprise Polyglot + governance + Sigstore
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {c}from'./chunk-
|
|
1
|
+
import {c}from'./chunk-7RBZGQ7T.js';import {b}from'./chunk-JBDQADHY.js';import {b as b$1}from'./chunk-RUUDLAKJ.js';import {a as a$1}from'./chunk-T5LN7EO5.js';import {a as a$2}from'./chunk-6P5DCHBQ.js';import {a}from'./chunk-KMUWWZRT.js';import {e,d}from'./chunk-B2KOIORF.js';import c$1 from'chalk';import D from'fs-extra';import u from'path';function C(t){return t===0?"pass":t===2?"warn":"fail"}function M(t){return t.some(s=>s.status==="fail")?"blocked":t.some(s=>s.status==="warn")?"needs-attention":"ready"}function F(t,s){if(s)return 3;let a=t.some(i=>i.status==="fail"),r=t.some(i=>i.status==="warn");return a?1:r?2:0}async function j(t){let s=await b$1(t,true),a=false;try{let{syncWorkspaceContract:r}=await import('./workspace-contract-D5O4OZD5.js');await r({workspacePath:t}),a=true;}catch{a=false;}return {sync:s,contractSynced:a}}async function G(t={}){let s=u.resolve(t.workspacePath??process.cwd()),a$3=a(s);if(!a$3)throw new Error("No RapidKit workspace found in current directory or parents");let r=[],i=[],l=false,p,y,m,f=Date.now();try{let{sync:e,contractSynced:n}=await j(a$3),o=e.workspaceFound&&(e.added.length>0||e.skipped>=0)||e.workspaceFound?"pass":"warn";r.push({name:"sync",status:o,durationMs:Date.now()-f,summary:e.workspaceFound?`registry sync complete (${e.added.length} added, ${e.skipped} existing)${n?", contract synced":""}`:"workspace not registered in global registry; contract sync attempted"}),e.workspaceFound||i.push("workspace registry entry missing \u2014 run rapidkit create workspace or register manually");}catch(e){l=true,r.push({name:"sync",status:"fail",durationMs:Date.now()-f,summary:`sync failed: ${e instanceof Error?e.message:String(e)}`}),i.push("workspace sync stage failed");}let w=Date.now();try{let e=await b({workspace:true,json:true,quiet:true,strict:t.strict===true,ci:t.strict!==true}),n=C(e),o=u.join(a$3,".rapidkit","reports","doctor-last-run.json");r.push({name:"doctor",status:n,durationMs:Date.now()-w,summary:n==="pass"?"doctor workspace passed":n==="warn"?"doctor workspace reported warnings":"doctor workspace reported errors",exitCode:e,evidencePath:o}),n==="fail"?i.push("doctor workspace gate failed"):n==="warn"&&i.push("doctor workspace reported warnings");}catch(e){l=true,r.push({name:"doctor",status:"fail",durationMs:Date.now()-w,summary:`doctor failed: ${e instanceof Error?e.message:String(e)}`}),i.push("doctor workspace stage failed");}if(t.skipAnalyze)r.push({name:"analyze",status:"skipped",durationMs:0,summary:"analyze stage skipped"});else {let e=Date.now();try{let n=await a$1({workspacePath:a$3,json:true,strict:t.strict===true});p=u.join(a$3,".rapidkit","reports","analyze-last-run.json");let o=n.summary.verdict==="blocked"?"fail":n.summary.verdict==="needs-attention"?"warn":"pass";r.push({name:"analyze",status:o,durationMs:Date.now()-e,summary:`analyze verdict: ${n.summary.verdict} (score ${n.summary.score}/100)`,evidencePath:p}),o==="fail"?i.push("analyze reported blocked verdict"):o==="warn"&&i.push("analyze reported needs-attention verdict");}catch(n){l=true,r.push({name:"analyze",status:"fail",durationMs:Date.now()-e,summary:`analyze failed: ${n instanceof Error?n.message:String(n)}`}),i.push("analyze stage failed");}}let h=Date.now();try{let e=await a$2({startPath:a$3,writeReport:true,skipVerify:t.skipVerify===true});y=e.evidencePath;let n=e.overallStatus==="pass"?"pass":e.overallStatus==="warn"?"warn":"fail";r.push({name:"readiness",status:n,durationMs:Date.now()-h,summary:`readiness overall: ${e.overallStatus}`,evidencePath:e.evidencePath}),n==="fail"?i.push(...e.blockingReasons.map(o=>`readiness: ${o}`)):n==="warn"&&i.push(...e.gates.filter(o=>o.status==="warn").map(o=>`readiness warn: ${o.gate}: ${o.summary}`));}catch(e){l=true,r.push({name:"readiness",status:"fail",durationMs:Date.now()-h,summary:`readiness failed: ${e instanceof Error?e.message:String(e)}`}),i.push("readiness stage failed");}if(t.skipAutopilot)r.push({name:"autopilot",status:"skipped",durationMs:0,summary:"autopilot stage skipped"});else {let e=Date.now(),n=t.autopilotMode??"audit";try{let o=await c({workspacePath:a$3,mode:n,json:true,skipPipelineStages:true});m=o.artifacts.reportPath;let P=o.summary.verdict==="approved"?"pass":o.summary.verdict==="partial"?"warn":"fail";r.push({name:"autopilot",status:P,durationMs:Date.now()-e,summary:`autopilot ${n}: ${o.summary.verdict}`,exitCode:o.summary.exitCode,evidencePath:m}),P!=="pass"&&i.push(...o.blockingReasons.slice(0,5));}catch(o){l=true,r.push({name:"autopilot",status:"fail",durationMs:Date.now()-e,summary:`autopilot failed: ${o instanceof Error?o.message:String(o)}`}),i.push("autopilot release stage failed");}}let z=M(r),k=F(r,l),g=u.join(a$3,".rapidkit","reports","pipeline-last-run.json"),d$1={schemaVersion:"rapidkit-pipeline-v1",generatedAt:new Date().toISOString(),workspacePath:a$3,summary:{verdict:z,exitCode:k,stagesPassed:r.filter(e=>e.status==="pass").length,stagesWarn:r.filter(e=>e.status==="warn").length,stagesFailed:r.filter(e=>e.status==="fail").length},stages:r,blockingReasons:[...new Set(i)],artifacts:{reportPath:g,analyzeEvidencePath:p,readinessEvidencePath:y,autopilotEvidencePath:m}};if(t.writeReport!==false){await D.ensureDir(u.dirname(g));let e$1=e(d$1,{commandId:"workspacePipeline",exitCode:k,generatedAt:d$1.generatedAt,blockers:d$1.blockingReasons,runId:d()});await D.writeJSON(g,e$1,{spaces:2});}if(t.writeReport!==false&&t.noAgentSync!==true&&process.env.RAPIDKIT_NO_AGENT_SYNC!=="1"&&t.agentSync!==false)try{let{syncWorkspaceAgentGrounding:e}=await import('./workspace-agent-sync-4R7S3F6T.js'),n=await e({workspacePath:a$3,write:true,refreshContext:true,strict:false});d$1.agentGrounding={indexPath:n.indexPath,writtenFiles:n.writtenFiles,blockers:n.blockers};}catch{}return d$1}async function X(t){let s;try{s=await G(t);}catch(a){let r=a instanceof Error?a.message:String(a);t.json?console.log(JSON.stringify({schemaVersion:"rapidkit-pipeline-error-v1",ok:false,error:{message:r}},null,2)):console.log(c$1.red(`Pipeline failed: ${r}`)),process.exit(1);}if(t.json)console.log(JSON.stringify(s,null,2));else {console.log(c$1.bold.cyan(`
|
|
2
2
|
\u{1F517} RapidKit Governance Pipeline
|
|
3
3
|
`)),console.log(c$1.bold(`Workspace: ${c$1.cyan(u.basename(s.workspacePath))}`)),console.log(c$1.gray(`Path: ${s.workspacePath}`)),console.log(c$1.white(`Verdict: ${s.summary.verdict} Exit: ${s.summary.exitCode} (${s.summary.stagesPassed} pass / ${s.summary.stagesWarn} warn / ${s.summary.stagesFailed} fail)`));for(let a of s.stages){let r=a.status==="pass"?c$1.green("PASS"):a.status==="warn"?c$1.yellow("WARN"):a.status==="skipped"?c$1.gray("SKIP"):c$1.red("FAIL");console.log(` - ${a.name}: ${r} ${a.summary}`);}if(s.blockingReasons.length>0){console.log(c$1.bold(`
|
|
4
4
|
Blocking reasons:`));for(let a of s.blockingReasons.slice(0,8))console.log(c$1.gray(` \u2022 ${a}`));}console.log(c$1.gray(`
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {b,c,d}from'./chunk-
|
|
1
|
+
import {b,c,d}from'./chunk-3SWQKRXH.js';import i from'path';import c$1 from'fs-extra';var O="rapidkit-agent-reports-index.v1",E=".rapidkit/reports/INDEX.json",G=".rapidkit/AGENT-GROUNDING.md",S=[{relativePath:b,label:"Agent context pack",required:true},{relativePath:".rapidkit/reports/workspace-model.json",label:"Workspace model graph",required:false},{relativePath:".rapidkit/reports/doctor-last-run.json",label:"Workspace doctor",required:false},{relativePath:".rapidkit/reports/analyze-last-run.json",label:"Workspace analyze",required:false},{relativePath:".rapidkit/reports/pipeline-last-run.json",label:"Governance pipeline",required:false},{relativePath:".rapidkit/reports/release-readiness-last-run.json",label:"Release readiness",required:false},{relativePath:".rapidkit/reports/workspace-impact-last-run.json",label:"Workspace impact",required:false},{relativePath:".rapidkit/reports/workspace-verify-last-run.json",label:"Workspace verify",required:false}];function k(e){return `npx rapidkit ${e}`.trim()}function I(e){return e&&typeof e=="object"?e:null}function j(e,t=12){return Array.isArray(e)?e.filter(r=>typeof r=="string"&&r.trim().length>0).slice(0,t):[]}function q(e){let t=j(e.blockers,12);if(t.length>0)return t;let r=j(e.blockingReasons,12);if(r.length>0)return r;let n=I(e.summary);return n&&Array.isArray(n.blockingReasons)?j(n.blockingReasons,12):[]}function _(e){for(let t of ["generatedAt","timestamp"]){let r=e[t];if(typeof r=="string"&&r.trim())return r.trim()}}function $(e,t,r){if(!e)return true;let n=Date.parse(e);return Number.isFinite(n)?r.getTime()-n>t*60*60*1e3:true}function K(e){let t=e&&e.length>0?e:["all"];return t.includes("all")?new Set(["all","agents","copilot","cursor","claude","codex","orca"]):new Set(t)}function u(e,t){return e.has("all")||e.has(t)}async function X(e){try{if(!await c$1.pathExists(e))return null;let t=await c$1.readJson(e);return I(t)}catch{return null}}async function F(e){let t=e.now??new Date,r=e.staleAfterHours??24,n=[],d=[];for(let l of S){let h=i.join(e.workspacePath,l.relativePath),a=await X(h),p=a!==null;p&&a&&d.push(...q(a)),n.push({path:l.relativePath,label:l.label,required:l.required,exists:p,generatedAt:a?_(a):void 0,commandId:typeof a?.commandId=="string"?a.commandId:void 0,exitCode:typeof a?.exitCode=="number"?a.exitCode:void 0});}let s=[...new Set(d.map(l=>l.trim()).filter(Boolean))].slice(0,16);return {schemaVersion:O,generatedAt:t.toISOString(),workspaceRoot:e.workspacePath,readOrder:S.map(l=>l.relativePath),blockers:s,staleAfterHours:r,reports:n,refreshCommand:k("workspace agent-sync --write --refresh-context")}}function N(e){let t=["# RapidKit agent grounding","","Cross-tool instructions for Copilot, Cursor, Claude Code, Codex, Grok, and other agents.","","## Read order (mandatory before workspace diagnosis)","","1. `.rapidkit/reports/INDEX.json` \u2014 latest blockers, timestamps, and report paths","2. `.rapidkit/reports/workspace-context-agent.json` \u2014 canonical agent context pack","3. Evidence artifacts listed in the index (doctor, analyze, pipeline, readiness, impact, verify)","","Do **not** full-repo scan until these reports are read or regenerated.","","## Regenerate intelligence","","```bash",k("workspace agent-sync --write --refresh-context"),k("workspace context --for-agent --json --write"),k("pipeline --json --write"),"```",""];if(e.index.blockers.length>0){t.push("## Current blockers","");for(let r of e.index.blockers.slice(0,12))t.push(`- ${r}`);t.push("");}if(e.context?.safeCommands?.length){t.push("## Safe commands (prefer these)","");for(let r of e.context.safeCommands.slice(0,10))t.push(`- \`${r.display}\` \u2014 ${r.description}`);t.push("");}return t.push("## Rules","","- Treat `.rapidkit/reports/*` as the source of truth for health, gates, and release posture.","- Prefer deterministic RapidKit CLI commands over heuristic framework guesses.","- If evidence is missing or stale, run the refresh commands above before proposing fixes.","- Keep project-scoped advice aligned with the active project named in the context pack.",""),t.join(`
|
|
2
2
|
`)}function B(e){return ["# RapidKit agent grounding","",`Generated: ${e.generatedAt}`,"","This file is tool-agnostic. Synced agents should read it together with `.rapidkit/reports/INDEX.json`.","","## Mandatory read order","",...e.readOrder.map((t,r)=>`${r+1}. \`${t}\``),"",e.blockers.length>0?"## Blockers":"",...e.blockers.length>0?e.blockers.map(t=>`- ${t}`):[],"","## Refresh","","```bash",e.refreshCommand,"```",""].filter(t=>t!=="").join(`
|
|
3
3
|
`)}function H(){return ["# RapidKit workspace grounding","","Before answering workspace, release, or architecture questions:","","1. Read `AGENTS.md` (managed RapidKit section).","2. Read `.rapidkit/reports/INDEX.json` and `.rapidkit/reports/workspace-context-agent.json`.","3. Use evidence reports before scanning the full repository.","","Regenerate stale intelligence:","","```bash",k("workspace agent-sync --write --refresh-context"),"```",""].join(`
|
|
4
4
|
`)}function L(){return ["## Claude Code","","- Load `.rapidkit/reports/INDEX.json` before diagnosing blockers.","- Use `.claude/rules/rapidkit-evidence.md` when editing files under `.rapidkit/`.","- Refresh grounding with `npx rapidkit workspace agent-sync --write`.",""].join(`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export{b as WORKSPACE_CONTEXT_AGENT_REPORT_PATH,a as WORKSPACE_CONTEXT_SCHEMA_VERSION,c as buildWorkspaceAgentContext,d as writeWorkspaceAgentContext}from'./chunk-
|
|
1
|
+
export{b as WORKSPACE_CONTEXT_AGENT_REPORT_PATH,a as WORKSPACE_CONTEXT_SCHEMA_VERSION,c as buildWorkspaceAgentContext,d as writeWorkspaceAgentContext}from'./chunk-3SWQKRXH.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{a as runWorkspaceStage}from'./chunk-TRXYRHD7.js';export{a as WORKSPACE_RUN_LAST_REPORT_FILENAME}from'./chunk-FV5A3N3I.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import {m,f as f$1,c,n,e}from'./chunk-U6QUN6V2.js';import {d}from'./chunk-C7OVQQXT.js';import {c as c$1}from'./chunk-FV5A3N3I.js';import p from'path';import g from'fs-extra';var R="workspace-verify.v1",S=".rapidkit/reports/workspace-verify-last-run.json";function C(e,s){return p.isAbsolute(s)?s:p.join(e,s)}async function P(e$1){let s=await g.readJson(e$1);if(!s||typeof s!="object"||Array.isArray(s))throw new Error(`Workspace impact input is not a JSON object: ${e$1}`);let r=s;if(r.schemaVersion!==e)throw new Error(`Unsupported workspace impact schema: ${String(r.schemaVersion)}`);return r}function I(e){let s=new Set,r=[];for(let a of e){let i=`${a.scope}:${a.project??""}:${a.display}`;s.has(i)||(s.add(i),r.push(a));}return r}function V(e,s){if(!e||e==="workspace")return true;let r=(e.startsWith("project:")?e.slice(8):e).trim().toLowerCase();return s.scope==="workspace"?true:(s.project??"").trim().toLowerCase()===r}function A(e,s){if(e.id==="workspace.doctor")return p.join(s,".rapidkit","reports","doctor-last-run.json");if(e.id==="workspace.contract.verify")return p.join(s,".rapidkit","reports","workspace-contract-verify-last-run.json");if(e.id==="workspace.readiness")return p.join(s,".rapidkit","reports","release-readiness-last-run.json");if(e.id==="workspace.analyze")return p.join(s,".rapidkit","reports","analyze-last-run.json");if(e.id==="workspace.pipeline")return p.join(s,".rapidkit","reports","pipeline-last-run.json");if(e.id.startsWith("project.")&&(e.id.endsWith(".test")||e.id.endsWith(".build")))return p.join(s,".rapidkit","reports","workspace-run-last.json")}function k(e){return !e||typeof e!="object"||Array.isArray(e)?null:e}function $(e){let s=k(e.healthScore),r=typeof s?.errors=="number"?s.errors:0,a=typeof s?.percent=="number"?s.percent:void 0;return r>0?{status:"fail",message:`Doctor evidence reports ${r} error(s).`}:typeof a=="number"&&a<70?{status:"warn",message:`Doctor health score is ${a}%.`}:{status:"pass",message:"Doctor evidence is present and healthy."}}function M(e){let s=typeof e.overallStatus=="string"?e.overallStatus:"unknown";return s==="fail"?{status:"fail",message:"Release readiness evidence reports blocking failures."}:s==="warn"?{status:"warn",message:"Release readiness evidence reports warnings."}:s==="pass"?{status:"pass",message:"Release readiness evidence passed."}:{status:"warn",message:`Release readiness evidence status is ${s}.`}}function O(e){let s=typeof e.status=="string"?e.status:"unknown";return s==="failed"||s==="fail"?{status:"fail",message:"Workspace contract verify evidence failed."}:s==="passed"||s==="pass"?{status:"pass",message:"Workspace contract verify evidence passed."}:{status:"warn",message:`Workspace contract verify evidence status is ${s}.`}}function x(e){let s=k(e.summary);if(s?.blocking===true||e.blocking===true)return {status:"fail",message:"Analyze evidence reports blocking findings."};let a=typeof s?.status=="string"?s.status:void 0;return a==="warn"||a==="warning"?{status:"warn",message:"Analyze evidence reports warnings."}:{status:"pass",message:"Analyze evidence is present."}}function _(e){let s=k(e.summary),r=typeof s?.verdict=="string"?s.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 D(e,s,r){let a=s.id.endsWith(".build")?"build":s.id.endsWith(".test")?"test":null,i=c$1(e,a);if(!i)return {status:"missing",message:"Workspace run evidence is missing or unreadable."};let u=i.stage;if(a&&u!==a)return {status:"missing",message:`Workspace run evidence is for stage "${u}", expected "${a}".`};let c=Array.isArray(i.projects)?i.projects:[],o=s.project?.toLowerCase();if(!o)return {status:"missing",message:"Project-scoped workspace run evidence is missing a project identifier."};let n=c.find(d=>{let t=k(d);if(!t)return false;let m=typeof t.projectName=="string"?t.projectName.toLowerCase():"",E=["projectPath","relativePath","path"].map(l=>t[l]).filter(l=>typeof l=="string"&&l.trim().length>0).map(l=>l.replace(/\\/g,"/").toLowerCase());return m===o||E.some(l=>l.endsWith(`/${o}`)||l===o)});if(n){let d=f(i.generatedAt,r,`Workspace run evidence for ${s.project??s.id}`);if(d)return {status:"fail",message:d};let t=k(n),m=typeof t?.status=="string"?t.status:"unknown";return m==="failed"?{status:"fail",message:`Workspace run evidence failed for ${s.project}.`}:m==="passed"?{status:"pass",message:`Workspace run evidence passed for ${s.project}.`}:m==="skipped"?{status:"warn",message:`Workspace run evidence skipped for ${s.project}.`}:{status:"warn",message:`Workspace run evidence status is ${m} for ${s.project}.`}}return {status:"missing",message:`Workspace run evidence does not include project ${s.project}.`}}function f(e,s,r){if(typeof e!="string"||!s)return null;let a=Date.parse(e),i=Date.parse(s);return !Number.isFinite(a)||!Number.isFinite(i)?null:a<i?`${r} is stale: generated at ${e}, before impact ${s}.`:null}async function F(e,s,r,a){let i=A(e,s),u=i?p.relative(s,i).split(p.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."};if(!i||!await g.pathExists(i))return {id:e.id,label:e.label,scope:e.scope,project:e.project,command:e,status:"missing",required:e.required,evidencePath:u,message:u?`Missing evidence report: ${u}`:"No evidence mapping exists for this command."};let c=k(await g.readJson(i));if(!c)return {id:e.id,label:e.label,scope:e.scope,project:e.project,command:e,status:"fail",required:e.required,evidencePath:u,message:"Evidence report is not a JSON object."};let o;if(e.id==="workspace.doctor"){let n=f(c.generatedAt,a,"Doctor evidence");n?o={status:"fail",message:n}:o=$(c);}else if(e.id==="workspace.readiness"){let n=f(c.generatedAt,a,"Release readiness evidence");n?o={status:"fail",message:n}:o=M(c);}else if(e.id==="workspace.contract.verify"){let n=f(c.generatedAt,a,"Workspace contract verify evidence");n?o={status:"fail",message:n}:o=O(c);}else if(e.id==="workspace.analyze"){let n=f(c.generatedAt,a,"Analyze evidence");n?o={status:"fail",message:n}:o=x(c);}else if(e.id==="workspace.pipeline"){let n=f(c.generatedAt,a,"Pipeline evidence");n?o={status:"fail",message:n}:o=_(c);}else if(e.id.startsWith("project."))o=D(c,e,a);else {let n=f(c.generatedAt,a,"Evidence report");n?o={status:"fail",message:n}: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:u,message:o.message}}function q(e){let s=e.filter(t=>t.status==="pass").length,r=e.filter(t=>t.status==="warn").length,a=e.filter(t=>t.status==="fail").length,i=e.filter(t=>t.status==="missing").length,u=e.filter(t=>t.status==="skipped").length,c=e.filter(t=>t.required&&(t.status==="fail"||t.status==="missing")).map(t=>`${t.id}: ${t.message}`),o=e.filter(t=>t.required&&t.status==="missing").length,n="ready",d=0;return c.length>0?(n="blocked",d=2):(r>0||o>0)&&(n="needs-attention",d=1),{verdict:n,exitCode:d,stepsPassed:s,stepsWarn:r,stepsFailed:a,stepsMissing:i,stepsSkipped:u}}async function N(e$1){let s=p.resolve(e$1.workspacePath);if(e$1.fromImpactPath){let u=C(s,e$1.fromImpactPath);return {impact:await P(u),fromImpactRef:p.relative(s,u).split(p.sep).join("/")}}let r=p.join(s,f$1);if(await g.pathExists(r))return {impact:await P(r),fromImpactRef:f$1};let a=p.join(s,c);if(await g.pathExists(a))return {impact:await n({workspacePath:s,fromPath:c,scope:e$1.scope,includeAbsolutePaths:e$1.includeAbsolutePaths,includeEvidence:e$1.includeEvidence,observableScanDepth:e$1.observableScanDepth,now:e$1.now}),fromImpactRef:c};let i=await d({workspacePath:s,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:i.workspace.name,profile:i.workspace.profile,type:i.workspace.type},summary:{changed:false,risk:"none",affectedProjects:0,workspaceItems:0,recommendedCommands:0},affectedProjects:[],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:i}}}}async function Y(e){let s=p.resolve(e.workspacePath),{impact:r,fromImpactRef:a}=await N(e),i=r.diff.currentModel,u=I([...m(),...r.verificationPlan]).filter(t=>V(e.scope,t)),c=[];for(let t of u)c.push(await F(t,s,i.contracts.exists===true,r.generatedAt));let o=q(c),n=c.filter(t=>t.status==="missing"&&t.evidencePath).map(t=>t.evidencePath),d=c.filter(t=>t.required&&(t.status==="fail"||t.status==="missing")).map(t=>`${t.id}: ${t.message}`);return {schemaVersion:R,generatedAt:(e.now??new Date).toISOString(),workspacePath:s,mode:"evidence",fromImpactRef:a,scope:e.scope,impact:{changed:r.summary.changed,risk:r.summary.risk,affectedProjects:r.summary.affectedProjects,recommendedCommands:r.summary.recommendedCommands},summary:o,steps:c,missingEvidence:n,blockingReasons:d,verificationPlan:u}}async function U(e,s){let r=p.join(s,S);return await g.ensureDir(p.dirname(r)),await g.writeJson(r,e,{spaces:2}),r}function Q(e,s){return e.summary.verdict==="blocked"?2:s?.strict&&e.summary.verdict!=="ready"?1:e.summary.exitCode}export{S as WORKSPACE_VERIFY_REPORT_PATH,R as WORKSPACE_VERIFY_SCHEMA_VERSION,Y as buildWorkspaceVerify,Q as workspaceVerifyExitCode,U as writeWorkspaceVerify};
|