@dcrays/dcgchat-test 0.3.17 → 0.3.18

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dcrays/dcgchat-test",
3
- "version": "0.3.17",
3
+ "version": "0.3.18",
4
4
  "type": "module",
5
5
  "description": "OpenClaw channel plugin for 书灵墨宝 (WebSocket)",
6
6
  "main": "index.ts",
@@ -94,11 +94,9 @@ function stripMobookNoise(s: string) {
94
94
  }
95
95
 
96
96
  /**
97
- * 从文本中扫描 `/mobook/` 片段,按最长后缀匹配合法扩展名(兜底,不依赖 FILE_NAME 字符集)
97
+ * 从文本中扫描 `.../mobook/...` `...\mobook\...` 片段,按最长后缀匹配合法扩展名(兜底)
98
98
  */
99
- function collectMobookPathsByScan(text: string, result: Set<string>): void {
100
- const lower = text.toLowerCase()
101
- const needle = '/mobook/'
99
+ function collectMobookPathsAfterNeedle(text: string, lower: string, needle: string, result: Set<string>): void {
102
100
  let from = 0
103
101
  while (from < text.length) {
104
102
  const i = lower.indexOf(needle, from)
@@ -136,8 +134,16 @@ function collectMobookPathsByScan(text: string, result: Set<string>): void {
136
134
  }
137
135
  }
138
136
 
137
+ function collectMobookPathsByScan(text: string, result: Set<string>): void {
138
+ const lower = text.toLowerCase()
139
+ collectMobookPathsAfterNeedle(text, lower, '/mobook/', result)
140
+ collectMobookPathsAfterNeedle(text, lower, '\\mobook\\', result)
141
+ }
142
+
139
143
  export function extractMobookFiles(text = '') {
140
144
  if (typeof text !== 'string' || !text.trim()) return []
145
+ // 全角冒号(中文输入常见)→ 半角,便于匹配 c:\mobook\
146
+ text = text.replace(/\uFF1A/g, ':')
141
147
  const result = new Set<string>()
142
148
  // ✅ 扩展名(必须长扩展名优先,见 EXT_SORTED_FOR_REGEX)
143
149
  const EXT = `(${EXT_SORTED_FOR_REGEX.join('|')})`
@@ -157,6 +163,14 @@ export function extractMobookFiles(text = '') {
157
163
  ;(text.match(fullPathReg) || []).forEach((p) => {
158
164
  result.add(normalizePath(p))
159
165
  })
166
+ // 2️⃣b Windows 实际保存路径:C:\mobook\xxx、c:/mobook/xxx、\mobook\xxx(模型常写反斜杠,原先无法识别)
167
+ const winMobookReg = new RegExp(`(?:[a-zA-Z]:)?[/\\\\]mobook[/\\\\]${FILE_NAME}\\.${EXT}`, 'gi')
168
+ ;(text.match(winMobookReg) || []).forEach((full) => {
169
+ const name = full.replace(/^(?:[a-zA-Z]:)?[/\\\\]mobook[/\\\\]/i, '').trim()
170
+ if (isValidFileName(name)) {
171
+ result.add(normalizePath(`/mobook/${name}`))
172
+ }
173
+ })
160
174
  // 3️⃣ mobook下的 xxx.xxx
161
175
  const inlineReg = new RegExp(`mobook下的\\s*(${FILE_NAME}\\.${EXT})`, 'gi')
162
176
  ;(text.match(inlineReg) || []).forEach((item) => {