@descix/cli 1.0.3 → 1.0.4

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.
@@ -85,9 +85,11 @@ The broker validates this context and propagates it to downstream services.
85
85
 
86
86
  ### 3.1 Primary Discovery Mechanism
87
87
 
88
- `tell_me_how` is the **primary entry point** for discovering platform capabilities. Always use it before attempting platform operations.
88
+ **Prerequisite: the developer is signed in.** `tell_me_how` returns caller-specific context (and `kb corpus sync` writes to a KB namespace) — both correctly refuse a credential-free caller, loud: `Authentication required`, exit 1. There is no guest/unauthenticated form of discovery, and that refusal must not be treated as a bug to work around. The step before discovery is `descix login --env dev`: it starts a device-code flow — opens a browser and mints a fresh sign-in code for that one invocation — and completes once the browser confirms it.
89
89
 
90
- **Rule:** Ask `tell_me_how` first, then execute the recommended command.
90
+ Once signed in, `tell_me_how` is the **primary entry point** for discovering platform capabilities. Always use it before attempting platform operations.
91
+
92
+ **Rule:** Sign in, then ask `tell_me_how` first, then execute the recommended command.
91
93
 
92
94
  ### 3.2 Three Scopes
93
95
 
@@ -100,6 +102,9 @@ The broker validates this context and propagates it to downstream services.
100
102
  ### 3.3 CLI Usage
101
103
 
