@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
package/README.md ADDED
@@ -0,0 +1,95 @@
1
+ # DeSciX CLI
2
+
3
+ The official command-line interface for the DeSciX platform.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install -g @descix/cli
9
+ ```
10
+
11
+ ## Quick Start
12
+
13
+ 1. **Login to DeSciX**:
14
+ ```bash
15
+ descix login
16
+ ```
17
+
18
+ 2. **Setup your workspace**:
19
+ ```bash
20
+ descix setup
21
+ ```
22
+ This will guide you through connecting your Google Drive and setting up your local environment.
23
+
24
+ **Development Mode**:
25
+ If you are developing locally or against a test environment, you can use the `--dev` flag:
26
+ ```bash
27
+ npx descix setup --dev
28
+ ```
29
+ This defaults to `https://localhost:4000` unless configured otherwise.
30
+
31
+ 3. **Check your status**:
32
+ ```bash
33
+ descix status
34
+ ```
35
+
36
+ ## Workspace Modes
37
+
38
+ The CLI supports three workspace modes to accommodate different development needs:
39
+
40
+ ### 1. Single App Mode (`single_app`)
41
+ Best for individual developers working on one app.
42
+ - **Structure**: The root folder is your app folder.
43
+ - **Drive Path**: `{community_id}/{app_id}/`
44
+
45
+ ### 2. Single Community Mode (`single_community`)
46
+ Best for teams managing multiple apps within one community.
47
+ - **Structure**: The root folder is the community folder, containing subfolders for each app.
48
+ - **Drive Path**: `{community_id}/`
49
+
50
+ ### 3. Multi-Community Mode (`multi_community`)
51
+ Best for platform admins or agencies managing multiple communities.
52
+ - **Structure**: The root folder contains subfolders for each community.
53
+ - **Drive Path**: `/` (Root of your base folder)
54
+
55
+ ## Core Commands
56
+
57
+ - `descix login`: Authenticate with the platform.
58
+ - `descix setup`: Initialize or repair your workspace configuration.
59
+ - `descix status`: View your current environment status and workspace mode.
60
+ - `descix init`: Create `.descix/workspace.json` for the current project.
61
+ - `descix app create`: Show instructions; use `--quick -c <community> -a <name>` for template-only app creation, or use PWA / `descix-admin app create`.
62
+ - `descix sync`: Sync content to the platform (Site, Assets).
63
+ - `descix kb`: Manage Knowledge Base content (Pull -> Chunk -> Sync).
64
+
65
+ ## Knowledge Base Management (Git Mode)
66
+
67
+ For apps managed via CLI (Git Mode), use the following commands to process your Knowledge Base locally:
68
+
69
+ 1. **Pull**: Fetch source documents from Drive.
70
+ ```bash
71
+ descix kb pull
72
+ ```
73
+ 2. **Chunk**: Process documents into chunks locally.
74
+ ```bash
75
+ descix kb chunk
76
+ ```
77
+ 3. **Sync**: Push chunks to the platform (Pinecone).
78
+ ```bash
79
+ descix kb sync
80
+ ```
81
+ 4. **Build**: Run the full pipeline (Pull -> Chunk -> Sync).
82
+ ```bash
83
+ descix kb build
84
+ ```
85
+
86
+ ## Provisioning
87
+
88
+ **Communities and apps are created in the PWA** (Workspace Config / Device Setup / App Manager) or via **Admin CLI** (`descix-admin community create`, `descix-admin app create`) for platform admins. The user CLI does not create communities or full app structures; use `descix init` to write `.descix/workspace.json` and PWA or Admin CLI to create entities.
89
+
90
+ 1. Create your App in the PWA (Workspace Builder).
91
+ 2. Run `descix setup` to hydrate your local folder structure.
92
+
93
+ ## Documentation
94
+
95
+ For full documentation, please refer to the [DeSciX SDK Documentation](../../SERVICE_README_sdk.md).
@@ -0,0 +1,399 @@
1
+ # DeSciX SDK - CLI and MCP Tools
2
+
3
+ ## Overview
4
+
5
+ The DeSciX SDK provides command-line tools and MCP (Model Context Protocol) integration for building applications on the DeSciX platform. The SDK enables developers to authenticate, manage workspaces, create apps, and leverage AI-assisted development through Cursor IDE integration.
6
+
7
+ **Key capabilities:**
8
+ - CLI commands for all platform operations
9
+ - MCP server for Cursor IDE integration
10
+ - Intelligent tool discovery via `tell_me_how`
11
+ - Entitlements-driven workspace setup
12
+ - Git-aware project initialization
13
+
14
+ ---
15
+
16
+ ## Installation
17
+
18
+ ```bash
19
+ # Global install (recommended)
20
+ npm install -g @descix/cli
21
+
22
+ # Or via npm link during development
23
+ cd DeSciX_Core/descix-cli
24
+ npm link
25
+ ```
26
+
27
+ ---
28
+
29
+ ## CLI Commands
30
+
31
+ ### descix setup
32
+
33
+ **Description:** One-time workspace configuration wizard
34
+ **Use when:** First time setting up DeSciX in a new workspace or Cursor project
35
+ **What it does:**
36
+ 1. Prompts for API endpoint (production/local/custom)
37
+ 2. Runs device authentication (opens browser)
38
+ 3. Creates `.cursor/mcp.json` for MCP server
39
+ 4. Creates `.cursor/rules/descix_mcp.mdc` for AI agent instructions
40
+ 5. Creates `.descix/workspace.json` with initial configuration
41
+
42
+ **Example:**
43
+ ```bash
44
+ cd ~/Projects/MyApp
45
+ descix setup
46
+ # Follow the prompts
47
+ # Restart Cursor after completion
48
+ ```
49
+
50
+ ---
51
+
52
+ ### descix login
53
+
54
+ **Description:** Authenticate with the DeSciX platform
55
+ **Use when:** Session expired or first-time authentication
56
+ **Options:**
57
+ - `--device` (default): Opens browser for Powch authentication
58
+ - `--wallet`: Direct wallet signature authentication
59
+
60
+ **Example:**
61
+ ```bash
62
+ descix login
63
+ # Opens browser, complete authentication
64
+ # Credentials saved to .descix/wallet.json
65
+ ```
66
+
67
+ ---
68
+
69
+ ### descix whoami
70
+
71
+ **Description:** Display current authentication status
72
+ **Use when:** Checking if you're logged in and what account you're using
73
+
74
+ **Example:**
75
+ ```bash
76
+ descix whoami
77
+ # Output:
78
+ # User: sam@descix.net
79
+ # Wallet: 0xe71b412d...
80
+ # Session: Valid
81
+ ```
82
+
83
+ ---
84
+
85
+ ### descix tell-me-how
86
+
87
+ **Description:** Discover platform tools using natural language
88
+ **Use when:** You don't know which command to use for a task
89
+
90
+ **Options:**
91
+ - `--scope project`: Search within current workspace apps
92
+ - `--scope entitlements`: Search apps you have access to (default)
93
+ - `--scope discovery`: Search all platform tools
94
+ - `--json`: Output raw JSON response
95
+
96
+ **Examples:**
97
+ ```bash
98
+ # Find how to create an app
99
+ descix tell-me-how "How do I create a new app?"
100
+
101
+ # Search within current project
102
+ descix tell-me-how --scope project "How do I sync my knowledge base?"
103
+
104
+ # Discover all available tools
105
+ descix tell-me-how --scope discovery "What AI training tools exist?"
106
+ ```
107
+
108
+ ---
109
+
110
+ ### descix app create
111
+
112
+ **Description:** Create or hydrate an app using the interactive wizard
113
+ **Use when:** Starting a new project or hydrating an existing app
114
+ **Options:**
115
+ - `-c, --community <id>`: Community ID
116
+ - `-a, --app <name>`: App name
117
+ - `--wizard`: Interactive wizard mode
118
+ - `--quick`: Skip optional prompts
119
+
120
+ **Note:** New apps should primarily be provisioned via the PWA. This command can hydrate a local workspace from an existing app or create a skeleton if permitted.
121
+
122
+ **Example:**
123
+ ```bash
124
+ # Interactive wizard
125
+ descix app create --wizard
126
+ ```
127
+
128
+ ---
129
+
130
+ ### descix kb
131
+
132
+ **Description:** Manage Knowledge Base content (Git Mode)
133
+ **Use when:** Processing KB documents locally
134
+
135
+ **Subcommands:**
136
+ - `pull`: Download source documents from Drive to `kb/src/`
137
+ - `chunk`: Process source files into chunks in `kb/chunks/`
138
+ - `sync`: Push chunks to the platform (Pinecone)
139
+ - `build`: Run the full pipeline (Pull -> Chunk -> Sync)
140
+
141
+ **Example:**
142
+ ```bash
143
+ # Full build pipeline
144
+ descix kb build -c descix -a myapp
145
+ ```
146
+
147
+ ---
148
+
149
+ ### descix microservice vectorize
150
+
151
+ **Description:** Vectorize a SERVICE_README for tell_me_how discovery
152
+ **Use when:** Adding or updating service documentation
153
+ **Options:**
154
+ - `-n, --name <name>`: Service name
155
+ - `-c, --community <id>`: Community ID
156
+ - `-a, --app <id>`: App ID
157
+ - `-r, --readme <path>`: Path to README file
158
+
159
+ **Example:**
160
+ ```bash
161
+ descix microservice vectorize -r ./SERVICE_README_myservice.md
162
+ ```
163
+
164
+ ---
165
+
166
+ ### descix purchases
167
+
168
+ **Description:** List your entitlements (communities, apps, service slots)
169
+ **Use when:** Checking what resources you have access to
170
+
171
+ **Example:**
172
+ ```bash
173
+ descix purchases
174
+ # Output shows communities, apps, and service slots
175
+ ```
176
+
177
+ ---
178
+
179
+ ## MCP Tools (for Cursor AI)
180
+
181
+ After running `descix setup` and restarting Cursor, these MCP tools are available to the AI agent:
182
+
183
+ ### tell_me_how
184
+
185
+ **Description:** Primary discovery tool - finds relevant commands for any task
186
+ **Use first:** Always use this before attempting platform operations
187
+
188
+ ```javascript
189
+ tell_me_how({
190
+ question: "How do I deploy my app?",
191
+ scope: "entitlements"
192
+ })
193
+ ```
194
+
195
+ **Scope options:**
196
+ - `project`: Uses `.descix/workspace.json` mappings
197
+ - `entitlements`: Only tools you have access to (default)
198
+ - `discovery`: All platform tools (may require purchase)
199
+
200
+ ---
201
+
202
+ ### execute_remote_command
203
+
204
+ **Description:** Execute any backend command discovered via tell_me_how
205
+ **Use after:** tell_me_how returns recommended commands
206
+
207
+ ```javascript
208
+ execute_remote_command({
209
+ command: "create_app",
210
+ params: {
211
+ community_id: "descix",
212
+ app_name: "My New App"
213
+ }
214
+ })
215
+ ```
216
+
217
+ ---
218
+
219
+ ### descix_init
220
+
221
+ **Description:** Initialize a local project for DeSciX deployment
222
+ **Use when:** Setting up a new project folder
223
+
224
+ ```javascript
225
+ descix_init({
226
+ projectPath: "/Users/dev/Projects/MyApp",
227
+ appName: "my-app",
228
+ communityId: "descix"
229
+ })
230
+ ```
231
+
232
+ **Creates:**
233
+ - `.descix/workspace.json` or `.descix/context.json`
234
+ - `app_description.md` from README if missing
235
+ - Folder structure for knowledge base
236
+
237
+ ---
238
+
239
+ ### descix_wizard_step
240
+
241
+ **Description:** Execute multi-step wizard workflows
242
+ **Use when:** Creating apps, communities, or complex operations
243
+
244
+ ```javascript
245
+ descix_wizard_step({
246
+ wizard_type: "create_app",
247
+ step: "init",
248
+ params: {
249
+ community_id: "descix",
250
+ app_name: "My App"
251
+ }
252
+ })
253
+ ```
254
+
255
+ **Wizard types:**
256
+ - `create_app`: App creation with folder setup
257
+ - `create_community`: Community creation with token
258
+ - `publish_kb`: Knowledge base sync and publish
259
+
260
+ ---
261
+
262
+ ### git_sync_ops
263
+
264
+ **Description:** Git operations with auto-generated commit messages
265
+ **Use when:** Committing changes, checking status
266
+
267
+ ```javascript
268
+ git_sync_ops({
269
+ operation: "status", // or "commit", "diff", "sync_info"
270
+ projectPath: "/Users/dev/Projects/MyApp"
271
+ })
272
+ ```
273
+
274
+ ---
275
+
276
+ ### search_knowledge_base
277
+
278
+ **Description:** Search a specific knowledge base via RAG
279
+ **Use when:** You know the exact KB to search
280
+
281
+ ```javascript
282
+ search_knowledge_base({
283
+ communityId: "descix",
284
+ appId: "docs",
285
+ kbId: "sdk",
286
+ query: "How do I authenticate?"
287
+ })
288
+ ```
289
+
290
+ ---
291
+
292
+ ### chat_with_kb
293
+
294
+ **Description:** Conversational RAG with knowledge base context
295
+ **Use when:** Complex questions requiring AI reasoning
296
+
297
+ ```javascript
298
+ chat_with_kb({
299
+ communityId: "descix",
300
+ appId: "docs",
301
+ kbId: "sdk",
302
+ message: "Explain the authentication flow step by step"
303
+ })
304
+ ```
305
+
306
+ ---
307
+
308
+ ## Workspace Configuration
309
+
310
+ ### workspace.json (Monorepo)
311
+
312
+ For multi-app workspaces, create `.descix/workspace.json`:
313
+
314
+ ```json
315
+ {
316
+ "version": "2.0",
317
+ "primaryCommunity": "descix",
318
+ "directoryMappings": {
319
+ "frontend": { "communityId": "descix", "appId": "pwa", "kbId": "General" },
320
+ "backend": { "communityId": "descix", "appId": "cloud", "kbId": "General" },
321
+ "docs": { "communityId": "descix", "appId": "docs", "kbId": "sdk" }
322
+ },
323
+ "defaultContext": {
324
+ "communityId": "descix",
325
+ "appId": "docs",
326
+ "kbId": "sdk"
327
+ }
328
+ }
329
+ ```
330
+
331
+ ### context.json (Single App)
332
+
333
+ For individual app folders, create `.descix/context.json`:
334
+
335
+ ```json
336
+ {
337
+ "version": "2.0",
338
+ "type": "app",
339
+ "community_id": "descix",
340
+ "app_id": "myapp",
341
+ "app_name": "My Application",
342
+ "folders": {
343
+ "app": { "local_path": ".", "sync_type": "assets" },
344
+ "kb": { "local_path": "docs", "sync_type": "rag" }
345
+ }
346
+ }
347
+ ```
348
+
349
+ ---
350
+
351
+ ## Common Workflows
352
+
353
+ ### New Developer Onboarding (Cursor IDE)
354
+
355
+ 1. Install CLI: `npm install -g @descix/cli`
356
+ 2. Run setup: `descix setup`
357
+ 3. Restart Cursor (Cmd+Shift+P → "Reload Window")
358
+ 4. AI agent can now use MCP tools
359
+ 5. Ask: "How do I create an app?"
360
+ 6. AI uses `tell_me_how` → `execute_remote_command`
361
+
362
+ ### Entitlements-First App Creation
363
+
364
+ 1. AI calls `execute_remote_command({ command: "fetch_my_purchases" })`
365
+ 2. AI presents user's communities and apps
366
+ 3. User selects community (or creates new)
367
+ 4. AI calls `descix_wizard_step` for app creation
368
+ 5. AI creates local `.descix/context.json`
369
+
370
+ ### Monorepo Setup
371
+
372
+ 1. AI calls `fetch_my_purchases` to get entitlements
373
+ 2. AI scans workspace folders
374
+ 3. AI asks user: "Map `frontend/` to which app?"
375
+ 4. AI creates `.descix/workspace.json` with mappings
376
+ 5. `tell_me_how --scope project` now uses these mappings
377
+
378
+ ---
379
+
380
+ ## Troubleshooting
381
+
382
+ ### "MCP tools not available"
383
+ 1. Run `descix setup` in workspace root
384
+ 2. Restart Cursor completely
385
+ 3. Check `.cursor/mcp.json` exists with `descix` server
386
+
387
+ ### "Session expired"
388
+ Run `descix reconnect` or `descix login`
389
+
390
+ ### "No results from tell_me_how"
391
+ Service READMEs may not be vectorized. Ask admin to run `descix microservice vectorize` for relevant services.
392
+
393
+ ### "workspace.json not found" for project scope
394
+ Run `descix init` or let AI create workspace.json via `descix_init` MCP tool.
395
+
396
+ ---
397
+
398
+ *SDK Version: 2.0.0*
399
+ *Package: @descix/cli*
@@ -0,0 +1,61 @@
1
+ # App Pattern Guides
2
+
3
+ These guides describe the four app packaging patterns in DeSciX. Use them to help users choose the right architecture for their needs.
4
+
5
+ ## Patterns Overview
6
+
7
+ | Pattern | Description | Public URL | MCP Tools |
8
+ |---------|-------------|------------|-----------|
9
+ | [Knowledge-Only](./knowledge-only-pattern.md) | RAG-indexed docs, no UI | No | No |
10
+ | [Static Site](./static-site-pattern.md) | HTML/CSS/JS + RAG docs | Yes | No |
11
+ | [Microservice](./microservice-pattern.md) | Backend service + MCP tools | Yes | Yes |
12
+ | [Dynamic Site](./dynamic-site-pattern.md) | SSR app + MCP tools | Yes | Yes |
13
+
14
+ ## Decision Tree
15
+
16
+ ```
17
+ Does the user need a public website?
18
+ │
19
+ ├── NO → Knowledge-Only
20
+ │
21
+ └── YES → Does it have backend logic?
22
+ │
23
+ ├── NO → Static Site
24
+ │
25
+ └── YES → Does it need SSR?
26
+ │
27
+ ├── NO → Microservice
28
+ │
29
+ └── YES → Dynamic Site
30
+ ```
31
+
32
+ ## Quick Reference
33
+
34
+ ### Knowledge-Only
35
+ - Just docs/content for RAG search
36
+ - No `site/` or `microservice/` folders needed
37
+ - Commands: `descix kb pull/push/chunk/sync`
38
+
39
+ ### Static Site
40
+ - Built HTML/CSS/JS deployed to CDN
41
+ - Add `site/` folder with `descix site init`
42
+ - Commands: `descix site upload`
43
+
44
+ ### Microservice
45
+ - Backend service with MCP-exposed commands
46
+ - Add `microservice/` folder with `descix microservice init`
47
+ - Commands: `descix microservice register/vectorize`
48
+
49
+ ### Dynamic Site
50
+ - SSR app where microservice serves the site
51
+ - Everything in `microservice/` (no separate `site/`)
52
+ - Commands: `descix deploy service`
53
+
54
+ ## Two-Tier Template System
55
+
56
+ All patterns use the same two-tier template approach:
57
+
58
+ 1. **Drive Templates** - Content (assets, KB) synced to/from Google Drive
59
+ 2. **Git Scaffolds** - Code (site, microservice) copied from SDK templates
60
+
61
+ See [templates/drive/](../../templates/drive/) and [templates/scaffolds/](../../templates/scaffolds/) for the actual templates.
@@ -0,0 +1,125 @@
1
+ # Dynamic Site App Pattern
2
+
3
+ ## Overview
4
+
5
+ A Dynamic Site app is a server-rendered application where the microservice handles both API and HTML rendering (SSR).
6
+
7
+ ## When to Use
8
+
9
+ Choose this pattern when the user wants to:
10
+ - Build a full web application with server-side rendering
11
+ - Create apps requiring real-time server logic
12
+ - Implement multi-tenant platforms
13
+ - Build complex apps where client-side isn't sufficient
14
+
15
+ **Key Questions:**
16
+ 1. "Does it need server-side rendering?" → Yes
17
+ 2. "Is the site content dynamically generated?" → Yes
18
+
19
+ ## Structure
20
+
21
+ ```
22
+ my-dynamic-app/
23
+ ├── assets/
24
+ │ ├── app_description.md
25
+ │ ├── icon.png
26
+ │ └── system_instructions.md
27
+ ├── kb/
28
+ │ ├── staging/
29
+ │ ├── General/
30
+ │ │ ├── README.md
31
+ │ │ └── user-guide.md
32
+ │ └── chunks/
33
+ ├── site/
34
+ │ └── README.md # "Site served by microservice"
35
+ ├── microservice/
36
+ │ ├── manifest.json
37
+ │ ├── SERVICE_README_myapp.md
38
+ │ ├── package.json
39
+ │ ├── Dockerfile
40
+ │ ├── app.yaml
41
+ │ └── src/
42
+ │ ├── index.js
43
+ │ ├── pages/ # SSR routes
44
+ │ │ ├── index.js
45
+ │ │ └── dashboard.js
46
+ │ ├── api/ # API routes
47
+ │ │ └── ...
48
+ │ └── views/ # Templates
49
+ │ └── ...
50
+ └── package.json
51
+ ```
52
+
53
+ ## Configuration (`workspace.json`)
54
+
55
+ ```json
56
+ {
57
+ "communities": {
58
+ "my-community": {
59
+ "apps": {
60
+ "my-dynamic-app": {
61
+ "localPath": "my-community/my-dynamic-app",
62
+ "sync_mode": "git",
63
+ "service": {
64
+ "port": 4000,
65
+ "devCommand": "npm run dev"
66
+ }
67
+ }
68
+ }
69
+ }
70
+ }
71
+ }
72
+ ```
73
+
74
+ ## CLI Workflow
75
+
76
+ ```bash
77
+ # 1. Create microservice scaffold
78
+ descix microservice init
79
+
80
+ # 2. Add SSR routes to your service
81
+
82
+ # 3. Deploy to Cloud Run
83
+ descix deploy service
84
+
85
+ # 4. Register and vectorize
86
+ descix microservice register
87
+ descix microservice vectorize
88
+
89
+ # 5. Sync KB
90
+ descix kb sync -c <community> -a <app>
91
+ ```
92
+
93
+ ## Capabilities
94
+
95
+ | Capability | Enabled |
96
+ |------------|---------|
97
+ | RAG search | Yes |
98
+ | chat_with_kb | Yes |
99
+ | Public URL | Yes |
100
+ | MCP tools | Yes |
101
+ | tell_me_how discovery | Yes |
102
+ | SSR/Dynamic content | Yes |
103
+
104
+ ## Key Differences from Static + Microservice
105
+
106
+ 1. **No separate site deployment** - The microservice serves the site
107
+ 2. **SSR routes** - HTML generated on the server per request
108
+ 3. **Single deployment** - Everything deploys together to Cloud Run
109
+ 4. **Real-time capabilities** - WebSockets, streaming, etc.
110
+
111
+ ## Example Use Cases
112
+
113
+ 1. **Dashboard App** - Admin panel with real-time data
114
+ 2. **Multi-tenant Platform** - Each user sees personalized content
115
+ 3. **Streaming App** - Real-time data visualization
116
+ 4. **Complex Web App** - E-commerce, social platforms
117
+
118
+ ## Deployment
119
+
120
+ Dynamic sites deploy to Google Cloud Run as a single container. The service handles both API requests and page rendering.
121
+
122
+ ```bash
123
+ # Deploy the microservice (includes site)
124
+ descix deploy service
125
+ ```