@descix/cli 1.0.1 → 1.0.3

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 (100) hide show
  1. package/LICENSE.md +671 -0
  2. package/README.md +43 -4
  3. package/agent-assets/guides/README.md +2 -2
  4. package/agent-assets/guides/dynamic-site-pattern.md +29 -14
  5. package/agent-assets/guides/knowledge-only-pattern.md +5 -5
  6. package/agent-assets/guides/microservice-pattern.md +48 -4
  7. package/agent-assets/guides/static-site-pattern.md +8 -0
  8. package/agent-assets/instructions/app-asset-validation.md +5 -5
  9. package/agent-assets/instructions/onboarding-flow.md +4 -4
  10. package/agent-assets/instructions/standard-folder-structure.md +20 -11
  11. package/agent-assets/reference/app-creation.md +42 -20
  12. package/agent-assets/reference/architecture.md +24 -22
  13. package/agent-assets/reference/local-dev.md +230 -67
  14. package/agent-assets/reference/mcp-integration.md +9 -9
  15. package/agent-assets/reference/platform-api-consumer.md +244 -0
  16. package/agent-assets/reference/workspace-config.md +7 -7
  17. package/agent-assets/rules/descix_mcp.template.mdc +8 -8
  18. package/bin/descix.js +2559 -1435
  19. package/bin/kb-deny-lint.mjs +91 -0
  20. package/bin/mcp-server.js +175 -91
  21. package/lib/agent-files.js +37 -25
  22. package/lib/api-client.js +223 -56
  23. package/lib/auth-guard.js +13 -3
  24. package/lib/chat-session.js +187 -0
  25. package/lib/cli-version.js +59 -0
  26. package/lib/commands/airdrop.js +251 -0
  27. package/lib/commands/auth.js +254 -72
  28. package/lib/commands/briefer/errors.js +88 -0
  29. package/lib/commands/briefer/index.js +319 -0
  30. package/lib/commands/briefer/sources/canonical-sources.js +129 -0
  31. package/lib/commands/briefer/sources/entitlements.js +209 -0
  32. package/lib/commands/briefer/sources/environments.js +205 -0
  33. package/lib/commands/briefer/sources/identifiers.js +214 -0
  34. package/lib/commands/briefer/sources/microservice-deploy.js +267 -0
  35. package/lib/commands/briefer/sources/routing.js +275 -0
  36. package/lib/commands/briefer/sources/what-is-not.js +223 -0
  37. package/lib/commands/briefer/stitcher.js +134 -0
  38. package/lib/commands/briefer/util/source-reader.js +502 -0
  39. package/lib/commands/config.js +210 -90
  40. package/lib/commands/corpus.js +978 -0
  41. package/lib/commands/credits.js +122 -0
  42. package/lib/commands/health.js +627 -0
  43. package/lib/commands/kb-list-render.js +32 -0
  44. package/lib/commands/kb.js +190 -413
  45. package/lib/commands/mcp.js +5 -5
  46. package/lib/commands/microservice-restart.js +359 -0
  47. package/lib/commands/model-config.js +313 -0
  48. package/lib/commands/retired-kb-sync.js +134 -0
  49. package/lib/commands/serve.js +26 -1
  50. package/lib/commands/status.js +23 -51
  51. package/lib/commands/update.js +36 -107
  52. package/lib/core/Chunker.js +491 -17
  53. package/lib/core/CorpusDenyLint.js +326 -0
  54. package/lib/core/CorpusWalker.js +357 -0
  55. package/lib/core/Hydrator.js +75 -29
  56. package/lib/core/ManifestLoader.js +533 -0
  57. package/lib/core/SiteWalker.js +218 -0
  58. package/lib/core/Syncer.js +163 -11
  59. package/lib/diagnostic-log.js +41 -0
  60. package/lib/environment-report.js +100 -0
  61. package/lib/global-config.js +4 -1
  62. package/lib/oauth-client.js +164 -0
  63. package/lib/origin.js +143 -0
  64. package/lib/service-api-client.js +95 -0
  65. package/lib/wallet-environment.js +49 -0
  66. package/lib/wallet-file.js +16 -2
  67. package/lib/wizard/setup.js +10 -9
  68. package/lib/workspace-config.js +380 -235
  69. package/lib/workspace-identity.js +92 -0
  70. package/lib/workspace-utils.js +41 -61
  71. package/package.json +19 -6
  72. package/templates/agent-claude.md +157 -9
  73. package/templates/agent-cline.md +68 -8
  74. package/templates/agent-copilot.md +68 -8
  75. package/templates/agent-cursor.md +68 -8
  76. package/templates/alignment-schema.json +20 -0
  77. package/templates/cloud-brain-hook.sh +20 -0
  78. package/templates/drive/README.md +1 -1
  79. package/templates/drive_templates/README.md +2 -2
  80. package/templates/scaffolds/README.md +6 -10
  81. package/templates/scaffolds/microservice/SERVICE_README_sdk.md +30 -0
  82. package/templates/scaffolds/microservice/app.js +51 -10
  83. package/templates/scaffolds/microservice/app.yaml +2 -2
  84. package/templates/scaffolds/microservice/defaults-config-dev.json +4 -0
  85. package/templates/scaffolds/microservice/dev-overrides.example.json +5 -0
  86. package/templates/scaffolds/microservice/manifest.json +0 -1
  87. package/templates/scaffolds/microservice/package.json +3 -3
  88. package/templates/scaffolds/microservice/scripts/register.js +56 -41
  89. package/templates/scaffolds/microservice/services/mcpClient.js +55 -65
  90. package/templates/scaffolds/microservice/services/utils.js +20 -238
  91. package/templates/scaffolds/microservice/templates/SERVICE_README_TEMPLATE.md +24 -0
  92. package/lib/commands/app-wizard.js +0 -627
  93. package/lib/commands/folder.js +0 -291
  94. package/lib/core/PathContext.js +0 -335
  95. package/templates/scaffolds/microservice/dev-overrides.json.example +0 -5
  96. package/templates/scaffolds/site/DeSciXAppSDK.js +0 -62
  97. package/templates/scaffolds/site/README.md +0 -51
  98. package/templates/scaffolds/site/app.js +0 -22
  99. package/templates/scaffolds/site/index.html +0 -42
  100. package/templates/scaffolds/site/styles.css +0 -123
