@pecot/workflow-mcp 5.0.0 → 6.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 +80 -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 +59 -0
- package/cli/dist/commands/board-judgment.d.ts +60 -0
- package/cli/dist/commands/board-judgment.js +144 -0
- package/cli/dist/commands/board-move.d.ts +3 -0
- package/cli/dist/commands/board-move.js +57 -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 +72 -0
- package/cli/dist/commands/board-sync.d.ts +3 -0
- package/cli/dist/commands/board-sync.js +111 -0
- package/cli/dist/commands/{project-info.d.ts → board-view.d.ts} +21 -7
- package/cli/dist/commands/{project-info.js → board-view.js} +22 -12
- 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 +100 -0
- package/cli/dist/commands/command-binding.js +4 -0
- package/cli/dist/commands/command-definition.d.ts +20 -6
- package/cli/dist/commands/command-definition.js +11 -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 +34 -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 +33 -0
- package/cli/dist/commands/issue-board.js +61 -1
- package/cli/dist/commands/issue-comment.js +47 -28
- package/cli/dist/commands/issue-create.js +548 -91
- package/cli/dist/commands/issue-dependency.d.ts +3 -0
- package/cli/dist/commands/issue-dependency.js +282 -0
- package/cli/dist/commands/issue-readiness.d.ts +94 -0
- package/cli/dist/commands/issue-readiness.js +218 -0
- package/cli/dist/commands/issue-reopen.d.ts +3 -0
- package/cli/dist/commands/issue-reopen.js +115 -0
- package/cli/dist/commands/issue-shared.d.ts +32 -19
- package/cli/dist/commands/issue-shared.js +82 -75
- package/cli/dist/commands/issue-show.d.ts +3 -0
- package/cli/dist/commands/issue-show.js +169 -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 +62 -0
- package/cli/dist/commands/output.d.ts +14 -2
- package/cli/dist/commands/output.js +14 -7
- package/cli/dist/commands/pr-waiting.d.ts +20 -0
- package/cli/dist/commands/pr-waiting.js +106 -0
- package/cli/dist/commands/pr.d.ts +19 -0
- package/cli/dist/commands/pr.js +242 -323
- package/cli/dist/commands/project-sync.d.ts +2 -1
- package/cli/dist/commands/project-sync.js +18 -9
- package/cli/dist/commands/project.d.ts +3 -2
- package/cli/dist/commands/project.js +212 -175
- package/cli/dist/commands/registry.js +13 -10
- package/cli/dist/commands/release.d.ts +2 -2
- package/cli/dist/commands/release.js +53 -114
- 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 +3 -2
- package/cli/dist/commands/session-finish.d.ts +3 -0
- package/cli/dist/commands/session-finish.js +267 -0
- package/cli/dist/commands/session-start.d.ts +3 -0
- package/cli/dist/commands/{repository.js → session-start.js} +99 -128
- package/cli/dist/commands/session.d.ts +3 -0
- package/cli/dist/commands/session.js +82 -29
- package/cli/dist/commands/tracker-sync-dependabot.d.ts +7 -0
- package/cli/dist/commands/{dependabot.js → tracker-sync-dependabot.js} +57 -66
- package/cli/dist/commands/tracker-sync-security.d.ts +7 -0
- package/cli/dist/commands/{security.js → tracker-sync-security.js} +50 -61
- package/cli/dist/commands/tracker-sync.d.ts +7 -0
- package/cli/dist/commands/tracker-sync.js +3 -6
- package/cli/dist/commands/tracker.d.ts +3 -0
- package/cli/dist/commands/tracker.js +18 -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 +12 -3
- package/cli/dist/commands/work-target.js +46 -5
- package/cli/dist/commands/worktree.js +32 -28
- 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 -0
- 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 +27 -0
- package/cli/dist/domain/readiness.js +114 -3
- 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/security-alerts.js +1 -1
- package/cli/dist/domain/state.d.ts +30 -0
- package/cli/dist/domain/state.js +39 -0
- package/cli/dist/domain/work-start.d.ts +34 -0
- package/cli/dist/domain/work-start.js +49 -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 +12 -0
- package/cli/dist/infra/git.js +13 -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 +24 -0
- package/cli/dist/infra/github/pulls.js +56 -0
- package/cli/dist/infra/github/queries.d.ts +12 -4
- package/cli/dist/infra/github/queries.js +156 -8
- package/cli/dist/infra/github/readout.d.ts +5 -1
- package/cli/dist/infra/github/readout.js +11 -0
- 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 +34 -6
- package/cli/dist/mcp/result.js +62 -18
- package/cli/dist/mcp/server.d.ts +2 -2
- package/cli/dist/mcp/server.js +24 -10
- package/cli/templates/comment/plan.md +14 -0
- package/cli/templates/issue/bug.md +1 -1
- package/cli/templates/issue/task-implement.md +13 -6
- package/cli/templates/issue/task.md +1 -1
- 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/repository.d.ts +0 -5
- package/cli/dist/commands/security.d.ts +0 -3
package/README.md
CHANGED
|
@@ -74,52 +74,110 @@ WSL 内の npx が非ログインシェルの PATH に無い場合は、`args`
|
|
|
74
74
|
ツールが対象にするリポジトリは、サーバを起動したディレクトリを含むリポジトリです。
|
|
75
75
|
Claude Code では、Claude Code がサーバを起動するディレクトリ(通常はプロジェクトの root)になります。
|
|
76
76
|
|
|
77
|
-
プラグインの hooks は働きません。`issue_create`・`
|
|
77
|
+
プラグインの hooks は働きません。`issue_create`・`pr_create` の確認は、MCP クライアント自身の確認だけになります。
|
|
78
78
|
これらのツールは自動で許可しないでください。また、`--help` を打つと、プラグインで出る補足の節は出ません。
|
|
79
79
|
|
|
80
80
|
## ツール
|
|
81
81
|
|
|
82
|
+
ツール名は `<対象>_<動詞>` の形です。
|
|
83
|
+
|
|
82
84
|
| ツール | 内容 |
|
|
83
85
|
|---|---|
|
|
84
|
-
| `add_to_project` | プロジェクトボードに Issue を足す(pecot の外で作った Issue 用) |
|
|
85
|
-
| `update_issue_status` | Issue 番号でボードのステータスを更新する |
|
|
86
|
-
| `create_branch` | Issue に紐づくブランチを作る |
|
|
87
|
-
| `delete_branch` | リモートブランチを削除する(保護ブランチは消さない) |
|
|
88
86
|
| `project_list` | 使えるプロジェクトを一覧する |
|
|
89
87
|
| `project_search` | GitHub API でプロジェクトを検索する |
|
|
90
88
|
| `project_init` | 既存のプロジェクトに pecot-workflow のフィールドを足す |
|
|
91
89
|
| `project_create` | プロジェクトを新規に作る |
|
|
92
|
-
| `project_info` | プロジェクトの情報をまとめて表示する |
|
|
93
90
|
| `project_activate` | 初期化済みのプロジェクトを有効にする |
|
|
94
|
-
| `
|
|
95
|
-
| `
|
|
96
|
-
| `
|
|
97
|
-
| `
|
|
98
|
-
| `
|
|
99
|
-
| `
|
|
100
|
-
| `
|
|
91
|
+
| `project_link` | プロジェクトの設定にリポジトリを足す・更新する |
|
|
92
|
+
| `project_get` | プロジェクトの設定の値を表示する(`key` は今は `aggregation_repo` だけ。Epic の集約先リポジトリ) |
|
|
93
|
+
| `project_set` | プロジェクトの設定の値を設定する(`key` は今は `aggregation_repo` だけ) |
|
|
94
|
+
| `project_unset` | プロジェクトの設定の値を解除する(`key` は今は `aggregation_repo` だけ) |
|
|
95
|
+
| `board_show` | ボードの状態をまとめて表示する |
|
|
96
|
+
| `board_add` | プロジェクトボードに Issue を足す(pecot の外で作った Issue 用) |
|
|
97
|
+
| `board_move` | Issue 番号でボードのステータスを更新する |
|
|
98
|
+
| `board_sync` | ボードの Ready・Blocked・Active・In Review の Issue を、判定に合う列と札へ直す(`dry_run`・`project` を取る) |
|
|
99
|
+
| `issue_create` | frontmatter 付きの Markdown から Issue を作る(`freeform: true` と `repo`・`message` で、自由形式のメッセージから作る。`dry_run: true` は作らずに予定だけ出す) |
|
|
100
|
+
| `issue_show` | Issue の詳細を必要な項目だけ取得する |
|
|
101
101
|
| `issue_comment` | Issue にコメントを投稿する |
|
|
102
|
+
| `issue_block` | Issue に前提(blocked by)を付ける。付いている前提の種類と理由を変えるのにも使う |
|
|
103
|
+
| `issue_unblock` | Issue から前提(blocked by)を外す |
|
|
102
104
|
| `issue_reopen` | 閉じた Issue を開き直す(ボードのステータスも戻す) |
|
|
103
|
-
| `
|
|
104
|
-
| `
|
|
105
|
-
| `pr_preflight` | PR を作る前に確かめる情報をまとめて表示する |
|
|
106
|
-
| `pr_read` | PR の詳細を必要な項目だけ取得する |
|
|
107
|
-
| `session_status` | セッションのフラグ、ブランチ、推定した Issue を表示する |
|
|
105
|
+
| `session_start` | Issue の作業を始める(ブランチを作り、ボードを Active にし、作業対象を記録する) |
|
|
106
|
+
| `session_show` | セッションのフラグ、ブランチ、推定した Issue を表示する |
|
|
108
107
|
| `session_restore` | 失われたセッションのフラグをブランチから復元する |
|
|
109
|
-
| `
|
|
108
|
+
| `session_finish` | 作業を終える(マージ後の後処理として、Issue のクローズ、ブランチ削除、ローカルの整理をする) |
|
|
109
|
+
| `pr_create` | PR を作る |
|
|
110
|
+
| `pr_show` | PR の詳細を必要な項目だけ取得する |
|
|
111
|
+
| `pr_check` | PR を作る前に確かめる情報をまとめて表示する |
|
|
112
|
+
| `release_check` | リリース前の確認をする |
|
|
110
113
|
| `release_create` | GitHub のリリースとタグを作る(ノートは CHANGELOG から取る) |
|
|
111
114
|
| `release_merge` | リリースの PR を通常のマージで取り込む |
|
|
112
|
-
| `
|
|
113
|
-
| `dependabot_sync` | 開いている Tracker の Dependabot PR の一覧を書き直す |
|
|
115
|
+
| `tracker_sync` | 開いている Tracker の一覧を書き直す(`source` が `dependabot` なら Dependabot PR、`security` ならセキュリティアラート) |
|
|
114
116
|
| `worktree_add` | worktree を作る |
|
|
115
117
|
| `worktree_remove` | worktree を削除する |
|
|
116
118
|
| `worktree_init` | メイン worktree に worktree の設定ファイルを作る |
|
|
117
119
|
| `worktree_link` | 既存の worktree にシンボリックリンクを適用・更新する |
|
|
120
|
+
| `branch_delete` | リモートブランチを削除する(保護ブランチは消さない) |
|
|
121
|
+
|
|
122
|
+
## 古いツール名からの移行
|
|
123
|
+
|
|
124
|
+
次の 17 個は、名前が変わりました。古い名前は登録していないので、呼ぶと `Tool <名前> not found` で失敗します。
|
|
125
|
+
|
|
126
|
+
- `add_to_project` → `board_add`
|
|
127
|
+
- `update_issue_status` → `board_move`
|
|
128
|
+
- `project_info` → `board_show`
|
|
129
|
+
- `create_branch` → `session_start`
|
|
130
|
+
- `pr_cleanup` → `session_finish`
|
|
131
|
+
- `session_status` → `session_show`
|
|
132
|
+
- `delete_branch` → `branch_delete`
|
|
133
|
+
- `project_set_repo` → `project_link`
|
|
134
|
+
- `project_show_aggregation_repo` → `project_get`(`key: "aggregation_repo"` を足す)
|
|
135
|
+
- `project_set_aggregation_repo` → `project_set`(`key: "aggregation_repo"` を足す)
|
|
136
|
+
- `project_unset_aggregation_repo` → `project_unset`(`key: "aggregation_repo"` を足す)
|
|
137
|
+
- `issue_read` → `issue_show`
|
|
138
|
+
- `pr_read` → `pr_show`
|
|
139
|
+
- `pr_preflight` → `pr_check`
|
|
140
|
+
- `release_preflight` → `release_check`
|
|
141
|
+
- `dependabot_sync` → `tracker_sync`(`source: "dependabot"` を足す)
|
|
142
|
+
- `security_sync` → `tracker_sync`(`source: "security"` を足す)
|
|
143
|
+
|
|
144
|
+
`issue_quick` は、なくなりました。Issue の作成と作業の開始を 2 回の呼び出しに分けます。
|
|
145
|
+
|
|
146
|
+
- `issue_quick` の代わりに、次の 2 つを順に呼ぶ
|
|
147
|
+
- `issue_create`(`freeform: true`・`repo`・`message`)で Issue を作る
|
|
148
|
+
- `session_start`(`issue_ref`・`branch`)でブランチを作って作業を始める
|
|
149
|
+
- `issue_create` は Issue だけを作る。ブランチの作成と作業対象の記録はしない
|
|
150
|
+
|
|
151
|
+
許可の設定に古い名前を書いているときは、`mcp__pecot-workflow__<ツール名>` の `<ツール名>` を新しい名前に書き換えてください。
|
|
152
|
+
書き換えるまでは、確認のダイアログが出るだけで、失敗はしません。
|
|
153
|
+
入力の `delete_branch`(`session_finish`・`release_merge`)は変わりません。
|
|
154
|
+
|
|
155
|
+
## 古い入力名からの移行
|
|
156
|
+
|
|
157
|
+
同じものを指す入力の名前をそろえました。古い入力名を渡すと、実行せずに失敗します。結果は、新しい名前を案内する形です。
|
|
158
|
+
|
|
159
|
+
`invalid input: unknown key 'issue' ('issue' was renamed to 'issue_ref')`
|
|
160
|
+
|
|
161
|
+
- `issue_comment`・`session_restore`: `issue` → `issue_ref`
|
|
162
|
+
- `branch_delete`: `repo_ref` → `repo`
|
|
163
|
+
- `project_link`: `owner_repo` → `repo`
|
|
164
|
+
- `session_start`: `branch_name` → `branch`
|
|
165
|
+
- `issue_create`: `plan` → `dry_run`
|
|
166
|
+
|
|
167
|
+
書き込む 15 個のツールに、何も書かずに予定だけを出す `dry_run` が付きました。
|
|
168
|
+
|
|
169
|
+
- `board_add`・`board_move`
|
|
170
|
+
- `issue_comment`・`issue_create`・`issue_reopen`
|
|
171
|
+
- `project_activate`・`project_create`・`project_init`・`project_link`・`project_set`・`project_unset`
|
|
172
|
+
- `session_restore`・`session_start`
|
|
173
|
+
- `worktree_init`・`worktree_remove`
|
|
174
|
+
|
|
175
|
+
`board_show` は Archived の古い項目を消さなくなり(整理は `board_sync`)、`release_check` は `git fetch` をしなくなりました。
|
|
118
176
|
|
|
119
177
|
## 失敗したとき
|
|
120
178
|
|
|
121
179
|
- 初回の起動は依存の取得に時間がかかる。Claude Code で起動が 30 秒を超えて失敗したら、環境変数 `MCP_TIMEOUT` を延ばす
|
|
122
|
-
-
|
|
180
|
+
- ツールの結果は JSON で返る。失敗すると `ok` が `false` になり、原因の名前が `kind`、終了コードが `exitCode` に入る。標準出力と標準エラーは `stdout` と `stderr` に入る
|
|
123
181
|
- `EBADDEVENGINES` で止まるときは、登録の `args` に `--prefix=/` が付いているか確認する
|
|
124
182
|
|
|
125
183
|
## 版
|
package/cli/dist/cli.js
CHANGED
|
@@ -31,7 +31,8 @@ import { COMMANDS, findCommand } from './commands/registry.js';
|
|
|
31
31
|
import { createOutput, createProcessIo } from './commands/output.js';
|
|
32
32
|
import { formatResolvedRepository } from './commands/repository-display.js';
|
|
33
33
|
import { outputWidth } from './commands/rich-panel.js';
|
|
34
|
-
import { COMMAND_SYNOPSIS, MISSING_COMMAND_MESSAGE, noSuchCommandMessage, noSuchOptionMessage, USAGE_EXIT_CODE, UsageError, } from './commands/usage-error.js';
|
|
34
|
+
import { COMMAND_SYNOPSIS, MISSING_COMMAND_MESSAGE, noSuchCommandMessage, noSuchOptionMessage, renamedCommandMessage, USAGE_EXIT_CODE, UsageError, } from './commands/usage-error.js';
|
|
35
|
+
import { findRenamedCommand } from './commands/renamed-commands.js';
|
|
35
36
|
import { readVersion } from './version.js';
|
|
36
37
|
function isUnderGroup(path, group) {
|
|
37
38
|
return group.every((segment, index) => path.at(index) === segment);
|
|
@@ -54,6 +55,9 @@ function resolveCommand(group, rest, commands) {
|
|
|
54
55
|
.filter(command => command.path.length > group.length && isUnderGroup(command.path, group))
|
|
55
56
|
.map(command => command.path.slice(group.length, group.length + 1).join(''));
|
|
56
57
|
if (!names.includes(name)) {
|
|
58
|
+
const renamed = findRenamedCommand(path);
|
|
59
|
+
if (renamed !== undefined)
|
|
60
|
+
throw new UsageError(renamedCommandMessage(...renamed), context);
|
|
57
61
|
const possibilities = closeMatches(name, [...new Set(names)]);
|
|
58
62
|
throw new UsageError(noSuchCommandMessage(name, possibilities), context);
|
|
59
63
|
}
|
|
@@ -80,6 +84,7 @@ function showRepository(repository, context) {
|
|
|
80
84
|
return 0;
|
|
81
85
|
}
|
|
82
86
|
catch (error) {
|
|
87
|
+
// eslint-disable-next-line no-restricted-syntax -- CLI の最上位でグローバルの --repo を読むときだけ出る
|
|
83
88
|
if (error instanceof InvalidValueError)
|
|
84
89
|
context.io.stderr(`error: --repo: ${error.message}\n`);
|
|
85
90
|
else if (error instanceof AmbiguousRepositoryError)
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
// board add。cli/commands/issue.py の add_to_project の移植。
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
import { GitHubAPIError } from '../infra/github/errors.js';
|
|
4
|
+
import { defineCommand } from './command-definition.js';
|
|
5
|
+
import { addIssueToBoard, isStatusConfigured, setIssueField } from './issue-board.js';
|
|
6
|
+
import { stopWith, requireActiveConfigPlain } from './command-stop.js';
|
|
7
|
+
import { kindOfFailure } from './failure.js';
|
|
8
|
+
import { connectToProject, exitInvalidStatus, ISSUE_REF_DESCRIPTION, issuePath, notConfiguredMessage, parseIssueReferenceOrExit, runWithExit, VALID_STATUSES, } from './issue-shared.js';
|
|
9
|
+
import { createOutput } from './output.js';
|
|
10
|
+
const BOARD_ADD = defineCommand({
|
|
11
|
+
path: ['board', 'add'],
|
|
12
|
+
description: 'Add an Issue to the project board with a GraphQL mutation (for an Issue created outside pecot)',
|
|
13
|
+
input: z.object({
|
|
14
|
+
issue_ref: z.string().describe(ISSUE_REF_DESCRIPTION),
|
|
15
|
+
status: z.string().default('ready').describe('Initial status (backlog/pending/blocked/ready/active/in_review/archived)'),
|
|
16
|
+
dry_run: z.boolean().default(false).describe('Show what would change without writing anything'),
|
|
17
|
+
}),
|
|
18
|
+
positional: ['issue_ref'],
|
|
19
|
+
shortFlags: { status: '-s', dry_run: '-n' },
|
|
20
|
+
interactive: false,
|
|
21
|
+
run: async (input, io) => {
|
|
22
|
+
const output = createOutput(input.dry_run, io);
|
|
23
|
+
return await runWithExit(async () => {
|
|
24
|
+
const { status } = input;
|
|
25
|
+
if (status !== '' && !VALID_STATUSES.has(status))
|
|
26
|
+
exitInvalidStatus(output, status);
|
|
27
|
+
const config = requireActiveConfigPlain(output);
|
|
28
|
+
if (status !== '' && !isStatusConfigured(config, status)) {
|
|
29
|
+
stopWith(output, notConfiguredMessage(status), 'status-not-configured');
|
|
30
|
+
}
|
|
31
|
+
const { owner, repository, number } = parseIssueReferenceOrExit(output, input.repo, input.issue_ref);
|
|
32
|
+
const target = `Issue ${issuePath(owner, repository, number)}`;
|
|
33
|
+
try {
|
|
34
|
+
const client = await connectToProject(output, config, owner, repository);
|
|
35
|
+
if (input.dry_run) {
|
|
36
|
+
// Issue が読めることだけ確かめる
|
|
37
|
+
await client.getIssueNodeId(owner, repository, number);
|
|
38
|
+
output.planned({ verb: 'add', target: `${target} to project` });
|
|
39
|
+
if (status !== '')
|
|
40
|
+
output.planned({ verb: 'set', target: `${target} status ${status}` });
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
const { itemId } = await addIssueToBoard(client, config, owner, repository, number, undefined);
|
|
44
|
+
output.done({ verb: 'add', target: `${target} to project` });
|
|
45
|
+
if (status !== '') {
|
|
46
|
+
await setIssueField(client, config, itemId, 'workflow', status);
|
|
47
|
+
output.done({ verb: 'set', target: `${target} status ${status}` });
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
catch (error) {
|
|
51
|
+
if (!(error instanceof GitHubAPIError))
|
|
52
|
+
throw error;
|
|
53
|
+
stopWith(output, `could not add ${target} to project: ${error.message}`, kindOfFailure(error));
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
},
|
|
57
|
+
});
|
|
58
|
+
export const BOARD_ADD_COMMANDS = [BOARD_ADD];
|
|
59
|
+
//# sourceMappingURL=board-add.js.map
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import type { BoardMove, MissingValue } from '../domain/board-move.js';
|
|
2
|
+
import type { ProjectConfig } from '../domain/config.js';
|
|
3
|
+
import type { BoardItem, BoardProgress } from '../domain/format.js';
|
|
4
|
+
import type { IssueReference } from '../domain/reference-parser.js';
|
|
5
|
+
import type { RepositoryReference } from '../domain/repository-resolver.js';
|
|
6
|
+
import type { GitHubClient } from '../infra/github/index.js';
|
|
7
|
+
import type { IssueReadiness, IssueSnapshot, JudgedIssue } from './issue-readiness.js';
|
|
8
|
+
import type { HintedText } from './command-hint.js';
|
|
9
|
+
import type { Output } from './output.js';
|
|
10
|
+
/**
|
|
11
|
+
board sync と pr create が判定し直す列
|
|
12
|
+
*/
|
|
13
|
+
export declare const SYNCED_COLUMNS: ReadonlySet<string>;
|
|
14
|
+
/**
|
|
15
|
+
動かす先の値がボードに無いときの warning の文
|
|
16
|
+
*/
|
|
17
|
+
export declare function missingWarning(missing: ReadonlySet<MissingValue>): HintedText;
|
|
18
|
+
export interface BoardTarget {
|
|
19
|
+
readonly item: BoardItem;
|
|
20
|
+
readonly key: string;
|
|
21
|
+
readonly ref: IssueReference;
|
|
22
|
+
}
|
|
23
|
+
export interface JudgedTarget {
|
|
24
|
+
readonly target: BoardTarget;
|
|
25
|
+
readonly result: IssueReadiness;
|
|
26
|
+
}
|
|
27
|
+
export interface JudgeBoardOptions {
|
|
28
|
+
/**
|
|
29
|
+
判定の対象にする列
|
|
30
|
+
*/
|
|
31
|
+
readonly columns: ReadonlySet<string>;
|
|
32
|
+
/**
|
|
33
|
+
個別の読み取りを省く Issue。'skip' は判定から外し、IssueSnapshot は一覧の値だけで判定し、undefined は個別に読む
|
|
34
|
+
*/
|
|
35
|
+
readonly withoutRead: (target: BoardTarget, progress: BoardProgress | undefined) => IssueSnapshot | 'skip' | undefined;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
対象の列の Issue の前提と着手の跡を読み、輪も含めて判定する。
|
|
39
|
+
Issue の依存関係に対応しない GHES では undefined を返す。warning は呼ぶ側が出す
|
|
40
|
+
*/
|
|
41
|
+
export declare function judgeBoard(client: GitHubClient, config: ProjectConfig, items: readonly BoardItem[], progress: ReadonlyMap<string, BoardProgress>, options: JudgeBoardOptions): Promise<readonly JudgedTarget[] | undefined>;
|
|
42
|
+
/**
|
|
43
|
+
列と札を動かす処理が共有する、出力先・クライアント・設定・表示の基準のリポ
|
|
44
|
+
*/
|
|
45
|
+
export interface BoardContext {
|
|
46
|
+
readonly out: Readonly<Output>;
|
|
47
|
+
readonly client: GitHubClient;
|
|
48
|
+
readonly config: ProjectConfig;
|
|
49
|
+
readonly home: RepositoryReference | undefined;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
判定の結果に合わせて、列と札を動かす。読めない Issue は warning にし、ボードに無い値は最後に 1 行の warning にまとめる。
|
|
53
|
+
isDryRun は同じ文を予定の行で出し、書かない。書き込みに失敗した Issue の数を返す
|
|
54
|
+
*/
|
|
55
|
+
export declare function applyJudgedMoves(context: Readonly<BoardContext>, judged: readonly JudgedTarget[], isDryRun?: boolean): Promise<number>;
|
|
56
|
+
/**
|
|
57
|
+
判定から、列と札の動かし方を決める。info の数え方と board sync の書き込みが同じ規則を使う(FR-083)
|
|
58
|
+
*/
|
|
59
|
+
export declare function boardMoveOf(config: ProjectConfig, target: BoardTarget, result: JudgedIssue): BoardMove | undefined;
|
|
60
|
+
//# sourceMappingURL=board-judgment.d.ts.map
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/prefer-readonly-parameter-types -- 引数の型は readonly にできない */
|
|
2
|
+
// ボードの Issue の読み取り・判定と、列と札の動かし方。board show(数えるだけ)と、board sync・pr create(書く)が共有する。
|
|
3
|
+
import { decideBoardMove } from '../domain/board-move.js';
|
|
4
|
+
import { getOptionId } from '../domain/config.js';
|
|
5
|
+
import { boardItemKey } from '../domain/format.js';
|
|
6
|
+
import { compareStrings } from '../domain/python-format.js';
|
|
7
|
+
import { cycleThrough, describeReadiness, displayReference, hasStarted, TRACKER_TITLE_PREFIX } from '../domain/readiness.js';
|
|
8
|
+
import { createIssueReference, issueReferenceKey } from '../domain/reference-parser.js';
|
|
9
|
+
import { createRepositoryReference, splitOwnerRepository } from '../domain/repository-resolver.js';
|
|
10
|
+
import { DependenciesUnsupportedError, GitHubAPIError } from '../infra/github/errors.js';
|
|
11
|
+
import { blockedByReadCount, createReadinessCache, judgeSnapshot, prerequisiteKeys, readIssueSnapshot } from './issue-readiness.js';
|
|
12
|
+
import { mapWithLimit } from './board-view.js';
|
|
13
|
+
import { commandHint, hinted } from './command-hint.js';
|
|
14
|
+
import { applyBoardMove, planBoardMove } from './issue-board.js';
|
|
15
|
+
/**
|
|
16
|
+
前提の読み取りを並列に行う数の上限
|
|
17
|
+
*/
|
|
18
|
+
const READ_MAX_WORKERS = 8;
|
|
19
|
+
/**
|
|
20
|
+
board sync と pr create が判定し直す列
|
|
21
|
+
*/
|
|
22
|
+
export const SYNCED_COLUMNS = new Set(['Ready', 'Blocked', 'Active', 'In Review']);
|
|
23
|
+
/**
|
|
24
|
+
動かす先の値がボードに無いときの warning の文
|
|
25
|
+
*/
|
|
26
|
+
export function missingWarning(missing) {
|
|
27
|
+
const names = [...missing].toSorted(compareStrings);
|
|
28
|
+
return hinted `the board has no option ${names.join(', ')}; add ${names.length === 1 ? 'it' : 'them'} with ${commandHint(['project', 'init'])}`;
|
|
29
|
+
}
|
|
30
|
+
// 対象の列の Issue か。PR と Tracker は対象にしない
|
|
31
|
+
function toTarget(item, columns) {
|
|
32
|
+
const key = boardItemKey(item);
|
|
33
|
+
const split = splitOwnerRepository(item.content.repository ?? '');
|
|
34
|
+
const { number } = item.content;
|
|
35
|
+
const url = typeof item.content.url === 'string' ? item.content.url : '';
|
|
36
|
+
const title = typeof item.title === 'string' ? item.title : '';
|
|
37
|
+
const isExcluded = url.includes('/pull/') || title.startsWith(TRACKER_TITLE_PREFIX);
|
|
38
|
+
const isTarget = !isExcluded && typeof item.workflow === 'string' && columns.has(item.workflow) && key !== undefined && split !== undefined && typeof number === 'number';
|
|
39
|
+
return isTarget ? { item, key, ref: createIssueReference(createRepositoryReference(split.owner, split.repository), number) } : undefined;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
対象の列の Issue の前提と着手の跡を読み、輪も含めて判定する。
|
|
43
|
+
Issue の依存関係に対応しない GHES では undefined を返す。warning は呼ぶ側が出す
|
|
44
|
+
*/
|
|
45
|
+
export async function judgeBoard(client, config, items, progress, options) {
|
|
46
|
+
const targets = items.flatMap(item => toTarget(item, options.columns) ?? []);
|
|
47
|
+
const state = { isUnsupported: false };
|
|
48
|
+
const reads = await mapWithLimit(targets, READ_MAX_WORKERS, async (target) => {
|
|
49
|
+
if (state.isUnsupported)
|
|
50
|
+
return undefined;
|
|
51
|
+
const known = progress.get(target.key);
|
|
52
|
+
const local = options.withoutRead(target, known);
|
|
53
|
+
if (local === 'skip')
|
|
54
|
+
return undefined;
|
|
55
|
+
if (local !== undefined)
|
|
56
|
+
return { target, snapshot: local };
|
|
57
|
+
try {
|
|
58
|
+
return { target, snapshot: await readIssueSnapshot(client, config, target.ref, blockedByReadCount(known?.blockedBy)) };
|
|
59
|
+
}
|
|
60
|
+
catch (error) {
|
|
61
|
+
if (!(error instanceof DependenciesUnsupportedError))
|
|
62
|
+
throw error;
|
|
63
|
+
state.isUnsupported = true;
|
|
64
|
+
return undefined;
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
if (state.isUnsupported)
|
|
68
|
+
return undefined;
|
|
69
|
+
const pairs = reads.flatMap(read => read ?? []);
|
|
70
|
+
const edges = new Map();
|
|
71
|
+
for (const { target, snapshot } of pairs) {
|
|
72
|
+
if (snapshot.kind === 'snapshot')
|
|
73
|
+
edges.set(issueReferenceKey(target.ref), prerequisiteKeys(snapshot));
|
|
74
|
+
}
|
|
75
|
+
const cache = createReadinessCache();
|
|
76
|
+
return await mapWithLimit(pairs, READ_MAX_WORKERS, async ({ target, snapshot }) => {
|
|
77
|
+
if (snapshot.kind === 'unreadable')
|
|
78
|
+
return { target, result: snapshot };
|
|
79
|
+
try {
|
|
80
|
+
return { target, result: await judgeSnapshot(client, snapshot, cache, cycleThrough(issueReferenceKey(target.ref), edges)) };
|
|
81
|
+
}
|
|
82
|
+
catch (error) {
|
|
83
|
+
if (error instanceof GitHubAPIError)
|
|
84
|
+
return { target, result: { kind: 'unreadable', reason: error.message } };
|
|
85
|
+
throw error;
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
判定の結果に合わせて、列と札を動かす。読めない Issue は warning にし、ボードに無い値は最後に 1 行の warning にまとめる。
|
|
91
|
+
isDryRun は同じ文を予定の行で出し、書かない。書き込みに失敗した Issue の数を返す
|
|
92
|
+
*/
|
|
93
|
+
export async function applyJudgedMoves(context, judged, isDryRun = false) {
|
|
94
|
+
const { out, client, config, home } = context;
|
|
95
|
+
const missing = new Set();
|
|
96
|
+
let failures = 0;
|
|
97
|
+
for (const { target, result } of judged) {
|
|
98
|
+
if (result.kind === 'unreadable') {
|
|
99
|
+
out.warning(`could not judge ${displayReference(target.ref, home)}: ${result.reason.replaceAll(/\s+/gu, ' ')}`);
|
|
100
|
+
continue;
|
|
101
|
+
}
|
|
102
|
+
const { readiness } = result;
|
|
103
|
+
const move = boardMoveOf(config, target, result);
|
|
104
|
+
if (readiness === undefined || move === undefined)
|
|
105
|
+
continue;
|
|
106
|
+
for (const value of move.missing)
|
|
107
|
+
missing.add(value);
|
|
108
|
+
const text = describeReadiness(readiness, result.prerequisites, target.ref.repository);
|
|
109
|
+
const destination = { ref: target.ref, home };
|
|
110
|
+
const itemId = target.item.id;
|
|
111
|
+
if (isDryRun)
|
|
112
|
+
planBoardMove(out, destination, move, text);
|
|
113
|
+
else if (typeof itemId === 'string') {
|
|
114
|
+
const applied = await applyBoardMove(out, client, config, itemId, destination, move, text);
|
|
115
|
+
if (applied.hasFailed)
|
|
116
|
+
failures += 1;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
if (missing.size > 0)
|
|
120
|
+
out.warning(missingWarning(missing));
|
|
121
|
+
return failures;
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
判定から、列と札の動かし方を決める。info の数え方と board sync の書き込みが同じ規則を使う(FR-083)
|
|
125
|
+
*/
|
|
126
|
+
export function boardMoveOf(config, target, result) {
|
|
127
|
+
return decideBoardMove({
|
|
128
|
+
// 常に真でよい。readBoard が返すのは OPEN の Issue だけで、Tracker を対象から外し、Epic の readiness が undefined になる
|
|
129
|
+
eligible: true,
|
|
130
|
+
column: target.item.workflow ?? undefined,
|
|
131
|
+
label: result.target.label,
|
|
132
|
+
hasStarted: hasStarted(result.target),
|
|
133
|
+
hasPrerequisites: result.prerequisites.length > 0,
|
|
134
|
+
readiness: result.readiness,
|
|
135
|
+
// 札を書いたのが自動処理かは記録していない(data-model.md の 6)
|
|
136
|
+
labelWrittenByAutomation: false,
|
|
137
|
+
available: {
|
|
138
|
+
blocked: getOptionId(config, 'workflow', 'blocked') !== undefined,
|
|
139
|
+
needsAttention: getOptionId(config, 'status', 'needs_attention') !== undefined,
|
|
140
|
+
todo: getOptionId(config, 'status', 'todo') !== undefined,
|
|
141
|
+
},
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
//# sourceMappingURL=board-judgment.js.map
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
// board move。cli/commands/issue.py の update_issue_status の移植。
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
import { GitHubAPIError } from '../infra/github/errors.js';
|
|
4
|
+
import { defineCommand } from './command-definition.js';
|
|
5
|
+
import { isStatusConfigured, setIssueField } from './issue-board.js';
|
|
6
|
+
import { commandHint, hinted } from './command-hint.js';
|
|
7
|
+
import { stopWith, requireActiveConfigPlain } from './command-stop.js';
|
|
8
|
+
import { kindOfFailure } from './failure.js';
|
|
9
|
+
import { connectToProject, exitInvalidStatus, ISSUE_REF_DESCRIPTION, issuePath, notConfiguredMessage, parseIssueReferenceOrExit, runWithExit, VALID_STATUSES, } from './issue-shared.js';
|
|
10
|
+
import { createOutput } from './output.js';
|
|
11
|
+
const BOARD_MOVE = defineCommand({
|
|
12
|
+
path: ['board', 'move'],
|
|
13
|
+
description: 'Update the status of an Issue on the project board by Issue number (pecot commands normally set the status themselves)',
|
|
14
|
+
input: z.object({
|
|
15
|
+
issue_ref: z.string().describe(ISSUE_REF_DESCRIPTION),
|
|
16
|
+
status: z.string().describe('Status (backlog/pending/blocked/ready/active/in_review/archived)'),
|
|
17
|
+
dry_run: z.boolean().default(false).describe('Show what would change without writing anything'),
|
|
18
|
+
}),
|
|
19
|
+
positional: ['issue_ref', 'status'],
|
|
20
|
+
shortFlags: { dry_run: '-n' },
|
|
21
|
+
interactive: false,
|
|
22
|
+
run: async (input, io) => {
|
|
23
|
+
const output = createOutput(input.dry_run, io);
|
|
24
|
+
return await runWithExit(async () => {
|
|
25
|
+
const { status } = input;
|
|
26
|
+
if (!VALID_STATUSES.has(status))
|
|
27
|
+
exitInvalidStatus(output, status);
|
|
28
|
+
const config = requireActiveConfigPlain(output);
|
|
29
|
+
const { owner, repository, number } = parseIssueReferenceOrExit(output, input.repo, input.issue_ref);
|
|
30
|
+
const target = `Issue ${issuePath(owner, repository, number)}`;
|
|
31
|
+
try {
|
|
32
|
+
const client = await connectToProject(output, config, owner, repository);
|
|
33
|
+
const itemId = await client.getItemIdByIssue(config.project.id, owner, repository, number);
|
|
34
|
+
if (itemId === undefined) {
|
|
35
|
+
stopWith(output, hinted `${target} is not on the project board\nhint: add it to the board first with ${commandHint(['board', 'add'], { issue_ref: `${owner}/${repository}/${String(number)}` })}`, 'not-on-board');
|
|
36
|
+
}
|
|
37
|
+
if (input.dry_run) {
|
|
38
|
+
if (!isStatusConfigured(config, status))
|
|
39
|
+
stopWith(output, notConfiguredMessage(status), 'status-not-configured');
|
|
40
|
+
output.planned({ verb: 'set', target: `${target} status ${status}` });
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
if (!await setIssueField(client, config, itemId, 'workflow', status)) {
|
|
44
|
+
stopWith(output, notConfiguredMessage(status), 'status-not-configured');
|
|
45
|
+
}
|
|
46
|
+
output.done({ verb: 'set', target: `${target} status ${status}` });
|
|
47
|
+
}
|
|
48
|
+
catch (error) {
|
|
49
|
+
if (!(error instanceof GitHubAPIError))
|
|
50
|
+
throw error;
|
|
51
|
+
stopWith(output, `could not set ${target} status ${status}: ${error.message}`, kindOfFailure(error));
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
},
|
|
55
|
+
});
|
|
56
|
+
export const BOARD_MOVE_COMMANDS = [BOARD_MOVE];
|
|
57
|
+
//# sourceMappingURL=board-move.js.map
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { ProjectConfig } from '../domain/config.js';
|
|
2
|
+
import type { BoardItem, BoardProgress, StackableChain } from '../domain/format.js';
|
|
3
|
+
import type { JsonObject } from '../domain/json.js';
|
|
4
|
+
import { JSON_NULL } from '../domain/json-null.js';
|
|
5
|
+
import type { GitHubClient } from '../infra/github/index.js';
|
|
6
|
+
import type { Output } from './output.js';
|
|
7
|
+
export interface BoardReadiness {
|
|
8
|
+
/**
|
|
9
|
+
boardItemKey → 表の Readiness の列の文。undefined なら列を出さない
|
|
10
|
+
*/
|
|
11
|
+
readonly texts: ReadonlyMap<string, string> | undefined;
|
|
12
|
+
/**
|
|
13
|
+
boardItemKey → JSON の readiness。undefined なら JSON に足さない
|
|
14
|
+
*/
|
|
15
|
+
readonly json: ReadonlyMap<string, JsonObject> | undefined;
|
|
16
|
+
readonly chains: readonly StackableChain[];
|
|
17
|
+
/**
|
|
18
|
+
board sync が列か札を動かしそうな Ready・Blocked の Issue の数
|
|
19
|
+
*/
|
|
20
|
+
readonly mismatches: number;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
判定を読まずに、依存関係に対応しない GHES と同じ扱いにする。warning を 1 回出す
|
|
24
|
+
*/
|
|
25
|
+
export declare function skipBoardReadiness(out: Readonly<Output>): BoardReadiness;
|
|
26
|
+
/**
|
|
27
|
+
Ready・Blocked の Issue の前提を読んで判定する。items は表示するアイテム(--repo で絞った後)。列と札は動かさない
|
|
28
|
+
*/
|
|
29
|
+
export declare function readBoardReadiness(out: Readonly<Output>, client: GitHubClient, config: ProjectConfig, items: readonly BoardItem[], repository: string | undefined, progress?: ReadonlyMap<string, BoardProgress>): Promise<BoardReadiness>;
|
|
30
|
+
/**
|
|
31
|
+
アイテムのキーを引いて JSON の readiness を返す。判定が無ければ null
|
|
32
|
+
*/
|
|
33
|
+
export declare function readinessOf(readiness: BoardReadiness, item: BoardItem): JsonObject | typeof JSON_NULL;
|
|
34
|
+
//# sourceMappingURL=board-readiness.d.ts.map
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/prefer-readonly-parameter-types -- 引数の型は readonly にできない */
|
|
2
|
+
// board show の着手の判定。盤上の Ready・Blocked の Issue の前提を読んで表示する。列と札は動かさない。
|
|
3
|
+
import { homeRepositoryOf } from '../domain/config.js';
|
|
4
|
+
import { boardItemKey } from '../domain/format.js';
|
|
5
|
+
import { isEpicIssue } from '../domain/issue-kind.js';
|
|
6
|
+
import { JSON_NULL } from '../domain/json-null.js';
|
|
7
|
+
import { describeReadiness, describeUnknown, displayReference, progressionsFromReadiness, stackChains } from '../domain/readiness.js';
|
|
8
|
+
import { createIssueReference, issueReferenceKey } from '../domain/reference-parser.js';
|
|
9
|
+
import { createRepositoryReference, splitOwnerRepository } from '../domain/repository-resolver.js';
|
|
10
|
+
import { boardMoveOf, judgeBoard } from './board-judgment.js';
|
|
11
|
+
import { readinessJson, snapshotWithoutPrerequisites } from './issue-readiness.js';
|
|
12
|
+
const JUDGED_STATUSES = new Set(['Ready', 'Blocked']);
|
|
13
|
+
// 前提の無い Issue を、一覧の値だけで判定の入力にする。前提の件数が一覧に無ければ undefined
|
|
14
|
+
function localSnapshot(config, target, progress) {
|
|
15
|
+
if (progress?.blockedBy !== 0)
|
|
16
|
+
return undefined;
|
|
17
|
+
const split = splitOwnerRepository(progress.parent?.repository ?? '');
|
|
18
|
+
const parent = split === undefined || progress.parent === undefined ? undefined : createIssueReference(createRepositoryReference(split.owner, split.repository), progress.parent.number);
|
|
19
|
+
const isEpic = isEpicIssue({ issue_type: progress.issueType, sub_issues_total: progress.subIssues });
|
|
20
|
+
return snapshotWithoutPrerequisites(config, {
|
|
21
|
+
title: typeof target.item.title === 'string' ? target.item.title : '',
|
|
22
|
+
parent,
|
|
23
|
+
target: {
|
|
24
|
+
ref: target.ref,
|
|
25
|
+
state: 'open',
|
|
26
|
+
column: target.item.workflow ?? undefined,
|
|
27
|
+
label: progress.label,
|
|
28
|
+
kind: isEpic ? 'epic' : 'task',
|
|
29
|
+
// 着手の跡は一覧に無いので、info の案内は「may be」と書く
|
|
30
|
+
branches: [],
|
|
31
|
+
pullRequests: [],
|
|
32
|
+
},
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
// 小文字のキーを、元の参照(無ければキーから作る)に戻して表記する
|
|
36
|
+
function displayKey(key, references, home) {
|
|
37
|
+
const known = references.get(key);
|
|
38
|
+
const [repository = '', number = ''] = key.split('#', 2);
|
|
39
|
+
const split = splitOwnerRepository(repository);
|
|
40
|
+
return known === undefined && split === undefined ? key : displayReference(known ?? createIssueReference(createRepositoryReference(split?.owner ?? '', split?.repository ?? ''), Number(number)), home);
|
|
41
|
+
}
|
|
42
|
+
function unsupportedWarning(out) {
|
|
43
|
+
out.warning('this GitHub Enterprise Server does not support issue dependencies (blockedBy); the Readiness column is omitted');
|
|
44
|
+
}
|
|
45
|
+
const PLAIN = { texts: undefined, json: undefined, chains: [], mismatches: 0 };
|
|
46
|
+
/**
|
|
47
|
+
判定を読まずに、依存関係に対応しない GHES と同じ扱いにする。warning を 1 回出す
|
|
48
|
+
*/
|
|
49
|
+
export function skipBoardReadiness(out) {
|
|
50
|
+
unsupportedWarning(out);
|
|
51
|
+
return PLAIN;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
Ready・Blocked の Issue の前提を読んで判定する。items は表示するアイテム(--repo で絞った後)。列と札は動かさない
|
|
55
|
+
*/
|
|
56
|
+
export async function readBoardReadiness(out, client, config, items, repository, progress = new Map()) {
|
|
57
|
+
const judged = await judgeBoard(client, config, items, progress, {
|
|
58
|
+
columns: JUDGED_STATUSES,
|
|
59
|
+
withoutRead: (target, known) => localSnapshot(config, target, known),
|
|
60
|
+
});
|
|
61
|
+
if (judged === undefined) {
|
|
62
|
+
unsupportedWarning(out);
|
|
63
|
+
return PLAIN;
|
|
64
|
+
}
|
|
65
|
+
const home = homeRepositoryOf(config, repository);
|
|
66
|
+
const texts = new Map();
|
|
67
|
+
const json = new Map();
|
|
68
|
+
const readinessByKey = new Map();
|
|
69
|
+
const parents = new Map();
|
|
70
|
+
const references = new Map(judged.map(({ target }) => [target.key, target.ref]));
|
|
71
|
+
let mismatches = 0;
|
|
72
|
+
for (const { target, result } of judged) {
|
|
73
|
+
if (result.kind === 'unreadable') {
|
|
74
|
+
const text = describeUnknown(result.reason.replaceAll(/\s+/gu, ' '));
|
|
75
|
+
texts.set(target.key, text);
|
|
76
|
+
json.set(target.key, { kind: 'unknown', stackOn: JSON_NULL, reason: JSON_NULL, text });
|
|
77
|
+
continue;
|
|
78
|
+
}
|
|
79
|
+
if (result.parent !== undefined)
|
|
80
|
+
parents.set(target.key, result.parent);
|
|
81
|
+
const { readiness } = result;
|
|
82
|
+
if (readiness === undefined)
|
|
83
|
+
continue;
|
|
84
|
+
const text = describeReadiness(readiness, result.prerequisites, target.ref.repository);
|
|
85
|
+
texts.set(target.key, text);
|
|
86
|
+
json.set(target.key, readinessJson(readiness, text));
|
|
87
|
+
readinessByKey.set(target.key, readiness);
|
|
88
|
+
const move = boardMoveOf(config, target, result);
|
|
89
|
+
if (move?.column !== undefined || move?.label !== undefined)
|
|
90
|
+
mismatches += 1;
|
|
91
|
+
if (readiness.stackOn !== undefined)
|
|
92
|
+
references.set(issueReferenceKey(readiness.stackOn.issue), readiness.stackOn.issue);
|
|
93
|
+
}
|
|
94
|
+
const chains = stackChains(progressionsFromReadiness(readinessByKey)).filter(chain => chain.length >= 2).map((chain) => {
|
|
95
|
+
const parentKey = chain.find(key => parents.has(key));
|
|
96
|
+
const parent = parentKey === undefined ? undefined : parents.get(parentKey);
|
|
97
|
+
return { epic: parent === undefined ? undefined : displayReference(parent, home), chain: chain.map(key => displayKey(key, references, home)) };
|
|
98
|
+
});
|
|
99
|
+
return { texts, json, chains, mismatches };
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
アイテムのキーを引いて JSON の readiness を返す。判定が無ければ null
|
|
103
|
+
*/
|
|
104
|
+
export function readinessOf(readiness, item) {
|
|
105
|
+
const key = boardItemKey(item);
|
|
106
|
+
return (key === undefined ? undefined : readiness.json?.get(key)) ?? JSON_NULL;
|
|
107
|
+
}
|
|
108
|
+
//# sourceMappingURL=board-readiness.js.map
|