@kindgi/cli 0.1.8 → 0.1.9-rc.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (267) hide show
  1. package/README.md +59 -2
  2. package/dist/api-address.d.ts +104 -12
  3. package/dist/api-address.d.ts.map +1 -1
  4. package/dist/api-address.js +169 -30
  5. package/dist/api-address.js.map +1 -1
  6. package/dist/cli.js +12 -2
  7. package/dist/cli.js.map +1 -1
  8. package/dist/commands/approvals.d.ts.map +1 -1
  9. package/dist/commands/approvals.js +15 -3
  10. package/dist/commands/approvals.js.map +1 -1
  11. package/dist/commands/auth.d.ts.map +1 -1
  12. package/dist/commands/auth.js +27 -0
  13. package/dist/commands/auth.js.map +1 -1
  14. package/dist/commands/build.d.ts +18 -0
  15. package/dist/commands/build.d.ts.map +1 -1
  16. package/dist/commands/build.js +118 -13
  17. package/dist/commands/build.js.map +1 -1
  18. package/dist/commands/conversations.d.ts.map +1 -1
  19. package/dist/commands/conversations.js +13 -3
  20. package/dist/commands/conversations.js.map +1 -1
  21. package/dist/commands/deploy.d.ts.map +1 -1
  22. package/dist/commands/deploy.js +235 -53
  23. package/dist/commands/deploy.js.map +1 -1
  24. package/dist/commands/deployments.d.ts +3 -0
  25. package/dist/commands/deployments.d.ts.map +1 -0
  26. package/dist/commands/deployments.js +196 -0
  27. package/dist/commands/deployments.js.map +1 -0
  28. package/dist/commands/doctor.d.ts +1 -5
  29. package/dist/commands/doctor.d.ts.map +1 -1
  30. package/dist/commands/doctor.js +42 -22
  31. package/dist/commands/doctor.js.map +1 -1
  32. package/dist/commands/egress.d.ts +9 -0
  33. package/dist/commands/egress.d.ts.map +1 -0
  34. package/dist/commands/egress.js +40 -0
  35. package/dist/commands/egress.js.map +1 -0
  36. package/dist/commands/env-scoped.d.ts +5 -0
  37. package/dist/commands/env-scoped.d.ts.map +1 -1
  38. package/dist/commands/env-scoped.js +64 -19
  39. package/dist/commands/env-scoped.js.map +1 -1
  40. package/dist/commands/env.d.ts.map +1 -1
  41. package/dist/commands/env.js +91 -30
  42. package/dist/commands/env.js.map +1 -1
  43. package/dist/commands/environments.d.ts +6 -0
  44. package/dist/commands/environments.d.ts.map +1 -0
  45. package/dist/commands/environments.js +166 -0
  46. package/dist/commands/environments.js.map +1 -0
  47. package/dist/commands/exports.d.ts.map +1 -1
  48. package/dist/commands/exports.js +118 -3
  49. package/dist/commands/exports.js.map +1 -1
  50. package/dist/commands/feedback.d.ts +1 -2
  51. package/dist/commands/feedback.d.ts.map +1 -1
  52. package/dist/commands/feedback.js +55 -24
  53. package/dist/commands/feedback.js.map +1 -1
  54. package/dist/commands/helpers.d.ts +6 -0
  55. package/dist/commands/helpers.d.ts.map +1 -1
  56. package/dist/commands/helpers.js +8 -0
  57. package/dist/commands/helpers.js.map +1 -1
  58. package/dist/commands/index.d.ts.map +1 -1
  59. package/dist/commands/index.js +12 -0
  60. package/dist/commands/index.js.map +1 -1
  61. package/dist/commands/license.d.ts +3 -0
  62. package/dist/commands/license.d.ts.map +1 -1
  63. package/dist/commands/license.js +1 -1
  64. package/dist/commands/license.js.map +1 -1
  65. package/dist/commands/people.d.ts.map +1 -1
  66. package/dist/commands/people.js +105 -10
  67. package/dist/commands/people.js.map +1 -1
  68. package/dist/commands/projects.d.ts.map +1 -1
  69. package/dist/commands/projects.js +133 -11
  70. package/dist/commands/projects.js.map +1 -1
  71. package/dist/commands/promote.d.ts +38 -0
  72. package/dist/commands/promote.d.ts.map +1 -0
  73. package/dist/commands/promote.js +371 -0
  74. package/dist/commands/promote.js.map +1 -0
  75. package/dist/commands/proposals.d.ts.map +1 -1
  76. package/dist/commands/proposals.js +2 -1
  77. package/dist/commands/proposals.js.map +1 -1
  78. package/dist/commands/providers.d.ts.map +1 -1
  79. package/dist/commands/providers.js +29 -5
  80. package/dist/commands/providers.js.map +1 -1
  81. package/dist/commands/schedules.d.ts.map +1 -1
  82. package/dist/commands/schedules.js +30 -2
  83. package/dist/commands/schedules.js.map +1 -1
  84. package/dist/commands/secrets.d.ts.map +1 -1
  85. package/dist/commands/secrets.js +65 -40
  86. package/dist/commands/secrets.js.map +1 -1
  87. package/dist/commands/sign-in.d.ts +3 -0
  88. package/dist/commands/sign-in.d.ts.map +1 -0
  89. package/dist/commands/sign-in.js +61 -0
  90. package/dist/commands/sign-in.js.map +1 -0
  91. package/dist/commands/sites.d.ts +3 -0
  92. package/dist/commands/sites.d.ts.map +1 -0
  93. package/dist/commands/sites.js +244 -0
  94. package/dist/commands/sites.js.map +1 -0
  95. package/dist/commands/tools.d.ts.map +1 -1
  96. package/dist/commands/tools.js +2 -2
  97. package/dist/commands/tools.js.map +1 -1
  98. package/dist/commands/types.d.ts +11 -0
  99. package/dist/commands/types.d.ts.map +1 -1
  100. package/dist/commands/webhooks.d.ts.map +1 -1
  101. package/dist/commands/webhooks.js +38 -2
  102. package/dist/commands/webhooks.js.map +1 -1
  103. package/dist/config.d.ts +13 -0
  104. package/dist/config.d.ts.map +1 -1
  105. package/dist/config.js +20 -7
  106. package/dist/config.js.map +1 -1
  107. package/dist/context.d.ts +38 -2
  108. package/dist/context.d.ts.map +1 -1
  109. package/dist/context.js +12 -1
  110. package/dist/context.js.map +1 -1
  111. package/dist/deploy/defaults.d.ts.map +1 -1
  112. package/dist/deploy/defaults.js +7 -1
  113. package/dist/deploy/defaults.js.map +1 -1
  114. package/dist/deploy/pack-service-text.d.ts +29 -0
  115. package/dist/deploy/pack-service-text.d.ts.map +1 -0
  116. package/dist/deploy/pack-service-text.js +72 -0
  117. package/dist/deploy/pack-service-text.js.map +1 -0
  118. package/dist/deploy/post.d.ts +17 -4
  119. package/dist/deploy/post.d.ts.map +1 -1
  120. package/dist/deploy/post.js +177 -60
  121. package/dist/deploy/post.js.map +1 -1
  122. package/dist/deploy/promotion-path.d.ts +44 -0
  123. package/dist/deploy/promotion-path.d.ts.map +1 -0
  124. package/dist/deploy/promotion-path.js +86 -0
  125. package/dist/deploy/promotion-path.js.map +1 -0
  126. package/dist/deploy/response.d.ts +3 -0
  127. package/dist/deploy/response.d.ts.map +1 -1
  128. package/dist/deploy/response.js +66 -12
  129. package/dist/deploy/response.js.map +1 -1
  130. package/dist/deploy/runners.d.ts +99 -5
  131. package/dist/deploy/runners.d.ts.map +1 -1
  132. package/dist/dev/java-builder.d.ts.map +1 -1
  133. package/dist/dev/java-builder.js +19 -3
  134. package/dist/dev/java-builder.js.map +1 -1
  135. package/dist/dev/python-builder.d.ts.map +1 -1
  136. package/dist/dev/python-builder.js +18 -3
  137. package/dist/dev/python-builder.js.map +1 -1
  138. package/dist/dev/runtime-container.d.ts +28 -3
  139. package/dist/dev/runtime-container.d.ts.map +1 -1
  140. package/dist/dev/runtime-container.js +103 -36
  141. package/dist/dev/runtime-container.js.map +1 -1
  142. package/dist/dev/runtime-image.d.ts +1 -1
  143. package/dist/dev/runtime-image.d.ts.map +1 -1
  144. package/dist/dev/runtime-image.js +1 -1
  145. package/dist/dev/runtime-image.js.map +1 -1
  146. package/dist/dev/scala-builder.d.ts.map +1 -1
  147. package/dist/dev/scala-builder.js +55 -21
  148. package/dist/dev/scala-builder.js.map +1 -1
  149. package/dist/dev/shared-watch.d.ts +30 -0
  150. package/dist/dev/shared-watch.d.ts.map +1 -1
  151. package/dist/dev/shared-watch.js +46 -1
  152. package/dist/dev/shared-watch.js.map +1 -1
  153. package/dist/env/pack-env-hint.d.ts +52 -0
  154. package/dist/env/pack-env-hint.d.ts.map +1 -0
  155. package/dist/env/pack-env-hint.js +57 -0
  156. package/dist/env/pack-env-hint.js.map +1 -0
  157. package/dist/env/pack-env-plan.d.ts +2 -0
  158. package/dist/env/pack-env-plan.d.ts.map +1 -1
  159. package/dist/env/pack-env-plan.js +2 -1
  160. package/dist/env/pack-env-plan.js.map +1 -1
  161. package/dist/env-projects.d.ts +23 -0
  162. package/dist/env-projects.d.ts.map +1 -0
  163. package/dist/env-projects.js +28 -0
  164. package/dist/env-projects.js.map +1 -0
  165. package/dist/exports/create.d.ts +71 -0
  166. package/dist/exports/create.d.ts.map +1 -0
  167. package/dist/exports/create.js +576 -0
  168. package/dist/exports/create.js.map +1 -0
  169. package/dist/exports/plan.d.ts +69 -0
  170. package/dist/exports/plan.d.ts.map +1 -0
  171. package/dist/exports/plan.js +496 -0
  172. package/dist/exports/plan.js.map +1 -0
  173. package/dist/exports/reader.d.ts +48 -0
  174. package/dist/exports/reader.d.ts.map +1 -0
  175. package/dist/exports/reader.js +181 -0
  176. package/dist/exports/reader.js.map +1 -0
  177. package/dist/feedback/entries.d.ts +53 -0
  178. package/dist/feedback/entries.d.ts.map +1 -0
  179. package/dist/feedback/entries.js +173 -0
  180. package/dist/feedback/entries.js.map +1 -0
  181. package/dist/feedback/intake.d.ts +37 -0
  182. package/dist/feedback/intake.d.ts.map +1 -0
  183. package/dist/feedback/intake.js +101 -0
  184. package/dist/feedback/intake.js.map +1 -0
  185. package/dist/feedback/protocol.d.ts +111 -0
  186. package/dist/feedback/protocol.d.ts.map +1 -0
  187. package/dist/feedback/protocol.js +143 -0
  188. package/dist/feedback/protocol.js.map +1 -0
  189. package/dist/feedback/redact.d.ts +34 -0
  190. package/dist/feedback/redact.d.ts.map +1 -0
  191. package/dist/feedback/redact.js +258 -0
  192. package/dist/feedback/redact.js.map +1 -0
  193. package/dist/feedback/report.d.ts +51 -0
  194. package/dist/feedback/report.d.ts.map +1 -0
  195. package/dist/feedback/report.js +122 -0
  196. package/dist/feedback/report.js.map +1 -0
  197. package/dist/feedback/run.d.ts +21 -0
  198. package/dist/feedback/run.d.ts.map +1 -0
  199. package/dist/feedback/run.js +578 -0
  200. package/dist/feedback/run.js.map +1 -0
  201. package/dist/feedback/store.d.ts +24 -0
  202. package/dist/feedback/store.d.ts.map +1 -0
  203. package/dist/feedback/store.js +117 -0
  204. package/dist/feedback/store.js.map +1 -0
  205. package/dist/main.d.ts +6 -0
  206. package/dist/main.d.ts.map +1 -1
  207. package/dist/main.js +86 -5
  208. package/dist/main.js.map +1 -1
  209. package/dist/node-version.d.ts +13 -0
  210. package/dist/node-version.d.ts.map +1 -0
  211. package/dist/node-version.js +37 -0
  212. package/dist/node-version.js.map +1 -0
  213. package/dist/parse.d.ts +8 -2
  214. package/dist/parse.d.ts.map +1 -1
  215. package/dist/parse.js +7 -2
  216. package/dist/parse.js.map +1 -1
  217. package/dist/project-ref.d.ts +44 -0
  218. package/dist/project-ref.d.ts.map +1 -0
  219. package/dist/project-ref.js +69 -0
  220. package/dist/project-ref.js.map +1 -0
  221. package/dist/sdk-skills/kindgi-authoring-agents/SKILL.md +15 -2
  222. package/dist/sdk-skills/kindgi-authoring-flows/SKILL.md +1 -1
  223. package/dist/sdk-skills/kindgi-authoring-guardrails/SKILL.md +44 -7
  224. package/dist/sdk-skills/kindgi-authoring-mcp-servers/SKILL.md +11 -2
  225. package/dist/sdk-skills/kindgi-authoring-providers/SKILL.md +60 -13
  226. package/dist/sdk-skills/kindgi-authoring-tools/SKILL.md +19 -2
  227. package/dist/sdk-skills/kindgi-framework-feedback/SKILL.md +82 -3
  228. package/dist/sdk-skills/kindgi-getting-started/SKILL.md +1 -1
  229. package/dist/sdk-skills/kindgi-java-authoring-agents/SKILL.md +17 -3
  230. package/dist/sdk-skills/kindgi-java-authoring-flows/SKILL.md +1 -1
  231. package/dist/sdk-skills/kindgi-java-authoring-guardrails/SKILL.md +43 -6
  232. package/dist/sdk-skills/kindgi-java-authoring-tools/SKILL.md +19 -2
  233. package/dist/sdk-skills/kindgi-java-getting-started/SKILL.md +1 -1
  234. package/dist/sdk-skills/kindgi-python-authoring-agents/SKILL.md +17 -3
  235. package/dist/sdk-skills/kindgi-python-authoring-flows/SKILL.md +1 -1
  236. package/dist/sdk-skills/kindgi-python-authoring-guardrails/SKILL.md +49 -13
  237. package/dist/sdk-skills/kindgi-python-authoring-tools/SKILL.md +27 -3
  238. package/dist/sdk-skills/kindgi-python-getting-started/SKILL.md +1 -1
  239. package/dist/sdk-skills/kindgi-scala-authoring-agents/SKILL.md +17 -3
  240. package/dist/sdk-skills/kindgi-scala-authoring-flows/SKILL.md +1 -1
  241. package/dist/sdk-skills/kindgi-scala-authoring-guardrails/SKILL.md +43 -6
  242. package/dist/sdk-skills/kindgi-scala-authoring-tools/SKILL.md +19 -2
  243. package/dist/sdk-skills/kindgi-scala-getting-started/SKILL.md +1 -1
  244. package/dist/sdk-skills/kindgi-using/SKILL.md +1 -1
  245. package/dist/slug.d.ts +18 -0
  246. package/dist/slug.d.ts.map +1 -0
  247. package/dist/slug.js +29 -0
  248. package/dist/slug.js.map +1 -0
  249. package/dist/templates/drupal/AGENTS.md +2 -0
  250. package/dist/templates/java/AGENTS.md +2 -0
  251. package/dist/templates/minimal/AGENTS.md +2 -0
  252. package/dist/templates/python/AGENTS.md +2 -0
  253. package/dist/templates/sample/AGENTS.md +2 -0
  254. package/dist/templates/scala/AGENTS.md +2 -0
  255. package/dist/templates/woocommerce/AGENTS.md +11 -4
  256. package/dist/templates/woocommerce/README.md.tmpl +47 -4
  257. package/dist/templates/woocommerce/agents/store-agent/index.test.ts.tmpl +13 -0
  258. package/dist/templates/woocommerce/agents/store-agent/index.ts.tmpl +11 -1
  259. package/dist/templates/woocommerce/tools/publish-product/index.ts.tmpl +7 -1
  260. package/dist/templates/woocommerce/tools/refund/index.ts.tmpl +7 -2
  261. package/dist/templates/woocommerce/tools/refund-large/index.ts.tmpl +8 -2
  262. package/dist/templates/woocommerce/tools/set-price/index.ts.tmpl +6 -0
  263. package/dist/value-target.d.ts +139 -0
  264. package/dist/value-target.d.ts.map +1 -0
  265. package/dist/value-target.js +231 -0
  266. package/dist/value-target.js.map +1 -0
  267. package/package.json +13 -13
