workspai 0.77.0 → 0.78.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (82) hide show
  1. package/contracts/create-planner-capabilities.v1.json +26 -2
  2. package/contracts/runtime-command-surface.v1.json +2 -0
  3. package/contracts/workspace-intelligence-architecture.v1.json +2 -0
  4. package/dist/analyze-X76YV667.js +1 -0
  5. package/dist/autopilot-release-6OV2FLRS.js +1 -0
  6. package/dist/{chunk-3EMAC3MF.js → chunk-2CUT4GLE.js} +1 -1
  7. package/dist/chunk-3PGXGAHC.js +2 -0
  8. package/dist/{chunk-4CXV3PPV.js → chunk-4AAXIWYY.js} +1 -1
  9. package/dist/{chunk-47UR6ZH4.js → chunk-4KAYWMNE.js} +1 -1
  10. package/dist/{chunk-UP3UWAJV.js → chunk-5FVREPQC.js} +1 -1
  11. package/dist/{chunk-HRVHQBTA.js → chunk-5OKNWBAN.js} +1 -1
  12. package/dist/{chunk-DWKCFHHL.js → chunk-75WJOYWT.js} +1 -1
  13. package/dist/{chunk-LUPKDFQ3.js → chunk-7EMG3C3H.js} +2 -2
  14. package/dist/{chunk-O3TVVQ6X.js → chunk-7HV4U2OV.js} +1 -1
  15. package/dist/{chunk-TGNPMOM6.js → chunk-AMGIXK6Z.js} +1 -1
  16. package/dist/{chunk-IDETNYCF.js → chunk-FLAGHVSH.js} +1 -1
  17. package/dist/{chunk-UNEK3VVR.js → chunk-HB3ZYG2Z.js} +2144 -91
  18. package/dist/{chunk-UTIK3K3M.js → chunk-HMWZWT7B.js} +1 -1
  19. package/dist/{chunk-3SQIV3F4.js → chunk-IQJL3LBM.js} +1 -1
  20. package/dist/{chunk-475GQJ2D.js → chunk-KRTVIBPC.js} +1 -1
  21. package/dist/chunk-MD4CHXV3.js +2 -0
  22. package/dist/{chunk-QCX6BO2M.js → chunk-MN5S462C.js} +1 -1
  23. package/dist/{chunk-IAXRGH4Q.js → chunk-ONUFNCRN.js} +1 -1
  24. package/dist/chunk-QDM6TWFK.js +1 -0
  25. package/dist/{chunk-WC2K5QFI.js → chunk-QLHRGWUW.js} +1 -1
  26. package/dist/{chunk-223SWPTL.js → chunk-QMNJTI65.js} +1 -1
  27. package/dist/{chunk-ZIWWE4BQ.js → chunk-RHF2IZOW.js} +1 -1
  28. package/dist/{chunk-V6HVDVKJ.js → chunk-RJESUJQF.js} +5 -5
  29. package/dist/chunk-RQXZF7BZ.js +1 -0
  30. package/dist/{chunk-JVZA35OL.js → chunk-TJRVWVAZ.js} +1 -1
  31. package/dist/{chunk-GLBFY7AB.js → chunk-UVIBPWOG.js} +2 -2
  32. package/dist/{chunk-3EPR3D5Q.js → chunk-VEMGICT4.js} +1 -1
  33. package/dist/{chunk-SC43A6LH.js → chunk-VRZAN3WS.js} +50 -50
  34. package/dist/{chunk-E7WJ2QX7.js → chunk-YHQK4S3H.js} +1 -1
  35. package/dist/{chunk-X5XFT5UZ.js → chunk-YWC5MKIL.js} +1 -1
  36. package/dist/{chunk-J2MPBSQJ.js → chunk-ZQ36CTLF.js} +1 -1
  37. package/dist/{create-YPAZJYCE.js → create-WB5YQ7C6.js} +1 -1
  38. package/dist/{doctor-W5PXJ5FL.js → doctor-HOSHQ7II.js} +1 -1
  39. package/dist/{goal-lifecycle-5R55CA7H.js → goal-lifecycle-UEJMTUFV.js} +1 -1
  40. package/dist/{goal-pack-IS6GGJPH.js → goal-pack-YGZMG3RQ.js} +1 -1
  41. package/dist/index.js +92 -91
  42. package/dist/{pipeline-LW3SW2WT.js → pipeline-Z4JOJ4PX.js} +1 -1
  43. package/dist/{project-agent-entry-5TYKK5IV.js → project-agent-entry-ZMDQWJ6I.js} +1 -1
  44. package/dist/{project-intelligence-lens-TEOSTKNU.js → project-intelligence-lens-FSWQKY3E.js} +1 -1
  45. package/dist/{project-test-coverage-T4TIWGKN.js → project-test-coverage-EJ3MBSZ3.js} +1 -1
  46. package/dist/{proof-carrying-change-2TKRADCW.js → proof-carrying-change-M2RNYQ7E.js} +1 -1
  47. package/dist/{verified-goal-RN4TOV34.js → verified-goal-UAUCEDZZ.js} +1 -1
  48. package/dist/{workspace-A33YMF2N.js → workspace-J5QYWAE3.js} +1 -1
  49. package/dist/{workspace-agent-sync-VCA4G4DT.js → workspace-agent-sync-GLG36KQZ.js} +1 -1
  50. package/dist/{workspace-context-YBWLSKR6.js → workspace-context-BZV4ZFKZ.js} +1 -1
  51. package/dist/{workspace-contract-3QUZDBMM.js → workspace-contract-XDNIB5JX.js} +1 -1
  52. package/dist/{workspace-explain-NXYRAQFI.js → workspace-explain-V3XDMONQ.js} +1 -1
  53. package/dist/{workspace-foundation-DZ52PECX.js → workspace-foundation-EDTKW2RB.js} +1 -1
  54. package/dist/{workspace-graph-stream-4VT46HZ7.js → workspace-graph-stream-UPASFCAF.js} +1 -1
  55. package/dist/{workspace-intelligence-FKYQQDJ6.js → workspace-intelligence-24MZRG2S.js} +1 -1
  56. package/dist/{workspace-intelligence-runner-3K2JZH6Q.js → workspace-intelligence-runner-HISKHQLG.js} +1 -1
  57. package/dist/{workspace-knowledge-graph-CPBKNXQI.js → workspace-knowledge-graph-5EECTGXQ.js} +1 -1
  58. package/dist/workspace-knowledge-graph-snapshot-T6ZJGWLC.js +1 -0
  59. package/dist/{workspace-mcp-serve-UXPKX7K6.js → workspace-mcp-serve-S3TWO4RI.js} +1 -1
  60. package/dist/{workspace-model-POCPMNRT.js → workspace-model-J757KSDE.js} +1 -1
  61. package/dist/{workspace-onboarding-KLG3GG7S.js → workspace-onboarding-3TLME4HP.js} +1 -1
  62. package/dist/{workspace-registry-summary-M4WMFDQ4.js → workspace-registry-summary-ZC5CFZXP.js} +1 -1
  63. package/dist/{workspace-repair-engine-2VGN42QD.js → workspace-repair-engine-C26C7OIB.js} +1 -1
  64. package/dist/workspace-run-2KBTMGG7.js +1 -0
  65. package/dist/{workspace-verify-PLAKTF3J.js → workspace-verify-KFBWQ37C.js} +1 -1
  66. package/dist/{workspace-watch-VNU4KVYN.js → workspace-watch-LNP5JPD4.js} +1 -1
  67. package/docs/agent-framework-adapters.md +68 -18
  68. package/docs/ci-workflows.md +9 -6
  69. package/docs/commands-reference.md +5 -2
  70. package/docs/creating-workspaces-and-projects.md +2 -0
  71. package/docs/doctor-command.md +5 -3
  72. package/docs/native-kit-baselines.md +2 -2
  73. package/package.json +4 -1
  74. package/scripts/enterprise-package-smoke.mjs +50 -0
  75. package/dist/analyze-TJM66CPF.js +0 -1
  76. package/dist/autopilot-release-C7Q4OTPY.js +0 -1
  77. package/dist/chunk-5KXOV7W4.js +0 -1
  78. package/dist/chunk-IHWS3ALP.js +0 -2
  79. package/dist/chunk-N7DOKE7V.js +0 -2
  80. package/dist/chunk-SEZTSMRR.js +0 -1
  81. package/dist/workspace-knowledge-graph-snapshot-67XDXUOT.js +0 -1
  82. package/dist/workspace-run-5YQR7GEZ.js +0 -1
@@ -29,15 +29,15 @@ a report and artifact. It does not commit, open a pull request, regenerate
29
29
  Create contracts, or write `release-admissions.v2.json`. A human pin update
30
30
  still has to pass the manual `full` mode of `agent-framework-conformance` on
31
31
  Linux, macOS, and Windows for every built-in adapter runtime. Pull requests run
32
- the faster Linux gate only for the affected Microsoft or OpenAI family; shared
33
- agent-framework surfaces select both, while documentation-only changes skip the
34
- specialized workflow. The full matrix compiles the nested `agents/primary`
32
+ the faster Linux gate only for the affected Microsoft, OpenAI, or Google family;
33
+ shared agent-framework surfaces select the affected families, while documentation-only
34
+ changes skip the specialized workflow. The full matrix compiles the nested `agents/primary`
35
35
  runtime, runs credentialless context-boundary tests, and records manifest-bound
36
36
  admission data plus semantic implementation provenance. Promotion requires the
37
37
  candidate source commit to equal the checked-out promotion commit. An
38
38
  implementation digest is audit evidence, not a runtime lock and not a manual
39
39
  maintenance requirement after every routine adapter edit.
40
- It never sets Foundry or OpenAI credentials. Only a reviewed admission on the protected
40
+ It never sets Foundry, OpenAI, Gemini, or Vertex credentials. Only a reviewed admission on the protected
41
41
  version-update branch can promote a green candidate.
42
42
 
43
43
  OpenRouter AI Gateway kits are not part of the Agent Framework conformance
@@ -113,7 +113,10 @@ cross-platform qualification is needed. npm and Composer download caches reduce
113
113
  repeated network work without treating an earlier commit or calendar-day result
114
114
  as proof for a new SHA.
115
115
 
116
- The Windows coverage lane intentionally uses bounded Vitest worker concurrency
116
+ Linux is the only matrix job that collects V8 coverage, and that report is
117
+ text plus `coverage-final.json`. macOS and Windows run the same suite without
118
+ coverage instrumentation and without a second `tsup`, because the job build
119
+ already produced `dist`. The Windows test lane intentionally uses bounded Vitest worker concurrency
117
120
  and platform-aware transaction timeouts. Filesystem-heavy workspace tests must
118
121
  finish their transaction before teardown; cleanup retries transient Windows
119
122
  `EBUSY`, `ENOTEMPTY`, and `EPERM` states instead of converting one slow operation into a
@@ -136,7 +139,7 @@ Validate or preview the current CLI announcement locally:
136
139
  npm --workspace workspai run check:release-announcement
137
140
  npm --workspace workspai run release:announcement -- \
138
141
  --product workspai-cli \
139
- --tag v0.77.0 \
142
+ --tag v0.78.0 \
140
143
  --markdown-output /tmp/workspai-discord-announcement.md
141
144
  ```
142
145
 
@@ -280,7 +280,9 @@ See [Canonical-first agent entry](./agent-entry.md).
280
280
  agent runtime. `list` exposes every built-in adapter and its release-admission
281
281
  state. In this CLI version Microsoft Python `1.18.0` and .NET `1.21.0` remain
282
282
  `preview`. OpenAI Agents SDK Python `0.22.2` and TypeScript `0.18.0` are
283
- labeled `stable`. Create and Attach require the reviewed v2 release inventory,
283
+ labeled `stable`. Google ADK Python `2.9.2` and TypeScript `2.1.0` remain
284
+ labeled `preview` and are admitted for Create and Attach by their complete
285
+ Linux, macOS, and Windows evidence. Create and Attach require the reviewed v2 release inventory,
284
286
  whose manifest, framework baseline, runtime, and platform claims were promoted
285
287
  from the Linux, macOS, and Windows release matrix. Semantic implementation
286
288
  digests remain audit provenance rather than runtime authorization. `plan`
@@ -295,7 +297,8 @@ agent.microsoft.python|dotnet` uses the same admitted lifecycle for a new
295
297
  project: it registers the project, plans against a Model baseline, writes the
296
298
  nested runtime, then re-observes Model/Graph before it claims Intelligence is
297
299
  sealed. `create project agent.openai.python|typescript` uses the same admitted
298
- lifecycle. Dependency installation, credentials, generated-code execution, and
300
+ lifecycle. `create project agent.google-adk.python|typescript` uses the same
301
+ admitted lifecycle. Dependency installation, credentials, generated-code execution, and
299
302
  model provider calls are never implied by that approval. `apply` is the
300
303
  automation counterpart for a plan that was separately authorized with
301
304
  `change authorize`. Any adapter, version, manifest, runtime, or platform drift
@@ -397,6 +397,8 @@ project metadata and performs the selected workspace registration.
397
397
  | `agent.microsoft.dotnet` | .NET | `Microsoft.Agents.AI` `1.21.0`, Foundry `1.21.0-preview.260911.1` | Isolated `agents/<instance>/` with the executable project plus a dedicated test project |
398
398
  | `agent.openai.python` | Python | `openai-agents` `0.22.2` | Isolated `agents/<instance>/` with pip-editable `pyproject.toml`, credentialless `unittest`, and `.env.example` |
399
399
  | `agent.openai.typescript` | Node.js | `@openai/agents` `0.18.0`, `zod` `4.6.5` | Isolated `agents/<instance>/` with `package.json`, credentialless `node:test`, and `.env.example` |
400
+ | `agent.google-adk.python` | Python | `google-adk` `2.9.2` | Isolated `agents/<instance>/` with pip-editable `pyproject.toml`, credentialless `unittest`, and provider profiles `gemini-api` / `vertex-ai`. Preview and release-admitted. |
401
+ | `agent.google-adk.typescript` | Node.js | `@google/adk` `2.1.0`, `zod` `4.6.5` | Isolated `agents/<instance>/` with `package.json`, credentialless `node:test`, and provider profiles `gemini-api` / `vertex-ai`. Preview, release-admitted, and independent from the Python runtime. |
400
402
 
401
403
  Interactive `workspai create` shows these kits under **AI Agent** after
402
404
  reviewed release admission. Agent kits require Workspace governance and therefore do not
@@ -775,9 +775,11 @@ These fields are designed for release gates and extension timeline cards that mu
775
775
  - Supports Workspai, legacy RapidKit, and non-Workspai projects when project metadata is missing.
776
776
  - Evidence: `.workspai/reports/doctor-project-last-run.json`.
777
777
  - `--fix`, `--plan`, and `--apply` apply only project-scoped fixes.
778
- - Governed Microsoft Agent Framework and OpenAI Agents SDK projects keep
779
- `kind` as `agent`. Microsoft retains `microsoft-agent-framework`; OpenAI
780
- retains `openai-agents`. Doctor discovers nested environment examples and
778
+ - Governed Microsoft Agent Framework, OpenAI Agents SDK, and Google ADK
779
+ projects keep `kind` as `agent`. Microsoft retains
780
+ `microsoft-agent-framework`; OpenAI retains `openai-agents`; Google ADK
781
+ retains `google-adk`. Doctor discovers nested environment examples and
782
+ dependency manifests under `agents/primary` and aims Python/`uv`, Node
781
783
  dependency manifests under `agents/primary` and aims Python/`uv`, Node
782
784
  `npm --prefix`, or .NET repair commands at that runtime, not at a phantom
783
785
  project-root manifest.
@@ -12,8 +12,8 @@ native kits:
12
12
  This policy does not cover FastAPI or NestJS kits owned by the RapidKit Python
13
13
  engine. It also does not cover generators delegated to an upstream official
14
14
  CLI, such as Next.js, Astro, Angular, Vue, Svelte, Nuxt, or React Native.
15
- Governed Microsoft Agent Framework and OpenAI Agents SDK kits are versioned
16
- separately through the
15
+ Governed Microsoft Agent Framework, OpenAI Agents SDK, and Google ADK kits are
16
+ versioned separately through the
17
17
  [Agent Framework Adapter Contract](./agent-framework-adapters.md); they are
18
18
  not native HTTP service generators. OpenRouter AI Gateway kits are versioned
19
19
  through [AI Gateway](./model-gateways.md) and are not Agent Framework kits.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "workspai",
3
- "version": "0.77.0",
3
+ "version": "0.78.0",
4
4
  "type": "module",
5
5
  "description": "Open-source workspace intelligence CLI for software systems: create, adopt, govern, verify, and align polyglot workspaces for humans, CI, IDEs, and AI agents.",
6
6
  "keywords": [
@@ -97,6 +97,7 @@
97
97
  "test:parity-contract": "corepack npm run check:shared-contracts && vitest run src/__tests__/contracts/import-stack-parity.snapshot.test.ts",
98
98
  "test:watch": "vitest",
99
99
  "test:coverage": "corepack npm run test:prebuild && vitest run --coverage --reporter=default --reporter=json --outputFile.json=test-results/vitest.json",
100
+ "test:coverage:ci": "vitest run --coverage --reporter=default --reporter=json --outputFile.json=test-results/vitest.json",
100
101
  "test:prepare-embeddings": "node scripts/prepare-mock-embeddings.mjs",
101
102
  "generate-embeddings": "npx tsx src/ai/generate-embeddings.ts",
102
103
  "verify:package-cli": "node scripts/verify-package-cli.mjs",
@@ -117,6 +118,8 @@
117
118
  "test:agent-framework:dotnet": "tsx scripts/smoke-microsoft-agent-framework-adapter.ts --runtime dotnet",
118
119
  "test:agent-framework:openai:python": "tsx scripts/smoke-openai-agents-adapter.ts --runtime python",
119
120
  "test:agent-framework:openai:typescript": "tsx scripts/smoke-openai-agents-adapter.ts --runtime typescript",
121
+ "test:agent-framework:google-adk:python": "tsx scripts/smoke-google-adk-adapter.ts --runtime python",
122
+ "test:agent-framework:google-adk:typescript": "tsx scripts/smoke-google-adk-adapter.ts --runtime typescript",
120
123
  "verify:agent-framework:matrix": "tsx scripts/verify-agent-framework-conformance.ts --reports test-results/agent-framework-conformance",
121
124
  "discover:agent-framework:versions": "tsx scripts/discover-agent-framework-versions.ts",
122
125
  "propose:agent-framework:versions": "tsx scripts/propose-agent-framework-version-update.ts",
@@ -358,6 +358,8 @@ function assertCliContracts() {
358
358
  .map((adapter) => adapter.id)
359
359
  .sort();
360
360
  const expectedAdapterIds = [
361
+ 'google-adk-python',
362
+ 'google-adk-typescript',
361
363
  'microsoft-agent-framework-dotnet',
362
364
  'microsoft-agent-framework-python',
363
365
  'openai-agents-python',
@@ -387,6 +389,19 @@ function assertCliContracts() {
387
389
  );
388
390
  }
389
391
  }
392
+ for (const googleId of ['google-adk-python', 'google-adk-typescript']) {
393
+ const google = adapters.find((adapter) => adapter.id === googleId);
394
+ if (!google) {
395
+ fail(`published CLI is missing implemented Google ADK adapter ${googleId}`);
396
+ }
397
+ if (google.stability !== 'preview') {
398
+ fail(
399
+ `${googleId} must retain its preview stability label after release admission (observed: ${
400
+ google.stability ?? 'missing'
401
+ })`
402
+ );
403
+ }
404
+ }
390
405
 
391
406
  log(`verified CLI contract surfaces for v${version.version}`);
392
407
  }