102
104
  ```bash
105
+ # Sign in first — device-code flow, opens a browser (skip if already authenticated)
106
+ descix login --env dev
107
+
103
108
  # Default (entitlements scope)
104
109
  descix tell-me-how "How do I create a new app?"
105
110
 
@@ -341,10 +346,11 @@ Custom services integrate with the same pattern:
341
346
 
342
347
  ### 7.1 For AI Agents
343
348
 
344
- 1. **Always use tell_me_how first** - Don't guess at command names
345
- 2. **Use project scope when in a workspace** - More focused results
346
- 3. **Chain operations** - tell_me_how -> execute_remote_command
347
- 4. **Handle errors gracefully** - Show user-friendly messages
349
+ 1. **Be signed in before discovery** - `descix login --env dev` (device-code flow) is the step before `tell_me_how`; it refuses loud, not silently, for a credential-free caller
350
+ 2. **Always use tell_me_how first (once signed in)** - Don't guess at command names
351
+ 3. **Use project scope when in a workspace** - More focused results
352
+ 4. **Chain operations** - tell_me_how -> execute_remote_command
353
+ 5. **Handle errors gracefully** - Show user-friendly messages
348
354
 
349
355
  ### 7.2 For Service Developers
350
356
 
package/bin/descix.js CHANGED
@@ -2327,7 +2327,7 @@ corpusCommand
2327
2327
  .option('-k, --kb <name>', 'KB name (syncs specific manifest; default: all)')
2328
2328
  .option('-v, --verbose', 'Show verbose output')
2329
2329
  .option('--ref <ref>', 'Override the git ref for ALL manifest sources (e.g., --ref ws-admin-b1). Precedence: --ref > manifest source.ref > "main".')
2330
- .option('--rebuild', 'Reconcile Pinecone against the current manifest walk: enumerate remote file_ids, purge any not in the current corpus, then re-sync from scratch. Use to recover from accumulated stale-chunk drift. Prompts before deleting unless --yes is supplied.')
2330
+ .option('--rebuild', 'Reconcile Pinecone against REMOTE state: enumerate remote file_ids, purge any not in the current corpus, then re-sync from scratch. NOT needed to remove deleted files — an ordinary sync already purges them, diffing the walk against sync-state\'s last_sync_commit (measured: a plain sync purged 1962 chunks across 124 stale blob SHAs). Use --rebuild ONLY when that local sync-state cannot be trusted: it is lost, hand-edited, or vectors were orphaned outside the history it tracks. Prompts before deleting unless --yes is supplied.')
2331
2331
  .option('--dry-run', 'Enumerate would-be-purged file_ids and would-be-upserted chunks without ANY Pinecone writes. Exit 0 if no drift, 1 if drift. Read-only.')
2332
2332
  .option('--show-walk', 'Print the resolved ref + the first 50 walked files BEFORE any Pinecone operations. Useful for verifying --ref / manifest source resolution.')
2333
2333
  .option('--yes', 'Skip the interactive purge confirmation in --rebuild mode. Use in scripting/CI.')
@@ -85,12 +85,23 @@ export async function extract({ env, cliPaths } = {}) {
85
85
  relPath: CM_FILE,
86
86
  section: `§${SECTION.number} ${SECTION.heading}`
87
87
  });
88
+ // The symbol is matched WITHIN an export list rather than as the list's sole member. The old
89
+ // pattern anchored on the closing brace immediately after the name, so it broke the moment a
90
+ // second symbol was re-exported beside it — the extractor reported the re-export missing when
91
+ // it was present and one token wider.
92
+ //
93
+ // HONEST LIMITATION, stated rather than implied: this is still textual matching, so it remains a
94
+ // derivation of a fact the module itself owns. The robust fix is to consume the owner's actual
95
+ // exports, but this extractor cannot import communityManagement.js — that would pull the whole
96
+ // Cloud service graph (config bootstrap, Firestore) into the CLI. Matching the identifier inside
97
+ // any export list is what survives a re-ordering; a move to `export * from` would still need
98
+ // this line changed.
88
99
  const reExportMatch = findInLines({
89
100
  lines: cm.lines,
90
- regex: /export\s*\{\s*hydrateCommunityIdFromProducts\s*\}/,
101
+ regex: /export\s*\{[^}]*\bhydrateCommunityIdFromProducts\b/,
91
102
  section: `§${SECTION.number} ${SECTION.heading}`,
92
103
  source: `${CM_FILE} (hydrate re-export)`,
93
- expected: 'export { hydrateCommunityIdFromProducts }',
104
+ expected: 'hydrateCommunityIdFromProducts named in an export list',
94
105
  recovery: `Verify ${CM_FILE} still re-exports hydrateCommunityIdFromProducts.`
95
106
  });
96
107
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@descix/cli",
3
- "version": "1.0.3",
3
+ "version": "1.0.4",
4
4
  "description": "DeSciX CLI and MCP Server - Unified command-line interface for DeSciX platform",
5
5
  "repository": {
6
6
  "type": "git",
@@ -2,11 +2,11 @@
2
2
 
3
3
  ## Overview
4
4
 
5
- The DeSciX SDK provides command-line tools and MCP (Model Context Protocol) integration for building applications on the DeSciX platform. The SDK enables developers to authenticate, manage workspaces, create apps, and leverage AI-assisted development through Cursor IDE integration.
5
+ The DeSciX SDK provides command-line tools and MCP (Model Context Protocol) integration for building applications on the DeSciX platform. The SDK enables developers to authenticate, manage workspaces, create apps, and leverage AI-assisted development through editor MCP integration (Claude Code, Copilot, Cursor, Cline).
6
6
 
7
7
  **Key capabilities:**
8
8
  - CLI commands for all platform operations
9
- - MCP server for Cursor IDE integration
9
+ - MCP server integration for Claude Code, Copilot, Cursor and Cline
10
10
  - Intelligent tool discovery via `tell_me_how`
11
11
  - Entitlements-driven workspace setup
12
12
  - Git-aware project initialization
@@ -28,23 +28,22 @@ npm link
28
28
 
29
29
  ## CLI Commands
30
30
 
31
- ### descix setup
31
+ ### descix quickstart
32
32
 
33
- **Description:** One-time workspace configuration wizard
34
- **Use when:** First time setting up DeSciX in a new workspace or Cursor project
33
+ **Description:** One-command setup: auth → workspace → agent files → MCP config
34
+ **Use when:** First time setting up DeSciX in a new workspace
35
35
  **What it does:**
36
- 1. Prompts for API endpoint (production/local/custom)
37
- 2. Runs device authentication (opens browser)
38
- 3. Creates `.cursor/mcp.json` for MCP server
39
- 4. Creates `.cursor/rules/descix_mcp.mdc` for AI agent instructions
40
- 5. Creates `.descix/workspace.json` with initial configuration
36
+ 1. Authenticates via device login if no valid session exists
37
+ 2. Initializes `.descix/workspace.json` if missing
38
+ 3. Generates agent instruction files (`CLAUDE.md`, `.github/copilot-instructions.md`, `.cursorrules`, `.clinerules`) from the workspace's registered app/community
39
+ 4. Generates `.vscode/mcp.json` for MCP server config (skipped if the DeSciX VS Code extension already handles MCP)
40
+ 5. Copies SDK assets into `.descix/sdk-assets/`
41
41
 
42
42
  **Example:**
43
43
  ```bash
