@kashdao/cli 0.1.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 (85) hide show
  1. package/CHANGELOG.md +78 -0
  2. package/CONTRIBUTING.md +159 -0
  3. package/LICENSE +21 -0
  4. package/README.md +868 -0
  5. package/SECURITY.md +110 -0
  6. package/dist/account-AVFLEM5D.js +90 -0
  7. package/dist/account-AVFLEM5D.js.map +1 -0
  8. package/dist/auth-GUJCVKTD.js +239 -0
  9. package/dist/auth-GUJCVKTD.js.map +1 -0
  10. package/dist/chunk-BN2CUM42.js +9 -0
  11. package/dist/chunk-BN2CUM42.js.map +1 -0
  12. package/dist/chunk-BRK7KJ4O.js +154 -0
  13. package/dist/chunk-BRK7KJ4O.js.map +1 -0
  14. package/dist/chunk-KMBMQIZ7.js +393 -0
  15. package/dist/chunk-KMBMQIZ7.js.map +1 -0
  16. package/dist/chunk-LBIRQHX5.js +133 -0
  17. package/dist/chunk-LBIRQHX5.js.map +1 -0
  18. package/dist/chunk-MIXOZU2S.js +366 -0
  19. package/dist/chunk-MIXOZU2S.js.map +1 -0
  20. package/dist/chunk-QJMF73M5.js +129 -0
  21. package/dist/chunk-QJMF73M5.js.map +1 -0
  22. package/dist/chunk-UZNSYATZ.js +680 -0
  23. package/dist/chunk-UZNSYATZ.js.map +1 -0
  24. package/dist/chunk-VIADBYFY.js +94 -0
  25. package/dist/chunk-VIADBYFY.js.map +1 -0
  26. package/dist/chunk-YHCG2SUC.js +159 -0
  27. package/dist/chunk-YHCG2SUC.js.map +1 -0
  28. package/dist/chunk-YJX3JJ4M.js +174 -0
  29. package/dist/chunk-YJX3JJ4M.js.map +1 -0
  30. package/dist/client-IOM55ZCS.js +14 -0
  31. package/dist/client-IOM55ZCS.js.map +1 -0
  32. package/dist/completion-ZZGX5BQC.js +100 -0
  33. package/dist/completion-ZZGX5BQC.js.map +1 -0
  34. package/dist/config-XJL5TSYK.js +690 -0
  35. package/dist/config-XJL5TSYK.js.map +1 -0
  36. package/dist/config-store-3ZSYGXMQ.js +44 -0
  37. package/dist/config-store-3ZSYGXMQ.js.map +1 -0
  38. package/dist/docs-MDKKSJDC.js +102 -0
  39. package/dist/docs-MDKKSJDC.js.map +1 -0
  40. package/dist/eoa-IQ72EIHR.js +551 -0
  41. package/dist/eoa-IQ72EIHR.js.map +1 -0
  42. package/dist/errors-WMZIEGQI.js +18 -0
  43. package/dist/errors-WMZIEGQI.js.map +1 -0
  44. package/dist/explain-H4EH3KH3.js +165 -0
  45. package/dist/explain-H4EH3KH3.js.map +1 -0
  46. package/dist/global-options-XOLJUPTT.js +18 -0
  47. package/dist/global-options-XOLJUPTT.js.map +1 -0
  48. package/dist/health-VZEIII74.js +98 -0
  49. package/dist/health-VZEIII74.js.map +1 -0
  50. package/dist/help-footer-GTANVDNP.js +43 -0
  51. package/dist/help-footer-GTANVDNP.js.map +1 -0
  52. package/dist/index.d.ts +2 -0
  53. package/dist/index.js +251 -0
  54. package/dist/index.js.map +1 -0
  55. package/dist/intro-PQQTYWR7.js +41 -0
  56. package/dist/intro-PQQTYWR7.js.map +1 -0
  57. package/dist/markets-C37JZDPE.js +295 -0
  58. package/dist/markets-C37JZDPE.js.map +1 -0
  59. package/dist/output-VCBZ3FM7.js +22 -0
  60. package/dist/output-VCBZ3FM7.js.map +1 -0
  61. package/dist/portfolio-2AEPIJIG.js +115 -0
  62. package/dist/portfolio-2AEPIJIG.js.map +1 -0
  63. package/dist/protocol-XEQXF2GW.js +1572 -0
  64. package/dist/protocol-XEQXF2GW.js.map +1 -0
  65. package/dist/quote-I4DVJ7ZB.js +144 -0
  66. package/dist/quote-I4DVJ7ZB.js.map +1 -0
  67. package/dist/schema-PIFQ65TS.js +410 -0
  68. package/dist/schema-PIFQ65TS.js.map +1 -0
  69. package/dist/setup-USZ6IODD.js +260 -0
  70. package/dist/setup-USZ6IODD.js.map +1 -0
  71. package/dist/stdin-YW2CEQXU.js +28 -0
  72. package/dist/stdin-YW2CEQXU.js.map +1 -0
  73. package/dist/trace-IZBYTUFO.js +103 -0
  74. package/dist/trace-IZBYTUFO.js.map +1 -0
  75. package/dist/trade-IIZSEXEI.js +586 -0
  76. package/dist/trade-IIZSEXEI.js.map +1 -0
  77. package/dist/version-JDK3PEP5.js +117 -0
  78. package/dist/version-JDK3PEP5.js.map +1 -0
  79. package/dist/version-check-TDCION37.js +138 -0
  80. package/dist/version-check-TDCION37.js.map +1 -0
  81. package/dist/webhooks-PTVRKICZ.js +680 -0
  82. package/dist/webhooks-PTVRKICZ.js.map +1 -0
  83. package/dist/with-retry-4FIZG3A7.js +223 -0
  84. package/dist/with-retry-4FIZG3A7.js.map +1 -0
  85. package/package.json +99 -0