package/README.md CHANGED
@@ -21,12 +21,15 @@ npm install -g @descix/cli
21
21
  ```
22
22
  This will guide you through connecting your Google Drive and setting up your local environment.
23
23
 
24
- **Development Mode**:
25
- If you are developing locally or against a test environment, you can use the `--dev` flag:
24
+ **Choosing an environment**:
25
+ The `--dev` flag has been REMOVED. Its absence silently meant production, so the most common
26
+ invocation targeted PROD without saying so. Name the environment instead:
26
27
  ```bash
27
- npx descix setup --dev
28
+ descix config init --env dev # or demo, or prod
28
29
  ```
29
- This defaults to `https://localhost:4000` unless configured otherwise.
30
+ An unconfigured workspace resolves to the declared default, PROD, and every network-bound
31
+ command prints the environment, origin and source it resolved on stderr. For a local backend,
32
+ name the URL: `descix config set-env dev --url https://localhost:4000`.
30
33
 
31
34
  3. **Check your status**:
32
35
  ```bash
@@ -90,6 +93,42 @@ For apps managed via CLI (Git Mode), use the following commands to process your
90
93
  1. Create your App in the PWA (Workspace Builder).
91
94
  2. Run `descix setup` to hydrate your local folder structure.
92
95
 
96
+ ## Airdrop Admin Operations (WS-ADMIN-B1)
97
+
98
+ Admin-only commands for triggering airdrop migration batch runs. Per CEO-D-MANUAL-TRIGGER-NO-CRON (2026-04-20), Cloud Scheduler cron was dropped from Round B in favor of operator-invoked manual triggers via this CLI.
99
+
100
+ **Access:** requires platform-admin membership (enforced server-side via `isPlatformAdmin(user)`).
101
+
102
+ ### `descix airdrop execute-queue`
103
+
104
+ Manually trigger the server-side `airdrop_execute_queue` command on the target environment. Assembles `pending_migrations` rows into per-community batches and (when `BATCH_UPDATE_BALANCES_BROADCAST_ENABLED=true`) broadcasts to the Powch HD wallet. When the broadcast flag is off (default for DEV), batches are assembled but the downstream Powch handler returns `stopped_at_broadcast_boundary` — useful for verifying queue shape without spending MATIC.
105
+
106
+ **Options:**
107
+
108
+ - `--batch-size <n>`: Cap on users processed this run (server caps at `AIRDROP_MAX_RUN_USERS`; a larger `--batch-size` is clamped).
109
+ - `--dry-run`: Assemble batches but skip the broadcast call entirely. Emits an `on_chain_log` row with `status: dry_run` for audit.
110
+
111
+ **Examples:**
112
+
113
+ ```bash
114
+ # Dry run against DEV — safe to run repeatedly; no broadcast, no MATIC
115
+ descix airdrop execute-queue --env dev --dry-run
116
+
117
+ # Execute a capped real run (10 users max this invocation)
118
+ descix airdrop execute-queue --env dev --batch-size 10
119
+
120
+ # Execute a full queue run (still gated by BATCH_UPDATE_BALANCES_BROADCAST_ENABLED)
121
+ descix airdrop execute-queue --env dev
122
+ ```
123
+
124
+ **Audit trail:** every invocation (dry-run or real) writes one `on_chain_log` row with `op.kind = "airdrop_execute_queue_trigger"` and `caller.operator_email = <invoking admin email>`.
125
+
126
+ **Testing:**
127
+
128
+ ```bash
129
+ cd DeSciX_Core/descix-cli && npm test
130
+ ```
131
+
93
132
  ## Documentation
94
133
 
95
134
  For full documentation, please refer to the [DeSciX SDK Documentation](../../SERVICE_README_sdk.md).
@@ -34,7 +34,7 @@ Does the user need a public website?
34
34
  ### Knowledge-Only
35
35
  - Just docs/content for RAG search
36
36
  - No `site/` or `microservice/` folders needed
37
- - Commands: `descix kb pull/push/chunk/sync`
37
+ - Commands: `descix drive pull` / `descix drive push` / `descix kb corpus sync`
38
38
 
39
39
  ### Static Site
40
40
  - Built HTML/CSS/JS deployed to CDN
@@ -49,7 +49,7 @@ Does the user need a public website?
49
49
  ### Dynamic Site
50
50
  - SSR app where microservice serves the site
51
51
  - Everything in `microservice/` (no separate `site/`)
52
- - Commands: `descix deploy service`
52
+ - Commands: `descix microservice deploy` (ADMIN/LOCAL only — public deploy is not open yet)
53
53
 
54
54
  ## Two-Tier Template System
55
55
 
@@ -33,23 +33,32 @@ my-dynamic-app/
33
33
  ├── site/
34
34
  │ └── README.md # "Site served by microservice"
35
35
  ├── microservice/
36
+ │ ├── app.js # Entry point (from the scaffold)
36
37
  │ ├── manifest.json
37
38
  │ ├── SERVICE_README_myapp.md
38
39
  │ ├── package.json
39
40
  │ ├── Dockerfile
40
41
  │ ├── 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
- │ └── ...
42
+ │ ├── services/ # From the scaffold — NOT src/
43
+ │ │ ├── utils.js # Config bootstrap over @descix/cloud-core
44
+ │ │ ├── apiFront.js
45
+ │ │ └── commandHandlers/
46
+ │ ├── pages/ # YOU add these: SSR routes
47
+ │ │ ├── index.js
48
+ │ │ └── dashboard.js
49
+ │ ├── api/ # YOU add these: API routes
50
+ │ │ └── ...
51
+ │ └── views/ # YOU add these: templates
52
+ │ └── ...
50
53
  └── package.json
51
54
  ```
