@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.
- package/agent-assets/guides/dynamic-site-pattern.md +10 -14
- package/agent-assets/guides/knowledge-only-pattern.md +11 -15
- package/agent-assets/guides/microservice-pattern.md +12 -14
- package/agent-assets/guides/static-site-pattern.md +12 -15
- package/agent-assets/instructions/onboarding-flow.md +4 -4
- package/agent-assets/reference/app-creation.md +36 -101
- package/agent-assets/reference/architecture.md +24 -27
- package/agent-assets/reference/mcp-integration.md +14 -22
- package/agent-assets/reference/workspace-config.md +97 -340
- package/agent-assets/rules/descix_mcp.template.mdc +1 -1
- package/bin/descix.js +137 -75
- package/lib/api-client.js +30 -22
- package/lib/commands/airdrop.js +10 -0
- package/lib/commands/auth.js +16 -2
- package/lib/commands/briefer/index.js +8 -5
- package/lib/commands/config.js +13 -31
- package/lib/commands/corpus.js +161 -54
- package/lib/commands/health.js +116 -21
- package/lib/commands/init.js +17 -45
- package/lib/commands/kb.js +7 -0
- package/lib/core/Chunker.js +1 -1
- package/lib/core/CorpusWalker.js +238 -47
- package/lib/core/ManifestLoader.js +68 -0
- package/lib/core/Syncer.js +147 -46
- package/lib/interactive.js +158 -0
- package/lib/origin.js +3 -3
- package/lib/wallet-file.js +36 -37
- package/lib/wizard/setup.js +104 -22
- package/lib/workspace-config.js +265 -163
- package/lib/workspace-identity.js +0 -1
- package/package.json +2 -2
|
@@ -1,249 +1,108 @@
|
|
|
1
1
|
# Workspace Configuration Guide
|
|
2
2
|
|
|
3
|
-
**
|
|
4
|
-
**
|
|
5
|
-
|
|
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.
|
|
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
|
-
"
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
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
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
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
|
-
|
|
43
|
+
A product entry:
|
|
53
44
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
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
|
-
|
|
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
|
-
###
|
|
57
|
+
### Refused shapes
|
|
81
58
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
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.
|
|
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
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
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
|
-
|
|
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
|
-
**
|
|
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
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
-
|
|
206
|
-
|
|
207
|
-
-
|
|
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
|
|
90
|
+
### 3.2 Drive Mode (PWA users)
|
|
210
91
|
|
|
211
|
-
**Source of
|
|
212
|
-
|
|
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
|
-
|
|
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
|
-
|
|
221
|
-
|
|
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
|
-
|
|
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
|
-
|
|
261
|
-
|
|
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
|
|
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
|
-
|
|
293
|
-
|
|
294
|
-
|
|
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
|
-
|
|
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.
|
|
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
|
-
|
|
346
|
-
|
|
347
|
-
|
|
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
|
|
397
|
-
cd
|
|
398
|
-
descix kb corpus sync
|
|
152
|
+
# From inside an app directory — detected
|
|
153
|
+
cd my-app
|
|
154
|
+
descix kb corpus sync
|
|
399
155
|
|
|
400
|
-
# From
|
|
401
|
-
|
|
402
|
-
descix
|
|
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
|
-
##
|
|
163
|
+
## 7. File References
|
|
408
164
|
|
|
409
165
|
| Component | Path | Description |
|
|
410
166
|
|-----------|------|-------------|
|
|
411
|
-
| WorkspaceConfig | `DeSciX_Core/descix-cli/lib/workspace-config.js` |
|
|
412
|
-
|
|
|
413
|
-
|
|
|
414
|
-
|
|
|
415
|
-
|
|
|
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 |
|