ccg-workflow 1.0.6 → 1.1.1

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
@@ -14,9 +14,16 @@
14
14
 
15
15
  ---
16
16
 
17
- ## 🎉 v3.0.0 重大更新
17
+ ## 🎉 最新更新
18
18
 
19
- ### 安装方式革命性升级
19
+ ### v1.1.0 - 智能更新系统
20
+ - ✅ **一键更新**:`npx ccg-workflow` 选择"更新工作流"
21
+ - ✅ **自动版本检测**:自动对比当前版本与 npm 最新版本
22
+ - ✅ **增量更新**:仅更新命令模板和提示词,保留用户配置
23
+ - ✅ **强制修复**:支持强制重装,修复损坏的文件
24
+ - ✅ **零权限**:无需 sudo,无需全局安装
25
+
26
+ ### v3.0.0 - 三 CLI 协作时代
20
27
  - ✅ 从 Python 脚本重构为 **TypeScript + unbuild** 构建系统
21
28
  - ✅ 发布到 npm: **`npx ccg-workflow`** 一键安装
22
29
  - ✅ 交互式配置菜单(初始化/更新/卸载)
@@ -132,7 +139,9 @@ pnpm start
132
139
  ✕ 退出
133
140
  ```
134
141
 
135
- 选择 "初始化 CCG 配置" 进行首次安装,会引导你:
142
+ ### 首次安装
143
+
144
+ 选择 **"初始化 CCG 配置"** 进行首次安装,会引导你:
136
145
  1. 选择语言(中文/English)
137
146
  2. 配置前端模型(Gemini/Codex/Claude)
138
147
  3. 配置后端模型(Codex/Gemini/Claude)
@@ -140,6 +149,20 @@ pnpm start
140
149
  5. 选择要安装的工作流
141
150
  6. 配置 ace-tool MCP(可选)
142
151
 
152
+ ### 更新到最新版
153
+
154
+ 选择 **"更新工作流"**,系统将:
155
+ 1. 🔍 检查 npm 最新版本
156
+ 2. 📊 显示当前版本 vs 最新版本对比
157
+ 3. 📥 自动更新所有命令模板和提示词
158
+ 4. ✅ 保留用户配置和自定义内容
159
+
160
+ **特性**:
161
+ - ✅ 自动检测版本,有更新时提示
162
+ - ✅ 已是最新版本时,可选择"强制重装"修复损坏文件
163
+ - ✅ 无需 sudo 权限
164
+ - ✅ 无需卸载重装
165
+
143
166
  ---
144
167
 
145
168
  ## 使用
@@ -324,6 +347,37 @@ strategy = "parallel"
324
347
 
325
348
  ---
326
349
 
350
+ ## 更新
351
+
352
+ ### 更新到最新版本
353
+
354
+ ```bash
355
+ # 运行 CCG 菜单
356
+ npx ccg-workflow
357
+
358
+ # 选择 "更新工作流"
359
+ ```
360
+
361
+ 系统会自动:
362
+ 1. 检查 npm 最新版本
363
+ 2. 对比当前版本与最新版本
364
+ 3. 更新所有命令模板(`~/.claude/commands/ccg/`)
365
+ 4. 更新所有角色提示词(`~/.claude/prompts/ccg/`)
366
+ 5. 保留用户配置(`~/.ccg/config.toml`)
367
+
368
+ ### 强制修复损坏文件
369
+
370
+ 如果已是最新版本但文件损坏,可选择"强制重新安装":
371
+
372
+ ```bash
373
+ npx ccg-workflow
374
+ # 选择 "更新工作流"
375
+ # 当提示"已是最新版本"时
376
+ # 选择 Yes 进行强制重装
377
+ ```
378
+
379
+ ---
380
+
327
381
  ## 卸载
328
382
 
329
383
  ```bash
package/dist/cli.mjs CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import cac from 'cac';
3
3
  import ansis from 'ansis';
4
- import { r as readCcgConfig, b as initI18n, s as showMainMenu, i as init, a as i18n } from './shared/ccg-workflow.Bx_EgCjC.mjs';
4
+ import { r as readCcgConfig, b as initI18n, s as showMainMenu, i as init, a as i18n } from './shared/ccg-workflow.BJvXd6ru.mjs';
5
5
  import 'inquirer';
6
6
  import 'node:os';
7
7
  import 'pathe';
@@ -10,8 +10,10 @@ import 'fs-extra';
10
10
  import 'node:url';
11
11
  import 'ora';
12
12
  import 'smol-toml';
13
+ import 'node:child_process';
14
+ import 'node:util';
13
15
 
