neon-init 0.13.1 → 0.15.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (117) hide show
  1. package/dist/cli.js +368 -33
  2. package/dist/cli.js.map +1 -1
  3. package/dist/index.d.ts +15 -3
  4. package/dist/index.d.ts.map +1 -1
  5. package/dist/index.js +220 -41
  6. package/dist/index.js.map +1 -1
  7. package/dist/interactive.d.ts +12 -0
  8. package/dist/interactive.d.ts.map +1 -0
  9. package/dist/interactive.js +495 -0
  10. package/dist/interactive.js.map +1 -0
  11. package/dist/lib/agents.d.ts +23 -0
  12. package/dist/lib/agents.d.ts.map +1 -0
  13. package/dist/lib/agents.js +148 -0
  14. package/dist/lib/agents.js.map +1 -0
  15. package/dist/lib/auth.d.ts +10 -3
  16. package/dist/lib/auth.d.ts.map +1 -1
  17. package/dist/lib/auth.js +20 -13
  18. package/dist/lib/auth.js.map +1 -1
  19. package/dist/lib/bootstrap.d.ts +30 -0
  20. package/dist/lib/bootstrap.d.ts.map +1 -0
  21. package/dist/lib/bootstrap.js +61 -0
  22. package/dist/lib/bootstrap.js.map +1 -0
  23. package/dist/lib/build-config.d.ts +5 -0
  24. package/dist/lib/build-config.d.ts.map +1 -0
  25. package/dist/lib/build-config.js +6 -0
  26. package/dist/lib/build-config.js.map +1 -0
  27. package/dist/lib/detect-agent.d.ts +22 -0
  28. package/dist/lib/detect-agent.d.ts.map +1 -0
  29. package/dist/lib/detect-agent.js +65 -0
  30. package/dist/lib/detect-agent.js.map +1 -0
  31. package/dist/lib/editors.d.ts.map +1 -1
  32. package/dist/lib/editors.js +1 -2
  33. package/dist/lib/editors.js.map +1 -1
  34. package/dist/lib/extension.d.ts +11 -3
  35. package/dist/lib/extension.d.ts.map +1 -1
  36. package/dist/lib/extension.js +29 -9
  37. package/dist/lib/extension.js.map +1 -1
  38. package/dist/lib/inspect.d.ts +28 -0
  39. package/dist/lib/inspect.d.ts.map +1 -0
  40. package/dist/lib/inspect.js +190 -0
  41. package/dist/lib/inspect.js.map +1 -0
  42. package/dist/lib/install.d.ts +10 -4
  43. package/dist/lib/install.d.ts.map +1 -1
  44. package/dist/lib/install.js +74 -71
  45. package/dist/lib/install.js.map +1 -1
  46. package/dist/lib/neonctl.d.ts +32 -0
  47. package/dist/lib/neonctl.d.ts.map +1 -0
  48. package/dist/lib/neonctl.js +149 -0
  49. package/dist/lib/neonctl.js.map +1 -0
  50. package/dist/lib/phases/auth.d.ts +12 -0
  51. package/dist/lib/phases/auth.d.ts.map +1 -0
  52. package/dist/lib/phases/auth.js +188 -0
  53. package/dist/lib/phases/auth.js.map +1 -0
  54. package/dist/lib/phases/cleanup.d.ts +12 -0
  55. package/dist/lib/phases/cleanup.d.ts.map +1 -0
  56. package/dist/lib/phases/cleanup.js +29 -0
  57. package/dist/lib/phases/cleanup.js.map +1 -0
  58. package/dist/lib/phases/db.d.ts +17 -0
  59. package/dist/lib/phases/db.d.ts.map +1 -0
  60. package/dist/lib/phases/db.js +258 -0
  61. package/dist/lib/phases/db.js.map +1 -0
  62. package/dist/lib/phases/getting-started.d.ts +26 -0
  63. package/dist/lib/phases/getting-started.d.ts.map +1 -0
  64. package/dist/lib/phases/getting-started.js +195 -0
  65. package/dist/lib/phases/getting-started.js.map +1 -0
  66. package/dist/lib/phases/mcp.d.ts +15 -0
  67. package/dist/lib/phases/mcp.d.ts.map +1 -0
  68. package/dist/lib/phases/mcp.js +179 -0
  69. package/dist/lib/phases/mcp.js.map +1 -0
  70. package/dist/lib/phases/migrations.d.ts +14 -0
  71. package/dist/lib/phases/migrations.d.ts.map +1 -0
  72. package/dist/lib/phases/migrations.js +239 -0
  73. package/dist/lib/phases/migrations.js.map +1 -0
  74. package/dist/lib/phases/neon-auth.d.ts +13 -0
  75. package/dist/lib/phases/neon-auth.d.ts.map +1 -0
  76. package/dist/lib/phases/neon-auth.js +117 -0
  77. package/dist/lib/phases/neon-auth.js.map +1 -0
  78. package/dist/lib/phases/setup.d.ts +41 -0
  79. package/dist/lib/phases/setup.d.ts.map +1 -0
  80. package/dist/lib/phases/setup.js +689 -0
  81. package/dist/lib/phases/setup.js.map +1 -0
  82. package/dist/lib/phases/skills.d.ts +14 -0
  83. package/dist/lib/phases/skills.d.ts.map +1 -0
  84. package/dist/lib/phases/skills.js +80 -0
  85. package/dist/lib/phases/skills.js.map +1 -0
  86. package/dist/lib/phases/status.d.ts +10 -0
  87. package/dist/lib/phases/status.d.ts.map +1 -0
  88. package/dist/lib/phases/status.js +65 -0
  89. package/dist/lib/phases/status.js.map +1 -0
  90. package/dist/lib/resolve-context.d.ts +19 -0
  91. package/dist/lib/resolve-context.d.ts.map +1 -0
  92. package/dist/lib/resolve-context.js +112 -0
  93. package/dist/lib/resolve-context.js.map +1 -0
  94. package/dist/lib/route-command.d.ts +8 -0
  95. package/dist/lib/route-command.d.ts.map +1 -0
  96. package/dist/lib/route-command.js +195 -0
  97. package/dist/lib/route-command.js.map +1 -0
  98. package/dist/lib/skills.d.ts +21 -4
  99. package/dist/lib/skills.d.ts.map +1 -1
  100. package/dist/lib/skills.js +129 -22
  101. package/dist/lib/skills.js.map +1 -1
  102. package/dist/lib/types.d.ts +146 -13
  103. package/dist/lib/types.d.ts.map +1 -1
  104. package/dist/lib/types.js +1 -1
  105. package/dist/lib/vsix.d.ts +15 -0
  106. package/dist/lib/vsix.d.ts.map +1 -0
  107. package/dist/lib/vsix.js +91 -0
  108. package/dist/lib/vsix.js.map +1 -0
  109. package/dist/v2.d.ts +31 -0
  110. package/dist/v2.d.ts.map +1 -0
  111. package/dist/v2.js +147 -0
  112. package/dist/v2.js.map +1 -0
  113. package/package.json +9 -4
  114. package/dist/lib/mcp-config.d.ts +0 -24
  115. package/dist/lib/mcp-config.d.ts.map +0 -1
  116. package/dist/lib/mcp-config.js +0 -51
  117. package/dist/lib/mcp-config.js.map +0 -1
