neon-init 0.20.1 → 0.20.2

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.
@@ -25,7 +25,7 @@ async function handleGettingStartedPhase(options) {
25
25
  id: "select_or_create_project",
26
26
  description: [
27
27
  "List existing Neon projects in the selected organization using the CLI command below (replace <org-id> with the selected org ID).",
28
- "IMPORTANT: Preview features require a project in the AWS us-east-2 region created on or after 2026-06-15.",
28
+ "IMPORTANT: Neon platform features (Functions, Object Storage, and AI Gateway) are currently in beta and only available in the AWS us-east-2 region (more regions coming shortly). Projects must have region_id 'aws-us-east-2' and be created on or after 2026-06-15.",
29
29
  "Filter the project list to ONLY show projects where region_id is 'aws-us-east-2' AND created_at is on or after '2026-06-15'.",
30
30
  "If eligible projects exist, present them alongside a 'Create new project' option.",
31
31
  "If no eligible projects exist, tell the user and proceed directly to creating a new one.",
@@ -1 +1 @@
1
- {"version":3,"file":"getting-started.js","names":[],"sources":["../../../src/lib/phases/getting-started.ts"],"sourcesContent":["import { neonctlCmd } from \"../neonctl.js\";\nimport { ensureSkillsUpToDate, SKILL_REFERENCE_URLS } from \"../skills.js\";\nimport type { PhaseResponse } from \"../types.js\";\n\nexport interface GettingStartedPhaseOptions {\n\tagent?: string;\n\thasConnectionString?: boolean;\n\tframework?: string;\n\torm?: string;\n\tmigrationTool?: string;\n\tmigrationDir?: string;\n\t/** Neon features required by the project (from .neon or template) */\n\tfeatures?: string[];\n\t/** Preview mode — restricts project creation to new projects in AWS us-east */\n\tpreview?: boolean;\n}\n\n/**\n * Initiates the \"Get started with Neon\" workflow.\n *\n * Steps are concrete and executable — each has a CLI command to run\n * or a specific file operation. The agent should attempt each step\n * in order and actually perform the action using the Neon CLI.\n */\nexport async function handleGettingStartedPhase(\n\toptions: GettingStartedPhaseOptions,\n): Promise<PhaseResponse> {\n\t// Ensure skills are up to date (no-op if recently updated)\n\tif (options.agent) {\n\t\tawait ensureSkillsUpToDate(options.agent);\n\t}\n\tconst steps: { id: string; description: string; command?: string }[] = [];\n\n\tif (!options.hasConnectionString) {\n\t\tif (options.preview) {\n\t\t\t// Preview mode: new project in AWS us-east-2, or existing eligible project\n\t\t\tsteps.push(\n\t\t\t\t{\n\t\t\t\t\tid: \"select_org\",\n\t\t\t\t\tdescription: [\n\t\t\t\t\t\t\"List the user's Neon organizations using the CLI command below.\",\n\t\t\t\t\t\t\"If only one org exists, use it automatically.\",\n\t\t\t\t\t\t\"If multiple orgs exist, ask the user which one to use.\",\n\t\t\t\t\t\t\"Remember the selected org ID for the next steps.\",\n\t\t\t\t\t].join(\" \"),\n\t\t\t\t\tcommand: `${neonctlCmd()} orgs list --output json`,\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tid: \"select_or_create_project\",\n\t\t\t\t\tdescription: [\n\t\t\t\t\t\t\"List existing Neon projects in the selected organization using the CLI command below (replace <org-id> with the selected org ID).\",\n\t\t\t\t\t\t\"IMPORTANT: Preview features require a project in the AWS us-east-2 region created on or after 2026-06-15.\",\n\t\t\t\t\t\t\"Filter the project list to ONLY show projects where region_id is 'aws-us-east-2' AND created_at is on or after '2026-06-15'.\",\n\t\t\t\t\t\t\"If eligible projects exist, present them alongside a 'Create new project' option.\",\n\t\t\t\t\t\t\"If no eligible projects exist, tell the user and proceed directly to creating a new one.\",\n\t\t\t\t\t\t\"IMPORTANT: Always include --org-id when creating a project to avoid interactive prompts.\",\n\t\t\t\t\t].join(\" \"),\n\t\t\t\t\tcommand: `${neonctlCmd()} projects list --org-id <org-id> --output json`,\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tid: \"create_project_if_needed\",\n\t\t\t\t\tdescription: [\n\t\t\t\t\t\t\"If the user chose to create a new project, create it in the AWS us-east-2 region using the CLI command below (replace <org-id> and <project-name>).\",\n\t\t\t\t\t\t\"Ask the user for a project name (suggest the current directory name).\",\n\t\t\t\t\t\t\"If the user chose an existing eligible project, skip this step.\",\n\t\t\t\t\t].join(\" \"),\n\t\t\t\t\tcommand: `${neonctlCmd()} projects create --name <project-name> --org-id <org-id> --region-id aws-us-east-2 --output json`,\n\t\t\t\t},\n\t\t\t);\n\t\t} else {\n\t\t\t// Standard mode: let user choose existing or create new\n\t\t\tsteps.push(\n\t\t\t\t{\n\t\t\t\t\tid: \"select_org\",\n\t\t\t\t\tdescription: [\n\t\t\t\t\t\t\"List the user's Neon organizations using the CLI command below.\",\n\t\t\t\t\t\t\"If only one org exists, use it automatically.\",\n\t\t\t\t\t\t\"If multiple orgs exist, ask the user which one to use.\",\n\t\t\t\t\t\t\"Remember the selected org ID for the next steps.\",\n\t\t\t\t\t].join(\" \"),\n\t\t\t\t\tcommand: `${neonctlCmd()} orgs list --output json`,\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tid: \"select_or_create_project\",\n\t\t\t\t\tdescription: [\n\t\t\t\t\t\t\"List existing Neon projects in the selected organization using the CLI command below (replace <org-id> with the selected org ID).\",\n\t\t\t\t\t\t\"Ask the user whether they want to use an existing project or create a new one.\",\n\t\t\t\t\t\t\"If creating new, ask the user for a project name (suggest the current directory name).\",\n\t\t\t\t\t\t\"IMPORTANT: Always include --org-id when creating a project to avoid interactive prompts.\",\n\t\t\t\t\t].join(\" \"),\n\t\t\t\t\tcommand: `${neonctlCmd()} projects list --org-id <org-id> --output json`,\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tid: \"create_project_if_needed\",\n\t\t\t\t\tdescription: [\n\t\t\t\t\t\t\"If the user chose to create a new project, create it using the CLI command below (replace <org-id> and <project-name>).\",\n\t\t\t\t\t\t\"If the user chose an existing project, skip this step.\",\n\t\t\t\t\t].join(\" \"),\n\t\t\t\t\tcommand: `${neonctlCmd()} projects create --name <project-name> --org-id <org-id> --output json`,\n\t\t\t\t},\n\t\t\t);\n\t\t}\n\n\t\t// Create/update .neon context file\n\t\tsteps.push({\n\t\t\tid: \"create_neon_context\",\n\t\t\tdescription: [\n\t\t\t\t\"Update the .neon context file in the project root with the selected org and project IDs.\",\n\t\t\t\t\"IMPORTANT: If a .neon file already exists, you MUST read it first, then merge the new orgId and projectId into the existing content. Do NOT overwrite the file — other fields (like _init, branch, etc.) must be preserved.\",\n\t\t\t\t\"If no .neon file exists, create one.\",\n\t\t\t\t'The file is JSON. Add/update only the orgId and projectId fields: {\"orgId\": \"<org-id>\", \"projectId\": \"<project-id>\", ...existing fields}.',\n\t\t\t\t\"This file is safe to commit — it contains no secrets.\",\n\t\t\t].join(\" \"),\n\t\t});\n\n\t\t// Install project dependencies (required before env pull — config files may import packages)\n\t\tsteps.push({\n\t\t\tid: \"install_dependencies\",\n\t\t\tdescription: [\n\t\t\t\t\"Check if node_modules exists in the project root.\",\n\t\t\t\t\"If not, install project dependencies using the appropriate package manager (check for pnpm-lock.yaml, yarn.lock, bun.lockb, or default to npm).\",\n\t\t\t\t\"This must be done before `neon env pull` because the project's Neon config file may import packages that need to be installed first.\",\n\t\t\t].join(\" \"),\n\t\t\tcommand: \"npm install\",\n\t\t});\n\n\t\t// Pull environment variables (connection string, etc.) from Neon\n\t\tsteps.push({\n\t\t\tid: \"pull_env\",\n\t\t\tdescription: [\n\t\t\t\t\"Now that the .neon context file is in place and dependencies are installed, run `neon env pull` to populate the project's environment variables.\",\n\t\t\t\t\"This automatically writes the database connection string (and any other Neon-managed env vars) to the correct env file.\",\n\t\t\t\t\"It reads the .neon context file to determine the project, and writes to the appropriate env file for the project.\",\n\t\t\t\t\"Ensure the target env file is listed in .gitignore.\",\n\t\t\t].join(\" \"),\n\t\t\tcommand: `${neonctlCmd()} env pull`,\n\t\t});\n\n\t\t// Step 6: Install Neon serverless driver if needed\n\t\tif (options.orm === \"prisma\") {\n\t\t\tsteps.push({\n\t\t\t\tid: \"install_driver\",\n\t\t\t\tdescription: [\n\t\t\t\t\t\"Install the @neondatabase/serverless driver adapter for Prisma.\",\n\t\t\t\t\t\"This enables Prisma to use Neon's serverless driver for edge/serverless deployments.\",\n\t\t\t\t].join(\" \"),\n\t\t\t\tcommand:\n\t\t\t\t\t\"npm install @neondatabase/serverless @prisma/adapter-neon\",\n\t\t\t});\n\t\t} else if (options.orm === \"drizzle\" || options.orm === \"drizzle-orm\") {\n\t\t\tsteps.push({\n\t\t\t\tid: \"install_driver\",\n\t\t\t\tdescription: \"Install the Neon serverless driver for Drizzle.\",\n\t\t\t\tcommand: \"npm install @neondatabase/serverless\",\n\t\t\t});\n\t\t} else if (!options.orm || options.orm === \"none\") {\n\t\t\tsteps.push({\n\t\t\t\tid: \"install_driver\",\n\t\t\t\tdescription:\n\t\t\t\t\t\"Install the Neon serverless driver for direct database access.\",\n\t\t\t\tcommand: \"npm install @neondatabase/serverless\",\n\t\t\t});\n\t\t}\n\t}\n\n\t// Run migrations if applicable\n\tif (options.migrationTool && options.migrationTool !== \"none\") {\n\t\tconst tool = options.migrationTool.toLowerCase();\n\t\tconst migrationDir = options.migrationDir;\n\t\tconst hasMigrationDir = migrationDir && migrationDir !== \"none\";\n\n\t\tif (tool === \"drizzle\") {\n\t\t\tsteps.push({\n\t\t\t\tid: \"run_migrations\",\n\t\t\t\tdescription: [\n\t\t\t\t\thasMigrationDir\n\t\t\t\t\t\t? `Check if the ${migrationDir} directory contains .sql migration files.`\n\t\t\t\t\t\t: \"Check if a drizzle migrations directory exists with .sql files.\",\n\t\t\t\t\t\"If .sql files exist, apply them with `npx drizzle-kit migrate`.\",\n\t\t\t\t\t\"If the directory is empty or missing but a drizzle schema file exists (e.g. src/db/schema.ts, drizzle/schema.ts), run `npx drizzle-kit generate` first to create migrations, then `npx drizzle-kit migrate` to apply them.\",\n\t\t\t\t\t\"If neither schema nor migrations exist, skip this step.\",\n\t\t\t\t].join(\" \"),\n\t\t\t\tcommand: \"npx drizzle-kit migrate\",\n\t\t\t});\n\t\t} else if (tool === \"prisma\") {\n\t\t\tsteps.push({\n\t\t\t\tid: \"run_migrations\",\n\t\t\t\tdescription: [\n\t\t\t\t\thasMigrationDir\n\t\t\t\t\t\t? `Check if the ${migrationDir} directory contains migration folders.`\n\t\t\t\t\t\t: \"Check if prisma/migrations contains migration folders.\",\n\t\t\t\t\t\"If migrations exist, apply them with `npx prisma migrate deploy`.\",\n\t\t\t\t\t\"If the migrations directory is empty or missing but prisma/schema.prisma has models defined, run `npx prisma migrate dev --name init` to create and apply the initial migration.\",\n\t\t\t\t\t\"If no models are defined, skip this step.\",\n\t\t\t\t].join(\" \"),\n\t\t\t\tcommand: \"npx prisma migrate deploy\",\n\t\t\t});\n\t\t} else if (tool === \"knex\") {\n\t\t\tsteps.push({\n\t\t\t\tid: \"run_migrations\",\n\t\t\t\tdescription: `Apply existing knex migrations to the Neon database.`,\n\t\t\t\tcommand: \"npx knex migrate:latest\",\n\t\t\t});\n\t\t}\n\t} else if (options.preview) {\n\t\t// Bootstrap flow: migration tool wasn't detected because the project was\n\t\t// inspected before scaffolding. Detect and run migrations from the scaffolded template.\n\t\tsteps.push({\n\t\t\tid: \"run_migrations\",\n\t\t\tdescription: [\n\t\t\t\t\"Check the scaffolded project for a migration tool and schema.\",\n\t\t\t\t\"Look for: drizzle.config.ts/js (Drizzle), prisma/schema.prisma (Prisma), or knexfile.ts/js (Knex).\",\n\t\t\t\t\"If Drizzle is found: check if a drizzle migrations directory exists with .sql files. If .sql files exist, run `npx drizzle-kit migrate`. If the directory is empty or missing but a schema file exists, run `npx drizzle-kit generate` first, then `npx drizzle-kit migrate`.\",\n\t\t\t\t\"If Prisma is found: check if prisma/migrations contains migration folders. If yes, run `npx prisma migrate deploy`. If not but models exist, run `npx prisma migrate dev --name init`.\",\n\t\t\t\t\"If no migration tool is found, skip this step.\",\n\t\t\t].join(\" \"),\n\t\t});\n\t}\n\n\t// Verify the connection\n\tsteps.push({\n\t\tid: \"verify_connection\",\n\t\tdescription: [\n\t\t\t\"Verify the database connection works by running a SQL query against the Neon database.\",\n\t\t\t\"Write and run a short script that connects using DATABASE_URL from the project's env file and executes `SELECT 1` (or queries a table from the migration if migrations were run).\",\n\t\t\t\"Do NOT use the Neon CLI or MCP tools for this — use a direct database connection to verify end-to-end connectivity.\",\n\t\t].join(\" \"),\n\t});\n\n\treturn {\n\t\tphase: \"setup\",\n\t\tstatus: \"getting_started\",\n\t\tnextAction: {\n\t\t\ttype: \"agent_action\",\n\t\t\tprerequisite: SKILL_REFERENCE_URLS.gettingStarted,\n\t\t\tsteps,\n\t\t\tonComplete: buildOnComplete(options),\n\t\t},\n\t};\n}\n\nfunction buildOnComplete(\n\toptions: GettingStartedPhaseOptions,\n): import(\"../types.js\").RunNeonInitAction {\n\tconst agentArgs = options.agent ? [\"--agent\", options.agent] : [];\n\tconst features = options.features ?? [];\n\tconst hasFeatureRequirements = features.length > 0;\n\n\t// If features are specified and auth is not required, go to finalize\n\tif (hasFeatureRequirements && !features.includes(\"auth\")) {\n\t\treturn {\n\t\t\ttype: \"run_neon_init\",\n\t\t\targs: [\"finalize\", \"--json\", ...agentArgs],\n\t\t};\n\t}\n\n\t// Chain to neon-auth — if user already selected auth via features, go straight to setup\n\tconst authSetup =\n\t\thasFeatureRequirements && features.includes(\"auth\") ? [\"--setup\"] : [];\n\treturn {\n\t\ttype: \"run_neon_init\",\n\t\targs: [\"neon-auth\", \"--json\", ...agentArgs, ...authSetup],\n\t};\n}\n"],"mappings":";;;;;;;;;;AAwBA,eAAsB,0BACrB,SACyB;CAEzB,IAAI,QAAQ,OACX,MAAM,qBAAqB,QAAQ,KAAK;CAEzC,MAAM,QAAiE,CAAC;CAExE,IAAI,CAAC,QAAQ,qBAAqB;EACjC,IAAI,QAAQ,SAEX,MAAM,KACL;GACC,IAAI;GACJ,aAAa;IACZ;IACA;IACA;IACA;GACD,CAAC,CAAC,KAAK,GAAG;GACV,SAAS,GAAG,WAAW,EAAE;EAC1B,GACA;GACC,IAAI;GACJ,aAAa;IACZ;IACA;IACA;IACA;IACA;IACA;GACD,CAAC,CAAC,KAAK,GAAG;GACV,SAAS,GAAG,WAAW,EAAE;EAC1B,GACA;GACC,IAAI;GACJ,aAAa;IACZ;IACA;IACA;GACD,CAAC,CA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ting-started.js","names":[],"sources":["../../../src/lib/phases/getting-started.ts"],"sourcesContent":["import { neonctlCmd } from \"../neonctl.js\";\nimport { ensureSkillsUpToDate, SKILL_REFERENCE_URLS } from \"../skills.js\";\nimport type { PhaseResponse } from \"../types.js\";\n\nexport interface GettingStartedPhaseOptions {\n\tagent?: string;\n\thasConnectionString?: boolean;\n\tframework?: string;\n\torm?: string;\n\tmigrationTool?: string;\n\tmigrationDir?: string;\n\t/** Neon features required by the project (from .neon or template) */\n\tfeatures?: string[];\n\t/** Preview mode — restricts project creation to new projects in AWS us-east */\n\tpreview?: boolean;\n}\n\n/**\n * Initiates the \"Get started with Neon\" workflow.\n *\n * Steps are concrete and executable — each has a CLI command to run\n * or a specific file operation. The agent should attempt each step\n * in order and actually perform the action using the Neon CLI.\n */\nexport async function handleGettingStartedPhase(\n\toptions: GettingStartedPhaseOptions,\n): Promise<PhaseResponse> {\n\t// Ensure skills are up to date (no-op if recently updated)\n\tif (options.agent) {\n\t\tawait ensureSkillsUpToDate(options.agent);\n\t}\n\tconst steps: { id: string; description: string; command?: string }[] = [];\n\n\tif (!options.hasConnectionString) {\n\t\tif (options.preview) {\n\t\t\t// Public beta: platform features are only in AWS us-east-2 for now\n\t\t\tsteps.push(\n\t\t\t\t{\n\t\t\t\t\tid: \"select_org\",\n\t\t\t\t\tdescription: [\n\t\t\t\t\t\t\"List the user's Neon organizations using the CLI command below.\",\n\t\t\t\t\t\t\"If only one org exists, use it automatically.\",\n\t\t\t\t\t\t\"If multiple orgs exist, ask the user which one to use.\",\n\t\t\t\t\t\t\"Remember the selected org ID for the next steps.\",\n\t\t\t\t\t].join(\" \"),\n\t\t\t\t\tcommand: `${neonctlCmd()} orgs list --output json`,\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tid: \"select_or_create_project\",\n\t\t\t\t\tdescription: [\n\t\t\t\t\t\t\"List existing Neon projects in the selected organization using the CLI command below (replace <org-id> with the selected org ID).\",\n\t\t\t\t\t\t\"IMPORTANT: Neon platform features (Functions, Object Storage, and AI Gateway) are currently in beta and only available in the AWS us-east-2 region (more regions coming shortly). Projects must have region_id 'aws-us-east-2' and be created on or after 2026-06-15.\",\n\t\t\t\t\t\t\"Filter the project list to ONLY show projects where region_id is 'aws-us-east-2' AND created_at is on or after '2026-06-15'.\",\n\t\t\t\t\t\t\"If eligible projects exist, present them alongside a 'Create new project' option.\",\n\t\t\t\t\t\t\"If no eligible projects exist, tell the user and proceed directly to creating a new one.\",\n\t\t\t\t\t\t\"IMPORTANT: Always include --org-id when creating a project to avoid interactive prompts.\",\n\t\t\t\t\t].join(\" \"),\n\t\t\t\t\tcommand: `${neonctlCmd()} projects list --org-id <org-id> --output json`,\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tid: \"create_project_if_needed\",\n\t\t\t\t\tdescription: [\n\t\t\t\t\t\t\"If the user chose to create a new project, create it in the AWS us-east-2 region using the CLI command below (replace <org-id> and <project-name>).\",\n\t\t\t\t\t\t\"Ask the user for a project name (suggest the current directory name).\",\n\t\t\t\t\t\t\"If the user chose an existing eligible project, skip this step.\",\n\t\t\t\t\t].join(\" \"),\n\t\t\t\t\tcommand: `${neonctlCmd()} projects create --name <project-name> --org-id <org-id> --region-id aws-us-east-2 --output json`,\n\t\t\t\t},\n\t\t\t);\n\t\t} else {\n\t\t\t// Standard mode: let user choose existing or create new\n\t\t\tsteps.push(\n\t\t\t\t{\n\t\t\t\t\tid: \"select_org\",\n\t\t\t\t\tdescription: [\n\t\t\t\t\t\t\"List the user's Neon organizations using the CLI command below.\",\n\t\t\t\t\t\t\"If only one org exists, use it automatically.\",\n\t\t\t\t\t\t\"If multiple orgs exist, ask the user which one to use.\",\n\t\t\t\t\t\t\"Remember the selected org ID for the next steps.\",\n\t\t\t\t\t].join(\" \"),\n\t\t\t\t\tcommand: `${neonctlCmd()} orgs list --output json`,\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tid: \"select_or_create_project\",\n\t\t\t\t\tdescription: [\n\t\t\t\t\t\t\"List existing Neon projects in the selected organization using the CLI command below (replace <org-id> with the selected org ID).\",\n\t\t\t\t\t\t\"Ask the user whether they want to use an existing project or create a new one.\",\n\t\t\t\t\t\t\"If creating new, ask the user for a project name (suggest the current directory name).\",\n\t\t\t\t\t\t\"IMPORTANT: Always include --org-id when creating a project to avoid interactive prompts.\",\n\t\t\t\t\t].join(\" \"),\n\t\t\t\t\tcommand: `${neonctlCmd()} projects list --org-id <org-id> --output json`,\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tid: \"create_project_if_needed\",\n\t\t\t\t\tdescription: [\n\t\t\t\t\t\t\"If the user chose to create a new project, create it using the CLI command below (replace <org-id> and <project-name>).\",\n\t\t\t\t\t\t\"If the user chose an existing project, skip this step.\",\n\t\t\t\t\t].join(\" \"),\n\t\t\t\t\tcommand: `${neonctlCmd()} projects create --name <project-name> --org-id <org-id> --output json`,\n\t\t\t\t},\n\t\t\t);\n\t\t}\n\n\t\t// Create/update .neon context file\n\t\tsteps.push({\n\t\t\tid: \"create_neon_context\",\n\t\t\tdescription: [\n\t\t\t\t\"Update the .neon context file in the project root with the selected org and project IDs.\",\n\t\t\t\t\"IMPORTANT: If a .neon file already exists, you MUST read it first, then merge the new orgId and projectId into the existing content. Do NOT overwrite the file — other fields (like _init, branch, etc.) must be preserved.\",\n\t\t\t\t\"If no .neon file exists, create one.\",\n\t\t\t\t'The file is JSON. Add/update only the orgId and projectId fields: {\"orgId\": \"<org-id>\", \"projectId\": \"<project-id>\", ...existing fields}.',\n\t\t\t\t\"This file is safe to commit — it contains no secrets.\",\n\t\t\t].join(\" \"),\n\t\t});\n\n\t\t// Install project dependencies (required before env pull — config files may import packages)\n\t\tsteps.push({\n\t\t\tid: \"install_dependencies\",\n\t\t\tdescription: [\n\t\t\t\t\"Check if node_modules exists in the project root.\",\n\t\t\t\t\"If not, install project dependencies using the appropriate package manager (check for pnpm-lock.yaml, yarn.lock, bun.lockb, or default to npm).\",\n\t\t\t\t\"This must be done before `neon env pull` because the project's Neon config file may import packages that need to be installed first.\",\n\t\t\t].join(\" \"),\n\t\t\tcommand: \"npm install\",\n\t\t});\n\n\t\t// Pull environment variables (connection string, etc.) from Neon\n\t\tsteps.push({\n\t\t\tid: \"pull_env\",\n\t\t\tdescription: [\n\t\t\t\t\"Now that the .neon context file is in place and dependencies are installed, run `neon env pull` to populate the project's environment variables.\",\n\t\t\t\t\"This automatically writes the database connection string (and any other Neon-managed env vars) to the correct env file.\",\n\t\t\t\t\"It reads the .neon context file to determine the project, and writes to the appropriate env file for the project.\",\n\t\t\t\t\"Ensure the target env file is listed in .gitignore.\",\n\t\t\t].join(\" \"),\n\t\t\tcommand: `${neonctlCmd()} env pull`,\n\t\t});\n\n\t\t// Step 6: Install Neon serverless driver if needed\n\t\tif (options.orm === \"prisma\") {\n\t\t\tsteps.push({\n\t\t\t\tid: \"install_driver\",\n\t\t\t\tdescription: [\n\t\t\t\t\t\"Install the @neondatabase/serverless driver adapter for Prisma.\",\n\t\t\t\t\t\"This enables Prisma to use Neon's serverless driver for edge/serverless deployments.\",\n\t\t\t\t].join(\" \"),\n\t\t\t\tcommand:\n\t\t\t\t\t\"npm install @neondatabase/serverless @prisma/adapter-neon\",\n\t\t\t});\n\t\t} else if (options.orm === \"drizzle\" || options.orm === \"drizzle-orm\") {\n\t\t\tsteps.push({\n\t\t\t\tid: \"install_driver\",\n\t\t\t\tdescription: \"Install the Neon serverless driver for Drizzle.\",\n\t\t\t\tcommand: \"npm install @neondatabase/serverless\",\n\t\t\t});\n\t\t} else if (!options.orm || options.orm === \"none\") {\n\t\t\tsteps.push({\n\t\t\t\tid: \"install_driver\",\n\t\t\t\tdescription:\n\t\t\t\t\t\"Install the Neon serverless driver for direct database access.\",\n\t\t\t\tcommand: \"npm install @neondatabase/serverless\",\n\t\t\t});\n\t\t}\n\t}\n\n\t// Run migrations if applicable\n\tif (options.migrationTool && options.migrationTool !== \"none\") {\n\t\tconst tool = options.migrationTool.toLowerCase();\n\t\tconst migrationDir = options.migrationDir;\n\t\tconst hasMigrationDir = migrationDir && migrationDir !== \"none\";\n\n\t\tif (tool === \"drizzle\") {\n\t\t\tsteps.push({\n\t\t\t\tid: \"run_migrations\",\n\t\t\t\tdescription: [\n\t\t\t\t\thasMigrationDir\n\t\t\t\t\t\t? `Check if the ${migrationDir} directory contains .sql migration files.`\n\t\t\t\t\t\t: \"Check if a drizzle migrations directory exists with .sql files.\",\n\t\t\t\t\t\"If .sql files exist, apply them with `npx drizzle-kit migrate`.\",\n\t\t\t\t\t\"If the directory is empty or missing but a drizzle schema file exists (e.g. src/db/schema.ts, drizzle/schema.ts), run `npx drizzle-kit generate` first to create migrations, then `npx drizzle-kit migrate` to apply them.\",\n\t\t\t\t\t\"If neither schema nor migrations exist, skip this step.\",\n\t\t\t\t].join(\" \"),\n\t\t\t\tcommand: \"npx drizzle-kit migrate\",\n\t\t\t});\n\t\t} else if (tool === \"prisma\") {\n\t\t\tsteps.push({\n\t\t\t\tid: \"run_migrations\",\n\t\t\t\tdescription: [\n\t\t\t\t\thasMigrationDir\n\t\t\t\t\t\t? `Check if the ${migrationDir} directory contains migration folders.`\n\t\t\t\t\t\t: \"Check if prisma/migrations contains migration folders.\",\n\t\t\t\t\t\"If migrations exist, apply them with `npx prisma migrate deploy`.\",\n\t\t\t\t\t\"If the migrations directory is empty or missing but prisma/schema.prisma has models defined, run `npx prisma migrate dev --name init` to create and apply the initial migration.\",\n\t\t\t\t\t\"If no models are defined, skip this step.\",\n\t\t\t\t].join(\" \"),\n\t\t\t\tcommand: \"npx prisma migrate deploy\",\n\t\t\t});\n\t\t} else if (tool === \"knex\") {\n\t\t\tsteps.push({\n\t\t\t\tid: \"run_migrations\",\n\t\t\t\tdescription: `Apply existing knex migrations to the Neon database.`,\n\t\t\t\tcommand: \"npx knex migrate:latest\",\n\t\t\t});\n\t\t}\n\t} else if (options.preview) {\n\t\t// Bootstrap flow: migration tool wasn't detected because the project was\n\t\t// inspected before scaffolding. Detect and run migrations from the scaffolded template.\n\t\tsteps.push({\n\t\t\tid: \"run_migrations\",\n\t\t\tdescription: [\n\t\t\t\t\"Check the scaffolded project for a migration tool and schema.\",\n\t\t\t\t\"Look for: drizzle.config.ts/js (Drizzle), prisma/schema.prisma (Prisma), or knexfile.ts/js (Knex).\",\n\t\t\t\t\"If Drizzle is found: check if a drizzle migrations directory exists with .sql files. If .sql files exist, run `npx drizzle-kit migrate`. If the directory is empty or missing but a schema file exists, run `npx drizzle-kit generate` first, then `npx drizzle-kit migrate`.\",\n\t\t\t\t\"If Prisma is found: check if prisma/migrations contains migration folders. If yes, run `npx prisma migrate deploy`. If not but models exist, run `npx prisma migrate dev --name init`.\",\n\t\t\t\t\"If no migration tool is found, skip this step.\",\n\t\t\t].join(\" \"),\n\t\t});\n\t}\n\n\t// Verify the connection\n\tsteps.push({\n\t\tid: \"verify_connection\",\n\t\tdescription: [\n\t\t\t\"Verify the database connection works by running a SQL query against the Neon database.\",\n\t\t\t\"Write and run a short script that connects using DATABASE_URL from the project's env file and executes `SELECT 1` (or queries a table from the migration if migrations were run).\",\n\t\t\t\"Do NOT use the Neon CLI or MCP tools for this — use a direct database connection to verify end-to-end connectivity.\",\n\t\t].join(\" \"),\n\t});\n\n\treturn {\n\t\tphase: \"setup\",\n\t\tstatus: \"getting_started\",\n\t\tnextAction: {\n\t\t\ttype: \"agent_action\",\n\t\t\tprerequisite: SKILL_REFERENCE_URLS.gettingStarted,\n\t\t\tsteps,\n\t\t\tonComplete: buildOnComplete(options),\n\t\t},\n\t};\n}\n\nfunction buildOnComplete(\n\toptions: GettingStartedPhaseOptions,\n): import(\"../types.js\").RunNeonInitAction {\n\tconst agentArgs = options.agent ? [\"--agent\", options.agent] : [];\n\tconst features = options.features ?? [];\n\tconst hasFeatureRequirements = features.length > 0;\n\n\t// If features are specified and auth is not required, go to finalize\n\tif (hasFeatureRequirements && !features.includes(\"auth\")) {\n\t\treturn {\n\t\t\ttype: \"run_neon_init\",\n\t\t\targs: [\"finalize\", \"--json\", ...agentArgs],\n\t\t};\n\t}\n\n\t// Chain to neon-auth — if user already selected auth via features, go straight to setup\n\tconst authSetup =\n\t\thasFeatureRequirements && features.includes(\"auth\") ? [\"--setup\"] : [];\n\treturn {\n\t\ttype: \"run_neon_init\",\n\t\targs: [\"neon-auth\", \"--json\", ...agentArgs, ...authSetup],\n\t};\n}\n"],"mappings":";;;;;;;;;;AAwBA,eAAsB,0BACrB,SACyB;CAEzB,IAAI,QAAQ,OACX,MAAM,qBAAqB,QAAQ,KAAK;CAEzC,MAAM,QAAiE,CAAC;CAExE,IAAI,CAAC,QAAQ,qBAAqB;EACjC,IAAI,QAAQ,SAEX,MAAM,KACL;GACC,IAAI;GACJ,aAAa;IACZ;IACA;IACA;IACA;GACD,CAAC,CAAC,KAAK,GAAG;GACV,SAAS,GAAG,WAAW,EAAE;EAC1B,GACA;GACC,IAAI;GACJ,aAAa;IACZ;IACA;IACA;IACA;IACA;IACA;GACD,CAAC,CAAC,KAAK,GAAG;GACV,SAAS,GAAG,WAAW,EAAE;EAC1B,GACA;GACC,IAAI;GACJ,aAAa;IACZ;IACA;IACA;GACD,CAAC,CAAC,KAAK,GAAG;GACV,SAAS,GAAG,WAAW,EAAE;EAC1B,CACD;OAGA,MAAM,KACL;GACC,IAAI;GACJ,aAAa;IACZ;IACA;IACA;IACA;GACD,CAAC,CAAC,KAAK,GAAG;GACV,SAAS,GAAG,WAAW,EAAE;EAC1B,GACA;GACC,IAAI;GACJ,aAAa;IACZ;IACA;IACA;IACA;GACD,CAAC,CAAC,KAAK,GAAG;GACV,SAAS,GAAG,WAAW,EAAE;EAC1B,GACA;GACC,IAAI;GACJ,aAAa,CACZ,2HACA,wDACD,CAAC,CAAC,KAAK,GAAG;GACV,SAAS,GAAG,WAAW,EAAE;EAC1B,CACD;EAID,MAAM,KAAK;GACV,IAAI;GACJ,aAAa;IACZ;IACA;IACA;IACA;IACA;GACD,CAAC,CAAC,KAAK,GAAG;EACX,CAAC;EAGD,MAAM,KA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AAC,KAAK,GAAG;CACX,CAAC;CAIF,MAAM,KAAK;EACV,IAAI;EACJ,aAAa;GACZ;GACA;GACA;EACD,CAAC,CAAC,KAAK,GAAG;CACX,CAAC;CAED,OAAO;EACN,OAAO;EACP,QAAQ;EACR,YAAY;GACX,MAAM;GACN,cAAc,qBAAqB;GACnC;GACA,YAAY,gBAAgB,OAAO;EACpC;CACD;AACD;AAEA,SAAS,gBACR,SAC0C;CAC1C,MAAM,YAAY,QAAQ,QAAQ,CAAC,WAAW,QAAQ,KAAK,IAAI,CAAC;CAChE,MAAM,WAAW,QAAQ,YAAY,CAAC;CACtC,MAAM,yBAAyB,SAAS,SAAS;CAGjD,IAAI,0BAA0B,CAAC,SAAS,SAAS,MAAM,GACtD,OAAO;EACN,MAAM;EACN,MAAM;GAAC;GAAY;GAAU,GAAG;EAAS;CAC1C;CAID,MAAM,YACL,0BAA0B,SAAS,SAAS,MAAM,IAAI,CAAC,SAAS,IAAI,CAAC;CACtE,OAAO;EACN,MAAM;EACN,MAAM;GAAC;GAAa;GAAU,GAAG;GAAW,GAAG;EAAS;CACzD;AACD"}
@@ -162,7 +162,8 @@ function skillsAreFresh(agent, requiredSkills) {
162
162
  if (requiredSkills.every((skill) => projectSkillDirs.some((dir) => existsSync(resolve(cwd, dir, "skills", skill, "SKILL.md"))))) return true;
163
163
  }
164
164
  } catch {}
165
- const globalDirs = GLOBAL_SKILLS_DIRS[getSkillsAgentName(agent)] ?? [];
165
+ const agentName = getSkillsAgentName(agent);
166
+ const globalDirs = GLOBAL_SKILLS_DIRS[agentName] ?? [];
166
167
  for (const dir of globalDirs) if (requiredSkills.every((skill) => existsSync(resolve(dir, skill, "SKILL.md")))) try {
167
168
  if (now - statSync(resolve(dir, requiredSkills[0], "SKILL.md")).mtimeMs < SKILLS_FRESHNESS_MS) return true;
168
169
  } catch {}
@@ -1 +1 @@
1
- {"version":3,"file":"skills.js","names":["getSkillsAgentNameFromId"],"sources":["../../src/lib/skills.ts"],"sourcesContent":["import { existsSync, statSync } from \"node:fs\";\nimport { resolve } from \"node:path\";\nimport { log, spinner } from \"@clack/prompts\";\nimport { execa } from \"execa\";\nimport { dim } from \"yoctocolors\";\nimport { getSkillsAgentName as getSkillsAgentNameFromId } from \"./agents.js\";\nimport type { Editor } from \"./types.js\";\n\n/**\n * Ensures the `skills` CLI is globally installed so npx doesn't need\n * to download it (which can fail behind corporate proxies / sandboxes).\n */\nasync function ensureSkillsCli(): Promise<void> {\n\ttry {\n\t\tawait execa(\"skills\", [\"--version\"], { stdio: \"pipe\", timeout: 5000 });\n\t} catch {\n\t\t// Not installed — install it globally\n\t\ttry {\n\t\t\tawait execa(\"npm\", [\"install\", \"-g\", \"skills\"], {\n\t\t\t\tstdio: \"pipe\",\n\t\t\t\ttimeout: 60000,\n\t\t\t});\n\t\t} catch {\n\t\t\t// Best effort — npx will fall back to downloading\n\t\t}\n\t}\n}\n\n/** Base skills installed for all invocations */\nconst BASE_SKILLS = [\"neon\", \"neon-postgres\"];\n\n/** Additional skills installed for preview (non-bootstrap) invocations */\nconst PREVIEW_SKILLS = [\n\t\"neon-object-storage\",\n\t\"neon-functions\",\n\t\"neon-ai-gateway\",\n];\n\n/** Returns the skill list based on whether preview mode is active */\nexport function getSkillList(preview?: boolean): string[] {\n\treturn preview ? [...BASE_SKILLS, ...PREVIEW_SKILLS] : BASE_SKILLS;\n}\n\nconst SKILL_BASE_URL =\n\t\"https://neon.com/docs/ai/skills/neon-postgres/references\";\n\nexport const SKILL_REFERENCE_URLS: Record<string, string> = {\n\tgettingStarted: `${SKILL_BASE_URL}/getting-started.md`,\n\tconnectionMethods: `${SKILL_BASE_URL}/connection-methods.md`,\n\tneonAuth: `${SKILL_BASE_URL}/neon-auth.md`,\n\tserverlessDriver: `${SKILL_BASE_URL}/neon-serverless.md`,\n\tneonCli: `${SKILL_BASE_URL}/neon-cli.md`,\n\tdevtools: `${SKILL_BASE_URL}/devtools.md`,\n\tbranching: `${SKILL_BASE_URL}/branching.md`,\n\tneonJs: `${SKILL_BASE_URL}/neon-js.md`,\n};\n\n/**\n * Fetches the \"Getting Started with Neon\" skill content from the public URL.\n * Returns the markdown content, or null if the fetch fails.\n */\nexport async function fetchSkillContent(): Promise<string | null> {\n\ttry {\n\t\tconst response = await fetch(SKILL_REFERENCE_URLS.gettingStarted, {\n\t\t\tsignal: AbortSignal.timeout(10000),\n\t\t});\n\t\tif (!response.ok) return null;\n\t\treturn await response.text();\n\t} catch {\n\t\treturn null;\n\t}\n}\n\n/**\n * Maps Editor display names to the skills CLI agent name.\n * Used only by the v1 installAgentSkills function.\n */\nfunction editorToSkillsAgent(editor: Editor): string {\n\tswitch (editor) {\n\t\tcase \"Cursor\":\n\t\t\treturn \"cursor\";\n\t\tcase \"VS Code\":\n\t\tcase \"GitHub Copilot CLI\":\n\t\t\treturn \"github-copilot\";\n\t\tcase \"Claude CLI\":\n\t\t\treturn \"claude-code\";\n\t\tcase \"Codex\":\n\t\t\treturn \"codex\";\n\t\tcase \"OpenCode\":\n\t\t\treturn \"opencode\";\n\t\tcase \"Antigravity\":\n\t\t\treturn \"antigravity\";\n\t\tcase \"Cline\":\n\t\tcase \"Cline CLI\":\n\t\t\treturn \"cline\";\n\t\tcase \"Gemini CLI\":\n\t\t\treturn \"gemini-cli\";\n\t\tcase \"Goose\":\n\t\t\treturn \"goose\";\n\t\tcase \"Claude Desktop\":\n\t\t\treturn \"claude-code\";\n\t\tcase \"MCPorter\":\n\t\t\treturn \"mcporter\";\n\t\tcase \"Zed\":\n\t\t\treturn \"zed\";\n\t\tdefault:\n\t\t\treturn \"\";\n\t}\n}\n\nexport interface InstallSkillsOptions {\n\tjson?: boolean;\n\tscope?: \"global\" | \"project\";\n\tpreview?: boolean;\n}\n\n/**\n * Installs Neon agent skills using Vercel's skills CLI.\n */\nexport async function installAgentSkills(\n\tselectedEditors: Editor[],\n\toptions?: InstallSkillsOptions,\n): Promise<boolean> {\n\tconst quiet = options?.json === true;\n\n\tconst editorsWithSkills = selectedEditors.filter(\n\t\t(e) => editorToSkillsAgent(e) !== \"\",\n\t);\n\n\tif (editorsWithSkills.length === 0) {\n\t\treturn true;\n\t}\n\n\tconst skillsSpinner = quiet ? null : spinner();\n\tskillsSpinner?.start(\"Installing agent skills for Neon in this project...\");\n\n\tlet anyFailed = false;\n\n\tawait ensureSkillsCli();\n\tconst skills = getSkillList(options?.preview);\n\n\tfor (const editor of editorsWithSkills) {\n\t\tconst agentName = editorToSkillsAgent(editor);\n\n\t\t// Install one skill at a time — the skills CLI has a bug with multiple\n\t\t// --skill flags where it creates directories but doesn't copy all SKILL.md files.\n\t\tfor (const skill of skills) {\n\t\t\ttry {\n\t\t\t\tawait execa(\n\t\t\t\t\t\"skills\",\n\t\t\t\t\t[\n\t\t\t\t\t\t\"add\",\n\t\t\t\t\t\t\"neondatabase/agent-skills\",\n\t\t\t\t\t\t\"--skill\",\n\t\t\t\t\t\tskill,\n\t\t\t\t\t\t\"--agent\",\n\t\t\t\t\t\tagentName,\n\t\t\t\t\t\t...(options?.scope === \"global\" ? [\"-g\"] : []),\n\t\t\t\t\t\t\"-y\",\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: 120000,\n\t\t\t\t\t},\n\t\t\t\t);\n\t\t\t} catch (error) {\n\t\t\t\tif (!quiet)\n\t\t\t\t\tlog.error(\n\t\t\t\t\t\t`Failed to install skill ${skill} for ${editor}: ${error instanceof Error ? error.message : \"Unknown error\"}`,\n\t\t\t\t\t);\n\t\t\t\tanyFailed = true;\n\t\t\t}\n\t\t}\n\t}\n\n\tif (anyFailed) {\n\t\tskillsSpinner?.stop(\n\t\t\t\"Agent skills installation for this project completed with errors\",\n\t\t);\n\t\tif (!quiet)\n\t\t\tlog.info(\n\t\t\t\t\"You can manually install skills by running: npx skills add neondatabase/agent-skills --skill neon --skill neon-postgres\",\n\t\t\t);\n\t\treturn false;\n\t}\n\n\tskillsSpinner?.stop(dim(\"Agent skills installed ✓\"));\n\treturn true;\n}\n\n// ---------------------------------------------------------------------------\n// Evergreen skills: ensure skills are up to date (at most once per 12 hours)\n// ---------------------------------------------------------------------------\n\nconst SKILLS_FRESHNESS_MS = 12 * 60 * 60 * 1000; // 12 hours\n\n/**\n * Agent skills directory paths by agent, keyed by scope.\n * These are the directories that `skills add` writes to.\n */\nconst GLOBAL_SKILLS_DIRS: Record<string, string[]> = (() => {\n\tconst home = process.env.HOME || process.env.USERPROFILE || \"\";\n\t// .agents/skills is the generic directory used by multiple agents\n\tconst agentsDir = resolve(home, \".agents\", \"skills\");\n\treturn {\n\t\tcursor: [resolve(home, \".cursor\", \"skills\"), agentsDir],\n\t\t\"claude-code\": [resolve(home, \".claude\", \"skills\"), agentsDir],\n\t\t\"github-copilot\": [resolve(home, \".vscode\", \"skills\"), agentsDir],\n\t\tcodex: [resolve(home, \".codex\", \"skills\"), agentsDir],\n\t\tcline: [resolve(home, \".cline\", \"skills\"), agentsDir],\n\t};\n})();\n\n/**\n * Checks whether skills were recently updated (within the freshness window).\n * Checks both project-level (skills-lock.json mtime) and global (skills dir mtime).\n */\nfunction skillsAreFresh(agent: string, requiredSkills: string[]): boolean {\n\tconst now = Date.now();\n\tconst cwd = process.cwd();\n\tconst projectSkillDirs = [\".agents\", \".cursor\", \".claude\"];\n\n\t// Check project-level: ALL required skills must exist on disk\n\t// and skills-lock.json must be recent\n\tconst lockPath = resolve(cwd, \"skills-lock.json\");\n\tif (existsSync(lockPath)) {\n\t\ttry {\n\t\t\tconst mtime = statSync(lockPath).mtimeMs;\n\t\t\tif (now - mtime < SKILLS_FRESHNESS_MS) {\n\t\t\t\tconst allExist = requiredSkills.every((skill) =>\n\t\t\t\t\tprojectSkillDirs.some((dir) =>\n\t\t\t\t\t\texistsSync(\n\t\t\t\t\t\t\tresolve(cwd, dir, \"skills\", skill, \"SKILL.md\"),\n\t\t\t\t\t\t),\n\t\t\t\t\t),\n\t\t\t\t);\n\t\t\t\tif (allExist) return true;\n\t\t\t}\n\t\t} catch {}\n\t}\n\n\t// Check global: ALL required skills must exist in agent-specific dirs\n\tconst agentName = getSkillsAgentNameFromId(agent);\n\tconst globalDirs = GLOBAL_SKILLS_DIRS[agentName] ?? [];\n\tfor (const dir of globalDirs) {\n\t\tconst allExist = requiredSkills.every((skill) =>\n\t\t\texistsSync(resolve(dir, skill, \"SKILL.md\")),\n\t\t);\n\t\tif (allExist) {\n\t\t\t// Check freshness of any one skill file\n\t\t\ttry {\n\t\t\t\tconst mtime = statSync(\n\t\t\t\t\tresolve(dir, requiredSkills[0], \"SKILL.md\"),\n\t\t\t\t).mtimeMs;\n\t\t\t\tif (now - mtime < SKILLS_FRESHNESS_MS) return true;\n\t\t\t} catch {}\n\t\t}\n\t}\n\n\treturn false;\n}\n\n/**\n * Ensures Neon agent skills are up to date. Runs `skills add` if the skills\n * haven't been updated within the freshness window (12 hours).\n *\n * Designed to be called from any phase handler — cheap to call repeatedly\n * since it's a no-op when skills are fresh.\n */\nexport async function ensureSkillsUpToDate(\n\tagent: string | undefined,\n\tscope?: \"global\" | \"project\",\n\tpreview?: boolean,\n): Promise<boolean> {\n\tconst resolvedAgent = agent || \"cursor\";\n\tconst skills = getSkillList(preview);\n\tif (skillsAreFresh(resolvedAgent, skills)) return true;\n\n\tawait ensureSkillsCli();\n\tconst agentName = getSkillsAgentNameFromId(resolvedAgent);\n\tlet allOk = true;\n\n\t// Only install skills that don't already have SKILL.md on disk.\n\t// Re-installing existing skills can trigger sandbox permission prompts.\n\tconst home = process.env.HOME || process.env.USERPROFILE || \"\";\n\tconst cwd = process.cwd();\n\tconst checkDirs =\n\t\tscope === \"global\"\n\t\t\t? [\n\t\t\t\t\tresolve(home, \".cursor\", \"skills\"),\n\t\t\t\t\tresolve(home, \".claude\", \"skills\"),\n\t\t\t\t\tresolve(home, \".agents\", \"skills\"),\n\t\t\t\t]\n\t\t\t: [\n\t\t\t\t\tresolve(cwd, \".cursor\", \"skills\"),\n\t\t\t\t\tresolve(cwd, \".claude\", \"skills\"),\n\t\t\t\t\tresolve(cwd, \".agents\", \"skills\"),\n\t\t\t\t];\n\n\tconst missingSkills = skills.filter(\n\t\t(skill) =>\n\t\t\t!checkDirs.some((dir) =>\n\t\t\t\texistsSync(resolve(dir, skill, \"SKILL.md\")),\n\t\t\t),\n\t);\n\n\tif (missingSkills.length === 0) return true;\n\n\t// Install one skill at a time — the skills CLI has a bug with multiple\n\t// --skill flags where it creates directories but doesn't copy all SKILL.md files.\n\tfor (const skill of missingSkills) {\n\t\ttry {\n\t\t\tawait execa(\n\t\t\t\t\"skills\",\n\t\t\t\t[\n\t\t\t\t\t\"add\",\n\t\t\t\t\t\"neondatabase/agent-skills\",\n\t\t\t\t\t\"--skill\",\n\t\t\t\t\tskill,\n\t\t\t\t\t\"--agent\",\n\t\t\t\t\tagentName,\n\t\t\t\t\t...(scope === \"global\" ? [\"-g\"] : []),\n\t\t\t\t\t\"-y\",\n\t\t\t\t],\n\t\t\t\t{ stdio: \"pipe\", timeout: 120000 },\n\t\t\t);\n\t\t} catch {\n\t\t\tallOk = false;\n\t\t}\n\t}\n\n\treturn allOk;\n}\n"],"mappings":";;;;;;;;;;;AAYA,eAAe,kBAAiC;CAC/C,IAAI;EACH,MAAM,MAAM,UAAU,CAAC,WAAW,GAAG;GAAE,OAAO;GAAQ,SAAS;EAAK,CAAC;CACtE,QAAQ;EAEP,IAAI;GACH,MAAM,MAAM,OAAO;IAAC;IAAW;IAAM;GAAQ,GAAG;IAC/C,OAAO;IACP,SAAS;GACV,CAAC;EACF,QAAQ,CAER;CACD;AACD;;AAGA,MAAM,cAAc,CAAC,QAAQ,eAAe;;AAG5C,MAAM,iBAAiB;CACtB;CACA;CACA;AACD;;AAGA,SAAgB,aAAa,SAA6B;CACzD,OAAO,UAAU,CAAC,GAAG,aAAa,GAAG,cAAc,IAAI;AACxD;AAEA,MAAM,iBACL;AAED,MAAa,uBAA+C;CAC3D,gBAAgB,GAAG,eAAe;CAClC,mBAAmB,GAAG,eA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CAClC;CACD,QAAQ;EACP,QAAQ;CACT;CAGD,OAAO;AACR"}
1
+ {"version":3,"file":"skills.js","names":["getSkillsAgentNameFromId"],"sources":["../../src/lib/skills.ts"],"sourcesContent":["import { existsSync, statSync } from \"node:fs\";\nimport { resolve } from \"node:path\";\nimport { log, spinner } from \"@clack/prompts\";\nimport { execa } from \"execa\";\nimport { dim } from \"yoctocolors\";\nimport { getSkillsAgentName as getSkillsAgentNameFromId } from \"./agents.js\";\nimport type { Editor } from \"./types.js\";\n\n/**\n * Ensures the `skills` CLI is globally installed so npx doesn't need\n * to download it (which can fail behind corporate proxies / sandboxes).\n */\nasync function ensureSkillsCli(): Promise<void> {\n\ttry {\n\t\tawait execa(\"skills\", [\"--version\"], { stdio: \"pipe\", timeout: 5000 });\n\t} catch {\n\t\t// Not installed — install it globally\n\t\ttry {\n\t\t\tawait execa(\"npm\", [\"install\", \"-g\", \"skills\"], {\n\t\t\t\tstdio: \"pipe\",\n\t\t\t\ttimeout: 60000,\n\t\t\t});\n\t\t} catch {\n\t\t\t// Best effort — npx will fall back to downloading\n\t\t}\n\t}\n}\n\n/** Base skills installed for all invocations */\nconst BASE_SKILLS = [\"neon\", \"neon-postgres\"];\n\n/** Additional skills installed for preview (non-bootstrap) invocations */\nconst PREVIEW_SKILLS = [\n\t\"neon-object-storage\",\n\t\"neon-functions\",\n\t\"neon-ai-gateway\",\n];\n\n/** Returns the skill list based on whether preview mode is active */\nexport function getSkillList(preview?: boolean): string[] {\n\treturn preview ? [...BASE_SKILLS, ...PREVIEW_SKILLS] : BASE_SKILLS;\n}\n\nconst SKILL_BASE_URL =\n\t\"https://neon.com/docs/ai/skills/neon-postgres/references\";\n\nexport const SKILL_REFERENCE_URLS: Record<string, string> = {\n\tgettingStarted: `${SKILL_BASE_URL}/getting-started.md`,\n\tconnectionMethods: `${SKILL_BASE_URL}/connection-methods.md`,\n\tneonAuth: `${SKILL_BASE_URL}/neon-auth.md`,\n\tserverlessDriver: `${SKILL_BASE_URL}/neon-serverless.md`,\n\tneonCli: `${SKILL_BASE_URL}/neon-cli.md`,\n\tdevtools: `${SKILL_BASE_URL}/devtools.md`,\n\tbranching: `${SKILL_BASE_URL}/branching.md`,\n\tneonJs: `${SKILL_BASE_URL}/neon-js.md`,\n};\n\n/**\n * Fetches the \"Getting Started with Neon\" skill content from the public URL.\n * Returns the markdown content, or null if the fetch fails.\n */\nexport async function fetchSkillContent(): Promise<string | null> {\n\ttry {\n\t\tconst response = await fetch(SKILL_REFERENCE_URLS.gettingStarted, {\n\t\t\tsignal: AbortSignal.timeout(10000),\n\t\t});\n\t\tif (!response.ok) return null;\n\t\treturn await response.text();\n\t} catch {\n\t\treturn null;\n\t}\n}\n\n/**\n * Maps Editor display names to the skills CLI agent name.\n * Used only by the v1 installAgentSkills function.\n */\nfunction editorToSkillsAgent(editor: Editor): string {\n\tswitch (editor) {\n\t\tcase \"Cursor\":\n\t\t\treturn \"cursor\";\n\t\tcase \"VS Code\":\n\t\tcase \"GitHub Copilot CLI\":\n\t\t\treturn \"github-copilot\";\n\t\tcase \"Claude CLI\":\n\t\t\treturn \"claude-code\";\n\t\tcase \"Codex\":\n\t\t\treturn \"codex\";\n\t\tcase \"OpenCode\":\n\t\t\treturn \"opencode\";\n\t\tcase \"Antigravity\":\n\t\t\treturn \"antigravity\";\n\t\tcase \"Cline\":\n\t\tcase \"Cline CLI\":\n\t\t\treturn \"cline\";\n\t\tcase \"Gemini CLI\":\n\t\t\treturn \"gemini-cli\";\n\t\tcase \"Goose\":\n\t\t\treturn \"goose\";\n\t\tcase \"Claude Desktop\":\n\t\t\treturn \"claude-code\";\n\t\tcase \"MCPorter\":\n\t\t\treturn \"mcporter\";\n\t\tcase \"Zed\":\n\t\t\treturn \"zed\";\n\t\tdefault:\n\t\t\treturn \"\";\n\t}\n}\n\nexport interface InstallSkillsOptions {\n\tjson?: boolean;\n\tscope?: \"global\" | \"project\";\n\tpreview?: boolean;\n}\n\n/**\n * Installs Neon agent skills using Vercel's skills CLI.\n */\nexport async function installAgentSkills(\n\tselectedEditors: Editor[],\n\toptions?: InstallSkillsOptions,\n): Promise<boolean> {\n\tconst quiet = options?.json === true;\n\n\tconst editorsWithSkills = selectedEditors.filter(\n\t\t(e) => editorToSkillsAgent(e) !== \"\",\n\t);\n\n\tif (editorsWithSkills.length === 0) {\n\t\treturn true;\n\t}\n\n\tconst skillsSpinner = quiet ? null : spinner();\n\tskillsSpinner?.start(\"Installing agent skills for Neon in this project...\");\n\n\tlet anyFailed = false;\n\n\tawait ensureSkillsCli();\n\tconst skills = getSkillList(options?.preview);\n\n\tfor (const editor of editorsWithSkills) {\n\t\tconst agentName = editorToSkillsAgent(editor);\n\n\t\t// Install one skill at a time — the skills CLI has a bug with multiple\n\t\t// --skill flags where it creates directories but doesn't copy all SKILL.md files.\n\t\tfor (const skill of skills) {\n\t\t\ttry {\n\t\t\t\tawait execa(\n\t\t\t\t\t\"skills\",\n\t\t\t\t\t[\n\t\t\t\t\t\t\"add\",\n\t\t\t\t\t\t\"neondatabase/agent-skills\",\n\t\t\t\t\t\t\"--skill\",\n\t\t\t\t\t\tskill,\n\t\t\t\t\t\t\"--agent\",\n\t\t\t\t\t\tagentName,\n\t\t\t\t\t\t...(options?.scope === \"global\" ? [\"-g\"] : []),\n\t\t\t\t\t\t\"-y\",\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: 120000,\n\t\t\t\t\t},\n\t\t\t\t);\n\t\t\t} catch (error) {\n\t\t\t\tif (!quiet)\n\t\t\t\t\tlog.error(\n\t\t\t\t\t\t`Failed to install skill ${skill} for ${editor}: ${error instanceof Error ? error.message : \"Unknown error\"}`,\n\t\t\t\t\t);\n\t\t\t\tanyFailed = true;\n\t\t\t}\n\t\t}\n\t}\n\n\tif (anyFailed) {\n\t\tskillsSpinner?.stop(\n\t\t\t\"Agent skills installation for this project completed with errors\",\n\t\t);\n\t\tif (!quiet)\n\t\t\tlog.info(\n\t\t\t\t\"You can manually install skills by running: npx skills add neondatabase/agent-skills --skill neon --skill neon-postgres\",\n\t\t\t);\n\t\treturn false;\n\t}\n\n\tskillsSpinner?.stop(dim(\"Agent skills installed ✓\"));\n\treturn true;\n}\n\n// ---------------------------------------------------------------------------\n// Evergreen skills: ensure skills are up to date (at most once per 12 hours)\n// ---------------------------------------------------------------------------\n\nconst SKILLS_FRESHNESS_MS = 12 * 60 * 60 * 1000; // 12 hours\n\n/**\n * Agent skills directory paths by agent, keyed by scope.\n * These are the directories that `skills add` writes to.\n */\nconst GLOBAL_SKILLS_DIRS: Record<string, string[]> = (() => {\n\tconst home = process.env.HOME || process.env.USERPROFILE || \"\";\n\t// .agents/skills is the generic directory used by multiple agents\n\tconst agentsDir = resolve(home, \".agents\", \"skills\");\n\treturn {\n\t\tcursor: [resolve(home, \".cursor\", \"skills\"), agentsDir],\n\t\t\"claude-code\": [resolve(home, \".claude\", \"skills\"), agentsDir],\n\t\t\"github-copilot\": [resolve(home, \".vscode\", \"skills\"), agentsDir],\n\t\tcodex: [resolve(home, \".codex\", \"skills\"), agentsDir],\n\t\tcline: [resolve(home, \".cline\", \"skills\"), agentsDir],\n\t};\n})();\n\n/**\n * Checks whether skills were recently updated (within the freshness window).\n * Checks both project-level (skills-lock.json mtime) and global (skills dir mtime).\n */\nfunction skillsAreFresh(agent: string, requiredSkills: string[]): boolean {\n\tconst now = Date.now();\n\tconst cwd = process.cwd();\n\tconst projectSkillDirs = [\".agents\", \".cursor\", \".claude\"];\n\n\t// Check project-level: ALL required skills must exist on disk\n\t// and skills-lock.json must be recent\n\tconst lockPath = resolve(cwd, \"skills-lock.json\");\n\tif (existsSync(lockPath)) {\n\t\ttry {\n\t\t\tconst mtime = statSync(lockPath).mtimeMs;\n\t\t\tif (now - mtime < SKILLS_FRESHNESS_MS) {\n\t\t\t\tconst allExist = requiredSkills.every((skill) =>\n\t\t\t\t\tprojectSkillDirs.some((dir) =>\n\t\t\t\t\t\texistsSync(\n\t\t\t\t\t\t\tresolve(cwd, dir, \"skills\", skill, \"SKILL.md\"),\n\t\t\t\t\t\t),\n\t\t\t\t\t),\n\t\t\t\t);\n\t\t\t\tif (allExist) return true;\n\t\t\t}\n\t\t} catch {}\n\t}\n\n\t// Check global: ALL required skills must exist in agent-specific dirs\n\tconst agentName = getSkillsAgentNameFromId(agent);\n\tconst globalDirs = GLOBAL_SKILLS_DIRS[agentName] ?? [];\n\tfor (const dir of globalDirs) {\n\t\tconst allExist = requiredSkills.every((skill) =>\n\t\t\texistsSync(resolve(dir, skill, \"SKILL.md\")),\n\t\t);\n\t\tif (allExist) {\n\t\t\t// Check freshness of any one skill file\n\t\t\ttry {\n\t\t\t\tconst mtime = statSync(\n\t\t\t\t\tresolve(dir, requiredSkills[0], \"SKILL.md\"),\n\t\t\t\t).mtimeMs;\n\t\t\t\tif (now - mtime < SKILLS_FRESHNESS_MS) return true;\n\t\t\t} catch {}\n\t\t}\n\t}\n\n\treturn false;\n}\n\n/**\n * Ensures Neon agent skills are up to date. Runs `skills add` if the skills\n * haven't been updated within the freshness window (12 hours).\n *\n * Designed to be called from any phase handler — cheap to call repeatedly\n * since it's a no-op when skills are fresh.\n */\nexport async function ensureSkillsUpToDate(\n\tagent: string | undefined,\n\tscope?: \"global\" | \"project\",\n\tpreview?: boolean,\n): Promise<boolean> {\n\tconst resolvedAgent = agent || \"cursor\";\n\tconst skills = getSkillList(preview);\n\tif (skillsAreFresh(resolvedAgent, skills)) return true;\n\n\tawait ensureSkillsCli();\n\tconst agentName = getSkillsAgentNameFromId(resolvedAgent);\n\tlet allOk = true;\n\n\t// Only install skills that don't already have SKILL.md on disk.\n\t// Re-installing existing skills can trigger sandbox permission prompts.\n\tconst home = process.env.HOME || process.env.USERPROFILE || \"\";\n\tconst cwd = process.cwd();\n\tconst checkDirs =\n\t\tscope === \"global\"\n\t\t\t? [\n\t\t\t\t\tresolve(home, \".cursor\", \"skills\"),\n\t\t\t\t\tresolve(home, \".claude\", \"skills\"),\n\t\t\t\t\tresolve(home, \".agents\", \"skills\"),\n\t\t\t\t]\n\t\t\t: [\n\t\t\t\t\tresolve(cwd, \".cursor\", \"skills\"),\n\t\t\t\t\tresolve(cwd, \".claude\", \"skills\"),\n\t\t\t\t\tresolve(cwd, \".agents\", \"skills\"),\n\t\t\t\t];\n\n\tconst missingSkills = skills.filter(\n\t\t(skill) =>\n\t\t\t!checkDirs.some((dir) =>\n\t\t\t\texistsSync(resolve(dir, skill, \"SKILL.md\")),\n\t\t\t),\n\t);\n\n\tif (missingSkills.length === 0) return true;\n\n\t// Install one skill at a time — the skills CLI has a bug with multiple\n\t// --skill flags where it creates directories but doesn't copy all SKILL.md files.\n\tfor (const skill of missingSkills) {\n\t\ttry {\n\t\t\tawait execa(\n\t\t\t\t\"skills\",\n\t\t\t\t[\n\t\t\t\t\t\"add\",\n\t\t\t\t\t\"neondatabase/agent-skills\",\n\t\t\t\t\t\"--skill\",\n\t\t\t\t\tskill,\n\t\t\t\t\t\"--agent\",\n\t\t\t\t\tagentName,\n\t\t\t\t\t...(scope === \"global\" ? [\"-g\"] : []),\n\t\t\t\t\t\"-y\",\n\t\t\t\t],\n\t\t\t\t{ stdio: \"pipe\", timeout: 120000 },\n\t\t\t);\n\t\t} catch {\n\t\t\tallOk = false;\n\t\t}\n\t}\n\n\treturn allOk;\n}\n"],"mappings":";;;;;;;;;;;AAYA,eAAe,kBAAiC;CAC/C,IAAI;EACH,MAAM,MAAM,UAAU,CAAC,WAAW,GAAG;GAAE,OAAO;GAAQ,SAAS;EAAK,CAAC;CACtE,QAAQ;EAEP,IAAI;GACH,MAAM,MAAM,OAAO;IAAC;IAAW;IAAM;GAAQ,GAAG;IAC/C,OAAO;IACP,SAAS;GACV,CAAC;EACF,QAAQ,CAER;CACD;AACD;;AAGA,MAAM,cAAc,CAAC,QAAQ,eAAe;;AAG5C,MAAM,iBAAiB;CACtB;CACA;CACA;AACD;;AAGA,SAAgB,aAAa,SAA6B;CACzD,OAAO,UAAU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nB,IAAI;EACH,MAAM,MACL,UACA;GACC;GACA;GACA;GACA;GACA;GACA;GACA,GAAI,UAAU,WAAW,CAAC,IAAI,IAAI,CAAC;GACnC;EACD,GACA;GAAE,OAAO;GAAQ,SAAS;EAAO,CAClC;CACD,QAAQ;EACP,QAAQ;CACT;CAGD,OAAO;AACR"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "neon-init",
3
- "version": "0.20.1",
3
+ "version": "0.20.2",
4
4
  "description": "Initialize Neon projects",
5
5
  "keywords": [
6
6
  "neon",