siluzan-cso-cli 1.1.8-beta.2 → 1.1.8-beta.3

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
@@ -20,7 +20,7 @@ siluzan-cso init -d /path/to/skills # 写入自定义目录
20
20
  siluzan-cso init --force # 强制覆盖已存在文件
21
21
  ```
22
22
 
23
- > **注意**:当前为测试版(1.1.8-beta.2),供内部测试使用。正式发布后安装命令将改为 `npm install -g siluzan-cso-cli`。
23
+ > **注意**:当前为测试版(1.1.8-beta.3),供内部测试使用。正式发布后安装命令将改为 `npm install -g siluzan-cso-cli`。
24
24
 
25
25
  | 助手 | 建议 `--ai` |
26
26
  |------|-------------|
package/dist/index.js CHANGED
@@ -4760,55 +4760,161 @@ async function getWithQuery(runtime, endpoint, query) {
4760
4760
  }
4761
4761
  return res.data;
4762
4762
  }
4763
- function renderCoreData(coreData, unicode = false) {
4764
- if (coreData.length === 0) {
4765
- console.log(" \u6838\u5FC3\u6307\u6807\u4E3A\u7A7A\u3002");
4763
+ var MODULE_TITLES = {
4764
+ "total-fans": "\u603B\u7C89\u4E1D\u6570",
4765
+ "fans-analysis": "\u7C89\u4E1D\u5206\u6790",
4766
+ "hot-topic": "\u70ED\u95E8\u8BDD\u9898",
4767
+ "hot-comment-word": "\u70ED\u95E8\u8BC4\u8BBA\u8BCD",
4768
+ "comment-top10": "\u8BC4\u8BBA Top10",
4769
+ "video-duration": "\u89C6\u9891\u65F6\u957F\u5206\u5E03",
4770
+ "video-distribution": "\u89C6\u9891\u5206\u5E03",
4771
+ "comment-trend": "\u8BC4\u8BBA\u8D8B\u52BF",
4772
+ "fans-trend": "\u7C89\u4E1D\u8D8B\u52BF",
4773
+ "new-fans-trend": "\u65B0\u589E\u7C89\u4E1D\u8D8B\u52BF",
4774
+ "homepage-visit": "\u4E3B\u9875\u8BBF\u95EE\u8D8B\u52BF"
4775
+ };
4776
+ function renderMarkdownArrayOfObjects(rows) {
4777
+ if (rows.length === 0) {
4766
4778
  return;
4767
4779
  }
4768
- const columns = [
4769
- { key: "name", header: "\u6307\u6807" },
4770
- { key: "value", header: "\u5F53\u524D\u503C" },
4771
- { key: "incrementRate", header: "\u73AF\u6BD4(%)" }
4772
- ];
4773
- const rows = coreData.map((item) => ({
4774
- name: item.name,
4775
- value: item.value === null || item.value === void 0 ? "-" : String(item.value),
4776
- incrementRate: item.incrementRate === null || item.incrementRate === void 0 ? "-" : String(item.incrementRate)
4777
- }));
4778
- const tableOptions2 = unicode ? { plain: false } : void 0;
4779
- printCliTable(rows, columns, tableOptions2);
4780
+ const keys = Object.keys(rows[0]);
4781
+ console.log("| " + keys.join(" | ") + " |");
4782
+ console.log("| " + keys.map(() => "---").join(" | ") + " |");
4783
+ for (const row of rows) {
4784
+ console.log("| " + keys.map((k) => String(row[k] ?? "-")).join(" | ") + " |");
4785
+ }
4786
+ console.log();
4780
4787
  }
4781
- function renderWorksData(worksData, unicode = false) {
4782
- if (worksData.length === 0) {
4783
- console.log(" \u89C6\u9891\u660E\u7EC6\u4E3A\u7A7A\u3002");
4788
+ function isTimeSeries(arr) {
4789
+ if (arr.length === 0) return false;
4790
+ const first = arr[0];
4791
+ if ("date" in first && "count" in first) return true;
4792
+ if ("name" in first && "value" in first) {
4793
+ const name = first.name;
4794
+ return typeof name === "number" || typeof name === "string" && /^\d{4}-\d{2}-\d{2}/.test(name);
4795
+ }
4796
+ return false;
4797
+ }
4798
+ function renderTimeSeries(arr) {
4799
+ const keyField = "date" in arr[0] ? "date" : "name";
4800
+ const valField = "count" in arr[0] ? "count" : "value";
4801
+ const nonZero = arr.filter((item) => {
4802
+ const v = item[valField];
4803
+ return v !== null && v !== void 0 && Number(v) !== 0;
4804
+ });
4805
+ if (nonZero.length === 0) {
4806
+ console.log(`_\uFF08${arr.length}\u6761\u5747\u4E3A0\uFF09_
4807
+ `);
4784
4808
  return;
4785
4809
  }
4786
- const columns = [
4787
- { key: "rank", header: "\u6392\u540D" },
4788
- { key: "title", header: "\u6807\u9898" },
4789
- { key: "play", header: "\u64AD\u653E" },
4790
- { key: "digg", header: "\u70B9\u8D5E" },
4791
- { key: "comment", header: "\u8BC4\u8BBA" }
4792
- ];
4793
- const rows = worksData.slice(0, 10).map((item, index) => ({
4794
- rank: String(index + 1),
4795
- title: String(item.title ?? item.name ?? "-"),
4796
- play: String(item.play ?? item.playCount ?? "-"),
4797
- digg: String(item.digg ?? item.likeCount ?? "-"),
4798
- comment: String(item.comment ?? item.commentCount ?? "-")
4799
- }));
4800
- const tableOptions2 = unicode ? { plain: false } : void 0;
4801
- printCliTable(rows, columns, tableOptions2);
4810
+ if (nonZero.length <= 6) {
4811
+ const pairs = nonZero.map((item) => `${item[keyField]}:${item[valField]}`).join(", ");
4812
+ const zeroCount = arr.length - nonZero.length;
4813
+ console.log(`${pairs}${zeroCount > 0 ? `\uFF08\u5176\u4F59${zeroCount}\u6761\u4E3A0\uFF09` : ""}
4814
+ `);
4815
+ return;
4816
+ }
4817
+ renderMarkdownArrayOfObjects(arr);
4802
4818
  }
4803
- function printFetchSummary(runtime, modules) {
4819
+ function renderMarkdownValue(data) {
4820
+ if (data === null || data === void 0) return;
4821
+ if (Array.isArray(data)) {
4822
+ if (data.length === 0) return;
4823
+ if (typeof data[0] === "object" && data[0] !== null) {
4824
+ const rows = data;
4825
+ if (isTimeSeries(rows)) {
4826
+ renderTimeSeries(rows);
4827
+ } else {
4828
+ renderMarkdownArrayOfObjects(rows);
4829
+ }
4830
+ } else {
4831
+ for (const item of data) console.log(`- ${String(item)}`);
4832
+ console.log();
4833
+ }
4834
+ return;
4835
+ }
4836
+ if (typeof data === "object") {
4837
+ const obj = data;
4838
+ const keys = Object.keys(obj);
4839
+ if (keys.length === 0) return;
4840
+ const summaryParts = [];
4841
+ for (const key of keys) {
4842
+ const val = obj[key];
4843
+ if (Array.isArray(val) && val.length > 0 && typeof val[0] === "object") {
4844
+ if (summaryParts.length > 0) {
4845
+ console.log(summaryParts.join(" | ") + "\n");
4846
+ summaryParts.length = 0;
4847
+ }
4848
+ console.log(`**${key}**`);
4849
+ renderMarkdownValue(val);
4850
+ } else if (!Array.isArray(val)) {
4851
+ summaryParts.push(`${key}: ${JSON.stringify(val)}`);
4852
+ }
4853
+ }
4854
+ if (summaryParts.length > 0) console.log(summaryParts.join(" | ") + "\n");
4855
+ return;
4856
+ }
4857
+ console.log(String(data) + "\n");
4858
+ }
4859
+ function printMarkdownFetch(runtime, includeModules, sections) {
4804
4860
  const accountScope = runtime.baseQuery.mediaCustomerIds.length > 0 ? runtime.baseQuery.mediaCustomerIds.join(", ") : "\u5168\u90E8\u8D26\u53F7";
4805
- console.log("\n\u8FD0\u8425\u62A5\u8868\u67E5\u8BE2\u53C2\u6570\uFF1A");
4806
- console.log(` \u5E73\u53F0\u7C7B\u578B(csoPlatformType): ${runtime.baseQuery.csoPlatformType}`);
4807
- console.log(` \u5A92\u4F53\u7C7B\u578B(mediaTypes): ${runtime.baseQuery.mediaTypes.join(", ")}`);
4808
- console.log(` \u8D26\u53F7\u8303\u56F4(mediaCustomerIds): ${accountScope}`);
4809
- console.log(` \u65F6\u95F4\u533A\u95F4(UTC): ${runtime.baseQuery.startDate} ~ ${runtime.baseQuery.endDate}`);
4810
- console.log(` \u805A\u5408\u7EF4\u5EA6(method): ${runtime.method}`);
4811
- console.log(` \u67E5\u8BE2\u6A21\u5757(include): ${modules.join(", ")}`);
4861
+ const startDay = runtime.baseQuery.startDate.slice(0, 10);
4862
+ const endDay = runtime.baseQuery.endDate.slice(0, 10);
4863
+ console.log(`# \u8FD0\u8425\u62A5\u8868\uFF5C${runtime.baseQuery.mediaTypes.join(",")}\uFF5C${accountScope}\uFF5C${startDay}~${endDay}\uFF5C${runtime.method}
4864
+ `);
4865
+ if (sections.operation && typeof sections.operation === "object") {
4866
+ const op = sections.operation;
4867
+ const core = Array.isArray(op.coreData) ? [...op.coreData] : [];
4868
+ if (typeof sections["total-fans"] === "number") {
4869
+ if (!core.some((item) => item.name === "TotalFans")) {
4870
+ core.push({ name: "TotalFans", value: sections["total-fans"], incrementRate: null });
4871
+ }
4872
+ }
4873
+ console.log("## \u6838\u5FC3\u6307\u6807\n");
4874
+ if (core.length > 0) {
4875
+ console.log("| \u6307\u6807 | \u5F53\u524D\u503C | \u73AF\u6BD4(%) |");
4876
+ console.log("| --- | --- | --- |");
4877
+ for (const item of core) {
4878
+ const val = item.value === null || item.value === void 0 ? "-" : String(item.value);
4879
+ const rate = item.incrementRate === null || item.incrementRate === void 0 ? "-" : String(item.incrementRate);
4880
+ console.log(`| ${item.name} | ${val} | ${rate} |`);
4881
+ }
4882
+ console.log();
4883
+ } else {
4884
+ console.log("_\uFF08\u65E0\u6838\u5FC3\u6307\u6807\u6570\u636E\uFF09_\n");
4885
+ }
4886
+ }
4887
+ if (Array.isArray(sections.works)) {
4888
+ const works = sections.works;
4889
+ console.log("## \u89C6\u9891\u660E\u7EC6\n");
4890
+ if (works.length > 0) {
4891
+ console.log("| \u6392\u540D | \u6807\u9898 | \u64AD\u653E | \u70B9\u8D5E | \u8BC4\u8BBA |");
4892
+ console.log("| --- | --- | --- | --- | --- |");
4893
+ works.forEach((item, idx) => {
4894
+ const title = String(item.title ?? item.name ?? "-");
4895
+ const play = String(item.play ?? item.playCount ?? "-");
4896
+ const digg = String(item.digg ?? item.likeCount ?? "-");
4897
+ const comment = String(item.comment ?? item.commentCount ?? "-");
4898
+ console.log(`| ${idx + 1} | ${title} | ${play} | ${digg} | ${comment} |`);
4899
+ });
4900
+ console.log();
4901
+ } else {
4902
+ console.log("_\uFF08\u65E0\u89C6\u9891\u6570\u636E\uFF09_\n");
4903
+ }
4904
+ }
4905
+ const otherModules = includeModules.filter(
4906
+ (m) => m !== "operation" && m !== "works" && m !== "total-fans"
4907
+ );
4908
+ for (const moduleName of otherModules) {
4909
+ const data = sections[moduleName];
4910
+ if (data === null || data === void 0) continue;
4911
+ if (Array.isArray(data) && data.length === 0) continue;
4912
+ if (typeof data === "object" && !Array.isArray(data) && Object.keys(data).length === 0) continue;
4913
+ const title = MODULE_TITLES[moduleName] ?? moduleName;
4914
+ console.log(`## ${title}
4915
+ `);
4916
+ renderMarkdownValue(data);
4917
+ }
4812
4918
  }
4813
4919
  async function runReportFetch(options) {
4814
4920
  const runtime = buildRuntime(options);
@@ -4901,39 +5007,7 @@ async function runReportFetch(options) {
4901
5007
  console.log(JSON.stringify(payload, null, 2));
4902
5008
  return;
4903
5009
  }
4904
- printFetchSummary(runtime, includeModules);
4905
- if (sections.operation && typeof sections.operation === "object") {
4906
- const op = sections.operation;
4907
- const core = Array.isArray(op.coreData) ? [...op.coreData] : [];
4908
- if (typeof sections["total-fans"] === "number") {
4909
- const exists = core.some((item) => item.name === "TotalFans");
4910
- if (!exists) {
4911
- core.push({ name: "TotalFans", value: sections["total-fans"], incrementRate: null });
4912
- }
4913
- }
4914
- console.log("\n\u6838\u5FC3\u6307\u6807\uFF1A");
4915
- renderCoreData(core, options.unicode);
4916
- }
4917
- if (Array.isArray(sections.works)) {
4918
- console.log("\n\u89C6\u9891\u660E\u7EC6\uFF08\u6700\u591A\u5C55\u793A\u524D 10 \u6761\uFF09\uFF1A");
4919
- renderWorksData(sections.works, options.unicode);
4920
- }
4921
- const hiddenModules = includeModules.filter((m) => m !== "operation" && m !== "works");
4922
- if (hiddenModules.length > 0) {
4923
- console.log("\n\u5176\u4ED6\u6A21\u5757\u5DF2\u83B7\u53D6\uFF1A");
4924
- for (const m of hiddenModules) {
4925
- const data = sections[m];
4926
- if (Array.isArray(data)) {
4927
- console.log(` - ${m}: \u6570\u7EC4(${data.length})`);
4928
- } else if (data && typeof data === "object") {
4929
- console.log(` - ${m}: \u5BF9\u8C61`);
4930
- } else {
4931
- console.log(` - ${m}: ${String(data ?? "null")}`);
4932
- }
4933
- }
4934
- console.log("\u63D0\u793A\uFF1A\u5982\u9700\u5B8C\u6574\u7ED3\u6784\uFF0C\u8BF7\u52A0 --json\u3002");
4935
- }
4936
- console.log();
5010
+ printMarkdownFetch(runtime, includeModules, sections);
4937
5011
  }
4938
5012
  function parsePositiveInt(value, optionName, defaultValue) {
4939
5013
  if (!value) return defaultValue;
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "slug": "siluzan-cso",
3
- "version": "1.1.8-beta.2",
4
- "publishedAt": 1775642940171
3
+ "version": "1.1.8-beta.3",
4
+ "publishedAt": 1775698667005
5
5
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "siluzan-cso-cli",
3
- "version": "1.1.8-beta.2",
3
+ "version": "1.1.8-beta.3",
4
4
  "description": "Siluzan platform AI Skill CLI — multi-platform content publishing (video/image-text) for Cursor, Claude Code, and OpenClaw.",
5
5
  "type": "module",
6
6
  "bin": {