@descix/cli 1.0.0 → 1.0.1

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/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@descix/cli",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "DeSciX CLI and MCP Server - Unified command-line interface for DeSciX platform",
5
5
  "type": "module",
6
6
  "main": "./bin/descix.js",
7
7
  "bin": {
8
- "descix": "./bin/descix.js",
9
- "descix-mcp": "./bin/mcp-server.js"
8
+ "descix": "bin/descix.js",
9
+ "descix-mcp": "bin/mcp-server.js"
10
10
  },
11
11
  "scripts": {
12
12
  "test": "echo \"Error: no test specified\" && exit 1",
@@ -34,7 +34,14 @@
34
34
  "ora": "^9.0.0",
35
35
  "vite": "^6.2.0"
36
36
  },
37
- "bundledDependencies": ["@descix/app-sdk", "@descix/sdk"],
37
+ "files": [
38
+ "bin",
39
+ "lib",
40
+ "templates",
41
+ "agent-assets",
42
+ "vendor",
43
+ "!**/node_modules"
44
+ ],
38
45
  "engines": {
39
46
  "node": ">=24.0.0"
40
47
  }
@@ -1,399 +0,0 @@
1
- # DeSciX SDK - CLI and MCP Tools
2
-
3
- ## Overview
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.
6
-
7
- **Key capabilities:**
8
- - CLI commands for all platform operations
9
- - MCP server for Cursor IDE integration
10
- - Intelligent tool discovery via `tell_me_how`
11
- - Entitlements-driven workspace setup
12
- - Git-aware project initialization
13
-
14
- ---
15
-
16
- ## Installation
17
-
18
- ```bash
19
- # Global install (recommended)
20
- npm install -g @descix/cli
21
-
22
- # Or via npm link during development
23
- cd DeSciX_Core/descix-cli
24
- npm link
25
- ```
26
-
27
- ---
28
-
29
- ## CLI Commands
30
-
31
- ### descix setup
32
-
33
- **Description:** One-time workspace configuration wizard
34
- **Use when:** First time setting up DeSciX in a new workspace or Cursor project
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
41
-
42
- **Example:**
43
- ```bash
44
- cd ~/Projects/MyApp
45
- descix setup
46
- # Follow the prompts
47
- # Restart Cursor after completion
48
- ```
49
-
50
- ---
51
-
52
- ### descix login
53
-
54
- **Description:** Authenticate with the DeSciX platform
55
- **Use when:** Session expired or first-time authentication
56
- **Options:**
57
- - `--device` (default): Opens browser for Powch authentication
58
- - `--wallet`: Direct wallet signature authentication
59
-
60
- **Example:**
61
- ```bash
62
- descix login
63
- # Opens browser, complete authentication
64
- # Credentials saved to .descix/wallet.json
65
- ```
66
-
67
- ---
68
-
69
- ### descix whoami
70
-
71
- **Description:** Display current authentication status
72
- **Use when:** Checking if you're logged in and what account you're using
73
-
74
- **Example:**
75
- ```bash
76
- descix whoami
77
- # Output:
78
- # User: sam@descix.net
79
- # Wallet: 0xe71b412d...
80
- # Session: Valid
81
- ```
82
-
83
- ---
84
-
85
- ### descix tell-me-how
86
-
87
- **Description:** Discover platform tools using natural language
88
- **Use when:** You don't know which command to use for a task
89
-
90
- **Options:**
91
- - `--scope project`: Search within current workspace apps
92
- - `--scope entitlements`: Search apps you have access to (default)
93
- - `--scope discovery`: Search all platform tools
94
- - `--json`: Output raw JSON response
95
-
96
- **Examples:**
97
- ```bash
98
- # Find how to create an app
99
- descix tell-me-how "How do I create a new app?"
100
-
101
- # Search within current project
102
- descix tell-me-how --scope project "How do I sync my knowledge base?"
103
-
104
- # Discover all available tools
105
- descix tell-me-how --scope discovery "What AI training tools exist?"
106
- ```
107
-
108
- ---
109
-
110
- ### descix app create
111
-
112
- **Description:** Create or hydrate an app using the interactive wizard
113
- **Use when:** Starting a new project or hydrating an existing app
114
- **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.
121
-
122
- **Example:**
123
- ```bash
124
- # Interactive wizard
125
- descix app create --wizard
126
- ```
127
-
128
- ---
129
-
130
- ### descix kb
131
-
132
- **Description:** Manage Knowledge Base content (Git Mode)
133
- **Use when:** Processing KB documents locally
134
-
135
- **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)
140
-
141
- **Example:**
142
- ```bash
143
- # Full build pipeline
144
- descix kb build -c descix -a myapp
145
- ```
146
-
147
- ---
148
-
149
- ### descix microservice vectorize
150
-
151
- **Description:** Vectorize a SERVICE_README for tell_me_how discovery
152
- **Use when:** Adding or updating service documentation
153
- **Options:**
154
- - `-n, --name <name>`: Service name
155
- - `-c, --community <id>`: Community ID
156
- - `-a, --app <id>`: App ID
157
- - `-r, --readme <path>`: Path to README file
158
-
159
- **Example:**
160
- ```bash
161
- descix microservice vectorize -r ./SERVICE_README_myservice.md
162
- ```
163
-
164
- ---
165
-
166
- ### descix purchases
167
-
168
- **Description:** List your entitlements (communities, apps, service slots)
169
- **Use when:** Checking what resources you have access to
170
-
171
- **Example:**
172
- ```bash
173
- descix purchases
174
- # Output shows communities, apps, and service slots
175
- ```
176
-
177
- ---
178
-
179
- ## MCP Tools (for Cursor AI)
180
-
181
- After running `descix setup` and restarting Cursor, these MCP tools are available to the AI agent:
182
-
183
- ### tell_me_how
184
-
185
- **Description:** Primary discovery tool - finds relevant commands for any task
186
- **Use first:** Always use this before attempting platform operations
187
-
188
- ```javascript
189
- tell_me_how({
190
- question: "How do I deploy my app?",
191
- scope: "entitlements"
192
- })
193
- ```
194
-
195
- **Scope options:**
196
- - `project`: Uses `.descix/workspace.json` mappings
197
- - `entitlements`: Only tools you have access to (default)
198
- - `discovery`: All platform tools (may require purchase)
199
-
200
- ---
201
-
202
- ### execute_remote_command
203
-
204
- **Description:** Execute any backend command discovered via tell_me_how
205
- **Use after:** tell_me_how returns recommended commands
206
-
207
- ```javascript
208
- execute_remote_command({
209
- command: "create_app",
210
- params: {
211
- community_id: "descix",
212
- app_name: "My New App"
213
- }
214
- })
215
- ```
216
-
217
- ---
218
-
219
- ### descix_init
220
-
221
- **Description:** Initialize a local project for DeSciX deployment
222
- **Use when:** Setting up a new project folder
223
-
224
- ```javascript
225
- descix_init({
226
- projectPath: "/Users/dev/Projects/MyApp",
227
- appName: "my-app",
228
- communityId: "descix"
229
- })
230
- ```
231
-
232
- **Creates:**
233
- - `.descix/workspace.json` or `.descix/context.json`
234
- - `app_description.md` from README if missing
235
- - Folder structure for knowledge base
236
-
237
- ---
238
-
239
- ### descix_wizard_step
240
-
241
- **Description:** Execute multi-step wizard workflows
242
- **Use when:** Creating apps, communities, or complex operations
243
-
244
- ```javascript
245
- descix_wizard_step({
246
- wizard_type: "create_app",
247
- step: "init",
248
- params: {
249
- community_id: "descix",
250
- app_name: "My App"
251
- }
252
- })
253
- ```
254
-
255
- **Wizard types:**
256
- - `create_app`: App creation with folder setup
257
- - `create_community`: Community creation with token
258
- - `publish_kb`: Knowledge base sync and publish
259
-
260
- ---
261
-
262
- ### git_sync_ops
263
-
264
- **Description:** Git operations with auto-generated commit messages
265
- **Use when:** Committing changes, checking status
266
-
267
- ```javascript
268
- git_sync_ops({
269
- operation: "status", // or "commit", "diff", "sync_info"
270
- projectPath: "/Users/dev/Projects/MyApp"
271
- })
272
- ```
273
-
274
- ---
275
-
276
- ### search_knowledge_base
277
-
278
- **Description:** Search a specific knowledge base via RAG
279
- **Use when:** You know the exact KB to search
280
-
281
- ```javascript
282
- search_knowledge_base({
283
- communityId: "descix",
284
- appId: "docs",
285
- kbId: "sdk",
286
- query: "How do I authenticate?"
287
- })
288
- ```
289
-
290
- ---
291
-
292
- ### chat_with_kb
293
-
294
- **Description:** Conversational RAG with knowledge base context
295
- **Use when:** Complex questions requiring AI reasoning
296
-
297
- ```javascript
298
- chat_with_kb({
299
- communityId: "descix",
300
- appId: "docs",
301
- kbId: "sdk",
302
- message: "Explain the authentication flow step by step"
303
- })
304
- ```
305
-
306
- ---
307
-
308
- ## Workspace Configuration
309
-
310
- ### workspace.json (Monorepo)
311
-
312
- For multi-app workspaces, create `.descix/workspace.json`:
313
-
314
- ```json
315
- {
316
- "version": "2.0",
317
- "primaryCommunity": "descix",
318
- "directoryMappings": {
319
- "frontend": { "communityId": "descix", "appId": "pwa", "kbId": "General" },
320
- "backend": { "communityId": "descix", "appId": "cloud", "kbId": "General" },
321
- "docs": { "communityId": "descix", "appId": "docs", "kbId": "sdk" }
322
- },
323
- "defaultContext": {
324
- "communityId": "descix",
325
- "appId": "docs",
326
- "kbId": "sdk"
327
- }
328
- }
329
- ```
330
-
331
- ### context.json (Single App)
332
-
333
- For individual app folders, create `.descix/context.json`:
334
-
335
- ```json
336
- {
337
- "version": "2.0",
338
- "type": "app",
339
- "community_id": "descix",
340
- "app_id": "myapp",
341
- "app_name": "My Application",
342
- "folders": {
343
- "app": { "local_path": ".", "sync_type": "assets" },
344
- "kb": { "local_path": "docs", "sync_type": "rag" }
345
- }
346
- }
347
- ```
348
-
349
- ---
350
-
351
- ## Common Workflows
352
-
353
- ### New Developer Onboarding (Cursor IDE)
354
-
355
- 1. Install CLI: `npm install -g @descix/cli`
356
- 2. Run setup: `descix setup`
357
- 3. Restart Cursor (Cmd+Shift+P → "Reload Window")
358
- 4. AI agent can now use MCP tools
359
- 5. Ask: "How do I create an app?"
360
- 6. AI uses `tell_me_how` → `execute_remote_command`
361
-
362
- ### Entitlements-First App Creation
363
-
364
- 1. AI calls `execute_remote_command({ command: "fetch_my_purchases" })`
365
- 2. AI presents user's communities and apps
366
- 3. User selects community (or creates new)
367
- 4. AI calls `descix_wizard_step` for app creation
368
- 5. AI creates local `.descix/context.json`
369
-
370
- ### Monorepo Setup
371
-
372
- 1. AI calls `fetch_my_purchases` to get entitlements
373
- 2. AI scans workspace folders
374
- 3. AI asks user: "Map `frontend/` to which app?"
375
- 4. AI creates `.descix/workspace.json` with mappings
376
- 5. `tell_me_how --scope project` now uses these mappings
377
-
378
- ---
379
-
380
- ## Troubleshooting
381
-
382
- ### "MCP tools not available"
383
- 1. Run `descix setup` in workspace root
384
- 2. Restart Cursor completely
385
- 3. Check `.cursor/mcp.json` exists with `descix` server
386
-
387
- ### "Session expired"
388
- Run `descix reconnect` or `descix login`
389
-
390
- ### "No results from tell_me_how"
391
- Service READMEs may not be vectorized. Ask admin to run `descix microservice vectorize` for relevant services.
392
-
393
- ### "workspace.json not found" for project scope
394
- Run `descix init` or let AI create workspace.json via `descix_init` MCP tool.
395
-
396
- ---
397
-
398
- *SDK Version: 2.0.0*
399
- *Package: @descix/cli*
Binary file
package/test-hydration.js DELETED
@@ -1,150 +0,0 @@
1
- #!/usr/bin/env node
2
- /**
3
- * Test Drive Hydration
4
- */
5
-
6
- import { google } from 'googleapis';
7
- import GoogleStorage from './lib/google-storage-adc.js';
8
- import * as fs from 'fs/promises';
9
- import * as path from 'path';
10
- import { fileURLToPath } from 'url';
11
-
12
- const __dirname = path.dirname(fileURLToPath(import.meta.url));
13
- const DRIVE_FOLDER_MIME = 'application/vnd.google-apps.folder';
14
-
15
- async function getAuth() {
16
- return new google.auth.GoogleAuth({
17
- scopes: ['https://www.googleapis.com/auth/drive', 'https://www.googleapis.com/auth/drive.file']
18
- });
19
- }
20
-
21
- async function main() {
22
- console.log('=== Drive Hydration Test ===\n');
23
-
24
- // Step 1: Verify ADC
25
- console.log('1. Verifying ADC authentication...');
26
- const user = await GoogleStorage.verifyDriveAuth();
27
- console.log(` ✓ Authenticated as: ${user.emailAddress}\n`);
28
-
29
- // Step 2: Find DeSciX base folder
30
- console.log('2. Looking for DeSciX base folder...');
31
- const auth = await getAuth();
32
- const drive = google.drive({ version: 'v3', auth });
33
-
34
- const possibleNames = ['DeSciX', 'DeSciX_Apps', 'descix-apps', 'descix'];
35
- let baseFolder = null;
36
-
37
- for (const name of possibleNames) {
38
- const res = await drive.files.list({
39
- q: `name='${name}' and mimeType='${DRIVE_FOLDER_MIME}' and trashed=false`,
40
- fields: 'files(id, name)'
41
- });
42
- if (res.data.files?.length) {
43
- baseFolder = res.data.files[0];
44
- console.log(` ✓ Found base folder: "${name}" (ID: ${baseFolder.id})\n`);
45
- break;
46
- }
47
- }
48
-
49
- if (!baseFolder) {
50
- console.log(' ✗ Could not find DeSciX base folder');
51
- const rootRes = await drive.files.list({
52
- q: `'root' in parents and mimeType='${DRIVE_FOLDER_MIME}' and trashed=false`,
53
- fields: 'files(id, name)',
54
- pageSize: 20
55
- });
56
- console.log(' Root folders:');
57
- for (const f of rootRes.data.files || []) {
58
- console.log(` - ${f.name} (${f.id})`);
59
- }
60
- return;
61
- }
62
-
63
- // Step 3: Find descix/agent
64
- console.log('3. Locating descix/agent folder...');
65
- const agentFolderId = await GoogleStorage.findFolderByPath(baseFolder.id, 'descix/agent');
66
-
67
- if (!agentFolderId) {
68
- console.log(' ✗ Could not find descix/agent folder');
69
- console.log(' Contents of base folder:');
70
- const contents = await GoogleStorage.listFolderWithMeta(baseFolder.id);
71
- for (const f of contents) {
72
- console.log(` - ${f.name} (${f.mimeType === DRIVE_FOLDER_MIME ? 'folder' : 'file'})`);
73
- }
74
- return;
75
- }
76
-
77
- console.log(` ✓ Found descix/agent folder (ID: ${agentFolderId})\n`);
78
-
79
- // Step 4: List contents
80
- console.log('4. Contents of descix/agent in Drive:');
81
- const agentContents = await GoogleStorage.listFolderWithMeta(agentFolderId);
82
- for (const f of agentContents) {
83
- const type = f.mimeType === DRIVE_FOLDER_MIME ? '📁' : '📄';
84
- console.log(` ${type} ${f.name}`);
85
-
86
- // List subfolders
87
- if (f.mimeType === DRIVE_FOLDER_MIME) {
88
- const subContents = await GoogleStorage.listFolderWithMeta(f.id);
89
- for (const sf of subContents) {
90
- const subType = sf.mimeType === DRIVE_FOLDER_MIME ? '📁' : '📄';
91
- console.log(` ${subType} ${sf.name}`);
92
- }
93
- }
94
- }
95
- console.log('');
96
-
97
- // Step 5: Pull content using the new downloadFileFromDrive function
98
- const targetDir = '/Users/essam/Documents/Code/DaitaERC20/descix/agent';
99
- console.log(`5. Pulling content to ${targetDir}...`);
100
-
101
- const pullRecursive = async (localPath, folderId, indent = ' ') => {
102
- await fs.mkdir(localPath, { recursive: true });
103
- const files = await GoogleStorage.listFolderWithMeta(folderId);
104
- let count = 0;
105
-
106
- for (const file of files) {
107
- const targetPath = path.join(localPath, file.name);
108
-
109
- if (file.mimeType === DRIVE_FOLDER_MIME) {
110
- console.log(`${indent}📁 ${file.name}/`);
111
- count += await pullRecursive(targetPath, file.id, indent + ' ');
112
- } else {
113
- console.log(`${indent}📄 Downloading: ${file.name}`);
114
- await GoogleStorage.downloadFileFromDrive(file.id, targetPath);
115
- count++;
116
- }
117
- }
118
- return count;
119
- };
120
-
121
- const downloaded = await pullRecursive(targetDir, agentFolderId);
122
- console.log(`\n ✓ Downloaded ${downloaded} files\n`);
123
-
124
- // Step 6: Verify
125
- console.log('6. Verifying local content:');
126
- const verifyDir = async (dir, indent = '') => {
127
- try {
128
- const entries = await fs.readdir(dir, { withFileTypes: true });
129
- for (const e of entries) {
130
- const type = e.isDirectory() ? '📁' : '📄';
131
- console.log(` ${indent}${type} ${e.name}`);
132
- if (e.isDirectory()) {
133
- await verifyDir(path.join(dir, e.name), indent + ' ');
134
- }
135
- }
136
- } catch {
137
- console.log(` ${indent}(empty)`);
138
- }
139
- };
140
- await verifyDir(targetDir);
141
-
142
- console.log('\n=== Test Complete ===');
143
- console.log(`\nBase folder ID for workspace.json: ${baseFolder.id}`);
144
- }
145
-
146
- main().catch(err => {
147
- console.error('Error:', err.message);
148
- console.error(err.stack);
149
- process.exit(1);
150
- });