Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ebd381a2b5 |
No files matched your search
@@ -1,17 +0,0 @@
|
|||||||
# DSH 运行包与入口修复验证
|
|
||||||
|
|
||||||
## 问题
|
|
||||||
|
|
||||||
发布规格此前把 `integration/dsh/node_modules` 整个目录递归复制进 PyInstaller,包含非 Windows 平台二进制、实验包、测试目录、TypeScript 源码、source map 和文档,导致包体偏大。另一个问题是 DSH 懒启动发生导入、Qt WebEngine 或 Node 运行包异常时,异常从 QAction 槽冒出,桌面上看起来像点击没有反应。
|
|
||||||
|
|
||||||
## 修复
|
|
||||||
|
|
||||||
- 打包前生成 Windows x64 DSH 运行时暂存目录:保留当前平台依赖、JavaScript/JSON/原生运行文件和官方 Harness 包;去除其他平台包、测试/示例/缓存目录、TypeScript 源码、source map 和文档。优先使用硬链接暂存,跨卷时自动回退复制,不修改源 `node_modules`。
|
|
||||||
- DSH助手入口捕获懒启动异常,写入现有应用错误日志,并在任务中心操作栏显示“DSH助手启动失败,请检查发布包中的运行时和 Node.js”,避免无反馈点击。
|
|
||||||
|
|
||||||
## 验证
|
|
||||||
|
|
||||||
- 精简运行时单元回归和 DSH UI/打包/原生运行时回归:**48 passed**。
|
|
||||||
- 精简后的实际 Harness 暂存目录运行 `start.mjs --doctor`:返回 `status=ready`,官方前端、7 个受控工具和 Node 版本信息正常。
|
|
||||||
- 源码真实 Qt/CDP 点击验收:报告 `build/dsh-click-after-fix-9267/desktop-report.json`,直接导航、官方三栏页面、SVG/动画、模型选择、原生取消确认、草稿保留和正常退出通过;`uncaughtErrors=false`、`unexpectedUiErrors=false`。
|
|
||||||
- 本轮未构建发布 EXE,未操作真实 CAD 或远端工单;PyInstaller 发布时会使用新的暂存逻辑。
|
|
||||||
@@ -3,14 +3,11 @@
|
|||||||
|
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
import shutil
|
import shutil
|
||||||
import sys
|
|
||||||
|
|
||||||
import win32com.client.gencache
|
import win32com.client.gencache
|
||||||
|
|
||||||
|
|
||||||
project_root = Path(SPECPATH).parent
|
project_root = Path(SPECPATH).parent
|
||||||
sys.path.insert(0, str(project_root / 'packaging'))
|
|
||||||
from dsh_runtime_staging import stage_node_modules
|
|
||||||
generated_root = project_root / "build" / "DxPartReplace-generated"
|
generated_root = project_root / "build" / "DxPartReplace-generated"
|
||||||
generated_root.mkdir(parents=True, exist_ok=True)
|
generated_root.mkdir(parents=True, exist_ok=True)
|
||||||
viewdraw_api = win32com.client.gencache.EnsureModule(
|
viewdraw_api = win32com.client.gencache.EnsureModule(
|
||||||
@@ -41,13 +38,11 @@ if (dsh_root / 'issue-bootstrap.json').is_file():
|
|||||||
if (dsh_root / 'node_modules' / '@deepseek-ai' / 'dsh' / 'package.json').is_file():
|
if (dsh_root / 'node_modules' / '@deepseek-ai' / 'dsh' / 'package.json').is_file():
|
||||||
if not (dsh_root / 'issue-bootstrap.json').is_file():
|
if not (dsh_root / 'issue-bootstrap.json').is_file():
|
||||||
raise RuntimeError('Provision the DSH issue-only reporter before packaging the native assistant.')
|
raise RuntimeError('Provision the DSH issue-only reporter before packaging the native assistant.')
|
||||||
staged_node_modules = stage_node_modules(
|
|
||||||
dsh_root / 'node_modules', generated_root / 'dsh-node_modules')
|
|
||||||
legacy_runtime_datas.extend([
|
legacy_runtime_datas.extend([
|
||||||
(str(dsh_root / 'start.mjs'), 'dsh-runtime'),
|
(str(dsh_root / 'start.mjs'), 'dsh-runtime'),
|
||||||
(str(dsh_root / 'package.json'), 'dsh-runtime'),
|
(str(dsh_root / 'package.json'), 'dsh-runtime'),
|
||||||
(str(dsh_root / 'task-plugin'), 'dsh-runtime/task-plugin'),
|
(str(dsh_root / 'task-plugin'), 'dsh-runtime/task-plugin'),
|
||||||
(str(staged_node_modules), 'dsh-runtime/node_modules'),
|
(str(dsh_root / 'node_modules'), 'dsh-runtime/node_modules'),
|
||||||
(shutil.which('node'), 'dsh-runtime'),
|
(shutil.which('node'), 'dsh-runtime'),
|
||||||
(str(project_root / 'licenses' / 'DeepSeek-Harness-MIT.txt'), 'licenses'),
|
(str(project_root / 'licenses' / 'DeepSeek-Harness-MIT.txt'), 'licenses'),
|
||||||
])
|
])
|
||||||
|
|||||||
@@ -1,71 +0,0 @@
|
|||||||
"""Create a small, Windows-only copy of the installed DSH Node runtime."""
|
|
||||||
from __future__ import annotations
|
|
||||||
|
|
||||||
import json
|
|
||||||
import os
|
|
||||||
from pathlib import Path
|
|
||||||
import shutil
|
|
||||||
|
|
||||||
_PRUNED_DIRS = frozenset({
|
|
||||||
".bin", ".cache", ".github", "__tests__", "benchmark", "benchmarks",
|
|
||||||
"coverage", "example", "examples", "test", "tests",
|
|
||||||
})
|
|
||||||
_PRUNED_SUFFIXES = frozenset({".map", ".ts", ".tsx"})
|
|
||||||
_PRUNED_NAMES = frozenset({"changelog", "changelog.md", "history.md", "readme", "readme.md"})
|
|
||||||
|
|
||||||
|
|
||||||
def _matches(value: str, rule: str) -> bool:
|
|
||||||
return value.casefold() == rule.lstrip("!").casefold()
|
|
||||||
|
|
||||||
|
|
||||||
def _compatible(package: Path, *, platform: str, arch: str) -> bool:
|
|
||||||
try:
|
|
||||||
value = json.loads((package / "package.json").read_text(encoding="utf8"))
|
|
||||||
except (OSError, ValueError, TypeError):
|
|
||||||
return True
|
|
||||||
if not isinstance(value, dict):
|
|
||||||
return True
|
|
||||||
for field, current in (("os", platform), ("cpu", arch)):
|
|
||||||
rules = value.get(field)
|
|
||||||
if not isinstance(rules, list):
|
|
||||||
continue
|
|
||||||
if any(isinstance(rule, str) and rule.startswith("!") and _matches(current, rule)
|
|
||||||
for rule in rules):
|
|
||||||
return False
|
|
||||||
positive = [rule for rule in rules if isinstance(rule, str) and not rule.startswith("!")]
|
|
||||||
if positive and not any(_matches(current, rule) for rule in positive):
|
|
||||||
return False
|
|
||||||
return True
|
|
||||||
|
|
||||||
|
|
||||||
def _ignore(directory: str, names: list[str], *, platform: str, arch: str) -> set[str]:
|
|
||||||
ignored: set[str] = set()
|
|
||||||
for name in names:
|
|
||||||
path = Path(directory) / name
|
|
||||||
if path.is_dir():
|
|
||||||
if name.casefold() in _PRUNED_DIRS or not _compatible(path, platform=platform, arch=arch):
|
|
||||||
ignored.add(name)
|
|
||||||
elif Path(name).suffix.casefold() in _PRUNED_SUFFIXES or name.casefold() in _PRUNED_NAMES:
|
|
||||||
ignored.add(name)
|
|
||||||
return ignored
|
|
||||||
|
|
||||||
|
|
||||||
def stage_node_modules(source: Path, destination: Path, *, platform: str = "win32", arch: str = "x64") -> Path:
|
|
||||||
"""Stage runtime packages without other-platform binaries or documentation."""
|
|
||||||
source = Path(source)
|
|
||||||
destination = Path(destination)
|
|
||||||
if not (source / "@deepseek-ai" / "dsh" / "package.json").is_file():
|
|
||||||
raise FileNotFoundError("DSH runtime package is not installed")
|
|
||||||
if destination.exists():
|
|
||||||
shutil.rmtree(destination)
|
|
||||||
destination.parent.mkdir(parents=True, exist_ok=True)
|
|
||||||
def link_or_copy(source_file: str, destination_file: str) -> None:
|
|
||||||
try:
|
|
||||||
os.link(source_file, destination_file)
|
|
||||||
except OSError:
|
|
||||||
shutil.copy2(source_file, destination_file)
|
|
||||||
|
|
||||||
shutil.copytree(source, destination, ignore=lambda directory, names: _ignore(
|
|
||||||
directory, names, platform=platform, arch=arch), copy_function=link_or_copy,
|
|
||||||
symlinks=False)
|
|
||||||
return destination
|
|
||||||
@@ -1028,21 +1028,10 @@ class TrialTaskCenterWindow(MaterialMainWindow):
|
|||||||
self.run_panel.operator_band.style().polish(self.run_panel.operator_band)
|
self.run_panel.operator_band.style().polish(self.run_panel.operator_band)
|
||||||
|
|
||||||
def _open_dsh(self):
|
def _open_dsh(self):
|
||||||
try:
|
self._ensure_dsh_view()
|
||||||
self._ensure_dsh_view()
|
self.content_stack.setCurrentWidget(self._dsh_view)
|
||||||
self.content_stack.setCurrentWidget(self._dsh_view)
|
if self._dsh_automation is not None and self._dsh_automation.latest:
|
||||||
if self._dsh_automation is not None and self._dsh_automation.latest:
|
self._dsh_automation._publish_context()
|
||||||
self._dsh_automation._publish_context()
|
|
||||||
except Exception as error:
|
|
||||||
# QAction slots do not surface exceptions visibly in a frozen Qt
|
|
||||||
# app. Route lazy import/WebEngine failures through the operator
|
|
||||||
# error path instead of making the click appear to do nothing.
|
|
||||||
try:
|
|
||||||
self.service.report_ui_error(error)
|
|
||||||
except Exception:
|
|
||||||
pass
|
|
||||||
self._show_error(TaskCenterError(
|
|
||||||
'dsh_startup', 'DSH助手启动失败,请检查发布包中的运行时和 Node.js。'))
|
|
||||||
|
|
||||||
def _ensure_dsh_view(self):
|
def _ensure_dsh_view(self):
|
||||||
if self._dsh_view is None:
|
if self._dsh_view is None:
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ import json
|
|||||||
import re
|
import re
|
||||||
|
|
||||||
ERROR_TEXT = {
|
ERROR_TEXT = {
|
||||||
"dsh_startup": "DSH助手启动失败,请检查发布包中的运行时和 Node.js。",
|
|
||||||
'user_forced_stop': '操作已强制中断,结果待核验。',
|
'user_forced_stop': '操作已强制中断,结果待核验。',
|
||||||
'application_shutdown_failed': '业务结果已保留,但应用收尾异常。',
|
'application_shutdown_failed': '业务结果已保留,但应用收尾异常。',
|
||||||
"batch_resources_pending": "后台资源尚未确认释放,请使用“重新清理资源”后再开始下一批。",
|
"batch_resources_pending": "后台资源尚未确认释放,请使用“重新清理资源”后再开始下一批。",
|
||||||
|
|||||||
@@ -1,40 +0,0 @@
|
|||||||
from pathlib import Path
|
|
||||||
import importlib.util
|
|
||||||
|
|
||||||
_MODULE = Path(__file__).resolve().parents[2] / 'packaging' / 'dsh_runtime_staging.py'
|
|
||||||
_SPEC = importlib.util.spec_from_file_location('dsh_runtime_staging', _MODULE)
|
|
||||||
_LOADED = importlib.util.module_from_spec(_SPEC)
|
|
||||||
assert _SPEC and _SPEC.loader
|
|
||||||
_SPEC.loader.exec_module(_LOADED)
|
|
||||||
stage_node_modules = _LOADED.stage_node_modules
|
|
||||||
|
|
||||||
|
|
||||||
def _package(root: Path, name: str, *, os=None, cpu=None, files=()):
|
|
||||||
path = root / name
|
|
||||||
path.mkdir(parents=True)
|
|
||||||
manifest = {'name': name, 'version': '1.0.0'}
|
|
||||||
if os is not None:
|
|
||||||
manifest['os'] = os
|
|
||||||
if cpu is not None:
|
|
||||||
manifest['cpu'] = cpu
|
|
||||||
import json
|
|
||||||
(path / 'package.json').write_text(json.dumps(manifest), encoding='utf8')
|
|
||||||
for relative, content in files:
|
|
||||||
target = path / relative
|
|
||||||
target.parent.mkdir(parents=True, exist_ok=True)
|
|
||||||
target.write_text(content, encoding='utf8')
|
|
||||||
|
|
||||||
|
|
||||||
def test_stage_dsh_runtime_keeps_windows_runtime_and_prunes_other_platforms(tmp_path):
|
|
||||||
source = tmp_path / 'node_modules'
|
|
||||||
(source / '@deepseek-ai' / 'dsh').mkdir(parents=True)
|
|
||||||
(source / '@deepseek-ai' / 'dsh' / 'package.json').write_text('{}', encoding='utf8')
|
|
||||||
_package(source, 'win-addon', os=['win32'], cpu=['x64'], files=[('index.js', 'ok')])
|
|
||||||
_package(source, 'linux-addon', os=['linux'], files=[('index.js', 'drop')])
|
|
||||||
_package(source, 'docs-only', files=[('index.js', 'ok'), ('README.md', 'drop'), ('source.ts', 'drop')])
|
|
||||||
staged = stage_node_modules(source, tmp_path / 'staged')
|
|
||||||
assert (staged / 'win-addon' / 'index.js').read_text(encoding='utf8') == 'ok'
|
|
||||||
assert not (staged / 'linux-addon').exists()
|
|
||||||
assert (staged / 'docs-only' / 'index.js').is_file()
|
|
||||||
assert not (staged / 'docs-only' / 'README.md').exists()
|
|
||||||
assert not (staged / 'docs-only' / 'source.ts').exists()
|
|
||||||
@@ -58,15 +58,6 @@ def test_direct_navigation_opens_harness_and_returns_without_losing_task(ui, mon
|
|||||||
assert window._dsh_view.starts == 1
|
assert window._dsh_view.starts == 1
|
||||||
|
|
||||||
|
|
||||||
def test_dsh_navigation_surfaces_lazy_startup_failure(ui, monkeypatch, qtbot):
|
|
||||||
window = ui.window
|
|
||||||
def fail(_self):
|
|
||||||
raise RuntimeError('controlled missing WebEngine')
|
|
||||||
monkeypatch.setattr(type(window), '_create_dsh_view', fail)
|
|
||||||
qtbot.mouseClick(window.dsh_navigation, Qt.MouseButton.LeftButton)
|
|
||||||
assert 'DSH助手启动失败' in window.run_panel.operator_band.text()
|
|
||||||
|
|
||||||
|
|
||||||
def test_cross_task_harness_action_never_reaches_task_service(ui, monkeypatch):
|
def test_cross_task_harness_action_never_reaches_task_service(ui, monkeypatch):
|
||||||
window = ui.window
|
window = ui.window
|
||||||
monkeypatch.setattr(type(window), '_create_dsh_view', lambda self: HarnessView(self), raising=False)
|
monkeypatch.setattr(type(window), '_create_dsh_view', lambda self: HarnessView(self), raising=False)
|
||||||
|
|||||||
Reference in new issue
Block a user