workspai 0.46.0 → 0.48.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 (143) hide show
  1. package/README.md +225 -81
  2. package/contracts/agent-customization-pack.v1.json +11 -1
  3. package/contracts/bootstrap-compliance.v1.json +14 -0
  4. package/contracts/cli-runtime-command-inventory.v1.snapshot.json +4 -0
  5. package/contracts/extension-cli-compatibility.v1.json +13 -2
  6. package/contracts/mirror-ops.v1.json +16 -0
  7. package/contracts/published-contract-catalog.v1.json +59 -1
  8. package/contracts/runtime-command-surface.v1.json +294 -2
  9. package/contracts/transparency-evidence.v1.json +13 -0
  10. package/contracts/workspace-contract.v1.json +78 -0
  11. package/contracts/workspace-intelligence/model-usage-event.v1.json +82 -0
  12. package/contracts/workspace-intelligence/workspace-context.v1.json +20 -0
  13. package/contracts/workspace-intelligence/workspace-graph-token-efficiency.v1.json +72 -0
  14. package/contracts/workspace-intelligence/workspace-intelligence-evaluation-comparison.v1.json +53 -0
  15. package/contracts/workspace-intelligence/workspace-intelligence-evaluation.v1.json +120 -0
  16. package/contracts/workspace-intelligence/workspace-intelligence-run.v1.json +6 -1
  17. package/contracts/workspace-intelligence/workspace-knowledge-graph-change-overlay.v1.json +200 -0
  18. package/contracts/workspace-intelligence/workspace-knowledge-graph.v1.json +260 -0
  19. package/contracts/workspace-intelligence/workspace-knowledge-search.v1.json +60 -0
  20. package/contracts/workspace-intelligence-architecture.v1.json +37 -5
  21. package/contracts/workspace-intelligence-chain.v1.json +58 -6
  22. package/contracts/workspace-share-bundle.v1.json +16 -0
  23. package/dist/analyze-EEEU3MIF.js +1 -0
  24. package/dist/artifact-remediation-plan-SPOUHMK5.js +3 -0
  25. package/dist/autopilot-release-XGVXPOZI.js +1 -0
  26. package/dist/chunk-32OJDBIG.js +2 -0
  27. package/dist/chunk-37CVKXBD.js +1 -0
  28. package/dist/chunk-3NU32T4A.js +2 -0
  29. package/dist/chunk-3VFA7D5T.js +1 -0
  30. package/dist/chunk-4HDYADHT.js +13 -0
  31. package/dist/chunk-54EP5CEV.js +8 -0
  32. package/dist/chunk-5S3DJQEP.js +8 -0
  33. package/dist/chunk-AFL3ACCR.js +2 -0
  34. package/dist/{chunk-VFDM65IE.js → chunk-BFLJ2R4D.js} +22 -22
  35. package/dist/chunk-BGPXQQNY.js +4 -0
  36. package/dist/chunk-BMWFQXGW.js +1 -0
  37. package/dist/{chunk-UQWOVV6V.js → chunk-CRHYBQI3.js} +1 -1
  38. package/dist/chunk-CV5HKU4P.js +1 -0
  39. package/dist/chunk-ESLPI3XZ.js +1 -0
  40. package/dist/chunk-FB7SCXAZ.js +1 -0
  41. package/dist/{chunk-WPEEC5BX.js → chunk-HDXNIN4N.js} +1 -1
  42. package/dist/chunk-HZDXO65G.js +36 -0
  43. package/dist/{chunk-J5PIZCAU.js → chunk-I46XEIPL.js} +1 -1
  44. package/dist/chunk-J5ENLXDF.js +1 -0
  45. package/dist/chunk-KB44JP4M.js +2 -0
  46. package/dist/chunk-LHOZXC2M.js +2 -0
  47. package/dist/chunk-NAJCUQ4X.js +2 -0
  48. package/dist/chunk-OA537ZQ5.js +1 -0
  49. package/dist/chunk-OW42TZFB.js +1 -0
  50. package/dist/chunk-P3D5YQB2.js +1 -0
  51. package/dist/chunk-PHXQR6PX.js +2 -0
  52. package/dist/{chunk-ZKAI3PJE.js → chunk-PRTR2DQ2.js} +1 -1
  53. package/dist/{chunk-QA5BGEQW.js → chunk-QNONOO4F.js} +1 -1
  54. package/dist/chunk-RHQW3DTP.js +1 -0
  55. package/dist/chunk-T4YR4RAI.js +2 -0
  56. package/dist/chunk-THIOE2PB.js +2 -0
  57. package/dist/{chunk-4LGXSBCN.js → chunk-VU7NZHPM.js} +1 -1
  58. package/dist/chunk-WDKNMTJQ.js +1 -0
  59. package/dist/{chunk-YUATNVOT.js → chunk-Y5UJLPS4.js} +16 -16
  60. package/dist/{chunk-6IIZJQLV.js → chunk-YJZOMRAS.js} +1 -1
  61. package/dist/{create-WCV3L6XH.js → create-DBQNAMKP.js} +1 -1
  62. package/dist/{doctor-5BWM2EMJ.js → doctor-4NNUDNGZ.js} +1 -1
  63. package/dist/{dotnet-webapi-clean-6TVFBTVI.js → dotnet-webapi-clean-A6MVDYXX.js} +4 -4
  64. package/dist/{gofiber-standard-2BL7GWZB.js → gofiber-standard-I5YPQG5V.js} +1 -1
  65. package/dist/{gogin-standard-XGP3KBXA.js → gogin-standard-VY2L4QT5.js} +1 -1
  66. package/dist/index.d.ts +56 -14
  67. package/dist/index.js +322 -320
  68. package/dist/pipeline-TQM43A3K.js +5 -0
  69. package/dist/{springboot-standard-JJNUID6M.js → springboot-standard-55XKCBIZ.js} +4 -4
  70. package/dist/{workspace-7OXW5YTJ.js → workspace-NCWRINEF.js} +1 -1
  71. package/dist/{workspace-agent-sync-O4IA6VOA.js → workspace-agent-sync-662QHXGF.js} +1 -1
  72. package/dist/{workspace-archive-H74NBBNW.js → workspace-archive-P76EDIUG.js} +1 -1
  73. package/dist/{workspace-context-R7IPUBPG.js → workspace-context-23YYCUCP.js} +1 -1
  74. package/dist/workspace-contract-TU2I7GC2.js +1 -0
  75. package/dist/workspace-dependency-graph-BP4EXYQ5.js +1 -0
  76. package/dist/workspace-explain-MWUEN643.js +1 -0
  77. package/dist/workspace-explain-contract-ZPI3JXJU.js +1 -0
  78. package/dist/{workspace-feedback-REOS36ZZ.js → workspace-feedback-SUVH2LUJ.js} +1 -1
  79. package/dist/{workspace-foundation-KXT4QI5O.js → workspace-foundation-WXJ6I7ES.js} +1 -1
  80. package/dist/workspace-graph-token-efficiency-CFGFCJ5V.js +1 -0
  81. package/dist/{workspace-history-OGOVSKZG.js → workspace-history-BANOJRQ2.js} +1 -1
  82. package/dist/workspace-intelligence-MFJE7W67.js +1 -0
  83. package/dist/workspace-intelligence-evaluation-IPH7M3WV.js +1 -0
  84. package/dist/workspace-intelligence-runner-THYLHHMF.js +1 -0
  85. package/dist/workspace-knowledge-graph-ARDC6HHG.js +1 -0
  86. package/dist/workspace-knowledge-graph-change-overlay-XG6FC4IX.js +1 -0
  87. package/dist/workspace-knowledge-graph-export-UYAYFTWX.js +10 -0
  88. package/dist/workspace-knowledge-graph-query-VOSPPH4W.js +1 -0
  89. package/dist/workspace-mcp-serve-EZR6O76D.js +3 -0
  90. package/dist/workspace-model-7OU2M3LE.js +1 -0
  91. package/dist/workspace-model-hash-MHXK5MEI.js +1 -0
  92. package/dist/{workspace-registry-summary-SZ46R5PD.js → workspace-registry-summary-ORDK7A36.js} +1 -1
  93. package/dist/workspace-run-RLIYSOTN.js +1 -0
  94. package/dist/{workspace-verify-MFQ7IXGD.js → workspace-verify-EBVL7FWT.js} +1 -1
  95. package/dist/workspace-watch-3BPGLFLB.js +1 -0
  96. package/docs/AI_DYNAMIC_INTEGRATION.md +73 -428
  97. package/docs/AI_EXAMPLES.md +37 -395
  98. package/docs/AI_FEATURES.md +76 -456
  99. package/docs/AI_QUICKSTART.md +49 -212
  100. package/docs/GLOSSARY.md +64 -0
  101. package/docs/OPEN_SOURCE_USER_SCENARIOS.md +68 -7
  102. package/docs/README.md +70 -41
  103. package/docs/README_CONTENT_CONTRACT.md +154 -0
  104. package/docs/commands-reference.md +64 -4
  105. package/docs/config-file-guide.md +6 -2
  106. package/docs/contracts/ARTIFACT_CATALOG.md +76 -37
  107. package/docs/contracts/README.md +47 -8
  108. package/docs/graph-benchmark-methodology.md +121 -0
  109. package/docs/workspace-intelligence-evaluation.md +147 -0
  110. package/docs/workspace-knowledge-graph.md +316 -0
  111. package/docs/workspace-operations.md +49 -0
  112. package/package.json +2 -1
  113. package/dist/analyze-BEBEZSZK.js +0 -1
  114. package/dist/artifact-remediation-plan-FFQSESAM.js +0 -3
  115. package/dist/autopilot-release-WUR4CQIT.js +0 -1
  116. package/dist/chunk-2G7FASAO.js +0 -2
  117. package/dist/chunk-4EPHWD27.js +0 -8
  118. package/dist/chunk-CVHMUSRX.js +0 -1
  119. package/dist/chunk-DIPD72H4.js +0 -2
  120. package/dist/chunk-EFYHGCGX.js +0 -2
  121. package/dist/chunk-FWRXA435.js +0 -2
  122. package/dist/chunk-HDURFXW5.js +0 -2
  123. package/dist/chunk-HMUKBW2S.js +0 -4
  124. package/dist/chunk-K4WNYXKK.js +0 -33
  125. package/dist/chunk-LG6RFLPZ.js +0 -1
  126. package/dist/chunk-N7DV5L7C.js +0 -1
  127. package/dist/chunk-PRBVYW3T.js +0 -1
  128. package/dist/chunk-QZLIURER.js +0 -13
  129. package/dist/chunk-RIEF2DDX.js +0 -8
  130. package/dist/chunk-SXMTSV5M.js +0 -1
  131. package/dist/chunk-SXPY523X.js +0 -1
  132. package/dist/chunk-V3LRQZ36.js +0 -1
  133. package/dist/chunk-WYFPXTTS.js +0 -2
  134. package/dist/pipeline-ORIWVVYM.js +0 -5
  135. package/dist/workspace-contract-HKCMOMFE.js +0 -1
  136. package/dist/workspace-explain-GOPQYTPQ.js +0 -1
  137. package/dist/workspace-explain-contract-SVFJAAEI.js +0 -1
  138. package/dist/workspace-intelligence-7IESQSXY.js +0 -1
  139. package/dist/workspace-intelligence-runner-6GJ5M4HB.js +0 -1
  140. package/dist/workspace-mcp-serve-FRVWBO36.js +0 -3
  141. package/dist/workspace-model-PPYX7B4S.js +0 -1
  142. package/dist/workspace-run-V3KKHTVF.js +0 -1
  143. package/dist/workspace-watch-SOPZHRWA.js +0 -1