44
44
  cd ~/Projects/MyApp
45
- descix setup
45
+ descix quickstart
46
46
  # Follow the prompts
47
- # Restart Cursor after completion
48
47
  ```
49
48
 
50
49
  ---
@@ -54,8 +53,11 @@ descix setup
54
53
  **Description:** Authenticate with the DeSciX platform
55
54
  **Use when:** Session expired or first-time authentication
56
55
  **Options:**
57
- - `--device` (default): Opens browser for Powch authentication
58
- - `--wallet`: Direct wallet signature authentication
56
+ - (default, no flag needed): Device login — opens a browser for Powch authentication
57
+ - `--wallet`: Direct wallet signature authentication (advanced, not yet implemented)
58
+ - `-u, --url <url>`: API URL override
59
+ - `--no-oauth`: Skip the OAuth long-lived token leg (wallet-signature login only)
60
+ - `--scope <scope>`: OAuth scope to request (default: `mcp:read mcp:tools mcp:write mcp:admin`)
59
61
 
60
62
  **Example:**
61
63
  ```bash
@@ -107,41 +109,44 @@ descix tell-me-how --scope discovery "What AI training tools exist?"
107
109
 
108
110
  ---
109
111
 
110
- ### descix app create
112
+ ### descix app init
111
113
 
112
- **Description:** Create or hydrate an app using the interactive wizard
113
- **Use when:** Starting a new project or hydrating an existing app
114
+ **Description:** Create (if needed) and initialize an app: platform record + default KB + local workspace registration and scaffold. Idempotent.
115
+ **Use when:** Starting a new project or hydrating an existing app. This is the single canonical path — the old two-step `app create` then `app init` is deleted; `descix app create` now hard-fails naming this replacement.
114
116
  **Options:**
115
- - `-c, --community <id>`: Community ID
116
- - `-a, --app <name>`: App name
117
- - `--wizard`: Interactive wizard mode
118
- - `--quick`: Skip optional prompts
119
-
120
- **Note:** New apps should primarily be provisioned via the PWA. This command can hydrate a local workspace from an existing app or create a skeleton if permitted.
117
+ - `-a, --app <app_id>` (required): App ID. With `-c` this is the app NAME to create.
118
+ - `-c, --community <id>`: Community ID — required to create an app that does not exist yet
119
+ - `-s, --short <short_name>`: Short id segment (no hyphens) used when creating; defaults to `--app`
120
+ - `--overwrite`: When creating, overwrite an existing app record intentionally
121
+ - `--kb <name>`: Knowledge base name (default: `General`)
122
+ - `-p, --path <dir>`: Local app directory (default: auto-detected or cwd)
121
123
 
122
124
  **Example:**
123
125
  ```bash
124
- # Interactive wizard
125
- descix app create --wizard
126
+ descix app init -a myapp -c descix
126
127
  ```
127
128
 
128
129
  ---
129
130
 
130
131
  ### descix kb
131
132
 
132
- **Description:** Manage Knowledge Base content (Git Mode)
133
- **Use when:** Processing KB documents locally
133
+ **Description:** Manage Knowledge Base registration, corpus sync and per-KB configuration
134
+ **Use when:** Creating a KB, syncing its corpus to Pinecone, or managing per-KB settings
134
135
 
135
136
  **Subcommands:**
