@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.
Files changed (2) hide show
  1. package/README.md +112 -111
  2. 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
- Command-line tool for querying [Huawei Cloud Log Tank Service (LTS)](https://www.huaweicloud.com/intl/en-us/product/lts.html) logs from the terminal.
3
+ **简体中文** | [English](README_en.md)
4
4
 
5
- [![npm version](https://img.shields.io/npm/v/huawei-lts-cli.svg)](https://www.npmjs.com/package/huawei-lts-cli)
5
+ [![npm version](https://img.shields.io/npm/v/@cvtoolman/huawei-lts-cli.svg)](https://www.npmjs.com/package/@cvtoolman/huawei-lts-cli)
6
6
  [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)
7
7
 
8
- ## Features
8
+ > 让你的 AI 编程助手(Claude Code、Cursor、Copilot、Qoder 等)通过自然语言查询华为云日志服务(LTS)。
9
9
 
10
- - 🔍 Query LTS logs by time range, keyword, and more
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
- ## Quick Start
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. Install
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. Configure
40
+ ### 2. 配置凭证
27
41
 
28
42
  ```bash
29
43
  lts-cli init
30
44
  ```
31
45
 
32
- The wizard will ask for your AK, SK, Project ID, and Region. You can find your credentials in the Huawei Cloud console under **My Credentials > Access Keys**.
46
+ 向导会依次询问 AK、SK、Project ID、Region,一次配好。配置存储在 `~/.lts-cli/config.json`。
33
47
 
34
- Or set manually:
48
+ ### 3. 安装 Skill(给 AI 工具用)
35
49
 
50
+ **Claude Code:**
36
51
  ```bash
37
- lts-cli config --set ak=YOUR_ACCESS_KEY
38
- lts-cli config --set sk=YOUR_SECRET_KEY
39
- lts-cli config --set projectId=YOUR_PROJECT_ID
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
- ### 3. Query
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
- # Basic query
69
+ # 基础查询
50
70
  lts-cli query --st 2024-01-01T00:00:00Z --et 2024-01-02T00:00:00Z
51
71
 
52
- # With keyword filter
72
+ # 关键词搜索
53
73
  lts-cli query --st 2024-01-01T00:00:00Z --et 2024-01-02T00:00:00Z -k "ERROR"
54
74
 
55
- # With explicit group/stream (overrides config defaults)
56
- lts-cli query -g <group-id> -s <stream-id> --st 2024-01-01T00:00:00Z --et 2024-01-02T00:00:00Z
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
- ## Command Reference
79
+ ## 命令参考
66
80
 
67
- ### `lts-cli query` — Query Logs
81
+ ### `lts-cli query` — 查询日志
68
82
 
69
83
  ```
70
- Usage: lts-cli query [options]
71
-
72
- Options:
73
- -g, --group-id <groupId> Log group ID (can be set in config)
74
- -s, --stream-id <streamId> Log stream ID (can be set in config)
75
- --start-time, --st <time> Start time in ISO 8601 (required)
76
- --end-time, --et <time> End time in ISO 8601 (required)
77
- -k, --keyword <keyword> Search keyword
78
- -l, --limit <limit> Results per page (default: 100)
79
- -o, --offset <offset> Pagination offset (default: 0)
80
- -r, --reverse Show newest logs first
81
- -f, --format <format> Output format: pretty, json, table (default: pretty)
82
- --no-paginate Disable auto-pagination (single page only)
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` — Manage Configuration
99
+ ### `lts-cli config` — 管理配置
86
100
 
87
101
  ```
88
- Usage: lts-cli config [options]
102
+ lts-cli config [选项]
89
103
 
90
- Options:
91
- --set <key=value> Set a configuration value
92
- --get <key> Get a configuration value
93
- --list List all configuration values
94
- --unset <key> Remove a configuration value
104
+ 选项:
105
+ --set <key=value> 设置配置项
106
+ --get <key> 查看配置项
107
+ --list 列出所有配置
108
+ --unset <key> 删除配置项
95
109
  ```
96
110
 
97
- ### `lts-cli init` — Setup Wizard
111
+ ### `lts-cli init` — 配置向导
98
112
 
99
113
  ```
100
- Usage: lts-cli init
114
+ lts-cli init
101
115
 
102
- Interactive wizard that guides you through setting up AK, SK, Project ID,
103
- region, endpoint, and optional default log group/stream.
116
+ 交互式向导,引导设置 AK、SK、Project ID、Region、endpoint,
117
+ 以及可选的默认日志组和日志流。
104
118
  ```
105
119
 
106
- ### `lts-cli completion` — Shell Completion
120
+ ### `lts-cli completion` — Shell 补全
107
121
 
108
122
  ```
109
- Usage: lts-cli completion <shell>
123
+ lts-cli completion <bash|zsh|powershell>
110
124
 
111
- Generate completion script for bash, zsh, or powershell.
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
- ## Configuration
120
-
121
- Configuration is stored in `~/.lts-cli/config.json` (Linux/macOS) or `%USERPROFILE%\.lts-cli\config.json` (Windows).
128
+ ## 配置说明
122
129
 
123
- ### Available Keys
130
+ 配置存储在 `~/.lts-cli/config.json`(Linux/macOS)或 `%USERPROFILE%\.lts-cli\config.json`(Windows)。
124
131
 
125
- | Key | Required | Description |
132
+ | 键 | 必填 | 说明 |
126
133
  |---|---|---|
127
- | `ak` | Yes | Huawei Cloud Access Key |
128
- | `sk` | Yes | Huawei Cloud Secret Key |
129
- | `projectId` | Yes | Huawei Cloud Project ID |
130
- | `region` | No | Region (e.g. `cn-south-1`) |
131
- | `endpoint` | No | LTS service endpoint. Must include `https://` |
132
- | `groupId` | No | Default log group ID |
133
- | `streamId` | No | Default log stream ID |
134
+ | `ak` | 是 | 华为云访问密钥 |
135
+ | `sk` | 是 | 华为云私有密钥 |
136
+ | `projectId` | 是 | 项目 ID |
137
+ | `region` | 否 | 如 `cn-south-1` |
138
+ | `endpoint` | 否 | 需包含 `https://` |
139
+ | `groupId` | 否 | 默认日志组 ID |
140
+ | `streamId` | 否 | 默认日志流 ID |
134
141
 
135
- ### Environment Variables
142
+ ### 环境变量
136
143
 
137
- All config keys can also be set via environment variables (useful for CI/CD):
144
+ 所有配置项也支持环境变量(适用于 CI/CD):
138
145
 
139
- | Config Key | Environment Variable |
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
- Environment variables take precedence over config file values.
156
+ 环境变量优先级高于配置文件。
150
157
 
151
- ## Supported Regions
158
+ ## 支持的区域
152
159
 
153
- | Region ID | Region Name | Endpoint |
160
+ | 区域 ID | 区域名称 | Endpoint |
154
161
  |---|---|---|
155
- | `cn-north-1` | CN North-Beijing1 | `lts.cn-north-1.myhuaweicloud.com` |
156
- | `cn-north-4` | CN North-Beijing4 | `lts.cn-north-4.myhuaweicloud.com` |
157
- | `cn-east-2` | CN East-Shanghai2 | `lts.cn-east-2.myhuaweicloud.com` |
158
- | `cn-east-3` | CN East-Shanghai3 | `lts.cn-east-3.myhuaweicloud.com` |
159
- | `cn-south-1` | CN South-Guangzhou | `lts.cn-south-1.myhuaweicloud.com` |
160
- | `cn-south-4` | CN South-Shenzhen | `lts.cn-south-4.myhuaweicloud.com` |
161
- | `cn-southwest-2` | CN Southwest-Guiyang | `lts.cn-southwest-2.myhuaweicloud.com` |
162
- | `ap-southeast-1` | AP-Singapore | `lts.ap-southeast-1.myhuaweicloud.com` |
163
- | `ap-southeast-2` | AP-Bangkok | `lts.ap-southeast-2.myhuaweicloud.com` |
164
- | `ap-southeast-3` | AP-Jakarta | `lts.ap-southeast-3.myhuaweicloud.com` |
165
- | `af-south-1` | AF-Johannesburg | `lts.af-south-1.myhuaweicloud.com` |
166
-
167
- > For a complete list, see [Huawei Cloud LTS Endpoints](https://support.huaweicloud.com/intl/en-us/api-lts/lts_api_0011.html).
168
-
169
- ## Development
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
- # Clone and install
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
- # Run during development (no build step needed)
184
+ # 开发模式运行(无需编译)
181
185
  npm run dev -- query --st 2024-01-01T00:00:00Z --et 2024-01-02T00:00:00Z
182
186
 
183
- # Run compiled version
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
  ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cvtoolman/huawei-lts-cli",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "Command-line tool for querying Huawei Cloud Log Tank Service (LTS) logs",
5
5
  "main": "dist/cli/index.js",
6
6
  "bin": {