workspai 0.75.1 → 0.75.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (103) hide show
  1. package/dist/analyze-6UEBC5OJ.js +1 -0
  2. package/dist/{artifact-remediation-plan-HD5K52UJ.js → artifact-remediation-plan-SRH2Q6N2.js} +1 -1
  3. package/dist/autopilot-release-H5TO6NYY.js +1 -0
  4. package/dist/chunk-2DZLCINC.js +1 -0
  5. package/dist/{chunk-W7I65IXY.js → chunk-3HXEPDFF.js} +2 -2
  6. package/dist/chunk-3N27P3KO.js +7 -0
  7. package/dist/{chunk-6NSJBKKK.js → chunk-3RNWBFRP.js} +1 -1
  8. package/dist/{chunk-2OCJKLTW.js → chunk-4JXJRIJM.js} +1 -1
  9. package/dist/chunk-5HNQIMGW.js +1 -0
  10. package/dist/chunk-5K4O3TAW.js +4 -0
  11. package/dist/{chunk-566NQQTJ.js → chunk-66O62XNJ.js} +49 -49
  12. package/dist/{chunk-SCKEFXF5.js → chunk-ADHX7D3F.js} +1 -1
  13. package/dist/chunk-DTNOF3MP.js +1 -0
  14. package/dist/{chunk-OH6LV5JP.js → chunk-E42IFQFR.js} +4 -4
  15. package/dist/{chunk-6B7L4NZE.js → chunk-EFHSRPW7.js} +6 -6
  16. package/dist/{chunk-NI5QWBZK.js → chunk-EP7SUMAX.js} +1 -1
  17. package/dist/chunk-EWD6QTAM.js +2 -0
  18. package/dist/{chunk-6KMR5PKQ.js → chunk-FNVWDXK2.js} +3 -3
  19. package/dist/{chunk-AICCXYY5.js → chunk-FZWLWFR4.js} +1 -1
  20. package/dist/chunk-G5UCEXP6.js +1 -0
  21. package/dist/{chunk-2CT5SN2L.js → chunk-GDOO2YZW.js} +1 -1
  22. package/dist/{chunk-2GWQ6NZV.js → chunk-IKBE3HOH.js} +1 -1
  23. package/dist/{chunk-4VSQNSGH.js → chunk-K52IQX3J.js} +1 -1
  24. package/dist/{chunk-UE7ART6X.js → chunk-KDVNRNDU.js} +1 -1
  25. package/dist/chunk-LARREYZN.js +1 -0
  26. package/dist/{chunk-HDISUL3F.js → chunk-LFY7KTPD.js} +1 -1
  27. package/dist/{chunk-RTD5D35M.js → chunk-P36TACKN.js} +1 -1
  28. package/dist/{chunk-NGZF4YJS.js → chunk-PFAGXI3G.js} +1 -1
  29. package/dist/chunk-ROOPODG6.js +2 -0
  30. package/dist/{chunk-5EEXLM45.js → chunk-SZHRPELL.js} +1 -1
  31. package/dist/{chunk-DJH2CH42.js → chunk-UHIN3RS6.js} +1 -1
  32. package/dist/{chunk-25V5XMWB.js → chunk-VWBWDDU2.js} +1 -1
  33. package/dist/chunk-VXFIMEC6.js +2 -0
  34. package/dist/{chunk-3WQ5TYCO.js → chunk-WHBKKJ7L.js} +1 -1
  35. package/dist/chunk-WXUCAVFT.js +681 -0
  36. package/dist/chunk-X7OI24LO.js +418 -0
  37. package/dist/{chunk-RPM67N7A.js → chunk-XHUM372O.js} +1 -1
  38. package/dist/{chunk-NRIMJMTF.js → chunk-ZGVODK5C.js} +8 -8
  39. package/dist/{create-P4XJVZCL.js → create-ZFSFWAW3.js} +1 -1
  40. package/dist/{demo-kit-ALW6OSQV.js → demo-kit-QNGY4KQ5.js} +1 -1
  41. package/dist/{doctor-PFN6KB6P.js → doctor-4KL4XUCS.js} +1 -1
  42. package/dist/{dotnet-webapi-clean-6Z4EXEJY.js → dotnet-webapi-clean-GXTNZMKO.js} +1 -1
  43. package/dist/{goal-lifecycle-BDWTWS55.js → goal-lifecycle-EXQZD7IA.js} +1 -1
  44. package/dist/{goal-pack-5JDNZFKV.js → goal-pack-DKJU2DEP.js} +1 -1
  45. package/dist/{gofiber-standard-TDJQIVQZ.js → gofiber-standard-PFBIAMGR.js} +1 -1
  46. package/dist/{gogin-standard-UEF3IHSJ.js → gogin-standard-DW5GL7YG.js} +1 -1
  47. package/dist/index.js +86 -85
  48. package/dist/{pipeline-OUYS4ZYV.js → pipeline-4GVAOCEN.js} +1 -1
  49. package/dist/{project-agent-entry-75WO3QWP.js → project-agent-entry-7QKNEEXP.js} +1 -1
  50. package/dist/{project-intelligence-lens-JCHFOIA7.js → project-intelligence-lens-IHRYCLNU.js} +1 -1
  51. package/dist/{proof-carrying-change-LAYV4LTI.js → proof-carrying-change-O37XUPIZ.js} +1 -1
  52. package/dist/{rust-axum-4TRVPFMB.js → rust-axum-L7UAYARA.js} +1 -1
  53. package/dist/{springboot-standard-COWL75GT.js → springboot-standard-CZH24KWD.js} +1 -1
  54. package/dist/verified-goal-XI4RQESU.js +1 -0
  55. package/dist/{workspace-CBQDOUSH.js → workspace-EYXAKMVI.js} +1 -1
  56. package/dist/{workspace-agent-sync-RTOTO3DY.js → workspace-agent-sync-SN55KT6N.js} +1 -1
  57. package/dist/{workspace-context-STRZO2N3.js → workspace-context-PW6ESEHH.js} +1 -1
  58. package/dist/{workspace-contract-PMHUUKFM.js → workspace-contract-FPLFL4G3.js} +1 -1
  59. package/dist/{workspace-explain-CATMJUMN.js → workspace-explain-TVQ5IF5D.js} +1 -1
  60. package/dist/{workspace-foundation-OULCDCXG.js → workspace-foundation-DWIJPZRH.js} +1 -1
  61. package/dist/{workspace-graph-stream-Q55CI4K4.js → workspace-graph-stream-RUTNWLQB.js} +1 -1
  62. package/dist/workspace-graph-token-efficiency-WF6TGSK7.js +1 -0
  63. package/dist/{workspace-intelligence-3RPZRWSF.js → workspace-intelligence-4CA2CSPZ.js} +1 -1
  64. package/dist/{workspace-intelligence-benchmark-R5MEGJQS.js → workspace-intelligence-benchmark-V6AEVDMB.js} +1 -1
  65. package/dist/{workspace-intelligence-runner-BNZUYUUN.js → workspace-intelligence-runner-VM5SXXAT.js} +1 -1
  66. package/dist/{workspace-knowledge-graph-VJLD35ES.js → workspace-knowledge-graph-JXN2ZOAF.js} +1 -1
  67. package/dist/workspace-knowledge-graph-query-BROIV27M.js +1 -0
  68. package/dist/workspace-knowledge-graph-snapshot-KBNUXA64.js +1 -0
  69. package/dist/{workspace-mcp-serve-67NTYD67.js → workspace-mcp-serve-4WN4CSD7.js} +1 -1
  70. package/dist/{workspace-model-6TKZMNEF.js → workspace-model-D4IECQML.js} +1 -1
  71. package/dist/{workspace-onboarding-7V7EH3RH.js → workspace-onboarding-6XWDKLM5.js} +1 -1
  72. package/dist/{workspace-registry-summary-ILVO7DEU.js → workspace-registry-summary-Y3ET36NH.js} +1 -1
  73. package/dist/{workspace-repair-engine-2VGFB3DJ.js → workspace-repair-engine-HBUXRHDY.js} +1 -1
  74. package/dist/workspace-run-VN7KV4BU.js +1 -0
  75. package/dist/{workspace-verify-VQWYDAF2.js → workspace-verify-OOAZ3NMZ.js} +1 -1
  76. package/dist/{workspace-watch-2Z636HWS.js → workspace-watch-BNM5B6HU.js} +1 -1
  77. package/docs/README.md +1 -1
  78. package/docs/agent-framework-adapters.md +33 -14
  79. package/docs/ci-workflows.md +17 -1
  80. package/docs/commands-reference.md +18 -11
  81. package/docs/creating-workspaces-and-projects.md +28 -10
  82. package/docs/doctor-command.md +4 -0
  83. package/docs/native-kit-baselines.md +3 -0
  84. package/docs/workspace-run.md +8 -0
  85. package/package.json +5 -4
  86. package/dist/analyze-Z3EZNJRI.js +0 -1
  87. package/dist/autopilot-release-T6XFRWZT.js +0 -1
  88. package/dist/chunk-65AE7EC5.js +0 -2
  89. package/dist/chunk-ABUSBLBH.js +0 -1
  90. package/dist/chunk-CMLLERGG.js +0 -418
  91. package/dist/chunk-FU6SQ2ND.js +0 -1
  92. package/dist/chunk-M6DVNC6X.js +0 -2
  93. package/dist/chunk-O5XQP5E7.js +0 -1
  94. package/dist/chunk-PTI743SC.js +0 -7
  95. package/dist/chunk-QBKOPXKC.js +0 -1
  96. package/dist/chunk-VJQPIH2S.js +0 -681
  97. package/dist/chunk-WPPRUFJW.js +0 -4
  98. package/dist/chunk-ZKYH44ER.js +0 -1
  99. package/dist/verified-goal-75KGBWTE.js +0 -1
  100. package/dist/workspace-graph-token-efficiency-YHXFGH3Z.js +0 -1
  101. package/dist/workspace-knowledge-graph-query-TT2KK3SF.js +0 -1
  102. package/dist/workspace-knowledge-graph-snapshot-TQAKDDUA.js +0 -1
  103. package/dist/workspace-run-X7KV6MIT.js +0 -1
