Back to home@ABccgh

dsh-github-plugin-tools

GitHub ↔ DSH plugin management: install / upload / uninstall tools

Stars
0
Language
JavaScript
Created
Aug 23, 2026
Updated
Aug 23, 2026

Introduction

dsh-github-plugin-tools — GitHub ↔ DSH 插件管理工具集(合并版)

DSH 动态 Cordis 插件(Host 半部),由 install-github-plugin + upload-github-plugin + uninstall-github-plugin 三个插件合并而成,注册三个工具(工具名与合并前完全一致):

工具功能
install_github_plugin下载/校验/留档 GitHub 插件(包装 install-github-plugin.ps1)
upload_github_plugin本地插件上传 GitHub(包装 upload-github-plugin.js)
uninstall_dsh_plugin三维卸载(动态 / 预设 / 工作区)

为什么合并

三个工具同属"GitHub ↔ DSH 插件管理"功能域,共享同一套底层模式(脚本定位回退、沙箱策略解析、JSON 标记解析、token 临时文件处理)。合并后:

  • 预设组合行 3 → 1,安装/卸载粒度为整个工具集
  • 共享工具函数收敛,维护成本降低
  • 工具名不变,既有调用方式零迁移

加载到 DSH

  1. 把本仓库 plugin.js 全文作为 code.host 交给 cordis_define(新插件给 3–6 位小写字母前缀,如 ghtl)
  2. cordis_run 运行插件
  3. 会话内即可调用三个工具

依赖服务(Host):dynamicCordisRunner(必注入,卸载维度用)、fsshellsandboxPolicyagentPresets(均可选读)。

各工具参数

install_github_plugin

参数必填说明
repo_url必填GitHub 仓库 URL
out_dir可选源码留档目录(默认会话工作区 plugins/)
branch可选指定分支(默认自动尝试 main → master)

upload_github_plugin

参数必填说明
repo必填owner/repo 或 GitHub 仓库 URL
token上传必填GitHub PAT(fine-grained 需 Contents 读写;classic 需 repo)
plugin_dir可选本地插件目录(默认 plugins/<仓库名>)
files可选显式上传文件列表
branch / message / private / create可选分支/提交信息/私有/自动建库
check可选免 token 自检连通性与仓库状态

uninstall_dsh_plugin

参数必填说明
plugin必填插件名称/别名或动态插件 pluginId
scope可选all(默认) | dynamic | preset | workspace
dry_run可选true 时只预览不删除

支持的卸载目标:ws-cleanerwiki-to-ima(imakb)、dsh-github-plugin-tools(即本工具集,别名 installer / uploader / uninstaller / github-tools —— 卸载任一别名即卸载整个工具集)。

使用示例

install_github_plugin({ repo_url: "https://github.com/owner/repo" })
upload_github_plugin({ repo: "owner/repo", token: "<PAT>" })
upload_github_plugin({ repo: "owner/repo", check: true })        # 免 token 自检
uninstall_dsh_plugin({ plugin: "uploader" })                      # 卸载整个工具集
uninstall_dsh_plugin({ plugin: "imakb", dry_run: true })          # 预览

网络说明(本机 schannel/hosts 障碍)

下载/上传全程使用 Node OpenSSL:下载优先 Node fetch;上传经自定义 lookup 钉住 api.github.com 真实 IP(DoH: doh.pub → alidns → 内置已知 IP 兜底),不依赖系统 DNS/schannel/git。token 只经环境变量传入 Node 进程(不进入命令行),用完即删。

持久化安装

把本插件写入 agent preset 的 cordis.yml 可重启自动加载:预设 plugins/ 放 Loader 原生包装器(编译 plugin.js 函数体 + harness shim + schema DSL→标准 JSON Schema 归一化),组合追加一行 - id: plugin-github-tools / name: ./plugins/github-tools.js;两个脚本随预设分发,工具在工作区找不到时会回退到预设目录。