ccg-workflow 1.0.6 → 1.1.0
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/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.
|
|
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
|
|
16
|
+
const version = "1.1.0";
|
|
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
|
-
|
|
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
|
-
|
|
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,
|
|
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$
|
|
386
|
-
const __dirname$
|
|
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$
|
|
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
|
-
|
|
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,
|
|
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 };
|