@@ -486,6 +501,41 @@ function smokeCreateAgentFrameworkKits() {
486
501
  'agents/primary/README.md',
487
502
  ],
488
503
  },
504
+ {
505
+ kit: 'agent.google-adk.python',
506
+ name: 'google-python-agent',
507
+ expectCreate: releaseAdmittedAdapterIds.has('google-adk-python'),
508
+ expectedFiles: [
509
+ 'README.md',
510
+ '.workspai/project.json',
511
+ '.workspai/agent-frameworks/google-adk-python/primary.json',
512
+ 'agents/primary/main.py',
513
+ 'agents/primary/workspai_context.py',
514
+ 'agents/primary/agent.py',
515
+ 'agents/primary/pyproject.toml',
516
+ 'agents/primary/tests/test_context.py',
517
+ 'agents/primary/.env.example',
518
+ 'agents/primary/README.md',
519
+ ],
520
+ },
521
+ {
522
+ kit: 'agent.google-adk.typescript',
523
+ name: 'google-typescript-agent',
524
+ expectCreate: releaseAdmittedAdapterIds.has('google-adk-typescript'),
525
+ expectedFiles: [
526
+ 'README.md',
527
+ '.workspai/project.json',
528
+ '.workspai/agent-frameworks/google-adk-typescript/primary.json',
529
+ 'agents/primary/src/main.ts',
530
+ 'agents/primary/src/workspai-context.ts',
531
+ 'agents/primary/src/agent.ts',
532
+ 'agents/primary/package.json',
533
+ 'agents/primary/tsconfig.json',
534
+ 'agents/primary/tests/context.test.ts',
535
+ 'agents/primary/.env.example',
536
+ 'agents/primary/README.md',
537
+ ],
538
+ },
489
539
  ];
