siluzan-tso-cli 1.1.7 → 1.1.8-beta.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
@@ -12,7 +12,7 @@
12
12
  在**用户的目标项目根目录**执行(根据用户使用的助手选择 `--ai`):
13
13
 
14
14
  ```bash
15
- npm install -g siluzan-tso-cli
15
+ npm install -g siluzan-tso-cli@beta
16
16
  siluzan-tso init --ai cursor # 写入 Cursor(默认)
17
17
  siluzan-tso init --ai cursor,claude # 同时写入多个平台
18
18
  siluzan-tso init --ai all # 写入所有支持的平台
@@ -20,6 +20,7 @@ siluzan-tso init -d /path/to/skills # 写入自定义目录
20
20
  siluzan-tso init --force # 强制覆盖已存在文件
21
21
  ```
22
22
 
23
+ > **注意**:当前为测试版(1.1.8-beta.1),供内部测试使用。正式发布后安装命令将改为 `npm install -g siluzan-tso-cli`。
23
24
 
24
25
  | 助手 | 建议 `--ai` |
25
26
  |------|-------------|
package/dist/index.js CHANGED
@@ -1962,9 +1962,7 @@ import { fileURLToPath as fileURLToPath4 } from "url";
1962
1962
  import { Command } from "commander";
1963
1963
 
1964
1964
  // src/config/defaults.ts
1965
- var BUILD_ENV = "production";
1966
- var DEFAULT_API_BASE = "https://tso-api.siluzan.com";
1967
- var DEFAULT_GOOGLE_API = "https://googleapi.mysiluzan.com";
1965
+ var DEFAULT_API_BASE = "https://tso-api-ci.siluzan.com";
1968
1966
 
1969
1967
  // ../common/dist/index.js
1970
1968
  import * as fs from "fs";
