@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,415 @@
1
+ # Workspace Configuration Guide
2
+
3
+ **Status:** Implemented
4
+ **Version:** 2.0
5
+ **Last Updated:** January 2026
6
+
7
+ This document describes how DeSciX workspaces are configured, including workspace modes, configuration files, and sync modes.
8
+
9
+ ---
10
+
11
+ ## 1. Workspace Modes
12
+
13
+ The DeSciX CLI supports three workspace modes, determined by the structure of `workspace.json`.
14
+
15
+ ### 1.1 Single App Mode
16
+
17
+ **Use Case:** Dedicated repository for a single app.
18
+
19
+ ```json
20
+ {
21
+ "communities": {
22
+ "descix": {
23
+ "apps": {
24
+ "agent": {
25
+ "localPath": ".",
26
+ "sync_mode": "git"
27
+ }
28
+ }
29
+ }
30
+ }
31
+ }
32
+ ```
33
+
34
+ **Characteristics:**
35
+ - Workspace root IS the app folder
36
+ - No community subfolder created
37
+ - Simplest structure for focused development
38
+
39
+ **Folder Structure:**
40
+ ```
41
+ [workspace-root]/
42
+ ├── .descix/
43
+ │ └── workspace.json
44
+ ├── assets/
45
+ ├── kb/
46
+ ├── site/
47
+ └── microservice/
48
+ ```
49
+
50
+ ### 1.2 Single Community Mode
51
+
52
+ **Use Case:** Multiple apps within one community.
53
+
54
+ ```json
55
+ {
56
+ "communities": {
57
+ "descix": {
58
+ "apps": {
59
+ "agent": { "localPath": "agent", "sync_mode": "git" },
60
+ "docs": { "localPath": "docs", "sync_mode": "git" }
61
+ }
62
+ }
63
+ }
64
+ }
65
+ ```
66
+
67
+ **Folder Structure:**
68
+ ```
69
+ [workspace-root]/
70
+ ├── .descix/
71
+ │ └── workspace.json
72
+ ├── agent/
73
+ │ ├── assets/
74
+ │ └── kb/
75
+ └── docs/
76
+ ├── assets/
77
+ └── kb/
78
+ ```
79
+
80
+ ### 1.3 Multi-Community Mode
81
+
82
+ **Use Case:** Working across multiple communities.
83
+
84
+ ```json
85
+ {
86
+ "communities": {
87
+ "descix": {
88
+ "apps": {
89
+ "agent": { "localPath": "descix/agent", "sync_mode": "git" }
90
+ }
91
+ },
92
+ "myorg": {
93
+ "apps": {
94
+ "assistant": { "localPath": "myorg/assistant", "sync_mode": "git" }
95
+ }
96
+ }
97
+ }
98
+ }
99
+ ```
100
+
101
+ **Folder Structure:**
102
+ ```
103
+ [workspace-root]/
104
+ ├── .descix/
105
+ │ └── workspace.json
106
+ ├── descix/
107
+ │ └── agent/
108
+ │ ├── assets/
109
+ │ └── kb/
110
+ └── myorg/
111
+ └── assistant/
112
+ ├── assets/
113
+ └── kb/
114
+ ```
115
+
116
+ ---
117
+
118
+ ## 2. Configuration Files
119
+
120
+ ### 2.1 `.descix/workspace.json`
121
+
122
+ **Location:** `[workspace-root]/.descix/workspace.json`
123
+ **Purpose:** Workspace-level configuration
124
+
125
+ **Schema:**
126
+ ```json
127
+ {
128
+ "communities": {
129
+ "[community_id]": {
130
+ "apps": {
131
+ "[app_id]": {
132
+ "localPath": "path/to/app",
133
+ "sync_mode": "git"
134
+ }
135
+ }
136
+ }
137
+ },
138
+ "driveConfig": {
139
+ "base_folder_id": "1ABC..."
140
+ },
141
+ "environment": "development",
142
+ "apiUrl": "https://localhost:4000"
143
+ }
144
+ ```
145
+
146
+ **Fields:**
147
+
148
+ | Field | Required | Description |
149
+ |-------|----------|-------------|
150
+ | `communities` | Yes | Map of community IDs to their configuration |
151
+ | `communities.[id].apps` | Yes | Map of app IDs to their configuration |
152
+ | `communities.[id].apps.[id].localPath` | Yes | Relative path from workspace root |
153
+ | `communities.[id].apps.[id].kbId` | No | Default KB folder name (default: `"General"`) |
154
+ | `communities.[id].apps.[id].absolutePath` | No | Absolute path to app (auto-set during init) |
155
+ | `communities.[id].apps.[id].site.port` | No | Local dev server port for CodeSite |
156
+ | `communities.[id].apps.[id].service.port` | No | Local dev server port for Microservice |
157
+ | `driveConfig.base_folder_id` | Yes | User's Drive base folder ID |
158
+ | `environment` | No | `"development"` or `"production"` |
159
+ | `apiUrl` | No | Override API URL (dev mode) |
160
+
161
+ ### 2.2 `.descix/wallet.json`
162
+
163
+ **Location:** `[workspace-root]/.descix/wallet.json`
164
+ **Purpose:** Authentication credentials (Git-ignored)
165
+
166
+ **Schema:**
167
+ ```json
168
+ {
169
+ "walletAddress": "0x...",
170
+ "signature": "...",
171
+ "tokenSymbol": "DAITA",
172
+ "communityId": "descix",
173
+ "userId": "user_...",
174
+ "email": "user@example.com",
175
+ "sessionToken": "...",
176
+ "expiresAt": "2026-01-28T00:00:00.000Z"
177
+ }
178
+ ```
179
+
180
+ **Security:** This file is automatically added to `.gitignore` during setup.
181
+
182
+ ---
183
+
184
+ ## 3. Sync Modes
185
+
186
+ DeSciX supports two sync modes, determined by how the app is managed:
187
+
188
+ ### 3.1 Git Mode (CLI Developers)
189
+
190
+ **Source of Truth:** Local Git repository
191
+ **Versioning:** Git
192
+ **Tool:** CLI (`descix kb *` commands)
193
+
194
+ **Workflow:**
195
+ 1. User creates/edits documents in Google Drive
196
+ 2. User runs `descix kb pull` to get text-converted content
197
+ 3. User edits text files locally (Git version control)
198
+ 4. User runs `descix kb chunk` to generate chunks
199
+ 5. User runs `descix kb sync` to push chunks to Pinecone
200
+ 6. User commits changes to Git
201
+
202
+ **When to Use:**
203
+ - Developers with local development environment
204
+ - Need for Git version control
205
+ - Offline development capability
206
+ - Code review workflows
207
+ - CodeSite or Microservice development
208
+
209
+ ### 3.2 Drive Mode (PWA Users)
210
+
211
+ **Source of Truth:** Google Drive
212
+ **Versioning:** GCS/Firestore
213
+ **Tool:** PWA only (no CLI)
214
+
215
+ **Workflow:**
216
+ 1. User edits files in Drive or PWA
217
+ 2. Backend automatically syncs to GCS/Pinecone
218
+ 3. No local CLI involvement
219
+
220
+ **When to Use:**
221
+ - Non-technical users
222
+ - Browser-based editing
223
+ - Real-time collaboration
224
+ - No local tooling required
225
+ - Knowledge-base-only apps (no CodeSite or Microservice)
226
+
227
+ ### 3.3 Mode Determination
228
+
229
+ **Important:** The CLI only supports git-mode operations. If you're using the CLI, you're in git-mode.
230
+
231
+ | Tool | Mode | Configuration |
232
+ |------|------|---------------|
233
+ | CLI | Git mode only | `workspace.json` |
234
+ | PWA | Drive mode | Automatic (backend handles) |
235
+
236
+ There is no CLI command to switch modes - the mode is determined by which tool you use.
237
+
238
+ ---
239
+
240
+ ## 4. Drive Configuration
241
+
242
+ ### 4.1 Base Folder ID
243
+
244
+ The `base_folder_id` is the root of all DeSciX content in the user's Drive.
245
+
246
+ **Structure in Drive:**
247
+ ```
248
+ [User's Base Folder]/
249
+ ├── [community_id]/
250
+ │ ├── community_assets/
251
+ │ └── [app_id]/
252
+ │ ├── assets/
253
+ │ ├── kb/
254
+ │ │ └── General/
255
+ │ ├── site/
256
+ │ └── microservice/
257
+ └── [other_community]/
258
+ ```
259
+
260
+ **Folder Navigation:**
261
+ ```javascript
262
+ // Template-based navigation
263
+ const kbPath = `${communityId}/${appId}/kb/${kbId}`;
264
+ const folderId = await findFolderByPath(baseFolderId, kbPath);
265
+ ```
266
+
267
+ ### 4.2 Template-Based Navigation
268
+
269
+ The SDK navigates Drive using predictable template paths:
270
+
271
+ | Content | Drive Path |
272
+ |---------|------------|
273
+ | App folder | `{community}/{app}/` |
274
+ | KB folder | `{community}/{app}/kb/{kb_name}/` |
275
+ | Assets | `{community}/{app}/assets/` |
276
+ | Site | `{community}/{app}/site/` |
277
+
278
+ ---
279
+
280
+ ## 5. ADC Authentication
281
+
282
+ ### Requirements
283
+
284
+ Google Cloud ADC (Application Default Credentials) is required for Drive access.
285
+
286
+ **Setup:**
287
+ ```bash
288
+ gcloud auth application-default login \
289
+ --scopes=https://www.googleapis.com/auth/drive.file,https://www.googleapis.com/auth/drive
290
+ ```
291
+
292
+ ### Verification
293
+
294
+ The CLI verifies ADC before operations:
295
+
296
+ ```javascript
297
+ // google-storage-adc.js
298
+ async function verifyDriveAuth() {
299
+ const auth = new google.auth.GoogleAuth({
300
+ scopes: ['https://www.googleapis.com/auth/drive']
301
+ });
302
+ const drive = google.drive({ version: 'v3', auth });
303
+ const response = await drive.about.get({ fields: 'user' });
304
+ return response.data.user;
305
+ }
306
+ ```
307
+
308
+ ### Error Messages
309
+
310
+ | Error | Cause | Solution |
311
+ |-------|-------|----------|
312
+ | "Could not load default credentials" | ADC not configured | Run `gcloud auth application-default login` |
313
+ | "Drive authentication failed" | Scopes missing | Re-run with Drive scopes |
314
+ | "base_folder_id missing" | Not setup | Run `descix setup` |
315
+
316
+ ---
317
+
318
+ ## 6. Workspace Detection
319
+
320
+ ### Algorithm
321
+
322
+ ```javascript
323
+ function detectWorkspaceMode(workspaceConfig) {
324
+ const communities = Object.keys(workspaceConfig.communities || {});
325
+
326
+ if (communities.length === 0) {
327
+ throw new Error('No communities configured');
328
+ }
329
+
330
+ if (communities.length === 1) {
331
+ const apps = Object.keys(workspaceConfig.communities[communities[0]].apps);
332
+ if (apps.length === 1) {
333
+ const app = workspaceConfig.communities[communities[0]].apps[apps[0]];
334
+ if (app.localPath === '.' || app.localPath === '') {
335
+ return 'single_app';
336
+ }
337
+ }
338
+ return 'single_community';
339
+ }
340
+
341
+ return 'multi_community';
342
+ }
343
+ ```
344
+
345
+ ### Mode-Specific Behavior
346
+
347
+ | Mode | Community Folder | App Folder | Context Inference |
348
+ |------|-----------------|------------|-------------------|
349
+ | single_app | Workspace root | Workspace root | Full (community + app) |
350
+ | single_community | Workspace root | `./[app]/` | Community only |
351
+ | multi_community | `./[community]/` | `./[community]/[app]/` | None |
352
+
353
+ ---
354
+
355
+ ## 7. CLI Context Resolution
356
+
357
+ The CLI auto-detects app context from the current working directory:
358
+
359
+ ```javascript
360
+ // WorkspaceConfig.detectContext() matches cwd against registered app paths
361
+ detectContext(startDir = process.cwd()) {
362
+ const cwd = path.resolve(startDir);
363
+ for (const [commId, comm] of Object.entries(this.communities || {})) {
364
+ for (const [appId, app] of Object.entries(comm.apps || {})) {
365
+ if (app.absolutePath && cwd.startsWith(app.absolutePath)) {
366
+ return { communityId: commId, appId, kbId: app.kbId || 'General' };
367
+ }
368
+ }
369
+ }
370
+ return null;
371
+ }
372
+
373
+ // resolveContextWithOptions() combines CLI flags with autodiscovery
374
+ resolveContextWithOptions(options = {}) {
375
+ // 1. Try explicit flags first
376
+ if (options.community && options.app) {
377
+ return { communityId: options.community, appId: options.app, ... };
378
+ }
379
+
380
+ // 2. Fall back to autodiscovery from cwd
381
+ const detected = this.detectContext();
382
+ if (detected) {
383
+ return {
384
+ communityId: options.community || detected.communityId,
385
+ appId: options.app || detected.appId,
386
+ kbId: options.kb || detected.kbId
387
+ };
388
+ }
389
+
390
+ return null;
391
+ }
392
+ ```
393
+
394
+ **Usage Pattern:**
395
+ ```bash
396
+ # From within an app directory - auto-detects community/app
397
+ cd descix/appsdk
398
+ descix kb build # Works without -c/-a flags
399
+
400
+ # From workspace root - requires flags
401
+ cd /workspace
402
+ descix kb build -c descix -a appsdk
403
+ ```
404
+
405
+ ---
406
+
407
+ ## 8. File References
408
+
409
+ | Component | Path | Description |
410
+ |-----------|------|-------------|
411
+ | WorkspaceConfig | `DeSciX_Core/descix-cli/lib/workspace-config.js` | Sole configuration class for CLI |
412
+ | GlobalConfig | `DeSciX_Core/descix-cli/lib/global-config.js` | User-level settings (~/.descix) |
413
+ | Workspace Utils | `DeSciX_Core/descix-cli/lib/workspace-utils.js` | Helper utilities |
414
+ | Setup Command | `DeSciX_Core/descix-cli/lib/commands/setup.js` | Initial workspace setup |
415
+ | Config Commands | `DeSciX_Core/descix-cli/lib/commands/config.js` | Configuration management |
@@ -0,0 +1,243 @@
1
+ ---
2
+ alwaysApply: true
3
+ ---
4
+
5
+ # DeSciX SDK Agent Instructions
6
+
7
+ You have SDK agent assets available locally at `{{SDK_ASSETS_PATH}}/`.
8
+
9
+ ## Key Architecture Concepts
10
+
11
+ ### Configuration: workspace.json is the Config File
12
+
13
+ - **`workspace.json`** at `.descix/workspace.json` is the configuration file
14
+ - **Context auto-detection** - CLI commands detect community/app from current working directory
15
+
16
+ ### CLI = Git Mode ONLY
17
+
18
+ - The CLI only supports **git-mode** operations (local processing with Git version control)
19
+ - **Drive-mode** apps are managed via PWA only (server-side processing)
20
+ - All content starts on Drive - developers pull it locally, then manage with Git
21
+
22
+ ### App Folder Structure (Convention-Based)
23
+
24
+ ```
25
+ my-app/
26
+ ├── assets/ # App metadata (icon.png, app_description.md, system_instructions.md)
27
+ ├── kb/ # Knowledge base
28
+ │ ├── staging/ # Files to push TO Drive
29
+ │ ├── General/ # Text files pulled FROM Drive
30
+ │ └── chunks/ # Generated JSON chunks (Git-tracked)
31
+ ├── site/ # CodeSite static files (optional)
32
+ └── microservice/ # Backend service code (optional)
33
+ ```
34
+
35
+ ## Post-Setup Initialization
36
+
37
+ **IMPORTANT**: Check `.descix/workspace.json` for `_needsAgentSetup: true`.
38
+
39
+ When this flag is set, the user has just completed `descix setup` and needs your help configuring their workspace:
40
+
41
+ 1. **Greet the user** and confirm MCP is working: "I can see your DeSciX setup is complete. Let me help you configure your workspace."
42
+ 2. **Show their entitlements** from the cached JSON below (communities and apps they own)
43
+ 3. **Ask**: "Which app would you like to configure first?" or "Would you like me to scan your folders and suggest mappings?"
44
+ 4. **For each app folder**:
45
+ - Analyze the folder structure using heuristics from `{{SDK_ASSETS_PATH}}/instructions/folder-analysis.md`
46
+ - Recommend a packaging type using the decision tree from `{{SDK_ASSETS_PATH}}/instructions/packaging-types.md`
47
+ - Register the app in `workspace.json` with its localPath and absolutePath
48
+ 5. **When done**, set `_needsAgentSetup: false` in workspace.json
49
+
50
+ If user asks "Help me configure my workspace" or similar, follow this flow.
51
+
52
+ ## Entitlements-First Principle
53
+
54
+ **CRITICAL**: Users purchase apps/communities in the PWA first. Your role is to help configure local folders for apps they already own.
55
+
56
+ ### On First Interaction
57
+
58
+ 1. Check `.descix/workspace.json` for existing configuration
59
+ 2. If `_needsAgentSetup: true`, follow the Post-Setup Initialization flow above
60
+ 3. If unconfigured, read `{{SDK_ASSETS_PATH}}/instructions/onboarding-flow.md`
61
+ 4. For fresh entitlements: `execute_remote_command({ command: "fetch_my_purchases" })`
62
+ 5. Guide user through folder-to-app mapping in `workspace.json`
63
+
64
+ ## Local Asset References
65
+
66
+ For quick decisions, read these local files (no network required):
67
+
68
+ | File | Purpose |
69
+ |------|---------|
70
+ | `{{SDK_ASSETS_PATH}}/instructions/packaging-types.md` | App type taxonomy and decision tree |
71
+ | `{{SDK_ASSETS_PATH}}/instructions/folder-analysis.md` | Detect project type from files |
72
+ | `{{SDK_ASSETS_PATH}}/instructions/conversation-guides.md` | Dialogue templates |
73
+ | `{{SDK_ASSETS_PATH}}/instructions/onboarding-flow.md` | Full onboarding workflow |
74
+
75
+ ## Template Usage
76
+
77
+ When scaffolding apps, use templates from `{{SDK_ASSETS_PATH}}/templates/`:
78
+
79
+ | Packaging Type | Templates Available |
80
+ |----------------|---------------------|
81
+ | `knowledge-only` | Assets folder only |
82
+ | `static-site` | Site folder scaffold |
83
+ | `microservice` | `manifest.json.template`, `SERVICE_README.template` |
84
+ | `dynamic-site` | Site + microservice scaffolds |
85
+
86
+ Replace `{{PLACEHOLDER}}` values with actual data from user input.
87
+
88
+ ## User Entitlements (Cached at Setup)
89
+
90
+ ```json
91
+ {{ENTITLEMENTS_JSON}}
92
+ ```
93
+
94
+ **Primary Community**: {{PRIMARY_COMMUNITY}}
95
+
96
+ Use this cached data for quick checks. For fresh data, call `fetch_my_purchases`.
97
+
98
+ ## Tiered Access Pattern
99
+
100
+ Use the appropriate tier based on what you need:
101
+
102
+ ### Tier 1: Local Files (Instant)
103
+ ```javascript
104
+ // Read instructions directly
105
+ Read("{{SDK_ASSETS_PATH}}/instructions/packaging-types.md")
106
+ ```
107
+ **Use for**: Quick lookups, decision trees, templates
108
+
109
+ ### Tier 2: tell_me_how (Semantic Discovery)
110
+ ```javascript
111
+ tell_me_how({
112
+ question: "How do I scaffold a microservice?",
113
+ scope: "entitlements"
114
+ })
115
+ ```
116
+ **Use for**: Finding the right tool for a task
117
+
118
+ ### Tier 3: chat_with_kb (Rich Context)
119
+ ```javascript
120
+ chat_with_kb({
121
+ communityId: "descix",
122
+ appId: "docs",
123
+ kbId: "sdk",
124
+ message: "Explain the deployment workflow for dynamic sites"
125
+ })
126
+ ```
127
+ **Use for**: Complex questions requiring reasoning
128
+
129
+ ### Tier 4: execute_remote_command (Action)
130
+ ```javascript
131
+ execute_remote_command({
132
+ command: "scaffold_app_type",
133
+ params: { type: "microservice", app_id: "myapp", ... }
134
+ })
135
+ ```
136
+ **Use for**: Actually creating/modifying things
137
+
138
+ ## Tool Discovery
139
+
140
+ Use `tell_me_how` to discover platform capabilities:
141
+
142
+ ```javascript
143
+ // Discover tools for a task
144
+ tell_me_how({ question: "How do I deploy my app?", scope: "entitlements" })
145
+
146
+ // Then execute the recommended command
147
+ execute_remote_command({ command: "discovered_command", params: {...} })
148
+ ```
149
+
150
+ **Scope Options**:
151
+ - `project`: Only tools for apps in workspace.json
152
+ - `entitlements`: Tools for all apps user owns (default)
153
+ - `discovery`: All platform tools (may show purchasable)
154
+
155
+ ## App Configuration Workflow
156
+
157
+ When user wants to configure a folder:
158
+
159
+ 1. **Analyze folder** using heuristics from `folder-analysis.md`
160
+ 2. **Recommend packaging type** using decision tree from `packaging-types.md`
161
+ 3. **Present options** using dialogue from `conversation-guides.md`
162
+ 4. **Register app** in `workspace.json` with localPath and absolutePath
163
+ 5. **Guide CLI commands** based on packaging type
164
+
165
+ ## Primary CLI Commands
166
+
167
+ Guide users to these git-mode commands:
168
+
169
+ ### Knowledge Base Commands
170
+ | Command | Purpose |
171
+ |---------|---------|
172
+ | `descix kb pull` | Pull text-converted content from Drive |
173
+ | `descix kb push` | Push staging files to Drive |
174
+ | `descix kb chunk` | Generate JSON chunks from text files |
175
+ | `descix kb sync` | Push chunks to Pinecone |
176
+ | `descix kb build` | Full pipeline: pull → chunk → sync |
177
+ | `descix kb status` | Show local vs Pinecone sync status |
178
+
179
+ ### Site Commands
180
+ | Command | Purpose |
181
+ |---------|---------|
182
+ | `descix site init` | Copy site scaffold to app |
183
+ | `descix site upload` | Deploy CodeSite to GCS |
184
+ | `descix site servelocal [port]` | Register local dev server port |
185
+ | `descix site list` | List deployed site files |
186
+ | `descix site status` | Get deployment status |
187
+
188
+ ### Microservice Commands
189
+ | Command | Purpose |
190
+ |---------|---------|
191
+ | `descix microservice init` | Copy microservice scaffold to app |
192
+ | `descix microservice register` | Register microservice with gateway |
193
+ | `descix microservice vectorize` | Vectorize README for discovery |
194
+ | `descix microservice list` | List registered microservices |
195
+ | `descix microservice health <name>` | Check microservice health |
196
+ | `descix microservice reload` | Reload manifests (admin) |
197
+
198
+ **Context Auto-Detection**: When run from within an app directory, these commands auto-detect community/app from `workspace.json`. Otherwise use `-c` and `-a` flags.
199
+
200
+ ## SDK Tools Available (Remote)
201
+
202
+ These tools are auto-registered and discoverable via `tell_me_how`:
203
+
204
+ | Tool | Purpose |
205
+ |------|---------|
206
+ | `scaffold_app_type` | Create boilerplate for chosen packaging type |
207
+ | `analyze_folder_structure` | Detect project type from folder contents |
208
+ | `get_app_sync_status` | Check what's synced (KB, site, service) |
209
+ | `fetch_my_purchases` | Get user's entitlements |
210
+ | `register_service` | Register microservice with gateway |
211
+ | `vectorize_service_readme` | Enable tell_me_how discovery |
212
+
213
+ ## Key Principles
214
+
215
+ 1. **Never assume** - Always ask before creating mappings
216
+ 2. **Entitlements are truth** - Can't configure apps user doesn't own
217
+ 3. **Local first** - Read local assets before making network calls
218
+ 4. **Guide, don't dictate** - Present options, let user choose
219
+ 5. **workspace.json is truth** - All configuration goes here
220
+
221
+ ## Error Recovery
222
+
223
+ If commands fail:
224
+ 1. Check authentication: Is `wallet.json` valid?
225
+ 2. Check entitlements: Does user own the app?
226
+ 3. Check configuration: Is app registered in `workspace.json`?
227
+ 4. Check location: Are you in the app directory or using `-c/-a` flags?
228
+ 5. Use `tell_me_how` to find alternative approaches
229
+
230
+ ### Common Errors
231
+
232
+ | Error | Cause | Solution |
233
+ |-------|-------|----------|
234
+ | "Workspace not configured" | No workspace.json | Run `descix init` |
235
+ | "Could not determine app context" | Not in app directory | `cd` to app or use `-c/-a` flags |
236
+ | "ADC not configured" | Missing Google auth | Run `gcloud auth application-default login` |
237
+ | "App not found in workspace" | App not registered | Run `descix setup` or add to workspace.json |
238
+
239
+ ---
240
+
241
+ *Generated by DeSciX SDK Setup*
242
+ *SDK Version: {{SDK_VERSION}}*
243
+ *Workspace: {{WORKSPACE_PATH}}*