@wkgeo/cli 1.1.4 → 1.1.5

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/CHANGELOG.md CHANGED
@@ -4,7 +4,20 @@
4
4
 
5
5
  ---
6
6
 
7
- ## 未发布 · 2026-11-10
7
+ ## 1.1.5 · 2026-11-17
8
+
9
+ **`orders create` 改调账务域**(`/cli` 白名单转发 → `wkgeo-billing` 的 `orderCreate{kind:'quota'}`)。
10
+
11
+ - 不再打 `/order` 的 `createQuotaOrder`:下单 / 计价 / 履约(余额扣减、收银台、`pay_token`)
12
+ 只剩账务域一条实现,金额仍**只从服务端商品价**取,前端不传任何金额。
13
+ - 每次执行生成**新的幂等键**(`^[A-Za-z0-9_-]{8,80}$`):同键重放回原单、不会多建单;
14
+ 同键换参数服务端回 409,CLI 现在把它翻成人话("这一单已经创建…去我的订单付款"),
15
+ 不再落到笼统的「未知错误(code=409)」。
16
+ - 命令面、参数、输出字段一字未变(`--product/--units/--quota/--amount/--allow-wechat`)。
17
+
18
+ ---
19
+
20
+ ## 1.1.4 · 2026-11-10
8
21
 
9
22
  **新增 `data` 命令组(数据交换,全部只读)**:`wkgeo data chat|stats|usage`。
10
23
 
package/README.md CHANGED
@@ -510,7 +510,7 @@ wkgeo login --device-continue --json
510
510
  | `notify list` | **我的消息**:未读数 + 列表(未读置顶;只读 `listMyNotifications`) | `--limit`(1~50,默认 20)、`--offset` |
511
511
  | `notify read` | 把一条消息标为已读(**默认 dry-run**,`--confirm` 才真发;幂等,已读过回 `updated:0`) | `<消息ID>`(**纯数字**)、`--confirm` |
512
512
  | `invoices list` | **我的开票**:可开票订单(合计金额)+ 我的开票申请(状态/抬头/税号/开票时间)两张表(只读;**不含开票 / 取消开票**,那是会员端的活) | `--limit`(1~100) |
513
- | `plans list` | **套餐目录**(四张小表):订阅套餐(含各周期价)/ 站点续费价 / 加量包套餐 / 我已买的加量包;只列在售(`status=active`) | `--no-bundles`(跳过加量包那两块,少两次请求) |
513
+ | `plans list` | **套餐目录**(三张小表):订阅套餐(含各周期价)/ 加量包套餐 / 我已买的加量包;只列在售(`status=active`) | `--no-bundles`(跳过加量包那两块,少两次请求) |
514
514
  | `products list` | 能买什么(找 `--product` 该填什么) | — |
515
515
  | `orders create` | 下单(**余额够就当场用钱包付清**) | `--product <代码>` + `--units <份数>`,或 `--quota <键>` + `--amount <数量>`;`--allow-wechat` |
516
516
  | `orders check` | 查支付结果(微信侧已付则就地履约)+ 最新余额 | `<订单ID>` |
package/SKILL.md CHANGED
@@ -34,7 +34,7 @@ version: 1.0.0
34
34
  * 用户说"**我有哪些券**"/"这张单能用哪张券" → `coupons`(全部)/ `coupons --usable --kind subscribe --amount-cents 2990`(这笔单能用的券 + 预览)
35
35
  * 用户说"**我有什么消息**"/"帮我标已读" → `notify list` / `notify read <消息ID> --confirm`(⚠️ 不带 `--confirm` 只 dry-run,不会真标)
36
36
  * 用户说"**我要开票**"/"能开哪些单" → `invoices list`(只读;**开票动作在会员端**,CLI 不做)
37
- * 用户说"**有哪些套餐 / 多少钱**" → `plans list`(订阅套餐 / 站点续费价 / 加量包套餐 / 我已买的加量包)
37
+ * 用户说"**有哪些套餐 / 多少钱**" → `plans list`(订阅套餐 / 加量包套餐 / 我已买的加量包)
38
38
  * 用户说"**我删掉的站还能恢复吗**"/"回收站" → `sites recycle` → `sites recycle restore <站点ID> --confirm`(⚠️ 不带 `--confirm` 只 dry-run)
39
39
  * 用户说"**改一下站名**" → `sites update <站点ID> --name <新站名> --confirm`(⚠️ 只有站名能改;`--remark` 服务端还不支持)
40
40
  * 用户说"**我的订单**"/"订单状态" → `orders list` / `orders get` / `orders check`
@@ -142,7 +142,7 @@ npx -y @wkgeo/cli@latest skill > SKILL.md # 直接落一份到本地,离线
142
142
  | `notify list` | 我的消息(未读数 + 列表) | `--limit`(1~50)、`--offset` |
143
143
  | `notify read` | 把一条消息标已读(**默认 dry-run**,`--confirm` 才真发;幂等) | `<消息ID>`(纯数字)、`--confirm` |
144
144
  | `invoices list` | 我的开票:可开票订单 + 我的开票申请两张表(只读;**不含开票动作**) | `--limit` |
145
- | `plans list` | 套餐目录四张小表:订阅套餐 / 站点续费价 / 加量包套餐 / 我已买的加量包 | `--no-bundles` |
145
+ | `plans list` | 套餐目录三张小表:订阅套餐 / 加量包套餐 / 我已买的加量包 | `--no-bundles` |
146
146
  | `products list` | 能买什么 | — |
147
147
  | `orders create` | 下单(余额够**当场付清**) | `--product <代码>` `--units <份数>`(或 `--quota <键>` `--amount <数量>`)`--allow-wechat` |