52
55
 
56
+ The first group comes from the scaffold and should not be reshaped: `app.js` is the entry
57
+ point and service code lives under `services/` — **there is no `src/` directory**. The
58
+ `pages/`, `api/` and `views/` directories are yours; the layout inside them is your call.
59
+ Keeping the scaffold's shape is what lets the service keep inheriting platform behaviour
60
+ (see `guides/microservice-pattern.md`).
61
+
53
62
  ## Configuration (`workspace.json`)
54
63
 
55
64
  ```json
@@ -79,15 +88,15 @@ descix microservice init
79
88
 
80
89
  # 2. Add SSR routes to your service
81
90
 
82
- # 3. Deploy to Cloud Run
83
- descix deploy service
91
+ # 3. Deploy to Cloud Run (ADMIN/LOCAL ONLY — see note below)
92
+ descix microservice deploy
84
93
 
85
94
  # 4. Register and vectorize
86
95
  descix microservice register
87
96
  descix microservice vectorize
88
97
 
89
98
  # 5. Sync KB
90
- descix kb sync -c <community> -a <app>
99
+ descix kb corpus sync -c <community> -a <app>
91
100
  ```
92
101
 
93
102
  ## Capabilities
@@ -120,6 +129,12 @@ descix kb sync -c <community> -a <app>
120
129
  Dynamic sites deploy to Google Cloud Run as a single container. The service handles both API requests and page rendering.
121
130
 
122
131
  ```bash
123
- # Deploy the microservice (includes site)
124
- descix deploy service
132
+ # Deploy the microservice (includes site) — ADMIN/LOCAL ONLY
133
+ descix microservice deploy
125
134
  ```
135
+
136
+ > **`descix microservice deploy` is not open to every developer yet.** Its own help
137
+ > marks it `[ADMIN/LOCAL]` — it shells out to the platform deploy script — and the
138
+ > CLI states that public MCP deploy is "coming soon". If you are not a platform
139
+ > admin, expect this step to fail on permissions rather than on your code. Build and
140
+ > run locally with `descix serve` until the public path lands.
@@ -57,22 +57,22 @@ my-docs/
57
57
 
58
58
  ```bash
59
59
  # 1. Pull content from Drive (if any)
60
- descix kb pull -c <community> -a <app>
60
+ descix drive pull -c <community> -a <app>
61
61
 
62
62
  # 2. Add local files to staging
63
63
  cp my-new-doc.pdf kb/staging/
64
64
 
65
65
  # 3. Push to Drive (converts to text)
66
- descix kb push -c <community> -a <app>
66
+ descix drive push -c <community> -a <app>
67
67
 
68
68
  # 4. Pull converted text back
69
- descix kb pull -c <community> -a <app>
69
+ descix drive pull -c <community> -a <app>
70
70
 
71
71
  # 5. Chunk for RAG
72
- descix kb chunk -c <community> -a <app>
72
+ descix kb corpus sync -c <community> -a <app>
73
73
 
74
74
  # 6. Sync to Pinecone
75
- descix kb sync -c <community> -a <app>
75
+ descix kb corpus sync -c <community> -a <app>
76
76
  ```
