dsh-gufa-code 1.3.100 → 1.3.101

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
@@ -44,7 +44,7 @@ dsh plugin add dsh-gufa-code
44
44
  - **Copilot 风格 Tab 行内补全**:光标停/打字后,基于 Harness 自己的 DeepSeek 模型(默认 `deepseek-flash`,不需要额外 Copilot 订阅)流式生成灰色 ghost text,Tab 接受、Esc 忽略;支持 JS/TS/Python/Java/Go/Rust/C++/C#/JSON/YAML/Shell 等常见语言;
45
45
  - 保存走磁盘版本冲突检测 + 原子写;未保存标记;
46
46
  - **⌘/Ctrl + 点击跳转定义 / 方法实现**:Python 走 **Pyright 语言服务(LSP)**,JS/TS 走 Monaco 内置 TypeScript 语言服务(点击前会按需把当前文件的 import 依赖加载进 Monaco,跨文件变量/函数由 TS 语言服务解析);其他语言暂用项目级定义搜索兜底;优先走 Monaco 语言服务;目标文件没在 Monaco 里打开、或语言没有内置语言服务时,自动用项目级定义搜索兜底(函数 / 类 / 方法 / const / type 等声明)。兜底会解析 import/require 直接定位来源文件,并跳过压缩产物/大文件;同一个文件里的声明、import 命中的定义、目录距离近的定义直接跳,只有多个真正同名的声明才弹「跳转到定义」列表,点同名属性/变量时不会拿远端无关的 const 来凑数;按住 ⌘/Ctrl 悬停时,可跳转的符号会显示下划线 + 手型光标;
47
- - **⌘⇧N 新开实例窗口**:用古法编程自带原生 helper 打开一个普通 Harness 窗口(同一 Web GUI、共享登录态),新窗口会**直接进入古法编程**并恢复当前项目/标签页/布局;当前窗口全屏时新窗口也直接全屏;macOS 已支持,Windows/Linux 待 helper 实现 full 模式;
47
+ - **⌘⇧N 新开实例窗口**:用古法编程自带原生 helper 打开一个普通 Harness 窗口(同一 Web GUI、共享登录态),新窗口**直接进入古法编程的空工作区**(提示新建或打开工作区,不继承当前项目/标签页),方便并行操作别的工作区;当前窗口全屏时新窗口也直接全屏;macOS 已支持,Windows/Linux 待 helper 实现 full 模式;
48
48
  - **全局搜索 / 替换**(左栏放大镜 / `⌘⇧F`):整个项目的文本搜索,支持区分大小写、正则、包含/排除文件(glob);结果按文件分组、高亮匹配,点击跳转行列;替换栏支持保留大小写(AB)、全部替换(需确认)、按文件替换(悬停文件头铅笔)、按单行匹配替换与忽略(悬停结果行);替换前会自动保存未落盘的编辑器内容;Git 项目用 `git ls-files` 枚举文件(尊重 `.gitignore`、含未跟踪文件),非 Git 项目遍历目录并自动跳过 `node_modules` 等依赖/缓存目录;摸鱼悬浮窗里同样可用;
49
49
  - 资源管理器文件/文件夹可直接**拖进右侧输入框**变成 @引用;
50
50
  - 资源管理器右键:新建 / 重命名 / 删除 / 复制 / 粘贴 / 打开所在文件夹 / 两文件对比;
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.100'
19
+ G.BUILD = '1.3.101'
20
20
  G.PANEL_ID = 'gufa-code'
21
21
  /** 从哪个工作区点进来的(工作区菜单/节点按钮写入,App 启动时消费)。 */
22
22
  G.pendingEntryWorkspace = null
@@ -12195,6 +12195,8 @@ G.GufaApp = function GufaApp(props) {
12195
12195
  }
12196
12196
  }
12197
12197
  if (G.isFloatMode()) return
