dsh-github-flow 0.1.0 → 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 DSH Contributor
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.en.md ADDED
@@ -0,0 +1,119 @@
1
+ # DSH GitHub Flow (`dsh-github-flow`)
2
+
3
+ <p align="center">
4
+ <a href="https://www.npmjs.com/package/dsh-github-flow"><img src="https://img.shields.io/npm/v/dsh-github-flow.svg?style=flat-square&color=0969da" alt="npm version" /></a>
5
+ <a href="https://www.npmjs.com/package/dsh-github-flow"><img src="https://img.shields.io/npm/dm/dsh-github-flow.svg?style=flat-square&color=2ea043" alt="npm downloads" /></a>
6
+ <a href="./LICENSE"><img src="https://img.shields.io/badge/license-MIT-blue.svg?style=flat-square" alt="license" /></a>
7
+ <a href="https://deepseek-harness.github.io/deepseek-harness/"><img src="https://img.shields.io/badge/Cordis-Compatible-8957e5.svg?style=flat-square" alt="Cordis" /></a>
8
+ </p>
9
+
10
+ <p align="center">
11
+ <b>Modern, native GitHub workflow integration plugin for DeepSeek Harness (DSH) powered by GitHub CLI (<code>gh</code>).</b><br>
12
+ Deeply connects local Git repository development with remote GitHub collaboration (PRs, Issues, Actions CI diagnosis, and code reviews), featuring Agent model tools, human slash commands, and dual native Web UI views.
13
+ </p>
14
+
15
+ <p align="center">
16
+ <b><a href="./README.md">简体中文</a></b> | <b>English</b>
17
+ </p>
18
+
19
+ ---
20
+
21
+ ## 🌟 Key Features
22
+
23
+ 1. **Zero-Configuration Authentication**:
24
+ - Seamlessly reuses existing host credentials from `gh auth login` (OAuth tokens / system Keyrings) without exposing plain-text Personal Access Tokens (PATs) in DSH.
25
+ 2. **Deep Workspace Affinity (CWD Binding)**:
26
+ - Automatically scopes commands to the active session workspace. `gh` resolves the remote repository and current Git branch automatically, saving model tokens from redundant `owner/repo` arguments.
27
+ 3. **High Signal-to-Noise Ratio & Token Budget Protection**:
28
+ - Consolidates over 70+ scattered micro-tools into **5 focused domain tools**.
29
+ - Queries use `--json <fields>` projections by default; long diffs and failed CI logs are safely truncated (default 24KB) to protect the model's context window.
30
+ 4. **Dual Native Web UI Views**:
31
+ - **Global Cockpit** (`sidebar.panellist`, Order 20): Account-wide repository overview, local workspace matrix, and pending personal PRs/issues.
32
+ - **Right Sidebar Panel** (`sidebarRightTabs`, Order 40): Shows current repository status, PR list with CI check pills, and quick action buttons inside the session.
33
+ 5. **Standard Cordis Microkernel Compliance**:
34
+ - Exposes native `GitHubService` (`ctx.github`) for ecosystem extensibility;
35
+ - Strongly typed runtime validation via Schemastery (`Config`);
36
+ - Domain event broadcasting (`github/pr:create`, `github/issue:create`).
37
+
38
+ ---
39
+
40
+ ## 🚀 Installation
41
+
42
+ Run in your DSH terminal to install directly from npm:
43
+
44
+ ```bash
45
+ # Install to desktop profile
46
+ dsh plugin --profile desktop add dsh-github-flow
47
+
48
+ # Or install to web profile
49
+ dsh plugin --profile web add dsh-github-flow
50
+ ```
51
+
52
+ ---
53
+
54
+ ## 🛠️ Agent Tools Reference
55
+
56
+ | Tool Name | Actions | Typical Use Cases |
57
+ |---|---|---|
58
+ | `github_pr` | `list`, `view`, `create`, `diff`, `checks`, `review`, `merge` | Inspect PR details, verify CI checks, conduct code reviews, merge pull requests |
59
+ | `github_issue` | `list`, `view`, `create`, `comment`, `close`, `reopen` | Search and view issues, create issues, add comments |
60
+ | `github_run` | `list`, `view`, `log_failed`, `rerun`, `cancel` | Monitor Actions workflows; `log_failed` extracts failure logs for automatic fixes |
61
+ | `github_repo` | `view`, `search_code`, `search_repos` | Query repository metadata, search cross-repo code |
62
+ | `github_api` | Any GitHub REST / GraphQL endpoint | Universal escape hatch for custom queries (supports `--jq`) |
63
+
64
+ ---
65
+
66
+ ## 💬 Human Slash Commands
67
+
68
+ In any DSH chat prompt:
69
+ - `/gh status`: Check current GitHub CLI authentication status, granted scopes, and active repository;
70
+ - `/gh help`: Display quick reference and help information.
71
+
72
+ ---
73
+
74
+ ## ⚙️ Configuration
75
+
76
+ Customize options in your `cordis.patch.yml` or profile:
77
+
78
+ ```yaml
79
+ - insert:
80
+ - id: github-flow
81
+ name: dsh-github-flow
82
+ config:
83
+ ghPath: 'gh' # Custom path to gh binary
84
+ defaultTimeoutMs: 30000 # Timeout in milliseconds
85
+ maxOutputChars: 24000 # Maximum characters per output (Token guard)
86
+ cacheTtlMs: 15000 # Web overview cache time
87
+ defaultListLimit: 20 # Default page size
88
+ ```
89
+
90
+ ---
91
+
92
+ ## 🔌 Ecosystem Service Extension (Cordis Service)
93
+
94
+ Other DSH plugins can consume GitHub CLI capabilities via dependency injection:
95
+
96
+ ```ts
97
+ import type { Context } from '@deepseek-ai/cordis';
98
+
99
+ export const inject = ['github'];
100
+
101
+ export function apply(ctx: Context) {
102
+ // Directly invoke the underlying secure execution engine via ctx.github
103
+ const auth = await ctx.github.checkAuth();
104
+ const repo = await ctx.github.getRepoMetadata();
105
+ }
106
+ ```
107
+
108
+ ---
109
+
110
+ ## 📚 Documentation
111
+
112
+ - [npm Publishing & Maintenance Guide](./docs/npm-publish-guide.md)
113
+ - [Architecture & Design Specifications](./docs/architecture.md)
114
+
115
+ ---
116
+
117
+ ## 📄 License
118
+
119
+ This project is licensed under the [MIT License](./LICENSE).
package/README.md CHANGED
@@ -1,7 +1,20 @@
1
1
  # DSH GitHub Flow (`dsh-github-flow`)
