@kitionstage/cli 0.0.0-stage → 0.5.2-stage.13

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
@@ -1,3 +1,137 @@
1
- # Temporary Holding Version
1
+ # @kition/cli
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Kition's command line, from npm. `kition` holds no kit: it downloads each published kit the first
4
+ time you or your agent need it, into `~/.kition/kits`, and serves the kits' tools to any agent
5
+ over MCP (Claude Code, Claude Desktop, Cursor, Codex, or your own MCP client). No Kition app has
6
+ to run, nothing is compiled on your machine, and no license key is needed.
7
+
8
+ ```sh
9
+ npm install -g @kition/cli
10
+ kition --version
11
+ kition kit install note
12
+ kition agent add claude # in your project folder: Claude Code runs `kition mcp` there
13
+ ```
14
+
15
+ or, without installing:
16
+
17
+ ```sh
18
+ npx -y @kition/cli kit list
19
+ npx -y @kition/cli mcp --workspace <folder>
20
+ ```
21
+
22
+ Node.js 20 or later, on macOS (arm64, x64), Linux with glibc (arm64, x64) or Windows (x64). The
23
+ same `kition`, without Node.js: this package carries an install script (`dist/install.sh`,
24
+ `dist/install.ps1` on Windows) that downloads `@kition/cli-<platform>` from the npm registry
25
+ (registry.npmjs.org, else registry.npmmirror.com, or `KITION_NPM_REGISTRY`) with `curl` and `tar`,
26
+ checks its integrity, and installs `~/.kition/bin/kition`:
27
+
28
+ ```sh
29
+ curl -fsSL https://unpkg.com/@kition/cli/dist/install.sh | sh
30
+ ```
31
+
32
+ Every command (`kit`, `agent`, `mcp`, `serve`, `doctor`) is in
33
+ [docs/sdk/cli.md](https://github.com/KitionAI/kition-sdk/blob/main/docs/sdk/cli.md).
34
+
35
+ ## Connect your agent
36
+
37
+ `kition agent add claude` (or `codex`, `cursor`) registers `kition mcp` with the agent and prints
38
+ what it ran or wrote. Installed with `npm install -g @kition/cli`, it registers npm's `kition` command;
39
+ run through `npx -y @kition/cli agent add ...`, it registers `npx -y @kition/cli mcp`, so the agent can
40
+ start it again after npm clears its cache. By hand:
41
+
42
+ ```sh
43
+ claude mcp add kition -- npx -y @kition/cli mcp --workspace "$PWD"
44
+ ```
45
+
46
+ **Claude Desktop, Cursor, and any client with an `mcpServers` file** (`claude_desktop_config.json`,
47
+ `.cursor/mcp.json`, `.mcp.json`, ...). Use an absolute path where the client does not start
48
+ servers in your project folder (Claude Desktop); Cursor fills in `${workspaceFolder}`:
49
+
50
+ ```json
51
+ {
52
+ "mcpServers": {
53
+ "kition": {
54
+ "command": "npx",
55
+ "args": ["-y", "@kition/cli", "mcp", "--workspace", "/absolute/path/to/folder"]
56
+ }
57
+ }
58
+ }
59
+ ```
60
+
61
+ **Codex**: `~/.codex/config.toml`:
62
+
63
+ ```toml
64
+ [mcp_servers.kition]
65
+ command = "npx"
66
+ args = ["-y", "@kition/cli", "mcp", "--workspace", "/absolute/path/to/folder"]
67
+ ```
68
+
69
+ With `kition` installed globally, put `kition` as the command and drop `-y` and `@kition/cli`
70
+ from the arguments. On Windows, an agent starts `npx` (a batch file) as `cmd /c npx -y @kition/cli mcp ...`.
71
+
72
+ The server's tools, the workspace and its sandbox, drafts and kits installed on first use are in
73
+ [docs/sdk/agent.md](https://github.com/KitionAI/kition-sdk/blob/main/docs/sdk/agent.md) and
74
+ [docs/sdk/cli.md](https://github.com/KitionAI/kition-sdk/blob/main/docs/sdk/cli.md#your-agent).
75
+
76
+ ## How the `kition` command finds kition
77
+
78
+ The `kition` command here is a small Node launcher. It starts the `kition` executable for this
79
+ platform with your arguments and your standard input, output and error, and exits with its exit
80
+ code or signal; a client's SIGTERM or SIGINT is passed on, and when the client closes standard
81
+ input, `kition mcp` ends by itself. The launcher itself never writes to standard output. It runs:
82
+
83
+ 1. `KITION_BINARY`, an executable you name, for example a development build. If the variable
84
+ names a missing file, the launcher stops with an error.
85
+ 2. Otherwise the `bin/kition` of the optional package `@kition/cli-<platform>`, which npm installs
86
+ with this one on `darwin-arm64`, `darwin-x64`, `linux-arm64` (glibc), `linux-x64` (glibc) and
87
+ `win32-x64`. It holds `kition` and nothing else.
88
+
89
+ It never looks on the `PATH`, where `npm install -g` puts this launcher itself. If there is no
90
+ `kition` for this platform, the launcher says why on standard error: the platform is not one of
91
+ those, Linux runs musl (Alpine), or npm left the optional package out (`--omit=optional`,
92
+ `--no-optional`); and it names `install.sh` (`install.ps1` on Windows) as the way without npm.
93
+
94
+ The launcher tells `kition` how it was started in `KITION_LAUNCHER`, a JSON object with `via`
95
+ (`npx` or `npm`), `command` (the words that start this `kition` again) and `executable` (the
96
+ `kition` it started), which `kition agent add` registers and `kition doctor` checks on the `PATH`.
97
+
98
+ Programs that start kition themselves can use the same lookup:
99
+
100
+ ```js
101
+ import { launchedAs, resolveKition, thisMachine } from '@kition/cli'
102
+ // resolveKition(thisMachine(file)) -> { ok, command } or { ok: false, message }
103
+ ```
104
+
105
+ <!-- kition-family:begin (generated by kition-sdk from templates/community/repositories.json, its family; edit the data there, not this text) -->
106
+ ## Part of the Kition SDK
107
+
108
+ `@kition/cli` is a package of the [Kition SDK](https://github.com/KitionAI/kition-sdk) ([its source](https://github.com/KitionAI/kition-sdk/tree/main/packages/kition)), which lets you put Kition's editors in your product, and give the same files to your AI agent. Guides and reference: [developer.kition.ai](https://developer.kition.ai).
109
+
110
+ ## The Kition family
111
+
112
+ Kition is the open pro suite for AI: 16 kits, editors that people and AI agents use on the same files, and the products around them ([all repositories](https://github.com/KitionAI)).
113
+
114
+ | Product | What it is | Links |
115
+ | --- | --- | --- |
116
+ | Kition Desktop | The open pro suite for AI: 16 editors and an agent in one desktop app | [GitHub](https://github.com/KitionAI/kition) · [kition.ai](https://kition.ai) |
117
+ | Kition SDK | Put Kition's editors in your product, and give the same files to your AI agent | [GitHub](https://github.com/KitionAI/kition-sdk) · [developer.kition.ai](https://developer.kition.ai) |
118
+ | **`kition` command line** | Install kits on demand and run them for your agent: `npx @kition/cli` | [developer.kition.ai](https://developer.kition.ai) · [Guide](https://github.com/KitionAI/kition-sdk/blob/main/docs/sdk/cli.md) |
119
+ | Kition One | A self-hosted team workspace built on Kition's kits | [one.kition.ai](https://one.kition.ai) |
120
+ | Kition Server | Real-time co-editing for kits, self-hosted | [developer.kition.ai](https://developer.kition.ai) |
121
+ | Kit Harness Protocol (KHP) | The open protocol between a kit and its host | [GitHub](https://github.com/kitharness/kitharness) · [kitharness.org](https://kitharness.org) |
122
+ | Kition Tessera | The design system for kits | [GitHub](https://github.com/KitionAI/kition-tessera) · [tessera.kition.ai](https://tessera.kition.ai) |
123
+ | Kition Showcase | Sample files for every kit | [GitHub](https://github.com/KitionAI/kition-showcase) |
124
+ | Kition Universe | A 3D map of the kits and what they make | [GitHub](https://github.com/KitionAI/kition-universe) · [universe.kition.ai](https://universe.kition.ai) |
125
+ | Kition Fonts | The open fonts the editors use | [GitHub](https://github.com/KitionAI/kition-fonts) |
126
+
127
+ | Product line | Kits |
128
+ | --- | --- |
129
+ | Office | [Note](https://github.com/KitionAI/kition-note) · [Table](https://github.com/KitionAI/kition-table) · [Board](https://github.com/KitionAI/kition-board) · [Doc](https://github.com/KitionAI/kition-doc) · [Sheet](https://github.com/KitionAI/kition-sheet) · [Slide](https://github.com/KitionAI/kition-slide) · [PDF](https://github.com/KitionAI/kition-pdf) · [HTML](https://github.com/KitionAI/kition-html) (Preview) |
130
+ | Design | [Photo](https://github.com/KitionAI/kition-photo) · [Vector](https://github.com/KitionAI/kition-vector) · [Layout](https://github.com/KitionAI/kition-layout) · [Design](https://github.com/KitionAI/kition-design) (Preview) |
131
+ | Media | [Film](https://github.com/KitionAI/kition-film) · [Motion](https://github.com/KitionAI/kition-motion) |
132
+ | Engineering | [CAD](https://github.com/KitionAI/kition-cad) · [Scene](https://github.com/KitionAI/kition-scene) (Preview) |
133
+
134
+ ## License
135
+
136
+ Apache-2.0 ([LICENSE](https://github.com/KitionAI/kition-sdk/blob/main/LICENSE)).
137
+ <!-- kition-family:end -->
package/dist/LICENSE ADDED
@@ -0,0 +1,177 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
@@ -0,0 +1,114 @@
1
+ import g from "node:fs";
2
+ import { createRequire as h } from "node:module";
3
+ import r from "node:path";
4
+ function x() {
5
+ return process.platform !== "linux" ? void 0 : !!process.report?.getReport()?.header?.glibcVersionRuntime;
6
+ }
7
+ const d = (t) => {
8
+ try {
9
+ return g.realpathSync(t);
10
+ } catch {
11
+ return t;
12
+ }
13
+ };
14
+ function A(t) {
15
+ try {
16
+ const n = JSON.parse(g.readFileSync(r.join(r.dirname(r.dirname(t)), "package.json"), "utf8")).name;
17
+ return typeof n == "string" ? n : void 0;
18
+ } catch {
19
+ return;
20
+ }
21
+ }
22
+ function O(t) {
23
+ const n = h(t);
24
+ return {
25
+ name: A(d(t)),
26
+ env: process.env,
27
+ platform: process.platform,
28
+ arch: process.arch,
29
+ glibc: x(),
30
+ packageDir(o) {
31
+ try {
32
+ return r.dirname(n.resolve(`${o}/package.json`));
33
+ } catch {
34
+ return null;
35
+ }
36
+ },
37
+ isFile: (o) => g.statSync(o, { throwIfNoEntry: !1 })?.isFile() ?? !1,
38
+ realPath: d,
39
+ self: d(t),
40
+ join: r.join,
41
+ dirname: r.dirname,
42
+ basename: r.basename
43
+ };
44
+ }
45
+ const I = "The platforms the npm package @kition/cli ships kition for, each as the optional package @kition/cli-<platform> (scripts/platform-package.mjs). The key is Node's `${process.platform}-${process.arch}`, which is also the SDK release's platform name.", N = {
46
+ $comment: I,
47
+ "darwin-arm64": { os: "darwin", cpu: "arm64", rustTarget: "aarch64-apple-darwin" },
48
+ "darwin-x64": { os: "darwin", cpu: "x64", rustTarget: "x86_64-apple-darwin" },
49
+ "linux-arm64": { os: "linux", cpu: "arm64", libc: "glibc", rustTarget: "aarch64-unknown-linux-gnu" },
50
+ "linux-x64": { os: "linux", cpu: "x64", libc: "glibc", rustTarget: "x86_64-unknown-linux-gnu" },
51
+ "win32-x64": { os: "win32", cpu: "x64", rustTarget: "x86_64-pc-windows-msvc" }
52
+ }, b = "@kition/cli", _ = "@kition", j = "KITION_NPM_SCOPE", p = "kition", k = "KITION_BINARY", y = "KITION_LAUNCHER", w = Object.fromEntries(Object.entries(N).filter(([t]) => !t.startsWith("$"))), $ = (t, n = b) => `${n}-${t}`;
53
+ function K(t, n) {
54
+ const o = /^(@[a-z0-9][a-z0-9-]*)\//.exec(t)?.[1];
55
+ return !o || o === _ || n[j] !== void 0 ? null : o;
56
+ }
57
+ const S = (t) => t === "win32" ? ".exe" : "";
58
+ function v() {
59
+ const t = Object.entries(w).map(([n, o]) => o.libc ? `${n} (${o.libc})` : n);
60
+ return `${t.slice(0, -1).join(", ")} and ${t[t.length - 1]}`;
61
+ }
62
+ const T = "curl -fsSL https://unpkg.com/@kition/cli/dist/install.sh | sh", E = "irm https://unpkg.com/@kition/cli/dist/install.ps1 | iex";
63
+ function B(t) {
64
+ const n = t.env[k];
65
+ if (n)
66
+ return t.isFile(n) ? { ok: !0, command: n, from: "env" } : { ok: !1, message: `${k} names ${n}, which is no file. Point it at a kition executable, or unset it.` };
67
+ const o = t.name ?? b, s = `${t.platform}-${t.arch}`, f = w[s], a = f?.libc === "glibc" && t.glibc === !1, l = f && !a;
68
+ if (l) {
69
+ const m = t.packageDir($(s, o));
70
+ if (m) {
71
+ const e = t.join(m, "bin", `${p}${S(t.platform)}`);
72
+ if (t.isFile(e)) return { ok: !0, command: e, from: "package" };
73
+ }
74
+ }
75
+ const i = a ? `${s} (not glibc: musl, as on Alpine)` : s, u = l ? `The optional package ${$(s, o)} that carries it is not installed: npm leaves it out when optional dependencies are omitted (--omit=optional, --no-optional) or when the install ran on another platform. Install ${o} again without omitting them.` : `${o} carries no kition for ${i}.`, c = t.platform === "win32" ? E : T;
76
+ return {
77
+ ok: !1,
78
+ message: [
79
+ `no kition for this platform (${i}).`,
80
+ u,
81
+ `${o} carries kition for ${v()}.`,
82
+ `Without npm, install kition with ${t.platform === "win32" ? "install.ps1" : "install.sh"}: ${c}`,
83
+ `(https://github.com/KitionAI/kition-sdk/blob/main/docs/sdk/cli.md), or set ${k} to a kition executable.`
84
+ ].join(`
85
+ `)
86
+ };
87
+ }
88
+ function F(t, n) {
89
+ const o = t.name ?? b, s = t.self;
90
+ if (s.split(/[\\/]/).includes("_npx")) return { via: "npx", command: ["npx", "-y", o], executable: n };
91
+ const a = t.dirname(t.dirname(s)), l = t.dirname(a);
92
+ if (`${t.basename(l)}/${t.basename(a)}` !== o) return null;
93
+ const i = t.dirname(l);
94
+ if (t.basename(i) !== "node_modules") return null;
95
+ const u = t.platform === "win32", c = t.dirname(i), m = u ? [t.join(c, `${p}.cmd`), t.join(i, ".bin", `${p}.cmd`)] : [...t.basename(c) === "lib" ? [t.join(t.dirname(c), "bin", p)] : [], t.join(i, ".bin", p)];
96
+ for (const e of m)
97
+ if (t.isFile(e) && (u || t.realPath(e) === s)) return { via: "npm", command: [e], executable: n };
98
+ return null;
99
+ }
100
+ export {
101
+ k as B,
102
+ p as K,
103
+ y as L,
104
+ b as P,
105
+ _ as R,
106
+ j as S,
107
+ w as a,
108
+ K as b,
109
+ F as l,
110
+ $ as p,
111
+ B as r,
112
+ v as s,
113
+ O as t
114
+ };
package/dist/cli.d.ts ADDED
@@ -0,0 +1 @@
1
+ export {};
package/dist/cli.js ADDED
@@ -0,0 +1,28 @@
1
+ #!/usr/bin/env node
2
+ import { spawn as d } from "node:child_process";
3
+ import { fileURLToPath as f } from "node:url";
4
+ import { t as E, r as h, l as u, b as A, L as t, P as I, S } from "./chunks/resolve-qkpPHdnj.js";
5
+ const r = E(f(import.meta.url)), e = h(r);
6
+ e.ok || (process.stderr.write(`kition (npm): ${e.message}
7
+ `), process.exit(1));
8
+ const c = u(r, e.command), n = { ...process.env };
9
+ c ? n[t] = JSON.stringify(c) : delete n[t];
10
+ const a = A(r.name ?? I, n);
11
+ a && (n[S] = a);
12
+ const l = process.platform === "win32" ? ["SIGINT", "SIGTERM"] : ["SIGINT", "SIGTERM", "SIGHUP"], p = (s) => {
13
+ o.exitCode === null && o.signalCode === null && o.kill(s);
14
+ };
15
+ for (const s of l) process.on(s, p);
16
+ const o = d(e.command, process.argv.slice(2), { stdio: "inherit", env: n, windowsHide: !0 });
17
+ o.on("error", (s) => {
18
+ process.stderr.write(`kition (npm): cannot start ${e.command}: ${s.message}
19
+ `), process.exit(s.code === "ENOENT" ? 127 : 126);
20
+ });
21
+ o.on("exit", (s, i) => {
22
+ for (const m of l) process.off(m, p);
23
+ if (i) {
24
+ process.kill(process.pid, i);
25
+ return;
26
+ }
27
+ process.exit(s ?? 1);
28
+ });
@@ -0,0 +1,8 @@
1
+ /**
2
+ * `@kition/cli` on npm: the `kition` command, a launcher that starts Kition's command line for this
3
+ * platform (from the optional package `@kition/cli-<platform>`). This module is how it finds
4
+ * kition, for programs that start kition themselves.
5
+ */
6
+ export { BINARY_VARIABLE, KITION_NAME, LAUNCHER_VARIABLE, PACKAGE_NAME, PLATFORMS, REAL_SCOPE, SCOPE_VARIABLE, launchedAs, launcherScope, platformPackage, resolveKition, supportedPlatforms } from './resolve.js';
7
+ export type { Launched, Machine, Platform, Resolved } from './resolve.js';
8
+ export { thisMachine } from './machine.js';
package/dist/index.js ADDED
@@ -0,0 +1,16 @@
1
+ import { B as A, K as E, L as e, P as o, a as r, R, S as t, l as L, b as P, p as l, r as p, s as I, t as _ } from "./chunks/resolve-qkpPHdnj.js";
2
+ export {
3
+ A as BINARY_VARIABLE,
4
+ E as KITION_NAME,
5
+ e as LAUNCHER_VARIABLE,
6
+ o as PACKAGE_NAME,
7
+ r as PLATFORMS,
8
+ R as REAL_SCOPE,
9
+ t as SCOPE_VARIABLE,
10
+ L as launchedAs,
11
+ P as launcherScope,
12
+ l as platformPackage,
13
+ p as resolveKition,
14
+ I as supportedPlatforms,
15
+ _ as thisMachine
16
+ };
@@ -0,0 +1,159 @@
1
+ # Installs `kition`, the Kition command line, on Windows, from npm without Node.js: the package
2
+ # @kition/cli-win32-x64 (the executable that `npm install -g @kition/cli` brings), from the first npm
3
+ # registry that serves it, checked against the integrity (SHA-512) the registry's metadata gives, as
4
+ # %USERPROFILE%\.kition\bin\kition.exe. Kits are not installed here: `kition` downloads each one when
5
+ # it is first needed, or with `kition kit install <kit>`.
6
+ #
7
+ # irm https://unpkg.com/@kition/cli/dist/install.ps1 | iex
8
+ # & ([scriptblock]::Create((irm https://unpkg.com/@kition/cli/dist/install.ps1))) 0.6.0 # a given version
9
+ #
10
+ # The registries, in order (as kition itself reads them, docs/sdk/cli.md):
11
+ # KITION_NPM_REGISTRY one address, or several separated by commas
12
+ # npm's own setting `@kition:registry` (the scope's), else `npm_config_registry`, else `registry`, in the
13
+ # .npmrc that npm_config_userconfig names or %USERPROFILE%\.npmrc (read; npm is not needed)
14
+ # https://registry.npmjs.org/, then https://registry.npmmirror.com/
15
+ # A registry that does not answer, lacks the version, or serves other bytes than its metadata says
16
+ # passes to the next. Proxies: the system's (Internet Options), as PowerShell's.
17
+ #
18
+ # Environment:
19
+ # KITION_HOME the Kition home (default %USERPROFILE%\.kition); kition.exe goes to its bin\
20
+ # KITION_VERSION the version to install, as the argument does (default: the latest)
21
+ #
22
+ # It needs no administrator rights and never changes the PATH: it says how to put kition on it.
23
+ # Windows 10 1803 or later (for tar.exe). See docs/sdk/cli.md in https://github.com/KitionAI/kition-sdk.
24
+ param([string]$Version = $env:KITION_VERSION)
25
+
26
+ # The npm scope of the packages it installs: <scope>/cli-<platform>. The one place it is named; a
27
+ # rehearsal's launcher (<scope>/cli, made by kition-sdk's tools/stage-package.mjs) carries a copy
28
+ # naming its own scope here.
29
+ $scope = '@kitionstage'
30
+
31
+ $ErrorActionPreference = 'Stop'
32
+ $ProgressPreference = 'SilentlyContinue'
33
+
34
+ # throw, not exit: run through `irm | iex`, exit would close the person's PowerShell window.
35
+ function Fail([string]$Message) {
36
+ throw "kition install: $Message"
37
+ }
38
+ function Say([string]$Message) {
39
+ [Console]::Error.WriteLine("kition install: $Message")
40
+ }
41
+
42
+ $Version = if ($Version) { $Version.TrimStart('v') } else { '' }
43
+ $kitionHome = if ($env:KITION_HOME) { $env:KITION_HOME } else { Join-Path $env:USERPROFILE '.kition' }
44
+
45
+ # The platform, as @kition/cli names its packages. Windows on Arm runs the x64 build (Windows 11 emulates x64).
46
+ $arch = [System.Runtime.InteropServices.RuntimeInformation]::OSArchitecture
47
+ switch ($arch) {
48
+ 'X64' { $target = 'win32-x64' }
49
+ 'Arm64' { $target = 'win32-x64'; Say 'Windows on Arm: installing the x64 build, which Windows 11 runs by emulation.' }
50
+ default { Fail "kition is built for x64 Windows; not for $arch." }
51
+ }
52
+ if (-not (Get-Command tar.exe -ErrorAction SilentlyContinue)) { Fail 'tar.exe is missing (Windows 10 1803 or later has it).' }
53
+ $package = "$scope/cli-$target"
54
+
55
+ # setting <key> <file>: the value of `key=value` in an .npmrc, quotes taken off, ${VAR} expanded; '' without one.
56
+ function Setting([string]$Key, [string]$File) {
57
+ if (-not (Test-Path $File -PathType Leaf)) { return '' }
58
+ foreach ($line in Get-Content $File) {
59
+ $text = $line.Trim()
60
+ if (-not $text -or $text.StartsWith('#') -or $text.StartsWith(';')) { continue }
61
+ $at = $text.IndexOf('=')
62
+ if ($at -lt 1 -or $text.Substring(0, $at).Trim() -ne $Key) { continue }
63
+ $value = $text.Substring($at + 1).Trim().Trim('"').Trim("'")
64
+ return [regex]::Replace($value, '\$\{([^}]+)\}', { param($m) [Environment]::GetEnvironmentVariable($m.Groups[1].Value) })
65
+ }
66
+ return ''
67
+ }
68
+
69
+ # The registries, in order, each once and ending with /.
70
+ $npmrc = if ($env:npm_config_userconfig) { $env:npm_config_userconfig } else { Join-Path $env:USERPROFILE '.npmrc' }
71
+ $general = if ($env:npm_config_registry) { $env:npm_config_registry } else { Setting 'registry' $npmrc }
72
+ $registries = New-Object System.Collections.Generic.List[string]
73
+ foreach ($candidate in @((("$env:KITION_NPM_REGISTRY") -split ',') + @((Setting "${scope}:registry" $npmrc), $general, 'https://registry.npmjs.org/', 'https://registry.npmmirror.com/'))) {
74
+ $address = "$candidate".Trim()
75
+ if ($address -notmatch '^https?://') { continue }
76
+ $address = $address.TrimEnd('/') + '/'
77
+ if (-not $registries.Contains($address)) { $registries.Add($address) }
78
+ }
79
+
80
+ [Net.ServicePointManager]::SecurityProtocol = [Net.ServicePointManager]::SecurityProtocol -bor [Net.SecurityProtocolType]::Tls12
81
+
82
+ $tmp = Join-Path $kitionHome 'tmp'
83
+ New-Item -ItemType Directory -Force -Path $tmp | Out-Null
84
+ $work = Join-Path $tmp ("install." + [Guid]::NewGuid().ToString('N').Substring(0, 8))
85
+ New-Item -ItemType Directory -Path $work | Out-Null
86
+ try {
87
+ $tried = @()
88
+ $from = $null
89
+ $file = Join-Path $work 'package.tgz'
90
+ $wanted = if ($Version) { $Version } else { 'latest' }
91
+ foreach ($registry in $registries) {
92
+ # The version's metadata: its version and npm's integrity of its tarball.
93
+ try {
94
+ $metadata = Invoke-RestMethod -Uri "$registry$scope%2fcli-$target/$wanted" -UseBasicParsing -TimeoutSec 30
95
+ } catch {
96
+ $tried += "${registry}: no $package@$wanted there, or no answer ($($_.Exception.Message))"
97
+ continue
98
+ }
99
+ $found = "$($metadata.version)"
100
+ $expected = "$($metadata.dist.integrity)"
101
+ if (-not $found -or $expected -notmatch '^sha512-[A-Za-z0-9+/]+={0,2}$') {
102
+ $tried += "${registry}: its metadata of $package names no version and sha512 integrity"
103
+ continue
104
+ }
105
+ if ($Version -and $found -ne $Version) {
106
+ $tried += "${registry}: it offers $package $found, not $Version"
107
+ continue
108
+ }
109
+ $tarball = "$registry$scope/cli-$target/-/cli-$target-$found.tgz"
110
+ try {
111
+ Invoke-WebRequest -Uri $tarball -OutFile $file -UseBasicParsing -TimeoutSec 600
112
+ } catch {
113
+ $tried += "${registry}: $tarball cannot be downloaded ($($_.Exception.Message))"
114
+ continue
115
+ }
116
+ $sha512 = [System.Security.Cryptography.SHA512]::Create()
117
+ $stream = [System.IO.File]::OpenRead($file)
118
+ try { $actual = 'sha512-' + [Convert]::ToBase64String($sha512.ComputeHash($stream)) } finally { $stream.Dispose(); $sha512.Dispose() }
119
+ if ($actual -cne $expected) {
120
+ $tried += "${registry}: $package $found has the integrity $actual, and its metadata gives ${expected}: refused"
121
+ continue
122
+ }
123
+ $from = $registry
124
+ break
125
+ }
126
+ if (-not $from) {
127
+ $what = if ($Version) { "$package $Version" } else { $package }
128
+ Fail "kition was not installed: no registry served $what with the integrity it gives (tried $($tried -join '; ')). Name a registry that answers with KITION_NPM_REGISTRY (such as https://registry.npmmirror.com/)."
129
+ }
130
+ $archive = "$package $found"
131
+
132
+ $unpacked = Join-Path $work 'unpacked'
133
+ New-Item -ItemType Directory -Path $unpacked | Out-Null
134
+ & tar.exe -xzf $file -C $unpacked
135
+ if ($LASTEXITCODE -ne 0) { Fail "cannot unpack $archive" }
136
+ $exe = Join-Path $unpacked 'package\bin\kition.exe'
137
+ if (-not (Test-Path $exe -PathType Leaf)) { Fail "$archive holds no bin\kition.exe" }
138
+ $ran = & $exe --version 2>&1
139
+ if ($LASTEXITCODE -ne 0) { Fail "the kition.exe in $archive does not run on this machine: $ran" }
140
+
141
+ $bin = Join-Path $kitionHome 'bin'
142
+ New-Item -ItemType Directory -Force -Path $bin | Out-Null
143
+ $installed = Join-Path $bin 'kition.exe'
144
+ try { Move-Item -Force -Path $exe -Destination $installed } catch { Fail "cannot write ${installed} (is kition running? close it and try again): $($_.Exception.Message)" }
145
+ Say "installed $(& $installed --version) as $installed (from $from)"
146
+
147
+ $userPath = [Environment]::GetEnvironmentVariable('Path', 'User')
148
+ $onPath = (($env:Path -split ';') + ($userPath -split ';')) | Where-Object { $_ -and ($_.TrimEnd('\') -ieq $bin.TrimEnd('\')) }
149
+ if (-not $onPath) {
150
+ Say "$bin is not on your PATH. To use kition from any new terminal, run:"
151
+ [Console]::Error.WriteLine("")
152
+ [Console]::Error.WriteLine(" [Environment]::SetEnvironmentVariable('Path', `"$bin;`" + [Environment]::GetEnvironmentVariable('Path', 'User'), 'User')")
153
+ [Console]::Error.WriteLine("")
154
+ Say "or run it as $installed"
155
+ }
156
+ Say 'next: kition kit list; connect an agent with: kition mcp --workspace <folder> (docs/sdk/cli.md)'
157
+ } finally {
158
+ Remove-Item -Recurse -Force -Path $work -ErrorAction SilentlyContinue
159
+ }
@@ -0,0 +1,172 @@
1
+ #!/bin/sh
2
+ # Installs `kition`, the Kition command line, on macOS or Linux, from npm without Node.js: the
3
+ # package @kition/cli-<platform> (the executable that `npm install -g @kition/cli` brings), from the
4
+ # first npm registry that serves it, checked against the integrity (SHA-512) the registry's
5
+ # metadata gives, as ~/.kition/bin/kition. Kits are not installed here: `kition` downloads each one
6
+ # when it is first needed, or with `kition kit install <kit>`.
7
+ #
8
+ # curl -fsSL https://unpkg.com/@kition/cli/dist/install.sh | sh
9
+ # curl -fsSL https://unpkg.com/@kition/cli/dist/install.sh | sh -s -- 0.6.0 # a given version
10
+ # It rides in the npm package @kition/cli (dist/install.sh), so any registry or mirror serves it:
11
+ # curl -fsSL https://registry.npmmirror.com/@kition/cli/-/cli-0.6.0.tgz | tar -xzO package/dist/install.sh | sh
12
+ #
13
+ # The registries, in order (as kition itself reads them, docs/sdk/cli.md):
14
+ # KITION_NPM_REGISTRY one address, or several separated by commas
15
+ # npm's own setting `@kition:registry` (the scope's), else `npm_config_registry`, else `registry`, in the
16
+ # .npmrc that npm_config_userconfig names or ~/.npmrc (read; npm is not needed)
17
+ # https://registry.npmjs.org/, then https://registry.npmmirror.com/
18
+ # A registry that does not answer within 5 seconds, lacks the version, or serves other bytes than
19
+ # its metadata says passes to the next. Proxies: curl's (https_proxy, ...).
20
+ #
21
+ # Environment:
22
+ # KITION_HOME the Kition home (default ~/.kition); kition goes to $KITION_HOME/bin
23
+ # KITION_VERSION the version to install, as the argument does (default: the latest)
24
+ #
25
+ # It never uses sudo and never edits a shell profile: it says how to put kition on the PATH.
26
+ # See docs/sdk/cli.md in https://github.com/KitionAI/kition-sdk.
27
+ set -eu
28
+
29
+ # The npm scope of the packages it installs: <scope>/cli-<platform>. The one place it is named; a
30
+ # rehearsal's launcher (<scope>/cli, made by kition-sdk's tools/stage-package.mjs) carries a copy
31
+ # naming its own scope here.
32
+ scope='@kitionstage'
33
+
34
+ version="${1:-${KITION_VERSION:-}}"
35
+ version="${version#v}"
36
+ home="${KITION_HOME:-${HOME:?HOME is not set; set KITION_HOME}/.kition}"
37
+
38
+ say() { printf 'kition install: %s\n' "$*" >&2; }
39
+ fail() {
40
+ say "$*"
41
+ exit 1
42
+ }
43
+
44
+ # The platform of this machine, as @kition/cli names its packages.
45
+ platform() {
46
+ os=$(uname -s)
47
+ arch=$(uname -m)
48
+ case "$os" in
49
+ Darwin)
50
+ os=darwin
51
+ # A shell running under Rosetta says x86_64 on Apple silicon: take the native build.
52
+ if [ "$arch" = x86_64 ] && [ "$(sysctl -n sysctl.proc_translated 2>/dev/null || true)" = 1 ]; then
53
+ arch=arm64
54
+ fi
55
+ ;;
56
+ Linux)
57
+ os=linux
58
+ if [ -n "$(ls /lib/ld-musl-* /usr/lib/ld-musl-* 2>/dev/null || true)" ] || ldd --version 2>&1 | grep -qi musl; then
59
+ fail "this Linux uses the musl C library (Alpine, for example); kition is built for glibc 2.17 or later only. Use a glibc distribution (Debian, Ubuntu, Fedora, ...) or a glibc container image, or build kition from source: cargo build --release -p kition-cli in https://github.com/KitionAI/kition-sdk."
60
+ fi
61
+ ;;
62
+ MINGW* | MSYS* | CYGWIN* | Windows_NT)
63
+ fail "on Windows, run install.ps1 in PowerShell instead (docs/sdk/cli.md)"
64
+ ;;
65
+ *) fail "kition is built for macOS, Linux (glibc) and Windows; not for $os." ;;
66
+ esac
67
+ case "$arch" in
68
+ arm64 | aarch64) arch=arm64 ;;
69
+ x86_64 | amd64) arch=x64 ;;
70
+ *) fail "kition is built for arm64 and x64; not for $arch ($os)." ;;
71
+ esac
72
+ echo "$os-$arch"
73
+ }
74
+
75
+ # fetch <url> <file>: downloads, quietly; fails (status 1) without a word.
76
+ fetch() {
77
+ if command -v curl >/dev/null 2>&1; then
78
+ curl -fsSL --connect-timeout 5 --retry 1 -o "$2" "$1" 2>/dev/null
79
+ elif command -v wget >/dev/null 2>&1; then
80
+ wget -q -T 30 -O "$2" "$1"
81
+ else
82
+ fail "neither curl nor wget is installed; install one of them"
83
+ fi
84
+ }
85
+
86
+ # integrity <file>: npm's integrity of it, sha512-<base64>.
87
+ integrity() {
88
+ if command -v openssl >/dev/null 2>&1; then
89
+ printf 'sha512-%s' "$(openssl dgst -sha512 -binary "$1" | openssl base64 -A)"
90
+ elif command -v xxd >/dev/null 2>&1 && command -v base64 >/dev/null 2>&1; then
91
+ if command -v sha512sum >/dev/null 2>&1; then hex=$(sha512sum "$1" | cut -d ' ' -f 1); else hex=$(shasum -a 512 "$1" | cut -d ' ' -f 1); fi
92
+ printf 'sha512-%s' "$(printf '%s' "$hex" | xxd -r -p | base64 | tr -d '\n')"
93
+ else
94
+ fail "neither openssl nor xxd and base64 are installed; cannot check the download"
95
+ fi
96
+ }
97
+
98
+ # setting <key> <file>: the value of `key=value` in an .npmrc, quotes taken off; empty without one.
99
+ setting() {
100
+ [ -f "$2" ] || return 0
101
+ sed -n "s/^[[:space:]]*$1[[:space:]]*=[[:space:]]*//p" "$2" | head -n 1 | sed "s/^[\"']//; s/[\"'][[:space:]]*\$//; s/[[:space:]]*\$//"
102
+ }
103
+
104
+ # The registries, in order, each once and ending with /.
105
+ registries() {
106
+ npmrc="${npm_config_userconfig:-${NPM_CONFIG_USERCONFIG:-$HOME/.npmrc}}"
107
+ general="${npm_config_registry:-${NPM_CONFIG_REGISTRY:-$(setting registry "$npmrc")}}"
108
+ printf '%s\n' "$(printf '%s' "${KITION_NPM_REGISTRY:-}" | tr ',' '\n')" "$(setting "$scope:registry" "$npmrc")" "$general" https://registry.npmjs.org/ https://registry.npmmirror.com/ |
109
+ sed 's/^[[:space:]]*//; s/[[:space:]]*$//' | grep -E '^https?://' | sed 's#/*$#/#' | awk '!seen[$0]++'
110
+ }
111
+
112
+ target=$(platform) || exit 1
113
+ package="$scope/cli-$target"
114
+ mkdir -p "$home/tmp" || fail "cannot create $home/tmp"
115
+ work=$(mktemp -d "$home/tmp/install.XXXXXX") || fail "cannot create a folder in $home/tmp"
116
+ trap 'rm -rf "$work"' EXIT
117
+ trap 'exit 130' INT TERM
118
+
119
+ tried=""
120
+ installed_from=""
121
+ for registry in $(registries); do
122
+ # The version's metadata: its version and npm's integrity of its tarball.
123
+ if ! fetch "$registry$scope%2fcli-$target/${version:-latest}" "$work/metadata.json"; then
124
+ tried="$tried; $registry: no $package@${version:-latest} there, or no answer"
125
+ continue
126
+ fi
127
+ found=$(tr -d '\n' < "$work/metadata.json" | sed -n 's/.*"version"[[:space:]]*:[[:space:]]*"\([^"]*\)".*/\1/p' | head -n 1)
128
+ expected=$(tr -d '\n' < "$work/metadata.json" | sed -n 's/.*"integrity"[[:space:]]*:[[:space:]]*"\(sha512-[A-Za-z0-9+/=]*\)".*/\1/p' | head -n 1)
129
+ if [ -z "$found" ] || [ -z "$expected" ]; then
130
+ tried="$tried; $registry: its metadata of $package names no version and sha512 integrity"
131
+ continue
132
+ fi
133
+ if [ -n "$version" ] && [ "$found" != "$version" ]; then
134
+ tried="$tried; $registry: it offers $package $found, not $version"
135
+ continue
136
+ fi
137
+ tarball="$registry$scope/cli-$target/-/cli-$target-$found.tgz"
138
+ if ! fetch "$tarball" "$work/package.tgz"; then
139
+ tried="$tried; $registry: $tarball cannot be downloaded"
140
+ continue
141
+ fi
142
+ actual=$(integrity "$work/package.tgz")
143
+ if [ "$actual" != "$expected" ]; then
144
+ tried="$tried; $registry: $package $found has the integrity $actual, and its metadata gives $expected: refused"
145
+ continue
146
+ fi
147
+ installed_from="$registry"
148
+ break
149
+ done
150
+ [ -n "$installed_from" ] || fail "kition was not installed: no registry served $package${version:+ $version} with the integrity it gives (tried${tried#;}). Name a registry that answers with KITION_NPM_REGISTRY (such as https://registry.npmmirror.com/)."
151
+
152
+ mkdir -p "$work/unpacked"
153
+ tar -xzf "$work/package.tgz" -C "$work/unpacked" || fail "cannot unpack $package $found"
154
+ [ -f "$work/unpacked/package/bin/kition" ] || fail "$package $found holds no bin/kition"
155
+ chmod 755 "$work/unpacked/package/bin/kition"
156
+ ran=$("$work/unpacked/package/bin/kition" --version 2>&1) || fail "the kition of $package $found does not run on this machine ($target): $ran"
157
+
158
+ mkdir -p "$home/bin" || fail "cannot create $home/bin"
159
+ # Moved into place with one rename, so a kition running now keeps its file.
160
+ mv -f "$work/unpacked/package/bin/kition" "$home/bin/kition" || fail "cannot write $home/bin/kition"
161
+ say "installed $("$home/bin/kition" --version) as $home/bin/kition (from $installed_from)"
162
+
163
+ case ":${PATH:-}:" in
164
+ *":$home/bin:"*) ;;
165
+ *)
166
+ say "$home/bin is not on your PATH. To use kition from any shell, add this line to your shell's profile (~/.zshrc, ~/.bashrc, ~/.profile, ...):"
167
+ printf '\n export PATH="%s/bin:$PATH"\n\n' "$home" >&2
168
+ say "for fish: fish_add_path $home/bin"
169
+ say "or run it as $home/bin/kition"
170
+ ;;
171
+ esac
172
+ say "next: kition kit list; connect an agent with: kition mcp --workspace <folder> (docs/sdk/cli.md)"
@@ -0,0 +1,3 @@
1
+ import type { Machine } from './resolve.js';
2
+ /** This machine, as `resolveKition` and `launchedAs` look at it; `self` is the launcher's own file. */
3
+ export declare function thisMachine(self: string): Machine;
@@ -0,0 +1,82 @@
1
+ /** The npm package, and the command it installs (sdk.json `binaries.cli.npm` and `name`). */
2
+ export declare const PACKAGE_NAME = "@kition/cli";
3
+ /** The scope of the real packages, whose kits kition installs when `KITION_NPM_SCOPE` is not set. */
4
+ export declare const REAL_SCOPE = "@kition";
5
+ /** The npm scope kition installs kits from (kition's `registry.rs`). */
6
+ export declare const SCOPE_VARIABLE = "KITION_NPM_SCOPE";
7
+ export declare const KITION_NAME = "kition";
8
+ /** The environment variable naming the executable to start instead (sdk.json `binaries.cli.binary`). */
9
+ export declare const BINARY_VARIABLE = "KITION_BINARY";
10
+ /** Set by the launcher for kition: how it was started (sdk.json `binaries.cli.launcher`). */
11
+ export declare const LAUNCHER_VARIABLE = "KITION_LAUNCHER";
12
+ export interface Platform {
13
+ os: string;
14
+ cpu: string;
15
+ libc?: string;
16
+ rustTarget: string;
17
+ }
18
+ /** The platforms a package carries kition for, by `${process.platform}-${process.arch}`. */
19
+ export declare const PLATFORMS: Readonly<Record<string, Platform>>;
20
+ /**
21
+ * The optional package that carries kition for `platform`: `<launcher>-<platform>`, beside the
22
+ * launcher `name` (`@kition/cli-darwin-arm64`; a rehearsal's `@kitionstage/cli-darwin-arm64`).
23
+ */
24
+ export declare const platformPackage: (platform: string, name?: string) => string;
25
+ /**
26
+ * The scope kition is to install kits from when this launcher is published under another scope
27
+ * than the real one (a rehearsal, `@kitionstage/cli`) and `KITION_NPM_SCOPE` is not set: that
28
+ * scope, so the staged kition reads the staged kit index and kits. Null otherwise.
29
+ */
30
+ export declare function launcherScope(name: string, env: Record<string, string | undefined>): string | null;
31
+ export interface Machine {
32
+ /** The npm package this launcher is installed as (its package.json's name); `PACKAGE_NAME` when unknown. */
33
+ name?: string;
34
+ env: Record<string, string | undefined>;
35
+ /** `process.platform` */
36
+ platform: string;
37
+ /** `process.arch` */
38
+ arch: string;
39
+ /** Linux only: false on a C library other than glibc (musl). */
40
+ glibc?: boolean;
41
+ /** The folder of an installed package, or null. */
42
+ packageDir(name: string): string | null;
43
+ isFile(path: string): boolean;
44
+ /** The real path of a file (symbolic links followed); the path itself when it has none. */
45
+ realPath(path: string): string;
46
+ /** This launcher's own file, its real path (`<package>/dist/cli.js`). */
47
+ self: string;
48
+ join(...parts: string[]): string;
49
+ dirname(path: string): string;
50
+ basename(path: string): string;
51
+ }
52
+ export type Resolved = {
53
+ ok: true;
54
+ command: string;
55
+ from: 'env' | 'package';
56
+ } | {
57
+ ok: false;
58
+ message: string;
59
+ };
60
+ export declare function supportedPlatforms(): string;
61
+ export declare function resolveKition(machine: Machine): Resolved;
62
+ /** How the launcher was started, as kition reads it from `KITION_LAUNCHER` (JSON). */
63
+ export interface Launched {
64
+ /** `npx`: from npx's cache; `npm`: npm's `kition` command, global or a project's. */
65
+ via: 'npx' | 'npm';
66
+ /** The command that starts this kition again, kition's arguments to follow. */
67
+ command: string[];
68
+ /** The executable the launcher started: kition takes the rest as its own only when it is that one. */
69
+ executable: string;
70
+ }
71
+ /**
72
+ * How this launcher runs, and the command that starts it again; null when neither npx nor an npm
73
+ * command of its own is to be seen (kition then registers its own path).
74
+ *
75
+ * - npx runs packages from its cache, `<npm cache>/_npx/<hash>/node_modules/@kition/cli`.
76
+ * The package is `machine.name` (a rehearsal's `@kitionstage/cli`), `PACKAGE_NAME` by default.
77
+ * - npm's `kition` command: global, `<prefix>/bin/kition` (a link to this file) on macOS and
78
+ * Linux, `<prefix>\kition.cmd` on Windows, beside `<prefix>\node_modules`; a project's,
79
+ * `node_modules/.bin/kition` (`kition.cmd` on Windows). This file is
80
+ * `<modules>/@kition/cli/dist/cli.js` in both.
81
+ */
82
+ export declare function launchedAs(machine: Machine, executable: string): Launched | null;
package/package.json CHANGED
@@ -1,6 +1,51 @@
1
1
  {
2
2
  "name": "@kitionstage/cli",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.5.2-stage.13",
4
+ "description": "Kition's command line from npm: `npm install -g @kition/cli` gives the `kition` command, and `npx -y @kition/cli mcp --workspace <folder>` serves the kits' tools to any agent over MCP. It downloads each published kit on first use.",
5
+ "license": "Apache-2.0",
6
+ "type": "module",
7
+ "exports": {
8
+ ".": {
9
+ "types": "./dist/index.d.ts",
10
+ "import": "./dist/index.js"
11
+ }
12
+ },
13
+ "bin": {
14
+ "kition": "./dist/cli.js"
15
+ },
16
+ "engines": {
17
+ "node": ">=20"
18
+ },
19
+ "files": [
20
+ "dist"
21
+ ],
22
+ "repository": {
23
+ "type": "git",
24
+ "url": "git+https://github.com/KitionAI/kition-sdk.git",
25
+ "directory": "packages/kition"
26
+ },
27
+ "homepage": "https://github.com/KitionAI/kition-sdk/tree/main/packages/kition#readme",
28
+ "bugs": {
29
+ "url": "https://github.com/KitionAI/kition-sdk/issues"
30
+ },
31
+ "keywords": [
32
+ "kition",
33
+ "cli",
34
+ "mcp",
35
+ "model-context-protocol",
36
+ "khp",
37
+ "agent",
38
+ "markdown"
39
+ ],
40
+ "types": "./dist/index.d.ts",
41
+ "publishConfig": {
42
+ "access": "public"
43
+ },
44
+ "main": "./dist/index.js",
45
+ "scripts": {
46
+ "build": "node ../../tools/build-package.mjs"
47
+ },
48
+ "optionalDependencies": {
49
+ "@kitionstage/cli-darwin-arm64": "0.5.2-stage.13"
50
+ }
51
+ }