12198
+ /* 实例窗口不继承当前项目,等用户自己新建/打开工作区 */
12199
+ if (G.instanceBoot === true) return
12198
12200
  if (typeof sessionCwd === 'string' && sessionCwd !== '') {
12199
12201
  try {
12200
12202
  const value = await G.api('project.open', { path: sessionCwd })
@@ -13959,13 +13961,7 @@ G.GufaApp = function GufaApp(props) {
13959
13961
  } catch {
13960
13962
  fullscreen = false
13961
13963
  }
13962
- let state
13963
- try {
13964
- state = buildFloatSnapshot()
13965
- } catch {
13966
- state = undefined
13967
- }
13968
- void G.api('app.newWindow', { state, fullscreen }).catch((error) => {
13964
+ void G.api('app.newWindow', { fullscreen }).catch((error) => {
13969
13965
  let opened = null
13970
13966
  try { opened = window.open(location.href, '_blank') } catch { opened = null }
13971
13967
  if (opened !== null && opened !== undefined) {
@@ -14007,7 +14003,7 @@ G.GufaApp = function GufaApp(props) {
14007
14003
  }
14008
14004
  setShortcutsOpen((open) => open === false)
14009
14005
  },
14010
- }), [activePath, tabs, ui.terminalOpen, ui.sidebarOpen, saveFile, saveCompareTab, patchUi, closeTabWithConfirm, buildFloatSnapshot])
14006
+ }), [activePath, tabs, ui.terminalOpen, ui.sidebarOpen, saveFile, saveCompareTab, patchUi, closeTabWithConfirm])
14011
14007
  G.useIdeShortcuts(ideShortcutHandlers)
14012
14008
 
14013
14009
  /* 原生快捷键服务派发到当前 App 的动作表(IDE 模式内有效)。 */
