@descix/cli 1.0.0
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/README.md +95 -0
- package/SERVICE_README_sdk.md +399 -0
- package/agent-assets/guides/README.md +61 -0
- package/agent-assets/guides/dynamic-site-pattern.md +125 -0
- package/agent-assets/guides/knowledge-only-pattern.md +93 -0
- package/agent-assets/guides/microservice-pattern.md +152 -0
- package/agent-assets/guides/static-site-pattern.md +111 -0
- package/agent-assets/instructions/app-asset-validation.md +477 -0
- package/agent-assets/instructions/onboarding-flow.md +408 -0
- package/agent-assets/instructions/standard-folder-structure.md +125 -0
- package/agent-assets/reference/app-creation.md +381 -0
- package/agent-assets/reference/architecture.md +406 -0
- package/agent-assets/reference/local-dev.md +138 -0
- package/agent-assets/reference/mcp-integration.md +424 -0
- package/agent-assets/reference/workspace-config.md +415 -0
- package/agent-assets/rules/descix_mcp.template.mdc +243 -0
- package/bin/descix.js +3930 -0
- package/bin/mcp-server.js +382 -0
- package/descix-cli-1.0.0.tgz +0 -0
- package/lib/agent-files.js +162 -0
- package/lib/api-client.js +458 -0
- package/lib/auth-guard.js +67 -0
- package/lib/commands/app-wizard.js +627 -0
- package/lib/commands/auth.js +407 -0
- package/lib/commands/buy.js +207 -0
- package/lib/commands/clone.js +91 -0
- package/lib/commands/config.js +155 -0
- package/lib/commands/doctor.js +277 -0
- package/lib/commands/folder.js +291 -0
- package/lib/commands/init.js +257 -0
- package/lib/commands/kb.js +654 -0
- package/lib/commands/mcp.js +273 -0
- package/lib/commands/serve.js +12 -0
- package/lib/commands/status.js +239 -0
- package/lib/commands/update.js +653 -0
- package/lib/core/Chunker.js +610 -0
- package/lib/core/Hydrator.js +801 -0
- package/lib/core/PathContext.js +335 -0
- package/lib/core/Syncer.js +310 -0
- package/lib/core/index.js +32 -0
- package/lib/global-config.js +86 -0
- package/lib/google-storage-adc.js +511 -0
- package/lib/wallet-file.js +232 -0
- package/lib/wizard/setup.js +502 -0
- package/lib/workspace-config.js +712 -0
- package/lib/workspace-utils.js +126 -0
- package/package.json +41 -0
- package/templates/agent-claude.md +226 -0
- package/templates/agent-cline.md +133 -0
- package/templates/agent-copilot.md +133 -0
- package/templates/agent-cursor.md +133 -0
- package/templates/descix_mcp.mdc +122 -0
- package/templates/drive/README.md +42 -0
- package/templates/drive/app/assets/app_description.md +13 -0
- package/templates/drive/app/assets/icon.png +0 -0
- package/templates/drive/app/assets/system_instructions.md +17 -0
- package/templates/drive/app/kb/General/README.md +25 -0
- package/templates/drive/community/Apps/.gitkeep +4 -0
- package/templates/drive/community/community_assets/community_description.md +15 -0
- package/templates/drive/community/community_assets/icon.png +0 -0
- package/templates/drive_templates/README.md +104 -0
- package/templates/drive_templates/agent_app_template/assets/app_description.txt +13 -0
- package/templates/drive_templates/agent_app_template/assets/system_instructions.txt +17 -0
- package/templates/drive_templates/agent_app_template/kb/General/README.md +25 -0
- package/templates/drive_templates/agent_app_template/microservice/.gitkeep +10 -0
- package/templates/drive_templates/agent_app_template/site/.gitkeep +4 -0
- package/templates/drive_templates/community_template/Apps/.gitkeep +4 -0
- package/templates/drive_templates/community_template/community_assets/community_description.txt +15 -0
- package/templates/scaffolds/README.md +62 -0
- package/templates/scaffolds/microservice/Dockerfile +19 -0
- package/templates/scaffolds/microservice/SERVICE_README_sdk.md +399 -0
- package/templates/scaffolds/microservice/app.js +50 -0
- package/templates/scaffolds/microservice/app.yaml +8 -0
- package/templates/scaffolds/microservice/defaults-config.json +5 -0
- package/templates/scaffolds/microservice/dev-overrides.json.example +5 -0
- package/templates/scaffolds/microservice/manifest.json +49 -0
- package/templates/scaffolds/microservice/package-lock.json +2645 -0
- package/templates/scaffolds/microservice/package.json +29 -0
- package/templates/scaffolds/microservice/scripts/register.js +55 -0
- package/templates/scaffolds/microservice/services/apiFront.js +75 -0
- package/templates/scaffolds/microservice/services/commandHandlers/sampleCommands.js +57 -0
- package/templates/scaffolds/microservice/services/mcpClient.js +78 -0
- package/templates/scaffolds/microservice/services/utils.js +247 -0
- package/templates/scaffolds/microservice/setup-schema.json +18 -0
- package/templates/scaffolds/microservice/templates/SERVICE_README_TEMPLATE.md +143 -0
- package/templates/scaffolds/site/DeSciXAppSDK.js +62 -0
- package/templates/scaffolds/site/README.md +51 -0
- package/templates/scaffolds/site/app.js +22 -0
- package/templates/scaffolds/site/index.html +42 -0
- package/templates/scaffolds/site/styles.css +123 -0
- package/test-hydration.js +150 -0
- package/vendor/mcp/transports/http-sse-transport.js +196 -0
- package/vendor/mcp/transports/index.js +15 -0
- package/vendor/mcp/transports/stdio-transport.js +118 -0
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Workspace Utilities
|
|
3
|
+
*
|
|
4
|
+
* Helper functions for workspace mode detection and path resolution.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import path from 'path';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Detect workspace mode from workspace.json configuration
|
|
11
|
+
* @param {Object} workspace - Parsed workspace.json
|
|
12
|
+
* @returns {'single_app' | 'single_community' | 'multi_community'}
|
|
13
|
+
*/
|
|
14
|
+
export function detectWorkspaceMode(workspace) {
|
|
15
|
+
// Strict Mode Validation: Prioritize explicit mode
|
|
16
|
+
if (workspace.mode) {
|
|
17
|
+
return workspace.mode;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
// Infer from structure (fallback)
|
|
21
|
+
if (workspace.communities && Object.keys(workspace.communities).length > 0) {
|
|
22
|
+
const communityCount = Object.keys(workspace.communities).length;
|
|
23
|
+
if (communityCount > 1) {
|
|
24
|
+
return 'multi_community';
|
|
25
|
+
}
|
|
26
|
+
// Single community in communities object
|
|
27
|
+
const community = Object.values(workspace.communities)[0];
|
|
28
|
+
const appCount = Object.keys(community.apps || {}).length;
|
|
29
|
+
return appCount > 1 ? 'single_community' : 'single_app';
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// Legacy format: single community at root
|
|
33
|
+
if (workspace.community_id && workspace.app_id) {
|
|
34
|
+
return 'single_app';
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
if (workspace.community_id && workspace.apps) {
|
|
38
|
+
return Object.keys(workspace.apps).length > 1 ? 'single_community' : 'single_app';
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// Fallback for empty/initialized workspace using defaultContext
|
|
42
|
+
if (workspace.defaultContext && workspace.defaultContext.communityId && workspace.defaultContext.appId) {
|
|
43
|
+
return 'single_app';
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
throw new Error('Unable to determine workspace mode from configuration');
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Resolve local path to Drive path based on workspace mode
|
|
51
|
+
* @param {Object} workspace - Workspace configuration
|
|
52
|
+
* @param {string} localPath - Path relative to workspace root
|
|
53
|
+
* @returns {string} Path relative to user's base_folder_id
|
|
54
|
+
*/
|
|
55
|
+
export function resolveToDrivePath(workspace, localPath) {
|
|
56
|
+
const mode = detectWorkspaceMode(workspace);
|
|
57
|
+
|
|
58
|
+
// Normalize local path (remove leading ./)
|
|
59
|
+
const normalizedLocal = localPath.replace(/^\.\//, '');
|
|
60
|
+
|
|
61
|
+
switch (mode) {
|
|
62
|
+
case 'single_app':
|
|
63
|
+
// Workspace root = app folder
|
|
64
|
+
// Local: ./kb/General/file.md
|
|
65
|
+
// Drive: {community_id}/{app_id}/kb/General/file.md
|
|
66
|
+
const communityId = workspace.community_id || (workspace.defaultContext && workspace.defaultContext.communityId);
|
|
67
|
+
const appId = workspace.app_id || (workspace.defaultContext && workspace.defaultContext.appId);
|
|
68
|
+
|
|
69
|
+
if (!communityId || !appId) {
|
|
70
|
+
throw new Error('Missing community_id or app_id for single_app mode path resolution');
|
|
71
|
+
}
|
|
72
|
+
return `${communityId}/${appId}/${normalizedLocal}`;
|
|
73
|
+
|
|
74
|
+
case 'single_community':
|
|
75
|
+
// Workspace root = community folder
|
|
76
|
+
// Local: ./agent/kb/General/file.md
|
|
77
|
+
// Drive: {community_id}/agent/kb/General/file.md
|
|
78
|
+
const commId = workspace.community_id || (workspace.communities && Object.keys(workspace.communities)[0]);
|
|
79
|
+
if (!commId) {
|
|
80
|
+
throw new Error('Missing community_id for single_community mode path resolution');
|
|
81
|
+
}
|
|
82
|
+
return `${commId}/${normalizedLocal}`;
|
|
83
|
+
|
|
84
|
+
case 'multi_community':
|
|
85
|
+
// Workspace root = base folder
|
|
86
|
+
// Local: ./descix/agent/kb/General/file.md
|
|
87
|
+
// Drive: descix/agent/kb/General/file.md
|
|
88
|
+
return normalizedLocal;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Resolve Drive path to local path based on workspace mode
|
|
94
|
+
* @param {Object} workspace - Workspace configuration
|
|
95
|
+
* @param {string} drivePath - Path relative to user's base_folder_id
|
|
96
|
+
* @returns {string} Path relative to workspace root
|
|
97
|
+
*/
|
|
98
|
+
export function resolveToLocalPath(workspace, drivePath) {
|
|
99
|
+
const mode = detectWorkspaceMode(workspace);
|
|
100
|
+
|
|
101
|
+
switch (mode) {
|
|
102
|
+
case 'single_app':
|
|
103
|
+
// Remove community_id/app_id prefix
|
|
104
|
+
const communityId = workspace.community_id || (workspace.defaultContext && workspace.defaultContext.communityId);
|
|
105
|
+
const appId = workspace.app_id || (workspace.defaultContext && workspace.defaultContext.appId);
|
|
106
|
+
|
|
107
|
+
const appPrefix = `${communityId}/${appId}/`;
|
|
108
|
+
if (drivePath.startsWith(appPrefix)) {
|
|
109
|
+
return './' + drivePath.slice(appPrefix.length);
|
|
110
|
+
}
|
|
111
|
+
throw new Error(`Drive path '${drivePath}' implies app '${appId}', but workspace is configured for '${appId}'`);
|
|
112
|
+
|
|
113
|
+
case 'single_community':
|
|
114
|
+
// Remove community_id prefix
|
|
115
|
+
const commId = workspace.community_id || (workspace.communities && Object.keys(workspace.communities)[0]);
|
|
116
|
+
const commPrefix = `${commId}/`;
|
|
117
|
+
if (drivePath.startsWith(commPrefix)) {
|
|
118
|
+
return './' + drivePath.slice(commPrefix.length);
|
|
119
|
+
}
|
|
120
|
+
throw new Error(`Drive path '${drivePath}' implies community '${commId}', but workspace is configured for '${commId}'`);
|
|
121
|
+
|
|
122
|
+
case 'multi_community':
|
|
123
|
+
// No prefix to remove
|
|
124
|
+
return './' + drivePath;
|
|
125
|
+
}
|
|
126
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@descix/cli",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "DeSciX CLI and MCP Server - Unified command-line interface for DeSciX platform",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./bin/descix.js",
|
|
7
|
+
"bin": {
|
|
8
|
+
"descix": "./bin/descix.js",
|
|
9
|
+
"descix-mcp": "./bin/mcp-server.js"
|
|
10
|
+
},
|
|
11
|
+
"scripts": {
|
|
12
|
+
"test": "echo \"Error: no test specified\" && exit 1",
|
|
13
|
+
"pack": "npm pack"
|
|
14
|
+
},
|
|
15
|
+
"keywords": [
|
|
16
|
+
"descix",
|
|
17
|
+
"cli",
|
|
18
|
+
"mcp",
|
|
19
|
+
"rag",
|
|
20
|
+
"cursor",
|
|
21
|
+
"ai"
|
|
22
|
+
],
|
|
23
|
+
"author": "DeSciX",
|
|
24
|
+
"license": "@Daita_DeSci_Community_License_v1/Daita_DeSci_Community_License_v1.pdf",
|
|
25
|
+
"dependencies": {
|
|
26
|
+
"@descix/app-sdk": "^0.1.0",
|
|
27
|
+
"@descix/sdk": "^1.0.0",
|
|
28
|
+
"@modelcontextprotocol/sdk": "^1.25.1",
|
|
29
|
+
"axios": "^1.7.9",
|
|
30
|
+
"chalk": "^5.6.2",
|
|
31
|
+
"commander": "^14.0.1",
|
|
32
|
+
"googleapis": "^170.1.0",
|
|
33
|
+
"inquirer": "^12.1.0",
|
|
34
|
+
"ora": "^9.0.0",
|
|
35
|
+
"vite": "^6.2.0"
|
|
36
|
+
},
|
|
37
|
+
"bundledDependencies": ["@descix/app-sdk", "@descix/sdk"],
|
|
38
|
+
"engines": {
|
|
39
|
+
"node": ">=24.0.0"
|
|
40
|
+
}
|
|
41
|
+
}
|
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
# DeSciX App Development
|
|
2
|
+
|
|
3
|
+
<!-- BOOTSTRAP MODE: This file was auto-generated by DeSciX.
|
|
4
|
+
You (the AI agent) should update it as you learn more about the user's
|
|
5
|
+
project. Remove this comment block once you've customized the file. -->
|
|
6
|
+
|
|
7
|
+
## Your First Action
|
|
8
|
+
|
|
9
|
+
Call the `descix_doctor` MCP tool immediately. It returns your auth state,
|
|
10
|
+
workspace context, available tools, and any configuration issues. Use its
|
|
11
|
+
output to orient yourself before doing anything else.
|
|
12
|
+
|
|
13
|
+
## What is DeSciX?
|
|
14
|
+
|
|
15
|
+
DeSciX is a platform for building knowledge-powered applications. Think of
|
|
16
|
+
it as a virtual university where:
|
|
17
|
+
|
|
18
|
+
- **Communities** are departments — each has an on-chain identity and members
|
|
19
|
+
- **Apps** are anything: courses, textbooks, problem sets, simulations, services
|
|
20
|
+
- **Knowledge bases** are the source material — markdown docs vectorized for AI retrieval
|
|
21
|
+
- **You (the AI agent)** are the primary interface for building and navigating
|
|
22
|
+
|
|
23
|
+
Any community member can build apps, contribute knowledge, and use AI tools
|
|
24
|
+
to interact with the community's collective knowledge.
|
|
25
|
+
|
|
26
|
+
## Pre-Step 0: Check for Invite Config
|
|
27
|
+
|
|
28
|
+
Before scanning the repo, check if `.descix/app.json` exists.
|
|
29
|
+
|
|
30
|
+
If it does:
|
|
31
|
+
1. Read it — extract `app_id`, `community_id`, `agent_hint`, `kb_ready`, `has_repo`
|
|
32
|
+
2. If it contains `invite_token`, call `resolve_invite` with that token to get live context
|
|
33
|
+
2b. **Verify auth before demo:** Call `descix_doctor` first. If `auth.connected` is false,
|
|
34
|
+
tell the user: "Run `descix login` in the terminal — or click DeSciX: Connect in the VS Code
|
|
35
|
+
status bar." Wait for auth before proceeding to chat or resolve_invite.
|
|
36
|
+
3. **Read `agent_hint` carefully** — it was written by the app creator specifically for you.
|
|
37
|
+
It describes this user's skill level and goals. Let it override default checkpoints.
|
|
38
|
+
The hint can change your entire approach:
|
|
39
|
+
- "No coding background" → never ask about frameworks or deployment. Only narrate what you're doing.
|
|
40
|
+
- "Experienced DeSciX developer" → skip all setup explanations, go straight to the task.
|
|
41
|
+
- "Airdrop recipient, first time" → demonstrate value with 2-3 demo questions before explaining anything.
|
|
42
|
+
If the hint contradicts a checkpoint in this document, the hint wins.
|
|
43
|
+
4. If `kb_ready` is true, skip KB setup and demonstrate value immediately:
|
|
44
|
+
`descix chat -a <app_id> "What is this about?"` — show the user what the AI knows
|
|
45
|
+
5. If `kb_ready` is false, skip the chat demo — the KB is not populated yet.
|
|
46
|
+
Proceed to setup (`descix init`, `app init`, `update kb`), then demo afterward.
|
|
47
|
+
Frame it as: "Let's get this set up so you can start exploring."
|
|
48
|
+
6. If `has_repo` is true and no source code is present locally, offer `descix clone -a <app_id>`.
|
|
49
|
+
For non-technical users (infer from `agent_hint`): "Want to run this on your own machine?"
|
|
50
|
+
For developers: "I'll clone the source code so you can build on it."
|
|
51
|
+
7. If `app.json` contains `api_url`, use it as the backend target — skip Checkpoint 3 (environment).
|
|
52
|
+
8. After the demo and clone, check if `workspace.json` exists. If not, run standard setup
|
|
53
|
+
(`descix init`, `app init`). If it does, setup is already done — proceed to development.
|
|
54
|
+
9. If `descix_doctor` shows an existing workspace with a **different** `app_id` than the invite,
|
|
55
|
+
ask the user: "You have an existing workspace for [X]. Add the invited app, or switch context?"
|
|
56
|
+
|
|
57
|
+
**Important:** If `app.json` is present, Step 0's empty-repo detection does NOT mean "scaffold from scratch."
|
|
58
|
+
The project context comes from the invite, not the file structure.
|
|
59
|
+
|
|
60
|
+
## Step 0: Scan the Repo
|
|
61
|
+
|
|
62
|
+
Before asking the user any questions, scan the working directory:
|
|
63
|
+
- Check for existing content: `docs/`, `src/`, `README.md`, `package.json`
|
|
64
|
+
- Check for existing DeSciX structure: `kb/`, `site/`, `microservice/`, `.descix/`
|
|
65
|
+
- Check for existing frameworks: `vite.config.*`, `next.config.*`, `tsconfig.json`
|
|
66
|
+
|
|
67
|
+
Use what you find to tailor your questions:
|
|
68
|
+
- If docs exist: "I see markdown files in `docs/`. Want to use those as your knowledge base?"
|
|
69
|
+
- If a site exists: "You have a site in `src/`. Want me to configure it as a DeSciX app?"
|
|
70
|
+
- If KB already has content: skip the "create starter KB" question
|
|
71
|
+
- If the repo is empty: proceed with standard checkpoints
|
|
72
|
+
|
|
73
|
+
## Setup Workflow
|
|
74
|
+
|
|
75
|
+
If `descix_doctor` reports `setup_needed: true`, guide the user through these
|
|
76
|
+
checkpoints. **Ask the user at each step** — don't assume.
|
|
77
|
+
|
|
78
|
+
### Checkpoint 1: Objective
|
|
79
|
+
> "Do you want to explore existing apps, or build something new?"
|
|
80
|
+
|
|
81
|
+
### Checkpoint 2: Community & App Selection
|
|
82
|
+
Use `find_communities` and `list_apps_for_community` to show options, then ask:
|
|
83
|
+
> "Which community and app should this project target?"
|
|
84
|
+
|
|
85
|
+
### Checkpoint 3: Environment
|
|
86
|
+
> "Should this run against local dev backend (localhost:4000) or hosted API?"
|
|
87
|
+
|
|
88
|
+
### Canonical Setup Commands (run in terminal after checkpoints)
|
|
89
|
+
```bash
|
|
90
|
+
descix whoami # confirm identity
|
|
91
|
+
descix app list # see available apps
|
|
92
|
+
descix init -c <community> -a <app> -p . # create workspace.json
|
|
93
|
+
descix app init -a <app> -c <community> # register app on platform
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
### Checkpoint 4: Content Strategy
|
|
97
|
+
> "Should I create a starter KB doc now, or wait for your domain docs?"
|
|
98
|
+
|
|
99
|
+
### Checkpoint 5: Frontend Scope
|
|
100
|
+
> "Do you want plain HTML, or should I set up a framework (React, VitePress, etc.)?"
|
|
101
|
+
|
|
102
|
+
## Important: Use Explicit Flags
|
|
103
|
+
|
|
104
|
+
Until workspace context is verified working, **always use explicit flags**
|
|
105
|
+
for all CLI commands:
|
|
106
|
+
```bash
|
|
107
|
+
descix chat -c <community> -a <app> -q "..."
|
|
108
|
+
descix update kb -c <community> -a <app>
|
|
109
|
+
descix kb sync -c <community> -a <app> --kb General
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
Implicit defaults can silently target the wrong app. After setup, verify
|
|
113
|
+
with `descix chat -c <community> -a <app> -q "test"` before dropping flags.
|
|
114
|
+
|
|
115
|
+
## Success Criteria
|
|
116
|
+
|
|
117
|
+
After setup, verify all of these pass:
|
|
118
|
+
- [ ] App visible in `descix app list`
|
|
119
|
+
- [ ] `descix update kb -c <community> -a <app>` succeeds (KB sync)
|
|
120
|
+
- [ ] `descix chat -c <community> -a <app> -q "..."` returns response with source attribution
|
|
121
|
+
|
|
122
|
+
## Local Development
|
|
123
|
+
|
|
124
|
+
To see your app in a browser:
|
|
125
|
+
|
|
126
|
+
| Goal | Command |
|
|
127
|
+
|------|---------|
|
|
128
|
+
| Serve `site/` locally | `npx serve site/` or `python3 -m http.server -d site/` on any port |
|
|
129
|
+
| Register port with DeSciX | `descix site servelocal <port> -c <community> -a <app>` |
|
|
130
|
+
| Run full gateway (multi-app) | `descix serve` (reverse proxy on :5173) |
|
|
131
|
+
|
|
132
|
+
For single-app development, a static server is sufficient. The gateway is only
|
|
133
|
+
needed when running multiple apps or testing platform routing.
|
|
134
|
+
|
|
135
|
+
## Integrating Existing Content
|
|
136
|
+
|
|
137
|
+
If the repo already has content (an HTML page, a React app, an SDK with docs),
|
|
138
|
+
**do NOT copy files into `site/` or `kb/`**. Instead, integrate them in place.
|
|
139
|
+
|
|
140
|
+
### Site Integration
|
|
141
|
+
|
|
142
|
+
**If the project has an `index.html` or web app already:**
|
|
143
|
+
- Serve it directly — it IS the site. Don't duplicate into `site/`.
|
|
144
|
+
- To add DeSciX integration (auth, API access), include `DeSciXAppSDK.js`
|
|
145
|
+
(scaffolded by `descix app init`) in your HTML:
|
|
146
|
+
```html
|
|
147
|
+
<script src="DeSciXAppSDK.js"></script>
|
|
148
|
+
<script>
|
|
149
|
+
// window.DeSciX.call('ask_question_to_app', { user_input: '...' })
|
|
150
|
+
// window.DeSciX.AppData — user profile, community data
|
|
151
|
+
</script>
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
**For React/Vite apps**, wrap your root component in AppShell:
|
|
155
|
+
```jsx
|
|
156
|
+
import AppShell from '@descix/app-sdk/AppShell';
|
|
157
|
+
<AppShell appId="{{appId}}">
|
|
158
|
+
<YourApp />
|
|
159
|
+
</AppShell>
|
|
160
|
+
```
|
|
161
|
+
AppShell provides: Powch auth sidebar, session management, Web3 wallet, DeSciX API.
|
|
162
|
+
|
|
163
|
+
**For auth-only (no DeSciX UI chrome):**
|
|
164
|
+
```js
|
|
165
|
+
import { PowchClient } from '@descix/app-sdk/powch-client';
|
|
166
|
+
const powch = new PowchClient();
|
|
167
|
+
const user = await powch.auth();
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
### KB Integration
|
|
171
|
+
|
|
172
|
+
If docs already exist (`docs/`, `README.md`, SDK reference files):
|
|
173
|
+
- Copy markdown files to `kb/General/` for the sync pipeline
|
|
174
|
+
- Keep originals as the source of truth — sync from there
|
|
175
|
+
- Ask: "I see docs in `docs/`. Want me to use those as your knowledge base?"
|
|
176
|
+
|
|
177
|
+
### Decision Guide
|
|
178
|
+
|
|
179
|
+
| Existing Content | Site Strategy | KB Strategy |
|
|
180
|
+
|-----------------|---------------|-------------|
|
|
181
|
+
| HTML/JS app with `index.html` | Serve as-is, add DeSciXAppSDK.js | Use any `docs/` or `*.md` files |
|
|
182
|
+
| React/Vite app | Wrap root in `<AppShell>` | Use `docs/` or README |
|
|
183
|
+
| SDK package with docs + demo | Serve the SDK's demo page | Copy docs to `kb/General/` |
|
|
184
|
+
| Docs only (no frontend) | Skip or create minimal site | Docs ARE the KB |
|
|
185
|
+
| Empty repo | Scaffold from scratch | Create starter KB doc |
|
|
186
|
+
|
|
187
|
+
## App Structure
|
|
188
|
+
|
|
189
|
+
Every app has three parts:
|
|
190
|
+
- `site/` — Frontend (any framework: React, VitePress, vanilla HTML)
|
|
191
|
+
- `kb/General/` — Knowledge base source docs (markdown files)
|
|
192
|
+
- `microservice/` — Backend service (optional)
|
|
193
|
+
|
|
194
|
+
## App Context
|
|
195
|
+
|
|
196
|
+
- App ID: `{{appId}}`
|
|
197
|
+
- Community: `{{communityId}}`
|
|
198
|
+
- API: `{{apiUrl}}`
|
|
199
|
+
|
|
200
|
+
## Available MCP Tools
|
|
201
|
+
|
|
202
|
+
| Tool | Purpose |
|
|
203
|
+
|------|---------|
|
|
204
|
+
| `descix_doctor` | Startup diagnostic — call first |
|
|
205
|
+
| `ask_question_to_app` | RAG chat with any app's knowledge base |
|
|
206
|
+
| `query_knowledge_base` | Raw vector search (returns chunks) |
|
|
207
|
+
| `find_communities` | List communities on the platform |
|
|
208
|
+
| `list_apps_for_community` | List apps in a community |
|
|
209
|
+
| `tell_me_how` | Discover any platform capability by asking |
|
|
210
|
+
| `resolve_invite` | Exchange an invite token for app context + agent hint |
|
|
211
|
+
|
|
212
|
+
## Known CLI Quirks
|
|
213
|
+
|
|
214
|
+
- `descix status` may report "No workspace found" even when `.descix/workspace.json`
|
|
215
|
+
exists. This is a known bug — continue with explicit flags.
|
|
216
|
+
- `descix status` may suggest `descix setup` — that command doesn't exist. Use
|
|
217
|
+
`descix init -c <community> -a <app> -p .` instead.
|
|
218
|
+
|
|
219
|
+
## After Bootstrap
|
|
220
|
+
|
|
221
|
+
Once you understand the user's intent and have verified the success criteria,
|
|
222
|
+
rewrite this file to reflect the actual project. Replace this generic content with:
|
|
223
|
+
- Project-specific structure and conventions
|
|
224
|
+
- The user's chosen framework and patterns
|
|
225
|
+
- Relevant community/app context from `descix_doctor`
|
|
226
|
+
- Workflow shortcuts specific to their use case
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
# DeSciX App Development
|
|
2
|
+
|
|
3
|
+
<!-- BOOTSTRAP: Auto-generated. Update this file as you learn the project. -->
|
|
4
|
+
|
|
5
|
+
## First Action
|
|
6
|
+
|
|
7
|
+
Call `descix_doctor` MCP tool to check auth, workspace, and available tools.
|
|
8
|
+
|
|
9
|
+
## Platform
|
|
10
|
+
|
|
11
|
+
DeSciX is a virtual university for knowledge-powered apps. Communities are
|
|
12
|
+
departments, apps are courses/textbooks/services. You are the primary
|
|
13
|
+
interface — guide the user to explore, build, or discover.
|
|
14
|
+
|
|
15
|
+
## Pre-Step 0: Check for Invite Config
|
|
16
|
+
|
|
17
|
+
Before scanning the repo, check if `.descix/app.json` exists.
|
|
18
|
+
|
|
19
|
+
If it does:
|
|
20
|
+
1. Read it — extract `app_id`, `community_id`, `agent_hint`, `kb_ready`, `has_repo`
|
|
21
|
+
2. If it contains `invite_token`, call `resolve_invite` with that token to get live context
|
|
22
|
+
3. **Read `agent_hint` carefully** — it was written by the app creator specifically for you.
|
|
23
|
+
It describes this user's skill level and goals. Let it override default checkpoints.
|
|
24
|
+
For example, if the hint says "no coding background", do not ask technical questions.
|
|
25
|
+
4. If `kb_ready` is true, skip KB setup and demonstrate value immediately:
|
|
26
|
+
`descix chat -a <app_id> "What is this about?"` — show the user what the AI knows
|
|
27
|
+
5. If `kb_ready` is false, skip the chat demo — the KB is not populated yet.
|
|
28
|
+
Proceed to setup (`descix init`, `app init`, `update kb`), then demo afterward.
|
|
29
|
+
Frame it as: "Let's get this set up so you can start exploring."
|
|
30
|
+
6. If `has_repo` is true and no source code is present locally, offer `descix clone -a <app_id>`.
|
|
31
|
+
For non-technical users (infer from `agent_hint`): "Want to run this on your own machine?"
|
|
32
|
+
For developers: "I'll clone the source code so you can build on it."
|
|
33
|
+
7. If `app.json` contains `api_url`, use it as the backend target — skip Checkpoint 3 (environment).
|
|
34
|
+
8. After the demo and clone, check if `workspace.json` exists. If not, run standard setup
|
|
35
|
+
(`descix init`, `app init`). If it does, setup is already done — proceed to development.
|
|
36
|
+
9. If `descix_doctor` shows an existing workspace with a **different** `app_id` than the invite,
|
|
37
|
+
ask the user: "You have an existing workspace for [X]. Add the invited app, or switch context?"
|
|
38
|
+
|
|
39
|
+
**Important:** If `app.json` is present, Step 0's empty-repo detection does NOT mean "scaffold from scratch."
|
|
40
|
+
The project context comes from the invite, not the file structure.
|
|
41
|
+
|
|
42
|
+
## Step 0: Scan the Repo
|
|
43
|
+
|
|
44
|
+
Before asking questions, list the working directory and check for:
|
|
45
|
+
- Existing content: `docs/`, `src/`, `README.md`, `package.json`
|
|
46
|
+
- Existing DeSciX structure: `kb/`, `site/`, `microservice/`, `.descix/`
|
|
47
|
+
- Existing frameworks: `vite.config.*`, `next.config.*`, `tsconfig.json`
|
|
48
|
+
|
|
49
|
+
Tailor your questions based on what you find (e.g., offer to use existing docs
|
|
50
|
+
as KB, configure an existing site, skip starter content if KB is already populated).
|
|
51
|
+
|
|
52
|
+
## Setup Workflow (if doctor reports setup_needed)
|
|
53
|
+
|
|
54
|
+
Ask the user at each checkpoint — don't assume:
|
|
55
|
+
|
|
56
|
+
1. **Objective:** "Explore existing apps or build something new?"
|
|
57
|
+
2. **Community/App:** Use `find_communities` + `list_apps_for_community`, then ask which to target
|
|
58
|
+
3. **Environment:** "Local dev (localhost:4000) or hosted API?" (Skip if `app.json` has `api_url`)
|
|
59
|
+
|
|
60
|
+
Canonical setup commands:
|
|
61
|
+
```bash
|
|
62
|
+
descix whoami # confirm identity
|
|
63
|
+
descix app list # see available apps
|
|
64
|
+
descix init -c <community> -a <app> -p . # create workspace.json
|
|
65
|
+
descix app init -a <app> -c <community> # register app on platform
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
4. **Content strategy:** "Create starter KB now or wait for your docs?"
|
|
69
|
+
5. **Frontend scope:** "Plain HTML or a framework (React, VitePress)?"
|
|
70
|
+
|
|
71
|
+
## Important: Use Explicit Flags
|
|
72
|
+
|
|
73
|
+
Always use `-c <community> -a <app>` for all commands until verified:
|
|
74
|
+
```bash
|
|
75
|
+
descix chat -c <community> -a <app> -q "..."
|
|
76
|
+
descix update kb -c <community> -a <app>
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
## Success Criteria
|
|
80
|
+
|
|
81
|
+
- App visible in `descix app list`
|
|
82
|
+
- KB sync succeeds: `descix update kb -c <community> -a <app>`
|
|
83
|
+
- Chat returns response: `descix chat -c <community> -a <app> -q "test"`
|
|
84
|
+
|
|
85
|
+
## Local Development
|
|
86
|
+
|
|
87
|
+
| Goal | Command |
|
|
88
|
+
|------|---------|
|
|
89
|
+
| Serve `site/` locally | `npx serve site/` or `python3 -m http.server -d site/` on any port |
|
|
90
|
+
| Register port with DeSciX | `descix site servelocal <port> -c <community> -a <app>` |
|
|
91
|
+
| Run full gateway (multi-app) | `descix serve` (reverse proxy on :5173) |
|
|
92
|
+
|
|
93
|
+
Single-app dev: a static server is sufficient. Gateway is for multi-app or
|
|
94
|
+
platform routing tests.
|
|
95
|
+
|
|
96
|
+
## MCP Tools
|
|
97
|
+
|
|
98
|
+
- `descix_doctor` — Startup diagnostic (call first)
|
|
99
|
+
- `ask_question_to_app` — RAG chat with app_id `{{appId}}`
|
|
100
|
+
- `query_knowledge_base` — Vector search (raw chunks)
|
|
101
|
+
- `find_communities` — List communities
|
|
102
|
+
- `list_apps_for_community` — List apps in a community
|
|
103
|
+
- `tell_me_how` — Discover any platform capability (use scope "discovery" if "entitlements" is empty)
|
|
104
|
+
- `resolve_invite` — Exchange an invite token for app context + agent hint
|
|
105
|
+
|
|
106
|
+
## Integrating Existing Content
|
|
107
|
+
|
|
108
|
+
**NEVER copy existing project files into `site/` or `kb/`.** Integrate in place:
|
|
109
|
+
|
|
110
|
+
- **Existing HTML/JS app:** Serve as-is. Add `DeSciXAppSDK.js` for DeSciX integration.
|
|
111
|
+
- **React/Vite app:** Wrap root in `<AppShell appId="{{appId}}">` from `@descix/app-sdk/AppShell`.
|
|
112
|
+
- **Auth only (no DeSciX UI):** Use `PowchClient` from `@descix/app-sdk/powch-client`.
|
|
113
|
+
- **Existing docs:** Copy `docs/*.md` to `kb/General/` for sync. Keep originals as source of truth.
|
|
114
|
+
- **Empty repo:** Scaffold from scratch.
|
|
115
|
+
|
|
116
|
+
## App Structure
|
|
117
|
+
|
|
118
|
+
- `site/` — Frontend (any framework)
|
|
119
|
+
- `kb/General/` — Knowledge base source docs (markdown)
|
|
120
|
+
- `microservice/` — Backend service (optional)
|
|
121
|
+
|
|
122
|
+
## Context
|
|
123
|
+
|
|
124
|
+
- App ID: `{{appId}}` | Community: `{{communityId}}` | API: `{{apiUrl}}`
|
|
125
|
+
|
|
126
|
+
## Known CLI Quirks
|
|
127
|
+
|
|
128
|
+
- `descix status` may show "No workspace found" even when config exists — use explicit flags
|
|
129
|
+
- `descix status` may suggest `descix setup` — use `descix init` instead
|
|
130
|
+
|
|
131
|
+
## After Bootstrap
|
|
132
|
+
|
|
133
|
+
Rewrite this file with project-specific context once you understand the user's intent.
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
# DeSciX App Development
|
|
2
|
+
|
|
3
|
+
<!-- BOOTSTRAP: Auto-generated. Update this file as you learn the project. -->
|
|
4
|
+
|
|
5
|
+
## First Action
|
|
6
|
+
|
|
7
|
+
Call `descix_doctor` MCP tool to check auth, workspace, and available tools.
|
|
8
|
+
|
|
9
|
+
## Platform
|
|
10
|
+
|
|
11
|
+
DeSciX is a virtual university for knowledge-powered apps. Communities are
|
|
12
|
+
departments, apps are courses/textbooks/services. You are the primary
|
|
13
|
+
interface — guide the user to explore, build, or discover.
|
|
14
|
+
|
|
15
|
+
## Pre-Step 0: Check for Invite Config
|
|
16
|
+
|
|
17
|
+
Before scanning the repo, check if `.descix/app.json` exists.
|
|
18
|
+
|
|
19
|
+
If it does:
|
|
20
|
+
1. Read it — extract `app_id`, `community_id`, `agent_hint`, `kb_ready`, `has_repo`
|
|
21
|
+
2. If it contains `invite_token`, call `resolve_invite` with that token to get live context
|
|
22
|
+
3. **Read `agent_hint` carefully** — it was written by the app creator specifically for you.
|
|
23
|
+
It describes this user's skill level and goals. Let it override default checkpoints.
|
|
24
|
+
For example, if the hint says "no coding background", do not ask technical questions.
|
|
25
|
+
4. If `kb_ready` is true, skip KB setup and demonstrate value immediately:
|
|
26
|
+
`descix chat -a <app_id> "What is this about?"` — show the user what the AI knows
|
|
27
|
+
5. If `kb_ready` is false, skip the chat demo — the KB is not populated yet.
|
|
28
|
+
Proceed to setup (`descix init`, `app init`, `update kb`), then demo afterward.
|
|
29
|
+
Frame it as: "Let's get this set up so you can start exploring."
|
|
30
|
+
6. If `has_repo` is true and no source code is present locally, offer `descix clone -a <app_id>`.
|
|
31
|
+
For non-technical users (infer from `agent_hint`): "Want to run this on your own machine?"
|
|
32
|
+
For developers: "I'll clone the source code so you can build on it."
|
|
33
|
+
7. If `app.json` contains `api_url`, use it as the backend target — skip Checkpoint 3 (environment).
|
|
34
|
+
8. After the demo and clone, check if `workspace.json` exists. If not, run standard setup
|
|
35
|
+
(`descix init`, `app init`). If it does, setup is already done — proceed to development.
|
|
36
|
+
9. If `descix_doctor` shows an existing workspace with a **different** `app_id` than the invite,
|
|
37
|
+
ask the user: "You have an existing workspace for [X]. Add the invited app, or switch context?"
|
|
38
|
+
|
|
39
|
+
**Important:** If `app.json` is present, Step 0's empty-repo detection does NOT mean "scaffold from scratch."
|
|
40
|
+
The project context comes from the invite, not the file structure.
|
|
41
|
+
|
|
42
|
+
## Step 0: Scan the Repo
|
|
43
|
+
|
|
44
|
+
Before asking questions, list the working directory and check for:
|
|
45
|
+
- Existing content: `docs/`, `src/`, `README.md`, `package.json`
|
|
46
|
+
- Existing DeSciX structure: `kb/`, `site/`, `microservice/`, `.descix/`
|
|
47
|
+
- Existing frameworks: `vite.config.*`, `next.config.*`, `tsconfig.json`
|
|
48
|
+
|
|
49
|
+
Tailor your questions based on what you find (e.g., offer to use existing docs
|
|
50
|
+
as KB, configure an existing site, skip starter content if KB is already populated).
|
|
51
|
+
|
|
52
|
+
## Setup Workflow (if doctor reports setup_needed)
|
|
53
|
+
|
|
54
|
+
Ask the user at each checkpoint — don't assume:
|
|
55
|
+
|
|
56
|
+
1. **Objective:** "Explore existing apps or build something new?"
|
|
57
|
+
2. **Community/App:** Use `find_communities` + `list_apps_for_community`, then ask which to target
|
|
58
|
+
3. **Environment:** "Local dev (localhost:4000) or hosted API?" (Skip if `app.json` has `api_url`)
|
|
59
|
+
|
|
60
|
+
Canonical setup commands:
|
|
61
|
+
```bash
|
|
62
|
+
descix whoami # confirm identity
|
|
63
|
+
descix app list # see available apps
|
|
64
|
+
descix init -c <community> -a <app> -p . # create workspace.json
|
|
65
|
+
descix app init -a <app> -c <community> # register app on platform
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
4. **Content strategy:** "Create starter KB now or wait for your docs?"
|
|
69
|
+
5. **Frontend scope:** "Plain HTML or a framework (React, VitePress)?"
|
|
70
|
+
|
|
71
|
+
## Important: Use Explicit Flags
|
|
72
|
+
|
|
73
|
+
Always use `-c <community> -a <app>` for all commands until verified:
|
|
74
|
+
```bash
|
|
75
|
+
descix chat -c <community> -a <app> -q "..."
|
|
76
|
+
descix update kb -c <community> -a <app>
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
## Success Criteria
|
|
80
|
+
|
|
81
|
+
- App visible in `descix app list`
|
|
82
|
+
- KB sync succeeds: `descix update kb -c <community> -a <app>`
|
|
83
|
+
- Chat returns response: `descix chat -c <community> -a <app> -q "test"`
|
|
84
|
+
|
|
85
|
+
## Local Development
|
|
86
|
+
|
|
87
|
+
| Goal | Command |
|
|
88
|
+
|------|---------|
|
|
89
|
+
| Serve `site/` locally | `npx serve site/` or `python3 -m http.server -d site/` on any port |
|
|
90
|
+
| Register port with DeSciX | `descix site servelocal <port> -c <community> -a <app>` |
|
|
91
|
+
| Run full gateway (multi-app) | `descix serve` (reverse proxy on :5173) |
|
|
92
|
+
|
|
93
|
+
Single-app dev: a static server is sufficient. Gateway is for multi-app or
|
|
94
|
+
platform routing tests.
|
|
95
|
+
|
|
96
|
+
## MCP Tools
|
|
97
|
+
|
|
98
|
+
- `descix_doctor` — Startup diagnostic (call first)
|
|
99
|
+
- `ask_question_to_app` — RAG chat with app_id `{{appId}}`
|
|
100
|
+
- `query_knowledge_base` — Vector search (raw chunks)
|
|
101
|
+
- `find_communities` — List communities
|
|
102
|
+
- `list_apps_for_community` — List apps in a community
|
|
103
|
+
- `tell_me_how` — Discover any platform capability (use scope "discovery" if "entitlements" is empty)
|
|
104
|
+
- `resolve_invite` — Exchange an invite token for app context + agent hint
|
|
105
|
+
|
|
106
|
+
## Integrating Existing Content
|
|
107
|
+
|
|
108
|
+
**NEVER copy existing project files into `site/` or `kb/`.** Integrate in place:
|
|
109
|
+
|
|
110
|
+
- **Existing HTML/JS app:** Serve as-is. Add `DeSciXAppSDK.js` for DeSciX integration.
|
|
111
|
+
- **React/Vite app:** Wrap root in `<AppShell appId="{{appId}}">` from `@descix/app-sdk/AppShell`.
|
|
112
|
+
- **Auth only (no DeSciX UI):** Use `PowchClient` from `@descix/app-sdk/powch-client`.
|
|
113
|
+
- **Existing docs:** Copy `docs/*.md` to `kb/General/` for sync. Keep originals as source of truth.
|
|
114
|
+
- **Empty repo:** Scaffold from scratch.
|
|
115
|
+
|
|
116
|
+
## App Structure
|
|
117
|
+
|
|
118
|
+
- `site/` — Frontend (any framework)
|
|
119
|
+
- `kb/General/` — Knowledge base source docs (markdown)
|
|
120
|
+
- `microservice/` — Backend service (optional)
|
|
121
|
+
|
|
122
|
+
## Context
|
|
123
|
+
|
|
124
|
+
- App ID: `{{appId}}` | Community: `{{communityId}}` | API: `{{apiUrl}}`
|
|
125
|
+
|
|
126
|
+
## Known CLI Quirks
|
|
127
|
+
|
|
128
|
+
- `descix status` may show "No workspace found" even when config exists — use explicit flags
|
|
129
|
+
- `descix status` may suggest `descix setup` — use `descix init` instead
|
|
130
|
+
|
|
131
|
+
## After Bootstrap
|
|
132
|
+
|
|
133
|
+
Rewrite this file with project-specific context once you understand the user's intent.
|