@double-codeing/flow2spec 3.0.9 → 3.0.12

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/cli.js CHANGED
@@ -12,6 +12,8 @@ const {
12
12
  getMissingConfigFields,
13
13
  } = require("./lib/flow2specConfig");
14
14
 
15
+ const { execSync } = require("child_process");
16
+
15
17
  const args = process.argv.slice(2);
16
18
  const sub = args[0];
17
19
 
@@ -19,12 +21,16 @@ const agentList = Object.entries(AGENTS)
19
21
  .map(([id, { label }]) => `${id}(${label})`)
20
22
  .join(", ");
21
23
 
24
+ const pkg = require("./package.json");
25
+
22
26
  const help = `
23
- Flow2Spec - 统一知识库工作流(AI 配置入口)
27
+ Flow2Spec - 统一知识库工作流(AI 配置入口) v${pkg.version}
24
28
 
25
29
  用法:
26
30
  flow2spec init [agent ...] [--reset-knowledge] [--yes] 在当前项目初始化:写入 .Knowledge 与所选 agent 入口
27
31
  flow2spec config 打印项目根 ${CONFIG_FILENAME} 的解析结果(缺省值合并后)
32
+ flow2spec version 显示当前 flow2spec 版本
33
+ flow2spec update 更新 flow2spec 到最新版本
28
34
  flow2spec --help 显示本说明
29
35
 
30
36
  agent(可多个,空格分隔;省略时交互选择):
@@ -60,6 +66,35 @@ if (sub === "--help" || sub === "-h" || !sub) {
60
66
  process.exit(0);
61
67
  }
62
68
 
69
+ if (sub === "version" || sub === "--version" || sub === "-v") {
70
+ console.log(`flow2spec v${pkg.version}`);
71
+ process.exit(0);
72
+ }
73
+
74
+ if (sub === "update") {
75
+ console.log(`当前版本: v${pkg.version}`);
76
+ console.log("正在检查最新版本...");
77
+ try {
78
+ const latest = execSync(`npm view ${pkg.name} version`, {
79
+ encoding: "utf8",
80
+ }).trim();
81
+ if (latest === pkg.version) {
82
+ console.log(`已是最新版本 v${latest}`);
83
+ process.exit(0);
84
+ }
85
+ console.log(`发现新版本: v${latest}`);
86
+ console.log("正在更新...");
87
+ execSync(`npm install -g ${pkg.name}@latest`, {
88
+ stdio: "inherit",
89
+ });
90
+ console.log(`\n✓ 已更新到 v${latest}`);
91
+ } catch (e) {
92
+ console.error("更新失败:", e.message || e);
93
+ process.exit(1);
94
+ }
95
+ process.exit(0);
96
+ }
97
+
63
98
  if (sub === "config") {
64
99
  const cwd = process.cwd();
65
100
  const abs = path.join(cwd, CONFIG_FILENAME);