@@ -58,7 +58,7 @@ compatibility view. See [Workspai Live Activity](./workspace-live-activity.md).
58
58
 
59
59
  ```bash
60
60
  npx workspai create # Guided create or existing-software ingestion
61
- npx workspai create workspace <name> [--profile <profile>] [--yes] [--here|--output <parent-dir>] [--skip-python-engine] [--skip-git] [--dry-run] [--install-method <poetry|venv|pipx>]
61
+ npx workspai create workspace <name> [--profile <profile>] [--yes] [--here|--output <parent-dir>] [--skip-python-engine] [--skip-git] [--dry-run] [--json] [--install-method <poetry|venv|pipx>]
62
62
  npx workspai bootstrap [--profile <profile>] [--ci] [--json] [--compliance-only]
63
63
  npx workspai setup <python|node|go|java|dotnet|rust|php> [--warm-deps]
64
64
  npx workspai pipeline [--json] [--strict] [--skip-verify] [--skip-analyze] [--skip-autopilot] [--autopilot-mode <audit|safe-fix|enforce>] [--agent-sync|--no-agent-sync]
@@ -80,6 +80,8 @@ npx workspai change resume --change <change-id> --to <authorized|executing|verif
80
80
  npx workspai change abort --change <change-id> --reason <text> [--actor <identity>] [--json]
81
81
  npx workspai change capsule validate --change <change-id> [--workspace <path>] [--json]
82
82
  npx workspai change capsule export --change <change-id> --output <path> [--workspace <path>] [--json]
83
+ npx workspai create project agent.microsoft.python <name> [--agent-name <name>] [--skip-git]
84
+ npx workspai create project agent.microsoft.dotnet <name> [--agent-name <name>] [--skip-git]
83
85
  npx workspai agent bootstrap [--project <path>] [--for-agent <host>] [--no-live-inputs] [--strict] [--json]
84
86
  npx workspai agent framework list [--json]
85
87
  npx workspai agent framework plan --project <name> --runtime <python|dotnet> --name <agent> [--goal <goal-id>] [--workspace <path>] [--json]
@@ -273,16 +275,21 @@ Blocked receipts exit `2`; strict mode also maps degraded evidence to exit `2`.
273
275
  See [Canonical-first agent entry](./agent-entry.md).
274
276
 
275
277
  `agent framework` is the governed bridge between Workspai evidence and an
276
- agent runtime. `list` exposes only exact release-admitted baselines. `plan`
277
- creates or reuses a scoped Goal, begins a Proof-Carrying Change, and attaches a
278
- hash-bound file plan without writing project files. `attach` shows that plan
279
- and requires an interactive confirmation or explicit `--yes` before granting
280
- the filesystem effect and writing an isolated `agents/<name>` directory.
281
- Dependency installation, credentials, generated-code execution, and model
282
- provider calls are never implied by that approval. `apply` is the automation
283
- counterpart for a plan that was separately authorized with `change authorize`.
284
- Any adapter, version, manifest, runtime, or platform drift invalidates its
285
- bundled release admission until the complete conformance matrix passes again.
278
+ agent runtime. `list` exposes only exact release-admitted baselines: Python
279
+ `1.18.0` and .NET `1.21.0` in this CLI version. `plan` creates or reuses a
280
+ scoped Goal, begins a Proof-Carrying Change, and attaches a hash-bound file
281
+ plan without writing project files. `attach` shows that plan and requires an
282
+ interactive confirmation or explicit `--yes` before granting the filesystem
283
+ effect and writing an isolated `agents/<name>` directory. `create project
284
+ agent.microsoft.python|dotnet` uses the same admitted lifecycle for a new
285
+ project: it registers the project, plans against a Model baseline, writes the
286
+ nested runtime, then re-observes Model/Graph before it claims Intelligence is
287
+ sealed. Dependency installation, credentials, generated-code execution, and
288
+ model provider calls are never implied by that approval. `apply` is the
289
+ automation counterpart for a plan that was separately authorized with
290
+ `change authorize`. Any adapter, version, manifest, runtime, or platform drift
291
+ invalidates its bundled release admission until the complete conformance matrix
292
+ passes again. The generated Change remains open until `change verify`.
286
293
 
287
294
  `workspace feedback record` is a non-interactive machine interface. It requires
288
295
  exactly one JSON object on stdin and `--json`; an empty stdin or interactive TTY
@@ -16,8 +16,9 @@ For a compact list of command syntax, see
16
16
  A **workspace** is the shared home for related projects, rules, and saved
17
17
  Workspai reports.
18
18
 
19
- A **project** is an application or service, such as a FastAPI API, Go service,
20
- Spring Boot service, .NET API, or frontend application.
19
+ A **project** is an application, service, or governed agent, such as a FastAPI
20
+ API, Go service, Spring Boot service, .NET API, frontend application, or
21
+ Microsoft Agent Framework entrypoint.
21
22
 
22
23
  The canonical commands are:
23
24
 
@@ -40,6 +41,7 @@ does not have exactly the same behavior.
40
41
  | Create a project and use the current/default workspace behavior | `npx workspai create project gofiber.standard api` |
41
42
  | Turn the current folder into a workspace before creating | `npx workspai create project gofiber.standard api --create-workspace --yes` |
42
43
  | Create a project without workspace management | `npx workspai create project gofiber.standard api --no-workspace --yes` |
44
+ | Create a governed Microsoft Agent Framework project | `npx workspai create project agent.microsoft.python support-agent` |
43
45
  | Preview a supported create plan | `npx workspai create project frontend.nextjs web --dry-run` |
44
46
 
45
47
  # Creating a workspace
@@ -388,15 +390,31 @@ project metadata and performs the selected workspace registration.
388
390
 
389
391
  ## Agent Framework kits
390
392
 
391
- | Kit | Runtime | Framework baseline | Behavior |
392
- | ------------------------ | ------- | ------------------ | ------------------------------------------ |
393
- | `agent.microsoft.python` | Python | Release-admitted | Goal + PCC + owned isolated agent scaffold |
394
- | `agent.microsoft.dotnet` | .NET | Release-admitted | Goal + PCC + owned isolated agent scaffold |
393
+ | Kit | Runtime | Tested baseline | Layout |
394
+ | ------------------------ | ------- | --------------- | ------ |
395
+ | `agent.microsoft.python` | Python | `agent-framework-core` `1.18.0`, Foundry `1.13.0`, `azure-identity` `1.25.3` | Isolated `agents/<instance>/` with `pyproject.toml`, credentialless `unittest`, and `.env.example` |
396
+ | `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 |
395
397
 
