@descix/cli 1.0.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 (94) hide show
  1. package/README.md +95 -0
  2. package/SERVICE_README_sdk.md +399 -0
  3. package/agent-assets/guides/README.md +61 -0
  4. package/agent-assets/guides/dynamic-site-pattern.md +125 -0
  5. package/agent-assets/guides/knowledge-only-pattern.md +93 -0
  6. package/agent-assets/guides/microservice-pattern.md +152 -0
  7. package/agent-assets/guides/static-site-pattern.md +111 -0
  8. package/agent-assets/instructions/app-asset-validation.md +477 -0
  9. package/agent-assets/instructions/onboarding-flow.md +408 -0
  10. package/agent-assets/instructions/standard-folder-structure.md +125 -0
  11. package/agent-assets/reference/app-creation.md +381 -0
  12. package/agent-assets/reference/architecture.md +406 -0
  13. package/agent-assets/reference/local-dev.md +138 -0
  14. package/agent-assets/reference/mcp-integration.md +424 -0
  15. package/agent-assets/reference/workspace-config.md +415 -0
  16. package/agent-assets/rules/descix_mcp.template.mdc +243 -0
  17. package/bin/descix.js +3930 -0
  18. package/bin/mcp-server.js +382 -0
  19. package/descix-cli-1.0.0.tgz +0 -0
  20. package/lib/agent-files.js +162 -0
  21. package/lib/api-client.js +458 -0
  22. package/lib/auth-guard.js +67 -0
  23. package/lib/commands/app-wizard.js +627 -0
  24. package/lib/commands/auth.js +407 -0
  25. package/lib/commands/buy.js +207 -0
  26. package/lib/commands/clone.js +91 -0
  27. package/lib/commands/config.js +155 -0
  28. package/lib/commands/doctor.js +277 -0
  29. package/lib/commands/folder.js +291 -0
  30. package/lib/commands/init.js +257 -0
  31. package/lib/commands/kb.js +654 -0
  32. package/lib/commands/mcp.js +273 -0
  33. package/lib/commands/serve.js +12 -0
  34. package/lib/commands/status.js +239 -0
  35. package/lib/commands/update.js +653 -0
  36. package/lib/core/Chunker.js +610 -0
  37. package/lib/core/Hydrator.js +801 -0
  38. package/lib/core/PathContext.js +335 -0
  39. package/lib/core/Syncer.js +310 -0
  40. package/lib/core/index.js +32 -0
  41. package/lib/global-config.js +86 -0
  42. package/lib/google-storage-adc.js +511 -0
  43. package/lib/wallet-file.js +232 -0
  44. package/lib/wizard/setup.js +502 -0
  45. package/lib/workspace-config.js +712 -0
  46. package/lib/workspace-utils.js +126 -0
  47. package/package.json +41 -0
  48. package/templates/agent-claude.md +226 -0
  49. package/templates/agent-cline.md +133 -0
  50. package/templates/agent-copilot.md +133 -0
  51. package/templates/agent-cursor.md +133 -0
  52. package/templates/descix_mcp.mdc +122 -0
  53. package/templates/drive/README.md +42 -0
  54. package/templates/drive/app/assets/app_description.md +13 -0
  55. package/templates/drive/app/assets/icon.png +0 -0
  56. package/templates/drive/app/assets/system_instructions.md +17 -0
  57. package/templates/drive/app/kb/General/README.md +25 -0
  58. package/templates/drive/community/Apps/.gitkeep +4 -0
  59. package/templates/drive/community/community_assets/community_description.md +15 -0
  60. package/templates/drive/community/community_assets/icon.png +0 -0
  61. package/templates/drive_templates/README.md +104 -0
  62. package/templates/drive_templates/agent_app_template/assets/app_description.txt +13 -0
  63. package/templates/drive_templates/agent_app_template/assets/system_instructions.txt +17 -0
  64. package/templates/drive_templates/agent_app_template/kb/General/README.md +25 -0
  65. package/templates/drive_templates/agent_app_template/microservice/.gitkeep +10 -0
  66. package/templates/drive_templates/agent_app_template/site/.gitkeep +4 -0
  67. package/templates/drive_templates/community_template/Apps/.gitkeep +4 -0
  68. package/templates/drive_templates/community_template/community_assets/community_description.txt +15 -0
  69. package/templates/scaffolds/README.md +62 -0
  70. package/templates/scaffolds/microservice/Dockerfile +19 -0
  71. package/templates/scaffolds/microservice/SERVICE_README_sdk.md +399 -0
  72. package/templates/scaffolds/microservice/app.js +50 -0
  73. package/templates/scaffolds/microservice/app.yaml +8 -0
  74. package/templates/scaffolds/microservice/defaults-config.json +5 -0
  75. package/templates/scaffolds/microservice/dev-overrides.json.example +5 -0
  76. package/templates/scaffolds/microservice/manifest.json +49 -0
  77. package/templates/scaffolds/microservice/package-lock.json +2645 -0
  78. package/templates/scaffolds/microservice/package.json +29 -0
  79. package/templates/scaffolds/microservice/scripts/register.js +55 -0
  80. package/templates/scaffolds/microservice/services/apiFront.js +75 -0
  81. package/templates/scaffolds/microservice/services/commandHandlers/sampleCommands.js +57 -0
  82. package/templates/scaffolds/microservice/services/mcpClient.js +78 -0
  83. package/templates/scaffolds/microservice/services/utils.js +247 -0
  84. package/templates/scaffolds/microservice/setup-schema.json +18 -0
  85. package/templates/scaffolds/microservice/templates/SERVICE_README_TEMPLATE.md +143 -0
  86. package/templates/scaffolds/site/DeSciXAppSDK.js +62 -0
  87. package/templates/scaffolds/site/README.md +51 -0
  88. package/templates/scaffolds/site/app.js +22 -0
  89. package/templates/scaffolds/site/index.html +42 -0
  90. package/templates/scaffolds/site/styles.css +123 -0
  91. package/test-hydration.js +150 -0
  92. package/vendor/mcp/transports/http-sse-transport.js +196 -0
  93. package/vendor/mcp/transports/index.js +15 -0
  94. package/vendor/mcp/transports/stdio-transport.js +118 -0
