siluzan-cso-cli 1.1.18-beta.5 → 1.1.18-beta.6

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
@@ -54,7 +54,7 @@ siluzan-cso init -d /path/to/skills # 写入自定义目录
54
54
  siluzan-cso init --force # 强制覆盖已存在文件
55
55
  ```
56
56
 
57
- > **注意**:当前为测试版(1.1.18-beta.5),供内部测试使用。正式发布后安装命令将改为 `npm install -g siluzan-cso-cli`。
57
+ > **注意**:当前为测试版(1.1.18-beta.6),供内部测试使用。正式发布后安装命令将改为 `npm install -g siluzan-cso-cli`。
58
58
 
59
59
  | 助手 | 建议 `--ai` |
60
60
  | ----------------------- | ------------------------------------ |
package/dist/index.js CHANGED
@@ -1936,6 +1936,7 @@ var require_semver2 = __commonJS({
1936
1936
  });
1937
1937
 
1938
1938
  // ../common/dist/index.js
1939
+ var import_semver = __toESM(require_semver2(), 1);
1939
1940
  import * as fs from "fs";
1940
1941
  import * as path from "path";
1941
1942
  import * as os from "os";
@@ -1944,7 +1945,7 @@ import * as https from "https";
1944
1945
  import * as http from "http";
1945
1946
  import * as zlib from "zlib";
1946
1947
  import { performance } from "perf_hooks";
1947
- var import_semver = __toESM(require_semver2(), 1);
1948
+ import { randomUUID as _randomUUID } from "crypto";
1948
1949
  import * as fs2 from "fs";
1949
1950
  import * as path2 from "path";
1950
1951
  import { fileURLToPath } from "url";
@@ -2305,6 +2306,7 @@ function isUUID(value) {
2305
2306
  if (typeof value !== "string") return false;
2306
2307
  return /^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(value);
2307
2308
  }
2309
+ var randomUUID = _randomUUID;
2308
2310
  function getCurrentVersion(importMetaUrl) {
2309
2311
  try {
2310
2312
  const __dirname2 = path2.dirname(fileURLToPath(importMetaUrl));
@@ -4090,6 +4092,397 @@ async function runAccountGroupRemoveAccounts(options) {
4090
4092
  function nowUtc() {
4091
4093
  return (/* @__PURE__ */ new Date()).toISOString().replace("T", " ").slice(0, 19);
4092
4094
  }
4095
+ var guid = randomUUID;
4096
+ function isGuidFormat(s) {
4097
+ return /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(s);
4098
+ }
4099
+ function defaultTaskName() {
4100
+ const d = /* @__PURE__ */ new Date();
4101
+ const pad = (n) => String(n).padStart(2, "0");
4102
+ return `\u6279\u91CF\u53D1\u5E03 ${d.getFullYear()}-${pad(d.getMonth() + 1)}-${pad(d.getDate())} ${pad(d.getHours())}:${pad(d.getMinutes())}`;
4103
+ }
4104
+ function buildPublishTitle(item, mediaType, override, isImagePost = false) {
4105
+ const title = override?.title ?? item.title ?? "";
4106
+ const topics = override?.topics ?? item.topics ?? [];
4107
+ const rawDesc = override?.description ?? item.description ?? "";
4108
+ let description;
4109
+ if (isImagePost) {
4110
+ description = rawDesc;
4111
+ } else {
4112
+ description = ["YouTube", "Facebook"].includes(mediaType) ? rawDesc || title : title;
4113
+ }
4114
+ const defaultTopicPosition = ["YouTube", "Facebook"].includes(mediaType) ? 4 : 2;
4115
+ const topicPosition = override?.topicPosition ?? item.topicPosition ?? defaultTopicPosition;
4116
+ return { title, description, topics, topicPosition };
4117
+ }
4118
+ function buildImagePayload(img, currentUserId) {
4119
+ return {
4120
+ imageUrl: img.imageUrl,
4121
+ imageName: img.imageName,
4122
+ sourceImageId: img.sourceImageId ?? void 0,
4123
+ imageCreateUserId: img.imageCreateUserId ?? currentUserId ?? void 0,
4124
+ imageSourceType: img.imageSourceType,
4125
+ belongTo: -1,
4126
+ belongToId: null,
4127
+ replica: false,
4128
+ size: img.size ?? 0,
4129
+ width: img.width ?? 0,
4130
+ height: img.height ?? 0
4131
+ };
4132
+ }
4133
+ function buildCoverPayload(cover, videoId, currentUserId) {
4134
+ return {
4135
+ imageUrl: cover.imageUrl,
4136
+ imageName: cover.imageName,
4137
+ imageSourceType: cover.imageSourceType,
4138
+ sourceImageId: cover.sourceImageId ?? videoId,
4139
+ imageCreateUserId: cover.imageCreateUserId ?? currentUserId ?? void 0,
4140
+ // belongTo / belongToId:CLI 无法获取组织信息,统一与前端素材库视频行为保持一致
4141
+ belongTo: -1,
4142
+ belongToId: null,
4143
+ replica: false,
4144
+ coverTsp: 0,
4145
+ compositeCover: false,
4146
+ size: cover.size ?? 0,
4147
+ width: cover.width ?? 0,
4148
+ height: cover.height ?? 0
4149
+ };
4150
+ }
4151
+ function toSendType(mode) {
4152
+ return mode === "scheduled" ? 2 : 1;
4153
+ }
4154
+ function finalizeChannels(channels, sentKey) {
4155
+ for (const ch of Object.values(channels)) {
4156
+ let chSendType = 1;
4157
+ let chPublishAt = null;
4158
+ for (const acc of ch.mediaAccountInfos) {
4159
+ const items = acc[sentKey] ?? [];
4160
+ for (const v of items) {
4161
+ if (v.sendType <= 1) continue;
4162
+ if (v.sendType > chSendType) {
4163
+ chSendType = v.sendType;
4164
+ chPublishAt = v.publishAt;
4165
+ } else if (v.sendType === chSendType && v.publishAt && (!chPublishAt || new Date(v.publishAt) < new Date(chPublishAt))) {
4166
+ chPublishAt = v.publishAt;
4167
+ }
4168
+ }
4169
+ }
4170
+ ch.videoType = chSendType > 1 ? 2 : 1;
4171
+ ch.publishAts = chSendType > 1 && chPublishAt ? [chPublishAt] : [];
4172
+ }
4173
+ }
4174
+
4175
+ // src/commands/publish/params.ts
4176
+ var UUID_HINT = "\uFF08\u8BF7\u5148\u8FD0\u884C `siluzan-cso list-accounts --json` \u83B7\u53D6\u6B63\u786E\u7684 UUID \u503C\uFF0C\u4E0D\u8981\u4F7F\u7528\u5360\u4F4D\u7B26\u6587\u672C\uFF09";
4177
+ function buildVideoChannels(videos, currentUserId) {
4178
+ const channels = {};
4179
+ const contents = [];
4180
+ const errorList = [];
4181
+ let globalSendType = 1;
4182
+ for (const item of videos) {
4183
+ if (!item.accounts?.length) errorList.push(`\u89C6\u9891 "${item.videoName}" \u672A\u8BBE\u7F6E\u8D26\u53F7`);
4184
+ if (!item.title) errorList.push(`\u89C6\u9891 "${item.videoName}" \u672A\u586B\u5199\u6807\u9898`);
4185
+ if (!item.cover?.imageUrl) errorList.push(`\u89C6\u9891 "${item.videoName}" \u5C01\u9762\u53C2\u6570\u7F3A\u5931`);
4186
+ if (!isGuidFormat(item.videoId)) {
4187
+ errorList.push(
4188
+ `\u89C6\u9891 "${item.videoName}" \u7684 videoId "${item.videoId}" \u4E0D\u662F\u5408\u6CD5 UUID \u683C\u5F0F ${UUID_HINT}`
4189
+ );
4190
+ }
4191
+ let itemSendType = 1;
4192
+ for (const account of item.accounts ?? []) {
4193
+ if (!isGuidFormat(account.entityId)) {
4194
+ errorList.push(
4195
+ `\u8D26\u53F7 "${account.mediaCustomerName}" \u7684 entityId "${account.entityId}" \u4E0D\u662F\u5408\u6CD5 UUID \u683C\u5F0F ${UUID_HINT}`
4196
+ );
4197
+ }
4198
+ if (!isGuidFormat(account.externalMediaAccountTokenId)) {
4199
+ errorList.push(
4200
+ `\u8D26\u53F7 "${account.mediaCustomerName}" \u7684 externalMediaAccountTokenId "${account.externalMediaAccountTokenId}" \u4E0D\u662F\u5408\u6CD5 UUID \u683C\u5F0F ${UUID_HINT}`
4201
+ );
4202
+ }
4203
+ const mediaType = account.mediaAccountType;
4204
+ const sendType = toSendType(item.publishMode);
4205
+ const publishAtUtc = item.publishAt ? new Date(item.publishAt).toISOString() : null;
4206
+ if (item.publishMode === "scheduled" && !item.publishAt) {
4207
+ errorList.push(`\u89C6\u9891 "${item.videoName}" \u8BBE\u7F6E\u4E86\u5B9A\u65F6\u53D1\u5E03\u4F46\u672A\u586B\u5199 publishAt`);
4208
+ }
4209
+ if (sendType > itemSendType) itemSendType = sendType;
4210
+ const override = item.platformOverrides?.[mediaType];
4211
+ const publishTitle = buildPublishTitle(item, mediaType, override);
4212
+ const youTubeVideoStatus = mediaType === "YouTube" ? {
4213
+ privacyStatus: item.youtubePrivacy ?? "public",
4214
+ instantPremiere: false
4215
+ } : null;
4216
+ const toBeSent = {
4217
+ videoId: item.videoId,
4218
+ sendType,
4219
+ publishAt: publishAtUtc,
4220
+ publishTitle,
4221
+ publishCover: buildCoverPayload(item.cover, item.videoId, currentUserId),
4222
+ youTubeVideoStatus
4223
+ };
4224
+ const accountInfo = {
4225
+ mediaAccountId: account.entityId,
4226
+ mediaCustomerId: account.mediaCustomerId,
4227
+ mediaCustomerName: account.mediaCustomerName,
4228
+ externalMediaAccountTokenId: account.externalMediaAccountTokenId
4229
+ };
4230
+ if (channels[mediaType]) {
4231
+ const existing = channels[mediaType].mediaAccountInfos.find(
4232
+ (i) => i.mediaAccountId === account.entityId
4233
+ );
4234
+ if (existing) {
4235
+ existing.videoToBeSent.push(toBeSent);
4236
+ } else {
4237
+ channels[mediaType].mediaAccountInfos.push({ ...accountInfo, videoToBeSent: [toBeSent] });
4238
+ }
4239
+ } else {
4240
+ channels[mediaType] = {
4241
+ mediaType,
4242
+ mediaAccountInfos: [{ ...accountInfo, videoToBeSent: [toBeSent] }]
4243
+ };
4244
+ }
4245
+ }
4246
+ if (itemSendType > globalSendType) globalSendType = itemSendType;
4247
+ contents.push({
4248
+ videoId: item.videoId,
4249
+ // 素材库视频:sourceVideoId 与 videoId 相同;非素材库:null
4250
+ sourceVideoId: item.isMaterialCenter ? item.videoId : null,
4251
+ videoUrl: item.videoUrl,
4252
+ videoName: item.videoName,
4253
+ width: item.width ?? 0,
4254
+ height: item.height ?? 0,
4255
+ videoSize: item.videoSize ?? 0,
4256
+ duration: item.duration ?? 0,
4257
+ // 实际请求中 videoMd5 为 null(非空字符串)
4258
+ videoMd5: item.videoMd5 ?? null,
4259
+ isMaterialCenter: item.isMaterialCenter ?? false,
4260
+ // videoCreateUserId:优先取配置里的值,回落到当前 token 的 sub(上传者 ID)
4261
+ videoCreateUserId: item.videoCreateUserId ?? currentUserId,
4262
+ // belongTo/-ToId:CLI 无组织上下文,统一 -1/null(与前端素材库视频行为一致)
4263
+ belongTo: -1,
4264
+ belongToId: null,
4265
+ replica: false,
4266
+ // mediaAccountIds:后端用于建立视频与账号的关联,缺少此字段会导致发布失败
4267
+ mediaAccountIds: (item.accounts ?? []).map((a) => a.entityId),
4268
+ // POI 地理位置:默认 poiWay=3(不使用 POI)
4269
+ poiWay: 3,
4270
+ poiId: "",
4271
+ poiName: "",
4272
+ defaultTitle: {
4273
+ title: item.title,
4274
+ description: item.description ?? "",
4275
+ topicPosition: 2,
4276
+ topics: item.topics ?? []
4277
+ },
4278
+ // defaultCover 补全所有后端字段(与 publishCover 保持结构一致)
4279
+ defaultCover: buildCoverPayload(item.cover, item.videoId, currentUserId)
4280
+ });
4281
+ }
4282
+ finalizeChannels(channels, "videoToBeSent");
4283
+ return { channels, videoType: globalSendType, contents, errorList };
4284
+ }
4285
+ function buildImageChannels(posts, currentUserId) {
4286
+ const channels = {};
4287
+ const contents = [];
4288
+ const errorList = [];
4289
+ let globalSendType = 1;
4290
+ const validPosts = posts.filter(
4291
+ (item) => item.images?.some((img) => img.imageUrl) || (item.title ?? "").trim()
4292
+ );
4293
+ if (validPosts.length === 0) {
4294
+ errorList.push("\u6CA1\u6709\u53EF\u53D1\u5E03\u7684\u5E16\u5B50\uFF0C\u8BF7\u81F3\u5C11\u4E3A\u6BCF\u4E2A\u5E16\u5B50\u6DFB\u52A0\u56FE\u7247\u6216\u6587\u6848");
4295
+ return { channels, videoType: 1, contents, errorList };
4296
+ }
4297
+ for (const item of validPosts) {
4298
+ const vGuid = item.vGuid ?? guid();
4299
+ if (!item.accounts?.length) errorList.push("\u56FE\u6587\u5E16\u5B50\u672A\u8BBE\u7F6E\u8D26\u53F7");
4300
+ let itemSendType = 1;
4301
+ for (const account of item.accounts ?? []) {
4302
+ if (!isGuidFormat(account.entityId)) {
4303
+ errorList.push(
4304
+ `\u8D26\u53F7 "${account.mediaCustomerName}" \u7684 entityId "${account.entityId}" \u4E0D\u662F\u5408\u6CD5 UUID \u683C\u5F0F ${UUID_HINT}`
4305
+ );
4306
+ }
4307
+ if (!isGuidFormat(account.externalMediaAccountTokenId)) {
4308
+ errorList.push(
4309
+ `\u8D26\u53F7 "${account.mediaCustomerName}" \u7684 externalMediaAccountTokenId "${account.externalMediaAccountTokenId}" \u4E0D\u662F\u5408\u6CD5 UUID \u683C\u5F0F ${UUID_HINT}`
4310
+ );
4311
+ }
4312
+ const mediaType = account.mediaAccountType;
4313
+ const sendType = toSendType(item.publishMode);
4314
+ const publishAtUtc = item.publishAt ? new Date(item.publishAt).toISOString() : null;
4315
+ if (item.publishMode === "scheduled" && !item.publishAt) {
4316
+ errorList.push("\u56FE\u6587\u5E16\u5B50\u8BBE\u7F6E\u4E86\u5B9A\u65F6\u53D1\u5E03\u4F46\u672A\u586B\u5199 publishAt");
4317
+ }
4318
+ if (sendType > itemSendType) itemSendType = sendType;
4319
+ const override = item.platformOverrides?.[mediaType];
4320
+ const publishTitle = buildPublishTitle(item, mediaType, override, true);
4321
+ const toBeSent = {
4322
+ imageGroupId: vGuid,
4323
+ sendType,
4324
+ publishAt: publishAtUtc,
4325
+ publishTitle
4326
+ };
4327
+ const accountInfo = {
4328
+ mediaAccountId: account.entityId,
4329
+ mediaCustomerId: account.mediaCustomerId,
4330
+ mediaCustomerName: account.mediaCustomerName,
4331
+ externalMediaAccountTokenId: account.externalMediaAccountTokenId
4332
+ };
4333
+ if (channels[mediaType]) {
4334
+ const existing = channels[mediaType].mediaAccountInfos.find(
4335
+ (i) => i.mediaAccountId === account.entityId
4336
+ );
4337
+ if (existing) {
4338
+ existing.imageTextToBeSent.push(toBeSent);
4339
+ } else {
4340
+ channels[mediaType].mediaAccountInfos.push({
4341
+ ...accountInfo,
4342
+ imageTextToBeSent: [toBeSent]
4343
+ });
4344
+ }
4345
+ } else {
4346
+ channels[mediaType] = {
4347
+ mediaType,
4348
+ mediaAccountInfos: [{ ...accountInfo, imageTextToBeSent: [toBeSent] }]
4349
+ };
4350
+ }
4351
+ }
4352
+ if (itemSendType > globalSendType) globalSendType = itemSendType;
4353
+ contents.push({
4354
+ imageGroupId: vGuid,
4355
+ // 补全每张图片的后端必填字段(belongTo、replica、imageCreateUserId 等)
4356
+ images: (item.images ?? []).map((img) => buildImagePayload(img, currentUserId)),
4357
+ mediaAccountIds: (item.accounts ?? []).map((a) => a.entityId)
4358
+ });
4359
+ }
4360
+ finalizeChannels(channels, "imageTextToBeSent");
4361
+ return { channels, videoType: globalSendType, contents, errorList };
4362
+ }
4363
+
4364
+ // src/commands/publish/preview.ts
4365
+ function formatTopics(topics) {
4366
+ if (!topics?.length) return "";
4367
+ return topics.map((t) => `#${t}`).join(" ");
4368
+ }
4369
+ function formatPublishMode(mode, publishAt) {
4370
+ if (mode === "scheduled") {
4371
+ return publishAt ? `\u5B9A\u65F6\u53D1\u5E03\uFF08${publishAt}\uFF09` : "\u5B9A\u65F6\u53D1\u5E03\uFF08\u26A0\uFE0F \u672A\u586B\u5199 publishAt\uFF09";
4372
+ }
4373
+ return "\u7ACB\u5373\u53D1\u5E03";
4374
+ }
4375
+ function printDryRun(input, taskName, isDomestic, body, verbose) {
4376
+ const SEP = "\u2500".repeat(54);
4377
+ console.log("\n\u2705 [dry-run] \u53D1\u5E03\u53C2\u6570\u9884\u89C8\uFF08\u672A\u5B9E\u9645\u63D0\u4EA4\uFF09\n");
4378
+ console.log(`\u4EFB\u52A1\u540D \uFF1A${taskName}`);
4379
+ console.log(`\u5185\u5BB9\u7C7B\u578B \uFF1A${input.contentType === 1 ? "\u89C6\u9891" : "\u56FE\u6587"}`);
4380
+ console.log(`\u5E73\u53F0\u6A21\u5F0F \uFF1A${isDomestic ? "\u5185\u8D38" : "\u5916\u8D38"}`);
4381
+ if (input.contentType === 1) {
4382
+ const items = input.videos;
4383
+ console.log(`\u89C6\u9891\u6570\u91CF \uFF1A${items.length} \u4E2A`);
4384
+ for (let i = 0; i < items.length; i++) {
4385
+ const item = items[i];
4386
+ console.log(`
4387
+ ${SEP}`);
4388
+ console.log(` \u89C6\u9891 ${i + 1} / ${items.length}\uFF1A${item.videoName}`);
4389
+ console.log(SEP);
4390
+ console.log(` \u89C6\u9891 ID \uFF1A${item.videoId}`);
4391
+ console.log(` \u6807\u9898 \uFF1A${item.title || "\u26A0\uFE0F \u672A\u586B\u5199"}`);
4392
+ if (item.description) {
4393
+ console.log(` \u63CF\u8FF0 \uFF1A${item.description}`);
4394
+ }
4395
+ const topicsStr = formatTopics(item.topics);
4396
+ if (topicsStr) {
4397
+ console.log(` \u6807\u7B7E \uFF1A${topicsStr}`);
4398
+ }
4399
+ console.log(` \u53D1\u5E03\u6A21\u5F0F \uFF1A${formatPublishMode(item.publishMode, item.publishAt)}`);
4400
+ console.log(` \u5C01\u9762 URL \uFF1A${item.cover?.imageUrl || "\u26A0\uFE0F \u672A\u8BBE\u7F6E"}`);
4401
+ if (item.cover?.sourceImageId) {
4402
+ console.log(` \u5C01\u9762 ID \uFF1A${item.cover.sourceImageId}`);
4403
+ }
4404
+ const byPlatform = /* @__PURE__ */ new Map();
4405
+ for (const acc of item.accounts ?? []) {
4406
+ const list = byPlatform.get(acc.mediaAccountType) ?? [];
4407
+ list.push(acc);
4408
+ byPlatform.set(acc.mediaAccountType, list);
4409
+ }
4410
+ const totalAccounts = item.accounts?.length ?? 0;
4411
+ console.log(`
4412
+ \u8D26\u53F7\uFF08${totalAccounts} \u4E2A\uFF0C${byPlatform.size} \u4E2A\u5E73\u53F0\uFF09\uFF1A`);
4413
+ for (const [platform, accounts] of byPlatform) {
4414
+ const override = item.platformOverrides?.[platform];
4415
+ console.log(`
4416
+ \u25AA ${platform}`);
4417
+ if (override) {
4418
+ const pt = buildPublishTitle(item, platform, override);
4419
+ if (override.title) console.log(` \u6807\u9898\u8986\u76D6 \uFF1A${pt.title}`);
4420
+ if (override.description) console.log(` \u63CF\u8FF0\u8986\u76D6 \uFF1A${pt.description}`);
4421
+ const ovTopics = formatTopics(override.topics);
4422
+ if (ovTopics) console.log(` \u6807\u7B7E\u8986\u76D6 \uFF1A${ovTopics}`);
4423
+ }
4424
+ for (const acc of accounts) {
4425
+ console.log(` \xB7 ${acc.mediaCustomerName}\uFF08${acc.mediaCustomerId}\uFF09`);
4426
+ }
4427
+ }
4428
+ }
4429
+ console.log(`
4430
+ ${SEP}`);
4431
+ } else {
4432
+ const items = input.posts;
4433
+ console.log(`\u56FE\u6587\u6570\u91CF \uFF1A${items.length} \u4E2A`);
4434
+ for (let i = 0; i < items.length; i++) {
4435
+ const item = items[i];
4436
+ console.log(`
4437
+ ${SEP}`);
4438
+ console.log(` \u56FE\u6587 ${i + 1} / ${items.length}`);
4439
+ console.log(SEP);
4440
+ console.log(` \u6807\u9898 \uFF1A${item.title || "\u26A0\uFE0F \u672A\u586B\u5199"}`);
4441
+ if (item.description) {
4442
+ console.log(` \u63CF\u8FF0 \uFF1A${item.description}`);
4443
+ }
4444
+ const topicsStr = formatTopics(item.topics);
4445
+ if (topicsStr) {
4446
+ console.log(` \u6807\u7B7E \uFF1A${topicsStr}`);
4447
+ }
4448
+ console.log(` \u56FE\u7247\u6570\u91CF \uFF1A${item.images?.length ?? 0} \u5F20`);
4449
+ console.log(` \u53D1\u5E03\u6A21\u5F0F \uFF1A${formatPublishMode(item.publishMode, item.publishAt)}`);
4450
+ const byPlatform = /* @__PURE__ */ new Map();
4451
+ for (const acc of item.accounts ?? []) {
4452
+ const list = byPlatform.get(acc.mediaAccountType) ?? [];
4453
+ list.push(acc);
4454
+ byPlatform.set(acc.mediaAccountType, list);
4455
+ }
4456
+ const totalAccounts = item.accounts?.length ?? 0;
4457
+ console.log(`
4458
+ \u8D26\u53F7\uFF08${totalAccounts} \u4E2A\uFF0C${byPlatform.size} \u4E2A\u5E73\u53F0\uFF09\uFF1A`);
4459
+ for (const [platform, accounts] of byPlatform) {
4460
+ const override = item.platformOverrides?.[platform];
4461
+ console.log(`
4462
+ \u25AA ${platform}`);
4463
+ if (override) {
4464
+ const pt = buildPublishTitle(item, platform, override, true);
4465
+ if (override.title) console.log(` \u6807\u9898\u8986\u76D6 \uFF1A${pt.title}`);
4466
+ if (override.description) console.log(` \u63CF\u8FF0\u8986\u76D6 \uFF1A${pt.description}`);
4467
+ const ovTopics = formatTopics(override.topics);
4468
+ if (ovTopics) console.log(` \u6807\u7B7E\u8986\u76D6 \uFF1A${ovTopics}`);
4469
+ }
4470
+ for (const acc of accounts) {
4471
+ console.log(` \xB7 ${acc.mediaCustomerName}\uFF08${acc.mediaCustomerId}\uFF09`);
4472
+ }
4473
+ }
4474
+ }
4475
+ console.log(`
4476
+ ${SEP}`);
4477
+ }
4478
+ if (verbose) {
4479
+ const verboseBody = { ...body, contents: JSON.parse(body.contents) };
4480
+ console.log("\n\u5B8C\u6574 JSON \u8BF7\u6C42\u4F53\uFF08--verbose\uFF0Ccontents \u5DF2\u5C55\u5F00\uFF09\uFF1A\n");
4481
+ console.log(JSON.stringify(verboseBody, null, 2));
4482
+ } else {
4483
+ console.log("\n\u2139\uFE0F \u52A0 --verbose \u53C2\u6570\u53EF\u67E5\u770B\u5B8C\u6574 JSON \u8BF7\u6C42\u4F53\u3002");
4484
+ }
4485
+ }
4093
4486
 