77
77
 
78
78
  ## Capabilities
@@ -33,19 +33,56 @@ my-service/
33
33
  ├── site/ # Optional frontend
34
34
  │ └── ...
35
35
  ├── microservice/
36
+ │ ├── app.js # Entry point — binds the server, mounts the router
36
37
  │ ├── manifest.json # Command registration
37
38
  │ ├── SERVICE_README_myapp.md # Tool discovery docs
38
39
  │ ├── package.json
39
40
  │ ├── Dockerfile
40
41
  │ ├── app.yaml
41
- │ └── src/
42
- │ ├── index.js
42
+ │ ├── defaults-config.json # Layered config: committed defaults
43
+ │ ├── defaults-config-dev.json
44
+ │ ├── scripts/
45
+ │ │ └── register.js # Registers the service MANIFEST (commands) for discovery
46
+ │ └── services/
47
+ │ ├── utils.js # Config bootstrap — see below, read this first
43
48
  │ ├── apiFront.js
49
+ │ ├── mcpClient.js
44
50
  │ └── commandHandlers/
45
51
  │ └── myCommands.js
46
52
  └── package.json
47
53
  ```
48
54
 
55
+ ## The bootstrap — why a service inherits instead of implements
56
+
57
+ **Read `services/utils.js` before you write a line of your own.** It is a thin wrapper
58
+ over `@descix/cloud-core` (`createCloudConfig`, `getCloudConfig`, `initializeCloudConfig`)
59
+ and it carries the layered config chain — environment, then `.env`, then
60
+ `workspace.json` — along with Secret Manager resolution and dev port detection. `app.js`
61
+ reaches it through `initializeServiceConfig`.
62
+
63
+ Its own header states the rule, and the rule is the point:
64
+
65
+ > This is the ONLY path to config values. Never use process.env directly.
66
+ > Never add fallback values to utils.CONFIG_VALUE — nulls surface misconfigurations.
67
+
68
+ That is not house style. It is what makes a service **inherit** its platform behaviour
69
+ rather than reimplement it: a service that bootstraps correctly gets the shared
70
+ infrastructure for free, and a service that hand-rolls its own config or reads
71
+ `process.env` opts itself out of it silently — nothing fails at startup, and the gap
72
+ only shows up later, in the environment where it matters.
73
+
74
+ **This is also why your service is called at its own Cloud Run instance rather than
75
+ through an extra hop at the DeSciX router** (CEO-D-2026-08-21-DIRECT-MICROSERVICE-ROUTING-IS-DESIGN).
76
+ Direct routing is the intended path *because* a service built on the SDK already carries
77
+ the infrastructure the extra hop would otherwise have to add. Read a direct call as the
78
+ architecture working, not as a bypass — the correctness precondition is that the service
79
+ was built this way.
80
+
81
+ The corollary is worth stating plainly: **correct bootstrap usage is self-enforcing and
82
+ self-extending.** Services that inherit gain new platform behaviour as the SDK gains it.
83
+ A service that forked the mechanism keeps whatever it forked, forever, and no one finds
84
+ out until something depends on the difference.
85
+
49
86
  ## Configuration (`workspace.json`)
50
87
 
51
88
  ```json
@@ -75,16 +112,23 @@ descix microservice init
75
112
 
76
113
  # 2. Implement your commands in commandHandlers/
77
114
 
78
- # 3. Register service with gateway
115
+ # 3. Publish the service MANIFEST so its commands are discoverable
79
116
  descix microservice register
80
117
 
81
118
  # 4. Vectorize SERVICE_README for discovery
82
119
  descix microservice vectorize
83
120
 
84
121
  # 5. Sync KB
