@oasissys/k8s-cli 0.1.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.
- package/LICENSE +21 -0
- package/README.md +84 -0
- package/dist/bin/oasis-k8s.d.ts +2 -0
- package/dist/bin/oasis-k8s.js +4 -0
- package/dist/bin/oasis-k8s.js.map +1 -0
- package/dist/src/axi.d.ts +122 -0
- package/dist/src/axi.js +406 -0
- package/dist/src/axi.js.map +1 -0
- package/dist/src/cli.d.ts +16 -0
- package/dist/src/cli.js +768 -0
- package/dist/src/cli.js.map +1 -0
- package/dist/src/client.d.ts +158 -0
- package/dist/src/client.js +185 -0
- package/dist/src/client.js.map +1 -0
- package/dist/src/config.d.ts +13 -0
- package/dist/src/config.js +20 -0
- package/dist/src/config.js.map +1 -0
- package/dist/src/storage.d.ts +22 -0
- package/dist/src/storage.js +88 -0
- package/dist/src/storage.js.map +1 -0
- package/dist/src/toon.d.ts +19 -0
- package/dist/src/toon.js +148 -0
- package/dist/src/toon.js.map +1 -0
- package/package.json +55 -0
- package/skills/k8s-cli/SKILL.md +63 -0
package/dist/src/toon.js
ADDED
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Minimal TOON (Token-Oriented Object Notation) encoder.
|
|
3
|
+
*
|
|
4
|
+
* TOON is the stdout format for AXI CLIs — ~40% fewer tokens than JSON while
|
|
5
|
+
* staying readable by agents. See https://toonformat.dev/reference/spec.html.
|
|
6
|
+
*
|
|
7
|
+
* Keep all internal logic on plain JS objects; call `encode()` only at the
|
|
8
|
+
* output boundary. This encoder covers the shapes an AXI CLI actually emits:
|
|
9
|
+
*
|
|
10
|
+
* - objects key: value
|
|
11
|
+
* - nested objects key:\n child: value
|
|
12
|
+
* - tabular arrays key[N]{f1,f2}:\n a,b\n c,d
|
|
13
|
+
* - primitive arrays key[N]: a,b,c
|
|
14
|
+
* - empty arrays key[0]:
|
|
15
|
+
*
|
|
16
|
+
* Two-space indentation, no tabs, no trailing newline (§12).
|
|
17
|
+
*/
|
|
18
|
+
const INDENT = " ";
|
|
19
|
+
function isPlainObject(v) {
|
|
20
|
+
return typeof v === "object" && v !== null && !Array.isArray(v);
|
|
21
|
+
}
|
|
22
|
+
function isScalar(v) {
|
|
23
|
+
return v === null || v === undefined || ["string", "number", "boolean"].includes(typeof v);
|
|
24
|
+
}
|
|
25
|
+
// §7.2 — a string MUST be quoted when it would otherwise be ambiguous with a
|
|
26
|
+
// structural token, a literal (true/false/null), or a number. We also quote on
|
|
27
|
+
// the comma delimiter so the same formatter is safe inside tabular rows.
|
|
28
|
+
const NUMERIC_LIKE = /^-?\d+(?:\.\d+)?(?:e[+-]?\d+)?$/i;
|
|
29
|
+
const NEEDS_QUOTE = /[:"\\[\]{},]/;
|
|
30
|
+
function hasControlChar(s) {
|
|
31
|
+
for (let i = 0; i < s.length; i++) {
|
|
32
|
+
if (s.charCodeAt(i) <= 0x1f)
|
|
33
|
+
return true;
|
|
34
|
+
}
|
|
35
|
+
return false;
|
|
36
|
+
}
|
|
37
|
+
function quoteString(s) {
|
|
38
|
+
const needs = s.length === 0 ||
|
|
39
|
+
s !== s.trim() ||
|
|
40
|
+
s === "true" ||
|
|
41
|
+
s === "false" ||
|
|
42
|
+
s === "null" ||
|
|
43
|
+
NUMERIC_LIKE.test(s) ||
|
|
44
|
+
NEEDS_QUOTE.test(s) ||
|
|
45
|
+
hasControlChar(s);
|
|
46
|
+
if (!needs)
|
|
47
|
+
return s;
|
|
48
|
+
const escaped = s
|
|
49
|
+
.replace(/\\/g, "\\\\")
|
|
50
|
+
.replace(/"/g, '\\"')
|
|
51
|
+
.replace(/\n/g, "\\n")
|
|
52
|
+
.replace(/\r/g, "\\r")
|
|
53
|
+
.replace(/\t/g, "\\t");
|
|
54
|
+
return `"${escaped}"`;
|
|
55
|
+
}
|
|
56
|
+
function formatScalar(v) {
|
|
57
|
+
if (v === null || v === undefined)
|
|
58
|
+
return "null";
|
|
59
|
+
if (typeof v === "boolean")
|
|
60
|
+
return v ? "true" : "false";
|
|
61
|
+
if (typeof v === "number") {
|
|
62
|
+
if (!Number.isFinite(v))
|
|
63
|
+
return "null";
|
|
64
|
+
return Object.is(v, -0) ? "0" : String(v);
|
|
65
|
+
}
|
|
66
|
+
if (typeof v === "string")
|
|
67
|
+
return quoteString(v);
|
|
68
|
+
// Non-scalar leaked into a scalar slot — stringify defensively rather than throw.
|
|
69
|
+
return quoteString(JSON.stringify(v));
|
|
70
|
+
}
|
|
71
|
+
function tableFields(arr) {
|
|
72
|
+
// Tabular form is only valid when every row is a flat object (scalar values)
|
|
73
|
+
// sharing the first row's key set. Otherwise fall back to a list.
|
|
74
|
+
const fields = Object.keys(arr[0]);
|
|
75
|
+
if (fields.length === 0)
|
|
76
|
+
return null;
|
|
77
|
+
for (const row of arr) {
|
|
78
|
+
const keys = Object.keys(row);
|
|
79
|
+
if (keys.length !== fields.length || !fields.every(f => f in row))
|
|
80
|
+
return null;
|
|
81
|
+
if (!fields.every(f => isScalar(row[f])))
|
|
82
|
+
return null;
|
|
83
|
+
}
|
|
84
|
+
return fields;
|
|
85
|
+
}
|
|
86
|
+
function emitArray(key, arr, depth, lines) {
|
|
87
|
+
const pad = INDENT.repeat(depth);
|
|
88
|
+
if (arr.length === 0) {
|
|
89
|
+
lines.push(`${pad}${key}[0]:`);
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
if (arr.every(isScalar)) {
|
|
93
|
+
lines.push(`${pad}${key}[${arr.length}]: ${arr.map(formatScalar).join(",")}`);
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
if (arr.every(isPlainObject)) {
|
|
97
|
+
const rows = arr;
|
|
98
|
+
const fields = tableFields(rows);
|
|
99
|
+
if (fields) {
|
|
100
|
+
lines.push(`${pad}${key}[${arr.length}]{${fields.join(",")}}:`);
|
|
101
|
+
for (const row of rows) {
|
|
102
|
+
lines.push(`${INDENT.repeat(depth + 1)}${fields.map(f => formatScalar(row[f])).join(",")}`);
|
|
103
|
+
}
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
// Non-uniform / nested objects → list of blocks.
|
|
107
|
+
lines.push(`${pad}${key}[${arr.length}]:`);
|
|
108
|
+
for (const row of rows) {
|
|
109
|
+
lines.push(`${INDENT.repeat(depth + 1)}-`);
|
|
110
|
+
emitObject(row, depth + 2, lines);
|
|
111
|
+
}
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
// Mixed array — stringify each element as a scalar.
|
|
115
|
+
lines.push(`${pad}${key}[${arr.length}]: ${arr.map(formatScalar).join(",")}`);
|
|
116
|
+
}
|
|
117
|
+
function emitObject(obj, depth, lines) {
|
|
118
|
+
const pad = INDENT.repeat(depth);
|
|
119
|
+
for (const [key, value] of Object.entries(obj)) {
|
|
120
|
+
if (value === undefined)
|
|
121
|
+
continue;
|
|
122
|
+
if (Array.isArray(value)) {
|
|
123
|
+
emitArray(key, value, depth, lines);
|
|
124
|
+
}
|
|
125
|
+
else if (isPlainObject(value)) {
|
|
126
|
+
lines.push(`${pad}${key}:`);
|
|
127
|
+
emitObject(value, depth + 1, lines);
|
|
128
|
+
}
|
|
129
|
+
else {
|
|
130
|
+
lines.push(`${pad}${key}: ${formatScalar(value)}`);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
/** Encode a JS value to a TOON document (no trailing newline). */
|
|
135
|
+
export function encode(value) {
|
|
136
|
+
const lines = [];
|
|
137
|
+
if (Array.isArray(value)) {
|
|
138
|
+
// Root array: emit with an empty key so the header is a bare `[N]{...}:`.
|
|
139
|
+
emitArray("", value, 0, lines);
|
|
140
|
+
return lines.join("\n");
|
|
141
|
+
}
|
|
142
|
+
if (isPlainObject(value)) {
|
|
143
|
+
emitObject(value, 0, lines);
|
|
144
|
+
return lines.join("\n");
|
|
145
|
+
}
|
|
146
|
+
return formatScalar(value);
|
|
147
|
+
}
|
|
148
|
+
//# sourceMappingURL=toon.js.map
|
|
@@ -0,0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CAAC,KAAK,CAAC,EAAE,CAAC;YACzB,SAAS,CAAC,GAAG,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC;QACtC,CAAC;aAAM,IAAI,aAAa,CAAC,KAAK,CAAC,EAAE,CAAC;YAChC,KAAK,CAAC,IAAI,CAAC,GAAG,GAAG,GAAG,GAAG,GAAG,CAAC,CAAC;YAC5B,UAAU,CAAC,KAAK,EAAE,KAAK,GAAG,CAAC,EAAE,KAAK,CAAC,CAAC;QACtC,CAAC;aAAM,CAAC;YACN,KAAK,CAAC,IAAI,CAAC,GAAG,GAAG,GAAG,GAAG,KAAK,YAAY,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;QACrD,CAAC;IACH,CAAC;AACH,CAAC;AAED,kEAAkE;AAClE,MAAM,UAAU,MAAM,CAAC,KAAc;IACnC,MAAM,KAAK,GAAa,EAAE,CAAC;IAC3B,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QACzB,0EAA0E;QAC1E,SAAS,CAAC,EAAE,EAAE,KAAK,EAAE,CAAC,EAAE,KAAK,CAAC,CAAC;QAC/B,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC1B,CAAC;IACD,IAAI,aAAa,CAAC,KAAK,CAAC,EAAE,CAAC;QACzB,UAAU,CAAC,KAAK,EAAE,CAAC,EAAE,KAAK,CAAC,CAAC;QAC5B,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC1B,CAAC;IACD,OAAO,YAAY,CAAC,KAAK,CAAC,CAAC;AAC7B,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@oasissys/k8s-cli",
|
|
3
|
+
"version": "0.1.2",
|
|
4
|
+
"packageManager": "pnpm@11.9.0",
|
|
5
|
+
"description": "oasis-k8s — AXI CLI for read-only Kubernetes access across the Oasis clusters (token-only, multi-cluster) with token-efficient TOON output",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "https://github.com/oasissys/k8s-cli.git"
|
|
10
|
+
},
|
|
11
|
+
"keywords": [
|
|
12
|
+
"kubernetes",
|
|
13
|
+
"k8s",
|
|
14
|
+
"cli",
|
|
15
|
+
"agent",
|
|
16
|
+
"axi",
|
|
17
|
+
"toon",
|
|
18
|
+
"oasis"
|
|
19
|
+
],
|
|
20
|
+
"bin": {
|
|
21
|
+
"oasis-k8s": "./dist/bin/oasis-k8s.js"
|
|
22
|
+
},
|
|
23
|
+
"files": [
|
|
24
|
+
"dist",
|
|
25
|
+
"skills/k8s-cli",
|
|
26
|
+
"LICENSE",
|
|
27
|
+
"README.md"
|
|
28
|
+
],
|
|
29
|
+
"scripts": {
|
|
30
|
+
"build": "tsc",
|
|
31
|
+
"build:skill": "tsx scripts/build-skill.ts",
|
|
32
|
+
"test": "vitest run",
|
|
33
|
+
"test:watch": "vitest",
|
|
34
|
+
"lint": "eslint .",
|
|
35
|
+
"dev": "tsx bin/oasis-k8s.ts",
|
|
36
|
+
"prepublishOnly": "npm run build"
|
|
37
|
+
},
|
|
38
|
+
"license": "MIT",
|
|
39
|
+
"engines": {
|
|
40
|
+
"node": ">=20"
|
|
41
|
+
},
|
|
42
|
+
"devDependencies": {
|
|
43
|
+
"@eslint/js": "^10.0.1",
|
|
44
|
+
"@types/node": "^22.0.0",
|
|
45
|
+
"eslint": "^10.1.0",
|
|
46
|
+
"globals": "^17.4.0",
|
|
47
|
+
"tsx": "^4.0.0",
|
|
48
|
+
"typescript": "^5.7.0",
|
|
49
|
+
"typescript-eslint": "^8.58.0",
|
|
50
|
+
"vitest": "^3.0.0"
|
|
51
|
+
},
|
|
52
|
+
"publishConfig": {
|
|
53
|
+
"access": "public"
|
|
54
|
+
}
|
|
55
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: k8s-cli
|
|
3
|
+
description: Read-only Kubernetes access across the Oasis clusters from the shell — list namespaces/nodes/pods/deployments/services/events, read pod logs, and describe objects, against multiple clusters selected by name. Use when the user asks about Kubernetes/k8s pods, nodes, deployments, cluster status, pod logs, why a pod is crashing, or the Oasis Jeddah/Jordan clusters.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# oasis-k8s
|
|
7
|
+
|
|
8
|
+
Shell CLI for read-only Kubernetes access to the Oasis clusters. Talks straight to each kube-apiserver with a ServiceAccount token — no kubeconfig, no certs. Add a cluster: `oasis-k8s add <name> --url https://<host>:6443 --token <token>`.
|
|
9
|
+
Invoke as `oasis-k8s` (on PATH after a global install; no install: `npx -y @oasissys/k8s-cli`). TOON output; exit 0/1/2; every command has `--help`.
|
|
10
|
+
|
|
11
|
+
## Multiple clusters
|
|
12
|
+
|
|
13
|
+
Clusters are saved by name (like `oasis-sqlcl` connections), with one
|
|
14
|
+
**active**. Commands run against the active cluster; override per-command
|
|
15
|
+
with `--cluster <name>`. Switch the default with `use <name>`.
|
|
16
|
+
|
|
17
|
+
## Token-only, read-only
|
|
18
|
+
|
|
19
|
+
Every command is a GET — the CLI never mutates cluster state. A scoped
|
|
20
|
+
token may lack RBAC for some resources; those calls report a clear
|
|
21
|
+
`forbidden` error rather than crashing. TLS verification is skipped
|
|
22
|
+
(internal self-signed CAs) — point it only at clusters you control.
|
|
23
|
+
|
|
24
|
+
## Commands
|
|
25
|
+
|
|
26
|
+
| Command | What it does |
|
|
27
|
+
|---|---|
|
|
28
|
+
| `oasis-k8s (no args)` | live view: saved clusters + which is active |
|
|
29
|
+
| `oasis-k8s clusters` | list saved clusters and the active one |
|
|
30
|
+
| `oasis-k8s use <name>` | set the active cluster |
|
|
31
|
+
| `oasis-k8s add <name> --url <apiserver> --token <t>` | register a cluster (verified before saving) |
|
|
32
|
+
| `oasis-k8s rm <name>` | remove a saved cluster |
|
|
33
|
+
| `oasis-k8s namespaces` | list namespaces |
|
|
34
|
+
| `oasis-k8s nodes` | list nodes (status + kubelet version) |
|
|
35
|
+
| `oasis-k8s pods [--namespace <ns>]` | list pods (all namespaces by default) |
|
|
36
|
+
| `oasis-k8s deployments [--namespace <ns>]` | list deployments (ready/available replicas) |
|
|
37
|
+
| `oasis-k8s services [--namespace <ns>]` | list services (type, clusterIP, ports) |
|
|
38
|
+
| `oasis-k8s events [--namespace <ns>]` | list events, newest last |
|
|
39
|
+
| `oasis-k8s logs <pod> --namespace <ns> [--container <c>] [--tail <n>] [--previous]` | print a pod's container logs |
|
|
40
|
+
| `oasis-k8s describe <kind> <name> [--namespace <ns>]` | dump one object as JSON |
|
|
41
|
+
|
|
42
|
+
## Examples
|
|
43
|
+
|
|
44
|
+
```sh
|
|
45
|
+
# Which clusters are configured, and which is active?
|
|
46
|
+
oasis-k8s clusters
|
|
47
|
+
|
|
48
|
+
# Inspect the active cluster
|
|
49
|
+
oasis-k8s pods --namespace default
|
|
50
|
+
oasis-k8s nodes
|
|
51
|
+
|
|
52
|
+
# Why is a pod crashing? tail its logs, then the previous instance
|
|
53
|
+
oasis-k8s logs my-pod --namespace default --tail 80
|
|
54
|
+
oasis-k8s logs my-pod --namespace default --previous
|
|
55
|
+
|
|
56
|
+
# Target a specific cluster without switching the active one
|
|
57
|
+
oasis-k8s deployments --cluster jordan --namespace default
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
## Notes
|
|
61
|
+
- `--cluster <name>` targets one cluster per-command; `use <name>` sets the default.
|
|
62
|
+
- Pod `status` reflects the real container reason (CrashLoopBackOff, ImagePullBackOff, …), not just the phase.
|
|
63
|
+
- A `forbidden` error means the cluster's token lacks RBAC for that resource — try another resource or a broader token.
|