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.
- package/dist/cli.js +368 -33
- package/dist/cli.js.map +1 -1
- package/dist/index.d.ts +15 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +220 -41
- package/dist/index.js.map +1 -1
- package/dist/interactive.d.ts +12 -0
- package/dist/interactive.d.ts.map +1 -0
- package/dist/interactive.js +495 -0
- package/dist/interactive.js.map +1 -0
- package/dist/lib/agents.d.ts +23 -0
- package/dist/lib/agents.d.ts.map +1 -0
- package/dist/lib/agents.js +148 -0
- package/dist/lib/agents.js.map +1 -0
- package/dist/lib/auth.d.ts +10 -3
- package/dist/lib/auth.d.ts.map +1 -1
- package/dist/lib/auth.js +20 -13
- package/dist/lib/auth.js.map +1 -1
- package/dist/lib/bootstrap.d.ts +30 -0
- package/dist/lib/bootstrap.d.ts.map +1 -0
- package/dist/lib/bootstrap.js +61 -0
- package/dist/lib/bootstrap.js.map +1 -0
- package/dist/lib/build-config.d.ts +5 -0
- package/dist/lib/build-config.d.ts.map +1 -0
- package/dist/lib/build-config.js +6 -0
- package/dist/lib/build-config.js.map +1 -0
- package/dist/lib/detect-agent.d.ts +22 -0
- package/dist/lib/detect-agent.d.ts.map +1 -0
- package/dist/lib/detect-agent.js +65 -0
- package/dist/lib/detect-agent.js.map +1 -0
- package/dist/lib/editors.d.ts.map +1 -1
- package/dist/lib/editors.js +1 -2
- package/dist/lib/editors.js.map +1 -1
- package/dist/lib/extension.d.ts +11 -3
- package/dist/lib/extension.d.ts.map +1 -1
- package/dist/lib/extension.js +29 -9
- package/dist/lib/extension.js.map +1 -1
- package/dist/lib/inspect.d.ts +28 -0
- package/dist/lib/inspect.d.ts.map +1 -0
- package/dist/lib/inspect.js +190 -0
- package/dist/lib/inspect.js.map +1 -0
- package/dist/lib/install.d.ts +10 -4
- package/dist/lib/install.d.ts.map +1 -1
- package/dist/lib/install.js +74 -71
- package/dist/lib/install.js.map +1 -1
- package/dist/lib/neonctl.d.ts +32 -0
- package/dist/lib/neonctl.d.ts.map +1 -0
- package/dist/lib/neonctl.js +149 -0
- package/dist/lib/neonctl.js.map +1 -0
- package/dist/lib/phases/auth.d.ts +12 -0
- package/dist/lib/phases/auth.d.ts.map +1 -0
- package/dist/lib/phases/auth.js +188 -0
- package/dist/lib/phases/auth.js.map +1 -0
- package/dist/lib/phases/cleanup.d.ts +12 -0
- package/dist/lib/phases/cleanup.d.ts.map +1 -0
- package/dist/lib/phases/cleanup.js +29 -0
- package/dist/lib/phases/cleanup.js.map +1 -0
- package/dist/lib/phases/db.d.ts +17 -0
- package/dist/lib/phases/db.d.ts.map +1 -0
- package/dist/lib/phases/db.js +258 -0
- package/dist/lib/phases/db.js.map +1 -0
- package/dist/lib/phases/getting-started.d.ts +26 -0
- package/dist/lib/phases/getting-started.d.ts.map +1 -0
- package/dist/lib/phases/getting-started.js +195 -0
- package/dist/lib/phases/getting-started.js.map +1 -0
- package/dist/lib/phases/mcp.d.ts +15 -0
- package/dist/lib/phases/mcp.d.ts.map +1 -0
- package/dist/lib/phases/mcp.js +179 -0
- package/dist/lib/phases/mcp.js.map +1 -0
- package/dist/lib/phases/migrations.d.ts +14 -0
- package/dist/lib/phases/migrations.d.ts.map +1 -0
- package/dist/lib/phases/migrations.js +239 -0
- package/dist/lib/phases/migrations.js.map +1 -0
- package/dist/lib/phases/neon-auth.d.ts +13 -0
- package/dist/lib/phases/neon-auth.d.ts.map +1 -0
- package/dist/lib/phases/neon-auth.js +117 -0
- package/dist/lib/phases/neon-auth.js.map +1 -0
- package/dist/lib/phases/setup.d.ts +41 -0
- package/dist/lib/phases/setup.d.ts.map +1 -0
- package/dist/lib/phases/setup.js +689 -0
- package/dist/lib/phases/setup.js.map +1 -0
- package/dist/lib/phases/skills.d.ts +14 -0
- package/dist/lib/phases/skills.d.ts.map +1 -0
- package/dist/lib/phases/skills.js +80 -0
- package/dist/lib/phases/skills.js.map +1 -0
- package/dist/lib/phases/status.d.ts +10 -0
- package/dist/lib/phases/status.d.ts.map +1 -0
- package/dist/lib/phases/status.js +65 -0
- package/dist/lib/phases/status.js.map +1 -0
- package/dist/lib/resolve-context.d.ts +19 -0
- package/dist/lib/resolve-context.d.ts.map +1 -0
- package/dist/lib/resolve-context.js +112 -0
- package/dist/lib/resolve-context.js.map +1 -0
- package/dist/lib/route-command.d.ts +8 -0
- package/dist/lib/route-command.d.ts.map +1 -0
- package/dist/lib/route-command.js +195 -0
- package/dist/lib/route-command.js.map +1 -0
- package/dist/lib/skills.d.ts +21 -4
- package/dist/lib/skills.d.ts.map +1 -1
- package/dist/lib/skills.js +129 -22
- package/dist/lib/skills.js.map +1 -1
- package/dist/lib/types.d.ts +146 -13
- package/dist/lib/types.d.ts.map +1 -1
- package/dist/lib/types.js +1 -1
- package/dist/lib/vsix.d.ts +15 -0
- package/dist/lib/vsix.d.ts.map +1 -0
- package/dist/lib/vsix.js +91 -0
- package/dist/lib/vsix.js.map +1 -0
- package/dist/v2.d.ts +31 -0
- package/dist/v2.d.ts.map +1 -0
- package/dist/v2.js +147 -0
- package/dist/v2.js.map +1 -0
- package/package.json +9 -4
- package/dist/lib/mcp-config.d.ts +0 -24
- package/dist/lib/mcp-config.d.ts.map +0 -1
- package/dist/lib/mcp-config.js +0 -51
- package/dist/lib/mcp-config.js.map +0 -1
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
import { resolveAddMcpAgentId } from "../agents.js";
|
|
2
|
+
import { isAuthenticated } from "../auth.js";
|
|
3
|
+
//#region src/lib/phases/mcp.ts
|
|
4
|
+
async function handleMcpPhase(options) {
|
|
5
|
+
const agentArgs = options.agent ? [
|
|
6
|
+
"--agent",
|
|
7
|
+
options.agent,
|
|
8
|
+
"--json"
|
|
9
|
+
] : ["--json"];
|
|
10
|
+
if (options.status) return {
|
|
11
|
+
phase: "tooling",
|
|
12
|
+
status: "status",
|
|
13
|
+
nextAction: {
|
|
14
|
+
type: "agent_check",
|
|
15
|
+
checks: [{
|
|
16
|
+
id: "mcp_server",
|
|
17
|
+
description: "Check if the Neon MCP server is already configured in your MCP server list",
|
|
18
|
+
lookFor: ["An MCP server entry named 'Neon' or with URL containing 'mcp.neon.tech'"]
|
|
19
|
+
}],
|
|
20
|
+
reportBack: {
|
|
21
|
+
type: "run_neon_init",
|
|
22
|
+
args: [
|
|
23
|
+
"mcp",
|
|
24
|
+
"--json",
|
|
25
|
+
...options.agent ? ["--agent", options.agent] : [],
|
|
26
|
+
"--mcp-configured",
|
|
27
|
+
"<true|false>"
|
|
28
|
+
]
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
if (options.install) {
|
|
33
|
+
if (!await isAuthenticated()) return {
|
|
34
|
+
phase: "tooling",
|
|
35
|
+
status: "auth_required",
|
|
36
|
+
nextAction: {
|
|
37
|
+
type: "run_neon_init",
|
|
38
|
+
args: ["auth", "--json"]
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
const scope = options.scope ?? "global";
|
|
42
|
+
const mcpAgentId = resolveAddMcpAgentId(options.agent ?? "claude-code");
|
|
43
|
+
const isCursor = mcpAgentId === "cursor" || options.agent?.toLowerCase() === "cursor";
|
|
44
|
+
const isClaudeCode = mcpAgentId === "claude-code" || options.agent?.toLowerCase() === "claude-code";
|
|
45
|
+
const installCmd = [
|
|
46
|
+
"npx -y add-mcp https://mcp.neon.tech/mcp",
|
|
47
|
+
scope === "global" ? "-g" : "",
|
|
48
|
+
"-n Neon",
|
|
49
|
+
"-y",
|
|
50
|
+
`-a ${mcpAgentId}`
|
|
51
|
+
].filter(Boolean).join(" ");
|
|
52
|
+
let enableNote = "";
|
|
53
|
+
if (isCursor && scope === "project") enableNote = " Note: Cursor disables project-level MCP servers by default — after installation, open Cursor Settings > MCP and toggle the \"Neon\" server on.";
|
|
54
|
+
else if (isClaudeCode) enableNote = " Note: Claude Code requires approval for newly added MCP servers. When prompted, approve the \"Neon\" server to enable it.";
|
|
55
|
+
return {
|
|
56
|
+
phase: "tooling",
|
|
57
|
+
status: "installing",
|
|
58
|
+
nextAction: {
|
|
59
|
+
type: "run_command",
|
|
60
|
+
command: installCmd,
|
|
61
|
+
description: `Installing Neon MCP server (${scope} scope) for ${mcpAgentId}.${enableNote}`,
|
|
62
|
+
timeout: 6e4,
|
|
63
|
+
onSuccess: {
|
|
64
|
+
type: "run_neon_init",
|
|
65
|
+
args: [
|
|
66
|
+
"skills",
|
|
67
|
+
"--json",
|
|
68
|
+
...options.agent ? ["--agent", options.agent] : [],
|
|
69
|
+
"--install"
|
|
70
|
+
]
|
|
71
|
+
},
|
|
72
|
+
onFailure: { other: {
|
|
73
|
+
type: "ask_user",
|
|
74
|
+
question: "Failed to install the Neon MCP server automatically. Would you like to try again or configure it manually?",
|
|
75
|
+
options: [{
|
|
76
|
+
value: "retry",
|
|
77
|
+
label: "Try again"
|
|
78
|
+
}, {
|
|
79
|
+
value: "manual",
|
|
80
|
+
label: "I'll configure it manually"
|
|
81
|
+
}],
|
|
82
|
+
responseMapping: {
|
|
83
|
+
retry: { args: [
|
|
84
|
+
"mcp",
|
|
85
|
+
"--json",
|
|
86
|
+
...options.agent ? ["--agent", options.agent] : [],
|
|
87
|
+
"--install"
|
|
88
|
+
] },
|
|
89
|
+
manual: { args: agentArgs }
|
|
90
|
+
}
|
|
91
|
+
} }
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
if (options.mcpConfigured === true) return {
|
|
96
|
+
phase: "tooling",
|
|
97
|
+
status: "mcp_configured",
|
|
98
|
+
nextAction: {
|
|
99
|
+
type: "run_neon_init",
|
|
100
|
+
args: [
|
|
101
|
+
"skills",
|
|
102
|
+
"--json",
|
|
103
|
+
...options.agent ? ["--agent", options.agent] : [],
|
|
104
|
+
"--install"
|
|
105
|
+
]
|
|
106
|
+
}
|
|
107
|
+
};
|
|
108
|
+
if (options.mcpConfigured === false) return {
|
|
109
|
+
phase: "tooling",
|
|
110
|
+
status: "install_needed",
|
|
111
|
+
nextAction: {
|
|
112
|
+
type: "ask_user",
|
|
113
|
+
question: "The Neon MCP server is not yet configured. Would you like to install it?",
|
|
114
|
+
options: [
|
|
115
|
+
{
|
|
116
|
+
value: "defaults",
|
|
117
|
+
label: "Yes, install with default settings"
|
|
118
|
+
},
|
|
119
|
+
{
|
|
120
|
+
value: "project_scope",
|
|
121
|
+
label: "Yes, install for this project only"
|
|
122
|
+
},
|
|
123
|
+
{
|
|
124
|
+
value: "skip",
|
|
125
|
+
label: "Skip for now"
|
|
126
|
+
}
|
|
127
|
+
],
|
|
128
|
+
context: "The Neon MCP server gives your AI assistant direct access to Neon database operations like creating projects, running queries, and managing branches." + (options.agent?.toLowerCase() === "cursor" || options.editor?.toLowerCase() === "cursor" ? " Note: Cursor disables project-level MCP servers by default. If you choose project scope, you will need to manually enable the Neon server in Cursor Settings > MCP. Global scope is recommended for Cursor." : ""),
|
|
129
|
+
responseMapping: {
|
|
130
|
+
defaults: { args: [
|
|
131
|
+
"mcp",
|
|
132
|
+
"--json",
|
|
133
|
+
...options.agent ? ["--agent", options.agent] : [],
|
|
134
|
+
"--install"
|
|
135
|
+
] },
|
|
136
|
+
project_scope: { args: [
|
|
137
|
+
"mcp",
|
|
138
|
+
"--json",
|
|
139
|
+
...options.agent ? ["--agent", options.agent] : [],
|
|
140
|
+
"--install",
|
|
141
|
+
"--scope",
|
|
142
|
+
"project"
|
|
143
|
+
] },
|
|
144
|
+
skip: { args: [
|
|
145
|
+
"skills",
|
|
146
|
+
"--json",
|
|
147
|
+
...options.agent ? ["--agent", options.agent] : [],
|
|
148
|
+
"--install"
|
|
149
|
+
] }
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
};
|
|
153
|
+
return {
|
|
154
|
+
phase: "tooling",
|
|
155
|
+
status: "detection_needed",
|
|
156
|
+
nextAction: {
|
|
157
|
+
type: "agent_check",
|
|
158
|
+
checks: [{
|
|
159
|
+
id: "mcp_server",
|
|
160
|
+
description: "Check if the Neon MCP server is already configured in your MCP server list",
|
|
161
|
+
lookFor: ["An MCP server entry named 'Neon' or with URL containing 'mcp.neon.tech'"]
|
|
162
|
+
}],
|
|
163
|
+
reportBack: {
|
|
164
|
+
type: "run_neon_init",
|
|
165
|
+
args: [
|
|
166
|
+
"mcp",
|
|
167
|
+
"--json",
|
|
168
|
+
...options.agent ? ["--agent", options.agent] : [],
|
|
169
|
+
"--mcp-configured",
|
|
170
|
+
"<true|false>"
|
|
171
|
+
]
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
//#endregion
|
|
177
|
+
export { handleMcpPhase };
|
|
178
|
+
|
|
179
|
+
//# sourceMappingURL=mcp.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcp.js","names":[],"sources":["../../../src/lib/phases/mcp.ts"],"sourcesContent":["import { resolveAddMcpAgentId } from \"../agents.js\";\nimport { isAuthenticated } from \"../auth.js\";\nimport type { Editor, PhaseResponse } from \"../types.js\";\n\nexport interface McpPhaseOptions {\n\tagent?: string;\n\teditor?: Editor;\n\tstatus?: boolean;\n\tinstall?: boolean;\n\tscope?: \"global\" | \"project\";\n\tmcpConfigured?: boolean | null;\n}\n\nexport async function handleMcpPhase(\n\toptions: McpPhaseOptions,\n): Promise<PhaseResponse> {\n\tconst agentArgs = options.agent\n\t\t? [\"--agent\", options.agent, \"--json\"]\n\t\t: [\"--json\"];\n\n\t// --status: just report what we know\n\tif (options.status) {\n\t\treturn {\n\t\t\tphase: \"tooling\",\n\t\t\tstatus: \"status\",\n\t\t\tnextAction: {\n\t\t\t\ttype: \"agent_check\",\n\t\t\t\tchecks: [\n\t\t\t\t\t{\n\t\t\t\t\t\tid: \"mcp_server\",\n\t\t\t\t\t\tdescription:\n\t\t\t\t\t\t\t\"Check if the Neon MCP server is already configured in your MCP server list\",\n\t\t\t\t\t\tlookFor: [\n\t\t\t\t\t\t\t\"An MCP server entry named 'Neon' or with URL containing 'mcp.neon.tech'\",\n\t\t\t\t\t\t],\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t\treportBack: {\n\t\t\t\t\ttype: \"run_neon_init\",\n\t\t\t\t\targs: [\n\t\t\t\t\t\t\"mcp\",\n\t\t\t\t\t\t\"--json\",\n\t\t\t\t\t\t...(options.agent ? [\"--agent\", options.agent] : []),\n\t\t\t\t\t\t\"--mcp-configured\",\n\t\t\t\t\t\t\"<true|false>\",\n\t\t\t\t\t],\n\t\t\t\t},\n\t\t\t},\n\t\t};\n\t}\n\n\t// --install: proceed with installation\n\tif (options.install) {\n\t\tconst authed = await isAuthenticated();\n\t\tif (!authed) {\n\t\t\treturn {\n\t\t\t\tphase: \"tooling\",\n\t\t\t\tstatus: \"auth_required\",\n\t\t\t\tnextAction: {\n\t\t\t\t\ttype: \"run_neon_init\",\n\t\t\t\t\targs: [\"auth\", \"--json\"],\n\t\t\t\t},\n\t\t\t};\n\t\t}\n\n\t\t// Build the add-mcp command\n\t\tconst scope = options.scope ?? \"global\";\n\t\tconst mcpAgentId = resolveAddMcpAgentId(options.agent ?? \"claude-code\");\n\t\tconst isCursor =\n\t\t\tmcpAgentId === \"cursor\" ||\n\t\t\toptions.agent?.toLowerCase() === \"cursor\";\n\t\tconst isClaudeCode =\n\t\t\tmcpAgentId === \"claude-code\" ||\n\t\t\toptions.agent?.toLowerCase() === \"claude-code\";\n\t\tconst installCmd = [\n\t\t\t\"npx -y add-mcp https://mcp.neon.tech/mcp\",\n\t\t\tscope === \"global\" ? \"-g\" : \"\",\n\t\t\t\"-n Neon\",\n\t\t\t\"-y\",\n\t\t\t`-a ${mcpAgentId}`,\n\t\t]\n\t\t\t.filter(Boolean)\n\t\t\t.join(\" \");\n\n\t\tlet enableNote = \"\";\n\t\tif (isCursor && scope === \"project\") {\n\t\t\tenableNote =\n\t\t\t\t' Note: Cursor disables project-level MCP servers by default — after installation, open Cursor Settings > MCP and toggle the \"Neon\" server on.';\n\t\t} else if (isClaudeCode) {\n\t\t\tenableNote =\n\t\t\t\t' Note: Claude Code requires approval for newly added MCP servers. When prompted, approve the \"Neon\" server to enable it.';\n\t\t}\n\n\t\treturn {\n\t\t\tphase: \"tooling\",\n\t\t\tstatus: \"installing\",\n\t\t\tnextAction: {\n\t\t\t\ttype: \"run_command\",\n\t\t\t\tcommand: installCmd,\n\t\t\t\tdescription: `Installing Neon MCP server (${scope} scope) for ${mcpAgentId}.${enableNote}`,\n\t\t\t\ttimeout: 60000,\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\"skills\",\n\t\t\t\t\t\t\"--json\",\n\t\t\t\t\t\t...(options.agent ? [\"--agent\", options.agent] : []),\n\t\t\t\t\t\t\"--install\",\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: \"ask_user\",\n\t\t\t\t\t\tquestion:\n\t\t\t\t\t\t\t\"Failed to install the Neon MCP server automatically. Would you like to try again or configure it manually?\",\n\t\t\t\t\t\toptions: [\n\t\t\t\t\t\t\t{ value: \"retry\", label: \"Try again\" },\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tvalue: \"manual\",\n\t\t\t\t\t\t\t\tlabel: \"I'll configure it manually\",\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t],\n\t\t\t\t\t\tresponseMapping: {\n\t\t\t\t\t\t\tretry: {\n\t\t\t\t\t\t\t\targs: [\n\t\t\t\t\t\t\t\t\t\"mcp\",\n\t\t\t\t\t\t\t\t\t\"--json\",\n\t\t\t\t\t\t\t\t\t...(options.agent\n\t\t\t\t\t\t\t\t\t\t? [\"--agent\", options.agent]\n\t\t\t\t\t\t\t\t\t\t: []),\n\t\t\t\t\t\t\t\t\t\"--install\",\n\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tmanual: {\n\t\t\t\t\t\t\t\targs: agentArgs,\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\t}\n\n\t// Agent reported detection result via --mcp-configured\n\tif (options.mcpConfigured === true) {\n\t\t// MCP is done — chain to skills installation (not back to orchestrator,\n\t\t// which would re-check MCP and loop since skills aren't installed yet).\n\t\treturn {\n\t\t\tphase: \"tooling\",\n\t\t\tstatus: \"mcp_configured\",\n\t\t\tnextAction: {\n\t\t\t\ttype: \"run_neon_init\",\n\t\t\t\targs: [\n\t\t\t\t\t\"skills\",\n\t\t\t\t\t\"--json\",\n\t\t\t\t\t...(options.agent ? [\"--agent\", options.agent] : []),\n\t\t\t\t\t\"--install\",\n\t\t\t\t],\n\t\t\t},\n\t\t};\n\t}\n\n\tif (options.mcpConfigured === false) {\n\t\treturn {\n\t\t\tphase: \"tooling\",\n\t\t\tstatus: \"install_needed\",\n\t\t\tnextAction: {\n\t\t\t\ttype: \"ask_user\",\n\t\t\t\tquestion:\n\t\t\t\t\t\"The Neon MCP server is not yet configured. Would you like to install it?\",\n\t\t\t\toptions: [\n\t\t\t\t\t{\n\t\t\t\t\t\tvalue: \"defaults\",\n\t\t\t\t\t\tlabel: \"Yes, install with default settings\",\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tvalue: \"project_scope\",\n\t\t\t\t\t\tlabel: \"Yes, install for this project only\",\n\t\t\t\t\t},\n\t\t\t\t\t{ value: \"skip\", label: \"Skip for now\" },\n\t\t\t\t],\n\t\t\t\tcontext:\n\t\t\t\t\t\"The Neon MCP server gives your AI assistant direct access to Neon database operations like creating projects, running queries, and managing branches.\" +\n\t\t\t\t\t(options.agent?.toLowerCase() === \"cursor\" ||\n\t\t\t\t\toptions.editor?.toLowerCase() === \"cursor\"\n\t\t\t\t\t\t? \" Note: Cursor disables project-level MCP servers by default. If you choose project scope, you will need to manually enable the Neon server in Cursor Settings > MCP. Global scope is recommended for Cursor.\"\n\t\t\t\t\t\t: \"\"),\n\t\t\t\tresponseMapping: {\n\t\t\t\t\tdefaults: {\n\t\t\t\t\t\targs: [\n\t\t\t\t\t\t\t\"mcp\",\n\t\t\t\t\t\t\t\"--json\",\n\t\t\t\t\t\t\t...(options.agent\n\t\t\t\t\t\t\t\t? [\"--agent\", options.agent]\n\t\t\t\t\t\t\t\t: []),\n\t\t\t\t\t\t\t\"--install\",\n\t\t\t\t\t\t],\n\t\t\t\t\t},\n\t\t\t\t\tproject_scope: {\n\t\t\t\t\t\targs: [\n\t\t\t\t\t\t\t\"mcp\",\n\t\t\t\t\t\t\t\"--json\",\n\t\t\t\t\t\t\t...(options.agent\n\t\t\t\t\t\t\t\t? [\"--agent\", options.agent]\n\t\t\t\t\t\t\t\t: []),\n\t\t\t\t\t\t\t\"--install\",\n\t\t\t\t\t\t\t\"--scope\",\n\t\t\t\t\t\t\t\"project\",\n\t\t\t\t\t\t],\n\t\t\t\t\t},\n\t\t\t\t\tskip: {\n\t\t\t\t\t\targs: [\n\t\t\t\t\t\t\t\"skills\",\n\t\t\t\t\t\t\t\"--json\",\n\t\t\t\t\t\t\t...(options.agent\n\t\t\t\t\t\t\t\t? [\"--agent\", options.agent]\n\t\t\t\t\t\t\t\t: []),\n\t\t\t\t\t\t\t\"--install\",\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: ask the agent to check\n\treturn {\n\t\tphase: \"tooling\",\n\t\tstatus: \"detection_needed\",\n\t\tnextAction: {\n\t\t\ttype: \"agent_check\",\n\t\t\tchecks: [\n\t\t\t\t{\n\t\t\t\t\tid: \"mcp_server\",\n\t\t\t\t\tdescription:\n\t\t\t\t\t\t\"Check if the Neon MCP server is already configured in your MCP server list\",\n\t\t\t\t\tlookFor: [\n\t\t\t\t\t\t\"An MCP server entry named 'Neon' or with URL containing 'mcp.neon.tech'\",\n\t\t\t\t\t],\n\t\t\t\t},\n\t\t\t],\n\t\t\treportBack: {\n\t\t\t\ttype: \"run_neon_init\",\n\t\t\t\targs: [\n\t\t\t\t\t\"mcp\",\n\t\t\t\t\t\"--json\",\n\t\t\t\t\t...(options.agent ? [\"--agent\", options.agent] : []),\n\t\t\t\t\t\"--mcp-configured\",\n\t\t\t\t\t\"<true|false>\",\n\t\t\t\t],\n\t\t\t},\n\t\t},\n\t};\n}\n"],"mappings":"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"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { PhaseResponse } from "../types.js";
|
|
2
|
+
|
|
3
|
+
//#region src/lib/phases/migrations.d.ts
|
|
4
|
+
interface MigrationsPhaseOptions {
|
|
5
|
+
agent?: string;
|
|
6
|
+
tool?: string;
|
|
7
|
+
migrationDir?: string;
|
|
8
|
+
scaffold?: "prisma" | "drizzle";
|
|
9
|
+
apply?: boolean;
|
|
10
|
+
}
|
|
11
|
+
declare function handleMigrationsPhase(options: MigrationsPhaseOptions): Promise<PhaseResponse>;
|
|
12
|
+
//#endregion
|
|
13
|
+
export { MigrationsPhaseOptions, handleMigrationsPhase };
|
|
14
|
+
//# sourceMappingURL=migrations.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"migrations.d.ts","names":[],"sources":["../../../src/lib/phases/migrations.ts"],"mappings":";;;UAGiB,sBAAA;;EAAA,IAAA,CAAA,EAAA,MAAA;EAQK,YAAA,CAAA,EAAA,MAAA;EAAqB,QAAA,CAAA,EAAA,QAAA,GAAA,SAAA;OACjC,CAAA,EAAA,OAAA;;AACP,iBAFmB,qBAAA,CAEnB,OAAA,EADO,sBACP,CAAA,EAAA,OAAA,CAAQ,aAAR,CAAA"}
|
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
import { ensureSkillsUpToDate } from "../skills.js";
|
|
2
|
+
//#region src/lib/phases/migrations.ts
|
|
3
|
+
async function handleMigrationsPhase(options) {
|
|
4
|
+
if (options.agent) await ensureSkillsUpToDate(options.agent);
|
|
5
|
+
const agentArgs = options.agent ? [
|
|
6
|
+
"--agent",
|
|
7
|
+
options.agent,
|
|
8
|
+
"--json"
|
|
9
|
+
] : ["--json"];
|
|
10
|
+
if (options.scaffold) {
|
|
11
|
+
if (options.scaffold === "prisma") return {
|
|
12
|
+
phase: "migrations",
|
|
13
|
+
status: "scaffolding",
|
|
14
|
+
tool: "prisma",
|
|
15
|
+
nextAction: {
|
|
16
|
+
type: "agent_action",
|
|
17
|
+
steps: [
|
|
18
|
+
{
|
|
19
|
+
id: "install_prisma",
|
|
20
|
+
description: "Install Prisma as a dev dependency",
|
|
21
|
+
command: "npm install -D prisma"
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
id: "init_prisma",
|
|
25
|
+
description: "Initialize Prisma with PostgreSQL provider",
|
|
26
|
+
command: "npx prisma init --datasource-provider postgresql"
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
id: "configure_env",
|
|
30
|
+
description: "Ensure DATABASE_URL in .env points to your Neon database. The prisma init command may have created a placeholder — replace it with the real connection string if needed."
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
id: "create_schema",
|
|
34
|
+
description: "Help the user define their initial schema in prisma/schema.prisma based on their application needs."
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
id: "run_migration",
|
|
38
|
+
description: "Create and apply the initial migration",
|
|
39
|
+
command: "npx prisma migrate dev --name init"
|
|
40
|
+
}
|
|
41
|
+
],
|
|
42
|
+
onComplete: {
|
|
43
|
+
type: "complete",
|
|
44
|
+
message: "Prisma is set up with your Neon database. You can now define models in schema.prisma and run migrations with `npx prisma migrate dev`."
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
return {
|
|
49
|
+
phase: "migrations",
|
|
50
|
+
status: "scaffolding",
|
|
51
|
+
tool: "drizzle",
|
|
52
|
+
nextAction: {
|
|
53
|
+
type: "agent_action",
|
|
54
|
+
steps: [
|
|
55
|
+
{
|
|
56
|
+
id: "install_drizzle",
|
|
57
|
+
description: "Install Drizzle ORM, drizzle-kit, and the Neon serverless driver",
|
|
58
|
+
command: "npm install drizzle-orm @neondatabase/serverless && npm install -D drizzle-kit"
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
id: "create_config",
|
|
62
|
+
description: "Create drizzle.config.ts at the project root. Set the dialect to 'postgresql' and dbCredentials.url to process.env.DATABASE_URL."
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
id: "create_schema",
|
|
66
|
+
description: "Create a schema file (e.g. src/db/schema.ts) and help the user define their initial tables using Drizzle's table builder."
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
id: "run_migration",
|
|
70
|
+
description: "Generate and apply the initial migration",
|
|
71
|
+
command: "npx drizzle-kit generate && npx drizzle-kit migrate"
|
|
72
|
+
}
|
|
73
|
+
],
|
|
74
|
+
onComplete: {
|
|
75
|
+
type: "complete",
|
|
76
|
+
message: "Drizzle ORM is set up with your Neon database. Define tables in your schema file and run migrations with `npx drizzle-kit generate && npx drizzle-kit migrate`."
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
if (options.apply && options.tool) {
|
|
82
|
+
const applySteps = getMigrationApplySteps(options.tool);
|
|
83
|
+
return {
|
|
84
|
+
phase: "migrations",
|
|
85
|
+
status: "applying",
|
|
86
|
+
tool: options.tool,
|
|
87
|
+
nextAction: {
|
|
88
|
+
type: "agent_action",
|
|
89
|
+
steps: applySteps,
|
|
90
|
+
onComplete: {
|
|
91
|
+
type: "complete",
|
|
92
|
+
message: "Database migrations applied successfully."
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
if (options.tool && options.tool !== "none") return {
|
|
98
|
+
phase: "migrations",
|
|
99
|
+
status: "found",
|
|
100
|
+
detected: {
|
|
101
|
+
tool: options.tool,
|
|
102
|
+
migrationDir: options.migrationDir ?? null
|
|
103
|
+
},
|
|
104
|
+
nextAction: {
|
|
105
|
+
type: "ask_user",
|
|
106
|
+
question: `Found ${options.tool} migrations${options.migrationDir ? ` in ${options.migrationDir}` : ""}. Would you like to apply them to your Neon database?`,
|
|
107
|
+
options: [{
|
|
108
|
+
value: "apply",
|
|
109
|
+
label: "Yes, apply migrations"
|
|
110
|
+
}, {
|
|
111
|
+
value: "skip",
|
|
112
|
+
label: "Skip for now"
|
|
113
|
+
}],
|
|
114
|
+
responseMapping: {
|
|
115
|
+
apply: { args: [
|
|
116
|
+
"migrations",
|
|
117
|
+
"--json",
|
|
118
|
+
"--apply",
|
|
119
|
+
"--tool",
|
|
120
|
+
options.tool
|
|
121
|
+
] },
|
|
122
|
+
skip: { args: [...agentArgs, "--skip-migrations"] }
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
};
|
|
126
|
+
if (options.tool === "none") return {
|
|
127
|
+
phase: "migrations",
|
|
128
|
+
status: "none_found",
|
|
129
|
+
nextAction: {
|
|
130
|
+
type: "ask_user",
|
|
131
|
+
question: "No existing database migrations were found. Would you like to set up a migration framework?",
|
|
132
|
+
options: [
|
|
133
|
+
{
|
|
134
|
+
value: "prisma",
|
|
135
|
+
label: "Prisma (recommended for TypeScript)"
|
|
136
|
+
},
|
|
137
|
+
{
|
|
138
|
+
value: "drizzle",
|
|
139
|
+
label: "Drizzle ORM"
|
|
140
|
+
},
|
|
141
|
+
{
|
|
142
|
+
value: "skip",
|
|
143
|
+
label: "Skip - I'll handle migrations myself"
|
|
144
|
+
}
|
|
145
|
+
],
|
|
146
|
+
context: "A migration framework helps you version-control your database schema changes.",
|
|
147
|
+
responseMapping: {
|
|
148
|
+
prisma: { args: [
|
|
149
|
+
"migrations",
|
|
150
|
+
"--json",
|
|
151
|
+
"--scaffold",
|
|
152
|
+
"prisma"
|
|
153
|
+
] },
|
|
154
|
+
drizzle: { args: [
|
|
155
|
+
"migrations",
|
|
156
|
+
"--json",
|
|
157
|
+
"--scaffold",
|
|
158
|
+
"drizzle"
|
|
159
|
+
] },
|
|
160
|
+
skip: { args: [...agentArgs, "--skip-migrations"] }
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
};
|
|
164
|
+
return {
|
|
165
|
+
phase: "migrations",
|
|
166
|
+
status: "detection_needed",
|
|
167
|
+
nextAction: {
|
|
168
|
+
type: "agent_check",
|
|
169
|
+
checks: [{
|
|
170
|
+
id: "existing_migrations",
|
|
171
|
+
description: "Check if the project has existing database migrations",
|
|
172
|
+
lookFor: [
|
|
173
|
+
"prisma/migrations/ directory or schema.prisma file",
|
|
174
|
+
"drizzle/ directory or drizzle.config.ts",
|
|
175
|
+
"migrations/ or db/migrations/ directory",
|
|
176
|
+
"knex migration files (knexfile.js/ts)"
|
|
177
|
+
]
|
|
178
|
+
}],
|
|
179
|
+
reportBack: {
|
|
180
|
+
type: "run_neon_init",
|
|
181
|
+
args: [
|
|
182
|
+
"migrations",
|
|
183
|
+
"--json",
|
|
184
|
+
"--tool",
|
|
185
|
+
"<prisma|drizzle|knex|none>",
|
|
186
|
+
"--migration-dir",
|
|
187
|
+
"<path|none>"
|
|
188
|
+
]
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
};
|
|
192
|
+
}
|
|
193
|
+
function getMigrationApplySteps(tool) {
|
|
194
|
+
switch (tool) {
|
|
195
|
+
case "prisma": return [
|
|
196
|
+
{
|
|
197
|
+
id: "ensure_env",
|
|
198
|
+
description: "Verify DATABASE_URL is set in .env"
|
|
199
|
+
},
|
|
200
|
+
{
|
|
201
|
+
id: "apply",
|
|
202
|
+
description: "Apply migrations to the Neon database",
|
|
203
|
+
command: "npx prisma migrate deploy"
|
|
204
|
+
},
|
|
205
|
+
{
|
|
206
|
+
id: "generate",
|
|
207
|
+
description: "Generate the Prisma client",
|
|
208
|
+
command: "npx prisma generate"
|
|
209
|
+
}
|
|
210
|
+
];
|
|
211
|
+
case "drizzle": return [{
|
|
212
|
+
id: "ensure_env",
|
|
213
|
+
description: "Verify DATABASE_URL is set in .env"
|
|
214
|
+
}, {
|
|
215
|
+
id: "apply",
|
|
216
|
+
description: "Apply migrations to the Neon database",
|
|
217
|
+
command: "npx drizzle-kit migrate"
|
|
218
|
+
}];
|
|
219
|
+
case "knex": return [{
|
|
220
|
+
id: "ensure_env",
|
|
221
|
+
description: "Verify DATABASE_URL is set in .env"
|
|
222
|
+
}, {
|
|
223
|
+
id: "apply",
|
|
224
|
+
description: "Apply migrations to the Neon database",
|
|
225
|
+
command: "npx knex migrate:latest"
|
|
226
|
+
}];
|
|
227
|
+
default: return [{
|
|
228
|
+
id: "ensure_env",
|
|
229
|
+
description: "Verify DATABASE_URL is set in .env"
|
|
230
|
+
}, {
|
|
231
|
+
id: "apply",
|
|
232
|
+
description: `Apply ${tool} migrations to the Neon database using the appropriate command for your migration tool.`
|
|
233
|
+
}];
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
//#endregion
|
|
237
|
+
export { handleMigrationsPhase };
|
|
238
|
+
|
|
239
|
+
//# sourceMappingURL=migrations.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"migrations.js","names":[],"sources":["../../../src/lib/phases/migrations.ts"],"sourcesContent":["import { ensureSkillsUpToDate } from \"../skills.js\";\nimport type { PhaseResponse } from \"../types.js\";\n\nexport interface MigrationsPhaseOptions {\n\tagent?: string;\n\ttool?: string;\n\tmigrationDir?: string;\n\tscaffold?: \"prisma\" | \"drizzle\";\n\tapply?: boolean;\n}\n\nexport async function handleMigrationsPhase(\n\toptions: MigrationsPhaseOptions,\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 agentArgs = options.agent\n\t\t? [\"--agent\", options.agent, \"--json\"]\n\t\t: [\"--json\"];\n\n\t// --scaffold: set up a new migration framework\n\tif (options.scaffold) {\n\t\tif (options.scaffold === \"prisma\") {\n\t\t\treturn {\n\t\t\t\tphase: \"migrations\",\n\t\t\t\tstatus: \"scaffolding\",\n\t\t\t\ttool: \"prisma\",\n\t\t\t\tnextAction: {\n\t\t\t\t\ttype: \"agent_action\",\n\t\t\t\t\tsteps: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tid: \"install_prisma\",\n\t\t\t\t\t\t\tdescription: \"Install Prisma as a dev dependency\",\n\t\t\t\t\t\t\tcommand: \"npm install -D prisma\",\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tid: \"init_prisma\",\n\t\t\t\t\t\t\tdescription:\n\t\t\t\t\t\t\t\t\"Initialize Prisma with PostgreSQL provider\",\n\t\t\t\t\t\t\tcommand:\n\t\t\t\t\t\t\t\t\"npx prisma init --datasource-provider postgresql\",\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tid: \"configure_env\",\n\t\t\t\t\t\t\tdescription:\n\t\t\t\t\t\t\t\t\"Ensure DATABASE_URL in .env points to your Neon database. The prisma init command may have created a placeholder — replace it with the real connection string if needed.\",\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tid: \"create_schema\",\n\t\t\t\t\t\t\tdescription:\n\t\t\t\t\t\t\t\t\"Help the user define their initial schema in prisma/schema.prisma based on their application needs.\",\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tid: \"run_migration\",\n\t\t\t\t\t\t\tdescription:\n\t\t\t\t\t\t\t\t\"Create and apply the initial migration\",\n\t\t\t\t\t\t\tcommand: \"npx prisma migrate dev --name init\",\n\t\t\t\t\t\t},\n\t\t\t\t\t],\n\t\t\t\t\tonComplete: {\n\t\t\t\t\t\ttype: \"complete\",\n\t\t\t\t\t\tmessage:\n\t\t\t\t\t\t\t\"Prisma is set up with your Neon database. You can now define models in schema.prisma and run migrations with `npx prisma migrate dev`.\",\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t};\n\t\t}\n\n\t\t// drizzle\n\t\treturn {\n\t\t\tphase: \"migrations\",\n\t\t\tstatus: \"scaffolding\",\n\t\t\ttool: \"drizzle\",\n\t\t\tnextAction: {\n\t\t\t\ttype: \"agent_action\",\n\t\t\t\tsteps: [\n\t\t\t\t\t{\n\t\t\t\t\t\tid: \"install_drizzle\",\n\t\t\t\t\t\tdescription:\n\t\t\t\t\t\t\t\"Install Drizzle ORM, drizzle-kit, and the Neon serverless driver\",\n\t\t\t\t\t\tcommand:\n\t\t\t\t\t\t\t\"npm install drizzle-orm @neondatabase/serverless && npm install -D drizzle-kit\",\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tid: \"create_config\",\n\t\t\t\t\t\tdescription:\n\t\t\t\t\t\t\t\"Create drizzle.config.ts at the project root. Set the dialect to 'postgresql' and dbCredentials.url to process.env.DATABASE_URL.\",\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tid: \"create_schema\",\n\t\t\t\t\t\tdescription:\n\t\t\t\t\t\t\t\"Create a schema file (e.g. src/db/schema.ts) and help the user define their initial tables using Drizzle's table builder.\",\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tid: \"run_migration\",\n\t\t\t\t\t\tdescription: \"Generate and apply the initial migration\",\n\t\t\t\t\t\tcommand:\n\t\t\t\t\t\t\t\"npx drizzle-kit generate && npx drizzle-kit migrate\",\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t\tonComplete: {\n\t\t\t\t\ttype: \"complete\",\n\t\t\t\t\tmessage:\n\t\t\t\t\t\t\"Drizzle ORM is set up with your Neon database. Define tables in your schema file and run migrations with `npx drizzle-kit generate && npx drizzle-kit migrate`.\",\n\t\t\t\t},\n\t\t\t},\n\t\t};\n\t}\n\n\t// --apply: apply existing migrations\n\tif (options.apply && options.tool) {\n\t\tconst applySteps = getMigrationApplySteps(options.tool);\n\t\treturn {\n\t\t\tphase: \"migrations\",\n\t\t\tstatus: \"applying\",\n\t\t\ttool: options.tool,\n\t\t\tnextAction: {\n\t\t\t\ttype: \"agent_action\",\n\t\t\t\tsteps: applySteps,\n\t\t\t\tonComplete: {\n\t\t\t\t\ttype: \"complete\",\n\t\t\t\t\tmessage: \"Database migrations applied successfully.\",\n\t\t\t\t},\n\t\t\t},\n\t\t};\n\t}\n\n\t// Agent reported detection results via --tool and --migration-dir\n\tif (options.tool && options.tool !== \"none\") {\n\t\treturn {\n\t\t\tphase: \"migrations\",\n\t\t\tstatus: \"found\",\n\t\t\tdetected: {\n\t\t\t\ttool: options.tool,\n\t\t\t\tmigrationDir: options.migrationDir ?? null,\n\t\t\t},\n\t\t\tnextAction: {\n\t\t\t\ttype: \"ask_user\",\n\t\t\t\tquestion: `Found ${options.tool} migrations${options.migrationDir ? ` in ${options.migrationDir}` : \"\"}. Would you like to apply them to your Neon database?`,\n\t\t\t\toptions: [\n\t\t\t\t\t{ value: \"apply\", label: \"Yes, apply migrations\" },\n\t\t\t\t\t{ value: \"skip\", label: \"Skip for now\" },\n\t\t\t\t],\n\t\t\t\tresponseMapping: {\n\t\t\t\t\tapply: {\n\t\t\t\t\t\targs: [\n\t\t\t\t\t\t\t\"migrations\",\n\t\t\t\t\t\t\t\"--json\",\n\t\t\t\t\t\t\t\"--apply\",\n\t\t\t\t\t\t\t\"--tool\",\n\t\t\t\t\t\t\toptions.tool,\n\t\t\t\t\t\t],\n\t\t\t\t\t},\n\t\t\t\t\tskip: { args: [...agentArgs, \"--skip-migrations\"] },\n\t\t\t\t},\n\t\t\t},\n\t\t};\n\t}\n\n\tif (options.tool === \"none\") {\n\t\treturn {\n\t\t\tphase: \"migrations\",\n\t\t\tstatus: \"none_found\",\n\t\t\tnextAction: {\n\t\t\t\ttype: \"ask_user\",\n\t\t\t\tquestion:\n\t\t\t\t\t\"No existing database migrations were found. Would you like to set up a migration framework?\",\n\t\t\t\toptions: [\n\t\t\t\t\t{\n\t\t\t\t\t\tvalue: \"prisma\",\n\t\t\t\t\t\tlabel: \"Prisma (recommended for TypeScript)\",\n\t\t\t\t\t},\n\t\t\t\t\t{ value: \"drizzle\", label: \"Drizzle ORM\" },\n\t\t\t\t\t{\n\t\t\t\t\t\tvalue: \"skip\",\n\t\t\t\t\t\tlabel: \"Skip - I'll handle migrations myself\",\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t\tcontext:\n\t\t\t\t\t\"A migration framework helps you version-control your database schema changes.\",\n\t\t\t\tresponseMapping: {\n\t\t\t\t\tprisma: {\n\t\t\t\t\t\targs: [\"migrations\", \"--json\", \"--scaffold\", \"prisma\"],\n\t\t\t\t\t},\n\t\t\t\t\tdrizzle: {\n\t\t\t\t\t\targs: [\"migrations\", \"--json\", \"--scaffold\", \"drizzle\"],\n\t\t\t\t\t},\n\t\t\t\t\tskip: { args: [...agentArgs, \"--skip-migrations\"] },\n\t\t\t\t},\n\t\t\t},\n\t\t};\n\t}\n\n\t// Default: ask agent to detect migration tooling\n\treturn {\n\t\tphase: \"migrations\",\n\t\tstatus: \"detection_needed\",\n\t\tnextAction: {\n\t\t\ttype: \"agent_check\",\n\t\t\tchecks: [\n\t\t\t\t{\n\t\t\t\t\tid: \"existing_migrations\",\n\t\t\t\t\tdescription:\n\t\t\t\t\t\t\"Check if the project has existing database migrations\",\n\t\t\t\t\tlookFor: [\n\t\t\t\t\t\t\"prisma/migrations/ directory or schema.prisma file\",\n\t\t\t\t\t\t\"drizzle/ directory or drizzle.config.ts\",\n\t\t\t\t\t\t\"migrations/ or db/migrations/ directory\",\n\t\t\t\t\t\t\"knex migration files (knexfile.js/ts)\",\n\t\t\t\t\t],\n\t\t\t\t},\n\t\t\t],\n\t\t\treportBack: {\n\t\t\t\ttype: \"run_neon_init\",\n\t\t\t\targs: [\n\t\t\t\t\t\"migrations\",\n\t\t\t\t\t\"--json\",\n\t\t\t\t\t\"--tool\",\n\t\t\t\t\t\"<prisma|drizzle|knex|none>\",\n\t\t\t\t\t\"--migration-dir\",\n\t\t\t\t\t\"<path|none>\",\n\t\t\t\t],\n\t\t\t},\n\t\t},\n\t};\n}\n\nfunction getMigrationApplySteps(tool: string) {\n\tswitch (tool) {\n\t\tcase \"prisma\":\n\t\t\treturn [\n\t\t\t\t{\n\t\t\t\t\tid: \"ensure_env\",\n\t\t\t\t\tdescription: \"Verify DATABASE_URL is set in .env\",\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tid: \"apply\",\n\t\t\t\t\tdescription: \"Apply migrations to the Neon database\",\n\t\t\t\t\tcommand: \"npx prisma migrate deploy\",\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tid: \"generate\",\n\t\t\t\t\tdescription: \"Generate the Prisma client\",\n\t\t\t\t\tcommand: \"npx prisma generate\",\n\t\t\t\t},\n\t\t\t];\n\t\tcase \"drizzle\":\n\t\t\treturn [\n\t\t\t\t{\n\t\t\t\t\tid: \"ensure_env\",\n\t\t\t\t\tdescription: \"Verify DATABASE_URL is set in .env\",\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tid: \"apply\",\n\t\t\t\t\tdescription: \"Apply migrations to the Neon database\",\n\t\t\t\t\tcommand: \"npx drizzle-kit migrate\",\n\t\t\t\t},\n\t\t\t];\n\t\tcase \"knex\":\n\t\t\treturn [\n\t\t\t\t{\n\t\t\t\t\tid: \"ensure_env\",\n\t\t\t\t\tdescription: \"Verify DATABASE_URL is set in .env\",\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tid: \"apply\",\n\t\t\t\t\tdescription: \"Apply migrations to the Neon database\",\n\t\t\t\t\tcommand: \"npx knex migrate:latest\",\n\t\t\t\t},\n\t\t\t];\n\t\tdefault:\n\t\t\treturn [\n\t\t\t\t{\n\t\t\t\t\tid: \"ensure_env\",\n\t\t\t\t\tdescription: \"Verify DATABASE_URL is set in .env\",\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tid: \"apply\",\n\t\t\t\t\tdescription: `Apply ${tool} migrations to the Neon database using the appropriate command for your migration tool.`,\n\t\t\t\t},\n\t\t\t];\n\t}\n}\n"],"mappings":";;AAWA,eAAsB,sBACrB,SACyB;CAEzB,IAAI,QAAQ,OACX,MAAM,qBAAqB,QAAQ,KAAK;CAEzC,MAAM,YAAY,QAAQ,QACvB;EAAC;EAAW,QAAQ;EAAO;CAAQ,IACnC,CAAC,QAAQ;CAGZ,IAAI,QAAQ,UAAU;EACrB,IAAI,QAAQ,aAAa,UACxB,OAAO;GACN,OAAO;GACP,QAAQ;GACR,MAAM;GACN,YAAY;IACX,MAAM;IACN,OAAO;KACN;MACC,IAAI;MACJ,aAAa;MACb,SAAS;KACV;KACA;MACC,IAAI;MACJ,aACC;MACD,SACC;KACF;KACA;MACC,IAAI;MACJ,aACC;KACF;KACA;MACC,IAAI;MACJ,aACC;KACF;KACA;MACC,IAAI;MACJ,aACC;MACD,SAAS;KACV;IACD;IACA,YAAY;KACX,MAAM;KACN,SACC;IACF;GACD;EACD;EAID,OAAO;GACN,OAAO;GACP,QAAQ;GACR,MAAM;GACN,YAAY;IACX,MAAM;IACN,OAAO;KACN;MACC,IAAI;MACJ,aACC;MACD,SACC;KACF;KACA;MACC,IAAI;MACJ,aACC;KACF;KACA;MACC,IAAI;MACJ,aACC;KACF;KACA;MACC,IAAI;MACJ,aAAa;MACb,SACC;KACF;IACD;IACA,YAAY;KACX,MAAM;KACN,SACC;IACF;GACD;EACD;CACD;CAGA,IAAI,QAAQ,SAAS,QAAQ,MAAM;EAClC,MAAM,aAAa,uBAAuB,QAAQ,IAAI;EACtD,OAAO;GACN,OAAO;GACP,QAAQ;GACR,MAAM,QAAQ;GACd,YAAY;IACX,MAAM;IACN,OAAO;IACP,YAAY;KACX,MAAM;KACN,SAAS;IACV;GACD;EACD;CACD;CAGA,IAAI,QAAQ,QAAQ,QAAQ,SAAS,QACpC,OAAO;EACN,OAAO;EACP,QAAQ;EACR,UAAU;GACT,MAAM,QAAQ;GACd,cAAc,QAAQ,gBAAgB;EACvC;EACA,YAAY;GACX,MAAM;GACN,UAAU,SAAS,QAAQ,KAAK,aAAa,QAAQ,eAAe,OAAO,QAAQ,iBAAiB,GAAG;GACvG,SAAS,CACR;IAAE,OAAO;IAAS,OAAO;GAAwB,GACjD;IAAE,OAAO;IAAQ,OAAO;GAAe,CACxC;GACA,iBAAiB;IAChB,OAAO,EACN,MAAM;KACL;KACA;KACA;KACA;KACA,QAAQ;IACT,EACD;IACA,MAAM,EAAE,MAAM,CAAC,GAAG,WAAW,mBAAmB,EAAE;GACnD;EACD;CACD;CAGD,IAAI,QAAQ,SAAS,QACpB,OAAO;EACN,OAAO;EACP,QAAQ;EACR,YAAY;GACX,MAAM;GACN,UACC;GACD,SAAS;IACR;KACC,OAAO;KACP,OAAO;IACR;IACA;KAAE,OAAO;KAAW,OAAO;IAAc;IACzC;KACC,OAAO;KACP,OAAO;IACR;GACD;GACA,SACC;GACD,iBAAiB;IAChB,QAAQ,EACP,MAAM;KAAC;KAAc;KAAU;KAAc;IAAQ,EACtD;IACA,SAAS,EACR,MAAM;KAAC;KAAc;KAAU;KAAc;IAAS,EACvD;IACA,MAAM,EAAE,MAAM,CAAC,GAAG,WAAW,mBAAmB,EAAE;GACnD;EACD;CACD;CAID,OAAO;EACN,OAAO;EACP,QAAQ;EACR,YAAY;GACX,MAAM;GACN,QAAQ,CACP;IACC,IAAI;IACJ,aACC;IACD,SAAS;KACR;KACA;KACA;KACA;IACD;GACD,CACD;GACA,YAAY;IACX,MAAM;IACN,MAAM;KACL;KACA;KACA;KACA;KACA;KACA;IACD;GACD;EACD;CACD;AACD;AAEA,SAAS,uBAAuB,MAAc;CAC7C,QAAQ,MAAR;EACC,KAAK,UACJ,OAAO;GACN;IACC,IAAI;IACJ,aAAa;GACd;GACA;IACC,IAAI;IACJ,aAAa;IACb,SAAS;GACV;GACA;IACC,IAAI;IACJ,aAAa;IACb,SAAS;GACV;EACD;EACD,KAAK,WACJ,OAAO,CACN;GACC,IAAI;GACJ,aAAa;EACd,GACA;GACC,IAAI;GACJ,aAAa;GACb,SAAS;EACV,CACD;EACD,KAAK,QACJ,OAAO,CACN;GACC,IAAI;GACJ,aAAa;EACd,GACA;GACC,IAAI;GACJ,aAAa;GACb,SAAS;EACV,CACD;EACD,SACC,OAAO,CACN;GACC,IAAI;GACJ,aAAa;EACd,GACA;GACC,IAAI;GACJ,aAAa,SAAS,KAAK;EAC5B,CACD;CACF;AACD"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { PhaseResponse } from "../types.js";
|
|
2
|
+
|
|
3
|
+
//#region src/lib/phases/neon-auth.d.ts
|
|
4
|
+
interface NeonAuthPhaseOptions {
|
|
5
|
+
agent?: string;
|
|
6
|
+
setup?: boolean;
|
|
7
|
+
info?: boolean;
|
|
8
|
+
projectId?: string;
|
|
9
|
+
}
|
|
10
|
+
declare function handleNeonAuthPhase(options: NeonAuthPhaseOptions): Promise<PhaseResponse>;
|
|
11
|
+
//#endregion
|
|
12
|
+
export { NeonAuthPhaseOptions, handleNeonAuthPhase };
|
|
13
|
+
//# sourceMappingURL=neon-auth.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"neon-auth.d.ts","names":[],"sources":["../../../src/lib/phases/neon-auth.ts"],"mappings":";;;UAGiB,oBAAA;;EAAA,KAAA,CAAA,EAAA,OAAA;EAOK,IAAA,CAAA,EAAA,OAAA;EAAmB,SAAA,CAAA,EAAA,MAAA;;AAE9B,iBAFW,mBAAA,CAEX,OAAA,EADD,oBACC,CAAA,EAAR,OAAQ,CAAA,aAAA,CAAA"}
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import { SKILL_REFERENCE_URLS, ensureSkillsUpToDate } from "../skills.js";
|
|
2
|
+
//#region src/lib/phases/neon-auth.ts
|
|
3
|
+
async function handleNeonAuthPhase(options) {
|
|
4
|
+
if (options.projectId && !/^[\w.:-]+$/.test(options.projectId)) throw new Error(`Invalid project ID: "${options.projectId}". Expected alphanumeric, hyphens, underscores, dots, or colons.`);
|
|
5
|
+
if (options.agent) await ensureSkillsUpToDate(options.agent);
|
|
6
|
+
if (options.info) return {
|
|
7
|
+
phase: "neon_auth",
|
|
8
|
+
status: "info",
|
|
9
|
+
nextAction: {
|
|
10
|
+
type: "ask_user",
|
|
11
|
+
question: "Neon Auth provides drop-in user authentication that integrates with your Neon database. It handles user sign-up, sign-in, and session management. Would you like to set it up?",
|
|
12
|
+
options: [{
|
|
13
|
+
value: "yes",
|
|
14
|
+
label: "Yes, set up Neon Auth"
|
|
15
|
+
}, {
|
|
16
|
+
value: "no",
|
|
17
|
+
label: "No, skip for now"
|
|
18
|
+
}],
|
|
19
|
+
context: `Full documentation: ${SKILL_REFERENCE_URLS.neonAuth}`,
|
|
20
|
+
responseMapping: {
|
|
21
|
+
yes: { args: [
|
|
22
|
+
"neon-auth",
|
|
23
|
+
"--json",
|
|
24
|
+
...options.agent ? ["--agent", options.agent] : [],
|
|
25
|
+
"--setup",
|
|
26
|
+
...options.projectId ? ["--project-id", options.projectId] : []
|
|
27
|
+
] },
|
|
28
|
+
no: { args: [
|
|
29
|
+
"finalize",
|
|
30
|
+
"--json",
|
|
31
|
+
...options.agent ? ["--agent", options.agent] : []
|
|
32
|
+
] }
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
if (options.setup) return {
|
|
37
|
+
phase: "neon_auth",
|
|
38
|
+
status: "in_progress",
|
|
39
|
+
nextAction: {
|
|
40
|
+
type: "agent_action",
|
|
41
|
+
prerequisite: SKILL_REFERENCE_URLS.neonAuth,
|
|
42
|
+
steps: [
|
|
43
|
+
{
|
|
44
|
+
id: "provision",
|
|
45
|
+
description: "Enable Neon Auth on the project using the neonctl CLI. Run: `CI= npx -y neonctl neon-auth enable --project-id <project-id> --output json`. You can check current status with: `CI= npx -y neonctl neon-auth status --project-id <project-id> --output json`." + (options.projectId ? ` Project ID: ${options.projectId}.` : " Determine the project ID from the .neon file in the project root, or from the DATABASE_URL in .env, or ask the user.")
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
id: "install_packages",
|
|
49
|
+
description: "Install required packages per the skill reference. The exact packages depend on the framework (Next.js, React, etc.)."
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
id: "create_components",
|
|
53
|
+
description: "Create auth components per the skill reference. Follow the exact patterns and imports specified."
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
id: "pull_env",
|
|
57
|
+
description: "Run `neonctl env pull` to populate the NEON_AUTH_BASE_URL, NEON_AUTH_JWKS_URL, and other Neon Auth environment variables. This reads the .neon context file and writes the auth URLs to the project's env file.",
|
|
58
|
+
command: "CI= npx -y neonctl env pull"
|
|
59
|
+
}
|
|
60
|
+
],
|
|
61
|
+
onComplete: {
|
|
62
|
+
type: "run_neon_init",
|
|
63
|
+
args: [
|
|
64
|
+
"finalize",
|
|
65
|
+
"--json",
|
|
66
|
+
...options.agent ? ["--agent", options.agent] : []
|
|
67
|
+
]
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
return {
|
|
72
|
+
phase: "neon_auth",
|
|
73
|
+
status: "optional",
|
|
74
|
+
nextAction: {
|
|
75
|
+
type: "ask_user",
|
|
76
|
+
question: "Would you like to set up Neon Auth for user authentication in your app?",
|
|
77
|
+
options: [
|
|
78
|
+
{
|
|
79
|
+
value: "yes",
|
|
80
|
+
label: "Yes, set up Neon Auth"
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
value: "no",
|
|
84
|
+
label: "No, skip for now"
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
value: "info",
|
|
88
|
+
label: "Tell me more about Neon Auth"
|
|
89
|
+
}
|
|
90
|
+
],
|
|
91
|
+
context: "Neon Auth provides drop-in user authentication that integrates with your Neon database.",
|
|
92
|
+
responseMapping: {
|
|
93
|
+
yes: { args: [
|
|
94
|
+
"neon-auth",
|
|
95
|
+
"--json",
|
|
96
|
+
...options.agent ? ["--agent", options.agent] : [],
|
|
97
|
+
"--setup"
|
|
98
|
+
] },
|
|
99
|
+
no: { args: [
|
|
100
|
+
"finalize",
|
|
101
|
+
"--json",
|
|
102
|
+
...options.agent ? ["--agent", options.agent] : []
|
|
103
|
+
] },
|
|
104
|
+
info: { args: [
|
|
105
|
+
"neon-auth",
|
|
106
|
+
"--json",
|
|
107
|
+
...options.agent ? ["--agent", options.agent] : [],
|
|
108
|
+
"--info"
|
|
109
|
+
] }
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
//#endregion
|
|
115
|
+
export { handleNeonAuthPhase };
|
|
116
|
+
|
|
117
|
+
//# sourceMappingURL=neon-auth.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"neon-auth.js","names":[],"sources":["../../../src/lib/phases/neon-auth.ts"],"sourcesContent":["import { ensureSkillsUpToDate, SKILL_REFERENCE_URLS } from \"../skills.js\";\nimport type { PhaseResponse } from \"../types.js\";\n\nexport interface NeonAuthPhaseOptions {\n\tagent?: string;\n\tsetup?: boolean;\n\tinfo?: boolean;\n\tprojectId?: string;\n}\n\nexport async function handleNeonAuthPhase(\n\toptions: NeonAuthPhaseOptions,\n): Promise<PhaseResponse> {\n\t// Validate IDs that may be interpolated into instruction strings\n\tif (options.projectId && !/^[\\w.:-]+$/.test(options.projectId)) {\n\t\tthrow new Error(\n\t\t\t`Invalid project ID: \"${options.projectId}\". Expected alphanumeric, hyphens, underscores, dots, or colons.`,\n\t\t);\n\t}\n\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\t// --info: return information about Neon Auth\n\tif (options.info) {\n\t\treturn {\n\t\t\tphase: \"neon_auth\",\n\t\t\tstatus: \"info\",\n\t\t\tnextAction: {\n\t\t\t\ttype: \"ask_user\",\n\t\t\t\tquestion:\n\t\t\t\t\t\"Neon Auth provides drop-in user authentication that integrates with your Neon database. It handles user sign-up, sign-in, and session management. Would you like to set it up?\",\n\t\t\t\toptions: [\n\t\t\t\t\t{ value: \"yes\", label: \"Yes, set up Neon Auth\" },\n\t\t\t\t\t{ value: \"no\", label: \"No, skip for now\" },\n\t\t\t\t],\n\t\t\t\tcontext: `Full documentation: ${SKILL_REFERENCE_URLS.neonAuth}`,\n\t\t\t\tresponseMapping: {\n\t\t\t\t\tyes: {\n\t\t\t\t\t\targs: [\n\t\t\t\t\t\t\t\"neon-auth\",\n\t\t\t\t\t\t\t\"--json\",\n\t\t\t\t\t\t\t...(options.agent\n\t\t\t\t\t\t\t\t? [\"--agent\", options.agent]\n\t\t\t\t\t\t\t\t: []),\n\t\t\t\t\t\t\t\"--setup\",\n\t\t\t\t\t\t\t...(options.projectId\n\t\t\t\t\t\t\t\t? [\"--project-id\", options.projectId]\n\t\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\tno: {\n\t\t\t\t\t\targs: [\n\t\t\t\t\t\t\t\"finalize\",\n\t\t\t\t\t\t\t\"--json\",\n\t\t\t\t\t\t\t...(options.agent\n\t\t\t\t\t\t\t\t? [\"--agent\", options.agent]\n\t\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\t}\n\n\t// --setup: guide through Neon Auth configuration\n\tif (options.setup) {\n\t\treturn {\n\t\t\tphase: \"neon_auth\",\n\t\t\tstatus: \"in_progress\",\n\t\t\tnextAction: {\n\t\t\t\ttype: \"agent_action\",\n\t\t\t\tprerequisite: SKILL_REFERENCE_URLS.neonAuth,\n\t\t\t\tsteps: [\n\t\t\t\t\t{\n\t\t\t\t\t\tid: \"provision\",\n\t\t\t\t\t\tdescription:\n\t\t\t\t\t\t\t\"Enable Neon Auth on the project using the neonctl CLI. \" +\n\t\t\t\t\t\t\t\"Run: `CI= npx -y neonctl neon-auth enable --project-id <project-id> --output json`. \" +\n\t\t\t\t\t\t\t\"You can check current status with: `CI= npx -y neonctl neon-auth status --project-id <project-id> --output json`.\" +\n\t\t\t\t\t\t\t(options.projectId\n\t\t\t\t\t\t\t\t? ` Project ID: ${options.projectId}.`\n\t\t\t\t\t\t\t\t: \" Determine the project ID from the .neon file in the project root, or from the DATABASE_URL in .env, or ask the user.\"),\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tid: \"install_packages\",\n\t\t\t\t\t\tdescription:\n\t\t\t\t\t\t\t\"Install required packages per the skill reference. The exact packages depend on the framework (Next.js, React, etc.).\",\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tid: \"create_components\",\n\t\t\t\t\t\tdescription:\n\t\t\t\t\t\t\t\"Create auth components per the skill reference. Follow the exact patterns and imports specified.\",\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tid: \"pull_env\",\n\t\t\t\t\t\tdescription:\n\t\t\t\t\t\t\t\"Run `neonctl env pull` to populate the NEON_AUTH_BASE_URL, NEON_AUTH_JWKS_URL, and other Neon Auth environment variables. This reads the .neon context file and writes the auth URLs to the project's env file.\",\n\t\t\t\t\t\tcommand: \"CI= npx -y neonctl env pull\",\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: [\n\t\t\t\t\t\t\"finalize\",\n\t\t\t\t\t\t\"--json\",\n\t\t\t\t\t\t...(options.agent ? [\"--agent\", options.agent] : []),\n\t\t\t\t\t],\n\t\t\t\t},\n\t\t\t},\n\t\t};\n\t}\n\n\t// Default: ask if they want Neon Auth\n\treturn {\n\t\tphase: \"neon_auth\",\n\t\tstatus: \"optional\",\n\t\tnextAction: {\n\t\t\ttype: \"ask_user\",\n\t\t\tquestion:\n\t\t\t\t\"Would you like to set up Neon Auth for user authentication in your app?\",\n\t\t\toptions: [\n\t\t\t\t{ value: \"yes\", label: \"Yes, set up Neon Auth\" },\n\t\t\t\t{ value: \"no\", label: \"No, skip for now\" },\n\t\t\t\t{ value: \"info\", label: \"Tell me more about Neon Auth\" },\n\t\t\t],\n\t\t\tcontext:\n\t\t\t\t\"Neon Auth provides drop-in user authentication that integrates with your Neon database.\",\n\t\t\tresponseMapping: {\n\t\t\t\tyes: {\n\t\t\t\t\targs: [\n\t\t\t\t\t\t\"neon-auth\",\n\t\t\t\t\t\t\"--json\",\n\t\t\t\t\t\t...(options.agent ? [\"--agent\", options.agent] : []),\n\t\t\t\t\t\t\"--setup\",\n\t\t\t\t\t],\n\t\t\t\t},\n\t\t\t\tno: {\n\t\t\t\t\targs: [\n\t\t\t\t\t\t\"finalize\",\n\t\t\t\t\t\t\"--json\",\n\t\t\t\t\t\t...(options.agent ? [\"--agent\", options.agent] : []),\n\t\t\t\t\t],\n\t\t\t\t},\n\t\t\t\tinfo: {\n\t\t\t\t\targs: [\n\t\t\t\t\t\t\"neon-auth\",\n\t\t\t\t\t\t\"--json\",\n\t\t\t\t\t\t...(options.agent ? [\"--agent\", options.agent] : []),\n\t\t\t\t\t\t\"--info\",\n\t\t\t\t\t],\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t};\n}\n"],"mappings":";;AAUA,eAAsB,oBACrB,SACyB;CAEzB,IAAI,QAAQ,aAAa,CAAC,aAAa,KAAK,QAAQ,SAAS,GAC5D,MAAM,IAAI,MACT,wBAAwB,QAAQ,UAAU,iEAC3C;CAID,IAAI,QAAQ,OACX,MAAM,qBAAqB,QAAQ,KAAK;CAGzC,IAAI,QAAQ,MACX,OAAO;EACN,OAAO;EACP,QAAQ;EACR,YAAY;GACX,MAAM;GACN,UACC;GACD,SAAS,CACR;IAAE,OAAO;IAAO,OAAO;GAAwB,GAC/C;IAAE,OAAO;IAAM,OAAO;GAAmB,CAC1C;GACA,SAAS,uBAAuB,qBAAqB;GACrD,iBAAiB;IAChB,KAAK,EACJ,MAAM;KACL;KACA;KACA,GAAI,QAAQ,QACT,CAAC,WAAW,QAAQ,KAAK,IACzB,CAAC;KACJ;KACA,GAAI,QAAQ,YACT,CAAC,gBAAgB,QAAQ,SAAS,IAClC,CAAC;IACL,EACD;IACA,IAAI,EACH,MAAM;KACL;KACA;KACA,GAAI,QAAQ,QACT,CAAC,WAAW,QAAQ,KAAK,IACzB,CAAC;IACL,EACD;GACD;EACD;CACD;CAID,IAAI,QAAQ,OACX,OAAO;EACN,OAAO;EACP,QAAQ;EACR,YAAY;GACX,MAAM;GACN,cAAc,qBAAqB;GACnC,OAAO;IACN;KACC,IAAI;KACJ,aACC,kQAGC,QAAQ,YACN,gBAAgB,QAAQ,UAAU,KAClC;IACL;IACA;KACC,IAAI;KACJ,aACC;IACF;IACA;KACC,IAAI;KACJ,aACC;IACF;IACA;KACC,IAAI;KACJ,aACC;KACD,SAAS;IACV;GACD;GACA,YAAY;IACX,MAAM;IACN,MAAM;KACL;KACA;KACA,GAAI,QAAQ,QAAQ,CAAC,WAAW,QAAQ,KAAK,IAAI,CAAC;IACnD;GACD;EACD;CACD;CAID,OAAO;EACN,OAAO;EACP,QAAQ;EACR,YAAY;GACX,MAAM;GACN,UACC;GACD,SAAS;IACR;KAAE,OAAO;KAAO,OAAO;IAAwB;IAC/C;KAAE,OAAO;KAAM,OAAO;IAAmB;IACzC;KAAE,OAAO;KAAQ,OAAO;IAA+B;GACxD;GACA,SACC;GACD,iBAAiB;IAChB,KAAK,EACJ,MAAM;KACL;KACA;KACA,GAAI,QAAQ,QAAQ,CAAC,WAAW,QAAQ,KAAK,IAAI,CAAC;KAClD;IACD,EACD;IACA,IAAI,EACH,MAAM;KACL;KACA;KACA,GAAI,QAAQ,QAAQ,CAAC,WAAW,QAAQ,KAAK,IAAI,CAAC;IACnD,EACD;IACA,MAAM,EACL,MAAM;KACL;KACA;KACA,GAAI,QAAQ,QAAQ,CAAC,WAAW,QAAQ,KAAK,IAAI,CAAC;KAClD;IACD,EACD;GACD;EACD;CACD;AACD"}
|