2
2
 
3
- 基于 GitHub CLI (`gh`) 为 DeepSeek Harness (DSH) 打造的现代化原生集成插件。
4
- 深度打通本地 Git 仓库开发与远程 GitHub 协作(PR、Issue、Actions CI 诊断与代码审查),兼备 Agent 模型工具、人类 Slash 指令以及原生 Web UI 双重视图(主驾驶舱与右侧栏快捷面板)。
3
+ <p align="center">
4
+ <a href="https://www.npmjs.com/package/dsh-github-flow"><img src="https://img.shields.io/npm/v/dsh-github-flow.svg?style=flat-square&color=0969da" alt="npm version" /></a>
5
+ <a href="https://www.npmjs.com/package/dsh-github-flow"><img src="https://img.shields.io/npm/dm/dsh-github-flow.svg?style=flat-square&color=2ea043" alt="npm downloads" /></a>
6
+ <a href="./LICENSE"><img src="https://img.shields.io/badge/license-MIT-blue.svg?style=flat-square" alt="license" /></a>
7
+ <a href="https://deepseek-harness.github.io/deepseek-harness/"><img src="https://img.shields.io/badge/Cordis-Compatible-8957e5.svg?style=flat-square" alt="Cordis" /></a>
8
+ </p>
9
+
10
+ <p align="center">
11
+ <b>基于 GitHub CLI (<code>gh</code>) 为 DeepSeek Harness (DSH) 打造的现代化原生工作流集成插件。</b><br>
12
+ 深度打通本地 Git 仓库开发与远程 GitHub 协作(PR、Issue、Actions CI 诊断与代码审查),兼备 Agent 模型工具、人类 Slash 指令以及原生 Web UI 双重视图。
13
+ </p>
14
+
15
+ <p align="center">
16
+ <b>简体中文</b> | <b><a href="./README.en.md">English</a></b>
17
+ </p>
5
18
 
