aico-cli 2.0.36 → 2.0.38

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 { O as createEscapablePrompt, P as processManager, l as isClaudeCodeInstalled, n as installClaudeCode, Q as displayBannerWithInfo, i as init, R as executeWithEscapeSupport, T as handleExitPromptError, U as handleGeneralError, V as EscapeKeyPressed, W as version, X as ConfigCheckerInstaller, Y as readAicoConfig, Z as updateAicoConfig } from './chunks/simple-config.mjs';
4
+ import { V as createEscapablePrompt, W as processManager, r as isClaudeCodeInstalled, s as installClaudeCode, X as displayBannerWithInfo, i as init, Y as executeWithEscapeSupport, Z as handleExitPromptError, _ as handleGeneralError, $ as EscapeKeyPressed, a0 as version, a1 as ConfigCheckerInstaller, a2 as readAicoConfig, a3 as updateAicoConfig } from './chunks/simple-config.mjs';
5
5
  import inquirer$1 from 'inquirer';
6
6
  import 'tinyexec';
7
7
  import 'node:os';
@@ -329,11 +329,12 @@ async function startClaudeCodeEditorWithSkipPermissions() {
329
329
  }
330
330
  }
331
331
 
332
- function createDefaultContext() {
332
+ function createDefaultContext(target = "claude") {
333
333
  return {
334
334
  lang: "zh-CN",
335
335
  platform: process.platform === "win32" ? "windows" : process.platform === "darwin" ? "macos" : "linux",
336
- isCI: !!process.env.CI
336
+ isCI: !!process.env.CI,
337
+ target
337
338
  };
338
339
  }
339
340
  async function launchCodeEditor() {
@@ -341,7 +342,7 @@ async function launchCodeEditor() {
341
342
  }
342
343
  async function launchCUI() {
343
344
  try {
344
- const { run } = await import('./chunks/simple-config.mjs').then(function (n) { return n.$; });
345
+ const { run } = await import('./chunks/simple-config.mjs').then(function (n) { return n.a5; });
345
346
  console.log("\x1B[36m\u6B63\u5728\u5B89\u88C5PM2...\x1B[0m");
346
347
  await run("npm install -g pm2");
347
348
  console.log("\x1B[36m\u6B63\u5728\u5B89\u88C5AICO\u53EF\u89C6\u5316\u754C\u9762...\x1B[0m");
@@ -486,7 +487,7 @@ function setupCommands(cli) {
486
487
  } else if (options.update) {
487
488
  await updateConfigAndCliOnly();
488
489
  } else if (options.company) {
489
- const { init } = await import('./chunks/simple-config.mjs').then(function (n) { return n.a0; });
490
+ const { init } = await import('./chunks/simple-config.mjs').then(function (n) { return n.a6; });
490
491
  await init({
491
492
  apiType: "auth_token",
492
493
  force: options.force,
@@ -494,7 +495,7 @@ function setupCommands(cli) {
494
495
  skipPrompt: true
495
496
  });
496
497
  } else if (options.personal) {
497
- const { init } = await import('./chunks/simple-config.mjs').then(function (n) { return n.a0; });
498
+ const { init } = await import('./chunks/simple-config.mjs').then(function (n) { return n.a6; });
498
499
  await init({
499
500
  apiType: "ccr_proxy",
500
501
  force: options.force,
@@ -516,7 +517,7 @@ function setupCommands(cli) {
516
517
  await updateConfigAndCliOnly();
517
518
  });
518
519
  cli.command("c", "\u5FEB\u901F\u914D\u7F6E\u516C\u53F8\u8BBE\u7F6E").action(async () => {
519
- const { init } = await import('./chunks/simple-config.mjs').then(function (n) { return n.a0; });
520
+ const { init } = await import('./chunks/simple-config.mjs').then(function (n) { return n.a6; });
520
521
  await init({
521
522
  apiType: "auth_token",
522
523
  force: false,
@@ -525,7 +526,7 @@ function setupCommands(cli) {
525
526
  });
526
527
  });
527
528
  cli.command("p", "\u5FEB\u901F\u914D\u7F6E\u4E2A\u4EBA\u8BBE\u7F6E").action(async () => {
528
- const { init } = await import('./chunks/simple-config.mjs').then(function (n) { return n.a0; });
529
+ const { init } = await import('./chunks/simple-config.mjs').then(function (n) { return n.a6; });
529
530
  await init({
530
531
  apiType: "ccr_proxy",
531
532
  force: false,
@@ -546,7 +547,7 @@ function setupCommands(cli) {
546
547
  async function initCompanyConfigOnly() {
547
548
  try {
548
549
  console.log(ansis.cyan("\u{1F4E6} \u6B63\u5728\u5B89\u88C5\u516C\u53F8\u914D\u7F6E..."));
549
- const { init } = await import('./chunks/simple-config.mjs').then(function (n) { return n.a0; });
550
+ const { init } = await import('./chunks/simple-config.mjs').then(function (n) { return n.a6; });
550
551
  await init({
551
552
  apiType: "auth_token",
552
553
  skipBanner: true,
@@ -568,7 +569,7 @@ async function updateConfigAndCliOnly() {
568
569
  await updateAicoCli();
569
570
  if (configType === "none") {
570
571
  console.log(ansis.cyan("\u{1F4E6} \u672A\u68C0\u6D4B\u5230\u914D\u7F6E\uFF0C\u6B63\u5728\u5B89\u88C5\u516C\u53F8\u914D\u7F6E..."));
571
- const { init } = await import('./chunks/simple-config.mjs').then(function (n) { return n.a0; });
572
+ const { init } = await import('./chunks/simple-config.mjs').then(function (n) { return n.a6; });
572
573
  await init({
573
574
  apiType: "auth_token",
574
575
  skipBanner: true,
@@ -577,7 +578,7 @@ async function updateConfigAndCliOnly() {
577
578
  });
578
579
  } else {
579
580
  console.log(ansis.cyan(`\u{1F504} \u6B63\u5728\u66F4\u65B0${configType === "company" ? "\u516C\u53F8" : "\u4E2A\u4EBA"}\u914D\u7F6E...`));
580
- const { init } = await import('./chunks/simple-config.mjs').then(function (n) { return n.a0; });
581
+ const { init } = await import('./chunks/simple-config.mjs').then(function (n) { return n.a6; });
581
582
  await init({
582
583
  apiType: configType === "company" ? "auth_token" : "ccr_proxy",
583
584
  skipBanner: true,
@@ -604,7 +605,7 @@ async function startCodeEditor() {
604
605
  const needsReinstall = !aicoConfig || aicoConfig.version !== version;
605
606
  if (configType === "none") {
606
607
  console.log(ansis.cyan("\u{1F4E6} \u672A\u68C0\u6D4B\u5230\u914D\u7F6E\uFF0C\u6B63\u5728\u5B89\u88C5\u516C\u53F8\u914D\u7F6E..."));
607
- const { init } = await import('./chunks/simple-config.mjs').then(function (n) { return n.a0; });
608
+ const { init } = await import('./chunks/simple-config.mjs').then(function (n) { return n.a6; });
608
609
  await init({
609
610
  skipBanner: true,
610
611
  skipPrompt: true,
@@ -612,7 +613,7 @@ async function startCodeEditor() {
612
613
  });
613
614
  } else if (needsReinstall) {
614
615
  console.log(ansis.cyan(`\u{1F504} \u68C0\u6D4B\u5230\u65B0\u7248\u672C\uFF0C\u6B63\u5728\u66F4\u65B0${configType === "company" ? "\u516C\u53F8" : "\u4E2A\u4EBA"}\u914D\u7F6E...`));
615
- const { init } = await import('./chunks/simple-config.mjs').then(function (n) { return n.a0; });
616
+ const { init } = await import('./chunks/simple-config.mjs').then(function (n) { return n.a6; });
616
617
  await init({
617
618
  apiType: configType === "company" ? "auth_token" : "ccr_proxy",
618
619
  skipBanner: true,
@@ -628,7 +629,7 @@ async function startCodeEditor() {
628
629
  await startClaudeCodeEditorWithSkipPermissions();
629
630
  } catch (error) {
630
631
  console.error(ansis.red(`\u2716 \u542F\u52A8\u4EE3\u7801\u7F16\u8F91\u5668\u5931\u8D25: ${error}`));
631
- const { processManager } = await import('./chunks/simple-config.mjs').then(function (n) { return n._; });
632
+ const { processManager } = await import('./chunks/simple-config.mjs').then(function (n) { return n.a4; });
632
633
  processManager.cleanup();
633
634
  process.exit(1);
634
635
  }
@@ -671,7 +672,7 @@ function customizeHelp(sections) {
671
672
  }
672
673
  async function startUI() {
673
674
  try {
674
- const { run } = await import('./chunks/simple-config.mjs').then(function (n) { return n.$; });
675
+ const { run } = await import('./chunks/simple-config.mjs').then(function (n) { return n.a5; });
675
676
  console.log("\x1B[36m\u6B63\u5728\u5B89\u88C5\u667A\u80FD\u8F6F\u4EF6\u661F\u5DE5\u5382\u53EF\u89C6\u5316\u754C\u9762...\x1B[0m");
676
677
  await run("npm install -g pm2");
677
678
  await run("npm install -g aico-cui");
package/dist/index.d.mts CHANGED
@@ -1,3 +1,23 @@
1
+ /**
2
+ * 安装目标类型
3
+ * claude: 安装到 ~/.claude (使用 CLAUDE.md)
4
+ * codebuddy: 安装到 ~/.codebuddy (使用 CODEBUDDY.md)
5
+ */
6
+ type InstallationTarget = 'claude' | 'codebuddy';
7
+ /**
8
+ * 安装目标配置
9
+ */
10
+ interface TargetConfig {
11
+ /** 目标目录名 (如 .claude, .codebuddy) */
12
+ dirName: string;
13
+ /** 主配置文件名 (如 CLAUDE.md, CODEBUDDY.md) */
14
+ mainConfigFile: string;
15
+ /** 设置文件名 */
16
+ settingsFile: string;
17
+ /** 模板中的源文件名映射 (源文件名 -> 目标文件名) */
18
+ fileRenames?: Record<string, string>;
19
+ }
20
+
1
21
  interface McpService {
2
22
  id: string;
3
23
  name: string;
@@ -28,6 +48,27 @@ declare const CLAUDE_MD_FILE: string;
28
48
  declare const ClAUDE_CONFIG_FILE: string;
29
49
  declare const LEGACY_AICO_CONFIG_FILE: string;
30
50
  declare const AICO_CONFIG_FILE: string;
51
+ /**
52
+ * 安装目标配置映射
53
+ * 支持 claude 和 codebuddy,可扩展到其他目标
54
+ */
55
+ declare const TARGET_CONFIGS: Record<InstallationTarget, TargetConfig>;
56
+ /**
57
+ * 获取指定目标的目录路径
58
+ */
59
+ declare function getTargetDir(target?: InstallationTarget): string;
60
+ /**
61
+ * 获取指定目标的设置文件路径
62
+ */
63
+ declare function getTargetSettingsFile(target?: InstallationTarget): string;
64
+ /**
65
+ * 获取指定目标的主配置文件路径
66
+ */
67
+ declare function getTargetMainConfigFile(target?: InstallationTarget): string;
68
+ /**
69
+ * 获取指定目标的 aico 配置文件路径
70
+ */
71
+ declare function getTargetAicoConfigFile(target?: InstallationTarget): string;
31
72
  declare const SUPPORTED_LANGS: readonly ["zh-CN"];
32
73
  type SupportedLang = (typeof SUPPORTED_LANGS)[number];
33
74
  declare const LANG_LABELS: {
@@ -46,35 +87,6 @@ declare const AI_OUTPUT_LANGUAGES: {
46
87
  type AiOutputLanguage = keyof typeof AI_OUTPUT_LANGUAGES;
47
88
  declare const MCP_SERVICES: McpService[];
48
89
 
49
- /**
50
- * 初始化选项接口
51
- */
52
- interface InitOptions {
53
- aiOutputLang?: AiOutputLanguage | string;
54
- force?: boolean;
55
- skipBanner?: boolean;
56
- skipPrompt?: boolean;
57
- configAction?: 'new' | 'backup' | 'merge' | 'docs-only' | 'skip';
58
- apiType?: 'auth_token' | 'ccr_proxy' | 'skip';
59
- apiKey?: string;
60
- apiUrl?: string;
61
- mcpServices?: string[] | string | boolean;
62
- workflows?: string[] | string | boolean;
63
- aiPersonality?: string;
64
- installCometixLine?: string | boolean;
65
- }
66
- /**
67
- * 初始化命令主函数 - 重构为使用解耦架构
68
- */
69
- declare function init(options?: InitOptions): Promise<void>;
70
-
71
- declare function getPlatform(): "windows" | "macos" | "linux";
72
- declare function commandExists(command: string): Promise<boolean>;
73
-
74
- declare function isClaudeCodeInstalled(): Promise<boolean>;
75
- declare function installClaudeCode(lang: SupportedLang): Promise<void>;
76
- declare function installClaudeCodeSilently(): Promise<void>;
77
-
78
90
  /**
79
91
  * API configuration for Claude Code
80
92
  */
@@ -83,8 +95,8 @@ interface ApiConfig {
83
95
  key: string;
84
96
  }
85
97
 
86
- declare function ensureClaudeDir(): void;
87
- declare function backupExistingConfig(): string | null;
98
+ declare function ensureClaudeDir(target?: InstallationTarget): void;
99
+ declare function backupExistingConfig(target?: InstallationTarget): string | null;
88
100
  declare function copyConfigFiles(lang: SupportedLang, onlyMd?: boolean): void;
89
101
  interface FileCopyConfig {
90
102
  source: string;
@@ -99,13 +111,19 @@ interface FileCopyConfig {
99
111
  };
100
112
  }
101
113
  declare const DEFAULT_FILE_COPY_CONFIGS: FileCopyConfig[];
102
- declare function copyConfigFilesWithConfig(configs?: FileCopyConfig[]): void;
103
- declare function configureApi(apiConfig: ApiConfig | null): ApiConfig | null;
114
+ /**
115
+ * 根据目标生成文件复制配置
116
+ * 使用目标特定的模板目录 (templates/claude 或 templates/codebuddy)
117
+ */
118
+ declare function getFileCopyConfigsForTarget(target?: InstallationTarget): FileCopyConfig[];
119
+ declare function copyConfigFilesWithConfig(configs?: FileCopyConfig[], target?: InstallationTarget): void;
120
+ declare function configureApi(apiConfig: ApiConfig | null, target?: InstallationTarget): ApiConfig | null;
104
121
  declare function mergeConfigs(sourceFile: string, targetFile: string): void;
105
122
  declare function updateDefaultModel(model: 'opus' | 'sonnet'): void;
106
123
  /**
107
124
  * Merge settings.json intelligently
108
125
  * Preserves user's environment variables and custom configurations
126
+ * Always uses template's hooks and statusLine to ensure correct paths
109
127
  */
110
128
  declare function mergeSettingsFile(templatePath: string, targetPath: string): void;
111
129
  /**
@@ -114,19 +132,51 @@ declare function mergeSettingsFile(templatePath: string, targetPath: string): vo
114
132
  declare function getExistingApiConfig(): ApiConfig | null;
115
133
  declare function applyAiLanguageDirective(aiOutputLang: AiOutputLanguage | string): void;
116
134
 
117
- declare function getMcpConfigPath(): string;
118
- declare function readMcpConfig(): ClaudeConfiguration | null;
119
- declare function writeMcpConfig(config: ClaudeConfiguration): void;
120
- declare function backupMcpConfig(): string | null;
135
+ /**
136
+ * 初始化选项接口
137
+ */
138
+ interface InitOptions {
139
+ aiOutputLang?: AiOutputLanguage | string;
140
+ force?: boolean;
141
+ skipBanner?: boolean;
142
+ skipPrompt?: boolean;
143
+ configAction?: 'new' | 'backup' | 'merge' | 'docs-only' | 'skip';
144
+ apiType?: 'auth_token' | 'ccr_proxy' | 'skip';
145
+ apiKey?: string;
146
+ apiUrl?: string;
147
+ mcpServices?: string[] | string | boolean;
148
+ workflows?: string[] | string | boolean;
149
+ aiPersonality?: string;
150
+ installCometixLine?: string | boolean;
151
+ /** 安装目标:claude 或 codebuddy */
152
+ target?: InstallationTarget;
153
+ }
154
+ /**
155
+ * 初始化命令主函数 - 重构为使用解耦架构
156
+ */
157
+ declare function init(options?: InitOptions): Promise<void>;
158
+
159
+ declare function getPlatform(): "windows" | "macos" | "linux";
160
+ declare function commandExists(command: string): Promise<boolean>;
161
+
162
+ declare function isClaudeCodeInstalled(): Promise<boolean>;
163
+ declare function installClaudeCode(lang: SupportedLang): Promise<void>;
164
+ declare function installClaudeCodeSilently(): Promise<void>;
165
+
166
+ declare function getMcpConfigPath(target?: InstallationTarget): string;
167
+ declare function readMcpConfig(target?: InstallationTarget): ClaudeConfiguration | null;
168
+ declare function writeMcpConfig(config: ClaudeConfiguration, target?: InstallationTarget): void;
169
+ declare function backupMcpConfig(target?: InstallationTarget): string | null;
121
170
  declare function mergeMcpServers(existing: ClaudeConfiguration | null, newServers: Record<string, McpServerConfig>): ClaudeConfiguration;
122
171
  declare function buildMcpServerConfig(baseConfig: McpServerConfig, apiKey?: string, placeholder?: string, envVarName?: string): McpServerConfig;
123
172
  declare function fixWindowsMcpConfig(config: ClaudeConfiguration): ClaudeConfiguration;
124
173
  /**
125
- * 更新 ~/.claude.json 的 env 对象
174
+ * 更新目标配置文件的 env 对象
126
175
  * @param envVars 要设置的环境变量键值对
176
+ * @param target 安装目标,默认为 'claude'
127
177
  */
128
- declare function updateClaudeConfigEnv(envVars: Record<string, string>): void;
129
- declare function addCompletedOnboarding(): void;
178
+ declare function updateClaudeConfigEnv(envVars: Record<string, string>, target?: InstallationTarget): void;
179
+ declare function addCompletedOnboarding(target?: InstallationTarget): void;
130
180
 
131
181
  declare function importRecommendedEnv(): Promise<void>;
132
182
  declare function importRecommendedPermissions(): Promise<void>;
@@ -152,5 +202,5 @@ declare function cleanupPermissions(templatePermissions: string[], userPermissio
152
202
  */
153
203
  declare function mergeAndCleanPermissions(templatePermissions: string[] | undefined, userPermissions: string[] | undefined): string[];
154
204
 
155
- export { AICO_CONFIG_FILE, AI_OUTPUT_LANGUAGES, CLAUDE_DIR, CLAUDE_MD_FILE, ClAUDE_CONFIG_FILE, DEFAULT_FILE_COPY_CONFIGS, LANG_LABELS, LEGACY_AICO_CONFIG_FILE, MCP_SERVICES, SETTINGS_FILE, SUPPORTED_LANGS, addCompletedOnboarding, applyAiLanguageDirective, backupExistingConfig, backupMcpConfig, buildMcpServerConfig, cleanupPermissions, commandExists, configureApi, copyConfigFiles, copyConfigFilesWithConfig, ensureClaudeDir, fixWindowsMcpConfig, getExistingApiConfig, getMcpConfigPath, getPlatform, importRecommendedEnv, importRecommendedPermissions, init, installClaudeCode, installClaudeCodeSilently, isClaudeCodeInstalled, mergeAndCleanPermissions, mergeConfigs, mergeMcpServers, mergeSettingsFile, openSettingsJson, readMcpConfig, updateClaudeConfigEnv, updateDefaultModel, writeMcpConfig };
205
+ export { AICO_CONFIG_FILE, AI_OUTPUT_LANGUAGES, CLAUDE_DIR, CLAUDE_MD_FILE, ClAUDE_CONFIG_FILE, DEFAULT_FILE_COPY_CONFIGS, LANG_LABELS, LEGACY_AICO_CONFIG_FILE, MCP_SERVICES, SETTINGS_FILE, SUPPORTED_LANGS, TARGET_CONFIGS, addCompletedOnboarding, applyAiLanguageDirective, backupExistingConfig, backupMcpConfig, buildMcpServerConfig, cleanupPermissions, commandExists, configureApi, copyConfigFiles, copyConfigFilesWithConfig, ensureClaudeDir, fixWindowsMcpConfig, getExistingApiConfig, getFileCopyConfigsForTarget, getMcpConfigPath, getPlatform, getTargetAicoConfigFile, getTargetDir, getTargetMainConfigFile, getTargetSettingsFile, importRecommendedEnv, importRecommendedPermissions, init, installClaudeCode, installClaudeCodeSilently, isClaudeCodeInstalled, mergeAndCleanPermissions, mergeConfigs, mergeMcpServers, mergeSettingsFile, openSettingsJson, readMcpConfig, updateClaudeConfigEnv, updateDefaultModel, writeMcpConfig };
156
206
  export type { AiOutputLanguage, ApiConfig, ClaudeConfiguration, FileCopyConfig, McpServerConfig, McpService, SupportedLang };
package/dist/index.d.ts CHANGED
@@ -1,3 +1,23 @@
1
+ /**
2
+ * 安装目标类型
3
+ * claude: 安装到 ~/.claude (使用 CLAUDE.md)
4
+ * codebuddy: 安装到 ~/.codebuddy (使用 CODEBUDDY.md)
5
+ */
6
+ type InstallationTarget = 'claude' | 'codebuddy';
7
+ /**
8
+ * 安装目标配置
9
+ */
10
+ interface TargetConfig {
11
+ /** 目标目录名 (如 .claude, .codebuddy) */
12
+ dirName: string;
13
+ /** 主配置文件名 (如 CLAUDE.md, CODEBUDDY.md) */
14
+ mainConfigFile: string;
15
+ /** 设置文件名 */
16
+ settingsFile: string;
17
+ /** 模板中的源文件名映射 (源文件名 -> 目标文件名) */
18
+ fileRenames?: Record<string, string>;
19
+ }
20
+
1
21
  interface McpService {
2
22
  id: string;
3
23
  name: string;
@@ -28,6 +48,27 @@ declare const CLAUDE_MD_FILE: string;
28
48
  declare const ClAUDE_CONFIG_FILE: string;
29
49
  declare const LEGACY_AICO_CONFIG_FILE: string;
30
50
  declare const AICO_CONFIG_FILE: string;
51
+ /**
52
+ * 安装目标配置映射
53
+ * 支持 claude 和 codebuddy,可扩展到其他目标
54
+ */
55
+ declare const TARGET_CONFIGS: Record<InstallationTarget, TargetConfig>;
56
+ /**
57
+ * 获取指定目标的目录路径
58
+ */
59
+ declare function getTargetDir(target?: InstallationTarget): string;
60
+ /**
61
+ * 获取指定目标的设置文件路径
62
+ */
63
+ declare function getTargetSettingsFile(target?: InstallationTarget): string;
64
+ /**
65
+ * 获取指定目标的主配置文件路径
66
+ */
67
+ declare function getTargetMainConfigFile(target?: InstallationTarget): string;
68
+ /**
69
+ * 获取指定目标的 aico 配置文件路径
70
+ */
71
+ declare function getTargetAicoConfigFile(target?: InstallationTarget): string;
31
72
  declare const SUPPORTED_LANGS: readonly ["zh-CN"];
32
73
  type SupportedLang = (typeof SUPPORTED_LANGS)[number];
33
74
  declare const LANG_LABELS: {
@@ -46,35 +87,6 @@ declare const AI_OUTPUT_LANGUAGES: {
46
87
  type AiOutputLanguage = keyof typeof AI_OUTPUT_LANGUAGES;
47
88
  declare const MCP_SERVICES: McpService[];
48
89
 
49
- /**
50
- * 初始化选项接口
51
- */
52
- interface InitOptions {
53
- aiOutputLang?: AiOutputLanguage | string;
54
- force?: boolean;
55
- skipBanner?: boolean;
56
- skipPrompt?: boolean;
57
- configAction?: 'new' | 'backup' | 'merge' | 'docs-only' | 'skip';
58
- apiType?: 'auth_token' | 'ccr_proxy' | 'skip';
59
- apiKey?: string;
60
- apiUrl?: string;
61
- mcpServices?: string[] | string | boolean;
62
- workflows?: string[] | string | boolean;
63
- aiPersonality?: string;
64
- installCometixLine?: string | boolean;
65
- }
66
- /**
67
- * 初始化命令主函数 - 重构为使用解耦架构
68
- */
69
- declare function init(options?: InitOptions): Promise<void>;
70
-
71
- declare function getPlatform(): "windows" | "macos" | "linux";
72
- declare function commandExists(command: string): Promise<boolean>;
73
-
74
- declare function isClaudeCodeInstalled(): Promise<boolean>;
75
- declare function installClaudeCode(lang: SupportedLang): Promise<void>;
76
- declare function installClaudeCodeSilently(): Promise<void>;
77
-
78
90
  /**
79
91
  * API configuration for Claude Code
80
92
  */
@@ -83,8 +95,8 @@ interface ApiConfig {
83
95
  key: string;
84
96
  }
85
97
 
86
- declare function ensureClaudeDir(): void;
87
- declare function backupExistingConfig(): string | null;
98
+ declare function ensureClaudeDir(target?: InstallationTarget): void;
99
+ declare function backupExistingConfig(target?: InstallationTarget): string | null;
88
100
  declare function copyConfigFiles(lang: SupportedLang, onlyMd?: boolean): void;
89
101
  interface FileCopyConfig {
90
102
  source: string;
@@ -99,13 +111,19 @@ interface FileCopyConfig {
99
111
  };
100
112
  }
101
113
  declare const DEFAULT_FILE_COPY_CONFIGS: FileCopyConfig[];
102
- declare function copyConfigFilesWithConfig(configs?: FileCopyConfig[]): void;
103
- declare function configureApi(apiConfig: ApiConfig | null): ApiConfig | null;
114
+ /**
115
+ * 根据目标生成文件复制配置
116
+ * 使用目标特定的模板目录 (templates/claude 或 templates/codebuddy)
117
+ */
118
+ declare function getFileCopyConfigsForTarget(target?: InstallationTarget): FileCopyConfig[];
119
+ declare function copyConfigFilesWithConfig(configs?: FileCopyConfig[], target?: InstallationTarget): void;
120
+ declare function configureApi(apiConfig: ApiConfig | null, target?: InstallationTarget): ApiConfig | null;
104
121
  declare function mergeConfigs(sourceFile: string, targetFile: string): void;
105
122
  declare function updateDefaultModel(model: 'opus' | 'sonnet'): void;
106
123
  /**
107
124
  * Merge settings.json intelligently
108
125
  * Preserves user's environment variables and custom configurations
126
+ * Always uses template's hooks and statusLine to ensure correct paths
109
127
  */
110
128
  declare function mergeSettingsFile(templatePath: string, targetPath: string): void;
111
129
  /**
@@ -114,19 +132,51 @@ declare function mergeSettingsFile(templatePath: string, targetPath: string): vo
114
132
  declare function getExistingApiConfig(): ApiConfig | null;
115
133
  declare function applyAiLanguageDirective(aiOutputLang: AiOutputLanguage | string): void;
116
134
 
117
- declare function getMcpConfigPath(): string;
118
- declare function readMcpConfig(): ClaudeConfiguration | null;
119
- declare function writeMcpConfig(config: ClaudeConfiguration): void;
120
- declare function backupMcpConfig(): string | null;
135
+ /**
136
+ * 初始化选项接口
137
+ */
138
+ interface InitOptions {
139
+ aiOutputLang?: AiOutputLanguage | string;
140
+ force?: boolean;
141
+ skipBanner?: boolean;
142
+ skipPrompt?: boolean;
143
+ configAction?: 'new' | 'backup' | 'merge' | 'docs-only' | 'skip';
144
+ apiType?: 'auth_token' | 'ccr_proxy' | 'skip';
145
+ apiKey?: string;
146
+ apiUrl?: string;
147
+ mcpServices?: string[] | string | boolean;
148
+ workflows?: string[] | string | boolean;
149
+ aiPersonality?: string;
150
+ installCometixLine?: string | boolean;
151
+ /** 安装目标:claude 或 codebuddy */
152
+ target?: InstallationTarget;
153
+ }
154
+ /**
155
+ * 初始化命令主函数 - 重构为使用解耦架构
156
+ */
157
+ declare function init(options?: InitOptions): Promise<void>;
158
+
159
+ declare function getPlatform(): "windows" | "macos" | "linux";
160
+ declare function commandExists(command: string): Promise<boolean>;
161
+
162
+ declare function isClaudeCodeInstalled(): Promise<boolean>;
163
+ declare function installClaudeCode(lang: SupportedLang): Promise<void>;
164
+ declare function installClaudeCodeSilently(): Promise<void>;
165
+
166
+ declare function getMcpConfigPath(target?: InstallationTarget): string;
167
+ declare function readMcpConfig(target?: InstallationTarget): ClaudeConfiguration | null;
168
+ declare function writeMcpConfig(config: ClaudeConfiguration, target?: InstallationTarget): void;
169
+ declare function backupMcpConfig(target?: InstallationTarget): string | null;
121
170
  declare function mergeMcpServers(existing: ClaudeConfiguration | null, newServers: Record<string, McpServerConfig>): ClaudeConfiguration;
122
171
  declare function buildMcpServerConfig(baseConfig: McpServerConfig, apiKey?: string, placeholder?: string, envVarName?: string): McpServerConfig;
123
172
  declare function fixWindowsMcpConfig(config: ClaudeConfiguration): ClaudeConfiguration;
124
173
  /**
125
- * 更新 ~/.claude.json 的 env 对象
174
+ * 更新目标配置文件的 env 对象
126
175
  * @param envVars 要设置的环境变量键值对
176
+ * @param target 安装目标,默认为 'claude'
127
177
  */
128
- declare function updateClaudeConfigEnv(envVars: Record<string, string>): void;
129
- declare function addCompletedOnboarding(): void;
178
+ declare function updateClaudeConfigEnv(envVars: Record<string, string>, target?: InstallationTarget): void;
179
+ declare function addCompletedOnboarding(target?: InstallationTarget): void;
130
180
 
131
181
  declare function importRecommendedEnv(): Promise<void>;
132
182
  declare function importRecommendedPermissions(): Promise<void>;
@@ -152,5 +202,5 @@ declare function cleanupPermissions(templatePermissions: string[], userPermissio
152
202
  */
153
203
  declare function mergeAndCleanPermissions(templatePermissions: string[] | undefined, userPermissions: string[] | undefined): string[];
154
204
 
155
- export { AICO_CONFIG_FILE, AI_OUTPUT_LANGUAGES, CLAUDE_DIR, CLAUDE_MD_FILE, ClAUDE_CONFIG_FILE, DEFAULT_FILE_COPY_CONFIGS, LANG_LABELS, LEGACY_AICO_CONFIG_FILE, MCP_SERVICES, SETTINGS_FILE, SUPPORTED_LANGS, addCompletedOnboarding, applyAiLanguageDirective, backupExistingConfig, backupMcpConfig, buildMcpServerConfig, cleanupPermissions, commandExists, configureApi, copyConfigFiles, copyConfigFilesWithConfig, ensureClaudeDir, fixWindowsMcpConfig, getExistingApiConfig, getMcpConfigPath, getPlatform, importRecommendedEnv, importRecommendedPermissions, init, installClaudeCode, installClaudeCodeSilently, isClaudeCodeInstalled, mergeAndCleanPermissions, mergeConfigs, mergeMcpServers, mergeSettingsFile, openSettingsJson, readMcpConfig, updateClaudeConfigEnv, updateDefaultModel, writeMcpConfig };
205
+ export { AICO_CONFIG_FILE, AI_OUTPUT_LANGUAGES, CLAUDE_DIR, CLAUDE_MD_FILE, ClAUDE_CONFIG_FILE, DEFAULT_FILE_COPY_CONFIGS, LANG_LABELS, LEGACY_AICO_CONFIG_FILE, MCP_SERVICES, SETTINGS_FILE, SUPPORTED_LANGS, TARGET_CONFIGS, addCompletedOnboarding, applyAiLanguageDirective, backupExistingConfig, backupMcpConfig, buildMcpServerConfig, cleanupPermissions, commandExists, configureApi, copyConfigFiles, copyConfigFilesWithConfig, ensureClaudeDir, fixWindowsMcpConfig, getExistingApiConfig, getFileCopyConfigsForTarget, getMcpConfigPath, getPlatform, getTargetAicoConfigFile, getTargetDir, getTargetMainConfigFile, getTargetSettingsFile, importRecommendedEnv, importRecommendedPermissions, init, installClaudeCode, installClaudeCodeSilently, isClaudeCodeInstalled, mergeAndCleanPermissions, mergeConfigs, mergeMcpServers, mergeSettingsFile, openSettingsJson, readMcpConfig, updateClaudeConfigEnv, updateDefaultModel, writeMcpConfig };
156
206
  export type { AiOutputLanguage, ApiConfig, ClaudeConfiguration, FileCopyConfig, McpServerConfig, McpService, SupportedLang };
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- export { A as AICO_CONFIG_FILE, k as AI_OUTPUT_LANGUAGES, C as CLAUDE_DIR, e as CLAUDE_MD_FILE, f as ClAUDE_CONFIG_FILE, D as DEFAULT_FILE_COPY_CONFIGS, j as LANG_LABELS, L as LEGACY_AICO_CONFIG_FILE, M as MCP_SERVICES, S as SETTINGS_FILE, h as SUPPORTED_LANGS, N as addCompletedOnboarding, z as applyAiLanguageDirective, r as backupExistingConfig, G as backupMcpConfig, I as buildMcpServerConfig, d as cleanupPermissions, c as commandExists, u as configureApi, s as copyConfigFiles, t as copyConfigFilesWithConfig, q as ensureClaudeDir, J as fixWindowsMcpConfig, y as getExistingApiConfig, B as getMcpConfigPath, g as getPlatform, a as importRecommendedEnv, b as importRecommendedPermissions, i as init, n as installClaudeCode, p as installClaudeCodeSilently, l as isClaudeCodeInstalled, m as mergeAndCleanPermissions, v as mergeConfigs, H as mergeMcpServers, x as mergeSettingsFile, o as openSettingsJson, E as readMcpConfig, K as updateClaudeConfigEnv, w as updateDefaultModel, F as writeMcpConfig } from './chunks/simple-config.mjs';
1
+ export { A as AICO_CONFIG_FILE, q as AI_OUTPUT_LANGUAGES, C as CLAUDE_DIR, e as CLAUDE_MD_FILE, f as ClAUDE_CONFIG_FILE, D as DEFAULT_FILE_COPY_CONFIGS, p as LANG_LABELS, L as LEGACY_AICO_CONFIG_FILE, M as MCP_SERVICES, S as SETTINGS_FILE, n as SUPPORTED_LANGS, T as TARGET_CONFIGS, U as addCompletedOnboarding, H as applyAiLanguageDirective, v as backupExistingConfig, N as backupMcpConfig, P as buildMcpServerConfig, d as cleanupPermissions, c as commandExists, z as configureApi, w as copyConfigFiles, y as copyConfigFilesWithConfig, u as ensureClaudeDir, Q as fixWindowsMcpConfig, G as getExistingApiConfig, x as getFileCopyConfigsForTarget, I as getMcpConfigPath, g as getPlatform, l as getTargetAicoConfigFile, h as getTargetDir, k as getTargetMainConfigFile, j as getTargetSettingsFile, a as importRecommendedEnv, b as importRecommendedPermissions, i as init, s as installClaudeCode, t as installClaudeCodeSilently, r as isClaudeCodeInstalled, m as mergeAndCleanPermissions, B as mergeConfigs, O as mergeMcpServers, F as mergeSettingsFile, o as openSettingsJson, J as readMcpConfig, R as updateClaudeConfigEnv, E as updateDefaultModel, K as writeMcpConfig } from './chunks/simple-config.mjs';
2
2
  import 'ansis';
3
3
  import 'inquirer';
4
4
  import 'tinyexec';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aico-cli",
3
- "version": "2.0.36",
3
+ "version": "2.0.38",
4
4
  "packageManager": "pnpm@9.15.9",
5
5
  "description": "AI CLI",
6
6
  "repository": {
@@ -0,0 +1,2 @@
1
+ @language.md
2
+ @personality.md
@@ -0,0 +1,98 @@
1
+ {
2
+ "$schema": "https://json.schemastore.org/claude-code-settings.json",
3
+ "env": {
4
+ "DISABLE_TELEMETRY": "1",
5
+ "DISABLE_ERROR_REPORTING": "1",
6
+ "CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC": "1",
7
+ "ANTHROPIC_BASE_URL": "http://127.0.0.1:3456",
8
+ "ANTHROPIC_AUTH_TOKEN": "sk-aico-x-ccr"
9
+ },
10
+ "includeCoAuthoredBy": false,
11
+ "permissions": {
12
+ "allow": [
13
+ "Bash",
14
+ "LS",
15
+ "Read",
16
+ "Agent",
17
+ "Write",
18
+ "Edit",
19
+ "MultiEdit",
20
+ "Glob",
21
+ "Grep",
22
+ "WebFetch",
23
+ "WebSearch",
24
+ "TodoWrite",
25
+ "NotebookRead",
26
+ "NotebookEdit",
27
+ "mcp__intention-coding",
28
+ "mcp__context7",
29
+ "mcp__open-websearch",
30
+ "mcp__chrome-devtools"
31
+ ],
32
+ "deny": []
33
+ },
34
+ "hooks": {
35
+ "PreToolUse": [
36
+ {
37
+ "matcher": "Edit|Write",
38
+ "hooks": [
39
+ {
40
+ "type": "command",
41
+ "command": "npx tsx ~/.claude/hooks/scripts/PreToolUse/pre-tool-use.ts",
42
+ "timeout": 10
43
+ }
44
+ ]
45
+ }
46
+ ],
47
+ "PostToolUse": [
48
+ {
49
+ "matcher": "Edit|Write",
50
+ "hooks": [
51
+ {
52
+ "type": "command",
53
+ "command": "npx tsx ~/.claude/hooks/scripts/PostToolUse/post-tool-use.ts",
54
+ "timeout": 10
55
+ }
56
+ ]
57
+ }
58
+ ],
59
+ "UserPromptSubmit": [
60
+ {
61
+ "hooks": [
62
+ {
63
+ "type": "command",
64
+ "command": "npx tsx ~/.claude/hooks/scripts/UserPromptSubmit/user-prompt-submit.ts",
65
+ "timeout": 10
66
+ }
67
+ ]
68
+ }
69
+ ],
70
+ "Notification": [
71
+ {
72
+ "hooks": [
73
+ {
74
+ "type": "command",
75
+ "command": "npx tsx ~/.claude/hooks/scripts/Notification/notification.ts",
76
+ "timeout": 10
77
+ }
78
+ ]
79
+ }
80
+ ],
81
+ "Stop": [
82
+ {
83
+ "hooks": [
84
+ {
85
+ "type": "command",
86
+ "command": "npx tsx ~/.claude/hooks/scripts/Stop/stop.ts",
87
+ "timeout": 10
88
+ }
89
+ ]
90
+ }
91
+ ]
92
+ },
93
+ "statusLine": {
94
+ "type": "command",
95
+ "command": "~/.claude/ccline/ccline",
96
+ "padding": 0
97
+ }
98
+ }
@@ -0,0 +1,2 @@
1
+ @language.md
2
+ @personality.md