clash-kit 1.0.6 → 1.0.8

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
@@ -38,22 +38,7 @@ clash init
38
38
  ck init
39
39
  ```
40
40
 
41
- ### 3. 启动服务
42
-
43
- 启动 Clash 核心服务(建议在一个单独的终端窗口运行):
44
-
45
- ```bash
46
- # 启动 Clash 代理服务
47
- ck start # 或者 ck on
48
-
49
- # 启动并自动开启系统代理
50
- ck start -s
51
-
52
- # 关闭服务并关闭系统代理
53
- ck stop # 或者 ck off
54
- ```
55
-
56
- ### 4. 添加订阅
41
+ ### 3. 添加订阅
57
42
 
58
43
  ```bash
59
44
  # 交互式管理订阅(添加、切换、删除等)【推荐使用这种方式来管理订阅】
@@ -66,6 +51,21 @@ ck sub -l
66
51
  ck sub -a "https://example.com/subscribe?token=xxx" -n "abcName"
67
52
  ```
68
53
 
54
+ ### 4. 启动服务
55
+
56
+ 启动 Clash 核心服务(建议在一个单独的终端窗口运行):
57
+
58
+ ```bash
59
+ # 启动 Clash 代理服务
60
+ ck on # 或者 ck start
61
+
62
+ # 启动并自动开启系统代理
63
+ ck on -s
64
+
65
+ # 关闭服务并关闭系统代理
66
+ ck off # 或者 ck stop
67
+ ```
68
+
69
69
  ### 4. 节点切换(自动测速)
70
70
 
71
71
  进入交互式界面,自动对当前节点组进行并发测速,并展示带有即时延迟数据的节点列表供选择。
@@ -83,10 +83,10 @@ ck node
83
83
 
84
84
  ```bash
85
85
  # 查看状态
86
- ck status
86
+ ck info # 或者 ck status, ck view
87
87
 
88
88
  # 节点并发测速 (仅测速不切换,支持别名: test, ls, t)
89
- ck list
89
+ ck list # 或者 ck test, ck ls
90
90
 
91
91
  # 设置系统代理
92
92
  ck sys on
@@ -102,9 +102,9 @@ ck tun off # 关闭
102
102
  | 命令 (别名) | 说明 | 示例 |
103
103
  | ----------------------------- | -------------------------- | --------------------------------------- |
104
104
  | `ck init` | 初始化内核及权限 | `ck init` |
105
- | `ck start` (`on`) | 启动 Clash 服务 | `ck on` `ck on -s` (启动并设置系统代理) |
106
- | `ck stop` (`off`) | 停止服务并关闭代理 | `ck off` |
107
- | `ck status` (`info`, `view`) | 查看运行状态及当前节点延迟 | `ck status` |
105
+ | `ck on` (`start`) | 启动 Clash 服务 | `ck on` `ck on -s` (启动并设置系统代理) |
106
+ | `ck off` (`stop`) | 停止服务并关闭代理 | `ck off` |
107
+ | `ck info` (`status`, `view`) | 查看运行状态及当前节点延迟 | `ck info` / `ck status` / `ck view` |
108
108
  | `ck sysproxy` (`sys`) | 设置系统代理 | `ck sys on` / `ck sys off` |
109
109
  | `ck tun` | 设置 TUN 模式 (需要 sudo) | `ck tun on` |
110
110
  | `ck sub` | 管理订阅(交互式)【推荐】 | `ck sub` |
package/bin/index.js CHANGED
@@ -28,14 +28,14 @@ program
28
28
 
29
29
  // 启动 clash 服务
30
30
  program
31
- .command('start')
32
- .alias('on')
31
+ .command('on')
32
+ .alias('start')
33
33
  .description('启动 Clash 服务')
34
34
  .option('-s, --sysproxy', '启动后自动开启系统代理')
35
35
  .action(start)
36
36
 
37
37
  // 停止 clash 服务
38
- program.command('stop').alias('off').description('停止 Clash 服务').action(stop)
38
+ program.command('off').alias('stop').description('停止 Clash 服务').action(stop)
39
39
 
40
40
  // 设置系统代理
41
41
  program
@@ -49,7 +49,7 @@ program
49
49
  program.command('tun').description('设置 TUN 模式 (可能需要提权)').argument('[action]', 'on 或 off').action(setTun)
50
50
 
51
51
  // 查看 clash 状态
52
- program.command('status').alias('st').alias('view').alias('info').description('查看 Clash 运行状态').action(status)
52
+ program.command('info').alias('status').alias('view').description('查看 Clash 运行状态').action(status)
53
53
 
54
54
  // 管理订阅
55
55
  program
package/index.js CHANGED
@@ -15,8 +15,8 @@ const __filename = fileURLToPath(import.meta.url)
15
15
  const __dirname = path.dirname(__filename)
16
16
 
17
17
  // ---------------- 配置项 ----------------
18
- const CLASH_BIN_PATH = path.join(__dirname, 'clash-kit') // 解压后的二进制文件路径
19
- const CLASH_CONFIG_PATH = path.join(__dirname, 'config.yaml') // 配置文件路径
18
+ export const CLASH_BIN_PATH = path.join(__dirname, 'clash-kit') // 解压后的二进制文件路径
19
+ export const CLASH_CONFIG_PATH = path.join(__dirname, 'config.yaml') // 配置文件路径
20
20
 
21
21
  async function checkPorts() {
22
22
  try {
@@ -4,6 +4,7 @@ import fs from 'fs'
4
4
  import { fileURLToPath } from 'url'
5
5
  import chalk from 'chalk'
6
6
  import * as sub from '../subscription.js'
7
+ import { CLASH_BIN_PATH } from '../../index.js'
7
8
 
8
9
  const __filename = fileURLToPath(import.meta.url)
9
10
  const __dirname = path.dirname(__filename)
@@ -22,6 +23,11 @@ async function handleAddSubscription(url, name) {
22
23
  }
23
24
 
24
25
  export async function manageSub(options) {
26
+ // 检查 clash-kit 二进制文件是否存在
27
+ if (!fs.existsSync(CLASH_BIN_PATH)) {
28
+ return console.error(chalk.red('\n找不到 Clash.Meta 内核文件,请先运行 clash init 命令初始化内核!\n'))
29
+ }
30
+
25
31
  if (options.add) {
26
32
  if (!options.name) return console.error('错误: 添加订阅时必须指定名称 (-n)')
27
33
  try {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "clash-kit",
3
- "version": "1.0.6",
3
+ "version": "1.0.8",
4
4
  "type": "module",
5
5
  "description": "A command-line interface for managing Clash configurations, subscriptions, and proxies.",
6
6
  "bin": {