@pecot/workflow-mcp 7.0.1-dev.26 → 7.0.1-dev.27
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/cli/dist/commands/board-add.js +12 -3
- package/cli/dist/commands/board-judgment.d.ts +4 -2
- package/cli/dist/commands/board-judgment.js +5 -3
- package/cli/dist/commands/board-move.js +11 -2
- package/cli/dist/commands/field-write-failure.d.ts +14 -0
- package/cli/dist/commands/field-write-failure.js +25 -0
- package/cli/dist/commands/issue-board.d.ts +7 -4
- package/cli/dist/commands/issue-board.js +24 -9
- package/cli/dist/commands/issue-create.js +1 -1
- package/cli/dist/commands/issue-reopen.js +22 -5
- package/cli/dist/commands/issue-shared.d.ts +1 -6
- package/cli/dist/commands/issue-shared.js +4 -20
- package/cli/dist/commands/pr-waiting.d.ts +7 -2
- package/cli/dist/commands/pr-waiting.js +4 -4
- package/cli/dist/commands/pr.js +11 -7
- package/cli/dist/commands/session-start.js +10 -1
- package/cli/dist/commands/tracker-sync-dependabot.js +2 -4
- package/cli/dist/commands/tracker-sync-security.js +2 -3
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
|
@@ -5,6 +5,7 @@ import { defineCommand } from './command-definition.js';
|
|
|
5
5
|
import { addIssueToBoard, isStatusConfigured, setIssueField } from './issue-board.js';
|
|
6
6
|
import { stopWith, requireActiveConfigPlain } from './command-stop.js';
|
|
7
7
|
import { kindOfFailure } from './failure.js';
|
|
8
|
+
import { fieldWriteFailure } from './field-write-failure.js';
|
|
8
9
|
import { connectToProject, exitInvalidStatus, ISSUE_REF_DESCRIPTION, issuePath, notConfiguredMessage, parseIssueReferenceOrExit, runWithExit, VALID_STATUSES, } from './issue-shared.js';
|
|
9
10
|
import { createOutput, DRY_RUN_FIELD } from './output.js';
|
|
10
11
|
const BOARD_ADD_OUTPUT = z.strictObject({
|
|
@@ -51,11 +52,19 @@ const BOARD_ADD = defineCommand({
|
|
|
51
52
|
const { itemId } = await addIssueToBoard(client, config, owner, repository, number, undefined);
|
|
52
53
|
output.done({ verb: 'add', target: `${target} to project` });
|
|
53
54
|
output.result({ issue: issuePath(owner, repository, number), added: true });
|
|
54
|
-
if (status
|
|
55
|
+
if (status === '')
|
|
56
|
+
return;
|
|
57
|
+
try {
|
|
55
58
|
await setIssueField(client, config, itemId, 'workflow', status);
|
|
56
|
-
output.done({ verb: 'set', target: `${target} status ${status}` });
|
|
57
|
-
output.result({ status });
|
|
58
59
|
}
|
|
60
|
+
catch (error) {
|
|
61
|
+
if (!(error instanceof GitHubAPIError))
|
|
62
|
+
throw error;
|
|
63
|
+
// 追加は済んでいるので、追加の失敗とは別の文で止める
|
|
64
|
+
stopWith(output, fieldWriteFailure(`could not set ${target} status ${status}: ${error.message}`, error), kindOfFailure(error));
|
|
65
|
+
}
|
|
66
|
+
output.done({ verb: 'set', target: `${target} status ${status}` });
|
|
67
|
+
output.result({ status });
|
|
59
68
|
}
|
|
60
69
|
catch (error) {
|
|
61
70
|
if (!(error instanceof GitHubAPIError))
|
|
@@ -7,6 +7,7 @@ import type { GitHubClient } from '../infra/github/index.js';
|
|
|
7
7
|
import type { IssueReadiness, IssueSnapshot, JudgedIssue, ReadinessCache } from './issue-readiness.js';
|
|
8
8
|
import type { HintedText } from './command-hint.js';
|
|
9
9
|
import type { BoardMoveLine } from './issue-board.js';
|
|
10
|
+
import type { FieldHintState } from './field-write-failure.js';
|
|
10
11
|
import type { Output } from './output.js';
|
|
11
12
|
/**
|
|
12
13
|
board sync と pr create が判定し直す列
|
|
@@ -56,9 +57,10 @@ export interface BoardContext {
|
|
|
56
57
|
/**
|
|
57
58
|
判定の結果に合わせて、列と札を動かす。読めない Issue は warning にし、ボードに無い値は最後に 1 行の warning にまとめる。
|
|
58
59
|
isDryRun は同じ文を予定の行で出し、書かない。書き込みに失敗した Issue の数と、行に出した列と札(dry-run では予定)を返す。
|
|
59
|
-
moves
|
|
60
|
+
moves を渡すと、行に出した列と札をそこへ足していくので、途中で例外が出ても書けた分が残る。
|
|
61
|
+
hintState は、選択肢の ID を読み直す案内を 1 回だけ出すための印。省くと呼び出しごとに 1 つ作る
|
|
60
62
|
*/
|
|
61
|
-
export declare function applyJudgedMoves(context: Readonly<BoardContext>, judged: readonly JudgedTarget[], isDryRun?: boolean, moves?: BoardMoveLine[]): Promise<{
|
|
63
|
+
export declare function applyJudgedMoves(context: Readonly<BoardContext>, judged: readonly JudgedTarget[], isDryRun?: boolean, moves?: BoardMoveLine[], hintState?: FieldHintState): Promise<{
|
|
62
64
|
readonly failures: number;
|
|
63
65
|
readonly moves: readonly BoardMoveLine[];
|
|
64
66
|
}>;
|
|
@@ -89,10 +89,12 @@ export async function judgeBoard(client, config, items, progress, options) {
|
|
|
89
89
|
/**
|
|
90
90
|
判定の結果に合わせて、列と札を動かす。読めない Issue は warning にし、ボードに無い値は最後に 1 行の warning にまとめる。
|
|
91
91
|
isDryRun は同じ文を予定の行で出し、書かない。書き込みに失敗した Issue の数と、行に出した列と札(dry-run では予定)を返す。
|
|
92
|
-
moves
|
|
92
|
+
moves を渡すと、行に出した列と札をそこへ足していくので、途中で例外が出ても書けた分が残る。
|
|
93
|
+
hintState は、選択肢の ID を読み直す案内を 1 回だけ出すための印。省くと呼び出しごとに 1 つ作る
|
|
93
94
|
*/
|
|
94
|
-
export async function applyJudgedMoves(context, judged, isDryRun = false, moves = []) {
|
|
95
|
+
export async function applyJudgedMoves(context, judged, isDryRun = false, moves = [], hintState) {
|
|
95
96
|
const { out, client, config, home } = context;
|
|
97
|
+
const fieldHint = hintState ?? { hasHinted: false };
|
|
96
98
|
const missing = new Set();
|
|
97
99
|
let failures = 0;
|
|
98
100
|
for (const { target, result } of judged) {
|
|
@@ -115,7 +117,7 @@ export async function applyJudgedMoves(context, judged, isDryRun = false, moves
|
|
|
115
117
|
moves.push(planned);
|
|
116
118
|
}
|
|
117
119
|
else if (typeof itemId === 'string') {
|
|
118
|
-
const applied = await applyBoardMove(out, client, config, itemId, destination, move, text);
|
|
120
|
+
const applied = await applyBoardMove(out, client, config, itemId, destination, move, text, fieldHint);
|
|
119
121
|
if (applied.hasFailed)
|
|
120
122
|
failures += 1;
|
|
121
123
|
if (applied.written !== undefined)
|
|
@@ -6,6 +6,7 @@ import { isStatusConfigured, setIssueField } from './issue-board.js';
|
|
|
6
6
|
import { commandHint, hinted } from './command-hint.js';
|
|
7
7
|
import { stopWith, requireActiveConfigPlain } from './command-stop.js';
|
|
8
8
|
import { kindOfFailure } from './failure.js';
|
|
9
|
+
import { fieldWriteFailure } from './field-write-failure.js';
|
|
9
10
|
import { connectToProject, exitInvalidStatus, ISSUE_REF_DESCRIPTION, issuePath, notConfiguredMessage, parseIssueReferenceOrExit, runWithExit, VALID_STATUSES, } from './issue-shared.js';
|
|
10
11
|
import { createOutput, DRY_RUN_FIELD } from './output.js';
|
|
11
12
|
const BOARD_MOVE_OUTPUT = z.strictObject({
|
|
@@ -47,9 +48,17 @@ const BOARD_MOVE = defineCommand({
|
|
|
47
48
|
output.result({ issue: issuePath(owner, repository, number), status });
|
|
48
49
|
return;
|
|
49
50
|
}
|
|
50
|
-
|
|
51
|
-
|
|
51
|
+
let isSet;
|
|
52
|
+
try {
|
|
53
|
+
isSet = await setIssueField(client, config, itemId, 'workflow', status);
|
|
54
|
+
}
|
|
55
|
+
catch (error) {
|
|
56
|
+
if (!(error instanceof GitHubAPIError))
|
|
57
|
+
throw error;
|
|
58
|
+
stopWith(output, fieldWriteFailure(`could not set ${target} status ${status}: ${error.message}`, error), kindOfFailure(error));
|
|
52
59
|
}
|
|
60
|
+
if (!isSet)
|
|
61
|
+
stopWith(output, notConfiguredMessage(status), 'status-not-configured');
|
|
53
62
|
output.done({ verb: 'set', target: `${target} status ${status}` });
|
|
54
63
|
output.result({ issue: issuePath(owner, repository, number), status });
|
|
55
64
|
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { GitHubAPIError } from '../infra/github/errors.js';
|
|
2
|
+
import type { HintedText } from './command-hint.js';
|
|
3
|
+
/**
|
|
4
|
+
選択肢の ID を読み直す案内を 1 回の実行で 1 回だけ出すための印
|
|
5
|
+
*/
|
|
6
|
+
export interface FieldHintState {
|
|
7
|
+
hasHinted: boolean;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
選択肢の書き込みの失敗の文。古い ID で落ちたとき(VALIDATION)だけ、ID を読み直す案内を添える。
|
|
11
|
+
hintState を渡すと案内は 1 回だけ、省くと毎回添える
|
|
12
|
+
*/
|
|
13
|
+
export declare function fieldWriteFailure(message: string, error: Readonly<GitHubAPIError>, hintState?: FieldHintState): string | HintedText;
|
|
14
|
+
//# sourceMappingURL=field-write-failure.d.ts.map
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
// ボードの選択肢の書き込みの失敗の文。issue-board.ts と issue-shared.ts の両方が使うので、どちらにも置かない(循環 import を避ける)
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import { getActiveConfigPath, projectsDirectory } from '../infra/config-store.js';
|
|
4
|
+
import { commandHint, hinted, joinHinted, placeholder } from './command-hint.js';
|
|
5
|
+
function rereadOptionsHint() {
|
|
6
|
+
const configPath = getActiveConfigPath();
|
|
7
|
+
// projects/ の外の config は、ファイル名では project activate が見つけられない
|
|
8
|
+
const project = configPath === undefined
|
|
9
|
+
? placeholder('PROJECT')
|
|
10
|
+
: (path.dirname(configPath) === projectsDirectory() ? path.basename(configPath, '.json') : configPath);
|
|
11
|
+
return hinted `hint: if the board options were recreated, run ${commandHint(['project', 'activate'], { project })} to read their IDs again`;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
選択肢の書き込みの失敗の文。古い ID で落ちたとき(VALIDATION)だけ、ID を読み直す案内を添える。
|
|
15
|
+
hintState を渡すと案内は 1 回だけ、省くと毎回添える
|
|
16
|
+
*/
|
|
17
|
+
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types -- 出したことを hintState に書く
|
|
18
|
+
export function fieldWriteFailure(message, error, hintState) {
|
|
19
|
+
if (error.errorType !== 'VALIDATION' || hintState?.hasHinted === true)
|
|
20
|
+
return message;
|
|
21
|
+
if (hintState !== undefined)
|
|
22
|
+
hintState.hasHinted = true;
|
|
23
|
+
return joinHinted([message, rereadOptionsHint()]);
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=field-write-failure.js.map
|
|
@@ -5,6 +5,7 @@ import type { IssueReference } from '../domain/reference-parser.js';
|
|
|
5
5
|
import type { RepositoryReference } from '../domain/repository-resolver.js';
|
|
6
6
|
import type { JsonObject } from '../domain/json.js';
|
|
7
7
|
import type { GitHubClient } from '../infra/github/index.js';
|
|
8
|
+
import type { FieldHintState } from './field-write-failure.js';
|
|
8
9
|
import type { Output } from './output.js';
|
|
9
10
|
export interface BoardItem {
|
|
10
11
|
readonly itemId: string;
|
|
@@ -41,9 +42,10 @@ export interface PutOnBoardOptions {
|
|
|
41
42
|
}
|
|
42
43
|
/**
|
|
43
44
|
ボードへの追加と、Status(Backlog)・Priority の設定(何度やっても同じ結果になる)。
|
|
44
|
-
途中で失敗して空のままの項目は、次の onlyIfEmpty
|
|
45
|
+
途中で失敗して空のままの項目は、次の onlyIfEmpty の実行で直る。追加と欄の読み込みの失敗は GitHubAPIError。
|
|
46
|
+
欄の書き込みの失敗は error の行にして残りの欄を続け、書けなかった欄の数を返す
|
|
45
47
|
*/
|
|
46
|
-
export declare function putOnBoard(client: GitHubClient, config: ProjectConfig, owner: string, repository: string, issueNumber: number, priority: string | undefined, options: Readonly<PutOnBoardOptions>): Promise<
|
|
48
|
+
export declare function putOnBoard(out: Readonly<Output>, client: GitHubClient, config: ProjectConfig, owner: string, repository: string, issueNumber: number, priority: string | undefined, options: Readonly<PutOnBoardOptions>): Promise<number>;
|
|
47
49
|
/**
|
|
48
50
|
列と札の行(moved: と set: Status of)に出した値。issue は行の表示の参照、reason は列を動かす理由の文。書いていない側は undefined
|
|
49
51
|
*/
|
|
@@ -88,9 +90,10 @@ interface MoveTarget {
|
|
|
88
90
|
}
|
|
89
91
|
/**
|
|
90
92
|
decideBoardMove の結果をボードに書く。書き込みの失敗は warning にして続ける(元の列のまま)。
|
|
91
|
-
text は列を動かす理由の判定の文。board sync と issue block / unblock
|
|
93
|
+
text は列を動かす理由の判定の文。board sync と issue block / unblock が使う。
|
|
94
|
+
hintState は、選択肢の ID を読み直す案内を 1 回の実行で 1 回だけ出すための印(省くと毎回出す)
|
|
92
95
|
*/
|
|
93
|
-
export declare function applyBoardMove(out: Readonly<Output>, client: GitHubClient, config: ProjectConfig, itemId: string, target: MoveTarget, move: Readonly<BoardMove>, text: string): Promise<AppliedMove>;
|
|
96
|
+
export declare function applyBoardMove(out: Readonly<Output>, client: GitHubClient, config: ProjectConfig, itemId: string, target: MoveTarget, move: Readonly<BoardMove>, text: string, hintState?: FieldHintState): Promise<AppliedMove>;
|
|
94
97
|
/**
|
|
95
98
|
applyBoardMove と同じ文を、書かずに予定の行として出す(--dry-run)。予定の列と札を返し、どちらも無ければ undefined
|
|
96
99
|
*/
|
|
@@ -6,6 +6,7 @@ import { COLUMN_CONFIG_KEYS, LABEL_CONFIG_KEYS } from '../domain/board-move.js';
|
|
|
6
6
|
import { getFieldId, getOptionId } from '../domain/config.js';
|
|
7
7
|
import { displayReference } from '../domain/readiness.js';
|
|
8
8
|
import { GitHubAPIError } from '../infra/github/errors.js';
|
|
9
|
+
import { fieldWriteFailure } from './field-write-failure.js';
|
|
9
10
|
// 作ったボード項目の Status(Tracker はここから始める)
|
|
10
11
|
const BOARD_STATUS = 'backlog';
|
|
11
12
|
/**
|
|
@@ -58,18 +59,31 @@ export async function itemHasFieldValue(client, config, owner, repository, issue
|
|
|
58
59
|
}
|
|
59
60
|
/**
|
|
60
61
|
ボードへの追加と、Status(Backlog)・Priority の設定(何度やっても同じ結果になる)。
|
|
61
|
-
途中で失敗して空のままの項目は、次の onlyIfEmpty
|
|
62
|
+
途中で失敗して空のままの項目は、次の onlyIfEmpty の実行で直る。追加と欄の読み込みの失敗は GitHubAPIError。
|
|
63
|
+
欄の書き込みの失敗は error の行にして残りの欄を続け、書けなかった欄の数を返す
|
|
62
64
|
*/
|
|
63
|
-
export async function putOnBoard(client, config, owner, repository, issueNumber, priority, options) {
|
|
65
|
+
export async function putOnBoard(out, client, config, owner, repository, issueNumber, priority, options) {
|
|
66
|
+
const hintState = { hasHinted: false };
|
|
64
67
|
const { itemId } = await addIssueToBoard(client, config, owner, repository, issueNumber, undefined);
|
|
65
|
-
|
|
68
|
+
// 3 つ目は error の行に出す欄の名前
|
|
69
|
+
const fields = [['workflow', BOARD_STATUS, 'status']];
|
|
66
70
|
if (priority !== undefined)
|
|
67
|
-
fields.push(['priority', priority]);
|
|
68
|
-
|
|
71
|
+
fields.push(['priority', priority, 'priority']);
|
|
72
|
+
let failures = 0;
|
|
73
|
+
for (const [fieldName, option, label] of fields) {
|
|
69
74
|
if (options.onlyIfEmpty && await itemHasFieldValue(client, config, owner, repository, issueNumber, itemId, fieldName))
|
|
70
75
|
continue;
|
|
71
|
-
|
|
76
|
+
try {
|
|
77
|
+
await setIssueField(client, config, itemId, fieldName, option);
|
|
78
|
+
}
|
|
79
|
+
catch (error) {
|
|
80
|
+
if (!(error instanceof GitHubAPIError))
|
|
81
|
+
throw error;
|
|
82
|
+
out.error(fieldWriteFailure(`could not set ${label} ${option} of Tracker #${String(issueNumber)}: ${error.message}`, error, hintState));
|
|
83
|
+
failures += 1;
|
|
84
|
+
}
|
|
72
85
|
}
|
|
86
|
+
return failures;
|
|
73
87
|
}
|
|
74
88
|
/**
|
|
75
89
|
列と札を動かした(dry-run は動かす予定の)Issue 1 件。board sync・pr create・issue block / unblock の data が使う
|
|
@@ -101,9 +115,10 @@ function warnConflict(out, name, target, conflict) {
|
|
|
101
115
|
}
|
|
102
116
|
/**
|
|
103
117
|
decideBoardMove の結果をボードに書く。書き込みの失敗は warning にして続ける(元の列のまま)。
|
|
104
|
-
text は列を動かす理由の判定の文。board sync と issue block / unblock
|
|
118
|
+
text は列を動かす理由の判定の文。board sync と issue block / unblock が使う。
|
|
119
|
+
hintState は、選択肢の ID を読み直す案内を 1 回の実行で 1 回だけ出すための印(省くと毎回出す)
|
|
105
120
|
*/
|
|
106
|
-
export async function applyBoardMove(out, client, config, itemId, target, move, text) {
|
|
121
|
+
export async function applyBoardMove(out, client, config, itemId, target, move, text, hintState) {
|
|
107
122
|
const name = displayReference(target.ref, target.home);
|
|
108
123
|
if (move.conflict !== undefined)
|
|
109
124
|
warnConflict(out, name, target, move.conflict);
|
|
@@ -123,7 +138,7 @@ export async function applyBoardMove(out, client, config, itemId, target, move,
|
|
|
123
138
|
catch (error) {
|
|
124
139
|
if (!(error instanceof GitHubAPIError))
|
|
125
140
|
throw error;
|
|
126
|
-
out.warning(`could not move ${name}: ${error.message}
|
|
141
|
+
out.warning(fieldWriteFailure(`could not move ${name}: ${error.message}`, error, hintState));
|
|
127
142
|
hasFailed = true;
|
|
128
143
|
}
|
|
129
144
|
const written = column === undefined && label === undefined ? undefined : { issue: name, column, label, reason: text };
|
|
@@ -162,7 +162,7 @@ async function settleColumn(output, client, config, session, issue, item, linked
|
|
|
162
162
|
if (move === undefined)
|
|
163
163
|
return undefined;
|
|
164
164
|
// 起票の直後は、既定の自動化が札を書くので、札は書かない
|
|
165
|
-
const applied = await applyBoardMove(output, client, config, item.itemId, { ref: issue, home: issue.repository }, withoutLabel(move), describeReadiness(judged.readiness, judged.prerequisites, issue.repository));
|
|
165
|
+
const applied = await applyBoardMove(output, client, config, item.itemId, { ref: issue, home: issue.repository }, withoutLabel(move), describeReadiness(judged.readiness, judged.prerequisites, issue.repository), session.fieldHint);
|
|
166
166
|
return applied.column;
|
|
167
167
|
}
|
|
168
168
|
function withoutLabel(move) {
|
|
@@ -7,6 +7,7 @@ import { defineCommand } from './command-definition.js';
|
|
|
7
7
|
import { isStatusConfigured, setIssueField } from './issue-board.js';
|
|
8
8
|
import { stopWith, requireActiveConfigPlain } from './command-stop.js';
|
|
9
9
|
import { kindOfFailure } from './failure.js';
|
|
10
|
+
import { fieldWriteFailure } from './field-write-failure.js';
|
|
10
11
|
import { connectToProject, exitInvalidStatus, ISSUE_REF_DESCRIPTION, issuePath, notConfiguredMessage, parseIssueReferenceOrExit, runWithExit, VALID_STATUSES, } from './issue-shared.js';
|
|
11
12
|
import { createOutput, DRY_RUN_FIELD } from './output.js';
|
|
12
13
|
// Projects V2 の自動化が Issue をもう一度閉じることがあるため、status を設定した後に待つ
|
|
@@ -42,14 +43,30 @@ async function reopenAndSetStatus(output, client, config, issue, status) {
|
|
|
42
43
|
if (itemId === undefined) {
|
|
43
44
|
output.warning(`${target} is not on the project board`);
|
|
44
45
|
}
|
|
45
|
-
else if (await setIssueField(client, config, itemId, 'workflow', status)) {
|
|
46
|
-
output.done({ verb: 'set', target: `${target} status ${status}` });
|
|
47
|
-
output.result({ status });
|
|
48
|
-
await delay(AUTOMATION_WAIT_MILLISECONDS);
|
|
49
|
-
}
|
|
50
46
|
else {
|
|
47
|
+
await setReopenedStatus(output, client, config, { target, itemId }, status);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
// 列を書く。書けなければ warning にとどめ、2 回目の reopen とコメントの投稿へ進む。設定できたときだけ自動化を待つ
|
|
51
|
+
async function setReopenedStatus(output, client, config, item, status) {
|
|
52
|
+
const { target, itemId } = item;
|
|
53
|
+
let isSet;
|
|
54
|
+
try {
|
|
55
|
+
isSet = await setIssueField(client, config, itemId, 'workflow', status);
|
|
56
|
+
}
|
|
57
|
+
catch (error) {
|
|
58
|
+
if (!(error instanceof GitHubAPIError))
|
|
59
|
+
throw error;
|
|
60
|
+
output.warning(fieldWriteFailure(`could not set ${target} status ${status}: ${error.message}`, error));
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
if (!isSet) {
|
|
51
64
|
output.warning(notConfiguredMessage(status));
|
|
65
|
+
return;
|
|
52
66
|
}
|
|
67
|
+
output.done({ verb: 'set', target: `${target} status ${status}` });
|
|
68
|
+
output.result({ status });
|
|
69
|
+
await delay(AUTOMATION_WAIT_MILLISECONDS);
|
|
53
70
|
}
|
|
54
71
|
// 2 回目の reopen(自動化による close への対策)で open を確かめ、--comment があれば理由を投稿する
|
|
55
72
|
async function confirmReopened(output, client, issue, comment) {
|
|
@@ -6,6 +6,7 @@ import type { IssueReference } from '../domain/reference-parser.js';
|
|
|
6
6
|
import type { JsonObject } from '../domain/json.js';
|
|
7
7
|
import type { GitHubClient } from '../infra/github/index.js';
|
|
8
8
|
import type { HintedText } from './command-hint.js';
|
|
9
|
+
import type { FieldHintState } from './field-write-failure.js';
|
|
9
10
|
import type { BoardItem } from './issue-board.js';
|
|
10
11
|
import type { Output } from './output.js';
|
|
11
12
|
export type IssueType = IssueFrontmatter['type'];
|
|
@@ -135,12 +136,6 @@ export interface IssueField {
|
|
|
135
136
|
readonly label: string;
|
|
136
137
|
}
|
|
137
138
|
/**
|
|
138
|
-
選択肢の ID を読み直す案内を 1 回の実行で 1 回だけ出すための印
|
|
139
|
-
*/
|
|
140
|
-
export interface FieldHintState {
|
|
141
|
-
hasHinted: boolean;
|
|
142
|
-
}
|
|
143
|
-
/**
|
|
144
139
|
カスタムフィールドを順に設定し、設定できた分を 1 行の set にする。書き込みに失敗したフィールドは warning にして飛ばす。設定できたフィールドの名前を返す
|
|
145
140
|
*/
|
|
146
141
|
export declare function setIssueFields(output: Output, client: GitHubClient, config: ProjectConfig, itemId: string, target: string, fields: readonly IssueField[], hintState: FieldHintState): Promise<readonly string[]>;
|
|
@@ -15,13 +15,13 @@ import { issueReferenceToCliReference, parseIssueReference, ReferenceParseError
|
|
|
15
15
|
import { AmbiguousRepositoryError, createRepositoryReference, resolveRepository } from '../domain/repository-resolver.js';
|
|
16
16
|
import { CLOSED_HEADINGS_BY_TEMPLATE, FOLD_SUMMARY_BY_TEMPLATE, validateBodyStyle, validateClosedHeadings, validateFoldBalance, validateFoldSummaries, validateHeadingSummaries, validateSections, } from '../domain/sections.js';
|
|
17
17
|
import { gitRunnerFor } from '../infra/git.js';
|
|
18
|
-
import { GitHubAPIError
|
|
18
|
+
import { GitHubAPIError } from '../infra/github/errors.js';
|
|
19
19
|
import { requireNumber, requireString } from '../infra/github/payload.js';
|
|
20
20
|
import { readTemplateSections, templateFile } from '../infra/template-store.js';
|
|
21
|
-
import {
|
|
22
|
-
import { commandHint, hinted, inputHint, inputNameHint, joinHinted, placeholder } from './command-hint.js';
|
|
21
|
+
import { commandHint, hinted, inputHint, inputNameHint } from './command-hint.js';
|
|
23
22
|
import { stopWith } from './command-stop.js';
|
|
24
23
|
import { kindOfFailure } from './failure.js';
|
|
24
|
+
import { fieldWriteFailure } from './field-write-failure.js';
|
|
25
25
|
import { createGitHubClient } from './github-client.js';
|
|
26
26
|
import { addIssueToBoard, createIssue, setIssueField } from './issue-board.js';
|
|
27
27
|
import { USAGE_EXIT_CODE, UsageError } from './usage-error.js';
|
|
@@ -306,14 +306,6 @@ export async function addToBoardOrWarn(output, client, config, owner, repository
|
|
|
306
306
|
output.done({ verb: 'add', target: `Issue ${issuePath(owner, repository, issueNumber)} to project` });
|
|
307
307
|
return added;
|
|
308
308
|
}
|
|
309
|
-
function rereadOptionsHint() {
|
|
310
|
-
const configPath = getActiveConfigPath();
|
|
311
|
-
// projects/ の外の config は、ファイル名では project activate が見つけられない
|
|
312
|
-
const project = configPath === undefined
|
|
313
|
-
? placeholder('PROJECT')
|
|
314
|
-
: (path.dirname(configPath) === projectsDirectory() ? path.basename(configPath, '.json') : configPath);
|
|
315
|
-
return hinted `hint: if the board options were recreated, run ${commandHint(['project', 'activate'], { project })} to read their IDs again`;
|
|
316
|
-
}
|
|
317
309
|
/**
|
|
318
310
|
カスタムフィールドを順に設定し、設定できた分を 1 行の set にする。書き込みに失敗したフィールドは warning にして飛ばす。設定できたフィールドの名前を返す
|
|
319
311
|
*/
|
|
@@ -330,15 +322,7 @@ export async function setIssueFields(output, client, config, itemId, target, fie
|
|
|
330
322
|
catch (error) {
|
|
331
323
|
if (!(error instanceof GitHubAPIError))
|
|
332
324
|
throw error;
|
|
333
|
-
|
|
334
|
-
// 選択肢を作り直すと config の ID が古くなり、書き込みが落ちる。認証とレート制限の失敗は、読み直しても直らない
|
|
335
|
-
const canReread = !(error instanceof GitHubAuthError || error instanceof GitHubRateLimitError);
|
|
336
|
-
if (!canReread || hintState.hasHinted) {
|
|
337
|
-
output.warning(message);
|
|
338
|
-
continue;
|
|
339
|
-
}
|
|
340
|
-
output.warning(joinHinted([message, rereadOptionsHint()]));
|
|
341
|
-
hintState.hasHinted = true;
|
|
325
|
+
output.warning(fieldWriteFailure(`could not set ${label} of ${target}: ${error.message}`, error, hintState));
|
|
342
326
|
}
|
|
343
327
|
}
|
|
344
328
|
if (labels.length > 0)
|
|
@@ -6,6 +6,7 @@ import type { GitHubClient } from '../infra/github/index.js';
|
|
|
6
6
|
import type { BoardContext, JudgedTarget } from './board-judgment.js';
|
|
7
7
|
import type { HintedText } from './command-hint.js';
|
|
8
8
|
import type { BoardMoveLine } from './issue-board.js';
|
|
9
|
+
import type { FieldHintState } from './field-write-failure.js';
|
|
9
10
|
import type { JudgedIssue, ReadinessCache } from './issue-readiness.js';
|
|
10
11
|
import type { Output } from './output.js';
|
|
11
12
|
export interface CreatedPullRequest {
|
|
@@ -41,6 +42,10 @@ export interface WaitingOptions {
|
|
|
41
42
|
readonly check: WaitingCheck;
|
|
42
43
|
readonly isDryRun: boolean;
|
|
43
44
|
readonly cache: ReadinessCache;
|
|
45
|
+
/**
|
|
46
|
+
選択肢の ID を読み直す案内を 1 回だけ出すための印。省くと applyJudgedMoves が 1 つ作る
|
|
47
|
+
*/
|
|
48
|
+
readonly fieldHint?: FieldHintState;
|
|
44
49
|
}
|
|
45
50
|
/**
|
|
46
51
|
判定の前提のうち、issue の前提
|
|
@@ -53,7 +58,7 @@ heads を待つ Issue を読み、判定に合わせてボードの列と札を
|
|
|
53
58
|
export declare function moveIssuesWaitingFor(context: Readonly<BoardContext>, options: WaitingOptions, moves?: BoardMoveLine[]): Promise<readonly JudgedTarget[]>;
|
|
54
59
|
/**
|
|
55
60
|
pr create の後に、head の Issue を待つ Issue の列と札を動かす。作った PR が判定に出るまで 1 回だけ読み直す。
|
|
56
|
-
動かした列と札(moved: と set: の行の値)を moves
|
|
61
|
+
動かした列と札(moved: と set: の行の値)を moves に足していき、それを返す。fieldHint は、in_review の書き込みと同じ印を渡す
|
|
57
62
|
*/
|
|
58
|
-
export declare function moveWaitingIssues(out: Readonly<Output>, client: GitHubClient, config: ProjectConfig, created: CreatedPullRequest, moves?: BoardMoveLine[]): Promise<readonly BoardMoveLine[]>;
|
|
63
|
+
export declare function moveWaitingIssues(out: Readonly<Output>, client: GitHubClient, config: ProjectConfig, created: CreatedPullRequest, fieldHint: FieldHintState, moves?: BoardMoveLine[]): Promise<readonly BoardMoveLine[]>;
|
|
59
64
|
//# sourceMappingURL=pr-waiting.d.ts.map
|
|
@@ -83,7 +83,7 @@ async function moveWaiting(waiting, issues, moves) {
|
|
|
83
83
|
return [];
|
|
84
84
|
const { assume } = options.check;
|
|
85
85
|
const confirmed = assume === undefined ? judged.confirmed : await Promise.all(judged.confirmed.map(async (target) => await assume(target)));
|
|
86
|
-
await applyJudgedMoves(context, confirmed, options.isDryRun, moves);
|
|
86
|
+
await applyJudgedMoves(context, confirmed, options.isDryRun, moves, options.fieldHint);
|
|
87
87
|
for (const { target } of judged.unconfirmed)
|
|
88
88
|
context.out.warning(options.check.unconfirmed(displayReference(target.ref, context.home)));
|
|
89
89
|
return confirmed;
|
|
@@ -128,16 +128,16 @@ export async function moveIssuesWaitingFor(context, options, moves = []) {
|
|
|
128
128
|
}
|
|
129
129
|
/**
|
|
130
130
|
pr create の後に、head の Issue を待つ Issue の列と札を動かす。作った PR が判定に出るまで 1 回だけ読み直す。
|
|
131
|
-
動かした列と札(moved: と set: の行の値)を moves
|
|
131
|
+
動かした列と札(moved: と set: の行の値)を moves に足していき、それを返す。fieldHint は、in_review の書き込みと同じ印を渡す
|
|
132
132
|
*/
|
|
133
|
-
export async function moveWaitingIssues(out, client, config, created, moves = []) {
|
|
133
|
+
export async function moveWaitingIssues(out, client, config, created, fieldHint, moves = []) {
|
|
134
134
|
const context = { out, client, config, home: homeRepositoryOf(config) };
|
|
135
135
|
const head = createIssueReference(created.repository, created.issueNumber);
|
|
136
136
|
const check = {
|
|
137
137
|
isReflected: judged => created.pullRequest === undefined || (prerequisiteOf(judged, head)?.issue.pullRequests.some(pullRequest => pullRequest.number === created.pullRequest) ?? false),
|
|
138
138
|
unconfirmed: name => hinted `could not confirm that GitHub reflects PR #${String(created.pullRequest)} in the readiness of ${name}; its column was not moved; run ${commandHint(['board', 'sync'])} later to move it`,
|
|
139
139
|
};
|
|
140
|
-
await moveIssuesWaitingFor(context, { heads: [head], check, isDryRun: false, cache: createReadinessCache() }, moves);
|
|
140
|
+
await moveIssuesWaitingFor(context, { heads: [head], check, isDryRun: false, cache: createReadinessCache(), fieldHint }, moves);
|
|
141
141
|
return moves;
|
|
142
142
|
}
|
|
143
143
|
//# sourceMappingURL=pr-waiting.js.map
|
package/cli/dist/commands/pr.js
CHANGED
|
@@ -40,6 +40,7 @@ import { PR_MERGE_COMMAND } from './pr-merge.js';
|
|
|
40
40
|
import { parseReference, PR_REFERENCE_DESCRIPTION } from './pr-reference.js';
|
|
41
41
|
import { readRestackDecision } from './restack-reading.js';
|
|
42
42
|
import { moveWaitingIssues } from './pr-waiting.js';
|
|
43
|
+
import { fieldWriteFailure } from './field-write-failure.js';
|
|
43
44
|
export { parseReference, PR_REFERENCE_DESCRIPTION } from './pr-reference.js';
|
|
44
45
|
// 本文の検証の失敗。1(通信・設定・引数)と 2(preflight)と区別する
|
|
45
46
|
const VALIDATION_EXIT_CODE = 3;
|
|
@@ -144,8 +145,8 @@ const PR_CREATE_OUTPUT = z.strictObject({
|
|
|
144
145
|
function inReviewOperation(issueNumber) {
|
|
145
146
|
return { verb: 'set', target: `Issue #${String(issueNumber)} status to In Review` };
|
|
146
147
|
}
|
|
147
|
-
// Status を In Review にした Issue の番号を返す。書かなかったら undefined
|
|
148
|
-
async function updateIssueStatusToInReview(config, client, location, headBranch, out) {
|
|
148
|
+
// Status を In Review にした Issue の番号を返す。書かなかったら undefined。hintState は待ちの Issue の書き込みと同じ印
|
|
149
|
+
async function updateIssueStatusToInReview(config, client, location, headBranch, out, hintState) {
|
|
149
150
|
const issueNumber = extractIssueNumberFromBranch(headBranch);
|
|
150
151
|
if (issueNumber === undefined)
|
|
151
152
|
return undefined;
|
|
@@ -176,7 +177,8 @@ async function updateIssueStatusToInReview(config, client, location, headBranch,
|
|
|
176
177
|
await client.updateProjectItemField(config.project.id, itemId, fieldId, optionId);
|
|
177
178
|
}
|
|
178
179
|
catch (error) {
|
|
179
|
-
|
|
180
|
+
const message = `status update of ${label} failed: ${reasonOf(error)}`;
|
|
181
|
+
out.warning(error instanceof GitHubAPIError ? fieldWriteFailure(message, error, hintState) : message);
|
|
180
182
|
return;
|
|
181
183
|
}
|
|
182
184
|
out.done(inReviewOperation(issueNumber));
|
|
@@ -342,9 +344,9 @@ async function registerStack(client, location, lower, created, out) {
|
|
|
342
344
|
}
|
|
343
345
|
}
|
|
344
346
|
// moves に、書けた列と札を足していく。例外で止まっても、それまでの分が残る
|
|
345
|
-
async function moveWaitingIssuesSafely(client, config, location, issueNumber, pullRequest, out, moves) {
|
|
347
|
+
async function moveWaitingIssuesSafely(client, config, location, issueNumber, pullRequest, out, moves, hintState) {
|
|
346
348
|
try {
|
|
347
|
-
await moveWaitingIssues(out, client, config, { repository: location, issueNumber, pullRequest }, moves);
|
|
349
|
+
await moveWaitingIssues(out, client, config, { repository: location, issueNumber, pullRequest }, hintState, moves);
|
|
348
350
|
}
|
|
349
351
|
catch (error) {
|
|
350
352
|
if (!isRequestFailure(error))
|
|
@@ -369,7 +371,9 @@ async function submitPullRequest(config, client, directory, draft, stackOn, base
|
|
|
369
371
|
const url = jsonField(created, 'html_url');
|
|
370
372
|
// url は先に渡す。後の処理が例外で止まっても、作った PR を結果から読める
|
|
371
373
|
out.result({ head: draft.head, base: draft.base, title: draft.title, ...pullRequest !== undefined && { number: pullRequest }, ...typeof url === 'string' && { url } });
|
|
372
|
-
|
|
374
|
+
// in_review と待ちの Issue の書き込みで、選択肢の ID を読み直す案内を 1 回だけ出す
|
|
375
|
+
const fieldHint = { hasHinted: false };
|
|
376
|
+
const inReview = draft.isRelease ? undefined : await updateIssueStatusToInReview(config, client(), draft.location, draft.head, out, fieldHint);
|
|
373
377
|
if (inReview !== undefined)
|
|
374
378
|
out.result({ inReview });
|
|
375
379
|
if (stackOn !== undefined)
|
|
@@ -378,7 +382,7 @@ async function submitPullRequest(config, client, directory, draft, stackOn, base
|
|
|
378
382
|
const moves = [];
|
|
379
383
|
try {
|
|
380
384
|
if (!draft.isRelease && isPositive(issueNumber))
|
|
381
|
-
await moveWaitingIssuesSafely(client(), config, draft.location, issueNumber, pullRequest, out, moves);
|
|
385
|
+
await moveWaitingIssuesSafely(client(), config, draft.location, issueNumber, pullRequest, out, moves, fieldHint);
|
|
382
386
|
}
|
|
383
387
|
finally {
|
|
384
388
|
out.result({ moves: moves.map(move => moveJson(move)) });
|
|
@@ -12,6 +12,7 @@ import { defineCommand } from './command-definition.js';
|
|
|
12
12
|
import { commandHint, hinted, joinHinted } from './command-hint.js';
|
|
13
13
|
import { requireActiveConfig, stopWith } from './command-stop.js';
|
|
14
14
|
import { kindOfFailure } from './failure.js';
|
|
15
|
+
import { fieldWriteFailure } from './field-write-failure.js';
|
|
15
16
|
import { createGitHubClient } from './github-client.js';
|
|
16
17
|
import { USAGE_EXIT_CODE } from './usage-error.js';
|
|
17
18
|
import { requireRepositoryMatch, resolveCurrentRepository } from './repository-match.js';
|
|
@@ -93,7 +94,15 @@ async function setIssueStatusActive(out, client, config, issue) {
|
|
|
93
94
|
out.warning(`could not set ${target}: the workflow status field has no 'active' option`);
|
|
94
95
|
return;
|
|
95
96
|
}
|
|
96
|
-
|
|
97
|
+
try {
|
|
98
|
+
await client.updateProjectItemField(config.project.id, itemId, fieldId, optionId);
|
|
99
|
+
}
|
|
100
|
+
catch (error) {
|
|
101
|
+
if (!(error instanceof GitHubAPIError))
|
|
102
|
+
throw error;
|
|
103
|
+
out.warning(fieldWriteFailure(`could not set ${target}: ${error.message}`, error));
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
97
106
|
out.done({ verb: 'set', target });
|
|
98
107
|
}
|
|
99
108
|
catch (error) {
|
|
@@ -66,8 +66,7 @@ async function applyChanges(out, input) {
|
|
|
66
66
|
out.done(operation);
|
|
67
67
|
const created = requireNumber(issue['number'], 'number');
|
|
68
68
|
out.result({ tracker: created, created: true, added: rows.added });
|
|
69
|
-
await putOnBoard(client, config, owner, repository, created, PRIORITY, { onlyIfEmpty: false });
|
|
70
|
-
return 0;
|
|
69
|
+
return await putOnBoard(out, client, config, owner, repository, created, PRIORITY, { onlyIfEmpty: false });
|
|
71
70
|
}
|
|
72
71
|
if (!isUnchanged) {
|
|
73
72
|
try {
|
|
@@ -102,8 +101,7 @@ async function applyChanges(out, input) {
|
|
|
102
101
|
return 0;
|
|
103
102
|
}
|
|
104
103
|
// 作った後にボード登録が失敗した実行を直す。Status・Priority は空のときだけ入れる
|
|
105
|
-
await putOnBoard(client, config, owner, repository, number, PRIORITY, { onlyIfEmpty: true });
|
|
106
|
-
return 0;
|
|
104
|
+
return await putOnBoard(out, client, config, owner, repository, number, PRIORITY, { onlyIfEmpty: true });
|
|
107
105
|
}
|
|
108
106
|
catch (error) {
|
|
109
107
|
const detail = apiErrorDetail(error);
|
|
@@ -85,8 +85,7 @@ async function applyChanges(out, input) {
|
|
|
85
85
|
out.done(operation);
|
|
86
86
|
const created = requireNumber(issue['number'], 'number');
|
|
87
87
|
out.result({ tracker: created, created: true, added: rows.added });
|
|
88
|
-
await putOnBoard(client, config, owner, repository, created, priority, { onlyIfEmpty: false });
|
|
89
|
-
return 0;
|
|
88
|
+
return await putOnBoard(out, client, config, owner, repository, created, priority, { onlyIfEmpty: false });
|
|
90
89
|
}
|
|
91
90
|
let failures = 0;
|
|
92
91
|
let isUpdated = true;
|
|
@@ -110,7 +109,7 @@ async function applyChanges(out, input) {
|
|
|
110
109
|
out.result(rows);
|
|
111
110
|
}
|
|
112
111
|
// 作った後にボード登録が失敗した実行を直す。Status・Priority は空のときだけ入れる
|
|
113
|
-
await putOnBoard(client, config, owner, repository, number, priority, { onlyIfEmpty: true });
|
|
112
|
+
failures += await putOnBoard(out, client, config, owner, repository, number, priority, { onlyIfEmpty: true });
|
|
114
113
|
return failures;
|
|
115
114
|
}
|
|
116
115
|
catch (error) {
|
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pecot/workflow-mcp",
|
|
3
|
-
"version": "7.0.1-dev.
|
|
3
|
+
"version": "7.0.1-dev.27",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "@pecot/workflow-mcp",
|
|
9
|
-
"version": "7.0.1-dev.
|
|
9
|
+
"version": "7.0.1-dev.27",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@modelcontextprotocol/server": "^2.4.0",
|