85
- descix kb sync -c <community> -a <app>
122
+ descix kb corpus sync -c <community> -a <app>
86
123
  ```
87
124
 
125
+ **What registration is, and is not.** It publishes your `manifest.json` — the command list —
126
+ so `tell_me_how` can discover your tools. `scripts/register.js` writes that manifest and logs
127
+ the commands it published. It is a DISCOVERY step.
128
+
129
+ It is not how your service becomes reachable, and nothing here asks you to declare a route or
130
+ a URL. Do not read this step as wiring up addressing.
131
+
88
132
  ## Capabilities
89
133
 
90
134
  | Capability | Enabled |
@@ -34,6 +34,8 @@ my-site/
34
34
  │ ├── index.html
35
35
  │ ├── styles.css
36
36
  │ ├── app.js
37
+ │ ├── DeSciXAppSDK.js # The DeSciX bridge — GENERATED, see below
38
+ │ ├── README.md
37
39
  │ └── dist/ # Build output (if using bundler)
38
40
  ├── src/ # Source files (not deployed)
39
41
  │ └── ...
@@ -104,6 +106,12 @@ This copies the site template with:
104
106
  - `index.html` - Main entry point
105
107
  - `styles.css` - Basic styling
106
108
  - `app.js` - Client-side JavaScript
109
+ - `DeSciXAppSDK.js` - The DeSciX bridge: reaches `DeSciX.view`, `DeSciX.chat` and the rest
110
+ of the shell's bus, resolving the frame level for you. **Do not hand-edit it.** It is
111
+ GENERATED from `descix-app-sdk/templates/DeSciXAppSDK.template.js`, which inlines the one
112
+ owner of level detection (`descix-app-sdk/src/util/bridgeResolver.js`); a `--check` drift
113
+ gate keeps the copies identical. Edit the template, regenerate — a local patch forks the
114
+ bridge and silently stops inheriting its fixes.
107
115
  - `README.md` - Usage instructions
108
116
 
109
117
  ## Deployment
@@ -124,7 +124,7 @@ This app does not yet have a web UI.
124
124
  ## To Add a Site
125
125
  1. Add HTML/CSS/JS files directly here, OR
126
126
  2. Configure your build tool to output to `site/dist/`
127
- 3. Run `descix update site` to deploy
127
+ 3. Run `descix site upload` to deploy
128
128
 
129
129
  ## Supported Content
130
130
  - Static HTML files
@@ -334,7 +334,7 @@ This folder doesn't appear to be configured as a DeSciX app.
334
334
 
335
335
  Options:
336
336
  1. Run `descix init` to configure this folder as a new app
337
- 2. Run `descix setup` to configure the entire workspace
337
+ 2. Run `descix mcp quickstart` to configure the entire workspace
338
338
  3. Check if this is the correct folder
339
339
 
340
340
  Which would you like to do?
@@ -366,7 +366,7 @@ Please check:
366
366
 
367
367
  ## Integration with Workflows
368
368
 
369
- ### Before `descix update app`
369
+ ### Before `descix app sync-assets`
370
370
 
371
371
  Always run validation:
372
372
  1. Check `assets/` folder structure
@@ -374,14 +374,14 @@ Always run validation:
374
374
  3. Warn about missing icon
375
375
  4. Confirm app_description has meaningful content
376
376
 
377
- ### Before `descix update kb`
377
+ ### Before `descix kb corpus sync`
378
378
 
379
379
  1. Check `kb/General/` exists
380
380
  2. Verify at least one document exists
381
381
  3. Warn if no README.md
382
382
  4. Report total document count and size
383
383
 
384
- ### Before `descix update site`
384
+ ### Before `descix site upload`
385
385
 
386
386
  1. Check `site/` exists
387
387
  2. Verify either index.html or dist/index.html exists
@@ -264,7 +264,7 @@ Created:
264
264
  ✓ site/README.md (placeholder)
265
265
  ✓ microservice/README.md (placeholder)
266
266
 
267
- Your app structure is now ready. Run `descix update app` to sync.
267
+ Your app structure is now ready. Run `descix app sync-assets` to sync.
268
268
  ```
269
269
 
270
270
  ## Key Principles
@@ -300,10 +300,10 @@ Once configured, guide user to:
300
300
 
301
301
  ### Sync Commands (in order)
302
302
 
303
- 1. **Sync app assets**: `descix update app`
303
+ 1. **Sync app assets**: `descix app sync-assets`
304
304
  - Uploads app_description.md, icon.png, system_instructions.md to Drive
305
305
 
306
- 2. **Sync knowledge base**: `descix update kb`
306
+ 2. **Sync knowledge base**: `descix kb corpus sync`
307
307
  - Indexes documents to Pinecone for RAG
308
308
 
309
309
  3. **Deploy static site** (if applicable): `descix site upload`
@@ -374,7 +374,7 @@ All done! Your app is configured.
374
374
  **What you can do now:**
375
375
  - Use `tell_me_how` to discover tools
376
376
  - Ask me to sync content when you make changes
377
- - Run `descix kb sync` to update RAG index
377
+ - Run `descix kb corpus sync` to update RAG index
378
378
 
379
379
  Anything else I can help with?
380
380
  ```
@@ -33,12 +33,19 @@ DeSciX uses a "Mono-Repo" style structure where multiple communities and apps ca
33
33
  │ │
34
34
  │ ├── site/ # Frontend UI (Optional)
35
35
  │ │ ├── index.html
36
- │ │ └── src/
36
+ │ │ ├── styles.css
37
+ │ │ ├── app.js
38
+ │ │ └── DeSciXAppSDK.js # The DeSciX bridge — GENERATED, do not hand-edit
37
39
  │ │
38
40
  │ └── microservice/ # Backend Logic (Optional)
41
+ │ ├── app.js # Entry point
39
42
  │ ├── Dockerfile
40
43
  │ ├── package.json
41
- │ └── src/
44
+ │ ├── scripts/
45
+ │ └── services/ # NOT src/ — see below
46
+ │ ├── utils.js # Config bootstrap — read this first
47
+ │ ├── apiFront.js
48
+ │ └── commandHandlers/
42
49
  ```
43
50
 
44
51
  ## Folder Purposes
@@ -61,17 +68,17 @@ Self-contained folder for a single application.
61
68
 
62
69
  #### `kb/` - Knowledge Base
63
70
  The KB folder supports both local-first (Git mode) and Drive-based workflows:
