modao-prd-cli 0.1.0__tar.gz

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.
Files changed (40) hide show
  1. modao_prd_cli-0.1.0/LICENSE +22 -0
  2. modao_prd_cli-0.1.0/PKG-INFO +108 -0
  3. modao_prd_cli-0.1.0/README.md +82 -0
  4. modao_prd_cli-0.1.0/modao_prd_cli/__init__.py +1 -0
  5. modao_prd_cli-0.1.0/modao_prd_cli/modao_prd/__init__.py +4 -0
  6. modao_prd_cli-0.1.0/modao_prd_cli/modao_prd/__main__.py +7 -0
  7. modao_prd_cli-0.1.0/modao_prd_cli/modao_prd/browser.py +578 -0
  8. modao_prd_cli-0.1.0/modao_prd_cli/modao_prd/capture_evidence.py +547 -0
  9. modao_prd_cli-0.1.0/modao_prd_cli/modao_prd/classifier.py +96 -0
  10. modao_prd_cli-0.1.0/modao_prd_cli/modao_prd/cli.py +205 -0
  11. modao_prd_cli-0.1.0/modao_prd_cli/modao_prd/errors.py +31 -0
  12. modao_prd_cli-0.1.0/modao_prd_cli/modao_prd/evidence.py +207 -0
  13. modao_prd_cli-0.1.0/modao_prd_cli/modao_prd/explorer.py +300 -0
  14. modao_prd_cli-0.1.0/modao_prd_cli/modao_prd/extractor.py +465 -0
  15. modao_prd_cli-0.1.0/modao_prd_cli/modao_prd/models.py +56 -0
  16. modao_prd_cli-0.1.0/modao_prd_cli/modao_prd/normalizer.py +135 -0
  17. modao_prd_cli-0.1.0/modao_prd_cli/modao_prd/schemas/coverage-1.0.json +15 -0
  18. modao_prd_cli-0.1.0/modao_prd_cli/modao_prd/schemas/document-2.0.json +21 -0
  19. modao_prd_cli-0.1.0/modao_prd_cli/modao_prd/schemas/document-2.1.json +31 -0
  20. modao_prd_cli-0.1.0/modao_prd_cli/modao_prd/schemas/manifest-1.0.json +28 -0
  21. modao_prd_cli-0.1.0/modao_prd_cli/modao_prd/tests/__init__.py +1 -0
  22. modao_prd_cli-0.1.0/modao_prd_cli/modao_prd/tests/fixtures/modao_sample.html +20 -0
  23. modao_prd_cli-0.1.0/modao_prd_cli/modao_prd/tests/test_browser.py +54 -0
  24. modao_prd_cli-0.1.0/modao_prd_cli/modao_prd/tests/test_classifier.py +32 -0
  25. modao_prd_cli-0.1.0/modao_prd_cli/modao_prd/tests/test_cli.py +88 -0
  26. modao_prd_cli-0.1.0/modao_prd_cli/modao_prd/tests/test_extractor.py +57 -0
  27. modao_prd_cli-0.1.0/modao_prd_cli/modao_prd/tests/test_full_e2e.py +23 -0
  28. modao_prd_cli-0.1.0/modao_prd_cli/modao_prd/tests/test_writers.py +79 -0
  29. modao_prd_cli-0.1.0/modao_prd_cli/modao_prd/writers.py +468 -0
  30. modao_prd_cli-0.1.0/modao_prd_cli.egg-info/PKG-INFO +108 -0
  31. modao_prd_cli-0.1.0/modao_prd_cli.egg-info/SOURCES.txt +38 -0
  32. modao_prd_cli-0.1.0/modao_prd_cli.egg-info/dependency_links.txt +1 -0
  33. modao_prd_cli-0.1.0/modao_prd_cli.egg-info/entry_points.txt +2 -0
  34. modao_prd_cli-0.1.0/modao_prd_cli.egg-info/requires.txt +7 -0
  35. modao_prd_cli-0.1.0/modao_prd_cli.egg-info/top_level.txt +1 -0
  36. modao_prd_cli-0.1.0/pyproject.toml +48 -0
  37. modao_prd_cli-0.1.0/setup.cfg +4 -0
  38. modao_prd_cli-0.1.0/tests/test_capture_evidence.py +190 -0
  39. modao_prd_cli-0.1.0/tests/test_evidence.py +132 -0
  40. modao_prd_cli-0.1.0/tests/test_schemas.py +13 -0
