@kimchi-dev/kimchictl 0.0.2

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 (231) hide show
  1. package/LICENSE +203 -0
  2. package/README.md +105 -0
  3. package/bin/kimchictl.mjs +17 -0
  4. package/dist/api/http.d.ts +7 -0
  5. package/dist/api/http.d.ts.map +1 -0
  6. package/dist/api/http.js +60 -0
  7. package/dist/api/http.js.map +1 -0
  8. package/dist/api/keys.d.ts +7 -0
  9. package/dist/api/keys.d.ts.map +1 -0
  10. package/dist/api/keys.js +28 -0
  11. package/dist/api/keys.js.map +1 -0
  12. package/dist/api/me.d.ts +12 -0
  13. package/dist/api/me.d.ts.map +1 -0
  14. package/dist/api/me.js +28 -0
  15. package/dist/api/me.js.map +1 -0
  16. package/dist/api/resolver.d.ts +26 -0
  17. package/dist/api/resolver.d.ts.map +1 -0
  18. package/dist/api/resolver.js +62 -0
  19. package/dist/api/resolver.js.map +1 -0
  20. package/dist/api/resources.d.ts +16 -0
  21. package/dist/api/resources.d.ts.map +1 -0
  22. package/dist/api/resources.js +96 -0
  23. package/dist/api/resources.js.map +1 -0
  24. package/dist/api/templates.d.ts +19 -0
  25. package/dist/api/templates.d.ts.map +1 -0
  26. package/dist/api/templates.js +25 -0
  27. package/dist/api/templates.js.map +1 -0
  28. package/dist/api/tokens.d.ts +23 -0
  29. package/dist/api/tokens.d.ts.map +1 -0
  30. package/dist/api/tokens.js +51 -0
  31. package/dist/api/tokens.js.map +1 -0
  32. package/dist/api/types.d.ts +34 -0
  33. package/dist/api/types.d.ts.map +1 -0
  34. package/dist/api/types.js +32 -0
  35. package/dist/api/types.js.map +1 -0
  36. package/dist/api/wait.d.ts +17 -0
  37. package/dist/api/wait.d.ts.map +1 -0
  38. package/dist/api/wait.js +37 -0
  39. package/dist/api/wait.js.map +1 -0
  40. package/dist/api/workspaces.d.ts +33 -0
  41. package/dist/api/workspaces.d.ts.map +1 -0
  42. package/dist/api/workspaces.js +159 -0
  43. package/dist/api/workspaces.js.map +1 -0
  44. package/dist/auth/auth-file.d.ts +37 -0
  45. package/dist/auth/auth-file.d.ts.map +1 -0
  46. package/dist/auth/auth-file.js +100 -0
  47. package/dist/auth/auth-file.js.map +1 -0
  48. package/dist/auth/browser-login.d.ts +45 -0
  49. package/dist/auth/browser-login.d.ts.map +1 -0
  50. package/dist/auth/browser-login.js +195 -0
  51. package/dist/auth/browser-login.js.map +1 -0
  52. package/dist/auth/config-file.d.ts +4 -0
  53. package/dist/auth/config-file.d.ts.map +1 -0
  54. package/dist/auth/config-file.js +52 -0
  55. package/dist/auth/config-file.js.map +1 -0
  56. package/dist/auth/models-providers.d.ts +17 -0
  57. package/dist/auth/models-providers.d.ts.map +1 -0
  58. package/dist/auth/models-providers.js +63 -0
  59. package/dist/auth/models-providers.js.map +1 -0
  60. package/dist/auth/paths.d.ts +15 -0
  61. package/dist/auth/paths.d.ts.map +1 -0
  62. package/dist/auth/paths.js +25 -0
  63. package/dist/auth/paths.js.map +1 -0
  64. package/dist/auth/provider-ids.d.ts +4 -0
  65. package/dist/auth/provider-ids.d.ts.map +1 -0
  66. package/dist/auth/provider-ids.js +12 -0
  67. package/dist/auth/provider-ids.js.map +1 -0
  68. package/dist/auth/resolve.d.ts +19 -0
  69. package/dist/auth/resolve.d.ts.map +1 -0
  70. package/dist/auth/resolve.js +37 -0
  71. package/dist/auth/resolve.js.map +1 -0
  72. package/dist/cli.d.ts +2 -0
  73. package/dist/cli.d.ts.map +1 -0
  74. package/dist/cli.js +15 -0
  75. package/dist/cli.js.map +1 -0
  76. package/dist/commands/completion.d.ts +2 -0
  77. package/dist/commands/completion.d.ts.map +1 -0
  78. package/dist/commands/completion.js +71 -0
  79. package/dist/commands/completion.js.map +1 -0
  80. package/dist/commands/flags.d.ts +16 -0
  81. package/dist/commands/flags.d.ts.map +1 -0
  82. package/dist/commands/flags.js +23 -0
  83. package/dist/commands/flags.js.map +1 -0
  84. package/dist/commands/guard.d.ts +10 -0
  85. package/dist/commands/guard.d.ts.map +1 -0
  86. package/dist/commands/guard.js +41 -0
  87. package/dist/commands/guard.js.map +1 -0
  88. package/dist/commands/help.d.ts +4 -0
  89. package/dist/commands/help.d.ts.map +1 -0
  90. package/dist/commands/help.js +19 -0
  91. package/dist/commands/help.js.map +1 -0
  92. package/dist/commands/login.d.ts +18 -0
  93. package/dist/commands/login.d.ts.map +1 -0
  94. package/dist/commands/login.js +80 -0
  95. package/dist/commands/login.js.map +1 -0
  96. package/dist/commands/logout.d.ts +14 -0
  97. package/dist/commands/logout.d.ts.map +1 -0
  98. package/dist/commands/logout.js +41 -0
  99. package/dist/commands/logout.js.map +1 -0
  100. package/dist/commands/prompt.d.ts +9 -0
  101. package/dist/commands/prompt.d.ts.map +1 -0
  102. package/dist/commands/prompt.js +21 -0
  103. package/dist/commands/prompt.js.map +1 -0
  104. package/dist/commands/registry.d.ts +16 -0
  105. package/dist/commands/registry.d.ts.map +1 -0
  106. package/dist/commands/registry.js +35 -0
  107. package/dist/commands/registry.js.map +1 -0
  108. package/dist/commands/ssh.d.ts +15 -0
  109. package/dist/commands/ssh.d.ts.map +1 -0
  110. package/dist/commands/ssh.js +90 -0
  111. package/dist/commands/ssh.js.map +1 -0
  112. package/dist/commands/table.d.ts +3 -0
  113. package/dist/commands/table.d.ts.map +1 -0
  114. package/dist/commands/table.js +10 -0
  115. package/dist/commands/table.js.map +1 -0
  116. package/dist/commands/update.d.ts +16 -0
  117. package/dist/commands/update.d.ts.map +1 -0
  118. package/dist/commands/update.js +57 -0
  119. package/dist/commands/update.js.map +1 -0
  120. package/dist/commands/version.d.ts +2 -0
  121. package/dist/commands/version.d.ts.map +1 -0
  122. package/dist/commands/version.js +6 -0
  123. package/dist/commands/version.js.map +1 -0
  124. package/dist/commands/whoami.d.ts +7 -0
  125. package/dist/commands/whoami.d.ts.map +1 -0
  126. package/dist/commands/whoami.js +30 -0
  127. package/dist/commands/whoami.js.map +1 -0
  128. package/dist/commands/workspace.d.ts +15 -0
  129. package/dist/commands/workspace.d.ts.map +1 -0
  130. package/dist/commands/workspace.js +206 -0
  131. package/dist/commands/workspace.js.map +1 -0
  132. package/dist/run.d.ts +10 -0
  133. package/dist/run.d.ts.map +1 -0
  134. package/dist/run.js +30 -0
  135. package/dist/run.js.map +1 -0
  136. package/dist/ssh/bridge.d.ts +25 -0
  137. package/dist/ssh/bridge.d.ts.map +1 -0
  138. package/dist/ssh/bridge.js +95 -0
  139. package/dist/ssh/bridge.js.map +1 -0
  140. package/dist/ssh/config.d.ts +65 -0
  141. package/dist/ssh/config.d.ts.map +1 -0
  142. package/dist/ssh/config.js +198 -0
  143. package/dist/ssh/config.js.map +1 -0
  144. package/dist/ssh/connect.d.ts +27 -0
  145. package/dist/ssh/connect.d.ts.map +1 -0
  146. package/dist/ssh/connect.js +67 -0
  147. package/dist/ssh/connect.js.map +1 -0
  148. package/dist/ssh/tunnel.d.ts +29 -0
  149. package/dist/ssh/tunnel.d.ts.map +1 -0
  150. package/dist/ssh/tunnel.js +36 -0
  151. package/dist/ssh/tunnel.js.map +1 -0
  152. package/dist/test-support.d.ts +30 -0
  153. package/dist/test-support.d.ts.map +1 -0
  154. package/dist/test-support.js +67 -0
  155. package/dist/test-support.js.map +1 -0
  156. package/dist/updates/check.d.ts +18 -0
  157. package/dist/updates/check.d.ts.map +1 -0
  158. package/dist/updates/check.js +90 -0
  159. package/dist/updates/check.js.map +1 -0
  160. package/dist/updates/self.d.ts +36 -0
  161. package/dist/updates/self.d.ts.map +1 -0
  162. package/dist/updates/self.js +103 -0
  163. package/dist/updates/self.js.map +1 -0
  164. package/dist/version.d.ts +7 -0
  165. package/dist/version.d.ts.map +1 -0
  166. package/dist/version.js +7 -0
  167. package/dist/version.js.map +1 -0
  168. package/package.json +77 -0
  169. package/src/api/http.ts +70 -0
  170. package/src/api/keys.ts +40 -0
  171. package/src/api/me.ts +48 -0
  172. package/src/api/resolver.test.ts +109 -0
  173. package/src/api/resolver.ts +72 -0
  174. package/src/api/resources.test.ts +56 -0
  175. package/src/api/resources.ts +92 -0
  176. package/src/api/templates.ts +28 -0
  177. package/src/api/tokens.ts +80 -0
  178. package/src/api/types.ts +50 -0
  179. package/src/api/wait.ts +45 -0
  180. package/src/api/workspaces.ts +234 -0
  181. package/src/auth/auth-file.test.ts +176 -0
  182. package/src/auth/auth-file.ts +103 -0
  183. package/src/auth/browser-login.test.ts +93 -0
  184. package/src/auth/browser-login.ts +247 -0
  185. package/src/auth/config-file.test.ts +68 -0
  186. package/src/auth/config-file.ts +50 -0
  187. package/src/auth/models-providers.test.ts +63 -0
  188. package/src/auth/models-providers.ts +76 -0
  189. package/src/auth/paths.ts +28 -0
  190. package/src/auth/provider-ids.ts +15 -0
  191. package/src/auth/resolve.test.ts +72 -0
  192. package/src/auth/resolve.ts +46 -0
  193. package/src/cli.ts +16 -0
  194. package/src/commands/completion.test.ts +31 -0
  195. package/src/commands/completion.ts +77 -0
  196. package/src/commands/flags.ts +29 -0
  197. package/src/commands/guard.ts +44 -0
  198. package/src/commands/help.ts +20 -0
  199. package/src/commands/login.test.ts +159 -0
  200. package/src/commands/login.ts +94 -0
  201. package/src/commands/logout.test.ts +89 -0
  202. package/src/commands/logout.ts +53 -0
  203. package/src/commands/prompt.ts +21 -0
  204. package/src/commands/registry.ts +50 -0
  205. package/src/commands/ssh.test.ts +101 -0
  206. package/src/commands/ssh.ts +112 -0
  207. package/src/commands/table.test.ts +24 -0
  208. package/src/commands/table.ts +10 -0
  209. package/src/commands/update.test.ts +91 -0
  210. package/src/commands/update.ts +78 -0
  211. package/src/commands/version.ts +6 -0
  212. package/src/commands/whoami.test.ts +72 -0
  213. package/src/commands/whoami.ts +36 -0
  214. package/src/commands/workspace.test.ts +360 -0
  215. package/src/commands/workspace.ts +250 -0
  216. package/src/run.test.ts +53 -0
  217. package/src/run.ts +34 -0
  218. package/src/ssh/bridge.test.ts +70 -0
  219. package/src/ssh/bridge.ts +110 -0
  220. package/src/ssh/config.test.ts +213 -0
  221. package/src/ssh/config.ts +233 -0
  222. package/src/ssh/connect.test.ts +123 -0
  223. package/src/ssh/connect.ts +98 -0
  224. package/src/ssh/tunnel.test.ts +119 -0
  225. package/src/ssh/tunnel.ts +64 -0
  226. package/src/test-support.ts +77 -0
  227. package/src/updates/check.test.ts +99 -0
  228. package/src/updates/check.ts +117 -0
  229. package/src/updates/self.test.ts +117 -0
  230. package/src/updates/self.ts +131 -0
  231. package/src/version.ts +6 -0