@@ -0,0 +1,258 @@
1
+ import { SKILL_REFERENCE_URLS } from "../skills.js";
2
+ //#region src/lib/phases/db.ts
3
+ /**
4
+ * Validates that an ID contains only safe characters for shell interpolation.
5
+ * Neon org/project IDs are typically UUIDs or slug-like strings.
6
+ */
7
+ function assertSafeId(value, label) {
8
+ if (!/^[\w.:-]+$/.test(value)) throw new Error(`Invalid ${label}: "${value}". Expected alphanumeric, hyphens, underscores, dots, or colons.`);
9
+ }
10
+ async function handleDbPhase(options) {
11
+ const agentArgs = options.agent ? [
12
+ "--agent",
13
+ options.agent,
14
+ "--json"
15
+ ] : ["--json"];
16
+ if (options.projectId) assertSafeId(options.projectId, "project ID");
17
+ if (options.orgId) assertSafeId(options.orgId, "org ID");
18
+ if (options.error) return {
19
+ phase: "db",
20
+ status: "error",
21
+ error: options.error,
22
+ nextAction: {
23
+ type: "ask_user",
24
+ question: `An error occurred during database setup: ${options.error}. Would you like to try again or skip this step?`,
25
+ options: [{
26
+ value: "retry",
27
+ label: "Try again"
28
+ }, {
29
+ value: "skip",
30
+ label: "Skip database setup"
31
+ }],
32
+ responseMapping: {
33
+ retry: { args: ["db", "--json"] },
34
+ skip: { args: agentArgs }
35
+ }
36
+ }
37
+ };
38
+ if (options.projectId) return {
39
+ phase: "db",
40
+ status: "project_ready",
41
+ project: { id: options.projectId },
42
+ nextAction: {
43
+ type: "agent_action",
44
+ prerequisite: SKILL_REFERENCE_URLS.connectionMethods,
45
+ steps: [
46
+ {
47
+ id: "get_connection_string",
48
+ description: "Get the database connection string",
49
+ command: `CI= npx -y neonctl connection-string --project-id ${options.projectId}`
50
+ },
51
+ {
52
+ id: "store_env",
53
+ description: "Append DATABASE_URL=<connection_string> to .env. Create .env if it doesn't exist. Do NOT overwrite existing entries. Ensure .env is in .gitignore."
54
+ },
55
+ {
56
+ id: "detect_framework",
57
+ description: "Examine the project to determine the framework (Next.js, Remix, Express, etc.) and ORM (Prisma, Drizzle, raw SQL) in use."
58
+ }
59
+ ],
60
+ onComplete: {
61
+ type: "run_neon_init",
62
+ args: agentArgs
63
+ }
64
+ }
65
+ };
66
+ if (options.projectsResult) {
67
+ let projects;
68
+ try {
69
+ const parsed = JSON.parse(options.projectsResult);
70
+ projects = Array.isArray(parsed.projects) ? parsed.projects : Array.isArray(parsed) ? parsed : [];
71
+ } catch {
72
+ projects = [];
73
+ }
74
+ const orgIdArgs = options.orgId ? ["--org-id", options.orgId] : [];
75
+ if (projects.length === 0) return {
76
+ phase: "db",
77
+ status: "no_projects",
78
+ nextAction: {
79
+ type: "ask_user",
80
+ question: "You don't have any Neon projects yet. What would you like to name your new project?",
81
+ options: [{
82
+ value: "create",
83
+ label: "Create a new project (provide a name)"
84
+ }],
85
+ context: "The agent should ask the user for a project name, then run: CI= npx -y neonctl projects create --name <name> --output json" + (options.orgId ? ` --org-id ${options.orgId}` : "") + " and pass the result back.",
86
+ responseMapping: { create: { args: [
87
+ "db",
88
+ "--json",
89
+ ...orgIdArgs,
90
+ "--project-id",
91
+ "<created-project-id>"
92
+ ] } }
93
+ }
94
+ };
95
+ const projectOptions = projects.map((p) => ({
96
+ value: p.id,
97
+ label: `${p.name} (${p.id})`
98
+ }));
99
+ projectOptions.push({
100
+ value: "create_new",
101
+ label: "Create a new project"
102
+ });
103
+ const responseMapping = {};
104
+ for (const p of projects) responseMapping[p.id] = { args: [
105
+ "db",
106
+ "--json",
107
+ ...orgIdArgs,
108
+ "--project-id",
109
+ p.id
110
+ ] };
111
+ responseMapping.create_new = { args: [
112
+ "db",
113
+ "--json",
114
+ ...orgIdArgs,
115
+ "--project-id",
116
+ "<created-project-id>"
117
+ ] };
118
+ return {
119
+ phase: "db",
120
+ status: "select_project",
121
+ nextAction: {
122
+ type: "ask_user",
123
+ question: "Which Neon project would you like to use?",
124
+ options: projectOptions,
125
+ context: "If the user wants to create a new project, ask for a name then run: CI= npx -y neonctl projects create --name <name> --output json and use the returned project id.",
126
+ responseMapping
127
+ }
128
+ };
129
+ }
130
+ if (options.orgsResult) {
131
+ let orgs;
132
+ try {
133
+ const parsed = JSON.parse(options.orgsResult);
134
+ orgs = Array.isArray(parsed.organizations) ? parsed.organizations : Array.isArray(parsed) ? parsed : [];
135
+ } catch {
136
+ orgs = [];
137
+ }
138
+ const orgId = options.orgId ?? (orgs.length === 1 ? orgs[0].id : null);
139
+ if (orgId) {
140
+ assertSafeId(orgId, "org ID");
141
+ return {
142
+ phase: "db",
143
+ status: "org_selected",
144
+ org: { id: orgId },
145
+ nextAction: {
146
+ type: "run_command",
147
+ command: `CI= npx -y neonctl projects list --org-id ${orgId} --output json`,
148
+ description: "Listing Neon projects.",
149
+ timeout: 3e4,
150
+ onSuccess: {
151
+ type: "run_neon_init",
152
+ args: [
153
+ "db",
154
+ "--json",
155
+ "--org-id",
156
+ orgId,
157
+ "--projects-result",
158
+ "<stdout>"
159
+ ]
160
+ },
161
+ onFailure: { other: {
162
+ type: "run_neon_init",
163
+ args: [
164
+ "db",
165
+ "--json",
166
+ "--error",
167
+ "projects-list-failed"
168
+ ]
169
+ } }
170
+ }
171
+ };
172
+ }
173
+ const orgOptions = orgs.map((o) => ({
174
+ value: o.id,
175
+ label: `${o.name} (${o.id})`
176
+ }));
177
+ const responseMapping = {};
178
+ for (const o of orgs) responseMapping[o.id] = { args: [
179
+ "db",
180
+ "--json",
181
+ "--org-id",
182
+ o.id
183
+ ] };
184
+ return {
185
+ phase: "db",
186
+ status: "select_org",
187
+ nextAction: {
188
+ type: "ask_user",
189
+ question: "Which Neon organization would you like to use?",
190
+ options: orgOptions,
191
+ responseMapping
192
+ }
193
+ };
194
+ }
195
+ if (options.orgId) return {
196
+ phase: "db",
197
+ status: "org_selected",
198
+ org: { id: options.orgId },
199
+ nextAction: {
200
+ type: "run_command",
201
+ command: `CI= npx -y neonctl projects list --org-id ${options.orgId} --output json`,
202
+ description: "Listing Neon projects.",
203
+ timeout: 3e4,
204
+ onSuccess: {
205
+ type: "run_neon_init",
206
+ args: [
207
+ "db",
208
+ "--json",
209
+ "--org-id",
210
+ options.orgId,
211
+ "--projects-result",
212
+ "<stdout>"
213
+ ]
214
+ },
215
+ onFailure: { other: {
216
+ type: "run_neon_init",
217
+ args: [
218
+ "db",
219
+ "--json",
220
+ "--error",
221
+ "projects-list-failed"
222
+ ]
223
+ } }
224
+ }
225
+ };
226
+ return {
227
+ phase: "db",
228
+ status: "ready",
229
+ nextAction: {
230
+ type: "run_command",
231
+ command: "CI= npx -y neonctl orgs list --output json",
232
+ description: "Listing your Neon organizations.",
233
+ timeout: 3e4,
234
+ onSuccess: {
235
+ type: "run_neon_init",
236
+ args: [
237
+ "db",
238
+ "--json",
239
+ "--orgs-result",
240
+ "<stdout>"
241
+ ]
242
+ },
243
+ onFailure: { other: {
244
+ type: "run_neon_init",
245
+ args: [
246
+ "db",
247
+ "--json",
248
+ "--error",
249
+ "orgs-list-failed"
250
+ ]
251
+ } }
252
+ }
253
+ };
254
+ }
255
+ //#endregion
256
+ export { handleDbPhase };
257
+
258
+ //# sourceMappingURL=db.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"db.js","names":[],"sources":["../../../src/lib/phases/db.ts"],"sourcesContent":["import { SKILL_REFERENCE_URLS } from \"../skills.js\";\nimport type { PhaseResponse } from \"../types.js\";\n\n/**\n * Validates that an ID contains only safe characters for shell interpolation.\n * Neon org/project IDs are typically UUIDs or slug-like strings.\n */\nfunction assertSafeId(value: string, label: string): void {\n\tif (!/^[\\w.:-]+$/.test(value)) {\n\t\tthrow new Error(\n\t\t\t`Invalid ${label}: \"${value}\". Expected alphanumeric, hyphens, underscores, dots, or colons.`,\n\t\t);\n\t}\n}\n\nexport interface DbPhaseOptions {\n\tagent?: string;\n\torgId?: string;\n\tprojectId?: string;\n\torgsResult?: string;\n\tprojectsResult?: string;\n\tframework?: string;\n\torm?: string;\n\terror?: string;\n}\n\nexport async function handleDbPhase(\n\toptions: DbPhaseOptions,\n): Promise<PhaseResponse> {\n\tconst agentArgs = options.agent\n\t\t? [\"--agent\", options.agent, \"--json\"]\n\t\t: [\"--json\"];\n\n\t// Validate IDs that will be interpolated into shell commands\n\tif (options.projectId) assertSafeId(options.projectId, \"project ID\");\n\tif (options.orgId) assertSafeId(options.orgId, \"org ID\");\n\n\t// Error from a previous step\n\tif (options.error) {\n\t\treturn {\n\t\t\tphase: \"db\",\n\t\t\tstatus: \"error\",\n\t\t\terror: options.error,\n\t\t\tnextAction: {\n\t\t\t\ttype: \"ask_user\",\n\t\t\t\tquestion: `An error occurred during database setup: ${options.error}. Would you like to try again or skip this step?`,\n\t\t\t\toptions: [\n\t\t\t\t\t{ value: \"retry\", label: \"Try again\" },\n\t\t\t\t\t{ value: \"skip\", label: \"Skip database setup\" },\n\t\t\t\t],\n\t\t\t\tresponseMapping: {\n\t\t\t\t\tretry: { args: [\"db\", \"--json\"] },\n\t\t\t\t\tskip: { args: agentArgs },\n\t\t\t\t},\n\t\t\t},\n\t\t};\n\t}\n\n\t// If we have a project ID, we're in the \"wire it up\" phase\n\tif (options.projectId) {\n\t\treturn {\n\t\t\tphase: \"db\",\n\t\t\tstatus: \"project_ready\",\n\t\t\tproject: { id: options.projectId },\n\t\t\tnextAction: {\n\t\t\t\ttype: \"agent_action\",\n\t\t\t\tprerequisite: SKILL_REFERENCE_URLS.connectionMethods,\n\t\t\t\tsteps: [\n\t\t\t\t\t{\n\t\t\t\t\t\tid: \"get_connection_string\",\n\t\t\t\t\t\tdescription: \"Get the database connection string\",\n\t\t\t\t\t\tcommand: `CI= npx -y neonctl connection-string --project-id ${options.projectId}`,\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tid: \"store_env\",\n\t\t\t\t\t\tdescription:\n\t\t\t\t\t\t\t\"Append DATABASE_URL=<connection_string> to .env. Create .env if it doesn't exist. Do NOT overwrite existing entries. Ensure .env is in .gitignore.\",\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tid: \"detect_framework\",\n\t\t\t\t\t\tdescription:\n\t\t\t\t\t\t\t\"Examine the project to determine the framework (Next.js, Remix, Express, etc.) and ORM (Prisma, Drizzle, raw SQL) in use.\",\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t\tonComplete: {\n\t\t\t\t\ttype: \"run_neon_init\",\n\t\t\t\t\targs: agentArgs,\n\t\t\t\t},\n\t\t\t},\n\t\t};\n\t}\n\n\t// If we have projects result, let user pick or create\n\tif (options.projectsResult) {\n\t\tlet projects: { id: string; name: string }[];\n\t\ttry {\n\t\t\tconst parsed = JSON.parse(options.projectsResult);\n\t\t\tprojects = Array.isArray(parsed.projects)\n\t\t\t\t? parsed.projects\n\t\t\t\t: Array.isArray(parsed)\n\t\t\t\t\t? parsed\n\t\t\t\t\t: [];\n\t\t} catch {\n\t\t\tprojects = [];\n\t\t}\n\n\t\tconst orgIdArgs = options.orgId ? [\"--org-id\", options.orgId] : [];\n\n\t\tif (projects.length === 0) {\n\t\t\treturn {\n\t\t\t\tphase: \"db\",\n\t\t\t\tstatus: \"no_projects\",\n\t\t\t\tnextAction: {\n\t\t\t\t\ttype: \"ask_user\",\n\t\t\t\t\tquestion:\n\t\t\t\t\t\t\"You don't have any Neon projects yet. What would you like to name your new project?\",\n\t\t\t\t\toptions: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tvalue: \"create\",\n\t\t\t\t\t\t\tlabel: \"Create a new project (provide a name)\",\n\t\t\t\t\t\t},\n\t\t\t\t\t],\n\t\t\t\t\tcontext:\n\t\t\t\t\t\t\"The agent should ask the user for a project name, then run: CI= npx -y neonctl projects create --name <name> --output json\" +\n\t\t\t\t\t\t(options.orgId ? ` --org-id ${options.orgId}` : \"\") +\n\t\t\t\t\t\t\" and pass the result back.\",\n\t\t\t\t\tresponseMapping: {\n\t\t\t\t\t\tcreate: {\n\t\t\t\t\t\t\targs: [\n\t\t\t\t\t\t\t\t\"db\",\n\t\t\t\t\t\t\t\t\"--json\",\n\t\t\t\t\t\t\t\t...orgIdArgs,\n\t\t\t\t\t\t\t\t\"--project-id\",\n\t\t\t\t\t\t\t\t\"<created-project-id>\",\n\t\t\t\t\t\t\t],\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t};\n\t\t}\n\n\t\tconst projectOptions = projects.map((p) => ({\n\t\t\tvalue: p.id,\n\t\t\tlabel: `${p.name} (${p.id})`,\n\t\t}));\n\t\tprojectOptions.push({\n\t\t\tvalue: \"create_new\",\n\t\t\tlabel: \"Create a new project\",\n\t\t});\n\n\t\tconst responseMapping: Record<string, { args: string[] }> = {};\n\t\tfor (const p of projects) {\n\t\t\tresponseMapping[p.id] = {\n\t\t\t\targs: [\"db\", \"--json\", ...orgIdArgs, \"--project-id\", p.id],\n\t\t\t};\n\t\t}\n\t\tresponseMapping.create_new = {\n\t\t\targs: [\n\t\t\t\t\"db\",\n\t\t\t\t\"--json\",\n\t\t\t\t...orgIdArgs,\n\t\t\t\t\"--project-id\",\n\t\t\t\t\"<created-project-id>\",\n\t\t\t],\n\t\t};\n\n\t\treturn {\n\t\t\tphase: \"db\",\n\t\t\tstatus: \"select_project\",\n\t\t\tnextAction: {\n\t\t\t\ttype: \"ask_user\",\n\t\t\t\tquestion: \"Which Neon project would you like to use?\",\n\t\t\t\toptions: projectOptions,\n\t\t\t\tcontext:\n\t\t\t\t\t\"If the user wants to create a new project, ask for a name then run: CI= npx -y neonctl projects create --name <name> --output json and use the returned project id.\",\n\t\t\t\tresponseMapping,\n\t\t\t},\n\t\t};\n\t}\n\n\t// If we have orgs result, decide next step\n\tif (options.orgsResult) {\n\t\tlet orgs: { id: string; name: string }[];\n\t\ttry {\n\t\t\tconst parsed = JSON.parse(options.orgsResult);\n\t\t\torgs = Array.isArray(parsed.organizations)\n\t\t\t\t? parsed.organizations\n\t\t\t\t: Array.isArray(parsed)\n\t\t\t\t\t? parsed\n\t\t\t\t\t: [];\n\t\t} catch {\n\t\t\torgs = [];\n\t\t}\n\n\t\t// Single org or org already selected: list projects\n\t\tconst orgId = options.orgId ?? (orgs.length === 1 ? orgs[0].id : null);\n\n\t\tif (orgId) {\n\t\t\tassertSafeId(orgId, \"org ID\");\n\t\t\treturn {\n\t\t\t\tphase: \"db\",\n\t\t\t\tstatus: \"org_selected\",\n\t\t\t\torg: { id: orgId },\n\t\t\t\tnextAction: {\n\t\t\t\t\ttype: \"run_command\",\n\t\t\t\t\tcommand: `CI= npx -y neonctl projects list --org-id ${orgId} --output json`,\n\t\t\t\t\tdescription: \"Listing Neon projects.\",\n\t\t\t\t\ttimeout: 30000,\n\t\t\t\t\tonSuccess: {\n\t\t\t\t\t\ttype: \"run_neon_init\",\n\t\t\t\t\t\targs: [\n\t\t\t\t\t\t\t\"db\",\n\t\t\t\t\t\t\t\"--json\",\n\t\t\t\t\t\t\t\"--org-id\",\n\t\t\t\t\t\t\torgId,\n\t\t\t\t\t\t\t\"--projects-result\",\n\t\t\t\t\t\t\t\"<stdout>\",\n\t\t\t\t\t\t],\n\t\t\t\t\t},\n\t\t\t\t\tonFailure: {\n\t\t\t\t\t\tother: {\n\t\t\t\t\t\t\ttype: \"run_neon_init\",\n\t\t\t\t\t\t\targs: [\n\t\t\t\t\t\t\t\t\"db\",\n\t\t\t\t\t\t\t\t\"--json\",\n\t\t\t\t\t\t\t\t\"--error\",\n\t\t\t\t\t\t\t\t\"projects-list-failed\",\n\t\t\t\t\t\t\t],\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t};\n\t\t}\n\n\t\t// Multiple orgs: ask user to pick\n\t\tconst orgOptions = orgs.map((o) => ({\n\t\t\tvalue: o.id,\n\t\t\tlabel: `${o.name} (${o.id})`,\n\t\t}));\n\t\tconst responseMapping: Record<string, { args: string[] }> = {};\n\t\tfor (const o of orgs) {\n\t\t\tresponseMapping[o.id] = {\n\t\t\t\targs: [\"db\", \"--json\", \"--org-id\", o.id],\n\t\t\t};\n\t\t}\n\n\t\treturn {\n\t\t\tphase: \"db\",\n\t\t\tstatus: \"select_org\",\n\t\t\tnextAction: {\n\t\t\t\ttype: \"ask_user\",\n\t\t\t\tquestion: \"Which Neon organization would you like to use?\",\n\t\t\t\toptions: orgOptions,\n\t\t\t\tresponseMapping,\n\t\t\t},\n\t\t};\n\t}\n\n\t// If org-id provided but no orgs-result, list projects directly\n\tif (options.orgId) {\n\t\treturn {\n\t\t\tphase: \"db\",\n\t\t\tstatus: \"org_selected\",\n\t\t\torg: { id: options.orgId },\n\t\t\tnextAction: {\n\t\t\t\ttype: \"run_command\",\n\t\t\t\tcommand: `CI= npx -y neonctl projects list --org-id ${options.orgId} --output json`,\n\t\t\t\tdescription: \"Listing Neon projects.\",\n\t\t\t\ttimeout: 30000,\n\t\t\t\tonSuccess: {\n\t\t\t\t\ttype: \"run_neon_init\",\n\t\t\t\t\targs: [\n\t\t\t\t\t\t\"db\",\n\t\t\t\t\t\t\"--json\",\n\t\t\t\t\t\t\"--org-id\",\n\t\t\t\t\t\toptions.orgId,\n\t\t\t\t\t\t\"--projects-result\",\n\t\t\t\t\t\t\"<stdout>\",\n\t\t\t\t\t],\n\t\t\t\t},\n\t\t\t\tonFailure: {\n\t\t\t\t\tother: {\n\t\t\t\t\t\ttype: \"run_neon_init\",\n\t\t\t\t\t\targs: [\n\t\t\t\t\t\t\t\"db\",\n\t\t\t\t\t\t\t\"--json\",\n\t\t\t\t\t\t\t\"--error\",\n\t\t\t\t\t\t\t\"projects-list-failed\",\n\t\t\t\t\t\t],\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t};\n\t}\n\n\t// Default: start by listing orgs\n\treturn {\n\t\tphase: \"db\",\n\t\tstatus: \"ready\",\n\t\tnextAction: {\n\t\t\ttype: \"run_command\",\n\t\t\tcommand: \"CI= npx -y neonctl orgs list --output json\",\n\t\t\tdescription: \"Listing your Neon organizations.\",\n\t\t\ttimeout: 30000,\n\t\t\tonSuccess: {\n\t\t\t\ttype: \"run_neon_init\",\n\t\t\t\targs: [\"db\", \"--json\", \"--orgs-result\", \"<stdout>\"],\n\t\t\t},\n\t\t\tonFailure: {\n\t\t\t\tother: {\n\t\t\t\t\ttype: \"run_neon_init\",\n\t\t\t\t\targs: [\"db\", \"--json\", \"--error\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
@@ -0,0 +1,26 @@
1
+ import { PhaseResponse } from "../types.js";
2
+
3
+ //#region src/lib/phases/getting-started.d.ts
4
+ interface GettingStartedPhaseOptions {
5
+ agent?: string;
6
+ hasConnectionString?: boolean;
7
+ framework?: string;
8
+ orm?: string;
9
+ migrationTool?: string;
10
+ migrationDir?: string;
11
+ /** Neon features required by the project (from .neon or template) */
12
+ features?: string[];
13
+ /** Preview mode — restricts project creation to new projects in AWS us-east */
14
+ preview?: boolean;
15
+ }
16
+ /**
17
+ * Initiates the "Get started with Neon" workflow.
18
+ *
19
+ * Steps are concrete and executable — each has a CLI command to run
20
+ * or a specific file operation. The agent should attempt each step
21
+ * in order and actually perform the action using the neonctl CLI.
22
+ */
23
+ declare function handleGettingStartedPhase(options: GettingStartedPhaseOptions): Promise<PhaseResponse>;
24
+ //#endregion
25
+ export { GettingStartedPhaseOptions, handleGettingStartedPhase };
26
+ //# sourceMappingURL=getting-started.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getting-started.d.ts","names":[],"sources":["../../../src/lib/phases/getting-started.ts"],"mappings":";;;UAGiB,0BAAA;;EAAA,mBAAA,CAAA,EAAA,OAA0B;EAoBrB,SAAA,CAAA,EAAA,MAAA;EAAyB,GAAA,CAAA,EAAA,MAAA;eACrC,CAAA,EAAA,MAAA;cACC,CAAA,EAAA,MAAA;;EAAD,QAAA,CAAA,EAAA,MAAA,EAAA;;;;;;;;;;;iBAFY,yBAAA,UACZ,6BACP,QAAQ"}
@@ -0,0 +1,195 @@
1
+ import { SKILL_REFERENCE_URLS, ensureSkillsUpToDate } from "../skills.js";
2
+ //#region src/lib/phases/getting-started.ts
3
+ /**
4
+ * Initiates the "Get started with Neon" workflow.
5
+ *
6
+ * Steps are concrete and executable — each has a CLI command to run
7
+ * or a specific file operation. The agent should attempt each step
8
+ * in order and actually perform the action using the neonctl CLI.
9
+ */
10
+ async function handleGettingStartedPhase(options) {
11
+ if (options.agent) await ensureSkillsUpToDate(options.agent);
12
+ const steps = [];
13
+ if (!options.hasConnectionString) {
14
+ if (options.preview) steps.push({
15
+ id: "select_org",
16
+ description: [
17
+ "List the user's Neon organizations using the CLI command below.",
18
+ "If only one org exists, use it automatically.",
19
+ "If multiple orgs exist, ask the user which one to use.",
20
+ "Remember the selected org ID for the next steps."
21
+ ].join(" "),
22
+ command: "CI= npx -y neonctl orgs list --output json"
23
+ }, {
24
+ id: "select_or_create_project",
25
+ description: [
26
+ "List existing Neon projects in the selected organization using the CLI command below (replace <org-id> with the selected org ID).",
27
+ "IMPORTANT: Preview features require a project in the AWS us-east-2 region created on or after 2026-06-11.",
28
+ "Filter the project list to ONLY show projects where region_id is 'aws-us-east-2' AND created_at is on or after '2026-06-11'.",
29
+ "If eligible projects exist, present them alongside a 'Create new project' option.",
30
+ "If no eligible projects exist, tell the user and proceed directly to creating a new one.",
31
+ "IMPORTANT: Always include --org-id when creating a project to avoid interactive prompts."
32
+ ].join(" "),
33
+ command: "CI= npx -y neonctl projects list --org-id <org-id> --output json"
34
+ }, {
35
+ id: "create_project_if_needed",
36
+ description: [
37
+ "If the user chose to create a new project, create it in the AWS us-east-2 region using the CLI command below (replace <org-id> and <project-name>).",
38
+ "Ask the user for a project name (suggest the current directory name).",
39
+ "If the user chose an existing eligible project, skip this step."
40
+ ].join(" "),
41
+ command: "CI= npx -y neonctl projects create --name <project-name> --org-id <org-id> --region-id aws-us-east-2 --output json"
42
+ });
43
+ else steps.push({
44
+ id: "select_org",
45
+ description: [
46
+ "List the user's Neon organizations using the CLI command below.",
47
+ "If only one org exists, use it automatically.",
48
+ "If multiple orgs exist, ask the user which one to use.",
49
+ "Remember the selected org ID for the next steps."
50
+ ].join(" "),
51
+ command: "CI= npx -y neonctl orgs list --output json"
52
+ }, {
53
+ id: "select_or_create_project",
54
+ description: [
55
+ "List existing Neon projects in the selected organization using the CLI command below (replace <org-id> with the selected org ID).",
56
+ "Ask the user whether they want to use an existing project or create a new one.",
57
+ "If creating new, ask the user for a project name (suggest the current directory name).",
58
+ "IMPORTANT: Always include --org-id when creating a project to avoid interactive prompts."
59
+ ].join(" "),
60
+ command: "CI= npx -y neonctl projects list --org-id <org-id> --output json"
61
+ }, {
62
+ id: "create_project_if_needed",
63
+ description: ["If the user chose to create a new project, create it using the CLI command below (replace <org-id> and <project-name>).", "If the user chose an existing project, skip this step."].join(" "),
64
+ command: "CI= npx -y neonctl projects create --name <project-name> --org-id <org-id> --output json"
65
+ });
66
+ steps.push({
67
+ id: "create_neon_context",
68
+ description: [
69
+ "Update the .neon context file in the project root with the selected org and project IDs.",
70
+ "IMPORTANT: If a .neon file already exists, you MUST read it first, then merge the new orgId and projectId into the existing content. Do NOT overwrite the file — other fields (like _init, branch, etc.) must be preserved.",
71
+ "If no .neon file exists, create one.",
72
+ "The file is JSON. Add/update only the orgId and projectId fields: {\"orgId\": \"<org-id>\", \"projectId\": \"<project-id>\", ...existing fields}.",
73
+ "This file is safe to commit — it contains no secrets."
74
+ ].join(" ")
75
+ });
76
+ steps.push({
77
+ id: "install_dependencies",
78
+ description: [
79
+ "Check if node_modules exists in the project root.",
80
+ "If not, install project dependencies using the appropriate package manager (check for pnpm-lock.yaml, yarn.lock, bun.lockb, or default to npm).",
81
+ "This must be done before `neonctl env pull` because the project's Neon config file may import packages that need to be installed first."
82
+ ].join(" "),
83
+ command: "npm install"
84
+ });
85
+ steps.push({
86
+ id: "pull_env",
87
+ description: [
88
+ "Now that the .neon context file is in place and dependencies are installed, run `neonctl env pull` to populate the project's environment variables.",
89
+ "This automatically writes the database connection string (and any other Neon-managed env vars) to the correct env file.",
90
+ "It reads the .neon context file to determine the project, and writes to the appropriate env file for the project.",
91
+ "Ensure the target env file is listed in .gitignore."
92
+ ].join(" "),
93
+ command: "CI= npx -y neonctl env pull"
94
+ });
95
+ if (options.orm === "prisma") steps.push({
96
+ id: "install_driver",
97
+ description: ["Install the @neondatabase/serverless driver adapter for Prisma.", "This enables Prisma to use Neon's serverless driver for edge/serverless deployments."].join(" "),
98
+ command: "npm install @neondatabase/serverless @prisma/adapter-neon"
99
+ });
100
+ else if (options.orm === "drizzle" || options.orm === "drizzle-orm") steps.push({
101
+ id: "install_driver",
102
+ description: "Install the Neon serverless driver for Drizzle.",
103
+ command: "npm install @neondatabase/serverless"
104
+ });
105
+ else if (!options.orm || options.orm === "none") steps.push({
106
+ id: "install_driver",
107
+ description: "Install the Neon serverless driver for direct database access.",
108
+ command: "npm install @neondatabase/serverless"
109
+ });
110
+ }
111
+ if (options.migrationTool && options.migrationTool !== "none") {
112
+ const tool = options.migrationTool.toLowerCase();
113
+ const migrationDir = options.migrationDir;
114
+ const hasMigrationDir = migrationDir && migrationDir !== "none";
115
+ if (tool === "drizzle") steps.push({
116
+ id: "run_migrations",
117
+ description: [
118
+ hasMigrationDir ? `Check if the ${migrationDir} directory contains .sql migration files.` : "Check if a drizzle migrations directory exists with .sql files.",
119
+ "If .sql files exist, apply them with `npx drizzle-kit migrate`.",
120
+ "If the directory is empty or missing but a drizzle schema file exists (e.g. src/db/schema.ts, drizzle/schema.ts), run `npx drizzle-kit generate` first to create migrations, then `npx drizzle-kit migrate` to apply them.",
121
+ "If neither schema nor migrations exist, skip this step."
122
+ ].join(" "),
123
+ command: "npx drizzle-kit migrate"
124
+ });
125
+ else if (tool === "prisma") steps.push({
126
+ id: "run_migrations",
127
+ description: [
128
+ hasMigrationDir ? `Check if the ${migrationDir} directory contains migration folders.` : "Check if prisma/migrations contains migration folders.",
129
+ "If migrations exist, apply them with `npx prisma migrate deploy`.",
130
+ "If the migrations directory is empty or missing but prisma/schema.prisma has models defined, run `npx prisma migrate dev --name init` to create and apply the initial migration.",
131
+ "If no models are defined, skip this step."
132
+ ].join(" "),
133
+ command: "npx prisma migrate deploy"
134
+ });
135
+ else if (tool === "knex") steps.push({
136
+ id: "run_migrations",
137
+ description: `Apply existing knex migrations to the Neon database.`,
138
+ command: "npx knex migrate:latest"
139
+ });
140
+ } else if (options.preview) steps.push({
141
+ id: "run_migrations",
142
+ description: [
143
+ "Check the scaffolded project for a migration tool and schema.",
144
+ "Look for: drizzle.config.ts/js (Drizzle), prisma/schema.prisma (Prisma), or knexfile.ts/js (Knex).",
145
+ "If Drizzle is found: check if a drizzle migrations directory exists with .sql files. If .sql files exist, run `npx drizzle-kit migrate`. If the directory is empty or missing but a schema file exists, run `npx drizzle-kit generate` first, then `npx drizzle-kit migrate`.",
146
+ "If Prisma is found: check if prisma/migrations contains migration folders. If yes, run `npx prisma migrate deploy`. If not but models exist, run `npx prisma migrate dev --name init`.",
147
+ "If no migration tool is found, skip this step."
148
+ ].join(" ")
149
+ });
150
+ steps.push({
151
+ id: "verify_connection",
152
+ description: [
153
+ "Verify the database connection works by running a SQL query against the Neon database.",
154
+ "Write and run a short script that connects using DATABASE_URL from the project's env file and executes `SELECT 1` (or queries a table from the migration if migrations were run).",
155
+ "Do NOT use the neonctl CLI or MCP tools for this — use a direct database connection to verify end-to-end connectivity."
156
+ ].join(" ")
157
+ });
158
+ return {
159
+ phase: "setup",
160
+ status: "getting_started",
161
+ nextAction: {
162
+ type: "agent_action",
163
+ prerequisite: SKILL_REFERENCE_URLS.gettingStarted,
164
+ steps,
165
+ onComplete: buildOnComplete(options)
166
+ }
167
+ };
168
+ }
169
+ function buildOnComplete(options) {
170
+ const agentArgs = options.agent ? ["--agent", options.agent] : [];
171
+ const features = options.features ?? [];
172
+ const hasFeatureRequirements = features.length > 0;
173
+ if (hasFeatureRequirements && !features.includes("auth")) return {
174
+ type: "run_neon_init",
175
+ args: [
176
+ "finalize",
177
+ "--json",
178
+ ...agentArgs
179
+ ]
180
+ };
181
+ const authSetup = hasFeatureRequirements && features.includes("auth") ? ["--setup"] : [];
182
+ return {
183
+ type: "run_neon_init",
184
+ args: [
185
+ "neon-auth",
186
+ "--json",
187
+ ...agentArgs,
188
+ ...authSetup
189
+ ]
190
+ };
191
+ }
192
+ //#endregion
193
+ export { handleGettingStartedPhase };
194
+
195
+ //# sourceMappingURL=getting-started.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getting-started.js","names":[],"sources":["../../../src/lib/phases/getting-started.ts"],"sourcesContent":["import { ensureSkillsUpToDate, SKILL_REFERENCE_URLS } from \"../skills.js\";\nimport type { PhaseResponse } from \"../types.js\";\n\nexport interface GettingStartedPhaseOptions {\n\tagent?: string;\n\thasConnectionString?: boolean;\n\tframework?: string;\n\torm?: string;\n\tmigrationTool?: string;\n\tmigrationDir?: string;\n\t/** Neon features required by the project (from .neon or template) */\n\tfeatures?: string[];\n\t/** Preview mode — restricts project creation to new projects in AWS us-east */\n\tpreview?: boolean;\n}\n\n/**\n * Initiates the \"Get started with Neon\" workflow.\n *\n * Steps are concrete and executable — each has a CLI command to run\n * or a specific file operation. The agent should attempt each step\n * in order and actually perform the action using the neonctl CLI.\n */\nexport async function handleGettingStartedPhase(\n\toptions: GettingStartedPhaseOptions,\n): Promise<PhaseResponse> {\n\t// Ensure skills are up to date (no-op if recently updated)\n\tif (options.agent) {\n\t\tawait ensureSkillsUpToDate(options.agent);\n\t}\n\tconst steps: { id: string; description: string; command?: string }[] = [];\n\n\tif (!options.hasConnectionString) {\n\t\tif (options.preview) {\n\t\t\t// Preview mode: new project in AWS us-east-2, or existing eligible project\n\t\t\tsteps.push(\n\t\t\t\t{\n\t\t\t\t\tid: \"select_org\",\n\t\t\t\t\tdescription: [\n\t\t\t\t\t\t\"List the user's Neon organizations using the CLI command below.\",\n\t\t\t\t\t\t\"If only one org exists, use it automatically.\",\n\t\t\t\t\t\t\"If multiple orgs exist, ask the user which one to use.\",\n\t\t\t\t\t\t\"Remember the selected org ID for the next steps.\",\n\t\t\t\t\t].join(\" \"),\n\t\t\t\t\tcommand: \"CI= npx -y neonctl orgs list --output json\",\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tid: \"select_or_create_project\",\n\t\t\t\t\tdescription: [\n\t\t\t\t\t\t\"List existing Neon projects in the selected organization using the CLI command below (replace <org-id> with the selected org ID).\",\n\t\t\t\t\t\t\"IMPORTANT: Preview features require a project in the AWS us-east-2 region created on or after 2026-06-11.\",\n\t\t\t\t\t\t\"Filter the project list to ONLY show projects where region_id is 'aws-us-east-2' AND created_at is on or after '2026-06-11'.\",\n\t\t\t\t\t\t\"If eligible projects exist, present them alongside a 'Create new project' option.\",\n\t\t\t\t\t\t\"If no eligible projects exist, tell the user and proceed directly to creating a new one.\",\n\t\t\t\t\t\t\"IMPORTANT: Always include --org-id when creating a project to avoid interactive prompts.\",\n\t\t\t\t\t].join(\" \"),\n\t\t\t\t\tcommand:\n\t\t\t\t\t\t\"CI= npx -y neonctl projects list --org-id <org-id> --output json\",\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tid: \"create_project_if_needed\",\n\t\t\t\t\tdescription: [\n\t\t\t\t\t\t\"If the user chose to create a new project, create it in the AWS us-east-2 region using the CLI command below (replace <org-id> and <project-name>).\",\n\t\t\t\t\t\t\"Ask the user for a project name (suggest the current directory name).\",\n\t\t\t\t\t\t\"If the user chose an existing eligible project, skip this step.\",\n\t\t\t\t\t].join(\" \"),\n\t\t\t\t\tcommand:\n\t\t\t\t\t\t\"CI= npx -y neonctl projects create --name <project-name> --org-id <org-id> --region-id aws-us-east-2 --output json\",\n\t\t\t\t},\n\t\t\t);\n\t\t} else {\n\t\t\t// Standard mode: let user choose existing or create new\n\t\t\tsteps.push(\n\t\t\t\t{\n\t\t\t\t\tid: \"select_org\",\n\t\t\t\t\tdescription: [\n\t\t\t\t\t\t\"List the user's Neon organizations using the CLI command below.\",\n\t\t\t\t\t\t\"If only one org exists, use it automatically.\",\n\t\t\t\t\t\t\"If multiple orgs exist, ask the user which one to use.\",\n\t\t\t\t\t\t\"Remember the selected org ID for the next steps.\",\n\t\t\t\t\t].join(\" \"),\n\t\t\t\t\tcommand: \"CI= npx -y neonctl orgs list --output json\",\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tid: \"select_or_create_project\",\n\t\t\t\t\tdescription: [\n\t\t\t\t\t\t\"List existing Neon projects in the selected organization using the CLI command below (replace <org-id> with the selected org ID).\",\n\t\t\t\t\t\t\"Ask the user whether they want to use an existing project or create a new one.\",\n\t\t\t\t\t\t\"If creating new, ask the user for a project name (suggest the current directory name).\",\n\t\t\t\t\t\t\"IMPORTANT: Always include --org-id when creating a project to avoid interactive prompts.\",\n\t\t\t\t\t].join(\" \"),\n\t\t\t\t\tcommand:\n\t\t\t\t\t\t\"CI= npx -y neonctl projects list --org-id <org-id> --output json\",\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tid: \"create_project_if_needed\",\n\t\t\t\t\tdescription: [\n\t\t\t\t\t\t\"If the user chose to create a new project, create it using the CLI command below (replace <org-id> and <project-name>).\",\n\t\t\t\t\t\t\"If the user chose an existing project, skip this step.\",\n\t\t\t\t\t].join(\" \"),\n\t\t\t\t\tcommand:\n\t\t\t\t\t\t\"CI= npx -y neonctl projects create --name <project-name> --org-id <org-id> --output json\",\n\t\t\t\t},\n\t\t\t);\n\t\t}\n\n\t\t// Create/update .neon context file\n\t\tsteps.push({\n\t\t\tid: \"create_neon_context\",\n\t\t\tdescription: [\n\t\t\t\t\"Update the .neon context file in the project root with the selected org and project IDs.\",\n\t\t\t\t\"IMPORTANT: If a .neon file already exists, you MUST read it first, then merge the new orgId and projectId into the existing content. Do NOT overwrite the file — other fields (like _init, branch, etc.) must be preserved.\",\n\t\t\t\t\"If no .neon file exists, create one.\",\n\t\t\t\t'The file is JSON. Add/update only the orgId and projectId fields: {\"orgId\": \"<org-id>\", \"projectId\": \"<project-id>\", ...existing fields}.',\n\t\t\t\t\"This file is safe to commit — it contains no secrets.\",\n\t\t\t].join(\" \"),\n\t\t});\n\n\t\t// Install project dependencies (required before env pull — config files may import packages)\n\t\tsteps.push({\n\t\t\tid: \"install_dependencies\",\n\t\t\tdescription: [\n\t\t\t\t\"Check if node_modules exists in the project root.\",\n\t\t\t\t\"If not, install project dependencies using the appropriate package manager (check for pnpm-lock.yaml, yarn.lock, bun.lockb, or default to npm).\",\n\t\t\t\t\"This must be done before `neonctl env pull` because the project's Neon config file may import packages that need to be installed first.\",\n\t\t\t].join(\" \"),\n\t\t\tcommand: \"npm install\",\n\t\t});\n\n\t\t// Pull environment variables (connection string, etc.) from Neon\n\t\tsteps.push({\n\t\t\tid: \"pull_env\",\n\t\t\tdescription: [\n\t\t\t\t\"Now that the .neon context file is in place and dependencies are installed, run `neonctl env pull` to populate the project's environment variables.\",\n\t\t\t\t\"This automatically writes the database connection string (and any other Neon-managed env vars) to the correct env file.\",\n\t\t\t\t\"It reads the .neon context file to determine the project, and writes to the appropriate env file for the project.\",\n\t\t\t\t\"Ensure the target env file is listed in .gitignore.\",\n\t\t\t].join(\" \"),\n\t\t\tcommand: \"CI= npx -y neonctl env pull\",\n\t\t});\n\n\t\t// Step 6: Install Neon serverless driver if needed\n\t\tif (options.orm === \"prisma\") {\n\t\t\tsteps.push({\n\t\t\t\tid: \"install_driver\",\n\t\t\t\tdescription: [\n\t\t\t\t\t\"Install the @neondatabase/serverless driver adapter for Prisma.\",\n\t\t\t\t\t\"This enables Prisma to use Neon's serverless driver for edge/serverless deployments.\",\n\t\t\t\t].join(\" \"),\n\t\t\t\tcommand:\n\t\t\t\t\t\"npm install @neondatabase/serverless @prisma/adapter-neon\",\n\t\t\t});\n\t\t} else if (options.orm === \"drizzle\" || options.orm === \"drizzle-orm\") {\n\t\t\tsteps.push({\n\t\t\t\tid: \"install_driver\",\n\t\t\t\tdescription: \"Install the Neon serverless driver for Drizzle.\",\n\t\t\t\tcommand: \"npm install @neondatabase/serverless\",\n\t\t\t});\n\t\t} else if (!options.orm || options.orm === \"none\") {\n\t\t\tsteps.push({\n\t\t\t\tid: \"install_driver\",\n\t\t\t\tdescription:\n\t\t\t\t\t\"Install the Neon serverless driver for direct database access.\",\n\t\t\t\tcommand: \"npm install @neondatabase/serverless\",\n\t\t\t});\n\t\t}\n\t}\n\n\t// Run migrations if applicable\n\tif (options.migrationTool && options.migrationTool !== \"none\") {\n\t\tconst tool = options.migrationTool.toLowerCase();\n\t\tconst migrationDir = options.migrationDir;\n\t\tconst hasMigrationDir = migrationDir && migrationDir !== \"none\";\n\n\t\tif (tool === \"drizzle\") {\n\t\t\tsteps.push({\n\t\t\t\tid: \"run_migrations\",\n\t\t\t\tdescription: [\n\t\t\t\t\thasMigrationDir\n\t\t\t\t\t\t? `Check if the ${migrationDir} directory contains .sql migration files.`\n\t\t\t\t\t\t: \"Check if a drizzle migrations directory exists with .sql files.\",\n\t\t\t\t\t\"If .sql files exist, apply them with `npx drizzle-kit migrate`.\",\n\t\t\t\t\t\"If the directory is empty or missing but a drizzle schema file exists (e.g. src/db/schema.ts, drizzle/schema.ts), run `npx drizzle-kit generate` first to create migrations, then `npx drizzle-kit migrate` to apply them.\",\n\t\t\t\t\t\"If neither schema nor migrations exist, skip this step.\",\n\t\t\t\t].join(\" \"),\n\t\t\t\tcommand: \"npx drizzle-kit migrate\",\n\t\t\t});\n\t\t} else if (tool === \"prisma\") {\n\t\t\tsteps.push({\n\t\t\t\tid: \"run_migrations\",\n\t\t\t\tdescription: [\n\t\t\t\t\thasMigrationDir\n\t\t\t\t\t\t? `Check if the ${migrationDir} directory contains migration folders.`\n\t\t\t\t\t\t: \"Check if prisma/migrations contains migration folders.\",\n\t\t\t\t\t\"If migrations exist, apply them with `npx prisma migrate deploy`.\",\n\t\t\t\t\t\"If the migrations directory is empty or missing but prisma/schema.prisma has models defined, run `npx prisma migrate dev --name init` to create and apply the initial migration.\",\n\t\t\t\t\t\"If no models are defined, skip this step.\",\n\t\t\t\t].join(\" \"),\n\t\t\t\tcommand: \"npx prisma migrate deploy\",\n\t\t\t});\n\t\t} else if (tool === \"knex\") {\n\t\t\tsteps.push({\n\t\t\t\tid: \"run_migrations\",\n\t\t\t\tdescription: `Apply existing knex migrations to the Neon database.`,\n\t\t\t\tcommand: \"npx knex migrate:latest\",\n\t\t\t});\n\t\t}\n\t} else if (options.preview) {\n\t\t// Bootstrap flow: migration tool wasn't detected because the project was\n\t\t// inspected before scaffolding. Detect and run migrations from the scaffolded template.\n\t\tsteps.push({\n\t\t\tid: \"run_migrations\",\n\t\t\tdescription: [\n\t\t\t\t\"Check the scaffolded project for a migration tool and schema.\",\n\t\t\t\t\"Look for: drizzle.config.ts/js (Drizzle), prisma/schema.prisma (Prisma), or knexfile.ts/js (Knex).\",\n\t\t\t\t\"If Drizzle is found: check if a drizzle migrations directory exists with .sql files. If .sql files exist, run `npx drizzle-kit migrate`. If the directory is empty or missing but a schema file exists, run `npx drizzle-kit generate` first, then `npx drizzle-kit migrate`.\",\n\t\t\t\t\"If Prisma is found: check if prisma/migrations contains migration folders. If yes, run `npx prisma migrate deploy`. If not but models exist, run `npx prisma migrate dev --name init`.\",\n\t\t\t\t\"If no migration tool is found, skip this step.\",\n\t\t\t].join(\" \"),\n\t\t});\n\t}\n\n\t// Verify the connection\n\tsteps.push({\n\t\tid: \"verify_connection\",\n\t\tdescription: [\n\t\t\t\"Verify the database connection works by running a SQL query against the Neon database.\",\n\t\t\t\"Write and run a short script that connects using DATABASE_URL from the project's env file and executes `SELECT 1` (or queries a table from the migration if migrations were run).\",\n\t\t\t\"Do NOT use the neonctl CLI or MCP tools for this — use a direct database connection to verify end-to-end connectivity.\",\n\t\t].join(\" \"),\n\t});\n\n\treturn {\n\t\tphase: \"setup\",\n\t\tstatus: \"getting_started\",\n\t\tnextAction: {\n\t\t\ttype: \"agent_action\",\n\t\t\tprerequisite: SKILL_REFERENCE_URLS.gettingStarted,\n\t\t\tsteps,\n\t\t\tonComplete: buildOnComplete(options),\n\t\t},\n\t};\n}\n\nfunction buildOnComplete(\n\toptions: GettingStartedPhaseOptions,\n): import(\"../types.js\").RunNeonInitAction {\n\tconst agentArgs = options.agent ? [\"--agent\", options.agent] : [];\n\tconst features = options.features ?? [];\n\tconst hasFeatureRequirements = features.length > 0;\n\n\t// If features are specified and auth is not required, go to finalize\n\tif (hasFeatureRequirements && !features.includes(\"auth\")) {\n\t\treturn {\n\t\t\ttype: \"run_neon_init\",\n\t\t\targs: [\"finalize\", \"--json\", ...agentArgs],\n\t\t};\n\t}\n\n\t// Chain to neon-auth — if user already selected auth via features, go straight to setup\n\tconst authSetup =\n\t\thasFeatureRequirements && features.includes(\"auth\") ? [\"--setup\"] : [];\n\treturn {\n\t\ttype: \"run_neon_init\",\n\t\targs: [\"neon-auth\", \"--json\", ...agentArgs, ...authSetup],\n\t};\n}\n"],"mappings":";;;;;;;;;AAuBA,eAAsB,0BACrB,SACyB;CAEzB,IAAI,QAAQ,OACX,MAAM,qBAAqB,QAAQ,KAAK;CAEzC,MAAM,QAAiE,CAAC;CAExE,IAAI,CAAC,QAAQ,qBAAqB;EACjC,IAAI,QAAQ,SAEX,MAAM,KACL;GACC,IAAI;GACJ,aAAa;IACZ;IACA;IACA;IACA;GACD,CAAC,CAAC,KAAK,GAAG;GACV,SAAS;EACV,GACA;GACC,IAAI;GACJ,aAAa;IACZ;IACA;IACA;IACA;IACA;IACA;GACD,CAAC,CAAC,KAAK,GAAG;GACV,SACC;EACF,GACA;GACC,IAAI;GACJ,aAAa;IACZ;IACA;IACA;GACD,CAAC,CAAC,KAAK,GAAG;GACV,SACC;EACF,CACD;OAGA,MAAM,KACL;GACC,IAAI;GACJ,aAAa;IACZ;IACA;IACA;IACA;GACD,CAAC,CAAC,KAAK,GAAG;GACV,SAAS;EACV,GACA;GACC,IAAI;GACJ,aAAa;IACZ;IACA;IACA;IACA;GACD,CAAC,CAAC,KAAK,GAAG;GACV,SACC;EACF,GACA;GACC,IAAI;GACJ,aAAa,CACZ,2HACA,wDACD,CAAC,CAAC,KAAK,GAAG;GACV,SACC;EACF,CACD;EAID,MAAM,KAAK;GACV,IAAI;GACJ,aAAa;IACZ;IACA;IACA;IACA;IACA;GACD,CAAC,CAAC,KAAK,GAAG;EACX,CAAC;EAGD,MAAM,KAAK;GACV,IAAI;GACJ,aAAa;IACZ;IACA;IACA;GACD,CAAC,CAAC,KAAK,GAAG;GACV,SAAS;EACV,CAAC;EAGD,MAAM,KAAK;GACV,IAAI;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AO;EACP,QAAQ;EACR,YAAY;GACX,MAAM;GACN,cAAc,qBAAqB;GACnC;GACA,YAAY,gBAAgB,OAAO;EACpC;CACD;AACD;AAEA,SAAS,gBACR,SAC0C;CAC1C,MAAM,YAAY,QAAQ,QAAQ,CAAC,WAAW,QAAQ,KAAK,IAAI,CAAC;CAChE,MAAM,WAAW,QAAQ,YAAY,CAAC;CACtC,MAAM,yBAAyB,SAAS,SAAS;CAGjD,IAAI,0BAA0B,CAAC,SAAS,SAAS,MAAM,GACtD,OAAO;EACN,MAAM;EACN,MAAM;GAAC;GAAY;GAAU,GAAG;EAAS;CAC1C;CAID,MAAM,YACL,0BAA0B,SAAS,SAAS,MAAM,IAAI,CAAC,SAAS,IAAI,CAAC;CACtE,OAAO;EACN,MAAM;EACN,MAAM;GAAC;GAAa;GAAU,GAAG;GAAW,GAAG;EAAS;CACzD;AACD"}
@@ -0,0 +1,15 @@
1
+ import { Editor, PhaseResponse } from "../types.js";
2
+
3
+ //#region src/lib/phases/mcp.d.ts
4
+ interface McpPhaseOptions {
5
+ agent?: string;
6
+ editor?: Editor;
7
+ status?: boolean;
8
+ install?: boolean;
9
+ scope?: "global" | "project";
10
+ mcpConfigured?: boolean | null;
11
+ }
12
+ declare function handleMcpPhase(options: McpPhaseOptions): Promise<PhaseResponse>;
13
+ //#endregion
14
+ export { McpPhaseOptions, handleMcpPhase };
15
+ //# sourceMappingURL=mcp.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mcp.d.ts","names":[],"sources":["../../../src/lib/phases/mcp.ts"],"mappings":";;;UAIiB,eAAA;;EAAA,MAAA,CAAA,EAEP,MAFO;EASK,MAAA,CAAA,EAAA,OAAA;EAAc,OAAA,CAAA,EAAA,OAAA;OAC1B,CAAA,EAAA,QAAA,GAAA,SAAA;eACC,CAAA,EAAA,OAAA,GAAA,IAAA;;AAAD,iBAFY,cAAA,CAEZ,OAAA,EADA,eACA,CAAA,EAAP,OAAO,CAAC,aAAD,CAAA"}