aicodeswitch 1.3.7 → 1.3.9

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/bin/cli.js CHANGED
@@ -1,41 +1,17 @@
1
1
  #!/usr/bin/env node
2
2
 
3
3
  const path = require('path');
4
- const fs = require('fs');
5
- const os = require('os');
6
4
 
7
5
  const args = process.argv.slice(2);
8
6
  const command = args[0];
9
7
 
10
- // 检查是否有更新版本的 current 文件
11
- const CURRENT_FILE = path.join(os.homedir(), '.aicodeswitch', 'current');
12
-
13
- let binDir = __dirname;
14
- let useLocalVersion = true;
15
-
16
- // 如果存在 current 文件,使用更新版本的脚本
17
- if (fs.existsSync(CURRENT_FILE)) {
18
- try {
19
- const currentPath = fs.readFileSync(CURRENT_FILE, 'utf-8').trim();
20
- const currentBinDir = path.join(currentPath, 'bin');
21
-
22
- // 检查新版本的 bin 目录是否存在
23
- if (fs.existsSync(currentBinDir) && fs.existsSync(path.join(currentBinDir, 'cli.js'))) {
24
- binDir = currentBinDir;
25
- useLocalVersion = false;
26
- }
27
- } catch (err) {
28
- // 读取失败,使用本地版本
29
- }
30
- }
31
-
32
8
  const commands = {
33
- start: () => require(path.join(binDir, 'start')),
34
- stop: () => require(path.join(binDir, 'stop')),
35
- restart: () => require(path.join(binDir, 'restart')),
36
- update: () => require(path.join(binDir, 'update')),
37
- restore: () => require(path.join(binDir, 'restore')),
38
- version: () => require(path.join(binDir, 'version')),
9
+ start: () => require(path.join(__dirname, 'start')),
10
+ stop: () => require(path.join(__dirname, 'stop')),
11
+ restart: () => require(path.join(__dirname, 'restart')),
12
+ update: () => require(path.join(__dirname, 'update')),
13
+ restore: () => require(path.join(__dirname, 'restore')),
14
+ version: () => require(path.join(__dirname, 'version')),
39
15
  };
40
16
 
41
17
  if (!command || !commands[command]) {
package/bin/restore.js CHANGED
@@ -220,7 +220,7 @@ const restore = async () => {
220
220
 
221
221
  console.log('');
222
222
  console.log(chalk.cyan('💡 Tips:\n'));
223
- console.log(chalk.white(' • Write config: ') + chalk.cyan('aicos write-config [target]'));
223
+ console.log(chalk.white(' • Restart server: ') + chalk.cyan('aicos restart'));
224
224
  console.log(chalk.white(' • Start server: ') + chalk.cyan('aicos start'));
225
225
  console.log('\n');
226
226
  };
package/bin/version.js CHANGED
@@ -1,51 +1,21 @@
1
1
  const path = require('path');
2
2
  const fs = require('fs');
3
- const os = require('os');
4
3
  const chalk = require('chalk');
5
4
  const boxen = require('boxen');
6
5
 
7
- const AICOSWITCH_DIR = path.join(os.homedir(), '.aicodeswitch');
8
- const CURRENT_FILE = path.join(AICOSWITCH_DIR, 'current');
9
-
10
6
  const getVersionInfo = () => {
11
- // 先检查是否有 current 文件(更新的版本)
12
- if (fs.existsSync(CURRENT_FILE)) {
13
- try {
14
- const currentPath = fs.readFileSync(CURRENT_FILE, 'utf-8').trim();
15
- const currentPackageJson = path.join(currentPath, 'package.json');
16
-
17
- if (fs.existsSync(currentPackageJson)) {
18
- const pkg = JSON.parse(fs.readFileSync(currentPackageJson, 'utf-8'));
19
-
20
- return {
21
- version: pkg.version,
22
- source: 'npm',
23
- path: currentPath,
24
- isUpdated: true
25
- };
26
- }
27
- } catch (err) {
28
- // 读取失败,fallback 到本地版本
29
- }
30
- }
31
-
32
- // 使用本地 package.json
33
7
  try {
34
8
  const packageJson = path.join(__dirname, '..', 'package.json');
35
9
  const pkg = JSON.parse(fs.readFileSync(packageJson, 'utf-8'));
36
10
 
37
11
  return {
38
12
  version: pkg.version,
39
- source: 'local',
40
- path: path.dirname(packageJson),
41
- isUpdated: false
13
+ path: path.dirname(packageJson)
42
14
  };
43
15
  } catch (err) {
44
16
  return {
45
17
  version: 'unknown',
46
- source: 'unknown',
47
- path: 'unknown',
48
- isUpdated: false
18
+ path: 'unknown'
49
19
  };
50
20
  }
51
21
  };
@@ -55,41 +25,21 @@ const version = () => {
55
25
 
56
26
  console.log('\n');
57
27
 
58
- if (info.isUpdated) {
59
- console.log(boxen(
60
- chalk.green.bold('AI Code Switch\n\n') +
61
- chalk.white('Version: ') + chalk.cyan.bold(info.version) + '\n' +
62
- chalk.white('Source: ') + chalk.yellow.bold('npm (updated)') + '\n' +
63
- chalk.white('Location: ') + chalk.gray(info.path),
64
- {
65
- padding: 1,
66
- margin: 1,
67
- borderStyle: 'double',
68
- borderColor: 'green'
69
- }
70
- ));
71
-
72
- console.log(chalk.cyan('💡 Tips:\n'));
73
- console.log(chalk.white(' • Check for updates: ') + chalk.yellow('aicos update'));
74
- console.log(chalk.white(' • Revert to local: ') + chalk.gray('rm ~/.aicodeswitch/current\n'));
75
- } else {
76
- console.log(boxen(
77
- chalk.cyan.bold('AI Code Switch\n\n') +
78
- chalk.white('Version: ') + chalk.cyan.bold(info.version) + '\n' +
79
- chalk.white('Source: ') + chalk.yellow.bold('local development') + '\n' +
80
- chalk.white('Location: ') + chalk.gray(info.path),
81
- {
82
- padding: 1,
83
- margin: 1,
84
- borderStyle: 'double',
85
- borderColor: 'cyan'
86
- }
87
- ));
28
+ console.log(boxen(
29
+ chalk.cyan.bold('AI Code Switch\n\n') +
30
+ chalk.white('Version: ') + chalk.cyan.bold(info.version) + '\n' +
31
+ chalk.white('Location: ') + chalk.gray(info.path),
32
+ {
33
+ padding: 1,
34
+ margin: 1,
35
+ borderStyle: 'double',
36
+ borderColor: 'cyan'
37
+ }
38
+ ));
88
39
 
89
- console.log(chalk.cyan('💡 Tips:\n'));
90
- console.log(chalk.white(' • Check for updates: ') + chalk.yellow('aicos update'));
91
- console.log(chalk.white(' • Update to latest: ') + chalk.yellow('aicos update\n'));
92
- }
40
+ console.log(chalk.cyan('💡 Tips:\n'));
41
+ console.log(chalk.white(' • Check for updates: ') + chalk.yellow('aicos update'));
42
+ console.log(chalk.white(' • Restart server: ') + chalk.yellow('aicos restart\n'));
93
43
 
94
44
  process.exit(0);
95
45
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aicodeswitch",
3
- "version": "1.3.7",
3
+ "version": "1.3.9",
4
4
  "description": "A tool to help you manage AI programming tools to access large language models locally. It allows your Claude Code, Codex and other tools to no longer be limited to official models.",
5
5
  "author": "tangshuang",
6
6
  "license": "GPL-3.0",