6
19
  ---
7
20
 
@@ -10,12 +23,12 @@
10
23
  1. **零鉴权配置,开箱即用**:
11
24
  - 自动复用宿主机已通过 `gh auth login` 认证的登录凭据(OAuth Token / 系统 Keyring),无需在 DSH 中存储任何明文 GitHub PAT。
12
25
  2. **工作区目录深度亲和 (CWD 绑定)**:
13
- - 自动继承当前会话所在的 Workspace 物理目录,`gh` 自动识别当前 Git 仓库与本地工作分支,无需 Agent 每次传参 `owner/repo`。
26
+ - 自动继承当前会话所在的 Workspace 物理目录,`gh` 自动识别当前 Git 仓库与本地工作分支,无需 Agent 每次显式传递 `owner/repo`。
14
27
  3. **高信噪比与 Token 防溢出治理**:
15
- - 拒绝 70+ 个碎片化微型工具撑爆上下文,聚合为 **5 大领域核心 Tool**。
28
+ - 拒绝 70+ 个碎片化微型工具撑爆上下文,收敛聚合为 **5 大领域核心 Tool**。
16
29
  - 所有查询原生采用 `--json <fields>` 按需返回;对 `diff`、`log_failed` 设置安全截断保护(默认 24KB),防止模型上下文窗口溢出崩溃。
17
- 4. **原生双重视图(驾驶舱与右侧栏)**:
18
- - **全局驾驶舱**(主导航栏 `sidebar.panellist`,Order 20):展示账号全局仓库、本地工作区矩阵、个人待办 PR 与 Issues;
30
+ 4. **原生 Web UI 双重视图**:
31
+ - **全局驾驶舱**(主导航栏 `sidebar.panellist`,Order 20):透视账号全局仓库、本地工作区矩阵、个人待办 PR 与 Issues;
19
32
  - **右侧栏工作区面板**(`sidebarRightTabs`,Order 40):在会话引导页与右侧抽屉常驻呈现当前仓库的 PR 列表、Checks 状态药丸与快捷操作。
20
33
  5. **符合 Cordis 官方微内核架构**:
21
34
  - 暴露原生 `GitHubService`(`ctx.github`),允许生态其他插件复用;
@@ -24,32 +37,16 @@
24
37
 
25
38
  ---
26
39
 
