@kriston-ai/kst-im-cli 0.0.8
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-workbuddy-install.md +48 -0
- package/README.md +109 -0
- package/dist/index.js +225 -0
- package/package.json +51 -0
- package/skills/kst-im-cli/SKILL.md +425 -0
package/package.json
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@kriston-ai/kst-im-cli",
|
|
3
|
+
"version": "0.0.8",
|
|
4
|
+
"publishConfig": {
|
|
5
|
+
"access": "public"
|
|
6
|
+
},
|
|
7
|
+
"description": "KST IM CLI 工具",
|
|
8
|
+
"type": "module",
|
|
9
|
+
"bin": {
|
|
10
|
+
"kst-im-cli": "dist/index.js"
|
|
11
|
+
},
|
|
12
|
+
"files": [
|
|
13
|
+
"dist/",
|
|
14
|
+
"skills/",
|
|
15
|
+
"README-workbuddy-install.md"
|
|
16
|
+
],
|
|
17
|
+
"scripts": {
|
|
18
|
+
"release": "npm run build && npm pack",
|
|
19
|
+
"build": "tsx scripts/build.ts",
|
|
20
|
+
"dev": "tsx src/index.ts",
|
|
21
|
+
"typecheck": "tsc --noEmit",
|
|
22
|
+
"test": "vitest run",
|
|
23
|
+
"test:watch": "vitest",
|
|
24
|
+
"lint": "eslint src && prettier --check src",
|
|
25
|
+
"format": "prettier --write src && eslint --fix src",
|
|
26
|
+
"prepublishOnly": "npm run lint && npm run typecheck && npm run test && npm run build"
|
|
27
|
+
},
|
|
28
|
+
"engines": {
|
|
29
|
+
"node": ">=18"
|
|
30
|
+
},
|
|
31
|
+
"dependencies": {},
|
|
32
|
+
"devDependencies": {
|
|
33
|
+
"@clack/prompts": "0.9.1",
|
|
34
|
+
"@types/node": "22.10.2",
|
|
35
|
+
"@types/update-notifier": "6.0.8",
|
|
36
|
+
"axios": "1.7.9",
|
|
37
|
+
"cli-table3": "0.6.5",
|
|
38
|
+
"commander": "12.1.0",
|
|
39
|
+
"dayjs": "^1.11.20",
|
|
40
|
+
"esbuild": "0.24.2",
|
|
41
|
+
"eslint": "10.3.0",
|
|
42
|
+
"eslint-config-prettier": "10.1.8",
|
|
43
|
+
"eslint-plugin-simple-import-sort": "13.0.0",
|
|
44
|
+
"prettier": "3.8.3",
|
|
45
|
+
"tsx": "4.19.2",
|
|
46
|
+
"typescript": "5.7.2",
|
|
47
|
+
"typescript-eslint": "8.59.3",
|
|
48
|
+
"update-notifier": "7.3.1",
|
|
49
|
+
"vitest": "2.1.8"
|
|
50
|
+
}
|
|
51
|
+
}
|
|
@@ -0,0 +1,425 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: kst-im-cli
|
|
3
|
+
description: Use when invoking kst-im-cli commands as an agent for KST IM data queries, including authentication, JSON envelope parsing, intent routing (list vs stats basic-board), channel/site/stats command syntax, basic-board channel/web subcommands, history records, schema lookup, data dependency chain, and error recovery
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# kst-im-cli
|
|
7
|
+
|
|
8
|
+
## Quick Reference
|
|
9
|
+
|
|
10
|
+
| 命令 | 说明 |
|
|
11
|
+
| --------------------------------------------------------------------------- | ---------------------------- |
|
|
12
|
+
| `auth login -k <key>` | 登录 |
|
|
13
|
+
| `auth logout` | 退出 |
|
|
14
|
+
| `auth status` | 查看登录状态 |
|
|
15
|
+
| `config get <key>` | 读取配置项 |
|
|
16
|
+
| `config set <key> <value>` | 写入配置项 |
|
|
17
|
+
| `channel type list` | 列出所有渠道类型 |
|
|
18
|
+
| `channel type get --key <渠道标识>` | 查询单个渠道类型 |
|
|
19
|
+
| `channel account list [--channelKey <keys>] [--keyword <text>]` | 列出渠道账号 |
|
|
20
|
+
| `channel account get --accountId <id>` | 查询单个账号 |
|
|
21
|
+
| `site list [--with-codes]` | 列出网页站点 |
|
|
22
|
+
| `site get --siteId <id> [--with-codes]` | 查询单个站点 |
|
|
23
|
+
| `stats init` | 刷新中文字段映射缓存 |
|
|
24
|
+
| `stats basic-board channel (--period \| --start/--end) [--accounts <ids>]` | 查询渠道基础看板(默认子命令) |
|
|
25
|
+
| `stats basic-board web (--period \| --start/--end) [--sites <ids>]` | 查询网页站点看板 |
|
|
26
|
+
| `history schema` | 输出历史记录字段说明 |
|
|
27
|
+
| `history web --start <time> --end <time> [--site-ids <ids>]` | 查询网页站点历史会话 |
|
|
28
|
+
| `history channel --start <time> --end <time> [--account-ids <ids>]` | 查询渠道账号历史会话 |
|
|
29
|
+
|
|
30
|
+
所有命令支持 `-f/--format json|table|pretty`,默认 `json`;agent 模式始终用默认值。
|
|
31
|
+
|
|
32
|
+
---
|
|
33
|
+
|
|
34
|
+
## Overview
|
|
35
|
+
|
|
36
|
+
`kst-im-cli` 是快商通 IM 数据查询 CLI。agent 使用时需先完成认证,所有命令默认输出 JSON 信封,stdout/stderr 分工严格。
|
|
37
|
+
|
|
38
|
+
agent 查询历史记录前必须先调用 `history schema` 理解字段含义;不要依赖 schema 未声明的旧接口字段。
|
|
39
|
+
|
|
40
|
+
---
|
|
41
|
+
|
|
42
|
+
## 意图路由(优先遵守)
|
|
43
|
+
|
|
44
|
+
用户问「有哪些 / 列表 / 几个」时,**一律用 `* list` 枚举**,不要用 `stats basic-board` 代替。
|
|
45
|
+
|
|
46
|
+
| 用户问法 | 正确命令 | 禁止替代 |
|
|
47
|
+
| -------- | -------- | -------- |
|
|
48
|
+
| 有哪些渠道账号 / 渠道账号列表 | `channel account list` | ✗ `stats basic-board channel` |
|
|
49
|
+
| 有哪些站点 / 网页站点列表 / 几个站点 | `site list` | ✗ `stats basic-board web` |
|
|
50
|
+
| 有哪些渠道类型 | `channel type list` | — |
|
|
51
|
+
| 站点今天/本周数据、对话数、开口率等指标 | `stats basic-board web` | 需 siteId 时先 `site list` |
|
|
52
|
+
| 渠道账号今天/本周数据、对话数等指标 | `stats basic-board channel` | 需 accountId 时先 `channel account list` |
|
|
53
|
+
|
|
54
|
+
`stats basic-board` 省略 `--accounts` / `--sites` 表示查**全部对象的统计指标**(须指定时间范围),**不是**枚举清单。看板结果虽含账号名/站点名,但缺少完整元数据(如 siteId、code),不能当作 list 使用。
|
|
55
|
+
|
|
56
|
+
---
|
|
57
|
+
|
|
58
|
+
## 认证(前置必须)
|
|
59
|
+
|
|
60
|
+
```bash
|
|
61
|
+
kst-im-cli auth login -k <API_KEY>
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
必须用 `-k` 传入 key,CLI 无法在非交互环境下提示输入。
|
|
65
|
+
|
|
66
|
+
成功后 stdout:`{ "ok": true, "data": "已验证 compId=<N> customerId=<N>" }`
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
kst-im-cli auth status
|
|
70
|
+
# stdout: { "ok": true, "data": { "key": "...", "compId": N, "customerId": N } }
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
---
|
|
74
|
+
|
|
75
|
+
## 输出解析规则
|
|
76
|
+
|
|
77
|
+
### 流分工
|
|
78
|
+
|
|
79
|
+
| 流 | exit 0 | exit 1 |
|
|
80
|
+
| ------ | -------------------------------- | --------------------- |
|
|
81
|
+
| stdout | JSON 信封(成功数据) | **空** |
|
|
82
|
+
| stderr | 日志(`[info/warn/error]` 前缀) | 日志 + 失败 JSON 信封 |
|
|
83
|
+
|
|
84
|
+
失败时:stdout 为空,stderr 输出失败 JSON 信封(`CliError` 类型);未捕获的非 CliError 异常输出纯文本,无 JSON 信封。
|
|
85
|
+
|
|
86
|
+
stderr 可能混入 npm 更新提示(非 JSON 行)。解析时按行过滤,只处理能 `JSON.parse` 的行。设置 `CI=true` 可完全抑制更新提示。
|
|
87
|
+
|
|
88
|
+
### 成功 — stdout,exit 0
|
|
89
|
+
|
|
90
|
+
```json
|
|
91
|
+
{ "ok": true, "data": <payload>, "meta": { "count": N } }
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
`meta.count` 仅当 data 为数组时存在。`site list --with-codes` 额外有 `meta.codeCount`。
|
|
95
|
+
|
|
96
|
+
### 失败 — stderr,exit 1
|
|
97
|
+
|
|
98
|
+
```json
|
|
99
|
+
{ "ok": false, "data": { "type": "...", "content": "..." } }
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
---
|
|
103
|
+
|
|
104
|
+
## 命令参考
|
|
105
|
+
|
|
106
|
+
### channel
|
|
107
|
+
|
|
108
|
+
```bash
|
|
109
|
+
# 列出所有渠道类型
|
|
110
|
+
kst-im-cli channel type list
|
|
111
|
+
# 提取: .data[].key(渠道标识)、.data[].name(渠道名称)
|
|
112
|
+
|
|
113
|
+
# 查询单个渠道类型(--key 是渠道标识,不是 API Key)
|
|
114
|
+
kst-im-cli channel type get --key <渠道标识>
|
|
115
|
+
|
|
116
|
+
# 列出渠道账号
|
|
117
|
+
kst-im-cli channel account list [--channelKey <keys>] [--keyword <text>]
|
|
118
|
+
# --channelKey: 逗号分隔,来源 channel type list 的 .data[].key
|
|
119
|
+
# 提取: .data[].accountId(账号 ID)、.data[].name(账号名称)
|
|
120
|
+
|
|
121
|
+
# 查询单个账号
|
|
122
|
+
kst-im-cli channel account get --accountId <id>
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
### site
|
|
126
|
+
|
|
127
|
+
```bash
|
|
128
|
+
# 列出网页站点
|
|
129
|
+
kst-im-cli site list [--with-codes]
|
|
130
|
+
# 提取: .data[].siteId、.data[].siteName
|
|
131
|
+
# --with-codes 时还有 .data[].codes[](含 codeId、codeName)
|
|
132
|
+
|
|
133
|
+
# 查询单个站点(--siteId 来源 site list)
|
|
134
|
+
kst-im-cli site get --siteId <id> [--with-codes]
|
|
135
|
+
# --with-codes 时 meta.count 为 code 数量
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
### config
|
|
139
|
+
|
|
140
|
+
```bash
|
|
141
|
+
kst-im-cli config get <key> # 读取配置项,输出 { key, value }
|
|
142
|
+
kst-im-cli config set <key> <value> # 写入配置项,输出 { key, value }
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
### stats init
|
|
146
|
+
|
|
147
|
+
```bash
|
|
148
|
+
kst-im-cli stats init
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
将服务端的 dimension/indicator 中文映射缓存到 `~/.config/.kst-im-cli/stats.json`。channel 与 web 看板共用此缓存。`stats.json` 已存在时不会自动刷新;若服务端更新了指标配置,需手动执行。
|
|
152
|
+
|
|
153
|
+
### stats basic-board
|
|
154
|
+
|
|
155
|
+
`basic-board` 拆为 **channel**(渠道账号维度,默认)和 **web**(网页站点维度)两个子命令。
|
|
156
|
+
|
|
157
|
+
**向后兼容:** `stats basic-board --period today` 等价于 `stats basic-board channel --period today`。
|
|
158
|
+
|
|
159
|
+
#### channel — 渠道基础看板
|
|
160
|
+
|
|
161
|
+
```bash
|
|
162
|
+
kst-im-cli stats basic-board channel \
|
|
163
|
+
(--period <period> | --start "yyyy-MM-dd HH:mm:ss" --end "yyyy-MM-dd HH:mm:ss") \
|
|
164
|
+
[--accounts <ids>]
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
#### web — 网页站点看板
|
|
168
|
+
|
|
169
|
+
```bash
|
|
170
|
+
kst-im-cli stats basic-board web \
|
|
171
|
+
(--period <period> | --start "yyyy-MM-dd HH:mm:ss" --end "yyyy-MM-dd HH:mm:ss") \
|
|
172
|
+
[--sites <ids>]
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
`--period` 时间范围(均为 00:00:00 ~ 23:59:59):
|
|
176
|
+
|
|
177
|
+
| 值 | 范围 |
|
|
178
|
+
| ----------- | --------------- |
|
|
179
|
+
| `today` | 今天 |
|
|
180
|
+
| `yesterday` | 昨天 |
|
|
181
|
+
| `week` | 本周一 ~ 今天 |
|
|
182
|
+
| `last-week` | 上周一 ~ 上周日 |
|
|
183
|
+
|
|
184
|
+
`--period` 与 `--start`/`--end` 互斥;`--start` 和 `--end` 必须同时指定。
|
|
185
|
+
|
|
186
|
+
`--accounts`:逗号分隔,来源 `channel account list` 的 `.data[].accountId`;省略则查全部账号的**指标**(仅 channel,不是账号清单)。
|
|
187
|
+
|
|
188
|
+
`--sites`:逗号分隔,来源 `site list` 的 `.data[].siteId`;省略则查全部站点的**指标**(仅 web,不是站点清单)。
|
|
189
|
+
|
|
190
|
+
**输出**:
|
|
191
|
+
|
|
192
|
+
```
|
|
193
|
+
.data[] ← resultlist 明细行(字段名为中文)
|
|
194
|
+
.meta.count ← 行数
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
**stats.json 依赖行为**:
|
|
198
|
+
|
|
199
|
+
- **缺失**:自动调用 `stats init`(发网络请求);init 失败则整个命令 exit 1
|
|
200
|
+
- **存在但解析失败**:字段名退化为原始英文 key,stderr 输出 `[error]` + `[warn]`,命令仍成功(exit 0)
|
|
201
|
+
|
|
202
|
+
### history schema
|
|
203
|
+
|
|
204
|
+
```bash
|
|
205
|
+
kst-im-cli history schema
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
返回历史记录字段说明,用于解释 `history web` 和 `history channel` 的 `.data[]`。查询历史记录前先调用一次。
|
|
209
|
+
|
|
210
|
+
必须读取:
|
|
211
|
+
|
|
212
|
+
- `.data.timeFormat`:时间格式,当前为 `yyyy-MM-dd HH:mm:ss`
|
|
213
|
+
- `.data.fields[]`:字段路径、中英文名称、类型、可空性和解释
|
|
214
|
+
- `.data.enums[]`:枚举或常见取值解释
|
|
215
|
+
- `.data.notes[]`:脱敏、稳定字段边界等注意事项
|
|
216
|
+
|
|
217
|
+
解释规则:
|
|
218
|
+
|
|
219
|
+
- 只把 `.data.fields[].path` 中声明的字段当作稳定对外字段。
|
|
220
|
+
- `dialogRecordList` 是当前会话内的聊天消息列表,不是会话列表。
|
|
221
|
+
- `visitorInfo` 是访客维度信息。
|
|
222
|
+
- `dialogInfo` 是会话维度信息。
|
|
223
|
+
- `cardInfo.cardCusType` 是名片标签名称;映射缺失时可能是原始值。
|
|
224
|
+
- 聊天内容、联系方式、来源 IP 等可能已脱敏,不要声称拿到了完整原文。
|
|
225
|
+
|
|
226
|
+
### history web
|
|
227
|
+
|
|
228
|
+
```bash
|
|
229
|
+
kst-im-cli history web \
|
|
230
|
+
--start "yyyy-MM-dd HH:mm:ss" \
|
|
231
|
+
--end "yyyy-MM-dd HH:mm:ss" \
|
|
232
|
+
[--site-ids <ids>] \
|
|
233
|
+
[--page <page>] \
|
|
234
|
+
[--page-size <size>]
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
按时间范围查询网页站点历史会话。`--site-ids` 为逗号分隔的站点 ID,来源 `site list` 的 `.data[].siteId`;省略时由服务端权限和默认查询逻辑决定范围。
|
|
238
|
+
|
|
239
|
+
输出:
|
|
240
|
+
|
|
241
|
+
```
|
|
242
|
+
.data[] ← 会话列表
|
|
243
|
+
.meta.count ← 当前页返回条数
|
|
244
|
+
```
|
|
245
|
+
|
|
246
|
+
每个会话对象可能包含:`contacted`、`visitorInfo`、`dialogInfo`、`dialogRecordList`、`adInfo`、`trackRecordList`、`cardInfo`。
|
|
247
|
+
|
|
248
|
+
### history channel
|
|
249
|
+
|
|
250
|
+
```bash
|
|
251
|
+
kst-im-cli history channel \
|
|
252
|
+
--start "yyyy-MM-dd HH:mm:ss" \
|
|
253
|
+
--end "yyyy-MM-dd HH:mm:ss" \
|
|
254
|
+
[--account-ids <ids>] \
|
|
255
|
+
[--page <page>] \
|
|
256
|
+
[--page-size <size>]
|
|
257
|
+
```
|
|
258
|
+
|
|
259
|
+
按时间范围查询渠道账号历史会话。`--account-ids` 为逗号分隔的渠道账号 ID,来源通常是 `channel account list` 的 `.data[].accountId`。
|
|
260
|
+
|
|
261
|
+
渠道查询与网页查询共用历史记录结果结构。渠道专有信息优先看:
|
|
262
|
+
|
|
263
|
+
- `visitorInfo.visitorNick`
|
|
264
|
+
- `visitorInfo.sourceCity`
|
|
265
|
+
- `visitorInfo.trafficType`
|
|
266
|
+
- `visitorInfo.accountInfo`
|
|
267
|
+
- `dialogInfo.dialogTag`
|
|
268
|
+
|
|
269
|
+
### history 查询约束
|
|
270
|
+
|
|
271
|
+
- `--start` 和 `--end` 必须同时指定。
|
|
272
|
+
- 时间格式必须是 `yyyy-MM-dd HH:mm:ss`。
|
|
273
|
+
- `--page` 和 `--page-size` 必须大于 0;默认分别为 `1` 和 `500`。
|
|
274
|
+
- `--page-size` 不能大于 `500`;大范围查询应分页执行,不要一次请求过大页数。
|
|
275
|
+
- 返回空数组表示当前条件下未查到会话,不等于 CLI 调用失败。
|
|
276
|
+
- 若需要解释字段,重新调用 `history schema`,不要猜测字段含义。
|
|
277
|
+
|
|
278
|
+
---
|
|
279
|
+
|
|
280
|
+
## 数据依赖关系
|
|
281
|
+
|
|
282
|
+
```
|
|
283
|
+
channel type list → channel account list --channelKey
|
|
284
|
+
channel account list → stats basic-board channel --accounts
|
|
285
|
+
site list → stats basic-board web --sites
|
|
286
|
+
site list → history web --site-ids
|
|
287
|
+
stats init → channel / web 看板(中文字段映射,共用 stats.json)
|
|
288
|
+
```
|
|
289
|
+
|
|
290
|
+
---
|
|
291
|
+
|
|
292
|
+
## 错误处理
|
|
293
|
+
|
|
294
|
+
| type / 症状 | 原因 | 处理 |
|
|
295
|
+
| -------------------------- | ------------------------------ | ----------------------------------------- |
|
|
296
|
+
| `auth` | 未登录或 token 失效 | `auth login -k <key>` 后重试 |
|
|
297
|
+
| `validation` | 参数错误 | 修正参数后重试 |
|
|
298
|
+
| `network` | 网络不通 | 检查网络连通性 |
|
|
299
|
+
| `api` | 服务端业务错误 | 读 `.data.content` 查看服务端响应 |
|
|
300
|
+
| `auth login` 挂起 | 未带 `-k`,进入交互模式 | 加 `-k <key>` 重试 |
|
|
301
|
+
| `basic-board` exit 1 | `stats.json` 缺失且 init 失败 | 先手动执行 `stats init` |
|
|
302
|
+
| channel 看板 api 错误 | 未配置渠道基础看板 | 确认 OnlineRecord 看板配置 |
|
|
303
|
+
| web 看板 api 错误 | 未配置网页基础看板 | 确认 OnlineRecord 网页看板配置 |
|
|
304
|
+
| `站点不存在: {siteId}` | siteId 无效 | 重新执行 `site list` 获取有效 ID |
|
|
305
|
+
| `--key` 参数错误 | 传的是 API Key 而非渠道标识 | 传渠道标识(如 `weixin`) |
|
|
306
|
+
| stderr 有非 JSON 行 | npm 更新提示 | 设置 `CI=true` 抑制,或按行过滤 |
|
|
307
|
+
| `basic-board` 字段名为英文 | `stats.json` 损坏 | 执行 `stats init` 刷新 |
|
|
308
|
+
| `history` 字段含义不清 | 未读取 schema | 先执行 `history schema` |
|
|
309
|
+
| `history` 参数校验失败 | 时间格式、分页或必填项错误 | 按 `yyyy-MM-dd HH:mm:ss` 和正整数分页重试 |
|
|
310
|
+
| `history` 返回空列表 | 条件下无数据或权限范围内无数据 | 缩小/调整时间、站点或账号条件后重试 |
|
|
311
|
+
|
|
312
|
+
---
|
|
313
|
+
|
|
314
|
+
## 禁止使用
|
|
315
|
+
|
|
316
|
+
| 命令 | 原因 |
|
|
317
|
+
| ----------------------- | ----------------------------------- |
|
|
318
|
+
| `auth login`(无 `-k`) | 交互式,会挂起 |
|
|
319
|
+
| `skill install` | 交互式,会挂起 |
|
|
320
|
+
| `completion` | 生成 shell 补全脚本,agent 无需使用 |
|
|
321
|
+
|
|
322
|
+
---
|
|
323
|
+
|
|
324
|
+
## 典型工作流
|
|
325
|
+
|
|
326
|
+
### 查询指定渠道的基础看板数据
|
|
327
|
+
|
|
328
|
+
```bash
|
|
329
|
+
# 1. 拿渠道 key
|
|
330
|
+
kst-im-cli channel type list
|
|
331
|
+
# → .data[].key 如 "weixin", "xiaohongshu"
|
|
332
|
+
|
|
333
|
+
# 2. 拿 accountId
|
|
334
|
+
kst-im-cli channel account list --channelKey weixin,xiaohongshu
|
|
335
|
+
# → .data[].accountId 如 101, 102, 203
|
|
336
|
+
|
|
337
|
+
# 3. 查看板(channel 为默认子命令,可省略子命令名)
|
|
338
|
+
kst-im-cli stats basic-board channel --period today --accounts 101,102,203
|
|
339
|
+
# → .data[] 明细行(字段名为中文)
|
|
340
|
+
# → .meta.count 行数
|
|
341
|
+
```
|
|
342
|
+
|
|
343
|
+
### 查询指定站点的网页看板数据
|
|
344
|
+
|
|
345
|
+
```bash
|
|
346
|
+
# 1. 拿 siteId
|
|
347
|
+
kst-im-cli site list
|
|
348
|
+
# → .data[].siteId 如 "118501", "118503"
|
|
349
|
+
|
|
350
|
+
# 2. 查网页看板
|
|
351
|
+
kst-im-cli stats basic-board web --period today --sites 118501,118503
|
|
352
|
+
# → .data[] 明细行(字段名为中文)
|
|
353
|
+
# → .meta.count 行数
|
|
354
|
+
```
|
|
355
|
+
|
|
356
|
+
### 对比昨今数据(渠道)
|
|
357
|
+
|
|
358
|
+
```bash
|
|
359
|
+
kst-im-cli stats basic-board channel --period yesterday --accounts 101,102,203
|
|
360
|
+
kst-im-cli stats basic-board channel --period today --accounts 101,102,203
|
|
361
|
+
# 对比两次 .data[] 中相同维度行的指标差值
|
|
362
|
+
```
|
|
363
|
+
|
|
364
|
+
### 对比昨今数据(网页站点)
|
|
365
|
+
|
|
366
|
+
```bash
|
|
367
|
+
kst-im-cli stats basic-board web --period yesterday --sites 118501,118503
|
|
368
|
+
kst-im-cli stats basic-board web --period today --sites 118501,118503
|
|
369
|
+
# 对比两次 .data[] 中相同维度行的指标差值
|
|
370
|
+
```
|
|
371
|
+
|
|
372
|
+
### 自定义时间范围
|
|
373
|
+
|
|
374
|
+
```bash
|
|
375
|
+
kst-im-cli stats basic-board channel \
|
|
376
|
+
--start "2026-05-01 00:00:00" \
|
|
377
|
+
--end "2026-05-27 23:59:59" \
|
|
378
|
+
--accounts 101,102
|
|
379
|
+
|
|
380
|
+
kst-im-cli stats basic-board web \
|
|
381
|
+
--start "2026-05-01 00:00:00" \
|
|
382
|
+
--end "2026-05-27 23:59:59" \
|
|
383
|
+
--sites 118501,118503
|
|
384
|
+
```
|
|
385
|
+
|
|
386
|
+
### 查询网页历史会话
|
|
387
|
+
|
|
388
|
+
```bash
|
|
389
|
+
# 1. 拿 siteId(过滤用)
|
|
390
|
+
kst-im-cli site list
|
|
391
|
+
# → .data[].siteId 如 "118501", "118504"
|
|
392
|
+
|
|
393
|
+
# 2. 先拿字段说明
|
|
394
|
+
kst-im-cli history schema
|
|
395
|
+
|
|
396
|
+
# 3. 查询历史会话
|
|
397
|
+
kst-im-cli history web \
|
|
398
|
+
--start "2026-06-01 00:00:00" \
|
|
399
|
+
--end "2026-06-03 23:59:59" \
|
|
400
|
+
--site-ids 118501,118504 \
|
|
401
|
+
--page 1 \
|
|
402
|
+
--page-size 500
|
|
403
|
+
|
|
404
|
+
# 4. 解释结果
|
|
405
|
+
# .data[] 是会话列表
|
|
406
|
+
# .data[].dialogRecordList 是当前会话内的聊天消息列表
|
|
407
|
+
```
|
|
408
|
+
|
|
409
|
+
### 查询渠道历史会话
|
|
410
|
+
|
|
411
|
+
```bash
|
|
412
|
+
# 1. 获取渠道账号 ID
|
|
413
|
+
kst-im-cli channel account list --channelKey weixin
|
|
414
|
+
|
|
415
|
+
# 2. 获取历史字段说明
|
|
416
|
+
kst-im-cli history schema
|
|
417
|
+
|
|
418
|
+
# 3. 查询渠道历史会话
|
|
419
|
+
kst-im-cli history channel \
|
|
420
|
+
--start "2026-06-01 00:00:00" \
|
|
421
|
+
--end "2026-06-03 23:59:59" \
|
|
422
|
+
--account-ids 101,102 \
|
|
423
|
+
--page 1 \
|
|
424
|
+
--page-size 500
|
|
425
|
+
```
|