rapidkit 0.39.0 → 0.40.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 CHANGED
@@ -23,7 +23,9 @@ contracts, and release gates.
23
23
  npm install -g rapidkit
24
24
  ```
25
25
 
26
- or run without installing:
26
+ ### CLI help
27
+
28
+ Browse all commands without a global install (first run fetches from npm):
27
29
 
28
30
  ```bash
29
31
  npx rapidkit --help
@@ -32,11 +34,8 @@ npx rapidkit --help
32
34
  ### Create a governed workspace
33
35
 
34
36
  ```bash
35
- mkdir -p ~/rapidkit/workspaces
36
- cd ~/rapidkit/workspaces
37
-
38
- npx rapidkit create workspace platform --yes --profile polyglot --output .
39
- cd platform
37
+ npx rapidkit my-workspace --yes --profile polyglot
38
+ cd ~/rapidkit/workspaces/my-workspace
40
39
 
41
40
  npx rapidkit bootstrap --profile polyglot
42
41
  npx rapidkit create project
@@ -50,13 +49,9 @@ npx rapidkit pipeline --json --strict
50
49
  ### Adopt an existing project
51
50
 
52
51
  ```bash
53
- mkdir -p ~/rapidkit/workspaces
54
- cd ~/rapidkit/workspaces
55
-
56
- npx rapidkit create workspace platform --yes --profile polyglot --output .
57
- npx rapidkit adopt /path/to/project --workspace ~/rapidkit/workspaces/platform
52
+ npx rapidkit adopt /path/to/project
53
+ cd ~/rapidkit/workspaces/workspai
58
54
 
59
- cd ~/rapidkit/workspaces/platform
60
55
  npx rapidkit workspace model --json
61
56
  npx rapidkit workspace context --for-agent --json --write
62
57
  npx rapidkit pipeline --json --strict
