# 2026-11-02 迁移:Low 工作区 + Nutstore 单一发布 > 目标:DSH 以 **workspace-write(Low)** 运行就能改代码、编译、测试;成品只通过用户手动运行的 `publish.ps1` 发布到 Nutstore。 > 执行前先读 `agent/AGENTS.md`。 ## 1. 最终结构 ~~~ D:\Scripts\md-preview\ ├─ AgentLowWorking\ ← 仓库根(整棵树 Low,含 .git) │ ├─ src / assets / agent / target / Cargo.* / README.md ... │ └─ test\ 本机草稿(已 gitignore) └─ MD-Preview-windows-x64.exe 旧产物(Medium);publish.ps1 成功后删除 ~~~ - 仓库根:`D:\Scripts\md-preview\AgentLowWorking` - 发布产物:`C:\Users\wucl1\Nutstore\1\Scripts\MD-Preview-windows-x64.exe`(Medium) - 默认 `.md` 打开方式:由 `publish.ps1` 指向 Nutstore - 仓库内不再放 exe ## 2. 一次性移动(用户执行) DSH 工作区保持在父目录 `D:\Scripts\md-preview`,所以**不需要关 DSH**;只要没有编辑器/进程占用仓库文件即可。如果 `Move-Item` 报“文件被占用”,再关掉 DSH/编辑器重试。 ~~~powershell $old = 'D:\Scripts\md-preview' $new = Join-Path $old 'AgentLowWorking' # 1) 创建新仓库根(继承 Low) New-Item -ItemType Directory -Path $new -Force | Out-Null # 2) 移动除旧 exe 和新目录以外的全部内容(含 .git、target、backup、test) Get-ChildItem -LiteralPath $old -Force | Where-Object { $_.Name -notin @('AgentLowWorking', 'MD-Preview-windows-x64.exe') } | Move-Item -Destination $new -Force # 3) 整棵树 relabel 成 Low(对目录用 /T,顶层文件也会覆盖) icacls $new /setintegritylevel "(OI)(CI)Low" /T /C # 4) 校验:前三项 Low,最后一项 Medium icacls (Join-Path $new 'src\main.rs') | Select-String 'Mandatory Label' icacls (Join-Path $new 'Cargo.toml') | Select-String 'Mandatory Label' icacls (Join-Path $new '.git') | Select-String 'Mandatory Label' icacls (Join-Path $old 'MD-Preview-windows-x64.exe') | Select-String 'Mandatory Label' ~~~ 移动是同卷 rename,`.git` 一起走:历史、分支、远程都不受影响,**不需要任何 rename 提交**。 ## 3. 移动后继续 不需要重开 DSH;在 DSH 里 `cd AgentLowWorking`(或所有命令用绝对路径)。验证: ~~~powershell # 在 DSH 的 pwsh 里应能写 Set-Content "$PWD\target\tmp\probe.txt" 'ok'; Get-Content "$PWD\target\tmp\probe.txt"; Remove-Item "$PWD\target\tmp\probe.txt" cargo test ~~~ ## 4. 开发循环 ~~~powershell .\agent\scripts\build.ps1 # 产物 target\release\md-preview.exe 是 Low,不能直接双击 $env:MD_PREVIEW_CONFIG_DIR="$PWD\target\smoke" .\target\release\md-preview.exe path\to\file.md ~~~ ## 5. 发布(用户手动,普通 PowerShell) ~~~powershell cd D:\Scripts\md-preview\AgentLowWorking .\agent\scripts\publish.ps1 ~~~ 脚本会:检查 Medium 权限和进程占用 → 复制到 Nutstore → 设 Medium → 校验 SHA256 → 刷新 `.md` 关联 → 删除 `D:\Scripts\md-preview\MD-Preview-windows-x64.exe`。 ## 6. 回滚 如果新模型不可用: 1. 关掉 DSH。 2. 把 `AgentLowWorking` 里的内容移回 `D:\Scripts\md-preview`(同样排除 `AgentLowWorking`)。 3. `icacls D:\Scripts\md-preview /setintegritylevel "(OI)(CI)Medium" /T /C`(旧模型)。 4. 旧 exe 若已被删除,从 Nutstore 复制回来或重新发布。 5. DSH 改回 danger-full-access。 ## 7. 注意 - `publish.ps1` 只应在**普通 / Medium** PowerShell 里运行;DSH 的 Low shell 会被脚本拒绝。 - 发布前关闭 MD Preview;Nutstore 同步也可能短暂锁文件。 - 开发版写不了 HKCU,不会抢默认打开;不要用 Medium 的旧 exe 启动,否则关联会被改回旧路径。 - `test/` 已 gitignore,移动后仍不提交。 ## 8. 迁移后待办 - 在 DSH 里确认可写、`cargo test` 全绿。 - 父目录可选:`publish.ps1` 启动器 + `AGENTS.md` 指针(让新会话在父目录也能找到仓库规则)。 - 给 `.gitignore` 加 `/test/`(本机草稿目录)。 - 更新根 `README.md` 的目录树/构建命令。 - 提交:`git add -A && git commit -m "chore: move to Low workspace and Nutstore-only publish"`(不要提交 `test/`)。 - 需要切换默认打开并删除旧 exe 时,运行 `publish.ps1`。