@descix/cli 1.0.6 → 1.0.8

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 (59) hide show
  1. package/README.md +1 -1
  2. package/agent-assets/guides/README.md +1 -1
  3. package/agent-assets/guides/dynamic-site-pattern.md +17 -30
  4. package/agent-assets/guides/knowledge-only-pattern.md +11 -15
  5. package/agent-assets/guides/microservice-pattern.md +12 -14
  6. package/agent-assets/guides/static-site-pattern.md +12 -15
  7. package/agent-assets/instructions/app-asset-validation.md +1 -1
  8. package/agent-assets/instructions/onboarding-flow.md +4 -4
  9. package/agent-assets/reference/app-creation.md +36 -101
  10. package/agent-assets/reference/architecture.md +43 -51
  11. package/agent-assets/reference/local-dev.md +1 -6
  12. package/agent-assets/reference/mcp-integration.md +21 -23
  13. package/agent-assets/reference/workspace-config.md +97 -340
  14. package/bin/descix.js +337 -618
  15. package/lib/api-client.js +30 -22
  16. package/lib/command-visibility.js +213 -0
  17. package/lib/commands/airdrop.js +10 -0
  18. package/lib/commands/auth.js +16 -2
  19. package/lib/commands/config.js +13 -31
  20. package/lib/commands/corpus.js +163 -59
  21. package/lib/commands/health.js +116 -21
  22. package/lib/commands/init.js +17 -45
  23. package/lib/commands/kb.js +7 -0
  24. package/lib/commands/retired-kb-sync.js +5 -27
  25. package/lib/commands/status.js +0 -9
  26. package/lib/core/Chunker.js +1 -1
  27. package/lib/core/CorpusWalker.js +238 -47
  28. package/lib/core/ManifestLoader.js +68 -0
  29. package/lib/core/Syncer.js +147 -46
  30. package/lib/interactive.js +158 -0
  31. package/lib/origin.js +3 -3
  32. package/lib/sdk-assets.js +28 -0
  33. package/lib/verb-invokes.generated.json +233 -0
  34. package/lib/wallet-file.js +36 -37
  35. package/lib/workspace-config.js +266 -199
  36. package/lib/workspace-identity.js +0 -1
  37. package/package.json +7 -3
  38. package/templates/agent-claude.md +1 -3
  39. package/templates/agent-cline.md +1 -2
  40. package/templates/agent-copilot.md +1 -2
  41. package/templates/agent-cursor.md +1 -2
  42. package/templates/scaffolds/microservice/SERVICE_README_sdk.md +1 -1
  43. package/templates/scaffolds/microservice/templates/SERVICE_README_TEMPLATE.md +2 -3
  44. package/agent-assets/rules/descix_mcp.template.mdc +0 -243
  45. package/lib/commands/briefer/errors.js +0 -88
  46. package/lib/commands/briefer/index.js +0 -319
  47. package/lib/commands/briefer/sources/canonical-sources.js +0 -129
  48. package/lib/commands/briefer/sources/entitlements.js +0 -220
  49. package/lib/commands/briefer/sources/environments.js +0 -205
  50. package/lib/commands/briefer/sources/identifiers.js +0 -214
  51. package/lib/commands/briefer/sources/microservice-deploy.js +0 -267
  52. package/lib/commands/briefer/sources/routing.js +0 -275
  53. package/lib/commands/briefer/sources/what-is-not.js +0 -223
  54. package/lib/commands/briefer/stitcher.js +0 -134
  55. package/lib/commands/briefer/util/source-reader.js +0 -502
  56. package/lib/commands/mcp.js +0 -273
  57. package/lib/commands/update.js +0 -581
  58. package/lib/wizard/setup.js +0 -503
  59. package/templates/descix_mcp.mdc +0 -122
@@ -71,7 +71,7 @@ All MCP calls include a `_descix` context object for identity propagation:
71
71
  expires_at: "..."
72
72
  },
73
73
  workspace: {
74
- community_id: "descix",
74
+ community_id: "daita",
75
75
  app_id: "agent"
76
76
  }
77
77
  }
