@pecot/workflow-mcp 5.0.0 → 7.0.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/.claude-plugin/plugin.json +1 -1
- package/README.md +27 -22
- package/cli/dist/cli.js +6 -1
- package/cli/dist/commands/board-add.d.ts +3 -0
- package/cli/dist/commands/board-add.js +69 -0
- package/cli/dist/commands/board-judgment.d.ts +69 -0
- package/cli/dist/commands/board-judgment.js +150 -0
- package/cli/dist/commands/board-move.d.ts +3 -0
- package/cli/dist/commands/board-move.js +65 -0
- package/cli/dist/commands/board-readiness.d.ts +34 -0
- package/cli/dist/commands/board-readiness.js +108 -0
- package/cli/dist/commands/board-show.d.ts +3 -0
- package/cli/dist/commands/board-show.js +75 -0
- package/cli/dist/commands/board-sync.d.ts +3 -0
- package/cli/dist/commands/board-sync.js +120 -0
- package/cli/dist/commands/board-view.d.ts +151 -0
- package/cli/dist/commands/board-view.js +293 -0
- package/cli/dist/commands/board.d.ts +3 -0
- package/cli/dist/commands/board.js +12 -0
- package/cli/dist/commands/branch.d.ts +3 -0
- package/cli/dist/commands/branch.js +111 -0
- package/cli/dist/commands/command-binding.js +4 -0
- package/cli/dist/commands/command-definition.d.ts +39 -8
- package/cli/dist/commands/command-definition.js +20 -7
- package/cli/dist/commands/command-help.js +2 -2
- package/cli/dist/commands/command-hint.d.ts +5 -0
- package/cli/dist/commands/command-hint.js +13 -0
- package/cli/dist/commands/command-stop.d.ts +5 -3
- package/cli/dist/commands/command-stop.js +7 -6
- package/cli/dist/commands/failure-kind.d.ts +3 -0
- package/cli/dist/commands/failure-kind.js +35 -0
- package/cli/dist/commands/failure.d.ts +6 -0
- package/cli/dist/commands/failure.js +29 -3
- package/cli/dist/commands/github-client.d.ts +6 -2
- package/cli/dist/commands/github-client.js +13 -3
- package/cli/dist/commands/help.js +8 -13
- package/cli/dist/commands/issue-board.d.ts +61 -0
- package/cli/dist/commands/issue-board.js +85 -1
- package/cli/dist/commands/issue-comment.js +66 -30
- package/cli/dist/commands/issue-create.js +632 -92
- package/cli/dist/commands/issue-dependency.d.ts +3 -0
- package/cli/dist/commands/issue-dependency.js +310 -0
- package/cli/dist/commands/issue-readiness.d.ts +122 -0
- package/cli/dist/commands/issue-readiness.js +253 -0
- package/cli/dist/commands/issue-reopen.d.ts +3 -0
- package/cli/dist/commands/issue-reopen.js +130 -0
- package/cli/dist/commands/issue-shared.d.ts +33 -20
- package/cli/dist/commands/issue-shared.js +84 -76
- package/cli/dist/commands/issue-show.d.ts +3 -0
- package/cli/dist/commands/issue-show.js +239 -0
- package/cli/dist/commands/issue.d.ts +0 -1
- package/cli/dist/commands/issue.js +6 -8
- package/cli/dist/commands/names.d.ts +33 -0
- package/cli/dist/commands/names.js +63 -0
- package/cli/dist/commands/output.d.ts +32 -4
- package/cli/dist/commands/output.js +28 -8
- package/cli/dist/commands/pr-merge.d.ts +3 -0
- package/cli/dist/commands/pr-merge.js +230 -0
- package/cli/dist/commands/pr-reference.d.ts +8 -0
- package/cli/dist/commands/pr-reference.js +30 -0
- package/cli/dist/commands/pr-restack.d.ts +6 -0
- package/cli/dist/commands/pr-restack.js +233 -0
- package/cli/dist/commands/pr-waiting.d.ts +59 -0
- package/cli/dist/commands/pr-waiting.js +143 -0
- package/cli/dist/commands/pr.d.ts +23 -0
- package/cli/dist/commands/pr.js +378 -366
- package/cli/dist/commands/project-sync.d.ts +12 -3
- package/cli/dist/commands/project-sync.js +23 -13
- package/cli/dist/commands/project.d.ts +3 -2
- package/cli/dist/commands/project.js +371 -177
- package/cli/dist/commands/registry.js +15 -10
- package/cli/dist/commands/release.d.ts +2 -2
- package/cli/dist/commands/release.js +118 -130
- package/cli/dist/commands/renamed-commands.d.ts +26 -0
- package/cli/dist/commands/renamed-commands.js +53 -0
- package/cli/dist/commands/repository-match.js +9 -3
- package/cli/dist/commands/session-finish.d.ts +3 -0
- package/cli/dist/commands/session-finish.js +383 -0
- package/cli/dist/commands/session-start.d.ts +3 -0
- package/cli/dist/commands/session-start.js +252 -0
- package/cli/dist/commands/session.d.ts +3 -0
- package/cli/dist/commands/session.js +186 -32
- package/cli/dist/commands/tracker-sync-dependabot.d.ts +7 -0
- package/cli/dist/commands/{dependabot.js → tracker-sync-dependabot.js} +76 -68
- package/cli/dist/commands/tracker-sync-security.d.ts +7 -0
- package/cli/dist/commands/{security.js → tracker-sync-security.js} +71 -64
- package/cli/dist/commands/tracker-sync.d.ts +37 -0
- package/cli/dist/commands/tracker-sync.js +18 -6
- package/cli/dist/commands/tracker.d.ts +3 -0
- package/cli/dist/commands/tracker.js +20 -0
- package/cli/dist/commands/usage-error.d.ts +4 -0
- package/cli/dist/commands/usage-error.js +6 -0
- package/cli/dist/commands/work-target.d.ts +20 -3
- package/cli/dist/commands/work-target.js +49 -6
- package/cli/dist/commands/worktree.js +103 -33
- package/cli/dist/domain/batch-plan.d.ts +73 -0
- package/cli/dist/domain/batch-plan.js +114 -0
- package/cli/dist/domain/blocked-by-change.d.ts +99 -0
- package/cli/dist/domain/blocked-by-change.js +101 -0
- package/cli/dist/domain/board-move.d.ts +90 -0
- package/cli/dist/domain/board-move.js +92 -0
- package/cli/dist/domain/branch-name.js +1 -1
- package/cli/dist/domain/command-hint.d.ts +85 -0
- package/cli/dist/domain/command-hint.js +148 -0
- package/cli/dist/domain/config.d.ts +4 -0
- package/cli/dist/domain/config.js +11 -1
- package/cli/dist/domain/dependabot.js +1 -1
- package/cli/dist/domain/errors.d.ts +5 -0
- package/cli/dist/domain/errors.js +5 -0
- package/cli/dist/domain/format.d.ts +51 -4
- package/cli/dist/domain/format.js +72 -6
- package/cli/dist/domain/frontmatter.d.ts +18 -3
- package/cli/dist/domain/frontmatter.js +38 -12
- package/cli/dist/domain/issue-order.d.ts +55 -0
- package/cli/dist/domain/issue-order.js +65 -0
- package/cli/dist/domain/issue-readout.d.ts +36 -4
- package/cli/dist/domain/pull-request.d.ts +71 -4
- package/cli/dist/domain/pull-request.js +59 -10
- package/cli/dist/domain/readiness.d.ts +44 -0
- package/cli/dist/domain/readiness.js +153 -5
- package/cli/dist/domain/reference-parser.d.ts +3 -1
- package/cli/dist/domain/reference-parser.js +6 -2
- package/cli/dist/domain/release.d.ts +7 -3
- package/cli/dist/domain/release.js +5 -12
- package/cli/dist/domain/repository-policy.d.ts +9 -3
- package/cli/dist/domain/repository-policy.js +8 -7
- package/cli/dist/domain/repository-resolver.js +4 -1
- package/cli/dist/domain/restack.d.ts +62 -0
- package/cli/dist/domain/restack.js +53 -0
- package/cli/dist/domain/security-alerts.js +1 -1
- package/cli/dist/domain/state.d.ts +69 -0
- package/cli/dist/domain/state.js +67 -1
- package/cli/dist/domain/work-start.d.ts +30 -0
- package/cli/dist/domain/work-start.js +42 -0
- package/cli/dist/infra/authored-notes.d.ts +1 -1
- package/cli/dist/infra/authored-notes.js +10 -4
- package/cli/dist/infra/config-store.d.ts +4 -0
- package/cli/dist/infra/config-store.js +13 -0
- package/cli/dist/infra/git.d.ts +76 -0
- package/cli/dist/infra/git.js +123 -1
- package/cli/dist/infra/github/client.d.ts +5 -0
- package/cli/dist/infra/github/client.js +10 -7
- package/cli/dist/infra/github/errors.d.ts +18 -0
- package/cli/dist/infra/github/errors.js +22 -0
- package/cli/dist/infra/github/issues.d.ts +39 -3
- package/cli/dist/infra/github/issues.js +178 -23
- package/cli/dist/infra/github/projects.d.ts +35 -0
- package/cli/dist/infra/github/projects.js +89 -8
- package/cli/dist/infra/github/pulls.d.ts +105 -2
- package/cli/dist/infra/github/pulls.js +172 -5
- package/cli/dist/infra/github/queries.d.ts +15 -4
- package/cli/dist/infra/github/queries.js +203 -40
- package/cli/dist/infra/github/readout.d.ts +5 -1
- package/cli/dist/infra/github/readout.js +11 -33
- package/cli/dist/infra/github/repos.d.ts +18 -0
- package/cli/dist/infra/github/repos.js +31 -0
- package/cli/dist/infra/nx-scope.d.ts +1 -1
- package/cli/dist/infra/nx-scope.js +1 -1
- package/cli/dist/infra/state-store.d.ts +10 -1
- package/cli/dist/infra/state-store.js +14 -2
- package/cli/dist/infra/worktree-links.d.ts +3 -0
- package/cli/dist/infra/worktree-links.js +8 -1
- package/cli/dist/infra/worktree.d.ts +12 -1
- package/cli/dist/infra/worktree.js +40 -23
- package/cli/dist/mcp/result.d.ts +82 -7
- package/cli/dist/mcp/result.js +139 -19
- package/cli/dist/mcp/server.d.ts +2 -2
- package/cli/dist/mcp/server.js +57 -10
- package/cli/templates/comment/plan.md +14 -0
- package/cli/templates/comment/review-findings.md +3 -2
- package/cli/templates/issue/bug.md +13 -4
- package/cli/templates/issue/task-implement.md +13 -6
- package/cli/templates/issue/task.md +13 -4
- package/cli/templates/workflow/pecot-board-sync.yml +84 -0
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
- package/cli/dist/commands/dependabot.d.ts +0 -3
- package/cli/dist/commands/issue-project.d.ts +0 -3
- package/cli/dist/commands/issue-project.js +0 -176
- package/cli/dist/commands/issue-quick.d.ts +0 -3
- package/cli/dist/commands/issue-quick.js +0 -126
- package/cli/dist/commands/issue-read.d.ts +0 -3
- package/cli/dist/commands/issue-read.js +0 -80
- package/cli/dist/commands/project-info.d.ts +0 -48
- package/cli/dist/commands/project-info.js +0 -181
- package/cli/dist/commands/repository.d.ts +0 -5
- package/cli/dist/commands/repository.js +0 -265
- package/cli/dist/commands/security.d.ts +0 -3
|
@@ -10,6 +10,7 @@ template: review-findings
|
|
|
10
10
|
- 見出しの `—` の後は、何がどうなったか(どうなるか)を、主語と述語のある 1 文で書く
|
|
11
11
|
- 行に紐づく指摘は、PR の該当行にインラインコメントとして投稿してある。本文をここに再掲しない
|
|
12
12
|
- 指摘 1 件に F-NN を 1 つ振る(F-01 から連番。外部のレビュアーの指摘も同じ連番)
|
|
13
|
+
- 視点の印は w-reviewer の指摘に付け、w-reviewer が返した `[tech]`・`[cuj]`・`[quality]` のどれかを書く。w-e2e-planner が返した CUJ の不合格は `[cuj]` にする。外部のレビュアーの指摘には付けない
|
|
13
14
|
- General には、行に紐づけられない指摘だけを書く(PR 本文・欠けているもの・差分の外の既存行・横断的な設計)
|
|
14
15
|
- Disposition には、インラインにした分も含めて全 F-NN を並べる。URL は、自分が投稿したコメントなら `html_url`、外部のレビュアーなら元のスレッド。インラインでない分は省く
|
|
15
16
|
- 想定する方針は「対応」か「対応不要」で書く。保留は使わない
|
|
@@ -22,7 +23,7 @@ template: review-findings
|
|
|
22
23
|
|
|
23
24
|
### General — PR 本文に CSV の文字コードの説明が無い
|
|
24
25
|
|
|
25
|
-
- **F-02** [tech
|
|
26
|
+
- **F-02** [tech] PR 本文の Summary に、書き出す CSV の文字コード(UTF-8・BOM の有無)が書かれていない
|
|
26
27
|
|
|
27
28
|
### Disposition — 2 件の指摘は、どちらも直す
|
|
28
29
|
|
|
@@ -34,7 +35,7 @@ template: review-findings
|
|
|
34
35
|
|
|
35
36
|
### General — <行に紐づかない指摘を1行で>
|
|
36
37
|
|
|
37
|
-
- **F-02** [
|
|
38
|
+
- **F-02** [<視点の印>] <指摘の要旨(該当箇所)>
|
|
38
39
|
|
|
39
40
|
### Disposition — <F-NN ごとの想定対応方針を1行で>
|
|
40
41
|
|
|
@@ -2,12 +2,11 @@
|
|
|
2
2
|
title: ""
|
|
3
3
|
type: bug
|
|
4
4
|
repository: ""
|
|
5
|
-
status: ready
|
|
6
5
|
priority: ""
|
|
7
6
|
size: ""
|
|
8
7
|
labels: []
|
|
9
8
|
parent_epic: ""
|
|
10
|
-
|
|
9
|
+
blocked_by: []
|
|
11
10
|
---
|
|
12
11
|
|
|
13
12
|
<!--
|
|
@@ -20,8 +19,18 @@ order: ""
|
|
|
20
19
|
フィールド:
|
|
21
20
|
- repository: 起票先 `owner/repo` 必須
|
|
22
21
|
- parent_epic: `owner/repo/number` 推奨。番号のみは aggregation_repo 解釈なので別リポの Epic を指すなら full path 必須
|
|
23
|
-
-
|
|
24
|
-
-
|
|
22
|
+
- blocked_by: この Issue の着手を止める前提の一覧。前提が無ければ `[]` のまま
|
|
23
|
+
- `issue` は、前提の Issue を指す `owner/repo/N`
|
|
24
|
+
- マージを待つ前提だけ、`wait: merge` と、待つ理由の 1 文の `reason`(改行しない)を足す
|
|
25
|
+
```yaml
|
|
26
|
+
blocked_by:
|
|
27
|
+
- issue: acme/mytool/12
|
|
28
|
+
- issue: acme/mytool/13
|
|
29
|
+
wait: merge
|
|
30
|
+
reason: "action は、既定のブランチのプラグインを入れる。main に入るまで、確認ができない"
|
|
31
|
+
```
|
|
32
|
+
- order・status: 書かない。通し番号(タイトル先頭の `#{epic}-NN`)と置く列(前提があれば `Blocked`、無ければ `Ready`)は CLI が決める
|
|
33
|
+
- 起票ルール: skills/w-help/references/issue-flow-rules.md (投稿先 / parent_epic / blocked_by の判定基準)
|
|
25
34
|
|
|
26
35
|
例:
|
|
27
36
|
|
|
@@ -3,13 +3,11 @@ title: ""
|
|
|
3
3
|
type: task
|
|
4
4
|
template: task-implement
|
|
5
5
|
repository: ""
|
|
6
|
-
status: ready
|
|
7
6
|
priority: ""
|
|
8
7
|
size: ""
|
|
9
8
|
labels: []
|
|
10
9
|
parent_epic: ""
|
|
11
|
-
|
|
12
|
-
parallel: ""
|
|
10
|
+
blocked_by: []
|
|
13
11
|
---
|
|
14
12
|
|
|
15
13
|
<!--
|
|
@@ -23,9 +21,18 @@ parallel: ""
|
|
|
23
21
|
フィールド:
|
|
24
22
|
- repository: 実装が行われるリポ `owner/repo` 必須
|
|
25
23
|
- parent_epic: 親 Epic を `owner/repo/number` で指定(推奨)
|
|
26
|
-
-
|
|
27
|
-
-
|
|
28
|
-
-
|
|
24
|
+
- blocked_by: このフェーズの着手を止める前提の一覧。前提が無ければ `[]` のまま
|
|
25
|
+
- `issue` は、同じ一括投稿のファイルのキー(`suffix`)か、Issue 化済みのフェーズを指す `owner/repo/N`
|
|
26
|
+
- マージを待つ前提だけ、`wait: merge` と、前提の表の `理由` の文をそのまま写した `reason`(改行しない)を足す
|
|
27
|
+
```yaml
|
|
28
|
+
blocked_by:
|
|
29
|
+
- issue: phase3
|
|
30
|
+
- issue: phase4
|
|
31
|
+
wait: merge
|
|
32
|
+
reason: "action は、既定のブランチのプラグインを入れる。main に入るまで、確認ができない"
|
|
33
|
+
```
|
|
34
|
+
- order・status: 書かない。通し番号と置く列は CLI が決める
|
|
35
|
+
- 起票ルール: skills/w-help/references/issue-flow-rules.md (投稿先 / parent_epic / blocked_by の判定基準)
|
|
29
36
|
|
|
30
37
|
例:
|
|
31
38
|
|
|
@@ -2,12 +2,11 @@
|
|
|
2
2
|
title: ""
|
|
3
3
|
type: task
|
|
4
4
|
repository: ""
|
|
5
|
-
status: ready
|
|
6
5
|
priority: ""
|
|
7
6
|
size: ""
|
|
8
7
|
labels: []
|
|
9
8
|
parent_epic: ""
|
|
10
|
-
|
|
9
|
+
blocked_by: []
|
|
11
10
|
---
|
|
12
11
|
|
|
13
12
|
<!--
|
|
@@ -19,8 +18,18 @@ order: ""
|
|
|
19
18
|
フィールド:
|
|
20
19
|
- repository: 起票先 `owner/repo` 必須
|
|
21
20
|
- parent_epic: `owner/repo/number` 推奨。番号のみは aggregation_repo 解釈なので別リポの Epic を指すなら full path 必須
|
|
22
|
-
-
|
|
23
|
-
-
|
|
21
|
+
- blocked_by: この Issue の着手を止める前提の一覧。前提が無ければ `[]` のまま
|
|
22
|
+
- `issue` は、前提の Issue を指す `owner/repo/N`
|
|
23
|
+
- マージを待つ前提だけ、`wait: merge` と、待つ理由の 1 文の `reason`(改行しない)を足す
|
|
24
|
+
```yaml
|
|
25
|
+
blocked_by:
|
|
26
|
+
- issue: acme/mytool/12
|
|
27
|
+
- issue: acme/mytool/13
|
|
28
|
+
wait: merge
|
|
29
|
+
reason: "action は、既定のブランチのプラグインを入れる。main に入るまで、確認ができない"
|
|
30
|
+
```
|
|
31
|
+
- order・status: 書かない。通し番号(タイトル先頭の `#{epic}-NN`)と置く列(前提があれば `Blocked`、無ければ `Ready`)は CLI が決める
|
|
32
|
+
- 起票ルール: skills/w-help/references/issue-flow-rules.md (投稿先 / parent_epic / blocked_by の判定基準)
|
|
24
33
|
|
|
25
34
|
例:
|
|
26
35
|
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
# Place this file at .github/workflows/pecot-board-sync.yml in your repository.
|
|
2
|
+
#
|
|
3
|
+
# This workflow runs `pecot board sync` after PRs and issues change.
|
|
4
|
+
# The command fixes the Status column and label of the pecot project board.
|
|
5
|
+
# It reads the whole board on every run, so the trigger only decides when it runs.
|
|
6
|
+
#
|
|
7
|
+
# Set one of the two token setups in Settings > Secrets and variables > Actions.
|
|
8
|
+
# The job is skipped until one of them exists.
|
|
9
|
+
# GitHub App.
|
|
10
|
+
# Use it when the board and this repository have the same organization as owner.
|
|
11
|
+
# The token covers only the installation on that owner (owner: github.repository_owner).
|
|
12
|
+
# Set variable PECOT_BOARD_SYNC_APP_CLIENT_ID.
|
|
13
|
+
# Set secret PECOT_BOARD_SYNC_APP_PRIVATE_KEY.
|
|
14
|
+
# Personal access token.
|
|
15
|
+
# Use it for a personal account board, or when the board owner differs from the repository.
|
|
16
|
+
# Set variable PECOT_BOARD_SYNC_USE_PAT to true.
|
|
17
|
+
# Set secret PECOT_BOARD_SYNC_TOKEN.
|
|
18
|
+
#
|
|
19
|
+
# GitHub Enterprise Server names the token variable after the host.
|
|
20
|
+
# The name is PECOT_GITHUB_<HOST>_TOKEN, with the host upper-cased and dots replaced by underscores.
|
|
21
|
+
# For example, ghe.example.com gives PECOT_GITHUB_GHE_EXAMPLE_COM_TOKEN.
|
|
22
|
+
# Change the name under `env:` in the last step.
|
|
23
|
+
#
|
|
24
|
+
# pull_request_target runs the workflow from the default branch.
|
|
25
|
+
# Secrets are passed to PRs from forks, so this workflow never checks out code from a PR.
|
|
26
|
+
name: pecot board sync
|
|
27
|
+
|
|
28
|
+
on:
|
|
29
|
+
pull_request_target:
|
|
30
|
+
types: [opened, reopened, closed, ready_for_review, converted_to_draft]
|
|
31
|
+
issues:
|
|
32
|
+
types: [closed, reopened]
|
|
33
|
+
workflow_dispatch:
|
|
34
|
+
# Optional periodic run. Choose the interval and uncomment.
|
|
35
|
+
# Actions minutes are billed for private repositories.
|
|
36
|
+
# schedule:
|
|
37
|
+
# - cron: "0 * * * *"
|
|
38
|
+
|
|
39
|
+
permissions:
|
|
40
|
+
contents: read
|
|
41
|
+
|
|
42
|
+
concurrency:
|
|
43
|
+
group: pecot-board-sync
|
|
44
|
+
cancel-in-progress: false
|
|
45
|
+
|
|
46
|
+
jobs:
|
|
47
|
+
sync:
|
|
48
|
+
# A job-level if cannot read secrets, so variables tell whether a token is set up.
|
|
49
|
+
# Runs started by Dependabot are skipped because secrets are not always passed to them.
|
|
50
|
+
# The actor is whoever started the run, so a human merging a Dependabot PR still runs.
|
|
51
|
+
if: ${{ (vars.PECOT_BOARD_SYNC_APP_CLIENT_ID != '' || vars.PECOT_BOARD_SYNC_USE_PAT == 'true') && github.actor != 'dependabot[bot]' }}
|
|
52
|
+
runs-on: ubuntu-latest
|
|
53
|
+
timeout-minutes: 15
|
|
54
|
+
steps:
|
|
55
|
+
# No ref: the default branch is checked out, which holds the project settings.
|
|
56
|
+
- name: Checkout
|
|
57
|
+
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
|
58
|
+
with:
|
|
59
|
+
persist-credentials: false
|
|
60
|
+
|
|
61
|
+
- name: Set up Node.js
|
|
62
|
+
uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
|
|
63
|
+
with:
|
|
64
|
+
node-version: "24.22.1"
|
|
65
|
+
|
|
66
|
+
- name: Generate GitHub App token
|
|
67
|
+
id: app-token
|
|
68
|
+
if: ${{ vars.PECOT_BOARD_SYNC_APP_CLIENT_ID != '' }}
|
|
69
|
+
uses: actions/create-github-app-token@64ab729a6294000f5aa4a4bc0b73d1f32bc45510 # v3.3.0
|
|
70
|
+
with:
|
|
71
|
+
client-id: ${{ vars.PECOT_BOARD_SYNC_APP_CLIENT_ID }}
|
|
72
|
+
private-key: ${{ secrets.PECOT_BOARD_SYNC_APP_PRIVATE_KEY }}
|
|
73
|
+
owner: ${{ github.repository_owner }}
|
|
74
|
+
permission-organization-projects: write
|
|
75
|
+
permission-issues: read
|
|
76
|
+
permission-pull-requests: read
|
|
77
|
+
permission-contents: read
|
|
78
|
+
|
|
79
|
+
# Pin the major version here. Raise it when the plugin's major version is raised.
|
|
80
|
+
# --prefix=/ keeps npx from stopping in a repository that declares pnpm devEngines.
|
|
81
|
+
- name: Sync the board
|
|
82
|
+
env:
|
|
83
|
+
PECOT_GITHUB_COM_TOKEN: ${{ steps.app-token.outputs.token || secrets.PECOT_BOARD_SYNC_TOKEN }}
|
|
84
|
+
run: npx -y --prefix=/ @pecot/workflow-mcp@7 board sync
|
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pecot/workflow-mcp",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "7.0.0",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "@pecot/workflow-mcp",
|
|
9
|
-
"version": "
|
|
9
|
+
"version": "7.0.0",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@modelcontextprotocol/server": "^2.4.0",
|
package/package.json
CHANGED
|
@@ -1,176 +0,0 @@
|
|
|
1
|
-
/* eslint-disable @typescript-eslint/prefer-readonly-parameter-types -- 引数の型は readonly にできない */
|
|
2
|
-
// add-to-project・update-issue-status・issue reopen。cli/commands/issue.py の移植。
|
|
3
|
-
import { setTimeout as delay } from 'node:timers/promises';
|
|
4
|
-
import { z } from 'zod';
|
|
5
|
-
import { getFieldId, getOptionId } from '../domain/config.js';
|
|
6
|
-
import { GitHubAPIError } from '../infra/github/errors.js';
|
|
7
|
-
import { defineCommand } from './command-definition.js';
|
|
8
|
-
import { addIssueToBoard, setIssueField } from './issue-board.js';
|
|
9
|
-
import { stopWith, requireActiveConfigPlain } from './command-stop.js';
|
|
10
|
-
import { createGitHubClient } from './github-client.js';
|
|
11
|
-
import { ensureRepositoryInProject, exitInvalidStatus, ISSUE_REF_DESCRIPTION, issuePath, parseIssueReferenceOrExit, runWithExit, VALID_STATUSES, } from './issue-shared.js';
|
|
12
|
-
import { createOutput } from './output.js';
|
|
13
|
-
// Projects V2 の自動化が Issue をもう一度閉じることがあるため、status を設定した後に待つ
|
|
14
|
-
const AUTOMATION_WAIT_MILLISECONDS = 3000;
|
|
15
|
-
// クライアントを作り、リポジトリがプロジェクトにあることを確かめる。無ければ error と終了コード 1
|
|
16
|
-
async function connectToProject(output, config, owner, repository) {
|
|
17
|
-
const client = createGitHubClient(output, config.host);
|
|
18
|
-
await ensureRepositoryInProject(output, config, client, owner, repository, `repository ${owner}/${repository} is not in the project`);
|
|
19
|
-
return client;
|
|
20
|
-
}
|
|
21
|
-
function isStatusConfigured(config, status) {
|
|
22
|
-
const fieldId = getFieldId(config, 'workflow');
|
|
23
|
-
const optionId = getOptionId(config, 'workflow', status);
|
|
24
|
-
return fieldId !== undefined && fieldId !== '' && optionId !== undefined && optionId !== '';
|
|
25
|
-
}
|
|
26
|
-
// blocked は後から足せる option なので、足し方の hint を添える
|
|
27
|
-
function notConfiguredMessage(status) {
|
|
28
|
-
const base = `status '${status}' is not configured in the project`;
|
|
29
|
-
return status === 'blocked' ? `${base}\nhint: run pecot project init to add the Blocked option to the board` : base;
|
|
30
|
-
}
|
|
31
|
-
const ADD_TO_PROJECT = defineCommand({
|
|
32
|
-
path: ['add-to-project'],
|
|
33
|
-
description: 'Add an Issue to the project board with a GraphQL mutation (for an Issue created outside pecot)',
|
|
34
|
-
input: z.object({
|
|
35
|
-
issue_ref: z.string().describe(ISSUE_REF_DESCRIPTION),
|
|
36
|
-
status: z.string().default('ready').describe('Initial status (backlog/pending/blocked/ready/active/in_review/archived)'),
|
|
37
|
-
}),
|
|
38
|
-
positional: ['issue_ref'],
|
|
39
|
-
shortFlags: { status: '-s' },
|
|
40
|
-
interactive: false,
|
|
41
|
-
run: async (input, io) => {
|
|
42
|
-
const output = createOutput(false, io);
|
|
43
|
-
return await runWithExit(async () => {
|
|
44
|
-
const { status } = input;
|
|
45
|
-
if (status !== '' && !VALID_STATUSES.has(status))
|
|
46
|
-
exitInvalidStatus(output, status);
|
|
47
|
-
const config = requireActiveConfigPlain(output);
|
|
48
|
-
if (status !== '' && !isStatusConfigured(config, status)) {
|
|
49
|
-
stopWith(output, notConfiguredMessage(status));
|
|
50
|
-
}
|
|
51
|
-
const { owner, repository, number } = parseIssueReferenceOrExit(output, input.repo, input.issue_ref);
|
|
52
|
-
const target = `Issue ${issuePath(owner, repository, number)}`;
|
|
53
|
-
try {
|
|
54
|
-
const client = await connectToProject(output, config, owner, repository);
|
|
55
|
-
const { itemId } = await addIssueToBoard(client, config, owner, repository, number, undefined);
|
|
56
|
-
output.done({ verb: 'add', target: `${target} to project` });
|
|
57
|
-
if (status !== '') {
|
|
58
|
-
await setIssueField(client, config, itemId, 'workflow', status);
|
|
59
|
-
output.done({ verb: 'set', target: `${target} status ${status}` });
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
catch (error) {
|
|
63
|
-
if (!(error instanceof GitHubAPIError))
|
|
64
|
-
throw error;
|
|
65
|
-
stopWith(output, `could not add ${target} to project: ${error.message}`);
|
|
66
|
-
}
|
|
67
|
-
});
|
|
68
|
-
},
|
|
69
|
-
});
|
|
70
|
-
const UPDATE_ISSUE_STATUS = defineCommand({
|
|
71
|
-
path: ['update-issue-status'],
|
|
72
|
-
description: 'Update the status of an Issue on the project board by Issue number (pecot commands normally set the status themselves)',
|
|
73
|
-
input: z.object({
|
|
74
|
-
issue_ref: z.string().describe(ISSUE_REF_DESCRIPTION),
|
|
75
|
-
status: z.string().describe('Status (backlog/pending/blocked/ready/active/in_review/archived)'),
|
|
76
|
-
}),
|
|
77
|
-
positional: ['issue_ref', 'status'],
|
|
78
|
-
interactive: false,
|
|
79
|
-
run: async (input, io) => {
|
|
80
|
-
const output = createOutput(false, io);
|
|
81
|
-
return await runWithExit(async () => {
|
|
82
|
-
const { status } = input;
|
|
83
|
-
if (!VALID_STATUSES.has(status))
|
|
84
|
-
exitInvalidStatus(output, status);
|
|
85
|
-
const config = requireActiveConfigPlain(output);
|
|
86
|
-
const { owner, repository, number } = parseIssueReferenceOrExit(output, input.repo, input.issue_ref);
|
|
87
|
-
const target = `Issue ${issuePath(owner, repository, number)}`;
|
|
88
|
-
try {
|
|
89
|
-
const client = await connectToProject(output, config, owner, repository);
|
|
90
|
-
const itemId = await client.getItemIdByIssue(config.project.id, owner, repository, number);
|
|
91
|
-
if (itemId === undefined) {
|
|
92
|
-
stopWith(output, `${target} is not on the project board\nhint: add it to the board first with add-to-project`);
|
|
93
|
-
}
|
|
94
|
-
if (!await setIssueField(client, config, itemId, 'workflow', status)) {
|
|
95
|
-
stopWith(output, notConfiguredMessage(status));
|
|
96
|
-
}
|
|
97
|
-
output.done({ verb: 'set', target: `${target} status ${status}` });
|
|
98
|
-
}
|
|
99
|
-
catch (error) {
|
|
100
|
-
if (!(error instanceof GitHubAPIError))
|
|
101
|
-
throw error;
|
|
102
|
-
stopWith(output, `could not set ${target} status ${status}: ${error.message}`);
|
|
103
|
-
}
|
|
104
|
-
});
|
|
105
|
-
},
|
|
106
|
-
});
|
|
107
|
-
// 1 回目の reopen(status を更新する前提として open にする)と、ボードの status の更新。設定できたら自動化を待つ
|
|
108
|
-
async function reopenAndSetStatus(output, client, config, issue, status) {
|
|
109
|
-
const { owner, repository, number } = issue;
|
|
110
|
-
const target = `Issue ${issuePath(owner, repository, number)}`;
|
|
111
|
-
await client.reopenIssue(owner, repository, number);
|
|
112
|
-
const itemId = await client.getItemIdByIssue(config.project.id, owner, repository, number);
|
|
113
|
-
if (itemId === undefined) {
|
|
114
|
-
output.warning(`${target} is not on the project board`);
|
|
115
|
-
}
|
|
116
|
-
else if (await setIssueField(client, config, itemId, 'workflow', status)) {
|
|
117
|
-
output.done({ verb: 'set', target: `${target} status ${status}` });
|
|
118
|
-
await delay(AUTOMATION_WAIT_MILLISECONDS);
|
|
119
|
-
}
|
|
120
|
-
else {
|
|
121
|
-
output.warning(notConfiguredMessage(status));
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
// 2 回目の reopen(自動化による close への対策)で open を確かめ、--comment があれば理由を投稿する
|
|
125
|
-
async function confirmReopened(output, client, issue, comment) {
|
|
126
|
-
const { owner, repository, number } = issue;
|
|
127
|
-
const target = `Issue ${issuePath(owner, repository, number)}`;
|
|
128
|
-
const result = await client.reopenIssue(owner, repository, number);
|
|
129
|
-
const state = result['state'];
|
|
130
|
-
if (state !== 'open') {
|
|
131
|
-
stopWith(output, `${target} did not become open (state: ${typeof state === 'string' ? state : 'None'})`);
|
|
132
|
-
}
|
|
133
|
-
output.done({ verb: 'reopen', target });
|
|
134
|
-
if (comment === undefined || comment === '')
|
|
135
|
-
return;
|
|
136
|
-
await client.addIssueComment(owner, repository, number, comment);
|
|
137
|
-
output.done({ verb: 'create', target: `comment on ${issuePath(owner, repository, number)}` });
|
|
138
|
-
}
|
|
139
|
-
async function reopenIssue(output, client, config, issue, status, comment) {
|
|
140
|
-
await reopenAndSetStatus(output, client, config, issue, status);
|
|
141
|
-
await confirmReopened(output, client, issue, comment);
|
|
142
|
-
}
|
|
143
|
-
const ISSUE_REOPEN = defineCommand({
|
|
144
|
-
path: ['issue', 'reopen'],
|
|
145
|
-
description: 'Reopen a closed Issue (also sets the status on the board)',
|
|
146
|
-
input: z.object({
|
|
147
|
-
issue_ref: z.string().describe(ISSUE_REF_DESCRIPTION),
|
|
148
|
-
status: z.string().default('ready').describe('Status after reopening (backlog/pending/blocked/ready/active/in_review/archived)'),
|
|
149
|
-
comment: z.string().optional().describe('Reason for reopening (posted as a comment)'),
|
|
150
|
-
}),
|
|
151
|
-
positional: ['issue_ref'],
|
|
152
|
-
shortFlags: { status: '-s', comment: '-c' },
|
|
153
|
-
interactive: false,
|
|
154
|
-
run: async (input, io) => {
|
|
155
|
-
const output = createOutput(false, io);
|
|
156
|
-
return await runWithExit(async () => {
|
|
157
|
-
const { status, comment } = input;
|
|
158
|
-
if (!VALID_STATUSES.has(status))
|
|
159
|
-
exitInvalidStatus(output, status);
|
|
160
|
-
const config = requireActiveConfigPlain(output);
|
|
161
|
-
const { owner, repository, number } = parseIssueReferenceOrExit(output, input.repo, input.issue_ref);
|
|
162
|
-
const target = `Issue ${issuePath(owner, repository, number)}`;
|
|
163
|
-
try {
|
|
164
|
-
const client = await connectToProject(output, config, owner, repository);
|
|
165
|
-
await reopenIssue(output, client, config, { owner, repository, number }, status, comment);
|
|
166
|
-
}
|
|
167
|
-
catch (error) {
|
|
168
|
-
if (!(error instanceof GitHubAPIError))
|
|
169
|
-
throw error;
|
|
170
|
-
stopWith(output, `could not reopen ${target}: ${error.message}`);
|
|
171
|
-
}
|
|
172
|
-
});
|
|
173
|
-
},
|
|
174
|
-
});
|
|
175
|
-
export const ISSUE_PROJECT_COMMANDS = [ADD_TO_PROJECT, UPDATE_ISSUE_STATUS, ISSUE_REOPEN];
|
|
176
|
-
//# sourceMappingURL=issue-project.js.map
|
|
@@ -1,126 +0,0 @@
|
|
|
1
|
-
/* eslint-disable @typescript-eslint/prefer-readonly-parameter-types -- 引数の型は readonly にできない */
|
|
2
|
-
// issue quick。cli/commands/issue.py の issue_quick_command の移植。テンプレートの検証はしない。
|
|
3
|
-
import { z } from 'zod';
|
|
4
|
-
import { splitOwnerRepository } from '../domain/repository-resolver.js';
|
|
5
|
-
import { findRepository } from '../domain/config.js';
|
|
6
|
-
import { pythonRightStrip, pythonStrip, truncateCodePoints } from '../domain/python-format.js';
|
|
7
|
-
import { FLAG_ISSUE_CREATE_SLASH_PENDING, FLAG_ISSUE_PENDING, FLAG_PECOT_QUICK_MODE } from '../domain/state.js';
|
|
8
|
-
import { GitHubAPIError } from '../infra/github/errors.js';
|
|
9
|
-
import { formatTimestamp } from '../infra/paths.js';
|
|
10
|
-
import { consumeFlag, touchFlag } from '../infra/state-store.js';
|
|
11
|
-
import { defineCommand } from './command-definition.js';
|
|
12
|
-
import { stopWith, requireActiveConfigPlain } from './command-stop.js';
|
|
13
|
-
import { addToBoardOrWarn, BACKLOG_TYPES, buildIssueTitle, clientForIssueCreate, createIssueOrExit, ISSUE_TYPE_SCHEMA, issuePath, linkToParentEpic, normalizeParentEpicCli, PARENT_EPIC_DESCRIPTION, resolveParentEpicReference, runWithExit, setIssueFields, summarizeCreatedIssue, } from './issue-shared.js';
|
|
14
|
-
import { createOutput } from './output.js';
|
|
15
|
-
import { recordWorkTarget } from './work-target.js';
|
|
16
|
-
// Python の re の `\s` と同じ集合。JS の `\s` と違い、U+001C〜U+001F を含む。U+FEFF は含まない
|
|
17
|
-
// eslint-disable-next-line no-control-regex -- Python の空白に含まれる制御文字
|
|
18
|
-
const PYTHON_WHITESPACE_RUN = /[\p{White_Space}\u{1C}\u{1D}\u{1E}\u{1F}]+/gu;
|
|
19
|
-
// テンプレートの検証を飛ばす quick でも、起票規約への参照を本文の末尾に残す
|
|
20
|
-
const BODY_FOOTER = '<!-- pecot issue quick で起票(テンプレ検証スキップ)。起票ルール: skills/w-help/references/issue-flow-rules.md#起票時の既定-status -->';
|
|
21
|
-
const TITLE_LENGTH = 50;
|
|
22
|
-
// 空のメッセージと owner/repo の形の誤りを止める
|
|
23
|
-
function parseQuickArguments(output, message, repository) {
|
|
24
|
-
if (pythonStrip(message) === '') {
|
|
25
|
-
stopWith(output, 'the message is empty');
|
|
26
|
-
}
|
|
27
|
-
const parts = splitOwnerRepository(repository);
|
|
28
|
-
if (parts === undefined) {
|
|
29
|
-
stopWith(output, `invalid repository format: ${repository}\nexpected: owner/repo`);
|
|
30
|
-
}
|
|
31
|
-
return [parts.owner, parts.repository];
|
|
32
|
-
}
|
|
33
|
-
// status は Backlog に置く型なら backlog、それ以外は active。priority は medium、size は s(Backlog に置く型は付けない)
|
|
34
|
-
function quickFields(issueType) {
|
|
35
|
-
const isBacklog = BACKLOG_TYPES.has(issueType);
|
|
36
|
-
const status = isBacklog ? 'backlog' : 'active';
|
|
37
|
-
const fields = [
|
|
38
|
-
{ fieldName: 'workflow', optionName: status, label: `status ${status}` },
|
|
39
|
-
{ fieldName: 'priority', optionName: 'medium', label: 'priority medium' },
|
|
40
|
-
];
|
|
41
|
-
if (!isBacklog)
|
|
42
|
-
fields.push({ fieldName: 'size', optionName: 's', label: 'size s' });
|
|
43
|
-
return fields;
|
|
44
|
-
}
|
|
45
|
-
async function createBranch(output, config, client, owner, repository, issueNumber, issueNodeId, title) {
|
|
46
|
-
const base = findRepository(config, owner, repository)?.develop_branch;
|
|
47
|
-
if (base === undefined || base === '') {
|
|
48
|
-
stopWith(output, `develop_branch is not set for repository ${owner}/${repository}\nset it with: pecot project set-repo ${owner}/${repository} --develop-branch develop\n(or --develop-branch develop-aist / --develop-branch main)`);
|
|
49
|
-
}
|
|
50
|
-
const name = `feat/${formatTimestamp(Date.now())}/${String(issueNumber)}`;
|
|
51
|
-
const sha = await client.getBranchSha(owner, repository, base);
|
|
52
|
-
const created = await client.createLinkedBranch(issueNodeId, sha, name);
|
|
53
|
-
output.done({ verb: 'create', target: `branch ${created} in ${owner}/${repository}` });
|
|
54
|
-
recordWorkTarget(output, owner, repository, issueNumber, title, { failWithExit: false });
|
|
55
|
-
}
|
|
56
|
-
// ブランチの作成。API の失敗は warning にして続ける(--no-branch なら作業対象を記録するだけ)
|
|
57
|
-
async function branchOrRecord(output, config, client, target, isNoBranch) {
|
|
58
|
-
if (isNoBranch) {
|
|
59
|
-
recordWorkTarget(output, target.owner, target.repository, target.number, target.title, { failWithExit: false });
|
|
60
|
-
return;
|
|
61
|
-
}
|
|
62
|
-
try {
|
|
63
|
-
await createBranch(output, config, client, target.owner, target.repository, target.number, target.nodeId, target.title);
|
|
64
|
-
}
|
|
65
|
-
catch (error) {
|
|
66
|
-
if (!(error instanceof GitHubAPIError))
|
|
67
|
-
throw error;
|
|
68
|
-
output.warning(`could not create the branch: ${error.message}\ncreate the branch manually`);
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
// 作った Issue の後始末。ボードへの追加に失敗したら、そこで止める
|
|
72
|
-
async function finishIssue(output, config, client, owner, repository, issue, options) {
|
|
73
|
-
const { number, url, nodeId } = summarizeCreatedIssue(issue);
|
|
74
|
-
const target = `Issue ${issuePath(owner, repository, number)}`;
|
|
75
|
-
const added = await addToBoardOrWarn(output, client, config, owner, repository, number, nodeId, url);
|
|
76
|
-
if (added === undefined)
|
|
77
|
-
return;
|
|
78
|
-
await setIssueFields(output, client, config, added.itemId, target, quickFields(options.issueType));
|
|
79
|
-
if (options.parentReference !== undefined) {
|
|
80
|
-
if (options.issueType === 'epic')
|
|
81
|
-
output.warning('giving a parent Epic to an Epic is not recommended');
|
|
82
|
-
await linkToParentEpic(output, client, target, options.parentReference, added.issueNodeId, url);
|
|
83
|
-
}
|
|
84
|
-
const title = typeof issue['title'] === 'string' ? issue['title'] : '';
|
|
85
|
-
await branchOrRecord(output, config, client, { owner, repository, number, nodeId: added.issueNodeId, title }, options.noBranch);
|
|
86
|
-
if (!BACKLOG_TYPES.has(options.issueType))
|
|
87
|
-
touchFlag(FLAG_PECOT_QUICK_MODE);
|
|
88
|
-
output.data(url);
|
|
89
|
-
}
|
|
90
|
-
const ISSUE_QUICK = defineCommand({
|
|
91
|
-
path: ['issue', 'quick'],
|
|
92
|
-
hasOwnRepo: true,
|
|
93
|
-
ignoresGlobalRepo: true,
|
|
94
|
-
description: 'Create an Issue at once from a free-format message',
|
|
95
|
-
input: z.object({
|
|
96
|
-
message: z.string().describe('Issue message (free format)'),
|
|
97
|
-
repo: z.string().describe('Repository (owner/repo form)'),
|
|
98
|
-
parent_epic: z.string().optional().describe(PARENT_EPIC_DESCRIPTION),
|
|
99
|
-
order: z.int().optional().describe('Order number of the subtask (used with parent_epic)'),
|
|
100
|
-
no_branch: z.boolean().default(false).describe('Skip creating a branch'),
|
|
101
|
-
type: ISSUE_TYPE_SCHEMA,
|
|
102
|
-
}),
|
|
103
|
-
positional: [],
|
|
104
|
-
shortFlags: { message: '-m', repo: '-r' },
|
|
105
|
-
interactive: false,
|
|
106
|
-
run: async (input, io) => {
|
|
107
|
-
const output = createOutput(false, io);
|
|
108
|
-
return await runWithExit(async () => {
|
|
109
|
-
const [owner, repository] = parseQuickArguments(output, input.message, input.repo);
|
|
110
|
-
const config = requireActiveConfigPlain(output);
|
|
111
|
-
const rawParent = normalizeParentEpicCli(input.parent_epic);
|
|
112
|
-
const parentReference = rawParent === undefined ? undefined : resolveParentEpicReference(rawParent, config, owner, repository);
|
|
113
|
-
// タイトルは先頭 50 文字の空白を 1 つにまとめたもの
|
|
114
|
-
const cleaned = pythonStrip(truncateCodePoints(input.message, TITLE_LENGTH).replaceAll(PYTHON_WHITESPACE_RUN, ' '));
|
|
115
|
-
const title = buildIssueTitle(input.type, cleaned, { parentEpic: parentReference?.number, order: input.order });
|
|
116
|
-
const client = await clientForIssueCreate(output, config, owner, repository, input.repo, parentReference, input.order);
|
|
117
|
-
const body = `${pythonRightStrip(input.message)}\n\n${BODY_FOOTER}`;
|
|
118
|
-
const issue = await createIssueOrExit(output, client, owner, repository, title, body, undefined);
|
|
119
|
-
consumeFlag(FLAG_ISSUE_PENDING);
|
|
120
|
-
consumeFlag(FLAG_ISSUE_CREATE_SLASH_PENDING);
|
|
121
|
-
await finishIssue(output, config, client, owner, repository, issue, { issueType: input.type, parentReference, noBranch: input.no_branch });
|
|
122
|
-
});
|
|
123
|
-
},
|
|
124
|
-
});
|
|
125
|
-
export const ISSUE_QUICK_COMMANDS = [ISSUE_QUICK];
|
|
126
|
-
//# sourceMappingURL=issue-quick.js.map
|
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
// issue read。cli/commands/issue.py の issue_read の移植。
|
|
2
|
-
import { z } from 'zod';
|
|
3
|
-
import { GitHubAPIError } from '../infra/github/errors.js';
|
|
4
|
-
import { defineCommand } from './command-definition.js';
|
|
5
|
-
import { stopWith, requireActiveConfigPlain } from './command-stop.js';
|
|
6
|
-
import { createGitHubClient } from './github-client.js';
|
|
7
|
-
import { ISSUE_REF_DESCRIPTION, issuePath, parseIssueReferenceOrExit, runWithExit } from './issue-shared.js';
|
|
8
|
-
import { createOutput } from './output.js';
|
|
9
|
-
const MAX_COMMENT_LIMIT = 20;
|
|
10
|
-
const DEFAULT_COMMENT_LIMIT = 5;
|
|
11
|
-
function parentLine(issue, owner, repository) {
|
|
12
|
-
const { parent } = issue;
|
|
13
|
-
if (parent === null)
|
|
14
|
-
return undefined;
|
|
15
|
-
const isCrossRepository = parent.owner !== null && parent.repo !== null && (parent.owner !== owner || parent.repo !== repository);
|
|
16
|
-
const label = isCrossRepository ? `${parent.owner}/${parent.repo}#${String(parent.number)}` : `#${String(parent.number)}`;
|
|
17
|
-
return `**Parent:** ${label} ${parent.title} (${parent.state})`;
|
|
18
|
-
}
|
|
19
|
-
/**
|
|
20
|
-
Issue の情報を Markdown にする。owner・repo は、親が別のリポジトリかを調べる元
|
|
21
|
-
*/
|
|
22
|
-
function formatIssueMarkdown(issue, owner, repository) {
|
|
23
|
-
const lines = [`## #${String(issue.number)} ${issue.title}`, ''];
|
|
24
|
-
const meta = [`**State:** ${issue.state}`];
|
|
25
|
-
if (issue.comments.total_count > 0)
|
|
26
|
-
meta.push(`**Comments:** ${String(issue.comments.total_count)}`);
|
|
27
|
-
lines.push(meta.join(' | '), '');
|
|
28
|
-
const parent = parentLine(issue, owner, repository);
|
|
29
|
-
if (parent !== undefined)
|
|
30
|
-
lines.push(parent, '');
|
|
31
|
-
if (issue.linked_branches.length > 0) {
|
|
32
|
-
lines.push('**Branches:**', ...issue.linked_branches.map(branch => ` - \`${branch}\``), '');
|
|
33
|
-
}
|
|
34
|
-
if (issue.linked_prs.length > 0) {
|
|
35
|
-
lines.push('**Linked PRs:**', ...issue.linked_prs.map(pr => ` - #${String(pr.number)} ${pr.title} (${pr.state})`), '');
|
|
36
|
-
}
|
|
37
|
-
if (issue.sub_issues.length > 0) {
|
|
38
|
-
lines.push('**Sub-issues:**', ...issue.sub_issues.map(sub => ` - #${String(sub.number)} ${sub.title} (${sub.state})`), '');
|
|
39
|
-
}
|
|
40
|
-
lines.push('---', '', issue.body);
|
|
41
|
-
const comments = issue.comments.nodes;
|
|
42
|
-
if (comments.length > 0) {
|
|
43
|
-
lines.push('', '', `### Comments (${String(comments.length)}/${String(issue.comments.total_count)})`, '');
|
|
44
|
-
for (const comment of comments) {
|
|
45
|
-
lines.push('---', '', `**@${comment.author}** - ${comment.created_at.slice(0, 10)}`, '', comment.body, '');
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
return lines.join('\n');
|
|
49
|
-
}
|
|
50
|
-
const ISSUE_READ = defineCommand({
|
|
51
|
-
path: ['issue', 'read'],
|
|
52
|
-
description: 'Fetch Issue details efficiently (GraphQL, only the needed fields)',
|
|
53
|
-
input: z.object({
|
|
54
|
-
issue_ref: z.string().describe(ISSUE_REF_DESCRIPTION),
|
|
55
|
-
json: z.boolean().default(false).describe('Output as JSON'),
|
|
56
|
-
comment_limit: z.int().min(0).max(MAX_COMMENT_LIMIT).default(DEFAULT_COMMENT_LIMIT).describe('Number of comments to show (0-20; 0 hides them)'),
|
|
57
|
-
}),
|
|
58
|
-
positional: ['issue_ref'],
|
|
59
|
-
shortFlags: { json: '-j', comment_limit: '-c' },
|
|
60
|
-
interactive: false,
|
|
61
|
-
run: async (input, io) => {
|
|
62
|
-
const output = createOutput(false, io);
|
|
63
|
-
return await runWithExit(async () => {
|
|
64
|
-
const config = requireActiveConfigPlain(output);
|
|
65
|
-
const { owner, repository, number } = parseIssueReferenceOrExit(output, input.repo, input.issue_ref);
|
|
66
|
-
let issue;
|
|
67
|
-
try {
|
|
68
|
-
issue = await createGitHubClient(output, config.host).getIssueSlim(owner, repository, number, input.comment_limit);
|
|
69
|
-
}
|
|
70
|
-
catch (error) {
|
|
71
|
-
if (!(error instanceof GitHubAPIError))
|
|
72
|
-
throw error;
|
|
73
|
-
return stopWith(output, `could not read Issue ${issuePath(owner, repository, number)}: ${error.message}`);
|
|
74
|
-
}
|
|
75
|
-
output.data(input.json ? JSON.stringify({ ...issue, owner, repo: repository }, undefined, 2) : formatIssueMarkdown(issue, owner, repository));
|
|
76
|
-
});
|
|
77
|
-
},
|
|
78
|
-
});
|
|
79
|
-
export const ISSUE_READ_COMMANDS = [ISSUE_READ];
|
|
80
|
-
//# sourceMappingURL=issue-read.js.map
|