neon-init 0.14.0 → 0.16.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 +366 -30
- 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 +218 -13
- 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 +6 -1
- package/dist/lib/agents.d.ts.map +1 -1
- package/dist/lib/agents.js +62 -1
- package/dist/lib/agents.js.map +1 -1
- package/dist/lib/auth.d.ts +10 -3
- package/dist/lib/auth.d.ts.map +1 -1
- package/dist/lib/auth.js +21 -12
- 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.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 +28 -7
- 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 +37 -20
- package/dist/lib/install.js.map +1 -1
- package/dist/lib/neonctl.d.ts +51 -0
- package/dist/lib/neonctl.d.ts.map +1 -0
- package/dist/lib/neonctl.js +184 -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 +197 -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 +259 -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 +196 -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 +118 -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 +20 -3
- package/dist/lib/skills.d.ts.map +1 -1
- package/dist/lib/skills.js +116 -12
- package/dist/lib/skills.js.map +1 -1
- package/dist/lib/types.d.ts +150 -1
- package/dist/lib/types.d.ts.map +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 +7 -3
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"setup.js","names":[],"sources":["../../../src/lib/phases/setup.ts"],"sourcesContent":["import { writeFileSync } from \"node:fs\";\nimport { unlink } from \"node:fs/promises\";\nimport { resolve } from \"node:path\";\nimport { execa } from \"execa\";\nimport { resolveAddMcpAgentId } from \"../agents.js\";\nimport {\n\tFALLBACK_TEMPLATES,\n\tfetchTemplates,\n\ttype NeonFeature,\n} from \"../bootstrap.js\";\nimport {\n\tdetectIde,\n\tisCursorInstalled,\n\tisVSCodeInstalled,\n} from \"../detect-agent.js\";\nimport { findEditorCommand } from \"../extension.js\";\nimport { inspectProject } from \"../inspect.js\";\nimport { ensureNeonctl } from \"../neonctl.js\";\nimport { ensureSkillsUpToDate } from \"../skills.js\";\nimport type { Editor, PhaseResponse } from \"../types.js\";\nimport { downloadVsix, NEON_EXTENSION_ID } from \"../vsix.js\";\n\nexport interface SetupPhaseOptions {\n\tagent?: string;\n\t/** The IDE/editor the user is running in (e.g. \"cursor\", \"vscode\") — reported by agent */\n\tide?: string;\n\t/** Whether the directory already contains an application */\n\thasApp?: boolean;\n\t/** Template ID to scaffold (when bootstrapping a new project) */\n\ttemplate?: string;\n\t/** Neon features required by the selected template */\n\ttemplateRequires?: NeonFeature[];\n\t/** Neon features selected by the user (brownfield flows) */\n\tfeatures?: NeonFeature[];\n\t// Inspection results — pre-filled by orchestrator or reported by agent\n\tmcpConfigured?: boolean | null;\n\tconnectionString?: boolean | null;\n\tconnectionParams?: string; // JSON with host/dbname/etc if found\n\tframework?: string;\n\torm?: string;\n\tmigrationTool?: string;\n\tmigrationDir?: string;\n\tisVscodeIde?: boolean | null;\n\t// User preferences\n\tmode?: \"defaults\" | \"customize\";\n\tmcpScope?: \"global\" | \"project\" | \"none\";\n\tskillsScope?: \"global\" | \"project\";\n\tinstallExtension?: boolean;\n\t// Execution flags\n\texecute?: boolean;\n}\n\n/**\n * Comprehensive setup phase: inspects repo state, collects user preferences,\n * then batches all installation commands together.\n *\n * With --data JSON, the agent sends inspection results AND user preferences\n * in a single call, so the CLI can go straight to installation.\n */\nexport async function handleSetupPhase(\n\toptions: SetupPhaseOptions,\n): Promise<PhaseResponse> {\n\t// Parse features from comma-separated string (e.g. \"database,auth\" from agent --data)\n\tif (typeof options.features === \"string\") {\n\t\toptions.features = (options.features as unknown as string)\n\t\t\t.split(\",\")\n\t\t\t.map((f) => f.trim()) as NeonFeature[];\n\t}\n\n\t// Treat \"none\" as no template selected\n\tif (options.template === \"none\") {\n\t\toptions.template = undefined;\n\t}\n\n\t// Resolve template requirements if a template was selected but requires not yet populated\n\tif (options.template && !options.templateRequires) {\n\t\tconst templates = await fetchTemplates();\n\t\tconst selected = templates.find((t) => t.id === options.template);\n\t\tif (selected) {\n\t\t\toptions.templateRequires = selected.requires;\n\t\t}\n\t}\n\n\t// --execute: run the batched installation (legacy path)\n\tif (options.execute) {\n\t\treturn executeBatchedInstallation(await mergeCliInspection(options));\n\t}\n\n\t// User chose \"defaults\" — batch install with default settings\n\tif (options.mode === \"defaults\") {\n\t\tconst merged = await mergeCliInspection(options);\n\t\tconst shouldInstallExt =\n\t\t\tmerged.installExtension ?? isVscodeBasedIde(merged);\n\t\treturn executeBatchedInstallation({\n\t\t\t...merged,\n\t\t\tmcpScope: merged.mcpScope ?? \"global\",\n\t\t\tskillsScope: merged.skillsScope ?? \"project\",\n\t\t\tinstallExtension: shouldInstallExt,\n\t\t});\n\t}\n\n\t// User chose \"customize\" with scopes already provided (via --data) — go straight to install\n\tif (options.mode === \"customize\") {\n\t\tif (\n\t\t\toptions.mcpScope !== undefined ||\n\t\t\toptions.skillsScope !== undefined\n\t\t) {\n\t\t\tconst merged = await mergeCliInspection(options);\n\t\t\tconst shouldInstallExt =\n\t\t\t\tmerged.installExtension ?? isVscodeBasedIde(merged);\n\t\t\treturn executeBatchedInstallation({\n\t\t\t\t...merged,\n\t\t\t\tmcpScope: merged.mcpScope ?? \"global\",\n\t\t\t\tskillsScope: merged.skillsScope ?? \"project\",\n\t\t\t\tinstallExtension: shouldInstallExt,\n\t\t\t});\n\t\t}\n\t\t// Legacy path: scopes not yet chosen, ask follow-up\n\t\treturn buildCustomizeQuestions(options);\n\t}\n\n\t// Agent has reported inspection results (via legacy individual flags), but user hasn't chosen mode yet.\n\t// Only go to mode question if the agent explicitly reported back (not pre-filled by orchestrator).\n\t// Agent has reported inspection results (via legacy individual flags), but user hasn't chosen mode yet\n\tif (options.mcpConfigured !== null && options.mcpConfigured !== undefined) {\n\t\treturn buildModeQuestion(options);\n\t}\n\n\t// Default: send inspection checks with user preferences\n\treturn buildBulkInspection(options);\n}\n\nfunction buildTemplatePreference(\n\ttemplates: { id: string; title: string; description: string }[],\n) {\n\treturn [\n\t\t{\n\t\t\tid: \"template\",\n\t\t\tquestion:\n\t\t\t\t\"No application was detected in this directory. Would you like to scaffold a new project from a template?\",\n\t\t\tphase: \"before_checks\" as const,\n\t\t\toptions: [\n\t\t\t\t...templates.map((t) => ({\n\t\t\t\t\tvalue: t.id,\n\t\t\t\t\tlabel: `${t.title} — ${t.description}`,\n\t\t\t\t})),\n\t\t\t\t{\n\t\t\t\t\tvalue: \"none\",\n\t\t\t\t\tlabel: \"No thanks — continue without scaffolding\",\n\t\t\t\t},\n\t\t\t],\n\t\t\tdefault: \"none\",\n\t\t},\n\t];\n}\n\nasync function buildBulkInspection(\n\toptions: SetupPhaseOptions,\n): Promise<PhaseResponse> {\n\tconst hasApp = options.hasApp !== false;\n\tconst detectedIde = detectIde();\n\n\t// If no IDE detected (e.g. standalone terminal), check what's installed\n\tconst installedEditors: string[] = [];\n\tif (!detectedIde) {\n\t\tif (isCursorInstalled()) installedEditors.push(\"cursor\");\n\t\tif (isVSCodeInstalled()) installedEditors.push(\"vscode\");\n\t}\n\n\t// Fetch available templates when no app is detected\n\tlet templatePreferences: ReturnType<typeof buildTemplatePreference> = [];\n\tif (!hasApp) {\n\t\tlet templates = FALLBACK_TEMPLATES;\n\t\ttry {\n\t\t\tconst fetched = await fetchTemplates();\n\t\t\tif (fetched && fetched.length > 0) templates = fetched;\n\t\t} catch {}\n\t\ttemplatePreferences = buildTemplatePreference(templates);\n\t}\n\n\treturn {\n\t\tphase: \"setup\",\n\t\tstatus: hasApp ? \"pending\" : \"bootstrap_needed\",\n\t\tdetectedIde: detectedIde?.toLowerCase() ?? null,\n\t\tinstalledEditors: installedEditors.length > 0 ? installedEditors : null,\n\t\tnextAction: {\n\t\t\ttype: \"agent_check\",\n\t\t\tinstructions: [\n\t\t\t\t\"IMPORTANT: Do NOT summarize this response or ask the user for consent/confirmation before starting. Proceed IMMEDIATELY with the first userPreference question.\",\n\t\t\t\t\"\",\n\t\t\t\thasApp\n\t\t\t\t\t? \"Perform the agent checks listed above (MCP server status and your agent identity), then present each userPreference question to the user ONE AT A TIME, in order. Wait for the user's answer before showing the next question. Respect the `condition` field — only show a question if its condition is met.\"\n\t\t\t\t\t: \"No application was detected in this directory. Ask the user if they'd like to scaffold a new project from a template (the `template` preference). Present ALL template options and the 'No thanks' option — do NOT auto-select even if there is only one template. If the user selects a template, the scaffolded template includes agent skills so skills installation will be skipped. If the user chooses 'none', continue with the remaining setup preferences normally. Then perform the agent checks and present the remaining preferences ONE AT A TIME.\",\n\t\t\t\t\"\",\n\t\t\t\t\"If the MCP server is already configured, tell the user and note that it will be kept up to date. IMPORTANT: If you find neon-postgres in skills-lock.json, you MUST verify the actual SKILL.md file exists on disk (e.g. .agents/skills/neon-postgres/SKILL.md or .cursor/skills/neon-postgres/SKILL.md). If the lock file references it but the file is missing, report skills as NOT installed. Only ask about scope/options for components that are NOT already configured.\",\n\t\t\t\t\"\",\n\t\t\t\t\"IMPORTANT (Cursor users): Cursor disables project-level MCP servers by default as a security measure. If the user is in Cursor and chooses project-level MCP scope, warn them that they will need to manually enable the Neon server in Cursor Settings > MCP after installation. Recommend global scope for Cursor to avoid this extra step.\",\n\t\t\t\t\"\",\n\t\t\t\t\"GROUPING: Preferences that share the same `group` field should be presented together in a single message (e.g. list all customize options at once and let the user answer them together). Preferences without a `group` must be asked individually.\",\n\t\t\t\t\"\",\n\t\t\t\tdetectedIde\n\t\t\t\t\t? `The CLI has detected the IDE as: ${detectedIde.toLowerCase()}. Include this as the \"ide\" field in your reportBack data. IMPORTANT: The IDE and the agent are different — you may be Claude Code (agent) running inside Cursor (IDE). The extension installs into the IDE, so if the IDE is Cursor/VS Code/Windsurf, the extension IS applicable even if you are Claude Code.`\n\t\t\t\t\t: installedEditors.length > 0\n\t\t\t\t\t\t? `No IDE detected, but the following editors are installed: ${installedEditors.join(\", \")}. The \"installedEditors\" field in this response lists them. If the user wants the extension installed, ask which editor to install it for and include that as the \"ide\" field in your reportBack data. If not, set \"ide\" to \"none\".`\n\t\t\t\t\t\t: `No IDE or supported editors detected. Set \"ide\" to \"none\" in your reportBack data.`,\n\t\t\t\t\"\",\n\t\t\t\t\"After all questions are answered, call reportBack with a single --data JSON containing: agent, ide, mcpConfigured, and all preference answers. The CLI will inspect the project and merge results automatically.\",\n\t\t\t].join(\"\\n\"),\n\t\t\tchecks: [\n\t\t\t\t{\n\t\t\t\t\tid: \"neonctl\",\n\t\t\t\t\tdescription:\n\t\t\t\t\t\t\"The neonctl CLI will be installed or updated automatically (no action needed from the agent)\",\n\t\t\t\t\tlookFor: [],\n\t\t\t\t},\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\t{\n\t\t\t\t\tid: \"agent_type\",\n\t\t\t\t\tdescription:\n\t\t\t\t\t\t\"Identify which coding agent is running this command\",\n\t\t\t\t\tlookFor: [\n\t\t\t\t\t\t\"Determine which agent you are: cursor, claude-code, copilot, vscode, windsurf, codex, cline, gemini-cli, goose, opencode, or antigravity\",\n\t\t\t\t\t\t\"Report your own agent identifier — this is used to configure the MCP server for the correct tool\",\n\t\t\t\t\t],\n\t\t\t\t},\n\t\t\t\t...(detectedIde\n\t\t\t\t\t? [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tid: \"extension_installed\",\n\t\t\t\t\t\t\t\tdescription:\n\t\t\t\t\t\t\t\t\t\"Check if the Neon editor extension (databricks.neon-local-connect) is already installed in the IDE (NOT the agent — e.g. if you are Claude Code running inside Cursor, check Cursor's extensions)\",\n\t\t\t\t\t\t\t\tlookFor: [\n\t\t\t\t\t\t\t\t\t\"Run the IDE's --list-extensions command or check installed extensions for 'databricks.neon-local-connect' or 'Neon Local Connect'\",\n\t\t\t\t\t\t\t\t\t\"If the extension is found, set installExtension to false in your reportBack data and SKIP the installExtension question\",\n\t\t\t\t\t\t\t\t],\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],\n\t\t\tuserPreferences: [\n\t\t\t\t...templatePreferences,\n\t\t\t\t// For brownfield flows, ask which Neon features to enable\n\t\t\t\t...(hasApp\n\t\t\t\t\t? [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tid: \"features\",\n\t\t\t\t\t\t\t\tquestion:\n\t\t\t\t\t\t\t\t\t\"Which Neon features would you like to enable for this project?\",\n\t\t\t\t\t\t\t\tphase: \"after_checks\" as const,\n\t\t\t\t\t\t\t\toptions: [\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tvalue: \"database\",\n\t\t\t\t\t\t\t\t\t\tlabel: \"Database (always included)\",\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tvalue: \"database,auth\",\n\t\t\t\t\t\t\t\t\t\tlabel: \"Database + Neon Auth (adds authentication via Neon)\",\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t\tdefault: \"database\",\n\t\t\t\t\t\t\t\tcontext:\n\t\t\t\t\t\t\t\t\t\"Database connectivity is always set up. Neon Auth adds user authentication powered by Neon. More features (Functions, AI Gateway, Object Storage) will be available soon.\",\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\t\tid: \"mode\",\n\t\t\t\t\tquestion: \"Use default settings or customize?\",\n\t\t\t\t\tphase: \"after_checks\",\n\t\t\t\t\toptions: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tvalue: \"defaults\",\n\t\t\t\t\t\t\tlabel: hasApp\n\t\t\t\t\t\t\t\t? \"Use defaults (neonctl CLI, MCP: global, skills: project-level, extension if applicable — already-configured components will be skipped)\"\n\t\t\t\t\t\t\t\t: \"Use defaults (neonctl CLI, MCP: global, extension if applicable — skills included in template)\",\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tvalue: \"customize\",\n\t\t\t\t\t\t\tlabel: \"Customize installation settings\",\n\t\t\t\t\t\t},\n\t\t\t\t\t],\n\t\t\t\t\tdefault: \"defaults\",\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tid: \"mcpScope\",\n\t\t\t\t\tquestion: \"Where should the Neon MCP server be configured?\",\n\t\t\t\t\tcontext:\n\t\t\t\t\t\t\"SKIP this question entirely if the mcp_server check found it is already configured. Only ask if MCP is NOT yet configured. NOTE: Cursor disables project-level MCP servers by default — if the user is in Cursor, recommend global scope or warn that they will need to manually enable the server in Cursor Settings > MCP.\",\n\t\t\t\t\tphase: \"after_checks\",\n\t\t\t\t\toptions: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tvalue: \"global\",\n\t\t\t\t\t\t\tlabel: \"Global (available in all projects)\",\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tvalue: \"project\",\n\t\t\t\t\t\t\tlabel: \"Project-level (scoped to this project only)\",\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tvalue: \"none\",\n\t\t\t\t\t\t\tlabel: \"Skip — do not install the MCP server\",\n\t\t\t\t\t\t},\n\t\t\t\t\t],\n\t\t\t\t\tdefault: \"global\",\n\t\t\t\t\tcondition: { preferenceId: \"mode\", equals: \"customize\" },\n\t\t\t\t\tgroup: \"customize\",\n\t\t\t\t},\n\t\t\t\t// Only show skills scope when there's an existing app (templates bundle skills)\n\t\t\t\t...(hasApp\n\t\t\t\t\t? [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tid: \"skillsScope\",\n\t\t\t\t\t\t\t\tquestion:\n\t\t\t\t\t\t\t\t\t\"Where should Neon agent skills be installed?\",\n\t\t\t\t\t\t\t\tcontext:\n\t\t\t\t\t\t\t\t\t\"Always ask this question — the CLI handles skill detection and freshness automatically.\",\n\t\t\t\t\t\t\t\tphase: \"after_checks\" as const,\n\t\t\t\t\t\t\t\toptions: [\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tvalue: \"global\",\n\t\t\t\t\t\t\t\t\t\tlabel: \"Global (available in all projects)\",\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tvalue: \"project\",\n\t\t\t\t\t\t\t\t\t\tlabel: \"Project-level (scoped to this project only)\",\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t\tdefault: \"project\",\n\t\t\t\t\t\t\t\tcondition: {\n\t\t\t\t\t\t\t\t\tpreferenceId: \"mode\",\n\t\t\t\t\t\t\t\t\tequals: \"customize\",\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\tgroup: \"customize\",\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\t\tid: \"installExtension\",\n\t\t\t\t\tquestion:\n\t\t\t\t\t\t\"Install the Neon editor extension for local database browsing?\",\n\t\t\t\t\tphase: \"after_checks\",\n\t\t\t\t\toptions: [\n\t\t\t\t\t\t{ value: \"true\", label: \"Yes\" },\n\t\t\t\t\t\t{ value: \"false\", label: \"No\" },\n\t\t\t\t\t],\n\t\t\t\t\tdefault: \"true\",\n\t\t\t\t\tcontext:\n\t\t\t\t\t\t\"The extension installs into the IDE, NOT the agent. If the CLI detected the IDE (see detectedIde field), use that — e.g. Claude Code running inside Cursor means the IDE is Cursor and the extension IS applicable. Only applicable for VS Code-based IDEs (VS Code, Cursor, Windsurf). SKIP this question if the user is NOT in a VS Code-based IDE, or if the extension_installed check found it is already installed. Set installExtension to false in reportBack if skipped.\",\n\t\t\t\t\tcondition: { preferenceId: \"mode\", equals: \"customize\" },\n\t\t\t\t\tgroup: \"customize\",\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\"setup\",\n\t\t\t\t\t\"--json\",\n\t\t\t\t\t\"--data\",\n\t\t\t\t\t`<json: { agent: string, ide: string, mcpConfigured: bool, mode: string, mcpScope?: 'global'|'project'|'none', skillsScope?: string, installExtension?: bool${hasApp ? \", features?: string\" : \", template: string\"} }>`,\n\t\t\t\t],\n\t\t\t},\n\t\t},\n\t};\n}\n\nfunction buildModeQuestion(options: SetupPhaseOptions): PhaseResponse {\n\tconst agentArgs = options.agent ? [\"--agent\", options.agent] : [];\n\n\t// Build a context summary from what the agent found\n\tconst findings: string[] = [];\n\tif (options.mcpConfigured) {\n\t\tfindings.push(\n\t\t\t\"Neon MCP server is already configured (will be upgraded to evergreen)\",\n\t\t);\n\t} else {\n\t\tfindings.push(\"Neon MCP server is not configured\");\n\t}\n\tif (options.connectionString) {\n\t\tfindings.push(\"A Neon connection string was found in the project\");\n\t} else {\n\t\tfindings.push(\"No Neon connection string found — will need to add one\");\n\t}\n\tif (options.framework && options.framework !== \"none\") {\n\t\tfindings.push(`Framework detected: ${options.framework}`);\n\t}\n\tif (options.orm && options.orm !== \"none\") {\n\t\tfindings.push(`ORM detected: ${options.orm}`);\n\t}\n\tif (options.migrationTool && options.migrationTool !== \"none\") {\n\t\tfindings.push(`Migration tool detected: ${options.migrationTool}`);\n\t}\n\tif (options.isVscodeIde) {\n\t\tfindings.push(\"VS Code-based IDE detected — Neon extension available\");\n\t}\n\n\tconst inspectionArgs = buildInspectionArgs(options);\n\n\t// Build defaults label showing only what will be installed\n\tconst defaultsParts: string[] = [\"neonctl CLI\"];\n\tif (!options.mcpConfigured) defaultsParts.push(\"MCP global\");\n\tdefaultsParts.push(\"skills in project\");\n\tif (options.isVscodeIde) defaultsParts.push(\"install extension\");\n\tconst defaultsLabel =\n\t\tdefaultsParts.length > 0\n\t\t\t? `Use defaults (${defaultsParts.join(\", \")})`\n\t\t\t: \"Use defaults\";\n\n\treturn {\n\t\tphase: \"setup\",\n\t\tstatus: \"preferences_needed\",\n\t\tinspection: {\n\t\t\tmcpConfigured: options.mcpConfigured,\n\t\t\tconnectionString: options.connectionString,\n\t\t\tframework: options.framework,\n\t\t\torm: options.orm,\n\t\t\tmigrationTool: options.migrationTool,\n\t\t\tmigrationDir: options.migrationDir,\n\t\t\tisVscodeIde: options.isVscodeIde,\n\t\t},\n\t\tnextAction: {\n\t\t\ttype: \"ask_user\",\n\t\t\tquestion: \"Use default settings or customize?\",\n\t\t\toptions: [\n\t\t\t\t{\n\t\t\t\t\tvalue: \"defaults\",\n\t\t\t\t\tlabel: defaultsLabel,\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tvalue: \"customize\",\n\t\t\t\t\tlabel: \"Customize installation settings\",\n\t\t\t\t},\n\t\t\t],\n\t\t\tcontext: `Project inspection results:\\n${findings.map((f) => `- ${f}`).join(\"\\n\")}`,\n\t\t\tresponseMapping: {\n\t\t\t\tdefaults: {\n\t\t\t\t\targs: [\n\t\t\t\t\t\t\"setup\",\n\t\t\t\t\t\t\"--json\",\n\t\t\t\t\t\t...agentArgs,\n\t\t\t\t\t\t...inspectionArgs,\n\t\t\t\t\t\t\"--mode\",\n\t\t\t\t\t\t\"defaults\",\n\t\t\t\t\t],\n\t\t\t\t},\n\t\t\t\tcustomize: {\n\t\t\t\t\targs: [\n\t\t\t\t\t\t\"setup\",\n\t\t\t\t\t\t\"--json\",\n\t\t\t\t\t\t...agentArgs,\n\t\t\t\t\t\t...inspectionArgs,\n\t\t\t\t\t\t\"--mode\",\n\t\t\t\t\t\t\"customize\",\n\t\t\t\t\t],\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t};\n}\n\nfunction buildCustomizeQuestions(options: SetupPhaseOptions): PhaseResponse {\n\tconst agentArgs = options.agent ? [\"--agent\", options.agent] : [];\n\tconst inspectionArgs = buildInspectionArgs(options);\n\n\tconst needsMcp = !options.mcpConfigured;\n\tconst mcpScopes = needsMcp ? [\"global\", \"project\", \"none\"] : [\"skip\"];\n\tconst skillsScopes = [\"global\", \"project\"];\n\tconst extOptions = options.isVscodeIde ? [\"ext\", \"noext\"] : [\"ext\"];\n\n\t// Build all combinations of configurable options\n\tconst customOptions: { value: string; label: string }[] = [];\n\tfor (const mcp of mcpScopes) {\n\t\tfor (const skills of skillsScopes) {\n\t\t\tfor (const ext of extOptions) {\n\t\t\t\tconst parts: string[] = [];\n\t\t\t\tif (mcp === \"none\") parts.push(\"Skip MCP\");\n\t\t\t\telse if (mcp !== \"skip\") parts.push(`MCP: ${mcp}`);\n\t\t\t\tif (skills !== \"skip\")\n\t\t\t\t\tparts.push(\n\t\t\t\t\t\t`Skills: ${skills === \"project\" ? \"project-level\" : skills}`,\n\t\t\t\t\t);\n\t\t\t\tif (options.isVscodeIde) {\n\t\t\t\t\tparts.push(\n\t\t\t\t\t\text === \"ext\" ? \"Install extension\" : \"Skip extension\",\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tcustomOptions.push({\n\t\t\t\t\tvalue: `${mcp}_${skills}_${ext}`,\n\t\t\t\t\tlabel: parts.join(\", \"),\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t}\n\n\tconst responseMapping: Record<string, { args: string[] }> = {};\n\n\tfor (const opt of customOptions) {\n\t\tconst parts = opt.value.split(\"_\");\n\t\tconst mcpScope = parts[0] === \"skip\" ? \"global\" : parts[0]; // \"none\" passes through\n\t\tconst skillsScope = parts[1] === \"skip\" ? \"project\" : parts[1];\n\t\tconst installExt = parts[2] === \"ext\";\n\n\t\tresponseMapping[opt.value] = {\n\t\t\targs: [\n\t\t\t\t\"setup\",\n\t\t\t\t\"--json\",\n\t\t\t\t...agentArgs,\n\t\t\t\t...inspectionArgs,\n\t\t\t\t\"--mode\",\n\t\t\t\t\"customize\",\n\t\t\t\t\"--mcp-scope\",\n\t\t\t\tmcpScope,\n\t\t\t\t\"--skills-scope\",\n\t\t\t\tskillsScope,\n\t\t\t\t...(options.isVscodeIde\n\t\t\t\t\t? [\"--install-extension\", installExt ? \"true\" : \"false\"]\n\t\t\t\t\t: []),\n\t\t\t\t\"--execute\",\n\t\t\t],\n\t\t};\n\t}\n\n\treturn {\n\t\tphase: \"setup\",\n\t\tstatus: \"customizing\",\n\t\tnextAction: {\n\t\t\ttype: \"ask_user\",\n\t\t\tquestion: \"Choose your installation configuration:\",\n\t\t\toptions: customOptions,\n\t\t\tcontext:\n\t\t\t\t\"Global scope means settings apply across all your projects. Project-level means settings are scoped to this project only.\" +\n\t\t\t\t(options.mcpConfigured\n\t\t\t\t\t? \"\\nSince Neon tools are already installed, they will be upgraded to the latest evergreen version.\"\n\t\t\t\t\t: \"\") +\n\t\t\t\t(isCursorAgent(options)\n\t\t\t\t\t? \"\\nNote: 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.\"\n\t\t\t\t\t: \"\"),\n\t\t\tresponseMapping,\n\t\t},\n\t};\n}\n\ninterface InstallResult {\n\tid: string;\n\tdescription: string;\n\tstatus: \"success\" | \"failed\";\n\terror?: string;\n\t/** True when the step wasn't automated — the description contains manual instructions for the user */\n\tmanualAction?: boolean;\n}\n\n/**\n * Executes the batched installation of MCP server, skills, and extension.\n * Runs commands directly in the CLI process — the agent does NOT run these.\n * Returns results and chains to the getting-started phase.\n */\nasync function executeBatchedInstallation(\n\toptions: SetupPhaseOptions,\n): Promise<PhaseResponse> {\n\tconst mcpScope = options.mcpScope ?? \"global\";\n\tconst agentId = options.agent ?? \"claude-code\";\n\tconst mcpAgentId = resolveAddMcpAgentId(agentId);\n\tconst installExt = options.installExtension === true;\n\n\tconst results: InstallResult[] = [];\n\tconst isBootstrap = !!options.template;\n\n\t// Step 0: Bootstrap project from template if specified\n\tif (isBootstrap && options.template) {\n\t\ttry {\n\t\t\tawait execa(\n\t\t\t\t\"npx\",\n\t\t\t\t[\n\t\t\t\t\t\"neonctl\",\n\t\t\t\t\t\"bootstrap\",\n\t\t\t\t\t\".\",\n\t\t\t\t\t\"--template\",\n\t\t\t\t\toptions.template,\n\t\t\t\t\t\"--force\",\n\t\t\t\t],\n\t\t\t\t{ stdio: \"pipe\", timeout: 120000 },\n\t\t\t);\n\t\t\tresults.push({\n\t\t\t\tid: \"bootstrap\",\n\t\t\t\tdescription: `Scaffolded project from template \"${options.template}\"`,\n\t\t\t\tstatus: \"success\",\n\t\t\t});\n\n\t\t\t// Write template features to .neon under _init (ephemeral, cleaned up when init completes)\n\t\t\tif (options.templateRequires) {\n\t\t\t\tconst neonContextPath = resolve(process.cwd(), \".neon\");\n\t\t\t\tconst context: Record<string, unknown> = {\n\t\t\t\t\t_init: { features: options.templateRequires },\n\t\t\t\t};\n\t\t\t\twriteFileSync(\n\t\t\t\t\tneonContextPath,\n\t\t\t\t\t`${JSON.stringify(context, null, 2)}\\n`,\n\t\t\t\t);\n\t\t\t}\n\t\t} catch (err) {\n\t\t\tresults.push({\n\t\t\t\tid: \"bootstrap\",\n\t\t\t\tdescription: `Failed to scaffold project from template \"${options.template}\"`,\n\t\t\t\tstatus: \"failed\",\n\t\t\t\terror: err instanceof Error ? err.message : \"Unknown error\",\n\t\t\t});\n\t\t}\n\t}\n\n\t// Step 1: Ensure neonctl CLI is installed and up to date\n\tconst neonctlResult = await ensureNeonctl();\n\tswitch (neonctlResult.status) {\n\t\tcase \"already_current\":\n\t\t\tresults.push({\n\t\t\t\tid: \"neonctl\",\n\t\t\t\tdescription: `neonctl CLI is up to date (v${neonctlResult.version})`,\n\t\t\t\tstatus: \"success\",\n\t\t\t});\n\t\t\tbreak;\n\t\tcase \"installed\":\n\t\t\tresults.push({\n\t\t\t\tid: \"neonctl\",\n\t\t\t\tdescription: `Installed neonctl CLI (v${neonctlResult.version})`,\n\t\t\t\tstatus: \"success\",\n\t\t\t});\n\t\t\tbreak;\n\t\tcase \"updated\":\n\t\t\tresults.push({\n\t\t\t\tid: \"neonctl\",\n\t\t\t\tdescription: `Updated neonctl CLI to v${neonctlResult.version}`,\n\t\t\t\tstatus: \"success\",\n\t\t\t});\n\t\t\tbreak;\n\t\tcase \"failed\":\n\t\t\tresults.push({\n\t\t\t\tid: \"neonctl\",\n\t\t\t\tdescription: \"Failed to install neonctl CLI\",\n\t\t\t\tstatus: \"failed\",\n\t\t\t\terror: neonctlResult.error,\n\t\t\t});\n\t\t\tbreak;\n\t}\n\n\t// Step 2: Install MCP server (skip if already configured)\n\tconst isCursor =\n\t\tmcpAgentId === \"cursor\" ||\n\t\toptions.ide?.toLowerCase() === \"cursor\" ||\n\t\toptions.agent?.toLowerCase() === \"cursor\";\n\n\tif (mcpScope === \"none\") {\n\t\tresults.push({\n\t\t\tid: \"skip_mcp\",\n\t\t\tdescription: \"Neon MCP server installation skipped by user\",\n\t\t\tstatus: \"success\",\n\t\t});\n\t} else if (options.mcpConfigured) {\n\t\tresults.push({\n\t\t\tid: \"skip_mcp\",\n\t\t\tdescription: \"Neon MCP server already configured\",\n\t\t\tstatus: \"success\",\n\t\t});\n\t} else {\n\t\tconst mcpArgs = [\n\t\t\t\"-y\",\n\t\t\t\"add-mcp\",\n\t\t\t\"https://mcp.neon.tech/mcp\",\n\t\t\t...(mcpScope === \"global\" ? [\"-g\"] : []),\n\t\t\t\"-n\",\n\t\t\t\"Neon\",\n\t\t\t\"-y\",\n\t\t\t\"-a\",\n\t\t\tmcpAgentId,\n\t\t];\n\t\ttry {\n\t\t\tawait execa(\"npx\", mcpArgs, { stdio: \"pipe\", timeout: 60000 });\n\t\t\tresults.push({\n\t\t\t\tid: \"install_mcp\",\n\t\t\t\tdescription: `Installed Neon MCP server (${mcpScope} scope)`,\n\t\t\t\tstatus: \"success\",\n\t\t\t});\n\n\t\t\t// Some editors disable newly added MCP servers by default.\n\t\t\t// Cursor: project-level servers are always disabled initially.\n\t\t\t// Claude Code: newly added servers require user approval.\n\t\t\tconst isClaudeCode =\n\t\t\t\tmcpAgentId === \"claude-code\" ||\n\t\t\t\toptions.agent?.toLowerCase() === \"claude-code\";\n\n\t\t\tif (isCursor && mcpScope === \"project\") {\n\t\t\t\tresults.push({\n\t\t\t\t\tid: \"enable_mcp\",\n\t\t\t\t\tdescription:\n\t\t\t\t\t\t'Cursor disables project-level MCP servers by default. Open Cursor Settings > MCP and toggle the \"Neon\" server on.',\n\t\t\t\t\tstatus: \"success\",\n\t\t\t\t\tmanualAction: true,\n\t\t\t\t});\n\t\t\t} else if (isClaudeCode) {\n\t\t\t\tresults.push({\n\t\t\t\t\tid: \"enable_mcp\",\n\t\t\t\t\tdescription:\n\t\t\t\t\t\t'Claude Code requires approval for newly added MCP servers. When prompted, approve the \"Neon\" MCP server to enable it. You can check MCP server status with /mcp in Claude Code.',\n\t\t\t\t\tstatus: \"success\",\n\t\t\t\t\tmanualAction: true,\n\t\t\t\t});\n\t\t\t}\n\t\t} catch (err) {\n\t\t\tresults.push({\n\t\t\t\tid: \"install_mcp\",\n\t\t\t\tdescription: \"Failed to install Neon MCP server\",\n\t\t\t\tstatus: \"failed\",\n\t\t\t\terror: err instanceof Error ? err.message : \"Unknown error\",\n\t\t\t});\n\t\t}\n\t}\n\n\t// Step 3: Install/update skills (skip when bootstrapping — templates bundle skills)\n\tif (isBootstrap) {\n\t\tresults.push({\n\t\t\tid: \"install_skills\",\n\t\t\tdescription: \"Neon agent skills included in template\",\n\t\t\tstatus: \"success\",\n\t\t});\n\t} else {\n\t\tconst skillsScope = options.skillsScope ?? \"project\";\n\t\tconst skillsOk = await ensureSkillsUpToDate(agentId, skillsScope);\n\t\tresults.push({\n\t\t\tid: \"install_skills\",\n\t\t\tdescription: skillsOk\n\t\t\t\t? \"Neon agent skills installed\"\n\t\t\t\t: \"Failed to install Neon agent skills\",\n\t\t\tstatus: skillsOk ? \"success\" : \"failed\",\n\t\t});\n\t}\n\n\t// Step 4: Install editor extension if requested\n\t// Use the agent-reported IDE (not agent identity) — e.g. Claude Code running in\n\t// Cursor should install the extension for Cursor, not skip it.\n\tif (installExt) {\n\t\tconst extResult = await installExtensionForIde(options.ide ?? agentId);\n\t\tresults.push(extResult);\n\t}\n\n\t// Step 5: Write selected features to .neon under _init for brownfield flows\n\t// (Bootstrap flows already wrote _init in step 0)\n\tif (!isBootstrap && options.features && options.features.length > 0) {\n\t\tconst neonContextPath = resolve(process.cwd(), \".neon\");\n\t\tconst context: Record<string, unknown> = {\n\t\t\t_init: { features: options.features },\n\t\t};\n\t\twriteFileSync(neonContextPath, `${JSON.stringify(context, null, 2)}\\n`);\n\t}\n\n\tconst allSucceeded = results.every((r) => r.status === \"success\");\n\n\t// Build args to chain to the getting-started phase as a separate CLI call.\n\t// This ensures the agent gets a clean response with ONLY the getting-started\n\t// action — no competing \"results\" array to distract it.\n\tconst gettingStartedData: Record<string, unknown> = {};\n\tif (options.connectionString) gettingStartedData.hasConnectionString = true;\n\tif (options.framework) gettingStartedData.framework = options.framework;\n\tif (options.orm) gettingStartedData.orm = options.orm;\n\tif (options.migrationTool)\n\t\tgettingStartedData.migrationTool = options.migrationTool;\n\tif (options.migrationDir)\n\t\tgettingStartedData.migrationDir = options.migrationDir;\n\t// Pass features so getting-started knows which phases to chain to\n\tconst resolvedFeatures = options.templateRequires ?? options.features;\n\tif (resolvedFeatures && resolvedFeatures.length > 0)\n\t\tgettingStartedData.features = resolvedFeatures;\n\t// Bootstrap implies preview mode (new project in us-east required)\n\tif (isBootstrap) gettingStartedData.preview = true;\n\tconst gettingStartedArgs = [\n\t\t\"getting-started\",\n\t\t\"--json\",\n\t\t\"--data\",\n\t\tJSON.stringify(gettingStartedData),\n\t];\n\n\treturn {\n\t\tphase: \"setup\",\n\t\tstatus: allSucceeded ? \"installed\" : \"partial\",\n\t\tresults,\n\t\tnextAction: {\n\t\t\ttype: \"run_neon_init\",\n\t\t\targs: gettingStartedArgs,\n\t\t},\n\t};\n}\n\nfunction buildInspectionArgs(options: SetupPhaseOptions): string[] {\n\tconst args: string[] = [];\n\tif (options.mcpConfigured !== null && options.mcpConfigured !== undefined) {\n\t\targs.push(\"--mcp-configured\", options.mcpConfigured ? \"true\" : \"false\");\n\t}\n\tif (\n\t\toptions.connectionString !== null &&\n\t\toptions.connectionString !== undefined\n\t) {\n\t\targs.push(\n\t\t\t\"--connection-string\",\n\t\t\toptions.connectionString ? \"true\" : \"false\",\n\t\t);\n\t}\n\tif (options.framework) {\n\t\targs.push(\"--framework\", options.framework);\n\t}\n\tif (options.orm) {\n\t\targs.push(\"--orm\", options.orm);\n\t}\n\tif (options.migrationTool) {\n\t\targs.push(\"--migration-tool\", options.migrationTool);\n\t}\n\tif (options.migrationDir) {\n\t\targs.push(\"--migration-dir\", options.migrationDir);\n\t}\n\tif (options.isVscodeIde !== null && options.isVscodeIde !== undefined) {\n\t\targs.push(\"--is-vscode-ide\", options.isVscodeIde ? \"true\" : \"false\");\n\t}\n\treturn args;\n}\n\n/**\n * Fills in missing filesystem inspection fields by running inspectProject().\n * Agent-reported data (mcpConfigured, agent, mode, scopes) is preserved.\n * CLI-detectable fields (framework, orm, migrations, connectionString, isVscodeIde)\n * are filled in only if not already present.\n */\nasync function mergeCliInspection(\n\toptions: SetupPhaseOptions,\n): Promise<SetupPhaseOptions> {\n\t// If the agent already provided these, no need to re-inspect\n\tif (options.framework !== undefined && options.orm !== undefined) {\n\t\treturn options;\n\t}\n\n\tconst inspection = await inspectProject([\n\t\t{ id: \"connection_string\", description: \"\", lookFor: [] },\n\t\t{ id: \"project_stack\", description: \"\", lookFor: [] },\n\t\t{ id: \"migrations\", description: \"\", lookFor: [] },\n\t\t{ id: \"ide_type\", description: \"\", lookFor: [] },\n\t]);\n\n\t// Also detect IDE if not already reported by the agent\n\tconst ide =\n\t\toptions.ide?.toLowerCase().replace(/\\s+/g, \"-\") ||\n\t\tdetectIde()?.toLowerCase().replace(/\\s+/g, \"-\") ||\n\t\tundefined;\n\n\treturn {\n\t\t...options,\n\t\tide,\n\t\tconnectionString:\n\t\t\toptions.connectionString ??\n\t\t\t(inspection.connectionString as boolean | undefined),\n\t\tframework:\n\t\t\toptions.framework ?? (inspection.framework as string | undefined),\n\t\torm: options.orm ?? (inspection.orm as string | undefined),\n\t\tmigrationTool:\n\t\t\toptions.migrationTool ??\n\t\t\t(inspection.migrationTool as string | undefined),\n\t\tmigrationDir:\n\t\t\toptions.migrationDir ??\n\t\t\t(inspection.migrationDir as string | undefined),\n\t\tisVscodeIde:\n\t\t\toptions.isVscodeIde ??\n\t\t\t(inspection.isVscodeIde as boolean | undefined),\n\t};\n}\n\n/**\n * Checks whether the user is in a VS Code-based IDE that supports extensions.\n * Uses agent-reported `ide` field first, then falls back to `isVscodeIde` from inspection.\n */\nfunction isCursorAgent(options: SetupPhaseOptions): boolean {\n\tconst ide = options.ide?.toLowerCase();\n\tif (ide === \"cursor\") return true;\n\tconst agent = options.agent?.toLowerCase();\n\tif (agent === \"cursor\") return true;\n\treturn false;\n}\n\nfunction isVscodeBasedIde(options: SetupPhaseOptions): boolean {\n\tif (options.ide) {\n\t\tconst ide = options.ide.toLowerCase();\n\t\treturn (\n\t\t\tide === \"cursor\" ||\n\t\t\tide === \"vscode\" ||\n\t\t\tide === \"vs-code\" ||\n\t\t\tide === \"windsurf\"\n\t\t);\n\t}\n\treturn options.isVscodeIde === true;\n}\n\n/**\n * Resolves which IDE to install the extension for.\n * Accepts the agent-reported IDE value (preferred), the agent ID, or\n * falls back to env-var detection.\n */\nfunction resolveEditorForExtension(ideOrAgentId: string): Editor | null {\n\t// Map known IDE/agent identifiers to Editor types\n\tswitch (ideOrAgentId.toLowerCase()) {\n\t\tcase \"cursor\":\n\t\t\treturn \"Cursor\";\n\t\tcase \"vscode\":\n\t\tcase \"vs-code\":\n\t\tcase \"copilot\":\n\t\tcase \"github-copilot\":\n\t\tcase \"github-copilot-cli\":\n\t\t\treturn \"VS Code\";\n\t\tdefault:\n\t\t\tbreak;\n\t}\n\n\t// Fall back to env-var detection\n\tconst ide = detectIde();\n\tif (ide === \"Cursor\" || ide === \"VS Code\") return ide;\n\n\treturn null;\n}\n\nconst MANUAL_INSTALL_MSG = `Search for \"Neon\" in the extensions panel (Cmd+Shift+X / Ctrl+Shift+X) and install \"Neon Local Connect\" by Databricks.`;\n\n/**\n * Installs the Neon extension for the detected IDE.\n *\n * Uses env-var detection to determine the IDE (not the agent identity),\n * so Claude Code running in Cursor correctly installs for Cursor.\n *\n * Strategy:\n * 1. Try `<editor> --install-extension <id>` directly (uses editor's configured marketplace)\n * 2. If that fails, download .vsix (from proxy or Open VSX) and install via local file\n * 3. If all else fails: return manual install instructions\n */\nasync function installExtensionForIde(agentId: string): Promise<InstallResult> {\n\tconst editorType = resolveEditorForExtension(agentId);\n\tif (!editorType) {\n\t\treturn {\n\t\t\tid: \"install_extension\",\n\t\t\tdescription: MANUAL_INSTALL_MSG,\n\t\t\tstatus: \"success\",\n\t\t\tmanualAction: true,\n\t\t};\n\t}\n\n\tconst editorCmd = await findEditorCommand(editorType);\n\tif (!editorCmd) {\n\t\treturn {\n\t\t\tid: \"install_extension\",\n\t\t\tdescription: MANUAL_INSTALL_MSG,\n\t\t\tstatus: \"success\",\n\t\t\tmanualAction: true,\n\t\t};\n\t}\n\n\t// Try direct marketplace install first (works if editor has marketplace configured)\n\ttry {\n\t\tawait execa(editorCmd, [\"--install-extension\", NEON_EXTENSION_ID], {\n\t\t\tstdio: \"pipe\",\n\t\t\ttimeout: 60000,\n\t\t});\n\t\treturn {\n\t\t\tid: \"install_extension\",\n\t\t\tdescription: `Installed Neon extension for ${editorType}`,\n\t\t\tstatus: \"success\",\n\t\t};\n\t} catch {\n\t\t// Fall through to VSIX download approach\n\t}\n\n\t// Download .vsix and install locally\n\tconst vsixPath = await downloadVsix();\n\tif (!vsixPath) {\n\t\treturn {\n\t\t\tid: \"install_extension\",\n\t\t\tdescription: MANUAL_INSTALL_MSG,\n\t\t\tstatus: \"success\",\n\t\t\tmanualAction: true,\n\t\t};\n\t}\n\n\ttry {\n\t\tawait execa(editorCmd, [\"--install-extension\", vsixPath], {\n\t\t\tstdio: \"pipe\",\n\t\t\ttimeout: 60000,\n\t\t});\n\t\treturn {\n\t\t\tid: \"install_extension\",\n\t\t\tdescription: `Installed Neon extension for ${editorType}`,\n\t\t\tstatus: \"success\",\n\t\t};\n\t} catch {\n\t\treturn {\n\t\t\tid: \"install_extension\",\n\t\t\tdescription: MANUAL_INSTALL_MSG,\n\t\t\tstatus: \"success\",\n\t\t\tmanualAction: true,\n\t\t};\n\t} finally {\n\t\ttry {\n\t\t\tawait unlink(vsixPath);\n\t\t} catch {}\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AA2DA,eAAsB,iBACrB,SACyB;CAEzB,IAAI,OAAO,QAAQ,aAAa,UAC/B,QAAQ,WAAY,QAAQ,SAC1B,MAAM,GAAG,CAAC,CACV,KAAK,MAAM,EAAE,KAAK,CAAC;CAItB,IAAI,QAAQ,aAAa,QACxB,QAAQ,WAAW,KAAA;CAIpB,IAAI,QAAQ,YAAY,CAAC,QAAQ,kBAAkB;EAElD,MAAM,YAAW,MADO,eAAe,EAAA,CACZ,MAAM,MAAM,EAAE,OAAO,QAAQ,QAAQ;EAChE,IAAI,UACH,QAAQ,mBAAmB,SAAS;CAEtC;CAGA,IAAI,QAAQ,SACX,OAAO,2BAA2B,MAAM,mBAAmB,OAAO,CAAC;CAIpE,IAAI,QAAQ,SAAS,YAAY;EAChC,MAAM,SAAS,MAAM,mBAAmB,OAAO;EAC/C,MAAM,mBACL,OAAO,oBAAoB,iBAAiB,MAAM;EACnD,OAAO,2BAA2B;GACjC,GAAG;GACH,UAAU,OAAO,YAAY;GAC7B,aAAa,OAAO,eAAe;GACnC,kBAAkB;EACnB,CAAC;CACF;CAGA,IAAI,QAAQ,SAAS,aAAa;EACjC,IACC,QAAQ,aAAa,KAAA,KACrB,QAAQ,gBAAgB,KAAA,GACvB;GACD,MAAM,SAAS,MAAM,mBAAmB,OAAO;GAC/C,MAAM,mBACL,OAAO,oBAAoB,iBAAiB,MAAM;GACnD,OAAO,2BAA2B;IACjC,GAAG;IACH,UAAU,OAAO,YAAY;IAC7B,aAAa,OAAO,eAAe;IACnC,kBAAkB;GACnB,CAAC;EACF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aACC;KACD,SAAS,CAAC;IACX;IACA;KACC,IAAI;KACJ,aACC;KACD,SAAS,CACR,yEACD;IACD;IACA;KACC,IAAI;KACJ,aACC;KACD,SAAS,CACR,4IACA,kGACD;IACD;IACA,GAAI,cACD,CACA;KACC,IAAI;KACJ,aACC;KACD,SAAS,CACR,qIACA,yHACD;IACD,CACD,IACC,CAAC;GACL;GACA,iBAAiB;IAChB,GAAG;IAEH,GAAI,SACD,CACA;KACC,IAAI;KACJ,UACC;KACD,OAAO;KACP,SAAS,CACR;MACC,OAAO;MACP,OAAO;KACR,GACA;MACC,OAAO;MACP,OAAO;KACR,CACD;KACA,SAAS;KACT,SACC;IACF,CACD,IACC,CAAC;IACJ;KACC,IAAI;KACJ,UAAU;KACV,OAAO;KACP,SAAS,CACR;MACC,OAAO;MACP,OAAO,SACJ,4IACA;KACJ,GACA;MACC,OAAO;MACP,OAAO;KACR,CACD;KACA,SAAS;IACV;IACA;KACC,IAAI;KACJ,UAAU;KACV,SACC;KACD,OAAO;KACP,SAAS;MACR;OACC,OAAO;OACP,OAAO;MACR;MACA;OACC,OAAO;OACP,OAAO;MACR;MACA;OACC,OAAO;OACP,OAAO;MACR;KACD;KACA,SAAS;KACT,WAAW;MAAE,cAAc;MAAQ,QAAQ;KAAY;KACvD,OAAO;IACR;IAEA,GAAI,SACD,CACA;KACC,IAAI;KACJ,UACC;KACD,SACC;KACD,OAAO;KACP,SAAS,CACR;MACC,OAAO;MACP,OAAO;KACR,GACA;MACC,OAAO;MACP,OAAO;KACR,CACD;KACA,SAAS;KACT,WAAW;MACV,cAAc;MACd,QAAQ;KACT;KACA,OAAO;IACR,CACD,IACC,CAAC;IACJ;KACC,IAAI;KACJ,UACC;KACD,OAAO;KACP,SAAS,CACR;MAAE,OAAO;MAAQ,OAAO;KAAM,GAC9B;MAAE,OAAO;MAAS,OAAO;KAAK,CAC/B;KACA,SAAS;KACT,SACC;KACD,WAAW;MAAE,cAAc;MAAQ,QAAQ;KAAY;KACvD,OA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J,aAAa,gCAAgC;GAC7C,QAAQ;EACT;CACD,QAAQ,CAER;CAGA,MAAM,WAAW,MAAM,aAAa;CACpC,IAAI,CAAC,UACJ,OAAO;EACN,IAAI;EACJ,aAAa;EACb,QAAQ;EACR,cAAc;CACf;CAGD,IAAI;EACH,MAAM,MAAM,WAAW,CAAC,uBAAuB,QAAQ,GAAG;GACzD,OAAO;GACP,SAAS;EACV,CAAC;EACD,OAAO;GACN,IAAI;GACJ,aAAa,gCAAgC;GAC7C,QAAQ;EACT;CACD,QAAQ;EACP,OAAO;GACN,IAAI;GACJ,aAAa;GACb,QAAQ;GACR,cAAc;EACf;CACD,UAAU;EACT,IAAI;GACH,MAAM,OAAO,QAAQ;EACtB,QAAQ,CAAC;CACV;AACD"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Editor, PhaseResponse } from "../types.js";
|
|
2
|
+
|
|
3
|
+
//#region src/lib/phases/skills.d.ts
|
|
4
|
+
interface SkillsPhaseOptions {
|
|
5
|
+
agent?: string;
|
|
6
|
+
editor?: Editor;
|
|
7
|
+
status?: boolean;
|
|
8
|
+
install?: boolean;
|
|
9
|
+
update?: boolean;
|
|
10
|
+
}
|
|
11
|
+
declare function handleSkillsPhase(options: SkillsPhaseOptions): Promise<PhaseResponse>;
|
|
12
|
+
//#endregion
|
|
13
|
+
export { SkillsPhaseOptions, handleSkillsPhase };
|
|
14
|
+
//# sourceMappingURL=skills.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"skills.d.ts","names":[],"sources":["../../../src/lib/phases/skills.ts"],"mappings":";;;UAIiB,kBAAA;;EAAA,MAAA,CAAA,EAEP,MAFO;EAQK,MAAA,CAAA,EAAA,OAAA;EAAiB,OAAA,CAAA,EAAA,OAAA;QAC7B,CAAA,EAAA,OAAA;;AACP,iBAFmB,iBAAA,CAEnB,OAAA,EADO,kBACP,CAAA,EAAA,OAAA,CAAQ,aAAR,CAAA"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { getSkillsAgentName } from "../agents.js";
|
|
2
|
+
import { SKILL_REFERENCE_URLS } from "../skills.js";
|
|
3
|
+
//#region src/lib/phases/skills.ts
|
|
4
|
+
async function handleSkillsPhase(options) {
|
|
5
|
+
const agentArgs = options.agent ? [
|
|
6
|
+
"--agent",
|
|
7
|
+
options.agent,
|
|
8
|
+
"--json"
|
|
9
|
+
] : ["--json"];
|
|
10
|
+
const skillsAgent = options.agent ? getSkillsAgentName(options.agent) : "claude-code";
|
|
11
|
+
if (options.status) return {
|
|
12
|
+
phase: "tooling",
|
|
13
|
+
status: "skills_check",
|
|
14
|
+
nextAction: {
|
|
15
|
+
type: "agent_check",
|
|
16
|
+
checks: [{
|
|
17
|
+
id: "skills",
|
|
18
|
+
description: "Check if Neon agent skills are installed in this project",
|
|
19
|
+
lookFor: ["A skill file referencing 'neon-postgres' (e.g. .cursor/skills/, CLAUDE.md, .cursorrules)", "A .skills/ directory with neon-related content"]
|
|
20
|
+
}],
|
|
21
|
+
reportBack: {
|
|
22
|
+
type: "run_neon_init",
|
|
23
|
+
args: [
|
|
24
|
+
"skills",
|
|
25
|
+
"--json",
|
|
26
|
+
...options.agent ? ["--agent", options.agent] : [],
|
|
27
|
+
...options.update ? ["--update"] : ["--install"]
|
|
28
|
+
]
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
if (options.install || options.update) return {
|
|
33
|
+
phase: "tooling",
|
|
34
|
+
status: "installing_skills",
|
|
35
|
+
nextAction: {
|
|
36
|
+
type: "run_command",
|
|
37
|
+
command: `npx -y skills add neondatabase/agent-skills --skill neon-postgres --agent ${skillsAgent} -y`,
|
|
38
|
+
description: `Installing Neon agent skills for ${skillsAgent}.`,
|
|
39
|
+
timeout: 3e4,
|
|
40
|
+
onSuccess: {
|
|
41
|
+
type: "run_neon_init",
|
|
42
|
+
args: agentArgs
|
|
43
|
+
},
|
|
44
|
+
onFailure: { other: {
|
|
45
|
+
type: "run_neon_init",
|
|
46
|
+
args: agentArgs
|
|
47
|
+
} }
|
|
48
|
+
},
|
|
49
|
+
skillReferences: SKILL_REFERENCE_URLS
|
|
50
|
+
};
|
|
51
|
+
return {
|
|
52
|
+
phase: "tooling",
|
|
53
|
+
status: "skills_available",
|
|
54
|
+
nextAction: {
|
|
55
|
+
type: "ask_user",
|
|
56
|
+
question: "Would you like to install Neon agent skills for this project? Skills provide your AI assistant with Neon-specific knowledge.",
|
|
57
|
+
options: [{
|
|
58
|
+
value: "yes",
|
|
59
|
+
label: "Yes, install skills"
|
|
60
|
+
}, {
|
|
61
|
+
value: "skip",
|
|
62
|
+
label: "Skip for now"
|
|
63
|
+
}],
|
|
64
|
+
context: "Agent skills include guides for connection patterns, Neon Auth setup, branching, migrations, and more.",
|
|
65
|
+
responseMapping: {
|
|
66
|
+
yes: { args: [
|
|
67
|
+
"skills",
|
|
68
|
+
"--json",
|
|
69
|
+
...options.agent ? ["--agent", options.agent] : [],
|
|
70
|
+
"--install"
|
|
71
|
+
] },
|
|
72
|
+
skip: { args: agentArgs }
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
//#endregion
|
|
78
|
+
export { handleSkillsPhase };
|
|
79
|
+
|
|
80
|
+
//# sourceMappingURL=skills.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"skills.js","names":[],"sources":["../../../src/lib/phases/skills.ts"],"sourcesContent":["import { getSkillsAgentName } from \"../agents.js\";\nimport { SKILL_REFERENCE_URLS } from \"../skills.js\";\nimport type { Editor, PhaseResponse } from \"../types.js\";\n\nexport interface SkillsPhaseOptions {\n\tagent?: string;\n\teditor?: Editor;\n\tstatus?: boolean;\n\tinstall?: boolean;\n\tupdate?: boolean;\n}\n\nexport async function handleSkillsPhase(\n\toptions: SkillsPhaseOptions,\n): Promise<PhaseResponse> {\n\tconst agentArgs = options.agent\n\t\t? [\"--agent\", options.agent, \"--json\"]\n\t\t: [\"--json\"];\n\tconst skillsAgent = options.agent\n\t\t? getSkillsAgentName(options.agent)\n\t\t: \"claude-code\";\n\n\t// --status: ask agent to check\n\tif (options.status) {\n\t\treturn {\n\t\t\tphase: \"tooling\",\n\t\t\tstatus: \"skills_check\",\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: \"skills\",\n\t\t\t\t\t\tdescription:\n\t\t\t\t\t\t\t\"Check if Neon agent skills are installed in this project\",\n\t\t\t\t\t\tlookFor: [\n\t\t\t\t\t\t\t\"A skill file referencing 'neon-postgres' (e.g. .cursor/skills/, CLAUDE.md, .cursorrules)\",\n\t\t\t\t\t\t\t\"A .skills/ directory with neon-related content\",\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\"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...(options.update ? [\"--update\"] : [\"--install\"]),\n\t\t\t\t\t],\n\t\t\t\t},\n\t\t\t},\n\t\t};\n\t}\n\n\t// --install or --update: run the skills CLI\n\tif (options.install || options.update) {\n\t\tconst installCmd = `npx -y skills add neondatabase/agent-skills --skill neon-postgres --agent ${skillsAgent} -y`;\n\t\treturn {\n\t\t\tphase: \"tooling\",\n\t\t\tstatus: \"installing_skills\",\n\t\t\tnextAction: {\n\t\t\t\ttype: \"run_command\",\n\t\t\t\tcommand: installCmd,\n\t\t\t\tdescription: `Installing Neon agent skills for ${skillsAgent}.`,\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: agentArgs,\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: agentArgs,\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t\tskillReferences: SKILL_REFERENCE_URLS,\n\t\t};\n\t}\n\n\t// Default: ask if they want skills installed\n\treturn {\n\t\tphase: \"tooling\",\n\t\tstatus: \"skills_available\",\n\t\tnextAction: {\n\t\t\ttype: \"ask_user\",\n\t\t\tquestion:\n\t\t\t\t\"Would you like to install Neon agent skills for this project? Skills provide your AI assistant with Neon-specific knowledge.\",\n\t\t\toptions: [\n\t\t\t\t{ value: \"yes\", label: \"Yes, install skills\" },\n\t\t\t\t{ value: \"skip\", label: \"Skip for now\" },\n\t\t\t],\n\t\t\tcontext:\n\t\t\t\t\"Agent skills include guides for connection patterns, Neon Auth setup, branching, migrations, and more.\",\n\t\t\tresponseMapping: {\n\t\t\t\tyes: {\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\tskip: { args: agentArgs },\n\t\t\t},\n\t\t},\n\t};\n}\n"],"mappings":";;;AAYA,eAAsB,kBACrB,SACyB;CACzB,MAAM,YAAY,QAAQ,QACvB;EAAC;EAAW,QAAQ;EAAO;CAAQ,IACnC,CAAC,QAAQ;CACZ,MAAM,cAAc,QAAQ,QACzB,mBAAmB,QAAQ,KAAK,IAChC;CAGH,IAAI,QAAQ,QACX,OAAO;EACN,OAAO;EACP,QAAQ;EACR,YAAY;GACX,MAAM;GACN,QAAQ,CACP;IACC,IAAI;IACJ,aACC;IACD,SAAS,CACR,4FACA,gDACD;GACD,CACD;GACA,YAAY;IACX,MAAM;IACN,MAAM;KACL;KACA;KACA,GAAI,QAAQ,QAAQ,CAAC,WAAW,QAAQ,KAAK,IAAI,CAAC;KAClD,GAAI,QAAQ,SAAS,CAAC,UAAU,IAAI,CAAC,WAAW;IACjD;GACD;EACD;CACD;CAID,IAAI,QAAQ,WAAW,QAAQ,QAE9B,OAAO;EACN,OAAO;EACP,QAAQ;EACR,YAAY;GACX,MAAM;GACN,SAAS,6EANqF,YAAY;GAO1G,aAAa,oCAAoC,YAAY;GAC7D,SAAS;GACT,WAAW;IACV,MAAM;IACN,MAAM;GACP;GACA,WAAW,EACV,OAAO;IACN,MAAM;IACN,MAAM;GACP,EACD;EACD;EACA,iBAAiB;CAClB;CAID,OAAO;EACN,OAAO;EACP,QAAQ;EACR,YAAY;GACX,MAAM;GACN,UACC;GACD,SAAS,CACR;IAAE,OAAO;IAAO,OAAO;GAAsB,GAC7C;IAAE,OAAO;IAAQ,OAAO;GAAe,CACxC;GACA,SACC;GACD,iBAAiB;IAChB,KAAK,EACJ,MAAM;KACL;KACA;KACA,GAAI,QAAQ,QAAQ,CAAC,WAAW,QAAQ,KAAK,IAAI,CAAC;KAClD;IACD,EACD;IACA,MAAM,EAAE,MAAM,UAAU;GACzB;EACD;CACD;AACD"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { StatusResponse } from "../types.js";
|
|
2
|
+
|
|
3
|
+
//#region src/lib/phases/status.d.ts
|
|
4
|
+
interface StatusOptions {
|
|
5
|
+
agent?: string;
|
|
6
|
+
}
|
|
7
|
+
declare function handleStatusPhase(options: StatusOptions): Promise<StatusResponse>;
|
|
8
|
+
//#endregion
|
|
9
|
+
export { StatusOptions, handleStatusPhase };
|
|
10
|
+
//# sourceMappingURL=status.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"status.d.ts","names":[],"sources":["../../../src/lib/phases/status.ts"],"mappings":";;;UAIiB,aAAA;;AAAjB;AAIsB,iBAAA,iBAAA,CAAiB,OAAA,EAC7B,aAD6B,CAAA,EAEpC,OAFoC,CAE5B,cAF4B,CAAA"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { isAuthenticated } from "../auth.js";
|
|
2
|
+
import { inspectProject } from "../inspect.js";
|
|
3
|
+
//#region src/lib/phases/status.ts
|
|
4
|
+
async function handleStatusPhase(options) {
|
|
5
|
+
const authed = await isAuthenticated();
|
|
6
|
+
const inspection = await inspectProject([
|
|
7
|
+
{
|
|
8
|
+
id: "database_url",
|
|
9
|
+
description: "",
|
|
10
|
+
lookFor: []
|
|
11
|
+
},
|
|
12
|
+
{
|
|
13
|
+
id: "skills",
|
|
14
|
+
description: "",
|
|
15
|
+
lookFor: []
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
id: "migrations",
|
|
19
|
+
description: "",
|
|
20
|
+
lookFor: []
|
|
21
|
+
}
|
|
22
|
+
]);
|
|
23
|
+
const hasDatabaseUrl = inspection.databaseUrl === true;
|
|
24
|
+
const skillsInstalled = inspection.skillsInstalled === true;
|
|
25
|
+
const migrationTool = inspection.migrationTool ?? null;
|
|
26
|
+
const hasMigrations = migrationTool !== null && migrationTool !== "none" && inspection.migrationDir !== "none";
|
|
27
|
+
const recommendations = [];
|
|
28
|
+
if (!authed) recommendations.push({
|
|
29
|
+
priority: "high",
|
|
30
|
+
message: "Not authenticated with Neon",
|
|
31
|
+
command: "neon-init auth --json"
|
|
32
|
+
});
|
|
33
|
+
if (!hasDatabaseUrl) recommendations.push({
|
|
34
|
+
priority: "high",
|
|
35
|
+
message: "No DATABASE_URL found in .env",
|
|
36
|
+
command: "neon-init db --json"
|
|
37
|
+
});
|
|
38
|
+
if (!skillsInstalled) recommendations.push({
|
|
39
|
+
priority: "medium",
|
|
40
|
+
message: "Neon agent skills not detected in this project",
|
|
41
|
+
command: options.agent ? `neon-init skills --json --agent ${options.agent} --install` : "neon-init skills --json --install"
|
|
42
|
+
});
|
|
43
|
+
if (migrationTool && !hasMigrations) recommendations.push({
|
|
44
|
+
priority: "medium",
|
|
45
|
+
message: `${migrationTool} detected but no migrations found`,
|
|
46
|
+
command: "neon-init migrations --json"
|
|
47
|
+
});
|
|
48
|
+
return {
|
|
49
|
+
auth: { authenticated: authed },
|
|
50
|
+
tooling: {
|
|
51
|
+
mcpServer: { configured: null },
|
|
52
|
+
skills: { installed: skillsInstalled }
|
|
53
|
+
},
|
|
54
|
+
project: { databaseUrl: hasDatabaseUrl },
|
|
55
|
+
migrations: {
|
|
56
|
+
tool: migrationTool,
|
|
57
|
+
hasMigrations
|
|
58
|
+
},
|
|
59
|
+
recommendations
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
//#endregion
|
|
63
|
+
export { handleStatusPhase };
|
|
64
|
+
|
|
65
|
+
//# sourceMappingURL=status.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"status.js","names":[],"sources":["../../../src/lib/phases/status.ts"],"sourcesContent":["import { isAuthenticated } from \"../auth.js\";\nimport { inspectProject } from \"../inspect.js\";\nimport type { StatusResponse } from \"../types.js\";\n\nexport interface StatusOptions {\n\tagent?: string;\n}\n\nexport async function handleStatusPhase(\n\toptions: StatusOptions,\n): Promise<StatusResponse> {\n\tconst authed = await isAuthenticated();\n\n\tconst inspection = await inspectProject([\n\t\t{ id: \"database_url\", description: \"\", lookFor: [] },\n\t\t{ id: \"skills\", description: \"\", lookFor: [] },\n\t\t{ id: \"migrations\", description: \"\", lookFor: [] },\n\t]);\n\n\tconst hasDatabaseUrl = inspection.databaseUrl === true;\n\tconst skillsInstalled = inspection.skillsInstalled === true;\n\tconst migrationTool = (inspection.migrationTool as string | null) ?? null;\n\tconst hasMigrations =\n\t\tmigrationTool !== null &&\n\t\tmigrationTool !== \"none\" &&\n\t\tinspection.migrationDir !== \"none\";\n\n\tconst recommendations: StatusResponse[\"recommendations\"] = [];\n\n\tif (!authed) {\n\t\trecommendations.push({\n\t\t\tpriority: \"high\",\n\t\t\tmessage: \"Not authenticated with Neon\",\n\t\t\tcommand: \"neon-init auth --json\",\n\t\t});\n\t}\n\n\tif (!hasDatabaseUrl) {\n\t\trecommendations.push({\n\t\t\tpriority: \"high\",\n\t\t\tmessage: \"No DATABASE_URL found in .env\",\n\t\t\tcommand: \"neon-init db --json\",\n\t\t});\n\t}\n\n\tif (!skillsInstalled) {\n\t\trecommendations.push({\n\t\t\tpriority: \"medium\",\n\t\t\tmessage: \"Neon agent skills not detected in this project\",\n\t\t\tcommand: options.agent\n\t\t\t\t? `neon-init skills --json --agent ${options.agent} --install`\n\t\t\t\t: \"neon-init skills --json --install\",\n\t\t});\n\t}\n\n\tif (migrationTool && !hasMigrations) {\n\t\trecommendations.push({\n\t\t\tpriority: \"medium\",\n\t\t\tmessage: `${migrationTool} detected but no migrations found`,\n\t\t\tcommand: \"neon-init migrations --json\",\n\t\t});\n\t}\n\n\treturn {\n\t\tauth: {\n\t\t\tauthenticated: authed,\n\t\t},\n\t\ttooling: {\n\t\t\tmcpServer: { configured: null },\n\t\t\tskills: { installed: skillsInstalled },\n\t\t},\n\t\tproject: {\n\t\t\tdatabaseUrl: hasDatabaseUrl,\n\t\t},\n\t\tmigrations: {\n\t\t\ttool: migrationTool,\n\t\t\thasMigrations,\n\t\t},\n\t\trecommendations,\n\t};\n}\n"],"mappings":";;;AAQA,eAAsB,kBACrB,SAC0B;CAC1B,MAAM,SAAS,MAAM,gBAAgB;CAErC,MAAM,aAAa,MAAM,eAAe;EACvC;GAAE,IAAI;GAAgB,aAAa;GAAI,SAAS,CAAC;EAAE;EACnD;GAAE,IAAI;GAAU,aAAa;GAAI,SAAS,CAAC;EAAE;EAC7C;GAAE,IAAI;GAAc,aAAa;GAAI,SAAS,CAAC;EAAE;CAClD,CAAC;CAED,MAAM,iBAAiB,WAAW,gBAAgB;CAClD,MAAM,kBAAkB,WAAW,oBAAoB;CACvD,MAAM,gBAAiB,WAAW,iBAAmC;CACrE,MAAM,gBACL,kBAAkB,QAClB,kBAAkB,UAClB,WAAW,iBAAiB;CAE7B,MAAM,kBAAqD,CAAC;CAE5D,IAAI,CAAC,QACJ,gBAAgB,KAAK;EACpB,UAAU;EACV,SAAS;EACT,SAAS;CACV,CAAC;CAGF,IAAI,CAAC,gBACJ,gBAAgB,KAAK;EACpB,UAAU;EACV,SAAS;EACT,SAAS;CACV,CAAC;CAGF,IAAI,CAAC,iBACJ,gBAAgB,KAAK;EACpB,UAAU;EACV,SAAS;EACT,SAAS,QAAQ,QACd,mCAAmC,QAAQ,MAAM,cACjD;CACJ,CAAC;CAGF,IAAI,iBAAiB,CAAC,eACrB,gBAAgB,KAAK;EACpB,UAAU;EACV,SAAS,GAAG,cAAc;EAC1B,SAAS;CACV,CAAC;CAGF,OAAO;EACN,MAAM,EACL,eAAe,OAChB;EACA,SAAS;GACR,WAAW,EAAE,YAAY,KAAK;GAC9B,QAAQ,EAAE,WAAW,gBAAgB;EACtC;EACA,SAAS,EACR,aAAa,eACd;EACA,YAAY;GACX,MAAM;GACN;EACD;EACA;CACD;AACD"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
//#region src/lib/resolve-context.d.ts
|
|
2
|
+
interface NeonContext {
|
|
3
|
+
orgId: string;
|
|
4
|
+
projectId: string;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Resolves the Neon org and project that own the endpoint in DATABASE_URL.
|
|
8
|
+
*
|
|
9
|
+
* Strategy:
|
|
10
|
+
* 1. Extract endpoint hostname from .env
|
|
11
|
+
* 2. List orgs via neonctl
|
|
12
|
+
* 3. For each org, list projects
|
|
13
|
+
* 4. For each project, get connection string and compare hostnames
|
|
14
|
+
* 5. Return the matching org/project
|
|
15
|
+
*/
|
|
16
|
+
declare function resolveNeonContext(cwd: string): Promise<NeonContext | null>;
|
|
17
|
+
//#endregion
|
|
18
|
+
export { resolveNeonContext };
|
|
19
|
+
//# sourceMappingURL=resolve-context.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolve-context.d.ts","names":[],"sources":["../../src/lib/resolve-context.ts"],"mappings":";UASU,WAAA;EAAA,KAAA,EAAA,MAAA;EAwCY,SAAA,EAAA,MAAA;;;;AAEZ;;;;;;;;iBAFY,kBAAA,eAEnB,QAAQ"}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
2
|
+
import { resolve } from "node:path";
|
|
3
|
+
import { execa } from "execa";
|
|
4
|
+
//#region src/lib/resolve-context.ts
|
|
5
|
+
/**
|
|
6
|
+
* Resolves the Neon org/project from a DATABASE_URL in .env.
|
|
7
|
+
* Parses the endpoint hostname, then queries the Neon API to find
|
|
8
|
+
* which project it belongs to.
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* Extracts the Neon endpoint host from .env's DATABASE_URL or PGHOST.
|
|
12
|
+
* Returns the hostname (e.g. "ep-cool-name-12345.us-east-2.aws.neon.tech") or null.
|
|
13
|
+
*/
|
|
14
|
+
function extractNeonHost(cwd) {
|
|
15
|
+
for (const envFile of [".env", ".env.local"]) {
|
|
16
|
+
const envPath = resolve(cwd, envFile);
|
|
17
|
+
if (!existsSync(envPath)) continue;
|
|
18
|
+
try {
|
|
19
|
+
const content = readFileSync(envPath, "utf-8");
|
|
20
|
+
const dbUrlMatch = content.match(/^DATABASE_URL=.*@([^/:\s]+\.neon\.tech)/m);
|
|
21
|
+
if (dbUrlMatch) return dbUrlMatch[1];
|
|
22
|
+
const pgHostMatch = content.match(/^PGHOST=([^\s]+\.neon\.tech)/m);
|
|
23
|
+
if (pgHostMatch) return pgHostMatch[1];
|
|
24
|
+
} catch {}
|
|
25
|
+
}
|
|
26
|
+
return null;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Resolves the Neon org and project that own the endpoint in DATABASE_URL.
|
|
30
|
+
*
|
|
31
|
+
* Strategy:
|
|
32
|
+
* 1. Extract endpoint hostname from .env
|
|
33
|
+
* 2. List orgs via neonctl
|
|
34
|
+
* 3. For each org, list projects
|
|
35
|
+
* 4. For each project, get connection string and compare hostnames
|
|
36
|
+
* 5. Return the matching org/project
|
|
37
|
+
*/
|
|
38
|
+
async function resolveNeonContext(cwd) {
|
|
39
|
+
const neonHost = extractNeonHost(cwd);
|
|
40
|
+
if (!neonHost) return null;
|
|
41
|
+
let orgs;
|
|
42
|
+
try {
|
|
43
|
+
const result = await execa("npx", [
|
|
44
|
+
"-y",
|
|
45
|
+
"neonctl",
|
|
46
|
+
"orgs",
|
|
47
|
+
"list",
|
|
48
|
+
"--output",
|
|
49
|
+
"json"
|
|
50
|
+
], {
|
|
51
|
+
stdio: "pipe",
|
|
52
|
+
timeout: 3e4,
|
|
53
|
+
env: {
|
|
54
|
+
...process.env,
|
|
55
|
+
CI: void 0
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
orgs = JSON.parse(result.stdout);
|
|
59
|
+
} catch {
|
|
60
|
+
return null;
|
|
61
|
+
}
|
|
62
|
+
if (orgs.length === 0) return null;
|
|
63
|
+
for (const org of orgs) {
|
|
64
|
+
let projects;
|
|
65
|
+
try {
|
|
66
|
+
const result = await execa("npx", [
|
|
67
|
+
"-y",
|
|
68
|
+
"neonctl",
|
|
69
|
+
"projects",
|
|
70
|
+
"list",
|
|
71
|
+
"--org-id",
|
|
72
|
+
org.id,
|
|
73
|
+
"--output",
|
|
74
|
+
"json"
|
|
75
|
+
], {
|
|
76
|
+
stdio: "pipe",
|
|
77
|
+
timeout: 3e4,
|
|
78
|
+
env: {
|
|
79
|
+
...process.env,
|
|
80
|
+
CI: void 0
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
projects = JSON.parse(result.stdout);
|
|
84
|
+
} catch {
|
|
85
|
+
continue;
|
|
86
|
+
}
|
|
87
|
+
for (const project of projects) try {
|
|
88
|
+
if ((await execa("npx", [
|
|
89
|
+
"-y",
|
|
90
|
+
"neonctl",
|
|
91
|
+
"connection-string",
|
|
92
|
+
"--project-id",
|
|
93
|
+
project.id
|
|
94
|
+
], {
|
|
95
|
+
stdio: "pipe",
|
|
96
|
+
timeout: 15e3,
|
|
97
|
+
env: {
|
|
98
|
+
...process.env,
|
|
99
|
+
CI: void 0
|
|
100
|
+
}
|
|
101
|
+
})).stdout.trim().includes(neonHost)) return {
|
|
102
|
+
orgId: org.id,
|
|
103
|
+
projectId: project.id
|
|
104
|
+
};
|
|
105
|
+
} catch {}
|
|
106
|
+
}
|
|
107
|
+
return null;
|
|
108
|
+
}
|
|
109
|
+
//#endregion
|
|
110
|
+
export { resolveNeonContext };
|
|
111
|
+
|
|
112
|
+
//# sourceMappingURL=resolve-context.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolve-context.js","names":[],"sources":["../../src/lib/resolve-context.ts"],"sourcesContent":["/**\n * Resolves the Neon org/project from a DATABASE_URL in .env.\n * Parses the endpoint hostname, then queries the Neon API to find\n * which project it belongs to.\n */\nimport { existsSync, readFileSync } from \"node:fs\";\nimport { resolve } from \"node:path\";\nimport { execa } from \"execa\";\n\ninterface NeonContext {\n\torgId: string;\n\tprojectId: string;\n}\n\n/**\n * Extracts the Neon endpoint host from .env's DATABASE_URL or PGHOST.\n * Returns the hostname (e.g. \"ep-cool-name-12345.us-east-2.aws.neon.tech\") or null.\n */\nfunction extractNeonHost(cwd: string): string | null {\n\tfor (const envFile of [\".env\", \".env.local\"]) {\n\t\tconst envPath = resolve(cwd, envFile);\n\t\tif (!existsSync(envPath)) continue;\n\t\ttry {\n\t\t\tconst content = readFileSync(envPath, \"utf-8\");\n\n\t\t\t// Try DATABASE_URL\n\t\t\tconst dbUrlMatch = content.match(\n\t\t\t\t/^DATABASE_URL=.*@([^/:\\s]+\\.neon\\.tech)/m,\n\t\t\t);\n\t\t\tif (dbUrlMatch) return dbUrlMatch[1];\n\n\t\t\t// Try PGHOST\n\t\t\tconst pgHostMatch = content.match(/^PGHOST=([^\\s]+\\.neon\\.tech)/m);\n\t\t\tif (pgHostMatch) return pgHostMatch[1];\n\t\t} catch {}\n\t}\n\treturn null;\n}\n\n/**\n * Resolves the Neon org and project that own the endpoint in DATABASE_URL.\n *\n * Strategy:\n * 1. Extract endpoint hostname from .env\n * 2. List orgs via neonctl\n * 3. For each org, list projects\n * 4. For each project, get connection string and compare hostnames\n * 5. Return the matching org/project\n */\nexport async function resolveNeonContext(\n\tcwd: string,\n): Promise<NeonContext | null> {\n\tconst neonHost = extractNeonHost(cwd);\n\tif (!neonHost) return null;\n\n\t// List orgs\n\tlet orgs: { id: string; name: string }[];\n\ttry {\n\t\tconst result = await execa(\n\t\t\t\"npx\",\n\t\t\t[\"-y\", \"neonctl\", \"orgs\", \"list\", \"--output\", \"json\"],\n\t\t\t{\n\t\t\t\tstdio: \"pipe\",\n\t\t\t\ttimeout: 30000,\n\t\t\t\tenv: { ...process.env, CI: undefined },\n\t\t\t},\n\t\t);\n\t\torgs = JSON.parse(result.stdout);\n\t} catch {\n\t\treturn null;\n\t}\n\n\tif (orgs.length === 0) return null;\n\n\t// Search each org's projects for a matching endpoint\n\tfor (const org of orgs) {\n\t\tlet projects: { id: string; name: string }[];\n\t\ttry {\n\t\t\tconst result = await execa(\n\t\t\t\t\"npx\",\n\t\t\t\t[\n\t\t\t\t\t\"-y\",\n\t\t\t\t\t\"neonctl\",\n\t\t\t\t\t\"projects\",\n\t\t\t\t\t\"list\",\n\t\t\t\t\t\"--org-id\",\n\t\t\t\t\torg.id,\n\t\t\t\t\t\"--output\",\n\t\t\t\t\t\"json\",\n\t\t\t\t],\n\t\t\t\t{\n\t\t\t\t\tstdio: \"pipe\",\n\t\t\t\t\ttimeout: 30000,\n\t\t\t\t\tenv: { ...process.env, CI: undefined },\n\t\t\t\t},\n\t\t\t);\n\t\t\tprojects = JSON.parse(result.stdout);\n\t\t} catch {\n\t\t\tcontinue;\n\t\t}\n\n\t\tfor (const project of projects) {\n\t\t\ttry {\n\t\t\t\tconst result = await execa(\n\t\t\t\t\t\"npx\",\n\t\t\t\t\t[\n\t\t\t\t\t\t\"-y\",\n\t\t\t\t\t\t\"neonctl\",\n\t\t\t\t\t\t\"connection-string\",\n\t\t\t\t\t\t\"--project-id\",\n\t\t\t\t\t\tproject.id,\n\t\t\t\t\t],\n\t\t\t\t\t{\n\t\t\t\t\t\tstdio: \"pipe\",\n\t\t\t\t\t\ttimeout: 15000,\n\t\t\t\t\t\tenv: { ...process.env, CI: undefined },\n\t\t\t\t\t},\n\t\t\t\t);\n\t\t\t\tconst connStr = result.stdout.trim();\n\t\t\t\tif (connStr.includes(neonHost)) {\n\t\t\t\t\treturn { orgId: org.id, projectId: project.id };\n\t\t\t\t}\n\t\t\t} catch {}\n\t\t}\n\t}\n\n\treturn null;\n}\n"],"mappings":";;;;;;;;;;;;;AAkBA,SAAS,gBAAgB,KAA4B;CACpD,KAAK,MAAM,WAAW,CAAC,QAAQ,YAAY,GAAG;EAC7C,MAAM,UAAU,QAAQ,KAAK,OAAO;EACpC,IAAI,CAAC,WAAW,OAAO,GAAG;EAC1B,IAAI;GACH,MAAM,UAAU,aAAa,SAAS,OAAO;GAG7C,MAAM,aAAa,QAAQ,MAC1B,0CACD;GACA,IAAI,YAAY,OAAO,WAAW;GAGlC,MAAM,cAAc,QAAQ,MAAM,+BAA+B;GACjE,IAAI,aAAa,OAAO,YAAY;EACrC,QAAQ,CAAC;CACV;CACA,OAAO;AACR;;;;;;;;;;;AAYA,eAAsB,mBACrB,KAC8B;CAC9B,MAAM,WAAW,gBAAgB,GAAG;CACpC,IAAI,CAAC,UAAU,OAAO;CAGtB,IAAI;CACJ,IAAI;EACH,MAAM,SAAS,MAAM,MACpB,OACA;GAAC;GAAM;GAAW;GAAQ;GAAQ;GAAY;EAAM,GACpD;GACC,OAAO;GACP,SAAS;GACT,KAAK;IAAE,GAAG,QAAQ;IAAK,IAAI,KAAA;GAAU;EACtC,CACD;EACA,OAAO,KAAK,MAAM,OAAO,MAAM;CAChC,QAAQ;EACP,OAAO;CACR;CAEA,IAAI,KAAK,WAAW,GAAG,OAAO;CAG9B,KAAK,MAAM,OAAO,MAAM;EACvB,IAAI;EACJ,IAAI;GACH,MAAM,SAAS,MAAM,MACpB,OACA;IACC;IACA;IACA;IACA;IACA;IACA,IAAI;IACJ;IACA;GACD,GACA;IACC,OAAO;IACP,SAAS;IACT,KAAK;KAAE,GAAG,QAAQ;KAAK,IAAI,KAAA;IAAU;GACtC,CACD;GACA,WAAW,KAAK,MAAM,OAAO,MAAM;EACpC,QAAQ;GACP;EACD;EAEA,KAAK,MAAM,WAAW,UACrB,IAAI;GAiBH,KADgB,MAfK,MACpB,OACA;IACC;IACA;IACA;IACA;IACA,QAAQ;GACT,GACA;IACC,OAAO;IACP,SAAS;IACT,KAAK;KAAE,GAAG,QAAQ;KAAK,IAAI,KAAA;IAAU;GACtC,CACD,EAAA,CACuB,OAAO,KACpB,CAAC,CAAC,SAAS,QAAQ,GAC5B,OAAO;IAAE,OAAO,IAAI;IAAI,WAAW,QAAQ;GAAG;EAEhD,QAAQ,CAAC;CAEX;CAEA,OAAO;AACR"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"route-command.d.ts","names":[],"sources":["../../src/lib/route-command.ts"],"mappings":";;;;AAuEoD,iBAA9B,YAAA,CAA8B,IAAA,EAAA,MAAA,EAAA,CAAA,EAAA,OAAA,CAAQ,aAAR,CAAA"}
|