@descix/cli 1.0.7 → 1.0.9
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 +1 -1
- package/agent-assets/guides/README.md +1 -1
- package/agent-assets/guides/dynamic-site-pattern.md +7 -16
- package/agent-assets/instructions/app-asset-validation.md +1 -1
- package/agent-assets/reference/architecture.md +20 -25
- package/agent-assets/reference/local-dev.md +1 -6
- package/agent-assets/reference/mcp-integration.md +15 -9
- package/agent-assets/reference/platform-api-consumer.md +11 -5
- package/agent-assets/reference/workspace-config.md +2 -2
- package/bin/descix.js +211 -688
- package/lib/command-visibility.js +213 -0
- package/lib/commands/corpus.js +2 -5
- package/lib/commands/kb.js +2 -2
- package/lib/commands/media-upload.js +176 -0
- package/lib/commands/retired-kb-sync.js +5 -27
- package/lib/commands/status.js +0 -9
- package/lib/output.js +31 -0
- package/lib/sdk-assets.js +28 -0
- package/lib/verb-invokes.generated.json +233 -0
- package/lib/workspace-config.js +9 -44
- package/package.json +6 -2
- package/templates/agent-claude.md +1 -3
- package/templates/agent-cline.md +1 -2
- package/templates/agent-copilot.md +1 -2
- package/templates/agent-cursor.md +1 -2
- package/templates/scaffolds/microservice/SERVICE_README_sdk.md +1 -1
- package/templates/scaffolds/microservice/templates/SERVICE_README_TEMPLATE.md +2 -3
- package/agent-assets/rules/descix_mcp.template.mdc +0 -243
- package/lib/commands/briefer/errors.js +0 -88
- package/lib/commands/briefer/index.js +0 -322
- package/lib/commands/briefer/sources/canonical-sources.js +0 -129
- package/lib/commands/briefer/sources/entitlements.js +0 -220
- package/lib/commands/briefer/sources/environments.js +0 -205
- package/lib/commands/briefer/sources/identifiers.js +0 -214
- package/lib/commands/briefer/sources/microservice-deploy.js +0 -267
- package/lib/commands/briefer/sources/routing.js +0 -275
- package/lib/commands/briefer/sources/what-is-not.js +0 -223
- package/lib/commands/briefer/stitcher.js +0 -134
- package/lib/commands/briefer/util/source-reader.js +0 -502
- package/lib/commands/mcp.js +0 -273
- package/lib/commands/update.js +0 -581
- package/lib/wizard/setup.js +0 -585
- package/templates/descix_mcp.mdc +0 -122
package/lib/commands/mcp.js
DELETED
|
@@ -1,273 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* MCP Commands
|
|
3
|
-
*
|
|
4
|
-
* MCP server setup and configuration commands
|
|
5
|
-
* All operations use HTTP API client - no service imports
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
import chalk from 'chalk';
|
|
9
|
-
import ora from 'ora';
|
|
10
|
-
import { DeSciXApiClient } from '../api-client.js';
|
|
11
|
-
import { requireAuth } from '../auth-guard.js';
|
|
12
|
-
import * as fs from 'fs/promises';
|
|
13
|
-
import * as path from 'path';
|
|
14
|
-
import { fileURLToPath } from 'url';
|
|
15
|
-
import { dirname } from 'path';
|
|
16
|
-
|
|
17
|
-
const __filename = fileURLToPath(import.meta.url);
|
|
18
|
-
const __dirname = dirname(__filename);
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* Load workspace config from JSON file
|
|
22
|
-
*/
|
|
23
|
-
async function loadWorkspaceConfig(workspaceRoot = process.cwd()) {
|
|
24
|
-
const configPath = path.join(workspaceRoot, '.descix', 'workspace.json');
|
|
25
|
-
try {
|
|
26
|
-
const data = await fs.readFile(configPath, 'utf-8');
|
|
27
|
-
return JSON.parse(data);
|
|
28
|
-
} catch (error) {
|
|
29
|
-
// Return default config if file doesn't exist
|
|
30
|
-
return {
|
|
31
|
-
primaryCommunity: 'daita',
|
|
32
|
-
directoryMappings: {},
|
|
33
|
-
additionalContexts: [],
|
|
34
|
-
defaultContext: {
|
|
35
|
-
communityId: 'daita',
|
|
36
|
-
appId: 'daita',
|
|
37
|
-
kbId: 'General'
|
|
38
|
-
}
|
|
39
|
-
};
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* Deploy descix_mcp.mdc rules file to .cursor/rules/
|
|
45
|
-
*/
|
|
46
|
-
async function deployRulesFile(workspaceRoot = process.cwd()) {
|
|
47
|
-
const rulesDir = path.join(workspaceRoot, '.cursor', 'rules');
|
|
48
|
-
await fs.mkdir(rulesDir, { recursive: true });
|
|
49
|
-
|
|
50
|
-
const templatePath = path.join(__dirname, '../../templates/descix_mcp.mdc');
|
|
51
|
-
const rulesPath = path.join(rulesDir, 'descix_mcp.mdc');
|
|
52
|
-
|
|
53
|
-
try {
|
|
54
|
-
// Check if template exists
|
|
55
|
-
await fs.access(templatePath);
|
|
56
|
-
|
|
57
|
-
// Copy template to rules directory
|
|
58
|
-
const templateContent = await fs.readFile(templatePath, 'utf-8');
|
|
59
|
-
|
|
60
|
-
// Check if rules file already exists
|
|
61
|
-
let existingContent = '';
|
|
62
|
-
try {
|
|
63
|
-
existingContent = await fs.readFile(rulesPath, 'utf-8');
|
|
64
|
-
} catch {
|
|
65
|
-
// File doesn't exist, that's fine
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
// Only write if content is different (avoid unnecessary writes)
|
|
69
|
-
if (existingContent !== templateContent) {
|
|
70
|
-
await fs.writeFile(rulesPath, templateContent, 'utf-8');
|
|
71
|
-
return true; // File was deployed
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
return false; // File already exists with same content
|
|
75
|
-
} catch (error) {
|
|
76
|
-
// Template might not exist in development, that's okay
|
|
77
|
-
console.error(chalk.yellow(`Warning: Could not deploy rules file: ${error.message}`));
|
|
78
|
-
return false;
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
/**
|
|
83
|
-
* Initialize MCP server for workspace
|
|
84
|
-
*/
|
|
85
|
-
export async function init() {
|
|
86
|
-
const apiClient = new DeSciXApiClient();
|
|
87
|
-
await requireAuth(apiClient);
|
|
88
|
-
|
|
89
|
-
console.log(chalk.cyan('\n🚀 DeSciX MCP Workspace Setup\n'));
|
|
90
|
-
|
|
91
|
-
const spinner = ora('Initializing...').start();
|
|
92
|
-
|
|
93
|
-
try {
|
|
94
|
-
spinner.text = 'Loading communities...';
|
|
95
|
-
|
|
96
|
-
// Query communities via HTTP
|
|
97
|
-
const response = await apiClient.invoke('find_communities', {}, { allowGuest: false });
|
|
98
|
-
const result = response.message || response;
|
|
99
|
-
const communities = result.communities || [];
|
|
100
|
-
spinner.succeed(`Found ${communities.length} communities`);
|
|
101
|
-
|
|
102
|
-
console.log(chalk.cyan('\nAvailable communities:'));
|
|
103
|
-
communities.forEach((c, idx) => {
|
|
104
|
-
console.log(chalk.gray(` ${idx + 1}. ${c.community_name} (${c.community_id})`));
|
|
105
|
-
});
|
|
106
|
-
|
|
107
|
-
// Use default community for now (can be enhanced with prompts)
|
|
108
|
-
const primaryCommunity = 'daita';
|
|
109
|
-
|
|
110
|
-
// Generate .descix/workspace.json
|
|
111
|
-
const workspaceRoot = process.cwd();
|
|
112
|
-
const config = {
|
|
113
|
-
primaryCommunity,
|
|
114
|
-
directoryMappings: {},
|
|
115
|
-
additionalContexts: [],
|
|
116
|
-
defaultContext: {
|
|
117
|
-
communityId: primaryCommunity,
|
|
118
|
-
appId: 'docs',
|
|
119
|
-
kbId: 'sdk'
|
|
120
|
-
}
|
|
121
|
-
};
|
|
122
|
-
|
|
123
|
-
spinner.start('Creating configuration files...');
|
|
124
|
-
|
|
125
|
-
const descixDir = path.join(workspaceRoot, '.descix');
|
|
126
|
-
await fs.mkdir(descixDir, { recursive: true });
|
|
127
|
-
const configPath = path.join(descixDir, 'workspace.json');
|
|
128
|
-
await fs.writeFile(configPath, JSON.stringify(config, null, 2));
|
|
129
|
-
console.log(chalk.green('✅ Created .descix/workspace.json'));
|
|
130
|
-
|
|
131
|
-
// Create .cursor/mcp.json
|
|
132
|
-
const cursorDir = path.join(workspaceRoot, '.cursor');
|
|
133
|
-
await fs.mkdir(cursorDir, { recursive: true });
|
|
134
|
-
|
|
135
|
-
const cursorConfig = {
|
|
136
|
-
mcpServers: {
|
|
137
|
-
'descix-rag': {
|
|
138
|
-
command: 'node',
|
|
139
|
-
args: ['node_modules/@descix/cli/bin/mcp-server.js'],
|
|
140
|
-
cwd: '${workspaceFolder}'
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
};
|
|
144
|
-
|
|
145
|
-
const cursorConfigPath = path.join(cursorDir, 'mcp.json');
|
|
146
|
-
await fs.writeFile(cursorConfigPath, JSON.stringify(cursorConfig, null, 2));
|
|
147
|
-
console.log(chalk.green('✅ Created .cursor/mcp.json'));
|
|
148
|
-
|
|
149
|
-
// Deploy rules file
|
|
150
|
-
spinner.text = 'Deploying agent rules file...';
|
|
151
|
-
const rulesDeployed = await deployRulesFile(workspaceRoot);
|
|
152
|
-
if (rulesDeployed) {
|
|
153
|
-
console.log(chalk.green('✅ Deployed .cursor/rules/descix_mcp.mdc'));
|
|
154
|
-
} else {
|
|
155
|
-
console.log(chalk.gray(' Rules file already exists'));
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
spinner.succeed('Configuration complete!');
|
|
159
|
-
|
|
160
|
-
console.log(chalk.cyan('\n📋 Next Steps:\n'));
|
|
161
|
-
console.log(chalk.white('1. Restart Cursor (Cmd/Ctrl + Shift + P → "Reload Window")\n'));
|
|
162
|
-
console.log(chalk.white('2. MCP will automatically use your credentials!\n'));
|
|
163
|
-
console.log(chalk.gray('Test with: descix mcp test\n'));
|
|
164
|
-
|
|
165
|
-
} catch (error) {
|
|
166
|
-
spinner.fail('Setup failed');
|
|
167
|
-
console.error(chalk.red(error.message));
|
|
168
|
-
throw error;
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
/**
|
|
173
|
-
* Test MCP server via HTTP
|
|
174
|
-
*/
|
|
175
|
-
export async function test(options = {}) {
|
|
176
|
-
const apiClient = new DeSciXApiClient();
|
|
177
|
-
await requireAuth(apiClient);
|
|
178
|
-
|
|
179
|
-
const spinner = ora('Testing MCP server...').start();
|
|
180
|
-
|
|
181
|
-
try {
|
|
182
|
-
const config = await loadWorkspaceConfig(process.cwd());
|
|
183
|
-
|
|
184
|
-
spinner.text = `Querying ${config.defaultContext.communityId}/${config.defaultContext.appId}/${config.defaultContext.kbId}...`;
|
|
185
|
-
|
|
186
|
-
// Get RAG status via HTTP
|
|
187
|
-
const statusResponse = await apiClient.invoke('get_kb_rag_status', {
|
|
188
|
-
app_id: config.defaultContext.appId,
|
|
189
|
-
kb_id: config.defaultContext.kbId
|
|
190
|
-
}, { allowGuest: false });
|
|
191
|
-
|
|
192
|
-
const status = statusResponse.message || statusResponse;
|
|
193
|
-
|
|
194
|
-
if (!status.enabled) {
|
|
195
|
-
spinner.warn(chalk.yellow('RAG not enabled for this knowledge base'));
|
|
196
|
-
console.log(chalk.gray('Enable RAG with: descix kb corpus sync -c ' + config.defaultContext.communityId + ' -a ' + config.defaultContext.appId + ' -k ' + config.defaultContext.kbId));
|
|
197
|
-
throw new Error('RAG not enabled');
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
const query = options.query || 'What is this knowledge base about?';
|
|
201
|
-
const queryResponse = await apiClient.invoke('query_knowledge_base', {
|
|
202
|
-
app_id: config.defaultContext.appId,
|
|
203
|
-
kb_id: config.defaultContext.kbId,
|
|
204
|
-
query: query,
|
|
205
|
-
limit: 3
|
|
206
|
-
}, { allowGuest: false });
|
|
207
|
-
|
|
208
|
-
const result = queryResponse.message?.results || queryResponse.results || [];
|
|
209
|
-
|
|
210
|
-
spinner.succeed(chalk.green('MCP server working!'));
|
|
211
|
-
console.log(chalk.cyan(`\nQuery: "${query}"\n`));
|
|
212
|
-
console.log(chalk.white(`Found ${result.length} results\n`));
|
|
213
|
-
|
|
214
|
-
result.forEach((r, idx) => {
|
|
215
|
-
console.log(chalk.yellow(`${idx + 1}. ${r.fileName || r.file_path} (${((r.similarity || 0) * 100).toFixed(1)}% match)`));
|
|
216
|
-
console.log(chalk.gray(` ${(r.content || '').substring(0, 100)}...`));
|
|
217
|
-
console.log();
|
|
218
|
-
});
|
|
219
|
-
|
|
220
|
-
} catch (error) {
|
|
221
|
-
spinner.fail('Test failed');
|
|
222
|
-
console.error(chalk.red(error.message));
|
|
223
|
-
throw error;
|
|
224
|
-
}
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
/**
|
|
228
|
-
* Show MCP configuration
|
|
229
|
-
*/
|
|
230
|
-
export async function config() {
|
|
231
|
-
try {
|
|
232
|
-
const config = await loadWorkspaceConfig(process.cwd());
|
|
233
|
-
console.log(chalk.cyan('\nWorkspace Configuration:\n'));
|
|
234
|
-
console.log(JSON.stringify({
|
|
235
|
-
primaryCommunity: config.primaryCommunity,
|
|
236
|
-
directoryMappings: config.directoryMappings,
|
|
237
|
-
additionalContexts: config.additionalContexts,
|
|
238
|
-
defaultContext: config.defaultContext
|
|
239
|
-
}, null, 2));
|
|
240
|
-
console.log();
|
|
241
|
-
} catch (error) {
|
|
242
|
-
console.error(chalk.red('Error loading config:', error.message));
|
|
243
|
-
throw error;
|
|
244
|
-
}
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
/**
|
|
248
|
-
* Quickstart - one-command setup
|
|
249
|
-
*/
|
|
250
|
-
export async function quickstart(options = {}) {
|
|
251
|
-
const apiClient = new DeSciXApiClient();
|
|
252
|
-
|
|
253
|
-
console.log(chalk.cyan('\n🚀 DeSciX MCP Quick Start\n'));
|
|
254
|
-
|
|
255
|
-
// Check if authenticated
|
|
256
|
-
try {
|
|
257
|
-
await requireAuth(apiClient);
|
|
258
|
-
} catch (error) {
|
|
259
|
-
console.log(chalk.yellow('⚠️ Authentication required first.\n'));
|
|
260
|
-
console.log(chalk.white('Run: descix login\n'));
|
|
261
|
-
throw new Error('Authentication required');
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
// Run setup wizard
|
|
265
|
-
const { runSetupWizard } = await import('../wizard/setup.js');
|
|
266
|
-
await runSetupWizard();
|
|
267
|
-
|
|
268
|
-
// Deploy rules file after wizard completes
|
|
269
|
-
const workspaceRoot = process.cwd();
|
|
270
|
-
await deployRulesFile(workspaceRoot);
|
|
271
|
-
console.log(chalk.green('✅ Deployed .cursor/rules/descix_mcp.mdc'));
|
|
272
|
-
}
|
|
273
|
-
|