@@ -0,0 +1,424 @@
1
+ # MCP Agent Integration Guide
2
+
3
+ **Status:** Implemented
4
+ **Version:** 1.0
5
+ **Last Updated:** January 2026
6
+
7
+ This document covers how AI agents interact with the DeSciX platform via MCP (Model Context Protocol) after SDK setup is complete.
8
+
9
+ ---
10
+
11
+ ## 1. Architecture Overview
12
+
13
+ DeSciX operates as a **Federated MCP Service Mesh**. The `DeSciX_Cloud` backend acts as a broker that aggregates tools from all registered microservices into a unified catalog.
14
+
15
+ **Key Innovation:** AI agents discover and invoke capabilities across the entire mesh without knowing where individual services are hosted.
16
+
17
+ ```
18
+ AI Agent (Cursor/MCP Client)
19
+ │
20
+ ▼
21
+ tell_me_how (semantic discovery)
22
+ │
23
+ ▼
24
+ execute_remote_command
25
+ │
26
+ ▼
27
+ DeSciX_Cloud (Federated Broker)
28
+ │
29
+ ├──► Service 1 (Powch)
30
+ ├──► Service 2 (SmartModel)
31
+ └──► Service N (Custom)
32
+ ```
33
+
34
+ ---
35
+
36
+ ## 2. Agent as Assistant Pattern
37
+
38
+ ### 2.1 MCP as Transport Layer
39
+
40
+ MCP provides the communication protocol between AI agents and the DeSciX platform. All DeSciX capabilities are exposed as MCP tools.
41
+
42
+ **Key Tools:**
43
+ - `tell_me_how` - Semantic tool discovery
44
+ - `execute_remote_command` - Execute any backend command
45
+ - `descix_init` - Initialize local workspace
46
+ - `chat_with_kb` - Query knowledge bases
47
+ - `search_knowledge_base` - Search specific KBs
48
+
49
+ ### 2.2 Cursor/AI Agent Integration
50
+
51
+ When an AI agent (e.g., Cursor) is configured with the DeSciX MCP server:
52
+
53
+ 1. Agent receives user question
54
+ 2. Agent uses `tell_me_how` to find relevant tools
55
+ 3. Agent calls `execute_remote_command` with discovered tool
56
+ 4. Result returned to user
57
+
58
+ ### 2.3 The `_descix` Context Object
59
+
60
+ All MCP calls include a `_descix` context object for identity propagation:
61
+
62
+ ```javascript
63
+ {
64
+ user: {
65
+ id: "user_123",
66
+ wallet_address: "0x...",
67
+ email: "user@example.com"
68
+ },
69
+ session: {
70
+ token: "...",
71
+ expires_at: "..."
72
+ },
73
+ workspace: {
74
+ community_id: "descix",
75
+ app_id: "agent"
76
+ }
77
+ }
78
+ ```
79
+
80
+ The broker validates this context and propagates it to downstream services.
81
+
82
+ ---
83
+
84
+ ## 3. tell_me_how Usage Paradigm
85
+
86
+ ### 3.1 Primary Discovery Mechanism
87
+
88
+ `tell_me_how` is the **primary entry point** for discovering platform capabilities. Always use it before attempting platform operations.
89
+
90
+ **Rule:** Ask `tell_me_how` first, then execute the recommended command.
91
+
92
+ ### 3.2 Three Scopes
93
+
94
+ | Scope | Description | Use Case |
95
+ |-------|-------------|----------|
96
+ | `entitlements` (default) | Only tools user has access to | Production usage |
97
+ | `project` | Tools filtered by workspace.json | Working within a project |
98
+ | `discovery` | All available tools | Exploring capabilities |
99
+
100
+ ### 3.3 CLI Usage
101
+
102
+ ```bash
103
+ # Default (entitlements scope)
104
+ descix tell-me-how "How do I create a new app?"
105
+
106
+ # Project scope - uses workspace.json
107
+ descix tell-me-how --scope project "How do I sync my knowledge base?"
108
+
109
+ # Discovery scope - see all tools
110
+ descix tell-me-how --scope discovery "What AI training tools exist?"
111
+ ```
112
+
113
+ ### 3.4 MCP Usage
114
+
115
+ ```javascript
116
+ tell_me_how({
117
+ question: "How do I deploy my app?",
118
+ scope: "entitlements"
119
+ })
120
+
121
+ // Returns:
122
+ {
123
+ recommended_tools: [
124
+ {
125
+ name: "deploy_site",
126
+ description: "Deploy static site to GCS",
127
+ parameters: { ... }
128
+ }
129
+ ],
130
+ guidance: "Use deploy_site to upload your site/ folder..."
131
+ }
132
+ ```
133
+
134
+ ### 3.5 Integration with SDK V2 Setup
135
+
136
+ After `descix setup` completes:
137
+
138
+ 1. `workspace.json` is created with community/app mappings
139
+ 2. Credentials are saved to `.descix/wallet.json`
140
+ 3. `tell_me_how --scope project` now filters by configured apps
141
+ 4. Agent can discover project-specific tools
142
+
143
+ ---
144
+
145
+ ## 4. Dynamic Tools Discovery
146
+
147
+ ### 4.1 Federated MCP Broker
148
+
149
+ `DeSciX_Cloud` aggregates tools from all registered microservices:
150
+
151
+ ```
152
+ Microservice A
153
+ └── manifest.json (tools: [tool1, tool2])
154
+ │
155
+ ▼
156
+ Registers with Core
157
+ │
158
+ ▼
159
+ DeSciX_Cloud (Broker)
160
+ └── Aggregated tools/list
161
+ │
162
+ ▼
163
+ AI Agent sees: [tool1, tool2, core_tools...]
164
+ ```
165
+
166
+ ### 4.2 SERVICE_README Vectorization
167
+
168
+ Each service documents its capabilities in a `SERVICE_README_{name}.md` file. This documentation is vectorized for semantic discovery.
169
+
170
+ **Format:**
171
+ ```markdown
172
+ # My Service
173
+
174
+ ## Overview
175
+ [What this service does and when to use it]
176
+
177
+ ## Available Commands
178
+
179
+ ### command_name
180
+ **Description:** What it does
181
+ **Use when:** Scenarios when this command is appropriate
182
+ **Parameters:**
183
+ - `param1` (required, string): Description
184
+ - `param2` (optional, number): Description
185
+
186
+ **Example:**
187
+ ```javascript
188
+ execute_remote_command({
189
+ command: "command_name",
190
+ params: { param1: "value" }
191
+ })
192
+ ```
193
+ ```
194
+
195
+ ### 4.3 Service Registration
196
+
197
+ Services self-register with the broker:
198
+
199
+ ```bash
200
+ # Register service manifest
201
+ descix microservice register -m ./manifest.json
202
+
203
+ # Vectorize SERVICE_README for discovery
204
+ descix microservice vectorize -r SERVICE_README.md
205
+ ```
206
+
207
+ ### 4.4 The execute_remote_command Pattern
208
+
209
+ After `tell_me_how` returns recommended tools:
210
+
211
+ ```javascript
212
+ // 1. Discover
213
+ const plan = await tell_me_how({
214
+ question: "How do I sync my KB?",
215
+ scope: "project"
216
+ });
217
+
218
+ // 2. Execute
219
+ const result = await execute_remote_command({
220
+ command: plan.recommended_tools[0].name,
221
+ params: {
222
+ community_id: "descix",
223
+ app_id: "agent",
224
+ kb_id: "General"
225
+ }
226
+ });
227
+ ```
228
+
229
+ ---
230
+
231
+ ## 5. Post-Setup Workflow
232
+
233
+ ### 5.1 Initial Setup Phase
234
+
235
+ ```
236
+ descix setup [--dev]
237
+ │
238
+ ▼
239
+ Prerequisites Check (gcloud, ADC)
240
+ │
241
+ ▼
242
+ Device Login (browser)
243
+ │
244
+ ▼
245
+ Workspace Builder (PWA)
246
+ │
247
+ ▼
248
+ Hydration (Hydrator module)
249
+ │
250
+ ▼
251
+ Credentials Saved (.descix/wallet.json)
252
+ │
253
+ ▼
254
+ ✓ Ready for agent interaction
255
+ ```
256
+
257
+ ### 5.2 Ongoing Usage - Agent as Assistant
258
+
259
+ ```
260
+ User asks question
261
+ │
262
+ ▼
263
+ tell_me_how({ question, scope: "project" })
264
+ │
265
+ ▼
266
+ Discover relevant tools
267
+ │
268
+ ▼
269
+ execute_remote_command({ command, params })
270
+ │
271
+ ▼
272
+ Broker routes to appropriate service
273
+ │
274
+ ▼
275
+ Result returned to user
276
+ ```
277
+
278
+ ### 5.3 Project Scope Filtering
279
+
280
+ When `--scope project` is used:
281
+
282
+ 1. CLI/MCP loads `workspace.json`
283
+ 2. Extracts configured communities and apps
284
+ 3. Filters `tell_me_how` results to only tools applicable to those apps
285
+ 4. Returns focused recommendations
286
+
287
+ ```javascript
288
+ // workspace.json
289
+ {
290
+ "communities": {
291
+ "descix": {
292
+ "apps": {
293
+ "agent": { "localPath": ".", "sync_mode": "git" }
294
+ }
295
+ }
296
+ }
297
+ }
298
+
299
+ // tell_me_how with project scope only searches within descix/agent
300
+ ```
301
+
302
+ ---
303
+
304
+ ## 6. Key Integration Points with SDK V2
305
+
306
+ ### 6.1 KB Operations via tell_me_how
307
+
308
+ The new SDK V2 KB commands are discoverable:
309
+
310
+ ```bash
311
+ descix tell-me-how "How do I sync my knowledge base?"
312
+ # Returns: kb_sync_chunks, kb_get_chunk_ids, kb_delete_chunks
313
+ ```
314
+
315
+ ### 6.2 workspace.json from Hydration
316
+
317
+ The `Hydrator` module creates `workspace.json` during setup:
318
+
319
+ ```javascript
320
+ // Created by Hydrator.hydrateWorkspace()
321
+ {
322
+ "communities": { ... },
323
+ "driveConfig": {
324
+ "base_folder_id": "..." // For tell_me_how project scope
325
+ }
326
+ }
327
+ ```
328
+
329
+ ### 6.3 Service Registration for Custom Microservices
330
+
331
+ Custom services integrate with the same pattern:
332
+
333
+ 1. Create `SERVICE_README_{name}.md`
334
+ 2. Register with `descix microservice register`
335
+ 3. Vectorize with `descix microservice vectorize`
336
+ 4. Tools become discoverable via `tell_me_how`
337
+
338
+ ---
339
+
340
+ ## 7. Best Practices
341
+
342
+ ### 7.1 For AI Agents
343
+
344
+ 1. **Always use tell_me_how first** - Don't guess at command names
345
+ 2. **Use project scope when in a workspace** - More focused results
346
+ 3. **Chain operations** - tell_me_how -> execute_remote_command
347
+ 4. **Handle errors gracefully** - Show user-friendly messages
348
+
349
+ ### 7.2 For Service Developers
350
+
351
+ 1. **Document all commands in SERVICE_README** - Required for discovery
352
+ 2. **Use clear descriptions** - "Use when:" is crucial for semantic matching
353
+ 3. **Include examples** - Helps AI agents understand usage
354
+ 4. **Register after changes** - Re-vectorize when README updates
355
+
356
+ ### 7.3 Common Patterns
357
+
358
+ **Pattern: Discover and Execute**
359
+ ```javascript
360
+ const tools = await tell_me_how({ question: "...", scope: "entitlements" });
361
+ if (tools.recommended_tools.length > 0) {
362
+ await execute_remote_command({
363
+ command: tools.recommended_tools[0].name,
364
+ params: { ... }
365
+ });
366
+ }
367
+ ```
368
+
369
+ **Pattern: Project-Scoped Operations**
370
+ ```javascript
371
+ // Only works after descix setup
372
+ const tools = await tell_me_how({
373
+ question: "How do I update this app?",
374
+ scope: "project" // Uses workspace.json
375
+ });
376
+ ```
377
+
378
+ ---
379
+
380
+ ## 8. Troubleshooting
381
+
382
+ ### 8.1 "No results from tell_me_how"
383
+
384
+ **Cause:** SERVICE_READMEs may not be vectorized.
385
+
386
+ **Solution:** Admin should run:
387
+ ```bash
388
+ descix microservice vectorize -r SERVICE_README.md
389
+ ```
390
+
391
+ ### 8.2 "workspace.json not found" for project scope
392
+
393
+ **Cause:** Setup not completed or not in workspace root.
394
+
395
+ **Solution:**
396
+ ```bash
397
+ # Run setup first
398
+ descix setup --dev
399
+
400
+ # Or ensure you're in the workspace root
401
+ cd /path/to/workspace
402
+ ```
403
+
404
+ ### 8.3 "Command not found"
405
+
406
+ **Cause:** Service not registered or command deprecated.
407
+
408
+ **Solution:**
409
+ 1. Verify service is registered: `descix microservice list`
410
+ 2. Check if command was deprecated in V2
411
+ 3. Use `tell_me_how --scope discovery` to find alternatives
412
+
413
+ ---
414
+
415
+ ## 9. File References
416
+
417
+ | Component | Path |
418
+ |-----------|------|
419
+ | MCP Tools | `DeSciX_Core/descix-cli/lib/mcp-tools.js` |
420
+ | tell_me_how Implementation | `DeSciX_Cloud/services/commandHandlers/ragCommands.js` |
421
+ | execute_remote_command | `DeSciX_Cloud/services/apiFront.js` |
422
+ | SERVICE_README Template | `DeSciX_ServiceSDK/templates/SERVICE_README_TEMPLATE.md` |
423
+ | Workspace Config | `DeSciX_Core/descix-cli/lib/workspace-config.js` |
424
+ | Service Registration | `DeSciX_Core/descix-cli/lib/commands/service.js` |