@zhizuqiu/cubectl 0.1.3 → 1.0.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 +37 -114
- package/dist/.tsbuildinfo +1 -1
- package/dist/core/ai/agent.d.ts +3 -2
- package/dist/core/ai/agent.js +23 -4
- package/dist/core/ai/agent.js.map +1 -1
- package/dist/core/ai/tools.d.ts +7 -0
- package/dist/core/ai/tools.js +41 -14
- package/dist/core/ai/tools.js.map +1 -1
- package/dist/core/index.js.map +1 -1
- package/dist/core/kubernetes/client.d.ts +2 -2
- package/dist/core/kubernetes/client.js +191 -67
- package/dist/core/kubernetes/client.js.map +1 -1
- package/dist/core/session/session.js +3 -1
- package/dist/core/session/session.js.map +1 -1
- package/dist/cubectl.js +15 -5
- package/dist/cubectl.js.map +1 -1
- package/dist/debug-multiturn.d.ts +1 -0
- package/dist/debug-multiturn.js.map +1 -0
- package/dist/debug-official.d.ts +1 -0
- package/dist/debug-official.js.map +1 -0
- package/dist/debug-stream.d.ts +1 -0
- package/dist/debug-stream.js.map +1 -0
- package/dist/i18n.js +36 -2
- package/dist/i18n.js.map +1 -1
- package/dist/index.js +9 -0
- package/dist/index.js.map +1 -1
- package/dist/ui/AppContainer.js +488 -197
- package/dist/ui/AppContainer.js.map +1 -1
- package/dist/ui/MessageComponent.js +32 -14
- package/dist/ui/MessageComponent.js.map +1 -1
- package/dist/ui/input/key-parser.js.map +1 -1
- package/dist/ui/types.d.ts +79 -8
- package/dist/ui/types.js +19 -1
- package/dist/ui/types.js.map +1 -1
- package/package.json +64 -61
package/README.md
CHANGED
|
@@ -1,139 +1,62 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
🚀 **Cubectl** 是一个基于 AI 驱动的 Kubernetes 运维助手终端工具,使用 [Ink](https://github.com/vadimdemedes/ink) 构建。
|
|
4
|
-
|
|
5
|
-
用户可以通过自然语言与 Kubernetes 集群进行交互,无需记忆复杂的 `kubectl` 命令。它支持自动执行工具调用来查询资源,并提供实时的流式 AI 响应。
|
|
1
|
+
English | [中文](./docs/manual/README.zh-CN.md)
|
|
6
2
|
|
|
7
|
-
|
|
3
|
+
# Cubectl
|
|
8
4
|
|
|
9
|
-
-
|
|
10
|
-
- 📡 **流式响应**:实时展示 AI 的思考过程和输出结果,类似于 ChatGPT 的打字机体验。
|
|
11
|
-
- 🔧 **动态资源发现**:基于 `unstructured` 对象的动态 Kubernetes 客户端,支持几乎所有 K8s 资源类型(Pods, Deployments, Services, CRDs 等)。
|
|
12
|
-
- 💻 **终端原生 UI**:利用 React 和 Ink 构建,支持原生终端滚动、彩色高亮和加载动画。
|
|
13
|
-
- 🌏 **中英双语**:内置 i18n 支持,根据系统自动适配或手动配置。
|
|
14
|
-
- 🔍 **一键摘要**:快速获取命名空间的资源概览统计。
|
|
5
|
+
🚀 **Cubectl** is a state-of-the-art AI-powered Kubernetes operations assistant terminal tool built with [Ink](https://github.com/vadimdemedes/ink) and [LangChain](https://github.com/langchain-ai/langchainjs).
|
|
15
6
|
|
|
16
|
-
|
|
7
|
+
Interact with your Kubernetes clusters using natural language. No more memorizing complex `kubectl` flags—just ask and let the AI handle the heavy lifting with full Human-in-the-Loop safety.
|
|
17
8
|
|
|
18
|
-
|
|
9
|
+
## ✨ Key Features
|
|
19
10
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
└── package.json # 根工作区配置
|
|
28
|
-
```
|
|
11
|
+
- 🤖 **Natural Language Intelligence**: Query resources ("How many nodes are ready?") or modify them ("Scale my deployment to 3 replicas") with ease.
|
|
12
|
+
- 📡 **Robust Streaming UI**: Experience real-time AI reasoning and output with a premium, flick-free terminal interface.
|
|
13
|
+
- 🛡️ **Human-in-the-Loop (HITL)**: Safety first. Sensitive operations (create, patch, delete) require explicit user approval.
|
|
14
|
+
- ⚡ **Autonomous Mode**: Switch to "Auto-execute" with `Ctrl+A` for the AI to perform operations without interruptions (best for trusted environments).
|
|
15
|
+
- 🧩 **Deep Type Safety**: Built with strict TypeScript and aligned with official LangChain/LangGraph schemas for maximum reliability.
|
|
16
|
+
- ⌨️ **Input Stability**: Custom keyboard parser ensures no character loss, even during high-frequency streaming.
|
|
17
|
+
- 🔍 **Dynamic Resource Discovery**: Supports standard resources and CRDs via dynamic Kubernetes client resolution.
|
|
29
18
|
|
|
30
|
-
##
|
|
19
|
+
## 🚀 Quick Start
|
|
31
20
|
|
|
32
|
-
###
|
|
21
|
+
### Prerequisites
|
|
33
22
|
|
|
34
|
-
- **Node.js**: >= 20.0.0
|
|
35
|
-
- **
|
|
36
|
-
- **Kubernetes**: 具有有效的 `~/.kube/config` 配置
|
|
23
|
+
- **Node.js**: >= 20.0.0
|
|
24
|
+
- **Kubernetes**: A valid `~/.kube/config`
|
|
37
25
|
|
|
38
|
-
###
|
|
26
|
+
### Global Installation
|
|
39
27
|
|
|
40
28
|
```bash
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
# 配置环境变量 (详见下文 环境变量 章节)
|
|
45
|
-
cp .env.example .env
|
|
46
|
-
|
|
47
|
-
# 构建项目
|
|
48
|
-
npm run build
|
|
29
|
+
npm install -g @zhizuqiu/cubectl@latest
|
|
30
|
+
cubectl
|
|
49
31
|
```
|
|
50
32
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
在项目根目录下创建一个 `.env` 文件,或参考 `.env.example` 进行配置。
|
|
54
|
-
|
|
55
|
-
| 变量名 | 必填 | 描述 | 默认值 |
|
|
56
|
-
| :--- | :--- | :--- | :--- |
|
|
57
|
-
| `OPENAI_API_KEY` | 是 | 您的 AI 模型 API Key | - |
|
|
58
|
-
| `OPENAI_API_MODEL` | 否 | 使用的模型名称 | `gpt-4o` |
|
|
59
|
-
| `OPENAI_BASE_URL` | 否 | API 请求的基础 URL| `https://api.openai.com/v1` |
|
|
60
|
-
| `KUBECONFIG` | 否 | Kubernetes 配置文件路径 | `~/.kube/config` |
|
|
61
|
-
|
|
62
|
-
> [!TIP]
|
|
63
|
-
> 如果您使用的是非 OpenAI 的兼容接口(如通义千问、DeepSeek 等),请务必正确设置 `OPENAI_BASE_URL`。
|
|
64
|
-
|
|
65
|
-
### NPM 全局安装 (推荐)
|
|
66
|
-
|
|
67
|
-
您可以直接从 NPM 仓库安装 `cubectl` 并全局运行:
|
|
33
|
+
### Local Development
|
|
68
34
|
|
|
69
35
|
```bash
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
# 直接使用
|
|
74
|
-
cubectl "列出 pods"
|
|
75
|
-
```
|
|
76
|
-
|
|
77
|
-
### 源码安装(开发调试)
|
|
78
|
-
|
|
79
|
-
如果您想在本地开发或调试:
|
|
80
|
-
|
|
81
|
-
```bash
|
|
82
|
-
# 1. 克隆并安装依赖
|
|
36
|
+
git clone https://github.com/zhizuqiu/cubectl.git
|
|
37
|
+
cd cubectl/cubectl
|
|
83
38
|
npm install
|
|
84
|
-
|
|
85
|
-
# 2. 构建项目
|
|
86
39
|
npm run build
|
|
87
|
-
|
|
88
|
-
# 3. 链接到全局
|
|
89
|
-
cd packages/cli
|
|
90
|
-
sudo npm link
|
|
91
|
-
|
|
92
|
-
# 现在可以使用 cubectl 命令了
|
|
93
|
-
cubectl "列出 pods"
|
|
94
|
-
```
|
|
95
|
-
|
|
96
|
-
### 如何发布到 NPM
|
|
97
|
-
|
|
98
|
-
如果您是项目维护者,可以按照以下步骤发布新版本:
|
|
99
|
-
|
|
100
|
-
```bash
|
|
101
|
-
# 1. 确保已登录 npm
|
|
102
|
-
npm login
|
|
103
|
-
|
|
104
|
-
# 2. 构建所有 workspace
|
|
105
|
-
npm run build
|
|
106
|
-
|
|
107
|
-
# 3. 发布 cli 包
|
|
108
|
-
npm publish --access public
|
|
109
|
-
```
|
|
110
|
-
|
|
111
|
-
### 运行
|
|
112
|
-
|
|
113
|
-
```bash
|
|
114
|
-
# 启动交互式终端
|
|
115
40
|
npm start
|
|
116
|
-
|
|
117
|
-
# 直接执行查询
|
|
118
|
-
npm start "显示所有运行中的 pods"
|
|
119
|
-
|
|
120
|
-
# 启用调试模式
|
|
121
|
-
npm start -- --debug
|
|
122
41
|
```
|
|
123
42
|
|
|
124
|
-
##
|
|
43
|
+
## ⚙️ Configuration
|
|
44
|
+
|
|
45
|
+
Cubectl supports environment variables via `.env` files (Project root or `~/.cubectl/.env`).
|
|
125
46
|
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
-
|
|
130
|
-
|
|
131
|
-
- `--version`: 显示版本号
|
|
47
|
+
| Variable | Required | Description | Default |
|
|
48
|
+
| :----------------- | :------- | :---------------------------------- | :-------------------------- |
|
|
49
|
+
| `OPENAI_API_KEY` | **Yes** | AI model API Key | - |
|
|
50
|
+
| `OPENAI_API_MODEL` | No | Model name (e.g., qwen-max, gpt-4o) | `gpt-4o` |
|
|
51
|
+
| `OPENAI_BASE_URL` | No | Custom provider endpoint | `https://api.openai.com/v1` |
|
|
132
52
|
|
|
133
|
-
##
|
|
53
|
+
## 🕹️ Controls
|
|
134
54
|
|
|
135
|
-
|
|
55
|
+
- **Enter**: Send message
|
|
56
|
+
- **Ctrl+A**: Toggle Autonomous Mode (Auto-execute)
|
|
57
|
+
- **Arrow Up/Down**: Command history
|
|
58
|
+
- **Ctrl+C**: Exit
|
|
136
59
|
|
|
137
|
-
##
|
|
60
|
+
## 📄 License
|
|
138
61
|
|
|
139
|
-
MIT
|
|
62
|
+
MIT © [zhizuqiu](https://github.com/zhizuqiu)
|