@codapult/cli 0.11.0 → 0.12.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/dist/commands/setup.js +78 -14
- package/dist/mcp/resources.js +1 -1
- package/dist/mcp/tools/project.js +1 -1
- package/package.json +1 -1
package/dist/commands/setup.js
CHANGED
|
@@ -11,7 +11,7 @@ async function selectPrompt(iface, question, options) {
|
|
|
11
11
|
const idx = parseInt(answer, 10) - 1;
|
|
12
12
|
return options[Math.max(0, Math.min(idx, options.length - 1))];
|
|
13
13
|
}
|
|
14
|
-
function
|
|
14
|
+
function emptyLine() {
|
|
15
15
|
console.log();
|
|
16
16
|
return true;
|
|
17
17
|
}
|
|
@@ -167,7 +167,12 @@ const MODULE_REMOVALS = [
|
|
|
167
167
|
},
|
|
168
168
|
{
|
|
169
169
|
key: 'enableAI',
|
|
170
|
-
paths: [
|
|
170
|
+
paths: [
|
|
171
|
+
`${APP}/(dashboard)/dashboard/ai-chat`,
|
|
172
|
+
'src/app/api/chat',
|
|
173
|
+
'src/components/ai',
|
|
174
|
+
'src/lib/ai',
|
|
175
|
+
],
|
|
171
176
|
label: 'AI Chat',
|
|
172
177
|
},
|
|
173
178
|
{
|
|
@@ -181,7 +186,9 @@ const MODULE_REMOVALS = [
|
|
|
181
186
|
'src/lib/rss.test.ts',
|
|
182
187
|
'content/blog',
|
|
183
188
|
'src/app/rss.xml',
|
|
184
|
-
'src/app/
|
|
189
|
+
'src/app/(marketing)/rss.xml',
|
|
190
|
+
`${APP}/(marketing)/rss.xml`,
|
|
191
|
+
`${APP}/rss.xml`,
|
|
185
192
|
],
|
|
186
193
|
label: 'Blog',
|
|
187
194
|
},
|
|
@@ -247,6 +254,7 @@ const MODULE_REMOVALS = [
|
|
|
247
254
|
`${APP}/(marketing)/docs`,
|
|
248
255
|
'src/lib/docs',
|
|
249
256
|
'src/components/docs/HelpDocSearch.tsx',
|
|
257
|
+
'src/components/seo/DocArticleJsonLd.tsx',
|
|
250
258
|
'content/docs',
|
|
251
259
|
],
|
|
252
260
|
label: 'Documentation',
|
|
@@ -294,6 +302,7 @@ const MODULE_REMOVALS = [
|
|
|
294
302
|
paths: [
|
|
295
303
|
`${APP}/(dashboard)/dashboard/connect`,
|
|
296
304
|
'src/lib/payments/connect.ts',
|
|
305
|
+
'src/lib/payments/connect.test.ts',
|
|
297
306
|
'src/app/api/connect',
|
|
298
307
|
'src/components/dashboard/ConnectDashboard.tsx',
|
|
299
308
|
],
|
|
@@ -360,6 +369,7 @@ const MODULE_REMOVALS = [
|
|
|
360
369
|
key: 'enableRAG',
|
|
361
370
|
paths: [
|
|
362
371
|
'src/lib/ai/chunker.ts',
|
|
372
|
+
'src/lib/ai/chunker.test.ts',
|
|
363
373
|
'src/lib/ai/embeddings.ts',
|
|
364
374
|
'src/lib/ai/vector-store.ts',
|
|
365
375
|
'src/lib/ai/rag.ts',
|
|
@@ -425,11 +435,11 @@ const MODULE_REMOVALS = [
|
|
|
425
435
|
paths: [
|
|
426
436
|
`${APP}/(marketing)/plugins`,
|
|
427
437
|
`${APP}/(dashboard)/dashboard/plugins`,
|
|
428
|
-
'src/
|
|
429
|
-
'src/lib/plugins',
|
|
438
|
+
'src/lib/plugins/marketplace.ts',
|
|
430
439
|
'src/components/marketing/PluginsShowcase.tsx',
|
|
431
440
|
'src/components/marketing/PluginDetail.tsx',
|
|
432
441
|
'src/components/dashboard/PluginMarketplace.tsx',
|
|
442
|
+
'plugins/example-analytics',
|
|
433
443
|
],
|
|
434
444
|
label: 'Plugin Marketplace',
|
|
435
445
|
},
|
|
@@ -467,14 +477,21 @@ const FEATURE_ENV_VARS = {
|
|
|
467
477
|
enablePlugins: 'ENABLE_PLUGINS',
|
|
468
478
|
};
|
|
469
479
|
// codapult:prune:start {key}
|
|
480
|
+
// codapult:prune:replace
|
|
470
481
|
// codapult:prune:end {key}
|
|
471
482
|
const PRUNE_MARKER_FILES = [
|
|
472
483
|
'src/app/sitemap.ts',
|
|
473
484
|
'src/app/sitemap.test.ts',
|
|
485
|
+
'src/app/(marketing)/llms.txt/route.ts',
|
|
486
|
+
'src/components/marketing/Footer.tsx',
|
|
474
487
|
'src/lib/auth/index.ts',
|
|
475
488
|
'src/lib/auth/client-adapter.ts',
|
|
476
489
|
'src/lib/jobs/definitions.ts',
|
|
490
|
+
'src/lib/actions/admin.ts',
|
|
491
|
+
'src/lib/actions/impersonation.ts',
|
|
492
|
+
'src/lib/scheduled-reports/index.ts',
|
|
477
493
|
'src/config/marketing.test.ts',
|
|
494
|
+
'src/config/app.ts',
|
|
478
495
|
'src/instrumentation.ts',
|
|
479
496
|
];
|
|
480
497
|
function generateEnvFile(root, config) {
|
|
@@ -540,14 +557,61 @@ function generateMcpConfig(root) {
|
|
|
540
557
|
success('Created .cursor/mcp.json — Codapult MCP server configured for Cursor');
|
|
541
558
|
}
|
|
542
559
|
function pruneMarkedBlocks(content, disabledKeys) {
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
560
|
+
const keySet = new Set(disabledKeys.map(String));
|
|
561
|
+
const lines = content.split('\n');
|
|
562
|
+
const out = [];
|
|
563
|
+
const startRe = /^[ \t]*\/\/\s*codapult:prune:start\s+(\S+)\s*$/;
|
|
564
|
+
const replaceRe = /^[ \t]*\/\/\s*codapult:prune:replace\s*$/;
|
|
565
|
+
const endRe = /^[ \t]*\/\/\s*codapult:prune:end\s+(\S+)[ \t]*$/;
|
|
566
|
+
const commentRe = /^([ \t]*)\/\/ ?(.*)$/;
|
|
567
|
+
// Ищет ближайший terminator (replace или end с нужным key) начиная с индекса i.
|
|
568
|
+
// Бросает при вложенном start того же формата. Возвращает индекс ПОСЛЕ terminator-строки.
|
|
569
|
+
const seekTo = (i, key) => {
|
|
570
|
+
for (let j = i; j < lines.length; j += 1) {
|
|
571
|
+
if (replaceRe.test(lines[j]))
|
|
572
|
+
return { i: j + 1, kind: 'replace' };
|
|
573
|
+
const end = endRe.exec(lines[j]);
|
|
574
|
+
if (end?.[1] === key)
|
|
575
|
+
return { i: j + 1, kind: 'end' };
|
|
576
|
+
if (startRe.test(lines[j])) {
|
|
577
|
+
throw new Error(`Nested "codapult:prune:start" before closing "${key}" (line ${j + 1}).`);
|
|
578
|
+
}
|
|
579
|
+
}
|
|
580
|
+
throw new Error(`Unclosed "codapult:prune:start ${key}" — no matching end found.`);
|
|
581
|
+
};
|
|
582
|
+
for (let i = 0; i < lines.length;) {
|
|
583
|
+
const start = startRe.exec(lines[i]);
|
|
584
|
+
if (!start || !keySet.has(start[1])) {
|
|
585
|
+
out.push(lines[i]);
|
|
586
|
+
i += 1;
|
|
587
|
+
continue;
|
|
588
|
+
}
|
|
589
|
+
const key = start[1];
|
|
590
|
+
const body = seekTo(i + 1, key);
|
|
591
|
+
if (body.kind === 'end') {
|
|
592
|
+
i = body.i; // тело отбрасываем целиком
|
|
593
|
+
continue;
|
|
594
|
+
}
|
|
595
|
+
// body.kind === 'replace': строки от body.i до end — это закомментированный replacement
|
|
596
|
+
const replEnd = seekTo(body.i, key);
|
|
597
|
+
if (replEnd.kind !== 'end') {
|
|
598
|
+
throw new Error(`Expected "end" after "replace" for key "${key}".`);
|
|
599
|
+
}
|
|
600
|
+
for (let r = body.i; r < replEnd.i - 1; r++) {
|
|
601
|
+
const line = lines[r];
|
|
602
|
+
if (line.trim() === '') {
|
|
603
|
+
out.push('');
|
|
604
|
+
continue;
|
|
605
|
+
}
|
|
606
|
+
const m = commentRe.exec(line);
|
|
607
|
+
if (!m) {
|
|
608
|
+
throw new Error(`Line ${r + 1} in "replace" section for "${key}" is not commented out: ${JSON.stringify(line)}`);
|
|
609
|
+
}
|
|
610
|
+
out.push(m[1] + m[2]);
|
|
611
|
+
}
|
|
612
|
+
i = replEnd.i;
|
|
548
613
|
}
|
|
549
|
-
return
|
|
550
|
-
// return next.replace(/\n{3,}/g, '\n\n');
|
|
614
|
+
return out.join('\n');
|
|
551
615
|
}
|
|
552
616
|
function pruneMarkedBlocksInFiles(root, config) {
|
|
553
617
|
const disabledKeys = Object.keys(config).filter((key) => key.startsWith('enable') && config[key] === false);
|
|
@@ -620,7 +684,7 @@ async function interactiveSetup() {
|
|
|
620
684
|
'bullmq',
|
|
621
685
|
]),
|
|
622
686
|
enableAuth: authEnabled,
|
|
623
|
-
enableAI:
|
|
687
|
+
enableAI: emptyLine() && (await confirm(iface, 'Enable AI Chat module?')),
|
|
624
688
|
enableBlog: await confirm(iface, 'Enable Blog module?'),
|
|
625
689
|
enableTeams: authEnabled && (await confirm(iface, 'Enable Teams/Organizations?')),
|
|
626
690
|
enableWaitlist: await confirm(iface, 'Enable Waitlist page?'),
|
|
@@ -647,7 +711,7 @@ async function interactiveSetup() {
|
|
|
647
711
|
enableBranding: authEnabled && (await confirm(iface, 'Enable per-org branding (white-label)?')),
|
|
648
712
|
enableTwoFactor: authEnabled && (await confirm(iface, 'Enable two-factor authentication (TOTP)?')),
|
|
649
713
|
enablePlugins: await confirm(iface, 'Enable plugin marketplace (/plugins)?'),
|
|
650
|
-
removeUnusedCode:
|
|
714
|
+
removeUnusedCode: emptyLine() && (await confirm(iface, 'Remove unused module code?', false)),
|
|
651
715
|
};
|
|
652
716
|
iface.close();
|
|
653
717
|
return config;
|
package/dist/mcp/resources.js
CHANGED
|
@@ -17,7 +17,7 @@ export function registerResources(server) {
|
|
|
17
17
|
});
|
|
18
18
|
server.registerResource('codapult_app_config', 'codapult://config/app', {
|
|
19
19
|
title: 'App Configuration',
|
|
20
|
-
description: `Application config (src/config/app.ts) — brand, AI,
|
|
20
|
+
description: `Application config (src/config/app.ts) — brand, AI, company. Feature toggles and auth methods live in the project env source (${ENV_FILE_NAME} or process.env) and can be inspected via codapult://env-example or codapult_project_status.`,
|
|
21
21
|
mimeType: 'text/plain',
|
|
22
22
|
}, () => {
|
|
23
23
|
const content = readProjectFile(getRoot(), 'src/config/app.ts') ?? 'Config file not found';
|
|
@@ -61,7 +61,7 @@ export function registerProjectTools(server) {
|
|
|
61
61
|
});
|
|
62
62
|
server.registerTool('codapult_project_config', {
|
|
63
63
|
title: 'Project Config',
|
|
64
|
-
description: 'Read the app configuration from src/config/app.ts (brand,
|
|
64
|
+
description: 'Read the app configuration from src/config/app.ts (brand, ai, company)',
|
|
65
65
|
}, () => {
|
|
66
66
|
const root = getRoot();
|
|
67
67
|
const content = readProjectFile(root, 'src/config/app.ts') ?? 'Config file not found';
|