rapidkit 0.41.0 → 0.41.2

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.
Files changed (169) hide show
  1. package/README.md +88 -11
  2. package/contracts/extension-cli-compatibility.v1.json +1 -1
  3. package/contracts/runtime-command-surface.v1.json +3 -1
  4. package/contracts/workspace-intelligence/agent-action-outcome.v1.json +17 -1
  5. package/contracts/workspace-intelligence/studio-blocker-handoff.v1.json +24 -0
  6. package/contracts/workspace-intelligence/workspace-dependency-graph.v1.json +61 -1
  7. package/dist/analyze-QYHMGLSG.js +1 -0
  8. package/dist/autopilot-release-YDEUKRW6.js +1 -0
  9. package/dist/{chunk-WA6JYVJM.js → chunk-33LR2QEM.js} +1 -1
  10. package/dist/{chunk-DMUEGR36.js → chunk-3PTJID76.js} +1 -1
  11. package/dist/chunk-46AGNYI7.js +50 -0
  12. package/dist/chunk-AQ4XZZC6.js +1 -0
  13. package/dist/{chunk-MGUJWRZA.js → chunk-BFEBZABL.js} +3 -3
  14. package/dist/chunk-DWXRVGOY.js +2 -0
  15. package/dist/chunk-E5ZVQL3C.js +13 -0
  16. package/dist/chunk-ELU3G6DQ.js +9 -0
  17. package/dist/chunk-EN6YCX36.js +1 -0
  18. package/dist/chunk-FMBSON6H.js +33 -0
  19. package/dist/chunk-GBJBQ43T.js +1 -0
  20. package/dist/chunk-HYAT2EG7.js +1 -0
  21. package/dist/{chunk-FPUNOIAR.js → chunk-ITJ6RKUW.js} +3 -3
  22. package/dist/{chunk-Y2SCTWL4.js → chunk-JNXT6KJV.js} +2 -2
  23. package/dist/{chunk-XOVB2ZP5.js → chunk-JU3VNLTY.js} +1 -1
  24. package/dist/{chunk-44GSDNPQ.js → chunk-KIUSCFHF.js} +1 -1
  25. package/dist/{chunk-KTQZUWAM.js → chunk-RSYUNEH7.js} +13 -13
  26. package/dist/chunk-VDTAPIHB.js +2 -0
  27. package/dist/chunk-WCICO7ZB.js +13 -0
  28. package/dist/chunk-WRMCPKGA.js +1 -0
  29. package/dist/{chunk-73IS6RIM.js → chunk-ZPXMZCYG.js} +1 -1
  30. package/dist/{create-UGXMC4CT.js → create-RNP5ACQL.js} +1 -1
  31. package/dist/demo-kit-N5U3NGAE.js +149 -0
  32. package/dist/{doctor-LCKG5S76.js → doctor-XM6QDTDC.js} +1 -1
  33. package/dist/index.d.ts +1 -1
  34. package/dist/index.js +118 -117
  35. package/dist/{pipeline-MKNYPNGD.js → pipeline-YD2DO7XY.js} +1 -1
  36. package/dist/platform-capabilities-TSLK667K.js +1 -0
  37. package/dist/{pythonRapidkitExec-MNWRC4F2.js → pythonRapidkitExec-SGKW76XM.js} +1 -1
  38. package/dist/{workspace-FDMJD5XI.js → workspace-E554C5SM.js} +1 -1
  39. package/dist/{workspace-agent-sync-WJIZCZX5.js → workspace-agent-sync-BHE2V4KS.js} +1 -1
  40. package/dist/{workspace-context-RYOQYGOP.js → workspace-context-VJTXW3K4.js} +1 -1
  41. package/dist/{workspace-contract-ITFCJCHI.js → workspace-contract-OO4GMENV.js} +1 -1
  42. package/dist/workspace-explain-XJ22ZXJY.js +1 -0
  43. package/dist/workspace-explain-contract-24RQ7KIW.js +1 -0
  44. package/dist/{workspace-foundation-SILFUKL5.js → workspace-foundation-LISDH53T.js} +1 -1
  45. package/dist/{workspace-intelligence-YOZQBAK5.js → workspace-intelligence-EC63CRVF.js} +1 -1
  46. package/dist/workspace-mcp-serve-KOM2V35Q.js +3 -0
  47. package/dist/{workspace-model-VMMLHJWI.js → workspace-model-YL7W3573.js} +1 -1
  48. package/dist/workspace-registry-summary-X5WRUU3T.js +1 -0
  49. package/dist/workspace-run-F5FADRY5.js +1 -0
  50. package/dist/workspace-verify-IAUHP6Y6.js +1 -0
  51. package/dist/{workspace-watch-3MEZRSEE.js → workspace-watch-H2AETGFI.js} +1 -1
  52. package/docs/DEVELOPMENT.md +1 -1
  53. package/docs/OPEN_SOURCE_USER_SCENARIOS.md +1 -1
  54. package/docs/README.md +1 -1
  55. package/docs/commands-reference.md +10 -2
  56. package/docs/contracts/ARTIFACT_CATALOG.md +1 -1
  57. package/docs/contracts/README.md +11 -0
  58. package/package.json +7 -3
  59. package/scripts/enterprise-package-smoke.mjs +433 -0
  60. package/scripts/prepack-enterprise.mjs +40 -0
  61. package/templates/generator.js +175 -0
  62. package/templates/kits/fastapi-ddd/README.md.j2 +122 -0
  63. package/templates/kits/fastapi-ddd/common/env.example.j2 +10 -0
  64. package/templates/kits/fastapi-ddd/env.example.j2 +1 -0
  65. package/templates/kits/fastapi-ddd/pyproject.toml.j2 +64 -0
  66. package/templates/kits/fastapi-ddd/src/__init__.py.j2 +3 -0
  67. package/templates/kits/fastapi-ddd/src/app/__init__.py.j2 +11 -0
  68. package/templates/kits/fastapi-ddd/src/app/application/__init__.py.j2 +5 -0
  69. package/templates/kits/fastapi-ddd/src/app/application/interfaces.py.j2 +43 -0
  70. package/templates/kits/fastapi-ddd/src/app/application/use_cases/__init__.py.j2 +6 -0
  71. package/templates/kits/fastapi-ddd/src/app/application/use_cases/health.py.j2 +14 -0
  72. package/templates/kits/fastapi-ddd/src/app/application/use_cases/notes.py.j2 +24 -0
  73. package/templates/kits/fastapi-ddd/src/app/config/__init__.py.j2 +16 -0
  74. package/templates/kits/fastapi-ddd/src/app/domain/__init__.py.j2 +3 -0
  75. package/templates/kits/fastapi-ddd/src/app/domain/models/__init__.py.j2 +6 -0
  76. package/templates/kits/fastapi-ddd/src/app/domain/models/health.py.j2 +16 -0
  77. package/templates/kits/fastapi-ddd/src/app/domain/models/note.py.j2 +27 -0
  78. package/templates/kits/fastapi-ddd/src/app/infrastructure/__init__.py.j2 +5 -0
  79. package/templates/kits/fastapi-ddd/src/app/infrastructure/repositories/__init__.py.j2 +6 -0
  80. package/templates/kits/fastapi-ddd/src/app/infrastructure/repositories/health.py.j2 +17 -0
  81. package/templates/kits/fastapi-ddd/src/app/infrastructure/repositories/notes.py.j2 +28 -0
  82. package/templates/kits/fastapi-ddd/src/app/main.py.j2 +61 -0
  83. package/templates/kits/fastapi-ddd/src/app/presentation/__init__.py.j2 +3 -0
  84. package/templates/kits/fastapi-ddd/src/app/presentation/api/__init__.py.j2 +5 -0
  85. package/templates/kits/fastapi-ddd/src/app/presentation/api/dependencies/__init__.py.j2 +19 -0
  86. package/templates/kits/fastapi-ddd/src/app/presentation/api/router.py.j2 +10 -0
  87. package/templates/kits/fastapi-ddd/src/app/presentation/api/routes/__init__.py.j2 +5 -0
  88. package/templates/kits/fastapi-ddd/src/app/presentation/api/routes/health.py.j2 +27 -0
  89. package/templates/kits/fastapi-ddd/src/app/presentation/api/routes/notes.py.j2 +50 -0
  90. package/templates/kits/fastapi-ddd/src/app/shared/__init__.py.j2 +5 -0
  91. package/templates/kits/fastapi-ddd/src/app/shared/result.py.j2 +28 -0
  92. package/templates/kits/fastapi-ddd/src/cli.py.j2 +167 -0
  93. package/templates/kits/fastapi-ddd/src/main.py.j2 +35 -0
  94. package/templates/kits/fastapi-ddd/src/modules/__init__.py.j2 +3 -0
  95. package/templates/kits/fastapi-ddd/src/routing/__init__.py.j2 +13 -0
  96. package/templates/kits/fastapi-ddd/src/routing/health.py.j2 +7 -0
  97. package/templates/kits/fastapi-ddd/src/routing/notes.py.j2 +7 -0
  98. package/templates/kits/fastapi-ddd/tests/__init__.py.j2 +1 -0
  99. package/templates/kits/fastapi-ddd/tests/test_app_factory.py.j2 +22 -0
  100. package/templates/kits/fastapi-ddd/tests/test_health.py.j2 +17 -0
  101. package/templates/kits/fastapi-ddd/tests/test_notes.py.j2 +27 -0
  102. package/templates/kits/fastapi-standard/README.md.j2 +145 -0
  103. package/templates/kits/fastapi-standard/common/env.example.j2 +10 -0
  104. package/templates/kits/fastapi-standard/env.example.j2 +1 -0
  105. package/templates/kits/fastapi-standard/pyproject.toml.j2 +64 -0
  106. package/templates/kits/fastapi-standard/src/__init__.py.j2 +3 -0
  107. package/templates/kits/fastapi-standard/src/cli.py.j2 +168 -0
  108. package/templates/kits/fastapi-standard/src/main.py.j2 +66 -0
  109. package/templates/kits/fastapi-standard/src/modules/__init__.py.j2 +3 -0
  110. package/templates/kits/fastapi-standard/src/routing/__init__.py.j2 +16 -0
  111. package/templates/kits/fastapi-standard/src/routing/examples.py.j2 +71 -0
  112. package/templates/kits/fastapi-standard/src/routing/health.py.j2 +22 -0
  113. package/templates/kits/fastapi-standard/tests/__init__.py.j2 +1 -0
  114. package/templates/kits/fastapi-standard/tests/test_examples.py.j2 +29 -0
  115. package/templates/kits/fastapi-standard/tests/test_health.py.j2 +17 -0
  116. package/templates/kits/nestjs-standard/Dockerfile.j2 +41 -0
  117. package/templates/kits/nestjs-standard/README.md.j2 +139 -0
  118. package/templates/kits/nestjs-standard/docker-compose.yml.j2 +94 -0
  119. package/templates/kits/nestjs-standard/docs/README.md.j2 +15 -0
  120. package/templates/kits/nestjs-standard/env.example.j2 +18 -0
  121. package/templates/kits/nestjs-standard/eslint.config.cjs.j2 +9 -0
  122. package/templates/kits/nestjs-standard/jest.config.ts.j2 +22 -0
  123. package/templates/kits/nestjs-standard/nest-cli.json.j2 +10 -0
  124. package/templates/kits/nestjs-standard/package.json.j2 +101 -0
  125. package/templates/kits/nestjs-standard/src/app.controller.ts.j2 +14 -0
  126. package/templates/kits/nestjs-standard/src/app.module.ts.j2 +26 -0
  127. package/templates/kits/nestjs-standard/src/app.service.ts.j2 +16 -0
  128. package/templates/kits/nestjs-standard/src/auth/auth.controller.ts.j2 +20 -0
  129. package/templates/kits/nestjs-standard/src/auth/auth.module.ts.j2 +13 -0
  130. package/templates/kits/nestjs-standard/src/auth/auth.service.ts.j2 +6 -0
  131. package/templates/kits/nestjs-standard/src/auth/entities/token.entity.ts.j2 +3 -0
  132. package/templates/kits/nestjs-standard/src/auth/entities/user.entity.ts.j2 +3 -0
  133. package/templates/kits/nestjs-standard/src/auth/entities/webauthn.entity.ts.j2 +3 -0
  134. package/templates/kits/nestjs-standard/src/config/configuration.ts.j2 +85 -0
  135. package/templates/kits/nestjs-standard/src/config/index.ts.j2 +2 -0
  136. package/templates/kits/nestjs-standard/src/config/validation.ts.j2 +21 -0
  137. package/templates/kits/nestjs-standard/src/examples/dto/create-note.dto.ts.j2 +11 -0
  138. package/templates/kits/nestjs-standard/src/examples/examples.controller.ts.j2 +24 -0
  139. package/templates/kits/nestjs-standard/src/examples/examples.module.ts.j2 +10 -0
  140. package/templates/kits/nestjs-standard/src/examples/examples.service.ts.j2 +33 -0
  141. package/templates/kits/nestjs-standard/src/main.ts.j2 +53 -0
  142. package/templates/kits/nestjs-standard/src/modules/index.ts.j2 +25 -0
  143. package/templates/kits/nestjs-standard/test/app.controller.spec.ts.j2 +24 -0
  144. package/templates/kits/nestjs-standard/test/app.e2e-spec.ts.j2 +60 -0
  145. package/templates/kits/nestjs-standard/test/examples.controller.spec.ts.j2 +28 -0
  146. package/templates/kits/nestjs-standard/test/jest-e2e.json.j2 +15 -0
  147. package/templates/kits/nestjs-standard/tsconfig.build.json.j2 +12 -0
  148. package/templates/kits/nestjs-standard/tsconfig.json.j2 +26 -0
  149. package/dist/analyze-JVMUCQ22.js +0 -1
  150. package/dist/autopilot-release-GM5ALPWO.js +0 -1
  151. package/dist/chunk-424B73UF.js +0 -1
  152. package/dist/chunk-56RL5OB6.js +0 -2
  153. package/dist/chunk-AO6PG3K2.js +0 -9
  154. package/dist/chunk-AT3EQ2S7.js +0 -2
  155. package/dist/chunk-FVCZGUVX.js +0 -1
  156. package/dist/chunk-GX7UU7LL.js +0 -33
  157. package/dist/chunk-P5ODFWB2.js +0 -13
  158. package/dist/chunk-QN2LPLHO.js +0 -1
  159. package/dist/chunk-RIZCWYRR.js +0 -1
  160. package/dist/chunk-YOQ2546V.js +0 -50
  161. package/dist/chunk-Z5LKRG57.js +0 -1
  162. package/dist/chunk-ZQRFVFKK.js +0 -13
  163. package/dist/demo-kit-2VI4H6OJ.js +0 -141
  164. package/dist/workspace-explain-VKSUKP3O.js +0 -1
  165. package/dist/workspace-explain-contract-CLHQ3XEH.js +0 -1
  166. package/dist/workspace-mcp-serve-OOLITFCK.js +0 -3
  167. package/dist/workspace-registry-summary-ZXGKL2NT.js +0 -1
  168. package/dist/workspace-run-IHB2TPMD.js +0 -1
  169. package/dist/workspace-verify-3CAKAZIL.js +0 -1