4094
4487
  // src/commands/publish/commands.ts
4095
4488
  import * as fs6 from "fs";
@@ -4228,7 +4621,208 @@ var SENSITIVE_PATH_PREFIXES = [
4228
4621
  path7.join(os5.homedir(), ".env")
4229
4622
  // 常用本地环境变量文件
4230
4623
  ];
4624
+ var SENSITIVE_ABSOLUTE_PATHS = ["/etc/passwd", "/etc/shadow", "/etc/hosts"];
4625
+ function validateUploadPath(resolved) {
4626
+ const normalized = resolved.toLowerCase();
4627
+ for (const prefix of SENSITIVE_PATH_PREFIXES) {
4628
+ if (normalized === prefix.toLowerCase() || normalized.startsWith(prefix.toLowerCase() + path7.sep)) {
4629
+ return `\u7981\u6B62\u4E0A\u4F20\u654F\u611F\u76EE\u5F55\u4E0B\u7684\u6587\u4EF6\uFF1A${prefix}`;
4630
+ }
4631
+ }
4632
+ for (const abs of SENSITIVE_ABSOLUTE_PATHS) {
4633
+ if (normalized === abs.toLowerCase()) {
4634
+ return `\u7981\u6B62\u4E0A\u4F20\u7CFB\u7EDF\u654F\u611F\u6587\u4EF6\uFF1A${abs}`;
4635
+ }
4636
+ }
4637
+ const base = path7.basename(resolved).toLowerCase();
4638
+ if (base === ".env" || base.startsWith(".env.")) {
4639
+ return `\u7981\u6B62\u4E0A\u4F20\u73AF\u5883\u53D8\u91CF\u6587\u4EF6\uFF08${path7.basename(resolved)}\uFF09\uFF0C\u53EF\u80FD\u5305\u542B\u5BC6\u94A5`;
4640
+ }
4641
+ return null;
4642
+ }
4643
+ var DEFAULT_FOLDER_ID = "77777777-7777-7777-7777-777777777777";
4231
4644
  var BLOCK_SIZE = 2 * 1024 * 1024;
