neon 8.10.1 → 8.10.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1015,7 +1015,7 @@ neon docs search "create branch" --category api --category docs
1015
1015
  neon docs search "pg_dump" --limit 5 --output json
1016
1016
  ```
1017
1017
 
1018
- `--category` limits results to `docs`, `api`, `postgresql`, `guides`, `faqs`, `blog`, or `changelog`; repeat it for more than one. `--limit` is 1 to 40, default 10. Default table output is one row per page: title, the section that matched, and URL. `--output json` and `--output yaml` print an array of hits with `title`, `url`, `category`, `breadcrumb`, `heading`, and `excerpt`, in rank order. No match prints `No results for "<query>".` and exits 0 (`[]` in JSON).
1018
+ `--category` limits results to `docs`, `api`, `postgresql`, `guides`, `faqs`, `blog`, or `changelog`; repeat it for more than one. `--limit` is 1 to 40, default 10. Default output is one block per result: `Title › Section` on one line, cut to the terminal width, and the full URL under it. `--output json` and `--output yaml` print an array of hits with `title`, `url`, `category`, `breadcrumb`, `heading`, and `excerpt`, in rank order. No match prints `No results for "<query>".` and exits 0 (`[]` in JSON).
1019
1019
 
1020
1020
  ## Install the Neon plugin (`plugins`)
1021
1021
 
@@ -55,6 +55,7 @@ const handler = async (props) => {
55
55
  const text = await askAssistant({
56
56
  prompt: props.prompt,
57
57
  url,
58
+ analytics: props.analytics,
58
59
  acceptEventStream: human,
59
60
  onStatus: (message) => {
60
61
  spinner.setMessage(message);
@@ -129,7 +130,8 @@ async function askAssistant(opts) {
129
130
  headers: {
130
131
  "Content-Type": "application/json",
131
132
  Accept: opts.acceptEventStream ? "text/event-stream" : "application/json",
132
- "x-neon-source": "cli"
133
+ "x-caller-source": "cli",
134
+ ...opts.analytics ? {} : { "x-caller-analytics": "off" }
133
135
  },
134
136
  body: JSON.stringify({ prompt: opts.prompt }),
135
137
  signal: AbortSignal.timeout(ASK_TIMEOUT_MS)
@@ -1,9 +1,11 @@
1
1
  import { t as __exportAll } from "../_chunks/rolldown-runtime-8H4AJuhK.js";
2
- import { getCliAgent } from "../env.js";
2
+ import { getCliAgent, isCi } from "../env.js";
3
3
  import pkg_default from "../pkg.js";
4
4
  import { isNetworkError } from "../errors.js";
5
+ import { resolveOutputWidth, stripAnsi, truncateTo } from "../human_table.js";
5
6
  import { writer } from "../writer.js";
6
7
  import { single } from "../utils/flags.js";
8
+ import chalk from "chalk";
7
9
  //#region src/commands/docs.ts
8
10
  var docs_exports = /* @__PURE__ */ __exportAll({
9
11
  DEFAULT_SITE_SEARCH_URL: () => DEFAULT_SITE_SEARCH_URL,
@@ -13,6 +15,7 @@ var docs_exports = /* @__PURE__ */ __exportAll({
13
15
  builder: () => builder,
14
16
  command: () => command,
15
17
  describe: () => describe,
18
+ formatSearchResults: () => formatSearchResults,
16
19
  parseSearchHits: () => parseSearchHits,
17
20
  resolveSiteSearchUrl: () => resolveSiteSearchUrl,
18
21
  siteSearchHeaders: () => siteSearchHeaders
@@ -86,16 +89,36 @@ const search = async (props) => {
86
89
  version: pkg_default.version
87
90
  })
88
91
  });
89
- writer(props).end(hits, {
90
- fields: [
91
- "title",
92
- "heading",
93
- "url"
94
- ],
95
- emptyMessage: `No results for "${query}".`,
96
- renderColumns: { heading: (hit) => sectionOf(hit) }
92
+ const emptyMessage = `No results for "${query}".`;
93
+ if (props.output === "json" || props.output === "yaml") {
94
+ writer(props).end(hits, {
95
+ fields: [
96
+ "title",
97
+ "heading",
98
+ "url"
99
+ ],
100
+ emptyMessage
101
+ });
102
+ return;
103
+ }
104
+ const text = formatSearchResults(hits, {
105
+ emptyMessage,
106
+ width: resolveOutputWidth(process.stdout, void 0, {
107
+ stdout: process.stdout,
108
+ envColumns: process.env.COLUMNS
109
+ })
97
110
  });
111
+ process.stdout.write(process.env.NO_COLOR || isCi() ? stripAnsi(text) : text);
98
112
  };
113
+ function formatSearchResults(hits, opts) {
114
+ if (hits.length === 0) return `\n${opts.emptyMessage}\n`;
115
+ return hits.map((hit) => {
116
+ const section = sectionOf(hit).split(" > ").filter(Boolean);
117
+ const line = [hit.title, ...section].join(" › ");
118
+ const shown = opts.width === void 0 ? line : truncateTo(line, opts.width);
119
+ return `${chalk.bold(shown)}\n ${chalk.cyan(hit.url)}\n`;
120
+ }).join("\n");
121
+ }
99
122
  function sectionOf(hit) {
100
123
  const parts = hit.heading.split(" > ");
101
124
  return (parts[0] === hit.title ? parts.slice(1) : parts).join(" > ");
@@ -104,9 +127,9 @@ function siteSearchHeaders(opts) {
104
127
  return {
105
128
  "Content-Type": "application/json",
106
129
  "User-Agent": `neon/${opts.version}`,
107
- "x-neon-source": "cli",
108
- ...opts.agent ? { "x-neon-client": encodeURIComponent(opts.agent) } : {},
109
- ...opts.analytics ? {} : { "x-neon-analytics": "off" }
130
+ "x-caller-source": "cli",
131
+ ...opts.agent ? { "x-caller-client": encodeURIComponent(opts.agent) } : {},
132
+ ...opts.analytics ? {} : { "x-caller-analytics": "off" }
110
133
  };
111
134
  }
112
135
  function isTimeout(error) {
@@ -171,4 +194,4 @@ function parseSearchHits(raw) {
171
194
  });
172
195
  }
173
196
  //#endregion
174
- export { DEFAULT_SITE_SEARCH_URL, MAX_LIMIT, MAX_QUERY_LENGTH, SITE_SEARCH_CATEGORIES, builder, command, describe, parseSearchHits, resolveSiteSearchUrl, siteSearchHeaders, docs_exports as t };
197
+ export { DEFAULT_SITE_SEARCH_URL, MAX_LIMIT, MAX_QUERY_LENGTH, SITE_SEARCH_CATEGORIES, builder, command, describe, formatSearchResults, parseSearchHits, resolveSiteSearchUrl, siteSearchHeaders, docs_exports as t };
@@ -226,4 +226,4 @@ function charWidth(code) {
226
226
  return 1;
227
227
  }
228
228
  //#endregion
229
- export { displayWidth, formatHumanChunk, parseColumns, resolveOutputWidth, stripAnsi, titleCaseField };
229
+ export { displayWidth, formatHumanChunk, parseColumns, resolveOutputWidth, stripAnsi, titleCaseField, truncateTo };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "neon",
3
- "version": "8.10.1",
3
+ "version": "8.10.3",
4
4
  "description": "CLI tool for Neon, the cloud backend primitives built around Lakebase Postgres",
5
5
  "keywords": [
6
6
  "neon",
@@ -70,10 +70,10 @@
70
70
  "yaml": "^2.9.0",
71
71
  "yargs": "17.7.2",
72
72
  "yoctocolors": "^2.1.2",
73
- "@neon/config": "1.9.3",
74
73
  "@neon/realtime": "0.1.2",
74
+ "@neon/config-runtime": "1.10.2",
75
75
  "@neon/sdk": "7.4.0",
76
- "@neon/config-runtime": "1.10.2"
76
+ "@neon/config": "1.9.3"
77
77
  },
78
78
  "optionalDependencies": {
79
79
  "@napi-rs/keyring": "1.3.0",
@@ -111,9 +111,9 @@
111
111
  "vitest": "^3.0.9",
112
112
  "@neon-internals/cli-core": "0.0.0",
113
113
  "@neon-internals/env-core": "0.0.34",
114
- "@neon/e2e-harness": "0.0.0",
114
+ "@neon/functions": "0.11.0",
115
115
  "@neon/env": "1.6.4",
116
- "@neon/functions": "0.11.0"
116
+ "@neon/e2e-harness": "0.0.0"
117
117
  },
118
118
  "publishConfig": {
119
119
  "access": "public",