@@ -1,436 +1,81 @@
1
- # 🔄 Dynamic AI Integration with Python Core
1
+ # AI Recommender Architecture
2
2
 
3
- > **Date:** January 1, 2026
4
- > **Implementation:** Dynamic module catalog fetching from Python Core
3
+ This document describes the optional module recommender implementation for
4
+ contributors. It does not define the canonical Workspace Intelligence chain.
5
5
 
6
- ---
6
+ ## Runtime flow
7
7
 
8
- ## 🎯 Summary
9
-
10
- AI system uses a **dynamic runtime catalog** and fetches module metadata from **RapidKit Python Core** instead of relying only on hardcoded entries.
11
-
12
- ### Before (Static):
13
-
14
- ```typescript
15
- // ❌ Hardcoded fixed subset
16
- export const MODULE_CATALOG = [
17
- { id: 'authentication-core', ... },
18
- // ... 10 more
19
- ]
20
- ```
21
-
22
- ### After (Dynamic):
23
-
24
- ```typescript
25
- // Fetches through the validated Core bridge
26
- export async function getModuleCatalog() {
27
- const result = await runCoreRapidkitCapture(
28
- ['modules', 'list', '--json-schema', '1'],
29
- { preferWorkspaceVenv: true }
30
- );
31
- return parseModules(result.stdout);
32
- }
33
- ```
34
-
35
- ---
36
-
37
- ## 📊 Architecture
38
-
39
- ### Data Flow
40
-
41
- ```
42
- User Query
8
+ ```text
9
+ ai recommend
43
10
 
