@movemama/opencode-legacy 1.0.2 → 1.0.4
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 +5 -5
- package/legacy-rules.json +3 -3
- package/package.json +1 -1
- package/tools/legacy-router.mjs +1 -1
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @movemama/opencode-legacy
|
|
2
2
|
|
|
3
|
-
OpenCode legacy
|
|
3
|
+
OpenCode legacy 文本处理插件,默认更偏向 `GBK` 文本兼容,同时支持手动指定 `GB2312`、脚本型 `.txt` 编辑和 legacy 规则路由场景。
|
|
4
4
|
|
|
5
5
|
当前主链路已经改为纯 JS 编码实现,不再依赖系统外部 `iconv.exe`。
|
|
6
6
|
|
|
@@ -74,7 +74,7 @@ OpenCode legacy 文本处理插件,面向 `GB2312` 文本、脚本型 `.txt`
|
|
|
74
74
|
|
|
75
75
|
## 自定义扩展规则
|
|
76
76
|
|
|
77
|
-
如果用户希望让其他文件类型也走 `
|
|
77
|
+
如果用户希望让其他文件类型也走 `GBK` / `GB2312` 的 legacy 读写链路,当前可以通过项目级规则扩展实现。
|
|
78
78
|
|
|
79
79
|
推荐在当前项目放置:
|
|
80
80
|
|
|
@@ -87,7 +87,7 @@ OpenCode legacy 文本处理插件,面向 `GB2312` 文本、脚本型 `.txt`
|
|
|
87
87
|
"rules": [
|
|
88
88
|
{
|
|
89
89
|
"glob": "**/*.{npc,msg,dialog}",
|
|
90
|
-
"encoding": "
|
|
90
|
+
"encoding": "gbk",
|
|
91
91
|
"strict": true,
|
|
92
92
|
"tool": "txt-gb2312",
|
|
93
93
|
"priority": 50,
|
|
@@ -103,7 +103,7 @@ OpenCode legacy 文本处理插件,面向 `GB2312` 文本、脚本型 `.txt`
|
|
|
103
103
|
字段说明:
|
|
104
104
|
|
|
105
105
|
- `glob`:匹配要走 legacy 读写链路的文件范围
|
|
106
|
-
- `encoding`:指定文件使用的编码,例如 `gb2312
|
|
106
|
+
- `encoding`:指定文件使用的编码,例如 `gbk`、`gb2312`
|
|
107
107
|
- `strict`:是否使用严格模式;通常脚本类文本建议保持 `true`
|
|
108
108
|
- `tool`:建议使用的处理器名称,当前常见值为 `txt-gb2312` 或 `legacy-text`
|
|
109
109
|
- `priority`:规则优先级,数值越大越优先匹配
|
|
@@ -112,7 +112,7 @@ OpenCode legacy 文本处理插件,面向 `GB2312` 文本、脚本型 `.txt`
|
|
|
112
112
|
- `fallbackMode`:主策略失败后的回退方式,例如 `legacy-safe-replace`、`widget-field-update`
|
|
113
113
|
- `scriptMarkers`:用于辅助识别脚本型文件或 DSL 结构的关键标记数组
|
|
114
114
|
|
|
115
|
-
|
|
115
|
+
如果客户只是想让某类新文件按中文常见编码读写,通常建议优先使用 `GBK`;如果确实需要严格限制在 `GB2312`,也可以手动指定。最小配置通常只需要先关心:
|
|
116
116
|
|
|
117
117
|
- `glob`
|
|
118
118
|
- `encoding`
|
package/legacy-rules.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
|
-
"_comment": "rules 为实际生效规则;examples 为示例模板,不会自动生效。新增文件类型时,优先复制 examples 中最接近的一条到 rules。tool 可选值当前建议使用 txt-gb2312 或 legacy-text
|
|
2
|
+
"_comment": "rules 为实际生效规则;examples 为示例模板,不会自动生效。新增文件类型时,优先复制 examples 中最接近的一条到 rules。tool 可选值当前建议使用 txt-gb2312 或 legacy-text。默认 .txt 规则现已优先使用 gbk,以获得更好的中文兼容性。",
|
|
3
3
|
"rules": [
|
|
4
4
|
{
|
|
5
5
|
"glob": "**/*.txt",
|
|
6
|
-
"encoding": "
|
|
6
|
+
"encoding": "gbk",
|
|
7
7
|
"strict": true,
|
|
8
8
|
"tool": "txt-gb2312",
|
|
9
9
|
"priority": 10,
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
},
|
|
15
15
|
{
|
|
16
16
|
"glob": "**/*.txt",
|
|
17
|
-
"encoding": "
|
|
17
|
+
"encoding": "gbk",
|
|
18
18
|
"strict": true,
|
|
19
19
|
"tool": "txt-gb2312",
|
|
20
20
|
"priority": 20,
|
package/package.json
CHANGED
package/tools/legacy-router.mjs
CHANGED
|
@@ -55,7 +55,7 @@ function globToRegExp(glob) {
|
|
|
55
55
|
|
|
56
56
|
export function createDefaultLegacyRules() {
|
|
57
57
|
return [
|
|
58
|
-
{ glob: '**/*.txt', encoding: '
|
|
58
|
+
{ glob: '**/*.txt', encoding: 'gbk', strict: true },
|
|
59
59
|
{ glob: '**/*.{ini,cfg,dat}', encoding: 'gbk', strict: false },
|
|
60
60
|
];
|
|
61
61
|
}
|