@codapult/cli 0.20.0 → 0.21.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/README.md +48 -16
- package/dist/commands/generate.js +4 -2
- package/dist/commands/plugins.d.ts +1 -0
- package/dist/commands/plugins.js +41 -1
- package/dist/commands/recipes.d.ts +47 -0
- package/dist/commands/recipes.js +117 -0
- package/dist/commands/setup.d.ts +46 -0
- package/dist/commands/setup.js +100 -12
- package/dist/commands/update.js +7 -52
- package/dist/index.js +17 -1
- package/dist/mcp/server-factory.d.ts +3 -0
- package/dist/mcp/server-factory.js +34 -0
- package/dist/mcp/server.js +2 -31
- package/dist/mcp/tools/generate.js +2 -1
- package/dist/utils/manifest.d.ts +9 -0
- package/dist/utils/manifest.js +30 -0
- package/dist/utils/patchers.js +19 -9
- package/dist/utils/project-paths.d.ts +9 -0
- package/dist/utils/project-paths.js +13 -0
- package/package.json +24 -14
package/README.md
CHANGED
|
@@ -1,26 +1,28 @@
|
|
|
1
|
-
# @codapult/cli
|
|
1
|
+
# Next.js SaaS CLI and MCP Server for Codapult | @codapult/cli
|
|
2
2
|
|
|
3
3
|
[](https://github.com/codapult/codapult-cli/actions/workflows/ci.yml)
|
|
4
4
|
[](https://www.npmjs.com/package/@codapult/cli)
|
|
5
5
|
[](LICENSE)
|
|
6
6
|
[](package.json)
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
`@codapult/cli` is the Next.js SaaS CLI for managing projects built with
|
|
9
|
+
[Codapult](https://codapult.dev), a full-source Next.js SaaS boilerplate and starter kit. Use it to
|
|
10
|
+
set up and update a SaaS codebase, configure plugins and databases, check deployment readiness,
|
|
11
|
+
and connect AI coding agents through its Model Context Protocol (MCP) server.
|
|
10
12
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
13
|
+
The open-source CLI brings project setup, updates, plugins, database, deployment, MCP, and
|
|
14
|
+
architecture-control workflows into one developer tool. It is designed for Codapult projects built
|
|
15
|
+
with the Next.js SaaS boilerplate; it is not a general-purpose Next.js app generator.
|
|
14
16
|
|
|
15
|
-
For a non-Codapult JavaScript or TypeScript project, install
|
|
17
|
+
For architecture guardrails for AI coding agents in a non-Codapult JavaScript or TypeScript project, install
|
|
16
18
|
[`@codapult/guard`](https://github.com/codapult/codapult-guard) directly. The CLI does not make
|
|
17
|
-
Guard universal by adding Codapult assumptions to it;
|
|
18
|
-
|
|
19
|
+
Guard universal by adding Codapult assumptions to it; within Codapult projects, the CLI includes the
|
|
20
|
+
same published Guard package through a thin adapter.
|
|
19
21
|
|
|
20
|
-
| Package | Use it when
|
|
21
|
-
| --------------------------------------------------------------- |
|
|
22
|
-
| [`@codapult/guard`](https://github.com/codapult/codapult-guard) | You need
|
|
23
|
-
| `@codapult/cli` | You are building a Codapult SaaS and also need setup, plugins, database, environment, and deployment workflows.
|
|
22
|
+
| Package | Use it when |
|
|
23
|
+
| --------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------ |
|
|
24
|
+
| [`@codapult/guard`](https://github.com/codapult/codapult-guard) | You need AI coding agent guardrails, software architecture checks, project memory, MCP, and verification in any JS/TS project. |
|
|
25
|
+
| `@codapult/cli` | You are building a Codapult SaaS and also need setup, plugins, database, environment, and deployment workflows. |
|
|
24
26
|
|
|
25
27
|
## Installation
|
|
26
28
|
|
|
@@ -46,11 +48,33 @@ pnpm add -D @codapult/cli
|
|
|
46
48
|
Project users who do not install the CLI globally should prefix commands with `npx @codapult/cli`,
|
|
47
49
|
for example `npx @codapult/cli db schema-diff`.
|
|
48
50
|
|
|
51
|
+
### Verified project workflow
|
|
52
|
+
|
|
53
|
+
The CLI repository includes an executable golden-path contract for the workflow used by a new
|
|
54
|
+
Codapult project:
|
|
55
|
+
|
|
56
|
+
```text
|
|
57
|
+
create → setup → run → MCP status/generate → project checks → Guard → test
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
Maintainers can run it with:
|
|
61
|
+
|
|
62
|
+
```shell
|
|
63
|
+
pnpm test:golden
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
The check creates a temporary shallow-clone source, starts the generated project locally, verifies
|
|
67
|
+
its health endpoint, connects to MCP, generates a page, runs the project test through MCP, and
|
|
68
|
+
finishes with Guard initialization, proposal, and verification. It uses no external provider
|
|
69
|
+
credentials. Authentication and payment-provider flows remain covered by their focused adapter,
|
|
70
|
+
route, webhook, and application E2E tests.
|
|
71
|
+
|
|
49
72
|
## Commands
|
|
50
73
|
|
|
51
74
|
### Project
|
|
52
75
|
|
|
53
76
|
- `codapult setup` — interactive project setup wizard (or non-interactive with `--preset`)
|
|
77
|
+
- `codapult recipe list|show|apply <name>` — inspect or apply a starter workflow
|
|
54
78
|
- `codapult update [version]` — update from upstream Codapult releases
|
|
55
79
|
- `codapult doctor` — check project health and configuration (exit code 1 on failures for CI)
|
|
56
80
|
- `codapult config` — show current project configuration
|
|
@@ -61,6 +85,7 @@ for example `npx @codapult/cli db schema-diff`.
|
|
|
61
85
|
- `codapult plugins remove <name>` — uninstall a plugin
|
|
62
86
|
- `codapult plugins migrate [name]` — update plugin schema and generate DB migration (`--push` for dev mode)
|
|
63
87
|
- `codapult plugins list` — list installed plugins
|
|
88
|
+
- `codapult plugins check [name]` — verify plugin install compatibility without changing files
|
|
64
89
|
|
|
65
90
|
### Code Generation
|
|
66
91
|
|
|
@@ -92,8 +117,8 @@ for example `npx @codapult/cli db schema-diff`.
|
|
|
92
117
|
|
|
93
118
|
### Architecture Guard
|
|
94
119
|
|
|
95
|
-
Codapult CLI includes the
|
|
96
|
-
|
|
120
|
+
Codapult CLI includes the [`@codapult/guard`](https://github.com/codapult/codapult-guard) engine and
|
|
121
|
+
keeps the `codapult guard ...` command surface as a Codapult-friendly entrypoint.
|
|
97
122
|
Guard is responsible for project architecture memory, approved contracts, baselines, changed-file
|
|
98
123
|
regressions, impact context, and AI-agent review packets. It does not replace ESLint, TypeScript,
|
|
99
124
|
tests, SAST, or a general PR-review service.
|
|
@@ -138,10 +163,17 @@ Mutation commands (`db push`, `db generate`, `plugins add/remove`, env sync, and
|
|
|
138
163
|
|
|
139
164
|
## MCP Server
|
|
140
165
|
|
|
141
|
-
The CLI includes an MCP (Model Context Protocol) server
|
|
166
|
+
The CLI includes an MCP (Model Context Protocol) server for working with Codapult projects. Its
|
|
167
|
+
core integration exposes 29 tools, 8 resources, and 2 prompt templates. The integrated Guard
|
|
168
|
+
capabilities add 14 tools, 6 resources, and 2 prompt templates. The resulting current full surface
|
|
169
|
+
is 43 tools, 14 resources, and 4 prompt templates.
|
|
142
170
|
|
|
143
171
|
### MCP Tools
|
|
144
172
|
|
|
173
|
+
The tools below are the Codapult template integration. Guard tools are documented in the
|
|
174
|
+
[`@codapult/guard` repository](https://github.com/codapult/codapult-guard) and are registered by
|
|
175
|
+
the CLI as its architecture-control layer.
|
|
176
|
+
|
|
145
177
|
#### Project
|
|
146
178
|
|
|
147
179
|
| Tool | Description |
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { existsSync, mkdirSync, writeFileSync } from 'node:fs';
|
|
2
2
|
import { resolve, dirname } from 'node:path';
|
|
3
3
|
import { checkProjectRoot } from '../utils/project.js';
|
|
4
|
+
import { dashboardPageManifestPath, dashboardPagePath } from '../utils/project-paths.js';
|
|
4
5
|
import { heading, success, fail, info, dim } from '../utils/ui.js';
|
|
5
6
|
import { validateGeneratedName } from '../utils/validation.js';
|
|
6
7
|
function toKebab(name) {
|
|
@@ -36,7 +37,7 @@ export function generatePageCommand(name) {
|
|
|
36
37
|
const pascal = toPascal(name);
|
|
37
38
|
const title = pascal.replace(/([A-Z])/g, ' $1').trim();
|
|
38
39
|
heading(`Generating dashboard page: ${kebab}`);
|
|
39
|
-
const pagePath = resolve(root,
|
|
40
|
+
const pagePath = resolve(root, dashboardPagePath(kebab));
|
|
40
41
|
const page = `import { getAppSession } from '@/lib/auth';
|
|
41
42
|
import { redirect } from 'next/navigation';
|
|
42
43
|
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/components/ui/card';
|
|
@@ -295,11 +296,12 @@ export default ${camel}Plugin;
|
|
|
295
296
|
name: kebab,
|
|
296
297
|
package: `@codapult/plugin-${kebab}`,
|
|
297
298
|
version: '0.1.0',
|
|
299
|
+
apiVersion: 1,
|
|
298
300
|
description: `${pascal} plugin for Codapult`,
|
|
299
301
|
install: {
|
|
300
302
|
transpilePackages: [`@codapult/plugin-${kebab}`],
|
|
301
303
|
pages: {
|
|
302
|
-
[
|
|
304
|
+
[dashboardPageManifestPath(kebab)]: `@codapult/plugin-${kebab}/pages/${kebab}-page`,
|
|
303
305
|
},
|
|
304
306
|
env: {},
|
|
305
307
|
},
|
package/dist/commands/plugins.js
CHANGED
|
@@ -3,7 +3,7 @@ import { existsSync, readFileSync, readdirSync, rmSync } from 'node:fs';
|
|
|
3
3
|
import { resolve } from 'node:path';
|
|
4
4
|
import { checkProjectRoot } from '../utils/project.js';
|
|
5
5
|
import { ENV_FILE_NAME, getProjectEnvSource, } from '../utils/project-env.js';
|
|
6
|
-
import { resolveManifest } from '../utils/manifest.js';
|
|
6
|
+
import { getPluginCompatibilityIssues, resolveManifest } from '../utils/manifest.js';
|
|
7
7
|
import { clonePlugin } from '../utils/git.js';
|
|
8
8
|
import { patchSchemaImports, patchSchemaImportsPg, patchSchemaTables, patchSchemaTablesPg, patchDbReExports, patchNextConfig, createPluginRegistration, patchPages, findPageConflicts, patchEnvFile, patchPackageJson, } from '../utils/patchers.js';
|
|
9
9
|
import { heading, success, fail, warn, info, dim, confirm } from '../utils/ui.js';
|
|
@@ -46,6 +46,13 @@ export async function pluginsAddCommand(name, options = {}) {
|
|
|
46
46
|
process.exit(1);
|
|
47
47
|
}
|
|
48
48
|
const { manifest, pluginDir } = result;
|
|
49
|
+
const compatibilityIssues = getPluginCompatibilityIssues(manifest, pluginDir);
|
|
50
|
+
if (compatibilityIssues.length > 0) {
|
|
51
|
+
fail(`Plugin "${manifest.name}" is not compatible with this Codapult project.`);
|
|
52
|
+
for (const issue of compatibilityIssues)
|
|
53
|
+
dim(` ${issue.message}`);
|
|
54
|
+
process.exit(1);
|
|
55
|
+
}
|
|
49
56
|
info(`Found: ${manifest.package}@${manifest.version}`);
|
|
50
57
|
dim(` ${manifest.description}`);
|
|
51
58
|
dim(` ${pluginDir}`);
|
|
@@ -450,3 +457,36 @@ export function pluginsListCommand() {
|
|
|
450
457
|
}
|
|
451
458
|
console.log();
|
|
452
459
|
}
|
|
460
|
+
// ---------------------------------------------------------------------------
|
|
461
|
+
// codapult plugins check [name]
|
|
462
|
+
// ---------------------------------------------------------------------------
|
|
463
|
+
export function pluginsCheckCommand(name) {
|
|
464
|
+
const root = checkProjectRoot('exit');
|
|
465
|
+
const pluginNames = name ? [name] : getInstalledPluginNames(root);
|
|
466
|
+
if (pluginNames.length === 0) {
|
|
467
|
+
info('No installed plugins found.');
|
|
468
|
+
return;
|
|
469
|
+
}
|
|
470
|
+
heading(name ? `Checking plugin: ${name}` : 'Checking installed plugins');
|
|
471
|
+
let hasErrors = false;
|
|
472
|
+
for (const pluginName of pluginNames) {
|
|
473
|
+
const result = resolveManifest(root, pluginName);
|
|
474
|
+
if (!result) {
|
|
475
|
+
fail(`${pluginName}: manifest not found`);
|
|
476
|
+
hasErrors = true;
|
|
477
|
+
continue;
|
|
478
|
+
}
|
|
479
|
+
const issues = getPluginCompatibilityIssues(result.manifest, result.pluginDir);
|
|
480
|
+
if (issues.length === 0) {
|
|
481
|
+
success(`${result.manifest.name}: compatible`);
|
|
482
|
+
continue;
|
|
483
|
+
}
|
|
484
|
+
hasErrors = true;
|
|
485
|
+
fail(`${result.manifest.name}: incompatible`);
|
|
486
|
+
for (const issue of issues)
|
|
487
|
+
dim(` ${issue.message}`);
|
|
488
|
+
}
|
|
489
|
+
if (hasErrors)
|
|
490
|
+
process.exitCode = 1;
|
|
491
|
+
console.log();
|
|
492
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
export declare const RECIPES: {
|
|
2
|
+
readonly saas: {
|
|
3
|
+
readonly preset: 'saas';
|
|
4
|
+
readonly description: 'General-purpose SaaS with the full Codapult foundation.';
|
|
5
|
+
readonly steps: readonly ['setup --preset saas', 'pnpm install', 'pnpm db:push', 'pnpm dev'];
|
|
6
|
+
};
|
|
7
|
+
readonly 'ai-saas': {
|
|
8
|
+
readonly preset: 'ai-saas';
|
|
9
|
+
readonly description: 'AI product with chat, agents, batch processing, playground, and RAG.';
|
|
10
|
+
readonly steps: readonly ['setup --preset ai-saas', 'pnpm install', 'pnpm db:push', 'pnpm db:seed', 'npx @codapult/cli doctor', 'npx @codapult/cli mcp doctor', 'pnpm dev'];
|
|
11
|
+
};
|
|
12
|
+
readonly 'b2b-saas': {
|
|
13
|
+
readonly preset: 'b2b-saas';
|
|
14
|
+
readonly description: 'Team product with organizations, SSO, branding, audit, and operations modules.';
|
|
15
|
+
readonly steps: readonly ['setup --preset b2b-saas', 'pnpm install', 'pnpm db:push', 'pnpm db:seed', 'npx @codapult/cli doctor', 'npx @codapult/cli mcp doctor', 'pnpm dev'];
|
|
16
|
+
};
|
|
17
|
+
readonly 'ai-chatbot': {
|
|
18
|
+
readonly preset: 'ai-chatbot';
|
|
19
|
+
readonly description: 'Focused AI chatbot with chat, tenant context, quotas, and audit-ready events.';
|
|
20
|
+
readonly steps: readonly ['setup --preset ai-chatbot', 'pnpm install', 'pnpm db:push', 'pnpm db:seed', 'npx @codapult/cli doctor', 'npx @codapult/cli mcp doctor', 'pnpm dev'];
|
|
21
|
+
};
|
|
22
|
+
readonly marketplace: {
|
|
23
|
+
readonly preset: 'marketplace';
|
|
24
|
+
readonly description: 'Marketplace with organizations, Stripe Connect, webhooks, audit, and branding.';
|
|
25
|
+
readonly steps: readonly ['setup --preset marketplace', 'pnpm install', 'pnpm db:push', 'pnpm db:seed', 'npx @codapult/cli doctor', 'npx @codapult/cli mcp doctor', 'pnpm dev'];
|
|
26
|
+
};
|
|
27
|
+
readonly 'internal-tool': {
|
|
28
|
+
readonly preset: 'internal-tool';
|
|
29
|
+
readonly description: 'Internal tool with auth, organizations, workflows, analytics, audit, and reports.';
|
|
30
|
+
readonly steps: readonly ['setup --preset internal-tool', 'pnpm install', 'pnpm db:push', 'pnpm db:seed', 'npx @codapult/cli doctor', 'npx @codapult/cli mcp doctor', 'pnpm dev'];
|
|
31
|
+
};
|
|
32
|
+
readonly 'content-saas': {
|
|
33
|
+
readonly preset: 'content-saas';
|
|
34
|
+
readonly description: 'Content and productivity SaaS with blog, workflows, onboarding, analytics, and growth surfaces.';
|
|
35
|
+
readonly steps: readonly ['setup --preset content-saas', 'pnpm install', 'pnpm db:push', 'pnpm db:seed', 'npx @codapult/cli doctor', 'npx @codapult/cli mcp doctor', 'pnpm dev'];
|
|
36
|
+
};
|
|
37
|
+
readonly marketing: {
|
|
38
|
+
readonly preset: 'marketing';
|
|
39
|
+
readonly description: 'Marketing site without authentication or dashboard modules.';
|
|
40
|
+
readonly steps: readonly ['setup --preset marketing', 'pnpm install', 'npx @codapult/cli doctor', 'pnpm dev'];
|
|
41
|
+
};
|
|
42
|
+
};
|
|
43
|
+
export declare function recipeListCommand(): void;
|
|
44
|
+
export declare function recipeShowCommand(name: string): void;
|
|
45
|
+
export declare function recipeApplyCommand(name: string, options: {
|
|
46
|
+
envFile?: boolean;
|
|
47
|
+
}): Promise<void>;
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import { fail, heading, info, dim } from '../utils/ui.js';
|
|
2
|
+
import { setupCommand } from './setup.js';
|
|
3
|
+
export const RECIPES = {
|
|
4
|
+
saas: {
|
|
5
|
+
preset: 'saas',
|
|
6
|
+
description: 'General-purpose SaaS with the full Codapult foundation.',
|
|
7
|
+
steps: ['setup --preset saas', 'pnpm install', 'pnpm db:push', 'pnpm dev'],
|
|
8
|
+
},
|
|
9
|
+
'ai-saas': {
|
|
10
|
+
preset: 'ai-saas',
|
|
11
|
+
description: 'AI product with chat, agents, batch processing, playground, and RAG.',
|
|
12
|
+
steps: [
|
|
13
|
+
'setup --preset ai-saas',
|
|
14
|
+
'pnpm install',
|
|
15
|
+
'pnpm db:push',
|
|
16
|
+
'pnpm db:seed',
|
|
17
|
+
'npx @codapult/cli doctor',
|
|
18
|
+
'npx @codapult/cli mcp doctor',
|
|
19
|
+
'pnpm dev',
|
|
20
|
+
],
|
|
21
|
+
},
|
|
22
|
+
'b2b-saas': {
|
|
23
|
+
preset: 'b2b-saas',
|
|
24
|
+
description: 'Team product with organizations, SSO, branding, audit, and operations modules.',
|
|
25
|
+
steps: [
|
|
26
|
+
'setup --preset b2b-saas',
|
|
27
|
+
'pnpm install',
|
|
28
|
+
'pnpm db:push',
|
|
29
|
+
'pnpm db:seed',
|
|
30
|
+
'npx @codapult/cli doctor',
|
|
31
|
+
'npx @codapult/cli mcp doctor',
|
|
32
|
+
'pnpm dev',
|
|
33
|
+
],
|
|
34
|
+
},
|
|
35
|
+
'ai-chatbot': {
|
|
36
|
+
preset: 'ai-chatbot',
|
|
37
|
+
description: 'Focused AI chatbot with chat, tenant context, quotas, and audit-ready events.',
|
|
38
|
+
steps: [
|
|
39
|
+
'setup --preset ai-chatbot',
|
|
40
|
+
'pnpm install',
|
|
41
|
+
'pnpm db:push',
|
|
42
|
+
'pnpm db:seed',
|
|
43
|
+
'npx @codapult/cli doctor',
|
|
44
|
+
'npx @codapult/cli mcp doctor',
|
|
45
|
+
'pnpm dev',
|
|
46
|
+
],
|
|
47
|
+
},
|
|
48
|
+
marketplace: {
|
|
49
|
+
preset: 'marketplace',
|
|
50
|
+
description: 'Marketplace with organizations, Stripe Connect, webhooks, audit, and branding.',
|
|
51
|
+
steps: [
|
|
52
|
+
'setup --preset marketplace',
|
|
53
|
+
'pnpm install',
|
|
54
|
+
'pnpm db:push',
|
|
55
|
+
'pnpm db:seed',
|
|
56
|
+
'npx @codapult/cli doctor',
|
|
57
|
+
'npx @codapult/cli mcp doctor',
|
|
58
|
+
'pnpm dev',
|
|
59
|
+
],
|
|
60
|
+
},
|
|
61
|
+
'internal-tool': {
|
|
62
|
+
preset: 'internal-tool',
|
|
63
|
+
description: 'Internal tool with auth, organizations, workflows, analytics, audit, and reports.',
|
|
64
|
+
steps: [
|
|
65
|
+
'setup --preset internal-tool',
|
|
66
|
+
'pnpm install',
|
|
67
|
+
'pnpm db:push',
|
|
68
|
+
'pnpm db:seed',
|
|
69
|
+
'npx @codapult/cli doctor',
|
|
70
|
+
'npx @codapult/cli mcp doctor',
|
|
71
|
+
'pnpm dev',
|
|
72
|
+
],
|
|
73
|
+
},
|
|
74
|
+
'content-saas': {
|
|
75
|
+
preset: 'content-saas',
|
|
76
|
+
description: 'Content and productivity SaaS with blog, workflows, onboarding, analytics, and growth surfaces.',
|
|
77
|
+
steps: [
|
|
78
|
+
'setup --preset content-saas',
|
|
79
|
+
'pnpm install',
|
|
80
|
+
'pnpm db:push',
|
|
81
|
+
'pnpm db:seed',
|
|
82
|
+
'npx @codapult/cli doctor',
|
|
83
|
+
'npx @codapult/cli mcp doctor',
|
|
84
|
+
'pnpm dev',
|
|
85
|
+
],
|
|
86
|
+
},
|
|
87
|
+
marketing: {
|
|
88
|
+
preset: 'marketing',
|
|
89
|
+
description: 'Marketing site without authentication or dashboard modules.',
|
|
90
|
+
steps: ['setup --preset marketing', 'pnpm install', 'npx @codapult/cli doctor', 'pnpm dev'],
|
|
91
|
+
},
|
|
92
|
+
};
|
|
93
|
+
function getRecipe(name) {
|
|
94
|
+
if (name in RECIPES)
|
|
95
|
+
return RECIPES[name];
|
|
96
|
+
fail(`Unknown recipe: "${name}". Available: ${Object.keys(RECIPES).join(', ')}`);
|
|
97
|
+
process.exit(1);
|
|
98
|
+
}
|
|
99
|
+
export function recipeListCommand() {
|
|
100
|
+
heading('Codapult Recipes');
|
|
101
|
+
for (const [name, recipe] of Object.entries(RECIPES)) {
|
|
102
|
+
info(`${name} — ${recipe.description}`);
|
|
103
|
+
}
|
|
104
|
+
console.log();
|
|
105
|
+
dim('Run `codapult recipe show <name>` for the steps.');
|
|
106
|
+
}
|
|
107
|
+
export function recipeShowCommand(name) {
|
|
108
|
+
const recipe = getRecipe(name);
|
|
109
|
+
heading(`Recipe: ${name}`);
|
|
110
|
+
info(recipe.description);
|
|
111
|
+
console.log();
|
|
112
|
+
recipe.steps.forEach((step, index) => dim(`${index + 1}. ${step}`));
|
|
113
|
+
}
|
|
114
|
+
export async function recipeApplyCommand(name, options) {
|
|
115
|
+
const recipe = getRecipe(name);
|
|
116
|
+
await setupCommand({ preset: recipe.preset, envFile: options.envFile });
|
|
117
|
+
}
|
package/dist/commands/setup.d.ts
CHANGED
|
@@ -1,4 +1,50 @@
|
|
|
1
1
|
import { type ProjectEnvOptions } from '../utils/project-env.js';
|
|
2
|
+
export interface ProjectConfig {
|
|
3
|
+
appName: string;
|
|
4
|
+
appUrl: string;
|
|
5
|
+
appMode: 'app' | 'landing' | 'demo';
|
|
6
|
+
authProvider: 'better-auth' | 'kinde' | 'none';
|
|
7
|
+
paymentProvider: 'stripe' | 'lemonsqueezy' | 'polar';
|
|
8
|
+
ssoProvider: 'jackson' | 'none';
|
|
9
|
+
storageProvider: 'local' | 's3';
|
|
10
|
+
jobProvider: 'memory' | 'bullmq' | 'none';
|
|
11
|
+
enableAuth: boolean;
|
|
12
|
+
enableAI: boolean;
|
|
13
|
+
enableRAG: boolean;
|
|
14
|
+
enableAiChat: boolean;
|
|
15
|
+
enableAgents: boolean;
|
|
16
|
+
enableBatch: boolean;
|
|
17
|
+
enablePlayground: boolean;
|
|
18
|
+
enableBlog: boolean;
|
|
19
|
+
enableTeams: boolean;
|
|
20
|
+
enableWaitlist: boolean;
|
|
21
|
+
enableGraphQL: boolean;
|
|
22
|
+
enableSSO: boolean;
|
|
23
|
+
enableApiDocs: boolean;
|
|
24
|
+
enableHelpCenter: boolean;
|
|
25
|
+
enableExperiments: boolean;
|
|
26
|
+
enableFeatureRequests: boolean;
|
|
27
|
+
enableCompare: boolean;
|
|
28
|
+
enableConnect: boolean;
|
|
29
|
+
enableEventStore: boolean;
|
|
30
|
+
enableOtel: boolean;
|
|
31
|
+
enableDripCampaigns: boolean;
|
|
32
|
+
enableOnboarding: boolean;
|
|
33
|
+
enableWorkflows: boolean;
|
|
34
|
+
enableReferrals: boolean;
|
|
35
|
+
enableAnalytics: boolean;
|
|
36
|
+
enableChangelog: boolean;
|
|
37
|
+
enableWebhooks: boolean;
|
|
38
|
+
enableAuditLog: boolean;
|
|
39
|
+
enableReports: boolean;
|
|
40
|
+
enableBranding: boolean;
|
|
41
|
+
enableTwoFactor: boolean;
|
|
42
|
+
enablePlugins: boolean;
|
|
43
|
+
removeUnusedCode: boolean;
|
|
44
|
+
}
|
|
45
|
+
export declare function resolvePreset(raw: string): ProjectConfig;
|
|
46
|
+
export declare function getPresetNames(): string[];
|
|
47
|
+
export declare function buildEnvContent(content: string, config: ProjectConfig): string;
|
|
2
48
|
interface SetupOptions extends Pick<ProjectEnvOptions, 'envFile'> {
|
|
3
49
|
preset?: string;
|
|
4
50
|
}
|
package/dist/commands/setup.js
CHANGED
|
@@ -19,8 +19,81 @@ function emptyLine() {
|
|
|
19
19
|
// Built-in presets for non-interactive (CI/CD) setup via --preset flag.
|
|
20
20
|
// ---------------------------------------------------------------------------
|
|
21
21
|
const BUILT_IN_PRESETS = {
|
|
22
|
+
saas: {},
|
|
23
|
+
'ai-saas': {
|
|
24
|
+
enableAI: true,
|
|
25
|
+
enableRAG: true,
|
|
26
|
+
enableAgents: true,
|
|
27
|
+
enableBatch: true,
|
|
28
|
+
enablePlayground: true,
|
|
29
|
+
},
|
|
30
|
+
'b2b-saas': {
|
|
31
|
+
authProvider: 'better-auth',
|
|
32
|
+
ssoProvider: 'jackson',
|
|
33
|
+
enableAuth: true,
|
|
34
|
+
enableSSO: true,
|
|
35
|
+
enableTeams: true,
|
|
36
|
+
enableBranding: true,
|
|
37
|
+
enableAuditLog: true,
|
|
38
|
+
enableReports: true,
|
|
39
|
+
enableWebhooks: true,
|
|
40
|
+
},
|
|
41
|
+
'ai-chatbot': {
|
|
42
|
+
enableAI: true,
|
|
43
|
+
enableAiChat: true,
|
|
44
|
+
enableRAG: false,
|
|
45
|
+
enableAgents: false,
|
|
46
|
+
enableBatch: false,
|
|
47
|
+
enablePlayground: false,
|
|
48
|
+
enableTeams: true,
|
|
49
|
+
enableAuditLog: true,
|
|
50
|
+
enableWebhooks: true,
|
|
51
|
+
},
|
|
52
|
+
marketplace: {
|
|
53
|
+
enableTeams: true,
|
|
54
|
+
enableConnect: true,
|
|
55
|
+
enableWebhooks: true,
|
|
56
|
+
enableAuditLog: true,
|
|
57
|
+
enableBranding: true,
|
|
58
|
+
},
|
|
59
|
+
'internal-tool': {
|
|
60
|
+
enableAI: false,
|
|
61
|
+
enableBlog: false,
|
|
62
|
+
enableTeams: true,
|
|
63
|
+
enableConnect: false,
|
|
64
|
+
enableSSO: false,
|
|
65
|
+
enableWorkflows: true,
|
|
66
|
+
enableAnalytics: true,
|
|
67
|
+
enableWebhooks: true,
|
|
68
|
+
enableAuditLog: true,
|
|
69
|
+
enableReports: true,
|
|
70
|
+
enableBranding: true,
|
|
71
|
+
enableReferrals: false,
|
|
72
|
+
enableChangelog: false,
|
|
73
|
+
enableWaitlist: false,
|
|
74
|
+
enableFeatureRequests: false,
|
|
75
|
+
enableCompare: false,
|
|
76
|
+
removeUnusedCode: true,
|
|
77
|
+
},
|
|
78
|
+
'content-saas': {
|
|
79
|
+
enableAI: false,
|
|
80
|
+
enableBlog: true,
|
|
81
|
+
enableTeams: false,
|
|
82
|
+
enableWorkflows: true,
|
|
83
|
+
enableAnalytics: true,
|
|
84
|
+
enableOnboarding: true,
|
|
85
|
+
enableReferrals: true,
|
|
86
|
+
enableChangelog: true,
|
|
87
|
+
enableWaitlist: true,
|
|
88
|
+
enableFeatureRequests: false,
|
|
89
|
+
enableCompare: false,
|
|
90
|
+
enableWebhooks: true,
|
|
91
|
+
enableAuditLog: true,
|
|
92
|
+
removeUnusedCode: true,
|
|
93
|
+
},
|
|
22
94
|
// Marketing-only site.
|
|
23
95
|
marketing: {
|
|
96
|
+
appMode: 'landing',
|
|
24
97
|
authProvider: 'none',
|
|
25
98
|
jobProvider: 'none',
|
|
26
99
|
ssoProvider: 'none',
|
|
@@ -59,12 +132,14 @@ const BUILT_IN_PRESETS = {
|
|
|
59
132
|
removeUnusedCode: true,
|
|
60
133
|
},
|
|
61
134
|
demo: {
|
|
135
|
+
appMode: 'demo',
|
|
62
136
|
authProvider: 'better-auth',
|
|
63
137
|
},
|
|
64
138
|
};
|
|
65
139
|
const DEFAULT_CONFIG = {
|
|
66
140
|
appName: 'Codapult',
|
|
67
141
|
appUrl: 'http://localhost:3000',
|
|
142
|
+
appMode: 'app',
|
|
68
143
|
authProvider: 'better-auth',
|
|
69
144
|
ssoProvider: 'none',
|
|
70
145
|
paymentProvider: 'stripe',
|
|
@@ -135,7 +210,7 @@ function parsePresetValue(raw) {
|
|
|
135
210
|
}
|
|
136
211
|
return { ...base, ...result };
|
|
137
212
|
}
|
|
138
|
-
function resolvePreset(raw) {
|
|
213
|
+
export function resolvePreset(raw) {
|
|
139
214
|
const overrides = parsePresetValue(raw);
|
|
140
215
|
const config = { ...DEFAULT_CONFIG, ...overrides };
|
|
141
216
|
if (config.authProvider === 'none') {
|
|
@@ -150,6 +225,9 @@ function resolvePreset(raw) {
|
|
|
150
225
|
}
|
|
151
226
|
return config;
|
|
152
227
|
}
|
|
228
|
+
export function getPresetNames() {
|
|
229
|
+
return Object.keys(BUILT_IN_PRESETS);
|
|
230
|
+
}
|
|
153
231
|
// All app-router paths are under `src/app/[locale]/...` (next-intl).
|
|
154
232
|
// API routes (`src/app/api/...`) and `src/lib`/`src/components` paths
|
|
155
233
|
// are NOT under [locale].
|
|
@@ -451,7 +529,7 @@ const MODULE_REMOVALS = [
|
|
|
451
529
|
{
|
|
452
530
|
key: 'enableReports',
|
|
453
531
|
paths: [
|
|
454
|
-
`${APP}/(dashboard)/dashboard/reports`,
|
|
532
|
+
`${APP}/(protected)/(dashboard)/dashboard/reports`,
|
|
455
533
|
'src/app/api/reports',
|
|
456
534
|
'src/lib/scheduled-reports',
|
|
457
535
|
'src/components/dashboard/ReportSchedules.tsx',
|
|
@@ -539,6 +617,7 @@ const PRUNE_MARKER_FILES = [
|
|
|
539
617
|
'src/app/sitemap.ts',
|
|
540
618
|
'src/app/sitemap.test.ts',
|
|
541
619
|
'src/app/(marketing)/llms.txt/route.ts',
|
|
620
|
+
'src/app/api/checkout/route.ts',
|
|
542
621
|
'src/components/marketing/Footer.tsx',
|
|
543
622
|
'src/lib/auth/index.ts',
|
|
544
623
|
'src/lib/auth/client-adapter.ts',
|
|
@@ -548,20 +627,18 @@ const PRUNE_MARKER_FILES = [
|
|
|
548
627
|
'src/lib/scheduled-reports/index.ts',
|
|
549
628
|
'src/lib/guards.ts',
|
|
550
629
|
'src/lib/guards.test.ts',
|
|
630
|
+
'src/lib/auth/adapters/better-auth.ts',
|
|
551
631
|
'src/config/marketing.test.ts',
|
|
552
632
|
'src/config/env-schema.ts',
|
|
553
633
|
'src/instrumentation.ts',
|
|
634
|
+
'src/proxy.ts',
|
|
554
635
|
];
|
|
555
|
-
function
|
|
556
|
-
|
|
557
|
-
const envLocalPath = join(root, ENV_FILE_NAME);
|
|
558
|
-
if (existsSync(envLocalPath)) {
|
|
559
|
-
info(`${ENV_FILE_NAME} already exists — creating ${ENV_FILE_NAME}.new instead`);
|
|
560
|
-
}
|
|
561
|
-
let content = existsSync(envExamplePath) ? readFileSync(envExamplePath, 'utf-8') : '';
|
|
636
|
+
export function buildEnvContent(content, config) {
|
|
637
|
+
let result = content;
|
|
562
638
|
const replacements = {
|
|
563
639
|
NEXT_PUBLIC_APP_NAME: config.appName,
|
|
564
640
|
NEXT_PUBLIC_APP_URL: config.appUrl,
|
|
641
|
+
APP_MODE: config.appMode,
|
|
565
642
|
AUTH_PROVIDER: config.authProvider,
|
|
566
643
|
PAYMENT_PROVIDER: config.paymentProvider,
|
|
567
644
|
STORAGE_PROVIDER: config.storageProvider,
|
|
@@ -574,13 +651,23 @@ function generateEnvFile(root, config) {
|
|
|
574
651
|
}
|
|
575
652
|
for (const [key, value] of Object.entries(replacements)) {
|
|
576
653
|
const regex = new RegExp(`^${key}=.*$`, 'm');
|
|
577
|
-
if (regex.test(
|
|
578
|
-
|
|
654
|
+
if (regex.test(result)) {
|
|
655
|
+
result = result.replace(regex, `${key}=${value}`);
|
|
579
656
|
}
|
|
580
657
|
else {
|
|
581
|
-
|
|
658
|
+
result += `\n${key}=${value}`;
|
|
582
659
|
}
|
|
583
660
|
}
|
|
661
|
+
return result;
|
|
662
|
+
}
|
|
663
|
+
function generateEnvFile(root, config) {
|
|
664
|
+
const envExamplePath = join(root, ENV_EXAMPLE_FILE_NAME);
|
|
665
|
+
const envLocalPath = join(root, ENV_FILE_NAME);
|
|
666
|
+
if (existsSync(envLocalPath)) {
|
|
667
|
+
info(`${ENV_FILE_NAME} already exists — creating ${ENV_FILE_NAME}.new instead`);
|
|
668
|
+
}
|
|
669
|
+
const exampleContent = existsSync(envExamplePath) ? readFileSync(envExamplePath, 'utf-8') : '';
|
|
670
|
+
const content = buildEnvContent(exampleContent, config);
|
|
584
671
|
const outputPath = existsSync(envLocalPath) ? `${envLocalPath}.new` : envLocalPath;
|
|
585
672
|
writeFileSync(outputPath, content, 'utf-8');
|
|
586
673
|
success(`Written to ${relative(root, outputPath)}`);
|
|
@@ -736,6 +823,7 @@ async function interactiveSetup() {
|
|
|
736
823
|
const config = {
|
|
737
824
|
appName,
|
|
738
825
|
appUrl,
|
|
826
|
+
appMode: 'app',
|
|
739
827
|
authProvider,
|
|
740
828
|
ssoProvider,
|
|
741
829
|
paymentProvider: await selectPrompt(iface, 'Payment provider:', ['stripe', 'lemonsqueezy', 'polar']),
|
package/dist/commands/update.js
CHANGED
|
@@ -49,35 +49,9 @@ function getCurrentVersion(cwd) {
|
|
|
49
49
|
const tag = execQuiet(['describe', '--tags', '--abbrev=0'], cwd);
|
|
50
50
|
return tag || '(no version tag)';
|
|
51
51
|
}
|
|
52
|
-
|
|
53
|
-
'src/config/app.ts',
|
|
54
|
-
'src/config/navigation.ts',
|
|
55
|
-
'src/config/marketing.ts',
|
|
56
|
-
'src/app/globals.css',
|
|
57
|
-
'messages/',
|
|
58
|
-
'content/',
|
|
59
|
-
'.env',
|
|
60
|
-
];
|
|
61
|
-
function classifyConflicts(cwd) {
|
|
52
|
+
function getConflictFiles(cwd) {
|
|
62
53
|
const raw = execQuiet(['diff', '--name-only', '--diff-filter=U'], cwd);
|
|
63
|
-
|
|
64
|
-
return { safe: [], caution: [], core: [] };
|
|
65
|
-
const files = raw.split('\n').filter(Boolean);
|
|
66
|
-
const safe = [];
|
|
67
|
-
const caution = [];
|
|
68
|
-
const core = [];
|
|
69
|
-
for (const file of files) {
|
|
70
|
-
if (SAFE_ZONE_PATTERNS.some((p) => file.startsWith(p))) {
|
|
71
|
-
safe.push(file);
|
|
72
|
-
}
|
|
73
|
-
else if (file === 'pnpm-lock.yaml' || file === 'package.json' || file.endsWith('schema.ts')) {
|
|
74
|
-
caution.push(file);
|
|
75
|
-
}
|
|
76
|
-
else {
|
|
77
|
-
core.push(file);
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
return { safe, caution, core };
|
|
54
|
+
return raw ? raw.split('\n').filter(Boolean) : [];
|
|
81
55
|
}
|
|
82
56
|
export async function updateCommand(version, options) {
|
|
83
57
|
const root = checkProjectRoot('exit');
|
|
@@ -147,30 +121,11 @@ export async function updateCommand(version, options) {
|
|
|
147
121
|
catch {
|
|
148
122
|
warn('Merge conflicts detected.');
|
|
149
123
|
console.log();
|
|
150
|
-
const
|
|
151
|
-
if (
|
|
152
|
-
info('
|
|
153
|
-
for (const
|
|
154
|
-
dim(` ${
|
|
155
|
-
console.log();
|
|
156
|
-
}
|
|
157
|
-
if (caution.length > 0) {
|
|
158
|
-
warn('Caution-zone conflicts (review carefully):');
|
|
159
|
-
for (const f of caution) {
|
|
160
|
-
dim(` ${f}`);
|
|
161
|
-
if (f === 'pnpm-lock.yaml') {
|
|
162
|
-
dim(' → Resolve: accept either side, then run pnpm install');
|
|
163
|
-
}
|
|
164
|
-
else if (f.endsWith('schema.ts')) {
|
|
165
|
-
dim(' → Resolve: merge both column additions, then pnpm db:push');
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
console.log();
|
|
169
|
-
}
|
|
170
|
-
if (core.length > 0) {
|
|
171
|
-
info('Core conflicts (review the upstream changes):');
|
|
172
|
-
for (const f of core)
|
|
173
|
-
dim(` ${f}`);
|
|
124
|
+
const conflicts = getConflictFiles(root);
|
|
125
|
+
if (conflicts.length > 0) {
|
|
126
|
+
info('Files requiring manual conflict resolution:');
|
|
127
|
+
for (const file of conflicts)
|
|
128
|
+
dim(` ${file}`);
|
|
174
129
|
console.log();
|
|
175
130
|
}
|
|
176
131
|
info('After resolving conflicts:');
|
package/dist/index.js
CHANGED
|
@@ -3,10 +3,11 @@ import { Command } from 'commander';
|
|
|
3
3
|
import { createRequire } from 'node:module';
|
|
4
4
|
import pc from 'picocolors';
|
|
5
5
|
import { setupCommand } from './commands/setup.js';
|
|
6
|
+
import { recipeApplyCommand, recipeListCommand, recipeShowCommand } from './commands/recipes.js';
|
|
6
7
|
import { updateCommand } from './commands/update.js';
|
|
7
8
|
import { doctorCommand } from './commands/doctor.js';
|
|
8
9
|
import { configShowCommand } from './commands/config-show.js';
|
|
9
|
-
import { pluginsAddCommand, pluginsRemoveCommand, pluginsListCommand, pluginsMigrateCommand, } from './commands/plugins.js';
|
|
10
|
+
import { pluginsAddCommand, pluginsRemoveCommand, pluginsListCommand, pluginsMigrateCommand, pluginsCheckCommand, } from './commands/plugins.js';
|
|
10
11
|
import { generatePageCommand, generateApiCommand, generateActionCommand, generatePluginCommand, } from './commands/generate.js';
|
|
11
12
|
import { dbPushCommand, dbGenerateCommand, dbSeedCommand, dbStudioCommand, dbStatusCommand, dbLiveDiffCommand, dbSchemaDiffCommand, } from './commands/db.js';
|
|
12
13
|
import { envCheckCommand, envSyncCommand } from './commands/env.js';
|
|
@@ -37,6 +38,17 @@ program
|
|
|
37
38
|
.option('--preset <value>', 'apply a preset non-interactively (name, key=value pairs, or both)')
|
|
38
39
|
.option('--no-env-file', `do not create ${ENV_FILE_NAME}; read env vars from process.env instead`)
|
|
39
40
|
.action(setupCommand);
|
|
41
|
+
const recipe = program
|
|
42
|
+
.commandsGroup('Project')
|
|
43
|
+
.command('recipe')
|
|
44
|
+
.description('show or apply a Codapult starter recipe');
|
|
45
|
+
recipe.command('list').description('list starter recipes').action(recipeListCommand);
|
|
46
|
+
recipe.command('show <name>').description('show a recipe').action(recipeShowCommand);
|
|
47
|
+
recipe
|
|
48
|
+
.command('apply <name>')
|
|
49
|
+
.description('apply a recipe to the current project')
|
|
50
|
+
.option('--no-env-file', `do not create ${ENV_FILE_NAME}`)
|
|
51
|
+
.action(recipeApplyCommand);
|
|
40
52
|
program
|
|
41
53
|
.command('update [version]')
|
|
42
54
|
.description(`update from upstream ${config.projectName} releases`)
|
|
@@ -61,6 +73,10 @@ plugins
|
|
|
61
73
|
.option('--push', 'use db:push instead of db:generate + db:migrate (dev mode)')
|
|
62
74
|
.action(pluginsMigrateCommand);
|
|
63
75
|
plugins.command('list').description('list installed plugins').action(pluginsListCommand);
|
|
76
|
+
plugins
|
|
77
|
+
.command('check [name]')
|
|
78
|
+
.description('check plugin install compatibility without changing files')
|
|
79
|
+
.action(pluginsCheckCommand);
|
|
64
80
|
const generate = program
|
|
65
81
|
.commandsGroup('Code Generation')
|
|
66
82
|
.command('generate')
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { createRequire } from 'node:module';
|
|
2
|
+
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
3
|
+
import { registerGuardTools } from '@codapult/guard/mcp';
|
|
4
|
+
import { registerGuardPrompts } from '@codapult/guard/mcp/prompts';
|
|
5
|
+
import { registerGuardResources } from '@codapult/guard/mcp/resources';
|
|
6
|
+
import { registerProjectTools } from './tools/project.js';
|
|
7
|
+
import { registerDbTools } from './tools/db.js';
|
|
8
|
+
import { registerEnvTools } from './tools/env.js';
|
|
9
|
+
import { registerPluginTools } from './tools/plugins.js';
|
|
10
|
+
import { registerGenerateTools } from './tools/generate.js';
|
|
11
|
+
import { registerDeployTools } from './tools/deploy.js';
|
|
12
|
+
import { registerPrompts } from './prompts.js';
|
|
13
|
+
import { registerResources } from './resources.js';
|
|
14
|
+
const require = createRequire(import.meta.url);
|
|
15
|
+
const packageJson = require('../../package.json');
|
|
16
|
+
/** Create the complete Codapult MCP server, including the integrated Guard surface. */
|
|
17
|
+
export function createMcpServer() {
|
|
18
|
+
const server = new McpServer({
|
|
19
|
+
name: 'codapult',
|
|
20
|
+
version: packageJson.version,
|
|
21
|
+
});
|
|
22
|
+
registerProjectTools(server);
|
|
23
|
+
registerDbTools(server);
|
|
24
|
+
registerEnvTools(server);
|
|
25
|
+
registerPluginTools(server);
|
|
26
|
+
registerGenerateTools(server);
|
|
27
|
+
registerDeployTools(server);
|
|
28
|
+
registerPrompts(server);
|
|
29
|
+
registerResources(server);
|
|
30
|
+
registerGuardTools(server);
|
|
31
|
+
registerGuardPrompts(server);
|
|
32
|
+
registerGuardResources(server);
|
|
33
|
+
return server;
|
|
34
|
+
}
|
package/dist/mcp/server.js
CHANGED
|
@@ -1,33 +1,4 @@
|
|
|
1
|
-
import { createRequire } from 'node:module';
|
|
2
|
-
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
3
1
|
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
|
|
4
|
-
import {
|
|
5
|
-
import { registerDbTools } from './tools/db.js';
|
|
6
|
-
import { registerEnvTools } from './tools/env.js';
|
|
7
|
-
import { registerPluginTools } from './tools/plugins.js';
|
|
8
|
-
import { registerGenerateTools } from './tools/generate.js';
|
|
9
|
-
import { registerDeployTools } from './tools/deploy.js';
|
|
10
|
-
import { registerPrompts } from './prompts.js';
|
|
11
|
-
import { registerResources } from './resources.js';
|
|
12
|
-
import { registerGuardTools } from '@codapult/guard/mcp';
|
|
13
|
-
import { registerGuardPrompts } from '@codapult/guard/mcp/prompts';
|
|
14
|
-
import { registerGuardResources } from '@codapult/guard/mcp/resources';
|
|
15
|
-
const require = createRequire(import.meta.url);
|
|
16
|
-
const packageJson = require('../../package.json');
|
|
17
|
-
const server = new McpServer({
|
|
18
|
-
name: 'codapult',
|
|
19
|
-
version: packageJson.version,
|
|
20
|
-
});
|
|
21
|
-
registerProjectTools(server);
|
|
22
|
-
registerDbTools(server);
|
|
23
|
-
registerEnvTools(server);
|
|
24
|
-
registerPluginTools(server);
|
|
25
|
-
registerGenerateTools(server);
|
|
26
|
-
registerDeployTools(server);
|
|
27
|
-
registerPrompts(server);
|
|
28
|
-
registerResources(server);
|
|
29
|
-
registerGuardTools(server);
|
|
30
|
-
registerGuardPrompts(server);
|
|
31
|
-
registerGuardResources(server);
|
|
2
|
+
import { createMcpServer } from './server-factory.js';
|
|
32
3
|
const transport = new StdioServerTransport();
|
|
33
|
-
await
|
|
4
|
+
await createMcpServer().connect(transport);
|
|
@@ -2,6 +2,7 @@ import { existsSync, mkdirSync, writeFileSync } from 'node:fs';
|
|
|
2
2
|
import { resolve, dirname } from 'node:path';
|
|
3
3
|
import { z } from 'zod';
|
|
4
4
|
import { checkProjectRoot } from '../../utils/project.js';
|
|
5
|
+
import { dashboardPagePath } from '../../utils/project-paths.js';
|
|
5
6
|
import { validateGeneratedName } from '../../utils/validation.js';
|
|
6
7
|
function toKebab(name) {
|
|
7
8
|
return name
|
|
@@ -40,7 +41,7 @@ export function registerGenerateTools(server) {
|
|
|
40
41
|
const kebab = toKebab(name);
|
|
41
42
|
const pascal = toPascal(name);
|
|
42
43
|
const title = pascal.replace(/([A-Z])/g, ' $1').trim();
|
|
43
|
-
const path =
|
|
44
|
+
const path = dashboardPagePath(kebab);
|
|
44
45
|
if (dry_run) {
|
|
45
46
|
return {
|
|
46
47
|
content: [
|
package/dist/utils/manifest.d.ts
CHANGED
|
@@ -8,6 +8,8 @@ export interface PluginManifest {
|
|
|
8
8
|
package: string;
|
|
9
9
|
version: string;
|
|
10
10
|
description: string;
|
|
11
|
+
/** Version of the Codapult plugin contract, independent of the app version. */
|
|
12
|
+
apiVersion?: number;
|
|
11
13
|
install: {
|
|
12
14
|
schemaImports?: string[];
|
|
13
15
|
schemaImportsPg?: string[];
|
|
@@ -22,6 +24,13 @@ export interface PluginManifest {
|
|
|
22
24
|
optionalDeps?: Record<string, string>;
|
|
23
25
|
};
|
|
24
26
|
}
|
|
27
|
+
export declare const CURRENT_PLUGIN_API_VERSION = 1;
|
|
28
|
+
export interface PluginCompatibilityIssue {
|
|
29
|
+
code: 'unsupported-api-version' | 'missing-install-file';
|
|
30
|
+
message: string;
|
|
31
|
+
}
|
|
32
|
+
/** Check the stable install contract before the CLI mutates the host project. */
|
|
33
|
+
export declare function getPluginCompatibilityIssues(manifest: PluginManifest, pluginDir: string): PluginCompatibilityIssue[];
|
|
25
34
|
export declare function resolveManifest(projectRoot: string, nameOrPath: string): {
|
|
26
35
|
manifest: PluginManifest;
|
|
27
36
|
pluginDir: string;
|
package/dist/utils/manifest.js
CHANGED
|
@@ -3,6 +3,7 @@ import { resolve, join, isAbsolute, relative } from 'node:path';
|
|
|
3
3
|
import { z } from 'zod';
|
|
4
4
|
import { getCacheDir } from './git.js';
|
|
5
5
|
const MANIFEST_FILENAME = 'codapult-plugin.json';
|
|
6
|
+
export const CURRENT_PLUGIN_API_VERSION = 1;
|
|
6
7
|
const nonEmptyString = z.string().trim().min(1);
|
|
7
8
|
const packageName = z.string().regex(/^@?[A-Za-z0-9._-]+(?:\/[A-Za-z0-9._-]+)?$/);
|
|
8
9
|
const relativePluginPath = nonEmptyString.refine((value) => !isAbsolute(value) && !value.split(/[\\/]+/).includes('..'), 'Plugin paths must stay inside the plugin directory');
|
|
@@ -11,6 +12,7 @@ const pluginManifestSchema = z.object({
|
|
|
11
12
|
package: packageName,
|
|
12
13
|
version: nonEmptyString,
|
|
13
14
|
description: z.string(),
|
|
15
|
+
apiVersion: z.number().int().positive().default(CURRENT_PLUGIN_API_VERSION),
|
|
14
16
|
install: z
|
|
15
17
|
.object({
|
|
16
18
|
schemaImports: z.array(nonEmptyString).optional(),
|
|
@@ -34,6 +36,34 @@ const pluginManifestSchema = z.object({
|
|
|
34
36
|
})
|
|
35
37
|
.default({}),
|
|
36
38
|
});
|
|
39
|
+
/** Check the stable install contract before the CLI mutates the host project. */
|
|
40
|
+
export function getPluginCompatibilityIssues(manifest, pluginDir) {
|
|
41
|
+
const issues = [];
|
|
42
|
+
const apiVersion = manifest.apiVersion ?? CURRENT_PLUGIN_API_VERSION;
|
|
43
|
+
if (apiVersion !== CURRENT_PLUGIN_API_VERSION) {
|
|
44
|
+
issues.push({
|
|
45
|
+
code: 'unsupported-api-version',
|
|
46
|
+
message: 'Plugin "' +
|
|
47
|
+
manifest.name +
|
|
48
|
+
'" uses plugin API v' +
|
|
49
|
+
String(apiVersion) +
|
|
50
|
+
'; this CLI supports v' +
|
|
51
|
+
String(CURRENT_PLUGIN_API_VERSION) +
|
|
52
|
+
'.',
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
for (const relativeFile of [manifest.install.schemaTables, manifest.install.schemaTablesPg]) {
|
|
56
|
+
if (relativeFile == null)
|
|
57
|
+
continue;
|
|
58
|
+
if (!existsSync(resolve(pluginDir, relativeFile))) {
|
|
59
|
+
issues.push({
|
|
60
|
+
code: 'missing-install-file',
|
|
61
|
+
message: 'Plugin "' + manifest.name + '" references a missing install file: ' + relativeFile,
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
return issues;
|
|
66
|
+
}
|
|
37
67
|
function realPathOrOriginal(path) {
|
|
38
68
|
try {
|
|
39
69
|
const resolved = realpathSync(path);
|
package/dist/utils/patchers.js
CHANGED
|
@@ -47,8 +47,10 @@ function patchSchemaImportsAtPath(projectRoot, pluginName, imports, action, sche
|
|
|
47
47
|
if (idx === -1)
|
|
48
48
|
continue;
|
|
49
49
|
// Check if the symbol is used outside the import line itself
|
|
50
|
-
const usagePattern = new RegExp(
|
|
51
|
-
const contentAfterImport = contentWithoutThisPlugin
|
|
50
|
+
const usagePattern = new RegExp(`(?<![.\\w])${imp}\\b`);
|
|
51
|
+
const contentAfterImport = contentWithoutThisPlugin
|
|
52
|
+
.replace(importLine[0], '')
|
|
53
|
+
.replace(/\/\*[\\s\\S]*?\*\/|\/\/.*$/gm, '');
|
|
52
54
|
if (!usagePattern.test(contentAfterImport)) {
|
|
53
55
|
existing.splice(idx, 1);
|
|
54
56
|
}
|
|
@@ -73,7 +75,7 @@ function extractMarkedBlock(content, name) {
|
|
|
73
75
|
return undefined;
|
|
74
76
|
return content.slice(startIdx + start.length, endIdx);
|
|
75
77
|
}
|
|
76
|
-
function readPluginTables(pluginDir, tablesFile) {
|
|
78
|
+
function readPluginTables(pluginDir, pluginName, tablesFile) {
|
|
77
79
|
const resolvedPlugin = resolve(pluginDir);
|
|
78
80
|
const tablesPath = resolve(pluginDir, tablesFile);
|
|
79
81
|
const rel = relative(resolvedPlugin, tablesPath);
|
|
@@ -83,11 +85,19 @@ function readPluginTables(pluginDir, tablesFile) {
|
|
|
83
85
|
if (!existsSync(tablesPath))
|
|
84
86
|
return undefined;
|
|
85
87
|
let tables = readFileSync(tablesPath, 'utf-8');
|
|
86
|
-
// Strip
|
|
87
|
-
|
|
88
|
-
//
|
|
89
|
-
|
|
90
|
-
tables = tables.replace(/^(
|
|
88
|
+
// Strip runtime imports — host schema already provides the Drizzle and DB
|
|
89
|
+
// imports. Keep type imports, but point them at the installed plugin's
|
|
90
|
+
// public entrypoints because relative paths no longer resolve from the host
|
|
91
|
+
// schema file.
|
|
92
|
+
tables = tables.replace(/^import(?!\s+type\b)\s+.*;\s*\n/gm, '');
|
|
93
|
+
const packageName = `@codapult/plugin-${pluginName}`;
|
|
94
|
+
tables = tables.replace(/from\s+['"](\.\.?\/[^'"]+)['"]/g, (_match, importPath) => {
|
|
95
|
+
const exportName = importPath === './tables' ? 'schema' : importPath.split('/')[1];
|
|
96
|
+
return exportName ? `from '${packageName}/${exportName}'` : _match;
|
|
97
|
+
});
|
|
98
|
+
// Keep type/interface declarations: table definitions may use them in
|
|
99
|
+
// `$type<...>()`, so removing them makes the generated host schema fail
|
|
100
|
+
// type-checking after plugin installation.
|
|
91
101
|
return tables.trim();
|
|
92
102
|
}
|
|
93
103
|
function patchSchemaTablesAtPath(projectRoot, pluginName, pluginDir, tablesFile, action, schemaPath) {
|
|
@@ -102,7 +112,7 @@ function patchSchemaTablesAtPath(projectRoot, pluginName, pluginDir, tablesFile,
|
|
|
102
112
|
}
|
|
103
113
|
if (action === 'add' && hasMarker(content, pluginName))
|
|
104
114
|
return false;
|
|
105
|
-
const tables = readPluginTables(pluginDir, tablesFile);
|
|
115
|
+
const tables = readPluginTables(pluginDir, pluginName, tablesFile);
|
|
106
116
|
if (!tables)
|
|
107
117
|
return false;
|
|
108
118
|
if (action === 'update') {
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Paths owned by the Codapult template.
|
|
3
|
+
*
|
|
4
|
+
* Route groups are part of the template contract even though they do not
|
|
5
|
+
* appear in public URLs. Keep generators and plugin manifests on the same
|
|
6
|
+
* route layout as the template itself.
|
|
7
|
+
*/
|
|
8
|
+
export declare function dashboardPagePath(name: string): string;
|
|
9
|
+
export declare function dashboardPageManifestPath(name: string): string;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Paths owned by the Codapult template.
|
|
3
|
+
*
|
|
4
|
+
* Route groups are part of the template contract even though they do not
|
|
5
|
+
* appear in public URLs. Keep generators and plugin manifests on the same
|
|
6
|
+
* route layout as the template itself.
|
|
7
|
+
*/
|
|
8
|
+
export function dashboardPagePath(name) {
|
|
9
|
+
return `src/app/[locale]/(protected)/(dashboard)/dashboard/${name}/page.tsx`;
|
|
10
|
+
}
|
|
11
|
+
export function dashboardPageManifestPath(name) {
|
|
12
|
+
return dashboardPagePath(name);
|
|
13
|
+
}
|
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@codapult/cli",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "0.21.1",
|
|
4
|
+
"description": "Next.js SaaS CLI and MCP server for Codapult boilerplate projects, with setup, plugins, database, deployment, and AI-agent architecture guardrails",
|
|
5
5
|
"license": "MIT",
|
|
6
|
-
"packageManager": "pnpm@
|
|
6
|
+
"packageManager": "pnpm@12.14.0+sha512.c18ba6d87993d3d164cb5e8948f32b2c06ee854487e06cd8d86781342fb3e5bb4634367034711e86802baa9c37bea906ce1929ad08d70884c97d801df13389a6",
|
|
7
7
|
"engines": {
|
|
8
8
|
"node": ">=20.19.0"
|
|
9
9
|
},
|
|
@@ -24,6 +24,7 @@
|
|
|
24
24
|
"format:check": "prettier --check .",
|
|
25
25
|
"release:check": "pnpm lint && pnpm format:check && pnpm typecheck && pnpm test && pnpm build && npm pack --dry-run",
|
|
26
26
|
"test": "vitest run",
|
|
27
|
+
"test:golden": "pnpm build && pnpm --dir ../codapult-create build && node scripts/golden-path.mjs",
|
|
27
28
|
"test:coverage": "vitest run --coverage",
|
|
28
29
|
"test:watch": "vitest",
|
|
29
30
|
"typecheck": "tsc --noEmit",
|
|
@@ -34,8 +35,17 @@
|
|
|
34
35
|
"codapult",
|
|
35
36
|
"saas",
|
|
36
37
|
"boilerplate",
|
|
38
|
+
"saas boilerplate",
|
|
39
|
+
"nextjs boilerplate",
|
|
40
|
+
"next.js boilerplate",
|
|
41
|
+
"starter-kit",
|
|
42
|
+
"saas starter kit",
|
|
43
|
+
"nextjs-saas",
|
|
44
|
+
"next.js saas",
|
|
45
|
+
"saas-starter",
|
|
37
46
|
"cli",
|
|
38
47
|
"nextjs",
|
|
48
|
+
"next.js",
|
|
39
49
|
"mcp",
|
|
40
50
|
"ai-agents",
|
|
41
51
|
"architecture",
|
|
@@ -52,12 +62,12 @@
|
|
|
52
62
|
"access": "public"
|
|
53
63
|
},
|
|
54
64
|
"dependencies": {
|
|
55
|
-
"@codapult/guard": "^0.
|
|
56
|
-
"@modelcontextprotocol/sdk": "^1.
|
|
65
|
+
"@codapult/guard": "^0.10.0",
|
|
66
|
+
"@modelcontextprotocol/sdk": "^1.32.1",
|
|
57
67
|
"commander": "^15.0.0",
|
|
58
68
|
"picocolors": "^1.1.1",
|
|
59
69
|
"typescript": "npm:@typescript/typescript6@^6.0.2",
|
|
60
|
-
"zod": "^4.6.
|
|
70
|
+
"zod": "^4.6.7"
|
|
61
71
|
},
|
|
62
72
|
"devDependencies": {
|
|
63
73
|
"@js-toolkit/config-utils": "^1.0.1",
|
|
@@ -65,15 +75,15 @@
|
|
|
65
75
|
"@js-toolkit/prettier-config": "^1.0.1",
|
|
66
76
|
"@js-toolkit/tsconfig": "^1.0.1",
|
|
67
77
|
"@release-it/conventional-changelog": "^12.0.2",
|
|
68
|
-
"@types/node": "^26.6.
|
|
78
|
+
"@types/node": "^26.6.5",
|
|
69
79
|
"@typescript/native": "npm:typescript@^7.0.2",
|
|
70
|
-
"@vitest/coverage-v8": "^5.0.
|
|
71
|
-
"eslint": "^10.
|
|
80
|
+
"@vitest/coverage-v8": "^5.0.5",
|
|
81
|
+
"eslint": "^10.13.0",
|
|
72
82
|
"eslint-config-prettier": "^10.1.8",
|
|
73
|
-
"eslint-plugin-prettier": "^5.5.
|
|
74
|
-
"prettier": "^3.9.
|
|
75
|
-
"release-it": "^21.1.
|
|
76
|
-
"typescript-eslint": "^8.
|
|
77
|
-
"vitest": "^5.0.
|
|
83
|
+
"eslint-plugin-prettier": "^5.5.7",
|
|
84
|
+
"prettier": "^3.9.10",
|
|
85
|
+
"release-it": "^21.1.1",
|
|
86
|
+
"typescript-eslint": "^8.71.2",
|
|
87
|
+
"vitest": "^5.0.5"
|
|
78
88
|
}
|
|
79
89
|
}
|