@@ -0,0 +1,22 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 modao-prd-cli contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
22
+
@@ -0,0 +1,108 @@
1
+ Metadata-Version: 2.4
2
+ Name: modao-prd-cli
3
+ Version: 0.1.0
4
+ Summary: Extract public Modao prototype shares into agent-friendly JSON, Markdown, and NDJSON
5
+ Author: modao-prd-cli contributors
6
+ License-Expression: MIT
7
+ Keywords: modao,prototype,prd,cli,agent,playwright
8
+ Classifier: Development Status :: 3 - Alpha
9
+ Classifier: Environment :: Console
10
+ Classifier: Intended Audience :: Developers
11
+ Classifier: Programming Language :: Python :: 3
12
+ Classifier: Programming Language :: Python :: 3.10
13
+ Classifier: Programming Language :: Python :: 3.11
14
+ Classifier: Programming Language :: Python :: 3.12
15
+ Classifier: Topic :: Software Development :: Documentation
16
+ Requires-Python: >=3.10
17
+ Description-Content-Type: text/markdown
18
+ License-File: LICENSE
19
+ Requires-Dist: click<9.0,>=8.1
20
+ Requires-Dist: playwright<2.0,>=1.62
21
+ Provides-Extra: dev
22
+ Requires-Dist: build>=1.2; extra == "dev"
23
+ Requires-Dist: pytest>=7; extra == "dev"
24
+ Requires-Dist: twine>=5; extra == "dev"
25
+ Dynamic: license-file
26
+
27
+ # modao-prd-cli
28
+
29
+ `modao-prd-cli` 将墨刀公开分享页采集为便于 Agent 读取的结构化文档和证据包。它使用本机 Chrome/Chromium 渲染页面,不登录墨刀、不保存 Cookie、不调用远程解析服务。
30
+
31
+ ## 安装
32
+
33
+ ```bash
34
+ python3 -m pip install modao-prd-cli
35
+ python3 -m playwright install chromium # doctor 未发现可用浏览器时执行
36
+ modao-prd-cli doctor --json
37
+ ```
38
+
39
+ ## 使用
40
+
41
+ ```bash
42
+ modao-prd-cli inspect "https://modao.cc/proto/<project-id>/sharing?view_mode=inspect" --json
43
+
44
+ modao-prd-cli export "https://modao.cc/proto/<project-id>/sharing?view_mode=inspect" \
45
+ --format all
46
+ ```
47
+
48
+ 不传 `--output` 时,工具会从当前工作目录向上查找最近的 Git 根目录,并将结果写入该项目根目录下的 `.modao-prd/<project-id>/`。如果当前目录不属于 Git 项目,则使用当前工作目录作为项目根目录。首次默认导出会在项目根目录的 `.gitignore` 中幂等加入 `/.modao-prd/`。
49
+
50
+ 如需指定其他位置,显式传入 `--output` 即可;此时不会修改项目的 `.gitignore`:
51
+
52
+ ```bash
53
+ modao-prd-cli export "<墨刀公开分享链接>" \
54
+ --format all --output ./modao-export
55
+ ```
56
+
57
+ 导出默认使用精简证据模式:保留结构化事实、DOM 布局快照、整页截图、可读画布截图和有效原型图片,过滤运行时代码、埋点资源和常见 UI 图标。DOM 快照也会排除 `script/style` 等运行时节点,避免把框架代码混进需求证据。需要排查渲染问题或核对视觉/无障碍细节时,再显式开启完整证据(debug/full)模式:
58
+
59
+ ```bash
60
+ modao-prd-cli export "<墨刀公开分享链接>" --format all \
61
+ --evidence full --headed --explore safe --max-states 50 --max-depth 3 \
62
+ --max-actions 200 --timeout 30 --max-duration 120 \
63
+ --max-item-mb 10 --max-total-mb 200
64
+ ```
65
+
66
+ 只支持 HTTPS 的墨刀公开分享路径:`https://modao.cc/proto/<project-id>/sharing`。
67
+
68
+ ## 输出
69
+
70
+ ```text
71
+ .modao-prd/<project-id>/
72
+ ├── manifest.json
73
+ ├── document.json
74
+ ├── document.md
75
+ ├── document.ndjson
76
+ ├── coverage.json
77
+ └── evidence/
78
+ ├── state-001.dom.json
79
+ ├── state-001.screen-001.png # essential/full:每个画布一张完整大图
80
+ ├── state-001.full.png # --evidence full
81
+ ├── state-001.rendered.html # --evidence full
82
+ ├── state-001.aria.yaml # --evidence full
83
+ ├── assets/ # 过滤后的原型图片
84
+ └── network/ # --evidence full
85
+ ```
86
+
87
+ 读取顺序建议为 `manifest.json → document.json → coverage.json → evidence/`。
88
+
89
+ - `document.json` 使用 schema 2.1,是面向 Agent 的紧凑精简投影,区分 `facts`(页面事实)和 `derived`(确定性启发式推导);需要人读时使用 `document.md`,需要逐条检索时使用 `document.ndjson`。
90
+ - `document.md` 是人工阅读摘要,不替代原始证据。
91
+ - `document.ndjson` 是逐行知识单元,适合 RAG、向量化和增量处理。
92
+ - 默认精简模式输出 DOM/布局证据、可读画布截图和过滤后的原型图片;`--evidence full` 额外保存浏览器整页截图、渲染 HTML、ARIA、相关 JSON/HTML 网络正文和网络索引。精简模式不会为了“完整”保存无助于需求分析的浏览器整页截图、JS、CSS、埋点或通用图标。
93
+ - 每个画布默认只生成一张原始比例的完整大图,例如 `screen-001.png`,不再切分成多张图片;Agent 可按需放大图片,具体文本和结构优先从 `document.json`、`dom.json` 读取。
94
+ - `--headed` 只控制是否显示浏览器窗口,便于 debug,不会单独切换证据级别;完整证据必须显式指定 `--evidence full`。
95
+ - `coverage.json` 记录访问到的状态、动作、跳过项和部分完成原因。
96
+
97
+ `document.json` 不重复内嵌完整 DOM 父子关系,也不重复输出旧版的 `document.blocks`、顶层 `requirements`、`tables` 等别名;布局树保存在 `evidence/state-*.dom.json`,主文档通过状态和精简证据引用回查。所有页面事实尽量带 `state_id`、`screen_id` 和核心 `evidence_ids`。发生冲突时,以截图、HTML、DOM、ARIA 和原始表格为准;`derived` 只作为分析线索。
98
+
99
+ 退出码为 `0`(在策略范围内完成)、`2`(得到可用但部分完成的证据包)、`1`(未得到可用文档)。
100
+
101
+ ## 限制
102
+
103
+ - 不支持私有项目、登录态、评论和评审记录。
104
+ - 不点击抽奖、支付、购买、领取、提交、保存、发布、删除等高风险控件。
105
+ - 不访问页面中的外部链接;跨域 iframe、Canvas、视觉表格和图片文字只保存证据并标记未结构化区域。
106
+ - 不承诺理解业务语义;原型示例、日期、概率和外部文档引用需要人工确认。
107
+
108
+ Agent 使用说明见 [`skills/modao-prd-cli/SKILL.md`](skills/modao-prd-cli/SKILL.md)。
@@ -0,0 +1,82 @@
1
+ # modao-prd-cli
2
+
3
+ `modao-prd-cli` 将墨刀公开分享页采集为便于 Agent 读取的结构化文档和证据包。它使用本机 Chrome/Chromium 渲染页面,不登录墨刀、不保存 Cookie、不调用远程解析服务。
4
+
5
+ ## 安装
6
+
7
+ ```bash
8
+ python3 -m pip install modao-prd-cli
9
+ python3 -m playwright install chromium # doctor 未发现可用浏览器时执行
10
+ modao-prd-cli doctor --json
11
+ ```
12
+
13
+ ## 使用
14
+
15
+ ```bash
16
+ modao-prd-cli inspect "https://modao.cc/proto/<project-id>/sharing?view_mode=inspect" --json
17
+
18
+ modao-prd-cli export "https://modao.cc/proto/<project-id>/sharing?view_mode=inspect" \
19
+ --format all
20
+ ```
21
+
22
+ 不传 `--output` 时,工具会从当前工作目录向上查找最近的 Git 根目录,并将结果写入该项目根目录下的 `.modao-prd/<project-id>/`。如果当前目录不属于 Git 项目,则使用当前工作目录作为项目根目录。首次默认导出会在项目根目录的 `.gitignore` 中幂等加入 `/.modao-prd/`。
23
+
24
+ 如需指定其他位置,显式传入 `--output` 即可;此时不会修改项目的 `.gitignore`:
25
+
26
+ ```bash
27
+ modao-prd-cli export "<墨刀公开分享链接>" \
28
+ --format all --output ./modao-export
29
+ ```
30
+
31
+ 导出默认使用精简证据模式:保留结构化事实、DOM 布局快照、整页截图、可读画布截图和有效原型图片,过滤运行时代码、埋点资源和常见 UI 图标。DOM 快照也会排除 `script/style` 等运行时节点,避免把框架代码混进需求证据。需要排查渲染问题或核对视觉/无障碍细节时,再显式开启完整证据(debug/full)模式:
32
+
33
+ ```bash
34
+ modao-prd-cli export "<墨刀公开分享链接>" --format all \
35
+ --evidence full --headed --explore safe --max-states 50 --max-depth 3 \
36
+ --max-actions 200 --timeout 30 --max-duration 120 \
37
+ --max-item-mb 10 --max-total-mb 200
38
+ ```
39
+
40
+ 只支持 HTTPS 的墨刀公开分享路径:`https://modao.cc/proto/<project-id>/sharing`。
41
+
42
+ ## 输出
43
+
44
+ ```text
45
+ .modao-prd/<project-id>/
46
+ ├── manifest.json
47
+ ├── document.json
48
+ ├── document.md
49
+ ├── document.ndjson
50
+ ├── coverage.json
51
+ └── evidence/
52
+ ├── state-001.dom.json
53
+ ├── state-001.screen-001.png # essential/full:每个画布一张完整大图
54
+ ├── state-001.full.png # --evidence full
55
+ ├── state-001.rendered.html # --evidence full
56
+ ├── state-001.aria.yaml # --evidence full
57
+ ├── assets/ # 过滤后的原型图片
58
+ └── network/ # --evidence full
59
+ ```
60
+
61
+ 读取顺序建议为 `manifest.json → document.json → coverage.json → evidence/`。
62
+
63
+ - `document.json` 使用 schema 2.1,是面向 Agent 的紧凑精简投影,区分 `facts`(页面事实)和 `derived`(确定性启发式推导);需要人读时使用 `document.md`,需要逐条检索时使用 `document.ndjson`。
64
+ - `document.md` 是人工阅读摘要,不替代原始证据。
65
+ - `document.ndjson` 是逐行知识单元,适合 RAG、向量化和增量处理。
66
+ - 默认精简模式输出 DOM/布局证据、可读画布截图和过滤后的原型图片;`--evidence full` 额外保存浏览器整页截图、渲染 HTML、ARIA、相关 JSON/HTML 网络正文和网络索引。精简模式不会为了“完整”保存无助于需求分析的浏览器整页截图、JS、CSS、埋点或通用图标。
67
+ - 每个画布默认只生成一张原始比例的完整大图,例如 `screen-001.png`,不再切分成多张图片;Agent 可按需放大图片,具体文本和结构优先从 `document.json`、`dom.json` 读取。
68
+ - `--headed` 只控制是否显示浏览器窗口,便于 debug,不会单独切换证据级别;完整证据必须显式指定 `--evidence full`。
69
+ - `coverage.json` 记录访问到的状态、动作、跳过项和部分完成原因。
70
+
71
+ `document.json` 不重复内嵌完整 DOM 父子关系,也不重复输出旧版的 `document.blocks`、顶层 `requirements`、`tables` 等别名;布局树保存在 `evidence/state-*.dom.json`,主文档通过状态和精简证据引用回查。所有页面事实尽量带 `state_id`、`screen_id` 和核心 `evidence_ids`。发生冲突时,以截图、HTML、DOM、ARIA 和原始表格为准;`derived` 只作为分析线索。
72
+
73
+ 退出码为 `0`(在策略范围内完成)、`2`(得到可用但部分完成的证据包)、`1`(未得到可用文档)。
74
+
75
+ ## 限制
76
+
77
+ - 不支持私有项目、登录态、评论和评审记录。
78
+ - 不点击抽奖、支付、购买、领取、提交、保存、发布、删除等高风险控件。
79
+ - 不访问页面中的外部链接;跨域 iframe、Canvas、视觉表格和图片文字只保存证据并标记未结构化区域。
80
+ - 不承诺理解业务语义;原型示例、日期、概率和外部文档引用需要人工确认。
81
+
82
+ Agent 使用说明见 [`skills/modao-prd-cli/SKILL.md`](skills/modao-prd-cli/SKILL.md)。
@@ -0,0 +1 @@
1
+ """Python package for the modao-prd-cli tool."""
@@ -0,0 +1,4 @@
1
+ """Public Modao prototype extraction CLI."""
2
+
3
+ __version__ = "0.1.0"
4
+
@@ -0,0 +1,7 @@
1
+ """Run modao-prd-cli with ``python -m modao_prd_cli.modao_prd``."""
2
+
3
+ from .cli import main
4
+
5
+
6
+ if __name__ == "__main__":
7
+ main()