package/LICENSE ADDED
@@ -0,0 +1,203 @@
1
+ Copyright 2024-2026 CAST AI Group, Inc.
2
+
3
+ Apache License
4
+ Version 2.0, January 2004
5
+ http://www.apache.org/licenses/
6
+
7
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
8
+
9
+ 1. Definitions.
10
+
11
+ "License" shall mean the terms and conditions for use, reproduction,
12
+ and distribution as defined by Sections 1 through 9 of this document.
13
+
14
+ "Licensor" shall mean the copyright owner or entity authorized by
15
+ the copyright owner that is granting the License.
16
+
17
+ "Legal Entity" shall mean the union of the acting entity and all
18
+ other entities that control, are controlled by, or are under common
19
+ control with that entity. For the purposes of this definition,
20
+ "control" means (i) the power, direct or indirect, to cause the
21
+ direction or management of such entity, whether by contract or
22
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
23
+ outstanding shares, or (iii) beneficial ownership of such entity.
24
+
25
+ "You" (or "Your") shall mean an individual or Legal Entity
26
+ exercising permissions granted by this License.
27
+
28
+ "Source" form shall mean the preferred form for making modifications,
29
+ including but not limited to software source code, documentation
30
+ source, and configuration files.
31
+
32
+ "Object" form shall mean any form resulting from mechanical
33
+ transformation or translation of a Source form, including but
34
+ not limited to compiled object code, generated documentation,
35
+ and conversions to other media types.
36
+
37
+ "Work" shall mean the work of authorship, whether in Source or
38
+ Object form, made available under the License, as indicated by a
39
+ copyright notice that is included in or attached to the work
40
+ (an example is provided in the Appendix below).
41
+
42
+ "Derivative Works" shall mean any work, whether in Source or Object
43
+ form, that is based on (or derived from) the Work and for which the
44
+ editorial revisions, annotations, elaborations, or other modifications
45
+ represent, as a whole, an original work of authorship. For the purposes
46
+ of this License, Derivative Works shall not include works that remain
47
+ separable from, or merely link (or bind by name) to the interfaces of,
48
+ the Work and Derivative Works thereof.
49
+
50
+ "Contribution" shall mean any work of authorship, including
51
+ the original version of the Work and any modifications or additions
52
+ to that Work or Derivative Works thereof, that is intentionally
53
+ submitted to Licensor for inclusion in the Work by the copyright owner
54
+ or by an individual or Legal Entity authorized to submit on behalf of
55
+ the copyright owner. For the purposes of this definition, "submitted"
56
+ means any form of electronic, verbal, or written communication sent
57
+ to the Licensor or its representatives, including but not limited to
58
+ communication on electronic mailing lists, source code control systems,
59
+ and issue tracking systems that are managed by, or on behalf of, the
60
+ Licensor for the purpose of discussing and improving the Work, but
61
+ excluding communication that is conspicuously marked or otherwise
62
+ designated in writing by the copyright owner as "Not a Contribution."
63
+
64
+ "Contributor" shall mean Licensor and any individual or Legal Entity
65
+ on behalf of whom a Contribution has been received by Licensor and
66
+ subsequently incorporated within the Work.
67
+
68
+ 2. Grant of Copyright License. Subject to the terms and conditions of
69
+ this License, each Contributor hereby grants to You a perpetual,
70
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
71
+ copyright license to reproduce, prepare Derivative Works of,
72
+ publicly display, publicly perform, sublicense, and distribute the
73
+ Work and such Derivative Works in Source or Object form.
74
+
75
+ 3. Grant of Patent License. Subject to the terms and conditions of
76
+ this License, each Contributor hereby grants to You a perpetual,
77
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
78
+ (except as stated in this section) patent license to make, have made,
79
+ use, offer to sell, sell, import, and otherwise transfer the Work,
80
+ where such license applies only to those patent claims licensable
81
+ by such Contributor that are necessarily infringed by their
82
+ Contribution(s) alone or by combination of their Contribution(s)
83
+ with the Work to which such Contribution(s) was submitted. If You
84
+ institute patent litigation against any entity (including a
85
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
86
+ or a Contribution incorporated within the Work constitutes direct
87
+ or contributory patent infringement, then any patent licenses
88
+ granted to You under this License for that Work shall terminate
89
+ as of the date such litigation is filed.
90
+
91
+ 4. Redistribution. You may reproduce and distribute copies of the
92
+ Work or Derivative Works thereof in any medium, with or without
93
+ modifications, and in Source or Object form, provided that You
94
+ meet the following conditions:
95
+
96
+ (a) You must give any other recipients of the Work or
97
+ Derivative Works a copy of this License; and
98
+
99
+ (b) You must cause any modified files to carry prominent notices
100
+ stating that You changed the files; and
101
+
102
+ (c) You must retain, in the Source form of any Derivative Works
103
+ that You distribute, all copyright, patent, trademark, and
104
+ attribution notices from the Source form of the Work,
105
+ excluding those notices that do not pertain to any part of
106
+ the Derivative Works; and
107
+
108
+ (d) If the Work includes a "NOTICE" text file as part of its
109
+ distribution, then any Derivative Works that You distribute must
110
+ include a readable copy of the attribution notices contained
111
+ within such NOTICE file, excluding those notices that do not
112
+ pertain to any part of the Derivative Works, in at least one
113
+ of the following places: within a NOTICE text file distributed
114
+ as part of the Derivative Works; within the Source form or
115
+ documentation, if provided along with the Derivative Works; or,
116
+ within a display generated by the Derivative Works, if and
117
+ wherever such third-party notices normally appear. The contents
118
+ of the NOTICE file are for informational purposes only and
119
+ do not modify the License. You may add Your own attribution
120
+ notices within Derivative Works that You distribute, alongside
121
+ or as an addendum to the NOTICE text from the Work, provided
122
+ that such additional attribution notices cannot be construed
123
+ as modifying the License.
124
+
125
+ You may add Your own copyright statement to Your modifications and
126
+ may provide additional or different license terms and conditions
127
+ for use, reproduction, or distribution of Your modifications, or
128
+ for any such Derivative Works as a whole, provided Your use,
129
+ reproduction, and distribution of the Work otherwise complies with
130
+ the conditions stated in this License.
131
+
132
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
133
+ any Contribution intentionally submitted for inclusion in the Work
134
+ by You to the Licensor shall be under the terms and conditions of
135
+ this License, without any additional terms or conditions.
136
+ Notwithstanding the above, nothing herein shall supersede or modify
137
+ the terms of any separate license agreement you may have executed
138
+ with Licensor regarding such Contributions.
139
+
140
+ 6. Trademarks. This License does not grant permission to use the trade
141
+ names, trademarks, service marks, or product names of the Licensor,
142
+ except as required for reasonable and customary use in describing the
143
+ origin of the Work and reproducing the content of the NOTICE file.
144
+
145
+ 7. Disclaimer of Warranty. Unless required by applicable law or
146
+ agreed to in writing, Licensor provides the Work (and each
147
+ Contributor provides its Contributions) on an "AS IS" BASIS,
148
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
149
+ implied, including, without limitation, any warranties or conditions
150
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
151
+ PARTICULAR PURPOSE. You are solely responsible for determining the
152
+ appropriateness of using or redistributing the Work and assume any
153
+ risks associated with Your exercise of permissions under this License.
154
+
155
+ 8. Limitation of Liability. In no event and under no legal theory,
156
+ whether in tort (including negligence), contract, or otherwise,
157
+ unless required by applicable law (such as deliberate and grossly
158
+ negligent acts) or agreed to in writing, shall any Contributor be
159
+ liable to You for damages, including any direct, indirect, special,
160
+ incidental, or consequential damages of any character arising as a
161
+ result of this License or out of the use or inability to use the
162
+ Work (including but not limited to damages for loss of goodwill,
163
+ work stoppage, computer failure or malfunction, or any and all
164
+ other commercial damages or losses), even if such Contributor
165
+ has been advised of the possibility of such damages.
166
+
167
+ 9. Accepting Warranty or Additional Liability. While redistributing
168
+ the Work or Derivative Works thereof, You may choose to offer,
169
+ and charge a fee for, acceptance of support, warranty, indemnity,
170
+ or other liability obligations and/or rights consistent with this
171
+ License. However, in accepting such obligations, You may act only
172
+ on Your own behalf and on Your sole responsibility, not on behalf
173
+ of any other Contributor, and only if You agree to indemnify,
174
+ defend, and hold each Contributor harmless for any liability
175
+ incurred by, or claims asserted against, such Contributor by reason
176
+ of your accepting any such warranty or additional liability.
177
+
178
+ END OF TERMS AND CONDITIONS
179
+
180
+ APPENDIX: How to apply the Apache License to your work.
181
+
182
+ To apply the Apache License to your work, attach the following
183
+ boilerplate notice, with the fields enclosed by brackets "[]"
184
+ replaced with your own identifying information. (Don't include
185
+ the brackets!) The text should be enclosed in the appropriate
186
+ comment syntax for the file format. We also recommend that a
187
+ file or class name and description of purpose be included on the
188
+ same "printed page" as the copyright notice for easier
189
+ identification within third-party archives.
190
+
191
+ Copyright 2024-2026 CAST AI Group, Inc.
192
+
193
+ Licensed under the Apache License, Version 2.0 (the "License");
194
+ you may not use this file except in compliance with the License.
195
+ You may obtain a copy of the License at
196
+
197
+ http://www.apache.org/licenses/LICENSE-2.0
198
+
199
+ Unless required by applicable law or agreed to in writing, software
200
+ distributed under the License is distributed on an "AS IS" BASIS,
201
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
202
+ See the License for the specific language governing permissions and
203
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,105 @@
1
+ # kimchictl
2
+
3
+ `kimchictl` is the standalone CLI for [kimchi](https://kimchi.dev) remote workspaces — create them, list them, and attach your terminal or editor over plain SSH.
4
+
5
+ - Run heavyweight agents, databases, dev servers in a remote workspace
6
+ - Connect with any SSH-capable tool: terminal, `scp`, git-over-ssh, Editor remote extensions
7
+ - Shares the `kimchi` coding agent's login — one sign-in for both tools
8
+
9
+ ## Install
10
+
11
+ ### Prebuilt binary (recommended)
12
+
13
+ ```sh
14
+ curl -fsSL https://github.com/getkimchi/kimchictl/releases/latest/download/install.sh | sh
15
+ ```
16
+
17
+ The installer ships as a release asset, so it always matches the binaries it downloads. macOS binaries are Developer ID–signed with a hardened runtime (same signing infrastructure as the kimchi harness); SHA-256 checksums ship alongside every release. Installs to `/usr/local/bin` (or `~/.local/bin`, override with `KIMCHICTL_INSTALL`), verifies checksums, and configures the SSH integration (see below). Pin a release with `VERSION=0.2.0 sh`.
18
+
19
+ ### Homebrew (macOS/Linux)
20
+
21
+ ```sh
22
+ brew install getkimchi/tap/kimchictl
23
+ ```
24
+
25
+ post-install, the formula offers the same SSH integration step.
26
+
27
+ ### npm (consumes the JS build, mainly for the kimchi harness)
28
+
29
+ ```sh
30
+ npm install -g @kimchi-dev/kimchictl
31
+ ```
32
+
33
+ ## Getting started
34
+
35
+ ```sh
36
+ kimchictl login # browser sign-in (shared with the kimchi agent)
37
+ kimchictl workspace create --desc "blog refactor"
38
+ kimchictl ssh pensive-brainy-kimchi-c711c6-56d6 # or plain: ssh <name>.remote.kimchi.dev
39
+ ```
40
+
41
+ `workspace create` defaults to a random base template (Rust, Python, Go, JS/TS). Pass `--template <name>` once named templates ship; the CLI tells you when the API starts accepting them.
42
+
43
+ ## SSH integration
44
+
45
+ At install time (and on first `kimchictl ssh`), kimchictl writes:
46
+
47
+ - `~/.config/kimchi/kimchictl/ssh_config` — a `Host *.remote.kimchi.dev` block routing connections through `kimchictl ssh proxy %h` as `ProxyCommand`
48
+ - an `Include ~/.config/kimchi/kimchictl/ssh_config` block (marker-wrapped) at the **top** of your `~/.ssh/config`, so it can't be shadowed by existing `Host *` default
49
+
50
+ The ProxyCommand pins a fully-qualified command — the binary's own path, or `node <cli.js>` for JS-runtime installs — so connections never depend on `PATH`. If the executable later moves, the next `kimchictl ssh setup` detects the drift and rewrites it.
51
+
52
+ That is all workspace connectivity needs — `ssh <name>.remote.kimchi.dev`, `scp`, git-over-ssh, and editor Remote-SSH extensions just work.
53
+
54
+ - Remove: `kimchictl ssh setup --uninstall`
55
+ - Opt out of auto-setup: `export KIMCHICTL_NO_SSH_SETUP=1`
56
+ - The setup is **automatic with notice**, not interactive — it never prompts.
57
+
58
+ ## Commands
59
+
60
+ ```
61
+ kimchictl login [--api-key <key>] Sign in via browser or a kimi API key
62
+ kimchictl logout [--all] Remove kimchictl credentials (keeps kimchi agent auth by default)
63
+ kimchictl whoami Show the logged-in account and auth source
64
+
65
+ kimchictl workspace create [--desc "..."] [--no-wait]
66
+ kimchictl workspace list [--output table|json] (alias: ws)
67
+ kimchictl workspace get <name>
68
+ kimchictl workspace delete <name> [--force]
69
+
70
+ kimchictl ssh <name> [command...] Connect (resumes hibernated workspaces)
71
+ kimchictl ssh setup [--uninstall] Manage the native SSH integration
72
+
73
+ kimchictl update Self-update binary installs (brew/npm tell you their path)
74
+ kimchictl completion <bash|zsh|fish> Print shell completions
75
+ kimchictl version Print the version
76
+ ```
77
+
78
+ Suspend/resume exposed by the API today: **none**. `workspace suspend` / `workspace resume` land when the endpoints exist.
79
+
80
+ ## Sharing auth with the kimchi agent
81
+
82
+ `kimchictl login` writes the same credential files the kimchi coding agent uses — `~/.config/kimchi/harness/auth.json` (provider `kimchi-dev`) and the `apiKey` field of `~/.config/kimchi/config.json` — so either tool can sign you in and the other is logged in. `KIMCHI_API_KEY` overrides the file-based credentials.
83
+
84
+ ## Environment variables
85
+
86
+ | Variable | Purpose |
87
+ | --- | --- |
88
+ | `KIMCHI_API_KEY` | API key override (highest precedence) |
89
+ | `KIMCHI_REMOTE_ENDPOINT` | API endpoint override (default `https://app.kimchi.dev/api`) |
90
+ | `KIMCHI_WEB_APP_URL` | Web app URL override for browser login |
91
+ | `KIMCHI_CODING_AGENT_DIR` | Override the shared credential directory |
92
+ | `KIMCHICTL_NO_SSH_SETUP` | Skip all automatic SSH integration |
93
+ | `KIMCHICTL_SSH_DOMAIN` | Override the workspace wildcard domain |
94
+ | `KIMCHICTL_NO_UPDATE_CHECK` | Disable the daily background update check |
95
+
96
+ ## Development
97
+
98
+ ```sh
99
+ bun install # or: pnpm install
100
+ bun dev -- help # run from source
101
+ pnpm run check # biome + typecheck + unit tests
102
+ pnpm run build # emit dist/
103
+ ```
104
+
105
+ The release pipeline compiles single-file binaries via `bun build --compile` per platform and publishes them to GitHub Releases; the npm package is a thin ESM distribution.
@@ -0,0 +1,17 @@
1
+ #!/usr/bin/env node
2
+ // Thin bin entry for the published npm package. The real CLI is dist/cli.js
3
+ // (built by `prepack`); it self-executes on import and sets process.exitCode.
4
+ // A missing dist means this is a source checkout — tell the user to build.
5
+ try {
6
+ await import("../dist/cli.js")
7
+ } catch (error) {
8
+ const code = error && typeof error === "object" && "code" in error ? error.code : undefined
9
+ if (code === "ERR_MODULE_NOT_FOUND") {
10
+ console.error(
11
+ "kimchictl: dist/cli.js not found — run `pnpm run build` (source checkout) or install a published version.",
12
+ )
13
+ } else {
14
+ console.error(error instanceof Error ? error.message : String(error))
15
+ }
16
+ process.exitCode = 2
17
+ }
@@ -0,0 +1,7 @@
1
+ import type { ApiOptions } from "./types.js";
2
+ /** Control-plane base URL: option → KIMCHI_REMOTE_ENDPOINT → https://app.kimchi.dev/api. */
3
+ export declare function resolveEndpoint(options?: ApiOptions): string;
4
+ export declare function fetchWithTimeout(url: string, init: RequestInit, fetchImpl: typeof globalThis.fetch, ms?: number, externalSignal?: AbortSignal): Promise<Response>;
5
+ /** Status-to-error mapping shared by all control-plane calls (mirrors the harness). */
6
+ export declare function checkResponse(resp: Response, endpoint: string): Promise<void>;
7
+ //# sourceMappingURL=http.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"http.d.ts","sourceRoot":"../src/","sources":["api/http.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AAG5C,4FAA4F;AAC5F,wBAAgB,eAAe,CAAC,OAAO,CAAC,EAAE,UAAU,GAAG,MAAM,CAE5D;AAED,wBAAsB,gBAAgB,CACrC,GAAG,EAAE,MAAM,EACX,IAAI,EAAE,WAAW,EACjB,SAAS,EAAE,OAAO,UAAU,CAAC,KAAK,EAClC,EAAE,SAAS,EACX,cAAc,CAAC,EAAE,WAAW,GAC1B,OAAO,CAAC,QAAQ,CAAC,CASnB;AAED,uFAAuF;AACvF,wBAAsB,aAAa,CAAC,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CA6BnF"}
@@ -0,0 +1,60 @@
1
+ import { RemoteAuthError, RemoteNetworkError, RemoteQuotaError } from "./types.js";
2
+ /** Control-plane base URL: option → KIMCHI_REMOTE_ENDPOINT → https://app.kimchi.dev/api. */
3
+ export function resolveEndpoint(options) {
4
+ return options?.endpoint ?? process.env.KIMCHI_REMOTE_ENDPOINT ?? "https://app.kimchi.dev/api";
5
+ }
6
+ export async function fetchWithTimeout(url, init, fetchImpl, ms = 30_000, externalSignal) {
7
+ const ctrl = new AbortController();
8
+ const timer = setTimeout(() => ctrl.abort(), ms);
9
+ const signal = externalSignal ? AbortSignal.any([ctrl.signal, externalSignal]) : ctrl.signal;
10
+ try {
11
+ return await fetchImpl(url, { ...init, signal });
12
+ }
13
+ finally {
14
+ clearTimeout(timer);
15
+ }
16
+ }
17
+ /** Status-to-error mapping shared by all control-plane calls (mirrors the harness). */
18
+ export async function checkResponse(resp, endpoint) {
19
+ if (resp.ok)
20
+ return;
21
+ const body = await resp.text().catch(() => "");
22
+ switch (resp.status) {
23
+ case 401:
24
+ throw new RemoteAuthError(`Invalid API key — run 'kimchictl login' to authenticate: ${endpoint}`, 401);
25
+ case 403:
26
+ throw new RemoteAuthError(`Forbidden — your API key does not have permission to use remote workspaces. ${endpoint}`, 403);
27
+ case 404:
28
+ throw new RemoteAuthError(`Workspace not found or endpoint not available. ${endpoint}`, 404);
29
+ case 409:
30
+ throw new RemoteAuthError(`Workspace conflict — another client may already own this workspace. ${endpoint}`, 409);
31
+ case 429: {
32
+ // Quota-exceeded bodies look like
33
+ // {"message":"quota exceeded: user CPU limit exceeded","fieldViolations":[]}.
34
+ const detail = parseQuotaDetail(body);
35
+ if (detail !== undefined) {
36
+ throw new RemoteQuotaError(`Unable to provision workspace: ${detail}`, 429);
37
+ }
38
+ throw new RemoteNetworkError(`HTTP ${resp.status} from ${endpoint}${body ? `: ${body}` : ""}`);
39
+ }
40
+ default: {
41
+ throw new RemoteNetworkError(`HTTP ${resp.status} from ${endpoint}${body ? `: ${body}` : ""}`);
42
+ }
43
+ }
44
+ }
45
+ /**
46
+ * Extract the human-readable reason from a 429 body, or undefined when the
47
+ * body is not JSON with a "message" string (plain rate-limit response).
48
+ */
49
+ function parseQuotaDetail(body) {
50
+ try {
51
+ const parsed = JSON.parse(body);
52
+ if (typeof parsed.message !== "string" || parsed.message.length === 0)
53
+ return undefined;
54
+ return parsed.message.replace(/^quota exceeded:\s*/i, "");
55
+ }
56
+ catch {
57
+ return undefined;
58
+ }
59
+ }
60
+ //# sourceMappingURL=http.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"http.js","sourceRoot":"../src/","sources":["api/http.ts"],"names":[],"mappings":"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"}
@@ -0,0 +1,7 @@
1
+ import type { ApiOptions } from "./types.js";
2
+ /**
3
+ * Verify an API key against the control plane. Returns the organization id.
4
+ * (Mirror of kimchi-dev:src/sandbox/cloud/keys.ts.)
5
+ */
6
+ export declare function verifyApiKey(apiKey: string, options?: ApiOptions): Promise<string>;
7
+ //# sourceMappingURL=keys.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"keys.d.ts","sourceRoot":"../src/","sources":["api/keys.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AAG5C;;;GAGG;AACH,wBAAsB,YAAY,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,UAAU,GAAG,OAAO,CAAC,MAAM,CAAC,CA+BxF"}
@@ -0,0 +1,28 @@
1
+ import { checkResponse, fetchWithTimeout, resolveEndpoint } from "./http.js";
2
+ import { RemoteNetworkError } from "./types.js";
3
+ /**
4
+ * Verify an API key against the control plane. Returns the organization id.
5
+ * (Mirror of kimchi-dev:src/sandbox/cloud/keys.ts.)
6
+ */
7
+ export async function verifyApiKey(apiKey, options) {
8
+ const endpoint = resolveEndpoint(options);
9
+ const fetchImpl = options?.fetch ?? globalThis.fetch;
10
+ const url = `${endpoint}/ai-optimizer/v1beta/workspace-tokens:verifyKey`;
11
+ const resp = await fetchWithTimeout(url, {
12
+ method: "POST",
13
+ headers: {
14
+ Authorization: `Bearer ${apiKey}`,
15
+ "Content-Type": "application/json",
16
+ },
17
+ }, fetchImpl, 30_000, options?.signal);
18
+ await checkResponse(resp, url);
19
+ const data = await resp.json().catch(() => {
20
+ throw new RemoteNetworkError(`Unexpected non-JSON response from ${endpoint}`);
21
+ });
22
+ const orgId = data.organizationId;
23
+ if (typeof orgId !== "string") {
24
+ throw new RemoteNetworkError(`Missing organizationId in verify response from ${endpoint}`);
25
+ }
26
+ return orgId;
27
+ }
28
+ //# sourceMappingURL=keys.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"keys.js","sourceRoot":"../src/","sources":["api/keys.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,WAAW,CAAA;AAE5E,OAAO,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAA;AAE/C;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY,CAAC,MAAc,EAAE,OAAoB;IACtE,MAAM,QAAQ,GAAG,eAAe,CAAC,OAAO,CAAC,CAAA;IACzC,MAAM,SAAS,GAAG,OAAO,EAAE,KAAK,IAAI,UAAU,CAAC,KAAK,CAAA;IAEpD,MAAM,GAAG,GAAG,GAAG,QAAQ,iDAAiD,CAAA;IACxE,MAAM,IAAI,GAAG,MAAM,gBAAgB,CAClC,GAAG,EACH;QACC,MAAM,EAAE,MAAM;QACd,OAAO,EAAE;YACR,aAAa,EAAE,UAAU,MAAM,EAAE;YACjC,cAAc,EAAE,kBAAkB;SAClC;KACD,EACD,SAAS,EACT,MAAM,EACN,OAAO,EAAE,MAAM,CACf,CAAA;IAED,MAAM,aAAa,CAAC,IAAI,EAAE,GAAG,CAAC,CAAA;IAE9B,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE;QACzC,MAAM,IAAI,kBAAkB,CAAC,qCAAqC,QAAQ,EAAE,CAAC,CAAA;IAC9E,CAAC,CAAC,CAAA;IAEF,MAAM,KAAK,GAAI,IAAqC,CAAC,cAAc,CAAA;IACnE,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC/B,MAAM,IAAI,kBAAkB,CAAC,kDAAkD,QAAQ,EAAE,CAAC,CAAA;IAC3F,CAAC;IAED,OAAO,KAAK,CAAA;AACb,CAAC"}
@@ -0,0 +1,12 @@
1
+ import type { ApiOptions } from "./types.js";
2
+ /**
3
+ * GET /v1/me — the authenticated user's profile.
4
+ * (Mirror of kimchi-dev:src/api/me.ts.)
5
+ */
6
+ export declare function getMe(apiKey: string, options?: ApiOptions): Promise<{
7
+ id: string;
8
+ username?: string;
9
+ name?: string;
10
+ email?: string;
11
+ }>;
12
+ //# sourceMappingURL=me.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"me.d.ts","sourceRoot":"../src/","sources":["api/me.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AAE5C;;;GAGG;AACH,wBAAsB,KAAK,CAC1B,MAAM,EAAE,MAAM,EACd,OAAO,CAAC,EAAE,UAAU,GAClB,OAAO,CAAC;IACV,EAAE,EAAE,MAAM,CAAA;IACV,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,KAAK,CAAC,EAAE,MAAM,CAAA;CACd,CAAC,CAgCD"}
package/dist/api/me.js ADDED
@@ -0,0 +1,28 @@
1
+ import { fetchWithTimeout, resolveEndpoint } from "./http.js";
2
+ /**
3
+ * GET /v1/me — the authenticated user's profile.
4
+ * (Mirror of kimchi-dev:src/api/me.ts.)
5
+ */
6
+ export async function getMe(apiKey, options) {
7
+ const endpoint = resolveEndpoint(options);
8
+ const fetchImpl = options?.fetch ?? globalThis.fetch;
9
+ const url = `${endpoint}/v1/me`;
10
+ const resp = await fetchWithTimeout(url, {
11
+ method: "GET",
12
+ headers: {
13
+ Authorization: `Bearer ${apiKey}`,
14
+ Accept: "application/json",
15
+ },
16
+ }, fetchImpl, 30_000, options?.signal);
17
+ if (!resp.ok) {
18
+ throw new Error(`GET ${url} failed with HTTP ${resp.status}`);
19
+ }
20
+ const data = await resp.json().catch(() => {
21
+ throw new Error(`Unexpected non-JSON response from ${url}`);
22
+ });
23
+ if (typeof data?.id !== "string" || data.id.length === 0) {
24
+ throw new Error(`Missing id in /v1/me response from ${url}`);
25
+ }
26
+ return data;
27
+ }
28
+ //# sourceMappingURL=me.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"me.js","sourceRoot":"../src/","sources":["api/me.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,WAAW,CAAA;AAG7D;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,KAAK,CAC1B,MAAc,EACd,OAAoB;IAOpB,MAAM,QAAQ,GAAG,eAAe,CAAC,OAAO,CAAC,CAAA;IACzC,MAAM,SAAS,GAAG,OAAO,EAAE,KAAK,IAAI,UAAU,CAAC,KAAK,CAAA;IAEpD,MAAM,GAAG,GAAG,GAAG,QAAQ,QAAQ,CAAA;IAC/B,MAAM,IAAI,GAAG,MAAM,gBAAgB,CAClC,GAAG,EACH;QACC,MAAM,EAAE,KAAK;QACb,OAAO,EAAE;YACR,aAAa,EAAE,UAAU,MAAM,EAAE;YACjC,MAAM,EAAE,kBAAkB;SAC1B;KACD,EACD,SAAS,EACT,MAAM,EACN,OAAO,EAAE,MAAM,CACf,CAAA;IAED,IAAI,CAAC,IAAI,CAAC,EAAE,EAAE,CAAC;QACd,MAAM,IAAI,KAAK,CAAC,OAAO,GAAG,qBAAqB,IAAI,CAAC,MAAM,EAAE,CAAC,CAAA;IAC9D,CAAC;IAED,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE;QACzC,MAAM,IAAI,KAAK,CAAC,qCAAqC,GAAG,EAAE,CAAC,CAAA;IAC5D,CAAC,CAAC,CAAA;IAEF,IAAI,OAAQ,IAAyB,EAAE,EAAE,KAAK,QAAQ,IAAK,IAAuB,CAAC,EAAE,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACpG,MAAM,IAAI,KAAK,CAAC,sCAAsC,GAAG,EAAE,CAAC,CAAA;IAC7D,CAAC;IAED,OAAO,IAAwE,CAAA;AAChF,CAAC"}
@@ -0,0 +1,26 @@
1
+ import type { ApiOptions } from "./types.js";
2
+ import { type Workspace, type WorkspaceCommandOptions } from "./workspaces.js";
3
+ /**
4
+ * Workspace reference resolution — a port of kap's internal/resolver.
5
+ *
6
+ * Users type the alias (the first DNS label of the workspace URI) or a
7
+ * prefix of it; the control plane addresses workspaces by UUID. Resolution:
8
+ * 1. UUID-shaped refs go straight to GET (404 → not found).
9
+ * 2. Anything else lists workspaces and matches, in order:
10
+ * exact id, exact alias, case-insensitive alias prefix.
11
+ * 3. No match → WorkspaceNotFoundError; multiple matches →
12
+ * AmbiguousWorkspaceError listing the candidates.
13
+ *
14
+ * kap caches the list for 30s — pointless in a one-shot CLI process, so
15
+ * this port is uncached.
16
+ */
17
+ export declare class WorkspaceNotFoundError extends Error {
18
+ constructor(ref: string);
19
+ }
20
+ export declare class AmbiguousWorkspaceError extends Error {
21
+ constructor(ref: string, candidates: readonly string[]);
22
+ }
23
+ export declare function isWorkspaceUuid(ref: string): boolean;
24
+ /** Resolve a workspace reference (UUID, alias, or alias prefix) to the workspace. */
25
+ export declare function resolveWorkspace(apiKey: string, ref: string, options?: WorkspaceCommandOptions & ApiOptions): Promise<Workspace>;
26
+ //# sourceMappingURL=resolver.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resolver.d.ts","sourceRoot":"../src/","sources":["api/resolver.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AAE5C,OAAO,EAAgC,KAAK,SAAS,EAAE,KAAK,uBAAuB,EAAE,MAAM,iBAAiB,CAAA;AAE5G;;;;;;;;;;;;;GAaG;AAEH,qBAAa,sBAAuB,SAAQ,KAAK;gBACpC,GAAG,EAAE,MAAM;CAIvB;AAED,qBAAa,uBAAwB,SAAQ,KAAK;gBACrC,GAAG,EAAE,MAAM,EAAE,UAAU,EAAE,SAAS,MAAM,EAAE;CAItD;AAID,wBAAgB,eAAe,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAEpD;AAQD,qFAAqF;AACrF,wBAAsB,gBAAgB,CACrC,MAAM,EAAE,MAAM,EACd,GAAG,EAAE,MAAM,EACX,OAAO,CAAC,EAAE,uBAAuB,GAAG,UAAU,GAC5C,OAAO,CAAC,SAAS,CAAC,CAqBpB"}
@@ -0,0 +1,62 @@
1
+ import { RemoteAuthError } from "./types.js";
2
+ import { getWorkspace, listWorkspaces } from "./workspaces.js";
3
+ /**
4
+ * Workspace reference resolution — a port of kap's internal/resolver.
5
+ *
6
+ * Users type the alias (the first DNS label of the workspace URI) or a
7
+ * prefix of it; the control plane addresses workspaces by UUID. Resolution:
8
+ * 1. UUID-shaped refs go straight to GET (404 → not found).
9
+ * 2. Anything else lists workspaces and matches, in order:
10
+ * exact id, exact alias, case-insensitive alias prefix.
11
+ * 3. No match → WorkspaceNotFoundError; multiple matches →
12
+ * AmbiguousWorkspaceError listing the candidates.
13
+ *
14
+ * kap caches the list for 30s — pointless in a one-shot CLI process, so
15
+ * this port is uncached.
16
+ */
17
+ export class WorkspaceNotFoundError extends Error {
18
+ constructor(ref) {
19
+ super(`No workspace matches "${ref}" — list workspaces with: kimchictl workspace list`);
20
+ this.name = "WorkspaceNotFoundError";
21
+ }
22
+ }
23
+ export class AmbiguousWorkspaceError extends Error {
24
+ constructor(ref, candidates) {
25
+ super(`Multiple workspaces match "${ref}": ${candidates.join(", ")} — use the full alias`);
26
+ this.name = "AmbiguousWorkspaceError";
27
+ }
28
+ }
29
+ const UUID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
30
+ export function isWorkspaceUuid(ref) {
31
+ return UUID_RE.test(ref);
32
+ }
33
+ function matchesRef(ws, ref) {
34
+ if (ws.id === ref)
35
+ return true;
36
+ if (ws.alias === ref)
37
+ return true;
38
+ return ws.alias.toLowerCase().startsWith(ref.toLowerCase());
39
+ }
40
+ /** Resolve a workspace reference (UUID, alias, or alias prefix) to the workspace. */
41
+ export async function resolveWorkspace(apiKey, ref, options) {
42
+ if (isWorkspaceUuid(ref)) {
43
+ try {
44
+ return await getWorkspace(apiKey, ref, options);
45
+ }
46
+ catch (err) {
47
+ if (err instanceof RemoteAuthError && err.statusCode === 404) {
48
+ throw new WorkspaceNotFoundError(ref);
49
+ }
50
+ throw err;
51
+ }
52
+ }
53
+ const workspaces = await listWorkspaces(apiKey, options);
54
+ const matched = workspaces.filter((ws) => matchesRef(ws, ref));
55
+ const [unique] = matched;
56
+ if (matched.length === 1 && unique)
57
+ return unique;
58
+ if (matched.length === 0)
59
+ throw new WorkspaceNotFoundError(ref);
60
+ throw new AmbiguousWorkspaceError(ref, matched.map((ws) => ws.alias));
61
+ }
62
+ //# sourceMappingURL=resolver.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resolver.js","sourceRoot":"../src/","sources":["api/resolver.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AAC5C,OAAO,EAAE,YAAY,EAAE,cAAc,EAAgD,MAAM,iBAAiB,CAAA;AAE5G;;;;;;;;;;;;;GAaG;AAEH,MAAM,OAAO,sBAAuB,SAAQ,KAAK;IAChD,YAAY,GAAW;QACtB,KAAK,CAAC,yBAAyB,GAAG,oDAAoD,CAAC,CAAA;QACvF,IAAI,CAAC,IAAI,GAAG,wBAAwB,CAAA;IACrC,CAAC;CACD;AAED,MAAM,OAAO,uBAAwB,SAAQ,KAAK;IACjD,YAAY,GAAW,EAAE,UAA6B;QACrD,KAAK,CAAC,8BAA8B,GAAG,MAAM,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,uBAAuB,CAAC,CAAA;QAC1F,IAAI,CAAC,IAAI,GAAG,yBAAyB,CAAA;IACtC,CAAC;CACD;AAED,MAAM,OAAO,GAAG,iEAAiE,CAAA;AAEjF,MAAM,UAAU,eAAe,CAAC,GAAW;IAC1C,OAAO,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;AACzB,CAAC;AAED,SAAS,UAAU,CAAC,EAAa,EAAE,GAAW;IAC7C,IAAI,EAAE,CAAC,EAAE,KAAK,GAAG;QAAE,OAAO,IAAI,CAAA;IAC9B,IAAI,EAAE,CAAC,KAAK,KAAK,GAAG;QAAE,OAAO,IAAI,CAAA;IACjC,OAAO,EAAE,CAAC,KAAK,CAAC,WAAW,EAAE,CAAC,UAAU,CAAC,GAAG,CAAC,WAAW,EAAE,CAAC,CAAA;AAC5D,CAAC;AAED,qFAAqF;AACrF,MAAM,CAAC,KAAK,UAAU,gBAAgB,CACrC,MAAc,EACd,GAAW,EACX,OAA8C;IAE9C,IAAI,eAAe,CAAC,GAAG,CAAC,EAAE,CAAC;QAC1B,IAAI,CAAC;YACJ,OAAO,MAAM,YAAY,CAAC,MAAM,EAAE,GAAG,EAAE,OAAO,CAAC,CAAA;QAChD,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACd,IAAI,GAAG,YAAY,eAAe,IAAI,GAAG,CAAC,UAAU,KAAK,GAAG,EAAE,CAAC;gBAC9D,MAAM,IAAI,sBAAsB,CAAC,GAAG,CAAC,CAAA;YACtC,CAAC;YACD,MAAM,GAAG,CAAA;QACV,CAAC;IACF,CAAC;IAED,MAAM,UAAU,GAAG,MAAM,cAAc,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IACxD,MAAM,OAAO,GAAG,UAAU,CAAC,MAAM,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,UAAU,CAAC,EAAE,EAAE,GAAG,CAAC,CAAC,CAAA;IAC9D,MAAM,CAAC,MAAM,CAAC,GAAG,OAAO,CAAA;IACxB,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,IAAI,MAAM;QAAE,OAAO,MAAM,CAAA;IACjD,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC;QAAE,MAAM,IAAI,sBAAsB,CAAC,GAAG,CAAC,CAAA;IAC/D,MAAM,IAAI,uBAAuB,CAChC,GAAG,EACH,OAAO,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,KAAK,CAAC,CAC7B,CAAA;AACF,CAAC"}
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Kubernetes quantity parsing (port of kimchi-dev:src/sandbox/cloud/resources.ts,
3
+ * trimmed to what the workspace list/detail rendering needs) plus display
4
+ * formatters for human tables.
5
+ */
6
+ /** "200m" → 200, "1.5" → 1500. Undefined for absent/invalid. */
7
+ export declare function cpuQuantityToMillicores(raw: unknown): number | undefined;
8
+ /** "512Mi" → 536870912, "1G" → 1000000000. Undefined for absent/invalid. */
9
+ export declare function byteQuantityToBytes(raw: unknown): number | undefined;
10
+ /** 1000 → "1", 1500 → "1.5", 250 → "250m", undefined → "-". */
11
+ export declare function formatMillicores(millicores: number | undefined): string;
12
+ /** 2147483648 → "2Gi", 536870912 → "512Mi", undefined → "-". */
13
+ export declare function formatBytes(bytes: number | undefined): string;
14
+ /** Relative age for table columns: "45s", "12m", "3h", "5d". */
15
+ export declare function formatAge(since: Date, now?: Date): string;
16
+ //# sourceMappingURL=resources.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resources.d.ts","sourceRoot":"../src/","sources":["api/resources.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AA2CH,gEAAgE;AAChE,wBAAgB,uBAAuB,CAAC,GAAG,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CAGxE;AAED,4EAA4E;AAC5E,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CAGpE;AAED,+DAA+D;AAC/D,wBAAgB,gBAAgB,CAAC,UAAU,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,CAKvE;AAED,gEAAgE;AAChE,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,CAQ7D;AAMD,gEAAgE;AAChE,wBAAgB,SAAS,CAAC,KAAK,EAAE,IAAI,EAAE,GAAG,GAAE,IAAiB,GAAG,MAAM,CAQrE"}