@microi.net/cli 6.0.0 → 6.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.codebuddy-plugin/marketplace.json +2 -2
- package/.codebuddy-plugin/plugin.json +1 -1
- package/.codex-plugin/plugin.json +43 -43
- package/.mcp.json +1 -1
- package/.workbuddy-plugin/marketplace.json +2 -2
- package/.workbuddy-plugin/plugin.json +1 -1
- package/LICENSE +21 -21
- package/README.md +71 -71
- package/assets/build-meta.json +7 -7
- package/assets/feature-matrix.json +138 -138
- package/assets/logo.svg +4 -4
- package/cordis.patch.yml +1 -1
- package/package.json +82 -82
- package/scripts/codex-marketplace.json +20 -20
- package/scripts/mcp-codex-stdio-adapter.js +189 -189
- package/scripts/mcp-server.js +81 -81
- package/scripts/mcp-trae-windows-launcher.cmd +21 -21
- package/scripts/microi-cli-mcp.js +7 -7
- package/scripts/microi-cli.js +60 -59
- package/scripts/microi-codex-broker.js +466 -466
- package/scripts/microi-codex-router.js +635 -635
- package/scripts/microi-skills.meta.json +225 -222
- package/skills/.microi-skills-version.json +6 -6
- package/skills/.progressive-disclosure-manifest.json +75 -75
- package/skills/microi-client-frontend/SKILL.md +266 -258
- package/skills/microi-codex/SKILL.md +16 -2
- package/skills/microi-codex-installer/SKILL.md +4 -2
- package/skills/microi-deployment/SKILL.md +1 -1
- package/skills/microi-microservice/SKILL.md +348 -337
- package/skills/microi-system-delivery/SKILL.md +100 -92
- package/skills/microi-system-delivery/references/progressive-02-/350/207/252/345/212/250/345/214/226/346/265/213/350/257/225/345/277/205/351/241/273/350/246/206/347/233/226/347/232/204/345/235/221.md +2 -2
- package/skills/page-engine/SKILL.md +231 -227
- package/skills/playwright-e2e/SKILL.md +204 -200
- package/skills/scripts/validate-progressive-disclosure.mjs +15 -4
- package/skills/scripts/validate-progressive-disclosure.test.mjs +108 -0
- package/skills/v8-cache-pattern/SKILL.md +8 -4
- package/skills/v8-export-import/SKILL.md +5 -0
- package/skills/v8-file-upload/SKILL.md +4 -0
- package/skills/v8-security/references/progressive-01-2-/346/235/203/351/231/220/346/240/241/351/252/214.md +10 -2
- package/skills/workspace-conventions/SKILL.md +26 -3
- package/skills/workspace-conventions/references/progressive-01-/347/211/210/346/234/254/346/233/264/346/226/260/346/227/245/345/277/227/344/277/235/346/212/244/350/247/204/345/210/231-/345/274/272/345/210/266.md +6 -3
- package/skills/workspace-conventions/references/progressive-02-microi-net-api-/346/234/254/345/234/260/345/220/257/345/212/250/347/272/246/345/256/232.md +4 -3
- package/skills/workspace-conventions/references/progressive-03-cli-/344/270/216-ide-/346/217/222/344/273/266/351/224/231/347/211/210/345/205/261/345/255/230/347/272/246/345/256/232.md +4 -4
- package/skills/workspace-conventions/references/progressive-04-/345/267/245/344/275/234/345/214/272/344/270/216/345/271/263/345/217/260/344/270/223/351/241/271/344/277/235/351/232/234.md +10 -8
|
@@ -1,200 +1,204 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: playwright-e2e
|
|
3
|
-
description: 按 Microi 系统真实业务逻辑进行 Playwright 全自动化、全面测试。用于测试 PC Vue、本地多 ApiBase/OsClient 独立浏览器上下文、远端运行目标识别、前端微服务菜单切换与 keep-alive/LRU、uni-app H5、网站、界面引擎、移动商城、ApiEngine/FormEngine 契约、登录流程、写入闭环、网络防护、截图、报告和 Playwright Test for VSCode 集成。
|
|
4
|
-
---
|
|
5
|
-
|
|
6
|
-
> **Microi吾码基础规范(强制):** 任何 AI 模型与宿主每次新建或接续吾码任务,先完整读取 `../workspace-conventions/SKILL.md`,必须执行版本播报、`@microi.net/cli` 后台自动升级、Skills/MCP 同步和进度播报。安装与诊断读取 `../microi-codex-installer/SKILL.md`;更新失败延后重试,不阻断当前工作。
|
|
7
|
-
|
|
8
|
-
# Microi 吾码 Playwright E2E 自动化测试
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
> -
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
-
|
|
35
|
-
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
|
53
|
-
|
|
54
|
-
|
|
|
55
|
-
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
```
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
`
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
`
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
```
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
```
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
1
|
+
---
|
|
2
|
+
name: playwright-e2e
|
|
3
|
+
description: 按 Microi 系统真实业务逻辑进行 Playwright 全自动化、全面测试。用于测试 PC Vue、本地多 ApiBase/OsClient 独立浏览器上下文、远端运行目标识别、前端微服务菜单切换与 keep-alive/LRU、uni-app H5、网站、界面引擎、移动商城、ApiEngine/FormEngine 契约、登录流程、写入闭环、网络防护、截图、报告和 Playwright Test for VSCode 集成。
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
> **Microi吾码基础规范(强制):** 任何 AI 模型与宿主每次新建或接续吾码任务,先完整读取 `../workspace-conventions/SKILL.md`,必须执行版本播报、`@microi.net/cli` 后台自动升级、Skills/MCP 同步和进度播报。安装与诊断读取 `../microi-codex-installer/SKILL.md`;更新失败延后重试,不阻断当前工作。
|
|
7
|
+
|
|
8
|
+
# Microi 吾码 Playwright E2E 自动化测试
|
|
9
|
+
|
|
10
|
+
桌面人工补充或新建浏览器验收默认只选一个常规 CSS 视口:优先复现用户实际浏览器尺寸,未知时用 1920×1080。截图文件像素还受设备缩放影响,不能据此强制 4K;仅用户明确要求或问题涉及超宽屏时追加 4K,移动端或响应式改动按需补充相关窄屏。沿用已有有效验收,不为截图分辨率重复整套用例;正式脚本既有 Full 不在运行中删减。核心发布已冻结后,新增规范文案独立交付,不因此重启合格候选的构建、测试或上传。
|
|
11
|
+
|
|
12
|
+
每轮测试成功、失败、取消或中断退出时,在 `finally` / teardown 中关闭本任务 browser/context 和临时写入进程,再按 [测试临时文件随任务清理](../workspace-conventions/SKILL.md#测试临时文件必须随任务清理强制) 删除本任务 `.tmp` 下的一次性脚本、夹具及无用途的截图、trace、video、日志和编译副本。交付必需证据先最小归档并回读,失败排查只暂留有明确归属和清理时机的最小集合;报告和截图路径规则不构成永久保留许可,结束后必须单独验收清理结果。
|
|
13
|
+
|
|
14
|
+
> **2026-05 更新(重要)**:Microi.Agent 插件生成的E2E 配置、用例和帮助器保留在 `<projectRoot>/.microi-e2e/`;运行产物统一输出到 `<gitRoot>/.tmp/microi-e2e/<项目相对路径>/`,**不再**写入 `tests/e2e/`、根目录 `playwright.config.js` 或 `.env.e2e.example`。
|
|
15
|
+
> - `playwright.config.js` 位于 `.microi-e2e/playwright.config.js`,`testDir` 为 `./` (即 `.microi-e2e/specs/`)
|
|
16
|
+
> - 报告、截图、trace、video 和 test-results 放在对应 `.tmp/microi-e2e/` 项目子目录
|
|
17
|
+
> - 上下文 `.microi-e2e/.microi-playwright-context.json`
|
|
18
|
+
> - 本文档下方仍有大量 `tests/e2e/...` 写法,均为历史风格示意,**实际生成路径以 `.microi-e2e/` 为准**。手写测试(如 `tests/blueprint-e2e.spec.mjs`)不受影响。
|
|
19
|
+
|
|
20
|
+
`E2E` 是 `End-to-End`,中文通常叫"端到端测试"。它强调从用户入口开始,穿过前端页面、接口引擎、表单引擎、权限、缓存、数据库等真实链路,验证一条业务路径是否真的可交付。
|
|
21
|
+
|
|
22
|
+
真实依赖与发布范围沿用 `../workspace-conventions/SKILL.md` 的“平台回归与独立应用测试归属”:常规验证指定 MCP 实际使用的 MySQL、MongoDB、Redis 和 MinIO 或 OSS/HDFS,不要求额外 SQL Server 环境;仅用户明确指定 SQL Server 问题时才做其专项。按 [发布测试矩阵](../microi-system-delivery/references/progressive-02-自动化测试必须覆盖的坑.md#按指定-mcp-选择发布测试矩阵) 记录实际覆盖,保留正常登录、业务闭环与资源收尾,不以连接成功代替真实读写验收。
|
|
23
|
+
|
|
24
|
+
<!-- microi-progressive:begin -->
|
|
25
|
+
<!-- microi-progressive:chunk id=playwright-e2e-000 sha256=f04614f276c139cfa50b9e46e89857675c6dc5e7cf0cfbfde76d6e6dbe9746c9 -->
|
|
26
|
+
## 是否需要 `-e2e` 后缀
|
|
27
|
+
|
|
28
|
+
建议保留 `playwright-e2e` 这个 skill 名称。
|
|
29
|
+
|
|
30
|
+
- Playwright 也能做接口测试、组件测试和截图巡检,但在 Microi 中最关键的价值是“像真实用户一样跑通低代码系统”。
|
|
31
|
+
- `-e2e` 能让 AI 明确区分它和 `v8-debugging`、`v8-crud-api`、`playwright-ct` 等其他能力。
|
|
32
|
+
- 如果未来要补更细的能力,可以新增 `playwright-api` 或 `visual-regression`,不要把当前 skill 改成泛泛的 `playwright`。
|
|
33
|
+
|
|
34
|
+
<!-- /microi-progressive:chunk -->
|
|
35
|
+
<!-- microi-progressive:chunk id=playwright-e2e-001 sha256=703786ae7a5a52cb39664f1c82de7fb7aa7dfece511046d3757da64918c23063 -->
|
|
36
|
+
## 适用范围
|
|
37
|
+
|
|
38
|
+
- PC 管理端:`Microi.Client`、租户后台、运营后台。
|
|
39
|
+
- uni-app H5:移动商城、会员中心、H5 工作台。
|
|
40
|
+
- Page Engine 页面:大屏、仪表盘、官网页面。
|
|
41
|
+
- 接口引擎验收:直接用 Playwright `request` 调 `/apiengine/{ApiEngineKey}`。
|
|
42
|
+
- 交付冒烟:登录、主导航、核心业务流、退出登录、关键页面截图。
|
|
43
|
+
|
|
44
|
+
不适合把 Playwright 用来替代 V8 单函数调试。单个接口引擎的入参输出优先用 VS Code 插件远程执行、MCP `microi_run_engine` 或后端单元测试。
|
|
45
|
+
|
|
46
|
+
<!-- /microi-progressive:chunk -->
|
|
47
|
+
<!-- microi-progressive:chunk id=playwright-e2e-002 sha256=acef3e589cf11f3c197ee0b0ccf56d96b3f286263d54161b3c260e07c2090ed0 -->
|
|
48
|
+
## 临时文件与产物放置规则(必须遵守)
|
|
49
|
+
|
|
50
|
+
AI 在工作区内生成的**一次性临时脚本、诊断文件、截图、测试报告**等,**绝对不能放在工作区根目录**,必须放在以下指定位置:
|
|
51
|
+
|
|
52
|
+
| 类型 | 放置位置 |
|
|
53
|
+
|------|---------|
|
|
54
|
+
| 一次性 Python/JS/PS1 脚本 | `<workspace-root>/.tmp/` |
|
|
55
|
+
| 诊断截图、调试输出 | `<workspace-root>/.tmp/screenshots/` 或子目录 |
|
|
56
|
+
| E2E 配置、用例、帮助器 | `<projectRoot>/.microi-e2e/` |
|
|
57
|
+
| E2E 截图、报告、trace、video、test-results | `<gitRoot>/.tmp/microi-e2e/<项目相对路径>/` |
|
|
58
|
+
| AI 一次性 Playwright 脚本、截图、日志、报告 | `<workspace-root>/.tmp/`、`<workspace-root>/.tmp/screenshots/`、`<workspace-root>/.tmp/reports/` |
|
|
59
|
+
| 性能测试报告 | `<workspace-root>/.microi-performance/`(仅限此目录) |
|
|
60
|
+
|
|
61
|
+
**禁止在根目录创建的文件类型**:`*.mjs`、`*.py`、`*.ps1`、`*.sh`(一次性脚本)、`*.png`、`screenshots/`、`node_modules/`(无 package.json 时)、`obj/`(非 .NET 项目文件)、`dark-mode-*/`、`test-*/` 等临时目录。
|
|
62
|
+
|
|
63
|
+
`.tmp/` 目录已在 `.gitignore` 中排除,AI 可以在此创建临时文件。收尾清理只允许针对已确认归属的本任务子目录;删除前核对解析后的绝对路径、所有权和保留价值,不得整体删除共享 `.tmp/` 或其它任务的产物。临时文件保留不等于允许保留测试进程或容器。
|
|
64
|
+
|
|
65
|
+
**2026-06 强制补充**:AI 手写的一次性 Playwright 验证脚本、运行日志、截图和报告只能写到工作区根目录 `.tmp/`。不要写到 `Microi.Client/`、`Microi.Server/`、`microi.doc/` 或其它子项目目录,即使这些目录已有 `tests/` 目录也不例外。只有 Microi.Agent 插件正式初始化的可复用 E2E 工程,才使用 `.microi-e2e/`。
|
|
66
|
+
|
|
67
|
+
<!-- /microi-progressive:chunk -->
|
|
68
|
+
<!-- microi-progressive:chunk id=playwright-e2e-003 sha256=69b8842a221a0de60f8605c5059deee391be0f16f0b6cbc5ddfb3cfd210268db -->
|
|
69
|
+
## 标准目录
|
|
70
|
+
|
|
71
|
+
前端项目中推荐使用 `tests/e2e`,而不是根目录 `e2e`,这样能和单元测试、组件测试并列。
|
|
72
|
+
|
|
73
|
+
```text
|
|
74
|
+
<frontend-project>/
|
|
75
|
+
playwright.config.js
|
|
76
|
+
tests/
|
|
77
|
+
e2e/
|
|
78
|
+
helpers/
|
|
79
|
+
microi.js
|
|
80
|
+
specs/
|
|
81
|
+
auth.spec.js
|
|
82
|
+
smoke.spec.js
|
|
83
|
+
<business-flow>.spec.js
|
|
84
|
+
screenshots/
|
|
85
|
+
report/
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
<!-- /microi-progressive:chunk -->
|
|
89
|
+
<!-- microi-progressive:chunk id=playwright-e2e-004 sha256=4f5e11baf4651c11b5f9819a0b4f33ce2590db1733d4db72814bd1a25daf56ff -->
|
|
90
|
+
## 必备环境变量
|
|
91
|
+
|
|
92
|
+
```bash
|
|
93
|
+
PW_BASE_URL=http://127.0.0.1:5180
|
|
94
|
+
PW_API_BASE=https://api.example.com
|
|
95
|
+
PW_OS_CLIENT=demo
|
|
96
|
+
PW_WEB_SERVER_COMMAND="npm run dev:h5 -- --host 0.0.0.0 --port 5180"
|
|
97
|
+
PW_WEB_SERVER_URL=http://127.0.0.1:5180
|
|
98
|
+
PW_BROWSER_CHANNEL=msedge
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
常用业务变量:
|
|
102
|
+
|
|
103
|
+
```bash
|
|
104
|
+
PW_LOGIN_ENGINE=member_login
|
|
105
|
+
PW_TEST_ACCOUNT=<从本地配置读取或用环境变量覆盖>
|
|
106
|
+
PW_TEST_PASSWORD=<从本地配置读取或用环境变量覆盖>
|
|
107
|
+
PW_HOME_PATH=/#/pages/index/index
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
<!-- /microi-progressive:chunk -->
|
|
111
|
+
<!-- microi-progressive:chunk id=playwright-e2e-005 sha256=51567cea5fca434f9b031fef0871454100cf4715dfb65695dc1722bd275399be -->
|
|
112
|
+
## 本地测试账号自动发现
|
|
113
|
+
|
|
114
|
+
当没有显式传入 `PW_TEST_ACCOUNT` / `PW_TEST_PASSWORD` / `MICROI_OSCLIENT` 时,AI 不要把账号密码写入后端配置来制造旁路:
|
|
115
|
+
|
|
116
|
+
1. 读取 `Microi.Server/Microi.net.Api/.microi-local`,取得当前环境名。
|
|
117
|
+
2. 账号密码只从用户本轮明确提供、`PW_TEST_ACCOUNT` / `PW_TEST_PASSWORD`、CI Secret 或既有受保护登录态取得;`appsettings.*.json` 不再保存测试账号密码。
|
|
118
|
+
3. 这些值只作为自动化进程的登录输入或接口请求参数使用。日志、最终回复、截图说明、报告和异常消息中必须写成 `<redacted>` 或“本地配置凭据”,不要展开真实账号密码、Token、连接串或 Redis 密码。
|
|
119
|
+
4. 如果凭据不存在或登录失败,再报告具体阻塞点,例如“未提供受保护测试凭据”“本地后端未启动”“登录接口返回 Code=0”,不要泛泛说无法测试。
|
|
120
|
+
|
|
121
|
+
### 跨 ApiBase / OsClient 本地自动化(强制)
|
|
122
|
+
|
|
123
|
+
1. 复用工作区唯一的 `61500` Vite 服务,但每组 `ApiBase + OsClient` 创建独立
|
|
124
|
+
`browser.newContext()`;禁止在同一个 context 的多个 Page 中混测不同租户。
|
|
125
|
+
2. 本地入口固定把参数放在 `#` 前:
|
|
126
|
+
`http://localhost:61500/?OsClient=${encodeURIComponent(osClient)}&ApiBase=${encodeURIComponent(apiBase)}#/route`。
|
|
127
|
+
URL 参数应覆盖 `index.html`、`src/config.json`、Pinia 和 localStorage。
|
|
128
|
+
3. 页面初始化后读取 `window.__MICROI_RUNTIME_ENDPOINT__`,断言实际 ApiBase/OsClient 与测试目标
|
|
129
|
+
完全一致再登录或点击业务。该对象不得包含 Token。
|
|
130
|
+
4. 从线上地址复现时,先在一次性独立 context 读取上述对象;旧版回退到页面全局值、
|
|
131
|
+
`localStorage['microi.net']` 和域名租户解析。不能根据标题猜租户,也不能复用线上 context 跑本地。
|
|
132
|
+
5. 人工第二租户至少使用无痕窗口;多个无痕窗口可能共享同一临时会话,更多并行目标使用独立
|
|
133
|
+
Profile/`--user-data-dir`。自动化收尾只关闭自己创建的 context/browser。
|
|
134
|
+
|
|
135
|
+
<!-- /microi-progressive:chunk -->
|
|
136
|
+
<!-- microi-progressive:chunk id=playwright-e2e-006 sha256=88e1002cae934acd2de5af2f77f371a9ea152a525eecf11b49fe182b16a56044 -->
|
|
137
|
+
## 后端改动后的 E2E 前置动作
|
|
138
|
+
|
|
139
|
+
如果本轮任务修改过 `Microi.Server/**` 后端源码、配置、控制器、服务、依赖项目或接口行为,跑 Playwright、页面截图、接口验收或前后端联调前,必须先按 `workspace-conventions` 的“后端代码改动后的重启验收”完成:
|
|
140
|
+
|
|
141
|
+
1. 编译后端。
|
|
142
|
+
2. 停止旧的本地 `Microi.net.Api` 进程。
|
|
143
|
+
3. 在 `Microi.Server/Microi.net.Api` 目录用 `dotnet run --launch-profile Microi.net.Api` 重新启动。
|
|
144
|
+
4. 从 launch profile 回读实际地址(当前标准工作区为 `https://localhost:61501`),验证端口已监听并且进程未立即崩溃。
|
|
145
|
+
|
|
146
|
+
不要只说“代码已编译”或“需要用户自己重启后端”;除非用户明确要求不要中断当前服务,否则 AI 要主动完成重启。
|
|
147
|
+
|
|
148
|
+
<!-- /microi-progressive:chunk -->
|
|
149
|
+
<!-- microi-progressive:chunk id=playwright-e2e-007 sha256=948194cce3a29cfec216546acab77314ccaa1c0afad3cbcfd6b426a94f36d4ac -->
|
|
150
|
+
## 服务自启动纪律(必做)
|
|
151
|
+
|
|
152
|
+
执行自动化测试、截图巡检、接口引擎回读、`/apiengine/{key}` 验收时,如果本地后端或前端不可达,不能把 `fetch failed`、`ECONNREFUSED`、`000 Failed to connect`、端口无人监听当作任务终点。必须先自动启动所需服务,再继续完整验证。
|
|
153
|
+
|
|
154
|
+
同一工作区有多个 AI 对话时,服务自启动还必须遵守共享生命周期:
|
|
155
|
+
|
|
156
|
+
- 先执行 `../workspace-conventions/SKILL.md` 的“本地测试程序与依赖生命周期”统一规则:默认复用当前 MCP 对应的 MySQL、Redis、MongoDB、MinIO/OSS,以及健康本地源码程序或隔离目录的编译产物;不按测试任务重复创建 Docker/Compose,不例行询问临时容器许可。需要双节点时启动两个本机程序进程连接同组依赖,不等于建立两套 Docker 环境。不得已创建的临时容器和纯测试资源每轮必须精确删除并回读。
|
|
157
|
+
- API 服务启动前执行 `node Microi.Server/tools/release-lock.mjs assert api <工作区根>`,PC 服务使用 `assert pc`。Playwright `webServer`、自愈脚本或 AI 只在对应范围发布时等待;官网/Agent 发布不阻塞 `61500/61501`。同时启动前后端时分别检查两项。旧锁仅在真实进程证明所属范围后缩小阻塞范围,未知锁继续保护,不得删除活跃锁。
|
|
158
|
+
- 端口健康且 PID/命令行属于当前工作区时直接复用,不得每个对话都无条件“先杀再启动”。
|
|
159
|
+
必须重载源码时才串行重启,并在状态播报中说明旧/新 PID。
|
|
160
|
+
- 本地长期后端使用项目目录中的 `dotnet run --launch-profile Microi.net.Api`,禁止把
|
|
161
|
+
`bin/Release/net10.0` 或 `bin/Release/publish` 的 DLL 作为长期测试服务,否则会锁住
|
|
162
|
+
一键发布的 Release 输出。
|
|
163
|
+
- 每次测试成功、失败、取消或因资源不足暂停时,都必须结束本次创建的 browser/context、临时 webServer 及其它自有测试进程;按统一规则收回新建临时容器,并独立回读进程、监听端口和容器状态确认无残留。复用的既有共享服务保持原状。VS Code 持有的
|
|
164
|
+
`playwright test-server` 与用户 Edge/Chrome 不属于孤儿清理;禁止按进程名结束所有
|
|
165
|
+
`node/dotnet/chrome/msedge`。
|
|
166
|
+
- 只读盘点或精确停止使用 `Microi.Server/tools/Microi.LocalProcessManager.ps1` 的
|
|
167
|
+
`Status`、`StopBackend`、`StopFrontend`,不能让用户在任务管理器里猜 PID。
|
|
168
|
+
|
|
169
|
+
默认本地后端:
|
|
170
|
+
|
|
171
|
+
```powershell
|
|
172
|
+
Push-Location Microi.Server/Microi.net.Api
|
|
173
|
+
dotnet run --launch-profile Microi.net.Api
|
|
174
|
+
Pop-Location
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
普通本地启动不要手动设置 `ASPNETCORE_ENVIRONMENT` / `DOTNET_ENVIRONMENT`;后端会读取 `Microi.Server/Microi.net.Api/.microi-local`,再加载对应的 `appsettings.{Env}.json`。如果测试脚本显式注入环境变量,则以脚本注入为准。
|
|
178
|
+
|
|
179
|
+
默认 PC 前端:
|
|
180
|
+
|
|
181
|
+
```powershell
|
|
182
|
+
Push-Location Microi.Client
|
|
183
|
+
npm run dev -- --host 0.0.0.0 --port 61500
|
|
184
|
+
Pop-Location
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
uni-app H5 或移动端前端按项目自身命令启动,例如 `npm run dev:h5 -- --host 0.0.0.0 --port 5192` 或测试配置里的 `PW_WEB_SERVER_COMMAND`。如果目标测试同时依赖 PC 管理端和移动 H5,需要分别启动对应前端;不要用一个前端服务替代另一个业务入口。
|
|
188
|
+
|
|
189
|
+
执行顺序:先检查端口/健康接口是否可达;不可达则用后台终端启动;等待服务输出监听地址;再重试接口同步、页面打开、Playwright 截图和断言。只有启动命令失败、缺少依赖、数据库连接失败、端口冲突无法自动换端口且无替代配置时,才算真正阻塞,并且要报告具体失败命令和错误。
|
|
190
|
+
|
|
191
|
+
<!-- /microi-progressive:chunk -->
|
|
192
|
+
## 详细参考路由(渐进披露)
|
|
193
|
+
|
|
194
|
+
### 菜单微服务生命周期验收(强制)
|
|
195
|
+
|
|
196
|
+
菜单型 MicroService 使用 `runtime-keep-alive` 单一缓存所有者。E2E 必须覆盖至少 3 条子路由连续切换 8 轮,确认返回后状态仍在、页面无永久骨架屏或空白;继续打开第 6 个实例,确认 LRU 只淘汰最久未使用的隐藏实例。还要观察 `appstate-change`:`afterhidden` 后后台任务应暂停,`aftershow` 后应幂等恢复;关闭 Tab、关闭其它/全部以及退出登录后,对应运行时必须被销毁。
|
|
197
|
+
|
|
198
|
+
仅在当前任务涉及对应主题时读取;下列文件合计保留了原 SKILL.md 的全部详细知识。
|
|
199
|
+
|
|
200
|
+
- [references/progressive-01-全自动登录-免验证码-但不免密码-必读.md](references/progressive-01-全自动登录-免验证码-但不免密码-必读.md):全自动登录(免验证码,但不免密码)——必读;表单引擎卡死/递归更新全自动化诊断;移动端视觉与资源验收;测试证据必须绑定需求编号;移动端/H5 回归纪律
|
|
201
|
+
- [references/progressive-02-文字对比度与可读性自动化检查-必做.md](references/progressive-02-文字对比度与可读性自动化检查-必做.md):文字对比度与可读性自动化检查(必做);安装;playwright.config.js 模板
|
|
202
|
+
- [references/progressive-03-microi-helper-模板.md](references/progressive-03-microi-helper-模板.md):Microi helper 模板;典型用例;Microi 专属测试策略;最少冒烟集;完整业务验收门槛;与 MCP 的配合;与 VS Code 插件的配合
|
|
203
|
+
- [references/progressive-04-ci-建议.md](references/progressive-04-ci-建议.md):CI 建议;常见问题;前端微服务 E2E 必测点;动态模块按钮验收
|
|
204
|
+
<!-- microi-progressive:end -->
|
|
@@ -6,6 +6,14 @@ import { fileURLToPath } from 'node:url'
|
|
|
6
6
|
const skillsRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..')
|
|
7
7
|
const manifest = JSON.parse(fs.readFileSync(path.join(skillsRoot, '.progressive-disclosure-manifest.json'), 'utf8'))
|
|
8
8
|
const hash = (value) => crypto.createHash('sha256').update(value).digest('hex')
|
|
9
|
+
// Git 检出可转换 LF/CRLF;只兼容这两种逐字符换行表示,正文和末尾换行仍必须完整匹配。
|
|
10
|
+
const getTextForHash = (value, expected) => {
|
|
11
|
+
if (hash(value) === expected) return value
|
|
12
|
+
const lf = value.replace(/\r\n/g, '\n')
|
|
13
|
+
if (hash(lf) === expected) return lf
|
|
14
|
+
const crlf = lf.replace(/\n/g, '\r\n')
|
|
15
|
+
return hash(crlf) === expected ? crlf : null
|
|
16
|
+
}
|
|
9
17
|
const lineCount = (value) => value.length === 0 ? 0 : value.split(/\r?\n/).length
|
|
10
18
|
|
|
11
19
|
// 可只验证显式修改的 Skill;默认仍检查全库,不能为并行工作区的历史漂移改写共同基线。
|
|
@@ -21,7 +29,8 @@ for (const [skillName, skill] of selected) {
|
|
|
21
29
|
const begin = entry.indexOf('<!-- microi-progressive:begin -->')
|
|
22
30
|
if (begin < 0) throw new Error(`${skillName}: missing progressive begin marker`)
|
|
23
31
|
const prefix = entry.slice(0, begin)
|
|
24
|
-
|
|
32
|
+
const checkedPrefix = getTextForHash(prefix, skill.prefixSha256)
|
|
33
|
+
if (checkedPrefix === null) throw new Error(`${skillName}: entry prefix changed`)
|
|
25
34
|
if (lineCount(entry) > manifest.policy.maxEntryLines) throw new Error(`${skillName}: entry exceeds line budget`)
|
|
26
35
|
|
|
27
36
|
const sources = new Map([[`${skillName}/SKILL.md`, entry]])
|
|
@@ -44,11 +53,13 @@ for (const [skillName, skill] of selected) {
|
|
|
44
53
|
const contentEnd = source.indexOf(close, contentStart)
|
|
45
54
|
if (contentEnd < 0) throw new Error(`${skillName}: unterminated chunk ${chunk.id}`)
|
|
46
55
|
const raw = source.slice(contentStart, contentEnd)
|
|
47
|
-
|
|
48
|
-
|
|
56
|
+
const checkedRaw = getTextForHash(raw, chunk.sha256)
|
|
57
|
+
if (checkedRaw === null) throw new Error(`${skillName}: chunk ${chunk.id} changed`)
|
|
58
|
+
ordered[chunk.ordinal] = checkedRaw
|
|
49
59
|
checkedChunks += 1
|
|
50
60
|
}
|
|
51
|
-
|
|
61
|
+
// 每段使用其登记SHA已精确匹配的换行表示,恢复历史混合EOL;总原文仍必须逐字节命中。
|
|
62
|
+
const reconstructed = checkedPrefix + ordered.join('')
|
|
52
63
|
if (hash(reconstructed) !== skill.originalSha256) {
|
|
53
64
|
throw new Error(`${skillName}: reconstructed knowledge differs from original`)
|
|
54
65
|
}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import assert from 'node:assert/strict'
|
|
2
|
+
import crypto from 'node:crypto'
|
|
3
|
+
import fs from 'node:fs'
|
|
4
|
+
import path from 'node:path'
|
|
5
|
+
import { spawnSync } from 'node:child_process'
|
|
6
|
+
import { fileURLToPath } from 'node:url'
|
|
7
|
+
import test from 'node:test'
|
|
8
|
+
|
|
9
|
+
const scriptsRoot = path.dirname(fileURLToPath(import.meta.url))
|
|
10
|
+
const validator = path.join(scriptsRoot, 'validate-progressive-disclosure.mjs')
|
|
11
|
+
const tempRoot = path.resolve(scriptsRoot, '../../.tmp/progressive-disclosure-eol-regression')
|
|
12
|
+
const hash = value => crypto.createHash('sha256').update(value).digest('hex')
|
|
13
|
+
const eol = (value, ending) => value.replace(/\r\n/g, '\n').replace(/\n/g, ending)
|
|
14
|
+
const prefix = '---\nname: sample\n---\n# Sample\n\n'
|
|
15
|
+
const bodies = ['## First\nALPHA\n\n', '## Second\nBETA\n\n']
|
|
16
|
+
const close = '<!-- /microi-progressive:chunk -->'
|
|
17
|
+
|
|
18
|
+
function runFixture(options = {}) {
|
|
19
|
+
const { sourceEol = '\n', manifestEol = '\n', prefixManifestEol = manifestEol, chunkManifestEols = [manifestEol, manifestEol], referenceEol = sourceEol, mutation = '' } = options
|
|
20
|
+
fs.mkdirSync(tempRoot, { recursive: true })
|
|
21
|
+
const root = fs.mkdtempSync(path.join(tempRoot, 'case-'))
|
|
22
|
+
// 只删除本次创建的普通私有夹具;原校验器与清单始终只读。
|
|
23
|
+
try {
|
|
24
|
+
const scripts = path.join(root, 'scripts')
|
|
25
|
+
fs.mkdirSync(scripts)
|
|
26
|
+
fs.mkdirSync(path.join(root, 'sample/references'), { recursive: true })
|
|
27
|
+
fs.copyFileSync(validator, path.join(scripts, 'validate-progressive-disclosure.mjs'))
|
|
28
|
+
const chunks = bodies.map((body, ordinal) => ({
|
|
29
|
+
id: `sample-${ordinal}`, ordinal,
|
|
30
|
+
destination: ordinal === 0 ? 'sample/SKILL.md' : 'sample/references/detail.md',
|
|
31
|
+
sha256: hash(eol(body, chunkManifestEols[ordinal]))
|
|
32
|
+
}))
|
|
33
|
+
if (mutation === 'reordered') chunks.forEach(chunk => { chunk.ordinal = 1 - chunk.ordinal })
|
|
34
|
+
const manifest = {
|
|
35
|
+
version: 1,
|
|
36
|
+
policy: { maxEntryLines: 285 },
|
|
37
|
+
skills: { sample: {
|
|
38
|
+
prefixSha256: hash(eol(prefix, prefixManifestEol)),
|
|
39
|
+
originalSha256: hash(eol(prefix, prefixManifestEol) + bodies.map((body, index) => eol(body, chunkManifestEols[index])).join('')),
|
|
40
|
+
references: [{ path: 'references/detail.md' }], chunks
|
|
41
|
+
} }
|
|
42
|
+
}
|
|
43
|
+
if (mutation === 'original-hash') manifest.skills.sample.originalSha256 = '0'.repeat(64)
|
|
44
|
+
const block = (index, body) => `<!-- microi-progressive:chunk id=${chunks[index].id} sha256=${chunks[index].sha256} -->\n${body}${close}\n`
|
|
45
|
+
let actualPrefix = prefix
|
|
46
|
+
let firstBody = bodies[0]
|
|
47
|
+
if (mutation === 'prefix-text') actualPrefix = prefix.replace('Sample', 'Changed')
|
|
48
|
+
if (mutation === 'prefix-whitespace') actualPrefix = prefix.replace('# Sample', '# Sample ')
|
|
49
|
+
if (mutation === 'chunk-text') firstBody = firstBody.replace('ALPHA', 'DELTA')
|
|
50
|
+
if (mutation === 'trailing-newline') firstBody = firstBody.slice(0, -1)
|
|
51
|
+
if (mutation === 'lone-cr') firstBody = firstBody.replace('ALPHA', 'AL\rPHA')
|
|
52
|
+
let entry = actualPrefix + '<!-- microi-progressive:begin -->\n' + block(0, firstBody) + '<!-- microi-progressive:end -->\n'
|
|
53
|
+
if (mutation === 'begin-missing') entry = entry.replace('<!-- microi-progressive:begin -->', '<!-- removed -->')
|
|
54
|
+
const reference = mutation === 'chunk-missing' ? '# Empty reference\n' : '# Reference\n' + block(1, bodies[1])
|
|
55
|
+
const files = [path.join(root, '.progressive-disclosure-manifest.json'), path.join(root, 'sample/SKILL.md'), path.join(root, 'sample/references/detail.md')]
|
|
56
|
+
fs.writeFileSync(files[0], JSON.stringify(manifest))
|
|
57
|
+
fs.writeFileSync(files[1], eol(entry, sourceEol))
|
|
58
|
+
fs.writeFileSync(files[2], eol(reference, referenceEol))
|
|
59
|
+
const before = files.map(file => hash(fs.readFileSync(file)))
|
|
60
|
+
const result = spawnSync(process.execPath, [path.join(scripts, 'validate-progressive-disclosure.mjs'), 'sample'], {
|
|
61
|
+
cwd: root, encoding: 'utf8', timeout: 10_000, windowsHide: true
|
|
62
|
+
})
|
|
63
|
+
assert.equal(result.error, undefined)
|
|
64
|
+
assert.equal(result.signal, null)
|
|
65
|
+
assert.deepEqual(files.map(file => hash(fs.readFileSync(file))), before, 'validation must not rewrite source or manifest')
|
|
66
|
+
return result
|
|
67
|
+
} finally {
|
|
68
|
+
assert.equal(fs.realpathSync(root), root)
|
|
69
|
+
assert.equal(fs.lstatSync(root).isSymbolicLink(), false)
|
|
70
|
+
assert.ok(root.startsWith(tempRoot + path.sep))
|
|
71
|
+
fs.rmSync(root, { recursive: true })
|
|
72
|
+
assert.equal(fs.existsSync(root), false)
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
for (const [name, options] of [
|
|
77
|
+
['exact LF manifest and source', {}],
|
|
78
|
+
['mixed recorded EOL reconstructs exact original after LF checkout', { sourceEol: '\n', prefixManifestEol: '\r\n', chunkManifestEols: ['\n', '\r\n'] }],
|
|
79
|
+
['mixed recorded EOL reconstructs exact original after CRLF checkout', { sourceEol: '\r\n', prefixManifestEol: '\n', chunkManifestEols: ['\r\n', '\n'] }],
|
|
80
|
+
['exact CRLF manifest and source', { sourceEol: '\r\n', manifestEol: '\r\n' }],
|
|
81
|
+
['CRLF manifest survives LF checkout', { sourceEol: '\n', manifestEol: '\r\n' }],
|
|
82
|
+
['LF manifest survives CRLF checkout', { sourceEol: '\r\n', manifestEol: '\n' }],
|
|
83
|
+
['reference checkout ending may differ without changing text', { sourceEol: '\n', referenceEol: '\r\n', manifestEol: '\r\n' }]
|
|
84
|
+
]) {
|
|
85
|
+
test(name, () => {
|
|
86
|
+
const result = runFixture(options)
|
|
87
|
+
assert.equal(result.status, 0, result.stderr)
|
|
88
|
+
assert.match(result.stdout, /Validated 1 skills and 2 lossless chunks/)
|
|
89
|
+
})
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
for (const [name, mutation, error] of [
|
|
93
|
+
['prefix body remains significant', 'prefix-text', /entry prefix changed/],
|
|
94
|
+
['prefix whitespace is not trimmed', 'prefix-whitespace', /entry prefix changed/],
|
|
95
|
+
['chunk body remains significant', 'chunk-text', /chunk sample-0 changed/],
|
|
96
|
+
['manifest chunk reordering remains rejected', 'reordered', /reconstructed knowledge differs/],
|
|
97
|
+
['wrong original hash remains rejected', 'original-hash', /reconstructed knowledge differs/],
|
|
98
|
+
['missing chunk remains rejected', 'chunk-missing', /missing chunk sample-1/],
|
|
99
|
+
['last newline remains significant', 'trailing-newline', /chunk sample-0 changed/],
|
|
100
|
+
['standalone CR is not a line ending conversion', 'lone-cr', /chunk sample-0 changed/],
|
|
101
|
+
['missing progressive begin remains rejected', 'begin-missing', /missing progressive begin marker/]
|
|
102
|
+
]) {
|
|
103
|
+
test(name, () => {
|
|
104
|
+
const result = runFixture({ sourceEol: '\n', manifestEol: '\r\n', mutation })
|
|
105
|
+
assert.equal(result.status, 1)
|
|
106
|
+
assert.match(result.stderr, error)
|
|
107
|
+
})
|
|
108
|
+
}
|