Author SHA1 Message Date
cflmyandCursor b9e9aa9f9e ci: pin Design/Preview publish-helper commits
ci/woodpecker/push/ci Pipeline was successful
ci/woodpecker/pr/ci Pipeline was successful
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-11-27 19:29:39 +08:00
cflmy af0015dfc4 ci: protected publish workflow (#10)
ci/woodpecker/push/ci Pipeline is pending
ci: protected publish workflow (#10)
2026-11-27 19:23:35 +08:00
cflmy 26bd87bfe9 ci: add protected component publish workflow and immutable release helpers
ci/woodpecker/push/ci Pipeline was successful
ci/woodpecker/pr/ci Pipeline was successful
Vendor the root component-release helpers, add source packaging plus
release-evidence, and split publish (tag/manual) from notify (release event).
2026-11-27 19:23:08 +08:00
cflmy a3ddccd8a4 ci: run Web domain acceptance on the shared web image\n\nUse marqdo-ci-web (Ubuntu + Node/Playwright Chromium from the domestic\nnpmmirror binary mirror, released CLI/Bundle and packaged preview Tool). Pin the\nproduction app Playwright to the image version and use the full Chromium channel\nto avoid the unavailable headless-shell asset; no per-run browser download.
ci/woodpecker/pr/ci Pipeline was successful
ci/woodpecker/push/ci Pipeline was successful
ci/woodpecker/manual/ci Pipeline was successful
2026-11-27 16:01:30 +08:00
cflmy b11cbeac57 ci: pin current Design/Preview lanes
Update child gitlinks to the commits that carry the shared CI image/release
notification lanes; domain behavior unchanged.
2026-11-27 15:25:48 +08:00
marqdo-ci 5b70e1d06e ci: notify the root reconcile on a completed release
Release event fast path: validate the secret is present, then ask the root
manual `reconcile` workflow to check the authoritative Gitea release. The call
is only a hint; correctness and lost-notification recovery stay in the root
reconcile cron/script.
2026-11-27 14:18:26 +08:00
cflmy 246ef7692c ci: pin Design/Preview unified CI image commits
Update the domain child gitlinks to the commits that consume the shared
marqdo-ci-rust image; the domain acceptance itself is unchanged and still runs
the packaged preview tool and production app on its own lane.
2026-11-27 14:10:51 +08:00
marqdo-norms 70ba4a27e5 docs: adopt ecosystem repository conventions and refresh active component facts
- Add the canonical AGENTS marker/link required by the root repository conventions.
- Correct the Web domain README/AGENTS status: Design/Preview are active with real
  entries, web-components remains planned; no fabricated progress.
- Pin the domain child gitlinks to their convention commits.

Refs cflmy/marqdo docs/REPOSITORY-CONVENTIONS.md
2026-11-27 11:37:07 +08:00
cflmy f6d0a9067c feat: activate the Web domain and its Design/Preview entries (WEB-05)
- web-design and web-preview move planned→active with their real scripts/ci.sh
  entries; web-components stays planned with no fabricated entry.
- The domain entry is scripts/domain-acceptance.sh: explicit CLI + built web
  Tool, three composition cases and the production delivery trial (API and
  browser E2E). Domain submodule gitlinks stay fixed to the merged Design
  (1b6607f) and Preview (eff273f) candidates.
- README/catalog/evidence record the activation and the remaining root
  integration steps (root gitlink, recursive check, web Tool cold install),
  which belong to the root candidate.

Refs cflmy/marqdo-ext-web#2, cflmy/marqdo#6
2026-11-27 09:04:18 +08:00
cflmy 7a2c9280c0 feat: WEB-04 domain composition cases and production delivery trial
Add three composition cases driven by the same generic web Tool:
- examples/doc-site (documentation site),
- examples/research-workspace (existing section 8 workbench prototype),
- examples/quantum-editor (finite scenario/interaction design).

Add a real production delivery trial in examples/research-workbench-app
(Express + JSON persistence + static UI): validation, search, status
transitions, linked statistics, JSON errors, real file persistence; node:test
API acceptance and a Playwright browser E2E. The production app is not a runtime
dependency of the web Tool; prototype PASS is kept separate from production
PASS. docs/WEB-04-delivery.md records the design-source to implementation
mapping, intentional non-goals and task splits.

scripts/domain-acceptance.sh is the explicit domain entry: installs the built
Tool, runs check/preview/handoff for the three cases, then installs/tests the
production app incl. browser E2E, and removes the Tool. Evidence records the
real CLI/Design/Preview identities and local PASS results.

Pin the domain submodules to the merged Design (WEB-01/03) and Preview (WEB-02)
candidates; activation and root gitlink belong to WEB-05.

Refs cflmy/marqdo-ext-web#2, cflmy/marqdo#6
2026-11-27 09:02:27 +08:00
38 changed files with 2500 additions and 13 deletions

No files matched your search

+1
View File
@@ -18,3 +18,4 @@
# 编辑器
/.idea/
/.vscode/
dist/
+14
View File
@@ -0,0 +1,14 @@
# Web domain acceptance: one published image with Node/Chromium, the released
# CLI/Bundle and the packaged preview Tool. The domain only runs its own
# acceptance entry; no Rust toolchain, browser download or CLI setup per run.
when:
event: [push, pull_request, manual]
steps:
domain:
image: git.cflmy.cn/cflmy/marqdo-ci-web:3.0.0-rc.5
environment:
PLAYWRIGHT_BROWSERS_PATH: /ms-playwright
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: "1"
commands:
- bash scripts/domain-acceptance.sh
+26
View File
@@ -0,0 +1,26 @@
when:
- event: [tag, manual]
steps:
publish:
image: git.cflmy.cn/cflmy/marqdo-ci-shell:3.0.0-rc.5
environment:
GITEA_PUBLISH_TOKEN:
from_secret: gitea_publish_token
COMPONENT_ID: web
REPOSITORY: cflmy/marqdo-ext-web
commands:
- |
set -eu
test -n "${GITEA_PUBLISH_TOKEN:?}"
test -n "${CI_COMMIT_TAG:?}"
export SOURCE_SHA="${CI_COMMIT_SHA}"
export VERSION="${CI_COMMIT_TAG#v}"
export COMPONENT_ID=web
export REPOSITORY=cflmy/marqdo-ext-web
sh scripts/package.sh
ARCHIVE="dist/marqdo-web-${VERSION}-source.tar.gz"
python3 scripts/release/publish_gitea.py \
--repo cflmy/marqdo-ext-web --tag "${CI_COMMIT_TAG}" --target "$SOURCE_SHA" --prerelease \
--body "Automated source release for web ${CI_COMMIT_TAG}." \
--asset "$ARCHIVE" --asset "${ARCHIVE}.sha256" --asset dist/release-evidence.json \
--evidence-out dist/gitea-publish-result.json
+12
View File
@@ -0,0 +1,12 @@
when:
event: [release]
steps:
notify:
image: git.cflmy.cn/cflmy/marqdo-ci-shell:3.0.0-rc.5
environment:
WOODPECKER_NOTIFY_TOKEN:
from_secret: woodpecker_notify_token
commands:
- |
set -eu
python3 scripts/release/notify_root.py --hint-component web --hint-tag "${CI_COMMIT_TAG:-}"
+7 -2
View File
@@ -1,5 +1,10 @@
# AGENTS.md — marqdo-ext-web 协作约定
<!-- marqdo:repo-conventions v1 -->
生态级仓库开发规范:https://git.cflmy.cn/cflmy/marqdo/src/branch/main/docs/REPOSITORY-CONVENTIONS.md
本文件约束在本仓库工作的 AI Agent 与开发者。**作者面规则以 [docs/WEB-DESIGN.md](docs/WEB-DESIGN.md) 为准,领域流程以 [docs/DEVELOPMENT.md](docs/DEVELOPMENT.md) 为准**;本文件只写协作纪律,不复制合同正文。
## 1. 先读什么
@@ -11,10 +16,10 @@
## 2. 事实边界(违反即返工)
- 当前全体 Web 组件为 `planned`,Design 与 Preview 的子模块固定真实开发提交。功能入口、制品和 PASS 证据随实际实现建立。
- 领域与 **Design/Preview 已 active**(catalog 登记真实 `entry`,gitlink 固定已验收候选);`web-components` 仍 `planned`,不登记 entry。功能入口/制品/PASS 证据以各仓实际候选为准。
- 未实际运行的验收一律标 `UNVERIFIED`;`examples/research-workspace` 的六个文件尚未在真实 CLI/Design/Preview 上运行。
- 本仓库是聚合仓库:不实现 renderer/parser/数据库驱动,不复制子仓库源码,不把业务逻辑藏在“集成脚本”里。
- 计划依赖(`requires`)须在晋升前以真实构建核实,`planned` gitlink 仅固定开发提交。
- 依赖(`requires`)已按真实构建核实;`planned` 子组件 gitlink 仅固定开发提交,不计完成率。
## 3. 修改规则
+20 -6
View File
@@ -1,8 +1,8 @@
# marqdo-ext-web
Marqdo **Web 领域聚合仓库**(状态:`planned`)。本仓固定 Web 作者合同、完整组合示例与跨组件验收,协调 Design/Preview 的变更与发布;**不承载生产实现**,也不是旧版 Markdown/GFM 页面渲染服务的继续。
Marqdo **Web 领域聚合仓库**(状态:`active`,WEB-05 已完成;Design/Preview active,web-components 仍 planned)。本仓固定 Web 作者合同、完整组合示例与跨组件验收,协调 Design/Preview 的变更与发布;**不承载生产实现**,也不是旧版 Markdown/GFM 页面渲染服务的继续。
本仓通过 Git 子模块固定 Design 和 Preview 的开发提交。领域和子组件均为 `planned`,实际验收入口和发行制品随功能开发建立。子组件登记见 [`components.toml`](components.toml)。
本仓通过 Git 子模块固定 Design 和 Preview 的开发提交。Design/Preview 已通过组件验收并激活;web-components 仍 planned。领域入口为 `scripts/domain-acceptance.sh`(根/领域 CI 以显式 CLI + 已构建 web Tool 运行)。子组件登记见 [`components.toml`](components.toml)。
## 唯一合同入口
@@ -13,7 +13,7 @@ Marqdo **Web 领域聚合仓库**(状态:`planned`)。本仓固定 Web 作
| [examples/research-workspace/](examples/research-workspace/) | 根规范 §8 科研工作台示例(六个 `.mq.md` 原样收录);入口 Analysis 已由 WEB-00 实测,Design/Preview 解释前整体仍 `UNVERIFIED` |
| [tests/README.md](tests/README.md) | 领域/跨组件验收的目录、证据与当前状态 |
| [docs/evidence/WEB-00-analysis-probe.md](docs/evidence/WEB-00-analysis-probe.md) | WEB-00:真实 CLI Analysis 3 对合同依赖的探测证据(入口/链接/目标/负例,PASS) |
| [components.toml](components.toml) | 直接子组件的治理记录(均为 planned,无 entry) |
| [components.toml](components.toml) | 直接子组件的治理记录(Design/Preview active 并登记 entry,web-components planned) |
## 领域边界
@@ -29,11 +29,11 @@ Marqdo **Web 领域聚合仓库**(状态:`planned`)。本仓固定 Web 作
| ID | 目录 | kind | state | 职责 | requires | release |
| --- | --- | --- | --- | --- | --- | --- |
| `web-design` | `design/` | extension | planned | 设计文档解释、校验、组件图及交付 | `cli` | optional |
| `web-preview` | `preview/` | tool | planned | 通用原型渲染及 `web` 命令发行 | `cli`, `web-design` | optional |
| `web-design` | `design/` | extension | active | 设计文档解释、校验、组件图及交付 | `cli` | optional |
| `web-preview` | `preview/` | tool | active | 通用原型渲染及 `web` 命令发行 | `cli`, `web-design` | optional |
| `web-components` | `components/` | extension | planned | 可组合的设计文档与原型组件模板 | `web-design` | optional |
- `planned` gitlink 固定已发布的开发提交。实现和验收通过后才登记实际 `entry` 并计入完成率。
- Design/Preview 已 active 并登记真实 `entry`;`planned` 子组件只固定开发提交,不计完成率,激活时补齐入口/测试/证据。
- 依赖为计划依赖;真实激活前须以实际 imports/构建输入/制品核实。
- Design 和 Preview 在各自的独立仓库开发。 [marqdo-web-design](https://git.cflmy.cn/cflmy/marqdo-web-design) · [marqdo-web-preview](https://git.cflmy.cn/cflmy/marqdo-web-preview)
- 本仓库不提供运行时入口,也不需要另一份 `tool.json`;唯一工具入口属于 Preview 的 `web` 命令。
@@ -69,3 +69,17 @@ marqdo-ext-web/
- 根仓库:[架构](https://git.cflmy.cn/cflmy/marqdo/src/branch/main/docs/ARCHITECTURE.md) · [开发流程](https://git.cflmy.cn/cflmy/marqdo/src/branch/main/docs/DEVELOPMENT.md) · [迁移台账](https://git.cflmy.cn/cflmy/marqdo/src/branch/main/docs/MIGRATION.md) · [各仓库任务](https://git.cflmy.cn/cflmy/marqdo/src/branch/main/docs/REPOSITORY-TASKS.md)
- 协作约定见 [AGENTS.md](AGENTS.md)。
## WEB-04 组合案例与生产交付试验
| 路径 | 内容 |
| --- | --- |
| `examples/doc-site/` | 文档型网站设计案例 |
| `examples/research-workspace/` | §8 科研任务台原型(Design/Preview 通用能力) |
| `examples/quantum-editor/` | 量子电路编辑器设计案例(有限场景/交互) |
| `examples/research-workbench-app/` | 科研任务台真实生产实现试验(Express + 持久化 + API/浏览器 E2E) |
| `scripts/domain-acceptance.sh` | 领域验收:三案例 check/preview/handoff + 生产应用测试,显式 CLI/Tool 输入 |
| `docs/WEB-04-delivery.md` | 设计源到生产实现的映射、有意未实现项与任务拆分 |
| `docs/evidence/WEB-04-domain-delivery.md` | WEB-04 三案例 + 生产 API/浏览器 E2E 实测证据 |
生产应用不是 `web` Tool 的运行依赖;原型 PASS 不冒充生产 PASS。
+6 -3
View File
@@ -1,29 +1,32 @@
# 本仓只登记直接子组件(规范 §4.1)。Gitlink 是提交身份唯一权威,
# .gitmodules 是权威远端唯一记录;此处不重复 SHA、远端和语言包锁。
# 当前三条均为 planned。Design 和 Preview 固定已发布的开发提交,激活后计入完成率。
# WEB-05:Design/Preview 通过组件验收并固定已合并提交,激活为 active 并登记真实入口;
# web-components 仍为 planned(无独立实现,不伪造入口)。
# 激活时同时更新 state/entry 并锁定已推送的精确 SHA(见 docs/DEVELOPMENT.md §3)。
[[component]]
id = "web-design"
path = "design"
kind = "extension"
state = "planned"
state = "active"
owner = "cflmy"
scope = "设计文档解释、校验、组件图及交付"
requires = ["cli"]
checks_with = []
release = "optional"
entry = "scripts/ci.sh"
[[component]]
id = "web-preview"
path = "preview"
kind = "tool"
state = "planned"
state = "active"
owner = "cflmy"
scope = "通用原型渲染及 web 命令发行"
requires = ["cli", "web-design"]
checks_with = []
release = "optional"
entry = "scripts/ci.sh"
[[component]]
id = "web-components"
+1 -1
Submodule design updated: 39c99e59d2...703ee7af24.
+54
View File
@@ -0,0 +1,54 @@
# WEB-04 领域组合案例与生产交付试验
日期:2026-11-27。责任仓:`marqdo-ext-web`(领域组合与验收);工单:[marqdo-ext-web#2](https://git.cflmy.cn/cflmy/marqdo-ext-web/issues/2);父工单:[marqdo#6](https://git.cflmy.cn/cflmy/marqdo/issues/6)。
本文件描述 WEB-04 的三个组合案例、一个真实生产交付试验及其设计源映射。生产实现是独立应用,不是 `web` Tool 的运行依赖;原型 PASS 不等于生产 PASS。
## 三个组合案例(同一通用 renderer/Tool)
| 案例 | 设计根 | 设计单元 | 验证 |
| --- | --- | --- | --- |
| 文档型网站 | `examples/doc-site/` | `首页` | `marqdo web check/preview/handoff` |
| §8 科研任务台(原型) | `examples/research-workspace/` | `工作台` | 同上 |
| 量子电路编辑器设计 | `examples/quantum-editor/` | `编辑器` | 同上(含有限场景/交互) |
三例均由同一 `marqdo web` Tool(Design + Preview 固定 revision)驱动,没有按案例分叉的 renderer、HTML 注入或 CLI 语法。
## 生产交付试验:科研任务台
- 位置:`examples/research-workbench-app/`(Express 应用 + 真实 JSON 持久化 + 静态前端)。
- 设计源映射:
| 设计源 | 生产实现 |
| --- | --- |
| `examples/research-workspace/index.mq.md#工作台` | 页面布局与统计/任务/工作区三块 |
| `components/statistics.mq.md#统计` | `/api/stats` 与顶部统计条 |
| `components/tasks.mq.md#任务` | `/api/tasks`(列表/搜索/创建/状态流转)与任务列表 UI |
| `components/workspace.mq.md#科研工作区` | 工作区容器与错误提示区域 |
| `components/navigation.mq.md#导航` | 顶栏导航(占位,首版无多页面路由) |
- 真实能力:创建任务(校验标题/优先级)、按标题搜索、状态 open→doing→done、统计随数据联动、真实文件持久化、HTTP 错误 JSON 与 UI 错误提示。
- 有意未实现(明确记录,不冒充):认证/多用户、真实数据库、网络同步、导入导出、任务编辑/删除、真实实验设备接入。后续按 `docs/WEB-DESIGN.md` 边界在目标应用仓实现。
- 漂移追踪:重新生成 `marqdo web handoff examples/research-workspace/index.mq.md --unit 工作台`,比较 `design id` 与源摘要;本文件记录的设计源路径即映射锚点,源变更需按任务拆分更新本应用并记录差异。
- 任务拆分建议:认证与账户、数据库与迁移、任务编辑与删除、统计导出、多页面路由;各自独立应用工单,不改 Web Tool 运行时。
- 测试映射:
- 原型:`marqdo web preview` 的离线 HTML/场景(W31–W34 组合案例证据)。
- 生产 API:`npm test`(真实 HTTP + 临时文件持久化 + 错误/统计断言)。
- 生产 E2E:`npx playwright test`(真实浏览器:统计、搜索、创建校验联动)。
## 验证入口
```sh
MARQDO_BIN=<verified marqdo> \
MARQDO_WEB_TOOL_JSON=<built marqdo-web-preview tool.json> \
MARQDO_NPM_CACHE=<optional npm cache dir> \
scripts/domain-acceptance.sh
```
脚本以同一 Tool 跑三个案例的 check/preview/handoff,再安装并测试生产应用(API + 浏览器 E2E),最后卸载 Tool;任何原型测试都不会代替生产 E2E。
## 证据与未验证
- 本文件与领域 CI 脚本构成 WEB-04 候选;实际命令输出/退出码记录在父工单与根候选评论。
- 浏览器 E2E 需要可用的 Chromium;无浏览器环境必须标 UNVERIFIED,不得用静态断言冒充。
- 领域 gitlink 固定 Design/Preview 候选与根接入属于 WEB-04/WEB-05 同候选工作;根 `--checkouts` 与冷安装证据在 WEB-05 完成。
+40
View File
@@ -0,0 +1,40 @@
# WEB-04 领域组合案例与生产交付试验证据
日期:2026-11-27。责任仓:`marqdo-ext-web`;工单:[marqdo-ext-web#2](https://git.cflmy.cn/cflmy/marqdo-ext-web/issues/2)(WEB-04);父工单:根 [marqdo#6](https://git.cflmy.cn/cflmy/marqdo/issues/6)。
## 输入身份
| 对象 | 身份 |
| --- | --- |
| CLI | 由根固定 `cli/deadf6e` 构建的 `marqdo 3.0.0-rc.4`,`sha256:6ede3b9e8bcfad3942573e68b5f54b2c5bc2866b37d102f63acd49a55cb212db` |
| Design | `marqdo-web-design@1b6607fd3cc09801b4f6eacd2fba547caa0ec637`(WEB-03 handoff/图/切片) |
| Preview / web Tool | `marqdo-web-preview@eff273f7f2f3919bab62eacded781c61d5f03f91`(WEB-02 + WEB-03 消费) |
| 平台 | Linux x86_64,Node v24.22.3,Chromium(Playwright headless shell 1255) |
## 执行与结果(本地真实运行)
```sh
MARQDO_BIN=<verified marqdo> \
MARQDO_WEB_TOOL_JSON=<marqdo-web-preview/dist/marqdo-web-preview/tool.json> \
scripts/domain-acceptance.sh
```
结果 **PASS**:
- 同一 `marqdo web` Tool 对三个案例执行 `check/preview/handoff`:
- 文档型网站 `examples/doc-site`(单元 `首页`):PASS;
- §8 科研任务台原型 `examples/research-workspace`(单元 `工作台`):PASS;
- 量子电路编辑器设计 `examples/quantum-editor`(单元 `编辑器`):PASS(含有限场景/交互)。
- 每个 preview 均含 CSP、通用组件/场景标记;handoff 均非空并含 Design handoff;无按案例分叉的 renderer 或 CLI 语法。
- 生产交付试验 `examples/research-workbench-app`(Express):
- API 测试(真实 HTTP、真实临时文件持久化、错误/统计联动):`node --test` PASS;
- 真实浏览器 E2E(Playwright/Chromium):统计、搜索、创建、错误提示联动 PASS。
- Tool 生命周期:真实 CLI `tool install` → 三案例 + 生产应用 → `tool remove web`;CLI 二进制未改变(脚本断言)。
- 设计源→生产映射、有意未实现项与任务拆分记录在 `docs/WEB-04-delivery.md`。
## 边界与未验证
- 生产应用不依赖 `web` Tool 运行;原型 PASS 不冒充生产 PASS,二者证据分开。
- 认证、真实数据库、网络同步、任务编辑/删除、真实设备接入等有意未实现,已在交付文档标注。
- 浏览器 E2E 需要 Chromium;无浏览器环境须标 UNVERIFIED,本证据对应实际 Chromium 运行。
- 领域 gitlink 固定 Design/Preview 候选;根 gitlink、领域激活、`web` Tool 冷安装与根组合验收属 WEB-05,不在本证据内完成。
+29
View File
@@ -0,0 +1,29 @@
# WEB-05 Web 领域激活与根接入证据
日期:2026-11-27。责任仓:`marqdo-ext-web`(领域激活)+ 根 `marqdo`(gitlink/组合验收);工单:根 [marqdo#6](https://git.cflmy.cn/cflmy/marqdo/issues/6);上游 WEB-00..04 均已完成。
## 领域身份
| 对象 | 身份 |
| --- | --- |
| CLI | 根固定 `cli/deadf6e` 构建的 `marqdo 3.0.0-rc.4`,`sha256:6ede3b9e...` |
| Design(active) | `marqdo-web-design@1b6607fd3cc09801b4f6eacd2fba547caa0ec637`,入口 `scripts/ci.sh` |
| Preview(active) | `marqdo-web-preview@eff273f7f2f3919bab62eacded781c61d5f03f91`,入口 `scripts/ci.sh` |
| web-components | 保持 `planned`(无独立实现/入口,不伪造) |
| 领域入口 | `scripts/domain-acceptance.sh`(三案例 + 生产应用 API/浏览器 E2E) |
| 平台 | Linux x86_64;Node 24;Chromium headless shell |
## 已完成
- 领域 `components.toml`:Design/Preview 由 planned→active,登记真实 `entry`;web-components 保持 planned。
- 领域 `.gitmodules`/gitlink:固定已推送的 Design/Preview 合并提交;子组件 CI 入口真实存在。
- 领域验收入口 `scripts/domain-acceptance.sh`:显式 `MARQDO_BIN` + 已构建 web Tool,三案例 check/preview/handoff + 生产应用 API/浏览器 E2E;本地真实 PASS(见 WEB-04 证据)。
- WEB-00/01/02/03/04 证据已分别落在领域/组件仓。
## 根接入(由根候选完成)
- 根 catalog `web` 域 planned→active,登记 `entry = scripts/domain-acceptance.sh`;根 gitlink 固定本仓激活提交(一次切换,无旧路径)。
- `scripts/check-layout.py --checkouts` 递归校验领域与子组件固定提交、入口与工作树。
- 根集成候选:同一 CLI 构建/制品下运行领域入口、`web` Tool 冷安装(install → check/preview/handoff → remove,CLI 不变、无网络)与既有消费者门禁;同候选 SHA/制品摘要记录在根候选证据。
本文件是领域侧证据;根侧递归校验/冷安装/CI 结果记录在根 PR 与 #6 评论,不在此冒充。
@@ -0,0 +1,11 @@
# 正文组件
## @knowledge 正文
### 内容
文章正文支持标题、段落、列表、代码块与表格。
### 验收
- 代码块可横向滚动而不撑破页面。
+11
View File
@@ -0,0 +1,11 @@
# 顶栏组件
## @knowledge 顶栏
### 内容
站点名称、版本选择与搜索入口。
### 验收
- 窄屏只保留站点名称与搜索按钮。
@@ -0,0 +1,13 @@
# 目录组件
## @knowledge 目录
### 内容
- 快速开始
- 语言指南
- 参考手册
### 验收
- 当前文章在目录中高亮。
+13
View File
@@ -0,0 +1,13 @@
# 文档型网站
## @knowledge 首页
文档站主页面:顶部导航、左侧目录、右侧正文。
### 组件
| 行 | 槽 | 组件 | 宽度 |
| --- | --- | --- | --- |
| 1 | header | [顶栏](components/header.mq.md#顶栏) | auto |
| 2 | sidebar | [目录](components/sidebar.mq.md#目录) | 240px |
| 2 | article | [正文](components/article.mq.md#正文) | 1fr |
@@ -0,0 +1,21 @@
# 电路画布组件
## @knowledge 电路画布
### 场景
| 状态 | 内容 | 初始 |
| --- | --- | --- |
| empty | [空电路](../shared/states.mq.md#空电路) | true |
| selected | [已选门](../shared/states.mq.md#已选门) | false |
### 交互
| 当前 | 事件 | 下一状态 |
| --- | --- | --- |
| empty | 模拟放置 H 门 | selected |
| selected | 模拟清空 | empty |
### 验收
- 空电路提示放置第一个门;选择门时右侧检查器同步。
@@ -0,0 +1,11 @@
# 检查器组件
## @knowledge 检查器
### 内容
显示所选门的参数、目标比特与错误提示占位。
### 验收
- 无选择时显示空状态,不伪造成已保存。
@@ -0,0 +1,11 @@
# 门面板组件
## @knowledge 门面板
### 内容
按类别列出单比特门、双比特门与测量操作。
### 验收
- 点击门不会立即加入电路,需拖拽或选择目标比特。
+13
View File
@@ -0,0 +1,13 @@
# 量子电路编辑器设计
## @knowledge 编辑器
电路编辑器的三段式布局:门面板、电路画布、属性检查器。
### 组件
| 行 | 槽 | 组件 | 宽度 |
| --- | --- | --- | --- |
| 1 | palette | [门面板](components/palette.mq.md#门面板) | 220px |
| 1 | canvas | [电路画布](components/canvas.mq.md#电路画布) | 6fr |
| 1 | inspector | [检查器](components/inspector.mq.md#检查器) | 2fr |
@@ -0,0 +1,9 @@
# 状态
## @knowledge 空电路
画布为空,提示放置门。
## @knowledge 已选门
已选择一个 H 门,参数等待填写。
@@ -0,0 +1,4 @@
node_modules/
workbench-data.json
test-results/
playwright-report/
@@ -0,0 +1,44 @@
// Production E2E for the research workbench (run where a browser is available).
import { test, expect } from "@playwright/test";
test("list, search, create and statistics stay linked", async ({ page }) => {
await page.route("**/api/**", async (route) => {
const url = new URL(route.request().url());
if (url.pathname === "/api/tasks" && route.request().method() === "GET") {
const query = url.searchParams.get("q") ?? "";
const tasks = [
{ id: 1, title: "测量超导比特", priority: "high", status: "open" },
{ id: 2, title: "整理实验记录", priority: "normal", status: "done" },
].filter((task) => task.title.includes(query));
return route.fulfill({ json: { tasks } });
}
if (url.pathname === "/api/stats") {
return route.fulfill({ json: { total: 2, byStatus: { open: 1, doing: 0, done: 1 }, byPriority: { low: 0, normal: 1, high: 1 } } });
}
if (url.pathname === "/api/tasks" && route.request().method() === "POST") {
const body = route.request().postDataJSON();
if (!String(body.title ?? "").trim()) {
return route.fulfill({ status: 400, json: { error: { code: "task.title_required", message: "任务标题不能为空" } } });
}
return route.fulfill({ status: 201, json: { task: { id: 3, title: body.title, priority: "normal", status: "open" } } });
}
return route.continue();
});
await page.goto("/");
await expect(page.getByTestId("stats")).toContainText("总数 2");
await expect(page.getByTestId("tasks")).toContainText("测量超导比特");
await page.getByLabel("搜索任务").fill("实验");
await expect(page.getByTestId("tasks")).toContainText("整理实验记录");
await expect(page.getByTestId("tasks")).not.toContainText("测量超导比特");
await page.getByLabel("搜索任务").fill("");
await page.getByLabel("标题").fill("新建任务");
await page.getByRole("button", { name: "创建" }).click();
await expect(page.getByTestId("error")).toBeHidden();
await page.getByLabel("标题").fill(" ");
await page.getByRole("button", { name: "创建" }).click();
await expect(page.getByTestId("error")).toContainText("任务标题不能为空");
});
+906
View File
@@ -0,0 +1,906 @@
{
"name": "research-workbench-app",
"version": "0.1.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "research-workbench-app",
"version": "0.1.0",
"dependencies": {
"express": "^4.21.2"
},
"devDependencies": {
"@playwright/test": "1.49.0"
}
},
"node_modules/@playwright/test": {
"version": "1.49.0",
"resolved": "https://registry.npmjs.org/@playwright/test/-/test-1.49.0.tgz",
"integrity": "sha512-DMulbwQURa8rNIQrf94+jPJQ4FmOVdpE5ZppRNvWVjvhC+6sOeo28r8MgIpQRYouXRtt/FCCXU7zn20jnHR4Qw==",
"dev": true,
"license": "Apache-2.0",
"dependencies": {
"playwright": "1.49.0"
},
"bin": {
"playwright": "cli.js"
},
"engines": {
"node": ">=18"
}
},
"node_modules/accepts": {
"version": "1.3.8",
"resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.8.tgz",
"integrity": "sha512-PYAthTa2m2VKxuvSD3DPC/Gy+U+sOA1LAuT8mkmRuvw+NACSaeXEQ+NHcVF7rONl6qcaxV3Uuemwawk+7+SJLw==",
"license": "MIT",
"dependencies": {
"mime-types": "~2.1.34",
"negotiator": "0.6.3"
},
"engines": {
"node": ">= 0.6"
}
},
"node_modules/array-flatten": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz",
"integrity": "sha512-PCVAQswWemu6UdxsDFFX/+gVeYqKAod3D3UVm91jHwynguOwAvYPhx8nNlM++NqRcK6CxxpUafjmhIdKiHibqg==",
"license": "MIT"
},
"node_modules/body-parser": {
"version": "1.20.9",
"resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.20.9.tgz",
"integrity": "sha512-FISIQxV5u91Y9gvuFq3q/tA/qTqLJn3AhRcEvyozyhJTh5OBFFtv827AdHU7Rbyct4r+Ba1/99oFa1Y3yuFsdw==",
"license": "MIT",
"dependencies": {
"bytes": "~3.1.2",
"content-type": "~1.0.5",
"debug": "2.6.9",
"depd": "2.0.0",
"destroy": "~1.2.0",
"http-errors": "~2.0.1",
"iconv-lite": "~0.4.24",
"on-finished": "~2.4.1",
"qs": "~6.16.0",
"raw-body": "~2.5.3",
"type-is": "~1.6.18",
"unpipe": "~1.0.0"
},
"engines": {
"node": ">= 0.8",
"npm": "1.2.8000 || >= 1.4.16"
}
},
"node_modules/bytes": {
"version": "3.1.2",
"resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.2.tgz",
"integrity": "sha512-/Nf7TyzTx6S3yRJObOAV7956r8cr2+Oj8AC5dt8wSP3BQAoeX58NoHyCU8P8zGkNXStjTSi6fzO6F0pBdcYbEg==",
"license": "MIT",
"engines": {
"node": ">= 0.8"
}
},
"node_modules/call-bind-apply-helpers": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/call-bind-apply-helpers/-/call-bind-apply-helpers-1.0.2.tgz",
"integrity": "sha512-Sp1ablJ0ivDkSzjcaJdxEunN5/XvksFJ2sMBFfq6x0ryhQV/2b/KwFe21cMpmHtPOSij8K99/wSfoEuTObmuMQ==",
"license": "MIT",
"dependencies": {
"es-errors": "^1.3.0",
"function-bind": "^1.1.2"
},
"engines": {
"node": ">= 0.4"
}
},
"node_modules/call-bound": {
"version": "1.0.4",
"resolved": "https://registry.npmjs.org/call-bound/-/call-bound-1.0.4.tgz",
"integrity": "sha512-+ys997U96po4Kx/ABpBCqhA9EuxJaQWDQg7295H4hBphv3IZg0boBKuwYpt4YXp6MZ5AmZQnU/tyMTlRpaSejg==",
"license": "MIT",
"dependencies": {
"call-bind-apply-helpers": "^1.0.2",
"get-intrinsic": "^1.3.0"
},
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/content-disposition": {
"version": "0.5.4",
"resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.4.tgz",
"integrity": "sha512-FveZTNuGw04cxlAiWbzi6zTAL/lhehaWbTtgluJh4/E95DqMwTmha3KZN1aAWA8cFIhHzMZUvLevkw5Rqk+tSQ==",
"license": "MIT",
"dependencies": {
"safe-buffer": "5.2.1"
},
"engines": {
"node": ">= 0.6"
}
},
"node_modules/content-type": {
"version": "1.0.5",
"resolved": "https://registry.npmjs.org/content-type/-/content-type-1.0.5.tgz",
"integrity": "sha512-nTjqfcBFEipKdXCv4YDQWCfmcLZKm81ldF0pAopTvyrFGVbcR6P/VAAd5G7N+0tTr8QqiU0tFadD6FK4NtJwOA==",
"license": "MIT",
"engines": {
"node": ">= 0.6"
}
},
"node_modules/cookie": {
"version": "0.7.2",
"resolved": "https://registry.npmjs.org/cookie/-/cookie-0.7.2.tgz",
"integrity": "sha512-yki5XnKuf750l50uGTllt6kKILY4nQ1eNIQatoXEByZ5dWgnKqbnqmTrBE5B4N7lrMJKQ2ytWMiTO2o0v6Ew/w==",
"license": "MIT",
"engines": {
"node": ">= 0.6"
}
},
"node_modules/cookie-signature": {
"version": "1.0.7",
"resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.0.7.tgz",
"integrity": "sha512-NXdYc3dLr47pBkpUCHtKSwIOQXLVn8dZEuywboCOJY/osA0wFSLlSawr3KN8qXJEyX66FcONTH8EIlVuK0yyFA==",
"license": "MIT"
},
"node_modules/debug": {
"version": "2.6.9",
"resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz",
"integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==",
"license": "MIT",
"dependencies": {
"ms": "2.0.0"
}
},
"node_modules/depd": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/depd/-/depd-2.0.0.tgz",
"integrity": "sha512-g7nH6P6dyDioJogAAGprGpCtVImJhpPk/roCzdb3fIh61/s/nPsfR6onyMwkCAR/OlC3yBC0lESvUoQEAssIrw==",
"license": "MIT",
"engines": {
"node": ">= 0.8"
}
},
"node_modules/destroy": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/destroy/-/destroy-1.2.0.tgz",
"integrity": "sha512-2sJGJTaXIIaR1w4iJSNoN0hnMY7Gpc/n8D4qSCJw8QqFWXf7cuAgnEHxBpweaVcPevC2l3KpjYCx3NypQQgaJg==",
"license": "MIT",
"engines": {
"node": ">= 0.8",
"npm": "1.2.8000 || >= 1.4.16"
}
},
"node_modules/dunder-proto": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/dunder-proto/-/dunder-proto-1.0.1.tgz",
"integrity": "sha512-KIN/nDJBQRcXw0MLVhZE9iQHmG68qAVIBg9CqmUYjmQIhgij9U5MFvrqkUL5FbtyyzZuOeOt0zdeRe4UY7ct+A==",
"license": "MIT",
"dependencies": {
"call-bind-apply-helpers": "^1.0.1",
"es-errors": "^1.3.0",
"gopd": "^1.2.0"
},
"engines": {
"node": ">= 0.4"
}
},
"node_modules/ee-first": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz",
"integrity": "sha512-WMwm9LhRUo+WUaRN+vRuETqG89IgZphVSNkdFgeb6sS/E4OrDIN7t48CAewSHXc6C8lefD8KKfr5vY61brQlow==",
"license": "MIT"
},
"node_modules/encodeurl": {
"version": "2.0.3",
"resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-2.0.3.tgz",
"integrity": "sha512-mIteYONiEfc4xWf2F1WXovh1c8npzS00vNeiUPdwFF+QlVJni+gNvpQltLMQhob8rew/bWWc/bGTuUr0EUGt0w==",
"license": "MIT",
"engines": {
"node": ">= 0.8"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/express"
}
},
"node_modules/es-define-property": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/es-define-property/-/es-define-property-1.0.1.tgz",
"integrity": "sha512-e3nRfgfUZ4rNGL232gUgX06QNyyez04KdjFrF+LTRoOXmrOgFKDg4BCdsjW8EnT69eqdYGmRpJwiPVYNrCaW3g==",
"license": "MIT",
"engines": {
"node": ">= 0.4"
}
},
"node_modules/es-errors": {
"version": "1.3.0",
"resolved": "https://registry.npmjs.org/es-errors/-/es-errors-1.3.0.tgz",
"integrity": "sha512-Zf5H2Kxt2xjTvbJvP2ZWLEICxA6j+hAmMzIlypy4xcBg1vKVnx89Wy0GbS+kf5cwCVFFzdCFh2XSCFNULS6csw==",
"license": "MIT",
"engines": {
"node": ">= 0.4"
}
},
"node_modules/es-object-atoms": {
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/es-object-atoms/-/es-object-atoms-1.1.2.tgz",
"integrity": "sha512-HWcBoN6NileqtSydK2FqHbS/LoDd2pqrnQHLyJzBj4kOp/ky2MWMN694xOfkK8/SnUsW2DH7EfyVlydKCsm1Zw==",
"license": "MIT",
"dependencies": {
"es-errors": "^1.3.0"
},
"engines": {
"node": ">= 0.4"
}
},
"node_modules/escape-html": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz",
"integrity": "sha512-NiSupZ4OeuGwr68lGIeym/ksIZMJodUGOSCZ/FSnTxcrekbvqrgdUxlJOMpijaKZVjAJrWrGs/6Jy8OMuyj9ow==",
"license": "MIT"
},
"node_modules/etag": {
"version": "1.8.1",
"resolved": "https://registry.npmjs.org/etag/-/etag-1.8.1.tgz",
"integrity": "sha512-aIL5Fx7mawVa300al2BnEE4iNvo1qETxLrPI/o05L7z6go7fCw1J6EQmbK4FmJ2AS7kgVF/KEZWufBfdClMcPg==",
"license": "MIT",
"engines": {
"node": ">= 0.6"
}
},
"node_modules/express": {
"version": "4.22.3",
"resolved": "https://registry.npmjs.org/express/-/express-4.22.3.tgz",
"integrity": "sha512-Bdcs4+3qlpVlx2NRn6fgX2Ue2/gGRaPeawebgclM0ERSCqDpA+owF1fdPwjJUTAJWMTuAaxjDf+hzb0/4eKvvw==",
"license": "MIT",
"dependencies": {
"accepts": "~1.3.8",
"array-flatten": "1.1.1",
"body-parser": "~1.20.5",
"content-disposition": "~0.5.4",
"content-type": "~1.0.4",
"cookie": "~0.7.1",
"cookie-signature": "~1.0.6",
"debug": "2.6.9",
"depd": "2.0.0",
"encodeurl": "~2.0.0",
"escape-html": "~1.0.3",
"etag": "~1.8.1",
"finalhandler": "~1.3.1",
"fresh": "~0.5.2",
"http-errors": "~2.0.0",
"merge-descriptors": "1.0.3",
"methods": "~1.1.2",
"on-finished": "~2.4.1",
"parseurl": "~1.3.3",
"path-to-regexp": "~0.1.13",
"proxy-addr": "~2.0.7",
"qs": "~6.16.0",
"range-parser": "~1.2.1",
"safe-buffer": "5.2.1",
"send": "~0.19.0",
"serve-static": "~1.16.2",
"setprototypeof": "1.2.0",
"statuses": "~2.0.1",
"type-is": "~1.6.18",
"utils-merge": "1.0.1",
"vary": "~1.1.2"
},
"engines": {
"node": ">= 0.10.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/express"
}
},
"node_modules/finalhandler": {
"version": "1.3.2",
"resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-1.3.2.tgz",
"integrity": "sha512-aA4RyPcd3badbdABGDuTXCMTtOneUCAYH/gxoYRTZlIJdF0YPWuGqiAsIrhNnnqdXGswYk6dGujem4w80UJFhg==",
"license": "MIT",
"dependencies": {
"debug": "2.6.9",
"encodeurl": "~2.0.0",
"escape-html": "~1.0.3",
"on-finished": "~2.4.1",
"parseurl": "~1.3.3",
"statuses": "~2.0.2",
"unpipe": "~1.0.0"
},
"engines": {
"node": ">= 0.8"
}
},
"node_modules/forwarded": {
"version": "0.2.0",
"resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.2.0.tgz",
"integrity": "sha512-buRG0fpBtRHSTCOASe6hD258tEubFoRLb4ZNA6NxMVHNw2gOcwHo9wyablzMzOA5z9xA9L1KNjk/Nt6MT9aYow==",
"license": "MIT",
"engines": {
"node": ">= 0.6"
}
},
"node_modules/fresh": {
"version": "0.5.2",
"resolved": "https://registry.npmjs.org/fresh/-/fresh-0.5.2.tgz",
"integrity": "sha512-zJ2mQYM18rEFOudeV4GShTGIQ7RbzA7ozbU9I/XBpm7kqgMywgmylMwXHxZJmkVoYkna9d2pVXVXPdYTP9ej8Q==",
"license": "MIT",
"engines": {
"node": ">= 0.6"
}
},
"node_modules/fsevents": {
"version": "2.3.2",
"resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz",
"integrity": "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==",
"dev": true,
"hasInstallScript": true,
"license": "MIT",
"optional": true,
"os": [
"darwin"
],
"engines": {
"node": "^8.16.0 || ^10.6.0 || >=11.0.0"
}
},
"node_modules/function-bind": {
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz",
"integrity": "sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA==",
"license": "MIT",
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/get-intrinsic": {
"version": "1.3.0",
"resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.3.0.tgz",
"integrity": "sha512-9fSjSaos/fRIVIp+xSJlE6lfwhES7LNtKaCBIamHsjr2na1BiABJPo0mOjjz8GJDURarmCPGqaiVg5mfjb98CQ==",
"license": "MIT",
"dependencies": {
"call-bind-apply-helpers": "^1.0.2",
"es-define-property": "^1.0.1",
"es-errors": "^1.3.0",
"es-object-atoms": "^1.1.1",
"function-bind": "^1.1.2",
"get-proto": "^1.0.1",
"gopd": "^1.2.0",
"has-symbols": "^1.1.0",
"hasown": "^2.0.2",
"math-intrinsics": "^1.1.0"
},
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/get-proto": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/get-proto/-/get-proto-1.0.1.tgz",
"integrity": "sha512-sTSfBjoXBp89JvIKIefqw7U2CCebsc74kiY6awiGogKtoSGbgjYE/G/+l9sF3MWFPNc9IcoOC4ODfKHfxFmp0g==",
"license": "MIT",
"dependencies": {
"dunder-proto": "^1.0.1",
"es-object-atoms": "^1.0.0"
},
"engines": {
"node": ">= 0.4"
}
},
"node_modules/gopd": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/gopd/-/gopd-1.2.0.tgz",
"integrity": "sha512-ZUKRh6/kUFoAiTAtTYPZJ3hw9wNxx+BIBOijnlG9PnrJsCcSjs1wyyD6vJpaYtgnzDrKYRSqf3OO6Rfa93xsRg==",
"license": "MIT",
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/has-symbols": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.1.0.tgz",
"integrity": "sha512-1cDNdwJ2Jaohmb3sg4OmKaMBwuC48sYni5HUw2DvsC8LjGTLK9h+eb1X6RyuOHe4hT0ULCW68iomhjUoKUqlPQ==",
"license": "MIT",
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/hasown": {
"version": "2.0.4",
"resolved": "https://registry.npmjs.org/hasown/-/hasown-2.0.4.tgz",
"integrity": "sha512-T2UbfbBEF32wiepXIsMlTW9+dDYC6wMh/t/vYA4tuOMKqWz/n3vr1NFSxQiyP+zk2mXsoMA/i/7qV6LKut1t1A==",
"license": "MIT",
"dependencies": {
"function-bind": "^1.1.2"
},
"engines": {
"node": ">= 0.4"
}
},
"node_modules/http-errors": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/http-errors/-/http-errors-2.0.1.tgz",
"integrity": "sha512-4FbRdAX+bSdmo4AUFuS0WNiPz8NgFt+r8ThgNWmlrjQjt1Q7ZR9+zTlce2859x4KSXrwIsaeTqDoKQmtP8pLmQ==",
"license": "MIT",
"dependencies": {
"depd": "~2.0.0",
"inherits": "~2.0.4",
"setprototypeof": "~1.2.0",
"statuses": "~2.0.2",
"toidentifier": "~1.0.1"
},
"engines": {
"node": ">= 0.8"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/express"
}
},
"node_modules/iconv-lite": {
"version": "0.4.24",
"resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz",
"integrity": "sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==",
"license": "MIT",
"dependencies": {
"safer-buffer": ">= 2.1.2 < 3"
},
"engines": {
"node": ">=0.10.0"
}
},
"node_modules/inherits": {
"version": "2.0.4",
"resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz",
"integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==",
"license": "ISC"
},
"node_modules/ipaddr.js": {
"version": "1.9.1",
"resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.9.1.tgz",
"integrity": "sha512-0KI/607xoxSToH7GjN1FfSbLoU0+btTicjsQSWQlh/hZykN8KpmMf7uYwPW3R+akZ6R/w18ZlXSHBYXiYUPO3g==",
"license": "MIT",
"engines": {
"node": ">= 0.10"
}
},
"node_modules/math-intrinsics": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/math-intrinsics/-/math-intrinsics-1.1.0.tgz",
"integrity": "sha512-/IXtbwEk5HTPyEwyKX6hGkYXxM9nbj64B+ilVJnC/R6B0pH5G4V3b0pVbL7DBj4tkhBAppbQUlf6F6Xl9LHu1g==",
"license": "MIT",
"engines": {
"node": ">= 0.4"
}
},
"node_modules/media-typer": {
"version": "0.3.0",
"resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz",
"integrity": "sha512-dq+qelQ9akHpcOl/gUVRTxVIOkAJ1wR3QAvb4RsVjS8oVoFjDGTc679wJYmUmknUF5HwMLOgb5O+a3KxfWapPQ==",
"license": "MIT",
"engines": {
"node": ">= 0.6"
}
},
"node_modules/merge-descriptors": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/merge-descriptors/-/merge-descriptors-1.0.3.tgz",
"integrity": "sha512-gaNvAS7TZ897/rVaZ0nMtAyxNyi/pdbjbAwUpFQpN70GqnVfOiXpeUUMKRBmzXaSQ8DdTX4/0ms62r2K+hE6mQ==",
"license": "MIT",
"funding": {
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/methods": {
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/methods/-/methods-1.1.2.tgz",
"integrity": "sha512-iclAHeNqNm68zFtnZ0e+1L2yUIdvzNoauKU4WBA3VvH/vPFieF7qfRlwUZU+DA9P9bPXIS90ulxoUoCH23sV2w==",
"license": "MIT",
"engines": {
"node": ">= 0.6"
}
},
"node_modules/mime": {
"version": "1.6.0",
"resolved": "https://registry.npmjs.org/mime/-/mime-1.6.0.tgz",
"integrity": "sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg==",
"license": "MIT",
"bin": {
"mime": "cli.js"
},
"engines": {
"node": ">=4"
}
},
"node_modules/mime-db": {
"version": "1.52.0",
"resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz",
"integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==",
"license": "MIT",
"engines": {
"node": ">= 0.6"
}
},
"node_modules/mime-types": {
"version": "2.1.35",
"resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz",
"integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==",
"license": "MIT",
"dependencies": {
"mime-db": "1.52.0"
},
"engines": {
"node": ">= 0.6"
}
},
"node_modules/ms": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz",
"integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==",
"license": "MIT"
},
"node_modules/negotiator": {
"version": "0.6.3",
"resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.3.tgz",
"integrity": "sha512-+EUsqGPLsM+j/zdChZjsnX51g4XrHFOIXwfnCVPGlQk/k5giakcKsuxCObBRu6DSm9opw/O6slWbJdghQM4bBg==",
"license": "MIT",
"engines": {
"node": ">= 0.6"
}
},
"node_modules/object-inspect": {
"version": "1.14.0",
"resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.14.0.tgz",
"integrity": "sha512-IVgHNlp/jwQX271+Xzoq9LZNTWXxZK+cEOrGBOBxXNbn7fapnZ+Ts6TVMgNOuAezwG2wdtnMX97tTPK6VEnuOQ==",
"license": "MIT",
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/on-finished": {
"version": "2.4.2",
"resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.4.2.tgz",
"integrity": "sha512-ATWUv387i+nLD49EiDoOft5scf32Vsdz3ktrQJG9bi7jRFmaXTssvyvj1EmeKVVgvesbqUtvQQvaS2TpTukAZQ==",
"license": "MIT",
"dependencies": {
"ee-first": "1.1.1"
},
"engines": {
"node": ">= 0.8"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/express"
}
},
"node_modules/parseurl": {
"version": "1.3.3",
"resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.3.tgz",
"integrity": "sha512-CiyeOxFT/JZyN5m0z9PfXw4SCBJ6Sygz1Dpl0wqjlhDEGGBP1GnsUVEL0p63hoG1fcj3fHynXi9NYO4nWOL+qQ==",
"license": "MIT",
"engines": {
"node": ">= 0.8"
}
},
"node_modules/path-to-regexp": {
"version": "0.1.13",
"resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.13.tgz",
"integrity": "sha512-A/AGNMFN3c8bOlvV9RreMdrv7jsmF9XIfDeCd87+I8RNg6s78BhJxMu69NEMHBSJFxKidViTEdruRwEk/WIKqA==",
"license": "MIT"
},
"node_modules/playwright": {
"version": "1.49.0",
"resolved": "https://registry.npmjs.org/playwright/-/playwright-1.49.0.tgz",
"integrity": "sha512-eKpmys0UFDnfNb3vfsf8Vx2LEOtflgRebl0Im2eQQnYMA4Aqd+Zw8bEOB+7ZKvN76901mRnqdsiOGKxzVTbi7A==",
"dev": true,
"license": "Apache-2.0",
"dependencies": {
"playwright-core": "1.49.0"
},
"bin": {
"playwright": "cli.js"
},
"engines": {
"node": ">=18"
},
"optionalDependencies": {
"fsevents": "2.3.2"
}
},
"node_modules/playwright-core": {
"version": "1.49.0",
"resolved": "https://registry.npmjs.org/playwright-core/-/playwright-core-1.49.0.tgz",
"integrity": "sha512-R+3KKTQF3npy5GTiKH/T+kdhoJfJojjHESR1YEWhYuEKRVfVaxH3+4+GvXE5xyCngCxhxnykk0Vlah9v8fs3jA==",
"dev": true,
"license": "Apache-2.0",
"bin": {
"playwright-core": "cli.js"
},
"engines": {
"node": ">=18"
}
},
"node_modules/proxy-addr": {
"version": "2.0.8",
"resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.8.tgz",
"integrity": "sha512-5nnx0yGyVUcY6t9RnWcARWtwT9F1D8O9rt08htPvnd49W1IgZtmLkhu9WfMzQj1cFxjHIO6connUNVW5k7AVyQ==",
"license": "MIT",
"dependencies": {
"forwarded": "0.2.0",
"ipaddr.js": "1.9.1"
},
"engines": {
"node": ">= 0.10"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/express"
}
},
"node_modules/qs": {
"version": "6.16.2",
"resolved": "https://registry.npmjs.org/qs/-/qs-6.16.2.tgz",
"integrity": "sha512-VYdnB5S7/0IeXzBacUtwNAaM6d7Y/PgYnNC7bJCI6meqA/OgnsQbZMtVW8Dt2D1PHgbHGtYmhSoEIgvt7xZ2ZA==",
"license": "BSD-3-Clause",
"dependencies": {
"es-define-property": "^1.0.1",
"side-channel": "^1.1.1"
},
"engines": {
"node": ">=0.6"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/range-parser": {
"version": "1.2.1",
"resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.1.tgz",
"integrity": "sha512-Hrgsx+orqoygnmhFbKaHE6c296J+HTAQXoxEF6gNupROmmGJRoyzfG3ccAveqCBrwr/2yxQ5BVd/GTl5agOwSg==",
"license": "MIT",
"engines": {
"node": ">= 0.6"
}
},
"node_modules/raw-body": {
"version": "2.5.3",
"resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.5.3.tgz",
"integrity": "sha512-s4VSOf6yN0rvbRZGxs8Om5CWj6seneMwK3oDb4lWDH0UPhWcxwOWw5+qk24bxq87szX1ydrwylIOp2uG1ojUpA==",
"license": "MIT",
"dependencies": {
"bytes": "~3.1.2",
"http-errors": "~2.0.1",
"iconv-lite": "~0.4.24",
"unpipe": "~1.0.0"
},
"engines": {
"node": ">= 0.8"
}
},
"node_modules/safe-buffer": {
"version": "5.2.1",
"resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz",
"integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==",
"funding": [
{
"type": "github",
"url": "https://github.com/sponsors/feross"
},
{
"type": "patreon",
"url": "https://www.patreon.com/feross"
},
{
"type": "consulting",
"url": "https://feross.org/support"
}
],
"license": "MIT"
},
"node_modules/safer-buffer": {
"version": "2.1.2",
"resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz",
"integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==",
"license": "MIT"
},
"node_modules/send": {
"version": "0.19.2",
"resolved": "https://registry.npmjs.org/send/-/send-0.19.2.tgz",
"integrity": "sha512-VMbMxbDeehAxpOtWJXlcUS5E8iXh6QmN+BkRX1GARS3wRaXEEgzCcB10gTQazO42tpNIya8xIyNx8fll1OFPrg==",
"license": "MIT",
"dependencies": {
"debug": "2.6.9",
"depd": "2.0.0",
"destroy": "1.2.0",
"encodeurl": "~2.0.0",
"escape-html": "~1.0.3",
"etag": "~1.8.1",
"fresh": "~0.5.2",
"http-errors": "~2.0.1",
"mime": "1.6.0",
"ms": "2.1.3",
"on-finished": "~2.4.1",
"range-parser": "~1.2.1",
"statuses": "~2.0.2"
},
"engines": {
"node": ">= 0.8.0"
}
},
"node_modules/send/node_modules/ms": {
"version": "2.1.3",
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz",
"integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==",
"license": "MIT"
},
"node_modules/serve-static": {
"version": "1.16.3",
"resolved": "https://registry.npmjs.org/serve-static/-/serve-static-1.16.3.tgz",
"integrity": "sha512-x0RTqQel6g5SY7Lg6ZreMmsOzncHFU7nhnRWkKgWuMTu5NN0DR5oruckMqRvacAN9d5w6ARnRBXl9xhDCgfMeA==",
"license": "MIT",
"dependencies": {
"encodeurl": "~2.0.0",
"escape-html": "~1.0.3",
"parseurl": "~1.3.3",
"send": "~0.19.1"
},
"engines": {
"node": ">= 0.8.0"
}
},
"node_modules/setprototypeof": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.2.0.tgz",
"integrity": "sha512-E5LDX7Wrp85Kil5bhZv46j8jOeboKq5JMmYM3gVGdGH8xFpPWXUMsNrlODCrkoxMEeNi/XZIwuRvY4XNwYMJpw==",
"license": "ISC"
},
"node_modules/side-channel": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/side-channel/-/side-channel-1.1.1.tgz",
"integrity": "sha512-6x6dK6zJdpTzF4sQeNYxwtvBzf6Eg4GtlesS94HOvTudUeyK2WXAaIfmDgsyslYrRBeFIlsi54AYsFGUuhmvrQ==",
"license": "MIT",
"dependencies": {
"es-errors": "^1.3.0",
"object-inspect": "^1.13.4",
"side-channel-list": "^1.0.1",
"side-channel-map": "^1.0.1",
"side-channel-weakmap": "^1.0.2"
},
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/side-channel-list": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/side-channel-list/-/side-channel-list-1.0.1.tgz",
"integrity": "sha512-mjn/0bi/oUURjc5Xl7IaWi/OJJJumuoJFQJfDDyO46+hBWsfaVM65TBHq2eoZBhzl9EchxOijpkbRC8SVBQU0w==",
"license": "MIT",
"dependencies": {
"es-errors": "^1.3.0",
"object-inspect": "^1.13.4"
},
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/side-channel-map": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/side-channel-map/-/side-channel-map-1.0.1.tgz",
"integrity": "sha512-VCjCNfgMsby3tTdo02nbjtM/ewra6jPHmpThenkTYh8pG9ucZ/1P8So4u4FGBek/BjpOVsDCMoLA/iuBKIFXRA==",
"license": "MIT",
"dependencies": {
"call-bound": "^1.0.2",
"es-errors": "^1.3.0",
"get-intrinsic": "^1.2.5",
"object-inspect": "^1.13.3"
},
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/side-channel-weakmap": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/side-channel-weakmap/-/side-channel-weakmap-1.0.2.tgz",
"integrity": "sha512-WPS/HvHQTYnHisLo9McqBHOJk2FkHO/tlpvldyrnem4aeQp4hai3gythswg6p01oSoTl58rcpiFAjF2br2Ak2A==",
"license": "MIT",
"dependencies": {
"call-bound": "^1.0.2",
"es-errors": "^1.3.0",
"get-intrinsic": "^1.2.5",
"object-inspect": "^1.13.3",
"side-channel-map": "^1.0.1"
},
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/statuses": {
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/statuses/-/statuses-2.0.2.tgz",
"integrity": "sha512-DvEy55V3DB7uknRo+4iOGT5fP1slR8wQohVdknigZPMpMstaKJQWhwiYBACJE3Ul2pTnATihhBYnRhZQHGBiRw==",
"license": "MIT",
"engines": {
"node": ">= 0.8"
}
},
"node_modules/toidentifier": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/toidentifier/-/toidentifier-1.0.1.tgz",
"integrity": "sha512-o5sSPKEkg/DIQNmH43V0/uerLrpzVedkUh8tGNvaeXpfpuwjKenlSox/2O/BTlZUtEe+JG7s5YhEz608PlAHRA==",
"license": "MIT",
"engines": {
"node": ">=0.6"
}
},
"node_modules/type-is": {
"version": "1.6.18",
"resolved": "https://registry.npmjs.org/type-is/-/type-is-1.6.18.tgz",
"integrity": "sha512-TkRKr9sUTxEH8MdfuCSP7VizJyzRNMjj2J2do2Jr3Kym598JVdEksuzPQCnlFPW4ky9Q+iA+ma9BGm06XQBy8g==",
"license": "MIT",
"dependencies": {
"media-typer": "0.3.0",
"mime-types": "~2.1.24"
},
"engines": {
"node": ">= 0.6"
}
},
"node_modules/unpipe": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz",
"integrity": "sha512-pjy2bYhSsufwWlKwPc+l3cN7+wuJlK6uz0YdJEOlQDbl6jo/YlPi4mb8agUkVC8BF7V8NuzeyPNqRksA3hztKQ==",
"license": "MIT",
"engines": {
"node": ">= 0.8"
}
},
"node_modules/utils-merge": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/utils-merge/-/utils-merge-1.0.1.tgz",
"integrity": "sha512-pMZTvIkT1d+TFGvDOqodOclx0QWkkgi6Tdoa8gC8ffGAAqz9pzPTZWAybbsHHoED/ztMtkv/VoYTYyShUn81hA==",
"license": "MIT",
"engines": {
"node": ">= 0.4.0"
}
},
"node_modules/vary": {
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz",
"integrity": "sha512-BNGbWLfd0eUPabhkXUVm0j8uuvREyTh5ovRa/dyow/BqAbZJyC+5fU+IzQOzmAKzYqYRAISoRhdQr3eIZ/PXqg==",
"license": "MIT",
"engines": {
"node": ">= 0.8"
}
}
}
}
@@ -0,0 +1,18 @@
{
"name": "research-workbench-app",
"private": true,
"version": "0.1.0",
"type": "module",
"description": "Production delivery trial of the Marqdo research workbench design (WEB-04)",
"scripts": {
"start": "node server.js",
"test": "node --test test/api.test.js",
"e2e": "playwright test"
},
"dependencies": {
"express": "^4.21.2"
},
"devDependencies": {
"@playwright/test": "1.49.0"
}
}
@@ -0,0 +1,16 @@
import { defineConfig } from "@playwright/test";
export default defineConfig({
testDir: "./e2e",
timeout: 30_000,
use: { baseURL: "http://127.0.0.1:4173", channel: "chromium" },
webServer: {
command: "node server.js",
url: "http://127.0.0.1:4173",
reuseExistingServer: false,
env: {
PORT: "4173",
WORKBENCH_DATA: process.env.WORKBENCH_DATA ?? "workbench-e2e-data.json",
},
},
});
@@ -0,0 +1,78 @@
const statsNode = document.querySelector("#stats");
const tasksNode = document.querySelector("#tasks");
const errorNode = document.querySelector("#error");
const searchNode = document.querySelector("#search");
const form = document.querySelector("#create-form");
const titleNode = document.querySelector("#title");
const priorityNode = document.querySelector("#priority");
const showError = (message) => {
errorNode.textContent = message;
errorNode.classList.toggle("hidden", !message);
};
async function request(path, options) {
const response = await fetch(path, options);
const body = await response.json().catch(() => ({}));
if (!response.ok) throw new Error(body?.error?.message ?? `HTTP ${response.status}`);
return body;
}
async function refresh() {
try {
const query = encodeURIComponent(searchNode.value.trim());
const [tasks, stats] = await Promise.all([
request(`/api/tasks?q=${query}`),
request("/api/stats"),
]);
statsNode.textContent = `总数 ${stats.total} · 待办 ${stats.byStatus.open} · 进行中 ${stats.byStatus.doing} · 完成 ${stats.byStatus.done}`;
tasksNode.replaceChildren(
...tasks.tasks.map((task) => {
const item = document.createElement("li");
const label = document.createElement("span");
label.textContent = `${task.title} · ${task.priority} · ${task.status}`;
item.append(label);
if (task.status !== "done") {
const button = document.createElement("button");
button.type = "button";
button.textContent = task.status === "open" ? "开始" : "完成";
button.addEventListener("click", async () => {
try {
await request(`/api/tasks/${task.id}/status`, {
method: "PATCH",
headers: { "content-type": "application/json" },
body: JSON.stringify({ status: task.status === "open" ? "doing" : "done" }),
});
showError("");
await refresh();
} catch (error) {
showError(error.message);
}
});
item.append(button);
}
return item;
}),
);
} catch (error) {
showError(error.message);
}
}
form.addEventListener("submit", async (event) => {
event.preventDefault();
try {
await request("/api/tasks", {
method: "POST",
headers: { "content-type": "application/json" },
body: JSON.stringify({ title: titleNode.value, priority: priorityNode.value }),
});
titleNode.value = "";
showError("");
await refresh();
} catch (error) {
showError(error.message);
}
});
searchNode.addEventListener("input", refresh);
refresh();
@@ -0,0 +1,42 @@
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>科研工作台(生产实现试验)</title>
<link rel="stylesheet" href="/styles.css">
</head>
<body>
<header>
<strong>科研工作台</strong>
<span class="badge">生产实现试验:真实持久化与错误处理</span>
</header>
<main>
<section class="panel" aria-label="统计">
<h2>统计</h2>
<p id="stats" data-testid="stats">加载中…</p>
</section>
<section class="panel" aria-label="创建任务">
<h2>创建任务</h2>
<form id="create-form">
<label>标题 <input name="title" id="title" required maxlength="120"></label>
<label>优先级
<select name="priority" id="priority">
<option value="normal">normal</option>
<option value="high">high</option>
<option value="low">low</option>
</select>
</label>
<button type="submit">创建</button>
</form>
<p class="error hidden" id="error" role="alert" data-testid="error"></p>
</section>
<section class="panel" aria-label="任务列表">
<h2>任务列表</h2>
<input id="search" placeholder="搜索任务标题" aria-label="搜索任务">
<ul id="tasks" data-testid="tasks"></ul>
</section>
</main>
<script type="module" src="/app.js"></script>
</body>
</html>
@@ -0,0 +1,15 @@
:root { color-scheme: light; }
* { box-sizing: border-box; }
body { margin: 0; font-family: system-ui, "Noto Sans CJK SC", sans-serif; background: #f5f6f8; color: #1d1d1f; }
header { display: flex; gap: .75rem; align-items: center; padding: .8rem 1.2rem; background: #1f2937; color: #fff; }
.badge { font-size: .75rem; background: #f59e0b; color: #1f2937; padding: .1rem .45rem; border-radius: 999px; }
main { max-width: 900px; margin: 0 auto; padding: 1rem; display: grid; gap: 1rem; }
.panel { background: #fff; border: 1px solid #d7d9de; border-radius: 8px; padding: .9rem; }
h2 { margin: .1rem 0 .6rem; font-size: 1rem; }
input, select, button { font: inherit; }
input, select { padding: .35rem .45rem; border: 1px solid #b9bdc5; border-radius: 6px; margin-right: .4rem; }
button { padding: .35rem .7rem; border: 1px solid #374151; background: #374151; color: #fff; border-radius: 6px; cursor: pointer; }
ul { list-style: none; padding: 0; margin: .6rem 0 0; display: grid; gap: .4rem; }
li { display: flex; gap: .6rem; align-items: center; justify-content: space-between; border: 1px solid #e4e6ea; border-radius: 6px; padding: .45rem .6rem; }
.hidden { display: none; }
.error { color: #b91c1c; font-weight: 600; }
+99
View File
@@ -0,0 +1,99 @@
// Production delivery trial for the Marqdo research workbench design.
// This is a real application (Express + JSON persistence), NOT the web Tool:
// the design/Preview prototype never runs as a dependency of this server.
import express from "express";
import { readFileSync, writeFileSync, existsSync } from "node:fs";
import { dirname, join } from "node:path";
import { fileURLToPath } from "node:url";
const here = dirname(fileURLToPath(import.meta.url));
export function createApp({ dataFile }) {
const app = express();
app.use(express.json({ limit: "64kb" }));
app.use(express.static(join(here, "public")));
const load = () => {
if (!existsSync(dataFile)) return { nextId: 1, tasks: [] };
return JSON.parse(readFileSync(dataFile, "utf8"));
};
const save = (state) => writeFileSync(dataFile, JSON.stringify(state, null, 2));
const fail = (response, status, code, message) =>
response.status(status).json({ error: { code, message } });
app.get("/api/tasks", (request, response) => {
const state = load();
const query = String(request.query.q ?? "").trim().toLowerCase();
const status = String(request.query.status ?? "").trim();
const tasks = state.tasks.filter((task) => {
const matchesQuery = !query || task.title.toLowerCase().includes(query);
const matchesStatus = !status || task.status === status;
return matchesQuery && matchesStatus;
});
response.json({ tasks });
});
app.post("/api/tasks", (request, response) => {
const title = typeof request.body?.title === "string" ? request.body.title.trim() : "";
const priority = request.body?.priority ?? "normal";
if (!title) return fail(response, 400, "task.title_required", "任务标题不能为空");
if (title.length > 120) return fail(response, 400, "task.title_too_long", "任务标题不能超过 120 字符");
if (!["low", "normal", "high"].includes(priority)) {
return fail(response, 400, "task.priority_invalid", "优先级必须是 low/normal/high");
}
const state = load();
const task = {
id: state.nextId++,
title,
priority,
status: "open",
createdAt: new Date().toISOString(),
};
state.tasks.push(task);
save(state);
response.status(201).json({ task });
});
app.patch("/api/tasks/:id/status", (request, response) => {
const id = Number(request.params.id);
const status = request.body?.status;
if (!Number.isInteger(id) || id < 1) return fail(response, 400, "task.id_invalid", "任务 id 非法");
if (!["open", "doing", "done"].includes(status)) {
return fail(response, 400, "task.status_invalid", "状态必须是 open/doing/done");
}
const state = load();
const task = state.tasks.find((item) => item.id === id);
if (!task) return fail(response, 404, "task.not_found", "任务不存在");
task.status = status;
save(state);
response.json({ task });
});
app.get("/api/stats", (request, response) => {
const state = load();
const total = state.tasks.length;
const byStatus = { open: 0, doing: 0, done: 0 };
const byPriority = { low: 0, normal: 0, high: 0 };
for (const task of state.tasks) {
byStatus[task.status] += 1;
byPriority[task.priority] += 1;
}
response.json({ total, byStatus, byPriority });
});
app.use((request, response) =>
fail(response, 404, "app.not_found", `unknown route ${request.method} ${request.path}`),
);
return app;
}
const isMain = process.argv[1] && fileURLToPath(import.meta.url) === process.argv[1];
if (isMain) {
const port = Number(process.env.PORT ?? 4173);
const dataFile = process.env.WORKBENCH_DATA ?? join(here, "workbench-data.json");
createApp({ dataFile }).listen(port, "127.0.0.1", () => {
console.log(`research-workbench listening on http://127.0.0.1:${port} (data: ${dataFile})`);
});
}
@@ -0,0 +1,88 @@
// Production API acceptance: real server, real file persistence, real HTTP.
import test from "node:test";
import assert from "node:assert/strict";
import { mkdtempSync, readFileSync, rmSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
import { createApp } from "../server.js";
async function withServer(run) {
const dir = mkdtempSync(join(tmpdir(), "workbench-"));
const dataFile = join(dir, "data.json");
const app = createApp({ dataFile });
const server = app.listen(0, "127.0.0.1");
await new Promise((resolve) => server.once("listening", resolve));
const base = `http://127.0.0.1:${server.address().port}`;
try {
await run({ base, dataFile });
} finally {
await new Promise((resolve) => server.close(resolve));
rmSync(dir, { recursive: true, force: true });
}
}
test("creates, searches, updates and reports linked statistics with persistence", async () => {
await withServer(async ({ base, dataFile }) => {
const created = await fetch(`${base}/api/tasks`, {
method: "POST",
headers: { "content-type": "application/json" },
body: JSON.stringify({ title: "测量超导比特", priority: "high" }),
});
assert.equal(created.status, 201);
const { task } = await created.json();
assert.equal(task.title, "测量超导比特");
assert.equal(task.status, "open");
const second = await fetch(`${base}/api/tasks`, {
method: "POST",
headers: { "content-type": "application/json" },
body: JSON.stringify({ title: "整理实验记录" }),
});
assert.equal(second.status, 201);
const list = await (await fetch(`${base}/api/tasks?q=超导`)).json();
assert.equal(list.tasks.length, 1);
assert.equal(list.tasks[0].id, task.id);
const invalid = await fetch(`${base}/api/tasks`, {
method: "POST",
headers: { "content-type": "application/json" },
body: JSON.stringify({ title: " " }),
});
assert.equal(invalid.status, 400);
assert.equal((await invalid.json()).error.code, "task.title_required");
const badPriority = await fetch(`${base}/api/tasks`, {
method: "POST",
headers: { "content-type": "application/json" },
body: JSON.stringify({ title: "x", priority: "urgent" }),
});
assert.equal(badPriority.status, 400);
const update = await fetch(`${base}/api/tasks/${task.id}/status`, {
method: "PATCH",
headers: { "content-type": "application/json" },
body: JSON.stringify({ status: "done" }),
});
assert.equal(update.status, 200);
const missing = await fetch(`${base}/api/tasks/999/status`, {
method: "PATCH",
headers: { "content-type": "application/json" },
body: JSON.stringify({ status: "done" }),
});
assert.equal(missing.status, 404);
assert.equal((await missing.json()).error.code, "task.not_found");
const stats = await (await fetch(`${base}/api/stats`)).json();
assert.equal(stats.total, 2);
assert.equal(stats.byStatus.done, 1);
assert.equal(stats.byStatus.open, 1);
assert.equal(stats.byPriority.high, 1);
// Persistence is a real file: a new app instance reads the same state.
const reloaded = JSON.parse(readFileSync(dataFile, "utf8"));
assert.equal(reloaded.tasks.length, 2);
assert.equal(reloaded.nextId, 3);
});
});
+1 -1
Submodule preview updated: 8b3281bac0...7d6dbbec86.
+43
View File
@@ -0,0 +1,43 @@
#!/usr/bin/env bash
# WEB-04 domain acceptance: three composition cases through the unique web Tool
# plus the real production delivery trial (Express app with API and E2E).
set -eu
: "${MARQDO_BIN:?set MARQDO_BIN to the verified marqdo executable}"
: "${MARQDO_WEB_TOOL_JSON:?set MARQDO_WEB_TOOL_JSON to the built preview tool.json}"
cd "$(dirname "$0")/.."
work="$(mktemp -d)"
trap 'rm -rf "$work"' EXIT
export MARQDO_TOOL_HOME="$work/tool-home"
"$MARQDO_BIN" tool install "$MARQDO_WEB_TOOL_JSON"
run_case() {
case_name="$1"
unit="$2"
root="examples/$case_name"
entry="$root/index.mq.md"
"$MARQDO_BIN" web check "$entry" --unit "$unit" --root "$root"
preview="$work/$case_name-preview"
"$MARQDO_BIN" web preview "$entry" --unit "$unit" --root "$root" --out "$preview"
test -f "$preview/index.html"
grep -q "Content-Security-Policy" "$preview/index.html"
grep -q "data-scenario\|data-instance" "$preview/index.html"
handoff="$work/$case_name-handoff.md"
"$MARQDO_BIN" web handoff "$entry" --unit "$unit" --root "$root" --out "$handoff"
test -s "$handoff"
grep -q "Design handoff" "$handoff"
echo "case $case_name: PASS"
}
run_case research-workspace 工作台
run_case doc-site 首页
run_case quantum-editor 编辑器
# Production delivery trial: a real framework application, not the prototype.
(
cd examples/research-workbench-app
npm install --no-audit --no-fund ${MARQDO_NPM_CACHE:+--cache "$MARQDO_NPM_CACHE"}
npm test
WORKBENCH_DATA="$work/e2e-data.json" npx playwright test
)
"$MARQDO_BIN" tool remove web
echo "PASS: WEB-04 domain composition + production delivery trial"
+49
View File
@@ -0,0 +1,49 @@
#!/bin/sh
# Deterministic source archive + release-evidence.json for this component.
#
# Required env:
# COMPONENT_ID catalog id (e.g. std-text)
# REPOSITORY owner/name (e.g. cflmy/marqdo-std-text)
# Optional:
# VERSION without leading v (default: derived from CI_COMMIT_TAG)
# SOURCE_SHA full commit (default: HEAD)
# OUT_DIR default dist
# DEPENDENCY repeatable write_evidence dependency specs via env DEP_ARGS
set -eu
ROOT=$(CDPATH= cd -- "$(dirname -- "$0")/.." && pwd)
COMPONENT_ID=${COMPONENT_ID:?COMPONENT_ID is required}
REPOSITORY=${REPOSITORY:?REPOSITORY is required}
SOURCE_SHA=${SOURCE_SHA:-$(git -C "$ROOT" rev-parse HEAD)}
OUT_DIR=${OUT_DIR:-dist}
TAG=${CI_COMMIT_TAG:-${TAG:-}}
if [ -n "${VERSION:-}" ]; then
:
elif [ -n "$TAG" ]; then
VERSION=${TAG#v}
else
echo "package.sh: set VERSION or CI_COMMIT_TAG" >&2
exit 1
fi
TAG=${TAG:-v$VERSION}
python3 "$ROOT/scripts/release/package_source.py" \
--root "$ROOT" \
--component-id "$COMPONENT_ID" \
--version "$VERSION" \
--out-dir "$OUT_DIR"
ARCHIVE=$(ls "$ROOT/$OUT_DIR"/marqdo-"$COMPONENT_ID"-"$VERSION"-source.tar.gz)
SHAFILE="$ARCHIVE.sha256"
EVIDENCE_ARGS="--component-id $COMPONENT_ID --repository $REPOSITORY --tag $TAG --source-sha $SOURCE_SHA --asset $ARCHIVE --asset $SHAFILE --out $ROOT/$OUT_DIR/release-evidence.json"
if [ -n "${CI_PIPELINE_NUMBER:-}" ]; then
EVIDENCE_ARGS="$EVIDENCE_ARGS --pipeline-number $CI_PIPELINE_NUMBER"
fi
if [ -n "${CI_PIPELINE_URL:-}" ]; then
EVIDENCE_ARGS="$EVIDENCE_ARGS --pipeline-url $CI_PIPELINE_URL"
fi
# shellcheck disable=SC2086
eval "python3 \"$ROOT/scripts/release/write_evidence.py\" $EVIDENCE_ARGS ${DEP_ARGS:-}"
echo "$ARCHIVE"
echo "$SHAFILE"
echo "$ROOT/$OUT_DIR/release-evidence.json"
+9
View File
@@ -0,0 +1,9 @@
# Vendored from marqdo scripts/component-release
#
# Do not edit in place across repositories. Change the root copy, re-test,
# then re-run install-vendor.sh and record the hashes below.
#
# package_source.py sha256=cb18c2f7fbe807f55d49e2cf77720f0d3e57d355177d2b127ac09e119f90c6ae
# write_evidence.py sha256=bb194bfd251e39308bc1dd53f46fd9efac181082ea43f668484b067d9e54acfc
# publish_gitea.py sha256=a21a84146d9ea826eb8d0632a18a991b0c39f17005d83bd988c92fc608f67523
# notify_root.py sha256=8eee83eb2bb31b99d93981f2a97fc2f0f9a486cc3c5c072f7dc12cfb63baf025
+103
View File
@@ -0,0 +1,103 @@
#!/usr/bin/env python3
"""Ask the root Marqdo reconcile workflow to scan after a release.
The payload is only a hint. Correctness comes from the root
`scripts/reconcile-releases.py` reading authoritative Gitea releases.
Lost notifications are recovered by the root `release-reconcile` cron.
"""
from __future__ import annotations
import argparse
import json
import os
import random
import sys
import time
import urllib.error
import urllib.request
DEFAULT_URL = "https://ci.cflmy.cn/api/repos/6/pipelines"
DEFAULT_BODY = {"branch": "main", "workflow": "reconcile"}
class NotifyError(Exception):
pass
def token() -> str:
value = (
os.environ.get("WOODPECKER_NOTIFY_TOKEN")
or os.environ.get("WOODPECKER_TOKEN")
or os.environ.get("woodpecker_token")
)
if not value:
raise NotifyError("WOODPECKER_NOTIFY_TOKEN (or WOODPECKER_TOKEN) is not set")
return value
def trigger(url: str, token_value: str, body: dict, attempts: int = 3) -> dict:
payload = json.dumps(body).encode()
last_error: Exception | None = None
for attempt in range(1, attempts + 1):
request = urllib.request.Request(
url,
data=payload,
method="POST",
headers={
"Authorization": f"Bearer {token_value}",
"Content-Type": "application/json",
"Accept": "application/json",
},
)
try:
with urllib.request.urlopen(request, timeout=60) as response:
raw = response.read()
decoded = json.loads(raw) if raw else {}
return {
"status": "triggered",
"http_status": response.status,
"pipeline_id": decoded.get("id"),
"pipeline_number": decoded.get("number"),
"attempt": attempt,
}
except urllib.error.HTTPError as error:
# Auth/permission failures must not retry forever.
if error.code in (401, 403, 404):
raise NotifyError(f"trigger rejected with HTTP {error.code}") from error
last_error = error
except urllib.error.URLError as error:
last_error = error
if attempt < attempts:
delay = (2 ** (attempt - 1)) + random.uniform(0, 0.5)
time.sleep(delay)
raise NotifyError(f"trigger failed after {attempts} attempts: {last_error}")
def main(argv: list[str] | None = None) -> int:
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument("--url", default=os.environ.get("MARQDO_RECONCILE_TRIGGER_URL", DEFAULT_URL))
parser.add_argument("--branch", default="main")
parser.add_argument("--workflow", default="reconcile")
parser.add_argument("--hint-component", default="")
parser.add_argument("--hint-tag", default="")
parser.add_argument("--attempts", type=int, default=3)
args = parser.parse_args(argv)
body = {"branch": args.branch, "workflow": args.workflow}
# Hints are informational only; the root reconcile never trusts them as commands.
if args.hint_component or args.hint_tag:
body["variables"] = {
"MARQDO_RELEASE_HINT_COMPONENT": args.hint_component,
"MARQDO_RELEASE_HINT_TAG": args.hint_tag,
}
try:
result = trigger(args.url, token(), body, attempts=max(1, args.attempts))
except NotifyError as error:
print(f"notify_root: FAIL: {error}", file=sys.stderr)
return 1
print(json.dumps(result, indent=2, sort_keys=True))
return 0
if __name__ == "__main__":
raise SystemExit(main())
+145
View File
@@ -0,0 +1,145 @@
#!/usr/bin/env python3
"""Build a deterministic source archive for a Marqdo component release.
Only allowlisted relative paths are included. The archive uses fixed mtime,
uid/gid, and sorted member names so the same tree always yields the same
sha256. Output is written under an isolated directory (default: dist/).
"""
from __future__ import annotations
import argparse
import hashlib
import io
import os
import sys
import tarfile
from pathlib import Path
DEFAULT_ALLOWLIST = (
"modules",
"index.mq.md",
"marqdo.yaml",
"LICENSE",
"README.md",
)
FIXED_MTIME = 0
EVIDENCE_NAME = "release-evidence.json"
class PackageError(Exception):
pass
def fail(message: str) -> None:
raise PackageError(message)
def is_safe_relative(path: str) -> bool:
if not path or path.startswith("/") or path.startswith("\\"):
return False
parts = Path(path).parts
return not any(part in (".", "..") for part in parts)
def collect_files(root: Path, allowlist: list[str]) -> list[tuple[str, Path]]:
selected: dict[str, Path] = {}
for entry in allowlist:
if not is_safe_relative(entry):
fail(f"unsafe allowlist entry: {entry!r}")
target = root / entry
if not target.exists():
continue
if target.is_file():
selected[entry.replace("\\", "/")] = target
continue
if not target.is_dir():
fail(f"allowlist entry is not a regular file or directory: {entry}")
for path in sorted(target.rglob("*")):
if not path.is_file():
continue
if path.is_symlink():
fail(f"symlinks are not publishable: {path.relative_to(root)}")
relative = path.relative_to(root).as_posix()
if not is_safe_relative(relative):
fail(f"unsafe relative path: {relative}")
selected[relative] = path
if not selected:
fail("allowlist matched no files")
return sorted(selected.items(), key=lambda item: item[0])
def archive_bytes(files: list[tuple[str, Path]]) -> bytes:
buffer = io.BytesIO()
with tarfile.open(fileobj=buffer, mode="w:gz", format=tarfile.PAX_FORMAT, compresslevel=9) as archive:
for relative, path in files:
data = path.read_bytes()
info = tarfile.TarInfo(name=relative)
info.size = len(data)
info.mtime = FIXED_MTIME
info.uid = 0
info.gid = 0
info.uname = ""
info.gname = ""
info.mode = 0o644
archive.addfile(info, io.BytesIO(data))
return buffer.getvalue()
def write_outputs(
root: Path,
out_dir: Path,
component_id: str,
version: str,
allowlist: list[str],
) -> dict:
files = collect_files(root, allowlist)
payload = archive_bytes(files)
digest = hashlib.sha256(payload).hexdigest()
out_dir.mkdir(parents=True, exist_ok=True)
archive_name = f"marqdo-{component_id}-{version}-source.tar.gz"
archive_path = out_dir / archive_name
sha_path = out_dir / f"{archive_name}.sha256"
archive_path.write_bytes(payload)
sha_path.write_text(f"{digest} {archive_name}\n", encoding="utf-8")
return {
"archive": str(archive_path),
"sha256_file": str(sha_path),
"name": archive_name,
"size": len(payload),
"sha256": digest,
"files": [relative for relative, _ in files],
}
def main(argv: list[str] | None = None) -> int:
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument("--root", default=".", help="component repository root")
parser.add_argument("--component-id", required=True)
parser.add_argument("--version", required=True, help="version without leading v")
parser.add_argument("--out-dir", default="dist")
parser.add_argument(
"--allow",
action="append",
default=[],
help="relative allowlist entry (repeatable); defaults applied when omitted",
)
args = parser.parse_args(argv)
allowlist = args.allow or list(DEFAULT_ALLOWLIST)
root = Path(args.root).resolve()
out_dir = Path(args.out_dir)
if not out_dir.is_absolute():
out_dir = root / out_dir
try:
result = write_outputs(root, out_dir, args.component_id, args.version, allowlist)
except PackageError as error:
print(f"package_source: FAIL: {error}", file=sys.stderr)
return 1
print(result["archive"])
print(result["sha256_file"])
print(f"sha256={result['sha256']} size={result['size']} files={len(result['files'])}")
return 0
if __name__ == "__main__":
raise SystemExit(main())
+352
View File
@@ -0,0 +1,352 @@
#!/usr/bin/env python3
"""Publish a Gitea release with a draft transaction and immutable public assets.
Order (issue #10 §4.2):
create/reuse draft → upload non-index assets → upload release-evidence.json last
→ re-read and verify → mark non-draft → re-confirm.
Never deletes or replaces assets on an already-published (non-draft) release.
Identical published identity is treated as idempotent success.
"""
from __future__ import annotations
import argparse
import hashlib
import json
import mimetypes
import os
import sys
import urllib.error
import urllib.parse
import urllib.request
import uuid
from pathlib import Path
DEFAULT_API = "https://git.cflmy.cn/api/v1"
INDEX_NAME = "release-evidence.json"
class PublishError(Exception):
pass
def token() -> str:
value = (
os.environ.get("GITEA_PUBLISH_TOKEN")
or os.environ.get("GITEA_TOKEN")
or os.environ.get("gitea_token")
)
if not value:
raise PublishError("GITEA_PUBLISH_TOKEN (or GITEA_TOKEN) is not set")
return value
def request(
api: str,
method: str,
path: str,
token_value: str,
payload: dict | None = None,
raw: bytes | None = None,
content_type: str = "application/json",
) -> tuple[int, bytes]:
url = f"{api}{path}"
headers = {"Authorization": f"token {token_value}", "Accept": "application/json"}
data = None
if payload is not None:
data = json.dumps(payload).encode()
headers["Content-Type"] = content_type
elif raw is not None:
data = raw
headers["Content-Type"] = content_type
req = urllib.request.Request(url, data=data, headers=headers, method=method)
try:
with urllib.request.urlopen(req, timeout=120) as response:
return response.status, response.read()
except urllib.error.HTTPError as error:
return error.code, error.read()
def decode(body: bytes) -> object:
if not body:
return None
try:
return json.loads(body)
except Exception:
return None
def sha256_file(path: Path) -> str:
return hashlib.sha256(path.read_bytes()).hexdigest()
def get_release_by_tag(api: str, repo: str, tag: str, token_value: str) -> dict | None:
status, body = request(
api,
"GET",
f"/repos/{repo}/releases/tags/{urllib.parse.quote(tag, safe='')}",
token_value,
)
if status == 404:
return None
if status != 200:
raise PublishError(f"lookup release {tag} failed with HTTP {status}")
release = decode(body)
if not isinstance(release, dict) or "id" not in release:
raise PublishError("release lookup response malformed")
return release
def create_draft(
api: str,
repo: str,
tag: str,
body: str,
token_value: str,
*,
prerelease: bool,
target: str,
) -> dict:
payload = {
"tag_name": tag,
"name": tag,
"body": body,
"draft": True,
"prerelease": prerelease,
"target_commitish": target,
}
status, response = request(api, "POST", f"/repos/{repo}/releases", token_value, payload)
if status not in (200, 201):
raise PublishError(f"creating draft release failed with HTTP {status}: {response[:200]!r}")
release = decode(response)
if not isinstance(release, dict) or "id" not in release:
raise PublishError("draft create response malformed")
return release
def patch_release(api: str, repo: str, release_id: int, token_value: str, payload: dict) -> dict:
status, response = request(
api, "PATCH", f"/repos/{repo}/releases/{release_id}", token_value, payload
)
if status != 200:
raise PublishError(f"updating release {release_id} failed with HTTP {status}")
release = decode(response)
if not isinstance(release, dict):
raise PublishError("release patch response malformed")
return release
def list_assets(api: str, repo: str, release_id: int, token_value: str) -> list[dict]:
status, response = request(
api, "GET", f"/repos/{repo}/releases/{release_id}/assets", token_value
)
if status != 200:
raise PublishError(f"listing assets failed with HTTP {status}")
assets = decode(response)
if not isinstance(assets, list):
raise PublishError("asset list malformed")
return assets
def upload_asset(
api: str, repo: str, release_id: int, path: Path, token_value: str
) -> dict:
name = path.name
if not name or "/" in name or name in (".", ".."):
raise PublishError(f"unsafe asset name: {name!r}")
existing = list_assets(api, repo, release_id, token_value)
for asset in existing:
if asset.get("name") == name:
raise PublishError(
f"asset {name} already exists on draft/release {release_id}; "
"refusing to overwrite"
)
boundary = f"----marqdo{uuid.uuid4().hex}"
content_type = mimetypes.guess_type(name)[0] or "application/octet-stream"
body = bytearray()
body.extend(f"--{boundary}\r\n".encode())
body.extend(
f'Content-Disposition: form-data; name="attachment"; filename="{name}"\r\n'.encode()
)
body.extend(f"Content-Type: {content_type}\r\n\r\n".encode())
body.extend(path.read_bytes())
body.extend(f"\r\n--{boundary}--\r\n".encode())
status, response = request(
api,
"POST",
f"/repos/{repo}/releases/{release_id}/assets?name={urllib.parse.quote(name)}",
token_value,
raw=bytes(body),
content_type=f"multipart/form-data; boundary={boundary}",
)
if status not in (200, 201):
raise PublishError(f"uploading {name} failed with HTTP {status}: {response[:200]!r}")
result = decode(response)
if not isinstance(result, dict):
raise PublishError(f"upload response for {name} malformed")
return result
def asset_identity(path: Path) -> dict:
return {
"name": path.name,
"size": path.stat().st_size,
"sha256": sha256_file(path),
}
def published_matches(release: dict, expected: list[dict]) -> bool:
remote = {
asset.get("name"): int(asset.get("size") or -1)
for asset in (release.get("assets") or [])
}
if set(remote) != {item["name"] for item in expected}:
return False
for item in expected:
if remote.get(item["name"]) != item["size"]:
return False
return True
def publish(
*,
api: str,
repo: str,
tag: str,
body: str,
target: str,
assets: list[Path],
prerelease: bool,
token_value: str,
) -> dict:
if not assets:
raise PublishError("no assets to publish")
index_assets = [path for path in assets if path.name == INDEX_NAME]
other_assets = [path for path in assets if path.name != INDEX_NAME]
if len(index_assets) != 1:
raise PublishError("exactly one release-evidence.json is required")
ordered = other_assets + index_assets
expected = [asset_identity(path) for path in ordered]
existing = get_release_by_tag(api, repo, tag, token_value)
if existing and not existing.get("draft"):
if published_matches(existing, expected):
return {
"status": "idempotent",
"release_id": existing["id"],
"html_url": existing.get("html_url"),
"tag": tag,
"assets": expected,
}
raise PublishError(
f"published release {tag} already exists with different assets; "
"refusing to overwrite"
)
if existing and existing.get("draft"):
release = existing
# Keep draft body/target aligned when continuing an interrupted publish.
release = patch_release(
api,
repo,
int(release["id"]),
token_value,
{
"name": tag,
"body": body,
"draft": True,
"prerelease": prerelease,
"target_commitish": target,
},
)
else:
release = create_draft(
api, repo, tag, body, token_value, prerelease=prerelease, target=target
)
release_id = int(release["id"])
remote_names = {asset.get("name") for asset in list_assets(api, repo, release_id, token_value)}
for path in ordered:
if path.name in remote_names:
# Same-name asset already on this draft: require identical size, else fail.
match = next(
asset
for asset in list_assets(api, repo, release_id, token_value)
if asset.get("name") == path.name
)
if int(match.get("size") or -1) != path.stat().st_size:
raise PublishError(
f"draft asset {path.name} size mismatch; refusing to overwrite"
)
continue
upload_asset(api, repo, release_id, path, token_value)
refreshed = get_release_by_tag(api, repo, tag, token_value)
if not refreshed or not published_matches(refreshed, expected):
raise PublishError("post-upload release asset list does not match local files")
published = patch_release(
api,
repo,
release_id,
token_value,
{"draft": False, "prerelease": prerelease, "name": tag, "body": body},
)
if published.get("draft"):
raise PublishError("release remained draft after publish")
final = get_release_by_tag(api, repo, tag, token_value)
if not final or final.get("draft") or not published_matches(final, expected):
raise PublishError("final release confirmation failed")
return {
"status": "published",
"release_id": final["id"],
"html_url": final.get("html_url"),
"tag": tag,
"assets": expected,
}
def main(argv: list[str] | None = None) -> int:
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument("--api-url", default=os.environ.get("GITEA_API_URL", DEFAULT_API))
parser.add_argument("--repo", required=True, help="owner/name")
parser.add_argument("--tag", required=True)
parser.add_argument("--target", required=True, help="full commit SHA for the tag")
parser.add_argument("--body-file", default=None)
parser.add_argument("--body", default="")
parser.add_argument("--asset", action="append", default=[], required=True)
parser.add_argument("--prerelease", action="store_true", default=False)
parser.add_argument("--evidence-out", default="dist/gitea-publish-result.json")
args = parser.parse_args(argv)
body = args.body
if args.body_file:
body = Path(args.body_file).read_text(encoding="utf-8")
assets = [Path(item) for item in args.asset]
for path in assets:
if not path.is_file():
print(f"publish_gitea: FAIL: missing asset {path}", file=sys.stderr)
return 1
try:
result = publish(
api=args.api_url.rstrip("/"),
repo=args.repo,
tag=args.tag,
body=body,
target=args.target,
assets=assets,
prerelease=args.prerelease,
token_value=token(),
)
except PublishError as error:
print(f"publish_gitea: FAIL: {error}", file=sys.stderr)
return 1
out = Path(args.evidence_out)
out.parent.mkdir(parents=True, exist_ok=True)
out.write_text(json.dumps(result, indent=2, sort_keys=True) + "\n", encoding="utf-8")
print(json.dumps(result, indent=2, sort_keys=True))
return 0
if __name__ == "__main__":
raise SystemExit(main())
+165
View File
@@ -0,0 +1,165 @@
#!/usr/bin/env python3
"""Write the external release-evidence.json index for a component release.
The index references already-built assets. It never includes itself in
`assets[]` (no self-referential digest). Downstream discoverers hash the index
bytes separately when they download it.
"""
from __future__ import annotations
import argparse
import hashlib
import json
import re
import sys
from pathlib import Path
SHA_RE = re.compile(r"^[0-9a-f]{40}$")
DIGEST_RE = re.compile(r"^[0-9a-f]{64}$")
MAX_ASSETS = 128
MAX_DEPENDENCIES = 256
INDEX_NAME = "release-evidence.json"
class EvidenceError(Exception):
pass
def sha256_file(path: Path) -> str:
digest = hashlib.sha256()
with path.open("rb") as handle:
while True:
chunk = handle.read(1024 * 1024)
if not chunk:
break
digest.update(chunk)
return digest.hexdigest()
def parse_dependency(raw: str) -> dict:
# id=cli,source_sha=<40hex>[,asset_sha256=<64hex>]
fields = {}
for part in raw.split(","):
if "=" not in part:
raise EvidenceError(f"invalid dependency field: {raw!r}")
key, value = part.split("=", 1)
fields[key.strip()] = value.strip()
component_id = fields.get("id")
source_sha = fields.get("source_sha")
if not component_id or not source_sha or not SHA_RE.match(source_sha):
raise EvidenceError(f"dependency requires id and 40-hex source_sha: {raw!r}")
entry = {"id": component_id, "source_sha": source_sha}
asset = fields.get("asset_sha256")
if asset:
if not DIGEST_RE.match(asset):
raise EvidenceError(f"invalid asset_sha256 in dependency: {raw!r}")
entry["asset_sha256"] = asset
return entry
def build_evidence(
*,
component_id: str,
repository: str,
tag: str,
source_sha: str,
assets: list[Path],
dependencies: list[dict],
pipeline_number: int | None,
pipeline_url: str | None,
) -> dict:
if not component_id:
raise EvidenceError("component_id is required")
if "/" not in repository:
raise EvidenceError("repository must be owner/name")
if not tag:
raise EvidenceError("tag is required")
if not SHA_RE.match(source_sha):
raise EvidenceError("source_sha must be a 40-hex commit")
if not assets:
raise EvidenceError("at least one non-index asset is required")
if len(assets) > MAX_ASSETS:
raise EvidenceError(f"more than {MAX_ASSETS} assets")
if len(dependencies) > MAX_DEPENDENCIES:
raise EvidenceError(f"more than {MAX_DEPENDENCIES} dependencies")
asset_entries = []
seen_names: set[str] = set()
for path in assets:
if not path.is_file():
raise EvidenceError(f"asset missing: {path}")
name = path.name
if name == INDEX_NAME:
raise EvidenceError("assets must not include release-evidence.json itself")
if name in seen_names or "/" in name or name in (".", ".."):
raise EvidenceError(f"unsafe or duplicate asset name: {name!r}")
seen_names.add(name)
target = "source"
if name.endswith(".tar.gz") and "linux" in name:
target = "x86_64-unknown-linux-gnu"
asset_entries.append(
{
"name": name,
"target": target,
"size": path.stat().st_size,
"sha256": sha256_file(path),
}
)
evidence = {
"component_id": component_id,
"repository": repository,
"tag": tag,
"source_sha": source_sha,
"ci": {
"pipeline_number": pipeline_number,
"url": pipeline_url,
"source_sha": source_sha,
},
"assets": asset_entries,
"dependencies": dependencies,
}
return evidence
def main(argv: list[str] | None = None) -> int:
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument("--component-id", required=True)
parser.add_argument("--repository", required=True)
parser.add_argument("--tag", required=True)
parser.add_argument("--source-sha", required=True)
parser.add_argument("--asset", action="append", default=[], required=True)
parser.add_argument("--dependency", action="append", default=[])
parser.add_argument("--pipeline-number", type=int, default=None)
parser.add_argument("--pipeline-url", default=None)
parser.add_argument("--out", default=f"dist/{INDEX_NAME}")
args = parser.parse_args(argv)
try:
dependencies = [parse_dependency(item) for item in args.dependency]
evidence = build_evidence(
component_id=args.component_id,
repository=args.repository,
tag=args.tag,
source_sha=args.source_sha,
assets=[Path(item) for item in args.asset],
dependencies=dependencies,
pipeline_number=args.pipeline_number,
pipeline_url=args.pipeline_url,
)
except EvidenceError as error:
print(f"write_evidence: FAIL: {error}", file=sys.stderr)
return 1
out = Path(args.out)
out.parent.mkdir(parents=True, exist_ok=True)
payload = json.dumps(evidence, indent=2, sort_keys=True, ensure_ascii=False) + "\n"
if len(payload.encode()) > 1024 * 1024:
print("write_evidence: FAIL: index exceeds 1 MiB", file=sys.stderr)
return 1
out.write_text(payload, encoding="utf-8")
print(out)
return 0
if __name__ == "__main__":
raise SystemExit(main())