package/README.md CHANGED
@@ -1,12 +1,16 @@
1
1
  # RapidKit
2
2
 
3
- ### Open-Source Workspace Intelligence for Software Systems
3
+ ## Open-Source Workspace Intelligence for Software Systems
4
4
 
5
5
  [![npm version](https://img.shields.io/npm/v/rapidkit.svg?style=flat-square)](https://www.npmjs.com/package/rapidkit)
6
6
  [![Downloads](https://img.shields.io/npm/dm/rapidkit.svg?style=flat-square)](https://www.npmjs.com/package/rapidkit)
7
7
  [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg?style=flat-square)](https://opensource.org/licenses/MIT)
8
8
  [![Built by RapidKit](https://img.shields.io/badge/Built%20by-RapidKit-0f172a?logo=github)](https://www.getrapidkit.com)
9
9
 
10
+ Not another AI coding assistant.
11
+ Not another agent framework.
12
+ Not another context engine.
13
+
10
14
  > One workspace. One truth. Humans and AI aligned.
11
15
 
12
16
  RapidKit turns scattered projects into a governed, agent-ready workspace.
@@ -38,8 +42,8 @@ npx rapidkit my-workspace --yes --profile polyglot
38
42
  cd ~/rapidkit/workspaces/my-workspace
39
43
 
40
44
  npx rapidkit bootstrap --profile polyglot
41
- npx rapidkit create project
42
- npx rapidkit create frontend nextjs my-web --yes
45
+ npx rapidkit create project nextjs my-web --yes
46
+ npx rapidkit create project fastapi.standard my-api --yes
43
47
 
44
48
  npx rapidkit workspace model --json
45
49
  npx rapidkit workspace context --for-agent --json --write
@@ -142,6 +146,7 @@ For the visual experience, install the [Workspai VS Code extension](https://mark
142
146
  - [From Code to Shared Understanding](#from-code-to-shared-understanding)
143
147
  - [Typical workflows](#typical-workflows)
144
148
  - [Mental model](#mental-model)
149
+ - [Why this architecture helps](#why-this-architecture-helps)
145
150
  - [Workspace Intelligence Commands](#workspace-intelligence-commands)
146
151
  - [Agent Customization Pack](#agent-customization-pack)
147
152
  - [Requirements](#requirements)
@@ -211,27 +216,92 @@ New workspaces go under `~/rapidkit/workspaces/<name>`. Legacy `~/Workspai/rapid
211
216
 
212
217
  ## Mental model
213
218
 
214
- ### Two-layer model
219
+ ### Two capabilities, one workspace intelligence layer
215
220
 
216
221
  ```text
217
- First-class engine kitsFastAPI and NestJS (modules + deep generation)
218
- Workspace intelligence frontend apps, Go, Spring, .NET, adopted/imported repos
222
+ Workspace Intelligenceevery project in the workspace
223
+ Native generation first-class scaffolds and stack-specific project creation
224
+ Deep module generation → selected backend engine kits such as FastAPI and NestJS
219
225
  ```
220
226
 
221
- RapidKit treats the **workspace** as the operating boundary: policy, registry, evidence, contracts, and release readiness. Projects can live inside the workspace or be **adopted** from outside.
227
+ Workspace Intelligence is not limited to a framework lane. It works across
228
+ RapidKit-created projects, frontend apps, Go, Spring Boot, .NET, FastAPI, NestJS,
229
+ and adopted/imported repositories. The difference is generation depth:
230
+ some stacks have first-class scaffolds, some use official ecosystem generators,
231
+ and existing projects can be adopted in place.
232
+
233
+ RapidKit treats the **workspace** as the operating boundary: policy, registry,
234
+ evidence, contracts, and release readiness. Projects can live inside the
235
+ workspace or be **adopted** from outside.
222
236
 
223
237
  ```text
224
238
  workspace/
239
+ .rapidkit-workspace
225
240
  .rapidkit/workspace.json
226
241
  .rapidkit/reports/
242
+ workspace-model.json
243
+ workspace-context-agent.json
244
+ INDEX.json
245
+ agent-customization-pack.json
246
+ workspace-skills-index.json
247
+ rapidkit-mcp-design.json
248
+ .rapidkit/skills/
249
+ .rapidkit/AGENT-GROUNDING.md
227
250
  services/api/
251
+ .rapidkit/project.json
252
+ AGENTS.md
253
+ .github/copilot-instructions.md
254
+ .github/instructions/
255
+ .github/prompts/
256
+ .github/skills/
257
+ .github/agents/
258
+ .cursor/rules/rapidkit-grounding.mdc
259
+ CLAUDE.md
260
+ .vscode/rapidkit-agent-hooks.json
228
261
 
229
262
  external-project/
230
263
  .rapidkit/project.json
231
264
  .rapidkit/adopt.json
232
265
  ```
233
266
 
234
- Every tool gets the same answers: what projects exist, what stack they use, which commands are safe, what evidence exists, and what context agents should receive.
267
+ `.rapidkit/workspace.json` is the workspace manifest, not the project list.
268
+ Projects are discovered from workspace project metadata, imported/adopted
269
+ records, and workspace intelligence reports.
270
+
271
+ Agent-facing outputs are generated from the same evidence layer:
272
+ `workspace context --for-agent --write` writes the agent context report, and
273
+ `workspace agent-sync --write --refresh-context --preset enterprise` writes the
274
+ portable `AGENTS.md`, report index, skills, Copilot/Cursor/Claude surfaces, and
275
+ agent handoff files. The exact generated output inventory is recorded in
276
+ `.rapidkit/reports/agent-customization-pack.json` and summarized in the
277
+ [Agent Customization Pack](#agent-customization-pack) section below.
278
+
279
+ Every tool gets the same answers for every registered project: what projects
280
+ exist, what stack they use, which commands are safe, what evidence exists, what
281
+ changed, what release gates apply, and what context agents should receive.
282
+
283
+ ## Why this architecture helps
284
+
285
+ You do not have to change frameworks to benefit from RapidKit.
286
+
287
+ Use the frontend or backend stack that already fits your product: Next.js,
288
+ Vite, FastAPI, NestJS, Go, Spring Boot, .NET, or an existing repository you
289
+ adopt in place. RapidKit adds the workspace layer around it: project registry,
290
+ safe commands, evidence, impact analysis, agent context, verification, and
291
+ release gates.
292
+
293
+ That means you can move faster without turning the product into a fragile
294
+ prototype:
295
+
296
+ - Start new products with governed scaffolds when RapidKit owns the create path
297
+ - Adopt existing products without moving source code or rewriting the stack
298
+ - Give humans, CI, IDEs, and AI agents the same workspace truth
299
+ - Know what changed, what is affected, and what must be verified before release
300
+ - Keep framework stability while adding professional product-development
301
+ workflows around the codebase
302
+
303
+ The result is faster product development with clearer boundaries, safer AI
304
+ assistance, and release decisions backed by evidence instead of guesswork.
235
305
 
236
306
  ## Workspace Intelligence Commands
237
307
 
@@ -413,13 +483,20 @@ cd ~/rapidkit/workspaces/my-workspace
413
483
 
414
484
  npx rapidkit bootstrap --profile polyglot
415
485
  npx rapidkit create project # interactive kit picker
416
- npx rapidkit create frontend nextjs my-web --yes
486
+ npx rapidkit create project nextjs my-web --yes
487
+ npx rapidkit create project fastapi.standard my-api --yes
417
488
  cd <project-name> && npx rapidkit init && npx rapidkit dev
418
489
  ```
419
490
 
420
491
  Backend kits: `fastapi.standard`, `nestjs.standard`, `springboot.standard`, `gofiber.standard`, `dotnet.webapi.clean`, and more.
421
492
 
422
- Frontend: `create frontend nextjs|remix|vite-react|angular|astro|…` or `create project frontend.nextjs <name>`.
493
+ Frontend kits: `nextjs`, `remix`, `vite-react`, `nuxt`, `angular`, `astro`, `sveltekit`, and more — same command shape:
494
+
495
+ ```bash
496
+ npx rapidkit create project <kit> <name>
497
+ ```
498
+
499
+ (`create frontend <id>` remains supported as an alias.)
423
500
 
424
501
  Shortcut: `npx rapidkit platform` (interactive workspace wizard).
425
502
 
@@ -484,7 +561,7 @@ Search **Workspai** in the marketplace or install via:
484
561
  | Enterprise evidence loop | Partial | Full dashboard |
485
562
  | Module catalog (FastAPI/NestJS) | Limited | Browser UI |
486
563
 
487
- The extension invokes this npm CLI. For the latest `adopt` and `create frontend` features, install matching CLI version: `npm install -g rapidkit@latest` or `npm link` from this repo ([Development](#development)).
564
+ 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
565
 
489
566
  ## Documentation
490
567
 
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "schemaVersion": "rapidkit-extension-cli-compatibility.v1",
3
3
  "cli": "rapidkit-npm",
4
- "minimumVerifiedCliVersion": "0.41.0",
4
+ "minimumVerifiedCliVersion": "0.41.2",
5
5
  "publishedContractSchemas": {
6
6
  "runtimeCommandSurface": "rapidkit-runtime-command-surface-v1",
7
7
  "cliLogEvent": "cli-log-event-v1",
@@ -76,7 +76,9 @@
76
76
  "verify",
77
77
  "context",
78
78
  "agent-sync",
79
- "explain"
79
+ "explain",
80
+ "why",
81
+ "trace"
80
82
  ],
81
83
  "moduleSuggestionFrameworks": [
82
84
  "fastapi",
@@ -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
  }
@@ -65,6 +65,30 @@
65
65
  "studioMode": {
66
66
  "enum": ["FIX", "RUN_ONCE", "VERIFY_ONLY", "EXPLAIN"]
67
67
  },
68
+ "incidentSummary": {
69
+ "type": "object",
70
+ "required": ["title", "phase", "primaryAction", "verifyRequired", "auditStatus"],
71
+ "properties": {
72
+ "title": {
73
+ "type": "string",
74
+ "minLength": 1
75
+ },
76
+ "phase": {
77
+ "enum": ["detect", "diagnose", "fix", "verify", "audit"]
78
+ },
79
+ "primaryAction": {
80
+ "type": "string",
81
+ "minLength": 1
82
+ },
83
+ "verifyRequired": {
84
+ "type": "boolean"
85
+ },
86
+ "auditStatus": {
87
+ "enum": ["not-started", "pending", "saved", "failed", "unknown"]
88
+ }
89
+ },
90
+ "additionalProperties": false
91
+ },
68
92
  "resolutionHints": {
69
93
  "type": "array",
70
94
  "items": {
@@ -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-ZPXMZCYG.js';
@@ -1,2 +1,2 @@
1
- import {j as j$1}from'./chunk-QN2LPLHO.js';import {a}from'./chunk-DMUEGR36.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(`
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};