neon 4.6.0 → 4.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (57) hide show
  1. package/README.md +48 -113
  2. package/dist/_chunks/{auth_selection-ktL6uoEe.js → auth_selection-pitMFzDe.js} +1 -1
  3. package/dist/_chunks/{credential_io-B1JxWELN.js → credential_io-YeAxg9Xn.js} +2 -2
  4. package/dist/_chunks/{paths-g3DRqJiD.js → paths-DMq0Lt7a.js} +1 -1
  5. package/dist/_chunks/{profiles-D95AeZ5v.js → profiles-CvnFEQyd.js} +1 -1
  6. package/dist/analytics.js +2 -2
  7. package/dist/auth_context.js +1 -1
  8. package/dist/commands/auth.js +12 -9
  9. package/dist/commands/bootstrap.js +72 -43
  10. package/dist/commands/claim.js +1 -1
  11. package/dist/commands/env.js +3 -20
  12. package/dist/commands/init.js +80 -79
  13. package/dist/commands/link.js +110 -292
  14. package/dist/commands/mcp.js +2 -2
  15. package/dist/commands/plugins.js +3 -3
  16. package/dist/commands/profile.js +4 -4
  17. package/dist/config.js +1 -1
  18. package/dist/credential_io.js +1 -1
  19. package/dist/index.js +1 -1
  20. package/dist/init/child.js +36 -0
  21. package/dist/init/plan.js +47 -0
  22. package/dist/init/tooling.js +43 -0
  23. package/dist/init/wizard.js +42 -0
  24. package/dist/mcp/targets.js +1 -1
  25. package/dist/plugins/plan.js +1 -1
  26. package/dist/plugins/targets.js +5 -1
  27. package/dist/retire_credential.js +1 -1
  28. package/dist/utils/cli_name.js +1 -12
  29. package/dist/utils/middlewares.js +1 -1
  30. package/dist/utils/package_manager.js +10 -5
  31. package/package.json +13 -14
  32. package/dist/init/auth.js +0 -53
  33. package/dist/init/build_config.js +0 -4
  34. package/dist/init/detect_agent.js +0 -63
  35. package/dist/init/editors.js +0 -19
  36. package/dist/init/enrich_output.js +0 -61
  37. package/dist/init/extension.js +0 -154
  38. package/dist/init/inspect.js +0 -249
  39. package/dist/init/interactive.js +0 -529
  40. package/dist/init/neonctl.js +0 -139
  41. package/dist/init/orchestrate.js +0 -189
  42. package/dist/init/phases/auth.js +0 -195
  43. package/dist/init/phases/cleanup.js +0 -27
  44. package/dist/init/phases/db.js +0 -257
  45. package/dist/init/phases/getting_started.js +0 -218
  46. package/dist/init/phases/mcp.js +0 -219
  47. package/dist/init/phases/migrations.js +0 -250
  48. package/dist/init/phases/neon_auth.js +0 -116
  49. package/dist/init/phases/setup.js +0 -582
  50. package/dist/init/phases/skills.js +0 -86
  51. package/dist/init/phases/status.js +0 -82
  52. package/dist/init/profile_cli.js +0 -56
  53. package/dist/init/resolve_context.js +0 -105
  54. package/dist/init/route_command.js +0 -93
  55. package/dist/init/skills.js +0 -206
  56. package/dist/init/types.js +0 -1
  57. package/dist/init/vsix.js +0 -89
