@prisma-next/cli 0.8.0-dev.3 → 0.8.0-dev.5
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/cli.mjs +3 -3
- package/dist/cli.mjs.map +1 -1
- package/dist/commands/migration-new.d.mts.map +1 -1
- package/dist/commands/migration-new.mjs +17 -16
- package/dist/commands/migration-new.mjs.map +1 -1
- package/dist/commands/migration-plan.d.mts.map +1 -1
- package/dist/commands/migration-plan.mjs +1 -1
- package/dist/exports/init-output.mjs +1 -1
- package/dist/{init-CVBXQidr.mjs → init-1-s6FvGv.mjs} +99 -52
- package/dist/init-1-s6FvGv.mjs.map +1 -0
- package/dist/{migration-plan-q1pPoOCf.mjs → migration-plan-DTwYi61q.mjs} +29 -5
- package/dist/migration-plan-DTwYi61q.mjs.map +1 -0
- package/dist/{output-nBJ6NvsE.mjs → output-DEg3SSnJ.mjs} +2 -2
- package/dist/{output-nBJ6NvsE.mjs.map → output-DEg3SSnJ.mjs.map} +1 -1
- package/dist/types-LItU7E4l.d.mts.map +1 -1
- package/package.json +17 -17
- package/src/commands/init/agent-skill-install.ts +112 -41
- package/src/commands/init/errors.ts +2 -2
- package/src/commands/init/exit-codes.ts +2 -2
- package/src/commands/init/index.ts +1 -1
- package/src/commands/init/init.ts +12 -6
- package/src/commands/init/inputs.ts +1 -1
- package/src/commands/init/output.ts +2 -2
- package/src/commands/migration-new.ts +17 -9
- package/src/commands/migration-plan.ts +36 -4
- package/src/control-api/types.ts +1 -2
- package/dist/init-CVBXQidr.mjs.map +0 -1
- package/dist/migration-plan-q1pPoOCf.mjs.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"output-
|
|
1
|
+
{"version":3,"file":"output-DEg3SSnJ.mjs","names":[],"sources":["../src/commands/init/output.ts"],"sourcesContent":["import { type } from 'arktype';\nimport type { GlobalFlags } from '../../utils/global-flags';\nimport type { TerminalUI } from '../../utils/terminal-ui';\n\n/**\n * arktype schema for the structured success document `init --json` writes\n * to stdout (FR1.5). The same shape backs the human-readable outro\n * renderer (FR10), so the two output modes carry identical information.\n *\n * `target` is normalised to the user-facing flag value (`mongodb` rather\n * than the internal `mongo`) so consumers can round-trip the document\n * straight into a follow-up `--target` invocation.\n *\n * The `ok: true` literal is the documented success/error discriminator —\n * see [Style Guide § JSON Semantics](../../../../../../../docs/CLI%20Style%20Guide.md#json-semantics).\n * Error envelopes (`CliErrorEnvelope`) carry `ok: false` so consumers can\n * branch with `if (doc.ok)` without inspecting the rest of the structure.\n */\nexport const InitOutputSchema = type({\n ok: 'true',\n target: \"'postgres'|'mongodb'\",\n authoring: \"'psl'|'typescript'\",\n schemaPath: 'string',\n filesWritten: 'string[]',\n /**\n * FR9.1 — files removed from disk during this run. Populated only on\n * re-init when previously-emitted contract artefacts (`contract.json`,\n * `contract.d.ts`, `start-/end-contract.*`, `ops.json`,\n * `migration.json`) were left behind by an earlier run. Empty on a\n * green-field init.\n */\n filesDeleted: 'string[]',\n packagesInstalled: {\n skipped: 'boolean',\n deps: 'string[]',\n devDeps: 'string[]',\n },\n contractEmitted: 'boolean',\n nextSteps: 'string[]',\n warnings: 'string[]',\n});\n\nexport type InitOutput = typeof InitOutputSchema.infer;\n\n/**\n * Serialises the output document for `--json`. Sorted keys are not enforced\n * — `JSON.stringify` preserves insertion order, and the schema field order\n * is the documented order, which matches what users will see when they\n * `jq .` the result.\n */\nexport function formatInitJson(output: InitOutput): string {\n return JSON.stringify(output, null, 2);\n}\n\n/**\n * Renders the human-readable outro on stderr (FR10.1). Re-uses the same\n * data structure as the JSON output so the two stay in lock-step.\n *\n * Warnings come before \"Next steps\" because they describe state the user\n * needs to be aware of before acting on the next-steps list.\n */\nexport function renderInitOutro(ui: TerminalUI, output: InitOutput, flags: GlobalFlags): void {\n if (flags.quiet || flags.json) {\n return;\n }\n\n for (const warning of output.warnings) {\n ui.warn(warning);\n }\n\n const lines: string[] = [];\n lines.push(`Target: ${output.target}`);\n lines.push(`Authoring: ${output.authoring}`);\n lines.push(`Schema: ${output.schemaPath}`);\n lines.push('');\n lines.push('Files written:');\n for (const file of output.filesWritten) {\n lines.push(` • ${file}`);\n }\n\n if (output.filesDeleted.length > 0) {\n lines.push('');\n lines.push('Files deleted (stale contract artefacts):');\n for (const file of output.filesDeleted) {\n lines.push(` • ${file}`);\n }\n }\n\n if (!output.packagesInstalled.skipped) {\n lines.push('');\n lines.push('Packages installed:');\n for (const dep of output.packagesInstalled.deps) {\n lines.push(` • ${dep}`);\n }\n for (const dep of output.packagesInstalled.devDeps) {\n lines.push(` • ${dep} (dev)`);\n }\n }\n\n lines.push('');\n lines.push('Next steps:');\n for (const step of output.nextSteps) {\n lines.push(` ${step}`);\n }\n\n ui.note(lines.join('\\n'), 'Done');\n}\n\n/**\n * Builds the `nextSteps` array from the resolved scaffold state. Steps are\n * ordered by the workflow a user needs to follow: configure connection →\n * (emit if not yet done) → run a starter query → docs / agent skill.\n *\n * The strings are stable and human-readable; agents wanting to act on them\n * should match on substrings (e.g. \"DATABASE_URL\") rather than exact text,\n * since copy may evolve.\n */\nexport function buildNextSteps(options: {\n readonly target: 'postgres' | 'mongodb';\n readonly contractEmitted: boolean;\n readonly emitCommand: string;\n readonly schemaPath: string;\n /**\n * Whether the project-level Prisma Next skills install actually ran\n * and succeeded during this `init`. When false (the user passed\n * `--no-skill` or `--no-install`, so the install was skipped), the\n * \"registered with your agent runtime\" step is omitted — the skip is\n * already surfaced in the warnings array with a manual-install hint.\n */\n readonly skillRegistered: boolean;\n}): string[] {\n const steps: string[] = [];\n let stepNumber = 1;\n const push = (text: string): void => {\n steps.push(`${stepNumber}. ${text}`);\n stepNumber += 1;\n };\n push('Set DATABASE_URL in your environment (export it or add it to .env).');\n if (!options.contractEmitted) {\n push(`Emit the contract: \\`${options.emitCommand}\\``);\n push(`Edit your schema at ${options.schemaPath}, then re-run the emit command.`);\n } else {\n push(`Edit your schema at ${options.schemaPath}, then re-run \\`${options.emitCommand}\\`.`);\n }\n push('Open prisma-next.md for a quick reference on how to write your first typed query.');\n if (options.skillRegistered) {\n push(\n 'Prisma Next skills are registered with your agent runtime — open the project in your IDE and ask the agent to add a model, run a query, or plan a migration.',\n );\n }\n return steps;\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAkBA,MAAa,mBAAmB,KAAK;CACnC,IAAI;CACJ,QAAQ;CACR,WAAW;CACX,YAAY;CACZ,cAAc;;;;;;;;CAQd,cAAc;CACd,mBAAmB;EACjB,SAAS;EACT,MAAM;EACN,SAAS;EACV;CACD,iBAAiB;CACjB,WAAW;CACX,UAAU;CACX,CAAC;;;;;;;AAUF,SAAgB,eAAe,QAA4B;CACzD,OAAO,KAAK,UAAU,QAAQ,MAAM,EAAE;;;;;;;;;AAUxC,SAAgB,gBAAgB,IAAgB,QAAoB,OAA0B;CAC5F,IAAI,MAAM,SAAS,MAAM,MACvB;CAGF,KAAK,MAAM,WAAW,OAAO,UAC3B,GAAG,KAAK,QAAQ;CAGlB,MAAM,QAAkB,EAAE;CAC1B,MAAM,KAAK,cAAc,OAAO,SAAS;CACzC,MAAM,KAAK,cAAc,OAAO,YAAY;CAC5C,MAAM,KAAK,cAAc,OAAO,aAAa;CAC7C,MAAM,KAAK,GAAG;CACd,MAAM,KAAK,iBAAiB;CAC5B,KAAK,MAAM,QAAQ,OAAO,cACxB,MAAM,KAAK,OAAO,OAAO;CAG3B,IAAI,OAAO,aAAa,SAAS,GAAG;EAClC,MAAM,KAAK,GAAG;EACd,MAAM,KAAK,4CAA4C;EACvD,KAAK,MAAM,QAAQ,OAAO,cACxB,MAAM,KAAK,OAAO,OAAO;;CAI7B,IAAI,CAAC,OAAO,kBAAkB,SAAS;EACrC,MAAM,KAAK,GAAG;EACd,MAAM,KAAK,sBAAsB;EACjC,KAAK,MAAM,OAAO,OAAO,kBAAkB,MACzC,MAAM,KAAK,OAAO,MAAM;EAE1B,KAAK,MAAM,OAAO,OAAO,kBAAkB,SACzC,MAAM,KAAK,OAAO,IAA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14,14 @@
|
|
|
14
14
|
"dependencies": {
|
|
15
15
|
"@clack/prompts": "^1.3.0",
|
|
16
16
|
"@dagrejs/dagre": "^3.0.0",
|
|
17
|
-
"@prisma-next/config": "0.8.0-dev.
|
|
18
|
-
"@prisma-next/contract": "0.8.0-dev.
|
|
19
|
-
"@prisma-next/emitter": "0.8.0-dev.
|
|
20
|
-
"@prisma-next/errors": "0.8.0-dev.
|
|
21
|
-
"@prisma-next/framework-components": "0.8.0-dev.
|
|
22
|
-
"@prisma-next/migration-tools": "0.8.0-dev.
|
|
23
|
-
"@prisma-next/psl-printer": "0.8.0-dev.
|
|
24
|
-
"@prisma-next/utils": "0.8.0-dev.
|
|
17
|
+
"@prisma-next/config": "0.8.0-dev.5",
|
|
18
|
+
"@prisma-next/contract": "0.8.0-dev.5",
|
|
19
|
+
"@prisma-next/emitter": "0.8.0-dev.5",
|
|
20
|
+
"@prisma-next/errors": "0.8.0-dev.5",
|
|
21
|
+
"@prisma-next/framework-components": "0.8.0-dev.5",
|
|
22
|
+
"@prisma-next/migration-tools": "0.8.0-dev.5",
|
|
23
|
+
"@prisma-next/psl-printer": "0.8.0-dev.5",
|
|
24
|
+
"@prisma-next/utils": "0.8.0-dev.5",
|
|
25
25
|
"arktype": "^2.1.29",
|
|
26
26
|
"c12": "^3.3.4",
|
|
27
27
|
"clipanion": "4.0.0-rc.4",
|
|
@@ -37,14 +37,14 @@
|
|
|
37
37
|
"wrap-ansi": "^10.0.0"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
|
-
"@prisma-next/sql-contract": "0.8.0-dev.
|
|
41
|
-
"@prisma-next/sql-contract-emitter": "0.8.0-dev.
|
|
42
|
-
"@prisma-next/sql-contract-ts": "0.8.0-dev.
|
|
43
|
-
"@prisma-next/sql-operations": "0.8.0-dev.
|
|
44
|
-
"@prisma-next/sql-runtime": "0.8.0-dev.
|
|
45
|
-
"@prisma-next/test-utils": "0.8.0-dev.
|
|
46
|
-
"@prisma-next/tsconfig": "0.8.0-dev.
|
|
47
|
-
"@prisma-next/tsdown": "0.8.0-dev.
|
|
40
|
+
"@prisma-next/sql-contract": "0.8.0-dev.5",
|
|
41
|
+
"@prisma-next/sql-contract-emitter": "0.8.0-dev.5",
|
|
42
|
+
"@prisma-next/sql-contract-ts": "0.8.0-dev.5",
|
|
43
|
+
"@prisma-next/sql-operations": "0.8.0-dev.5",
|
|
44
|
+
"@prisma-next/sql-runtime": "0.8.0-dev.5",
|
|
45
|
+
"@prisma-next/test-utils": "0.8.0-dev.5",
|
|
46
|
+
"@prisma-next/tsconfig": "0.8.0-dev.5",
|
|
47
|
+
"@prisma-next/tsdown": "0.8.0-dev.5",
|
|
48
48
|
"@types/node": "24.10.4",
|
|
49
49
|
"tsdown": "0.22.0",
|
|
50
50
|
"typescript": "5.9.3",
|
|
@@ -1,44 +1,109 @@
|
|
|
1
1
|
import { execFile } from 'node:child_process';
|
|
2
2
|
import { promisify } from 'node:util';
|
|
3
|
+
import { version as cliVersion } from '../../../package.json' with { type: 'json' };
|
|
3
4
|
import type { PackageManager } from './detect-package-manager';
|
|
4
5
|
import { errorInitSkillInstallFailed } from './errors';
|
|
5
6
|
|
|
6
7
|
const exec = promisify(execFile);
|
|
7
8
|
|
|
8
9
|
/**
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
10
|
+
* Default base for the GitHub-URL form `<owner>/<repo>` consumed by
|
|
11
|
+
* upstream `skills add`. Each `SkillSource` joins this base with its
|
|
12
|
+
* own subpath (and optional `#ref` for version-pinned clusters).
|
|
13
|
+
*/
|
|
14
|
+
export const DEFAULT_AGENT_SKILL_BASE = 'prisma/prisma-next';
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* One discovery scope inside the Prisma Next monorepo. The CLI emits
|
|
18
|
+
* one `skills add <base>/<subpath>[#ref] --all` invocation per source
|
|
19
|
+
* during `init`.
|
|
20
|
+
*
|
|
21
|
+
* `ref` semantics:
|
|
22
|
+
* - `cli`: pin to the CLI's own package version (lockstep with the
|
|
23
|
+
* skills' SPI). Used for the version-locked usage cluster — the
|
|
24
|
+
* skills under `skills/<X>/SKILL.md`, which describe the public
|
|
25
|
+
* package API and are pinned to the version of `@prisma-next/*`
|
|
26
|
+
* currently installed in the consumer's project.
|
|
27
|
+
* - `null`: no ref. The cluster is "always-latest" — the cumulative
|
|
28
|
+
* instruction set is the source of truth, and the latest revision
|
|
29
|
+
* on `main` includes bug fixes for every prior transition. Used
|
|
30
|
+
* for the upgrade and extension-author clusters.
|
|
31
|
+
*/
|
|
32
|
+
export interface SkillSource {
|
|
33
|
+
readonly subpath: string;
|
|
34
|
+
readonly ref: 'cli' | null;
|
|
35
|
+
readonly description: string;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export const DEFAULT_AGENT_SKILL_SOURCES: readonly SkillSource[] = [
|
|
39
|
+
{
|
|
40
|
+
subpath: 'skills',
|
|
41
|
+
ref: 'cli',
|
|
42
|
+
description: 'usage skills (version-locked to installed Prisma Next)',
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
subpath: 'skills/upgrade',
|
|
46
|
+
ref: null,
|
|
47
|
+
description: 'upgrade skill (always tracks `main`)',
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
subpath: 'skills/extension-author',
|
|
51
|
+
ref: null,
|
|
52
|
+
description: 'extension-author skill (always tracks `main`)',
|
|
53
|
+
},
|
|
54
|
+
];
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Test-only escape hatch for pinning the install base to a local
|
|
58
|
+
* checkout. Production runs leave this unset, so installs always use
|
|
59
|
+
* `DEFAULT_AGENT_SKILL_BASE`.
|
|
12
60
|
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
|
|
19
|
-
|
|
61
|
+
* When set to an absolute filesystem path (typical for tests), the
|
|
62
|
+
* `#ref` fragment is dropped — local-path mode in upstream's CLI does
|
|
63
|
+
* not accept refs, and the local clone has whatever content the test
|
|
64
|
+
* checked into it anyway. When set to anything else (e.g. a fork name
|
|
65
|
+
* `myuser/prisma-next`), the ref policy is preserved.
|
|
66
|
+
*/
|
|
67
|
+
function resolveAgentSkillBase(): string {
|
|
68
|
+
const override = process.env['PRISMA_NEXT_SKILLS_BASE']?.trim();
|
|
69
|
+
return override && override.length > 0 ? override : DEFAULT_AGENT_SKILL_BASE;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
function isLocalPath(base: string): boolean {
|
|
73
|
+
return base.startsWith('/') || /^[a-zA-Z]:[\\/]/.test(base);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Build the `<base>/<subpath>[#ref]` URL the `skills` CLI will
|
|
78
|
+
* resolve. Exported for unit tests so the per-source format can be
|
|
79
|
+
* asserted without going through the full install loop.
|
|
20
80
|
*/
|
|
21
|
-
export
|
|
81
|
+
export function formatSkillSourceUrl(source: SkillSource): string {
|
|
82
|
+
const base = resolveAgentSkillBase();
|
|
83
|
+
const url = `${base}/${source.subpath}`;
|
|
84
|
+
if (source.ref === null) return url;
|
|
85
|
+
if (isLocalPath(base)) return url;
|
|
86
|
+
if (source.ref === 'cli') return `${url}#v${cliVersion}`;
|
|
87
|
+
return url;
|
|
88
|
+
}
|
|
22
89
|
|
|
23
90
|
/**
|
|
24
|
-
* The skill-install command, formatted for the
|
|
25
|
-
* package manager. `npx`/`pnpm dlx`/`bunx` are
|
|
26
|
-
* user; we pick the variant that matches the
|
|
27
|
-
* so a single project consistently uses one
|
|
91
|
+
* The skill-install command for one source, formatted for the
|
|
92
|
+
* project's detected package manager. `npx`/`pnpm dlx`/`bunx` are
|
|
93
|
+
* interchangeable to the user; we pick the variant that matches the
|
|
94
|
+
* rest of the install step so a single project consistently uses one
|
|
95
|
+
* runner.
|
|
28
96
|
*
|
|
29
97
|
* `--all` auto-selects every skill in the cluster and every detected
|
|
30
98
|
* agent runtime, skipping the multi-select prompts the `skills` CLI
|
|
31
99
|
* shows by default. A non-interactive scaffold step cannot present
|
|
32
|
-
* prompts
|
|
33
|
-
* router skill routes between the workflow-scoped siblings). Users who
|
|
34
|
-
* want a narrower install run `npx skills add @prisma-next/skills`
|
|
35
|
-
* themselves after `init` with the flags they want.
|
|
100
|
+
* prompts.
|
|
36
101
|
*
|
|
37
102
|
* Exported for unit tests so the per-PM dispatch can be asserted
|
|
38
103
|
* without a live subprocess.
|
|
39
104
|
*/
|
|
40
|
-
export function formatSkillInstallCommand(pm: PackageManager): string {
|
|
41
|
-
const args = ['skills', 'add',
|
|
105
|
+
export function formatSkillInstallCommand(pm: PackageManager, source: SkillSource): string {
|
|
106
|
+
const args = ['skills', 'add', formatSkillSourceUrl(source), '--all'];
|
|
42
107
|
switch (pm) {
|
|
43
108
|
case 'pnpm':
|
|
44
109
|
return `pnpm dlx ${args.join(' ')}`;
|
|
@@ -69,31 +134,37 @@ function commandToExec(command: string): {
|
|
|
69
134
|
}
|
|
70
135
|
|
|
71
136
|
/**
|
|
72
|
-
* Runs the project-level skill install
|
|
73
|
-
*
|
|
74
|
-
*
|
|
75
|
-
*
|
|
76
|
-
*
|
|
77
|
-
*
|
|
137
|
+
* Runs the project-level skill install for every source in
|
|
138
|
+
* `DEFAULT_AGENT_SKILL_SOURCES`, in order. Returns
|
|
139
|
+
* `{ ok: true, commands }` on success; throws a structured
|
|
140
|
+
* `errorInitSkillInstallFailed` on the first failure (subsequent
|
|
141
|
+
* sources are not attempted — the user opted into Prisma Next by
|
|
142
|
+
* running `init` and a partial install would leave the project in an
|
|
143
|
+
* ambiguous state). The throw is intentionally fatal — project-level
|
|
144
|
+
* skill install is unconditional (modulo `--no-skill`).
|
|
78
145
|
*/
|
|
79
146
|
export async function runProjectLevelSkillInstall(ctx: {
|
|
80
147
|
readonly baseDir: string;
|
|
81
148
|
readonly pm: PackageManager;
|
|
82
149
|
readonly filesWritten: readonly string[];
|
|
83
|
-
}): Promise<{ readonly ok: true; readonly
|
|
84
|
-
const
|
|
85
|
-
const
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
150
|
+
}): Promise<{ readonly ok: true; readonly commands: readonly string[] }> {
|
|
151
|
+
const commands: string[] = [];
|
|
152
|
+
for (const source of DEFAULT_AGENT_SKILL_SOURCES) {
|
|
153
|
+
const command = formatSkillInstallCommand(ctx.pm, source);
|
|
154
|
+
const { file, args } = commandToExec(command);
|
|
155
|
+
try {
|
|
156
|
+
await exec(file, args, { cwd: ctx.baseDir });
|
|
157
|
+
commands.push(command);
|
|
158
|
+
} catch (err) {
|
|
159
|
+
throw errorInitSkillInstallFailed({
|
|
160
|
+
skillInstallCommand: command,
|
|
161
|
+
filesWritten: ctx.filesWritten,
|
|
162
|
+
cause:
|
|
163
|
+
redactSecrets(readChildStderr(err)) || (err instanceof Error ? err.message : String(err)),
|
|
164
|
+
});
|
|
165
|
+
}
|
|
96
166
|
}
|
|
167
|
+
return { ok: true, commands };
|
|
97
168
|
}
|
|
98
169
|
|
|
99
170
|
function readChildStderr(err: unknown): string {
|
|
@@ -125,6 +196,6 @@ export function redactSecrets(stderr: string): string {
|
|
|
125
196
|
/**
|
|
126
197
|
* Hand-rolled skill stub path that init must not leave behind. Removed
|
|
127
198
|
* on every init run so a project's `.agents/skills/prisma-next/` does
|
|
128
|
-
* not shadow the
|
|
199
|
+
* not shadow the installed Prisma Next skill cluster.
|
|
129
200
|
*/
|
|
130
201
|
export const LEGACY_SKILL_FILE = '.agents/skills/prisma-next/SKILL.md';
|
|
@@ -239,7 +239,7 @@ export function errorInitEmitFailed(options: {
|
|
|
239
239
|
|
|
240
240
|
/**
|
|
241
241
|
* The project-level agent-skill install (`npx skills add
|
|
242
|
-
*
|
|
242
|
+
* prisma/prisma-next#v<version>`) failed after a successful dependency
|
|
243
243
|
* install + emit. The project's scaffold remains on disk; the user
|
|
244
244
|
* can either fix the underlying issue (network, registry, PATH) and
|
|
245
245
|
* run the install command manually, or re-run `init --no-skill` to
|
|
@@ -253,7 +253,7 @@ export function errorInitSkillInstallFailed(options: {
|
|
|
253
253
|
readonly filesWritten: readonly string[];
|
|
254
254
|
readonly cause: string;
|
|
255
255
|
}): CliStructuredError {
|
|
256
|
-
return new CliStructuredError('5013', 'Failed to install
|
|
256
|
+
return new CliStructuredError('5013', 'Failed to install Prisma Next skills', {
|
|
257
257
|
domain: 'CLI',
|
|
258
258
|
why: `\`${options.skillInstallCommand}\` exited with an error: ${options.cause}`,
|
|
259
259
|
fix:
|
|
@@ -62,8 +62,8 @@ export const INIT_EXIT_INSTALL_FAILED = 4;
|
|
|
62
62
|
export const INIT_EXIT_EMIT_FAILED = 5;
|
|
63
63
|
|
|
64
64
|
/**
|
|
65
|
-
* The project-level
|
|
66
|
-
*
|
|
65
|
+
* The project-level Prisma Next skills install (`npx skills add
|
|
66
|
+
* prisma/prisma-next#v<version>`) failed after a successful dependency
|
|
67
67
|
* install + emit. The scaffolded project files remain on disk; the
|
|
68
68
|
* user can fix the underlying issue (network, registry reachability,
|
|
69
69
|
* `npx skills` not on PATH) and run the install manually, or re-run
|
|
@@ -89,7 +89,7 @@ export function createInitCommand(): Command {
|
|
|
89
89
|
.option('--no-install', 'Skip dependency installation and contract emission')
|
|
90
90
|
.option(
|
|
91
91
|
'--no-skill',
|
|
92
|
-
'Skip
|
|
92
|
+
'Skip Prisma Next skills install (air-gapped CI, restricted registries, etc.)',
|
|
93
93
|
)
|
|
94
94
|
.action(async (options: InitCommandOptions) => {
|
|
95
95
|
const { runInit } = await import('./init');
|
|
@@ -8,6 +8,7 @@ import { formatErrorJson, formatErrorOutput } from '../../utils/formatters/error
|
|
|
8
8
|
import type { GlobalFlags } from '../../utils/global-flags';
|
|
9
9
|
import { TerminalUI } from '../../utils/terminal-ui';
|
|
10
10
|
import {
|
|
11
|
+
DEFAULT_AGENT_SKILL_SOURCES,
|
|
11
12
|
formatSkillInstallCommand,
|
|
12
13
|
LEGACY_SKILL_FILE,
|
|
13
14
|
runProjectLevelSkillInstall,
|
|
@@ -182,7 +183,7 @@ export async function runInit(
|
|
|
182
183
|
// and missing-on-disk-at-write-time is tolerated.
|
|
183
184
|
const filesToDelete: string[] = inputs.reinit ? [...findStaleArtefacts(baseDir, schemaDir)] : [];
|
|
184
185
|
|
|
185
|
-
// `init` delegates the skill to `npx skills add
|
|
186
|
+
// `init` delegates the skill to `npx skills add prisma/prisma-next#v<version>`,
|
|
186
187
|
// so a hand-rolled `.agents/skills/prisma-next/SKILL.md` in the project
|
|
187
188
|
// would shadow the published package. Queue it for deletion on every
|
|
188
189
|
// run (not gated on `--reinit`).
|
|
@@ -449,26 +450,31 @@ export async function runInit(
|
|
|
449
450
|
// potentially fails. We skip the install when the user passed
|
|
450
451
|
// `--no-install` for the same reason — no `node_modules` means the
|
|
451
452
|
// workspace isn't ready to consume the skill yet anyway.
|
|
452
|
-
const
|
|
453
|
+
const manualProjectSkillCommands = DEFAULT_AGENT_SKILL_SOURCES.map((source) =>
|
|
454
|
+
formatSkillInstallCommand(install.effectivePm, source),
|
|
455
|
+
);
|
|
456
|
+
const manualProjectSkillSummary = manualProjectSkillCommands.map((c) => `\`${c}\``).join(' && ');
|
|
453
457
|
let skillRegistered = false;
|
|
454
458
|
if (!inputs.installProjectSkill) {
|
|
455
459
|
warnings.push(
|
|
456
|
-
`Skipped
|
|
460
|
+
`Skipped Prisma Next agent-skill install (--no-skill). To install the skills later, run: ${manualProjectSkillSummary}`,
|
|
457
461
|
);
|
|
458
462
|
} else if (install.skipped) {
|
|
459
463
|
warnings.push(
|
|
460
|
-
`Skipped
|
|
464
|
+
`Skipped Prisma Next agent-skill install because --no-install was passed. After you run install manually, install the skills with: ${manualProjectSkillSummary}`,
|
|
461
465
|
);
|
|
462
466
|
} else {
|
|
463
467
|
const spinner = ui.spinner();
|
|
464
|
-
spinner.start('Registering
|
|
468
|
+
spinner.start('Registering Prisma Next skills with the agent runtime...');
|
|
465
469
|
try {
|
|
466
470
|
const project = await runProjectLevelSkillInstall({
|
|
467
471
|
baseDir,
|
|
468
472
|
pm: install.effectivePm,
|
|
469
473
|
filesWritten,
|
|
470
474
|
});
|
|
471
|
-
spinner.stop(
|
|
475
|
+
spinner.stop(
|
|
476
|
+
`Registered Prisma Next skills (project level) — ran ${project.commands.map((c) => `\`${c}\``).join(', ')}`,
|
|
477
|
+
);
|
|
472
478
|
skillRegistered = true;
|
|
473
479
|
} catch (error) {
|
|
474
480
|
spinner.stop('Agent-skill install failed');
|
|
@@ -69,7 +69,7 @@ export interface ResolvedInitInputs {
|
|
|
69
69
|
*/
|
|
70
70
|
readonly removePreviousFacade: string | null;
|
|
71
71
|
/**
|
|
72
|
-
* Whether to run `npx skills add
|
|
72
|
+
* Whether to run `npx skills add prisma/prisma-next#v<version>` at the
|
|
73
73
|
* project level after install + emit. True by default; `--no-skill`
|
|
74
74
|
* sets it to `false`. The skill is always project-level (never
|
|
75
75
|
* user-level / global) so its version stays locked to the project's
|
|
@@ -121,7 +121,7 @@ export function buildNextSteps(options: {
|
|
|
121
121
|
readonly emitCommand: string;
|
|
122
122
|
readonly schemaPath: string;
|
|
123
123
|
/**
|
|
124
|
-
* Whether the project-level
|
|
124
|
+
* Whether the project-level Prisma Next skills install actually ran
|
|
125
125
|
* and succeeded during this `init`. When false (the user passed
|
|
126
126
|
* `--no-skill` or `--no-install`, so the install was skipped), the
|
|
127
127
|
* "registered with your agent runtime" step is omitted — the skip is
|
|
@@ -145,7 +145,7 @@ export function buildNextSteps(options: {
|
|
|
145
145
|
push('Open prisma-next.md for a quick reference on how to write your first typed query.');
|
|
146
146
|
if (options.skillRegistered) {
|
|
147
147
|
push(
|
|
148
|
-
'
|
|
148
|
+
'Prisma Next skills are registered with your agent runtime — open the project in your IDE and ask the agent to add a model, run a query, or plan a migration.',
|
|
149
149
|
);
|
|
150
150
|
}
|
|
151
151
|
return steps;
|
|
@@ -32,6 +32,7 @@ import { join, relative } from 'pathe';
|
|
|
32
32
|
import { loadConfig } from '../config-loader';
|
|
33
33
|
import {
|
|
34
34
|
CliStructuredError,
|
|
35
|
+
errorFileNotFound,
|
|
35
36
|
errorRuntime,
|
|
36
37
|
errorTargetMigrationNotSupported,
|
|
37
38
|
errorUnexpected,
|
|
@@ -115,7 +116,6 @@ async function executeMigrationNewCommand(
|
|
|
115
116
|
);
|
|
116
117
|
}
|
|
117
118
|
|
|
118
|
-
let fromContract: Contract | null = null;
|
|
119
119
|
let fromHash: string | null = null;
|
|
120
120
|
let fromContractSourceDir: string | null = null;
|
|
121
121
|
|
|
@@ -136,7 +136,6 @@ async function executeMigrationNewCommand(
|
|
|
136
136
|
);
|
|
137
137
|
}
|
|
138
138
|
fromHash = match.metadata.to;
|
|
139
|
-
fromContract = match.metadata.toContract;
|
|
140
139
|
fromContractSourceDir = match.dirPath;
|
|
141
140
|
} else {
|
|
142
141
|
const latestMigration = findLatestMigration(graph);
|
|
@@ -146,7 +145,6 @@ async function executeMigrationNewCommand(
|
|
|
146
145
|
(p) => p.metadata.migrationHash === latestMigration.migrationHash,
|
|
147
146
|
);
|
|
148
147
|
if (leafPkg) {
|
|
149
|
-
fromContract = leafPkg.metadata.toContract;
|
|
150
148
|
fromContractSourceDir = leafPkg.dirPath;
|
|
151
149
|
}
|
|
152
150
|
}
|
|
@@ -180,8 +178,6 @@ async function executeMigrationNewCommand(
|
|
|
180
178
|
const baseMetadata: Omit<MigrationMetadata, 'migrationHash'> = {
|
|
181
179
|
from: fromHash,
|
|
182
180
|
to: toStorageHash,
|
|
183
|
-
fromContract,
|
|
184
|
-
toContract: toContractJson,
|
|
185
181
|
hints: {
|
|
186
182
|
used: [],
|
|
187
183
|
applied: [],
|
|
@@ -222,10 +218,22 @@ async function executeMigrationNewCommand(
|
|
|
222
218
|
const sourceArtifacts = getEmittedArtifactPaths(
|
|
223
219
|
join(fromContractSourceDir, 'end-contract.json'),
|
|
224
220
|
);
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
221
|
+
try {
|
|
222
|
+
await copyFilesWithRename(packageDir, [
|
|
223
|
+
{ sourcePath: sourceArtifacts.jsonPath, destName: 'start-contract.json' },
|
|
224
|
+
{ sourcePath: sourceArtifacts.dtsPath, destName: 'start-contract.d.ts' },
|
|
225
|
+
]);
|
|
226
|
+
} catch (error) {
|
|
227
|
+
if (error instanceof Error && (error as { code?: string }).code === 'ENOENT') {
|
|
228
|
+
return notOk(
|
|
229
|
+
errorFileNotFound(sourceArtifacts.jsonPath, {
|
|
230
|
+
why: `Predecessor migration is missing its destination contract snapshot at ${sourceArtifacts.jsonPath}`,
|
|
231
|
+
fix: 'Re-emit the predecessor migration (`prisma-next migration plan` from its source) so its sibling `end-contract.json` is restored, then re-run this command.',
|
|
232
|
+
}),
|
|
233
|
+
);
|
|
234
|
+
}
|
|
235
|
+
throw error;
|
|
236
|
+
}
|
|
229
237
|
}
|
|
230
238
|
|
|
231
239
|
const stack = createControlStack(config);
|
|
@@ -58,6 +58,34 @@ interface MigrationPlanOptions extends CommonCommandOptions {
|
|
|
58
58
|
readonly from?: string;
|
|
59
59
|
}
|
|
60
60
|
|
|
61
|
+
/**
|
|
62
|
+
* Load a predecessor migration's destination contract from its sibling
|
|
63
|
+
* `end-contract.json` on disk. The manifest no longer inlines the
|
|
64
|
+
* contract; the planner reads it from the canonical on-disk artefact
|
|
65
|
+
* authored by a previous `migration plan` run.
|
|
66
|
+
*
|
|
67
|
+
* Throws `CliStructuredError` with `errorFileNotFound` when the
|
|
68
|
+
* sibling file is missing — the user has likely deleted or never
|
|
69
|
+
* authored the snapshot, and the message names the file and points
|
|
70
|
+
* them at re-emitting from the source.
|
|
71
|
+
*/
|
|
72
|
+
async function readPredecessorEndContract(migrationDir: string): Promise<Contract> {
|
|
73
|
+
const path = join(migrationDir, 'end-contract.json');
|
|
74
|
+
let raw: string;
|
|
75
|
+
try {
|
|
76
|
+
raw = await readFile(path, 'utf-8');
|
|
77
|
+
} catch (error) {
|
|
78
|
+
if (error instanceof Error && (error as { code?: string }).code === 'ENOENT') {
|
|
79
|
+
throw errorFileNotFound(path, {
|
|
80
|
+
why: `Predecessor migration is missing its destination contract snapshot at ${path}`,
|
|
81
|
+
fix: 'Re-emit the predecessor migration (`prisma-next migration plan` from its source) so its sibling `end-contract.json` is restored, then re-run this command.',
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
throw error;
|
|
85
|
+
}
|
|
86
|
+
return JSON.parse(raw) as Contract;
|
|
87
|
+
}
|
|
88
|
+
|
|
61
89
|
export interface MigrationPlanResult {
|
|
62
90
|
readonly ok: boolean;
|
|
63
91
|
readonly noOp: boolean;
|
|
@@ -202,8 +230,8 @@ async function executeMigrationPlanCommand(
|
|
|
202
230
|
);
|
|
203
231
|
}
|
|
204
232
|
fromHash = resolved.value.metadata.to;
|
|
205
|
-
fromContract = resolved.value.metadata.toContract;
|
|
206
233
|
fromContractSourceDir = resolved.value.dirPath;
|
|
234
|
+
fromContract = await readPredecessorEndContract(fromContractSourceDir);
|
|
207
235
|
} else {
|
|
208
236
|
const latestMigration = findLatestMigration(graph);
|
|
209
237
|
if (latestMigration) {
|
|
@@ -212,8 +240,8 @@ async function executeMigrationPlanCommand(
|
|
|
212
240
|
(p) => p.metadata.migrationHash === latestMigration.migrationHash,
|
|
213
241
|
);
|
|
214
242
|
if (leafPkg) {
|
|
215
|
-
fromContract = leafPkg.metadata.toContract;
|
|
216
243
|
fromContractSourceDir = leafPkg.dirPath;
|
|
244
|
+
fromContract = await readPredecessorEndContract(fromContractSourceDir);
|
|
217
245
|
}
|
|
218
246
|
}
|
|
219
247
|
}
|
|
@@ -221,6 +249,12 @@ async function executeMigrationPlanCommand(
|
|
|
221
249
|
if (MigrationToolsError.is(error)) {
|
|
222
250
|
return notOk(mapMigrationToolsError(error));
|
|
223
251
|
}
|
|
252
|
+
// `readPredecessorEndContract` raises a `CliStructuredError` directly
|
|
253
|
+
// for the missing-snapshot case so the operator gets a precise
|
|
254
|
+
// why/fix; pass it through unchanged rather than re-wrapping.
|
|
255
|
+
if (CliStructuredError.is(error)) {
|
|
256
|
+
return notOk(error);
|
|
257
|
+
}
|
|
224
258
|
// Wrap unexpected (non-MigrationToolsError) failures from the migration
|
|
225
259
|
// load phase in a structured CLI envelope. Letting them throw would
|
|
226
260
|
// bypass `handleResult()` and crash the command — see CLI structured-
|
|
@@ -327,8 +361,6 @@ async function executeMigrationPlanCommand(
|
|
|
327
361
|
const baseMetadata: Omit<MigrationMetadata, 'migrationHash' | 'providedInvariants'> = {
|
|
328
362
|
from: fromHash,
|
|
329
363
|
to: toStorageHash,
|
|
330
|
-
fromContract,
|
|
331
|
-
toContract: toContractJson,
|
|
332
364
|
hints: {
|
|
333
365
|
used: [],
|
|
334
366
|
applied: [],
|
package/src/control-api/types.ts
CHANGED
|
@@ -2,7 +2,7 @@ import type {
|
|
|
2
2
|
ContractSourceDiagnostics,
|
|
3
3
|
ContractSourceProvider,
|
|
4
4
|
} from '@prisma-next/config/config-types';
|
|
5
|
-
import type {
|
|
5
|
+
import type { ContractMarkerRecord } from '@prisma-next/contract/types';
|
|
6
6
|
import type {
|
|
7
7
|
ControlAdapterDescriptor,
|
|
8
8
|
ControlDriverDescriptor,
|
|
@@ -590,7 +590,6 @@ export interface MigrationApplyStep {
|
|
|
590
590
|
readonly dirName: string;
|
|
591
591
|
readonly from: string | null;
|
|
592
592
|
readonly to: string;
|
|
593
|
-
readonly toContract: Contract;
|
|
594
593
|
readonly operations: readonly MigrationPlanOperation[];
|
|
595
594
|
/**
|
|
596
595
|
* Sorted, deduplicated invariant ids from `migration.json.providedInvariants`.
|