siluzan-cso-cli 1.1.8-beta.1 → 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 +1 -1
- package/dist/index.js +150 -80
- package/dist/skill/_meta.json +2 -2
- package/package.json +1 -1
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.
|
|
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
|
-
|
|
4764
|
-
|
|
4765
|
-
|
|
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
|
|
4769
|
-
|
|
4770
|
-
|
|
4771
|
-
|
|
4772
|
-
|
|
4773
|
-
|
|
4774
|
-
|
|
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
|
|
4782
|
-
if (
|
|
4783
|
-
|
|
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
|
-
|
|
4787
|
-
|
|
4788
|
-
|
|
4789
|
-
{
|
|
4790
|
-
|
|
4791
|
-
|
|
4792
|
-
|
|
4793
|
-
|
|
4794
|
-
|
|
4795
|
-
|
|
4796
|
-
|
|
4797
|
-
|
|
4798
|
-
|
|
4799
|
-
|
|
4800
|
-
|
|
4801
|
-
|
|
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);
|
|
4818
|
+
}
|
|
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");
|
|
4802
4858
|
}
|
|
4803
|
-
function
|
|
4859
|
+
function printMarkdownFetch(runtime, includeModules, sections) {
|
|
4804
4860
|
const accountScope = runtime.baseQuery.mediaCustomerIds.length > 0 ? runtime.baseQuery.mediaCustomerIds.join(", ") : "\u5168\u90E8\u8D26\u53F7";
|
|
4805
|
-
|
|
4806
|
-
|
|
4807
|
-
console.log(
|
|
4808
|
-
|
|
4809
|
-
|
|
4810
|
-
|
|
4811
|
-
|
|
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
|
-
|
|
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;
|
|
@@ -5025,10 +5099,6 @@ async function runReportDownload(options) {
|
|
|
5025
5099
|
const msg = error.message;
|
|
5026
5100
|
exitWithError(`\u83B7\u53D6\u4E0B\u8F7D\u5730\u5740\u5931\u8D25\uFF1A${msg}`);
|
|
5027
5101
|
}
|
|
5028
|
-
if (options.urlOnly) {
|
|
5029
|
-
console.log(pdfUrl);
|
|
5030
|
-
return;
|
|
5031
|
-
}
|
|
5032
5102
|
const output = path8.resolve(options.output ? options.output : defaultDownloadPath(options.id));
|
|
5033
5103
|
try {
|
|
5034
5104
|
await downloadFile(pdfUrl, output);
|
|
@@ -6773,7 +6843,7 @@ reportCmd.command("fetch").description("\u6309\u5A92\u4F53/\u65E5\u671F\u62C9\u5
|
|
|
6773
6843
|
reportCmd.command("records").description("\u67E5\u8BE2\u8FD0\u8425\u62A5\u8868\u5BFC\u51FA\u8BB0\u5F55\uFF08\u5BF9\u5E94 table \u5BFC\u51FA\u8BB0\u5F55\u5F39\u7A97\uFF09").option("--page <number>", "\u9875\u7801\uFF08\u9ED8\u8BA4 1\uFF09").option("--page-size <number>", "\u6BCF\u9875\u6761\u6570\uFF08\u9ED8\u8BA4 20\uFF09").option("-t, --token <token>", "Token\uFF08\u53EF\u9009\uFF1B\u4F18\u5148\u4E8E ~/.siluzan/config.json\uFF09").option("--json", "\u8F93\u51FA\u5B8C\u6574 JSON\uFF08\u9002\u5408\u811A\u672C\u5904\u7406\uFF09", false).option("--unicode", "\u4F7F\u7528 Unicode \u7EBF\u6846\u8868\u683C\uFF08\u9ED8\u8BA4 ASCII\uFF09", false).option("--verbose", "\u663E\u793A\u8BE6\u7EC6\u9519\u8BEF\u4FE1\u606F", false).action(async (opts) => {
|
|
6774
6844
|
await runReportRecords(opts);
|
|
6775
6845
|
});
|
|
6776
|
-
reportCmd.command("download").description("\u6309\u5BFC\u51FA\u8BB0\u5F55 ID \u4E0B\u8F7D\u8FD0\u8425\u62A5\u8868 PDF\uFF08\u5BF9\u5E94 table \u7684\u91CD\u65B0\u4E0B\u8F7D\uFF09").requiredOption("--id <recordId>", "\u5BFC\u51FA\u8BB0\u5F55 ID").option("-o, --output <path>", "\u8F93\u51FA PDF \u8DEF\u5F84\uFF08\u9ED8\u8BA4\u5F53\u524D\u76EE\u5F55\u81EA\u52A8\u547D\u540D\uFF09").option("
|
|
6846
|
+
reportCmd.command("download").description("\u6309\u5BFC\u51FA\u8BB0\u5F55 ID \u4E0B\u8F7D\u8FD0\u8425\u62A5\u8868 PDF\uFF08\u5BF9\u5E94 table \u7684\u91CD\u65B0\u4E0B\u8F7D\uFF09").requiredOption("--id <recordId>", "\u5BFC\u51FA\u8BB0\u5F55 ID").option("-o, --output <path>", "\u8F93\u51FA PDF \u8DEF\u5F84\uFF08\u9ED8\u8BA4\u5F53\u524D\u76EE\u5F55\u81EA\u52A8\u547D\u540D\uFF09").option("-t, --token <token>", "Token\uFF08\u53EF\u9009\uFF1B\u4F18\u5148\u4E8E ~/.siluzan/config.json\uFF09").option("--verbose", "\u663E\u793A\u8BE6\u7EC6\u9519\u8BEF\u4FE1\u606F", false).action(async (opts) => {
|
|
6777
6847
|
await runReportDownload(opts);
|
|
6778
6848
|
});
|
|
6779
6849
|
var planningCmd = program.command("planning").description("AI \u5185\u5BB9\u89C4\u5212\uFF08planning\uFF09\uFF1A\u4F01\u4E1A\u5217\u8868\u3001\u5185\u5BB9\u7C7B\u578B\u3001\u751F\u6210\u3001\u4EFB\u52A1\u7BA1\u7406\u3001\u8BE6\u60C5\u4E0E\u5BFC\u51FA");
|
package/dist/skill/_meta.json
CHANGED
package/package.json
CHANGED