@@ -148,6 +143,7 @@ For the visual experience, install the [Workspai VS Code extension](https://mark
148
143
  - [Typical workflows](#typical-workflows)
149
144
  - [Mental model](#mental-model)
150
145
  - [Workspace Intelligence Commands](#workspace-intelligence-commands)
146
+ - [Agent Customization Pack](#agent-customization-pack)
151
147
  - [Requirements](#requirements)
152
148
  - [Install](#install)
153
149
  - [Project workflows](#project-workflows)
@@ -182,7 +178,8 @@ npx rapidkit workspace model --json
182
178
 
183
179
  ```bash
184
180
  npx rapidkit workspace context --for-agent --json --write
185
- npx rapidkit workspace agent-sync --write --refresh-context
181
+ npx rapidkit workspace agent-sync --write --refresh-context --preset enterprise
182
+ npx rapidkit workspace agent-sync --write --refresh-context --preset enterprise --experimental-hooks
186
183
  ```
187
184
 
188
185
  ### Release verification
@@ -237,17 +234,17 @@ Every tool gets the same answers: what projects exist, what stack they use, whic
237
234
 
238
235
  Workspace Intelligence provides a shared understanding of projects, dependencies, operational context, and release readiness for developers, CI pipelines, and AI agents.
239
236
 
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 |
237
+ | Command | Purpose |
238
+ | ------------------------------------------------- | ------------------------------------------------------------------------------------ |
239
+ | `workspace model [--cache\|--incremental] --json` | Canonical workspace model (graph-aware, incremental rebuilds) |
240
+ | `workspace context --for-agent --json --write` | Agent-ready context pack + auto agent grounding sync |
241
+ | `workspace agent-sync --write` | Agent Customization Pack (AGENTS.md, Copilot, Cursor, Claude, INDEX, skills, agents) |
242
+ | `workspace snapshot --json` | Persist model snapshot |
243
+ | `workspace diff --from <file\|git[:ref]> --json` | Diff against snapshot or git |
244
+ | `workspace impact --from <file> --json` | Graph-aware transitive blast-radius evidence |
245
+ | `workspace verify [--strict] --json` | Definitive verification gate (subgraph + freshness + policy) |
246
+ | `workspace graph <emit\|explain\|dot\|mermaid>` | Inspect and visualize the dependency graph |
247
+ | `workspace watch [--json] [--once]` | Daemon mode: keep model + graph in memory, stream change events |
251
248
 
252
249
  JSON schemas: `contracts/workspace-intelligence/`. Details: [commands-reference.md](docs/commands-reference.md).
253
250
 
@@ -276,40 +273,76 @@ radius, gating, and visualization:
276
273
  deterministic `workspace-watch-event.v1` change events (changed projects, graph edge
277
274
  deltas, structural hash) via fast incremental rebuilds.
278
275
 
279
- ### Agent grounding (CLI-only, no extension required)
276
+ ### Agent Customization Pack
277
+
278
+ RapidKit can generate a versioned **Agent Customization Pack** so AI tools do
279
+ not start from an ungrounded repository scan. They start from the same workspace
280
+ truth developers and CI use: reports, commands, contracts, blockers, scope, and
281
+ verification evidence.
280
282
 
281
- RapidKit can sync **cross-tool instruction files** so Copilot, Cursor, Claude Code, Codex, Grok, and other agents read the same evidence before guessing:
283
+ This is CLI-only and does not require the Workspai extension:
282
284
 
283
285
  ```bash
284
- # Full sync: refresh context pack + INDEX + AGENTS.md + Copilot/Cursor/Claude hooks
285
- npx rapidkit workspace agent-sync --write --refresh-context
286
+ # Full enterprise pack:
287
+ # context pack + INDEX + AGENTS.md + Copilot/Cursor/Claude/Codex surfaces + MCP-ready design
288
+ npx rapidkit workspace agent-sync --write --refresh-context --preset enterprise
289
+
290
+ # Optional advisory VS Code agent hooks (disabled by default in the generated file)
291
+ npx rapidkit workspace agent-sync --write --refresh-context --preset enterprise --experimental-hooks
286
292
 
287
293
  # Context pack write also syncs grounding by default
288
294
  npx rapidkit workspace context --for-agent --json --write
289
295
 
290
296
  # CI strict gate (fail if required reports missing/stale)
291
297
  npx rapidkit workspace agent-sync --write --strict --json
298
+
299
+ # CI drift gate after sync
300
+ npm run check:agent-customization-drift -- --workspace <workspace-root>
301
+ ```
302
+
303
+ | Artifact / file | Purpose |
304
+ | ----------------------------------------------------------------------- | -------------------------------------------------------- |
305
+ | `.rapidkit/reports/agent-customization-pack.json` | Versioned output inventory, target matrix, drift state |
306
+ | `.rapidkit/reports/rapidkit-mcp-design.json` | Read-mostly MCP-ready tool design manifest |
307
+ | `.rapidkit/reports/INDEX.json` | Read order, blockers, report timestamps |
308
+ | `.rapidkit/reports/workspace-context-agent.json` | Canonical agent context pack |
309
+ | `.rapidkit/AGENT-GROUNDING.md` | Tool-agnostic grounding doc |
310
+ | `AGENTS.md` | Open standard for all agents (managed RapidKit section) |
311
+ | `.github/copilot-instructions.md` | GitHub Copilot / VS Code Chat always-on rules |
312
+ | `.github/instructions/rapidkit-workspace.instructions.md` | Copilot workspace scope and command discipline |
313
+ | `.github/instructions/rapidkit-evidence.instructions.md` | Copilot scoped rules for `.rapidkit/**` |
314
+ | `.github/prompts/rapidkit-diagnose.prompt.md` | Copilot reusable diagnose prompt |
315
+ | `.github/skills/rapidkit-workspace-intelligence/SKILL.md` | Workspace Intelligence skill workflow |
316
+ | `.github/skills/rapidkit-workspace-intelligence/resources/mcp-tools.md` | Future MCP tool design reference |
317
+ | `.github/agents/workspai-advisor.agent.md` | Read-only workspace advisor agent |
318
+ | `.github/agents/workspai-repair.agent.md` | Blocker repair agent |
319
+ | `.github/agents/workspai-release.agent.md` | Release safety agent |
320
+ | `.github/agents/workspai-project-onboarder.agent.md` | Project onboarding agent |
321
+ | `.cursor/rules/rapidkit-grounding.mdc` | Cursor always-on project rule |
322
+ | `CLAUDE.md` | Claude Code entry (`@AGENTS.md` + managed notes) |
323
+ | `.claude/rules/rapidkit-evidence.md` | Claude Code scoped evidence rules |
324
+ | `.vscode/rapidkit-agent-hooks.json` | Optional advisory VS Code hooks (`--experimental-hooks`) |
325
+
326
+ The pack also publishes a standard answer contract for agent-facing output:
327
+
328
+ ```text
329
+ Scope -> Evidence -> Diagnosis -> Fix Plan -> Run -> Verify -> Assumptions
292
330
  ```
293
331
 
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.
332
+ That contract is what keeps agent responses operational: every recommendation
333
+ should name the workspace/project scope, cite the evidence it used, explain the
334
+ diagnosis, propose the command or file action, and tell the user how to verify
335
+ the result.
336
+
337
+ Agents cannot be **forced** probabilistically. This stack makes the desired
338
+ behavior explicit, versioned, and easy for IDEs, CI, and Workspai to audit.
309
339
 
310
340
  Skip auto-sync after context write: `--no-agent-sync`. Target specific ecosystems: `--target copilot,cursor,claude`.
311
341
 
312
- After `pipeline`, grounding syncs automatically (refresh context + INDEX + hooks). Disable with `--no-agent-sync` or `RAPIDKIT_NO_AGENT_SYNC=1`.
342
+ After `pipeline`, grounding syncs automatically (refresh context + INDEX + agent surfaces). Disable with `--no-agent-sync` or `RAPIDKIT_NO_AGENT_SYNC=1`.
343
+
344
+ Contract: `contracts/agent-customization-pack.v1.json`. Artifact map:
345
+ [docs/contracts/ARTIFACT_CATALOG.md](docs/contracts/ARTIFACT_CATALOG.md).
313
346
 
314
347
  CI template: [docs/examples/ci-agent-grounding.yml](docs/examples/ci-agent-grounding.yml).
315
348
 
@@ -323,8 +356,6 @@ CI template: [docs/examples/ci-agent-grounding.yml](docs/examples/ci-agent-groun
323
356
 
324
357
  ```bash
325
358
  npm install -g rapidkit
326
- # or
327
- npx rapidkit --help
328
359
  ```
329
360
 
330
361
  ## Project workflows
@@ -332,8 +363,10 @@ npx rapidkit --help
332
363
  ### I already have a project
333
364
 
334
365
  ```bash
335
- npx rapidkit adopt /path/to/project --workspace /path/to/workspace
336
- npx rapidkit import ../orders-api --workspace ./platform
366
+ npx rapidkit adopt /path/to/project
367
+ npx rapidkit import ../orders-api
368
+ cd ~/rapidkit/workspaces/workspai
369
+
337
370
  npx rapidkit workspace model --json
338
371
  npx rapidkit doctor workspace --json
339
372
  ```
@@ -341,11 +374,8 @@ npx rapidkit doctor workspace --json
341
374
  ### I want a new project
342
375
 
343
376
  ```bash
344
- mkdir -p ~/rapidkit/workspaces
345
- cd ~/rapidkit/workspaces
346
-
347
- npx rapidkit create workspace platform --yes --profile polyglot --output .
348
- cd platform
377
+ npx rapidkit my-workspace --yes --profile polyglot
378
+ cd ~/rapidkit/workspaces/my-workspace
349
379
 
350
380
  npx rapidkit bootstrap --profile polyglot
351
381
  npx rapidkit create project # interactive kit picker
@@ -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.1",
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-5VBRMLRU.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-7VI4U7Q5.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(`