396
- Agent kits require Workspace governance and therefore do not accept
397
- `--no-workspace`. They do not install dependencies, call a model, or store
398
- credentials. Their exact framework versions are promoted only after the full
399
- Linux, macOS, and Windows conformance matrix passes.
398
+ Interactive `workspai create` shows these kits under **AI Agent** only after
399
+ release admission. Agent kits require Workspace governance and therefore do not
400
+ accept `--no-workspace`. Optional `--agent-name` names the instance directory
401
+ (default `primary`). They do not install dependencies, call a model, or store
402
+ credentials. Exact versions are promoted only after the full Linux, macOS, and
403
+ Windows conformance matrix passes. Weekly registry discovery is report-only; it
404
+ cannot rewrite these pins.
405
+
406
+ Create does not emit an empty root `pyproject.toml` or `.csproj`. The nested
407
+ instance is the only Workspace Run unit. After Create, Model and Graph already
408
+ include that nested runtime. The generated Change still needs:
409
+
410
+ ```bash
411
+ npx workspai workspace intelligence run --for-agent generic --strict --json
412
+ npx workspai change verify --change <change-id> --json
413
+ ```
414
+
415
+ `--strict` clears workspace-wide readiness blockers. `change verify` is the
416
+ independent proof for this scaffold. See
417
+ [Agent Framework Adapter Contract](./agent-framework-adapters.md).
400
418
 
401
419
  ## Desktop, extension, and additional backend generators
402
420
 
@@ -775,6 +775,10 @@ 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 projects keep `kind`/`framework` as `agent` /
779
+ `microsoft-agent-framework`. Doctor discovers nested environment examples and
780
+ dependency manifests under `agents/primary` and aims Python/`uv` or .NET
781
+ repair commands at that runtime, not at a phantom project-root manifest.
778
782
 
779
783
  ## Project JSON fields (AI/automation)
780
784
 
@@ -12,6 +12,9 @@ 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 kits are versioned separately through the
16
+ [Agent Framework Adapter Contract](./agent-framework-adapters.md); they are
17
+ not native HTTP service generators.
15
18
 
16
19
  ## Current tested baseline
17
20
 
@@ -48,6 +48,14 @@ nested directory is already an explicit workspace project, an aggregate parent
48
48
  does not execute that child's runtime unit again. `--plan --json` exposes the
49
49
  resulting ownership so operators can review the exact units before execution.
50
50
 
51
+ Microsoft Agent Framework projects keep their executable manifest under
52
+ `agents/<instance>/`. Workspace Run treats that nested `pyproject.toml` or
53
+ `.csproj` as its own unit (`python3 -m compileall .`,
54
+ `python3 -m unittest discover -s tests`, `python3 main.py`, or the matching
55
+ .NET commands). An empty legacy root manifest is ignored only when it still
56
+ matches the exact older Workspai shell and a real `agents/primary` runtime
57
+ exists. Any user edit restores the root as an independent unit.
58
+
51
59
  Planning and `init` do not require Doctor or release-readiness evidence. Real
52
60
  `test`, `build`, and `start` runs enforce the `doctor-workspace` and `readiness`
53
61
  gates by default. A failed gate prevents project commands from starting and is
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "workspai",
3
- "version": "0.75.1",
3
+ "version": "0.75.2",
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": [
@@ -123,6 +123,7 @@
123
123
  "test:runtime-matrix:full": "node scripts/runtime-acceptance-matrix.mjs --full",
124
124
  "test:real-world": "node scripts/real-world-qualification.mjs",
125
125
  "test:real-world:enterprise": "node scripts/enterprise-workspace-qualification.mjs",
126
+ "test:graph-shadow": "node --import tsx scripts/graph-shadow-qualification.ts",
126
127
  "check:english-text": "node ../../scripts/english-text-guard.mjs --all",
127
128
  "lint": "corepack npm run check:english-text && eslint src --ext .ts",
128
129
  "lint:fix": "eslint src --ext .ts --fix",
@@ -204,8 +205,8 @@
204
205
  "@types/yazl": "^3.3.1",
205
206
  "@typescript-eslint/eslint-plugin": "^8.46.2",
206
207
  "@typescript-eslint/parser": "^8.46.2",
207
- "@vitest/coverage-v8": "^4.0.15",
208
- "@vitest/ui": "^4.0.15",
208
+ "@vitest/coverage-v8": "^4.1.11",
209
+ "@vitest/ui": "^4.1.11",
209
210
  "eslint": "^9.39.2",
210
211
  "husky": "^9.1.7",
211
212
  "lint-staged": "^15.5.2",
@@ -215,7 +216,7 @@
215
216
  "tsx": "^4.20.6",
216
217
  "typescript": "^5.5.0",
217
218
  "vite-bundle-visualizer": "^1.2.1",
218
- "vitest": "^4.0.15"
219
+ "vitest": "^4.1.11"
219
220
  },
