dsh-autodetect 0.1.0 → 0.2.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/README.md CHANGED
@@ -8,6 +8,7 @@
8
8
  <p align="center">
9
9
  <a href="https://github.com/Xiaoph123/dsh-autodetect"><img src="https://img.shields.io/badge/DeepSeek-Harness%20Web-4b6bfb" alt="DeepSeek Harness Web"></a>
10
10
  <a href="https://www.npmjs.com/package/dsh-autodetect"><img src="https://img.shields.io/npm/v/dsh-autodetect" alt="npm version"></a>
11
+ <a href="https://www.npmjs.com/package/dsh-autodetect"><img src="https://img.shields.io/npm/dm/dsh-autodetect" alt="npm downloads"></a>
11
12
  <a href="https://github.com/Xiaoph123/dsh-autodetect/blob/main/LICENSE"><img src="https://img.shields.io/badge/license-MIT-green" alt="MIT license"></a>
12
13
  </p>
13
14
 
@@ -33,48 +34,27 @@ Windows 工具链里,`.bat`、`.cmd`、`.ini`、`.vbs` 和 `.ps1` 经常混用
33
34
 
34
35
  ### 推荐:通过 npm 包安装
35
36
 
36
- 先确认已安装 Node.js、Python 3.10+ 和 DeepSeek Harness Web。发布到 npm 后,推荐直接执行这一条命令:
37
+ 当前 TypeScript 版本 `0.2.0` 已发布到 [npm](https://www.npmjs.com/package/dsh-autodetect)。它不再需要 Python;先确认已安装 Node.js 和 DeepSeek Harness Web,然后推荐直接执行这一条命令:
37
38
 
38
39
  ```powershell
39
- dsh plugin --profile web install dsh-autodetect --replace --yes
40
+ dsh plugin --profile web add dsh-autodetect
40
41
  ```
41
42
 
42
43
  `dsh` 会从 npm 获取 `dsh-autodetect`,并把它注册到 **Harness Web 官方侧边栏**。安装或更新后重启 Harness Web。
43
44
 
44
- 如果你的 `dsh` 版本不支持从 npm 包名解析,也可以先下载包再使用本地目录:
45
+ 如果你的 `dsh` 版本不支持从 npm 包名解析,可以先下载包再使用本地目录:
45
46
 
46
47
  ```powershell
47
48
  npm install dsh-autodetect
48
- dsh plugin --profile web install .\node_modules\dsh-autodetect --replace --yes
49
+ dsh plugin --profile web add .\node_modules\dsh-autodetect
49
50
  ```
50
51
 
51
- > 如果当前版本的 `dsh` CLI 不接受 npm 包名,请使用兼容方式:
52
- >
53
- > ```powershell
54
- > git clone https://github.com/Xiaoph123/dsh-autodetect.git
55
- > dsh plugin --profile web install .\dsh-autodetect --replace --yes
56
- > ```
57
-
58
52
  ### 开发链接安装
59
53
 
60
54
  ```powershell
61
55
  git clone https://github.com/Xiaoph123/dsh-autodetect.git
62
56
  cd dsh-autodetect
63
- dsh plugin --profile web install . --link --replace --yes
64
- ```
65
-
66
- ### Python 依赖
67
-
68
- 插件后端需要 `charset-normalizer`:
69
-
70
- ```powershell
71
- py -3 -m pip install -r requirements.txt
72
- ```
73
-
74
- 如果 Harness 使用的不是默认 Python,可以指定:
75
-
76
- ```powershell
77
- $env:AUTODETECT_PYTHON = 'C:\Path\To\python.exe'
57
+ dsh plugin --profile web add .
78
58
  ```
79
59
 
80
60
  ## 使用
@@ -91,7 +71,7 @@ $env:AUTODETECT_PYTHON = 'C:\Path\To\python.exe'
91
71
  插件由两个部分组成:
92
72
 
93
73
  - **Node.js Host**:注册 `/autodetect/api/read` 和 `/autodetect/api/write`,执行会话工作区校验、SHA-256 并发检查和备份。
94
- - **Python Codec Helper**:读取原始字节,检测编码、BOM 和换行格式,并按元数据原子写回。
74
+ - **TypeScript Codec**:使用 Node.js Buffer 和 `iconv-lite` 读取原始字节,检测编码、BOM 和换行格式,并按元数据原子写回。
95
75
 
96
76
  客户端通过 Harness 官方 Sidebar slots 注册文件标签页,只匹配 `dsh-resource://file/**` 下的目标扩展名。
97
77
 
@@ -99,17 +79,17 @@ $env:AUTODETECT_PYTHON = 'C:\Path\To\python.exe'
99
79
 
100
80
  ```text
101
81
  dsh-autodetect/
102
- ├─ lib/
103
- │ ├─ index.js # Host 路由和 Python Helper 调用
104
- └─ client.js # Harness 官方 Sidebar 文件标签页
105
- ├─ python/
106
- │ └─ autodetect_codec.py # 编码检测、读取和写入
82
+ ├─ src/
83
+ │ ├─ host/ # Node.js Host 路由与会话工作区校验
84
+ ├─ codec/ # TypeScript 编码检测、读取和写入
85
+ │ └─ client/ # Harness 官方 Sidebar 文件标签页
86
+ ├─ lib/ # 构建后的 JavaScript 文件
107
87
  ├─ tests/
108
- │ ├─ test_codec.py # 编码与文件写入测试
88
+ │ ├─ codec.test.mjs # 编码与文件写入测试
109
89
  │ └─ test_package.mjs # npm 元数据和 README 回归测试
110
90
  ├─ cordis.patch.yml # DSH Web 插件挂载配置
111
91
  ├─ package.json
112
- ├─ requirements.txt
92
+ ├─ tsconfig.json
113
93
  └─ README.md
114
94
  ```
115
95
 
@@ -121,9 +101,9 @@ npm run pack:check
121
101
  node --check lib\index.js
122
102
  ```
123
103
 
124
- `npm run pack:check` 会检查最终 npm 包内容,不会把 `node_modules`、Python 缓存或备份文件打进去。
104
+ `npm run pack:check` 会检查最终 npm 包内容,不会把 `node_modules`、源代码、测试、缓存或备份文件打进去。
125
105
 
126
- ## 发布
106
+ ## 维护者发布
127
107
 
128
108
  维护者登录 npm 后执行:
129
109
 
@@ -132,6 +112,8 @@ npm login
132
112
  npm publish --access public
133
113
  ```
134
114
 
115
+ 当前公开包地址:<https://www.npmjs.com/package/dsh-autodetect>
116
+
135
117
  发布新版本前先更新 `package.json` 中的版本号,并运行:
136
118
 
137
119
  ```powershell
@@ -150,9 +132,9 @@ npm publish --access public
150
132
 
151
133
  这是 SHA-256 并发保护触发。重新打开文件、确认内容后再保存,避免覆盖其他程序的修改。
152
134
 
153
- ### Python 依赖找不到
135
+ ### 旧版本为什么需要 Python
154
136
 
155
- 使用 Harness 实际调用的 Python 解释器安装 `requirements.txt`,必要时设置 `AUTODETECT_PYTHON`。
137
+ `0.1.x` 是历史 Python 版本;从 `0.2.0` 开始,编码检测和文件写回已经迁移到 TypeScript/Node.js,不再需要 Python 或 `charset-normalizer`。
156
138
 
157
139
  ## 许可证
158
140
 
@@ -160,4 +142,4 @@ npm publish --access public
160
142
 
161
143
  ## 反馈与贡献
162
144
 
163
- 欢迎通过 [GitHub Issues](https://github.com/Xiaoph123/dsh-autodetect/issues) 提交问题。反馈时请注明 Harness Web 版本、Node.js/Python 版本,以及是否使用了官方侧边栏宿主。
145
+ 欢迎通过 [GitHub Issues](https://github.com/Xiaoph123/dsh-autodetect/issues) 提交问题。反馈时请注明 Harness Web 版本、Node.js 版本,以及是否使用了官方侧边栏宿主。