@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 CHANGED
@@ -1,139 +1,62 @@
1
- # Cubectl
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
- - 🤖 **自然语言交互**:直接询问 "有哪些 pods 正在运行?" "帮我查一下 default 命名空间的 service"。
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
- 这是一个使用 npm workspaces 管理的 monorepo:
9
+ ## Key Features
19
10
 
20
- ```
21
- cubectl/
22
- ├── packages/
23
- │ ├── core/ # 核心库:包含 AI Agent 逻辑、动态 K8s 客户端和工具定义
24
- │ └── cli/ # CLI 应用:Ink UI 组件和命令行入口
25
- ├── scripts/ # 构建和辅助脚本
26
- ├── .env.example # 环境变量模板
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 (必须,因为依赖使用了正则表达式 `v` 标志)
35
- - **npm**: >= 10.0.0
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
- npm install
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
- npm install -g @zhizuqiu/cubectl
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
- - `-d, --debug`: 启用调试模式
127
- - `-c, --context <context>`: 指定 Kubernetes 上下文
128
- - `-n, --namespace <namespace>`: 指定命名空间 (默认为 default)
129
- - `-ae, --auto-execute`: 开启自动执行模式 (实验性)
130
- - `-h, --help`: 显示帮助信息
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
- 详见 **[DEVELOPER.md](./DEVELOPER.md)**。
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)