zy
Committed by GitHub

chore: 删除已完成的 PROMPT.md 开发任务文件 (#16)

P0 增强任务已全部完成,该文件不再需要。

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Showing 1 changed file with 0 additions and 183 deletions
1 -# 小红书 Skills P0 增强任务  
2 -  
3 -## 目标  
4 -  
5 -在现有 13 个 MCP 工具基础上,补充 3 项 P0 能力:写长文发布模式、Headless 自动降级、分步 CLI 命令。  
6 -  
7 -## 参考资料  
8 -  
9 -- **xiaohongshu-mcp/skills Python 实现**(主要参考):  
10 - - `/Users/zy/src/zy/xiaohongshu-mcp/skills/post-to-xhs/scripts/cdp_publish.py` — 长文发布核心逻辑  
11 - - `/Users/zy/src/zy/xiaohongshu-mcp/skills/post-to-xhs/scripts/publish_pipeline.py` — headless 降级逻辑  
12 - - `/Users/zy/src/zy/xiaohongshu-mcp/skills/post-to-xhs/scripts/chrome_launcher.py` — Chrome 重启/模式切换  
13 - - `/Users/zy/src/zy/xiaohongshu-mcp/skills/post-to-xhs/SKILL.md` — 长文工作流 SKILL 定义  
14 - - `/Users/zy/src/zy/xiaohongshu-mcp/skills/post-to-xhs/references/publish-workflow.md` — DOM 选择器参考  
15 -  
16 -- **当前项目代码**: `/Users/zy/src/zy/00_autoclaw/xiaohongshu-skills/scripts/`  
17 -  
18 -## 代码规范  
19 -  
20 -- `uv run ruff check .` 无错误  
21 -- `uv run ruff format --check .` 无差异  
22 -- 完整 type hints,`from __future__ import annotations`  
23 -- 公共函数有 docstring  
24 -- 行长度 ≤ 100  
25 -- 异常继承 `XHSError`  
26 -- JSON 输出 `ensure_ascii=False`  
27 -- Exit code: 0=成功,1=未登录,2=错误  
28 -  
29 -## 任务拆解  
30 -  
31 -### Task 1: 写长文发布模式  
32 -  
33 -参考 `cdp_publish.py` 的 `publish_long_article()`、`get_template_names()`、`select_template()`、`click_next_and_prepare_publish()` 方法。  
34 -  
35 -#### 1.1 新增选择器(`xhs/selectors.py`)  
36 -  
37 -添加长文模式相关的 CSS 选择器:  
38 -- `LONG_ARTICLE_TAB` — "写长文" tab  
39 -- `NEW_CREATION_BUTTON` — "新的创作" 按钮  
40 -- `LONG_ARTICLE_TITLE` — 长文标题 textarea  
41 -- `AUTO_FORMAT_BUTTON` — "一键排版" 按钮  
42 -- `TEMPLATE_CARD` — 模板卡片  
43 -- `TEMPLATE_TITLE` — 模板名称  
44 -- `NEXT_STEP_BUTTON` — "下一步" 按钮  
45 -  
46 -参考 reference `publish-workflow.md` 中的 DOM 选择器参考表。  
47 -  
48 -#### 1.2 新增长文发布模块(`xhs/publish_long_article.py`)  
49 -  
50 -创建独立模块,包含以下函数:  
51 -  
52 -```python  
53 -def publish_long_article(page, title, content, image_paths=None) -> list[str]:  
54 - """长文发布:导航 → 点击写长文 → 新的创作 → 填写标题正文 → 一键排版。  
55 - 返回可用模板名称列表。"""  
56 -  
57 -def get_template_names(page) -> list[str]:  
58 - """获取当前可用的排版模板名称列表。"""  
59 -  
60 -def select_template(page, template_name) -> bool:  
61 - """选择指定名称的排版模板。"""  
62 -  
63 -def click_next_and_fill_description(page, description) -> None:  
64 - """点击下一步,进入发布页并填写正文描述。  
65 - 注意:发布页有独立的正文编辑器,需单独填入。  
66 - 如果 description 超过 1000 字,应压缩到 800 字左右。"""  
67 -```  
68 -  
69 -#### 1.3 新增 CLI 子命令(`cli.py`)  
70 -  
71 -添加 3 个子命令:  
72 -  
73 -```bash  
74 -# 长文模式:填写内容 + 一键排版,返回模板列表  
75 -python scripts/cli.py long-article \  
76 - --title-file T --content-file C [--images P1 P2]  
77 -  
78 -# 选择模板  
79 -python scripts/cli.py select-template --name "模板名"  
80 -  
81 -# 点击下一步 + 填写发布页描述  
82 -python scripts/cli.py next-step --content-file C  
83 -```  
84 -  
85 -#### 1.4 更新 SKILL.md  
86 -  
87 -`skills/xhs-publish/SKILL.md` 中添加写长文模式的完整工作流:  
88 -- 输入判断:用户说"发长文 / 写长文 / 长文模式"时触发  
89 -- Step B.1-B.5 的工作流  
90 -- 模板选择通过 AskUserQuestion 让用户选  
91 -  
92 -### Task 2: Headless 自动降级  
93 -  
94 -参考 `publish_pipeline.py` 的登录检查 + 模式切换逻辑,以及 `chrome_launcher.py` 的 `restart_chrome()`  
95 -  
96 -#### 2.1 增强 `chrome_launcher.py`  
97 -  
98 -添加 `restart_chrome()` 函数:  
99 -- 关闭当前 Chrome 实例  
100 -- 以新模式(headless 或 headed)重新启动  
101 -- 等待端口就绪  
102 -  
103 -#### 2.2 增强 `publish_pipeline.py`  
104 -  
105 -`run_publish_pipeline()` 中加入降级逻辑:  
106 -  
107 -```  
108 -检查登录 → 如果未登录且是 headless 模式:  
109 - 1. 关闭无头 Chrome  
110 - 2. 以有窗口模式重新启动 Chrome  
111 - 3. 打开登录页  
112 - 4. 返回 {"success": false, "error": "未登录", "action": "switched_to_headed", "message": "已切换到有窗口模式,请在浏览器中扫码登录"}  
113 - 5. exit code 1  
114 -```  
115 -  
116 -#### 2.3 新增 CLI 参数  
117 -  
118 -`publish` 和 `publish-video` 子命令添加 `--headless` 参数:  
119 -  
120 -```bash  
121 -python scripts/cli.py publish --headless \  
122 - --title-file T --content-file C --images P1 P2  
123 -```  
124 -  
125 -`--headless` + 未登录时,自动降级到有窗口模式。  
126 -  
127 -### Task 3: 分步 CLI 命令  
128 -  
129 -参考 `cdp_publish.py` 的 `fill`、`click-publish` 子命令设计。目标是让 agent 可以在填写表单和点击发布之间插入用户确认步骤。  
130 -  
131 -#### 3.1 新增 CLI 子命令  
132 -  
133 -```bash  
134 -# 只填写表单,不发布(图文模式)  
135 -python scripts/cli.py fill-publish \  
136 - --title-file T --content-file C --images P1 P2 \  
137 - [--tags --schedule-at --visibility --original]  
138 -  
139 -# 只填写表单,不发布(视频模式)  
140 -python scripts/cli.py fill-publish-video \  
141 - --title-file T --content-file C --video P \  
142 - [--tags --schedule-at --visibility]  
143 -  
144 -# 点击发布按钮(在用户确认后调用)  
145 -python scripts/cli.py click-publish  
146 -```  
147 -  
148 -#### 3.2 拆分现有 publish 逻辑  
149 -  
150 -`xhs/publish.py` 中将 `publish_image_content()` 拆分为:  
151 -- `fill_publish_form(page, content)` — 导航、上传、填写表单,**不点击发布**  
152 -- `click_publish_button(page)` — 仅点击发布按钮  
153 -  
154 -`publish_image_content()` 保持不变(内部调用两者),向后兼容。  
155 -  
156 -同理拆分 `xhs/publish_video.py`  
157 -  
158 -#### 3.3 更新 SKILL.md  
159 -  
160 -`skills/xhs-publish/SKILL.md` 中:  
161 -- 推荐的发布流程改为:fill → 用户通过 AskUserQuestion 确认 → click-publish  
162 -- 保留一步到位的 `publish` 命令作为快捷方式  
163 -  
164 -### Task 4: 验证 + 收尾  
165 -  
166 -- `uv run ruff check .` 无错误  
167 -- `uv run ruff format --check .` 无差异  
168 -- 所有新增 CLI 子命令 `--help` 正常输出  
169 -- `skills/xhs-publish/SKILL.md` 包含长文模式和分步发布的完整工作流  
170 -- `CLAUDE.md` 的 MCP 工具对照表更新(新增子命令)  
171 -  
172 -## 完成标志  
173 -  
174 -当以下条件全部满足时,输出完成标志:  
175 -1. `xhs/publish_long_article.py` 已创建,含 4 个核心函数  
176 -2. `cli.py` 新增 6 个子命令:`long-article`, `select-template`, `next-step`, `fill-publish`, `fill-publish-video`, `click-publish`  
177 -3. `chrome_launcher.py` 含 `restart_chrome()` 函数  
178 -4. `publish_pipeline.py` 含 headless 自动降级逻辑  
179 -5. `skills/xhs-publish/SKILL.md` 含长文模式和分步发布工作流  
180 -6. `uv run ruff check .` 无错误  
181 -7. `uv run ruff format --check .` 无差异  
182 -  
183 -<promise>P0 ENHANCE COMPLETE</promise>