490
540
  try {
491
541
  for (const scenario of scenarios) {
@@ -1 +0,0 @@
1
- export{b as printAnalyzeReport,a as runAnalyze}from'./chunk-223SWPTL.js';
@@ -1 +0,0 @@
1
- export{b as AUTOPILOT_RELEASE_ALIAS_FILENAME,a as AUTOPILOT_RELEASE_LAST_RUN_FILENAME,c as runAutopilotRelease}from'./chunk-E7WJ2QX7.js';
@@ -1 +0,0 @@
1
- import {j,m,e}from'./chunk-LUPKDFQ3.js';import {u}from'./chunk-VQZ5PI5J.js';import {t}from'./chunk-ODK4LCEL.js';import d from'path';import f from'fs-extra';import {parse}from'yaml';import k from'fs';var L=new Set(["backend","desktop","extension","service","frontend","worker","agent","gateway","platform","library","infra","docs","test-suite","unknown"]),O=new Set([".git",".workspai","vendor","node_modules","test","tests","testdata","fixtures","samples","examples","third_party"]),F=new Set([...O,".cache",".venv","build","dist","target"]);async function I(e){let n=0,t=async(o,r)=>{if(r>5)return false;let s;try{s=await f.readdir(o,{withFileTypes:true});}catch{return false}for(let c of s.sort((u,a)=>u.name.localeCompare(a.name))){if(c.isFile()&&c.name==="main.go"){let u=await f.readFile(d.join(o,c.name),"utf8").catch(()=>"");if(/^\s*package\s+main\b/m.test(u)&&(n+=1,n>1))return true}if(c.isDirectory()&&!O.has(c.name)&&await t(d.join(o,c.name),r+1))return true}return false};return t(e,0)}async function M(e,n){if(n!=="c"&&n!=="cpp")return false;let t=new Set,o=async(r,s)=>{if(s>3||t.size>=3)return;let c;try{c=await f.readdir(r,{withFileTypes:true});}catch{return}for(let u of c)if(u.isFile()){let a=u.name.toLowerCase();a==="cmakelists.txt"||a==="meson.build"?t.add("native"):a==="pyproject.toml"||a==="setup.py"?t.add("python"):a==="description"&&d.basename(r).toLowerCase()==="r"?t.add("r"):a.endsWith(".gemspec")?t.add("ruby"):a==="pom.xml"||a==="build.gradle"||a==="build.gradle.kts"?t.add("java"):a==="cargo.toml"?t.add("rust"):a==="go.mod"?t.add("go"):a==="package.json"&&t.add("node");}else u.isDirectory()&&!F.has(u.name)&&await o(d.join(r,u.name),s+1);};return await o(e,0),t.has("native")&&t.size>=3}async function K(e){if((((await f.readFile(d.join(e,"pom.xml"),"utf8").catch(()=>"")).match(/<modules\b[^>]*>([\s\S]*?)<\/modules>/iu)?.[1]??"").match(/<module\b[^>]*>[^<]+<\/module>/giu)??[]).length>=2)return true;for(let o of ["settings.gradle","settings.gradle.kts"]){let r=await f.readFile(d.join(e,o),"utf8").catch(()=>"");if(!r)continue;if(new Set([...r.matchAll(/['"](:[^'"]+)['"]/gu)].map(c=>c[1])).size>=2)return true}return false}async function $(e){for(let n of ["compose.yaml","compose.yml","docker-compose.yaml","docker-compose.yml"]){let t=await f.readFile(d.join(e,n),"utf8").catch(()=>"");if(t)try{let r=parse(t)?.services??{},s=Object.entries(r).map(([i,p])=>{let g=(()=>{if(typeof p?.build=="string")return `${p.build}|Dockerfile`;if(!p?.build||typeof p.build!="object")return null;let l=p.build.context;if(typeof l!="string"||l.length===0)return null;let j="dockerfile"in p.build&&typeof p.build.dockerfile=="string"?p.build.dockerfile:"Dockerfile";return `${l}|${j}`})();return g?{serviceName:i,service:p,identity:g.replaceAll("\\","/").replace(/\/$/,"")}:null}).filter(i=>i!==null);if(new Set(s.map(i=>i.identity)).size<2)continue;let u=new Set(s.map(i=>i.serviceName)),a=new Set(s.filter(({service:i})=>Array.isArray(i.ports)&&i.ports.length>0).map(({identity:i})=>i)),y=s.some(({service:i})=>(Array.isArray(i.depends_on)?i.depends_on:i.depends_on&&typeof i.depends_on=="object"?Object.keys(i.depends_on):[]).some(g=>typeof g=="string"&&u.has(g)));if(a.size>=2||y)return true}catch{}}return false}async function A(e){try{if(!await f.pathExists(e))return null;let n=await f.readJSON(e);return n&&typeof n=="object"?n:null}catch{return null}}async function z(e){for(let n of e){let t=await A(n);if(t)return t}return null}function S(e){if(typeof e!="string")return null;let n=e.trim().toLowerCase();return L.has(n)?n==="service"?"backend":n:null}function re(e){switch(e){case "backend":case "service":case "worker":return "backend";case "agent":return "agent";case "gateway":return "gateway";case "frontend":case "desktop":case "extension":case "library":case "platform":return e;case "infra":return "infrastructure";case "docs":return "documentation";case "test-suite":return "quality";default:return "unknown"}}async function oe(e$1,n,t={}){let o=n??await z(u(e$1,"project.json")),r=j(o)?null:o,s=r===null&&o!==null?m(e$1,null):null,c=S(r?.kind)??S(r?.type);if(c)return c==="worker"&&typeof r?.framework=="string"&&(r.framework.trim().toLowerCase()==="microsoft-agent-framework"||r.framework.trim().toLowerCase()==="openai-agents")?"agent":c;let u$1=typeof r?.kit_name=="string"?r.kit_name:typeof r?.kit=="string"?r.kit:t.kit,a=typeof r?.framework=="string"?r.framework:t.framework??s?.key,y=typeof r?.runtime=="string"?r.runtime:t.runtime??s?.runtime,i=`${typeof u$1=="string"?u$1:""} ${a??""} ${y??""}`.trim().toLowerCase();if(await $(e$1))return "platform";if(/\b(tauri|electron|wails|desktop)\b/.test(i))return "desktop";if(/\b(vscode-extension|visual studio code extension|jetbrains-plugin|browser-extension)\b/.test(i))return "extension";if(typeof u$1=="string"&&u$1.trim().toLowerCase().startsWith("gateway.")||typeof a=="string"&&a.trim().toLowerCase()==="openrouter")return "gateway";let p=await f.readFile(d.join(e$1,"Cargo.toml"),"utf8").catch(()=>""),g=/^\s*\[workspace\]\s*$/m.test(p)&&!/^\s*\[package\]\s*$/m.test(p),l=await A(d.join(e$1,"package.json"));if(l!==null&&(Array.isArray(l.workspaces)||l.workspaces!==null&&typeof l.workspaces=="object")||g||e(e$1))return "platform";if(/\b(frontend|nextjs|next\.js|react|vue|svelte|vite|angular|astro|remix|nuxt)\b/.test(i))return "frontend";if(/\b(fastapi|nestjs|springboot|spring boot|gofiber|gogin|webapi|django|flask|express|fastify|laravel|rails|phoenix|axum|actix|rocket)\b/.test(i))return "backend";if(l){let m={...l.dependencies??{},...l.devDependencies??{}},D=l.scripts??{},b=Object.values(D).filter(w=>typeof w=="string").join(" ").toLowerCase(),_=l.engines??{},N=Array.isArray(l.categories)?l.categories.filter(w=>typeof w=="string"):[];if(m["@tauri-apps/api"]||m["@tauri-apps/cli"]||await f.pathExists(d.join(e$1,"src-tauri","tauri.conf.json"))||await f.pathExists(d.join(e$1,"src-tauri","tauri.conf.json5"))||m.electron||m["@electron-forge/cli"]||b.includes("electron-forge")||b.includes("electron "))return "desktop";if(typeof _.vscode=="string"||N.some(w=>w.toLowerCase()==="extension packs")||l.publisher&&(l.activationEvents||l.contributes))return "extension";if(m.next||m.react||m.vue||m.svelte||m.vite||m["@angular/core"]||b.includes("next ")||b.includes("vite "))return "frontend";if(l.private===true&&!m.express&&!m["@nestjs/core"])return "library"}return g||await K(e$1)||await f.pathExists(d.join(e$1,"go.work"))||await f.pathExists(d.join(e$1,"go.mod"))&&await I(e$1)?"platform":await M(e$1,y)?"library":await f.pathExists(d.join(e$1,"compose.yaml"))||await f.pathExists(d.join(e$1,"compose.yml"))||await f.pathExists(d.join(e$1,"docker-compose.yml"))||await f.pathExists(d.join(e$1,"docker-compose.yaml"))||await f.pathExists(d.join(e$1,"terraform.tf"))?"infra":"backend"}var B={ci:[".github/workflows",".gitlab-ci.yml",".circleci/config.yml","azure-pipelines.yml","bitbucket-pipelines.yml","cloudbuild.yaml","Jenkinsfile",".buildkite/pipeline.yml","prow"],release:[".changeset",".releaserc",".releaserc.json","release.config.js",".goreleaser.yml",".goreleaser.yaml","RELEASING.md","RELEASE.md","tools/release","scripts/release","docs/release","doc/release","build/release.sh","hack/lib/release.sh"],ownership:[".github/CODEOWNERS",".gitlab/CODEOWNERS","CODEOWNERS","docs/CODEOWNERS","OWNERS","OWNERS_ALIASES","MAINTAINERS"]},J=/(?:^|[-_.])(?:release|publish|publishing|distribution)(?:[-_.]|$)/i,V={ci:/\b(?:prow|buildkite|jenkins|teamcity|travis|external ci|test-infra)\b/i,release:/\b(?:release automation|release engineering|release infrastructure|external release)\b/i,ownership:/\b(?:external ownership|central owners|maintainer team|code owners)\b/i};async function U(e,n){let t=[];for(let o of n)try{await k.promises.access(d.join(e,o),k.constants.F_OK),t.push(o);}catch{}return t}async function Y(e,n){let t=["README.md","CONTRIBUTING.md","DEVELOPMENT.md","docs/devel/README.md"],o=[];for(let r of t)try{let s=d.join(e,r),c=await k.promises.stat(s);if(!c.isFile()||c.size>1024*1024)continue;let u=await k.promises.readFile(s,"utf8");n.test(u)&&o.push(r);}catch{}return o}async function q(e){let n=d.join(e,".github","workflows");try{return (await k.promises.readdir(n,{withFileTypes:true})).filter(o=>o.isFile()&&/\.(?:ya?ml)$/i.test(o.name)&&J.test(o.name)).map(o=>`.github/workflows/${o.name}`).sort()}catch{return []}}function H(e,n){let t$1=e?.[n];return t$1?.mode?{status:t$1.mode==="external"?"external-declared":"repository",provider:t$1.provider?.trim()||null,evidence:[t.workspaceContract],reference:t$1.reference?.trim()||null}:null}async function v(e,n,t){let o=H(n,t);if(o)return o;let r=[...await U(e,B[t]),...t==="release"?await q(e):[]];if(r.length>0)return {status:"repository",provider:null,evidence:r,reference:null};let s=await Y(e,V[t]);return s.length>0?{status:"external-observed",provider:null,evidence:s,reference:null}:{status:"unknown",provider:null,evidence:[],reference:null}}async function ue(e){let[n,t,o]=await Promise.all([v(e.projectPath,e.declaration,"ci"),v(e.projectPath,e.declaration,"release"),v(e.projectPath,e.declaration,"ownership")]);return {schemaVersion:"workspai.project-governance.v1",ci:n,release:t,ownership:o}}export{re as a,oe as b,ue as c};
@@ -1,2 +0,0 @@
1
- import {a as a$2,D as D$1}from'./chunk-O3TVVQ6X.js';import {d}from'./chunk-ROOPODG6.js';import {j,m,i}from'./chunk-LUPKDFQ3.js';import {a as a$1}from'./chunk-GR6442P7.js';import {a as a$3,g,f as f$1,h}from'./chunk-BLEIUQL6.js';import {b}from'./chunk-VN2MKTQO.js';import {a}from'./chunk-XWKGZRHN.js';import {a as a$4}from'./chunk-252EKOR6.js';import {l}from'./chunk-OCGZNSOE.js';import {c}from'./chunk-64XWHDZ3.js';import {t as t$1,u,q as q$1}from'./chunk-VQZ5PI5J.js';import {t,p,s,q}from'./chunk-ODK4LCEL.js';import*as f from'path';import f__default from'path';import k from'fs-extra';import Re from'crypto';var Ae="unknown-run";function de(e){let t=c();return !t||t===Ae?e:{...e,runId:t}}async function ue(e,t){await k.ensureDir(f.dirname(e));let r=`${e}.${process.pid}.${Date.now()}.${Re.randomUUID()}.tmp`;try{await k.writeJSON(r,t,{spaces:2}),await k.move(r,e,{overwrite:true});}finally{await k.remove(r).catch(()=>{});}}function le(e){return q$1(e,"imported-projects.json")}async function I(e){let t=(await Promise.all(t$1(e,"imported-projects.json").map(async r=>await k.pathExists(r)?r:null))).find(r=>typeof r=="string");if(!t)return [];try{let r=await k.readJSON(t);if(!r||typeof r!="object"||r.version!==1||!Array.isArray(r.projects))throw new Error("expected a version 1 registry with a projects array");let o=r.projects,n=o.filter(i=>{if(!i||typeof i!="object")return false;let c=i;return typeof c.name=="string"&&typeof c.path=="string"&&typeof c.stack=="string"&&typeof c.confidence=="string"&&typeof c.importedAt=="string"});if(n.length!==o.length)throw new Error("one or more project entries are invalid");return n}catch(r){throw new Error(`Imported-project registry is invalid: ${t}`,{cause:r})}}async function Xe(e,t){if(t.length===0)return;let r=le(e);await a(`${r}.lock`,async()=>{let o=await I(e),n=new Map;for(let c of o)n.set(c.path,c);for(let c of t)n.set(c.path,c);let i=Array.from(n.values()).sort((c,l)=>c.name.localeCompare(l.name)).map(c=>({...c}));await ue(r,{version:1,updatedAt:new Date().toISOString(),projects:i});},{timeoutMs:3e4,staleMs:6e4,purpose:"imported-projects-registry-upsert"});}async function et(e,t){if(t.length===0)return;let r=le(e);await a(`${r}.lock`,async()=>{let o=await I(e),n=new Set(t.map(c=>f.resolve(c))),i=o.filter(c=>!n.has(f.resolve(c.path)));await ue(r,{version:1,updatedAt:new Date().toISOString(),projects:i});},{timeoutMs:3e4,staleMs:6e4,purpose:"imported-projects-registry-remove"});}var ot="workspace-dependency-graph.v1",me=["code-import","package-dep","event-pub-sub","service-dependsOn","shared-resource"],ge=["inferred","contract","manual"];var v=t.workspaceContract,xe=p.contractVerify,G=s.workspaceContract.schemaVersion,_e=q.contractVerify,D=class extends Error{constructor(r){super(`Workspace contract verification failed: ${r.violations.join("; ")}`);this.verification=r;this.name="WorkspaceContractVerificationError";}verification};function Pe(e){return e.replace(/\\/g,"/")}function z(e){let t=Pe(e).trim();return !t||t.startsWith("/")||t.startsWith("~")||/^[a-zA-Z]:\//.test(t)||t.includes("\0")?false:!t.split("/").filter(Boolean).some(r=>r===".."||r===".")}function fe(e,t){return e.trim().toLowerCase().replace(/[^a-z0-9._-]+/g,"-").replace(/-+/g,"-").replace(/^[-_.]+|[-_.]+$/g,"").slice(0,80)||t}function ye(e){return Array.isArray(e)?e.filter(t=>typeof t=="string"&&t.trim().length>0):[]}function Ge(e){return [...new Set(e.map(t=>t.trim()).filter(t=>t.length>0))].sort((t,r)=>t.localeCompare(r))}function Oe(e){let t=e.contracts;return !t||typeof t!="object"||Array.isArray(t)?[]:ye(t.env)}function Ce(e){let t=(e||"").toLowerCase();return t.includes("vscode-extension")||t.includes("desktop.electron")||t.startsWith("extension.")||t.startsWith("desktop.")&&!t.includes("tauri")||t.includes("agent.microsoft")||t.includes("agent.openai")}function he(e){let r=(Array.isArray(e.ports)?e.ports:[]).map(i=>{if(!i||typeof i!="object"||Array.isArray(i))return null;let c=i,l=Number(c.port);if(!Number.isInteger(l)||l<1||l>65535)return null;let m=c.protocol==="https"||c.protocol==="grpc"||c.protocol==="tcp"||c.protocol==="udp"?c.protocol:"http";return {name:typeof c.name=="string"&&c.name.trim()?c.name:"http",port:l,protocol:m}}).filter(i=>i!==null);if(r.length>0)return r;let o=e.frontend&&typeof e.frontend=="object"&&!Array.isArray(e.frontend)?e.frontend:void 0,n=Number(e.port??o?.default_port);return Number.isInteger(n)&&n>=1&&n<=65535?[{name:"http",port:n,protocol:"http"}]:[]}async function Ne(e){let t=f__default.join(e,"Dockerfile");if(!await k.pathExists(t))return [];try{let r=await k.readFile(t,"utf8"),o=new Map;for(let n of r.matchAll(/^\s*EXPOSE\s+(.+)$/gim))for(let i of n[1].split(/\s+/)){let c=i.match(/^(\d{1,5})(?:\/(tcp|udp))?$/i),l=Number(c?.[1]);if(!c||!Number.isInteger(l)||l<1||l>65535)continue;let m=c[2]?.toLowerCase();o.set(l,{name:"http",port:l,protocol:m==="udp"?"udp":"http"});}return [...o.values()].sort((n,i)=>n.port-i.port)}catch{return []}}async function T(e){for(let t of e)if(await k.pathExists(t))return t;return null}async function Ie(e){for(let r of t$1(e,"workspace.json"))try{let o=await k.readJson(r);return {name:typeof o.workspace_name=="string"&&o.workspace_name.trim()||typeof o.name=="string"&&o.name.trim()||f__default.basename(e),profile:typeof o.profile=="string"?o.profile:void 0}}catch{}let t=await a$4(e);return t?.name?.trim()?{name:t.name.trim()}:{name:f__default.basename(e)}}async function De(e){let t=[],r=[e],o=new Set,n=new Set([".git",".workspai",".rapidkit","node_modules",".venv","venv","dist","build","target",".next",".turbo",".cache"]);for(;r.length>0;){let i=r.shift();if(!i||o.has(i))continue;o.add(i);let c=await T(u(i,"project.json")),l=await T(u(i,"context.json"));if(c||l){t.push(c??l??"");continue}let m;try{m=await k.readdir(i,{withFileTypes:true});}catch{continue}for(let d of m)!d.isDirectory()||n.has(d.name)||a$1(d.name)||r.push(f__default.join(i,d.name));}return t.sort()}function Te(e){let t=(e||"").toLowerCase();if(t.includes("fastapi"))return "fastapi";if(t.includes("nestjs"))return "nestjs";if(t.includes("springboot"))return "springboot";if(t.includes("gofiber"))return "fiber";if(t.includes("gogin"))return "gin"}function $e(e,t){let r=(e||"").toLowerCase(),o=(t||"").toLowerCase();return Ce(e)?null:r.includes("fastapi")?8e3:r.includes("nestjs")?3e3:r.includes("springboot")?8080:r.includes("gofiber")?3e3:r.includes("gogin")?8080:r.startsWith("adopted.")?null:o==="node"?3e3:o==="python"?8e3:o==="java"||o==="go"?8080:null}function B(e,t){let r=e;for(;t.has(r)&&r<65535;)r+=1;return r}function U(e,t,r){let o=e!==void 0&&e.source===void 0,n=$e(t.kit,t.runtime),i=e?.ports||[],c=t.ports||[],l=Ce(t.kit),m=t.source==="adopted-local"&&e?.source!==void 0,d=t.source!==void 0&&e?.source!==void 0,p=(l&&c.length===0?[]:m?c.length>0?c:n?[{name:"http",port:B(n,r),protocol:"http"}]:[]:i.length>0?i:c.length>0?c:n?[{name:"http",port:B(n,r),protocol:"http"}]:[]).map(P=>({...P,port:B(P.port,r)}));for(let P of p)r.add(P.port);let g={...t,...e,slug:e?.slug||t.slug,relativePath:o&&e?.relativePath&&z(e.relativePath)?e.relativePath:t.relativePath,source:o&&e?.source||t.source,relationship:o&&e?.relationship||t.relationship,externalPath:o&&e?.externalPath||t.externalPath,runtime:d?t.runtime:e?.runtime||t.runtime,framework:d?t.framework:e?.framework||t.framework,kit:d?t.kit:e?.kit||t.kit,modules:e?.modules?.length?e.modules:t.modules,ports:p,contracts:{owns:e?.contracts?.owns||[],apis:e?.contracts?.apis||[],publishes:e?.contracts?.publishes||[],consumes:e?.contracts?.consumes||[],dependsOn:e?.contracts?.dependsOn||[],env:Ge([...e?.contracts?.env??[],...t.contracts.env??[]])}},h=JSON.stringify(e||null)!==JSON.stringify(g);return {project:g,changed:h}}async function Ee(e){let t=f__default.resolve(e.workspacePath),r=await Ie(t),o=await De(t),n=await I(t),i$1=new Map(n.map(s=>[f__default.resolve(s.path),s])),c=[];for(let s of n){let p=f__default.resolve(s.path),g=await T(u(p,"project.json"))??await T(u(p,"context.json"));!g||o.some(h=>f__default.resolve(h)===f__default.resolve(g))||c.push({projectJsonPath:g,registryEntry:s});}let l=[],m$1=[...o.map(s=>({projectJsonPath:s,registryEntry:i$1.get(f__default.resolve(f__default.dirname(f__default.dirname(s))))})),...c];for(let{projectJsonPath:s,registryEntry:p}of m$1){let g=f__default.dirname(f__default.dirname(s)),h=Pe(f__default.relative(t,g)),P=p!==void 0&&!z(h),C=fe(p?.name||f__default.basename(g),f__default.basename(g)),b=P?`external/${C}`:h||C,w=await k.readJson(s),a=typeof w.kit_name=="string"&&w.kit_name||typeof w.kit=="string"&&w.kit||void 0,E=j(w)?m(g,w):void 0,j$1=E!==void 0&&E.key!=="unknown",S=i({runtime:typeof w.runtime=="string"?w.runtime:void 0,framework:typeof w.framework=="string"?w.framework:void 0,kitName:a}),y=a$2(a),$=j$1?E.runtime:S.runtime!=="unknown"?S.runtime:y?.runtime,K=j$1?E.key:typeof w.framework=="string"&&w.framework||(S.key!=="unknown"?S.key:void 0)||y?.framework||Te(a),We=p?.relationship==="adopted"?"adopted":"imported",Se=j$1?`${We}.${E.key}`:a;l.push({slug:p?.name||b||f__default.basename(g),relativePath:b,source:p?.source??"workspace",relationship:p?.relationship,externalPath:P?g:void 0,runtime:$,framework:K,kit:Se,modules:ye(w.modules),ports:he(w).length>0?he(w):await Ne(g),contracts:{owns:[],apis:[],publishes:[],consumes:[],dependsOn:[],env:Oe(w)}});}let d=new Map;for(let s of l){let p=fe(s.slug,s.relativePath),g=d.get(p);(!g||g.source!=="workspace"&&s.source==="workspace")&&d.set(p,s);}return {schemaVersion:G,kind:"rapidkit.workspace.contract",generatedAt:(e.now??new Date).toISOString(),workspace:r,projects:[...d.values()]}}async function Et(e){let t=f__default.resolve(e.outputPath||a$3(e.workspacePath,v));if(await k.pathExists(t)&&e.force!==true)throw new Error(`Workspace contract already exists: ${t}. Use --force to overwrite.`);let r=await Ee({workspacePath:e.workspacePath,now:e.now}),o=new Set,n={...r,projects:r.projects.map(c=>U(void 0,c,o).project)},i=await be({workspacePath:e.workspacePath,contractPath:t,contract:n});if(e.strict&&i.status==="failed")throw new D(i);return await ve({workspacePath:e.workspacePath,contractPath:t,contract:n,now:e.now}),{contractPath:t,contract:n}}async function vt(e){let t=f__default.resolve(e.workspacePath),r=a$3(t,v),o=await g(t,v)??r,n=await Ee({workspacePath:t,now:e.now}),i=await k.pathExists(o)?await k.readJson(o):null,c=new Map((i?.projects||[]).map(h=>[h.slug,h])),l=new Set,m=[],d=[],s=[];for(let h of n.projects){let P=c.get(h.slug),C=U(P,h,l);P?C.changed&&d.push(h.slug):m.push(h.slug),s.push(C.project),c.delete(h.slug);}for(let h of c.values()){if(h.source)continue;let P=U(h,h,l);s.push(P.project);}let p={schemaVersion:G,kind:"rapidkit.workspace.contract",generatedAt:(e.now??new Date).toISOString(),workspace:{...i?.workspace||{},...n.workspace,name:n.workspace.name||i?.workspace?.name||f__default.basename(t)},projects:s.sort((h,P)=>h.slug.localeCompare(P.slug))},g$1=await be({workspacePath:t,contractPath:r,contract:p});if(e.strict&&g$1.status==="failed")throw new D(g$1);return await ve({workspacePath:t,contractPath:r,contract:p,now:e.now}),{contractPath:r,contract:p,addedProjects:m,updatedProjects:d,verification:g$1}}async function ke(e){return await k.pathExists(e)?{exists:true,contents:await k.readFile(e)}:{exists:false}}async function we(e,t){if(!t.exists){await k.remove(e);return}await k.outputFile(e,t.contents);}async function ve(e){let{buildWorkspaceRegistrySummary:t,WORKSPACE_REGISTRY_SUMMARY_RELATIVE_PATH:r}=await import('./workspace-registry-summary-M4WMFDQ4.js'),o=await t(e.workspacePath,{now:e.now,contract:e.contract}),n=a$3(e.workspacePath,r),i=c=>{if(!c||typeof c!="object"||Array.isArray(c))return JSON.stringify(c);let{generatedAt:l,...m}=c;return JSON.stringify(m)};if(await k.pathExists(e.contractPath)&&await k.pathExists(n)){let[c,l]=await Promise.all([k.readJson(e.contractPath),k.readJson(n)]);if(i(c)===i(e.contract)&&i(l)===i(o))return}b(v,e.contract),b(r,o),await f$1(e.workspacePath,v,async()=>{let[c,l]=await Promise.all([ke(e.contractPath),ke(n)]);try{if(e.contractPath===a$3(e.workspacePath,v)?await h(e.workspacePath,v,e.contract):(await k.ensureDir(f__default.dirname(e.contractPath)),await k.writeJson(e.contractPath,e.contract,{spaces:2})),process.env.WORKSPAI_TEST_FAIL_WORKSPACE_REGISTRY_PUBLISH==="1")throw new Error("Injected workspace registry summary publication failure.");await h(e.workspacePath,r,o);}catch(m){let s=(await Promise.allSettled([we(e.contractPath,c),we(n,l)])).filter(p=>p.status==="rejected");throw s.length>0?new AggregateError([m,...s.map(p=>p.reason)],"Workspace contract publication failed and rollback was incomplete."):m}});}async function je(e){let t=e.contractPath??(await g(e.workspacePath,v)||a$3(e.workspacePath,v)),r=await k.readJson(t);return {contractPath:t,contract:r}}var Ke={metadata:[".workspai/project.json",".workspai/context.json",".rapidkit/project.json",".rapidkit/context.json"],manifests:["package.json","package-lock.json","pnpm-lock.yaml","yarn.lock","pyproject.toml","poetry.lock","requirements.txt","go.mod","go.sum","pom.xml","build.gradle","build.gradle.kts","Cargo.toml","Gemfile","composer.json"],entrypoints:["src/main.ts","src/index.ts","src/app.ts","src/main.js","src/index.js","main.py","app/main.py","manage.py","main.go","cmd/main.go","Program.cs"],apiSpecifications:["openapi.yaml","openapi.yml","openapi.json","swagger.yaml","swagger.yml","swagger.json"],infrastructure:["Dockerfile","docker-compose.yml","docker-compose.yaml","compose.yml","compose.yaml","k8s","kubernetes","terraform"],documentation:["README.md","ARCHITECTURE.md","CONTRIBUTING.md","docs"]};function Ve(e,t){return d(e,t.relativePath,{...t.externalPath?{absolutePath:t.externalPath}:{}})}async function Me(e){let t={metadata:[],manifests:[],entrypoints:[],apiSpecifications:[],infrastructure:[],documentation:[]};for(let[r,o]of Object.entries(Ke))for(let n of o)await k.pathExists(f__default.join(e,n))&&t[r].push(n);try{let r=await k.readdir(e,{withFileTypes:true});for(let o of r)o.isFile()&&(o.name.endsWith(".csproj")||o.name.endsWith(".sln"))&&t.manifests.push(o.name),o.isFile()&&o.name.endsWith(".tf")&&t.infrastructure.push(o.name);}catch{}for(let r of Object.values(t))r.sort((o,n)=>o.localeCompare(n));return t}function _(e){return !e||typeof e!="object"||Array.isArray(e)?[]:Object.keys(e).sort((t,r)=>t.localeCompare(r))}async function Fe(e){try{let t=await k.readJson(f__default.join(e,"package.json")),r={runtime:_(t.dependencies),development:_(t.devDependencies),peer:_(t.peerDependencies),optional:_(t.optionalDependencies)};return {...typeof t.name=="string"?{name:t.name}:{},...typeof t.version=="string"?{version:t.version}:{},...typeof t.private=="boolean"?{private:t.private}:{},scripts:_(t.scripts),dependencies:r,dependencyCount:new Set(Object.values(r).flat()).size}}catch{return}}async function Le(e){for(let t of [".env.example",".env.sample",".env.template"])try{return (await k.readFile(f__default.join(e,t),"utf8")).split(/\r?\n/).map(o=>o.trim()).filter(o=>o.length>0&&!o.startsWith("#")&&o.includes("=")).map(o=>o.slice(0,o.indexOf("=")).trim()).filter(o=>/^[A-Za-z_][A-Za-z0-9_]*$/.test(o)).sort((o,n)=>o.localeCompare(n))}catch{}return []}function He(e,t){try{let r=D$1(e);if(r.engine!=="unknown")return r;let o=k.pathExistsSync(f__default.join(e,"package.json"))?"npm":k.pathExistsSync(f__default.join(e,"pyproject.toml"))?"python":k.pathExistsSync(f__default.join(e,"requirements.txt"))?"pip":"unknown";return {...r,engine:o,runtime:t.runtime??r.runtime,framework:t.framework??r.framework,frameworkDisplayName:t.framework??r.frameworkDisplayName}}catch{return {schemaVersion:1,scope:"project",projectRoot:null,engine:"unknown",runtime:"unknown",runtimeCandidates:["unknown"],compositeRuntime:false,lifecycleCoverage:"complete",framework:"unknown",frameworkDisplayName:"Unknown",frameworkConfidence:"low",frameworkSupportTier:"observed",runtimeSupportTier:"observed",runtimeDoctorSupport:"observed",moduleSupport:false,fleetStages:[],localOnlyCommands:[],commandMap:{},supportedCommands:[],unsupportedCommands:[],globalCommands:[]}}}function Je(e,t,r){let o=e.projects.map(n=>({id:n.slug,path:n.relativePath,runtime:n.runtime,framework:n.framework}));return {schemaVersion:"workspace-dependency-graph.v1",generatedAt:t,nodes:o,edges:[],stats:{nodeCount:o.length,edgeCount:0,inferredEdges:0,contractEdges:0,manualEdges:0,authoritativeEdges:0,lowConfidenceEdges:0,orphanCount:o.length,connectedNodeCount:0,density:0,edgeCoverageRatio:o.length===0?1:0,evidenceCoverageRatio:1,hotspotCount:0,hasCycle:false},diagnostics:[{code:"graph.enrichment.failed",severity:"warning",message:r,recommendation:"Review project manifests and graph overrides, then rerun workspace contract graph."}]}}async function jt(e){let{contractPath:t,contract:r}=await je(e),o=e.now??new Date,n=o.toISOString(),{buildWorkspaceModel:i,workspaceModelProjectTopology:c}=await import('./workspace-model-POCPMNRT.js'),{hashWorkspaceModel:l}=await import('./workspace-model-hash-ZXYPIGCW.js'),m=await i({workspacePath:e.workspacePath,includeEvidence:false,now:o}),d=c(m)??Je(r,n,"The canonical Workspace Model did not provide a project dependency topology."),s=new Map(d.nodes.map(a=>[a.id,a.operationalProfile])),{buildWorkspaceKnowledgeGraph:p$1}=await import('./workspace-knowledge-graph-CPBKNXQI.js'),g=await p$1({workspacePath:e.workspacePath,workspace:{name:m.workspace.name,...m.workspace.profile?{profile:m.workspace.profile}:{}},contract:r,projectTopology:d,now:o,projects:m.projects.map(a=>({id:a.name,path:a.path,...a.absolutePath?{absolutePath:a.absolutePath}:{},runtime:a.runtime,runtimeCandidates:a.runtimeCandidates,framework:a.framework,...a.kit?{kit:a.kit}:{}})),source:{kind:"workspace-model",artifact:p.model,hashAlgorithm:"sha256",hash:l(m)}}),h=await Promise.all(r.projects.map(async a=>{let u=Ve(e.workspacePath,a),[E,j,S]=await Promise.all([Me(u),Fe(u),Le(u)]),y=He(u,a);return {id:a.slug,label:a.slug,relativePath:a.relativePath,source:a.source,relationship:a.relationship,externalPath:a.externalPath,runtime:a.runtime??y.runtime,framework:a.framework??y.framework,kit:a.kit,modules:a.modules,ports:a.ports,apis:a.contracts.apis,owns:a.contracts.owns,env:[...new Set([...a.contracts.env,...S])].sort(($,K)=>$.localeCompare(K)),contracts:{owns:[...a.contracts.owns],apis:[...a.contracts.apis],publishes:[...a.contracts.publishes],consumes:[...a.contracts.consumes],dependsOn:[...a.contracts.dependsOn],env:[...a.contracts.env]},capabilities:{engine:y.engine,supportTier:y.frameworkSupportTier,runtimeSupportTier:y.runtimeSupportTier,doctorSupport:y.runtimeDoctorSupport,moduleSupport:y.moduleSupport,fleetStages:[...y.fleetStages],localOnlyCommands:[...y.localOnlyCommands],supportedCommands:[...y.supportedCommands]},files:E,...j?{package:j}:{},...s.get(a.slug)?{operationalProfile:s.get(a.slug)}:{}}})),P=new Set(h.map(a=>a.id)),C=new Map,b=[];for(let a of r.projects){for(let u of a.contracts.dependsOn||[])P.has(u)&&b.push({from:u,to:a.slug,type:"dependency",label:"dependsOn"});for(let u of a.contracts.publishes||[])C.has(u)||C.set(u,new Set),C.get(u)?.add(a.slug);}for(let a of r.projects)for(let u of a.contracts.consumes||[]){let E=C.get(u);if(E)for(let j of E)j!==a.slug&&b.push({from:j,to:a.slug,type:"event",label:u});}let w={schemaVersion:1,kind:"rapidkit.workspace.contract.graph",workspace:r.workspace,generatedAt:n,nodes:h.sort((a,u)=>a.id.localeCompare(u.id)),edges:b.sort((a,u)=>`${a.from}:${a.to}:${a.type}:${a.label}`.localeCompare(`${u.from}:${u.to}:${u.type}:${u.label}`)),dependencyGraph:d,knowledgeGraph:g,semantics:{legacyEdges:"producer-to-consumer",dependencyGraphEdges:"consumer-to-dependency"},summary:{projectCount:h.length,dependencyEdges:b.filter(a=>a.type==="dependency").length,eventEdges:b.filter(a=>a.type==="event").length,portCount:h.reduce((a,u)=>a+u.ports.length,0),apiCount:h.reduce((a,u)=>a+u.apis.length,0),relationshipEdges:d.stats.edgeCount,inferredEdges:d.stats.inferredEdges,authoritativeEdges:d.stats.authoritativeEdges,orphanProjects:d.stats.orphanCount,hotspotProjects:d.stats.hotspotCount,evidenceCoverageRatio:d.stats.evidenceCoverageRatio,edgeCoverageRatio:d.stats.edgeCoverageRatio,connectedProjects:d.stats.connectedNodeCount,lowConfidenceEdges:d.stats.lowConfidenceEdges,hasCycle:d.stats.hasCycle,manifestCount:h.reduce((a,u)=>a+u.files.manifests.length,0),entrypointCount:h.reduce((a,u)=>a+u.files.entrypoints.length,0),diagnostics:d.diagnostics?.length??0,relationshipKinds:Object.fromEntries(me.map(a=>[a,d.edges.filter(u=>u.kind===a).length])),relationshipSources:Object.fromEntries(ge.map(a=>[a,d.edges.filter(u=>u.source===a).length])),entityCount:g.quality.entityCount,knowledgeRelations:g.quality.relationCount,proofCount:g.quality.proofCount,providerCount:g.providers.length,knowledgeUnknowns:g.quality.unknownCount}};return {contractPath:t,graph:w}}async function be(e){let t=e.contract?{contractPath:e.contractPath??a$3(e.workspacePath,v),contract:e.contract}:await je(e),{contractPath:r,contract:o}=t,n=[],i=[];o.kind!=="rapidkit.workspace.contract"&&n.push("Contract kind must be rapidkit.workspace.contract."),o.schemaVersion!==G&&n.push(`Contract schemaVersion must be ${G}.`),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,l$1=new Map;for(let s of o.projects||[]){if(!s.slug){n.push("Every project must declare slug.");continue}c.has(s.slug)&&n.push(`Duplicate project slug: ${s.slug}.`),c.add(s.slug),s.relativePath?z(s.relativePath)||n.push(`Project ${s.slug} declares unsafe relativePath: ${s.relativePath}.`):n.push(`Project ${s.slug} must declare relativePath.`),s.externalPath&&(s.relationship==="adopted"||s.source==="adopted-local"||s.source==="local-folder"||s.source==="git-url"||n.push(`Project ${s.slug} declares externalPath without imported/adopted provenance.`),f__default.isAbsolute(s.externalPath)||n.push(`Project ${s.slug} declares non-absolute externalPath.`));for(let p of s.ports||[]){(!Number.isInteger(p.port)||p.port<1||p.port>65535)&&n.push(`Project ${s.slug} declares invalid port: ${p.port}.`);let g=l$1.get(p.port);g&&n.push(`Port ${p.port} is claimed by both ${g} and ${s.slug}.`),l$1.set(p.port,s.slug);}for(let p of s.contracts?.apis||[])(!p.name?.trim()||!p.basePath?.startsWith("/"))&&n.push(`Project ${s.slug} declares invalid API contract.`);for(let p of [...s.contracts?.publishes||[],...s.contracts?.consumes||[]])p.trim()||n.push(`Project ${s.slug} declares an empty event contract.`);for(let p of s.contracts?.env||[])/^[A-Z_][A-Z0-9_]*$/.test(p)||n.push(`Project ${s.slug} declares invalid env contract: ${p}.`);for(let p of s.contracts?.dependsOn||[])c.has(p);}for(let s of o.projects||[])for(let p of s.contracts?.dependsOn||[])c.has(p)||n.push(`Project ${s.slug} depends on unknown project: ${p}.`);i.push({id:"schema",status:o.kind==="rapidkit.workspace.contract"&&o.schemaVersion===G?"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(s=>s.toLowerCase().includes("port"))?"failed":"passed",message:"Project port declarations are valid and collision-free."}),i.push({id:"dependencies",status:n.some(s=>s.includes("depends on unknown project"))?"failed":"passed",message:"Project dependencies point to known project slugs."}),i.push({id:"contracts",status:n.some(s=>s.includes("unsafe relativePath")||s.includes("invalid API contract")||s.includes("event contract")||s.includes("env contract"))?"failed":"passed",message:"Project path, API, event, and env contracts are valid."});let m=await l(e.workspacePath);if(m.moduleCount>0){for(let s of m.issues)n.push(`${f__default.basename(s.projectRoot)}: ${s.message} (slug=${s.slug})`);i.push({id:"module-paths",status:m.status,message:m.status==="passed"?`All ${m.moduleCount} registered module(s) resolve under canonical paths.`:`${m.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 bt(e){let t=f__default.resolve(e.workspacePath),r={schemaVersion:_e,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 h(t,xe,de(r))}
2
- export{I as a,Xe as b,et as c,de as d,ot as e,me as f,v as g,xe as h,G as i,_e as j,D as k,De as l,Ee as m,Et as n,vt as o,je as p,jt as q,be as r,bt as s};
@@ -1,2 +0,0 @@
1
- import {b as b$1}from'./chunk-B6FJ6RG6.js';import {O as O$1,N,k as k$1,q as q$1,G,I,P}from'./chunk-UNEK3VVR.js';import {c}from'./chunk-O3TVVQ6X.js';import {e,f as f$1}from'./chunk-EFHSRPW7.js';import {b}from'./chunk-UJXE4UAX.js';import {m,l}from'./chunk-VQZ5PI5J.js';import {promises}from'fs';import c$1 from'path';import L,{homedir}from'os';import {pathToFileURL}from'url';import p from'process';import ie from'fs-extra';var y={schemaVersion:"workspai.model-gateway-qualification.v1",workspaiReleaseAuthority:"source-ready",attach:"unsupported",adapters:[{adapterId:"openrouter-typescript",status:"source-ready",platforms:[]},{adapterId:"openrouter-python",status:"source-ready",platforms:[]}]};var R=["ubuntu-latest","macos-latest","windows-latest"];function B(e){if(!e||typeof e!="object"||Array.isArray(e))throw new Error("Model gateway qualification document must be an object.");let t=e;if(!Array.isArray(t.adapters)||t.adapters.length===0)throw new Error("Model gateway qualification document contains no adapters.");let o=new Set;for(let a of t.adapters){if(!a||typeof a.adapterId!="string")throw new Error("Model gateway qualification adapter is missing adapterId.");if(o.has(a.adapterId))throw new Error(`Duplicate model gateway qualification adapter: ${a.adapterId}`);o.add(a.adapterId);let n=O$1(a.adapterId);if(!n)throw new Error(`Qualification adapter ${a.adapterId} is not in the version baseline.`);if(a.status!=="source-ready"&&a.status!=="qualified")throw new Error(`Invalid qualification status for ${a.adapterId}.`);if(!Array.isArray(a.platforms))throw new Error(`Qualification platforms missing for ${a.adapterId}.`);if(a.status==="source-ready"){if(a.platforms.length!==0)throw new Error(`Source-ready adapter ${a.adapterId} must not record platform qualification.`);continue}let s=new Set;for(let r of a.platforms){if(!r||!R.includes(r.os)||r.result!=="pass"||r.skippedRequiredStage!==false||r.sdkVersion!==n.sdkVersion)throw new Error(`Qualified adapter ${a.adapterId} is missing a valid platform record bound to ${n.sdkVersion}.`);if(s.has(r.os))throw new Error(`Duplicate platform ${r.os} for ${a.adapterId}.`);s.add(r.os);}for(let r of R)if(!s.has(r))throw new Error(`Qualified adapter ${a.adapterId} is missing ${r} evidence.`)}for(let a of N)if(!o.has(a.adapterId))throw new Error(`Baseline adapter ${a.adapterId} has no qualification record.`);let i=t.adapters.every(a=>a.status==="qualified");if(i)throw new Error("All adapters are qualified; release authority must match.")}B(y);var f=y,W=Object.freeze({schemaVersion:f.schemaVersion,workspaiReleaseAuthority:f.workspaiReleaseAuthority,attach:f.attach,adapters:Object.freeze(f.adapters.map(e=>Object.freeze({...e,platforms:Object.freeze(e.platforms.map(t=>Object.freeze(t)))})))}),z=W.workspaiReleaseAuthority;function K(e){return `${e} \xB7 ${z}`}var w=["backend","frontend","desktop","agent","gateway","extension","gaming"],J=[{id:"backend",label:"Backend",hint:"APIs and services"},{id:"frontend",label:"Frontend",hint:"Web applications"},{id:"desktop",label:"Desktop",hint:"Native desktop applications"},{id:"agent",label:"AI Agent",hint:"Governed agent runtimes"},{id:"gateway",label:"AI Gateway",hint:"Unified model access and routing"},{id:"extension",label:"Extension",hint:"Editor and platform extensions"},{id:"gaming",label:"Gaming",hint:"Game runtimes and tooling"}];function X(e){let o=e.label.indexOf(" \u2014 ");return o>=0?e.label.slice(o+3).trim():e.label.trim()}function Z(e){return w.includes(e.category)?e.category:null}function T(e){let t=c().flatMap(r=>{let l=Z(r);return l?[{value:r.id,label:`${D(l)} \xB7 ${X(r)}`,hint:`${r.runtime} \xB7 tested baseline`,name:r.label,category:l}]:[]}),o=k$1().map(r=>({value:r.kitId,label:`Frontend \xB7 ${r.displayName}`,hint:"official \xB7 latest stable",name:`${r.displayName} \u2014 ${r.framework}`,category:"frontend"})),i=q$1().map(r=>({value:r.kitId,label:`${D(r.category)} \xB7 ${r.displayName}`,hint:`${r.runtimeCandidates.join(" + ")} \xB7 official latest stable`,name:`${r.displayName} \u2014 ${r.category}`,category:r.category})),a=G().map(r=>({value:r.id,label:`AI Agent \xB7 ${r.label}`,hint:`${r.runtime} \xB7 ${I(r)?"release-admitted baseline":"published baseline"}`,name:r.label,category:"agent"})),n=P().map(r=>({value:r.id,label:`AI Gateway \xB7 ${r.label}`,hint:K(r.runtime),name:r.label,category:"gateway"})),s=[...t,...o,...i,...a,...n].filter(r=>!e||r.category===e).sort((r,l)=>{let Q=w.indexOf(r.category),V=w.indexOf(l.category);return Q-V||(r.label??"").localeCompare(l.label??"")});return O(s),s}function Ae(){let e=new Set(T().map(t=>t.category));return J.filter(t=>e.has(t.id)).map(t=>({value:t.id,label:t.label,hint:t.hint}))}function D(e){return e.charAt(0).toUpperCase()+e.slice(1)}function O(e){let t=new Set,o=new Set;for(let i of e){let a=i.label??i.name??String(i.value),n=String(i.value);if(t.has(a))throw new Error(`Duplicate kit picker label: ${a}`);if(o.has(n))throw new Error(`Duplicate kit picker value: ${n}`);t.add(a),o.add(n);}}var te=".workspairc.json",oe=".rapidkitrc.json",re=["workspai.config.js","workspai.config.mjs","workspai.config.cjs","rapidkit.config.js","rapidkit.config.mjs","rapidkit.config.cjs"],ae=["workspai.config.json","rapidkit.config.json"];function F(e){return typeof e=="object"&&e!==null&&"code"in e&&e.code==="ENOENT"}function k(e,t){let o=t instanceof Error?t.message:String(t),i=e.endsWith(".js")&&/module is not defined in ES module scope/i.test(o)?' CommonJS syntax in a .js config is not valid when the project package uses "type": "module"; rename the file to .cjs or use export default.':"";return `Failed to load Workspai config at ${e}.${i} Cause: ${o}`}async function et(){for(let e$1 of [c$1.join(L.homedir(),te),c$1.join(L.homedir(),oe)])try{let t=await promises.readFile(e$1,"utf-8"),o=JSON.parse(t);return e.debug(`Loaded config from ${e$1}`),o}catch{}return e.debug("No user config found, using defaults"),{}}async function tt(e$1=process.cwd(),t={}){let o=e$1,i=c$1.parse(o).root;for(;o!==i;){for(let a of ae){let n=c$1.join(o,a);try{let s=await promises.readFile(n,"utf-8"),r=JSON.parse(s);if(!r||typeof r!="object"||Array.isArray(r))throw new Error("configuration root must be a JSON object");return e.debug(`Loaded data-only Workspai config from ${a}`),r}catch(s){if(F(s))continue;throw new Error(k(n,s))}}for(let a of re){let n=c$1.join(o,a);try{await promises.access(n);}catch(s){if(F(s))continue;throw new Error(k(n,s))}if(e.debug(`Found config file: ${n}`),!t.trustExecutableConfig)throw new Error(`Refusing to execute Workspai config at ${n} without explicit trust. Use a data-only workspai.config.json file, pass --trust-config, or set WORKSPAI_TRUST_CONFIG=1.`);try{let r=await import(pathToFileURL(n).href),l=r.default||r;return e.debug(`Loaded Workspai config from ${a}`),l}catch(s){throw new Error(k(n,s))}}o=c$1.dirname(o);}return e.debug("No Workspai config file found, using defaults"),{}}function ot(e,t,o){return {author:o.author||t.workspace?.defaultAuthor||e.author,pythonVersion:o.pythonVersion||t.workspace?.pythonVersion||e.pythonVersion,defaultInstallMethod:o.defaultInstallMethod||t.workspace?.installMethod||e.defaultInstallMethod,defaultKit:o.defaultKit||t.projects?.defaultKit||e.defaultKit,skipGit:o.skipGit??t.projects?.skipGit??e.skipGit,license:o.license||e.license,testRapidKitPath:o.testRapidKitPath||e.testRapidKitPath}}function rt(e){return f$1("DEV_PATH")||e.testRapidKitPath||void 0}var C=class extends Error{constructor(o,i){super(["Workspai workspaces cannot be nested.",`Target: ${o}`,`Containing workspace: ${i}`,"Choose Managed home or pass --output <path> with a location outside the current workspace."].join(`
2
- `));this.targetPath=o;this.containingWorkspacePath=i;this.name="NestedWorkspaceCreationError";}targetPath;containingWorkspacePath;code="WORKSPACE_NESTING_NOT_SUPPORTED"};async function ne(e){try{return !!await ie.stat(e)}catch{return false}}function se(e,t){let o=e.indexOf(t);if(o>=0&&o+1<e.length)return e[o+1];let i=e.find(a=>a.startsWith(`${t}=`));if(i)return i.slice(t.length+1)}function ce(e){return e.includes("--here")}async function U(e){let t=c$1.resolve(e);for(;;){let o=[c$1.join(t,".workspai-workspace"),c$1.join(t,".rapidkit-workspace"),c$1.join(t,".workspai","workspace.json"),c$1.join(t,".rapidkit","workspace.json")];if((await Promise.all(o.map(ne))).some(Boolean))return t;let i=c$1.dirname(t);if(i===t)return;t=i;}}async function ft(e){let t=c$1.resolve(e),o=await U(c$1.dirname(t));if(o)throw new C(t,o)}async function le(e,t=homedir()){let i=[{value:"managed",label:"Managed home",hint:l(t)}];return await U(e)||i.push({value:"here",label:"Current directory",hint:e}),i}function q(e,t=p.cwd()){if(ce(e))return c$1.resolve(t);let o=se(e,"--output");if(o)return c$1.resolve(o)}function gt(e,t=p.cwd()){let o=c$1.resolve(e),i=c$1.resolve(t),a=c$1.relative(i,o);return a.length>0&&!a.startsWith("..")&&!c$1.isAbsolute(a)?`cd ${a}`:`cd ${o}`}function mt(e,t={}){let o=t.argv??[],i=t.outputParent??q(o,p.cwd());return m(e.trim(),{homeDir:t.homeDir,outputDir:i})}function ht(e,t,o={}){return e?c$1.resolve(e)===c$1.resolve(t)?true:o.outputParent===void 0:false}async function yt(e,t={}){let o=t.cwd??p.cwd(),i=t.homeDir??homedir(),a=q(e,o);if(a!==void 0)return a;let n=t.hasYes??(e.includes("--yes")||e.includes("-y"));if(!(t.interactive??(!n&&!!p.stdin.isTTY&&!b())))return;let r=await le(o,i);if(r.length===1)return;let{location:l}=await b$1([{type:"rawlist",name:"location",message:"Where should the workspace be created?",choices:r,default:0}]);if(l==="here")return c$1.resolve(o)}export{T as a,Ae as b,et as c,tt as d,ot as e,rt as f,ft as g,gt as h,mt as i,ht as j,yt as k};
@@ -1 +0,0 @@
1
- import {H,Q,k,q as q$1,R,W}from'./chunk-UNEK3VVR.js';import {b as b$2,c as c$2,a as a$3}from'./chunk-5KXOV7W4.js';import {a as a$2}from'./chunk-NMXGSVMD.js';import {a as a$6}from'./chunk-HTYMXMQM.js';import {d as d$1,a as a$1,p as p$1,g as g$2,f as f$1,e}from'./chunk-IHWS3ALP.js';import {c,b as b$1,j as j$2,q as q$3,D,f}from'./chunk-O3TVVQ6X.js';import {d,b as b$3}from'./chunk-ROOPODG6.js';import {j as j$3,m,l}from'./chunk-LUPKDFQ3.js';import {a as a$5}from'./chunk-GR6442P7.js';import {j as j$1,g as g$1,a as a$4,h}from'./chunk-BLEIUQL6.js';import {a}from'./chunk-252EKOR6.js';import {d as d$2,c as c$1}from'./chunk-EWZZUQBR.js';import {t}from'./chunk-VQZ5PI5J.js';import {q as q$2,p,t as t$1,s}from'./chunk-ODK4LCEL.js';import g from'path';import C from'fs-extra';import $t from'crypto';import {execFile}from'child_process';import {promisify}from'util';import {createRequire}from'module';var Tt=new Set([...c().map(e=>e.id),...H().map(e=>e.id),...Q().flatMap(e=>[e.id,...e.aliases])]),Nt=[...k().map(e=>({id:e.kitId,aliases:[...e.aliases],ecosystem:e.framework,plannerFramework:e.id,runtime:"node",runtimeCandidates:["node"],workspacePythonEngine:"none",status:"available",canExecuteCreate:true,versionPolicy:e.versionPolicy,officialCommands:[e.commandDisplay("<name>",{skipGit:false,skipInstall:false})],adoptAfterCreate:true,...e.minNodeVersion?{runtimeRequirements:{node:`>=${e.minNodeVersion}`}}:e.minNodeMajor?{runtimeRequirements:{node:`>=${e.minNodeMajor}`}}:{}})),...q$1().map(e=>({id:e.kitId,aliases:[...e.aliases],ecosystem:e.framework,plannerFramework:e.framework,runtime:e.runtime,runtimeCandidates:[...e.runtimeCandidates],workspacePythonEngine:"none",status:"available",canExecuteCreate:true,versionPolicy:e.versionPolicy,officialCommands:[e.commandDisplay("<name>",{skipGit:false,skipInstall:false})],adoptAfterCreate:true,...e.nodeSupport?{runtimeRequirements:{node:e.nodeSupport.requirement}}:{}})),{id:"wordpress-site",aliases:["wordpress","wordpress-site","wp","wp-site"],ecosystem:"wordpress",plannerFramework:"wordpress",runtime:"php",runtimeCandidates:["php"],workspacePythonEngine:"none",status:"planned",canExecuteCreate:false,versionPolicy:"planned",officialCommands:["wp core download","wp config create","wp db create","wp core install"],adoptAfterCreate:true},{id:"wordpress-block",aliases:["wordpress-block","wp-block","gutenberg-block"],ecosystem:"wordpress",plannerFramework:"wordpress",runtime:"node",runtimeCandidates:["node","php"],workspacePythonEngine:"none",status:"planned",canExecuteCreate:false,versionPolicy:"planned",officialCommands:["npx @wordpress/create-block@latest <slug>"],adoptAfterCreate:true},{id:"symfony",aliases:["symfony","php-symfony"],ecosystem:"php",plannerFramework:"symfony",runtime:"php",runtimeCandidates:["php"],workspacePythonEngine:"none",status:"planned",canExecuteCreate:false,versionPolicy:"planned",officialCommands:["composer create-project symfony/skeleton <name>"],adoptAfterCreate:true},{id:"rails",aliases:["rails","ruby-on-rails","ruby-rails"],ecosystem:"ruby",plannerFramework:"rails",runtime:"ruby",runtimeCandidates:["ruby"],workspacePythonEngine:"none",status:"planned",canExecuteCreate:false,versionPolicy:"planned",officialCommands:["rails new <name>"],adoptAfterCreate:true}],L=new Map;for(let e of Nt){L.set(e.id,e);for(let t of e.aliases)L.set(t,e);}var Kt=new Set(["php","ruby","rust","elixir","clojure","scala","kotlin","unknown"]);function V(e){return e?.trim().toLowerCase()||void 0}function dt(e){let t=V(e.kitId)??V(e.framework)??V(e.runtime)??"unknown";if(e.projectExists)return {lane:"existing",status:"available",canExecuteCreate:false,requested:t,reason:"Existing projects enter Workspace Intelligence through adopt/import."};let r=R(e.kitId)??R(e.framework);if(r)return {lane:"native",status:"available",canExecuteCreate:true,requested:t,resolved:r.id,reason:"Workspai owns the create contract, project marker, registry, doctor, and workspace model path."};let o=e.kitId?b$1(e.kitId):void 0;if(o&&Tt.has(o))return {lane:"native",status:"available",canExecuteCreate:true,requested:t,resolved:o,reason:"Workspai owns the create contract, project marker, registry, doctor, and workspace model path."};let s=L.get(t)??L.get(V(e.framework)??"")??L.get(V(e.runtime)??"");if(s)return {lane:"official",status:s.status,canExecuteCreate:s.canExecuteCreate,requested:t,resolved:s.id,officialCommands:s.officialCommands,fallbackLane:s.canExecuteCreate?void 0:"existing",reason:s.status==="available"?"Workspai runs the official ecosystem generator, then registers the project in Workspace Intelligence.":"Official generator support is planned but not enabled; use adopt/import until Workspai owns the post-create contract."};let n=V(e.runtime);return n&&Kt.has(n)?{lane:"existing",status:"available",canExecuteCreate:false,requested:t,resolved:n,reason:"Runtime can be governed through Workspace Intelligence, but native create is not supported."}:{lane:"existing",status:"available",canExecuteCreate:false,requested:t,reason:"No native create contract is available; use adopt/import to enter Workspace Intelligence."}}function Zr(e){return !e.canExecuteCreate&&(e.lane==="official"||e.lane==="existing"&&e.resolved!==void 0)}var nn="rapidkit-freshness-metadata-v1";function ke(e){if(Array.isArray(e))return e.map(t=>ke(t));if(e&&typeof e=="object"){let t={};for(let r of Object.keys(e).sort())t[r]=ke(e[r]);return t}return e}function Vt(e){return JSON.stringify(ke(e))}function _(e){return $t.createHash("sha256").update(Vt(e)).digest("hex")}var lt=".workspai/workspace-graph.overrides.json",Ht=new Set([".ts",".tsx",".js",".jsx",".mjs",".cjs"]),Bt=new Set([".git",".hg",".svn",".workspai",".rapidkit",".venv","node_modules","dist","build","out","target","coverage","htmlcov",".next",".turbo",".cache"]),ut=600,ft=5,Lt=256*1024,pt={inferred:1,contract:2,manual:3};function Ut(e){return e.split(g.sep).join("/")}function ee(e,t){return Ut(g.relative(e,t)||".")}function mt(e){let t=new Map;for(let r of e.projects)t.has(r.name)||t.set(r.name,{id:r.name,path:r.path,...r.runtime?{runtime:r.runtime}:{},...r.framework?{framework:r.framework}:{},...r.kind?{kind:r.kind}:{}});return [...t.values()].sort((r,o)=>r.id.localeCompare(o.id))}function gt(e,t){let r=new Map,o=new Map;for(let n of t.projects){if(r.has(n.name))continue;let i=d(e,n.path,{...n.absolutePath?{absolutePath:n.absolutePath}:{}});r.set(n.name,i),o.has(i)||o.set(i,n.name);}let s=[...o.entries()].map(([n,i])=>({dir:n,id:i})).sort((n,i)=>i.dir.length-n.dir.length||n.dir.localeCompare(i.dir));return {idToDir:r,dirToId:o,sortedDirs:s}}function te(e,t){let r=g.resolve(t);for(let{dir:o,id:s}of e.sortedDirs)if(r===o||r.startsWith(`${o}${g.sep}`))return s;return null}function ve(e,t){let r=g.relative(e,t);return r.length>0&&!r.startsWith("..")&&!g.isAbsolute(r)}function je(e,t,r){let o=e.idToDir.get(t),s=e.idToDir.get(r);return !o||!s?false:ve(o,s)||ve(s,o)}async function be(e){try{if(!await C.pathExists(e))return null;let t=await C.readJSON(e);return t&&typeof t=="object"&&!Array.isArray(t)?t:null}catch{return null}}async function Ce(e){try{return await C.pathExists(e)?await C.readFile(e,"utf8"):null}catch{return null}}async function ht(e,t){let r=[],o=new Map;for(let[s,n]of t.idToDir.entries()){let i=await be(g.join(n,"package.json")),a=typeof i?.name=="string"?i.name.trim():"";a&&!o.has(a)&&o.set(a,s);}for(let[s,n]of t.idToDir.entries()){let i=await be(g.join(n,"package.json"));if(i){let a=["dependencies","devDependencies","peerDependencies","optionalDependencies"],c=new Set;for(let l of a){let u=i[l];if(!(!u||typeof u!="object"||Array.isArray(u)))for(let p of Object.keys(u)){let d=o.get(p);!d||d===s||c.has(d)||(c.add(d),r.push({from:s,to:d,kind:"package-dep",source:"inferred",confidence:"high",evidence:[{file:ee(e,g.join(n,"package.json")),detail:`declares dependency ${p}`}]}));}}}r.push(...await zt(e,t,s,n)),r.push(...await qt(e,t,s,n));}return r}async function zt(e,t,r,o){let s=await Ce(g.join(o,"pyproject.toml"));if(!s)return [];let n=[],i=new Set,a=/path\s*=\s*["']([^"']+)["']/g,c;for(;(c=a.exec(s))!==null;){let l=te(t,g.resolve(o,c[1]));!l||l===r||je(t,r,l)||i.has(l)||(i.add(l),n.push({from:r,to:l,kind:"package-dep",source:"inferred",confidence:"high",evidence:[{file:ee(e,g.join(o,"pyproject.toml")),detail:`path dependency ${c[1]}`}]}));}return n}async function qt(e,t,r,o){let s=await Ce(g.join(o,"go.mod"));if(!s)return [];let n=[],i=new Set,a=/replace\s+\S+\s+=>\s+(\.[^\s]+)/g,c;for(;(c=a.exec(s))!==null;){let l=te(t,g.resolve(o,c[1]));!l||l===r||je(t,r,l)||i.has(l)||(i.add(l),n.push({from:r,to:l,kind:"package-dep",source:"inferred",confidence:"high",evidence:[{file:ee(e,g.join(o,"go.mod")),detail:`go.mod replace ${c[1]}`}]}));}return n}async function Jt(e,t,r=new Set){let o=[],s=[e];for(;s.length>0&&o.length<t;){let n=s.shift();if(!n)continue;let i=[];try{i=await C.readdir(n,{withFileTypes:true});}catch{continue}let a=[],c=[];for(let l of i)if(l.isDirectory()){let u=g.resolve(n,l.name);if(r.has(u)||Bt.has(l.name)||a$5(l.name)||l.name.startsWith("."))continue;a.push(g.join(n,l.name));}else l.isFile()&&Ht.has(g.extname(l.name))&&c.push(g.join(n,l.name));c.sort((l,u)=>l.localeCompare(u)),a.sort((l,u)=>l.localeCompare(u));for(let l of c){if(o.length>=t)break;o.push(l);}s.push(...a);}return o}var Xt=[/\bfrom\s+["']([^"']+)["']/g,/\bimport\s+["']([^"']+)["']/g,/\bimport\s*\(\s*["']([^"']+)["']\s*\)/g,/\brequire\s*\(\s*["']([^"']+)["']\s*\)/g];function Yt(e){let t=new Set;for(let r of Xt){r.lastIndex=0;let o;for(;(o=r.exec(e))!==null;){let s=o[1];s.startsWith(".")&&t.add(s);}}return [...t]}async function Pe(e,t,r,o){let s=new Map;for(let[n,i]of t.idToDir.entries()){if(o&&!o.has(n))continue;let a=new Set([...t.idToDir.entries()].filter(([l,u])=>l!==n&&ve(i,u)).map(([,l])=>g.resolve(l))),c=await Jt(i,r,a);for(let l of c){let u=await C.stat(l).catch(()=>null);if(!u||u.size>Lt)continue;let p=await Ce(l);if(p)for(let d of Yt(p)){let f=g.resolve(g.dirname(l),d),h=te(t,f);if(!h||h===n||je(t,n,h))continue;let m=`${n}\0${h}`,v=s.get(m);v||(v={from:n,to:h,evidence:[]},s.set(m,v)),v.evidence.length<ft&&v.evidence.push({file:ee(e,l),detail:`imports ${d}`});}}}return [...s.values()].map(n=>({from:n.from,to:n.to,kind:"code-import",source:"inferred",confidence:"medium",evidence:n.evidence}))}function Qt(e,t,r){let o=new Map;for(let s of r.projects){let n=Zt(e,t,s);n&&o.set(s.slug,n);}return o}function Zt(e,t,r){let o=[r.relativePath,r.externalPath].filter(s=>typeof s=="string"&&s.length>0);for(let s of o){let n=g.resolve(e,s),i=t.dirToId.get(n)??te(t,n);if(i)return i}return t.idToDir.has(r.slug)?r.slug:null}function kt(e,t,r){let o=[],s=Qt(e,t,r),n=g$2,i=new Map,a=new Map;for(let c of r.projects){let l=s.get(c.slug);if(!l)continue;let u=c.contracts??{publishes:[],consumes:[],dependsOn:[]};for(let p of u.dependsOn??[]){let d=s.get(p);!d||d===l||o.push({from:l,to:d,kind:"service-dependsOn",source:"contract",confidence:"high",evidence:[{file:n,detail:`dependsOn ${p}`}]});}for(let p of u.publishes??[])i.has(p)||i.set(p,new Set),i.get(p)?.add(l);for(let p of u.consumes??[])a.has(p)||a.set(p,new Set),a.get(p)?.add(l);}for(let[c,l]of i.entries()){let u=a.get(c);if(u)for(let p of u)for(let d of l)p!==d&&o.push({from:p,to:d,kind:"event-pub-sub",source:"contract",confidence:"high",evidence:[{file:n,detail:`consumes event ${c}`}]});}return o.push(...er(r,s)),o}function ye(e){return e.toLowerCase().replace(/[^a-z0-9]/g,"")}function er(e,t){let r=[],o=e.projects.map(s=>({project:s,id:t.get(s.slug)})).filter(s=>!!s.id).filter(s=>ye(s.project.slug).length>=3);for(let s of e.projects){let n=t.get(s.slug);if(!n)continue;let i=s.contracts?.env??[];if(i.length===0)continue;let a=new Set;for(let c of i){let l=ye(c);for(let u of o)u.id===n||a.has(u.id)||!(l.includes(ye(u.project.slug))&&(u.project.ports?.length??0)>0)||(a.add(u.id),r.push({from:n,to:u.id,kind:"shared-resource",source:"inferred",confidence:"low",evidence:[{file:g$2,detail:`env ${c} references ${u.project.slug}`}]}));}}return r}async function yt(e,t){let r=await be(g.join(e,lt)),o=Array.isArray(r?.edges)?r?.edges:[],s=[],n=new Set(f$1);for(let i of o){if(!i||typeof i!="object"||Array.isArray(i))continue;let a=i,c=typeof a.from=="string"?a.from:"",l=typeof a.to=="string"?a.to:"",u=typeof a.kind=="string"?a.kind:"";if(!t.has(c)||!t.has(l)||c===l||!n.has(u))continue;let p=Array.isArray(a.evidence)?a.evidence.map(d=>d&&typeof d=="object"&&typeof d.file=="string"?{file:d.file,...typeof d.detail=="string"?{detail:d.detail}:{}}:null).filter(d=>!!d):[];s.push({from:c,to:l,kind:u,source:"manual",confidence:"high",evidence:p.length>0?p:[{file:lt,detail:"manual edge"}]});}return s}function tr(e){return `${e.from}\0${e.to}\0${e.kind}`}function rr(e){let t=new Set,r=[];for(let o of e){let s=`${o.file}\0${o.detail??""}`;t.has(s)||(t.add(s),r.push(o));}return r.sort((o,s)=>o.file.localeCompare(s.file)||(o.detail??"").localeCompare(s.detail??"")).slice(0,ft)}function nr(e){let t=new Map;for(let r of e){let o=tr(r),s=t.get(o);if(!s){t.set(o,{...r,evidence:[...r.evidence]});continue}let n=pt[s.source],i=pt[r.source];i>n?t.set(o,{...r,evidence:[...r.evidence,...s.evidence]}):i===n&&s.evidence.push(...r.evidence);}return [...t.values()].map(r=>({from:r.from,to:r.to,kind:r.kind,source:r.source,confidence:r.confidence,evidence:rr(r.evidence)})).sort((r,o)=>r.from.localeCompare(o.from)||r.to.localeCompare(o.to)||r.kind.localeCompare(o.kind)||r.source.localeCompare(o.source))}function we(e){return Math.round(e*1e3)/1e3}function or(e){return Math.max(0,Math.min(100,Math.round(e)))}function sr(e){return e>=75?"critical":e>=50?"high":e>=20?"medium":"low"}function ar(e){return e==="critical"||e==="high"?"strict":e==="medium"?"elevated":"normal"}function ir(e,t){let r=a$6({nodes:e,edges:t}),o=new Map;for(let s of e){let n=r.byId.get(s.id)??{fanIn:0,fanOut:0,reach:0,betweenness:0,isHotspot:false},i=t.filter(f=>f.from===s.id||f.to===s.id),a=i.filter(f=>f.source==="contract"||f.source==="manual").length,c=i.filter(f=>f.confidence==="low").length,l=[],u=n.reach*20+n.fanIn*14+n.fanOut*8+Math.min(20,n.betweenness*4)+a*8;n.isHotspot&&(u+=24,l.push("Critical-path hotspot in dependency graph")),n.reach>0&&l.push(`Change reaches ${n.reach} dependent project(s)`),n.fanIn>0&&l.push(`${n.fanIn} direct dependent project(s)`),n.fanOut>0&&l.push(`${n.fanOut} direct dependency project(s)`),a>0&&l.push(`${a} contract/manual edge(s)`),c>0&&l.push(`${c} low-confidence inferred edge(s) need review`),i.length===0&&l.push(e.length===1?"Single-project workspace; inter-project dependency edges are not applicable":"No dependency evidence connected to this project yet");let p=or(u),d=sr(p);o.set(s.id,{weight:d,score:p,verificationPriority:ar(d),reasons:l.slice(0,5),centrality:{fanIn:n.fanIn,fanOut:n.fanOut,reach:n.reach,betweenness:n.betweenness,isHotspot:n.isHotspot}});}return o}function cr(e,t){let r=ir(e,t);return e.map(o=>({...o,operationalProfile:r.get(o.id)}))}function dr(e,t){let r=new Set;for(let c of t)r.add(c.from),r.add(c.to);let o=e.length,s=t.length,n=e.filter(c=>r.has(c.id)).length,i=Math.max(0,o-n),a=a$6({nodes:e,edges:t});return {nodeCount:o,edgeCount:s,inferredEdges:t.filter(c=>c.source==="inferred").length,contractEdges:t.filter(c=>c.source==="contract").length,manualEdges:t.filter(c=>c.source==="manual").length,authoritativeEdges:t.filter(c=>c.source==="contract"||c.source==="manual").length,lowConfidenceEdges:t.filter(c=>c.confidence==="low").length,orphanCount:i,connectedNodeCount:n,density:we(o>1?s/(o*(o-1)):0),edgeCoverageRatio:we(o>0?n/o:1),evidenceCoverageRatio:we(s>0?t.filter(c=>c.evidence.length>0).length/s:1),hotspotCount:a.hotspots.length,hasCycle:pr(e,t)}}function lr(e,t,r){let o=[],s=e.filter(n=>!t.some(i=>i.from===n.id||i.to===n.id)).map(n=>n.id).sort((n,i)=>n.localeCompare(i));return r.nodeCount===0&&o.push({code:"graph.empty",severity:"info",message:"Workspace model has no projects, so dependency reasoning is unavailable.",recommendation:"Import, scaffold, or register projects before relying on graph-aware impact."}),r.nodeCount>1&&r.edgeCount===0?o.push({code:"graph.edges.missing",severity:"warning",message:"Projects were detected, but no inter-project dependency edges were found.",recommendation:"Run graph explain, add workspace contract relationships, or define manual graph overrides for operational dependencies that code imports cannot reveal.",nodeIds:s}):r.nodeCount>1&&r.orphanCount>0&&o.push({code:"graph.orphans.detected",severity:"warning",message:`${r.orphanCount} project(s) have no dependency evidence connected to the graph.`,recommendation:"Review isolated projects and add package, contract, or manual edges when they participate in release-critical flows.",nodeIds:s.slice(0,12)}),r.lowConfidenceEdges>0&&o.push({code:"graph.low_confidence_edges",severity:"info",message:`${r.lowConfidenceEdges} inferred edge(s) are low confidence.`,recommendation:"Promote important low-confidence relationships to workspace contract or manual overrides."}),r.edgeCount>0&&r.evidenceCoverageRatio<1&&o.push({code:"graph.evidence.partial",severity:"warning",message:"Some dependency edges do not include file-level evidence.",recommendation:"Attach evidence to manual overrides so agents can audit why a relationship exists."}),r.hasCycle&&o.push({code:"graph.cycle.detected",severity:"error",message:"The dependency graph contains at least one directed cycle.",recommendation:"Break the cycle or document the relationship explicitly before using graph-aware release gates."}),o.sort((n,i)=>{let a={error:0,warning:1,info:2};return a[n.severity]-a[i.severity]||n.code.localeCompare(i.code)})}function pr(e,t){let r=new Map;for(let c of e)r.set(c.id,[]);for(let c of t)r.has(c.from)||r.set(c.from,[]),r.get(c.from)?.push(c.to);let o=0,s=1,n=2,i=new Map;for(let c of r.keys())i.set(c,o);let a=c=>{let l=[{id:c,index:0}];for(i.set(c,s);l.length>0;){let u=l[l.length-1],p=r.get(u.id)??[];if(u.index>=p.length){i.set(u.id,n),l.pop();continue}let d=p[u.index];u.index+=1;let f=i.get(d)??o;if(f===s)return true;f===o&&(i.set(d,s),l.push({id:d,index:0}));}return false};for(let c of [...r.keys()].sort())if(i.get(c)===o&&a(c))return true;return false}function wt(e$1,t,r,o){let s=nr(r.filter(c=>t.has(c.from)&&t.has(c.to))),n=cr(e$1,s),i=dr(e$1,s),a=lr(e$1,s,i);return {schemaVersion:e,generatedAt:(o??new Date).toISOString(),nodes:n,edges:s,stats:i,...a.length>0?{diagnostics:a}:{}}}async function vt(e){let t=g.resolve(e.workspacePath),r=e.maxImportFilesPerProject??ut,o=mt(e.model),s=new Set(o.map(a=>a.id)),n=gt(t,e.model),i=[];return i.push(...await ht(t,n)),i.push(...await Pe(t,n,r)),e.contract&&i.push(...kt(t,n,e.contract)),i.push(...await yt(t,s)),wt(o,s,i,e.now)}async function bt(e){let t=g.resolve(e.workspacePath),r=e.maxImportFilesPerProject??ut,o=mt(e.model),s=new Set(o.map(a=>a.id)),n=gt(t,e.model),i=[];if(i.push(...await ht(t,n)),e.structuralChange)i.push(...await Pe(t,n,r));else {i.push(...await Pe(t,n,r,e.changedProjectIds));for(let a of e.previousGraph.edges)a.kind==="code-import"&&a.source==="inferred"&&!e.changedProjectIds.has(a.from)&&s.has(a.from)&&s.has(a.to)&&i.push({from:a.from,to:a.to,kind:"code-import",source:"inferred",confidence:a.confidence,evidence:a.evidence});}return e.contract&&i.push(...kt(t,n,e.contract)),i.push(...await yt(t,s)),wt(o,s,i,e.now)}var re="workspace-model-producer.v3";var Ee=s.workspaceModelCache.schemaVersion,Se=t$1.workspaceModelCache,hr=["package.json","pyproject.toml","setup.py","requirements.txt","requirements.in","go.mod","go.sum","pom.xml","build.gradle","build.gradle.kts","Cargo.toml","composer.json","Gemfile","Gemfile.lock","mix.exs","mix.lock","deno.json","deno.jsonc","deno.lock","bun.lock","bun.lockb","bunfig.toml",".bunfig.toml","deps.edn","project.clj","build.sbt","CMakeLists.txt","meson.build","workspai.project.json",".workspai/project.json",".workspai/context.json","rapidkit.project.json",".rapidkit/project.json",".rapidkit/context.json"],kr=[".csproj",".fsproj",".vbproj",".sln",".slnx",".gemspec"],Pt=[t$1.workspaceContract,".workspai/workspace.json","workspai.workspace.json",".workspai/policies.yml",".workspai/policies.yaml",".rapidkit/workspace.contract.json",".rapidkit/workspace.json","rapidkit.workspace.json",".rapidkit/policies.yml",".rapidkit/policies.yaml"],jt=new Set([".ts",".tsx",".js",".jsx",".mjs",".cjs",".vue",".svelte",".rb",".go",".py",".java",".kt",".kts",".rs",".cs",".php",".ex",".exs",".clj",".cljs",".scala",".c",".cc",".cpp",".cxx",".h",".hh",".hpp",".hxx",".proto",".graphql",".gql",".sql",".sh"]),yr=new Set([".git",".workspai",".rapidkit","node_modules","dist","build","out","target","coverage",".next",".turbo",".cache",".venv"]),wr=1500,ne=promisify(execFile);function vr(e){return jt.has(g.extname(e).toLowerCase())}async function br(e){try{let{stdout:t}=await ne("git",["-C",e,"rev-parse","--show-toplevel"],{encoding:"utf8",timeout:1e4,maxBuffer:1048576}),r=t.trim();if(!r)return null;let o=g.relative(r,e).split(g.sep).join("/");if(o===".."||o.startsWith("../"))return null;let s=o||".",n=o?`HEAD:${o}`:"HEAD^{tree}",{stdout:i}=await ne("git",["-C",r,"rev-parse",n],{encoding:"utf8",timeout:1e4,maxBuffer:1024*1024}),[a,c]=await Promise.all([ne("git",["-C",r,"diff","--name-only","-z","HEAD","--",s],{encoding:"buffer",timeout:2e4,maxBuffer:64*1024*1024}),ne("git",["-C",r,"ls-files","--others","--exclude-standard","-z","--",s],{encoding:"buffer",timeout:2e4,maxBuffer:64*1024*1024})]),l=new Set([a.stdout,c.stdout].flatMap(p=>p.toString("utf8").split("\0")).filter(Boolean)),u=[`git-tree:${i.trim()}`];for(let p of [...l].sort((d,f)=>d.localeCompare(f))){let d=g.resolve(r,p),f=g.relative(e,d).split(g.sep).join("/");f===".."||f.startsWith("../")||!vr(f)||u.push(`${f}:${await z(d)??"<deleted>"}`);}return u}catch{return null}}var U=null;function We(){if(U)return U;try{U=createRequire(import.meta.url)("../package.json")?.version??"0.0.0";}catch{U="0.0.0";}return U}async function z(e){try{let t=await C.readFile(e);return $t.createHash("sha256").update(t).digest("hex")}catch{return null}}async function Ct(e){let t={};for(let o of hr){let s=await z(g.join(e,o));s&&(t[o]=s);}let r=await C.readdir(e).catch(()=>[]);for(let o of r.sort((s,n)=>s.localeCompare(n))){if(!kr.some(n=>o.toLowerCase().endsWith(n)))continue;let s=await z(g.join(e,o));s&&(t[o]=s);}return t}async function Pr(e){let t=await Ct(e),r=await br(e),o=r??[];if(r)return _({manifests:t,source:o});let s=[e];for(;s.length>0&&o.length<wr;){let n=s.shift();if(!n)continue;let i=[];try{i=await C.readdir(n,{withFileTypes:true});}catch{continue}let a=[];for(let c of i)if(c.isDirectory()){if(yr.has(c.name)||a$5(c.name)||c.name.startsWith("."))continue;a.push(g.join(n,c.name));}else if(c.isFile()&&jt.has(g.extname(c.name))){let l=g.join(n,c.name),u=await C.stat(l).catch(()=>null);if(u){let p=g.relative(e,l).split(g.sep).join("/");o.push(`${p}:${u.size}:${Math.round(u.mtimeMs)}`);}}a.sort((c,l)=>c.localeCompare(l)),s.push(...a);}return o.sort((n,i)=>n.localeCompare(i)),_({manifests:t,source:o})}async function oe(e,t){let r=g.resolve(e),o={},s=[...new Set(t.map(n=>g.relative(r,g.resolve(n)).split(g.sep).join("/")))].sort((n,i)=>n.localeCompare(i));for(let n of s)o[n]=await Pr(g.join(r,n));return o}async function se(e){let t=g.resolve(e),r={};for(let o of Pt){let s=await z(g.join(t,o));s&&(r[o]=s);}return r}async function ae(e){let t=g.resolve(e.workspacePath),r=[...new Set(e.projectPaths.map(n=>g.relative(t,g.resolve(n)).split(g.sep).join("/")))].sort((n,i)=>n.localeCompare(i)),o=[];for(let n of r){let i=await Ct(g.join(t,n));o.push({project:n,manifests:i});}let s={};for(let n of Pt){let i=await z(g.join(t,n));i&&(s[n]=i);}return _({cacheSchema:Ee,cliVersion:e.cliVersion,flags:e.flags,workspaceJson:e.workspaceJson??null,marker:e.marker??null,projects:o,workspaceFiles:s})}async function Re(e){let t=await g$1(e,Se)??a$4(e,Se);try{if(!await C.pathExists(t))return null;let r=await C.readJson(t);return !r||r.schemaVersion!==Ee||r.producerRevision!==re||typeof r.inputsHash!="string"||typeof r.cliVersion!="string"||!r.model?null:r}catch{return null}}async function ie(e,t){let r={schemaVersion:Ee,producerRevision:re,...t};return h(e,Se,r)}var St="rapidkit-fact-freshness-v1",q={durable:720*60*60,derived:10080*60,evidenceBacked:1440*60,live:300,verifyBeforeUse:1440*60};function jr(e){switch(e){case "durable":return q.durable;case "derived":return q.derived;case "evidence-backed":return q.evidenceBacked;case "live":return q.live;case "verify-before-use":return q.verifyBeforeUse}}function Cr(e){if(e.status)return e.status;if(e.ttlSeconds===null)return "unknown";let t=Date.parse(e.generatedAt);if(!Number.isFinite(t))return "unknown";let r=t+e.ttlSeconds*1e3;return e.now.getTime()>r?"stale":"fresh"}function Sr(e){let t=e.now??new Date,r=e.generatedAt??t.toISOString(),o=Date.parse(r),s=Number.isFinite(o),n=s?r:t.toISOString(),i=e.ttlSeconds===void 0?jr(e.kind):e.ttlSeconds,a=Cr({generatedAt:n,ttlSeconds:i,status:e.status??(s?void 0:"unknown"),now:t}),c=Date.parse(n),l=i===null||!Number.isFinite(c)?void 0:new Date(c+i*1e3),u=e.verifyBeforeUse??(e.kind==="live"||e.kind==="verify-before-use"||e.category!=="structure"||a!=="fresh");return {schemaVersion:St,kind:e.kind,category:e.category,generatedAt:n,ttlSeconds:i,...l?{expiresAt:l.toISOString()}:{},status:a,verifyBeforeUse:u,...e.sourceArtifact?{sourceArtifact:e.sourceArtifact}:{},...e.sourcePath?{sourcePath:e.sourcePath}:{},inputsHash:e.inputsHash??_(e.value??null),reason:e.reason}}function b(e){return {id:e.id,label:e.label,scope:e.scope,value:e.value,...e.project?{project:e.project}:{},freshness:Sr({...e.freshness,value:e.value})}}function Et(e){let t=e.generatedAt??(e.now??new Date).toISOString(),r={durable:0,derived:0,"evidence-backed":0,live:0,"verify-before-use":0},o={structure:0,verification:0,state:0},s=0,n=0,i=0,a=0;for(let c of e.facts)r[c.freshness.kind]+=1,o[c.freshness.category]+=1,c.freshness.status==="stale"&&(s+=1),c.freshness.status==="unknown"&&(n+=1),c.freshness.kind==="live"&&(i+=1),c.freshness.verifyBeforeUse&&(a+=1);return {schemaVersion:St,generatedAt:t,status:s>0?"stale":n>0?"unknown":"fresh",totalFacts:e.facts.length,staleFacts:s,unknownFacts:n,liveFacts:i,verifyBeforeUseFacts:a,byKind:r,byCategory:o}}function J(e,t){let r=[...new Set(e)],o=r.filter(s=>t.has(s)).length;return {eligibleCount:r.length,boundCount:o,unknownCount:r.length-o,coverageRatio:r.length===0?null:o/r.length}}function Wt(e,t){let r=e.filter(d=>d.kind==="project").map(d=>d.id),o=e.filter(d=>d.kind==="endpoint").map(d=>d.id),s=new Set(o),n=e.filter(d=>d.kind==="api"&&!!d.projectId&&d.attributes.runtimeRegistrationRequired===true).map(d=>d.id),i=new Set(n),a=new Map(e.map(d=>[d.id,d.kind])),c=new Set(t.filter(d=>d.kind==="implements"||d.kind==="defines"&&a.get(d.from)==="file"&&a.get(d.to)==="endpoint").flatMap(d=>s.has(d.from)?[d.from]:s.has(d.to)?[d.to]:[])),l=new Set(t.filter(d=>d.kind==="implements"&&(a.get(d.from)==="runtime-unit"||a.get(d.to)==="runtime-unit")).flatMap(d=>i.has(d.from)?[d.from]:i.has(d.to)?[d.to]:[])),u=new Set(r),p=d=>new Set(t.filter(f=>f.kind===d).flatMap(f=>[f.from,f.to]).filter(f=>u.has(f)));return {apiImplementation:J(o,c),apiRuntimeRegistration:J(n,l),projectTests:J(r,p("tests")),projectDeployment:J(r,p("deploys")),projectOwnership:J(r,p("owns"))}}function Rt(e,t){return e.filter(o=>o.code.includes("unknown")||o.code.includes("unresolved")||o.code.includes("limit_reached")||o.code.endsWith(".empty_result")).reduce((o,s)=>o+Math.max(s.entityIds?.length??0,s.relationIds?.length??0,1),0)+Object.values(t).reduce((o,s)=>o+s.unknownCount,0)}function xe(e,t){return t===0?1:e/t}function Er(e,t,r,o){return e.entityIds?.some(s=>t.has(s))||e.relationIds?.some(s=>r.has(s))?true:e.entityIds?.length||e.relationIds?.length?false:!/\bproject\b/i.test(e.message)||e.message.includes(o)}function Wr(e,t,r,o,s){let n=new Set(s.filter(a=>a.provider===e.id).map(a=>a.id)),i=e.inputCoverage?.filter(a=>a.scope==="workspace"||a.scope==="project"&&a.scopeId===t);return {...e,discoveredEntities:r.filter(a=>a.proofIds.some(c=>n.has(c))).length,discoveredRelations:o.filter(a=>a.proofIds.some(c=>n.has(c))).length,proofCount:n.size,...i?{inputCoverage:i}:{}}}function Rr(e,t){let r=new Set(e.entities.filter(m=>m.projectId===t).map(m=>m.id)),o=e.relations.filter(m=>r.has(m.from)||r.has(m.to)),s=new Set(r);for(let m of o)s.add(m.from),s.add(m.to);let n=e.entities.filter(m=>s.has(m.id)),i=new Set([...n,...o].flatMap(m=>m.proofIds)),a=e.proofs.filter(m=>i.has(m.id)),c=new Set(o.map(m=>m.id)),l=e.diagnostics.filter(m=>Er(m,s,c,t)),u=e.providers.map(m=>Wr(m,t,n,o,a)),p=e.source.inputs?.scopes.filter(m=>m.kind==="workspace"||m.kind==="project"&&m.id===t)??[],d=p.filter(m=>!m.truncated).length,f=u.reduce((m,v)=>(v.status==="failed"?m.failed+=1:v.status==="skipped"||v.inputCoverage?.every(W=>W.status==="not-applicable")?m.notApplicable+=1:v.status==="partial"||v.inputCoverage?.some(W=>W.status==="bounded")?m.bounded+=1:m.complete+=1,m),{complete:0,bounded:0,notApplicable:0,failed:0}),h=Wt(n,o);return {...e,entities:n,relations:o,proofs:a,providers:u,quality:{entityCount:n.length,relationCount:o.length,proofCount:a.length,entityProofCoverageRatio:xe(n.filter(m=>m.proofIds.length>0).length,n.length),relationProofCoverageRatio:xe(o.filter(m=>m.proofIds.length>0).length,o.length),providerSuccessRatio:xe(u.filter(m=>m.status!=="failed").length,u.length),conflictCount:l.filter(m=>m.code.includes("conflict")).length,unknownCount:Rt(l,h),bindingCoverage:h,...e.quality.completeness?{completeness:{status:p.some(m=>m.truncated)||f.bounded>0||f.failed>0?"bounded":"complete",inventory:{scopeCount:p.length,completeScopes:d,boundedScopes:p.length-d,eligibleFiles:p.reduce((m,v)=>m+(v.eligibleFileCount??v.fileCount),0),indexedFiles:p.reduce((m,v)=>m+v.fileCount,0),eligibleFileCountExact:p.every(m=>m.eligibleFileCountExact!==false)},providers:f}}:{},portable:true,secretValuesEmitted:false},diagnostics:l}}var xr=s.projectKnowledgeGraphReference.schemaVersion;function xt(e,t){let r=Rr(e,t),o={schemaVersion:xr,generatedAt:e.generatedAt,project:{name:t},canonical:{graph:"workspace:.workspai/reports/workspace-knowledge-graph.json",boundedQuery:`workspai workspace graph search <task-query> --scope project:${t} --limit 12 --json`,sourceHash:e.source.hash,projectionHash:c$1(r)},summary:{entityCount:r.entities.length,relationCount:r.relations.length,proofCount:r.proofs.length}};return {...o,integrity:{algorithm:"sha256",payloadHash:c$1(o),portable:true,absolutePathsEmitted:false}}}function At(e,t){return d(e,t.path,{...t.absolutePath?{absolutePath:t.absolutePath}:{}})}var Ar=q$2.model,de=p.model;function Ae(e){return e.projectTopology??e.graph}function It(e){return !!(e.projectTopology&&e.graph&&c$1(e.projectTopology)===c$1(e.graph))}function ko(e){let t=e.engineStatus==="hit"||e.engineStatus==="unchanged"?"reused":e.engineStatus==="incremental"?"partially-reused":"rebuilt";return {schemaVersion:"workspace-model-build.v1",mode:e.mode,outcome:t,engineStatus:e.engineStatus}}var Mr=["package.json","pyproject.toml","requirements.txt","go.mod","pom.xml","build.gradle","build.gradle.kts","Cargo.toml","composer.json","Gemfile","mix.exs","deno.json","deno.jsonc","bun.lock","bun.lockb","bunfig.toml",".bunfig.toml","deps.edn","project.clj","build.sbt","docker-compose.yml","docker-compose.yaml","compose.yml","compose.yaml","terraform.tf"],Ir=new Set([".git",".hg",".svn",".workspai",".rapidkit",".venv","node_modules","dist","build","target","coverage","htmlcov",".next",".turbo"]);function Fr(e,t){return (g.relative(e,t)||".").split(g.sep).join("/")}function ce(e,t){return Fr(e,d(e,t.path,{...t.absolutePath?{absolutePath:t.absolutePath}:{}}))}async function Ft(e){try{if(!await C.pathExists(e))return null;let t=await C.readJSON(e);return t&&typeof t=="object"?t:null}catch{return null}}async function Dr(e,t){for(let r of t)if(await C.pathExists(g.join(e,r)))return true;return false}function Me(e){let t=Number.parseInt(process.env.RAPIDKIT_WORKSPACE_MODEL_SCAN_DEPTH??"",10),r=typeof e=="number"&&Number.isFinite(e)?e:Number.isFinite(t)?t:4;return Math.min(12,Math.max(1,Math.trunc(r)))}async function Or(e,t){let r=g.resolve(e),o=[{dirPath:r,depth:0}],s=new Set,n=new Set;for(;o.length>0;){let i=o.shift();if(!i)continue;let a=g.resolve(i.dirPath);if(n.has(a))continue;if(n.add(a),a!==r&&await Dr(a,Mr)){s.add(a);continue}if(i.depth>=t)continue;let c=[];try{c=await C.readdir(a,{withFileTypes:true});}catch{continue}for(let l of c)!l.isDirectory()||Ir.has(l.name)||a$5(l.name)||l.name.startsWith(".")&&l.name!==".config"||o.push({dirPath:g.join(a,l.name),depth:i.depth+1});}return Array.from(s).sort((i,a)=>i.localeCompare(a))}function Gr(e){let t=new Set,r=[];for(let o of e){let s=g.resolve(o);t.has(s)||(t.add(s),r.push(s));}return r.sort((o,s)=>o.localeCompare(s))}function Mt(e,t){let r=e?.[t];return typeof r=="string"&&r.trim()?r.trim():void 0}function _r(e,t){return e?.[t]===true}function Tr(e,t,r){let o=e?.frontend&&typeof e.frontend=="object"&&!Array.isArray(e.frontend)?e.frontend:void 0,s=Mt(o,"generator"),n=Mt(o,"command_display"),i=typeof t=="string"&&t.startsWith("frontend.");if(!(!s&&!i))return {...s?{id:s}:{},...t?{kit:t}:{},displayName:r,source:_r(o,"official_generator")?"official-generator":"metadata",...n?{commandDisplay:n}:{}}}async function Nr(e){let t=[".workspai/project.json",".workspai/context.json",".rapidkit/project.json",".rapidkit/context.json","package.json","product.json","tsconfig.json","pnpm-workspace.yaml","bunfig.toml",".bunfig.toml","nx.json","turbo.json","pyproject.toml","requirements.txt","go.mod","go.work","go.work.sum","pom.xml","build.gradle","build.gradle.kts","Cargo.toml","rust-toolchain.toml","rust-toolchain","CMakeLists.txt","meson.build","Makefile","WORKSPACE","WORKSPACE.bazel","MODULE.bazel","BUILD","BUILD.bazel",".bazelrc","composer.json","Gemfile","mix.exs","deno.json","setup.py","setup.cfg","Dockerfile","docker-compose.yml","docker-compose.yaml","compose.yml","compose.yaml","README.md"],r=[];for(let s of t)await C.pathExists(g.join(e,s))&&r.push(s);let o=new Set(["package.json","pyproject.toml","go.mod","go.work","pom.xml","build.gradle","build.gradle.kts","Cargo.toml","CMakeLists.txt","meson.build","composer.json","Gemfile","mix.exs","deno.json"]);if(!r.some(s=>o.has(s))){let s=[],n=new Set([".git",".workspai",".rapidkit",".venv","build","dist","node_modules","target","third_party","vendor"]),i=(p,d)=>{let f=p.toLowerCase();return ["package.json","pyproject.toml","go.mod","pom.xml","build.gradle","build.gradle.kts","cargo.toml","cmakelists.txt","meson.build","composer.json","gemfile","mix.exs","deno.json"].includes(f)||f.endsWith(".gemspec")||f==="description"&&d.toLowerCase()==="r"},a=async(p,d)=>{if(d>3||s.length>=512)return;let f=await C.readdir(p,{withFileTypes:true}).catch(()=>[]);for(let h of f.sort((m,v)=>m.name.localeCompare(v.name))){if(s.length>=512)return;h.isFile()&&i(h.name,g.basename(p))?s.push(g.relative(e,g.join(p,h.name)).split(g.sep).join("/")):h.isDirectory()&&!n.has(h.name)&&await a(g.join(p,h.name),d+1);}};await a(e,0);let c=new Map;for(let p of s){let d=p.split("/")[0],f=c.get(d)??[];f.push(p),c.set(d,f);}for(let p of c.values())p.sort((d,f)=>d.split("/").length-f.split("/").length||d.localeCompare(f));let l=[],u=[...c.keys()].sort();for(let p=0;l.length<16&&u.some(d=>p<(c.get(d)?.length??0));p+=1)for(let d of u){let f=c.get(d)?.[p];f&&l.length<16&&l.push(f);}r.push(...l.filter(p=>!r.includes(p)));}return r}async function A(e,t,r,o=t){let s=await g$1(e,t),n=s!==null,i={path:o.split(g.sep).join("/"),exists:n};if(s&&r){let a=await Ft(s);typeof a?.generatedAt=="string"&&(i.generatedAt=a.generatedAt);let c=a?.status??a?.result??a?.verdict;typeof c=="string"&&(i.status=c);}return i}async function Kr(e,t,r,o){let s=".workspai/reports",n=c=>A(t,`${s}/${c}`,r,`${o}/${s}/${c}`),i=await n("doctor-project-last-run.json");return {doctor:i?.exists===true?i:await n("doctor-last-run.json"),remediationPlan:await n("doctor-remediation-plan-last-run.json"),fixResult:await n("doctor-fix-result-last-run.json"),analyze:await n("analyze-last-run.json"),readiness:await n("release-readiness-last-run.json")}}async function $r(e,t,r){let o=j$2(t,{searchParents:false}),s=q$3(t),n=s&&!j$3(o)?s.detection:m(t,o),i=D(t),a=f(n.runtime),c=await b$2(t,o,{runtime:n.runtime,framework:n.key}),l$1=r.contractProject?.slug?r.contractProject.slug:typeof o?.name=="string"&&o.name.trim()?o.name.trim():g.basename(t),u=j$3(o)?`adopted.${n.key}`:typeof o?.kit_name=="string"?o.kit_name:typeof o?.kit=="string"?o.kit:r.contractProject?.kit,p=typeof o?.engine=="string"?o.engine:i.engine!=="unknown"?i.engine:void 0,d=Tr(o,u,n.displayName),f$1=dt({kitId:u,framework:n.key,runtime:n.runtime}),h=l(t),m$1=[n.runtime,...h.filter(T=>T!==n.runtime)],v=await c$2({projectPath:t,declaration:r.contractProject?.governance}),W=b$3({workspacePath:e,projectPath:t,projectName:l$1,declaredRelativePath:r.contractProject?.relativePath});return {name:l$1,path:W,...r.includeAbsolutePaths?{absolutePath:t}:{},kind:c,category:a$3(c),runtime:n.runtime,runtimeCandidates:m$1,framework:n.key,frameworkDisplayName:n.displayName,confidence:n.confidence,detectionSource:n.source,supportTier:n.supportTier,runtimeSupportTier:a.tier,runtimeDoctorSupport:a.doctorSupport,moduleSupport:i.moduleSupport,...u?{kit:u}:{},...p?{engine:p}:{},...d?{generator:d}:{},createCapability:f$1,commands:{supported:i.supportedCommands,unsupported:i.unsupportedCommands,global:i.globalCommands,fleetStages:i.fleetStages,localOnly:i.localOnlyCommands,map:i.commandMap},importantFiles:await Nr(t),governance:v,evidence:await Kr(e,t,r.includeEvidence,W),provenance:{path:r.contractProject?"workspace contract declaration reconciled with filesystem discovery":"filesystem discovery",runtime:n.source,framework:n.source,commands:"project command capability matrix",createCapability:"create planner capability contract",governance:r.contractProject?.governance!==void 0?"workspace contract declaration reconciled with repository evidence":"repository and documented external governance discovery",evidence:"project .workspai/reports"}}}async function Vr(e){for(let t$1 of t(e,"workspace.json")){let r=await Ft(t$1);if(r)return r}return null}function Hr(e){if(e.length===0)return "empty-workspace";let t=new Set(e.map(r=>r.category));return t.size>1?"polyglot-product-workspace":t.has("frontend")&&e.length>1?"full-stack-workspace":t.has("frontend")?"frontend-workspace":t.has("desktop")?"desktop-application-workspace":t.has("extension")?"extension-workspace":t.has("agent")?e.length>1?"agent-platform-workspace":"agent-workspace":t.has("platform")?"platform-workspace":t.has("library")?"library-workspace":e.length>1?"backend-platform":"backend-workspace"}function Br(e){let t=new Set;for(let r of e){let o=`${r.name} ${r.path}`.toLowerCase();for(let s of ["auth","billing","payment","notification","order","admin","report","search","analytics"])o.includes(s)&&t.add(s);}return Array.from(t).sort()}function j(e,t,r,o){return {severity:e,code:t,message:r,target:o}}function Dt(e){let t=[];if(e.workspace.name.trim()||t.push(j("error","workspace.name.missing","Workspace name could not be resolved.","workspace")),e.workspace.type==="observed-workspace"&&t.push(j("warning","workspace.marker.missing","Workspace marker is missing; model is based on filesystem observation.","workspace.marker")),e.summary.projectCount===0&&t.push(j("warning","workspace.projects.empty","No project roots were detected in this workspace.","projects")),e.workspace.profile){let n=W({profile:e.workspace.profile,runtimes:e.summary.runtimes});n.ok||t.push(j("warning","workspace.profile.mismatch",[n.message,n.recommendedCommand?`Keep the current profile and run ${n.recommendedCommand} when you want the recommended profile.`:void 0].filter(Boolean).join(" "),"workspace.profile"));}e.contracts.exists||t.push(j("warning","workspace.contract.missing","Workspace contract is missing; dependency and API edges may be incomplete.",e.contracts.workspaceContractPath));let r=new Map;for(let n of e.projects){let i=n.name.toLowerCase(),a=r.get(i)??[];a.push(n),r.set(i,a),n.importantFiles.length||t.push(j("warning","project.markers.missing",`Project ${n.name} has no important manifest files recorded.`,n.path));let c=d(e.workspace.root,n.path,{...n.absolutePath?{absolutePath:n.absolutePath}:{}});C.existsSync(c)||t.push(j("warning","project.path.missing",`Registered project ${n.name} is not available at its declared path.`,n.path)),n.runtime==="unknown"&&t.push(j("warning","project.runtime.unknown",`Project ${n.name} runtime could not be confidently detected.`,n.path));let l=["test","build"];for(let d of l)n.commands.supported.includes(d)&&n.commands.unsupported.includes(d)&&t.push(j("error","project.commands.conflict",`Project ${n.name} marks ${d} as both supported and unsupported.`,n.path));let u=new Set(n.commands.fleetStages),p=new Set(n.commands.localOnly);for(let d of n.commands.fleetStages){p.has(d)&&t.push(j("error","project.commands.scope-conflict",`Project ${n.name} marks ${d} as both fleet and local-only.`,n.path));let f=n.commands.map[d];(!f||f.fleetEligible!==true||f.executionScope!=="fleet")&&t.push(j("error","project.commands.fleet-stage-invalid",`Project ${n.name} advertises ${d} as a fleet stage without a supported fleet capability.`,n.path));}for(let d of n.commands.localOnly){let f=n.commands.map[d];(!f||f.status!=="supported"||f.executionScope!=="local-only"||f.fleetEligible===true)&&t.push(j("error","project.commands.local-only-invalid",`Project ${n.name} advertises ${d} as local-only without a matching local-only capability.`,n.path));}for(let d of Object.values(n.commands.map))d.status==="supported"&&(d.fleetEligible===true&&!u.has(d.command)&&t.push(j("error","project.commands.fleet-stage-missing",`Project ${n.name} capability ${d.command} is fleet-eligible but missing from fleetStages.`,n.path)),d.executionScope==="local-only"&&d.fleetEligible!==true&&!p.has(d.command)&&t.push(j("error","project.commands.local-only-missing",`Project ${n.name} capability ${d.command} is local-only but missing from localOnly commands.`,n.path)));}for(let[n,i]of r.entries())i.length>1&&t.push(j("error","project.name.duplicate",`Project name "${n}" is ambiguous across ${i.length} project roots.`,i.map(a=>a.path).join(", ")));e.projectTopology&&e.graph&&c$1({...e.projectTopology,generatedAt:"<ignored>"})!==c$1({...e.graph,generatedAt:"<ignored>"})&&t.push(j("error","workspace.project-topology.alias-mismatch","Deprecated model.graph must remain structurally identical to canonical model.projectTopology during the v1 migration window.","projectTopology"));let o=t.filter(n=>n.severity==="error").length,s=t.filter(n=>n.severity==="warning").length;return {status:o>0?"failed":s>0?"warning":"passed",errors:o,warnings:s,issues:t}}function yo(e){return Dt(e)}function P(e){return e.join(".")}function Lr(e,t){let r=de,o=e.generatedAt,s=[b({id:"workspace.name",label:"Workspace name",scope:"workspace",value:e.workspace.name,freshness:{kind:"durable",category:"structure",generatedAt:o,now:t,sourceArtifact:r,sourcePath:P(["workspace","name"]),reason:"Workspace identity is structural metadata and changes through workspace setup."}}),b({id:"workspace.type",label:"Workspace type",scope:"workspace",value:e.identity.workspaceType,freshness:{kind:"derived",category:"structure",generatedAt:o,now:t,sourceArtifact:r,sourcePath:P(["identity","workspaceType"]),reason:"Workspace type is derived from the current project inventory."}}),b({id:"workspace.projectCount",label:"Project count",scope:"workspace",value:e.summary.projectCount,freshness:{kind:"derived",category:"structure",generatedAt:o,now:t,sourceArtifact:r,sourcePath:P(["summary","projectCount"]),reason:"Project count is derived from workspace discovery and should be refreshed after structural changes."}}),b({id:"workspace.runtimeFamilies",label:"Runtime families",scope:"workspace",value:e.identity.runtimeFamilies,freshness:{kind:"derived",category:"structure",generatedAt:o,now:t,sourceArtifact:r,sourcePath:P(["identity","runtimeFamilies"]),reason:"Runtime coverage is inferred from project surfaces."}}),b({id:"workspace.policyMode",label:"Workspace policy mode",scope:"policy",value:e.policies.mode,freshness:{kind:"durable",category:"structure",generatedAt:o,now:t,sourceArtifact:r,sourcePath:P(["policies","mode"]),reason:"Policy mode is configuration, not runtime state."}}),b({id:"workspace.contract.exists",label:"Workspace contract presence",scope:"contract",value:e.contracts.exists,freshness:{kind:"derived",category:"structure",generatedAt:o,now:t,sourceArtifact:r,sourcePath:P(["contracts","exists"]),reason:"Contract presence is derived from workspace files and should be refreshed before release gating."}})],n=Ae(e);n&&s.push(b({id:"graph.edgeCount",label:"Dependency graph edge count",scope:"graph",value:n.stats.edgeCount,freshness:{kind:"derived",category:"structure",generatedAt:n.generatedAt??o,now:t,sourceArtifact:r,sourcePath:P(["projectTopology","stats","edgeCount"]),reason:"Graph topology is derived from manifests, imports, and workspace contracts."}}),b({id:"graph.evidenceCoverageRatio",label:"Dependency graph evidence coverage",scope:"graph",value:n.stats.evidenceCoverageRatio,freshness:{kind:"derived",category:"structure",generatedAt:n.generatedAt??o,now:t,sourceArtifact:r,sourcePath:P(["projectTopology","stats","evidenceCoverageRatio"]),reason:"Graph evidence coverage changes when dependency evidence or contract edges change."}}));for(let[i,a]of e.projects.entries()){let c=`projects[${i}]`,l={kind:"derived",category:"structure",generatedAt:o,now:t,sourceArtifact:r,reason:"Project facts are derived from workspace discovery, project metadata, and framework probes."};s.push(b({id:`project.${a.name}.kind`,label:`${a.name} kind`,scope:"project",project:a.name,value:a.kind,freshness:{...l,sourcePath:P([c,"kind"])}}),b({id:`project.${a.name}.category`,label:`${a.name} category`,scope:"project",project:a.name,value:a.category,freshness:{...l,sourcePath:P([c,"category"])}}),b({id:`project.${a.name}.runtime`,label:`${a.name} runtime`,scope:"project",project:a.name,value:a.runtime,freshness:{...l,sourcePath:P([c,"runtime"])}}),b({id:`project.${a.name}.framework`,label:`${a.name} framework`,scope:"project",project:a.name,value:a.frameworkDisplayName,freshness:{...l,sourcePath:P([c,"frameworkDisplayName"])}}),b({id:`project.${a.name}.supportTier`,label:`${a.name} support tier`,scope:"project",project:a.name,value:a.supportTier,freshness:{...l,sourcePath:P([c,"supportTier"])}}),b({id:`project.${a.name}.safeFleetStages`,label:`${a.name} safe fleet stages`,scope:"command",project:a.name,value:a.commands.fleetStages,freshness:{...l,sourcePath:P([c,"commands","fleetStages"]),reason:"Safe command availability is derived from package and project command surfaces."}}),...["ci","release","ownership"].map(u=>b({id:`project.${a.name}.governance.${u}`,label:`${a.name} ${u} governance`,scope:"policy",project:a.name,value:a.governance?.[u]??{status:"unknown",provider:null,evidence:[],reference:null},freshness:{...l,sourcePath:P([c,"governance",u]),reason:"Governance truth is reconciled from repository surfaces and explicit workspace contract declarations."}})));for(let[u,p]of Object.entries(a.evidence))s.push(b({id:`project.${a.name}.evidence.${u}`,label:`${a.name} ${u} evidence`,scope:"evidence",project:a.name,value:p?{path:p.path,exists:p.exists,status:p.status??null}:{exists:false},freshness:{kind:p?.exists?"evidence-backed":"verify-before-use",category:"verification",generatedAt:p?.generatedAt??o,now:t,status:p?.exists?void 0:"unknown",sourceArtifact:p?.path??r,sourcePath:P([c,"evidence",u]),verifyBeforeUse:true,reason:p?.exists?"Evidence reports can expire or become stale after source changes.":"Missing evidence must be generated before this fact is used for verification."}}));}for(let[i,a]of Object.entries(e.evidence))s.push(b({id:`workspace.evidence.${i}`,label:`Workspace ${i} evidence`,scope:"evidence",value:a?{path:a.path,exists:a.exists,status:a.status??null}:null,freshness:{kind:a?.exists?"evidence-backed":"verify-before-use",category:"verification",generatedAt:a?.generatedAt??o,now:t,status:a?.exists?void 0:"unknown",sourceArtifact:a?.path??r,sourcePath:P(["evidence",i]),verifyBeforeUse:true,reason:a?.exists?"Workspace evidence can expire or become stale after project, dependency, or policy changes.":"Missing workspace evidence must be generated before release or repair decisions."}}));return s}async function Ie(e,t){let[r,o,s,n,i,a$3]=await Promise.all([a(e),Vr(e),Fe(e),a$1(e),a$2(e,{descendIntoMatchedProjects:false}),Or(e,t)]),c=new Map;for(let u of s?.projects??[]){let p=d(e,u.relativePath,u.externalPath?{absolutePath:u.externalPath}:{});c.set(p,u);}let l=Gr([...i,...a$3.filter(u=>!i.some(p=>{let d=g.relative(p,u);return d!==""&&d!==".."&&!d.startsWith(`..${g.sep}`)&&!g.isAbsolute(d)})),...c.keys(),...n.map(u=>d(e,u.relativePath||u.name,u.path?{absolutePath:u.path}:{}))]);return {marker:r,workspaceJson:o,workspaceContract:s,contractProjectPaths:c,projectPaths:l}}async function le(e){let t$2=g.resolve(e.workspacePath),r=e.includeAbsolutePaths===true,o=e.includeEvidence===true,s=Me(e.observableScanDepth),n=e.now??new Date,{marker:i,workspaceJson:a,workspaceContract:c,contractProjectPaths:l,projectPaths:u}=await Ie(t$2,s),p$1=e.reuseProjectModels,d=await Promise.all(u.map(w=>{if(p$1){let _t=g.relative(t$2,g.resolve(w)).split(g.sep).join("/"),De=p$1.get(_t);if(De)return Promise.resolve(De)}return $r(t$2,w,{includeAbsolutePaths:r,includeEvidence:o,contractProject:l.get(g.resolve(w))})})),f=typeof a?.workspace_name=="string"?a.workspace_name:typeof a?.name=="string"?a.name:i?.name||c?.workspace.name||g.basename(t$2),h=typeof a?.profile=="string"?a.profile:typeof a?.mode=="string"?a.mode:c?.workspace.profile,m=Array.from(new Set(d.map(w=>w.kind))).sort(),v=Array.from(new Set(d.map(w=>w.category))).sort(),W=Array.from(new Set(d.flatMap(w=>w.runtimeCandidates.length>0?w.runtimeCandidates:[w.runtime]))).sort(),T=Array.from(new Set(d.map(w=>w.framework))).sort(),N=[".workspai/policies.yml",".workspai/policies.yaml",".rapidkit/policies.yml",".rapidkit/policies.yaml"].find(w=>C.existsSync(g.join(t$2,w))),X=t(t$2,"workspace.contract.json").map(w=>g.relative(t$2,w).split(g.sep).join("/")).find(w=>C.existsSync(g.join(t$2,w)))??t$1.workspaceContract,O=await C.pathExists(g.join(t$2,X)),Y={schemaVersion:Ar,generatedAt:n.toISOString(),workspace:{name:f,root:t$2,...h?{profile:h}:{},type:i?"rapidkit-workspace":"observed-workspace",...i?{marker:{createdBy:i.createdBy,version:i.version,createdAt:i.createdAt}}:{}},identity:{workspaceType:Hr(d),surfaces:m,categories:v,runtimeFamilies:W,businessCapabilities:Br(d)},discovery:{observableScanDepth:s},projects:d,policies:{mode:typeof a?.policy_mode=="string"?a.policy_mode:typeof a?.policyMode=="string"?a.policyMode:"warn",source:N??null,exists:!!N},contracts:{workspaceContractPath:X,exists:O,status:O?"known":"missing"},evidence:{doctor:await A(t$2,p.doctor,o),projectDoctor:await A(t$2,t$1.doctorProject,o),doctorRemediationPlan:await A(t$2,t$1.doctorRemediationPlan,o),artifactRemediationPlan:await A(t$2,t$1.artifactRemediationPlan,o),doctorFixResult:await A(t$2,t$1.doctorFixResult,o),analyze:await A(t$2,p.analyze,o),readiness:await A(t$2,p.readiness,o),pipeline:await A(t$2,t$1.pipelineLastRun,o)},summary:{projectCount:d.length,runtimes:W,frameworks:T,firstClassProjects:d.filter(w=>w.supportTier==="first-class").length,extendedProjects:d.filter(w=>w.supportTier==="extended").length,observedProjects:d.filter(w=>w.supportTier==="observed").length}},S=await Ot(t$2,Y,{contractExists:O,now:n,incrementalGraph:e.incrementalGraph}),E={...Y,projectTopology:S,graph:S},G=Dt(E),K=Lr({...E},n),Gt=Et({facts:K,generatedAt:n.toISOString(),now:n});return {...E,facts:K,factFreshness:Gt,validation:G}}async function wo(e){if(e.cache!==true)return {model:await le(e),cache:"disabled"};let t=g.resolve(e.workspacePath),r=Me(e.observableScanDepth),o=We(),{marker:s,workspaceJson:n,projectPaths:i}=await Ie(t,r),a=await ae({workspacePath:t,cliVersion:o,flags:{includeAbsolutePaths:e.includeAbsolutePaths===true,includeEvidence:e.includeEvidence===true,observableScanDepth:r},projectPaths:i,workspaceJson:n,marker:s}),c=await Re(t);if(c&&c.cliVersion===o&&c.inputsHash===a&&It(c.model))return {model:c.model,cache:"hit"};let l=await le({...e}),[u,p]=await Promise.all([oe(t,i),se(t)]);return await ie(t,{cliVersion:o,inputsHash:a,generatedAt:(e.now??new Date).toISOString(),model:l,projectSignatures:u,workspaceFileSignatures:p}),{model:l,cache:"miss"}}function Ur(e,t){let r=new Set,o=new Set,s=new Set;for(let[n,i]of Object.entries(t))n in e?e[n]!==i&&r.add(n):o.add(n);for(let n of Object.keys(e))n in t||s.add(n);return {changed:r,added:o,removed:s}}function zr(e={},t={}){let r=new Set([...Object.keys(e),...Object.keys(t)]);for(let o of r)if(e[o]!==t[o])return false;return true}async function vo(e){let t=g.resolve(e.workspacePath),r=Me(e.observableScanDepth),o=We(),s=e.now??new Date,{marker:n,workspaceJson:i,projectPaths:a}=await Ie(t,r),c=await Re(t),l=async()=>{let S=await le({...e}),E=await ae({workspacePath:t,cliVersion:o,flags:{includeAbsolutePaths:e.includeAbsolutePaths===true,includeEvidence:e.includeEvidence===true,observableScanDepth:r},projectPaths:a,workspaceJson:i,marker:n}),[G,K]=await Promise.all([oe(t,a),se(t)]);return await ie(t,{cliVersion:o,inputsHash:E,generatedAt:s.toISOString(),model:S,projectSignatures:G,workspaceFileSignatures:K}),{model:S,mode:"full"}},u=c?Ae(c.model):void 0;if(!c||c.cliVersion!==o||!c.projectSignatures||!u||!It(c.model))return l();let p=await se(t);if(!zr(c.workspaceFileSignatures,p))return l();let d=await oe(t,a),{changed:f,added:h,removed:m}=Ur(c.projectSignatures,d);if(f.size===0&&h.size===0&&m.size===0)return {model:c.model,mode:"unchanged"};let v=new Set([...f,...h]),W=new Map;for(let S of c.model.projects){let E=ce(t,S);!v.has(E)&&!m.has(E)&&W.set(E,S);}let T=new Set,N=false;for(let S of c.model.projects){let E=ce(t,S);f.has(E)&&T.add(S.name);}let X=h.size>0||m.size>0,O=await le({...e,reuseProjectModels:W,incrementalGraph:{previousGraph:u,changedProjectIds:T,structuralChange:X||N}});for(let S of c.model.projects){let E=ce(t,S);if(!f.has(E))continue;let G=O.projects.find(K=>ce(t,K)===E);if(G&&G.name!==S.name){N=true;break}}if(N)return l();let Y=await ae({workspacePath:t,cliVersion:o,flags:{includeAbsolutePaths:e.includeAbsolutePaths===true,includeEvidence:e.includeEvidence===true,observableScanDepth:r},projectPaths:a,workspaceJson:i,marker:n});return await ie(t,{cliVersion:o,inputsHash:Y,generatedAt:s.toISOString(),model:O,projectSignatures:d,workspaceFileSignatures:p}),{model:O,mode:"incremental"}}async function Fe(e){try{let{contract:t}=await p$1({workspacePath:e});return t&&typeof t=="object"?t:null}catch{return null}}async function Ot(e,t,r){let o=r.contractExists?await Fe(e):null;try{return r.incrementalGraph?await bt({workspacePath:e,model:t,contract:o,now:r.now,previousGraph:r.incrementalGraph.previousGraph,changedProjectIds:r.incrementalGraph.changedProjectIds,structuralChange:r.incrementalGraph.structuralChange}):await vt({workspacePath:e,model:t,contract:o,now:r.now})}catch{let s=t.projects.map(n=>({id:n.name,path:n.path}));return {schemaVersion:"workspace-dependency-graph.v1",generatedAt:r.now.toISOString(),nodes:s,edges:[],stats:{nodeCount:s.length,edgeCount:0,inferredEdges:0,contractEdges:0,manualEdges:0,authoritativeEdges:0,lowConfidenceEdges:0,orphanCount:s.length,connectedNodeCount:0,density:0,edgeCoverageRatio:s.length>0?0:1,evidenceCoverageRatio:1,hotspotCount:0,hasCycle:false},diagnostics:s.length>1?[{code:"graph.inference.failed",severity:"warning",message:"Dependency graph inference failed; model contains projects but no dependency edges.",recommendation:"Run workspace model again after fixing graph inputs, or add workspace contract/manual graph overrides.",nodeIds:s.map(n=>n.id).sort((n,i)=>n.localeCompare(i))}]:void 0}}}async function bo(e,t,r={}){let o=e.contracts.exists?await Fe(t):null,{buildWorkspaceKnowledgeGraph:s}=await import('./workspace-knowledge-graph-CPBKNXQI.js'),n=d$1(e),i=r.refreshKnowledgeGraph?null:await C.readJson(g.join(t,p.knowledgeGraph)).then(p=>p).catch(()=>null),a=await s({workspacePath:t,workspace:{name:e.workspace.name,...e.workspace.profile?{profile:e.workspace.profile}:{}},projects:e.projects.map(p=>({id:p.name,path:p.path,...p.absolutePath?{absolutePath:p.absolutePath}:{},runtime:p.runtime,runtimeCandidates:p.runtimeCandidates,framework:p.framework,kind:p.kind,category:p.category,...p.governance?{governance:p.governance}:{},...p.kit?{kit:p.kit}:{}})),projectTopology:Ae(e)??await Ot(t,e,{contractExists:e.contracts.exists,now:new Date(e.generatedAt)}),contract:o,now:new Date(e.generatedAt),source:{kind:"workspace-model",artifact:de,hashAlgorithm:"sha256",hash:d$2(n)},previousGraph:i}),c=[],l=new Map;for(let p of e.projects){let d=At(t,p);if(!(await C.stat(d).catch(()=>null))?.isDirectory())continue;let h=await C.realpath(d),m=l.get(h);if(m)throw new Error(`Projects ${m} and ${p.name} resolve to the same graph artifact root: ${d}`);l.set(h,p.name),c.push({rootPath:d,relativePath:t$1.projectKnowledgeGraphReference,payload:xt(a,p.name)});}let u=await j$1(t,de,[{rootPath:t,relativePath:p.knowledgeGraph,payload:a},{rootPath:t,relativePath:de,payload:n},...c]);for(let p$1 of c){let d=g.join(p$1.rootPath,p.knowledgeGraph);(await C.readJson(d).catch(()=>null))?.schemaVersion===q$2.knowledgeGraph&&await C.remove(d).catch(()=>{});}return u[1]}export{dt as a,Zr as b,nn as c,_ as d,St as e,b as f,Et as g,Wt as h,Rt as i,Rr as j,At as k,Ar as l,de as m,Ae as n,ko as o,yo as p,Lr as q,le as r,wo as s,vo as t,bo as u};
@@ -1 +0,0 @@
1
- export{a as readWorkspaceKnowledgeGraphSnapshot}from'./chunk-4CXV3PPV.js';
@@ -1 +0,0 @@
1
- export{a as resolveWorkspaceRunStageTimeoutMs,b as runWorkspaceStage}from'./chunk-WC2K5QFI.js';export{a as WORKSPACE_RUN_LAST_REPORT_FILENAME}from'./chunk-P5LI5DL3.js';