neon 3.0.0 → 3.1.1

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 (207) hide show
  1. package/README.md +70 -5
  2. package/dist/_chunks/auth_selection-DGgq6ifc.js +83 -0
  3. package/dist/_chunks/cmd_pipeline-CUbBO9U_.js +2818 -0
  4. package/dist/_chunks/credentials-MYdHdKah.js +188 -0
  5. package/dist/_chunks/env-NbA61JR3.js +585 -0
  6. package/dist/_chunks/env_services-Tz9G4JeT.js +531 -0
  7. package/dist/_chunks/paths-DMq0Lt7a.js +151 -0
  8. package/dist/_chunks/profiles-Ir29rqns.js +217 -0
  9. package/dist/_chunks/psql-DWH-kc69.js +2169 -0
  10. package/dist/_chunks/rolldown-runtime-D7D4PA-g.js +13 -0
  11. package/dist/_chunks/secure_file-BucZj4yQ.js +39 -0
  12. package/dist/analytics.js +163 -207
  13. package/dist/api.js +815 -758
  14. package/dist/auth.js +121 -141
  15. package/dist/auth_context.js +39 -53
  16. package/dist/cli.js +4 -7
  17. package/dist/commands/api.js +220 -250
  18. package/dist/commands/api_keys.js +251 -314
  19. package/dist/commands/auth.js +283 -328
  20. package/dist/commands/bootstrap.js +372 -437
  21. package/dist/commands/branches.js +304 -455
  22. package/dist/commands/bucket.js +374 -514
  23. package/dist/commands/checkout.js +213 -298
  24. package/dist/commands/config.js +573 -690
  25. package/dist/commands/connection_string.js +137 -165
  26. package/dist/commands/data_api.js +238 -260
  27. package/dist/commands/databases.js +67 -76
  28. package/dist/commands/deploy.js +31 -25
  29. package/dist/commands/dev.js +639 -719
  30. package/dist/commands/diff.js +156 -200
  31. package/dist/commands/env.js +255 -305
  32. package/dist/commands/functions.js +275 -355
  33. package/dist/commands/index.js +70 -65
  34. package/dist/commands/init.js +84 -119
  35. package/dist/commands/inspect.js +55 -55
  36. package/dist/commands/ip_allow.js +88 -120
  37. package/dist/commands/link.js +874 -1019
  38. package/dist/commands/logs.js +291 -0
  39. package/dist/commands/neon_auth.js +725 -933
  40. package/dist/commands/operations.js +34 -25
  41. package/dist/commands/orgs.js +28 -18
  42. package/dist/commands/profile.js +615 -846
  43. package/dist/commands/projects.js +313 -373
  44. package/dist/commands/psql.js +60 -58
  45. package/dist/commands/roles.js +55 -58
  46. package/dist/commands/schema_diff.js +87 -131
  47. package/dist/commands/set_context.js +34 -26
  48. package/dist/commands/snapshots.js +288 -413
  49. package/dist/commands/status.js +41 -37
  50. package/dist/commands/user.js +21 -10
  51. package/dist/commands/vpc_endpoints.js +85 -113
  52. package/dist/config.js +7 -6
  53. package/dist/config_format.js +50 -66
  54. package/dist/config_template.js +128 -157
  55. package/dist/context.js +183 -235
  56. package/dist/current_branch_fast_path.js +40 -49
  57. package/dist/dev/env.js +2 -446
  58. package/dist/dev/functions.js +54 -68
  59. package/dist/dev/inputs.js +46 -58
  60. package/dist/dev/runtime.js +135 -164
  61. package/dist/dev/websocket.js +766 -959
  62. package/dist/env.js +27 -33
  63. package/dist/env_file.js +118 -132
  64. package/dist/env_services.js +2 -51
  65. package/dist/errors.js +57 -68
  66. package/dist/functions_api.js +45 -43
  67. package/dist/help.js +189 -140
  68. package/dist/index.js +182 -257
  69. package/dist/init/agents.js +137 -118
  70. package/dist/init/auth.js +58 -68
  71. package/dist/init/bootstrap.js +325 -396
  72. package/dist/init/build_config.js +4 -2
  73. package/dist/init/detect_agent.js +56 -101
  74. package/dist/init/editors.js +35 -52
  75. package/dist/init/enrich_output.js +51 -66
  76. package/dist/init/extension.js +134 -171
  77. package/dist/init/inspect.js +179 -266
  78. package/dist/init/interactive.js +510 -622
  79. package/dist/init/neonctl.js +117 -168
  80. package/dist/init/orchestrate.js +157 -173
  81. package/dist/init/phases/auth.js +188 -202
  82. package/dist/init/phases/cleanup.js +23 -23
  83. package/dist/init/phases/db.js +251 -277
  84. package/dist/init/phases/getting_started.js +213 -223
  85. package/dist/init/phases/mcp.js +174 -224
  86. package/dist/init/phases/migrations.js +247 -248
  87. package/dist/init/phases/neon_auth.js +114 -133
  88. package/dist/init/phases/setup.js +546 -703
  89. package/dist/init/phases/skills.js +75 -86
  90. package/dist/init/phases/status.js +72 -67
  91. package/dist/init/resolve_context.js +102 -99
  92. package/dist/init/route_command.js +91 -98
  93. package/dist/init/skills.js +174 -218
  94. package/dist/init/vsix.js +77 -99
  95. package/dist/log.js +17 -16
  96. package/dist/neon_services.js +104 -129
  97. package/dist/parameters.gen.js +481 -471
  98. package/dist/pkg.js +17 -19
  99. package/dist/profile_keys.js +44 -47
  100. package/dist/psql/cli.js +44 -47
  101. package/dist/psql/command/cmd_cond.js +231 -406
  102. package/dist/psql/command/cmd_connect.js +557 -764
  103. package/dist/psql/command/cmd_copy.js +728 -984
  104. package/dist/psql/command/cmd_describe.js +1499 -1688
  105. package/dist/psql/command/cmd_format.js +733 -905
  106. package/dist/psql/command/cmd_io.js +2 -2193
  107. package/dist/psql/command/cmd_lo.js +297 -359
  108. package/dist/psql/command/cmd_meta.js +727 -878
  109. package/dist/psql/command/cmd_misc.js +138 -172
  110. package/dist/psql/command/cmd_pipeline.js +2 -1148
  111. package/dist/psql/command/cmd_restrict.js +119 -155
  112. package/dist/psql/command/cmd_show.js +529 -688
  113. package/dist/psql/command/dispatch.js +260 -325
  114. package/dist/psql/command/inputQueue.js +35 -33
  115. package/dist/psql/command/shared.js +49 -63
  116. package/dist/psql/complete/filenames.js +90 -133
  117. package/dist/psql/complete/index.js +59 -97
  118. package/dist/psql/complete/matcher.js +236 -300
  119. package/dist/psql/complete/psqlVars.js +218 -223
  120. package/dist/psql/complete/queries.js +159 -177
  121. package/dist/psql/complete/rules.js +1493 -2299
  122. package/dist/psql/core/common.js +2 -1253
  123. package/dist/psql/core/help.js +456 -546
  124. package/dist/psql/core/mainloop.js +692 -1303
  125. package/dist/psql/core/prompt.js +391 -408
  126. package/dist/psql/core/settings.js +429 -644
  127. package/dist/psql/core/sqlHelp.js +480 -554
  128. package/dist/psql/core/startup.js +2 -846
  129. package/dist/psql/core/syncVars.js +67 -110
  130. package/dist/psql/core/variables.js +156 -278
  131. package/dist/psql/describe/formatters.js +884 -1285
  132. package/dist/psql/describe/processNamePattern.js +173 -260
  133. package/dist/psql/describe/queries.js +1368 -2403
  134. package/dist/psql/describe/versionGate.js +32 -41
  135. package/dist/psql/index.js +2 -2030
  136. package/dist/psql/io/history.js +232 -271
  137. package/dist/psql/io/input.js +103 -108
  138. package/dist/psql/io/lineEditor/buffer.js +238 -319
  139. package/dist/psql/io/lineEditor/complete.js +135 -213
  140. package/dist/psql/io/lineEditor/filename.js +139 -148
  141. package/dist/psql/io/lineEditor/index.js +653 -870
  142. package/dist/psql/io/lineEditor/keymap.js +544 -702
  143. package/dist/psql/io/lineEditor/vt100.js +294 -341
  144. package/dist/psql/io/pgpass.js +158 -187
  145. package/dist/psql/io/pgservice.js +146 -183
  146. package/dist/psql/io/psqlrc.js +328 -403
  147. package/dist/psql/print/aligned.js +1020 -1683
  148. package/dist/psql/print/asciidoc.js +180 -214
  149. package/dist/psql/print/crosstab.js +281 -442
  150. package/dist/psql/print/csv.js +48 -70
  151. package/dist/psql/print/html.js +195 -226
  152. package/dist/psql/print/json.js +75 -88
  153. package/dist/psql/print/latex.js +291 -364
  154. package/dist/psql/print/pager.js +171 -242
  155. package/dist/psql/print/troff.js +194 -226
  156. package/dist/psql/print/unaligned.js +69 -95
  157. package/dist/psql/print/units.js +167 -169
  158. package/dist/psql/scanner/slash.js +428 -483
  159. package/dist/psql/scanner/sql.js +445 -889
  160. package/dist/psql/scanner/stringutils.js +309 -379
  161. package/dist/psql/types/index.js +8 -7
  162. package/dist/psql/types/scanner.js +25 -22
  163. package/dist/psql/wire/connection.js +2042 -2803
  164. package/dist/psql/wire/copy.js +84 -100
  165. package/dist/psql/wire/notify.js +39 -59
  166. package/dist/psql/wire/pipeline.js +305 -518
  167. package/dist/psql/wire/protocol.js +349 -417
  168. package/dist/psql/wire/sasl.js +180 -265
  169. package/dist/psql/wire/tls.js +400 -561
  170. package/dist/storage_api.js +115 -129
  171. package/dist/test_utils/fixtures.js +94 -113
  172. package/dist/test_utils/oauth_server.js +10 -7
  173. package/dist/test_utils/project_dir.js +33 -0
  174. package/dist/utils/ai_gateway_notice.js +131 -162
  175. package/dist/utils/api_enums.js +21 -28
  176. package/dist/utils/auth.js +10 -4
  177. package/dist/utils/branch_notice.js +20 -19
  178. package/dist/utils/branch_picker.js +83 -89
  179. package/dist/utils/cli_name.js +15 -12
  180. package/dist/utils/compute_units.js +20 -27
  181. package/dist/utils/config_diff.js +127 -158
  182. package/dist/utils/enrichers.js +95 -148
  183. package/dist/utils/esbuild.js +130 -189
  184. package/dist/utils/flags.js +35 -47
  185. package/dist/utils/formats.js +8 -15
  186. package/dist/utils/git_diff.js +69 -80
  187. package/dist/utils/inspect_db.js +101 -143
  188. package/dist/utils/inspect_queries.js +179 -142
  189. package/dist/utils/middlewares.js +39 -45
  190. package/dist/utils/openapi.js +87 -99
  191. package/dist/utils/package_manager.js +312 -110
  192. package/dist/utils/point_in_time.js +49 -53
  193. package/dist/utils/psql.js +89 -106
  194. package/dist/utils/service_picker.js +55 -58
  195. package/dist/utils/string.js +5 -5
  196. package/dist/utils/ui.js +38 -55
  197. package/dist/utils/write_sync.js +26 -35
  198. package/dist/utils/zip.js +4 -3
  199. package/dist/writer.js +67 -87
  200. package/package.json +11 -6
  201. package/dist/_shared/auth_selection.js +0 -86
  202. package/dist/_shared/credentials.js +0 -209
  203. package/dist/_shared/env-core/env.js +0 -558
  204. package/dist/_shared/env-core/reuse-secrets.js +0 -223
  205. package/dist/_shared/paths.js +0 -148
  206. package/dist/_shared/profiles.js +0 -276
  207. package/dist/_shared/secure_file.js +0 -43
