@goodandready/dsh-github-ops 0.1.0
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/CHANGELOG.md +81 -0
- package/LICENSE +21 -0
- package/README.md +163 -0
- package/README.ru.md +161 -0
- package/README.zh.md +151 -0
- package/cordis.patch.yml +3 -0
- package/lib/approval.js +168 -0
- package/lib/auth.js +59 -0
- package/lib/client.js +304 -0
- package/lib/commands.js +151 -0
- package/lib/github.js +315 -0
- package/lib/index.js +332 -0
- package/lib/jobs.js +107 -0
- package/lib/present.js +214 -0
- package/lib/repo-context.js +72 -0
- package/lib/review-rules.js +147 -0
- package/lib/tools/actions.js +107 -0
- package/lib/tools/api.js +44 -0
- package/lib/tools/issues.js +101 -0
- package/lib/tools/mirror.js +163 -0
- package/lib/tools/pulls.js +207 -0
- package/lib/tools/register-collab.js +233 -0
- package/lib/tools/register-core.js +259 -0
- package/lib/tools/register-jobs.js +57 -0
- package/lib/tools/register-mirror.js +88 -0
- package/lib/tools/register-ops.js +283 -0
- package/lib/tools/releases.js +111 -0
- package/lib/tools/repo-settings.js +207 -0
- package/lib/tools/repos.js +108 -0
- package/lib/tools/tags.js +68 -0
- package/package.json +73 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
Notable changes to `@goodandready/dsh-github-ops`.
|
|
4
|
+
|
|
5
|
+
## 0.1.1
|
|
6
|
+
|
|
7
|
+
- Retries and rate-limit respect: a read (GET/HEAD) is retried on a network failure, a
|
|
8
|
+
timeout or a 5xx, and a 429 is honoured through `Retry-After` or the rate-limit reset.
|
|
9
|
+
A write is never retried automatically. `maxRetries` in settings.
|
|
10
|
+
- A call may omit the repository inside a checkout: it is taken from the origin remote.
|
|
11
|
+
`owner/repo#12` and a bare `12` are understood.
|
|
12
|
+
- Review findings are configuration now: glob paths, severities, the large-diff threshold
|
|
13
|
+
and whether tests are required (`reviewRulesJson`).
|
|
14
|
+
- Tool results render as cards (links, branch pairs, verdicts, failing steps) instead of a
|
|
15
|
+
JSON blob.
|
|
16
|
+
- Writes pass through the approval contour: every write maps to a named action, an action
|
|
17
|
+
outside `allowedActions` is denied, destructive actions always ask, and only
|
|
18
|
+
`DSH_GITHUB_OPS_UNATTENDED=1` with `autoApprove` can skip a prompt.
|
|
19
|
+
- Background reviews: `gh_review_job` starts one and answers immediately;
|
|
20
|
+
`gh_review_job_status` reads it.
|
|
21
|
+
- Slash commands: `/pr create [title]`, `/review [number]`, `/issue new|list|show`, `/gh`.
|
|
22
|
+
A command never writes itself — it hands the model an instruction, so the write still goes
|
|
23
|
+
through the approval gate.
|
|
24
|
+
- Access can come from the DSH credential, the environment variable or the `gh` CLI session
|
|
25
|
+
(`tokenSource`), which is why a machine with `gh auth login` needs no extra configuration.
|
|
26
|
+
|
|
27
|
+
## 0.1.0 — first release
|
|
28
|
+
|
|
29
|
+
The plugin is **not released yet**: it must first carry the full tool set — parity with
|
|
30
|
+
the reference GitHub plugin plus the operations our release pipeline needs.
|
|
31
|
+
|
|
32
|
+
### Added
|
|
33
|
+
- GitHub API client (`lib/github.js`): REST v3 and GraphQL v4 behind one transport that
|
|
34
|
+
is injected (`fetchImpl`), so every caller and every test runs without a network.
|
|
35
|
+
Failures are normalized into one shape — `status`, `code` (`http_error`,
|
|
36
|
+
`rate_limited`, `timeout`, `network`, `graphql_error`), `rateLimit` with the reset
|
|
37
|
+
time — so a tool never throws a turn away because GitHub answered 404 or 403.
|
|
38
|
+
- Release tools: `gh_release_list`, `gh_release_view`, `gh_release_create`,
|
|
39
|
+
`gh_release_edit` (including `makeLatest`), `gh_release_delete`.
|
|
40
|
+
- Tag tools: `gh_tag_list`, `gh_tag_create` (lightweight or annotated), `gh_tag_delete`.
|
|
41
|
+
- `gh_api`: guarded generic pass-through — reads are free, `POST`/`PATCH`/`PUT`/`DELETE`
|
|
42
|
+
require `confirm: true`, and deleting a repository, transferring one or deleting an
|
|
43
|
+
organization is refused outright.
|
|
44
|
+
- Tests without a harness and without a network: 51 cases covering URL building, error
|
|
45
|
+
mapping, rate limits, timeouts, pagination, GraphQL, tag object ordering, base64 file
|
|
46
|
+
decoding, issue normalization, diff truncation, the CI rollup and the `gh_api` safety
|
|
47
|
+
boundary.
|
|
48
|
+
- Repository tools: `gh_repo`, `gh_file` (file content at a ref, or a directory
|
|
49
|
+
listing), `gh_repo_search`, `gh_repo_create`, `gh_repo_edit`.
|
|
50
|
+
- Issue tools: `gh_issue`, `issue_open`, `issue_comment`, `issue_close`, `gh_search`.
|
|
51
|
+
- Pull request tools: `pr_create`, `pr_update`, `pr_merge` (merge/squash/rebase,
|
|
52
|
+
optional head-branch delete), `gh_review` (metadata, areas, capped diff, comments,
|
|
53
|
+
CI rollup and deterministic findings), `review_post` (summary or inline),
|
|
54
|
+
`gh_checks`, `ci_run` (one-shot review with a rule-based verdict).
|
|
55
|
+
|
|
56
|
+
- Mirror tools: `gh_mirror_check` (read-only plan: what would be published, what stays
|
|
57
|
+
behind, and why a publication must be refused) and `gh_mirror_publish` (one commit on
|
|
58
|
+
top of the mirror branch, fast-forward, never a force; `dryRun`, `confirm: true`).
|
|
59
|
+
The allowlist is the package manifest's own `files` plus README/LICENSE/CHANGELOG/
|
|
60
|
+
`cordis.patch.yml`; `docs/**` and agent instructions are forbidden even when a manifest
|
|
61
|
+
lists them, while shipped tooling such as `scripts/**` is published because it is part
|
|
62
|
+
of the package.
|
|
63
|
+
- Workflow-run tools: `gh_run_list`, `gh_run_view`, `gh_run_jobs` (failed steps named),
|
|
64
|
+
`gh_run_rerun` (all or failed-only), `gh_run_cancel`, `gh_run_logs` (returns the zip
|
|
65
|
+
URL instead of pulling a binary into the conversation).
|
|
66
|
+
- Repository settings tools: `gh_variable_list/set/delete`, `gh_secret_list/set/delete`,
|
|
67
|
+
`gh_ruleset_list/view/apply/delete`, `gh_branch_protection_get/set/delete`.
|
|
68
|
+
Setting a secret uses GitHub sealed-box encryption through the optional `tweetnacl`
|
|
69
|
+
package; without it the tool explains what to install rather than writing a broken
|
|
70
|
+
value.
|
|
71
|
+
- Browser half: a settings card on the plugin's own page (the plugin-list seat
|
|
72
|
+
`plugins.item`, plus the row seat and the legacy `settings.plugin.item` card) with
|
|
73
|
+
locales `en`/`zh`, a snapshot-status check so an unavailable settings service is stated
|
|
74
|
+
instead of hidden, all-changed-fields saving with per-field failure reporting, and a
|
|
75
|
+
style element tagged `data-dsh-plugin="dsh-github-ops"`.
|
|
76
|
+
|
|
77
|
+
### Planned (release blockers)
|
|
78
|
+
- Release notes for `dsh-russian-lang` (the card adds no new user-facing strings beyond
|
|
79
|
+
the four settings, but the translation issue must be filed before publishing).
|
|
80
|
+
- Verification on the isolated DSH test server, then acceptance on production, then the
|
|
81
|
+
public release (npm + GitHub) after an explicit go-ahead.
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 GooDAnDReaDY
|
|
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.md
ADDED
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
# dsh-github-ops
|
|
2
|
+
|
|
3
|
+
GitHub operations for [DeepSeek Harness](https://github.com/topics/dsh-plugin): releases,
|
|
4
|
+
tags, a guarded generic API pass-through, workflow runs, secrets and sanitized mirror
|
|
5
|
+
publication.
|
|
6
|
+
|
|
7
|
+
The plugin exists because the release pipeline needs operations the existing GitHub
|
|
8
|
+
plugin does not provide — releases and tags first, then a way to publish a GitHub mirror
|
|
9
|
+
that carries the **product** and not the whole development tree.
|
|
10
|
+
|
|
11
|
+
> **Status: work in progress, not released.** The public release happens only after the
|
|
12
|
+
> plugin carries the full tool set (see [Roadmap](#roadmap)).
|
|
13
|
+
|
|
14
|
+
## Install
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
dsh plugin --profile web add @goodandready/dsh-github-ops
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
Requires a GitHub token in the DSH credential service. Store the token under a name
|
|
21
|
+
(default `GITHUB_TOKEN`) and put only that **name** in the plugin settings.
|
|
22
|
+
|
|
23
|
+
## Settings
|
|
24
|
+
|
|
25
|
+
| Setting | Default | Meaning |
|
|
26
|
+
|---|---|---|
|
|
27
|
+
| `tokenEnv` | `GITHUB_TOKEN` | Name looked up in the DSH credentials, then the environment, then the `gh` CLI. The value is never stored in settings. |
|
|
28
|
+
| `tokenSource` | `auto` | Where access comes from: `auto` tries the DSH credential, then the environment variable, then the `gh` CLI session; pin it to `credentials`, `env` or `gh`. |
|
|
29
|
+
| `defaultRepository` | *(empty)* | `owner/repo` used by tools that omit `repository`. |
|
|
30
|
+
| `baseUrl` | `https://api.github.com` | API base; change it for GitHub Enterprise. |
|
|
31
|
+
| `timeoutMs` | `30000` | Per-request timeout. |
|
|
32
|
+
| `maxRetries` | `2` | Retries for a failed read (never for a write). |
|
|
33
|
+
| `reviewRulesJson` | *(empty)* | Review-rule overrides as JSON: `sensitivePaths`, `sensitiveSeverity`, `attentionPaths`, `migrationPaths`, `testsRequired`, `sourcePatterns`, `testPatterns`, `largeDiffLines`. |
|
|
34
|
+
| `allowedActions` | *(all)* | Write actions the plugin may perform; anything else is denied. Each one still asks. |
|
|
35
|
+
| `autoApprove` | *(empty)* | Actions an unattended run (`DSH_GITHUB_OPS_UNATTENDED=1`) may perform without asking. Destructive actions are never auto-approved. |
|
|
36
|
+
| `reviewJobTimeoutMs` | `120000` | How long a background review job may run. |
|
|
37
|
+
|
|
38
|
+
## Tools
|
|
39
|
+
|
|
40
|
+
### Releases
|
|
41
|
+
|
|
42
|
+
| Tool | What it does |
|
|
43
|
+
|---|---|
|
|
44
|
+
| `gh_release_list` | List releases, newest first (read-only). |
|
|
45
|
+
| `gh_release_view` | Read one release by tag: flags, notes, assets (read-only). |
|
|
46
|
+
| `gh_release_create` | Create a release for a tag, optionally on a specific commit. |
|
|
47
|
+
| `gh_release_edit` | Edit title, notes, draft/prerelease, and **which release is latest**. |
|
|
48
|
+
| `gh_release_delete` | Delete a release (requires `confirm: true`). |
|
|
49
|
+
|
|
50
|
+
`gh_release_edit` with `makeLatest: true` is the step that keeps the repository badge on
|
|
51
|
+
the current version: creating older releases afterwards otherwise moves “Latest” back.
|
|
52
|
+
|
|
53
|
+
### Tags
|
|
54
|
+
|
|
55
|
+
| Tool | What it does |
|
|
56
|
+
|---|---|
|
|
57
|
+
| `gh_tag_list` | List tags with their commit SHAs (read-only). |
|
|
58
|
+
| `gh_tag_create` | Create a tag — lightweight, or annotated when `message` is given. |
|
|
59
|
+
| `gh_tag_delete` | Delete a tag (requires `confirm: true`). |
|
|
60
|
+
|
|
61
|
+
### Generic API
|
|
62
|
+
|
|
63
|
+
`gh_api` reaches anything the typed tools do not cover (refs, rulesets, organizations,
|
|
64
|
+
gists). Reads are free. `POST`/`PATCH`/`PUT`/`DELETE` require `confirm: true`. Deleting a
|
|
65
|
+
repository, transferring a repository or deleting an organization is refused outright —
|
|
66
|
+
a single confirmation cannot make those safe.
|
|
67
|
+
|
|
68
|
+
### Issues and pull requests
|
|
69
|
+
|
|
70
|
+
| Tool | What it does |
|
|
71
|
+
|---|---|
|
|
72
|
+
| `gh_issue` | List or read issues (`action: list\|get\|comments`); pull requests come back as `kind: "pr"`. |
|
|
73
|
+
| `issue_open`, `issue_comment`, `issue_close` | Create an issue, comment on an issue or PR, close it (optionally with a state reason). |
|
|
74
|
+
| `gh_search` | Search issues and PRs with GitHub search syntax (separate quota). |
|
|
75
|
+
| `pr_create`, `pr_update` | Open a pull request from a head branch; edit title, body, state or base. |
|
|
76
|
+
| `pr_merge` | Merge a PR (merge/squash/rebase), optionally deleting the head branch. |
|
|
77
|
+
| `gh_review` | One review pack: metadata, areas, capped diff, comments, CI rollup and deterministic findings (secrets, migrations, CI config, source without tests, large diff). |
|
|
78
|
+
| `review_post` | Publish a review as one summary comment, or as line-anchored inline comments. |
|
|
79
|
+
| `gh_checks` | Check runs, legacy statuses and one rollup verdict for a commit. |
|
|
80
|
+
| `ci_run` | One-shot review of a PR with a rule-based verdict. |
|
|
81
|
+
|
|
82
|
+
### Mirror publication
|
|
83
|
+
|
|
84
|
+
| Tool | What it does |
|
|
85
|
+
|---|---|
|
|
86
|
+
| `gh_mirror_check` | Read-only plan: which product files would reach the mirror, how many stay behind, and why a publication must be refused. |
|
|
87
|
+
| `gh_mirror_publish` | Publish the sanitized tree: one commit on top of the mirror branch, fast-forward, **never a force**. `dryRun: true` previews; writing needs `confirm: true`. |
|
|
88
|
+
|
|
89
|
+
The allowlist is the package manifest's own `files` plus `.gitignore`, `LICENSE`,
|
|
90
|
+
README trio, `CHANGELOG.md` and `cordis.patch.yml`. `docs/**` and agent instructions are
|
|
91
|
+
forbidden even when a manifest lists them; shipped tooling such as `scripts/**` is
|
|
92
|
+
published because it is part of the package.
|
|
93
|
+
|
|
94
|
+
### Workflow runs
|
|
95
|
+
|
|
96
|
+
| Tool | What it does |
|
|
97
|
+
|---|---|
|
|
98
|
+
| `gh_run_list`, `gh_run_view` | List runs (branch, workflow, status filters) and read one run. |
|
|
99
|
+
| `gh_run_jobs` | Jobs with their steps, and the steps that failed — usually enough to diagnose a failure. |
|
|
100
|
+
| `gh_run_rerun`, `gh_run_cancel` | Re-run all or only failed jobs; cancel an in-progress run (needs `confirm: true`). |
|
|
101
|
+
| `gh_run_logs` | Returns the logs archive URL: GitHub answers with a redirect to a zip, which is not pulled into the conversation. |
|
|
102
|
+
|
|
103
|
+
### Repository settings
|
|
104
|
+
|
|
105
|
+
| Tool | What it does |
|
|
106
|
+
|---|---|
|
|
107
|
+
| `gh_variable_list/set/delete` | Actions variables, repository-wide or per environment. |
|
|
108
|
+
| `gh_secret_list/set/delete` | Actions secrets. Setting one uses sealed-box encryption through the optional `tweetnacl` package; without it the tool says what to install instead of writing a broken value. |
|
|
109
|
+
| `gh_ruleset_list/view/apply/delete` | Repository rulesets: read, create, update, delete. |
|
|
110
|
+
| `gh_branch_protection_get/set/delete` | Classic branch protection: required reviews, status checks, admin enforcement, force-push and deletion flags. |
|
|
111
|
+
|
|
112
|
+
## Background reviews and commands
|
|
113
|
+
|
|
114
|
+
`gh_review_job` starts a review and returns a job id immediately; `gh_review_job_status`
|
|
115
|
+
reports it. With a host job registry the work is visible and cancellable in the UI; without
|
|
116
|
+
one it runs inside the plugin.
|
|
117
|
+
|
|
118
|
+
Slash commands are the fast path for a human:
|
|
119
|
+
|
|
120
|
+
| Command | What it does |
|
|
121
|
+
|---|---|
|
|
122
|
+
| `/pr create [title]` | Reads the current branch and origin, then instructs the model to call `pr_create`. |
|
|
123
|
+
| `/review [number]` | Reviews a pull request (or the one for the current branch). |
|
|
124
|
+
| `/issue new <title>` \| `/issue list` \| `/issue show <number>` | Opens, lists or reads issues. |
|
|
125
|
+
| `/gh [group\|tool]` | Points at the tools for releases, tags, mirror, runs, secrets, variables, rulesets or branch protection. |
|
|
126
|
+
|
|
127
|
+
A command never writes to GitHub itself: it hands the model an instruction, so the write
|
|
128
|
+
still passes through the approval gate.
|
|
129
|
+
|
|
130
|
+
## Safety
|
|
131
|
+
|
|
132
|
+
- The token lives in the DSH credential service; settings hold only its name.
|
|
133
|
+
- Read operations never change state; mutations are confirmed explicitly, and deleting a
|
|
134
|
+
repository, transferring one or deleting an organization is refused outright.
|
|
135
|
+
- The client never logs the token, and every failure is reported as a value
|
|
136
|
+
(`ok: false` with `status`, `code`, `rateLimit`) instead of an exception.
|
|
137
|
+
- Findings from `gh_review` are deterministic rules: they point at what needs attention
|
|
138
|
+
and are never presented as a verdict on correctness.
|
|
139
|
+
|
|
140
|
+
## Roadmap
|
|
141
|
+
|
|
142
|
+
Everything planned for the first release is implemented. What remains is the release
|
|
143
|
+
process itself:
|
|
144
|
+
|
|
145
|
+
1. Preflight (`dsh-plugin-preflight`) and the package check.
|
|
146
|
+
2. Verification of the exact `.tgz` on the isolated DSH test server.
|
|
147
|
+
3. Acceptance of the same candidate on production.
|
|
148
|
+
4. Translation notes for `dsh-russian-lang`.
|
|
149
|
+
5. Public release (npm + GitHub) after an explicit go-ahead.
|
|
150
|
+
|
|
151
|
+
## Development
|
|
152
|
+
|
|
153
|
+
```bash
|
|
154
|
+
npm test # node --test, no harness and no network: fetch is injected
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
Tests live next to the code they cover and never touch the network: the transport is a
|
|
158
|
+
parameter, so failure modes (404, rate limit, timeout, non-JSON body, short pages) are
|
|
159
|
+
exercised directly.
|
|
160
|
+
|
|
161
|
+
## License
|
|
162
|
+
|
|
163
|
+
MIT — see [LICENSE](LICENSE).
|
package/README.ru.md
ADDED
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
# dsh-github-ops
|
|
2
|
+
|
|
3
|
+
Операции с GitHub для [DeepSeek Harness](https://github.com/topics/dsh-plugin): релизы,
|
|
4
|
+
теги, защищённый универсальный доступ к API, запуски workflow, секреты и публикация
|
|
5
|
+
санитизированного зеркала.
|
|
6
|
+
|
|
7
|
+
Плагин появился потому, что релизному конвейеру нужны операции, которых нет в
|
|
8
|
+
существующем GitHub-плагине: сначала релизы и теги, затем способ публиковать
|
|
9
|
+
GitHub-зеркало, которое несёт **продукт**, а не всё дерево разработки.
|
|
10
|
+
|
|
11
|
+
> **Статус: в работе, релиза нет.** Публикация состоится только после того, как в плагине
|
|
12
|
+
> появятся все инструменты (см. [План](#план)).
|
|
13
|
+
|
|
14
|
+
## Установка
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
dsh plugin --profile web add @goodandready/dsh-github-ops
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
Нужен токен GitHub в сервисе учётных данных DSH. Имя по умолчанию — `GITHUB_TOKEN`,
|
|
21
|
+
в настройках плагина хранится только это **имя**.
|
|
22
|
+
|
|
23
|
+
## Настройки
|
|
24
|
+
|
|
25
|
+
| Настройка | Значение по умолчанию | Смысл |
|
|
26
|
+
|---|---|---|
|
|
27
|
+
| `tokenEnv` | `GITHUB_TOKEN` | Имя, которое ищется в креденшелах DSH, затем в переменной окружения, затем в `gh` CLI. Само значение в настройках не хранится. |
|
|
28
|
+
| `tokenSource` | `auto` | Откуда берётся доступ: `auto` — креденшел DSH, затем переменная окружения, затем сессия `gh`; можно зафиксировать `credentials`, `env` или `gh`. |
|
|
29
|
+
| `defaultRepository` | пусто | `owner/repo`, если в вызове инструмента репозиторий не указан. |
|
|
30
|
+
| `baseUrl` | `https://api.github.com` | База API; меняется для GitHub Enterprise. |
|
|
31
|
+
| `timeoutMs` | `30000` | Таймаут одного запроса. |
|
|
32
|
+
| `maxRetries` | `2` | Повторы для неудачного чтения (запись не повторяется). |
|
|
33
|
+
| `reviewRulesJson` | пусто | Переопределение правил ревью в JSON: `sensitivePaths`, `sensitiveSeverity`, `attentionPaths`, `migrationPaths`, `testsRequired`, `sourcePatterns`, `testPatterns`, `largeDiffLines`. |
|
|
34
|
+
| `allowedActions` | все | Разрешённые записи; всё остальное отклоняется, и каждая всё равно спрашивает подтверждение. |
|
|
35
|
+
| `autoApprove` | пусто | Действия, которые неавтономный прогон (`DSH_GITHUB_OPS_UNATTENDED=1`) может выполнить без вопроса; разрушительные не автоутверждаются никогда. |
|
|
36
|
+
| `reviewJobTimeoutMs` | `120000` | Сколько может работать фоновая задача ревью. |
|
|
37
|
+
|
|
38
|
+
## Инструменты
|
|
39
|
+
|
|
40
|
+
### Релизы
|
|
41
|
+
|
|
42
|
+
| Инструмент | Что делает |
|
|
43
|
+
|---|---|
|
|
44
|
+
| `gh_release_list` | Список релизов от новых к старым (только чтение). |
|
|
45
|
+
| `gh_release_view` | Чтение релиза по тегу: флаги, заметки, артефакты (только чтение). |
|
|
46
|
+
| `gh_release_create` | Создание релиза для тега, при необходимости на конкретном коммите. |
|
|
47
|
+
| `gh_release_edit` | Правка заголовка, заметок, draft/prerelease и **того, какой релиз считается latest**. |
|
|
48
|
+
| `gh_release_delete` | Удаление релиза (нужно `confirm: true`). |
|
|
49
|
+
|
|
50
|
+
`gh_release_edit` с `makeLatest: true` — тот шаг, который держит бейдж репозитория на
|
|
51
|
+
актуальной версии: если после этого создать релиз старой версии, «Latest» уедет назад.
|
|
52
|
+
|
|
53
|
+
### Теги
|
|
54
|
+
|
|
55
|
+
| Инструмент | Что делает |
|
|
56
|
+
|---|---|
|
|
57
|
+
| `gh_tag_list` | Список тегов с SHA коммитов (только чтение). |
|
|
58
|
+
| `gh_tag_create` | Создание тега — обычного, либо аннотированного при наличии `message`. |
|
|
59
|
+
| `gh_tag_delete` | Удаление тега (нужно `confirm: true`). |
|
|
60
|
+
|
|
61
|
+
### Универсальный API
|
|
62
|
+
|
|
63
|
+
`gh_api` закрывает всё, что не покрыто типизированными инструментами (refs, rulesets,
|
|
64
|
+
организации, gists). Чтение свободно; `POST`/`PATCH`/`PUT`/`DELETE` требуют
|
|
65
|
+
`confirm: true`. Удаление репозитория, его перенос и удаление организации отклоняются
|
|
66
|
+
сразу: одно подтверждение не делает такие вызовы безопасными.
|
|
67
|
+
|
|
68
|
+
### Issues и pull requests
|
|
69
|
+
|
|
70
|
+
| Инструмент | Что делает |
|
|
71
|
+
|---|---|
|
|
72
|
+
| `gh_issue` | Список или чтение issues (`action: list/get/comments`); PR приходят с `kind: "pr"`. |
|
|
73
|
+
| `issue_open`, `issue_comment`, `issue_close` | Создать issue, прокомментировать, закрыть (с причиной). |
|
|
74
|
+
| `gh_search` | Поиск issues и PR синтаксисом GitHub (отдельная квота). |
|
|
75
|
+
| `pr_create`, `pr_update` | Открыть PR из head-ветки; правка заголовка, тела, состояния, базовой ветки. |
|
|
76
|
+
| `pr_merge` | Слияние PR (merge/squash/rebase) с опциональным удалением head-ветки. |
|
|
77
|
+
| `gh_review` | Один обзорный пакет: метаданные, области, дифф с лимитом, комменты, сводка CI и детерминированные находки (секреты, миграции, CI-конфиг, изменения в исходниках без тестов, крупный дифф). |
|
|
78
|
+
| `review_post` | Публикация обзора: сводный комментарий или построчные inline-замечания. |
|
|
79
|
+
| `gh_checks` | Check-runs, статусы коммита и единый вердикт. |
|
|
80
|
+
| `ci_run` | Одноразовый обзор PR с вердиктом по правилам. |
|
|
81
|
+
|
|
82
|
+
### Публикация зеркала
|
|
83
|
+
|
|
84
|
+
| Инструмент | Что делает |
|
|
85
|
+
|---|---|
|
|
86
|
+
| `gh_mirror_check` | Read-only план: какие продуктовые файлы уедут в зеркало, сколько останется и почему публикация должна быть отклонена. |
|
|
87
|
+
| `gh_mirror_publish` | Публикация санитизированного дерева: один коммит поверх зеркальной ветки, fast-forward, **никогда не force**. `dryRun: true` — только превью; запись требует `confirm: true`. |
|
|
88
|
+
|
|
89
|
+
Allowlist — состав `package.json → files` плюс `.gitignore`, `LICENSE`, README-трио,
|
|
90
|
+
`CHANGELOG.md` и `cordis.patch.yml`. `docs/**` и инструкции агентов запрещены даже при
|
|
91
|
+
наличии в манифесте; поставляемый инструментарий вроде `scripts/**` публикуется, потому
|
|
92
|
+
что входит в пакет.
|
|
93
|
+
|
|
94
|
+
### Запуски workflow
|
|
95
|
+
|
|
96
|
+
| Инструмент | Что делает |
|
|
97
|
+
|---|---|
|
|
98
|
+
| `gh_run_list`, `gh_run_view` | Список запусков (фильтры по ветке, workflow, статусу) и чтение одного запуска. |
|
|
99
|
+
| `gh_run_jobs` | Джобы с шагами и отдельно — упавшие шаги; обычно этого достаточно для диагноза. |
|
|
100
|
+
| `gh_run_rerun`, `gh_run_cancel` | Перезапуск всех или только упавших джоб; отмена идущего запуска (нужно `confirm: true`). |
|
|
101
|
+
| `gh_run_logs` | Возвращает адрес архива логов: GitHub отвечает редиректом на zip, который не тянется в разговор. |
|
|
102
|
+
|
|
103
|
+
### Настройки репозитория
|
|
104
|
+
|
|
105
|
+
| Инструмент | Что делает |
|
|
106
|
+
|---|---|
|
|
107
|
+
| `gh_variable_list/set/delete` | Actions-переменные: в репозитории или в конкретном окружении. |
|
|
108
|
+
| `gh_secret_list/set/delete` | Actions-секреты. Установка использует sealed-box шифрование через опциональный `tweetnacl`; без него инструмент говорит, что установить, а не пишет испорченное значение. |
|
|
109
|
+
| `gh_ruleset_list/view/apply/delete` | Rulesets: чтение, создание, обновление, удаление. |
|
|
110
|
+
| `gh_branch_protection_get/set/delete` | Классическая защита веток: обязательные ревью, статус-чеки, принуждение для админов, флаги force-push и удаления. |
|
|
111
|
+
|
|
112
|
+
### Карточка настроек
|
|
113
|
+
|
|
114
|
+
Настройки живут на странице плагина (списочная посадка `plugins.item`, плюс посадка строки
|
|
115
|
+
и легаси `settings.plugin.item`): имя учётной записи, репозиторий по умолчанию, база API и
|
|
116
|
+
таймаут. Карточка проверяет **статус** снимка настроек и честно сообщает, когда сервис
|
|
117
|
+
настроек недоступен, вместо того чтобы рисовать рабочий на вид формы.
|
|
118
|
+
|
|
119
|
+
## Фоновые обзоры и команды
|
|
120
|
+
|
|
121
|
+
`gh_review_job` запускает обзор и сразу возвращает id задачи, `gh_review_job_status` читает
|
|
122
|
+
результат. Если в композиции есть реестр задач, работа видна и отменяема в интерфейсе; если
|
|
123
|
+
нет — выполняется внутри плагина.
|
|
124
|
+
|
|
125
|
+
Слэш-команды — быстрый путь для человека: `/pr create [title]`, `/review [number]`,
|
|
126
|
+
`/issue new <title> | list | show <number>`, `/gh [группа|инструмент]`. Команда **не пишет**
|
|
127
|
+
в GitHub сама: она передаёт модели инструкцию, поэтому запись всё равно проходит через
|
|
128
|
+
подтверждение.
|
|
129
|
+
|
|
130
|
+
## Безопасность
|
|
131
|
+
|
|
132
|
+
- Токен живёт в сервисе учётных данных DSH; в настройках только его имя.
|
|
133
|
+
- Чтение не меняет состояние; изменения подтверждаются явно; удаление репозитория, его
|
|
134
|
+
перенос и удаление организации отклоняются сразу.
|
|
135
|
+
- Клиент никогда не печатает токен, а любая ошибка возвращается значением
|
|
136
|
+
(`ok: false` с `status`, `code`, `rateLimit`), а не исключением.
|
|
137
|
+
|
|
138
|
+
## План
|
|
139
|
+
|
|
140
|
+
Блокеры релиза, по порядку:
|
|
141
|
+
|
|
142
|
+
1. **Паритет** — `pr_create`, `pr_update`, `pr_merge`, `gh_review`, `review_post`,
|
|
143
|
+
`gh_issue`, `issue_open`, `issue_comment`, `issue_close`, `gh_search`,
|
|
144
|
+
`gh_repo_search`, `gh_repo`, `gh_file`, `gh_checks`, `ci_run`.
|
|
145
|
+
2. **Зеркало** — `gh_mirror_check`, `gh_mirror_publish`: санитизированное дерево продукта
|
|
146
|
+
(allowlist из `package.json → files`), один коммит поверх зеркальной ветки,
|
|
147
|
+
fast-forward, никогда не force.
|
|
148
|
+
3. **Запуски workflow** — `gh_run_list/view/rerun/cancel/logs`.
|
|
149
|
+
4. **Настройки репозитория** — секреты, переменные, rulesets, защита веток,
|
|
150
|
+
`gh_repo_create`, `gh_repo_edit`.
|
|
151
|
+
5. Карточка настроек на странице плагинов, локали `en`/`zh`, дизайн-контракт.
|
|
152
|
+
|
|
153
|
+
## Разработка
|
|
154
|
+
|
|
155
|
+
```bash
|
|
156
|
+
npm test # node --test, без харнесса и без сети: fetch подменяется
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
## Лицензия
|
|
160
|
+
|
|
161
|
+
MIT — см. [LICENSE](LICENSE).
|
package/README.zh.md
ADDED
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
# dsh-github-ops
|
|
2
|
+
|
|
3
|
+
面向 [DeepSeek Harness](https://github.com/topics/dsh-plugin) 的 GitHub 操作插件:发布(release)、
|
|
4
|
+
标签(tag)、受保护的通用 API 直通、工作流运行、密钥,以及经过净化的镜像发布。
|
|
5
|
+
|
|
6
|
+
插件的存在理由:发布流水线需要现有 GitHub 插件没有提供的能力——首先是 release 和 tag,
|
|
7
|
+
其次是只发布**产品**、而不是整个开发树的 GitHub 镜像。
|
|
8
|
+
|
|
9
|
+
> **状态:开发中,尚未发布。** 只有在插件具备完整工具集之后才会公开发布(见[路线图](#路线图))。
|
|
10
|
+
|
|
11
|
+
## 安装
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
dsh plugin --profile web add @goodandready/dsh-github-ops
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
需要在 DSH 凭据服务中保存 GitHub token。默认凭据名为 `GITHUB_TOKEN`,插件设置里只保存
|
|
18
|
+
这个**名称**。
|
|
19
|
+
|
|
20
|
+
## 设置
|
|
21
|
+
|
|
22
|
+
| 设置 | 默认值 | 含义 |
|
|
23
|
+
|---|---|---|
|
|
24
|
+
| `tokenEnv` | `GITHUB_TOKEN` | 依次在 DSH 凭据、环境变量与 `gh` CLI 中查找该名称;取值本身不写入设置。 |
|
|
25
|
+
| `tokenSource` | `auto` | 访问来源:`auto` 依次尝试 DSH 凭据、环境变量与 `gh` CLI 会话;可固定为 `credentials`、`env` 或 `gh`。 |
|
|
26
|
+
| `defaultRepository` | 空 | 未传 `repository` 时使用的 `owner/repo`。 |
|
|
27
|
+
| `baseUrl` | `https://api.github.com` | API 地址,GitHub Enterprise 时修改。 |
|
|
28
|
+
| `timeoutMs` | `30000` | 单次请求超时。 |
|
|
29
|
+
| `maxRetries` | `2` | 读取失败时的重试次数(写入不重试)。 |
|
|
30
|
+
| `reviewRulesJson` | 空 | 以 JSON 覆盖评审规则:`sensitivePaths`、`sensitiveSeverity`、`attentionPaths`、`migrationPaths`、`testsRequired`、`sourcePatterns`、`testPatterns`、`largeDiffLines`。 |
|
|
31
|
+
| `allowedActions` | 全部 | 允许执行的写操作;其余一律拒绝,且每个都会询问确认。 |
|
|
32
|
+
| `autoApprove` | 空 | 非交互运行(`DSH_GITHUB_OPS_UNATTENDED=1`)可免除询问的操作;破坏性操作永远不会被自动批准。 |
|
|
33
|
+
| `reviewJobTimeoutMs` | `120000` | 后台评审任务的最长运行时间。 |
|
|
34
|
+
|
|
35
|
+
## 工具
|
|
36
|
+
|
|
37
|
+
### Release
|
|
38
|
+
|
|
39
|
+
| 工具 | 作用 |
|
|
40
|
+
|---|---|
|
|
41
|
+
| `gh_release_list` | 按时间倒序列出 release(只读)。 |
|
|
42
|
+
| `gh_release_view` | 按 tag 读取单个 release:标记、说明、附件(只读)。 |
|
|
43
|
+
| `gh_release_create` | 为 tag 创建 release,可指定 commit。 |
|
|
44
|
+
| `gh_release_edit` | 修改标题、说明、draft/prerelease,以及**哪个 release 是 latest**。 |
|
|
45
|
+
| `gh_release_delete` | 删除 release(需要 `confirm: true`)。 |
|
|
46
|
+
|
|
47
|
+
`gh_release_edit` 配合 `makeLatest: true` 是保持仓库徽章指向当前版本的关键一步:之后再创建
|
|
48
|
+
旧版本的 release 会把 “Latest” 移回旧版本。
|
|
49
|
+
|
|
50
|
+
### Tag
|
|
51
|
+
|
|
52
|
+
| 工具 | 作用 |
|
|
53
|
+
|---|---|
|
|
54
|
+
| `gh_tag_list` | 列出 tag 及其 commit SHA(只读)。 |
|
|
55
|
+
| `gh_tag_create` | 创建 tag;带 `message` 时创建附带注释的 tag。 |
|
|
56
|
+
| `gh_tag_delete` | 删除 tag(需要 `confirm: true`)。 |
|
|
57
|
+
|
|
58
|
+
### 通用 API
|
|
59
|
+
|
|
60
|
+
`gh_api` 用于覆盖类型化工具未涉及的接口(refs、rulesets、organization、gist)。读取无需确认;
|
|
61
|
+
`POST`/`PATCH`/`PUT`/`DELETE` 需要 `confirm: true`。删除仓库、转移仓库、删除组织会被直接拒绝——
|
|
62
|
+
这类操作无法靠一次确认变得安全。
|
|
63
|
+
|
|
64
|
+
### Issue 与 Pull Request
|
|
65
|
+
|
|
66
|
+
| 工具 | 作用 |
|
|
67
|
+
|---|---|
|
|
68
|
+
| `gh_issue` | 列出或读取 issue(`action: list/get/comments`);PR 以 `kind: "pr"` 返回。 |
|
|
69
|
+
| `issue_open`、`issue_comment`、`issue_close` | 创建 issue、评论、关闭(可带原因)。 |
|
|
70
|
+
| `gh_search` | 使用 GitHub 搜索语法检索 issue 与 PR(独立配额)。 |
|
|
71
|
+
| `pr_create`、`pr_update` | 从 head 分支创建 PR;修改标题、正文、状态或目标分支。 |
|
|
72
|
+
| `pr_merge` | 合并 PR(merge/squash/rebase),可选择删除 head 分支。 |
|
|
73
|
+
| `gh_review` | 一个完整评审包:元数据、涉及范围、限量 diff、评论、CI 汇总与确定性发现(密钥、迁移、CI 配置、改源码未改测试、超大 diff)。 |
|
|
74
|
+
| `review_post` | 发布评审:一条汇总评论,或按行内联评论。 |
|
|
75
|
+
| `gh_checks` | 某个提交的 check runs、旧式状态与统一结论。 |
|
|
76
|
+
| `ci_run` | 对 PR 做一次性评审并给出基于规则的结论。 |
|
|
77
|
+
|
|
78
|
+
### 镜像发布
|
|
79
|
+
|
|
80
|
+
| 工具 | 作用 |
|
|
81
|
+
|---|---|
|
|
82
|
+
| `gh_mirror_check` | 只读计划:哪些产品文件会进入镜像、多少文件会留在原地、以及为何必须拒绝发布。 |
|
|
83
|
+
| `gh_mirror_publish` | 发布净化后的树:在镜像分支之上一个提交,fast-forward,**绝不 force**。`dryRun: true` 仅预览;写入需要 `confirm: true`。 |
|
|
84
|
+
|
|
85
|
+
白名单取自包清单自身的 `files`,加上 `.gitignore`、`LICENSE`、README 三件套、
|
|
86
|
+
`CHANGELOG.md` 和 `cordis.patch.yml`。即使清单里列了 `docs/**` 与代理说明文件也会被禁止;
|
|
87
|
+
像 `scripts/**` 这种随包发布的工具则会进入镜像,因为它属于包内容。
|
|
88
|
+
|
|
89
|
+
### 工作流运行
|
|
90
|
+
|
|
91
|
+
| 工具 | 作用 |
|
|
92
|
+
|---|---|
|
|
93
|
+
| `gh_run_list`、`gh_run_view` | 列出运行(可按分支、工作流、状态过滤)与读取单个运行。 |
|
|
94
|
+
| `gh_run_jobs` | 作业及其步骤,并单独列出失败的步骤——通常足以定位失败原因。 |
|
|
95
|
+
| `gh_run_rerun`、`gh_run_cancel` | 重跑全部或仅失败作业;取消进行中的运行(需要 `confirm: true`)。 |
|
|
96
|
+
| `gh_run_logs` | 返回日志压缩包地址:GitHub 以 302 指向 zip,不会把二进制拉进对话。 |
|
|
97
|
+
|
|
98
|
+
### 仓库设置
|
|
99
|
+
|
|
100
|
+
| 工具 | 作用 |
|
|
101
|
+
|---|---|
|
|
102
|
+
| `gh_variable_list/set/delete` | Actions 变量,仓库级或按环境。 |
|
|
103
|
+
| `gh_secret_list/set/delete` | Actions 密钥。写入使用 sealed-box 加密,需要可选的 `tweetnacl`;缺失时会明确说明需要安装什么,而不是写入无效值。 |
|
|
104
|
+
| `gh_ruleset_list/view/apply/delete` | 仓库 ruleset:读取、创建、更新、删除。 |
|
|
105
|
+
| `gh_branch_protection_get/set/delete` | 经典分支保护:必需评审、状态检查、管理员强制、force push 与删除开关。 |
|
|
106
|
+
|
|
107
|
+
### 插件设置卡片
|
|
108
|
+
|
|
109
|
+
设置在插件自己的页面上(插件列表座位 `plugins.item`,并保留行座位与旧版
|
|
110
|
+
`settings.plugin.item`):凭据名称、默认仓库、API 地址、请求超时。卡片会检查设置快照的
|
|
111
|
+
**状态**,在设置服务不可用时明确说明,而不是画出一个看似可用的表单。
|
|
112
|
+
|
|
113
|
+
## 后台评审与斜杠命令
|
|
114
|
+
|
|
115
|
+
`gh_review_job` 立即返回任务 id,`gh_review_job_status` 读取结果。宿主提供任务注册表时,
|
|
116
|
+
任务可在界面中查看与取消;否则在插件内部运行。
|
|
117
|
+
|
|
118
|
+
斜杠命令是人类的快捷入口:`/pr create [title]`、`/review [number]`、
|
|
119
|
+
`/issue new <title> | list | show <number>`、`/gh [分组|工具]`。命令本身**不会**写入 GitHub,
|
|
120
|
+
只是把指令交给模型,因此写入仍然经过审批关卡。
|
|
121
|
+
|
|
122
|
+
## 安全边界
|
|
123
|
+
|
|
124
|
+
- token 只存在于 DSH 凭据服务,设置中只有名称;
|
|
125
|
+
- 读取操作不改变状态,写入必须显式确认;删除仓库、转移仓库、删除组织会被直接拒绝;
|
|
126
|
+
- 客户端不会输出 token,失败以返回值形式报告(`ok: false` 及 `status`、`code`、`rateLimit`),
|
|
127
|
+
不会中断整个回合;
|
|
128
|
+
- `gh_review` 的发现是确定性规则:指出需要关注的地方,绝不冒充正确性结论。
|
|
129
|
+
|
|
130
|
+
## 路线图
|
|
131
|
+
|
|
132
|
+
按顺序的发布阻塞项:
|
|
133
|
+
|
|
134
|
+
1. **功能对齐** —— `pr_create`、`pr_update`、`pr_merge`、`gh_review`、`review_post`、
|
|
135
|
+
`gh_issue`、`issue_open`、`issue_comment`、`issue_close`、`gh_search`、
|
|
136
|
+
`gh_repo_search`、`gh_repo`、`gh_file`、`gh_checks`、`ci_run`。
|
|
137
|
+
2. **镜像** —— `gh_mirror_check`、`gh_mirror_publish`:净化后的产品树(白名单取自
|
|
138
|
+
`package.json → files`),在镜像分支之上一个提交,fast-forward,绝不 force。
|
|
139
|
+
3. **工作流运行** —— `gh_run_list/view/rerun/cancel/logs`。
|
|
140
|
+
4. **仓库设置** —— secrets、variables、rulesets、分支保护、`gh_repo_create`、`gh_repo_edit`。
|
|
141
|
+
5. 插件页设置卡片、`en`/`zh` 语言包、设计契约。
|
|
142
|
+
|
|
143
|
+
## 开发
|
|
144
|
+
|
|
145
|
+
```bash
|
|
146
|
+
npm test # node --test,不需要 harness,也不访问网络:fetch 是注入的
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
## 许可证
|
|
150
|
+
|
|
151
|
+
MIT —— 见 [LICENSE](LICENSE)。
|
package/cordis.patch.yml
ADDED