64
- - **`staging/`**: Place raw files here (PDFs, images) to push them to Drive via `descix kb push`.
65
- - **`General/`**: The canonical source of text content. Files here are pulled from Drive and converted to Markdown via `descix kb pull`.
66
- - **`chunks/`**: Processed JSON chunk files ready for vectorization via `descix kb sync`.
71
+ - **`staging/`**: Place raw files here (PDFs, images) to push them to Drive via `descix drive push`.
72
+ - **`General/`**: The canonical source of text content. Files here are pulled from Drive and converted to Markdown via `descix drive pull`.
73
+ - **`chunks/`**: Processed JSON chunk files ready for vectorization via `descix kb corpus sync`.
67
74
 
68
75
  **CLI-Centric Processing (Git Mode):**
69
76
  ```bash
70
- descix kb push # Push staging/ -> Drive
71
- descix kb pull # Pull Drive -> General/ (converted to markdown)
72
- descix kb chunk # Generate chunks from General/ -> chunks/
73
- descix kb sync # Push chunks to Pinecone via service layer
74
- descix kb build # Convenience: pull → chunk → sync
77
+ descix drive push # Push staging/ -> Drive
78
+ descix drive pull # Pull Drive -> General/ (converted to markdown)
79
+ descix kb corpus sync # Generate chunks from General/ -> chunks/
80
+ descix kb corpus sync # Push chunks to Pinecone via service layer
81
+ descix kb corpus sync # Convenience: pull → chunk → sync
75
82
  ```
76
83
 
77
84
  #### `site/` - Frontend
@@ -81,7 +88,9 @@ descix kb build # Convenience: pull → chunk → sync
81
88
  #### `microservice/` - Backend
82
89
  - Contains the server-side logic.
83
90
  - **`Dockerfile`**: Defines the runtime environment.
84
- - **`src/`**: Source code.
91
+ - **`services/`**: Service code. **There is no `src/` directory** in a scaffolded
92
+ microservice — the entry point is `app.js` at the root and the code lives under
93
+ `services/`, with `services/utils.js` as the config bootstrap over `@descix/cloud-core`.
85
94
 
86
95
  ## Configuration Files
87
96
 
@@ -45,7 +45,7 @@ This separation ensures:
45
45
 
46
46
  **Location:** Google Drive, owned by `dip@descix.net`
47
47
  **SDK Reference:** `DeSciX_Core/descix-cli/templates/drive/`
48
- **Template IDs:** Configured in `DeSciX_Cloud/defaults-config.json`
48
+ **Template IDs:** Configured in `DeSciX_Cloud/microservice/defaults-config.json`
49
49
 
50
50
  ```json
51
51
  {
@@ -79,31 +79,53 @@ templates/drive/app/
79
79
 
80
80
  ### Git Scaffolds
81
81
 
82
- **Location:** `DeSciX_Core/descix-cli/templates/scaffolds/`
82
+ **Location:** microservice — `DeSciX_Core/descix-cli/templates/scaffolds/`;
83
+ site — `DeSciX_Core/descix-app-sdk/scaffold/` (owned there, and exported as `SITE_SCAFFOLD_DIR`
84
+ from `@descix/app-sdk/scaffold`, so no caller re-derives the path).
83
85
 
84
86
  **Site Scaffold:**
85
87
  ```
86
- templates/scaffolds/site/
88
+ descix-app-sdk/scaffold/site/
87
89
  ├── index.html # Entry point
88
90
  ├── styles.css # Basic styling
89
91
  ├── app.js # Client-side JavaScript
92
+ ├── DeSciXAppSDK.js # The DeSciX bridge — GENERATED, do not hand-edit
90
93
  └── README.md # Usage instructions
91
94
  ```
92
95
 
96
+ `DeSciXAppSDK.js` ships IN the scaffold; it is not something you add afterwards. It is
97
+ generated from `descix-app-sdk/templates/DeSciXAppSDK.template.js` (which inlines
98
+ `descix-app-sdk/src/util/bridgeResolver.js`, the one owner of frame-level detection) and a
99
+ `--check` drift gate keeps the copies identical. Patch the template and regenerate — never
100
+ the copy.
101
+
93
102
  **Microservice Scaffold:**
94
103
  ```
95
104
  templates/scaffolds/microservice/
105
+ ├── app.js # Entry point — binds the server, mounts the router
96
106
  ├── package.json
97
107
  ├── Dockerfile
98
108
  ├── app.yaml
99
109
  ├── manifest.json