@@ -1,154 +0,0 @@
1
- import { NEON_EXTENSION_ID, downloadVsix } from "./vsix.js";
2
- import { existsSync } from "node:fs";
3
- import { unlink } from "node:fs/promises";
4
- import { execa } from "execa";
5
- //#region src/init/extension.ts
6
- /**
7
- * Uses macOS mdfind to locate an app by bundle identifier
8
- */
9
- async function findAppWithMdfind(bundleId) {
10
- try {
11
- return (await execa("mdfind", [`kMDItemCFBundleIdentifier == '${bundleId}'`], { timeout: 5e3 })).stdout.trim().split("\n").filter(Boolean)[0] || null;
12
- } catch {
13
- return null;
14
- }
15
- }
16
- /**
17
- * Known installation paths for VS Code CLI
18
- */
19
- function getVSCodePaths() {
20
- const platform = process.platform;
21
- const home = process.env.HOME || "";
22
- if (platform === "darwin") return [
23
- "/Applications/Visual Studio Code.app/Contents/Resources/app/bin/code",
24
- "/Applications/Visual Studio Code - Insiders.app/Contents/Resources/app/bin/code-insiders",
25
- `${home}/Applications/Visual Studio Code.app/Contents/Resources/app/bin/code`,
26
- `${home}/Downloads/Visual Studio Code.app/Contents/Resources/app/bin/code`
27
- ];
28
- if (platform === "linux") return [
29
- "/usr/share/code/bin/code",
30
- "/usr/bin/code",
31
- "/snap/bin/code",
32
- "/usr/share/code-insiders/bin/code-insiders"
33
- ];
34
- if (platform === "win32") {
35
- const localAppData = process.env.LOCALAPPDATA || "";
36
- const programFiles = process.env.PROGRAMFILES || "C:\\Program Files";
37
- return [
38
- `${localAppData}\\Programs\\Microsoft VS Code\\bin\\code.cmd`,
39
- `${programFiles}\\Microsoft VS Code\\bin\\code.cmd`,
40
- `${localAppData}\\Programs\\Microsoft VS Code Insiders\\bin\\code-insiders.cmd`
41
- ];
42
- }
43
- return [];
44
- }
45
- /**
46
- * Known installation paths for Cursor CLI
47
- */
48
- function getCursorPaths() {
49
- const platform = process.platform;
50
- const home = process.env.HOME || "";
51
- if (platform === "darwin") return [
52
- "/Applications/Cursor.app/Contents/Resources/app/bin/cursor",
53
- `${home}/Applications/Cursor.app/Contents/Resources/app/bin/cursor`,
54
- `${home}/Downloads/Cursor.app/Contents/Resources/app/bin/cursor`
55
- ];
56
- if (platform === "linux") return [
57
- "/usr/share/cursor/bin/cursor",
58
- "/usr/bin/cursor",
59
- `${home}/.local/bin/cursor`,
60
- "/opt/cursor/bin/cursor"
61
- ];
62
- if (platform === "win32") {
63
- const localAppData = process.env.LOCALAPPDATA || "";
64
- const programFiles = process.env.PROGRAMFILES || "C:\\Program Files";
65
- return [
66
- `${localAppData}\\Programs\\Cursor\\resources\\app\\bin\\cursor.cmd`,
67
- `${localAppData}\\cursor\\Cursor.exe`,
68
- `${programFiles}\\Cursor\\resources\\app\\bin\\cursor.cmd`
69
- ];
70
- }
71
- return [];
72
- }
73
- /**
74
- * Finds the CLI command for an editor by checking known installation paths
75
- * On macOS, also uses mdfind to locate the app if standard paths fail
76
- * Falls back to the simple command name if no full path is found (in case it's in PATH)
77
- */
78
- async function findEditorCommand(editor) {
79
- let paths;
80
- let fallbackCommand;
81
- let bundleId = null;
82
- if (editor === "VS Code") {
83
- paths = getVSCodePaths();
84
- fallbackCommand = "code";
85
- bundleId = "com.microsoft.VSCode";
86
- } else if (editor === "Cursor") {
87
- paths = getCursorPaths();
88
- fallbackCommand = "cursor";
89
- bundleId = "com.todesktop.230313mzl4w4u92";
90
- } else return null;
91
- for (const path of paths) if (existsSync(path)) return path;
92
- if (process.platform === "darwin" && bundleId) {
93
- const appPath = await findAppWithMdfind(bundleId);
94
- if (appPath) {
95
- const cliPath = `${appPath}/Contents/Resources/app/bin/${fallbackCommand}`;
96
- if (existsSync(cliPath)) return cliPath;
97
- }
98
- }
99
- return fallbackCommand;
100
- }
101
- /**
102
- * Checks if the extension is installed by querying the editor's extension list
103
- */
104
- async function isExtensionInstalled(editor) {
105
- const command = await findEditorCommand(editor);
106
- if (!command) return false;
107
- try {
108
- return (await execa(command, ["--list-extensions"], { timeout: 5e3 })).stdout.includes(NEON_EXTENSION_ID);
109
- } catch {
110
- return false;
111
- }
112
- }
113
- /**
114
- * Installs the Neon Local Connect extension for VS Code or Cursor.
115
- *
116
- * Strategy:
117
- * 1. Try `--install-extension <id>` directly (uses the editor's configured marketplace)
118
- * 2. If that fails, download .vsix (from proxy or Open VSX) and install locally
119
- * 3. Set NEON_VSX_GALLERY_URL to use a corporate proxy for the download
120
- */
121
- async function installExtension(editor) {
122
- const command = await findEditorCommand(editor);
123
- if (!command) return false;
124
- try {
125
- await execa(command, ["--install-extension", NEON_EXTENSION_ID], {
126
- stdio: "pipe",
127
- timeout: 6e4
128
- });
129
- return true;
130
- } catch {}
131
- const vsixPath = await downloadVsix();
132
- if (!vsixPath) return false;
133
- try {
134
- await execa(command, ["--install-extension", vsixPath], {
135
- stdio: "pipe",
136
- timeout: 6e4
137
- });
138
- return true;
139
- } catch {
140
- return false;
141
- } finally {
142
- try {
143
- await unlink(vsixPath);
144
- } catch {}
145
- }
146
- }
147
- /**
148
- * Returns the editor types that should use extension installation (vs MCP)
149
- */
150
- function usesExtension(editor) {
151
- return editor === "VS Code" || editor === "Cursor";
152
- }
153
- //#endregion
154
- export { findEditorCommand, installExtension, isExtensionInstalled, usesExtension };
@@ -1,249 +0,0 @@
1
- import { existsSync, readFileSync } from "node:fs";
2
- import { resolve, sep } from "node:path";
3
- import { homedir } from "node:os";
4
- import { agents, getAgentTypes } from "add-mcp";
5
- //#region src/init/inspect.ts
6
- /**
7
- * Filesystem-based project inspection for interactive (agentless) mode.
8
- * Replaces the "agent_check" pattern — instead of asking an agent to look,
9
- * we examine the filesystem directly.
10
- */
11
- /**
12
- * Runs filesystem checks based on the agent_check descriptors.
13
- * Maps check IDs to concrete inspection functions.
14
- */
15
- async function inspectProject(checks) {
16
- const results = {};
17
- const cwd = process.cwd();
18
- for (const check of checks) switch (check.id) {
19
- case "mcp_server": {
20
- const hits = findNeonMcpAgents(cwd);
21
- results.mcpAgents = hits;
22
- results.mcpConfigured = hits.length > 0;
23
- results.mcpScope = mcpScopeFromHits(hits);
24
- break;
25
- }
26
- case "connection_string":
27
- results.connectionString = checkConnectionString(cwd);
28
- break;
29
- case "database_url":
30
- results.databaseUrl = checkDatabaseUrl(cwd);
31
- break;
32
- case "project_stack": {
33
- const stack = detectProjectStack(cwd);
34
- results.framework = stack.framework;
35
- results.orm = stack.orm;
36
- break;
37
- }
38
- case "migrations": {
39
- const migrations = detectMigrations(cwd);
40
- results.migrationTool = migrations.tool;
41
- results.migrationDir = migrations.dir;
42
- break;
43
- }
44
- case "skills": {
45
- const skillsScope = checkSkillsInstalled(cwd);
46
- results.skillsInstalled = skillsScope !== false;
47
- results.skillsScope = skillsScope;
48
- break;
49
- }
50
- case "ide_type":
51
- results.isVscodeIde = checkVscodeIde();
52
- break;
53
- case "has_app": results.hasApp = checkHasApp(cwd);
54
- }
55
- return results;
56
- }
57
- function mcpScopeFromHits(hits) {
58
- if (hits.some((hit) => hit.scope === "project")) return "project";
59
- if (hits.some((hit) => hit.scope === "global")) return "global";
60
- return false;
61
- }
62
- function addMcpBakedHome() {
63
- const cursorPath = agents.cursor.configPath;
64
- const suffix = `${sep}.cursor${sep}mcp.json`;
65
- if (cursorPath.endsWith(suffix)) return cursorPath.slice(0, -suffix.length);
66
- return homedir();
67
- }
68
- function rebaseAddMcpHome(configPath) {
69
- const currentHome = process.env.HOME || process.env.USERPROFILE || homedir();
70
- const baked = addMcpBakedHome();
71
- if (configPath.startsWith(baked)) return currentHome + configPath.slice(baked.length);
72
- return configPath;
73
- }
74
- function agentProjectPath(id, cwd) {
75
- const agent = agents[id];
76
- if (agent.resolveConfigPath && agent.localConfigPath) return agent.resolveConfigPath(agent, {
77
- local: true,
78
- cwd
79
- });
80
- if (agent.localConfigPath) return resolve(cwd, agent.localConfigPath);
81
- }
82
- function agentGlobalPath(id, cwd) {
83
- const agent = agents[id];
84
- if (agent.resolveConfigPath) return rebaseAddMcpHome(agent.resolveConfigPath(agent, {
85
- local: false,
86
- cwd
87
- }));
88
- return rebaseAddMcpHome(agent.configPath);
89
- }
90
- function fileHasNeonMcp(configPath) {
91
- if (!existsSync(configPath)) return false;
92
- try {
93
- const content = readFileSync(configPath, "utf-8");
94
- if (content.toLowerCase().includes("mcp.neon.tech")) return true;
95
- if (/"neon"\s*:/i.test(content)) return true;
96
- if (/\[mcp_servers\.neon\]/i.test(content)) return true;
97
- if (/^neon\s*=/im.test(content)) return true;
98
- return false;
99
- } catch {
100
- return false;
101
- }
102
- }
103
- function findNeonMcpAgents(cwd) {
104
- const hits = [];
105
- for (const id of getAgentTypes()) {
106
- const projectPath = agentProjectPath(id, cwd);
107
- if (projectPath && fileHasNeonMcp(projectPath)) {
108
- hits.push({
109
- agent: id,
110
- scope: "project"
111
- });
112
- continue;
113
- }
114
- if (fileHasNeonMcp(agentGlobalPath(id, cwd))) hits.push({
115
- agent: id,
116
- scope: "global"
117
- });
118
- }
119
- return hits;
120
- }
121
- function checkConnectionString(cwd) {
122
- for (const envFile of [".env", ".env.local"]) {
123
- const envPath = resolve(cwd, envFile);
124
- if (existsSync(envPath)) try {
125
- const content = readFileSync(envPath, "utf-8");
126
- if (/^DATABASE_URL=.*neon/m.test(content) || /^PGHOST=.*neon/m.test(content)) return true;
127
- } catch {}
128
- }
129
- return false;
130
- }
131
- function detectProjectStack(cwd) {
132
- const result = {
133
- framework: "none",
134
- orm: "none"
135
- };
136
- const pkgPath = resolve(cwd, "package.json");
137
- if (!existsSync(pkgPath)) return result;
138
- try {
139
- const pkg = JSON.parse(readFileSync(pkgPath, "utf-8"));
140
- const allDeps = {
141
- ...pkg.dependencies,
142
- ...pkg.devDependencies
143
- };
144
- if (allDeps.next) result.framework = "next";
145
- else if (allDeps.remix || allDeps["@remix-run/node"]) result.framework = "remix";
146
- else if (allDeps.express) result.framework = "express";
147
- else if (allDeps.hono) result.framework = "hono";
148
- else if (allDeps.fastify) result.framework = "fastify";
149
- else if (allDeps["@sveltejs/kit"]) result.framework = "sveltekit";
150
- else if (allDeps.nuxt) result.framework = "nuxt";
151
- else if (allDeps.astro) result.framework = "astro";
152
- if (allDeps.prisma || allDeps["@prisma/client"]) result.orm = "prisma";
153
- else if (allDeps["drizzle-orm"]) result.orm = "drizzle";
154
- else if (allDeps.knex) result.orm = "knex";
155
- else if (allDeps.typeorm) result.orm = "typeorm";
156
- else if (allDeps.sequelize) result.orm = "sequelize";
157
- else if (allDeps["@neondatabase/serverless"]) result.orm = "neon-serverless";
158
- } catch {}
159
- return result;
160
- }
161
- function detectMigrations(cwd) {
162
- if (existsSync(resolve(cwd, "prisma", "schema.prisma"))) {
163
- const migrationsDir = resolve(cwd, "prisma", "migrations");
164
- return {
165
- tool: "prisma",
166
- dir: existsSync(migrationsDir) ? "prisma/migrations" : "none"
167
- };
168
- }
169
- if (existsSync(resolve(cwd, "drizzle.config.ts")) || existsSync(resolve(cwd, "drizzle.config.js"))) {
170
- const drizzleDir = resolve(cwd, "drizzle");
171
- return {
172
- tool: "drizzle",
173
- dir: existsSync(drizzleDir) ? "drizzle" : "none"
174
- };
175
- }
176
- if (existsSync(resolve(cwd, "knexfile.js")) || existsSync(resolve(cwd, "knexfile.ts"))) {
177
- const migrationsDir = resolve(cwd, "migrations");
178
- return {
179
- tool: "knex",
180
- dir: existsSync(migrationsDir) ? "migrations" : "none"
181
- };
182
- }
183
- return {
184
- tool: "none",
185
- dir: "none"
186
- };
187
- }
188
- function checkDatabaseUrl(cwd) {
189
- const envPath = resolve(cwd, ".env");
190
- if (existsSync(envPath)) try {
191
- const content = readFileSync(envPath, "utf-8");
192
- if (/^DATABASE_URL=/m.test(content)) return true;
193
- } catch {}
194
- return false;
195
- }
196
- function checkSkillsInstalled(cwd) {
197
- const home = process.env.HOME || process.env.USERPROFILE || "";
198
- const skillNames = ["neon", "neon-postgres"];
199
- const projectDirs = [
200
- resolve(cwd, ".cursor", "skills"),
201
- resolve(cwd, ".claude", "skills"),
202
- resolve(cwd, ".agents", "skills")
203
- ];
204
- if (skillNames.every((skill) => projectDirs.some((dir) => existsSync(resolve(dir, skill, "SKILL.md"))))) return "project";
205
- const claudeMd = resolve(cwd, "CLAUDE.md");
206
- if (existsSync(claudeMd)) try {
207
- const content = readFileSync(claudeMd, "utf-8");
208
- if (content.includes("neon-postgres") && content.includes("neon/SKILL.md")) return "project";
209
- } catch {}
210
- const globalDirs = [
211
- resolve(home, ".cursor", "skills"),
212
- resolve(home, ".claude", "skills"),
213
- resolve(home, ".agents", "skills")
214
- ];
215
- if (skillNames.every((skill) => globalDirs.some((dir) => existsSync(resolve(dir, skill, "SKILL.md"))))) return "global";
216
- if (skillNames.some((skill) => projectDirs.some((dir) => existsSync(resolve(dir, skill, "SKILL.md"))))) return "project-partial";
217
- if (skillNames.some((skill) => globalDirs.some((dir) => existsSync(resolve(dir, skill, "SKILL.md"))))) return "global-partial";
218
- return false;
219
- }
220
- function checkVscodeIde() {
221
- const env = process.env;
222
- return !!(env.TERM_PROGRAM === "vscode" || env.TERM_PROGRAM === "cursor" || env.TERM_PROGRAM === "windsurf" || env.VSCODE_PID || env.VSCODE_CWD);
223
- }
224
- /**
225
- * Detects whether the current directory contains an application.
226
- * Returns true if package.json has dependencies or common source directories exist.
227
- */
228
- function checkHasApp(cwd) {
229
- const pkgPath = resolve(cwd, "package.json");
230
- if (existsSync(pkgPath)) try {
231
- const pkg = JSON.parse(readFileSync(pkgPath, "utf-8"));
232
- const deps = Object.keys(pkg.dependencies ?? {});
233
- const devDeps = Object.keys(pkg.devDependencies ?? {});
234
- if (deps.length > 0 || devDeps.length > 0) return true;
235
- } catch {}
236
- for (const indicator of [
237
- "src",
238
- "app",
239
- "pages",
240
- "lib",
241
- "index.ts",
242
- "index.js",
243
- "main.ts",
244
- "main.js"
245
- ]) if (existsSync(resolve(cwd, indicator))) return true;
246
- return false;
247
- }
248
- //#endregion
249
- export { inspectProject };