neon 4.6.0 → 4.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (57) hide show
  1. package/README.md +48 -113
  2. package/dist/_chunks/{auth_selection-ktL6uoEe.js → auth_selection-pitMFzDe.js} +1 -1
  3. package/dist/_chunks/{credential_io-B1JxWELN.js → credential_io-YeAxg9Xn.js} +2 -2
  4. package/dist/_chunks/{paths-g3DRqJiD.js → paths-DMq0Lt7a.js} +1 -1
  5. package/dist/_chunks/{profiles-D95AeZ5v.js → profiles-CvnFEQyd.js} +1 -1
  6. package/dist/analytics.js +2 -2
  7. package/dist/auth_context.js +1 -1
  8. package/dist/commands/auth.js +12 -9
  9. package/dist/commands/bootstrap.js +72 -43
  10. package/dist/commands/claim.js +1 -1
  11. package/dist/commands/env.js +3 -20
  12. package/dist/commands/init.js +80 -79
  13. package/dist/commands/link.js +110 -292
  14. package/dist/commands/mcp.js +2 -2
  15. package/dist/commands/plugins.js +3 -3
  16. package/dist/commands/profile.js +4 -4
  17. package/dist/config.js +1 -1
  18. package/dist/credential_io.js +1 -1
  19. package/dist/index.js +1 -1
  20. package/dist/init/child.js +36 -0
  21. package/dist/init/plan.js +47 -0
  22. package/dist/init/tooling.js +43 -0
  23. package/dist/init/wizard.js +42 -0
  24. package/dist/mcp/targets.js +1 -1
  25. package/dist/plugins/plan.js +1 -1
  26. package/dist/plugins/targets.js +5 -1
  27. package/dist/retire_credential.js +1 -1
  28. package/dist/utils/cli_name.js +1 -12
  29. package/dist/utils/middlewares.js +1 -1
  30. package/dist/utils/package_manager.js +10 -5
  31. package/package.json +13 -14
  32. package/dist/init/auth.js +0 -53
  33. package/dist/init/build_config.js +0 -4
  34. package/dist/init/detect_agent.js +0 -63
  35. package/dist/init/editors.js +0 -19
  36. package/dist/init/enrich_output.js +0 -61
  37. package/dist/init/extension.js +0 -154
  38. package/dist/init/inspect.js +0 -249
  39. package/dist/init/interactive.js +0 -529
  40. package/dist/init/neonctl.js +0 -139
  41. package/dist/init/orchestrate.js +0 -189
  42. package/dist/init/phases/auth.js +0 -195
  43. package/dist/init/phases/cleanup.js +0 -27
  44. package/dist/init/phases/db.js +0 -257
  45. package/dist/init/phases/getting_started.js +0 -218
  46. package/dist/init/phases/mcp.js +0 -219
  47. package/dist/init/phases/migrations.js +0 -250
  48. package/dist/init/phases/neon_auth.js +0 -116
  49. package/dist/init/phases/setup.js +0 -582
  50. package/dist/init/phases/skills.js +0 -86
  51. package/dist/init/phases/status.js +0 -82
  52. package/dist/init/profile_cli.js +0 -56
  53. package/dist/init/resolve_context.js +0 -105
  54. package/dist/init/route_command.js +0 -93
  55. package/dist/init/skills.js +0 -206
  56. package/dist/init/types.js +0 -1
  57. package/dist/init/vsix.js +0 -89
@@ -1,94 +1,95 @@
1
1
  import { t as __exportAll } from "../_chunks/rolldown-runtime-8H4AJuhK.js";
2
- import { closeAnalytics, sendError } from "../analytics.js";
3
- import { detectAgent } from "../init/detect_agent.js";
4
- import { enrichResponse } from "../init/enrich_output.js";
5
- import { interactiveInit } from "../init/interactive.js";
6
- import { orchestrate } from "../init/orchestrate.js";
7
- import { routeDataStep } from "../init/route_command.js";
8
- import { writeAllSync } from "../utils/write_sync.js";
2
+ import { log } from "../log.js";
3
+ import { readContextFile } from "../context.js";
4
+ import { getCliName } from "../utils/cli_name.js";
5
+ import { t as credentialInputs } from "../_chunks/auth_selection-pitMFzDe.js";
6
+ import { initChildEnv, spawnCliChild } from "../init/child.js";
7
+ import { bootstrapInitStep, directoryIsEmpty, planExistingInit } from "../init/plan.js";
8
+ import { runAgentTooling, runInitSteps } from "../init/tooling.js";
9
+ import { helpEpilogue } from "../utils/help_text.js";
10
+ import { existsSync, readdirSync } from "node:fs";
11
+ import { resolve } from "node:path";
9
12
  //#region src/commands/init.ts
