dsh-gufa-code 1.3.173 → 1.3.179
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 +2 -2
- package/client.js +97 -9
- package/package.json +1 -1
- package/src/client/85-shortcuts.js +85 -3
- package/src/client/99-main.js +11 -5
package/README.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# 古法编程 · AI 辅助(dsh-gufa-code)
|
|
2
2
|
|
|
3
|
-
>
|
|
4
|
-
> 在 DeepSeek Harness 里一键进入 VS Code
|
|
3
|
+
> **古法编程:充分、合理、克制地运用 AI。**
|
|
4
|
+
> 在 DeepSeek Harness 里一键进入 VS Code 风格 IDE:左边是编辑器、文件树和终端,右边就是当前这个 DSH 会话;它改了什么、跑了什么、什么时候等你确认,都在眼前。
|
|
5
5
|
|
|
6
6
|
<p align="center">
|
|
7
7
|
<img src="docs/screenshot-ide.jpg" width="900" alt="古法编程 IDE 模式:左侧资源管理器与 Monaco 编辑器,右侧官方 DSH 会话">
|
package/client.js
CHANGED
|
@@ -16,7 +16,7 @@ const GUFA_NS = 'gufa-code'
|
|
|
16
16
|
const G = {}
|
|
17
17
|
G.NS = GUFA_NS
|
|
18
18
|
/** 客户端构建标记(排查页面是否加载了新代码时看标题栏) */
|
|
19
|
-
G.BUILD = '1.3.
|
|
19
|
+
G.BUILD = '1.3.179'
|
|
20
20
|
G.PANEL_ID = 'gufa-code'
|
|
21
21
|
/** 从哪个工作区点进来的(工作区菜单/节点按钮写入,App 启动时消费)。 */
|
|
22
22
|
G.pendingEntryWorkspace = null
|
|
@@ -12114,7 +12114,72 @@ G.installShortcutIntegration = function installShortcutIntegration(service) {
|
|
|
12114
12114
|
delete registry.__gufaOriginalDispatch
|
|
12115
12115
|
}
|
|
12116
12116
|
|
|
12117
|
-
// 2)
|
|
12117
|
+
// 2) 全局清扫历史遗留的命令包装(插件热重载后 service 单例仍在,
|
|
12118
|
+
// 旧模块的 __gufaPatchedCommands 记录可能已经丢失,只靠记录还原不干净)。
|
|
12119
|
+
try {
|
|
12120
|
+
const commandMap = registry.commands
|
|
12121
|
+
if (commandMap !== null && commandMap !== undefined && typeof commandMap.values === 'function') {
|
|
12122
|
+
for (const command of commandMap.values()) {
|
|
12123
|
+
try {
|
|
12124
|
+
if (command !== null && command !== undefined && command.__gufaWrapped === true && typeof command.__gufaOriginalResolve === 'function') {
|
|
12125
|
+
command.resolve = command.__gufaOriginalResolve
|
|
12126
|
+
try { delete command.__gufaWrapped } catch { /* ignore */ }
|
|
12127
|
+
try { delete command.__gufaOriginalResolve } catch { /* ignore */ }
|
|
12128
|
+
}
|
|
12129
|
+
} catch {
|
|
12130
|
+
/* ignore */
|
|
12131
|
+
}
|
|
12132
|
+
}
|
|
12133
|
+
}
|
|
12134
|
+
} catch {
|
|
12135
|
+
/* ignore */
|
|
12136
|
+
}
|
|
12137
|
+
|
|
12138
|
+
// 3) 撤销上一轮命令包装:经典模式必须保持 DSH 原生行为,不能带着我们的
|
|
12139
|
+
// resolve 包装运行(这是 Cmd+/ 呼不出快捷键面板的根因)。
|
|
12140
|
+
const restoreWrappedCommands = () => {
|
|
12141
|
+
const patched = Array.isArray(service.__gufaPatchedCommands) ? service.__gufaPatchedCommands : []
|
|
12142
|
+
for (const item of patched) {
|
|
12143
|
+
try {
|
|
12144
|
+
if (item !== null && item !== undefined && item.command !== null && item.command !== undefined) {
|
|
12145
|
+
item.command.resolve = item.originalResolve
|
|
12146
|
+
try { delete item.command.__gufaWrapped } catch { /* ignore */ }
|
|
12147
|
+
}
|
|
12148
|
+
} catch {
|
|
12149
|
+
/* ignore */
|
|
12150
|
+
}
|
|
12151
|
+
}
|
|
12152
|
+
service.__gufaPatchedCommands = []
|
|
12153
|
+
}
|
|
12154
|
+
restoreWrappedCommands()
|
|
12155
|
+
|
|
12156
|
+
// 模式切换时重新评估:进 IDE 才包装,退出立刻还原
|
|
12157
|
+
if (service.__gufaModeSubscribed !== true && G.mode !== null && G.mode !== undefined && typeof G.mode.subscribe === 'function') {
|
|
12158
|
+
service.__gufaModeSubscribed = true
|
|
12159
|
+
try {
|
|
12160
|
+
G.mode.subscribe(() => {
|
|
12161
|
+
try { G.installShortcutIntegration(service) } catch { /* ignore */ }
|
|
12162
|
+
})
|
|
12163
|
+
} catch {
|
|
12164
|
+
/* ignore */
|
|
12165
|
+
}
|
|
12166
|
+
}
|
|
12167
|
+
|
|
12168
|
+
// 经典模式:不碰任何 DSH 原生命令
|
|
12169
|
+
if (G.mode.get() !== true) {
|
|
12170
|
+
try {
|
|
12171
|
+
if (window !== undefined && window !== null) {
|
|
12172
|
+
if (window.__gufaClassicShortcutLogs === undefined) window.__gufaClassicShortcutLogs = 3
|
|
12173
|
+
if (window.__gufaClassicShortcutLogs > 0) {
|
|
12174
|
+
window.__gufaClassicShortcutLogs -= 1
|
|
12175
|
+
void G.api('dev.log', { message: 'shortcut-integration skipped: classic mode (native untouched)' }).catch(() => {})
|
|
12176
|
+
}
|
|
12177
|
+
}
|
|
12178
|
+
} catch { /* ignore */ }
|
|
12179
|
+
return true
|
|
12180
|
+
}
|
|
12181
|
+
|
|
12182
|
+
// 3) IDE 模式内的命令改派表(被原生占用的组合 → IDE 动作)
|
|
12118
12183
|
const commandActions = {
|
|
12119
12184
|
'session.search': 'clearTerminal',
|
|
12120
12185
|
'sidebar.left.toggle': 'toggleSidebar',
|
|
@@ -12140,7 +12205,10 @@ G.installShortcutIntegration = function installShortcutIntegration(service) {
|
|
|
12140
12205
|
const commands = registry.commands
|
|
12141
12206
|
const makeResolve = (id, originalResolve) => function gufaIdeResolve(context) {
|
|
12142
12207
|
try {
|
|
12143
|
-
|
|
12208
|
+
let overlayMounted = false
|
|
12209
|
+
try { overlayMounted = typeof document !== 'undefined' && document.querySelector('.gufa-overlay-root') !== null } catch { overlayMounted = false }
|
|
12210
|
+
const ideActive = G.mode.get() === true && overlayMounted === true && typeof window.__gufaIdeShortcutDispatch === 'function'
|
|
12211
|
+
if (ideActive) {
|
|
12144
12212
|
const actions = service.__gufaCommandActions
|
|
12145
12213
|
const mapped = actions === null || actions === undefined ? undefined : actions[id]
|
|
12146
12214
|
if (typeof mapped === 'string') {
|
|
@@ -12184,6 +12252,8 @@ G.installShortcutIntegration = function installShortcutIntegration(service) {
|
|
|
12184
12252
|
} catch {
|
|
12185
12253
|
/* ignore */
|
|
12186
12254
|
}
|
|
12255
|
+
if (Array.isArray(service.__gufaPatchedCommands) !== true) service.__gufaPatchedCommands = []
|
|
12256
|
+
service.__gufaPatchedCommands.push({ command, originalResolve })
|
|
12187
12257
|
wrapped.push(id)
|
|
12188
12258
|
}
|
|
12189
12259
|
}
|
|
@@ -12430,11 +12500,23 @@ G.useIdeShortcuts = function useIdeShortcuts(handlers) {
|
|
|
12430
12500
|
} catch {
|
|
12431
12501
|
/* ignore */
|
|
12432
12502
|
}
|
|
12433
|
-
if (typeof G.installShortcutBridge === 'function') G.installShortcutBridge()
|
|
12434
12503
|
return () => {
|
|
12435
12504
|
if (gufaShortcutHandlers === handlers) gufaShortcutHandlers = null
|
|
12436
12505
|
}
|
|
12437
12506
|
}, [handlers])
|
|
12507
|
+
/* 键盘桥只在 IDE 覆盖层挂载期间存在,经典模式完全不装监听器 */
|
|
12508
|
+
useEffect(() => {
|
|
12509
|
+
if (typeof G.installShortcutBridge === 'function') G.installShortcutBridge()
|
|
12510
|
+
return () => {
|
|
12511
|
+
try {
|
|
12512
|
+
if (typeof window.__gufaShortcutBridgeDispose === 'function') window.__gufaShortcutBridgeDispose()
|
|
12513
|
+
} catch {
|
|
12514
|
+
/* ignore */
|
|
12515
|
+
}
|
|
12516
|
+
try { window.__gufaShortcutBridgeDispose = null } catch { /* ignore */ }
|
|
12517
|
+
try { window.__gufaShortcutBridge = false } catch { /* ignore */ }
|
|
12518
|
+
}
|
|
12519
|
+
}, [])
|
|
12438
12520
|
}
|
|
12439
12521
|
|
|
12440
12522
|
|
|
@@ -16670,11 +16752,6 @@ const GUFA_PLUGIN = {
|
|
|
16670
16752
|
} catch (error) {
|
|
16671
16753
|
console.error('[gufa-code] 安装原生快捷键集成失败', error)
|
|
16672
16754
|
}
|
|
16673
|
-
try {
|
|
16674
|
-
if (typeof G.installShortcutBridge === 'function') G.installShortcutBridge()
|
|
16675
|
-
} catch (error) {
|
|
16676
|
-
console.error('[gufa-code] 安装快捷键桥失败', error)
|
|
16677
|
-
}
|
|
16678
16755
|
})
|
|
16679
16756
|
}
|
|
16680
16757
|
} catch (error) {
|
|
@@ -16822,6 +16899,17 @@ try {
|
|
|
16822
16899
|
/* 忽略只读 window */
|
|
16823
16900
|
}
|
|
16824
16901
|
|
|
16902
|
+
/* 插件热重载/升级后,清掉上一代遗留在 window 上的快捷键桥,避免经典模式被旧监听器拦截 */
|
|
16903
|
+
try {
|
|
16904
|
+
if (typeof window !== 'undefined' && window !== null && typeof window.__gufaShortcutBridgeDispose === 'function') {
|
|
16905
|
+
window.__gufaShortcutBridgeDispose()
|
|
16906
|
+
window.__gufaShortcutBridgeDispose = null
|
|
16907
|
+
window.__gufaShortcutBridge = false
|
|
16908
|
+
}
|
|
16909
|
+
} catch {
|
|
16910
|
+
/* ignore */
|
|
16911
|
+
}
|
|
16912
|
+
|
|
16825
16913
|
return GUFA_PLUGIN
|
|
16826
16914
|
|
|
16827
16915
|
},
|
package/package.json
CHANGED
|
@@ -203,7 +203,72 @@ G.installShortcutIntegration = function installShortcutIntegration(service) {
|
|
|
203
203
|
delete registry.__gufaOriginalDispatch
|
|
204
204
|
}
|
|
205
205
|
|
|
206
|
-
// 2)
|
|
206
|
+
// 2) 全局清扫历史遗留的命令包装(插件热重载后 service 单例仍在,
|
|
207
|
+
// 旧模块的 __gufaPatchedCommands 记录可能已经丢失,只靠记录还原不干净)。
|
|
208
|
+
try {
|
|
209
|
+
const commandMap = registry.commands
|
|
210
|
+
if (commandMap !== null && commandMap !== undefined && typeof commandMap.values === 'function') {
|
|
211
|
+
for (const command of commandMap.values()) {
|
|
212
|
+
try {
|
|
213
|
+
if (command !== null && command !== undefined && command.__gufaWrapped === true && typeof command.__gufaOriginalResolve === 'function') {
|
|
214
|
+
command.resolve = command.__gufaOriginalResolve
|
|
215
|
+
try { delete command.__gufaWrapped } catch { /* ignore */ }
|
|
216
|
+
try { delete command.__gufaOriginalResolve } catch { /* ignore */ }
|
|
217
|
+
}
|
|
218
|
+
} catch {
|
|
219
|
+
/* ignore */
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
} catch {
|
|
224
|
+
/* ignore */
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
// 3) 撤销上一轮命令包装:经典模式必须保持 DSH 原生行为,不能带着我们的
|
|
228
|
+
// resolve 包装运行(这是 Cmd+/ 呼不出快捷键面板的根因)。
|
|
229
|
+
const restoreWrappedCommands = () => {
|
|
230
|
+
const patched = Array.isArray(service.__gufaPatchedCommands) ? service.__gufaPatchedCommands : []
|
|
231
|
+
for (const item of patched) {
|
|
232
|
+
try {
|
|
233
|
+
if (item !== null && item !== undefined && item.command !== null && item.command !== undefined) {
|
|
234
|
+
item.command.resolve = item.originalResolve
|
|
235
|
+
try { delete item.command.__gufaWrapped } catch { /* ignore */ }
|
|
236
|
+
}
|
|
237
|
+
} catch {
|
|
238
|
+
/* ignore */
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
service.__gufaPatchedCommands = []
|
|
242
|
+
}
|
|
243
|
+
restoreWrappedCommands()
|
|
244
|
+
|
|
245
|
+
// 模式切换时重新评估:进 IDE 才包装,退出立刻还原
|
|
246
|
+
if (service.__gufaModeSubscribed !== true && G.mode !== null && G.mode !== undefined && typeof G.mode.subscribe === 'function') {
|
|
247
|
+
service.__gufaModeSubscribed = true
|
|
248
|
+
try {
|
|
249
|
+
G.mode.subscribe(() => {
|
|
250
|
+
try { G.installShortcutIntegration(service) } catch { /* ignore */ }
|
|
251
|
+
})
|
|
252
|
+
} catch {
|
|
253
|
+
/* ignore */
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
// 经典模式:不碰任何 DSH 原生命令
|
|
258
|
+
if (G.mode.get() !== true) {
|
|
259
|
+
try {
|
|
260
|
+
if (window !== undefined && window !== null) {
|
|
261
|
+
if (window.__gufaClassicShortcutLogs === undefined) window.__gufaClassicShortcutLogs = 3
|
|
262
|
+
if (window.__gufaClassicShortcutLogs > 0) {
|
|
263
|
+
window.__gufaClassicShortcutLogs -= 1
|
|
264
|
+
void G.api('dev.log', { message: 'shortcut-integration skipped: classic mode (native untouched)' }).catch(() => {})
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
} catch { /* ignore */ }
|
|
268
|
+
return true
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
// 3) IDE 模式内的命令改派表(被原生占用的组合 → IDE 动作)
|
|
207
272
|
const commandActions = {
|
|
208
273
|
'session.search': 'clearTerminal',
|
|
209
274
|
'sidebar.left.toggle': 'toggleSidebar',
|
|
@@ -229,7 +294,10 @@ G.installShortcutIntegration = function installShortcutIntegration(service) {
|
|
|
229
294
|
const commands = registry.commands
|
|
230
295
|
const makeResolve = (id, originalResolve) => function gufaIdeResolve(context) {
|
|
231
296
|
try {
|
|
232
|
-
|
|
297
|
+
let overlayMounted = false
|
|
298
|
+
try { overlayMounted = typeof document !== 'undefined' && document.querySelector('.gufa-overlay-root') !== null } catch { overlayMounted = false }
|
|
299
|
+
const ideActive = G.mode.get() === true && overlayMounted === true && typeof window.__gufaIdeShortcutDispatch === 'function'
|
|
300
|
+
if (ideActive) {
|
|
233
301
|
const actions = service.__gufaCommandActions
|
|
234
302
|
const mapped = actions === null || actions === undefined ? undefined : actions[id]
|
|
235
303
|
if (typeof mapped === 'string') {
|
|
@@ -273,6 +341,8 @@ G.installShortcutIntegration = function installShortcutIntegration(service) {
|
|
|
273
341
|
} catch {
|
|
274
342
|
/* ignore */
|
|
275
343
|
}
|
|
344
|
+
if (Array.isArray(service.__gufaPatchedCommands) !== true) service.__gufaPatchedCommands = []
|
|
345
|
+
service.__gufaPatchedCommands.push({ command, originalResolve })
|
|
276
346
|
wrapped.push(id)
|
|
277
347
|
}
|
|
278
348
|
}
|
|
@@ -519,9 +589,21 @@ G.useIdeShortcuts = function useIdeShortcuts(handlers) {
|
|
|
519
589
|
} catch {
|
|
520
590
|
/* ignore */
|
|
521
591
|
}
|
|
522
|
-
if (typeof G.installShortcutBridge === 'function') G.installShortcutBridge()
|
|
523
592
|
return () => {
|
|
524
593
|
if (gufaShortcutHandlers === handlers) gufaShortcutHandlers = null
|
|
525
594
|
}
|
|
526
595
|
}, [handlers])
|
|
596
|
+
/* 键盘桥只在 IDE 覆盖层挂载期间存在,经典模式完全不装监听器 */
|
|
597
|
+
useEffect(() => {
|
|
598
|
+
if (typeof G.installShortcutBridge === 'function') G.installShortcutBridge()
|
|
599
|
+
return () => {
|
|
600
|
+
try {
|
|
601
|
+
if (typeof window.__gufaShortcutBridgeDispose === 'function') window.__gufaShortcutBridgeDispose()
|
|
602
|
+
} catch {
|
|
603
|
+
/* ignore */
|
|
604
|
+
}
|
|
605
|
+
try { window.__gufaShortcutBridgeDispose = null } catch { /* ignore */ }
|
|
606
|
+
try { window.__gufaShortcutBridge = false } catch { /* ignore */ }
|
|
607
|
+
}
|
|
608
|
+
}, [])
|
|
527
609
|
}
|
package/src/client/99-main.js
CHANGED
|
@@ -666,11 +666,6 @@ const GUFA_PLUGIN = {
|
|
|
666
666
|
} catch (error) {
|
|
667
667
|
console.error('[gufa-code] 安装原生快捷键集成失败', error)
|
|
668
668
|
}
|
|
669
|
-
try {
|
|
670
|
-
if (typeof G.installShortcutBridge === 'function') G.installShortcutBridge()
|
|
671
|
-
} catch (error) {
|
|
672
|
-
console.error('[gufa-code] 安装快捷键桥失败', error)
|
|
673
|
-
}
|
|
674
669
|
})
|
|
675
670
|
}
|
|
676
671
|
} catch (error) {
|
|
@@ -818,4 +813,15 @@ try {
|
|
|
818
813
|
/* 忽略只读 window */
|
|
819
814
|
}
|
|
820
815
|
|
|
816
|
+
/* 插件热重载/升级后,清掉上一代遗留在 window 上的快捷键桥,避免经典模式被旧监听器拦截 */
|
|
817
|
+
try {
|
|
818
|
+
if (typeof window !== 'undefined' && window !== null && typeof window.__gufaShortcutBridgeDispose === 'function') {
|
|
819
|
+
window.__gufaShortcutBridgeDispose()
|
|
820
|
+
window.__gufaShortcutBridgeDispose = null
|
|
821
|
+
window.__gufaShortcutBridge = false
|
|
822
|
+
}
|
|
823
|
+
} catch {
|
|
824
|
+
/* ignore */
|
|
825
|
+
}
|
|
826
|
+
|
|
821
827
|
return GUFA_PLUGIN
|