@bty/customer-service-cli 0.1.7 → 0.1.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.
Files changed (3) hide show
  1. package/README.md +4 -0
  2. package/dist/bin.js +36 -9
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -196,6 +196,7 @@ cs-cli product update-sku --agent <id> --sku "颜色分类:粉红" --update '{"
196
196
  | `issue get <issue_id>` | 获取工单详情 |
197
197
  | `issue create --title <标题> --content <内容> [--priority <优先级>] [--tags <标签>]` | 创建工单 |
198
198
  | `issue update <issue_id> --data <json|@file>` | 更新工单 |
199
+ | `issue stats [--start <日期>] [--end <日期>]` | 各工作空间 Issue 统计(open/closed/total) |
199
200
  | `issue comment list <issue_id>` | 列出工单评论 |
200
201
  | `issue comment add <issue_id> --content <内容>` | 添加评论 |
201
202
 
@@ -356,6 +357,9 @@ cs-cli debug ask --agent a0901fe383064c2abefb0bf1cd52988e --text "你好"
356
357
  # 获取调试信息
357
358
  cs-cli debug record <record_id>
358
359
 
360
+ # 各工作空间 Issue 统计
361
+ cs-cli issue stats --start 2026-03-01 --end 2026-03-23
362
+
359
363
  # 列出工单(按日期筛选)
360
364
  cs-cli issue list --agent <id> --start 2026-03-01T00:00:00 --end 2026-03-22T23:59:59
361
365
 
package/dist/bin.js CHANGED
@@ -294,6 +294,15 @@ function getWorkspaceId(overrideWorkspaceId) {
294
294
  if (globalConfig?.defaultWorkspaceId) return globalConfig.defaultWorkspaceId;
295
295
  throw new APIError(1, "\u672A\u8BBE\u7F6E\u5DE5\u4F5C\u7A7A\u95F4\uFF0C\u8BF7\u8FD0\u884C: cs-cli config set-workspace <id>");
296
296
  }
297
+ function buildCookieHeaders() {
298
+ const creds = readCredentials();
299
+ if (!creds) throw new APIError(2, "\u672A\u767B\u5F55\uFF0C\u8BF7\u8FD0\u884C: cs-cli auth login");
300
+ if (isTokenExpired(creds.expiresAt)) {
301
+ clearCredentials();
302
+ throw new APIError(2, "Token \u5DF2\u8FC7\u671F\uFF0C\u8BF7\u8FD0\u884C: cs-cli auth login");
303
+ }
304
+ return { Cookie: `auth_token=${creds.accessToken}` };
305
+ }
297
306
 
298
307
  // src/client/auth-api.ts
299
308
  var LOGIN_AUTHORIZATION = "Basic YWlfZmxvdzphaV9mbG93X3Bhc3M=";
@@ -898,6 +907,21 @@ async function addIssueComment(issueId, content) {
898
907
  return request(getCustomerServiceUrl(), `/v1/issues/${issueId}/comments`, { method: "POST", body: { content } });
899
908
  }
900
909
 
910
+ // src/client/issue-stats-api.ts
911
+ async function getIssueStats(opts) {
912
+ const request = createRequest();
913
+ const query = {};
914
+ if (opts.dateStart) query.date_start = opts.dateStart;
915
+ if (opts.dateEnd) query.date_end = opts.dateEnd;
916
+ const result = await request(getCustomerAgentUrl(), "/api/issues/stats", {
917
+ method: "GET",
918
+ query,
919
+ headers: buildCookieHeaders(),
920
+ skipAuth: true
921
+ });
922
+ return result.data ?? result;
923
+ }
924
+
901
925
  // src/commands/issue.ts
902
926
  function registerIssueCommand(program2) {
903
927
  const issue = program2.command("issue").description("\u5DE5\u5355\u7BA1\u7406");
@@ -954,6 +978,18 @@ function registerIssueCommand(program2) {
954
978
  process.exit(toExitCode(err));
955
979
  }
956
980
  });
981
+ issue.command("stats").description("\u5404\u5DE5\u4F5C\u7A7A\u95F4 Issue \u7EDF\u8BA1\uFF08open/closed/total\uFF09").option("--start <date>", "\u5F00\u59CB\u65E5\u671F\uFF08\u5982 2026-03-01\uFF09").option("--end <date>", "\u7ED3\u675F\u65E5\u671F\uFF08\u5982 2026-03-23\uFF09").action(async (opts) => {
982
+ try {
983
+ const data = await getIssueStats({
984
+ dateStart: opts.start,
985
+ dateEnd: opts.end
986
+ });
987
+ formatOutput({ success: true, data }, program2.opts().table);
988
+ } catch (err) {
989
+ outputError(err.statusCode ?? 1, err.message);
990
+ process.exit(toExitCode(err));
991
+ }
992
+ });
957
993
  const comment = issue.command("comment").description("\u5DE5\u5355\u8BC4\u8BBA\u7BA1\u7406");
958
994
  comment.command("list").description("\u5217\u51FA\u5DE5\u5355\u8BC4\u8BBA").argument("<issue_id>", "\u5DE5\u5355 ID").action(async (issueId) => {
959
995
  try {
@@ -1753,15 +1789,6 @@ function registerMonitorCommand(program2) {
1753
1789
 
1754
1790
  // src/client/repair-record-api.ts
1755
1791
  var PATH_PREFIX = "/api/repair-records";
1756
- function buildCookieHeaders() {
1757
- const creds = readCredentials();
1758
- if (!creds) throw new APIError(2, "\u672A\u767B\u5F55\uFF0C\u8BF7\u8FD0\u884C: cs-cli auth login");
1759
- if (isTokenExpired(creds.expiresAt)) {
1760
- clearCredentials();
1761
- throw new APIError(2, "Token \u5DF2\u8FC7\u671F\uFF0C\u8BF7\u8FD0\u884C: cs-cli auth login");
1762
- }
1763
- return { Cookie: `auth_token=${creds.accessToken}` };
1764
- }
1765
1792
  async function listRepairRecords(opts) {
1766
1793
  const request = createRequest();
1767
1794
  const query = {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bty/customer-service-cli",
3
- "version": "0.1.7",
3
+ "version": "0.1.8",
4
4
  "description": "AI Customer Service CLI - Agent friendly",
5
5
  "type": "module",
6
6
  "main": "./dist/bin.js",