rapidkit 0.41.0 → 0.41.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 +12 -5
- package/contracts/extension-cli-compatibility.v1.json +1 -1
- package/contracts/workspace-intelligence/agent-action-outcome.v1.json +17 -1
- package/contracts/workspace-intelligence/workspace-dependency-graph.v1.json +61 -1
- package/dist/analyze-QYHMGLSG.js +1 -0
- package/dist/autopilot-release-AHMQEUFH.js +1 -0
- package/dist/{chunk-WA6JYVJM.js → chunk-33LR2QEM.js} +1 -1
- package/dist/{chunk-DMUEGR36.js → chunk-3PTJID76.js} +1 -1
- package/dist/chunk-46AGNYI7.js +50 -0
- package/dist/chunk-AQ4XZZC6.js +1 -0
- package/dist/{chunk-MGUJWRZA.js → chunk-BFEBZABL.js} +3 -3
- package/dist/chunk-CDPR2YKL.js +13 -0
- package/dist/{chunk-73IS6RIM.js → chunk-CKXJR3YT.js} +1 -1
- package/dist/chunk-E5ZVQL3C.js +13 -0
- package/dist/chunk-ELU3G6DQ.js +9 -0
- package/dist/chunk-EN6YCX36.js +1 -0
- package/dist/chunk-FMBSON6H.js +33 -0
- package/dist/chunk-GBJBQ43T.js +1 -0
- package/dist/{chunk-FPUNOIAR.js → chunk-ITJ6RKUW.js} +3 -3
- package/dist/{chunk-XOVB2ZP5.js → chunk-JU3VNLTY.js} +1 -1
- package/dist/chunk-JW2FSKT3.js +2 -0
- package/dist/{chunk-44GSDNPQ.js → chunk-KIUSCFHF.js} +1 -1
- package/dist/{chunk-AT3EQ2S7.js → chunk-LKX3L7TE.js} +1 -1
- package/dist/{chunk-KTQZUWAM.js → chunk-RSYUNEH7.js} +13 -13
- package/dist/chunk-TJN7G2MA.js +1 -0
- package/dist/{chunk-Y2SCTWL4.js → chunk-UQR6G7KH.js} +2 -2
- package/dist/chunk-WRMCPKGA.js +1 -0
- package/dist/{create-UGXMC4CT.js → create-RNP5ACQL.js} +1 -1
- package/dist/demo-kit-N5U3NGAE.js +149 -0
- package/dist/{doctor-LCKG5S76.js → doctor-XM6QDTDC.js} +1 -1
- package/dist/index.js +118 -117
- package/dist/{pipeline-MKNYPNGD.js → pipeline-DH6Z47O4.js} +1 -1
- package/dist/platform-capabilities-TSLK667K.js +1 -0
- package/dist/{pythonRapidkitExec-MNWRC4F2.js → pythonRapidkitExec-SGKW76XM.js} +1 -1
- package/dist/{workspace-FDMJD5XI.js → workspace-E554C5SM.js} +1 -1
- package/dist/{workspace-agent-sync-WJIZCZX5.js → workspace-agent-sync-2HRPM5ZD.js} +1 -1
- package/dist/{workspace-context-RYOQYGOP.js → workspace-context-VJTXW3K4.js} +1 -1
- package/dist/{workspace-contract-ITFCJCHI.js → workspace-contract-OO4GMENV.js} +1 -1
- package/dist/workspace-explain-3WSJLIJ6.js +1 -0
- package/dist/workspace-explain-contract-24RQ7KIW.js +1 -0
- package/dist/{workspace-foundation-SILFUKL5.js → workspace-foundation-LISDH53T.js} +1 -1
- package/dist/{workspace-intelligence-YOZQBAK5.js → workspace-intelligence-E3KXEZCM.js} +1 -1
- package/dist/workspace-mcp-serve-RFYDCA2L.js +3 -0
- package/dist/{workspace-model-VMMLHJWI.js → workspace-model-YL7W3573.js} +1 -1
- package/dist/workspace-registry-summary-X5WRUU3T.js +1 -0
- package/dist/workspace-run-GCIQD73R.js +1 -0
- package/dist/workspace-verify-NRYH7RNB.js +1 -0
- package/dist/{workspace-watch-3MEZRSEE.js → workspace-watch-H2AETGFI.js} +1 -1
- package/docs/DEVELOPMENT.md +1 -1
- package/docs/OPEN_SOURCE_USER_SCENARIOS.md +1 -1
- package/docs/README.md +1 -1
- package/docs/commands-reference.md +10 -2
- package/package.json +7 -3
- package/scripts/enterprise-package-smoke.mjs +427 -0
- package/scripts/prepack-enterprise.mjs +40 -0
- package/templates/generator.js +175 -0
- package/templates/kits/fastapi-ddd/README.md.j2 +122 -0
- package/templates/kits/fastapi-ddd/common/env.example.j2 +10 -0
- package/templates/kits/fastapi-ddd/env.example.j2 +1 -0
- package/templates/kits/fastapi-ddd/pyproject.toml.j2 +64 -0
- package/templates/kits/fastapi-ddd/src/__init__.py.j2 +3 -0
- package/templates/kits/fastapi-ddd/src/app/__init__.py.j2 +11 -0
- package/templates/kits/fastapi-ddd/src/app/application/__init__.py.j2 +5 -0
- package/templates/kits/fastapi-ddd/src/app/application/interfaces.py.j2 +43 -0
- package/templates/kits/fastapi-ddd/src/app/application/use_cases/__init__.py.j2 +6 -0
- package/templates/kits/fastapi-ddd/src/app/application/use_cases/health.py.j2 +14 -0
- package/templates/kits/fastapi-ddd/src/app/application/use_cases/notes.py.j2 +24 -0
- package/templates/kits/fastapi-ddd/src/app/config/__init__.py.j2 +16 -0
- package/templates/kits/fastapi-ddd/src/app/domain/__init__.py.j2 +3 -0
- package/templates/kits/fastapi-ddd/src/app/domain/models/__init__.py.j2 +6 -0
- package/templates/kits/fastapi-ddd/src/app/domain/models/health.py.j2 +16 -0
- package/templates/kits/fastapi-ddd/src/app/domain/models/note.py.j2 +27 -0
- package/templates/kits/fastapi-ddd/src/app/infrastructure/__init__.py.j2 +5 -0
- package/templates/kits/fastapi-ddd/src/app/infrastructure/repositories/__init__.py.j2 +6 -0
- package/templates/kits/fastapi-ddd/src/app/infrastructure/repositories/health.py.j2 +17 -0
- package/templates/kits/fastapi-ddd/src/app/infrastructure/repositories/notes.py.j2 +28 -0
- package/templates/kits/fastapi-ddd/src/app/main.py.j2 +61 -0
- package/templates/kits/fastapi-ddd/src/app/presentation/__init__.py.j2 +3 -0
- package/templates/kits/fastapi-ddd/src/app/presentation/api/__init__.py.j2 +5 -0
- package/templates/kits/fastapi-ddd/src/app/presentation/api/dependencies/__init__.py.j2 +19 -0
- package/templates/kits/fastapi-ddd/src/app/presentation/api/router.py.j2 +10 -0
- package/templates/kits/fastapi-ddd/src/app/presentation/api/routes/__init__.py.j2 +5 -0
- package/templates/kits/fastapi-ddd/src/app/presentation/api/routes/health.py.j2 +27 -0
- package/templates/kits/fastapi-ddd/src/app/presentation/api/routes/notes.py.j2 +50 -0
- package/templates/kits/fastapi-ddd/src/app/shared/__init__.py.j2 +5 -0
- package/templates/kits/fastapi-ddd/src/app/shared/result.py.j2 +28 -0
- package/templates/kits/fastapi-ddd/src/cli.py.j2 +167 -0
- package/templates/kits/fastapi-ddd/src/main.py.j2 +35 -0
- package/templates/kits/fastapi-ddd/src/modules/__init__.py.j2 +3 -0
- package/templates/kits/fastapi-ddd/src/routing/__init__.py.j2 +13 -0
- package/templates/kits/fastapi-ddd/src/routing/health.py.j2 +7 -0
- package/templates/kits/fastapi-ddd/src/routing/notes.py.j2 +7 -0
- package/templates/kits/fastapi-ddd/tests/__init__.py.j2 +1 -0
- package/templates/kits/fastapi-ddd/tests/test_app_factory.py.j2 +22 -0
- package/templates/kits/fastapi-ddd/tests/test_health.py.j2 +17 -0
- package/templates/kits/fastapi-ddd/tests/test_notes.py.j2 +27 -0
- package/templates/kits/fastapi-standard/README.md.j2 +145 -0
- package/templates/kits/fastapi-standard/common/env.example.j2 +10 -0
- package/templates/kits/fastapi-standard/env.example.j2 +1 -0
- package/templates/kits/fastapi-standard/pyproject.toml.j2 +64 -0
- package/templates/kits/fastapi-standard/src/__init__.py.j2 +3 -0
- package/templates/kits/fastapi-standard/src/cli.py.j2 +168 -0
- package/templates/kits/fastapi-standard/src/main.py.j2 +66 -0
- package/templates/kits/fastapi-standard/src/modules/__init__.py.j2 +3 -0
- package/templates/kits/fastapi-standard/src/routing/__init__.py.j2 +16 -0
- package/templates/kits/fastapi-standard/src/routing/examples.py.j2 +71 -0
- package/templates/kits/fastapi-standard/src/routing/health.py.j2 +22 -0
- package/templates/kits/fastapi-standard/tests/__init__.py.j2 +1 -0
- package/templates/kits/fastapi-standard/tests/test_examples.py.j2 +29 -0
- package/templates/kits/fastapi-standard/tests/test_health.py.j2 +17 -0
- package/templates/kits/nestjs-standard/Dockerfile.j2 +41 -0
- package/templates/kits/nestjs-standard/README.md.j2 +139 -0
- package/templates/kits/nestjs-standard/docker-compose.yml.j2 +94 -0
- package/templates/kits/nestjs-standard/docs/README.md.j2 +15 -0
- package/templates/kits/nestjs-standard/env.example.j2 +18 -0
- package/templates/kits/nestjs-standard/eslint.config.cjs.j2 +9 -0
- package/templates/kits/nestjs-standard/jest.config.ts.j2 +22 -0
- package/templates/kits/nestjs-standard/nest-cli.json.j2 +10 -0
- package/templates/kits/nestjs-standard/package.json.j2 +101 -0
- package/templates/kits/nestjs-standard/src/app.controller.ts.j2 +14 -0
- package/templates/kits/nestjs-standard/src/app.module.ts.j2 +26 -0
- package/templates/kits/nestjs-standard/src/app.service.ts.j2 +16 -0
- package/templates/kits/nestjs-standard/src/auth/auth.controller.ts.j2 +20 -0
- package/templates/kits/nestjs-standard/src/auth/auth.module.ts.j2 +13 -0
- package/templates/kits/nestjs-standard/src/auth/auth.service.ts.j2 +6 -0
- package/templates/kits/nestjs-standard/src/auth/entities/token.entity.ts.j2 +3 -0
- package/templates/kits/nestjs-standard/src/auth/entities/user.entity.ts.j2 +3 -0
- package/templates/kits/nestjs-standard/src/auth/entities/webauthn.entity.ts.j2 +3 -0
- package/templates/kits/nestjs-standard/src/config/configuration.ts.j2 +85 -0
- package/templates/kits/nestjs-standard/src/config/index.ts.j2 +2 -0
- package/templates/kits/nestjs-standard/src/config/validation.ts.j2 +21 -0
- package/templates/kits/nestjs-standard/src/examples/dto/create-note.dto.ts.j2 +11 -0
- package/templates/kits/nestjs-standard/src/examples/examples.controller.ts.j2 +24 -0
- package/templates/kits/nestjs-standard/src/examples/examples.module.ts.j2 +10 -0
- package/templates/kits/nestjs-standard/src/examples/examples.service.ts.j2 +33 -0
- package/templates/kits/nestjs-standard/src/main.ts.j2 +53 -0
- package/templates/kits/nestjs-standard/src/modules/index.ts.j2 +25 -0
- package/templates/kits/nestjs-standard/test/app.controller.spec.ts.j2 +24 -0
- package/templates/kits/nestjs-standard/test/app.e2e-spec.ts.j2 +60 -0
- package/templates/kits/nestjs-standard/test/examples.controller.spec.ts.j2 +28 -0
- package/templates/kits/nestjs-standard/test/jest-e2e.json.j2 +15 -0
- package/templates/kits/nestjs-standard/tsconfig.build.json.j2 +12 -0
- package/templates/kits/nestjs-standard/tsconfig.json.j2 +26 -0
- package/dist/analyze-JVMUCQ22.js +0 -1
- package/dist/autopilot-release-GM5ALPWO.js +0 -1
- package/dist/chunk-424B73UF.js +0 -1
- package/dist/chunk-56RL5OB6.js +0 -2
- package/dist/chunk-AO6PG3K2.js +0 -9
- package/dist/chunk-FVCZGUVX.js +0 -1
- package/dist/chunk-GX7UU7LL.js +0 -33
- package/dist/chunk-P5ODFWB2.js +0 -13
- package/dist/chunk-QN2LPLHO.js +0 -1
- package/dist/chunk-RIZCWYRR.js +0 -1
- package/dist/chunk-YOQ2546V.js +0 -50
- package/dist/chunk-Z5LKRG57.js +0 -1
- package/dist/chunk-ZQRFVFKK.js +0 -13
- package/dist/demo-kit-2VI4H6OJ.js +0 -141
- package/dist/workspace-explain-VKSUKP3O.js +0 -1
- package/dist/workspace-explain-contract-CLHQ3XEH.js +0 -1
- package/dist/workspace-mcp-serve-OOLITFCK.js +0 -3
- package/dist/workspace-registry-summary-ZXGKL2NT.js +0 -1
- package/dist/workspace-run-IHB2TPMD.js +0 -1
- package/dist/workspace-verify-3CAKAZIL.js +0 -1
package/README.md
CHANGED
|
@@ -38,8 +38,8 @@ npx rapidkit my-workspace --yes --profile polyglot
|
|
|
38
38
|
cd ~/rapidkit/workspaces/my-workspace
|
|
39
39
|
|
|
40
40
|
npx rapidkit bootstrap --profile polyglot
|
|
41
|
-
npx rapidkit create project
|
|
42
|
-
npx rapidkit create
|
|
41
|
+
npx rapidkit create project nextjs my-web --yes
|
|
42
|
+
npx rapidkit create project fastapi.standard my-api --yes
|
|
43
43
|
|
|
44
44
|
npx rapidkit workspace model --json
|
|
45
45
|
npx rapidkit workspace context --for-agent --json --write
|
|
@@ -413,13 +413,20 @@ cd ~/rapidkit/workspaces/my-workspace
|
|
|
413
413
|
|
|
414
414
|
npx rapidkit bootstrap --profile polyglot
|
|
415
415
|
npx rapidkit create project # interactive kit picker
|
|
416
|
-
npx rapidkit create
|
|
416
|
+
npx rapidkit create project nextjs my-web --yes
|
|
417
|
+
npx rapidkit create project fastapi.standard my-api --yes
|
|
417
418
|
cd <project-name> && npx rapidkit init && npx rapidkit dev
|
|
418
419
|
```
|
|
419
420
|
|
|
420
421
|
Backend kits: `fastapi.standard`, `nestjs.standard`, `springboot.standard`, `gofiber.standard`, `dotnet.webapi.clean`, and more.
|
|
421
422
|
|
|
422
|
-
Frontend: `
|
|
423
|
+
Frontend kits: `nextjs`, `remix`, `vite-react`, `nuxt`, `angular`, `astro`, `sveltekit`, and more — same command shape:
|
|
424
|
+
|
|
425
|
+
```bash
|
|
426
|
+
npx rapidkit create project <kit> <name>
|
|
427
|
+
```
|
|
428
|
+
|
|
429
|
+
(`create frontend <id>` remains supported as an alias.)
|
|
423
430
|
|
|
424
431
|
Shortcut: `npx rapidkit platform` (interactive workspace wizard).
|
|
425
432
|
|
|
@@ -484,7 +491,7 @@ Search **Workspai** in the marketplace or install via:
|
|
|
484
491
|
| Enterprise evidence loop | Partial | Full dashboard |
|
|
485
492
|
| Module catalog (FastAPI/NestJS) | Limited | Browser UI |
|
|
486
493
|
|
|
487
|
-
The extension invokes this npm CLI. For the latest `adopt` and
|
|
494
|
+
The extension invokes this npm CLI. For the latest `adopt` and frontend generator features, install matching CLI version: `npm install -g rapidkit@latest` or `npm link` from this repo ([Development](#development)).
|
|
488
495
|
|
|
489
496
|
## Documentation
|
|
490
497
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"schemaVersion": "rapidkit-extension-cli-compatibility.v1",
|
|
3
3
|
"cli": "rapidkit-npm",
|
|
4
|
-
"minimumVerifiedCliVersion": "0.41.
|
|
4
|
+
"minimumVerifiedCliVersion": "0.41.1",
|
|
5
5
|
"publishedContractSchemas": {
|
|
6
6
|
"runtimeCommandSurface": "rapidkit-runtime-command-surface-v1",
|
|
7
7
|
"cliLogEvent": "cli-log-event-v1",
|
|
@@ -16,7 +16,23 @@
|
|
|
16
16
|
"verifyBefore": { "type": "string" },
|
|
17
17
|
"verifyAfter": { "type": "string" },
|
|
18
18
|
"evidenceSha256": { "type": "string", "pattern": "^[a-f0-9]{64}$" },
|
|
19
|
-
"evidencePath": { "type": "string" }
|
|
19
|
+
"evidencePath": { "type": "string" },
|
|
20
|
+
"patchMetadata": {
|
|
21
|
+
"type": "object",
|
|
22
|
+
"required": ["appliedCount", "rejectedCount", "failedCount", "affectedFiles"],
|
|
23
|
+
"properties": {
|
|
24
|
+
"patchId": { "type": "string" },
|
|
25
|
+
"sourceAction": { "enum": ["auto-fix", "apply-patch"] },
|
|
26
|
+
"reviewRequired": { "type": "boolean" },
|
|
27
|
+
"branchCreated": { "type": "string" },
|
|
28
|
+
"appliedCount": { "type": "integer", "minimum": 0 },
|
|
29
|
+
"rejectedCount": { "type": "integer", "minimum": 0 },
|
|
30
|
+
"failedCount": { "type": "integer", "minimum": 0 },
|
|
31
|
+
"affectedFiles": { "type": "array", "items": { "type": "string" } },
|
|
32
|
+
"rollbackCommand": { "type": "string" }
|
|
33
|
+
},
|
|
34
|
+
"additionalProperties": false
|
|
35
|
+
}
|
|
20
36
|
},
|
|
21
37
|
"additionalProperties": false
|
|
22
38
|
}
|
|
@@ -23,7 +23,33 @@
|
|
|
23
23
|
"path": { "type": "string", "minLength": 1 },
|
|
24
24
|
"runtime": { "type": "string" },
|
|
25
25
|
"framework": { "type": "string" },
|
|
26
|
-
"kind": { "type": "string" }
|
|
26
|
+
"kind": { "type": "string" },
|
|
27
|
+
"operationalProfile": {
|
|
28
|
+
"type": "object",
|
|
29
|
+
"required": ["weight", "score", "verificationPriority", "reasons", "centrality"],
|
|
30
|
+
"properties": {
|
|
31
|
+
"weight": { "enum": ["low", "medium", "high", "critical"] },
|
|
32
|
+
"score": { "type": "integer", "minimum": 0, "maximum": 100 },
|
|
33
|
+
"verificationPriority": { "enum": ["normal", "elevated", "strict"] },
|
|
34
|
+
"reasons": {
|
|
35
|
+
"type": "array",
|
|
36
|
+
"items": { "type": "string" }
|
|
37
|
+
},
|
|
38
|
+
"centrality": {
|
|
39
|
+
"type": "object",
|
|
40
|
+
"required": ["fanIn", "fanOut", "reach", "betweenness", "isHotspot"],
|
|
41
|
+
"properties": {
|
|
42
|
+
"fanIn": { "type": "integer", "minimum": 0 },
|
|
43
|
+
"fanOut": { "type": "integer", "minimum": 0 },
|
|
44
|
+
"reach": { "type": "integer", "minimum": 0 },
|
|
45
|
+
"betweenness": { "type": "number", "minimum": 0 },
|
|
46
|
+
"isHotspot": { "type": "boolean" }
|
|
47
|
+
},
|
|
48
|
+
"additionalProperties": true
|
|
49
|
+
}
|
|
50
|
+
},
|
|
51
|
+
"additionalProperties": true
|
|
52
|
+
}
|
|
27
53
|
},
|
|
28
54
|
"additionalProperties": true
|
|
29
55
|
}
|
|
@@ -75,6 +101,14 @@
|
|
|
75
101
|
"inferredEdges",
|
|
76
102
|
"contractEdges",
|
|
77
103
|
"manualEdges",
|
|
104
|
+
"authoritativeEdges",
|
|
105
|
+
"lowConfidenceEdges",
|
|
106
|
+
"orphanCount",
|
|
107
|
+
"connectedNodeCount",
|
|
108
|
+
"density",
|
|
109
|
+
"edgeCoverageRatio",
|
|
110
|
+
"evidenceCoverageRatio",
|
|
111
|
+
"hotspotCount",
|
|
78
112
|
"hasCycle"
|
|
79
113
|
],
|
|
80
114
|
"properties": {
|
|
@@ -83,9 +117,35 @@
|
|
|
83
117
|
"inferredEdges": { "type": "integer", "minimum": 0 },
|
|
84
118
|
"contractEdges": { "type": "integer", "minimum": 0 },
|
|
85
119
|
"manualEdges": { "type": "integer", "minimum": 0 },
|
|
120
|
+
"authoritativeEdges": { "type": "integer", "minimum": 0 },
|
|
121
|
+
"lowConfidenceEdges": { "type": "integer", "minimum": 0 },
|
|
122
|
+
"orphanCount": { "type": "integer", "minimum": 0 },
|
|
123
|
+
"connectedNodeCount": { "type": "integer", "minimum": 0 },
|
|
124
|
+
"density": { "type": "number", "minimum": 0 },
|
|
125
|
+
"edgeCoverageRatio": { "type": "number", "minimum": 0, "maximum": 1 },
|
|
126
|
+
"evidenceCoverageRatio": { "type": "number", "minimum": 0, "maximum": 1 },
|
|
127
|
+
"hotspotCount": { "type": "integer", "minimum": 0 },
|
|
86
128
|
"hasCycle": { "type": "boolean" }
|
|
87
129
|
},
|
|
88
130
|
"additionalProperties": true
|
|
131
|
+
},
|
|
132
|
+
"diagnostics": {
|
|
133
|
+
"type": "array",
|
|
134
|
+
"items": {
|
|
135
|
+
"type": "object",
|
|
136
|
+
"required": ["code", "severity", "message"],
|
|
137
|
+
"properties": {
|
|
138
|
+
"code": { "type": "string", "minLength": 1 },
|
|
139
|
+
"severity": { "enum": ["info", "warning", "error"] },
|
|
140
|
+
"message": { "type": "string", "minLength": 1 },
|
|
141
|
+
"recommendation": { "type": "string" },
|
|
142
|
+
"nodeIds": {
|
|
143
|
+
"type": "array",
|
|
144
|
+
"items": { "type": "string", "minLength": 1 }
|
|
145
|
+
}
|
|
146
|
+
},
|
|
147
|
+
"additionalProperties": true
|
|
148
|
+
}
|
|
89
149
|
}
|
|
90
150
|
},
|
|
91
151
|
"additionalProperties": true
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{b as printAnalyzeReport,a as runAnalyze}from'./chunk-ELU3G6DQ.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{b as AUTOPILOT_RELEASE_ALIAS_FILENAME,a as AUTOPILOT_RELEASE_LAST_RUN_FILENAME,c as runAutopilotRelease}from'./chunk-CKXJR3YT.js';
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {j as j$1}from'./chunk-
|
|
1
|
+
import {j as j$1}from'./chunk-EN6YCX36.js';import {a}from'./chunk-3PTJID76.js';import d from'path';import g from'fs-extra';var f="workspace-context.v1",w=".rapidkit/reports/workspace-context-agent.json";function h(e){if(typeof e!="string"||!e.trim()||e==="true")return "generic";let t=e.trim().toLowerCase();return t==="codex"||t==="claude"||t==="cursor"||t==="orca"?t:"generic"}function y(e){return `npx --yes --package rapidkit rapidkit ${e}`.trim()}function j(e){return `npx rapidkit ${e}`.trim()}function i(e){return {id:e.id,scope:e.scope,display:j(e.args),execute:y(e.args),description:e.description,...e.project?{project:e.project}:{}}}function k(e,t){return `workspace run ${t} --scope project:${e.name}`}function C(e){return (e.startsWith("project:")?e.slice(8):e).trim().toLowerCase()}function v(e){return [e.name,e.path,d.basename(e.path),e.absolutePath].filter(t=>typeof t=="string"&&t.trim().length>0).map(t=>t.trim().toLowerCase())}function x(e,t){let s=[i({id:"workspace.model",scope:"workspace",args:"workspace model --json",description:"Read the canonical workspace intelligence model."}),i({id:"workspace.doctor",scope:"workspace",args:"doctor workspace --json",description:"Check workspace health before claiming verification."}),i({id:"workspace.pipeline",scope:"workspace",args:"pipeline --json",description:"Run the governed sync, doctor, analyze, readiness, and autopilot loop."}),i({id:"workspace.contract.verify",scope:"workspace",args:"workspace contract verify --json",description:"Verify workspace contract and dependency edges."}),i({id:"workspace.verify",scope:"workspace",args:"workspace verify --json",description:"Evaluate evidence freshness and verification gates before release decisions."})],r=t?[t]:e.projects;for(let o of r)o.commands.fleetStages.includes("test")&&s.push(i({id:`project.${o.name}.test`,scope:"project",project:o.name,args:k(o,"test"),description:`Run tests for ${o.name} through workspace orchestration.`})),o.commands.fleetStages.includes("build")&&s.push(i({id:`project.${o.name}.build`,scope:"project",project:o.name,args:k(o,"build"),description:`Build ${o.name} through workspace orchestration.`}));return s}function W(e){return e.commands.fleetStages.filter(t=>t==="test"||t==="build").map(t=>`workspace run ${t}`)}function b(e,t){if(!t?.startsWith("project:"))return;let s=C(t);if(s)return e.projects.find(r=>v(r).includes(s))}function S(e,t,s){let r=[...e.validation?.issues??[]];t?.startsWith("project:")&&!s&&r.push({severity:"error",code:"context.scope.project.missing",message:`Requested project scope was not found: ${t}`,target:t});let o=r.filter(a=>a.severity==="error").length,c=r.filter(a=>a.severity==="warning").length;return {status:o>0?"failed":c>0?"warning":"passed",errors:o,warnings:c,issues:r}}function P(e){let t=[],s=[];for(let[r,o]of Object.entries(e.evidence))o?.exists?t.push(`${r}: ${o.path}`):s.push(r);return {available:t.sort(),missing:s.sort()}}function A(e){let t=e.summary.projectCount,s=e.summary.runtimes.length?e.summary.runtimes.join(", "):"no runtime",r=e.identity.surfaces.length?e.identity.surfaces.join(", "):"no detected surfaces";return `${e.workspace.name} is a ${e.identity.workspaceType} with ${t} project${t===1?"":"s"}, ${s} runtime coverage, and ${r}.`}function M(e){let t=["Do not claim a command passed unless a report or command output proves it.","Do not infer secrets or environment values from file names.","Do not change project scope without checking the selected project."];return e.contracts.exists||t.push("Workspace contract is missing; dependency and API edges may be incomplete."),e.summary.observedProjects>0&&t.push("Some projects are observed rather than first-class; command support may be partial."),t}async function V(e){let t=e.model??await j$1({workspacePath:e.workspacePath,includeEvidence:e.includeEvidence===true,observableScanDepth:e.observableScanDepth,now:e.now}),s=h(e.agent),r=b(t,e.scope),o=S(t,e.scope,r);if(e.strict===true&&o.status!=="passed"){let n=o.issues.map(p=>`${p.severity}:${p.code}:${p.target}`).join(", ");throw new Error(`Workspace context strict validation failed: ${n}`)}let c=(r?[r]:t.projects).map(n=>({name:n.name,path:n.path,kind:n.kind,runtime:n.runtime,framework:n.frameworkDisplayName,...n.generator?{generator:n.generator}:{},createCapability:n.createCapability,supportTier:n.supportTier,safeCommands:W(n),importantFiles:n.importantFiles})),a=P(t),m=A(t);return {schemaVersion:f,generatedAt:(e.now??new Date).toISOString(),agent:s,workspaceSummary:m,modelRef:".rapidkit/reports/workspace-model.json",workspace:{name:t.workspace.name,root:t.workspace.root,type:t.identity.workspaceType,...t.workspace.profile?{profile:t.workspace.profile}:{}},scope:{requested:e.scope??"workspace",...r?{activeProject:r.name}:{}},projects:c,safeCommands:x(t,r),evidence:a,policies:{mode:t.policies.mode,source:t.policies.source},contracts:{exists:t.contracts.exists,path:t.contracts.workspaceContractPath},validation:o,agentInstructions:["Read `.rapidkit/reports/INDEX.json` first, then this context pack and linked evidence reports.","Use this context as the workspace source of truth before inspecting random files.","Prefer workspace-level evidence over generic framework assumptions.","Use `display` commands when explaining steps to a human.","Use `execute` commands when launching commands from automation or tooling.","Keep project-scoped advice tied to the active project scope.","Regenerate stale grounding with `npx rapidkit workspace agent-sync --write --refresh-context`."],unsafeAssumptions:M(t),humanSummary:[m,`Evidence available: ${a.available.length}. Missing evidence groups: ${a.missing.join(", ")||"none"}.`,r?`Active project scope: ${r.name} (${r.frameworkDisplayName}).`:"Scope: whole workspace."].join(`
|
|
2
2
|
`)}}async function N(e,t){let s=d.join(t,w);return await g.ensureDir(d.dirname(s)),await g.writeJSON(s,a(e),{spaces:2}),s}export{f as a,w as b,V as c,N as d};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {e}from'./chunk-MIWDCR6I.js';import {a as a$1}from'./chunk-HHJAANUC.js';import {l}from'./chunk-OCGZNSOE.js';import a from'path';import d from'fs-extra';var _="unknown-run";function A(e$1){let r=e();return !r||r===_?e$1:{...e$1,runId:r}}var j=".rapidkit/workspace.contract.json",V=".rapidkit/reports/workspace-contract-verify-last-run.json",P=1,N="workspace-contract-verify.v1";function E(e){return e.replace(/\\/g,"/")}function C(e){let r=E(e).trim();return !r||r.startsWith("/")||r.startsWith("~")||/^[a-zA-Z]:\//.test(r)||r.includes("\0")?false:!r.split("/").filter(Boolean).some(o=>o===".."||o===".")}function I(e,r){return e.trim().toLowerCase().replace(/[^a-z0-9._-]+/g,"-").replace(/-+/g,"-").replace(/^[-_.]+|[-_.]+$/g,"").slice(0,80)||r}function J(e){return Array.isArray(e)?e.filter(r=>typeof r=="string"&&r.trim().length>0):[]}async function T(e){let r=a.join(e,".rapidkit","workspace.json");try{let o=await d.readJson(r);return {name:typeof o.workspace_name=="string"&&o.workspace_name.trim()||typeof o.name=="string"&&o.name.trim()||a.basename(e),profile:typeof o.profile=="string"?o.profile:void 0}}catch{return {name:a.basename(e)}}}async function D(e){let r=[],o=[e],n=new Set,i=new Set([".git","node_modules",".venv","venv","dist","build","target",".next",".turbo",".cache"]);for(;o.length>0;){let c=o.shift();if(!c||n.has(c))continue;n.add(c);let p=a.join(c,".rapidkit","project.json"),u=a.join(c,".rapidkit","context.json");if(await d.pathExists(p)||await d.pathExists(u)){r.push(await d.pathExists(p)?p:u);continue}let t;try{t=await d.readdir(c,{withFileTypes:true});}catch{continue}for(let s of t)!s.isDirectory()||i.has(s.name)||o.push(a.join(c,s.name));}return r.sort()}function G(e){let r=(e||"").toLowerCase();if(r.includes("fastapi"))return "fastapi";if(r.includes("nestjs"))return "nestjs";if(r.includes("springboot"))return "springboot";if(r.includes("gofiber"))return "fiber";if(r.includes("gogin"))return "gin"}function K(e,r){let o=(e||"").toLowerCase(),n=(r||"").toLowerCase();return o.includes("fastapi")?8e3:o.includes("nestjs")?3e3:o.includes("springboot")?8080:o.includes("gofiber")?3e3:o.includes("gogin")?8080:n==="node"?3e3:n==="python"?8e3:n==="java"||n==="go"?8080:null}function F(e,r){let o=e;for(;r.has(o)&&o<65535;)o+=1;return o}function w(e,r,o){let n=K(r.kit,r.runtime),i=e?.ports||[],c=i.length>0?i:n?[{name:"http",port:F(n,o),protocol:"http"}]:[];for(let t of c)o.add(t.port);let p={...r,...e,slug:e?.slug||r.slug,relativePath:e?.relativePath&&C(e.relativePath)?e.relativePath:r.relativePath,source:e?.source||r.source,relationship:e?.relationship||r.relationship,externalPath:e?.externalPath||r.externalPath,runtime:e?.runtime||r.runtime,framework:e?.framework||r.framework,kit:e?.kit||r.kit,modules:e?.modules?.length?e.modules:r.modules,ports:c,contracts:{owns:e?.contracts?.owns||[],apis:e?.contracts?.apis||[],publishes:e?.contracts?.publishes||[],consumes:e?.contracts?.consumes||[],dependsOn:e?.contracts?.dependsOn||[],env:e?.contracts?.env||[]}},u=JSON.stringify(e||null)!==JSON.stringify(p);return {project:p,changed:u}}async function S(e){let r=a.resolve(e.workspacePath),o=await T(r),n=await D(r),i=await a$1(r),c=[];for(let t of i){let s=a.resolve(t.path),h=a.join(s,".rapidkit","project.json"),f=a.join(s,".rapidkit","context.json"),k=await d.pathExists(h)?h:await d.pathExists(f)?f:null;!k||n.some(l=>a.resolve(l)===a.resolve(k))||c.push({projectJsonPath:k,registryEntry:t});}let p=[],u=[...n.map(t=>({projectJsonPath:t})),...c];for(let{projectJsonPath:t,registryEntry:s}of u){let h=a.dirname(a.dirname(t)),f=E(a.relative(r,h)),k=s!==void 0&&!C(f),l=I(s?.name||a.basename(h),a.basename(h)),m=k?`external/${l}`:f||l,g=await d.readJson(t),y=typeof g.kit_name=="string"&&g.kit_name||typeof g.kit=="string"&&g.kit||void 0,x=typeof g.framework=="string"&&g.framework||G(y);p.push({slug:s?.name||m||a.basename(h),relativePath:m,source:s?.source??"workspace",relationship:s?.relationship,externalPath:k?h:void 0,runtime:typeof g.runtime=="string"?g.runtime:void 0,framework:x,kit:y,modules:J(g.modules),ports:[],contracts:{owns:[],apis:[],publishes:[],consumes:[],dependsOn:[],env:[]}});}return {schemaVersion:P,kind:"rapidkit.workspace.contract",generatedAt:(e.now??new Date).toISOString(),workspace:o,projects:p}}async function Q(e){let r=a.resolve(e.outputPath||a.join(e.workspacePath,j));if(await d.pathExists(r)&&e.force!==true)throw new Error(`Workspace contract already exists: ${r}. Use --force to overwrite.`);let o=await S({workspacePath:e.workspacePath,now:e.now}),n=new Set,i={...o,projects:o.projects.map(p=>w(void 0,p,n).project)};await d.ensureDir(a.dirname(r)),await d.writeJson(r,i,{spaces:2});let{publishWorkspaceRegistrySummary:c}=await import('./workspace-registry-summary-ZXGKL2NT.js');return await c(e.workspacePath,{now:e.now}),{contractPath:r,contract:i}}async function X(e){let r=a.resolve(e.workspacePath),o=a.join(r,j),n=await S({workspacePath:r,now:e.now}),i=await d.pathExists(o)?await d.readJson(o):null,c=new Map((i?.projects||[]).map(l=>[l.slug,l])),p=new Set,u=[],t=[],s=[];for(let l of n.projects){let m=c.get(l.slug),g=w(m,l,p);m?g.changed&&t.push(l.slug):u.push(l.slug),s.push(g.project),c.delete(l.slug);}for(let l of c.values()){let m=w(l,l,p);s.push(m.project);}let h={schemaVersion:P,kind:"rapidkit.workspace.contract",generatedAt:(e.now??new Date).toISOString(),workspace:{...n.workspace,...i?.workspace||{},name:i?.workspace?.name||n.workspace.name},projects:s.sort((l,m)=>l.slug.localeCompare(m.slug))};await d.ensureDir(a.dirname(o)),await d.writeJson(o,h,{spaces:2});let f=await M({workspacePath:r}),{publishWorkspaceRegistrySummary:k}=await import('./workspace-registry-summary-ZXGKL2NT.js');return await k(r,{now:e.now}),{contractPath:o,contract:h,addedProjects:u,updatedProjects:t,verification:f}}async function R(e){let r=a.resolve(e.contractPath||a.join(e.workspacePath,j)),o=await d.readJson(r);return {contractPath:r,contract:o}}async function tt(e){let{contractPath:r,contract:o}=await R(e),n=o.projects.map(t=>({id:t.slug,label:t.slug,relativePath:t.relativePath,source:t.source,relationship:t.relationship,externalPath:t.externalPath,runtime:t.runtime,framework:t.framework,kit:t.kit,modules:t.modules,ports:t.ports,apis:t.contracts.apis,owns:t.contracts.owns,env:t.contracts.env})),i=new Set(n.map(t=>t.id)),c=new Map,p=[];for(let t of o.projects){for(let s of t.contracts.dependsOn||[])i.has(s)&&p.push({from:s,to:t.slug,type:"dependency",label:"dependsOn"});for(let s of t.contracts.publishes||[])c.has(s)||c.set(s,new Set),c.get(s)?.add(t.slug);}for(let t of o.projects)for(let s of t.contracts.consumes||[]){let h=c.get(s);if(h)for(let f of h)f!==t.slug&&p.push({from:f,to:t.slug,type:"event",label:s});}let u={schemaVersion:1,kind:"rapidkit.workspace.contract.graph",workspace:o.workspace,generatedAt:new Date().toISOString(),nodes:n.sort((t,s)=>t.id.localeCompare(s.id)),edges:p.sort((t,s)=>`${t.from}:${t.to}:${t.type}:${t.label}`.localeCompare(`${s.from}:${s.to}:${s.type}:${s.label}`)),summary:{projectCount:n.length,dependencyEdges:p.filter(t=>t.type==="dependency").length,eventEdges:p.filter(t=>t.type==="event").length,portCount:n.reduce((t,s)=>t+s.ports.length,0),apiCount:n.reduce((t,s)=>t+s.apis.length,0)}};return {contractPath:r,graph:u}}async function M(e){let{contractPath:r,contract:o}=await R(e),n=[],i=[];o.kind!=="rapidkit.workspace.contract"&&n.push("Contract kind must be rapidkit.workspace.contract."),o.schemaVersion!==P&&n.push(`Contract schemaVersion must be ${P}.`),o.workspace?.name||n.push("Contract workspace.name is required."),Array.isArray(o.projects)||n.push("Contract projects must be an array.");let c=new Set,p=new Map;for(let t of o.projects||[]){if(!t.slug){n.push("Every project must declare slug.");continue}c.has(t.slug)&&n.push(`Duplicate project slug: ${t.slug}.`),c.add(t.slug),t.relativePath?C(t.relativePath)||n.push(`Project ${t.slug} declares unsafe relativePath: ${t.relativePath}.`):n.push(`Project ${t.slug} must declare relativePath.`),t.externalPath&&(t.relationship==="adopted"||t.source==="adopted-local"||t.source==="local-folder"||t.source==="git-url"||n.push(`Project ${t.slug} declares externalPath without imported/adopted provenance.`),a.isAbsolute(t.externalPath)||n.push(`Project ${t.slug} declares non-absolute externalPath.`));for(let s of t.ports||[]){(!Number.isInteger(s.port)||s.port<1||s.port>65535)&&n.push(`Project ${t.slug} declares invalid port: ${s.port}.`);let h=p.get(s.port);h&&n.push(`Port ${s.port} is claimed by both ${h} and ${t.slug}.`),p.set(s.port,t.slug);}for(let s of t.contracts?.apis||[])(!s.name?.trim()||!s.basePath?.startsWith("/"))&&n.push(`Project ${t.slug} declares invalid API contract.`);for(let s of [...t.contracts?.publishes||[],...t.contracts?.consumes||[]])s.trim()||n.push(`Project ${t.slug} declares an empty event contract.`);for(let s of t.contracts?.env||[])/^[A-Z_][A-Z0-9_]*$/.test(s)||n.push(`Project ${t.slug} declares invalid env contract: ${s}.`);for(let s of t.contracts?.dependsOn||[])c.has(s);}for(let t of o.projects||[])for(let s of t.contracts?.dependsOn||[])c.has(s)||n.push(`Project ${t.slug} depends on unknown project: ${s}.`);i.push({id:"schema",status:o.kind==="rapidkit.workspace.contract"&&o.schemaVersion===P?"passed":"failed",message:"Contract schema and kind are valid."}),i.push({id:"projects",status:Array.isArray(o.projects)?"passed":"failed",message:`Contract declares ${Array.isArray(o.projects)?o.projects.length:0} project(s).`}),i.push({id:"ports",status:n.some(t=>t.toLowerCase().includes("port"))?"failed":"passed",message:"Project port declarations are valid and collision-free."}),i.push({id:"dependencies",status:n.some(t=>t.includes("depends on unknown project"))?"failed":"passed",message:"Project dependencies point to known project slugs."}),i.push({id:"contracts",status:n.some(t=>t.includes("unsafe relativePath")||t.includes("invalid API contract")||t.includes("event contract")||t.includes("env contract"))?"failed":"passed",message:"Project path, API, event, and env contracts are valid."});let u=await l(e.workspacePath);if(u.moduleCount>0){for(let t of u.issues)n.push(`${a.basename(t.projectRoot)}: ${t.message} (slug=${t.slug})`);i.push({id:"module-paths",status:u.status,message:u.status==="passed"?`All ${u.moduleCount} registered module(s) resolve under canonical paths.`:`${u.issues.length} registered module(s) missing canonical install paths.`});}else e.strict&&i.push({id:"module-paths",status:"passed",message:"No registry-backed modules declared in workspace projects."});return {status:n.length>0?"failed":"passed",contractPath:r,projectCount:Array.isArray(o.projects)?o.projects.length:0,checks:i,violations:n}}async function et(e){let r=a.resolve(e.workspacePath),o=a.join(r,V);await d.ensureDir(a.dirname(o));let n={schemaVersion:N,generatedAt:e.generatedAt??new Date().toISOString(),status:e.result.status,contractPath:e.result.contractPath,projectCount:e.result.projectCount,checks:e.result.checks,violations:e.result.violations};return await d.writeJSON(o,A(n),{spaces:2}),o}
|
|
1
|
+
import {l}from'./chunk-OCGZNSOE.js';import {e}from'./chunk-MIWDCR6I.js';import {a as a$1}from'./chunk-HHJAANUC.js';import a from'path';import d from'fs-extra';var _="unknown-run";function A(e$1){let r=e();return !r||r===_?e$1:{...e$1,runId:r}}var j=".rapidkit/workspace.contract.json",V=".rapidkit/reports/workspace-contract-verify-last-run.json",P=1,N="workspace-contract-verify.v1";function E(e){return e.replace(/\\/g,"/")}function C(e){let r=E(e).trim();return !r||r.startsWith("/")||r.startsWith("~")||/^[a-zA-Z]:\//.test(r)||r.includes("\0")?false:!r.split("/").filter(Boolean).some(o=>o===".."||o===".")}function I(e,r){return e.trim().toLowerCase().replace(/[^a-z0-9._-]+/g,"-").replace(/-+/g,"-").replace(/^[-_.]+|[-_.]+$/g,"").slice(0,80)||r}function J(e){return Array.isArray(e)?e.filter(r=>typeof r=="string"&&r.trim().length>0):[]}async function T(e){let r=a.join(e,".rapidkit","workspace.json");try{let o=await d.readJson(r);return {name:typeof o.workspace_name=="string"&&o.workspace_name.trim()||typeof o.name=="string"&&o.name.trim()||a.basename(e),profile:typeof o.profile=="string"?o.profile:void 0}}catch{return {name:a.basename(e)}}}async function D(e){let r=[],o=[e],n=new Set,i=new Set([".git","node_modules",".venv","venv","dist","build","target",".next",".turbo",".cache"]);for(;o.length>0;){let c=o.shift();if(!c||n.has(c))continue;n.add(c);let p=a.join(c,".rapidkit","project.json"),u=a.join(c,".rapidkit","context.json");if(await d.pathExists(p)||await d.pathExists(u)){r.push(await d.pathExists(p)?p:u);continue}let t;try{t=await d.readdir(c,{withFileTypes:true});}catch{continue}for(let s of t)!s.isDirectory()||i.has(s.name)||o.push(a.join(c,s.name));}return r.sort()}function G(e){let r=(e||"").toLowerCase();if(r.includes("fastapi"))return "fastapi";if(r.includes("nestjs"))return "nestjs";if(r.includes("springboot"))return "springboot";if(r.includes("gofiber"))return "fiber";if(r.includes("gogin"))return "gin"}function K(e,r){let o=(e||"").toLowerCase(),n=(r||"").toLowerCase();return o.includes("fastapi")?8e3:o.includes("nestjs")?3e3:o.includes("springboot")?8080:o.includes("gofiber")?3e3:o.includes("gogin")?8080:n==="node"?3e3:n==="python"?8e3:n==="java"||n==="go"?8080:null}function F(e,r){let o=e;for(;r.has(o)&&o<65535;)o+=1;return o}function w(e,r,o){let n=K(r.kit,r.runtime),i=e?.ports||[],c=i.length>0?i:n?[{name:"http",port:F(n,o),protocol:"http"}]:[];for(let t of c)o.add(t.port);let p={...r,...e,slug:e?.slug||r.slug,relativePath:e?.relativePath&&C(e.relativePath)?e.relativePath:r.relativePath,source:e?.source||r.source,relationship:e?.relationship||r.relationship,externalPath:e?.externalPath||r.externalPath,runtime:e?.runtime||r.runtime,framework:e?.framework||r.framework,kit:e?.kit||r.kit,modules:e?.modules?.length?e.modules:r.modules,ports:c,contracts:{owns:e?.contracts?.owns||[],apis:e?.contracts?.apis||[],publishes:e?.contracts?.publishes||[],consumes:e?.contracts?.consumes||[],dependsOn:e?.contracts?.dependsOn||[],env:e?.contracts?.env||[]}},u=JSON.stringify(e||null)!==JSON.stringify(p);return {project:p,changed:u}}async function S(e){let r=a.resolve(e.workspacePath),o=await T(r),n=await D(r),i=await a$1(r),c=[];for(let t of i){let s=a.resolve(t.path),h=a.join(s,".rapidkit","project.json"),f=a.join(s,".rapidkit","context.json"),k=await d.pathExists(h)?h:await d.pathExists(f)?f:null;!k||n.some(l=>a.resolve(l)===a.resolve(k))||c.push({projectJsonPath:k,registryEntry:t});}let p=[],u=[...n.map(t=>({projectJsonPath:t})),...c];for(let{projectJsonPath:t,registryEntry:s}of u){let h=a.dirname(a.dirname(t)),f=E(a.relative(r,h)),k=s!==void 0&&!C(f),l=I(s?.name||a.basename(h),a.basename(h)),m=k?`external/${l}`:f||l,g=await d.readJson(t),y=typeof g.kit_name=="string"&&g.kit_name||typeof g.kit=="string"&&g.kit||void 0,x=typeof g.framework=="string"&&g.framework||G(y);p.push({slug:s?.name||m||a.basename(h),relativePath:m,source:s?.source??"workspace",relationship:s?.relationship,externalPath:k?h:void 0,runtime:typeof g.runtime=="string"?g.runtime:void 0,framework:x,kit:y,modules:J(g.modules),ports:[],contracts:{owns:[],apis:[],publishes:[],consumes:[],dependsOn:[],env:[]}});}return {schemaVersion:P,kind:"rapidkit.workspace.contract",generatedAt:(e.now??new Date).toISOString(),workspace:o,projects:p}}async function Q(e){let r=a.resolve(e.outputPath||a.join(e.workspacePath,j));if(await d.pathExists(r)&&e.force!==true)throw new Error(`Workspace contract already exists: ${r}. Use --force to overwrite.`);let o=await S({workspacePath:e.workspacePath,now:e.now}),n=new Set,i={...o,projects:o.projects.map(p=>w(void 0,p,n).project)};await d.ensureDir(a.dirname(r)),await d.writeJson(r,i,{spaces:2});let{publishWorkspaceRegistrySummary:c}=await import('./workspace-registry-summary-X5WRUU3T.js');return await c(e.workspacePath,{now:e.now}),{contractPath:r,contract:i}}async function X(e){let r=a.resolve(e.workspacePath),o=a.join(r,j),n=await S({workspacePath:r,now:e.now}),i=await d.pathExists(o)?await d.readJson(o):null,c=new Map((i?.projects||[]).map(l=>[l.slug,l])),p=new Set,u=[],t=[],s=[];for(let l of n.projects){let m=c.get(l.slug),g=w(m,l,p);m?g.changed&&t.push(l.slug):u.push(l.slug),s.push(g.project),c.delete(l.slug);}for(let l of c.values()){let m=w(l,l,p);s.push(m.project);}let h={schemaVersion:P,kind:"rapidkit.workspace.contract",generatedAt:(e.now??new Date).toISOString(),workspace:{...n.workspace,...i?.workspace||{},name:i?.workspace?.name||n.workspace.name},projects:s.sort((l,m)=>l.slug.localeCompare(m.slug))};await d.ensureDir(a.dirname(o)),await d.writeJson(o,h,{spaces:2});let f=await M({workspacePath:r}),{publishWorkspaceRegistrySummary:k}=await import('./workspace-registry-summary-X5WRUU3T.js');return await k(r,{now:e.now}),{contractPath:o,contract:h,addedProjects:u,updatedProjects:t,verification:f}}async function R(e){let r=a.resolve(e.contractPath||a.join(e.workspacePath,j)),o=await d.readJson(r);return {contractPath:r,contract:o}}async function tt(e){let{contractPath:r,contract:o}=await R(e),n=o.projects.map(t=>({id:t.slug,label:t.slug,relativePath:t.relativePath,source:t.source,relationship:t.relationship,externalPath:t.externalPath,runtime:t.runtime,framework:t.framework,kit:t.kit,modules:t.modules,ports:t.ports,apis:t.contracts.apis,owns:t.contracts.owns,env:t.contracts.env})),i=new Set(n.map(t=>t.id)),c=new Map,p=[];for(let t of o.projects){for(let s of t.contracts.dependsOn||[])i.has(s)&&p.push({from:s,to:t.slug,type:"dependency",label:"dependsOn"});for(let s of t.contracts.publishes||[])c.has(s)||c.set(s,new Set),c.get(s)?.add(t.slug);}for(let t of o.projects)for(let s of t.contracts.consumes||[]){let h=c.get(s);if(h)for(let f of h)f!==t.slug&&p.push({from:f,to:t.slug,type:"event",label:s});}let u={schemaVersion:1,kind:"rapidkit.workspace.contract.graph",workspace:o.workspace,generatedAt:new Date().toISOString(),nodes:n.sort((t,s)=>t.id.localeCompare(s.id)),edges:p.sort((t,s)=>`${t.from}:${t.to}:${t.type}:${t.label}`.localeCompare(`${s.from}:${s.to}:${s.type}:${s.label}`)),summary:{projectCount:n.length,dependencyEdges:p.filter(t=>t.type==="dependency").length,eventEdges:p.filter(t=>t.type==="event").length,portCount:n.reduce((t,s)=>t+s.ports.length,0),apiCount:n.reduce((t,s)=>t+s.apis.length,0)}};return {contractPath:r,graph:u}}async function M(e){let{contractPath:r,contract:o}=await R(e),n=[],i=[];o.kind!=="rapidkit.workspace.contract"&&n.push("Contract kind must be rapidkit.workspace.contract."),o.schemaVersion!==P&&n.push(`Contract schemaVersion must be ${P}.`),o.workspace?.name||n.push("Contract workspace.name is required."),Array.isArray(o.projects)||n.push("Contract projects must be an array.");let c=new Set,p=new Map;for(let t of o.projects||[]){if(!t.slug){n.push("Every project must declare slug.");continue}c.has(t.slug)&&n.push(`Duplicate project slug: ${t.slug}.`),c.add(t.slug),t.relativePath?C(t.relativePath)||n.push(`Project ${t.slug} declares unsafe relativePath: ${t.relativePath}.`):n.push(`Project ${t.slug} must declare relativePath.`),t.externalPath&&(t.relationship==="adopted"||t.source==="adopted-local"||t.source==="local-folder"||t.source==="git-url"||n.push(`Project ${t.slug} declares externalPath without imported/adopted provenance.`),a.isAbsolute(t.externalPath)||n.push(`Project ${t.slug} declares non-absolute externalPath.`));for(let s of t.ports||[]){(!Number.isInteger(s.port)||s.port<1||s.port>65535)&&n.push(`Project ${t.slug} declares invalid port: ${s.port}.`);let h=p.get(s.port);h&&n.push(`Port ${s.port} is claimed by both ${h} and ${t.slug}.`),p.set(s.port,t.slug);}for(let s of t.contracts?.apis||[])(!s.name?.trim()||!s.basePath?.startsWith("/"))&&n.push(`Project ${t.slug} declares invalid API contract.`);for(let s of [...t.contracts?.publishes||[],...t.contracts?.consumes||[]])s.trim()||n.push(`Project ${t.slug} declares an empty event contract.`);for(let s of t.contracts?.env||[])/^[A-Z_][A-Z0-9_]*$/.test(s)||n.push(`Project ${t.slug} declares invalid env contract: ${s}.`);for(let s of t.contracts?.dependsOn||[])c.has(s);}for(let t of o.projects||[])for(let s of t.contracts?.dependsOn||[])c.has(s)||n.push(`Project ${t.slug} depends on unknown project: ${s}.`);i.push({id:"schema",status:o.kind==="rapidkit.workspace.contract"&&o.schemaVersion===P?"passed":"failed",message:"Contract schema and kind are valid."}),i.push({id:"projects",status:Array.isArray(o.projects)?"passed":"failed",message:`Contract declares ${Array.isArray(o.projects)?o.projects.length:0} project(s).`}),i.push({id:"ports",status:n.some(t=>t.toLowerCase().includes("port"))?"failed":"passed",message:"Project port declarations are valid and collision-free."}),i.push({id:"dependencies",status:n.some(t=>t.includes("depends on unknown project"))?"failed":"passed",message:"Project dependencies point to known project slugs."}),i.push({id:"contracts",status:n.some(t=>t.includes("unsafe relativePath")||t.includes("invalid API contract")||t.includes("event contract")||t.includes("env contract"))?"failed":"passed",message:"Project path, API, event, and env contracts are valid."});let u=await l(e.workspacePath);if(u.moduleCount>0){for(let t of u.issues)n.push(`${a.basename(t.projectRoot)}: ${t.message} (slug=${t.slug})`);i.push({id:"module-paths",status:u.status,message:u.status==="passed"?`All ${u.moduleCount} registered module(s) resolve under canonical paths.`:`${u.issues.length} registered module(s) missing canonical install paths.`});}else e.strict&&i.push({id:"module-paths",status:"passed",message:"No registry-backed modules declared in workspace projects."});return {status:n.length>0?"failed":"passed",contractPath:r,projectCount:Array.isArray(o.projects)?o.projects.length:0,checks:i,violations:n}}async function et(e){let r=a.resolve(e.workspacePath),o=a.join(r,V);await d.ensureDir(a.dirname(o));let n={schemaVersion:N,generatedAt:e.generatedAt??new Date().toISOString(),status:e.result.status,contractPath:e.result.contractPath,projectCount:e.result.projectCount,checks:e.result.checks,violations:e.result.violations};return await d.writeJSON(o,A(n),{spaces:2}),o}
|
|
2
2
|
export{A as a,j as b,V as c,P as d,N as e,D as f,S as g,Q as h,X as i,R as j,tt as k,M as l,et as m};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import {f as f$1,e}from'./chunk-PCXSTKZ5.js';import {b}from'./chunk-CDCYRBAY.js';import {c as c$1,a as a$2,b as b$1}from'./chunk-NFUXULIF.js';import {q}from'./chunk-YBS2HGO3.js';import {i,d,b as b$3,a as a$4}from'./chunk-UZW5QFRW.js';import {f}from'./chunk-OLDPVVSV.js';import {c,l as l$1,i as i$1,b as b$2,q as q$1,m,o}from'./chunk-WRMCPKGA.js';import {a as a$3}from'./chunk-2FIX2MDC.js';import {a as a$1}from'./chunk-HHJAANUC.js';import l from'chalk';import {execa}from'execa';import a from'fs-extra';import r from'path';var Ct=[".eslintrc.js",".eslintrc.cjs",".eslintrc.json",".eslintrc.yaml",".eslintrc.yml","eslint.config.js","eslint.config.mjs","eslint.config.cjs"],Et=["tests","test","src/test","__tests__","e2e","playwright","cypress"],Pt=["vitest.config.ts","vitest.config.js","vitest.config.mjs","jest.config.js","jest.config.ts","jest.config.mjs","playwright.config.ts","playwright.config.js","cypress.config.js","cypress.config.ts"],St=["src","app","pages"],Rt=["dev","build","test","lint"];function Xe(e){let n=e?.scripts;if(!n||typeof n!="object"||Array.isArray(n))return {};let i={};for(let[t,c]of Object.entries(n))typeof c=="string"&&c.trim().length>0&&(i[t]=c);return i}async function Ye(e,n){for(let c of Ct)if(await a.pathExists(r.join(e,c)))return true;let i=n??(await a.pathExists(r.join(e,"package.json"))?await a.readJson(r.join(e,"package.json")):null);if(!i)return false;if(i.eslintConfig)return true;let t={...i.dependencies??{},...i.devDependencies??{}};return !!(t.eslint||t["@eslint/js"]||t["@eslint/eslintrc"])}async function Ze(e,n){for(let c of Et)if(await a.pathExists(r.join(e,c)))return true;for(let c of Pt)if(await a.pathExists(r.join(e,c)))return true;let i=Xe(n);if(i.test||i["test:unit"]||i["test:e2e"]||i["test:ci"]||i["test:watch"])return true;let t={...n?.dependencies??{},...n?.devDependencies??{}};return t.vitest||t.jest||t["@playwright/test"]||t.cypress?true:await Ft(e)}async function Ft(e){let n=["src","app","pages","components"],i=/\.(test|spec)\.(tsx?|jsx?|vue|svelte)$/i,c=new Set(["node_modules",".git","dist","build",".next","coverage",".turbo"]);for(let o of n){let s=r.join(e,o);if(!await a.pathExists(s))continue;let d=[{dir:s,depth:0}];for(;d.length>0;){let u=d.shift();if(!u)break;let m=[];try{m=await a.readdir(u.dir);}catch{continue}for(let p of m){let f=r.join(u.dir,p);if(i.test(p))return true;if(!(u.depth>=3||c.has(p)||p.startsWith(".")))try{(await a.stat(f)).isDirectory()&&d.push({dir:f,depth:u.depth+1});}catch{continue}}}}return false}async function Re(e){for(let n of St){let i=r.join(e,n);if(await a.pathExists(i))try{if((await a.readdir(i)).some(c=>!c.startsWith(".")))return true}catch{continue}}return false}function $t(e){let n=e.key;return b$3(n).key}function Dt(e,n,i){return a$4(n,i).some(c=>!!e[c])}async function et(e){let{projectPath:n,detection:i,packageJsonData:t}=e,c=$t(i),o=b$3(c),s=Xe(t),d=[],u=await a.pathExists(r.join(n,"package-lock.json"))||await a.pathExists(r.join(n,"pnpm-lock.yaml"))||await a.pathExists(r.join(n,"yarn.lock"))||await a.pathExists(r.join(n,"bun.lockb"));d.push({id:"frontend-lockfile-integrity",label:"Frontend lockfile integrity",status:u?"pass":"warn",severity:"warn",scope:"project-scoped",reason:u?"Node lockfile detected for deterministic dependency restore.":"No Node lockfile detected (package-lock/yarn.lock/pnpm-lock.yaml/bun.lockb).",recommendation:u?void 0:"Commit a lockfile for deterministic installs and CI parity."});let m=await a.pathExists(r.join(n,"tsconfig.json")),p=await a.pathExists(r.join(n,"jsconfig.json")),f=m||p;d.push({id:"frontend-typescript-surface",label:"TypeScript project surface",status:f?"pass":"warn",severity:"warn",scope:"project-scoped",reason:f?m?"tsconfig.json detected.":"jsconfig.json detected.":"No tsconfig.json or jsconfig.json detected.",recommendation:f?void 0:"Add tsconfig.json (or jsconfig.json) for typed frontend builds and IDE parity."});let g=o.fileHints.length>0&&o.fileHints.some(k=>a.pathExistsSync(r.join(n,k)));d.push({id:"frontend-framework-config",label:`${o.displayName} config surface`,status:g?"pass":"warn",severity:"warn",scope:"project-scoped",reason:g?`${o.displayName} configuration artifacts detected.`:`No ${o.displayName} config markers detected (${o.fileHints.join(", ")||"n/a"}).`,recommendation:g?void 0:"Keep framework config files in-repo for reproducible dev/build behavior."});for(let k of Rt){let h=Dt(s,c,k),x=k==="dev"||k==="build";d.push({id:`frontend-script-${k}`,label:`${k} script surface`,status:h?"pass":x?"fail":"warn",severity:x?"error":"warn",scope:"project-scoped",reason:h?`package.json exposes a ${k} script for ${o.displayName}.`:`No ${k} script detected for ${o.displayName}.`,recommendation:h?void 0:`Add a "${a$4(c,k)[0]??k}" script to package.json.`});}let y=await Re(n);return d.push({id:"frontend-source-tree",label:"Frontend source tree",status:y?"pass":"warn",severity:"warn",scope:"project-scoped",reason:y?"Application source directories detected (src/app/pages).":"No frontend source directories detected under src/, app/, or pages/.",recommendation:y?void 0:"Ensure the scaffolded application tree exists before running lifecycle commands."}),d}var At="rapidkit-doctor-fix-result-v1",ee="npx rapidkit workspace verify --from-impact .rapidkit/reports/workspace-impact-last-run.json --json";function re(e){return {schemaVersion:At,appliedFixes:e.appliedFixes,remainingBlockers:e.remainingBlockers,verifyRecommended:e.verifyRecommended??ee}}function It(e){return [...new Set(e.filter(n=>n&&n.trim().length>0))]}function Nt(){let e=q$1().map(t=>r.join(t,b$2()?"poetry.exe":"poetry")),n=b$2()?[r.join(process.env.APPDATA||"","Python","Scripts","poetry.exe"),r.join(process.env.USERPROFILE||"","AppData","Roaming","Python","Scripts","poetry.exe")]:[],i=b$2()?[]:["/usr/local/bin/poetry","/usr/bin/poetry"];return It([...e,...n,...i])}function Ht(e){let n=q$1().map(u=>({location:"Global (user-local)",path:r.join(u,b$2()?"rapidkit.exe":"rapidkit")})),i=[{location:"Global (pipx)",path:r.join(e,".local","bin","rapidkit")},{location:"Global (pipx)",path:r.join(e,"AppData","Roaming","Python","Scripts","rapidkit.exe")},{location:"Global (pyenv)",path:r.join(e,".pyenv","shims","rapidkit")},{location:"Global (system)",path:"/usr/local/bin/rapidkit"},{location:"Global (system)",path:"/usr/bin/rapidkit"}],t=m(r.join(process.cwd(),".venv")),c=o(process.cwd()),o$1=[{location:"Workspace (.venv)",path:t},...c.map(u=>({location:"Workspace (launcher)",path:u}))],s=[...n,...i,...o$1],d=new Set;return s.filter(u=>d.has(u.path)?false:(d.add(u.path),true))}function Mt(e){let n=new Map([["Workspace (.venv)",0],["Global (user-local)",1],["Global (pipx)",2],["Global (pyenv)",3],["Global (system)",4]]);return [...e].sort((i,t)=>{let c=n.get(i.location)??Number.MAX_SAFE_INTEGER,o=n.get(t.location)??Number.MAX_SAFE_INTEGER;return c!==o?c-o:i.path.localeCompare(t.path)})}function ne(e){let n=0,i=e.issues.some(t=>t.toLowerCase().includes("environment file missing"));return e.hasEnvFile===false&&!i&&(n+=1),typeof e.vulnerabilities=="number"&&e.vulnerabilities>0&&(n+=1),n}function De(e){return e.filter(n=>ne(n)>0).length}function He(e){return e.reduce((n,i)=>n+ne(i),0)}var _t="doctor-project-scan-v2",at="doctor-workspace-cache-v2",Bt=Object.freeze({version:"doctor-evidence-v1",scoringPolicyVersion:"doctor-score-policy-v1",generatedBy:"rapidkit-npm",deterministicScoreBreakdown:true,scopeModel:"workspace-aggregate-or-project-scoped"});function ye(){return {...Bt}}function ke(e){return !e||e.total<=0?null:Math.round(e.passed/e.total*100)}function ct(e){return typeof e=="number"?e:Array.isArray(e)?e.length:0}async function lt(e,n){try{if(!await a.pathExists(e))return null;let i=await a.readJSON(e);return c$1(i,n)?i:null}catch{return null}}function dt(e,n){if(!e?.system)return [];let i=[{id:"python",current:n.python},{id:"poetry",current:n.poetry},{id:"pipx",current:n.pipx},{id:"go",current:n.go},{id:"rapidkitCore",current:n.rapidkitCore}],t=[];for(let c of i){let o=e.system?.[c.id]?.status;!o||o===c.current.status||t.push({id:c.id,from:o,to:c.current.status});}return t}function Tt(e,n){let i=new Map;for(let g of n.projects)i.set(g.path||g.name,g.issues.length);if(!e)return {baselineAvailable:false,newIssueCount:0,resolvedIssueCount:0,netIssueDelta:0,scoreDeltaPercent:null,systemStatusChanges:[],regressedProjects:[],improvedProjects:[]};let t=Array.isArray(e.projects)?e.projects:[],c=new Map;for(let g of t){let y=g.path||g.name;y&&c.set(y,ct(g.issues));}let o=0,s=0,d=new Set,u=new Set,m=new Set([...Array.from(c.keys()),...Array.from(i.keys())]);for(let g of m){let y=c.get(g)??0,k=i.get(g)??0;k>y?(o+=k-y,d.add(g)):k<y&&(s+=y-k,u.add(g));}let p=ke(e.healthScore),f=ke(n.healthScore);return {baselineAvailable:true,previousGeneratedAt:e.generatedAt,newIssueCount:o,resolvedIssueCount:s,netIssueDelta:o-s,scoreDeltaPercent:p===null||f===null?null:f-p,systemStatusChanges:dt(e,{python:n.python,poetry:n.poetry,pipx:n.pipx,go:n.go,rapidkitCore:n.rapidkitCore}),regressedProjects:Array.from(d).sort(),improvedProjects:Array.from(u).sort()}}function Ot(e,n){if(!e)return {baselineAvailable:false,newIssueCount:0,resolvedIssueCount:0,netIssueDelta:0,scoreDeltaPercent:null,systemStatusChanges:[],regressedProjects:[],improvedProjects:[]};let i=ct(e.project?.issues),t=n.project.issues.length,c=Math.max(t-i,0),o=Math.max(i-t,0),s=ke(e.healthScore),d=ke(n.healthScore),u=n.project.path||n.project.name;return {baselineAvailable:true,previousGeneratedAt:e.generatedAt,newIssueCount:c,resolvedIssueCount:o,netIssueDelta:c-o,scoreDeltaPercent:s===null||d===null?null:d-s,systemStatusChanges:dt(e,{python:n.python,poetry:n.poetry,pipx:n.pipx,go:n.go,rapidkitCore:n.rapidkitCore}),regressedProjects:c>0?[u]:[],improvedProjects:o>0?[u]:[]}}function ut(e){let n=e??[],i=0,t=0;for(let s of n){if(s.scope==="project-scoped"){i+=1;continue}(s.scope==="workspace-aggregate"||s.scope==="host-system")&&(t+=1);}let c=i>0&&t>0?1:0,o=c>0?"mixed":i>0?"scoped":t>0?"aggregated":"unknown";return {scopedCount:i,aggregatedCount:t,mixedCount:c,dominantScope:o}}function $(e,n){return b$2()?`cd "${e}"; ${n}`:`cd ${e} && ${n}`}function z(e){return b$2()?$(e,"Copy-Item .env.example .env"):$(e,"cp .env.example .env")}function Gt(e){return e==="FastAPI"||e==="NestJS"?"first-class":e==="Django"||e==="Flask"||e==="Express"||e==="Fastify"||e==="Koa"||e==="Go/Fiber"||e==="Go/Gin"||e==="Spring Boot"||e==="Rust"||e==="Phoenix"||e==="Elixir"||e==="Clojure"||e==="Scala"||e==="Kotlin"||e==="Deno"||e==="Bun"||e==="PHP"||e==="Laravel"||e==="Ruby"||e==="Ruby on Rails"||e==="ASP.NET"?"extended":"observed"}function Kt(e){return e==="Next.js"||e==="Remix"||e==="Nuxt"||e==="React"||e==="Vue"||e==="Angular"||e==="SvelteKit"||e==="Svelte"||e==="Vite"||e==="Astro"||e==="Solid"?"frontend":e==="Unknown"||e==="Node.js"||e==="Python"?"generic":"backend"}function Wt(e){return e==="NestJS"||e==="Next.js"||e==="Remix"||e==="Nuxt"||e==="React"||e==="Vue"||e==="Angular"||e==="SvelteKit"||e==="Svelte"||e==="Vite"||e==="Astro"||e==="Solid"||e==="Bun"||e==="Express"||e==="Fastify"||e==="Koa"||e==="Node.js"?"node":e==="FastAPI"||e==="Django"||e==="Flask"||e==="Python"?"python":e==="Go/Fiber"||e==="Go/Gin"?"go":e==="Spring Boot"?"java":e==="Rust"?"rust":e==="Elixir"||e==="Phoenix"?"elixir":e==="Clojure"?"clojure":e==="Deno"?"deno":e==="Laravel"||e==="PHP"?"php":e==="Ruby on Rails"||e==="Ruby"?"ruby":e==="ASP.NET"?"dotnet":"unknown"}function Ae(e,n){let i=q(n);e.commandCapabilities=i,e.supportTier=i.frameworkSupportTier;}function he(e,n,i,t){e.framework=n,e.frameworkConfidence=i,e.supportTier=Gt(n),e.projectKind=Kt(n),e.runtimeFamily=Wt(n);}function pt(e){return e==="python"?"python":e==="node"||e==="bun"?"node":e==="go"?"go":e==="java"?"java":e==="rust"?"rust":e==="elixir"?"elixir":e==="clojure"?"clojure":e==="deno"?"deno":e==="php"?"php":e==="ruby"?"ruby":e==="dotnet"?"dotnet":"unknown"}function Me(e){switch(e.key){case "fastapi":return "FastAPI";case "django":return "Django";case "flask":return "Flask";case "python":return "Python";case "nestjs":return "NestJS";case "nextjs":return "Next.js";case "remix":return "Remix";case "nuxt":return "Nuxt";case "react":return "React";case "vite":return "Vite";case "vue":return "Vue";case "sveltekit":return "SvelteKit";case "svelte":return "Svelte";case "angular":return "Angular";case "astro":return "Astro";case "solid":return "Solid";case "express":return "Express";case "fastify":return "Fastify";case "koa":return "Koa";case "node":return "Node.js";case "gofiber":return "Go/Fiber";case "gogin":return "Go/Gin";case "echo":return "Echo";case "go":return "Go";case "springboot":return "Spring Boot";case "java":return "Java";case "laravel":return "Laravel";case "php":return "PHP";case "rails":return "Ruby on Rails";case "ruby":return "Ruby";case "dotnet":return "ASP.NET";case "phoenix":return "Phoenix";case "elixir":return "Elixir";case "clojure":return "Clojure";case "scala":return "Scala";case "kotlin":return "Kotlin";case "deno":return "Deno";case "bun":return "Bun";case "actix":case "axum":case "rocket":case "rust":return "Rust";case "sinatra":case "symfony":case "unknown":return "Unknown";default:return "Unknown"}}function Vt(e){return e.key==="python"||e.key==="node"||e.key==="go"||e.key==="java"||e.key==="php"||e.key==="ruby"||e.key==="dotnet"||e.key==="rust"||e.key==="elixir"||e.key==="clojure"||e.key==="scala"||e.key==="kotlin"||e.key==="deno"||e.key==="bun"||e.key==="unknown"}function Lt(e,n){e.framework=Me(n),e.frameworkKey=n.key,e.importStack=n.importStack,e.frameworkConfidence=n.confidence,e.supportTier=n.supportTier,e.projectKind="frontend",e.runtimeFamily=pt(n.runtime);}function W(e,n){e.framework=Me(n),e.frameworkKey=n.key,e.importStack=n.importStack,e.frameworkConfidence=n.confidence,e.supportTier=n.supportTier,e.projectKind=Vt(n)?"generic":"backend",e.runtimeFamily=pt(n.runtime);}function Jt(e){let n=e.dependencies,i=e.scripts??{},t=(e.kitName??"").toLowerCase(),c=s=>!!n[s],o=Object.values(i).filter(s=>typeof s=="string").join(" ").toLowerCase();return c("next")||o.includes("next ")?{framework:"Next.js",confidence:"high"}:c("nuxt")||o.includes("nuxt ")?{framework:"Nuxt",confidence:"high"}:c("@nestjs/core")||t.startsWith("nestjs.")?{framework:"NestJS",confidence:"high"}:c("express")?{framework:"Express",confidence:"high"}:c("fastify")?{framework:"Fastify",confidence:"high"}:c("koa")?{framework:"Koa",confidence:"high"}:c("@angular/core")?{framework:"Angular",confidence:"high"}:c("@sveltejs/kit")||o.includes("svelte-kit")?{framework:"SvelteKit",confidence:"high"}:c("vue")?{framework:"Vue",confidence:"medium"}:c("react")&&c("react-dom")?{framework:"React",confidence:"medium"}:{framework:"Node.js",confidence:"low"}}async function qt(e){let n=i(e);return n.runtime!=="python"?{framework:"Python",confidence:"low"}:{framework:Me(n),confidence:n.confidence}}async function tt(e){try{let n=await a.stat(e);return `${r.basename(e)}:${n.isDirectory()?"d":"f"}:${n.size}:${n.mtimeMs}`}catch{return `${r.basename(e)}:missing`}}async function Ut(e){try{let n=new Set([".git",".venv","node_modules",".rapidkit","dist","build","coverage","__pycache__"]),i=new Set;await pe(e)&&i.add(e);let t=await a$1(e);for(let o of t){let s=r.isAbsolute(o.path)?o.path:r.join(e,o.path);await pe(s)&&i.add(s);}let c=async(o,s)=>{if(s<0)return;let d=await mt(o);for(let u of d){if(ft(u,n))continue;let m=r.join(o,u);if(await pe(m)){i.add(m);continue}s>0&&await c(m,s-1);}};return await c(e,1),i.size===0&&(await cn(e,3,n)).forEach(s=>i.add(s)),Array.from(i).sort((o,s)=>o.localeCompare(s))}catch{return []}}async function zt(e,n){let i=[r.join(e,".rapidkit-workspace"),r.join(e,".rapidkit","workspace.json"),r.join(e,".rapidkit","imported-projects.json"),r.join(e,".rapidkit","policies.yml"),r.join(e,".rapidkit","toolchain.lock"),r.join(e,".rapidkit","cache-config.yml")],t=[".rapidkit/project.json",".rapidkit/context.json",".rapidkit/file-hashes.json","package.json","pyproject.toml","composer.json","Gemfile","Gemfile.lock","go.mod","go.sum","pom.xml","requirements.txt","Dockerfile","Makefile",".env",".env.example","src","modules","tests","test",".venv","node_modules"],c=await Promise.all(i.map(tt)),o=await Promise.all(n.map(async s=>{let d=await Promise.all(t.map(u=>tt(r.join(s,u))));return `${s}::${d.join("|")}`}));return [_t,...c,...o].join("||")}async function Qt(e,n){try{if(!await a.pathExists(e))return null;let i=await a.readJSON(e);return !i||i.signature!==n||!Array.isArray(i.projects)||typeof i.schemaVersion=="string"&&i.schemaVersion!==at?null:i}catch{return null}}async function Xt(e,n){try{await a.ensureDir(r.dirname(e)),await a.writeJSON(e,n,{spaces:2});}catch{}}async function Yt(e$1,n,i){let t=r.join(e$1,".rapidkit","reports","doctor-last-run.json");try{await a.ensureDir(r.dirname(t));let c=[];for(let o of n.projects)for(let s of o.issues??[])typeof s=="string"&&s.trim()&&c.push(`${o.name}: ${s.trim()}`);for(let[o,s]of [["python",n.python],["rapidkitCore",n.rapidkitCore]])if(s?.status==="error"){let d=typeof s.message=="string"?s.message:`${o} check failed`;c.push(`${o}: ${d}`);}return await a.writeJSON(t,f$1({schemaVersion:a$2,evidenceType:"workspace",contract:ye(),workspacePath:e$1,workspaceName:n.workspaceName,projectScanCached:n.projectScanCached??false,projectScanSignature:n.projectScanSignature,cachePath:i,healthScore:n.healthScore,system:{python:n.python,poetry:n.poetry,pipx:n.pipx,go:n.go,rapidkitCore:n.rapidkitCore,versions:{core:n.coreVersion,npm:n.npmVersion}},projects:n.projects,summary:{totalProjects:n.projects.length,totalIssues:n.projects.reduce((o,s)=>o+s.issues.length,0),projectAdvisoryWarningProjects:De(n.projects),projectAdvisoryWarnings:He(n.projects),hasSystemErrors:[n.python,n.rapidkitCore].some(o=>o.status==="error"),scopeProvenance:n.scopeProvenance},driftDelta:n.driftDelta,scoreBreakdown:n.scoreBreakdown??[]},{commandId:"checkWorkspaceHealth",exitCode:ae(n.healthScore,{}),generatedAt:new Date().toISOString(),blockers:c.slice(0,12),runId:e()}),{spaces:2}),t}catch{return}}async function _e(){let[e,n,i,t,c]=await Promise.all([Zt(),en(),tn(),nn(),sn()]);return {python:e,poetry:n,pipx:i,go:t,rapidkitCore:c}}async function Zt(){let e=i$1();for(let n of e)try{let{stdout:i}=await execa(n,["--version"],{timeout:3e3}),t=i.match(/Python (\d+\.\d+\.\d+)/);if(t){let c=t[1],[o,s]=c.split(".").map(Number);return o<3||o===3&&s<10?{status:"warn",message:`Python ${c} (requires 3.10+)`,details:`${n} found but version is below minimum requirement`}:{status:"ok",message:`Python ${c}`,details:`Using ${n}`}}}catch{continue}return {status:"error",message:"Python not found",details:"Install Python 3.10+ and ensure it's in PATH"}}async function en(){try{let{stdout:e}=await execa("poetry",["--version"],{timeout:3e3}),n=e.match(/Poetry .*version ([\d.]+)/);return n?{status:"ok",message:`Poetry ${n[1]}`,details:"Available for dependency management"}:{status:"warn",message:"Poetry version unknown"}}catch{let e=i$1().map(n=>({cmd:n,args:n==="py"?["-3","-m","poetry","--version"]:["-m","poetry","--version"]}));for(let n of e)try{let{stdout:i}=await execa(n.cmd,n.args,{timeout:3e3,shell:c()}),t=i.match(/Poetry .*version ([\d.]+)/)||i.match(/([\d.]+)/);return {status:"ok",message:t?.[1]?`Poetry ${t[1]}`:"Poetry detected",details:`Available via ${n.cmd} ${n.args.join(" ")}`}}catch{continue}for(let n of Nt())try{if(!await a.pathExists(n))continue;let{stdout:i}=await execa(n,["--version"],{timeout:3e3,shell:c()}),t=i.match(/Poetry .*version ([\d.]+)/)||i.match(/([\d.]+)/);return {status:"ok",message:t?.[1]?`Poetry ${t[1]}`:"Poetry detected",details:`Available at ${n}`}}catch{continue}return {status:"warn",message:"Poetry not installed",details:"Optional: Install for better dependency management"}}}async function tn(){try{let{stdout:e}=await execa("pipx",["--version"],{timeout:3e3});return {status:"ok",message:`pipx ${e.trim()}`,details:"Available for global tool installation"}}catch{let e=i$1();for(let n of e)try{let i=n==="py"?["-3","-m","pipx","--version"]:["-m","pipx","--version"],{stdout:t}=await execa(n,i,{timeout:3e3,shell:c()});return {status:"ok",message:`pipx ${t.trim()}`,details:`Available via ${n} ${i.join(" ")}`}}catch{continue}return {status:"warn",message:"pipx not installed",details:"Optional: Install for isolated Python tools"}}}async function nn(){try{let{stdout:e}=await execa("go",["version"],{timeout:3e3}),n=e.match(/go version go(\d+\.\d+(?:\.\d+)?)/);return n?{status:"ok",message:`Go ${n[1]}`,details:"Available for Go/Fiber and Go/Gin projects"}:{status:"ok",message:"Go (version unknown)",details:"go found in PATH"}}catch{return {status:"warn",message:"Go not installed",details:"Optional: Required only for gofiber.standard / gogin.standard projects \u2014 https://go.dev/dl/"}}}async function sn(){let e=process.env.HOME||process.env.USERPROFILE||"",n=[],i=Ht(e);for(let{location:c,path:o}of i)try{if(await a.pathExists(o)){let{stdout:s,exitCode:d}=await execa(o,["--version"],{timeout:3e3,reject:false});if(d===0&&(s.includes("RapidKit Version")||s.includes("RapidKit"))){let u=s.match(/v?([\d.]+(?:rc\d+)?(?:a\d+)?(?:b\d+)?)/);u&&n.push({location:c,path:o,version:u[1]});}}}catch{continue}if(n.length>0){let c=n.filter(s=>s.location!=="Workspace (launcher)");if(c.length>0){let s=Mt(c),d=s[0].version,u=s.some(f=>f.location==="Workspace (.venv)"),m=s.some(f=>f.location.startsWith("Global (")),p=!u&&m?"Workspace (.venv): not installed (optional). For best project-level performance and isolation, run npx rapidkit workspace run init inside this workspace.":void 0;return {status:"ok",message:`RapidKit Core ${d}`,details:p,paths:s.map(f=>({location:f.location,path:f.path,version:f.version}))}}return {status:"ok",message:`RapidKit Core ${n[0].version}`,details:"Detected via workspace launcher"}}try{let{stdout:c,exitCode:o}=await execa("rapidkit",["--version"],{timeout:3e3,reject:false});if(o===0&&(c.includes("RapidKit Version")||c.includes("RapidKit"))){let s=c.match(/v?([\d.]+(?:rc\d+)?(?:a\d+)?(?:b\d+)?)/);if(s)return {status:"ok",message:`RapidKit Core ${s[1]}`,details:"Available via PATH"}}}catch{}try{let{stdout:c,exitCode:o}=await execa("poetry",["run","rapidkit","--version"],{timeout:3e3,reject:false});if(o===0&&(c.includes("RapidKit Version")||c.includes("RapidKit"))){let s=c.match(/v?([\d.]+(?:rc\d+)?(?:a\d+)?(?:b\d+)?)/);if(s)return {status:"ok",message:`RapidKit Core ${s[1]}`,details:"Available via Poetry"}}}catch{}let t=i$1();for(let c of t)try{let{stdout:o,exitCode:s}=await execa(c,["-c","import rapidkit_core; print(rapidkit_core.__version__)"],{timeout:3e3,reject:false});if(s===0&&o&&!o.includes("Traceback")&&!o.includes("ModuleNotFoundError")){let d=o.trim();if(d)return {status:"ok",message:`RapidKit Core ${d}`,details:`Available in ${c} environment`}}}catch{continue}return {status:"error",message:"RapidKit Core not installed",details:"Install with: pipx install rapidkit-core"}}async function T(e,n,i){let t=r.join(e,"Dockerfile");n.hasDocker=await a.pathExists(t);let c=r.join(e,"tests"),o=r.join(e,"test"),s=r.join(e,"src","test"),d=await a.pathExists(c)||await a.pathExists(o)||await a.pathExists(s),u=false;if(n.framework==="Go/Fiber"||n.framework==="Go/Gin")try{let m=[{dir:e,depth:0}],p=4,f=new Set([".git",".venv","node_modules","dist","build","vendor"]);for(;m.length>0&&!u;){let g=m.shift();if(!g)break;let y=[];try{y=await a.readdir(g.dir);}catch{continue}for(let k of y){let h=r.join(g.dir,k),x;try{x=await a.stat(h);}catch{continue}if(x.isFile()&&k.endsWith("_test.go")){u=true;break}x.isDirectory()&&g.depth<p&&!f.has(k)&&!k.startsWith(".")&&m.push({dir:h,depth:g.depth+1});}}}catch{}if(n.hasTests=d||u,n.runtimeFamily==="node"&&!n.hasTests&&(n.hasTests=await Ze(e,i)),n.runtimeFamily==="node")n.hasCodeQuality=await Ye(e,i);else if(n.framework==="Go/Fiber"||n.framework==="Go/Gin"){let m=r.join(e,".golangci.yml"),p=r.join(e,".golangci.yaml"),f=r.join(e,"Makefile"),g=await a.pathExists(f)&&(await a.readFile(f,"utf8")).includes("golangci-lint");n.hasCodeQuality=await a.pathExists(m)||await a.pathExists(p)||g;}else if(n.runtimeFamily==="python"){let m=r.join(e,"ruff.toml"),p=r.join(e,"pyproject.toml");if(await a.pathExists(p))try{let f=await a.readFile(p,"utf8");n.hasCodeQuality=f.includes("[tool.ruff]")||await a.pathExists(m);}catch{n.hasCodeQuality=await a.pathExists(m);}}else if(n.framework==="Spring Boot"){let m=r.join(e,"pom.xml");if(await a.pathExists(m))try{let p=await a.readFile(m,"utf8");n.hasCodeQuality=p.includes("spotless")||p.includes("checkstyle")||p.includes("pmd")||p.includes("maven-enforcer-plugin");}catch{n.hasCodeQuality=false;}}try{if(n.runtimeFamily==="node"){let{stdout:m}=await execa("npm",["audit","--json"],{cwd:e,reject:false});if(m)try{let f=JSON.parse(m).metadata?.vulnerabilities;f&&(n.vulnerabilities=(f.high||0)+(f.critical||0)+(f.moderate||0));}catch{}}else if(n.runtimeFamily==="python"){let m=r.join(e,".venv"),p=l$1(m);if(await a.pathExists(p))try{let{stdout:f}=await execa(p,["-m","pip","list","--format=json"],{timeout:5e3,reject:false});if(f){JSON.parse(f);n.vulnerabilities=0;}}catch{}}}catch{}}function N(e,n){e.probes||(e.probes=[]),e.probes.push(n);}async function on(e,n){let i=n.runtimeFamily||"unknown";if(n.projectKind==="backend"||n.projectKind==="generic"){if(i==="node"){let c=await a.pathExists(r.join(e,"package-lock.json"))||await a.pathExists(r.join(e,"pnpm-lock.yaml"))||await a.pathExists(r.join(e,"yarn.lock"));N(n,{id:"adapter-node-lockfile-integrity",label:"Node adapter lockfile integrity",status:c?"pass":"warn",severity:"warn",scope:"project-scoped",reason:c?"Node lockfile detected for deterministic dependency restore.":"No Node lockfile detected (package-lock/yarn.lock/pnpm-lock.yaml).",recommendation:c?void 0:"Commit a lockfile for deterministic installs and CI parity."});let o=await a.pathExists(r.join(e,"src/main.ts"))||await a.pathExists(r.join(e,"src/main.js"))||await a.pathExists(r.join(e,"src/server.ts"))||await a.pathExists(r.join(e,"src/server.js"));N(n,{id:"adapter-node-boot-entrypoint",label:"Node adapter boot entrypoint",status:o?"pass":"warn",severity:"warn",scope:"project-scoped",reason:o?"Boot entrypoint markers detected for service startup path.":"No canonical Node boot entrypoint markers detected.",recommendation:o?void 0:"Define and document service bootstrap entrypoint (main/server)."});return}if(i==="python"){let c=await a.pathExists(r.join(e,"poetry.lock"))||await a.pathExists(r.join(e,"requirements.txt"))||await a.pathExists(r.join(e,"uv.lock"));N(n,{id:"adapter-python-lockfile-integrity",label:"Python adapter dependency integrity",status:c?"pass":"warn",severity:"warn",scope:"project-scoped",reason:c?"Python dependency contract file detected.":"No Python dependency contract file detected (poetry.lock/requirements/uv.lock).",recommendation:c?void 0:"Pin dependency contract for deterministic setup and reproducible CI."});let o=await a.pathExists(r.join(e,"app/main.py"))||await a.pathExists(r.join(e,"main.py"))||await a.pathExists(r.join(e,"manage.py"));N(n,{id:"adapter-python-boot-entrypoint",label:"Python adapter boot entrypoint",status:o?"pass":"warn",severity:"warn",scope:"project-scoped",reason:o?"Python application entrypoint markers detected.":"No Python application entrypoint markers detected.",recommendation:o?void 0:"Expose explicit app/main entrypoint for deterministic boot probes."});return}if(i==="java"){let c=await a.pathExists(r.join(e,"mvnw"))||await a.pathExists(r.join(e,"gradlew"));N(n,{id:"adapter-java-build-wrapper",label:"Java adapter build wrapper",status:c?"pass":"warn",severity:"warn",scope:"project-scoped",reason:c?"Build wrapper detected (mvnw/gradlew).":"No Java build wrapper detected.",recommendation:c?void 0:"Commit mvnw or gradlew for reproducible enterprise pipelines."});return}if(i==="go"){let c=await a.pathExists(r.join(e,"go.sum"));N(n,{id:"adapter-go-module-integrity",label:"Go adapter module integrity",status:c?"pass":"warn",severity:"warn",scope:"project-scoped",reason:c?"go.sum detected for deterministic module verification.":"go.sum missing; module integrity baseline is incomplete.",recommendation:c?void 0:"Generate and commit go.sum in the repository baseline."});}}}async function rn(e,n){let i=[r.join(e,".rapidkit","doctor.adapters.json"),r.join(e,"doctor.adapters.json")];for(let t of i)if(await a.pathExists(t))try{let c=await a.readJSON(t),o=Array.isArray(c?.checks)?c.checks:[];for(let s=0;s<o.length;s+=1){let d=o[s]||{},u=Array.isArray(d.runtimes)?d.runtimes:[];if(u.length>0&&!u.includes(n.runtimeFamily||"unknown"))continue;let m=typeof d.id=="string"&&d.id.trim().length>0?d.id.trim():`adapter-check-${s+1}`,p=typeof d.label=="string"&&d.label.trim().length>0?d.label.trim():m,f=d.severity||"warn",g=Array.isArray(d.anyOfPaths)?d.anyOfPaths.filter(Boolean):[],y=Array.isArray(d.allOfPaths)?d.allOfPaths.filter(Boolean):[],k=g.length===0;for(let b of g)if(await a.pathExists(r.join(e,b))){k=true;break}let h=true;for(let b of y)if(!await a.pathExists(r.join(e,b))){h=false;break}let x=k&&h;N(n,{id:m,label:p,status:x?"pass":f==="error"?"fail":"warn",severity:f,scope:"project-scoped",reason:x?d.passReason||"Custom adapter contract satisfied.":d.failReason||`Custom adapter check failed from ${r.basename(t)}.`,recommendation:d.recommendation});}}catch{N(n,{id:"custom-adapter-config",label:"Custom doctor adapter configuration",status:"warn",severity:"warn",scope:"project-scoped",reason:`Failed to parse ${r.basename(t)}.`,recommendation:"Fix JSON syntax in doctor.adapters.json to re-enable adapter checks."});}}async function O(e,n){if(!(n.projectKind==="backend"||n.projectKind==="generic"))return;let t=r.join(e,".env"),c=r.join(e,".env.example"),o=await a.pathExists(t)||await a.pathExists(c)||await a.pathExists(r.join(e,"config"));N(n,{id:"config-surface",label:"Configuration contract surface",status:o?"pass":"warn",severity:"warn",scope:"project-scoped",reason:o?"Configuration artifacts detected (.env/.env.example/config).":"No explicit configuration contract artifacts detected.",recommendation:o?void 0:"Add .env.example or explicit config contract documentation for deterministic setup."});let s={python:["alembic.ini","migrations","versions"],node:["prisma/schema.prisma","migrations","typeorm.config.ts","typeorm.config.js"],go:["migrations","db/migrations"],java:["src/main/resources/db/migration","src/main/resources/liquibase"],rust:["migrations","sqlx-data.json"],elixir:["priv/repo/migrations"],clojure:["resources/migrations","migrations"],deno:["migrations"],php:["database/migrations","migrations"],ruby:["db/migrate"],dotnet:["Migrations","Data/Migrations"],unknown:["migrations"]},d=n.runtimeFamily||"unknown",u=s[d]||s.unknown,m=false;for(let g of u)if(await a.pathExists(r.join(e,g))){m=true;break}N(n,{id:"migration-surface",label:"Migration/readiness surface",status:m?"pass":"warn",severity:"warn",scope:"project-scoped",reason:m?"Migration or schema evolution markers detected.":"No migration markers detected for this backend runtime.",recommendation:m?void 0:"Add migration tooling baseline (migrations dir or runtime-native migration config)."});let p=["src/health","src/healthcheck","src/main/resources/application.yml","src/main/resources/application.properties","app/health.py","routes/health.ts","routes/health.js"],f=false;for(let g of p)if(await a.pathExists(r.join(e,g))){f=true;break}N(n,{id:"runtime-health-surface",label:"Runtime health probe surface",status:f?"pass":"warn",severity:"warn",scope:"project-scoped",reason:f?"Health endpoint/config markers detected.":"No explicit runtime health endpoint markers detected.",recommendation:f?void 0:"Expose a deterministic health endpoint and keep it covered in verify pack."}),await on(e,n);}async function an(e,n,i,t){let c=await et({projectPath:e,detection:t,packageJsonData:i});for(let o of c)N(n,o);}async function G(e,n){let i=[r.join(e,".rapidkit","doctor.probes.json"),r.join(e,"doctor.probes.json")];for(let t of i)if(await a.pathExists(t))try{let c=await a.readJSON(t),o=Array.isArray(c?.probes)?c.probes:[];for(let s=0;s<o.length;s+=1){let d=o[s]||{},u=typeof d.id=="string"&&d.id.trim().length>0?d.id.trim():`custom-probe-${s+1}`,m=typeof d.label=="string"&&d.label.trim().length>0?d.label.trim():u,p=d.severity||"warn",f=Array.isArray(d.anyOfPaths)?d.anyOfPaths.filter(Boolean):[],g=Array.isArray(d.allOfPaths)?d.allOfPaths.filter(Boolean):[],y=f.length===0;for(let x of f)if(await a.pathExists(r.join(e,x))){y=true;break}let k=true;for(let x of g)if(!await a.pathExists(r.join(e,x))){k=false;break}let h=y&&k;N(n,{id:u,label:m,status:h?"pass":p==="error"?"fail":"warn",severity:p,scope:"project-scoped",reason:h?"Custom probe contract satisfied.":`Custom probe failed from ${r.basename(t)}.`,recommendation:d.recommendation});}}catch{N(n,{id:"custom-probe-config",label:"Custom doctor probe configuration",status:"warn",severity:"warn",scope:"project-scoped",reason:`Failed to parse ${r.basename(t)}.`,recommendation:"Fix JSON syntax in doctor.probes.json to re-enable custom probes."});}await rn(e,n);}async function we(e,n={}){let t={name:r.basename(e),path:e,venvActive:false,depsInstalled:false,coreInstalled:false,issues:[],fixCommands:[]},c=n.allowNonRapidkit===true,o=r.join(e,".rapidkit");if(!await a.pathExists(o)){if(!c)return t.issues.push("Not a valid RapidKit project (missing .rapidkit directory)"),t;t.issues.push("Not a RapidKit-managed project (running generic backend diagnostics)");}try{let w=r.join(e,"registry.json");if(await a.pathExists(w)){let v=await a.readJson(w);v.installed_modules&&(t.stats={modules:v.installed_modules.length});}}catch{}try{let{auditProjectModulePaths:w}=await import('./module-layout-NZ43RSC5.js'),v=await w(e);if(v.issues.length>0){for(let E of v.issues)t.issues.push(`${E.message} (${E.slug})`);t.fixCommands=t.fixCommands??[],t.fixCommands.push("npx rapidkit workspace contract verify --strict --json"),t.fixCommands.push("npx rapidkit add module <slug> # reinstall via Core-backed module install");}}catch{}let s=null;try{let w=r.join(o,"project.json");if(await a.pathExists(w)){s=await a.readJson(w);let v=s?.kit_name||s?.kit;v&&(t.kit=v);}}catch{}try{let w=r.join(e,".git");if(await a.pathExists(w)){let{stdout:v}=await execa("git",["log","-1","--format=%cr"],{cwd:e,reject:false});v&&(t.lastModified=v.trim());}else {let v=await a.stat(e),D=Date.now()-v.mtime.getTime(),A=Math.floor(D/(1e3*60*60*24));t.lastModified=A===0?"today":`${A} day${A>1?"s":""} ago`;}}catch{}let d$1=r.join(e,"package.json"),u=r.join(e,"pyproject.toml"),m=r.join(e,"requirements.txt"),p=r.join(e,"go.mod"),f=r.join(e,"pom.xml"),g=r.join(e,"build.sbt"),y=r.join(e,"Cargo.toml"),k=r.join(e,"mix.exs"),h=r.join(e,"deps.edn"),x=r.join(e,"project.clj"),b=r.join(e,"deno.json"),H=r.join(e,"deno.jsonc"),fe=r.join(e,"bun.lockb"),K=r.join(e,"bun.lock"),U=r.join(e,"composer.json"),Q=r.join(e,"Gemfile"),V=await a.pathExists(d$1),ce=await a.pathExists(u)||await a.pathExists(m),oe=await a.pathExists(U),L=await a.pathExists(Q),M=await a.pathExists(y),ie=await a.pathExists(k),le=await a.pathExists(h)||await a.pathExists(x),vt=await a.pathExists(g),xt=await a.pathExists(b)||await a.pathExists(H),ge=s?.runtime==="dotnet";try{ge=ge||await nt(e,".csproj",3)||await nt(e,".sln",2);}catch{ge=s?.runtime==="dotnet";}let bt=await a.pathExists(p)||s?.runtime==="go"||typeof s?.kit_name=="string"&&(s.kit_name.startsWith("gofiber")||s.kit_name.startsWith("gogin")),Be=V&&(await a.pathExists(fe)||await a.pathExists(K)||typeof s?.packageManager=="string"&&(s?.packageManager).toLowerCase().startsWith("bun@"));if(bt){W(t,i(e,s??null)),t.isGoProject=true,t.venvActive=true,t.coreInstalled=false;try{await execa("go",["version"],{timeout:3e3});}catch{t.issues.push("Go toolchain not found \u2014 install from https://go.dev/dl/"),t.fixCommands?.push("https://go.dev/dl/");}let w=r.join(e,"go.sum");return await a.pathExists(w)?t.depsInstalled=true:(t.depsInstalled=false,t.issues.push("Go dependencies not downloaded (go.sum missing)"),t.fixCommands?.push($(e,"go mod tidy"))),await T(e,t),await O(e,t),await G(e,t),t}if(await a.pathExists(f)||s?.runtime==="java"||typeof s?.kit_name=="string"&&s.kit_name.startsWith("springboot")){W(t,i(e,s??null)),t.venvActive=true,t.coreInstalled=false;let w=await a.pathExists(f),v=await a.pathExists(r.join(e,"build.gradle"))||await a.pathExists(r.join(e,"build.gradle.kts")),E=await a.pathExists(r.join(e,"mvnw"))||await a.pathExists(r.join(e,"mvnw.cmd")),D=await a.pathExists(r.join(e,"gradlew"))||await a.pathExists(r.join(e,"gradlew.bat"));try{await execa("java",["-version"],{timeout:3e3,reject:false});}catch{t.issues.push("Java runtime not found \u2014 install JDK 21+ and ensure java is on PATH"),t.fixCommands?.push("https://adoptium.net/");}if(w){if(!E)try{await execa("mvn",["-version"],{timeout:3e3,reject:false});}catch{t.issues.push("Maven not found \u2014 install Maven 3.9+ or add Maven Wrapper"),t.fixCommands?.push("https://maven.apache.org/install.html");}}else if(v&&!D)try{await execa("gradle",["--version"],{timeout:3e3,reject:false});}catch{t.issues.push("Gradle not found \u2014 install Gradle 8+ or add Gradle Wrapper"),t.fixCommands?.push("https://gradle.org/install/");}let A=r.join(e,"target"),I=r.join(e,"build","libs"),_=r.join(e,".rapidkit","cache","java","m2"),C=r.join(e,".rapidkit","cache","java","gradle");t.depsInstalled=await a.pathExists(A)||await a.pathExists(I)||await a.pathExists(_)||await a.pathExists(C),t.depsInstalled||(t.issues.push("Java dependencies are not warmed or built yet"),t.fixCommands?.push($(e,"rapidkit init")));let S=r.join(e,".env");if(t.hasEnvFile=await a.pathExists(S),!t.hasEnvFile){let X=r.join(e,".env.example");await a.pathExists(X)&&(t.issues.push("Environment file missing (found .env.example)"),t.fixCommands?.push(z(e)));}let q=r.join(e,"src","main","resources","application.yml");if(await a.pathExists(q))try{let X=await a.readFile(q,"utf-8");/include:\s*[^\n]*health/i.test(X)||/management:\s*[\s\S]*endpoint:\s*[\s\S]*health:/i.test(X)||(t.issues.push("Actuator health endpoint exposure is not clearly configured in application.yml"),t.fixCommands?.push($(e,"Ensure management.endpoints.web.exposure.include contains health in src/main/resources/application.yml")));}catch{t.issues.push("Unable to read application.yml for Spring Actuator health checks");}return await T(e,t),await O(e,t),await G(e,t),t}if(M){W(t,i(e,s??null)),t.venvActive=true,t.coreInstalled=false;let w=r.join(e,"Cargo.lock"),v=r.join(e,"target");t.depsInstalled=await a.pathExists(w)||await a.pathExists(v),t.depsInstalled||(t.issues.push("Rust dependencies are not resolved yet (Cargo.lock/target missing)"),t.fixCommands?.push($(e,"cargo fetch")));let E=r.join(e,".env");if(t.hasEnvFile=await a.pathExists(E),!t.hasEnvFile){let D=r.join(e,".env.example");await a.pathExists(D)&&(t.issues.push("Environment file missing (found .env.example)"),t.fixCommands?.push(z(e)));}return await T(e,t),await O(e,t),await G(e,t),t}if(ie){W(t,i(e,s??null)),t.venvActive=true,t.coreInstalled=false;let w=r.join(e,"mix.lock"),v=r.join(e,"deps");t.depsInstalled=await a.pathExists(w)||await a.pathExists(v),t.depsInstalled||(t.issues.push("Elixir dependencies not installed (mix.lock/deps missing)"),t.fixCommands?.push($(e,"mix deps.get")));let E=r.join(e,".env");if(t.hasEnvFile=await a.pathExists(E),!t.hasEnvFile){let D=r.join(e,".env.example");await a.pathExists(D)&&(t.issues.push("Environment file missing (found .env.example)"),t.fixCommands?.push(z(e)));}return await T(e,t),await O(e,t),await G(e,t),t}if(le){W(t,i(e,s??null)),t.venvActive=true,t.coreInstalled=false;let w=r.join(e,".cpcache"),v=r.join(e,"target"),E=await a.pathExists(h)||await a.pathExists(x);return t.depsInstalled=await a.pathExists(w)||await a.pathExists(v)||E,t.depsInstalled||(t.issues.push("Clojure dependency cache not initialized"),t.fixCommands?.push($(e,"clojure -P"))),await T(e,t),await O(e,t),await G(e,t),t}if(vt){W(t,i(e,s??null)),t.venvActive=true,t.coreInstalled=false;let w=r.join(e,"target");t.depsInstalled=await a.pathExists(w),t.depsInstalled||(t.issues.push("Scala build artifacts missing (run dependency/build warmup)"),t.fixCommands?.push($(e,"sbt compile")));let v=r.join(e,".env");if(t.hasEnvFile=await a.pathExists(v),!t.hasEnvFile){let E=r.join(e,".env.example");await a.pathExists(E)&&(t.issues.push("Environment file missing (found .env.example)"),t.fixCommands?.push(z(e)));}return await T(e,t),await O(e,t),await G(e,t),t}if(xt){W(t,i(e,s??null)),t.venvActive=true,t.coreInstalled=false,t.depsInstalled=true;let w=r.join(e,".env");if(t.hasEnvFile=await a.pathExists(w),!t.hasEnvFile){let v=r.join(e,".env.example");await a.pathExists(v)&&(t.issues.push("Environment file missing (found .env.example)"),t.fixCommands?.push(z(e)));}return await T(e,t),await O(e,t),await G(e,t),t}if(V){let w=null;try{w=await a.readJson(d$1);}catch{w=null;}let v={...w?.dependencies??{},...w?.devDependencies??{}},E=w?.scripts??{},D=typeof s?.kit_name=="string"?s.kit_name.toLowerCase():typeof s?.kit=="string"?s.kit.toLowerCase():"",A=d(e,s),I=Jt({dependencies:v,scripts:E,kitName:D});if(Be)he(t,"Bun","high");else {let C=i(e,s??null);C.key==="nestjs"||C.key==="express"||C.key==="fastify"||C.key==="koa"?W(t,C):A.key!=="unknown"?Lt(t,A):C.key!=="unknown"&&C.key!=="node"?W(t,C):he(t,I.framework,I.confidence);}t.venvActive=true;let _=r.join(e,"node_modules");if(await a.pathExists(_))try{let S=(await a.readdir(_)).filter(q=>!q.startsWith(".")&&!q.startsWith("_"));t.depsInstalled=S.length>0;}catch{t.depsInstalled=false;}if(t.depsInstalled||(t.issues.push("Dependencies not installed (node_modules empty or missing)"),t.fixCommands?.push($(e,Be?"bun install":"rapidkit init"))),t.coreInstalled=false,t.projectKind==="frontend"){let C=[".env",".env.local",".env.development",".env.development.local",".env.production",".env.production.local"];if((await Promise.all(C.map(q=>a.pathExists(r.join(e,q))))).some(Boolean))t.hasEnvFile=true;else {let q=r.join(e,".env.example");await a.pathExists(q)&&(t.hasEnvFile=false,t.issues.push("Environment file missing (found .env.example)"),t.fixCommands?.push(z(e)));}}else {let C=r.join(e,".env");if(t.hasEnvFile=await a.pathExists(C),!t.hasEnvFile){let S=r.join(e,".env.example");await a.pathExists(S)&&(t.issues.push("Environment file missing (found .env.example)"),t.fixCommands?.push(z(e)));}}if(t.projectKind==="frontend")t.modulesHealthy=await Re(e),t.missingModules=[];else {let C=r.join(e,"src");if(t.modulesHealthy=true,t.missingModules=[],await a.pathExists(C))try{let S=await a.readdir(C);t.modulesHealthy=S.length>0;}catch{t.modulesHealthy=false;}}return await T(e,t,w),t.projectKind==="frontend"?await an(e,t,w,A.key!=="unknown"?A:d(e,s)):await O(e,t),await G(e,t),t}if(ce){let w=await qt(e);he(t,w.framework,w.confidence);let v=r.join(e,".venv");if(await a.pathExists(v)){t.venvActive=true;let I=l$1(v);if(await a.pathExists(I)){try{let{stdout:S}=await execa(I,["-c","import rapidkit_core; print(rapidkit_core.__version__)"],{timeout:2e3});t.coreInstalled=true,t.coreVersion=S.trim();}catch{t.coreInstalled=false;}let _="fastapi";t.framework==="Django"?_="django":t.framework==="Flask"?_="flask":t.framework==="Python"&&(_="");let C=true;if(_)try{await execa(I,["-c",`import ${_}`],{timeout:2e3}),t.depsInstalled=true,C=false;}catch{C=true;}if(C)try{let S=r.join(v,"lib");if(await a.pathExists(S)){let X=(await a.readdir(S)).find(de=>de.startsWith("python"));if(X){let de=r.join(S,X,"site-packages");if(await a.pathExists(de)){let jt=(await a.readdir(de)).filter(ve=>!ve.startsWith("_")&&!ve.includes("dist-info")&&!["pip","setuptools","wheel","pkg_resources"].includes(ve));t.depsInstalled=jt.length>0;}}}t.depsInstalled||(t.issues.push("Dependencies not installed"),t.fixCommands?.push($(e,"rapidkit init")));}catch{t.issues.push("Could not verify dependency installation");}}else t.issues.push("Virtual environment exists but Python executable not found");}else t.issues.push("Virtual environment not created"),t.fixCommands?.push($(e,"rapidkit init"));let E=r.join(e,".env");if(t.hasEnvFile=await a.pathExists(E),!t.hasEnvFile){let I=r.join(e,".env.example");await a.pathExists(I)&&(t.issues.push("Environment file missing (found .env.example)"),t.fixCommands?.push(z(e)));}let D=r.join(e,"src"),A=r.join(e,"modules");if(t.modulesHealthy=true,t.missingModules=[],await a.pathExists(D)){let I=r.join(D,"__init__.py");await a.pathExists(I)||(t.modulesHealthy=false,t.missingModules.push("src/__init__.py"));}if(await a.pathExists(A))try{let I=await mt(A);for(let _ of I){let C=r.join(A,_,"__init__.py");await a.pathExists(C)||(t.modulesHealthy=false,t.missingModules.push(`modules/${_}/__init__.py`));}}catch{}return !t.modulesHealthy&&t.missingModules.length>0&&t.issues.push(`Missing module init files: ${t.missingModules.join(", ")}`),await T(e,t),await O(e,t),await G(e,t),t}if(oe){W(t,i(e,s??null)),t.venvActive=true,t.coreInstalled=false;let w=r.join(e,"vendor");t.depsInstalled=await a.pathExists(w),t.depsInstalled||(t.issues.push("PHP dependencies not installed (vendor missing)"),t.fixCommands?.push($(e,"composer install")));let v=r.join(e,".env");if(t.hasEnvFile=await a.pathExists(v),!t.hasEnvFile){let E=r.join(e,".env.example");await a.pathExists(E)&&(t.issues.push("Environment file missing (found .env.example)"),t.fixCommands?.push(z(e)));}return await T(e,t),await O(e,t),await G(e,t),t}if(L){W(t,i(e,s??null)),t.venvActive=true,t.coreInstalled=false;let w=await a.pathExists(r.join(e,"Gemfile.lock")),v=await a.pathExists(r.join(e,"vendor","bundle"));t.depsInstalled=w||v,t.depsInstalled||(t.issues.push("Ruby dependencies not installed (Gemfile.lock/vendor missing)"),t.fixCommands?.push($(e,"bundle install")));let E=r.join(e,".env");return t.hasEnvFile=await a.pathExists(E),await T(e,t),await O(e,t),await G(e,t),t}if(ge){W(t,i(e,s??null)),t.venvActive=true,t.coreInstalled=false;let w=r.join(e,"obj"),v=r.join(e,"src","obj"),E=r.join(e,"packages.lock.json");t.depsInstalled=await a.pathExists(w)||await a.pathExists(v)||await a.pathExists(E),t.depsInstalled||(t.issues.push(".NET restore/build artifacts not found"),t.fixCommands?.push($(e,"dotnet restore")));let D=r.join(e,".env");return t.hasEnvFile=await a.pathExists(D),await T(e,t),await O(e,t),await G(e,t),t}return he(t,"Unknown","low"),t.issues.push("Unknown project type (no recognized runtime marker files)"),await T(e,t),await O(e,t),await G(e,t),t}async function mt(e){try{return (await a.readdir(e,{withFileTypes:true})).filter(i=>i.isDirectory()).map(i=>i.name)}catch{try{let n=await a.readdir(e),i=[];for(let t of n)try{(await a.stat(r.join(e,t))).isDirectory()&&i.push(t);}catch{continue}return i}catch{return []}}}async function nt(e,n,i){let t=[{dir:e,depth:0}],c=new Set([".git",".rapidkit","node_modules","bin","obj","target"]);for(;t.length>0;){let o=t.shift();if(!o||o.depth>i)continue;let s;try{s=await a.readdir(o.dir,{withFileTypes:true});}catch{continue}for(let d of s){if(d.isFile()&&d.name.toLowerCase().endsWith(n.toLowerCase()))return true;d.isDirectory()&&!c.has(d.name)&&t.push({dir:r.join(o.dir,d.name),depth:o.depth+1});}}return false}async function pe(e){let n=r.join(e,".rapidkit");if(!await a.pathExists(n))return false;let i=["project.json","context.json","file-hashes.json"];for(let t of i)if(await a.pathExists(r.join(n,t)))return true;return false}function ft(e,n){if(n.has(e))return true;let i=e.toLowerCase();return !!(i==="dist"||i.startsWith("dist-")||i.startsWith("dist_")||i==="build"||i.startsWith("build-")||i.startsWith("build_"))}async function cn(e,n,i){let t=new Set,c=[{dir:e,depth:0}];for(;c.length>0;){let o=c.shift();if(!o)break;try{let s=await a.readdir(o.dir);for(let d of s){if(ft(d,i))continue;let u=r.join(o.dir,d),m;try{m=await a.stat(u);}catch{continue}if(m.isDirectory()){if(await pe(u)){t.add(u);continue}o.depth<n&&c.push({dir:u,depth:o.depth+1});}}}catch{continue}}return Array.from(t)}async function me(e){let n=r.resolve(e),i=r.parse(n).root;for(;;){if(await un(n))return n;if(n===i)break;n=r.dirname(n);}return null}async function ln(e){let n=r.resolve(e),i=await me(n),t=i??r.parse(n).root;for(;;){if(await pe(n)||await dn(n)&&(!i||n!==i))return n;if(n===t)break;n=r.dirname(n);}return null}function st(e){let n=r.resolve(e);return process.platform==="darwin"?n.replace(/^\/private(?=\/var\/)/,""):n}async function dn(e){let n=["package.json","pyproject.toml","requirements.txt","go.mod","pom.xml","build.sbt","Cargo.toml","mix.exs","deps.edn","project.clj","deno.json","deno.jsonc","composer.json","Gemfile"];for(let i of n)if(await a.pathExists(r.join(e,i)))return true;return false}async function un(e){let n=[r.join(e,".rapidkit-workspace"),r.join(e,".rapidkit","workspace-marker.json"),r.join(e,".rapidkit","config.json")];return Promise.all(n.map(i=>a.pathExists(i))).then(i=>i.some(Boolean))}function gt(e,n){let i=0,t=0,c=0;return e.forEach(s=>{s.status==="ok"?i++:s.status==="warn"?t++:s.status==="error"&&c++;}),n.forEach(s=>{let d=ne(s),u=s.isGoProject?s.issues.length===0&&s.depsInstalled:s.issues.length===0&&s.venvActive&&s.depsInstalled;if(s.issues.length>0||d>0||!u){t++;return}i++;}),{total:i+t+c,passed:i,warnings:t,errors:c}}function ht(e,n,i={}){let t=[];for(let o of e)t.push({id:o.id,label:o.label,status:o.result.status,scope:"host-system",policyRuleId:"system-status-derived",reason:o.result.details||o.result.message});let c=[...n].sort((o,s)=>{let d=`${o.path||""}|${o.name||""}`.toLowerCase(),u=`${s.path||""}|${s.name||""}`.toLowerCase();return d.localeCompare(u)});for(let o of c){let s=o.issues.length>0,d=ne(o),u=s||d>0?"warn":"ok",m=s?`${o.issues.length} blocking issue(s)`:d>0?`${d} advisory warning(s)`:"Project checks passed";t.push({id:`project:${o.name}`,label:`Project ${o.name}`,status:u,scope:"project-scoped",policyRuleId:s?"project-blocking-issues":d>0?"project-advisory-warnings":"project-checks-passed",reason:m});}if(i.includeWorkspaceAggregateRules){let o=n.reduce((u,m)=>u+m.issues.length,0),s=He(n),d=e.filter(u=>u.result.status==="error").length;t.push({id:"workspace:projects-discovered",label:"Workspace projects discovered",status:n.length>0?"ok":"warn",scope:"workspace-aggregate",policyRuleId:"workspace-project-discovery",reason:n.length>0?`${n.length} project(s) discovered for workspace analysis.`:"No projects discovered for workspace analysis."}),t.push({id:"workspace:system-error-gate",label:"Workspace system error gate",status:d>0?"error":"ok",scope:"workspace-aggregate",policyRuleId:"workspace-system-error-gate",reason:d>0?`${d} system requirement gate(s) failed.`:"All system requirement gates passed."}),t.push({id:"workspace:blocking-issues-gate",label:"Workspace blocking issues gate",status:o>0?"warn":"ok",scope:"workspace-aggregate",policyRuleId:"workspace-blocking-issues-gate",reason:o>0?`${o} blocking project issue(s) detected.`:"No blocking project issues detected."}),t.push({id:"workspace:advisory-warnings-gate",label:"Workspace advisory warnings gate",status:s>0?"warn":"ok",scope:"workspace-aggregate",policyRuleId:"workspace-advisory-warning-gate",reason:s>0?`${s} advisory warning(s) detected.`:"No advisory warnings detected."});}return t}async function Fe(e,n=true){let i=r.basename(e);try{let g=r.join(e,".rapidkit-workspace");await a.pathExists(g)&&(i=(await a.readJSON(g)).name||i);}catch{try{let g=r.join(e,".rapidkit","config.json");i=(await a.readJSON(g)).workspace_name||i;}catch{}}let[t,c]=await Promise.all([_e(),Ut(e)]),o={workspacePath:e,workspaceName:i,python:t.python,poetry:t.poetry,pipx:t.pipx,go:t.go,rapidkitCore:t.rapidkitCore,projects:[]};f.debug(`Workspace scan found ${c.length} project(s)`);let s=await zt(e,c),d=r.join(e,".rapidkit","reports","doctor-workspace-cache.json"),u=n?await Qt(d,s):null;if(u){o.projects=u.projects;for(let g of o.projects)Ae(g,g.path);o.projectScanCached=true,f.debug(`Workspace project health cache hit: ${d}`);}else try{let g=await Promise.all(c.map(y=>we(y)));for(let y of g)Ae(y,y.path);o.projects=g,o.projectScanCached=false,await Xt(d,{schemaVersion:at,signature:s,generatedAt:new Date().toISOString(),projects:g}),f.debug(`Workspace project health cache refreshed: ${d}`);}catch(g){f.debug(`Failed to scan workspace projects: ${g}`);}o.projectScanSignature=s,o.projectScanCachePath=d;let m=[o.python,o.poetry,o.pipx,o.go,o.rapidkitCore];if(o.healthScore=gt(m,o.projects),o.scoreBreakdown=ht([{id:"system-python",label:"Python",result:o.python},{id:"system-poetry",label:"Poetry",result:o.poetry},{id:"system-pipx",label:"pipx",result:o.pipx},{id:"system-go",label:"Go",result:o.go},{id:"system-rapidkit-core",label:"RapidKit Core",result:o.rapidkitCore}],o.projects,{includeWorkspaceAggregateRules:true}),o.scopeProvenance=ut(o.scoreBreakdown),o.rapidkitCore.status==="ok"){let g=o.rapidkitCore.message.match(/([\d.]+(?:rc\d+)?(?:a\d+)?(?:b\d+)?)/);g&&(o.coreVersion=g[1]);}let p=r.join(e,".rapidkit","reports","doctor-last-run.json"),f$1=await lt(p,"workspace");return o.driftDelta=Tt(f$1,o),o.evidencePath=await Yt(e,o,u?d:null),o}function ot(e){return {name:e.name,path:e.path,framework:e.framework,frameworkKey:e.frameworkKey,importStack:e.importStack,runtimeFamily:e.runtimeFamily,projectKind:e.projectKind,supportTier:e.supportTier,frameworkConfidence:e.frameworkConfidence,kit:e.kit,venvActive:e.venvActive,depsInstalled:e.depsInstalled,hasEnvFile:e.hasEnvFile,modulesHealthy:e.modulesHealthy,missingModules:e.missingModules,hasTests:e.hasTests,hasDocker:e.hasDocker,hasCodeQuality:e.hasCodeQuality,vulnerabilities:e.vulnerabilities,coreInstalled:e.coreInstalled,coreVersion:e.coreVersion,lastModified:e.lastModified,stats:e.stats,issues:e.issues,fixCommands:e.fixCommands,probes:e.probes,commandCapabilities:e.commandCapabilities}}async function pn(e$1,n){let i=e$1||n.projectPath,t=r.join(i,".rapidkit","reports","doctor-project-last-run.json");try{await a.ensureDir(r.dirname(t));let c=n.project.issues.filter(o=>typeof o=="string"&&o.trim().length>0).slice(0,12);return await a.writeJSON(t,f$1({schemaVersion:b$1,evidenceType:"project",contract:ye(),workspacePath:e$1||null,projectPath:n.projectPath,projectName:n.projectName,healthScore:n.healthScore,system:{python:n.python,poetry:n.poetry,pipx:n.pipx,go:n.go,rapidkitCore:n.rapidkitCore},project:n.project,driftDelta:n.driftDelta,summary:{scopeProvenance:n.scopeProvenance},scoreBreakdown:n.scoreBreakdown??[]},{commandId:"projectDoctor",exitCode:ae(n.healthScore,{}),generatedAt:new Date().toISOString(),blockers:c,runId:e()}),{spaces:2}),t}catch{return}}async function mn(e){let n=await me(e),i=await _e(),t=await we(e,{allowNonRapidkit:true});Ae(t,e);let c=gt([i.python,i.poetry,i.pipx,i.go,i.rapidkitCore],[t]),o={workspacePath:n||void 0,projectPath:e,projectName:r.basename(e),python:i.python,poetry:i.poetry,pipx:i.pipx,go:i.go,rapidkitCore:i.rapidkitCore,project:t,healthScore:c};o.scoreBreakdown=ht([{id:"system-python",label:"Python",result:o.python},{id:"system-poetry",label:"Poetry",result:o.poetry},{id:"system-pipx",label:"pipx",result:o.pipx},{id:"system-go",label:"Go",result:o.go},{id:"system-rapidkit-core",label:"RapidKit Core",result:o.rapidkitCore}],[o.project]),o.scopeProvenance=ut(o.scoreBreakdown);let s=n||e,d=r.join(s,".rapidkit","reports","doctor-project-last-run.json"),u=await lt(d,"project");return o.driftDelta=Ot(u,o),o.evidencePath=await pn(n||void 0,o),o}function F(e,n){let i=e.status==="ok"?"\u2705":e.status==="warn"?"\u26A0\uFE0F":"\u274C",t=e.status==="ok"?l.green:e.status==="warn"?l.yellow:l.red;console.log(`${i} ${l.bold(n)}: ${t(e.message)}`),e.paths&&e.paths.length>0&&e.paths.forEach(c=>{let o=c.version?l.cyan(` -> ${c.version}`):"";console.log(` ${l.cyan("\u2022")} ${l.gray(c.location)}: ${l.dim(c.path)}${o}`);}),e.details&&console.log(` ${l.gray(e.details)}`);}function it(e){let n=e.issues.length>0,i=n?"\u26A0\uFE0F":"\u2705",t=n?l.yellow:l.green;if(console.log(`
|
|
2
|
+
${i} ${l.bold("Project")}: ${t(e.name)}`),e.framework){let s=e.framework==="FastAPI"||e.framework==="Django"||e.framework==="Flask"?"\u{1F40D}":e.framework==="NestJS"?"\u{1F985}":e.framework==="Next.js"||e.framework==="Nuxt"||e.framework==="Remix"?"\u25B2":e.framework==="React"||e.framework==="Vite"?"\u269B\uFE0F":e.framework==="Vue"?"\u{1F7E2}":e.framework==="Angular"?"\u{1F170}\uFE0F":e.framework==="SvelteKit"?"\u{1F9E1}":e.framework==="Spring Boot"?"\u2615":e.framework==="Rust"?"\u{1F980}":e.framework==="Elixir"||e.framework==="Phoenix"?"\u{1F9EA}":e.framework==="Clojure"?"\u2699\uFE0F":e.framework==="Scala"?"\u{1F53A}":e.framework==="Kotlin"?"\u{1F7E3}":e.framework==="Deno"?"\u{1F995}":e.framework==="Bun"?"\u{1F956}":e.framework==="Go/Fiber"||e.framework==="Go/Gin"?"\u{1F439}":e.framework==="Laravel"||e.framework==="PHP"?"\u{1F418}":e.framework==="Ruby on Rails"||e.framework==="Ruby"?"\u{1F48E}":e.framework==="ASP.NET"?"\u{1F537}":"\u{1F4E6}";console.log(` ${s} Framework: ${l.cyan(e.framework)}${e.kit?l.gray(` (${e.kit})`):""}`);let d=[];e.runtimeFamily&&d.push(`runtime: ${e.runtimeFamily}`),e.projectKind&&d.push(`kind: ${e.projectKind}`),e.supportTier&&d.push(`support: ${e.supportTier}`),e.frameworkConfidence&&d.push(`confidence: ${e.frameworkConfidence}`),d.length>0&&console.log(` ${l.dim("\u21B3")} ${l.gray(d.join(" \u2022 "))}`);}if(console.log(` ${l.gray(`Path: ${e.path}`)}`),e.runtimeFamily==="python"&&(e.venvActive?console.log(` \u2705 Virtual environment: ${l.green("Active")}`):console.log(` \u274C Virtual environment: ${l.red("Not found")}`),e.coreInstalled?console.log(` ${l.dim("\u2139")} RapidKit Core: ${l.gray(e.coreVersion||"In venv")} ${l.dim("(optional)")}`):console.log(` ${l.dim("\u2139")} RapidKit Core: ${l.gray("Using global installation")} ${l.dim("(recommended)")}`)),e.depsInstalled?console.log(` \u2705 Dependencies: ${l.green("Installed")}`):console.log(` \u26A0\uFE0F Dependencies: ${l.yellow("Not installed")}`),e.hasEnvFile!==void 0&&(e.hasEnvFile?console.log(` \u2705 Environment: ${l.green(".env configured")}`):console.log(` \u26A0\uFE0F Environment: ${l.yellow(".env missing")}`)),e.modulesHealthy!==void 0){let s=e.projectKind==="frontend"?"Source tree":"Modules";e.modulesHealthy?console.log(` \u2705 ${s}: ${l.green("Healthy")}`):e.missingModules&&e.missingModules.length>0?console.log(` \u26A0\uFE0F ${s}: ${l.yellow(`Missing ${e.missingModules.length} init file(s)`)}`):e.projectKind==="frontend"&&console.log(` \u26A0\uFE0F ${s}: ${l.yellow("No application directories detected")}`);}if(e.stats){let s=[];e.stats.modules!==void 0&&s.push(`${e.stats.modules} module${e.stats.modules!==1?"s":""}`),s.length>0&&console.log(` \u{1F4CA} Stats: ${l.cyan(s.join(" \u2022 "))}`);}e.lastModified&&console.log(` \u{1F552} Last Modified: ${l.gray(e.lastModified)}`);let o=[];if(e.hasTests!==void 0&&o.push(e.hasTests?"\u2705 Tests":l.dim("\u2298 No tests")),e.hasDocker!==void 0&&o.push(e.hasDocker?"\u2705 Docker":l.dim("\u2298 No Docker")),e.hasCodeQuality!==void 0){let s=e.runtimeFamily==="node"?"ESLint":e.runtimeFamily==="rust"?"clippy":e.runtimeFamily==="elixir"?"Credo":e.runtimeFamily==="clojure"?"clj-kondo":e.runtimeFamily==="deno"?"deno lint":e.framework==="Spring Boot"?"Static analysis":e.framework==="Go/Fiber"||e.framework==="Go/Gin"?"golangci-lint":e.runtimeFamily==="python"?"Ruff":"Lint";o.push(e.hasCodeQuality?`\u2705 ${s}`:l.dim(`\u2298 No ${s}`));}if(o.length>0&&console.log(` ${o.join(" \u2022 ")}`),e.vulnerabilities!==void 0&&e.vulnerabilities>0&&console.log(` \u26A0\uFE0F Security: ${l.yellow(`${e.vulnerabilities} vulnerability(ies) found`)}`),e.issues.length>0&&(console.log(` ${l.bold("Issues:")}`),e.issues.forEach(s=>{console.log(` \u2022 ${l.yellow(s)}`);}),e.fixCommands&&e.fixCommands.length>0&&(console.log(`
|
|
3
|
+
${l.bold.cyan("\u{1F527} Quick Fix:")}`),e.fixCommands.forEach(s=>{console.log(` ${l.cyan("$")} ${l.white(s)}`);}))),e.probes&&e.probes.length>0){console.log(` ${l.bold("Probe checks:")}`);for(let s of e.probes){let d=s.status==="pass"?"\u2705":s.status==="warn"?"\u26A0\uFE0F":"\u274C";console.log(` ${d} ${s.label}: ${l.gray(s.reason)}`),s.recommendation&&console.log(` ${l.dim("\u21B3")} ${l.gray(s.recommendation)}`);}}if(e.commandCapabilities){let s=e.commandCapabilities;if(console.log(` ${l.bold("Command support:")}`),console.log(` ${l.green("supported")} ${s.supportedCommands.length} \u2022 ${l.yellow("unsupported")} ${s.unsupportedCommands.length} \u2022 ${l.gray("global")} ${s.globalCommands.length}`),s.unsupportedCommands.length>0){let d=s.unsupportedCommands.slice(0,8).join(", "),u=s.unsupportedCommands.length>8?", ...":"";console.log(` ${l.dim("\u21B3")} ${l.gray(`Unsupported here: ${d}${u}`)}`);}}}async function yt(){try{return (await execa("go",["version"],{timeout:a$3(),reject:false})).exitCode===0}catch{return false}}function se(e,n){let i=[new RegExp(`^cd\\s+"([^"]+)"\\s*(?:&&|;)\\s*${n}\\s*$`,"i"),new RegExp(`^cd\\s+'([^']+)'\\s*(?:&&|;)\\s*${n}\\s*$`,"i"),new RegExp(`^cd\\s+(.+?)\\s*(?:&&|;)\\s*${n}\\s*$`,"i")];for(let t of i){let c=e.match(t);if(c?.[1])return {projectPath:c[1].trim()}}return null}function kt(e){return se(e,"cp\\s+\\.env\\.example\\s+\\.env")||se(e,"copy-item\\s+\\.env\\.example\\s+\\.env")}function wt(e){let n=[{pattern:"npm\\s+install",command:"npm",args:["install"]},{pattern:"npm\\s+ci",command:"npm",args:["ci"]},{pattern:"pnpm\\s+install",command:"pnpm",args:["install"]},{pattern:"yarn\\s+install",command:"yarn",args:["install"]},{pattern:"poetry\\s+install",command:"poetry",args:["install"]},{pattern:"pip\\s+install\\s+-r\\s+requirements\\.txt",command:"pip",args:["install","-r","requirements.txt"]},{pattern:"composer\\s+install",command:"composer",args:["install"]},{pattern:"bundle\\s+install",command:"bundle",args:["install"]},{pattern:"dotnet\\s+restore",command:"dotnet",args:["restore"]},{pattern:"cargo\\s+fetch",command:"cargo",args:["fetch"]},{pattern:"mix\\s+deps\\.get",command:"mix",args:["deps.get"]},{pattern:"clojure\\s+-P",command:"clojure",args:["-P"]},{pattern:"sbt\\s+compile",command:"sbt",args:["compile"]}];for(let i of n){let t=se(e,i.pattern);if(t)return {projectPath:t.projectPath,command:i.command,args:i.args}}return null}function Ie(e,n){return /^https?:\/\//i.test(n.trim())?{projectName:e.name,projectPath:e.path,originalCommand:n,kind:"manual-url",risk:"safe",executable:false,reason:"Manual guidance URL"}:kt(n)?{projectName:e.name,projectPath:e.path,originalCommand:n,kind:"env-copy",risk:"safe",executable:true,reason:"Environment seed copy"}:se(n,"rapidkit\\s+init")?{projectName:e.name,projectPath:e.path,originalCommand:n,kind:"rapidkit-init",risk:"guarded",executable:true,reason:"RapidKit initializer may mutate dependencies and configs"}:se(n,"go\\s+mod\\s+tidy")?{projectName:e.name,projectPath:e.path,originalCommand:n,kind:"go-mod-tidy",risk:"guarded",executable:true,reason:"Go module graph reconciliation"}:wt(n)?{projectName:e.name,projectPath:e.path,originalCommand:n,kind:"dependency-sync",risk:"guarded",executable:true,reason:"Dependency synchronization command"}:{projectName:e.name,projectPath:e.path,originalCommand:n,kind:"shell",risk:"invasive",executable:true,reason:"Generic shell command"}}async function Ne(e){let n=e.filter(m=>m.fixCommands&&m.fixCommands.length>0),i=n.flatMap(m=>(m.fixCommands??[]).map(p=>Ie(m,p))),t=null,c=[],o=0,s=0,d=0,u=0;for(let m of i){let p=m.executable,f;m.kind==="go-mod-tidy"&&(t===null&&(t=await yt()),t||(p=false,f="Go toolchain not available")),p&&(o+=1,m.risk==="safe"&&(s+=1),m.risk==="guarded"&&(d+=1),m.risk==="invasive"&&(u+=1)),c.push({...m,executableInCurrentEnvironment:p,blockedReason:f});}return {generatedAt:new Date().toISOString(),fixableProjects:n.length,totalSteps:c.length,executableSteps:o,risk:{safe:s,guarded:d,invasive:u},steps:c}}function rt(e){let n=e instanceof Error?e.message:String(e),i=["ETIMEDOUT","ECONNRESET","ECONNREFUSED","EAI_AGAIN","ENOTFOUND","network","503","504"],t=n.toLowerCase();return i.some(c=>t.includes(c.toLowerCase()))}async function fn(e,n){let i=e.get(n);if(i)return i;let t=`${Date.now()}-${Math.random().toString(36).slice(2,8)}`,c=r.basename(n).replace(/[^a-zA-Z0-9._-]/g,"_"),o=r.join(n,".rapidkit","reports","fix-snapshots",`${c}-${t}`);await a.ensureDir(o);let s=[".env","package-lock.json","pnpm-lock.yaml","yarn.lock","poetry.lock","requirements.txt","go.mod","go.sum","Cargo.lock","composer.lock","Gemfile.lock","pom.xml","build.gradle","build.gradle.kts","gradle.lockfile"],d=new Map;for(let m of s){let p=r.join(n,m);if(!await a.pathExists(p))continue;let f=r.join(o,m);await a.ensureDir(r.dirname(f)),await a.copy(p,f,{overwrite:true}),d.set(p,f);}let u={snapshotRoot:o,files:d};return e.set(n,u),u}async function gn(e){for(let[n,i]of e.files.entries())await a.pathExists(i)&&(await a.ensureDir(r.dirname(n)),await a.copy(i,n,{overwrite:true}));}async function hn(e){let n=await we(e,{allowNonRapidkit:true});return {issues:n.issues.length,healthy:n.issues.length===0}}async function $e(e){let n=[];for(let i of e){let t=await we(i.path,{allowNonRapidkit:true});for(let c of t.issues)typeof c=="string"&&c.trim()&&n.push(`${i.name}: ${c.trim()}`);}return n.slice(0,24)}async function te(e,n=false,i={}){let t=await Ne(e),c$1=e.filter(h=>h.fixCommands&&h.fixCommands.length>0),o=[],s=i.json===true,d=null,u=t.steps.some(h=>h.kind==="go-mod-tidy"&&!h.executableInCurrentEnvironment),m=new Map;if(c$1.length===0)return s||console.log(l.green(`
|
|
4
|
+
\u2705 No fixes needed - all projects are healthy!`)),n?re({appliedFixes:[],remainingBlockers:[],verifyRecommended:ee}):void 0;if(!s){console.log(l.bold.cyan(`
|
|
5
|
+
\u{1F527} Available Fixes:
|
|
6
|
+
`));for(let h of c$1){let x=h.fixCommands??[];console.log(l.bold(`Project: ${l.yellow(h.name)}`)),x.forEach((b,H)=>{console.log(` ${H+1}. ${l.cyan(b)}`);}),console.log();}}if(i.planOnly){if(i.json){console.log(JSON.stringify(t,null,2));return}console.log(l.bold(`
|
|
7
|
+
\u{1F9ED} Remediation Plan
|
|
8
|
+
`)),console.log(l.gray(`Executable steps: ${t.executableSteps}/${t.totalSteps} | risk: safe=${t.risk.safe}, guarded=${t.risk.guarded}, invasive=${t.risk.invasive}`));for(let h of t.steps){let x=h.executableInCurrentEnvironment?l.green("ready"):l.yellow(`blocked${h.blockedReason?` (${h.blockedReason})`:""}`);console.log(` - ${l.cyan(h.projectName)} [${h.risk}] ${h.originalCommand} ${l.gray(`=> ${x}`)}`);}console.log(l.gray(`
|
|
9
|
+
Use --apply to execute this plan non-interactively, or --fix for interactive confirmation.`));return}let p=t.executableSteps,f=t.risk.safe,g=t.risk.guarded,y=t.risk.invasive;if(p===0)return s||(console.log(l.gray("\u{1F4A1} No automatic fixes can be applied right now.")),u&&console.log(l.gray(" Install Go to enable go mod tidy fixes, then rerun `rapidkit doctor workspace --fix`."))),n?re({appliedFixes:[],remainingBlockers:await $e(c$1),verifyRecommended:ee}):void 0;if(!n){s||console.log(l.gray('\u{1F4A1} Run "npx rapidkit doctor workspace --fix" to apply fixes automatically'));return}if(s||console.log(l.gray(`Risk policy: safe=${f}, guarded=${g}, invasive=${y}. Guarded/invasive fixes use snapshot + rollback.`)),!i.skipConfirmation){let{confirm:h}=await b([{type:"confirm",name:"confirm",message:`Apply ${c$1.reduce((x,b)=>x+(b.fixCommands?.length??0),0)} fix(es)?`,default:false}]);if(!h)return s||console.log(l.yellow(`
|
|
10
|
+
\u26A0\uFE0F Fixes cancelled by user`)),re({appliedFixes:[],remainingBlockers:await $e(c$1),verifyRecommended:ee})}s||console.log(l.bold.cyan(`
|
|
11
|
+
\u{1F680} Applying fixes...
|
|
12
|
+
`));let k=new Set;for(let h of c$1){let x=h.fixCommands??[];s||console.log(l.bold(`Fixing ${l.cyan(h.name)}...`));for(let b of x){let H=Ie(h,b),fe=`${h.path}::${b}`;if(!k.has(fe)){k.add(fe);try{if(console.log(l.gray(` $ ${b}`)),H.kind==="manual-url"){console.log(l.yellow(` \u2139 Manual action required: open ${b}`)),console.log(l.green(` \u2705 Recorded as guidance
|
|
13
|
+
`));continue}if(!H.executable){console.log(l.yellow(" \u26A0 Step is non-executable by policy")),console.log(l.green(` \u2705 Recorded as guidance
|
|
14
|
+
`));continue}H.risk!=="safe"&&await fn(m,H.projectPath);let K=kt(b);if(K){let L=r.join(K.projectPath,".env.example"),M=r.join(K.projectPath,".env");if(!await a.pathExists(L))throw new Error(`.env.example not found at ${L}`);if(await a.pathExists(M)){console.log(l.green(` \u2705 .env already exists
|
|
15
|
+
`));continue}await a.copy(L,M,{overwrite:false,errorOnExist:false}),console.log(l.green(` \u2705 Success
|
|
16
|
+
`));continue}let U=se(b,"rapidkit\\s+init");if(U){await execa("rapidkit",["init"],{cwd:U.projectPath,shell:c(),stdio:"inherit"}),console.log(l.green(` \u2705 Success
|
|
17
|
+
`));continue}let Q=se(b,"go\\s+mod\\s+tidy");if(Q){if(d===null&&(d=await yt()),!d){console.log(l.yellow(" \u26A0 Go toolchain is not installed \u2014 skipping go mod tidy; install Go to apply this fix.")),console.log(l.green(` \u2705 Recorded as guidance
|
|
18
|
+
`));continue}await execa("go",["mod","tidy"],{cwd:Q.projectPath,shell:c(),stdio:"inherit"}),console.log(l.green(` \u2705 Success
|
|
19
|
+
`));continue}let V=wt(b);if(V){let M;for(let ie=1;ie<=2;ie+=1)try{await execa(V.command,V.args,{cwd:V.projectPath,shell:c(),stdio:"inherit"}),M=null;break}catch(le){if(M=le,ie<2&&rt(le)){console.log(l.yellow(` \u26A0 Retrying dependency sync (${ie}/1)...`));continue}throw le}if(M)throw M;console.log(l.green(` \u2705 Success
|
|
20
|
+
`));continue}let ce=H.kind==="shell"?2:1,oe;for(let L=1;L<=ce;L+=1)try{await execa(b,{shell:true,stdio:"inherit"}),oe=null;break}catch(M){if(oe=M,L<ce&&rt(M)){console.log(l.yellow(` \u26A0 Retrying command (${L}/${ce-1})...`));continue}throw M}if(oe)throw oe;s||console.log(l.green(` \u2705 Success
|
|
21
|
+
`)),o.push({path:H.projectPath,action:H.kind,outcome:"applied",projectName:h.name,command:b});}catch(K){let U=Ie(h,b);if(U.risk!=="safe"){let Q=m.get(U.projectPath);if(Q)try{await gn(Q),s||console.log(l.yellow(" \u21A9 Rolled back snapshot after failed fix"));}catch(V){s||console.log(l.red(` \u274C Rollback failed: ${V instanceof Error?V.message:String(V)}`));}}s||console.log(l.red(` \u274C Failed: ${K instanceof Error?K.message:String(K)}
|
|
22
|
+
`)),o.push({path:U.projectPath,action:U.kind,outcome:"failed",projectName:h.name,command:b,detail:K instanceof Error?K.message:String(K)});}}}try{let b=await hn(h.path);console.log(b.healthy?l.green(` \u2705 Post-fix verification passed for ${h.name}`):l.yellow(` \u26A0 Post-fix verification: ${b.issues} issue(s) remain for ${h.name}`));}catch(b){console.log(l.yellow(` \u26A0 Post-fix verification skipped: ${b instanceof Error?b.message:String(b)}`));}}if(s||console.log(l.bold.green(`
|
|
23
|
+
\u2705 Fix process completed!`)),n)return re({appliedFixes:o,remainingBlockers:await $e(c$1),verifyRecommended:ee})}function ae(e,n){if(!n.strict&&!n.ci)return 0;let i=Number(e?.errors??0),t=Number(e?.warnings??0);return i>0?1:n.ci&&t>0?2:n.strict&&t>0?1:0}async function Wn(e={}){let n=!!(e.fix||e.plan||e.apply),i=!e.workspace&&!e.project&&n?await me(process.cwd()):null,t=e.workspace||!!i,c=!!e.project&&!t;if(e.json||console.log(l.bold.cyan(`
|
|
24
|
+
\u{1FA7A} RapidKit Health Check
|
|
25
|
+
`)),t){let o=i??await me(process.cwd());o||(f.error("No RapidKit workspace found in current directory or parents"),f.info('Run this command from within a workspace, or use "rapidkit doctor" for system check'),process.exit(1)),e.json||(i&&console.log(l.gray("\u2139\uFE0F Detected workspace context; enabling workspace checks for --fix")),console.log(l.bold(`Workspace: ${l.cyan(r.basename(o))}`)),console.log(l.gray(`Path: ${o}`)));let s=await Fe(o);if(e.json||(s.projectScanCached&&console.log(l.gray(`\u2139\uFE0F Reused cached project scan${s.projectScanCachePath?` (${r.basename(s.projectScanCachePath)})`:""}`)),s.evidencePath&&console.log(l.gray(`\u2139\uFE0F Evidence saved: ${s.evidencePath}`))),e.json){let p,f=e.plan?await Ne(s.projects):void 0;(e.fix||e.apply)&&!e.plan&&(p=await te(s.projects,true,{skipConfirmation:e.apply===true||e.fix===true,json:true})??re({appliedFixes:[],remainingBlockers:[],verifyRecommended:ee}),s=await Fe(o,false));let g={contract:ye(),workspace:{name:r.basename(o),path:o},cache:{projectScan:s.projectScanCached??false,projectScanPath:s.projectScanCachePath,evidencePath:s.evidencePath},healthScore:s.healthScore,system:{python:s.python,poetry:s.poetry,pipx:s.pipx,rapidkitCore:s.rapidkitCore,versions:{core:s.coreVersion,npm:s.npmVersion}},projects:s.projects.map(y=>ot(y)),summary:{totalProjects:s.projects.length,totalIssues:s.projects.reduce((y,k)=>y+k.issues.length,0),projectAdvisoryWarningProjects:De(s.projects),projectAdvisoryWarnings:He(s.projects),hasSystemErrors:[s.python,s.rapidkitCore].some(y=>y.status==="error"),scopeProvenance:s.scopeProvenance},driftDelta:s.driftDelta,scoreBreakdown:s.scoreBreakdown??[],...f?{remediationPlan:f}:{},...p?{appliedFixes:p.appliedFixes,remainingBlockers:p.remainingBlockers,verifyRecommended:p.verifyRecommended,fixResult:p}:{}};return e.quiet||console.log(JSON.stringify(g,null,2)),ae(s.healthScore,e)}if(s.healthScore){let p=s.healthScore,f=Math.round(p.passed/p.total*100),g=f>=80?l.green:f>=50?l.yellow:l.red,y="\u2588".repeat(Math.floor(f/5))+"\u2591".repeat(20-Math.floor(f/5));console.log(l.bold(`
|
|
26
|
+
\u{1F4CA} Health Score:`)),console.log(` ${g(`${f}%`)} ${l.gray(y)}`),console.log(` ${l.green(`\u2705 ${p.passed} passed`)} ${l.gray("|")} ${l.yellow(`\u26A0\uFE0F ${p.warnings} warnings`)} ${l.gray("|")} ${l.red(`\u274C ${p.errors} errors`)}`);}if(console.log(l.bold(`
|
|
27
|
+
|
|
28
|
+
System Tools:
|
|
29
|
+
`)),F(s.python,"Python"),F(s.poetry,"Poetry"),F(s.pipx,"pipx"),F(s.go,"Go"),F(s.rapidkitCore,"RapidKit Core"),s.coreVersion&&s.npmVersion){let p=s.coreVersion.split(".")[1],f=s.npmVersion.split(".")[1];p!==f&&(console.log(l.yellow(`
|
|
30
|
+
\u26A0\uFE0F Version mismatch: Core ${s.coreVersion} / CLI ${s.npmVersion}`)),console.log(l.gray(" Consider updating to matching versions for best compatibility")));}s.projects.length>0?(console.log(l.bold(`
|
|
31
|
+
\u{1F4E6} Projects (${s.projects.length}):`)),s.projects.forEach(p=>it(p))):(console.log(l.bold(`
|
|
32
|
+
\u{1F4E6} Projects:`)),console.log(l.gray(" No RapidKit projects found in workspace")));let d=s.projects.reduce((p,f)=>p+f.issues.length,0),u=De(s.projects),m=[s.python,s.rapidkitCore].some(p=>p.status==="error");if(m||d>0||u>0){let p=u>0?` and ${u} advisory warning project(s)`:"";if(console.log(l.bold.yellow(`
|
|
33
|
+
\u26A0\uFE0F Found ${d} project issue(s)${p}`)),m&&console.log(l.bold.red("\u274C System requirements not met")),e.plan)await te(s.projects,false,{planOnly:true,json:e.json});else if(e.fix||e.apply){if(await te(s.projects,true,{skipConfirmation:e.apply===true}),!e.json){let f=await Fe(o,false),g=f.projects.reduce((k,h)=>k+h.issues.length,0),y=[f.python,f.rapidkitCore].some(k=>k.status==="error");y||g>0?(console.log(l.bold.yellow(`
|
|
34
|
+
\u26A0\uFE0F Post-fix verification found ${g} remaining issue(s)`)),y&&console.log(l.bold.red("\u274C System requirements still not met"))):console.log(l.bold.green(`
|
|
35
|
+
\u2705 Post-fix verification passed. Workspace is healthy.`)),f.projectScanCached&&console.log(l.gray(`\u2139\uFE0F Reused cached project scan${f.projectScanCachePath?` (${r.basename(f.projectScanCachePath)})`:""}`)),f.evidencePath&&console.log(l.gray(`\u2139\uFE0F Evidence refreshed: ${f.evidencePath}`));}}else d>0&&await te(s.projects,false);}else console.log(l.bold.green(`
|
|
36
|
+
\u2705 All checks passed! Workspace is healthy.`));return ae(s.healthScore,e)}else if(c){let o=await ln(process.cwd());o||(await me(process.cwd())?(f.error("No backend project found in current directory within this workspace"),f.info("Run this command from inside a project directory in the workspace")):f.error("No RapidKit project found in current directory or parents"),f.info('Run this command from within a project, or use "rapidkit doctor workspace" for workspace checks'),process.exit(1));let s=await mn(o),d=s.workspacePath?st(s.workspacePath):null,u=st(s.project.path);if(e.json){let x=e.plan?await Ne([s.project]):void 0,b={contract:ye(),scope:"project",workspace:d?{name:r.basename(d),path:d}:null,project:{...ot(s.project),path:u},evidencePath:s.evidencePath,healthScore:s.healthScore,system:{python:s.python,poetry:s.poetry,pipx:s.pipx,go:s.go,rapidkitCore:s.rapidkitCore},summary:{totalProjects:1,totalIssues:s.project.issues.length,projectAdvisoryWarningProjects:ne(s.project)>0?1:0,projectAdvisoryWarnings:ne(s.project),hasSystemErrors:[s.python,s.rapidkitCore].some(H=>H.status==="error"),scopeProvenance:s.scopeProvenance},driftDelta:s.driftDelta,scoreBreakdown:s.scoreBreakdown??[],...x?{remediationPlan:x}:{}};return e.quiet||console.log(JSON.stringify(b,null,2)),ae(s.healthScore,e)}console.log(l.bold(`Project: ${l.cyan(r.basename(o))}`)),console.log(l.gray(`Path: ${o}`)),s.workspacePath&&console.log(l.gray(`Workspace: ${r.basename(s.workspacePath)}`)),s.evidencePath&&console.log(l.gray(`\u2139\uFE0F Evidence saved: ${s.evidencePath}`));let m=s.healthScore,p=m.total>0?Math.round(m.passed/m.total*100):0,f$1=p>=80?l.green:p>=50?l.yellow:l.red,g="\u2588".repeat(Math.floor(p/5))+"\u2591".repeat(20-Math.floor(p/5));console.log(l.bold(`
|
|
37
|
+
\u{1F4CA} Health Score:`)),console.log(` ${f$1(`${p}%`)} ${l.gray(g)}`),console.log(` ${l.green(`\u2705 ${m.passed} passed`)} ${l.gray("|")} ${l.yellow(`\u26A0\uFE0F ${m.warnings} warnings`)} ${l.gray("|")} ${l.red(`\u274C ${m.errors} errors`)}`),console.log(l.bold(`
|
|
38
|
+
|
|
39
|
+
System Tools:
|
|
40
|
+
`)),F(s.python,"Python"),F(s.poetry,"Poetry"),F(s.pipx,"pipx"),F(s.go,"Go"),F(s.rapidkitCore,"RapidKit Core"),console.log(l.bold(`
|
|
41
|
+
\u{1F4E6} Project (1):`)),it(s.project);let y=[s.python,s.rapidkitCore].some(x=>x.status==="error"),k=s.project.issues.length,h=ne(s.project);if(y||k>0||h>0){let x=h>0?` and ${h} advisory warning(s)`:"";console.log(l.bold.yellow(`
|
|
42
|
+
\u26A0\uFE0F Found ${k} project issue(s)${x}`)),y&&console.log(l.bold.red("\u274C System requirements not met")),e.plan?await te([s.project],false,{planOnly:true,json:e.json}):e.fix||e.apply?await te([s.project],true,{skipConfirmation:e.apply===true}):k>0&&await te([s.project],false);}else console.log(l.bold.green(`
|
|
43
|
+
\u2705 All checks passed! Project is healthy.`));return ae(s.healthScore,e)}else {console.log(l.bold(`System Tools:
|
|
44
|
+
`));let o=await _e(),s=o.python,d=o.poetry,u=o.pipx,m=o.go,p=o.rapidkitCore;F(s,"Python"),F(d,"Poetry"),F(u,"pipx"),F(m,"Go"),F(p,"RapidKit Core"),[s,p].some(y=>y.status==="error")?(console.log(l.bold.red(`
|
|
45
|
+
\u274C Some required tools are missing`)),(e.fix||e.apply)&&console.log(l.gray(`
|
|
46
|
+
Tip: Project auto-fix runs in workspace mode. Run from a workspace and use "rapidkit doctor workspace --fix"`)),console.log(l.gray(`
|
|
47
|
+
Tip: Run "rapidkit doctor workspace" for workspace-wide checks, or "rapidkit doctor project" for the current project`))):(console.log(l.bold.green(`
|
|
48
|
+
\u2705 All required tools are installed!`)),(e.fix||e.apply)&&console.log(l.gray(`
|
|
49
|
+
Tip: Project auto-fix runs in workspace mode. Run from a workspace and use "rapidkit doctor workspace --fix"`)),console.log(l.gray(`
|
|
50
|
+
Tip: Run "rapidkit doctor workspace" for workspace-wide checks, or "rapidkit doctor project" for the current project`))),console.log("");let g=[s,p].filter(y=>y.status==="error").length;return (e.strict||e.ci)&&g>0?1:0}}export{ae as a,Wn as b};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var o="workspace-explain.v1",f=["project","release-blocked","blocker","trace"];function i(t){let r=t.trim();if(!r)return null;if(r==="release-blocked")return {kind:"release-blocked"};if(r.startsWith("project:")){let e=r.slice(8).trim();return e?{kind:"project",project:e}:null}if(r.startsWith("blocker:")){let e=r.slice(8).trim();return e?{kind:"blocker",blockerId:e}:null}if(r.startsWith("trace:")){let e=r.slice(6).trim();return e?{kind:"trace",diffRef:e}:null}return {kind:"project",project:r}}function g(t){let r=t.trim();if(!r)return null;if(r.startsWith("trace:")){let n=i(r);return n?.kind==="trace"?n:null}let e=r.replace(/\\/g,"/").trim().toLowerCase();return e.endsWith(".json")||e.includes("workspace-model-diff")||e.startsWith(".rapidkit/")||e.includes("/.rapidkit/")?{kind:"trace",diffRef:r}:null}function u(t){if(!t||typeof t!="object"||Array.isArray(t))return false;let r=t;return r.schemaVersion===o&&typeof r.generatedAt=="string"&&typeof r.summary=="string"&&Array.isArray(r.sections)&&r.target!=null&&typeof r.target=="object"&&!Array.isArray(r.target)&&typeof r.target.kind=="string"}export{o as a,f as b,i as c,g as d,u as e};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {c}from'./chunk-NFUXULIF.js';import {a}from'./chunk-A5FBGRJA.js';import {a as a$1}from'./chunk-VKLL63TL.js';import {b}from'./chunk-Q2KZIBV4.js';import {
|
|
1
|
+
import {c}from'./chunk-NFUXULIF.js';import {a}from'./chunk-A5FBGRJA.js';import {a as a$1}from'./chunk-VKLL63TL.js';import {b}from'./chunk-Q2KZIBV4.js';import {p}from'./chunk-WRMCPKGA.js';import {promises}from'fs';import o from'path';import i from'chalk';import N from'ora';import {execa}from'execa';function B(e){let t=a(e.path),r=Array.isArray(e.projects)?e.projects:[],a$1=[],s=new Set;for(let p of r){if(!p||typeof p.name!="string"||typeof p.path!="string")continue;let n=a(p.path);s.has(n)||(s.add(n),a$1.push({name:p.name,path:n}));}return {name:e.name,path:t,mode:e.mode,projects:a$1}}function P(e){let t=[],r=new Set;for(let a of e.workspaces||[]){if(!a||typeof a.name!="string"||typeof a.path!="string")continue;let s=B(a);r.has(s.path)||(r.add(s.path),t.push(s));}return {workspaces:t}}async function F(e){try{let t=await promises.readFile(e,"utf8"),r=JSON.parse(t);if(r&&Array.isArray(r.workspaces))return P(r)}catch{}return {workspaces:[]}}async function T(e,t){try{let r=a(e),a$1=p(),s=o.join(a$1,"workspaces.json");await promises.mkdir(a$1,{recursive:true});let p$1={name:t,path:r,mode:"full",projects:[]};for(let n=0;n<3;n+=1){let c=await F(s);if(c.workspaces.some(k=>k.path===r)||(c.workspaces.push(p$1),await promises.writeFile(s,JSON.stringify(c,null,2)),(await F(s)).workspaces.some(k=>k.path===r)))return}console.warn(i.gray("Note: Could not register workspace in shared registry"));}catch{console.warn(i.gray("Note: Could not register workspace in shared registry"));}}async function ne(e,t=false){let r=a(e),a$1={workspacePath:r,workspaceFound:false,added:[],skipped:0};try{let s=p(),p$1=o.join(s,"workspaces.json"),n={workspaces:[]};try{let f=await promises.readFile(p$1,"utf8"),h=JSON.parse(f);h&&Array.isArray(h.workspaces)&&(n=P(h));}catch{return t||console.log("\u26A0\uFE0F Workspace registry not found"),a$1}let c=n.workspaces.find(f=>f.path===r);if(!c)return t||console.log("\u26A0\uFE0F Workspace not registered in registry"),a$1;Array.isArray(c.projects)||(c.projects=[]);let l=0,k=0,g=[],m=[e],y=new Set;for(;m.length>0;){let f=m.shift();if(!f||y.has(f))continue;y.add(f);let h=await promises.readdir(f,{withFileTypes:true});for(let w of h){if(!w.isDirectory()||w.name.startsWith(".")||["node_modules","dist","build","target","coverage","htmlcov"].includes(w.name))continue;let b=o.join(f,w.name),u=a(b),$=o.join(u,".rapidkit","context.json"),W=o.join(u,".rapidkit","project.json");try{let S=false;try{await promises.access($),S=true;}catch{await promises.access(W),S=true;}if(S){let v=o.basename(u);c.projects.some(_=>_.path===u||_.name===v)?k++:(c.projects.push({name:v,path:u}),l++,g.push(u),t||console.log(`\u2714 Added: ${o.relative(e,u)}`));continue}}catch{}m.push(b);}}return l>0?(await promises.writeFile(p$1,JSON.stringify(n,null,2)),t||console.log(`
|
|
2
2
|
\u2705 Synced ${l} project(s) to registry`)):t||console.log(`
|
|
3
|
-
\u2705 All projects already registered (${k} found)`),{workspacePath:r,workspaceFound:true,added:g,skipped:k}}catch(s){return t||console.error("\u274C Failed to sync projects:",s.message),a$1}}async function se(e,t,r){try{let a$1=a(e),s=a(r),p=
|
|
3
|
+
\u2705 All projects already registered (${k} found)`),{workspacePath:r,workspaceFound:true,added:g,skipped:k}}catch(s){return t||console.error("\u274C Failed to sync projects:",s.message),a$1}}async function se(e,t,r){try{let a$1=a(e),s=a(r),p$1=p(),n=o.join(p$1,"workspaces.json"),c={workspaces:[]};try{let m=await promises.readFile(n,"utf8"),y=JSON.parse(m);y&&Array.isArray(y.workspaces)&&(c=P(y));}catch{return}let l=c.workspaces.find(m=>m.path===a$1);if(!l)return;Array.isArray(l.projects)||(l.projects=[]);let k=l.projects.findIndex(m=>m.path===s||m.name===t),g={name:t,path:s};if(k>=0){let m=l.projects[k];(m.name!==g.name||m.path!==g.path)&&(l.projects[k]=g,await promises.writeFile(n,JSON.stringify(c,null,2)));}else l.projects.push({name:t,path:s}),await promises.writeFile(n,JSON.stringify(c,null,2));}catch{}}async function ce(e,t){let r=N("Creating RapidKit workspace...").start();try{await promises.mkdir(e,{recursive:true}),await promises.mkdir(o.join(e,".rapidkit"),{recursive:true});let a={workspace_name:t.name,author:t.author,rapidkit_version:b(),created_at:new Date().toISOString(),type:"workspace"};await promises.writeFile(o.join(e,".rapidkit","config.json"),JSON.stringify(a,null,2));let{syncWorkspaceFoundationFiles:s}=await import('./create-RNP5ACQL.js');await s(e,{workspaceName:t.name,installMethod:"venv",writeMarker:true,writeGitignore:false,onlyIfMissing:true});let{publishWorkspaceRegistrySummary:p}=await import('./workspace-registry-summary-X5WRUU3T.js');await p(e);let n=z();await promises.writeFile(o.join(e,"rapidkit"),n),await promises.chmod(o.join(e,"rapidkit"),493);let c=U();await promises.writeFile(o.join(e,"rapidkit.cmd"),c);let l=J(t.name);if(await promises.writeFile(o.join(e,"README.md"),l),await promises.writeFile(o.join(e,".gitignore"),`# RapidKit workspace
|
|
4
4
|
.env
|
|
5
5
|
.env.*
|
|
6
6
|
!.env.example
|
|
@@ -614,7 +614,7 @@ ${i.bold("\u{1F310} API endpoints:")}
|
|
|
614
614
|
http://localhost:8000/examples/notes # Example API
|
|
615
615
|
|
|
616
616
|
${i.gray("\u{1F4A1} Tip: Install globally (npm i -g rapidkit) to use without npx")}
|
|
617
|
-
`);}catch(p){throw s.fail(`Failed to create ${a} project`),p}}async function O(e,t,r){let a=await promises.readdir(e,{withFileTypes:true});for(let s of a){let p=o.join(e,s.name),n=s.name.replace(/\.j2$/,""),c=o.join(t,n);if(s.isDirectory())await promises.mkdir(c,{recursive:true}),await O(p,c,r);else {let l=await promises.readFile(p,"utf-8");s.name.endsWith(".j2")&&(l=K(l,r)),await promises.writeFile(c,l),(n==="rapidkit"||n==="activate"||n.endsWith(".py")&&c.includes(".rapidkit"))&&await promises.chmod(c,493);}}}function K(e,t){let r=e;for(let[a,s]of Object.entries(t)){let p=new RegExp(`\\{\\{\\s*${a}\\s*\\}\\}`,"g");r=r.replace(p,String(s));let n=new RegExp(`\\{\\{\\s*${a}\\s*\\|\\s*replace\\s*\\(\\s*['"]([^'"]+)['"]\\s*,\\s*['"]([^'"]*)['"]\\s*\\)\\s*\\}\\}`,"g");r=r.replace(n,(k,g,m)=>String(s).replace(new RegExp(g,"g"),m));let c=new RegExp(`\\{\\{\\s*${a}\\s*\\|\\s*lower\\s*\\}\\}`,"g");r=r.replace(c,String(s).toLowerCase());let l=new RegExp(`\\{\\{\\s*${a}\\s*\\|\\s*replace\\s*\\(\\s*['"]([^'"]+)['"]\\s*,\\s*['"]([^'"]*)['"]\\s*\\)\\s*\\|\\s*lower\\s*\\}\\}`,"g");r=r.replace(l,(k,g,m)=>String(s).replace(new RegExp(g,"g"),m).toLowerCase());}return r}async function de(){let e=
|
|
617
|
+
`);}catch(p){throw s.fail(`Failed to create ${a} project`),p}}async function O(e,t,r){let a=await promises.readdir(e,{withFileTypes:true});for(let s of a){let p=o.join(e,s.name),n=s.name.replace(/\.j2$/,""),c=o.join(t,n);if(s.isDirectory())await promises.mkdir(c,{recursive:true}),await O(p,c,r);else {let l=await promises.readFile(p,"utf-8");s.name.endsWith(".j2")&&(l=K(l,r)),await promises.writeFile(c,l),(n==="rapidkit"||n==="activate"||n.endsWith(".py")&&c.includes(".rapidkit"))&&await promises.chmod(c,493);}}}function K(e,t){let r=e;for(let[a,s]of Object.entries(t)){let p=new RegExp(`\\{\\{\\s*${a}\\s*\\}\\}`,"g");r=r.replace(p,String(s));let n=new RegExp(`\\{\\{\\s*${a}\\s*\\|\\s*replace\\s*\\(\\s*['"]([^'"]+)['"]\\s*,\\s*['"]([^'"]*)['"]\\s*\\)\\s*\\}\\}`,"g");r=r.replace(n,(k,g,m)=>String(s).replace(new RegExp(g,"g"),m));let c=new RegExp(`\\{\\{\\s*${a}\\s*\\|\\s*lower\\s*\\}\\}`,"g");r=r.replace(c,String(s).toLowerCase());let l=new RegExp(`\\{\\{\\s*${a}\\s*\\|\\s*replace\\s*\\(\\s*['"]([^'"]+)['"]\\s*,\\s*['"]([^'"]*)['"]\\s*\\)\\s*\\|\\s*lower\\s*\\}\\}`,"g");r=r.replace(l,(k,g,m)=>String(s).replace(new RegExp(g,"g"),m).toLowerCase());}return r}async function de(){let e=p(),t=o.join(e,"workspaces.json");if(!await promises.stat(t).catch(()=>null)){console.log(i.yellow(`
|
|
618
618
|
\u26A0\uFE0F No workspaces registered yet.
|
|
619
619
|
`)),console.log(i.gray(`Create a workspace with: npx rapidkit <workspace-name>
|
|
620
620
|
`));return}try{let r=await promises.readFile(t,"utf8"),a=JSON.parse(r);if(!a||typeof a!="object"||!Array.isArray(a.workspaces)){console.log(i.yellow(`
|