shunk031-gh-comment-attach-files
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseGitHub Comment Attach Files
GitHub Comment Attach Files
Read Acknowledgement
阅读确认
- After reading this skill, say:
🐙 I read shunk031-gh-comment-attach-files.
- 阅读完本技能后,请回复:
🐙 I read shunk031-gh-comment-attach-files.
When To Use
使用场景
Use this skill when you need GitHub to host local files and give back anonymized attachment URLs, but you do not want the agent to submit the issue or pull request comment itself.
Typical cases:
- Upload PNG, JPG, PDF, Markdown, or other GitHub-supported attachments to a PR or issue comment box.
- Replace broken local image URLs in a draft report with GitHub-hosted URLs.
- Work against either or GitHub Enterprise Server.
github.com
Do not use this skill when the task is to actually post, edit, or rewrite a comment. This skill stops after URL acquisition.
当您需要GitHub托管本地文件并返回匿名附件URL,但不希望Agent提交Issue或Pull Request评论时,可使用本技能。
典型场景:
- 将PNG、JPG、PDF、Markdown或其他GitHub支持的附件上传到PR或Issue评论框。
- 用GitHub托管的URL替换草稿报告中失效的本地图片URL。
- 适用于或GitHub Enterprise Server环境。
github.com
请勿在需要实际发布、编辑或重写评论的任务中使用本技能。本技能仅获取URL后即停止操作。
Prerequisites
前置条件
- must be available.
npx @playwright/cli - If you use or
--repo ... --issue ...,--repo ... --pr ...must be installed and authenticated.gh - If GitHub redirects to login or SSO, finish authentication in the opened browser window while the script is polling for the comment composer.
- 必须可使用。
npx @playwright/cli - 如果使用或
--repo ... --issue ...参数,必须安装并认证--repo ... --pr ...工具。gh - 如果GitHub跳转至登录或SSO页面,请在脚本轮询评论编辑器期间,在打开的浏览器窗口中完成认证。
Workflow
工作流程
- Resolve the target page from either a direct URL or metadata.
gh - Stage the requested files under .
./.playwright-cli/gh-comment-attach-files/... - Open the issue or pull request page with a persistent Playwright CLI browser profile.
- Find the main comment composer and attach files one by one.
- Read the inserted Markdown and return JSON with ,
target_url,source_path, andstaged_name.attachment_url - Close the browser unless is used.
--leave-open
- 通过直接URL或元数据确定目标页面。
gh - 将请求的文件暂存至路径下。
./.playwright-cli/gh-comment-attach-files/... - 使用持久化的Playwright CLI浏览器配置文件打开Issue或Pull Request页面。
- 找到主评论编辑器,逐个附加文件。
- 读取插入的Markdown内容,返回包含、
target_url、source_path和staged_name的JSON数据。attachment_url - 除非使用参数,否则关闭浏览器。
--leave-open
Command
命令示例
Direct URL:
bash
uv run python ~/.agents/skills/shunk031-gh-comment-attach-files/scripts/attach_comment_files.py \
--url https://github.com/OWNER/REPO/pull/123 \
docs/report.md assets/chart.pngResolve the page with :
ghbash
uv run python ~/.agents/skills/shunk031-gh-comment-attach-files/scripts/attach_comment_files.py \
--repo OWNER/REPO \
--pr 123 \
results/report.md results/chart.pngLarge uploads that may need multiple runs:
bash
uv run python ~/.agents/skills/shunk031-gh-comment-attach-files/scripts/attach_comment_files.py \
--repo OWNER/REPO \
--pr 123 \
--resume-manifest attachments.jsonl \
--sleep-between-files 2 \
--max-files-per-run 60 \
results/*.pngWhen is set, each successful upload is appended as JSONL.
Rerunning the same command skips files that already have a entry in the manifest and returns those existing URLs in the normal JSON output.
--resume-manifestsource_path直接使用URL:
bash
uv run python ~/.agents/skills/shunk031-gh-comment-attach-files/scripts/attach_comment_files.py \
--url https://github.com/OWNER/REPO/pull/123 \
docs/report.md assets/chart.png通过工具确定页面:
ghbash
uv run python ~/.agents/skills/shunk031-gh-comment-attach-files/scripts/attach_comment_files.py \
--repo OWNER/REPO \
--pr 123 \
results/report.md results/chart.png适用于可能需要多次运行的大文件上传:
bash
uv run python ~/.agents/skills/shunk031-gh-comment-attach-files/scripts/attach_comment_files.py \
--repo OWNER/REPO \
--pr 123 \
--resume-manifest attachments.jsonl \
--sleep-between-files 2 \
--max-files-per-run 60 \
results/*.png当设置参数时,每次成功上传的记录会以JSONL格式追加到文件中。
重新运行相同命令时,会跳过清单中已存在记录的文件,并在常规JSON输出中返回这些已有的URL。
--resume-manifestsource_pathOutput
输出结果
The script prints JSON only:
json
{
"target_url": "https://github.com/OWNER/REPO/pull/123",
"attachments": [
{
"source_path": "/abs/path/results/chart.png",
"staged_name": "chart--e5b6d4a1.png",
"attachment_url": "https://github.com/user-attachments/assets/..."
}
]
}脚本仅输出JSON格式内容:
json
{
"target_url": "https://github.com/OWNER/REPO/pull/123",
"attachments": [
{
"source_path": "/abs/path/results/chart.png",
"staged_name": "chart--e5b6d4a1.png",
"attachment_url": "https://github.com/user-attachments/assets/..."
}
]
}Notes
注意事项
- The script does not submit the comment.
- may differ from the original basename so duplicate filenames stay distinct.
staged_name - The default persistent profile lives under .
./.playwright-cli/gh-comment-attach-files/profile - Use when you want to keep the browser and draft comment visible after the URLs are collected.
--leave-open - Use with
--max-files-per-runto chunk large attachment sets without losing completed URLs.--resume-manifest - Diagnostic progress, retry information, and the final run directory on failure are printed to stderr.
- 本脚本不会提交评论。
- 可能与原始文件名不同,以确保重复文件名保持唯一性。
staged_name - 默认持久化配置文件存储在路径下。
./.playwright-cli/gh-comment-attach-files/profile - 如果希望在获取URL后保持浏览器和草稿评论可见,请使用参数。
--leave-open - 结合使用和
--max-files-per-run参数,可将大量附件分块上传,且不会丢失已完成的URL。--resume-manifest - 诊断进度、重试信息以及失败时的最终运行目录会输出到stderr。
Resources
资源说明
scripts/
scripts/
- : resolves the target page, stages files, drives Playwright CLI, and returns hosted attachment URLs as JSON.
scripts/attach_comment_files.py
- :确定目标页面,暂存文件,驱动Playwright CLI,并以JSON格式返回托管附件的URL。
scripts/attach_comment_files.py