@@ -138,9 +138,9 @@ tell_me_how({
138
138
 
139
139
  ### 3.5 Integration with SDK V2 Setup
140
140
 
141
- After `descix mcp quickstart` completes:
141
+ After `descix quickstart` completes:
142
142
 
143
- 1. `workspace.json` is created with community/app mappings
143
+ 1. `.descix/workspace.json` exists (created when none was found up the tree)
144
144
  2. Credentials are saved to `.descix/wallet.json`
145
145
  3. `tell_me_how --scope project` now filters by configured apps
146
146
  4. Agent can discover project-specific tools
@@ -224,7 +224,7 @@ const plan = await tell_me_how({
224
224
  const result = await execute_remote_command({
225
225
  command: plan.recommended_tools[0].name,
226
226
  params: {
227
- community_id: "descix",
227
+ community_id: "daita",
228
228
  app_id: "agent",
229
229
  kb_id: "General"
230
230
  }
@@ -238,22 +238,22 @@ const result = await execute_remote_command({
238
238
  ### 5.1 Initial Setup Phase
239
239
 
240
240
  ```
241
- descix mcp quickstart
241
+ descix quickstart
242
242
  │
243
243
  ▼
244
- Prerequisites Check (gcloud, ADC)
244
+ Device login (skipped when .descix/wallet.json holds a valid session)
245
245
  │
246
246
  ▼
247
- Device Login (browser)
247
+ .descix/workspace.json created (skipped when one exists up the tree)
248
248
  │
249
249
  ▼
250
- Workspace Builder (PWA)
250
+ CLAUDE.md, .github/copilot-instructions.md, .cursorrules, .clinerules written
251
251
  │
252
252
  ▼
253
- Hydration (Hydrator module)
253
+ .vscode/mcp.json written (skipped when the DeSciX extension handles MCP)
254
254
  │
255
255
  ▼
256
- Credentials Saved (.descix/wallet.json)
256
+ .descix/sdk-assets/ copied (fails loud if the package's assets are missing)
257
257
  │
258
258
  ▼
259
259
  ✓ Ready for agent interaction
@@ -290,18 +290,17 @@ When `--scope project` is used:
290
290
  4. Returns focused recommendations
291
291
 
292
292
  ```javascript
293
- // workspace.json
293
+ // workspace.json (v2.1)
294
294
  {
295
- "communities": {
296
- "descix": {
297
- "apps": {
298
- "agent": { "localPath": ".", "sync_mode": "git" }
299
- }
300
- }
295
+ "env": {
296
+ "apiUrl": "https://dev.descix.net",
297
+ "products": [
298
+ { "appId": "daita-agent", "communityId": "daita", "localPath": ".", "kbId": "General" }
299
+ ]
301
300
  }
302
301
  }
303
302
 
304
- // tell_me_how with project scope only searches within descix/agent
303
+ // tell_me_how with project scope only searches within daita-agent
305
304
  ```
306
305
 
307
306
  ---
@@ -319,12 +318,11 @@ descix tell-me-how "How do I sync my knowledge base?"
319
318
 
320
319
  ### 6.2 workspace.json from Hydration
321
320
 
322
- The `Hydrator` module creates `workspace.json` during setup:
321
+ `descix config init --env …` creates `workspace.json`; `descix app init` adds the app's `env.products[]` entry; no verb writes `driveConfig.base_folder_id` — set it in `.descix/workspace.json` when you use `descix drive pull/push`:
323
322
 
324
323
  ```javascript
325
- // Created by Hydrator.hydrateWorkspace()
326
324
  {
327
- "communities": { ... },
325
+ "env": { "apiUrl": "https://dev.descix.net", "products": [ /* one entry per app */ ] },
328
326
  "driveConfig": {
329
327
  "base_folder_id": "..." // For tell_me_how project scope
330
328
  }
@@ -374,7 +372,7 @@ if (tools.recommended_tools.length > 0) {
374
372
 
375
373
  **Pattern: Project-Scoped Operations**
376
374
  ```javascript
377
- // Only works after descix mcp quickstart
375
+ // Only works inside a workspace (descix quickstart or descix config init)
378
376
  const tools = await tell_me_how({
379
377
  question: "How do I update this app?",
380
378
  scope: "project" // Uses workspace.json
@@ -401,7 +399,7 @@ descix microservice vectorize -r SERVICE_README.md
401
399
  **Solution:**
402
400
  ```bash
403
401
  # Run setup first
404
- descix mcp quickstart
402
+ descix quickstart
405
403
 
406
404
  # Or ensure you're in the workspace root
407
405
  cd /path/to/workspace
@@ -1,249 +1,108 @@
1
1
  # Workspace Configuration Guide
2
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.
3
+ `.descix/workspace.json` is the CLI's only local configuration file. It is **version 2.1**, it is
4
+ written **only by CLI verbs**, and the loader refuses the shapes that hand edits produce. This page
5
+ is the schema and the verb that owns each key.
8
6
 
9
7
  ---
10
8
 
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.
9
+ ## 1. Format (v2.1 — the only format)
18
10
 
19
11
  ```json
20
12
  {
21
- "communities": {
22
- "descix": {
23
- "apps": {
24
- "agent": {
25
- "localPath": ".",
26
- "sync_mode": "git"
27
- }
28
- }
29
- }
30
- }
13
+ "version": "2.1",
14
+ "type": "workspace",
15
+ "workspaceRoot": "/path/to/workspace",
16
+ "env": {
17
+ "environment": "DEV",
18
+ "apiUrl": "https://dev.descix.net",
19
+ "gateway": { "port": 5599 },
20
+ "devCerts": { "dir": "/Users/you/.descix/dev-certs-san" },
21
+ "powchUrl": "https://powch.dev.descix.net",
22
+ "products": [
23
+ { "appId": "egpt-mydocs", "communityId": "egpt", "localPath": ".", "kbId": "General", "site": { "static": "site" } },
24
+ { "appId": "egpt-tool", "communityId": "egpt", "localPath": "tool", "kbId": "General", "site": { "port": 5174 }, "microservice": { "port": 4001 } }
25
+ ]
26
+ },
27
+ "driveConfig": { "base_folder_id": "1ABC..." }
31
28
  }
32
29
  ```
33
30
 
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
31
+ | Key | Meaning | Owned by |
32
+ |---|---|---|
33
+ | `env.environment` | `DEV`, `DEMO` or `PROD` | `descix config init --env dev\|demo\|prod` |
34
+ | `env.apiUrl` | the API origin this workspace talks to | `descix config init --env …` (known envs) / `descix config set-env <name> --url <origin>` (custom) |
35
+ | `env.gateway.port` | the port `descix serve` listens on | `descix config set-gateway-port <port>` |
36
+ | `env.devCerts` | `dir`, or `cert` + `key` — the TLS pair for the gateway and every app behind it | `descix config set-dev-certs --dir\|--cert\|--key\|--clear` |
37
+ | `env.powchUrl` | Powch's own origin (optional; Powch is cross-origin from the shell by design) | `descix config set-powch-url <url>` |
38
+ | `env.siteUrl` | the App Shell origin the gateway proxies `/` to (optional; default is the API origin) | `descix config set-site-url <url>` |
39
+ | `env.products[]` | one entry per app in this workspace, see below | `descix app init`, `app set-site`, `app set-port`, `app set-localpath`, `app unmap` |
40
+ | `env.platform` | the platform shell's own entry — platform contributors only; an app developer has none | platform runbook |
41
+ | `driveConfig.base_folder_id` | the Drive base folder for `descix drive pull/push` | no verb; set it in `.descix/workspace.json` |
51
42
 
52
- **Use Case:** Multiple apps within one community.
43
+ A product entry:
53
44
 
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
- ```
45
+ | Field | Meaning | Written by |
46
+ |---|---|---|
47
+ | `appId` | the platform app id (`<community>-<short>`) | `descix app init` |
48
+ | `communityId` | the app's community; stored so context detection can name it | `descix app init` |
49
+ | `localPath` | the app directory, relative to `workspaceRoot` (`.` when the workspace root is the app) | `descix app init -p`, `descix app set-localpath` |
50
+ | `kbId` | the default knowledge base (default `General`) | `descix app init --kb` |
51
+ | `site.static` | a directory under `localPath` served from disk at `/p/<appId>/` | `descix app set-site --static <dir>` |
52
+ | `site.port` | a framework dev server the gateway proxies `/p/<appId>` to (no path rewrite) | `descix app set-site --port <n>` |
53
+ | `microservice.port` | the local port the gateway proxies `/s/<appId>` to; `descix microservice init` requires it | `descix app set-port -p <n>` |
66
54
 
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
- ```
55
+ Sites and services are started by you (or your framework); the CLI does not store or run a dev command.
79
56
 
80
- ### 1.3 Multi-Community Mode
57
+ ### Refused shapes
81
58
 
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
- ```
59
+ - A `communities` block with no `env` block — the v1 format — fails on load: `v1 workspace format is
60
+ not supported. Migrate to v2.1.` The file is left untouched; re-create it with `descix config init
61
+ --env …` and `descix app init`.
62
+ - A top-level `apiUrl` key is refused by name; the origin lives at `env.apiUrl` and nowhere else.
115
63
 
116
64
  ---
117
65
 
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) |
66
+ ## 2. Other files under `.descix/`
160
67
 
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.
68
+ | File | Written by | Notes |
69
+ |---|---|---|
70
+ | `.descix/wallet.json` | `descix login` — always at `{workspaceRoot}/.descix/wallet.json` | credentials. `descix clone` appends `.descix/wallet.json` and `.descix/repo_key` to the clone's `.gitignore`; `descix login` and `descix init` do **not** touch `.gitignore` — add the entry yourself before the first commit |
71
+ | `.descix/manifests/<KB>.json` | you | corpus manifest: the sources `descix kb corpus sync` walks (paths relative to the repository root, at a git ref) |
72
+ | `.descix/manifests/site.json` | you (optional) | site manifest consumed by `descix site upload` |
73
+ | `.descix/sync-state/<KB>.json` | `descix kb corpus sync` | last sync commit, synced blob SHAs, `total_chunks` (the store's measured live count) |
181
74
 
182
75
  ---
183
76
 
184
77
  ## 3. Sync Modes
185
78
 
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)
79
+ ### 3.1 Git Mode (CLI developers)
193
80
 
194
- **Workflow:**
195
- 1. User creates/edits documents in Google Drive
196
- 2. User runs `descix drive pull` to get text-converted content
197
- 3. User edits text files locally (Git version control)
198
- 4. User runs `descix kb corpus sync` to generate chunks
199
- 5. User runs `descix kb corpus sync` to push chunks to Pinecone
200
- 6. User commits changes to Git
81
+ **Source of truth:** the git repository. **Tool:** the CLI.
201
82
 
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
83
+ 1. Author markdown in the repo (or pull Drive documents as markdown with `descix drive pull`).
84
+ 2. Commit.
85
+ 3. Name the folder(s) in `.descix/manifests/<KB>.json`.
86
+ 4. `descix kb corpus sync -a <app>` — walks the manifest's sources at the git ref (`main` unless
87
+ `--ref`), chunks what changed, purges what was deleted, upserts to Pinecone.
88
+ 5. `descix kb corpus status -a <app> -k <KB>` — files tracked, last sync commit, chunk total.
208
89
 
209
- ### 3.2 Drive Mode (PWA Users)
90
+ ### 3.2 Drive Mode (PWA users)
210
91
 
211
- **Source of Truth:** Google Drive
212
- **Versioning:** GCS/Firestore
213
- **Tool:** PWA only (no CLI)
92
+ **Source of truth:** Google Drive. **Tool:** the PWA; the backend's three-stage pipeline
93
+ (Drive → GCS → Pinecone) runs server-side. The CLI never triggers it.
214
94
 
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
95
+ ### 3.3 Mode determination
219
96
 
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.
97
+ The CLI only performs git-mode operations. If you are using the CLI, you are in git mode; there is no
98
+ switch.
237
99
 
238
100
  ---
239
101
 
240
102
  ## 4. Drive Configuration
241
103
 
242
- ### 4.1 Base Folder ID
104
+ `driveConfig.base_folder_id` is the root of all DeSciX content in the user's Drive:
243
105
 
244
- The `base_folder_id` is the root of all DeSciX content in the user's Drive.
245
-
246
- **Structure in Drive:**
247
106
  ```
248
107
  [User's Base Folder]/
249
108
  ├── [community_id]/
@@ -257,159 +116,57 @@ The `base_folder_id` is the root of all DeSciX content in the user's Drive.
257
116
  └── [other_community]/
258
117
  ```
259
118
 
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/` |
119
+ The SDK navigates Drive by template path: app `{community}/{app}/`, KB `{community}/{app}/kb/{kb}/`,
120
+ assets `{community}/{app}/assets/`, site `{community}/{app}/site/`.
277
121
 
278
122
  ---
279
123
 
280
- ## 5. ADC Authentication
281
-
282
- ### Requirements
124
+ ## 5. ADC Authentication (Drive verbs only)
283
125
 
284
- Google Cloud ADC (Application Default Credentials) is required for Drive access.
126
+ `descix drive pull` / `descix drive push` need Google Cloud Application Default Credentials with Drive
127
+ scopes:
285
128
 
286
- **Setup:**
287
129
  ```bash
288
130
  gcloud auth application-default login \
289
131
  --scopes=https://www.googleapis.com/auth/drive.file,https://www.googleapis.com/auth/drive
290
132
  ```
291
133
 
292
- ### Verification
293
-
294
- The CLI verifies ADC before operations:
134
+ | Error | Cause | Remedy |
135
+ |-------|-------|--------|
136
+ | "Could not load default credentials" | ADC not configured | `gcloud auth application-default login` |
137
+ | "Drive authentication failed" | scopes missing | re-run with the Drive scopes above |
138
+ | "Drive is not linked" | `driveConfig.base_folder_id` unset | set `driveConfig.base_folder_id` in `.descix/workspace.json`, or pass `--folder <id>` to `descix drive pull` |
295
139
 
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 mcp quickstart` |
140
+ The git path (`descix kb corpus sync`) needs none of this.
315
141
 
316
142
  ---
317
143
 
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
- ```
144
+ ## 6. CLI Context Resolution
344
145
 
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
- ```
146
+ `WorkspaceConfig.detectContext()` matches your current directory against every product's resolved
147
+ `localPath` (longest match wins) and returns `{ communityId, appId, kbId }` from that entry —
148
+ `communityId` is `null` for an entry registered by a CLI that did not yet store it.
149
+ `resolveContextWithOptions()` lets explicit `-c` / `-a` / `-k` flags win over detection.
393
150
 
394
- **Usage Pattern:**
395
151
  ```bash
396
- # From within an app directory - auto-detects community/app
397
- cd descix/appsdk
398
- descix kb corpus sync # Works without -c/-a flags
152
+ # From inside an app directory — detected
153
+ cd my-app
154
+ descix kb corpus sync
399
155
 
400
- # From workspace root - requires flags
401
- cd /workspace
402
- descix kb corpus sync -c descix -a appsdk
156
+ # From anywhere — flags
157
+ descix kb corpus sync -a egpt-mydocs
158
+ descix site status -c egpt -a egpt-mydocs # site status/list need both when the entry has no communityId
403
159
  ```
404
160
 
405
161
  ---
406
162
 
407
- ## 8. File References
163
+ ## 7. File References
408
164
 
409
165
  | Component | Path | Description |
410
166
  |-----------|------|-------------|
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/wizard/setup.js` | Initial workspace setup |
415
- | Config Commands | `DeSciX_Core/descix-cli/lib/commands/config.js` | Configuration management |
167
+ | WorkspaceConfig | `DeSciX_Core/descix-cli/lib/workspace-config.js` | the loader, the v2.1 writer, `registerApp`, `detectContext` |
168
+ | Origin resolution | `DeSciX_Core/descix-cli/lib/origin.js` | flag → `DESCIX_API_URL` → `env.apiUrl` → default |
169
+ | GlobalConfig | `DeSciX_Core/descix-cli/lib/global-config.js` | user-level settings (`~/.descixrc`) |
170
+ | Config commands | `DeSciX_Core/descix-cli/lib/commands/config.js` | `config init/set-env/set-*` |
171
+ | Wallet file | `DeSciX_Core/descix-cli/lib/wallet-file.js` | `.descix/wallet.json` location |
172
+ | Corpus sync | `DeSciX_Core/descix-cli/lib/commands/corpus.js` | manifests, sync-state |