27
- ## 📦 项目结构
28
-
29
- ```text
30
- dsh-github-flow/
31
- ├── package.json # 模块定义、Cordis bundle 声明及 peerDependencies
32
- ├── cordis.patch.yml # DSH Profile 自动装配补丁(含默认配置项)
33
- ├── tsconfig.json # TypeScript 编译配置
34
- ├── README.md # 插件说明文档
35
- ├── icon.svg # 官方矢量微渐变包图标
36
- ├── src/
37
- │ ├── index.ts # Host 插件主入口:apply(ctx) 生命周期、服务挂载与 Config Schema
38
- │ ├── service.ts # Cordis 原生 GitHubService 抽象
39
- │ ├── types.ts # 数据结构、事件定义与接口类型
40
- │ ├── executor.ts # 底层 gh 执行引擎(execFile 参数数组隔离、防注入、超时与截断)
41
- │ ├── commands/
42
- │ │ └── gh.ts # 人类交互斜杠命令 (/gh status, /gh help)
43
- │ ├── api/
44
- │ │ └── routes.ts # 面向 Web 视口的 Host HTTP 路由 (/api/github/*,受 effect 生命周期管理)
45
- │ ├── tools/ # Agent 模型工具集(规范化 defineTool DSL)
46
- │ │ ├── pr.ts # github_pr: PR 查看、比对、Checks、评审与合并
47
- │ │ ├── issue.ts # github_issue: Issue 检索、创建、追加评论、关闭
48
- │ │ ├── run.ts # github_run: Actions CI 监控与 --log-failed 报错定位
49
- │ │ ├── repo.ts # github_repo: 仓库元数据与跨仓库搜索
50
- │ │ └── api.ts # github_api: 万能 REST/GraphQL 逃生门
51
- │ └── client.ts # Client 页面扩展:注册右侧栏 tab 与主面板视口
52
- └── lib/ # TypeScript 编译输出产物(双端 ESM)
40
+ ## 🚀 安装指南
41
+
42
+ 在 DSH 终端执行以下命令直接从 npm 安装:
43
+
44
+ ```bash
45
+ # 安装到桌面端 Profile
46
+ dsh plugin --profile desktop add dsh-github-flow
47
+
48
+ # 或者安装到 Web Profile
49
+ dsh plugin --profile web add dsh-github-flow
53
50
  ```
54
51
 
55
52
  ---
@@ -110,21 +107,13 @@ export function apply(ctx: Context) {
110
107
 
111
108
  ---
112
109
 
113
- ## 🖥️ 页面安装与体验
114
-
115
- 1. **依赖前提**:
116
- 宿主机已安装 GitHub CLI (`gh`) 并已登录:
117
- ```bash
118
- gh auth status
119
- ```
120
- 2. **在 DSH 中安装与挂载**:
121
- 通过 DSH Profile 配置加载本插件 bundle:
122
- ```yaml
123
- # cordis.patch.yml
124
- - insert:
125
- - id: github-flow
126
- name: dsh-github-flow
127
- ```
128
- 3. **界面体验**:
129
- - **右侧栏**:在右侧抽屉常驻呈现当前仓库的 PR、CI 状态药丸与快捷操作按钮;
130
- - **主视口**:左侧导航栏点击 GitHub 图标进入全局驾驶舱。
110
+ ## 📚 开发与维护文档
111
+
112
+ - [npm 发布与版本维护指南](./docs/npm-publish-guide.md)
113
+ - [架构设计与技术规范](./docs/architecture.md)
114
+
115
+ ---
116
+
117
+ ## 📄 开源协议 (License)
118
+
119
+ 本项目基于 [MIT License](./LICENSE) 协议开源。
package/cordis.patch.yml CHANGED
@@ -1,7 +1,3 @@
1
1
  - insert:
2
- - id: github-flow
3
- name: dsh-github-flow
4
- config:
5
- defaultTimeoutMs: 30000
6
- maxOutputChars: 24000
7
- cacheTtlMs: 15000
2
+ - id: github-flow-v3
3
+ name: 'D:/Desktop/AgentWork/DSHQuestion/dsh-github-flow/lib/main.js'
@@ -0,0 +1,69 @@
1
+ # DSH GitHub Flow 架构与设计规范 (Architecture & Specs)
2
+
3
+ `dsh-github-flow` 是为 DeepSeek Harness (DSH) 打造的原生 GitHub 工作流集成插件,基于底层 Cordis 微内核架构与宿主机原生 GitHub CLI (`gh`) 构建。
4
+
5
+ ---
6
+
7
+ ## 1. 架构全景图
8
+
9
+ ```text
10
+ ┌─────────────────────────────────────────────────────────────────────────────┐
11
+ │ DeepSeek Harness Host │
12
+ │ │
13
+ │ ┌────────────────────────┐ ┌──────────────────────────┐ │
14
+ │ │ Cordis Context (ctx) │ │ PluginConfig │ │
15
+ │ │ │ │(Schemastery 运行时校验) │ │
16
+ │ └───────────┬────────────┘ └─────────────┬────────────┘ │
17
+ │ │ │ │
18
+ │ ▼ ▼ │
19
+ │ ┌──────────────────────────────────────────────────────────────┐ │
20
+ │ │ GitHubService (ctx.github 原生服务) │ │
21
+ │ │ - checkAuth(cwd) - getRepoMetadata(cwd) │ │
22
+ │ │ - run<T>(args, opts) [execFile 数组隔离 + 24KB 智能截断] │ │
23
+ │ └──────┬───────────────────────┬────────────────────────┬──────┘ │
24
+ │ │ │ │ │
25
+ │ ▼ ▼ ▼ │
26
+ │ ┌──────────────────┐ ┌──────────────────┐ ┌───────────────────────┐ │
27
+ │ │ 5 大 Agent 工具 │ │ 人类 Slash 指令 │ │ Host HTTP WebServer │ │
28
+ │ │ (defineTool DSL)│ │ /gh status|help │ │ (Effect Disposer 清理)│ │
29
+ │ │ - pr │ └──────────────────┘ │ - /api/github/overview│ │
30
+ │ │ - issue │ │ - /api/github/action │ │
31
+ │ │ - run │ │ - /api/github/refresh │ │
32
+ │ │ - repo │ └──────────┬────────────┘ │
33
+ │ │ - api (逃生门) │ │ │
34
+ │ └──────────────────┘ │ HTTP API │
35
+ └─────────────────────────────────────────────────────────────┼───────────────┘
36
+ │
37
+ ┌─────────────────────────────────────────────────────────────┼───────────────┐
38
+ │ DSH Web Client ▼ │
39
+ │ │
40
+ │ ┌──────────────────────────────────┐ ┌─────────────────────────────┐ │
41
+ │ │ 全局驾驶舱 (Main Slot) │ │ 右侧栏面板 (Right Sidebar) │ │
42
+ │ │ - 账号全局所有 GitHub 仓库 │ │ - 当前会话工作区关联仓库 │ │
43
+ │ │ - 本地工作区矩阵透视 │ │ - PR 列表与 CI Checks 药丸 │ │
44
+ │ │ - 个人待办 PRs & Issues │ │ - 快速创建 PR / Issue │ │
45
+ │ └──────────────────────────────────┘ └─────────────────────────────┘ │
46
+ └─────────────────────────────────────────────────────────────────────────────┘
47
+ ```
48
+
49
+ ---
50
+
51
+ ## 2. 核心设计原则
52
+
53
+ ### 2.1 零凭证侵入 (Zero-Credential Store)
54
+ - 严禁在 DSH 内部配置或持久化存储任何 GitHub PAT 明文密钥;
55
+ - 直接复用宿主机由 `gh auth login` 认证的安全凭证(系统 Keychain / Windows Credential Manager / 系统的加密存储);
56
+ - 天然支持多账号、企业 GitHub (GH Enterprise) 以及各种 OAuth 作用域。
57
+
58
+ ### 2.2 工作区 CWD 亲和 (Workspace Affinity)
59
+ - 会话内的所有命令默认在当前 Agent 会话物理目录(`cwd`)执行;
60
+ - `gh` 引擎自动逆向推导关联的远程仓库(识别 `origin` 或 `github` remote),免去大模型每次必须传递 `owner/repo` 的繁重上下文负担。
61
+
62
+ ### 2.3 上下文 Token 保护 (Token Budget Guard)
63
+ - 所有的 `gh` 查询原生采用 `--json <fields>` 结构化投影;
64
+ - 对长文本输出(如大型 PR 的完整 `diff`、CI 失败步骤日志)设置安全截断阈值(默认 24KB),保留头尾关键上下文并添加显式截断标记,杜绝撑爆模型上下文。
65
+
66
+ ### 2.4 Cordis 微内核标准规范
67
+ - **硬依赖解耦**:顶层仅强依赖 `['tools']`,Web 服务与命令服务采用动态作用域注入,在纯终端 / Headless 模式下零卡死;
68
+ - **生命周期 Effect 闭环**:所有 HTTP 路由与命令注册均持有 Disposer 清理函数,插件热重载或重新挂载时自动彻底注销,零内存泄漏;
69
+ - **配置自校验**:基于 `@deepseek-ai/schemastery` 实现强类型声明与运行时校验。
@@ -0,0 +1,100 @@
1
+ # npm 发布与 GitHub Release 自动化发版指南
2
+
3
+ 本文档详细记录 `dsh-github-flow` 插件在 npm 公共注册表([https://www.npmjs.com/package/dsh-github-flow](https://www.npmjs.com/package/dsh-github-flow))以及 GitHub Releases 上的发布流程、鉴权策略、版本规范,以及基于 **GitHub Actions 实现全自动构建、测试、推送 npm 与同步发布 GitHub Release** 的具体触发规则与安全机制。
4
+
5
+ ---
6
+
7
+ ## 1. GitHub Actions 自动化流水线架构与触发规则
8
+
9
+ 本项目已在 [`.github/workflows/npm-publish.yml`](../.github/workflows/npm-publish.yml) 中配置了工业级的自动化 CI/CD 发包流水线(`Release & Publish to npm`)。
10
+
11
+ ### 1.1 触发规则深度剖析 (Trigger Rules)
12
+
13
+ 流水线设计了 **两种触发模式**,兼顾了版本规范性与调试灵活性:
14
+
15
+ | 触发模式 | 触发条件 | 语法定义 | 自动化执行内容 | 适用场景与安全保障 |
16
+ | :--- | :--- | :--- | :--- | :--- |
17
+ | **模式 A:Git Tag 语义化标签触发(推荐生产)** | 推送符合 `v*` 规则的版本标签 | `on.push.tags: ['v*.*.*', 'v*']` | **全套发布**:检出源码 ➔ 安装依赖 ➔ 全量构建 ➔ 校验产物 ➔ **带 Provenance 签名发布 npm** ➔ **自动创建并发布 GitHub Release(自动生成 Release Notes)** | **生产标准**:日常分支开发、合并 PR **不会**触发发包,彻底避免因版本号未变导致 npm 403 冲突;仅当打上发布标签时精准触发。 |
18
+ | **模式 B:手动调度触发(Workflow Dispatch)** | GitHub 网页 Actions 面板手动点击 | `on.workflow_dispatch` | **按需执行**:支持勾选 `dry_run`(预演模式),在不实际发布到 npm 与 Release 的情况下完整跑通 build 与打包流水线。 | **排错与测试**:用于在合入代码后快速验证 CI 构建与 npm 打包能否顺利通过。 |
19
+
20
+ #### 为什么不采用「代码 push 到 master 分支就自动发包」?
21
+ 1. **npm 版本的不可篡改性**:npm 绝对禁止覆盖已发布的相同版本号。若每次 git push master 均发包,一旦开发者忘记递增 `package.json` 中的 `version`,CI 必定直接报错失败;
22
+ 2. **发布意图明确**:通过 `git tag v0.1.1` 将代码快照、GitHub Release 与 npm 注册表版本三者完全对齐(1:1:1 映射),符合开源软件主流最佳实践。
23
+
24
+ ---
25
+
26
+ ### 1.2 GitHub 仓库密钥配置 (One-Time Setup)
27
+
28
+ 在自动化工作流执行前,只需在 GitHub 仓库中配置一次 npm Token:
29
+
30
+ 1. **获取 npm Granular Access Token**:
31
+ - 登录 npm 访问:[https://www.npmjs.com/settings/~/tokens/create](https://www.npmjs.com/settings/~/tokens/create);
32
+ - 权限选择:**Packages and scopes** 勾选 `Read and write`;
33
+ - **关键勾选**:勾选 **`Bypass two-factor authentication (2FA) for publishing`**;
34
+ - 复制生成的 `npm_xxxxxxxxxxxx` 密匙。
35
+ 2. **存入 GitHub Secrets**:
36
+ - 打开 GitHub 仓库页面 ➔ 点击 **Settings** ➔ **Secrets and variables** ➔ **Actions**;
37
+ - 点击 **New repository secret**:
38
+ - **Name**:`NPM_TOKEN`
39
+ - **Secret**:粘贴你刚刚复制的 `npm_` Token;
40
+ - 点击 **Add secret** 保存。
41
+
42
+ > 注:创建 GitHub Release 使用的是 GitHub 官方内置的 `secrets.GITHUB_TOKEN`,工作流中已声明 `permissions.contents: write`,无需额外配置任何第三方 Personal Access Token。
43
+
44
+ ---
45
+
46
+ ### 1.3 自动发布操作三步走 (发布新版本日常流程)
47
+
48
+ 配置好上述 Secret 后,日常发布新版本只需在本地终端运行:
49
+
50
+ ```bash
51
+ # 第一步:递增版本号(自动修改 package.json 并生成对应 git commit 和 git tag)
52
+ npm version patch # 修补 Bug: 0.1.0 -> 0.1.1
53
+ # 或者 npm version minor # 新增特性: 0.1.0 -> 0.2.0
54
+
55
+ # 第二步:将代码与标签推送到 GitHub
56
+ git push origin master --tags
57
+ ```
58
+
59
+ **推送完成后**:
60
+ - GitHub Actions 会在 5 秒内自动感知到 `v0.1.1` 标签被创建;
61
+ - 启动 Ubuntu runner,全自动执行:
62
+ `检出代码 ➔ 安装 pnpm ➔ 安装依赖 ➔ pnpm run build (编译 + 清理) ➔ 产物完整性校验 ➔ 带 Provenance 签名发布到 npm ➔ 自动创建并发布对应 GitHub Release`;
63
+ - 约 1 分钟后,npm 官网版本与 GitHub 仓库 Releases 页面同步更新!
64
+
65
+ ---
66
+
67
+ ## 2. 安全机制与 Provenance 产物溯源
68
+
69
+ 流水线中配置了 `permissions.id-token: write` 与 `--provenance` 参数:
70
+ - **软件供应链安全**:通过 GitHub OIDC 向 npm 提供加密的签名凭据;
71
+ - **官方认证徽章**:发布到 npm 后的包页面将自动挂上绿色的 **`Verified`** 徽章,向用户证明此版本由 GitHub Actions 在干净沙箱中从本开源仓库公开构建产出,杜绝后门与供应链投毒。
72
+
73
+ ---
74
+
75
+ ## 3. 本地手动备用发布流程 (Local Fallback)
76
+
77
+ 若遇到 GitHub Actions 宕机或需要紧急本地直发,可按以下流程:
78
+
79
+ ```bash
80
+ # 1. 编译
81
+ pnpm run build
82
+
83
+ # 2. 本地绑定 Token
84
+ npm config set //registry.npmjs.org/:_authToken=npm_你的Token
85
+
86
+ # 3. 本地直接发布
87
+ npm publish --access public
88
+ ```
89
+
90
+ ---
91
+
92
+ ## 4. 常见问题排查 (Troubleshooting)
93
+
94
+ ### Q1: GitHub Actions 报错 `npm error code E403: Forbidden - Two-factor authentication...`
95
+ - **原因**:GitHub Secrets 中的 `NPM_TOKEN` 未勾选 `Bypass two-factor authentication (2FA) for publishing`。
96
+ - **解法**:在 npm 重新生成勾选了 Bypass 2FA 的 Granular Access Token,并更新 GitHub 仓库里的 `NPM_TOKEN` Secret。
97
+
98
+ ### Q2: 报错 `403 You cannot publish over the previously published versions`
99
+ - **原因**:当前打 tag 的代码版本在 `package.json` 中的 `version` 已经被发布过了。
100
+ - **解法**:本地执行 `npm version patch` 递增版本号后再重新打 tag 推送。
@@ -1,3 +1,2 @@
1
1
  import type { GhExecutor } from '../executor.js';
2
- import type { PluginConfig } from '../types.js';
3
- export declare function registerApiRoutes(ctx: any, executor: GhExecutor, config?: PluginConfig): void;
2
+ export declare function registerApiRoutes(webServerService: any, executor: GhExecutor, workspaceRegistry?: any): void;