@@ -1,100 +1,93 @@
1
+ //#region src/init/route_command.ts
1
2
  /**
2
- * Routes a `--data` payload to a phase handler by its `step` field, without
3
- * shelling out. This is the whole agent-facing surface of `neon init`:
4
- *
5
- * neon init --agent --data '{"step":"auth"}'
6
- * neon init --agent --data '{"step":"db","projectId":"xyz"}'
7
- */
8
- export async function routeDataStep(data, agent) {
9
- const { step, agentId, ...rest } = data;
10
- // Allow agentId override from data JSON, fall back to caller-provided agent
11
- const resolvedAgent = typeof agentId === "string" ? agentId : agent;
12
- // Agents sometimes nest the actual payload inside a "data" key:
13
- // {"step":"setup","data":{"mode":"defaults",...}}
14
- // or as a JSON string:
15
- // {"step":"setup","data":"{\"mode\":\"defaults\",...}"}
16
- // Unwrap it so the phase handler gets the right options.
17
- if (rest.data !== undefined && Object.keys(rest).length === 1) {
18
- let nested = rest.data;
19
- if (typeof nested === "string") {
20
- try {
21
- nested = JSON.parse(nested);
22
- }
23
- catch {
24
- // leave as-is
25
- }
26
- }
27
- if (typeof nested === "object" && nested !== null) {
28
- Object.assign(rest, nested);
29
- delete rest.data;
30
- }
31
- }
32
- switch (step) {
33
- case "auth": {
34
- const { handleAuthPhase } = await import("./phases/auth.js");
35
- return handleAuthPhase({
36
- agent: resolvedAgent,
37
- ...rest,
38
- });
39
- }
40
- case "db": {
41
- const { handleDbPhase } = await import("./phases/db.js");
42
- return handleDbPhase({
43
- agent: resolvedAgent,
44
- ...rest,
45
- });
46
- }
47
- case "setup": {
48
- const { handleSetupPhase } = await import("./phases/setup.js");
49
- return handleSetupPhase({
50
- agent: resolvedAgent,
51
- ...rest,
52
- });
53
- }
54
- case "getting-started": {
55
- const { handleGettingStartedPhase } = await import("./phases/getting_started.js");
56
- return handleGettingStartedPhase({
57
- agent: resolvedAgent,
58
- ...rest,
59
- });
60
- }
61
- case "mcp": {
62
- const { handleMcpPhase } = await import("./phases/mcp.js");
63
- return handleMcpPhase({
64
- agent: resolvedAgent,
65
- ...rest,
66
- });
67
- }
68
- case "skills": {
69
- const { handleSkillsPhase } = await import("./phases/skills.js");
70
- return handleSkillsPhase({
71
- agent: resolvedAgent,
72
- ...rest,
73
- });
74
- }
75
- case "migrations": {
76
- const { handleMigrationsPhase } = await import("./phases/migrations.js");
77
- return handleMigrationsPhase({
78
- agent: resolvedAgent,
79
- ...rest,
80
- });
81
- }
82
- case "neon-auth": {
83
- const { handleNeonAuthPhase } = await import("./phases/neon_auth.js");
84
- return handleNeonAuthPhase({
85
- agent: resolvedAgent,
86
- ...rest,
87
- });
88
- }
89
- case "status": {
90
- const { handleStatusPhase } = await import("./phases/status.js");
91
- return handleStatusPhase({ agent: resolvedAgent });
92
- }
93
- case "finalize": {
94
- const { handleCleanup } = await import("./phases/cleanup.js");
95
- return handleCleanup();
96
- }
97
- default:
98
- throw new Error(`Unknown step: "${step}". Valid steps: auth, db, setup, getting-started, mcp, skills, migrations, neon-auth, status, finalize`);
99
- }
3
+ * Routes a `--data` payload to a phase handler by its `step` field, without
4
+ * shelling out. This is the whole agent-facing surface of `neon init`:
5
+ *
6
+ * neon init --agent --data '{"step":"auth"}'
7
+ * neon init --agent --data '{"step":"db","projectId":"xyz"}'
8
+ */
9
+ async function routeDataStep(data, agent) {
10
+ const { step, agentId, ...rest } = data;
11
+ const resolvedAgent = typeof agentId === "string" ? agentId : agent;
12
+ if (rest.data !== void 0 && Object.keys(rest).length === 1) {
13
+ let nested = rest.data;
14
+ if (typeof nested === "string") try {
15
+ nested = JSON.parse(nested);
16
+ } catch {}
17
+ if (typeof nested === "object" && nested !== null) {
18
+ Object.assign(rest, nested);
19
+ delete rest.data;
20
+ }
21
+ }
22
+ switch (step) {
23
+ case "auth": {
24
+ const { handleAuthPhase } = await import("./phases/auth.js");
25
+ return handleAuthPhase({
26
+ agent: resolvedAgent,
27
+ ...rest
28
+ });
29
+ }
30
+ case "db": {
31
+ const { handleDbPhase } = await import("./phases/db.js");
32
+ return handleDbPhase({
33
+ agent: resolvedAgent,
34
+ ...rest
35
+ });
36
+ }
37
+ case "setup": {
38
+ const { handleSetupPhase } = await import("./phases/setup.js");
39
+ return handleSetupPhase({
40
+ agent: resolvedAgent,
41
+ ...rest
42
+ });
43
+ }
44
+ case "getting-started": {
45
+ const { handleGettingStartedPhase } = await import("./phases/getting_started.js");
46
+ return handleGettingStartedPhase({
47
+ agent: resolvedAgent,
48
+ ...rest,
49
+ cwd: process.cwd()
50
+ });
51
+ }
52
+ case "mcp": {
53
+ const { handleMcpPhase } = await import("./phases/mcp.js");
54
+ return handleMcpPhase({
55
+ agent: resolvedAgent,
56
+ ...rest
57
+ });
58
+ }
59
+ case "skills": {
60
+ const { handleSkillsPhase } = await import("./phases/skills.js");
61
+ return handleSkillsPhase({
62
+ agent: resolvedAgent,
63
+ ...rest
64
+ });
65
+ }
66
+ case "migrations": {
67
+ const { handleMigrationsPhase } = await import("./phases/migrations.js");
68
+ return handleMigrationsPhase({
69
+ agent: resolvedAgent,
70
+ ...rest,
71
+ cwd: process.cwd()
72
+ });
73
+ }
74
+ case "neon-auth": {
75
+ const { handleNeonAuthPhase } = await import("./phases/neon_auth.js");
76
+ return handleNeonAuthPhase({
77
+ agent: resolvedAgent,
78
+ ...rest
79
+ });
80
+ }
81
+ case "status": {
82
+ const { handleStatusPhase } = await import("./phases/status.js");
83
+ return handleStatusPhase({ agent: resolvedAgent });
84
+ }
85
+ case "finalize": {
86
+ const { handleCleanup } = await import("./phases/cleanup.js");
87
+ return handleCleanup();
88
+ }
89
+ default: throw new Error(`Unknown step: "${step}". Valid steps: auth, db, setup, getting-started, mcp, skills, migrations, neon-auth, status, finalize`);
90
+ }
100
91
  }
92
+ //#endregion
93
+ export { routeDataStep };
@@ -1,248 +1,204 @@
1
+ import { globalInstallCommand, resolveInvokingPackageManager } from "../utils/package_manager.js";
2
+ import { getSkillsAgentName } from "./agents.js";
1
3
  import { existsSync, statSync } from "node:fs";
2
4
  import { resolve } from "node:path";
3
5
  import { log, spinner } from "@clack/prompts";
4
6
  import { execa } from "execa";
5
7
  import { dim } from "yoctocolors";
6
- import { getSkillsAgentName as getSkillsAgentNameFromId } from "./agents.js";
8
+ //#region src/init/skills.ts
7
9
  /**
8
- * Ensures the `skills` CLI is globally installed so npx doesn't need
9
- * to download it (which can fail behind corporate proxies / sandboxes).
10
- */
10
+ * Ensures the `skills` CLI is globally installed so npx doesn't need
11
+ * to download it (which can fail behind corporate proxies / sandboxes).
12
+ */
11
13
  async function ensureSkillsCli() {
12
- try {
13
- await execa("skills", ["--version"], { stdio: "pipe", timeout: 5000 });
14
- }
15
- catch {
16
- // Not installed — install it globally
17
- try {
18
- await execa("npm", ["install", "-g", "skills"], {
19
- stdio: "pipe",
20
- timeout: 60000,
21
- });
22
- }
23
- catch {
24
- // Best effort — npx will fall back to downloading
25
- }
26
- }
14
+ try {
15
+ await execa("skills", ["--version"], {
16
+ stdio: "pipe",
17
+ timeout: 5e3
18
+ });
19
+ } catch {
20
+ const install = globalInstallCommand(resolveInvokingPackageManager(), "skills");
21
+ if (!install) return;
22
+ try {
23
+ await execa(install.command, install.args, {
24
+ stdio: "pipe",
25
+ timeout: 6e4
26
+ });
27
+ } catch {}
28
+ }
27
29
  }
28
30
  /** Base skills installed for all invocations */
29
31
  const BASE_SKILLS = ["neon", "neon-postgres"];
30
32
  /** Additional skills installed for preview (non-bootstrap) invocations */
31
33
  const PREVIEW_SKILLS = [
32
- "neon-object-storage",
33
- "neon-functions",
34
- "neon-ai-gateway",
34
+ "neon-object-storage",
35
+ "neon-functions",
36
+ "neon-ai-gateway"
35
37
  ];
36
38
  /** Returns the skill list based on whether preview mode is active */
37
- export function getSkillList(preview) {
38
- return preview ? [...BASE_SKILLS, ...PREVIEW_SKILLS] : BASE_SKILLS;
39
+ function getSkillList(preview) {
40
+ return preview ? [...BASE_SKILLS, ...PREVIEW_SKILLS] : BASE_SKILLS;
39
41
  }
40
42
  const SKILL_BASE_URL = "https://neon.com/docs/ai/skills/neon-postgres/references";
41
- export const SKILL_REFERENCE_URLS = {
42
- gettingStarted: `${SKILL_BASE_URL}/getting-started.md`,
43
- connectionMethods: `${SKILL_BASE_URL}/connection-methods.md`,
44
- neonAuth: `${SKILL_BASE_URL}/neon-auth.md`,
45
- serverlessDriver: `${SKILL_BASE_URL}/neon-serverless.md`,
46
- neonCli: `${SKILL_BASE_URL}/neon-cli.md`,
47
- devtools: `${SKILL_BASE_URL}/devtools.md`,
48
- branching: `${SKILL_BASE_URL}/branching.md`,
49
- neonJs: `${SKILL_BASE_URL}/neon-js.md`,
43
+ const SKILL_REFERENCE_URLS = {
44
+ gettingStarted: `${SKILL_BASE_URL}/getting-started.md`,
45
+ connectionMethods: `${SKILL_BASE_URL}/connection-methods.md`,
46
+ neonAuth: `${SKILL_BASE_URL}/neon-auth.md`,
47
+ serverlessDriver: `${SKILL_BASE_URL}/neon-serverless.md`,
48
+ neonCli: `${SKILL_BASE_URL}/neon-cli.md`,
49
+ devtools: `${SKILL_BASE_URL}/devtools.md`,
50
+ branching: `${SKILL_BASE_URL}/branching.md`,
51
+ neonJs: `${SKILL_BASE_URL}/neon-js.md`
50
52
  };
51
53
  /**
52
- * Maps Editor display names to the skills CLI agent name.
53
- */
54
+ * Maps Editor display names to the skills CLI agent name.
55
+ */
54
56
  function editorToSkillsAgent(editor) {
55
- switch (editor) {
56
- case "Cursor":
57
- return "cursor";
58
- case "VS Code":
59
- case "GitHub Copilot CLI":
60
- return "github-copilot";
61
- case "Claude CLI":
62
- return "claude-code";
63
- case "Codex":
64
- return "codex";
65
- case "OpenCode":
66
- return "opencode";
67
- case "Antigravity":
68
- return "antigravity";
69
- case "Cline":
70
- case "Cline CLI":
71
- return "cline";
72
- case "Gemini CLI":
73
- return "gemini-cli";
74
- case "Goose":
75
- return "goose";
76
- case "Claude Desktop":
77
- return "claude-code";
78
- case "MCPorter":
79
- return "mcporter";
80
- case "Zed":
81
- return "zed";
82
- default:
83
- return "";
84
- }
57
+ switch (editor) {
58
+ case "Cursor": return "cursor";
59
+ case "VS Code":
60
+ case "GitHub Copilot CLI": return "github-copilot";
61
+ case "Claude CLI": return "claude-code";
62
+ case "Codex": return "codex";
63
+ case "OpenCode": return "opencode";
64
+ case "Antigravity": return "antigravity";
65
+ case "Cline":
66
+ case "Cline CLI": return "cline";
67
+ case "Gemini CLI": return "gemini-cli";
68
+ case "Goose": return "goose";
69
+ case "Claude Desktop": return "claude-code";
70
+ case "MCPorter": return "mcporter";
71
+ case "Zed": return "zed";
72
+ default: return "";
73
+ }
85
74
  }
86
75
  /**
87
- * Installs Neon agent skills using Vercel's skills CLI.
88
- */
89
- export async function installAgentSkills(selectedEditors, options) {
90
- const quiet = options?.json === true;
91
- const editorsWithSkills = selectedEditors.filter((e) => editorToSkillsAgent(e) !== "");
92
- if (editorsWithSkills.length === 0) {
93
- return true;
94
- }
95
- const skillsSpinner = quiet ? null : spinner();
96
- skillsSpinner?.start("Installing agent skills for Neon in this project...");
97
- let anyFailed = false;
98
- await ensureSkillsCli();
99
- const skills = getSkillList(options?.preview);
100
- for (const editor of editorsWithSkills) {
101
- const agentName = editorToSkillsAgent(editor);
102
- // Install one skill at a time — the skills CLI has a bug with multiple
103
- // --skill flags where it creates directories but doesn't copy all SKILL.md files.
104
- for (const skill of skills) {
105
- try {
106
- await execa("skills", [
107
- "add",
108
- "neondatabase/agent-skills",
109
- "--skill",
110
- skill,
111
- "--agent",
112
- agentName,
113
- ...(options?.scope === "global" ? ["-g"] : []),
114
- "-y",
115
- ], {
116
- stdio: "pipe",
117
- timeout: 120000,
118
- });
119
- }
120
- catch (error) {
121
- if (!quiet)
122
- log.error(`Failed to install skill ${skill} for ${editor}: ${error instanceof Error ? error.message : "Unknown error"}`);
123
- anyFailed = true;
124
- }
125
- }
126
- }
127
- if (anyFailed) {
128
- skillsSpinner?.stop("Agent skills installation for this project completed with errors");
129
- if (!quiet)
130
- log.info("You can manually install skills by running: npx skills add neondatabase/agent-skills --skill neon --skill neon-postgres");
131
- return false;
132
- }
133
- skillsSpinner?.stop(dim("Agent skills installed ✓"));
134
- return true;
76
+ * Installs Neon agent skills using Vercel's skills CLI.
77
+ */
78
+ async function installAgentSkills(selectedEditors, options) {
79
+ const quiet = options?.json === true;
80
+ const editorsWithSkills = selectedEditors.filter((e) => editorToSkillsAgent(e) !== "");
81
+ if (editorsWithSkills.length === 0) return true;
82
+ const skillsSpinner = quiet ? null : spinner();
83
+ skillsSpinner?.start("Installing agent skills for Neon in this project...");
84
+ let anyFailed = false;
85
+ await ensureSkillsCli();
86
+ const skills = getSkillList(options?.preview);
87
+ for (const editor of editorsWithSkills) {
88
+ const agentName = editorToSkillsAgent(editor);
89
+ for (const skill of skills) try {
90
+ await execa("skills", [
91
+ "add",
92
+ "neondatabase/agent-skills",
93
+ "--skill",
94
+ skill,
95
+ "--agent",
96
+ agentName,
97
+ ...options?.scope === "global" ? ["-g"] : [],
98
+ "-y"
99
+ ], {
100
+ stdio: "pipe",
101
+ timeout: 12e4
102
+ });
103
+ } catch (error) {
104
+ if (!quiet) log.error(`Failed to install skill ${skill} for ${editor}: ${error instanceof Error ? error.message : "Unknown error"}`);
105
+ anyFailed = true;
106
+ }
107
+ }
108
+ if (anyFailed) {
109
+ skillsSpinner?.stop("Agent skills installation for this project completed with errors");
110
+ if (!quiet) log.info("You can manually install skills by running: npx skills add neondatabase/agent-skills --skill neon --skill neon-postgres");
111
+ return false;
112
+ }
113
+ skillsSpinner?.stop(dim("Agent skills installed ✓"));
114
+ return true;
135
115
  }
136
- // ---------------------------------------------------------------------------
137
- // Evergreen skills: ensure skills are up to date (at most once per 12 hours)
138
- // ---------------------------------------------------------------------------
139
- const SKILLS_FRESHNESS_MS = 12 * 60 * 60 * 1000; // 12 hours
116
+ const SKILLS_FRESHNESS_MS = 432e5;
140
117
  /**
141
- * Agent skills directory paths by agent, keyed by scope.
142
- * These are the directories that `skills add` writes to.
143
- */
118
+ * Agent skills directory paths by agent, keyed by scope.
119
+ * These are the directories that `skills add` writes to.
120
+ */
144
121
  const GLOBAL_SKILLS_DIRS = (() => {
145
- const home = process.env.HOME || process.env.USERPROFILE || "";
146
- // .agents/skills is the generic directory used by multiple agents
147
- const agentsDir = resolve(home, ".agents", "skills");
148
- return {
149
- cursor: [resolve(home, ".cursor", "skills"), agentsDir],
150
- "claude-code": [resolve(home, ".claude", "skills"), agentsDir],
151
- "github-copilot": [resolve(home, ".vscode", "skills"), agentsDir],
152
- codex: [resolve(home, ".codex", "skills"), agentsDir],
153
- cline: [resolve(home, ".cline", "skills"), agentsDir],
154
- };
122
+ const home = process.env.HOME || process.env.USERPROFILE || "";
123
+ const agentsDir = resolve(home, ".agents", "skills");
124
+ return {
125
+ cursor: [resolve(home, ".cursor", "skills"), agentsDir],
126
+ "claude-code": [resolve(home, ".claude", "skills"), agentsDir],
127
+ "github-copilot": [resolve(home, ".vscode", "skills"), agentsDir],
128
+ codex: [resolve(home, ".codex", "skills"), agentsDir],
129
+ cline: [resolve(home, ".cline", "skills"), agentsDir]
130
+ };
155
131
  })();
156
132
  /**
157
- * Checks whether skills were recently updated (within the freshness window).
158
- * Checks both project-level (skills-lock.json mtime) and global (skills dir mtime).
159
- */
133
+ * Checks whether skills were recently updated (within the freshness window).
134
+ * Checks both project-level (skills-lock.json mtime) and global (skills dir mtime).
135
+ */
160
136
  function skillsAreFresh(agent, requiredSkills) {
161
- const now = Date.now();
162
- const cwd = process.cwd();
163
- const projectSkillDirs = [".agents", ".cursor", ".claude"];
164
- // Check project-level: ALL required skills must exist on disk
165
- // and skills-lock.json must be recent
166
- const lockPath = resolve(cwd, "skills-lock.json");
167
- if (existsSync(lockPath)) {
168
- try {
169
- const mtime = statSync(lockPath).mtimeMs;
170
- if (now - mtime < SKILLS_FRESHNESS_MS) {
171
- const allExist = requiredSkills.every((skill) => projectSkillDirs.some((dir) => existsSync(resolve(cwd, dir, "skills", skill, "SKILL.md"))));
172
- if (allExist)
173
- return true;
174
- }
175
- }
176
- catch { }
177
- }
178
- // Check global: ALL required skills must exist in agent-specific dirs
179
- const agentName = getSkillsAgentNameFromId(agent);
180
- const globalDirs = GLOBAL_SKILLS_DIRS[agentName] ?? [];
181
- for (const dir of globalDirs) {
182
- const allExist = requiredSkills.every((skill) => existsSync(resolve(dir, skill, "SKILL.md")));
183
- if (allExist) {
184
- // Check freshness of any one skill file
185
- try {
186
- const mtime = statSync(resolve(dir, requiredSkills[0], "SKILL.md")).mtimeMs;
187
- if (now - mtime < SKILLS_FRESHNESS_MS)
188
- return true;
189
- }
190
- catch { }
191
- }
192
- }
193
- return false;
137
+ const now = Date.now();
138
+ const cwd = process.cwd();
139
+ const projectSkillDirs = [
140
+ ".agents",
141
+ ".cursor",
142
+ ".claude"
143
+ ];
144
+ const lockPath = resolve(cwd, "skills-lock.json");
145
+ if (existsSync(lockPath)) try {
146
+ if (now - statSync(lockPath).mtimeMs < SKILLS_FRESHNESS_MS) {
147
+ if (requiredSkills.every((skill) => projectSkillDirs.some((dir) => existsSync(resolve(cwd, dir, "skills", skill, "SKILL.md"))))) return true;
148
+ }
149
+ } catch {}
150
+ const agentName = getSkillsAgentName(agent);
151
+ const globalDirs = GLOBAL_SKILLS_DIRS[agentName] ?? [];
152
+ for (const dir of globalDirs) if (requiredSkills.every((skill) => existsSync(resolve(dir, skill, "SKILL.md")))) try {
153
+ if (now - statSync(resolve(dir, requiredSkills[0], "SKILL.md")).mtimeMs < SKILLS_FRESHNESS_MS) return true;
154
+ } catch {}
155
+ return false;
194
156
  }
195
157
  /**
196
- * Ensures Neon agent skills are up to date. Runs `skills add` if the skills
197
- * haven't been updated within the freshness window (12 hours).
198
- *
199
- * Designed to be called from any phase handler — cheap to call repeatedly
200
- * since it's a no-op when skills are fresh.
201
- */
202
- export async function ensureSkillsUpToDate(agent, scope, preview) {
203
- const resolvedAgent = agent || "cursor";
204
- const skills = getSkillList(preview);
205
- if (skillsAreFresh(resolvedAgent, skills))
206
- return true;
207
- await ensureSkillsCli();
208
- const agentName = getSkillsAgentNameFromId(resolvedAgent);
209
- let allOk = true;
210
- // Only install skills that don't already have SKILL.md on disk.
211
- // Re-installing existing skills can trigger sandbox permission prompts.
212
- const home = process.env.HOME || process.env.USERPROFILE || "";
213
- const cwd = process.cwd();
214
- const checkDirs = scope === "global"
215
- ? [
216
- resolve(home, ".cursor", "skills"),
217
- resolve(home, ".claude", "skills"),
218
- resolve(home, ".agents", "skills"),
219
- ]
220
- : [
221
- resolve(cwd, ".cursor", "skills"),
222
- resolve(cwd, ".claude", "skills"),
223
- resolve(cwd, ".agents", "skills"),
224
- ];
225
- const missingSkills = skills.filter((skill) => !checkDirs.some((dir) => existsSync(resolve(dir, skill, "SKILL.md"))));
226
- if (missingSkills.length === 0)
227
- return true;
228
- // Install one skill at a time — the skills CLI has a bug with multiple
229
- // --skill flags where it creates directories but doesn't copy all SKILL.md files.
230
- for (const skill of missingSkills) {
231
- try {
232
- await execa("skills", [
233
- "add",
234
- "neondatabase/agent-skills",
235
- "--skill",
236
- skill,
237
- "--agent",
238
- agentName,
239
- ...(scope === "global" ? ["-g"] : []),
240
- "-y",
241
- ], { stdio: "pipe", timeout: 120000 });
242
- }
243
- catch {
244
- allOk = false;
245
- }
246
- }
247
- return allOk;
158
+ * Ensures Neon agent skills are up to date. Runs `skills add` if the skills
159
+ * haven't been updated within the freshness window (12 hours).
160
+ *
161
+ * Designed to be called from any phase handler — cheap to call repeatedly
162
+ * since it's a no-op when skills are fresh.
163
+ */
164
+ async function ensureSkillsUpToDate(agent, scope, preview) {
165
+ const resolvedAgent = agent || "cursor";
166
+ const skills = getSkillList(preview);
167
+ if (skillsAreFresh(resolvedAgent, skills)) return true;
168
+ await ensureSkillsCli();
169
+ const agentName = getSkillsAgentName(resolvedAgent);
170
+ let allOk = true;
171
+ const home = process.env.HOME || process.env.USERPROFILE || "";
172
+ const cwd = process.cwd();
173
+ const checkDirs = scope === "global" ? [
174
+ resolve(home, ".cursor", "skills"),
175
+ resolve(home, ".claude", "skills"),
176
+ resolve(home, ".agents", "skills")
177
+ ] : [
178
+ resolve(cwd, ".cursor", "skills"),
179
+ resolve(cwd, ".claude", "skills"),
180
+ resolve(cwd, ".agents", "skills")
181
+ ];
182
+ const missingSkills = skills.filter((skill) => !checkDirs.some((dir) => existsSync(resolve(dir, skill, "SKILL.md"))));
183
+ if (missingSkills.length === 0) return true;
184
+ for (const skill of missingSkills) try {
185
+ await execa("skills", [
186
+ "add",
187
+ "neondatabase/agent-skills",
188
+ "--skill",
189
+ skill,
190
+ "--agent",
191
+ agentName,
192
+ ...scope === "global" ? ["-g"] : [],
193
+ "-y"
194
+ ], {
195
+ stdio: "pipe",
196
+ timeout: 12e4
197
+ });
198
+ } catch {
199
+ allOk = false;
200
+ }
201
+ return allOk;
248
202
  }
203
+ //#endregion
204
+ export { SKILL_REFERENCE_URLS, ensureSkillsUpToDate, getSkillList, installAgentSkills };