220
221
  "optionalDependencies": {
221
222
  "@rollup/rollup-win32-x64-msvc": "*"
@@ -1 +0,0 @@
1
- export{b as printAnalyzeReport,a as runAnalyze}from'./chunk-4VSQNSGH.js';
@@ -1 +0,0 @@
1
- export{b as AUTOPILOT_RELEASE_ALIAS_FILENAME,a as AUTOPILOT_RELEASE_LAST_RUN_FILENAME,c as runAutopilotRelease}from'./chunk-NI5QWBZK.js';
@@ -1,2 +0,0 @@
1
- import {b as b$1}from'./chunk-B6FJ6RG6.js';import {k,q as q$1,G as G$1}from'./chunk-CMLLERGG.js';import {a}from'./chunk-M6DVNC6X.js';import {c,j}from'./chunk-OH6LV5JP.js';import {m as m$2}from'./chunk-7NKM6EHE.js';import {e,f}from'./chunk-6B7L4NZE.js';import {b}from'./chunk-UJXE4UAX.js';import {m as m$1,t,k as k$1,u,l}from'./chunk-VQZ5PI5J.js';import fe,{promises}from'fs';import c$1 from'path';import J,{homedir}from'os';import {pathToFileURL}from'url';import m from'process';import h from'fs-extra';var R=["backend","frontend","desktop","agent","extension","gaming"],te=[{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:"extension",label:"Extension",hint:"Editor and platform extensions"},{id:"gaming",label:"Gaming",hint:"Game runtimes and tooling"}];function oe(t){let o=t.label.indexOf(" \u2014 ");return o>=0?t.label.slice(o+3).trim():t.label.trim()}function ne(t){return R.includes(t.category)?t.category:null}function G(t){let e=c().flatMap(n=>{let s=ne(n);return s?[{value:n.id,label:`${U(s)} \xB7 ${oe(n)}`,hint:`${n.runtime} \xB7 tested baseline`,name:n.label,category:s}]:[]}),o=k().map(n=>({value:n.kitId,label:`Frontend \xB7 ${n.displayName}`,hint:"official \xB7 latest stable",name:`${n.displayName} \u2014 ${n.framework}`,category:"frontend"})),r=q$1().map(n=>({value:n.kitId,label:`${U(n.category)} \xB7 ${n.displayName}`,hint:`${n.runtimeCandidates.join(" + ")} \xB7 official latest stable`,name:`${n.displayName} \u2014 ${n.category}`,category:n.category})),a=G$1().map(n=>({value:n.id,label:`AI Agent \xB7 ${n.label}`,hint:`${n.runtime} \xB7 release-admitted baseline`,name:n.label,category:"agent"})),i=[...e,...o,...r,...a].filter(n=>!t||n.category===t).sort((n,s)=>{let l=R.indexOf(n.category),d=R.indexOf(s.category);return l-d||(n.label??"").localeCompare(s.label??"")});return B(i),i}function je(){let t=new Set(G().map(e=>e.category));return te.filter(e=>t.has(e.id)).map(e=>({value:e.id,label:e.label,hint:e.hint}))}function U(t){return t.charAt(0).toUpperCase()+t.slice(1)}function B(t){let e=new Set,o=new Set;for(let r of t){let a=r.label??r.name??String(r.value),i=String(r.value);if(e.has(a))throw new Error(`Duplicate kit picker label: ${a}`);if(o.has(i))throw new Error(`Duplicate kit picker value: ${i}`);e.add(a),o.add(i);}}var ie=".workspairc.json",ae=".rapidkitrc.json",se=["workspai.config.js","workspai.config.mjs","workspai.config.cjs","rapidkit.config.js","rapidkit.config.mjs","rapidkit.config.cjs"],ce=["workspai.config.json","rapidkit.config.json"];function Y(t){return typeof t=="object"&&t!==null&&"code"in t&&t.code==="ENOENT"}function x(t,e){let o=e instanceof Error?e.message:String(e),r=t.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 ${t}.${r} Cause: ${o}`}async function nt(){for(let t of [c$1.join(J.homedir(),ie),c$1.join(J.homedir(),ae)])try{let e$1=await promises.readFile(t,"utf-8"),o=JSON.parse(e$1);return e.debug(`Loaded config from ${t}`),o}catch{}return e.debug("No user config found, using defaults"),{}}async function rt(t=process.cwd(),e$1={}){let o=t,r=c$1.parse(o).root;for(;o!==r;){for(let a of ce){let i=c$1.join(o,a);try{let n=await promises.readFile(i,"utf-8"),s=JSON.parse(n);if(!s||typeof s!="object"||Array.isArray(s))throw new Error("configuration root must be a JSON object");return e.debug(`Loaded data-only Workspai config from ${a}`),s}catch(n){if(Y(n))continue;throw new Error(x(i,n))}}for(let a of se){let i=c$1.join(o,a);try{await promises.access(i);}catch(n){if(Y(n))continue;throw new Error(x(i,n))}if(e.debug(`Found config file: ${i}`),!e$1.trustExecutableConfig)throw new Error(`Refusing to execute Workspai config at ${i} without explicit trust. Use a data-only workspai.config.json file, pass --trust-config, or set WORKSPAI_TRUST_CONFIG=1.`);try{let s=await import(pathToFileURL(i).href),l=s.default||s;return e.debug(`Loaded Workspai config from ${a}`),l}catch(n){throw new Error(x(i,n))}}o=c$1.dirname(o);}return e.debug("No Workspai config file found, using defaults"),{}}function it(t,e,o){return {author:o.author||e.workspace?.defaultAuthor||t.author,pythonVersion:o.pythonVersion||e.workspace?.pythonVersion||t.pythonVersion,defaultInstallMethod:o.defaultInstallMethod||e.workspace?.installMethod||t.defaultInstallMethod,defaultKit:o.defaultKit||e.projects?.defaultKit||t.defaultKit,skipGit:o.skipGit??e.projects?.skipGit??t.skipGit,license:o.license||t.license,testRapidKitPath:o.testRapidKitPath||t.testRapidKitPath}}function at(t){return f("DEV_PATH")||t.testRapidKitPath||void 0}var E=class extends Error{constructor(o,r){super(["Workspai workspaces cannot be nested.",`Target: ${o}`,`Containing workspace: ${r}`,"Choose Managed home or pass --output <path> with a location outside the current workspace."].join(`
2
- `));this.targetPath=o;this.containingWorkspacePath=r;this.name="NestedWorkspaceCreationError";}targetPath;containingWorkspacePath;code="WORKSPACE_NESTING_NOT_SUPPORTED"};async function de(t){try{return !!await h.stat(t)}catch{return false}}function pe(t,e){let o=t.indexOf(e);if(o>=0&&o+1<t.length)return t[o+1];let r=t.find(a=>a.startsWith(`${e}=`));if(r)return r.slice(e.length+1)}function ue(t){return t.includes("--here")}async function H(t){let e=c$1.resolve(t);for(;;){let o=[c$1.join(e,".workspai-workspace"),c$1.join(e,".rapidkit-workspace"),c$1.join(e,".workspai","workspace.json"),c$1.join(e,".rapidkit","workspace.json")];if((await Promise.all(o.map(de))).some(Boolean))return e;let r=c$1.dirname(e);if(r===e)return;e=r;}}async function yt(t){let e=c$1.resolve(t),o=await H(c$1.dirname(e));if(o)throw new E(e,o)}async function me(t,e=homedir()){let r=[{value:"managed",label:"Managed home",hint:l(e)}];return await H(t)||r.push({value:"here",label:"Current directory",hint:t}),r}function z(t,e=m.cwd()){if(ue(t))return c$1.resolve(e);let o=pe(t,"--output");if(o)return c$1.resolve(o)}function ht(t,e=m.cwd()){let o=c$1.resolve(t),r=c$1.resolve(e),a=c$1.relative(r,o);return a.length>0&&!a.startsWith("..")&&!c$1.isAbsolute(a)?`cd ${a}`:`cd ${o}`}function kt(t,e={}){let o=e.argv??[],r=e.outputParent??z(o,m.cwd());return m$1(t.trim(),{homeDir:e.homeDir,outputDir:r})}function Pt(t,e,o={}){return t?c$1.resolve(t)===c$1.resolve(e)?true:o.outputParent===void 0:false}async function wt(t,e={}){let o=e.cwd??m.cwd(),r=e.homeDir??homedir(),a=z(t,o);if(a!==void 0)return a;let i=e.hasYes??(t.includes("--yes")||t.includes("-y"));if(!(e.interactive??(!i&&!!m.stdin.isTTY&&!b())))return;let s=await me(o,r);if(s.length===1)return;let{location:l}=await b$1([{type:"rawlist",name:"location",message:"Where should the workspace be created?",choices:s,default:0}]);if(l==="here")return c$1.resolve(o)}var ge=["minimal","python-only","node-only","go-only","java-only","dotnet-only","polyglot","enterprise"],ye=new Set(["minimal","node-only","go-only","java-only","dotnet-only"]),Ft=new Set(["python-only","polyglot","enterprise"]);function he(t){return typeof t=="string"&&ge.includes(t)}function At(t){return he(t)&&ye.has(t)}var X={"python-only":"python","node-only":"node","go-only":"go","java-only":"java","dotnet-only":"dotnet"},ke={python:"Python",node:"Node",go:"Go",java:"Java",dotnet:".NET",php:"PHP",ruby:"Ruby",rust:"Rust",elixir:"Elixir",clojure:"Clojure",scala:"Scala",kotlin:"Kotlin",deno:"Deno",bun:"Bun",c:"C",cpp:"C++",unknown:"Unknown"},Pe={python:"python-only",node:"node-only",go:"go-only",java:"java-only",dotnet:"dotnet-only"},q=["node","deno","bun","python","go","java","kotlin","scala","dotnet","php","ruby","rust","elixir","clojure","c","cpp","unknown"];function v(t){return t==="bun"||t==="deno"?"node":t==="kotlin"||t==="scala"?"java":t}function I(t){return typeof t!="string"||t.trim().length===0?"minimal":t.trim().toLowerCase()}function g(t){if(typeof t!="string")return "unknown";let e=t.trim().toLowerCase();return e==="python"||e==="node"||e==="go"||e==="java"||e==="dotnet"||e==="php"||e==="ruby"||e==="rust"||e==="elixir"||e==="clojure"||e==="scala"||e==="kotlin"||e==="deno"||e==="bun"||e==="c"||e==="cpp"?e:e==="c++"||e==="cplusplus"||e==="cc"||e==="clang++"||e==="g++"?"cpp":e==="clang"||e==="gcc"?"c":"unknown"}function w(t){let e=new Set;for(let o of t)e.add(g(o));return [...e].sort((o,r)=>q.indexOf(o)-q.indexOf(r))}function we(t){let e=w(t).filter(o=>o!=="unknown");if(e.length!==0)return e.length===1?Pe[e[0]]:"polyglot"}function Q(t,e={}){return `npx workspai bootstrap --profile ${t}${e.ci?" --ci --json":""}`}function be(t,e){return t?"none":e==="strict"?"error":"warning"}function y(t){let e=t.ok?void 0:we(t.runtimes)??"polyglot";return {ok:t.ok,checkId:t.checkId,status:t.ok?"passed":"failed",profile:t.profile,runtimes:t.runtimes,message:t.message,recommendedProfile:e,recommendedCommand:e?Q(e):void 0,ciRecommendedCommand:e?Q(e,{ci:true}):void 0,severity:be(t.ok,t.mode)}}function $t(t){let e=I(t.profile),o=w(t.runtimes),r=t.mode??"warn",a=X[e];if(a){let i=o.length===0||o.every(n=>v(n)===a);return y({ok:i,checkId:`profile.${e}`,profile:e,runtimes:o,message:i?`${e} profile validated for discovered projects.`:`${e} profile mismatch: detected runtimes [${o.join(", ")}].`,mode:r})}if(e==="minimal"){let i=o.filter(l=>l!=="unknown"),s=new Set(i.map(l=>v(l))).size<=1;return y({ok:s,checkId:"profile.minimal",profile:e,runtimes:o,message:s?"minimal profile is compatible with detected runtime mix.":`minimal profile mismatch: multiple runtimes detected [${i.join(", ")}].`,mode:r})}return y({ok:true,checkId:`profile.${e}`,profile:e,runtimes:o,message:`${e} profile accepts the detected runtime mix.`,mode:r})}function Kt(t){let e=I(t.profile),o=g(t.runtime),r=t.mode??"warn",a=X[e];if(!a||o==="unknown")return y({ok:true,checkId:`profile.${e}`,profile:e,runtimes:[o],message:o==="unknown"?`Project "${t.subjectLabel}" runtime is unknown; profile compatibility will be checked by workspace doctor.`:`${e} profile accepts project "${t.subjectLabel}".`,mode:r});let i=v(o)===a;return y({ok:i,checkId:`profile.${e}`,profile:e,runtimes:i?[o]:w([a,o]),message:i?`Project "${t.subjectLabel}" is compatible with workspace profile "${e}".`:`Project "${t.subjectLabel}" is ${ke[o]}, but workspace profile is "${e}".`,mode:r})}async function St(t$1){let e=(await Promise.all(t(t$1,"policies.yml").map(async o=>await h.pathExists(o)?o:null))).find(o=>typeof o=="string");if(!e)return "warn";try{return (await h.readFile(e,"utf-8")).match(/^\s*mode:\s*(warn|strict)\s*(?:#.*)?$/m)?.[1]==="strict"?"strict":"warn"}catch{return "warn"}}async function _t(t$1){let e=(await Promise.all(t(t$1,"workspace.json").map(async o=>await h.pathExists(o)?o:null))).find(o=>typeof o=="string");if(!e)return "minimal";try{let o=await h.readJson(e);return I(o.profile)}catch{return "minimal"}}async function Lt(t,e={}){let o=new Set,r=[],a$1=new Set,i=[t];for(;i.length>0;){let n=i.pop();if(!n||a$1.has(n))continue;a$1.add(n);let s=[];try{s=await fe.promises.readdir(n,{withFileTypes:true});}catch{continue}for(let l of s){if(!l.isDirectory()||l.name.startsWith(".")||["node_modules","dist","build","target","coverage","htmlcov"].includes(l.name))continue;let d=c$1.join(n,l.name);if(d!==t&&k$1(d))continue;if((await Promise.all([...u(d,"context.json"),...u(d,"project.json")].map(async ee=>h.pathExists(ee)))).some(Boolean)){r.push(d);continue}i.push(d);}}for(let n of r){if(e.excludeProjectPath&&c$1.resolve(n)===c$1.resolve(e.excludeProjectPath))continue;let s=j(n);o.add(g(m$2(n,s).runtime));}for(let n of await a(t))e.excludeProjectPath&&c$1.resolve(n.path)===c$1.resolve(e.excludeProjectPath)||o.add(g(n.runtime));for(let n of e.additionalRuntimes??[])o.add(g(n));return w(o)}function Nt(t,e={}){let o=e.ci?t.ciRecommendedCommand:t.recommendedCommand;return o?`Recommended: ${o}`:null}export{G as a,je as b,nt as c,rt as d,it as e,at as f,yt as g,ht as h,kt as i,Pt as j,wt as k,Ft as l,At as m,$t as n,Kt as o,St as p,_t as q,Lt as r,Nt as s};
@@ -1 +0,0 @@
1
- import {c}from'./chunk-UE7ART6X.js';import {j,i,d as d$1,f as f$1,c as c$2,e,h}from'./chunk-QBKOPXKC.js';import {f as f$2}from'./chunk-ZKYH44ER.js';import {a as a$1}from'./chunk-25V5XMWB.js';import {c as c$3}from'./chunk-ZI54C2AO.js';import {b}from'./chunk-OA2YJN22.js';import {b as b$1}from'./chunk-NRIMJMTF.js';import {f,i as i$1}from'./chunk-BLEIUQL6.js';import {a}from'./chunk-AFIFZTOY.js';import {d,c as c$1}from'./chunk-EWZZUQBR.js';import {q,p}from'./chunk-ODK4LCEL.js';import C from'path';import _ from'fs-extra';var be=/[\u0000-\u0008\u000b\u000c\u000e-\u001f\u007f]/,we=/(?:^|\s)(?:\/(?:home|Users|private|var|tmp|mnt|opt|srv|root|workspace|workspaces|data|Volumes|etc|usr|run|dev|proc|sys)\/[^\s]+|[A-Za-z]:[\\/][^\s]+|\\\\[^\\\s]+\\[^\s]+)/,ke=/(?:-----BEGIN (?:RSA |EC |OPENSSH )?PRIVATE KEY-----|\b(?:github_pat_|gh[pousr]_|glpat-|npm_|xox[baprs]-|sk-(?:proj-)?)[A-Za-z0-9_-]{12,}|\b(?:AKIA|ASIA)[A-Z0-9]{16}\b|\bAIza[A-Za-z0-9_-]{20,}|\bBearer\s+[A-Za-z0-9._~+/-]{16,}|[a-z][a-z0-9+.-]*:\/\/[^\s:/]+:[^\s@/]+@|\b(?:password|passwd|secret|token|api[_-]?key)\s*[:=]\s*[^\s]{6,})/i,ve=[{category:"test-coverage",patterns:[/\b(?:test\s+)?coverage\b/i,/\bcoverage\s+(?:to|above|at least)\b/i]},{category:"dependency-security",patterns:[/\b(?:dependency|dependencies|package|packages)\b.*\b(?:security|vulnerab|audit)\b/i,/\b(?:security|vulnerab|audit)\b.*\b(?:dependency|dependencies|package|packages)\b/i]},{category:"release-readiness",patterns:[/\brelease[ -]readiness\b/i,/\bready (?:this |the )?(?:workspace|project) for release\b/i,/\bprepare (?:this |the )?(?:workspace|project) for release\b/i,/\bprepare\b[^\n]{0,80}\bfor release\b/i]},{category:"defect-repair",patterns:[/\b(?:fix|repair|resolve|debug)\b.*\b(?:bug|error|failure|issue|regression)\b/i]},{category:"performance",patterns:[/\b(?:performance|latency|throughput|cpu|optimi[sz]e|faster|slower)\b/i,/\b(?:memory\s+(?:allocation|consumption|footprint|leak|pressure|usage)|out[ -]of[ -]memory|heap|ram)\b/i]},{category:"refactor",patterns:[/\b(?:refactor|restructure|decouple|extract|simplify|cleanup|clean up)\b/i]},{category:"documentation",patterns:[/\b(?:document|documentation|readme|guide|tutorial|docs)\b/i]},{category:"feature-change",patterns:[/\b(?:add|build|create|enforce|enhance|harden|implement|improve|introduce|support)\b/i]},{category:"system-understanding",patterns:[/\b(?:understand|explain|map|find|where|how|architecture|analy[sz]e|search)\b/i]}];function ye(e){if(typeof e!="string")throw new Error("Goal intent must be text.");let t=e.trim().replace(/\s+/g," ");if(!t)throw new Error("Goal intent cannot be empty.");if(t.length>2e3)throw new Error("Goal intent exceeds the 2000 character safety limit.");if(be.test(t))throw new Error("Goal intent contains unsupported control characters.");if(we.test(t))throw new Error("Goal intent contains a machine-local absolute path. Use a workspace-relative path or project scope.");if(ke.test(t))throw new Error("Goal intent appears to contain secret material and was not persisted.");return t}function Pe(e){let t=e.match(/\b(?:coverage\D{0,24})?((?:100(?:\.0+)?|\d{1,2}(?:\.\d+)?))\s*(?:%|percent(?:age)?(?:\s+points?)?)/i);if(!t||!/coverage/i.test(e))return null;let r=Number(t[1]);return Number.isFinite(r)&&r>=0&&r<=100?r:null}var re=[{runtime:"cpp",patterns:[/\bc\+\+/i,/\bcpp\b/i]},{runtime:"dotnet",patterns:[/\.net\b/i,/\bdotnet\b/i,/\bc#/i,/\bcsharp\b/i]},{runtime:"node",patterns:[/\bnode(?:\.js)?\b/i,/\btypescript\b/i,/\bjavascript\b/i,/\b(?:js|ts)\b/i]},{runtime:"python",patterns:[/\bpython\b/i,/\bpytest\b/i]},{runtime:"go",patterns:[/\bgolang\b/i,/\bgo(?:\s+(?:test|coverage|tests))\b/i]},{runtime:"java",patterns:[/\bjava\b/i,/\bjunit\b/i,/\bjacoco\b/i]},{runtime:"rust",patterns:[/\brust\b/i,/\bcargo\b/i]},{runtime:"php",patterns:[/\bphp\b/i,/\bphpunit\b/i]},{runtime:"ruby",patterns:[/\bruby\b/i,/\brspec\b/i]},{runtime:"kotlin",patterns:[/\bkotlin\b/i]},{runtime:"scala",patterns:[/\bscala\b/i]},{runtime:"clojure",patterns:[/\bclojure\b/i]},{runtime:"elixir",patterns:[/\belixir\b/i]},{runtime:"deno",patterns:[/\bdeno\b/i]},{runtime:"bun",patterns:[/\bbun\b/i]},{runtime:"c",patterns:[/\bc(?:\s+(?:test|coverage|tests|code))\b/i]}];function je(e){return re.filter(t=>t.patterns.some(r=>r.test(e))).map(t=>t.runtime)}function K(e,t={}){let r=ye(e),n=ve.filter(u=>u.patterns.some(j=>j.test(r))).map(u=>u.category),a=n.some(u=>u!=="feature-change")?n.filter(u=>u!=="feature-change"):n,s=a[0]??"feature-change",l=Pe(r),d=je(r),p=d.length===0&&t.selectedCoverageRuntime?[t.selectedCoverageRuntime]:d,m=[...new Set((t.availableCoverageRuntimes??[]).filter(u=>re.some(j=>j.runtime===u)))].sort(),b=[];return a.length>1&&a[0]!=="test-coverage"&&b.push(`The intent also contains signals for: ${a.slice(1).join(", ")}.`),s==="test-coverage"&&l===null&&b.push("A numeric test coverage target is required for machine verification."),s==="test-coverage"&&p.length>1&&b.push(`The Goal names multiple coverage runtimes: ${p.join(", ")}. Select one runtime per Goal.`),s==="test-coverage"&&p.length===0&&m.length>1&&b.push(`Coverage scope is ambiguous across detected runtimes: ${m.join(", ")}. Name one runtime or language in the Goal.`),s==="test-coverage"&&p.length===1&&m.length>0&&!m.includes(p[0])&&b.push(`The requested ${p[0]} coverage runtime is not present in the selected scope. Detected runtimes: ${m.join(", ")}.`),{original:r,normalized:r.toLocaleLowerCase("en-US"),statement:r.replace(/[.!?]+$/,""),category:s,confidence:a.length===1?"high":a.length>1?"medium":"low",ambiguities:b,...l===null?{}:{requestedTarget:{metric:"test-coverage-percent",operator:"at-least",value:l,...p.length===1?{runtime:p[0]}:{}}}}}function oe(e){let t={"test-coverage":["test suite coverage configuration instrumentation","CI tests LCOV Cobertura JaCoCo LLVM coverage"],"dependency-security":["dependency manifest lockfile security audit vulnerability"],"release-readiness":["release pipeline readiness gates build test deploy"],"defect-repair":["failure error test implementation call path"],"feature-change":["API implementation module dependency tests"],refactor:["module dependency ownership implementation tests"],performance:["performance benchmark latency throughput runtime"],documentation:["documentation README guide architecture decision"],"system-understanding":["architecture service API dependency ownership"]};return [...new Set([e.statement,...t[e.category]])].slice(0,3)}var ae="contracts/workspace-intelligence/goal-pack.v1.json",se="contracts/workspace-intelligence/goal-agent-handoff.v1.json",Ge="contracts/workspace-intelligence/goal-plan-result.v1.json",pe="contracts/workspace-intelligence/goal-index.v1.json",ue=new Set(["node","bun","deno","python","go","java","dotnet","rust","php","ruby","elixir","clojure","scala","kotlin","c","cpp"]);function Ce(e,t){let r=e.match(/[A-Za-z0-9][A-Za-z0-9+#.%_-]*/g)??[],n=new Set(t.map(m=>m.toLocaleLowerCase("en-US").replace(/[^a-z0-9]/g,"")).filter(Boolean)),a=[];for(let m=0;m<r.length;){let b=0;for(let u=Math.min(4,r.length-m);u>=1;u-=1){let j=r.slice(m,m+u).join("").toLocaleLowerCase("en-US").replace(/[^a-z0-9]/g,"");if(n.has(j)){b=u;break}}if(b>0){m+=b;continue}a.push(r[m]),m+=1;}let s=a.findIndex((m,b)=>{let u=m.toLocaleLowerCase("en-US"),j=a[b+1]?.toLocaleLowerCase("en-US");return u==="without"&&["breaking","changing","modifying","removing"].includes(j??"")||u==="while"&&["keeping","maintaining","preserving"].includes(j??"")}),l=s>=2?a.slice(0,s):a,d=l.length>=2?l.join(" "):e;if(s<2)return [d];let p=a.slice(s).filter(m=>!["without","while","breaking","changing","modifying","removing","keeping","maintaining","preserving"].includes(m.toLocaleLowerCase("en-US")));return p.length>0?[d,p.join(" ")]:[d]}function ie(e){return e.split(C.sep).join("/")}function V(e,t){return C.resolve(t.absolutePath??C.join(e,t.path))}function ce(e){let t=e.requested.trim().replace(/^project:/,"");if(!t)throw new Error("Project goal scope must name a project.");let r=C.isAbsolute(t)?C.resolve(t):null,n=e.model.projects.filter(a=>a.name===t||ie(a.path)===ie(t)||r!==null&&V(e.workspacePath,a)===r);if(n.length!==1)throw new Error(n.length===0?`Project goal scope was not found in the canonical model: ${t}`:`Project goal scope is ambiguous in the canonical model: ${t}`);return n[0]}async function Ae(e){let t=await a$1(e);if(t.status==="miss")throw new Error(`Canonical model and live graph evidence are required (${t.reason}). Run \`workspai workspace intelligence run --for-agent generic --strict --json\` or retry with --refresh.`);let{model:r,graph:n}=t;return a(r,"contracts/workspace-intelligence/workspace-model.v1.json","Goal source model"),a(n,"contracts/workspace-intelligence/workspace-knowledge-graph.v1.json","Goal source graph"),b$1(n,r),{model:r,graph:n}}function le(e){let t=e.scope.trim();if(t==="workspace")return {kind:"workspace",projects:e.model.projects.map(n=>n.name).sort(),selectionSource:e.selectionSource,resolution:"selected"};let r=t.startsWith("projects:")?"projects:":t.startsWith("project:")&&t.slice(8).includes(",")?"project:":null;if(r){let n=t.slice(r.length).split(",").map(l=>l.trim()).filter(Boolean);if(n.length<2)throw new Error("A project-set Goal scope must name at least two projects.");let a=n.map(l=>ce({workspacePath:e.workspacePath,model:e.model,requested:l})),s=[...new Set(a.map(l=>l.name))].sort();if(s.length!==n.length)throw new Error("A project-set Goal scope must not contain duplicate projects.");return {kind:"project-set",projects:s,selectionSource:e.selectionSource,resolution:"selected"}}if(t)return {kind:"project",projects:[ce({workspacePath:e.workspacePath,model:e.model,requested:t}).name],selectionSource:e.selectionSource,resolution:"selected"};throw new Error("Goal scope cannot be empty.")}async function Re(e){if(e.explicitScope?.trim())return {scope:le({workspacePath:e.workspacePath,model:e.model,scope:e.explicitScope,selectionSource:"explicit"}),selectionRequired:false};if(e.invocationProjectPath){let t=C.resolve(e.invocationProjectPath),r=e.model.projects.filter(n=>V(e.workspacePath,n)===t);if(r.length!==1)throw new Error("The invocation project is not represented uniquely in the canonical workspace model. Refresh intelligence or pass --scope explicitly.");return {scope:{kind:"project",projects:[r[0].name],selectionSource:"invocation-project",resolution:"selected"},selectionRequired:false}}if(e.model.projects.length===1)return {scope:{kind:"project",projects:[e.model.projects[0].name],selectionSource:"single-project-workspace",resolution:"selected"},selectionRequired:false};if(e.selectScope){let t=await e.selectScope({workspaceName:e.model.workspace.name,projects:e.model.projects.map(n=>({name:n.name,runtime:n.runtime,runtimeCandidates:[...n.runtimeCandidates].sort(),framework:n.framework})).sort((n,a)=>n.name.localeCompare(a.name))}),r=t.kind==="workspace"?"workspace":t.projects.length===1?`project:${t.projects[0]}`:`projects:${t.projects.join(",")}`;return {scope:le({workspacePath:e.workspacePath,model:e.model,scope:r,selectionSource:"interactive"}),selectionRequired:false}}return {scope:{kind:"workspace",projects:e.model.projects.map(t=>t.name).sort(),selectionSource:"workspace",resolution:"selection-required"},selectionRequired:true}}function Se(e,t){if(t.kind==="workspace")return {entities:e.quality.entityCount,relationships:e.quality.relationCount,proofs:e.quality.proofCount,unresolved:e.quality.unknownCount,proofCoveragePercent:Number((e.quality.relationProofCoverageRatio*100).toFixed(2))};let r=new Set(t.projects),n=e.entities.filter(p=>p.projectId!==void 0&&r.has(p.projectId)),a=new Set(n.map(p=>p.id)),s=e.relations.filter(p=>a.has(p.from)||a.has(p.to)),l=new Set([...n.flatMap(p=>p.proofIds),...s.flatMap(p=>p.proofIds)]),d=s.filter(p=>p.proofIds.length>0).length;return {entities:n.length,relationships:s.length,proofs:l.size,unresolved:s.length-d,proofCoveragePercent:s.length===0?100:Number((d/s.length*100).toFixed(2))}}function Ee(e){let t=new Map;for(let n of e){let a=t.get(n.kind)??[];a.push(n),t.set(n.kind,a);}let r=[];for(let n=0;[...t.values()].some(a=>n<a.length);n+=1)for(let a of t.values()){let s=a[n];s&&r.push(s);}return r}async function Ie(e){let t=C.join(e.workspacePath,p.intelligenceRun),r=await _.readJson(t).catch(()=>null),a=(Array.isArray(r?.stages)?r.stages:[]).filter(o=>o.status==="blocked"||o.status==="failed").map(o=>String(o.id??"unknown")).sort(),s=r?.status,l={status:s==="passed"?"passed":s==="blocked"||s==="failed"?"blocked":"unknown",artifact:p.intelligenceRun,blockedStages:a},d={status:"not-applicable",runtime:null,runtimeChoices:[],runner:null,existingEvidence:[],prerequisites:[]};if(e.intent.category==="test-coverage"){let o=e.intent.requestedTarget?.runtime;if(e.intent.ambiguities.some(P=>P.startsWith("Coverage scope is ambiguous")||P.startsWith("The Goal names multiple coverage runtimes")||P.startsWith("The selected projects do not share a common canonical coverage runtime")||P.startsWith("The requested ")))d={status:"requires-setup",runtime:o??null,runtimeChoices:e.coverageRuntimeChoices,runner:null,existingEvidence:[],prerequisites:["Select exactly one detected runtime or language for this coverage Goal."]};else {let P=o?e.projects.filter(c=>c.runtimeCandidates.includes(o)):e.projects,i=await Promise.all(P.map(async c=>({project:c,capability:await c$3(V(e.workspacePath,c),o??(ue.has(c.runtime)?c.runtime:"unknown"))}))),h=i.map(c=>c.capability.status);d={status:h.includes("unsupported")?"unsupported":h.includes("requires-setup")?"requires-setup":"available",runtime:i.length===1?i[0].capability.runtime:[...new Set(i.map(c=>c.capability.runtime))].join(","),runtimeChoices:e.coverageRuntimeChoices,runner:i.length===1?i[0].capability.runner:[...new Set(i.flatMap(c=>c.capability.runner?[c.capability.runner]:[]))].join(",")||null,existingEvidence:i.flatMap(c=>c.capability.existingEvidence.map(A=>({project:c.project.name,...A}))).filter((c,A,w)=>w.findIndex(k=>k.project===c.project&&k.path===c.path&&k.sha256===c.sha256)===A).sort((c,A)=>c.project.localeCompare(A.project)||c.path.localeCompare(A.path)),prerequisites:[...new Set(i.flatMap(c=>c.capability.prerequisites))].sort()};}}let p$1=oe(e.intent),m=[...Ce(p$1[0],e.projects.map(o=>o.name)),...p$1.slice(1)].filter((o,y,P)=>P.indexOf(o)===y).slice(0,3),b=m.map((o,y)=>{let P=o.match(/[A-Za-z0-9][A-Za-z0-9+#.%_-]*/g)?.length??0,i=y===0&&P>=4?2:1,h=e.projects.map(w=>{let k=G=>f$2(e.graph,{query:o,projectId:w.name,...G?{kind:G}:{},limit:60,relationsPerEntity:0,minimumTermMatches:i}).entities,S=k(),de=[...new Set(e.graph.entities.filter(G=>G.projectId===w.name||G.projectId===void 0&&G.identity.scope==="workspace").map(G=>G.kind))].flatMap(G=>k(G).slice(0,8)),U=[...S,...de];return U.filter((G,me)=>U.findIndex(ge=>ge.id===G.id)===me)}),c=[],A=new Set;for(let w=0;h.some(k=>w<k.length);w+=1)for(let k of h){let S=k[w];!S||A.has(S.id)||(A.add(S.id),c.push(S));}return Ee(c)}),u={"test-coverage":["test-suite"],"dependency-security":["package","module"],"release-readiness":["pipeline","deployment","lifecycle-stage"],"defect-repair":["test-suite","lifecycle-stage"],"feature-change":["project","runtime-unit","api","package","module","test-suite"],refactor:["package","module","api","test-suite"],performance:["lifecycle-stage","test-suite","pipeline"],documentation:["document","decision"],"system-understanding":["project","service","api","package","protocol"]},j=new Set(e.projects.map(o=>o.name)),v=e.graph.entities.filter(o=>o.proofIds.length>0&&(!o.projectId||j.has(o.projectId))&&u[e.intent.category].includes(o.kind)).sort((o,y)=>u[e.intent.category].indexOf(o.kind)-u[e.intent.category].indexOf(y.kind)||o.label.localeCompare(y.label)),f=[],M=new Set,E=o=>{!o||f.length>=20||M.has(o.id)||(M.add(o.id),f.push(o));},I=(e.intent.statement.match(/[A-Za-z][A-Za-z0-9+#.-]{1,}/g)??[]).length>=2,g=I?b[0]??[]:[];for(let o of g.slice(0,12))E(o);if(!I)for(let o of v)E(o);for(let o=0;f.length<20&&b.slice(1).some(y=>o<y.length);o+=1)for(let y of b.slice(1))E(y[o]);if(I)for(let o of v)E(o);for(let o of g.slice(12))E(o);let T=f.map(o=>({entityId:o.id,kind:o.kind,label:o.label,proofIds:o.proofIds.slice(0,12)})),L=b[0]?.length??0;return {workspaceIntelligence:l,measurement:d,retrieval:{status:I&&L>=3?"grounded":T.length>0?"partial":"empty",strategy:"deterministic-category-v1",queries:m,anchors:T}}}async function Te(e$1){let t=C.join(e$1,f$1);if(!await _.pathExists(t))return {schemaVersion:e,generatedAt:new Date(0).toISOString(),activeGoalId:null,goals:[]};let r=await _.readJson(t);a(r,pe,"Goal index");try{i(r);}catch(n){let a=h(r);if(!(a!==null&&n instanceof Error&&n.message==="Goal index is inconsistent: activeGoalId must identify the only selected actionable lifecycle entry.")||!a)throw n;return a}return r}function xe(e$1,t,r){let n=e$1.goals.find(l=>l.id===t.id),a=t.state==="ready-to-plan",s={id:t.id,fingerprint:t.fingerprint,objective:t.intent.statement,category:t.intent.category,state:t.state,lifecycle:n?.lifecycle==="cancelled"?"cancelled":a?"active":"planned",scope:t.scope,createdAt:n?.createdAt??t.generatedAt,updatedAt:r,goalPack:t.artifacts.goalPack,agentHandoff:t.artifacts.agentHandoff,...n?.verifiedGoalId?{verifiedGoalId:n.verifiedGoalId}:{},...n?.repairTransactionId?{repairTransactionId:n.repairTransactionId}:{},...n?.repairTransactionIds?{repairTransactionIds:n.repairTransactionIds}:{},...n?.changeTransactionId?{changeTransactionId:n.changeTransactionId}:{},...n?.changeTransactionIds?{changeTransactionIds:n.changeTransactionIds}:{},...n?.verificationReceipt?{verificationReceipt:n.verificationReceipt}:{}};return {schemaVersion:e,generatedAt:r,activeGoalId:s.lifecycle==="active"?t.id:e$1.activeGoalId===t.id?null:e$1.activeGoalId,goals:[...e$1.goals.filter(l=>l.id!==t.id).map(l=>s.lifecycle==="active"&&l.lifecycle==="active"?{...l,lifecycle:"planned",updatedAt:r}:l),s].sort((l,d)=>l.id.localeCompare(d.id))}}async function et(e){let t=b({startPath:C.resolve(e.startPath),explicitWorkspacePath:e.workspacePath,strict:true,requireProjectMembership:!e.scope?.trim()});if(!t)throw new Error("No canonical Workspai workspace could be resolved.");let r=C.resolve(t.workspacePath);e.refresh&&await c({workspacePath:r,strict:false,agent:"generic"});let{model:n,graph:a$1}=await Ae(r),s=await Re({workspacePath:r,invocationProjectPath:t.projectPath,model:n,explicitScope:e.scope,selectScope:e.selectScope}),l=s.scope,d$2=n.projects.filter(i=>l.projects.includes(i.name));if(d$2.length===0)throw new Error("A Goal Pack requires at least one registered project in its selected scope.");let p$1=e.maxAttempts??5;if(!Number.isInteger(p$1)||p$1<1||p$1>25)throw new Error("--max-attempts must be an integer from 1 to 25.");let m=new Date().toISOString(),b$1=d(n),u=d$2.map(i=>({name:i.name,runtimes:[...new Set(i.runtimeCandidates.filter(h=>ue.has(h)))].sort()})),j$1=[...new Set(u.flatMap(i=>i.runtimes))].sort(),v=u.length<=1?j$1:u[0].runtimes.filter(i=>u.every(h=>h.runtimes.includes(i))),f$2=K(e.intent,{availableCoverageRuntimes:v,...e.runtime?{selectedCoverageRuntime:e.runtime}:v.length===1?{selectedCoverageRuntime:v[0]}:{}});if(e.runtime&&!v.includes(e.runtime)){let i=e.runtime,h=u.filter(c=>!c.runtimes.includes(i)).map(c=>c.name);throw new Error(d$2.length>1&&h.length>0?`--runtime ${e.runtime} is not canonical for every project in the selected Goal scope. Missing from: ${h.join(", ")}. Split the projects into runtime-compatible Goal scopes.`:`--runtime ${e.runtime} is not present in the canonical Workspace Model for the selected Goal scope. Available runtimes: ${v.join(", ")||"none"}.`)}if(e.runtime&&f$2.category!=="test-coverage")throw new Error("--runtime is valid only for a test-coverage Goal.");if(e.runtime&&f$2.requestedTarget?.runtime&&f$2.requestedTarget.runtime!==e.runtime)throw new Error(`--runtime ${e.runtime} conflicts with the ${f$2.requestedTarget.runtime} runtime named in the Goal intent.`);if(!s.selectionRequired&&f$2.category==="test-coverage"&&f$2.requestedTarget&&!f$2.requestedTarget.runtime&&v.length>1&&!e.runtime&&e.selectCoverageRuntime){let i=await e.selectCoverageRuntime({workspaceName:n.workspace.name,scope:l,projects:d$2.map(h=>({name:h.name,runtime:h.runtime,runtimeCandidates:[...h.runtimeCandidates].sort()})),runtimes:v});if(!v.includes(i))throw new Error("The selected coverage runtime is outside the canonical Goal scope.");f$2=K(e.intent,{availableCoverageRuntimes:v,selectedCoverageRuntime:i});}!s.selectionRequired&&f$2.category==="test-coverage"&&d$2.length>1&&v.length===0&&(f$2={...f$2,ambiguities:[`The selected projects do not share a common canonical coverage runtime: ${u.map(i=>`${i.name} (${i.runtimes.join(", ")||"none"})`).join("; ")}. Split them into runtime-compatible Goal scopes so every selected project is verified.`,...f$2.ambiguities]}),s.selectionRequired&&(f$2={...f$2,ambiguities:[`Goal scope is unresolved across ${l.projects.length} registered projects: ${l.projects.join(", ")}. Select one project, multiple projects, or the entire workspace.`,...f$2.ambiguities]});let M=await Ie({workspacePath:r,projects:d$2,graph:a$1,intent:f$2,coverageRuntimeChoices:v}),E={generatedAt:m,intent:f$2,workspaceName:n.workspace.name,scope:l,sourceBinding:{model:{artifact:p.model,schemaVersion:q.model,hashAlgorithm:"sha256",hashSemantics:"workspace-model-structural-v1",hash:b$1,generatedAt:n.generatedAt},graph:{artifact:p.knowledgeGraph,schemaVersion:q.knowledgeGraph,hashAlgorithm:"sha256",hashSemantics:"canonical-json-v1",hash:c$1(a$1),generatedAt:a$1.generatedAt,modelHash:a$1.source.hash,...a$1.source.inputs?.hash?{inputHash:a$1.source.inputs.hash}:{}}},preflight:M,baseline:{projectCount:d$2.length,runtimes:[...new Set(d$2.flatMap(i=>i.runtimeCandidates))].sort(),frameworks:[...new Set(d$2.map(i=>i.framework))].sort(),graph:Se(a$1,l)},maxAttempts:p$1,consumer:e.consumer??"generic"},I={digestCanonical:c$1},{goalPack:g,handoff:T}=j(E,I);a(g,ae,"Goal Pack"),a(T,se,"Goal agent handoff");let L=false,o=async()=>{let i=C.join(r,g.artifacts.goalPack),h=C.join(r,g.artifacts.agentHandoff),[c,A]=await Promise.all([_.pathExists(i),_.pathExists(h)]);if(c!==A)throw new Error(`Goal Pack instance is incomplete and cannot be resumed: ${g.id}`);if(!c)return;let[w,k]=await Promise.all([_.readJson(i),_.readJson(h)]);a(w,ae,"Persisted Goal Pack"),a(k,se,"Persisted goal agent handoff");let S=j({...E,generatedAt:w.generatedAt,sourceBinding:w.sourceBinding},I);if(w.id!==g.id||k.goalId!==g.id||c$1(w)!==c$1(S.goalPack)||c$1(k)!==c$1(S.handoff))throw new Error(`Goal Pack instance failed immutable integrity validation: ${g.id}`);g=w,T=k,L=true;};if(e.dryRun)await o();else {let i$2=`.workspai/goals/${g.id}/publication`;await f(r,i$2,async()=>{await o();let h=xe(await Te(r),g,new Date().toISOString());a(h,pe,"Goal index"),i(h),await i$1(r,d$1,L?[{relativePath:d$1,payload:g},{relativePath:f$1,payload:h}]:[{relativePath:g.artifacts.goalPack,payload:g},{relativePath:g.artifacts.agentHandoff,payload:T},{relativePath:d$1,payload:g},{relativePath:f$1,payload:h}]);});}let y=[g.artifacts.goalPack,g.artifacts.agentHandoff,d$1,f$1],P={schemaVersion:c$2,result:g.state==="needs-confirmation"?"needs-confirmation":g.state==="blocked"?"blocked":g.state==="needs-evidence"?"needs-evidence":"planned",resolution:{source:t.source,invocationScope:t.projectPath?"project":"workspace"},goalPack:g,agentHandoff:T,writtenArtifacts:e.dryRun?[]:L?[d$1,f$1]:y,dryRun:e.dryRun===true,resumed:L};return a(P,Ge,"Goal plan result"),P}export{et as a};