tickflow-assist 0.2.12 → 0.2.13

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
@@ -2,7 +2,7 @@
2
2
 
3
3
  基于 [OpenClaw](https://openclaw.ai) 的 A 股监控与分析插件。它使用 [TickFlow](https://tickflow.org/auth/register?ref=BUJ54JEDGE) 获取行情与财务数据,结合 LLM 生成技术面、基本面、资讯面的综合判断,并把结果持久化到本地 LanceDB。
4
4
 
5
- 最近更新:`v0.2.12` 调整社区安装清单,允许先安装插件再执行 `configure-openclaw` 写入密钥配置;同时将 `test_alert` 升级为文本 + PNG 告警卡链路测试。
5
+ 最近更新:`v0.2.13` `configure-openclaw` 与一键安装脚本中加入 Linux 中文字体自动安装,减少 VPS PNG 告警卡中文乱码;并补充 GitHub README 效果预览图。
6
6
 
7
7
  ## 安装
8
8
 
@@ -14,6 +14,7 @@ npx -y tickflow-assist configure-openclaw
14
14
  ```
15
15
 
16
16
  安装阶段允许先落插件,再通过第二条命令写入 `tickflowApiKey`、`llmApiKey` 等正式配置。
17
+ 在 Linux 上,`configure-openclaw` 还会 best-effort 安装 PNG 告警卡所需的中文字体;如需跳过,可追加 `--no-font-setup`。
17
18
 
18
19
  第二条命令会写入 `~/.openclaw/openclaw.json` 中的 `plugins.entries["tickflow-assist"].config`,并默认执行:
19
20
 
@@ -1,5 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
  import { spawnSync } from "node:child_process";
3
+ import { readFileSync } from "node:fs";
3
4
  import { access, mkdir, readFile, writeFile } from "node:fs/promises";
4
5
  import os from "node:os";
5
6
  import path from "node:path";
@@ -38,6 +39,7 @@ Options:
38
39
  --no-enable Do not run 'openclaw plugins enable'
39
40
  --no-restart Do not run 'openclaw gateway restart'
40
41
  --no-python-setup Do not run 'uv sync' for Python dependencies
42
+ --no-font-setup Do not try to install Linux Chinese fonts for PNG alerts
41
43
  --openclaw-bin <path> OpenClaw CLI binary, default: openclaw
42
44
  --tickflow-api-key <key>
43
45
  --tickflow-api-key-level <Free|Start|Pro|Expert>
@@ -61,6 +63,7 @@ function parseArgs(argv) {
61
63
  restart: true,
62
64
  enable: true,
63
65
  pythonSetup: true,
66
+ fontSetup: true,
64
67
  openclawBin: DEFAULTS.openclawCliBin,
65
68
  overrides: {},
66
69
  };
@@ -115,6 +118,9 @@ function parseArgs(argv) {
115
118
  case "--no-python-setup":
116
119
  options.pythonSetup = false;
117
120
  break;
121
+ case "--no-font-setup":
122
+ options.fontSetup = false;
123
+ break;
118
124
  case "--no-enable":
119
125
  options.enable = false;
120
126
  break;
@@ -623,6 +629,162 @@ async function setupPythonDeps(pythonWorkdir, nonInteractive) {
623
629
  }
624
630
  console.log("Python dependencies installed successfully.");
625
631
  }
632
+ function isCommandAvailable(command) {
633
+ const result = spawnSync("which", [command], { stdio: "ignore" });
634
+ return result.status === 0;
635
+ }
636
+ function isRootUser() {
637
+ return typeof process.getuid === "function" && process.getuid() === 0;
638
+ }
639
+ function hasChineseFonts() {
640
+ const result = spawnSync("fc-list", [":lang=zh", "family"], { encoding: "utf-8" });
641
+ return result.status === 0 && Boolean(result.stdout.trim());
642
+ }
643
+ function detectLinuxDistro() {
644
+ try {
645
+ const raw = readFileSync("/etc/os-release", "utf-8");
646
+ const record = Object.fromEntries(raw
647
+ .split("\n")
648
+ .map((line) => line.trim())
649
+ .filter(Boolean)
650
+ .filter((line) => !line.startsWith("#") && line.includes("="))
651
+ .map((line) => {
652
+ const index = line.indexOf("=");
653
+ const key = line.slice(0, index);
654
+ const value = line.slice(index + 1).replace(/^"/, "").replace(/"$/, "");
655
+ return [key, value];
656
+ }));
657
+ const ids = [
658
+ String(record.ID ?? "").toLowerCase(),
659
+ ...String(record.ID_LIKE ?? "")
660
+ .toLowerCase()
661
+ .split(/\s+/)
662
+ .filter(Boolean),
663
+ ];
664
+ if (ids.some((value) => ["debian", "ubuntu"].includes(value))) {
665
+ return "debian";
666
+ }
667
+ if (ids.some((value) => ["rhel", "fedora", "centos", "rocky", "almalinux"].includes(value))) {
668
+ return "rhel";
669
+ }
670
+ if (ids.some((value) => ["arch", "manjaro"].includes(value))) {
671
+ return "arch";
672
+ }
673
+ if (ids.includes("alpine")) {
674
+ return "alpine";
675
+ }
676
+ }
677
+ catch {
678
+ // fall through
679
+ }
680
+ return "unknown";
681
+ }
682
+ function getManualFontCommands(distro) {
683
+ switch (distro) {
684
+ case "debian":
685
+ return ["sudo apt-get update", "sudo apt-get install -y fontconfig fonts-noto-cjk", "fc-cache -fv"];
686
+ case "rhel":
687
+ return [
688
+ "sudo dnf install -y fontconfig google-noto-sans-cjk-ttc-fonts",
689
+ "fc-cache -fv",
690
+ ];
691
+ case "arch":
692
+ return ["sudo pacman -Sy --noconfirm fontconfig noto-fonts-cjk", "fc-cache -fv"];
693
+ case "alpine":
694
+ return ["sudo apk add fontconfig font-noto-cjk", "fc-cache -fv"];
695
+ default:
696
+ return [
697
+ "请安装 fontconfig 和任意可用的中文字体包,例如 Noto Sans CJK",
698
+ "安装后执行: fc-cache -fv",
699
+ ];
700
+ }
701
+ }
702
+ function buildPrivilegedCommand(argv, nonInteractive) {
703
+ if (isRootUser()) {
704
+ return argv;
705
+ }
706
+ if (!isCommandAvailable("sudo")) {
707
+ return null;
708
+ }
709
+ return nonInteractive ? ["sudo", "-n", ...argv] : ["sudo", ...argv];
710
+ }
711
+ function runSetupCommand(argv, description) {
712
+ console.log(description);
713
+ const result = spawnSync(argv[0], argv.slice(1), { stdio: "inherit" });
714
+ if (result.error) {
715
+ console.warn(`Warning: failed to run ${description}: ${result.error.message}`);
716
+ return false;
717
+ }
718
+ if (result.status !== 0) {
719
+ console.warn(`Warning: ${description} exited with status ${result.status}`);
720
+ return false;
721
+ }
722
+ return true;
723
+ }
724
+ async function setupLinuxChineseFonts(nonInteractive) {
725
+ if (process.platform !== "linux") {
726
+ return;
727
+ }
728
+ if (!isCommandAvailable("fc-list")) {
729
+ console.warn("Warning: fontconfig is not installed; PNG alerts may not render Chinese text correctly.");
730
+ }
731
+ else if (hasChineseFonts()) {
732
+ console.log("Chinese fonts detected for PNG alert cards.");
733
+ return;
734
+ }
735
+ const distro = detectLinuxDistro();
736
+ console.log("Chinese fonts not detected. TickFlow Assist will try to install Noto CJK fonts for PNG alert cards.");
737
+ const attempts = [];
738
+ switch (distro) {
739
+ case "debian":
740
+ attempts.push(["apt-get", "update"]);
741
+ attempts.push(["apt-get", "install", "-y", "fontconfig", "fonts-noto-cjk"]);
742
+ break;
743
+ case "rhel":
744
+ attempts.push(["dnf", "install", "-y", "fontconfig", "google-noto-sans-cjk-ttc-fonts"]);
745
+ attempts.push(["dnf", "install", "-y", "fontconfig", "google-noto-cjk-fonts"]);
746
+ attempts.push(["yum", "install", "-y", "fontconfig", "google-noto-sans-cjk-ttc-fonts"]);
747
+ attempts.push(["yum", "install", "-y", "fontconfig", "google-noto-cjk-fonts"]);
748
+ break;
749
+ case "arch":
750
+ attempts.push(["pacman", "-Sy", "--noconfirm", "fontconfig", "noto-fonts-cjk"]);
751
+ break;
752
+ case "alpine":
753
+ attempts.push(["apk", "add", "fontconfig", "font-noto-cjk"]);
754
+ break;
755
+ default:
756
+ break;
757
+ }
758
+ let attemptedInstall = false;
759
+ for (const baseArgv of attempts) {
760
+ if (!isCommandAvailable(baseArgv[0])) {
761
+ continue;
762
+ }
763
+ const argv = buildPrivilegedCommand(baseArgv, nonInteractive);
764
+ if (!argv) {
765
+ break;
766
+ }
767
+ attemptedInstall = true;
768
+ if (!runSetupCommand(argv, `Running ${argv.join(" ")}`)) {
769
+ continue;
770
+ }
771
+ if (isCommandAvailable("fc-cache")) {
772
+ runSetupCommand(["fc-cache", "-fv"], "Refreshing font cache with fc-cache -fv");
773
+ }
774
+ if (isCommandAvailable("fc-list") && hasChineseFonts()) {
775
+ console.log("Chinese fonts installed successfully.");
776
+ return;
777
+ }
778
+ }
779
+ console.warn("Warning: automatic Chinese font setup did not complete.");
780
+ if (!attemptedInstall && nonInteractive) {
781
+ console.warn("Non-interactive mode skipped any sudo password prompt.");
782
+ }
783
+ console.warn("Manual install examples:");
784
+ for (const command of getManualFontCommands(distro)) {
785
+ console.warn(` ${command}`);
786
+ }
787
+ }
626
788
  async function configureOpenClaw(options) {
627
789
  const configPath = resolveOpenClawConfigPath(options.configPath);
628
790
  const stateDir = resolveStateDir(configPath);
@@ -636,6 +798,9 @@ async function configureOpenClaw(options) {
636
798
  if (options.pythonSetup) {
637
799
  await setupPythonDeps(config.pythonWorkdir, options.nonInteractive);
638
800
  }
801
+ if (options.fontSetup) {
802
+ await setupLinuxChineseFonts(options.nonInteractive);
803
+ }
639
804
  applyPluginConfig(root, config, target);
640
805
  const backupPath = await writeConfig(configPath, root);
641
806
  console.log("");
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "id": "tickflow-assist",
3
3
  "name": "TickFlow Assist",
4
- "version": "0.2.12",
4
+ "version": "0.2.13",
5
5
  "description": "A-share watchlist analysis, monitoring, and alert delivery powered by TickFlow and OpenClaw.",
6
6
  "skills": [
7
7
  "skills"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tickflow-assist",
3
- "version": "0.2.12",
3
+ "version": "0.2.13",
4
4
  "description": "OpenClaw plugin for TickFlow-based A-share analysis, monitoring, and alerting.",
5
5
  "license": "MIT",
6
6
  "type": "module",