136
- - `pull`: Download source documents from Drive to `kb/src/`
137
- - `chunk`: Process source files into chunks in `kb/chunks/`
138
- - `sync`: Push chunks to the platform (Pinecone)
139
- - `build`: Run the full pipeline (Pull -> Chunk -> Sync)
137
+ - `create` / `list` / `delete`: Register, list or remove a KB
138
+ - `corpus sync`: The one KB sync surface — walks the corpus manifest, chunks in-memory, pushes to Pinecone
139
+ - `set-override-model` / `clear-override-model`: Pin or clear a per-KB model override
140
+ - `status`: Show corpus sync state (files, chunks, last sync, resolved ref)
141
+ - `doctor`: Detect drift between local sync-state and live Pinecone vector count
142
+ - `records put|query|get|delete`: Structured record CRUD on a KB
143
+
144
+ **Drive content authoring is a separate command:** `descix drive pull` / `descix drive push` (not under `kb`) move source documents between Drive and the local working tree.
140
145
 
141
146
  **Example:**
142
147
  ```bash
143
- # Full build pipeline
144
- descix kb build -c descix -a myapp
148
+ # Sync a KB's corpus manifest to Pinecone
149
+ descix kb corpus sync -a myapp -k General
145
150
  ```
146
151
 
147
152
  ---
@@ -159,8 +164,7 @@ The scaffold reads them via `utils.DEVELOPER_WALLET_ADDRESS` / `utils.DEVELOPER_
159
164
 
160
165
  **Canonical microservice onboarding sequence:**
161
166
  ```bash
162
- descix app create -c <community> -a <app>
163
- descix app init -a <community>-<app>
167
+ descix app init -a <app> -c <community>
164
168
  descix app set-port -a <community>-<app> -p <port>
165
169
  descix microservice register
166
170
  # then: cp dev-overrides.example.json dev-overrides.json and fill in the developer credential
@@ -200,14 +204,15 @@ descix purchases
200
204
 
201
205
  ---
202
206
 
203
- ## MCP Tools (for Cursor AI)
207
+ ## MCP Tools
204
208
 
205
- After running `descix setup` and restarting Cursor, these MCP tools are available to the AI agent:
209
+ After running `descix quickstart` and reloading your editor/session, these MCP tools are available to the AI agent. `descix quickstart` authenticates via device login as its first step (opens a browser device-code flow) before it writes workspace, agent-instruction and MCP config files; there is no unauthenticated form of any of this.
206
210
 
207
211
  ### tell_me_how
208
212
 
209
213
  **Description:** Primary discovery tool - finds relevant commands for any task
210
- **Use first:** Always use this before attempting platform operations
214
+ **Prerequisite:** the caller is signed in — it returns caller-specific context and is refused loud (`Authentication required`, exit 1) for a credential-free caller, never a silent partial answer
215
+ **Use first:** Once signed in, always use this before attempting platform operations
211
216
 
212
217
  ```javascript
213
218
  tell_me_how({
@@ -230,7 +235,7 @@ tell_me_how({
230
235
 
231
236
  ```javascript