@@ -0,0 +1,43 @@
1
+ #!/usr/bin/env node
2
+
3
+ // src/utils/help-footer.ts
4
+ var DOCS_BASE_URL = "https://kash.bot/docs/cli";
5
+ function withDocsFooter(cmd, slug) {
6
+ const url = slug ? `${DOCS_BASE_URL}/${slug}` : DOCS_BASE_URL;
7
+ cmd.addHelpText("after", `
8
+ More: ${url}
9
+ `);
10
+ return cmd;
11
+ }
12
+ function attachDocsFooters(program) {
13
+ const slugByName = {
14
+ account: "account",
15
+ auth: "authentication",
16
+ markets: "markets",
17
+ quote: "quotes",
18
+ trade: "trades",
19
+ portfolio: "portfolio",
20
+ protocol: "direct-mode",
21
+ eoa: "eoa-mode",
22
+ webhooks: "webhooks",
23
+ config: "configuration",
24
+ health: "health",
25
+ version: "version",
26
+ explain: "errors",
27
+ schema: "schemas",
28
+ setup: "setup",
29
+ trace: "trace",
30
+ "with-retry": "with-retry",
31
+ docs: "introspection",
32
+ completion: "completion"
33
+ };
34
+ for (const cmd of program.commands) {
35
+ const slug = slugByName[cmd.name()] ?? "";
36
+ withDocsFooter(cmd, slug);
37
+ }
38
+ }
39
+ export {
40
+ attachDocsFooters,
41
+ withDocsFooter
42
+ };
43
+ //# sourceMappingURL=help-footer-GTANVDNP.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/utils/help-footer.ts"],"sourcesContent":["/**\n * Inline docs footers for `--help` output.\n *\n * Every top-level command registered with the CLI gets a footer line\n * pointing at the matching docs page. Keeps the help output skimmable\n * while still giving users (and AI agents reading `kash docs --json`)\n * a deep-link to the prose explanation.\n *\n * Footer text is appended via Commander's `addHelpText('after', ...)`,\n * which appears after `Examples:` (when present) but before Commander's\n * own boilerplate. Commands that already have an `addHelpText` block\n * stack with this one — order is registration order.\n */\n\nimport type { Command } from 'commander';\n\nconst DOCS_BASE_URL = 'https://kash.bot/docs/cli';\n\n/**\n * Append a one-line \"More: <url>\" footer to the command's `--help`\n * output. The URL is composed from `DOCS_BASE_URL` + the supplied\n * slug. Pass slug `''` to point at the CLI index page.\n *\n * Typical usage at the registration site:\n *\n * ```ts\n * import { withDocsFooter } from '../utils/help-footer.js';\n *\n * const marketsCommand = withDocsFooter(\n * new Command('markets').description('…'),\n * 'markets'\n * );\n * ```\n *\n * The helper returns the same command instance so it can be chained\n * inline with the rest of the builder.\n */\nexport function withDocsFooter(cmd: Command, slug: string): Command {\n const url = slug ? `${DOCS_BASE_URL}/${slug}` : DOCS_BASE_URL;\n cmd.addHelpText('after', `\\nMore: ${url}\\n`);\n return cmd;\n}\n\n/**\n * Apply a docs-footer line to every top-level command registered on\n * the root program. Maps known command names to their docs slug; any\n * command whose name isn't in the map gets the CLI-index footer.\n *\n * Call this AFTER all `program.addCommand(...)` calls so we walk the\n * fully-populated tree.\n */\nexport function attachDocsFooters(program: Command): void {\n const slugByName: Record<string, string> = {\n account: 'account',\n auth: 'authentication',\n markets: 'markets',\n quote: 'quotes',\n trade: 'trades',\n portfolio: 'portfolio',\n protocol: 'direct-mode',\n eoa: 'eoa-mode',\n webhooks: 'webhooks',\n config: 'configuration',\n health: 'health',\n version: 'version',\n explain: 'errors',\n schema: 'schemas',\n setup: 'setup',\n trace: 'trace',\n 'with-retry': 'with-retry',\n docs: 'introspection',\n completion: 'completion',\n };\n\n for (const cmd of program.commands) {\n const slug = slugByName[cmd.name()] ?? '';\n withDocsFooter(cmd, slug);\n }\n}\n"],"mappings":";;;AAgBA,IAAM,gBAAgB;AAqBf,SAAS,eAAe,KAAc,MAAuB;AAClE,QAAM,MAAM,OAAO,GAAG,aAAa,IAAI,IAAI,KAAK;AAChD,MAAI,YAAY,SAAS;AAAA,QAAW,GAAG;AAAA,CAAI;AAC3C,SAAO;AACT;AAUO,SAAS,kBAAkB,SAAwB;AACxD,QAAM,aAAqC;AAAA,IACzC,SAAS;AAAA,IACT,MAAM;AAAA,IACN,SAAS;AAAA,IACT,OAAO;AAAA,IACP,OAAO;AAAA,IACP,WAAW;AAAA,IACX,UAAU;AAAA,IACV,KAAK;AAAA,IACL,UAAU;AAAA,IACV,QAAQ;AAAA,IACR,QAAQ;AAAA,IACR,SAAS;AAAA,IACT,SAAS;AAAA,IACT,QAAQ;AAAA,IACR,OAAO;AAAA,IACP,OAAO;AAAA,IACP,cAAc;AAAA,IACd,MAAM;AAAA,IACN,YAAY;AAAA,EACd;AAEA,aAAW,OAAO,QAAQ,UAAU;AAClC,UAAM,OAAO,WAAW,IAAI,KAAK,CAAC,KAAK;AACvC,mBAAe,KAAK,IAAI;AAAA,EAC1B;AACF;","names":[]}
@@ -0,0 +1,2 @@
1
+
2
+ export { }
package/dist/index.js ADDED
@@ -0,0 +1,251 @@
1
+ #!/usr/bin/env node
2
+ import {
3
+ CLI_VERSION
4
+ } from "./chunk-BN2CUM42.js";
5
+
6
+ // src/utils/debug-hint.ts
7
+ function isTruthyEnv(value) {
8
+ if (value === void 0) return false;
9
+ const v = value.trim().toLowerCase();
10
+ return v === "1" || v === "true" || v === "yes" || v === "on";
11
+ }
12
+ function isDebugOn(argv2 = process.argv, env = process.env) {
13
+ return argv2.slice(2).includes("--debug") || isTruthyEnv(env["KASH_DEBUG"]);
14
+ }
15
+ function shouldPromoteDebug(code) {
16
+ switch (code) {
17
+ case "INVALID_INPUT":
18
+ case "CONFIGURATION":
19
+ case "INVALID_USEROP":
20
+ case "INSUFFICIENT_FUNDS":
21
+ case "INSUFFICIENT_GAS":
22
+ case "INSUFFICIENT_SCOPE":
23
+ return false;
24
+ default:
25
+ return true;
26
+ }
27
+ }
28
+
29
+ // src/index.ts
30
+ for (const stream of [process.stdout, process.stderr]) {
31
+ stream.on("error", (err) => {
32
+ if (err.code === "EPIPE" || err.code === "EIO") {
33
+ process.exit(0);
34
+ }
35
+ throw err;
36
+ });
37
+ }
38
+ process.on("uncaughtException", (err) => {
39
+ if (err.code === "EPIPE" || err.code === "EIO") {
40
+ process.exit(0);
41
+ }
42
+ throw err;
43
+ });
44
+ var argv = process.argv;
45
+ if (argv[2] === "--version" || argv[2] === "-V") {
46
+ if (argv.slice(3).includes("--json")) {
47
+ const [{ buildVersionManifest }, { printJson: printJson2 }] = await Promise.all([
48
+ import("./version-JDK3PEP5.js"),
49
+ import("./output-VCBZ3FM7.js")
50
+ ]);
51
+ printJson2(buildVersionManifest());
52
+ } else {
53
+ process.stdout.write(`${CLI_VERSION}
54
+ `);
55
+ }
56
+ process.exit(0);
57
+ }
58
+ {
59
+ const tail = argv.slice(2);
60
+ const helpIdx = tail.indexOf("--help");
61
+ const dashHIdx = tail.indexOf("-h");
62
+ const hasHelp = helpIdx !== -1 || dashHIdx !== -1;
63
+ const hasJson = tail.includes("--json");
64
+ const hasOther = tail.some(
65
+ (t) => t !== "--help" && t !== "-h" && t !== "--json" && t !== "--quiet"
66
+ );
67
+ if (hasHelp && hasJson && !hasOther) {
68
+ process.argv = [argv[0], argv[1], "docs", "--json"];
69
+ if (tail.includes("--quiet")) process.argv.push("--quiet");
70
+ }
71
+ }
72
+ var onlyArgs = argv.slice(2);
73
+ var isBareInvocation = onlyArgs.length === 0 || onlyArgs.length === 1 && (onlyArgs[0] === "--json" || onlyArgs[0] === "--quiet");
74
+ if (isBareInvocation) {
75
+ const wantsJson = onlyArgs.includes("--json");
76
+ const wantsQuiet = onlyArgs.includes("--quiet") || isTruthyEnv2(process.env["KASH_QUIET"]);
77
+ if (wantsQuiet && !wantsJson) {
78
+ process.exit(0);
79
+ }
80
+ const { buildIntroEnvelope, INTRO_SUGGESTIONS, DOCS_URL } = await import("./intro-PQQTYWR7.js");
81
+ if (wantsJson) {
82
+ const { printJson: printJson2 } = await import("./output-VCBZ3FM7.js");
83
+ printJson2(buildIntroEnvelope(CLI_VERSION));
84
+ } else {
85
+ const { print, style } = await import("./output-VCBZ3FM7.js");
86
+ print("");
87
+ print(`${style.bold("kash")} ${style.dim(`v${CLI_VERSION}`)} \u2014 Kash prediction markets CLI`);
88
+ print("");
89
+ for (const s of INTRO_SUGGESTIONS) {
90
+ print(` ${style.bold(s.title)}`);
91
+ print(` ${style.cyan(s.command)}`);
92
+ print(` ${style.dim(s.description)}`);
93
+ print("");
94
+ }
95
+ print(
96
+ `${style.dim("Run")} ${style.cyan("kash --help")} ${style.dim("for the full command list.")}`
97
+ );
98
+ print(`${style.dim("Docs:")} ${DOCS_URL}`);
99
+ print("");
100
+ }
101
+ process.exit(0);
102
+ }
103
+ function isTruthyEnv2(value) {
104
+ if (value === void 0) return false;
105
+ const v = value.trim().toLowerCase();
106
+ return v === "1" || v === "true" || v === "yes" || v === "on";
107
+ }
108
+ var { Command } = await import("commander");
109
+ var { authCommand } = await import("./auth-GUJCVKTD.js");
110
+ var { configCommand } = await import("./config-XJL5TSYK.js");
111
+ var { buildDocsCommand } = await import("./docs-MDKKSJDC.js");
112
+ var { eoaCommand } = await import("./eoa-IQ72EIHR.js");
113
+ var { explainCommand } = await import("./explain-H4EH3KH3.js");
114
+ var { accountCommand } = await import("./account-AVFLEM5D.js");
115
+ var { healthCommand } = await import("./health-VZEIII74.js");
116
+ var { marketsCommand } = await import("./markets-C37JZDPE.js");
117
+ var { portfolioCommand } = await import("./portfolio-2AEPIJIG.js");
118
+ var { protocolCommand } = await import("./protocol-XEQXF2GW.js");
119
+ var { quoteCommand } = await import("./quote-I4DVJ7ZB.js");
120
+ var { schemaCommand } = await import("./schema-PIFQ65TS.js");
121
+ var { setupCommand } = await import("./setup-USZ6IODD.js");
122
+ var { traceCommand } = await import("./trace-IZBYTUFO.js");
123
+ var { tradeCommand } = await import("./trade-IIZSEXEI.js");
124
+ var { withRetryCommand } = await import("./with-retry-4FIZG3A7.js");
125
+ var { versionCommand } = await import("./version-JDK3PEP5.js");
126
+ var { webhooksCommand } = await import("./webhooks-PTVRKICZ.js");
127
+ var { createCompletionCommand, initCompletion } = await import("./completion-ZZGX5BQC.js");
128
+ var { EXIT_CODES, toCliError } = await import("./errors-WMZIEGQI.js");
129
+ var { readGlobals } = await import("./global-options-XOLJUPTT.js");
130
+ var { configureOutput, log, printJson } = await import("./output-VCBZ3FM7.js");
131
+ var program = new Command();
132
+ program.name("kash").description("Official command-line interface for the Kash public API.").version(CLI_VERSION, "-V, --version", "output the CLI version").option("--json", "emit machine-readable JSON instead of human-formatted output", false).option(
133
+ "--quiet",
134
+ "suppress spinners, progress, informational logs, AND human-mode tables (pair with --json \u2014 bare --quiet on a list/get command produces no stdout at all by design)",
135
+ false
136
+ ).option("--no-color", "disable ANSI color in human-mode output").option(
137
+ "--debug",
138
+ "emit SDK request/response/retry/error traces to stderr; pairs with --json for NDJSON traces",
139
+ false
140
+ ).option(
141
+ "-p, --profile <name>",
142
+ "pick a named profile from ~/.kash/config.json (overrides KASH_PROFILE)"
143
+ ).option(
144
+ "--config <path>",
145
+ "use an explicit config file path instead of ~/.kash/config.json (overrides KASH_CONFIG)"
146
+ ).option("--base-url <url>", "override the API base URL for this invocation only").option("--max-retries <n>", "override the SDK retry budget for this invocation only").option("--timeout-ms <n>", "override the SDK request timeout (ms) for this invocation only").option(
147
+ "--api-version <date>",
148
+ "pin against a public-API contract date (sent as 'X-Kash-Api-Version: <date>'). Omit to let the server use its canonical default."
149
+ ).option(
150
+ "--fields <list>",
151
+ "comma-separated dot-paths to project on JSON output (e.g. id,title,outcomes.label)"
152
+ ).option(
153
+ "--filter <expr>",
154
+ "boolean predicate on JSON entries (e.g. 'status==ACTIVE && outcomeCount>2')"
155
+ ).hook("preAction", (thisCommand) => {
156
+ const globals = readGlobals(thisCommand);
157
+ configureOutput({
158
+ quiet: globals.quiet,
159
+ noColor: globals.noColor,
160
+ fields: globals.fields,
161
+ filter: globals.filter
162
+ });
163
+ }).addHelpText(
164
+ "after",
165
+ `
166
+ Common workflows:
167
+ First-time setup kash setup
168
+ Switch / inspect profile kash su <name>
169
+ Browse markets kash markets list --status ACTIVE
170
+ Place a trade and wait kash trade buy <id> --outcome 0 --amount 10 --wait
171
+ Inspect portfolio kash portfolio show && kash portfolio positions
172
+
173
+ For AI agents:
174
+ Universal agent mode kash <any-command> --json --quiet
175
+ Discover all commands kash docs --json --quiet
176
+ Get a request schema kash schema CreateTradeBody --json
177
+ Recover from an error kash explain RATE_LIMITED --json
178
+ Stream paginated reads kash markets list --ndjson
179
+
180
+ Exit codes:
181
+ 0 success
182
+ 1 generic error (validation, server, network, \u2026)
183
+ 2 auth failure (missing or invalid API key, missing scope)
184
+
185
+ Run \`kash <command> --help\` for command-specific help and examples.
186
+ Docs: https://kash.bot/docs/cli
187
+ `
188
+ );
189
+ program.exitOverride();
190
+ program.addCommand(authCommand);
191
+ program.addCommand(accountCommand);
192
+ program.addCommand(marketsCommand);
193
+ program.addCommand(quoteCommand);
194
+ program.addCommand(tradeCommand);
195
+ program.addCommand(portfolioCommand);
196
+ program.addCommand(protocolCommand);
197
+ program.addCommand(eoaCommand);
198
+ program.addCommand(webhooksCommand);
199
+ program.addCommand(configCommand);
200
+ program.addCommand(healthCommand);
201
+ program.addCommand(versionCommand);
202
+ program.addCommand(explainCommand);
203
+ program.addCommand(schemaCommand);
204
+ program.addCommand(setupCommand);
205
+ program.addCommand(traceCommand);
206
+ program.addCommand(withRetryCommand);
207
+ program.addCommand(buildDocsCommand(() => program));
208
+ program.addCommand(createCompletionCommand());
209
+ var { attachDocsFooters } = await import("./help-footer-GTANVDNP.js");
210
+ attachDocsFooters(program);
211
+ await initCompletion();
212
+ try {
213
+ await program.parseAsync(process.argv);
214
+ } catch (rawError) {
215
+ const error = toCliError(rawError);
216
+ if (error.code === "NOOP" && error.exitCode === EXIT_CODES.OK) {
217
+ process.exit(0);
218
+ }
219
+ emitError(error);
220
+ process.exit(error.exitCode);
221
+ }
222
+ function emitError(error) {
223
+ const json = safeReadJsonFlag();
224
+ if (json) {
225
+ printJson(error.toEnvelope());
226
+ return;
227
+ }
228
+ log.error(`[${error.code}] ${error.message}`);
229
+ if (error.suggestion) {
230
+ log.detail("Suggestion", error.suggestion);
231
+ }
232
+ if (error.retryAfterMs !== void 0) {
233
+ log.detail("Retry after", `${String(Math.round(error.retryAfterMs / 1e3))}s`);
234
+ }
235
+ if (error.docsUrl) {
236
+ log.detail("Docs", error.docsUrl);
237
+ }
238
+ if (error.requestId) {
239
+ log.detail("Request ID", error.requestId);
240
+ }
241
+ if (error.code !== "UNEXPECTED") {
242
+ log.detail("More", `kash explain ${error.code}`);
243
+ }
244
+ if (!isDebugOn(process.argv, process.env) && shouldPromoteDebug(error.code)) {
245
+ log.detail("Debug", "Re-run with --debug for verbose HTTP logs.");
246
+ }
247
+ }
248
+ function safeReadJsonFlag() {
249
+ return process.argv.slice(2).includes("--json");
250
+ }
251
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/utils/debug-hint.ts","../src/index.ts"],"sourcesContent":["/**\n * Helpers for the \"Re-run with --debug for verbose HTTP logs\" hint\n * emitted on the error path in `src/index.ts`.\n *\n * Factored out of `src/index.ts` so the helpers are unit-testable —\n * `index.ts` is the CLI entry point and runs Commander at module load,\n * so importing it from a test triggers `process.exit`.\n */\n\n/**\n * Recognise truthy env values the way every other tool does: `1`,\n * `true`, `yes`, `on` (case-insensitive). Empty string and `0` are\n * falsy. Anything else is a no-op rather than an error — env\n * pollution is common and shouldn't fail builds.\n *\n * Local copy of the same helper that lives in `utils/global-options.ts`\n * — kept in sync intentionally; the two MUST agree on what counts as\n * \"debug on\" or the UX gets confusing (readGlobals decides \"is\n * --debug active?\" via isTruthyEnv, and the error path's hint decides\n * \"should I suggest --debug?\" via the same rule).\n */\nfunction isTruthyEnv(value: string | undefined): boolean {\n if (value === undefined) return false;\n const v = value.trim().toLowerCase();\n return v === '1' || v === 'true' || v === 'yes' || v === 'on';\n}\n\n/**\n * \"Is debug already on?\" — used on the error path to decide whether to\n * promote `--debug` as a next-step hint. Mirrors readGlobals'\n * resolution: either the `--debug` flag is in argv, or `KASH_DEBUG`\n * is a *truthy* value per the shared `isTruthyEnv` rule.\n *\n * Critical: a bare presence check on `KASH_DEBUG` would mistakenly\n * skip the hint when the user has `KASH_DEBUG=0` / `=false` / `=no`\n * set — those env values do NOT enable debug mode in readGlobals,\n * so the hint should still fire. The two resolution paths must\n * agree or the UX gets confused.\n *\n * Pure inputs → pure output; safe to invoke with synthetic argv/env\n * in unit tests without touching `process`.\n */\nexport function isDebugOn(\n argv: readonly string[] = process.argv,\n env: NodeJS.ProcessEnv = process.env\n): boolean {\n return argv.slice(2).includes('--debug') || isTruthyEnv(env['KASH_DEBUG']);\n}\n\n/**\n * Promote `--debug` for codes where verbose HTTP logs help — anything\n * the operator can't fix by changing input. Validation / config /\n * input errors don't benefit from more logs (the cause is right there\n * in the message).\n */\nexport function shouldPromoteDebug(code: string): boolean {\n switch (code) {\n case 'INVALID_INPUT':\n case 'CONFIGURATION':\n case 'INVALID_USEROP':\n case 'INSUFFICIENT_FUNDS':\n case 'INSUFFICIENT_GAS':\n case 'INSUFFICIENT_SCOPE':\n return false;\n default:\n return true;\n }\n}\n","/**\n * `kash` — official command-line interface for the Kash public API.\n *\n * The binary is a thin wrapper over `@kashdao/sdk`. Every command\n * resolves its config (file → env), constructs a KashClient, and\n * defers to the SDK for the actual work. This file is only the\n * Commander wiring: registration, global flags, and the top-level\n * error boundary.\n *\n * **Cold-start strategy.** Plain `kash --version` and `kash -V` are the\n * single hottest invocation in CI/agent contexts (every health probe,\n * every doctor script). We short-circuit them before any of the\n * subcommand modules load — they pull `@kashdao/sdk`, `chalk`, `ora`,\n * etc., none of which `--version` needs. The full Commander tree is\n * built only when the user actually asks for a real command.\n */\n\nimport { isDebugOn, shouldPromoteDebug } from './utils/debug-hint.js';\nimport { CLI_VERSION } from './version.js';\n\n// ── SIGPIPE-safe stdout/stderr ──────────────────────────────────────\n//\n// `kash <cmd> | head` is a common shell pattern; without this guard,\n// when `head` closes the pipe early Node throws `EPIPE` from the next\n// `process.stdout.write`, which surfaces as exit code 1 — surprising\n// for users piping output into `head`/`less`/`column`. We treat\n// EPIPE / EIO as a clean exit (0): downstream told us to stop, we\n// stop. Any other write error still propagates so real I/O failures\n// aren't masked.\n//\n// Two listeners are needed:\n// 1. `'error'` on the streams catches EPIPE delivered as an event\n// (async writes / future flushes).\n// 2. `'uncaughtException'` catches EPIPE thrown synchronously by a\n// `process.stdout.write` call when the pipe is already closed —\n// this is what `head -c 5` triggers and the stream listener\n// doesn't see.\nfor (const stream of [process.stdout, process.stderr]) {\n stream.on('error', (err: NodeJS.ErrnoException) => {\n if (err.code === 'EPIPE' || err.code === 'EIO') {\n process.exit(0);\n }\n throw err;\n });\n}\nprocess.on('uncaughtException', (err: NodeJS.ErrnoException) => {\n if (err.code === 'EPIPE' || err.code === 'EIO') {\n process.exit(0);\n }\n // Re-throw so Node's default handler logs and exits with 1.\n throw err;\n});\n\n// ── Fast path: plain `--version` / `-V` ─────────────────────────────\n//\n// Short-circuits before commander, the SDK, and every command module\n// are imported. The structured `--version --json` path still needs\n// `buildVersionManifest` (which reads `os` info) and `printJson`, but\n// even those load lazily so the simpler `kash --version` only pays\n// for `version.js`.\nconst argv = process.argv;\nif (argv[2] === '--version' || argv[2] === '-V') {\n if (argv.slice(3).includes('--json')) {\n const [{ buildVersionManifest }, { printJson }] = await Promise.all([\n import('./commands/version.js'),\n import('./utils/output.js'),\n ]);\n printJson(buildVersionManifest());\n } else {\n process.stdout.write(`${CLI_VERSION}\\n`);\n }\n process.exit(0);\n}\n\n// ── Fast path: `kash --help --json` / `kash --json --help` ──────────\n//\n// Commander's default `--help` renderer emits human-formatted text —\n// useful for operators, useless for AI agents probing the surface.\n// When `--help` is paired with `--json` (any order, no other args),\n// route to the structured `kash docs --json --quiet` envelope. That's\n// the canonical machine-readable help and pinning to it keeps the\n// agent contract clean.\n//\n// We don't try to handle `kash <subcommand> --help --json` — those\n// fall through to Commander's text help, and the right answer for\n// agents is to fetch the full tree once via `kash docs --json` and\n// drill down.\n{\n const tail = argv.slice(2);\n const helpIdx = tail.indexOf('--help');\n const dashHIdx = tail.indexOf('-h');\n const hasHelp = helpIdx !== -1 || dashHIdx !== -1;\n const hasJson = tail.includes('--json');\n const hasOther = tail.some(\n (t) => t !== '--help' && t !== '-h' && t !== '--json' && t !== '--quiet'\n );\n if (hasHelp && hasJson && !hasOther) {\n // Use the existing docs command via its describeCommand walker.\n // We need a fully-built program to walk, so we let the eager\n // imports below run and handle this in the docs command's own\n // action. Mark it with the flag and let it fall through.\n process.argv = [argv[0]!, argv[1]!, 'docs', '--json'];\n if (tail.includes('--quiet')) process.argv.push('--quiet');\n }\n}\n\n// ── Friendly intro: `kash` (no args, optionally with --json) ─────────\n//\n// Default Commander behaviour for a no-args invocation is to dump\n// `--help`, which is overwhelming on first contact. Show a curated\n// landing instead. Detected by argv length: pure `kash`, `kash --json`,\n// or `kash --quiet` (with no other tokens) trip this path.\n//\n// **Quiet contracts.** CI environments and orchestrators that spawn\n// `kash` with no extra args shouldn't see decorative output. Honour\n// `--quiet`, `KASH_QUIET=1` (env mirror — same truthy parser as\n// `KASH_DEBUG`), and the de-facto-standard `NO_COLOR`/`CI` are\n// deliberately NOT included because they have unrelated semantics.\n// In quiet mode we exit 0 with no output at all — no JSON envelope\n// either, since a script triggering this path didn't ask for it.\n//\n// Anything else (`kash foo`, `kash --help`, `kash markets …`) falls\n// through to Commander as before.\nconst onlyArgs = argv.slice(2);\nconst isBareInvocation =\n onlyArgs.length === 0 ||\n (onlyArgs.length === 1 && (onlyArgs[0] === '--json' || onlyArgs[0] === '--quiet'));\nif (isBareInvocation) {\n const wantsJson = onlyArgs.includes('--json');\n const wantsQuiet = onlyArgs.includes('--quiet') || isTruthyEnv(process.env['KASH_QUIET']);\n\n // Quiet mode: emit nothing — neither the human banner nor the JSON\n // envelope. CI scripts that bare-invoke `kash` to test the binary\n // works don't need decorative output. (`--json` still wins if the\n // user is explicit about wanting structured output.)\n if (wantsQuiet && !wantsJson) {\n process.exit(0);\n }\n\n const { buildIntroEnvelope, INTRO_SUGGESTIONS, DOCS_URL } = await import('./utils/intro.js');\n if (wantsJson) {\n const { printJson } = await import('./utils/output.js');\n printJson(buildIntroEnvelope(CLI_VERSION));\n } else {\n const { print, style } = await import('./utils/output.js');\n print('');\n print(`${style.bold('kash')} ${style.dim(`v${CLI_VERSION}`)} — Kash prediction markets CLI`);\n print('');\n for (const s of INTRO_SUGGESTIONS) {\n print(` ${style.bold(s.title)}`);\n print(` ${style.cyan(s.command)}`);\n print(` ${style.dim(s.description)}`);\n print('');\n }\n print(\n `${style.dim('Run')} ${style.cyan('kash --help')} ${style.dim('for the full command list.')}`\n );\n print(`${style.dim('Docs:')} ${DOCS_URL}`);\n print('');\n }\n process.exit(0);\n}\n\n/**\n * Mirror of the `isTruthyEnv` helper in `utils/global-options.ts`.\n * Inlined here so the bare-invocation fast path doesn't pay for the\n * full import. Same truth values: `1`, `true`, `yes`, `on`\n * (case-insensitive). Empty string and `0` are falsy.\n */\nfunction isTruthyEnv(value: string | undefined): boolean {\n if (value === undefined) return false;\n const v = value.trim().toLowerCase();\n return v === '1' || v === 'true' || v === 'yes' || v === 'on';\n}\n\n// Eager imports below run only for invocations that actually need a\n// command. The SDK-heavy modules still load — Commander needs every\n// subcommand registered up-front to render `--help` correctly — but\n// individual commands lazy-load their own dependencies (`omelette`,\n// `zod-to-json-schema`, `@kashdao/protocol-sdk`, `viem`) inside their\n// action handlers.\nconst { Command } = await import('commander');\nconst { authCommand } = await import('./commands/auth/index.js');\nconst { configCommand } = await import('./commands/config/index.js');\nconst { buildDocsCommand } = await import('./commands/docs.js');\nconst { eoaCommand } = await import('./commands/eoa/index.js');\nconst { explainCommand } = await import('./commands/explain.js');\nconst { accountCommand } = await import('./commands/account/index.js');\nconst { healthCommand } = await import('./commands/health.js');\nconst { marketsCommand } = await import('./commands/markets/index.js');\nconst { portfolioCommand } = await import('./commands/portfolio/index.js');\nconst { protocolCommand } = await import('./commands/protocol/index.js');\nconst { quoteCommand } = await import('./commands/quote/index.js');\nconst { schemaCommand } = await import('./commands/schema.js');\nconst { setupCommand } = await import('./commands/setup.js');\nconst { traceCommand } = await import('./commands/trace.js');\nconst { tradeCommand } = await import('./commands/trade/index.js');\nconst { withRetryCommand } = await import('./commands/with-retry.js');\nconst { versionCommand } = await import('./commands/version.js');\nconst { webhooksCommand } = await import('./commands/webhooks/index.js');\nconst { createCompletionCommand, initCompletion } = await import('./completion.js');\nconst { EXIT_CODES, toCliError } = await import('./errors.js');\nconst { readGlobals } = await import('./utils/global-options.js');\nconst { configureOutput, log, printJson } = await import('./utils/output.js');\n\nimport type { CliError } from './errors.js';\n\nconst program = new Command();\n\nprogram\n .name('kash')\n .description('Official command-line interface for the Kash public API.')\n .version(CLI_VERSION, '-V, --version', 'output the CLI version')\n // Output controls\n .option('--json', 'emit machine-readable JSON instead of human-formatted output', false)\n .option(\n '--quiet',\n 'suppress spinners, progress, informational logs, AND human-mode tables (pair with --json — bare --quiet on a list/get command produces no stdout at all by design)',\n false\n )\n .option('--no-color', 'disable ANSI color in human-mode output')\n .option(\n '--debug',\n 'emit SDK request/response/retry/error traces to stderr; pairs with --json for NDJSON traces',\n false\n )\n // Config selection\n .option(\n '-p, --profile <name>',\n 'pick a named profile from ~/.kash/config.json (overrides KASH_PROFILE)'\n )\n .option(\n '--config <path>',\n 'use an explicit config file path instead of ~/.kash/config.json (overrides KASH_CONFIG)'\n )\n // SDK overrides — useful for staging tests, CI matrix builds, agent retry tuning\n .option('--base-url <url>', 'override the API base URL for this invocation only')\n .option('--max-retries <n>', 'override the SDK retry budget for this invocation only')\n .option('--timeout-ms <n>', 'override the SDK request timeout (ms) for this invocation only')\n .option(\n '--api-version <date>',\n \"pin against a public-API contract date (sent as 'X-Kash-Api-Version: <date>'). \" +\n 'Omit to let the server use its canonical default.'\n )\n // Output projection — applied only on --json/--ndjson output\n .option(\n '--fields <list>',\n 'comma-separated dot-paths to project on JSON output (e.g. id,title,outcomes.label)'\n )\n .option(\n '--filter <expr>',\n \"boolean predicate on JSON entries (e.g. 'status==ACTIVE && outcomeCount>2')\"\n )\n .hook('preAction', (thisCommand) => {\n const globals = readGlobals(thisCommand);\n configureOutput({\n quiet: globals.quiet,\n noColor: globals.noColor,\n fields: globals.fields,\n filter: globals.filter,\n });\n })\n .addHelpText(\n 'after',\n `\nCommon workflows:\n First-time setup kash setup\n Switch / inspect profile kash su <name>\n Browse markets kash markets list --status ACTIVE\n Place a trade and wait kash trade buy <id> --outcome 0 --amount 10 --wait\n Inspect portfolio kash portfolio show && kash portfolio positions\n\nFor AI agents:\n Universal agent mode kash <any-command> --json --quiet\n Discover all commands kash docs --json --quiet\n Get a request schema kash schema CreateTradeBody --json\n Recover from an error kash explain RATE_LIMITED --json\n Stream paginated reads kash markets list --ndjson\n\nExit codes:\n 0 success\n 1 generic error (validation, server, network, …)\n 2 auth failure (missing or invalid API key, missing scope)\n\nRun \\`kash <command> --help\\` for command-specific help and examples.\nDocs: https://kash.bot/docs/cli\n`\n );\n\n// Hand control of Commander's exit behaviour to our top-level error\n// boundary. Without this, Commander calls `process.exit(1)` directly\n// on unknown commands / unknown options, skipping our structured\n// error envelope. With `exitOverride`, Commander throws a\n// `CommanderError` we can map to a `CliError` (see `toCliError` in\n// errors.ts).\n//\n// Help and version short-circuits still get filtered there — they\n// surface as `commander.help`/`commander.helpDisplayed`/`commander.version`\n// codes which the mapper detects and treats as clean exits.\nprogram.exitOverride();\n\n// Register top-level command groups.\nprogram.addCommand(authCommand);\nprogram.addCommand(accountCommand);\nprogram.addCommand(marketsCommand);\nprogram.addCommand(quoteCommand);\nprogram.addCommand(tradeCommand);\nprogram.addCommand(portfolioCommand);\nprogram.addCommand(protocolCommand);\nprogram.addCommand(eoaCommand);\nprogram.addCommand(webhooksCommand);\nprogram.addCommand(configCommand);\nprogram.addCommand(healthCommand);\nprogram.addCommand(versionCommand);\nprogram.addCommand(explainCommand);\nprogram.addCommand(schemaCommand);\nprogram.addCommand(setupCommand);\nprogram.addCommand(traceCommand);\nprogram.addCommand(withRetryCommand);\nprogram.addCommand(buildDocsCommand(() => program));\nprogram.addCommand(createCompletionCommand());\n\n// Append a per-command \"More: <docs-url>\" footer to every top-level\n// `--help` page. Done after every command is registered so we walk\n// the fully-populated tree once.\nconst { attachDocsFooters } = await import('./utils/help-footer.js');\nattachDocsFooters(program);\n\n// Initialize shell completion before parseAsync — omelette needs to\n// see the args first to detect a completion request. Now async because\n// `initCompletion` lazy-imports omelette only when the args look like\n// a completion handshake.\nawait initCompletion();\n\ntry {\n await program.parseAsync(process.argv);\n // Let Node exit naturally on success so any buffered stdout writes\n // (NDJSON streams, large `--all` exports through a pipe) flush\n // cleanly. Calling `process.exit` here would truncate the buffer\n // when stdout is connected to a slow consumer. The error path\n // still calls `process.exit` because we want a deterministic exit\n // code; data loss isn't a concern when we already failed.\n} catch (rawError) {\n const error = toCliError(rawError);\n // Clean exits (e.g. `--help` and `--version` short-circuits surfaced\n // via Commander's `exitOverride`) bypass the error renderer — they\n // already wrote their output to stdout and there's nothing to add.\n if (error.code === 'NOOP' && error.exitCode === EXIT_CODES.OK) {\n process.exit(0);\n }\n emitError(error);\n process.exit(error.exitCode);\n}\n\n/**\n * Render the error using whichever output mode is currently active.\n * In JSON mode we stay machine-readable so an AI agent can branch on\n * `code` without parsing prose; in human mode we surface the\n * suggestion (when available) and the request id (when available).\n *\n * `readGlobals` itself can throw when a flag value is malformed\n * (`--base-url not-a-url`, `--max-retries 99`). On the error path\n * we shouldn't double-throw — fall back to a minimal mode (sniff the\n * raw argv for `--json` / `--quiet`) so the original error is still\n * surfaced cleanly.\n */\nfunction emitError(error: CliError): void {\n const json = safeReadJsonFlag();\n if (json) {\n printJson(error.toEnvelope());\n return;\n }\n log.error(`[${error.code}] ${error.message}`);\n if (error.suggestion) {\n log.detail('Suggestion', error.suggestion);\n }\n if (error.retryAfterMs !== undefined) {\n log.detail('Retry after', `${String(Math.round(error.retryAfterMs / 1000))}s`);\n }\n if (error.docsUrl) {\n log.detail('Docs', error.docsUrl);\n }\n if (error.requestId) {\n log.detail('Request ID', error.requestId);\n }\n // Always promote the explainer for the structured-actions catalog —\n // it's the deepest source of recovery info the CLI ships with and\n // every catalog entry has a `kash explain CODE` payload. Skipped\n // when the code itself isn't in the catalog (UNEXPECTED, etc.) to\n // avoid pointing the user at an empty page.\n if (error.code !== 'UNEXPECTED') {\n log.detail('More', `kash explain ${error.code}`);\n }\n // For non-trivial failures, surface --debug as the next-step lever.\n // It enables verbose request/response logging on the SDK's HTTP\n // path — the natural diagnostic when an error keeps recurring.\n // Skipped when --debug is already on (don't suggest what they're\n // already doing) and on plain validation errors (the user needs to\n // fix input, not log more bytes).\n if (!isDebugOn(process.argv, process.env) && shouldPromoteDebug(error.code)) {\n log.detail('Debug', 'Re-run with --debug for verbose HTTP logs.');\n }\n}\n\n/**\n * Inspect the raw argv for `--json` without re-running validation —\n * used on the error path so a malformed flag value (which is what\n * triggered the error in the first place) doesn't double-throw and\n * obscure the original failure.\n */\nfunction safeReadJsonFlag(): boolean {\n return process.argv.slice(2).includes('--json');\n}\n"],"mappings":";;;;;;AAqBA,SAAS,YAAY,OAAoC;AACvD,MAAI,UAAU,OAAW,QAAO;AAChC,QAAM,IAAI,MAAM,KAAK,EAAE,YAAY;AACnC,SAAO,MAAM,OAAO,MAAM,UAAU,MAAM,SAAS,MAAM;AAC3D;AAiBO,SAAS,UACdA,QAA0B,QAAQ,MAClC,MAAyB,QAAQ,KACxB;AACT,SAAOA,MAAK,MAAM,CAAC,EAAE,SAAS,SAAS,KAAK,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,OAAO,KAAK,MAAM,MAAM,eAAe,GAAI,CAAC,CAAC,GAAG;AAAA,EAC/E;AACA,MAAI,MAAM,SAAS;AACjB,QAAI,OAAO,QAAQ,MAAM,OAAO;AAAA,EAClC;AACA,MAAI,MAAM,WAAW;AACnB,QAAI,OAAO,cAAc,MAAM,SAAS;AAAA,EAC1C;AAMA,MAAI,MAAM,SAAS,cAAc;AAC/B,QAAI,OAAO,QAAQ,gBAAgB,MAAM,IAAI,EAAE;AAAA,EACjD;AAOA,MAAI,CAAC,UAAU,QAAQ,MAAM,QAAQ,GAAG,KAAK,mBAAmB,MAAM,IAAI,GAAG;AAC3E,QAAI,OAAO,SAAS,4CAA4C;AAAA,EAClE;AACF;AAQA,SAAS,mBAA4B;AACnC,SAAO,QAAQ,KAAK,MAAM,CAAC,EAAE,SAAS,QAAQ;AAChD;","names":["argv","printJson","isTruthyEnv"]}
@@ -0,0 +1,41 @@
1
+ #!/usr/bin/env node
2
+
3
+ // src/utils/intro.ts
4
+ var INTRO_SUGGESTIONS = [
5
+ {
6
+ title: "Authenticate",
7
+ command: "kash setup",
8
+ description: "Interactive first-run wizard."
9
+ },
10
+ {
11
+ title: "Browse markets",
12
+ command: "kash markets list --status ACTIVE",
13
+ description: "List active prediction markets."
14
+ },
15
+ {
16
+ title: "Place a trade and wait",
17
+ command: "kash trade buy <market-id> --outcome 0 --amount 10 --wait",
18
+ description: "Buy outcome tokens, block on settlement."
19
+ },
20
+ {
21
+ title: "For agents",
22
+ command: "kash docs --json --quiet",
23
+ description: "Full machine-readable command surface. `--json --quiet` is the universal agent mode \u2014 every command emits a stable JSON envelope on stdout."
24
+ }
25
+ ];
26
+ var DOCS_URL = "https://kash.bot/docs/cli";
27
+ function buildIntroEnvelope(version) {
28
+ return {
29
+ name: "kash",
30
+ version,
31
+ docsUrl: DOCS_URL,
32
+ suggestions: INTRO_SUGGESTIONS,
33
+ hint: "Run `kash --help` for the full command list, or `kash docs --json --quiet` for the machine-readable surface (matches the agent suggestion above)."
34
+ };
35
+ }
36
+ export {
37
+ DOCS_URL,
38
+ INTRO_SUGGESTIONS,
39
+ buildIntroEnvelope
40
+ };
41
+ //# sourceMappingURL=intro-PQQTYWR7.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/utils/intro.ts"],"sourcesContent":["/**\n * Friendly-intro suggestions for the bare `kash` invocation.\n *\n * Hoisted out of `index.ts` so:\n * 1. The list is testable in isolation (without spinning up the\n * full bare-invocation pipeline).\n * 2. Adding/removing curated suggestions doesn't churn the entry\n * point.\n * 3. Both the human and `--json` renderers consume the same source\n * of truth.\n */\n\nexport type IntroSuggestion = {\n /** Short label for human mode. */\n readonly title: string;\n /** Concrete command line a user can copy + run. */\n readonly command: string;\n /** One-sentence description of the suggestion. */\n readonly description: string;\n};\n\n/**\n * Curated 4-suggestion landing for the bare `kash` invocation. Tuned\n * for first-contact users and AI agents — covers (auth → discover →\n * trade → introspection).\n */\nexport const INTRO_SUGGESTIONS: readonly IntroSuggestion[] = [\n {\n title: 'Authenticate',\n command: 'kash setup',\n description: 'Interactive first-run wizard.',\n },\n {\n title: 'Browse markets',\n command: 'kash markets list --status ACTIVE',\n description: 'List active prediction markets.',\n },\n {\n title: 'Place a trade and wait',\n command: 'kash trade buy <market-id> --outcome 0 --amount 10 --wait',\n description: 'Buy outcome tokens, block on settlement.',\n },\n {\n title: 'For agents',\n command: 'kash docs --json --quiet',\n description:\n 'Full machine-readable command surface. `--json --quiet` is the universal agent mode — every command emits a stable JSON envelope on stdout.',\n },\n];\n\n/** Dashboard URL surfaced alongside the suggestions. */\nexport const DOCS_URL = 'https://kash.bot/docs/cli';\n\nexport type IntroEnvelope = {\n readonly name: 'kash';\n readonly version: string;\n readonly docsUrl: string;\n readonly suggestions: readonly IntroSuggestion[];\n readonly hint: string;\n};\n\n/**\n * Compose the JSON-mode intro envelope. Pure function so callers\n * (and tests) can pin to the contract shape.\n */\nexport function buildIntroEnvelope(version: string): IntroEnvelope {\n return {\n name: 'kash',\n version,\n docsUrl: DOCS_URL,\n suggestions: INTRO_SUGGESTIONS,\n hint: 'Run `kash --help` for the full command list, or `kash docs --json --quiet` for the machine-readable surface (matches the agent suggestion above).',\n };\n}\n"],"mappings":";;;AA0BO,IAAM,oBAAgD;AAAA,EAC3D;AAAA,IACE,OAAO;AAAA,IACP,SAAS;AAAA,IACT,aAAa;AAAA,EACf;AAAA,EACA;AAAA,IACE,OAAO;AAAA,IACP,SAAS;AAAA,IACT,aAAa;AAAA,EACf;AAAA,EACA;AAAA,IACE,OAAO;AAAA,IACP,SAAS;AAAA,IACT,aAAa;AAAA,EACf;AAAA,EACA;AAAA,IACE,OAAO;AAAA,IACP,SAAS;AAAA,IACT,aACE;AAAA,EACJ;AACF;AAGO,IAAM,WAAW;AAcjB,SAAS,mBAAmB,SAAgC;AACjE,SAAO;AAAA,IACL,MAAM;AAAA,IACN;AAAA,IACA,SAAS;AAAA,IACT,aAAa;AAAA,IACb,MAAM;AAAA,EACR;AACF;","names":[]}