100
- ├── SERVICE_README_TEMPLATE.md
101
- └── src/
102
- ├── index.js
103
- ├── apiFront.js
104
- └── utils.js
110
+ ├── defaults-config.json # Layered config: committed defaults
111
+ ├── defaults-config-dev.json
112
+ ├── setup-schema.json
113
+ ├── SERVICE_README_sdk.md
114
+ ├── scripts/
115
+ │ └── register.js # Registers the service MANIFEST (commands) for discovery
116
+ ├── services/
117
+ │ ├── utils.js # Config bootstrap over @descix/cloud-core — read first
118
+ │ ├── apiFront.js
119
+ │ ├── mcpClient.js
120
+ │ └── commandHandlers/
121
+ └── templates/
122
+ └── SERVICE_README_TEMPLATE.md
105
123
  ```
106
124
 
125
+ There is no `src/` directory. The entry point is `app.js` at the root and the service code
126
+ lives under `services/`. See `guides/microservice-pattern.md` for why `services/utils.js` is
127
+ the file to open first.
128
+
107
129
  ### Adding Scaffolds to Apps
108
130
 
109
131
  After an app is created via PWA, add code scaffolds via CLI:
@@ -232,7 +254,7 @@ The PWA Workspace Builder allows users to configure which apps to sync to their
232
254
  ### Setup Command
233
255
 
234
256
  ```bash
235
- descix setup [--dev]
257
+ descix mcp quickstart
236
258
  ```
237
259
 
238
260
  **Flow:**
@@ -272,10 +294,10 @@ After initial setup, users can hydrate specific apps:
272
294
 
273
295
  ```bash
274
296
  # Pull entire app from Drive
275
- descix kb pull -c community -a app
297
+ descix drive pull -c community -a app
276
298
 
277
299
  # Or use the build command for full pipeline
278
- descix kb build
300
+ descix kb corpus sync
279
301
  ```
280
302
 
281
303
  ---
@@ -352,15 +374,15 @@ The CLI does not create apps directly. Users should:
352
374
 
353
375
  1. Go to PWA dashboard
354
376
  2. Create app/community
355
- 3. Run `descix setup` or `descix login --setup` to hydrate
377
+ 3. Run `descix mcp quickstart` or `descix login --setup` to hydrate
356
378
 
357
379
  ### Post-Creation Commands
358
380
 
359
381
  ```bash
360
382
  # 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
383
+ descix mcp quickstart # Hydrate workspace (first time)
384
+ descix kb corpus sync # Pull, chunk, sync KB
385
+ descix site upload -a app # Deploy static site
364
386
  ```
365
387
 
366
388
  ---
@@ -369,13 +391,13 @@ descix sync site # Deploy static site
369
391
 
370
392
  | Component | Path | Description |
371
393
  |-----------|------|-------------|
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 |
394
+ | Community Management | `DeSciX_Cloud/microservice/services/communityManagement.js` | Community/App creation |
395
+ | App Commands | `DeSciX_Cloud/microservice/services/commandHandlers/appCommands.js` | Server-side app ops |
396
+ | Google Storage Service | `DeSciX_Cloud/microservice/services/googleStorageService.js` | Drive/GCS operations |
397
+ | Template Config | `DeSciX_Cloud/microservice/defaults-config.json` | Template folder IDs |
376
398
  | Drive Templates | `DeSciX_Core/descix-cli/templates/drive/` | Content templates |
377
399
  | Git Scaffolds | `DeSciX_Core/descix-cli/templates/scaffolds/` | Code scaffolds |
378
400
  | Hydrator | `DeSciX_Core/descix-cli/lib/core/Hydrator.js` | Workspace hydration |
379
401
  | WorkspaceConfig | `DeSciX_Core/descix-cli/lib/workspace-config.js` | CLI configuration |
380
- | Setup Command | `DeSciX_Core/descix-cli/lib/commands/setup.js` | Initial setup |
402
+ | Setup Command | `DeSciX_Core/descix-cli/lib/wizard/setup.js` | Initial setup |
381
403
  | Scaffold Command | `DeSciX_Core/descix-cli/bin/descix.js` | CLI scaffolds |
@@ -122,9 +122,11 @@ All core SDK logic resides in `DeSciX_Core/descix-cli/lib/core/`.
122
122
  │ ├── research.chunks.json
123
123
  │ └── notes.chunks.json
124
124
  ├── site/ # Static site files (push-only)
125
- │ └── index.html
125
+ │ ├── index.html
126
+ │ └── DeSciXAppSDK.js # The DeSciX bridge (generated)
126
127
  └── microservice/ # Service code (push-only)
127
- └── src/index.js
128
+ ├── app.js # Entry point
129
+ └── services/ # Service code — there is no src/
128
130
  ```
129
131
 
130
132
  ### Folder Purposes
@@ -186,10 +188,10 @@ These commands auto-detect app context from `workspace.json` based on the curren
186
188
  | Command | Description |
187
189
  |---------|-------------|
188
190
  | `descix update` | Auto-detect what to update based on current folder |
189
- | `descix update app` | Sync app assets (icon, description, instructions) to Drive |
190
- | `descix update kb` | Full three-stage sync (Local → Drive → GCS → Pinecone) |
191
- | `descix update site` | Deploy CodeSite to GCS |
192
- | `descix update all` | Update all resources (App, KB, Site) in sequence |
191
+ | `descix app sync-assets` | Sync app assets (icon, description, instructions) to Drive |
192
+ | `descix kb corpus sync` | Full three-stage sync (Local → Drive → GCS → Pinecone) |
193
+ | `descix site upload` | Deploy CodeSite to GCS |
194
+ | ~~`descix update all`~~ | **Deleted.** There is no single all-resources verb. Run the three canonical commands: `descix app sync-assets`, `descix kb corpus sync`, `descix site upload`. |
193
195
 
