rapidkit 0.37.0 → 0.37.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. package/README.md +23 -44
  2. package/dist/autopilot-release-QNZ2IL7K.js +1 -0
  3. package/dist/chunk-3SWQKRXH.js +2 -0
  4. package/dist/{chunk-7VSYTOOG.js → chunk-7RBZGQ7T.js} +1 -1
  5. package/dist/index.js +4 -4
  6. package/dist/{pipeline-BOU4KETN.js → pipeline-IMB3C3JY.js} +1 -1
  7. package/dist/{workspace-agent-sync-V2H6NTGD.js → workspace-agent-sync-4R7S3F6T.js} +1 -1
  8. package/dist/{workspace-context-KCKNV5VQ.js → workspace-context-CKACDTVE.js} +1 -1
  9. package/dist/workspace-run-PNMZJNDC.js +1 -0
  10. package/dist/workspace-verify-EO435PS4.js +1 -0
  11. package/docs/AI_DYNAMIC_INTEGRATION.md +440 -0
  12. package/docs/AI_EXAMPLES.md +419 -0
  13. package/docs/AI_FEATURES.md +460 -0
  14. package/docs/AI_QUICKSTART.md +245 -0
  15. package/docs/DEVELOPMENT.md +88 -0
  16. package/docs/From Code to Shared Understanding.png +0 -0
  17. package/docs/OPEN_SOURCE_USER_SCENARIOS.md +170 -0
  18. package/docs/OPTIMIZATION_GUIDE.md +504 -0
  19. package/docs/PACKAGE_MANAGER_POLICY.md +25 -0
  20. package/docs/README.md +120 -0
  21. package/docs/SECURITY.md +63 -0
  22. package/docs/SETUP.md +107 -0
  23. package/docs/UTILITIES.md +221 -0
  24. package/docs/WORKSPACE_MARKER_SPEC.md +276 -0
  25. package/docs/ci-workflows.md +56 -0
  26. package/docs/commands-reference.md +136 -0
  27. package/docs/config-file-guide.md +295 -0
  28. package/docs/contracts/ARTIFACT_CATALOG.md +104 -0
  29. package/docs/contracts/COMMAND_OWNERSHIP_MATRIX.md +138 -0
  30. package/docs/contracts/README.md +70 -0
  31. package/docs/contracts/RUNTIME_ACCEPTANCE_MATRIX.md +98 -0
  32. package/docs/contracts/RUNTIME_SUPPORT_MATRIX.md +74 -0
  33. package/docs/contracts/rapidkit-cli-contracts.json +239 -0
  34. package/docs/doctor-command.md +263 -0
  35. package/docs/examples/ci-agent-grounding.yml +62 -0
  36. package/docs/from-code-to-shared-understanding.md +46 -0
  37. package/docs/governance-policy.enterprise.example.json +40 -0
  38. package/docs/mirror-config.enterprise.example.json +60 -0
  39. package/docs/policies.workspace.example.yml +23 -0
  40. package/docs/workspace-operations.md +160 -0
  41. package/docs/workspace-run.md +80 -0
  42. package/package.json +3 -2
  43. package/dist/autopilot-release-AUXP2ZIF.js +0 -1
  44. package/dist/chunk-EJGKBFV4.js +0 -2
  45. package/dist/workspace-run-DEXI52KO.js +0 -1
  46. package/dist/workspace-verify-HBCQNNGU.js +0 -1
  47. /package/dist/{chunk-D23L2GFT.js → chunk-TRXYRHD7.js} +0 -0