@@ -1992,9 +1990,6 @@ function readSharedConfig() {
1992
1990
  return {
1993
1991
  authToken: readStr(raw, "authToken") ?? "",
1994
1992
  apiKey: readStr(raw, "apiKey"),
1995
- apiBaseUrl: readStr(raw, "apiBaseUrl"),
1996
- tsoApiBaseUrl: readStr(raw, "tsoApiBaseUrl"),
1997
- googleApiUrl: readStr(raw, "googleApiUrl"),
1998
1993
  dataPermission: readStr(raw, "dataPermission")
1999
1994
  };
2000
1995
  } catch {
@@ -2013,9 +2008,6 @@ function writeSharedConfig(partial) {
2013
2008
  const keys = [
2014
2009
  "authToken",
2015
2010
  "apiKey",
2016
- "apiBaseUrl",
2017
- "tsoApiBaseUrl",
2018
- "googleApiUrl",
2019
2011
  "dataPermission"
2020
2012
  ];
2021
2013
  for (const k of keys) {
@@ -2404,15 +2396,26 @@ function cacheKeyForUser(mainOrigin, config) {
2404
2396
  }
2405
2397
  var userContextDone = /* @__PURE__ */ new Set();
2406
2398
  var userContextInflight = /* @__PURE__ */ new Map();
2399
+ function pickCompanyIdFromMe(data) {
2400
+ const direct = pickStr(data, "companyId") ?? pickStr(data, "companyID") ?? pickStr(data, "CompanyId");
2401
+ if (direct) return direct;
2402
+ const ci = data["companyInfo"];
2403
+ if (ci && typeof ci === "object") {
2404
+ const o = ci;
2405
+ return pickStr(o, "id") ?? pickStr(o, "companyId") ?? pickStr(o, "companyID");
2406
+ }
2407
+ return void 0;
2408
+ }
2407
2409
  function parseMeResponse(text) {
2408
2410
  try {
2409
2411
  const json = JSON.parse(text);
2410
2412
  const data = json?.data && typeof json.data === "object" ? json.data : json;
2411
- const id = pickStr(data, "id") ?? pickStr(data, "userId") ?? pickStr(data, "accountId");
2413
+ const id = pickStr(data, "entityId") ?? pickStr(data, "id") ?? pickStr(data, "userId") ?? pickStr(data, "accountId");
2412
2414
  const email = pickStr(data, "email");
2413
2415
  const username = pickStr(data, "userName") ?? pickStr(data, "username") ?? pickStr(data, "name") ?? pickStr(data, "phone");
2414
- if (!id && !email && !username) return null;
2415
- return { id, email, username };
2416
+ const companyId = pickCompanyIdFromMe(data);
2417
+ if (!id && !email && !username && !companyId) return null;
2418
+ return { id, email, username, companyId };
2416
2419
  } catch {
2417
2420
  return null;
2418
2421
  }
@@ -2733,6 +2736,9 @@ function deriveFacebookApiUrl(tsoApiBaseUrl) {
2733
2736
  function deriveChatGptApiUrl(tsoApiBaseUrl) {
2734
2737
  return tsoApiBaseUrl.includes("-ci") ? "https://chatgpt-ci.mysiluzan.com" : "https://chatgpt.mysiluzan.com";
2735
2738
  }
2739
+ function deriveGoogleApiUrl(tsoApiBaseUrl) {
2740
+ return tsoApiBaseUrl.includes("-ci") ? "https://googleapi-ci.mysiluzan.com" : "https://googleapi.mysiluzan.com";
2741
+ }
2736
2742
  var TSO_KNOWN_ROUTE = "/v2/foreign_trade/recharge/invoiceManagement/invoiceList";
2737
2743
  function findDpByUrl(nodes, targetUrl) {
2738
2744
  for (const node of nodes) {
@@ -2782,14 +2788,14 @@ function loadConfig(tokenArg) {
2782
2788
  );
2783
2789
  process.exit(1);
2784
2790
  }
2785
- const apiBaseUrl = process.env.SILUZAN_TSO_API_BASE ?? shared.tsoApiBaseUrl ?? DEFAULT_API_BASE;
2791
+ const apiBaseUrl = process.env.SILUZAN_TSO_API_BASE ?? DEFAULT_API_BASE;
2786
2792
  const apiErr = validateBaseUrl(apiBaseUrl);
2787
2793
  if (apiErr) {
2788
2794
  console.error(`
2789
2795
  \u274C tsoApiBaseUrl \u4E0D\u5408\u6CD5\uFF1A${apiErr}`);
2790
2796
  process.exit(1);
2791
2797
  }
2792
- const googleApiUrl = process.env.SILUZAN_GOOGLE_API ?? shared.googleApiUrl ?? DEFAULT_GOOGLE_API;
2798
+ const googleApiUrl = process.env.SILUZAN_GOOGLE_API ?? deriveGoogleApiUrl(apiBaseUrl);
2793
2799
  const googleApiErr = validateBaseUrl(googleApiUrl);
2794
2800
  if (googleApiErr) {
2795
2801
  console.error(`
@@ -2864,8 +2870,8 @@ function cmdConfigShow() {
2864
2870
  const shared = readSharedConfig();
2865
2871
  const authToken = shared.authToken;
2866
2872
  const apiKey = shared.apiKey ?? "";
2867
- const apiBaseUrl = shared.tsoApiBaseUrl ?? DEFAULT_API_BASE;
2868
- const googleApiUrl = shared.googleApiUrl ?? DEFAULT_GOOGLE_API;
2873
+ const apiBaseUrl = process.env.SILUZAN_TSO_API_BASE ?? DEFAULT_API_BASE;
2874
+ const googleApiUrl = process.env.SILUZAN_GOOGLE_API ?? deriveGoogleApiUrl(apiBaseUrl);
2869
2875
  const webUrl = deriveWebUrl(apiBaseUrl);
2870
2876
  if (!apiKey && !authToken) {
2871
2877
  console.log(
@@ -2874,7 +2880,6 @@ function cmdConfigShow() {
2874
2880
  return;
2875
2881
  }
2876
2882
  console.log("\n\u5F53\u524D\u914D\u7F6E\uFF08~/.siluzan/config.json\uFF09\uFF1A");
2877
- console.log(` \u6784\u5EFA\u73AF\u5883 : ${BUILD_ENV}`);
2878
2883
  console.log(` tsoApiBaseUrl : ${apiBaseUrl}`);
2879
2884
  console.log(` googleApiUrl : ${googleApiUrl}`);
2880
2885
  console.log(` webUrl : ${webUrl}`);
@@ -2886,48 +2891,24 @@ function cmdConfigShow() {
2886
2891
  console.log(` authToken : ${maskSecret(authToken)}${note}`);
2887
2892
  }
2888
2893
  console.log();
2889
- console.log(" \u5207\u6362\u6D4B\u8BD5\u73AF\u5883\uFF08\u5199\u5165 config.json.tsoApiBaseUrl\uFF0C\u4E0D\u5F71\u54CD CSO CLI \u7684 apiBaseUrl\uFF09\uFF1A");
2890
- console.log(" siluzan-tso config set --api-base https://tso-api-ci.siluzan.com");
2891
2894
  console.log(`
2892
2895
  \u914D\u7F6E\u6587\u4EF6\u4F4D\u7F6E\uFF1A${CONFIG_FILE}`);
2893
2896
  console.log(" \u26A0\uFE0F \u51ED\u636E\u660E\u6587\u5B58\u50A8\uFF0C\u8BF7\u52FF\u63D0\u4EA4\u81F3\u4EE3\u7801\u4ED3\u5E93\uFF0C\u901A\u8FC7 SILUZAN_API_KEY \u73AF\u5883\u53D8\u91CF\u4F20\u5165\u66F4\u5B89\u5168\u3002");
2894
2897
  console.log();
2895
2898
  }
2896
2899
  function cmdConfigSet(opts) {
2897
- if (!opts.token && !opts.apiKey && !opts.apiBase && !opts.googleApi) {
2900
+ if (!opts.token && !opts.apiKey) {
2898
2901
  console.error(
2899
- "\n\u274C \u8BF7\u81F3\u5C11\u63D0\u4F9B\u4E00\u4E2A\u8981\u66F4\u65B0\u7684\u914D\u7F6E\u9879\uFF08--api-key\u3001--token\u3001--api-base \u6216 --google-api\uFF09\n"
2902
+ "\n\u274C \u8BF7\u81F3\u5C11\u63D0\u4F9B\u4E00\u4E2A\u8981\u66F4\u65B0\u7684\u914D\u7F6E\u9879\uFF08--api-key \u6216 --token\uFF09\n"
2900
2903
  );
2901
2904
  process.exit(1);
2902
2905
  }
2903
- if (opts.apiBase) {
2904
- const err = validateBaseUrl(opts.apiBase);
2905
- if (err) {
2906
- console.error(`
2907
- \u274C --api-base \u4E0D\u5408\u6CD5\uFF1A${err}
2908
- `);
2909
- process.exit(1);
2910
- }
2911
- writeSharedConfig({ tsoApiBaseUrl: opts.apiBase });
2912
- }
2913
- if (opts.googleApi) {
2914
- const err = validateBaseUrl(opts.googleApi);
2915
- if (err) {
2916
- console.error(`
2917
- \u274C --google-api \u4E0D\u5408\u6CD5\uFF1A${err}
2918
- `);
2919
- process.exit(1);
2920
- }
2921
- writeSharedConfig({ googleApiUrl: opts.googleApi });
2922
- }
2923
2906
  if (opts.apiKey) writeSharedConfig({ apiKey: opts.apiKey });
2924
2907
  if (opts.token) writeSharedConfig({ authToken: opts.token });
2925
2908
  console.log(`
2926
2909
  \u2705 \u914D\u7F6E\u5DF2\u4FDD\u5B58\u5230 ${CONFIG_FILE}`);
2927
- if (opts.apiKey) console.log(` apiKey: ${maskSecret(opts.apiKey)}`);
2928
- if (opts.token) console.log(` authToken: ${maskSecret(opts.token)}`);
2929
- if (opts.apiBase) console.log(` tsoApiBaseUrl: ${opts.apiBase}`);
2930
- if (opts.googleApi) console.log(` googleApiUrl: ${opts.googleApi}`);
2910
+ if (opts.apiKey) console.log(` apiKey: ${maskSecret(opts.apiKey)}`);
2911
+ if (opts.token) console.log(` authToken: ${maskSecret(opts.token)}`);
2931
2912
  console.log("\n\u540E\u7EED\u6240\u6709\u547D\u4EE4\u81EA\u52A8\u8BFB\u53D6\u6B64\u914D\u7F6E\u3002\n");
2932
2913
  }
2933
2914
  function cmdConfigClear() {
@@ -9355,9 +9336,7 @@ var MCC_AGENT_TYPES = ["ChengGongYi", "SiGeUS", "SiGeCN", "Dee"];
9355
9336
  function googleGatewayBase(config) {
9356
9337
  const raw = (config.googleApiUrl ?? "").replace(/\/$/, "");
9357
9338
  if (!raw) {
9358
- console.error(
9359
- "\n\u274C \u672A\u914D\u7F6E Google \u7F51\u5173\u5730\u5740\uFF08googleApiUrl\uFF09\u3002\u8BF7\u8FD0\u884C\uFF1A\n siluzan-tso config set --google-api https://googleapi.mysiluzan.com\n \u6D4B\u8BD5\u73AF\u5883\uFF1Ahttps://googleapi-ci.mysiluzan.com\n"
9360
- );
9339
+ console.error("\n\u274C Google \u7F51\u5173\u5730\u5740\u672A\u80FD\u63A8\u5BFC\uFF0C\u8BF7\u68C0\u67E5 tsoApiBaseUrl \u914D\u7F6E\u3002\n");
9361
9340
  process.exit(1);
9362
9341
  }
9363
9342
  const err = validateBaseUrl(raw);
@@ -11276,14 +11255,8 @@ program.command("login").description("\u4FDD\u5B58\u8BA4\u8BC1\u51ED\u636E\u5230
11276
11255
  });
11277
11256
  var configCmd = program.command("config").description("\u67E5\u770B\u6216\u8BBE\u7F6E\u8BA4\u8BC1\u914D\u7F6E\uFF08\u4E0E siluzan-cso \u5171\u7528 ~/.siluzan/config.json\uFF09");
11278
11257
  configCmd.command("show").description("\u5C55\u793A\u5F53\u524D\u5DF2\u4FDD\u5B58\u7684\u914D\u7F6E\uFF08Token \u8131\u654F\u663E\u793A\uFF09").action(() => cmdConfigShow());
11279
- configCmd.command("set").description("\u4FDD\u5B58\u914D\u7F6E\u5230 ~/.siluzan/config.json").option("--api-key <key>", "API Key\uFF08\u5728\u4E1D\u8DEF\u8D5E\u300C\u8BBE\u7F6E \u2192 API Key \u7BA1\u7406\u300D\u521B\u5EFA\uFF0C\u63A8\u8350\uFF09").option("-t, --token <token>", "JWT \u7528\u6237 Auth Token\uFF08\u4E0E --api-key \u4E8C\u9009\u4E00\uFF09").option(
11280
- "--api-base <url>",
11281
- "TSO API \u57FA\u5730\u5740\uFF08\u751F\u4EA7\uFF1Ahttps://tso-api.siluzan.com \u6D4B\u8BD5\uFF1Ahttps://tso-api-ci.siluzan.com\uFF09"
11282
- ).option(
11283
- "--google-api <url>",
11284
- "Google \u5E7F\u544A\u7F51\u5173\u5730\u5740\uFF08\u751F\u4EA7\uFF1Ahttps://googleapi.mysiluzan.com \u6D4B\u8BD5\uFF1Ahttps://googleapi-ci.mysiluzan.com\uFF09"
11285
- ).action((opts) => {
11286
- cmdConfigSet({ apiKey: opts.apiKey, token: opts.token, apiBase: opts.apiBase, googleApi: opts.googleApi });
11258
+ configCmd.command("set").description("\u4FDD\u5B58\u914D\u7F6E\u5230 ~/.siluzan/config.json").option("--api-key <key>", "API Key\uFF08\u5728\u4E1D\u8DEF\u8D5E\u300C\u8BBE\u7F6E \u2192 API Key \u7BA1\u7406\u300D\u521B\u5EFA\uFF0C\u63A8\u8350\uFF09").option("-t, --token <token>", "JWT \u7528\u6237 Auth Token\uFF08\u4E0E --api-key \u4E8C\u9009\u4E00\uFF09").action((opts) => {
11259
+ cmdConfigSet({ apiKey: opts.apiKey, token: opts.token });
11287
11260
  });
11288
11261
  configCmd.command("clear").description("\u6E05\u7A7A\u5DF2\u4FDD\u5B58\u7684 Token").action(() => cmdConfigClear());
11289
11262
  program.command("update").description("\u68C0\u67E5\u5E76\u66F4\u65B0 siluzan-tso-cli \u81F3\u6700\u65B0\u7248\u672C\uFF0C\u5E76\u6253\u5370 Skill \u6587\u4EF6\u76EE\u5F55\u4F9B\u624B\u52A8\u590D\u5236").option("--force", "\u8DF3\u8FC7\u7248\u672C\u6BD4\u8F83\uFF0C\u5F3A\u5236\u91CD\u65B0\u5B89\u88C5", false).action(async (opts) => {
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "slug": "siluzan-tso",
3
- "version": "1.1.7",
4
- "publishedAt": 1775198993745
3
+ "version": "1.1.8-beta.1",
4
+ "publishedAt": 1775642281942
5
5
  }
@@ -7,7 +7,7 @@
7
7
 
8
8
  ## invoice-info — 发票抬头管理
9
9
 
10
- 对应页面:`https://www.siluzan.com/v3/foreign_trade/settings/invoiceInformation`
10
+ 对应页面:`https://www-ci.siluzan.com/v3/foreign_trade/settings/invoiceInformation`
11
11
 
12
12
  发票抬头是开票申请时使用的公司/企业信息模板,支持三种类型:
13
13
  - **PI**:形式发票(境外美金账户,英文信息)
@@ -130,10 +130,10 @@ siluzan-tso config show
130
130
  **示例:**
131
131
 
132
132
  ```
133
- - 现金充值(单笔):https://www.siluzan.com/recharge/pay
134
- - 现金充值(批量):https://www.siluzan.com/recharge/pay_batch
135
- - 月结充值: https://www.siluzan.com/recharge/accountBillingQuota
136
- - 丝路赞钱包: https://www.siluzan.com/recharge/siluzanWallet
133
+ - 现金充值(单笔):https://www-ci.siluzan.com/recharge/pay
134
+ - 现金充值(批量):https://www-ci.siluzan.com/recharge/pay_batch
135
+ - 月结充值: https://www-ci.siluzan.com/recharge/accountBillingQuota
136
+ - 丝路赞钱包: https://www-ci.siluzan.com/recharge/siluzanWallet
137
137
  ```
138
138
 
139
139
  ---
@@ -212,8 +212,8 @@ siluzan-tso report list -m Google --json
212
212
 
213
213
  # 第二步:查看 webUrl
214
214
  siluzan-tso config show
215
- # webUrl: https://www.siluzan.com
215
+ # webUrl: https://www-ci.siluzan.com
216
216
 
217
217
  # 第三步:拼接链接(Google 日报)
218
- # https://www.siluzan.com/media-report/publish/rpt_abc123?culture=zh-CN
218
+ # https://www-ci.siluzan.com/media-report/publish/rpt_abc123?culture=zh-CN
219
219
  ```
@@ -3,7 +3,7 @@
3
3
  ## 安装 CLI
4
4
 
5
5
  ```bash
6
- npm install -g siluzan-tso-cli
6
+ npm install -g siluzan-tso-cli@beta
7
7
  ```
8
8
 
9
9
  环境要求:Node.js 18+
@@ -42,7 +42,7 @@ siluzan-tso config set --api-key <Key> # 或通过 config set 直接写入
42
42
  siluzan-tso config set --token <Token> # 备用:设置 JWT Token
43
43
  ```
44
44
 
45
- API Key 获取入口:`https://www.siluzan.com/v3/foreign_trade/settings/apiKeyManagement`
45
+ API Key 获取入口:`https://www-ci.siluzan.com/v3/foreign_trade/settings/apiKeyManagement`
46
46
 
47
47
  ---
48
48
 
@@ -54,9 +54,9 @@ siluzan-tso config show
54
54
  输出示例:
55
55
  ```
56
56
  构建环境 : production
57
- apiBaseUrl : https://tso-api.siluzan.com
58
- googleApiUrl : https://googleapi.mysiluzan.com
59
- webUrl : https://www.siluzan.com
57
+ apiBaseUrl : https://tso-api-ci.siluzan.com
58
+ googleApiUrl : https://googleapi-ci.mysiluzan.com
59
+ webUrl : https://www-ci.siluzan.com
60
60
  apiKey : abcd****1234
61
61
  ```
62
62
 
@@ -6,7 +6,7 @@
6
6
 
7
7
  用 `siluzan-tso config show` 读取 **`webUrl`**,再拼接路径:
8
8
 
9
- 首页地址:`https://www.siluzan.com/v3/foreign_trade/tso/home`
9
+ 首页地址:`https://www-ci.siluzan.com/v3/foreign_trade/tso/home`
10
10
 
11
11
  > 若用户已登录 TSO,也可从左侧菜单进入「首页」。
12
12
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "siluzan-tso-cli",
3
- "version": "1.1.7",
3
+ "version": "1.1.8-beta.1",
4
4
  "description": "Siluzan 广告账户管理 CLI — 查询账户、余额、消耗数据,管理绑定关系与充值。",
5
5
  "type": "module",
6
6
  "bin": {