dsh-gufa-code 1.3.133 → 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 +4 -4
- package/client.js +383 -39
- package/desktop/float/bin/gufa-float-macos-arm64 +0 -0
- package/desktop/float/bin/gufa-float-macos-universal +0 -0
- package/desktop/float/bin/gufa-float-macos-x64 +0 -0
- package/desktop/float//345/217/244/346/263/225/347/274/226/347/250/213/346/202/254/346/265/256/345/261/202.app/Contents/Info.plist +2 -2
- package/desktop/float//345/217/244/346/263/225/347/274/226/347/250/213/346/202/254/346/265/256/345/261/202.app/Contents/MacOS/gufa-float +0 -0
- package/docs/KNOWN-PITFALLS.md +26 -0
- package/host/code.js +41 -0
- package/host/fs.js +11 -0
- package/host/lint.js +152 -2
- package/package.json +2 -1
- package/scripts/selftest-host.mjs +17 -2
- package/scripts/test-editor.mjs +3 -3
- package/src/client/00-core.js +11 -0
- package/src/client/20-editor.js +78 -23
- package/src/client/55-backdrop.js +51 -0
- package/src/client/60-dock.js +144 -6
- package/src/client/85-shortcuts.js +85 -3
- package/src/client/90-app.js +2 -1
- 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 会话">
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
一个 DSH 插件。点工作区行「…」菜单里的 **古法编程** 后,主面板切换成一个三栏 IDE:
|
|
13
13
|
|
|
14
14
|
- **左**:活动栏 + 资源管理器 / 全局搜索 / 源代码管理 / SSH / 终端;
|
|
15
|
-
- **中**:Monaco 编辑器(标签页、面包屑、状态栏、两文件对比、Git diff、⌘+点击/F12 跳转定义;系统内置 API 如 `parseInt` 会打开 TypeScript lib
|
|
15
|
+
- **中**:Monaco 编辑器(标签页、面包屑、状态栏、两文件对比、Git diff、⌘+点击/F12 跳转定义;系统内置 API 如 `parseInt` 会打开 TypeScript lib 的只读标签;会话里的文件引用 chip 点击直接跳到古法编辑器对应行);
|
|
16
16
|
- **右**:**官方 DSH 会话面板原样停靠** —— 工具调用、自动读写文件、审批弹窗、斜杠命令、上下文引用、会话历史都还在。
|
|
17
17
|
|
|
18
18
|
从哪个工作区点进来,IDE 就打开哪个工作区,右侧也自动是你在这个工作区正在聊的那个会话。
|
|
@@ -41,7 +41,7 @@ dsh plugin add dsh-gufa-code
|
|
|
41
41
|
- Monaco 编辑器(离线随包分发,无需联网下载);Monaco 自带 81 种语言全部映射(ABAP、Apex、Clojure、Elixir、F#、GraphQL、HCL/Terraform、Julia、Objective-C、Pascal、Perl、Protobuf、R、RST、Scheme、Solidity、SystemVerilog/Verilog、Tcl、TypeSpec、VB、WGSL、Bicep、Batch、CoffeeScript、Cypher、DAX、Logstash/ECL、MIPS、Power Query、Q#、Redis、SPARQL、Structured Text、Modula-3、ATS、Pony 系列等);
|
|
42
42
|
- **HTML 模板语法高亮**:EJS / Eta、ERB、Nunjucks / Jinja2(`.njk/.nunjucks/.jinja/.jinja2/.j2`)、Blade(`.blade.php`)、Haml、Slim,以及 Monaco 内置的 Handlebars / Mustache / Pug / Twig / Liquid / Razor / FreeMarker;扩展名自动识别;
|
|
43
43
|
- 多标签、按扩展名语法高亮、面包屑、状态栏(分支 / 行列 / 保存状态);
|
|
44
|
-
- **JS/TS 实时诊断**:
|
|
44
|
+
- **JS/TS 实时诊断**:JS 用项目自己的 **ESLint**(自动读取 `.eslintrc.*` / `eslint.config.js` / package.json 的 eslintConfig,`globals` 里声明的全局变量不会误报;没有配置时用内置默认规则 `no-undef`);TS 用 Host TypeScript 编译器兜底;Monaco 的自动缩进/括号引号自动闭合保持开启;
|
|
45
45
|
- **AI Tab 行内补全已移除**(结果质量不稳定且增加输入延迟);基础代码联想(Monaco 建议列表 / 当前文档单词)保持开启;
|
|
46
46
|
- **AI/外部修改自动刷新**:已打开的标签每 1.6s 检查一次磁盘 mtime/size,AI 在会话里改完代码后编辑器自动换成新内容(保留光标位置),不需要关闭重开;点击文件树里的已打开文件也会重新对齐磁盘;有未保存修改时不会覆盖用户内容;
|
|
47
47
|
- 保存走磁盘版本冲突检测 + 原子写;未保存标记;
|
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
|
|
@@ -1161,6 +1161,7 @@ G.errorText = (error) => {
|
|
|
1161
1161
|
G.CSS = `
|
|
1162
1162
|
.gufa-overlay-root{position:fixed;inset:0;z-index:1;display:flex;box-sizing:border-box;background:var(--gufa-solid-bg, var(--dsw-alias-bg-base));pointer-events:auto;overflow:hidden}
|
|
1163
1163
|
.gufa-backdrop{position:absolute;inset:0;z-index:0;overflow:hidden;pointer-events:none}
|
|
1164
|
+
|
|
1164
1165
|
/* 桌面悬浮层(摸鱼)模式:整窗半透明,透明度由 --gufa-float-alpha 控制(标题栏滑块) */
|
|
1165
1166
|
html[data-gufa-float]{--gufa-float-alpha:0.55}
|
|
1166
1167
|
html[data-gufa-float] body{background:transparent!important;color-scheme:dark;
|
|
@@ -1301,7 +1302,17 @@ html[data-gufa-float] #root [data-gufa-dock],
|
|
|
1301
1302
|
html[data-gufa-float] #root .gufa-overlay-root *,
|
|
1302
1303
|
html[data-gufa-float] #root [data-gufa-dock] *{visibility:visible!important}
|
|
1303
1304
|
/* 桌宠提到覆盖层之上:同时兼容 @linxin666/dsh-pet(data-dsh-pet-root)与官方 dsh-pet(.dsh-pet-root) */
|
|
1305
|
+
/* 古法覆盖层打开时,DSH 右侧栏被覆盖却仍参与 layout/paint;
|
|
1306
|
+
myrta 这类会话会给右侧栏渲染 7000+ 节点,导致编辑器滚动每帧 style/layout 50ms。 */
|
|
1307
|
+
html[data-gufa-ide] [class*="rightbarCol"],
|
|
1308
|
+
html[data-gufa-float] [class*="rightbarCol"]{display:none!important}
|
|
1309
|
+
|
|
1304
1310
|
html[data-gufa-ide] .dsh-pet-root{z-index:2147483050!important}
|
|
1311
|
+
/* 聊天栏收起时,把覆盖层下面的官方会话(可能几千个 DOM 节点)真正隐藏,
|
|
1312
|
+
避免编辑器滚动时整页 layout/paint 把它一起算进去。 */
|
|
1313
|
+
/* 古法/摸鱼模式下皮肤自身的粒子 canvas 不参与绘制(防止 WebGL/rAF 在覆盖层下面持续跑) */
|
|
1314
|
+
html[data-gufa-ide] .liang-ambient,
|
|
1315
|
+
html[data-gufa-float] .liang-ambient{display:none!important}
|
|
1305
1316
|
/* 外部弹窗(DSH 设置等)打开时:停靠会话、古法 portal、桌宠全部降到官方弹窗之下 */
|
|
1306
1317
|
html[data-gufa-external-modal] [data-gufa-dock]{z-index:2!important}
|
|
1307
1318
|
html[data-gufa-external-modal] #gufa-portal-root{z-index:1!important}
|
|
@@ -2758,6 +2769,9 @@ G.registerTemplateLanguages = function registerTemplateLanguages(monaco) {
|
|
|
2758
2769
|
'editorLink.activeForeground': gufaHex(accent),
|
|
2759
2770
|
'editorInfo.foreground': gufaHex(accent),
|
|
2760
2771
|
'editorOverviewRuler.border': '#00000000',
|
|
2772
|
+
'editorOverviewRuler.findMatchForeground': dark ? '#d7ba7d' : '#b58900',
|
|
2773
|
+
'editorOverviewRuler.errorForeground': '#f14c4c',
|
|
2774
|
+
'editorOverviewRuler.warningForeground': '#cca700',
|
|
2761
2775
|
'scrollbarSlider.background': gufaHexAlpha(fg, 0.16),
|
|
2762
2776
|
'scrollbarSlider.hoverBackground': gufaHexAlpha(fg, 0.26),
|
|
2763
2777
|
'scrollbarSlider.activeBackground': gufaHexAlpha(fg, 0.34),
|
|
@@ -3169,7 +3183,7 @@ function gufaRegisterDefinitionInfrastructure(monaco) {
|
|
|
3169
3183
|
}
|
|
3170
3184
|
|
|
3171
3185
|
/* 诊断波浪线已关闭(用户要求);Host lint 也不再在每次输入后跑 tsc,省 CPU */
|
|
3172
|
-
const GUFA_LINT_ENABLED =
|
|
3186
|
+
const GUFA_LINT_ENABLED = true
|
|
3173
3187
|
|
|
3174
3188
|
/* ── model / URI ────────────────────────────────────────────────────── */
|
|
3175
3189
|
|
|
@@ -3222,19 +3236,82 @@ const GUFA_LINT_ENABLED = false
|
|
|
3222
3236
|
return model
|
|
3223
3237
|
}
|
|
3224
3238
|
|
|
3239
|
+
/**
|
|
3240
|
+
* 查找框可见时才打开 overview ruler(查找匹配标记),关闭时收起。
|
|
3241
|
+
* 常开 ruler 会在每次滚动时额外渲染诊断/查找标记,体感卡。
|
|
3242
|
+
*/
|
|
3243
|
+
function gufaInstallFindRuler(instance) {
|
|
3244
|
+
try {
|
|
3245
|
+
const dom = typeof instance.getDomNode === 'function' ? instance.getDomNode() : null
|
|
3246
|
+
if (dom === null || dom === undefined) return null
|
|
3247
|
+
let frame = 0
|
|
3248
|
+
const apply = () => {
|
|
3249
|
+
frame = 0
|
|
3250
|
+
let visible = false
|
|
3251
|
+
try {
|
|
3252
|
+
const widget = dom.querySelector('.find-widget')
|
|
3253
|
+
visible = widget !== null && widget !== undefined && widget.classList.contains('visible')
|
|
3254
|
+
} catch {
|
|
3255
|
+
visible = false
|
|
3256
|
+
}
|
|
3257
|
+
try {
|
|
3258
|
+
instance.updateOptions({ renderOverviewRuler: visible, overviewRulerLanes: visible ? 1 : 0 })
|
|
3259
|
+
} catch {
|
|
3260
|
+
/* ignore */
|
|
3261
|
+
}
|
|
3262
|
+
}
|
|
3263
|
+
const schedule = () => {
|
|
3264
|
+
if (frame !== 0) return
|
|
3265
|
+
frame = typeof requestAnimationFrame === 'function' ? requestAnimationFrame(apply) : window.setTimeout(apply, 16)
|
|
3266
|
+
}
|
|
3267
|
+
const observer = typeof MutationObserver === 'function' ? new MutationObserver((records) => {
|
|
3268
|
+
for (const record of records) {
|
|
3269
|
+
if (record.type === 'attributes' && record.target instanceof Element && record.target.classList.contains('find-widget')) {
|
|
3270
|
+
schedule()
|
|
3271
|
+
return
|
|
3272
|
+
}
|
|
3273
|
+
if (record.type === 'childList') {
|
|
3274
|
+
for (const node of record.addedNodes) {
|
|
3275
|
+
if (node instanceof Element && (node.classList.contains('find-widget') || node.querySelector('.find-widget') !== null)) {
|
|
3276
|
+
schedule()
|
|
3277
|
+
return
|
|
3278
|
+
}
|
|
3279
|
+
}
|
|
3280
|
+
}
|
|
3281
|
+
}
|
|
3282
|
+
}) : null
|
|
3283
|
+
observer?.observe(dom, { subtree: true, attributes: true, attributeFilter: ['class'], childList: true })
|
|
3284
|
+
return () => {
|
|
3285
|
+
try { observer?.disconnect() } catch { /* ignore */ }
|
|
3286
|
+
if (frame !== 0) {
|
|
3287
|
+
try {
|
|
3288
|
+
if (typeof cancelAnimationFrame === 'function') cancelAnimationFrame(frame)
|
|
3289
|
+
else window.clearTimeout(frame)
|
|
3290
|
+
} catch { /* ignore */ }
|
|
3291
|
+
frame = 0
|
|
3292
|
+
}
|
|
3293
|
+
}
|
|
3294
|
+
} catch {
|
|
3295
|
+
return null
|
|
3296
|
+
}
|
|
3297
|
+
}
|
|
3298
|
+
|
|
3225
3299
|
/** Monaco 编辑器选项:关闭 minimap / overview ruler,automaticLayout 跟随容器尺寸。 */
|
|
3226
3300
|
function gufaEditorOptions(theme) {
|
|
3227
3301
|
return {
|
|
3228
3302
|
theme: gufaMonacoTheme(theme),
|
|
3229
3303
|
automaticLayout: true,
|
|
3230
3304
|
minimap: { enabled: false },
|
|
3231
|
-
|
|
3232
|
-
|
|
3305
|
+
/* 右侧 ruler 常开:查找匹配/诊断标记显示在滚动条旁 */
|
|
3306
|
+
renderOverviewRuler: true,
|
|
3307
|
+
overviewRulerLanes: 1,
|
|
3233
3308
|
overviewRulerBorder: false,
|
|
3234
3309
|
hideCursorInOverviewRuler: true,
|
|
3235
3310
|
scrollBeyondLastLine: false,
|
|
3236
3311
|
smoothScrolling: true,
|
|
3237
3312
|
cursorBlinking: 'smooth',
|
|
3313
|
+
/* 滚动相关的额外渲染关掉:sticky scroll / 常驻 overview ruler 已单独处理 */
|
|
3314
|
+
stickyScroll: { enabled: false },
|
|
3238
3315
|
fontSize: 13,
|
|
3239
3316
|
lineHeight: 20,
|
|
3240
3317
|
fontFamily: 'ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace',
|
|
@@ -3510,27 +3587,13 @@ const GUFA_LINT_ENABLED = false
|
|
|
3510
3587
|
} catch {
|
|
3511
3588
|
/* ignore */
|
|
3512
3589
|
}
|
|
3513
|
-
/*
|
|
3514
|
-
|
|
3515
|
-
这里显式打开并开 checkJs,否则 .js 里只有语法错误、没有未定义变量等诊断。 */
|
|
3590
|
+
/* 诊断统一由 Host 提供:JS 用项目 ESLint(尊重 .eslintrc/globals/rules),
|
|
3591
|
+
TS 回落 Host tsc;关掉 Monaco worker 诊断,避免同一个错误画两条线/问题计数翻倍。 */
|
|
3516
3592
|
try {
|
|
3517
3593
|
const typescriptLanguages = monaco.languages.typescript
|
|
3518
|
-
|
|
3519
|
-
|
|
3520
|
-
|
|
3521
|
-
typescriptLanguages.javascriptDefaults?.setDiagnosticsOptions(diagnosticsOn)
|
|
3522
|
-
typescriptLanguages.javascriptDefaults?.setCompilerOptions({
|
|
3523
|
-
allowNonTsExtensions: true,
|
|
3524
|
-
allowJs: true,
|
|
3525
|
-
checkJs: true,
|
|
3526
|
-
target: 99,
|
|
3527
|
-
moduleResolution: 2,
|
|
3528
|
-
module: 99,
|
|
3529
|
-
jsx: 1,
|
|
3530
|
-
esModuleInterop: true,
|
|
3531
|
-
allowSyntheticDefaultImports: true,
|
|
3532
|
-
})
|
|
3533
|
-
}
|
|
3594
|
+
const diagnosticsOff = { noSemanticValidation: true, noSyntaxValidation: true }
|
|
3595
|
+
typescriptLanguages?.typescriptDefaults?.setDiagnosticsOptions(diagnosticsOff)
|
|
3596
|
+
typescriptLanguages?.javascriptDefaults?.setDiagnosticsOptions(diagnosticsOff)
|
|
3534
3597
|
} catch (error) {
|
|
3535
3598
|
/* ignore */
|
|
3536
3599
|
}
|
|
@@ -4456,7 +4519,10 @@ const GUFA_LINT_ENABLED = false
|
|
|
4456
4519
|
minimap: { enabled: false },
|
|
4457
4520
|
scrollBeyondLastLine: false,
|
|
4458
4521
|
lineNumbers: 'on',
|
|
4459
|
-
|
|
4522
|
+
/* diff 编辑器也显示右侧 overview ruler:新增/删除改动在滚动条旁有红绿标记 */
|
|
4523
|
+
renderOverviewRuler: true,
|
|
4524
|
+
overviewRulerLanes: 1,
|
|
4525
|
+
overviewRulerBorder: false,
|
|
4460
4526
|
fontFamily: 'ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace',
|
|
4461
4527
|
fontSize: 12.5,
|
|
4462
4528
|
lineHeight: 1.15,
|
|
@@ -9955,6 +10021,57 @@ G.BackdropParticles = function BackdropParticles(props) {
|
|
|
9955
10021
|
return h('canvas', { ref: canvasRef, className: 'gufa-backdrop-particles', 'aria-hidden': 'true', style: { mixBlendMode: 'screen' } })
|
|
9956
10022
|
}
|
|
9957
10023
|
|
|
10024
|
+
/** 进入古法 IDE 时临时关掉皮肤自身的粒子/动效(它们会在覆盖层下面持续跑 WebGL/rAF);
|
|
10025
|
+
* 退出时恢复用户原设置,不改变用户偏好。 */
|
|
10026
|
+
let gufaSkinEffectsSaved = null
|
|
10027
|
+
G.suspendSkinEffects = function suspendSkinEffects() {
|
|
10028
|
+
try {
|
|
10029
|
+
if (gufaSkinEffectsSaved !== null) return
|
|
10030
|
+
const raw = localStorage.getItem(SKIN_SETTINGS_KEY)
|
|
10031
|
+
if (raw === null || raw === '') return
|
|
10032
|
+
const record = JSON.parse(raw)
|
|
10033
|
+
if (record === null || typeof record !== 'object' || record.values === null || typeof record.values !== 'object') return
|
|
10034
|
+
const values = record.values
|
|
10035
|
+
if (values.particlesEnabled !== true && values.motionEnabled !== true) return
|
|
10036
|
+
gufaSkinEffectsSaved = raw
|
|
10037
|
+
const next = { ...record, values: { ...values, particlesEnabled: false, motionEnabled: false } }
|
|
10038
|
+
const payload = JSON.stringify(next)
|
|
10039
|
+
localStorage.setItem(SKIN_SETTINGS_KEY, payload)
|
|
10040
|
+
try {
|
|
10041
|
+
window.dispatchEvent(new StorageEvent('storage', {
|
|
10042
|
+
key: SKIN_SETTINGS_KEY,
|
|
10043
|
+
oldValue: raw,
|
|
10044
|
+
newValue: payload,
|
|
10045
|
+
storageArea: localStorage,
|
|
10046
|
+
}))
|
|
10047
|
+
} catch {
|
|
10048
|
+
/* ignore */
|
|
10049
|
+
}
|
|
10050
|
+
} catch {
|
|
10051
|
+
gufaSkinEffectsSaved = null
|
|
10052
|
+
}
|
|
10053
|
+
}
|
|
10054
|
+
G.resumeSkinEffects = function resumeSkinEffects() {
|
|
10055
|
+
try {
|
|
10056
|
+
if (gufaSkinEffectsSaved === null) return
|
|
10057
|
+
const raw = gufaSkinEffectsSaved
|
|
10058
|
+
gufaSkinEffectsSaved = null
|
|
10059
|
+
localStorage.setItem(SKIN_SETTINGS_KEY, raw)
|
|
10060
|
+
try {
|
|
10061
|
+
window.dispatchEvent(new StorageEvent('storage', {
|
|
10062
|
+
key: SKIN_SETTINGS_KEY,
|
|
10063
|
+
oldValue: null,
|
|
10064
|
+
newValue: raw,
|
|
10065
|
+
storageArea: localStorage,
|
|
10066
|
+
}))
|
|
10067
|
+
} catch {
|
|
10068
|
+
/* ignore */
|
|
10069
|
+
}
|
|
10070
|
+
} catch {
|
|
10071
|
+
/* ignore */
|
|
10072
|
+
}
|
|
10073
|
+
}
|
|
10074
|
+
|
|
9958
10075
|
/** 背景浓度滑杆(无级、连续;双击恢复「跟随皮肤」)。 */
|
|
9959
10076
|
G.BackdropStrengthSlider = function BackdropStrengthSlider(props) {
|
|
9960
10077
|
const t = G.useT()
|
|
@@ -10804,6 +10921,8 @@ function gufaRestoreDockTarget(node, saved) {
|
|
|
10804
10921
|
}
|
|
10805
10922
|
}
|
|
10806
10923
|
|
|
10924
|
+
G.findConversationRoot = gufaFindConversationRoot
|
|
10925
|
+
|
|
10807
10926
|
/**
|
|
10808
10927
|
* 把会话根浮到停靠区的位置与尺寸;返回是否成功。
|
|
10809
10928
|
*
|
|
@@ -10815,6 +10934,7 @@ function gufaRestoreDockTarget(node, saved) {
|
|
|
10815
10934
|
* 用「测实际位置 → 补偿差值」迭代 2 次把会话对齐到停靠区。
|
|
10816
10935
|
*/
|
|
10817
10936
|
function gufaPlaceDockedConversation(root, host, options) {
|
|
10937
|
+
try { root.removeAttribute('data-gufa-hide') } catch { /* ignore */ }
|
|
10818
10938
|
const rect = host.getBoundingClientRect()
|
|
10819
10939
|
if (!(rect.width >= 80 && rect.height >= 80)) return false
|
|
10820
10940
|
const target = { left: Math.round(rect.left), top: Math.round(rect.top), width: Math.round(rect.width), height: Math.round(rect.height) }
|
|
@@ -10840,10 +10960,20 @@ function gufaPlaceDockedConversation(root, host, options) {
|
|
|
10840
10960
|
let floatMode = false
|
|
10841
10961
|
try { floatMode = document.documentElement.hasAttribute('data-gufa-float') } catch { floatMode = false }
|
|
10842
10962
|
if (floatMode) root.style.background = dockBackground === '' ? 'rgba(13, 15, 19, 0.55)' : `color-mix(in srgb, ${dockBackground} 45%, transparent)`
|
|
10843
|
-
else if (backdropMode
|
|
10963
|
+
else if (backdropMode) {
|
|
10964
|
+
/* 背景模式下必须半透明:解析不到实色时也用 color-mix + 变量兜底,
|
|
10965
|
+
不能掉进不透明实色分支(之前右侧对话背景变实色就是这个原因)。 */
|
|
10966
|
+
root.style.background = dockBackground === ''
|
|
10967
|
+
? 'color-mix(in srgb, var(--gufa-solid-bg, #1a1b1f) 34%, transparent)'
|
|
10968
|
+
: `color-mix(in srgb, ${dockBackground} 34%, transparent)`
|
|
10969
|
+
}
|
|
10844
10970
|
else root.style.background = dockBackground === '' ? 'var(--gufa-solid-bg, #1a1b1f)' : dockBackground
|
|
10845
10971
|
root.style.borderLeft = '1px solid var(--dsw-alias-border-l1)'
|
|
10846
10972
|
root.style.boxSizing = 'border-box'
|
|
10973
|
+
/* 注意:不要给会话根加 will-change/contain——实测会增加每次滚动时的样式/布局成本 */
|
|
10974
|
+
try {
|
|
10975
|
+
root.style.contain = 'layout paint'
|
|
10976
|
+
} catch { /* ignore */ }
|
|
10847
10977
|
root.style.setProperty('--dsh-chat-user-width', 'calc(100% - 24px)')
|
|
10848
10978
|
root.style.setProperty('--dsh-conversation-column-width', `${target.width}px`)
|
|
10849
10979
|
root.setAttribute('data-gufa-dock', '1')
|
|
@@ -11168,6 +11298,68 @@ G.__dock = {
|
|
|
11168
11298
|
restore: gufaRestoreDockTarget,
|
|
11169
11299
|
}
|
|
11170
11300
|
|
|
11301
|
+
/** 从 DSH 会话里的文件引用按钮提取路径/行号,然后在古法编辑器里打开。 */
|
|
11302
|
+
function gufaParseMentionButton(button) {
|
|
11303
|
+
if (button === null || button === undefined || typeof button.closest !== 'function') return null
|
|
11304
|
+
const className = typeof button.className === 'string' ? button.className : ''
|
|
11305
|
+
const dataRef = typeof button.getAttribute === 'function' ? (button.getAttribute('data-ref-chip') ?? '') : ''
|
|
11306
|
+
const isMention = className.includes('fileMention') || className.includes('fileLink') || dataRef !== ''
|
|
11307
|
+
if (!isMention) return null
|
|
11308
|
+
const title = typeof button.getAttribute === 'function' ? (button.getAttribute('title') ?? '').trim() : ''
|
|
11309
|
+
const text = String(button.textContent ?? '').replace(/\s+/g, ' ').trim()
|
|
11310
|
+
const parseRef = (value) => {
|
|
11311
|
+
const source = String(value ?? '').trim()
|
|
11312
|
+
if (source === '') return null
|
|
11313
|
+
const match = /^(.*?)(?::(\d+)(?:\s*[-,]\s*\d+)*|#L(\d+)(?:-L?\d+)?)$/.exec(source)
|
|
11314
|
+
if (match === null) return { path: source, line: 0 }
|
|
11315
|
+
return { path: match[1].trim(), line: Number(match[2] ?? match[3]) || 0 }
|
|
11316
|
+
}
|
|
11317
|
+
const titleLooksPath = /[\\/]/.test(title) || /\.[A-Za-z0-9]{1,8}$/.test(title)
|
|
11318
|
+
const fromTitle = titleLooksPath ? parseRef(title) : null
|
|
11319
|
+
const fromText = parseRef(text)
|
|
11320
|
+
/* 关键:title 通常只有完整路径(无行号),行号在按钮文本 `xxx.js:165` 里;
|
|
11321
|
+
两者要合并,不能 title 命中就忽略文本的行号。 */
|
|
11322
|
+
let path = fromTitle !== null && fromTitle.path !== '' ? fromTitle.path : (fromText !== null ? fromText.path : '')
|
|
11323
|
+
let line = (fromTitle !== null ? fromTitle.line : 0) || (fromText !== null ? fromText.line : 0)
|
|
11324
|
+
if (path === '') return null
|
|
11325
|
+
if (dataRef !== '') {
|
|
11326
|
+
let dataPath = ''
|
|
11327
|
+
let dataLine = 0
|
|
11328
|
+
if (dataRef.trim().startsWith('{')) {
|
|
11329
|
+
try {
|
|
11330
|
+
const parsedData = JSON.parse(dataRef)
|
|
11331
|
+
dataPath = typeof parsedData?.path === 'string' ? parsedData.path : ''
|
|
11332
|
+
dataLine = Number(parsedData?.line) || 0
|
|
11333
|
+
} catch {
|
|
11334
|
+
/* ignore */
|
|
11335
|
+
}
|
|
11336
|
+
}
|
|
11337
|
+
if (dataPath !== '') {
|
|
11338
|
+
path = dataPath
|
|
11339
|
+
if (dataLine > 0) line = dataLine
|
|
11340
|
+
}
|
|
11341
|
+
}
|
|
11342
|
+
return { path: path.replace(/^\.\//, ''), line }
|
|
11343
|
+
}
|
|
11344
|
+
|
|
11345
|
+
async function gufaOpenMention(mention) {
|
|
11346
|
+
if (mention === null || mention === undefined || typeof mention.path !== 'string' || mention.path === '') return
|
|
11347
|
+
const root = typeof G.projectRoot === 'string' ? G.projectRoot.replace(/\\/g, '/').replace(/\/+$/, '') : ''
|
|
11348
|
+
if (root === '') return
|
|
11349
|
+
let resolved = null
|
|
11350
|
+
try {
|
|
11351
|
+
resolved = await G.api('code.resolvePath', { root, path: mention.path })
|
|
11352
|
+
} catch {
|
|
11353
|
+
return
|
|
11354
|
+
}
|
|
11355
|
+
if (resolved === null || resolved === undefined || typeof resolved.path !== 'string' || resolved.path === '') return
|
|
11356
|
+
try {
|
|
11357
|
+
G.bus.emit('editor:open-at', { path: resolved.path, line: Math.max(1, Number(mention.line) || 1), column: 1 })
|
|
11358
|
+
} catch {
|
|
11359
|
+
/* ignore */
|
|
11360
|
+
}
|
|
11361
|
+
}
|
|
11362
|
+
|
|
11171
11363
|
/**
|
|
11172
11364
|
* 停靠栏:官方会话本体(浮动) + 顶部工具条(新建会话 / 打开完整对话 / 收起)。
|
|
11173
11365
|
* props = { project, activeFile, selection, theme, width, onInsertCode, backdrop, active, sessionTitle, sessions, onOpenSession }
|
|
@@ -11181,11 +11373,56 @@ G.ChatDock = function ChatDock(props) {
|
|
|
11181
11373
|
if (followRef.current === null) followRef.current = gufaCreateChatFollowKeeper()
|
|
11182
11374
|
const tickRef = useRef(null)
|
|
11183
11375
|
const startedRef = useRef(0)
|
|
11376
|
+
const mentionRootRef = useRef(null)
|
|
11377
|
+
const mentionHandlerRef = useRef(null)
|
|
11378
|
+
const detachMentionRef = useRef(null)
|
|
11184
11379
|
const [phase, setPhase] = useState('searching')
|
|
11185
11380
|
const [error, setError] = useState('')
|
|
11186
11381
|
const active = props.active !== false && props.paused !== true
|
|
11187
11382
|
|
|
11383
|
+
const detachMention = useCallback(() => {
|
|
11384
|
+
const root = mentionRootRef.current
|
|
11385
|
+
const handler = mentionHandlerRef.current
|
|
11386
|
+
if (root !== null && handler !== null) {
|
|
11387
|
+
try { root.removeEventListener('click', handler, true) } catch { /* ignore */ }
|
|
11388
|
+
}
|
|
11389
|
+
mentionRootRef.current = null
|
|
11390
|
+
mentionHandlerRef.current = null
|
|
11391
|
+
}, [])
|
|
11392
|
+
detachMentionRef.current = detachMention
|
|
11393
|
+
|
|
11394
|
+
const ensureMentionHandler = useCallback((root) => {
|
|
11395
|
+
if (root === null) {
|
|
11396
|
+
detachMention()
|
|
11397
|
+
return
|
|
11398
|
+
}
|
|
11399
|
+
if (mentionRootRef.current === root && mentionHandlerRef.current !== null) return
|
|
11400
|
+
detachMention()
|
|
11401
|
+
const handler = (event) => {
|
|
11402
|
+
try {
|
|
11403
|
+
if (event.button !== 0 || event.defaultPrevented === true) return
|
|
11404
|
+
const target = event.target instanceof Element ? event.target.closest('button, [data-ref-chip]') : null
|
|
11405
|
+
if (target === null) return
|
|
11406
|
+
const mention = gufaParseMentionButton(target)
|
|
11407
|
+
if (mention === null) return
|
|
11408
|
+
event.preventDefault()
|
|
11409
|
+
event.stopPropagation()
|
|
11410
|
+
void gufaOpenMention(mention)
|
|
11411
|
+
} catch {
|
|
11412
|
+
/* ignore */
|
|
11413
|
+
}
|
|
11414
|
+
}
|
|
11415
|
+
try {
|
|
11416
|
+
root.addEventListener('click', handler, true)
|
|
11417
|
+
mentionRootRef.current = root
|
|
11418
|
+
mentionHandlerRef.current = handler
|
|
11419
|
+
} catch {
|
|
11420
|
+
/* ignore */
|
|
11421
|
+
}
|
|
11422
|
+
}, [detachMention])
|
|
11423
|
+
|
|
11188
11424
|
const undock = useCallback(() => {
|
|
11425
|
+
detachMentionRef.current?.()
|
|
11189
11426
|
const current = dockRef.current
|
|
11190
11427
|
if (current.root !== null) gufaRestoreDockTarget(current.root, current.saved)
|
|
11191
11428
|
dockRef.current = { root: null, saved: null }
|
|
@@ -11211,6 +11448,7 @@ G.ChatDock = function ChatDock(props) {
|
|
|
11211
11448
|
dockRef.current = { root, saved: gufaSnapshotDockTarget(root) }
|
|
11212
11449
|
}
|
|
11213
11450
|
if (gufaPlaceDockedConversation(root, host, { translucent: props.backdrop === true })) {
|
|
11451
|
+
ensureMentionHandler(root)
|
|
11214
11452
|
try {
|
|
11215
11453
|
const scroller = root.querySelector(GUFA_CONVERSATION_SCROLL_SELECTOR)
|
|
11216
11454
|
if (scroller !== null && scroller !== undefined) followRef.current?.attach(scroller)
|
|
@@ -11219,7 +11457,7 @@ G.ChatDock = function ChatDock(props) {
|
|
|
11219
11457
|
}
|
|
11220
11458
|
setPhase((previous) => (previous === 'docked' ? previous : 'docked'))
|
|
11221
11459
|
}
|
|
11222
|
-
}, [active, undock, props.backdrop])
|
|
11460
|
+
}, [active, undock, props.backdrop, ensureMentionHandler])
|
|
11223
11461
|
|
|
11224
11462
|
/* 拖拽分割条时的轻量重定位:只改宿主几何,不 getComputedStyle、不读自身 rect、不 setState。
|
|
11225
11463
|
完整 tick 每次都会 getComputedStyle + 最多两次 getBoundingClientRect,按帧跑会把拖拽拖卡。 */
|
|
@@ -11259,13 +11497,30 @@ G.ChatDock = function ChatDock(props) {
|
|
|
11259
11497
|
startedRef.current = Date.now()
|
|
11260
11498
|
setPhase((previous) => (previous === 'docked' ? previous : 'searching'))
|
|
11261
11499
|
let disposed = false
|
|
11500
|
+
/* dock 住之后彻底断开 body MutationObserver:Monaco 滚动会不断增删行 DOM,
|
|
11501
|
+
observer 即使不跑 tick,浏览器也要为整棵 body 维护/遍历 mutation record,依然拖慢滚动。
|
|
11502
|
+
发现/替换会话根交给 300ms 轮询(未 dock 时才观察)。 */
|
|
11503
|
+
let observer = typeof MutationObserver === 'function' ? new MutationObserver(() => { run() }) : null
|
|
11504
|
+
let observing = false
|
|
11505
|
+
const setObserving = (next) => {
|
|
11506
|
+
if (observer === null || observing === next) return
|
|
11507
|
+
observing = next
|
|
11508
|
+
try {
|
|
11509
|
+
if (next) observer.observe(document.body, { childList: true, subtree: true })
|
|
11510
|
+
else observer.disconnect()
|
|
11511
|
+
} catch {
|
|
11512
|
+
/* ignore */
|
|
11513
|
+
}
|
|
11514
|
+
}
|
|
11262
11515
|
const run = () => {
|
|
11263
|
-
if (
|
|
11516
|
+
if (disposed) return
|
|
11517
|
+
tickRef.current?.()
|
|
11518
|
+
const current = dockRef.current.root
|
|
11519
|
+
setObserving(!(current !== null && current.isConnected === true))
|
|
11264
11520
|
}
|
|
11521
|
+
setObserving(true)
|
|
11265
11522
|
run()
|
|
11266
|
-
const timer = window.setInterval(run,
|
|
11267
|
-
const observer = typeof MutationObserver === 'function' ? new MutationObserver(run) : null
|
|
11268
|
-
if (observer !== null) observer.observe(document.body, { childList: true, subtree: true })
|
|
11523
|
+
const timer = window.setInterval(run, 300)
|
|
11269
11524
|
let resizeObserver = null
|
|
11270
11525
|
if (typeof ResizeObserver === 'function') {
|
|
11271
11526
|
resizeObserver = new ResizeObserver(run)
|
|
@@ -11859,7 +12114,72 @@ G.installShortcutIntegration = function installShortcutIntegration(service) {
|
|
|
11859
12114
|
delete registry.__gufaOriginalDispatch
|
|
11860
12115
|
}
|
|
11861
12116
|
|
|
11862
|
-
// 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 动作)
|
|
11863
12183
|
const commandActions = {
|
|
11864
12184
|
'session.search': 'clearTerminal',
|
|
11865
12185
|
'sidebar.left.toggle': 'toggleSidebar',
|
|
@@ -11885,7 +12205,10 @@ G.installShortcutIntegration = function installShortcutIntegration(service) {
|
|
|
11885
12205
|
const commands = registry.commands
|
|
11886
12206
|
const makeResolve = (id, originalResolve) => function gufaIdeResolve(context) {
|
|
11887
12207
|
try {
|
|
11888
|
-
|
|
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) {
|
|
11889
12212
|
const actions = service.__gufaCommandActions
|
|
11890
12213
|
const mapped = actions === null || actions === undefined ? undefined : actions[id]
|
|
11891
12214
|
if (typeof mapped === 'string') {
|
|
@@ -11929,6 +12252,8 @@ G.installShortcutIntegration = function installShortcutIntegration(service) {
|
|
|
11929
12252
|
} catch {
|
|
11930
12253
|
/* ignore */
|
|
11931
12254
|
}
|
|
12255
|
+
if (Array.isArray(service.__gufaPatchedCommands) !== true) service.__gufaPatchedCommands = []
|
|
12256
|
+
service.__gufaPatchedCommands.push({ command, originalResolve })
|
|
11932
12257
|
wrapped.push(id)
|
|
11933
12258
|
}
|
|
11934
12259
|
}
|
|
@@ -12175,11 +12500,23 @@ G.useIdeShortcuts = function useIdeShortcuts(handlers) {
|
|
|
12175
12500
|
} catch {
|
|
12176
12501
|
/* ignore */
|
|
12177
12502
|
}
|
|
12178
|
-
if (typeof G.installShortcutBridge === 'function') G.installShortcutBridge()
|
|
12179
12503
|
return () => {
|
|
12180
12504
|
if (gufaShortcutHandlers === handlers) gufaShortcutHandlers = null
|
|
12181
12505
|
}
|
|
12182
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
|
+
}, [])
|
|
12183
12520
|
}
|
|
12184
12521
|
|
|
12185
12522
|
|
|
@@ -12401,7 +12738,8 @@ G.useSplitter = function useSplitter(options) {
|
|
|
12401
12738
|
return [size, onMouseDown, setSize]
|
|
12402
12739
|
}
|
|
12403
12740
|
|
|
12404
|
-
|
|
12741
|
+
|
|
12742
|
+
|
|
12405
12743
|
G.GufaApp = function GufaApp(props) {
|
|
12406
12744
|
const t = G.useT()
|
|
12407
12745
|
const theme = G.useTheme()
|
|
@@ -16414,11 +16752,6 @@ const GUFA_PLUGIN = {
|
|
|
16414
16752
|
} catch (error) {
|
|
16415
16753
|
console.error('[gufa-code] 安装原生快捷键集成失败', error)
|
|
16416
16754
|
}
|
|
16417
|
-
try {
|
|
16418
|
-
if (typeof G.installShortcutBridge === 'function') G.installShortcutBridge()
|
|
16419
|
-
} catch (error) {
|
|
16420
|
-
console.error('[gufa-code] 安装快捷键桥失败', error)
|
|
16421
|
-
}
|
|
16422
16755
|
})
|
|
16423
16756
|
}
|
|
16424
16757
|
} catch (error) {
|
|
@@ -16566,6 +16899,17 @@ try {
|
|
|
16566
16899
|
/* 忽略只读 window */
|
|
16567
16900
|
}
|
|
16568
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
|
+
|
|
16569
16913
|
return GUFA_PLUGIN
|
|
16570
16914
|
|
|
16571
16915
|
},
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -7,8 +7,8 @@
|
|
|
7
7
|
<key>CFBundleDisplayName</key><string>古法编程悬浮层</string>
|
|
8
8
|
<key>CFBundleExecutable</key><string>gufa-float</string>
|
|
9
9
|
<key>CFBundlePackageType</key><string>APPL</string>
|
|
10
|
-
<key>CFBundleShortVersionString</key><string>1.3.
|
|
11
|
-
<key>CFBundleVersion</key><string>1.3.
|
|
10
|
+
<key>CFBundleShortVersionString</key><string>1.3.173</string>
|
|
11
|
+
<key>CFBundleVersion</key><string>1.3.173</string>
|
|
12
12
|
<key>LSUIElement</key><true/>
|
|
13
13
|
<key>NSHighResolutionCapable</key><true/>
|
|
14
14
|
<key>NSPrincipalClass</key><string>NSApplication</string>
|