@cvtoolman/huawei-lts-cli 1.0.0 → 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 +112 -111
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,142 +1,149 @@
|
|
|
1
|
-
# huawei-lts-cli
|
|
1
|
+
# huawei-lts-cli — CLI + SKILL
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
**简体中文** | [English](README_en.md)
|
|
4
4
|
|
|
5
|
-
[](https://www.npmjs.com/package/huawei-lts-cli)
|
|
5
|
+
[](https://www.npmjs.com/package/@cvtoolman/huawei-lts-cli)
|
|
6
6
|
[](LICENSE)
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
> 让你的 AI 编程助手(Claude Code、Cursor、Copilot、Qoder 等)通过自然语言查询华为云日志服务(LTS)。
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
- 📋 Multiple output formats: pretty (colored), JSON, table
|
|
12
|
-
- 🚀 Auto-pagination — fetches all matching logs in one command
|
|
13
|
-
- ⚙️ Persistent configuration — set credentials once, use forever
|
|
14
|
-
- 🧙 Interactive setup wizard — `lts-cli init` guides you step by step
|
|
15
|
-
- 🔐 Environment variable support — CI/CD friendly
|
|
16
|
-
- 🐚 Shell completion for bash, zsh, and PowerShell
|
|
10
|
+
**一个工具,两部分:**
|
|
17
11
|
|
|
18
|
-
|
|
12
|
+
| 部分 | 作用 |
|
|
13
|
+
|---|---|
|
|
14
|
+
| **CLI** (`lts-cli`) | 轻量命令行工具,对接华为云 LTS API |
|
|
15
|
+
| **SKILL** (`SKILL.md`) | 一份给 AI 看的"说明书",教它如何把自然语言转成 CLI 命令 |
|
|
16
|
+
|
|
17
|
+
AI 读完 skill 后,你只需说一句"查下今天的 ERROR 日志",AI 就能自动拼出正确的 `lts-cli` 命令并执行。不用记参数,不用手写 ISO 8601 时间格式。
|
|
18
|
+
|
|
19
|
+
## 为什么用 CLI + SKILL 而不是 MCP?
|
|
20
|
+
|
|
21
|
+
AI 编程助手的上下文窗口很宝贵——一边要装代码库、一边要推理、一边还要跑工具。**省 token 就是省时省钱。**
|
|
22
|
+
|
|
23
|
+
| | CLI + SKILL | MCP |
|
|
24
|
+
|---|---|---|
|
|
25
|
+
| **上下文开销** | **低** — skill 就一个短 markdown 文件,CLI 输出是纯文本 | **高** — 工具 schema + 快照数据常驻上下文 |
|
|
26
|
+
| **AI 使用方式** | 执行 shell 命令,读取结果 | 通过协议调用结构化工具 |
|
|
27
|
+
| **配置难度** | `npm install -g`、一个 skill 文件 | 服务进程、配置连线 |
|
|
28
|
+
| **适用场景** | 编码过程中顺手查日志 | 长时间运行的自动化循环 |
|
|
29
|
+
|
|
30
|
+
> **一句话:** 如果你想让 AI 在写代码时顺嘴帮你查日志——CLI + SKILL 是更轻、更省钱的方案。
|
|
31
|
+
|
|
32
|
+
## 快速开始
|
|
19
33
|
|
|
20
|
-
### 1.
|
|
34
|
+
### 1. 安装 CLI
|
|
21
35
|
|
|
22
36
|
```bash
|
|
23
|
-
npm install -g huawei-lts-cli
|
|
37
|
+
npm install -g @cvtoolman/huawei-lts-cli
|
|
24
38
|
```
|
|
25
39
|
|
|
26
|
-
### 2.
|
|
40
|
+
### 2. 配置凭证
|
|
27
41
|
|
|
28
42
|
```bash
|
|
29
43
|
lts-cli init
|
|
30
44
|
```
|
|
31
45
|
|
|
32
|
-
|
|
46
|
+
向导会依次询问 AK、SK、Project ID、Region,一次配好。配置存储在 `~/.lts-cli/config.json`。
|
|
33
47
|
|
|
34
|
-
|
|
48
|
+
### 3. 安装 Skill(给 AI 工具用)
|
|
35
49
|
|
|
50
|
+
**Claude Code:**
|
|
36
51
|
```bash
|
|
37
|
-
lts-
|
|
38
|
-
lts-
|
|
39
|
-
lts-cli
|
|
40
|
-
lts-cli config --set region=cn-south-1
|
|
41
|
-
lts-cli config --set endpoint=https://lts.cn-south-1.myhuaweicloud.com
|
|
42
|
-
lts-cli config --set groupId=YOUR_LOG_GROUP_ID # optional — default
|
|
43
|
-
lts-cli config --set streamId=YOUR_LOG_STREAM_ID # optional — default
|
|
52
|
+
mkdir -p .claude/skills/huawei-lts-log-query
|
|
53
|
+
curl -o .claude/skills/huawei-lts-log-query/SKILL.md \
|
|
54
|
+
https://raw.githubusercontent.com/jcxy/huawei-lts-cli/main/skills/huawei-lts-log-query/SKILL.md
|
|
44
55
|
```
|
|
45
56
|
|
|
46
|
-
|
|
57
|
+
**Qoder:**
|
|
58
|
+
```bash
|
|
59
|
+
mkdir -p .qoder/skills/huawei-lts-log-query
|
|
60
|
+
curl -o .qoder/skills/huawei-lts-log-query/SKILL.md \
|
|
61
|
+
https://raw.githubusercontent.com/jcxy/huawei-lts-cli/main/skills/huawei-lts-log-query/SKILL.md
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
**手动安装(任意 AI 工具):** 将 [skills/huawei-lts-log-query/SKILL.md](skills/huawei-lts-log-query/SKILL.md) 复制到对应 AI 工具的 skills 目录下(`.claude/skills/`、`.qoder/skills/`、`.cursor/skills/` 等)。
|
|
65
|
+
|
|
66
|
+
### 4. 命令行直接使用(不依赖 AI)
|
|
47
67
|
|
|
48
68
|
```bash
|
|
49
|
-
#
|
|
69
|
+
# 基础查询
|
|
50
70
|
lts-cli query --st 2024-01-01T00:00:00Z --et 2024-01-02T00:00:00Z
|
|
51
71
|
|
|
52
|
-
#
|
|
72
|
+
# 关键词搜索
|
|
53
73
|
lts-cli query --st 2024-01-01T00:00:00Z --et 2024-01-02T00:00:00Z -k "ERROR"
|
|
54
74
|
|
|
55
|
-
#
|
|
56
|
-
lts-cli query
|
|
57
|
-
|
|
58
|
-
# JSON output (useful for piping to jq)
|
|
59
|
-
lts-cli query --st 2024-01-01T00:00:00Z --et 2024-01-02T00:00:00Z -f json
|
|
60
|
-
|
|
61
|
-
# Table output
|
|
62
|
-
lts-cli query --st 2024-01-01T00:00:00Z --et 2024-01-02T00:00:00Z -f table
|
|
75
|
+
# JSON 格式输出,管道给 jq 处理
|
|
76
|
+
lts-cli query --st 2024-01-01T00:00:00Z --et 2024-01-02T00:00:00Z -f json | jq .
|
|
63
77
|
```
|
|
64
78
|
|
|
65
|
-
##
|
|
79
|
+
## 命令参考
|
|
66
80
|
|
|
67
|
-
### `lts-cli query` —
|
|
81
|
+
### `lts-cli query` — 查询日志
|
|
68
82
|
|
|
69
83
|
```
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
-g, --group-id <groupId>
|
|
74
|
-
-s, --stream-id <streamId>
|
|
75
|
-
--start-time, --st <time>
|
|
76
|
-
--end-time, --et <time>
|
|
77
|
-
-k, --keyword <keyword>
|
|
78
|
-
-l, --limit <limit>
|
|
79
|
-
-o, --offset <offset>
|
|
80
|
-
-r, --reverse
|
|
81
|
-
-f, --format <format>
|
|
82
|
-
--no-paginate
|
|
84
|
+
lts-cli query [选项]
|
|
85
|
+
|
|
86
|
+
选项:
|
|
87
|
+
-g, --group-id <groupId> 日志组 ID(可在配置中预设)
|
|
88
|
+
-s, --stream-id <streamId> 日志流 ID(可在配置中预设)
|
|
89
|
+
--start-time, --st <time> 开始时间,ISO 8601 格式(必填)
|
|
90
|
+
--end-time, --et <time> 结束时间,ISO 8601 格式(必填)
|
|
91
|
+
-k, --keyword <keyword> 搜索关键词
|
|
92
|
+
-l, --limit <limit> 每页条数(默认: 100)
|
|
93
|
+
-o, --offset <offset> 分页偏移量(默认: 0)
|
|
94
|
+
-r, --reverse 按时间倒序
|
|
95
|
+
-f, --format <format> 输出格式: pretty、json、table(默认: pretty)
|
|
96
|
+
--no-paginate 关闭自动翻页
|
|
83
97
|
```
|
|
84
98
|
|
|
85
|
-
### `lts-cli config` —
|
|
99
|
+
### `lts-cli config` — 管理配置
|
|
86
100
|
|
|
87
101
|
```
|
|
88
|
-
|
|
102
|
+
lts-cli config [选项]
|
|
89
103
|
|
|
90
|
-
|
|
91
|
-
--set <key=value>
|
|
92
|
-
--get <key>
|
|
93
|
-
--list
|
|
94
|
-
--unset <key>
|
|
104
|
+
选项:
|
|
105
|
+
--set <key=value> 设置配置项
|
|
106
|
+
--get <key> 查看配置项
|
|
107
|
+
--list 列出所有配置
|
|
108
|
+
--unset <key> 删除配置项
|
|
95
109
|
```
|
|
96
110
|
|
|
97
|
-
### `lts-cli init` —
|
|
111
|
+
### `lts-cli init` — 配置向导
|
|
98
112
|
|
|
99
113
|
```
|
|
100
|
-
|
|
114
|
+
lts-cli init
|
|
101
115
|
|
|
102
|
-
|
|
103
|
-
|
|
116
|
+
交互式向导,引导设置 AK、SK、Project ID、Region、endpoint,
|
|
117
|
+
以及可选的默认日志组和日志流。
|
|
104
118
|
```
|
|
105
119
|
|
|
106
|
-
### `lts-cli completion` — Shell
|
|
120
|
+
### `lts-cli completion` — Shell 补全
|
|
107
121
|
|
|
108
122
|
```
|
|
109
|
-
|
|
123
|
+
lts-cli completion <bash|zsh|powershell>
|
|
110
124
|
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
Examples:
|
|
114
|
-
lts-cli completion bash >> ~/.bashrc
|
|
115
|
-
lts-cli completion zsh >> ~/.zshrc
|
|
116
|
-
lts-cli completion powershell >> $PROFILE
|
|
125
|
+
生成 shell 补全脚本。
|
|
117
126
|
```
|
|
118
127
|
|
|
119
|
-
##
|
|
120
|
-
|
|
121
|
-
Configuration is stored in `~/.lts-cli/config.json` (Linux/macOS) or `%USERPROFILE%\.lts-cli\config.json` (Windows).
|
|
128
|
+
## 配置说明
|
|
122
129
|
|
|
123
|
-
|
|
130
|
+
配置存储在 `~/.lts-cli/config.json`(Linux/macOS)或 `%USERPROFILE%\.lts-cli\config.json`(Windows)。
|
|
124
131
|
|
|
125
|
-
|
|
|
132
|
+
| 键 | 必填 | 说明 |
|
|
126
133
|
|---|---|---|
|
|
127
|
-
| `ak` |
|
|
128
|
-
| `sk` |
|
|
129
|
-
| `projectId` |
|
|
130
|
-
| `region` |
|
|
131
|
-
| `endpoint` |
|
|
132
|
-
| `groupId` |
|
|
133
|
-
| `streamId` |
|
|
134
|
+
| `ak` | 是 | 华为云访问密钥 |
|
|
135
|
+
| `sk` | 是 | 华为云私有密钥 |
|
|
136
|
+
| `projectId` | 是 | 项目 ID |
|
|
137
|
+
| `region` | 否 | 如 `cn-south-1` |
|
|
138
|
+
| `endpoint` | 否 | 需包含 `https://` |
|
|
139
|
+
| `groupId` | 否 | 默认日志组 ID |
|
|
140
|
+
| `streamId` | 否 | 默认日志流 ID |
|
|
134
141
|
|
|
135
|
-
###
|
|
142
|
+
### 环境变量
|
|
136
143
|
|
|
137
|
-
|
|
144
|
+
所有配置项也支持环境变量(适用于 CI/CD):
|
|
138
145
|
|
|
139
|
-
|
|
|
146
|
+
| 配置键 | 环境变量 |
|
|
140
147
|
|---|---|
|
|
141
148
|
| `ak` | `LTS_AK` |
|
|
142
149
|
| `sk` | `LTS_SK` |
|
|
@@ -146,44 +153,38 @@ All config keys can also be set via environment variables (useful for CI/CD):
|
|
|
146
153
|
| `groupId` | `LTS_GROUP_ID` |
|
|
147
154
|
| `streamId` | `LTS_STREAM_ID` |
|
|
148
155
|
|
|
149
|
-
|
|
156
|
+
环境变量优先级高于配置文件。
|
|
150
157
|
|
|
151
|
-
##
|
|
158
|
+
## 支持的区域
|
|
152
159
|
|
|
153
|
-
|
|
|
160
|
+
| 区域 ID | 区域名称 | Endpoint |
|
|
154
161
|
|---|---|---|
|
|
155
|
-
| `cn-north-1` |
|
|
156
|
-
| `cn-north-4` |
|
|
157
|
-
| `cn-east-2` |
|
|
158
|
-
| `cn-east-3` |
|
|
159
|
-
| `cn-south-1` |
|
|
160
|
-
| `cn-south-4` |
|
|
161
|
-
| `cn-southwest-2` |
|
|
162
|
-
| `ap-southeast-1` |
|
|
163
|
-
| `ap-southeast-2` |
|
|
164
|
-
| `ap-southeast-3` |
|
|
165
|
-
| `af-south-1` |
|
|
166
|
-
|
|
167
|
-
>
|
|
168
|
-
|
|
169
|
-
##
|
|
162
|
+
| `cn-north-1` | 华北-北京一 | `lts.cn-north-1.myhuaweicloud.com` |
|
|
163
|
+
| `cn-north-4` | 华北-北京四 | `lts.cn-north-4.myhuaweicloud.com` |
|
|
164
|
+
| `cn-east-2` | 华东-上海二 | `lts.cn-east-2.myhuaweicloud.com` |
|
|
165
|
+
| `cn-east-3` | 华东-上海三 | `lts.cn-east-3.myhuaweicloud.com` |
|
|
166
|
+
| `cn-south-1` | 华南-广州 | `lts.cn-south-1.myhuaweicloud.com` |
|
|
167
|
+
| `cn-south-4` | 华南-深圳 | `lts.cn-south-4.myhuaweicloud.com` |
|
|
168
|
+
| `cn-southwest-2` | 西南-贵阳一 | `lts.cn-southwest-2.myhuaweicloud.com` |
|
|
169
|
+
| `ap-southeast-1` | 亚太-新加坡 | `lts.ap-southeast-1.myhuaweicloud.com` |
|
|
170
|
+
| `ap-southeast-2` | 亚太-曼谷 | `lts.ap-southeast-2.myhuaweicloud.com` |
|
|
171
|
+
| `ap-southeast-3` | 亚太-雅加达 | `lts.ap-southeast-3.myhuaweicloud.com` |
|
|
172
|
+
| `af-south-1` | 非洲-约翰内斯堡 | `lts.af-south-1.myhuaweicloud.com` |
|
|
173
|
+
|
|
174
|
+
> 完整列表请参考 [华为云 LTS 终端节点](https://support.huaweicloud.com/api-lts/lts_api_0011.html)。
|
|
175
|
+
|
|
176
|
+
## 开发指南
|
|
170
177
|
|
|
171
178
|
```bash
|
|
172
|
-
|
|
173
|
-
git clone <repo-url>
|
|
179
|
+
git clone https://github.com/jcxy/huawei-lts-cli.git
|
|
174
180
|
cd huawei-lts-cli
|
|
175
181
|
npm install
|
|
176
|
-
|
|
177
|
-
# Build
|
|
178
182
|
npm run build
|
|
179
183
|
|
|
180
|
-
#
|
|
184
|
+
# 开发模式运行(无需编译)
|
|
181
185
|
npm run dev -- query --st 2024-01-01T00:00:00Z --et 2024-01-02T00:00:00Z
|
|
182
186
|
|
|
183
|
-
#
|
|
184
|
-
npm start -- query --st 2024-01-01T00:00:00Z --et 2024-01-02T00:00:00Z
|
|
185
|
-
|
|
186
|
-
# Link for local testing
|
|
187
|
+
# 本地测试
|
|
187
188
|
npm link
|
|
188
189
|
lts-cli query --st 2024-01-01T00:00:00Z --et 2024-01-02T00:00:00Z
|
|
189
190
|
```
|