kylon-cli 0.1.0 → 0.2.0-next.138

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -6,36 +6,31 @@ Requires Node.js 22 or newer.
6
6
 
7
7
  ## Install
8
8
 
9
- The current release train ships a single self-contained `.mjs` bundle
10
- as a GitHub Release asset on the `fre-so/p2` repo. The Web UI
9
+ The CLI is published to npm as
10
+ [`kylon-cli`](https://www.npmjs.com/package/kylon-cli). The Web UI
11
11
  generates two separate commands — an **install** step and a **run**
12
12
  step — each with its own Copy button. Operators paste the install
13
13
  once per host (and any time they want to upgrade) and the run
14
- whenever they want to start the daemon. npm is on the roadmap (see
15
- [Planned: npm install](#planned-npm-install) below) but not wired yet.
14
+ whenever they want to start the daemon.
16
15
 
17
16
  ### Step 1 — Install kylon (once per host, re-paste to upgrade)
18
17
 
19
18
  ```bash
20
- gh release download --repo fre-so/p2 --pattern 'kylon.mjs' --output /tmp/kylon.new \
21
- && chmod +x /tmp/kylon.new \
22
- && sudo mv /tmp/kylon.new /usr/local/bin/kylon
19
+ npm install -g kylon-cli@latest
23
20
  ```
24
21
 
25
- Downloads the latest bundle to an unprivileged scratch file, flips
26
- the executable bit, and `sudo mv`'s it into `/usr/local/bin/kylon`
27
- atomically. The repo is private, so `gh` (authenticated via
28
- `gh auth login`) is required instead of plain `curl`.
22
+ Installs the CLI globally so the `kylon` binary lands on PATH — the
23
+ gateway daemon's child `kylon workspace …` calls (issued by the
24
+ provider subprocess) resolve it there. Re-run to upgrade to whatever
25
+ the dist-tag now points to. If the global install needs elevated
26
+ permissions, prefix it with `sudo`.
29
27
 
30
- Re-paste to upgrade: the `sudo mv` overwrites the binary in place
31
- with whatever the latest release publishes as `kylon.mjs`. If you
32
- want a specific build instead of latest, download the matching
33
- `kylon-vX.Y.Z.mjs` from that release's page — every release
34
- publishes both the stable-name `kylon.mjs` and the versioned copy.
28
+ The dist-tag tracks the environment: production installs `@latest`,
29
+ dev installs `@next` (newest prerelease). To pin a specific build,
30
+ install `kylon-cli@X.Y.Z`.
35
31
 
36
- Requirements: Node.js 22+, [GitHub CLI](https://cli.github.com/)
37
- (`gh auth login`), `sudo`. Linux / macOS only (Windows operators
38
- should use WSL).
32
+ Requirements: Node.js 22+ (npm ships with Node). Linux / macOS only
33
+ (Windows operators should use WSL).
39
34
 
40
35
  ### Step 2 — Start the gateway daemon
41
36
 
@@ -65,21 +60,45 @@ pnpm --filter kylon-cli build
65
60
  See [Development → Exposing `kylon` to provider subprocesses](#exposing-kylon-to-provider-subprocesses)
66
61
  for the debugger-friendly tsx-based dev loop.
67
62
 
68
- ### Planned: npm install
63
+ ### Release channels
69
64
 
70
- The npm distribution path is designed (see
71
- [`docs/journal_docs/04_13_cli_npx_gateway_run_release_plan.md`](../../docs/journal_docs/04_13_cli_npx_gateway_run_release_plan.md))
72
- and this package is already publish-ready (`packages/cli/package.json`
73
- has the metadata and `prepack` runs `bundle:release`). Publishing is
74
- held pending the rollout-config side of that plan (platform-served
75
- `recommendedCliVersion`), at which point the Web UI will drop the
76
- Install step entirely and flip the Run step to
77
- `npx -y kylon-cli@<recommended> gateway run …`. Don't `npm publish`
78
- ad-hoc before that the first live release should come out through
79
- the paired CI workflow so the token path is exercised end-to-end.
65
+ npm dist-tags are the version pointer — there is no server-side version
66
+ policy. Every merge to `develop` publishes a prerelease to the `next` tag
67
+ (`.github/workflows/cli-publish.yml`); cutting a `kylon-cli-vX.Y.Z`
68
+ release tag publishes a stable to `latest`. dev installs `@next` and prd
69
+ installs `@latest`, so each environment tracks its own train.
70
+
71
+ Cutting a stable is a manual, when-ready step: tag a validated build
72
+ `kylon-cli-vX.Y.Z` and push the tag; CI publishes it to `latest`. Don't
73
+ `npm publish` ad-hoc releases go through the CI workflow so the OIDC
74
+ publish path is exercised end-to-end.
80
75
 
81
76
  ## Usage
82
77
 
78
+ ### Onboard an invited external agent
79
+
80
+ The Web UI provides one operator-run command after an external agent is
81
+ created. Run it from the project directory the agent should use:
82
+
83
+ ```bash
84
+ npx --yes kylon-cli@latest onboard \
85
+ --url 'https://api.kylon.io/docs/agent-onboard/<opaque-token>'
86
+ ```
87
+
88
+ The command resolves the invitation without printing its API key, checks the
89
+ local provider, verifies Codex or Claude Code authentication, connects the
90
+ gateway, binds a working directory, and starts the foreground daemon. On first
91
+ onboarding it uses the current directory. Re-onboarding the same agent preserves
92
+ its registered provider and directory, safely interrupts unfinished work owned
93
+ by the displaced connection, and replaces the foreground daemon. If Codex or
94
+ Claude Code is logged out, an interactive terminal launches the provider's own
95
+ login flow and verifies authentication again before connecting.
96
+
97
+ Use `--workdir <path>` to select a different directory or `--no-start` to
98
+ configure and validate without opening the long-running connection. Generic
99
+ providers can supply their one-shot command with `--agent-command <command>`;
100
+ an interactive terminal prompts for it when the flag is omitted.
101
+
83
102
  ### Run
84
103
 
85
104
  `gateway run` is the recommended entrypoint for external agent operators.
@@ -291,9 +310,9 @@ shim. The shim execs `node --import tsx <src>`, so:
291
310
  - On SIGINT/SIGTERM the tmpdir is wiped.
292
311
 
293
312
  This flag is **only compiled into local (non-minified) builds**. The
294
- npm package, the GitHub Release bundle, and any `bundle:release`
295
- output reject `--dev-cli-shim` as an unknown argument and omit it from
296
- `--help`, so it can never accidentally ship.
313
+ npm package and any `bundle:release` output reject `--dev-cli-shim` as
314
+ an unknown argument and omit it from `--help`, so it can never
315
+ accidentally ship.
297
316
 
298
317
  ### Debugging both the daemon and `kylon workspace` calls
299
318
 
@@ -339,7 +358,7 @@ The release artifact is a single-file ESM bundle produced by
339
358
  |---|---|---|---|
340
359
  | `pnpm --filter kylon-cli bundle` | `dist/kylon-bundle.mjs` | _(none)_ | debugging the bundled shape while keeping readable names — not shipped |
341
360
  | `pnpm --filter kylon-cli bundle:minify` | `dist/kylon-bundle.mjs` | `--minify` | reproducing the pre-obfuscation size and behavior for a bisect |
342
- | `pnpm --filter kylon-cli bundle:release` | `dist/kylon-bundle.mjs` | `--minify --obfuscate` | what ships on npm and in GitHub Releases |
361
+ | `pnpm --filter kylon-cli bundle:release` | `dist/kylon-bundle.mjs` | `--minify --obfuscate` | what ships on npm |
343
362
 
344
363
  The `bundle:release` path runs esbuild with `--minify`, then passes the
345
364
  output through `javascript-obfuscator`. It's also what the `prepack` hook
@@ -423,12 +442,11 @@ API server is the security boundary.
423
442
 
424
443
  ## Release
425
444
 
426
- Today there is **one** active release channel: a bundled `.mjs`
427
- uploaded as a GitHub Release asset. The npm channel is designed and
428
- publish-ready but intentionally held pending the
429
- `recommendedCliVersion` rollout config described in
430
- [`docs/journal_docs/04_13_cli_npx_gateway_run_release_plan.md`](../../docs/journal_docs/04_13_cli_npx_gateway_run_release_plan.md).
431
- See [Planned: npm publish](#planned-npm-publish) below.
445
+ The CLI ships via **npm dist-tags** there is no server-side version policy.
446
+ `cli-verify.yml` validates on PRs and pushes; `cli-publish.yml` publishes via
447
+ OIDC (no token): a prerelease to the `next` tag on every merge to `main`, and a
448
+ stable to `latest` when a `kylon-cli-vX.Y.Z` tag is pushed. dev installs
449
+ `@next`, prd installs `@latest`.
432
450
 
433
451
  ### Versioning
434
452
 
@@ -440,121 +458,39 @@ Use explicit semver in `packages/cli/package.json`:
440
458
  | minor (`0.1.x → 0.2.0`) | backward-compatible capability (new command, new flag) |
441
459
  | major (`0.x.x → 1.0.0`) | breaking change to CLI contract or runtime behavior |
442
460
 
443
- The GitHub Release tag still uses the historical
444
- `cli/v0.0.${github.run_number}` scheme, which is fine as an opaque
445
- build id while there is no consumer that pins to it. The moment we
446
- flip the npm plan on, bump `packages/cli/package.json` to explicit
447
- semver and let the publish workflow own version selection.
461
+ Prerelease builds are versioned `0.1.0-next.<run>` automatically by
462
+ `cli-publish.yml`; a stable release is whatever you tag — bump
463
+ `packages/cli/package.json` to the target semver, then push the matching
464
+ `kylon-cli-vX.Y.Z` tag.
448
465
 
449
- ### Active channel — GitHub Release asset
466
+ ### Publishing
450
467
 
451
- Triggered automatically by `.github/workflows/release-cli.yml` on any
452
- push to `main` that touches `packages/cli/**`,
453
- `packages/workspace-cli-core/**`, or `packages/types/**`. The workflow:
468
+ - **Prerelease (automatic):** every merge to `main` touching the CLI publishes
469
+ `0.1.0-next.<run>` to the `next` tag via `cli-publish.yml` (OIDC, no
470
+ `NPM_TOKEN`). dev tracks this tag, so dev always dogfoods the newest build.
471
+ - **Stable (manual, when ready):** bump `packages/cli/package.json` to the
472
+ target version, merge, then tag the commit on `main`:
454
473
 
455
- 1. Runs `pnpm --filter kylon-cli bundle:release` (obfuscated output).
456
- 2. Smoke-tests `node packages/cli/dist/kylon-bundle.mjs --help`.
457
- 3. Copies the bundle to **two** asset names under the release:
458
- - `kylon-v0.0.${run_number}.mjs` versioned, useful for pinning.
459
- - `kylon.mjs` stable name, downloadable via
460
- `gh release download --repo fre-so/p2 --pattern 'kylon.mjs'`.
461
- 4. Creates a GitHub Release tagged `cli/v0.0.${run_number}` with both
462
- `.mjs` files attached.
474
+ ```bash
475
+ git pull
476
+ git tag kylon-cli-v0.1.1
477
+ git push origin kylon-cli-v0.1.1 # cli-publish.yml publishes it to `latest`
478
+ npm view kylon-cli dist-tags # verify
479
+ ```
463
480
 
464
- The repo is private, so downloads require `gh` (authenticated) rather
465
- than plain `curl`. This is the shape the Web UI generates:
481
+ Do not `npm publish` ad-hoc releases go through the workflow so the OIDC
482
+ provenance path is exercised end to end.
466
483
 
467
- ```bash
468
- gh release download --repo fre-so/p2 --pattern 'kylon.mjs' --output /tmp/kylon
469
- chmod +x /tmp/kylon
470
- sudo mv /tmp/kylon /usr/local/bin/kylon
471
- ```
484
+ ### Rollback
472
485
 
473
- Pin to a specific build by downloading the versioned asset from its
474
- release page instead.
475
-
476
- No npm token required; the workflow only needs `contents: write`.
477
-
478
- ### Rollback (GitHub channel)
479
-
480
- If the most recent push produced a broken CLI:
481
-
482
- 1. Identify the last known good release under
483
- <https://github.com/fre-so/p2/releases>.
484
- 2. Manually re-upload that release's bundle under the name
485
- `kylon.mjs` on the most recent release — that's what the Web UI's
486
- stable URL resolves against. (Alternatively, revert the bad commit
487
- and let `release-cli.yml` cut a new release.)
488
- 3. Hosts with persistent installs re-run `curl -fsSL … -o
489
- /usr/local/bin/kylon` to pull the rolled-back bundle.
490
-
491
- There is no equivalent of `npm deprecate` on GitHub Releases, so a
492
- broken bundle is "fixed" only by publishing a newer one.
493
-
494
- ### Planned: npm publish
495
-
496
- This package is already wired for `npm publish` (metadata, `files`,
497
- `prepack`, `publishConfig.access: public`). The only things missing
498
- are the publish CI workflow and the owning npm account. The plan:
499
-
500
- 1. Someone claims `kylon-cli` on npm (the name is currently 404).
501
- 2. A granular publish token (Read + Write on `kylon-cli`) is stored
502
- as the `NPM_TOKEN` GitHub Actions secret on `fre-so/p2`.
503
- 3. Split the release automation:
504
- - **`cli-verify.yml`** — runs on PRs and pushes touching
505
- `packages/cli/**`. Runs typecheck, lint, test, `bundle:release`,
506
- and `npm pack`. Does not publish.
507
- - **`cli-publish.yml`** — runs on push of tag `cli/vX.Y.Z`.
508
- Verifies the tag matches `packages/cli/package.json#version`,
509
- then `pnpm --filter kylon-cli publish --access public
510
- --no-git-checks` with
511
- `NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}`.
512
- 4. The API exposes `recommendedCliVersion`; the Web UI flips from
513
- the `curl` shape above to `npx -y kylon-cli@<recommended> gateway
514
- run …`.
515
-
516
- Until (2) + (3) land, do **not** `npm publish` ad-hoc — the first
517
- live release should come out through the paired CI workflow so the
518
- token path is exercised end-to-end. Once the workflow exists, the
519
- release ritual becomes:
486
+ npm publishes are immutable; roll back by re-pointing the tag, not by
487
+ unpublishing:
520
488
 
521
489
  ```bash
522
- # 1. On a release branch
523
- pnpm --filter kylon-cli version 0.1.1 # bumps packages/cli/package.json only
524
-
525
- # 2. Merge to main via PR, verify CI is green
526
-
527
- # 3. Tag the commit on main
528
- git pull
529
- git tag cli/v0.1.1
530
- git push origin cli/v0.1.1
531
-
532
- # 4. GitHub Actions publishes; verify
533
- npm view kylon-cli@0.1.1 dist-tags
490
+ npm dist-tag add kylon-cli@<last-good> latest # move the channel back
491
+ npm deprecate kylon-cli@<bad> "Broken release use <last-good>."
534
492
  ```
535
493
 
536
- Rollback once npm is live: flip `recommendedCliVersion` in the API
537
- back to the last known good version (new operators get that version
538
- in their install command; in-flight daemons keep their current CLI
539
- until they restart). If the pushed version is actively broken, also
540
- `npm deprecate kylon-cli@<bad> "…"` so operators that ignore the
541
- recommendation see a warning. Do not `npm unpublish`.
542
-
543
- ### Pre-release channel (npm-era, also planned)
544
-
545
- Once npm is live, risky changes can go out under a `next` dist-tag so
546
- the Web UI's recommended version is untouched:
547
-
548
- ```bash
549
- # 1. Bump to a prerelease version
550
- pnpm --filter kylon-cli version 0.2.0-next.0
551
-
552
- # 2. Publish under the `next` dist-tag
553
- cd packages/cli && pnpm publish --tag next --access public --no-git-checks
554
-
555
- # 3. Operators can opt in explicitly
556
- npx -y kylon-cli@next gateway run …
557
-
558
- # 4. Promote to `latest` once validated
559
- npm dist-tag add kylon-cli@0.2.0-next.0 latest
560
- ```
494
+ Operators on `@latest` pick up the re-pointed version the next time they
495
+ `npm install -g kylon-cli@latest`; in-flight daemons keep their current CLI
496
+ until they restart. Do not `npm unpublish`.