@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
package/CHANGELOG.md ADDED
@@ -0,0 +1,78 @@
1
+ # Changelog
2
+
3
+ All notable changes to `@kashdao/cli` will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ While the package is `0.x`, minor versions may include breaking changes —
9
+ breaking changes are explicitly called out in the entry. See the
10
+ **Stability promise** section of `README.md` for what is and is not part
11
+ of the SemVer-stable contract.
12
+
13
+ The runtime contract surface (error envelope, version manifest, config
14
+ envelope, command tree) is also pinned by `tests/unit/contracts.test.ts`
15
+ — any drift there forces a deliberate update to both the schema and
16
+ the test, which surfaces in this changelog.
17
+
18
+ ## [Unreleased]
19
+
20
+ ## [0.1.0] — 2026-05-20
21
+
22
+ Initial public release.
23
+
24
+ ### Added
25
+
26
+ - **`kash setup`** — interactive first-run wizard (masked API key
27
+ prompt, profile selection, shell-completion install, health probe,
28
+ scope canary). Non-interactive via `--yes --api-key <key>`. Re-runnable
29
+ on existing configs (updates, not duplicates).
30
+ - **Multi-profile support** — `~/.kash/config.json` holds named profiles
31
+ (`default`, `live`, `test`, etc.). Switch via `--profile <name>`,
32
+ `KASH_PROFILE=<name>`, or `kash config use <name>`. Per-profile
33
+ `apiKey`, `baseUrl`, `defaultChainId`, plus protocol-mode fields
34
+ (`rpcUrl`, `smartAccount`, `bundlerUrl`, `bundlerProvider`,
35
+ `signerKeyRef`, `customChain`).
36
+ - **Auto-routing** — a `kash_test_*` API key auto-routes to staging
37
+ (`api-staging.kash.bot`); a `kash_live_*` key routes to production
38
+ (`api.kash.bot`). Mirrors `@kashdao/sdk`'s `inferBaseUrlFromApiKey()`.
39
+ Explicit `--base-url` or `KASH_BASE_URL` always wins.
40
+ - **Two orchestration modes — both fully non-custodial.** On every
41
+ path: Kash never holds funds, never moves funds, never holds keys,
42
+ and never signs anything. User funds always live in accounts the
43
+ user controls. See SECURITY.md § Non-custodial design for the full
44
+ statement.
45
+ - **Kash-orchestrated (default)** — uses the Kash public REST API
46
+ (`kash markets`, `kash quote`, `kash trade`, `kash portfolio`,
47
+ `kash webhooks`, `kash auth`, `kash trace`, `kash account`). The
48
+ API key is a scoped, revocable delegation the user issues against
49
+ their own Privy-managed smart account.
50
+ - **Self-orchestrated (`kash protocol ...`)** — wraps
51
+ `@kashdao/protocol-sdk` (signer + RPC + bundler all consumer-side).
52
+ Zero Kash backend dependency. Lazy-loaded — adds no cold-start
53
+ cost for users who stay on the Kash-orchestrated path.
54
+ - **JSON-everywhere** — every command accepts `--json` for a stable
55
+ machine-readable envelope (single object on stdout, errors on stderr).
56
+ `kash docs --json` returns the full command tree for tooling.
57
+ - **Idempotency** — `--auto-idempotency-key` on trade commands, or pass
58
+ `--idempotency-key <uuid>` manually. Replays return the cached
59
+ response.
60
+ - **Webhook ops** — `kash webhooks list`, `redeliver <eventId>`,
61
+ `rotate-secret`, `replay <file>` (offline signature preview).
62
+ - **Trade lifecycle** — `kash trade buy/sell`, `--dry-run` preview,
63
+ `--wait` polling until terminal, `kash trade status <id>`,
64
+ `kash trade confirm <id> --token <token>` for high-value flows,
65
+ `kash trade list --filter`.
66
+ - **High-value confirmation flow** — gracefully handles
67
+ `pending_confirmation` responses with a `--token` prompt or
68
+ `--auto-confirm` for trusted contexts.
69
+ - **`kash trace <correlationId>`** — end-to-end request-id trace from a
70
+ trade or webhook delivery, walks the event chain across services.
71
+ - **Typed errors + recovery hints** — every error includes a code, a
72
+ recovery suggestion (e.g., DNS errors against `api.kash.bot` suggest
73
+ using a test key), and a `kash explain <CODE>` reference.
74
+ - **Shell completion** — bash, zsh, fish via the `omelette` integration.
75
+ Installed during `kash setup` (skippable with `--yes`).
76
+ - **Cross-platform install** — npm (`npm i -g @kashdao/cli`), pnpm,
77
+ or yarn. A Homebrew tap (`kashdao/tap`) is planned for the
78
+ production launch.
@@ -0,0 +1,159 @@
1
+ # Contributing to `@kashdao/cli`
2
+
3
+ Thanks for considering a contribution. The CLI is the customer-facing
4
+ entry point for both humans and AI agents using the Kash API — every
5
+ behaviour here is something an integration may have pinned, so we hold
6
+ the bar high.
7
+
8
+ ## How development works
9
+
10
+ This repo (`KashDAO/cli`) is the **public mirror** of the CLI. The
11
+ canonical source lives inside Kash's private monorepo, and is synced
12
+ to this repo on every release. Pull requests land here in the public
13
+ mirror, get reviewed, and once accepted are re-imported into the
14
+ monorepo.
15
+
16
+ That's the same model Stripe (`stripe/stripe-cli`), GitHub
17
+ (`cli/cli`), and AWS use — public client, private server.
18
+
19
+ What that means in practice:
20
+
21
+ - ✅ Open issues and PRs in this repo.
22
+ - ✅ Comment on PRs, request changes, propose alternatives.
23
+ - ❌ The full Kash backend isn't visible from this repo. The CLI
24
+ speaks to `https://api.kash.bot/v1` like any other consumer (or
25
+ directly on-chain for `kash protocol …` and `kash eoa …`).
26
+
27
+ ## Quick start
28
+
29
+ ```sh
30
+ git clone https://github.com/KashDAO/cli.git
31
+ cd cli
32
+ pnpm install
33
+ pnpm build
34
+ pnpm test
35
+ node dist/index.js --version
36
+ ```
37
+
38
+ Requires Node 22+ and pnpm 9+.
39
+
40
+ ## What's in scope
41
+
42
+ ✅ Welcome:
43
+
44
+ - Bug fixes — especially in error envelope construction, output
45
+ formatting, and the contract surface (`kash version`,
46
+ `kash schema`, `kash docs`, `kash explain`).
47
+ - New examples under `examples/` for novel integration patterns.
48
+ - Better help text, JSON schema docs, and `--help` examples.
49
+ - Test coverage for edge cases (TTY detection, NDJSON streaming,
50
+ signal handling, BOM-aware stdin).
51
+ - Cold-start performance (stay lazy on heavy deps).
52
+
53
+ 🟡 Discuss first (open an issue):
54
+
55
+ - New commands or subcommands.
56
+ - New flags on existing commands.
57
+ - Changes to the contract surface — `CliErrorEnvelopeSchema`,
58
+ `VersionManifestSchema`, `CliConfigEnvelopeSchema`, the
59
+ `CliCapabilitySchema` enum, or any `kash *--json` shape that
60
+ agents may have pinned.
61
+ - New error codes in `src/error-catalog.ts` or changes to existing
62
+ recovery `actions[]`.
63
+ - Bumping the minimum Node version.
64
+
65
+ ❌ Out of scope:
66
+
67
+ - Wrapping the CLI in a programmatic Node API. Use
68
+ [`@kashdao/sdk`](https://www.npmjs.com/package/@kashdao/sdk) or
69
+ [`@kashdao/protocol-sdk`](https://www.npmjs.com/package/@kashdao/protocol-sdk)
70
+ directly — the CLI exists for shells and agents, not as a library.
71
+ - New runtime dependencies. The bundle is small by design; if you
72
+ need a small utility, write it inline.
73
+ - Auto-formatters / lint plugins beyond what `eslint.config.js`
74
+ already configures.
75
+
76
+ ## Standards
77
+
78
+ - **Stable JSON contracts.** Every `--json` output is pinned to a
79
+ Zod schema in `src/cli-schemas.ts`. Adding a field is a minor
80
+ bump; removing or renaming one is a breaking change. Both are
81
+ flagged by `tests/unit/contracts.test.ts`.
82
+ - **Two audiences, both first-class.** Humans get colored tables,
83
+ spinners, and tab completion; agents get `--json --quiet` with
84
+ structured errors. Don't optimise one path at the cost of the
85
+ other.
86
+ - **Errors are typed.** Throw `CliError` / `CliValidationError` from
87
+ `src/errors.ts`; never throw plain `Error`. Every code in
88
+ `src/error-catalog.ts` carries a `recoverable` flag and an
89
+ `actions[]` array of recovery hints.
90
+ - **Output through `src/utils/output.ts`.** Direct `console.log`
91
+ bypasses `--quiet` handling and chalk detection. The ESLint config
92
+ enforces this everywhere except inside `output.ts` itself.
93
+ - **Lazy-load heavy deps.** Cold start matters. The protocol-sdk and
94
+ viem are loaded only on the first `kash protocol …` or
95
+ `kash eoa …` invocation. Don't add top-level imports of `viem` or
96
+ `@kashdao/protocol-sdk` to commands that don't need them.
97
+ - **`run_command` actions with `<placeholder>` tokens MUST set
98
+ `template: true`.** Agents auto-shell concrete commands; templated
99
+ ones are surfaced for substitution. The contract test enforces
100
+ this.
101
+
102
+ ## Workflow
103
+
104
+ 1. **Fork** this repo and create a feature branch:
105
+ `git checkout -b feat/add-xyz`.
106
+ 2. **Make the change.** Run `pnpm typecheck`, `pnpm lint`, and
107
+ `pnpm test` after each substantial edit.
108
+ 3. **Add tests.** Cover happy path + at least one failure mode.
109
+ If you touch a schema in `src/cli-schemas.ts`, update
110
+ `tests/unit/contracts.test.ts` to pin the new shape.
111
+ 4. **Document.** Update the README, the `kash <cmd> --help` text,
112
+ and `CHANGELOG.md` under `[Unreleased]`.
113
+ 5. **Open a PR** with a short summary explaining the _why_, not
114
+ just the _what_. Link any related issue.
115
+
116
+ There is **no automated CI on this public mirror** for v0.x — the
117
+ maintainers run typecheck, lint, the unit + component suite, and
118
+ the runtime smoke (`scripts/runtime-smoke.mjs`) locally before
119
+ merging your PR.
120
+
121
+ ## Testing
122
+
123
+ ```sh
124
+ pnpm test # unit + component
125
+ pnpm typecheck
126
+ pnpm lint
127
+ pnpm build && node scripts/runtime-smoke.mjs # built-binary smoke
128
+ ```
129
+
130
+ The component suite under `tests/component/` drives the real binary
131
+ through Commander; no API mocks are needed for the contract surface.
132
+ The unit suite under `tests/unit/` covers envelope shapes, the error
133
+ catalog, install-script behaviour, and per-command flag matrices.
134
+
135
+ `tests/unit/contracts.test.ts` is the gatekeeper for the SemVer-stable
136
+ contract surface. If your PR causes a failure there, the contract
137
+ shape has drifted — update both the schema in `src/cli-schemas.ts`
138
+ AND the contract test deliberately, document the change in CHANGELOG,
139
+ and call it out in the PR description.
140
+
141
+ ## Commit messages
142
+
143
+ Conventional commits:
144
+
145
+ ```
146
+ feat: add `kash mcp serve` (Model Context Protocol)
147
+ fix: honour --quiet on early SIGPIPE
148
+ docs: document --refuse-private-addresses on webhooks replay
149
+ test: cover the BOM-aware stdin path
150
+ ```
151
+
152
+ (No scope needed — everything here is the CLI.)
153
+
154
+ ## Questions
155
+
156
+ - General product questions: [GitHub Discussions](https://github.com/KashDAO/cli/discussions)
157
+ - Security vulnerabilities: see [SECURITY.md](./SECURITY.md) —
158
+ please don't open public issues for security findings.
159
+ - Anything else: open an issue and we'll route it.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025-2026 KashDAO
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.