4645
+ var VIDEO_EXTS = [
4646
+ ".mp4",
4647
+ ".mov",
4648
+ ".avi",
4649
+ ".mkv",
4650
+ ".flv",
4651
+ ".f4v",
4652
+ ".rmvb",
4653
+ ".rm",
4654
+ ".vob",
4655
+ ".wmv",
4656
+ ".3gp",
4657
+ ".asf",
4658
+ ".mpeg",
4659
+ ".m4v",
4660
+ ".mpg"
4661
+ ];
4662
+ var IMAGE_EXTS = [".jpg", ".jpeg", ".png", ".gif", ".arw"];
4663
+ function detectKind(filePath) {
4664
+ const ext = path7.extname(filePath).toLowerCase();
4665
+ if (VIDEO_EXTS.includes(ext)) return "video";
4666
+ if (IMAGE_EXTS.includes(ext)) return "image";
4667
+ throw new Error(
4668
+ `\u65E0\u6CD5\u8BC6\u522B\u6587\u4EF6\u7C7B\u578B\uFF1A${ext}\u3002
4669
+ \u89C6\u9891\uFF1A${VIDEO_EXTS.join(", ")}
4670
+ \u56FE\u7247\uFF1A${IMAGE_EXTS.join(", ")}`
4671
+ );
4672
+ }
4673
+ function getMimeType(filePath) {
4674
+ const map = {
4675
+ ".mp4": "video/mp4",
4676
+ ".mov": "video/quicktime",
4677
+ ".avi": "video/avi",
4678
+ ".mkv": "video/x-matroska",
4679
+ ".flv": "video/x-flv",
4680
+ ".wmv": "video/x-ms-wmv",
4681
+ ".3gp": "video/3gpp",
4682
+ ".jpg": "image/jpeg",
4683
+ ".jpeg": "image/jpeg",
4684
+ ".png": "image/png",
4685
+ ".gif": "image/gif"
4686
+ };
4687
+ return map[path7.extname(filePath).toLowerCase()] ?? "application/octet-stream";
4688
+ }
4689
+ var guid2 = randomUUID;
4690
+ async function generateSas(config, verbose = false) {
4691
+ const url = `${config.csoBaseUrl}/cutapi/v1/material/generateuploadsas?account=cutapi&expirationMinutes=120`;
4692
+ const res = await apiFetch2(url, config, {}, verbose);
4693
+ if (res.code !== 1 || !res.data) {
4694
+ throw new Error("\u7533\u8BF7\u4E0A\u4F20\u51ED\u8BC1\u5931\u8D25\uFF0C\u670D\u52A1\u7AEF\u8FD4\u56DE\u5F02\u5E38");
4695
+ }
4696
+ return res.data;
4697
+ }
4698
+ async function uploadToAzure(filePath, sas, onProgress) {
4699
+ const ext = path7.extname(filePath);
4700
+ const blobName = `${guid2()}${ext}`;
4701
+ const containerClient = new ContainerClient(sas.sasUri);
4702
+ const blockBlobClient = containerClient.getBlockBlobClient(blobName);
4703
+ const fileSize = fs7.statSync(filePath).size;
4704
+ await blockBlobClient.uploadFile(filePath, {
4705
+ blockSize: BLOCK_SIZE,
4706
+ blobHTTPHeaders: { blobContentType: getMimeType(filePath) },
4707
+ onProgress: (ev) => {
4708
+ if (onProgress && fileSize > 0) {
4709
+ onProgress(Math.round(ev.loadedBytes / fileSize * 100));
4710
+ }
4711
+ }
4712
+ });
4713
+ const resourceUrl = `${sas.containerUri}/${blobName}`;
4714
+ return { resourceUrl, blobName };
4715
+ }
4716
+ async function notifyUploaded(config, body, verbose = false) {
4717
+ const url = `${config.csoBaseUrl}/cutapi/v1/material/uploadednotify`;
4718
+ const res = await apiFetch2(
4719
+ url,
4720
+ config,
4721
+ {
4722
+ method: "POST",
4723
+ body: JSON.stringify(body)
4724
+ },
4725
+ verbose
4726
+ );
4727
+ if (res.code !== 1 || !res.data?.id) {
4728
+ const detail = verbose ? `\uFF1A${JSON.stringify(res)}` : "";
4729
+ throw new Error(`\u7D20\u6750\u6CE8\u518C\u5931\u8D25${detail}`);
4730
+ }
4731
+ return res.data.id;
4732
+ }
4733
+ async function fetchMaterialInfo(config, id, verbose = false) {
4734
+ try {
4735
+ const url = `${config.csoBaseUrl}/cutapi/v1/material/${id}`;
4736
+ const res = await apiFetch2(url, config, {}, verbose);
4737
+ return res.data ?? {};
4738
+ } catch {
4739
+ return {};
4740
+ }
4741
+ }
4742
+ function readMp4Duration(filePath) {
4743
+ try {
4744
+ const fileSize = fs7.statSync(filePath).size;
4745
+ const chunkSize = Math.min(fileSize, 256 * 1024);
4746
+ const bufEnd = Buffer.alloc(chunkSize);
4747
+ const fdEnd = fs7.openSync(filePath, "r");
4748
+ fs7.readSync(fdEnd, bufEnd, 0, chunkSize, fileSize - chunkSize);
4749
+ fs7.closeSync(fdEnd);
4750
+ const bufStart = Buffer.alloc(chunkSize);
4751
+ const fdStart = fs7.openSync(filePath, "r");
4752
+ fs7.readSync(fdStart, bufStart, 0, chunkSize, 0);
4753
+ fs7.closeSync(fdStart);
4754
+ const durationSec = parseMvhdFromBuffer(bufEnd) ?? parseMvhdFromBuffer(bufStart);
4755
+ if (durationSec === null || durationSec <= 0) return null;
4756
+ const h = Math.floor(durationSec / 3600);
4757
+ const m = Math.floor(durationSec % 3600 / 60);
4758
+ const s = Math.floor(durationSec % 60);
4759
+ const ms = Math.round(durationSec % 1 * 1e3);
4760
+ return `${String(h).padStart(2, "0")}:${String(m).padStart(2, "0")}:${String(s).padStart(2, "0")}.${String(ms).padStart(3, "0")}`;
4761
+ } catch {
4762
+ return null;
4763
+ }
4764
+ }
4765
+ function parseMvhdFromBuffer(buf) {
4766
+ const marker = Buffer.from("6d766864", "hex");
4767
+ const idx = buf.lastIndexOf(marker);
4768
+ if (idx < 4) return null;
4769
+ const dataStart = idx + 4;
4770
+ const version = buf[dataStart];
4771
+ let timescale;
4772
+ let durationVal;
4773
+ if (version === 0) {
4774
+ timescale = buf.readUInt32BE(dataStart + 1 + 3 + 4 + 4);
4775
+ durationVal = buf.readUInt32BE(dataStart + 1 + 3 + 4 + 4 + 4);
4776
+ } else if (version === 1) {
4777
+ timescale = buf.readUInt32BE(dataStart + 1 + 3 + 8 + 8);
4778
+ durationVal = buf.readUInt32BE(dataStart + 1 + 3 + 8 + 8 + 4 + 4);
4779
+ } else {
4780
+ return null;
4781
+ }
4782
+ if (timescale === 0) return null;
4783
+ return durationVal / timescale;
4784
+ }
4785
+ function readImageDimensions(filePath) {
4786
+ try {
4787
+ const buf = fs7.readFileSync(filePath);
4788
+ const dim = imageSize(buf);
4789
+ return { width: dim.width, height: dim.height, format: (dim.type ?? "").toUpperCase() };
4790
+ } catch {
4791
+ return { width: 0, height: 0 };
4792
+ }
4793
+ }
4794
+ async function uploadImageFile(filePath, config, verbose = false) {
4795
+ const fileName = path7.basename(filePath);
4796
+ const fileSize = fs7.statSync(filePath).size;
4797
+ const format = path7.extname(filePath).replace(".", "").toUpperCase();
4798
+ const sas = await generateSas(config, verbose);
4799
+ const { resourceUrl } = await uploadToAzure(filePath, sas, void 0);
4800
+ const dim = readImageDimensions(filePath);
4801
+ const materialId = await notifyUploaded(
4802
+ config,
4803
+ {
4804
+ folderId: DEFAULT_FOLDER_ID,
4805
+ name: fileName,
4806
+ url: resourceUrl,
4807
+ fileSize,
4808
+ type: 1,
4809
+ source: 1,
4810
+ blobAccount: sas.accountName,
4811
+ blobContainer: sas.containerName,
4812
+ format,
4813
+ image: dim
4814
+ },
4815
+ verbose
4816
+ );
4817
+ const matInfo = await fetchMaterialInfo(config, materialId, verbose);
4818
+ return {
4819
+ resourceUrl,
4820
+ materialId,
4821
+ belongToId: matInfo?.belongToId,
4822
+ belongTo: matInfo?.belongTo,
4823
+ userId: matInfo?.userId
4824
+ };
4825
+ }
4232
4826
 