@@ -0,0 +1,440 @@
1
+ # 🔄 Dynamic AI Integration with Python Core
2
+
3
+ > **Date:** January 1, 2026
4
+ > **Implementation:** Dynamic module catalog fetching from Python Core
5
+
6
+ ---
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 from Python Core
26
+ export async function getModuleCatalog() {
27
+ const result = await exec('rapidkit modules list --json');
28
+ return parseModules(result);
29
+ }
30
+ ```
31
+
32
+ ---
33
+
34
+ ## 📊 Architecture
35
+
36
+ ### Data Flow
37
+
38
+ ```
39
+ User Query
40
+
41
+ AI Recommender
42
+
43
+ getModuleCatalog()
44
+
45
+ ├─ Try: rapidkit modules list --json
46
+ │ └─ Success: Return Python modules (runtime count)
47
+ │ └─ Fail: Return fallback catalog (baseline subset)
48
+
49
+ Generate Embeddings
50
+
51
+ Cosine Similarity
52
+
53
+ Return Top Recommendations
54
+ ```
55
+
56
+ ---
57
+
58
+ ## 🔧 Implementation Details
59
+
60
+ ### 1. Dynamic Module Fetching (`src/ai/module-catalog.ts`)
61
+
62
+ **Features:**
63
+
64
+ - ✅ Calls `rapidkit modules list --json`
65
+ - ✅ 5-minute cache (reduces Python calls)
66
+ - ✅ Fallback to hardcoded catalog if Python not available
67
+ - ✅ Automatic retry and error handling
68
+ - ✅ Category and framework mapping
69
+
70
+ **Code:**
71
+
72
+ ```typescript
73
+ export async function getModuleCatalog(): Promise<ModuleMetadata[]> {
74
+ // Check cache
75
+ if (cachedModules && Date.now() - lastFetchTime < CACHE_TTL) {
76
+ return cachedModules;
77
+ }
78
+
79
+ // Fetch from Python Core
80
+ try {
81
+ const { stdout } = await execAsync('rapidkit modules list --json');
82
+ const modules = parseModules(stdout);
83
+ cachedModules = modules;
84
+ return modules;
85
+ } catch (error) {
86
+ console.warn('⚠️ Using fallback catalog');
87
+ return FALLBACK_MODULE_CATALOG;
88
+ }
89
+ }
90
+ ```
91
+
92
+ ---
93
+
94
+ ### 2. Module Parsing
95
+
96
+ **Handles different Python CLI output formats:**
97
+
98
+ ```typescript
99
+ // Format 1: Array
100
+ ["module1", "module2"]
101
+
102
+ // Format 2: Object with modules key
103
+ { "modules": [...] }
104
+
105
+ // Format 3: Object with data key
106
+ { "data": [...] }
107
+ ```
108
+
109
+ **Category Mapping:**
110
+
111
+ ```typescript
112
+ Python Category → TypeScript Type
113
+ ├─ "auth" → "auth"
114
+ ├─ "authentication" → "auth"
115
+ ├─ "database" → "database"
116
+ ├─ "payment" → "payment"
117
+ ├─ "billing" → "payment"
118
+ └─ etc.
119
+ ```
120
+
121
+ ---
122
+
123
+ ### 3. Cache Strategy
124
+
125
+ **TTL: 5 minutes**
126
+
127
+ ```
128
+ First call:
129
+ ├─ Fetch from Python (10s)
130
+ ├─ Cache result
131
+ └─ Return
132
+
133
+ Subsequent calls (within 5 min):
134
+ ├─ Return cached
135
+ └─ Instant response
136
+
137
+ After 5 min:
138
+ ├─ Re-fetch from Python
139
+ └─ Update cache
140
+ ```
141
+
142
+ **Benefits:**
143
+
144
+ - ✅ Fast responses (cached)
145
+ - ✅ Always up-to-date (5min refresh)
146
+ - ✅ Reduces Python CLI calls
147
+
148
+ ---
149
+
150
+ ### 4. Fallback Mechanism
151
+
152
+ **Graceful degradation:**
153
+
154
+ ```
155
+ Try Python Core:
156
+ ├─ Success → Use runtime module catalog ✅
157
+ ├─ Python not in PATH → Use fallback subset ⚠️
158
+ ├─ Command timeout → Use fallback subset ⚠️
159
+ └─ Parse error → Use fallback subset ⚠️
160
+ ```
161
+
162
+ **Fallback catalog:**
163
+
164
+ - Baseline core modules (hardcoded subset)
165
+ - Authentication, database, payment, etc.
166
+ - Enough for basic recommendations
167
+
168
+ ---
169
+
170
+ ### 5. Embedding Generation
171
+
172
+ **Now dynamic:**
173
+
174
+ ```bash
175
+ # Old: Generated from fixed hardcoded subset
176
+ npx tsx src/ai/generate-embeddings.ts
177
+
178
+ # New: Fetches from Python Core first
179
+ # → Gets runtime module catalog
180
+ # → Generates embeddings for all discovered modules
181
+ # → Saves to data/modules-embeddings.json
182
+ ```
183
+
184
+ **Output:**
185
+
186
+ ```json
187
+ {
188
+ "model": "text-embedding-3-small",
189
+ "dimension": 1536,
190
+ "generated_at": "2026-01-01T...",
191
+ "modules": [
192
+ {
193
+ "id": "authentication-core",
194
+ "name": "Authentication Core",
195
+ "embedding": [0.123, -0.456, ...]
196
+ }
197
+ // ... runtime modules (from Python)
198
+ ]
199
+ }
200
+ ```
201
+
202
+ ---
203
+
204
+ ## 🚀 Usage Examples
205
+
206
+ ### Example 1: With Python Core Available
207
+
208
+ ```bash
209
+ $ rapidkit ai recommend "I need user authentication"
210
+
211
+ # Behind the scenes:
212
+ # 1. Calls: rapidkit modules list --json
213
+ # 2. Gets runtime module catalog from Python Core
214
+ # 3. Generates query embedding
215
+ # 4. Compares with catalog embeddings
216
+ # 5. Returns top 5 recommendations
217
+
218
+ 📦 Recommended Modules:
219
+ 1. authentication-core ⭐ (98% match)
220
+ 2. users-core ⭐ (92% match)
221
+ 3. session-management (88% match)
222
+ ...
223
+ ```
224
+
225
+ ---
226
+
227
+ ### Example 2: Without Python Core (Fallback)
228
+
229
+ ```bash
230
+ $ rapidkit ai recommend "payment processing"
231
+
232
+ # Console output:
233
+ ⚠️ RapidKit Python Core not found in PATH
234
+ Using fallback module catalog (baseline subset)
235
+
236
+ # Still works! Uses hardcoded fallback subset
237
+ 📦 Recommended Modules:
238
+ 1. stripe-payment ⭐ (95% match)
239
+ ...
240
+ ```
241
+
242
+ ---
243
+
244
+ ### Example 3: No Matching Modules
245
+
246
+ ```bash
247
+ $ rapidkit ai recommend "blockchain integration"
248
+
249
+ # Output:
250
+ ⚠️ No matching modules found in RapidKit registry.
251
+
252
+ 💡 Options:
253
+
254
+ 1. Create custom module:
255
+ rapidkit modules scaffold blockchain-integration --category integrations
256
+
257
+ 2. Search with different keywords
258
+ Try more general terms (e.g., "storage" instead of "blockchain")
259
+
260
+ 3. Request feature:
261
+ https://github.com/rapidkitlabs/rapidkit/issues
262
+ ```
263
+
264
+ ---
265
+
266
+ ## 📋 Benefits
267
+
268
+ ### ✅ Always Up-to-Date
269
+
270
+ ```
271
+ When Python Core adds new modules:
272
+ ├─ AI automatically picks them up
273
+ ├─ No code changes needed in npm
274
+ ├─ Just regenerate embeddings
275
+ └─ Users get latest recommendations
276
+ ```
277
+
278
+ ### ✅ Single Source of Truth
279
+
280
+ ```
281
+ Module Registry:
282
+ ├─ Python Core: runtime catalog (source of truth)
283
+ ├─ npm AI: Reads from Python (always synced)
284
+ └─ No duplicate data
285
+ ```
286
+
287
+ ### ✅ Graceful Fallback
288
+
289
+ ```
290
+ If Python unavailable:
291
+ ├─ Still works (fallback subset)
292
+ ├─ User informed (console warning)
293
+ ├─ No crashes or errors
294
+ └─ Can upgrade to Python later
295
+ ```
296
+
297
+ ### ✅ Performance
298
+
299
+ ```
300
+ Cache Strategy:
301
+ ├─ First call: 10s (Python fetch)
302
+ ├─ Cached calls: <100ms (instant)
303
+ ├─ Cache refresh: Every 5 minutes
304
+ └─ Optimal balance
305
+ ```
306
+
307
+ ---
308
+
309
+ ## 🔧 Configuration
310
+
311
+ ### Environment Variables
312
+
313
+ ```bash
314
+ # Optional: Force fallback mode (testing)
315
+ export RAPIDKIT_AI_FALLBACK=true
316
+
317
+ # Optional: Cache TTL (default: 5 minutes)
318
+ export RAPIDKIT_CACHE_TTL=600000 # milliseconds
319
+
320
+ # Optional: Python command/interpreter override (if python3/python is not the right one)
321
+ export RAPIDKIT_PYTHON_CMD=/path/to/python
322
+ ```
323
+
324
+ ---
325
+
326
+ ## 🧪 Testing
327
+
328
+ ### Test 1: With Python Core
329
+
330
+ ```bash
331
+ # Ensure Python Core in PATH
332
+ which rapidkit # Should return path
333
+
334
+ # Test recommendation
335
+ rapidkit ai recommend "authentication"
336
+
337
+ # Should show: using runtime catalog from Python Core
338
+ ```
339
+
340
+ ### Test 2: Without Python Core
341
+
342
+ ```bash
343
+ # Temporarily hide Python
344
+ export PATH=/tmp:$PATH
345
+
346
+ # Test recommendation
347
+ rapidkit ai recommend "authentication"
348
+
349
+ # Should show: ⚠️ Using fallback catalog (baseline subset)
350
+ ```
351
+
352
+ ### Test 3: Cache Behavior
353
+
354
+ ```bash
355
+ # First call (cold cache)
356
+ time rapidkit ai recommend "auth" # ~10 seconds
357
+
358
+ # Second call (warm cache)
359
+ time rapidkit ai recommend "database" # <1 second
360
+
361
+ # Wait 6 minutes, try again
362
+ sleep 360
363
+ time rapidkit ai recommend "payment" # ~10 seconds (cache expired)
364
+ ```
365
+
366
+ ---
367
+
368
+ ## 📊 Comparison
369
+
370
+ | Feature | Before (Static) | After (Dynamic) |
371
+ | ------------------- | ------------------ | ------------------ |
372
+ | **Module Count** | Fixed subset | Runtime catalog |
373
+ | **Updates** | Manual code change | Automatic |
374
+ | **Sync** | Manual | Automatic |
375
+ | **Fallback** | ❌ None | ✅ Baseline subset |
376
+ | **Cache** | ❌ None | ✅ 5-minute TTL |
377
+ | **Python Required** | ❌ No | ⚠️ Recommended |
378
+ | **Performance** | Fast (hardcoded) | Fast (cached) |
379
+
380
+ ---
381
+
382
+ ## 🚀 Next Steps
383
+
384
+ ### Current Stage: ✅ Dynamic Fetching
385
+
386
+ - ✅ Fetch from Python Core
387
+ - ✅ Cache with TTL
388
+ - ✅ Fallback to hardcoded
389
+ - ✅ Error handling
390
+
391
+ ### Next Stage: Module Installation
392
+
393
+ ```bash
394
+ rapidkit ai recommend "authentication"
395
+ # → Shows recommendations
396
+ # → [Install] button
397
+ # → Calls: rapidkit add module authentication-core
398
+ # → Python Core installs module
399
+ ```
400
+
401
+ ### Future Stage: Real-time Sync
402
+
403
+ ```bash
404
+ # Watch Python modules directory
405
+ # Auto-regenerate embeddings when modules change
406
+ # Push updates to users
407
+ ```
408
+
409
+ ---
410
+
411
+ ## 🎯 Summary
412
+
413
+ **What Changed:**
414
+
415
+ - ✅ AI now reads from Python Core dynamically
416
+ - ✅ Runtime catalog instead of a fixed hardcoded subset
417
+ - ✅ Always up-to-date
418
+ - ✅ Fallback if Python not available
419
+ - ✅ 5-minute cache for performance
420
+
421
+ **What Stayed Same:**
422
+
423
+ - ✅ Same API (getModuleCatalog)
424
+ - ✅ Same recommendation algorithm
425
+ - ✅ Same embedding model
426
+ - ✅ Same CLI commands
427
+ - ✅ Backward compatible
428
+
429
+ **Result:**
430
+
431
+ - 🎉 Runtime-driven catalog
432
+ - 🎉 Single source of truth
433
+ - 🎉 Production-ready
434
+ - 🎉 Zero breaking changes
435
+
436
+ ---
437
+
438
+ **Built with ❤️ by the RapidKit Team**
439
+
440
+ _Dynamic AI that grows with your framework._