148
148
  | `orders check` | 查支付结果 + 最新余额 | `<订单ID>` |
package/lib/api.mjs CHANGED
@@ -38,6 +38,10 @@ import { classifyResponse, toCliError, networkError, CliError } from './errors.m
38
38
  * —— 与 data 的 47 条映射(29 user + 14 order + 4 domain)等价。
39
39
  *
40
40
  * ⚠️ 加新 action 时:先确认它属于哪个函数,不在这两个集合里就当 user(user 会回"未知操作",与以前 data 的行为一致)。
41
+ *
42
+ * ★ 2026-11-17(task-627):**下单已改调账务域** `billing.orderCreate`(网关 `/billing-core`),
43
+ * 由 `wkgeo-cli-fc` 白名单转发。所以 `orderCreate` **故意不在这张表里**:
44
+ * 老 `/order` 从来没有这个动作,逃生阀也回不到它 —— `fnOf()` 里单独把它钉在 `cli`。
41
45
  */
42
46
  const FN_ORDER = new Set([
43
47
  'createRechargeOrder',
@@ -161,6 +165,11 @@ export function fnOf(action, { legacy = legacyEndpointsEnabled() } = {}) {
161
165
  if (FN_FORM.has(action)) return 'form';
162
166
  if (FN_MEMBER.has(action)) return 'member';
163
167
  if (FN_CHANNEL.has(action)) return 'channel';
168
+ /**
169
+ * ★ 2026-11-17(task-627):账务域下单**只在 `/cli` 后面**(cli-fc 再转发到 `/billing-core`)。
170
+ * 逃生阀也回不去:`/order` 没有 `orderCreate` 这个动作,`/user` 更没有。
171
+ */
172
+ if (action === 'orderCreate') return 'cli';
164
173
  if (legacy) {
165
174
  if (FN_ORDER.has(action)) return 'order';
166
175
  if (FN_DOMAIN.has(action)) return 'domain';
@@ -337,7 +346,11 @@ export const ACTIONS = {
337
346
  billing: 'getMyBilling',
338
347
  },
339
348
  orders: {
340
- createQuota: 'createQuotaOrder',
349
+ /**
350
+ * ★ 2026-11-17(task-627):下单 = `billing.orderCreate`(账务域),
351
+ * payload 必须带 `kind`(CLI 只用 `'quota'`)。旧的 `createQuotaOrder` 不再调用。
352
+ */
353
+ createQuota: 'orderCreate',
341
354
  check: 'checkOrder',
342
355
  list: 'listMyOrders',
343
356
  cancel: 'cancelOrder',
@@ -1658,7 +1658,7 @@ function publishSiteOrThrow(ctx) {
1658
1658
  const PUBLISH_NO_CUSTOM_DOMAIN_MESSAGE =
1659
1659
  '当前站点使用平台预览地址,内容实时生效,无需发布;请绑定自有域名后再发布';
1660
1660
 
1661
- /** 认「有自有域名」的 hostname_kind(与 CMS 的 SITE_PRIMARY_DOMAIN_SQL 一致,custom > root > other) */
1661
+ /** 认「有自有域名」的 kind(与 CMS 的 SITE_PRIMARY_DOMAIN_SQL 一致,custom > root > other) */
1662
1662
  const PUBLISH_CUSTOM_DOMAIN_KINDS = ['custom', 'root', 'other'];
1663
1663
 
1664
1664
  /** 站点行 / 域名接口上「客户自有域名」的候选列(平台面 custom_domain / CMS 面 cms_domain / 老列 domain) */
@@ -1681,7 +1681,7 @@ function publishVerifiedDomainOf(payload) {
1681
1681
  (one) =>
1682
1682
  one &&
1683
1683
  String(one.verify_status || '').toLowerCase() === 'verified' &&
1684
- String(one.hostname_kind || '').toLowerCase() === kind,
1684
+ String(one.kind || '').toLowerCase() === kind,
1685
1685
  );
1686
1686
  if (hit && String(hit.hostname || '').trim()) return String(hit.hostname).trim().toLowerCase();
1687
1687
  }
@@ -535,7 +535,7 @@ export const siteCreateCommand = {
535
535
  const c = data.closeout || {};
536
536
  out.head(`建站完成:${data.name || flags.name}`);
537
537
  out.line(` 站点 id:${data.site_id || data.id || '—'}`);
538
- out.line(` 池位:${c.set_code || '—'}(${c.pool_id || '—'}) 短域:${c.prefix_host || '—'}`);
538
+ out.line(` 短域:${c.prefix_host || '—'}`);
539
539
  out.line(` host KV:${c.kv ? (c.kv.verified ? `已验证(${c.kv.via})` : '未验证') : '—'}`);
540
540
  if (c.ok) out.ok(`短域可直接访问:${c.prefix_url || `https://${c.prefix_host}`}`);
541
541
  else out.warn(`收口未完成:${c.code || ''} ${c.message || ''}`.trim());
@@ -461,7 +461,7 @@ const GROUP_SUMMARY = {
461
461
  coupons: '优惠券:我的券(可按状态筛)/ `--usable` 看某笔订单能用的券与抵扣预览(只读,不含核销)',
462
462
  notify: '我的消息:列表(未读数置顶)/ 标已读(写,默认 dry-run,`--confirm` 才真发)',
463
463
  invoices: '我的开票:可开票订单 + 我的开票申请(只读;开票动作留在会员端)',
464
- plans: '套餐目录:订阅套餐 / 站点续费价 / 加量包套餐 / 我已买的加量包(只读,四块小表)',
464
+ plans: '套餐目录:订阅套餐 / 加量包套餐 / 我已买的加量包(只读,三块小表)',
465
465
  site: '站点:选站 / 建站 / 公司信息 / 域名巡检重检 / 示例内容 / 站级同步(写要 site:write,默认 dry-run)',
466
466
  domain: '域名:绑自有域名 / 看开通进度 / 取解析清单 / 查可用性(购买与解析读写见 domain search / zone / esa)',
467
467
  lang: '站点语言:列表 / 新增或修改 / 设默认 / 删除 / 启用停用(写要 site:write,默认 dry-run)',
@@ -523,7 +523,7 @@ export const sitesRecycleCommand = {
523
523
  [
524
524
  { title: '站点', key: 'name', width: 24 },
525
525
  { title: '域名', key: 'domains', width: 30, format: (v, row) => domainsText(row) },
526
- { title: '删除时间', key: 'deleted_at', width: 20, format: TIME },
526
+ { title: '删除时间', key: 'offline_at', width: 20, format: TIME },
527
527
  { title: '到期时间', key: 'expires_at', width: 20, format: TIME },
528
528
  { title: '站点 ID', key: 'id', width: 36 },
529
529
  ],
@@ -573,12 +573,9 @@ export const sitesRecycleRestoreCommand = {
573
573
  const data = {
574
574
  id: src.id || id,
575
575
  restored: src.restored !== false,
576
- pool: src.pool || null,
577
576
  };
578
577
  if (!out.json) {
579
578
  out.ok(`站点已还原:${data.id}`);
580
- const pool = data.pool && typeof data.pool === 'object' ? data.pool : null;
581
- if (pool && (pool.pool_id || pool.id)) out.line(` 资源池:${pool.pool_id || pool.id}`);
582
579
  }
583
580
  ctx.done(data);
584
581
  return data;
@@ -674,40 +671,80 @@ export const invoicesListCommand = {
674
671
 
675
672
  /* ════════════════════════════ ⑦ plans list ════════════════════════════ */
676
673
 
677
- /** 套餐的价格数组 → 一行文本:`1 个月 ¥29.90 / 12 个月 ¥299.00` */
674
+ /** 像「时长」的档位标签(`1 年` / `7 天` / `2 年(24 个月)`);不像就**不**拿它当时长用 */
675
+ const DURATION_LABEL_RE = /^\d+\s*(?:天|日|个月|月|年)/;
676
+
677
+ /**
678
+ * ★ 2026-11-16 task-528:时长文案统一入口。
679
+ *
680
+ * 为什么不能一律写「N 个月」:`bundle_price.months` 是**时长档里的数量**,单位在
681
+ * `unit`(`day` / `month` / `year`)—— `basic` 的三档是 **1 / 2 / 3 年**,按「个月」读
682
+ * 会说成「1 / 2 / 3 个月」,客户看到的档位就是错的。
683
+ * 取值顺序:① 服务端下发的 `duration_text`(「7 天」「1 年」,与下单计价同一份实现
684
+ * `_shared/bundle-term-policy.js`)→ ② 档位标签 `label`(管理员填的展示文案,且必须**长得像时长**)
685
+ * → ③ 按 `unit + months` 拼 → ④ 最后才按 `month` 降级。纯展示,不参与任何计价。
686
+ */
687
+ function termTextOf(t) {
688
+ const row = t && typeof t === 'object' ? t : {};
689
+ const text = String(row.duration_text === null || row.duration_text === undefined ? '' : row.duration_text).trim();
690
+ if (text) return text;
691
+ const label = String(row.label === null || row.label === undefined ? '' : row.label).trim();
692
+ if (DURATION_LABEL_RE.test(label)) return label;
693
+ const months = Number(row.months);
694
+ if (!Number.isFinite(months) || months <= 0) return dash(row.months);
695
+ const unit = String(row.unit === null || row.unit === undefined ? '' : row.unit).trim().toLowerCase();
696
+ if (unit === 'year') return `${months} 年`;
697
+ if (unit === 'day') return `${months} 天`;
698
+ return `${months} 个月`;
699
+ }
700
+
701
+ /**
702
+ * 档价文案:**生效价**(`price_cents`,后端按 `bundle_price` 算出)优先,
703
+ * 其次老的 `price_cents_month`,两者都没有才是「面议」。
704
+ *
705
+ * 为什么不再固定读 `price_cents_month`:那列是**每等价月的价**,按年 / 按天卖的档位
706
+ * 上恒为 NULL ⇒ 以前一律读它,`basic`(年档)全档显示成「面议」。
707
+ */
708
+ function termPriceTextOf(t) {
709
+ const row = t && typeof t === 'object' ? t : {};
710
+ const cents = Number(row.price_cents);
711
+ if (Number.isFinite(cents) && cents > 0) return formatMoney(cents);
712
+ const monthCents = Number(row.price_cents_month);
713
+ if (Number.isFinite(monthCents) && monthCents > 0) return formatMoney(monthCents);
714
+ return '面议';
715
+ }
716
+
717
+ /** 各周期价格数组 → 一行文本:`1 年 ¥368.00 / 2 年 ¥577.00` */
678
718
  function priceListText(prices) {
679
719
  const list = Array.isArray(prices) ? prices : [];
680
720
  if (!list.length) return '-';
681
- return list
682
- .map((p) => `${dash(p.months)} 个月 ${formatMoney(p.price_cents)}`)
683
- .join(' / ');
721
+ return list.map((p) => `${termTextOf(p)} ${termPriceTextOf(p)}`).join(' / ');
684
722
  }
685
723
 
686
724
  /**
687
- * 套餐目录(四块一起看,**默认全取**):
725
+ * 套餐目录(三块一起看,**默认全取**):
688
726
  * ① `listPlans` —— 订阅套餐 + 各周期价格(active)
689
- * ② `listSitePrices` —— 站点续费价(按周期)
690
- * ③ `listBundlePlans` —— 加量包套餐(含/加量项 + 各周期单价)
691
- * ④ `listBundles` —— 我已买的加量包(旧 plan 模型,含下架件)
727
+ * ② `listBundlePlans` —— 加量包套餐(含/加量项 + 各周期单价)
728
+ * ③ `listBundles` —— 我已买的加量包(旧 plan 模型,含下架件)
692
729
  *
693
- * 为什么四块都用**独立小表**:`plan` / `site_price` / `bundle` / `bundle_plan` 是四张表、
694
- * 四套字段(价格字段名都不一样:`price_cents` / `base_price_cents` / `price_cents_month`),
695
- * 硬合成一张宽表只会满屏 `-`。`--no-bundles` 可以只取前两块。
730
+ * 为什么三块都用**独立小表**:`plan` / `bundle` / `bundle_plan` 是三张表、
731
+ * 三套字段(价格字段名都不一样:`price_cents` / `base_price_cents` / `price_cents_month`),
732
+ * 硬合成一张宽表只会满屏 `-`。`--no-bundles` 可以只取第一块。
696
733
  */
697
734
  export const plansListCommand = {
698
735
  name: 'plans list',
699
- summary: '套餐目录:订阅套餐 / 站点价格 / 加量包套餐 / 我已买的加量包',
736
+ summary: '套餐目录:订阅套餐 / 加量包套餐 / 我已买的加量包',
700
737
  usage: 'wkgeo plans list [--no-bundles]',
701
738
  args: [],
702
739
  flags: {
703
740
  bundles: {
704
741
  type: 'boolean',
705
- desc: '取加量包那两块(默认取;`--no-bundles` 只取套餐与站点价格)',
742
+ desc: '取加量包那两块(默认取;`--no-bundles` 只取套餐)',
706
743
  },
707
744
  },
708
745
  examples: ['wkgeo plans list', 'wkgeo plans list --no-bundles', 'wkgeo plans list --json'],
709
746
  notes: [
710
- '只读(`billing:self` / `site:read`),四块分别是四次查询;`--no-bundles` 省掉后两次。',
747
+ '只读(`billing:self` / `site:read`),三块分别是三次查询;`--no-bundles` 省掉后两次。',
711
748
  '只列**在售**(`status=active`):下架的套餐 / 加量包不会出现。`listBundles` 例外 —— 管理员能看到自己名下的下架件。',
712
749
  '下单不在这条命令里:订阅 `wkgeo orders create`、加量包走报价单接口(CLI 暂未开放)。',
713
750
  ],
@@ -716,18 +753,15 @@ export const plansListCommand = {
716
753
  const withBundles = flags.bundles !== false;
717
754
 
718
755
  const plans = await ctx.callData('listPlans', {});
719
- const sitePrices = await ctx.callData('listSitePrices', {});
720
756
  const bundlePlans = withBundles ? await ctx.callData('listBundlePlans', {}) : null;
721
757
  const bundles = withBundles ? await ctx.callData('listBundles', {}) : null;
722
758
 
723
759
  const planRows = plans && Array.isArray(plans.rows) ? plans.rows : [];
724
- const priceRows = sitePrices && Array.isArray(sitePrices.rows) ? sitePrices.rows : [];
725
760
  const bundlePlanRows = bundlePlans && Array.isArray(bundlePlans.rows) ? bundlePlans.rows : [];
726
761
  const bundleRows = bundles && Array.isArray(bundles.rows) ? bundles.rows : [];
727
762
 
728
763
  const data = {
729
764
  plans: plans && typeof plans === 'object' ? plans : {},
730
- site_prices: sitePrices && typeof sitePrices === 'object' ? sitePrices : {},
731
765
  };
732
766
  if (withBundles) {
733
767
  data.bundle_plans = bundlePlans && typeof bundlePlans === 'object' ? bundlePlans : {};
@@ -762,29 +796,21 @@ export const plansListCommand = {
762
796
  planRows,
763
797
  );
764
798
 
765
- out.head(`站点续费价格 · ${priceRows.length} 档`);
766
- out.table(
767
- [
768
- { title: '周期', key: 'months', width: 8, format: (v) => `${dash(v)} 个月` },
769
- { title: '价格', key: 'price_cents', width: 12, format: (v) => formatMoney(v) },
770
- { title: '原价', key: 'original_cents', width: 12, format: (v) => (v ? formatMoney(v) : '-') },
771
- { title: '标签', key: 'label', width: 16 },
772
- ],
773
- priceRows,
774
- );
775
-
776
799
  if (withBundles) {
777
800
  out.head(`加量包套餐 · ${bundlePlanRows.length} 个`);
801
+ /**
802
+ * ⚠️ ★ 2026-11-16 task-528(老板 2026-11-16 拍板「删一列比显示错的好」):
803
+ * **不再列「基础价」(`bundle.base_price_cents`)**。
804
+ *
805
+ * 那一列是旧「月价」模型的基础月价(`basic` = ¥180.60/月),与在售档价
806
+ * (`basic` ¥368/年 ≈ ¥30.7/月)差一个量级,既不是客户能买的价格,也不参与本次任何计价;
807
+ * 「各周期」列已经把**真实生效价**按档列全了 ⇒ 显示它只会误导。
808
+ * 基础月价要不要与在售档价对齐(改数据)属定价口径,由老板定;在那之前**不展示**。
809
+ */
778
810
  out.table(
779
811
  [
780
812
  { title: '套餐', key: 'name', width: 22 },
781
813
  { title: '代码', key: 'code', width: 16 },
782
- {
783
- title: '基础价',
784
- key: 'base_price_cents',
785
- width: 12,
786
- format: (v) => formatMoney(v),
787
- },
788
814
  {
789
815
  title: '含项',
790
816
  key: 'included',
@@ -797,14 +823,10 @@ export const plansListCommand = {
797
823
  {
798
824
  title: '各周期',
799
825
  key: 'terms',
800
- width: 34,
826
+ width: 40,
801
827
  format: (v) =>
802
828
  Array.isArray(v) && v.length
803
- ? v
804
- .map((t) =>
805
- `${t.months} 个月 ${t.price_cents_month === null ? '面议' : formatMoney(t.price_cents_month)}`,
806
- )
807
- .join(' / ')
829
+ ? v.map((t) => `${termTextOf(t)} ${termPriceTextOf(t)}`).join(' / ')
808
830
  : '-',
809
831
  },
810
832
  ],
@@ -812,15 +834,47 @@ export const plansListCommand = {
812
834
  );
813
835
 
814
836
  out.head(`我已买的加量包 · ${bundleRows.length} 个`);
837
+ /**
838
+ * ★ 2026-11-16 task-528:**不再读 `bundle.price_cents` / `bundle.period_months`**。
839
+ *
840
+ * 那两列是旧「月价」模型的遗留值(`basic` / `trial_7d` 都停在 ¥180.60、`period_months`
841
+ * 为 null),既不是在售档价也不对应任何能买的东西。
842
+ * 档价按「目录价优先、本行 prices 兜底」展示:
843
+ * · 目录(`listBundlePlans`)按商品档价**实时算**出各档生效价(`basic` = ¥368 / ¥577 / ¥786);
844
+ * · `bundle_price.price_cents` 只是**手填快照**(`basic` 停在 ¥400.10,与生效价不同)
845
+ * ⇒ 只在下架件(不在目录里)时兜底,免得给"买不到的东西"假装报一个现价。
846
+ * ⚠️ 只改展示:不碰库、不碰计价(金额仍由服务端 `bundle-pricing` 算)。
847
+ */
848
+ const catalogTermsByCode = new Map();
849
+ for (const r of bundlePlanRows) {
850
+ const code = String((r && r.code) || '').trim();
851
+ if (code && Array.isArray(r.terms) && r.terms.length) catalogTermsByCode.set(code, r.terms);
852
+ }
853
+ const bundleDisplayRows = bundleRows.map((r) => {
854
+ const code = String((r && r.code) || '').trim();
855
+ const catalogTerms = catalogTermsByCode.get(code);
856
+ return {
857
+ ...r,
858
+ terms_display: Array.isArray(catalogTerms)
859
+ ? catalogTerms
860
+ : Array.isArray(r && r.prices)
861
+ ? r.prices
862
+ : [],
863
+ };
864
+ });
815
865
  out.table(
816
866
  [
817
867
  { title: '名称', key: 'name', width: 22 },
818
868
  { title: '代码', key: 'code', width: 16 },
819
869
  { title: '状态', key: 'status', width: 10 },
820
- { title: '周期', key: 'period_months', width: 8, format: (v) => (v ? `${v} 个月` : '-') },
821
- { title: '价格', key: 'price_cents', width: 12, format: (v) => (v ? formatMoney(v) : '-') },
870
+ {
871
+ title: '各周期',
872
+ key: 'terms_display',
873
+ width: 40,
874
+ format: (v) => priceListText(v),
875
+ },
822
876
  ],
823
- bundleRows,
877
+ bundleDisplayRows,
824
878
  );
825
879
  }
826
880
  }
@@ -841,7 +895,6 @@ export const plansListCommand = {
841
895
  * (★ 2026-11-11 task-85:`status` 已移出白名单,显式传会回 400 `STATUS_NOT_EDITABLE`,
842
896
  * 上下架走 `siteOffline` / `siteOnline`)
843
897
  * —— 没有 remark;`public.site` 表里也没有这一列(remark 只存在于 customer / wallet_txn /
844
- * user_debt / invoice_request / site_quota_purchase 这些别的表)。
845
898
  * 白名单外的 key 会被**静默忽略**,所以"传了就返回成功"是假成功。与其假装能改备注,
846
899
  * 不如明确报错 —— 要支持它得后端先加列 + 加白名单,那是另一个任务。
847
900
  * (也**不**用 `settings.remark` 变通:`settings` 是整块覆盖,读-改-写会吞掉原有设置。)
@@ -22,6 +22,20 @@ import { UsageError, CliError, EXIT } from '../errors.mjs';
22
22
  import { formatMoney, formatTime } from '../format.mjs';
23
23
  import { renderQrOptional } from '../qr.mjs';
24
24
 
25
+ /**
26
+ * 下单幂等键(★ 2026-11-17 task-627)。
27
+ *
28
+ * 服务端 `billing.orderCreate` 的口径:**同一键同一单**(重放回原单,含新的收银台令牌);
29
+ * 同键带不同参数回 409。CLI 不自动重试(`api.mjs` 约定),所以这里只保证
30
+ * 「每次执行 = 一次新尝试 = 一个新键」,绝不会把两次不同的购买合成一张单。
31
+ * 格式受服务端硬约束:`^[A-Za-z0-9_-]{8,80}$`。
32
+ */
33
+ function newOrderIdempotencyKey() {
34
+ const rand = Math.random().toString(36).slice(2, 11);
35
+
36
+ return `cli-quota-${Date.now().toString(36)}-${rand}`;
37
+ }
38
+
25
39
  /* ------------------------------------------------------------------ */
26
40
  /* products list */
27
41
  /* ------------------------------------------------------------------ */
@@ -180,7 +194,19 @@ export const ordersCreateCommand = {
180
194
  );
181
195
  }
182
196
 
183
- const res = await ctx.callData('createQuotaOrder', { quota_key: quotaKey, quota_amount: quotaAmount });
197
+ /**
198
+ * ★ 2026-11-17(task-627):下单**改调账务域** ——
199
+ * `/cli` → `wkgeo-cli-fc` 白名单转发 → `billing.orderCreate{kind:'quota'}`(网关 `/billing-core`)。
200
+ * 不再打 `/order` 的 `createQuotaOrder`(钱路径只留 billing 一条:
201
+ * `placeOrder` + `fulfillOrder`,金额只从 `product.price_cents` 算)。
202
+ * ⚠️ 必须带 `idempotency_key`:同键重放回原单(不会多建单、不会二次扣余额)。
203
+ */
204
+ const res = await ctx.callData('orderCreate', {
205
+ kind: 'quota',
206
+ quota_key: quotaKey,
207
+ quota_amount: quotaAmount,
208
+ idempotency_key: newOrderIdempotencyKey(),
209
+ });
184
210
  const paid = !!(res && res.paid);
185
211
  const data = {
186
212
  order_id: (res && res.order_id) || null,
@@ -614,7 +614,7 @@ export const domainRecordsCommand = {
614
614
  ],
615
615
  domains.map((one) => ({
616
616
  hostname: one.hostname || '',
617
- kind: one.hostname_kind || one.kind || '',
617
+ kind: one.kind || '',
618
618
  verify: one.verify_status || '',
619
619
  txt: dnsStateLabel(one.dns_txt && one.dns_txt.ok),
620
620
  cname: dnsStateLabel(one.dns_cname && one.dns_cname.ok),
@@ -732,7 +732,6 @@ export const sitesGetCommand = {
732
732
  if (detail.cert_status || detail.cert_not_after) {
733
733
  out.line(` 证书:${detail.cert_status || '-'}${detail.cert_not_after ? `(到期 ${formatTime(detail.cert_not_after)})` : ''}`);
734
734
  }
735
- if (detail.pool_id) out.line(` 计费池:${detail.pool_id}`);
736
735
  if (detail.provision_attempts) out.line(` 开通尝试:${detail.provision_attempts} 次`);
737
736
  out.line(` 创建时间:${formatTime(site.created_at)}${detail.updated_at ? ` · 更新时间:${formatTime(detail.updated_at)}` : ''}`);
738
737
  if (detail.last_error) out.warn(`最近一次错误:${detail.last_error}${detail.last_error_at ? `(${formatTime(detail.last_error_at)})` : ''}`);
@@ -1325,6 +1325,13 @@ export const templatesPullCommand = {
1325
1325
  out.ok(
1326
1326
  `已拉取 ${r.fileCount} 个文件(${fmtBytes(r.bytes)}${r.binaryCount ? `,其中二进制 ${r.binaryCount}` : ''})→ ${r.dir}`,
1327
1327
  );
1328
+ if (r.skipped && r.skipped.length) {
1329
+ for (const one of r.skipped) {
1330
+ out.warn(
1331
+ `跳过超限文件 ${one.path}(${one.measured}${one.reason === 'binary-bytes' ? ' 字节' : ' 字符'}):大体积演示资产不进站点模板副本,其余文件照常同步`,
1332
+ );
1333
+ }
1334
+ }
1328
1335
  out.info(`模板:${r.template.name || '-'}(key ${r.template.key || '-'} · id ${r.template.id || '-'})`);
1329
1336
  out.info(`manifest:${r.manifestPath}(contentHash ${r.contentHash.slice(0, 12)}…)`);
1330
1337
  out.table(
@@ -1344,6 +1351,8 @@ export const templatesPullCommand = {
1344
1351
  binary_count: r.binaryCount,
1345
1352
  bytes: r.bytes,
1346
1353
  files: r.files,
1354
+ skipped: r.skipped || [],
1355
+ warnings: r.warnings || [],
1347
1356
  next: 'wkgeo templates push --dir <目录> --dry-run',
1348
1357
  });
1349
1358
  },
@@ -1403,6 +1412,7 @@ export const templatesPushCommand = {
1403
1412
  template: r.template,
1404
1413
  plan: r.plan,
1405
1414
  warnings: r.warnings,
1415
+ skipped: r.skipped || [],
1406
1416
  applied: r.applied === true,
1407
1417
  written: r.written,
1408
1418
  content_hash: r.contentHash || null,
package/lib/errors.mjs CHANGED
@@ -264,6 +264,37 @@ export function classifyResponse({ httpStatus = 200, body = null, action = '', r
264
264
  });
265
265
  }
266
266
  if (codeNum === 404) return bad('not_found', message || '资源不存在', { code: 404 });
267
+ /**
268
+ * ★ 2026-11-17(task-627):**409 = 状态冲突**(下单打进来才有,之前落到 `unknown`)。
269
+ *
270
+ * 两种要分开:
271
+ * · `idempotency_mismatch` —— 同一幂等键的参数与已建订单不一致(**这一单其实已经建好了**)。
272
+ * 服务端原文带实现词 `idempotency_key`,**不能照抄给用户**,翻成"别重复下单 + 怎么继续付";
273
+ * · 其余(`ICP_ASSIST_OPEN_ORDER_EXISTS` 还有未完成服务单 / `VIP_ALREADY_ACTIVE` 仍在有效期)
274
+ * 后端文案本身就是人话 ⇒ 原样透出,只补一句下一步。
275
+ */
276
+ if (codeNum === 409) {
277
+ const biz = String(
278
+ (body && (body.error_code || (body.data && body.data.code))) || '',
279
+ );
280
+ if (biz === 'idempotency_mismatch' || /idempotency/i.test(message)) {
281
+ return bad(
282
+ 'conflict',
283
+ '这一单已经创建,请不要重复下单:订单 30 分钟内未支付会自动关闭(优惠券随之释放),' +
284
+ '关闭后再重新下单即可;也可以在网页「我的订单」里继续支付。',
285
+ {
286
+ code: 409,
287
+ hint:
288
+ `先 \`${cmdName} orders list\` 看这一单在不在;待支付就去网页收银台付,` +
289
+ `或 \`${cmdName} orders pay <订单号>\` 查一次状态。**不要**换个参数再下一单(会锁券、留多张待支付单)。`,
290
+ },
291
+ );
292
+ }
293
+ return bad('conflict', message || '该操作与当前状态冲突,请刷新后重试', {
294
+ code: 409,
295
+ hint: '按提示处理后再试;不要靠重复下单绕过(会锁券 / 留下多张待支付单)。',
296
+ });
297
+ }
267
298
  if (codeNum === 400) {
268
299
  // 内容类自持动作没带站点(`content-core.js` 的「缺少 siteId:CLI 内容动作必须指定站点…」)
269
300
  if (/缺少 siteId|指定站点/.test(message)) {
@@ -112,7 +112,6 @@ function siteBrief(row) {
112
112
  name: one.name || '',
113
113
  status: one.status || null,
114
114
  owner_user_id: one.owner_user_id || one.owner_id || null,
115
- pool_id: one.pool_id || null,
116
115
  prefix_host: prefixHost || null,
117
116
  prefix_url: one.prefix_url || (prefixHost ? `https://${prefixHost}/` : null),
118
117
  };
@@ -419,7 +418,7 @@ export async function runSiteCreate(ctx, flags) {
419
418
  hint: '用 `wkgeo sites list` 确认是否已经建出来了;刚建出来但没有 id 属服务端异常。',
420
419
  });
421
420
  }
422
- record('create_site', { site_id: site.id, prefix_host: site.prefix_host, pool_id: site.pool_id, region });
421
+ record('create_site', { site_id: site.id, prefix_host: site.prefix_host, region });
423
422
  if (!json) {
424
423
  out.ok(`站点已创建:${site.name || name}`);
425
424
  say(`站点 ID:${site.id}`);
@@ -42,6 +42,35 @@ export const MANIFEST_VERSION = 1;
42
42
  /** 服务端 `templateMaxBytes = 400 * 1024`(**按字符**算);二进制按字节同口径兜住 */
43
43
  export const MAX_FILE_CHARS = 400 * 1024;
44
44
  export const MAX_FILE_BYTES = 400 * 1024;
45
+ /**
46
+ * 超限文件 = **不该进站点模板副本的大体积演示资产**(three.min.js / 大图等)。
47
+ *
48
+ * ⚠️ 2026-11-14 task-107:以前拉 / 推遇到超限文件**整包直接失败**,结果是
49
+ * 「库里本来就有的大文件把整站的拉/推全堵死」——base 站 `assets/vendor/three-0.147.0/three.min.js`
50
+ * (607784 字符)与闵航站 `home.jpg`(538619 字节)就是这样堵住的,其余几十个小文件一个都推不上去。
51
+ * 现在改成:**跳过这一个文件 + 告警**,其余文件照常拉 / 推;上限本身**不调大**(避免整站模板过大)。
52
+ */
53
+ export function oversizeOf(filePath, buf) {
54
+ const rel = String(filePath || '');
55
+ const text = Buffer.isBuffer(buf) ? buf : Buffer.from(String(buf === undefined || buf === null ? '' : buf), 'utf8');
56
+ if (isBinaryPath(rel)) {
57
+ if (text.length > MAX_FILE_BYTES) return { reason: 'binary-bytes', measured: text.length, limit: MAX_FILE_BYTES };
58
+ return null;
59
+ }
60
+ const chars = text.toString('utf8').length;
61
+ if (chars > MAX_FILE_CHARS) return { reason: 'text-chars', measured: chars, limit: MAX_FILE_CHARS };
62
+ return null;
63
+ }
64
+
65
+ /** 超限告警文案(拉 / 推共用;不打印正文) */
66
+ export function oversizeWarning(rel, one) {
67
+ const unit = one.reason === 'binary-bytes' ? '字节' : '字符';
68
+ return (
69
+ `跳过超限文件 ${rel}(${one.measured} ${unit},上限 ${one.limit}):大体积演示资产不进站点模板副本,` +
70
+ '其余文件照常同步;要放它请走素材库 / 母版引用'
71
+ );
72
+ }
73
+
45
74
  /** 路径上限:对齐 `template-files.js` 的 `TEMPLATE_FILE_MAX_PATH_CHARS` / 每段 64 字符 */
46
75
  export const MAX_PATH_CHARS = 200;
47
76
  export const MAX_SEGMENT_CHARS = 64;
@@ -285,24 +314,17 @@ export async function pullTemplate({
285
314
 
286
315
  const at = now().toISOString();
287
316
  const files = [];
317
+ const skipped = [];
288
318
  let binaryCount = 0;
289
319
  let totalBytes = 0;
290
320
  for (const raw of remoteFiles) {
291
321
  const rel = assertSafePath(raw.path);
292
322
  const buf = entryBytes({ ...raw, path: rel });
293
323
  const binary = isBinaryPath(rel);
294
- if (binary) {
295
- if (buf.length > MAX_FILE_BYTES) {
296
- throw new CliError(`第 ${files.length + 1} 个模板文件太大:${rel}(${buf.length} 字节,上限 ${MAX_FILE_BYTES})`, {
297
- kind: 'file_too_large',
298
- hint: '把这张图/字体压缩后再放回来;模板里的大文件建议走素材库(assets upload)',
299
- });
300
- }
301
- } else if (buf.toString('utf8').length > MAX_FILE_CHARS) {
302
- throw new CliError(`第 ${files.length + 1} 个模板文件太长:${rel}(${buf.toString('utf8').length} 字符,上限 ${MAX_FILE_CHARS})`, {
303
- kind: 'file_too_large',
304
- hint: '拆成多个 partials 文件(服务端 templateFileSave 也按 40 万字符挡)',
305
- });
324
+ const oversize = oversizeOf(rel, buf);
325
+ if (oversize) {
326
+ skipped.push({ path: rel, bytes: buf.length, measured: oversize.measured, reason: oversize.reason });
327
+ continue;
306
328
  }
307
329
  const target = resolveInside(root, rel);
308
330
  fs.mkdirSync(path.dirname(target), { recursive: true });
@@ -341,6 +363,8 @@ export async function pullTemplate({
341
363
  bytes: totalBytes,
342
364
  contentHash: manifest.contentHash,
343
365
  files,
366
+ skipped,
367
+ warnings: skipped.map((one) => oversizeWarning(one.path, { reason: one.reason, measured: one.measured, limit: one.reason === 'binary-bytes' ? MAX_FILE_BYTES : MAX_FILE_CHARS })),
344
368
  };
345
369
  }
346
370
 
@@ -401,20 +425,17 @@ function scanLocal(dir) {
401
425
  };
402
426
  walk(root);
403
427
  const files = [];
428
+ const skipped = [];
404
429
  for (const abs of absPaths) {
405
430
  const rel = path.relative(root, abs).split(path.sep).join('/');
406
431
  if (rel === MANIFEST_FILE) continue;
407
432
  const safe = assertSafePath(rel);
408
433
  const buf = fs.readFileSync(abs);
409
434
  const binary = isBinaryPath(safe);
410
- if (binary) {
411
- if (buf.length > MAX_FILE_BYTES) {
412
- throw new CliError(`本地模板文件太大:${safe}(${buf.length} 字节,上限 ${MAX_FILE_BYTES})`, { kind: 'file_too_large' });
413
- }
414
- } else if (buf.toString('utf8').length > MAX_FILE_CHARS) {
415
- throw new CliError(`本地模板文件太长:${safe}(${buf.toString('utf8').length} 字符,上限 ${MAX_FILE_CHARS})`, {
416
- kind: 'file_too_large',
417
- });
435
+ const oversize = oversizeOf(safe, buf);
436
+ if (oversize) {
437
+ skipped.push({ path: safe, bytes: buf.length, measured: oversize.measured, reason: oversize.reason });
438
+ continue;
418
439
  }
419
440
  files.push({
420
441
  path: safe,
@@ -426,7 +447,7 @@ function scanLocal(dir) {
426
447
  text: binary ? null : buf.toString('utf8'),
427
448
  });
428
449
  }
429
- return files.sort((a, b) => a.path.localeCompare(b.path));
450
+ return { files: files.sort((a, b) => a.path.localeCompare(b.path)), skipped };
430
451
  }
431
452
 
432
453
  /** 远端当前文件(按 manifest 里那套模板取;不传 id = 当前启用那套) */
@@ -482,7 +503,9 @@ export async function planPush({ dir = '', api = null, prune = false, cwd = proc
482
503
 
483
504
  const { manifest, file: manifestPath } = readManifest(root);
484
505
  assertSameSite(manifest, api);
485
- const local = scanLocal(root);
506
+ const scanned = scanLocal(root);
507
+ const local = scanned.files;
508
+ const skipped = scanned.skipped;
486
509
  const remote = await fetchRemote(api, manifest);
487
510
  const localMap = new Map(local.map((f) => [f.path, f]));
488
511
  const remoteMap = new Map(remote.files.map((f) => [f.path, f]));
@@ -507,8 +530,12 @@ export async function planPush({ dir = '', api = null, prune = false, cwd = proc
507
530
  manifest,
508
531
  plan,
509
532
  local,
533
+ skipped,
510
534
  remote: remote.files,
511
- warnings: remote.warnings,
535
+ warnings: [
536
+ ...remote.warnings,
537
+ ...skipped.map((one) => oversizeWarning(one.path, { reason: one.reason, measured: one.measured, limit: one.reason === 'binary-bytes' ? MAX_FILE_BYTES : MAX_FILE_CHARS })),
538
+ ],
512
539
  };
513
540
  }
514
541
 
@@ -541,6 +568,7 @@ export async function pushTemplate({
541
568
  template: { id: planned.manifest.templateId || null, key: planned.manifest.key || null },
542
569
  plan,
543
570
  warnings: planned.warnings.slice(),
571
+ skipped: planned.skipped || [],
544
572
  written: [],
545
573
  failed: [],
546
574
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wkgeo/cli",
3
- "version": "1.1.4",
3
+ "version": "1.1.5",
4
4
  "description": "云站平台官方命令行客户端(@wkgeo/cli):授权登录一次,之后建站 / 下单 / 钱包支付 / 查余额都不用再登录(OAuth 授权码 + PKCE,公共客户端,零第三方依赖)",
5
5
  "keywords": [
6
6
  "wkgeo",