aico-cli 0.2.1 → 0.2.2
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/chunks/feature-checker.mjs +0 -1
- package/dist/chunks/simple-config.mjs +4 -211
- package/dist/chunks/workflow-installer.mjs +213 -0
- package/dist/cli.mjs +4 -5
- package/dist/index.mjs +0 -1
- package/package.json +1 -1
|
@@ -12,9 +12,8 @@ import 'dayjs';
|
|
|
12
12
|
import { join as join$1 } from 'node:path';
|
|
13
13
|
import { join, dirname, basename } from 'pathe';
|
|
14
14
|
import { fileURLToPath } from 'node:url';
|
|
15
|
-
import { rm, mkdir, copyFile as copyFile$1 } from 'node:fs/promises';
|
|
16
15
|
|
|
17
|
-
const version = "0.2.
|
|
16
|
+
const version = "0.2.2";
|
|
18
17
|
|
|
19
18
|
function displayBanner(subtitle) {
|
|
20
19
|
const defaultSubtitle = "\u4E00\u952E\u914D\u7F6E\u4F60\u7684\u5F00\u53D1\u73AF\u5883";
|
|
@@ -3402,8 +3401,8 @@ function copyDir(src, dest, options = {}) {
|
|
|
3402
3401
|
ensureDir(dest);
|
|
3403
3402
|
const entries = readDir(src);
|
|
3404
3403
|
for (const entry of entries) {
|
|
3405
|
-
const srcPath =
|
|
3406
|
-
const destPath =
|
|
3404
|
+
const srcPath = join(src, entry);
|
|
3405
|
+
const destPath = join(dest, entry);
|
|
3407
3406
|
const stats = getStats(srcPath);
|
|
3408
3407
|
if (filter && !filter(srcPath, stats)) {
|
|
3409
3408
|
continue;
|
|
@@ -5218,206 +5217,6 @@ const INSTALLER_NAMES = {
|
|
|
5218
5217
|
CONFIG_CHECKER: "config-checker"
|
|
5219
5218
|
};
|
|
5220
5219
|
|
|
5221
|
-
const WORKFLOW_CONFIGS = [
|
|
5222
|
-
{
|
|
5223
|
-
id: "sixStepsWorkflow",
|
|
5224
|
-
nameKey: "workflowOption.sixStepsWorkflow",
|
|
5225
|
-
descriptionKey: "workflowDescription.sixStepsWorkflow",
|
|
5226
|
-
defaultSelected: true,
|
|
5227
|
-
order: 1,
|
|
5228
|
-
commands: ["workflow.md"],
|
|
5229
|
-
agents: [],
|
|
5230
|
-
autoInstallAgents: false,
|
|
5231
|
-
category: "sixStep",
|
|
5232
|
-
outputDir: "workflow"
|
|
5233
|
-
},
|
|
5234
|
-
{
|
|
5235
|
-
id: "featPlanUx",
|
|
5236
|
-
nameKey: "workflowOption.featPlanUx",
|
|
5237
|
-
descriptionKey: "workflowDescription.featPlanUx",
|
|
5238
|
-
defaultSelected: true,
|
|
5239
|
-
order: 2,
|
|
5240
|
-
commands: ["feat.md"],
|
|
5241
|
-
agents: [
|
|
5242
|
-
{ id: "planner", filename: "planner.md", required: true },
|
|
5243
|
-
{ id: "ui-ux-designer", filename: "ui-ux-designer.md", required: true }
|
|
5244
|
-
],
|
|
5245
|
-
autoInstallAgents: true,
|
|
5246
|
-
category: "plan",
|
|
5247
|
-
outputDir: "feat"
|
|
5248
|
-
},
|
|
5249
|
-
{
|
|
5250
|
-
id: "bmadWorkflow",
|
|
5251
|
-
nameKey: "workflowOption.bmadWorkflow",
|
|
5252
|
-
descriptionKey: "workflowDescription.bmadWorkflow",
|
|
5253
|
-
defaultSelected: false,
|
|
5254
|
-
order: 3,
|
|
5255
|
-
commands: ["bmad-init.md"],
|
|
5256
|
-
agents: [],
|
|
5257
|
-
autoInstallAgents: false,
|
|
5258
|
-
category: "bmad",
|
|
5259
|
-
outputDir: "bmad"
|
|
5260
|
-
},
|
|
5261
|
-
{
|
|
5262
|
-
id: "gitWorkflow",
|
|
5263
|
-
nameKey: "workflowOption.gitWorkflow",
|
|
5264
|
-
descriptionKey: "workflowDescription.gitWorkflow",
|
|
5265
|
-
defaultSelected: false,
|
|
5266
|
-
order: 4,
|
|
5267
|
-
commands: ["git-commit.md", "git-rollback.md", "git-cleanBranches.md", "git-worktree.md"],
|
|
5268
|
-
agents: [],
|
|
5269
|
-
autoInstallAgents: false,
|
|
5270
|
-
category: "git",
|
|
5271
|
-
outputDir: "git"
|
|
5272
|
-
}
|
|
5273
|
-
];
|
|
5274
|
-
function getWorkflowConfig(workflowId) {
|
|
5275
|
-
return WORKFLOW_CONFIGS.find((config) => config.id === workflowId);
|
|
5276
|
-
}
|
|
5277
|
-
function getOrderedWorkflows() {
|
|
5278
|
-
return [...WORKFLOW_CONFIGS].sort((a, b) => a.order - b.order);
|
|
5279
|
-
}
|
|
5280
|
-
|
|
5281
|
-
function getRootDir() {
|
|
5282
|
-
const currentFilePath = fileURLToPath(import.meta.url);
|
|
5283
|
-
const distDir = dirname(dirname(currentFilePath));
|
|
5284
|
-
return dirname(distDir);
|
|
5285
|
-
}
|
|
5286
|
-
async function selectAndInstallWorkflows(configLang, scriptLang, preselectedWorkflows) {
|
|
5287
|
-
const workflows = getOrderedWorkflows();
|
|
5288
|
-
workflows.map((workflow) => {
|
|
5289
|
-
const nameKey = workflow.id;
|
|
5290
|
-
const name = messages.workflow.selectWorkflowType[nameKey] || workflow.id;
|
|
5291
|
-
return {
|
|
5292
|
-
name,
|
|
5293
|
-
value: workflow.id,
|
|
5294
|
-
checked: workflow.defaultSelected
|
|
5295
|
-
};
|
|
5296
|
-
});
|
|
5297
|
-
let selectedWorkflows;
|
|
5298
|
-
if (preselectedWorkflows) {
|
|
5299
|
-
selectedWorkflows = preselectedWorkflows;
|
|
5300
|
-
} else {
|
|
5301
|
-
selectedWorkflows = workflows.map((w) => w.id);
|
|
5302
|
-
}
|
|
5303
|
-
if (!selectedWorkflows || selectedWorkflows.length === 0) {
|
|
5304
|
-
console.log(ansis.yellow(messages.common.cancelled));
|
|
5305
|
-
return;
|
|
5306
|
-
}
|
|
5307
|
-
await cleanupOldVersionFiles();
|
|
5308
|
-
for (const workflowId of selectedWorkflows) {
|
|
5309
|
-
const config = getWorkflowConfig(workflowId);
|
|
5310
|
-
if (config) {
|
|
5311
|
-
await installWorkflowWithDependencies(config, configLang);
|
|
5312
|
-
}
|
|
5313
|
-
}
|
|
5314
|
-
}
|
|
5315
|
-
async function installWorkflowWithDependencies(config, configLang, scriptLang) {
|
|
5316
|
-
const rootDir = getRootDir();
|
|
5317
|
-
const result = {
|
|
5318
|
-
workflow: config.id,
|
|
5319
|
-
success: true,
|
|
5320
|
-
installedCommands: [],
|
|
5321
|
-
installedAgents: [],
|
|
5322
|
-
errors: []
|
|
5323
|
-
};
|
|
5324
|
-
const workflowName = messages.workflow.selectWorkflowType[config.id] || config.id;
|
|
5325
|
-
console.log(ansis.cyan(`
|
|
5326
|
-
\u{1F4E6} ${messages.workflow.installing}: ${workflowName}...`));
|
|
5327
|
-
const commandsDir = join(CLAUDE_DIR, "commands", "aico");
|
|
5328
|
-
if (!existsSync(commandsDir)) {
|
|
5329
|
-
await mkdir(commandsDir, { recursive: true });
|
|
5330
|
-
}
|
|
5331
|
-
for (const commandFile of config.commands) {
|
|
5332
|
-
const commandSource = join(rootDir, "templates", configLang, "workflow", config.category, "commands", commandFile);
|
|
5333
|
-
const destFileName = commandFile;
|
|
5334
|
-
const commandDest = join(commandsDir, destFileName);
|
|
5335
|
-
if (existsSync(commandSource)) {
|
|
5336
|
-
try {
|
|
5337
|
-
await copyFile$1(commandSource, commandDest);
|
|
5338
|
-
result.installedCommands.push(destFileName);
|
|
5339
|
-
console.log(ansis.gray(` \u2714 ${messages.workflow.installedCommand}: aico/${destFileName}`));
|
|
5340
|
-
} catch (error) {
|
|
5341
|
-
const errorMsg = `${messages.workflow.failedToInstallCommand} ${commandFile}: ${error}`;
|
|
5342
|
-
result.errors?.push(errorMsg);
|
|
5343
|
-
console.error(ansis.red(` \u2717 ${errorMsg}`));
|
|
5344
|
-
result.success = false;
|
|
5345
|
-
}
|
|
5346
|
-
}
|
|
5347
|
-
}
|
|
5348
|
-
if (config.autoInstallAgents && config.agents.length > 0) {
|
|
5349
|
-
const agentsCategoryDir = join(CLAUDE_DIR, "agents", "aico", config.category);
|
|
5350
|
-
if (!existsSync(agentsCategoryDir)) {
|
|
5351
|
-
await mkdir(agentsCategoryDir, { recursive: true });
|
|
5352
|
-
}
|
|
5353
|
-
for (const agent of config.agents) {
|
|
5354
|
-
const agentSource = join(rootDir, "templates", configLang, "workflow", config.category, "agents", agent.filename);
|
|
5355
|
-
const agentDest = join(agentsCategoryDir, agent.filename);
|
|
5356
|
-
if (existsSync(agentSource)) {
|
|
5357
|
-
try {
|
|
5358
|
-
await copyFile$1(agentSource, agentDest);
|
|
5359
|
-
result.installedAgents.push(agent.filename);
|
|
5360
|
-
console.log(ansis.gray(` \u2714 ${messages.workflow.installedAgent}: aico/${config.category}/${agent.filename}`));
|
|
5361
|
-
} catch (error) {
|
|
5362
|
-
const errorMsg = `${messages.workflow.failedToInstallAgent} ${agent.filename}: ${error}`;
|
|
5363
|
-
result.errors?.push(errorMsg);
|
|
5364
|
-
console.error(ansis.red(` \u2717 ${errorMsg}`));
|
|
5365
|
-
if (agent.required) {
|
|
5366
|
-
result.success = false;
|
|
5367
|
-
}
|
|
5368
|
-
}
|
|
5369
|
-
}
|
|
5370
|
-
}
|
|
5371
|
-
}
|
|
5372
|
-
if (result.success) {
|
|
5373
|
-
console.log(ansis.green(`\u2714 ${workflowName} ${messages.workflow.installSuccess}`));
|
|
5374
|
-
if (config.id === "bmadWorkflow") {
|
|
5375
|
-
console.log(ansis.cyan(`
|
|
5376
|
-
${messages.workflow.bmadInitPrompt}`));
|
|
5377
|
-
}
|
|
5378
|
-
} else {
|
|
5379
|
-
console.log(ansis.red(`\u2717 ${workflowName} ${messages.workflow.installFailed}`));
|
|
5380
|
-
}
|
|
5381
|
-
return result;
|
|
5382
|
-
}
|
|
5383
|
-
async function cleanupOldVersionFiles(scriptLang) {
|
|
5384
|
-
console.log(ansis.cyan(`
|
|
5385
|
-
\u{1F9F9} ${messages.workflow.cleaningOldFiles || "Cleaning up old version files"}...`));
|
|
5386
|
-
const oldCommandFiles = [
|
|
5387
|
-
join(CLAUDE_DIR, "commands", "workflow.md"),
|
|
5388
|
-
join(CLAUDE_DIR, "commands", "feat.md")
|
|
5389
|
-
];
|
|
5390
|
-
const oldAgentFiles = [
|
|
5391
|
-
join(CLAUDE_DIR, "agents", "planner.md"),
|
|
5392
|
-
join(CLAUDE_DIR, "agents", "ui-ux-designer.md")
|
|
5393
|
-
];
|
|
5394
|
-
for (const file of oldCommandFiles) {
|
|
5395
|
-
if (existsSync(file)) {
|
|
5396
|
-
try {
|
|
5397
|
-
await rm(file, { force: true });
|
|
5398
|
-
console.log(ansis.gray(` \u2714 ${messages.workflow.removedOldFile || "Removed old file"}: ${file.replace(CLAUDE_DIR, "~/.claude")}`));
|
|
5399
|
-
} catch (error) {
|
|
5400
|
-
console.error(ansis.yellow(` \u26A0 ${messages.workflow.failedToRemoveFile || "Failed to remove"}: ${file.replace(CLAUDE_DIR, "~/.claude")}`));
|
|
5401
|
-
}
|
|
5402
|
-
}
|
|
5403
|
-
}
|
|
5404
|
-
for (const file of oldAgentFiles) {
|
|
5405
|
-
if (existsSync(file)) {
|
|
5406
|
-
try {
|
|
5407
|
-
await rm(file, { force: true });
|
|
5408
|
-
console.log(ansis.gray(` \u2714 ${messages.workflow.removedOldFile || "Removed old file"}: ${file.replace(CLAUDE_DIR, "~/.claude")}`));
|
|
5409
|
-
} catch (error) {
|
|
5410
|
-
console.error(ansis.yellow(` \u26A0 ${messages.workflow.failedToRemoveFile || "Failed to remove"}: ${file.replace(CLAUDE_DIR, "~/.claude")}`));
|
|
5411
|
-
}
|
|
5412
|
-
}
|
|
5413
|
-
}
|
|
5414
|
-
}
|
|
5415
|
-
|
|
5416
|
-
const workflowInstaller = {
|
|
5417
|
-
__proto__: null,
|
|
5418
|
-
selectAndInstallWorkflows: selectAndInstallWorkflows
|
|
5419
|
-
};
|
|
5420
|
-
|
|
5421
5220
|
class InstallationComposer {
|
|
5422
5221
|
executor;
|
|
5423
5222
|
context;
|
|
@@ -5492,8 +5291,6 @@ class InstallationComposer {
|
|
|
5492
5291
|
const companyResults = await this.executor.executeBatch(companySteps, configOptions);
|
|
5493
5292
|
const configInstaller = new ConfigInstaller(this.context);
|
|
5494
5293
|
await configInstaller.applyCompanyConfig();
|
|
5495
|
-
console.log(ansis.cyan("\n\u{1F4E6} \u5B89\u88C5\u5DE5\u4F5C\u6D41\u6A21\u677F..."));
|
|
5496
|
-
await selectAndInstallWorkflows("zh-CN");
|
|
5497
5294
|
this.updateGlobalConfig();
|
|
5498
5295
|
this.printResults({ ...results, ...companyResults }, "\u516C\u53F8\u914D\u7F6E");
|
|
5499
5296
|
} else {
|
|
@@ -5507,8 +5304,6 @@ class InstallationComposer {
|
|
|
5507
5304
|
const companyResults = await this.executor.executeBatch(companySteps, configOptions);
|
|
5508
5305
|
const configInstaller = new ConfigInstaller(this.context);
|
|
5509
5306
|
await configInstaller.applyCompanyConfig();
|
|
5510
|
-
console.log(ansis.cyan("\n\u{1F4E6} \u5B89\u88C5\u5DE5\u4F5C\u6D41\u6A21\u677F..."));
|
|
5511
|
-
await selectAndInstallWorkflows("zh-CN");
|
|
5512
5307
|
this.updateGlobalConfig();
|
|
5513
5308
|
this.printResults({ ...results, ...companyResults }, "\u516C\u53F8\u914D\u7F6E");
|
|
5514
5309
|
}
|
|
@@ -5535,8 +5330,6 @@ class InstallationComposer {
|
|
|
5535
5330
|
if (results[INSTALLER_NAMES.CCR]?.success) {
|
|
5536
5331
|
await this.configureCCRForPersonal();
|
|
5537
5332
|
}
|
|
5538
|
-
console.log(ansis.cyan("\n\u{1F4E6} \u5B89\u88C5\u5DE5\u4F5C\u6D41\u6A21\u677F..."));
|
|
5539
|
-
await selectAndInstallWorkflows("zh-CN");
|
|
5540
5333
|
this.updateGlobalConfig();
|
|
5541
5334
|
this.printResults(results, "\u4E2A\u4EBA\u914D\u7F6E");
|
|
5542
5335
|
}
|
|
@@ -5772,4 +5565,4 @@ async function openSettingsJson() {
|
|
|
5772
5565
|
}
|
|
5773
5566
|
}
|
|
5774
5567
|
|
|
5775
|
-
export { AICO_CONFIG_FILE as A, mergeMcpServers as B, CLAUDE_DIR as C, buildMcpServerConfig as D, fixWindowsMcpConfig as E, addCompletedOnboarding as F, readJsonConfig as G, isTermux as H, messages as I, getTermuxPrefix as J, createEscapablePrompt as K, LEGACY_AICO_CONFIG_FILE as L, MCP_SERVICES as M, displayBannerWithInfo as N, executeWithEscapeSupport as O, handleExitPromptError as P, handleGeneralError as Q, EscapeKeyPressed as R, SETTINGS_FILE as S, displayBanner as T, version as U, ConfigCheckerInstaller as V, InstallerExecutor as W,
|
|
5568
|
+
export { AICO_CONFIG_FILE as A, mergeMcpServers as B, CLAUDE_DIR as C, buildMcpServerConfig as D, fixWindowsMcpConfig as E, addCompletedOnboarding as F, readJsonConfig as G, isTermux as H, messages as I, getTermuxPrefix as J, createEscapablePrompt as K, LEGACY_AICO_CONFIG_FILE as L, MCP_SERVICES as M, displayBannerWithInfo as N, executeWithEscapeSupport as O, handleExitPromptError as P, handleGeneralError as Q, EscapeKeyPressed as R, SETTINGS_FILE as S, displayBanner as T, version as U, ConfigCheckerInstaller as V, InstallerExecutor as W, init$1 as X, importRecommendedEnv as a, importRecommendedPermissions as b, commandExists as c, cleanupPermissions as d, CLAUDE_MD_FILE as e, ClAUDE_CONFIG_FILE as f, getPlatform as g, SUPPORTED_LANGS as h, init as i, LANG_LABELS as j, AI_OUTPUT_LANGUAGES as k, ensureClaudeDir as l, mergeAndCleanPermissions as m, backupExistingConfig as n, openSettingsJson as o, copyConfigFiles as p, configureApi as q, mergeConfigs as r, mergeSettingsFile as s, getExistingApiConfig as t, updateDefaultModel as u, applyAiLanguageDirective as v, getMcpConfigPath as w, readMcpConfig as x, writeMcpConfig as y, backupMcpConfig as z };
|
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
import { join, dirname } from 'pathe';
|
|
2
|
+
import { rm, mkdir, copyFile } from 'node:fs/promises';
|
|
3
|
+
import { existsSync } from 'node:fs';
|
|
4
|
+
import { fileURLToPath } from 'node:url';
|
|
5
|
+
import ansis from 'ansis';
|
|
6
|
+
import { I as messages, C as CLAUDE_DIR } from './simple-config.mjs';
|
|
7
|
+
import 'inquirer';
|
|
8
|
+
import 'tinyexec';
|
|
9
|
+
import 'node:os';
|
|
10
|
+
import 'node:child_process';
|
|
11
|
+
import 'node:util';
|
|
12
|
+
import 'child_process';
|
|
13
|
+
import 'util';
|
|
14
|
+
import 'ora';
|
|
15
|
+
import 'dayjs';
|
|
16
|
+
import 'node:path';
|
|
17
|
+
|
|
18
|
+
const WORKFLOW_CONFIGS = [
|
|
19
|
+
{
|
|
20
|
+
id: "sixStepsWorkflow",
|
|
21
|
+
nameKey: "workflowOption.sixStepsWorkflow",
|
|
22
|
+
descriptionKey: "workflowDescription.sixStepsWorkflow",
|
|
23
|
+
defaultSelected: true,
|
|
24
|
+
order: 1,
|
|
25
|
+
commands: ["workflow.md"],
|
|
26
|
+
agents: [],
|
|
27
|
+
autoInstallAgents: false,
|
|
28
|
+
category: "sixStep",
|
|
29
|
+
outputDir: "workflow"
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
id: "featPlanUx",
|
|
33
|
+
nameKey: "workflowOption.featPlanUx",
|
|
34
|
+
descriptionKey: "workflowDescription.featPlanUx",
|
|
35
|
+
defaultSelected: true,
|
|
36
|
+
order: 2,
|
|
37
|
+
commands: ["feat.md"],
|
|
38
|
+
agents: [
|
|
39
|
+
{ id: "planner", filename: "planner.md", required: true },
|
|
40
|
+
{ id: "ui-ux-designer", filename: "ui-ux-designer.md", required: true }
|
|
41
|
+
],
|
|
42
|
+
autoInstallAgents: true,
|
|
43
|
+
category: "plan",
|
|
44
|
+
outputDir: "feat"
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
id: "bmadWorkflow",
|
|
48
|
+
nameKey: "workflowOption.bmadWorkflow",
|
|
49
|
+
descriptionKey: "workflowDescription.bmadWorkflow",
|
|
50
|
+
defaultSelected: false,
|
|
51
|
+
order: 3,
|
|
52
|
+
commands: ["bmad-init.md"],
|
|
53
|
+
agents: [],
|
|
54
|
+
autoInstallAgents: false,
|
|
55
|
+
category: "bmad",
|
|
56
|
+
outputDir: "bmad"
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
id: "gitWorkflow",
|
|
60
|
+
nameKey: "workflowOption.gitWorkflow",
|
|
61
|
+
descriptionKey: "workflowDescription.gitWorkflow",
|
|
62
|
+
defaultSelected: false,
|
|
63
|
+
order: 4,
|
|
64
|
+
commands: ["git-commit.md", "git-rollback.md", "git-cleanBranches.md", "git-worktree.md"],
|
|
65
|
+
agents: [],
|
|
66
|
+
autoInstallAgents: false,
|
|
67
|
+
category: "git",
|
|
68
|
+
outputDir: "git"
|
|
69
|
+
}
|
|
70
|
+
];
|
|
71
|
+
function getWorkflowConfig(workflowId) {
|
|
72
|
+
return WORKFLOW_CONFIGS.find((config) => config.id === workflowId);
|
|
73
|
+
}
|
|
74
|
+
function getOrderedWorkflows() {
|
|
75
|
+
return [...WORKFLOW_CONFIGS].sort((a, b) => a.order - b.order);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
function getRootDir() {
|
|
79
|
+
const currentFilePath = fileURLToPath(import.meta.url);
|
|
80
|
+
const distDir = dirname(dirname(currentFilePath));
|
|
81
|
+
return dirname(distDir);
|
|
82
|
+
}
|
|
83
|
+
async function selectAndInstallWorkflows(configLang, scriptLang, preselectedWorkflows) {
|
|
84
|
+
const workflows = getOrderedWorkflows();
|
|
85
|
+
workflows.map((workflow) => {
|
|
86
|
+
const nameKey = workflow.id;
|
|
87
|
+
const name = messages.workflow.selectWorkflowType[nameKey] || workflow.id;
|
|
88
|
+
return {
|
|
89
|
+
name,
|
|
90
|
+
value: workflow.id,
|
|
91
|
+
checked: workflow.defaultSelected
|
|
92
|
+
};
|
|
93
|
+
});
|
|
94
|
+
let selectedWorkflows;
|
|
95
|
+
if (preselectedWorkflows) {
|
|
96
|
+
selectedWorkflows = preselectedWorkflows;
|
|
97
|
+
} else {
|
|
98
|
+
selectedWorkflows = workflows.map((w) => w.id);
|
|
99
|
+
}
|
|
100
|
+
if (!selectedWorkflows || selectedWorkflows.length === 0) {
|
|
101
|
+
console.log(ansis.yellow(messages.common.cancelled));
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
await cleanupOldVersionFiles();
|
|
105
|
+
for (const workflowId of selectedWorkflows) {
|
|
106
|
+
const config = getWorkflowConfig(workflowId);
|
|
107
|
+
if (config) {
|
|
108
|
+
await installWorkflowWithDependencies(config, configLang);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
async function installWorkflowWithDependencies(config, configLang, scriptLang) {
|
|
113
|
+
const rootDir = getRootDir();
|
|
114
|
+
const result = {
|
|
115
|
+
workflow: config.id,
|
|
116
|
+
success: true,
|
|
117
|
+
installedCommands: [],
|
|
118
|
+
installedAgents: [],
|
|
119
|
+
errors: []
|
|
120
|
+
};
|
|
121
|
+
const workflowName = messages.workflow.selectWorkflowType[config.id] || config.id;
|
|
122
|
+
console.log(ansis.cyan(`
|
|
123
|
+
\u{1F4E6} ${messages.workflow.installing}: ${workflowName}...`));
|
|
124
|
+
const commandsDir = join(CLAUDE_DIR, "commands", "aico");
|
|
125
|
+
if (!existsSync(commandsDir)) {
|
|
126
|
+
await mkdir(commandsDir, { recursive: true });
|
|
127
|
+
}
|
|
128
|
+
for (const commandFile of config.commands) {
|
|
129
|
+
const commandSource = join(rootDir, "templates", configLang, "workflow", config.category, "commands", commandFile);
|
|
130
|
+
const destFileName = commandFile;
|
|
131
|
+
const commandDest = join(commandsDir, destFileName);
|
|
132
|
+
if (existsSync(commandSource)) {
|
|
133
|
+
try {
|
|
134
|
+
await copyFile(commandSource, commandDest);
|
|
135
|
+
result.installedCommands.push(destFileName);
|
|
136
|
+
console.log(ansis.gray(` \u2714 ${messages.workflow.installedCommand}: aico/${destFileName}`));
|
|
137
|
+
} catch (error) {
|
|
138
|
+
const errorMsg = `${messages.workflow.failedToInstallCommand} ${commandFile}: ${error}`;
|
|
139
|
+
result.errors?.push(errorMsg);
|
|
140
|
+
console.error(ansis.red(` \u2717 ${errorMsg}`));
|
|
141
|
+
result.success = false;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
if (config.autoInstallAgents && config.agents.length > 0) {
|
|
146
|
+
const agentsCategoryDir = join(CLAUDE_DIR, "agents", "aico", config.category);
|
|
147
|
+
if (!existsSync(agentsCategoryDir)) {
|
|
148
|
+
await mkdir(agentsCategoryDir, { recursive: true });
|
|
149
|
+
}
|
|
150
|
+
for (const agent of config.agents) {
|
|
151
|
+
const agentSource = join(rootDir, "templates", configLang, "workflow", config.category, "agents", agent.filename);
|
|
152
|
+
const agentDest = join(agentsCategoryDir, agent.filename);
|
|
153
|
+
if (existsSync(agentSource)) {
|
|
154
|
+
try {
|
|
155
|
+
await copyFile(agentSource, agentDest);
|
|
156
|
+
result.installedAgents.push(agent.filename);
|
|
157
|
+
console.log(ansis.gray(` \u2714 ${messages.workflow.installedAgent}: aico/${config.category}/${agent.filename}`));
|
|
158
|
+
} catch (error) {
|
|
159
|
+
const errorMsg = `${messages.workflow.failedToInstallAgent} ${agent.filename}: ${error}`;
|
|
160
|
+
result.errors?.push(errorMsg);
|
|
161
|
+
console.error(ansis.red(` \u2717 ${errorMsg}`));
|
|
162
|
+
if (agent.required) {
|
|
163
|
+
result.success = false;
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
if (result.success) {
|
|
170
|
+
console.log(ansis.green(`\u2714 ${workflowName} ${messages.workflow.installSuccess}`));
|
|
171
|
+
if (config.id === "bmadWorkflow") {
|
|
172
|
+
console.log(ansis.cyan(`
|
|
173
|
+
${messages.workflow.bmadInitPrompt}`));
|
|
174
|
+
}
|
|
175
|
+
} else {
|
|
176
|
+
console.log(ansis.red(`\u2717 ${workflowName} ${messages.workflow.installFailed}`));
|
|
177
|
+
}
|
|
178
|
+
return result;
|
|
179
|
+
}
|
|
180
|
+
async function cleanupOldVersionFiles(scriptLang) {
|
|
181
|
+
console.log(ansis.cyan(`
|
|
182
|
+
\u{1F9F9} ${messages.workflow.cleaningOldFiles || "Cleaning up old version files"}...`));
|
|
183
|
+
const oldCommandFiles = [
|
|
184
|
+
join(CLAUDE_DIR, "commands", "workflow.md"),
|
|
185
|
+
join(CLAUDE_DIR, "commands", "feat.md")
|
|
186
|
+
];
|
|
187
|
+
const oldAgentFiles = [
|
|
188
|
+
join(CLAUDE_DIR, "agents", "planner.md"),
|
|
189
|
+
join(CLAUDE_DIR, "agents", "ui-ux-designer.md")
|
|
190
|
+
];
|
|
191
|
+
for (const file of oldCommandFiles) {
|
|
192
|
+
if (existsSync(file)) {
|
|
193
|
+
try {
|
|
194
|
+
await rm(file, { force: true });
|
|
195
|
+
console.log(ansis.gray(` \u2714 ${messages.workflow.removedOldFile || "Removed old file"}: ${file.replace(CLAUDE_DIR, "~/.claude")}`));
|
|
196
|
+
} catch (error) {
|
|
197
|
+
console.error(ansis.yellow(` \u26A0 ${messages.workflow.failedToRemoveFile || "Failed to remove"}: ${file.replace(CLAUDE_DIR, "~/.claude")}`));
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
for (const file of oldAgentFiles) {
|
|
202
|
+
if (existsSync(file)) {
|
|
203
|
+
try {
|
|
204
|
+
await rm(file, { force: true });
|
|
205
|
+
console.log(ansis.gray(` \u2714 ${messages.workflow.removedOldFile || "Removed old file"}: ${file.replace(CLAUDE_DIR, "~/.claude")}`));
|
|
206
|
+
} catch (error) {
|
|
207
|
+
console.error(ansis.yellow(` \u26A0 ${messages.workflow.failedToRemoveFile || "Failed to remove"}: ${file.replace(CLAUDE_DIR, "~/.claude")}`));
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
export { selectAndInstallWorkflows };
|
package/dist/cli.mjs
CHANGED
|
@@ -9,7 +9,6 @@ import 'node:os';
|
|
|
9
9
|
import 'node:fs';
|
|
10
10
|
import 'pathe';
|
|
11
11
|
import 'node:url';
|
|
12
|
-
import 'node:fs/promises';
|
|
13
12
|
import 'node:path';
|
|
14
13
|
import { exec } from 'child_process';
|
|
15
14
|
import { promisify } from 'util';
|
|
@@ -342,7 +341,7 @@ function setupCommands(cli) {
|
|
|
342
341
|
} else if (options.update) {
|
|
343
342
|
await update({});
|
|
344
343
|
} else if (options.company) {
|
|
345
|
-
const { init: init2 } = await import('./chunks/simple-config.mjs').then(function (n) { return n.
|
|
344
|
+
const { init: init2 } = await import('./chunks/simple-config.mjs').then(function (n) { return n.X; });
|
|
346
345
|
await init2({
|
|
347
346
|
apiType: "auth_token",
|
|
348
347
|
force: options.force,
|
|
@@ -350,7 +349,7 @@ function setupCommands(cli) {
|
|
|
350
349
|
skipPrompt: true
|
|
351
350
|
});
|
|
352
351
|
} else if (options.personal) {
|
|
353
|
-
const { init: init2 } = await import('./chunks/simple-config.mjs').then(function (n) { return n.
|
|
352
|
+
const { init: init2 } = await import('./chunks/simple-config.mjs').then(function (n) { return n.X; });
|
|
354
353
|
await init2({
|
|
355
354
|
apiType: "ccr_proxy",
|
|
356
355
|
force: options.force,
|
|
@@ -384,7 +383,7 @@ async function startCodeEditor() {
|
|
|
384
383
|
}
|
|
385
384
|
} else {
|
|
386
385
|
console.log(ansis.yellow("\u26A0\uFE0F \u672A\u68C0\u6D4B\u5230\u914D\u7F6E\uFF0C\u5C06\u5148\u6267\u884C\u521D\u59CB\u5316\u914D\u7F6E..."));
|
|
387
|
-
const { init: init2 } = await import('./chunks/simple-config.mjs').then(function (n) { return n.
|
|
386
|
+
const { init: init2 } = await import('./chunks/simple-config.mjs').then(function (n) { return n.X; });
|
|
388
387
|
await init2({ skipBanner: true, skipPrompt: true });
|
|
389
388
|
}
|
|
390
389
|
await startClaudeCodeEditor();
|
|
@@ -431,7 +430,7 @@ async function installMissingFeatures(context, _featureStatus, missingFeatures)
|
|
|
431
430
|
if (featureName === "workflow" || featureName === "aiPersonality") {
|
|
432
431
|
console.log(ansis.blue(`\u{1F4E6} \u5B89\u88C5\u529F\u80FD: ${featureName}...`));
|
|
433
432
|
try {
|
|
434
|
-
const { selectAndInstallWorkflows } = await import('./chunks/
|
|
433
|
+
const { selectAndInstallWorkflows } = await import('./chunks/workflow-installer.mjs');
|
|
435
434
|
await selectAndInstallWorkflows("zh-CN", "zh-CN");
|
|
436
435
|
console.log(ansis.green(`\u2705 ${featureName} \u5B89\u88C5\u6210\u529F`));
|
|
437
436
|
} catch (error) {
|
package/dist/index.mjs
CHANGED