@@ -15597,6 +15593,7 @@ const GUFA_PLUGIN = {
15597
15593
  try {
15598
15594
  const instanceMode = /[?&]gufa-instance=1/.test(String(location.search || ''))
15599
15595
  if (instanceMode && document.documentElement.hasAttribute('data-gufa-float') !== true) {
15596
+ G.instanceBoot = true
15600
15597
  document.documentElement.setAttribute('data-gufa-booting', '1')
15601
15598
  let attempts = 0
15602
15599
  let timer = 0
@@ -441,32 +441,11 @@ static NSURL *GufaInstanceURL(NSString *appUrl) {
441
441
  }
442
442
  }
443
443
  if (self.fullMode) {
444
- /* 实例窗口:只注入主窗口的编辑器状态(项目/标签页/UI),让新窗口直接进古法编程并恢复现场。 */
445
- NSDictionary *fullState = [self.options[@"state"] isKindOfClass:[NSDictionary class]] ? self.options[@"state"] : nil;
444
+ /* 实例窗口:不继承主窗口项目/标签页,保持干净的新工作区;
445
+ WKWebView data store 共享,先清掉上次摸鱼/实例残留的状态。 */
446
446
  NSMutableString *js = [NSMutableString stringWithString:@"try{"];
447
- /* 同一个 WKWebView data store 可能还留着上次摸鱼的标记,实例窗口必须先清掉 */
448
- [js appendString:@"localStorage.removeItem('gufa-code:float');"];
449
- if (fullState != nil) {
450
- NSString *projectRoot = [fullState[@"projectRoot"] isKindOfClass:[NSString class]] ? fullState[@"projectRoot"] : @"";
451
- if (projectRoot.length > 0) {
452
- /* 客户端用 JSON.parse 读 project,本地存的是 JSON 字符串(带引号),这里用 JSON.stringify 生成 */
453
- [js appendFormat:@"localStorage.setItem('gufa-code:project', JSON.stringify(%@));", GufaJSONLiteralString(projectRoot)];
454
- }
455
- NSString *stateText = GufaJSONLiteralString(fullState);
456
- if (stateText.length > 0) {
457
- NSString *escapedState = [stateText stringByReplacingOccurrencesOfString:@"\\" withString:@"\\\\"];
458
- escapedState = [escapedState stringByReplacingOccurrencesOfString:@"'" withString:@"\\'"];
459
- escapedState = [escapedState stringByReplacingOccurrencesOfString:@"\n" withString:@"\\n"];
460
- escapedState = [escapedState stringByReplacingOccurrencesOfString:@"\r" withString:@""];
461
- [js appendFormat:@"localStorage.setItem('gufa-code:float-state','%@');", escapedState];
462
- }
463
- NSDictionary *fullUi = [fullState[@"ui"] isKindOfClass:[NSDictionary class]] ? fullState[@"ui"] : nil;
464
- if (fullUi != nil) {
465
- NSString *uiText = GufaJSONLiteralString(fullUi);
466
- NSString *escapedUi = [uiText stringByReplacingOccurrencesOfString:@"\\" withString:@"\\\\"];
467
- escapedUi = [escapedUi stringByReplacingOccurrencesOfString:@"'" withString:@"\\'"];
468
- [js appendFormat:@"localStorage.setItem('gufa-code:ui:v1','%@');", escapedUi];
469
- }
447
+ for (NSString *key in @[@"gufa-code:float", @"gufa-code:float-state", @"gufa-code:project", @"gufa-code:ui:v1", @"gufa-code:tabs:v1", @"gufa-code:mode:v1"]) {
448
+ [js appendFormat:@"localStorage.removeItem('%@');", key];
470
449
  }
471
450
  [js appendString:@"}catch(e){}"];
472
451
  WKUserScript *stateScript = [[WKUserScript alloc] initWithSource:js injectionTime:WKUserScriptInjectionTimeAtDocumentStart forMainFrameOnly:YES];
@@ -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.100</string>
11
- <key>CFBundleVersion</key><string>1.3.100</string>
10
+ <key>CFBundleShortVersionString</key><string>1.3.101</string>
11
+ <key>CFBundleVersion</key><string>1.3.101</string>
12
12
  <key>LSUIElement</key><true/>
13
13
  <key>NSHighResolutionCapable</key><true/>
14
14
  <key>NSPrincipalClass</key><string>NSApplication</string>
@@ -59,8 +59,8 @@
59
59
  - 实现:复用插件自带的原生 helper(`desktop/float/GufaFloat.m`),payload 传 `{full:true, authUrl, appUrl}` —— helper 建普通标题栏窗口、Regular 激活策略、跳过摸鱼 localStorage/隐藏主窗/吸附,加载同一个 DSH Web GUI;鉴权复用它已有的 `connection.authenticatedUrl()` token 流程。
60
60
  - 客户端 ⌘⇧N 必须先调 Host `app.newWindow`,失败才回退 `window.open`(Electron 的 setWindowOpenHandler 会 deny 并用外部浏览器打开 http(s),不是应用内窗口)。
61
61
  - 新窗口与 Electron 主窗口共享的是 **同一个 Host/服务端**,但 UI 进程独立(WKWebView,不走 Electron preload);所以别让新窗口依赖 `window.dshDesktop` 之类的 Electron preload API。
62
- - **自动进入古法编程**:helper full 模式在 document-start 注入 `gufa-code:project` / `gufa-code:float-state` / `gufa-code:ui:v1`;URL 带 `?gufa-instance=1`,客户端 boot 时反复调 `G.enterGufa()` 直到 `.gufa-overlay-root` 挂载。注意 `gufa-code:project` 客户端用 `JSON.parse` 读,注入时必须写 **JSON 字符串**(`JSON.stringify(...)` 生成带引号的值),直接写裸路径会读成 null。
63
- - helper 的 WKWebView data store 与摸鱼悬浮层共享;full 模式必须 `localStorage.removeItem('gufa-code:float')`,否则新窗口会误进摸鱼 UI。
62
+ - **实例窗口不继承主窗口项目**(用户明确要求新窗口用来操作别的工作区):helper full 模式只清空 localStorage 里的 `gufa-code:float/float-state/project/ui/tabs/mode`,URL 带 `?gufa-instance=1`;客户端 boot 时反复调 `G.enterGufa()` 直到 `.gufa-overlay-root` 挂载,并通过 `G.instanceBoot` 跳过 App 的 `sessionCwd` 自动打开项目分支,最终停在「尚打开项目 / 打开项目 / 新建项目」空状态。
63
+ - helper 的 WKWebView data store 与摸鱼悬浮层共享;full 模式必须清残留标记,否则新窗口会误进摸鱼 UI 或恢复上次项目。
64
64
  - **全屏继承**:客户端用 `innerWidth/innerHeight` 对比 `screen.width/height` 和 `screen.availWidth/availHeight` 判断当前是否全屏,payload 传 `fullscreen:true`,helper 在窗口显示后 `toggleFullScreen`;不要依赖 Electron preload 或 AX 查询(Host 在 Node 模式进程里拿不到 Electron)。
65
65
 
66
66
  ## 1. 弹窗/菜单层级:只有一个正确做法(反复踩过多次,最终定案)
@@ -47,12 +47,10 @@ export async function newWindow(body, env) {
47
47
  }
48
48
  const base = `${webServer.protocol}//127.0.0.1:${String(webServer.port)}`
49
49
  const authUrl = connection.authenticatedUrl(`${base}/`)
50
- const state = body !== null && typeof body === 'object' && body.state !== null && typeof body.state === 'object' ? body.state : undefined
51
50
  const fullscreen = body !== null && typeof body === 'object' && body.fullscreen === true
52
51
  const payload = JSON.stringify({
53
52
  full: true,
54
53
  fullscreen,
55
- state,
56
54
  authUrl,
57
55
  appUrl: `${base}/`,
58
56
  title: 'DeepSeek Harness',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-gufa-code",
3
- "version": "1.3.100",
3
+ "version": "1.3.101",
4
4
  "description": "古法编程 · AI 辅助:一键把 DSH 主面板变成 VS Code 风格 IDE(Monaco 编辑器、文件树、Git、SSH、真实终端 + 右侧官方会话);主张亲手写、每个改动心中有数,AI 是助理、你是第一责任人",
5
5
  "icon": "icon.svg",
6
6
  "keywords": [
@@ -354,6 +354,8 @@ G.GufaApp = function GufaApp(props) {
354
354
  }
355
355
  }
356
356
  if (G.isFloatMode()) return
357
+ /* 实例窗口不继承当前项目,等用户自己新建/打开工作区 */
358
+ if (G.instanceBoot === true) return
357
359
  if (typeof sessionCwd === 'string' && sessionCwd !== '') {
358
360
  try {
359
361
  const value = await G.api('project.open', { path: sessionCwd })
@@ -2118,13 +2120,7 @@ G.GufaApp = function GufaApp(props) {
2118
2120
  } catch {
2119
2121
  fullscreen = false
2120
2122
  }
2121
- let state
2122
- try {
2123
- state = buildFloatSnapshot()
2124
- } catch {
2125
- state = undefined
2126
- }
2127
- void G.api('app.newWindow', { state, fullscreen }).catch((error) => {
2123
+ void G.api('app.newWindow', { fullscreen }).catch((error) => {
2128
2124
  let opened = null
2129
2125
  try { opened = window.open(location.href, '_blank') } catch { opened = null }
2130
2126
  if (opened !== null && opened !== undefined) {
@@ -2166,7 +2162,7 @@ G.GufaApp = function GufaApp(props) {
2166
2162
  }
2167
2163
  setShortcutsOpen((open) => open === false)
2168
2164
  },
2169
- }), [activePath, tabs, ui.terminalOpen, ui.sidebarOpen, saveFile, saveCompareTab, patchUi, closeTabWithConfirm, buildFloatSnapshot])
2165
+ }), [activePath, tabs, ui.terminalOpen, ui.sidebarOpen, saveFile, saveCompareTab, patchUi, closeTabWithConfirm])
2170
2166
  G.useIdeShortcuts(ideShortcutHandlers)
2171
2167
 
2172
2168
  /* 原生快捷键服务派发到当前 App 的动作表(IDE 模式内有效)。 */
@@ -435,6 +435,7 @@ const GUFA_PLUGIN = {
435
435
  try {
436
436
  const instanceMode = /[?&]gufa-instance=1/.test(String(location.search || ''))
437
437
  if (instanceMode && document.documentElement.hasAttribute('data-gufa-float') !== true) {
438
+ G.instanceBoot = true
438
439
  document.documentElement.setAttribute('data-gufa-booting', '1')
439
440
  let attempts = 0
440
441
  let timer = 0