chore: switch to Low workspace and Nutstore-only publish
- build.ps1: dev build only; no copy to a fixed exe - publish.ps1: user-run Medium publish to Nutstore - docs: workspace stays D:\Scripts\md-preview, repo under AgentLowWorking - .gitignore: local test/ scratch directory
This commit is contained in:
@@ -1,18 +1,23 @@
|
||||
# MD Preview 本地维护交接
|
||||
|
||||
> 最后更新:2026-10-21
|
||||
> 最后更新:2026-11-02
|
||||
> 维护范围:仅 Windows 本地构建,目标产物 `MD-Preview-windows-x64.exe`
|
||||
>
|
||||
> **Agent 必须先读 `agent/AGENTS.md`**:最高优先级是工作区边界,任何工作区外的文件修改都要先停下询问用户。
|
||||
|
||||
> **2026-11-02 迁移(重要)**:代码仓库移到 `D:\Scripts\md-preview\AgentLowWorking`;DSH 工作区仍是父目录 `D:\Scripts\md-preview`;
|
||||
> 仓库整棵树为 **Low**,DSH 用 **workspace-write** 即可改代码/编译;
|
||||
> 成品只发布到 `C:\Users\wucl1\Nutstore\1\Scripts\MD-Preview-windows-x64.exe`(Medium),仓库内不再放 exe。
|
||||
> 本文第 4 节等处的 “Medium / danger-full-access” 是旧模型;以 `agent/docs/migration-2026-11-02.md` 和 `AGENTS.md` 为准。
|
||||
|
||||
## 1. 当前状态
|
||||
|
||||
- 上游版本:`md-preview 1.4.2`(源码来自 `backup/md-preview-master.zip`)
|
||||
- 改造目标:**本地预览器,不联网、不自动更新**;预览/编辑/标签/会话等功能与上游一致
|
||||
- 源码规模:`src/main.rs` 4354 行、`src/session.rs` 281 行、`src/instance.rs` 207 行
|
||||
- 当前产物:`D:\Scripts\md-preview\MD-Preview-windows-x64.exe`
|
||||
- 大小 5,501,440 字节
|
||||
- SHA256 `F76BC3963BA13BBFC8259BC2B4E3D24468C34E3C9E26491D364D5D364BEDE96C`
|
||||
- 当前产物(2026-11-02 起):`C:\Users\wucl1\Nutstore\1\Scripts\MD-Preview-windows-x64.exe`
|
||||
- 当前发布版见 `STATUS.md` 第 2 节(v1.4.2-local.5,5,505,024 字节)
|
||||
- 仓库内不再放成品 exe;旧 `D:\Scripts\md-preview\MD-Preview-windows-x64.exe` 由 `publish.ps1` 删除
|
||||
- 测试:`cargo test` → 43 passed, 0 failed
|
||||
- 编译警告:1 个 `dead_code`(macOS 专用事件枚举,Windows 下未构造),可忽略
|
||||
- 2026-10-21 的全部功能需求已完成并部署,细节与实现要点见第 14 节。
|
||||
@@ -36,62 +41,31 @@ DSH 的 pwsh 可能没有继承 PATH,构建时用完整路径:
|
||||
|
||||
## 3. 构建与运行
|
||||
|
||||
```powershell
|
||||
cd D:\Scripts\md-preview
|
||||
cargo build --release
|
||||
copy .\target\release\md-preview.exe .\MD-Preview-windows-x64.exe
|
||||
.\MD-Preview-windows-x64.exe
|
||||
```
|
||||
~~~powershell
|
||||
cd D:\Scripts\md-preview\AgentLowWorking
|
||||
.\agent\scripts\build.ps1 # 开发构建(cargo test + build --release)
|
||||
# 发布由用户在自己的普通 PowerShell 运行:
|
||||
.\agent\scripts\publish.ps1
|
||||
~~~
|
||||
|
||||
- 增量构建约 15 秒,清理后约 1–2 分钟(16 核,release 开启 LTO + opt-level=z)
|
||||
- 依赖锁定在 `Cargo.lock`(435 个包),**不要随手 `cargo update`**
|
||||
- 调试可 `cargo build`(debug,快),产物在 `target\debug\`
|
||||
|
||||
## 4. ⚠️ 必读:完整性级别与 os error 5
|
||||
## 4. ⚠️ 必读:Low 工作区与发布(2026-11-02 起)
|
||||
|
||||
这是本次维护踩过最大的坑,务必先读:
|
||||
- 仓库根 `D:\Scripts\md-preview\AgentLowWorking` 整棵树是 **Low** 完整性级别;DSH 以 **workspace-write** 运行即可改代码、编译、commit。
|
||||
- 从 Low 工作区编译出的 exe 也是 Low:启动后写 `%LOCALAPPDATA%\md-preview\instance.lock` 会被 no-write-up 拒绝(os error 5)。这不是应用 bug。
|
||||
- 开发冒烟不要双击 `target\release\md-preview.exe`,用隔离配置目录:
|
||||
|
||||
- DSH 的 **workspace-write** 模式会把子进程降为 **Low 完整性级别(Low IL)**,并期望工作区文件也是 Low。
|
||||
- 从被标成 Low 的目录编译出的 exe 会继承 Low 标签;启动后写 `%LOCALAPPDATA%\md-preview\instance.lock` 会被 Windows 的 no-write-up 拒绝,弹窗:
|
||||
~~~powershell
|
||||
$env:MD_PREVIEW_CONFIG_DIR="$PWD\target\smoke"
|
||||
.\target\release\md-preview.exe path\to\file.md
|
||||
~~~
|
||||
|
||||
```
|
||||
Could Not Open MD Preview
|
||||
拒绝访问 (os error 5)
|
||||
```
|
||||
|
||||
- 这不是应用 bug。同一个 exe 复制到 `D:\Installer\MD-Preview\` 就能正常运行(目标目录是 Medium)。
|
||||
|
||||
当前仓库状态:工作区已设为 **Medium**,DSH 必须以 **danger-full-access** 运行才能编辑/编译此目录。
|
||||
如果你用 workspace-write 打开本仓库,DSH 进程是 Low,会写不动 Medium 工作区(表现是编辑/编译全部 Access denied)。
|
||||
|
||||
### 如果 exe 又报 os error 5
|
||||
|
||||
```powershell
|
||||
# 方案 1:把工作区(含 target)改回 Medium 后重建
|
||||
icacls D:\Scripts\md-preview /setintegritylevel "(OI)(CI)Medium" /T /C
|
||||
cargo build --release
|
||||
|
||||
# 方案 2:不改标签,直接把 exe 复制到普通目录再运行
|
||||
copy .\target\release\md-preview.exe D:\Installer\MD-Preview\MD-Preview-windows-x64.exe
|
||||
```
|
||||
|
||||
检查标签:
|
||||
|
||||
```powershell
|
||||
icacls .\MD-Preview-windows-x64.exe # 应显示 Medium,不能是 Low
|
||||
```
|
||||
|
||||
### 若坚持用 workspace-write 沙箱
|
||||
|
||||
工作区必须保持 Low,DSH 才能写;构建输出必须放到工作区外(否则 exe 又是 Low):
|
||||
|
||||
1. `icacls D:\Scripts\md-preview /setintegritylevel "(OI)(CI)Low" /T /C`
|
||||
2. 项目内 `.cargo\config.toml`:
|
||||
```toml
|
||||
[build]
|
||||
target-dir = "D:/MD-Preview-build/target"
|
||||
```
|
||||
3. 在**自己的普通 PowerShell**里构建,再把 exe 复制到 `D:\Installer\MD-Preview\`
|
||||
- 发布:用户在**普通 PowerShell(Medium)**运行 `agent\scripts\publish.ps1`。脚本会复制到 Nutstore、设 Medium、校验 SHA256、刷新 `.md` 关联,最后删除旧 exe。
|
||||
- 如果发布后仍报 os error 5:`icacls <Nutstore exe> | Select-String 'Mandatory Label'` 应为 Medium;确认不是从 Low 目录直接启动。
|
||||
- 不要再把仓库改回 Medium,也不要为了改代码申请 danger-full-access。
|
||||
|
||||
## 5. 已删除的联网/更新功能(不要加回来)
|
||||
|
||||
@@ -129,30 +103,23 @@ python -c "d=open(r'MD-Preview-windows-x64.exe','rb').read(); print(d.count(b'ap
|
||||
|
||||
## 7. 目录结构
|
||||
|
||||
```
|
||||
D:\Scripts\md-preview
|
||||
├─ Cargo.toml / Cargo.lock / build.rs
|
||||
├─ src/main.rs 界面、页面模板、渲染、事件循环、Windows 集成(4354 行)
|
||||
├─ src/session.rs 标签会话持久化
|
||||
├─ src/instance.rs 单实例锁与本地端口转发
|
||||
├─ assets/ 8 个被 include_str!/include_bytes! 内嵌的资源
|
||||
│ ├─ icon.ico
|
||||
│ ├─ enhance/preview-enhance.js
|
||||
│ ├─ hljs/(highlight.min.js、delphi、vs-dark.css)
|
||||
│ ├─ katex/…
|
||||
│ └─ mermaid/mermaid.min.js
|
||||
├─ backup/md-preview-master.zip 上游源码备份(3.77 MB,本地保留,不入 git)
|
||||
├─ MD-Preview-windows-x64.exe 构建产物(不入 git;默认打开方式指向此路径)
|
||||
├─ target/ 编译缓存(不入 git,可删)
|
||||
├─ agent/ Agent 文档 / 脚本 / 测试夹具
|
||||
│ ├─ AGENTS.md Agent 运行规则(最高优先级)
|
||||
│ ├─ README.md
|
||||
│ ├─ docs/{HANDOFF.md, STATUS.md, scan-2026-10-21.md, roadmap.md}
|
||||
│ ├─ scripts/build.ps1
|
||||
│ └─ tests/{smoke.ps1, fixtures/}
|
||||
├─ README.md 入口,指向 agent/docs/HANDOFF.md
|
||||
├─ LICENSE / .gitignore / .gitattributes
|
||||
```
|
||||
~~~
|
||||
D:\Scripts\md-preview\
|
||||
├─ AgentLowWorking\ ← 仓库根(整棵树 Low)
|
||||
│ ├─ Cargo.toml / Cargo.lock / build.rs
|
||||
│ ├─ src/ 应用源码
|
||||
│ ├─ assets/ 内嵌资源
|
||||
│ ├─ backup/ 上游源码备份(不入 git)
|
||||
│ ├─ target/ 编译缓存(不入 git,可删)
|
||||
│ ├─ agent/ Agent 文档 / 脚本 / 测试夹具
|
||||
│ │ ├─ AGENTS.md
|
||||
│ │ ├─ docs/{HANDOFF.md, STATUS.md, migration-2026-11-02.md, ...}
|
||||
│ │ ├─ scripts/{build.ps1, publish.ps1}
|
||||
│ │ └─ tests/{smoke.ps1, fixtures/}
|
||||
│ ├─ README.md / LICENSE / .gitignore / .gitattributes
|
||||
│ └─ test/ 本机草稿(已忽略)
|
||||
└─ MD-Preview-windows-x64.exe 旧产物;publish.ps1 成功后删除
|
||||
~~~
|
||||
|
||||
Git 由用户自行初始化(私有仓库;`backup/` 与成品 exe 不入 git)。`.gitignore` 已忽略 `/target/`、`MD-Preview-windows-x64.exe`、`/backup/` 与临时日志。
|
||||
|
||||
@@ -183,12 +150,13 @@ Git 由用户自行初始化(私有仓库;`backup/` 与成品 exe 不入 git
|
||||
|
||||
## 11. 验收清单
|
||||
|
||||
```powershell
|
||||
cd D:\Scripts\md-preview
|
||||
cargo test # 43 passed
|
||||
cargo build --release # Finished
|
||||
.\MD-Preview-windows-x64.exe path\to\file.md
|
||||
```
|
||||
~~~powershell
|
||||
cd D:\Scripts\md-preview\AgentLowWorking
|
||||
cargo test
|
||||
.\agent\scripts\build.ps1
|
||||
# 发布由用户在自己的普通 PowerShell 运行:
|
||||
.\agent\scripts\publish.ps1
|
||||
~~~
|
||||
|
||||
手工检查:
|
||||
|
||||
@@ -197,7 +165,7 @@ cargo build --release # Finished
|
||||
- [ ] 多标签切换、关闭、会话恢复
|
||||
- [ ] 编辑后 700ms 自动保存,关闭前落盘
|
||||
- [ ] 第二个实例打开文件时,第一个实例新增标签、第二个退出
|
||||
- [ ] `icacls MD-Preview-windows-x64.exe` 为 Medium
|
||||
- [ ] `icacls "C:\Users\wucl1\Nutstore\1\Scripts\MD-Preview-windows-x64.exe"` 为 Medium
|
||||
|
||||
## 12. 追加修复(2026-10-21 下午)
|
||||
|
||||
@@ -317,7 +285,7 @@ cargo test # 43 passed
|
||||
|
||||
- Gitea Release `v1.4.2-local.1`:https://git.wucl12.cn/wucl12/md-preview/releases/tag/v1.4.2-local.1
|
||||
- 附件 `MD-Preview-windows-x64.exe`(5,501,440 字节,SHA256 `F76BC396…BEDE96C`),发布说明见 `agent/docs/release-notes-v1.4.2-local.1.md`。
|
||||
- 发版流程:改版本 / 写 release notes → `build.ps1` → 推 tag 或用 Gitea API 建 release 并上传 exe。API 需要 `write:repository` scope 的 token,用完即删。
|
||||
- 发版流程:改版本 / 写 release notes → `build.ps1` → 用户在普通 PowerShell 运行 `publish.ps1` → 推 tag / 用 Gitea API 建 release 并上传 Nutstore 那份 exe。API 需要 `write:repository` scope 的 token,用完即删。
|
||||
|
||||
### 14.6 下一次开工检查
|
||||
|
||||
|
||||
Reference in New Issue
Block a user