shunk031-gh-comment-attach-files

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

GitHub 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
    github.com
    or GitHub Enterprise Server.
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.com
    或GitHub Enterprise Server环境。
请勿在需要实际发布、编辑或重写评论的任务中使用本技能。本技能仅获取URL后即停止操作。

Prerequisites

前置条件

  • npx @playwright/cli
    must be available.
  • If you use
    --repo ... --issue ...
    or
    --repo ... --pr ...
    ,
    gh
    must be installed and authenticated.
  • 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

工作流程

  1. Resolve the target page from either a direct URL or
    gh
    metadata.
  2. Stage the requested files under
    ./.playwright-cli/gh-comment-attach-files/...
    .
  3. Open the issue or pull request page with a persistent Playwright CLI browser profile.
  4. Find the main comment composer and attach files one by one.
  5. Read the inserted Markdown and return JSON with
    target_url
    ,
    source_path
    ,
    staged_name
    , and
    attachment_url
    .
  6. Close the browser unless
    --leave-open
    is used.
  1. 通过直接URL或
    gh
    元数据确定目标页面。
  2. 将请求的文件暂存至
    ./.playwright-cli/gh-comment-attach-files/...
    路径下。
  3. 使用持久化的Playwright CLI浏览器配置文件打开Issue或Pull Request页面。
  4. 找到主评论编辑器,逐个附加文件。
  5. 读取插入的Markdown内容,返回包含
    target_url
    source_path
    staged_name
    attachment_url
    的JSON数据。
  6. 除非使用
    --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.png
Resolve the page with
gh
:
bash
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
Large 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/*.png
When
--resume-manifest
is set, each successful upload is appended as JSONL. Rerunning the same command skips files that already have a
source_path
entry in the manifest and returns those existing URLs in the normal JSON output.
直接使用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
通过
gh
工具确定页面:
bash
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
当设置
--resume-manifest
参数时,每次成功上传的记录会以JSONL格式追加到文件中。 重新运行相同命令时,会跳过清单中已存在
source_path
记录的文件,并在常规JSON输出中返回这些已有的URL。

Output

输出结果

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.
  • staged_name
    may differ from the original basename so duplicate filenames stay distinct.
  • The default persistent profile lives under
    ./.playwright-cli/gh-comment-attach-files/profile
    .
  • Use
    --leave-open
    when you want to keep the browser and draft comment visible after the URLs are collected.
  • Use
    --max-files-per-run
    with
    --resume-manifest
    to chunk large attachment sets without losing completed URLs.
  • 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
    --resume-manifest
    参数,可将大量附件分块上传,且不会丢失已完成的URL。
  • 诊断进度、重试信息以及失败时的最终运行目录会输出到stderr。

Resources

资源说明

scripts/

scripts/

  • scripts/attach_comment_files.py
    : 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。