@pecot/workflow-mcp 6.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 +4 -57
- package/cli/dist/commands/board-add.js +11 -1
- package/cli/dist/commands/board-judgment.d.ts +12 -3
- package/cli/dist/commands/board-judgment.js +12 -6
- package/cli/dist/commands/board-move.js +9 -1
- package/cli/dist/commands/board-readiness.d.ts +3 -3
- package/cli/dist/commands/board-show.js +5 -2
- package/cli/dist/commands/board-sync.js +14 -5
- package/cli/dist/commands/board-view.d.ts +94 -5
- package/cli/dist/commands/board-view.js +119 -17
- package/cli/dist/commands/branch.js +12 -1
- package/cli/dist/commands/command-definition.d.ts +19 -2
- package/cli/dist/commands/command-definition.js +9 -0
- package/cli/dist/commands/failure-kind.d.ts +1 -1
- package/cli/dist/commands/failure-kind.js +1 -0
- package/cli/dist/commands/issue-board.d.ts +31 -3
- package/cli/dist/commands/issue-board.js +28 -4
- package/cli/dist/commands/issue-comment.js +19 -2
- package/cli/dist/commands/issue-create.js +90 -7
- package/cli/dist/commands/issue-dependency.js +32 -4
- package/cli/dist/commands/issue-readiness.d.ts +30 -2
- package/cli/dist/commands/issue-readiness.js +35 -0
- package/cli/dist/commands/issue-reopen.js +18 -3
- package/cli/dist/commands/issue-shared.d.ts +3 -3
- package/cli/dist/commands/issue-shared.js +3 -2
- package/cli/dist/commands/issue-show.js +78 -8
- package/cli/dist/commands/names.js +1 -0
- package/cli/dist/commands/output.d.ts +18 -2
- package/cli/dist/commands/output.js +16 -3
- 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 +41 -2
- package/cli/dist/commands/pr-waiting.js +74 -37
- package/cli/dist/commands/pr.d.ts +10 -6
- package/cli/dist/commands/pr.js +160 -67
- package/cli/dist/commands/project-sync.d.ts +10 -2
- package/cli/dist/commands/project-sync.js +7 -6
- package/cli/dist/commands/project.js +173 -16
- package/cli/dist/commands/registry.js +2 -0
- package/cli/dist/commands/release.js +67 -18
- package/cli/dist/commands/repository-match.js +7 -2
- package/cli/dist/commands/session-finish.js +128 -12
- package/cli/dist/commands/session-start.js +22 -6
- package/cli/dist/commands/session.js +121 -20
- package/cli/dist/commands/tracker-sync-dependabot.js +21 -4
- package/cli/dist/commands/tracker-sync-security.js +22 -4
- package/cli/dist/commands/tracker-sync.d.ts +30 -0
- package/cli/dist/commands/tracker-sync.js +15 -0
- package/cli/dist/commands/tracker.js +2 -0
- package/cli/dist/commands/work-target.d.ts +10 -2
- package/cli/dist/commands/work-target.js +6 -4
- package/cli/dist/commands/worktree.js +71 -5
- package/cli/dist/domain/issue-readout.d.ts +0 -4
- package/cli/dist/domain/pull-request.d.ts +1 -1
- package/cli/dist/domain/readiness.d.ts +17 -0
- package/cli/dist/domain/readiness.js +39 -2
- package/cli/dist/domain/restack.d.ts +62 -0
- package/cli/dist/domain/restack.js +53 -0
- package/cli/dist/domain/state.d.ts +39 -0
- package/cli/dist/domain/state.js +28 -1
- package/cli/dist/domain/work-start.d.ts +0 -4
- package/cli/dist/domain/work-start.js +0 -7
- package/cli/dist/infra/git.d.ts +64 -0
- package/cli/dist/infra/git.js +110 -0
- package/cli/dist/infra/github/pulls.d.ts +81 -2
- package/cli/dist/infra/github/pulls.js +116 -5
- package/cli/dist/infra/github/queries.d.ts +4 -1
- package/cli/dist/infra/github/queries.js +47 -32
- package/cli/dist/infra/github/readout.js +0 -33
- package/cli/dist/mcp/result.d.ts +63 -16
- package/cli/dist/mcp/result.js +106 -30
- package/cli/dist/mcp/server.js +37 -4
- package/cli/templates/comment/plan.md +2 -2
- package/cli/templates/comment/review-findings.md +3 -2
- package/cli/templates/issue/bug.md +13 -4
- package/cli/templates/issue/task.md +13 -4
- package/cli/templates/workflow/pecot-board-sync.yml +1 -1
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -74,7 +74,7 @@ WSL 内の npx が非ログインシェルの PATH に無い場合は、`args`
|
|
|
74
74
|
ツールが対象にするリポジトリは、サーバを起動したディレクトリを含むリポジトリです。
|
|
75
75
|
Claude Code では、Claude Code がサーバを起動するディレクトリ(通常はプロジェクトの root)になります。
|
|
76
76
|
|
|
77
|
-
プラグインの hooks は働きません。`issue_create`・`pr_create` の確認は、MCP クライアント自身の確認だけになります。
|
|
77
|
+
プラグインの hooks は働きません。`issue_create`・`pr_create`・`pr_merge` の確認は、MCP クライアント自身の確認だけになります。
|
|
78
78
|
これらのツールは自動で許可しないでください。また、`--help` を打つと、プラグインで出る補足の節は出ません。
|
|
79
79
|
|
|
80
80
|
## ツール
|
|
@@ -109,6 +109,8 @@ Claude Code では、Claude Code がサーバを起動するディレクトリ
|
|
|
109
109
|
| `pr_create` | PR を作る |
|
|
110
110
|
| `pr_show` | PR の詳細を必要な項目だけ取得する |
|
|
111
111
|
| `pr_check` | PR を作る前に確かめる情報をまとめて表示する |
|
|
112
|
+
| `pr_merge` | PR をマージする(スタックの中の PR は最下段だけ) |
|
|
113
|
+
| `pr_restack` | 積んだブランチを、base にしたブランチの新しい位置へ載せ直す |
|
|
112
114
|
| `release_check` | リリース前の確認をする |
|
|
113
115
|
| `release_create` | GitHub のリリースとタグを作る(ノートは CHANGELOG から取る) |
|
|
114
116
|
| `release_merge` | リリースの PR を通常のマージで取り込む |
|
|
@@ -119,65 +121,10 @@ Claude Code では、Claude Code がサーバを起動するディレクトリ
|
|
|
119
121
|
| `worktree_link` | 既存の worktree にシンボリックリンクを適用・更新する |
|
|
120
122
|
| `branch_delete` | リモートブランチを削除する(保護ブランチは消さない) |
|
|
121
123
|
|
|
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` をしなくなりました。
|
|
176
|
-
|
|
177
124
|
## 失敗したとき
|
|
178
125
|
|
|
179
126
|
- 初回の起動は依存の取得に時間がかかる。Claude Code で起動が 30 秒を超えて失敗したら、環境変数 `MCP_TIMEOUT` を延ばす
|
|
180
|
-
- ツールの結果は JSON で返る。失敗すると `
|
|
127
|
+
- ツールの結果は JSON で返る。失敗すると `isError` が真になり、原因の名前が `kind`、失敗の文が `detail` に入る。子プロセスの出力は `log` に入る
|
|
181
128
|
- `EBADDEVENGINES` で止まるときは、登録の `args` に `--prefix=/` が付いているか確認する
|
|
182
129
|
|
|
183
130
|
## 版
|
|
@@ -6,7 +6,13 @@ import { addIssueToBoard, isStatusConfigured, setIssueField } from './issue-boar
|
|
|
6
6
|
import { stopWith, requireActiveConfigPlain } from './command-stop.js';
|
|
7
7
|
import { kindOfFailure } from './failure.js';
|
|
8
8
|
import { connectToProject, exitInvalidStatus, ISSUE_REF_DESCRIPTION, issuePath, notConfiguredMessage, parseIssueReferenceOrExit, runWithExit, VALID_STATUSES, } from './issue-shared.js';
|
|
9
|
-
import { createOutput } from './output.js';
|
|
9
|
+
import { createOutput, DRY_RUN_FIELD } from './output.js';
|
|
10
|
+
const BOARD_ADD_OUTPUT = z.strictObject({
|
|
11
|
+
issue: z.string().describe('Issue (owner/repo/N)'),
|
|
12
|
+
added: z.boolean().describe('true when the Issue is on the board (on dry_run, would be added)'),
|
|
13
|
+
status: z.string().optional().describe('Status set on the board (omitted when status is empty)'),
|
|
14
|
+
dryRun: DRY_RUN_FIELD,
|
|
15
|
+
});
|
|
10
16
|
const BOARD_ADD = defineCommand({
|
|
11
17
|
path: ['board', 'add'],
|
|
12
18
|
description: 'Add an Issue to the project board with a GraphQL mutation (for an Issue created outside pecot)',
|
|
@@ -15,6 +21,7 @@ const BOARD_ADD = defineCommand({
|
|
|
15
21
|
status: z.string().default('ready').describe('Initial status (backlog/pending/blocked/ready/active/in_review/archived)'),
|
|
16
22
|
dry_run: z.boolean().default(false).describe('Show what would change without writing anything'),
|
|
17
23
|
}),
|
|
24
|
+
output: BOARD_ADD_OUTPUT,
|
|
18
25
|
positional: ['issue_ref'],
|
|
19
26
|
shortFlags: { status: '-s', dry_run: '-n' },
|
|
20
27
|
interactive: false,
|
|
@@ -38,13 +45,16 @@ const BOARD_ADD = defineCommand({
|
|
|
38
45
|
output.planned({ verb: 'add', target: `${target} to project` });
|
|
39
46
|
if (status !== '')
|
|
40
47
|
output.planned({ verb: 'set', target: `${target} status ${status}` });
|
|
48
|
+
output.result({ issue: issuePath(owner, repository, number), added: true, ...status !== '' && { status } });
|
|
41
49
|
return;
|
|
42
50
|
}
|
|
43
51
|
const { itemId } = await addIssueToBoard(client, config, owner, repository, number, undefined);
|
|
44
52
|
output.done({ verb: 'add', target: `${target} to project` });
|
|
53
|
+
output.result({ issue: issuePath(owner, repository, number), added: true });
|
|
45
54
|
if (status !== '') {
|
|
46
55
|
await setIssueField(client, config, itemId, 'workflow', status);
|
|
47
56
|
output.done({ verb: 'set', target: `${target} status ${status}` });
|
|
57
|
+
output.result({ status });
|
|
48
58
|
}
|
|
49
59
|
}
|
|
50
60
|
catch (error) {
|
|
@@ -4,8 +4,9 @@ import type { BoardItem, BoardProgress } from '../domain/format.js';
|
|
|
4
4
|
import type { IssueReference } from '../domain/reference-parser.js';
|
|
5
5
|
import type { RepositoryReference } from '../domain/repository-resolver.js';
|
|
6
6
|
import type { GitHubClient } from '../infra/github/index.js';
|
|
7
|
-
import type { IssueReadiness, IssueSnapshot, JudgedIssue } from './issue-readiness.js';
|
|
7
|
+
import type { IssueReadiness, IssueSnapshot, JudgedIssue, ReadinessCache } from './issue-readiness.js';
|
|
8
8
|
import type { HintedText } from './command-hint.js';
|
|
9
|
+
import type { BoardMoveLine } from './issue-board.js';
|
|
9
10
|
import type { Output } from './output.js';
|
|
10
11
|
/**
|
|
11
12
|
board sync と pr create が判定し直す列
|
|
@@ -33,6 +34,10 @@ export interface JudgeBoardOptions {
|
|
|
33
34
|
個別の読み取りを省く Issue。'skip' は判定から外し、IssueSnapshot は一覧の値だけで判定し、undefined は個別に読む
|
|
34
35
|
*/
|
|
35
36
|
readonly withoutRead: (target: BoardTarget, progress: BoardProgress | undefined) => IssueSnapshot | 'skip' | undefined;
|
|
37
|
+
/**
|
|
38
|
+
判定し直す呼び出しと共有するキャッシュ。無ければ判定ごとに作る
|
|
39
|
+
*/
|
|
40
|
+
readonly cache?: ReadinessCache;
|
|
36
41
|
}
|
|
37
42
|
/**
|
|
38
43
|
対象の列の Issue の前提と着手の跡を読み、輪も含めて判定する。
|
|
@@ -50,9 +55,13 @@ export interface BoardContext {
|
|
|
50
55
|
}
|
|
51
56
|
/**
|
|
52
57
|
判定の結果に合わせて、列と札を動かす。読めない Issue は warning にし、ボードに無い値は最後に 1 行の warning にまとめる。
|
|
53
|
-
isDryRun は同じ文を予定の行で出し、書かない。書き込みに失敗した Issue
|
|
58
|
+
isDryRun は同じ文を予定の行で出し、書かない。書き込みに失敗した Issue の数と、行に出した列と札(dry-run では予定)を返す。
|
|
59
|
+
moves を渡すと、行に出した列と札をそこへ足していくので、途中で例外が出ても書けた分が残る
|
|
54
60
|
*/
|
|
55
|
-
export declare function applyJudgedMoves(context: Readonly<BoardContext>, judged: readonly JudgedTarget[], isDryRun?: boolean): Promise<
|
|
61
|
+
export declare function applyJudgedMoves(context: Readonly<BoardContext>, judged: readonly JudgedTarget[], isDryRun?: boolean, moves?: BoardMoveLine[]): Promise<{
|
|
62
|
+
readonly failures: number;
|
|
63
|
+
readonly moves: readonly BoardMoveLine[];
|
|
64
|
+
}>;
|
|
56
65
|
/**
|
|
57
66
|
判定から、列と札の動かし方を決める。info の数え方と board sync の書き込みが同じ規則を使う(FR-083)
|
|
58
67
|
*/
|
|
@@ -72,7 +72,7 @@ export async function judgeBoard(client, config, items, progress, options) {
|
|
|
72
72
|
if (snapshot.kind === 'snapshot')
|
|
73
73
|
edges.set(issueReferenceKey(target.ref), prerequisiteKeys(snapshot));
|
|
74
74
|
}
|
|
75
|
-
const cache = createReadinessCache();
|
|
75
|
+
const cache = options.cache ?? createReadinessCache();
|
|
76
76
|
return await mapWithLimit(pairs, READ_MAX_WORKERS, async ({ target, snapshot }) => {
|
|
77
77
|
if (snapshot.kind === 'unreadable')
|
|
78
78
|
return { target, result: snapshot };
|
|
@@ -88,9 +88,10 @@ export async function judgeBoard(client, config, items, progress, options) {
|
|
|
88
88
|
}
|
|
89
89
|
/**
|
|
90
90
|
判定の結果に合わせて、列と札を動かす。読めない Issue は warning にし、ボードに無い値は最後に 1 行の warning にまとめる。
|
|
91
|
-
isDryRun は同じ文を予定の行で出し、書かない。書き込みに失敗した Issue
|
|
91
|
+
isDryRun は同じ文を予定の行で出し、書かない。書き込みに失敗した Issue の数と、行に出した列と札(dry-run では予定)を返す。
|
|
92
|
+
moves を渡すと、行に出した列と札をそこへ足していくので、途中で例外が出ても書けた分が残る
|
|
92
93
|
*/
|
|
93
|
-
export async function applyJudgedMoves(context, judged, isDryRun = false) {
|
|
94
|
+
export async function applyJudgedMoves(context, judged, isDryRun = false, moves = []) {
|
|
94
95
|
const { out, client, config, home } = context;
|
|
95
96
|
const missing = new Set();
|
|
96
97
|
let failures = 0;
|
|
@@ -108,17 +109,22 @@ export async function applyJudgedMoves(context, judged, isDryRun = false) {
|
|
|
108
109
|
const text = describeReadiness(readiness, result.prerequisites, target.ref.repository);
|
|
109
110
|
const destination = { ref: target.ref, home };
|
|
110
111
|
const itemId = target.item.id;
|
|
111
|
-
if (isDryRun)
|
|
112
|
-
planBoardMove(out, destination, move, text);
|
|
112
|
+
if (isDryRun) {
|
|
113
|
+
const planned = planBoardMove(out, destination, move, text);
|
|
114
|
+
if (planned !== undefined)
|
|
115
|
+
moves.push(planned);
|
|
116
|
+
}
|
|
113
117
|
else if (typeof itemId === 'string') {
|
|
114
118
|
const applied = await applyBoardMove(out, client, config, itemId, destination, move, text);
|
|
115
119
|
if (applied.hasFailed)
|
|
116
120
|
failures += 1;
|
|
121
|
+
if (applied.written !== undefined)
|
|
122
|
+
moves.push(applied.written);
|
|
117
123
|
}
|
|
118
124
|
}
|
|
119
125
|
if (missing.size > 0)
|
|
120
126
|
out.warning(missingWarning(missing));
|
|
121
|
-
return failures;
|
|
127
|
+
return { failures, moves };
|
|
122
128
|
}
|
|
123
129
|
/**
|
|
124
130
|
判定から、列と札の動かし方を決める。info の数え方と board sync の書き込みが同じ規則を使う(FR-083)
|
|
@@ -7,7 +7,12 @@ import { commandHint, hinted } from './command-hint.js';
|
|
|
7
7
|
import { stopWith, requireActiveConfigPlain } from './command-stop.js';
|
|
8
8
|
import { kindOfFailure } from './failure.js';
|
|
9
9
|
import { connectToProject, exitInvalidStatus, ISSUE_REF_DESCRIPTION, issuePath, notConfiguredMessage, parseIssueReferenceOrExit, runWithExit, VALID_STATUSES, } from './issue-shared.js';
|
|
10
|
-
import { createOutput } from './output.js';
|
|
10
|
+
import { createOutput, DRY_RUN_FIELD } from './output.js';
|
|
11
|
+
const BOARD_MOVE_OUTPUT = z.strictObject({
|
|
12
|
+
issue: z.string().describe('Issue (owner/repo/N)'),
|
|
13
|
+
status: z.string().describe('Status set on the board (on dry_run, to be set)'),
|
|
14
|
+
dryRun: DRY_RUN_FIELD,
|
|
15
|
+
});
|
|
11
16
|
const BOARD_MOVE = defineCommand({
|
|
12
17
|
path: ['board', 'move'],
|
|
13
18
|
description: 'Update the status of an Issue on the project board by Issue number (pecot commands normally set the status themselves)',
|
|
@@ -16,6 +21,7 @@ const BOARD_MOVE = defineCommand({
|
|
|
16
21
|
status: z.string().describe('Status (backlog/pending/blocked/ready/active/in_review/archived)'),
|
|
17
22
|
dry_run: z.boolean().default(false).describe('Show what would change without writing anything'),
|
|
18
23
|
}),
|
|
24
|
+
output: BOARD_MOVE_OUTPUT,
|
|
19
25
|
positional: ['issue_ref', 'status'],
|
|
20
26
|
shortFlags: { dry_run: '-n' },
|
|
21
27
|
interactive: false,
|
|
@@ -38,12 +44,14 @@ const BOARD_MOVE = defineCommand({
|
|
|
38
44
|
if (!isStatusConfigured(config, status))
|
|
39
45
|
stopWith(output, notConfiguredMessage(status), 'status-not-configured');
|
|
40
46
|
output.planned({ verb: 'set', target: `${target} status ${status}` });
|
|
47
|
+
output.result({ issue: issuePath(owner, repository, number), status });
|
|
41
48
|
return;
|
|
42
49
|
}
|
|
43
50
|
if (!await setIssueField(client, config, itemId, 'workflow', status)) {
|
|
44
51
|
stopWith(output, notConfiguredMessage(status), 'status-not-configured');
|
|
45
52
|
}
|
|
46
53
|
output.done({ verb: 'set', target: `${target} status ${status}` });
|
|
54
|
+
output.result({ issue: issuePath(owner, repository, number), status });
|
|
47
55
|
}
|
|
48
56
|
catch (error) {
|
|
49
57
|
if (!(error instanceof GitHubAPIError))
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { ProjectConfig } from '../domain/config.js';
|
|
2
2
|
import type { BoardItem, BoardProgress, StackableChain } from '../domain/format.js';
|
|
3
|
-
import type { JsonObject } from '../domain/json.js';
|
|
4
3
|
import { JSON_NULL } from '../domain/json-null.js';
|
|
5
4
|
import type { GitHubClient } from '../infra/github/index.js';
|
|
5
|
+
import type { BoardReadinessJson } from './issue-readiness.js';
|
|
6
6
|
import type { Output } from './output.js';
|
|
7
7
|
export interface BoardReadiness {
|
|
8
8
|
/**
|
|
@@ -12,7 +12,7 @@ export interface BoardReadiness {
|
|
|
12
12
|
/**
|
|
13
13
|
boardItemKey → JSON の readiness。undefined なら JSON に足さない
|
|
14
14
|
*/
|
|
15
|
-
readonly json: ReadonlyMap<string,
|
|
15
|
+
readonly json: ReadonlyMap<string, BoardReadinessJson> | undefined;
|
|
16
16
|
readonly chains: readonly StackableChain[];
|
|
17
17
|
/**
|
|
18
18
|
board sync が列か札を動かしそうな Ready・Blocked の Issue の数
|
|
@@ -30,5 +30,5 @@ export declare function readBoardReadiness(out: Readonly<Output>, client: GitHub
|
|
|
30
30
|
/**
|
|
31
31
|
アイテムのキーを引いて JSON の readiness を返す。判定が無ければ null
|
|
32
32
|
*/
|
|
33
|
-
export declare function readinessOf(readiness: BoardReadiness, item: BoardItem):
|
|
33
|
+
export declare function readinessOf(readiness: BoardReadiness, item: BoardItem): BoardReadinessJson | typeof JSON_NULL;
|
|
34
34
|
//# sourceMappingURL=board-readiness.d.ts.map
|
|
@@ -12,7 +12,7 @@ import { requireActiveConfig, stopWith } from './command-stop.js';
|
|
|
12
12
|
import { createGitHubClient } from './github-client.js';
|
|
13
13
|
import { createOutput } from './output.js';
|
|
14
14
|
import { readBoardReadiness, readinessOf, skipBoardReadiness } from './board-readiness.js';
|
|
15
|
-
import { boardShowJson, boardShowMarkdown, collectAlertStatuses, readBoard } from './board-view.js';
|
|
15
|
+
import { BOARD_SHOW_OUTPUT, boardShowData, boardShowJson, boardShowMarkdown, boardShowResult, collectAlertStatuses, readBoard } from './board-view.js';
|
|
16
16
|
import { failApi } from './project-sync.js';
|
|
17
17
|
const SYNC_PATH = ['board', 'sync'];
|
|
18
18
|
function mismatchNote(count) {
|
|
@@ -36,6 +36,7 @@ const boardShowCommand = defineCommand({
|
|
|
36
36
|
}).optional().describe('Target repository, given explicitly as \'owner/repo\''),
|
|
37
37
|
}),
|
|
38
38
|
hasOwnRepo: true,
|
|
39
|
+
output: BOARD_SHOW_OUTPUT,
|
|
39
40
|
positional: [],
|
|
40
41
|
shortFlags: { json: '-j' },
|
|
41
42
|
interactive: false,
|
|
@@ -53,8 +54,10 @@ const boardShowCommand = defineCommand({
|
|
|
53
54
|
if (readiness.mismatches > 0)
|
|
54
55
|
out.warning(mismatchNote(readiness.mismatches));
|
|
55
56
|
const json = readiness.json === undefined ? undefined : (item) => readinessOf(readiness, item);
|
|
57
|
+
const data = boardShowData(view, items, json);
|
|
58
|
+
out.result(boardShowResult(view, data, readiness.mismatches));
|
|
56
59
|
out.data(input.json
|
|
57
|
-
? boardShowJson(
|
|
60
|
+
? boardShowJson(data)
|
|
58
61
|
: boardShowMarkdown(view, input.repo, formatBoardOutput(items, readiness.texts), formatStackableChains(readiness.chains)));
|
|
59
62
|
}
|
|
60
63
|
catch (error) {
|
|
@@ -6,19 +6,25 @@ import { homeRepositoryOf } from '../domain/config.js';
|
|
|
6
6
|
import { loadActiveConfig, listProjectConfigNames, loadConfig, projectsDirectory } from '../infra/config-store.js';
|
|
7
7
|
import { GitHubAPIError } from '../infra/github/errors.js';
|
|
8
8
|
import { applyJudgedMoves, judgeBoard, SYNCED_COLUMNS } from './board-judgment.js';
|
|
9
|
+
import { BOARD_MOVE_JSON, moveJson } from './issue-board.js';
|
|
9
10
|
import { CommandExit, defineCommand } from './command-definition.js';
|
|
10
11
|
import { commandHint, hinted, placeholder } from './command-hint.js';
|
|
11
12
|
import { NO_ACTIVE_PROJECT, stopWith } from './command-stop.js';
|
|
12
13
|
import { makeClient } from './github-client.js';
|
|
13
|
-
import { createOutput } from './output.js';
|
|
14
|
+
import { createOutput, DRY_RUN_FIELD } from './output.js';
|
|
14
15
|
import { pruneArchivedItems, readBoard } from './board-view.js';
|
|
15
16
|
import { failApi } from './project-sync.js';
|
|
17
|
+
const BOARD_SYNC_OUTPUT = z.strictObject({
|
|
18
|
+
moves: z.array(BOARD_MOVE_JSON).describe('Issues whose column or Status was written (on dry_run, would be written)'),
|
|
19
|
+
deletedArchived: z.int().describe('Number of Archived items deleted from the board (on dry_run, to be deleted)'),
|
|
20
|
+
dryRun: DRY_RUN_FIELD,
|
|
21
|
+
});
|
|
16
22
|
function unsupportedWarning(out) {
|
|
17
23
|
out.warning('this GitHub Enterprise Server does not support issue dependencies (blockedBy); no column is moved');
|
|
18
24
|
}
|
|
19
25
|
/**
|
|
20
26
|
対象の Issue の前提と着手の跡を読み、判定に合わせて列と札を直す。dryRun は同じ文を予定の行で出し、書かない。
|
|
21
|
-
書き込みの失敗は warning にして続け、失敗した Issue
|
|
27
|
+
書き込みの失敗は warning にして続け、失敗した Issue の数と、書いた(dry-run は書く予定の)列と札を返す
|
|
22
28
|
*/
|
|
23
29
|
async function syncBoard(context, read, isDryRun) {
|
|
24
30
|
const { out, client, config } = context;
|
|
@@ -29,7 +35,7 @@ async function syncBoard(context, read, isDryRun) {
|
|
|
29
35
|
});
|
|
30
36
|
if (judged === undefined) {
|
|
31
37
|
unsupportedWarning(out);
|
|
32
|
-
return 0;
|
|
38
|
+
return { failures: 0, moves: [] };
|
|
33
39
|
}
|
|
34
40
|
return await applyJudgedMoves(context, judged, isDryRun);
|
|
35
41
|
}
|
|
@@ -76,6 +82,7 @@ const boardSyncCommand = defineCommand({
|
|
|
76
82
|
dry_run: z.boolean().default(false).describe('Show the planned moves without writing to the board'),
|
|
77
83
|
project: z.string().optional().describe('Name of the project config under .pecot/config/projects (without .json). Without it, the active project; when none is active and only one config exists, that one'),
|
|
78
84
|
}),
|
|
85
|
+
output: BOARD_SYNC_OUTPUT,
|
|
79
86
|
positional: [],
|
|
80
87
|
interactive: false,
|
|
81
88
|
run: async (input, io) => {
|
|
@@ -95,8 +102,10 @@ const boardSyncCommand = defineCommand({
|
|
|
95
102
|
}
|
|
96
103
|
if (read.isLegacy)
|
|
97
104
|
unsupportedWarning(out);
|
|
98
|
-
const failures = read.isLegacy ? 0 : await syncBoard({ out, client, config, home: homeRepositoryOf(config) }, read, input.dry_run);
|
|
99
|
-
const
|
|
105
|
+
const { failures, moves } = read.isLegacy ? { failures: 0, moves: [] } : await syncBoard({ out, client, config, home: homeRepositoryOf(config) }, read, input.dry_run);
|
|
106
|
+
const pruned = await pruneArchivedItems(out, client, config, read.allItems, input.dry_run);
|
|
107
|
+
const pruneFailures = pruned.failed;
|
|
108
|
+
out.result({ moves: moves.map(move => moveJson(move)), deletedArchived: pruned.deleted });
|
|
100
109
|
reportPoints(out, before, await client.getGraphqlRateLimit());
|
|
101
110
|
if (failures === 0 && pruneFailures === 0)
|
|
102
111
|
return 0;
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
1
2
|
import type { ProjectConfig } from '../domain/config.js';
|
|
2
3
|
import type { DependabotAlertStatus } from '../domain/dependabot.js';
|
|
3
4
|
import type { BoardItem, BoardProgress } from '../domain/format.js';
|
|
4
|
-
import type { JsonObject } from '../domain/json.js';
|
|
5
5
|
import { JSON_NULL } from '../domain/json-null.js';
|
|
6
6
|
import type { GitHubClient } from '../infra/github/index.js';
|
|
7
|
+
import type { BoardReadinessJson } from './issue-readiness.js';
|
|
7
8
|
import type { Output } from './output.js';
|
|
8
9
|
/**
|
|
9
10
|
取得に失敗したリポジトリは、理由の文字列
|
|
@@ -11,9 +12,12 @@ import type { Output } from './output.js';
|
|
|
11
12
|
export type AlertStatus = DependabotAlertStatus | string;
|
|
12
13
|
/**
|
|
13
14
|
Archived のアイテムを updatedAt の新しい順に並べ、最新の 20 件を残して、残りをボードから消す。
|
|
14
|
-
消せなかった件数を warning
|
|
15
|
+
消せなかった件数を warning の行に出す。消した件数(dry-run は消す予定の件数)と、消せなかった件数を返す
|
|
15
16
|
*/
|
|
16
|
-
export declare function pruneArchivedItems(out: Readonly<Output>, client: Readonly<Pick<GitHubClient, 'deleteProjectItem'>>, config: ProjectConfig, allItems: readonly BoardItem[], isDryRun: boolean): Promise<
|
|
17
|
+
export declare function pruneArchivedItems(out: Readonly<Output>, client: Readonly<Pick<GitHubClient, 'deleteProjectItem'>>, config: ProjectConfig, allItems: readonly BoardItem[], isDryRun: boolean): Promise<{
|
|
18
|
+
readonly deleted: number;
|
|
19
|
+
readonly failed: number;
|
|
20
|
+
}>;
|
|
17
21
|
/**
|
|
18
22
|
登録リポジトリごとの Dependabot alert の状態(登録の順)。
|
|
19
23
|
1 つの取得の失敗でボードの表示を止めないよう、DependabotAlertError はここで理由の文字列にする
|
|
@@ -23,6 +27,82 @@ export declare function collectAlertStatuses(client: Readonly<GitHubClient>, con
|
|
|
23
27
|
items を最大 limit 件ずつ並列に処理し、結果を items の順で返す。1 件でも投げたら、その例外で止まる
|
|
24
28
|
*/
|
|
25
29
|
export declare function mapWithLimit<Item, Result>(items: readonly Item[], limit: number, task: (item: Item) => Promise<Result>): Promise<readonly Result[]>;
|
|
30
|
+
/**
|
|
31
|
+
board show の MCP の data。project・repositories・board は --json と同じ。repositories の release_type・packages・changelog_file と mismatches は data にだけ足す
|
|
32
|
+
*/
|
|
33
|
+
export declare const BOARD_SHOW_OUTPUT: z.ZodObject<{
|
|
34
|
+
project: z.ZodObject<{
|
|
35
|
+
name: z.ZodString;
|
|
36
|
+
host: z.ZodString;
|
|
37
|
+
owner: z.ZodString;
|
|
38
|
+
number: z.ZodInt;
|
|
39
|
+
aggregation_repo: z.ZodNullable<z.ZodString>;
|
|
40
|
+
}, z.core.$strict>;
|
|
41
|
+
repositories: z.ZodArray<z.ZodObject<{
|
|
42
|
+
full_name: z.ZodString;
|
|
43
|
+
owner: z.ZodString;
|
|
44
|
+
name: z.ZodString;
|
|
45
|
+
develop_branch: z.ZodNullable<z.ZodString>;
|
|
46
|
+
release_branch: z.ZodNullable<z.ZodString>;
|
|
47
|
+
dependabot_alerts: z.ZodUnion<readonly [z.ZodObject<{
|
|
48
|
+
error: z.ZodString;
|
|
49
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
50
|
+
enabled: z.ZodBoolean;
|
|
51
|
+
open_count: z.ZodInt;
|
|
52
|
+
max_severity: z.ZodNullable<z.ZodString>;
|
|
53
|
+
alerts_url: z.ZodString;
|
|
54
|
+
}, z.core.$strict>]>;
|
|
55
|
+
release_type: z.ZodEnum<{
|
|
56
|
+
multi: "multi";
|
|
57
|
+
nx: "nx";
|
|
58
|
+
single: "single";
|
|
59
|
+
}>;
|
|
60
|
+
packages: z.ZodArray<z.ZodObject<{
|
|
61
|
+
name: z.ZodString;
|
|
62
|
+
changelog: z.ZodString;
|
|
63
|
+
}, z.core.$strict>>;
|
|
64
|
+
changelog_file: z.ZodOptional<z.ZodString>;
|
|
65
|
+
}, z.core.$strict>>;
|
|
66
|
+
board: z.ZodObject<{
|
|
67
|
+
items: z.ZodArray<z.ZodObject<{
|
|
68
|
+
id: z.ZodOptional<z.ZodUnknown>;
|
|
69
|
+
workflow: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
70
|
+
title: z.ZodOptional<z.ZodUnknown>;
|
|
71
|
+
updatedAt: z.ZodOptional<z.ZodUnknown>;
|
|
72
|
+
content: z.ZodObject<{
|
|
73
|
+
number: z.ZodOptional<z.ZodUnknown>;
|
|
74
|
+
state: z.ZodOptional<z.ZodUnknown>;
|
|
75
|
+
url: z.ZodOptional<z.ZodUnknown>;
|
|
76
|
+
labels: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
77
|
+
repository: z.ZodOptional<z.ZodString>;
|
|
78
|
+
}, z.core.$strict>;
|
|
79
|
+
readiness: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
80
|
+
stackOn: z.ZodNullable<z.ZodObject<{
|
|
81
|
+
number: z.ZodInt;
|
|
82
|
+
repository: z.ZodString;
|
|
83
|
+
branch: z.ZodString;
|
|
84
|
+
}, z.core.$strict>>;
|
|
85
|
+
reason: z.ZodNullable<z.ZodString>;
|
|
86
|
+
kind: z.ZodEnum<{
|
|
87
|
+
blocked: "blocked";
|
|
88
|
+
stackable: "stackable";
|
|
89
|
+
startable: "startable";
|
|
90
|
+
unknown: "unknown";
|
|
91
|
+
}>;
|
|
92
|
+
text: z.ZodString;
|
|
93
|
+
}, z.core.$strict>>>;
|
|
94
|
+
}, z.core.$strict>>;
|
|
95
|
+
}, z.core.$strict>;
|
|
96
|
+
mismatches: z.ZodInt;
|
|
97
|
+
}, z.core.$strict>;
|
|
98
|
+
export type BoardShowJson = z.input<typeof BOARD_SHOW_OUTPUT>;
|
|
99
|
+
type RepositoryExtras = Pick<BoardShowJson['repositories'][number], 'release_type' | 'packages' | 'changelog_file'>;
|
|
100
|
+
/**
|
|
101
|
+
--json に出す中身(data にだけ足す項目を除いたもの)
|
|
102
|
+
*/
|
|
103
|
+
export type BoardShowCore = Omit<BoardShowJson, 'repositories' | 'mismatches'> & {
|
|
104
|
+
readonly repositories: readonly Omit<BoardShowJson['repositories'][number], keyof RepositoryExtras>[];
|
|
105
|
+
};
|
|
26
106
|
export interface BoardShowView {
|
|
27
107
|
readonly config: ProjectConfig;
|
|
28
108
|
readonly projectName: string;
|
|
@@ -31,11 +111,19 @@ export interface BoardShowView {
|
|
|
31
111
|
/**
|
|
32
112
|
アイテムの JSON の readiness を引く。判定の無いアイテムは null
|
|
33
113
|
*/
|
|
34
|
-
export type ReadinessSource = (item: BoardItem) =>
|
|
114
|
+
export type ReadinessSource = (item: BoardItem) => BoardReadinessJson | typeof JSON_NULL;
|
|
115
|
+
/**
|
|
116
|
+
--json の標準出力と MCP の data の中身。キーを並べた順が --json の出力の順になる
|
|
117
|
+
*/
|
|
118
|
+
export declare function boardShowData(view: Readonly<BoardShowView>, items: readonly BoardItem[], readiness?: ReadinessSource): BoardShowCore;
|
|
35
119
|
/**
|
|
36
120
|
info --json の出力
|
|
37
121
|
*/
|
|
38
|
-
export declare function boardShowJson(
|
|
122
|
+
export declare function boardShowJson(data: Readonly<BoardShowCore>): string;
|
|
123
|
+
/**
|
|
124
|
+
MCP の data。--json の中身に、リポジトリごとの release_type・packages・changelog_file と、食い違いの件数を足す
|
|
125
|
+
*/
|
|
126
|
+
export declare function boardShowResult(view: Readonly<BoardShowView>, core: Readonly<BoardShowCore>, mismatches: number): BoardShowJson;
|
|
39
127
|
/**
|
|
40
128
|
info の Markdown の出力
|
|
41
129
|
*/
|
|
@@ -59,4 +147,5 @@ export interface BoardRead {
|
|
|
59
147
|
ボードのアイテムを全部読み、表示するものに絞る
|
|
60
148
|
*/
|
|
61
149
|
export declare function readBoard(client: Readonly<GitHubClient>, config: ProjectConfig, effectiveRepository: string | undefined): Promise<BoardRead>;
|
|
150
|
+
export {};
|
|
62
151
|
//# sourceMappingURL=board-view.d.ts.map
|