rapidkit 0.32.2 → 0.33.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
@@ -20,6 +20,7 @@ The official RapidKit npm CLI for creating and operating workspaces and projects
20
20
  - Multi-runtime support across Python, Node.js, Java, Go, and .NET
21
21
  - Policy enforcement with `warn` / `strict` modes
22
22
  - Cache and mirror lifecycle commands for stable environments
23
+ - Contract-driven workspace infra sidecar (`infra plan|up|down|status`) for local Postgres, Redis, mail, and related dev dependencies
23
24
 
24
25
  ## Workspace-First Architecture
25
26
 
@@ -149,6 +150,7 @@ npx rapidkit doctor
149
150
  npx rapidkit doctor workspace [--fix] [--plan] [--apply]
150
151
  npx rapidkit doctor project [--fix] [--plan] [--apply]
151
152
  npx rapidkit workspace list # Display all workspaces created on this system
153
+ npx rapidkit workspace foundation ensure [--force] [--json]
152
154
  npx rapidkit workspace share [--output <file>] [--include-paths] [--no-doctor]
153
155
  npx rapidkit workspace contract init [--force] [--json]
154
156
  npx rapidkit workspace contract inspect [--json]
@@ -170,6 +172,10 @@ npx rapidkit project restore <archive> [--name <project-name>] [--force] [--dry-
170
172
  npx rapidkit project delete <name> [--permanent --confirm <name>] [--dry-run] [--json]
171
173
  npx rapidkit workspace init # Full-init alias (same behavior as root init/workspace run init at workspace root)
172
174
  npx rapidkit workspace run <init|test|build|start> [--affected] [--blast-radius] [--since <ref>] [--parallel] [--max-workers <n>] [--strict] [--json]
175
+ npx rapidkit infra plan [--workspace <path>] [--json] [--dry-run] [--verbose]
176
+ npx rapidkit infra up [--workspace <path>] [--no-plan] [--build]
177
+ npx rapidkit infra down [--workspace <path>] [--volumes]
178
+ npx rapidkit infra status [--workspace <path>] [--json] [--strict]
173
179
  ```
174
180
 
175
181
  ### Project import into workspace
@@ -313,13 +319,46 @@ and `workspace archive doctor` when you want human-readable readiness/security g
313
319
  imports the workspace. Use `--include-env` only for trusted internal handoffs when you intentionally need
314
320
  environment files inside the archive.
315
321
 
322
+ ### Workspace infrastructure (sidecar)
323
+
324
+ Use `infra` when a workspace needs local dev dependencies (PostgreSQL, Redis, Mailpit, MinIO, and
325
+ related services) without replacing the workspace's own `docker-compose.yml`.
326
+
327
+ Discovery is contract-first and runtime-agnostic:
328
+
329
+ - Installed Core module slugs from each project's `registry.json`
330
+ - Infra-related variables from each project's `.env.example`
331
+ - Optional env declarations from `.rapidkit/workspace.contract.json`
332
+ - Manual overrides in `.rapidkit/infra/overrides.json`
333
+
334
+ ```bash
335
+ cd my-workspace
336
+ npx rapidkit infra plan
337
+ npx rapidkit infra up
338
+ npx rapidkit infra status --strict
339
+ npx rapidkit infra down
340
+ ```
341
+
342
+ Artifacts are written beside the workspace (sidecar strategy):
343
+
344
+ - `.rapidkit/infra/docker-compose.yml` — generated Docker Compose stack
345
+ - `.rapidkit/reports/infra-plan.json` — machine-readable plan and discovery evidence
346
+ - `.rapidkit/infra/.env.example` — connection env preview for local `.env` files
347
+
348
+ `infra up` refreshes the plan by default. Use `--no-plan` to start from the last saved plan only.
349
+ Connection defaults prefer project `.env.example` values (for example `RAPIDKIT_DB_POSTGRES_URL`).
350
+
351
+ This command family is wrapper-owned, does not mutate Core modules, and works for polyglot workspaces
352
+ (FastAPI, NestJS, Go, Spring Boot, .NET, and imported projects) as long as projects expose
353
+ `.rapidkit/project.json` and env/override signals.
354
+
316
355
  ### Command ownership
317
356
 
318
357
  RapidKit keeps the wrapper boundary explicit so users know which layer owns each action.
319
358
 
320
359
  | Command family | Owner | Notes |
321
360
  | -------------------------------------------------- | ---------------------- | ------------------------------------------------------------------------------------------------------------------------------- |
322
- | `create workspace`, `workspace`, `cache`, `mirror` | RapidKit wrapper | Platform-level orchestration |
361
+ | `create workspace`, `workspace`, `cache`, `mirror`, `infra` | RapidKit wrapper | Platform-level orchestration |
323
362
  | `init` | Wrapper orchestrated | Project init in project dirs; full-init alias at workspace root |
324
363
  | `dev`, `test`, `build`, `start` | Runtime aware | Delegates to the active project/runtime when available |
325
364
  | `readiness` | Wrapper release gate | Generates release-readiness evidence (`--json` for CI, `--strict` for fail-fast) |
@@ -331,6 +370,7 @@ RapidKit keeps the wrapper boundary explicit so users know which layer owns each
331
370
  | `doctor workspace` | Workspace health | Full workspace scan with project-level details and fixes |
332
371
  | `doctor project` | Project health | Current project (or nearest parent) diagnostics with project evidence and scoped fixes |
333
372
  | `workspace run` | Workspace orchestrator | Stage execution across discovered projects with optional affected-only, blast-radius expansion, and policy-gated pre-checks |
373
+ | `infra` | Workspace sidecar | Contract-driven local infra discovery, compose generation, and Docker lifecycle (`plan`, `up`, `down`, `status`) |
334
374
 
335
375
  Use `npx rapidkit doctor` for a quick host pre-flight, `npx rapidkit doctor project` for a service-level check, and `npx rapidkit doctor workspace` for the full workspace picture.
336
376
  Use `npx rapidkit analyze --json` to generate CI-friendly workspace health evidence and save it under `.rapidkit/reports/`.
@@ -424,8 +464,11 @@ available.
424
464
  ```bash
425
465
  npx rapidkit cache <status|clear|prune|repair>
426
466
  npx rapidkit mirror <status|sync|verify|rotate>
467
+ npx rapidkit infra <plan|up|down|status>
427
468
  ```
428
469
 
470
+ See [Workspace infrastructure (sidecar)](#workspace-infrastructure-sidecar) for discovery rules and generated artifacts.
471
+
429
472
  ## Profiles
430
473
 
431
474
  - `minimal` — baseline workspace scaffolding
@@ -0,0 +1,37 @@
1
+ {
2
+ "schemaVersion": "backend-import-stack-parity-v1",
3
+ "frameworkToStack": {
4
+ "fastapi": "fastapi",
5
+ "django": "django",
6
+ "flask": "flask",
7
+ "python": "unknown",
8
+ "nestjs": "nestjs",
9
+ "express": "express",
10
+ "fastify": "unknown",
11
+ "koa": "koa",
12
+ "node": "unknown",
13
+ "gofiber": "go",
14
+ "gogin": "go",
15
+ "echo": "go",
16
+ "go": "go",
17
+ "springboot": "springboot",
18
+ "java": "unknown",
19
+ "rails": "rails",
20
+ "ruby": "unknown",
21
+ "dotnet": "dotnet",
22
+ "unknown": "unknown"
23
+ },
24
+ "runtimeToStack": {
25
+ "python": "unknown",
26
+ "node": "unknown",
27
+ "nodejs": "unknown",
28
+ "typescript": "unknown",
29
+ "go": "go",
30
+ "golang": "go",
31
+ "java": "unknown",
32
+ "ruby": "unknown",
33
+ "dotnet": "dotnet",
34
+ "csharp": "dotnet",
35
+ "unknown": "unknown"
36
+ }
37
+ }
@@ -0,0 +1,162 @@
1
+ {
2
+ "schemaVersion": "rapidkit.infra-stack.v1",
3
+ "description": "Canonical workspace infrastructure service catalog and module/env resolution rules.",
4
+ "futureProfiles": ["frontend-dev", "edge-proxy"],
5
+ "services": {
6
+ "postgres": {
7
+ "displayName": "PostgreSQL",
8
+ "category": "database",
9
+ "image": "postgres:16-alpine",
10
+ "ports": [{ "name": "sql", "host": 5432, "container": 5432 }],
11
+ "env": {
12
+ "POSTGRES_USER": "rapidkit",
13
+ "POSTGRES_PASSWORD": "rapidkit",
14
+ "POSTGRES_DB": "rapidkit"
15
+ },
16
+ "volumes": ["postgres_data:/var/lib/postgresql/data"],
17
+ "healthcheck": {
18
+ "test": ["CMD-SHELL", "pg_isready -U rapidkit -d rapidkit"],
19
+ "interval": "10s",
20
+ "timeout": "5s",
21
+ "retries": 5
22
+ },
23
+ "connectionEnv": {
24
+ "DATABASE_URL": "postgresql://rapidkit:rapidkit@localhost:5432/rapidkit",
25
+ "RAPIDKIT_DB_POSTGRES_URL": "postgresql://rapidkit:rapidkit@localhost:5432/rapidkit"
26
+ }
27
+ },
28
+ "redis": {
29
+ "displayName": "Redis",
30
+ "category": "cache",
31
+ "image": "redis:7-alpine",
32
+ "ports": [{ "name": "redis", "host": 6379, "container": 6379 }],
33
+ "command": ["redis-server", "--appendonly", "yes"],
34
+ "volumes": ["redis_data:/data"],
35
+ "healthcheck": {
36
+ "test": ["CMD", "redis-cli", "ping"],
37
+ "interval": "10s",
38
+ "timeout": "3s",
39
+ "retries": 5
40
+ },
41
+ "connectionEnv": {
42
+ "REDIS_URL": "redis://localhost:6379/0",
43
+ "CELERY_BROKER_URL": "redis://localhost:6379/0",
44
+ "CELERY_RESULT_BACKEND": "redis://localhost:6379/1"
45
+ }
46
+ },
47
+ "mongo": {
48
+ "displayName": "MongoDB",
49
+ "category": "database",
50
+ "image": "mongo:7",
51
+ "ports": [{ "name": "mongo", "host": 27017, "container": 27017 }],
52
+ "volumes": ["mongo_data:/data/db"],
53
+ "connectionEnv": {
54
+ "MONGODB_URI": "mongodb://localhost:27017/rapidkit",
55
+ "MONGO_URL": "mongodb://localhost:27017/rapidkit"
56
+ }
57
+ },
58
+ "mysql": {
59
+ "displayName": "MySQL",
60
+ "category": "database",
61
+ "image": "mysql:8.4",
62
+ "ports": [{ "name": "mysql", "host": 3306, "container": 3306 }],
63
+ "env": {
64
+ "MYSQL_ROOT_PASSWORD": "rapidkit",
65
+ "MYSQL_DATABASE": "rapidkit",
66
+ "MYSQL_USER": "rapidkit",
67
+ "MYSQL_PASSWORD": "rapidkit"
68
+ },
69
+ "healthcheck": {
70
+ "test": ["CMD", "mysqladmin", "ping", "-h", "127.0.0.1", "-urapidkit", "-prapidkit"],
71
+ "interval": "10s",
72
+ "timeout": "5s",
73
+ "retries": 5
74
+ },
75
+ "connectionEnv": {
76
+ "DATABASE_URL": "mysql://rapidkit:rapidkit@localhost:3306/rapidkit"
77
+ }
78
+ },
79
+ "rabbitmq": {
80
+ "displayName": "RabbitMQ",
81
+ "category": "queue",
82
+ "image": "rabbitmq:3-management-alpine",
83
+ "ports": [
84
+ { "name": "amqp", "host": 5672, "container": 5672 },
85
+ { "name": "management", "host": 15672, "container": 15672 }
86
+ ],
87
+ "healthcheck": {
88
+ "test": ["CMD", "rabbitmq-diagnostics", "-q", "ping"],
89
+ "interval": "15s",
90
+ "timeout": "10s",
91
+ "retries": 5
92
+ },
93
+ "connectionEnv": {
94
+ "CELERY_BROKER_URL": "amqp://guest:guest@localhost:5672//",
95
+ "RABBITMQ_URL": "amqp://guest:guest@localhost:5672//"
96
+ }
97
+ },
98
+ "mailpit": {
99
+ "displayName": "Mailpit (SMTP dev)",
100
+ "category": "communication",
101
+ "image": "axllent/mailpit:latest",
102
+ "ports": [
103
+ { "name": "smtp", "host": 1025, "container": 1025 },
104
+ { "name": "ui", "host": 8025, "container": 8025 }
105
+ ],
106
+ "connectionEnv": {
107
+ "SMTP_HOST": "localhost",
108
+ "SMTP_PORT": "1025",
109
+ "MAIL_URL": "smtp://localhost:1025"
110
+ }
111
+ },
112
+ "minio": {
113
+ "displayName": "MinIO (S3-compatible)",
114
+ "category": "storage",
115
+ "image": "minio/minio:latest",
116
+ "ports": [
117
+ { "name": "s3", "host": 9000, "container": 9000 },
118
+ { "name": "console", "host": 9001, "container": 9001 }
119
+ ],
120
+ "command": ["server", "/data", "--console-address", ":9001"],
121
+ "env": {
122
+ "MINIO_ROOT_USER": "rapidkit",
123
+ "MINIO_ROOT_PASSWORD": "rapidkit-dev"
124
+ },
125
+ "volumes": ["minio_data:/data"],
126
+ "connectionEnv": {
127
+ "AWS_S3_ENDPOINT": "http://localhost:9000",
128
+ "S3_ENDPOINT_URL": "http://localhost:9000"
129
+ }
130
+ }
131
+ },
132
+ "moduleMappings": {
133
+ "free/database/db_postgres": ["postgres"],
134
+ "free/database/db_mongo": ["mongo"],
135
+ "free/database/db_mysql": ["mysql"],
136
+ "free/cache/redis": ["redis"],
137
+ "free/tasks/celery": ["redis"],
138
+ "free/tasks/workflow_engine": ["postgres", "redis"],
139
+ "free/tasks/queue_platform": ["redis"],
140
+ "free/tasks/event_bus": ["redis"],
141
+ "free/communication/webhook_platform": ["postgres", "redis"],
142
+ "free/communication/email": ["mailpit"],
143
+ "free/business/storage": ["minio"],
144
+ "free/security/audit_policy": ["postgres"],
145
+ "free/business/approval_engine": ["postgres", "redis"]
146
+ },
147
+ "envVarMappings": {
148
+ "DATABASE_URL": ["postgres"],
149
+ "RAPIDKIT_DB_POSTGRES_URL": ["postgres"],
150
+ "REDIS_URL": ["redis"],
151
+ "CELERY_BROKER_URL": ["redis"],
152
+ "CELERY_RESULT_BACKEND": ["redis"],
153
+ "MONGODB_URI": ["mongo"],
154
+ "MONGO_URL": ["mongo"],
155
+ "MYSQL_URL": ["mysql"],
156
+ "RABBITMQ_URL": ["rabbitmq"],
157
+ "SMTP_HOST": ["mailpit"],
158
+ "MAIL_URL": ["mailpit"],
159
+ "AWS_S3_ENDPOINT": ["minio"],
160
+ "S3_ENDPOINT_URL": ["minio"]
161
+ }
162
+ }
@@ -0,0 +1,25 @@
1
+ {
2
+ "schemaVersion": "rapidkit.module-layout.v1",
3
+ "canonicalModuleRoot": "src/modules/free",
4
+ "pathPattern": "src/modules/free/{category}/{module}",
5
+ "slugPattern": "free/{category}/{module}",
6
+ "frameworks": {
7
+ "fastapi": {
8
+ "moduleCommands": true,
9
+ "injectAnchors": [
10
+ "src/routing/__init__.py",
11
+ "src/modules/__init__.py"
12
+ ],
13
+ "moduleMarkerFiles": ["__init__.py"]
14
+ },
15
+ "nestjs": {
16
+ "moduleCommands": true,
17
+ "injectAnchors": [
18
+ "src/app.module.ts",
19
+ "src/modules/index.ts"
20
+ ],
21
+ "moduleMarkerFiles": ["index.ts", "module.ts"]
22
+ }
23
+ },
24
+ "unsupportedModuleFrameworks": ["go", "springboot", "dotnet"]
25
+ }
@@ -0,0 +1,152 @@
1
+ {
2
+ "schemaVersion": "rapidkit-runtime-command-surface-v1",
3
+ "lifecycleCommands": ["init", "dev", "start", "build", "test", "lint", "format", "help"],
4
+ "moduleMutationCommands": [
5
+ "add",
6
+ "modules",
7
+ "upgrade",
8
+ "diff",
9
+ "merge",
10
+ "reconcile",
11
+ "rollback",
12
+ "uninstall",
13
+ "checkpoint",
14
+ "snapshot",
15
+ "optimize"
16
+ ],
17
+ "globalCommands": ["create", "list", "info", "frameworks", "license"],
18
+ "universalCommands": ["version", "commands", "doctor", "project"],
19
+ "moduleSuggestionFrameworks": ["fastapi", "nestjs"],
20
+ "moduleUnsupportedFrameworks": ["go", "springboot", "dotnet"],
21
+ "scaffoldKits": [
22
+ "fastapi.standard",
23
+ "fastapi.ddd",
24
+ "nestjs.standard",
25
+ "gofiber.standard",
26
+ "gogin.standard",
27
+ "springboot.standard",
28
+ "dotnet.webapi.clean"
29
+ ],
30
+ "runtimeMatrix": {
31
+ "python": {
32
+ "tier": "first-class",
33
+ "scaffold": true,
34
+ "import": true,
35
+ "moduleCommands": true,
36
+ "doctor": "full",
37
+ "lifecycleCommands": ["init", "dev", "start", "build", "test", "lint", "format", "help"]
38
+ },
39
+ "node": {
40
+ "tier": "first-class",
41
+ "scaffold": true,
42
+ "import": true,
43
+ "moduleCommands": true,
44
+ "doctor": "full",
45
+ "lifecycleCommands": ["init", "dev", "start", "build", "test", "lint", "format", "help"]
46
+ },
47
+ "go": {
48
+ "tier": "extended",
49
+ "scaffold": true,
50
+ "import": true,
51
+ "moduleCommands": false,
52
+ "doctor": "readiness",
53
+ "lifecycleCommands": ["init", "dev", "start", "build", "test", "lint", "format", "help"]
54
+ },
55
+ "java": {
56
+ "tier": "extended",
57
+ "scaffold": true,
58
+ "import": true,
59
+ "moduleCommands": false,
60
+ "doctor": "readiness",
61
+ "lifecycleCommands": ["init", "dev", "start", "build", "test", "lint", "format", "help"]
62
+ },
63
+ "dotnet": {
64
+ "tier": "extended",
65
+ "scaffold": true,
66
+ "import": true,
67
+ "moduleCommands": false,
68
+ "doctor": "readiness",
69
+ "lifecycleCommands": ["init", "dev", "start", "build", "test", "lint", "format", "help"]
70
+ },
71
+ "php": {
72
+ "tier": "observed",
73
+ "scaffold": false,
74
+ "import": true,
75
+ "moduleCommands": false,
76
+ "doctor": "observed",
77
+ "lifecycleCommands": ["help"]
78
+ },
79
+ "ruby": {
80
+ "tier": "observed",
81
+ "scaffold": false,
82
+ "import": true,
83
+ "moduleCommands": false,
84
+ "doctor": "observed",
85
+ "lifecycleCommands": ["help"]
86
+ },
87
+ "rust": {
88
+ "tier": "observed",
89
+ "scaffold": false,
90
+ "import": true,
91
+ "moduleCommands": false,
92
+ "doctor": "observed",
93
+ "lifecycleCommands": ["help"]
94
+ },
95
+ "elixir": {
96
+ "tier": "observed",
97
+ "scaffold": false,
98
+ "import": true,
99
+ "moduleCommands": false,
100
+ "doctor": "observed",
101
+ "lifecycleCommands": ["help"]
102
+ },
103
+ "clojure": {
104
+ "tier": "observed",
105
+ "scaffold": false,
106
+ "import": true,
107
+ "moduleCommands": false,
108
+ "doctor": "observed",
109
+ "lifecycleCommands": ["help"]
110
+ },
111
+ "scala": {
112
+ "tier": "observed",
113
+ "scaffold": false,
114
+ "import": true,
115
+ "moduleCommands": false,
116
+ "doctor": "observed",
117
+ "lifecycleCommands": ["help"]
118
+ },
119
+ "kotlin": {
120
+ "tier": "observed",
121
+ "scaffold": false,
122
+ "import": true,
123
+ "moduleCommands": false,
124
+ "doctor": "observed",
125
+ "lifecycleCommands": ["help"]
126
+ },
127
+ "deno": {
128
+ "tier": "observed",
129
+ "scaffold": false,
130
+ "import": true,
131
+ "moduleCommands": false,
132
+ "doctor": "observed",
133
+ "lifecycleCommands": ["help"]
134
+ },
135
+ "bun": {
136
+ "tier": "observed",
137
+ "scaffold": false,
138
+ "import": true,
139
+ "moduleCommands": false,
140
+ "doctor": "observed",
141
+ "lifecycleCommands": ["help"]
142
+ },
143
+ "unknown": {
144
+ "tier": "observed",
145
+ "scaffold": false,
146
+ "import": true,
147
+ "moduleCommands": false,
148
+ "doctor": "observed",
149
+ "lifecycleCommands": ["help"]
150
+ }
151
+ }
152
+ }
@@ -1,4 +1,4 @@
1
- import {a}from'./chunk-VKLL63TL.js';import {d,e}from'./chunk-KXTXQODI.js';import g from'fs';import r from'path';import o from'chalk';var $=new Set([".git",".rapidkit",".venv","node_modules","dist","build","target","coverage","htmlcov",".next"]);async function y(e){try{return await g.promises.access(e,g.constants.F_OK),true}catch{return false}}async function v(e){try{let n=JSON.parse(await g.promises.readFile(e,"utf-8"));return n&&typeof n=="object"&&!Array.isArray(n)?n:null}catch{return null}}async function F(e){try{return await g.promises.readFile(e,"utf-8")}catch{return ""}}function I(e){let n=r.resolve(e);for(;;){if(g.existsSync(r.join(n,".rapidkit-workspace"))||g.existsSync(r.join(n,".rapidkit","workspace.json")))return n;let t=r.dirname(n);if(t===n)return null;n=t;}}async function G(e,n){return await y(r.join(e,".rapidkit","project.json"))||await y(r.join(e,".rapidkit","context.json"))?true:r.resolve(e)===r.resolve(n)?d(e).length>0:d(e).length>0}async function S(e){let n=await a(e,{skipDirs:$,includeHiddenDirs:false,descendIntoMatchedProjects:false,isProjectDir:G});return n.length>0?n:d(e).length>0?[e]:[]}function E(e,n){return r.relative(e,n).replace(/\\/g,"/")||"."}async function b(e,n){for(let t of n)if(await y(r.join(e,t)))return true;return false}async function T(e){return b(e,["health","health.ts","health.js","health.py","health.go","health.kt","health.rb","health.php","healthcheck","health-check","src/health.ts","src/health.js","src/health.py","src/health.go","src/health.kt","src/health.rb","src/health.php","src/healthcheck.ts","src/healthcheck.js","src/liveness.ts","src/readiness.ts","src/ping.ts"])}async function N(e){if(await b(e,["tests","test","__tests__","src/__tests__","pytest.ini","vitest.config.ts","jest.config.ts"]))return true;let t=await v(r.join(e,"package.json")),i=t?.scripts&&typeof t.scripts=="object"?t.scripts:{};return typeof i.test=="string"&&i.test.trim().length>0}async function K(e){let n=await v(r.join(e,"package.json")),t=n?.scripts&&typeof n.scripts=="object"?n.scripts:{};return Object.keys(t).sort()}function h(e,n,t,i,s,c){return {id:e,severity:n,target:t,title:i,detail:s,remediation:c}}function O(e){let n=e.reduce((t,i)=>i.severity==="fail"?t+28:i.severity==="warn"?t+12:t+3,0);return Math.max(0,100-n)}async function _(e$1,n){let t=await v(r.join(n,".rapidkit","project.json")),i=e(n,t),s=d(n),c=i.runtime==="unknown"?s[0]||"unknown":i.runtime,a=E(e$1,n),d$1=a,m=await K(n),f=await y(r.join(n,".rapidkit","project.json"))||await y(r.join(n,".rapidkit","context.json")),u=await N(n),k=await b(n,["Dockerfile","dockerfile"]),w=await b(n,[".env.example","env.example","config/env.example"]),A=await b(n,[".github/workflows/ci.yml",".github/workflows/ci.yaml",".github/workflows/main.yml",".github/workflows/build.yml",".github/workflows/test.yml",".github/workflows/deploy.yml",".gitlab-ci.yml",".circleci/config.yml","azure-pipelines.yml","bitbucket-pipelines.yml","cloudbuild.yaml"]),z=await T(n),l=[];return i.key==="unknown"&&l.push(h("project.stack.unknown","fail",d$1,"Project stack is unknown","RapidKit cannot confidently classify this backend project.","Add .rapidkit/project.json metadata or import the project with `rapidkit import`.")),f||l.push(h("project.marker.missing","warn",d$1,"RapidKit marker is missing","The project can be detected by files, but it is not registered with RapidKit metadata.","Run `rapidkit import <path>` from a workspace or create the project through RapidKit.")),u||l.push(h("project.tests.missing","warn",d$1,"Test entrypoint is missing","No common test folder, config, or package test script was found.","Add a test command so `rapidkit workspace run test --affected` can gate changes.")),w||l.push(h("project.env.example.missing","info",d$1,"Environment example is missing","No .env.example or env.example file was found.","Add an env example for onboarding and CI secret documentation.")),A||l.push(h("project.ci.missing","warn",d$1,"Continuous integration is missing","No recognized CI/CD configuration file was detected for this project.","Add CI configuration so tests and checks run automatically for every change.")),z||l.push(h("project.health.missing","info",d$1,"Health or readiness probe is missing","The project has no obvious health or readiness endpoint to support automated deployment and runtime checks.","Add a simple health endpoint and document it for readiness gates and observability.")),k||l.push(h("project.container.missing","info",d$1,"Container recipe is missing","No Dockerfile was found for this project.","Add a Dockerfile when the service is intended for containerized deployment.")),{name:r.basename(n),path:n,relativePath:a,runtime:c,framework:i.key,confidence:i.confidence,supportTier:i.supportTier,hasRapidKitMarker:f,hasTests:u,hasDockerfile:k,hasEnvExample:w,hasCiConfig:A,hasHealthEndpoint:z,scripts:m,findings:l,score:O(l)}}function J(e){return e.name.toLowerCase()}async function M(e){let n=new Map(e.map(s=>[J(s),s])),t=[];for(let s of e){let c=await v(r.join(s.path,"package.json")),a={...c?.dependencies??{},...c?.devDependencies??{},...c?.peerDependencies??{}};for(let m of Object.keys(a)){let f=m.replace(/^@[^/]+\//,"").toLowerCase(),u=n.get(f);u&&u.relativePath!==s.relativePath&&t.push({from:s.relativePath,to:u.relativePath,kind:"package"});}let d=await F(r.join(s.path,"pyproject.toml"));for(let m of e)m.relativePath!==s.relativePath&&d.includes(m.name)&&t.push({from:s.relativePath,to:m.relativePath,kind:"workspace-reference"});}let i=new Set;return t.filter(s=>{let c=`${s.from}\0${s.to}\0${s.kind}`;return i.has(c)?false:(i.add(c),true)})}function W(e,n){let t=new Map;for(let i of e)t.set(i.relativePath,{project:i.relativePath,directDependents:0,directDependencies:0});for(let i of n){let s=t.get(i.from),c=t.get(i.to);s&&(s.directDependencies+=1),c&&(c.directDependents+=1);}return Array.from(t.values()).sort((i,s)=>s.directDependents-i.directDependents||s.directDependencies-i.directDependencies)}async function H(e){let n=await v(r.join(e,".rapidkit","workspace.json"));return typeof n?.profile=="string"?n.profile:null}function B(e){return {fail:e.filter(n=>n.severity==="fail").length,warn:e.filter(n=>n.severity==="warn").length,info:e.filter(n=>n.severity==="info").length}}function V(e){if(e.projectCount===0)return ["Create a RapidKit workspace: npx rapidkit create workspace my-workspace --profile polyglot","Import an existing service: npx rapidkit import ../service"];let n=[];return e.findings.some(t=>t.id==="workspace.marker.missing")&&n.push("Initialize workspace metadata with `rapidkit bootstrap --profile polyglot`."),e.findings.some(t=>t.id==="project.marker.missing")&&n.push("Register detected projects with `rapidkit import <path>` or recreate them via `rapidkit create project`."),e.findings.some(t=>t.id==="project.tests.missing")&&n.push("Add test entrypoints, then gate changes with `rapidkit workspace run test --affected --strict`."),e.findings.some(t=>t.id==="project.ci.missing")&&n.push("Add CI/CD configuration to catch regressions early and make workspace health checks actionable."),e.findings.some(t=>t.id==="project.health.missing")&&n.push("Add a health/readiness endpoint so runtime probes and deployment checks can verify service health."),e.hasGraph||n.push("Create `.rapidkit/workspace-dependency-graph.json` or use analyze output as the first graph seed."),n.push("Run `rapidkit autopilot release --mode audit --json` before release."),Array.from(new Set(n))}async function ee(e={}){let n=r.resolve(e.workspacePath||process.cwd());if(!await y(n))throw new Error(`Workspace path does not exist: ${n}`);let t=I(n)??n,i=await y(r.join(t,".rapidkit-workspace"))||await y(r.join(t,".rapidkit","workspace.json")),s=await H(t),c=await S(t),a=await Promise.all(c.map(p=>_(t,p))),d=await M(a),m=W(a,d),f=[];i||f.push(h("workspace.marker.missing","warn",".","Workspace metadata is missing","The directory can be analyzed, but it is not a registered RapidKit workspace.","Run `rapidkit create workspace` or `rapidkit bootstrap --profile polyglot` in a workspace root.")),a.length===0&&f.push(h("workspace.projects.missing","fail",".","No backend projects detected","RapidKit did not find runtime markers or project metadata under this root.","Create a project with `rapidkit create project` or import one with `rapidkit import <path>`."));let u=[...f,...a.flatMap(p=>p.findings)],k=B(u),w={};for(let p of a)w[p.runtime]=(w[p.runtime]||0)+1;let A=a.length>0?Math.round(a.reduce((p,P)=>p+P.score,0)/a.length):0,z=f.reduce((p,P)=>p+(P.severity==="fail"?20:P.severity==="warn"?8:2),0),l=Math.max(0,A-z),R=k.fail>0||e.strict&&k.warn>0?"blocked":k.warn>0?"needs-attention":"ready",x={schemaVersion:"rapidkit-analyze-v1",generatedAt:new Date().toISOString(),workspacePath:t,workspaceDetected:i,profile:s,summary:{score:l,verdict:R,projectCount:a.length,runtimeCount:Object.keys(w).length,findings:k},runtimes:w,projects:a,dependencyGraph:{status:d.length>0?"generated":"empty",edges:d,topImpactedProjects:m.slice(0,5)},findings:u,nextActions:V({findings:u,projectCount:a.length,hasGraph:d.length>0}),enterpriseControls:{jsonReady:true,ciGateCommand:"rapidkit analyze --json --strict",releaseGateCommand:"rapidkit autopilot release --mode enforce --json",evidencePath:".rapidkit/reports/analyze-last-run.json"}};if(e.output&&(await g.promises.mkdir(r.dirname(r.resolve(e.output)),{recursive:true}),await g.promises.writeFile(r.resolve(e.output),`${JSON.stringify(x,null,2)}
1
+ import {d,e}from'./chunk-KXTXQODI.js';import {a}from'./chunk-VKLL63TL.js';import g from'fs';import r from'path';import o from'chalk';var $=new Set([".git",".rapidkit",".venv","node_modules","dist","build","target","coverage","htmlcov",".next"]);async function y(e){try{return await g.promises.access(e,g.constants.F_OK),true}catch{return false}}async function v(e){try{let n=JSON.parse(await g.promises.readFile(e,"utf-8"));return n&&typeof n=="object"&&!Array.isArray(n)?n:null}catch{return null}}async function F(e){try{return await g.promises.readFile(e,"utf-8")}catch{return ""}}function I(e){let n=r.resolve(e);for(;;){if(g.existsSync(r.join(n,".rapidkit-workspace"))||g.existsSync(r.join(n,".rapidkit","workspace.json")))return n;let t=r.dirname(n);if(t===n)return null;n=t;}}async function G(e,n){return await y(r.join(e,".rapidkit","project.json"))||await y(r.join(e,".rapidkit","context.json"))?true:r.resolve(e)===r.resolve(n)?d(e).length>0:d(e).length>0}async function S(e){let n=await a(e,{skipDirs:$,includeHiddenDirs:false,descendIntoMatchedProjects:false,isProjectDir:G});return n.length>0?n:d(e).length>0?[e]:[]}function E(e,n){return r.relative(e,n).replace(/\\/g,"/")||"."}async function b(e,n){for(let t of n)if(await y(r.join(e,t)))return true;return false}async function T(e){return b(e,["health","health.ts","health.js","health.py","health.go","health.kt","health.rb","health.php","healthcheck","health-check","src/health.ts","src/health.js","src/health.py","src/health.go","src/health.kt","src/health.rb","src/health.php","src/healthcheck.ts","src/healthcheck.js","src/liveness.ts","src/readiness.ts","src/ping.ts"])}async function N(e){if(await b(e,["tests","test","__tests__","src/__tests__","pytest.ini","vitest.config.ts","jest.config.ts"]))return true;let t=await v(r.join(e,"package.json")),i=t?.scripts&&typeof t.scripts=="object"?t.scripts:{};return typeof i.test=="string"&&i.test.trim().length>0}async function K(e){let n=await v(r.join(e,"package.json")),t=n?.scripts&&typeof n.scripts=="object"?n.scripts:{};return Object.keys(t).sort()}function h(e,n,t,i,s,c){return {id:e,severity:n,target:t,title:i,detail:s,remediation:c}}function O(e){let n=e.reduce((t,i)=>i.severity==="fail"?t+28:i.severity==="warn"?t+12:t+3,0);return Math.max(0,100-n)}async function _(e$1,n){let t=await v(r.join(n,".rapidkit","project.json")),i=e(n,t),s=d(n),c=i.runtime==="unknown"?s[0]||"unknown":i.runtime,a=E(e$1,n),d$1=a,m=await K(n),f=await y(r.join(n,".rapidkit","project.json"))||await y(r.join(n,".rapidkit","context.json")),u=await N(n),k=await b(n,["Dockerfile","dockerfile"]),w=await b(n,[".env.example","env.example","config/env.example"]),A=await b(n,[".github/workflows/ci.yml",".github/workflows/ci.yaml",".github/workflows/main.yml",".github/workflows/build.yml",".github/workflows/test.yml",".github/workflows/deploy.yml",".gitlab-ci.yml",".circleci/config.yml","azure-pipelines.yml","bitbucket-pipelines.yml","cloudbuild.yaml"]),z=await T(n),l=[];return i.key==="unknown"&&l.push(h("project.stack.unknown","fail",d$1,"Project stack is unknown","RapidKit cannot confidently classify this backend project.","Add .rapidkit/project.json metadata or import the project with `rapidkit import`.")),f||l.push(h("project.marker.missing","warn",d$1,"RapidKit marker is missing","The project can be detected by files, but it is not registered with RapidKit metadata.","Run `rapidkit import <path>` from a workspace or create the project through RapidKit.")),u||l.push(h("project.tests.missing","warn",d$1,"Test entrypoint is missing","No common test folder, config, or package test script was found.","Add a test command so `rapidkit workspace run test --affected` can gate changes.")),w||l.push(h("project.env.example.missing","info",d$1,"Environment example is missing","No .env.example or env.example file was found.","Add an env example for onboarding and CI secret documentation.")),A||l.push(h("project.ci.missing","warn",d$1,"Continuous integration is missing","No recognized CI/CD configuration file was detected for this project.","Add CI configuration so tests and checks run automatically for every change.")),z||l.push(h("project.health.missing","info",d$1,"Health or readiness probe is missing","The project has no obvious health or readiness endpoint to support automated deployment and runtime checks.","Add a simple health endpoint and document it for readiness gates and observability.")),k||l.push(h("project.container.missing","info",d$1,"Container recipe is missing","No Dockerfile was found for this project.","Add a Dockerfile when the service is intended for containerized deployment.")),{name:r.basename(n),path:n,relativePath:a,runtime:c,framework:i.key,confidence:i.confidence,supportTier:i.supportTier,hasRapidKitMarker:f,hasTests:u,hasDockerfile:k,hasEnvExample:w,hasCiConfig:A,hasHealthEndpoint:z,scripts:m,findings:l,score:O(l)}}function J(e){return e.name.toLowerCase()}async function M(e){let n=new Map(e.map(s=>[J(s),s])),t=[];for(let s of e){let c=await v(r.join(s.path,"package.json")),a={...c?.dependencies??{},...c?.devDependencies??{},...c?.peerDependencies??{}};for(let m of Object.keys(a)){let f=m.replace(/^@[^/]+\//,"").toLowerCase(),u=n.get(f);u&&u.relativePath!==s.relativePath&&t.push({from:s.relativePath,to:u.relativePath,kind:"package"});}let d=await F(r.join(s.path,"pyproject.toml"));for(let m of e)m.relativePath!==s.relativePath&&d.includes(m.name)&&t.push({from:s.relativePath,to:m.relativePath,kind:"workspace-reference"});}let i=new Set;return t.filter(s=>{let c=`${s.from}\0${s.to}\0${s.kind}`;return i.has(c)?false:(i.add(c),true)})}function W(e,n){let t=new Map;for(let i of e)t.set(i.relativePath,{project:i.relativePath,directDependents:0,directDependencies:0});for(let i of n){let s=t.get(i.from),c=t.get(i.to);s&&(s.directDependencies+=1),c&&(c.directDependents+=1);}return Array.from(t.values()).sort((i,s)=>s.directDependents-i.directDependents||s.directDependencies-i.directDependencies)}async function H(e){let n=await v(r.join(e,".rapidkit","workspace.json"));return typeof n?.profile=="string"?n.profile:null}function B(e){return {fail:e.filter(n=>n.severity==="fail").length,warn:e.filter(n=>n.severity==="warn").length,info:e.filter(n=>n.severity==="info").length}}function V(e){if(e.projectCount===0)return ["Create a RapidKit workspace: npx rapidkit create workspace my-workspace --profile polyglot","Import an existing service: npx rapidkit import ../service"];let n=[];return e.findings.some(t=>t.id==="workspace.marker.missing")&&n.push("Initialize workspace metadata with `rapidkit bootstrap --profile polyglot`."),e.findings.some(t=>t.id==="project.marker.missing")&&n.push("Register detected projects with `rapidkit import <path>` or recreate them via `rapidkit create project`."),e.findings.some(t=>t.id==="project.tests.missing")&&n.push("Add test entrypoints, then gate changes with `rapidkit workspace run test --affected --strict`."),e.findings.some(t=>t.id==="project.ci.missing")&&n.push("Add CI/CD configuration to catch regressions early and make workspace health checks actionable."),e.findings.some(t=>t.id==="project.health.missing")&&n.push("Add a health/readiness endpoint so runtime probes and deployment checks can verify service health."),e.hasGraph||n.push("Create `.rapidkit/workspace-dependency-graph.json` or use analyze output as the first graph seed."),n.push("Run `rapidkit autopilot release --mode audit --json` before release."),Array.from(new Set(n))}async function ee(e={}){let n=r.resolve(e.workspacePath||process.cwd());if(!await y(n))throw new Error(`Workspace path does not exist: ${n}`);let t=I(n)??n,i=await y(r.join(t,".rapidkit-workspace"))||await y(r.join(t,".rapidkit","workspace.json")),s=await H(t),c=await S(t),a=await Promise.all(c.map(p=>_(t,p))),d=await M(a),m=W(a,d),f=[];i||f.push(h("workspace.marker.missing","warn",".","Workspace metadata is missing","The directory can be analyzed, but it is not a registered RapidKit workspace.","Run `rapidkit create workspace` or `rapidkit bootstrap --profile polyglot` in a workspace root.")),a.length===0&&f.push(h("workspace.projects.missing","fail",".","No backend projects detected","RapidKit did not find runtime markers or project metadata under this root.","Create a project with `rapidkit create project` or import one with `rapidkit import <path>`."));let u=[...f,...a.flatMap(p=>p.findings)],k=B(u),w={};for(let p of a)w[p.runtime]=(w[p.runtime]||0)+1;let A=a.length>0?Math.round(a.reduce((p,P)=>p+P.score,0)/a.length):0,z=f.reduce((p,P)=>p+(P.severity==="fail"?20:P.severity==="warn"?8:2),0),l=Math.max(0,A-z),R=k.fail>0||e.strict&&k.warn>0?"blocked":k.warn>0?"needs-attention":"ready",x={schemaVersion:"rapidkit-analyze-v1",generatedAt:new Date().toISOString(),workspacePath:t,workspaceDetected:i,profile:s,summary:{score:l,verdict:R,projectCount:a.length,runtimeCount:Object.keys(w).length,findings:k},runtimes:w,projects:a,dependencyGraph:{status:d.length>0?"generated":"empty",edges:d,topImpactedProjects:m.slice(0,5)},findings:u,nextActions:V({findings:u,projectCount:a.length,hasGraph:d.length>0}),enterpriseControls:{jsonReady:true,ciGateCommand:"rapidkit analyze --json --strict",releaseGateCommand:"rapidkit autopilot release --mode enforce --json",evidencePath:".rapidkit/reports/analyze-last-run.json"}};if(e.output&&(await g.promises.mkdir(r.dirname(r.resolve(e.output)),{recursive:true}),await g.promises.writeFile(r.resolve(e.output),`${JSON.stringify(x,null,2)}
2
2
  `)),!e.output&&i){let p=r.join(t,".rapidkit","reports","analyze-last-run.json");await g.promises.mkdir(r.dirname(p),{recursive:true}),await g.promises.writeFile(p,`${JSON.stringify(x,null,2)}
3
3
  `);}return x}function ne(e){let n=e.summary.verdict==="ready"?o.green:e.summary.verdict==="needs-attention"?o.yellow:o.red;if(console.log(o.bold(`
4
4
  RapidKit Workspace Analysis
@@ -1,4 +1,4 @@
1
- import {a}from'./chunk-3V47U5UZ.js';import n from'chalk';import W from'fs';import g from'path';import {execa}from'execa';function b(s){try{return JSON.parse(s)}catch{return null}}function ie(s){let t=g.resolve(s);for(;;){if(W.existsSync(g.join(t,".rapidkit-workspace"))||W.existsSync(g.join(t,".rapidkit","workspace.json")))return t;let a=g.dirname(t);if(a===t)return null;t=a;}}function le(s){let t=g.resolve(s),a=ie(t);if(!a)throw new Error("No RapidKit workspace found in current directory or parents");return a}async function S(s,t){let a=process.argv[1];if(!a)return {exitCode:1,stdout:"",stderr:"RapidKit entrypoint is unavailable for autopilot execution.",crashed:true};try{let o=await execa(process.execPath,[a,...s],{cwd:t,reject:false,env:{...process.env,RAPIDKIT_AUTOPILOT_CHILD:"1"}});return {exitCode:Number(o.exitCode??1),stdout:o.stdout,stderr:o.stderr,crashed:false}}catch(o){return {exitCode:1,stdout:"",stderr:o instanceof Error?o.message:String(o),crashed:true}}}function H(s){let t=s.toLowerCase();return t==="pass"?"pass":t==="warn"?"warn":t==="fail"?"fail":"warn"}function U(s){return s.summary.failed>0?"fail":s.gates.results.some(t=>t.status==="warn")?"warn":"pass"}function ce(s){let t=s.filter(o=>o.status!=="skipped");if(t.length===0)return 100;let a=t.reduce((o,r)=>r.status==="pass"?o+1:r.status==="warn"?o+.6:o,0);return Math.round(a/t.length*100)}function ue(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 N(s,t){await W.promises.mkdir(g.dirname(s),{recursive:true}),await W.promises.writeFile(s,`${JSON.stringify(t,null,2)}
1
+ import {a}from'./chunk-CXKXZUV6.js';import n from'chalk';import W from'fs';import g from'path';import {execa}from'execa';function b(s){try{return JSON.parse(s)}catch{return null}}function ie(s){let t=g.resolve(s);for(;;){if(W.existsSync(g.join(t,".rapidkit-workspace"))||W.existsSync(g.join(t,".rapidkit","workspace.json")))return t;let a=g.dirname(t);if(a===t)return null;t=a;}}function le(s){let t=g.resolve(s),a=ie(t);if(!a)throw new Error("No RapidKit workspace found in current directory or parents");return a}async function S(s,t){let a=process.argv[1];if(!a)return {exitCode:1,stdout:"",stderr:"RapidKit entrypoint is unavailable for autopilot execution.",crashed:true};try{let o=await execa(process.execPath,[a,...s],{cwd:t,reject:false,env:{...process.env,RAPIDKIT_AUTOPILOT_CHILD:"1"}});return {exitCode:Number(o.exitCode??1),stdout:o.stdout,stderr:o.stderr,crashed:false}}catch(o){return {exitCode:1,stdout:"",stderr:o instanceof Error?o.message:String(o),crashed:true}}}function H(s){let t=s.toLowerCase();return t==="pass"?"pass":t==="warn"?"warn":t==="fail"?"fail":"warn"}function U(s){return s.summary.failed>0?"fail":s.gates.results.some(t=>t.status==="warn")?"warn":"pass"}function ce(s){let t=s.filter(o=>o.status!=="skipped");if(t.length===0)return 100;let a=t.reduce((o,r)=>r.status==="pass"?o+1:r.status==="warn"?o+.6:o,0);return Math.round(a/t.length*100)}function ue(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 N(s,t){await W.promises.mkdir(g.dirname(s),{recursive:true}),await W.promises.writeFile(s,`${JSON.stringify(t,null,2)}
2
2
  `,"utf-8");}async function ke(s){let t=le(s.workspacePath),a$1=s.mode,o=[],r=[],M,F,E,J=0,f=false,I=0,T=0,_=Date.now(),x=await S(["doctor","workspace","--json"],t),q=Date.now()-_,u="pass";if(x.crashed)u="fail",f=true,r.push(`doctor workspace execution error: ${x.stderr||"unknown error"}`);else if(x.exitCode!==0)u="fail",r.push("doctor workspace command failed");else {let e=b(x.stdout),i=e&&e.healthScore&&typeof e.healthScore=="object"?e.healthScore:{},l=Number(i.errors??0),c=Number(i.warnings??0);Number.isFinite(l)&&l>0?(u="fail",r.push(`doctor workspace reports ${l} error(s)`)):Number.isFinite(c)&&c>0&&(u="warn");}let L=o.push({name:"doctor-workspace",status:u,durationMs:q,summary:u==="pass"?"doctor workspace passed":u==="warn"?"doctor workspace reported warnings":"doctor workspace reported errors"})-1;a$1==="enforce"&&u==="warn"&&r.push("doctor workspace reported warnings under enforce mode");let z=Date.now(),A=await S(["readiness","--json"],t),O=Date.now()-z,p="fail";if(A.crashed)p="fail",f=true,r.push(`readiness execution error: ${A.stderr||"unknown error"}`);else if(A.exitCode!==0)p="fail",r.push("readiness command failed");else {let e=b(A.stdout),i=String(e?.overallStatus??"fail");if(p=H(i),typeof e?.evidencePath=="string"&&e.evidencePath.trim().length>0&&(M=e.evidencePath),p==="fail"){let l=Array.isArray(e?.blockingReasons)?e?.blockingReasons.filter(c=>typeof c=="string"):[];l.length>0?r.push(...l.map(c=>`readiness: ${c}`)):r.push("readiness overall status is fail");}}let V=o.push({name:"readiness",status:p,durationMs:O,summary:`readiness overall status is ${p}`})-1;a$1==="enforce"&&p==="warn"&&r.push("readiness reported warnings under enforce mode");let Q=Date.now(),v=await S(["doctor","workspace","--plan","--json"],t),X=Date.now()-Q,w="warn";if(v.crashed)w="fail",f=true,r.push(`doctor remediation plan execution error: ${v.stderr||"unknown error"}`);else if(v.exitCode!==0)w="fail",r.push("doctor remediation plan command failed");else {let e=b(v.stdout),i=e&&e.remediationPlan&&typeof e.remediationPlan=="object"?e.remediationPlan:null,l=Number(i?.totalSteps??0),c=Number(i?.executableSteps??0);Number.isFinite(l)&&l>0&&(I=l),Number.isFinite(c)&&c>0&&(T=c),Number.isFinite(l)&&l===0?w="pass":w="warn";}if(o.push({name:"remediation-plan",status:w,durationMs:X,summary:w==="pass"?"no remediation steps required":"remediation steps available"}),a$1==="enforce"&&w==="warn"&&r.push("remediation plan has pending steps under enforce mode"),a$1==="safe-fix"){let e=Date.now(),i=await S(["doctor","workspace","--apply"],t),l=Date.now()-e,c=i.crashed||i.exitCode!==0?"fail":"pass";if(i.crashed)f=true,r.push(`doctor remediation apply execution error: ${i.stderr||"unknown error"}`);else if(c==="fail")r.push("doctor remediation apply failed");else {J=T>0?T:I>0?I:1;let $=await S(["doctor","workspace","--json"],t);if($.crashed)u="fail",f=true,r.push(`post-apply doctor execution error: ${$.stderr||"unknown error"}`);else if($.exitCode!==0)u="fail",r.push("post-apply doctor workspace command failed");else {let m=b($.stdout),C=m&&m.healthScore&&typeof m.healthScore=="object"?m.healthScore:{},R=Number(C.errors??0),y=Number(C.warnings??0);Number.isFinite(R)&&R>0?(u="fail",r.push(`post-apply doctor reports ${R} error(s)`)):Number.isFinite(y)&&y>0?u="warn":u="pass";}o[L].status=u,o[L].summary=`doctor workspace post-apply status is ${u}`;let D=await S(["readiness","--json"],t);if(D.crashed)p="fail",f=true,r.push(`post-apply readiness execution error: ${D.stderr||"unknown error"}`);else if(D.exitCode!==0)p="fail",r.push("post-apply readiness command failed");else {let m=b(D.stdout),C=String(m?.overallStatus??"fail");if(p=H(C),typeof m?.evidencePath=="string"&&m.evidencePath.trim().length>0&&(M=m.evidencePath),p==="fail"){let R=Array.isArray(m?.blockingReasons)?m?.blockingReasons.filter(y=>typeof y=="string"):[];R.length>0?r.push(...R.map(y=>`post-apply readiness: ${y}`)):r.push("post-apply readiness overall status is fail");}}o[V].status=p,o[V].summary=`readiness post-apply overall status is ${p}`;}o.push({name:"remediation-apply",status:c,durationMs:l,summary:c==="pass"?"safe remediation apply completed":"safe remediation apply failed"});}else o.push({name:"remediation-apply",status:"skipped",durationMs:0,summary:"remediation apply is skipped for this mode"});let Y=Date.now(),h="pass",k="workspace test/build completed for selected projects";try{let e=await a({workspacePath:t,stage:"test",affected:true,since:s.since,parallel:s.parallel,maxWorkers:s.maxWorkers,strict:true,json:true,enforceGates:false});F=g.join(t,".rapidkit","reports","autopilot-workspace-run-test.json"),await N(F,e);let i=U(e);if(i==="fail")h="fail",k="workspace test stage failed for selected projects",r.push("workspace run test failed for selected projects");else {i==="warn"&&(h="warn",k="workspace test stage completed with warnings",a$1==="enforce"&&r.push("workspace run test reported warnings under enforce mode"));let l=await a({workspacePath:t,stage:"build",affected:true,since:s.since,parallel:s.parallel,maxWorkers:s.maxWorkers,strict:true,json:true,enforceGates:false});E=g.join(t,".rapidkit","reports","autopilot-workspace-run-build.json"),await N(E,l);let c=U(l);c==="fail"?(h="fail",k="workspace build stage failed for selected projects",r.push("workspace run build failed for selected projects")):c==="warn"&&(h="warn",k="workspace test/build completed with warnings",a$1==="enforce"&&r.push("workspace run test/build reported warnings under enforce mode"));}}catch(e){h="fail",k="workspace test/build orchestration failed",f=true,r.push(`workspace run orchestration error: ${e instanceof Error?e.message:String(e)}`);}let Z=Date.now()-Y;o.push({name:"workspace-run-test-build",status:h,durationMs:Z,summary:k});let P=o.filter(e=>e.status==="warn").length,ee=o.filter(e=>e.status==="fail").length,B=a$1==="enforce"?o.some(e=>e.status==="warn"||e.status==="fail"):ee>0,j=[...new Set(r)],te=f||B?Math.max(1,j.length):0,se=ce(o),re=f||B?"blocked":P>0?"partial":"approved",oe=f?3:B?1:P>0?2:0,ae=ue({mode:a$1,executionError:f,blockers:j,hasWarnings:P>0}),G=g.join(t,".rapidkit","reports","autopilot-release-last-run.json"),d={schemaVersion:"autopilot-release-v1",generatedAt:new Date().toISOString(),workspacePath:t,mode:a$1,summary:{releaseScore:se,verdict:re,blockers:te,warnings:P,safeFixesApplied:J,manualActions:j.length,exitCode:oe},stages:o,blockingReasons:j,nextActions:ae,artifacts:{reportPath:G,readinessEvidencePath:M,workspaceRunTestPath:F,workspaceRunBuildPath:E}};if(await N(G,d),s.output&&await N(g.resolve(s.output),d),!s.json){console.log(n.bold.cyan(`
3
3
  \u{1F680} RapidKit Autopilot Release
4
4
  `)),console.log(n.bold(`Workspace: ${n.cyan(g.basename(t))}`)),console.log(n.gray(`Path: ${t}`)),console.log(n.white(`Mode: ${a$1}`)),console.log(n.white(`Verdict: ${d.summary.verdict==="approved"?n.green("approved"):d.summary.verdict==="partial"?n.yellow("partial"):n.red("blocked")}`)),console.log(n.white(`Release score: ${d.summary.releaseScore}`));for(let e of d.stages){let i=e.status==="pass"?n.green("PASS"):e.status==="warn"?n.yellow("WARN"):e.status==="skipped"?n.gray("SKIP"):n.red("FAIL");console.log(` - ${e.name}: ${i} ${e.summary} (${e.durationMs}ms)`);}if(d.blockingReasons.length>0){console.log(n.bold.red(`
@@ -0,0 +1 @@
1
+ import i from'path';import a from'fs-extra';var h="rapidkit.module-layout.v1",c="src/modules/free",f="src/modules/free/{category}/{module}",m="free/{category}/{module}",d="free/";function p(t){return t.replace(/\\/g,"/")}function g(t){return typeof t=="string"&&t.startsWith(d)}function P(t,s){if(!g(s))throw new Error(`Module slug must start with ${d}: ${s}`);let e=i.join(c,...s.split("/").slice(1));return i.join(t,e)}function R(t){if(!g(t))throw new Error(`Module slug must start with ${d}: ${t}`);return p(i.join(c,...t.split("/").slice(1)))}async function y(t){return await a.pathExists(t)?(await a.stat(t)).isDirectory():false}async function M(t){let s=i.join(t,"registry.json"),e=[],r=0;if(!await a.pathExists(s))return {status:"passed",projectCount:1,moduleCount:0,issues:e};let n=await a.readJson(s);for(let l of n.installed_modules||[]){let u=l?.slug;if(!g(u))continue;r+=1;let o=P(t,u);await y(o)||e.push({projectRoot:t,registryPath:s,slug:u,expectedPath:o,message:`Missing canonical module directory: ${p(i.relative(t,o))}`});}return {status:e.length>0?"failed":"passed",projectCount:1,moduleCount:r,issues:e}}async function A(t){let s=await x(t),e=[],r=[],n=0;for(let l of s){let u=i.dirname(l),o=await M(u);n+=o.moduleCount,r.push(...o.issues),e.push({projectRoot:u,moduleCount:o.moduleCount,issueCount:o.issues.length,status:o.status});}return {workspacePath:t,status:r.length>0?"failed":"passed",projectCount:e.length,moduleCount:n,issues:r,projects:e}}async function x(t){let s=await a.readdir(t,{withFileTypes:true}),e=[];for(let r of s){if(!r.isDirectory())continue;let n=i.join(t,r.name,"registry.json");await a.pathExists(n)&&e.push(n);}return e.sort()}function _(){return {schemaVersion:h,canonicalModuleRoot:c,pathPattern:f,slugPattern:m}}export{h as a,c as b,f as c,m as d,d as e,g as f,P as g,R as h,M as i,A as j,_ as k};