14
- const version = "1.0.6";
16
+ const version = "1.1.1";
15
17
 
16
18
  function customizeHelp(sections) {
17
19
  sections.unshift({
package/dist/index.d.mts CHANGED
@@ -85,6 +85,11 @@ declare function init(options?: InitOptions): Promise<void>;
85
85
 
86
86
  declare function showMainMenu(): Promise<void>;
87
87
 
88
+ /**
89
+ * Main update command - checks for updates and installs if available
90
+ */
91
+ declare function update(): Promise<void>;
92
+
88
93
  declare const i18n: i18next.i18n;
89
94
  declare function initI18n(lang?: SupportedLang): Promise<void>;
90
95
  declare function changeLanguage(lang: SupportedLang): Promise<void>;
@@ -130,5 +135,27 @@ declare function installAceTool(config: AceToolConfig): Promise<{
130
135
  configPath?: string;
131
136
  }>;
132
137
 
133
- export { changeLanguage, createDefaultConfig, createDefaultRouting, getCcgDir, getConfigPath, getWorkflowById, getWorkflowConfigs, i18n, init, initI18n, installAceTool, installWorkflows, readCcgConfig, showMainMenu, uninstallAceTool, uninstallWorkflows, writeCcgConfig };
138
+ /**
139
+ * Get current installed version from package.json
140
+ */
141
+ declare function getCurrentVersion(): Promise<string>;
142
+ /**
143
+ * Get latest version from npm registry
144
+ */
145
+ declare function getLatestVersion(packageName?: string): Promise<string | null>;
146
+ /**
147
+ * Compare two semantic versions
148
+ * @returns 1 if v1 > v2, -1 if v1 < v2, 0 if equal
149
+ */
150
+ declare function compareVersions(v1: string, v2: string): number;
151
+ /**
152
+ * Check if update is available
153
+ */
154
+ declare function checkForUpdates(): Promise<{
155
+ hasUpdate: boolean;
156
+ currentVersion: string;
157
+ latestVersion: string | null;
158
+ }>;
159
+
160
+ export { changeLanguage, checkForUpdates, compareVersions, createDefaultConfig, createDefaultRouting, getCcgDir, getConfigPath, getCurrentVersion, getLatestVersion, getWorkflowById, getWorkflowConfigs, i18n, init, initI18n, installAceTool, installWorkflows, readCcgConfig, showMainMenu, uninstallAceTool, uninstallWorkflows, update, writeCcgConfig };
134
161
  export type { AceToolConfig, CcgConfig, CliOptions, CollaborationMode, InitOptions, InstallResult, ModelRouting, ModelType, RoutingStrategy, SupportedLang, WorkflowConfig };
package/dist/index.d.ts CHANGED
@@ -85,6 +85,11 @@ declare function init(options?: InitOptions): Promise<void>;
85
85
 
86
86
  declare function showMainMenu(): Promise<void>;
87
87
 
88
+ /**
89
+ * Main update command - checks for updates and installs if available
90
+ */
91
+ declare function update(): Promise<void>;
92
+
88
93
  declare const i18n: i18next.i18n;
89
94
  declare function initI18n(lang?: SupportedLang): Promise<void>;
90
95
  declare function changeLanguage(lang: SupportedLang): Promise<void>;
@@ -130,5 +135,27 @@ declare function installAceTool(config: AceToolConfig): Promise<{
130
135
  configPath?: string;
131
136
  }>;
132
137
 
133
- export { changeLanguage, createDefaultConfig, createDefaultRouting, getCcgDir, getConfigPath, getWorkflowById, getWorkflowConfigs, i18n, init, initI18n, installAceTool, installWorkflows, readCcgConfig, showMainMenu, uninstallAceTool, uninstallWorkflows, writeCcgConfig };
138
+ /**
139
+ * Get current installed version from package.json
140
+ */
141
+ declare function getCurrentVersion(): Promise<string>;
142
+ /**
143
+ * Get latest version from npm registry
144
+ */
145
+ declare function getLatestVersion(packageName?: string): Promise<string | null>;
146
+ /**
147
+ * Compare two semantic versions
148
+ * @returns 1 if v1 > v2, -1 if v1 < v2, 0 if equal
149
+ */
150
+ declare function compareVersions(v1: string, v2: string): number;
151
+ /**
152
+ * Check if update is available
153
+ */
154
+ declare function checkForUpdates(): Promise<{
155
+ hasUpdate: boolean;
156
+ currentVersion: string;
157
+ latestVersion: string | null;
158
+ }>;
159
+
160
+ export { changeLanguage, checkForUpdates, compareVersions, createDefaultConfig, createDefaultRouting, getCcgDir, getConfigPath, getCurrentVersion, getLatestVersion, getWorkflowById, getWorkflowConfigs, i18n, init, initI18n, installAceTool, installWorkflows, readCcgConfig, showMainMenu, uninstallAceTool, uninstallWorkflows, update, writeCcgConfig };
134
161
  export type { AceToolConfig, CcgConfig, CliOptions, CollaborationMode, InitOptions, InstallResult, ModelRouting, ModelType, RoutingStrategy, SupportedLang, WorkflowConfig };
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- export { c as changeLanguage, d as createDefaultConfig, e as createDefaultRouting, g as getCcgDir, f as getConfigPath, j as getWorkflowById, h as getWorkflowConfigs, a as i18n, i as init, b as initI18n, l as installAceTool, k as installWorkflows, r as readCcgConfig, s as showMainMenu, m as uninstallAceTool, u as uninstallWorkflows, w as writeCcgConfig } from './shared/ccg-workflow.Bx_EgCjC.mjs';
1
+ export { c as changeLanguage, q as checkForUpdates, t as compareVersions, d as createDefaultConfig, e as createDefaultRouting, g as getCcgDir, f as getConfigPath, o as getCurrentVersion, p as getLatestVersion, j as getWorkflowById, h as getWorkflowConfigs, a as i18n, i as init, b as initI18n, l as installAceTool, k as installWorkflows, r as readCcgConfig, s as showMainMenu, n as uninstallAceTool, m as uninstallWorkflows, u as update, w as writeCcgConfig } from './shared/ccg-workflow.BJvXd6ru.mjs';
2
2
  import 'ansis';
3
3
  import 'inquirer';
4
4
  import 'node:os';
@@ -8,3 +8,5 @@ import 'fs-extra';
8
8
  import 'node:url';
9
9
  import 'ora';
10
10
  import 'smol-toml';
11
+ import 'node:child_process';
12
+ import 'node:util';
@@ -7,6 +7,8 @@ import fs from 'fs-extra';
7
7
  import { fileURLToPath } from 'node:url';
8
8
  import ora from 'ora';
9
9
  import { parse, stringify } from 'smol-toml';
10
+ import { exec } from 'node:child_process';
11
+ import { promisify } from 'node:util';
10
12
 
11
13
  const i18n = i18next;
12
14
  const zhCN = {
@@ -382,9 +384,9 @@ function createDefaultRouting() {
382
384
  };
383
385
  }
384
386
 
385
- const __filename$1 = fileURLToPath(import.meta.url);
386
- const __dirname$1 = dirname(__filename$1);
387
- function findPackageRoot(startDir) {
387
+ const __filename$2 = fileURLToPath(import.meta.url);
388
+ const __dirname$2 = dirname(__filename$2);
389
+ function findPackageRoot$1(startDir) {
388
390
  let dir = startDir;
389
391
  for (let i = 0; i < 5; i++) {
390
392
  if (fs.existsSync(join(dir, "package.json"))) {
@@ -394,7 +396,7 @@ function findPackageRoot(startDir) {
394
396
  }
395
397
  return startDir;
396
398
  }
397
- const PACKAGE_ROOT = findPackageRoot(__dirname$1);
399
+ const PACKAGE_ROOT$1 = findPackageRoot$1(__dirname$2);
398
400
  const WORKFLOW_CONFIGS = [
399
401
  {
400
402
  id: "dev",
@@ -624,7 +626,7 @@ async function installWorkflows(workflowIds, installDir, force = false) {
624
626
  const promptsDir = join(installDir, "prompts", "ccg");
625
627
  await fs.ensureDir(commandsDir);
626
628
  await fs.ensureDir(promptsDir);
627
- const templateDir = join(PACKAGE_ROOT, "templates");
629
+ const templateDir = join(PACKAGE_ROOT$1, "templates");
628
630
  for (const workflowId of workflowIds) {
629
631
  const workflow = getWorkflowById(workflowId);
630
632
  if (!workflow) {
@@ -1057,6 +1059,154 @@ async function init(options = {}) {
1057
1059
  }
1058
1060
  }
1059
1061
 
1062
+ const execAsync = promisify(exec);
1063
+ const __filename$1 = fileURLToPath(import.meta.url);
1064
+ const __dirname$1 = dirname(__filename$1);
1065
+ function findPackageRoot(startDir) {
1066
+ let dir = startDir;
1067
+ for (let i = 0; i < 5; i++) {
1068
+ if (fs.existsSync(join(dir, "package.json"))) {
1069
+ return dir;
1070
+ }
1071
+ dir = dirname(dir);
1072
+ }
1073
+ return startDir;
1074
+ }
1075
+ const PACKAGE_ROOT = findPackageRoot(__dirname$1);
1076
+ async function getCurrentVersion() {
1077
+ try {
1078
+ const pkgPath = join(PACKAGE_ROOT, "package.json");
1079
+ const pkg = await fs.readJSON(pkgPath);
1080
+ return pkg.version || "0.0.0";
1081
+ } catch {
1082
+ return "0.0.0";
1083
+ }
1084
+ }
1085
+ async function getLatestVersion(packageName = "ccg-workflow") {
1086
+ try {
1087
+ const { stdout } = await execAsync(`npm view ${packageName} version`);
1088
+ return stdout.trim();
1089
+ } catch {
1090
+ return null;
1091
+ }
1092
+ }
1093
+ function compareVersions(v1, v2) {
1094
+ const parts1 = v1.split(".").map(Number);
1095
+ const parts2 = v2.split(".").map(Number);
1096
+ for (let i = 0; i < Math.max(parts1.length, parts2.length); i++) {
1097
+ const num1 = parts1[i] || 0;
1098
+ const num2 = parts2[i] || 0;
1099
+ if (num1 > num2)
1100
+ return 1;
1101
+ if (num1 < num2)
1102
+ return -1;
1103
+ }
1104
+ return 0;
1105
+ }
1106
+ async function checkForUpdates() {
1107
+ const currentVersion = await getCurrentVersion();
1108
+ const latestVersion = await getLatestVersion();
1109
+ if (!latestVersion) {
1110
+ return {
1111
+ hasUpdate: false,
1112
+ currentVersion,
1113
+ latestVersion: null
1114
+ };
1115
+ }
1116
+ const hasUpdate = compareVersions(latestVersion, currentVersion) > 0;
1117
+ return {
1118
+ hasUpdate,
1119
+ currentVersion,
1120
+ latestVersion
1121
+ };
1122
+ }
1123
+
1124
+ promisify(exec);
1125
+ async function update() {
1126
+ console.log();
1127
+ console.log(ansis.cyan.bold("\u{1F504} \u68C0\u67E5\u66F4\u65B0..."));
1128
+ console.log();
1129
+ const spinner = ora("\u6B63\u5728\u68C0\u67E5\u6700\u65B0\u7248\u672C...").start();
1130
+ try {
1131
+ const { hasUpdate, currentVersion, latestVersion } = await checkForUpdates();
1132
+ spinner.stop();
1133
+ if (!latestVersion) {
1134
+ console.log(ansis.red("\u274C \u65E0\u6CD5\u8FDE\u63A5\u5230 npm registry\uFF0C\u8BF7\u68C0\u67E5\u7F51\u7EDC\u8FDE\u63A5"));
1135
+ return;
1136
+ }
1137
+ console.log(`\u5F53\u524D\u7248\u672C: ${ansis.yellow(`v${currentVersion}`)}`);
1138
+ console.log(`\u6700\u65B0\u7248\u672C: ${ansis.green(`v${latestVersion}`)}`);
1139
+ console.log();
1140
+ if (!hasUpdate) {
1141
+ console.log(ansis.green("\u2705 \u5DF2\u662F\u6700\u65B0\u7248\u672C\uFF01"));
1142
+ const { forceReinstall } = await inquirer.prompt([{
1143
+ type: "confirm",
1144
+ name: "forceReinstall",
1145
+ message: "\u8981\u5F3A\u5236\u91CD\u65B0\u5B89\u88C5\u5F53\u524D\u7248\u672C\u5417\uFF1F\uFF08\u53EF\u4FEE\u590D\u635F\u574F\u7684\u6587\u4EF6\uFF09",
1146
+ default: false
1147
+ }]);
1148
+ if (!forceReinstall) {
1149
+ return;
1150
+ }
1151
+ } else {
1152
+ const { confirmUpdate } = await inquirer.prompt([{
1153
+ type: "confirm",
1154
+ name: "confirmUpdate",
1155
+ message: `\u786E\u8BA4\u8981\u66F4\u65B0\u5230 v${latestVersion} \u5417\uFF1F`,
1156
+ default: true
1157
+ }]);
1158
+ if (!confirmUpdate) {
1159
+ console.log(ansis.gray("\u5DF2\u53D6\u6D88\u66F4\u65B0"));
1160
+ return;
1161
+ }
1162
+ }
1163
+ await performUpdate(currentVersion, latestVersion || currentVersion);
1164
+ } catch (error) {
1165
+ spinner.stop();
1166
+ console.log(ansis.red(`\u274C \u66F4\u65B0\u5931\u8D25: ${error}`));
1167
+ }
1168
+ }
1169
+ async function performUpdate(fromVersion, toVersion) {
1170
+ console.log();
1171
+ console.log(ansis.yellow.bold("\u2699\uFE0F \u5F00\u59CB\u66F4\u65B0..."));
1172
+ console.log();
1173
+ const spinner = ora("\u66F4\u65B0\u547D\u4EE4\u6A21\u677F\u548C\u63D0\u793A\u8BCD...").start();
1174
+ try {
1175
+ const config = await readCcgConfig();
1176
+ const workflows = config?.workflows?.installed || [];
1177
+ const installDir = join(homedir(), ".claude");
1178
+ const result = await installWorkflows(workflows, installDir, true);
1179
+ if (result.success) {
1180
+ spinner.succeed("\u547D\u4EE4\u6A21\u677F\u548C\u63D0\u793A\u8BCD\u66F4\u65B0\u6210\u529F");
1181
+ console.log();
1182
+ console.log(ansis.cyan(`\u5DF2\u66F4\u65B0 ${result.installedCommands.length} \u4E2A\u547D\u4EE4:`));
1183
+ for (const cmd of result.installedCommands) {
1184
+ console.log(` ${ansis.gray("\u2022")} /ccg:${cmd}`);
1185
+ }
1186
+ if (config) {
1187
+ config.general.version = toVersion;
1188
+ await writeCcgConfig(config);
1189
+ }
1190
+ } else {
1191
+ spinner.fail("\u66F4\u65B0\u5931\u8D25");
1192
+ console.log(ansis.red("\u90E8\u5206\u6587\u4EF6\u66F4\u65B0\u5931\u8D25:"));
1193
+ for (const error of result.errors) {
1194
+ console.log(ansis.red(` \u2022 ${error}`));
1195
+ }
1196
+ return;
1197
+ }
1198
+ } catch (error) {
1199
+ spinner.fail("\u66F4\u65B0\u5931\u8D25");
1200
+ console.log(ansis.red(`\u9519\u8BEF: ${error}`));
1201
+ return;
1202
+ }
1203
+ console.log();
1204
+ console.log(ansis.green.bold("\u2705 \u66F4\u65B0\u5B8C\u6210\uFF01"));
1205
+ console.log();
1206
+ console.log(ansis.gray(`\u4ECE v${fromVersion} \u5347\u7EA7\u5230 v${toVersion}`));
1207
+ console.log();
1208
+ }
1209
+
1060
1210
  async function showMainMenu() {
1061
1211
  console.log();
1062
1212
  console.log(ansis.cyan.bold(` CCG - Claude + Codex + Gemini`));
@@ -1080,7 +1230,7 @@ async function showMainMenu() {
1080
1230
  await init();
1081
1231
  break;
1082
1232
  case "update":
1083
- console.log(ansis.yellow("Update functionality coming soon..."));
1233
+ await update();
1084
1234
  break;
1085
1235
  case "uninstall":
1086
1236
  await uninstall();
@@ -1156,4 +1306,4 @@ async function uninstall() {
1156
1306
  console.log();
1157
1307
  }
1158
1308
 
1159
- export { i18n as a, initI18n as b, changeLanguage as c, createDefaultConfig as d, createDefaultRouting as e, getConfigPath as f, getCcgDir as g, getWorkflowConfigs as h, init as i, getWorkflowById as j, installWorkflows as k, installAceTool as l, uninstallAceTool as m, readCcgConfig as r, showMainMenu as s, uninstallWorkflows as u, writeCcgConfig as w };
1309
+ export { i18n as a, initI18n as b, changeLanguage as c, createDefaultConfig as d, createDefaultRouting as e, getConfigPath as f, getCcgDir as g, getWorkflowConfigs as h, init as i, getWorkflowById as j, installWorkflows as k, installAceTool as l, uninstallWorkflows as m, uninstallAceTool as n, getCurrentVersion as o, getLatestVersion as p, checkForUpdates as q, readCcgConfig as r, showMainMenu as s, compareVersions as t, update as u, writeCcgConfig as w };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ccg-workflow",
3
- "version": "1.0.6",
3
+ "version": "1.1.1",
4
4
  "description": "Claude-Codex-Gemini 多模型协作系统 - 智能路由多模型开发工作流",
5
5
  "type": "module",
6
6
  "packageManager": "pnpm@10.17.1",