232
237
  execute_remote_command({
233
- command: "create_app",
238
+ command: "create_app_for_community",
234
239
  params: {
235
240
  community_id: "descix",
236
241
  app_name: "My New App"
@@ -240,90 +245,31 @@ execute_remote_command({
240
245
 
241
246
  ---
242
247
 
243
- ### descix_init
244
-
245
- **Description:** Initialize a local project for DeSciX deployment
246
- **Use when:** Setting up a new project folder
247
-
248
- ```javascript
249
- descix_init({
250
- projectPath: "/Users/dev/Projects/MyApp",
251
- appName: "my-app",
252
- communityId: "descix"
253
- })
254
- ```
255
-
256
- **Creates:**
257
- - `.descix/workspace.json` or `.descix/context.json`
258
- - `app_description.md` from README if missing
259
- - Folder structure for knowledge base
260
-
261
- ---
262
-
263
- ### descix_wizard_step
248
+ ### query_knowledge_base
264
249
 
265
- **Description:** Execute multi-step wizard workflows
266
- **Use when:** Creating apps, communities, or complex operations
250
+ **Description:** Vector-similarity search over a knowledge base — returns raw source chunks with dereferenceable citations (retrieval, no synthesis, stateless)
251
+ **Use when:** You want primary-source passages/citations, or to ground/check an `ask_question_to_app` answer
267
252
 
268
253
  ```javascript
269
- descix_wizard_step({
270
- wizard_type: "create_app",
271
- step: "init",
272
- params: {
273
- community_id: "descix",
274
- app_name: "My App"
275
- }
276
- })
277
- ```
278
-
279
- **Wizard types:**
280
- - `create_app`: App creation with folder setup
281
- - `create_community`: Community creation with token
282
- - `publish_kb`: Knowledge base sync and publish
283
-
284
- ---
285
-
286
- ### git_sync_ops
287
-
288
- **Description:** Git operations with auto-generated commit messages
289
- **Use when:** Committing changes, checking status
290
-
291
- ```javascript
292
- git_sync_ops({
293
- operation: "status", // or "commit", "diff", "sync_info"
294
- projectPath: "/Users/dev/Projects/MyApp"
295
- })
296
- ```
297
-
298
- ---
299
-
300
- ### search_knowledge_base
301
-
302
- **Description:** Search a specific knowledge base via RAG
303
- **Use when:** You know the exact KB to search
304
-
305
- ```javascript
306
- search_knowledge_base({
307
- communityId: "descix",
308
- appId: "docs",
309
- kbId: "sdk",
254
+ query_knowledge_base({
255
+ app_id: "docs",
256
+ kb_id: "sdk",
310
257
  query: "How do I authenticate?"
311
258
  })
312
259
  ```
313
260
 
314
261
  ---
315
262
 
316
- ### chat_with_kb
263
+ ### ask_question_to_app
317
264
 
318
- **Description:** Conversational RAG with knowledge base context
319
- **Use when:** Complex questions requiring AI reasoning
265
+ **Description:** Ask a natural-language question against an app's knowledge base and get a synthesized, cited answer (stateful — pass `previous_interaction_id` to continue a thread)
266
+ **Use when:** Complex questions requiring AI reasoning over a community's own sources
320
267
 
321
268
  ```javascript
322
- chat_with_kb({
323
- communityId: "descix",
324
- appId: "docs",
325
- kbId: "sdk",
326
- message: "Explain the authentication flow step by step"
269
+ ask_question_to_app({
270
+ app_id: "docs",
271
+ knowledgebase_name: "sdk",
272
+ user_input: "Explain the authentication flow step by step"
327
273
  })
328
274
  ```
329
275
 
@@ -331,65 +277,44 @@ chat_with_kb({
331
277
 
332
278
  ## Workspace Configuration
333
279
 
334
- ### workspace.json (Monorepo)
280
+ ### workspace.json (v2.1 — canonical)
335
281
 
336
- For multi-app workspaces, create `.descix/workspace.json`:
282
+ `.descix/workspace.json` is written and mutated by `descix init` / `descix app init` / `descix app set-*` — never hand-edited. The v2.1 format is `env.platform` (the shell/store app, served at root) plus `env.products[]` (apps hosted inside the shell); the older `communities`-based v1 format is not supported and hard-errors on load ("v1 workspace format is not supported. Migrate to v2.1."):
337
283
 
338
284
  ```json
339
285
  {
340
- "version": "2.0",
341
- "primaryCommunity": "descix",
342
- "directoryMappings": {
343
- "frontend": { "communityId": "descix", "appId": "pwa", "kbId": "General" },
344
- "backend": { "communityId": "descix", "appId": "cloud", "kbId": "General" },
345
- "docs": { "communityId": "descix", "appId": "docs", "kbId": "sdk" }
346
- },
347
- "defaultContext": {
348
- "communityId": "descix",
349
- "appId": "docs",
350
- "kbId": "sdk"
286
+ "version": "2.1",
287
+ "env": {
288
+ "platform": { "appId": "daita", "communityId": "descix", "localPath": ".", "kbId": "General" },
289
+ "products": [
290
+ { "appId": "docs", "communityId": "descix", "kbId": "sdk", "localPath": "descix-docs" }
291
+ ]
351
292
  }
352
293
  }
353
294
  ```
354
295
 
355
- ### context.json (Single App)
356
-
357
- For individual app folders, create `.descix/context.json`:
358
-
359
- ```json
360
- {
361
- "version": "2.0",
362
- "type": "app",
363
- "community_id": "descix",
364
- "app_id": "myapp",
365
- "app_name": "My Application",
366
- "folders": {
367
- "app": { "local_path": ".", "sync_type": "assets" },
368
- "kb": { "local_path": "docs", "sync_type": "rag" }
369
- }
370
- }
371
- ```
296
+ A single-app (non-monorepo) workspace uses the same v2.1 shape with only `env.platform` set and an empty (or omitted) `env.products[]` — there is no separate single-app file format.
372
297
 
373
298
  ---
374
299
 
375
300
  ## Common Workflows
376
301
 
377
- ### New Developer Onboarding (Cursor IDE)
302
+ ### New Developer Onboarding
378
303
 
379
304
  1. Install CLI: `npm install -g @descix/cli`
380
- 2. Run setup: `descix setup`
381
- 3. Restart Cursor (Cmd+Shift+P → "Reload Window")
305
+ 2. Run quickstart: `descix quickstart` — authenticates, initializes `.descix/workspace.json`, generates agent instruction files (`CLAUDE.md`, `.github/copilot-instructions.md`, `.cursorrules`, `.clinerules`) for Claude Code, Copilot, Cursor and Cline, and writes `.vscode/mcp.json` (skipped if the DeSciX VS Code extension is installed — it registers MCP natively)
306
+ 3. Reload the editor/session so it picks up the generated files
382
307
  4. AI agent can now use MCP tools
383
308
  5. Ask: "How do I create an app?"
384
309
  6. AI uses `tell_me_how` → `execute_remote_command`
385
310
 
386
311
  ### Entitlements-First App Creation
387
312
 
388
- 1. AI calls `execute_remote_command({ command: "fetch_my_purchases" })`
313
+ 1. AI calls `fetch_my_purchases()` directly (it is its own MCP tool, not an `execute_remote_command` target)
389
314
  2. AI presents user's communities and apps
390
315
  3. User selects community (or creates new)
391
- 4. AI calls `descix_wizard_step` for app creation
392
- 5. AI creates local `.descix/context.json`
316
+ 4. AI calls `execute_remote_command({ command: "create_app_for_community", params: {...} })` for app creation
317
+ 5. AI runs `descix app init` to register the local workspace mapping in `.descix/workspace.json`
393
318
 
394
319
  ### Monorepo Setup
395
320
 
@@ -404,9 +329,9 @@ For individual app folders, create `.descix/context.json`:
404
329
  ## Troubleshooting
405
330
 
406
331
  ### "MCP tools not available"
407
- 1. Run `descix setup` in workspace root
408
- 2. Restart Cursor completely
409
- 3. Check `.cursor/mcp.json` exists with `descix` server
332
+ 1. Run `descix quickstart` in workspace root
333
+ 2. Reload your editor/session completely
334
+ 3. Check `.vscode/mcp.json` exists with a `descix` server (this file is skipped, by design, if the DeSciX VS Code extension is installed — it registers MCP natively)
410
335
 
411
336
  ### "401 Unauthorized on a loopback / mesh call"
412
337
  For the app data plane, your service authenticates AS the developer (wallet_address + signature). A 401 means the
@@ -421,7 +346,7 @@ Run `descix reconnect` or `descix login`
421
346
  Service READMEs may not be vectorized. Ask admin to run `descix microservice vectorize` for relevant services.
422
347
 
423
348
  ### "workspace.json not found" for project scope
424
- Run `descix init` or let AI create workspace.json via `descix_init` MCP tool.
349
+ Run `descix init` (or `descix quickstart`, which runs it for you if missing).
425
350
 
426
351
  ---
427
352