@descix/cli 1.0.6 → 1.0.7

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.
@@ -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` | `descix mcp quickstart` |
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
+ | "base_folder_id missing" | Drive not registered | `descix mcp quickstart` |
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 |
@@ -118,7 +118,7 @@ tell_me_how({
118
118
  ### Tier 3: chat_with_kb (Rich Context)
119
119
  ```javascript
120
120
  chat_with_kb({
121
- communityId: "descix",
121
+ communityId: "daita",
122
122
  appId: "docs",
123
123
  kbId: "sdk",
124
124
  message: "Explain the deployment workflow for dynamic sites"