Skip to content

v0.1.1 — GitHub 工具(token 在插件设置里,不进仓库)

Pre-release
Pre-release

Choose a tag to compare

@KNLCXY KNLCXY released this 22 Oct 15:39
· 8 commits to main since this release

给 DSH 的 GitHub 工具插件:调 REST API、一次提交多个文件(一个 commit)、建仓库、查 token 身份。

token 你自己填 —— 在 设置 → GitHub 里粘一次,之后每个会话都能用。设置里那格只有示例占位符,没有默认值;插件源码、cordis.patch.yml、任何工具输出里都不会出现你的 token。

四个工具

工具 作用
github_status token 是谁的、有什么权限、还剩多少配额(只回显 ghp_…9c31)
github_api 直接调 REST API,返回体按 max_chars 截断,401/403/404/422 翻译成人话
github_push_files 一批文件 = 一个 commit(blob → tree → commit → 更新 ref),空仓库也能用
github_repo_create 建仓库 + 顺手设 topics

安装

# 附件包
dsh plugin --profile <你的 profile> add "file:<下载路径>/dsh-github-0.1.1.tgz"

# 或从 git
dsh plugin --profile <你的 profile> add github:KNLCXY/dsh-github

装完重启 DSH,然后到 设置 → GitHub 把 token 粘进去。

token 要什么权限

用途 最小权限
读仓库 / issue Contents: Read
提交文件 Contents: Read and write
建仓库 / 设 topics 再加 Administration: Read and write
图省事 classic token 勾一个 repo

建议设过期时间(7–30 天),不用了就 Revoke。

安全边界

  • token 只存在 ~/.dsh/storages/dsh-github/settings.json
  • 设置接口只返回 hasToken / tokenHint(掩码)/ 占位符,没有 token 字段
  • 仓库里的 cordis.patch.yml 写的是 token: ''
  • 工具输出里永远不出现明文 token

自测

node test/smoke.mjs    # 19 项,不联网、不需要 DSH

覆盖:4 个工具是否注册、设置接口校验(坏 token 400 / 好 token 200 且只回显首末 4 位 / 明文不出现 / 清除 / 坏代理 400)、没 token 时的提示、repo 格式校验。

旁路脚本(没有 token 时用)

脚本 作用
scripts/gh-web-commit.mjs 用浏览器里已登录的 GitHub 会话提交单个文件(不依赖 token)
scripts/gh-device-login.mjs 走 OAuth 设备流换一个 gho_ token
scripts/chrome-probe.mjs 用指定启动参数起内核排查渲染问题

踩过的坑:GitHub 的文件编辑器在 navigator.webdriver === true 时整块不渲染,加 --disable-blink-features=AutomationControlled 才正常。

校验下载包:sha256sum -c SHA256SUMS.txt。

MIT © KNLCXY