package/README.md CHANGED
@@ -38,7 +38,7 @@ Desktop, or a Docker engine on Linux). A Python pack needs Python and the
38
38
  | [`kindgi key`](#kindgi-key) | Ed25519 signing keys: local pairs under `~/.kindgi/keys/`, and the runtime's trust list. |
39
39
  | [`kindgi skills`](#kindgi-skills) | Refresh the Claude Code skills in `.claude/skills/`. |
40
40
  | [`kindgi mcp`](#kindgi-mcp) | MCP servers for your coding agent, in `.mcp.json`. |
41
- | [`kindgi feedback`](#kindgi-feedback) | Note framework friction in the pack's `FEEDBACK.md`. |
41
+ | [`kindgi feedback`](#kindgi-feedback) | Note framework friction in the pack's `FEEDBACK.md`, and send it to Kindgi once the person says yes to the preview. |
42
42
 
43
43
  The rest of the commands talk to a running Kindgi API: see
44
44
  [API commands](#api-commands).
@@ -590,6 +590,7 @@ and `--published-at`: the same inputs then give the same image.
590
590
  | `--push[=<repository>]` | With `--local`: push the image, sign it, and write the envelope. Default repository: the env block's `registry` + `/<packId>`. |
591
591
  | `--platform=<os/arch>` | The image's platform. Default: `linux/amd64` when pushing, else this machine's. |
592
592
  | `--endpoint=<url>` | The build server. Default: the env block's `build`. |
593
+ | `--out=<dir>` | Where the build writes `dist/`, the `Containerfile`, `context/` and `deploy-envelope.json`. Default: `.kindgi/build`, under the pack. It cannot be the pack root or a directory that contains it; for a TypeScript pack it must stay under the pack root, where the pack's `node_modules` resolves the bundled indexer's imports. |
593
594
  | `--tenant=<id>` | The tenant the signature names. Default: the env block's `tenantId`, else `KINDGI_TENANT_ID`. |
594
595
  | `--signing-key=<path>` | The Ed25519 private key (PEM). Default: the env block's `signingKey`. |
595
596
  | `--skip-integrity-gate` | Sign without re-checking the image's index. Prints a warning. |
@@ -626,7 +627,10 @@ deployment. The envelope is `--from-envelope`, else
626
627
  deployment's secrets after it lands. Off by default; without it, a deploy
627
628
  with such a file says what it didn't send. With it, secret-shaped names
628
629
  (`*_KEY`, `*_TOKEN`, `*_SECRET`, …) get a warning: those belong in
629
- `kindgi secrets set`.
630
+ `kindgi secrets set`. A hosted deploy (`--hosted`, or an env block's
631
+ `build: 'hosted'`) needs `--env` with it, since a hosted runtime reads
632
+ a deployment's secrets in the env it serves. Without it the deploy is
633
+ refused before anything is built or sent.
630
634
  - **Errors** carry a hint for the common ones: `signature-invalid`,
631
635
  `signer-not-trusted`, `image-unverifiable`,
632
636
  `deployment-validation-failed`.
@@ -760,6 +764,18 @@ pack's env files in its environment, so the secret is never written into
760
764
  friction to `FEEDBACK.md` at the pack root, where a coding agent can leave
761
765
  what it diagnosed for the maintainers.
762
766
 
767
+ - `kindgi feedback submit --preview` prints exactly what would be sent to
768
+ Kindgi's intake (access.kindgi.com), after redaction, with its digest.
769
+ `--yes=<digest>` then sends exactly that; at a terminal it asks instead.
770
+ Home directories, paths outside the pack, the pack's env values, keys,
771
+ tokens, URL query values and email addresses are taken out first.
772
+ `KINDGI_FEEDBACK_SUBMIT=off` turns sending off.
773
+ - `kindgi feedback status` says what became of the reports sent: received,
774
+ known, fixed (and in which version), won't fix, or withdrawn.
775
+ - `kindgi feedback withdraw <id>` takes a report back: the intake clears its
776
+ text at once. The key it needs stays in `~/.kindgi/feedback/keys.json` on
777
+ the machine that sent it; `FEEDBACK.md` holds only the report id.
778
+
763
779
  ## API commands
764
780
 
765
781
  These call a running Kindgi API through [`@kindgi/client`](../../sdks/typescript).
@@ -822,6 +838,46 @@ The API URL and token come from, in order:
822
838
  pair once with `kindgi auth login --url=<url> --token=<token>`, and check it
823
839
  with `kindgi auth whoami`.
824
840
 
841
+ **In a folder where `kindgi dev` ran, `--hosted` reaches the other API.**
842
+ There, `.kindgirc.json` points every command at the dev runtime, ahead of
843
+ your `kindgi auth login`. With `--hosted`, a command goes to the CLI's own
844
+ address (`--url`, `KINDGI_API_URL` or the one `kindgi auth login` stored),
845
+ with that address's key, and doesn't read the dev runtime's
846
+ `.kindgirc.json`: `kindgi auth whoami --hosted` checks your sign-in. An env
847
+ with `build: 'hosted'` in `kindgi.config.ts` does the same for a command
848
+ that acts in it (`--env <name>`, or `staging` for `kindgi build` and
849
+ `kindgi deploy`). With no address of its own, a hosted command is refused
850
+ before it sends anything, and the refusal says the file isn't read.
851
+ `kindgi dev --hosted` is refused (exit 2): a dev runtime is never hosted.
852
+
853
+ A command that goes to the dev runtime while another address is in reach
854
+ says so first, on stderr:
855
+
856
+ ```text
857
+ kindgi auth whoami goes to the kindgi dev runtime at http://127.0.0.1:4000 (…/.kindgirc.json says so). For https://platform.kindgi.com, pass --hosted.
858
+ ```
859
+
860
+ When the key was given with `--token` or `KINDGI_API_TOKEN` and nothing
861
+ else is signed in, the line ends `To send it to the address your key is
862
+ for, pass --url <that address> or export KINDGI_API_URL.` in place of the
863
+ `--hosted` sentence. There's no line when `--url` or `KINDGI_API_URL` named
864
+ the address, or when the dev runtime is the only one in reach.
865
+
866
+ **A stored key goes only to the address stored with it.** A key in
867
+ `.kindgirc.json` or `~/.kindgi/config.json` is for the `apiUrl` beside it.
868
+ When the two files hold keys for different addresses, the key used is the
869
+ one stored with the API URL the command goes to, so in a `kindgi dev`
870
+ folder `--url <the address you signed in to>` uses your sign-in's key.
871
+ When no key is stored for that address (a `--url`, `KINDGI_API_URL` or
872
+ folder `apiUrl` that names another one, or a key with no `apiUrl` beside
873
+ it), a command that needs the key is refused before it sends anything,
874
+ naming both addresses and the file. A command that sends no key isn't.
875
+ `kindgi auth login --url=<url>` saves a stored key only for its own address:
876
+ for another one, give that server's key with `--token` or `KINDGI_API_TOKEN`.
877
+ A key given with `--token` or `KINDGI_API_TOKEN` goes to whatever address
878
+ the command goes to. `kindgi doctor` says which key the CLI would use, and
879
+ whether it's for the API URL.
880
+
825
881
  ### The runtime image's registry
826
882
 
827
883
  The Kindgi runtime image `kindgi dev` runs needs a pull credential (a robot
@@ -852,6 +908,7 @@ to a mirror instead and checks for the same image there.
852
908
  | `--table` | A table for list responses (`runs list`, `tools list`, `providers list`; JSON where a list has no columns). |
853
909
  | `--quiet` | Nothing on stdout; the exit code only. |
854
910
  | `--url=<url>`, `--token=<token>` | The API and its token (see above). |
911
+ | `--hosted` | Go to the CLI's own address, never a `kindgi dev` runtime's `.kindgirc.json` (see above). `kindgi build` and `kindgi deploy` then use the hosted build service. `kindgi dev` refuses it. |
855
912
  | `--verbose`, `-v` | Full errors: stack traces and the API's error bodies. |
856
913
  | `--version` | The CLI's version. |
857
914
  | `--help`, `-h` | Help for the CLI or a command. |
@@ -1,24 +1,47 @@
1
1
  /**
2
- * Where `kindgi deploy` and `kindgi build --hosted` may send the CLI's API
3
- * key. A stored key (`kindgi auth login`'s ~/.kindgi/config.json, or
4
- * `kindgi dev`'s .kindgirc.json) is for the address stored beside it, and
5
- * goes only there: another address, wherever it's named (`--url`,
6
- * KINDGI_API_URL, a folder's .kindgirc.json, an env block's `endpoint`,
7
- * `--endpoint`), is refused, naming both, never picked silently.
2
+ * Where the CLI may send its API key. A stored key (`kindgi auth login`'s
3
+ * ~/.kindgi/config.json, or `kindgi dev`'s .kindgirc.json) is for the
4
+ * address stored beside it, and goes only there. The key for an address
5
+ * is the one stored with it (`storedKeyFor`); when none is,
6
+ * the command is refused before it sends anything, naming both addresses
7
+ * and the file, wherever the address is named (`--url`, KINDGI_API_URL, a
8
+ * folder's .kindgirc.json, an env block's `endpoint`, `--endpoint`). A
9
+ * key given for the command (`--token`, KINDGI_API_TOKEN) goes where the
10
+ * command says.
11
+ *
12
+ * - **Every command** that sends the key to the CLI's own address
13
+ * (`ctx.client()`, `ctx.token()`): `ownAddressKeyRefusal`.
8
14
  *
9
- * - **Hosted** (`--hosted`, or the env block's `build: 'hosted'`): the API
15
+ * - **Hosted** (`--hosted`, or the env block's `build: 'hosted'` for the
16
+ * env the command acts in: `hostedScope`), on every command: the API
10
17
  * is the CLI's own address (`--url`, KINDGI_API_URL or the stored one),
11
18
  * whatever key it goes with. An address named elsewhere may only repeat
12
- * it, and with no own address there's nothing to build at. A folder's
19
+ * it, and with no own address there's nothing to go to. A folder's
13
20
  * .kindgirc.json for a `kindgi dev` runtime (`kindgi dev` wrote it, or
14
21
  * it's at a loopback address) isn't read, address or key: a dev
15
- * runtime is never a hosted target.
22
+ * runtime is never a hosted target. A command that isn't hosted and
23
+ * goes to that runtime says so first when another address is in reach
24
+ * (`devRuntimeHint`).
16
25
  * - **A deploy to a runtime of your own:** `--endpoint`, else the env
17
26
  * block's `endpoint`, else the CLI's own address. A key given for the
18
27
  * command (`--token`, or an exported KINDGI_API_TOKEN) may go to any of
19
28
  * them; a stored key only to its own address.
20
29
  */
21
- import type { ResolvedConfig } from './config.js';
30
+ import type { ResolvedConfig, StoredKey } from './config.js';
31
+ /**
32
+ * The stored key for `url`: the one the files' order picks (this folder's
33
+ * over the home one) when it's for `url`, else the one stored for `url`
34
+ * in another file, else the picked one, which then can't go to `url`. A
35
+ * key with no address beside it is never passed over: nothing says which
36
+ * address it's for, so it's refused wherever it would go, never swapped.
37
+ */
38
+ export declare function storedKeyFor(keys: readonly StoredKey[], url: string | undefined): StoredKey | undefined;
39
+ /**
40
+ * `config` with the stored key for `url` (`storedKeyFor`) as its key: for
41
+ * a command that goes to another address than the CLI's own (`kindgi
42
+ * deploy --endpoint`). A key given for the command stays as it is.
43
+ */
44
+ export declare function keyedFor(config: ResolvedConfig, url: string): ResolvedConfig;
22
45
  /** An address a command was given, and where (`--endpoint`, `environments.prod.endpoint`). */
23
46
  export interface NamedAddress {
24
47
  readonly url: string | undefined;
@@ -39,13 +62,82 @@ export type ApiAddress = {
39
62
  * repeat it. `command` names the command in the refusal.
40
63
  */
41
64
  export declare function hostedApiAddress(command: string, config: ResolvedConfig, named: readonly NamedAddress[]): ApiAddress;
65
+ /**
66
+ * Why a hosted command has nowhere to go: no own address is set, and a
67
+ * folder's .kindgirc.json for a `kindgi dev` runtime, if there's one,
68
+ * isn't read.
69
+ */
70
+ export declare function hostedNoAddress(command: string, config: ResolvedConfig): string;
71
+ /** Whether a command is hosted, and the config it goes on with. */
72
+ export interface HostedScope {
73
+ /** `--hosted`, or the env the command acts in has `build: 'hosted'`. */
74
+ readonly hosted: boolean;
75
+ /** The config, without a `kindgi dev` runtime's .kindgirc.json when hosted (`hostedConfig`). */
76
+ readonly config: ResolvedConfig;
77
+ }
78
+ export interface HostedScopeInputs {
79
+ readonly config: ResolvedConfig;
80
+ /** `--hosted`. */
81
+ readonly flag: boolean;
82
+ /** The env the command acts in (`--env`, else its default); `undefined` when none applies. */
83
+ readonly envName: string | undefined;
84
+ /**
85
+ * Read the env block whether or not a `kindgi dev` runtime's
86
+ * .kindgirc.json is here: for a command whose run hosted changes, not
87
+ * only its address (`kindgi build`, `kindgi deploy`).
88
+ */
89
+ readonly always: boolean;
90
+ /** Whether the pack's env block says `build: 'hosted'`; `false` with no pack config, or a broken one. */
91
+ readonly envIsHosted: (envName: string) => Promise<boolean>;
92
+ }
93
+ /**
94
+ * The one hosted rule, for every command: `--hosted`, or the env the
95
+ * command acts in has `build: 'hosted'`. Hosted, the command goes on the
96
+ * config without a `kindgi dev` runtime's .kindgirc.json. Elsewhere the
97
+ * env block can only change the address when such a file is here, so it's
98
+ * read only then, unless `always`.
99
+ */
100
+ export declare function hostedScope(inputs: HostedScopeInputs): Promise<HostedScope>;
101
+ /**
102
+ * The config a hosted command goes on with: the one resolved without a
103
+ * `kindgi dev` runtime's .kindgirc.json (`devRuntime.without`), the file
104
+ * still known, so `ctx.config`, `ctx.client()` and `ctx.token()` agree.
105
+ */
106
+ export declare function hostedConfig(config: ResolvedConfig): ResolvedConfig;
107
+ /**
108
+ * The line a command that isn't hosted prints first when it sends a key
109
+ * to the `kindgi dev` runtime this folder's .kindgirc.json names, and
110
+ * another address is in reach: a stored sign-in for another address
111
+ * (`--hosted` goes there), or a key given for the command (its own
112
+ * address needs naming). `undefined` when the address was named for the
113
+ * command (`--url`, KINDGI_API_URL), or nothing else is in reach.
114
+ */
115
+ export declare function devRuntimeHint(command: string, config: ResolvedConfig): string | undefined;
42
116
  /**
43
117
  * A deploy's API: the first of `named` that's given, else the CLI's own
44
118
  * address; `undefined` when there's none. A stored key goes only to the
45
119
  * address stored with it; a key given for the command goes where the
46
- * command says.
120
+ * command says. `command` names the command in the refusal (`kindgi
121
+ * promote` goes where a deploy does).
47
122
  */
48
- export declare function deployApiAddress(config: ResolvedConfig, named: readonly NamedAddress[]): ApiAddress | undefined;
123
+ export declare function deployApiAddress(config: ResolvedConfig, named: readonly NamedAddress[], command?: string): ApiAddress | undefined;
124
+ /**
125
+ * Why a command that sends the API key to the CLI's own address can't:
126
+ * the stored key isn't for it. `undefined` when it can, or when there's
127
+ * no address or no key (which the command says itself).
128
+ */
129
+ export declare function ownAddressKeyRefusal(command: string, config: ResolvedConfig): string | undefined;
130
+ /** What `ownAddressKeyRefusal` finds, in parts: for `kindgi doctor`'s check. */
131
+ export interface KeyElsewhere {
132
+ /** "the API key stored in …, which is for …, to …, which … names". */
133
+ readonly sends: string;
134
+ /** What else is stored, and that none is for the address: "" or a sentence and a space. */
135
+ readonly stored: string;
136
+ /** "The key goes only to its own address: …, or …." */
137
+ readonly fix: string;
138
+ }
139
+ /** The stored key can't go to the CLI's own address: why, in parts (`KeyElsewhere`). */
140
+ export declare function ownAddressKeyElsewhere(config: ResolvedConfig): KeyElsewhere | undefined;
49
141
  /**
50
142
  * One address, however it's written: the scheme, the host (any case; the
51
143
  * loopback names localhost, 127.0.0.1 and ::1 are one), the port (a
@@ -1 +1 @@
1
- {"version":3,"file":"api-address.d.ts","sourceRoot":"","sources":["../src/api-address.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAElD,8FAA8F;AAC9F,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,CAAC;IACjC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;CACxB;AAED,gGAAgG;AAChG,MAAM,MAAM,UAAU,GAClB;IAAE,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC;IAAC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,cAAc,CAAA;CAAE,GAC9E;IAAE,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC;IAAC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC;AAE3D;;;;GAIG;AACH,wBAAgB,gBAAgB,CAC9B,OA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AAU,GAAG,SAAS,CAaxB;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,cAAc,GAAG,MAAM,GAAG,SAAS,CAIhG;AAED,gFAAgF;AAChF,MAAM,WAAW,YAAY;IAC3B,sEAAsE;IACtE,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,2FAA2F;IAC3F,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,uDAAuD;IACvD,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;CACtB;AAED,wFAAwF;AACxF,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,cAAc,GAAG,YAAY,GAAG,SAAS,CAIvF;AAgFD;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,OAAO,CAEzD;AAED,+EAA+E;AAC/E,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAMnD"}
@@ -1,5 +1,38 @@
1
1
  // SPDX-License-Identifier: Apache-2.0
2
2
  // Copyright (C) 2026 Kindgi Inc.
3
+ /**
4
+ * The stored key for `url`: the one the files' order picks (this folder's
5
+ * over the home one) when it's for `url`, else the one stored for `url`
6
+ * in another file, else the picked one, which then can't go to `url`. A
7
+ * key with no address beside it is never passed over: nothing says which
8
+ * address it's for, so it's refused wherever it would go, never swapped.
9
+ */
10
+ export function storedKeyFor(keys, url) {
11
+ const picked = keys.at(-1);
12
+ if (picked?.apiUrl === undefined || url === undefined || sameAddress(picked.apiUrl, url)) {
13
+ return picked;
14
+ }
15
+ return keys.findLast((k) => k.apiUrl !== undefined && sameAddress(k.apiUrl, url)) ?? picked;
16
+ }
17
+ /**
18
+ * `config` with the stored key for `url` (`storedKeyFor`) as its key: for
19
+ * a command that goes to another address than the CLI's own (`kindgi
20
+ * deploy --endpoint`). A key given for the command stays as it is.
21
+ */
22
+ export function keyedFor(config, url) {
23
+ if (config.source.token !== 'file' || config.storedKeys === undefined)
24
+ return config;
25
+ const key = storedKeyFor(config.storedKeys, url);
26
+ if (key === undefined)
27
+ return config;
28
+ const { keyAddress: _old, ...rest } = config;
29
+ return {
30
+ ...rest,
31
+ token: key.token,
32
+ files: { ...config.files, token: key.file },
33
+ ...(key.apiUrl !== undefined && { keyAddress: key.apiUrl }),
34
+ };
35
+ }
3
36
  /**
4
37
  * A hosted build's or deploy's API: the CLI's own address, without a
5
38
  * folder's .kindgirc.json for a `kindgi dev` runtime. `named` may only
@@ -8,14 +41,8 @@
8
41
  export function hostedApiAddress(command, config, named) {
9
42
  const hosted = config.devRuntime?.without ?? config;
10
43
  const own = hosted.apiUrl;
11
- if (own === undefined || own === '') {
12
- const dev = config.devRuntime;
13
- const at = dev?.apiUrl === undefined ? '' : ` (${dev.apiUrl})`;
14
- const unread = dev === undefined
15
- ? ''
16
- : ` ${dev.file} points this folder at a \`kindgi dev\` runtime${at}, which isn't a hosted target, so ${command} doesn't read it.`;
17
- return refused(`${command} goes to the API your key is for, and no API address is set.${unread} Run \`kindgi auth login --url <url>\`, export KINDGI_API_URL, or pass --url <url>.`);
18
- }
44
+ if (own === undefined || own === '')
45
+ return refused(hostedNoAddress(command, config));
19
46
  const keyElsewhere = storedKeyRefusal(command, hosted, own, ownWhere(hosted), false);
20
47
  if (keyElsewhere !== undefined)
21
48
  return refused(keyElsewhere);
@@ -23,24 +50,104 @@ export function hostedApiAddress(command, config, named) {
23
50
  if (other !== undefined) {
24
51
  return refused(`${command} sends your API key to ${own}, the address it's for (${ownSource(hosted)}), ` +
25
52
  `and ${other.where} names another: ${other.url}. The key goes only to its own address: ` +
26
- `remove ${other.where} (Kindgi Cloud needs none), or sign in to ${other.url} with ` +
27
- `\`kindgi auth login --url ${other.url}\`.`);
53
+ `remove ${other.where} (Kindgi Cloud needs none), or ${signIn(other.url)}.`);
28
54
  }
29
55
  return { kind: 'ok', url: own, config: hosted };
30
56
  }
57
+ /**
58
+ * Why a hosted command has nowhere to go: no own address is set, and a
59
+ * folder's .kindgirc.json for a `kindgi dev` runtime, if there's one,
60
+ * isn't read.
61
+ */
62
+ export function hostedNoAddress(command, config) {
63
+ const dev = config.devRuntime;
64
+ const at = dev?.apiUrl === undefined ? '' : ` (${dev.apiUrl})`;
65
+ const unread = dev === undefined
66
+ ? ''
67
+ : ` ${dev.file} points this folder at a \`kindgi dev\` runtime${at}, which isn't a hosted target, so ${command} doesn't read it.`;
68
+ return `${command} goes to the API your key is for, and no API address is set.${unread} Run \`kindgi auth login --url <url> --token <its key>\`, export KINDGI_API_URL, or pass --url <url>.`;
69
+ }
70
+ /**
71
+ * The one hosted rule, for every command: `--hosted`, or the env the
72
+ * command acts in has `build: 'hosted'`. Hosted, the command goes on the
73
+ * config without a `kindgi dev` runtime's .kindgirc.json. Elsewhere the
74
+ * env block can only change the address when such a file is here, so it's
75
+ * read only then, unless `always`.
76
+ */
77
+ export async function hostedScope(inputs) {
78
+ const { config, envName } = inputs;
79
+ const hosted = inputs.flag ||
80
+ (envName !== undefined &&
81
+ (inputs.always || config.devRuntime !== undefined) &&
82
+ (await inputs.envIsHosted(envName)));
83
+ return { hosted, config: hosted ? hostedConfig(config) : config };
84
+ }
85
+ /**
86
+ * The config a hosted command goes on with: the one resolved without a
87
+ * `kindgi dev` runtime's .kindgirc.json (`devRuntime.without`), the file
88
+ * still known, so `ctx.config`, `ctx.client()` and `ctx.token()` agree.
89
+ */
90
+ export function hostedConfig(config) {
91
+ const dev = config.devRuntime;
92
+ return dev === undefined ? config : { ...dev.without, devRuntime: dev };
93
+ }
94
+ /**
95
+ * The line a command that isn't hosted prints first when it sends a key
96
+ * to the `kindgi dev` runtime this folder's .kindgirc.json names, and
97
+ * another address is in reach: a stored sign-in for another address
98
+ * (`--hosted` goes there), or a key given for the command (its own
99
+ * address needs naming). `undefined` when the address was named for the
100
+ * command (`--url`, KINDGI_API_URL), or nothing else is in reach.
101
+ */
102
+ export function devRuntimeHint(command, config) {
103
+ const dev = config.devRuntime;
104
+ const url = config.apiUrl;
105
+ if (dev === undefined || url === undefined || config.files?.apiUrl?.path !== dev.file) {
106
+ return undefined;
107
+ }
108
+ const goes = `${command} goes to the kindgi dev runtime at ${url} (${dev.file} says so).`;
109
+ const other = dev.without.apiUrl;
110
+ if (given(other) && !sameAddress(other, url)) {
111
+ return `${goes} For ${other}, pass --hosted.\n`;
112
+ }
113
+ if (config.source.token === 'flag' || config.source.token === 'env') {
114
+ return `${goes} To send it to the address your key is for, pass --url <that address> or export KINDGI_API_URL.\n`;
115
+ }
116
+ return undefined;
117
+ }
31
118
  /**
32
119
  * A deploy's API: the first of `named` that's given, else the CLI's own
33
120
  * address; `undefined` when there's none. A stored key goes only to the
34
121
  * address stored with it; a key given for the command goes where the
35
- * command says.
122
+ * command says. `command` names the command in the refusal (`kindgi
123
+ * promote` goes where a deploy does).
36
124
  */
37
- export function deployApiAddress(config, named) {
125
+ export function deployApiAddress(config, named, command = 'kindgi deploy') {
38
126
  const chosen = named.find((n) => given(n.url));
39
127
  const url = chosen?.url ?? config.apiUrl;
40
128
  if (url === undefined || url === '')
41
129
  return undefined;
42
- const keyElsewhere = storedKeyRefusal('kindgi deploy', config, url, chosen?.where ?? ownWhere(config), true);
43
- return keyElsewhere !== undefined ? refused(keyElsewhere) : { kind: 'ok', url, config };
130
+ const keyed = keyedFor(config, url);
131
+ const keyElsewhere = storedKeyRefusal(command, keyed, url, chosen?.where ?? ownWhere(config), true);
132
+ return keyElsewhere !== undefined ? refused(keyElsewhere) : { kind: 'ok', url, config: keyed };
133
+ }
134
+ /**
135
+ * Why a command that sends the API key to the CLI's own address can't:
136
+ * the stored key isn't for it. `undefined` when it can, or when there's
137
+ * no address or no key (which the command says itself).
138
+ */
139
+ export function ownAddressKeyRefusal(command, config) {
140
+ const url = config.apiUrl;
141
+ if (url === undefined || url === '')
142
+ return undefined;
143
+ return storedKeyRefusal(command, config, url, ownWhere(config), true);
144
+ }
145
+ /** The stored key can't go to the CLI's own address: why, in parts (`KeyElsewhere`). */
146
+ export function ownAddressKeyElsewhere(config) {
147
+ const url = config.apiUrl;
148
+ if (url === undefined || url === '')
149
+ return undefined;
150
+ return keyElsewhere(config, url, ownWhere(config), true);
44
151
  }
45
152
  /**
46
153
  * Why a stored key can't go to `url` (named by `where`): it's for another
@@ -50,28 +157,60 @@ export function deployApiAddress(config, named) {
50
157
  * deploy's; a hosted command's address is the CLI's own whatever the key).
51
158
  */
52
159
  function storedKeyRefusal(command, config, url, where, keyForCommand) {
160
+ const found = keyElsewhere(config, url, where, keyForCommand);
161
+ if (found === undefined)
162
+ return undefined;
163
+ return `${command} would send ${found.sends}. ${found.stored}${found.fix}`;
164
+ }
165
+ function keyElsewhere(config, url, where, keyForCommand) {
53
166
  if (config.source.token !== 'file')
54
167
  return undefined;
168
+ const keyAddress = config.keyAddress;
169
+ if (keyAddress !== undefined && sameAddress(url, keyAddress))
170
+ return undefined;
55
171
  const keyFile = config.files?.token;
56
- const stored = keyFile === undefined ? 'stored' : `stored in ${keyFile.path}`;
57
- // `kindgi auth login` writes the home file; a folder's file stays over it.
58
- const signIn = keyFile?.kind !== 'folder';
172
+ const stored = keyFile === undefined ? 'the API key stored' : `the API key stored in ${keyFile.path}`;
59
173
  const giveKey = keyForCommand ? ["give that server's key with --token or KINDGI_API_TOKEN"] : [];
60
- const keyAddress = config.keyAddress;
61
174
  if (keyAddress === undefined) {
62
- const store = signIn
63
- ? `sign in to ${url} with \`kindgi auth login --url ${url}\`, which stores the address with the key`
64
- : `add the key's address to ${keyFile?.path} as its apiUrl`;
65
- return `${command} would send the API key ${stored} to ${url}, and no address is stored with that key, so nothing shows it's for ${url}. The key goes only to its own address: ${oneOf([store, ...giveKey])}.`;
175
+ const addAddress = `add "apiUrl": "${url}" beside it in ${keyFile?.path ?? 'its file'}, if it's that server's key`;
176
+ return {
177
+ sends: `${stored} to ${url}, and no address is stored with that key, so nothing shows it's for ${url}`,
178
+ stored: '',
179
+ fix: ownAddressOnly([addAddress, signIn(url), ...giveKey]),
180
+ };
66
181
  }
67
- if (sameAddress(url, keyAddress))
68
- return undefined;
69
- const fixes = [
70
- `point ${where} at ${keyAddress}`,
71
- ...(signIn ? [`sign in to ${url} with \`kindgi auth login --url ${url}\``] : []),
72
- ...giveKey,
73
- ];
74
- return `${command} would send the API key ${stored}, which is for ${keyAddress}, to ${url}, which ${where} names. The key goes only to its own address: ${oneOf(fixes)}.`;
182
+ return {
183
+ sends: `${stored}, which is for ${keyAddress}, to ${url}, which ${where} names`,
184
+ stored: otherKeys(config, url),
185
+ fix: ownAddressOnly([`point ${where} at ${keyAddress}`, signIn(url), ...giveKey]),
186
+ };
187
+ }
188
+ /**
189
+ * How to sign in to `url`. `kindgi auth login` keeps the key with its
190
+ * address in the home file, where it's found by that address from any
191
+ * folder; it saves only a key it's given (auth.ts), never a stored one for
192
+ * another address, so the hint always gives one.
193
+ */
194
+ function signIn(url) {
195
+ return `sign in to ${url} with \`kindgi auth login --url ${url} --token <its key>\``;
196
+ }
197
+ function ownAddressOnly(fixes) {
198
+ return `The key goes only to its own address: ${oneOf(fixes)}.`;
199
+ }
200
+ /**
201
+ * The other stored keys, and that none is for `url`: "" when the key is
202
+ * the only one. In a folder where `kindgi dev` ran, its .kindgirc.json is
203
+ * read over the home sign-in, so this says where each key is for.
204
+ */
205
+ function otherKeys(config, url) {
206
+ const keyFile = config.files?.token;
207
+ const others = (config.storedKeys ?? []).filter((k) => k.file.path !== keyFile?.path);
208
+ if (others.length === 0)
209
+ return '';
210
+ const each = others.map((k) => k.apiUrl === undefined
211
+ ? `${k.file.path} has one with no address`
212
+ : `${k.file.path} has one for ${k.apiUrl}`);
213
+ return `${each.join(', and ')}, and none is stored for ${url}. `;
75
214
  }
76
215
  /**
77
216
  * One address, however it's written: the scheme, the host (any case; the
@@ -1 +1 @@
1
- {"version":3,"file":"api-address.js","sourceRoot":"","sources":["../src/api-address.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,iCAAiC;AAoCjC;;;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,CAAC;AAED,oCAAoC;AACpC,SAAS,KAAK,CAAC,OAA0B;IACvC,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC;QAAE,OAAO,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IAChD,OAAO,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,OAAO,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC,EAAE,CAAC;AACjF,CAAC;AAED,SAAS,KAAK,CAAC,GAAuB;IACpC,OAAO,GAAG,KAAK,SAAS,IAAI,GAAG,KAAK,EAAE,CAAC;AACzC,CAAC;AAED,SAAS,OAAO,CAAC,OAAe;IAC9B,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,CAAC;AACtC,CAAC"}
package/dist/cli.js CHANGED
@@ -1,10 +1,20 @@
1
1
  #!/usr/bin/env node
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
  // Copyright (C) 2026 Kindgi Inc.
4
- import { runCli } from './main.js';
4
+ // Only modules that import nothing load before the Node check, and this file
5
+ // and they keep to syntax older Nodes parse (no nullish coalescing or optional
6
+ // chaining, which Node 12 can't): the rest of the CLI (`main.js`) is imported
7
+ // after the check, so on an older Node its one line is all the CLI prints.
8
+ import { unsupportedNode } from './node-version.js';
5
9
  import { createStopSignal, ignoreOutputAfterHangup } from './stop-signal.js';
6
10
  import { writeFully } from './write-fully.js';
7
11
  async function main() {
12
+ const tooOld = unsupportedNode(process.versions.node);
13
+ if (tooOld !== undefined) {
14
+ await writeFully(process.stderr, `${tooOld}\n`);
15
+ process.exit(1);
16
+ }
17
+ const { runCli } = await import('./main.js');
8
18
  // SIGINT/SIGTERM/SIGHUP → an AbortSignal so long-lived commands
9
19
  // (currently only `kindgi dev` — the watch loop) can shut down cleanly;
10
20
  // a second Ctrl+C forces the exit. Short-lived commands never observe it.
@@ -21,7 +31,7 @@ async function main() {
21
31
  process.exit(outcome.exitCode);
22
32
  }
23
33
  main().catch(async (err) => {
24
- await writeFully(process.stderr, `Fatal: ${err instanceof Error ? (err.stack ?? err.message) : String(err)}\n`);
34
+ await writeFully(process.stderr, `Fatal: ${err instanceof Error ? err.stack || err.message : String(err)}\n`);
25
35
  process.exit(1);
26
36
  });
27
37
  //# sourceMappingURL=cli.js.map
package/dist/cli.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AACA,sCAAsC;AACtC,iCAAiC;AAEjC,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AACnC,OAAO,EAAE,gBAAgB,EAAE,uBAAuB,EAAE,MAAM,kBAAkB,CAAC;AAC7E,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE9C,KAAK,UAAU,IAAI;IACjB,gEAAgE;IAChE,wEAAwE;IACxE,0EAA0E;IAC1E,MAAM,UAAU,GAAG,gBAAgB,CAAC,OAAO,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;IAC3E,uBAAuB,CAAC,OAAO,EAAE,CAAC,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC;IAEnE,MAAM,OAAO,GAAG,MAAM,MAAM,CAAC;QAC3B,IAAI,EAAE,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;QAC3B,GAAG,EAAE,OAAO,CAAC,GAAG;QAChB,UAAU;KACX,CAAC,CAAC;IACH,oEAAoE;IACpE,MAAM,UAAU,CAAC,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC;IACjD,MAAM,UAAU,CAAC,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC;IACjD,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;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AAO,EAAE,CAAC,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC;IAEnE,MAAM,OAAO,GAAG,MAAM,MAAM,CAAC;QAC3B,IAAI,EAAE,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;QAC3B,GAAG,EAAE,OAAO,CAAC,GAAG;QAChB,UAAU;KACX,CAAC,CAAC;IACH,oEAAoE;IACpE,MAAM,UAAU,CAAC,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC;IACjD,MAAM,UAAU,CAAC,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC;IACjD,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;AACjC,CAAC;AAED,IAAI,EAAE,CAAC,KAAK,CAAC,KAAK,EAAE,GAAY,EAAE,EAAE;IAClC,MAAM,UAAU,CACd,OAAO,CAAC,MAAM,EACd,UAAU,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,IAAI,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAC5E,CAAC;IACF,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"approvals.d.ts","sourceRoot":"","sources":["../../src/commands/approvals.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,OAAO,EAAe,MAAM,YAAY,CAAC;AAiJvD,eAAO,MAAM,gBAAgB,EAAE,OAK9B,CAAC"}
1
+ {"version":3,"file":"approvals.d.ts","sourceRoot":"","sources":["../../src/commands/approvals.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,OAAO,EAAe,MAAM,YAAY,CAAC;AA6JvD,eAAO,MAAM,gBAAgB,EAAE,OAK9B,CAAC"}