neon 2.44.0 → 2.46.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/README.md +62 -1
- package/dist/_shared/paths.js +3 -4
- package/dist/commands/bootstrap.js +12 -11
- package/dist/commands/checkout.js +7 -6
- package/dist/commands/config.js +2 -1
- package/dist/commands/data_api.js +4 -3
- package/dist/commands/env.js +5 -4
- package/dist/commands/functions.js +3 -2
- package/dist/commands/init.js +82 -37
- package/dist/commands/ip_allow.js +3 -2
- package/dist/commands/link.js +17 -16
- package/dist/commands/projects.js +3 -2
- package/dist/commands/set_context.js +5 -4
- package/dist/current_branch_fast_path.js +2 -1
- package/dist/dev/env.js +8 -7
- package/dist/dev/runtime.js +45 -1
- package/dist/dev/websocket.js +1031 -0
- package/dist/index.js +2 -2
- package/dist/init/agents.js +127 -0
- package/dist/init/auth.js +77 -0
- package/dist/init/bootstrap.js +448 -0
- package/dist/init/build_config.js +2 -0
- package/dist/init/detect_agent.js +108 -0
- package/dist/init/editors.js +62 -0
- package/dist/init/enrich_output.js +71 -0
- package/dist/init/extension.js +191 -0
- package/dist/init/inspect.js +287 -0
- package/dist/init/interactive.js +651 -0
- package/dist/init/neonctl.js +184 -0
- package/dist/init/orchestrate.js +190 -0
- package/dist/init/phases/auth.js +209 -0
- package/dist/init/phases/cleanup.js +27 -0
- package/dist/init/phases/db.js +283 -0
- package/dist/init/phases/getting_started.js +228 -0
- package/dist/init/phases/mcp.js +227 -0
- package/dist/init/phases/migrations.js +251 -0
- package/dist/init/phases/neon_auth.js +135 -0
- package/dist/init/phases/setup.js +729 -0
- package/dist/init/phases/skills.js +89 -0
- package/dist/init/phases/status.js +70 -0
- package/dist/init/resolve_context.js +107 -0
- package/dist/init/route_command.js +100 -0
- package/dist/init/skills.js +248 -0
- package/dist/init/types.js +1 -0
- package/dist/init/vsix.js +111 -0
- package/dist/psql/command/cmd_meta.js +2 -2
- package/dist/psql/core/mainloop.js +1 -1
- package/dist/psql/core/startup.js +1 -1
- package/dist/psql/core/syncVars.js +3 -3
- package/dist/psql/index.js +1 -1
- package/dist/utils/cli_name.js +14 -0
- package/dist/utils/esbuild.js +1 -1
- package/dist/utils/write_sync.js +39 -0
- package/package.json +18 -12
|
@@ -0,0 +1,287 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Filesystem-based project inspection for interactive (agentless) mode.
|
|
3
|
+
* Replaces the "agent_check" pattern — instead of asking an agent to look,
|
|
4
|
+
* we examine the filesystem directly.
|
|
5
|
+
*/
|
|
6
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
7
|
+
import { resolve } from "node:path";
|
|
8
|
+
/**
|
|
9
|
+
* Runs filesystem checks based on the agent_check descriptors.
|
|
10
|
+
* Maps check IDs to concrete inspection functions.
|
|
11
|
+
*/
|
|
12
|
+
export async function inspectProject(checks) {
|
|
13
|
+
const results = {};
|
|
14
|
+
const cwd = process.cwd();
|
|
15
|
+
for (const check of checks) {
|
|
16
|
+
switch (check.id) {
|
|
17
|
+
case "mcp_server": {
|
|
18
|
+
const mcpScope = checkMcpServer(cwd);
|
|
19
|
+
results.mcpConfigured = mcpScope !== false;
|
|
20
|
+
results.mcpScope = mcpScope;
|
|
21
|
+
break;
|
|
22
|
+
}
|
|
23
|
+
case "connection_string":
|
|
24
|
+
results.connectionString = checkConnectionString(cwd);
|
|
25
|
+
break;
|
|
26
|
+
case "database_url":
|
|
27
|
+
results.databaseUrl = checkDatabaseUrl(cwd);
|
|
28
|
+
break;
|
|
29
|
+
case "project_stack": {
|
|
30
|
+
const stack = detectProjectStack(cwd);
|
|
31
|
+
results.framework = stack.framework;
|
|
32
|
+
results.orm = stack.orm;
|
|
33
|
+
break;
|
|
34
|
+
}
|
|
35
|
+
case "migrations": {
|
|
36
|
+
const migrations = detectMigrations(cwd);
|
|
37
|
+
results.migrationTool = migrations.tool;
|
|
38
|
+
results.migrationDir = migrations.dir;
|
|
39
|
+
break;
|
|
40
|
+
}
|
|
41
|
+
case "skills": {
|
|
42
|
+
const skillsScope = checkSkillsInstalled(cwd);
|
|
43
|
+
results.skillsInstalled = skillsScope !== false;
|
|
44
|
+
results.skillsScope = skillsScope;
|
|
45
|
+
break;
|
|
46
|
+
}
|
|
47
|
+
case "ide_type":
|
|
48
|
+
results.isVscodeIde = checkVscodeIde();
|
|
49
|
+
break;
|
|
50
|
+
case "has_app":
|
|
51
|
+
results.hasApp = checkHasApp(cwd);
|
|
52
|
+
break;
|
|
53
|
+
case "agent_type":
|
|
54
|
+
// Handled by the interactive runner (prompt or env detection)
|
|
55
|
+
break;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
return results;
|
|
59
|
+
}
|
|
60
|
+
// ---------------------------------------------------------------------------
|
|
61
|
+
// Individual check implementations
|
|
62
|
+
// ---------------------------------------------------------------------------
|
|
63
|
+
function checkMcpServer(cwd) {
|
|
64
|
+
const home = process.env.HOME || process.env.USERPROFILE || "";
|
|
65
|
+
// Check project-level configs first
|
|
66
|
+
const projectConfigs = [
|
|
67
|
+
resolve(cwd, ".cursor", "mcp.json"),
|
|
68
|
+
resolve(cwd, ".vscode", "settings.json"),
|
|
69
|
+
];
|
|
70
|
+
for (const configPath of projectConfigs) {
|
|
71
|
+
if (existsSync(configPath)) {
|
|
72
|
+
try {
|
|
73
|
+
const content = readFileSync(configPath, "utf-8");
|
|
74
|
+
if (content.includes("neon") ||
|
|
75
|
+
content.includes("mcp.neon.tech")) {
|
|
76
|
+
return "project";
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
catch { }
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
// Check global configs
|
|
83
|
+
const globalConfigs = [
|
|
84
|
+
resolve(home, ".cursor", "mcp.json"),
|
|
85
|
+
// Claude Code config (add-mcp writes to settings.local.json)
|
|
86
|
+
resolve(home, ".claude", "settings.local.json"),
|
|
87
|
+
resolve(home, ".claude", "settings.json"),
|
|
88
|
+
];
|
|
89
|
+
for (const configPath of globalConfigs) {
|
|
90
|
+
if (existsSync(configPath)) {
|
|
91
|
+
try {
|
|
92
|
+
const content = readFileSync(configPath, "utf-8");
|
|
93
|
+
if (content.includes("neon") ||
|
|
94
|
+
content.includes("mcp.neon.tech")) {
|
|
95
|
+
return "global";
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
catch { }
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
return false;
|
|
102
|
+
}
|
|
103
|
+
function checkConnectionString(cwd) {
|
|
104
|
+
for (const envFile of [".env", ".env.local"]) {
|
|
105
|
+
const envPath = resolve(cwd, envFile);
|
|
106
|
+
if (existsSync(envPath)) {
|
|
107
|
+
try {
|
|
108
|
+
const content = readFileSync(envPath, "utf-8");
|
|
109
|
+
if (/^DATABASE_URL=.*neon/m.test(content) ||
|
|
110
|
+
/^PGHOST=.*neon/m.test(content)) {
|
|
111
|
+
return true;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
catch { }
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
return false;
|
|
118
|
+
}
|
|
119
|
+
function detectProjectStack(cwd) {
|
|
120
|
+
const result = { framework: "none", orm: "none" };
|
|
121
|
+
const pkgPath = resolve(cwd, "package.json");
|
|
122
|
+
if (!existsSync(pkgPath))
|
|
123
|
+
return result;
|
|
124
|
+
try {
|
|
125
|
+
const pkg = JSON.parse(readFileSync(pkgPath, "utf-8"));
|
|
126
|
+
const allDeps = {
|
|
127
|
+
...pkg.dependencies,
|
|
128
|
+
...pkg.devDependencies,
|
|
129
|
+
};
|
|
130
|
+
// Framework detection
|
|
131
|
+
if (allDeps.next)
|
|
132
|
+
result.framework = "next";
|
|
133
|
+
else if (allDeps.remix || allDeps["@remix-run/node"])
|
|
134
|
+
result.framework = "remix";
|
|
135
|
+
else if (allDeps.express)
|
|
136
|
+
result.framework = "express";
|
|
137
|
+
else if (allDeps.hono)
|
|
138
|
+
result.framework = "hono";
|
|
139
|
+
else if (allDeps.fastify)
|
|
140
|
+
result.framework = "fastify";
|
|
141
|
+
else if (allDeps["@sveltejs/kit"])
|
|
142
|
+
result.framework = "sveltekit";
|
|
143
|
+
else if (allDeps.nuxt)
|
|
144
|
+
result.framework = "nuxt";
|
|
145
|
+
else if (allDeps.astro)
|
|
146
|
+
result.framework = "astro";
|
|
147
|
+
// ORM detection
|
|
148
|
+
if (allDeps.prisma || allDeps["@prisma/client"])
|
|
149
|
+
result.orm = "prisma";
|
|
150
|
+
else if (allDeps["drizzle-orm"])
|
|
151
|
+
result.orm = "drizzle";
|
|
152
|
+
else if (allDeps.knex)
|
|
153
|
+
result.orm = "knex";
|
|
154
|
+
else if (allDeps.typeorm)
|
|
155
|
+
result.orm = "typeorm";
|
|
156
|
+
else if (allDeps.sequelize)
|
|
157
|
+
result.orm = "sequelize";
|
|
158
|
+
else if (allDeps["@neondatabase/serverless"])
|
|
159
|
+
result.orm = "neon-serverless";
|
|
160
|
+
}
|
|
161
|
+
catch { }
|
|
162
|
+
return result;
|
|
163
|
+
}
|
|
164
|
+
function detectMigrations(cwd) {
|
|
165
|
+
// Prisma
|
|
166
|
+
if (existsSync(resolve(cwd, "prisma", "schema.prisma"))) {
|
|
167
|
+
const migrationsDir = resolve(cwd, "prisma", "migrations");
|
|
168
|
+
return {
|
|
169
|
+
tool: "prisma",
|
|
170
|
+
dir: existsSync(migrationsDir) ? "prisma/migrations" : "none",
|
|
171
|
+
};
|
|
172
|
+
}
|
|
173
|
+
// Drizzle
|
|
174
|
+
if (existsSync(resolve(cwd, "drizzle.config.ts")) ||
|
|
175
|
+
existsSync(resolve(cwd, "drizzle.config.js"))) {
|
|
176
|
+
const drizzleDir = resolve(cwd, "drizzle");
|
|
177
|
+
return {
|
|
178
|
+
tool: "drizzle",
|
|
179
|
+
dir: existsSync(drizzleDir) ? "drizzle" : "none",
|
|
180
|
+
};
|
|
181
|
+
}
|
|
182
|
+
// Knex
|
|
183
|
+
if (existsSync(resolve(cwd, "knexfile.js")) ||
|
|
184
|
+
existsSync(resolve(cwd, "knexfile.ts"))) {
|
|
185
|
+
const migrationsDir = resolve(cwd, "migrations");
|
|
186
|
+
return {
|
|
187
|
+
tool: "knex",
|
|
188
|
+
dir: existsSync(migrationsDir) ? "migrations" : "none",
|
|
189
|
+
};
|
|
190
|
+
}
|
|
191
|
+
return { tool: "none", dir: "none" };
|
|
192
|
+
}
|
|
193
|
+
function checkDatabaseUrl(cwd) {
|
|
194
|
+
const envPath = resolve(cwd, ".env");
|
|
195
|
+
if (existsSync(envPath)) {
|
|
196
|
+
try {
|
|
197
|
+
const content = readFileSync(envPath, "utf-8");
|
|
198
|
+
if (/^DATABASE_URL=/m.test(content))
|
|
199
|
+
return true;
|
|
200
|
+
}
|
|
201
|
+
catch { }
|
|
202
|
+
}
|
|
203
|
+
return false;
|
|
204
|
+
}
|
|
205
|
+
function checkSkillsInstalled(cwd) {
|
|
206
|
+
const home = process.env.HOME || process.env.USERPROFILE || "";
|
|
207
|
+
const skillNames = ["neon", "neon-postgres"];
|
|
208
|
+
// Check project-level skill directories — ALL base skills must exist
|
|
209
|
+
const projectDirs = [
|
|
210
|
+
resolve(cwd, ".cursor", "skills"),
|
|
211
|
+
resolve(cwd, ".claude", "skills"),
|
|
212
|
+
resolve(cwd, ".agents", "skills"),
|
|
213
|
+
];
|
|
214
|
+
const allProjectSkills = skillNames.every((skill) => projectDirs.some((dir) => existsSync(resolve(dir, skill, "SKILL.md"))));
|
|
215
|
+
if (allProjectSkills)
|
|
216
|
+
return "project";
|
|
217
|
+
// Check CLAUDE.md for neon skill references (injected by skills CLI)
|
|
218
|
+
// Only counts as installed if both skill names are referenced
|
|
219
|
+
const claudeMd = resolve(cwd, "CLAUDE.md");
|
|
220
|
+
if (existsSync(claudeMd)) {
|
|
221
|
+
try {
|
|
222
|
+
const content = readFileSync(claudeMd, "utf-8");
|
|
223
|
+
if (content.includes("neon-postgres") &&
|
|
224
|
+
content.includes("neon/SKILL.md"))
|
|
225
|
+
return "project";
|
|
226
|
+
}
|
|
227
|
+
catch { }
|
|
228
|
+
}
|
|
229
|
+
// Check global skill directories — ALL base skills must exist
|
|
230
|
+
const globalDirs = [
|
|
231
|
+
resolve(home, ".cursor", "skills"),
|
|
232
|
+
resolve(home, ".claude", "skills"),
|
|
233
|
+
resolve(home, ".agents", "skills"),
|
|
234
|
+
];
|
|
235
|
+
const allGlobalSkills = skillNames.every((skill) => globalDirs.some((dir) => existsSync(resolve(dir, skill, "SKILL.md"))));
|
|
236
|
+
if (allGlobalSkills)
|
|
237
|
+
return "global";
|
|
238
|
+
// Check for partial installations — ANY skill exists
|
|
239
|
+
const anyProjectSkill = skillNames.some((skill) => projectDirs.some((dir) => existsSync(resolve(dir, skill, "SKILL.md"))));
|
|
240
|
+
if (anyProjectSkill)
|
|
241
|
+
return "project-partial";
|
|
242
|
+
const anyGlobalSkill = skillNames.some((skill) => globalDirs.some((dir) => existsSync(resolve(dir, skill, "SKILL.md"))));
|
|
243
|
+
if (anyGlobalSkill)
|
|
244
|
+
return "global-partial";
|
|
245
|
+
return false;
|
|
246
|
+
}
|
|
247
|
+
function checkVscodeIde() {
|
|
248
|
+
const env = process.env;
|
|
249
|
+
return !!(env.TERM_PROGRAM === "vscode" ||
|
|
250
|
+
env.TERM_PROGRAM === "cursor" ||
|
|
251
|
+
env.TERM_PROGRAM === "windsurf" ||
|
|
252
|
+
env.VSCODE_PID ||
|
|
253
|
+
env.VSCODE_CWD);
|
|
254
|
+
}
|
|
255
|
+
/**
|
|
256
|
+
* Detects whether the current directory contains an application.
|
|
257
|
+
* Returns true if package.json has dependencies or common source directories exist.
|
|
258
|
+
*/
|
|
259
|
+
function checkHasApp(cwd) {
|
|
260
|
+
const pkgPath = resolve(cwd, "package.json");
|
|
261
|
+
if (existsSync(pkgPath)) {
|
|
262
|
+
try {
|
|
263
|
+
const pkg = JSON.parse(readFileSync(pkgPath, "utf-8"));
|
|
264
|
+
const deps = Object.keys(pkg.dependencies ?? {});
|
|
265
|
+
const devDeps = Object.keys(pkg.devDependencies ?? {});
|
|
266
|
+
if (deps.length > 0 || devDeps.length > 0)
|
|
267
|
+
return true;
|
|
268
|
+
}
|
|
269
|
+
catch { }
|
|
270
|
+
}
|
|
271
|
+
// Check for common source directories / entry files
|
|
272
|
+
const indicators = [
|
|
273
|
+
"src",
|
|
274
|
+
"app",
|
|
275
|
+
"pages",
|
|
276
|
+
"lib",
|
|
277
|
+
"index.ts",
|
|
278
|
+
"index.js",
|
|
279
|
+
"main.ts",
|
|
280
|
+
"main.js",
|
|
281
|
+
];
|
|
282
|
+
for (const indicator of indicators) {
|
|
283
|
+
if (existsSync(resolve(cwd, indicator)))
|
|
284
|
+
return true;
|
|
285
|
+
}
|
|
286
|
+
return false;
|
|
287
|
+
}
|