4233
4827
  // src/commands/upload/commands.ts
4234
4828
  import * as fs8 from "fs";
@@ -4409,7 +5003,134 @@ async function runUpload(options) {
4409
5003
  }
4410
5004
 
4411
5005
  // src/commands/report/_shared.ts
4412
- function createQueryString2(query) {
5006
+ var DEFAULT_METHOD = "Day";
5007
+ var DEFAULT_WORKS_ORDER = "play";
5008
+ var REPORT_MODULES = [
5009
+ "operation",
5010
+ "total-fans",
5011
+ "fans-analysis",
5012
+ "hot-topic",
5013
+ "works",
5014
+ "hot-comment-word",
5015
+ "comment-top10",
5016
+ "video-duration",
5017
+ "video-distribution",
5018
+ "comment-trend",
5019
+ "fans-trend",
5020
+ "new-fans-trend",
5021
+ "homepage-visit"
5022
+ ];
5023
+ var MODULE_ALIAS = {
5024
+ operation: "operation",
5025
+ totalfans: "total-fans",
5026
+ "total-fans": "total-fans",
5027
+ fans: "fans-analysis",
5028
+ "fans-analysis": "fans-analysis",
5029
+ topic: "hot-topic",
5030
+ "hot-topic": "hot-topic",
5031
+ works: "works",
5032
+ "hot-comment-word": "hot-comment-word",
5033
+ hotcommentword: "hot-comment-word",
5034
+ commenttop10: "comment-top10",
5035
+ "comment-top10": "comment-top10",
5036
+ videoduration: "video-duration",
5037
+ "video-duration": "video-duration",
5038
+ videodistribution: "video-distribution",
5039
+ "video-distribution": "video-distribution",
5040
+ commenttrend: "comment-trend",
5041
+ "comment-trend": "comment-trend",
5042
+ fanstrend: "fans-trend",
5043
+ "fans-trend": "fans-trend",
5044
+ newfanstrend: "new-fans-trend",
5045
+ "new-fans-trend": "new-fans-trend",
5046
+ homepagevisit: "homepage-visit",
5047
+ "homepage-visit": "homepage-visit"
5048
+ };
5049
+ function exitWithError(message) {
5050
+ console.error(`
5051
+ \u274C ${message}
5052
+ `);
5053
+ process.exit(1);
5054
+ }
5055
+ function normalizeDateInput(value, kind) {
5056
+ const hasTime = /[T\s]\d{1,2}:\d{1,2}(:\d{1,2})?/.test(value);
5057
+ const date = hasTime ? new Date(value) : /* @__PURE__ */ new Date(`${value}${kind === "start" ? "T00:00:00" : "T23:59:59"}`);
5058
+ if (Number.isNaN(date.getTime())) {
5059
+ exitWithError(`\u65E5\u671F\u683C\u5F0F\u4E0D\u5408\u6CD5\uFF1A${value}\u3002\u8BF7\u4F7F\u7528 YYYY-MM-DD \u6216 ISO \u65E5\u671F\u65F6\u95F4\u3002`);
5060
+ }
5061
+ return date;
5062
+ }
5063
+ function formatUtcDateTime(date) {
5064
+ const pad = (n) => String(n).padStart(2, "0");
5065
+ return `${date.getUTCFullYear()}-${pad(date.getUTCMonth() + 1)}-${pad(date.getUTCDate())} ${pad(date.getUTCHours())}:${pad(date.getUTCMinutes())}:${pad(date.getUTCSeconds())}`;
5066
+ }
5067
+ function getDefaultDateRange(days = 30) {
5068
+ const end = /* @__PURE__ */ new Date();
5069
+ end.setDate(end.getDate() - 1);
5070
+ end.setHours(23, 59, 59, 0);
5071
+ const start = new Date(end);
5072
+ start.setDate(start.getDate() - (days - 1));
5073
+ start.setHours(0, 0, 0, 0);
5074
+ return { startDate: start, endDate: end };
5075
+ }
5076
+ function parseMediaCustomerIds(value) {
5077
+ if (!value || value.length === 0) return [];
5078
+ const ids = value.flatMap((part) => part.split(",")).map((s) => s.trim()).filter(Boolean);
5079
+ return Array.from(new Set(ids));
5080
+ }
5081
+ function ensureMethod(value) {
5082
+ if (!value) return DEFAULT_METHOD;
5083
+ if (value === "Day" || value === "Week" || value === "Moth") return value;
5084
+ exitWithError(`--method \u4EC5\u652F\u6301 Day / Week / Moth\uFF0C\u6536\u5230\uFF1A${value}`);
5085
+ }
5086
+ function ensureWorksOrder(value) {
5087
+ if (!value) return DEFAULT_WORKS_ORDER;
5088
+ if (value === "play" || value === "digg" || value === "fullplay") return value;
5089
+ exitWithError(`--order \u4EC5\u652F\u6301 play / digg / fullplay\uFF0C\u6536\u5230\uFF1A${value}`);
5090
+ }
5091
+ function parseModules(input) {
5092
+ if (!input || input.length === 0) return [...REPORT_MODULES];
5093
+ const modules = [];
5094
+ for (const part of input) {
5095
+ for (const raw of part.split(",")) {
5096
+ const key = raw.trim().toLowerCase();
5097
+ if (!key) continue;
5098
+ const mapped = MODULE_ALIAS[key];
5099
+ if (!mapped) {
5100
+ exitWithError(`\u672A\u77E5\u6A21\u5757\uFF1A${raw}\u3002\u53EF\u9009\u503C\uFF1A${REPORT_MODULES.join(", ")}`);
5101
+ }
5102
+ modules.push(mapped);
5103
+ }
5104
+ }
5105
+ return Array.from(new Set(modules));
5106
+ }
5107
+ function buildRuntime(opts) {
5108
+ if (!opts.media) {
5109
+ exitWithError("\u8BF7\u901A\u8FC7 --media \u6307\u5B9A\u5A92\u4F53\u7C7B\u578B\uFF0C\u4F8B\u5982 Douyin\u3001YouTube\u3002");
5110
+ }
5111
+ const config = loadConfig(opts.token);
5112
+ const days = opts.days && opts.days > 0 ? opts.days : 30;
5113
+ const { startDate: defaultStart, endDate: defaultEnd } = getDefaultDateRange(days);
5114
+ const startDate = opts.start ? normalizeDateInput(opts.start, "start") : defaultStart;
5115
+ const endDate = opts.end ? normalizeDateInput(opts.end, "end") : defaultEnd;
5116
+ if (startDate.getTime() > endDate.getTime()) {
5117
+ exitWithError("--start \u4E0D\u80FD\u665A\u4E8E --end");
5118
+ }
5119
+ const baseQuery = {
5120
+ csoPlatformType: 2,
5121
+ mediaTypes: [opts.media],
5122
+ mediaCustomerIds: parseMediaCustomerIds(opts.maids),
5123
+ startDate: formatUtcDateTime(startDate),
5124
+ endDate: formatUtcDateTime(endDate)
5125
+ };
5126
+ return {
5127
+ config,
5128
+ baseQuery,
5129
+ method: ensureMethod(opts.method),
5130
+ verbose: Boolean(opts.verbose)
5131
+ };
5132
+ }
5133
+ function createQueryString(query) {
4413
5134
  const params = new URLSearchParams();
4414
5135
  for (const [key, value] of Object.entries(query)) {
4415
5136
  if (Array.isArray(value)) {
@@ -4422,6 +5143,180 @@ function createQueryString2(query) {
4422
5143
  }
4423
5144
  return params.toString();
4424
5145
  }
5146
+ async function getWithQuery(runtime, endpoint, query) {
5147
+ const queryRecord = { ...query };
5148
+ const url = `${runtime.config.csoBaseUrl}/cso/v1/accountData/${endpoint}?${createQueryString(queryRecord)}`;
5149
+ const res = await apiFetch2(url, runtime.config, {}, runtime.verbose);
5150
+ if (res.code !== 1) {
5151
+ throw new Error(res.message || `\u8BF7\u6C42\u5931\u8D25\uFF1A${endpoint}`);
5152
+ }
5153
+ return res.data;
5154
+ }
5155
+
5156
+ // src/commands/report/markdown.ts
5157
+ var MODULE_TITLES = {
5158
+ "total-fans": "\u603B\u7C89\u4E1D\u6570",
5159
+ "fans-analysis": "\u7C89\u4E1D\u5206\u6790",
5160
+ "hot-topic": "\u70ED\u95E8\u8BDD\u9898",
5161
+ "hot-comment-word": "\u70ED\u95E8\u8BC4\u8BBA\u8BCD",
5162
+ "comment-top10": "\u8BC4\u8BBA Top10",
5163
+ "video-duration": "\u89C6\u9891\u65F6\u957F\u5206\u5E03",
5164
+ "video-distribution": "\u89C6\u9891\u5206\u5E03",
5165
+ "comment-trend": "\u8BC4\u8BBA\u8D8B\u52BF",
5166
+ "fans-trend": "\u7C89\u4E1D\u8D8B\u52BF",
5167
+ "new-fans-trend": "\u65B0\u589E\u7C89\u4E1D\u8D8B\u52BF",
5168
+ "homepage-visit": "\u4E3B\u9875\u8BBF\u95EE\u8D8B\u52BF"
5169
+ };
5170
+ function renderMarkdownArrayOfObjects(rows) {
5171
+ if (rows.length === 0) {
5172
+ return;
5173
+ }
5174
+ const keys = Object.keys(rows[0]);
5175
+ console.log("| " + keys.join(" | ") + " |");
5176
+ console.log("| " + keys.map(() => "---").join(" | ") + " |");
5177
+ for (const row of rows) {
5178
+ console.log("| " + keys.map((k) => String(row[k] ?? "-")).join(" | ") + " |");
5179
+ }
5180
+ console.log();
5181
+ }
5182
+ function isTimeSeries(arr) {
5183
+ if (arr.length === 0) return false;
5184
+ const first = arr[0];
5185
+ if ("date" in first && "count" in first) return true;
5186
+ if ("name" in first && "value" in first) {
5187
+ const name = first.name;
5188
+ return typeof name === "number" || typeof name === "string" && /^\d{4}-\d{2}-\d{2}/.test(name);
5189
+ }
5190
+ return false;
5191
+ }
5192
+ function renderTimeSeries(arr) {
5193
+ const keyField = "date" in arr[0] ? "date" : "name";
5194
+ const valField = "count" in arr[0] ? "count" : "value";
5195
+ const nonZero = arr.filter((item) => {
5196
+ const v = item[valField];
5197
+ return v !== null && v !== void 0 && Number(v) !== 0;
5198
+ });
5199
+ if (nonZero.length === 0) {
5200
+ console.log(`_\uFF08${arr.length}\u6761\u5747\u4E3A0\uFF09_
5201
+ `);
5202
+ return;
5203
+ }
5204
+ if (nonZero.length <= 6) {
5205
+ const pairs = nonZero.map((item) => `${item[keyField]}:${item[valField]}`).join(", ");
5206
+ const zeroCount = arr.length - nonZero.length;
5207
+ console.log(`${pairs}${zeroCount > 0 ? `\uFF08\u5176\u4F59${zeroCount}\u6761\u4E3A0\uFF09` : ""}
5208
+ `);
5209
+ return;
5210
+ }
5211
+ renderMarkdownArrayOfObjects(arr);
5212
+ }
5213
+ function renderMarkdownValue(data) {
5214
+ if (data === null || data === void 0) return;
5215
+ if (Array.isArray(data)) {
5216
+ if (data.length === 0) return;
5217
+ if (typeof data[0] === "object" && data[0] !== null) {
5218
+ const rows = data;
5219
+ if (isTimeSeries(rows)) {
5220
+ renderTimeSeries(rows);
5221
+ } else {
5222
+ renderMarkdownArrayOfObjects(rows);
5223
+ }
5224
+ } else {
5225
+ for (const item of data) console.log(`- ${String(item)}`);
5226
+ console.log();
5227
+ }
5228
+ return;
5229
+ }
5230
+ if (typeof data === "object") {
5231
+ const obj = data;
5232
+ const keys = Object.keys(obj);
5233
+ if (keys.length === 0) return;
5234
+ const summaryParts = [];
5235
+ for (const key of keys) {
5236
+ const val = obj[key];
5237
+ if (Array.isArray(val) && val.length > 0 && typeof val[0] === "object") {
5238
+ if (summaryParts.length > 0) {
5239
+ console.log(summaryParts.join(" | ") + "\n");
5240
+ summaryParts.length = 0;
5241
+ }
5242
+ console.log(`**${key}**`);
5243
+ renderMarkdownValue(val);
5244
+ } else if (!Array.isArray(val)) {
5245
+ summaryParts.push(`${key}: ${JSON.stringify(val)}`);
5246
+ }
5247
+ }
5248
+ if (summaryParts.length > 0) console.log(summaryParts.join(" | ") + "\n");
5249
+ return;
5250
+ }
5251
+ console.log(String(data) + "\n");
5252
+ }
5253
+ function printMarkdownFetch(runtime, includeModules, sections) {
5254
+ const accountScope = runtime.baseQuery.mediaCustomerIds.length > 0 ? runtime.baseQuery.mediaCustomerIds.join(", ") : "\u5168\u90E8\u8D26\u53F7";
5255
+ const startDay = runtime.baseQuery.startDate.slice(0, 10);
5256
+ const endDay = runtime.baseQuery.endDate.slice(0, 10);
5257
+ console.log(
5258
+ `# \u8FD0\u8425\u62A5\u8868\uFF5C${runtime.baseQuery.mediaTypes.join(",")}\uFF5C${accountScope}\uFF5C${startDay}~${endDay}\uFF5C${runtime.method}
5259
+ `
5260
+ );
5261
+ if (sections.operation && typeof sections.operation === "object") {
5262
+ const op = sections.operation;
5263
+ const core = Array.isArray(op.coreData) ? [...op.coreData] : [];
5264
+ if (typeof sections["total-fans"] === "number") {
5265
+ if (!core.some((item) => item.name === "TotalFans")) {
5266
+ core.push({
5267
+ name: "TotalFans",
5268
+ value: sections["total-fans"],
5269
+ incrementRate: null
5270
+ });
5271
+ }
5272
+ }
5273
+ console.log("## \u6838\u5FC3\u6307\u6807\n");
5274
+ if (core.length > 0) {
5275
+ console.log("| \u6307\u6807 | \u5F53\u524D\u503C | \u73AF\u6BD4(%) |");
5276
+ console.log("| --- | --- | --- |");
5277
+ for (const item of core) {
5278
+ const val = item.value === null || item.value === void 0 ? "-" : String(item.value);
5279
+ const rate = item.incrementRate === null || item.incrementRate === void 0 ? "-" : String(item.incrementRate);
5280
+ console.log(`| ${item.name} | ${val} | ${rate} |`);
5281
+ }
5282
+ console.log();
5283
+ } else {
5284
+ console.log("_\uFF08\u65E0\u6838\u5FC3\u6307\u6807\u6570\u636E\uFF09_\n");
5285
+ }
5286
+ }
5287
+ if (Array.isArray(sections.works)) {
5288
+ const works = sections.works;
5289
+ console.log("## \u89C6\u9891\u660E\u7EC6\n");
5290
+ if (works.length > 0) {
5291
+ console.log("| \u6392\u540D | \u6807\u9898 | \u64AD\u653E | \u70B9\u8D5E | \u8BC4\u8BBA |");
5292
+ console.log("| --- | --- | --- | --- | --- |");
5293
+ works.forEach((item, idx) => {
5294
+ const title = String(item.title ?? item.name ?? "-");
5295
+ const play = String(item.play ?? item.playCount ?? "-");
5296
+ const digg = String(item.digg ?? item.likeCount ?? "-");
5297
+ const comment = String(item.comment ?? item.commentCount ?? "-");
5298
+ console.log(`| ${idx + 1} | ${title} | ${play} | ${digg} | ${comment} |`);
5299
+ });
5300
+ console.log();
5301
+ } else {
5302
+ console.log("_\uFF08\u65E0\u89C6\u9891\u6570\u636E\uFF09_\n");
5303
+ }
5304
+ }
5305
+ const otherModules = includeModules.filter(
5306
+ (m) => m !== "operation" && m !== "works" && m !== "total-fans"
5307
+ );
5308
+ for (const moduleName of otherModules) {
5309
+ const data = sections[moduleName];
5310
+ if (data === null || data === void 0) continue;
5311
+ if (Array.isArray(data) && data.length === 0) continue;
5312
+ if (typeof data === "object" && !Array.isArray(data) && Object.keys(data).length === 0)
5313
+ continue;
5314
+ const title = MODULE_TITLES[moduleName] ?? moduleName;
5315
+ console.log(`## ${title}
5316
+ `);
5317
+ renderMarkdownValue(data);
5318
+ }
5319
+ }
4425
5320
 
4426
5321
  // src/commands/report/commands.ts
4427
5322
  import * as fs9 from "fs";
@@ -4547,7 +5442,7 @@ async function runReportFetch(options) {
4547
5442
  }
4548
5443
  printMarkdownFetch(runtime, includeModules, sections);
4549
5444
  }
4550
- function parsePositiveInt2(value, optionName, defaultValue) {
5445
+ function parsePositiveInt(value, optionName, defaultValue) {
4551
5446
  if (!value) return defaultValue;
4552
5447
  const num = Number(value);
4553
5448
  if (!Number.isInteger(num) || num <= 0) {
@@ -4577,10 +5472,10 @@ function renderRecordTable(list, unicode = false) {
4577
5472
  }
4578
5473
  async function runReportRecords(options) {
4579
5474
  const config = loadConfig(options.token);
4580
- const page = parsePositiveInt2(options.page, "--page", 1);
4581
- const size = parsePositiveInt2(options.pageSize, "--page-size", 20);
5475
+ const page = parsePositiveInt(options.page, "--page", 1);
5476
+ const size = parsePositiveInt(options.pageSize, "--page-size", 20);
4582
5477
  const verbose = Boolean(options.verbose);
4583
- const url = `${config.csoBaseUrl}/cso/v1/accountData/OperationsReportRecord/2?` + createQueryString2({ page, size });
5478
+ const url = `${config.csoBaseUrl}/cso/v1/accountData/OperationsReportRecord/2?` + createQueryString({ page, size });
4584
5479
  let data;
4585
5480
  try {
4586
5481
  const res = await apiFetch2(url, config, {}, verbose);
@@ -4625,7 +5520,7 @@ async function runReportDownload(options) {
4625
5520
  }
4626
5521
  const config = loadConfig(options.token);
4627
5522
  const verbose = Boolean(options.verbose);
4628
- const url = `${config.csoBaseUrl}/cso/v1/accountData/DownLoadOperationsReport/2?` + createQueryString2({ id: options.id });
5523
+ const url = `${config.csoBaseUrl}/cso/v1/accountData/DownLoadOperationsReport/2?` + createQueryString({ id: options.id });
4629
5524
  let pdfUrl = "";
4630
5525
  try {
4631
5526
  const res = await apiFetch2(url, config, { method: "POST" }, verbose);
@@ -4681,7 +5576,7 @@ function normalizeApiPayload(raw) {
4681
5576
  }
4682
5577
  return raw;
4683
5578
  }
4684
- function createQueryString3(query) {
5579
+ function createQueryString2(query) {
4685
5580
  const params = new URLSearchParams();
4686
5581
  for (const [key, value] of Object.entries(query)) {
4687
5582
  if (value === void 0 || value === null || value === "") continue;
@@ -4689,7 +5584,7 @@ function createQueryString3(query) {
4689
5584
  }
4690
5585
  return params.toString();
4691
5586
  }
4692
- function parsePositiveInt3(value, optionName, defaultValue) {
5587
+ function parsePositiveInt2(value, optionName, defaultValue) {
4693
5588
  if (!value) return defaultValue;
4694
5589
  const num = Number(value);
4695
5590
  if (!Number.isInteger(num) || num <= 0) {
@@ -4847,9 +5742,9 @@ import * as path10 from "path";
4847
5742
  async function runPlanningEnterprises(options) {
4848
5743
  const config = loadConfig(options.token);
4849
5744
  const verbose = Boolean(options.verbose);
4850
- const pageSize = parsePositiveInt3(options.pageSize, "--page-size", 100);
5745
+ const pageSize = parsePositiveInt2(options.pageSize, "--page-size", 100);
4851
5746
  const belongToId = String(options.belongToId ?? "").trim();
4852
- const query = createQueryString3({
5747
+ const query = createQueryString2({
4853
5748
  folderId: TOPIC_FOLDER_ID,
4854
5749
  belongTo: 0,
4855
5750
  belongToId,
@@ -5129,10 +6024,10 @@ async function runPlanningGenerate(options) {
5129
6024
  async function runPlanningList(options) {
5130
6025
  const config = loadConfig(options.token);
5131
6026
  const verbose = Boolean(options.verbose);
5132
- const pageIndex = parsePositiveInt3(options.pageIndex, "--page-index", 1);
5133
- const pageSize = parsePositiveInt3(options.pageSize, "--page-size", 10);
6027
+ const pageIndex = parsePositiveInt2(options.pageIndex, "--page-index", 1);
6028
+ const pageSize = parsePositiveInt2(options.pageSize, "--page-size", 10);
5134
6029
  const yearMonth = options.yearMonth ? ensureYearMonth(options.yearMonth, "--year-month") : void 0;
5135
- const query = createQueryString3({
6030
+ const query = createQueryString2({
5136
6031
  enterpriseId: options.enterpriseId?.trim() || void 0,
5137
6032
  yearMonth,
5138
6033
  pageIndex,
@@ -5403,6 +6298,85 @@ async function runPlanningExportTxt(options) {
5403
6298
  }
5404
6299
 
5405
6300
  // src/commands/task/_shared.ts
6301
+ var TASK_MEDIA_MAP = {
6302
+ Kuaishou: 11,
6303
+ Douyin: 12,
6304
+ TikTokBusinessAccount: 13,
6305
+ WeChatChannel: 14,
6306
+ Facebook: 5,
6307
+ YouTube: 8,
6308
+ Instagram: 18,
6309
+ Linkedin: 19,
6310
+ Twitter: 22
6311
+ };
6312
+ function exitWithError3(message) {
6313
+ console.error(`
6314
+ \u274C ${message}
6315
+ `);
6316
+ process.exit(1);
6317
+ }
6318
+ function parsePositiveInt3(input, field, defaultValue) {
6319
+ if (!input) return defaultValue;
6320
+ const n = Number(input);
6321
+ if (!Number.isInteger(n) || n <= 0) {
6322
+ exitWithError3(`${field} \u5FC5\u987B\u662F\u6B63\u6574\u6570\uFF0C\u6536\u5230\uFF1A${input}`);
6323
+ }
6324
+ return n;
6325
+ }
6326
+ function parseTaskStatus(input) {
6327
+ if (!input) return -1;
6328
+ const n = Number(input);
6329
+ if (n === -1 || n === 0 || n === 1 || n === 2) return n;
6330
+ exitWithError3(`--status \u4EC5\u652F\u6301 -1 | 0 | 1 | 2\uFF0C\u6536\u5230\uFF1A${input}`);
6331
+ }
6332
+ function parseContentType(input) {
6333
+ if (!input || input === "all") return void 0;
6334
+ if (input === "video") return "Video";
6335
+ if (input === "image-text") return "ImageText";
6336
+ exitWithError3(`--content-type \u4EC5\u652F\u6301 all | video | image-text\uFF0C\u6536\u5230\uFF1A${input}`);
6337
+ }
6338
+ function formatDateRange(datePreset, startDateInput, endDateInput) {
6339
+ if (startDateInput || endDateInput) {
6340
+ if (!startDateInput || !endDateInput) {
6341
+ exitWithError3("\u4F7F\u7528\u81EA\u5B9A\u4E49\u65F6\u95F4\u65F6\uFF0C--start-date \u548C --end-date \u5FC5\u987B\u540C\u65F6\u63D0\u4F9B");
6342
+ }
6343
+ return {
6344
+ startDate: `${startDateInput} 00:00:00`,
6345
+ endDate: `${endDateInput} 23:59:59`
6346
+ };
6347
+ }
6348
+ if (!datePreset || datePreset === "all") {
6349
+ return { startDate: "", endDate: "" };
6350
+ }
6351
+ const now = /* @__PURE__ */ new Date();
6352
+ const start = new Date(now);
6353
+ if (datePreset === "week") start.setDate(now.getDate() - 7);
6354
+ if (datePreset === "month") start.setMonth(now.getMonth() - 1);
6355
+ if (datePreset === "year") start.setFullYear(now.getFullYear() - 1);
6356
+ const pad = (v) => String(v).padStart(2, "0");
6357
+ const fmt = (d) => `${d.getFullYear()}-${pad(d.getMonth() + 1)}-${pad(d.getDate())}`;
6358
+ return {
6359
+ startDate: `${fmt(start)} 00:00:00`,
6360
+ endDate: `${fmt(now)} 23:59:59`
6361
+ };
6362
+ }
6363
+ function createQueryString3(query) {
6364
+ const params = new URLSearchParams();
6365
+ for (const [key, value] of Object.entries(query)) {
6366
+ if (value === void 0 || value === null) continue;
6367
+ params.append(key, String(value));
6368
+ }
6369
+ return params.toString();
6370
+ }
6371
+ function resolveMediaTypeForApi(input) {
6372
+ const trimmed = input.trim();
6373
+ if (!trimmed) exitWithError3("\u5A92\u4F53\u7C7B\u578B\u4E0D\u80FD\u4E3A\u7A7A");
6374
+ if (/^\d+$/.test(trimmed)) return trimmed;
6375
+ if (trimmed in TASK_MEDIA_MAP) return String(TASK_MEDIA_MAP[trimmed]);
6376
+ exitWithError3(
6377
+ `\u672A\u77E5\u5A92\u4F53\u7C7B\u578B\uFF1A${input}\u3002\u53EF\u7528\u503C\uFF1A${Object.keys(TASK_MEDIA_MAP).join(", ")} \u6216\u6570\u5B57 ID`
6378
+ );
6379
+ }
5406
6380
  function statusLabel(status) {
5407
6381
  if (status === 0) return "\u6267\u884C\u4E2D";
5408
6382
  if (status === 1) return "\u5DF2\u5B8C\u6210";
@@ -5417,15 +6391,42 @@ function itemStatusLabel(status) {
5417
6391
  if (status === 9) return "\u5B9A\u65F6\u53D1\u5E03";
5418
6392
  return status === void 0 ? "-" : String(status);
5419
6393
  }
6394
+ function tableOpts(unicode) {
6395
+ return unicode ? { plain: false } : void 0;
6396
+ }
5420
6397
  function isTaskMutationSuccess(code) {
5421
6398
  return code === 1 || code !== 400;
5422
6399
  }
6400
+ async function postForm(endpoint, body, options) {
6401
+ const config = loadConfig(options.token);
6402
+ return apiFetch2(
6403
+ `${config.csoBaseUrl}${endpoint}`,
6404
+ config,
6405
+ {
6406
+ method: "POST",
6407
+ headers: { "Content-Type": "application/x-www-form-urlencoded;charset=UTF-8" },
6408
+ body: new URLSearchParams(body).toString()
6409
+ },
6410
+ Boolean(options.verbose)
6411
+ );
6412
+ }
6413
+ async function postNoBody(endpoint, options) {
6414
+ const config = loadConfig(options.token);
6415
+ return apiFetch2(
6416
+ `${config.csoBaseUrl}${endpoint}`,
6417
+ config,
6418
+ {
6419
+ method: "POST"
6420
+ },
6421
+ Boolean(options.verbose)
6422
+ );
6423
+ }
5423
6424
 
5424
6425
  // src/commands/task/commands.ts
5425
6426
  async function runTaskList(options) {
5426
6427
  const config = loadConfig(options.token);
5427
- const page = parsePositiveInt(options.page, "--page", 1);
5428
- const size = parsePositiveInt(options.size, "--size", 10);
6428
+ const page = parsePositiveInt3(options.page, "--page", 1);
6429
+ const size = parsePositiveInt3(options.size, "--size", 10);
5429
6430
  const status = parseTaskStatus(options.status);
5430
6431
  const contentType = parseContentType(options.contentType);
5431
6432
  const { startDate, endDate } = formatDateRange(
@@ -5438,14 +6439,14 @@ async function runTaskList(options) {
5438
6439
  let creator = options.creator ?? "";
5439
6440
  if (options.mine) {
5440
6441
  if (!options.mineName) {
5441
- exitWithError("\u4F7F\u7528 --mine \u65F6\u9700\u8981\u63D0\u4F9B --mine-name <\u4F60\u7684\u7528\u6237\u540D>");
6442
+ exitWithError3("\u4F7F\u7528 --mine \u65F6\u9700\u8981\u63D0\u4F9B --mine-name <\u4F60\u7684\u7528\u6237\u540D>");
5442
6443
  }
5443
6444
  creator = options.mineName;
5444
6445
  } else if (options.keyword) {
5445
6446
  if (options.searchType === "creator") creator = options.keyword;
5446
6447
  else taskName = options.keyword;
5447
6448
  }
5448
- const url = `${config.csoBaseUrl}/cso/v1/task/taskList/2?${createQueryString({
6449
+ const url = `${config.csoBaseUrl}/cso/v1/task/taskList/2?${createQueryString3({
5449
6450
  page,
5450
6451
  size,
5451
6452
  status,
@@ -5468,7 +6469,7 @@ async function runTaskList(options) {
5468
6469
  if (!res.data) throw new Error(res.message || "\u670D\u52A1\u7AEF\u672A\u8FD4\u56DE\u5217\u8868\u6570\u636E");
5469
6470
  data = res.data;
5470
6471
  } catch (error) {
5471
- exitWithError(`\u83B7\u53D6\u4EFB\u52A1\u5217\u8868\u5931\u8D25\uFF1A${error.message}`);
6472
+ exitWithError3(`\u83B7\u53D6\u4EFB\u52A1\u5217\u8868\u5931\u8D25\uFF1A${error.message}`);
5472
6473
  }
5473
6474
  const list = Array.isArray(data.list) ? data.list : [];
5474
6475
  const total = data.total ?? 0;
@@ -5504,12 +6505,12 @@ async function runTaskList(options) {
5504
6505
  console.log();
5505
6506
  }
5506
6507
  async function runTaskDetail(options) {
5507
- if (!options.publishId) exitWithError("\u8BF7\u63D0\u4F9B --publish-id");
6508
+ if (!options.publishId) exitWithError3("\u8BF7\u63D0\u4F9B --publish-id");
5508
6509
  const config = loadConfig(options.token);
5509
- const page = parsePositiveInt(options.page, "--page", 1);
5510
- const size = parsePositiveInt(options.size, "--size", 10);
6510
+ const page = parsePositiveInt3(options.page, "--page", 1);
6511
+ const size = parsePositiveInt3(options.size, "--size", 10);
5511
6512
  const mediaType = options.media ? resolveMediaTypeForApi(options.media) : null;
5512
- const url = `${config.csoBaseUrl}/cso/v1/task/taskDetail/2?${createQueryString({
6513
+ const url = `${config.csoBaseUrl}/cso/v1/task/taskDetail/2?${createQueryString3({
5513
6514
  publishId: options.publishId,
5514
6515
  page,
5515
6516
  size,
@@ -5526,7 +6527,7 @@ async function runTaskDetail(options) {
5526
6527
  if (!res.data) throw new Error(res.message || "\u670D\u52A1\u7AEF\u672A\u8FD4\u56DE\u8BE6\u60C5\u6570\u636E");
5527
6528
  data = res.data;
5528
6529
  } catch (error) {
5529
- exitWithError(`\u83B7\u53D6\u4EFB\u52A1\u8BE6\u60C5\u5931\u8D25\uFF1A${error.message}`);
6530
+ exitWithError3(`\u83B7\u53D6\u4EFB\u52A1\u8BE6\u60C5\u5931\u8D25\uFF1A${error.message}`);
5530
6531
  }
5531
6532
  const list = Array.isArray(data.list) ? data.list : [];
5532
6533
  const raw = data;
@@ -5579,17 +6580,17 @@ async function runTaskMutation(endpoint, body, options, successText) {
5579
6580
  try {
5580
6581
  res = body ? await postForm(endpoint, body, options) : await postNoBody(endpoint, options);
5581
6582
  } catch (error) {
5582
- exitWithError(`${successText}\u5931\u8D25\uFF1A${error.message}`);
6583
+ exitWithError3(`${successText}\u5931\u8D25\uFF1A${error.message}`);
5583
6584
  }
5584
6585
  if (!isTaskMutationSuccess(res.code)) {
5585
- exitWithError(res.message || `${successText}\u5931\u8D25\uFF08code=${res.code}\uFF09`);
6586
+ exitWithError3(res.message || `${successText}\u5931\u8D25\uFF08code=${res.code}\uFF09`);
5586
6587
  }
5587
6588
  console.log(`
5588
6589
  \u2705 ${successText}\u6210\u529F
5589
6590
  `);
5590
6591
  }
5591
6592
  async function runTaskStart(options) {
5592
- if (!options.publishId) exitWithError("\u8BF7\u63D0\u4F9B --publish-id");
6593
+ if (!options.publishId) exitWithError3("\u8BF7\u63D0\u4F9B --publish-id");
5593
6594
  await runTaskMutation(
5594
6595
  "/cso/v1/task/startTask",
5595
6596
  { publishId: options.publishId },
@@ -5598,7 +6599,7 @@ async function runTaskStart(options) {
5598
6599
  );
5599
6600
  }
5600
6601
  async function runTaskStop(options) {
5601
- if (!options.publishId) exitWithError("\u8BF7\u63D0\u4F9B --publish-id");
6602
+ if (!options.publishId) exitWithError3("\u8BF7\u63D0\u4F9B --publish-id");
5602
6603
  await runTaskMutation(
5603
6604
  "/cso/v1/task/stopTask",
5604
6605
  { publishId: options.publishId },
@@ -5607,7 +6608,7 @@ async function runTaskStop(options) {
5607
6608
  );
5608
6609
  }
5609
6610
  async function runTaskDelete(options) {
5610
- if (!options.publishId) exitWithError("\u8BF7\u63D0\u4F9B --publish-id");
6611
+ if (!options.publishId) exitWithError3("\u8BF7\u63D0\u4F9B --publish-id");
5611
6612
  await runTaskMutation(
5612
6613
  "/cso/v1/task/deleteTask",
5613
6614
  { publishId: options.publishId },
@@ -5616,8 +6617,8 @@ async function runTaskDelete(options) {
5616
6617
  );
5617
6618
  }
5618
6619
  async function runTaskRename(options) {
5619
- if (!options.publishId) exitWithError("\u8BF7\u63D0\u4F9B --publish-id");
5620
- if (!options.name?.trim()) exitWithError("\u8BF7\u63D0\u4F9B\u975E\u7A7A\u7684 --name");
6620
+ if (!options.publishId) exitWithError3("\u8BF7\u63D0\u4F9B --publish-id");
6621
+ if (!options.name?.trim()) exitWithError3("\u8BF7\u63D0\u4F9B\u975E\u7A7A\u7684 --name");
5621
6622
  let res;
5622
6623
  try {
5623
6624
  res = await postForm(
@@ -5629,25 +6630,25 @@ async function runTaskRename(options) {
5629
6630
  options
5630
6631
  );
5631
6632
  } catch (error) {
5632
- exitWithError(`\u91CD\u547D\u540D\u4EFB\u52A1\u5931\u8D25\uFF1A${error.message}`);
6633
+ exitWithError3(`\u91CD\u547D\u540D\u4EFB\u52A1\u5931\u8D25\uFF1A${error.message}`);
5633
6634
  }
5634
6635
  if (res.code !== 1) {
5635
- exitWithError(res.message || `\u91CD\u547D\u540D\u4EFB\u52A1\u5931\u8D25\uFF08code=${res.code}\uFF09`);
6636
+ exitWithError3(res.message || `\u91CD\u547D\u540D\u4EFB\u52A1\u5931\u8D25\uFF08code=${res.code}\uFF09`);
5636
6637
  }
5637
6638
  console.log("\n\u2705 \u91CD\u547D\u540D\u4EFB\u52A1\u6210\u529F\n");
5638
6639
  }
5639
6640
  async function runTaskCheckEdit(options) {
5640
- if (!options.publishId) exitWithError("\u8BF7\u63D0\u4F9B --publish-id");
6641
+ if (!options.publishId) exitWithError3("\u8BF7\u63D0\u4F9B --publish-id");
5641
6642
  const config = loadConfig(options.token);
5642
- const url = `${config.csoBaseUrl}/cso/v1/task/checkAllowChange?${createQueryString({ publishId: options.publishId })}`;
6643
+ const url = `${config.csoBaseUrl}/cso/v1/task/checkAllowChange?${createQueryString3({ publishId: options.publishId })}`;
5643
6644
  let res;
5644
6645
  try {
5645
6646
  res = await apiFetch2(url, config, {}, Boolean(options.verbose));
5646
6647
  } catch (error) {
5647
- exitWithError(`\u68C0\u67E5\u53EF\u7F16\u8F91\u72B6\u6001\u5931\u8D25\uFF1A${error.message}`);
6648
+ exitWithError3(`\u68C0\u67E5\u53EF\u7F16\u8F91\u72B6\u6001\u5931\u8D25\uFF1A${error.message}`);
5648
6649
  }
5649
6650
  if (res.code !== 1 || !res.data) {
5650
- exitWithError(res.message || `\u68C0\u67E5\u53EF\u7F16\u8F91\u72B6\u6001\u5931\u8D25\uFF08code=${res.code}\uFF09`);
6651
+ exitWithError3(res.message || `\u68C0\u67E5\u53EF\u7F16\u8F91\u72B6\u6001\u5931\u8D25\uFF08code=${res.code}\uFF09`);
5651
6652
  }
5652
6653
  const allowChange = Boolean(res.data.allowChange);
5653
6654
  if (options.json) {
@@ -5662,7 +6663,7 @@ allowChange: ${allowChange ? "true" : "false"}`);
5662
6663
  console.log();
5663
6664
  }
5664
6665
  async function runTaskItemDelete(options) {
5665
- if (!options.itemId) exitWithError("\u8BF7\u63D0\u4F9B --item-id");
6666
+ if (!options.itemId) exitWithError3("\u8BF7\u63D0\u4F9B --item-id");
5666
6667
  await runTaskMutation(
5667
6668
  `/cso/v1/task/deletePublishItem/${options.itemId}`,
5668
6669
  null,
@@ -5671,17 +6672,17 @@ async function runTaskItemDelete(options) {
5671
6672
  );
5672
6673
  }
5673
6674
  async function runTaskItemRepublish(options) {
5674
- if (!options.itemId) exitWithError("\u8BF7\u63D0\u4F9B --item-id");
6675
+ if (!options.itemId) exitWithError3("\u8BF7\u63D0\u4F9B --item-id");
5675
6676
  await runTaskMutation(`/cso/v1/task/rePublish/${options.itemId}`, null, options, "\u91CD\u65B0\u53D1\u5E03");
5676
6677
  }
5677
6678
  async function runTaskItemRunNow(options) {
5678
- if (!options.itemId) exitWithError("\u8BF7\u63D0\u4F9B --item-id");
6679
+ if (!options.itemId) exitWithError3("\u8BF7\u63D0\u4F9B --item-id");
5679
6680
  await runTaskMutation(`/cso/v1/task/runPublish/${options.itemId}`, null, options, "\u7ACB\u5373\u53D1\u5E03");
5680
6681
  }
5681
6682
  async function runTaskCommentList(options) {
5682
6683
  const config = loadConfig(options.token);
5683
6684
  const mediaType = resolveMediaTypeForApi(options.mediaType);
5684
- const url = `${config.csoBaseUrl}/cso/v1/comment/listByVideoId/2/${mediaType}?${createQueryString(
6685
+ const url = `${config.csoBaseUrl}/cso/v1/comment/listByVideoId/2/${mediaType}?${createQueryString3(
5685
6686
  {
5686
6687
  videoId: encodeURIComponent(options.videoId),
5687
6688
  mediaCustomerId: options.mediaCustomerId
@@ -5700,7 +6701,7 @@ async function runTaskCommentList(options) {
5700
6701
  }
5701
6702
  data = res.data;
5702
6703
  } catch (error) {
5703
- exitWithError(`\u83B7\u53D6\u8BC4\u8BBA\u5217\u8868\u5931\u8D25\uFF1A${error.message}`);
6704
+ exitWithError3(`\u83B7\u53D6\u8BC4\u8BBA\u5217\u8868\u5931\u8D25\uFF1A${error.message}`);
5704
6705
  }
5705
6706
  const list = Array.isArray(data.list) ? data.list : [];
5706
6707
  const total = data.total ?? 0;
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "slug": "siluzan-cso",
3
- "version": "1.1.18-beta.5",
4
- "publishedAt": 1778666071422,
3
+ "version": "1.1.18-beta.6",
4
+ "publishedAt": 1778753569676,
5
5
  "homepage": "https://www.siluzan.com",
6
6
  "source": "https://dev.azure.com/jack4it/Sammamish/_git/siluzan-skill",
7
7
  "requiredBinaries": [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "siluzan-cso-cli",
3
- "version": "1.1.18-beta.5",
3
+ "version": "1.1.18-beta.6",
4
4
  "description": "Siluzan platform AI Skill CLI — multi-platform content publishing (video/image-text) for Cursor, Claude Code, and OpenClaw.",
5
5
  "keywords": [
6
6
  "ai-skill",