44
- AI Recommender
11
+ load user configuration and provider mode
45
12
 
46
- getModuleCatalog()
13
+ load module catalog + compatible embeddings
47
14
 
48
- ├─ Try through Core bridge: modules list --json-schema 1
49
- │ └─ Success: Return Python modules (runtime count)
50
- │ └─ Fail: Return fallback catalog (baseline subset)
15
+ embed the query
51
16
 
52
- Generate Embeddings
17
+ rank by cosine similarity
53
18
 
54
- Cosine Similarity
55
-
56
- Return Top Recommendations
57
- ```
58
-
59
- ---
60
-
61
- ## 🔧 Implementation Details
62
-
63
- ### 1. Dynamic Module Fetching (`src/ai/module-catalog.ts`)
64
-
65
- **Features:**
66
-
67
- - Calls the Core bridge with `modules list --json-schema 1`
68
- - 5-minute cache (reduces Python calls)
69
- - Fallback to hardcoded catalog if Python not available
70
- - Validates the bridge result and falls back on failure
71
- - ✅ Category and framework mapping
72
-
73
- **Code:**
74
-
75
- ```typescript
76
- export async function getModuleCatalog(): Promise<ModuleMetadata[]> {
77
- // Check cache
78
- if (cachedModules && Date.now() - lastFetchTime < CACHE_TTL) {
79
- return cachedModules;
80
- }
81
-
82
- // Fetch from Python Core
83
- try {
84
- const result = await runCoreRapidkitCapture(
85
- ['modules', 'list', '--json-schema', '1'],
86
- { preferWorkspaceVenv: true }
87
- );
88
- const modules = parseModules(result.stdout);
89
- cachedModules = modules;
90
- return modules;
91
- } catch (error) {
92
- console.warn('⚠️ Using fallback catalog');
93
- return FALLBACK_MODULE_CATALOG;
94
- }
95
- }
96
- ```
97
-
98
- ---
99
-
100
- ### 2. Module Parsing
101
-
102
- **Handles different Python CLI output formats:**
103
-
104
- ```typescript
105
- // Format 1: Array
106
- ["module1", "module2"]
107
-
108
- // Format 2: Object with modules key
109
- { "modules": [...] }
110
-
111
- // Format 3: Object with data key
112
- { "data": [...] }
113
- ```
114
-
115
- **Category Mapping:**
116
-
117
- ```typescript
118
- Python Category → TypeScript Type
119
- ├─ "auth" → "auth"
120
- ├─ "authentication" → "auth"
121
- ├─ "database" → "database"
122
- ├─ "payment" → "payment"
123
- ├─ "billing" → "payment"
124
- └─ etc.
125
- ```
126
-
127
- ---
128
-
129
- ### 3. Cache Strategy
130
-
131
- **TTL: 5 minutes**
132
-
133
- ```
134
- First call:
135
- ├─ Fetch from Python Core (duration depends on environment)
136
- ├─ Cache result
137
- └─ Return
138
-
139
- Subsequent calls (within 5 min):
140
- ├─ Return cached
141
- └─ Avoid another Core bridge invocation
142
-
143
- After 5 min:
144
- ├─ Re-fetch from Python
145
- └─ Update cache
146
- ```
147
-
148
- **Benefits:**
149
-
150
- - Cached responses avoid repeated bridge calls
151
- - Runtime catalog refreshes after five minutes
152
- - Provider and Core latency remain environment-dependent
153
-
154
- ---
155
-
156
- ### 4. Fallback Mechanism
157
-
158
- **Graceful degradation:**
159
-
160
- ```
161
- Try Python Core:
162
- ├─ Success → Use runtime module catalog ✅
163
- ├─ Python not in PATH → Use fallback subset ⚠️
164
- ├─ Command timeout → Use fallback subset ⚠️
165
- └─ Parse error → Use fallback subset ⚠️
166
- ```
167
-
168
- **Fallback catalog:**
169
-
170
- - Baseline core modules (hardcoded subset)
171
- - Authentication, database, payment, etc.
172
- - Enough for basic recommendations
173
-
174
- ---
175
-
176
- ### 5. Embedding Generation
177
-
178
- **Now dynamic:**
179
-
180
- ```bash
181
- # Old: Generated from fixed hardcoded subset
182
- npx tsx src/ai/generate-embeddings.ts
183
-
184
- # New: Fetches from Python Core first
185
- # → Gets runtime module catalog
186
- # → Generates embeddings for all discovered modules
187
- # → Saves to data/modules-embeddings.json
188
- ```
189
-
190
- **Output:**
191
-
192
- ```json
193
- {
194
- "model": "text-embedding-3-small",
195
- "dimension": 1536,
196
- "generated_at": "2026-01-01T...",
197
- "modules": [
198
- {
199
- "id": "authentication-core",
200
- "name": "Authentication Core",
201
- "embedding": [0.123, -0.456, ...]
202
- }
203
- // ... runtime modules (from Python)
204
- ]
205
- }
206
- ```
207
-
208
- ---
209
-
210
- ## 🚀 Usage Examples
211
-
212
- ### Example 1: With Python Core Available
213
-
214
- ```bash
215
- $ workspai ai recommend "I need user authentication"
216
-
217
- # Behind the scenes:
218
- # 1. Calls the Core bridge: modules list --json-schema 1
219
- # 2. Gets runtime module catalog from Python Core
220
- # 3. Generates query embedding
221
- # 4. Compares with catalog embeddings
222
- # 5. Returns top 5 recommendations
223
-
224
- 📦 Recommended Modules:
225
- 1. authentication-core ⭐ (98% match)
226
- 2. users-core ⭐ (92% match)
227
- 3. session-management (88% match)
228
- ...
229
- ```
230
-
231
- ---
232
-
233
- ### Example 2: Without Python Core (Fallback)
234
-
235
- ```bash
236
- $ workspai ai recommend "payment processing"
237
-
238
- # Console output:
239
- ⚠️ RapidKit Python Core not found in PATH
240
- Using fallback module catalog (baseline subset)
241
-
242
- # Still works! Uses hardcoded fallback subset
243
- 📦 Recommended Modules:
244
- 1. stripe-payment ⭐ (95% match)
245
- ...
246
- ```
247
-
248
- ---
249
-
250
- ### Example 3: No Matching Modules
251
-
252
- ```bash
253
- $ workspai ai recommend "blockchain integration"
254
-
255
- # Output:
256
- ⚠️ No matching modules found in RapidKit Core registry.
257
-
258
- 💡 Options:
259
-
260
- 1. Create custom module:
261
- rapidkit modules scaffold blockchain-integration --category integrations
262
-
263
- 2. Search with different keywords
264
- Try more general terms (e.g., "storage" instead of "blockchain")
265
-
266
- 3. Request feature:
267
- https://github.com/rapidkitlabs/workspai/issues
268
- ```
269
-
270
- ---
271
-
272
- ## 📋 Benefits
273
-
274
- ### ✅ Always Up-to-Date
275
-
276
- ```
277
- When Python Core adds new modules:
278
- ├─ AI automatically picks them up
279
- ├─ No code changes needed in npm
280
- ├─ Just regenerate embeddings
281
- └─ Users get latest recommendations
282
- ```
283
-
284
- ### ✅ Single Source of Truth
285
-
286
- ```
287
- Module Registry:
288
- ├─ Python Core: runtime catalog (source of truth)
289
- ├─ npm AI: Reads from Python (always synced)
290
- └─ No duplicate data
291
- ```
292
-
293
- ### ✅ Graceful Fallback
294
-
295
- ```
296
- If Python unavailable:
297
- ├─ Still works (fallback subset)
298
- ├─ User informed (console warning)
299
- ├─ No crashes or errors
300
- └─ Can upgrade to Python later
301
- ```
302
-
303
- ### Cache behavior
304
-
305
- The in-process catalog cache refreshes every five minutes. No fixed response-time
306
- or throughput guarantee is made; Core startup, provider latency, and catalog size
307
- vary by environment.
308
-
309
- ---
310
-
311
- ## 🔧 Configuration
312
-
313
- ### Environment Variables
314
-
315
- ```bash
316
- # Optional: Python command/interpreter override (if python3/python is not the right one)
317
- export RAPIDKIT_PYTHON_CMD=/path/to/python
318
- ```
319
-
320
- ---
321
-
322
- ## 🧪 Testing
323
-
324
- ### Test 1: With Python Core
325
-
326
- ```bash
327
- # Ensure Python Core in PATH
328
- which rapidkit # Should return path
329
-
330
- # Test recommendation
331
- workspai ai recommend "authentication"
332
-
333
- # Should show: using runtime catalog from Python Core
334
- ```
335
-
336
- ### Test 2: Without Python Core
337
-
338
- ```bash
339
- # Temporarily hide Python
340
- export PATH=/tmp:$PATH
341
-
342
- # Test recommendation
343
- workspai ai recommend "authentication"
344
-
345
- # Should show: ⚠️ Using fallback catalog (baseline subset)
346
- ```
347
-
348
- ### Test 3: Cache Behavior
349
-
350
- ```bash
351
- # First call (cold cache; duration is environment-dependent)
352
- time workspai ai recommend "auth"
353
-
354
- # Second call (warm catalog cache; still includes provider latency)
355
- time workspai ai recommend "database"
356
-
357
- # Wait 6 minutes, try again
358
- sleep 360
359
- time workspai ai recommend "payment"
360
- ```
361
-
362
- ---
363
-
364
- ## 📊 Comparison
365
-
366
- | Feature | Before (Static) | After (Dynamic) |
367
- | ------------------- | ------------------ | ------------------ |
368
- | **Module Count** | Fixed subset | Runtime catalog |
369
- | **Updates** | Manual code change | Automatic |
370
- | **Sync** | Manual | Automatic |
371
- | **Fallback** | ❌ None | ✅ Baseline subset |
372
- | **Cache** | ❌ None | ✅ 5-minute TTL |
373
- | **Python Required** | ❌ No | ⚠️ Recommended |
374
- | **Performance** | Fast (hardcoded) | Fast (cached) |
375
-
376
- ---
377
-
378
- ## 🚀 Next Steps
379
-
380
- ### Current Stage: ✅ Dynamic Fetching
381
-
382
- - ✅ Fetch from Python Core
383
- - ✅ Cache with TTL
384
- - ✅ Fallback to hardcoded
385
- - ✅ Error handling
386
-
387
- ### Next Stage: Module Installation
388
-
389
- ```bash
390
- workspai ai recommend "authentication"
391
- # → Shows recommendations
392
- # → [Install] button
393
- # → Calls: rapidkit add module authentication-core
394
- # → Python Core installs module
395
- ```
396
-
397
- ### Future Stage: Real-time Sync
398
-
399
- ```bash
400
- # Watch Python modules directory
401
- # Auto-regenerate embeddings when modules change
402
- # Push updates to users
403
- ```
404
-
405
- ---
406
-
407
- ## 🎯 Summary
408
-
409
- **What Changed:**
410
-
411
- - ✅ AI now reads from Python Core dynamically
412
- - ✅ Runtime catalog instead of a fixed hardcoded subset
413
- - ✅ Always up-to-date
414
- - ✅ Fallback if Python not available
415
- - ✅ 5-minute cache for performance
416
-
417
- **What Stayed Same:**
418
-
419
- - ✅ Same API (getModuleCatalog)
420
- - ✅ Same recommendation algorithm
421
- - ✅ Same embedding model
422
- - ✅ Same CLI commands
423
- - ✅ Backward compatible
424
-
425
- **Result:**
426
-
427
- - 🎉 Runtime-driven catalog
428
- - 🎉 Single source of truth
429
- - 🎉 Production-ready
430
- - 🎉 Zero breaking changes
431
-
432
- ---
433
-
434
- **Built by the Workspai Team**
435
-
436
- _Dynamic AI that grows with your framework._
19
+ return human or JSON recommendations
20
+ optional, interactive
21
+ validate project `add` capability → Core bridge module install
22
+ ```
23
+
24
+ ## Source ownership
25
+
26
+ | Concern | Source area |
27
+ | -------------------------------- | ------------------------------------------- |
28
+ | Command and error behavior | `src/commands/ai.ts` |
29
+ | Provider/mock embedding client | `src/ai/openai-client.ts` |
30
+ | Module catalog and Core fallback | `src/ai/module-catalog.ts` |
31
+ | Ranking | `src/ai/recommender.ts` |
32
+ | Catalog generation/update | `src/ai/embeddings-manager.ts` |
33
+ | User configuration | `src/config/user-config.ts` |
34
+ | Core process boundary | `src/core-bridge/pythonRapidkitExec.ts` |
35
+ | Project command capability | `src/utils/project-command-capabilities.ts` |
36
+
37
+ ## Catalog resolution
38
+
39
+ The recommender prefers compatible bundled catalog data. Development refreshes
40
+ can request module metadata through the validated Core bridge. If Core is not
41
+ available, a bounded fallback catalog permits basic discovery.
42
+
43
+ Catalog records must preserve their embedding model and dimension metadata.
44
+ Never combine vectors produced by incompatible models. Catalog caches are
45
+ in-process optimizations, not durable sources of truth.
46
+
47
+ ## Failure behavior
48
+
49
+ - Missing provider key selects mock mode for `recommend`.
50
+ - Missing catalog in provider mode returns a structured remediation pointing to
51
+ `ai generate-embeddings`.
52
+ - Provider authentication, rate-limit, and network failures return non-zero.
53
+ - Invalid or unavailable project `add` capability blocks installation without
54
+ weakening the recommendation response.
55
+ - Human and JSON output must preserve the same underlying result semantics.
56
+
57
+ ## Security boundaries
58
+
59
+ - Provider secrets come from user configuration or environment, never workspace
60
+ evidence.
61
+ - Logs and JSON responses must not emit provider keys.
62
+ - Core commands execute through the shared bridge rather than ad-hoc process
63
+ spawning.
64
+ - Module recommendation is advisory; installation remains capability-gated and
65
+ verification remains the responsibility of project/Workspace Intelligence
66
+ commands.
67
+
68
+ ## Testing expectations
69
+
70
+ Changes to this area require coverage for:
71
+
72
+ - provider and mock modes;
73
+ - missing/invalid configuration;
74
+ - catalog present, missing, and incompatible cases;
75
+ - deterministic ranking fixtures;
76
+ - JSON error contracts and non-zero exits;
77
+ - supported and unsupported Core installation capabilities;
78
+ - secret redaction.
79
+
80
+ Use [AI_QUICKSTART.md](./AI_QUICKSTART.md) for user setup and
81
+ [AI_FEATURES.md](./AI_FEATURES.md) for the public behavioral contract.