rapidkit 0.39.0 → 0.40.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -148,6 +148,7 @@ For the visual experience, install the [Workspai VS Code extension](https://mark
148
148
  - [Typical workflows](#typical-workflows)
149
149
  - [Mental model](#mental-model)
150
150
  - [Workspace Intelligence Commands](#workspace-intelligence-commands)
151
+ - [Agent Customization Pack](#agent-customization-pack)
151
152
  - [Requirements](#requirements)
152
153
  - [Install](#install)
153
154
  - [Project workflows](#project-workflows)
@@ -182,7 +183,8 @@ npx rapidkit workspace model --json
182
183
 
183
184
  ```bash
184
185
  npx rapidkit workspace context --for-agent --json --write
185
- npx rapidkit workspace agent-sync --write --refresh-context
186
+ npx rapidkit workspace agent-sync --write --refresh-context --preset enterprise
187
+ npx rapidkit workspace agent-sync --write --refresh-context --preset enterprise --experimental-hooks
186
188
  ```
187
189
 
188
190
  ### Release verification
@@ -237,17 +239,17 @@ Every tool gets the same answers: what projects exist, what stack they use, whic
237
239
 
238
240
  Workspace Intelligence provides a shared understanding of projects, dependencies, operational context, and release readiness for developers, CI pipelines, and AI agents.
239
241
 
240
- | Command | Purpose |
241
- | ------------------------------------------------- | ---------------------------------------------------------------- |
242
- | `workspace model [--cache\|--incremental] --json` | Canonical workspace model (graph-aware, incremental rebuilds) |
243
- | `workspace context --for-agent --json --write` | Agent-ready context pack + auto agent grounding sync |
244
- | `workspace agent-sync --write` | Cross-tool grounding (AGENTS.md, Copilot, Cursor, Claude, INDEX) |
245
- | `workspace snapshot --json` | Persist model snapshot |
246
- | `workspace diff --from <file\|git[:ref]> --json` | Diff against snapshot or git |
247
- | `workspace impact --from <file> --json` | Graph-aware transitive blast-radius evidence |
248
- | `workspace verify [--strict] --json` | Definitive verification gate (subgraph + freshness + policy) |
249
- | `workspace graph <emit\|explain\|dot\|mermaid>` | Inspect and visualize the dependency graph |
250
- | `workspace watch [--json] [--once]` | Daemon mode: keep model + graph in memory, stream change events |
242
+ | Command | Purpose |
243
+ | ------------------------------------------------- | ------------------------------------------------------------------------------------ |
244
+ | `workspace model [--cache\|--incremental] --json` | Canonical workspace model (graph-aware, incremental rebuilds) |
245
+ | `workspace context --for-agent --json --write` | Agent-ready context pack + auto agent grounding sync |
246
+ | `workspace agent-sync --write` | Agent Customization Pack (AGENTS.md, Copilot, Cursor, Claude, INDEX, skills, agents) |
247
+ | `workspace snapshot --json` | Persist model snapshot |
248
+ | `workspace diff --from <file\|git[:ref]> --json` | Diff against snapshot or git |
249
+ | `workspace impact --from <file> --json` | Graph-aware transitive blast-radius evidence |
250
+ | `workspace verify [--strict] --json` | Definitive verification gate (subgraph + freshness + policy) |
251
+ | `workspace graph <emit\|explain\|dot\|mermaid>` | Inspect and visualize the dependency graph |
252
+ | `workspace watch [--json] [--once]` | Daemon mode: keep model + graph in memory, stream change events |
251
253
 
252
254
  JSON schemas: `contracts/workspace-intelligence/`. Details: [commands-reference.md](docs/commands-reference.md).
253
255
 
@@ -276,40 +278,76 @@ radius, gating, and visualization:
276
278
  deterministic `workspace-watch-event.v1` change events (changed projects, graph edge
277
279
  deltas, structural hash) via fast incremental rebuilds.
278
280
 
279
- ### Agent grounding (CLI-only, no extension required)
281
+ ### Agent Customization Pack
282
+
283
+ RapidKit can generate a versioned **Agent Customization Pack** so AI tools do
284
+ not start from an ungrounded repository scan. They start from the same workspace
285
+ truth developers and CI use: reports, commands, contracts, blockers, scope, and
286
+ verification evidence.
280
287
 
281
- RapidKit can sync **cross-tool instruction files** so Copilot, Cursor, Claude Code, Codex, Grok, and other agents read the same evidence before guessing:
288
+ This is CLI-only and does not require the Workspai extension:
282
289
 
283
290
  ```bash
284
- # Full sync: refresh context pack + INDEX + AGENTS.md + Copilot/Cursor/Claude hooks
285
- npx rapidkit workspace agent-sync --write --refresh-context
291
+ # Full enterprise pack:
292
+ # context pack + INDEX + AGENTS.md + Copilot/Cursor/Claude/Codex surfaces + MCP-ready design
293
+ npx rapidkit workspace agent-sync --write --refresh-context --preset enterprise
294
+
295
+ # Optional advisory VS Code agent hooks (disabled by default in the generated file)
296
+ npx rapidkit workspace agent-sync --write --refresh-context --preset enterprise --experimental-hooks
286
297
 
287
298
  # Context pack write also syncs grounding by default
288
299
  npx rapidkit workspace context --for-agent --json --write
289
300
 
290
301
  # CI strict gate (fail if required reports missing/stale)
291
302
  npx rapidkit workspace agent-sync --write --strict --json
303
+
304
+ # CI drift gate after sync
305
+ npm run check:agent-customization-drift -- --workspace <workspace-root>
292
306
  ```
293
307
 
294
- | Artifact / file | Purpose |
295
- | -------------------------------------------------------- | ------------------------------------------------------- |
296
- | `.rapidkit/reports/INDEX.json` | Read order, blockers, report timestamps |
297
- | `.rapidkit/reports/workspace-context-agent.json` | Canonical agent context pack |
298
- | `.rapidkit/AGENT-GROUNDING.md` | Tool-agnostic grounding doc |
299
- | `AGENTS.md` | Open standard for all agents (managed RapidKit section) |
300
- | `.github/copilot-instructions.md` | GitHub Copilot / VS Code Chat always-on rules |
301
- | `.github/instructions/rapidkit-evidence.instructions.md` | Copilot scoped rules for `.rapidkit/**` |
302
- | `.github/prompts/rapidkit-diagnose.prompt.md` | Copilot reusable diagnose prompt |
303
- | `.github/skills/rapidkit-grounding/SKILL.md` | Copilot agent skill workflow |
304
- | `.cursor/rules/rapidkit-grounding.mdc` | Cursor always-on project rule |
305
- | `CLAUDE.md` | Claude Code entry (`@AGENTS.md` + managed notes) |
306
- | `.claude/rules/rapidkit-evidence.md` | Claude Code scoped evidence rules |
307
-
308
- Agents cannot be **forced** probabilistically — but this stack maximizes the chance they read reports first, even when the user talks to Copilot directly without Workspai.
308
+ | Artifact / file | Purpose |
309
+ | ----------------------------------------------------------------------- | -------------------------------------------------------- |
310
+ | `.rapidkit/reports/agent-customization-pack.json` | Versioned output inventory, target matrix, drift state |
311
+ | `.rapidkit/reports/rapidkit-mcp-design.json` | Read-mostly MCP-ready tool design manifest |
312
+ | `.rapidkit/reports/INDEX.json` | Read order, blockers, report timestamps |
313
+ | `.rapidkit/reports/workspace-context-agent.json` | Canonical agent context pack |
314
+ | `.rapidkit/AGENT-GROUNDING.md` | Tool-agnostic grounding doc |
315
+ | `AGENTS.md` | Open standard for all agents (managed RapidKit section) |
316
+ | `.github/copilot-instructions.md` | GitHub Copilot / VS Code Chat always-on rules |
317
+ | `.github/instructions/rapidkit-workspace.instructions.md` | Copilot workspace scope and command discipline |
318
+ | `.github/instructions/rapidkit-evidence.instructions.md` | Copilot scoped rules for `.rapidkit/**` |
319
+ | `.github/prompts/rapidkit-diagnose.prompt.md` | Copilot reusable diagnose prompt |
320
+ | `.github/skills/rapidkit-workspace-intelligence/SKILL.md` | Workspace Intelligence skill workflow |
321
+ | `.github/skills/rapidkit-workspace-intelligence/resources/mcp-tools.md` | Future MCP tool design reference |
322
+ | `.github/agents/workspai-advisor.agent.md` | Read-only workspace advisor agent |
323
+ | `.github/agents/workspai-repair.agent.md` | Blocker repair agent |
324
+ | `.github/agents/workspai-release.agent.md` | Release safety agent |
325
+ | `.github/agents/workspai-project-onboarder.agent.md` | Project onboarding agent |
326
+ | `.cursor/rules/rapidkit-grounding.mdc` | Cursor always-on project rule |
327
+ | `CLAUDE.md` | Claude Code entry (`@AGENTS.md` + managed notes) |
328
+ | `.claude/rules/rapidkit-evidence.md` | Claude Code scoped evidence rules |
329
+ | `.vscode/rapidkit-agent-hooks.json` | Optional advisory VS Code hooks (`--experimental-hooks`) |
330
+
331
+ The pack also publishes a standard answer contract for agent-facing output:
332
+
333
+ ```text
334
+ Scope -> Evidence -> Diagnosis -> Fix Plan -> Run -> Verify -> Assumptions
335
+ ```
336
+
337
+ That contract is what keeps agent responses operational: every recommendation
338
+ should name the workspace/project scope, cite the evidence it used, explain the
339
+ diagnosis, propose the command or file action, and tell the user how to verify
340
+ the result.
341
+
342
+ Agents cannot be **forced** probabilistically. This stack makes the desired
343
+ behavior explicit, versioned, and easy for IDEs, CI, and Workspai to audit.
309
344
 
310
345
  Skip auto-sync after context write: `--no-agent-sync`. Target specific ecosystems: `--target copilot,cursor,claude`.
311
346
 
312
- After `pipeline`, grounding syncs automatically (refresh context + INDEX + hooks). Disable with `--no-agent-sync` or `RAPIDKIT_NO_AGENT_SYNC=1`.
347
+ After `pipeline`, grounding syncs automatically (refresh context + INDEX + agent surfaces). Disable with `--no-agent-sync` or `RAPIDKIT_NO_AGENT_SYNC=1`.
348
+
349
+ Contract: `contracts/agent-customization-pack.v1.json`. Artifact map:
350
+ [docs/contracts/ARTIFACT_CATALOG.md](docs/contracts/ARTIFACT_CATALOG.md).
313
351
 
314
352
  CI template: [docs/examples/ci-agent-grounding.yml](docs/examples/ci-agent-grounding.yml).
315
353
 
@@ -0,0 +1,159 @@
1
+ {
2
+ "schemaVersion": "rapidkit-agent-customization-pack.v1",
3
+ "presets": {
4
+ "minimal": {
5
+ "meaning": "Generate the portable grounding index, AGENTS.md, and provider-specific lightweight instructions.",
6
+ "requiredOutputs": [
7
+ ".rapidkit/reports/INDEX.json",
8
+ ".rapidkit/reports/agent-customization-pack.json",
9
+ "AGENTS.md"
10
+ ]
11
+ },
12
+ "enterprise": {
13
+ "meaning": "Generate the full VS Code-native pack: instructions, prompts, skills, custom agents, and validation metadata.",
14
+ "requiredOutputs": [
15
+ ".rapidkit/reports/INDEX.json",
16
+ ".rapidkit/reports/agent-customization-pack.json",
17
+ "AGENTS.md",
18
+ ".github/instructions/rapidkit-workspace.instructions.md",
19
+ ".github/prompts/rapidkit-diagnose.prompt.md",
20
+ ".github/skills/rapidkit-workspace-intelligence/SKILL.md",
21
+ ".github/agents/workspai-advisor.agent.md",
22
+ ".rapidkit/reports/rapidkit-mcp-design.json"
23
+ ]
24
+ }
25
+ },
26
+ "targets": {
27
+ "all": {
28
+ "meaning": "Generate every supported customization surface.",
29
+ "outputFamilies": [
30
+ "portable",
31
+ "vscode",
32
+ "copilot",
33
+ "cursor",
34
+ "claude"
35
+ ]
36
+ },
37
+ "vscode": {
38
+ "meaning": "Generate VS Code-native customizations for Copilot Chat and agent workflows.",
39
+ "outputFamilies": [
40
+ "instructions",
41
+ "prompts",
42
+ "skills",
43
+ "agents",
44
+ "hooks"
45
+ ]
46
+ },
47
+ "agents": {
48
+ "meaning": "Generate portable AGENTS.md grounding for any agent.",
49
+ "outputFamilies": [
50
+ "portable"
51
+ ]
52
+ },
53
+ "copilot": {
54
+ "meaning": "Generate GitHub Copilot instructions, prompts, and skills.",
55
+ "outputFamilies": [
56
+ "instructions",
57
+ "prompts",
58
+ "skills"
59
+ ]
60
+ },
61
+ "cursor": {
62
+ "meaning": "Generate Cursor rules.",
63
+ "outputFamilies": [
64
+ "rules"
65
+ ]
66
+ },
67
+ "claude": {
68
+ "meaning": "Generate Claude Code grounding files.",
69
+ "outputFamilies": [
70
+ "rules",
71
+ "portable"
72
+ ]
73
+ },
74
+ "codex": {
75
+ "meaning": "Use AGENTS.md and the report index as the Codex grounding layer.",
76
+ "outputFamilies": [
77
+ "portable"
78
+ ]
79
+ },
80
+ "orca": {
81
+ "meaning": "Use AGENTS.md and the report index as the Orca/Grok grounding layer.",
82
+ "outputFamilies": [
83
+ "portable"
84
+ ]
85
+ }
86
+ },
87
+ "standardAnswerContract": [
88
+ "Scope",
89
+ "Evidence",
90
+ "Diagnosis",
91
+ "Fix Plan",
92
+ "Run",
93
+ "Verify",
94
+ "Assumptions"
95
+ ],
96
+ "requiredReports": [
97
+ {
98
+ "path": ".rapidkit/reports/workspace-context-agent.json",
99
+ "label": "Agent context pack",
100
+ "required": true
101
+ },
102
+ {
103
+ "path": ".rapidkit/reports/workspace-model.json",
104
+ "label": "Workspace model graph",
105
+ "required": false
106
+ },
107
+ {
108
+ "path": ".rapidkit/reports/doctor-last-run.json",
109
+ "label": "Workspace doctor",
110
+ "required": false
111
+ },
112
+ {
113
+ "path": ".rapidkit/reports/analyze-last-run.json",
114
+ "label": "Workspace analyze",
115
+ "required": false
116
+ },
117
+ {
118
+ "path": ".rapidkit/reports/pipeline-last-run.json",
119
+ "label": "Governance pipeline",
120
+ "required": false
121
+ },
122
+ {
123
+ "path": ".rapidkit/reports/release-readiness-last-run.json",
124
+ "label": "Release readiness",
125
+ "required": false
126
+ },
127
+ {
128
+ "path": ".rapidkit/reports/workspace-impact-last-run.json",
129
+ "label": "Workspace impact",
130
+ "required": false
131
+ },
132
+ {
133
+ "path": ".rapidkit/reports/workspace-verify-last-run.json",
134
+ "label": "Workspace verify",
135
+ "required": false
136
+ }
137
+ ],
138
+ "strictRules": [
139
+ "Required reports must exist.",
140
+ "Generated report paths must stay inside the workspace root.",
141
+ "Generated customization text must be English-only.",
142
+ "Agent answers must not claim pass, ready, or healthy without cited evidence.",
143
+ "Commands must distinguish display guidance from execution requests.",
144
+ "Agent hook files must be advisory and disabled by default unless the user explicitly enables them.",
145
+ "MCP design artifacts must stay read-mostly until write tools have explicit approval boundaries."
146
+ ],
147
+ "outputKinds": [
148
+ "report",
149
+ "grounding",
150
+ "instruction",
151
+ "prompt",
152
+ "skill",
153
+ "skill-resource",
154
+ "agent",
155
+ "rule",
156
+ "hook",
157
+ "mcp-design"
158
+ ]
159
+ }
@@ -0,0 +1,10 @@
1
+ {
2
+ "schemaVersion": "rapidkit-extension-cli-compatibility.v1",
3
+ "cli": "rapidkit-npm",
4
+ "minimumVerifiedCliVersion": "0.40.0",
5
+ "publishedContractSchemas": {
6
+ "runtimeCommandSurface": "rapidkit-runtime-command-surface-v1",
7
+ "cliLogEvent": "cli-log-event-v1",
8
+ "freshnessMetadata": "rapidkit-freshness-metadata-v1"
9
+ }
10
+ }
@@ -0,0 +1 @@
1
+ export{b as AUTOPILOT_RELEASE_ALIAS_FILENAME,a as AUTOPILOT_RELEASE_LAST_RUN_FILENAME,c as runAutopilotRelease}from'./chunk-CY2WXWYQ.js';
@@ -1,4 +1,4 @@
1
- import {a}from'./chunk-UY4KRFNL.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)}
1
+ import {a}from'./chunk-NAMOYGLS.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(`