194
196
  ### 4.2 KB Processing Commands (`descix kb`)
195
197
 
@@ -197,12 +199,12 @@ These commands provide granular control over the V2 local-first pipeline.
197
199
 
198
200
  | Command | Description |
199
201
  |---------|-------------|
200
- | `descix kb pull` | Download from Drive, convert to text in `kb/General/` |
201
- | `descix kb push` | Upload files from `kb/staging/` to Drive |
202
- | `descix kb chunk` | Generate JSON chunks from `kb/General/` to `kb/chunks/` |
203
- | `descix kb sync` | Push chunks to Pinecone via backend API |
204
- | `descix kb build` | Convenience: pull → chunk → sync |
205
- | `descix kb status` | Show sync status (local vs Pinecone) |
202
+ | `descix drive pull` | Download from Drive, convert to text in `kb/General/` |
203
+ | `descix drive push` | Upload files from `kb/staging/` to Drive |
204
+ | `descix kb corpus sync` | Generate JSON chunks from `kb/General/` to `kb/chunks/` |
205
+ | `descix kb corpus sync` | Push chunks to Pinecone via backend API |
206
+ | `descix kb corpus sync` | Convenience: pull → chunk → sync |
207
+ | `descix kb corpus status` | Show sync status (local vs Pinecone) |
206
208
 
207
209
  ### Scaffold Commands
208
210
 
@@ -229,7 +231,7 @@ These commands provide granular control over the V2 local-first pipeline.
229
231
  ### Setup Command
230
232
 
231
233
  ```bash
232
- descix setup [--dev]
234
+ descix mcp quickstart
233
235
  ```
234
236
 
235
237
  Flow:
@@ -318,15 +320,15 @@ flowchart LR
318
320
  ### Detailed Flow
319
321
 
320
322
  1. **Stage:** User adds `paper.pdf` to `kb/staging/`
321
- 2. **Push:** `descix kb push` uploads to Drive `kb/General/`
322
- 3. **Pull:** `descix kb pull` downloads and converts:
323
+ 2. **Push:** `descix drive push` uploads to Drive `kb/General/`
324
+ 3. **Pull:** `descix drive pull` downloads and converts:
323
325
  - Sees `paper.pdf` in Drive
324
326
  - Copies with `convert=true` → temp Google Doc
325
327
  - Exports as Markdown → `kb/General/paper.md`
326
328
  - Deletes temp doc
327
- 4. **Chunk:** `descix kb chunk` processes `paper.md`:
329
+ 4. **Chunk:** `descix kb corpus sync` processes `paper.md`:
328
330
  - Generates `kb/chunks/paper.chunks.json`
329
- 5. **Sync:** `descix kb sync` pushes to backend:
331
+ 5. **Sync:** `descix kb corpus sync` pushes to backend:
330
332
  - Backend validates metadata
331
333
  - Forwards to Pinecone
332
334
  - Pinecone embeds and stores
@@ -345,7 +347,7 @@ gcloud auth application-default login \
345
347
  ```
346
348
 
347
349
  **Verification:**
348
- - `descix setup` checks ADC before proceeding
350
+ - `descix mcp quickstart` checks ADC before proceeding
349
351
  - `Hydrator` calls `verifyDriveAuth()` before operations
350
352
 
351
353
  ### Backend Authentication
@@ -399,8 +401,8 @@ Both modes start with content on Google Drive (users create documents there). Th
399
401
  | Chunker | `DeSciX_Core/descix-cli/lib/core/Chunker.js` | KB chunking |
400
402
  | Syncer | `DeSciX_Core/descix-cli/lib/core/Syncer.js` | Pinecone sync |
401
403
  | KB Commands | `DeSciX_Core/descix-cli/lib/commands/kb.js` | Git-mode KB processing |
402
- | Setup Command | `DeSciX_Core/descix-cli/lib/commands/setup.js` | Initial workspace setup |
404
+ | Setup Command | `DeSciX_Core/descix-cli/lib/wizard/setup.js` | Initial workspace setup |
403
405
  | Drive ADC | `DeSciX_Core/descix-cli/lib/google-storage-adc.js` | Google Drive API wrapper |
404
- | Backend KB API | `DeSciX_Cloud/services/commandHandlers/appCommands.js` | Server-side processing |
405
- | Pinecone Service | `DeSciX_Cloud/services/pineconeService.js` | Vector database |
406
- | Server Chunking | `DeSciX_Cloud/services/chunkingUtils.js` | Drive-mode chunking |
406
+ | Backend KB API | `DeSciX_Cloud/microservice/services/commandHandlers/appCommands.js` | Server-side processing |
407
+ | Pinecone Service | `DeSciX_Cloud/microservice/services/pineconeService.js` | Vector database |
408
+ | Server Chunking | `DeSciX_Cloud/microservice/services/chunkingUtils.js` | Drive-mode chunking |