10
13
  var init_exports = /* @__PURE__ */ __exportAll({
11
14
  builder: () => builder,
12
15
  command: () => command,
13
16
  describe: () => describe,
14
- handler: () => handler
17
+ handler: () => handler,
18
+ initChildEnv: () => initChildEnv
15
19
  });
16
20
  const command = "init";
17
- const describe = "Initialize a project with Neon using your AI coding assistant";
18
- const builder = (yargs) => yargs.option("context-file", { hidden: true }).option("agent", {
19
- alias: "a",
21
+ const describe = "Set up this directory for Neon: agent tooling, a linked project, and neon.ts. In an empty directory, scaffolds a template first. Skills needs Node.js 22.20 or newer.";
22
+ const removedProtocol = () => `\`${getCliName()} init --agent\` and \`--data\` were removed. Run \`${getCliName()} init\` or \`${getCliName()} init -y\`.`;
23
+ const builder = (yargs) => yargs.usage("$0 init [options]").option("context-file", { hidden: true }).option("yes", {
24
+ alias: "y",
20
25
  type: "boolean",
21
26
  default: false,
22
- describe: "Enable agent/JSON mode (agent type is auto-detected)."
27
+ describe: "Empty dir: bootstrap --default. Otherwise plugin when a project plugin agent is detected, else skills and MCP, then link --yes and config init --services none. link --yes still asks for a project unless one is already linked"
28
+ }).option("agent", {
29
+ hidden: true,
30
+ type: "boolean"
23
31
  }).option("data", {
24
- type: "string",
25
- describe: "JSON object with a \"step\" field to route to a specific phase and phase-specific options."
26
- }).option("skip-migrations", {
27
- type: "boolean",
28
- default: false,
29
- describe: "Skip the migrations phase."
30
- }).option("preview", {
31
- type: "boolean",
32
- default: false,
33
- describe: "Enable preview features (e.g. project bootstrapping from templates)."
34
- }).strict(false);
35
- /**
36
- * The agent-facing half of `neon init` speaks JSON, and it speaks it on **stdout**:
37
- * one object, no prefix, nothing else. `log.info` would prefix every line with
38
- * `INFO: ` and send it to stderr, which is right for a diagnostic and wrong for the
39
- * payload an agent is expected to parse.
40
- */
41
- const writeAgentResponse = (result) => {
42
- writeAllSync(1, `${JSON.stringify(enrichResponse(result), null, 2)}\n`);
43
- };
44
- /**
45
- * A failure has to arrive in the shape the caller asked for. An agent parses stdout and
46
- * has no branch for "empty stdout, exit 1" — it cannot tell a broken credentials file
47
- * from a phase that legitimately produced nothing — so the error goes out as JSON too.
48
- */
49
- const writeAgentFailure = (error) => {
50
- writeAllSync(1, `${JSON.stringify({
51
- success: false,
52
- error: error.message
53
- }, null, 2)}\n`);
54
- };
55
- /** ` at position 12`, or nothing when the parser did not report one. */
56
- const parsePosition = (parseError) => {
57
- const at = (parseError instanceof Error ? parseError.message : "").match(/at position (\d+)/);
58
- return at === null ? "" : ` at position ${at[1]}`;
32
+ hidden: true,
33
+ type: "string"
34
+ }).option("output", {
35
+ alias: "o",
36
+ hidden: true,
37
+ describe: "Not supported; the commands init runs print their own output"
38
+ }).example("$0 init", "Empty dir: bootstrap (scaffold, agent tooling, link). Existing app: agent tooling, link, config init").example("$0 init -y", "Same steps, using each child's defaults").epilogue(helpEpilogue("Interactive agent setup: plugin (recommended), skills and MCP separately, or skip agent setup. Never both plugin and skills+MCP.", "-y installs the plugin when Cursor, Claude Code, or Codex is detected in the project. Otherwise skills and MCP. Then link unless already linked. link --yes may still ask for a project.")).check((argv) => {
39
+ if (argv.agent === true || argv.data !== void 0) throw new Error(removedProtocol());
40
+ if (argv.help !== true && (argv.output === "json" || argv.output === "yaml")) throw new Error(`\`${getCliName()} init\` does not support --output. The commands it runs print their own output.`);
41
+ return true;
42
+ }).strict();
43
+ const isLinked = (contextFile) => {
44
+ const projectId = readContextFile(contextFile).projectId;
45
+ return typeof projectId === "string" && projectId.length > 0;
59
46
  };
60
- const handler = async (argv) => {
61
- const agent = (argv.agent || !process.stdin.isTTY ? detectAgent() : null) || void 0;
62
- const isAgentMode = argv.agent || agent !== void 0;
63
- try {
64
- if (argv.data && isAgentMode) {
65
- let data;
66
- try {
67
- data = JSON.parse(argv.data);
68
- } catch (parseError) {
69
- throw new Error(`Invalid JSON in --data flag${parsePosition(parseError)}. Expected a JSON object.`);
70
- }
71
- if (typeof data.step === "string") {
72
- writeAgentResponse(await routeDataStep(data, agent));
73
- return;
74
- }
75
- }
76
- if (isAgentMode) writeAgentResponse(await orchestrate({
77
- agent,
78
- skipMigrations: argv.skipMigrations,
79
- preview: argv.preview
80
- }));
81
- else await interactiveInit({ preview: argv.preview });
82
- } catch (error) {
83
- const cause = error instanceof Error ? error : new Error(String(error));
84
- if (isAgentMode) {
85
- sendError(cause, "NEON_INIT_FAILED");
86
- writeAgentFailure(cause);
87
- await closeAnalytics();
88
- process.exit(1);
89
- }
90
- throw cause;
47
+ const handler = async (props) => {
48
+ if (props.output === "json" || props.output === "yaml") throw new Error(`\`${getCliName()} init\` does not support --output. The commands it runs print their own output.`);
49
+ const cwd = props.cwd ?? process.cwd();
50
+ const names = existsSync(cwd) ? readdirSync(cwd) : [];
51
+ const contextFile = resolve(cwd, props.contextFile);
52
+ const yes = props.yes === true;
53
+ const run = props.run ?? spawnCliChild;
54
+ const explicitKey = props.profile ? "" : credentialInputs().apiKeyFlag;
55
+ const authEnv = explicitKey ? { NEON_API_KEY: explicitKey } : void 0;
56
+ const forward = {
57
+ ...props.configDir ? { configDir: props.configDir } : {},
58
+ ...props.profile ? { profile: props.profile } : {},
59
+ apiHost: props.apiHost,
60
+ contextFile,
61
+ ...props.analytics === false ? { analytics: false } : {}
62
+ };
63
+ if (directoryIsEmpty(names)) {
64
+ await runInitSteps([bootstrapInitStep(yes)], {
65
+ cwd,
66
+ run,
67
+ forward,
68
+ authEnv
69
+ });
70
+ log.info("Done.");
71
+ return;
91
72
  }
73
+ await runAgentTooling({
74
+ cwd,
75
+ yes,
76
+ run,
77
+ forward,
78
+ authEnv,
79
+ ...props.pickAgentSetup ? { pickAgentSetup: props.pickAgentSetup } : {},
80
+ ...props.hasProjectPlugins ? { hasProjectPlugins: props.hasProjectPlugins } : {}
81
+ });
82
+ await runInitSteps(planExistingInit({
83
+ linked: isLinked(contextFile),
84
+ yes,
85
+ agentSetup: "skip"
86
+ }), {
87
+ cwd,
88
+ run,
89
+ forward,
90
+ authEnv
91
+ });
92
+ log.info("Done.");
92
93
  };
93
94
  //#endregion
94
- export { builder, command, describe, handler, init_exports as t };
95
+ export { builder, command, describe, handler, initChildEnv, init_exports as t };