@kaiba-cloud/cli 0.1.0 → 0.2.1
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 +112 -39
- package/action.yml +57 -3
- package/dist/cli.js +8941 -172
- package/package.json +14 -7
- package/skills/kaiba-cli/SKILL.md +239 -0
- package/dist/client.js +0 -52
package/README.md
CHANGED
|
@@ -1,32 +1,93 @@
|
|
|
1
1
|
# @kaiba-cloud/cli
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
The Kaiba platform from a terminal, a CI job, or an agent.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
```bash
|
|
6
|
+
npm install -g @kaiba-cloud/cli
|
|
7
|
+
kaiba login
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
## Why a CLI
|
|
11
|
+
|
|
12
|
+
Two things a hosted tool cannot do, and this can.
|
|
13
|
+
|
|
14
|
+
**It waits.** `kaiba sessions run --agent <id> --wait` blocks until the agent run
|
|
15
|
+
is done, however long that takes, and puts the outcome in its exit code. There is
|
|
16
|
+
no default timeout, because a client that gives up at an arbitrary minute mark
|
|
17
|
+
turns one job into a guessing game about how long to allow.
|
|
18
|
+
|
|
19
|
+
**It keeps your credential out of a model's context.** The token lives in your OS
|
|
20
|
+
keychain. There is no flag to pass one, so it never reaches a shell history, a
|
|
21
|
+
process table, or an agent transcript.
|
|
22
|
+
|
|
23
|
+
## Logging in
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
kaiba login # prints a code; approve it in a browser
|
|
27
|
+
kaiba whoami # which credential, from where, which organisation
|
|
28
|
+
kaiba orgs # every organisation this login reaches
|
|
29
|
+
kaiba org use acme
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
Login uses the OAuth device flow, so it works over SSH, in a container and in a
|
|
33
|
+
sandbox — anywhere without a browser to open. One login covers every organisation
|
|
34
|
+
you belong to, and the platform's own permissions decide each request.
|
|
35
|
+
|
|
36
|
+
For CI, set `KAIBA_API_TOKEN` to a `kaiba_deploy_` token instead. That credential
|
|
37
|
+
reaches the `build`, `deploy`, `registry-login` and `status` commands only.
|
|
38
|
+
|
|
39
|
+
## For agents
|
|
40
|
+
|
|
41
|
+
The CLI describes itself, and the description is generated from the same
|
|
42
|
+
declarations that parse your arguments — so it cannot be out of date:
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
kaiba describe # top-level commands, one line each
|
|
46
|
+
kaiba describe env # one group
|
|
47
|
+
kaiba schema sessions run # one command's full schema
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
Both need no credential and make no network call.
|
|
6
51
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
token grants only `build` and/or `deploy`. It is NOT an org admin key. Store it
|
|
10
|
-
as a CI secret and pass it as `KAIBA_API_TOKEN`.
|
|
52
|
+
Output is JSON whenever stdout is not a terminal. Errors go to stderr with a
|
|
53
|
+
machine-readable `code`, a `hint`, and often an exact `nextCommand` to run.
|
|
11
54
|
|
|
12
|
-
|
|
13
|
-
|
|
55
|
+
Exit codes: **0** success, **1** failed, **2** auth, **3** validation (nothing
|
|
56
|
+
happened), **4** confirmation required (nothing happened), **5** writes landed but
|
|
57
|
+
something needs a human.
|
|
14
58
|
|
|
15
|
-
|
|
59
|
+
A destructive command without `--confirm` exits 4, changes nothing, and prints
|
|
60
|
+
what it would do plus a `confirmCommand` to re-run. That replaces an interactive
|
|
61
|
+
prompt, which an agent can neither see nor answer.
|
|
62
|
+
|
|
63
|
+
Install the agent skill so an assistant knows all of this:
|
|
16
64
|
|
|
17
65
|
```bash
|
|
18
|
-
kaiba
|
|
19
|
-
kaiba
|
|
20
|
-
kaiba
|
|
66
|
+
kaiba skill install # into ./.claude/skills
|
|
67
|
+
kaiba skill install --global # into ~/.claude/skills
|
|
68
|
+
kaiba skill # just print it
|
|
21
69
|
```
|
|
22
70
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
- `deploy` retargets one compose service to an image and waits for it to run.
|
|
27
|
-
- `status` prints each service and its live state.
|
|
71
|
+
## Commands
|
|
72
|
+
|
|
73
|
+
Run `kaiba describe` for the current list. In outline:
|
|
28
74
|
|
|
29
|
-
|
|
75
|
+
| Group | What it does |
|
|
76
|
+
|---|---|
|
|
77
|
+
| `login`, `logout`, `whoami`, `orgs`, `org use` | Authentication and organisation selection |
|
|
78
|
+
| `agents` | Your organisation's agents. Kaiba's own system agents are not included. |
|
|
79
|
+
| `sessions` | Start an agent run, wait for it, stream it, stop it |
|
|
80
|
+
| `artifacts` | Upload, fetch, list and delete artifacts |
|
|
81
|
+
| `env` | Dev environments: compose, vars, logs, exec, query, jobs, volumes |
|
|
82
|
+
| `campus` | Deploy skills, agents and blueprints from a repo |
|
|
83
|
+
| `workflows` | Trigger workflows as `*.trigger.json` in git; run one from a node |
|
|
84
|
+
| `build`, `deploy`, `registry-login`, `status` | CI, on a deploy token |
|
|
85
|
+
| `describe`, `schema`, `skill`, `update` | Introspection and maintenance |
|
|
86
|
+
|
|
87
|
+
## Building and deploying from CI
|
|
88
|
+
|
|
89
|
+
The Action wraps the same binary. It carries the deploy-token commands only,
|
|
90
|
+
because a personal credential has no business in a shared workflow.
|
|
30
91
|
|
|
31
92
|
```yaml
|
|
32
93
|
jobs:
|
|
@@ -34,37 +95,49 @@ jobs:
|
|
|
34
95
|
runs-on: ubuntu-latest
|
|
35
96
|
steps:
|
|
36
97
|
- uses: actions/checkout@v4
|
|
98
|
+
- id: kaiba
|
|
99
|
+
uses: ai-kaiba/kaiba-action@v1
|
|
100
|
+
with:
|
|
101
|
+
command: registry-login
|
|
102
|
+
api-token: ${{ secrets.KAIBA_API_TOKEN }}
|
|
103
|
+
- uses: docker/build-push-action@v6
|
|
104
|
+
with:
|
|
105
|
+
push: true
|
|
106
|
+
tags: ${{ steps.kaiba.outputs.registry-url }}/web:${{ github.sha }}
|
|
37
107
|
- uses: ai-kaiba/kaiba-action@v1
|
|
38
108
|
with:
|
|
39
|
-
command:
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
image: web
|
|
43
|
-
tag: ${{ github.sha }}
|
|
44
|
-
service: web # chains a deploy after the build
|
|
109
|
+
command: deploy
|
|
110
|
+
service: web
|
|
111
|
+
image: ${{ steps.kaiba.outputs.registry-url }}/web:${{ github.sha }}
|
|
45
112
|
api-token: ${{ secrets.KAIBA_API_TOKEN }}
|
|
46
113
|
```
|
|
47
114
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
Published manually — no CI token to rotate. From the repo root:
|
|
115
|
+
Or have Kaiba do the build:
|
|
51
116
|
|
|
52
117
|
```bash
|
|
53
|
-
|
|
54
|
-
# 2. build + publish (publish runs the build via prepublishOnly)
|
|
55
|
-
cd packages/kaiba-cli
|
|
56
|
-
npm login # once per machine; prompts for 2FA
|
|
57
|
-
npm publish # access:public is set in package.json; prompts for an OTP
|
|
118
|
+
kaiba build --repo <url> --branch <ref> --image web --deploy-service web
|
|
58
119
|
```
|
|
59
120
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
- npm refuses to republish an existing version — always bump first.
|
|
63
|
-
- The published tarball contains only `dist/`, `action.yml`, and this README.
|
|
121
|
+
`build` builds a **pushed** git ref on your own cluster and streams status until
|
|
122
|
+
it succeeds or fails.
|
|
64
123
|
|
|
65
|
-
|
|
66
|
-
builds it automatically via `prepublishOnly`; to build without publishing:
|
|
124
|
+
## Updating
|
|
67
125
|
|
|
68
126
|
```bash
|
|
69
|
-
|
|
127
|
+
kaiba update --check # changes nothing; safe anywhere
|
|
128
|
+
kaiba update
|
|
70
129
|
```
|
|
130
|
+
|
|
131
|
+
The CLI notices a newer version from headers the hub already sends, so it costs no
|
|
132
|
+
extra request. It never checks or updates in CI, when output is machine-readable,
|
|
133
|
+
or under `--quiet` or `--non-interactive`: a pipeline must not get a different
|
|
134
|
+
binary mid-run.
|
|
135
|
+
|
|
136
|
+
## Publishing (maintainers)
|
|
137
|
+
|
|
138
|
+
Bump `version` in `package.json`, then push a matching `cli-v<version>` tag. The
|
|
139
|
+
`Release CLI` workflow tests, builds, verifies the tarball and publishes with
|
|
140
|
+
provenance. It refuses a version that is already on the registry, and a tag that
|
|
141
|
+
disagrees with `package.json`.
|
|
142
|
+
|
|
143
|
+
`npm publish` by hand still works and is the break-glass path.
|
package/action.yml
CHANGED
|
@@ -6,7 +6,7 @@ branding:
|
|
|
6
6
|
|
|
7
7
|
inputs:
|
|
8
8
|
command:
|
|
9
|
-
description: 'build | deploy | status'
|
|
9
|
+
description: 'build | deploy | registry-login | status'
|
|
10
10
|
required: true
|
|
11
11
|
api-token:
|
|
12
12
|
description: 'A scoped Kaiba deploy token (store it as a secret).'
|
|
@@ -14,6 +14,10 @@ inputs:
|
|
|
14
14
|
hub-url:
|
|
15
15
|
description: 'Kaiba hub URL. Defaults to https://cloud.kaiba.ai.'
|
|
16
16
|
required: false
|
|
17
|
+
cli-version:
|
|
18
|
+
description: 'npm version range for the CLI. Defaults to the major of the ref you pinned this action to.'
|
|
19
|
+
required: false
|
|
20
|
+
default: ''
|
|
17
21
|
# build inputs
|
|
18
22
|
repo:
|
|
19
23
|
description: 'Git repository URL to build (build).'
|
|
@@ -40,11 +44,20 @@ inputs:
|
|
|
40
44
|
service:
|
|
41
45
|
description: 'Compose service name to retarget (deploy, or build with chained deploy).'
|
|
42
46
|
required: false
|
|
47
|
+
output:
|
|
48
|
+
description: 'Output format: text | json | ndjson. Use json to parse the result with jq.'
|
|
49
|
+
required: false
|
|
50
|
+
|
|
51
|
+
outputs:
|
|
52
|
+
registry-url:
|
|
53
|
+
description: 'The registry push prefix (set by the registry-login command). Append /<image>:<tag>.'
|
|
54
|
+
value: ${{ steps.run.outputs.registry-url }}
|
|
43
55
|
|
|
44
56
|
runs:
|
|
45
57
|
using: 'composite'
|
|
46
58
|
steps:
|
|
47
59
|
- name: Run kaiba
|
|
60
|
+
id: run
|
|
48
61
|
shell: bash
|
|
49
62
|
# Every input reaches bash ONLY through the environment — never interpolated
|
|
50
63
|
# into the script body. Interpolating `${{ inputs.* }}` into `run:` would let
|
|
@@ -53,7 +66,6 @@ runs:
|
|
|
53
66
|
env:
|
|
54
67
|
KAIBA_API_TOKEN: ${{ inputs.api-token }}
|
|
55
68
|
KAIBA_HUB_URL: ${{ inputs.hub-url }}
|
|
56
|
-
ACTION_PATH: ${{ github.action_path }}
|
|
57
69
|
IN_COMMAND: ${{ inputs.command }}
|
|
58
70
|
IN_REPO: ${{ inputs.repo }}
|
|
59
71
|
IN_BRANCH: ${{ inputs.branch }}
|
|
@@ -63,6 +75,16 @@ runs:
|
|
|
63
75
|
IN_CONTEXT: ${{ inputs.context }}
|
|
64
76
|
IN_GIT_TOKEN: ${{ inputs.git-token }}
|
|
65
77
|
IN_SERVICE: ${{ inputs.service }}
|
|
78
|
+
IN_OUTPUT: ${{ inputs.output }}
|
|
79
|
+
CLI_VERSION: ${{ inputs.cli-version }}
|
|
80
|
+
# The ref the CALLER pinned — `v1` for `uses: ai-kaiba/kaiba-cli@v1`.
|
|
81
|
+
# The CLI major is read from it, so this file never needs editing when a
|
|
82
|
+
# new major ships: tagging `v2` in this repository is the whole release.
|
|
83
|
+
ACTION_REF: ${{ github.action_ref }}
|
|
84
|
+
# A workflow pins its CLI version through the `uses:` ref, so the CLI must
|
|
85
|
+
# not change it underneath. `CI` is set on every runner and would be enough
|
|
86
|
+
# on its own; this states the intent rather than relying on it.
|
|
87
|
+
KAIBA_DISABLE_AUTO_UPDATE: '1'
|
|
66
88
|
run: |
|
|
67
89
|
set -euo pipefail
|
|
68
90
|
add() { [ -n "${2:-}" ] && ARGS+=("--$1" "$2") || true; }
|
|
@@ -82,7 +104,39 @@ runs:
|
|
|
82
104
|
add service "$IN_SERVICE"
|
|
83
105
|
add image "$IN_IMAGE"
|
|
84
106
|
;;
|
|
107
|
+
registry-login) ;;
|
|
85
108
|
status) ;;
|
|
109
|
+
# Deploy-token commands only, on purpose. The user commands
|
|
110
|
+
# (env, campus, sessions, workflows) authenticate a PERSON, and a
|
|
111
|
+
# personal credential has no business in a shared workflow.
|
|
86
112
|
*) echo "Unknown command: $IN_COMMAND" >&2; exit 1 ;;
|
|
87
113
|
esac
|
|
88
|
-
|
|
114
|
+
add output "$IN_OUTPUT"
|
|
115
|
+
# Fetched from npm rather than vendored beside this file.
|
|
116
|
+
#
|
|
117
|
+
# A vendored `dist/cli.js` has to be re-pushed to this repository on
|
|
118
|
+
# every CLI release, which is how the copy here came to lag the source.
|
|
119
|
+
# npm already holds the published build, so the action carries no code
|
|
120
|
+
# at all and cannot drift from it.
|
|
121
|
+
#
|
|
122
|
+
# Which CLI to run, in order: an explicit `cli-version` input, else the
|
|
123
|
+
# major of the ref the caller pinned, else `latest`.
|
|
124
|
+
#
|
|
125
|
+
# Reading it from the ref is what lets this file stay fixed forever:
|
|
126
|
+
# `@v1` resolves to `1` (the newest 1.x, so fixes arrive on their own),
|
|
127
|
+
# `@v2` to `2`, and shipping a new major is just a new tag here.
|
|
128
|
+
#
|
|
129
|
+
# A ref that is not `vN` — a branch, or a commit SHA someone pinned for
|
|
130
|
+
# reproducibility — carries no version, so `latest` stands in rather than
|
|
131
|
+
# guessing a major that may not exist.
|
|
132
|
+
VERSION="$CLI_VERSION"
|
|
133
|
+
if [ -z "$VERSION" ]; then
|
|
134
|
+
case "$ACTION_REF" in
|
|
135
|
+
v[0-9]*) VERSION="${ACTION_REF#v}"; VERSION="${VERSION%%.*}" ;;
|
|
136
|
+
*) VERSION='latest' ;;
|
|
137
|
+
esac
|
|
138
|
+
fi
|
|
139
|
+
|
|
140
|
+
echo "Using @kaiba-cloud/cli@${VERSION}"
|
|
141
|
+
# `-y` because a runner is non-interactive.
|
|
142
|
+
npx -y "@kaiba-cloud/cli@${VERSION}" "$IN_COMMAND" ${ARGS[@]+"${ARGS[@]}"}
|