Skip to content

Commit ca9e89a

Browse files
committed
feat: neon-init v2 agent-driven state machine
Redesigns neon-init as a stateless state machine where each CLI invocation returns a typed JSON response with a `nextAction` that tells the agent exactly what to do next. Key changes: - Orchestrator inspects filesystem (MCP config, skills, DATABASE_URL) to skip phases that are already satisfied — no unnecessary round-trips - Phase handlers for auth, setup, getting-started, db, neon-auth, migrations, mcp, skills, and status as composable subcommands - `responseMapping` supports inline `{ action: NextAction }` to eliminate CLI round-trips (e.g. auth OAuth launches directly after user confirms) - Auth verified responses use `run_neon_init` instead of `complete` to prevent agents from getting distracted by neonctl output - `ensureSkillsUpToDate()` with 12-hour freshness window — called from phase handlers, skips if skills-lock.json or global skills dir is recent - Agent detection via TTY: IDE env vars + non-TTY stdin = agent invocation, IDE env vars + TTY stdin = human in terminal → interactive mode - Interactive mode with clack prompts, Neon green branding via picocolors patch, org/project selection, .neon context file - Extension install fallback chain: marketplace → VSIX download (corporate proxy or Open VSX) → manual instructions - Input validation (assertSafeId) for org/project IDs in shell commands - Filesystem inspection module (inspect.ts) shared by orchestrator, setup, and status phases - 95 tests across 11 test files Co-authored-by: Isaac
1 parent 0032d34 commit ca9e89a

35 files changed

Lines changed: 6887 additions & 187 deletions

packages/init/.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
src/lib/build-config.ts
2+
.agents/
3+
.claude/skills/
4+
skills-lock.json
5+
bin/

packages/init/package.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,12 @@
3434
"package.json"
3535
],
3636
"scripts": {
37-
"build": "tsc --noEmit && tsdown",
37+
"build": "node scripts/set-vsx-gallery.mjs && tsc --noEmit && tsdown",
38+
"build:internal": "node scripts/set-vsx-gallery.mjs https://cursor-vsx-proxy.cloud.databricks.com/gallery && tsc --noEmit && tsdown",
39+
"pretest": "node scripts/set-vsx-gallery.mjs",
3840
"test": "vitest --passWithNoTests",
3941
"test:ci": "vitest run --passWithNoTests",
40-
"tsc": "tsc"
42+
"tsc": "node scripts/set-vsx-gallery.mjs && tsc"
4143
},
4244
"devDependencies": {
4345
"@types/node": "catalog:",
@@ -52,6 +54,7 @@
5254
"@clack/prompts": "0.10.1",
5355
"add-mcp": "^1.5.1",
5456
"execa": "^9.5.2",
57+
"picocolors": "^1.1.1",
5558
"yargs": "^18.0.0",
5659
"yoctocolors": "^2.1.2"
5760
},
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// Generates src/lib/build-config.ts with the VSX gallery URL baked in.
2+
// Usage:
3+
// node scripts/set-vsx-gallery.mjs → empty (external release)
4+
// node scripts/set-vsx-gallery.mjs https://proxy.example.com/gallery → baked in (internal)
5+
import { writeFileSync } from "node:fs";
6+
7+
const url = process.argv[2] || "";
8+
writeFileSync(
9+
"src/lib/build-config.ts",
10+
`// Auto-generated by scripts/set-vsx-gallery.mjs — do not edit\nexport const INTERNAL_VSX_GALLERY = ${JSON.stringify(url)};\n`,
11+
);

0 commit comments

Comments
 (0)