Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
217e37ec6f | ||
|
|
2587c46b4a | ||
|
|
daf3d50ac1 | ||
|
|
822332b74d | ||
|
|
9ccb6b38e6 | ||
|
|
0dd4bb5edf | ||
|
|
46cf3ec691 | ||
|
|
18be7c04e7 | ||
|
|
6a1d6af109 | ||
|
|
57a9e0332f | ||
|
|
0d3a9c4369 | ||
|
|
54f1c090fc | ||
|
|
10a40b32c6 | ||
|
|
9a975e44fb | ||
|
|
0f63ced004 | ||
|
|
1bdc6cbc6f | ||
|
|
5573c7cacc | ||
|
|
73e4f6e57d | ||
|
|
99073e94c3 | ||
|
|
7e2f1ac325 | ||
|
|
9979411e08 | ||
|
|
28df81ee11 | ||
|
|
f89b2dd81e | ||
|
|
eceb13a70a | ||
|
|
fd1d129e00 | ||
|
|
a1517652c2 | ||
|
|
3e76e3df89 | ||
|
|
6c84ad4f1d | ||
|
|
240956ecae | ||
|
|
2aab24cccf | ||
|
|
86c10416dd | ||
|
|
56ff79cf01 | ||
|
|
01afaf2ce4 | ||
|
|
bc4bb48e61 |
No files matched your search
@@ -24,6 +24,7 @@ steps:
|
||||
depends_on: [install]
|
||||
environment:
|
||||
CI: "true"
|
||||
DSH_CLIENT_TITLE: "Marqdo Harness"
|
||||
commands:
|
||||
- corepack enable
|
||||
- corepack prepare pnpm@11.28.5 --activate
|
||||
|
||||
@@ -14,6 +14,12 @@ This repository is the **Marqdo Harness (MQDH)** downstream fork of DeepSeek Har
|
||||
|
||||
The upstream history, MIT license and third-party notices are retained. `origin` is `https://git.cflmy.cn/cflmy/marqdo-app-harness.git`; `upstream` is the Gitea DSH mirror. Product documentation lives under `docs/mqdh/` (ARCHITECTURE, STATUS, UPSTREAM, upstream-delta).
|
||||
|
||||
**Public beta:** `mqdh-v0.1.0-beta.1` (Linux x86_64) is published at
|
||||
<https://git.cflmy.cn/cflmy/marqdo-app-harness/releases/tag/mqdh-v0.1.0-beta.1>
|
||||
and accepted by the Marqdo root repository; download entry is
|
||||
<https://marqdo.com/download/>. Release identity, limits and acceptance record
|
||||
are owned by [DISTRIBUTION.md](docs/mqdh/DISTRIBUTION.md) and `docs/mqdh/STATUS.md`.
|
||||
|
||||
Run the product from this checkout with `node scripts/mqdh.mjs` after `pnpm install && pnpm run build`. The web workbench is served at `/mqdh` on the same loopback listener as the DSH client. The application does not bundle a Marqdo CLI, stdlib, extension or tool implementation; those are downloaded from trusted Gitea releases into an application-owned home.
|
||||
|
||||
Product commands (everything else is forwarded to the forked DSH launcher):
|
||||
|
||||
@@ -34,12 +34,13 @@ apps/harness/ # 独立应用仓库(父仓 gitlink:apps
|
||||
│ ├── src/release/ # 应用发行清单、签名、Gitea 发现
|
||||
│ ├── src/ecosystem/ # Runtime 信任来源、安装事务、环境、回退、Bootstrap Tool 兼容
|
||||
│ ├── src/market/ # 市场来源/索引、用户级能力存储、启用作用域、项目导入门禁
|
||||
│ ├── src/reader/ # View embed 桥、manifest/摘要校验、阅读包缓存与同源服务
|
||||
│ ├── src/bootstrap/ # 首次启动状态机、doctor、repair
|
||||
│ ├── src/distribution/ # 安装根、应用更新/回退/卸载
|
||||
│ ├── src/diagnostics/ # 脱敏报告、去重、Gitea Issue 提交
|
||||
│ ├── src/knowledge/ # 私人知识集合、导入、索引适配、检索
|
||||
│ ├── src/execution/ # Analysis 3、CLI argv、审批、证据
|
||||
│ ├── src/cli/ # 产品命令(bootstrap/doctor/repair/report/update/network)
|
||||
│ ├── src/cli/ # 产品命令(bootstrap/status/doctor/repair/report/update/network)
|
||||
│ ├── src/tools/ # 面向模型的六个操作
|
||||
│ ├── src/web/ # /mqdh 页面与同源只读/受控写 API
|
||||
│ └── tests/ # node:test 单元与真实 CLI/Release 集成
|
||||
@@ -94,6 +95,9 @@ MQDH_HOME/ # 默认 $XDG_DATA_HOME/marqdo-harness,070
|
||||
├── market/
|
||||
│ ├── index.json # 可重建的来源聚合投影
|
||||
│ └── events.jsonl # market.changed 变更事件
|
||||
├── reader/
|
||||
│ ├── packages/ # 按源/View/主题/锚点身份缓存的只读阅读包
|
||||
│ └── staging/ # 未完成的 View 导出
|
||||
├── capabilities/
|
||||
│ ├── index.json # 权威:已安装版本/激活摘要/启用作用域/导入记录
|
||||
│ ├── store/<source>-<kind>-<id>/ # 用户级能力载荷(按摘要分版本)
|
||||
@@ -154,7 +158,7 @@ MQDH_HOME/ # 默认 $XDG_DATA_HOME/marqdo-harness,070
|
||||
|
||||
## 7. Web 工作台
|
||||
|
||||
`/mqdh` 是 DSH Web 内的真实服务器渲染工作台(同一 webserver、同一 loopback 绑定)。生态目录固定按 Runtime → Tool → Std → Ext → Knowledge 展示真实来源;打开/筛选无副作用,候选检查、市场刷新、安装/激活/启用、Runtime 切换、项目导入/锁检查与 Tool 移除由按钮显式发起。市场来源、索引与能力合同见 [MARKET.md](MARKET.md),目录分层见 [ECOSYSTEM.md](ECOSYSTEM.md)。Ext 的市场条目与项目文件分开显示,项目锁语义仍由 CLI `sync --locked --json`/`lock` 承担:
|
||||
`/mqdh` 是 DSH Web 内的真实服务器渲染工作台(同一 webserver、同一 loopback 绑定)。生态目录固定按 Runtime → Tool → Std → Ext → Knowledge 展示真实来源;打开/筛选无副作用,候选检查、市场刷新、安装/激活/启用、Runtime 切换、项目导入/锁检查与 Tool 移除由按钮显式发起。市场来源、索引与能力合同见 [MARKET.md](MARKET.md),目录分层见 [ECOSYSTEM.md](ECOSYSTEM.md),View 阅读桥见 [READER.md](READER.md)。Ext 的市场条目与项目文件分开显示,项目锁语义仍由 CLI `sync --locked --json`/`lock` 承担:
|
||||
|
||||
- Runtime:CLI/Bundle/平台/环境 ID/遥测关闭状态;
|
||||
- Knowledge:集合、导入(浏览器上传文本/文件)、搜索、删除、导出;
|
||||
@@ -173,6 +177,7 @@ MQDH_HOME/ # 默认 $XDG_DATA_HOME/marqdo-harness,070
|
||||
- Runtime 安装只接受 Gitea 权威 release 的不可变 tag、资产名、平台、大小与 SHA-256;市场条目按来源配置发现,下载/解包同样强制摘要、大小、路径与链接安全;失败保留旧组合。
|
||||
- 市场不做可信/不可信中央裁决;来源标签不门禁,安装不等于对模型启用;项目导入只由 CLI 写声明与锁。
|
||||
- 私人知识、完整会话、路径、环境变量、密钥和用户源码默认不进入诊断对外内容。
|
||||
- View 阅读包同源服务只返回 manifest 列出的文件,iframe 仅 `allow-same-origin`,HTML 包 CSP 禁止脚本、表单、顶层导航与外部资源。
|
||||
|
||||
## 9. 出口、发行与引导边界
|
||||
|
||||
|
||||
@@ -6,13 +6,24 @@ MQDH 是**默认对外发行**的单用户应用:用户下载安装包,在
|
||||
|
||||
| 平台 | 首版 | 状态 |
|
||||
| --- | --- | --- |
|
||||
| Linux x86_64 glibc ≥ 2.39 | `.tar.gz`(内置 Node 运行时 + 用户级 `install.sh`) | 已构建并冷安装验证 |
|
||||
| Linux x86_64 glibc ≥ 2.39 | `.tar.gz`(内置 Node 运行时 + 用户级 `install.sh`) | 已发布公共 Beta `0.1.0-beta.1`(2026-12-02,未签名) |
|
||||
| Windows x86_64 | `.tar.gz`(内置 Node 运行时 + 用户级 `install.ps1` + `mqdh.cmd`) | 实验性:已构建并冷安装验证;未签名、无原生 CI lane,应用内更新未验证 |
|
||||
| Linux aarch64 | 未发布 | `UNVERIFIED`;不生成同名制品 |
|
||||
| macOS arm64/x64 | 未发布 | `UNVERIFIED`;没有签名/公证证书 |
|
||||
| Windows x64/arm64 | 未发布 | `UNVERIFIED` |
|
||||
| Windows arm64 | 未发布 | `UNVERIFIED` |
|
||||
|
||||
`detectPlatform` 对未发布目标返回 `supported=false` 与具体原因;更新检查在下载前按 manifest 的 target/min_glibc/Node/CLI 兼容范围拒绝。应用不继承 DSH 桌面或官方发布声明。
|
||||
|
||||
当前公共 Beta 发行身份(唯一来源是 Gitea Release):
|
||||
|
||||
| 项 | 值 |
|
||||
| --- | --- |
|
||||
| tag / 源提交 | `mqdh-v0.1.0-beta.1` → `0f63ced004be9a9de69f897c3385558dfd753287` |
|
||||
| Release | <https://git.cflmy.cn/cflmy/marqdo-app-harness/releases/tag/mqdh-v0.1.0-beta.1> |
|
||||
| 归档 | `marqdo-harness-0.1.0-beta.1-x86_64-unknown-linux-gnu.tar.gz`,786,741,787 B,sha256 `68cbb8f8…cd7d` |
|
||||
| 运行时 | 根已接受 `marqdo-cli v3.0.0-rc.7`(`63562d8…`)+ Bundle 0.3.0,由 `mqdh bootstrap` 安装 |
|
||||
| 根接受记录 | 主仓库 `docs/release-acceptance/mqdh-linux-x86_64-0.1.0-beta.1.json` |
|
||||
|
||||
## 2. 安装布局
|
||||
|
||||
```text
|
||||
@@ -30,6 +41,41 @@ MQDH_HOME/ # 用户数据,卸载默认保留
|
||||
|
||||
`mqdh` wrapper 优先使用安装树内的 `runtime/node`,否则要求系统 Node ≥ 24;应用包因此不要求用户预装 Node。`SOURCE_SHA` 与 `packages/marqdo/harness/package.json` 固定应用身份。
|
||||
|
||||
### Windows x86_64(实验性)
|
||||
|
||||
```text
|
||||
%LOCALAPPDATA%\MQDH\ # 默认安装前缀(-Prefix 可改)
|
||||
├── versions/<version>-<sha12>/ # 不可变应用树(含 runtime\node.exe、scripts、apps、packages)
|
||||
├── current.json # 原子活动版本指针
|
||||
└── bin\mqdh.cmd # 生成的用户级启动器(读 current.json)
|
||||
|
||||
%APPDATA%\Microsoft\Windows\Start Menu\Programs\MQDH.lnk # 可选快捷方式
|
||||
MQDH_HOME\ # 用户数据,默认 %USERPROFILE%\.local\share\marqdo-harness
|
||||
```
|
||||
|
||||
`install.ps1` 支持 `-Prefix`、`-NoPath`、`-NoShortcut`、`-Uninstall`。它把已解压树移入 `versions/`(同一卷内是移动,不复制整套依赖),写入 `current.json`,生成读指针的 `bin\mqdh.cmd`,可选加入用户 PATH 与开始菜单快捷方式;卸载只删除安装树与指向它的启动器,保留 `MQDH_HOME`。解压后的目录也可直接用根目录 `mqdh.cmd` 运行(便携模式)。Windows 产物当前未签名,应用内自动更新未验证;Windows 用户按发布说明手动下载安装新版本。
|
||||
|
||||
Windows 实验包内置离线运行时目录 `runtime-deps/`:一个 `marqdo-3.0.0-rc.7-x86_64-pc-windows-msvc.tar.gz` 及其 `.sha256`,内含 CLI、Provider Worker 与 `marqdo-stdlib 0.3.0` Bundle。`scripts/mqdh.mjs` 在未显式设置 `MQDH_BOOTSTRAP_OFFLINE` 时把 bootstrap 指向该目录,因此首次启动可在无网络时完成运行时安装与校验;`mqdh bootstrap --offline <dir>` 可覆盖。该离线包只提供运行时,默认 Knowledge/View Tool 在没有 Windows 归档时以 `bootstrap.offline_tool_missing` 显式跳过,不伪造安装。运行时归档、Bundle 摘要、平台 target 与二进制摘要由 `RELEASE_INFO.json` 声明并在安装前校验。
|
||||
|
||||
### Windows x86_64 便携 ZIP(正式分发形态)
|
||||
|
||||
正式 Windows 用户路径是**单一下载的 ZIP 便携包**,不再要求终端、`install.ps1` 或分卷脚本:
|
||||
|
||||
```text
|
||||
MQDH-<version>-win-x64.zip
|
||||
└── MQDH-<version>-win-x64/
|
||||
├── MQDH.exe # 双击启动:离线 bootstrap 后打开工作台;无控制台窗口
|
||||
├── README-Windows.txt
|
||||
├── runtime/node.exe
|
||||
├── runtime-deps/ # CLI/Worker/Bundle 离线运行时(摘要校验)
|
||||
└── ...(继承的 DSH Web UI 与 MQDH 应用代码)
|
||||
```
|
||||
|
||||
- 解压后双击 `MQDH.exe` 即可;首次启动自动安装内置运行时,然后打开继承的 DSH Web UI(当前仅少量品牌化,见 `marqdo-app-harness#25`)。后台服务用 `MQDH.exe --stop` 退出。
|
||||
- 用户数据默认 `%LOCALAPPDATA%\MQDH\data`,可由 `MQDH_HOME` 覆盖;删除解压目录不影响用户数据。
|
||||
- 该 ZIP 由 `scripts/package-windows-zip.ps1` 从已验证的 Windows 应用树生成,并做冷解压 + 启动 + 工作台 HTTP + 运行时安装检查。
|
||||
- EXE 安装器、签名、桌面/开始菜单集成仍属于 #25 的后续阶段;当前 ZIP 是正式便携形态,不是“过渡分卷脚本”。
|
||||
|
||||
## 3. 发行合同
|
||||
|
||||
`mqdh-release.json`(一个平台一个文件)由 `scripts/release-manifest.ts` 生成:
|
||||
@@ -72,7 +118,9 @@ mqdh update rollback --confirm [--json]
|
||||
- 运行中的进程继续使用已加载的版本;**下一次启动**由 wrapper 读取新指针。活跃任务不因更新切换环境。
|
||||
- 失败关闭:摘要/平台/兼容/smoke 任一失败都不改指针,staging 清理。
|
||||
- 更新不触碰 `MQDH_HOME/ecosystem`;Marqdo 运行时仍由 Bootstrap/生态中心独立管理。
|
||||
- 应用仓库当前为私有开发仓时,匿名检查返回 403/404,状态显示 `update.unavailable`(不是伪造“已是最新”)。正式发行需公开仓库或显式配置凭据。
|
||||
- 发行仓库必须启用 Gitea Releases(`has_releases=true`)且公开;否则匿名检查返回 403/404,状态显示 `update.unavailable`(不是伪造“已是最新”)。当前 `cflmy/marqdo-app-harness` 已公开并启用 Releases。
|
||||
- `update check` 同时展示最新候选的 `published_at`、官方下载 URL(`latest.asset.url`)、Release 页面 URL(`latest.release_url`)、`known_limits` 与发布说明;发布说明来自可信 Gitea Release body(截断到 8 KiB),不是第二份清单。JSON 字段为 `latest.notes` 与 `latest.release_url`。
|
||||
- `mqdh status [--json]` 只读展示已持久化的更新视图(channel、上次检查时间、是否可更新、最新候选、最后一个错误),不触发网络检查;JSON 字段为 `update`。需要最新检查时显式运行 `mqdh update check`。
|
||||
|
||||
## 5. 构建与发布
|
||||
|
||||
@@ -86,6 +134,19 @@ MQDH_GITEA_TOKEN=... node scripts/release.ts --version 0.1.0 \
|
||||
MQDH_GITEA_TOKEN=... node scripts/release.ts ... --publish # 不可变发布
|
||||
```
|
||||
|
||||
Windows x86_64 实验性构建(在真实 Windows + Node ≥ 24.22.3 上执行;产物未签名、尚无原生 CI lane):
|
||||
|
||||
```powershell
|
||||
pnpm install --frozen-lockfile --ignore-scripts
|
||||
pnpm run build
|
||||
$env:MQDH_NODE24_DIR = 'C:\path\to\node24' # 含 node.exe 与 pnpm.cmd
|
||||
powershell -ExecutionPolicy Bypass -File .\scripts\package-windows.ps1
|
||||
# .ci\: marqdo-harness-<version>-x86_64-pc-windows-msvc.tar.gz (+.sha256)
|
||||
# mqdh-release.json、release-evidence.json、package-evidence.json
|
||||
```
|
||||
|
||||
`package-windows.ps1` 在生产依赖树上使用 `--prod --node-linker=hoisted`,避免 pnpm 链接农场让归档依赖符号链接权限;随后从归档冷解压、运行 `install.ps1`、`mqdh --version`、`mqdh doctor --json` 与 `mqdh --dump-config` 并把结果写入 `package-evidence.json`。
|
||||
|
||||
`package.sh` 会从**归档**做一次冷安装:解包到干净目录、`install.sh --prefix`、`mqdh --version`、`mqdh doctor --json`、`mqdh --dump-config`,并把版本/schema/结果写入 `package-evidence.json`。生产发布顺序:同 SHA CI 通过 → 构建 → 冷安装 → 生成/签名 manifest → 上传权威 Gitea Release → 保存证据。生产签名、macOS/Windows、第二台干净主机、真实回滚演练仍未验证,见 [STATUS.md](STATUS.md)。
|
||||
|
||||
## 6. 边界与非目标
|
||||
|
||||
@@ -0,0 +1,72 @@
|
||||
# 文稿与知识只读阅读:复用 Marqdo View
|
||||
|
||||
本文件是 MQDH 阅读桥的唯一实现合同。正文渲染、主题、公式、表格、代码、锚点、受限媒体与静态包格式由 `marqdo-view` 的公开 `export --embed` 合同负责;MQDH 只负责选中文稿、外部布局、导航、审批/运行/证据入口和同源服务。实现位于 `packages/marqdo/harness/src/reader/`。
|
||||
|
||||
## 1. 上游公开合同
|
||||
|
||||
View 候选(PR `marqdo-view#18`,`tools/view` 分支 `b1f92548`)提供:
|
||||
|
||||
```sh
|
||||
marqdo view export <doc.mq.md|doc.md> --out <dir> --embed \
|
||||
--theme light|dark --anchor <heading-id> --expect-source-sha256 <raw-lower-hex>
|
||||
```
|
||||
|
||||
`manifest.json` 的必核字段:
|
||||
|
||||
| 字段 | 要求 |
|
||||
| --- | --- |
|
||||
| `schema` / `schema_version` | `marqdo.view-export` / `1` |
|
||||
| `mode` | `embedded` |
|
||||
| `theme` | 与请求一致 |
|
||||
| `executed` | 必须为 `false` |
|
||||
| `requires` | `api_revision=1`、`analysis=3`、`observation=1`、`markdown_profile=marqdo.md.v1` |
|
||||
| `producers.view.binary_sha256` | 等于已安装 View 可执行文件的 SHA-256 |
|
||||
| `producers.cli.binary_sha256` | 等于当前 Runtime CLI 的 SHA-256(有值时) |
|
||||
| `pages[0].source_sha256` | 等于所选源文件的原始 SHA-256 |
|
||||
| `pages[0].source_status` | `static-ok` 或 `markdown-only` |
|
||||
| `entry.href` / `entry.file` | 包内相对入口,通常 `index.html` 或 `index.html#<anchor>` |
|
||||
| `entry.anchor` / `entry.heading_ids` | 与请求锚点一致;锚点必须在列表内 |
|
||||
| `files[]` / `assets[]` | 包内相对路径与 SHA-256,不得包含 `.js`/脚本 |
|
||||
|
||||
`--embed` 包只含 `index.html`、`assets/`(CSS/字体/logo)与受限 `media/`;MQDH 不生成、不解析、不覆盖这些文件。
|
||||
|
||||
## 2. 桥接层
|
||||
|
||||
`ReaderService` 对每个请求:
|
||||
|
||||
1. 解析源:工作区文件经 `resolveDocument`(拒绝绝对路径、越界、符号链接);知识源经 collection + relPath 校验,读取 `MQDH_HOME/knowledge/sources/<collection>/<rel>`。
|
||||
2. 读取已安装 Tool 的 `record.json`,定位 `bin/marqdo-view` 并计算 SHA-256;读取当前 Runtime CLI SHA-256。
|
||||
3. 缓存键 = `workspace root + 源相对路径 + 源摘要 + View 二进制摘要 + CLI 二进制摘要 + theme + anchor` 的 SHA-256。
|
||||
4. 缓存未命中时固定 argv 执行 `marqdo view export ...`,`cwd` 为工作区或知识 source root;`MARQDO_TOOL_HOME` 指向当前 Runtime 的隔离 Tool home。
|
||||
5. 校验 manifest、全部包文件摘要、入口文件、主题、锚点、源摘要与生产者摘要。
|
||||
6. 原子移动到 `MQDH_HOME/reader/packages/<id>/`,元数据写在 `<id>.json`;缓存命中不重新导出。
|
||||
|
||||
失败码:`reader.view_missing`、`reader.cli_missing`、`reader.source_invalid`、`reader.source_changed`、`reader.anchor_missing`、`reader.export_failed`、`reader.manifest_invalid`、`reader.package_missing`、`reader.package_invalid`、`reader.knowledge_source_missing`。
|
||||
|
||||
## 3. 同源服务与隔离
|
||||
|
||||
- `POST /mqdh/api/reader/open`:显式 `confirm:true`;只做静态检查与本地导出,不执行文稿。
|
||||
- `GET /mqdh/api/reader/source`:只读源文本,最多 256 KiB,不调用 View。
|
||||
- `GET /mqdh/api/reader/status`:View/CLI 可用性、版本与二进制摘要。
|
||||
- `GET /mqdh/api/reader/package/<id>/<path>`:只服务 manifest 列出的文件;拒绝越界、符号链接、未列出文件与超过 16 MiB 的单个文件。
|
||||
- HTML 包响应发送 `Content-Security-Policy: default-src 'none'; style-src 'self'; font-src 'self'; img-src 'self' data:; media-src 'self'; base-uri 'none'; form-action 'none'; frame-ancestors 'self'`。
|
||||
- 页面 iframe 固定 `sandbox="allow-same-origin"`,不开放脚本、表单或顶层导航;父页 CSP 只允许 `frame-src 'self'`。
|
||||
|
||||
## 4. 两处入口与降级
|
||||
|
||||
- **任务右侧文稿**:工作台“文稿阅读”页签输入工作区相对路径、主题与可选锚点;外层显示路径、View 版本/二进制摘要、manifest 摘要、源码切换与“运行记录”入口。运行、审批和证据仍走现有 `marqdo_program`/CLI 流程。
|
||||
- **知识命中详情**:搜索结果“在 View 阅读”使用同一桥接层、同一 View 制品与同一 iframe;collection、relPath、anchor 由知识命中提供,普通 Markdown 显示 `markdown-only`。
|
||||
- 缺 View / 缺 Runtime 时显示明确文字与恢复入口(生态中心安装 Tool);源变更、锚点缺失、manifest/摘要不匹配均返回结构化错误,不回退到第二套渲染器或静默显示旧包。
|
||||
|
||||
## 5. 不做的部分
|
||||
|
||||
- 不复制 View CSS、不写第二套 Markdown/公式/表格渲染器、不读取 View 私有文件路径。
|
||||
- 不把知识文本、外部链接或未知媒体当作可执行内容;不因阅读自动执行、安装或授权。
|
||||
- 不在 MQDH 内定义新的 View manifest 方言;只消费 `marqdo.view-export` 的公开字段。
|
||||
- 不把“View 包已生成”等同于“运行验收通过”;运行事实仍由 CLI Observation 1 与 MQDH 证据绑定。
|
||||
|
||||
## 6. 验收与限制
|
||||
|
||||
真实证据见 [evidence/2026-11-29-reader.md](evidence/2026-11-29-reader.md):候选 View 二进制 `ab353d09…`、rc.6、真实工作区 `.mq.md` 与知识 `.md`,Playwright 验证主题、公式、表格/代码横向滚动、本地图片、锚点、源码切换、知识命中入口、0 外部请求、0 页面错误。
|
||||
|
||||
未验证:正式 View Release 尚未包含 `--embed`,发布后需用同资产复验;企业代理/离线安装组合;Windows/macOS 包路径;完整 screen-reader/像素级主题走查。
|
||||
@@ -1,10 +1,14 @@
|
||||
# Marqdo Harness 文档
|
||||
|
||||
产品级 AI 可读入口:[index.mq.md](index.mq.md)(定位、架构地图、能力地图、任务导航、关键不变量与真实验收入口;先读这里)。本列表只是文档索引;唯一现状仍是 [STATUS.md](STATUS.md),领域细节只在各自权威文档维护。
|
||||
|
||||
| 文档 | 内容 |
|
||||
| --- | --- |
|
||||
| [index.mq.md](index.mq.md) | **产品入口(AI 可读)**:定位/上游隔离/架构与能力地图/任务导航/关键不变量/验收入口 |
|
||||
| [ARCHITECTURE.md](ARCHITECTURE.md) | 产品边界、包结构、数据布局、执行与安全模型 |
|
||||
| [ECOSYSTEM.md](ECOSYSTEM.md) | 生态目录的发现、浏览与安装边界 |
|
||||
| [MARKET.md](MARKET.md) | 动态来源、市场索引、用户级能力存储与项目导入合同 |
|
||||
| [READER.md](READER.md) | 复用 Marqdo View 的文稿/知识只读阅读桥与隔离合同 |
|
||||
| [NETWORK.md](NETWORK.md) | 默认出口、代理/镜像/离线、审计与拒绝码 |
|
||||
| [BOOTSTRAP.md](BOOTSTRAP.md) | 首次启动状态机、`doctor`/`repair`、离线与失败处理 |
|
||||
| [DIAGNOSTICS.md](DIAGNOSTICS.md) | 本地脱敏报告、去重/限额与显式 Issue 提交 |
|
||||
|
||||
@@ -4,16 +4,17 @@
|
||||
|
||||
## 1. 发布前
|
||||
|
||||
1. 责任提交已在 `main`,`docs/mqdh/STATUS.md` 与证据已更新。
|
||||
2. 同 SHA 的应用 CI 通过:`scripts/ci.sh`(含真实 Release 安装、Bootstrap、全部测试)与父仓候选组合。
|
||||
3. 版本在 `packages/marqdo/harness/package.json` 唯一维护;tag 必须是 `mqdh-v<version>`。
|
||||
4. 准备 Node 24 / pnpm 11 构建环境与 ≥ 12 GiB 临时空间(归档 + 解包 + 冷安装)。
|
||||
1. 责任提交已在 `main`,`docs/mqdh/STATUS.md` 与证据已更新;仓库必须已启用 Gitea Releases(`has_releases=true`)并公开。
|
||||
2. 同 SHA 的应用 CI 通过:`scripts/ci.sh`(含真实 Release 安装、Bootstrap、全部测试);发行证据中的 `ci`/资产摘要必须来自该提交。tag 触发的打包流水线可被后续 push 取消,但同 SHA push 流水线必须 success。
|
||||
3. 版本在 `packages/marqdo/harness/package.json` 唯一维护;tag 必须是 `mqdh-v<version>`,预发布后缀决定 `prerelease`。
|
||||
4. 记录实际测试运行时:打包时设置 `MQDH_CLI_SOURCE_SHA=<40 hex>`,该值进入 `release-evidence.json.dependencies`,供根 reconcile 校验与根 gitlink 一致。
|
||||
5. 准备 Node 24 / pnpm 11 构建环境与 ≥ 12 GiB 临时空间(归档 + 解包 + 冷安装)。
|
||||
|
||||
## 2. 构建
|
||||
|
||||
```sh
|
||||
pnpm install --frozen-lockfile
|
||||
pnpm run build
|
||||
DSH_CLIENT_TITLE="Marqdo Harness" pnpm run build
|
||||
MQDH_PACKAGE_WORK=/var/tmp/mqdh-package bash scripts/package.sh
|
||||
```
|
||||
|
||||
@@ -28,7 +29,23 @@ MQDH_PACKAGE_WORK=/var/tmp/mqdh-package bash scripts/package.sh
|
||||
| `release-evidence.json` | 构建身份、tag、签名状态、未验证项 |
|
||||
| `package-evidence.json` | 冷安装实测结果 |
|
||||
|
||||
## 3. 签名(可选但推荐)
|
||||
## 3. Windows x86_64 实验性构建
|
||||
|
||||
仅在真实 Windows + Node ≥ 24.22.3 上执行;产物**未签名**、尚无原生 Windows CI lane,因此按实验性分发,不进入 `mqdh-v<version>` 应用更新渠道:
|
||||
|
||||
```powershell
|
||||
pnpm install --frozen-lockfile --ignore-scripts
|
||||
$env:DSH_CLIENT_TITLE = "Marqdo Harness"
|
||||
pnpm run build
|
||||
$env:MQDH_NODE24_DIR = 'C:\path\to\node24'
|
||||
powershell -ExecutionPolicy Bypass -File .\scripts\package-windows.ps1 -RuntimeDeps C:\path\to\runtime-deps
|
||||
```
|
||||
|
||||
`-RuntimeDeps` 是一个受控离线运行时目录:其中 `marqdo-<version>-x86_64-pc-windows-msvc.tar.gz` 与 `.sha256` 必须来自组件仓的 Windows 运行时构建,包含 CLI、Provider Worker、`RELEASE_INFO.json`、`SOURCE_SHA` 与 Bundle;打包脚本会逐字节校验摘要并把该目录放进应用树的 `runtime-deps/`,由启动器在首次 bootstrap 时使用。
|
||||
|
||||
输出 `.ci/marqdo-harness-<version>-x86_64-pc-windows-msvc.tar.gz`、`.sha256`、`mqdh-release.json`、`release-evidence.json`、`package-evidence.json`。发布使用实验性 tag(例如 `mqdh-win-experimental-<date>`),不属于 `mqdh-v<version>` 更新渠道;不得用它替换 Linux 正式 tag 或声称 Windows 已 supported。升级路径:用户手动下载运行新 `install.ps1`;应用内 Windows 更新未验证。
|
||||
|
||||
## 4. 签名(可选但推荐)
|
||||
|
||||
```sh
|
||||
MQDH_RELEASE_PRIVATE_KEY=/secure/mqdh-release.key \
|
||||
@@ -50,6 +67,8 @@ MQDH_GITEA_TOKEN=... node scripts/release.ts ... --publish # 创建 tag/Release
|
||||
|
||||
脚本会:校验 manifest/source/版本/摘要/证据一致 → 确认 tag 尚不存在(发行不可变)→ 创建 Release(prerelease 依据版本后缀)→ 逐项上传资产。任何一步失败都不能重命名/覆盖已发布资产;修正后提升版本重新发布。
|
||||
|
||||
发布完成后由根仓 `scripts/reconcile-releases.py` 按应用发行契约独立核验(tag→完整 SHA、同 SHA CI、资产匿名逐字节回读、`dependencies` 与根 gitlink 一致);根接受记录与公开发行投影是另一层事实,不由应用发布自动推导。
|
||||
|
||||
## 5. 发布后验证
|
||||
|
||||
在干净用户/干净主机(无 Node/Rust/pnpm/源码)执行:
|
||||
@@ -64,7 +83,7 @@ cd marqdo-harness-<version>-x86_64-unknown-linux-gnu
|
||||
~/.local/opt/mqdh/bin/mqdh --dump-config
|
||||
```
|
||||
|
||||
再验证更新/回退:用上一个已发布版本安装 → `mqdh update check --json` → `mqdh update install --confirm` → 新版本启动 → `mqdh update rollback --confirm` → 旧版本启动且 `MQDH_HOME/ecosystem` 不变。证据记录应用 SHA、tag、平台、Node、命令、退出码、size/sha256、冷安装日志与已知限制。
|
||||
再验证更新/回退:用上一个已发布版本安装 → `mqdh update check --channel beta --json`(应读到本次 Release 的版本、资产摘要、发布说明与官方 URL)→ `mqdh update install --confirm` → 新版本启动 → `mqdh update rollback --confirm` → 旧版本启动且 `MQDH_HOME/ecosystem` 不变。自动安装按现行政策保持关闭;证据记录应用 SHA、tag、平台、Node、命令、退出码、size/sha256、冷安装日志与已知限制。
|
||||
|
||||
## 6. 失败与回滚
|
||||
|
||||
@@ -73,6 +92,19 @@ cd marqdo-harness-<version>-x86_64-unknown-linux-gnu
|
||||
- 已发布版本有缺陷:发布更高版本;不删除或重写旧资产。用户侧可 `mqdh update rollback --confirm`。
|
||||
- 签名错误:停止发布,轮换密钥并提升版本;不得重新上传同 tag。
|
||||
|
||||
## 7. 未验证
|
||||
## 7. 发布说明
|
||||
|
||||
生产签名证书/密钥托管、macOS/Windows 构建与公证、第二台干净主机、低于 2.39 glibc 的平台、真实断网更新与弱网大文件下载。以上保持 `UNVERIFIED`,不得写成 PASS。
|
||||
创建 Gitea Release 时填写的 body 是产品内 `mqdh update check` 展示的发布说明唯一来源(截断到 8 KiB);不要另建发布说明清单或第二份版本表。发布说明应包含用户可见变化、已知限制和升级注意项,且不得包含凭据、私有数据或未验证的 PASS 声明。
|
||||
|
||||
## 8. 未验证
|
||||
|
||||
生产签名证书/密钥托管、macOS 构建与公证、原生 Windows CI lane 与 Windows 应用内更新、第二台干净主机、低于 2.39 glibc 的平台、真实断网更新与弱网大文件下载。以上保持 `UNVERIFIED`,不得写成 PASS。
|
||||
### Windows 便携 ZIP(正式分发)
|
||||
|
||||
```powershell
|
||||
powershell -ExecutionPolicy Bypass -File .\scripts\package-windows-zip.ps1 `
|
||||
-AppArchive .ci\marqdo-harness-<version>-x86_64-pc-windows-msvc.tar.gz `
|
||||
-SourceSha <40hex> -OutDir .ci
|
||||
```
|
||||
|
||||
脚本从已验证应用归档解出应用树,移除 `install.ps1`/`mqdh.cmd`,加入 `MQDH.exe` 启动器与 `README-Windows.txt`,生成 `MQDH-<version>-win-x64.zip` 与 `.sha256`;随后冷解压运行 `MQDH.exe`,确认工作台 HTTP 200 且离线运行时已安装。启动器为 Windows GUI 子系统(无控制台窗口),只负责启动运行时和打开继承的 DSH UI,不是第二套应用壳。前端品牌化范围见 `marqdo-app-harness#25`(继承 DSH,仅少量品牌化)。
|
||||
@@ -1,6 +1,13 @@
|
||||
# Marqdo Harness 状态与门禁
|
||||
|
||||
本文件是 MQDH 现状的唯一产品状态来源。日期:2026-11-29。应用提交以 `git rev-parse HEAD` 为准;上游基线为 DSH `4b399c39a6d1479cd84ca591b4d7c88e24d38a96`(标签 `dsh-v0.2.3-alpha.2`)。证据目录见 [evidence/](evidence/)。
|
||||
本文件是 MQDH 现状的唯一产品状态来源。日期:2026-12-02。应用提交以 `git rev-parse HEAD` 为准;上游基线为 DSH `4b399c39a6d1479cd84ca591b4d7c88e24d38a96`(标签 `dsh-v0.2.3-alpha.2`)。证据目录见 [evidence/](evidence/)。
|
||||
|
||||
**当前公共 Beta:** `0.1.0-beta.1`(2026-12-02 发布,源 `0f63ced004be9a9de69f897c3385558dfd753287`,
|
||||
归档 `marqdo-harness-0.1.0-beta.1-x86_64-unknown-linux-gnu.tar.gz`,786,741,787 B,
|
||||
sha256 `68cbb8f878af47a44a8e0ff7625b647ff4b8ac5817cda02e0a31fdc658fdcd7d`,
|
||||
签名状态 `unsigned`)。根接受记录见主仓库
|
||||
`docs/release-acceptance/mqdh-linux-x86_64-0.1.0-beta.1.json`;下载入口 <https://marqdo.com/download/>。
|
||||
发行身份以 Gitea Release 资产为准,本文件只记录门禁状态。
|
||||
|
||||
状态定义:**PASS** 表示本仓库或本机真实命令已通过并记录;**PARTIAL** 表示实现存在且已覆盖主要路径,但门禁要求的一部分尚未验证;**UNVERIFIED** 表示未运行或环境不具备,不能当作通过;**FAIL** 表示真实失败。
|
||||
|
||||
@@ -29,7 +36,7 @@
|
||||
| E06 安装失败保留旧组合 | PASS | 坏版本/无候选不改变 `current.json`;下载/SHA/平台/解包失败清理 staging;`cleanup` 保护 active 与 rollback 目标。 |
|
||||
| E07 更新只影响新任务 | PARTIAL | 每次运行记录环境 ID 与 CLI 身份;尚未实现“活跃任务固定原环境”的会话级绑定。 |
|
||||
| E08 未知来源/扩权审批 | PASS(工具层) | `marqdo_program`/`marqdo_ecosystem` 通过 `ctx.approval.request` 一次一授权;模型不能提供 URL/argv/安装根;单位测试覆盖 argv/路径拒绝。审批 UI 的真实浏览器流程见 S06。 |
|
||||
| E09 通知与对账 | UNVERIFIED | 首版只在用户显式查询/安装时发现 release;应用更新检查(30 分钟缓存)不等于发行通知/对账。 |
|
||||
| E09 通知与对账 | PARTIAL | `update check` 已在真实公开 Release 上发现 `0.1.0-beta.1`(版本/资产摘要/发布说明/官方 URL 正确,`unsigned` 如实显示);后台定时通知、去重持久化与对账闭环仍未实现。 |
|
||||
| E10 应用/运行时独立升级 | PARTIAL | 安装时校验 Analysis 3 / Observation 1;协议不兼容会拒绝。尚无跨大版本阻塞 UI。 |
|
||||
|
||||
## 执行与文稿(P)
|
||||
@@ -70,11 +77,12 @@
|
||||
| S03 文件/进程/网络边界 | PARTIAL | 路径/符号链接/argv/进程组/超时/输出上限有测试;OS 级隔离依赖 DSH 沙箱,未声称强隔离。 |
|
||||
| S04 插件/profile 旁路 | PASS | `plugin-manager` 服务关闭;插件 market/manager 工具不可用;不是仅隐藏 UI。 |
|
||||
| S05 工作区隔离 | PARTIAL | 工作区显式且路径受控;未实现每任务独立目录与跨工作区审计。 |
|
||||
| S06 浏览器真实交互 | PARTIAL | 市场工作台已用 Playwright 真实浏览器覆盖刷新/详情/安装/启用/撤销/窄窗口/暗色;知识导入检索、执行审批与完整生态安装仍未在浏览器中运行。 |
|
||||
| S06 浏览器真实交互 | PARTIAL | 市场、View 阅读与五组生态目录已用 Playwright 真实浏览器覆盖刷新/详情/安装/启用/撤销/阅读/知识命中/键盘/窄窗口/暗色;知识导入与执行审批的完整浏览器流程仍未运行。 |
|
||||
| S07 诊断脱敏 | PASS(本地/替身) | 捕获→脱敏→本地报告→显式提交全链路由 `tests/diagnostics.test.ts` 覆盖;真实公网 Gitea 权限与模板未验证,见 DIAG-03/05。 |
|
||||
| S08 独立归档冷安装 | PASS(本机) | 归档内置 Node + `install.sh`;从归档冷安装后 `mqdh --version`、`doctor --json`、`--dump-config` 通过(见 m7 证据)。未在第二台干净主机验证。 |
|
||||
| S09 CI/真实模型/发布 | PARTIAL | `scripts/ci.sh` 与 `.woodpecker/ci.yml` 已实现;父仓 PR#48 的 Woodpecker pipeline 已运行并暴露/修复 candidate manifest bug,最终通过证据以 PR 为准。真实模型两轮验收 UNVERIFIED。 |
|
||||
| S08 独立归档冷安装 | PASS(发布审计) | 发布归档内置 Node + `install.sh`;从公开发布字节冷安装后 `mqdh --version`(0.1.0-beta.1)、`doctor --json`、`--dump-config` 通过,匿名回读 sha256 与发布证据一致。第二台干净主机仍 UNVERIFIED。 |
|
||||
| S09 CI/真实模型/发布 | PARTIAL | 发行提交 `0f63ced` 的独立 Woodpecker pipeline **#50 success**(clone/install/build/test,无根仓 checkout、无 CLI 编译);应用 Release 已发布并回读。真实模型两轮验收仍 UNVERIFIED。 |
|
||||
| S10 父仓组合验收 | PASS(父仓) | 父仓 Node app lane 使用同一 CLI/Bundle 候选;app optional,不阻塞 CLI 独立发行。 |
|
||||
| S11 产品级 AI 可读入口 | PASS(本仓) | `docs/mqdh/index.mq.md` 为产品层唯一入口,`docs/mqdh/README.md` 指向;39 个相对链接在提交前核对存在;上游隔离/STATUS 权威声明与关键不变量在入口可见。完整 `pnpm run doc-sync` 在本下游 fork 基线不通过(既有 `docs/mqdh/` 文档缺双语/单行段落规范),文档门禁保持 UNVERIFIED,不用入口 PASS 冒充文档 gate。 |
|
||||
|
||||
## 网络出口(NET)
|
||||
|
||||
@@ -94,7 +102,7 @@
|
||||
| BOOT-02 首次启动 Web 向导、真实进度、CLI bootstrap | PASS | `/mqdh/api/bootstrap` 与 `/mqdh` 页面实测;真实下载字节进度与步骤状态。 |
|
||||
| BOOT-03 断点/恢复/并发锁、失败回滚、离线包 | PARTIAL | staging 清理 + 单实例锁 + 失败不切换已实现并测试;离线目录安装已实现;真实弱网/断网与续传演练未运行。 |
|
||||
| BOOT-04 Knowledge/View 默认 Tool 安装与真实 smoke | PASS | knowledge v0.1.0-beta.3、view v0.3.0 安装成功;知识 compile/query hits=3;view 工具能力仍受上游接口限制(P09)。 |
|
||||
| BOOT-05 跨平台验证、repair、发布候选 | PARTIAL | `repair` 已实现并测试;macOS/Windows 引导未验证。 |
|
||||
| BOOT-05 跨平台验证、repair、发布候选 | PARTIAL | `repair` 已实现并测试;Windows 离线 bootstrap 已在本机真机验证(内置 `runtime-deps`,真实 check/call smoke=120),macOS 引导未验证。 |
|
||||
|
||||
## 诊断(DIAG)
|
||||
|
||||
@@ -102,34 +110,34 @@
|
||||
| --- | --- | --- |
|
||||
| DIAG-01 错误模型、捕获点、report schema、脱敏器 | PASS | `diagnostics.test.ts`:路径/secret/敏感键/cause chain 脱敏,写入前完成。 |
|
||||
| DIAG-02 `mqdh report` + `/mqdh` 报告页 + 预览/删除 | PASS | CLI/Web 路由与页面已实现;预览返回完整 title/body。 |
|
||||
| DIAG-03 Gitea Issue 提交、目标仓路由、模板、去重/限额 | PASS(替身) | 本地 Gitea 替身真实创建 Issue/评论、附件 multipart、小时限额;真实公网组织权限未验证。 |
|
||||
| DIAG-03 Gitea Issue 提交、目标仓路由、模板、去重/限额 | PASS(真实 Gitea + 替身) | 真实 Gitea 私有夹具创建 Issue/去重评论/404 失败路径已验证(`docs/evidence/2026-12-01-feedback-real-gitea-e2e.md`);替身覆盖附件 multipart 与小时限额。真实组织权限矩阵仍有限。 |
|
||||
| DIAG-04 离线队列、附件选择、结果回填 | PASS | `--offline` 入队;附件仅从报告目录读取;issue URL 回填索引。 |
|
||||
| DIAG-05 真实失败演练、负例/安全测试、发布证据 | PARTIAL | 真实 Bootstrap/知识/CLI 失败样本与公网提交演练未全部运行;不得写成 PASS。 |
|
||||
| DIAG-05 真实失败演练、负例/安全测试、发布证据 | PARTIAL | 已做真实 Gitea app-area 提交/去重/404/离线入队;真实 Bootstrap/知识/CLI 失败样本、附件真实上传与离线恢复全流程未全部运行,不得写成 PASS。 |
|
||||
|
||||
## 发行与更新(DIST)
|
||||
|
||||
| 门禁 | 状态 | 证据或限制 |
|
||||
| --- | --- | --- |
|
||||
| DIST-01 清单 schema、命名、tag/证据、Linux tar 冷安装 | PASS(本机) | `mqdh-release.json` + `.sha256` + `release-evidence.json`;归档 747 MB,内置 Node,冷安装/`doctor`/`dump-config` 通过;未发布。 |
|
||||
| DIST-01 清单 schema、命名、tag/证据、Linux tar 冷安装 | PASS(已发布) | `mqdh-v0.1.0-beta.1`:`mqdh-release.json` + `.sha256` + `release-evidence.json`(含 `cli@63562d8…` 运行时依赖);归档 786,741,787 B / sha256 `68cbb8f8…`;冷安装/`doctor`/`dump-config` 通过;未签名。 |
|
||||
| DIST-02 Linux `.deb`/AppImage、用户级安装/卸载 | PARTIAL | 用户级 `install.sh`/`--uninstall` 已实现并测试;`.deb`/AppImage 未构建。 |
|
||||
| DIST-03 macOS/Windows 构建与冷安装 | UNVERIFIED | 无签名/公证证书;不生成同名制品。 |
|
||||
| DIST-03 macOS/Windows 构建与冷安装 | PARTIAL | Windows x86_64 已提供正式便携 ZIP(`MQDH-<version>-win-x64.zip`:解压双击 `MQDH.exe`,无终端/安装脚本;冷解压 + 工作台 HTTP + 离线 bootstrap 已验证);未签名、无原生 Windows CI lane、应用内更新未验证;EXE 安装器/桌面集成/前端品牌化见 `#25`;macOS 无签名/公证证书,`UNVERIFIED`。 |
|
||||
| DIST-04 签名、SBOM、代理/镜像、离线安装 | PARTIAL | Ed25519 清单签名/验证与测试密钥通过;官方密钥、SBOM、离线应用更新未运行。 |
|
||||
| DIST-05 更新检查/安装/回退、通知与对账 | PARTIAL | `update check/install/rollback` 用本地发布服务器完成真实切换与回退;无可发布的真实 Release;通知/对账未实现。 |
|
||||
| DIST-05 更新检查/安装/回退、通知与对账 | PARTIAL | `update check` 对真实 Release 可用;`install/rollback` 仍只用本地发布服务器完成真实切换与回退;自动下载/安装按政策关闭,通知/对账未实现。 |
|
||||
|
||||
## 生态目录、局部调用与阅读(CAT)
|
||||
|
||||
| 门禁 | 状态 | 证据或限制 |
|
||||
| --- | --- | --- |
|
||||
| CAT-01 固定顺序 Runtime/Tool/Std/Ext/Knowledge 与真实来源 | PARTIAL | `/mqdh` 生态目录按固定顺序投影真实状态;Runtime 可显式切换,Tool 候选由市场来源驱动,Ext 市场/已安装/当前项目三段视图与 CLI 锁检查并存,Std 只随 Bundle。市场工作台浏览器/键盘/窄窗口/主题验收已通过;完整五组目录的浏览器遍历未运行。 |
|
||||
| CAT-01 固定顺序 Runtime/Tool/Std/Ext/Knowledge 与真实来源 | PASS | 固定五组同工作台浏览器回归:真实 rc.6 Runtime + Bundle 17 模块 + View Tool + 锁定 Ext 项目 + 私人知识集合;组顺序、真实状态、Knowledge 同集合入口、市场行键盘 Enter、窄窗口/暗色均通过,0 外部请求、0 page error。见 [目录证据](evidence/2026-11-29-catalog.md)。浏览器态 Runtime 缺失负例已通过(空 home 五组仍可用、0 mutating request);下载中断/候选校验失败浏览器负例仍为 UNVERIFIED。 |
|
||||
| CAT-02 打开、筛选、查看详情无自动安装/执行 | PASS | `/ecosystem` 只做本地状态与文件读取;候选检查、项目锁检查、Tool 移除均由按钮显式发起。 |
|
||||
| CAT-03 Ext 锁语义(声明/锁差异/权限) | PARTIAL | 应用不解析第二套依赖图;显示 `marqdo.yaml`/`marqdo.lock` 存在性与摘要,显式按钮调用 CLI `sync --locked --json`/`lock`,错误原文展示;项目导入由 CLI `add` 写声明。 |
|
||||
| CAT-04 真实浏览器与主题回归 | PASS(市场工作台) | Playwright Chromium 149 真实打开 `/mqdh`:无 page/console error、无外部请求、键盘焦点与 Enter 打开详情、420px 窄窗口、明/暗主题截图;证据见 [市场证据](evidence/2026-11-29-market.md#6-真实浏览器与主题回归)。完整五组目录的浏览器遍历仍属 CAT-01。 |
|
||||
| CAT-05 动态市场来源、缓存/变更探测、离线目录 | PASS | `market.test.ts` 覆盖默认来源、目录发现、new/changed/stale、TTL、来源隔离、摘要/链接拒绝;真实 Gitea 通过 topic 发现 knowledge/lint/view,prove 无资产如实 warning;离线刷新保留官方旧条目并标记 `offline`,目录来源仍 `ok`。见 [市场证据](evidence/2026-11-29-market.md)。 |
|
||||
| CAT-06 用户级能力存储、安装/激活、启用/撤销与模型可见性 | PASS | 能力载荷写入 `MQDH_HOME/capabilities/store`;Tool 注册到当前 Runtime 隔离 Tool home;未启用时 `visible=[]`,全局启用后出现,撤销后立即消失;安装/激活/导入/锁/卸载写审计。真实 rc.6 + view 0.3.0 已跑通。 |
|
||||
| CAT-07 安装→项目导入门禁与 CLI 锁 | PASS | 未安装返回 `extension.not_installed`;已安装 ext 复制到 `marqdo-vendor/<alias>` 后由 CLI `add` 写声明、CLI `lock` 生成锁、`sync --locked` 通过;应用不写锁。 |
|
||||
| CAT-07 安装→项目导入门禁与 CLI 锁 | PASS | 未安装返回 `extension.not_installed`;已安装 ext 复制到 `marqdo-vendor/<alias>` 后由 CLI `add` 写声明、CLI `lock` 生成锁、`sync --locked` 通过;应用不写锁。真实浏览器完成启用项目→导入→生成锁→卸载被引用拒绝。 |
|
||||
| CAT-08 更新/卸载与项目引用 | PASS | 新版本安装后 `pending_activation=true`、旧版本保持激活,显式 `activate` 才切换;被 `marqdo.yaml`/`marqdo.lock` 引用时卸载返回 `extension.project_referenced`,强制卸载需显式 `force`;运行证据绑定锁摘要,重新锁后旧证据 stale。 |
|
||||
| CAT-09 市场浏览器/键盘/窄窗口/暗色回归 | PASS | Playwright Chromium 149:刷新、详情、安装、启用当前项目、撤销、搜索无网络副作用;`market-refresh` 聚焦、行 Enter 打开详情;420px 窄窗口与 dark 媒体截图;0 external request、0 page error。 |
|
||||
| READER-01 文稿/知识复用 Marqdo View 只读阅读 | UNVERIFIED(上游阻塞) | 等待 `marqdo-view#16` 公开只读嵌入与主题身份、`marqdo-view#15` 结果绑定;应用不实现第二套 Markdown/主题。 |
|
||||
| READER-01 文稿/知识复用 Marqdo View 只读阅读 | PASS(候选 View) | 已接入 View PR #18 的公开 `export --embed`:静态包 manifest、View/CLI 二进制摘要、源摘要、锚点与包文件摘要全部校验;工作区 `.mq.md` 与知识 `.md` 共用同一桥接层/View 制品,iframe 仅 `allow-same-origin`,HTML CSP 禁止脚本/外部资源。Playwright 真实验证主题、公式、表格/代码滚动、本地图片、源码切换、知识命中入口、0 外部请求、0 页面错误;证据见 [reader 证据](evidence/2026-11-29-reader.md)。正式 View Release 尚未包含 `--embed`,发布后同资产复验仍待。 |
|
||||
| SCOPE-01 局部调用、规则审阅与跨会话复用 | UNVERIFIED | 依赖真实模型/浏览器、E07 环境固定与主仓 #28 的独立规则/预期;应用现有 `marqdo_program` 已提供固定 argv/审批/证据基础,但未做真实模型验收。 |
|
||||
|
||||
## 明确边界
|
||||
|
||||
|
After Width: | Height: | Size: 533 KiB |
|
After Width: | Height: | Size: 531 KiB |
|
After Width: | Height: | Size: 544 KiB |
@@ -0,0 +1,75 @@
|
||||
{
|
||||
"schema": "marqdo.mqdh.catalog-evidence",
|
||||
"schema_version": 1,
|
||||
"status": "PASS",
|
||||
"application_sha": "01afaf2ce44effabdc8b45ebe575f580687dbb20",
|
||||
"group_order": [
|
||||
"Runtime",
|
||||
"Tool",
|
||||
"Std",
|
||||
"Ext",
|
||||
"Knowledge"
|
||||
],
|
||||
"runtime": {
|
||||
"cli": "3.0.0-rc.6",
|
||||
"environment": "cli-3.0.0-rc.6-8dc0b006302e",
|
||||
"bundle": "0.2.0",
|
||||
"bundle_digest": "sha256:db905508dde89763b9d43b47fc5d52c6a1d5445a91f3c86a550ced43e8aac9d7",
|
||||
"modules": 17
|
||||
},
|
||||
"tool": {
|
||||
"command": "view",
|
||||
"version": "0.3.0",
|
||||
"binary_sha256": "ab353d09868e651cddf4b7bd774c8a7d241855499b6d34d2c01233898631237c"
|
||||
},
|
||||
"ext": {
|
||||
"capability": "local:ext:demo-ext",
|
||||
"version": "0.2.0",
|
||||
"manifest_digest": "sha256:1535a268f91b4707913e9c8cf812f7dac5e618297ed6027a51787c4233efa8b7",
|
||||
"lock_digest": "sha256:090f0eb2bcaa97064929574224c739b8be75909eda76bce91acb528eb4bf2138"
|
||||
},
|
||||
"knowledge": {
|
||||
"collection": "kc-ff2818c3b057",
|
||||
"sources": 1,
|
||||
"enabled": 1
|
||||
},
|
||||
"browser": {
|
||||
"engine": "Playwright Chromium 149.0.7827.55 (Playwright 1.61.1)",
|
||||
"external_requests": 0,
|
||||
"page_errors": 0,
|
||||
"keyboard": "row-button focus + Enter detail",
|
||||
"viewports": [
|
||||
"1280x900",
|
||||
"420x900"
|
||||
],
|
||||
"themes": [
|
||||
"light",
|
||||
"dark"
|
||||
],
|
||||
"screenshots": [
|
||||
"2026-11-29-catalog-wide-light.png",
|
||||
"2026-11-29-catalog-narrow-light.png",
|
||||
"2026-11-29-catalog-narrow-dark.png"
|
||||
]
|
||||
},
|
||||
"unverified": [
|
||||
"download-interruption/candidate-validation browser negatives",
|
||||
"full tool/project mutation browser confirmation",
|
||||
"keyboard-only traversal and screen-reader"
|
||||
],
|
||||
"empty_home_negative": {
|
||||
"runtime_missing": true,
|
||||
"groups_visible": [
|
||||
"Runtime",
|
||||
"Tool",
|
||||
"Std",
|
||||
"Ext",
|
||||
"Knowledge"
|
||||
],
|
||||
"reader_status": "unavailable: installed View Tool is required",
|
||||
"requests": 14,
|
||||
"external_requests": 0,
|
||||
"mutating_requests": 0,
|
||||
"page_errors": 0
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
# 2026-11-29 生态目录五组组合证据
|
||||
|
||||
状态:固定五组同工作台浏览器回归 **PASS**;Runtime 缺失/下载中断/候选校验失败等浏览器态负例仍为 **UNVERIFIED**(由单元/HTTP 测试与 STATUS 覆盖)。应用身份与 CI 结果见 [2026-11-29-reader-ci.json](2026-11-29-reader-ci.json) 的同一候选提交。
|
||||
|
||||
## 输入
|
||||
|
||||
| 层 | 真实身份 |
|
||||
| --- | --- |
|
||||
| Runtime | CLI `3.0.0-rc.6`,环境 `cli-3.0.0-rc.6-8dc0b006302e`,Bundle `0.2.0` / `sha256:db905508…` / 17 个模块 |
|
||||
| Tool | View 候选 `0.3.0`,二进制 SHA-256 `ab353d09…`,安装在当前 Runtime 隔离 Tool home |
|
||||
| Std | 当前 Bundle 的 `std:clock`、`std:io`、`std:data/*` 等公开导入路径 |
|
||||
| Ext | 当前工作区 `marqdo.yaml` + `marqdo.lock`;市场本地来源安装的 `local:ext:demo-ext@0.2.0` |
|
||||
| Knowledge | 私人集合 `kc-ff2818c3b057` / `阅读知识`,1 份原文,已启用 |
|
||||
|
||||
## 浏览器结果
|
||||
|
||||
Playwright Chromium `149.0.7827.55` 真实打开 `/mqdh`:
|
||||
|
||||
- `#catalog .group h3` 顺序严格为 `Runtime|Tool|Std|Ext|Knowledge`。
|
||||
- 每层都能回溯真实来源:Runtime 版本/平台/环境、Tool 版本与路径、Std 命名空间导入、Ext 项目文件摘要与市场条目、Knowledge 集合计数。
|
||||
- 点击 Knowledge“打开集合”进入同一知识页;市场列表行可用键盘聚焦,`Enter` 打开 `Demo ext` 详情。
|
||||
- 0 外部请求、0 page error;窄窗口 420px 与暗色主题截图如下。
|
||||
|
||||

|
||||
|
||||

|
||||
|
||||

|
||||
|
||||
## Runtime 缺失负例
|
||||
|
||||
空 `MQDH_HOME`(无 Runtime、无 Tool、无知识集合)真实浏览器打开 `/mqdh`:五组仍按顺序显示;Runtime “未安装”、Std “随 Runtime”、Ext 文件“缺失”、Knowledge “0 个集合”;阅读页显示“阅读不可用:installed View Tool is required…”;14 个请求全部同源 GET,0 外部请求、0 mutating request、0 page error。原 DSH 对话入口仍由同一 `/mqdh` 外的页面保留。
|
||||
|
||||
## 未完成
|
||||
|
||||
- 下载中断、候选校验失败在真实浏览器中的目录态负例(命令/单元层已覆盖失败保留旧组合)。
|
||||
- Tool 安装/移除、项目依赖变更的完整浏览器确认流程(命令层已由市场/导入测试覆盖)。
|
||||
- 完整 keyboard-only 走查与 screen-reader。
|
||||
@@ -68,7 +68,10 @@
|
||||
"install",
|
||||
"enable project scope",
|
||||
"local search",
|
||||
"disable all"
|
||||
"disable all",
|
||||
"with real Runtime: import via CLI add",
|
||||
"lock via CLI lock",
|
||||
"uninstall refused by project reference"
|
||||
],
|
||||
"page_errors": 0,
|
||||
"console_errors": 0,
|
||||
@@ -85,7 +88,8 @@
|
||||
"screenshots": [
|
||||
"2026-11-29-market-wide-light.png",
|
||||
"2026-11-29-market-narrow-light.png",
|
||||
"2026-11-29-market-narrow-dark.png"
|
||||
"2026-11-29-market-narrow-dark.png",
|
||||
"2026-11-29-market-import-refusal.png"
|
||||
],
|
||||
"status": "PASS"
|
||||
},
|
||||
|
||||
|
After Width: | Height: | Size: 658 KiB |
@@ -92,6 +92,10 @@ Playwright Chromium `149.0.7827.55`(Playwright `1.61.1`)在 `http://127.0.0.
|
||||
|
||||

|
||||
|
||||
带真实 Runtime 的第二轮浏览器流程:在“已安装”启用当前项目 → “导入项目(CLI add)”写入 `marqdo.yaml` 的 `./marqdo-vendor/demo` → “当前项目”点击“生成项目锁(CLI lock)”生成 `marqdo.lock` → 点击卸载返回 `extension.project_referenced`,能力保持安装。项目内副本、锁文件与拒绝结果均从页面按钮触发并落盘。
|
||||
|
||||

|
||||
|
||||
## 7. 未验证
|
||||
|
||||
- 真实浏览器、键盘遍历、窄窗口、亮/暗主题截图与回归;
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
{
|
||||
"schema": "marqdo.mqdh.ci-evidence",
|
||||
"schema_version": 1,
|
||||
"status": "PASS",
|
||||
"application_sha": "01afaf2ce44effabdc8b45ebe575f580687dbb20",
|
||||
"platform": "x86_64-unknown-linux-gnu",
|
||||
"node": "v24.22.3",
|
||||
"view": {
|
||||
"candidate": "marqdo-view#18",
|
||||
"source_sha": "b1f92548dc343435677747580806fbe58c5ab4ef",
|
||||
"binary_sha256": "ab353d09868e651cddf4b7bd774c8a7d241855499b6d34d2c01233898631237c",
|
||||
"command": "marqdo view export --embed --theme --anchor --expect-source-sha256"
|
||||
},
|
||||
"cli": {
|
||||
"version": "3.0.0-rc.6",
|
||||
"source_sha": "63776735e924ade279cdf59d5c733dc24bfdabbb",
|
||||
"binary_sha256": "4f12e6b8a2edb327c0d9ab6165f74e8e88a01b05350527e3aade6f52d4f7a06c"
|
||||
},
|
||||
"browser": {
|
||||
"engine": "Playwright Chromium 149.0.7827.55 (Playwright 1.61.1)",
|
||||
"theme": "dark/light",
|
||||
"math": 1,
|
||||
"image_natural_width": 1,
|
||||
"code_scroll": {
|
||||
"scrollWidth": 1716,
|
||||
"clientWidth": 353
|
||||
},
|
||||
"iframe_sandbox": "allow-same-origin",
|
||||
"external_requests": 0,
|
||||
"page_errors": 0,
|
||||
"knowledge_reader": "PASS",
|
||||
"screenshots": [
|
||||
"2026-11-29-reader-wide-dark.png",
|
||||
"2026-11-29-reader-narrow-dark.png",
|
||||
"2026-11-29-reader-narrow-light.png"
|
||||
]
|
||||
},
|
||||
"unverified": [
|
||||
"official View release with --embed",
|
||||
"enterprise proxy/offline View install",
|
||||
"Windows/macOS packaging",
|
||||
"full screen-reader and pixel theme review"
|
||||
],
|
||||
"remote_ci": {
|
||||
"push": "https://ci.cflmy.cn/repos/21/pipeline/21/1",
|
||||
"pull_request": "https://ci.cflmy.cn/repos/21/pipeline/22/1"
|
||||
},
|
||||
"commands": [
|
||||
"pnpm run typecheck",
|
||||
"node --import tsx/esm --test packages/marqdo/harness/tests/*.test.ts",
|
||||
"Playwright Chromium reader acceptance"
|
||||
]
|
||||
}
|
||||
|
After Width: | Height: | Size: 188 KiB |
|
After Width: | Height: | Size: 134 KiB |
|
After Width: | Height: | Size: 163 KiB |
@@ -0,0 +1,50 @@
|
||||
# 2026-11-29 View 只读阅读桥证据
|
||||
|
||||
状态:候选 View 真实阅读 **PASS**;正式 View Release 与跨平台 **UNVERIFIED**。应用身份与 CI 退出码见 [2026-11-29-reader-ci.json](2026-11-29-reader-ci.json)。
|
||||
|
||||
## 1. 输入与身份
|
||||
|
||||
| 输入 | 身份 |
|
||||
| --- | --- |
|
||||
| View 候选 | PR `marqdo-view#18`;`tools/view` 分支 `b1f92548dc343435677747580806fbe58c5ab4ef`;候选二进制 SHA-256 `ab353d09868e651cddf4b7bd774c8a7d241855499b6d34d2c01233898631237c` |
|
||||
| View 命令 | `marqdo view export <doc> --out <dir> --embed --theme light|dark --anchor <id> --expect-source-sha256 <hex>` |
|
||||
| CLI Runtime | `v3.0.0-rc.6`,source `63776735e924ade279cdf59d5c733dc24bfdabbb`,二进制 SHA-256 `4f12e6b8a2edb327c0d9ab6165f74e8e88a01b05350527e3aade6f52d4f7a06c` |
|
||||
| 平台 | `x86_64-unknown-linux-gnu`,glibc 2.43,Node `v24.22.3` |
|
||||
| 工作区文稿 | `reader.mq.md`:标题、宽表格、长代码块、公式、本地 1×1 PNG、`@exec main` |
|
||||
| 知识源 | collection `kc-ff2818c3b057` / `knowledge.md`:标题、引用、表格、公式;普通 Markdown |
|
||||
|
||||
View 候选 manifest 实测 `mode=embedded`、`executed=false`、`theme=dark`、`source_status=static-ok`,`producers.view.binary_sha256` 与上述候选二进制一致,`pages[0].source_sha256` 与源文件一致。
|
||||
|
||||
## 2. 桥接与失败路径
|
||||
|
||||
命令/服务已验证:
|
||||
|
||||
- 工作区阅读:`POST /mqdh/api/reader/open` → 固定 argv `marqdo view export ... --embed --theme dark --expect-source-sha256 ...` → 校验 manifest/36 个包文件摘要 → 返回 `index.html` 包 URL;第二次打开 `cached=true`。
|
||||
- 锚点:`anchor=表格` 返回 `index.html#%E8%A1%A8%E6%A0%BC`;`anchor=no-such-heading` 返回 `reader.anchor_missing`。
|
||||
- 知识阅读:同一桥接层打开 collection/relPath,manifest `source_status=markdown-only`,标题 ID 为 `知识文章`、`细节`。
|
||||
- 源切换:`GET /mqdh/api/reader/source` 返回原始文本与 `sha256:` 摘要,不调用 View。
|
||||
- 包文件:只服务 manifest 列出的文件;`index.html` 与 CSS 返回正确 content-type;未列出路径/越界/脚本路径拒绝。
|
||||
- 缺 View / 缺 Runtime / 源变更 / 摘要不符 / manifest 主题或生产者不符均有结构化错误,不回退第二套渲染器。
|
||||
|
||||
## 3. 真实浏览器
|
||||
|
||||
Playwright Chromium `149.0.7827.55`(Playwright `1.61.1`)真实打开 `/mqdh`:
|
||||
|
||||
- 工作区阅读 dark:`body[data-theme=dark]`,公式 `math` 1 个,本地图片 `naturalWidth=1`,420px 窄窗口下长代码块 `scrollWidth=1716 > clientWidth=353`,iframe `sandbox="allow-same-origin"`。
|
||||
- 嵌入正文无 `script`/`button`/`.mq-topbar`/`.mq-dock`;0 外部请求、0 page error。
|
||||
- 源码切换显示文稿原文;知识搜索命中“在 View 阅读”打开同一桥接层的知识包,正文包含“知识文章”。
|
||||
- 宽屏 dark、窄屏 dark、窄屏 light 截图:
|
||||
|
||||

|
||||
|
||||

|
||||
|
||||

|
||||
|
||||
## 4. 未验证
|
||||
|
||||
- View 正式 Release 尚未包含 `--embed`;发布后必须用同资产复验并记录 tag/资产 SHA。
|
||||
- 企业代理/离线包安装组合下的 View Tool 获取。
|
||||
- Windows/macOS 路径与打包。
|
||||
- 完整 screen-reader 与像素级主题走查。
|
||||
- View 独立阅读器与嵌入正文的自动化样式对比目前复用 View 自身 `embedded.browser.cjs` 的证据;MQDH 侧只断言同一主题、同一包和关键渲染结果。
|
||||
@@ -0,0 +1,18 @@
|
||||
# 产品级 AI 可读入口证据(app-harness#15 P1)
|
||||
|
||||
Date: 2026-11-30. Branch: `codex/issue-15-product-entry`. Baseline: `2aab24cccf986141e0622d34391b9d012d8b9f98`(main)。
|
||||
|
||||
## 交付(P1/P2 的首个切片)
|
||||
|
||||
- 新增 `docs/mqdh/index.mq.md`:产品层唯一 AI 可读入口,包含上游隔离声明、定位与承担/不承担边界、架构地图与能力地图(每项指向权威文档 + 真实实现目录)、任务导航表(开发启动/Bootstrap/工作台/文稿执行/阅读桥/私人知识/生态/诊断/发行更新/上游同步 → 必读、实现位置、验证入口)、关键不变量(凭证 0600、默认出口、一次一授权、不复制 Marqdo 源码、`MQDH_HOME` 与安装树分离、上游修改登记)、真实验收入口(`pnpm run build`、`MQDH_TEST_INSTALL=1 ... scripts/ci.sh`、`node scripts/mqdh.mjs doctor --json`、tag 上 `scripts/package.sh`)、阅读顺序与“唯一现状是 STATUS.md”的权威性声明。
|
||||
- `docs/mqdh/README.md` 顶部文档列表指向 `index.mq.md`,本入口不复制领域正文。
|
||||
- `docs/mqdh/STATUS.md` 新增 S11(PASS(本仓)),记录入口存在、链接核对与文档 gate 基线不通过的边界。
|
||||
|
||||
## 真实性与边界
|
||||
|
||||
- 入口只导航,不复制 `docs/mqdh/` 领域正文;不新增 AI 专用语法/元数据。
|
||||
- 未改上游文件:本次只新增/修改 `docs/mqdh/` 下游文档,不触发 `upstream-delta.md`;根 `README.md` 未改(其既有 downstream 段已指向 `docs/mqdh/`,本入口由该目录 README 指向)。
|
||||
- 链接在提交前用脚本核对真实存在(39 个相对链接,0 个缺失)。
|
||||
- 文档 gate:在本下游 fork 基线上运行 `pnpm run test:docs`(doc-quick)会失败,失败集合包含既有 `docs/mqdh/` 文档(缺双语 counterpart、单行段落格式等),并非本入口单独引入;完整 `pnpm run doc-sync` 因此保持 UNVERIFIED,不冒充 PASS。入口与证据文件已改为一行一段,减少新增 wrap 违例。
|
||||
- 未运行完整文档 gate;`scripts/ci.sh` 不含文档 gate,组件 CI 结果以平台为准记录。
|
||||
- `index.mq.md` 是导航级入口,不重复 STATUS 矩阵;STATUS 中 UNVERIFIED/PARTIAL 项保持原样。
|
||||
@@ -0,0 +1,22 @@
|
||||
# `mqdh status` 生态版本视图(app-harness#16 切片)
|
||||
|
||||
Date: 2026-11-30. Branch: `codex/issue-16-status-view`.
|
||||
Baseline: `a1517652c29ac51357275661a59e7814b596efc8`(main)。
|
||||
|
||||
## 交付
|
||||
|
||||
- 新增只读产品命令 `mqdh status [--json]`:一次输出应用版本/home/workspace、平台与 Node、运行时候选版本、生态环境 id、Bundle 版本/模块数/摘要、已安装 Tool 版本、market/knowledge 计数与 privacy 常量;JSON schema `marqdo.mqdh.status`(`schema_version: 1`)。
|
||||
- `scripts/mqdh.mjs` 的产品命令集合加入 `status`(避免落到 DSH 转发);HELP 更新。
|
||||
- `docs/mqdh/ARCHITECTURE.md` 产品命令列表更新。
|
||||
- 测试:`packages/marqdo/harness/tests/cli.test.ts` 新增 `status` JSON/文本断言(未安装生态时如实显示 not installed/false)。
|
||||
|
||||
## 验证(本机,Linux x86_64 / glibc 2.43)
|
||||
|
||||
```text
|
||||
$ node --import tsx/esm --test packages/marqdo/harness/tests/cli.test.ts
|
||||
6 pass, 0 fail
|
||||
```
|
||||
|
||||
该命令只读现有 `MdhRuntime.status()` 状态,不触发安装/网络/更新;不是 #16 的
|
||||
“最新版本/发布说明/下载入口”完整生态版本检查,那部分保持 UNVERIFIED。未运行
|
||||
完整组件测试,组件 CI 结果以平台为准。
|
||||
@@ -0,0 +1,27 @@
|
||||
# `mqdh status` 持久化更新视图(app-harness#16 切片)
|
||||
|
||||
Date: 2026-11-30. Branch: `codex/issue-16-status-update`.
|
||||
Baseline: `28df81ee11d2dccc0a1a2606394c477ff7b09987`(main)。
|
||||
|
||||
## 交付
|
||||
|
||||
- `MdhStatus` 新增 `update: UpdateState`(读取已持久化的更新状态,不触网);
|
||||
`MdhRuntime.status()` 返回它。
|
||||
- `mqdh status --json` 输出 `update` 字段;文本输出新增
|
||||
`update: channel=… checked=… available=… latest=… [error=…]`。
|
||||
- `DISTRIBUTION.md` §4 区分只读状态视图与显式 `update check`(后者才触网)。
|
||||
- 测试:`cli.test.ts` 断言空安装下 `update.schema`/`channel`/`checked_at`/
|
||||
`latest` 与文本行。
|
||||
|
||||
## 验证(本机,Linux x86_64 / glibc 2.43)
|
||||
|
||||
```text
|
||||
pnpm run typecheck → 5/5 PASS
|
||||
node --import tsx/esm --test packages/marqdo/harness/tests/cli.test.ts → 6 pass
|
||||
node --import tsx/esm --test packages/marqdo/harness/tests/*.test.ts → 77 pass / 3 skipped
|
||||
```
|
||||
|
||||
## 边界
|
||||
|
||||
- 只读持久化状态;不刷新、不提示、不下载、不安装,不执行 E09 通知/对账。
|
||||
- 未创建 release/tag;真实 Gitea 反馈提交与浏览器端到端仍 UNVERIFIED。
|
||||
@@ -0,0 +1,28 @@
|
||||
# 应用更新检查展示发布说明/官方下载/已知限制(app-harness#16 切片)
|
||||
|
||||
Date: 2026-11-30. Branch: `codex/issue-16-update-notes`.
|
||||
Baseline: `eceb13a70a723d8623cbf7f4b1b6979bdc303680`(main)。
|
||||
|
||||
## 交付
|
||||
|
||||
- `release/gitea.ts`:可信 Gitea Release 的 `body` 进入候选(截断 8192 字节,空值 null);`AppReleaseCandidate.notes` 与 `browser_url` 明确。
|
||||
- `distribution/updater.ts`:`UpdateCandidate` 新增 `notes` 与 `release_url`;持久化 `UpdateState.latest` 携带二者。
|
||||
- CLI `mqdh update check` 文本输出新增 `published`/`download`(官方资产 URL)/`release`(Release 页面)/`known limits`/`release notes`;JSON 已直接包含这些字段。
|
||||
- 文档:`DISTRIBUTION.md` §4 更新检查字段、`RELEASING.md` §7 发布说明唯一来源(Gitea Release body,不另建清单)。
|
||||
- 测试:`updater.test.ts` 的 fake Gitea Release 带 body,断言 `latest.notes` 与 `latest.release_url`。
|
||||
|
||||
## 验证(本机,Linux x86_64 / glibc 2.43)
|
||||
|
||||
```text
|
||||
node --import tsx/esm --test packages/marqdo/harness/tests/updater.test.ts
|
||||
3 pass, 0 fail
|
||||
node --import tsx/esm --test packages/marqdo/harness/tests/*.test.ts
|
||||
77 pass, 0 fail, 3 skipped
|
||||
pnpm run typecheck → 5 passed, 0 failed
|
||||
```
|
||||
|
||||
## 边界
|
||||
|
||||
- 发布说明来自可信 Release body,显示为数据;不执行、不解析为指令,不冒充“更新说明已验证”。
|
||||
- 仍不是完整生态(CLI/View/Tools/Bundle/Knowledge)的最新版本聚合;E09 通知/对账仍 UNVERIFIED。
|
||||
- 未创建 release/tag;未运行浏览器/真实 Gitea 端到端。
|
||||
@@ -0,0 +1,50 @@
|
||||
# 反馈提交真实 Gitea 端到端(app-harness#16 §9)
|
||||
|
||||
Date: 2026-12-01. Branch: `codex/issue-16-feedback-e2e`.
|
||||
环境:本机 Linux x86_64;真实 Gitea `git.cflmy.cn`;私有测试仓
|
||||
`cflmy/mqdh-feedback-e2e`(仅用于验收,不是产品仓);真实 token 只在本地
|
||||
git 忽略环境文件与进程环境,不写入仓库/日志/报告。
|
||||
|
||||
## 1. 真实链路
|
||||
|
||||
1. 在隔离 `MQDH_HOME` 中用产品运行时捕获一条脱敏诊断报告
|
||||
(area=`app`、code=`e2e.feedback_probe`,不含凭据/私有数据)。
|
||||
2. `mqdh report token --stdin` 保存 token 到私有凭据文件(0600)。
|
||||
3. `mqdh report submit <id> --repo cflmy/mqdh-feedback-e2e --confirm --json`
|
||||
通过真实 Gitea API 创建 Issue。
|
||||
|
||||
```json
|
||||
{
|
||||
"report_id": "2026-12-01-04-09-09-f990188d",
|
||||
"status": "submitted",
|
||||
"repository": "cflmy/mqdh-feedback-e2e",
|
||||
"issue_url": "https://git.cflmy.cn/cflmy/mqdh-feedback-e2e/issues/1",
|
||||
"comment": false,
|
||||
"attachments_uploaded": [],
|
||||
"attachment_errors": []
|
||||
}
|
||||
```
|
||||
|
||||
Issue #1 标题 `[app] e2e.feedback_probe: …`,正文含错误码/阶段/现象/预期、
|
||||
应用/平台/Node/运行时/Bundle/Tool 身份、本地报告 id 与脱敏环境;不含凭据值。
|
||||
|
||||
## 2. 负例与队列
|
||||
|
||||
- **重复指纹**:再次提交返回 `"status":"deduplicated"`、
|
||||
`issue_url` 同上、`"comment":true`,真实追加评论而非新建 Issue。
|
||||
- **无效/无权限仓库**:`--repo cflmy/definitely-missing-repo` 返回
|
||||
`Gitea API returned 404: not found`,退出码 1,不写回成功 URL。
|
||||
- **离线队列**:`--offline --confirm` 返回 `"status":"queued"`、`issue_url:null`;
|
||||
队列恢复提交仍需用户再次确认(CLI 设计),本轮未执行恢复。
|
||||
|
||||
## 3. 状态更新
|
||||
|
||||
- `DIAG-03` 从“PASS(替身)”更新为 **PASS(真实 Gitea + 替身)**:真实公网
|
||||
Gitea 创建 Issue/去重评论/404 失败路径已验证;测试仓为私有夹具。
|
||||
- `DIAG-05` 仍 **PARTIAL**:真实 Bootstrap/知识/CLI 失败样本与附件 multipart
|
||||
真实上传、离线恢复全流程未全部演练,不写成 PASS。
|
||||
|
||||
## 4. 边界
|
||||
|
||||
- 私有测试仓 `cflmy/mqdh-feedback-e2e` 仅作验收夹具;Issue #1 保留作为证据。
|
||||
- 未创建产品 tag/Release;未自动上传任何用户数据;token/报告不含凭据。
|
||||
@@ -0,0 +1,74 @@
|
||||
# Windows x86_64 实验性分发记录(2026-12-02)
|
||||
|
||||
Date: 2026-12-02.
|
||||
性质:**experimental(维护者批准的受限实验分发),不是受支持发行。**
|
||||
应用:Marqdo Harness(MQDH)`0.1.0-beta.1`
|
||||
源码:`marqdo-app-harness` 提交 `6b970439f52eb1a956fb70a4207f33048ef064c5`;
|
||||
DSH upstream `4b399c39a6d1479cd84ca591b4d7c88e24d38a96`。
|
||||
Release:https://git.cflmy.cn/cflmy/marqdo-app-harness/releases/tag/mqdh-win-experimental-2026-12-02
|
||||
|
||||
## 1. 为什么单独记录
|
||||
|
||||
官方 MQDH 发行渠道与平台矩阵此前只有 Linux x86_64;Windows 为 `UNVERIFIED`。
|
||||
按 marqdo#90 的 Windows 独立交付任务,本记录给出**首个可下载的 Windows 实验包**
|
||||
及其真实本机证据。它不改变 supported 平台声明、不进入 `mqdh-v<version>` 应用更新
|
||||
渠道,根仓也不把它纳入推荐组合;正式支持仍需原生 Windows CI lane、签名与更多验收。
|
||||
|
||||
## 2. 构建(Windows 11 开发机,真实执行)
|
||||
|
||||
```text
|
||||
OS/CPU Windows 11 10.0.22631, x86_64
|
||||
toolchain Node v24.22.3(内置到归档)、pnpm 11.28.5、MSVC 19.41 / VS 2022 17.11
|
||||
source app-harness 6b970439f52eb1a956fb70a4207f33048ef064c5
|
||||
build pnpm install --frozen-lockfile --ignore-scripts
|
||||
pnpm run build -> 10/10 gates PASS (746.63s)
|
||||
tests node --test packages/marqdo/harness/tests/{platform,release,install-root}.test.ts
|
||||
-> 10 passed / 0 failed
|
||||
package powershell -File scripts/package-windows.ps1
|
||||
(生产依赖 hoisted、去链接农场、内置 Node、生成本地安装器)
|
||||
```
|
||||
|
||||
## 3. 冷安装验证(从归档解压,不依赖源码/构建目录)
|
||||
|
||||
```text
|
||||
tar -xzf marqdo-harness-0.1.0-beta.1-x86_64-pc-windows-msvc.tar.gz
|
||||
powershell -File install.ps1 -Prefix <clean-prefix> -NoPath -NoShortcut
|
||||
-> installed Marqdo Harness 0.1.0-beta.1 (0.1.0-beta.1-6b970439f52e)
|
||||
<prefix>\bin\mqdh.cmd --version -> mqdh 0.1.0-beta.1
|
||||
<prefix>\bin\mqdh.cmd doctor --json -> schema=marqdo.mqdh.doctor,
|
||||
platform.target=x86_64-pc-windows-msvc,
|
||||
supported=true, node=v24.22.3,
|
||||
install_root=<prefix>
|
||||
<prefix>\bin\mqdh.cmd --dump-config -> PASS(1371 行,mqdh profile 条目存在)
|
||||
便携树 mqdh.cmd --version -> PASS
|
||||
```
|
||||
|
||||
`install.ps1` 生成 `current.json` 版本指针与 `bin\mqdh.cmd`;本机还验证了
|
||||
Windows 目录联接(junction)替代符号链接创建 MQDH profile 链接,从而在不启用
|
||||
Developer Mode 的普通账户下可启动 `mqdh` 与工作台。
|
||||
|
||||
## 4. 归档与资产身份
|
||||
|
||||
| 项 | 值 |
|
||||
| --- | --- |
|
||||
| 文件 | `marqdo-harness-0.1.0-beta.1-x86_64-pc-windows-msvc.tar.gz` |
|
||||
| 大小 / SHA256 | 684,093,946 bytes / `c647e13e5e4658facbc9c064c41b4b845fdf78121be38f786f8dfddb9da9bb9d` |
|
||||
| 内置 Node | v24.22.3,sha256 `86fc4785…` |
|
||||
| 发布清单 | `mqdh-release.json`:target `x86_64-pc-windows-msvc`、os `windows`、`min_glibc=null` |
|
||||
| 发布证据 | `release-evidence.json`、`package-evidence.json`(本 Release 资产) |
|
||||
| 签名 | `unsigned`(明确披露,不做假签名) |
|
||||
|
||||
## 5. 明确边界
|
||||
|
||||
- 未签名、无 OS 安装包签名/公证;SHA256 仅证明完整性。
|
||||
- 尚无原生 Windows CI lane;构建与冷安装证据来自维护者开发机。
|
||||
- 应用内 Windows 自动更新未验证;更新方式为手动下载并运行 `install.ps1`。
|
||||
- 真实模型服务 E2E、第二台干净 Windows 主机、workbench 浏览器截图验收未执行。
|
||||
- macOS/Linux aarch64 未包含;运行时不随包内置,由 `mqdh bootstrap` 从官方
|
||||
Marqdo Release 安装(CLI `v3.0.0-rc.7` 系列)。
|
||||
- 不支持删除/重写已发布资产;后续版本使用新的不可变 tag。
|
||||
|
||||
## 6. 跟踪
|
||||
|
||||
- Windows 支持与后续平台工作:marqdo-app-harness#2、marqdo#90(M6)。
|
||||
- 根仓接受/推荐:本次不进入推荐投影;由根仓按范围政策另行接受。
|
||||
@@ -0,0 +1,51 @@
|
||||
# Windows x86_64 正式便携 ZIP 记录(2026-12-03)
|
||||
|
||||
Date: 2026-12-03.
|
||||
性质:**正式便携分发形态(experimental 渠道)**;不是受支持平台声明,也不进入根推荐组合。
|
||||
Release:<https://git.cflmy.cn/cflmy/marqdo-app-harness/releases/tag/mqdh-win-portable-2026-12-03>
|
||||
|
||||
## 1. 发行事实
|
||||
|
||||
| 项 | 值 |
|
||||
| --- | --- |
|
||||
| 应用 | Marqdo Harness(MQDH)`0.1.0-beta.1` |
|
||||
| 源提交 | `0dd4bb5edf10d726cddefff78c4bdab1e1b43b8f`(已合入 `main` `9ccb6b38…`) |
|
||||
| 应用构建树 | `0d3a9c43…`(Windows 构建 + 内置离线运行时) |
|
||||
| 文件名 | `MQDH-0.1.0-beta.1-win-x64.zip` |
|
||||
| 大小 / SHA256 | 832,861,190 bytes / `9b090fb5fc0aec8179d67f8fc6bd1543dd3412474a0c582230d756643765c32f` |
|
||||
| 启动器 | `MQDH.exe`(Windows GUI 子系统,无控制台窗口),sha256 见 `package-evidence.json` |
|
||||
| 内置运行时 | `marqdo-3.0.0-rc.7-x86_64-pc-windows-msvc.tar.gz`,sha256 `182a07c7…`,源 `63562d8…`,Bundle `0.3.0` |
|
||||
| 发行证据 | `mqdh-release.json`、`release-evidence.json`、`package-evidence.json`、`.sha256` |
|
||||
|
||||
## 2. 用户路径
|
||||
|
||||
```text
|
||||
下载 ZIP -> 解压 -> 双击 MQDH.exe
|
||||
-> 启动器用 runtime-deps 离线 bootstrap(CLI/Worker/Bundle)
|
||||
-> 打开继承的 DSH Web UI(工作台 HTTP 200)
|
||||
退出:MQDH.exe --stop
|
||||
```
|
||||
|
||||
不需要终端、`install.ps1` 或分卷脚本;用户数据默认 `%LOCALAPPDATA%\MQDH\data`。
|
||||
|
||||
## 3. 验证证据(Windows 11 x64 开发机)
|
||||
|
||||
- 冷解压 ZIP(832,861,190 bytes,SHA256 匹配)→ 双击 `MQDH.exe`:
|
||||
- 启动器 PE subsystem = 2(Windows GUI,无控制台);
|
||||
- 首次启动离线 bootstrap 成功:环境 `cli-3.0.0-rc.7-182a07c798ef`,`source_sha 63562d8…`,Bundle `sha256:4e47b0ff…`;真实 `check`/`call` smoke = 120(见前序记录与内置 runtime 证据);
|
||||
- 工作台 `http://127.0.0.1:<port>/?token=…` 返回 HTTP **200**;
|
||||
- `workbench.url`、`launcher.pid` 写入用户 home;`--stop` 清理后台服务。
|
||||
- `package-evidence.json` 记录 ZIP/启动器/冷启动结果;`release-evidence.json` 记录源 SHA、CLI 依赖、格式 `portable-zip`。
|
||||
|
||||
## 4. 边界
|
||||
|
||||
- **未签名**;Windows SmartScreen 可能提示,需核对 SHA256。EXE 安装器、桌面/开始菜单集成、签名与原生 Windows CI lane 仍属于
|
||||
[marqdo-app-harness#25](https://git.cflmy.cn/cflmy/marqdo-app-harness/issues/25)。
|
||||
- **前端继承 DSH**:按维护者评审,本版只做少量品牌化(产品名/窗口标题;Logo/主题/图标等按 #25 落地),不新建或改版前端;当前入口是继承的 DSH Web UI。
|
||||
- Knowledge/View Tool 无 Windows 归档,bootstrap 显式 `skipped`;应用内 Windows 更新未验证;未做第二台干净主机验证。
|
||||
- 组件独立发行(marqdo#96/#102):只由 app-harness 本仓打包;CLI/Worker/Bundle 来自组件构建并校验;未触发根仓或其它组件构建。
|
||||
- 不进入根推荐组合;Linux 正式预发布另行接受。
|
||||
|
||||
## 5. 打包入口
|
||||
|
||||
`scripts/package-windows-zip.ps1`(正式入口):从已验证 Windows 应用归档解出应用树,移除 `install.ps1`/`mqdh.cmd`,加入 `MQDH.exe` 与 `README-Windows.txt`,写成单一下载 ZIP,并做冷解压启动验证。启动器源码 `scripts/launcher/MqdhLauncher.cs`,构建 `scripts/launcher/build-launcher.ps1`。
|
||||
@@ -0,0 +1,74 @@
|
||||
# Windows x86_64 可用实验版记录(2026-12-03)
|
||||
|
||||
Date: 2026-12-03.
|
||||
性质:**experimental(维护者批准的受限实验分发),不是受支持发行。**
|
||||
应用:Marqdo Harness(MQDH)`0.1.0-beta.1`
|
||||
源码:`marqdo-app-harness` 提交 `0d3a9c4369a49244b3405998fa62ee851550cd88`;
|
||||
DSH upstream `4b399c39a6d1479cd84ca591b4d7c88e24d38a96`。
|
||||
Release:https://git.cflmy.cn/cflmy/marqdo-app-harness/releases/tag/mqdh-win-experimental-2026-12-03
|
||||
|
||||
## 1. 本次目标与结果
|
||||
|
||||
上一版 Windows 实验包只能启动壳:`mqdh bootstrap` 需要从 CLI Release 发现
|
||||
`marqdo-<version>-x86_64-pc-windows-msvc.tar.gz` 运行时资产,而 CLI 只有 Linux
|
||||
正式发行。本版改为**应用自带离线运行时包**(`runtime-deps/`,组件构建产物),
|
||||
首次启动在无网络时完成运行时安装,并在 Windows 上真实执行文稿:
|
||||
|
||||
```text
|
||||
安装 -> mqdh bootstrap --json -> status=ready
|
||||
environment cli-3.0.0-rc.7-182a07c798ef
|
||||
source_sha 63562d8…, bundle sha256:4e47b0ff…
|
||||
platform x86_64-pc-windows-msvc
|
||||
smoke: 真实 check + call 阶乘(n=5) = 120
|
||||
doctor --json -> runtime installed
|
||||
```
|
||||
|
||||
## 2. 构建与打包(Windows 11 开发机)
|
||||
|
||||
```text
|
||||
toolchain Node v24.22.3、pnpm 11.28.5、MSVC 19.41 / VS 2022 17.11
|
||||
build pnpm install --frozen-lockfile --ignore-scripts
|
||||
pnpm run build -> 10/10 gates PASS (337.44s)
|
||||
tests node --test .../windows-runtime|execution|platform|install-root
|
||||
package powershell -File scripts/package-windows.ps1 \
|
||||
-RuntimeDeps <runtime-deps> # 内置 CLI Windows 运行时
|
||||
```
|
||||
|
||||
离线运行时包:`marqdo-3.0.0-rc.7-x86_64-pc-windows-msvc.tar.gz`
|
||||
(4,060,223 bytes,sha256 `182a07c7…`,源 `63562d8`,CLI + Worker + Bundle 0.3.0,
|
||||
含 `RELEASE_INFO.json`/`SOURCE_SHA`)。
|
||||
|
||||
## 3. 归档与冷安装证据
|
||||
|
||||
| 项 | 值 |
|
||||
| --- | --- |
|
||||
| 应用归档 | `marqdo-harness-0.1.0-beta.1-x86_64-pc-windows-msvc.tar.gz` |
|
||||
| 大小 / SHA256 | 688,136,852 bytes / `6bb1580c259563a6d791f9ae526ac3172463716e82a95d6c4b9507748cf58e34` |
|
||||
| 分卷 | `*.tar.gz.part1`–`part4`;合并后摘要一致 |
|
||||
| 冷安装 | `install.ps1` 用户级安装成功;`current.json` = `0.1.0-beta.1-0d3a9c4369a4` |
|
||||
| 便携启动器 | 解压树 `mqdh.cmd --version` = `mqdh 0.1.0-beta.1` |
|
||||
| bootstrap | `ready`;环境 `cli-3.0.0-rc.7-182a07c798ef`;`cli_path=marqdo.exe`、`worker_path=marqdo-provider-worker.exe`;smoke=120 |
|
||||
| doctor | `overall=warn`(knowledge/view Tool 缺 Windows 归档);runtime installed |
|
||||
| dump-config | PASS(1371 行,mqdh profile 条目存在) |
|
||||
|
||||
## 4. 代码修复点
|
||||
|
||||
- 应用树存在 `runtime-deps/` 时 `scripts/mqdh.mjs` 自动设置
|
||||
`MQDH_BOOTSTRAP_OFFLINE`(显式环境变量优先)。
|
||||
- 运行时安装使用平台化可执行名:Windows 为 `marqdo.exe` /
|
||||
`marqdo-provider-worker.exe`,并写入 `cli_path`/`worker_path`。
|
||||
- 离线归档名解析支持 `pc-windows-msvc` target(原正则只接受 `unknown` 中缀)。
|
||||
- 执行层文档路径包含判断改用 `path.relative`(Windows 分隔符下原
|
||||
`startsWith(root + '/')` 恒失败)。
|
||||
- `package-windows.ps1` 增加 `-RuntimeDeps`:逐字节校验运行时归档摘要并写入
|
||||
`package-evidence.json` 的 `bundled_runtime`。
|
||||
|
||||
## 5. 明确边界
|
||||
|
||||
- 未签名;无原生 Windows CI lane;应用内 Windows 更新未验证。
|
||||
- Knowledge/View Tool 无 Windows 归档,bootstrap 显式 `skipped`;工作台知识编译
|
||||
与 View 阅读能力暂不可用(locator 模式除外)。
|
||||
- 真实模型 E2E、第二台干净 Windows 主机、浏览器工作台截图验收未执行。
|
||||
- 不进入根推荐组合;Linux 平台正式预发布另行接受;扩展库仍为 planned,未随包分发。
|
||||
- 发行边界按 marqdo#96/#102:只在 app-harness 本仓构建,未重编译 CLI/Worker/
|
||||
Stdlib/Ext,不触发根仓或其它组件构建。
|
||||
@@ -0,0 +1,80 @@
|
||||
# @knowledge MQDH 产品入口
|
||||
|
||||
Marqdo Harness(MQDH)是 Marqdo 生态的官方单用户应用:安装并校验 Marqdo 运行时与默认 Bundle/Tools,通过公开 CLI 契约执行 `.mq.md` 文稿,维护私人本地知识,并保存可复核的运行证据。本文件是**产品层唯一的 AI 可读入口**:只做定位、导航、关键不变量与验收入口,不复制领域正文。
|
||||
|
||||
## 上游隔离
|
||||
|
||||
本仓库是 DeepSeek Harness(DSH)的下游 fork。**上游 DSH 文档不是 MQDH 产品规范**:产品规范只在本仓 `docs/mqdh/` 与本文。上游远端、许可与同步规则见 [UPSTREAM.md](UPSTREAM.md);对上游文件的每一处修改都必须登记在 [upstream-delta.md](upstream-delta.md)。不得重建/复制上游文档,不得把上游文档改成第二套产品规范;产品特化优先通过 bundle patch 与公开 seam 完成。
|
||||
|
||||
## 产品定位与边界
|
||||
|
||||
- 用户:希望在本地运行 Marqdo 文稿、复用 View 阅读、保存私人知识的单用户。
|
||||
- 本仓承担:应用壳与 `/mqdh` 工作台、首次启动 Bootstrap、生态安装/更新、文稿执行入口与审批、阅读桥、私人知识、诊断/反馈路由、发行打包、上游同步。
|
||||
- 本仓不承担:CLI/语言语义、默认 Bundle 内容、扩展业务实现、知识检索实现、文稿渲染与静态包格式(由 `marqdo-cli`、标准库/扩展仓、`marqdo-knowledge`、`marqdo-view` 等按各自合同提供);不提供多用户账号、遥测或静默上传。
|
||||
- 权威边界与包结构见 [ARCHITECTURE.md](ARCHITECTURE.md);生态安装边界见 [ECOSYSTEM.md](ECOSYSTEM.md)。
|
||||
|
||||
## 架构地图
|
||||
|
||||
- 唯一产品启动器:`scripts/mqdh.mjs`;唯一 profile `mqdh`(`packages/marqdo/bundle/`)。
|
||||
- 产品插件与服务:`packages/marqdo/harness/src/`,按能力分为 `bootstrap/`、`cli/`、`core/`、`diagnostics/`、`distribution/`、`ecosystem/`、`execution/`、`knowledge/`、`market/`、`network/`、`platform/`、`reader/`、`release/`、`tools/`、`version/`、`web/`、`workspace.ts`。
|
||||
- 首次启动状态机、`doctor`/`repair`:见 [BOOTSTRAP.md](BOOTSTRAP.md)。
|
||||
- `/mqdh` 工作台在 DSH 同一 loopback listener 上注册(`ctx.webServer.register`)。
|
||||
- 应用不携带 Marqdo CLI/Bundle/扩展/Tool 实现;它们从可信 Gitea 发布安装到 `MQDH_HOME`,安装布局与平台矩阵见 [DISTRIBUTION.md](DISTRIBUTION.md)。
|
||||
|
||||
## 能力地图(权威文档)
|
||||
|
||||
| 能力 | 权威文档 | 实现位置 |
|
||||
| --- | --- | --- |
|
||||
| 产品边界/数据布局/执行安全 | [ARCHITECTURE.md](ARCHITECTURE.md) | `packages/marqdo/harness/src/core/` |
|
||||
| 生态目录、浏览与安装边界 | [ECOSYSTEM.md](ECOSYSTEM.md) | `src/ecosystem/`、`src/market/`、`src/tools/` |
|
||||
| 阅读桥(复用 View 合同) | [READER.md](READER.md) | `src/reader/` |
|
||||
| 默认网络出口/代理/离线/审计 | [NETWORK.md](NETWORK.md) | `src/network/` |
|
||||
| 首次启动、离线与失败处理 | [BOOTSTRAP.md](BOOTSTRAP.md) | `src/bootstrap/` |
|
||||
| 本地脱敏报告与显式 Issue 提交 | [DIAGNOSTICS.md](DIAGNOSTICS.md) | `src/diagnostics/` |
|
||||
| 平台矩阵、安装布局、更新/回退 | [DISTRIBUTION.md](DISTRIBUTION.md) | `src/distribution/`、`src/release/` |
|
||||
| 构建、签名、发布与发布后验证 | [RELEASING.md](RELEASING.md) | `scripts/release-manifest.ts`、`scripts/release.ts` |
|
||||
| 上游远端、同步与许可 | [UPSTREAM.md](UPSTREAM.md) | `scripts/upstream.sh` |
|
||||
| 唯一现状与门禁矩阵 | [STATUS.md](STATUS.md) | 本仓证据(`docs/mqdh/evidence/`) |
|
||||
|
||||
## 任务导航
|
||||
|
||||
| 任务 | 必读 | 实现位置 | 验证 |
|
||||
| --- | --- | --- | --- |
|
||||
| 本地启动产品 | 本文、[ARCHITECTURE.md](ARCHITECTURE.md) | `scripts/mqdh.mjs` | `pnpm install && pnpm run build`;`node scripts/mqdh.mjs --version` |
|
||||
| 首次启动/Bootstrap | [BOOTSTRAP.md](BOOTSTRAP.md) | `src/bootstrap/`、`src/cli/` | `node scripts/mqdh.mjs bootstrap --json`、`doctor --json`、`repair --json` |
|
||||
| Web `/mqdh` 工作台 | [ARCHITECTURE.md](ARCHITECTURE.md) | `src/web/` | `pnpm run build` 后打开 `/mqdh`;状态见 [STATUS.md](STATUS.md) S06 |
|
||||
| 文稿执行与审批 | [ARCHITECTURE.md](ARCHITECTURE.md)、[STATUS.md](STATUS.md) P 组 | `src/execution/` | `scripts/ci.sh` 的下游测试;真实浏览器审批见 STATUS |
|
||||
| 阅读桥 | [READER.md](READER.md) | `src/reader/` | `scripts/ci.sh`;View 导出合同回归按 STATUS P09 |
|
||||
| 私人知识 | [ARCHITECTURE.md](ARCHITECTURE.md) | `src/knowledge/` | `scripts/ci.sh`;状态见 [STATUS.md](STATUS.md) K 组 |
|
||||
| 生态目录/安装 | [ECOSYSTEM.md](ECOSYSTEM.md)、[MARKET.md](MARKET.md) | `src/ecosystem/`、`src/market/`、`src/tools/` | `node scripts/mqdh.mjs bootstrap --json`;`scripts/ci.sh` |
|
||||
| 诊断与反馈 | [DIAGNOSTICS.md](DIAGNOSTICS.md) | `src/diagnostics/` | `node scripts/mqdh.mjs report list`;`report submit --confirm` 需显式同意 |
|
||||
| 发行与更新 | [DISTRIBUTION.md](DISTRIBUTION.md)、[RELEASING.md](RELEASING.md) | `src/distribution/`、`src/release/` | `node scripts/mqdh.mjs update check --json`;tag 上 `bash scripts/package.sh` |
|
||||
| 上游同步 | [UPSTREAM.md](UPSTREAM.md)、[upstream-delta.md](upstream-delta.md) | `scripts/upstream.sh` | `bash scripts/upstream.sh report`;`candidate <sha>` 仅在真实同步时使用 |
|
||||
|
||||
## 关键不变量(安全)
|
||||
|
||||
- 凭证只存 `MQDH_HOME/config/credentials.json`(0600);不得写入仓库、日志、诊断报告或模型上下文。诊断/反馈不含凭据、私有知识正文、用户文件或完整会话。
|
||||
- 唯一默认网络出口:所有自有出站按 [NETWORK.md](NETWORK.md) 经受控代理/镜像/离线策略;运行时模块不得各自 `fetch`。
|
||||
- 审批一次一授权:文稿执行与生态变更通过 `ctx.approval.request`,模型不能提供 URL/argv/安装根。
|
||||
- 应用不复制 Marqdo 生产源码;运行时/Bundle/Tool 来自可信发布安装。
|
||||
- `MQDH_HOME` 与安装树分离;更新只影响新任务,回退目标受保护。
|
||||
- 对上游文件的修改必须记录在 [upstream-delta.md](upstream-delta.md),并优先使用公开 seam。
|
||||
- 不建第二套产品规范、包管理、反馈后端或渲染器:正文只在权威文档维护,本文只导航。
|
||||
|
||||
## 真实验收入口
|
||||
|
||||
```sh
|
||||
pnpm install --frozen-lockfile
|
||||
pnpm run build
|
||||
MQDH_TEST_INSTALL=1 MARQDO_CI_OUT=.ci bash scripts/ci.sh
|
||||
node scripts/mqdh.mjs --version
|
||||
node scripts/mqdh.mjs doctor --json
|
||||
bash scripts/package.sh # tag/发行构建时;含冷安装与 package-evidence.json
|
||||
```
|
||||
|
||||
- 仓库 CI:`.woodpecker/ci.yml`(install/build/test/package;package 仅 tag)。
|
||||
- 状态与证据:唯一现状是 [STATUS.md](STATUS.md),逐项命令/SHA/摘要见 [evidence/](evidence/)。本入口不复制矩阵、不把 UNVERIFIED 写成 PASS。
|
||||
|
||||
## 阅读顺序
|
||||
|
||||
本入口 → [STATUS.md](STATUS.md)(现状)→ [ARCHITECTURE.md](ARCHITECTURE.md)(边界)→ 对应能力的权威文档 → `packages/marqdo/harness/src/` 实现 → 对应测试/`docs/mqdh/evidence/`。新增文档只加入 [README.md](README.md) 的列表,不在此复制正文。
|
||||
@@ -5,9 +5,10 @@
|
||||
| 路径 | 修改 | 原因 | 能否使用公开 seam | 测试 | 上游 Issue/PR | 移除条件 |
|
||||
| --- | --- | --- | --- | --- | --- | --- |
|
||||
| `.github/workflows/*`(发布/上传/桌面打包/Cloudflare/Pages 共 18 个) | 删除 | 防止下游误用官方发布凭证与上传路径;Gitea/Woodpecker 是下游 CI 权威 | 不需要 | 仓库内无这些 workflow;`grep` 审计 | 无(下游发布策略) | 上游发布机制被下游显式复用时重新评估 |
|
||||
| `tsdown.config.ts` | 从 workspace bundle 列表排除 `packages/marqdo/*` | 下游包以 TypeScript 源码由 Node 24 原生类型剥离执行,没有 `lib/types` 产物 | 上游 workspace 配置即公开构建入口 | `pnpm run build` 10/10 gates PASS | 无 | 下游包改为产出 `lib/types` 时 |
|
||||
| `tsdown.config.ts`、`tsconfig.client.json` | 服务端产品包由 Node 原生执行,`@marqdo/mqdh-ui` 使用上游 Client 构建 | 产品浏览器插件通过现有动态模块加载器交付 | 使用同一个 `clientBundle` preset | `pnpm run build:artifacts`、`pnpm run build:check` | 无 | 上游自动识别非标准包组的构建类型时 |
|
||||
| `apps/cli/package.json` | 增加 `@deepseek-ai/cordis-plugin-group` 运行时依赖 | app-boot 将其列为 peer;生产部署闭包需要它 | 上游依赖声明 | `pnpm install --frozen-lockfile`;部署 smoke | 可作为通用打包修复回馈 | 上游把该 peer 改为直接依赖 |
|
||||
| `packages/marqdo/harness`、`packages/marqdo/bundle`、`scripts/mqdh.mjs`、`docs/mqdh` | 新增下游产品代码与文档 | Marqdo Harness 产品能力 | 新包,不改上游 | `scripts/ci.sh` | 无 | 不适用 |
|
||||
| `packages/client/ui-sidebar/src/client/SidebarRoot.tsx` | 为导航行提供 `data-panel-entry` | MQDH 按稳定 ID 设置 Marqdo 选中态,侧栏继续负责交互和布局 | 复用原有组件及选中态 token | Chromium 整页核对浅深色与键盘导航 | 无 | 上游提供导航行样式入口时 |
|
||||
|
||||
## 未修改但依赖的上游 seam
|
||||
|
||||
@@ -15,5 +16,6 @@
|
||||
- `ctx.approval.request`:文稿执行与生态变更的一次性授权。
|
||||
- `ctx.systemPrompt.section`:产品提示词段落。
|
||||
- `ctx.webServer.register`:`/mqdh` 工作台与 JSON API。
|
||||
- `sidebar.brand.mark`、`sidebar.brand.name`、`conversation.hero.brand.mark`、`sidebar.panellist` 和 `main` 槽:产品品牌、只读插件列表及 Marqdo 生态工作台。
|
||||
- `ctx.provide('mqdhRuntime')`:host 与 web 半部共享运行时。
|
||||
- profile/bundle 的 `dsh.bundle.patch`:唯一产品组合入口。
|
||||
@@ -69,7 +69,7 @@ function PanelRow({
|
||||
const active = usePanelInfo(info => info.activePanelId === id)
|
||||
const trailing = useId()
|
||||
return (
|
||||
<div className={clsx(css.panelEntry, wide && css.panelEntryWide, active && css.panelEntryActive)}>
|
||||
<div data-panel-entry={id} className={clsx(css.panelEntry, wide && css.panelEntryWide, active && css.panelEntryActive)}>
|
||||
<Tooltip label={label} delayMs={500} disabled={wide}>
|
||||
<button
|
||||
type="button"
|
||||
|
||||
@@ -36,6 +36,8 @@
|
||||
# Product UI surfaces that imply unsupported installation/session upload.
|
||||
- id: ui-plugin-manager
|
||||
disabled: true
|
||||
- id: ui-brand-official
|
||||
disabled: true
|
||||
- id: ui-agent-preset
|
||||
disabled: true
|
||||
- id: ui-settings-session-log
|
||||
@@ -72,6 +74,9 @@
|
||||
workspace: !!js process.env.MQDH_WORKSPACE
|
||||
maxRunMs: 300000
|
||||
|
||||
- id: mqdh-ui
|
||||
name: '@marqdo/mqdh-ui'
|
||||
|
||||
- id: mqdh-web
|
||||
name: '@marqdo/mqdh-harness/web'
|
||||
config:
|
||||
|
||||
@@ -17,7 +17,8 @@
|
||||
}
|
||||
},
|
||||
"dependencies": {
|
||||
"@marqdo/mqdh-harness": "workspace:*"
|
||||
"@marqdo/mqdh-harness": "workspace:*",
|
||||
"@marqdo/mqdh-ui": "workspace:*"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
|
||||
@@ -4,6 +4,8 @@ Marqdo Harness product services as one Cordis plugin (host half) plus the `/mqdh
|
||||
|
||||
## Surface
|
||||
|
||||
The left sidebar’s **Marqdo** entry opens the existing workbench in the main panel on its Ecosystem tab. The standalone `/mqdh` URL remains available. Its embedded view uses the same routes and allows framing by its own origin. The embedded workbench follows the shell’s active color scheme. The standalone page follows the browser’s color scheme. The adjacent **Plugins** entry displays the Host inventory with read-only access.
|
||||
|
||||
- `src/index.ts` — `mqdh-harness` plugin: provides `mqdhRuntime`, registers six tools, adds one product prompt section.
|
||||
- `src/web/index.ts` — `mqdh-web` plugin: `/mqdh` page, CSS/JS and same-origin JSON API over `ctx.webServer`.
|
||||
- `src/core/` — home layout, atomic files, lock, bounded process, safe tar, Observation 1, ValueWire.
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2026 Marqdo contributors
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
|
After Width: | Height: | Size: 353 KiB |
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64"><path fill="#343f22" d="M8 8v45l9-5V27l15 12 15-12v21l9 5V8L32 28z"/><path fill="#c59a55" d="m8 8 24 20L56 8 32 38z"/><path fill="#fcf9f4" d="m19 17 13 11 13-11-13 17z"/><path fill="#c59a55" d="m27 49 5-5 5 5-5 7z"/></svg>
|
||||
|
After Width: | Height: | Size: 282 B |
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@marqdo/mqdh-harness",
|
||||
"version": "0.1.0",
|
||||
"version": "0.1.0-beta.1",
|
||||
"description": "Marqdo Harness product services: ecosystem transactions, document-native execution, private knowledge and the /mqdh workbench",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
|
||||
@@ -289,9 +289,12 @@ function envOffline(): string | undefined {
|
||||
}
|
||||
|
||||
/** Extract kind/version/target from a component archive name. */
|
||||
function archiveIdentity(name: string): { kind: ArchiveKind; version: string; target: string } | null {
|
||||
const match = /^marqdo(?:-(knowledge|view|lint|prove))?-(\d+\.\d+\.\d+(?:-[0-9A-Za-z.]+)?)-([a-z0-9_]+-unknown-[a-z0-9-]+)\.tar\.gz$/
|
||||
.exec(name)
|
||||
export function parseArchiveIdentity(name: string): { kind: ArchiveKind; version: string; target: string } | null {
|
||||
const pattern = new RegExp(
|
||||
'^marqdo(?:-(knowledge|view|lint|prove))?-(\\d+\\.\\d+\\.\\d+(?:-[0-9A-Za-z.]+)?)-'
|
||||
+ '([a-z0-9_]+-(?:unknown|pc)-[a-z0-9-]+)\\.tar\\.gz$',
|
||||
)
|
||||
const match = pattern.exec(name)
|
||||
if (!match) return null
|
||||
const kind = (match[1] ?? 'cli') as ArchiveKind
|
||||
return { kind, version: match[2] ?? '', target: match[3] ?? '' }
|
||||
@@ -660,7 +663,7 @@ export class BootstrapManager {
|
||||
if (entries === undefined) throw new BootstrapError('bootstrap.offline_missing', `offline directory is not readable: ${directory}`)
|
||||
const match = entries
|
||||
.flatMap((name) => {
|
||||
const identity = archiveIdentity(name)
|
||||
const identity = parseArchiveIdentity(name)
|
||||
return identity !== null && identity.kind === 'cli' && identity.target === target ? [{ name, ...identity }] : []
|
||||
})
|
||||
.sort((left, right) => compareVersions(right.version, left.version))[0]
|
||||
@@ -699,7 +702,7 @@ export class BootstrapManager {
|
||||
const entries = await readdir(directory).catch(() => [] as string[])
|
||||
const match = entries
|
||||
.flatMap((name) => {
|
||||
const identity = archiveIdentity(name)
|
||||
const identity = parseArchiveIdentity(name)
|
||||
return identity !== null && identity.kind === component && identity.target === target ? [{ name, ...identity }] : []
|
||||
})
|
||||
.sort((left, right) => compareVersions(right.version, left.version))[0]
|
||||
|
||||
@@ -146,6 +146,7 @@ Usage: mqdh <command> [options]
|
||||
|
||||
Commands:
|
||||
bootstrap [--channel stable|beta] [--offline <dir>] [--force] [--json]
|
||||
status [--json]
|
||||
doctor [--json]
|
||||
repair [--json]
|
||||
report list|show|export|submit|delete|token [...]
|
||||
@@ -187,6 +188,8 @@ export async function runProductCli(argv: readonly string[], options: CliOptions
|
||||
switch (parsed.command) {
|
||||
case 'bootstrap':
|
||||
return await runBootstrap(parsed, io, runtime)
|
||||
case 'status':
|
||||
return await runStatus(parsed, io, runtime)
|
||||
case 'doctor':
|
||||
return await runDoctor(parsed, io, runtime)
|
||||
case 'repair':
|
||||
@@ -241,6 +244,48 @@ async function runBootstrap(parsed: ParsedCommand, io: CliIO, runtime: () => Pro
|
||||
return state.status === 'failed' ? 1 : 0
|
||||
}
|
||||
|
||||
/** `mqdh status`: one read-only ecosystem/app version view. */
|
||||
async function runStatus(parsed: ParsedCommand, io: CliIO, runtime: () => Promise<MdhRuntime>): Promise<number> {
|
||||
expectNoSubcommand(parsed)
|
||||
allowFlags(parsed, ['json'])
|
||||
const app = await runtime()
|
||||
const status = await app.status()
|
||||
if (booleanFlag(parsed, 'json')) {
|
||||
io.stdout(json({
|
||||
schema: 'marqdo.mqdh.status',
|
||||
schema_version: 1,
|
||||
app: { version: APP_VERSION, home: status.home, workspace: status.workspace },
|
||||
platform: status.platform,
|
||||
node: status.node,
|
||||
ecosystem: status.ecosystem,
|
||||
market: status.market,
|
||||
knowledge: status.knowledge,
|
||||
privacy: status.privacy,
|
||||
update: status.update,
|
||||
}))
|
||||
return 0
|
||||
}
|
||||
const environment = status.ecosystem.current
|
||||
const version = environment ? `${environment.version} (${environment.id})` : 'not installed'
|
||||
const tools = status.ecosystem.tools.length === 0
|
||||
? 'none'
|
||||
: status.ecosystem.tools.map(tool => `${tool.command} ${tool.version ?? 'unknown'}`).join(', ')
|
||||
io.stdout([
|
||||
`app: ${APP_VERSION} home: ${status.home}`,
|
||||
`workspace: ${status.workspace}`,
|
||||
`platform: ${status.platform} node: ${status.node}`,
|
||||
`runtime: ${status.ecosystem.runtime.version ?? 'not installed'}`,
|
||||
`environment: ${version}`,
|
||||
`bundle: ${status.ecosystem.std.version ?? 'not installed'} modules=${status.ecosystem.std.modules.length} digest=${status.ecosystem.std.digest ?? 'n/a'}`,
|
||||
`tools: ${tools}`,
|
||||
`market: entries=${status.market.entries} installed=${status.market.installed} enabled=${status.market.enabled}`,
|
||||
`knowledge: collections=${status.knowledge.collections} sources=${status.knowledge.sources} enabled=${status.knowledge.enabled}`,
|
||||
`privacy: telemetry=${String(status.privacy.telemetry)} session_upload=${String(status.privacy.sessionUpload)} plugin_install=${String(status.privacy.pluginInstall)}`,
|
||||
`update: channel=${status.update.channel} checked=${status.update.checked_at ?? 'never'} available=${String(status.update.update_available)} latest=${status.update.latest?.version ?? 'unknown'}${status.update.last_error === null ? '' : ` error=${status.update.last_error.code}`}`,
|
||||
].join('\n') + '\n')
|
||||
return 0
|
||||
}
|
||||
|
||||
/** `mqdh doctor`. */
|
||||
async function runDoctor(parsed: ParsedCommand, io: CliIO, runtime: () => Promise<MdhRuntime>): Promise<number> {
|
||||
expectNoSubcommand(parsed)
|
||||
@@ -389,6 +434,14 @@ async function runUpdate(parsed: ParsedCommand, io: CliIO, runtime: () => Promis
|
||||
`channel: ${state.channel}`,
|
||||
`latest: ${state.latest?.version ?? 'none'}${state.latest === null ? '' : ` (${state.latest.signature})`}`,
|
||||
`update available: ${String(state.update_available)}`,
|
||||
...(state.latest === null ? [] : [
|
||||
`published: ${state.latest.published_at}`,
|
||||
`download: ${state.latest.asset.url}`,
|
||||
`release: ${state.latest.release_url}`,
|
||||
...(state.latest.known_limits.length === 0 ? [] : ['known limits:']),
|
||||
...state.latest.known_limits.map(limit => ` - ${limit}`),
|
||||
...(state.latest.notes === null ? [] : ['release notes:', ...state.latest.notes.split('\n').map(line => ` ${line}`)]),
|
||||
]),
|
||||
...(state.last_error === null ? [] : [`error: ${state.last_error.code}: ${state.last_error.message}`]),
|
||||
].join('\n') + '\n')
|
||||
}
|
||||
|
||||
@@ -49,6 +49,10 @@ export interface MdhLayout {
|
||||
readonly capabilityStore: string
|
||||
readonly capabilityStaging: string
|
||||
readonly capabilityAudit: string
|
||||
/** Read-only View reader package cache. */
|
||||
readonly reader: string
|
||||
readonly readerPackages: string
|
||||
readonly readerStaging: string
|
||||
/** Private knowledge root. */
|
||||
readonly knowledge: string
|
||||
/** Imported original knowledge documents. */
|
||||
@@ -101,6 +105,9 @@ export function layoutOf(home: string): MdhLayout {
|
||||
capabilityStore: join(root, 'capabilities', 'store'),
|
||||
capabilityStaging: join(root, 'capabilities', 'staging'),
|
||||
capabilityAudit: join(root, 'capabilities', 'audit.jsonl'),
|
||||
reader: join(root, 'reader'),
|
||||
readerPackages: join(root, 'reader', 'packages'),
|
||||
readerStaging: join(root, 'reader', 'staging'),
|
||||
knowledge: join(root, 'knowledge'),
|
||||
knowledgeSources: join(root, 'knowledge', 'sources'),
|
||||
knowledgeIndex: join(root, 'knowledge', 'index'),
|
||||
@@ -136,6 +143,9 @@ export async function ensureMdhHome(home: string): Promise<MdhLayout> {
|
||||
layout.capabilities,
|
||||
layout.capabilityStore,
|
||||
layout.capabilityStaging,
|
||||
layout.reader,
|
||||
layout.readerPackages,
|
||||
layout.readerStaging,
|
||||
layout.knowledge,
|
||||
layout.knowledgeSources,
|
||||
layout.knowledgeIndex,
|
||||
|
||||
@@ -6,12 +6,12 @@
|
||||
* @module @marqdo/mqdh-harness/distribution/install-root
|
||||
*/
|
||||
|
||||
import { homedir } from 'node:os'
|
||||
import { homedir, platform } from 'node:os'
|
||||
import { join, resolve } from 'node:path'
|
||||
|
||||
/** One application install tree. */
|
||||
export interface InstallLayout {
|
||||
/** Installation root, e.g. `~/.local/opt/mqdh`. */
|
||||
/** Installation root, e.g. `~/.local/opt/mqdh` or `%LOCALAPPDATA%\MQDH`. */
|
||||
readonly root: string
|
||||
/** Immutable version directories. */
|
||||
readonly versions: string
|
||||
@@ -23,8 +23,12 @@ export interface InstallLayout {
|
||||
readonly bin: string
|
||||
}
|
||||
|
||||
/** Default installation root. */
|
||||
/** Default installation root for the current platform. */
|
||||
export function defaultInstallRoot(): string {
|
||||
if (platform() === 'win32') {
|
||||
const localAppData = process.env.LOCALAPPDATA?.trim()
|
||||
return join(localAppData !== undefined && localAppData !== '' ? localAppData : join(homedir(), 'AppData', 'Local'), 'MQDH')
|
||||
}
|
||||
return join(homedir(), '.local', 'opt', 'mqdh')
|
||||
}
|
||||
|
||||
|
||||
@@ -52,6 +52,10 @@ export interface UpdateCandidate {
|
||||
readonly node: string
|
||||
readonly signature: 'verified' | 'unsigned'
|
||||
readonly known_limits: readonly string[]
|
||||
/** Release notes from the trusted release body, or null. */
|
||||
readonly notes: string | null
|
||||
/** Official browser URL of the release page. */
|
||||
readonly release_url: string
|
||||
}
|
||||
|
||||
/** Persisted update state. */
|
||||
@@ -135,6 +139,8 @@ function candidateOf(candidate: AppReleaseCandidate): UpdateCandidate {
|
||||
node: candidate.manifest.app.node,
|
||||
signature: candidate.signature.status,
|
||||
known_limits: candidate.manifest.known_limits,
|
||||
notes: candidate.notes,
|
||||
release_url: candidate.browser_url,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -110,6 +110,14 @@ export class EcosystemError extends Error {
|
||||
override name = 'EcosystemError'
|
||||
}
|
||||
|
||||
/** Filename of one shipped runtime binary for a Node platform. */
|
||||
export function runtimeBinaryName(
|
||||
base: 'marqdo' | 'marqdo-provider-worker',
|
||||
nodePlatform: string = process.platform,
|
||||
): string {
|
||||
return nodePlatform === 'win32' ? `${base}.exe` : base
|
||||
}
|
||||
|
||||
/** Recompute the bundle digest from the extracted stdlib directory. */
|
||||
async function bundleDigest(directory: string): Promise<string> {
|
||||
const manifest = await readJson<{ digest?: string }>(join(directory, 'stdlib.json'))
|
||||
@@ -335,7 +343,7 @@ export class EcosystemManager {
|
||||
throw new EcosystemError(`release version mismatch: manifest=${info.product_version}, tag=${candidate.tag}`)
|
||||
}
|
||||
// A real invocation, not a file-existence check.
|
||||
const smoke = await runProcess(join(root, 'marqdo'), ['--version'], {
|
||||
const smoke = await runProcess(join(root, runtimeBinaryName('marqdo')), ['--version'], {
|
||||
cwd: root,
|
||||
limits: {
|
||||
timeoutMs: 30_000,
|
||||
@@ -348,7 +356,7 @@ export class EcosystemManager {
|
||||
}
|
||||
await options.smoke?.({
|
||||
root,
|
||||
cli: join(root, 'marqdo'),
|
||||
cli: join(root, runtimeBinaryName('marqdo')),
|
||||
version: info.product_version,
|
||||
sourceSha: info.source_sha ?? null,
|
||||
bundleDigest: stdlib.tree_digest,
|
||||
@@ -383,8 +391,8 @@ export class EcosystemManager {
|
||||
tree_digest: stdlib.tree_digest,
|
||||
aliases_digest: stdlib.aliases_digest ?? null,
|
||||
},
|
||||
cli_path: 'marqdo',
|
||||
worker_path: 'marqdo-provider-worker',
|
||||
cli_path: runtimeBinaryName('marqdo'),
|
||||
worker_path: runtimeBinaryName('marqdo-provider-worker'),
|
||||
tool_home: 'tool-home',
|
||||
previous: previous?.id ?? null,
|
||||
ci: candidate.ci,
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
|
||||
import { randomBytes } from 'node:crypto'
|
||||
import { mkdir, readFile, unlink } from 'node:fs/promises'
|
||||
import { isAbsolute, join, resolve } from 'node:path'
|
||||
import { isAbsolute, join, relative, resolve } from 'node:path'
|
||||
import { digestBytes, digestFile, readText } from '../core/fsx.ts'
|
||||
import { runProcess } from '../core/process.ts'
|
||||
import type { RunLimits, RunResult } from '../core/process.ts'
|
||||
@@ -132,7 +132,8 @@ export function documentPath(workspace: string, relativePath: string): string {
|
||||
}
|
||||
const absolute = resolve(workspace, relativePath)
|
||||
const root = resolve(workspace)
|
||||
if (!absolute.startsWith(`${root}/`) || absolute.split('/').includes('..')) {
|
||||
const within = relative(root, absolute)
|
||||
if (within === '' || within.startsWith('..') || isAbsolute(within)) {
|
||||
throw new ExecutionRejectedError(`document path escapes the workspace: ${relativePath}`)
|
||||
}
|
||||
return absolute
|
||||
|
||||
@@ -185,11 +185,12 @@ export class KnowledgeManager {
|
||||
if (text === undefined) {
|
||||
return { schema: COLLECTIONS_SCHEMA, schema_version: 1, collections: [] }
|
||||
}
|
||||
const parsed = JSON.parse(text) as CollectionsFile
|
||||
if (parsed.schema !== COLLECTIONS_SCHEMA || parsed.schema_version !== 1 || !Array.isArray(parsed.collections)) {
|
||||
const parsed: unknown = JSON.parse(text)
|
||||
const record = typeof parsed === 'object' && parsed !== null && !Array.isArray(parsed) ? parsed as Record<string, unknown> : undefined
|
||||
if (record === undefined || record.schema !== COLLECTIONS_SCHEMA || record.schema_version !== 1 || !Array.isArray(record.collections)) {
|
||||
throw new KnowledgeError('unsupported knowledge collections file')
|
||||
}
|
||||
return parsed
|
||||
return parsed as CollectionsFile
|
||||
}
|
||||
|
||||
/** Persist the collections file. */
|
||||
@@ -261,6 +262,25 @@ export class KnowledgeManager {
|
||||
return join(this.#layout.knowledgeSources, id)
|
||||
}
|
||||
|
||||
/** Resolve one imported source to its absolute copy and recorded identity. */
|
||||
async sourcePath(id: string, relPath: string): Promise<{
|
||||
root: string
|
||||
relative: string
|
||||
absolute: string
|
||||
digest: string
|
||||
title: string
|
||||
} | undefined> {
|
||||
const collection = await this.collection(id)
|
||||
if (collection === undefined) return undefined
|
||||
const relativePath = normalizeSourcePath(relPath)
|
||||
const known = collection.sources.find(source => source.relPath === relativePath)
|
||||
if (known === undefined) return undefined
|
||||
const root = this.sourceRoot(collection.id)
|
||||
const absolute = join(root, relativePath)
|
||||
assertWithin(root, absolute, 'knowledge source')
|
||||
return { root, relative: relativePath, absolute, digest: known.digest, title: known.title }
|
||||
}
|
||||
|
||||
/** Import files or directories. Nothing is written until all candidates pass. */
|
||||
async import(input: {
|
||||
collection: string
|
||||
@@ -279,8 +299,8 @@ export class KnowledgeManager {
|
||||
if (!info) { rejected.push({ path: selected, reason: 'not found' }); continue }
|
||||
if (info.isSymbolicLink()) { rejected.push({ path: selected, reason: 'symbolic link is not allowed' }); continue }
|
||||
const files = info.isDirectory()
|
||||
? await listRegularFiles(selected, { maxFiles: IMPORT_LIMITS.maxFiles }).catch((error: Error) => {
|
||||
rejected.push({ path: selected, reason: error.message })
|
||||
? await listRegularFiles(selected, { maxFiles: IMPORT_LIMITS.maxFiles }).catch((error: unknown) => {
|
||||
rejected.push({ path: selected, reason: error instanceof Error ? error.message : String(error) })
|
||||
return []
|
||||
})
|
||||
: [{ relative: basename(selected), size: info.size }]
|
||||
@@ -325,8 +345,8 @@ export class KnowledgeManager {
|
||||
rejected.push({ path: candidate.relPath, reason: 'document declares an @exec region; import a reviewed static extract instead' })
|
||||
continue
|
||||
}
|
||||
const semantic = await this.#checkExecutable(candidate.bytes, candidate.relPath).catch((error: Error) => {
|
||||
rejected.push({ path: candidate.relPath, reason: error.message })
|
||||
const semantic = await this.#checkExecutable(candidate.bytes, candidate.relPath).catch((error: unknown) => {
|
||||
rejected.push({ path: candidate.relPath, reason: error instanceof Error ? error.message : String(error) })
|
||||
return 'rejected' as const
|
||||
})
|
||||
if (semantic === 'rejected') continue
|
||||
@@ -425,11 +445,12 @@ export class KnowledgeManager {
|
||||
async indexState(id: string): Promise<IndexState | undefined> {
|
||||
const text = await readText(join(this.#layout.knowledgeIndex, id, 'state.json'))
|
||||
if (text === undefined) return undefined
|
||||
const parsed = JSON.parse(text) as IndexState
|
||||
if (parsed.schema !== 'marqdo.mqdh.knowledge-index' || parsed.schema_version !== 1) {
|
||||
const parsed: unknown = JSON.parse(text)
|
||||
const record = typeof parsed === 'object' && parsed !== null && !Array.isArray(parsed) ? parsed as Record<string, unknown> : undefined
|
||||
if (record === undefined || record.schema !== 'marqdo.mqdh.knowledge-index' || record.schema_version !== 1) {
|
||||
throw new KnowledgeError('unsupported knowledge index state')
|
||||
}
|
||||
return parsed
|
||||
return parsed as IndexState
|
||||
}
|
||||
|
||||
/** Compute the current source-tree digest for one collection. */
|
||||
@@ -453,8 +474,11 @@ export class KnowledgeManager {
|
||||
const record = await readJson<Record<string, unknown>>(join(toolHome, 'knowledge', 'record.json'))
|
||||
if (!record || record.command !== 'knowledge') return undefined
|
||||
const manifest = await readJson<Record<string, unknown>>(join(toolHome, 'knowledge', 'tool.json'))
|
||||
const requires = manifest?.requires as Record<string, unknown> | undefined
|
||||
if (!manifest || requires?.api_revision !== 1 || requires?.analysis !== 3) return undefined
|
||||
if (manifest === undefined) return undefined
|
||||
const requires = manifest.requires
|
||||
if (typeof requires !== 'object' || requires === null || Array.isArray(requires)) return undefined
|
||||
const requirement = requires as Record<string, unknown>
|
||||
if (requirement.api_revision !== 1 || requirement.analysis !== 3) return undefined
|
||||
return { cli, toolHome }
|
||||
}
|
||||
|
||||
|
||||
@@ -62,6 +62,7 @@ export interface CapabilityView {
|
||||
readonly tool_registered: boolean
|
||||
}[]
|
||||
readonly enabled: readonly CapabilityScope[]
|
||||
readonly imports: readonly CapabilityImport[]
|
||||
readonly project_references: readonly string[]
|
||||
readonly update_available: boolean
|
||||
readonly latest_version: string | null
|
||||
@@ -335,6 +336,7 @@ export class CapabilityStore {
|
||||
tool_registered: item.tool_registered,
|
||||
})),
|
||||
enabled: record.enabled,
|
||||
imports: record.imports,
|
||||
project_references: this.#references(record, texts),
|
||||
update_available: isNewer(active?.version ?? null, latest),
|
||||
latest_version: latest,
|
||||
|
||||
@@ -16,7 +16,7 @@ import { arch, platform, release } from 'node:os'
|
||||
import { delimiter, join } from 'node:path'
|
||||
|
||||
/** Target triples this release actually publishes an artifact for. */
|
||||
export const PUBLISHED_TARGETS = ['x86_64-unknown-linux-gnu'] as const
|
||||
export const PUBLISHED_TARGETS = ['x86_64-unknown-linux-gnu', 'x86_64-pc-windows-msvc'] as const
|
||||
|
||||
/** Minimum glibc for the published Linux target (matches the CLI release). */
|
||||
export const MINIMUM_GLIBC = '2.39'
|
||||
|
||||
@@ -0,0 +1,333 @@
|
||||
/**
|
||||
* View embedded-export manifest validation.
|
||||
*
|
||||
* View is the only renderer and theme authority. MQDH checks the public
|
||||
* `marqdo.view-export` manifest, its producer digests, the selected source
|
||||
* digest and package file digests before serving the package in a sandboxed
|
||||
* same-origin frame.
|
||||
*
|
||||
* @module @marqdo/mqdh-harness/reader/contract
|
||||
*/
|
||||
|
||||
import { lstat } from 'node:fs/promises'
|
||||
import { join } from 'node:path'
|
||||
import { digestFile, isWithin } from '../core/fsx.ts'
|
||||
import { READER_ERROR, ReaderError } from './errors.ts'
|
||||
|
||||
/** Reader theme selected by the user. */
|
||||
export type ReaderTheme = 'light' | 'dark'
|
||||
|
||||
/** Source kind accepted by the bridge. */
|
||||
export type ReaderSourceKind = 'workspace' | 'knowledge'
|
||||
|
||||
/** One requested reading surface. */
|
||||
export interface ReaderRequest {
|
||||
readonly kind: ReaderSourceKind
|
||||
/** Workspace-relative path or knowledge source relative path. */
|
||||
readonly path: string
|
||||
/** Collection id for a knowledge source. */
|
||||
readonly collection?: string | undefined
|
||||
readonly theme?: ReaderTheme | undefined
|
||||
readonly anchor?: string | undefined
|
||||
readonly force?: boolean | undefined
|
||||
}
|
||||
|
||||
/** Resolved source identity. */
|
||||
export interface ReaderSource {
|
||||
readonly kind: ReaderSourceKind
|
||||
readonly collection: string | null
|
||||
readonly root: string
|
||||
readonly relative: string
|
||||
readonly absolute: string
|
||||
/** `sha256:<hex>` digest of the exact source bytes. */
|
||||
readonly digest: string
|
||||
readonly title: string | null
|
||||
}
|
||||
|
||||
/** Installed View Tool identity from the active Runtime. */
|
||||
export interface ReaderViewTool {
|
||||
readonly command: 'view'
|
||||
readonly version: string | null
|
||||
readonly path: string
|
||||
readonly entrypoint: string
|
||||
readonly binaryPath: string
|
||||
/** Bare lowercase hex SHA-256 of the View executable. */
|
||||
readonly binarySha256: string
|
||||
readonly sourceSha: string | null
|
||||
}
|
||||
|
||||
/** One validated file of an embedded package. */
|
||||
export interface ReaderPackageFile {
|
||||
readonly path: string
|
||||
readonly sha256: string
|
||||
}
|
||||
|
||||
/** Cache metadata for one embedded package. */
|
||||
export interface ReaderPackageMeta {
|
||||
readonly schema: 'marqdo.mqdh.reader-package'
|
||||
readonly schema_version: 1
|
||||
readonly id: string
|
||||
readonly created_at: string
|
||||
readonly source: {
|
||||
readonly kind: ReaderSourceKind
|
||||
readonly collection: string | null
|
||||
readonly relative: string
|
||||
readonly digest: string
|
||||
readonly title: string | null
|
||||
}
|
||||
readonly theme: ReaderTheme
|
||||
readonly anchor: string | null
|
||||
readonly entry: {
|
||||
readonly href: string
|
||||
readonly file: string
|
||||
readonly heading_ids: readonly string[]
|
||||
readonly relative_path: string
|
||||
}
|
||||
readonly view: {
|
||||
readonly version: string | null
|
||||
readonly binary_sha256: string
|
||||
readonly source_sha: string | null
|
||||
}
|
||||
readonly cli: {
|
||||
readonly version: string | null
|
||||
readonly binary_sha256: string
|
||||
}
|
||||
readonly manifest_sha256: string
|
||||
readonly files: readonly ReaderPackageFile[]
|
||||
readonly assets: readonly ReaderPackageFile[]
|
||||
}
|
||||
|
||||
/** Reader package returned to the workbench. */
|
||||
export interface ReaderPackage {
|
||||
readonly id: string
|
||||
readonly source: ReaderPackageMeta['source']
|
||||
readonly theme: ReaderTheme
|
||||
readonly anchor: string | null
|
||||
readonly entry_href: string
|
||||
readonly heading_ids: readonly string[]
|
||||
readonly view: ReaderPackageMeta['view']
|
||||
readonly cli: ReaderPackageMeta['cli']
|
||||
readonly manifest_sha256: string
|
||||
readonly created_at: string
|
||||
readonly cached: boolean
|
||||
readonly package_url: string
|
||||
}
|
||||
|
||||
/** Expected identities one manifest must match. */
|
||||
export interface ViewManifestExpectation {
|
||||
readonly sourceSha256: string
|
||||
readonly viewBinarySha256: string
|
||||
readonly cliBinarySha256: string
|
||||
readonly theme: ReaderTheme
|
||||
readonly anchor: string | null
|
||||
readonly relativePath: string
|
||||
}
|
||||
|
||||
/** Parsed View manifest values the bridge consumes. */
|
||||
export interface ViewManifest {
|
||||
readonly schemaVersion: number
|
||||
readonly mode: string
|
||||
readonly theme: ReaderTheme
|
||||
readonly executed: boolean
|
||||
readonly requires: Record<string, unknown>
|
||||
readonly producers: Record<string, unknown>
|
||||
readonly entry: {
|
||||
readonly href: string
|
||||
readonly file: string
|
||||
readonly heading_ids: readonly string[]
|
||||
readonly relative_path: string
|
||||
readonly anchor: string | null
|
||||
readonly sha256: string
|
||||
}
|
||||
readonly pages: readonly {
|
||||
readonly source_sha256: string
|
||||
readonly source_status: string
|
||||
readonly relative_path: string
|
||||
readonly sha256: string
|
||||
}[]
|
||||
readonly files: readonly ReaderPackageFile[]
|
||||
readonly assets: readonly ReaderPackageFile[]
|
||||
}
|
||||
|
||||
/** Read a plain object or throw a manifest error. */
|
||||
function objectOf(value: unknown, label: string): Record<string, unknown> {
|
||||
if (typeof value !== 'object' || value === null || Array.isArray(value)) {
|
||||
throw new ReaderError(READER_ERROR.manifestInvalid, `${label} must be an object`)
|
||||
}
|
||||
return value as Record<string, unknown>
|
||||
}
|
||||
|
||||
/** Read a required string. */
|
||||
function stringOf(record: Record<string, unknown>, key: string, label: string): string {
|
||||
const value = record[key]
|
||||
if (typeof value !== 'string' || value === '') throw new ReaderError(READER_ERROR.manifestInvalid, `${label}.${key} must be a non-empty string`)
|
||||
return value
|
||||
}
|
||||
|
||||
/** Read an optional string. */
|
||||
function optionalString(record: Record<string, unknown>, key: string, label: string): string | null {
|
||||
const value = record[key]
|
||||
if (value === undefined || value === null) return null
|
||||
if (typeof value !== 'string') throw new ReaderError(READER_ERROR.manifestInvalid, `${label}.${key} must be a string`)
|
||||
return value
|
||||
}
|
||||
|
||||
/** Read a required digest as bare lowercase hex. */
|
||||
function digestOf(record: Record<string, unknown>, key: string, label: string): string {
|
||||
const value = record[key]
|
||||
if (typeof value !== 'string') throw new ReaderError(READER_ERROR.manifestInvalid, `${label}.${key} must be a digest`)
|
||||
const match = /^(?:sha256:)?([0-9a-f]{64})$/.exec(value)
|
||||
if (match?.[1] === undefined) throw new ReaderError(READER_ERROR.manifestInvalid, `${label}.${key} must be a SHA-256 digest`)
|
||||
return match[1]
|
||||
}
|
||||
|
||||
/** Read one file list with path and digest. */
|
||||
function fileList(record: Record<string, unknown>, key: string, label: string): ReaderPackageFile[] {
|
||||
const value = record[key]
|
||||
if (value === undefined || value === null) return []
|
||||
if (!Array.isArray(value)) throw new ReaderError(READER_ERROR.manifestInvalid, `${label}.${key} must be an array`)
|
||||
return value.map((item, index) => {
|
||||
const file = objectOf(item, `${label}.${key}[${index}]`)
|
||||
const path = stringOf(file, 'path', `${label}.${key}[${index}]`)
|
||||
assertPackagePath(path, `${label}.${key}[${index}].path`)
|
||||
return {
|
||||
path,
|
||||
sha256: digestOf(file, 'sha256', `${label}.${key}[${index}]`),
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
/** Reject a package-relative path that could escape or execute. */
|
||||
export function assertPackagePath(path: string, label: string): void {
|
||||
if (path === '' || path.startsWith('/') || /^[A-Za-z]:/.test(path) || path.includes('\\') || path.includes('\0')) {
|
||||
throw new ReaderError(READER_ERROR.manifestInvalid, `${label} is not a package-relative path: ${path}`)
|
||||
}
|
||||
const segments = path.split('/')
|
||||
if (segments.some(segment => segment === '' || segment === '.' || segment === '..')) {
|
||||
throw new ReaderError(READER_ERROR.manifestInvalid, `${label} is not a safe package path: ${path}`)
|
||||
}
|
||||
if (/\.(?:m?js|jsx|ts|tsx)$/i.test(path)) {
|
||||
throw new ReaderError(READER_ERROR.manifestInvalid, `${label} must not contain scripts: ${path}`)
|
||||
}
|
||||
}
|
||||
|
||||
/** Parse one `marqdo.view-export` manifest. */
|
||||
export function parseViewManifest(value: unknown): ViewManifest {
|
||||
const record = objectOf(value, 'manifest')
|
||||
const schemaVersion = record.schema_version
|
||||
if (record.schema !== 'marqdo.view-export' || schemaVersion !== 1) {
|
||||
throw new ReaderError(READER_ERROR.manifestInvalid, 'unsupported View export schema')
|
||||
}
|
||||
const theme = stringOf(record, 'theme', 'manifest')
|
||||
if (theme !== 'light' && theme !== 'dark') throw new ReaderError(READER_ERROR.manifestInvalid, `unknown View theme: ${theme}`)
|
||||
const entry = objectOf(record.entry, 'manifest.entry')
|
||||
const rawPages = record.pages
|
||||
if (!Array.isArray(rawPages) || rawPages.length !== 1) {
|
||||
throw new ReaderError(READER_ERROR.manifestInvalid, 'embedded export must contain exactly one page')
|
||||
}
|
||||
const page = objectOf(rawPages[0], 'manifest.pages[0]')
|
||||
const rawHeadingIds = entry.heading_ids
|
||||
if (!Array.isArray(rawHeadingIds) || !rawHeadingIds.every(item => typeof item === 'string')) {
|
||||
throw new ReaderError(READER_ERROR.manifestInvalid, 'manifest.entry.heading_ids must be a string array')
|
||||
}
|
||||
return {
|
||||
schemaVersion,
|
||||
mode: stringOf(record, 'mode', 'manifest'),
|
||||
theme,
|
||||
executed: record.executed === true,
|
||||
requires: objectOf(record.requires, 'manifest.requires'),
|
||||
producers: objectOf(record.producers, 'manifest.producers'),
|
||||
entry: {
|
||||
href: stringOf(entry, 'href', 'manifest.entry'),
|
||||
file: stringOf(entry, 'file', 'manifest.entry'),
|
||||
heading_ids: rawHeadingIds,
|
||||
relative_path: stringOf(entry, 'relative_path', 'manifest.entry'),
|
||||
anchor: optionalString(entry, 'anchor', 'manifest.entry'),
|
||||
sha256: digestOf(entry, 'sha256', 'manifest.entry'),
|
||||
},
|
||||
pages: [{
|
||||
source_sha256: digestOf(page, 'source_sha256', 'manifest.pages[0]'),
|
||||
source_status: stringOf(page, 'source_status', 'manifest.pages[0]'),
|
||||
relative_path: stringOf(page, 'relative_path', 'manifest.pages[0]'),
|
||||
sha256: digestOf(page, 'sha256', 'manifest.pages[0]'),
|
||||
}],
|
||||
files: fileList(record, 'files', 'manifest'),
|
||||
assets: fileList(record, 'assets', 'manifest'),
|
||||
}
|
||||
}
|
||||
|
||||
/** Validate the manifest against the exact source, Tool and CLI identities. */
|
||||
export function validateViewManifest(manifest: ViewManifest, expected: ViewManifestExpectation): void {
|
||||
if (manifest.mode !== 'embedded') throw new ReaderError(READER_ERROR.manifestInvalid, `View export mode is ${manifest.mode}, expected embedded`)
|
||||
if (manifest.executed) throw new ReaderError(READER_ERROR.manifestInvalid, 'View embed manifest claims execution')
|
||||
if (manifest.theme !== expected.theme) throw new ReaderError(READER_ERROR.manifestInvalid, 'View theme does not match the request')
|
||||
if (manifest.requires.api_revision !== 1 || manifest.requires.analysis !== 3 || manifest.requires.observation !== 1) {
|
||||
throw new ReaderError(READER_ERROR.manifestInvalid, 'View export requires an unsupported protocol revision')
|
||||
}
|
||||
if (manifest.requires.markdown_profile !== 'marqdo.md.v1') {
|
||||
throw new ReaderError(READER_ERROR.manifestInvalid, 'View export markdown profile is not marqdo.md.v1')
|
||||
}
|
||||
const viewProducer = objectOf(manifest.producers.view, 'manifest.producers.view')
|
||||
if (digestOf(viewProducer, 'binary_sha256', 'manifest.producers.view') !== expected.viewBinarySha256) {
|
||||
throw new ReaderError(READER_ERROR.manifestInvalid, 'View producer digest does not match the installed Tool')
|
||||
}
|
||||
const cliProducer = manifest.producers.cli
|
||||
if (cliProducer !== null && cliProducer !== undefined) {
|
||||
const cli = objectOf(cliProducer, 'manifest.producers.cli')
|
||||
if (digestOf(cli, 'binary_sha256', 'manifest.producers.cli') !== expected.cliBinarySha256) {
|
||||
throw new ReaderError(READER_ERROR.manifestInvalid, 'CLI producer digest does not match the active Runtime')
|
||||
}
|
||||
}
|
||||
const page = manifest.pages[0]
|
||||
if (page === undefined) throw new ReaderError(READER_ERROR.manifestInvalid, 'View export has no page')
|
||||
if (page.source_sha256 !== expected.sourceSha256) {
|
||||
throw new ReaderError(READER_ERROR.sourceChanged, 'View export source digest does not match the selected document')
|
||||
}
|
||||
if (page.source_status !== 'static-ok' && page.source_status !== 'markdown-only') {
|
||||
throw new ReaderError(READER_ERROR.manifestInvalid, `unexpected View source status: ${page.source_status}`)
|
||||
}
|
||||
if (manifest.entry.relative_path !== expected.relativePath || page.relative_path !== expected.relativePath) {
|
||||
throw new ReaderError(READER_ERROR.manifestInvalid, 'View export entry path does not match the request')
|
||||
}
|
||||
assertPackagePath(manifest.entry.file, 'manifest.entry.file')
|
||||
assertPackagePath(manifest.entry.href.split('#')[0] ?? '', 'manifest.entry.href')
|
||||
if (manifest.entry.anchor !== expected.anchor) {
|
||||
throw new ReaderError(READER_ERROR.manifestInvalid, 'View export anchor does not match the request')
|
||||
}
|
||||
if (expected.anchor !== null && !manifest.entry.heading_ids.includes(expected.anchor)) {
|
||||
throw new ReaderError(READER_ERROR.anchorMissing, `requested anchor does not exist: ${expected.anchor}`)
|
||||
}
|
||||
if (expected.anchor === null && manifest.entry.href !== manifest.entry.file) {
|
||||
throw new ReaderError(READER_ERROR.manifestInvalid, 'View export has an unexpected entry fragment')
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Verify every package file digest and ensure the entry file is listed.
|
||||
* @param packageRoot - extracted package directory.
|
||||
* @param manifest - validated manifest.
|
||||
* @returns the verified file list.
|
||||
*/
|
||||
export async function verifyPackageFiles(packageRoot: string, manifest: ViewManifest): Promise<ReaderPackageFile[]> {
|
||||
const all = [...manifest.files, ...manifest.assets]
|
||||
const seen = new Set<string>()
|
||||
let total = 0
|
||||
for (const file of all) {
|
||||
assertPackagePath(file.path, 'package file')
|
||||
if (seen.has(file.path)) throw new ReaderError(READER_ERROR.manifestInvalid, `duplicate package file: ${file.path}`)
|
||||
seen.add(file.path)
|
||||
const target = join(packageRoot, file.path)
|
||||
if (!isWithin(packageRoot, target)) throw new ReaderError(READER_ERROR.packageInvalid, `package file escapes its root: ${file.path}`)
|
||||
const info = await lstat(target).catch(() => undefined)
|
||||
if (info === undefined || !info.isFile() || info.isSymbolicLink()) {
|
||||
throw new ReaderError(READER_ERROR.packageInvalid, `package file is not a regular file: ${file.path}`)
|
||||
}
|
||||
if (info.size > 16 * 1024 * 1024) throw new ReaderError(READER_ERROR.packageInvalid, `package file exceeds its size limit: ${file.path}`)
|
||||
total += info.size
|
||||
if (total > 64 * 1024 * 1024) throw new ReaderError(READER_ERROR.packageInvalid, 'package exceeds its total size limit')
|
||||
const actual = await digestFile(target)
|
||||
if (actual !== `sha256:${file.sha256}`) throw new ReaderError(READER_ERROR.packageInvalid, `package file digest mismatch: ${file.path}`)
|
||||
}
|
||||
if (!seen.has(manifest.entry.file)) throw new ReaderError(READER_ERROR.manifestInvalid, 'entry file is not listed in the package')
|
||||
return all
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
/**
|
||||
* Reader bridge failure codes.
|
||||
*
|
||||
* Opening a reader package performs a static View export (a CLI `check` and
|
||||
* local HTML write) but never executes the document. Failures keep their own
|
||||
* code so the workbench can distinguish a missing Tool, a source change, an
|
||||
* invalid anchor and an untrusted package.
|
||||
*
|
||||
* @module @marqdo/mqdh-harness/reader/errors
|
||||
*/
|
||||
|
||||
/** Reader failure with a stable local code. */
|
||||
export class ReaderError extends Error {
|
||||
override name = 'ReaderError'
|
||||
readonly code: string
|
||||
|
||||
constructor(code: string, message: string) {
|
||||
super(message)
|
||||
this.code = code
|
||||
}
|
||||
}
|
||||
|
||||
/** Canonical reader failure codes. */
|
||||
export const READER_ERROR = {
|
||||
viewMissing: 'reader.view_missing',
|
||||
cliMissing: 'reader.cli_missing',
|
||||
sourceInvalid: 'reader.source_invalid',
|
||||
sourceChanged: 'reader.source_changed',
|
||||
anchorMissing: 'reader.anchor_missing',
|
||||
exportFailed: 'reader.export_failed',
|
||||
manifestInvalid: 'reader.manifest_invalid',
|
||||
packageMissing: 'reader.package_missing',
|
||||
packageInvalid: 'reader.package_invalid',
|
||||
knowledgeSourceMissing: 'reader.knowledge_source_missing',
|
||||
} as const
|
||||
|
||||
/** One canonical reader failure code. */
|
||||
export type ReaderErrorCode = (typeof READER_ERROR)[keyof typeof READER_ERROR]
|
||||
@@ -0,0 +1,402 @@
|
||||
/**
|
||||
* Read-only View reader bridge.
|
||||
*
|
||||
* One bridge runs the installed View Tool's public `export --embed` command,
|
||||
* validates the resulting package manifest and producer identities, caches the
|
||||
* package by source/Tool/theme identity and serves package files for a
|
||||
* sandboxed same-origin iframe. The bridge never renders Markdown, copies View
|
||||
* CSS or executes the document.
|
||||
*
|
||||
* @module @marqdo/mqdh-harness/reader/service
|
||||
*/
|
||||
|
||||
import { createHash, randomBytes } from 'node:crypto'
|
||||
import { lstat, mkdir, readFile, realpath, rename, rm } from 'node:fs/promises'
|
||||
import { dirname, extname, join, relative as relativePath } from 'node:path'
|
||||
import { digestBytes, digestFile, isDirectory, isFile, isWithin, readJson, writeJsonAtomic } from '../core/fsx.ts'
|
||||
import type { MdhLayout } from '../core/home.ts'
|
||||
import { withLock } from '../core/lock.ts'
|
||||
import { runProcess } from '../core/process.ts'
|
||||
import type { MarqdoCli } from '../execution/cli.ts'
|
||||
import { resolveDocument } from '../workspace.ts'
|
||||
import {
|
||||
assertPackagePath, parseViewManifest, validateViewManifest, verifyPackageFiles,
|
||||
} from './contract.ts'
|
||||
import type {
|
||||
ReaderPackage, ReaderPackageFile, ReaderPackageMeta, ReaderRequest, ReaderSource, ReaderTheme,
|
||||
ReaderViewTool, ViewManifest,
|
||||
} from './contract.ts'
|
||||
import { READER_ERROR, ReaderError } from './errors.ts'
|
||||
|
||||
/** Reader bridge dependencies. */
|
||||
export interface ReaderServiceOptions {
|
||||
readonly layout: MdhLayout
|
||||
readonly cli: () => Promise<MarqdoCli | undefined>
|
||||
readonly toolHome: () => Promise<string | undefined>
|
||||
readonly viewTool: () => Promise<ReaderViewTool | undefined>
|
||||
readonly workspace: () => string
|
||||
readonly knowledgeSource: (collection: string, path: string) => Promise<ReaderSource | undefined>
|
||||
}
|
||||
|
||||
/** Reader availability projection. */
|
||||
export interface ReaderStatus {
|
||||
readonly available: boolean
|
||||
readonly view: {
|
||||
readonly version: string | null
|
||||
readonly path: string
|
||||
readonly binary_sha256: string
|
||||
readonly source_sha: string | null
|
||||
} | null
|
||||
readonly cli: { readonly version: string | null } | null
|
||||
readonly error: string | null
|
||||
}
|
||||
|
||||
/** Project source text result. */
|
||||
export interface ReaderSourceText {
|
||||
readonly kind: 'workspace' | 'knowledge'
|
||||
readonly collection: string | null
|
||||
readonly path: string
|
||||
readonly digest: string
|
||||
readonly text: string
|
||||
readonly truncated: boolean
|
||||
}
|
||||
|
||||
/** One served package file. */
|
||||
export interface ReaderPackageFileBody {
|
||||
readonly path: string
|
||||
readonly contentType: string
|
||||
readonly body: Buffer
|
||||
}
|
||||
|
||||
/** The reader bridge. */
|
||||
export class ReaderService {
|
||||
readonly #layout: MdhLayout
|
||||
readonly #cli: ReaderServiceOptions['cli']
|
||||
readonly #toolHome: ReaderServiceOptions['toolHome']
|
||||
readonly #viewTool: ReaderServiceOptions['viewTool']
|
||||
readonly #workspace: ReaderServiceOptions['workspace']
|
||||
readonly #knowledgeSource: ReaderServiceOptions['knowledgeSource']
|
||||
|
||||
constructor(options: ReaderServiceOptions) {
|
||||
this.#layout = options.layout
|
||||
this.#cli = options.cli
|
||||
this.#toolHome = options.toolHome
|
||||
this.#viewTool = options.viewTool
|
||||
this.#workspace = options.workspace
|
||||
this.#knowledgeSource = options.knowledgeSource
|
||||
}
|
||||
|
||||
/** Read the current View/CLI availability without running either. */
|
||||
async status(): Promise<ReaderStatus> {
|
||||
const view = await this.#viewTool().catch(() => undefined)
|
||||
if (view === undefined) {
|
||||
return { available: false, view: null, cli: null, error: 'installed View Tool is required for the reader' }
|
||||
}
|
||||
const cli = await this.#cli().catch(() => undefined)
|
||||
return {
|
||||
available: cli !== undefined,
|
||||
view: {
|
||||
version: view.version,
|
||||
path: view.binaryPath,
|
||||
binary_sha256: view.binarySha256,
|
||||
source_sha: view.sourceSha,
|
||||
},
|
||||
cli: cli === undefined ? null : { version: cli.version ?? null },
|
||||
error: cli === undefined ? 'active Marqdo Runtime is required for the reader' : null,
|
||||
}
|
||||
}
|
||||
|
||||
/** Resolve one workspace or knowledge source to its exact bytes and root. */
|
||||
async #source(request: ReaderRequest): Promise<ReaderSource> {
|
||||
if (request.kind === 'workspace') {
|
||||
const workspace = this.#workspace()
|
||||
let absolute: string
|
||||
try {
|
||||
absolute = await resolveDocument(workspace, request.path)
|
||||
} catch (error) {
|
||||
throw new ReaderError(READER_ERROR.sourceInvalid, error instanceof Error ? error.message : String(error))
|
||||
}
|
||||
const digest = await digestFile(absolute)
|
||||
return {
|
||||
kind: 'workspace',
|
||||
collection: null,
|
||||
root: workspace,
|
||||
relative: relativePath(workspace, absolute).split('\\').join('/'),
|
||||
absolute,
|
||||
digest,
|
||||
title: null,
|
||||
}
|
||||
}
|
||||
const collection = request.collection?.trim()
|
||||
if (collection === undefined || collection === '') {
|
||||
throw new ReaderError(READER_ERROR.sourceInvalid, 'knowledge reading requires a collection id')
|
||||
}
|
||||
const source = await this.#knowledgeSource(collection, request.path).catch(() => undefined)
|
||||
if (source === undefined) throw new ReaderError(READER_ERROR.knowledgeSourceMissing, `unknown knowledge source: ${collection}/${request.path}`)
|
||||
return source
|
||||
}
|
||||
|
||||
/** Build the cache identity for one request. */
|
||||
#cacheId(source: ReaderSource, view: ReaderViewTool, cliSha256: string, theme: ReaderTheme, anchor: string | null): string {
|
||||
return createHash('sha256').update(JSON.stringify({
|
||||
schema: 1,
|
||||
kind: source.kind,
|
||||
collection: source.collection,
|
||||
root: source.root,
|
||||
relative: source.relative,
|
||||
source: source.digest,
|
||||
view: view.binarySha256,
|
||||
cli: cliSha256,
|
||||
theme,
|
||||
anchor,
|
||||
})).digest('hex')
|
||||
}
|
||||
|
||||
/** Read valid cache metadata or return undefined. */
|
||||
async #cachedMeta(
|
||||
id: string,
|
||||
source: ReaderSource,
|
||||
view: ReaderViewTool,
|
||||
theme: ReaderTheme,
|
||||
anchor: string | null,
|
||||
): Promise<ReaderPackageMeta | undefined> {
|
||||
const raw = await readJson<unknown>(join(this.#layout.readerPackages, `${id}.json`)).catch(() => undefined)
|
||||
if (typeof raw !== 'object' || raw === null || Array.isArray(raw)) return undefined
|
||||
const record = raw as Record<string, unknown>
|
||||
if (record.schema !== 'marqdo.mqdh.reader-package' || record.schema_version !== 1) return undefined
|
||||
try {
|
||||
const meta = raw as ReaderPackageMeta
|
||||
if (meta.id !== id || meta.theme !== theme || meta.anchor !== anchor) return undefined
|
||||
if (meta.source.digest !== source.digest || meta.source.relative !== source.relative) return undefined
|
||||
if (meta.view.binary_sha256 !== view.binarySha256) return undefined
|
||||
if (!(await isDirectory(join(this.#layout.readerPackages, id)))) return undefined
|
||||
return meta
|
||||
} catch (error) {
|
||||
void error
|
||||
return undefined
|
||||
}
|
||||
}
|
||||
|
||||
/** Render a cache hit. */
|
||||
#packageFromMeta(meta: ReaderPackageMeta, cached: boolean): ReaderPackage {
|
||||
return {
|
||||
id: meta.id,
|
||||
source: meta.source,
|
||||
theme: meta.theme,
|
||||
anchor: meta.anchor,
|
||||
entry_href: meta.entry.href,
|
||||
heading_ids: meta.entry.heading_ids,
|
||||
view: meta.view,
|
||||
cli: meta.cli,
|
||||
manifest_sha256: meta.manifest_sha256,
|
||||
created_at: meta.created_at,
|
||||
cached,
|
||||
package_url: `/mqdh/api/reader/package/${meta.id}/${meta.entry.href}`,
|
||||
}
|
||||
}
|
||||
|
||||
/** Expand a View failure into a stable reader error. */
|
||||
#exportFailure(error: Error, anchor: string | null): ReaderError {
|
||||
const message = error.message.slice(0, 600)
|
||||
if (anchor !== null && /anchor|heading/i.test(message)) return new ReaderError(READER_ERROR.anchorMissing, message)
|
||||
if (/source.*sha|expect-source|digest/i.test(message)) return new ReaderError(READER_ERROR.sourceChanged, message)
|
||||
return new ReaderError(READER_ERROR.exportFailed, message)
|
||||
}
|
||||
|
||||
/**
|
||||
* Open one read-only package. A cache miss runs the installed View Tool with a
|
||||
* fixed argv; the document is statically checked, never executed.
|
||||
* @param request - source, theme and optional anchor.
|
||||
* @returns the validated package and its same-origin URL.
|
||||
*/
|
||||
async open(request: ReaderRequest): Promise<ReaderPackage> {
|
||||
const theme: ReaderTheme = request.theme ?? 'light'
|
||||
const anchor = request.anchor?.trim() || null
|
||||
const view = await this.#viewTool()
|
||||
if (view === undefined) throw new ReaderError(READER_ERROR.viewMissing, 'install the View Tool to read documents')
|
||||
const cli = await this.#cli()
|
||||
if (cli === undefined) throw new ReaderError(READER_ERROR.cliMissing, 'install a Marqdo Runtime to read documents')
|
||||
const toolHome = await this.#toolHome()
|
||||
if (toolHome === undefined) throw new ReaderError(READER_ERROR.cliMissing, 'active Runtime has no Tool home')
|
||||
const cliSha256 = (await digestFile(cli.bin)).slice('sha256:'.length)
|
||||
const source = await this.#source(request)
|
||||
const sourceSha256 = source.digest.slice('sha256:'.length)
|
||||
const id = this.#cacheId(source, view, cliSha256, theme, anchor)
|
||||
return await withLock(join(this.#layout.reader, 'open.lock'), async () => {
|
||||
if (request.force !== true) {
|
||||
const cached = await this.#cachedMeta(id, source, view, theme, anchor)
|
||||
if (cached !== undefined) return this.#packageFromMeta(cached, true)
|
||||
}
|
||||
const output = join(this.#layout.readerStaging, `open-${id.slice(0, 12)}-${randomBytes(4).toString('hex')}`)
|
||||
await mkdir(dirname(output), { recursive: true, mode: 0o700 })
|
||||
try {
|
||||
const args = [
|
||||
'view', 'export', source.relative, '--out', output, '--embed',
|
||||
'--theme', theme, '--expect-source-sha256', sourceSha256,
|
||||
...(anchor === null ? [] : ['--anchor', anchor]),
|
||||
]
|
||||
const run = await runProcess(cli.bin, args, {
|
||||
cwd: source.root,
|
||||
env: { MARQDO_TOOL_HOME: toolHome },
|
||||
limits: { timeoutMs: 120_000, maxOutputBytes: 2 * 1024 * 1024 },
|
||||
})
|
||||
if (run.exitCode !== 0) {
|
||||
throw this.#exportFailure(new Error(run.stderr.trim() || run.stdout.trim() || `view export exited ${run.exitCode}`), anchor)
|
||||
}
|
||||
const manifestBytes = await readFile(join(output, 'manifest.json')).catch(() => undefined)
|
||||
if (manifestBytes === undefined) throw new ReaderError(READER_ERROR.manifestInvalid, 'View export produced no manifest.json')
|
||||
let raw: unknown
|
||||
try {
|
||||
raw = JSON.parse(manifestBytes.toString('utf8'))
|
||||
} catch {
|
||||
throw new ReaderError(READER_ERROR.manifestInvalid, 'View manifest is not valid JSON')
|
||||
}
|
||||
const manifest = parseViewManifest(raw)
|
||||
validateViewManifest(manifest, {
|
||||
sourceSha256,
|
||||
viewBinarySha256: view.binarySha256,
|
||||
cliBinarySha256: cliSha256,
|
||||
theme,
|
||||
anchor,
|
||||
relativePath: source.relative,
|
||||
})
|
||||
const files = await verifyPackageFiles(output, manifest)
|
||||
const packageRoot = join(this.#layout.readerPackages, id)
|
||||
await rm(packageRoot, { recursive: true, force: true })
|
||||
await rename(output, packageRoot)
|
||||
const meta: ReaderPackageMeta = {
|
||||
schema: 'marqdo.mqdh.reader-package',
|
||||
schema_version: 1,
|
||||
id,
|
||||
created_at: new Date().toISOString(),
|
||||
source: {
|
||||
kind: source.kind,
|
||||
collection: source.collection,
|
||||
relative: source.relative,
|
||||
digest: source.digest,
|
||||
title: source.title,
|
||||
},
|
||||
theme,
|
||||
anchor,
|
||||
entry: {
|
||||
href: manifest.entry.href,
|
||||
file: manifest.entry.file,
|
||||
heading_ids: manifest.entry.heading_ids,
|
||||
relative_path: manifest.entry.relative_path,
|
||||
},
|
||||
view: {
|
||||
version: view.version,
|
||||
binary_sha256: view.binarySha256,
|
||||
source_sha: view.sourceSha,
|
||||
},
|
||||
cli: { version: cli.version ?? null, binary_sha256: cliSha256 },
|
||||
manifest_sha256: digestBytes(manifestBytes).slice('sha256:'.length),
|
||||
files: files.filter(file => manifest.files.some(item => item.path === file.path)),
|
||||
assets: files.filter(file => manifest.assets.some(item => item.path === file.path)),
|
||||
}
|
||||
await writeJsonAtomic(join(this.#layout.readerPackages, `${id}.json`), meta, 0o600)
|
||||
return this.#packageFromMeta(meta, false)
|
||||
} catch (error) {
|
||||
await rm(output, { recursive: true, force: true }).catch(() => undefined)
|
||||
if (error instanceof ReaderError) throw error
|
||||
throw new ReaderError(READER_ERROR.exportFailed, error instanceof Error ? error.message : String(error))
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* Read the selected source text without invoking View.
|
||||
* @param request - workspace or knowledge source.
|
||||
* @returns bounded UTF-8 source text and its digest.
|
||||
*/
|
||||
async source(request: ReaderRequest): Promise<ReaderSourceText> {
|
||||
const source = await this.#source(request)
|
||||
const bytes = await readFile(source.absolute)
|
||||
const max = 256 * 1024
|
||||
const slice = bytes.byteLength > max ? bytes.subarray(0, max) : bytes
|
||||
return {
|
||||
kind: source.kind,
|
||||
collection: source.collection,
|
||||
path: source.relative,
|
||||
digest: source.digest,
|
||||
text: slice.toString('utf8'),
|
||||
truncated: bytes.byteLength > max,
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolve one file of a cached package for the same-origin route.
|
||||
* @param id - package cache id.
|
||||
* @param path - package-relative path.
|
||||
* @returns the file body and content type.
|
||||
*/
|
||||
async packageFile(id: string, path: string): Promise<ReaderPackageFileBody> {
|
||||
if (!/^[a-f0-9]{64}$/.test(id)) throw new ReaderError(READER_ERROR.packageInvalid, 'invalid reader package id')
|
||||
assertPackagePath(path, 'reader package path')
|
||||
const meta = await readJson<ReaderPackageMeta>(join(this.#layout.readerPackages, `${id}.json`))
|
||||
if (meta === undefined) throw new ReaderError(READER_ERROR.packageMissing, 'reader package is missing')
|
||||
const allowed = new Set([...meta.files.map(file => file.path), ...meta.assets.map(file => file.path), meta.entry.file])
|
||||
if (!allowed.has(path)) throw new ReaderError(READER_ERROR.packageInvalid, `file is not listed in the package manifest: ${path}`)
|
||||
const root = join(this.#layout.readerPackages, id)
|
||||
const target = join(root, path)
|
||||
if (!isWithin(root, target)) throw new ReaderError(READER_ERROR.packageInvalid, 'package path escapes its root')
|
||||
const info = await lstat(target).catch(() => undefined)
|
||||
if (info === undefined || !info.isFile() || info.isSymbolicLink()) throw new ReaderError(READER_ERROR.packageInvalid, 'package file is not a regular file')
|
||||
if (info.size > 16 * 1024 * 1024) throw new ReaderError(READER_ERROR.packageInvalid, 'package file is too large')
|
||||
const canonical = await realpath(target).catch(() => undefined)
|
||||
if (canonical === undefined || !isWithin(await realpath(root), canonical)) throw new ReaderError(READER_ERROR.packageInvalid, 'package file resolves outside its root')
|
||||
return { path, contentType: contentTypeOf(path), body: await readFile(canonical) }
|
||||
}
|
||||
|
||||
/** Whether one package file identity is already cached. */
|
||||
async cachedFile(id: string, path: string): Promise<ReaderPackageFile | undefined> {
|
||||
const meta = await readJson<ReaderPackageMeta>(join(this.#layout.readerPackages, `${id}.json`)).catch(() => undefined)
|
||||
return meta?.files.find(file => file.path === path) ?? meta?.assets.find(file => file.path === path)
|
||||
}
|
||||
|
||||
/** Remove one cached package or all packages. */
|
||||
async clear(id?: string): Promise<void> {
|
||||
if (id === undefined) {
|
||||
await rm(this.#layout.readerPackages, { recursive: true, force: true })
|
||||
await mkdir(this.#layout.readerPackages, { recursive: true, mode: 0o700 })
|
||||
return
|
||||
}
|
||||
if (!/^[a-f0-9]{64}$/.test(id)) throw new ReaderError(READER_ERROR.packageInvalid, 'invalid reader package id')
|
||||
await rm(join(this.#layout.readerPackages, id), { recursive: true, force: true })
|
||||
await rm(join(this.#layout.readerPackages, `${id}.json`), { force: true })
|
||||
}
|
||||
|
||||
/** Whether a package directory exists (used by tests and diagnostics). */
|
||||
async hasPackage(id: string): Promise<boolean> {
|
||||
return await isFile(join(this.#layout.readerPackages, `${id}.json`)) && await isDirectory(join(this.#layout.readerPackages, id))
|
||||
}
|
||||
|
||||
/** Read a package manifest for diagnostics. */
|
||||
async manifest(id: string): Promise<ViewManifest | undefined> {
|
||||
const path = join(this.#layout.readerPackages, id, 'manifest.json')
|
||||
const parsed = await readJson<unknown>(path).catch(() => undefined)
|
||||
if (parsed === undefined) return undefined
|
||||
return parseViewManifest(parsed)
|
||||
}
|
||||
}
|
||||
|
||||
/** Map package file extensions to response content types. */
|
||||
export function contentTypeOf(path: string): string {
|
||||
switch (extname(path).toLowerCase()) {
|
||||
case '.html': return 'text/html; charset=utf-8'
|
||||
case '.css': return 'text/css; charset=utf-8'
|
||||
case '.svg': return 'image/svg+xml'
|
||||
case '.png': return 'image/png'
|
||||
case '.jpg':
|
||||
case '.jpeg': return 'image/jpeg'
|
||||
case '.webp': return 'image/webp'
|
||||
case '.gif': return 'image/gif'
|
||||
case '.ttf': return 'font/ttf'
|
||||
case '.otf': return 'font/otf'
|
||||
case '.woff': return 'font/woff'
|
||||
case '.woff2': return 'font/woff2'
|
||||
case '.txt': return 'text/plain; charset=utf-8'
|
||||
case '.md': return 'text/markdown; charset=utf-8'
|
||||
default: return 'application/octet-stream'
|
||||
}
|
||||
}
|
||||
@@ -38,6 +38,8 @@ export interface GiteaRelease {
|
||||
readonly prerelease: boolean
|
||||
readonly draft: boolean
|
||||
readonly target_commitish: string | null
|
||||
/** Release notes authored in the trusted Gitea release, truncated. */
|
||||
readonly body: string | null
|
||||
readonly assets: readonly GiteaAsset[]
|
||||
}
|
||||
|
||||
@@ -72,11 +74,15 @@ function parseRelease(raw: unknown): GiteaRelease {
|
||||
const record = raw as Record<string, unknown>
|
||||
if (typeof record.tag_name !== 'string') throw new GiteaError('invalid_response', 'release has no tag_name')
|
||||
const assets = Array.isArray(record.assets) ? record.assets.map(parseAsset) : []
|
||||
const body = typeof record.body === 'string' && record.body.trim() !== ''
|
||||
? record.body.slice(0, 8192)
|
||||
: null
|
||||
return {
|
||||
tag_name: record.tag_name,
|
||||
prerelease: record.prerelease === true,
|
||||
draft: record.draft === true,
|
||||
target_commitish: typeof record.target_commitish === 'string' ? record.target_commitish : null,
|
||||
body,
|
||||
assets,
|
||||
}
|
||||
}
|
||||
@@ -131,6 +137,8 @@ export interface AppReleaseCandidate {
|
||||
readonly asset: { readonly name: string; readonly url: string; readonly size: number; readonly sha256: string }
|
||||
readonly manifest_url: string
|
||||
readonly browser_url: string
|
||||
/** Release notes from the release body, or null when absent. */
|
||||
readonly notes: string | null
|
||||
}
|
||||
|
||||
/** Read a detached signature asset when the release publishes one. */
|
||||
@@ -258,6 +266,7 @@ async function inspectRelease(
|
||||
},
|
||||
manifest_url: manifestAsset.browser_download_url,
|
||||
browser_url: `${authority}/${repository}/releases/tag/${release.tag_name}`,
|
||||
notes: release.body,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -156,6 +156,11 @@ export function assetNameFor(version: string, target: string): string {
|
||||
return `marqdo-harness-${version}-${target}.tar.gz`
|
||||
}
|
||||
|
||||
/** Asset name for the formal Windows portable ZIP distribution. */
|
||||
export function portableZipNameFor(version: string): string {
|
||||
return `MQDH-${version}-win-x64.zip`
|
||||
}
|
||||
|
||||
/** Sidecar digest name for one asset. */
|
||||
export function sidecarNameFor(asset: string): string {
|
||||
return `${asset}.sha256`
|
||||
|
||||
@@ -10,12 +10,15 @@
|
||||
|
||||
import { readFile, stat } from 'node:fs/promises'
|
||||
import { isAbsolute, join, resolve } from 'node:path'
|
||||
import { digestFile } from './core/fsx.ts'
|
||||
import { digestFile, isWithin, readJson, readText } from './core/fsx.ts'
|
||||
import { ensureMdhHome, resolveMdhHome } from './core/home.ts'
|
||||
import type { MdhLayout } from './core/home.ts'
|
||||
import { EcosystemManager } from './ecosystem/manager.ts'
|
||||
import type { EcosystemStatus } from './ecosystem/manager.ts'
|
||||
import { EvidenceStore } from './execution/evidence.ts'
|
||||
import { ReaderService } from './reader/service.ts'
|
||||
import type { ReaderSourceText, ReaderStatus } from './reader/service.ts'
|
||||
import type { ReaderPackage, ReaderViewTool } from './reader/contract.ts'
|
||||
import type { RunEvidence, RunRecord } from './execution/evidence.ts'
|
||||
import { MarqdoCli } from './execution/cli.ts'
|
||||
import type { CheckedDocument, ExecutedDocument, Grants, SandboxMode } from './execution/cli.ts'
|
||||
@@ -32,6 +35,7 @@ import { BootstrapManager } from './bootstrap/manager.ts'
|
||||
import { DiagnosticsStore } from './diagnostics/store.ts'
|
||||
import type { DiagnosticIdentity } from './diagnostics/store.ts'
|
||||
import { AppUpdater } from './distribution/updater.ts'
|
||||
import type { UpdateState } from './distribution/updater.ts'
|
||||
import { targetTriple } from './platform/detect.ts'
|
||||
import { APP_VERSION } from './version.ts'
|
||||
import type { KnowledgeSearchResult } from './knowledge/manager.ts'
|
||||
@@ -85,6 +89,8 @@ export interface MdhStatus {
|
||||
readonly privacy: { readonly telemetry: false; readonly sessionUpload: false; readonly pluginInstall: false }
|
||||
readonly platform: string
|
||||
readonly node: string
|
||||
/** Persisted application update view (no network check on read). */
|
||||
readonly update: UpdateState
|
||||
}
|
||||
|
||||
/** Resolve one CLI path override safely. */
|
||||
@@ -109,6 +115,7 @@ export class MdhRuntime {
|
||||
readonly bootstrap: BootstrapManager
|
||||
readonly updater: AppUpdater
|
||||
readonly knowledge: KnowledgeManager
|
||||
readonly reader: ReaderService
|
||||
readonly evidence: EvidenceStore
|
||||
readonly #cliCache = new Map<string, { cli: MarqdoCli }>()
|
||||
readonly #analysisCache = new Map<string, CheckedDocument>()
|
||||
@@ -152,6 +159,29 @@ export class MdhRuntime {
|
||||
return environment ? join(this.layout.environments, environment.id, environment.tool_home) : undefined
|
||||
},
|
||||
})
|
||||
this.reader = new ReaderService({
|
||||
layout,
|
||||
cli: () => this.cli(),
|
||||
toolHome: async () => {
|
||||
const environment = await this.ecosystem.current()
|
||||
return environment ? join(layout.environments, environment.id, environment.tool_home) : undefined
|
||||
},
|
||||
viewTool: () => this.#viewTool(),
|
||||
workspace: () => this.workspace,
|
||||
knowledgeSource: async (collection, path) => {
|
||||
const source = await this.knowledge.sourcePath(collection, path)
|
||||
if (source === undefined) return undefined
|
||||
return {
|
||||
kind: 'knowledge',
|
||||
collection,
|
||||
root: source.root,
|
||||
relative: source.relative,
|
||||
absolute: source.absolute,
|
||||
digest: source.digest,
|
||||
title: source.title,
|
||||
}
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -167,7 +197,7 @@ export class MdhRuntime {
|
||||
}
|
||||
|
||||
/** Configured workspace override applied at runtime (Web settings). */
|
||||
async setWorkspace(workspace: string): Promise<void> {
|
||||
setWorkspace(workspace: string): void {
|
||||
if (!isAbsolute(workspace)) throw new Error('workspace must be an absolute path')
|
||||
this.workspace = resolve(workspace)
|
||||
}
|
||||
@@ -204,6 +234,45 @@ export class MdhRuntime {
|
||||
return await readProjectDependencies(this.workspace)
|
||||
}
|
||||
|
||||
/** Installed View Tool identity used by the reader bridge. */
|
||||
async #viewTool(): Promise<ReaderViewTool | undefined> {
|
||||
const status = await this.ecosystem.status()
|
||||
const tool = status.tools.find(candidate => candidate.command === 'view')
|
||||
if (tool === undefined) return undefined
|
||||
const record = await readJson<Record<string, unknown>>(join(tool.path, 'record.json'))
|
||||
if (record === undefined || typeof record.entrypoint !== 'string' || record.entrypoint === '') return undefined
|
||||
const binaryPath = join(tool.path, record.entrypoint)
|
||||
if (!isWithin(tool.path, binaryPath)) return undefined
|
||||
const info = await stat(binaryPath).catch(() => undefined)
|
||||
if (info === undefined || !info.isFile()) return undefined
|
||||
const digest = await digestFile(binaryPath)
|
||||
const sourceSha = (await readText(join(tool.path, 'SOURCE_SHA')))?.trim() || null
|
||||
return {
|
||||
command: 'view',
|
||||
version: typeof record.version === 'string' ? record.version : tool.version,
|
||||
path: tool.path,
|
||||
entrypoint: record.entrypoint,
|
||||
binaryPath,
|
||||
binarySha256: digest.slice('sha256:'.length),
|
||||
sourceSha,
|
||||
}
|
||||
}
|
||||
|
||||
/** Reader availability and installed View/CLI identity. */
|
||||
async readerStatus(): Promise<ReaderStatus> {
|
||||
return await this.reader.status()
|
||||
}
|
||||
|
||||
/** Open one read-only View package for a workspace or knowledge source. */
|
||||
async openReader(request: Parameters<ReaderService['open']>[0]): Promise<ReaderPackage> {
|
||||
return await this.reader.open(request)
|
||||
}
|
||||
|
||||
/** Read source text for the reader's source toggle. */
|
||||
async readerSource(request: Parameters<ReaderService['source']>[0]): Promise<ReaderSourceText> {
|
||||
return await this.reader.source(request)
|
||||
}
|
||||
|
||||
/** Installed capabilities visible to one agent/session scope. */
|
||||
async visibleCapabilities(sessionId: string | null): Promise<VisibleCapability[]> {
|
||||
return await this.capabilities.visible(sessionId, this.workspace)
|
||||
@@ -259,6 +328,7 @@ export class MdhRuntime {
|
||||
privacy: { telemetry: false, sessionUpload: false, pluginInstall: false },
|
||||
platform: `${process.platform}-${process.arch}`,
|
||||
node: process.version,
|
||||
update: await this.updater.state(),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -8,6 +8,11 @@
|
||||
* @module @marqdo/mqdh-harness/web/assets
|
||||
*/
|
||||
|
||||
import { readFileSync } from 'node:fs'
|
||||
|
||||
/** The local Marqdo brand mark shared by the workbench and the shell. */
|
||||
export const BRAND_SVG = readFileSync(new URL('../../assets/marqdo.svg', import.meta.url))
|
||||
|
||||
/** The workbench document. */
|
||||
export const APP_HTML = `<!doctype html>
|
||||
<html lang="zh-CN">
|
||||
@@ -15,12 +20,13 @@ export const APP_HTML = `<!doctype html>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>Marqdo Harness</title>
|
||||
<link rel="icon" href="/mqdh/brand.svg" type="image/svg+xml">
|
||||
<link rel="stylesheet" href="/mqdh/app.css">
|
||||
<script type="module" src="/mqdh/app.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<body__MQDH_EMBEDDED__>
|
||||
<header class="top">
|
||||
<div class="brand"><span class="mark">M</span><strong>Marqdo Harness</strong><span class="sub">本地单用户工作台</span></div>
|
||||
<div class="brand"><img src="/mqdh/brand.svg" width="30" height="30" alt=""><strong>Marqdo Harness</strong><span class="sub">本地单用户工作台</span></div>
|
||||
<nav class="links">
|
||||
<a href="/">对话</a>
|
||||
<a href="/mqdh" aria-current="page">工作台</a>
|
||||
@@ -30,21 +36,22 @@ export const APP_HTML = `<!doctype html>
|
||||
</header>
|
||||
<main>
|
||||
<section class="hero">
|
||||
<h1>文档即程序,知识可复用</h1>
|
||||
<p>这里展示真实的已安装状态、私人知识集合、受控执行与运行证据。所有“可用”都来自实际服务,不显示虚构进度。</p>
|
||||
<h1>Marqdo 工作台</h1>
|
||||
<p>查看本地运行时、私人知识和隐私状态。</p>
|
||||
</section>
|
||||
|
||||
<section id="status" class="cards" aria-live="polite">
|
||||
<div class="card"><h2>Runtime</h2><p class="big" id="status-runtime">读取中…</p><p id="status-runtime-detail" class="muted"></p></div>
|
||||
<div class="card"><h2>Std Bundle</h2><p class="big" id="status-std">读取中…</p><p id="status-std-detail" class="muted"></p></div>
|
||||
<div class="card"><h2>私人知识</h2><p class="big" id="status-knowledge">读取中…</p><p id="status-knowledge-detail" class="muted"></p></div>
|
||||
<div class="card"><h2>隐私默认</h2><p class="big" id="status-privacy">读取中…</p><p id="status-privacy-detail" class="muted"></p></div>
|
||||
<div class="card"><h2>隐私</h2><p class="big" id="status-privacy">读取中…</p><p id="status-privacy-detail" class="muted"></p></div>
|
||||
</section>
|
||||
|
||||
<nav class="tabs" role="tablist">
|
||||
<button role="tab" data-tab="knowledge" aria-selected="true">私人知识</button>
|
||||
<button role="tab" data-tab="ecosystem">生态中心</button>
|
||||
<button role="tab" data-tab="document">文稿检查</button>
|
||||
<button role="tab" data-tab="reader">文稿阅读</button>
|
||||
<button role="tab" data-tab="runs">运行记录</button>
|
||||
<button role="tab" data-tab="bootstrap">首次启动</button>
|
||||
<button role="tab" data-tab="update">更新与出口</button>
|
||||
@@ -87,7 +94,7 @@ export const APP_HTML = `<!doctype html>
|
||||
|
||||
<section id="tab-ecosystem" class="panel" role="tabpanel" hidden>
|
||||
<h2>生态目录</h2>
|
||||
<p class="muted">固定顺序 Runtime → Tool → Std → Ext → Knowledge。打开、筛选和查看详情不触发下载或执行;有副作用的操作只由按钮显式发起。</p>
|
||||
<p class="muted">按 Runtime、Tool、Std、Ext 和 Knowledge 查看本地环境。</p>
|
||||
<div id="catalog" class="catalog"></div>
|
||||
<div id="ecosystem-detail" class="results"></div>
|
||||
|
||||
@@ -162,6 +169,27 @@ export const APP_HTML = `<!doctype html>
|
||||
<div id="document-result" class="results"></div>
|
||||
</section>
|
||||
|
||||
<section id="tab-reader" class="panel" role="tabpanel" hidden>
|
||||
<h2>文稿阅读</h2>
|
||||
<p class="muted">正文由已安装 View Tool 的公开 <code>export --embed</code> 生成;标题、公式、表格、主题与媒体来自同一 View 制品。打开只做静态检查与本地导出,不执行文稿,也不联网。</p>
|
||||
<form id="reader-form" class="form inline">
|
||||
<label>工作区相对路径<input name="path" placeholder="index.mq.md" required autocomplete="off"></label>
|
||||
<label>主题<select name="theme"><option value="light">light</option><option value="dark">dark</option></select></label>
|
||||
<label>锚点(可选)<input name="anchor" placeholder="heading-id" autocomplete="off"></label>
|
||||
<button type="submit">只读打开</button>
|
||||
</form>
|
||||
<div id="reader-status" class="card" aria-live="polite">尚未打开文稿。</div>
|
||||
<div class="reader-toolbar">
|
||||
<button id="reader-source-toggle" class="ghost" type="button" disabled>查看源码</button>
|
||||
<button id="reader-runs" class="ghost" type="button">查看运行记录</button>
|
||||
<span id="reader-identity" class="muted"></span>
|
||||
</div>
|
||||
<div class="reader-frame">
|
||||
<iframe id="reader-frame" title="View 只读阅读" sandbox="allow-same-origin" referrerpolicy="no-referrer"></iframe>
|
||||
</div>
|
||||
<pre id="reader-source-text" class="code" hidden></pre>
|
||||
</section>
|
||||
|
||||
<section id="tab-runs" class="panel" role="tabpanel" hidden>
|
||||
<h2>运行记录</h2>
|
||||
<p class="muted">记录绑定源文稿摘要、Analysis、CLI/Bundle 身份与 Observation 终态;源变更后标记为过期。</p>
|
||||
@@ -225,94 +253,190 @@ export const APP_HTML = `<!doctype html>
|
||||
|
||||
/** The workbench stylesheet. */
|
||||
export const APP_CSS = `:root {
|
||||
--paper: #f6f2e8;
|
||||
--ink: #26241f;
|
||||
--muted: #6b675d;
|
||||
--olive: #4f6146;
|
||||
--olive-soft: #dfe5d6;
|
||||
--line: #d8d2c4;
|
||||
--danger: #8a3b32;
|
||||
font-family: "Noto Serif SC", "Source Han Serif SC", Georgia, serif;
|
||||
color-scheme: light dark;
|
||||
--background: light-dark(#fafafa, #202124);
|
||||
--surface: light-dark(#fff, #252629);
|
||||
--field: light-dark(#fff, #202124);
|
||||
--ink: light-dark(#202124, #ecedf0);
|
||||
--muted: light-dark(#575d66, #b4b8be);
|
||||
--line: light-dark(#e1e4e8, #37393d);
|
||||
--control-line: #838a94;
|
||||
--hover: light-dark(#eef0f2, #303236);
|
||||
--accent: light-dark(#536742, #a7b996);
|
||||
--accent-line: light-dark(#758668, #78896d);
|
||||
--selection: light-dark(#dce4d6, #414b3a);
|
||||
--status: light-dark(#ebedf0, #333538);
|
||||
--warning-bg: light-dark(#f4e9d9, #463628);
|
||||
--warning-ink: light-dark(#714b22, #f2c89a);
|
||||
--danger: light-dark(#9d3435, #f1a6a5);
|
||||
--radius: 8px;
|
||||
font: 13px / 1.5 -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC',
|
||||
'Hiragino Sans GB', 'Microsoft YaHei', 'Helvetica Neue', Helvetica, Arial, sans-serif;
|
||||
}
|
||||
|
||||
/* The desktop shell can select a scheme independently of the operating system. */
|
||||
:root[data-mqdh-scheme="light"] { color-scheme: light; }
|
||||
:root[data-mqdh-scheme="dark"] { color-scheme: dark; }
|
||||
|
||||
* { box-sizing: border-box; }
|
||||
body { margin: 0; background: var(--paper); color: var(--ink); line-height: 1.7; }
|
||||
a { color: var(--olive); }
|
||||
.top { display: flex; justify-content: space-between; gap: 1rem; align-items: center; padding: 0.9rem 1.6rem; border-bottom: 1px solid var(--line); background: #fbf8f0; flex-wrap: wrap; }
|
||||
.brand { display: flex; align-items: center; gap: 0.6rem; }
|
||||
.brand .mark { width: 1.9rem; height: 1.9rem; border-radius: 0.45rem; background: var(--olive); color: #fff; display: grid; place-items: center; font-weight: 700; }
|
||||
.brand .sub { color: var(--muted); font-size: 0.85rem; }
|
||||
.links a { margin-left: 1rem; text-decoration: none; font-size: 0.92rem; }
|
||||
.links a[aria-current="page"] { border-bottom: 2px solid var(--olive); }
|
||||
main { max-width: 1080px; margin: 0 auto; padding: 1.4rem 1.6rem 4rem; }
|
||||
.hero h1 { font-size: 1.65rem; margin: 0.6rem 0 0.3rem; }
|
||||
.hero p { color: var(--muted); margin-top: 0; }
|
||||
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 0.9rem; margin: 1.2rem 0; }
|
||||
.card { background: #fffdf8; border: 1px solid var(--line); border-radius: 0.7rem; padding: 0.9rem 1rem; }
|
||||
.card h2 { font-size: 0.9rem; margin: 0; color: var(--muted); font-weight: 600; }
|
||||
.card .big { font-size: 1.15rem; margin: 0.25rem 0; overflow-wrap: anywhere; }
|
||||
.muted { color: var(--muted); font-size: 0.86rem; overflow-wrap: anywhere; }
|
||||
.tabs { display: flex; gap: 0.4rem; flex-wrap: wrap; border-bottom: 1px solid var(--line); margin-bottom: 1rem; }
|
||||
.tabs button { background: none; border: 0; border-bottom: 2px solid transparent; padding: 0.55rem 0.8rem; font: inherit; color: var(--muted); cursor: pointer; }
|
||||
.tabs button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--olive); }
|
||||
.panel h2 { font-size: 1.1rem; margin: 1rem 0 0.6rem; }
|
||||
.split { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 1rem; margin-bottom: 1rem; }
|
||||
.form { background: #fffdf8; border: 1px solid var(--line); border-radius: 0.7rem; padding: 1rem; display: flex; flex-direction: column; gap: 0.6rem; }
|
||||
.form.inline { flex-direction: row; align-items: end; }
|
||||
.form label { display: flex; flex-direction: column; gap: 0.25rem; font-size: 0.9rem; }
|
||||
input, select, button { font: inherit; }
|
||||
input, select { padding: 0.45rem 0.55rem; border: 1px solid var(--line); border-radius: 0.4rem; background: #fff; color: var(--ink); }
|
||||
button { padding: 0.5rem 0.9rem; border-radius: 0.45rem; border: 1px solid var(--olive); background: var(--olive); color: #fff; cursor: pointer; }
|
||||
button[data-destructive="true"], button.danger { background: var(--danger); border-color: var(--danger); }
|
||||
button.ghost { background: transparent; color: var(--olive); }
|
||||
button:disabled { opacity: 0.55; cursor: progress; }
|
||||
.catalog { display: flex; flex-direction: column; gap: 1rem; margin-bottom: 1rem; }
|
||||
.group { border: 1px solid var(--line); border-radius: 0.7rem; background: #fffdf8; padding: 0.9rem 1rem; }
|
||||
.group-head { display: flex; justify-content: space-between; gap: 0.8rem; align-items: baseline; flex-wrap: wrap; }
|
||||
.group-head h3 { margin: 0; font-size: 1rem; }
|
||||
.group .list { margin-top: 0.6rem; }
|
||||
.panel h3 { font-size: 1rem; margin: 0.8rem 0 0.4rem; }
|
||||
.list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.55rem; }
|
||||
.list li { background: #fffdf8; border: 1px solid var(--line); border-radius: 0.6rem; padding: 0.75rem 0.9rem; }
|
||||
.list .row { display: flex; justify-content: space-between; gap: 0.7rem; align-items: start; flex-wrap: wrap; }
|
||||
.badge { display: inline-block; font-size: 0.75rem; padding: 0.1rem 0.45rem; border-radius: 1rem; background: var(--olive-soft); color: var(--olive); margin-left: 0.35rem; }
|
||||
.badge.warn { background: #f3e4d2; color: #7a4b20; }
|
||||
.results { margin-top: 1rem; display: flex; flex-direction: column; gap: 0.7rem; }
|
||||
.hit { border: 1px solid var(--line); border-radius: 0.6rem; padding: 0.8rem 0.9rem; background: #fffdf8; }
|
||||
.hit h3 { margin: 0 0 0.2rem; font-size: 1rem; }
|
||||
.hit .src { color: var(--muted); font-size: 0.82rem; overflow-wrap: anywhere; }
|
||||
.hit pre { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 0.85rem; margin: 0.5rem 0 0; }
|
||||
.facts { display: grid; grid-template-columns: max-content 1fr; gap: 0.35rem 1rem; font-size: 0.9rem; }
|
||||
.facts dt { color: var(--muted); }
|
||||
.facts dd { margin: 0; overflow-wrap: anywhere; }
|
||||
.code { background: #26241f; color: #f3efe5; border-radius: 0.6rem; padding: 0.9rem; overflow: auto; font-size: 0.8rem; max-height: 32rem; }
|
||||
.error { color: var(--danger); min-height: 1.5rem; }
|
||||
.foot { text-align: center; color: var(--muted); font-size: 0.8rem; padding: 1rem; border-top: 1px solid var(--line); }
|
||||
.market { border: 1px solid var(--line); border-radius: 0.7rem; background: #fffdf8; padding: 0.9rem 1rem; margin: 1rem 0; }
|
||||
.market-toolbar { display: flex; gap: 0.7rem; align-items: end; flex-wrap: wrap; margin: 0.6rem 0; }
|
||||
.market-toolbar label { display: flex; flex-direction: column; gap: 0.2rem; font-size: 0.86rem; }
|
||||
.market-toolbar input, .market-toolbar select { min-width: 11rem; }
|
||||
.segmented { display: flex; gap: 0.3rem; flex-wrap: wrap; margin: 0.4rem 0 0.6rem; }
|
||||
.segmented button { background: transparent; color: var(--olive); border-color: var(--line); }
|
||||
.segmented button[aria-selected="true"] { background: var(--olive); color: #fff; }
|
||||
.row-button { display: block; width: 100%; text-align: left; background: transparent; border: 0; color: inherit; padding: 0; cursor: pointer; }
|
||||
.row-button:focus-visible { outline: 2px solid var(--olive); outline-offset: 3px; }
|
||||
.market .list li { background: #fffdf8; }
|
||||
.source-config { margin-top: 1rem; }
|
||||
.source-config summary { cursor: pointer; color: var(--olive); }
|
||||
.permissions { display: flex; flex-wrap: wrap; gap: 0.3rem; margin: 0.35rem 0; }
|
||||
.permissions span { font-size: 0.78rem; border: 1px solid var(--line); border-radius: 1rem; padding: 0.05rem 0.45rem; }
|
||||
@media (prefers-color-scheme: dark) {
|
||||
:root { --paper: #17181a; --ink: #e8e6e0; --muted: #aaa79f; --olive: #a7bd94; --olive-soft: #2d352a; --line: #3a3b35; --danger: #e08a80; }
|
||||
body { background: var(--paper); color: var(--ink); }
|
||||
.top, .card, .form, .group, .list li, .hit, .market, .market .list li { background: #20211e; }
|
||||
input, select { background: #262722; color: var(--ink); }
|
||||
.code { background: #0e0f0d; color: #ece9df; }
|
||||
.market-toolbar input, .market-toolbar select { background: #262722; }
|
||||
body { margin: 0; background: var(--background); color: var(--ink); }
|
||||
h1, h2, h3, strong, b { font-weight: 500; }
|
||||
a { color: var(--accent); }
|
||||
|
||||
.top {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
padding: 12px 24px;
|
||||
border-bottom: 1px solid var(--line);
|
||||
background: var(--surface);
|
||||
}
|
||||
.brand, .links { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
|
||||
body[data-embedded] > .top { display: none; }
|
||||
.brand .sub { color: var(--muted); }
|
||||
.links a { text-decoration: none; }
|
||||
.links a[aria-current="page"] { border-bottom: 2px solid var(--accent); }
|
||||
|
||||
main { max-width: 1120px; margin: 0 auto; padding: 24px 24px 40px; }
|
||||
.hero h1 { font-size: 22px; line-height: 28px; margin: 0 0 4px; }
|
||||
.hero p { color: var(--muted); margin: 0; }
|
||||
.cards {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fit, minmax(min(100%, 152px), 1fr));
|
||||
gap: 16px;
|
||||
margin: 20px 0;
|
||||
}
|
||||
.card { min-height: 136px; padding: 14px 16px; }
|
||||
.card h2 { font-size: 13px; margin: 0; color: var(--muted); }
|
||||
.card .big { font-size: 17px; line-height: 24px; font-weight: 500; margin: 6px 0; overflow-wrap: anywhere; }
|
||||
.card .muted { margin: 0; }
|
||||
.muted { color: var(--muted); overflow-wrap: anywhere; }
|
||||
|
||||
.tabs {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 0 4px;
|
||||
border-bottom: 1px solid var(--line);
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
.tabs button {
|
||||
background: transparent;
|
||||
border: 0;
|
||||
border-block-end: 2px solid transparent;
|
||||
border-radius: var(--radius) var(--radius) 0 0;
|
||||
padding: 7px 10px;
|
||||
color: var(--muted);
|
||||
}
|
||||
.tabs button[aria-selected="true"] {
|
||||
color: var(--ink);
|
||||
border-block-end-color: var(--accent);
|
||||
font-weight: 500;
|
||||
}
|
||||
.panel h2 { font-size: 17px; line-height: 24px; margin: 16px 0 8px; }
|
||||
.panel > .muted { margin: 0 0 12px; }
|
||||
.panel h3 { font-size: 15px; margin: 12px 0 6px; }
|
||||
.split {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr));
|
||||
gap: 16px;
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
|
||||
.card, .form, .group, .list li, .hit, .market, .reader-frame {
|
||||
border: 1px solid var(--line);
|
||||
border-radius: var(--radius);
|
||||
background: var(--surface);
|
||||
}
|
||||
.form { padding: 16px; display: flex; flex-direction: column; gap: 8px; }
|
||||
.form.inline { flex-direction: row; flex-wrap: wrap; align-items: end; }
|
||||
.form label { display: flex; flex-direction: column; gap: 4px; }
|
||||
input, select, textarea, button { font: inherit; max-inline-size: 100%; }
|
||||
input, select, textarea {
|
||||
padding: 6px 8px;
|
||||
border: 1px solid var(--control-line);
|
||||
border-radius: var(--radius);
|
||||
background: var(--field);
|
||||
color: var(--ink);
|
||||
}
|
||||
button {
|
||||
padding: 6px 12px;
|
||||
border: 1px solid var(--control-line);
|
||||
border-radius: var(--radius);
|
||||
background: var(--surface);
|
||||
color: var(--ink);
|
||||
cursor: pointer;
|
||||
}
|
||||
button.ghost { background: transparent; border-color: var(--accent-line); color: var(--accent); }
|
||||
button[data-destructive="true"], button.danger { color: var(--danger); }
|
||||
button:disabled { color: var(--muted); cursor: default; }
|
||||
:where(a, button, input, select, textarea, summary):focus-visible {
|
||||
outline: 2px solid var(--accent);
|
||||
outline-offset: 2px;
|
||||
}
|
||||
@media (hover: hover) {
|
||||
button:not(:disabled):hover { background-color: var(--hover); }
|
||||
}
|
||||
|
||||
.catalog, .results { display: flex; flex-direction: column; gap: 12px; margin-bottom: 16px; }
|
||||
.group, .market { padding: 12px 16px; }
|
||||
.group-head { display: flex; justify-content: space-between; gap: 6px 16px; align-items: baseline; flex-wrap: wrap; }
|
||||
.group-head h3, .group-head p { margin: 0; }
|
||||
.group .list { margin-top: 12px; }
|
||||
.list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
|
||||
.list li, .hit { padding: 10px 12px; min-inline-size: 0; }
|
||||
.list .row { display: flex; justify-content: space-between; gap: 8px 12px; align-items: center; flex-wrap: wrap; }
|
||||
.catalog .list li { padding: 12px; }
|
||||
.catalog .row { align-items: flex-start; }
|
||||
.catalog .row > div:first-child { flex: 1 1 240px; min-inline-size: 0; }
|
||||
.catalog .row > div:empty { display: none; }
|
||||
.catalog .row p { margin: 4px 0 0; }
|
||||
.badge {
|
||||
display: inline-block;
|
||||
font-size: 12px;
|
||||
padding: 1px 6px;
|
||||
border-radius: 999px;
|
||||
background: var(--status);
|
||||
color: var(--muted);
|
||||
margin-inline-start: 6px;
|
||||
}
|
||||
.badge.warn { background: var(--warning-bg); color: var(--warning-ink); }
|
||||
.results { margin-top: 16px; }
|
||||
.results:empty { display: none; }
|
||||
.hit h3 { margin: 0 0 4px; }
|
||||
.hit .src { color: var(--muted); overflow-wrap: anywhere; }
|
||||
.hit pre { white-space: pre-wrap; overflow-wrap: anywhere; margin: 8px 0 0; }
|
||||
.facts { display: grid; grid-template-columns: fit-content(40%) minmax(0, 1fr); gap: 4px 16px; }
|
||||
.facts dt { color: var(--muted); overflow-wrap: anywhere; }
|
||||
.facts dd { margin: 0; overflow-wrap: anywhere; }
|
||||
.code {
|
||||
background: light-dark(#eef0f2, #191a1c);
|
||||
color: var(--ink);
|
||||
border-radius: var(--radius);
|
||||
padding: 12px;
|
||||
overflow: auto;
|
||||
max-height: 32rem;
|
||||
}
|
||||
.error { color: var(--danger); min-block-size: 1.5rem; }
|
||||
.foot { text-align: center; color: var(--muted); font-size: 12px; padding: 16px; border-top: 1px solid var(--line); }
|
||||
.reader-toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 12px 0; }
|
||||
.reader-frame { overflow: hidden; }
|
||||
.reader-frame iframe { display: block; width: 100%; min-height: 70vh; border: 0; background: var(--field); }
|
||||
.market { margin: 16px 0; }
|
||||
.market-toolbar { display: flex; gap: 8px; align-items: end; flex-wrap: wrap; margin: 12px 0; }
|
||||
.market-toolbar label { display: flex; flex-direction: column; gap: 4px; }
|
||||
.segmented { display: flex; gap: 4px; flex-wrap: wrap; margin: 6px 0 10px; }
|
||||
.segmented button[aria-selected="true"], .segmented button[aria-selected="true"]:hover { background: var(--selection); }
|
||||
.row-button { display: block; width: 100%; text-align: left; background: transparent; border: 0; color: inherit; padding: 0; }
|
||||
.source-config { margin-top: 16px; }
|
||||
.source-config summary { cursor: pointer; color: var(--accent); }
|
||||
.permissions { display: flex; flex-wrap: wrap; gap: 4px; margin: 6px 0; }
|
||||
.permissions span { font-size: 12px; border: 1px solid var(--line); border-radius: 999px; padding: 1px 6px; }
|
||||
|
||||
@media (max-width: 640px) {
|
||||
main { padding: 1rem; }
|
||||
main, .top { padding-inline: 16px; }
|
||||
.form.inline { flex-direction: column; align-items: stretch; }
|
||||
.links a { margin-left: 0; margin-right: 0.9rem; }
|
||||
}
|
||||
`
|
||||
|
||||
@@ -453,6 +577,7 @@ function renderSearch(data) {
|
||||
el('h3', { text: hit.title || hit.rel_path }),
|
||||
el('div', { class: 'src', text: hit.collection_name + ' / ' + hit.rel_path + ' · ' + hit.digest + (hit.stale ? ' · 源已变更(STALE)' : '') }),
|
||||
el('pre', { text: hit.snippet || '' }),
|
||||
el('button', { class: 'ghost', type: 'button', text: '在 View 阅读', onclick: () => openKnowledgeReader(hit) }),
|
||||
));
|
||||
}
|
||||
}
|
||||
@@ -483,12 +608,12 @@ async function loadEcosystem() {
|
||||
ecosystem.runtime.installed
|
||||
? (ecosystem.runtime.version + ' · ' + ecosystem.runtime.platform + ' · ' + short(ecosystem.runtime.path, 90))
|
||||
: '未安装;首次启动或生态中心可安装受信任 CLI 基础发行',
|
||||
[el('button', { class: 'ghost', type: 'button', text: '检查受信任候选', onclick: () => checkCandidates() })])];
|
||||
[el('button', { class: 'ghost', type: 'button', text: '检查候选', onclick: () => checkCandidates() })])];
|
||||
runtimeRows.push(catalogRow('Bundle',
|
||||
ecosystem.std.installed ? '已校验' : '不可用',
|
||||
ecosystem.std.installed ? (ecosystem.std.version + ' · ' + ecosystem.std.digest + ' · ' + ecosystem.std.modules.length + ' 个模块') : '随 Runtime 作为单一 Bundle 安装,不逐模块启停'));
|
||||
runtimeRows.push(catalogRow('活动环境', environment ? '已记录' : '无',
|
||||
environment ? (environment.id + ' · source ' + (environment.source_sha || 'unknown')) : '没有 current.json',
|
||||
environment ? (environment.id + ' · source ' + (environment.source_sha || 'unknown')) : '尚未激活运行环境',
|
||||
[el('button', { class: 'ghost', type: 'button', text: '查看安装/恢复', onclick: () => $('#install-form').scrollIntoView({ behavior: 'smooth' }) })]));
|
||||
if (ecosystem.staging.length > 0) {
|
||||
runtimeRows.push(catalogRow('候选 staging', '待验证', ecosystem.staging.join(', ') + '(未激活,不会被当作已安装)'));
|
||||
@@ -902,7 +1027,7 @@ function renderMarketProject() {
|
||||
host.append(el('p', { text: 'marqdo.lock:' + (project.lock.present ? project.lock.digest : '缺失') }));
|
||||
const imports = [];
|
||||
for (const capability of data.capabilities) {
|
||||
for (const item of capability.imports) imports.push(capability.name + ' -> ' + item.alias + ' (' + item.path + ')');
|
||||
for (const item of capability.imports || []) imports.push(capability.name + ' -> ' + item.alias + ' (' + item.path + ')');
|
||||
}
|
||||
host.append(el('p', { class: 'muted', text: imports.length === 0 ? '尚无应用记录的导入。' : '应用记录的导入:' + imports.join(';') }));
|
||||
host.append(el('p', { class: 'muted', text: '锁由 CLI 生成与校验;应用不解析第二套依赖图,也不把锁当作运行授权。' }));
|
||||
@@ -929,6 +1054,79 @@ function renderMarketProject() {
|
||||
host.append(row);
|
||||
}
|
||||
|
||||
const readerState = { kind: 'workspace', path: '', collection: null, theme: 'light', anchor: '', package: null };
|
||||
|
||||
async function loadReaderStatus() {
|
||||
const status = $('#reader-status');
|
||||
if (!status) return;
|
||||
try {
|
||||
const data = await api('/reader/status');
|
||||
if (data.available) {
|
||||
const view = data.view;
|
||||
status.textContent = 'View ' + (view.version || 'unknown') + ' · ' + short(view.binary_sha256, 24) + ' · CLI ' + (data.cli?.version || 'unknown') + ' 可用。打开只读阅读不会执行文稿。';
|
||||
$('#reader-form').querySelector('button').disabled = false;
|
||||
} else {
|
||||
status.textContent = '阅读不可用:' + (data.error || 'View Tool 未安装') + '。可到“生态中心 → Tool”安装 View。';
|
||||
$('#reader-form').querySelector('button').disabled = true;
|
||||
}
|
||||
} catch (error) {
|
||||
status.textContent = '读取 View 状态失败:' + error.message;
|
||||
}
|
||||
}
|
||||
|
||||
async function openReader(request) {
|
||||
const status = $('#reader-status');
|
||||
const identity = $('#reader-identity');
|
||||
const frame = $('#reader-frame');
|
||||
clear($('#reader-source-text'));
|
||||
$('#reader-source-text').hidden = true;
|
||||
if (status) status.textContent = '正在静态检查并导出 View 阅读包…';
|
||||
if (identity) identity.textContent = '';
|
||||
if (frame) frame.removeAttribute('src');
|
||||
try {
|
||||
const data = await api('/reader/open', { method: 'POST', body: JSON.stringify({
|
||||
confirm: true,
|
||||
kind: request.kind || 'workspace',
|
||||
path: request.path,
|
||||
collection: request.collection || undefined,
|
||||
theme: request.theme || 'light',
|
||||
anchor: request.anchor || undefined,
|
||||
}) });
|
||||
readerState.kind = data.source.kind;
|
||||
readerState.path = data.source.relative;
|
||||
readerState.collection = data.source.collection;
|
||||
readerState.theme = data.theme;
|
||||
readerState.anchor = data.anchor || '';
|
||||
readerState.package = data;
|
||||
if (frame) frame.setAttribute('src', data.package_url);
|
||||
if (status) status.textContent = (data.cached ? '已复用缓存阅读包。' : '已生成并校验阅读包。') + ' 正文来自 View ' + (data.view.version || 'unknown') + ',未执行文稿。';
|
||||
if (identity) identity.textContent = 'source ' + data.source.digest + ' · manifest ' + data.manifest_sha256 + (data.anchor ? ' · anchor ' + data.anchor : '');
|
||||
$('#reader-source-toggle').disabled = false;
|
||||
} catch (error) {
|
||||
if (status) status.textContent = '打开阅读失败:' + error.message + (error.code === 'reader.view_missing' ? '。请先在生态中心安装 View Tool。' : '');
|
||||
if (frame) frame.removeAttribute('src');
|
||||
}
|
||||
}
|
||||
|
||||
async function openKnowledgeReader(hit) {
|
||||
const button = document.querySelector('[data-tab="reader"]');
|
||||
if (button) button.click();
|
||||
await openReader({ kind: 'knowledge', path: hit.rel_path, collection: hit.collection, theme: 'light', anchor: hit.anchor || '' });
|
||||
}
|
||||
|
||||
async function loadReaderSource() {
|
||||
const pkg = readerState.package;
|
||||
if (!pkg) return;
|
||||
try {
|
||||
const query = new URLSearchParams({ kind: readerState.kind, path: readerState.path });
|
||||
if (readerState.collection) query.set('collection', readerState.collection);
|
||||
const data = await api('/reader/source?' + query.toString());
|
||||
const node = $('#reader-source-text');
|
||||
node.textContent = data.text + (data.truncated ? '\\n…(已截断)' : '');
|
||||
node.hidden = false;
|
||||
} catch (error) { showError('读取源码失败:' + error.message); }
|
||||
}
|
||||
|
||||
async function loadRuns() {
|
||||
try {
|
||||
const data = await api('/runs');
|
||||
@@ -1119,6 +1317,7 @@ function bind() {
|
||||
});
|
||||
const tab = button.dataset.tab;
|
||||
if (tab === 'ecosystem') { loadEcosystem(); loadMarket(); }
|
||||
if (tab === 'reader') loadReaderStatus();
|
||||
if (tab === 'bootstrap') loadBootstrap();
|
||||
if (tab === 'update') { loadUpdate(); loadNetwork(); }
|
||||
if (tab === 'reports') loadReports();
|
||||
@@ -1186,6 +1385,13 @@ function bind() {
|
||||
await loadMarket();
|
||||
} catch (error) { showError('添加来源失败:' + error.message); }
|
||||
});
|
||||
$('#reader-form').addEventListener('submit', async (event) => {
|
||||
event.preventDefault();
|
||||
const form = new FormData(event.target);
|
||||
await openReader({ kind: 'workspace', path: String(form.get('path') || ''), theme: String(form.get('theme') || 'light'), anchor: String(form.get('anchor') || '') });
|
||||
});
|
||||
$('#reader-source-toggle').addEventListener('click', async () => { await loadReaderSource(); });
|
||||
$('#reader-runs').addEventListener('click', () => { document.querySelector('[data-tab="runs"]').click(); });
|
||||
$('#create-collection').addEventListener('submit', async (event) => {
|
||||
event.preventDefault();
|
||||
const form = new FormData(event.target);
|
||||
@@ -1305,5 +1511,6 @@ loadStatus();
|
||||
loadCollections();
|
||||
loadEcosystem();
|
||||
loadMarket();
|
||||
loadReaderStatus();
|
||||
loadRuns();
|
||||
`
|
||||
@@ -19,8 +19,9 @@ import type { DiagnosticArea } from '../diagnostics/contract.ts'
|
||||
import { discoverRelease } from '../ecosystem/sources.ts'
|
||||
import { parseSourceConfig } from '../market/config.ts'
|
||||
import { MarketError } from '../market/errors.ts'
|
||||
import { ReaderError } from '../reader/errors.ts'
|
||||
import { runProcess } from '../core/process.ts'
|
||||
import { APP_CSS, APP_HTML, APP_JS } from './assets.ts'
|
||||
import { APP_CSS, APP_HTML, BRAND_SVG, APP_JS } from './assets.ts'
|
||||
import { isLoopbackAuthority, isTrustedAuthority } from './trust.ts'
|
||||
|
||||
/** Stable Cordis plugin name. */
|
||||
@@ -53,7 +54,7 @@ class HttpError extends Error {
|
||||
|
||||
/** Read a bounded request body. */
|
||||
async function readBody(req: IncomingMessage, maxBytes: number): Promise<Buffer> {
|
||||
const chunks: Buffer[] = []
|
||||
const chunks: Uint8Array[] = []
|
||||
let total = 0
|
||||
for await (const chunk of req) {
|
||||
const bytes = Buffer.from(chunk)
|
||||
@@ -61,7 +62,7 @@ async function readBody(req: IncomingMessage, maxBytes: number): Promise<Buffer>
|
||||
if (total > maxBytes) throw new HttpError(413, 'request body exceeds its limit')
|
||||
chunks.push(bytes)
|
||||
}
|
||||
return Buffer.concat(chunks)
|
||||
return Buffer.concat(chunks.map(chunk => Buffer.from(chunk)))
|
||||
}
|
||||
|
||||
/** Parse a JSON body. */
|
||||
@@ -90,7 +91,7 @@ function registerRoutes(
|
||||
runtime: MdhRuntime,
|
||||
config: { trustedHosts: readonly string[]; bindHost?: string | undefined },
|
||||
): void {
|
||||
const webServer = ctx.get('webServer' as never) as {
|
||||
const webServer = ctx.get('webServer') as {
|
||||
register(route: {
|
||||
kind: 'prefix'
|
||||
path: string
|
||||
@@ -124,11 +125,15 @@ function registerRoutes(
|
||||
const url = new URL(req.url ?? '/', `http://${req.headers.host ?? '127.0.0.1'}`)
|
||||
const pathname = url.pathname.replace(/\/+$/, '') || '/'
|
||||
if (pathname === '/mqdh' && (req.method === 'GET' || req.method === 'HEAD')) {
|
||||
const embedded = url.searchParams.get('embedded') === '1'
|
||||
if (embedded) fence(req)
|
||||
const html = APP_HTML.replace('__MQDH_ORIGIN__', JSON.stringify(url.origin))
|
||||
.replace('__MQDH_EMBEDDED__', embedded ? ' data-embedded' : '')
|
||||
const ancestors = embedded ? "'self'" : "'none'"
|
||||
res.writeHead(200, {
|
||||
'content-type': 'text/html; charset=utf-8',
|
||||
'content-length': Buffer.byteLength(html),
|
||||
'content-security-policy': "default-src 'none'; script-src 'self'; style-src 'self'; img-src 'self' data:; connect-src 'self'; form-action 'self'; base-uri 'none'; frame-ancestors 'none'",
|
||||
'content-security-policy': `default-src 'none'; script-src 'self'; style-src 'self'; img-src 'self' data:; connect-src 'self'; frame-src 'self'; form-action 'self'; base-uri 'none'; frame-ancestors ${ancestors}`,
|
||||
'x-content-type-options': 'nosniff',
|
||||
'referrer-policy': 'no-referrer',
|
||||
'cache-control': 'no-store',
|
||||
@@ -136,6 +141,16 @@ function registerRoutes(
|
||||
res.end(req.method === 'HEAD' ? undefined : html)
|
||||
return
|
||||
}
|
||||
if (pathname === '/mqdh/brand.svg' && (req.method === 'GET' || req.method === 'HEAD')) {
|
||||
res.writeHead(200, {
|
||||
'content-type': 'image/svg+xml',
|
||||
'content-length': BRAND_SVG.length,
|
||||
'x-content-type-options': 'nosniff',
|
||||
'cache-control': 'no-cache',
|
||||
})
|
||||
res.end(req.method === 'HEAD' ? undefined : BRAND_SVG)
|
||||
return
|
||||
}
|
||||
if (pathname === '/mqdh/app.css' && req.method === 'GET') {
|
||||
res.writeHead(200, { 'content-type': 'text/css; charset=utf-8', 'cache-control': 'no-store' })
|
||||
res.end(APP_CSS)
|
||||
@@ -153,6 +168,7 @@ function registerRoutes(
|
||||
} catch (error) {
|
||||
if (error instanceof HttpError) { json(res, error.status, { error: error.message }); return }
|
||||
if (error instanceof MarketError) { json(res, 409, { error: error.message, code: error.code }); return }
|
||||
if (error instanceof ReaderError) { json(res, 409, { error: error.message, code: error.code }); return }
|
||||
const message = error instanceof Error ? error.message : String(error)
|
||||
const path = req.url ?? ''
|
||||
const area: DiagnosticArea = path.startsWith('/mqdh/api/knowledge') ? 'knowledge'
|
||||
@@ -302,6 +318,71 @@ async function handleApi(
|
||||
})
|
||||
return
|
||||
}
|
||||
if (path === '/reader/status' && method === 'GET') {
|
||||
json(res, 200, await runtime.readerStatus())
|
||||
return
|
||||
}
|
||||
if (path === '/reader/open' && method === 'POST') {
|
||||
const body = await readJson(req)
|
||||
if (body.confirm !== true) throw new HttpError(400, 'opening the reader requires explicit confirmation')
|
||||
const kind = body.kind
|
||||
if (kind !== 'workspace' && kind !== 'knowledge') throw new HttpError(400, 'kind must be workspace or knowledge')
|
||||
const sourcePath = stringField(body, 'path')
|
||||
let theme: 'light' | 'dark' | undefined
|
||||
if (body.theme !== undefined) {
|
||||
if (body.theme !== 'light' && body.theme !== 'dark') throw new HttpError(400, 'theme must be light or dark')
|
||||
theme = body.theme
|
||||
}
|
||||
const collection = typeof body.collection === 'string' && body.collection.trim() !== '' ? body.collection.trim() : undefined
|
||||
const anchor = typeof body.anchor === 'string' && body.anchor.trim() !== '' ? body.anchor.trim() : undefined
|
||||
json(res, 200, await runtime.openReader({
|
||||
kind,
|
||||
path: sourcePath,
|
||||
...(collection === undefined ? {} : { collection }),
|
||||
...(theme === undefined ? {} : { theme }),
|
||||
...(anchor === undefined ? {} : { anchor }),
|
||||
...(body.force === true ? { force: true } : {}),
|
||||
}))
|
||||
return
|
||||
}
|
||||
if (path === '/reader/source' && method === 'GET') {
|
||||
const kind = url.searchParams.get('kind') ?? 'workspace'
|
||||
if (kind !== 'workspace' && kind !== 'knowledge') throw new HttpError(400, 'kind must be workspace or knowledge')
|
||||
const sourcePath = url.searchParams.get('path') ?? ''
|
||||
if (sourcePath === '') throw new HttpError(400, 'missing path')
|
||||
const collection = url.searchParams.get('collection') ?? undefined
|
||||
json(res, 200, await runtime.readerSource({
|
||||
kind,
|
||||
path: sourcePath,
|
||||
...(collection === undefined || collection === '' ? {} : { collection }),
|
||||
}))
|
||||
return
|
||||
}
|
||||
const readerPackageMatch = /^\/reader\/package\/([a-f0-9]{64})\/(.+)$/.exec(path)
|
||||
if (readerPackageMatch && method === 'GET') {
|
||||
const id = readerPackageMatch[1]
|
||||
const encodedPath = readerPackageMatch[2]
|
||||
if (id === undefined || encodedPath === undefined) throw new HttpError(400, 'invalid reader package path')
|
||||
let filePath: string
|
||||
try {
|
||||
filePath = decodeURIComponent(encodedPath)
|
||||
} catch {
|
||||
throw new HttpError(400, 'invalid reader package path')
|
||||
}
|
||||
const file = await runtime.reader.packageFile(id, filePath)
|
||||
res.writeHead(200, {
|
||||
'content-type': file.contentType,
|
||||
'content-length': file.body.byteLength,
|
||||
'cache-control': 'no-store',
|
||||
'x-content-type-options': 'nosniff',
|
||||
'referrer-policy': 'no-referrer',
|
||||
...(file.contentType.startsWith('text/html')
|
||||
? { 'content-security-policy': "default-src 'none'; style-src 'self'; font-src 'self'; img-src 'self' data:; media-src 'self'; base-uri 'none'; form-action 'none'; frame-ancestors 'self'" }
|
||||
: {}),
|
||||
})
|
||||
res.end(file.body)
|
||||
return
|
||||
}
|
||||
if (path === '/market' && method === 'GET') {
|
||||
const config = await runtime.market.config()
|
||||
json(res, 200, {
|
||||
@@ -668,7 +749,7 @@ async function handleApi(
|
||||
proxy_https: config.proxy.https !== null,
|
||||
proxy_http: config.proxy.http !== null,
|
||||
no_proxy_entries: config.proxy.noProxy.length,
|
||||
mirrors: Object.entries(config.mirrors).map(([purpose, base]) => `${purpose}=${String(base)}`),
|
||||
mirrors: Object.entries(config.mirrors).map(([purpose, base]) => `${purpose}=${base}`),
|
||||
allowed_hosts: config.allowedHosts,
|
||||
allow_loopback: config.allowLoopback,
|
||||
allow_private: config.allowPrivate,
|
||||
@@ -756,7 +837,7 @@ async function handleApi(
|
||||
|
||||
/** Register the workbench and its API over the DSH web server. */
|
||||
export function apply(ctx: Context, config: { trustedHosts?: readonly string[] | undefined; bindHost?: string | undefined } = {}): void {
|
||||
const runtime = ctx.get('mqdhRuntime' as never) as MdhRuntime | undefined
|
||||
const runtime = ctx.get('mqdhRuntime') as MdhRuntime | undefined
|
||||
if (!runtime) throw new Error('mqdh-web requires mqdhRuntime')
|
||||
registerRoutes(ctx, runtime, { trustedHosts: config.trustedHosts ?? [], bindHost: config.bindHost })
|
||||
}
|
||||
@@ -41,6 +41,9 @@ test('the product bundle disables the Node PTC preset and plugin installation',
|
||||
const byId = new Map(rows.map(row => [row.id, row]))
|
||||
assert.equal(byId.get('preset-ptc')?.disabled, true)
|
||||
assert.equal(byId.get('plugin-manager')?.disabled, true)
|
||||
assert.equal(byId.get('ui-plugin-manager')?.disabled, true)
|
||||
assert.equal(byId.get('ui-brand-official')?.disabled, true)
|
||||
assert.ok(byId.has('mqdh-ui'))
|
||||
assert.equal(byId.get('tool-plugin-manager')?.disabled, true)
|
||||
assert.equal(byId.get('session-log-deepseek')?.disabled, true)
|
||||
assert.equal(byId.get('session-telemetry-otel')?.disabled, true)
|
||||
|
||||
@@ -80,3 +80,32 @@ test('a token is read from stdin and stored without appearing in output', async
|
||||
assert.doesNotMatch(output.out.join(''), new RegExp(token))
|
||||
assert.equal(await runtime.diagnostics.hasToken(), true)
|
||||
})
|
||||
|
||||
test('status emits a read-only app and ecosystem version view', async () => {
|
||||
const root = await mkdtemp(join(tmpdir(), 'mqdh-cli-'))
|
||||
const runtime = await MdhRuntime.create({ home: join(root, 'home'), workspace: join(root, 'ws') })
|
||||
const view = sink()
|
||||
const code = await runProductCli(['status', '--json'], { io: view.io, runtime: async () => runtime })
|
||||
assert.equal(code, 0)
|
||||
const parsed = JSON.parse(view.out.join('')) as {
|
||||
schema: string
|
||||
app: { version: string; home: string }
|
||||
ecosystem: { runtime: { installed: boolean }; std: { installed: boolean; modules: string[] } }
|
||||
privacy: { telemetry: boolean; sessionUpload: boolean; pluginInstall: boolean }
|
||||
update: { schema: string; channel: string; checked_at: string | null; latest: unknown }
|
||||
}
|
||||
assert.equal(parsed.schema, 'marqdo.mqdh.status')
|
||||
assert.equal(parsed.app.version, APP_VERSION)
|
||||
assert.equal(parsed.ecosystem.runtime.installed, false)
|
||||
assert.equal(parsed.ecosystem.std.installed, false)
|
||||
assert.deepEqual(parsed.privacy, { telemetry: false, sessionUpload: false, pluginInstall: false })
|
||||
assert.equal(parsed.update.schema, 'marqdo.mqdh.update')
|
||||
assert.equal(parsed.update.channel, 'stable')
|
||||
assert.equal(parsed.update.checked_at, null)
|
||||
assert.equal(parsed.update.latest, null)
|
||||
const text = sink()
|
||||
assert.equal(await runProductCli(['status'], { io: text.io, runtime: async () => runtime }), 0)
|
||||
assert.match(text.out.join(''), /^app: /)
|
||||
assert.match(text.out.join(''), /privacy: telemetry=false/)
|
||||
assert.match(text.out.join(''), /update: channel=stable checked=never/)
|
||||
})
|
||||
@@ -0,0 +1,28 @@
|
||||
/** The platform-specific application install root. */
|
||||
|
||||
import assert from 'node:assert/strict'
|
||||
import { homedir, platform } from 'node:os'
|
||||
import { join, resolve } from 'node:path'
|
||||
import { test } from 'node:test'
|
||||
|
||||
import { defaultInstallRoot, installLayoutOf, isSafeVersionId } from '../src/distribution/install-root.ts'
|
||||
|
||||
test('the default install root follows the platform convention', () => {
|
||||
if (platform() === 'win32') {
|
||||
const base = process.env.LOCALAPPDATA?.trim()
|
||||
const expected = join(base !== undefined && base !== '' ? base : join(homedir(), 'AppData', 'Local'), 'MQDH')
|
||||
assert.equal(defaultInstallRoot(), expected)
|
||||
} else {
|
||||
assert.equal(defaultInstallRoot(), join(homedir(), '.local', 'opt', 'mqdh'))
|
||||
}
|
||||
})
|
||||
|
||||
test('the install layout keeps versions, pointer and launcher separate', () => {
|
||||
const root = resolve('mqdh-root-fixture')
|
||||
const layout = installLayoutOf(root)
|
||||
assert.equal(layout.versions, join(root, 'versions'))
|
||||
assert.equal(layout.current, join(root, 'current.json'))
|
||||
assert.equal(layout.bin, join(root, 'bin'))
|
||||
assert.equal(isSafeVersionId('0.1.0-beta.1-abcdef123456'), true)
|
||||
assert.equal(isSafeVersionId('../escape'), false)
|
||||
})
|
||||
@@ -342,6 +342,9 @@ test('project import materializes a project-local copy and delegates add to the
|
||||
assert.equal(imported.next, 'marqdo lock')
|
||||
assert.match(await readFile(join(f.workspace, 'marqdo-vendor', 'demo', 'index.mq.md'), 'utf8'), /return 1/)
|
||||
assert.match(await readFile(join(f.workspace, 'marqdo.yaml'), 'utf8'), /demo/)
|
||||
const view = await store.capability(key)
|
||||
assert.equal(view?.imports.length, 1)
|
||||
assert.equal(view?.imports[0]?.project_path, 'marqdo-vendor/demo')
|
||||
} finally {
|
||||
await cleanup(join(f.home, '..'))
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@ test('target triples map Node runtime identities to release names', () => {
|
||||
assert.equal(targetTriple('darwin', 'x64'), 'x86_64-apple-darwin')
|
||||
assert.equal(targetTriple('win32', 'x64'), 'x86_64-pc-windows-msvc')
|
||||
assert.equal((PUBLISHED_TARGETS as readonly string[]).includes('x86_64-unknown-linux-gnu'), true)
|
||||
assert.equal((PUBLISHED_TARGETS as readonly string[]).includes('x86_64-pc-windows-msvc'), true)
|
||||
assert.equal((PUBLISHED_TARGETS as readonly string[]).includes('aarch64-apple-darwin'), false)
|
||||
})
|
||||
|
||||
|
||||
@@ -0,0 +1,114 @@
|
||||
/** View embedded manifest validation and package file safety. */
|
||||
|
||||
import assert from 'node:assert/strict'
|
||||
import { mkdtemp, writeFile } from 'node:fs/promises'
|
||||
import { tmpdir } from 'node:os'
|
||||
import { join } from 'node:path'
|
||||
import { test } from 'node:test'
|
||||
|
||||
import {
|
||||
assertPackagePath, parseViewManifest, validateViewManifest, verifyPackageFiles,
|
||||
} from '../src/reader/contract.ts'
|
||||
import { contentTypeOf } from '../src/reader/service.ts'
|
||||
import { READER_ERROR, ReaderError } from '../src/reader/errors.ts'
|
||||
|
||||
const hex = (char: string): string => char.repeat(64)
|
||||
|
||||
/** Build one valid View embedded manifest. */
|
||||
function manifest(overrides: Record<string, unknown> = {}): Record<string, unknown> {
|
||||
const base = {
|
||||
schema: 'marqdo.view-export',
|
||||
schema_version: 1,
|
||||
mode: 'embedded',
|
||||
theme: 'dark',
|
||||
executed: false,
|
||||
requires: { api_revision: 1, analysis: 3, observation: 1, markdown_profile: 'marqdo.md.v1' },
|
||||
producers: {
|
||||
view: { name: 'marqdo-view', version: '0.3.0', binary_sha256: hex('a') },
|
||||
cli: { version: '3.0.0-rc.6', binary_sha256: hex('b') },
|
||||
},
|
||||
entry: {
|
||||
href: 'index.html#detail',
|
||||
file: 'index.html',
|
||||
heading_ids: ['detail', 'intro'],
|
||||
relative_path: 'doc.md',
|
||||
anchor: 'detail',
|
||||
sha256: hex('c'),
|
||||
},
|
||||
pages: [{
|
||||
source_sha256: hex('d'),
|
||||
source_status: 'static-ok',
|
||||
relative_path: 'doc.md',
|
||||
sha256: hex('c'),
|
||||
}],
|
||||
files: [{ path: 'index.html', sha256: hex('c') }],
|
||||
assets: [],
|
||||
}
|
||||
return { ...base, ...overrides }
|
||||
}
|
||||
|
||||
/** Expected identities for the valid manifest. */
|
||||
const expected = {
|
||||
sourceSha256: hex('d'),
|
||||
viewBinarySha256: hex('a'),
|
||||
cliBinarySha256: hex('b'),
|
||||
theme: 'dark' as const,
|
||||
anchor: 'detail',
|
||||
relativePath: 'doc.md',
|
||||
}
|
||||
|
||||
/** Assert one reader failure code. */
|
||||
function rejectCode(run: () => unknown, code: string): void {
|
||||
assert.throws(() => { run() }, (error: unknown) => error instanceof ReaderError && error.code === code)
|
||||
}
|
||||
|
||||
void test('a View embedded manifest validates against exact source and producer identities', () => {
|
||||
const parsed = parseViewManifest(manifest())
|
||||
validateViewManifest(parsed, expected)
|
||||
assert.equal(parsed.mode, 'embedded')
|
||||
assert.equal(parsed.executed, false)
|
||||
assert.equal(parsed.entry.heading_ids[0], 'detail')
|
||||
})
|
||||
|
||||
void test('View manifest identity mismatches fail closed', () => {
|
||||
const base = parseViewManifest(manifest())
|
||||
rejectCode(() => { validateViewManifest(base, { ...expected, sourceSha256: hex('f') }) }, READER_ERROR.sourceChanged)
|
||||
rejectCode(() => { validateViewManifest(base, { ...expected, viewBinarySha256: hex('f') }) }, READER_ERROR.manifestInvalid)
|
||||
rejectCode(() => { validateViewManifest(base, { ...expected, theme: 'light' }) }, READER_ERROR.manifestInvalid)
|
||||
rejectCode(() => { validateViewManifest(base, { ...expected, anchor: 'missing' }) }, READER_ERROR.manifestInvalid)
|
||||
rejectCode(() => { validateViewManifest(parseViewManifest(manifest({ executed: true })), expected) }, READER_ERROR.manifestInvalid)
|
||||
rejectCode(() => { validateViewManifest(parseViewManifest(manifest({ mode: 'site' })), expected) }, READER_ERROR.manifestInvalid)
|
||||
})
|
||||
|
||||
void test('missing anchors and script assets in package manifests are rejected', () => {
|
||||
const noAnchor = parseViewManifest(manifest({
|
||||
entry: { href: 'index.html#detail', file: 'index.html', heading_ids: ['intro'], relative_path: 'doc.md', anchor: 'detail', sha256: hex('c') },
|
||||
}))
|
||||
rejectCode(() => { validateViewManifest(noAnchor, expected) }, READER_ERROR.anchorMissing)
|
||||
assert.throws(() => { parseViewManifest(manifest({ files: [{ path: 'assets/app.js', sha256: hex('c') }] })) }, ReaderError)
|
||||
assert.throws(() => { assertPackagePath('../escape', 'package file') }, ReaderError)
|
||||
assert.throws(() => { assertPackagePath('assets/app.js', 'package file') }, ReaderError)
|
||||
})
|
||||
|
||||
void test('package file digests are verified against the manifest', async () => {
|
||||
const root = await mkdtemp(join(tmpdir(), 'mqdh-reader-'))
|
||||
await writeFile(join(root, 'index.html'), '<p>reader</p>')
|
||||
const parsed = parseViewManifest(manifest({
|
||||
entry: {
|
||||
href: 'index.html', file: 'index.html', heading_ids: [], relative_path: 'doc.md', anchor: null, sha256: hex('0'),
|
||||
},
|
||||
pages: [{ source_sha256: hex('d'), source_status: 'static-ok', relative_path: 'doc.md', sha256: hex('0') }],
|
||||
files: [{ path: 'index.html', sha256: hex('0') }],
|
||||
}))
|
||||
await assert.rejects(verifyPackageFiles(root, parsed), (error: unknown) => (
|
||||
error instanceof ReaderError && error.code === READER_ERROR.packageInvalid
|
||||
))
|
||||
})
|
||||
|
||||
void test('reader content types stay static-only', () => {
|
||||
assert.equal(contentTypeOf('index.html'), 'text/html; charset=utf-8')
|
||||
assert.equal(contentTypeOf('assets/reader.css'), 'text/css; charset=utf-8')
|
||||
assert.equal(contentTypeOf('assets/noto-math.woff2'), 'font/woff2')
|
||||
assert.equal(contentTypeOf('media/x.png'), 'image/png')
|
||||
assert.equal(contentTypeOf('media/x.js'), 'application/octet-stream')
|
||||
})
|
||||
@@ -9,7 +9,7 @@ import { test } from 'node:test'
|
||||
|
||||
import {
|
||||
assetNameFor, canonicalJson, channelForVersion, checkCompatibility, compareVersions,
|
||||
isNewerVersion, parseAppReleaseManifest, publicKeyId, readAppReleaseManifest,
|
||||
isNewerVersion, parseAppReleaseManifest, portableZipNameFor, publicKeyId, readAppReleaseManifest,
|
||||
satisfiesRange, signAppReleaseManifest, signaturePayload, tagForVersion,
|
||||
verifyAppReleaseSignature, versionFromTag, ReleaseManifestError,
|
||||
} from '../src/release/manifest.ts'
|
||||
@@ -63,6 +63,21 @@ test('manifest parsing binds version, target and asset name', () => {
|
||||
assert.throws(() => readAppReleaseManifest('{'), /not valid JSON/)
|
||||
})
|
||||
|
||||
test('a Windows artifact manifest parses with no glibc floor', () => {
|
||||
const target = 'x86_64-pc-windows-msvc'
|
||||
const windows = fixture({
|
||||
platform: { target, os: 'windows', arch: 'x64', min_glibc: null, minimum_os: null },
|
||||
asset: { name: assetNameFor(VERSION, target), size: 4321, sha256: 'd'.repeat(64), target },
|
||||
})
|
||||
const parsed = parseAppReleaseManifest(JSON.parse(JSON.stringify(windows)))
|
||||
assert.equal(parsed.platform.min_glibc, null)
|
||||
assert.equal(parsed.asset.name, `marqdo-harness-${VERSION}-${target}.tar.gz`)
|
||||
const verdict = checkCompatibility(parsed, {
|
||||
target, node: 'v24.22.3', glibc: null, cliVersion: '3.0.0-rc.7',
|
||||
})
|
||||
assert.equal(verdict.compatible, true, verdict.reasons.join('; '))
|
||||
})
|
||||
|
||||
test('detached Ed25519 signature covers the canonical payload without the signature', () => {
|
||||
const payload = fixture()
|
||||
const signed = signAppReleaseManifest(payload, privateKey, publicKey)
|
||||
@@ -113,3 +128,7 @@ test('compatibility reports every mismatching dimension', () => {
|
||||
assert.match(verdict.reasons.join('\n'), /Node/)
|
||||
assert.match(verdict.reasons.join('\n'), /CLI/)
|
||||
})
|
||||
|
||||
test('the portable Windows asset uses the product-facing ZIP name', () => {
|
||||
assert.equal(portableZipNameFor('0.1.0-beta.1'), 'MQDH-0.1.0-beta.1-win-x64.zip')
|
||||
})
|
||||
@@ -81,6 +81,7 @@ async function startReleaseServer(releases: readonly {
|
||||
manifest: string
|
||||
signature: string
|
||||
size: number
|
||||
body?: string
|
||||
}[]): Promise<{ server: Server; authority: string; stop: () => void }> {
|
||||
const server = createServer(async (req: IncomingMessage, res: ServerResponse) => {
|
||||
const url = req.url ?? ''
|
||||
@@ -92,6 +93,7 @@ async function startReleaseServer(releases: readonly {
|
||||
prerelease: false,
|
||||
draft: false,
|
||||
target_commitish: null,
|
||||
body: release.body ?? null,
|
||||
assets: [
|
||||
{ name: 'mqdh-release.json', size: Buffer.byteLength(release.manifest), browser_download_url: `${authority}/assets/${release.tag}/mqdh-release.json` },
|
||||
{ name: 'mqdh-release.json.sig', size: Buffer.byteLength(release.signature), browser_download_url: `${authority}/assets/${release.tag}/mqdh-release.json.sig` },
|
||||
@@ -144,21 +146,24 @@ async function makeUpdater(authority: string): Promise<{
|
||||
}
|
||||
|
||||
test('checks, verifies, activates and rolls back a signed application release', async () => {
|
||||
const productVersion = JSON.parse(await readFile(new URL('../package.json', import.meta.url), 'utf8')).version as string
|
||||
const target = (await detectPlatform()).target
|
||||
const root = await mkdtemp(join(tmpdir(), 'mqdh-release-build-'))
|
||||
const v2 = await buildRelease({ root, version: '0.2.0', target })
|
||||
const v3 = await buildRelease({ root, version: '0.3.0', target })
|
||||
const server = await startReleaseServer([
|
||||
{ tag: 'mqdh-v0.2.0', archive: v2.archive, manifest: v2.manifest, signature: v2.signature, size: v2.size },
|
||||
{ tag: 'mqdh-v0.3.0', archive: v3.archive, manifest: v3.manifest, signature: v3.signature, size: v3.size },
|
||||
{ tag: 'mqdh-v0.3.0', archive: v3.archive, manifest: v3.manifest, signature: v3.signature, size: v3.size, body: '修复启动问题并更新默认 Bundle。' },
|
||||
])
|
||||
const { updater, installRoot } = await makeUpdater(server.authority)
|
||||
try {
|
||||
const checked = await updater.check({ force: true })
|
||||
assert.equal(checked.latest?.version, '0.3.0')
|
||||
assert.equal(checked.latest?.signature, 'verified')
|
||||
assert.equal(checked.latest?.notes, '修复启动问题并更新默认 Bundle。')
|
||||
assert.match(checked.latest?.release_url ?? '', /releases\/tag\/mqdh-v0\.3\.0$/)
|
||||
assert.equal(checked.update_available, true)
|
||||
assert.equal(checked.current?.version, '0.1.0')
|
||||
assert.equal(checked.current?.version, productVersion)
|
||||
|
||||
const installed = await updater.install({ confirm: true, version: '0.2.0' })
|
||||
assert.equal(installed.current?.version, '0.2.0')
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
/** Native Windows runtime identity and offline-pack parsing. */
|
||||
|
||||
import assert from 'node:assert/strict'
|
||||
import { test } from 'node:test'
|
||||
|
||||
import { parseArchiveIdentity } from '../src/bootstrap/manager.ts'
|
||||
import { runtimeBinaryName } from '../src/ecosystem/manager.ts'
|
||||
|
||||
test('offline archive identity accepts native Windows targets', () => {
|
||||
assert.deepEqual(parseArchiveIdentity('marqdo-3.0.0-rc.7-x86_64-pc-windows-msvc.tar.gz'), {
|
||||
kind: 'cli',
|
||||
version: '3.0.0-rc.7',
|
||||
target: 'x86_64-pc-windows-msvc',
|
||||
})
|
||||
assert.deepEqual(parseArchiveIdentity('marqdo-3.0.0-rc.7-x86_64-unknown-linux-gnu.tar.gz'), {
|
||||
kind: 'cli',
|
||||
version: '3.0.0-rc.7',
|
||||
target: 'x86_64-unknown-linux-gnu',
|
||||
})
|
||||
assert.deepEqual(parseArchiveIdentity('marqdo-knowledge-0.2.0-aarch64-apple-darwin.tar.gz'), null)
|
||||
assert.equal(parseArchiveIdentity('marqdo-3.0.0-rc.7-x86_64-pc-windows-msvc.zip'), null)
|
||||
})
|
||||
|
||||
test('runtime binary names carry the Windows executable suffix', () => {
|
||||
assert.equal(runtimeBinaryName('marqdo', 'win32'), 'marqdo.exe')
|
||||
assert.equal(runtimeBinaryName('marqdo-provider-worker', 'win32'), 'marqdo-provider-worker.exe')
|
||||
assert.equal(runtimeBinaryName('marqdo', 'linux'), 'marqdo')
|
||||
assert.equal(runtimeBinaryName('marqdo-provider-worker', 'darwin'), 'marqdo-provider-worker')
|
||||
})
|
||||
@@ -0,0 +1,52 @@
|
||||
{
|
||||
"name": "@marqdo/mqdh-ui",
|
||||
"version": "0.1.0",
|
||||
"description": "Marqdo branding and ecosystem navigation for the shared Harness shell",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"license": "MIT",
|
||||
"main": "lib/index.js",
|
||||
"exports": {
|
||||
".": {
|
||||
"types": "./lib/types/index.d.ts",
|
||||
"default": "./lib/index.js"
|
||||
},
|
||||
"./client": {
|
||||
"types": "./lib/types/client/index.d.ts",
|
||||
"default": "./lib/client.js"
|
||||
},
|
||||
"./package.json": "./package.json"
|
||||
},
|
||||
"dsh": {
|
||||
"client": {
|
||||
"platform": "web",
|
||||
"inject": [
|
||||
"@deepseek-ai/dsh-api-remote-access",
|
||||
"@deepseek-ai/dsh-api-remotes",
|
||||
"@deepseek-ai/dsh-client-locale",
|
||||
"@deepseek-ai/dsh-client-ui-conversation",
|
||||
"@deepseek-ai/dsh-client-ui-layout",
|
||||
"@deepseek-ai/dsh-client-ui-renderer",
|
||||
"@deepseek-ai/dsh-client-ui-sidebar",
|
||||
"@deepseek-ai/dsh-client-ui-theme"
|
||||
]
|
||||
}
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@deepseek-ai/cordis": "workspace:~"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@deepseek-ai/cordis": "workspace:~",
|
||||
"@deepseek-ai/dsh-api-remote-access": "workspace:*",
|
||||
"@deepseek-ai/dsh-api-remotes": "workspace:*",
|
||||
"@deepseek-ai/dsh-client-locale": "workspace:*",
|
||||
"@deepseek-ai/dsh-client-ui-conversation": "workspace:*",
|
||||
"@deepseek-ai/dsh-client-ui-layout": "workspace:*",
|
||||
"@deepseek-ai/dsh-client-ui-primitives": "workspace:*",
|
||||
"@deepseek-ai/dsh-client-ui-renderer": "workspace:*",
|
||||
"@deepseek-ai/dsh-client-ui-sidebar": "workspace:*",
|
||||
"@deepseek-ai/dsh-client-ui-slots": "workspace:*",
|
||||
"@deepseek-ai/dsh-client-ui-theme": "workspace:*",
|
||||
"react": "^18.2.0"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
:global([data-panel-entry='marqdo']) {
|
||||
--dsw-focus-ring-color: light-dark(#536742, #a7b996);
|
||||
}
|
||||
|
||||
:global([data-panel-entry='marqdo']):has(> :global(button[aria-current='page'])) {
|
||||
--dsw-alias-interactive-bg-hover: light-dark(#dce4d6, #414b3a);
|
||||
}
|
||||
|
||||
.workbench {
|
||||
flex: 1;
|
||||
min-block-size: 0;
|
||||
min-inline-size: 0;
|
||||
inline-size: 100%;
|
||||
border: 0;
|
||||
background: var(--dsw-alias-bg-base);
|
||||
}
|
||||
|
||||
.inventory {
|
||||
flex: 1;
|
||||
min-block-size: 0;
|
||||
overflow: auto;
|
||||
padding: 24px;
|
||||
}
|
||||
|
||||
:global([data-platform='darwin']) .workbench {
|
||||
margin-block-start: var(--dsh-frame-top-clearance);
|
||||
}
|
||||
|
||||
:global([data-platform='darwin']) .inventory {
|
||||
padding-block-start: calc(var(--dsh-frame-top-clearance) + 24px);
|
||||
}
|
||||
|
||||
.inventory h1 {
|
||||
margin-block: 0 16px;
|
||||
font-size: 20px;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.inventory ul {
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
list-style: none;
|
||||
}
|
||||
|
||||
.inventory li {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: baseline;
|
||||
justify-content: space-between;
|
||||
column-gap: 16px;
|
||||
padding-block: 8px;
|
||||
border-block-end: 1px solid var(--dsw-alias-border-l3);
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
|
||||
.inventory li span {
|
||||
color: var(--dsw-alias-label-secondary);
|
||||
}
|
||||
@@ -0,0 +1,106 @@
|
||||
import { useCallback, useEffect, useLayoutEffect, useRef, useState } from 'react'
|
||||
import type { PluginInventorySnapshot } from '@deepseek-ai/dsh-api-remotes/client'
|
||||
import { Button, IconPluginPinwheelOutlineRegular } from '@deepseek-ai/dsh-client-ui-primitives'
|
||||
import type { HostObservable, InjectFace, PropsLocale, PropsRuntime } from '@deepseek-ai/dsh-client-ui-slots'
|
||||
import type { HeroBrandMarkOwnerProps } from '@deepseek-ai/dsh-client-ui-conversation/client'
|
||||
import type { ThemeSnapshot } from '@deepseek-ai/dsh-client-ui-theme/client'
|
||||
import css from './Panels.module.css'
|
||||
|
||||
/** Same-origin artwork used on the workbench and the shell. */
|
||||
export const BRAND_ICON = '/mqdh/brand.svg'
|
||||
|
||||
/**
|
||||
* Brand artwork in the dimensions supplied by each slot.
|
||||
* @param props - Mark dimensions and optional host CSS.
|
||||
* @returns Decorative Marqdo mark.
|
||||
*/
|
||||
export function MarqdoMark({ size, className }: HeroBrandMarkOwnerProps) {
|
||||
return <img className={className} src={BRAND_ICON} width={size} height={size} alt="" />
|
||||
}
|
||||
|
||||
/** Wordmark in the expanded sidebar. */
|
||||
export function MarqdoName({ t }: PropsLocale<'mqdh'>) {
|
||||
return <span>{t('product')}</span>
|
||||
}
|
||||
|
||||
/** Native sidebar glyph for the read-only Plugins panel. */
|
||||
export function PluginsIcon({ size }: PropsRuntime<'sidebar.panellist'>) {
|
||||
return <IconPluginPinwheelOutlineRegular size={size} />
|
||||
}
|
||||
|
||||
/** Theme projection supplied by the shell to the same-origin workbench. */
|
||||
export interface WorkbenchTheme {
|
||||
readonly hooks: {
|
||||
readonly workbenchScheme: HostObservable<ThemeSnapshot['active']['colorScheme']>
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Open the workbench in the current application theme.
|
||||
* @param props - Localized title and the shell's resolved color scheme.
|
||||
* @returns The embedded workbench.
|
||||
*/
|
||||
export function Workbench({ t, useWorkbenchScheme }: PropsLocale<'mqdh'> & InjectFace<WorkbenchTheme>) {
|
||||
const scheme = useWorkbenchScheme(value => value)
|
||||
const frame = useRef<HTMLIFrameElement>(null)
|
||||
const syncScheme = useCallback(() => {
|
||||
const embedded = frame.current?.contentDocument
|
||||
if (embedded?.body?.hasAttribute('data-embedded')) {
|
||||
embedded.documentElement.setAttribute('data-mqdh-scheme', scheme)
|
||||
}
|
||||
}, [scheme])
|
||||
useLayoutEffect(syncScheme, [syncScheme])
|
||||
return <iframe
|
||||
ref={frame}
|
||||
className={css.workbench}
|
||||
title={t('marqdo')}
|
||||
src="/mqdh?embedded=1#ecosystem"
|
||||
onLoad={syncScheme}
|
||||
/>
|
||||
}
|
||||
|
||||
type Inventory = PluginInventorySnapshot['entries']
|
||||
|
||||
/** Read-only inventory callback injected by the browser plugin. */
|
||||
export interface InventoryProps extends PropsLocale<'mqdh'> {
|
||||
readonly loadInventory: () => Promise<Inventory>
|
||||
}
|
||||
|
||||
type InventoryState =
|
||||
| { readonly kind: 'loading' }
|
||||
| { readonly kind: 'failed' }
|
||||
| { readonly kind: 'ready'; readonly entries: Inventory }
|
||||
|
||||
/** The Host's configured plugin list without profile or package mutations. */
|
||||
export function PluginInventory({ loadInventory, t }: InventoryProps) {
|
||||
const [attempt, setAttempt] = useState(0)
|
||||
const [state, setState] = useState<InventoryState>({ kind: 'loading' })
|
||||
useEffect(() => {
|
||||
let current = true
|
||||
setState({ kind: 'loading' })
|
||||
void loadInventory().then((entries) => {
|
||||
if (current) setState({ kind: 'ready', entries })
|
||||
}, () => {
|
||||
if (current) setState({ kind: 'failed' })
|
||||
})
|
||||
return () => { current = false }
|
||||
}, [attempt, loadInventory])
|
||||
return (
|
||||
<section className={css.inventory}>
|
||||
<h1>{t('plugins')}</h1>
|
||||
{state.kind === 'loading' && <p role="status">{t('loading')}</p>}
|
||||
{state.kind === 'failed' && <>
|
||||
<p role="alert">{t('failed')}</p>
|
||||
<Button onClick={() => { setAttempt(attempt + 1) }}>{t('retry')}</Button>
|
||||
</>}
|
||||
{state.kind === 'ready' && (state.entries.length > 0
|
||||
? <ul>{state.entries.map(entry => (
|
||||
<li key={entry.entryId}>
|
||||
{entry.moduleName}
|
||||
<span>{t(!entry.enabled ? 'disabled' : entry.fiberPhase === 'failed' ? 'failedPlugin' : 'enabled')}</span>
|
||||
</li>
|
||||
))}</ul>
|
||||
: <p>{t('empty')}</p>)}
|
||||
</section>
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
declare module '*.module.css' {
|
||||
const classes: Readonly<Record<string, string>>
|
||||
export default classes
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
/** Product-owned contributions to the inherited DSH shell. */
|
||||
import type { Context } from '@deepseek-ai/cordis'
|
||||
import type {} from '@deepseek-ai/dsh-api-remote-access/client'
|
||||
import type { PluginInventorySnapshot } from '@deepseek-ai/dsh-api-remotes/client'
|
||||
import type {} from '@deepseek-ai/dsh-client-locale/client'
|
||||
import type {} from '@deepseek-ai/dsh-client-ui-conversation/client'
|
||||
import type { MainPanelId } from '@deepseek-ai/dsh-client-ui-layout/client'
|
||||
import type {} from '@deepseek-ai/dsh-client-ui-renderer/client'
|
||||
import type {} from '@deepseek-ai/dsh-client-ui-sidebar/client'
|
||||
import type {} from '@deepseek-ai/dsh-client-ui-theme/client'
|
||||
import { en, zh } from './locales.ts'
|
||||
import { BRAND_ICON, MarqdoMark, MarqdoName, PluginInventory, PluginsIcon, Workbench, type WorkbenchTheme } from './Panels.tsx'
|
||||
|
||||
declare module '@deepseek-ai/dsh-client-ui-slots' {
|
||||
interface LocaleNamespaceMap {
|
||||
/** MQDH brand and navigation copy. */
|
||||
mqdh: keyof typeof en
|
||||
}
|
||||
}
|
||||
|
||||
const NS = 'mqdh'
|
||||
const PLUGINS = 'plugins' as MainPanelId
|
||||
const MARQDO = 'marqdo' as MainPanelId
|
||||
|
||||
/** Services used to register navigation, artwork and the read-only inventory. */
|
||||
export const inject = ['slots', 'locale', 'remote', 'remote.pluginInventory', 'remoteAccess', 'theme']
|
||||
|
||||
/**
|
||||
* Add MQDH branding and the Marqdo entry to the existing shell.
|
||||
* @param ctx - Browser context for the product profile.
|
||||
*/
|
||||
export function apply(ctx: Context): void {
|
||||
ctx.effect(() => ctx.locale.register(NS, { en, zh }), 'mqdh: dictionaries')
|
||||
const t = ctx.locale.bind(NS)
|
||||
ctx.effect(() => {
|
||||
const icons = Array.from(document.querySelectorAll<HTMLLinkElement>('link[rel="icon"]'))
|
||||
const previous = icons.map(icon => icon.getAttribute('href'))
|
||||
icons.forEach((icon) => { icon.setAttribute('href', BRAND_ICON) })
|
||||
return () => {
|
||||
icons.forEach((icon, index) => {
|
||||
const href = previous[index]
|
||||
if (href === null || href === undefined) icon.removeAttribute('href')
|
||||
else icon.setAttribute('href', href)
|
||||
})
|
||||
}
|
||||
}, 'mqdh: favicon')
|
||||
ctx.slots.inject('sidebar.brand.mark', () =>
|
||||
ctx.slots.register({ name: 'sidebar.brand.mark' }, MarqdoMark))
|
||||
ctx.slots.inject('sidebar.brand.name', () =>
|
||||
ctx.slots.register({ name: 'sidebar.brand.name', locale: NS }, MarqdoName))
|
||||
ctx.slots.inject('conversation.hero.brand.mark', () =>
|
||||
ctx.slots.register({ name: 'conversation.hero.brand.mark' }, MarqdoMark))
|
||||
|
||||
const workbenchScheme: WorkbenchTheme['hooks']['workbenchScheme'] = {
|
||||
getSnapshot: () => ctx.theme.getTheme().active.colorScheme,
|
||||
subscribe: listener => ctx.on('theme/change', listener),
|
||||
}
|
||||
ctx.slots.inject('main', function* () {
|
||||
yield ctx.slots.register({
|
||||
name: 'main', key: MARQDO, locale: NS, inject: () => ({ hooks: { workbenchScheme } }),
|
||||
}, Workbench)
|
||||
yield ctx.slots.inject('sidebar.panellist', () =>
|
||||
ctx.slots.register({
|
||||
name: 'sidebar.panellist', id: MARQDO, order: 1, label: () => t('marqdo'),
|
||||
}, MarqdoMark))
|
||||
})
|
||||
|
||||
const loadInventory = async (): Promise<PluginInventorySnapshot['entries']> => {
|
||||
const result = await ctx.remote.pluginInventory.list()
|
||||
if (!result.ok) throw new Error('Plugin inventory is unavailable')
|
||||
return result.value.entries
|
||||
}
|
||||
|
||||
ctx.remoteAccess.whenAccess('pluginInventory/list', function* () {
|
||||
yield ctx.slots.inject('main', function* () {
|
||||
yield ctx.slots.register({
|
||||
name: 'main', key: PLUGINS, locale: NS, inject: () => ({ loadInventory }),
|
||||
}, PluginInventory)
|
||||
yield ctx.slots.inject('sidebar.panellist', () =>
|
||||
ctx.slots.register({
|
||||
name: 'sidebar.panellist', id: PLUGINS, order: 0, label: () => t('plugins'),
|
||||
}, PluginsIcon))
|
||||
})
|
||||
})
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
/** Product navigation and read-only plugin inventory in English. */
|
||||
export const en = {
|
||||
product: 'Marqdo Harness',
|
||||
marqdo: 'Marqdo',
|
||||
plugins: 'Plugins',
|
||||
loading: 'Loading plugins…',
|
||||
failed: 'Plugins could not be loaded.',
|
||||
retry: 'Retry',
|
||||
empty: 'No plugins are configured.',
|
||||
enabled: 'Enabled',
|
||||
disabled: 'Disabled',
|
||||
failedPlugin: 'Failed to start',
|
||||
}
|
||||
|
||||
/** Product navigation and read-only plugin inventory in Simplified Chinese. */
|
||||
export const zh: Record<keyof typeof en, string> = {
|
||||
product: 'Marqdo Harness',
|
||||
marqdo: 'Marqdo',
|
||||
plugins: '插件',
|
||||
loading: '正在读取插件…',
|
||||
failed: '无法读取插件',
|
||||
retry: '重试',
|
||||
empty: '当前没有配置插件',
|
||||
enabled: '已启用',
|
||||
disabled: '已停用',
|
||||
failedPlugin: '启动失败',
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
/** Host loader entry for the MQDH browser contribution. */
|
||||
export function apply(): void {}
|
||||
@@ -0,0 +1,21 @@
|
||||
{
|
||||
"extends": "../../../tsconfig.base.client.json",
|
||||
"compilerOptions": {
|
||||
"rootDir": "src",
|
||||
"outDir": "lib/types"
|
||||
},
|
||||
"include": ["src"],
|
||||
"references": [
|
||||
{ "path": "../../../vendor/cordis" },
|
||||
{ "path": "../../api/remote-access/tsconfig.client.json" },
|
||||
{ "path": "../../api/remotes/tsconfig.client.json" },
|
||||
{ "path": "../../client/locale/tsconfig.client.json" },
|
||||
{ "path": "../../client/ui-conversation/tsconfig.client.json" },
|
||||
{ "path": "../../client/ui-layout" },
|
||||
{ "path": "../../client/ui-primitives" },
|
||||
{ "path": "../../client/ui-renderer" },
|
||||
{ "path": "../../client/ui-sidebar" },
|
||||
{ "path": "../../client/ui-slots" },
|
||||
{ "path": "../../client/ui-theme/tsconfig.client.json" }
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
import { clientBundle } from '../../client/tsdown.client.ts'
|
||||
|
||||
export default clientBundle(import.meta.dirname, ['lib/types/index.js'])
|
||||
@@ -15575,9 +15575,51 @@ importers:
|
||||
'@marqdo/mqdh-harness':
|
||||
specifier: workspace:*
|
||||
version: link:../harness
|
||||
'@marqdo/mqdh-ui':
|
||||
specifier: workspace:*
|
||||
version: link:../ui
|
||||
|
||||
packages/marqdo/harness: {}
|
||||
|
||||
packages/marqdo/ui:
|
||||
devDependencies:
|
||||
'@deepseek-ai/cordis':
|
||||
specifier: workspace:~
|
||||
version: link:../../../vendor/cordis
|
||||
'@deepseek-ai/dsh-api-remote-access':
|
||||
specifier: workspace:*
|
||||
version: link:../../api/remote-access
|
||||
'@deepseek-ai/dsh-api-remotes':
|
||||
specifier: workspace:*
|
||||
version: link:../../api/remotes
|
||||
'@deepseek-ai/dsh-client-locale':
|
||||
specifier: workspace:*
|
||||
version: link:../../client/locale
|
||||
'@deepseek-ai/dsh-client-ui-conversation':
|
||||
specifier: workspace:*
|
||||
version: link:../../client/ui-conversation
|
||||
'@deepseek-ai/dsh-client-ui-layout':
|
||||
specifier: workspace:*
|
||||
version: link:../../client/ui-layout
|
||||
'@deepseek-ai/dsh-client-ui-primitives':
|
||||
specifier: workspace:*
|
||||
version: link:../../client/ui-primitives
|
||||
'@deepseek-ai/dsh-client-ui-renderer':
|
||||
specifier: workspace:*
|
||||
version: link:../../client/ui-renderer
|
||||
'@deepseek-ai/dsh-client-ui-sidebar':
|
||||
specifier: workspace:*
|
||||
version: link:../../client/ui-sidebar
|
||||
'@deepseek-ai/dsh-client-ui-slots':
|
||||
specifier: workspace:*
|
||||
version: link:../../client/ui-slots
|
||||
'@deepseek-ai/dsh-client-ui-theme':
|
||||
specifier: workspace:*
|
||||
version: link:../../client/ui-theme
|
||||
react:
|
||||
specifier: ^18.2.0
|
||||
version: 18.3.1
|
||||
|
||||
packages/mcp/mcp-account:
|
||||
dependencies:
|
||||
'@deepseek-ai/dsh-brand':
|
||||
|
||||
@@ -25,7 +25,7 @@ if [ ! -f "$root/apps/cli/lib/bin.js" ]; then
|
||||
exit 1
|
||||
fi
|
||||
echo "mqdh ci: building repository artifacts"
|
||||
pnpm run build
|
||||
DSH_CLIENT_TITLE="Marqdo Harness" pnpm run build
|
||||
fi
|
||||
|
||||
cli="${MARQDO_BIN:-}"
|
||||
@@ -34,10 +34,10 @@ if [ -z "$cli_sha" ] && [ -n "${MARQDO_BIN:-}" ]; then
|
||||
cli_sha="$(cat "$(dirname "$MARQDO_BIN")/SOURCE_SHA" 2>/dev/null || true)"
|
||||
fi
|
||||
if [ -z "$cli" ]; then
|
||||
version="3.0.0-rc.6"
|
||||
version="3.0.0-rc.7"
|
||||
archive="$work/marqdo-$version.tar.gz"
|
||||
url="https://git.cflmy.cn/cflmy/marqdo-cli/releases/download/v$version/marqdo-$version-x86_64-unknown-linux-gnu.tar.gz"
|
||||
expected="8dc0b006302e03c23451b8ea9f8a0fcdae8bf67c80c546bee2434bf69755bfe3"
|
||||
expected="10714820c9620b1b7b0da59e8d3930fc71b769a722aa80ede6fa889659de4613"
|
||||
echo "mqdh ci: downloading pinned CLI $version"
|
||||
curl -fsSL --retry 3 --max-time 300 -o "$archive" "$url"
|
||||
actual="$(sha256sum "$archive" | awk '{print $1}')"
|
||||
|
||||
@@ -0,0 +1,154 @@
|
||||
<#
|
||||
.SYNOPSIS
|
||||
User-level installer for a packaged Marqdo Harness (MQDH) tree on Windows.
|
||||
|
||||
.DESCRIPTION
|
||||
Installs one extracted release tree into a per-user prefix, writes the
|
||||
`current.json` version pointer and a launcher that always runs the active
|
||||
version. The application install tree is separate from MQDH_HOME (sessions,
|
||||
private knowledge, diagnostics and the Marqdo runtime); uninstall preserves
|
||||
MQDH_HOME unless the user removes it explicitly.
|
||||
|
||||
This is an experimental Windows distribution path: the archive is unsigned
|
||||
and the application's in-app updater only supports the Linux archive. Updates
|
||||
on Windows are manual (download and run the new installer).
|
||||
|
||||
.PARAMETER Prefix
|
||||
Install prefix. Defaults to `$env:LOCALAPPDATA\MQDH`.
|
||||
|
||||
.PARAMETER NoPath
|
||||
Do not add `<prefix>\bin` to the user PATH.
|
||||
|
||||
.PARAMETER NoShortcut
|
||||
Do not create a Start Menu shortcut.
|
||||
|
||||
.PARAMETER Uninstall
|
||||
Remove the install tree and launcher; user data under MQDH_HOME is preserved.
|
||||
|
||||
.EXAMPLE
|
||||
powershell -ExecutionPolicy Bypass -File .\install.ps1
|
||||
#>
|
||||
[CmdletBinding()]
|
||||
param(
|
||||
[string]$Prefix = (Join-Path $env:LOCALAPPDATA 'MQDH'),
|
||||
[switch]$NoPath,
|
||||
[switch]$NoShortcut,
|
||||
[switch]$Uninstall
|
||||
)
|
||||
|
||||
$ErrorActionPreference = 'Stop'
|
||||
$source = $PSScriptRoot
|
||||
$prefixFull = [System.IO.Path]::GetFullPath($Prefix)
|
||||
$launcher = Join-Path $prefixFull 'bin\mqdh.cmd'
|
||||
$shortcut = Join-Path $env:APPDATA 'Microsoft\Windows\Start Menu\Programs\MQDH.lnk'
|
||||
$homeHint = if ($env:MQDH_HOME) { $env:MQDH_HOME } else { Join-Path $env:USERPROFILE '.local\share\marqdo-harness' }
|
||||
|
||||
function Remove-UserPathEntry([string]$entry) {
|
||||
$current = [Environment]::GetEnvironmentVariable('Path', 'User')
|
||||
if ([string]::IsNullOrWhiteSpace($current)) { return }
|
||||
$parts = $current -split ';' | Where-Object { $_ -ne '' -and $_ -ne $entry }
|
||||
[Environment]::SetEnvironmentVariable('Path', ($parts -join ';'), 'User')
|
||||
}
|
||||
|
||||
if ($Uninstall) {
|
||||
Remove-Item -LiteralPath $launcher -Force -ErrorAction SilentlyContinue
|
||||
Remove-Item -LiteralPath $shortcut -Force -ErrorAction SilentlyContinue
|
||||
if (Test-Path -LiteralPath $prefixFull) {
|
||||
Remove-Item -LiteralPath $prefixFull -Recurse -Force
|
||||
}
|
||||
if (-not $NoPath) { Remove-UserPathEntry (Join-Path $prefixFull 'bin') }
|
||||
Write-Host "removed $prefixFull; user data under $homeHint is preserved"
|
||||
exit 0
|
||||
}
|
||||
|
||||
foreach ($required in @('scripts\mqdh.mjs', 'SOURCE_SHA', 'packages\marqdo\harness\package.json', 'runtime\node.exe')) {
|
||||
if (-not (Test-Path -LiteralPath (Join-Path $source $required))) {
|
||||
throw "install.ps1: not a Marqdo Harness Windows tree (missing $required): $source"
|
||||
}
|
||||
}
|
||||
$version = (Get-Content -LiteralPath (Join-Path $source 'packages\marqdo\harness\package.json') -Raw | ConvertFrom-Json).version
|
||||
if ([string]::IsNullOrWhiteSpace($version)) { throw 'install.ps1: cannot read the product version' }
|
||||
$sha = (Get-Content -LiteralPath (Join-Path $source 'SOURCE_SHA') -Raw).Trim()
|
||||
if ($sha -notmatch '^[0-9a-f]{12,40}$') { throw 'install.ps1: invalid SOURCE_SHA' }
|
||||
$installId = "$version-$($sha.Substring(0,12))"
|
||||
|
||||
New-Item -ItemType Directory -Force -Path (Join-Path $prefixFull 'versions') | Out-Null
|
||||
$target = Join-Path $prefixFull "versions\$installId"
|
||||
if (-not (Test-Path -LiteralPath $target)) {
|
||||
# Move preserves the staged tree's file identities and avoids re-copying the
|
||||
# multi-gigabyte production dependency tree; fall back to a copy across volumes.
|
||||
try {
|
||||
Move-Item -LiteralPath $source -Destination $target
|
||||
} catch {
|
||||
New-Item -ItemType Directory -Force -Path $target | Out-Null
|
||||
Copy-Item -LiteralPath (Join-Path $source '*') -Destination $target -Recurse -Force
|
||||
}
|
||||
} elseif ((Get-Item -LiteralPath $target).FullName -ne (Get-Item -LiteralPath $source).FullName) {
|
||||
Write-Host "install.ps1: version tree already installed: $target"
|
||||
}
|
||||
|
||||
$previous = $null
|
||||
$previousVersion = $null
|
||||
$currentPath = Join-Path $prefixFull 'current.json'
|
||||
if (Test-Path -LiteralPath $currentPath) {
|
||||
$current = Get-Content -LiteralPath $currentPath -Raw | ConvertFrom-Json
|
||||
$previous = $current.install_id
|
||||
$previousVersion = $current.version
|
||||
}
|
||||
$pointer = [ordered]@{
|
||||
schema = 'marqdo.mqdh.app-current'
|
||||
schema_version = 1
|
||||
version = $version
|
||||
install_id = $installId
|
||||
source_sha = $sha
|
||||
previous = $previous
|
||||
previous_version = $previousVersion
|
||||
updated_at = (Get-Date).ToUniversalTime().ToString('yyyy-MM-ddTHH:mm:ssZ')
|
||||
}
|
||||
$pointer | ConvertTo-Json | Set-Content -LiteralPath $currentPath -Encoding UTF8
|
||||
|
||||
New-Item -ItemType Directory -Force -Path (Join-Path $prefixFull 'bin') | Out-Null
|
||||
# The launcher resolves the active version from current.json at every start, so
|
||||
# a newer install switches atomically and a failed one leaves the old pointer.
|
||||
$launcherBody = @'
|
||||
@echo off
|
||||
setlocal
|
||||
set "ROOT=%~dp0.."
|
||||
if defined MQDH_INSTALL_ROOT set "ROOT=%MQDH_INSTALL_ROOT%"
|
||||
set "ID="
|
||||
for /f "tokens=2 delims=:" %%A in ('findstr /c:"\"install_id\"" "%ROOT%\current.json"') do set "ID=%%A"
|
||||
set "ID=%ID: =%"
|
||||
set "ID=%ID:"=%"
|
||||
set "ID=%ID:,=%"
|
||||
if "%ID%"=="" echo mqdh: invalid or missing install pointer: %ROOT%\current.json 1>&2 & exit /b 1
|
||||
set "TREE=%ROOT%\versions\%ID%"
|
||||
if not exist "%TREE%\runtime\node.exe" echo mqdh: installed version tree is missing: %TREE% 1>&2 & exit /b 1
|
||||
"%TREE%\runtime\node.exe" "%TREE%\scripts\mqdh.mjs" %*
|
||||
'@
|
||||
Set-Content -LiteralPath $launcher -Value $launcherBody -Encoding ASCII
|
||||
|
||||
if (-not $NoShortcut) {
|
||||
try {
|
||||
$shell = New-Object -ComObject WScript.Shell
|
||||
$link = $shell.CreateShortcut($shortcut)
|
||||
$link.TargetPath = $launcher
|
||||
$link.WorkingDirectory = $prefixFull
|
||||
$link.Description = 'Marqdo Harness (MQDH) workbench'
|
||||
$link.Save()
|
||||
} catch {
|
||||
Write-Warning "install.ps1: could not create the Start Menu shortcut: $($_.Exception.Message)"
|
||||
}
|
||||
}
|
||||
|
||||
if (-not $NoPath) {
|
||||
$bin = Join-Path $prefixFull 'bin'
|
||||
$current = [Environment]::GetEnvironmentVariable('Path', 'User')
|
||||
if (($current -split ';') -notcontains $bin) {
|
||||
[Environment]::SetEnvironmentVariable('Path', (($current, $bin) -join ';').Trim(';'), 'User')
|
||||
Write-Host "added $bin to the user PATH (open a new shell to use it)"
|
||||
}
|
||||
}
|
||||
|
||||
Write-Host "installed Marqdo Harness $version ($installId) at $prefixFull"
|
||||
Write-Host "run: $launcher --version"
|
||||
Write-Host "user data: $homeHint"
|
||||
@@ -0,0 +1,274 @@
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading;
|
||||
using System.Windows.Forms;
|
||||
|
||||
/// <summary>
|
||||
/// MQDH desktop launcher: installs the bundled offline runtime on first start,
|
||||
/// serves the inherited DSH Web UI on loopback, and opens it in an app window.
|
||||
/// Runs without a console window; <c>--stop</c> terminates the background server.
|
||||
/// </summary>
|
||||
internal static class MqdhLauncher
|
||||
{
|
||||
private const string Title = "MQDH";
|
||||
private const int WaitForServerMs = 120000;
|
||||
private static readonly Regex WebUrl = new Regex(@"http://127\.0\.0\.1:(\d+)/\?token=([A-Za-z0-9_\-]+)", RegexOptions.Compiled);
|
||||
private static string openedUrl = null;
|
||||
|
||||
private static string Root
|
||||
{
|
||||
get { return AppDomain.CurrentDomain.BaseDirectory.TrimEnd('\\', '/'); }
|
||||
}
|
||||
|
||||
private static string HomeDir
|
||||
{
|
||||
get
|
||||
{
|
||||
string configured = Environment.GetEnvironmentVariable("MQDH_HOME");
|
||||
if (!string.IsNullOrEmpty(configured)) return configured;
|
||||
return Path.Combine(
|
||||
Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData),
|
||||
"MQDH", "data");
|
||||
}
|
||||
}
|
||||
|
||||
private static string PidFile { get { return Path.Combine(HomeDir, "launcher.pid"); } }
|
||||
private static string UrlFile { get { return Path.Combine(HomeDir, "workbench.url"); } }
|
||||
private static string LogFile { get { return Path.Combine(HomeDir, "launcher.log"); } }
|
||||
|
||||
[STAThread]
|
||||
private static void Main(string[] args)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (args.Length > 0 && args[0] == "--stop")
|
||||
{
|
||||
Stop();
|
||||
return;
|
||||
}
|
||||
Start();
|
||||
}
|
||||
catch (Exception error)
|
||||
{
|
||||
try
|
||||
{
|
||||
Directory.CreateDirectory(HomeDir);
|
||||
Log(DateTime.Now.ToString("o") + " launcher failed: " + error);
|
||||
MessageBox.Show(
|
||||
"MQDH failed to start." + Environment.NewLine + Environment.NewLine + error.Message +
|
||||
Environment.NewLine + Environment.NewLine + "Log: " + LogFile,
|
||||
Title, MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
catch
|
||||
{
|
||||
// No window can be shown if even the log cannot be written.
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static bool Running(out int pid)
|
||||
{
|
||||
pid = 0;
|
||||
try
|
||||
{
|
||||
if (!File.Exists(PidFile)) return false;
|
||||
string text = File.ReadAllText(PidFile).Trim();
|
||||
if (!int.TryParse(text, out pid)) return false;
|
||||
Process process = Process.GetProcessById(pid);
|
||||
return process != null && !process.HasExited;
|
||||
}
|
||||
catch
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private static void Start()
|
||||
{
|
||||
Directory.CreateDirectory(HomeDir);
|
||||
int existing;
|
||||
if (Running(out existing))
|
||||
{
|
||||
OpenWorkbench(ReadSavedUrl());
|
||||
return;
|
||||
}
|
||||
|
||||
string node = Path.Combine(Root, "runtime", "node.exe");
|
||||
string script = Path.Combine(Root, "scripts", "mqdh.mjs");
|
||||
if (!File.Exists(node)) throw new FileNotFoundException("bundled Node runtime is missing", node);
|
||||
if (!File.Exists(script)) throw new FileNotFoundException("MQDH launcher script is missing", script);
|
||||
|
||||
string runtimeDeps = Path.Combine(Root, "runtime-deps");
|
||||
if (Directory.Exists(runtimeDeps) && string.IsNullOrEmpty(Environment.GetEnvironmentVariable("MQDH_BOOTSTRAP_OFFLINE")))
|
||||
{
|
||||
Environment.SetEnvironmentVariable("MQDH_BOOTSTRAP_OFFLINE", runtimeDeps);
|
||||
}
|
||||
Environment.SetEnvironmentVariable("MQDH_HOME", HomeDir);
|
||||
if (string.IsNullOrEmpty(Environment.GetEnvironmentVariable("MQDH_WORKSPACE")))
|
||||
{
|
||||
Environment.SetEnvironmentVariable("MQDH_WORKSPACE", Path.Combine(HomeDir, "workspace"));
|
||||
}
|
||||
|
||||
Bootstrap(node, script);
|
||||
StartServer(node, script);
|
||||
}
|
||||
|
||||
private static void StartServer(string node, string script)
|
||||
{
|
||||
ProcessStartInfo start = new ProcessStartInfo();
|
||||
start.FileName = node;
|
||||
start.Arguments = "\"" + script + "\" --no-open --port 0";
|
||||
start.WorkingDirectory = Root;
|
||||
start.UseShellExecute = false;
|
||||
start.CreateNoWindow = true;
|
||||
start.WindowStyle = ProcessWindowStyle.Hidden;
|
||||
start.RedirectStandardOutput = true;
|
||||
start.RedirectStandardError = true;
|
||||
|
||||
Process child = Process.Start(start);
|
||||
if (child == null) throw new InvalidOperationException("could not start the bundled runtime");
|
||||
File.WriteAllText(PidFile, child.Id.ToString());
|
||||
|
||||
child.OutputDataReceived += delegate(object sender, DataReceivedEventArgs data)
|
||||
{
|
||||
Log(data.Data);
|
||||
TryCaptured(data.Data);
|
||||
};
|
||||
child.ErrorDataReceived += delegate(object sender, DataReceivedEventArgs data) { Log(data.Data); };
|
||||
child.BeginOutputReadLine();
|
||||
child.BeginErrorReadLine();
|
||||
|
||||
DateTime deadline = DateTime.UtcNow.AddMilliseconds(WaitForServerMs);
|
||||
while (openedUrl == null && DateTime.UtcNow < deadline)
|
||||
{
|
||||
if (child.HasExited) throw new InvalidOperationException("MQDH exited before the workbench was ready (exit code " + child.ExitCode + "). Log: " + LogFile);
|
||||
Thread.Sleep(150);
|
||||
}
|
||||
if (openedUrl == null) throw new TimeoutException("timed out waiting for the MQDH workbench. Log: " + LogFile);
|
||||
}
|
||||
|
||||
private static void TryCaptured(string line)
|
||||
{
|
||||
if (openedUrl != null || line == null) return;
|
||||
Match match = WebUrl.Match(line);
|
||||
if (!match.Success) return;
|
||||
openedUrl = "http://127.0.0.1:" + match.Groups[1].Value + "/mqdh";
|
||||
try { File.WriteAllText(UrlFile, openedUrl); } catch { }
|
||||
OpenWorkbench(openedUrl);
|
||||
}
|
||||
|
||||
private static string ReadSavedUrl()
|
||||
{
|
||||
try
|
||||
{
|
||||
if (File.Exists(UrlFile))
|
||||
{
|
||||
string url = File.ReadAllText(UrlFile).Trim();
|
||||
if (url.StartsWith("http://127.0.0.1:")) return url;
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
// A missing or stale URL falls through to a server restart.
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private static void OpenWorkbench(string url)
|
||||
{
|
||||
if (string.IsNullOrEmpty(url))
|
||||
{
|
||||
throw new InvalidOperationException("the MQDH workbench URL is unavailable; run MQDH.exe --stop and retry");
|
||||
}
|
||||
string edge = FindEdge();
|
||||
if (edge != null)
|
||||
{
|
||||
ProcessStartInfo edgeStart = new ProcessStartInfo();
|
||||
edgeStart.FileName = edge;
|
||||
edgeStart.Arguments = "--app=" + url + " --window-size=1280,860";
|
||||
edgeStart.UseShellExecute = false;
|
||||
edgeStart.CreateNoWindow = true;
|
||||
Process.Start(edgeStart);
|
||||
return;
|
||||
}
|
||||
Process.Start(new ProcessStartInfo { FileName = url, UseShellExecute = true });
|
||||
}
|
||||
|
||||
private static string FindEdge()
|
||||
{
|
||||
string[] bases = new string[]
|
||||
{
|
||||
Environment.GetFolderPath(Environment.SpecialFolder.ProgramFilesX86),
|
||||
Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles),
|
||||
};
|
||||
foreach (string baseDir in bases)
|
||||
{
|
||||
string candidate = Path.Combine(baseDir, "Microsoft", "Edge", "Application", "msedge.exe");
|
||||
if (File.Exists(candidate)) return candidate;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private static void Bootstrap(string node, string script)
|
||||
{
|
||||
ProcessStartInfo start = new ProcessStartInfo();
|
||||
start.FileName = node;
|
||||
start.Arguments = "\"" + script + "\" bootstrap --json";
|
||||
start.WorkingDirectory = Root;
|
||||
start.UseShellExecute = false;
|
||||
start.CreateNoWindow = true;
|
||||
start.WindowStyle = ProcessWindowStyle.Hidden;
|
||||
start.RedirectStandardOutput = true;
|
||||
start.RedirectStandardError = true;
|
||||
|
||||
Process child = Process.Start(start);
|
||||
if (child == null) throw new InvalidOperationException("could not start the MQDH runtime installer");
|
||||
string output = child.StandardOutput.ReadToEnd();
|
||||
string error = child.StandardError.ReadToEnd();
|
||||
if (!child.WaitForExit(300000))
|
||||
{
|
||||
try { child.Kill(); } catch { }
|
||||
throw new TimeoutException("timed out installing the MQDH runtime");
|
||||
}
|
||||
Log(DateTime.Now.ToString("o") + " bootstrap exit=" + child.ExitCode);
|
||||
if (!string.IsNullOrEmpty(output)) Log(output);
|
||||
if (!string.IsNullOrEmpty(error)) Log(error);
|
||||
if (child.ExitCode != 0)
|
||||
{
|
||||
throw new InvalidOperationException("the MQDH runtime installer failed with exit code " + child.ExitCode + ". Log: " + LogFile);
|
||||
}
|
||||
}
|
||||
|
||||
private static void Log(string line)
|
||||
{
|
||||
if (string.IsNullOrEmpty(line)) return;
|
||||
try { File.AppendAllText(LogFile, line + Environment.NewLine); } catch { }
|
||||
}
|
||||
|
||||
private static void Stop()
|
||||
{
|
||||
int pid;
|
||||
if (!Running(out pid))
|
||||
{
|
||||
MessageBox.Show("MQDH is not running.", Title, MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
return;
|
||||
}
|
||||
try
|
||||
{
|
||||
ProcessStartInfo kill = new ProcessStartInfo();
|
||||
kill.FileName = "taskkill.exe";
|
||||
kill.Arguments = "/PID " + pid + " /T /F";
|
||||
kill.UseShellExecute = false;
|
||||
kill.CreateNoWindow = true;
|
||||
Process.Start(kill);
|
||||
}
|
||||
finally
|
||||
{
|
||||
try { File.Delete(PidFile); } catch { }
|
||||
try { File.Delete(UrlFile); } catch { }
|
||||
}
|
||||
MessageBox.Show("MQDH stopped.", Title, MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
# MQDH 便携版(Windows x64)
|
||||
|
||||
1. **双击 `MQDH.exe` 即可使用,无需终端。**
|
||||
首次启动会用内置 `runtime-deps/` 安装 Marqdo 运行时,然后自动打开
|
||||
MQDH 工作台窗口(复用 DSH 前端,当前实验版仅做少量品牌化,见
|
||||
`marqdo-app-harness#25`)。
|
||||
2. 后台服务会继续运行,浏览器窗口关闭不停止服务。需要退出时,运行:
|
||||
|
||||
```text
|
||||
MQDH.exe --stop
|
||||
```
|
||||
|
||||
也可以为它创建一个带 `--stop` 参数的快捷方式。
|
||||
3. 用户数据默认保存在 `%LOCALAPPDATA%\MQDH\data`;设置 `MQDH_HOME`
|
||||
环境变量可迁移。删除安装目录不会删除用户数据。
|
||||
4. 高级/诊断用途:`mqdh.cmd <bootstrap|status|doctor|repair|report|...>`;
|
||||
普通用户不需要使用命令行。
|
||||
5. 本实验版未签名,Windows 可能显示 SmartScreen 提示;请核对发布页的
|
||||
SHA256。正式安装器、签名与桌面集成见
|
||||
<https://git.cflmy.cn/cflmy/marqdo-app-harness/issues/25>。
|
||||
|
||||
故障排查:`%LOCALAPPDATA%\MQDH\data\launcher.log`。
|
||||
@@ -0,0 +1,27 @@
|
||||
# Build the MQDH Windows launcher (WinExe, no console window).
|
||||
#
|
||||
# The launcher only starts the bundled runtime and opens the inherited DSH Web
|
||||
# UI. Its icon is derived from the shared MQDH artwork.
|
||||
|
||||
[CmdletBinding()]
|
||||
param(
|
||||
[string]$OutDir = (Join-Path $PSScriptRoot '..\.ci')
|
||||
)
|
||||
|
||||
$ErrorActionPreference = 'Stop'
|
||||
Set-StrictMode -Version Latest
|
||||
|
||||
$csc = @(
|
||||
(Join-Path $env:WINDIR 'Microsoft.NET\Framework64\v4.0.30319\csc.exe'),
|
||||
(Join-Path $env:WINDIR 'Microsoft.NET\Framework\v4.0.30319\csc.exe')
|
||||
) | Where-Object { Test-Path -LiteralPath $_ } | Select-Object -First 1
|
||||
if (-not $csc) { throw 'C# compiler (csc.exe) not found; install .NET Framework 4.x' }
|
||||
|
||||
New-Item -ItemType Directory -Force -Path $OutDir | Out-Null
|
||||
$target = Join-Path $OutDir 'MQDH.exe'
|
||||
$icon = (Resolve-Path -LiteralPath (Join-Path $PSScriptRoot '..\..\packages\marqdo\harness\assets\marqdo.ico')).Path
|
||||
& $csc /nologo /codepage:65001 /target:winexe /out:$target /win32icon:$icon `
|
||||
/r:System.Windows.Forms.dll /r:System.Drawing.dll `
|
||||
(Join-Path $PSScriptRoot 'MqdhLauncher.cs')
|
||||
if ($LASTEXITCODE -ne 0) { throw "launcher compilation failed: $LASTEXITCODE" }
|
||||
Get-Item -LiteralPath $target | Select-Object FullName, Length
|
||||
@@ -0,0 +1,10 @@
|
||||
@echo off
|
||||
rem Portable launcher for an extracted Marqdo Harness Windows tree.
|
||||
rem The installed copy uses the version pointer instead; see install.ps1.
|
||||
setlocal
|
||||
set "HERE=%~dp0"
|
||||
if exist "%HERE%runtime\node.exe" (
|
||||
"%HERE%runtime\node.exe" "%HERE%scripts\mqdh.mjs" %*
|
||||
) else (
|
||||
node "%HERE%scripts\mqdh.mjs" %*
|
||||
)
|
||||
@@ -10,8 +10,8 @@
|
||||
* @module marqdo-app-harness/launcher
|
||||
*/
|
||||
|
||||
import { access, chmod, mkdir, readFile, symlink, unlink, writeFile } from 'node:fs/promises'
|
||||
import { constants } from 'node:fs'
|
||||
import { access, chmod, mkdir, readFile, rmdir, symlink, unlink, writeFile } from 'node:fs/promises'
|
||||
import { constants, existsSync } from 'node:fs'
|
||||
import { homedir } from 'node:os'
|
||||
import { dirname, join, resolve } from 'node:path'
|
||||
import { fileURLToPath, pathToFileURL } from 'node:url'
|
||||
@@ -19,7 +19,14 @@ import { spawn } from 'node:child_process'
|
||||
|
||||
const here = dirname(fileURLToPath(import.meta.url))
|
||||
const root = resolve(here, '..')
|
||||
const productCommands = new Set(['bootstrap', 'doctor', 'repair', 'report', 'update', 'network', 'uninstall', 'help'])
|
||||
const productCommands = new Set(['bootstrap', 'status', 'doctor', 'repair', 'report', 'update', 'network', 'uninstall', 'help'])
|
||||
|
||||
// A packaged offline runtime pack makes first-run bootstrap usable without a
|
||||
// network round trip; an explicit environment value still wins.
|
||||
const bundledRuntimeDeps = join(root, 'runtime-deps')
|
||||
if (!process.env.MQDH_BOOTSTRAP_OFFLINE && existsSync(bundledRuntimeDeps)) {
|
||||
process.env.MQDH_BOOTSTRAP_OFFLINE = bundledRuntimeDeps
|
||||
}
|
||||
|
||||
/** Resolve the application home without touching the user's `~/.dsh`. */
|
||||
function resolveHome() {
|
||||
@@ -80,10 +87,14 @@ async function ensureProfile(dshHome) {
|
||||
for (const [name, target] of [
|
||||
['mqdh-bundle', join(root, 'packages', 'marqdo', 'bundle')],
|
||||
['mqdh-harness', join(root, 'packages', 'marqdo', 'harness')],
|
||||
['mqdh-ui', join(root, 'packages', 'marqdo', 'ui')],
|
||||
]) {
|
||||
const link = join(nodeModules, name)
|
||||
await unlink(link).catch(() => undefined)
|
||||
await symlink(target, link, 'dir')
|
||||
// Junctions are the unprivileged Windows directory link; symbolic links
|
||||
// require Developer Mode or elevation there.
|
||||
const kind = process.platform === 'win32' ? 'junction' : 'dir'
|
||||
await rmdir(link).catch(() => unlink(link).catch(() => undefined))
|
||||
await symlink(target, link, kind)
|
||||
}
|
||||
return profileDir
|
||||
}
|
||||
|
||||
@@ -0,0 +1,167 @@
|
||||
# Build the formal MQDH Windows portable ZIP from a verified application tree.
|
||||
#
|
||||
# The ZIP is a ready-to-run portable distribution: extract, double-click
|
||||
# MQDH.exe, and the inherited DSH Web UI opens. It does not require PowerShell,
|
||||
# install.ps1 or a terminal. The application tree itself comes from the verified
|
||||
# Windows build (package-windows.ps1 / release archive); this script only adds
|
||||
# the thin launcher and packages the bytes.
|
||||
|
||||
[CmdletBinding()]
|
||||
param(
|
||||
[string]$AppArchive = '',
|
||||
[string]$AppTree = '',
|
||||
[string]$OutDir = (Join-Path $PSScriptRoot '..\.ci'),
|
||||
[string]$SourceSha = '',
|
||||
[string]$LauncherExe = ''
|
||||
)
|
||||
|
||||
$ErrorActionPreference = 'Stop'
|
||||
Set-StrictMode -Version Latest
|
||||
|
||||
|
||||
function Read-JsonFile {
|
||||
param([string]$Path)
|
||||
return [IO.File]::ReadAllText($Path, [Text.Encoding]::UTF8) | ConvertFrom-Json
|
||||
}
|
||||
|
||||
if ($AppArchive -eq '' -and $AppTree -eq '') { throw 'pass -AppArchive or -AppTree' }
|
||||
if ($AppTree -ne '' -and -not (Test-Path -LiteralPath $AppTree)) { throw "application tree is missing: $AppTree" }
|
||||
$archive = ''
|
||||
if ($AppArchive -ne '') {
|
||||
$archive = (Resolve-Path -LiteralPath $AppArchive).Path
|
||||
if (-not (Test-Path -LiteralPath $archive)) { throw "application archive is missing: $AppArchive" }
|
||||
}
|
||||
New-Item -ItemType Directory -Force -Path $OutDir | Out-Null
|
||||
|
||||
$work = Join-Path ([IO.Path]::GetTempPath()) ("mqdh-portable-" + [guid]::NewGuid().ToString('N'))
|
||||
New-Item -ItemType Directory -Force -Path $work | Out-Null
|
||||
try {
|
||||
if ($AppTree -ne '') {
|
||||
$tree = (Resolve-Path -LiteralPath $AppTree).Path
|
||||
} else {
|
||||
Write-Host "extracting verified application tree from $archive"
|
||||
& tar.exe -xzf $archive -C $work
|
||||
if ($LASTEXITCODE -ne 0) { throw "tar extraction failed: $LASTEXITCODE" }
|
||||
$top = Get-ChildItem -LiteralPath $work -Directory | Select-Object -First 1
|
||||
if (-not $top) { throw 'application archive has no top-level directory' }
|
||||
$tree = $top.FullName
|
||||
}
|
||||
|
||||
$packageJson = Read-JsonFile (Join-Path $tree 'packages\marqdo\harness\package.json')
|
||||
$version = [string]$packageJson.version
|
||||
if ($version -eq '') { throw 'application tree has no product version' }
|
||||
$folder = "MQDH-$version-win-x64"
|
||||
|
||||
if ($SourceSha -ne '') {
|
||||
if ($SourceSha -notmatch '^[0-9a-f]{40}$') { throw "invalid -SourceSha: $SourceSha" }
|
||||
Set-Content -LiteralPath (Join-Path $tree 'SOURCE_SHA') -Value $SourceSha -Encoding ASCII
|
||||
}
|
||||
|
||||
# A portable build is launched through MQDH.exe; the transitional install
|
||||
# script must not be part of the formal distribution.
|
||||
Remove-Item -LiteralPath (Join-Path $tree 'install.ps1') -Force -ErrorAction SilentlyContinue
|
||||
Remove-Item -LiteralPath (Join-Path $tree 'mqdh.cmd') -Force -ErrorAction SilentlyContinue
|
||||
|
||||
if ($LauncherExe -eq '') {
|
||||
& (Join-Path $PSScriptRoot 'launcher\build-launcher.ps1') -OutDir (Join-Path $work 'launcher')
|
||||
if ($LASTEXITCODE -ne 0) { throw "launcher build failed: $LASTEXITCODE" }
|
||||
$LauncherExe = Join-Path $work 'launcher\MQDH.exe'
|
||||
}
|
||||
if (-not (Test-Path -LiteralPath $LauncherExe)) { throw "launcher is missing: $LauncherExe" }
|
||||
Copy-Item -LiteralPath $LauncherExe -Destination (Join-Path $tree 'MQDH.exe') -Force
|
||||
Copy-Item -LiteralPath (Join-Path $PSScriptRoot 'launcher\README-Windows.txt') -Destination (Join-Path $tree 'README-Windows.txt') -Force
|
||||
|
||||
if ($AppTree -ne '') {
|
||||
$staged = $tree
|
||||
} else {
|
||||
$staged = Join-Path $work $folder
|
||||
Move-Item -LiteralPath $tree -Destination $staged
|
||||
}
|
||||
|
||||
$zipName = "$folder.zip"
|
||||
$zip = Join-Path $OutDir $zipName
|
||||
Remove-Item -LiteralPath $zip -Force -ErrorAction SilentlyContinue
|
||||
Write-Host "creating $zipName"
|
||||
Add-Type -AssemblyName System.IO.Compression
|
||||
Add-Type -AssemblyName System.IO.Compression.FileSystem
|
||||
$zipStream = [IO.File]::Create($zip)
|
||||
try {
|
||||
$archive = New-Object System.IO.Compression.ZipArchive($zipStream, [System.IO.Compression.ZipArchiveMode]::Create, $false)
|
||||
try {
|
||||
foreach ($file in Get-ChildItem -LiteralPath $staged -Recurse -File -Force) {
|
||||
$relative = $file.FullName.Substring($staged.Length + 1).Replace('\', '/')
|
||||
$entry = $archive.CreateEntry("$folder/$relative", [System.IO.Compression.CompressionLevel]::Fastest)
|
||||
$entryStream = $entry.Open()
|
||||
$input = [IO.File]::OpenRead($file.FullName)
|
||||
try { $input.CopyTo($entryStream) } finally { $input.Dispose(); $entryStream.Dispose() }
|
||||
}
|
||||
} finally { $archive.Dispose() }
|
||||
} finally { $zipStream.Dispose() }
|
||||
$zipHash = (Get-FileHash -LiteralPath $zip -Algorithm SHA256).Hash.ToLower()
|
||||
$sidecar = "$zip.sha256"
|
||||
[IO.File]::WriteAllText($sidecar, "$zipHash $zipName`n", (New-Object Text.UTF8Encoding($false)))
|
||||
|
||||
# PE subsystem 2 = Windows GUI: the launcher must never open a console window.
|
||||
$launcherBytes = [IO.File]::ReadAllBytes((Join-Path $staged 'MQDH.exe'))
|
||||
$peOffset = [BitConverter]::ToInt32($launcherBytes, 0x3C)
|
||||
$subsystem = [BitConverter]::ToUInt16($launcherBytes, $peOffset + 24 + 68)
|
||||
if ($subsystem -ne 2) { throw "launcher is not a Windows GUI executable (subsystem=$subsystem)" }
|
||||
|
||||
# Cold start: extract the ZIP, run MQDH.exe with an empty home, and confirm the
|
||||
# workbench answers. This exercises the actual portable user path.
|
||||
$verify = Join-Path $work 'verify'
|
||||
New-Item -ItemType Directory -Force -Path $verify | Out-Null
|
||||
[System.IO.Compression.ZipFile]::ExtractToDirectory($zip, $verify)
|
||||
$verifyTree = Join-Path $verify $folder
|
||||
$userHome = Join-Path $verify 'home'
|
||||
New-Item -ItemType Directory -Force -Path $userHome | Out-Null
|
||||
$previousHome = $env:MQDH_HOME
|
||||
$env:MQDH_HOME = $userHome
|
||||
try {
|
||||
$launcher = Start-Process -FilePath (Join-Path $verifyTree 'MQDH.exe') -PassThru
|
||||
$urlFile = Join-Path $userHome 'workbench.url'
|
||||
$deadline = (Get-Date).AddSeconds(180)
|
||||
while (-not (Test-Path -LiteralPath $urlFile) -and (Get-Date) -lt $deadline) { Start-Sleep -Milliseconds 500 }
|
||||
if (-not (Test-Path -LiteralPath $urlFile)) { throw 'portable launcher did not report a workbench URL' }
|
||||
$url = ([IO.File]::ReadAllText($urlFile)).Trim()
|
||||
$response = Invoke-WebRequest -Uri $url -UseBasicParsing -TimeoutSec 30
|
||||
if ($response.StatusCode -ne 200) { throw "workbench returned $($response.StatusCode)" }
|
||||
$environment = Get-ChildItem -LiteralPath (Join-Path $userHome 'ecosystem\environments') -Directory -ErrorAction SilentlyContinue | Select-Object -First 1
|
||||
if (-not $environment) { throw 'portable launcher did not install a runtime environment' }
|
||||
$pidFile = Join-Path $userHome 'launcher.pid'
|
||||
if (Test-Path -LiteralPath $pidFile) {
|
||||
$serverPid = [int](([IO.File]::ReadAllText($pidFile)).Trim())
|
||||
& taskkill.exe /PID $serverPid /T /F | Out-Null
|
||||
}
|
||||
if (-not $launcher.HasExited) { Stop-Process -Id $launcher.Id -Force -ErrorAction SilentlyContinue }
|
||||
$evidence = [ordered]@{
|
||||
schema = 'marqdo.mqdh.package-evidence'
|
||||
schema_version = 1
|
||||
status = 'PASS'
|
||||
format = 'portable-zip'
|
||||
archive = $zipName
|
||||
size = (Get-Item -LiteralPath $zip).Length
|
||||
sha256 = $zipHash
|
||||
application_sha = if ($SourceSha -ne '') { $SourceSha } else { (([IO.File]::ReadAllText((Join-Path $staged 'SOURCE_SHA'))).Trim()) }
|
||||
platform = 'x86_64-pc-windows-msvc'
|
||||
launcher = [ordered]@{ name = 'MQDH.exe'; subsystem = 'windows-gui'; sha256 = (Get-FileHash -LiteralPath (Join-Path $staged 'MQDH.exe') -Algorithm SHA256).Hash.ToLower() }
|
||||
cold_portable = [ordered]@{
|
||||
extracted = $true
|
||||
version = $version
|
||||
workbench_http = $response.StatusCode
|
||||
runtime_environment = $environment.Name
|
||||
user_home = $userHome
|
||||
launch_requires_terminal = $false
|
||||
}
|
||||
unverified = @('code signing', 'native Windows CI runner', 'EXE installer desktop integration', 'MQDH-branded shell (marqdo-app-harness#25)')
|
||||
}
|
||||
$evidence | ConvertTo-Json -Depth 8 | Set-Content -LiteralPath (Join-Path $OutDir 'package-evidence.json') -Encoding UTF8
|
||||
Write-Host ("portable zip: {0} ({1:N0} bytes, sha256 {2})" -f $zipName, $evidence.size, $zipHash)
|
||||
}
|
||||
finally {
|
||||
$env:MQDH_HOME = $previousHome
|
||||
}
|
||||
}
|
||||
finally {
|
||||
Remove-Item -LiteralPath $work -Recurse -Force -ErrorAction SilentlyContinue
|
||||
}
|
||||
@@ -0,0 +1,253 @@
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Build one experimental Windows (x86_64) Marqdo Harness release archive.
|
||||
|
||||
.DESCRIPTION
|
||||
Stages the built tree without VCS data, installs a production-only flat
|
||||
`node_modules` so the archive has no package-manager link farm, bundles the
|
||||
Node 24 runtime, adds the `mqdh.cmd` portable launcher and `install.ps1`,
|
||||
then verifies the archive from a cold extract (user-level install, version,
|
||||
doctor, dump-config).
|
||||
|
||||
This is the Windows packaging entry point for the experimental distribution;
|
||||
it does not replace the Linux `package.sh` pipeline or fabricate CI evidence.
|
||||
CI/CD remains Woodpecker-only; a native Windows runner is still required
|
||||
before the platform can be declared supported.
|
||||
|
||||
Environment:
|
||||
MQDH_NODE24_DIR directory containing node.exe and pnpm.cmd (Node >= 24.22.3)
|
||||
MQDH_PACKAGE_WORK working directory for staging/cold install (default: temp)
|
||||
|
||||
.EXAMPLE
|
||||
powershell -ExecutionPolicy Bypass -File .\scripts\package-windows.ps1
|
||||
#>
|
||||
[CmdletBinding()]
|
||||
param(
|
||||
[string]$OutDir = (Join-Path $PSScriptRoot '..\.ci'),
|
||||
[string]$RuntimeDeps = ''
|
||||
)
|
||||
|
||||
$ErrorActionPreference = 'Continue'
|
||||
Set-StrictMode -Version Latest
|
||||
$root = (Resolve-Path (Join-Path $PSScriptRoot '..')).Path
|
||||
Set-Location $root
|
||||
$nodeDir = $env:MQDH_NODE24_DIR
|
||||
if ([string]::IsNullOrWhiteSpace($nodeDir)) { throw 'MQDH_NODE24_DIR is required (Node >= 24.22.3 with pnpm)' }
|
||||
$nodeExe = Join-Path $nodeDir 'node.exe'
|
||||
$pnpmCmd = Join-Path $nodeDir 'pnpm.cmd'
|
||||
foreach ($required in @($nodeExe, $pnpmCmd)) {
|
||||
if (-not (Test-Path -LiteralPath $required)) { throw "missing build tool: $required" }
|
||||
}
|
||||
$nodeVersion = (& $nodeExe --version).Trim()
|
||||
if ($nodeVersion -notmatch '^v(\d+)\.' -or [int]$Matches[1] -lt 24) {
|
||||
throw "Node >= 24.22.3 is required, got $nodeVersion"
|
||||
}
|
||||
foreach ($required in @('apps\cli\lib\bin.js', 'apps\web\dist\index.html', 'scripts\mqdh.mjs')) {
|
||||
if (-not (Test-Path -LiteralPath (Join-Path $root $required))) {
|
||||
throw "build artifacts missing ($required); run pnpm run build first"
|
||||
}
|
||||
}
|
||||
$version = (Get-Content -LiteralPath (Join-Path $root 'packages\marqdo\harness\package.json') -Raw | ConvertFrom-Json).version
|
||||
$sha = (& git -C $root rev-parse HEAD).Trim()
|
||||
if ($sha -notmatch '^[0-9a-f]{40}$') { throw "invalid source SHA: $sha" }
|
||||
$status = & git -C $root status --porcelain
|
||||
if ($status) { throw 'package-windows: the worktree must be clean before packaging' }
|
||||
|
||||
$target = 'x86_64-pc-windows-msvc'
|
||||
$name = "marqdo-harness-$version-$target"
|
||||
$workRoot = if ($env:MQDH_PACKAGE_WORK) { $env:MQDH_PACKAGE_WORK } else { $env:TEMP }
|
||||
$stage = Join-Path $workRoot ("mqdh-win-stage-" + [guid]::NewGuid().ToString('N').Substring(0, 8))
|
||||
$cold = Join-Path $workRoot ("mqdh-win-cold-" + [guid]::NewGuid().ToString('N').Substring(0, 8))
|
||||
$app = Join-Path $stage $name
|
||||
New-Item -ItemType Directory -Force -Path $app, $cold, $OutDir | Out-Null
|
||||
try {
|
||||
# Stage the tracked/built source tree without VCS data or any workspace
|
||||
# node_modules. A tar copy is used instead of robocopy because pnpm creates
|
||||
# per-workspace symbolic-link node_modules; robocopy follows those links and
|
||||
# builds path-limit-breaking recursive copies.
|
||||
$sourceTar = Join-Path $workRoot ("mqdh-win-src-" + [guid]::NewGuid().ToString('N').Substring(0, 8) + '.tar')
|
||||
$excludes = @(
|
||||
'--exclude=.git', '--exclude=node_modules', '--exclude=.ci', '--exclude=.build',
|
||||
'--exclude=.issue-work', '--exclude=.app-verify', '--exclude=.integration-work',
|
||||
'--exclude=.migration-work', '--exclude=.dsh-build', '--exclude=__pycache__',
|
||||
'--exclude=.pytest_cache', '--exclude=coverage', '--exclude=.turbo', '--exclude=.vite',
|
||||
'--exclude=*.log', '--exclude=*.tsbuildinfo', '--exclude=.DS_Store'
|
||||
)
|
||||
& tar.exe -cf $sourceTar @excludes -C $root .
|
||||
if ($LASTEXITCODE -ne 0) { throw "source staging tar failed with exit code $LASTEXITCODE" }
|
||||
& tar.exe -xf $sourceTar -C $app
|
||||
if ($LASTEXITCODE -ne 0) { throw "source staging extraction failed with exit code $LASTEXITCODE" }
|
||||
Remove-Item -LiteralPath $sourceTar -Force -ErrorAction SilentlyContinue
|
||||
|
||||
# Production-only flat dependency tree: no pnpm symlink/junction farm, so the
|
||||
# archive extracts without Windows symlink privileges. Lifecycle scripts are
|
||||
# skipped: the staged tree has no git checkout for the hook installer, and the
|
||||
# build artifacts are already produced in the source worktree.
|
||||
$env:PATH = "$nodeDir;$env:PATH"
|
||||
Push-Location $app
|
||||
try {
|
||||
$pnpmLog = & $pnpmCmd install --frozen-lockfile --prod --node-linker=hoisted --ignore-scripts 2>&1
|
||||
if ($LASTEXITCODE -ne 0) { throw ("production dependency install failed: " + ($pnpmLog -join "`n")) }
|
||||
} finally {
|
||||
Pop-Location
|
||||
}
|
||||
|
||||
# pnpm also creates node_modules in each workspace package for its local
|
||||
# links. Those link farms require symlink privileges after extraction and
|
||||
# are unnecessary: the hoisted root node_modules resolves every dependency.
|
||||
# cmd's rmdir removes junctions/links without following them.
|
||||
$nested = @()
|
||||
$nested += Get-ChildItem -LiteralPath (Join-Path $app 'apps') -Directory -ErrorAction SilentlyContinue | ForEach-Object { Join-Path $_.FullName 'node_modules' }
|
||||
$nested += Get-ChildItem -LiteralPath (Join-Path $app 'packages') -Directory -ErrorAction SilentlyContinue | ForEach-Object {
|
||||
Get-ChildItem -LiteralPath $_.FullName -Directory -ErrorAction SilentlyContinue | ForEach-Object { Join-Path $_.FullName 'node_modules' }
|
||||
}
|
||||
$nested += Get-ChildItem -LiteralPath (Join-Path $app 'vendor') -Directory -ErrorAction SilentlyContinue | ForEach-Object { Join-Path $_.FullName 'node_modules' }
|
||||
$nested += Join-Path $app 'native\system\node_modules'
|
||||
$nested += Get-ChildItem -LiteralPath (Join-Path $app 'native\system\packages') -Directory -ErrorAction SilentlyContinue | ForEach-Object { Join-Path $_.FullName 'node_modules' }
|
||||
foreach ($nestedPath in $nested) {
|
||||
if (Test-Path -LiteralPath $nestedPath) {
|
||||
& cmd.exe /c "rmdir /s /q `"$nestedPath`"" | Out-Null
|
||||
}
|
||||
}
|
||||
# Hoisted install still links workspace packages into node_modules. Replace
|
||||
# each link with a copy so extraction on a clean Windows host needs no
|
||||
# symbolic-link privilege; nested dependency links are unnecessary because
|
||||
# the hoisted root node_modules holds the shared dependency tree.
|
||||
for ($pass = 0; $pass -lt 3; $pass++) {
|
||||
$links = @(Get-ChildItem -LiteralPath (Join-Path $app 'node_modules') -Recurse -Force -ErrorAction SilentlyContinue |
|
||||
Where-Object { $_.Attributes -band [System.IO.FileAttributes]::ReparsePoint })
|
||||
if ($links.Count -eq 0) { break }
|
||||
foreach ($link in $links) {
|
||||
$linkTarget = $link.Target
|
||||
if ($linkTarget -is [array]) { $linkTarget = $linkTarget[0] }
|
||||
if (-not [System.IO.Path]::IsPathRooted($linkTarget)) { $linkTarget = Join-Path $link.DirectoryName $linkTarget }
|
||||
$linkTarget = [System.IO.Path]::GetFullPath($linkTarget)
|
||||
if ((Test-Path -LiteralPath $linkTarget) -and (Get-Item -LiteralPath $linkTarget).PSIsContainer) {
|
||||
$copy = "$($link.FullName).workspace-copy"
|
||||
Remove-Item -LiteralPath $copy -Recurse -Force -ErrorAction SilentlyContinue
|
||||
# Do not copy the target's own node_modules: the hoisted root
|
||||
# dependency tree is the only resolver, and copy sources can
|
||||
# contain directory symlinks that robocopy would follow into
|
||||
# path-limit-breaking recursive copies.
|
||||
& robocopy $linkTarget $copy /E /XJ /XD (Join-Path $linkTarget 'node_modules') /R:1 /W:1 /NFL /NDL /NJH /NJS /NP | Out-Null
|
||||
if ($LASTEXITCODE -ge 8) { throw "workspace link copy failed: $($link.FullName)" }
|
||||
[System.IO.Directory]::Delete($link.FullName)
|
||||
Move-Item -LiteralPath $copy -Destination $link.FullName
|
||||
} else {
|
||||
$bytes = [System.IO.File]::ReadAllBytes($linkTarget)
|
||||
[System.IO.File]::Delete($link.FullName)
|
||||
[System.IO.File]::WriteAllBytes($link.FullName, $bytes)
|
||||
}
|
||||
}
|
||||
}
|
||||
$links = @(Get-ChildItem -LiteralPath (Join-Path $app 'node_modules') -Recurse -Force -ErrorAction SilentlyContinue |
|
||||
Where-Object { $_.Attributes -band [System.IO.FileAttributes]::ReparsePoint })
|
||||
if ($links.Count -gt 0) {
|
||||
throw "flat node_modules still contains $($links.Count) reparse points; the archive would not be portable"
|
||||
}
|
||||
|
||||
# Documentation, benchmarks, repository automation and Python/website
|
||||
# sources are not part of the product runtime; dropping them keeps the
|
||||
# experimental Windows download within the same order of magnitude as the
|
||||
# Linux archive.
|
||||
foreach ($prune in @('docs', 'website', 'benchmarks', '.agents', '.claude', '.github', '.woodpecker', 'python', 'snapshots')) {
|
||||
Remove-Item -LiteralPath (Join-Path $app $prune) -Recurse -Force -ErrorAction SilentlyContinue
|
||||
}
|
||||
|
||||
New-Item -ItemType Directory -Force -Path (Join-Path $app 'runtime') | Out-Null
|
||||
Copy-Item -LiteralPath $nodeExe -Destination (Join-Path $app 'runtime\node.exe')
|
||||
Set-Content -LiteralPath (Join-Path $app 'runtime\VERSION') -Value $nodeVersion -Encoding ASCII
|
||||
Set-Content -LiteralPath (Join-Path $app 'SOURCE_SHA') -Value $sha -Encoding ASCII
|
||||
Copy-Item -LiteralPath (Join-Path $root 'scripts\install.ps1') -Destination (Join-Path $app 'install.ps1') -Force
|
||||
Copy-Item -LiteralPath (Join-Path $root 'scripts\mqdh.cmd') -Destination (Join-Path $app 'mqdh.cmd') -Force
|
||||
|
||||
# Optional bundled offline runtime pack: the launcher points bootstrap at it,
|
||||
# so a fresh Windows install can install CLI/Worker/Bundle without network.
|
||||
$bundledRuntime = @()
|
||||
if ($RuntimeDeps -ne '') {
|
||||
$deps = (Resolve-Path -LiteralPath $RuntimeDeps).Path
|
||||
if (-not (Test-Path -LiteralPath $deps)) { throw "runtime deps directory is missing: $RuntimeDeps" }
|
||||
$targetDeps = Join-Path $app 'runtime-deps'
|
||||
New-Item -ItemType Directory -Force -Path $targetDeps | Out-Null
|
||||
foreach ($file in Get-ChildItem -LiteralPath $deps -File) {
|
||||
Copy-Item -LiteralPath $file.FullName -Destination (Join-Path $targetDeps $file.Name)
|
||||
if ($file.Name -like '*.tar.gz') {
|
||||
$sidecar = Join-Path $deps ($file.Name + '.sha256')
|
||||
if (-not (Test-Path -LiteralPath $sidecar)) { throw "runtime deps archive has no .sha256 sidecar: $($file.Name)" }
|
||||
$digest = (Get-FileHash -LiteralPath $file.FullName -Algorithm SHA256).Hash.ToLower()
|
||||
$declared = (Get-Content -LiteralPath $sidecar -Raw).Trim().Split(' ')[0].ToLower()
|
||||
if ($digest -ne $declared) { throw "runtime deps digest mismatch: $($file.Name)" }
|
||||
$bundledRuntime += [ordered]@{ name = $file.Name; size = $file.Length; sha256 = $digest }
|
||||
}
|
||||
}
|
||||
if ($bundledRuntime.Count -eq 0) { throw 'runtime deps directory has no component archive' }
|
||||
}
|
||||
|
||||
$archive = Join-Path $OutDir "$name.tar.gz"
|
||||
Remove-Item -LiteralPath $archive -Force -ErrorAction SilentlyContinue
|
||||
& tar.exe -czf $archive -C $stage $name
|
||||
if ($LASTEXITCODE -ne 0) { throw "archive creation failed with exit code $LASTEXITCODE" }
|
||||
$sha256 = (Get-FileHash -LiteralPath $archive -Algorithm SHA256).Hash.ToLower()
|
||||
Set-Content -LiteralPath "$archive.sha256" -Value "$sha256 $name.tar.gz" -Encoding ASCII
|
||||
Write-Host "archive: $archive ($((Get-Item -LiteralPath $archive).Length) bytes, sha256 $sha256)"
|
||||
|
||||
$manifestArgs = @('scripts/release-manifest.ts', '--archive', $archive, '--target', $target, '--out', $OutDir)
|
||||
$manifestLog = & $nodeExe @manifestArgs 2>&1
|
||||
if ($LASTEXITCODE -ne 0) { throw ("release manifest generation failed: " + ($manifestLog -join "`n")) }
|
||||
$manifestLog | Out-Host
|
||||
|
||||
& tar.exe -xzf $archive -C $cold
|
||||
if ($LASTEXITCODE -ne 0) { throw "cold extract failed with exit code $LASTEXITCODE" }
|
||||
$coldTree = Join-Path $cold $name
|
||||
$coldPrefix = Join-Path $cold 'prefix'
|
||||
& powershell -NoProfile -ExecutionPolicy Bypass -File (Join-Path $coldTree 'install.ps1') -Prefix $coldPrefix -NoPath -NoShortcut | Out-Host
|
||||
if ($LASTEXITCODE -ne 0) { throw "cold install failed with exit code $LASTEXITCODE" }
|
||||
$installed = (& (Join-Path $coldPrefix 'bin\mqdh.cmd') --version).Trim()
|
||||
if ($installed -notlike "*$version*") { throw "cold version mismatch: $installed" }
|
||||
$coldHome = Join-Path $cold 'home'
|
||||
$env:MQDH_HOME = $coldHome
|
||||
$doctor = (& (Join-Path $coldPrefix 'bin\mqdh.cmd') doctor --json) -join "`n"
|
||||
$doctorJson = $doctor | ConvertFrom-Json
|
||||
if ($doctorJson.schema -ne 'marqdo.mqdh.doctor') { throw "unexpected doctor schema: $($doctorJson.schema)" }
|
||||
if ($doctorJson.platform.target -ne $target) { throw "unexpected doctor target: $($doctorJson.platform.target)" }
|
||||
$dump = (& (Join-Path $coldPrefix 'bin\mqdh.cmd') --dump-config) -join "`n"
|
||||
if ($dump -notmatch 'mqdh-harness' -or $dump -notmatch 'mqdh-web') { throw 'dump-config missing mqdh profile entries' }
|
||||
Remove-Item Env:MQDH_HOME
|
||||
& $nodeExe --version | Out-Null
|
||||
|
||||
$evidence = [ordered]@{
|
||||
schema = 'marqdo.mqdh.package-evidence'
|
||||
schema_version = 1
|
||||
status = 'PASS'
|
||||
archive = "$name.tar.gz"
|
||||
size = (Get-Item -LiteralPath $archive).Length
|
||||
sha256 = $sha256
|
||||
application_sha = $sha
|
||||
platform = $target
|
||||
node = (& $nodeExe --version).Trim()
|
||||
bundled_node = [ordered]@{ version = (Get-Content -LiteralPath (Join-Path $app 'runtime\VERSION')).Trim(); sha256 = (Get-FileHash -LiteralPath (Join-Path $app 'runtime\node.exe') -Algorithm SHA256).Hash.ToLower() }
|
||||
cold_install = [ordered]@{
|
||||
version = $installed
|
||||
doctor_schema = $doctorJson.schema
|
||||
doctor_target = $doctorJson.platform.target
|
||||
dump_config = 'PASS'
|
||||
bundle_node = 'PASS'
|
||||
}
|
||||
manifest = 'mqdh-release.json'
|
||||
signature = 'unsigned'
|
||||
bundled_runtime = $bundledRuntime
|
||||
contains_marqdo_cli_source = $false
|
||||
unverified = @(
|
||||
'native Windows CI runner',
|
||||
'official signing key',
|
||||
'real model E2E',
|
||||
'second clean Windows host',
|
||||
'in-app Windows update path'
|
||||
)
|
||||
}
|
||||
$evidence | ConvertTo-Json -Depth 8 | Set-Content -LiteralPath (Join-Path $OutDir 'package-evidence.json') -Encoding UTF8
|
||||
Write-Host 'mqdh windows package: PASS'
|
||||
} finally {
|
||||
Remove-Item -LiteralPath $stage -Recurse -Force -ErrorAction SilentlyContinue
|
||||
Remove-Item -LiteralPath $cold -Recurse -Force -ErrorAction SilentlyContinue
|
||||
}
|
||||
@@ -15,7 +15,7 @@ import { execFileSync } from 'node:child_process'
|
||||
import { mkdir, readFile, stat, writeFile } from 'node:fs/promises'
|
||||
import { basename, join, resolve } from 'node:path'
|
||||
import {
|
||||
APP_RELEASE_SCHEMA, APP_RELEASE_SCHEMA_VERSION, assetNameFor, sidecarNameFor,
|
||||
APP_RELEASE_SCHEMA, APP_RELEASE_SCHEMA_VERSION, assetNameFor, portableZipNameFor, sidecarNameFor,
|
||||
signAppReleaseManifest, SIGNATURE_ASSET, MANIFEST_ASSET,
|
||||
} from '../packages/marqdo/harness/src/release/manifest.ts'
|
||||
import type { AppReleaseManifest } from '../packages/marqdo/harness/src/release/manifest.ts'
|
||||
@@ -48,10 +48,24 @@ function git(...command: string[]): string {
|
||||
}
|
||||
}
|
||||
|
||||
/** Map the host architecture to a release target. */
|
||||
function targetOf(machine: string): string {
|
||||
if (machine === 'x86_64' || machine === 'x64') return 'x86_64-unknown-linux-gnu'
|
||||
throw new Error(`unsupported packaging architecture: ${machine}`)
|
||||
/** Map the packaging host to a release target. */
|
||||
function targetOf(nodePlatform: string, machine: string): string {
|
||||
if (nodePlatform === 'win32') {
|
||||
if (machine === 'x64' || machine === 'x86_64') return 'x86_64-pc-windows-msvc'
|
||||
throw new Error(`unsupported packaging architecture: ${machine}`)
|
||||
}
|
||||
if (nodePlatform === 'linux') {
|
||||
if (machine === 'x86_64' || machine === 'x64') return 'x86_64-unknown-linux-gnu'
|
||||
throw new Error(`unsupported packaging architecture: ${machine}`)
|
||||
}
|
||||
throw new Error(`unsupported packaging platform: ${nodePlatform}`)
|
||||
}
|
||||
|
||||
/** Release platform fields for one supported target. */
|
||||
function platformFieldsFor(target: string): { os: string; arch: string; min_glibc: string | null } {
|
||||
if (target === 'x86_64-pc-windows-msvc') return { os: 'windows', arch: 'x64', min_glibc: null }
|
||||
if (target === 'x86_64-unknown-linux-gnu') return { os: 'linux', arch: 'x64', min_glibc: '2.39' }
|
||||
throw new Error(`unsupported release target: ${target}`)
|
||||
}
|
||||
|
||||
const parsed = args(process.argv.slice(2))
|
||||
@@ -68,10 +82,14 @@ const packageJson = JSON.parse(await readFile(join('packages', 'marqdo', 'harnes
|
||||
const version = typeof packageJson.version === 'string' ? packageJson.version : ''
|
||||
if (version === '') throw new Error('packages/marqdo/harness/package.json has no version')
|
||||
const pinnedUpstream = typeof packageJson.dshUpstreamSha === 'string' ? packageJson.dshUpstreamSha : ''
|
||||
const machine = execFileSync('uname', ['-m'], { encoding: 'utf8' }).trim()
|
||||
const target = flag(parsed, 'target') ?? targetOf(machine)
|
||||
if (basename(archivePath) !== assetNameFor(version, target)) {
|
||||
throw new Error(`archive name must be ${assetNameFor(version, target)}, got ${basename(archivePath)}`)
|
||||
const machine = process.arch
|
||||
const target = flag(parsed, 'target') ?? targetOf(process.platform, machine)
|
||||
const platformFields = platformFieldsFor(target)
|
||||
const format = flag(parsed, 'format') ?? 'tar.gz'
|
||||
if (format !== 'tar.gz' && format !== 'portable-zip') throw new Error(`unsupported release format: ${format}`)
|
||||
const expectedName = format === 'portable-zip' ? portableZipNameFor(version) : assetNameFor(version, target)
|
||||
if (basename(archivePath) !== expectedName) {
|
||||
throw new Error(`archive name must be ${expectedName}, got ${basename(archivePath)}`)
|
||||
}
|
||||
const sourceSha = flag(parsed, 'source-sha') ?? git('rev-parse', 'HEAD')
|
||||
const upstreamSha = flag(parsed, 'upstream-sha') ?? process.env.MQDH_DSH_UPSTREAM_SHA
|
||||
@@ -93,13 +111,13 @@ const payload: Omit<AppReleaseManifest, 'signature'> = {
|
||||
},
|
||||
platform: {
|
||||
target,
|
||||
os: 'linux',
|
||||
arch: machine === 'x86_64' || machine === 'x64' ? 'x64' : machine,
|
||||
min_glibc: '2.39',
|
||||
os: platformFields.os,
|
||||
arch: platformFields.arch,
|
||||
min_glibc: platformFields.min_glibc,
|
||||
minimum_os: null,
|
||||
},
|
||||
channel: version.includes('-') ? 'beta' : 'stable',
|
||||
asset: { name: assetNameFor(version, target), size: info.size, sha256, target },
|
||||
asset: { name: expectedName, size: info.size, sha256, target },
|
||||
compatibility: {
|
||||
cli: '>=3.0.0-rc.6 <4.0.0',
|
||||
bundle: '>=0.1.0',
|
||||
@@ -132,16 +150,23 @@ const evidence = {
|
||||
schema_version: 1,
|
||||
generated_at: new Date().toISOString(),
|
||||
status: 'PASS',
|
||||
tag: `mqdh-v${version}`,
|
||||
tag: flag(parsed, 'tag') ?? `mqdh-v${version}`,
|
||||
version,
|
||||
target,
|
||||
archive: { name: basename(archivePath), size: info.size, sha256 },
|
||||
format,
|
||||
manifest: MANIFEST_ASSET,
|
||||
signature: signed ? 'ed25519' : 'unsigned',
|
||||
app: { source_sha: sourceSha, dsh_upstream_sha: upstreamSha, node },
|
||||
compatibility: payload.compatibility,
|
||||
dependencies: (() => {
|
||||
const cliSha = (process.env.MQDH_CLI_SOURCE_SHA ?? '').trim()
|
||||
if (cliSha === '') return []
|
||||
if (!/^[0-9a-f]{40}$/.test(cliSha)) throw new Error('MQDH_CLI_SOURCE_SHA must be a full commit SHA')
|
||||
return [{ id: 'cli', source_sha: cliSha }]
|
||||
})(),
|
||||
commands: [
|
||||
`node scripts/release-manifest.ts --archive ${basename(archivePath)} --target ${target}`,
|
||||
`node scripts/release-manifest.ts --archive ${basename(archivePath)} --target ${target} --format ${format}`,
|
||||
],
|
||||
unverified: [
|
||||
'official signing key is not configured (release is explicitly unsigned)',
|
||||
|
||||
@@ -56,6 +56,7 @@
|
||||
"packages/client/*/tests/**/*.host.ts"
|
||||
],
|
||||
"references": [
|
||||
{ "path": "./packages/marqdo/ui" },
|
||||
{ "path": "./packages/client/ui-action-cards" },
|
||||
{ "path": "./packages/client/ui-creation-recommendations" },
|
||||
{ "path": "./packages/client/ui-plugin-recommendations" },
|
||||
|
||||
@@ -20,11 +20,10 @@ function isBuildFaceClient(value: unknown): boolean {
|
||||
*/
|
||||
export default defineConfig(({ env }) => {
|
||||
const client = isBuildFaceClient(env?.DSH_BUILD_FACE)
|
||||
// Downstream Marqdo packages ship TypeScript executed by Node's native type
|
||||
// stripping; they have no lib/types entry and must not enter the upstream
|
||||
// bundling graph (recorded in docs/mqdh/upstream-delta.md).
|
||||
// Product server packages run as TypeScript. Its browser contribution uses
|
||||
// the same client artifact pipeline as the inherited shell.
|
||||
const packages = workspacePackageGlobs(globSync(['vendor/*/package.json', 'packages/*/*/package.json'], { cwd: import.meta.dirname }))
|
||||
.filter(directory => !directory.startsWith('packages/marqdo/'))
|
||||
.filter(directory => !directory.startsWith('packages/marqdo/') || directory === 'packages/marqdo/ui')
|
||||
return {
|
||||
workspace: [...packages, 'apps/cli', ...client ? [] : ['apps/desktop-host']],
|
||||
entry: client ? '' : ['lib/types/{index,startup}.js'],
|
||||
|
||||