@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,381 @@
1
+ # App Creation Guide
2
+
3
+ **Status:** Implemented
4
+ **Version:** 2.0
5
+ **Last Updated:** January 2026
6
+
7
+ This document describes how apps and communities are created and hydrated in the DeSciX platform.
8
+
9
+ ---
10
+
11
+ ## 1. Core Philosophy
12
+
13
+ **"PWA for Provisioning, CLI for Development"**
14
+
15
+ - **Provisioning:** All apps and communities are created through the PWA. This enforces entitlement checks (NFTs, subscriptions) and ensures consistent folder structures via Drive templates.
16
+ - **Development:** The CLI is the primary tool for hydrating the local workspace, managing content, and syncing to the cloud. The CLI does not create apps directly.
17
+
18
+ **Important Distinction:**
19
+
20
+ | Mode | Users | Tool | Content Management |
21
+ |------|-------|------|-------------------|
22
+ | **Drive Mode** | Non-developers | PWA only | Server-side pipeline (Drive → GCS → Pinecone) |
23
+ | **Git Mode** | Developers | CLI | Local processing (Drive pull → Git → Pinecone) |
24
+
25
+ All apps start on Drive (users create documents there). Git-mode applies when developers pull content locally and use Git for version control of text/chunks. The CLI **only supports git-mode** operations.
26
+
27
+ ---
28
+
29
+ ## 2. Two-Tier Template Architecture
30
+
31
+ ### Why Two Tiers?
32
+
33
+ DeSciX uses a **two-tier template system** that separates content from code:
34
+
35
+ 1. **Drive Templates** - Content (assets, KB docs) synced to/from Google Drive
36
+ 2. **Git Scaffolds** - Code (site, microservice) that lives in Git
37
+
38
+ This separation ensures:
39
+ - Content stays editable in Drive (non-developers can update)
40
+ - Code stays version-controlled in Git
41
+ - Clear deployment paths for each type
42
+ - No code in Drive, no content in Git scaffolds
43
+
44
+ ### Drive Templates
45
+
46
+ **Location:** Google Drive, owned by `dip@descix.net`
47
+ **SDK Reference:** `DeSciX_Core/descix-cli/templates/drive/`
48
+ **Template IDs:** Configured in `DeSciX_Cloud/defaults-config.json`
49
+
50
+ ```json
51
+ {
52
+ "DRIVE_COMMUNITY_TEMPLATE_FOLDER_ID": "1ABC...",
53
+ "DRIVE_AGENT_APP_TEMPLATE_FOLDER_ID": "1XYZ..."
54
+ }
55
+ ```
56
+
57
+ **Community Template:**
58
+ ```
59
+ templates/drive/community/
60
+ ├── community_assets/
61
+ │ ├── icon.png # Community icon (512x512)
62
+ │ └── community_description.md # Community description
63
+ └── Apps/ # Empty, ready for apps
64
+ ```
65
+
66
+ **App Template:**
67
+ ```
68
+ templates/drive/app/
69
+ ├── assets/
70
+ │ ├── app_description.md # App store listing
71
+ │ ├── system_instructions.md # AI persona instructions
72
+ │ └── icon.png # App icon (512x512)
73
+ └── kb/
74
+ └── General/
75
+ └── README.md # KB starter doc
76
+ ```
77
+
78
+ **Note:** The Drive template does NOT include `site/` or `microservice/` folders. Code scaffolds are added separately via CLI.
79
+
80
+ ### Git Scaffolds
81
+
82
+ **Location:** `DeSciX_Core/descix-cli/templates/scaffolds/`
83
+
84
+ **Site Scaffold:**
85
+ ```
86
+ templates/scaffolds/site/
87
+ ├── index.html # Entry point
88
+ ├── styles.css # Basic styling
89
+ ├── app.js # Client-side JavaScript
90
+ └── README.md # Usage instructions
91
+ ```
92
+
93
+ **Microservice Scaffold:**
94
+ ```
95
+ templates/scaffolds/microservice/
96
+ ├── package.json
97
+ ├── Dockerfile
98
+ ├── app.yaml
99
+ ├── manifest.json
100
+ ├── SERVICE_README_TEMPLATE.md
101
+ └── src/
102
+ ├── index.js
103
+ ├── apiFront.js
104
+ └── utils.js
105
+ ```
106
+
107
+ ### Adding Scaffolds to Apps
108
+
109
+ After an app is created via PWA, add code scaffolds via CLI:
110
+
111
+ ```bash
112
+ # Add site scaffold
113
+ descix site init
114
+
115
+ # Add microservice scaffold
116
+ descix microservice init
117
+ ```
118
+
119
+ ---
120
+
121
+ ## 3. Creation Flows
122
+
123
+ ### 3.1 Community Creation
124
+
125
+ **Trigger:** User creates community via PWA
126
+ **Backend Endpoint:** `create_community_with_app`
127
+
128
+ **Flow:**
129
+ ```mermaid
130
+ sequenceDiagram
131
+ participant PWA
132
+ participant Backend
133
+ participant Drive
134
+ participant Firestore
135
+
136
+ PWA->>Backend: create_community_with_app(name, token)
137
+ Backend->>Backend: Check entitlements
138
+ Backend->>Drive: copyFolderRecursive(COMMUNITY_TEMPLATE)
139
+ Drive-->>Backend: new_folder_id
140
+ Backend->>Firestore: Create Community doc
141
+ Backend->>Firestore: Create default App doc
142
+ Backend-->>PWA: {community_id, app_id, folder_id}
143
+ ```
144
+
145
+ **Backend Implementation:**
146
+ ```javascript
147
+ // communityManagement.js
148
+ async function create_community_with_app(params) {
149
+ // 1. Copy community template
150
+ const communityFolderId = await copyFolderRecursive(
151
+ DRIVE_COMMUNITY_TEMPLATE_FOLDER_ID,
152
+ userBaseFolderId,
153
+ params.name
154
+ );
155
+
156
+ // 2. Copy app template into community
157
+ const appFolderId = await copyFolderRecursive(
158
+ DRIVE_AGENT_APP_TEMPLATE_FOLDER_ID,
159
+ communityFolderId + '/Apps',
160
+ params.app_name
161
+ );
162
+
163
+ // 3. Create Firestore records
164
+ await createCommunityDoc(communityId, communityFolderId);
165
+ await createAppDoc(appId, appFolderId);
166
+
167
+ return { community_id, app_id };
168
+ }
169
+ ```
170
+
171
+ ### 3.2 App Creation
172
+
173
+ **Trigger:** User creates app via PWA (within existing community)
174
+ **Backend Endpoint:** `create_skeleton_app`
175
+
176
+ **Flow:**
177
+ ```mermaid
178
+ sequenceDiagram
179
+ participant PWA
180
+ participant Backend
181
+ participant Drive
182
+ participant Firestore
183
+
184
+ PWA->>Backend: create_skeleton_app(community_id, app_name)
185
+ Backend->>Backend: Check entitlements + service slot
186
+ Backend->>Drive: copyFolderRecursive(APP_TEMPLATE)
187
+ Drive-->>Backend: new_folder_id
188
+ Backend->>Firestore: Create App doc
189
+ Backend-->>PWA: {app_id, folder_id}
190
+ ```
191
+
192
+ ---
193
+
194
+ ## 4. Workspace Builder
195
+
196
+ The PWA Workspace Builder allows users to configure which apps to sync to their local workspace.
197
+
198
+ ### Flow
199
+
200
+ 1. User completes device login (`descix login --setup`)
201
+ 2. PWA opens with Workspace Builder
202
+ 3. User selects/creates apps to include
203
+ 4. PWA returns `workspace_config` to CLI
204
+ 5. CLI hydrates local folders
205
+
206
+ ### Workspace Config Response
207
+
208
+ ```json
209
+ {
210
+ "workspace_config": {
211
+ "communities": {
212
+ "descix": {
213
+ "apps": {
214
+ "agent": {
215
+ "localPath": "descix/agent",
216
+ "sync_mode": "git"
217
+ }
218
+ }
219
+ }
220
+ }
221
+ },
222
+ "drive_config": {
223
+ "base_folder_id": "1ABC..."
224
+ }
225
+ }
226
+ ```
227
+
228
+ ---
229
+
230
+ ## 5. CLI Hydration
231
+
232
+ ### Setup Command
233
+
234
+ ```bash
235
+ descix setup [--dev]
236
+ ```
237
+
238
+ **Flow:**
239
+ 1. Check prerequisites (gcloud CLI, ADC)
240
+ 2. Verify Drive access
241
+ 3. Open browser for device login
242
+ 4. Receive workspace config from PWA
243
+ 5. Call `Hydrator.hydrateWorkspace()`
244
+ 6. Create local folder structure
245
+ 7. Pull content from Drive
246
+
247
+ ### Hydration Process
248
+
249
+ The `Hydrator` module handles all folder creation and content sync:
250
+
251
+ ```javascript
252
+ // Hydrator.hydrateWorkspace() creates:
253
+ [workspace]/
254
+ ├── .descix/
255
+ │ └── workspace.json # Workspace configuration (sole config file)
256
+ ├── [community]/[app]/
257
+ │ ├── assets/
258
+ │ ├── kb/
259
+ │ │ ├── staging/ # For local files to push to Drive
260
+ │ │ ├── General/ # Converted text from Drive
261
+ │ │ └── chunks/ # Generated chunk files
262
+ │ ├── site/ # Optional: for CodeSite
263
+ │ └── microservice/ # Optional: for backend service
264
+ └── .gitignore # Updated with .descix/wallet.json
265
+ ```
266
+
267
+ **Note:** App configuration is stored in `workspace.json`, not in per-app `context.json` files. The CLI auto-detects app context based on the current working directory.
268
+
269
+ ### Hydrating Individual Apps
270
+
271
+ After initial setup, users can hydrate specific apps:
272
+
273
+ ```bash
274
+ # Pull entire app from Drive
275
+ descix kb pull -c community -a app
276
+
277
+ # Or use the build command for full pipeline
278
+ descix kb build
279
+ ```
280
+
281
+ ---
282
+
283
+ ## 6. Folder Structure Standards
284
+
285
+ ### App Folders
286
+
287
+ | Folder | Purpose | Sync Direction |
288
+ |--------|---------|----------------|
289
+ | `assets/` | App metadata (icon, description) | Bidirectional |
290
+ | `kb/staging/` | Local files to push to Drive | Local → Drive |
291
+ | `kb/General/` | Text-converted files from Drive | Drive → Local |
292
+ | `kb/chunks/` | JSON chunks for Pinecone | Local only |
293
+ | `site/` | Static site files | Local → GCS |
294
+ | `microservice/` | Service code | Local → GCS |
295
+
296
+ ### Required Files
297
+
298
+ **`assets/` folder:**
299
+ - `icon.png` - App icon (square, PNG, 512x512 recommended)
300
+ - `app_description.md` - Markdown description for App Store
301
+ - `system_instructions.md` - AI agent persona and instructions
302
+
303
+ **`kb/General/` folder:**
304
+ - Contains reference documents for RAG
305
+ - All formats converted to Markdown/text
306
+
307
+ ---
308
+
309
+ ## 7. Entitlement Checks
310
+
311
+ App creation requires appropriate entitlements:
312
+
313
+ | Resource | Entitlement Required |
314
+ |----------|---------------------|
315
+ | Community | Community Creation NFT or Subscription |
316
+ | App | Service Slot (Runner NFT/Subscription) |
317
+ | KB Storage | Included with app |
318
+ | Pinecone Vectors | Metered by plan |
319
+
320
+ The PWA and backend enforce these checks before template copying.
321
+
322
+ ---
323
+
324
+ ## 8. Key Backend Functions
325
+
326
+ ### Template Copying
327
+
328
+ ```javascript
329
+ // googleStorageService.js
330
+ async function copyFolderRecursive(sourceFolderId, destParentId, newName) {
331
+ // Recursively copies folder structure
332
+ // Maintains all files and subfolders
333
+ // Returns new folder ID
334
+ }
335
+ ```
336
+
337
+ ### Creation Endpoints
338
+
339
+ | Endpoint | Description |
340
+ |----------|-------------|
341
+ | `create_community_with_app` | Create community + default app + token |
342
+ | `create_skeleton_app` | Create app from template in existing community |
343
+ | `create_kb_subfolder` | Add KB subfolder to existing app |
344
+
345
+ ---
346
+
347
+ ## 9. CLI Commands
348
+
349
+ ### App Management (via PWA)
350
+
351
+ The CLI does not create apps directly. Users should:
352
+
353
+ 1. Go to PWA dashboard
354
+ 2. Create app/community
355
+ 3. Run `descix setup` or `descix login --setup` to hydrate
356
+
357
+ ### Post-Creation Commands
358
+
359
+ ```bash
360
+ # After app is created via PWA:
361
+ descix setup --dev # Hydrate workspace (first time)
362
+ descix kb build # Pull, chunk, sync KB
363
+ descix sync site # Deploy static site
364
+ ```
365
+
366
+ ---
367
+
368
+ ## 10. File References
369
+
370
+ | Component | Path | Description |
371
+ |-----------|------|-------------|
372
+ | Community Management | `DeSciX_Cloud/services/communityManagement.js` | Community/App creation |
373
+ | App Commands | `DeSciX_Cloud/services/commandHandlers/appCommands.js` | Server-side app ops |
374
+ | Google Storage Service | `DeSciX_Cloud/services/googleStorageService.js` | Drive/GCS operations |
375
+ | Template Config | `DeSciX_Cloud/defaults-config.json` | Template folder IDs |
376
+ | Drive Templates | `DeSciX_Core/descix-cli/templates/drive/` | Content templates |
377
+ | Git Scaffolds | `DeSciX_Core/descix-cli/templates/scaffolds/` | Code scaffolds |
378
+ | Hydrator | `DeSciX_Core/descix-cli/lib/core/Hydrator.js` | Workspace hydration |
379
+ | WorkspaceConfig | `DeSciX_Core/descix-cli/lib/workspace-config.js` | CLI configuration |
380
+ | Setup Command | `DeSciX_Core/descix-cli/lib/commands/setup.js` | Initial setup |
381
+ | Scaffold Command | `DeSciX_Core/descix-cli/bin/descix.js` | CLI scaffolds |